@coralai/sps-cli 0.65.23 → 0.65.25
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/dist/console-assets/assets/{ShowcasePage-DlksLyHb.js → ShowcasePage-C-Qcrrsm.js} +1 -1
- package/dist/console-assets/assets/index-5SxV_3Ku.css +1 -0
- package/dist/console-assets/assets/{index-CZhMVChp.js → index-Cs0N0RAL.js} +5 -5
- package/dist/console-assets/index.html +2 -2
- package/dist/daemon/daemonEnv.d.ts.map +1 -1
- package/dist/daemon/daemonEnv.js +4 -0
- package/dist/daemon/daemonEnv.js.map +1 -1
- package/dist/daemon/sessionDaemon.d.ts.map +1 -1
- package/dist/daemon/sessionDaemon.js +23 -4
- package/dist/daemon/sessionDaemon.js.map +1 -1
- package/package.json +1 -1
- package/dist/console-assets/assets/index-BLzc86Oa.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-C-Qcrrsm.js","assets/ShowcasePage-EkuegwaP.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var Fz=Object.defineProperty;var oN=e=>{throw TypeError(e)};var $z=(e,t,n)=>t in e?Fz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var lN=(e,t,n)=>$z(e,typeof t!="symbol"?t+"":t,n),xb=(e,t,n)=>t.has(e)||oN("Cannot "+n);var ee=(e,t,n)=>(xb(e,t,"read from private field"),n?n.call(e):t.get(e)),nt=(e,t,n)=>t.has(e)?oN("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Be=(e,t,n,i)=>(xb(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),kt=(e,t,n)=>(xb(e,t,"access private method"),n);var Ih=(e,t,n,i)=>({set _(s){Be(e,t,s,n)},get _(){return ee(e,t,i)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function nf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vb={exports:{}},Wu={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -469,8 +469,8 @@ Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}
|
|
|
469
469
|
* This source code is licensed under the ISC license.
|
|
470
470
|
* See the LICENSE file in the root directory of this source tree.
|
|
471
471
|
*/const C6=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vn=Pe("x",C6),T6={"sidebar.collapse":"Collapse","sidebar.expand":"Expand","nav.home":"Home","nav.projects":"Projects","nav.board":"Board","nav.skills":"Skills","nav.system":"System","nav.memory":"Memory","nav.plugins":"Plugins","plugins.h1":"Plugins","plugins.desc":"Global plugin toggles. Applies to newly dispatched cards.","plugins.tab.memory":"Memory","plugins.tab.channel":"Channel","plugins.tab.model":"Model","plugins.tab.tool":"Tool","plugins.comingSoon":"Coming soon","nav.arrange":"Arrange","flow.addNode":"Add node","flow.tidy":"Tidy: re-layout cards by execution order + rebuild default links","flow.pickProject":"Pick a project to edit its flow. Each project has its own DAG (saved to the project).","flow.run":"Compile & run","flow.running":"Starting…","flow.pipelineRunning":"Running…","flow.node.default":"Task","flow.confirm.deleteTitle":"Delete card?","flow.confirm.deleteBody":"Delete card #{seq}. Undo with Ctrl/Cmd+Z.","flow.node.close":"Close","flow.node.title":"Title","flow.node.desc":"Description (what the worker does)","flow.node.skills":"Skills","flow.node.save":"Save","flow.node.delete":"Delete node","flow.hint":"Nodes are the project’s cards. Click to select (Delete removes card/edge), double-click to edit, drag from a handle to connect, drop a card onto an edge to insert it between. Run promotes staged cards and starts the pipeline; status updates live.","flow.mode.aria":"Switch view mode","flow.pending.create":"New card","flow.mode.free":"Free","flow.mode.lanes":"Lanes","flow.lane.wave":"Wave {n}","flow.lane.parallel":"{n} in parallel","flow.lane.applying":"Writing execution order…","flow.lane.orderTip":"Execution wave (order): same wave runs in parallel; a wave starts only after the previous one fully completes","flow.lane.hint":"Boxes are execution waves (written to card order — this IS the real run order): cards inside a box run in parallel, boxes run left to right, and a wave starts only after the previous one is fully Done; edges are wave dependencies, colored/animated by live status. Drag a card into another box to join that wave, into a gap to make a new wave. Click a card to edit.","flow.err.noProject":"Pick a project first.","flow.err.noNodes":"Add at least one node.","flow.status.creating":"Preparing cards","flow.status.starting":"Starting pipeline…","flow.status.done":"Created {n} cards · pipeline started","flow.goBoard":"Open board","nav.aria":"Main navigation","home.inputToggle":"Toggle voice / text input","home.copy":"Copy","home.play":"Play","home.stop":"Stop","home.artifacts.label":"Artifacts","home.sessions.tabAll":"All","home.sessions.expandWeek":"Show older than 7 days ({count})","home.sessions.expandMonth":"Show older than a month ({count})","home.sessions.collapseOld":"Hide older sessions","home.sessions.open":"Show conversations","home.sessions.collapse":"Hide conversations","home.sessions.delete":"Delete conversation","home.sessions.deleteConfirm":"Delete this conversation? This cannot be undone.","home.interrupt":"Stop","home.attach.remove":"Remove attachment","home.text.placeholder":"Type a message…","home.text.send":"Send","home.attach":"Attach file","home.text.hint":"Enter to send · Shift+Enter for newline","home.auto.toggle":"Auto listen","home.auto.tip":"Auto listen: starts when you speak; stops after 2s of silence.","home.auto.armedOpen":"Armed — just start talking","home.conversation.empty":"Select the voice orb below to begin","home.conversation.you":"You","home.conversation.ai":"AI","home.conversation.listening":"Listening…","home.conversation.thinking":"Thinking","home.debug.close":"Close debug panel","home.voice.start":"Start listening","home.voice.stop":"Stop listening","home.voice.finish":"Select again to finish","home.voice.idle":"Tap the orb or press Space to begin","home.voice.listening":"Listening","home.voice.thinking":"Thinking","home.voice.speaking":"Speaking","home.error.recognitionUnsupported":"Speech recognition is not supported by this browser.","home.error.recognition":"No usable speech was recognized. Please try again.","home.error.response":"The AI response failed. Please try again.","home.phase.aria":"Voice interaction state","home.phase.idle":"Idle","home.phase.listening":"Listening","home.phase.thinking":"Thinking","home.phase.speaking":"Speaking","home.visualizer.aria":"Flow voice field","home.mic.requesting":"Connecting microphone","home.message.speaking":"I have the direction. Let us move into the first step.","home.customize.title":"Customize","home.customize.reset":"Reset parameters","home.customize.colors":"Colors","home.customize.parameters":"Parameters","home.customize.color1":"Color 1","home.customize.color2":"Color 2","home.customize.color3":"Color 3","home.customize.count":"Count","home.customize.speed":"Speed","home.customize.amplitude":"Amplitude","home.customize.waviness":"Waviness","home.customize.thickness":"Thickness","home.customize.glow":"Glow","home.customize.taper":"Taper","home.customize.spread":"Spread","home.customize.hueShift":"Hue shift","home.customize.intensity":"Intensity","home.customize.saturation":"Saturation","home.customize.opacity":"Opacity","home.customize.scale":"Scale","processes.title":"Processes","processes.refresh":"Refresh","processes.col.kind":"Type","processes.col.slot":"Slot","processes.col.project":"Project","processes.col.state":"State","processes.col.memory":"Memory","processes.col.action":"Action","processes.empty":"No SPS processes","processes.kind.all":"All types","processes.kind.worker":"Worker","processes.kind.chat":"Chat","processes.kill":"Kill","processes.killConfirm":"Kill process {slot}?","audit.title":"Audit Log","audit.refresh":"Refresh","audit.filter.all":"All","audit.action.create":"Create","audit.action.modify":"Modify","audit.action.delete":"Delete","audit.action.daemon":"Daemon","audit.col.time":"Time","audit.col.action":"Action","audit.col.project":"Project","audit.col.detail":"Detail","audit.empty":"No audit records","lang.toggle.aria":"Switch interface language","lang.en":"EN","lang.zh":"中","theme.toggle.aria":"Switch theme","theme.dark":"Dark theme","theme.light":"Light theme","status.server":"server","status.offline":"offline","status.sse.open":"SSE","status.sse.connecting":"SSE connecting","status.sse.down":"SSE·down","status.pipelines.tooltip":"Active pipelines","status.workers.tooltip":"Active workers","status.pipeline.unit":"pipeline","status.worker.unit":"worker","common.save":"Save","common.cancel":"Cancel","common.delete":"Delete","common.create":"Create","common.edit":"Edit","common.close":"Close","common.loading":"Loading…","common.retry":"Retry","common.yes":"Yes","common.no":"No","projects.title":"Projects","projects.count":"{count} local project(s)","projects.new":"New project","projects.selectHint":"Select a project on the left to see its details.","projects.sort.label":"Sort by","projects.sort.activity":"Activity","projects.sort.date":"Modified","projects.sort.name":"Name","projects.load.failed":"Failed to load","projects.empty.title":"No projects yet","projects.empty.hint":"Run {cmd} to create your first project.","newProject.title":"New project","newProject.field.name":"Project name","newProject.field.dir":"Project directory","newProject.submit":"Create project","newProject.creating":"Creating…","newProject.dir.browse":"Browse","newProject.dir.browseAria":"Pick directory","newProject.back":"Back","newProject.back.aria":"Back to projects","newProject.field.name.placeholder":"e.g. acme-web","newProject.field.name.invalid":"Name only allows a-z A-Z 0-9 _ -","newProject.field.dir.long":"Absolute path of the PROJECT directory. The selected directory is the project root; project name defaults to the directory name. Has code → adopt (only adds .claude/ config, never touches source); empty → create new.","newProject.field.dir.placeholder":"/home/you/projects/my-app","newProject.field.dir.createIfMissing":"Auto-create if missing (recommended — otherwise .claude/ install gets skipped)","newProject.field.dir.pickerTitle":"Pick project directory","newProject.field.dir.adopt":"Existing content detected → will adopt (config only, source untouched)","newProject.field.dir.fresh":"Empty directory → create new project","newProject.field.name.derived":"Project name (defaults to directory name, editable)","newProject.field.maxWorkers.short":"Max workers","newProject.field.ackTimeout.minutes":"ACK timeout (min)","newProject.field.ackTimeout.minutes.help":"How long after dispatch before the worker is considered failed if no ACK","newProject.field.git.label":"Enable Git (worker auto commit + push)","newProject.field.git.detail":"When off, the worker only does the task, no version control — fits docs / data-processing non-code projects.","newProject.field.review.label":"Enable checklist review (independent agent verifies each finished card)","newProject.field.review.detail":"When on: cards carrying a checklist are verified item-by-item against the real output by an independent reviewer after the worker finishes; all-pass stays Done, any fail auto-inserts a priority fix card. Cards without a checklist are not reviewed. Write acceptance points with --checklist when creating cards.","newProject.field.git.branch":"Merge branch","newProject.field.gitlabProject.label":"Git remote project path","newProject.field.gitlabProject.help2":"Like user/repo. Empty = skip remote API (commit/push local only)","newProject.field.gitlabProject.placeholder":"user/repo","newProject.field.gitlabProjectId":"GitLab project ID","newProject.field.gitlabProjectId.help":"Number; leave blank for GitHub","newProject.field.gitlabProjectId.placeholder":"42","newProject.section.notifications":"Notifications","newProject.field.matrixRoom.label":"Matrix room ID","newProject.field.matrixRoom.help2":"Empty = use global config; blank = no notifications","newProject.field.matrixRoom.placeholder":"!abc:matrix.example.com","newProject.error.create.title":"Create failed","projectDetail.tab.pipeline":"Pipeline","projectDetail.tab.conf":"Conf","projectDetail.tab.delete":"Delete project","projectDetail.tab.overview":"Overview","projectDetail.tab.config":"Config","projectDetail.tab.pipelines":"Pipelines","projectDetail.tab.danger":"Danger zone","projectDetail.openBoard":"Board","projectDetail.overview.repoDir":"Repo path","projectDetail.overview.pmBackend":"PM backend","projectDetail.overview.agent":"Agent","projectDetail.overview.cards":"Cards","projectDetail.overview.cards.value":"{total} total · {inprogress} in progress · {done} done","projectDetail.overview.workers":"Workers","projectDetail.overview.workers.value":"{total} total ({active} active)","projectDetail.overview.pipeline":"Pipeline","projectDetail.overview.lastActivity":"Last activity","projectDetail.overview.notFound":"Project {name} not found or unreadable.","projectDetail.config.confDirty":"● Unsaved changes","projectDetail.config.reload":"Reload","projectDetail.config.save":"Save","projectDetail.config.saveAria":"Save config","projectDetail.config.settingsAria":"Project configuration settings","projectDetail.config.option.empty":"Not set","projectDetail.config.section.basic":"Project","projectDetail.config.section.basic.hint":"Identity and local repository path.","projectDetail.config.section.git":"Git","projectDetail.config.section.git.hint":"Remote repository and merge behavior.","projectDetail.config.section.pipeline":"Pipeline","projectDetail.config.section.pipeline.hint":"Execution mode, card labels, and review agents.","projectDetail.config.section.worker":"Worker","projectDetail.config.section.worker.hint":"Worker runtime, slots, and fallback skills.","projectDetail.config.section.policies":"Policies","projectDetail.config.section.policies.hint":"Timeouts, conflict handling, memory, and notifications.","projectDetail.config.section.custom":"Additional variables","projectDetail.config.section.custom.hint":"Unknown conf variables are preserved here.","projectDetail.config.custom.empty":"No additional variables.","projectDetail.config.custom.keyPlaceholder":"CUSTOM_KEY","projectDetail.config.custom.valuePlaceholder":"value","projectDetail.config.custom.keyAria":"New variable key","projectDetail.config.custom.valueAria":"Value for {key}","projectDetail.config.custom.newValueAria":"New variable value","projectDetail.config.custom.removeAria":"Remove {key}","projectDetail.config.custom.add":"Add","projectDetail.config.disabled.requiresReviewerConsumer":"Only used by SmartArrange or checklist review. Enable one of them before setting this model.","projectDetail.config.field.PROJECT_NAME":"Project name","projectDetail.config.field.PROJECT_NAME.help":"Internal project id.","projectDetail.config.field.PROJECT_DIR":"Project directory","projectDetail.config.field.PROJECT_DIR.help":"Absolute path to the code repository.","projectDetail.config.field.PROJECT_DIR.browse":"Browse","projectDetail.config.field.PROJECT_DIR.browseAria":"Pick project directory","projectDetail.config.field.PROJECT_DIR.pickerTitle":"Pick project directory","projectDetail.config.field.GIT_HOST":"Git host","projectDetail.config.field.GIT_HOST.help":"Optional override; otherwise SPS detects from the repo remote.","projectDetail.config.field.GITLAB_PROJECT":"Remote project","projectDetail.config.field.GITLAB_PROJECT.help":"Repository path, such as user/repo.","projectDetail.config.field.GITLAB_PROJECT_ID":"GitLab project ID","projectDetail.config.field.GITLAB_PROJECT_ID.help":"Numeric GitLab id; leave blank for GitHub or auto resolution.","projectDetail.config.field.GITLAB_MERGE_BRANCH":"Merge branch","projectDetail.config.field.GITLAB_MERGE_BRANCH.help":"Target branch for worker commits or merge requests.","projectDetail.config.field.MR_MODE":"Merge request mode","projectDetail.config.field.MR_MODE.help":"none pushes directly; create opens a merge request.","projectDetail.config.field.PIPELINE_LABEL":"Pipeline label","projectDetail.config.field.PIPELINE_LABEL.help":"Cards need this label to enter the project pipeline.","projectDetail.config.field.SPS_REVIEW":"Checklist review","projectDetail.config.field.SPS_REVIEW.help":"When enabled, completed cards with checklists are reviewed by a separate reviewer.","projectDetail.config.field.WORKER_MODEL":"Worker model","projectDetail.config.field.WORKER_MODEL.help":"Project-level worker model override; blank uses the global default.","projectDetail.config.field.SA_REVIEWER_MODEL":"Reviewer model","projectDetail.config.field.SA_REVIEWER_MODEL.help":"Project-level reviewer model override for review and SmartArrange.","projectDetail.config.field.WORKER_TRANSPORT":"Worker transport","projectDetail.config.field.WORKER_TRANSPORT.help":"Runtime transport. acp-sdk is the supported value.","projectDetail.config.field.MAX_CONCURRENT_WORKERS":"Worker slots","projectDetail.config.field.MAX_CONCURRENT_WORKERS.help":"Maximum number of concurrent workers.","projectDetail.config.field.MAX_ACTIONS_PER_TICK":"Actions per tick","projectDetail.config.field.MAX_ACTIONS_PER_TICK.help":"How many new tasks a tick may claim.","projectDetail.config.field.DEFAULT_WORKER_SKILLS":"Default skills","projectDetail.config.field.DEFAULT_WORKER_SKILLS.help":"Comma-separated fallback skills when a card has no profile or skills.","projectDetail.config.field.WORKTREE_DIR":"Worktree directory","projectDetail.config.field.WORKTREE_DIR.help":"Optional worker scratch/worktree root.","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS":"In-progress timeout","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS.help":"Hours before monitor marks stale runtime.","projectDetail.config.field.WORKER_ACK_TIMEOUT_S":"ACK timeout","projectDetail.config.field.WORKER_ACK_TIMEOUT_S.help":"Seconds to wait for a worker STARTED label after dispatch.","projectDetail.config.field.WORKER_ACK_MAX_RETRIES":"ACK retries","projectDetail.config.field.WORKER_ACK_MAX_RETRIES.help":"Maximum retry count after ACK timeout.","projectDetail.config.field.MONITOR_AUTO_QA":"Auto QA","projectDetail.config.field.MONITOR_AUTO_QA.help":"Automatically move stale runtime to QA when monitor detects it.","projectDetail.config.field.CONFLICT_DEFAULT":"Conflict default","projectDetail.config.field.CONFLICT_DEFAULT.help":"Fallback policy for cards without conflict labels.","projectDetail.config.field.ENABLE_MEMORY":"Memory","projectDetail.config.field.ENABLE_MEMORY.help":"Disable to skip memory write instructions in prompts.","projectDetail.config.field.WIKI_ENABLED":"Wiki context","projectDetail.config.field.WIKI_ENABLED.help":"Inject wiki context when project wiki files exist.","projectDetail.config.field.MATRIX_ROOM_ID":"Matrix room","projectDetail.config.field.MATRIX_ROOM_ID.help":"Project-level Matrix notification room override.","projectDetail.config.field.COMPLETION_SIGNAL":"Completion signal","projectDetail.config.field.COMPLETION_SIGNAL.help":"Word the stop hook listens for.","projectDetail.config.error.conflict.title":"Config was modified elsewhere","projectDetail.config.error.conflict.body":"The conf file was changed while you were editing. Click Reload, then re-edit.","projectDetail.config.error.save.title":"Save failed","projectDetail.config.error.load":"Load failed: {detail}","projectDetail.pipelines.title":"Pipelines","projectDetail.pipelines.add":"New pipeline","projectDetail.pipelines.empty":'No pipeline files yet. Click "New pipeline" to start.',"projectDetail.pipelines.activeBadge":"active","projectDetail.pipelines.edit":"Edit","projectDetail.pipelines.editAria":"Edit {name}","projectDetail.pipelines.switch":"Switch","projectDetail.pipelines.switchAria":"Switch to {name}","projectDetail.pipelines.switch.confirm.title":"Switch to {name}","projectDetail.pipelines.switch.confirm.body":"The current project.yaml will be overwritten with the contents of {name}. Continue?","projectDetail.pipelines.switch.confirm.button":"Switch","projectDetail.pipelines.switch.error":"Switch failed","projectDetail.pipelines.delete.confirm.title":"Delete {name}","projectDetail.pipelines.delete.confirm.body":"This pipeline file will be permanently deleted.","projectDetail.pipelines.delete.error":"Delete failed","projectDetail.pipelines.deleteAria":"Delete {name}","projectDetail.pipelines.create.error":"Create failed","projectDetail.danger.title":"Delete project","projectDetail.danger.body":"This clears {path} (all cards, runtime, logs).","projectDetail.danger.includeClaude.label":"Also clear repo's .claude/","projectDetail.danger.includeClaude.note":"The repo itself is untouched; only this directory is cleaned.","projectDetail.danger.deleteWorkspace.label":"Delete the entire workspace directory","projectDetail.danger.deleteWorkspace.note":"⚠️ Permanently deletes the code/artifacts too — not recoverable. Unchecked = only remove sps config, keep the directory.","projectDetail.danger.confirmPrompt":"Type the project name {name} to confirm:","projectDetail.danger.deleteAria":"Permanently delete project","projectDetail.danger.deleteButton":"Permanently delete","projectDetail.danger.deleted.title":"Deleted","projectDetail.danger.deleted.bodyWithList":`Project deleted. Also cleaned up:
|
|
472
|
-
{paths}`,"projectDetail.danger.deleted.body":"Project deleted.","projectDetail.danger.error":"Delete failed","pipelineEditor.close":"Close","pipelineEditor.error.conflict.title":"File was modified elsewhere","pipelineEditor.error.yaml.title":"YAML syntax error","pipelineEditor.error.save.title":"Save failed","pipelineEditor.error.serialize.title":"YAML serialize failed","pipelineEditor.error.load":"Load failed: {detail}","pipelineEditor.mode.structured":"Structured","pipelineEditor.mode.yaml":"Raw YAML","pipelineEditor.parseError.prefix":"YAML parse: {detail}","pipelineEditor.activeWarning":"⚠ This is the active pipeline — saving will take effect on the next tick","pipelineEditor.yamlAria":"pipeline YAML editor","pipelineEditor.status.unsaved":"● Unsaved","pipelineEditor.status.saved":"Saved","pipelineEditor.status.noChanges":"No changes","pipelineEditor.reload":"Reload","pipelineEditor.save":"Save","pipelineEditor.saveAria":"Save pipeline","pipelineEditor.activeBadge":"active","pipelineEditor.modeHint":"project = event-driven pipeline (default) · steps = sequential script","pipelineEditor.stages.heading":"Stages ({count})","pipelineEditor.stages.add":"Add stage","pipelineEditor.stages.empty":'No stages yet. Click "Add stage" to start.',"pipelineEditor.stage.name.hint":"Unique stage name","pipelineEditor.stage.profile.hint":"skill profile, may be empty","pipelineEditor.stage.cardState.hint":"Card state during this stage","pipelineEditor.stage.timeout.hint":"Optional, e.g. 30m 2h","pipelineEditor.stage.trigger.hint":"Trigger condition, blank uses default","pipelineEditor.stage.onComplete.hint":"Action on success","pipelineEditor.stage.onFail.action.hint":"Action on failure, e.g. label NEEDS-FIX","pipelineEditor.stage.onFail.comment.hint":"Comment written on the card","pipelineEditor.stage.halt.note":"(stops pipeline on failure; uncheck to continue with next card)","pipelineEditor.stage.moveUp":"Move up","pipelineEditor.stage.moveDown":"Move down","pipelineEditor.stage.remove":"Remove stage","newPipelineDialog.title":"New pipeline","newPipelineDialog.field.filename.label":"Filename","newPipelineDialog.field.filename.placeholder":"e.g. ci","newPipelineDialog.field.filename.help":"Will be saved as {filename}. Only a-z A-Z 0-9 _ - allowed; an existing file errors 409.","newPipelineDialog.section.template":"Initial content","newPipelineDialog.template.blank.label":"Blank template","newPipelineDialog.template.blank.desc":"Minimal 1-stage pipeline (develop → Done)","newPipelineDialog.template.sample.label":"Tutorial template","newPipelineDialog.template.sample.desc":"Copied from sample.yaml.example (annotated, every field explained)","newPipelineDialog.template.sample.unavailable":"sample.yaml.example does not exist","newPipelineDialog.template.active.label":"Copy current active","newPipelineDialog.template.active.desc":"Copied from project.yaml (build on the current config)","newPipelineDialog.template.active.unavailable":"project.yaml does not exist","newPipelineDialog.create.aria":"Create pipeline","board.title":"Board","board.title.bare":"Board","board.subtitle":"{name} · {cards} cards · {workers} workers active","board.pickPrompt.title":"Pick a project","board.pickPrompt.body":"The board is per-project. Pick one to start:","board.action.start":"Start","board.action.stop":"Stop","board.action.startAria":"Start pipeline","board.action.stopAria":"Stop pipeline","board.action.startError":"Failed to start pipeline","board.action.stopError":"Failed to stop pipeline","board.action.reset":"Reset","board.action.resetError":"Reset failed","board.action.reset.confirm.title":"Reset the entire pipeline","board.action.reset.confirm.body":"This clears all cards’ run state, worker markers, and branches. Cannot be undone.","board.action.reset.confirm.button":"Reset all","board.action.newCard":"New card","board.action.newCard.error":"Failed to create card","board.action.moveCard.error":"Failed to move card","board.search.placeholder":"Search title / skill / label…","board.search.aria":"Search cards","board.filter.clear":"Clear","board.filter.clearAria":"Clear filters","board.filter.aria":"Filter by {label}","board.filter.clearSelection":"Clear selection","board.error.loadCards":"Failed to load cards","board.col.planning":"Planning","board.col.backlog":"Backlog","board.col.todo":"Todo","board.col.inprogress":"Inprogress","board.col.qa":"QA / Review","board.col.done":"Done","kanban.checklist.label":"Checklist {done}/{total}","kanban.checklist.more":"… {count} more","kanban.column.empty":"— empty —","kanban.time.justNow":"just now","kanban.time.minutes":"{n}m ago","kanban.time.hours":"{n}h ago","newCard.title":"New card","newCard.field.title":"Title *","newCard.field.title.placeholder":"e.g. Add GitHub OAuth login","newCard.field.title.help":"Short, clear goal (<200 chars)","newCard.field.description":"Description","newCard.field.description.placeholder":"User story, requirements, acceptance criteria, references… Claude reads this when starting","newCard.field.description.help":"Markdown supported. If empty, Claude only sees the title.","newCard.field.skills":"Skills","newCard.field.skills.help":"Pick which skills get loaded (via frontmatter `skills:`). Optional — worker falls back to project-level skills.","newCard.field.skills.loading":"Loading skills…","newCard.field.skills.error":"Failed to load skills (creation still works): {detail}","newCard.field.skills.selected":"{count} selected: {names}","newCard.field.dispatch":"Dispatch","newCard.field.dispatch.label":"Dispatch immediately (go straight to Backlog)","newCard.field.dispatch.help":"Default off: card lands in Planning to wait; drag to Backlog when ready. On: skip Planning, the next tick assigns a worker.","newCard.create.aria":"Create card","cardDetail.save":"Save","logs.scroll.bottom.aria":"Scroll to bottom","logs.filter.keyword.placeholder":"Filter keyword…","logs.filter.keyword.aria":"Filter logs","logs.empty.match":"No matching logs","skills.category.all":"All","skills.category.language":"language","skills.category.domain":"domain","skills.category.persona":"persona","skills.category.workflow":"workflow","skills.category.engine":"engine","skills.category.genre":"genre","skills.category.platform":"platform","skills.category.review":"review","skills.category.meta":"meta","skills.category.other":"other","skills.tags.title":"Tags","skills.tags.clear":"Clear","skills.subtitleCount":"{count} user-level skill(s)","skills.search.placeholder":"Search skill…","skills.search.aria":"Search skill","skillDetail.close.aria":"Close","skillDetail.loading":"Loading…","skillDetail.error.load":"Load failed: {detail}","skillDetail.section.preview":"SKILL.md preview","skillDetail.toggleSection.aria":"{action} {file}","skillDetail.expand":"Expand","skillDetail.collapse":"Collapse","skillDetail.edit":"Edit","skillDetail.translate":"ZH/EN","skillDetail.delete":"Delete","skillDetail.save":"Save","skillDetail.cancel":"Cancel","skillDetail.translating":"Translating…","skillDetail.saving":"Saving…","skillDetail.editHint":"Edit the raw SKILL.md (incl. frontmatter). After saving, run `sps skill lint` to check the taxonomy & format.","skillDetail.deleteConfirm":'Delete "{name}" from the library? The whole directory is removed — this cannot be undone.',"skillDetail.translateFailed":"Translate failed: {detail}","skillDetail.saveFailed":"Save failed: {detail}","skillDetail.deleteFailed":"Delete failed: {detail}","system.h1":"System","system.tab.config":"Global Config","system.tab.processes":"Processes","system.tab.doctor":"Diagnostics","system.tab.audit":"Audit Log","system.upgrade.upToDate":"Already up to date ({version})","system.memory.title":"Memory backend","system.memory.desc":"Global setting: which backend workers read/write memory through. Applies to newly dispatched cards.","system.memory.provider":"Backend","system.memory.url":"Custom URL","system.memory.url.placeholder":"http://127.0.0.1:3111","system.memory.save":"Save","system.memory.save.aria":"Save memory backend setting","system.memory.saved":"Saved","system.memory.error":"Save failed","system.env.warning":"⚠ This file contains plaintext credentials. Keep mode 0600 on save.","system.env.settingsAria":"Global configuration settings","system.env.dirtyMark":" · ● Unsaved","system.env.save":"Save","system.env.save.aria":"Save env","system.env.section.git":"Git","system.env.section.git.hint":"Shared remote host credentials and SSH connection hints.","system.env.section.matrix":"Matrix","system.env.section.matrix.hint":"Global notification defaults used by projects without overrides.","system.env.section.memory":"Memory","system.env.section.memory.hint":"Runtime memory mode, external service URL, and capture policy.","system.env.section.voice":"Voice","system.env.section.voice.hint":"Doubao (Volcengine) remote TTS; keys stay on this machine.","system.env.section.daemon":"Daemon","system.env.section.daemon.hint":"Authoritative shared-daemon config (applied at startup since 0.65.15, overrides launcher env): sandbox plus concurrency gate/quotas/queue. Restart the daemon to apply changes.","system.env.section.console":"Console","system.env.section.console.hint":"Console access and optional linked service URLs.","system.env.section.custom":"Additional variables","system.env.section.custom.hint":"Unknown env variables are preserved here.","system.env.custom.empty":"No additional variables.","system.env.custom.keyPlaceholder":"CUSTOM_KEY","system.env.custom.valuePlaceholder":"value","system.env.custom.keyAria":"New variable key","system.env.custom.valueAria":"Value for {key}","system.env.custom.newValueAria":"New variable value","system.env.custom.removeAria":"Remove {key}","system.env.custom.add":"Add","system.env.field.GITLAB_URL":"GitLab URL","system.env.field.GITLAB_URL.help":"Base URL for GitLab API calls; leave blank when unused.","system.env.field.GITLAB_TOKEN":"GitLab token","system.env.field.GITLAB_TOKEN.help":"Personal access token for GitLab API calls.","system.env.field.MATRIX_HOMESERVER":"Matrix homeserver","system.env.field.MATRIX_HOMESERVER.help":"Homeserver URL for notifications.","system.env.field.MATRIX_ACCESS_TOKEN":"Matrix access token","system.env.field.MATRIX_ACCESS_TOKEN.help":"Access token used by the Matrix notifier.","system.env.field.MATRIX_ROOM_ID":"Matrix room","system.env.field.MATRIX_ROOM_ID.help":"Default notification room; project config can override it.","system.env.field.SPS_MEMORY_MODE":"Memory mode","system.env.field.SPS_MEMORY_MODE.help":"local stores memory on this machine; external uses a remote service.","system.env.field.SPS_MEMORY_EXTERNAL_URL":"External memory URL","system.env.field.SPS_MEMORY_EXTERNAL_URL.help":"Required when memory mode includes external storage.","system.env.field.SPS_MEMORY_DISTILL":"Memory distill","system.env.field.SPS_MEMORY_DISTILL.help":"Set to on to use the configured reviewer model for distilled memory capture.","system.env.field.SPS_MEMORY_REDACT":"Memory redaction","system.env.field.SPS_MEMORY_REDACT.help":"Optional override for memory redaction; blank keeps the default.","system.env.field.SPS_MEMORY_IMPORT":"Memory import","system.env.field.SPS_MEMORY_IMPORT.help":"When on, worker sessions are imported into the external memory store; requires an external mode plus a configured external URL.","system.env.field.SPS_DOUBAO_API_KEY":"Doubao API key","system.env.field.SPS_DOUBAO_API_KEY.help":"Volcengine Ark API key (ark-…); voice output falls back to browser Web Speech when unset.","system.env.field.SPS_DOUBAO_SPEAKER":"Doubao voice","system.env.field.SPS_DOUBAO_SPEAKER.help":"seed-tts-2.0 voices need the _uranus_bigtts suffix.","system.env.field.SPS_DOUBAO_RESOURCE_ID":"Doubao resource ID","system.env.field.SPS_DOUBAO_RESOURCE_ID.help":"TTS resource ID; defaults to seed-tts-2.0.","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER":"Sandbox provider","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER.help":"Execution sandbox for OpenAI sessions. Authoritative: this value overrides the launcher env (daemon respawn safe); blank infers from NODE_ENV (production→docker).","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS":"Global run limit","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS.help":"Daemon-wide concurrent run cap across all platforms; blank derives from machine memory (30GB≈47).","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS":"Per-platform quotas","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS.help":"Concurrency quota per origin, e.g. coral-platform=30,gameforge=20; keeps one platform from starving the rest.","system.env.field.SPS_DAEMON_QUEUE_WAIT_S":"Queue wait (s)","system.env.field.SPS_DAEMON_QUEUE_WAIT_S.help":"Max FIFO queue wait when at capacity; timeouts return a typed rejection with Retry-After. Default 20.","system.env.field.SPS_DAEMON_MAX_QUEUE":"Queue cap","system.env.field.SPS_DAEMON_MAX_QUEUE.help":"Max queued runs before immediate rejection. Default 200.","system.env.field.SPS_CONSOLE_TOKEN":"Console token","system.env.field.SPS_CONSOLE_TOKEN.help":"Bearer token required when exposing the console.","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL":"Memory viewer URL","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL.help":"Optional URL opened by the memory viewer integration.","system.env.error.conflict.title":"env was modified elsewhere","system.env.error.save.title":"Save failed","system.env.error.conflict.body":"Cancel and reopen the editor.","system.upgrade.checkUpdate":"Check update","system.upgrade.confirm.title":"Upgrade sps-cli","system.upgrade.confirm.body":"Current {current}, upgrade to {latest}. Requires all pipelines stopped. Restart sps console after upgrade.","system.upgrade.confirm.button":"Upgrade","system.upgrade.success.title":"Upgrade complete","system.upgrade.success.body":'Installed v{version}. Run `pkill -f "sps console"` and restart to see it.',"system.upgrade.notEffective.title":"Upgrade not effective","system.upgrade.error.title":"Upgrade failed","system.diagnostics.title":"Project health check","system.diagnostics.checkAll":"Check all","system.diagnostics.empty":"No projects yet.","system.diagnostics.expandAria":"Expand","system.diagnostics.collapseAria":"Collapse","system.diagnostics.never":'Click "Check" to run sps doctor',"system.diagnostics.checkAria":"Check","system.diagnostics.check":"Check","system.diagnostics.noFixesNeeded":"Nothing to fix","system.diagnostics.fix.tip":"Run sps doctor <proj> --fix: auto-create .claude/hooks/stop.sh, state.json, etc.","system.diagnostics.fixAria":"Auto fix","system.diagnostics.fix":"Fix","system.diagnostics.fixed":"Fixed","system.diagnostics.error.fix":"doctor fix failed","system.diagnostics.error.check":"doctor check failed","chat.list.new":"New chat","chat.list.title":"Sessions","chat.cli.banner.bold":"CLI session","chat.cli.banner":"This session was created by sps agent. The Console only shows history. To continue, run in a terminal:","chat.cliBadge":"CLI","chat.cliBadge.tooltip":"Created by sps agent CLI; history is read live from Claude jsonl (read-only).","notFound.title":"404","notFound.body":"This page does not exist.","notFound.home":"Back to home","dialog.confirm.default":"OK","dialog.alert.default":"Got it","dialog.cancel.default":"Cancel","dirPicker.title.default":"Pick a directory","dirPicker.close.aria":"Close","dirPicker.up.aria":"Parent directory","dirPicker.up.title":"Parent directory","dirPicker.home.aria":"Back to home","dirPicker.home.title":"Back to home","dirPicker.loading":"Loading…","dirPicker.error.title":"Read failed","dirPicker.empty":"— empty —","dirPicker.enter.aria":"Enter {name}/","dirPicker.pickFile.aria":"Pick {name} (double-click to confirm)","dirPicker.fileLocked":"File not selectable","dirPicker.cancel":"Cancel","dirPicker.useFile":"Use this file","dirPicker.useFile.tooltip.empty":"Click a file first","dirPicker.useDir":"Use this directory","dirPicker.newDir":"New folder","dirPicker.newDir.aria":"Create a subdirectory in the current directory","dirPicker.newDir.prompt":"New folder name (letters, digits, _ . - only)","dirPicker.newDir.placeholder":"Folder name","dirPicker.newDir.create":"Create","dirPicker.newDir.error.title":"Failed to create folder","chat.message.truncated":"⚠ Output exceeded 10MB and was truncated","chat.newSession.title":"New chat","chat.newSession.title.aria":"New chat","chat.newSession.close.aria":"Close","chat.newSession.field.agent":"Agent backend","chat.newSession.field.agent.openaiHint":"OpenAI sessions use the configured openai model; the model picker above does not apply","chat.newSession.field.model":"Model (optional)","chat.newSession.field.model.default":"Use global default model","chat.newSession.field.title":"Title (optional)","chat.newSession.field.title.placeholder":"Empty = auto-generate from first message","chat.newSession.field.cwd":"Working directory (optional)","chat.newSession.field.cwd.browse":"Browse","chat.newSession.field.cwd.browseAria":"Pick directory","chat.newSession.field.cwd.help1":"The agent reads/writes files here. Absolute path; must exist.","chat.newSession.field.cwd.help2":"Leave blank to auto-create a dedicated workspace for this chat.","chat.newSession.cancel":"Cancel","chat.newSession.create":"Create","cardModal.editing":"⚠ Editing","cardModal.order":"Wave {n}","cardModal.order.tip":"Execution wave (order): same wave runs in parallel; a wave starts only after the previous one fully completes","cardModal.title.aria":"Card title","cardModal.editAria":"Edit card","cardModal.edit":"Edit","cardModal.close.aria":"Close","cardModal.error.save.title":"Save failed","cardModal.error.load":"Load failed: {detail}","cardModal.skills.loading":"Loading skill list…","cardModal.label.removeAria":"Remove {label}","cardModal.label.addPlaceholder":"+ Add label","cardModal.label.addAria":"Add label","cardModal.label.note":"Note: AI-PIPELINE / STARTED-* / COMPLETED-* / NEEDS-FIX are managed by the pipeline; manual changes may be overwritten","cardModal.section.description":"Description","cardModal.section.empty":"(empty)","cardModal.section.checklist":"Checklist","cardModal.checklist.empty":"No checklist items. Add `- [ ] item` syntax in the description.","cardModal.section.log":"Log","cardModal.body.aria":"Card description","cardModal.body.replaceNote":'Only replaces the "## Description" section; checklist and log sections are untouched.',"cardModal.action.launch":"Launch worker","cardModal.action.launch.disabledDone":"Card is done; drag back to Todo to launch","cardModal.action.launch.disabledRunning":"Pipeline is running — supervisor dispatches automatically, no manual launch needed","cardModal.action.launch.error":"Launch worker failed","cardModal.action.reset":"Reset card","cardModal.action.viewPrompt":"View prompt","cardModal.prompt.title":"Worker prompt (preview)","cardModal.prompt.loading":"Rebuilding prompt…","cardModal.prompt.error":"Failed: {detail}","cardModal.prompt.copy":"Copy","cardModal.prompt.copied":"Copied","cardModal.prompt.metaSkills":"skills: {skills}","cardModal.prompt.metaMemory":"memory block","cardModal.prompt.metaGit":"git mode","cardModal.prompt.metaNonGit":"non-git","cardModal.prompt.nativeTitle":"Also read natively by claude (not in this string):","cardModal.prompt.sourceActual":"✅ Actual prompt as dispatched ({time})","cardModal.prompt.sourcePreview":"⚠️ Reconstructed preview (card not yet dispatched; memory reflects current state, may differ from the real dispatch)","cardModal.action.reset.confirm.title":"Reset card #{seq}","cardModal.action.reset.confirm.body":"Card state goes back to initial; checklist progress is cleared.","cardModal.action.reset.confirm.button":"Reset","cardModal.action.reset.error":"Reset failed","cardModal.action.delete":"Delete card","cardModal.action.delete.confirm1.title":"Delete card #{seq}","cardModal.action.delete.confirm1.body":'About to delete "{title}". This cannot be undone (the md file is physically removed). Continue?',"cardModal.action.delete.confirm1.button":"Continue","cardModal.action.delete.confirm2.title":"Final confirmation","cardModal.action.delete.confirm2.body":"Please re-confirm deleting card #{seq}.","projectDetail.tab.skills":"Skills","projectDetail.tab.rules":"Rules","projectDetail.skills.title":"Skill whitelist","projectDetail.skills.desc":"Pick which skills this project loads. Narrows what workers, subagents and chat see — cuts token cost.","projectDetail.skills.noPolicy":"No whitelist — all skills are available (subagents load the full set from disk).","projectDetail.skills.hasPolicy":"Whitelist active — {count} skill(s) eligible.","projectDetail.skills.save":"Save","projectDetail.skills.detail":"Details","projectDetail.skills.saveError":"Failed to save whitelist","projectDetail.skills.applied":"Saved. Projected {linked} linked, {pruned} pruned.","projectDetail.skills.unknown":"Unknown skill name(s), ignored: {names}","projectDetail.skills.empty":"No skills installed. Run `sps skill sync` first.","projectDetail.skills.selectAll":"Select all","projectDetail.skills.selectNone":"Select none","projectDetail.rules.readonly":"sps-cli only reads these. Editing is done at project creation or by an agent later.","projectDetail.rules.missing":"Not present","nav.prompts":"Prompts","prompts.title":"Prompt library","prompts.desc":"Reusable prompts with {{variable}} templates. Insert them into chat.","prompts.new":"New prompt","prompts.search":"Search prompts…","prompts.empty":"No prompts yet. Create one.","prompts.name":"Name","prompts.namePlaceholder":"kebab-case, e.g. code-review","prompts.nameError":"Name must be kebab-case (a-z, 0-9, dashes).","prompts.description":"Description","prompts.tags":"Tags","prompts.body":"Body","prompts.bodyPlaceholder":"Write your prompt. Use {{variable}} for fill-ins.","prompts.favorite":"Favorite","prompts.save":"Save","prompts.delete":"Delete","prompts.deleteConfirm":'Delete prompt "{name}"? This removes the file.',"prompts.saveError":"Failed to save prompt","prompts.vars":"Variables: {names}","prompts.noVars":"No variables","prompts.insert":"Insert a prompt","prompts.selectHint":"Select a prompt on the left, or create a new one.","prompts.tagAdd":"Type a tag, press Enter","prompts.ai":"AI generate","prompts.ai.title":"AI generate a prompt","prompts.ai.intent":"Describe what you want","prompts.ai.placeholder":"e.g. a prompt for reviewing TypeScript code for security issues","prompts.ai.submit":"Generate","prompts.ai.wait":"The agent is writing… this can take a while.","prompts.ai.error":"Generation failed","skills.import":"Import","skills.import.title":"Import a skill","skills.import.name":"Name (kebab-case)","skills.import.body":"SKILL.md content","skills.import.submit":"Import","skills.import.error":"Import failed","skills.export":"Export SKILL.md","skills.updates.badge":"{count} update(s) available","skills.ai":"AI create","skills.ai.title":"AI create a skill","skills.ai.name":"Name (kebab-case)","skills.ai.intent":"What is this skill for?","skills.ai.placeholder":"e.g. how to write idiomatic Rust error handling","skills.ai.submit":"Create","skills.ai.wait":"The agent is writing the skill… this can take a while.","skills.ai.error":"Create failed","projectDetail.tab.graph":"Code Graph","projectDetail.tab.logs":"Logs","graph.title":"Code Graph","graph.desc":"A symbol-level dependency graph of this project (tree-sitter, zero-token). Gives agents surgical context so they explore fewer files.","graph.build":"Build graph","graph.rebuild":"Rebuild","graph.building":"Building…","graph.sync":"Sync","graph.syncing":"Syncing…","graph.sync.desc":"Incremental — only re-index changed files (fast)","graph.empty":"No graph yet — build one to enable agent navigation and the dependency view.","graph.buildFailed":"Build failed","graph.stat.files":"Files","graph.stat.nodes":"Nodes","graph.stat.edges":"Edges","graph.stat.db":"DB size","graph.stat.lastBuilt":"Last built","graph.viz.loading":"Loading graph…","graph.viz.empty":"Build the graph to see the dependency view.","graph.viz.hint":"Node = file · edge = import · drag to explore · search to highlight","graph.viz.search":"Highlight files…"},A6={"sidebar.collapse":"收起","sidebar.expand":"展开","nav.home":"首页","nav.projects":"项目","nav.board":"看板","nav.skills":"技能","nav.system":"系统","nav.memory":"记忆","nav.plugins":"插件","plugins.h1":"插件","plugins.desc":"全局插件开关。改动对之后新派发的卡生效。","plugins.tab.memory":"记忆","plugins.tab.channel":"频道","plugins.tab.model":"模型","plugins.tab.tool":"工具","plugins.comingSoon":"即将上线","nav.arrange":"编排","flow.addNode":"加节点","flow.tidy":"整理:按执行顺序重排卡片 + 重建默认连线","flow.pickProject":"先选一个项目来编辑它的流程。每个项目有自己的 DAG(存在项目里)。","flow.run":"编译并启动","flow.running":"启动中…","flow.pipelineRunning":"运行中…","flow.node.default":"任务","flow.confirm.deleteTitle":"删除卡片?","flow.confirm.deleteBody":"删除卡片 #{seq}。可用 Ctrl/Cmd+Z 撤销。","flow.node.close":"关闭","flow.node.title":"标题","flow.node.desc":"描述(worker 要做什么)","flow.node.skills":"技能","flow.node.save":"保存","flow.node.delete":"删除节点","flow.hint":"节点=项目的卡。单击选中(Delete 删卡/删连线)、双击编辑、从边缘拖出连线定依赖、把卡拖到某条连线上插入其间。启动会提升待跑卡并跑 pipeline,状态实时刷新。","flow.mode.aria":"切换展示模式","flow.pending.create":"新建卡片","flow.mode.free":"自由","flow.mode.lanes":"泳道","flow.lane.wave":"第 {n} 波","flow.lane.parallel":"{n} 张并行","flow.lane.applying":"正在写入执行顺序…","flow.lane.orderTip":"执行波次(order):同波并行,前一波全部完成才开下一波","flow.lane.hint":"框=执行波次(写进卡片 order,就是真实执行顺序):框内并行,框间左→右按序,前一波全部 Done 才开下一波;连线=波间依赖,颜色/动效=运行状态。拖卡进另一个框=并入该波,拖到框外间隙=独立新波。单击卡编辑。","flow.err.noProject":"先选一个项目。","flow.err.noNodes":"至少加一个节点。","flow.status.creating":"准备卡片","flow.status.starting":"启动 pipeline…","flow.status.done":"已建 {n} 张卡 · pipeline 已启动","flow.goBoard":"去看板","nav.aria":"主导航","home.inputToggle":"切换语音 / 文字输入","home.copy":"复制","home.play":"播放","home.stop":"停止","home.artifacts.label":"产物","home.sessions.tabAll":"全部","home.sessions.expandWeek":"展开 7 天前的会话({count})","home.sessions.expandMonth":"展开 1 个月前的会话({count})","home.sessions.collapseOld":"收起早期会话","home.sessions.open":"展开会话列表","home.sessions.collapse":"收起会话列表","home.sessions.delete":"删除会话","home.sessions.deleteConfirm":"删除这条对话?此操作不可撤销。","home.interrupt":"中断","home.attach.remove":"移除附件","home.text.placeholder":"输入消息…","home.text.send":"发送","home.attach":"添加附件","home.text.hint":"Enter 发送 · Shift+Enter 换行","home.auto.toggle":"自动监听","home.auto.tip":"自动监听:检测到说话自动开始;静音 2 秒自动结束。","home.auto.armedOpen":"待命中 —— 直接说话即可","home.conversation.empty":"点击下方语音球开始对话","home.conversation.you":"你","home.conversation.ai":"AI","home.conversation.listening":"正在聆听…","home.conversation.thinking":"思考中","home.debug.close":"关闭调试面板","home.voice.start":"开始聆听","home.voice.stop":"结束聆听","home.voice.finish":"再次点击结束聆听","home.voice.idle":"点击语音球或按空格开始","home.voice.listening":"正在聆听","home.voice.thinking":"正在思考","home.voice.speaking":"正在回答","home.error.recognitionUnsupported":"当前浏览器不支持语音识别。","home.error.recognition":"没有识别到有效语音,请重试。","home.error.response":"AI 响应失败,请重试。","home.phase.aria":"语音交互状态","home.phase.idle":"待机","home.phase.listening":"聆听","home.phase.thinking":"思考","home.phase.speaking":"回答","home.visualizer.aria":"Flow 语音声场","home.mic.requesting":"正在连接麦克风","home.message.speaking":"方向已经清晰,我们从第一步开始。","home.customize.title":"参数调节","home.customize.reset":"重置参数","home.customize.colors":"颜色","home.customize.parameters":"参数","home.customize.color1":"颜色 1","home.customize.color2":"颜色 2","home.customize.color3":"颜色 3","home.customize.count":"数量","home.customize.speed":"速度","home.customize.amplitude":"振幅","home.customize.waviness":"波形密度","home.customize.thickness":"宽度","home.customize.glow":"光晕","home.customize.taper":"边缘收束","home.customize.spread":"分离度","home.customize.hueShift":"色相偏移","home.customize.intensity":"亮度","home.customize.saturation":"饱和度","home.customize.opacity":"透明度","home.customize.scale":"缩放","processes.title":"进程监控","processes.refresh":"刷新","processes.col.kind":"类型","processes.col.slot":"会话槽","processes.col.project":"项目","processes.col.state":"状态","processes.col.memory":"内存","processes.col.action":"操作","processes.empty":"没有 SPS 进程","processes.kind.all":"全部类型","processes.kind.worker":"构建 Worker","processes.kind.chat":"对话","processes.kill":"关闭","processes.killConfirm":"确定关闭进程 {slot}?","audit.title":"审计日志","audit.refresh":"刷新","audit.filter.all":"全部","audit.action.create":"创建","audit.action.modify":"修改","audit.action.delete":"删除","audit.action.daemon":"Daemon","audit.col.time":"时间","audit.col.action":"动作","audit.col.project":"项目","audit.col.detail":"详情","audit.empty":"暂无审计记录","lang.toggle.aria":"切换界面语言","lang.en":"EN","lang.zh":"中","theme.toggle.aria":"切换主题","theme.dark":"暗色主题","theme.light":"亮色主题","status.server":"服务","status.offline":"离线","status.sse.open":"SSE","status.sse.connecting":"SSE 连接中","status.sse.down":"SSE·断开","status.pipelines.tooltip":"活跃流水线数","status.workers.tooltip":"活跃 Worker 数","status.pipeline.unit":"流水线","status.worker.unit":"Worker","common.save":"保存","common.cancel":"取消","common.delete":"删除","common.create":"创建","common.edit":"编辑","common.close":"关闭","common.loading":"加载中…","common.retry":"重试","common.yes":"是","common.no":"否","projects.title":"项目","projects.count":"本机有 {count} 个项目","projects.new":"新建项目","projects.selectHint":"在左侧选择一个项目查看详情。","projects.sort.label":"排序方式","projects.sort.activity":"活跃度","projects.sort.date":"修改日期","projects.sort.name":"名字","projects.load.failed":"加载失败","projects.empty.title":"还没有项目","projects.empty.hint":"运行 {cmd} 创建第一个项目。","newProject.title":"新建项目","newProject.field.name":"项目名","newProject.field.dir":"项目目录","newProject.submit":"创建项目","newProject.creating":"创建中…","newProject.dir.browse":"浏览","newProject.dir.browseAria":"选择目录","newProject.back":"返回","newProject.back.aria":"返回项目列表","newProject.field.name.placeholder":"例如:acme-web","newProject.field.name.invalid":"名称只能包含 a-z A-Z 0-9 _ -","newProject.field.dir.long":"本机绝对路径的【项目目录】。选中的目录本身就是项目根;项目名默认取目录名。已有代码 → 收编(只加 .claude/ 配置,不动源码);空目录 → 新建。","newProject.field.dir.placeholder":"/home/you/projects/my-app","newProject.field.dir.createIfMissing":"目录不存在时自动创建(推荐 —— 否则 .claude/ 安装会被跳过)","newProject.field.dir.pickerTitle":"选择项目目录","newProject.field.dir.adopt":"检测到已有内容 → 将收编(只加配置,不动源码)","newProject.field.dir.fresh":"空目录 → 新建项目","newProject.field.name.derived":"项目名(默认取目录名,可微调)","newProject.field.maxWorkers.short":"最大 Worker 数","newProject.field.ackTimeout.minutes":"ACK 超时(分钟)","newProject.field.ackTimeout.minutes.help":"Worker 启动后多久没 ACK 视为失败","newProject.field.git.label":"启用 Git(Worker 自动 commit + push)","newProject.field.git.detail":"关闭后 Worker 只做任务、不做版本控制;适合文档/数据处理等非代码项目。","newProject.field.review.label":"启用清单验收(每卡完成后独立 agent 审核)","newProject.field.review.detail":"开启后:卡带「检查清单」的,Worker 完成后由独立 reviewer 逐条对着真实产物验收;全过留 Done,有不过自动插一张修正卡(优先跑)。无清单的卡不审。建卡时用 --checklist 写验收点。","newProject.field.git.branch":"合并分支","newProject.field.gitlabProject.label":"Git 远程项目路径","newProject.field.gitlabProject.help2":"如 user/repo,空则跳过远程 API(只本地 commit/push)","newProject.field.gitlabProject.placeholder":"user/repo","newProject.field.gitlabProjectId":"GitLab 项目 ID","newProject.field.gitlabProjectId.help":"数字;GitHub 用户留空","newProject.field.gitlabProjectId.placeholder":"42","newProject.section.notifications":"通知","newProject.field.matrixRoom.label":"Matrix 房间 ID","newProject.field.matrixRoom.help2":"空则使用全局配置;不填 = 不通知","newProject.field.matrixRoom.placeholder":"!abc:matrix.example.com","newProject.error.create.title":"创建失败","projectDetail.tab.pipeline":"流水线","projectDetail.tab.conf":"配置","projectDetail.tab.delete":"删除项目","projectDetail.tab.overview":"概览","projectDetail.tab.config":"配置","projectDetail.tab.pipelines":"流水线","projectDetail.tab.danger":"删除","projectDetail.openBoard":"看板","projectDetail.overview.repoDir":"仓库路径","projectDetail.overview.pmBackend":"PM 后端","projectDetail.overview.agent":"Agent","projectDetail.overview.cards":"卡片","projectDetail.overview.cards.value":"共 {total} 张 · {inprogress} 进行中 · {done} 完成","projectDetail.overview.workers":"Worker","projectDetail.overview.workers.value":"共 {total} 个({active} 活跃)","projectDetail.overview.pipeline":"Pipeline","projectDetail.overview.lastActivity":"最近活动","projectDetail.overview.notFound":"项目 {name} 不存在或无法读取。","projectDetail.config.confDirty":"● 未保存的修改","projectDetail.config.reload":"重新加载","projectDetail.config.save":"保存","projectDetail.config.saveAria":"保存配置","projectDetail.config.settingsAria":"项目配置设置","projectDetail.config.option.empty":"未设置","projectDetail.config.section.basic":"项目","projectDetail.config.section.basic.hint":"项目身份与本地仓库路径。","projectDetail.config.section.git":"Git","projectDetail.config.section.git.hint":"远程仓库与合并行为。","projectDetail.config.section.pipeline":"流水线","projectDetail.config.section.pipeline.hint":"执行模式、卡片标签与审核智能体。","projectDetail.config.section.worker":"Worker","projectDetail.config.section.worker.hint":"Worker 运行方式、槽位与兜底技能。","projectDetail.config.section.policies":"策略","projectDetail.config.section.policies.hint":"超时、冲突处理、记忆与通知。","projectDetail.config.section.custom":"附加变量","projectDetail.config.section.custom.hint":"未内置的 conf 变量会保留在这里。","projectDetail.config.custom.empty":"没有附加变量。","projectDetail.config.custom.keyPlaceholder":"CUSTOM_KEY","projectDetail.config.custom.valuePlaceholder":"值","projectDetail.config.custom.keyAria":"新变量名","projectDetail.config.custom.valueAria":"{key} 的值","projectDetail.config.custom.newValueAria":"新变量值","projectDetail.config.custom.removeAria":"移除 {key}","projectDetail.config.custom.add":"添加","projectDetail.config.disabled.requiresReviewerConsumer":"仅智能编排或清单验收会使用该模型。请先开启其中一个。","projectDetail.config.field.PROJECT_NAME":"项目名","projectDetail.config.field.PROJECT_NAME.help":"项目内部 id。","projectDetail.config.field.PROJECT_DIR":"项目目录","projectDetail.config.field.PROJECT_DIR.help":"代码仓库的本机绝对路径。","projectDetail.config.field.PROJECT_DIR.browse":"浏览","projectDetail.config.field.PROJECT_DIR.browseAria":"选择项目目录","projectDetail.config.field.PROJECT_DIR.pickerTitle":"选择项目目录","projectDetail.config.field.GIT_HOST":"Git 平台","projectDetail.config.field.GIT_HOST.help":"可选覆盖;不填则从仓库 remote 自动判断。","projectDetail.config.field.GITLAB_PROJECT":"远程项目","projectDetail.config.field.GITLAB_PROJECT.help":"仓库路径,例如 user/repo。","projectDetail.config.field.GITLAB_PROJECT_ID":"GitLab 项目 ID","projectDetail.config.field.GITLAB_PROJECT_ID.help":"GitLab 数字 id;GitHub 或自动解析时留空。","projectDetail.config.field.GITLAB_MERGE_BRANCH":"合并分支","projectDetail.config.field.GITLAB_MERGE_BRANCH.help":"Worker commit 或 MR 的目标分支。","projectDetail.config.field.MR_MODE":"MR 模式","projectDetail.config.field.MR_MODE.help":"none 直接 push;create 创建 MR。","projectDetail.config.field.PIPELINE_LABEL":"流水线标签","projectDetail.config.field.PIPELINE_LABEL.help":"卡片带这个标签才会进入项目流水线。","projectDetail.config.field.SPS_REVIEW":"清单验收","projectDetail.config.field.SPS_REVIEW.help":"开启后,带检查清单的完成卡会交给独立 reviewer 审核。","projectDetail.config.field.WORKER_MODEL":"Worker 模型","projectDetail.config.field.WORKER_MODEL.help":"项目级 worker 模型覆盖;留空使用全局默认。","projectDetail.config.field.SA_REVIEWER_MODEL":"Reviewer 模型","projectDetail.config.field.SA_REVIEWER_MODEL.help":"审核与智能编排使用的项目级 reviewer 模型覆盖。","projectDetail.config.field.WORKER_TRANSPORT":"Worker 传输","projectDetail.config.field.WORKER_TRANSPORT.help":"运行时传输方式。当前支持 acp-sdk。","projectDetail.config.field.MAX_CONCURRENT_WORKERS":"Worker 槽位","projectDetail.config.field.MAX_CONCURRENT_WORKERS.help":"最大并发 Worker 数。","projectDetail.config.field.MAX_ACTIONS_PER_TICK":"每轮动作数","projectDetail.config.field.MAX_ACTIONS_PER_TICK.help":"单次 tick 可领取的新任务数量。","projectDetail.config.field.DEFAULT_WORKER_SKILLS":"默认技能","projectDetail.config.field.DEFAULT_WORKER_SKILLS.help":"逗号分隔;卡片没有 profile 或 skills 时使用。","projectDetail.config.field.WORKTREE_DIR":"Worktree 目录","projectDetail.config.field.WORKTREE_DIR.help":"可选的 Worker 临时工作树根目录。","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS":"进行中超时","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS.help":"超过多少小时后 Monitor 标记 stale runtime。","projectDetail.config.field.WORKER_ACK_TIMEOUT_S":"ACK 超时","projectDetail.config.field.WORKER_ACK_TIMEOUT_S.help":"派发后等待 Worker STARTED 标签的秒数。","projectDetail.config.field.WORKER_ACK_MAX_RETRIES":"ACK 重试","projectDetail.config.field.WORKER_ACK_MAX_RETRIES.help":"ACK 超时后的最大重试次数。","projectDetail.config.field.MONITOR_AUTO_QA":"自动 QA","projectDetail.config.field.MONITOR_AUTO_QA.help":"Monitor 发现 stale runtime 后自动迁到 QA。","projectDetail.config.field.CONFLICT_DEFAULT":"默认冲突策略","projectDetail.config.field.CONFLICT_DEFAULT.help":"卡片没有 conflict 标签时的兜底策略。","projectDetail.config.field.ENABLE_MEMORY":"记忆","projectDetail.config.field.ENABLE_MEMORY.help":"关闭后跳过 prompt 里的记忆写入指引。","projectDetail.config.field.WIKI_ENABLED":"Wiki 上下文","projectDetail.config.field.WIKI_ENABLED.help":"项目存在 wiki 文件时注入 wiki 上下文。","projectDetail.config.field.MATRIX_ROOM_ID":"Matrix 房间","projectDetail.config.field.MATRIX_ROOM_ID.help":"项目级 Matrix 通知房间覆盖。","projectDetail.config.field.COMPLETION_SIGNAL":"完成信号","projectDetail.config.field.COMPLETION_SIGNAL.help":"Stop hook 监听的完成词。","projectDetail.config.error.conflict.title":"配置已被其他地方修改","projectDetail.config.error.conflict.body":'conf 文件在你编辑期间被改过。点"重新加载"后再编辑。',"projectDetail.config.error.save.title":"保存失败","projectDetail.config.error.load":"加载失败:{detail}","projectDetail.pipelines.title":"流水线","projectDetail.pipelines.add":"新建流水线","projectDetail.pipelines.empty":'还没有流水线文件。点"新建流水线"开始。',"projectDetail.pipelines.activeBadge":"当前","projectDetail.pipelines.edit":"编辑","projectDetail.pipelines.editAria":"编辑 {name}","projectDetail.pipelines.switch":"切换","projectDetail.pipelines.switchAria":"切换到 {name}","projectDetail.pipelines.switch.confirm.title":"切换到 {name}","projectDetail.pipelines.switch.confirm.body":"当前 project.yaml 会被 {name} 的内容覆盖。继续?","projectDetail.pipelines.switch.confirm.button":"切换","projectDetail.pipelines.switch.error":"切换失败","projectDetail.pipelines.delete.confirm.title":"删除 {name}","projectDetail.pipelines.delete.confirm.body":"这个流水线文件会被永久删除。","projectDetail.pipelines.delete.error":"删除失败","projectDetail.pipelines.deleteAria":"删除 {name}","projectDetail.pipelines.create.error":"创建失败","projectDetail.danger.title":"删除项目","projectDetail.danger.body":"这会清理 {path}(包括所有卡片、runtime、logs)。","projectDetail.danger.includeClaude.label":"同时清理 repo 的 .claude/","projectDetail.danger.includeClaude.note":"repo 本身不动,只清这个目录。","projectDetail.danger.deleteWorkspace.label":"完整删除整个工作区目录","projectDetail.danger.deleteWorkspace.note":"⚠️ 连同代码/产物一起永久删除,不可恢复。不勾选则只删 sps 配置、保留目录。","projectDetail.danger.confirmPrompt":"输入项目名 {name} 确认:","projectDetail.danger.deleteAria":"永久删除项目","projectDetail.danger.deleteButton":"永久删除","projectDetail.danger.deleted.title":"已删除","projectDetail.danger.deleted.bodyWithList":`项目已删除。同时清理了:
|
|
473
|
-
{paths}`,"projectDetail.danger.deleted.body":"项目已删除。","projectDetail.danger.error":"删除失败","pipelineEditor.close":"关闭","pipelineEditor.error.conflict.title":"文件已被其他地方修改","pipelineEditor.error.yaml.title":"YAML 语法错误","pipelineEditor.error.save.title":"保存失败","pipelineEditor.error.serialize.title":"YAML 序列化失败","pipelineEditor.error.load":"加载失败:{detail}","pipelineEditor.mode.structured":"结构化","pipelineEditor.mode.yaml":"原始 YAML","pipelineEditor.parseError.prefix":"YAML 解析:{detail}","pipelineEditor.activeWarning":"⚠ 这是当前激活的流水线,保存后下一轮 tick 生效","pipelineEditor.yamlAria":"pipeline YAML 编辑器","pipelineEditor.status.unsaved":"● 未保存","pipelineEditor.status.saved":"已保存","pipelineEditor.status.noChanges":"无变化","pipelineEditor.reload":"重新加载","pipelineEditor.save":"保存","pipelineEditor.saveAria":"保存 pipeline","pipelineEditor.activeBadge":"当前","pipelineEditor.modeHint":"project = 事件驱动流水线(默认) · steps = 顺序脚本","pipelineEditor.stages.heading":"Stages({count})","pipelineEditor.stages.add":"添加 stage","pipelineEditor.stages.empty":'还没 stage。点"添加 stage"开始。',"pipelineEditor.stage.name.hint":"stage 唯一名","pipelineEditor.stage.profile.hint":"skill 画像,可空","pipelineEditor.stage.cardState.hint":"本 stage 期间卡片状态","pipelineEditor.stage.timeout.hint":"可选,如 30m 2h","pipelineEditor.stage.trigger.hint":"触发条件,可空走默认","pipelineEditor.stage.onComplete.hint":"成功后动作","pipelineEditor.stage.onFail.action.hint":"失败时动作,如 label NEEDS-FIX","pipelineEditor.stage.onFail.comment.hint":"写进卡片的注释","pipelineEditor.stage.halt.note":"(失败后停流水线;去掉则继续下一张卡)","pipelineEditor.stage.moveUp":"上移","pipelineEditor.stage.moveDown":"下移","pipelineEditor.stage.remove":"删除 stage","newPipelineDialog.title":"新建流水线","newPipelineDialog.field.filename.label":"文件名","newPipelineDialog.field.filename.placeholder":"例如 ci","newPipelineDialog.field.filename.help":"实际会保存为 {filename}。只允许 a-z A-Z 0-9 _ -;已有同名文件会 409 报错。","newPipelineDialog.section.template":"初始内容","newPipelineDialog.template.blank.label":"空白模板","newPipelineDialog.template.blank.desc":"最简 1 stage(develop → Done)","newPipelineDialog.template.sample.label":"教学模板","newPipelineDialog.template.sample.desc":"从 sample.yaml.example 复制(带注释,讲解所有字段)","newPipelineDialog.template.sample.unavailable":"sample.yaml.example 不存在","newPipelineDialog.template.active.label":"复制当前活动的","newPipelineDialog.template.active.desc":"从 project.yaml 复制(基于目前的配置改)","newPipelineDialog.template.active.unavailable":"project.yaml 不存在","newPipelineDialog.create.aria":"创建 pipeline","board.title":"看板","board.title.bare":"看板","board.subtitle":"{name} · {cards} 张卡片 · {workers} workers 活跃","board.pickPrompt.title":"选择一个项目","board.pickPrompt.body":"看板按项目分。挑一个开始:","board.action.start":"启动","board.action.stop":"停止","board.action.startAria":"启动 pipeline","board.action.stopAria":"停止 pipeline","board.action.startError":"启动 pipeline 失败","board.action.stopError":"停止 pipeline 失败","board.action.reset":"重置","board.action.resetError":"重置失败","board.action.reset.confirm.title":"重置整个流水线","board.action.reset.confirm.body":"这会清空所有卡片的运行状态、worker marker、分支。不可撤销。","board.action.reset.confirm.button":"重置全部","board.action.newCard":"新卡片","board.action.newCard.error":"新建卡片失败","board.action.moveCard.error":"移动卡片失败","board.search.placeholder":"搜索标题 / skill / label…","board.search.aria":"搜索卡片","board.filter.clear":"清空","board.filter.clearAria":"清空筛选","board.filter.aria":"按 {label} 筛选","board.filter.clearSelection":"清空选择","board.error.loadCards":"加载卡片失败","board.col.planning":"Planning","board.col.backlog":"Backlog","board.col.todo":"Todo","board.col.inprogress":"Inprogress","board.col.qa":"QA / Review","board.col.done":"Done","kanban.checklist.label":"检查清单 {done}/{total}","kanban.checklist.more":"… 还有 {count} 条","kanban.column.empty":"— 空 —","kanban.time.justNow":"刚才","kanban.time.minutes":"{n} 分钟前","kanban.time.hours":"{n} 小时前","newCard.title":"新建卡片","newCard.field.title":"标题 *","newCard.field.title.placeholder":"例如:接入 GitHub OAuth 登录","newCard.field.title.help":"写简短明了的目标(<200 字符)","newCard.field.description":"描述","newCard.field.description.placeholder":"用户故事、需求、验收标准、参考资料… Claude 启动时会读这里的内容","newCard.field.description.help":"支持 markdown。空的话就只有 title,Claude 只能靠 title 推断要做啥。","newCard.field.skills":"技能","newCard.field.skills.help":"勾选哪些 skill 会被加载(走 frontmatter `skills:`)。不选也行,Worker 默认加载项目级 skills。","newCard.field.skills.loading":"加载 skill 列表…","newCard.field.skills.error":"skill 列表加载失败,不影响创建:{detail}","newCard.field.skills.selected":"已选 {count} 个:{names}","newCard.field.dispatch":"派发","newCard.field.dispatch.label":"立即派发执行(直接进 Backlog)","newCard.field.dispatch.help":"默认不勾:卡进 Planning 暂存,等你看板上拖到 Backlog 再开工。勾上:跳过暂存,下次 tick 直接派 worker 跑。","newCard.create.aria":"创建卡片","cardDetail.save":"保存","logs.scroll.bottom.aria":"滚动到底部","logs.filter.keyword.placeholder":"过滤关键字…","logs.filter.keyword.aria":"过滤日志","logs.empty.match":"没有匹配的日志","skills.category.all":"全部","skills.category.language":"语言","skills.category.domain":"领域","skills.category.persona":"角色","skills.category.workflow":"流程","skills.category.engine":"引擎","skills.category.genre":"品类","skills.category.platform":"平台","skills.category.review":"审核","skills.category.meta":"工具","skills.category.other":"其它","skills.tags.title":"标签","skills.tags.clear":"清除","skills.subtitleCount":"{count} 个 user-level skill","skills.search.placeholder":"搜索 skill…","skills.search.aria":"搜索 skill","skillDetail.close.aria":"关闭","skillDetail.loading":"加载中…","skillDetail.error.load":"加载失败:{detail}","skillDetail.section.preview":"SKILL.md 预览","skillDetail.toggleSection.aria":"{action} {file}","skillDetail.expand":"展开","skillDetail.collapse":"收起","skillDetail.edit":"编辑","skillDetail.translate":"中英转换","skillDetail.delete":"删除","skillDetail.save":"保存","skillDetail.cancel":"取消","skillDetail.translating":"翻译中…","skillDetail.saving":"保存中…","skillDetail.editHint":"直接编辑整份 SKILL.md(含 frontmatter)。保存后建议跑 `sps skill lint` 校验三轴与格式。","skillDetail.deleteConfirm":"确定从库中删除「{name}」?整目录会被移除,此操作不可撤销。","skillDetail.translateFailed":"翻译失败:{detail}","skillDetail.saveFailed":"保存失败:{detail}","skillDetail.deleteFailed":"删除失败:{detail}","system.h1":"系统","system.tab.config":"全局配置","system.tab.processes":"进程管理","system.tab.doctor":"项目诊断","system.tab.audit":"审计日志","system.upgrade.upToDate":"已是最新版本({version})","system.memory.title":"记忆后端","system.memory.desc":"全局设置:worker 的记忆读写走哪个后端。改动对新派发的卡生效。","system.memory.provider":"后端","system.memory.url":"自定义 URL","system.memory.url.placeholder":"http://127.0.0.1:3111","system.memory.save":"保存","system.memory.save.aria":"保存记忆后端设置","system.memory.saved":"已保存","system.memory.error":"保存失败","system.env.warning":"⚠ 文件包含凭证明文。保存时保持 0600 权限。","system.env.settingsAria":"全局配置设置","system.env.dirtyMark":" · ● 未保存","system.env.save":"保存","system.env.save.aria":"保存 env","system.env.section.git":"Git","system.env.section.git.hint":"共享远程仓库凭证与 SSH 连接配置。","system.env.section.matrix":"Matrix","system.env.section.matrix.hint":"项目未覆盖时使用的全局通知默认值。","system.env.section.memory":"记忆","system.env.section.memory.hint":"运行时记忆模式、外部服务地址与捕获策略。","system.env.section.voice":"语音","system.env.section.voice.hint":"豆包(火山)远程 TTS;密钥仅存本机。","system.env.section.daemon":"Daemon","system.env.section.daemon.hint":"共享 daemon 权威配置(0.65.15 起启动时应用、覆盖拉起方 env):沙箱与并发总闸/配额/排队。改动需重启 daemon 生效。","system.env.section.console":"控制台","system.env.section.console.hint":"控制台访问密钥与可选关联服务地址。","system.env.section.custom":"附加变量","system.env.section.custom.hint":"未内置的 env 变量会保留在这里。","system.env.custom.empty":"没有附加变量。","system.env.custom.keyPlaceholder":"CUSTOM_KEY","system.env.custom.valuePlaceholder":"值","system.env.custom.keyAria":"新变量名","system.env.custom.valueAria":"{key} 的值","system.env.custom.newValueAria":"新变量值","system.env.custom.removeAria":"移除 {key}","system.env.custom.add":"添加","system.env.field.GITLAB_URL":"GitLab 地址","system.env.field.GITLAB_URL.help":"GitLab API 基础地址;不用 GitLab 时可留空。","system.env.field.GITLAB_TOKEN":"GitLab Token","system.env.field.GITLAB_TOKEN.help":"GitLab API 使用的个人访问令牌。","system.env.field.MATRIX_HOMESERVER":"Matrix Homeserver","system.env.field.MATRIX_HOMESERVER.help":"通知使用的 homeserver 地址。","system.env.field.MATRIX_ACCESS_TOKEN":"Matrix Access Token","system.env.field.MATRIX_ACCESS_TOKEN.help":"Matrix 通知器使用的访问令牌。","system.env.field.MATRIX_ROOM_ID":"Matrix 房间","system.env.field.MATRIX_ROOM_ID.help":"默认通知房间;项目配置可以覆盖。","system.env.field.SPS_MEMORY_MODE":"记忆模式","system.env.field.SPS_MEMORY_MODE.help":"local 存在本机;external 使用远程服务。","system.env.field.SPS_MEMORY_EXTERNAL_URL":"外部记忆地址","system.env.field.SPS_MEMORY_EXTERNAL_URL.help":"记忆模式包含 external 时填写。","system.env.field.SPS_MEMORY_DISTILL":"记忆蒸馏","system.env.field.SPS_MEMORY_DISTILL.help":"设为 on 时使用已配置的 reviewer 模型提炼记忆。","system.env.field.SPS_MEMORY_REDACT":"记忆脱敏","system.env.field.SPS_MEMORY_REDACT.help":"可选覆盖记忆脱敏策略;留空使用默认值。","system.env.field.SPS_MEMORY_IMPORT":"记忆导入","system.env.field.SPS_MEMORY_IMPORT.help":"on 时把 worker 会话导入外部记忆库;需 external 模式且配了外部地址才生效。","system.env.field.SPS_DOUBAO_API_KEY":"豆包 API Key","system.env.field.SPS_DOUBAO_API_KEY.help":"火山方舟 API Key(ark-…);未配置时语音输出回落浏览器 Web Speech。","system.env.field.SPS_DOUBAO_SPEAKER":"豆包音色","system.env.field.SPS_DOUBAO_SPEAKER.help":"seed-tts-2.0 音色需带 _uranus_bigtts 后缀。","system.env.field.SPS_DOUBAO_RESOURCE_ID":"豆包资源 ID","system.env.field.SPS_DOUBAO_RESOURCE_ID.help":"TTS 资源 ID;默认 seed-tts-2.0。","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER":"沙箱 Provider","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER.help":"openai 会话执行沙箱。权威键:此处配置覆盖拉起方 env(daemon 重生不回归);留空按 NODE_ENV 推断(production→docker)。","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS":"并发总闸","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS.help":"daemon 全局同时执行的 run 上限(所有平台合计);留空按内存自动推导(30GB≈47)。","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS":"平台配额","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS.help":"按 origin 限并发,如 coral-platform=30,gameforge=20;防单平台吃光全机。","system.env.field.SPS_DAEMON_QUEUE_WAIT_S":"排队等待(秒)","system.env.field.SPS_DAEMON_QUEUE_WAIT_S.help":"满载时 FIFO 排队最长等待;超时返回带 Retry-After 的容量拒绝。默认 20。","system.env.field.SPS_DAEMON_MAX_QUEUE":"排队上限","system.env.field.SPS_DAEMON_MAX_QUEUE.help":"排队队列长度上限,超出直接拒绝。默认 200。","system.env.field.SPS_CONSOLE_TOKEN":"控制台 Token","system.env.field.SPS_CONSOLE_TOKEN.help":"对外暴露控制台时使用的 Bearer Token。","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL":"记忆查看器地址","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL.help":"记忆查看器集成使用的可选 URL。","system.env.error.conflict.title":"env 被其他地方修改了","system.env.error.save.title":"保存失败","system.env.error.conflict.body":"请点取消后重开编辑。","system.upgrade.checkUpdate":"检查更新","system.upgrade.confirm.title":"升级 sps-cli","system.upgrade.confirm.body":"当前 {current},升级到 {latest}。要求所有 pipeline 已停止。升级后请重启 sps console 生效。","system.upgrade.confirm.button":"升级","system.upgrade.success.title":"升级完成","system.upgrade.success.body":'装上了 v{version}。请 `pkill -f "sps console"` 再重启以生效。',"system.upgrade.notEffective.title":"升级未生效","system.upgrade.error.title":"升级失败","system.diagnostics.title":"项目健康检查","system.diagnostics.checkAll":"检查全部","system.diagnostics.empty":"还没有项目。","system.diagnostics.expandAria":"展开","system.diagnostics.collapseAria":"折叠","system.diagnostics.never":'点 "检查" 运行 sps doctor',"system.diagnostics.checkAria":"检查","system.diagnostics.check":"检查","system.diagnostics.noFixesNeeded":"已无可修问题","system.diagnostics.fix.tip":"调 sps doctor <proj> --fix:自动创建 .claude/hooks/stop.sh、state.json 等","system.diagnostics.fixAria":"自动修复","system.diagnostics.fix":"修复","system.diagnostics.fixed":"已修复","system.diagnostics.error.fix":"doctor 修复失败","system.diagnostics.error.check":"doctor 检查失败","chat.list.new":"新建对话","chat.list.title":"会话列表","chat.cli.banner.bold":"CLI 会话","chat.cli.banner":"这是 CLI 会话(由 sps agent 创建),Console 仅展示历史。续聊请在终端运行:","chat.cliBadge":"CLI","chat.cliBadge.tooltip":"该会话由 sps agent CLI 创建,从 Claude jsonl 实时读取(只读)","notFound.title":"404","notFound.body":"这个页面不存在。","notFound.home":"回到首页","dialog.confirm.default":"确定","dialog.alert.default":"知道了","dialog.cancel.default":"取消","dirPicker.title.default":"选择目录","dirPicker.close.aria":"关闭","dirPicker.up.aria":"上级目录","dirPicker.up.title":"上级目录","dirPicker.home.aria":"回到 Home","dirPicker.home.title":"回到 Home","dirPicker.loading":"加载中...","dirPicker.error.title":"读取失败","dirPicker.empty":"— 空目录 —","dirPicker.enter.aria":"进入 {name}/","dirPicker.pickFile.aria":"选择 {name}(双击直接确认)","dirPicker.fileLocked":"文件不可选","dirPicker.cancel":"取消","dirPicker.useFile":"使用此文件","dirPicker.useFile.tooltip.empty":"请先点选一个文件","dirPicker.useDir":"选此目录","dirPicker.newDir":"新建目录","dirPicker.newDir.aria":"在当前目录下新建子目录","dirPicker.newDir.prompt":"新目录名(仅字母数字 _ . -)","dirPicker.newDir.placeholder":"目录名","dirPicker.newDir.create":"创建","dirPicker.newDir.error.title":"新建目录失败","chat.message.truncated":"⚠ 输出超过 10MB,已截断","chat.newSession.title":"新建对话","chat.newSession.title.aria":"新建对话","chat.newSession.close.aria":"关闭","chat.newSession.field.agent":"Agent 后端","chat.newSession.field.agent.openaiHint":"OpenAI 会话用已配置的 openai 模型,上面的模型选择不生效","chat.newSession.field.model":"模型(可选)","chat.newSession.field.model.default":"用全局默认模型","chat.newSession.field.title":"标题(可选)","chat.newSession.field.title.placeholder":"留空 = 自动用首条消息生成","chat.newSession.field.cwd":"工作目录(可选)","chat.newSession.field.cwd.browse":"浏览","chat.newSession.field.cwd.browseAria":"浏览选择目录","chat.newSession.field.cwd.help1":"Agent 在该目录下读写文件。绝对路径,必须存在。","chat.newSession.field.cwd.help2":"留空则自动为该对话新建一个独立工作目录。","chat.newSession.cancel":"取消","chat.newSession.create":"创建","cardModal.editing":"⚠ 编辑中","cardModal.order":"第 {n} 波","cardModal.order.tip":"执行波次(order):同波并行,前一波全部完成才开下一波","cardModal.title.aria":"卡片标题","cardModal.editAria":"编辑卡片","cardModal.edit":"编辑","cardModal.close.aria":"关闭","cardModal.error.save.title":"保存失败","cardModal.error.load":"加载失败:{detail}","cardModal.skills.loading":"加载 skill 列表…","cardModal.label.removeAria":"删除 {label}","cardModal.label.addPlaceholder":"+ 添加 label","cardModal.label.addAria":"添加 label","cardModal.label.note":"注意:AI-PIPELINE / STARTED-* / COMPLETED-* / NEEDS-FIX 由流水线自动管理,手动改可能被覆盖","cardModal.section.description":"描述","cardModal.section.empty":"(空)","cardModal.section.checklist":"检查清单","cardModal.checklist.empty":"暂无清单项。在描述里用 `- [ ] 项` 语法添加。","cardModal.section.log":"日志","cardModal.body.aria":"卡片描述","cardModal.body.replaceNote":'只替换 "## 描述" 段的内容;检查清单和日志段不动。',"cardModal.action.launch":"启动 worker","cardModal.action.launch.disabledDone":"卡片已完成;先拖回 Todo 再启动","cardModal.action.launch.disabledRunning":"Pipeline 正在跑——supervisor 会自动 dispatch,无需手动启动","cardModal.action.launch.error":"启动 worker 失败","cardModal.action.reset":"重置卡片","cardModal.action.viewPrompt":"查看 prompt","cardModal.prompt.title":"注入 worker 的提示词(预览)","cardModal.prompt.loading":"重建提示词中…","cardModal.prompt.error":"获取失败:{detail}","cardModal.prompt.copy":"复制","cardModal.prompt.copied":"已复制","cardModal.prompt.metaSkills":"skills:{skills}","cardModal.prompt.metaMemory":"记忆块","cardModal.prompt.metaGit":"git 模式","cardModal.prompt.metaNonGit":"非 git","cardModal.prompt.nativeTitle":"claude 另原生读入(不在本串里):","cardModal.prompt.sourceActual":"✅ 派发时真实注入({time})","cardModal.prompt.sourcePreview":"⚠️ 预览重建(本卡未派发过;记忆按当前库状态,可能与真实派发不同)","cardModal.action.reset.confirm.title":"重置卡片 #{seq}","cardModal.action.reset.confirm.body":"卡片状态会回到初始,已做的 checklist 会清空。","cardModal.action.reset.confirm.button":"重置","cardModal.action.reset.error":"重置失败","cardModal.action.delete":"删除卡片","cardModal.action.delete.confirm1.title":"删除卡片 #{seq}","cardModal.action.delete.confirm1.body":'即将删除 "{title}"。此操作不可恢复(md 文件将被物理删除)。是否继续?',"cardModal.action.delete.confirm1.button":"继续","cardModal.action.delete.confirm2.title":"最终确认","cardModal.action.delete.confirm2.body":"请再次确认删除卡片 #{seq}。","projectDetail.tab.skills":"技能","projectDetail.tab.rules":"规则","projectDetail.skills.title":"Skill 白名单","projectDetail.skills.desc":"选择本项目加载哪些 skill。收窄 worker、subagent 与 chat 能看到的范围,降低 token 消耗。","projectDetail.skills.noPolicy":"未设白名单 —— 全部 skill 都可用(subagent 会从磁盘吃全量)。","projectDetail.skills.hasPolicy":"白名单已生效 —— {count} 个 skill 合格。","projectDetail.skills.save":"保存","projectDetail.skills.detail":"详情","projectDetail.skills.saveError":"保存白名单失败","projectDetail.skills.applied":"已保存。投影 {linked} 个链接,清理 {pruned} 个。","projectDetail.skills.unknown":"未识别的 skill 名(已忽略):{names}","projectDetail.skills.empty":"尚无已安装的 skill,先跑 `sps skill sync`。","projectDetail.skills.selectAll":"全选","projectDetail.skills.selectNone":"全不选","projectDetail.rules.readonly":"sps-cli 只读这些文件。编辑在项目创建时或日后由 agent 协助完成。","projectDetail.rules.missing":"不存在","nav.prompts":"提示词","prompts.title":"提示词库","prompts.desc":"带 {{变量}} 模板的可复用提示词,可插入到会话中。","prompts.new":"新建提示词","prompts.search":"搜索提示词…","prompts.empty":"还没有提示词,新建一个。","prompts.name":"名称","prompts.namePlaceholder":"kebab-case,如 code-review","prompts.nameError":"名称须为 kebab-case(小写字母、数字、连字符)。","prompts.description":"描述","prompts.tags":"标签","prompts.body":"正文","prompts.bodyPlaceholder":"写你的提示词。用 {{变量}} 做填充位。","prompts.favorite":"收藏","prompts.save":"保存","prompts.delete":"删除","prompts.deleteConfirm":"删除提示词「{name}」?会移除文件。","prompts.saveError":"保存提示词失败","prompts.vars":"变量:{names}","prompts.noVars":"无变量","prompts.insert":"插入提示词","prompts.selectHint":"在左侧选择一个提示词,或新建一个。","prompts.tagAdd":"输入标签后按 Enter","prompts.ai":"AI 生成","prompts.ai.title":"AI 生成提示词","prompts.ai.intent":"描述你想要什么","prompts.ai.placeholder":"例如:一个用于审查 TypeScript 代码安全问题的提示词","prompts.ai.submit":"生成","prompts.ai.wait":"agent 正在生成…可能需要一会儿。","prompts.ai.error":"生成失败","skills.import":"导入","skills.import.title":"导入 Skill","skills.import.name":"名称(kebab-case)","skills.import.body":"SKILL.md 内容","skills.import.submit":"导入","skills.import.error":"导入失败","skills.export":"导出 SKILL.md","skills.updates.badge":"有 {count} 个可更新","skills.ai":"AI 创建","skills.ai.title":"AI 创建 Skill","skills.ai.name":"名称(kebab-case)","skills.ai.intent":"这个 skill 用来做什么?","skills.ai.placeholder":"例如:如何写地道的 Rust 错误处理","skills.ai.submit":"创建","skills.ai.wait":"agent 正在生成 skill…可能需要一会儿。","skills.ai.error":"创建失败","projectDetail.tab.graph":"代码图谱","projectDetail.tab.logs":"日志","graph.title":"代码图谱","graph.desc":"本项目的符号级依赖图(tree-sitter,零 token)。给 agent 精准上下文,少读文件、省 token。","graph.build":"建图","graph.rebuild":"重建","graph.building":"建图中…","graph.sync":"增量同步","graph.syncing":"同步中…","graph.sync.desc":"增量 —— 只重新索引变化的文件(快)","graph.empty":"尚未建图 —— 建一次即可启用 agent 导航与依赖图。","graph.buildFailed":"建图失败","graph.stat.files":"文件","graph.stat.nodes":"节点","graph.stat.edges":"边","graph.stat.db":"DB 体积","graph.stat.lastBuilt":"上次建图","graph.viz.loading":"加载图谱…","graph.viz.empty":"建图后可查看依赖图。","graph.viz.hint":"节点=文件 · 边=import · 拖拽探索 · 搜索高亮","graph.viz.search":"高亮文件…"},Fj=C.createContext(null),$j="sps-console-lang";function j6(){if(typeof window>"u")return"en";try{const e=window.localStorage.getItem($j);if(e==="en"||e==="zh")return e}catch{}return"en"}function M6(e){try{window.localStorage.setItem($j,e)}catch{}}function R6({children:e}){const[t,n]=C.useState(()=>j6());C.useEffect(()=>{typeof document<"u"&&(document.documentElement.lang=t==="zh"?"zh-CN":"en")},[t]);const i=C.useCallback(o=>{n(o),M6(o)},[]),s=C.useMemo(()=>{const o=t==="zh"?A6:T6;return(c,u)=>{let f=o[c]??c;if(u)for(const[m,p]of Object.entries(u))p!==void 0&&(f=f.replace(`{${m}}`,String(p)));return f}},[t]),a=C.useMemo(()=>({lang:t,setLang:i,t:s}),[t,i,s]);return d.jsx(Fj.Provider,{value:a,children:e})}function qj(){const e=C.useContext(Fj);if(!e)throw new Error("useLang must be used inside I18nProvider");return e}function Xe(){return qj().t}function D6(...e){return e.filter(Boolean).join(" ")}const O6=3,L6=1,I6=e=>{const t=C.useRef(0),n=C.useRef(0),i=C.useRef(0),s=C.useRef(new Date),a=C.useRef(null),o=C.useRef(null),c=C.useCallback(m=>{const[p,y]=[a.current,o.current];if(!p||!y)return;y.style.filter=`blur(${Math.min(8/m-8,100)}px)`,y.style.opacity=`${Math.pow(m,.4)*100}%`;const b=1-m;p.style.filter=`blur(${Math.min(8/b-8,100)}px)`,p.style.opacity=`${Math.pow(b,.4)*100}%`,p.textContent=e[t.current%e.length]??"",y.textContent=e[(t.current+1)%e.length]??""},[e]),u=C.useCallback(()=>{n.current-=i.current,i.current=0;let m=n.current/O6;m>1&&(i.current=L6,m=1),c(m),m===1&&t.current++},[c]),f=C.useCallback(()=>{n.current=0;const[m,p]=[a.current,o.current];m&&p&&(p.style.filter="none",p.style.opacity="100%",m.style.filter="none",m.style.opacity="0%")},[]);return C.useEffect(()=>{let m;const p=()=>{m=requestAnimationFrame(p);const y=new Date,b=(y.getTime()-s.current.getTime())/1e3;s.current=y,i.current-=b,i.current<=0?u():f()};return p(),()=>{cancelAnimationFrame(m)}},[u,f]),{text1Ref:a,text2Ref:o}},P6=({texts:e})=>{const{text1Ref:t,text2Ref:n}=I6(e);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"absolute inset-x-0 top-0 m-auto inline-block w-full",ref:t}),d.jsx("span",{className:"absolute inset-x-0 top-0 m-auto inline-block w-full",ref:n})]})},z6=()=>d.jsx("svg",{id:"morphing-filters",className:"hidden","aria-hidden":"true",preserveAspectRatio:"xMidYMid slice",children:d.jsx("defs",{children:d.jsx("filter",{id:"threshold",children:d.jsx("feColorMatrix",{in:"SourceGraphic",type:"matrix",values:`1 0 0 0 0
|
|
472
|
+
{paths}`,"projectDetail.danger.deleted.body":"Project deleted.","projectDetail.danger.error":"Delete failed","pipelineEditor.close":"Close","pipelineEditor.error.conflict.title":"File was modified elsewhere","pipelineEditor.error.yaml.title":"YAML syntax error","pipelineEditor.error.save.title":"Save failed","pipelineEditor.error.serialize.title":"YAML serialize failed","pipelineEditor.error.load":"Load failed: {detail}","pipelineEditor.mode.structured":"Structured","pipelineEditor.mode.yaml":"Raw YAML","pipelineEditor.parseError.prefix":"YAML parse: {detail}","pipelineEditor.activeWarning":"⚠ This is the active pipeline — saving will take effect on the next tick","pipelineEditor.yamlAria":"pipeline YAML editor","pipelineEditor.status.unsaved":"● Unsaved","pipelineEditor.status.saved":"Saved","pipelineEditor.status.noChanges":"No changes","pipelineEditor.reload":"Reload","pipelineEditor.save":"Save","pipelineEditor.saveAria":"Save pipeline","pipelineEditor.activeBadge":"active","pipelineEditor.modeHint":"project = event-driven pipeline (default) · steps = sequential script","pipelineEditor.stages.heading":"Stages ({count})","pipelineEditor.stages.add":"Add stage","pipelineEditor.stages.empty":'No stages yet. Click "Add stage" to start.',"pipelineEditor.stage.name.hint":"Unique stage name","pipelineEditor.stage.profile.hint":"skill profile, may be empty","pipelineEditor.stage.cardState.hint":"Card state during this stage","pipelineEditor.stage.timeout.hint":"Optional, e.g. 30m 2h","pipelineEditor.stage.trigger.hint":"Trigger condition, blank uses default","pipelineEditor.stage.onComplete.hint":"Action on success","pipelineEditor.stage.onFail.action.hint":"Action on failure, e.g. label NEEDS-FIX","pipelineEditor.stage.onFail.comment.hint":"Comment written on the card","pipelineEditor.stage.halt.note":"(stops pipeline on failure; uncheck to continue with next card)","pipelineEditor.stage.moveUp":"Move up","pipelineEditor.stage.moveDown":"Move down","pipelineEditor.stage.remove":"Remove stage","newPipelineDialog.title":"New pipeline","newPipelineDialog.field.filename.label":"Filename","newPipelineDialog.field.filename.placeholder":"e.g. ci","newPipelineDialog.field.filename.help":"Will be saved as {filename}. Only a-z A-Z 0-9 _ - allowed; an existing file errors 409.","newPipelineDialog.section.template":"Initial content","newPipelineDialog.template.blank.label":"Blank template","newPipelineDialog.template.blank.desc":"Minimal 1-stage pipeline (develop → Done)","newPipelineDialog.template.sample.label":"Tutorial template","newPipelineDialog.template.sample.desc":"Copied from sample.yaml.example (annotated, every field explained)","newPipelineDialog.template.sample.unavailable":"sample.yaml.example does not exist","newPipelineDialog.template.active.label":"Copy current active","newPipelineDialog.template.active.desc":"Copied from project.yaml (build on the current config)","newPipelineDialog.template.active.unavailable":"project.yaml does not exist","newPipelineDialog.create.aria":"Create pipeline","board.title":"Board","board.title.bare":"Board","board.subtitle":"{name} · {cards} cards · {workers} workers active","board.pickPrompt.title":"Pick a project","board.pickPrompt.body":"The board is per-project. Pick one to start:","board.action.start":"Start","board.action.stop":"Stop","board.action.startAria":"Start pipeline","board.action.stopAria":"Stop pipeline","board.action.startError":"Failed to start pipeline","board.action.stopError":"Failed to stop pipeline","board.action.reset":"Reset","board.action.resetError":"Reset failed","board.action.reset.confirm.title":"Reset the entire pipeline","board.action.reset.confirm.body":"This clears all cards’ run state, worker markers, and branches. Cannot be undone.","board.action.reset.confirm.button":"Reset all","board.action.newCard":"New card","board.action.newCard.error":"Failed to create card","board.action.moveCard.error":"Failed to move card","board.search.placeholder":"Search title / skill / label…","board.search.aria":"Search cards","board.filter.clear":"Clear","board.filter.clearAria":"Clear filters","board.filter.aria":"Filter by {label}","board.filter.clearSelection":"Clear selection","board.error.loadCards":"Failed to load cards","board.col.planning":"Planning","board.col.backlog":"Backlog","board.col.todo":"Todo","board.col.inprogress":"Inprogress","board.col.qa":"QA / Review","board.col.done":"Done","kanban.checklist.label":"Checklist {done}/{total}","kanban.checklist.more":"… {count} more","kanban.column.empty":"— empty —","kanban.time.justNow":"just now","kanban.time.minutes":"{n}m ago","kanban.time.hours":"{n}h ago","newCard.title":"New card","newCard.field.title":"Title *","newCard.field.title.placeholder":"e.g. Add GitHub OAuth login","newCard.field.title.help":"Short, clear goal (<200 chars)","newCard.field.description":"Description","newCard.field.description.placeholder":"User story, requirements, acceptance criteria, references… Claude reads this when starting","newCard.field.description.help":"Markdown supported. If empty, Claude only sees the title.","newCard.field.skills":"Skills","newCard.field.skills.help":"Pick which skills get loaded (via frontmatter `skills:`). Optional — worker falls back to project-level skills.","newCard.field.skills.loading":"Loading skills…","newCard.field.skills.error":"Failed to load skills (creation still works): {detail}","newCard.field.skills.selected":"{count} selected: {names}","newCard.field.dispatch":"Dispatch","newCard.field.dispatch.label":"Dispatch immediately (go straight to Backlog)","newCard.field.dispatch.help":"Default off: card lands in Planning to wait; drag to Backlog when ready. On: skip Planning, the next tick assigns a worker.","newCard.create.aria":"Create card","cardDetail.save":"Save","logs.scroll.bottom.aria":"Scroll to bottom","logs.filter.keyword.placeholder":"Filter keyword…","logs.filter.keyword.aria":"Filter logs","logs.empty.match":"No matching logs","skills.category.all":"All","skills.category.language":"language","skills.category.domain":"domain","skills.category.persona":"persona","skills.category.workflow":"workflow","skills.category.engine":"engine","skills.category.genre":"genre","skills.category.platform":"platform","skills.category.review":"review","skills.category.meta":"meta","skills.category.other":"other","skills.tags.title":"Tags","skills.tags.clear":"Clear","skills.subtitleCount":"{count} user-level skill(s)","skills.search.placeholder":"Search skill…","skills.search.aria":"Search skill","skillDetail.close.aria":"Close","skillDetail.loading":"Loading…","skillDetail.error.load":"Load failed: {detail}","skillDetail.section.preview":"SKILL.md preview","skillDetail.toggleSection.aria":"{action} {file}","skillDetail.expand":"Expand","skillDetail.collapse":"Collapse","skillDetail.edit":"Edit","skillDetail.translate":"ZH/EN","skillDetail.delete":"Delete","skillDetail.save":"Save","skillDetail.cancel":"Cancel","skillDetail.translating":"Translating…","skillDetail.saving":"Saving…","skillDetail.editHint":"Edit the raw SKILL.md (incl. frontmatter). After saving, run `sps skill lint` to check the taxonomy & format.","skillDetail.deleteConfirm":'Delete "{name}" from the library? The whole directory is removed — this cannot be undone.',"skillDetail.translateFailed":"Translate failed: {detail}","skillDetail.saveFailed":"Save failed: {detail}","skillDetail.deleteFailed":"Delete failed: {detail}","system.h1":"System","system.tab.config":"Global Config","system.tab.processes":"Processes","system.tab.doctor":"Diagnostics","system.tab.audit":"Audit Log","system.upgrade.upToDate":"Already up to date ({version})","system.memory.title":"Memory backend","system.memory.desc":"Global setting: which backend workers read/write memory through. Applies to newly dispatched cards.","system.memory.provider":"Backend","system.memory.url":"Custom URL","system.memory.url.placeholder":"http://127.0.0.1:3111","system.memory.save":"Save","system.memory.save.aria":"Save memory backend setting","system.memory.saved":"Saved","system.memory.error":"Save failed","system.env.warning":"⚠ This file contains plaintext credentials. Keep mode 0600 on save.","system.env.settingsAria":"Global configuration settings","system.env.dirtyMark":" · ● Unsaved","system.env.save":"Save","system.env.save.aria":"Save env","system.env.section.git":"Git","system.env.section.git.hint":"Shared remote host credentials and SSH connection hints.","system.env.section.matrix":"Matrix","system.env.section.matrix.hint":"Global notification defaults used by projects without overrides.","system.env.section.memory":"Memory","system.env.section.memory.hint":"Runtime memory mode, external service URL, and capture policy.","system.env.section.daemon":"Daemon","system.env.section.daemon.hint":"Authoritative shared-daemon config (applied at startup since 0.65.15, overrides launcher env): sandbox plus concurrency gate/quotas/queue. Restart the daemon to apply changes.","system.env.section.console":"Console","system.env.section.console.hint":"Console access and optional linked service URLs.","system.env.section.custom":"Additional variables","system.env.section.custom.hint":"Unknown env variables are preserved here.","system.env.custom.empty":"No additional variables.","system.env.custom.keyPlaceholder":"CUSTOM_KEY","system.env.custom.valuePlaceholder":"value","system.env.custom.keyAria":"New variable key","system.env.custom.valueAria":"Value for {key}","system.env.custom.newValueAria":"New variable value","system.env.custom.removeAria":"Remove {key}","system.env.custom.add":"Add","system.env.field.GITLAB_URL":"GitLab URL","system.env.field.GITLAB_URL.help":"Base URL for GitLab API calls; leave blank when unused.","system.env.field.GITLAB_TOKEN":"GitLab token","system.env.field.GITLAB_TOKEN.help":"Personal access token for GitLab API calls.","system.env.field.MATRIX_HOMESERVER":"Matrix homeserver","system.env.field.MATRIX_HOMESERVER.help":"Homeserver URL for notifications.","system.env.field.MATRIX_ACCESS_TOKEN":"Matrix access token","system.env.field.MATRIX_ACCESS_TOKEN.help":"Access token used by the Matrix notifier.","system.env.field.MATRIX_ROOM_ID":"Matrix room","system.env.field.MATRIX_ROOM_ID.help":"Default notification room; project config can override it.","system.env.field.SPS_MEMORY_MODE":"Memory mode","system.env.field.SPS_MEMORY_MODE.help":"local stores memory on this machine; external uses a remote service.","system.env.field.SPS_MEMORY_EXTERNAL_URL":"External memory URL","system.env.field.SPS_MEMORY_EXTERNAL_URL.help":"Required when memory mode includes external storage.","system.env.field.SPS_MEMORY_DISTILL":"Memory distill","system.env.field.SPS_MEMORY_DISTILL.help":"Set to on to use the configured reviewer model for distilled memory capture.","system.env.field.SPS_MEMORY_REDACT":"Memory redaction","system.env.field.SPS_MEMORY_REDACT.help":"Optional override for memory redaction; blank keeps the default.","system.env.field.SPS_MEMORY_IMPORT":"Memory import","system.env.field.SPS_MEMORY_IMPORT.help":"When on, worker sessions are imported into the external memory store; requires an external mode plus a configured external URL.","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER":"Sandbox provider","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER.help":"Execution sandbox for OpenAI sessions. Authoritative: this value overrides the launcher env (daemon respawn safe); blank infers from NODE_ENV (production→docker).","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS":"Global run limit","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS.help":"Daemon-wide concurrent run cap across all platforms; blank derives from machine memory (30GB≈47).","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS":"Per-platform quotas","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS.help":"Concurrency quota per origin, e.g. coral-platform=30,gameforge=20; keeps one platform from starving the rest.","system.env.field.SPS_DAEMON_QUEUE_WAIT_S":"Queue wait (s)","system.env.field.SPS_DAEMON_QUEUE_WAIT_S.help":"Max FIFO queue wait when at capacity; timeouts return a typed rejection with Retry-After. Default 20.","system.env.field.SPS_DAEMON_MAX_QUEUE":"Queue cap","system.env.field.SPS_DAEMON_MAX_QUEUE.help":"Max queued runs before immediate rejection. Default 200.","system.env.field.SPS_RUN_IDLE_MINUTES":"Run idle timeout (min)","system.env.field.SPS_RUN_IDLE_MINUTES.help":"A chat turn with no events beyond this is deemed stuck and cancelled. Default 5.","system.env.field.SPS_RUN_TOOL_IDLE_MINUTES":"Tool-run timeout (min)","system.env.field.SPS_RUN_TOOL_IDLE_MINUTES.help":"Wider timeout used while a tool is executing (long media generation etc., 0.65.24+). Default 12; raise for slow local providers.","system.env.field.SPS_STUCK_RUN_MINUTES":"Stale-run reclaim (min)","system.env.field.SPS_STUCK_RUN_MINUTES.help":"A currentRun with silent output beyond this gets reclaimed as stale. Default 20.","system.env.field.SPS_CONSOLE_TOKEN":"Console token","system.env.field.SPS_CONSOLE_TOKEN.help":"Bearer token required when exposing the console.","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL":"Memory viewer URL","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL.help":"Optional URL opened by the memory viewer integration.","system.env.error.conflict.title":"env was modified elsewhere","system.env.error.save.title":"Save failed","system.env.error.conflict.body":"Cancel and reopen the editor.","system.upgrade.checkUpdate":"Check update","system.upgrade.confirm.title":"Upgrade sps-cli","system.upgrade.confirm.body":"Current {current}, upgrade to {latest}. Requires all pipelines stopped. Restart sps console after upgrade.","system.upgrade.confirm.button":"Upgrade","system.upgrade.success.title":"Upgrade complete","system.upgrade.success.body":'Installed v{version}. Run `pkill -f "sps console"` and restart to see it.',"system.upgrade.notEffective.title":"Upgrade not effective","system.upgrade.error.title":"Upgrade failed","system.diagnostics.title":"Project health check","system.diagnostics.checkAll":"Check all","system.diagnostics.empty":"No projects yet.","system.diagnostics.expandAria":"Expand","system.diagnostics.collapseAria":"Collapse","system.diagnostics.never":'Click "Check" to run sps doctor',"system.diagnostics.checkAria":"Check","system.diagnostics.check":"Check","system.diagnostics.noFixesNeeded":"Nothing to fix","system.diagnostics.fix.tip":"Run sps doctor <proj> --fix: auto-create .claude/hooks/stop.sh, state.json, etc.","system.diagnostics.fixAria":"Auto fix","system.diagnostics.fix":"Fix","system.diagnostics.fixed":"Fixed","system.diagnostics.error.fix":"doctor fix failed","system.diagnostics.error.check":"doctor check failed","chat.list.new":"New chat","chat.list.title":"Sessions","chat.cli.banner.bold":"CLI session","chat.cli.banner":"This session was created by sps agent. The Console only shows history. To continue, run in a terminal:","chat.cliBadge":"CLI","chat.cliBadge.tooltip":"Created by sps agent CLI; history is read live from Claude jsonl (read-only).","notFound.title":"404","notFound.body":"This page does not exist.","notFound.home":"Back to home","dialog.confirm.default":"OK","dialog.alert.default":"Got it","dialog.cancel.default":"Cancel","dirPicker.title.default":"Pick a directory","dirPicker.close.aria":"Close","dirPicker.up.aria":"Parent directory","dirPicker.up.title":"Parent directory","dirPicker.home.aria":"Back to home","dirPicker.home.title":"Back to home","dirPicker.loading":"Loading…","dirPicker.error.title":"Read failed","dirPicker.empty":"— empty —","dirPicker.enter.aria":"Enter {name}/","dirPicker.pickFile.aria":"Pick {name} (double-click to confirm)","dirPicker.fileLocked":"File not selectable","dirPicker.cancel":"Cancel","dirPicker.useFile":"Use this file","dirPicker.useFile.tooltip.empty":"Click a file first","dirPicker.useDir":"Use this directory","dirPicker.newDir":"New folder","dirPicker.newDir.aria":"Create a subdirectory in the current directory","dirPicker.newDir.prompt":"New folder name (letters, digits, _ . - only)","dirPicker.newDir.placeholder":"Folder name","dirPicker.newDir.create":"Create","dirPicker.newDir.error.title":"Failed to create folder","chat.message.truncated":"⚠ Output exceeded 10MB and was truncated","chat.newSession.title":"New chat","chat.newSession.title.aria":"New chat","chat.newSession.close.aria":"Close","chat.newSession.field.agent":"Agent backend","chat.newSession.field.agent.openaiHint":"OpenAI sessions use the configured openai model; the model picker above does not apply","chat.newSession.field.model":"Model (optional)","chat.newSession.field.model.default":"Use global default model","chat.newSession.field.title":"Title (optional)","chat.newSession.field.title.placeholder":"Empty = auto-generate from first message","chat.newSession.field.cwd":"Working directory (optional)","chat.newSession.field.cwd.browse":"Browse","chat.newSession.field.cwd.browseAria":"Pick directory","chat.newSession.field.cwd.help1":"The agent reads/writes files here. Absolute path; must exist.","chat.newSession.field.cwd.help2":"Leave blank to auto-create a dedicated workspace for this chat.","chat.newSession.cancel":"Cancel","chat.newSession.create":"Create","cardModal.editing":"⚠ Editing","cardModal.order":"Wave {n}","cardModal.order.tip":"Execution wave (order): same wave runs in parallel; a wave starts only after the previous one fully completes","cardModal.title.aria":"Card title","cardModal.editAria":"Edit card","cardModal.edit":"Edit","cardModal.close.aria":"Close","cardModal.error.save.title":"Save failed","cardModal.error.load":"Load failed: {detail}","cardModal.skills.loading":"Loading skill list…","cardModal.label.removeAria":"Remove {label}","cardModal.label.addPlaceholder":"+ Add label","cardModal.label.addAria":"Add label","cardModal.label.note":"Note: AI-PIPELINE / STARTED-* / COMPLETED-* / NEEDS-FIX are managed by the pipeline; manual changes may be overwritten","cardModal.section.description":"Description","cardModal.section.empty":"(empty)","cardModal.section.checklist":"Checklist","cardModal.checklist.empty":"No checklist items. Add `- [ ] item` syntax in the description.","cardModal.section.log":"Log","cardModal.body.aria":"Card description","cardModal.body.replaceNote":'Only replaces the "## Description" section; checklist and log sections are untouched.',"cardModal.action.launch":"Launch worker","cardModal.action.launch.disabledDone":"Card is done; drag back to Todo to launch","cardModal.action.launch.disabledRunning":"Pipeline is running — supervisor dispatches automatically, no manual launch needed","cardModal.action.launch.error":"Launch worker failed","cardModal.action.reset":"Reset card","cardModal.action.viewPrompt":"View prompt","cardModal.prompt.title":"Worker prompt (preview)","cardModal.prompt.loading":"Rebuilding prompt…","cardModal.prompt.error":"Failed: {detail}","cardModal.prompt.copy":"Copy","cardModal.prompt.copied":"Copied","cardModal.prompt.metaSkills":"skills: {skills}","cardModal.prompt.metaMemory":"memory block","cardModal.prompt.metaGit":"git mode","cardModal.prompt.metaNonGit":"non-git","cardModal.prompt.nativeTitle":"Also read natively by claude (not in this string):","cardModal.prompt.sourceActual":"✅ Actual prompt as dispatched ({time})","cardModal.prompt.sourcePreview":"⚠️ Reconstructed preview (card not yet dispatched; memory reflects current state, may differ from the real dispatch)","cardModal.action.reset.confirm.title":"Reset card #{seq}","cardModal.action.reset.confirm.body":"Card state goes back to initial; checklist progress is cleared.","cardModal.action.reset.confirm.button":"Reset","cardModal.action.reset.error":"Reset failed","cardModal.action.delete":"Delete card","cardModal.action.delete.confirm1.title":"Delete card #{seq}","cardModal.action.delete.confirm1.body":'About to delete "{title}". This cannot be undone (the md file is physically removed). Continue?',"cardModal.action.delete.confirm1.button":"Continue","cardModal.action.delete.confirm2.title":"Final confirmation","cardModal.action.delete.confirm2.body":"Please re-confirm deleting card #{seq}.","projectDetail.tab.skills":"Skills","projectDetail.tab.rules":"Rules","projectDetail.skills.title":"Skill whitelist","projectDetail.skills.desc":"Pick which skills this project loads. Narrows what workers, subagents and chat see — cuts token cost.","projectDetail.skills.noPolicy":"No whitelist — all skills are available (subagents load the full set from disk).","projectDetail.skills.hasPolicy":"Whitelist active — {count} skill(s) eligible.","projectDetail.skills.save":"Save","projectDetail.skills.detail":"Details","projectDetail.skills.saveError":"Failed to save whitelist","projectDetail.skills.applied":"Saved. Projected {linked} linked, {pruned} pruned.","projectDetail.skills.unknown":"Unknown skill name(s), ignored: {names}","projectDetail.skills.empty":"No skills installed. Run `sps skill sync` first.","projectDetail.skills.selectAll":"Select all","projectDetail.skills.selectNone":"Select none","projectDetail.rules.readonly":"sps-cli only reads these. Editing is done at project creation or by an agent later.","projectDetail.rules.missing":"Not present","nav.prompts":"Prompts","prompts.title":"Prompt library","prompts.desc":"Reusable prompts with {{variable}} templates. Insert them into chat.","prompts.new":"New prompt","prompts.search":"Search prompts…","prompts.empty":"No prompts yet. Create one.","prompts.name":"Name","prompts.namePlaceholder":"kebab-case, e.g. code-review","prompts.nameError":"Name must be kebab-case (a-z, 0-9, dashes).","prompts.description":"Description","prompts.tags":"Tags","prompts.body":"Body","prompts.bodyPlaceholder":"Write your prompt. Use {{variable}} for fill-ins.","prompts.favorite":"Favorite","prompts.save":"Save","prompts.delete":"Delete","prompts.deleteConfirm":'Delete prompt "{name}"? This removes the file.',"prompts.saveError":"Failed to save prompt","prompts.vars":"Variables: {names}","prompts.noVars":"No variables","prompts.insert":"Insert a prompt","prompts.selectHint":"Select a prompt on the left, or create a new one.","prompts.tagAdd":"Type a tag, press Enter","prompts.ai":"AI generate","prompts.ai.title":"AI generate a prompt","prompts.ai.intent":"Describe what you want","prompts.ai.placeholder":"e.g. a prompt for reviewing TypeScript code for security issues","prompts.ai.submit":"Generate","prompts.ai.wait":"The agent is writing… this can take a while.","prompts.ai.error":"Generation failed","skills.import":"Import","skills.import.title":"Import a skill","skills.import.name":"Name (kebab-case)","skills.import.body":"SKILL.md content","skills.import.submit":"Import","skills.import.error":"Import failed","skills.export":"Export SKILL.md","skills.updates.badge":"{count} update(s) available","skills.ai":"AI create","skills.ai.title":"AI create a skill","skills.ai.name":"Name (kebab-case)","skills.ai.intent":"What is this skill for?","skills.ai.placeholder":"e.g. how to write idiomatic Rust error handling","skills.ai.submit":"Create","skills.ai.wait":"The agent is writing the skill… this can take a while.","skills.ai.error":"Create failed","projectDetail.tab.graph":"Code Graph","projectDetail.tab.logs":"Logs","graph.title":"Code Graph","graph.desc":"A symbol-level dependency graph of this project (tree-sitter, zero-token). Gives agents surgical context so they explore fewer files.","graph.build":"Build graph","graph.rebuild":"Rebuild","graph.building":"Building…","graph.sync":"Sync","graph.syncing":"Syncing…","graph.sync.desc":"Incremental — only re-index changed files (fast)","graph.empty":"No graph yet — build one to enable agent navigation and the dependency view.","graph.buildFailed":"Build failed","graph.stat.files":"Files","graph.stat.nodes":"Nodes","graph.stat.edges":"Edges","graph.stat.db":"DB size","graph.stat.lastBuilt":"Last built","graph.viz.loading":"Loading graph…","graph.viz.empty":"Build the graph to see the dependency view.","graph.viz.hint":"Node = file · edge = import · drag to explore · search to highlight","graph.viz.search":"Highlight files…"},A6={"sidebar.collapse":"收起","sidebar.expand":"展开","nav.home":"首页","nav.projects":"项目","nav.board":"看板","nav.skills":"技能","nav.system":"系统","nav.memory":"记忆","nav.plugins":"插件","plugins.h1":"插件","plugins.desc":"全局插件开关。改动对之后新派发的卡生效。","plugins.tab.memory":"记忆","plugins.tab.channel":"频道","plugins.tab.model":"模型","plugins.tab.tool":"工具","plugins.comingSoon":"即将上线","nav.arrange":"编排","flow.addNode":"加节点","flow.tidy":"整理:按执行顺序重排卡片 + 重建默认连线","flow.pickProject":"先选一个项目来编辑它的流程。每个项目有自己的 DAG(存在项目里)。","flow.run":"编译并启动","flow.running":"启动中…","flow.pipelineRunning":"运行中…","flow.node.default":"任务","flow.confirm.deleteTitle":"删除卡片?","flow.confirm.deleteBody":"删除卡片 #{seq}。可用 Ctrl/Cmd+Z 撤销。","flow.node.close":"关闭","flow.node.title":"标题","flow.node.desc":"描述(worker 要做什么)","flow.node.skills":"技能","flow.node.save":"保存","flow.node.delete":"删除节点","flow.hint":"节点=项目的卡。单击选中(Delete 删卡/删连线)、双击编辑、从边缘拖出连线定依赖、把卡拖到某条连线上插入其间。启动会提升待跑卡并跑 pipeline,状态实时刷新。","flow.mode.aria":"切换展示模式","flow.pending.create":"新建卡片","flow.mode.free":"自由","flow.mode.lanes":"泳道","flow.lane.wave":"第 {n} 波","flow.lane.parallel":"{n} 张并行","flow.lane.applying":"正在写入执行顺序…","flow.lane.orderTip":"执行波次(order):同波并行,前一波全部完成才开下一波","flow.lane.hint":"框=执行波次(写进卡片 order,就是真实执行顺序):框内并行,框间左→右按序,前一波全部 Done 才开下一波;连线=波间依赖,颜色/动效=运行状态。拖卡进另一个框=并入该波,拖到框外间隙=独立新波。单击卡编辑。","flow.err.noProject":"先选一个项目。","flow.err.noNodes":"至少加一个节点。","flow.status.creating":"准备卡片","flow.status.starting":"启动 pipeline…","flow.status.done":"已建 {n} 张卡 · pipeline 已启动","flow.goBoard":"去看板","nav.aria":"主导航","home.inputToggle":"切换语音 / 文字输入","home.copy":"复制","home.play":"播放","home.stop":"停止","home.artifacts.label":"产物","home.sessions.tabAll":"全部","home.sessions.expandWeek":"展开 7 天前的会话({count})","home.sessions.expandMonth":"展开 1 个月前的会话({count})","home.sessions.collapseOld":"收起早期会话","home.sessions.open":"展开会话列表","home.sessions.collapse":"收起会话列表","home.sessions.delete":"删除会话","home.sessions.deleteConfirm":"删除这条对话?此操作不可撤销。","home.interrupt":"中断","home.attach.remove":"移除附件","home.text.placeholder":"输入消息…","home.text.send":"发送","home.attach":"添加附件","home.text.hint":"Enter 发送 · Shift+Enter 换行","home.auto.toggle":"自动监听","home.auto.tip":"自动监听:检测到说话自动开始;静音 2 秒自动结束。","home.auto.armedOpen":"待命中 —— 直接说话即可","home.conversation.empty":"点击下方语音球开始对话","home.conversation.you":"你","home.conversation.ai":"AI","home.conversation.listening":"正在聆听…","home.conversation.thinking":"思考中","home.debug.close":"关闭调试面板","home.voice.start":"开始聆听","home.voice.stop":"结束聆听","home.voice.finish":"再次点击结束聆听","home.voice.idle":"点击语音球或按空格开始","home.voice.listening":"正在聆听","home.voice.thinking":"正在思考","home.voice.speaking":"正在回答","home.error.recognitionUnsupported":"当前浏览器不支持语音识别。","home.error.recognition":"没有识别到有效语音,请重试。","home.error.response":"AI 响应失败,请重试。","home.phase.aria":"语音交互状态","home.phase.idle":"待机","home.phase.listening":"聆听","home.phase.thinking":"思考","home.phase.speaking":"回答","home.visualizer.aria":"Flow 语音声场","home.mic.requesting":"正在连接麦克风","home.message.speaking":"方向已经清晰,我们从第一步开始。","home.customize.title":"参数调节","home.customize.reset":"重置参数","home.customize.colors":"颜色","home.customize.parameters":"参数","home.customize.color1":"颜色 1","home.customize.color2":"颜色 2","home.customize.color3":"颜色 3","home.customize.count":"数量","home.customize.speed":"速度","home.customize.amplitude":"振幅","home.customize.waviness":"波形密度","home.customize.thickness":"宽度","home.customize.glow":"光晕","home.customize.taper":"边缘收束","home.customize.spread":"分离度","home.customize.hueShift":"色相偏移","home.customize.intensity":"亮度","home.customize.saturation":"饱和度","home.customize.opacity":"透明度","home.customize.scale":"缩放","processes.title":"进程监控","processes.refresh":"刷新","processes.col.kind":"类型","processes.col.slot":"会话槽","processes.col.project":"项目","processes.col.state":"状态","processes.col.memory":"内存","processes.col.action":"操作","processes.empty":"没有 SPS 进程","processes.kind.all":"全部类型","processes.kind.worker":"构建 Worker","processes.kind.chat":"对话","processes.kill":"关闭","processes.killConfirm":"确定关闭进程 {slot}?","audit.title":"审计日志","audit.refresh":"刷新","audit.filter.all":"全部","audit.action.create":"创建","audit.action.modify":"修改","audit.action.delete":"删除","audit.action.daemon":"Daemon","audit.col.time":"时间","audit.col.action":"动作","audit.col.project":"项目","audit.col.detail":"详情","audit.empty":"暂无审计记录","lang.toggle.aria":"切换界面语言","lang.en":"EN","lang.zh":"中","theme.toggle.aria":"切换主题","theme.dark":"暗色主题","theme.light":"亮色主题","status.server":"服务","status.offline":"离线","status.sse.open":"SSE","status.sse.connecting":"SSE 连接中","status.sse.down":"SSE·断开","status.pipelines.tooltip":"活跃流水线数","status.workers.tooltip":"活跃 Worker 数","status.pipeline.unit":"流水线","status.worker.unit":"Worker","common.save":"保存","common.cancel":"取消","common.delete":"删除","common.create":"创建","common.edit":"编辑","common.close":"关闭","common.loading":"加载中…","common.retry":"重试","common.yes":"是","common.no":"否","projects.title":"项目","projects.count":"本机有 {count} 个项目","projects.new":"新建项目","projects.selectHint":"在左侧选择一个项目查看详情。","projects.sort.label":"排序方式","projects.sort.activity":"活跃度","projects.sort.date":"修改日期","projects.sort.name":"名字","projects.load.failed":"加载失败","projects.empty.title":"还没有项目","projects.empty.hint":"运行 {cmd} 创建第一个项目。","newProject.title":"新建项目","newProject.field.name":"项目名","newProject.field.dir":"项目目录","newProject.submit":"创建项目","newProject.creating":"创建中…","newProject.dir.browse":"浏览","newProject.dir.browseAria":"选择目录","newProject.back":"返回","newProject.back.aria":"返回项目列表","newProject.field.name.placeholder":"例如:acme-web","newProject.field.name.invalid":"名称只能包含 a-z A-Z 0-9 _ -","newProject.field.dir.long":"本机绝对路径的【项目目录】。选中的目录本身就是项目根;项目名默认取目录名。已有代码 → 收编(只加 .claude/ 配置,不动源码);空目录 → 新建。","newProject.field.dir.placeholder":"/home/you/projects/my-app","newProject.field.dir.createIfMissing":"目录不存在时自动创建(推荐 —— 否则 .claude/ 安装会被跳过)","newProject.field.dir.pickerTitle":"选择项目目录","newProject.field.dir.adopt":"检测到已有内容 → 将收编(只加配置,不动源码)","newProject.field.dir.fresh":"空目录 → 新建项目","newProject.field.name.derived":"项目名(默认取目录名,可微调)","newProject.field.maxWorkers.short":"最大 Worker 数","newProject.field.ackTimeout.minutes":"ACK 超时(分钟)","newProject.field.ackTimeout.minutes.help":"Worker 启动后多久没 ACK 视为失败","newProject.field.git.label":"启用 Git(Worker 自动 commit + push)","newProject.field.git.detail":"关闭后 Worker 只做任务、不做版本控制;适合文档/数据处理等非代码项目。","newProject.field.review.label":"启用清单验收(每卡完成后独立 agent 审核)","newProject.field.review.detail":"开启后:卡带「检查清单」的,Worker 完成后由独立 reviewer 逐条对着真实产物验收;全过留 Done,有不过自动插一张修正卡(优先跑)。无清单的卡不审。建卡时用 --checklist 写验收点。","newProject.field.git.branch":"合并分支","newProject.field.gitlabProject.label":"Git 远程项目路径","newProject.field.gitlabProject.help2":"如 user/repo,空则跳过远程 API(只本地 commit/push)","newProject.field.gitlabProject.placeholder":"user/repo","newProject.field.gitlabProjectId":"GitLab 项目 ID","newProject.field.gitlabProjectId.help":"数字;GitHub 用户留空","newProject.field.gitlabProjectId.placeholder":"42","newProject.section.notifications":"通知","newProject.field.matrixRoom.label":"Matrix 房间 ID","newProject.field.matrixRoom.help2":"空则使用全局配置;不填 = 不通知","newProject.field.matrixRoom.placeholder":"!abc:matrix.example.com","newProject.error.create.title":"创建失败","projectDetail.tab.pipeline":"流水线","projectDetail.tab.conf":"配置","projectDetail.tab.delete":"删除项目","projectDetail.tab.overview":"概览","projectDetail.tab.config":"配置","projectDetail.tab.pipelines":"流水线","projectDetail.tab.danger":"删除","projectDetail.openBoard":"看板","projectDetail.overview.repoDir":"仓库路径","projectDetail.overview.pmBackend":"PM 后端","projectDetail.overview.agent":"Agent","projectDetail.overview.cards":"卡片","projectDetail.overview.cards.value":"共 {total} 张 · {inprogress} 进行中 · {done} 完成","projectDetail.overview.workers":"Worker","projectDetail.overview.workers.value":"共 {total} 个({active} 活跃)","projectDetail.overview.pipeline":"Pipeline","projectDetail.overview.lastActivity":"最近活动","projectDetail.overview.notFound":"项目 {name} 不存在或无法读取。","projectDetail.config.confDirty":"● 未保存的修改","projectDetail.config.reload":"重新加载","projectDetail.config.save":"保存","projectDetail.config.saveAria":"保存配置","projectDetail.config.settingsAria":"项目配置设置","projectDetail.config.option.empty":"未设置","projectDetail.config.section.basic":"项目","projectDetail.config.section.basic.hint":"项目身份与本地仓库路径。","projectDetail.config.section.git":"Git","projectDetail.config.section.git.hint":"远程仓库与合并行为。","projectDetail.config.section.pipeline":"流水线","projectDetail.config.section.pipeline.hint":"执行模式、卡片标签与审核智能体。","projectDetail.config.section.worker":"Worker","projectDetail.config.section.worker.hint":"Worker 运行方式、槽位与兜底技能。","projectDetail.config.section.policies":"策略","projectDetail.config.section.policies.hint":"超时、冲突处理、记忆与通知。","projectDetail.config.section.custom":"附加变量","projectDetail.config.section.custom.hint":"未内置的 conf 变量会保留在这里。","projectDetail.config.custom.empty":"没有附加变量。","projectDetail.config.custom.keyPlaceholder":"CUSTOM_KEY","projectDetail.config.custom.valuePlaceholder":"值","projectDetail.config.custom.keyAria":"新变量名","projectDetail.config.custom.valueAria":"{key} 的值","projectDetail.config.custom.newValueAria":"新变量值","projectDetail.config.custom.removeAria":"移除 {key}","projectDetail.config.custom.add":"添加","projectDetail.config.disabled.requiresReviewerConsumer":"仅智能编排或清单验收会使用该模型。请先开启其中一个。","projectDetail.config.field.PROJECT_NAME":"项目名","projectDetail.config.field.PROJECT_NAME.help":"项目内部 id。","projectDetail.config.field.PROJECT_DIR":"项目目录","projectDetail.config.field.PROJECT_DIR.help":"代码仓库的本机绝对路径。","projectDetail.config.field.PROJECT_DIR.browse":"浏览","projectDetail.config.field.PROJECT_DIR.browseAria":"选择项目目录","projectDetail.config.field.PROJECT_DIR.pickerTitle":"选择项目目录","projectDetail.config.field.GIT_HOST":"Git 平台","projectDetail.config.field.GIT_HOST.help":"可选覆盖;不填则从仓库 remote 自动判断。","projectDetail.config.field.GITLAB_PROJECT":"远程项目","projectDetail.config.field.GITLAB_PROJECT.help":"仓库路径,例如 user/repo。","projectDetail.config.field.GITLAB_PROJECT_ID":"GitLab 项目 ID","projectDetail.config.field.GITLAB_PROJECT_ID.help":"GitLab 数字 id;GitHub 或自动解析时留空。","projectDetail.config.field.GITLAB_MERGE_BRANCH":"合并分支","projectDetail.config.field.GITLAB_MERGE_BRANCH.help":"Worker commit 或 MR 的目标分支。","projectDetail.config.field.MR_MODE":"MR 模式","projectDetail.config.field.MR_MODE.help":"none 直接 push;create 创建 MR。","projectDetail.config.field.PIPELINE_LABEL":"流水线标签","projectDetail.config.field.PIPELINE_LABEL.help":"卡片带这个标签才会进入项目流水线。","projectDetail.config.field.SPS_REVIEW":"清单验收","projectDetail.config.field.SPS_REVIEW.help":"开启后,带检查清单的完成卡会交给独立 reviewer 审核。","projectDetail.config.field.WORKER_MODEL":"Worker 模型","projectDetail.config.field.WORKER_MODEL.help":"项目级 worker 模型覆盖;留空使用全局默认。","projectDetail.config.field.SA_REVIEWER_MODEL":"Reviewer 模型","projectDetail.config.field.SA_REVIEWER_MODEL.help":"审核与智能编排使用的项目级 reviewer 模型覆盖。","projectDetail.config.field.WORKER_TRANSPORT":"Worker 传输","projectDetail.config.field.WORKER_TRANSPORT.help":"运行时传输方式。当前支持 acp-sdk。","projectDetail.config.field.MAX_CONCURRENT_WORKERS":"Worker 槽位","projectDetail.config.field.MAX_CONCURRENT_WORKERS.help":"最大并发 Worker 数。","projectDetail.config.field.MAX_ACTIONS_PER_TICK":"每轮动作数","projectDetail.config.field.MAX_ACTIONS_PER_TICK.help":"单次 tick 可领取的新任务数量。","projectDetail.config.field.DEFAULT_WORKER_SKILLS":"默认技能","projectDetail.config.field.DEFAULT_WORKER_SKILLS.help":"逗号分隔;卡片没有 profile 或 skills 时使用。","projectDetail.config.field.WORKTREE_DIR":"Worktree 目录","projectDetail.config.field.WORKTREE_DIR.help":"可选的 Worker 临时工作树根目录。","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS":"进行中超时","projectDetail.config.field.INPROGRESS_TIMEOUT_HOURS.help":"超过多少小时后 Monitor 标记 stale runtime。","projectDetail.config.field.WORKER_ACK_TIMEOUT_S":"ACK 超时","projectDetail.config.field.WORKER_ACK_TIMEOUT_S.help":"派发后等待 Worker STARTED 标签的秒数。","projectDetail.config.field.WORKER_ACK_MAX_RETRIES":"ACK 重试","projectDetail.config.field.WORKER_ACK_MAX_RETRIES.help":"ACK 超时后的最大重试次数。","projectDetail.config.field.MONITOR_AUTO_QA":"自动 QA","projectDetail.config.field.MONITOR_AUTO_QA.help":"Monitor 发现 stale runtime 后自动迁到 QA。","projectDetail.config.field.CONFLICT_DEFAULT":"默认冲突策略","projectDetail.config.field.CONFLICT_DEFAULT.help":"卡片没有 conflict 标签时的兜底策略。","projectDetail.config.field.ENABLE_MEMORY":"记忆","projectDetail.config.field.ENABLE_MEMORY.help":"关闭后跳过 prompt 里的记忆写入指引。","projectDetail.config.field.WIKI_ENABLED":"Wiki 上下文","projectDetail.config.field.WIKI_ENABLED.help":"项目存在 wiki 文件时注入 wiki 上下文。","projectDetail.config.field.MATRIX_ROOM_ID":"Matrix 房间","projectDetail.config.field.MATRIX_ROOM_ID.help":"项目级 Matrix 通知房间覆盖。","projectDetail.config.field.COMPLETION_SIGNAL":"完成信号","projectDetail.config.field.COMPLETION_SIGNAL.help":"Stop hook 监听的完成词。","projectDetail.config.error.conflict.title":"配置已被其他地方修改","projectDetail.config.error.conflict.body":'conf 文件在你编辑期间被改过。点"重新加载"后再编辑。',"projectDetail.config.error.save.title":"保存失败","projectDetail.config.error.load":"加载失败:{detail}","projectDetail.pipelines.title":"流水线","projectDetail.pipelines.add":"新建流水线","projectDetail.pipelines.empty":'还没有流水线文件。点"新建流水线"开始。',"projectDetail.pipelines.activeBadge":"当前","projectDetail.pipelines.edit":"编辑","projectDetail.pipelines.editAria":"编辑 {name}","projectDetail.pipelines.switch":"切换","projectDetail.pipelines.switchAria":"切换到 {name}","projectDetail.pipelines.switch.confirm.title":"切换到 {name}","projectDetail.pipelines.switch.confirm.body":"当前 project.yaml 会被 {name} 的内容覆盖。继续?","projectDetail.pipelines.switch.confirm.button":"切换","projectDetail.pipelines.switch.error":"切换失败","projectDetail.pipelines.delete.confirm.title":"删除 {name}","projectDetail.pipelines.delete.confirm.body":"这个流水线文件会被永久删除。","projectDetail.pipelines.delete.error":"删除失败","projectDetail.pipelines.deleteAria":"删除 {name}","projectDetail.pipelines.create.error":"创建失败","projectDetail.danger.title":"删除项目","projectDetail.danger.body":"这会清理 {path}(包括所有卡片、runtime、logs)。","projectDetail.danger.includeClaude.label":"同时清理 repo 的 .claude/","projectDetail.danger.includeClaude.note":"repo 本身不动,只清这个目录。","projectDetail.danger.deleteWorkspace.label":"完整删除整个工作区目录","projectDetail.danger.deleteWorkspace.note":"⚠️ 连同代码/产物一起永久删除,不可恢复。不勾选则只删 sps 配置、保留目录。","projectDetail.danger.confirmPrompt":"输入项目名 {name} 确认:","projectDetail.danger.deleteAria":"永久删除项目","projectDetail.danger.deleteButton":"永久删除","projectDetail.danger.deleted.title":"已删除","projectDetail.danger.deleted.bodyWithList":`项目已删除。同时清理了:
|
|
473
|
+
{paths}`,"projectDetail.danger.deleted.body":"项目已删除。","projectDetail.danger.error":"删除失败","pipelineEditor.close":"关闭","pipelineEditor.error.conflict.title":"文件已被其他地方修改","pipelineEditor.error.yaml.title":"YAML 语法错误","pipelineEditor.error.save.title":"保存失败","pipelineEditor.error.serialize.title":"YAML 序列化失败","pipelineEditor.error.load":"加载失败:{detail}","pipelineEditor.mode.structured":"结构化","pipelineEditor.mode.yaml":"原始 YAML","pipelineEditor.parseError.prefix":"YAML 解析:{detail}","pipelineEditor.activeWarning":"⚠ 这是当前激活的流水线,保存后下一轮 tick 生效","pipelineEditor.yamlAria":"pipeline YAML 编辑器","pipelineEditor.status.unsaved":"● 未保存","pipelineEditor.status.saved":"已保存","pipelineEditor.status.noChanges":"无变化","pipelineEditor.reload":"重新加载","pipelineEditor.save":"保存","pipelineEditor.saveAria":"保存 pipeline","pipelineEditor.activeBadge":"当前","pipelineEditor.modeHint":"project = 事件驱动流水线(默认) · steps = 顺序脚本","pipelineEditor.stages.heading":"Stages({count})","pipelineEditor.stages.add":"添加 stage","pipelineEditor.stages.empty":'还没 stage。点"添加 stage"开始。',"pipelineEditor.stage.name.hint":"stage 唯一名","pipelineEditor.stage.profile.hint":"skill 画像,可空","pipelineEditor.stage.cardState.hint":"本 stage 期间卡片状态","pipelineEditor.stage.timeout.hint":"可选,如 30m 2h","pipelineEditor.stage.trigger.hint":"触发条件,可空走默认","pipelineEditor.stage.onComplete.hint":"成功后动作","pipelineEditor.stage.onFail.action.hint":"失败时动作,如 label NEEDS-FIX","pipelineEditor.stage.onFail.comment.hint":"写进卡片的注释","pipelineEditor.stage.halt.note":"(失败后停流水线;去掉则继续下一张卡)","pipelineEditor.stage.moveUp":"上移","pipelineEditor.stage.moveDown":"下移","pipelineEditor.stage.remove":"删除 stage","newPipelineDialog.title":"新建流水线","newPipelineDialog.field.filename.label":"文件名","newPipelineDialog.field.filename.placeholder":"例如 ci","newPipelineDialog.field.filename.help":"实际会保存为 {filename}。只允许 a-z A-Z 0-9 _ -;已有同名文件会 409 报错。","newPipelineDialog.section.template":"初始内容","newPipelineDialog.template.blank.label":"空白模板","newPipelineDialog.template.blank.desc":"最简 1 stage(develop → Done)","newPipelineDialog.template.sample.label":"教学模板","newPipelineDialog.template.sample.desc":"从 sample.yaml.example 复制(带注释,讲解所有字段)","newPipelineDialog.template.sample.unavailable":"sample.yaml.example 不存在","newPipelineDialog.template.active.label":"复制当前活动的","newPipelineDialog.template.active.desc":"从 project.yaml 复制(基于目前的配置改)","newPipelineDialog.template.active.unavailable":"project.yaml 不存在","newPipelineDialog.create.aria":"创建 pipeline","board.title":"看板","board.title.bare":"看板","board.subtitle":"{name} · {cards} 张卡片 · {workers} workers 活跃","board.pickPrompt.title":"选择一个项目","board.pickPrompt.body":"看板按项目分。挑一个开始:","board.action.start":"启动","board.action.stop":"停止","board.action.startAria":"启动 pipeline","board.action.stopAria":"停止 pipeline","board.action.startError":"启动 pipeline 失败","board.action.stopError":"停止 pipeline 失败","board.action.reset":"重置","board.action.resetError":"重置失败","board.action.reset.confirm.title":"重置整个流水线","board.action.reset.confirm.body":"这会清空所有卡片的运行状态、worker marker、分支。不可撤销。","board.action.reset.confirm.button":"重置全部","board.action.newCard":"新卡片","board.action.newCard.error":"新建卡片失败","board.action.moveCard.error":"移动卡片失败","board.search.placeholder":"搜索标题 / skill / label…","board.search.aria":"搜索卡片","board.filter.clear":"清空","board.filter.clearAria":"清空筛选","board.filter.aria":"按 {label} 筛选","board.filter.clearSelection":"清空选择","board.error.loadCards":"加载卡片失败","board.col.planning":"Planning","board.col.backlog":"Backlog","board.col.todo":"Todo","board.col.inprogress":"Inprogress","board.col.qa":"QA / Review","board.col.done":"Done","kanban.checklist.label":"检查清单 {done}/{total}","kanban.checklist.more":"… 还有 {count} 条","kanban.column.empty":"— 空 —","kanban.time.justNow":"刚才","kanban.time.minutes":"{n} 分钟前","kanban.time.hours":"{n} 小时前","newCard.title":"新建卡片","newCard.field.title":"标题 *","newCard.field.title.placeholder":"例如:接入 GitHub OAuth 登录","newCard.field.title.help":"写简短明了的目标(<200 字符)","newCard.field.description":"描述","newCard.field.description.placeholder":"用户故事、需求、验收标准、参考资料… Claude 启动时会读这里的内容","newCard.field.description.help":"支持 markdown。空的话就只有 title,Claude 只能靠 title 推断要做啥。","newCard.field.skills":"技能","newCard.field.skills.help":"勾选哪些 skill 会被加载(走 frontmatter `skills:`)。不选也行,Worker 默认加载项目级 skills。","newCard.field.skills.loading":"加载 skill 列表…","newCard.field.skills.error":"skill 列表加载失败,不影响创建:{detail}","newCard.field.skills.selected":"已选 {count} 个:{names}","newCard.field.dispatch":"派发","newCard.field.dispatch.label":"立即派发执行(直接进 Backlog)","newCard.field.dispatch.help":"默认不勾:卡进 Planning 暂存,等你看板上拖到 Backlog 再开工。勾上:跳过暂存,下次 tick 直接派 worker 跑。","newCard.create.aria":"创建卡片","cardDetail.save":"保存","logs.scroll.bottom.aria":"滚动到底部","logs.filter.keyword.placeholder":"过滤关键字…","logs.filter.keyword.aria":"过滤日志","logs.empty.match":"没有匹配的日志","skills.category.all":"全部","skills.category.language":"语言","skills.category.domain":"领域","skills.category.persona":"角色","skills.category.workflow":"流程","skills.category.engine":"引擎","skills.category.genre":"品类","skills.category.platform":"平台","skills.category.review":"审核","skills.category.meta":"工具","skills.category.other":"其它","skills.tags.title":"标签","skills.tags.clear":"清除","skills.subtitleCount":"{count} 个 user-level skill","skills.search.placeholder":"搜索 skill…","skills.search.aria":"搜索 skill","skillDetail.close.aria":"关闭","skillDetail.loading":"加载中…","skillDetail.error.load":"加载失败:{detail}","skillDetail.section.preview":"SKILL.md 预览","skillDetail.toggleSection.aria":"{action} {file}","skillDetail.expand":"展开","skillDetail.collapse":"收起","skillDetail.edit":"编辑","skillDetail.translate":"中英转换","skillDetail.delete":"删除","skillDetail.save":"保存","skillDetail.cancel":"取消","skillDetail.translating":"翻译中…","skillDetail.saving":"保存中…","skillDetail.editHint":"直接编辑整份 SKILL.md(含 frontmatter)。保存后建议跑 `sps skill lint` 校验三轴与格式。","skillDetail.deleteConfirm":"确定从库中删除「{name}」?整目录会被移除,此操作不可撤销。","skillDetail.translateFailed":"翻译失败:{detail}","skillDetail.saveFailed":"保存失败:{detail}","skillDetail.deleteFailed":"删除失败:{detail}","system.h1":"系统","system.tab.config":"全局配置","system.tab.processes":"进程管理","system.tab.doctor":"项目诊断","system.tab.audit":"审计日志","system.upgrade.upToDate":"已是最新版本({version})","system.memory.title":"记忆后端","system.memory.desc":"全局设置:worker 的记忆读写走哪个后端。改动对新派发的卡生效。","system.memory.provider":"后端","system.memory.url":"自定义 URL","system.memory.url.placeholder":"http://127.0.0.1:3111","system.memory.save":"保存","system.memory.save.aria":"保存记忆后端设置","system.memory.saved":"已保存","system.memory.error":"保存失败","system.env.warning":"⚠ 文件包含凭证明文。保存时保持 0600 权限。","system.env.settingsAria":"全局配置设置","system.env.dirtyMark":" · ● 未保存","system.env.save":"保存","system.env.save.aria":"保存 env","system.env.section.git":"Git","system.env.section.git.hint":"共享远程仓库凭证与 SSH 连接配置。","system.env.section.matrix":"Matrix","system.env.section.matrix.hint":"项目未覆盖时使用的全局通知默认值。","system.env.section.memory":"记忆","system.env.section.memory.hint":"运行时记忆模式、外部服务地址与捕获策略。","system.env.section.daemon":"Daemon","system.env.section.daemon.hint":"共享 daemon 权威配置(0.65.15 起启动时应用、覆盖拉起方 env):沙箱与并发总闸/配额/排队。改动需重启 daemon 生效。","system.env.section.console":"控制台","system.env.section.console.hint":"控制台访问密钥与可选关联服务地址。","system.env.section.custom":"附加变量","system.env.section.custom.hint":"未内置的 env 变量会保留在这里。","system.env.custom.empty":"没有附加变量。","system.env.custom.keyPlaceholder":"CUSTOM_KEY","system.env.custom.valuePlaceholder":"值","system.env.custom.keyAria":"新变量名","system.env.custom.valueAria":"{key} 的值","system.env.custom.newValueAria":"新变量值","system.env.custom.removeAria":"移除 {key}","system.env.custom.add":"添加","system.env.field.GITLAB_URL":"GitLab 地址","system.env.field.GITLAB_URL.help":"GitLab API 基础地址;不用 GitLab 时可留空。","system.env.field.GITLAB_TOKEN":"GitLab Token","system.env.field.GITLAB_TOKEN.help":"GitLab API 使用的个人访问令牌。","system.env.field.MATRIX_HOMESERVER":"Matrix Homeserver","system.env.field.MATRIX_HOMESERVER.help":"通知使用的 homeserver 地址。","system.env.field.MATRIX_ACCESS_TOKEN":"Matrix Access Token","system.env.field.MATRIX_ACCESS_TOKEN.help":"Matrix 通知器使用的访问令牌。","system.env.field.MATRIX_ROOM_ID":"Matrix 房间","system.env.field.MATRIX_ROOM_ID.help":"默认通知房间;项目配置可以覆盖。","system.env.field.SPS_MEMORY_MODE":"记忆模式","system.env.field.SPS_MEMORY_MODE.help":"local 存在本机;external 使用远程服务。","system.env.field.SPS_MEMORY_EXTERNAL_URL":"外部记忆地址","system.env.field.SPS_MEMORY_EXTERNAL_URL.help":"记忆模式包含 external 时填写。","system.env.field.SPS_MEMORY_DISTILL":"记忆蒸馏","system.env.field.SPS_MEMORY_DISTILL.help":"设为 on 时使用已配置的 reviewer 模型提炼记忆。","system.env.field.SPS_MEMORY_REDACT":"记忆脱敏","system.env.field.SPS_MEMORY_REDACT.help":"可选覆盖记忆脱敏策略;留空使用默认值。","system.env.field.SPS_MEMORY_IMPORT":"记忆导入","system.env.field.SPS_MEMORY_IMPORT.help":"on 时把 worker 会话导入外部记忆库;需 external 模式且配了外部地址才生效。","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER":"沙箱 Provider","system.env.field.SPS_OPENAI_SANDBOX_PROVIDER.help":"openai 会话执行沙箱。权威键:此处配置覆盖拉起方 env(daemon 重生不回归);留空按 NODE_ENV 推断(production→docker)。","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS":"并发总闸","system.env.field.SPS_DAEMON_MAX_CONCURRENT_RUNS.help":"daemon 全局同时执行的 run 上限(所有平台合计);留空按内存自动推导(30GB≈47)。","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS":"平台配额","system.env.field.SPS_DAEMON_ORIGIN_QUOTAS.help":"按 origin 限并发,如 coral-platform=30,gameforge=20;防单平台吃光全机。","system.env.field.SPS_DAEMON_QUEUE_WAIT_S":"排队等待(秒)","system.env.field.SPS_DAEMON_QUEUE_WAIT_S.help":"满载时 FIFO 排队最长等待;超时返回带 Retry-After 的容量拒绝。默认 20。","system.env.field.SPS_DAEMON_MAX_QUEUE":"排队上限","system.env.field.SPS_DAEMON_MAX_QUEUE.help":"排队队列长度上限,超出直接拒绝。默认 200。","system.env.field.SPS_RUN_IDLE_MINUTES":"回合空闲超时(分)","system.env.field.SPS_RUN_IDLE_MINUTES.help":"chat 回合无任何事件超过该时长判卡死并取消。默认 5。","system.env.field.SPS_RUN_TOOL_IDLE_MINUTES":"工具运行超时(分)","system.env.field.SPS_RUN_TOOL_IDLE_MINUTES.help":"有工具在执行时改用的宽超时(媒体生成等长耗时工具,0.65.24+)。默认 12;本地生图慢可调大。","system.env.field.SPS_STUCK_RUN_MINUTES":"假活回收阈值(分)","system.env.field.SPS_STUCK_RUN_MINUTES.help":"currentRun 存在但输出静默超过该时长按假活回收。默认 20。","system.env.field.SPS_CONSOLE_TOKEN":"控制台 Token","system.env.field.SPS_CONSOLE_TOKEN.help":"对外暴露控制台时使用的 Bearer Token。","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL":"记忆查看器地址","system.env.field.SPS_CONSOLE_MEMORY_VIEWER_URL.help":"记忆查看器集成使用的可选 URL。","system.env.error.conflict.title":"env 被其他地方修改了","system.env.error.save.title":"保存失败","system.env.error.conflict.body":"请点取消后重开编辑。","system.upgrade.checkUpdate":"检查更新","system.upgrade.confirm.title":"升级 sps-cli","system.upgrade.confirm.body":"当前 {current},升级到 {latest}。要求所有 pipeline 已停止。升级后请重启 sps console 生效。","system.upgrade.confirm.button":"升级","system.upgrade.success.title":"升级完成","system.upgrade.success.body":'装上了 v{version}。请 `pkill -f "sps console"` 再重启以生效。',"system.upgrade.notEffective.title":"升级未生效","system.upgrade.error.title":"升级失败","system.diagnostics.title":"项目健康检查","system.diagnostics.checkAll":"检查全部","system.diagnostics.empty":"还没有项目。","system.diagnostics.expandAria":"展开","system.diagnostics.collapseAria":"折叠","system.diagnostics.never":'点 "检查" 运行 sps doctor',"system.diagnostics.checkAria":"检查","system.diagnostics.check":"检查","system.diagnostics.noFixesNeeded":"已无可修问题","system.diagnostics.fix.tip":"调 sps doctor <proj> --fix:自动创建 .claude/hooks/stop.sh、state.json 等","system.diagnostics.fixAria":"自动修复","system.diagnostics.fix":"修复","system.diagnostics.fixed":"已修复","system.diagnostics.error.fix":"doctor 修复失败","system.diagnostics.error.check":"doctor 检查失败","chat.list.new":"新建对话","chat.list.title":"会话列表","chat.cli.banner.bold":"CLI 会话","chat.cli.banner":"这是 CLI 会话(由 sps agent 创建),Console 仅展示历史。续聊请在终端运行:","chat.cliBadge":"CLI","chat.cliBadge.tooltip":"该会话由 sps agent CLI 创建,从 Claude jsonl 实时读取(只读)","notFound.title":"404","notFound.body":"这个页面不存在。","notFound.home":"回到首页","dialog.confirm.default":"确定","dialog.alert.default":"知道了","dialog.cancel.default":"取消","dirPicker.title.default":"选择目录","dirPicker.close.aria":"关闭","dirPicker.up.aria":"上级目录","dirPicker.up.title":"上级目录","dirPicker.home.aria":"回到 Home","dirPicker.home.title":"回到 Home","dirPicker.loading":"加载中...","dirPicker.error.title":"读取失败","dirPicker.empty":"— 空目录 —","dirPicker.enter.aria":"进入 {name}/","dirPicker.pickFile.aria":"选择 {name}(双击直接确认)","dirPicker.fileLocked":"文件不可选","dirPicker.cancel":"取消","dirPicker.useFile":"使用此文件","dirPicker.useFile.tooltip.empty":"请先点选一个文件","dirPicker.useDir":"选此目录","dirPicker.newDir":"新建目录","dirPicker.newDir.aria":"在当前目录下新建子目录","dirPicker.newDir.prompt":"新目录名(仅字母数字 _ . -)","dirPicker.newDir.placeholder":"目录名","dirPicker.newDir.create":"创建","dirPicker.newDir.error.title":"新建目录失败","chat.message.truncated":"⚠ 输出超过 10MB,已截断","chat.newSession.title":"新建对话","chat.newSession.title.aria":"新建对话","chat.newSession.close.aria":"关闭","chat.newSession.field.agent":"Agent 后端","chat.newSession.field.agent.openaiHint":"OpenAI 会话用已配置的 openai 模型,上面的模型选择不生效","chat.newSession.field.model":"模型(可选)","chat.newSession.field.model.default":"用全局默认模型","chat.newSession.field.title":"标题(可选)","chat.newSession.field.title.placeholder":"留空 = 自动用首条消息生成","chat.newSession.field.cwd":"工作目录(可选)","chat.newSession.field.cwd.browse":"浏览","chat.newSession.field.cwd.browseAria":"浏览选择目录","chat.newSession.field.cwd.help1":"Agent 在该目录下读写文件。绝对路径,必须存在。","chat.newSession.field.cwd.help2":"留空则自动为该对话新建一个独立工作目录。","chat.newSession.cancel":"取消","chat.newSession.create":"创建","cardModal.editing":"⚠ 编辑中","cardModal.order":"第 {n} 波","cardModal.order.tip":"执行波次(order):同波并行,前一波全部完成才开下一波","cardModal.title.aria":"卡片标题","cardModal.editAria":"编辑卡片","cardModal.edit":"编辑","cardModal.close.aria":"关闭","cardModal.error.save.title":"保存失败","cardModal.error.load":"加载失败:{detail}","cardModal.skills.loading":"加载 skill 列表…","cardModal.label.removeAria":"删除 {label}","cardModal.label.addPlaceholder":"+ 添加 label","cardModal.label.addAria":"添加 label","cardModal.label.note":"注意:AI-PIPELINE / STARTED-* / COMPLETED-* / NEEDS-FIX 由流水线自动管理,手动改可能被覆盖","cardModal.section.description":"描述","cardModal.section.empty":"(空)","cardModal.section.checklist":"检查清单","cardModal.checklist.empty":"暂无清单项。在描述里用 `- [ ] 项` 语法添加。","cardModal.section.log":"日志","cardModal.body.aria":"卡片描述","cardModal.body.replaceNote":'只替换 "## 描述" 段的内容;检查清单和日志段不动。',"cardModal.action.launch":"启动 worker","cardModal.action.launch.disabledDone":"卡片已完成;先拖回 Todo 再启动","cardModal.action.launch.disabledRunning":"Pipeline 正在跑——supervisor 会自动 dispatch,无需手动启动","cardModal.action.launch.error":"启动 worker 失败","cardModal.action.reset":"重置卡片","cardModal.action.viewPrompt":"查看 prompt","cardModal.prompt.title":"注入 worker 的提示词(预览)","cardModal.prompt.loading":"重建提示词中…","cardModal.prompt.error":"获取失败:{detail}","cardModal.prompt.copy":"复制","cardModal.prompt.copied":"已复制","cardModal.prompt.metaSkills":"skills:{skills}","cardModal.prompt.metaMemory":"记忆块","cardModal.prompt.metaGit":"git 模式","cardModal.prompt.metaNonGit":"非 git","cardModal.prompt.nativeTitle":"claude 另原生读入(不在本串里):","cardModal.prompt.sourceActual":"✅ 派发时真实注入({time})","cardModal.prompt.sourcePreview":"⚠️ 预览重建(本卡未派发过;记忆按当前库状态,可能与真实派发不同)","cardModal.action.reset.confirm.title":"重置卡片 #{seq}","cardModal.action.reset.confirm.body":"卡片状态会回到初始,已做的 checklist 会清空。","cardModal.action.reset.confirm.button":"重置","cardModal.action.reset.error":"重置失败","cardModal.action.delete":"删除卡片","cardModal.action.delete.confirm1.title":"删除卡片 #{seq}","cardModal.action.delete.confirm1.body":'即将删除 "{title}"。此操作不可恢复(md 文件将被物理删除)。是否继续?',"cardModal.action.delete.confirm1.button":"继续","cardModal.action.delete.confirm2.title":"最终确认","cardModal.action.delete.confirm2.body":"请再次确认删除卡片 #{seq}。","projectDetail.tab.skills":"技能","projectDetail.tab.rules":"规则","projectDetail.skills.title":"Skill 白名单","projectDetail.skills.desc":"选择本项目加载哪些 skill。收窄 worker、subagent 与 chat 能看到的范围,降低 token 消耗。","projectDetail.skills.noPolicy":"未设白名单 —— 全部 skill 都可用(subagent 会从磁盘吃全量)。","projectDetail.skills.hasPolicy":"白名单已生效 —— {count} 个 skill 合格。","projectDetail.skills.save":"保存","projectDetail.skills.detail":"详情","projectDetail.skills.saveError":"保存白名单失败","projectDetail.skills.applied":"已保存。投影 {linked} 个链接,清理 {pruned} 个。","projectDetail.skills.unknown":"未识别的 skill 名(已忽略):{names}","projectDetail.skills.empty":"尚无已安装的 skill,先跑 `sps skill sync`。","projectDetail.skills.selectAll":"全选","projectDetail.skills.selectNone":"全不选","projectDetail.rules.readonly":"sps-cli 只读这些文件。编辑在项目创建时或日后由 agent 协助完成。","projectDetail.rules.missing":"不存在","nav.prompts":"提示词","prompts.title":"提示词库","prompts.desc":"带 {{变量}} 模板的可复用提示词,可插入到会话中。","prompts.new":"新建提示词","prompts.search":"搜索提示词…","prompts.empty":"还没有提示词,新建一个。","prompts.name":"名称","prompts.namePlaceholder":"kebab-case,如 code-review","prompts.nameError":"名称须为 kebab-case(小写字母、数字、连字符)。","prompts.description":"描述","prompts.tags":"标签","prompts.body":"正文","prompts.bodyPlaceholder":"写你的提示词。用 {{变量}} 做填充位。","prompts.favorite":"收藏","prompts.save":"保存","prompts.delete":"删除","prompts.deleteConfirm":"删除提示词「{name}」?会移除文件。","prompts.saveError":"保存提示词失败","prompts.vars":"变量:{names}","prompts.noVars":"无变量","prompts.insert":"插入提示词","prompts.selectHint":"在左侧选择一个提示词,或新建一个。","prompts.tagAdd":"输入标签后按 Enter","prompts.ai":"AI 生成","prompts.ai.title":"AI 生成提示词","prompts.ai.intent":"描述你想要什么","prompts.ai.placeholder":"例如:一个用于审查 TypeScript 代码安全问题的提示词","prompts.ai.submit":"生成","prompts.ai.wait":"agent 正在生成…可能需要一会儿。","prompts.ai.error":"生成失败","skills.import":"导入","skills.import.title":"导入 Skill","skills.import.name":"名称(kebab-case)","skills.import.body":"SKILL.md 内容","skills.import.submit":"导入","skills.import.error":"导入失败","skills.export":"导出 SKILL.md","skills.updates.badge":"有 {count} 个可更新","skills.ai":"AI 创建","skills.ai.title":"AI 创建 Skill","skills.ai.name":"名称(kebab-case)","skills.ai.intent":"这个 skill 用来做什么?","skills.ai.placeholder":"例如:如何写地道的 Rust 错误处理","skills.ai.submit":"创建","skills.ai.wait":"agent 正在生成 skill…可能需要一会儿。","skills.ai.error":"创建失败","projectDetail.tab.graph":"代码图谱","projectDetail.tab.logs":"日志","graph.title":"代码图谱","graph.desc":"本项目的符号级依赖图(tree-sitter,零 token)。给 agent 精准上下文,少读文件、省 token。","graph.build":"建图","graph.rebuild":"重建","graph.building":"建图中…","graph.sync":"增量同步","graph.syncing":"同步中…","graph.sync.desc":"增量 —— 只重新索引变化的文件(快)","graph.empty":"尚未建图 —— 建一次即可启用 agent 导航与依赖图。","graph.buildFailed":"建图失败","graph.stat.files":"文件","graph.stat.nodes":"节点","graph.stat.edges":"边","graph.stat.db":"DB 体积","graph.stat.lastBuilt":"上次建图","graph.viz.loading":"加载图谱…","graph.viz.empty":"建图后可查看依赖图。","graph.viz.hint":"节点=文件 · 边=import · 拖拽探索 · 搜索高亮","graph.viz.search":"高亮文件…"},Fj=C.createContext(null),$j="sps-console-lang";function j6(){if(typeof window>"u")return"en";try{const e=window.localStorage.getItem($j);if(e==="en"||e==="zh")return e}catch{}return"en"}function M6(e){try{window.localStorage.setItem($j,e)}catch{}}function R6({children:e}){const[t,n]=C.useState(()=>j6());C.useEffect(()=>{typeof document<"u"&&(document.documentElement.lang=t==="zh"?"zh-CN":"en")},[t]);const i=C.useCallback(o=>{n(o),M6(o)},[]),s=C.useMemo(()=>{const o=t==="zh"?A6:T6;return(c,u)=>{let f=o[c]??c;if(u)for(const[m,p]of Object.entries(u))p!==void 0&&(f=f.replace(`{${m}}`,String(p)));return f}},[t]),a=C.useMemo(()=>({lang:t,setLang:i,t:s}),[t,i,s]);return d.jsx(Fj.Provider,{value:a,children:e})}function qj(){const e=C.useContext(Fj);if(!e)throw new Error("useLang must be used inside I18nProvider");return e}function Xe(){return qj().t}function D6(...e){return e.filter(Boolean).join(" ")}const O6=3,L6=1,I6=e=>{const t=C.useRef(0),n=C.useRef(0),i=C.useRef(0),s=C.useRef(new Date),a=C.useRef(null),o=C.useRef(null),c=C.useCallback(m=>{const[p,y]=[a.current,o.current];if(!p||!y)return;y.style.filter=`blur(${Math.min(8/m-8,100)}px)`,y.style.opacity=`${Math.pow(m,.4)*100}%`;const b=1-m;p.style.filter=`blur(${Math.min(8/b-8,100)}px)`,p.style.opacity=`${Math.pow(b,.4)*100}%`,p.textContent=e[t.current%e.length]??"",y.textContent=e[(t.current+1)%e.length]??""},[e]),u=C.useCallback(()=>{n.current-=i.current,i.current=0;let m=n.current/O6;m>1&&(i.current=L6,m=1),c(m),m===1&&t.current++},[c]),f=C.useCallback(()=>{n.current=0;const[m,p]=[a.current,o.current];m&&p&&(p.style.filter="none",p.style.opacity="100%",m.style.filter="none",m.style.opacity="0%")},[]);return C.useEffect(()=>{let m;const p=()=>{m=requestAnimationFrame(p);const y=new Date,b=(y.getTime()-s.current.getTime())/1e3;s.current=y,i.current-=b,i.current<=0?u():f()};return p(),()=>{cancelAnimationFrame(m)}},[u,f]),{text1Ref:a,text2Ref:o}},P6=({texts:e})=>{const{text1Ref:t,text2Ref:n}=I6(e);return d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"absolute inset-x-0 top-0 m-auto inline-block w-full",ref:t}),d.jsx("span",{className:"absolute inset-x-0 top-0 m-auto inline-block w-full",ref:n})]})},z6=()=>d.jsx("svg",{id:"morphing-filters",className:"hidden","aria-hidden":"true",preserveAspectRatio:"xMidYMid slice",children:d.jsx("defs",{children:d.jsx("filter",{id:"threshold",children:d.jsx("feColorMatrix",{in:"SourceGraphic",type:"matrix",values:`1 0 0 0 0
|
|
474
474
|
0 1 0 0 0
|
|
475
475
|
0 0 1 0 0
|
|
476
476
|
0 0 0 255 -140`})})})}),B6=({texts:e,className:t})=>d.jsxs("div",{className:D6("relative w-full text-center leading-none [filter:url(#threshold)_blur(0.6px)]",t),children:[d.jsx(P6,{texts:e}),d.jsx(z6,{})]});function U6(){const{lang:e,setLang:t,t:n}=qj(),i=e==="zh";return d.jsxs("label",{className:"slide-switch",title:n("lang.toggle.aria"),children:[d.jsx("input",{type:"checkbox",checked:i,onChange:s=>t(s.target.checked?"zh":"en"),"aria-label":n("lang.toggle.aria")}),d.jsxs("span",{className:"slide-switch-track","aria-hidden":"true",children:[d.jsx("span",{className:"slide-switch-cell slide-switch-a",children:n("lang.en")}),d.jsx("span",{className:"slide-switch-cell slide-switch-b",children:n("lang.zh")}),d.jsx("span",{className:"slide-switch-thumb"})]})]})}const Hj="sps-console-theme";function Vj(){if(typeof window>"u")return"dark";try{const e=window.localStorage.getItem(Hj);if(e==="dark"||e==="light")return e}catch{}return"dark"}function h0(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function F6(e){try{window.localStorage.setItem(Hj,e)}catch{}}function $6(){const e=Vj();return h0(e),e}function q6(){const e=Xe(),[t,n]=C.useState(()=>Vj());C.useEffect(()=>{h0(t)},[t]);const i=C.useCallback(a=>{n(a),F6(a),h0(a)},[]),s=t==="light";return d.jsxs("label",{className:"slide-switch",title:e(s?"theme.light":"theme.dark"),children:[d.jsx("input",{type:"checkbox",checked:s,onChange:a=>i(a.target.checked?"light":"dark"),"aria-label":e("theme.toggle.aria")}),d.jsxs("span",{className:"slide-switch-track","aria-hidden":"true",children:[d.jsx("span",{className:"slide-switch-cell slide-switch-a",children:d.jsx(BU,{size:15,strokeWidth:2.4})}),d.jsx("span",{className:"slide-switch-cell slide-switch-b",children:d.jsx(y6,{size:15,strokeWidth:2.4})}),d.jsx("span",{className:"slide-switch-thumb"})]})]})}const H6=[{to:"/",labelKey:"nav.home",icon:Mj},{to:"/projects",labelKey:"nav.projects",icon:Dj},{to:"/board",labelKey:"nav.board",icon:Rj},{to:"/arrange",labelKey:"nav.arrange",icon:Gv},{to:"/skills",labelKey:"nav.skills",icon:vU},{to:"/prompts",labelKey:"nav.prompts",icon:$U},{to:"/plugins",labelKey:"nav.plugins",icon:QU},{to:"/system",labelKey:"nav.system",icon:Lj},{to:"/memory",labelKey:"nav.memory",icon:LB}];function V6({collapsed:e,onToggleCollapsed:t}){const n=Xe(),i=n(e?"sidebar.expand":"sidebar.collapse"),[s,a]=C.useState(null);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"sidebar-brand",type:"button",onClick:t,"aria-label":i,children:[d.jsx("img",{className:"sidebar-brand-logo",src:"/sps-logo.png",alt:"","aria-hidden":"true"}),d.jsx(B6,{texts:["SPS-CLI","CONSOLE"],className:"sidebar-brand-morph"}),d.jsx("span",{className:"sidebar-tooltip",role:"tooltip",children:i})]}),d.jsx("nav",{className:"sidebar-nav flex min-w-0 flex-1 flex-row gap-1 md:mt-2 md:min-h-0 md:flex-col md:gap-0.5","aria-label":n("nav.aria"),children:H6.map(o=>{const c=o.icon,u=n(o.labelKey);return d.jsxs(xj,{to:o.to,end:o.to==="/","aria-label":u,onPointerDown:f=>{f.pointerType==="mouse"&&a(o.to)},onMouseLeave:()=>{s===o.to&&a(null)},className:({isActive:f})=>["sidebar-nav-item dimension-menu-item shrink-0 font-semibold text-sm cursor-pointer",f?"dimension-menu-item-active":""].join(" "),children:[d.jsx(c,{size:18,strokeWidth:2.5}),d.jsx("span",{className:"sidebar-nav-label",children:u}),e&&d.jsx("span",{className:["sidebar-tooltip",s===o.to?"sidebar-tooltip-suppressed":""].join(" "),role:"tooltip",children:u})]},o.to)})}),d.jsxs("div",{className:"sidebar-footer shrink-0 flex flex-col items-stretch gap-2 md:pt-3",children:[d.jsx(U6,{}),d.jsx(q6,{})]})]})}class K6 extends Error{constructor(t,n,i){super(n),this.status=t,this.detail=i,this.name="ApiError"}}async function Wv(e){const t=await e.text().catch(()=>"");let n=t,i=`${e.status} ${e.statusText}`;try{const s=JSON.parse(t);if(n=s,s&&typeof s=="object"){const a=s,o=a.detail??a.title??a.message;typeof o=="string"&&o&&(i=o)}}catch{t&&(i=t.slice(0,300))}return new K6(e.status,i,n)}async function _t(e){const t=await fetch(e,{headers:{Accept:"application/json"}});if(!t.ok)throw await Wv(t);return await t.json()}async function Ks(e,t){return Kj("POST",e,t)}async function Rm(e,t){return Kj("PUT",e,t)}async function Yv(e){const t=await fetch(e,{method:"DELETE",headers:{Accept:"application/json"}});if(!t.ok)throw await Wv(t)}async function Kj(e,t,n){const i=await fetch(t,{method:e,headers:{Accept:"application/json","Content-Type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)});if(!i.ok)throw await Wv(i);return await i.json()}function Gj(){return _t("/api/system/info")}function G6(){return _t("/api/system/env/raw")}async function W6(e,t){const n=await fetch("/api/system/env",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,etag:t})});if(!n.ok){const i=await n.text(),s=new Error(`${n.status}: ${i}`);throw s.status=n.status,s}return n.json()}function Y6(){return _t("/api/system/memory")}async function X6(e,t){const n=await fetch("/api/system/memory",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,url:t})});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}function Xv(){return _t("/api/system/agents")}async function Q6(e){const t=await fetch("/api/system/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return t.json()}function Z6(){return _t("/api/system/latest-version")}async function J6(){const e=await fetch("/api/system/upgrade",{method:"POST"});if(!e.ok&&e.status!==409)throw new Error(`${e.status}: ${await e.text()}`);return e.json()}async function eF(e,t=!1){const n=t?"?fix=1":"",i=await fetch(`/api/system/doctor/${encodeURIComponent(e)}${n}`,{method:"POST"});if(!i.ok)throw new Error(`${i.status}: ${await i.text()}`);return i.json()}function ro(){return _t("/api/projects")}function tF(e){return _t(`/api/projects/${encodeURIComponent(e)}`)}async function nF(e){const t=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.text();throw new Error(`${t.status}: ${n}`)}return t.json()}function iF(e){return _t(`/api/projects/${encodeURIComponent(e)}/conf`)}async function sF(e,t,n){const i=await fetch(`/api/projects/${encodeURIComponent(e)}/conf`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,etag:n})});if(!i.ok){const s=await i.text(),a=new Error(`${i.status}: ${s}`);throw a.status=i.status,a}return i.json()}async function rF(e,t={}){const n=await fetch(`/api/projects/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}return n.json()}function aF(e){return _t(`/api/projects/${encodeURIComponent(e)}/pipelines`)}async function oF(e,t){const n=await fetch(`/api/projects/${encodeURIComponent(e)}/pipeline`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pipeline:t})});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}return n.json()}function lF(e,t){return _t(`/api/projects/${encodeURIComponent(e)}/pipelines/${encodeURIComponent(t)}`)}async function cF(e,t,n,i){const s=await fetch(`/api/projects/${encodeURIComponent(e)}/pipelines/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,etag:i})});if(!s.ok){const a=await s.text(),o=new Error(`${s.status}: ${a}`);throw o.status=s.status,o}return s.json()}async function uF(e,t,n="blank"){const i=await fetch(`/api/projects/${encodeURIComponent(e)}/pipelines`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,template:n})});if(!i.ok){const s=await i.text();throw new Error(`${i.status}: ${s}`)}return i.json()}async function dF(e,t){const n=await fetch(`/api/projects/${encodeURIComponent(e)}/pipelines/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}}function fF(){var u;const e=Xe(),t=at({queryKey:["system-info"],queryFn:Gj,refetchInterval:3e4}),n=at({queryKey:["projects"],queryFn:ro,refetchInterval:1e4}),i=pF(),s=!t.isError,a=((u=n.data)==null?void 0:u.data)??[],o=a.filter(f=>f.pipelineStatus==="running").length,c=a.reduce((f,m)=>f+m.workers.active,0);return d.jsxs("div",{className:"status-bar h-full min-w-0 flex items-center justify-end gap-3 overflow-x-auto whitespace-nowrap px-4 font-[family-name:var(--font-mono)] text-[11px] text-[var(--color-text-muted)] md:px-6",children:[d.jsxs("span",{className:"flex items-center gap-1",title:e("status.pipelines.tooltip"),children:[d.jsx(kB,{size:10,strokeWidth:2.5}),d.jsx("span",{className:"font-bold text-[var(--color-text)]",children:o})," ",e("status.pipeline.unit")]}),d.jsx("span",{className:"text-[var(--color-text-subtle)]",children:"·"}),d.jsxs("span",{className:"flex items-center gap-1",title:e("status.workers.tooltip"),children:[d.jsx(JU,{size:10,strokeWidth:2.5}),d.jsx("span",{className:"font-bold text-[var(--color-text)]",children:c})," ",e("status.worker.unit")]}),d.jsx("span",{className:"text-[var(--color-text-subtle)]",children:"·"}),d.jsxs("span",{children:["localhost:",window.location.port]}),t.data&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-[var(--color-text-subtle)]",children:"·"}),d.jsxs("span",{children:["v",t.data.version]}),d.jsx("span",{className:"text-[var(--color-text-subtle)]",children:"·"}),d.jsxs("span",{children:["node ",t.data.nodeVersion]})]}),d.jsx("span",{className:"nb-status",style:{background:s?"var(--color-running-bg)":"var(--color-crashed-bg)",color:s?"var(--color-running)":"var(--color-crashed)",padding:"2px 8px 2px 7px"},children:e(s?"status.server":"status.offline")}),d.jsx(hF,{state:i})]})}function hF({state:e}){const t=Xe();return e==="open"?d.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)",padding:"2px 8px 2px 7px"},children:t("status.sse.open")}):e==="connecting"?d.jsx("span",{className:"nb-status",style:{background:"var(--color-stuck-bg)",color:"var(--color-stuck)",padding:"2px 8px 2px 7px"},children:t("status.sse.connecting")}):d.jsxs("span",{className:"nb-status",style:{background:"var(--color-crashed-bg)",color:"var(--color-crashed)",padding:"2px 8px 2px 7px"},children:[d.jsx(jd,{size:9,strokeWidth:2.5}),t("status.sse.down")]})}function pF(){const[e,t]=C.useState("connecting");return C.useEffect(()=>{let n=null,i=null,s=!1;const a=()=>{s||(n=new EventSource("/stream/heartbeat"),n.addEventListener("server.heartbeat",()=>t("open")),n.addEventListener("open",()=>t("open")),n.addEventListener("error",()=>{(n==null?void 0:n.readyState)===EventSource.CLOSED?(t("closed"),i==null&&(i=setTimeout(()=>{i=null,n==null||n.close(),a()},1e4))):t("connecting")}))};return a(),()=>{s=!0,i!=null&&clearTimeout(i),n==null||n.close()}},[]),e}function HN({contentMode:e="workspace"}){const t=e==="workspace"?"overflow-hidden":"overflow-auto",[n,i]=Yr("sps.sidebar.collapsed",!1),s=["app-shell grid h-dvh overflow-hidden",n?"app-shell-sidebar-collapsed":"app-shell-sidebar-expanded"].join(" ");return d.jsxs("div",{className:s,children:[d.jsx("aside",{className:"app-sidebar row-start-1 min-h-0 overflow-visible border-b-[3px] border-[var(--color-text)] bg-[var(--color-bg)] flex flex-row md:col-start-1 md:row-start-1 md:border-b-0 md:border-r-[3px] md:flex-col",children:d.jsx(V6,{collapsed:n,onToggleCollapsed:()=>i(!n)})}),d.jsxs("section",{className:"app-main-surface row-start-2 min-h-0 grid grid-rows-[36px_minmax(0,1fr)] md:col-start-2 md:row-start-1",children:[d.jsx("header",{className:"app-topbar min-w-0 border-b-[3px] border-[var(--color-text)]",children:d.jsx(fF,{})}),d.jsx("main",{className:["min-h-0 p-4 md:p-6 flex flex-col gap-4",t].join(" "),children:d.jsx(D5,{})})]})]})}function p0(e,t){try{const n=JSON.stringify({message:(e instanceof Error?e.message:String(e)).slice(0,1e3),stack:(e instanceof Error?e.stack??"":"").slice(0,4e3),url:typeof window<"u"?window.location.href:"",ua:typeof navigator<"u"?navigator.userAgent:"",ts:new Date().toISOString(),context:t==null?void 0:t.slice(0,200)});fetch("/api/system/client-errors",{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}).catch(()=>{})}catch{}}function mF(){typeof window>"u"||(window.addEventListener("error",e=>{p0(e.error??e.message??"unknown error","window.error")}),window.addEventListener("unhandledrejection",e=>{const t=e.reason;p0(t instanceof Error?t:String(t),"unhandledrejection")}))}class gF extends C.Component{constructor(){super(...arguments);lN(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){var s;p0(n,`ErrorBoundary: ${((s=i.componentStack)==null?void 0:s.slice(0,200))??""}`),console.error("[ErrorBoundary]",n,i)}render(){if(this.state.error){const n=(()=>{try{return window.localStorage.getItem("sps-console-lang")==="zh"?"zh":"en"}catch{return"en"}})(),i=n==="zh"?"💥 UI 崩了":"💥 UI crashed",s=n==="zh"?"刷新页面":"Refresh page";return d.jsx("div",{className:"p-6",children:d.jsxs("div",{className:"nb-card max-w-2xl bg-[var(--color-crashed-bg)]",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold mb-2",children:i}),d.jsx("p",{className:"text-sm mb-3 text-[var(--color-text-muted)]",children:this.state.error.message}),d.jsxs("details",{className:"text-xs mb-4",children:[d.jsx("summary",{className:"cursor-pointer font-semibold",children:"stack"}),d.jsx("pre",{className:"mt-2 font-[family-name:var(--font-mono)] overflow-auto max-h-60 bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded-md p-3",children:this.state.error.stack??"(no stack)"})]}),d.jsx("button",{className:"nb-btn nb-btn-mint",type:"button",onClick:()=>{this.setState({error:null}),window.location.reload()},children:s})]})})}return this.props.children}}const yF={sps:"SPS","coral-platform":"Coral",gameforge:"GameForge"};function Wj({origins:e,active:t,allLabel:n,onChange:i}){return d.jsxs("div",{className:"origin-tabs",role:"tablist",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":t==="all",className:`origin-tab ${t==="all"?"is-active":""}`,onClick:()=>i("all"),children:n}),e.map(s=>d.jsx("button",{type:"button",role:"tab","aria-selected":t===s,className:`origin-tab ${t===s?"is-active":""}`,onClick:()=>i(s),children:yF[s]??s},s))]})}function m0(e,t,n=7){const i=Date.now()-n*864e5,s=[],a=[];for(const o of e){const c=t(o);((c?Date.parse(c):0)>=i?s:a).push(o)}return{recent:s,older:a}}function gd(e){let t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function g0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function bF(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function VN(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function KN(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function xF(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function vF(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function Ab(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function wF(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(n*n+i*i+s*s)}function EF(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return n*n+i*i+s*s}function GN(e){let t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function SF(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function kF(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function y0(e,t){let n=t[0],i=t[1],s=t[2],a=n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function Yj(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function WN(e,t,n){let i=t[0],s=t[1],a=t[2],o=n[0],c=n[1],u=n[2];return e[0]=s*u-a*c,e[1]=a*o-i*u,e[2]=i*c-s*o,e}function NF(e,t,n,i){let s=t[0],a=t[1],o=t[2];return e[0]=s+i*(n[0]-s),e[1]=a+i*(n[1]-a),e[2]=o+i*(n[2]-o),e}function _F(e,t,n,i,s){const a=Math.exp(-i*s);let o=t[0],c=t[1],u=t[2];return e[0]=n[0]+(o-n[0])*a,e[1]=n[1]+(c-n[1])*a,e[2]=n[2]+(u-n[2])*a,e}function CF(e,t,n){let i=t[0],s=t[1],a=t[2],o=n[3]*i+n[7]*s+n[11]*a+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*s+n[8]*a+n[12])/o,e[1]=(n[1]*i+n[5]*s+n[9]*a+n[13])/o,e[2]=(n[2]*i+n[6]*s+n[10]*a+n[14])/o,e}function TF(e,t,n){let i=t[0],s=t[1],a=t[2],o=n[3]*i+n[7]*s+n[11]*a+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*s+n[8]*a)/o,e[1]=(n[1]*i+n[5]*s+n[9]*a)/o,e[2]=(n[2]*i+n[6]*s+n[10]*a)/o,e}function AF(e,t,n){let i=t[0],s=t[1],a=t[2];return e[0]=i*n[0]+s*n[3]+a*n[6],e[1]=i*n[1]+s*n[4]+a*n[7],e[2]=i*n[2]+s*n[5]+a*n[8],e}function jF(e,t,n){let i=t[0],s=t[1],a=t[2],o=n[0],c=n[1],u=n[2],f=n[3],m=c*a-u*s,p=u*i-o*a,y=o*s-c*i,b=c*y-u*p,x=u*m-o*y,w=o*p-c*m,E=f*2;return m*=E,p*=E,y*=E,b*=2,x*=2,w*=2,e[0]=i+m+b,e[1]=s+p+x,e[2]=a+y+w,e}const MF=(function(){const e=[0,0,0],t=[0,0,0];return function(n,i){g0(e,n),g0(t,i),y0(e,e),y0(t,t);let s=Yj(e,t);return s>1?0:s<-1?Math.PI:Math.acos(s)}})();function RF(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}class zs extends Array{constructor(t=0,n=t,i=t){return super(t,n,i),this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set(t,n=t,i=t){return t.length?this.copy(t):(bF(this,t,n,i),this)}copy(t){return g0(this,t),this}add(t,n){return n?VN(this,t,n):VN(this,this,t),this}sub(t,n){return n?KN(this,t,n):KN(this,this,t),this}multiply(t){return t.length?xF(this,this,t):Ab(this,this,t),this}divide(t){return t.length?vF(this,this,t):Ab(this,this,1/t),this}inverse(t=this){return kF(this,t),this}len(){return gd(this)}distance(t){return t?wF(this,t):gd(this)}squaredLen(){return GN(this)}squaredDistance(t){return t?EF(this,t):GN(this)}negate(t=this){return SF(this,t),this}cross(t,n){return n?WN(this,t,n):WN(this,this,t),this}scale(t){return Ab(this,this,t),this}normalize(){return y0(this,this),this}dot(t){return Yj(this,t)}equals(t){return RF(this,t)}applyMatrix3(t){return AF(this,this,t),this}applyMatrix4(t){return CF(this,this,t),this}scaleRotateMatrix4(t){return TF(this,this,t),this}applyQuaternion(t){return jF(this,this,t),this}angle(t){return MF(this,t)}lerp(t,n){return NF(this,this,t,n),this}smoothLerp(t,n,i){return _F(this,this,t,n,i),this}clone(){return new zs(this[0],this[1],this[2])}fromArray(t,n=0){return this[0]=t[n],this[1]=t[n+1],this[2]=t[n+2],this}toArray(t=[],n=0){return t[n]=this[0],t[n+1]=this[1],t[n+2]=this[2],t}transformDirection(t){const n=this[0],i=this[1],s=this[2];return this[0]=t[0]*n+t[4]*i+t[8]*s,this[1]=t[1]*n+t[5]*i+t[9]*s,this[2]=t[2]*n+t[6]*i+t[10]*s,this.normalize()}}const YN=new zs;let DF=1,OF=1,XN=!1;class LF{constructor(t,n={}){t.canvas||console.error("gl not passed as first argument to Geometry"),this.gl=t,this.attributes=n,this.id=DF++,this.VAOs={},this.drawRange={start:0,count:0},this.instancedCount=0,this.gl.renderer.bindVertexArray(null),this.gl.renderer.currentGeometry=null,this.glState=this.gl.renderer.state;for(let i in n)this.addAttribute(i,n[i])}addAttribute(t,n){if(this.attributes[t]=n,n.id=OF++,n.size=n.size||1,n.type=n.type||(n.data.constructor===Float32Array?this.gl.FLOAT:n.data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT),n.target=t==="index"?this.gl.ELEMENT_ARRAY_BUFFER:this.gl.ARRAY_BUFFER,n.normalized=n.normalized||!1,n.stride=n.stride||0,n.offset=n.offset||0,n.count=n.count||(n.stride?n.data.byteLength/n.stride:n.data.length/n.size),n.divisor=n.instanced||0,n.needsUpdate=!1,n.usage=n.usage||this.gl.STATIC_DRAW,n.buffer||this.updateAttribute(n),n.divisor){if(this.isInstanced=!0,this.instancedCount&&this.instancedCount!==n.count*n.divisor)return console.warn("geometry has multiple instanced buffers of different length"),this.instancedCount=Math.min(this.instancedCount,n.count*n.divisor);this.instancedCount=n.count*n.divisor}else t==="index"?this.drawRange.count=n.count:this.attributes.index||(this.drawRange.count=Math.max(this.drawRange.count,n.count))}updateAttribute(t){const n=!t.buffer;n&&(t.buffer=this.gl.createBuffer()),this.glState.boundBuffer!==t.buffer&&(this.gl.bindBuffer(t.target,t.buffer),this.glState.boundBuffer=t.buffer),n?this.gl.bufferData(t.target,t.data,t.usage):this.gl.bufferSubData(t.target,0,t.data),t.needsUpdate=!1}setIndex(t){this.addAttribute("index",t)}setDrawRange(t,n){this.drawRange.start=t,this.drawRange.count=n}setInstancedCount(t){this.instancedCount=t}createVAO(t){this.VAOs[t.attributeOrder]=this.gl.renderer.createVertexArray(),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.bindAttributes(t)}bindAttributes(t){t.attributeLocations.forEach((n,{name:i,type:s})=>{if(!this.attributes[i]){console.warn(`active attribute ${i} not being supplied`);return}const a=this.attributes[i];this.gl.bindBuffer(a.target,a.buffer),this.glState.boundBuffer=a.buffer;let o=1;s===35674&&(o=2),s===35675&&(o=3),s===35676&&(o=4);const c=a.size/o,u=o===1?0:o*o*4,f=o===1?0:o*4;for(let m=0;m<o;m++)this.gl.vertexAttribPointer(n+m,c,a.type,a.normalized,a.stride+u,a.offset+m*f),this.gl.enableVertexAttribArray(n+m),this.gl.renderer.vertexAttribDivisor(n+m,a.divisor)}),this.attributes.index&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.attributes.index.buffer)}draw({program:t,mode:n=this.gl.TRIANGLES}){var s;this.gl.renderer.currentGeometry!==`${this.id}_${t.attributeOrder}`&&(this.VAOs[t.attributeOrder]||this.createVAO(t),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.gl.renderer.currentGeometry=`${this.id}_${t.attributeOrder}`),t.attributeLocations.forEach((a,{name:o})=>{const c=this.attributes[o];c.needsUpdate&&this.updateAttribute(c)});let i=2;((s=this.attributes.index)==null?void 0:s.type)===this.gl.UNSIGNED_INT&&(i=4),this.isInstanced?this.attributes.index?this.gl.renderer.drawElementsInstanced(n,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i,this.instancedCount):this.gl.renderer.drawArraysInstanced(n,this.drawRange.start,this.drawRange.count,this.instancedCount):this.attributes.index?this.gl.drawElements(n,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*i):this.gl.drawArrays(n,this.drawRange.start,this.drawRange.count)}getPosition(){const t=this.attributes.position;if(t.data)return t;if(!XN)return console.warn("No position buffer data found to compute bounds"),XN=!0}computeBoundingBox(t){t||(t=this.getPosition());const n=t.data,i=t.size;this.bounds||(this.bounds={min:new zs,max:new zs,center:new zs,scale:new zs,radius:1/0});const s=this.bounds.min,a=this.bounds.max,o=this.bounds.center,c=this.bounds.scale;s.set(1/0),a.set(-1/0);for(let u=0,f=n.length;u<f;u+=i){const m=n[u],p=n[u+1],y=n[u+2];s.x=Math.min(m,s.x),s.y=Math.min(p,s.y),s.z=Math.min(y,s.z),a.x=Math.max(m,a.x),a.y=Math.max(p,a.y),a.z=Math.max(y,a.z)}c.sub(a,s),o.add(s,a).divide(2)}computeBoundingSphere(t){t||(t=this.getPosition());const n=t.data,i=t.size;this.bounds||this.computeBoundingBox(t);let s=0;for(let a=0,o=n.length;a<o;a+=i)YN.fromArray(n,a),s=Math.max(s,this.bounds.center.squaredDistance(YN));this.bounds.radius=Math.sqrt(s)}remove(){for(let t in this.VAOs)this.gl.renderer.deleteVertexArray(this.VAOs[t]),delete this.VAOs[t];for(let t in this.attributes)this.gl.deleteBuffer(this.attributes[t].buffer),delete this.attributes[t]}}let IF=1;const QN={};class ZN{constructor(t,{vertex:n,fragment:i,uniforms:s={},transparent:a=!1,cullFace:o=t.BACK,frontFace:c=t.CCW,depthTest:u=!0,depthWrite:f=!0,depthFunc:m=t.LEQUAL}={}){t.canvas||console.error("gl not passed as first argument to Program"),this.gl=t,this.uniforms=s,this.id=IF++,n||console.warn("vertex shader not supplied"),i||console.warn("fragment shader not supplied"),this.transparent=a,this.cullFace=o,this.frontFace=c,this.depthTest=u,this.depthWrite=f,this.depthFunc=m,this.blendFunc={},this.blendEquation={},this.stencilFunc={},this.stencilOp={},this.transparent&&!this.blendFunc.src&&(this.gl.renderer.premultipliedAlpha?this.setBlendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.setBlendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA)),this.vertexShader=t.createShader(t.VERTEX_SHADER),this.fragmentShader=t.createShader(t.FRAGMENT_SHADER),this.program=t.createProgram(),t.attachShader(this.program,this.vertexShader),t.attachShader(this.program,this.fragmentShader),this.setShaders({vertex:n,fragment:i})}setShaders({vertex:t,fragment:n}){if(t&&(this.gl.shaderSource(this.vertexShader,t),this.gl.compileShader(this.vertexShader),this.gl.getShaderInfoLog(this.vertexShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.vertexShader)}
|
|
@@ -828,7 +828,7 @@ name: code-review
|
|
|
828
828
|
description: ...
|
|
829
829
|
---
|
|
830
830
|
|
|
831
|
-
# ...`,"aria-label":t("skills.import.body")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:f.isPending||!u||!o.trim(),onClick:()=>f.mutate(),children:[f.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(zj,{size:14,strokeWidth:3}),t("skills.import.submit")]})]})})}function eie({onClose:e,onSubmit:t}){const n=Xe(),[i,s]=C.useState(""),[a,o]=C.useState(""),c=/^[a-z0-9][a-z0-9-]*$/.test(i);return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold flex items-center gap-2",children:[d.jsx(il,{size:16,strokeWidth:2.5}),n("skills.ai.title")]}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:e,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("skills.ai.name")}),d.jsx("input",{type:"text",value:i,onChange:u=>s(u.target.value),placeholder:"rust-error-handling",className:"nb-input w-full font-[family-name:var(--font-mono)]","aria-label":n("skills.ai.name")})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("skills.ai.intent")}),d.jsx("textarea",{value:a,onChange:u=>o(u.target.value),placeholder:n("skills.ai.placeholder"),rows:5,className:"nb-input w-full text-sm","aria-label":n("skills.ai.intent")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:!c||!a.trim(),onClick:()=>t(i,a),children:[d.jsx(il,{size:14,strokeWidth:2.5}),n("skills.ai.submit")]})]})})})}async function tie(e){const{files:t}=await Vte(e),n=t["SKILL.md"]??"",i=new Blob([n],{type:"text/markdown"}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=`${e}.SKILL.md`,a.click(),URL.revokeObjectURL(s)}const nie=[{value:"all",labelKey:"skills.category.all"},{value:"language",labelKey:"skills.category.language"},{value:"domain",labelKey:"skills.category.domain"},{value:"persona",labelKey:"skills.category.persona"},{value:"workflow",labelKey:"skills.category.workflow"},{value:"engine",labelKey:"skills.category.engine"},{value:"genre",labelKey:"skills.category.genre"},{value:"platform",labelKey:"skills.category.platform"},{value:"review",labelKey:"skills.category.review"},{value:"meta",labelKey:"skills.category.meta"},{value:"other",labelKey:"skills.category.other"}],iie={language:"var(--color-accent-purple)",domain:"var(--color-secondary)",persona:"var(--color-primary)",workflow:"var(--color-accent-mint)",engine:"var(--color-accent-yellow)",genre:"var(--color-accent-pink)",platform:"var(--color-secondary-dark)",review:"var(--color-primary-dark)",meta:"var(--surface-control)",other:"var(--surface-control)"};function sie(){var q,V;const e=Xe(),[t,n]=C.useState("all"),[i,s]=C.useState([]),[a,o]=C.useState(""),[c,u]=C.useState(null),[f,m]=C.useState(!1),[p,y]=C.useState(!1),b=tn(),w=(((q=at({queryKey:["gen-jobs"],queryFn:UL,refetchInterval:3e3}).data)==null?void 0:q.data)??[]).filter(O=>O.kind==="skill"),E=w.filter(O=>O.status!=="done"),v=C.useRef(new Set);C.useEffect(()=>{for(const O of w)(O.status==="done"||O.status==="error")&&!v.current.has(O.id)&&(v.current.add(O.id),b.invalidateQueries({queryKey:["skills"]}),b.invalidateQueries({queryKey:["skill-updates"]}))},[w,b]);const _=(O,R)=>{Kte(O,R).then(()=>b.invalidateQueries({queryKey:["gen-jobs"]})).catch(()=>{})},T=(((V=at({queryKey:["skill-updates"],queryFn:qte}).data)==null?void 0:V.data)??[]).filter(O=>O.status!=="same").length,{data:A,isLoading:j}=at({queryKey:["skills"],queryFn:()=>ig()}),M=at({queryKey:["projects"],queryFn:ro}),D=C.useMemo(()=>((A==null?void 0:A.data)??[]).filter(R=>!(t!=="all"&&R.category!==t||i.length>0&&!R.tags.some(z=>i.includes(z))||a&&!R.name.toLowerCase().includes(a.toLowerCase()))),[A,t,i,a]),I=C.useMemo(()=>{const O=(A==null?void 0:A.data)??[],R={all:O.length};for(const z of O)R[z.category]=(R[z.category]??0)+1;return R},[A]),P=C.useMemo(()=>{const O=new Map;for(const R of(A==null?void 0:A.data)??[])for(const z of R.tags)O.set(z,(O.get(z)??0)+1);return[...O.entries()].sort((R,z)=>z[1]-R[1]||R[0].localeCompare(z[0]))},[A]),U=O=>s(R=>R.includes(O)?R.filter(z=>z!==O):[...R,O]);return d.jsxs("div",{className:"flex flex-col gap-4 max-w-full",children:[d.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:"Skills"}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:j?e("common.loading"):e("skills.subtitleCount",{count:(A==null?void 0:A.data.length)??0})})]}),d.jsxs("div",{className:"flex gap-3 items-center",children:[T>0&&d.jsx("span",{className:"nb-badge text-[10px]",title:e("skills.updates.badge",{count:String(T)}),children:e("skills.updates.badge",{count:String(T)})}),d.jsxs("button",{className:"nb-btn",onClick:()=>y(!0),type:"button",children:[d.jsx(il,{size:14,strokeWidth:2.5}),e("skills.ai")]}),d.jsxs("button",{className:"nb-btn",onClick:()=>m(!0),type:"button",children:[d.jsx(zj,{size:14,strokeWidth:2.5}),e("skills.import")]}),d.jsxs("button",{className:"nb-btn nb-btn-mint",onClick:async()=>{await Ute(),b.invalidateQueries({queryKey:["skills"]}),b.invalidateQueries({queryKey:["skill-updates"]})},type:"button",children:[d.jsx(ea,{size:14,strokeWidth:2.5}),"Sync bundled"]})]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"relative shrink-0 w-full max-w-xs",children:[d.jsx(cf,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),d.jsx("input",{className:"nb-input pl-9 w-full",placeholder:e("skills.search.placeholder"),value:a,onChange:O=>o(O.target.value),"aria-label":e("skills.search.aria")})]}),d.jsx(Zc,{ariaLabel:"skill categories",className:"flex-1 min-w-0",value:t,onChange:n,options:nie.filter(O=>O.value==="all"||(I[O.value]??0)>0).map(O=>({value:O.value,label:d.jsxs(d.Fragment,{children:[e(O.labelKey)," ",I[O.value]??0]})}))})]}),P.length>0&&d.jsxs("div",{className:"flex items-start gap-2 flex-wrap",children:[d.jsx("span",{className:"text-xs font-bold text-[var(--color-text-muted)] pt-1.5 uppercase tracking-wider",children:e("skills.tags.title")}),d.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1",children:[P.map(([O,R])=>{const z=i.includes(O);return d.jsxs("button",{type:"button",onClick:()=>U(O),className:["px-2.5 py-1 rounded-full text-xs font-[family-name:var(--font-mono)] border-2 border-[var(--color-text)] transition-colors",z?"bg-[var(--color-text)] text-[var(--color-bg)] font-bold":"bg-[var(--surface-control)] text-[var(--color-text-muted)] hover:bg-[var(--surface-control-hover)]"].join(" "),children:[O," ",d.jsx("span",{className:"opacity-60",children:R})]},O)}),i.length>0&&d.jsx("button",{type:"button",onClick:()=>s([]),className:"px-2.5 py-1 rounded-full text-xs font-bold text-[var(--color-crashed)] hover:underline",children:e("skills.tags.clear")})]})]}),d.jsxs("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(280px,1fr))]",children:[E.map(O=>d.jsxs("div",{className:`nb-card flex items-center gap-2 ${O.status==="error"?"bg-[var(--color-crashed-bg)]":"opacity-70"}`,children:[O.status==="running"?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(vn,{size:14,strokeWidth:3}),d.jsx("span",{className:"text-sm text-[var(--color-text-muted)] truncate",children:O.status==="running"?`${O.label} · ${e("skills.ai.wait")}`:`${O.label}: ${O.error??e("skills.ai.error")}`})]},O.id)),D.map(O=>{var R;return d.jsx(rie,{skill:O,projectCount:((R=M.data)==null?void 0:R.data.length)??0,onOpen:()=>u(O.name),onExport:()=>void tie(O.name)},O.name)})]}),c&&d.jsx(vL,{name:c,onClose:()=>u(null)}),f&&d.jsx(Jne,{onClose:()=>m(!1)}),p&&d.jsx(eie,{onClose:()=>y(!1),onSubmit:(O,R)=>{_(O,R),y(!1)}})]})}function rie({skill:e,projectCount:t,onOpen:n,onExport:i}){const s=Xe(),a=iie[e.category];return d.jsxs("article",{className:"nb-card nb-card-interactive relative flex flex-col gap-3",children:[d.jsx("button",{type:"button",onClick:n,"aria-label":`Open ${e.name}`,className:"absolute inset-0 cursor-pointer rounded-[inherit] border-0 bg-transparent"}),d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsx("h3",{className:"min-w-0 flex-1 overflow-hidden break-all font-[family-name:var(--font-heading)] text-lg font-bold leading-6 line-clamp-2",children:e.name}),d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[d.jsx("button",{type:"button",className:"nb-btn relative z-10 p-1",onClick:i,"aria-label":s("skills.export"),title:s("skills.export"),children:d.jsx(Tj,{size:12,strokeWidth:2.5})}),d.jsx("span",{className:"nb-badge text-[10px]",style:{background:a},children:e.category})]})]}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] leading-5 line-clamp-3",children:e.description||"(no description)"}),e.tags.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(o=>d.jsx("span",{className:"text-[10px] font-[family-name:var(--font-mono)] px-1.5 py-0.5 rounded-full bg-[var(--surface-control)] border border-[var(--control-border)]",children:o},o))}),d.jsxs("div",{className:"flex items-center justify-between text-xs font-[family-name:var(--font-mono)] pt-2 border-t-[1.5px] border-dashed border-[var(--color-border-light)] mt-auto",children:[d.jsx("span",{className:"font-bold",children:e.linkedProjects.length>0?`● linked in ${e.linkedProjects.length}`:"○ not linked"}),d.jsxs("span",{className:"text-[var(--color-text-subtle)]",children:[t," projects"]})]})]})}function aie(e){return _t("/api/prompts")}function FL(e){return _t(`/api/prompts/${encodeURIComponent(e)}`)}function oie(e){return Ks("/api/prompts",e)}function lie(e,t){return Rm(`/api/prompts/${encodeURIComponent(e)}`,t)}function cie(e){return Yv(`/api/prompts/${encodeURIComponent(e)}`)}function uie(e){return Ks("/api/prompts/generate",{intent:e})}function $L(e){const t=new Set,n=[];for(const i of e.matchAll(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g)){const s=i[1];s&&!t.has(s)&&(t.add(s),n.push(s))}return n}function die(){var M,D;const e=Xe(),[t,n]=Yr("prompts.last",""),[i,s]=C.useState(null),[a,o]=C.useState(!1),[c,u]=C.useState(""),[f,m]=C.useState(new Set),p=tn(),y=at({queryKey:["prompts"],queryFn:()=>aie()}),b=((M=y.data)==null?void 0:M.data)??[],x=C.useMemo(()=>[...new Set(b.flatMap(I=>I.tags))].sort(),[b]),E=(((D=at({queryKey:["gen-jobs"],queryFn:UL,refetchInterval:3e3}).data)==null?void 0:D.data)??[]).filter(I=>I.kind==="prompt"),v=E.filter(I=>I.status!=="done"),_=C.useRef(new Set),k=C.useRef(null);C.useEffect(()=>{for(const I of E)(I.status==="done"||I.status==="error")&&!_.current.has(I.id)&&(_.current.add(I.id),p.invalidateQueries({queryKey:["prompts"]}),I.status==="done"&&I.result&&n(I.result))},[E,p,n]);const T=I=>{uie(I).then(()=>p.invalidateQueries({queryKey:["gen-jobs"]})).catch(()=>{})},A=C.useMemo(()=>{const I=c.trim().toLowerCase();return b.filter(P=>!(f.size&&![...f].every(U=>P.tags.includes(U))||I&&!(P.name.toLowerCase().includes(I)||P.description.toLowerCase().includes(I)||P.tags.some(q=>q.toLowerCase().includes(I)))))},[b,f,c]);C.useEffect(()=>{t&&b.length&&!b.some(I=>I.name===t)&&n("")},[t,b,n]);const j=I=>m(P=>{const U=new Set(P);return U.has(I)?U.delete(I):U.add(I),U});return d.jsxs("div",{className:"flex flex-col flex-1 min-h-0 w-full gap-3",children:[d.jsxs("div",{className:"shrink-0 flex items-center justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("prompts.title")}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:e("prompts.desc")})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs("button",{className:"nb-btn",type:"button",onClick:()=>o(!0),children:[d.jsx(il,{size:14,strokeWidth:2.5}),e("prompts.ai")]}),d.jsxs("button",{className:"nb-btn nb-btn-mint",type:"button",onClick:()=>s({mode:"new"}),children:[d.jsx(Gn,{size:14,strokeWidth:3}),e("prompts.new")]})]})]}),d.jsxs("div",{className:"shrink-0 flex flex-col gap-2",children:[d.jsxs("label",{className:"nb-input flex items-center gap-2 w-full",children:[d.jsx(cf,{size:14}),d.jsx("input",{type:"text",value:c,onChange:I=>u(I.target.value),placeholder:e("prompts.search"),className:"bg-transparent outline-none flex-1 text-sm","aria-label":e("prompts.search")})]}),x.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.map(I=>d.jsx("button",{type:"button",onClick:()=>j(I),className:`nb-btn px-2 py-0.5 text-xs ${f.has(I)?"nb-btn-mint":""}`,children:I},I))})]}),d.jsxs("div",{className:"flex gap-5 flex-1 min-h-0",children:[d.jsx("aside",{className:"w-80 shrink-0 nb-card p-3 overflow-hidden flex h-full min-h-0 flex-col gap-2",children:d.jsxs("div",{ref:k,className:"edge-scroll-list flex-1 min-h-0 overflow-y-auto flex flex-col gap-0.5",children:[v.map(I=>d.jsxs("div",{className:`nb-card flex items-center gap-2 ${I.status==="error"?"bg-[var(--color-crashed-bg)]":"opacity-70"}`,style:{padding:"8px 10px"},children:[I.status==="running"?d.jsx(lt,{size:12,className:"animate-spin"}):d.jsx(vn,{size:12,strokeWidth:3}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)] truncate",children:I.status==="running"?e("prompts.ai.wait"):`${e("prompts.ai.error")}: ${I.error??""}`})]},I.id)),y.isLoading?d.jsx("div",{className:"nb-card",children:d.jsx(lt,{size:14,className:"animate-spin"})}):A.length===0?d.jsx("div",{className:"nb-card",children:d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:e("prompts.empty")})}):A.map((I,P)=>d.jsx(Qc,{index:P,root:k,children:d.jsxs("button",{type:"button",onClick:()=>n(I.name),className:["dimension-menu-item w-full min-w-0 flex-col items-stretch gap-1 px-3 py-2 pl-4 text-left",t===I.name?"dimension-menu-item-active":""].join(" "),children:[d.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[I.favorite&&d.jsx(Pj,{size:12,fill:"currentColor",className:"shrink-0"}),d.jsx("code",{className:"min-w-0 max-w-full truncate font-[family-name:var(--font-mono)] text-sm font-bold",children:I.name})]}),I.description&&d.jsx("span",{className:"block w-full min-w-0 truncate text-xs text-[var(--color-text-muted)]",children:I.description})]})},I.name))]})}),d.jsx("div",{className:"flex-1 min-w-0 min-h-0",children:t?d.jsx(hie,{name:t,onEdit:()=>s({mode:"edit",name:t}),onDeleted:()=>n("")},t):d.jsx("div",{className:"nb-card",children:d.jsx("p",{className:"text-[var(--color-text-muted)]",children:e("prompts.selectHint")})})})]}),i&&d.jsx(mie,{name:i.mode==="edit"?i.name:null,onClose:()=>s(null),onSaved:I=>{s(null),n(I)}}),a&&d.jsx(fie,{onClose:()=>o(!1),onSubmit:I=>{T(I),o(!1)}})]})}function fie({onClose:e,onSubmit:t}){const n=Xe(),[i,s]=C.useState("");return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold flex items-center gap-2",children:[d.jsx(il,{size:16,strokeWidth:2.5}),n("prompts.ai.title")]}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:e,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("prompts.ai.intent")}),d.jsx("textarea",{value:i,onChange:a=>s(a.target.value),placeholder:n("prompts.ai.placeholder"),rows:5,className:"nb-input w-full text-sm","aria-label":n("prompts.ai.intent")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:!i.trim(),onClick:()=>t(i),children:[d.jsx(il,{size:14,strokeWidth:2.5}),n("prompts.ai.submit")]})]})})})}function hie({name:e,onEdit:t,onDeleted:n}){const i=Xe(),s=tn(),{confirm:a}=Ln(),o=at({queryKey:["prompt",e],queryFn:()=>FL(e)}),c=zt({mutationFn:()=>cie(e),onSuccess:()=>{s.invalidateQueries({queryKey:["prompts"]}),n()}});if(o.isLoading)return d.jsx("div",{className:"nb-card",children:d.jsx(lt,{size:14,className:"animate-spin"})});const u=o.data;if(!u)return null;const f=$L(u.body);return d.jsxs("div",{className:"nb-card flex flex-col gap-3 h-full min-h-0",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 shrink-0",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold flex items-center gap-2",children:[u.favorite&&d.jsx(Pj,{size:16,fill:"currentColor"}),d.jsx("code",{className:"font-[family-name:var(--font-mono)] truncate",children:u.name})]}),u.description&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:u.description})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:t,children:[d.jsx(Hv,{size:14,strokeWidth:3}),i("common.edit")]}),d.jsx("button",{type:"button",className:"nb-btn",disabled:c.isPending,onClick:async()=>{await a({title:i("prompts.delete"),body:i("prompts.deleteConfirm",{name:e})})&&c.mutate()},"aria-label":i("prompts.delete"),children:d.jsx(qi,{size:14,strokeWidth:3})})]})]}),u.tags.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 shrink-0",children:u.tags.map(m=>d.jsx("span",{className:"nb-badge px-2 py-0.5 text-xs",children:m},m))}),d.jsx("pre",{className:"flex-1 bg-surface-input min-h-0 overflow-auto text-sm font-[family-name:var(--font-mono)] whitespace-pre-wrap break-words bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-3",children:u.body}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)] shrink-0",children:f.length?i("prompts.vars",{names:f.join(", ")}):i("prompts.noVars")})]})}function pie({tags:e,onChange:t}){const n=Xe(),[i,s]=C.useState(""),a=()=>{const o=i.trim();o&&!e.includes(o)&&t([...e,o]),s("")};return d.jsxs("div",{className:"nb-input w-full flex flex-wrap gap-1.5 items-center",children:[e.map(o=>d.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded px-1.5 py-0.5",children:[o,d.jsx("button",{type:"button",onClick:()=>t(e.filter(c=>c!==o)),"aria-label":`remove ${o}`,children:d.jsx(vn,{size:10,strokeWidth:3})})]},o)),d.jsx("input",{className:"flex-1 min-w-[90px] bg-transparent outline-none text-sm",value:i,onChange:o=>s(o.target.value),onKeyDown:o=>{o.key==="Enter"?(o.preventDefault(),a()):o.key==="Backspace"&&!i&&e.length&&t(e.slice(0,-1))},placeholder:e.length?"":n("prompts.tagAdd"),"aria-label":n("prompts.tags")})]})}function mie({name:e,onClose:t,onSaved:n}){const i=Xe(),s=tn(),{alert:a}=Ln(),o=e===null,c=at({queryKey:["prompt",e],queryFn:()=>FL(e),enabled:!o}),[u,f]=C.useState(o?{name:"",description:"",tags:[],body:"",favorite:!1}:null);C.useEffect(()=>{if(!o&&c.data&&u===null){const b=c.data;f({name:b.name,description:b.description,tags:b.tags,body:b.body,favorite:b.favorite})}},[o,c.data,u]);const m=zt({mutationFn:()=>{if(!u)throw new Error("no form");const b={description:u.description||void 0,tags:u.tags,favorite:u.favorite,body:u.body};return o?oie({name:u.name,...b}):lie(e,b)},onSuccess:b=>{s.invalidateQueries({queryKey:["prompts"]}),s.invalidateQueries({queryKey:["prompt",b.name]}),n(b.name)},onError:b=>void a({title:i("prompts.saveError"),body:b instanceof Error?b.message:String(b)})}),p=C.useMemo(()=>u?/^[a-z0-9][a-z0-9-]*$/.test(u.name):!1,[u]),y=C.useMemo(()=>u?$L(u.body):[],[u]);return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-2xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold",children:o?i("prompts.new"):e}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:t,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),!o&&c.isLoading?d.jsx(lt,{size:14,className:"animate-spin"}):u?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.name")}),d.jsx("input",{type:"text",value:u.name,disabled:!o,onChange:b=>f({...u,name:b.target.value}),placeholder:i("prompts.namePlaceholder"),className:"nb-input w-full","aria-label":i("prompts.name")}),o&&u.name&&!p&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:i("prompts.nameError")})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.description")}),d.jsx("input",{type:"text",value:u.description,onChange:b=>f({...u,description:b.target.value}),className:"nb-input w-full","aria-label":i("prompts.description")})]})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.tags")}),d.jsx(pie,{tags:u.tags,onChange:b=>f({...u,tags:b})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.body")}),d.jsx("textarea",{value:u.body,onChange:b=>f({...u,body:b.target.value}),placeholder:i("prompts.bodyPlaceholder"),rows:12,className:"nb-input w-full font-[family-name:var(--font-mono)] text-sm","aria-label":i("prompts.body")}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:y.length?i("prompts.vars",{names:y.join(", ")}):i("prompts.noVars")})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",disabled:m.isPending||o&&!p||!u.body.trim(),onClick:()=>m.mutate(),children:[m.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3}),i("prompts.save")]}),d.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:u.favorite,onChange:b=>f({...u,favorite:b.target.checked})}),i("prompts.favorite")]})]})]}):null]})})})}function gie(){return _t("/api/processes").then(e=>e.data)}function yie(e){return Ks(`/api/processes/${e}/kill`)}function bie(){return _t("/api/processes/reclaim")}async function xie(e){const t=await fetch("/api/processes/reclaim",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({idleMinutes:e})});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return t.json()}const vie="nb-card";function wie(e){if(!e)return"—";const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t)||t<0)return"—";const n=Math.floor(t/6e4);if(n<1)return"<1m";if(n<60)return`${n}m`;const i=Math.floor(n/60);return i<24?`${i}h${n%60?` ${n%60}m`:""}`:`${Math.floor(i/24)}d${i%24?` ${i%24}h`:""}`}function Mx(e){return e.project?e.project:e.cwd?e.cwd.split("/").filter(Boolean).pop()??e.slot:e.slot}function lT(e){const t=/^session-chat-(.+)$/.exec(e.slot);return(t==null?void 0:t[1])??null}function Eie({p:e}){const t=e.alive?e.sessionState??"alive":"offline",n=e.alive?"bg-[var(--color-accent-mint)]":"bg-[var(--color-bg-cream)] text-[var(--color-text)]/60";return d.jsx("span",{className:`nb-status font-[family-name:var(--font-mono)] ${n}`,children:t})}function Sie({embedded:e}={}){var w;const t=Xe(),n=tn(),[i,s]=C.useState(null),[a,o]=C.useState("all"),c=at({queryKey:["processes"],queryFn:gie,refetchInterval:5e3}),u=zt({mutationFn:yie,onSuccess:E=>{s(E.message),n.invalidateQueries({queryKey:["processes"]})},onError:E=>s(E instanceof Error?E.message:String(E))}),f=at({queryKey:["reclaim"],queryFn:bie}),[m,p]=C.useState("");C.useEffect(()=>{f.data&&m===""&&p(String(f.data.idleMinutes))},[f.data,m]);const y=zt({mutationFn:E=>xie(E),onSuccess:E=>{s(`自动回收已设为 ${E.idleMinutes} 分钟空闲`),n.invalidateQueries({queryKey:["reclaim"]})},onError:E=>s(E instanceof Error?E.message:String(E))}),x=(c.data??[]).filter(E=>a==="all"?!0:E.kind===a);return d.jsxs("div",{className:"max-w-full flex-1 min-h-0 flex flex-col",children:[!e&&d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl mb-2 shrink-0",children:t("processes.title")}),i&&d.jsx("div",{className:"nb-card mb-3 px-3 py-2 text-sm font-mono",children:i}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[["all","worker","chat"].map(E=>d.jsx("button",{type:"button","aria-pressed":a===E,onClick:()=>o(E),className:`nb-btn px-3 py-1 text-sm ${a===E?"nb-btn-primary":""}`,children:t(`processes.kind.${E}`)},E)),d.jsxs("button",{type:"button","aria-label":t("processes.refresh"),onClick:()=>n.invalidateQueries({queryKey:["processes"]}),className:"nb-btn px-3 py-1 text-sm",children:[c.isFetching?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(ea,{size:14}),t("processes.refresh")]}),d.jsxs("div",{className:`${vie} px-3 py-1 flex items-center gap-2 shrink-0 ml-auto`,title:"自动回收:会话空闲 N 分钟自动停,下次访问 durable resume 续上,不丢上下文",children:[d.jsx(x6,{size:15,strokeWidth:2.5}),d.jsx("input",{type:"number",min:1,max:1440,value:m,onChange:E=>p(E.target.value),className:"nb-input w-14 px-2 py-1 font-[family-name:var(--font-mono)] text-sm","aria-label":"自动回收空闲分钟数"}),d.jsx("button",{type:"button",disabled:y.isPending||m===""||Number(m)===((w=f.data)==null?void 0:w.idleMinutes),onClick:()=>y.mutate(Math.round(Number(m))),className:"nb-btn nb-btn-primary text-sm disabled:opacity-50",style:{padding:"4px 8px"},"aria-label":"保存自动回收设置",title:"保存自动回收设置",children:y.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})})]})]}),d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] flex-1 min-h-0 overflow-hidden flex flex-col text-sm",children:[d.jsxs("div",{className:"shrink-0 grid grid-cols-[130px_minmax(140px,1.2fr)_minmax(140px,1.5fr)_80px_110px_90px_90px_100px] bg-[var(--surface-table-head)] font-[family-name:var(--font-heading)] border-b-2 border-[var(--color-text)]/15",children:[d.jsx("div",{className:"px-3 py-2",children:t("processes.col.kind")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.slot")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.project")}),d.jsx("div",{className:"px-3 py-2",children:"PID"}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.state")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.memory")}),d.jsx("div",{className:"px-3 py-2",children:"运行时间"}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.action")})]}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto font-[family-name:var(--font-mono)]",children:[x.length===0&&d.jsx("div",{className:"px-3 py-6 text-center text-[var(--color-text)]/50",children:t("processes.empty")}),x.map(E=>d.jsxs("div",{className:"grid grid-cols-[130px_minmax(140px,1.2fr)_minmax(140px,1.5fr)_80px_110px_90px_90px_100px] border-t border-[var(--color-text)]/10 items-center",title:E.cwd??"",children:[d.jsxs("div",{className:"px-3 py-2 flex flex-col gap-0.5",children:[d.jsx("span",{className:`nb-badge text-xs whitespace-nowrap ${E.kind==="worker"?"bg-[var(--color-accent-yellow)]":"bg-[var(--color-accent-purple)]"}`,children:t(`processes.kind.${E.kind}`)}),d.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--color-text)]/45",children:E.tool})]}),d.jsx("div",{className:"px-3 py-2 truncate",children:E.slot}),d.jsx("div",{className:"px-3 py-2 truncate",children:E.kind==="chat"&&lT(E)?d.jsxs(jc,{to:`/chat/${lT(E)}`,className:"inline-flex items-center gap-1 font-semibold text-[var(--color-text)] underline decoration-2 underline-offset-2 hover:opacity-70",title:"打开对话窗口",children:[d.jsx(IU,{size:12,strokeWidth:2.5})," ",Mx(E)]}):E.kind==="worker"&&E.project?d.jsxs(jc,{to:`/board?project=${encodeURIComponent(E.project)}`,className:"inline-flex items-center gap-1 font-semibold text-[var(--color-text)] underline decoration-2 underline-offset-2 hover:opacity-70",title:"打开该项目看板",children:[d.jsx(QB,{size:12,strokeWidth:2.5})," ",Mx(E)]}):d.jsx("span",{children:Mx(E)})}),d.jsx("div",{className:"px-3 py-2",children:E.pid??"—"}),d.jsx("div",{className:"px-3 py-2",children:d.jsx(Eie,{p:E})}),d.jsx("div",{className:"px-3 py-2",children:E.memoryMB!=null?`${E.memoryMB} MB`:"—"}),d.jsx("div",{className:"px-3 py-2",children:wie(E.startedAt)}),d.jsx("div",{className:"px-3 py-2",children:E.alive&&E.pid!=null?d.jsxs("button",{type:"button","aria-label":`${t("processes.kill")} ${E.slot}`,onClick:()=>{confirm(t("processes.killConfirm").replace("{slot}",E.slot))&&u.mutate(E.pid)},className:"nb-btn nb-btn-danger px-2.5 py-1 text-xs",children:[d.jsx(_j,{size:13})," ",t("processes.kill")]}):d.jsx("span",{className:"text-[var(--color-text)]/40 text-xs",children:"—"})})]},E.slot))]})]})]})}function kie(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.action&&t.set("action",e.action);const n=t.toString();return _t(`/api/audit${n?`?${n}`:""}`).then(i=>i.data)}const Nie={create:"bg-[var(--color-accent-mint)]",modify:"bg-[var(--color-accent-yellow)]",delete:"bg-[var(--color-accent-pink)]",daemon:"bg-[var(--color-accent-purple)]"};function _ie({embedded:e}={}){const t=Xe(),n=tn(),[i,s]=C.useState(""),a=at({queryKey:["audit",i],queryFn:()=>kie(i?{action:i}:{}),refetchInterval:8e3}),o=a.data??[],c=u=>t(`audit.action.${u}`);return d.jsxs("div",{className:"max-w-full flex-1 min-h-0 flex flex-col",children:[!e&&d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl mb-2 shrink-0",children:t("audit.title")}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap shrink-0",children:[["","create","modify","delete","daemon"].map(u=>d.jsx("button",{type:"button","aria-pressed":i===u,onClick:()=>s(u),className:`nb-btn px-3 py-1 text-sm ${i===u?"nb-btn-primary":""}`,children:u?c(u):t("audit.filter.all")},u||"all")),d.jsxs("button",{type:"button","aria-label":t("audit.refresh"),onClick:()=>n.invalidateQueries({queryKey:["audit"]}),className:"nb-btn px-3 py-1 text-sm ml-auto",children:[a.isFetching?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(ea,{size:14}),t("audit.refresh")]})]}),d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] flex-1 min-h-0 overflow-hidden flex flex-col text-sm",children:[d.jsxs("div",{className:"shrink-0 grid grid-cols-[180px_120px_minmax(100px,1fr)_minmax(160px,2fr)] bg-[var(--surface-table-head)] font-[family-name:var(--font-heading)] border-b-2 border-[var(--color-text)]/15",children:[d.jsx("div",{className:"px-3 py-2",children:t("audit.col.time")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.action")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.project")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.detail")})]}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto font-[family-name:var(--font-mono)]",children:[o.length===0&&d.jsx("div",{className:"px-3 py-6 text-center text-[var(--color-text)]/50",children:t("audit.empty")}),o.map((u,f)=>d.jsxs("div",{className:"grid grid-cols-[180px_120px_minmax(100px,1fr)_minmax(160px,2fr)] border-t border-[var(--color-text)]/10 items-center",children:[d.jsx("div",{className:"px-3 py-2 whitespace-nowrap",children:new Date(u.ts).toLocaleString()}),d.jsx("div",{className:"px-3 py-2",children:d.jsx("span",{className:`nb-badge text-xs whitespace-nowrap ${Nie[u.action]}`,children:c(u.action)})}),d.jsx("div",{className:"px-3 py-2 truncate",title:u.project,children:u.project}),d.jsx("div",{className:"px-3 py-2 text-[var(--color-text)]/70 truncate",title:u.detail??"",children:u.detail??(u.source?`(${u.source})`:"—")})]},`${u.ts}-${f}`))]})]})]})}const qL=[{id:"git",fields:[{key:"GITLAB_URL",type:"text",placeholder:"https://gitlab.com"},{key:"GITLAB_TOKEN",type:"text"}]},{id:"matrix",fields:[{key:"MATRIX_HOMESERVER",type:"text",placeholder:"https://matrix.example.com"},{key:"MATRIX_ACCESS_TOKEN",type:"text"},{key:"MATRIX_ROOM_ID",type:"text",placeholder:"!room:example.com"}]},{id:"memory",fields:[{key:"SPS_MEMORY_MODE",type:"select",defaultValue:"local",options:["local","local+external","external","none"]},{key:"SPS_MEMORY_EXTERNAL_URL",type:"text",placeholder:"http://127.0.0.1:3111"},{key:"SPS_MEMORY_DISTILL",type:"select",options:["","on","off"]},{key:"SPS_MEMORY_IMPORT",type:"select",options:["","on","off"]},{key:"SPS_MEMORY_REDACT",type:"select",options:["","on","off"]}]},{id:"voice",fields:[{key:"SPS_DOUBAO_API_KEY",type:"text"},{key:"SPS_DOUBAO_SPEAKER",type:"text",placeholder:"zh_female_vv_uranus_bigtts"},{key:"SPS_DOUBAO_RESOURCE_ID",type:"text",placeholder:"seed-tts-2.0"}]},{id:"daemon",fields:[{key:"SPS_OPENAI_SANDBOX_PROVIDER",type:"select",options:["","unix_local","docker"]},{key:"SPS_DAEMON_MAX_CONCURRENT_RUNS",type:"number",placeholder:"按内存自动推导"},{key:"SPS_DAEMON_ORIGIN_QUOTAS",type:"text",placeholder:"coral-platform=30,gameforge=20"},{key:"SPS_DAEMON_QUEUE_WAIT_S",type:"number",defaultValue:"20"},{key:"SPS_DAEMON_MAX_QUEUE",type:"number",defaultValue:"200"}]},{id:"console",fields:[{key:"SPS_CONSOLE_TOKEN",type:"text"},{key:"SPS_CONSOLE_MEMORY_VIEWER_URL",type:"text",placeholder:"https://memory.example.com"}]}],Cie=qL.flatMap(e=>e.fields),cT=new Set(Cie.map(e=>e.key)),Tie=[{value:"config",labelKey:"system.tab.config"},{value:"processes",labelKey:"system.tab.processes"},{value:"doctor",labelKey:"system.tab.doctor"},{value:"audit",labelKey:"system.tab.audit"}];function Aie(){var s,a;const e=Xe(),t=at({queryKey:["system-info"],queryFn:Gj}),[n,i]=Yr("system.tab","config");return d.jsxs("div",{className:"system-page-shell flex flex-col flex-1 min-h-0 w-full",children:[d.jsxs("header",{className:"system-page-header shrink-0 flex items-center justify-between gap-3 flex-wrap",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("system.h1")}),d.jsx(jie,{platform:(s=t.data)==null?void 0:s.platform,current:(a=t.data)==null?void 0:a.version})]}),d.jsx(Zc,{ariaLabel:e("system.h1"),className:"max-w-full",value:n,onChange:i,options:Tie.map(o=>({value:o.value,label:e(o.labelKey)}))}),d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[n==="config"&&d.jsx(Mie,{}),n==="processes"&&d.jsx(Sie,{embedded:!0}),n==="doctor"&&d.jsx(Die,{}),n==="audit"&&d.jsx(_ie,{embedded:!0})]})]})}function jie({platform:e,current:t}){const n=Xe(),{confirm:i,alert:s}=Ln(),[a,o]=C.useState(!1),c=at({queryKey:["latest-version"],queryFn:Z6,enabled:!1}),u=async()=>{const m=(await c.refetch()).data;if(!m)return;if(m.upToDate){s({title:n("system.upgrade.checkUpdate"),body:n("system.upgrade.upToDate",{version:t??"?"})});return}if(await i({title:n("system.upgrade.confirm.title"),body:n("system.upgrade.confirm.body",{current:t??"?",latest:m.latest}),confirm:n("system.upgrade.confirm.button")})){o(!0);try{const y=await J6();s({title:y.ok?n("system.upgrade.success.title"):n("system.upgrade.notEffective.title"),body:y.ok?n("system.upgrade.success.body",{version:y.installedVersion??"?"}):y.output||""})}catch(y){s({title:n("system.upgrade.error.title"),body:y.message})}finally{o(!1)}}};return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] whitespace-nowrap",children:[e??"—",t?` · v${t}`:""]}),d.jsxs("button",{className:"nb-btn",style:{padding:"6px 12px",fontSize:12},onClick:u,disabled:a||c.isFetching||!t,type:"button","aria-label":n("system.upgrade.checkUpdate"),children:[a||c.isFetching?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:12,strokeWidth:2.5}),n("system.upgrade.checkUpdate")]})]})}function Mie(){const e=Xe(),t=tn(),{alert:n}=Ln(),{data:i,isLoading:s,isError:a,error:o,dataUpdatedAt:c}=at({queryKey:["system-env-raw"],queryFn:G6}),[u,f]=C.useState(null),[m,p]=C.useState(""),[y,b]=C.useState(""),x=i?`${i.etag}:${c}`:null;C.useEffect(()=>{if(!i||x===null)return;const I=u!==null&&u.content!==u.baseContent;(u===null||!I&&u.sourceKey!==x)&&(f({content:i.content,baseContent:i.content,etag:i.etag,sourceKey:x}),p(""),b(""))},[i,u,x]);const w=u,E=w!==null&&w.content!==w.baseContent,v=(w==null?void 0:w.content)??(i==null?void 0:i.content)??"",_=(w==null?void 0:w.etag)??(i==null?void 0:i.etag)??null,k=CL(v,cT),T=m.trim().toUpperCase(),A=AL(T)&&!cT.has(T)&&!k.some(I=>I.key===T),j=(I,P)=>{f(U=>{const q=U??Rx(i,x);return{...q,content:mm(q.content,I.key,P,I)}})},M=(I,P)=>{f(U=>{const q=U??Rx(i,x);return{...q,content:mm(q.content,I,P)}})},D=zt({mutationFn:()=>{if(w===null)throw new Error("no draft");return W6(w.content,w.etag)},onSuccess:I=>{f(P=>P===null?P:{...P,baseContent:P.content,etag:I.etag,sourceKey:`${I.etag}:saved`}),t.invalidateQueries({queryKey:["system-env"]}),t.invalidateQueries({queryKey:["system-env-raw"]})},onError:I=>{const P=I.status;n({title:e(P===409?"system.env.error.conflict.title":"system.env.error.save.title"),body:P===409?e("system.env.error.conflict.body"):I instanceof Error?I.message:String(I)})}});return s?d.jsx("p",{className:"text-[var(--color-text-muted)]",children:e("common.loading")}):a?d.jsx("div",{className:"bg-[var(--color-crashed-bg)] border-2 border-[var(--color-crashed)] rounded-lg p-3",children:d.jsx("p",{className:"text-sm",children:o instanceof Error?o.message:String(o)})}):d.jsxs("div",{className:"system-env-settings-editor",children:[d.jsxs("div",{className:"project-config-toolbar",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-base font-bold mb-1",children:e("system.tab.config")}),d.jsx("p",{className:"text-xs text-[var(--color-stuck)] font-bold",children:e("system.env.warning")}),_&&d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] mt-1",children:["etag: ",_,E?e("system.env.dirtyMark"):""]})]}),d.jsx("div",{className:"flex gap-2",children:d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 12px"},onClick:()=>D.mutate(),disabled:!E||D.isPending,type:"button","aria-label":e("system.env.save.aria"),children:[D.isPending?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:12,strokeWidth:3}),e("system.env.save")]})})]}),d.jsxs("div",{className:"project-config-settings","aria-label":e("system.env.settingsAria"),children:[qL.map(I=>d.jsxs("section",{className:"project-config-section",children:[d.jsxs("div",{className:"project-config-section-head",children:[d.jsx("h3",{children:e(`system.env.section.${I.id}`)}),d.jsx("p",{children:e(`system.env.section.${I.id}.hint`)})]}),d.jsx("div",{className:"project-config-grid",children:I.fields.map(P=>d.jsx(Rie,{field:P,value:_L(v,P),rawValue:Ud(v,P.key),onChange:U=>j(P,U)},P.key))})]},I.id)),d.jsxs("section",{className:"project-config-section",children:[d.jsxs("div",{className:"project-config-section-head",children:[d.jsx("h3",{children:e("system.env.section.custom")}),d.jsx("p",{children:e("system.env.section.custom.hint")})]}),d.jsxs("div",{className:"project-config-custom-list",children:[k.length===0?d.jsx("p",{className:"project-config-empty",children:e("system.env.custom.empty")}):k.map(I=>d.jsxs("div",{className:"project-config-custom-row",children:[d.jsx("code",{children:I.key}),d.jsx("input",{className:"nb-input",value:I.value,onChange:P=>M(I.key,P.target.value),"aria-label":e("system.env.custom.valueAria",{key:I.key})}),d.jsx("button",{type:"button",className:"nb-btn",onClick:()=>f(P=>{const U=P??Rx(i,x);return{...U,content:TL(U.content,I.key)}}),"aria-label":e("system.env.custom.removeAria",{key:I.key}),children:d.jsx(vn,{size:12,strokeWidth:3})})]},I.key)),d.jsxs("div",{className:"project-config-custom-row project-config-custom-add",children:[d.jsx("input",{className:"nb-input",value:m,onChange:I=>p(I.target.value),placeholder:e("system.env.custom.keyPlaceholder"),"aria-label":e("system.env.custom.keyAria")}),d.jsx("input",{className:"nb-input",value:y,onChange:I=>b(I.target.value),placeholder:e("system.env.custom.valuePlaceholder"),"aria-label":e("system.env.custom.newValueAria")}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",disabled:!A||!y,onClick:()=>{M(T,y),p(""),b("")},children:[d.jsx(Gn,{size:12,strokeWidth:3}),e("system.env.custom.add")]})]})]})]})]})]})}function Rx(e,t){const n=(e==null?void 0:e.content)??"",i=(e==null?void 0:e.etag)??"";return{content:n,baseContent:n,etag:i,sourceKey:t??`${i}:empty`}}function Rie({field:e,value:t,rawValue:n,onChange:i}){const s=Xe(),a=s(`system.env.field.${e.key}`),o=s(`system.env.field.${e.key}.help`),c=e.type==="boolean",u=(n||e.defaultValue||"").toLowerCase()==="true";return d.jsxs("div",{className:["project-config-field",c?"project-config-field-toggle":""].join(" "),children:[d.jsxs("span",{className:"project-config-label",children:[d.jsx("span",{children:a}),d.jsx("code",{children:e.key})]}),c?d.jsxs("span",{className:"project-config-toggle-row",children:[d.jsx("input",{type:"checkbox",checked:u,onChange:f=>i(String(f.target.checked))}),d.jsx("span",{children:s(u?"common.yes":"common.no")})]}):e.type==="select"?d.jsx("select",{className:"nb-input",value:t,onChange:f=>i(f.target.value),"aria-label":a,children:(e.options??[]).map(f=>d.jsx("option",{value:f,children:f||s("projectDetail.config.option.empty")},f||"__empty"))}):d.jsx("input",{className:"nb-input",type:e.type==="number"?"number":"text",min:e.type==="number"?0:void 0,value:t,onChange:f=>i(f.target.value),placeholder:e.placeholder,"aria-label":a}),d.jsx("span",{className:"project-config-help",children:o})]})}function Die(){var y;const e=Xe(),{alert:t}=Ln(),n=at({queryKey:["projects"],queryFn:ro}),[i,s]=C.useState({}),[a,o]=C.useState({}),[c,u]=C.useState(null),f=(((y=n.data)==null?void 0:y.data)??[]).map(b=>({project:b.name})),m=async(b,x)=>{o(w=>({...w,[b]:x?"fix":"check"}));try{const w=await eF(b,x);s(E=>({...E,[b]:w})),u(b)}catch(w){t({title:e(x?"system.diagnostics.error.fix":"system.diagnostics.error.check"),body:w instanceof Error?w.message:String(w)})}finally{o(w=>({...w,[b]:null}))}},p=async()=>{for(const b of f)await m(b.project,!1)};return d.jsxs("section",{className:"nb-card system-panel system-panel-doctor flex-1 min-h-0",children:[d.jsxs("div",{className:"system-panel-titlebar",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:e("system.diagnostics.title")}),d.jsxs("button",{className:"nb-btn nb-btn-mint",style:{padding:"6px 12px",fontSize:12},onClick:()=>{p()},disabled:f.length===0||Object.values(a).some(Boolean),type:"button",children:[d.jsx(ea,{size:12,strokeWidth:2.5}),e("system.diagnostics.checkAll")]})]}),d.jsx("div",{className:"system-panel-body",children:f.length===0?d.jsx("p",{className:"text-[var(--color-text-muted)] text-sm",children:e("system.diagnostics.empty")}):d.jsx("ul",{className:"system-diagnostics-list",children:f.map(b=>{const x=i[b.project],w=a[b.project],E=x?x.checks.filter(T=>T.status==="fail").length:0,v=x?x.checks.filter(T=>T.status==="warn").length:0,_=c===b.project,k=x!=null;return d.jsxs("li",{className:["system-diagnostics-item",_?"system-diagnostics-item-expanded":""].join(" "),children:[d.jsxs("div",{className:"system-diagnostics-row",children:[d.jsxs("button",{type:"button",onClick:()=>u(_?null:b.project),disabled:!k,className:"system-diagnostics-summary","aria-label":e(_?"system.diagnostics.collapseAria":"system.diagnostics.expandAria"),"aria-expanded":k?_:void 0,children:[d.jsxs("span",{className:"system-diagnostics-project-main",children:[k&&x.ok?d.jsx(d0,{size:16,className:"text-[var(--color-running)] shrink-0",strokeWidth:2.5}):k?d.jsx(jd,{size:16,className:"text-[var(--color-stuck)] shrink-0",strokeWidth:2.5}):d.jsx(d0,{size:16,className:"text-[var(--color-text-subtle)] shrink-0",strokeWidth:2.5}),k&&(_?d.jsx(so,{size:12}):d.jsx(lf,{size:12})),d.jsx("span",{className:"system-diagnostics-project-name",children:b.project})]}),k?x.ok?d.jsx("span",{className:"system-diagnostics-status system-diagnostics-status-ok",children:"OK"}):d.jsxs("span",{className:"system-diagnostics-status system-diagnostics-status-warn",children:[E," fail · ",v," warn"]}):d.jsx("span",{className:"system-diagnostics-never",children:e("system.diagnostics.never")})]}),d.jsxs("div",{className:"system-diagnostics-actions",children:[d.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:11},onClick:()=>{m(b.project,!1)},disabled:!!w,type:"button","aria-label":e("system.diagnostics.checkAria"),children:[w==="check"?d.jsx(lt,{size:11,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:11,strokeWidth:2.5}),e("system.diagnostics.check")]}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 10px",fontSize:11},onClick:()=>{m(b.project,!0)},disabled:!!w||k&&x.ok,type:"button","aria-label":e("system.diagnostics.fixAria"),title:k&&x.ok?e("system.diagnostics.noFixesNeeded"):e("system.diagnostics.fix.tip"),children:[w==="fix"?d.jsx(lt,{size:11,strokeWidth:3,className:"animate-spin"}):d.jsx(Uj,{size:11,strokeWidth:2.5}),e("system.diagnostics.fix")]})]})]}),_&&k&&d.jsxs("div",{className:"system-diagnostics-detail",children:[d.jsx("ul",{className:"system-diagnostics-checks",children:x.checks.map((T,A)=>d.jsx(Oie,{check:T},`${T.name}-${A}`))}),x.fixes.length>0&&d.jsxs("div",{className:"mt-3 bg-[var(--color-running-bg)] border-2 border-[var(--color-running)] rounded p-2",children:[d.jsx("div",{className:"text-xs font-bold text-[var(--color-running)] mb-1",children:e("system.diagnostics.fixed")}),d.jsx("ul",{className:"text-xs list-disc pl-4",children:x.fixes.map((T,A)=>d.jsx("li",{children:T},A))})]})]})]},b.project)})})})]})}function Oie({check:e}){const t=e.status==="pass"?d.jsx(d0,{size:12,className:"text-[var(--color-running)]",strokeWidth:2.5}):e.status==="fail"?d.jsx(jd,{size:12,className:"text-[var(--color-crashed)]",strokeWidth:2.5}):e.status==="warn"?d.jsx(jd,{size:12,className:"text-[var(--color-stuck)]",strokeWidth:2.5}):d.jsx("span",{className:"system-diagnostics-info-dot"});return d.jsxs("li",{className:"system-diagnostics-check-row",children:[d.jsx("span",{className:"system-diagnostics-check-icon",children:t}),d.jsx("span",{className:"system-diagnostics-check-name",children:e.name}),d.jsx("span",{className:"system-diagnostics-check-message",children:e.message})]})}function pc({value:e,onChange:t,options:n,ariaLabel:i,disabled:s,className:a="",placeholder:o="选择…",align:c="left"}){var v;const[u,f]=C.useState(!1),m=C.useRef(null),p=C.useRef(null),y=C.useRef(null),[b,x]=C.useState(null),w=()=>{var k;const _=(k=m.current)==null?void 0:k.getBoundingClientRect();_&&x({top:_.bottom+6,left:_.left,right:window.innerWidth-_.right,width:_.width})};C.useLayoutEffect(()=>{u&&w()},[u]),C.useEffect(()=>{if(!u)return;const _=()=>w(),k=T=>{var A,j;(A=m.current)!=null&&A.contains(T.target)||(j=p.current)!=null&&j.contains(T.target)||f(!1)};return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),document.addEventListener("mousedown",k),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_),document.removeEventListener("mousedown",k)}},[u]);const E=((v=n.find(_=>_.value===e))==null?void 0:v.label)??o;return d.jsxs("div",{className:`relative ${a}`,children:[d.jsxs("button",{ref:m,type:"button",disabled:s,"aria-label":i,"aria-expanded":u,className:"nb-btn w-full justify-between text-sm disabled:opacity-50",onClick:()=>f(_=>!_),children:[d.jsx("span",{className:"truncate",children:E}),d.jsx(so,{size:14,strokeWidth:2.5,className:["shrink-0 transition-transform",u?"rotate-180":""].join(" ")})]}),u&&b&&Ej.createPortal(d.jsx("div",{ref:p,style:{position:"fixed",top:b.top,left:c==="right"?void 0:b.left,right:c==="right"?b.right:void 0,minWidth:b.width},className:"z-[100] nb-card p-1 overflow-hidden bg-[var(--surface-menu)]",children:d.jsx("div",{ref:y,className:"max-h-[60vh] overflow-y-auto",children:n.map((_,k)=>d.jsx(Qc,{index:k,root:y,delay:.02,children:d.jsx("button",{type:"button",onClick:()=>{t(_.value),f(!1)},className:["dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2 whitespace-nowrap",_.value===e?"dimension-menu-item-active":""].join(" "),children:_.label})},_.value))})}),document.body)]})}const Lie=["convention","decision","gotcha","pattern","reference","note"],Iie=["local","local+external","external","none"];function dw(e){return e!=null&&typeof e=="object"?e:{}}function mc(e){return Array.isArray(e)?e:[]}function Pie(e){switch(e){case"none":return"none";case"agentmemory":case"custom":return"external";case"builtin":default:return"local"}}function uT(e){const t=dw(e);return{mode:typeof t.mode=="string"&&t.mode?t.mode:Pie(t.provider),externalUrl:typeof t.externalUrl=="string"?t.externalUrl:typeof t.url=="string"?t.url:"",modeOptions:mc(t.modeOptions).length>0?mc(t.modeOptions):Iie}}function zie(e){const t=dw(e),n=t.scope==="global"||t.scope==="project"||t.scope==="agent"?t.scope:null;return n?{scope:n,project:typeof t.project=="string"?t.project:void 0,agentId:typeof t.agentId=="string"?t.agentId:void 0,count:typeof t.count=="number"?t.count:0,updated:typeof t.updated=="string"?t.updated:""}:null}function Bie(e){const t=dw(e);if(typeof t.id!="string")return null;const n=t.scope==="global"||t.scope==="project"||t.scope==="agent"?t.scope:"global";return{id:t.id,title:typeof t.title=="string"?t.title:t.id,scope:n,category:typeof t.category=="string"?t.category:"note",tags:mc(t.tags),salience:typeof t.salience=="number"?t.salience:3,source:typeof t.source=="string"?t.source:"human",project:typeof t.project=="string"?t.project:void 0,agentId:typeof t.agentId=="string"?t.agentId:void 0,created:typeof t.created=="string"?t.created:"",updated:typeof t.updated=="string"?t.updated:"",body:typeof t.body=="string"?t.body:""}}function jo(e){return`${e.scope}:${e.project??e.agentId??""}`}function lp(e){return e.scope==="global"?`全局 (${e.count})`:e.scope==="project"?`项目:${e.project} (${e.count})`:`会话:${e.agentId} (${e.count})`}function Mo(e){const t={scope:e.scope};return e.project&&(t.project=e.project),e.agentId&&(t.agentId=e.agentId),t}async function sr(e,t){const n=await fetch(e,t);if(!n.ok){const i=await n.json().catch(()=>null);throw new Error((i==null?void 0:i.detail)||(i==null?void 0:i.title)||`HTTP ${n.status}`)}return await n.json()}const Uie=()=>({title:"",body:"",category:"note",tags:"",salience:3});function Fie(){var re,me,se;const e=Xe(),[t,n]=C.useState([]),[i,s]=C.useState(null),[a,o]=C.useState(!1),[c,u]=C.useState([]),[f,m]=C.useState(null),[p,y]=C.useState(!1),[b,x]=C.useState(""),[w,E]=C.useState(!0),[v,_]=C.useState([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(null),[I,P]=C.useState(null),[U,q]=C.useState(""),[V,O]=C.useState(""),R=C.useCallback(async()=>{try{const{scopes:Q}=await sr("/api/memory/scopes"),ye=mc(Q).map(zie).filter(_e=>_e!=null);n(ye),s(_e=>_e??ye[0]??null)}catch(Q){m(Q instanceof Error?Q.message:String(Q))}},[]),z=C.useCallback(async Q=>{try{const ye=new URLSearchParams(Mo(Q)).toString(),{data:_e}=await sr(`/api/memory/entries?${ye}`);u(mc(_e).map(Bie).filter(ze=>ze!=null))}catch(ye){m(ye instanceof Error?ye.message:String(ye))}},[]);C.useEffect(()=>{R(),sr("/api/system/memory").then(Q=>{const ye=uT(Q);P(ye),q(ye.mode),O(ye.externalUrl)}).catch(()=>{})},[R]),C.useEffect(()=>{i&&z(i),(i==null?void 0:i.scope)==="project"&&i.project?sr(`/api/memory/external?project=${encodeURIComponent(i.project)}`).then(Q=>D(Q)).catch(()=>D(null)):D(null)},[i,z]);const G=C.useCallback(async()=>{if(!b.trim()){_([]);return}y(!0),m(null);try{const Q=new URLSearchParams({q:b,limit:"20"});if(w)Q.set("all","1");else if(i)for(const[_e,ze]of Object.entries(Mo(i)))Q.set(_e,ze);const{results:ye}=await sr(`/api/memory/recall?${Q.toString()}`);_(mc(ye))}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}},[b,w,i]),Y=C.useCallback(async()=>{if(!(!i||!k)){y(!0),m(null);try{await sr("/api/memory/entries",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...Mo(i),id:k.id,title:k.title,body:k.body,category:k.category,tags:k.tags.split(",").map(Q=>Q.trim()).filter(Boolean),salience:k.salience})}),T(null),await Promise.all([z(i),R()])}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}}},[i,k,z,R]),K=C.useCallback(async Q=>{if(i){y(!0),m(null);try{const ye=new URLSearchParams(Mo(i)).toString();await sr(`/api/memory/entries/${encodeURIComponent(Q)}?${ye}`,{method:"DELETE"}),await Promise.all([z(i),R()])}catch(ye){m(ye instanceof Error?ye.message:String(ye))}finally{y(!1)}}},[i,z,R]),B=C.useCallback(async(Q,ye,_e)=>{if(i){y(!0),m(null);try{await sr("/api/memory/promote",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({from:Mo(i),id:Q.id,to:Mo(ye),move:_e})}),j(null),await Promise.all([z(i),R()])}catch(ze){m(ze instanceof Error?ze.message:String(ze))}finally{y(!1)}}},[i,z,R]),F=C.useCallback(async()=>{if(i){y(!0),m(null);try{const ye=(await sr("/api/memory/gc",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Mo(i))})).results[0];ye&&m(`收敛完成:清 tombstone ${ye.purged}、去重 ${ye.deduped}、剩余 ${ye.kept}`),await Promise.all([z(i),R()])}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}}},[i,z,R]),W=C.useCallback(async()=>{y(!0),m(null);try{const Q=uT(await sr("/api/system/memory",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({mode:U,externalUrl:V})}));P(Q),q(Q.mode),O(Q.externalUrl),m("模式已保存(重启 worker 生效)")}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}},[U,V]),$=I!=null&&(U!==I.mode||V!==I.externalUrl),ae=U==="external"||U==="local+external",be=C.useMemo(()=>A?t.filter(Q=>jo(Q)!==jo(i??{scope:""})):[],[A,t,i]),le=Array.isArray((re=M==null?void 0:M.profile)==null?void 0:re.topConcepts)?M.profile.topConcepts:[],Ne=Array.isArray((me=M==null?void 0:M.graph)==null?void 0:me.edges)?M.graph.edges.length:0;return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl text-[var(--color-text)]",children:e("nav.memory")}),d.jsx("span",{className:"text-xs text-[var(--color-text)] opacity-60",children:"本地记忆 v2 · markdown 真源"})]}),I&&d.jsxs("section",{className:"nb-card flex flex-wrap items-end gap-3",children:[d.jsxs("div",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:"记忆模式"}),d.jsx(pc,{value:U,onChange:q,ariaLabel:"记忆模式",options:I.modeOptions.map(Q=>({value:Q,label:Q}))})]}),ae&&d.jsxs("label",{className:"flex flex-col gap-1 text-sm flex-1 min-w-[220px]",children:[d.jsx("span",{className:"font-bold",children:"外部后端地址"}),d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-xs",value:V,onChange:Q=>O(Q.target.value),placeholder:"http://127.0.0.1:3113",spellCheck:!1,"aria-label":"外部后端地址"})]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:W,disabled:p||!$,"aria-label":"保存模式",children:"保存模式"})]}),(()=>{const Q=new Date(Date.now()-6048e5).toISOString(),ye=i?jo(i):"",_e=a?t:t.filter(fe=>fe.scope!=="project"||fe.updated>=Q||jo(fe)===ye),ze=t.length-_e.length;return d.jsxs("div",{className:"flex gap-2 flex-wrap items-center",children:[d.jsx("input",{value:b,onChange:fe=>x(fe.target.value),onKeyDown:fe=>fe.key==="Enter"&&G(),placeholder:"检索记忆…","aria-label":"检索记忆",className:"nb-input flex-1 min-w-[200px] font-[family-name:var(--font-mono)] text-sm"}),d.jsxs("label",{className:"flex items-center gap-1 text-sm font-semibold",children:[d.jsx("input",{type:"checkbox",checked:w,onChange:fe=>E(fe.target.checked),"aria-label":"全局检索"}),"全局"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:G,disabled:p,"aria-label":"检索",children:p?"…":"检索"}),d.jsx(pc,{className:"min-w-[180px]",value:ye,onChange:fe=>s(t.find(Se=>jo(Se)===fe)??null),ariaLabel:"选择作用域",placeholder:"选择作用域",options:_e.map(fe=>({value:jo(fe),label:lp(fe)}))}),(ze>0||a)&&d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>o(fe=>!fe),"aria-label":a?"收起更早项目":"显示更早项目",children:a?"收起更早":`含更早 (${ze})`}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>T(Uie()),disabled:!i,"aria-label":"新建记忆",children:"+ 新建"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-yellow",onClick:F,disabled:p||!i,"aria-label":"收敛去重",children:"收敛"})]})})(),f&&d.jsxs("div",{className:"text-sm text-[var(--color-text)] font-semibold nb-card py-2",children:["ℹ ",f]}),v.length>0&&d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:["检索结果(",v.length,")"]}),v.map(Q=>d.jsxs("div",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs opacity-60 font-[family-name:var(--font-mono)]",children:[d.jsx("span",{className:"nb-badge",children:Q.source==="external"?"🌐 外部":"📁 本地"}),d.jsx("span",{children:Q.source==="external"?Q.type??"":Q.scope==="project"?`项目:${Q.project}`:Q.scope}),Q.category&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"·"}),d.jsx("span",{children:Q.category})]})]}),d.jsx("div",{className:"font-bold text-sm mt-1",children:Q.title}),d.jsx("div",{className:"text-sm mt-1 whitespace-pre-wrap opacity-80",children:Q.snippet.slice(0,300)})]},Q.id))]}),M&&(le.length||Ne)?d.jsxs("section",{className:"nb-card flex flex-col gap-1",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:"🌐 外部智能(agentmemory)"}),le.length?d.jsxs("div",{className:"text-xs",children:[d.jsx("span",{className:"font-bold",children:"概念:"}),le.slice(0,8).map(Q=>d.jsx("span",{className:"nb-badge ml-1",children:Q.concept},Q.concept))]}):null,d.jsxs("div",{className:"text-xs opacity-70 font-[family-name:var(--font-mono)]",children:["知识图谱 ",Ne," 条边 · 观测 ",((se=M.profile)==null?void 0:se.totalObservations)??0]})]}):null,k&&d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-6 bg-black/30 overflow-hidden",onMouseDown:Q=>{Q.target===Q.currentTarget&&T(null)},children:d.jsxs("div",{className:"nb-card w-full max-w-2xl flex flex-col gap-2",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:k.id?"编辑记忆":"新建记忆"}),d.jsx("input",{className:"nb-input text-sm",value:k.title,onChange:Q=>T({...k,title:Q.target.value}),placeholder:"标题","aria-label":"标题"}),d.jsxs("div",{className:"flex gap-2 flex-wrap items-end",children:[d.jsx(pc,{className:"min-w-[140px]",value:k.category,onChange:Q=>T({...k,category:Q}),ariaLabel:"类别",options:Lie.map(Q=>({value:Q,label:Q}))}),d.jsx("input",{className:"nb-input flex-1 min-w-[160px] text-sm",value:k.tags,onChange:Q=>T({...k,tags:Q.target.value}),placeholder:"标签(逗号分隔)","aria-label":"标签"}),d.jsxs("label",{className:"flex items-center gap-1 text-sm",children:["显著度",d.jsx("input",{className:"nb-input w-16",type:"number",min:1,max:5,value:k.salience,onChange:Q=>T({...k,salience:Number(Q.target.value)}),"aria-label":"显著度"})]})]}),d.jsx("textarea",{className:"nb-input font-[family-name:var(--font-mono)] text-sm min-h-[120px]",value:k.body,onChange:Q=>T({...k,body:Q.target.value}),placeholder:"正文","aria-label":"正文"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:Y,disabled:p||!k.title.trim()||!k.body.trim(),"aria-label":"保存",children:"保存"}),d.jsx("button",{type:"button",className:"nb-btn",onClick:()=>T(null),"aria-label":"取消",children:"取消"})]})]})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:i?lp(i):"条目"}),c.length===0&&d.jsx("div",{className:"nb-card text-sm opacity-60",children:"(无记忆)"}),c.map(Q=>d.jsxs("div",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs opacity-60 font-[family-name:var(--font-mono)] flex-wrap",children:[d.jsx("span",{className:"nb-badge",children:Q.category}),d.jsxs("span",{children:["s",Q.salience]}),d.jsx("span",{children:"·"}),d.jsx("span",{children:Q.source}),Q.tags.map(ye=>d.jsxs("span",{children:["#",ye]},ye))]}),d.jsx("div",{className:"font-bold text-sm mt-1",children:Q.title}),d.jsx("div",{className:"text-sm mt-1 whitespace-pre-wrap opacity-80",children:Q.body.slice(0,400)}),d.jsxs("div",{className:"flex gap-2 mt-2",children:[d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue text-xs",onClick:()=>T({id:Q.id,title:Q.title,body:Q.body,category:Q.category,tags:Q.tags.join(", "),salience:Q.salience}),"aria-label":"编辑",children:"编辑"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-purple text-xs",onClick:()=>j(Q),"aria-label":"提升",children:"提升"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-danger text-xs",onClick:()=>K(Q.id),"aria-label":"删除",children:"删除"})]}),(A==null?void 0:A.id)===Q.id&&d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 border-t-[3px] border-[var(--color-text)] pt-2",children:[d.jsx("span",{className:"text-xs font-bold",children:"提升到:"}),be.map(ye=>d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint text-xs",onClick:()=>B(Q,ye,!1),"aria-label":`复制到${lp(ye)}`,children:lp(ye)},jo(ye))),be.length===0&&d.jsx("span",{className:"text-xs opacity-60",children:"(无其它作用域)"}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>j(null),"aria-label":"取消提升",children:"取消"})]})]},Q.id))]})]})}async function $ie(){return(await _t("/api/channels")).data??{console:{},adapters:[]}}async function qie(e){return(await Rm("/api/channels",e)).data}async function Hie(){return(await _t("/api/codex-proxy")).data}async function Vie(){return(await Ks("/api/codex-proxy/install")).data}async function Kie(e){const t=await fetch(`/api/codex-proxy?purgeAuth=${e?"1":"0"}`,{method:"DELETE",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return(await t.json()).data}async function Gie(){return(await Ks("/api/codex-proxy/auth/start")).data}async function Wie(){await Ks("/api/codex-proxy/auth/cancel")}function Yie(e){return _t(`/api/media-providers?capability=${encodeURIComponent(e)}`)}async function Xie(e){const t=await fetch("/api/media-providers",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return t.json()}function Qie(e){return Yv(`/api/media-providers/${encodeURIComponent(e)}`)}async function Zie(e,t){const n=await fetch(`/api/media-providers/default/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}const dv={image:"图片",video:"视频",music:"音乐",voice:"语音","3d":"3D",embedding:"向量(Embedding)",rerank:"重排(Rerank)"},Jie={image:["codex","openai","volcengine","minimax","tripo","agnes","bailian","openrouter"],video:["volcengine"],music:["minimax"],voice:["doubao"],"3d":["tripo"],embedding:["openai-compatible"],rerank:["openai-compatible"]},HL={codex:"",openai:"https://api.openai.com/v1",tripo:"https://openapi.tripo3d.ai",volcengine:"https://ark.cn-beijing.volces.com/api/v3",minimax:"https://api.minimaxi.com",doubao:"https://openspeech.bytedance.com",agnes:"https://apihub.agnes-ai.com",bailian:"https://dashscope.aliyuncs.com",openrouter:"https://openrouter.ai/api/v1","openai-compatible":""},ese=new Set(["codex"]);function tse({capability:e}){var E,v,_;const t=tn(),{alert:n,confirm:i}=Ln(),s=at({queryKey:["media-providers",e],queryFn:()=>Yie(e)}),[a,o]=C.useState(null),c=Jie[e]??[],u=((E=s.data)==null?void 0:E.providers)??[],f=(_=(v=s.data)==null?void 0:v.defaults)==null?void 0:_[e],m=zt({mutationFn:k=>Xie(k),onSuccess:()=>{o(null),t.invalidateQueries({queryKey:["media-providers",e]})},onError:k=>void n({title:"保存失败",body:k instanceof Error?k.message:String(k)})}),p=zt({mutationFn:k=>Qie(k),onSuccess:()=>void t.invalidateQueries({queryKey:["media-providers",e]}),onError:k=>void n({title:"删除失败",body:k instanceof Error?k.message:String(k)})}),y=zt({mutationFn:k=>Zie(e,k),onSuccess:()=>void t.invalidateQueries({queryKey:["media-providers",e]}),onError:k=>void n({title:"设默认失败",body:k instanceof Error?k.message:String(k)})}),b=(k,T)=>(f==null?void 0:f.providerId)===k&&(f==null?void 0:f.model)===T,x=()=>o({isNew:!0,entry:{id:"",name:"",capability:e,adapter:c[0]??"",baseUrl:c[0]?HL[c[0]]??"":"",apiKey:"",models:[]}}),w=k=>o({isNew:!1,entry:{id:k.id,name:k.name,capability:e,adapter:k.adapter,baseUrl:k.baseUrl,apiKey:"",models:k.models}});return d.jsxs("section",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[d.jsxs("div",{children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:[dv[e],"供应商"]}),d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:["增删该能力的第三方生成端点(adapter + Base URL + key + models)。**点模型标签设为该能力默认**;✓ = 当前默认。",f?d.jsxs(d.Fragment,{children:[" ","当前默认:",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:f.providerId}),f.model?d.jsxs(d.Fragment,{children:[" · ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:f.model})]}):null]}):" 当前默认:未设置"]})]}),d.jsxs("button",{className:"nb-btn nb-btn-primary shrink-0",style:{padding:"8px 16px"},type:"button",onClick:x,"aria-label":`添加${dv[e]}供应商`,children:[d.jsx(Gn,{size:14,strokeWidth:3})," 添加供应商"]})]}),d.jsxs("div",{className:"flex flex-col gap-2 mt-4",children:[s.isLoading&&d.jsxs("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 加载中…"]}),!s.isLoading&&u.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"(无供应商)"}),u.map(k=>d.jsxs("div",{className:"rounded-lg px-3 py-2 border-2 border-[var(--color-text)]",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:k.id}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm",children:[" · ",k.name]}),d.jsx("span",{className:"ml-2 text-[10px] font-bold px-2 py-0.5 rounded-md border-2 border-[var(--color-text)] bg-[var(--color-accent-yellow)]",children:k.adapter}),d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:[k.baseUrl," · key ",k.keyMasked||"未设置"]})]}),d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>w(k),"aria-label":`编辑 ${k.id}`,children:d.jsx(Vv,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:async()=>{await i({title:"删除供应商",body:`删除 ${k.id}?`,danger:!0})&&p.mutate(k.id)},"aria-label":`删除 ${k.id}`,children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),k.models.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:k.models.map(T=>{const A=b(k.id,T);return d.jsxs("button",{type:"button",onClick:()=>y.mutate({providerId:k.id,model:T}),disabled:y.isPending,"aria-pressed":A,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",A?"nb-btn-mint":""].join(" "),title:A?"当前默认":"设为该能力默认",children:[T,A?" ✓":""]},T)})})]},k.id))]}),a&&d.jsx(fw,{onClose:()=>o(null),children:d.jsx(ise,{state:a,adapters:c,onChange:k=>o({...a,entry:k}),onCancel:()=>o(null),onSave:k=>m.mutate(k),saving:m.isPending})})]})}function nse(e,t){const n=[...e];for(const i of t.split(/[,,\n\r]+/)){const s=i.trim();s&&!n.includes(s)&&n.push(s)}return n}function ise({state:e,adapters:t,onChange:n,onCancel:i,onSave:s,saving:a}){const o=e.entry,[c,u]=C.useState(""),f=b=>n({...o,...b}),m=ese.has(o.adapter),p=/^[a-zA-Z0-9_-]+$/.test(o.id)&&!!o.name.trim()&&!!o.adapter.trim()&&(m||!!o.baseUrl.trim()),y=b=>{f({adapter:b,baseUrl:HL[b]??""})};return d.jsxs("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,640px)] max-h-[88vh] overflow-y-auto",children:[d.jsxs("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:[e.isNew?"新增供应商":`编辑 ${o.id}`,d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-normal",children:[" (",dv[o.capability],")"]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["id(英数 _ -)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)]",value:o.id,disabled:!e.isNew,onChange:b=>f({id:b.target.value}),placeholder:"如 my-tripo",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["名称",d.jsx("input",{className:"nb-input",value:o.name,onChange:b=>f({name:b.target.value}),placeholder:"显示名"})]})]}),d.jsxs("div",{className:"flex flex-col gap-1 text-sm font-bold",children:["adapter",d.jsx(pc,{value:o.adapter,onChange:y,ariaLabel:"adapter",options:t.map(b=>({value:b,label:b}))})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Base URL",m&&"(订阅无需,可留空)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:o.baseUrl,onChange:b=>f({baseUrl:b.target.value}),placeholder:m?"订阅走本地凭据,无需填":"https://api.example.com",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["API Key",m?"(订阅无需)":!e.isNew&&"(留空=保留)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:o.apiKey??"",onChange:b=>f({apiKey:b.target.value}),placeholder:m?"订阅无需":e.isNew?"sk-...":"留空保留",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{htmlFor:"provider-models",className:"text-sm font-bold",children:"Models"}),d.jsx(VL,{models:o.models,draft:c,onModelsChange:b=>f({models:b}),onDraftChange:u}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"输入模型名,按 Enter 或逗号添加"})]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"8px 16px"},type:"button",onClick:i,children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"8px 16px"},type:"button",disabled:!p||a,onClick:()=>s({...o,models:nse(o.models,c)}),children:[a?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]})]})}const dT=[{key:"memory",labelKey:"plugins.tab.memory"},{key:"channel",labelKey:"plugins.tab.channel"},{key:"model",labelKey:"plugins.tab.model"},{key:"tool",labelKey:"plugins.tab.tool"}];function sse(){const e=Xe(),[t,n]=C.useState("memory");return d.jsxs("div",{className:"flex flex-col gap-6 w-full",children:[d.jsxs("header",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("plugins.h1")}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:e("plugins.desc")})]}),d.jsx(Zc,{ariaLabel:e("plugins.h1"),className:"",value:t,onChange:n,options:dT.map(i=>({value:i.key,label:e(i.labelKey)}))}),d.jsx("div",{role:"tabpanel",children:t==="memory"?d.jsx(ase,{}):t==="channel"?d.jsx(hse,{}):t==="model"?d.jsx(lse,{}):d.jsx(rse,{label:e(dT.find(i=>i.key===t).labelKey)})})]})}function rse({label:e}){const t=Xe();return d.jsx("section",{className:"nb-card",children:d.jsxs("p",{className:"text-[var(--color-text-muted)] text-sm",children:[e," — ",t("plugins.comingSoon")]})})}function ase(){var x,w,E;const e=Xe(),t=tn(),{alert:n}=Ln(),i=at({queryKey:["system-memory"],queryFn:Y6}),[s,a]=C.useState(null),[o,c]=C.useState(null);C.useEffect(()=>{i.data&&s===null&&(a(i.data.provider),c(i.data.url))},[i.data,s]);const u=s??((x=i.data)==null?void 0:x.provider)??"agentmemory",f=o??((w=i.data)==null?void 0:w.url)??"",m=i.data!=null&&(u!==i.data.provider||u==="custom"&&f!==i.data.url),p=v=>{const _=`system.memory.opt.${v}`;return e(_)},y=zt({mutationFn:()=>X6(u,u==="custom"?f:""),onSuccess:()=>{t.invalidateQueries({queryKey:["system-memory"]}),t.invalidateQueries({queryKey:["system-env"]})},onError:v=>{n({title:e("system.memory.error"),body:v instanceof Error?v.message:String(v)})}}),b=((E=i.data)==null?void 0:E.options)??["none","builtin","agentmemory","custom"];return d.jsxs("section",{className:"nb-card",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-1",children:e("system.memory.title")}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mb-3",children:e("system.memory.desc")}),d.jsxs("div",{className:"flex flex-col gap-3 max-w-md",children:[d.jsxs("div",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:e("system.memory.provider")}),d.jsx(pc,{value:u,onChange:a,ariaLabel:e("system.memory.provider"),options:b.map(v=>({value:v,label:p(v)}))})]}),u==="custom"&&d.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:e("system.memory.url")}),d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-xs",type:"text",value:f,onChange:v=>c(v.target.value),placeholder:e("system.memory.url.placeholder"),spellCheck:!1,"aria-label":e("system.memory.url")})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 12px",fontSize:12},onClick:()=>y.mutate(),disabled:!m||y.isPending,type:"button","aria-label":e("system.memory.save.aria"),children:[y.isPending?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:12,strokeWidth:3}),y.isSuccess&&!m?e("system.memory.saved"):e("system.memory.save")]})})]})]})}const ose=[{key:"llm",label:"sps agent"},{key:"image",label:"图片"},{key:"video",label:"视频"},{key:"music",label:"音乐"},{key:"voice",label:"语音"},{key:"3d",label:"3D"},{key:"embedding",label:"Embedding"},{key:"rerank",label:"Rerank"}];function lse(){const[e,t]=C.useState("llm");return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("div",{className:"flex flex-wrap gap-2",role:"tablist","aria-label":"模型/资源供应商",children:ose.map(n=>{const i=e===n.key;return d.jsx("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>t(n.key),className:["nb-btn",i?"nb-btn-primary":""].join(" "),style:{padding:"6px 14px"},children:n.label},n.key)})}),e==="llm"?d.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base border-b-2 border-[var(--color-text)] pb-1",children:["Anthropic 兼容 ",d.jsx("span",{className:"text-xs font-normal text-[var(--color-text-muted)]",children:"· 含 Claude 订阅"})]}),d.jsx(fT,{only:"anthropic"})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base border-b-2 border-[var(--color-text)] pb-1",children:["OpenAI 兼容 ",d.jsx("span",{className:"text-xs font-normal text-[var(--color-text-muted)]",children:"· 含 codex 订阅"})]}),d.jsx(fT,{only:"openai"})]})]}):d.jsx(tse,{capability:e})]})}function fT({only:e}={}){var _,k,T;const t=tn(),{alert:n,confirm:i}=Ln(),s=at({queryKey:["providers"],queryFn:x1}),o=(_=at({queryKey:["system-agents"],queryFn:Xv}).data)==null?void 0:_.agents,[c,u]=C.useState(null),f=zt({mutationFn:A=>IW(c.kind,A),onSuccess:()=>{u(null),t.invalidateQueries({queryKey:["providers"]})},onError:A=>void n({title:"保存失败",body:A instanceof Error?A.message:String(A)})}),m=zt({mutationFn:A=>PW(A.kind,A.id),onSuccess:()=>void t.invalidateQueries({queryKey:["providers"]}),onError:A=>void n({title:"删除失败",body:A instanceof Error?A.message:String(A)})}),p=zt({mutationFn:A=>Q6(A),onSuccess:()=>void t.invalidateQueries({queryKey:["system-agents"]}),onError:A=>void n({title:"设默认失败",body:A instanceof Error?A.message:String(A)})}),y=(A,j,M)=>{if(!o)return!1;const D=A==="anthropic"?o.worker:o.reviewer;return(D.providerId||"official")===j&&D.model===M},b=(A,j,M)=>{if(!o)return;let D;if(A==="anthropic"){const I={...o.worker,model:M};j==="official"?delete I.providerId:I.providerId=j,D={...o,worker:I}}else D={...o,reviewer:{...o.reviewer,providerId:j,model:M}};p.mutate(D)},x=[{kind:"anthropic",title:"Anthropic 兼容(worker / claude)",items:((k=s.data)==null?void 0:k.anthropic)??[]},{kind:"openai",title:"OpenAI 兼容(reviewer / openai agent)",items:((T=s.data)==null?void 0:T.openai)??[]}],w=e?x.filter(A=>A.kind===e):x,E=A=>u({kind:A,isNew:!0,entry:{id:"",name:"",baseUrl:"",apiKey:"",models:[]}}),v=(A,j)=>u({kind:A,isNew:!1,entry:{id:j.id,name:j.name,baseUrl:j.baseUrl,apiKey:"",models:j.models}});return d.jsxs("section",{className:"nb-card",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-1",children:"模型 API 端点"}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mb-4",children:"本地官方订阅(已登录验证)自动置顶,不可编辑;下方可增删第三方兼容端点。**点模型标签设为默认**(anthropic→worker / openai→监工);✓ = 当前默认。"}),d.jsx("div",{className:["grid grid-cols-1 gap-5",e?"":"lg:grid-cols-2"].join(" "),children:w.map(A=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"font-bold text-sm",children:A.title}),d.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:12},type:"button",onClick:()=>E(A.kind),"aria-label":`添加 ${A.title} 端点`,children:[d.jsx(Gn,{size:12,strokeWidth:3})," 添加"]})]}),A.items.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"(无端点)"}),A.items.map(j=>j.id==="codex-proxy"?d.jsx(use,{isDefault:M=>y(A.kind,j.id,M),pickDefault:M=>b(A.kind,j.id,M),setDefaultPending:p.isPending},j.id):d.jsxs("div",{className:["rounded-lg px-3 py-2 border-2",(j.builtin,"border-[var(--color-text)]")].join(" "),children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:j.id}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm",children:[" · ",j.name]}),j.builtin?d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:["本地订阅",j.detail?` · ${j.detail}`:""," · 已验证可用"]}):d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:[j.baseUrl," · key ",j.hasKey?j.apiKey:"未设置"]})]}),j.builtin?d.jsx("span",{className:"shrink-0 text-[10px] font-bold px-2 py-0.5 rounded-md border-2 border-[var(--color-text)] bg-[var(--color-accent-yellow)]",children:"内置"}):d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>v(A.kind,j),"aria-label":`编辑 ${j.id}`,children:d.jsx(Vv,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:async()=>{await i({title:"删除端点",body:`删除 ${j.id}?`,danger:!0})&&m.mutate({kind:A.kind,id:j.id})},"aria-label":`删除 ${j.id}`,children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),j.models.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:j.models.map(M=>{const D=y(A.kind,j.id,M);return d.jsxs("button",{type:"button",onClick:()=>b(A.kind,j.id,M),disabled:p.isPending,"aria-pressed":D,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",D?"nb-btn-mint":""].join(" "),title:D?"当前默认":"设为默认",children:[M,D?" ✓":""]},M)})})]},j.id))]},A.kind))}),c&&d.jsx(fw,{onClose:()=>u(null),children:d.jsx(cse,{state:c,onChange:A=>u({...c,entry:A}),onCancel:()=>u(null),onSave:A=>f.mutate(A),saving:f.isPending})})]})}function fv(e,t){const n=[...e];for(const i of t.split(/[,,\n\r]+/)){const s=i.trim();s&&!n.includes(s)&&n.push(s)}return n}function VL({models:e,draft:t,onModelsChange:n,onDraftChange:i}){const s=a=>{n(fv(e,a)),i("")};return d.jsxs("div",{className:"nb-input min-h-[46px] w-full flex flex-wrap gap-1.5 items-center px-2.5 py-2",children:[e.map(a=>d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-[var(--color-border-light)] bg-[var(--surface-control)] px-2 py-1 text-xs font-[family-name:var(--font-mono)]",children:[d.jsx("span",{className:"max-w-[480px] truncate",children:a}),d.jsx("button",{type:"button",className:"shrink-0 text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>n(e.filter(o=>o!==a)),"aria-label":`删除模型 ${a}`,children:d.jsx(vn,{size:12,strokeWidth:2.5})})]},a)),d.jsx("input",{id:"provider-models",className:"min-w-[180px] flex-1 bg-transparent px-1 py-0.5 text-sm outline-none font-[family-name:var(--font-mono)]",value:t,onChange:a=>{const o=a.target.value,c=o.split(/[,,\n\r]/);if(c.length===1){i(o);return}const u=c.pop()??"";n(fv(e,c.join(","))),i(u)},onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),s(t)):a.key==="Backspace"&&!t&&e.length>0&&n(e.slice(0,-1))},placeholder:e.length>0?"继续添加模型":"输入模型名后按 Enter","aria-label":"Models",spellCheck:!1})]})}function cse({state:e,onChange:t,onCancel:n,onSave:i,saving:s}){const a=e.entry,[o,c]=C.useState(""),u=m=>t({...a,...m}),f=/^[a-zA-Z0-9_-]+$/.test(a.id)&&a.name.trim()&&a.baseUrl.trim();return d.jsxs("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,640px)] max-h-[88vh] overflow-y-auto",children:[d.jsxs("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:[e.isNew?"新增端点":`编辑 ${a.id}`,d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-normal",children:["(",e.kind,")"]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["id(英数 _ -)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)]",value:a.id,disabled:!e.isNew,onChange:m=>u({id:m.target.value}),placeholder:"如 my-openai",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["名称",d.jsx("input",{className:"nb-input",value:a.name,onChange:m=>u({name:m.target.value}),placeholder:"显示名"})]})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Base URL",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:a.baseUrl,onChange:m=>u({baseUrl:m.target.value}),placeholder:"https://api.example.com/v1",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["API Key",!e.isNew&&"(留空=保留)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:a.apiKey??"",onChange:m=>u({apiKey:m.target.value}),placeholder:e.isNew?"sk-...":"••••(留空不改)",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{htmlFor:"provider-models",className:"text-sm font-bold",children:"Models"}),d.jsx(VL,{models:a.models,draft:o,onModelsChange:m=>u({models:m}),onDraftChange:c}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"输入模型名,按 Enter 或逗号添加"})]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"8px 16px"},type:"button",onClick:n,children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"8px 16px"},type:"button",disabled:!f||s,onClick:()=>i({...a,models:fv(a.models,o)}),children:[s?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]})]})}function use({isDefault:e,pickDefault:t,setDefaultPending:n}){const i=tn(),{alert:s,confirm:a}=Ln(),[o,c]=C.useState(!1),[u,f]=C.useState(null),[m,p]=C.useState(!1),[y,b]=C.useState(!1),[x,w]=C.useState(!1),E=at({queryKey:["codex-proxy"],queryFn:Hie,refetchInterval:o?3e3:!1}),v=E.data;C.useEffect(()=>{o&&(v!=null&&v.authed)?(c(!1),f(null),i.invalidateQueries({queryKey:["codex-proxy"]})):o&&(v!=null&&v.authError)&&(c(!1),f(null),s({title:"授权失败",body:v.authError}))},[o,v==null?void 0:v.authed,v==null?void 0:v.authError,i,s]);const _=zt({mutationFn:Vie,onSuccess:I=>{i.invalidateQueries({queryKey:["codex-proxy"]}),i.invalidateQueries({queryKey:["providers"]}),I.ok||s({title:"安装失败",body:(I.output||"未知错误").slice(-600)})},onError:I=>void s({title:"安装失败",body:I instanceof Error?I.message:String(I)})}),k=zt({mutationFn:I=>Kie(I),onSuccess:I=>{p(!1),b(!1),i.invalidateQueries({queryKey:["codex-proxy"]}),i.invalidateQueries({queryKey:["providers"]}),i.invalidateQueries({queryKey:["system-agents"]}),I.ok||s({title:"卸载未完成",body:I.note??"删除失败(可能需 sudo)"})},onError:I=>void s({title:"卸载失败",body:I instanceof Error?I.message:String(I)})}),T=async()=>{await a({title:"安装 claude-code-proxy",body:"将运行官方安装脚本(curl … install.sh | bash),下载预编译二进制到 ~/.local/bin。继续?"})&&_.mutate()},A=async()=>{c(!0),f(null);try{const I=await Gie();f(I)}catch(I){c(!1),s({title:"订阅失败",body:I instanceof Error?I.message:String(I)})}},j=()=>{Wie(),c(!1),f(null)},M=_.isPending||(v==null?void 0:v.installing),D=x&&(v!=null&&v.models.all.length)?v.models.all:(v==null?void 0:v.models.curated)??[];return d.jsxs("div",{className:"rounded-lg px-3 py-2 border-2 border-[var(--color-text)]",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:"codex-proxy"}),d.jsx("span",{className:"text-[var(--color-text-muted)] text-sm",children:" · ChatGPT 订阅"}),d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:v?v.binInstalled?v.authed?`已订阅${v.account?` · ${v.account.slice(0,8)}…`:""} · worker 出 GPT`:v.nativeCodex.available?"已检测到本机 ChatGPT 订阅 · proxy 待独立授权":"已安装 · 未检测到 ChatGPT 登录":"未安装 claude-code-proxy":"加载中…"})]}),(v==null?void 0:v.binInstalled)&&d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>void E.refetch(),disabled:E.isFetching,"aria-label":"重新获取模型",title:"重新获取模型(codex-proxy 模型可能过期)",children:E.isFetching?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:()=>p(!0),"aria-label":"卸载 codex-proxy",children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),d.jsx("div",{className:"mt-2",children:v?v.binInstalled?v.authed?d.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[D.map(I=>{const P=e(I);return d.jsxs("button",{type:"button",onClick:()=>t(I),disabled:n,"aria-pressed":P,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",P?"nb-btn-mint":""].join(" "),title:P?"当前默认":"设为 worker 默认",children:[I,P?" ✓":""]},I)}),v.models.all.length>v.models.curated.length&&d.jsx("button",{type:"button",className:"text-xs text-[var(--color-text-muted)] underline",onClick:()=>w(I=>!I),children:x?"收起":`显示全部(${v.models.all.length})`})]}):d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 12px",fontSize:12},type:"button",onClick:A,children:[d.jsx(_U,{size:12,strokeWidth:3})," ",v.nativeCodex.available?"授权 proxy":"授权 ChatGPT"]}):d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 12px",fontSize:12},type:"button",disabled:!!M,onClick:T,children:[M?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Tj,{size:12,strokeWidth:3}),M?" 安装中…":" 安装插件"]}):d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin text-[var(--color-text-muted)]"})}),o&&d.jsxs(hT,{onClose:j,children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"授权 codex-proxy(浏览器)"}),(v==null?void 0:v.nativeCodex.available)&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"已检测到本机 Codex CLI 的 ChatGPT 登录。codex-proxy 使用独立凭据,不读取或修改 ~/.codex;为避免令牌轮换冲突,需要为 proxy 单独授权一次。"}),u!=null&&u.authorizationUrl?d.jsxs("div",{className:"flex flex-col gap-3 text-sm",children:[d.jsxs("div",{children:["① 打开"," ",d.jsxs("a",{href:u.authorizationUrl,target:"_blank",rel:"noreferrer",className:"font-bold underline inline-flex items-center gap-1",children:["ChatGPT 授权页面 ",d.jsx(iU,{size:12,strokeWidth:3})]})]}),d.jsx("div",{children:"② 在浏览器完成授权,成功后会自动返回本机回调页面"}),d.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 等待授权…(完成后自动刷新)"]})]}):d.jsxs("div",{className:"flex flex-col gap-2 text-sm text-[var(--color-text-muted)]",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 正在生成浏览器授权地址…"]}),d.jsxs("div",{children:["若长时间无响应,可在终端运行 ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:"sps codex-proxy auth"}),"。"]})]}),d.jsx("div",{className:"flex justify-end pt-1",children:d.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},type:"button",onClick:j,children:"取消"})})]}),m&&d.jsxs(hT,{onClose:()=>p(!1),children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"卸载 claude-code-proxy"}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"停止 proxy 并删除二进制。默认保留授权(重装免再授权)。"}),d.jsxs("label",{className:"flex items-center gap-2 text-sm font-bold",children:[d.jsx("input",{type:"checkbox",checked:y,onChange:I=>b(I.target.checked)}),"同时清除 proxy 独立授权(macOS 钥匙串或配置目录)"]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},type:"button",onClick:()=>p(!1),children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-danger",style:{padding:"6px 14px"},type:"button",disabled:k.isPending,onClick:()=>k.mutate(y),children:[k.isPending?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(qi,{size:14,strokeWidth:3})," 卸载"]})]})]})]})}function fw({children:e,onClose:t}){return Ej.createPortal(d.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 p-4",onClick:t,children:d.jsx("div",{onClick:n=>n.stopPropagation(),children:e})}),document.body)}function hT({children:e,onClose:t}){return d.jsx(fw,{onClose:t,children:d.jsx("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,520px)]",children:e})})}const dse=["telegram","dingtalk","matrix","slack","discord","feishu"],Fd={telegram:"Telegram",dingtalk:"钉钉 (Stream)",matrix:"Matrix",slack:"Slack",discord:"Discord",feishu:"飞书 / Lark"},fse={telegram:[{key:"token",label:"Bot Token(@BotFather)",type:"password",placeholder:"123456:ABC-..."},{key:"allowedChatIds",label:"允许的 Chat ID(白名单,空=全放)",type:"list",placeholder:"逗号/换行分隔"}],dingtalk:[{key:"clientId",label:"Client ID(AppKey)",type:"text"},{key:"clientSecret",label:"Client Secret(AppSecret)",type:"password"},{key:"allowedConversations",label:"允许的会话 ID(白名单,空=全放)",type:"list"}],matrix:[{key:"homeserver",label:"Homeserver URL",type:"text",placeholder:"https://matrix.org"},{key:"accessToken",label:"Access Token",type:"password"},{key:"allowedRooms",label:"允许的 Room ID(白名单,空=全放)",type:"list"}],slack:[{key:"appToken",label:"App Token(xapp-,Socket Mode)",type:"password",placeholder:"xapp-..."},{key:"botToken",label:"Bot Token(xoxb-)",type:"password",placeholder:"xoxb-..."},{key:"allowedChannels",label:"允许的 Channel(白名单,空=全放)",type:"list"}],discord:[{key:"token",label:"Bot Token",type:"password"},{key:"allowedChannels",label:"允许的 Channel ID(白名单,空=全放)",type:"list"}],feishu:[{key:"appId",label:"App ID",type:"text"},{key:"appSecret",label:"App Secret",type:"password"},{key:"verificationToken",label:"Verification Token",type:"text"},{key:"encryptKey",label:"Encrypt Key(设了则事件 AES 解密)",type:"password"},{key:"port",label:"本机监听端口(默认 9800)",type:"number",placeholder:"9800"},{key:"path",label:"监听路径(默认 /feishu)",type:"text",placeholder:"/feishu"},{key:"allowedChats",label:"允许的 chat_id(白名单,空=全放)",type:"list"}]};function hse(){var x,w,E;const e=tn(),{alert:t}=Ln(),n=at({queryKey:["channels"],queryFn:$ie}),[i,s]=C.useState(null),[a,o]=C.useState({type:"console"});C.useEffect(()=>{n.data&&!i&&s({console:n.data.console??{},adapters:n.data.adapters??[]})},[n.data,i]);const c=zt({mutationFn:()=>qie(i),onSuccess:v=>{s({console:v.console??{},adapters:v.adapters??[]}),e.invalidateQueries({queryKey:["channels"]})},onError:v=>void t({title:"保存失败",body:v instanceof Error?v.message:String(v)})});if(!i)return d.jsx("section",{className:"nb-card",children:d.jsxs("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 加载频道配置…"]})});const u=i.adapters??[],f=JSON.stringify(i)!==JSON.stringify({console:((x=n.data)==null?void 0:x.console)??{},adapters:((w=n.data)==null?void 0:w.adapters)??[]}),m=v=>{const _=[...u,{kind:v,enabled:!0}];s({...i,adapters:_}),o({type:"adapter",index:_.length-1})},p=v=>{const _=u.filter((k,T)=>T!==v);s({...i,adapters:_}),o({type:"console"})},y=(v,_)=>{const k=u.map((T,A)=>A===v?{...T,..._}:T);s({...i,adapters:k})},b=v=>s({...i,console:{...i.console,...v}});return d.jsxs("section",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:"频道(IM 网关)"}),d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:["接入 Telegram / 钉钉 / 飞书 / Slack / Discord / Matrix。左侧选频道,右侧改设置。保存后 ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:"sps im"})," 重启生效。"]})]}),d.jsxs("button",{className:"nb-btn nb-btn-primary shrink-0",style:{padding:"8px 16px"},type:"button",disabled:!f||c.isPending,onClick:()=>c.mutate(),"aria-label":"保存频道配置",children:[c.isPending?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[220px_1fr] gap-5 mt-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] p-2 flex flex-col gap-1",children:[d.jsx(pT,{label:"console 桥接",sub:((E=i.console)==null?void 0:E.url)||"未配置",active:a.type==="console",onClick:()=>o({type:"console"})}),d.jsx("div",{className:"h-px bg-[var(--color-text)] opacity-15 my-0.5"}),u.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] px-2 py-1",children:"(无频道)"}),u.map((v,_)=>d.jsx(pT,{label:Fd[v.kind]??v.kind,sub:v.enabled===!1?"已停用":"启用",active:a.type==="adapter"&&a.index===_,onClick:()=>o({type:"adapter",index:_})},_))]}),d.jsx(pse,{onAdd:m})]}),d.jsx("div",{className:"border-2 bg-surface-input border-[var(--color-text)] rounded-xl p-4 bg-[var(--color-bg-cream)]",children:(()=>{if(a.type!=="adapter")return d.jsx(mT,{console:i.console??{},onChange:b});const v=u[a.index];if(!v)return d.jsx(mT,{console:i.console??{},onChange:b});const _=a.index;return d.jsx(mse,{adapter:v,onChange:k=>y(_,k),onRemove:()=>p(_)})})()})]})]})}function pse({onAdd:e}){const[t,n]=C.useState(!1),i=C.useRef(null),s=C.useRef(null);return C.useEffect(()=>{const a=o=>{var c;(c=i.current)!=null&&c.contains(o.target)||n(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]),d.jsxs("div",{className:"relative",ref:i,children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary w-full justify-center",onClick:()=>n(a=>!a),"aria-expanded":t,"aria-label":"添加频道",children:[d.jsx(Gn,{size:13,strokeWidth:3})," 添加频道",d.jsx(so,{size:13,strokeWidth:2.5,className:["transition-transform",t?"rotate-180":""].join(" ")})]}),t&&d.jsx("div",{className:"absolute z-30 mt-2 left-0 min-w-full nb-card p-1 overflow-hidden bg-[var(--surface-menu)]",children:d.jsx("div",{ref:s,className:"max-h-[50vh] overflow-y-auto",children:dse.map((a,o)=>d.jsx(Qc,{index:o,root:s,delay:.02,children:d.jsxs("button",{type:"button",className:"dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2",onClick:()=>{e(a),n(!1)},"aria-label":`添加 ${Fd[a]} 频道`,children:[d.jsx(Gn,{size:12,strokeWidth:3,className:"shrink-0"})," ",Fd[a]]})},a))})})]})}function pT({label:e,sub:t,active:n,onClick:i}){return d.jsxs("button",{type:"button",onClick:i,"aria-pressed":n,className:["dimension-menu-item flex-col items-start gap-0.5 px-3 py-2 text-left",n?"dimension-menu-item-active":""].join(" "),children:[d.jsx("div",{className:"font-bold text-sm",children:e}),d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] truncate w-full font-[family-name:var(--font-mono)]",children:t})]})}function mT({console:e,onChange:t}){return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"console 桥接"}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"IM 纯文本消息桥接到项目 agent 对话。设了 URL 才启用桥接;token 为 console 鉴权令牌。"})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Console URL",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:e.url??"",onChange:n=>t({url:n.target.value}),placeholder:"http://localhost:4321",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Console Token(SPS_CONSOLE_TOKEN)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:e.token??"",onChange:n=>t({token:n.target.value}),placeholder:"鉴权令牌(可空)",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1 text-sm font-bold",children:["对话后端",d.jsx(pc,{value:e.agentKind??"claude",onChange:n=>t({agentKind:n}),ariaLabel:"对话后端",options:[{value:"claude",label:"claude"},{value:"openai",label:"openai"}]})]})]})}function mse({adapter:e,onChange:t,onRemove:n}){const{confirm:i}=Ln(),s=fse[e.kind]??[],a=e.enabled!==!1;return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-start justify-between gap-2",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:Fd[e.kind]??e.kind}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-[family-name:var(--font-mono)]",children:[" · ",e.kind]})]}),d.jsxs("button",{className:"nb-btn nb-btn-danger shrink-0",style:{padding:"4px 10px",fontSize:12},type:"button",onClick:async()=>{await i({title:"删除频道",body:`删除 ${Fd[e.kind]??e.kind} 频道?`,danger:!0})&&n()},"aria-label":"删除频道",children:[d.jsx(qi,{size:12,strokeWidth:3})," 删除"]})]}),d.jsxs("label",{className:"flex items-center gap-2 text-sm font-bold",children:[d.jsx("input",{type:"checkbox",checked:a,onChange:o=>t({enabled:o.target.checked})}),"启用此频道"]}),s.map(o=>d.jsx(gse,{spec:o,value:e[o.key],onChange:c=>t({[o.key]:c})},o.key))]})}function gse({spec:e,value:t,onChange:n}){if(e.type==="list"){const i=Array.isArray(t)?t.map(String):[];return d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:[e.label,d.jsx("textarea",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",rows:2,value:i.join(", "),onChange:s=>{const a=s.target.value.split(/[,\n]/).map(o=>o.trim()).filter(Boolean);n(a.length?a:void 0)},placeholder:e.placeholder,spellCheck:!1})]})}return d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:[e.label,d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:e.type==="password"?"password":"text",value:t==null?"":String(t),onChange:i=>{const s=i.target.value;e.type==="number"?n(s.trim()===""?void 0:Number(s)):n(s===""?void 0:s)},placeholder:e.placeholder,spellCheck:!1})]})}function Wn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Wn(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var yse={value:()=>{}};function ag(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Pp(n)}function Pp(e){this._=e}function bse(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");if(s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Pp.prototype=ag.prototype={constructor:Pp,on:function(e,t){var n=this._,i=bse(e+"",n),s,a=-1,o=i.length;if(arguments.length<2){for(;++a<o;)if((s=(e=i[a]).type)&&(s=xse(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(s=(e=i[a]).type)n[s]=gT(n[s],e.name,t);else if(t==null)for(s in n)n[s]=gT(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Pp(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),i=0,s,a;i<s;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],i=0,s=a.length;i<s;++i)a[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],s=0,a=i.length;s<a;++s)i[s].value.apply(t,n)}};function xse(e,t){for(var n=0,i=e.length,s;n<i;++n)if((s=e[n]).name===t)return s.value}function gT(e,t,n){for(var i=0,s=e.length;i<s;++i)if(e[i].name===t){e[i]=yse,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var hv="http://www.w3.org/1999/xhtml";const yT={svg:"http://www.w3.org/2000/svg",xhtml:hv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function og(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),yT.hasOwnProperty(t)?{space:yT[t],local:e}:e}function vse(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hv&&t.documentElement.namespaceURI===hv?t.createElement(e):t.createElementNS(n,e)}}function wse(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function KL(e){var t=og(e);return(t.local?wse:vse)(t)}function Ese(){}function hw(e){return e==null?Ese:function(){return this.querySelector(e)}}function Sse(e){typeof e!="function"&&(e=hw(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=new Array(o),u,f,m=0;m<o;++m)(u=a[m])&&(f=e.call(u,u.__data__,m,a))&&("__data__"in u&&(f.__data__=u.__data__),c[m]=f);return new rs(i,this._parents)}function kse(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Nse(){return[]}function GL(e){return e==null?Nse:function(){return this.querySelectorAll(e)}}function _se(e){return function(){return kse(e.apply(this,arguments))}}function Cse(e){typeof e=="function"?e=_se(e):e=GL(e);for(var t=this._groups,n=t.length,i=[],s=[],a=0;a<n;++a)for(var o=t[a],c=o.length,u,f=0;f<c;++f)(u=o[f])&&(i.push(e.call(u,u.__data__,f,o)),s.push(u));return new rs(i,s)}function WL(e){return function(){return this.matches(e)}}function YL(e){return function(t){return t.matches(e)}}var Tse=Array.prototype.find;function Ase(e){return function(){return Tse.call(this.children,e)}}function jse(){return this.firstElementChild}function Mse(e){return this.select(e==null?jse:Ase(typeof e=="function"?e:YL(e)))}var Rse=Array.prototype.filter;function Dse(){return Array.from(this.children)}function Ose(e){return function(){return Rse.call(this.children,e)}}function Lse(e){return this.selectAll(e==null?Dse:Ose(typeof e=="function"?e:YL(e)))}function Ise(e){typeof e!="function"&&(e=WL(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=[],u,f=0;f<o;++f)(u=a[f])&&e.call(u,u.__data__,f,a)&&c.push(u);return new rs(i,this._parents)}function XL(e){return new Array(e.length)}function Pse(){return new rs(this._enter||this._groups.map(XL),this._parents)}function ym(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ym.prototype={constructor:ym,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function zse(e){return function(){return e}}function Bse(e,t,n,i,s,a){for(var o=0,c,u=t.length,f=a.length;o<f;++o)(c=t[o])?(c.__data__=a[o],i[o]=c):n[o]=new ym(e,a[o]);for(;o<u;++o)(c=t[o])&&(s[o]=c)}function Use(e,t,n,i,s,a,o){var c,u,f=new Map,m=t.length,p=a.length,y=new Array(m),b;for(c=0;c<m;++c)(u=t[c])&&(y[c]=b=o.call(u,u.__data__,c,t)+"",f.has(b)?s[c]=u:f.set(b,u));for(c=0;c<p;++c)b=o.call(e,a[c],c,a)+"",(u=f.get(b))?(i[c]=u,u.__data__=a[c],f.delete(b)):n[c]=new ym(e,a[c]);for(c=0;c<m;++c)(u=t[c])&&f.get(y[c])===u&&(s[c]=u)}function Fse(e){return e.__data__}function $se(e,t){if(!arguments.length)return Array.from(this,Fse);var n=t?Use:Bse,i=this._parents,s=this._groups;typeof e!="function"&&(e=zse(e));for(var a=s.length,o=new Array(a),c=new Array(a),u=new Array(a),f=0;f<a;++f){var m=i[f],p=s[f],y=p.length,b=qse(e.call(m,m&&m.__data__,f,i)),x=b.length,w=c[f]=new Array(x),E=o[f]=new Array(x),v=u[f]=new Array(y);n(m,p,w,E,v,b,t);for(var _=0,k=0,T,A;_<x;++_)if(T=w[_]){for(_>=k&&(k=_+1);!(A=E[k])&&++k<x;);T._next=A||null}}return o=new rs(o,i),o._enter=c,o._exit=u,o}function qse(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hse(){return new rs(this._exit||this._groups.map(XL),this._parents)}function Vse(e,t,n){var i=this.enter(),s=this,a=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),i&&s?i.merge(s).order():s}function Kse(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,s=n.length,a=i.length,o=Math.min(s,a),c=new Array(s),u=0;u<o;++u)for(var f=n[u],m=i[u],p=f.length,y=c[u]=new Array(p),b,x=0;x<p;++x)(b=f[x]||m[x])&&(y[x]=b);for(;u<s;++u)c[u]=n[u];return new rs(c,this._parents)}function Gse(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],s=i.length-1,a=i[s],o;--s>=0;)(o=i[s])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Wse(e){e||(e=Yse);function t(p,y){return p&&y?e(p.__data__,y.__data__):!p-!y}for(var n=this._groups,i=n.length,s=new Array(i),a=0;a<i;++a){for(var o=n[a],c=o.length,u=s[a]=new Array(c),f,m=0;m<c;++m)(f=o[m])&&(u[m]=f);u.sort(t)}return new rs(s,this._parents).order()}function Yse(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xse(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qse(){return Array.from(this)}function Zse(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,a=i.length;s<a;++s){var o=i[s];if(o)return o}return null}function Jse(){let e=0;for(const t of this)++e;return e}function ere(){return!this.node()}function tre(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var s=t[n],a=0,o=s.length,c;a<o;++a)(c=s[a])&&e.call(c,c.__data__,a,s);return this}function nre(e){return function(){this.removeAttribute(e)}}function ire(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sre(e,t){return function(){this.setAttribute(e,t)}}function rre(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function are(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ore(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function lre(e,t){var n=og(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?ire:nre:typeof t=="function"?n.local?ore:are:n.local?rre:sre)(n,t))}function QL(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function cre(e){return function(){this.style.removeProperty(e)}}function ure(e,t,n){return function(){this.style.setProperty(e,t,n)}}function dre(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function fre(e,t,n){return arguments.length>1?this.each((t==null?cre:typeof t=="function"?dre:ure)(e,t,n??"")):Pc(this.node(),e)}function Pc(e,t){return e.style.getPropertyValue(t)||QL(e).getComputedStyle(e,null).getPropertyValue(t)}function hre(e){return function(){delete this[e]}}function pre(e,t){return function(){this[e]=t}}function mre(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function gre(e,t){return arguments.length>1?this.each((t==null?hre:typeof t=="function"?mre:pre)(e,t)):this.node()[e]}function ZL(e){return e.trim().split(/^|\s+/)}function pw(e){return e.classList||new JL(e)}function JL(e){this._node=e,this._names=ZL(e.getAttribute("class")||"")}JL.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function eI(e,t){for(var n=pw(e),i=-1,s=t.length;++i<s;)n.add(t[i])}function tI(e,t){for(var n=pw(e),i=-1,s=t.length;++i<s;)n.remove(t[i])}function yre(e){return function(){eI(this,e)}}function bre(e){return function(){tI(this,e)}}function xre(e,t){return function(){(t.apply(this,arguments)?eI:tI)(this,e)}}function vre(e,t){var n=ZL(e+"");if(arguments.length<2){for(var i=pw(this.node()),s=-1,a=n.length;++s<a;)if(!i.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xre:t?yre:bre)(n,t))}function wre(){this.textContent=""}function Ere(e){return function(){this.textContent=e}}function Sre(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function kre(e){return arguments.length?this.each(e==null?wre:(typeof e=="function"?Sre:Ere)(e)):this.node().textContent}function Nre(){this.innerHTML=""}function _re(e){return function(){this.innerHTML=e}}function Cre(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tre(e){return arguments.length?this.each(e==null?Nre:(typeof e=="function"?Cre:_re)(e)):this.node().innerHTML}function Are(){this.nextSibling&&this.parentNode.appendChild(this)}function jre(){return this.each(Are)}function Mre(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Rre(){return this.each(Mre)}function Dre(e){var t=typeof e=="function"?e:KL(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ore(){return null}function Lre(e,t){var n=typeof e=="function"?e:KL(e),i=t==null?Ore:typeof t=="function"?t:hw(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Ire(){var e=this.parentNode;e&&e.removeChild(this)}function Pre(){return this.each(Ire)}function zre(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bre(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ure(e){return this.select(e?Bre:zre)}function Fre(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $re(e){return function(t){e.call(this,t,this.__data__)}}function qre(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Hre(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++i]=a;++i?t.length=i:delete this.__on}}}function Vre(e,t,n){return function(){var i=this.__on,s,a=$re(t);if(i){for(var o=0,c=i.length;o<c;++o)if((s=i[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},i?i.push(s):this.__on=[s]}}function Kre(e,t,n){var i=qre(e+""),s,a=i.length,o;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,f=c.length,m;u<f;++u)for(s=0,m=c[u];s<a;++s)if((o=i[s]).type===m.type&&o.name===m.name)return m.value}return}for(c=t?Vre:Hre,s=0;s<a;++s)this.each(c(i[s],t,n));return this}function nI(e,t,n){var i=QL(e),s=i.CustomEvent;typeof s=="function"?s=new s(t,n):(s=i.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Gre(e,t){return function(){return nI(this,e,t)}}function Wre(e,t){return function(){return nI(this,e,t.apply(this,arguments))}}function Yre(e,t){return this.each((typeof t=="function"?Wre:Gre)(e,t))}function*Xre(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,a=i.length,o;s<a;++s)(o=i[s])&&(yield o)}var iI=[null];function rs(e,t){this._groups=e,this._parents=t}function wf(){return new rs([[document.documentElement]],iI)}function Qre(){return this}rs.prototype=wf.prototype={constructor:rs,select:Sse,selectAll:Cse,selectChild:Mse,selectChildren:Lse,filter:Ise,data:$se,enter:Pse,exit:Hse,join:Vse,merge:Kse,selection:Qre,order:Gse,sort:Wse,call:Xse,nodes:Qse,node:Zse,size:Jse,empty:ere,each:tre,attr:lre,style:fre,property:gre,classed:vre,text:kre,html:Tre,raise:jre,lower:Rre,append:Dre,insert:Lre,remove:Pre,clone:Ure,datum:Fre,on:Kre,dispatch:Yre,[Symbol.iterator]:Xre};function ns(e){return typeof e=="string"?new rs([[document.querySelector(e)]],[document.documentElement]):new rs([[e]],iI)}function Zre(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Is(e,t){if(e=Zre(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Jre={passive:!1},$d={capture:!0,passive:!1};function Dx(e){e.stopImmediatePropagation()}function gc(e){e.preventDefault(),e.stopImmediatePropagation()}function sI(e){var t=e.document.documentElement,n=ns(e).on("dragstart.drag",gc,$d);"onselectstart"in t?n.on("selectstart.drag",gc,$d):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function rI(e,t){var n=e.document.documentElement,i=ns(e).on("dragstart.drag",null);t&&(i.on("click.drag",gc,$d),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const cp=e=>()=>e;function pv(e,{sourceEvent:t,subject:n,target:i,identifier:s,active:a,x:o,y:c,dx:u,dy:f,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:m}})}pv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function eae(e){return!e.ctrlKey&&!e.button}function tae(){return this.parentNode}function nae(e,t){return t??{x:e.x,y:e.y}}function iae(){return navigator.maxTouchPoints||"ontouchstart"in this}function aI(){var e=eae,t=tae,n=nae,i=iae,s={},a=ag("start","drag","end"),o=0,c,u,f,m,p=0;function y(T){T.on("mousedown.drag",b).filter(i).on("touchstart.drag",E).on("touchmove.drag",v,Jre).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,A){if(!(m||!e.call(this,T,A))){var j=k(this,t.call(this,T,A),T,A,"mouse");j&&(ns(T.view).on("mousemove.drag",x,$d).on("mouseup.drag",w,$d),sI(T.view),Dx(T),f=!1,c=T.clientX,u=T.clientY,j("start",T))}}function x(T){if(gc(T),!f){var A=T.clientX-c,j=T.clientY-u;f=A*A+j*j>p}s.mouse("drag",T)}function w(T){ns(T.view).on("mousemove.drag mouseup.drag",null),rI(T.view,f),gc(T),s.mouse("end",T)}function E(T,A){if(e.call(this,T,A)){var j=T.changedTouches,M=t.call(this,T,A),D=j.length,I,P;for(I=0;I<D;++I)(P=k(this,M,T,A,j[I].identifier,j[I]))&&(Dx(T),P("start",T,j[I]))}}function v(T){var A=T.changedTouches,j=A.length,M,D;for(M=0;M<j;++M)(D=s[A[M].identifier])&&(gc(T),D("drag",T,A[M]))}function _(T){var A=T.changedTouches,j=A.length,M,D;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),M=0;M<j;++M)(D=s[A[M].identifier])&&(Dx(T),D("end",T,A[M]))}function k(T,A,j,M,D,I){var P=a.copy(),U=Is(I||j,A),q,V,O;if((O=n.call(T,new pv("beforestart",{sourceEvent:j,target:y,identifier:D,active:o,x:U[0],y:U[1],dx:0,dy:0,dispatch:P}),M))!=null)return q=O.x-U[0]||0,V=O.y-U[1]||0,function R(z,G,Y){var K=U,B;switch(z){case"start":s[D]=R,B=o++;break;case"end":delete s[D],--o;case"drag":U=Is(Y||G,A),B=o;break}P.call(z,T,new pv(z,{sourceEvent:G,subject:O,target:y,identifier:D,active:B,x:U[0]+q,y:U[1]+V,dx:U[0]-K[0],dy:U[1]-K[1],dispatch:P}),M)}}return y.filter=function(T){return arguments.length?(e=typeof T=="function"?T:cp(!!T),y):e},y.container=function(T){return arguments.length?(t=typeof T=="function"?T:cp(T),y):t},y.subject=function(T){return arguments.length?(n=typeof T=="function"?T:cp(T),y):n},y.touchable=function(T){return arguments.length?(i=typeof T=="function"?T:cp(!!T),y):i},y.on=function(){var T=a.on.apply(a,arguments);return T===a?y:T},y.clickDistance=function(T){return arguments.length?(p=(T=+T)*T,y):Math.sqrt(p)},y}function mw(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function oI(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Ef(){}var qd=.7,bm=1/qd,yc="\\s*([+-]?\\d+)\\s*",Hd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sae=/^#([0-9a-f]{3,8})$/,rae=new RegExp(`^rgb\\(${yc},${yc},${yc}\\)$`),aae=new RegExp(`^rgb\\(${mr},${mr},${mr}\\)$`),oae=new RegExp(`^rgba\\(${yc},${yc},${yc},${Hd}\\)$`),lae=new RegExp(`^rgba\\(${mr},${mr},${mr},${Hd}\\)$`),cae=new RegExp(`^hsl\\(${Hd},${mr},${mr}\\)$`),uae=new RegExp(`^hsla\\(${Hd},${mr},${mr},${Hd}\\)$`),bT={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};mw(Ef,al,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xT,formatHex:xT,formatHex8:dae,formatHsl:fae,formatRgb:vT,toString:vT});function xT(){return this.rgb().formatHex()}function dae(){return this.rgb().formatHex8()}function fae(){return lI(this).formatHsl()}function vT(){return this.rgb().formatRgb()}function al(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sae.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?wT(t):n===3?new $i(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?up(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?up(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=rae.exec(e))?new $i(t[1],t[2],t[3],1):(t=aae.exec(e))?new $i(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oae.exec(e))?up(t[1],t[2],t[3],t[4]):(t=lae.exec(e))?up(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cae.exec(e))?kT(t[1],t[2]/100,t[3]/100,1):(t=uae.exec(e))?kT(t[1],t[2]/100,t[3]/100,t[4]):bT.hasOwnProperty(e)?wT(bT[e]):e==="transparent"?new $i(NaN,NaN,NaN,0):null}function wT(e){return new $i(e>>16&255,e>>8&255,e&255,1)}function up(e,t,n,i){return i<=0&&(e=t=n=NaN),new $i(e,t,n,i)}function hae(e){return e instanceof Ef||(e=al(e)),e?(e=e.rgb(),new $i(e.r,e.g,e.b,e.opacity)):new $i}function mv(e,t,n,i){return arguments.length===1?hae(e):new $i(e,t,n,i??1)}function $i(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}mw($i,mv,oI(Ef,{brighter(e){return e=e==null?bm:Math.pow(bm,e),new $i(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new $i(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $i(Zo(this.r),Zo(this.g),Zo(this.b),xm(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ET,formatHex:ET,formatHex8:pae,formatRgb:ST,toString:ST}));function ET(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}`}function pae(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}${Uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function ST(){const e=xm(this.opacity);return`${e===1?"rgb(":"rgba("}${Zo(this.r)}, ${Zo(this.g)}, ${Zo(this.b)}${e===1?")":`, ${e})`}`}function xm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Zo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uo(e){return e=Zo(e),(e<16?"0":"")+e.toString(16)}function kT(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ps(e,t,n,i)}function lI(e){if(e instanceof Ps)return new Ps(e.h,e.s,e.l,e.opacity);if(e instanceof Ef||(e=al(e)),!e)return new Ps;if(e instanceof Ps)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,s=Math.min(t,n,i),a=Math.max(t,n,i),o=NaN,c=a-s,u=(a+s)/2;return c?(t===a?o=(n-i)/c+(n<i)*6:n===a?o=(i-t)/c+2:o=(t-n)/c+4,c/=u<.5?a+s:2-a-s,o*=60):c=u>0&&u<1?0:o,new Ps(o,c,u,e.opacity)}function mae(e,t,n,i){return arguments.length===1?lI(e):new Ps(e,t,n,i??1)}function Ps(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}mw(Ps,mae,oI(Ef,{brighter(e){return e=e==null?bm:Math.pow(bm,e),new Ps(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new Ps(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,s=2*n-i;return new $i(Ox(e>=240?e-240:e+120,s,i),Ox(e,s,i),Ox(e<120?e+240:e-120,s,i),this.opacity)},clamp(){return new Ps(NT(this.h),dp(this.s),dp(this.l),xm(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=xm(this.opacity);return`${e===1?"hsl(":"hsla("}${NT(this.h)}, ${dp(this.s)*100}%, ${dp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function NT(e){return e=(e||0)%360,e<0?e+360:e}function dp(e){return Math.max(0,Math.min(1,e||0))}function Ox(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const gw=e=>()=>e;function gae(e,t){return function(n){return e+n*t}}function yae(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function bae(e){return(e=+e)==1?cI:function(t,n){return n-t?yae(t,n,e):gw(isNaN(t)?n:t)}}function cI(e,t){var n=t-e;return n?gae(e,n):gw(isNaN(e)?t:e)}const vm=(function e(t){var n=bae(t);function i(s,a){var o=n((s=mv(s)).r,(a=mv(a)).r),c=n(s.g,a.g),u=n(s.b,a.b),f=cI(s.opacity,a.opacity);return function(m){return s.r=o(m),s.g=c(m),s.b=u(m),s.opacity=f(m),s+""}}return i.gamma=e,i})(1);function xae(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),s;return function(a){for(s=0;s<n;++s)i[s]=e[s]*(1-a)+t[s]*a;return i}}function vae(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wae(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,s=new Array(i),a=new Array(n),o;for(o=0;o<i;++o)s[o]=Nd(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(c){for(o=0;o<i;++o)a[o]=s[o](c);return a}}function Eae(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function fr(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Sae(e,t){var n={},i={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=Nd(e[s],t[s]):i[s]=t[s];return function(a){for(s in n)i[s]=n[s](a);return i}}var gv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Lx=new RegExp(gv.source,"g");function kae(e){return function(){return e}}function Nae(e){return function(t){return e(t)+""}}function uI(e,t){var n=gv.lastIndex=Lx.lastIndex=0,i,s,a,o=-1,c=[],u=[];for(e=e+"",t=t+"";(i=gv.exec(e))&&(s=Lx.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),c[o]?c[o]+=a:c[++o]=a),(i=i[0])===(s=s[0])?c[o]?c[o]+=s:c[++o]=s:(c[++o]=null,u.push({i:o,x:fr(i,s)})),n=Lx.lastIndex;return n<t.length&&(a=t.slice(n),c[o]?c[o]+=a:c[++o]=a),c.length<2?u[0]?Nae(u[0].x):kae(t):(t=u.length,function(f){for(var m=0,p;m<t;++m)c[(p=u[m]).i]=p.x(f);return c.join("")})}function Nd(e,t){var n=typeof t,i;return t==null||n==="boolean"?gw(t):(n==="number"?fr:n==="string"?(i=al(t))?(t=i,vm):uI:t instanceof al?vm:t instanceof Date?Eae:vae(t)?xae:Array.isArray(t)?wae:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Sae:fr)(e,t)}var _T=180/Math.PI,yv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function dI(e,t,n,i,s,a){var o,c,u;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(u=e*n+t*i)&&(n-=e*u,i-=t*u),(c=Math.sqrt(n*n+i*i))&&(n/=c,i/=c,u/=c),e*i<t*n&&(e=-e,t=-t,u=-u,o=-o),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*_T,skewX:Math.atan(u)*_T,scaleX:o,scaleY:c}}var fp;function _ae(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?yv:dI(t.a,t.b,t.c,t.d,t.e,t.f)}function Cae(e){return e==null||(fp||(fp=document.createElementNS("http://www.w3.org/2000/svg","g")),fp.setAttribute("transform",e),!(e=fp.transform.baseVal.consolidate()))?yv:(e=e.matrix,dI(e.a,e.b,e.c,e.d,e.e,e.f))}function fI(e,t,n,i){function s(f){return f.length?f.pop()+" ":""}function a(f,m,p,y,b,x){if(f!==p||m!==y){var w=b.push("translate(",null,t,null,n);x.push({i:w-4,x:fr(f,p)},{i:w-2,x:fr(m,y)})}else(p||y)&&b.push("translate("+p+t+y+n)}function o(f,m,p,y){f!==m?(f-m>180?m+=360:m-f>180&&(f+=360),y.push({i:p.push(s(p)+"rotate(",null,i)-2,x:fr(f,m)})):m&&p.push(s(p)+"rotate("+m+i)}function c(f,m,p,y){f!==m?y.push({i:p.push(s(p)+"skewX(",null,i)-2,x:fr(f,m)}):m&&p.push(s(p)+"skewX("+m+i)}function u(f,m,p,y,b,x){if(f!==p||m!==y){var w=b.push(s(b)+"scale(",null,",",null,")");x.push({i:w-4,x:fr(f,p)},{i:w-2,x:fr(m,y)})}else(p!==1||y!==1)&&b.push(s(b)+"scale("+p+","+y+")")}return function(f,m){var p=[],y=[];return f=e(f),m=e(m),a(f.translateX,f.translateY,m.translateX,m.translateY,p,y),o(f.rotate,m.rotate,p,y),c(f.skewX,m.skewX,p,y),u(f.scaleX,f.scaleY,m.scaleX,m.scaleY,p,y),f=m=null,function(b){for(var x=-1,w=y.length,E;++x<w;)p[(E=y[x]).i]=E.x(b);return p.join("")}}}var Tae=fI(_ae,"px, ","px)","deg)"),Aae=fI(Cae,", ",")",")"),jae=1e-12;function CT(e){return((e=Math.exp(e))+1/e)/2}function Mae(e){return((e=Math.exp(e))-1/e)/2}function Rae(e){return((e=Math.exp(2*e))-1)/(e+1)}const zp=(function e(t,n,i){function s(a,o){var c=a[0],u=a[1],f=a[2],m=o[0],p=o[1],y=o[2],b=m-c,x=p-u,w=b*b+x*x,E,v;if(w<jae)v=Math.log(y/f)/t,E=function(M){return[c+M*b,u+M*x,f*Math.exp(t*M*v)]};else{var _=Math.sqrt(w),k=(y*y-f*f+i*w)/(2*f*n*_),T=(y*y-f*f-i*w)/(2*y*n*_),A=Math.log(Math.sqrt(k*k+1)-k),j=Math.log(Math.sqrt(T*T+1)-T);v=(j-A)/t,E=function(M){var D=M*v,I=CT(A),P=f/(n*_)*(I*Rae(t*D+A)-Mae(A));return[c+P*b,u+P*x,f*I/CT(t*D+A)]}}return E.duration=v*1e3*t/Math.SQRT2,E}return s.rho=function(a){var o=Math.max(.001,+a),c=o*o,u=c*c;return e(o,c,u)},s})(Math.SQRT2,2,4);var zc=0,hd=0,rd=0,hI=1e3,wm,pd,Em=0,ol=0,lg=0,Vd=typeof performance=="object"&&performance.now?performance:Date,pI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yw(){return ol||(pI(Dae),ol=Vd.now()+lg)}function Dae(){ol=0}function Sm(){this._call=this._time=this._next=null}Sm.prototype=mI.prototype={constructor:Sm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?yw():+n)+(t==null?0:+t),!this._next&&pd!==this&&(pd?pd._next=this:wm=this,pd=this),this._call=e,this._time=n,bv()},stop:function(){this._call&&(this._call=null,this._time=1/0,bv())}};function mI(e,t,n){var i=new Sm;return i.restart(e,t,n),i}function Oae(){yw(),++zc;for(var e=wm,t;e;)(t=ol-e._time)>=0&&e._call.call(void 0,t),e=e._next;--zc}function TT(){ol=(Em=Vd.now())+lg,zc=hd=0;try{Oae()}finally{zc=0,Iae(),ol=0}}function Lae(){var e=Vd.now(),t=e-Em;t>hI&&(lg-=t,Em=e)}function Iae(){for(var e,t=wm,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:wm=n);pd=e,bv(i)}function bv(e){if(!zc){hd&&(hd=clearTimeout(hd));var t=e-ol;t>24?(e<1/0&&(hd=setTimeout(TT,e-Vd.now()-lg)),rd&&(rd=clearInterval(rd))):(rd||(Em=Vd.now(),rd=setInterval(Lae,hI)),zc=1,pI(TT))}}function AT(e,t,n){var i=new Sm;return t=t==null?0:+t,i.restart(s=>{i.stop(),e(s+t)},t,n),i}var Pae=ag("start","end","cancel","interrupt"),zae=[],gI=0,jT=1,xv=2,Bp=3,MT=4,vv=5,Up=6;function cg(e,t,n,i,s,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Bae(e,n,{name:t,index:i,group:s,on:Pae,tween:zae,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:gI})}function bw(e,t){var n=Ws(e,t);if(n.state>gI)throw new Error("too late; already scheduled");return n}function vr(e,t){var n=Ws(e,t);if(n.state>Bp)throw new Error("too late; already running");return n}function Ws(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bae(e,t,n){var i=e.__transition,s;i[t]=n,n.timer=mI(a,0,n.time);function a(f){n.state=jT,n.timer.restart(o,n.delay,n.time),n.delay<=f&&o(f-n.delay)}function o(f){var m,p,y,b;if(n.state!==jT)return u();for(m in i)if(b=i[m],b.name===n.name){if(b.state===Bp)return AT(o);b.state===MT?(b.state=Up,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete i[m]):+m<t&&(b.state=Up,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete i[m])}if(AT(function(){n.state===Bp&&(n.state=MT,n.timer.restart(c,n.delay,n.time),c(f))}),n.state=xv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===xv){for(n.state=Bp,s=new Array(y=n.tween.length),m=0,p=-1;m<y;++m)(b=n.tween[m].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=b);s.length=p+1}}function c(f){for(var m=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(u),n.state=vv,1),p=-1,y=s.length;++p<y;)s[p].call(e,m);n.state===vv&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Up,n.timer.stop(),delete i[t];for(var f in i)return;delete e.__transition}}function Fp(e,t){var n=e.__transition,i,s,a=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){a=!1;continue}s=i.state>xv&&i.state<vv,i.state=Up,i.timer.stop(),i.on.call(s?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}a&&delete e.__transition}}function Uae(e){return this.each(function(){Fp(this,e)})}function Fae(e,t){var n,i;return function(){var s=vr(this,e),a=s.tween;if(a!==n){i=n=a;for(var o=0,c=i.length;o<c;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}s.tween=i}}function $ae(e,t,n){var i,s;if(typeof n!="function")throw new Error;return function(){var a=vr(this,e),o=a.tween;if(o!==i){s=(i=o).slice();for(var c={name:t,value:n},u=0,f=s.length;u<f;++u)if(s[u].name===t){s[u]=c;break}u===f&&s.push(c)}a.tween=s}}function qae(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Ws(this.node(),n).tween,s=0,a=i.length,o;s<a;++s)if((o=i[s]).name===e)return o.value;return null}return this.each((t==null?Fae:$ae)(n,e,t))}function xw(e,t,n){var i=e._id;return e.each(function(){var s=vr(this,i);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ws(s,i).value[t]}}function yI(e,t){var n;return(typeof t=="number"?fr:t instanceof al?vm:(n=al(t))?(t=n,vm):uI)(e,t)}function Hae(e){return function(){this.removeAttribute(e)}}function Vae(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kae(e,t,n){var i,s=n+"",a;return function(){var o=this.getAttribute(e);return o===s?null:o===i?a:a=t(i=o,n)}}function Gae(e,t,n){var i,s=n+"",a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===s?null:o===i?a:a=t(i=o,n)}}function Wae(e,t,n){var i,s,a;return function(){var o,c=n(this),u;return c==null?void this.removeAttribute(e):(o=this.getAttribute(e),u=c+"",o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c)))}}function Yae(e,t,n){var i,s,a;return function(){var o,c=n(this),u;return c==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),u=c+"",o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c)))}}function Xae(e,t){var n=og(e),i=n==="transform"?Aae:yI;return this.attrTween(e,typeof t=="function"?(n.local?Yae:Wae)(n,i,xw(this,"attr."+e,t)):t==null?(n.local?Vae:Hae)(n):(n.local?Gae:Kae)(n,i,t))}function Qae(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zae(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Jae(e,t){var n,i;function s(){var a=t.apply(this,arguments);return a!==i&&(n=(i=a)&&Zae(e,a)),n}return s._value=t,s}function eoe(e,t){var n,i;function s(){var a=t.apply(this,arguments);return a!==i&&(n=(i=a)&&Qae(e,a)),n}return s._value=t,s}function toe(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=og(e);return this.tween(n,(i.local?Jae:eoe)(i,t))}function noe(e,t){return function(){bw(this,e).delay=+t.apply(this,arguments)}}function ioe(e,t){return t=+t,function(){bw(this,e).delay=t}}function soe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?noe:ioe)(t,e)):Ws(this.node(),t).delay}function roe(e,t){return function(){vr(this,e).duration=+t.apply(this,arguments)}}function aoe(e,t){return t=+t,function(){vr(this,e).duration=t}}function ooe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?roe:aoe)(t,e)):Ws(this.node(),t).duration}function loe(e,t){if(typeof t!="function")throw new Error;return function(){vr(this,e).ease=t}}function coe(e){var t=this._id;return arguments.length?this.each(loe(t,e)):Ws(this.node(),t).ease}function uoe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;vr(this,e).ease=n}}function doe(e){if(typeof e!="function")throw new Error;return this.each(uoe(this._id,e))}function foe(e){typeof e!="function"&&(e=WL(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=[],u,f=0;f<o;++f)(u=a[f])&&e.call(u,u.__data__,f,a)&&c.push(u);return new ta(i,this._parents,this._name,this._id)}function hoe(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,s=n.length,a=Math.min(i,s),o=new Array(i),c=0;c<a;++c)for(var u=t[c],f=n[c],m=u.length,p=o[c]=new Array(m),y,b=0;b<m;++b)(y=u[b]||f[b])&&(p[b]=y);for(;c<i;++c)o[c]=t[c];return new ta(o,this._parents,this._name,this._id)}function poe(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function moe(e,t,n){var i,s,a=poe(t)?bw:vr;return function(){var o=a(this,e),c=o.on;c!==i&&(s=(i=c).copy()).on(t,n),o.on=s}}function goe(e,t){var n=this._id;return arguments.length<2?Ws(this.node(),n).on.on(e):this.each(moe(n,e,t))}function yoe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function boe(){return this.on("end.remove",yoe(this._id))}function xoe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hw(e));for(var i=this._groups,s=i.length,a=new Array(s),o=0;o<s;++o)for(var c=i[o],u=c.length,f=a[o]=new Array(u),m,p,y=0;y<u;++y)(m=c[y])&&(p=e.call(m,m.__data__,y,c))&&("__data__"in m&&(p.__data__=m.__data__),f[y]=p,cg(f[y],t,n,y,f,Ws(m,n)));return new ta(a,this._parents,t,n)}function voe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=GL(e));for(var i=this._groups,s=i.length,a=[],o=[],c=0;c<s;++c)for(var u=i[c],f=u.length,m,p=0;p<f;++p)if(m=u[p]){for(var y=e.call(m,m.__data__,p,u),b,x=Ws(m,n),w=0,E=y.length;w<E;++w)(b=y[w])&&cg(b,t,n,w,y,x);a.push(y),o.push(m)}return new ta(a,o,t,n)}var woe=wf.prototype.constructor;function Eoe(){return new woe(this._groups,this._parents)}function Soe(e,t){var n,i,s;return function(){var a=Pc(this,e),o=(this.style.removeProperty(e),Pc(this,e));return a===o?null:a===n&&o===i?s:s=t(n=a,i=o)}}function bI(e){return function(){this.style.removeProperty(e)}}function koe(e,t,n){var i,s=n+"",a;return function(){var o=Pc(this,e);return o===s?null:o===i?a:a=t(i=o,n)}}function Noe(e,t,n){var i,s,a;return function(){var o=Pc(this,e),c=n(this),u=c+"";return c==null&&(u=c=(this.style.removeProperty(e),Pc(this,e))),o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c))}}function _oe(e,t){var n,i,s,a="style."+t,o="end."+a,c;return function(){var u=vr(this,e),f=u.on,m=u.value[a]==null?c||(c=bI(t)):void 0;(f!==n||s!==m)&&(i=(n=f).copy()).on(o,s=m),u.on=i}}function Coe(e,t,n){var i=(e+="")=="transform"?Tae:yI;return t==null?this.styleTween(e,Soe(e,i)).on("end.style."+e,bI(e)):typeof t=="function"?this.styleTween(e,Noe(e,i,xw(this,"style."+e,t))).each(_oe(this._id,e)):this.styleTween(e,koe(e,i,t),n).on("end.style."+e,null)}function Toe(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Aoe(e,t,n){var i,s;function a(){var o=t.apply(this,arguments);return o!==s&&(i=(s=o)&&Toe(e,o,n)),i}return a._value=t,a}function joe(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Aoe(e,t,n??""))}function Moe(e){return function(){this.textContent=e}}function Roe(e){return function(){var t=e(this);this.textContent=t??""}}function Doe(e){return this.tween("text",typeof e=="function"?Roe(xw(this,"text",e)):Moe(e==null?"":e+""))}function Ooe(e){return function(t){this.textContent=e.call(this,t)}}function Loe(e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Ooe(s)),t}return i._value=e,i}function Ioe(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Loe(e))}function Poe(){for(var e=this._name,t=this._id,n=xI(),i=this._groups,s=i.length,a=0;a<s;++a)for(var o=i[a],c=o.length,u,f=0;f<c;++f)if(u=o[f]){var m=Ws(u,t);cg(u,e,n,f,o,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new ta(i,this._parents,e,n)}function zoe(){var e,t,n=this,i=n._id,s=n.size();return new Promise(function(a,o){var c={value:o},u={value:function(){--s===0&&a()}};n.each(function(){var f=vr(this,i),m=f.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(u)),f.on=t}),s===0&&a()})}var Boe=0;function ta(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function xI(){return++Boe}var Ur=wf.prototype;ta.prototype={constructor:ta,select:xoe,selectAll:voe,selectChild:Ur.selectChild,selectChildren:Ur.selectChildren,filter:foe,merge:hoe,selection:Eoe,transition:Poe,call:Ur.call,nodes:Ur.nodes,node:Ur.node,size:Ur.size,empty:Ur.empty,each:Ur.each,on:goe,attr:Xae,attrTween:toe,style:Coe,styleTween:joe,text:Doe,textTween:Ioe,remove:boe,tween:qae,delay:soe,duration:ooe,ease:coe,easeVarying:doe,end:zoe,[Symbol.iterator]:Ur[Symbol.iterator]};function Uoe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Foe={time:null,delay:0,duration:250,ease:Uoe};function $oe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function qoe(e){var t,n;e instanceof ta?(t=e._id,e=e._name):(t=xI(),(n=Foe).time=yw(),e=e==null?null:e+"");for(var i=this._groups,s=i.length,a=0;a<s;++a)for(var o=i[a],c=o.length,u,f=0;f<c;++f)(u=o[f])&&cg(u,e,t,f,o,n||$oe(u,t));return new ta(i,this._parents,e,t)}wf.prototype.interrupt=Uae;wf.prototype.transition=qoe;const hp=e=>()=>e;function Hoe(e,{sourceEvent:t,target:n,transform:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function Wr(e,t,n){this.k=e,this.x=t,this.y=n}Wr.prototype={constructor:Wr,scale:function(e){return e===1?this:new Wr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Wr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ug=new Wr(1,0,0);vI.prototype=Wr.prototype;function vI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ug;return e.__zoom}function Ix(e){e.stopImmediatePropagation()}function ad(e){e.preventDefault(),e.stopImmediatePropagation()}function Voe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Koe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function RT(){return this.__zoom||ug}function Goe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Woe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Yoe(e,t,n){var i=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function wI(){var e=Voe,t=Koe,n=Yoe,i=Goe,s=Woe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],c=250,u=zp,f=ag("start","zoom","end"),m,p,y,b=500,x=150,w=0,E=10;function v(O){O.property("__zoom",RT).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",U).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(O,R,z,G){var Y=O.selection?O.selection():O;Y.property("__zoom",RT),O!==Y?A(O,R,z,G):Y.interrupt().each(function(){j(this,arguments).event(G).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},v.scaleBy=function(O,R,z,G){v.scaleTo(O,function(){var Y=this.__zoom.k,K=typeof R=="function"?R.apply(this,arguments):R;return Y*K},z,G)},v.scaleTo=function(O,R,z,G){v.transform(O,function(){var Y=t.apply(this,arguments),K=this.__zoom,B=z==null?T(Y):typeof z=="function"?z.apply(this,arguments):z,F=K.invert(B),W=typeof R=="function"?R.apply(this,arguments):R;return n(k(_(K,W),B,F),Y,o)},z,G)},v.translateBy=function(O,R,z,G){v.transform(O,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),o)},null,G)},v.translateTo=function(O,R,z,G,Y){v.transform(O,function(){var K=t.apply(this,arguments),B=this.__zoom,F=G==null?T(K):typeof G=="function"?G.apply(this,arguments):G;return n(ug.translate(F[0],F[1]).scale(B.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof z=="function"?-z.apply(this,arguments):-z),K,o)},G,Y)};function _(O,R){return R=Math.max(a[0],Math.min(a[1],R)),R===O.k?O:new Wr(R,O.x,O.y)}function k(O,R,z){var G=R[0]-z[0]*O.k,Y=R[1]-z[1]*O.k;return G===O.x&&Y===O.y?O:new Wr(O.k,G,Y)}function T(O){return[(+O[0][0]+ +O[1][0])/2,(+O[0][1]+ +O[1][1])/2]}function A(O,R,z,G){O.on("start.zoom",function(){j(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(G).end()}).tween("zoom",function(){var Y=this,K=arguments,B=j(Y,K).event(G),F=t.apply(Y,K),W=z==null?T(F):typeof z=="function"?z.apply(Y,K):z,$=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),ae=Y.__zoom,be=typeof R=="function"?R.apply(Y,K):R,le=u(ae.invert(W).concat($/ae.k),be.invert(W).concat($/be.k));return function(Ne){if(Ne===1)Ne=be;else{var re=le(Ne),me=$/re[2];Ne=new Wr(me,W[0]-re[0]*me,W[1]-re[1]*me)}B.zoom(null,Ne)}})}function j(O,R,z){return!z&&O.__zooming||new M(O,R)}function M(O,R){this.that=O,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(O,R),this.taps=0}M.prototype={event:function(O){return O&&(this.sourceEvent=O),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(O,R){return this.mouse&&O!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&O!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&O!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(O){var R=ns(this.that).datum();f.call(O,this.that,new Hoe(O,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:f}),R)}};function D(O,...R){if(!e.apply(this,arguments))return;var z=j(this,R).event(O),G=this.__zoom,Y=Math.max(a[0],Math.min(a[1],G.k*Math.pow(2,i.apply(this,arguments)))),K=Is(O);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Y)return;z.mouse=[K,G.invert(K)],Fp(this),z.start()}ad(O),z.wheel=setTimeout(B,x),z.zoom("mouse",n(k(_(G,Y),z.mouse[0],z.mouse[1]),z.extent,o));function B(){z.wheel=null,z.end()}}function I(O,...R){if(y||!e.apply(this,arguments))return;var z=O.currentTarget,G=j(this,R,!0).event(O),Y=ns(O.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",$,!0),K=Is(O,z),B=O.clientX,F=O.clientY;sI(O.view),Ix(O),G.mouse=[K,this.__zoom.invert(K)],Fp(this),G.start();function W(ae){if(ad(ae),!G.moved){var be=ae.clientX-B,le=ae.clientY-F;G.moved=be*be+le*le>w}G.event(ae).zoom("mouse",n(k(G.that.__zoom,G.mouse[0]=Is(ae,z),G.mouse[1]),G.extent,o))}function $(ae){Y.on("mousemove.zoom mouseup.zoom",null),rI(ae.view,G.moved),ad(ae),G.event(ae).end()}}function P(O,...R){if(e.apply(this,arguments)){var z=this.__zoom,G=Is(O.changedTouches?O.changedTouches[0]:O,this),Y=z.invert(G),K=z.k*(O.shiftKey?.5:2),B=n(k(_(z,K),G,Y),t.apply(this,R),o);ad(O),c>0?ns(this).transition().duration(c).call(A,B,G,O):ns(this).call(v.transform,B,G,O)}}function U(O,...R){if(e.apply(this,arguments)){var z=O.touches,G=z.length,Y=j(this,R,O.changedTouches.length===G).event(O),K,B,F,W;for(Ix(O),B=0;B<G;++B)F=z[B],W=Is(F,this),W=[W,this.__zoom.invert(W),F.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==W[2]&&(Y.touch1=W,Y.taps=0):(Y.touch0=W,K=!0,Y.taps=1+!!m);m&&(m=clearTimeout(m)),K&&(Y.taps<2&&(p=W[0],m=setTimeout(function(){m=null},b)),Fp(this),Y.start())}}function q(O,...R){if(this.__zooming){var z=j(this,R).event(O),G=O.changedTouches,Y=G.length,K,B,F,W;for(ad(O),K=0;K<Y;++K)B=G[K],F=Is(B,this),z.touch0&&z.touch0[2]===B.identifier?z.touch0[0]=F:z.touch1&&z.touch1[2]===B.identifier&&(z.touch1[0]=F);if(B=z.that.__zoom,z.touch1){var $=z.touch0[0],ae=z.touch0[1],be=z.touch1[0],le=z.touch1[1],Ne=(Ne=be[0]-$[0])*Ne+(Ne=be[1]-$[1])*Ne,re=(re=le[0]-ae[0])*re+(re=le[1]-ae[1])*re;B=_(B,Math.sqrt(Ne/re)),F=[($[0]+be[0])/2,($[1]+be[1])/2],W=[(ae[0]+le[0])/2,(ae[1]+le[1])/2]}else if(z.touch0)F=z.touch0[0],W=z.touch0[1];else return;z.zoom("touch",n(k(B,F,W),z.extent,o))}}function V(O,...R){if(this.__zooming){var z=j(this,R).event(O),G=O.changedTouches,Y=G.length,K,B;for(Ix(O),y&&clearTimeout(y),y=setTimeout(function(){y=null},b),K=0;K<Y;++K)B=G[K],z.touch0&&z.touch0[2]===B.identifier?delete z.touch0:z.touch1&&z.touch1[2]===B.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(B=Is(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<E)){var F=ns(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return v.wheelDelta=function(O){return arguments.length?(i=typeof O=="function"?O:hp(+O),v):i},v.filter=function(O){return arguments.length?(e=typeof O=="function"?O:hp(!!O),v):e},v.touchable=function(O){return arguments.length?(s=typeof O=="function"?O:hp(!!O),v):s},v.extent=function(O){return arguments.length?(t=typeof O=="function"?O:hp([[+O[0][0],+O[0][1]],[+O[1][0],+O[1][1]]]),v):t},v.scaleExtent=function(O){return arguments.length?(a[0]=+O[0],a[1]=+O[1],v):[a[0],a[1]]},v.translateExtent=function(O){return arguments.length?(o[0][0]=+O[0][0],o[1][0]=+O[1][0],o[0][1]=+O[0][1],o[1][1]=+O[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(O){return arguments.length?(n=O,v):n},v.duration=function(O){return arguments.length?(c=+O,v):c},v.interpolate=function(O){return arguments.length?(u=O,v):u},v.on=function(){var O=f.on.apply(f,arguments);return O===f?v:O},v.clickDistance=function(O){return arguments.length?(w=(O=+O)*O,v):Math.sqrt(w)},v.tapDistance=function(O){return arguments.length?(E=+O,v):E},v}const as={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Kd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],EI=["Enter"," ","Escape"],SI={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Bc;(function(e){e.Strict="strict",e.Loose="loose"})(Bc||(Bc={}));var Jo;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Jo||(Jo={}));var Gd;(function(e){e.Partial="partial",e.Full="full"})(Gd||(Gd={}));const kI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fa||(Fa={}));var km;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(km||(km={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const DT={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top};function NI(e){return e===null?null:e?"valid":"invalid"}const _I=e=>"id"in e&&"source"in e&&"target"in e,Xoe=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),vw=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Sf=(e,t=[0,0])=>{const{width:n,height:i}=ia(e),s=e.origin??t,a=n*s[0],o=i*s[1];return{x:e.position.x-a,y:e.position.y-o}},Qoe=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,s)=>{const a=typeof s=="string";let o=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(o=a?t.nodeLookup.get(s):vw(s)?s:t.nodeLookup.get(s.id));const c=o?Nm(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return dg(i,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fg(n)},kf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=dg(n,Nm(s)),i=!0)}),i?fg(n):{x:0,y:0,width:0,height:0}},ww=(e,t,[n,i,s]=[0,0,1],a=!1,o=!1)=>{const c=(t.x-n)/s,u=(t.y-i)/s,f=t.width/s,m=t.height/s,p=[];for(const y of e.values()){const{measured:b,selectable:x=!0,hidden:w=!1}=y;if(o&&!x||w)continue;const E=b.width??y.width??y.initialWidth??0,v=b.height??y.height??y.initialHeight??0,{x:_,y:k}=y.internals.positionAbsolute,T=jI(c,u,f,m,_,k,E,v),A=E*v,j=a&&T>0;(!y.internals.handleBounds||j||T>=A||y.dragging)&&p.push(y)}return p},Zoe=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function Joe(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!i||i.has(s.id))&&n.set(s.id,s)}),n}async function ele({nodes:e,width:t,height:n,panZoom:i,minZoom:s,maxZoom:a},o){if(e.size===0)return!0;const c=Joe(e,o),u=kf(c),f=Sw(u,t,n,(o==null?void 0:o.minZoom)??s,(o==null?void 0:o.maxZoom)??a,(o==null?void 0:o.padding)??.1);return await i.setViewport(f,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0}function CI({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:s,onError:a}){const o=n.get(e),c=o.parentId?n.get(o.parentId):void 0,{x:u,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},m=o.origin??i;let p=o.extent||s;if(o.extent==="parent"&&!o.expandParent)if(!c)a==null||a("005",as.error005());else{const b=c.measured.width,x=c.measured.height;b&&x&&(p=[[u,f],[u+b,f+x]])}else c&&cl(o.extent)&&(p=[[o.extent[0][0]+u,o.extent[0][1]+f],[o.extent[1][0]+u,o.extent[1][1]+f]]);const y=cl(p)?ll(t,p,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&(a==null||a("015",as.error015())),{position:{x:y.x-u+(o.measured.width??0)*m[0],y:y.y-f+(o.measured.height??0)*m[1]},positionAbsolute:y}}async function tle({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:s}){const a=new Set(e.map(y=>y.id)),o=[];for(const y of n){if(y.deletable===!1)continue;const b=a.has(y.id),x=!b&&y.parentId&&o.find(w=>w.id===y.parentId);(b||x)&&o.push(y)}const c=new Set(t.map(y=>y.id)),u=i.filter(y=>y.deletable!==!1),m=Zoe(o,u);for(const y of u)c.has(y.id)&&!m.find(x=>x.id===y.id)&&m.push(y);if(!s)return{edges:m,nodes:o};const p=await s({nodes:o,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:o}:{edges:[],nodes:[]}:p}const Uc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ll=(e={x:0,y:0},t,n)=>({x:Uc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Uc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function TI(e,t,n){const{width:i,height:s}=ia(n),{x:a,y:o}=n.internals.positionAbsolute;return ll(e,[[a,o],[a+i,o+s]],t)}const OT=(e,t,n)=>e<t?Uc(Math.abs(e-t),1,t)/t:e>n?-Uc(Math.abs(e-n),1,t)/t:0,Ew=(e,t,n=15,i=40)=>{const s=OT(e.x,i,t.width-i)*n,a=OT(e.y,i,t.height-i)*n;return[s,a]},dg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wv=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),fg=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Wd=(e,t=[0,0])=>{var s,a;const{x:n,y:i}=vw(e)?e.internals.positionAbsolute:Sf(e,t);return{x:n,y:i,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((a=e.measured)==null?void 0:a.height)??e.height??e.initialHeight??0}},Nm=(e,t=[0,0])=>{var s,a;const{x:n,y:i}=vw(e)?e.internals.positionAbsolute:Sf(e,t);return{x:n,y:i,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:i+(((a=e.measured)==null?void 0:a.height)??e.height??e.initialHeight??0)}},AI=(e,t)=>fg(dg(wv(e),wv(t))),jI=(e,t,n,i,s,a,o,c)=>{const u=Math.max(0,Math.min(e+n,s+o)-Math.max(e,s)),f=Math.max(0,Math.min(t+i,a+c)-Math.max(t,a));return Math.ceil(u*f)},_m=(e,t)=>jI(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),LT=e=>Bs(e.width)&&Bs(e.height)&&Bs(e.x)&&Bs(e.y),Bs=e=>!isNaN(e)&&isFinite(e),MI=(e,t)=>(n,i)=>{},Nf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_f=({x:e,y:t},[n,i,s],a=!1,o=[1,1])=>{const c={x:(e-n)/s,y:(t-i)/s};return a?Nf(c,o):c},Fc=({x:e,y:t},[n,i,s])=>({x:e*s+n,y:t*s+i});function Ql(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function nle(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=Ql(e,n),s=Ql(e,t);return{top:i,right:s,bottom:i,left:s,x:s*2,y:i*2}}if(typeof e=="object"){const i=Ql(e.top??e.y??0,n),s=Ql(e.bottom??e.y??0,n),a=Ql(e.left??e.x??0,t),o=Ql(e.right??e.x??0,t);return{top:i,right:o,bottom:s,left:a,x:a+o,y:i+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ile(e,t,n,i,s,a){const{x:o,y:c}=Fc(e,[t,n,i]),{x:u,y:f}=Fc({x:e.x+e.width,y:e.y+e.height},[t,n,i]),m=s-u,p=a-f;return{left:Math.floor(o),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Sw=(e,t,n,i,s,a)=>{const o=nle(a,t,n),c=(t-o.x)/e.width,u=(n-o.y)/e.height,f=Math.min(c,u),m=Uc(f,i,s),p=e.x+e.width/2,y=e.y+e.height/2,b=t/2-p*m,x=n/2-y*m,w=ile(e,b,x,m,t,n),E={left:Math.min(w.left-o.left,0),top:Math.min(w.top-o.top,0),right:Math.min(w.right-o.right,0),bottom:Math.min(w.bottom-o.bottom,0)};return{x:b-E.left+E.right,y:x-E.top+E.bottom,zoom:m}},Yd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function cl(e){return e!=null&&e!=="parent"}function ia(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function RI(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function DI(e,t={width:0,height:0},n,i,s){const a={...e},o=i.get(n);if(o){const c=o.origin||s;a.x+=o.internals.positionAbsolute.x-(t.width??0)*c[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*c[1]}return a}function IT(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sle(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}function rle(e){return{...SI,...e||{}}}function _d(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:s}){const{x:a,y:o}=Us(e),c=_f({x:a-((s==null?void 0:s.left)??0),y:o-((s==null?void 0:s.top)??0)},i),{x:u,y:f}=n?Nf(c,t):c;return{xSnapped:u,ySnapped:f,...c}}const kw=e=>({width:e.offsetWidth,height:e.offsetHeight}),OI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},ale=["INPUT","SELECT","TEXTAREA"];function LI(e){var i,s;const t=((s=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:ale.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const II=e=>"clientX"in e,Us=(e,t)=>{var a,o;const n=II(e),i=n?e.clientX:(a=e.touches)==null?void 0:a[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},PT=(e,t,n,i,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(o=>{const c=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:e,nodeId:s,position:o.getAttribute("data-handlepos"),x:(c.left-n.left)/i,y:(c.top-n.top)/i,...kw(o)}})};function PI({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:s,sourceControlY:a,targetControlX:o,targetControlY:c}){const u=e*.125+s*.375+o*.375+n*.125,f=t*.125+a*.375+c*.375+i*.125,m=Math.abs(u-e),p=Math.abs(f-t);return[u,f,m,p]}function pp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function zT({pos:e,x1:t,y1:n,x2:i,y2:s,c:a}){switch(e){case Je.Left:return[t-pp(t-i,a),n];case Je.Right:return[t+pp(i-t,a),n];case Je.Top:return[t,n-pp(n-s,a)];case Je.Bottom:return[t,n+pp(s-n,a)]}}function zI({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top,curvature:o=.25}){const[c,u]=zT({pos:n,x1:e,y1:t,x2:i,y2:s,c:o}),[f,m]=zT({pos:a,x1:i,y1:s,x2:e,y2:t,c:o}),[p,y,b,x]=PI({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:m});return[`M${e},${t} C${c},${u} ${f},${m} ${i},${s}`,p,y,b,x]}function BI({sourceX:e,sourceY:t,targetX:n,targetY:i}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,o=Math.abs(i-t)/2,c=i<t?i+o:i-o;return[a,c,s,o]}function ole({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return i;const o=s&&n?i+1e3:i,c=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return o+c}function lle({sourceNode:e,targetNode:t,width:n,height:i,transform:s}){const a=dg(Nm(e),Nm(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const o={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:i/s[2]};return _m(o,fg(a))>0}const UI=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,cle=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),ule=(e,t,n={})=>{var a;if(!e.source||!e.target)return(a=n.onError)==null||a.call(n,"006",as.error006()),t;const i=n.getEdgeId||UI;let s;return _I(e)?s={...e}:s={...e,id:i(e)},cle(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))},dle=(e,t,n,i={shouldReplaceId:!0})=>{var f,m;const{id:s,...a}=e;if(!t.source||!t.target)return(f=i.onError)==null||f.call(i,"006",as.error006()),n;if(!n.find(p=>p.id===e.id))return(m=i.onError)==null||m.call(i,"007",as.error007(s)),n;const c=i.getEdgeId||UI,u={...a,id:i.shouldReplaceId?c(t):s,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(p=>p.id!==s).concat(u)};function FI({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[s,a,o,c]=BI({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,s,a,o,c]}const BT={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},fle=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},UT=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hle({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:i=Je.Top,center:s,offset:a,stepPosition:o}){const c=BT[t],u=BT[i],f={x:e.x+c.x*a,y:e.y+c.y*a},m={x:n.x+u.x*a,y:n.y+u.y*a},p=fle({source:f,sourcePosition:t,target:m}),y=p.x!==0?"x":"y",b=p[y];let x=[],w,E;const v={x:0,y:0},_={x:0,y:0},[,,k,T]=BI({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[y]*u[y]===-1){y==="x"?(w=s.x??f.x+(m.x-f.x)*o,E=s.y??(f.y+m.y)/2):(w=s.x??(f.x+m.x)/2,E=s.y??f.y+(m.y-f.y)*o);const D=[{x:w,y:f.y},{x:w,y:m.y}],I=[{x:f.x,y:E},{x:m.x,y:E}];c[y]===b?x=y==="x"?D:I:x=y==="x"?I:D}else{const D=[{x:f.x,y:m.y}],I=[{x:m.x,y:f.y}];if(y==="x"?x=c.x===b?I:D:x=c.y===b?D:I,t===i){const O=Math.abs(e[y]-n[y]);if(O<=a){const R=Math.min(a-1,a-O);c[y]===b?v[y]=(f[y]>e[y]?-1:1)*R:_[y]=(m[y]>n[y]?-1:1)*R}}if(t!==i){const O=y==="x"?"y":"x",R=c[y]===u[O],z=f[O]>m[O],G=f[O]<m[O];(c[y]===1&&(!R&&z||R&&G)||c[y]!==1&&(!R&&G||R&&z))&&(x=y==="x"?D:I)}const P={x:f.x+v.x,y:f.y+v.y},U={x:m.x+_.x,y:m.y+_.y},q=Math.max(Math.abs(P.x-x[0].x),Math.abs(U.x-x[0].x)),V=Math.max(Math.abs(P.y-x[0].y),Math.abs(U.y-x[0].y));q>=V?(w=(P.x+U.x)/2,E=x[0].y):(w=x[0].x,E=(P.y+U.y)/2)}const A={x:f.x+v.x,y:f.y+v.y},j={x:m.x+_.x,y:m.y+_.y};return[[e,...A.x!==x[0].x||A.y!==x[0].y?[A]:[],...x,...j.x!==x[x.length-1].x||j.y!==x[x.length-1].y?[j]:[],n],w,E,k,T]}function ple(e,t,n,i){const s=Math.min(UT(e,t)/2,UT(t,n)/2,i),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){const f=e.x<n.x?-1:1,m=e.y<n.y?1:-1;return`L ${a+s*f},${o}Q ${a},${o} ${a},${o+s*m}`}const c=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${a},${o+s*u}Q ${a},${o} ${a+s*c},${o}`}function Ev({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top,borderRadius:o=5,centerX:c,centerY:u,offset:f=20,stepPosition:m=.5}){const[p,y,b,x,w]=hle({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:s},targetPosition:a,center:{x:c,y:u},offset:f,stepPosition:m});let E=`M${p[0].x} ${p[0].y}`;for(let v=1;v<p.length-1;v++)E+=ple(p[v-1],p[v],p[v+1],o);return E+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[E,y,b,x,w]}function FT(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mle(e){var p;const{sourceNode:t,targetNode:n}=e;if(!FT(t)||!FT(n))return null;const i=t.internals.handleBounds||$T(t.handles),s=n.internals.handleBounds||$T(n.handles),a=qT((i==null?void 0:i.source)??[],e.sourceHandle),o=qT(e.connectionMode===Bc.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!a||!o)return(p=e.onError)==null||p.call(e,"008",as.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(a==null?void 0:a.position)||Je.Bottom,u=(o==null?void 0:o.position)||Je.Top,f=ul(t,a,c),m=ul(n,o,u);return{sourceX:f.x,sourceY:f.y,targetX:m.x,targetY:m.y,sourcePosition:c,targetPosition:u}}function $T(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function ul(e,t,n=Je.Left,i=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,a=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:c}=t??ia(e);if(i)return{x:s+o/2,y:a+c/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:s+o/2,y:a};case Je.Right:return{x:s+o,y:a+c/2};case Je.Bottom:return{x:s+o/2,y:a+c};case Je.Left:return{x:s,y:a+c/2}}}function qT(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Sv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function gle(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:s}){const a=new Set;return e.reduce((o,c)=>([c.markerStart||i,c.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const f=Sv(u,t);a.has(f)||(o.push({id:f,color:u.color||n,...u}),a.add(f))}}),o),[]).sort((o,c)=>o.id.localeCompare(c.id))}const $I=1e3,yle=10,Nw={nodeOrigin:[0,0],nodeExtent:Kd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ble={...Nw,checkEquality:!0};function _w(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function xle(e,t,n){const i=_w(Nw,n);for(const s of e.values())if(s.parentId)Tw(s,e,t,i);else{const a=Sf(s,i.nodeOrigin),o=cl(s.extent)?s.extent:i.nodeExtent,c=ll(a,o,ia(s));s.internals.positionAbsolute=c}}function vle(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&i.push(a)}return{source:n,target:i}}function Cw(e){return e==="manual"}function kv(e,t,n,i={}){var m,p;const s=_w(ble,i),a={i:0},o=new Map(t),c=s!=null&&s.elevateNodesOnSelect&&!Cw(s.zIndexMode)?$I:0;let u=e.length>0,f=!1;t.clear(),n.clear();for(const y of e){let b=o.get(y.id);if(s.checkEquality&&y===(b==null?void 0:b.internals.userNode))t.set(y.id,b);else{const x=Sf(y,s.nodeOrigin),w=cl(y.extent)?y.extent:s.nodeExtent,E=ll(x,w,ia(y));b={...s.defaults,...y,measured:{width:(m=y.measured)==null?void 0:m.width,height:(p=y.measured)==null?void 0:p.height},internals:{positionAbsolute:E,handleBounds:vle(y,b),z:qI(y,c,s.zIndexMode),userNode:y}},t.set(y.id,b)}(b.measured===void 0||b.measured.width===void 0||b.measured.height===void 0)&&!b.hidden&&(u=!1),y.parentId&&Tw(b,t,n,i,a),f||(f=y.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:f}}function wle(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Tw(e,t,n,i,s){const{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:c,zIndexMode:u}=_w(Nw,i),f=e.parentId,m=t.get(f);if(!m){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}wle(e,n),s&&!m.parentId&&m.internals.rootParentIndex===void 0&&u==="auto"&&(m.internals.rootParentIndex=++s.i,m.internals.z=m.internals.z+s.i*yle),s&&m.internals.rootParentIndex!==void 0&&(s.i=m.internals.rootParentIndex);const p=a&&!Cw(u)?$I:0,{x:y,y:b,z:x}=Ele(e,m,o,c,p,u),{positionAbsolute:w}=e.internals,E=y!==w.x||b!==w.y;(E||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:E?{x:y,y:b}:w,z:x}})}function qI(e,t,n){const i=Bs(e.zIndex)?e.zIndex:0;return Cw(n)?i:i+(e.selected?t:0)}function Ele(e,t,n,i,s,a){const{x:o,y:c}=t.internals.positionAbsolute,u=ia(e),f=Sf(e,n),m=cl(e.extent)?ll(f,e.extent,u):f;let p=ll({x:o+m.x,y:c+m.y},i,u);e.extent==="parent"&&(p=TI(p,u,t));const y=qI(e,s,a),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=y?b+1:y}}function Aw(e,t,n,i=[0,0]){var o;const s=[],a=new Map;for(const c of e){const u=t.get(c.parentId);if(!u)continue;const f=((o=a.get(c.parentId))==null?void 0:o.expandedRect)??Wd(u),m=AI(f,c.rect);a.set(c.parentId,{expandedRect:m,parent:u})}return a.size>0&&a.forEach(({expandedRect:c,parent:u},f)=>{var k;const m=u.internals.positionAbsolute,p=ia(u),y=u.origin??i,b=c.x<m.x?Math.round(Math.abs(m.x-c.x)):0,x=c.y<m.y?Math.round(Math.abs(m.y-c.y)):0,w=Math.max(p.width,Math.round(c.width)),E=Math.max(p.height,Math.round(c.height)),v=(w-p.width)*y[0],_=(E-p.height)*y[1];(b>0||x>0||v||_)&&(s.push({id:f,type:"position",position:{x:u.position.x-b+v,y:u.position.y-x+_}}),(k=n.get(f))==null||k.forEach(T=>{e.some(A=>A.id===T.id)||s.push({id:T.id,type:"position",position:{x:T.position.x+b,y:T.position.y+x}})})),(p.width<c.width||p.height<c.height||b||x)&&s.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:w+(b?y[0]*b-v:0),height:E+(x?y[1]*x-_:0)}})}),s}function Sle(e,t,n,i,s,a,o){const c=i==null?void 0:i.querySelector(".xyflow__viewport");let u=!1;if(!c)return{changes:[],updatedInternals:u};const f=[],m=window.getComputedStyle(c),{m22:p}=new window.DOMMatrixReadOnly(m.transform),y=[];for(const b of e.values()){const x=t.get(b.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),u=!0;continue}const w=kw(b.nodeElement),E=x.measured.width!==w.width||x.measured.height!==w.height;if(!!(w.width&&w.height&&(E||!x.internals.handleBounds||b.force))){const _=b.nodeElement.getBoundingClientRect(),k=cl(x.extent)?x.extent:a;let{positionAbsolute:T}=x.internals;x.parentId&&x.extent==="parent"?T=TI(T,w,t.get(x.parentId)):k&&(T=ll(T,k,w));const A={...x,measured:w,internals:{...x.internals,positionAbsolute:T,handleBounds:{source:PT("source",b.nodeElement,_,p,x.id),target:PT("target",b.nodeElement,_,p,x.id)}}};t.set(x.id,A),x.parentId&&Tw(A,t,n,{nodeOrigin:s,zIndexMode:o}),u=!0,E&&(f.push({id:x.id,type:"dimensions",dimensions:w}),x.expandParent&&x.parentId&&y.push({id:x.id,parentId:x.parentId,rect:Wd(A,s)}))}}if(y.length>0){const b=Aw(y,t,n,s);f.push(...b)}return{changes:f,updatedInternals:u}}async function kle({delta:e,panZoom:t,transform:n,translateExtent:i,width:s,height:a}){if(!t||!e.x&&!e.y)return!1;const o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],i);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function HT(e,t,n,i,s,a){let o=s;const c=i.get(o)||new Map;i.set(o,c.set(n,t)),o=`${s}-${e}`;const u=i.get(o)||new Map;if(i.set(o,u.set(n,t)),a){o=`${s}-${e}-${a}`;const f=i.get(o)||new Map;i.set(o,f.set(n,t))}}function HI(e,t,n){e.clear(),t.clear();for(const i of n){const{source:s,target:a,sourceHandle:o=null,targetHandle:c=null}=i,u={edgeId:i.id,source:s,target:a,sourceHandle:o,targetHandle:c},f=`${s}-${o}--${a}-${c}`,m=`${a}-${c}--${s}-${o}`;HT("source",u,m,e,s,o),HT("target",u,f,e,a,c),t.set(i.id,i)}}function VI(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:VI(n,t):!1}function VT(e,t,n){var s;let i=e;do{if((s=i==null?void 0:i.matches)!=null&&s.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Nle(e,t,n,i){const s=new Map;for(const[a,o]of e)if((o.selected||o.id===i)&&(!o.parentId||!VI(o,e))&&(o.draggable||t&&typeof o.draggable>"u")){const c=e.get(a);c&&s.set(a,{id:a,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return s}function Px({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var o,c,u;const s=[];for(const[f,m]of t){const p=(o=n.get(f))==null?void 0:o.internals.userNode;p&&s.push({...p,position:m.position,dragging:i})}if(!e)return[s[0],s];const a=(c=n.get(e))==null?void 0:c.internals.userNode;return[a?{...a,position:((u=t.get(e))==null?void 0:u.position)||a.position,dragging:i}:s[0],s]}function _le({dragItems:e,snapGrid:t,x:n,y:i}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:i-s.distance.y},o=Nf(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Cle({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:s}){let a={x:null,y:null},o=0,c=new Map,u=!1,f={x:0,y:0},m=null,p=!1,y=null,b=!1,x=!1,w=null;function E({noDragClassName:_,handleSelector:k,domNode:T,isSelectable:A,nodeId:j,nodeClickDistance:M=0}){y=ns(T);function D({x:q,y:V}){const{nodeLookup:O,nodeExtent:R,snapGrid:z,snapToGrid:G,nodeOrigin:Y,onNodeDrag:K,onSelectionDrag:B,onError:F,updateNodePositions:W}=t();a={x:q,y:V};let $=!1;const ae=c.size>1,be=ae&&R?wv(kf(c)):null,le=ae&&G?_le({dragItems:c,snapGrid:z,x:q,y:V}):null;for(const[Ne,re]of c){if(!O.has(Ne))continue;let me={x:q-re.distance.x,y:V-re.distance.y};G&&(me=le?{x:Math.round(me.x+le.x),y:Math.round(me.y+le.y)}:Nf(me,z));let se=null;if(ae&&R&&!re.extent&&be){const{positionAbsolute:_e}=re.internals,ze=_e.x-be.x+R[0][0],fe=_e.x+re.measured.width-be.x2+R[1][0],Se=_e.y-be.y+R[0][1],Re=_e.y+re.measured.height-be.y2+R[1][1];se=[[ze,Se],[fe,Re]]}const{position:Q,positionAbsolute:ye}=CI({nodeId:Ne,nextPosition:me,nodeLookup:O,nodeExtent:se||R,nodeOrigin:Y,onError:F});$=$||re.position.x!==Q.x||re.position.y!==Q.y,re.position=Q,re.internals.positionAbsolute=ye}if(x=x||$,!!$&&(W(c,!0),w&&(i||K||!j&&B))){const[Ne,re]=Px({nodeId:j,dragItems:c,nodeLookup:O});i==null||i(w,c,Ne,re),K==null||K(w,Ne,re),j||B==null||B(w,re)}}async function I(){if(!m)return;const{transform:q,panBy:V,autoPanSpeed:O,autoPanOnNodeDrag:R}=t();if(!R){u=!1,cancelAnimationFrame(o);return}const[z,G]=Ew(f,m,O);(z!==0||G!==0)&&(a.x=(a.x??0)-z/q[2],a.y=(a.y??0)-G/q[2],await V({x:z,y:G})&&D(a)),o=requestAnimationFrame(I)}function P(q){var ae;const{nodeLookup:V,multiSelectionActive:O,nodesDraggable:R,transform:z,snapGrid:G,snapToGrid:Y,selectNodesOnDrag:K,onNodeDragStart:B,onSelectionDragStart:F,unselectNodesAndEdges:W}=t();p=!0,(!K||!A)&&!O&&j&&((ae=V.get(j))!=null&&ae.selected||W()),A&&K&&j&&(e==null||e(j));const $=_d(q.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Y,containerBounds:m});if(a=$,c=Nle(V,R,$,j),c.size>0&&(n||B||!j&&F)){const[be,le]=Px({nodeId:j,dragItems:c,nodeLookup:V});n==null||n(q.sourceEvent,c,be,le),B==null||B(q.sourceEvent,be,le),j||F==null||F(q.sourceEvent,le)}}const U=aI().clickDistance(M).on("start",q=>{const{domNode:V,nodeDragThreshold:O,transform:R,snapGrid:z,snapToGrid:G}=t();m=(V==null?void 0:V.getBoundingClientRect())||null,b=!1,x=!1,w=q.sourceEvent,O===0&&P(q),a=_d(q.sourceEvent,{transform:R,snapGrid:z,snapToGrid:G,containerBounds:m}),f=Us(q.sourceEvent,m)}).on("drag",q=>{const{autoPanOnNodeDrag:V,transform:O,snapGrid:R,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Y}=t(),K=_d(q.sourceEvent,{transform:O,snapGrid:R,snapToGrid:z,containerBounds:m});if(w=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||j&&!Y.has(j))&&(b=!0),!b){if(!u&&V&&p&&(u=!0,I()),!p){const B=Us(q.sourceEvent,m),F=B.x-f.x,W=B.y-f.y;Math.sqrt(F*F+W*W)>G&&P(q)}(a.x!==K.xSnapped||a.y!==K.ySnapped)&&c&&p&&(f=Us(q.sourceEvent,m),D(K))}}).on("end",q=>{if(!p||b){b&&c.size>0&&t().updateNodePositions(c,!1);return}if(u=!1,p=!1,cancelAnimationFrame(o),c.size>0){const{nodeLookup:V,updateNodePositions:O,onNodeDragStop:R,onSelectionDragStop:z}=t();if(x&&(O(c,!1),x=!1),s||R||!j&&z){const[G,Y]=Px({nodeId:j,dragItems:c,nodeLookup:V,dragging:!1});s==null||s(q.sourceEvent,c,G,Y),R==null||R(q.sourceEvent,G,Y),j||z==null||z(q.sourceEvent,Y)}}}).filter(q=>{const V=q.target;return!q.button&&(!_||!VT(V,`.${_}`,T))&&(!k||VT(V,k,T))});y.call(U)}function v(){y==null||y.on(".drag",null)}return{update:E,destroy:v}}function Tle(e,t,n){const i=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())_m(s,Wd(a))>0&&i.push(a);return i}const Ale=250;function jle(e,t,n,i){var c,u;let s=[],a=1/0;const o=Tle(e,n,t+Ale);for(const f of o){const m=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((u=f.internals.handleBounds)==null?void 0:u.target)??[]];for(const p of m){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:y,y:b}=ul(f,p,p.position,!0),x=Math.sqrt(Math.pow(y-e.x,2)+Math.pow(b-e.y,2));x>t||(x<a?(s=[{...p,x:y,y:b}],a=x):x===a&&s.push({...p,x:y,y:b}))}}if(!s.length)return null;if(s.length>1){const f=i.type==="source"?"target":"source";return s.find(m=>m.type===f)??s[0]}return s[0]}function KI(e,t,n,i,s,a=!1){var f,m,p;const o=i.get(e);if(!o)return null;const c=s==="strict"?(f=o.internals.handleBounds)==null?void 0:f[t]:[...((m=o.internals.handleBounds)==null?void 0:m.source)??[],...((p=o.internals.handleBounds)==null?void 0:p.target)??[]],u=(n?c==null?void 0:c.find(y=>y.id===n):c==null?void 0:c[0])??null;return u&&a?{...u,...ul(o,u,u.position,!0)}:u}function GI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Mle(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const WI=()=>!0;function Rle(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:s,edgeUpdaterType:a,isTarget:o,domNode:c,nodeLookup:u,lib:f,autoPanOnConnect:m,flowId:p,panBy:y,cancelConnection:b,onConnectStart:x,onConnect:w,onConnectEnd:E,isValidConnection:v=WI,onReconnectEnd:_,updateConnection:k,getTransform:T,getFromHandle:A,autoPanSpeed:j,dragThreshold:M=1,handleDomNode:D}){const I=OI(e.target);let P=0,U;const{x:q,y:V}=Us(e),O=GI(a,D),R=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!R||!O)return;const G=KI(s,O,i,u,t);if(!G)return;let Y=Us(e,R),K=!1,B=null,F=!1,W=null;function $(){if(!m||!R)return;const[Q,ye]=Ew(Y,R,j);y({x:Q,y:ye}),P=requestAnimationFrame($)}const ae={...G,nodeId:s,type:O,position:G.position},be=u.get(s);let Ne={inProgress:!0,isValid:null,from:ul(be,ae,Je.Left,!0),fromHandle:ae,fromPosition:ae.position,fromNode:be,to:Y,toHandle:null,toPosition:DT[ae.position],toNode:null,pointer:Y};function re(){z=!0,k(Ne),x==null||x(e,{nodeId:s,handleId:i,handleType:O})}M===0&&re();function me(Q){if(!z){const{x:Re,y:Qe}=Us(Q),ht=Re-q,it=Qe-V;if(!(ht*ht+it*it>M*M))return;re()}if(!A()||!ae){se(Q);return}const ye=T();Y=Us(Q,R),U=jle(_f(Y,ye,!1,[1,1]),n,u,ae),K||($(),K=!0);const _e=YI(Q,{handle:U,connectionMode:t,fromNodeId:s,fromHandleId:i,fromType:o?"target":"source",isValidConnection:v,doc:I,lib:f,flowId:p,nodeLookup:u});W=_e.handleDomNode,B=_e.connection,F=Mle(!!U,_e.isValid);const ze=u.get(s),fe=ze?ul(ze,ae,Je.Left,!0):Ne.from,Se={...Ne,from:fe,isValid:F,to:_e.toHandle&&F?Fc({x:_e.toHandle.x,y:_e.toHandle.y},ye):Y,toHandle:_e.toHandle,toPosition:F&&_e.toHandle?_e.toHandle.position:DT[ae.position],toNode:_e.toHandle?u.get(_e.toHandle.nodeId):null,pointer:Y};k(Se),Ne=Se}function se(Q){if(!("touches"in Q&&Q.touches.length>0)){if(z){(U||W)&&B&&F&&(w==null||w(B));const{inProgress:ye,..._e}=Ne,ze={..._e,toPosition:Ne.toHandle?Ne.toPosition:null};E==null||E(Q,ze),a&&(_==null||_(Q,ze))}b(),cancelAnimationFrame(P),K=!1,F=!1,B=null,W=null,I.removeEventListener("mousemove",me),I.removeEventListener("mouseup",se),I.removeEventListener("touchmove",me),I.removeEventListener("touchend",se)}}I.addEventListener("mousemove",me),I.addEventListener("mouseup",se),I.addEventListener("touchmove",me),I.addEventListener("touchend",se)}function YI(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:a,doc:o,lib:c,flowId:u,isValidConnection:f=WI,nodeLookup:m}){const p=a==="target",y=t?o.querySelector(`.${c}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:x}=Us(e),w=o.elementFromPoint(b,x),E=w!=null&&w.classList.contains(`${c}-flow__handle`)?w:y,v={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const _=GI(void 0,E),k=E.getAttribute("data-nodeid"),T=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),j=E.classList.contains("connectableend");if(!k||!_)return v;const M={source:p?k:i,sourceHandle:p?T:s,target:p?i:k,targetHandle:p?s:T};v.connection=M;const I=A&&j&&(n===Bc.Strict?p&&_==="source"||!p&&_==="target":k!==i||T!==s);v.isValid=I&&f(M),v.toHandle=KI(k,_,T,m,n,!0)}return v}const Nv={onPointerDown:Rle,isValid:YI};function Dle({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const s=ns(e);function a({translateExtent:c,width:u,height:f,zoomStep:m=1,pannable:p=!0,zoomable:y=!0,inversePan:b=!1}){const x=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const T=n(),A=k.sourceEvent.ctrlKey&&Yd()?10:1,j=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,M=T[2]*Math.pow(2,j*A);t.scaleTo(M)};let w=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(w=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},v=k=>{const T=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],j=[A[0]-w[0],A[1]-w[1]];w=A;const M=i()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),D={x:T[0]-j[0]*M,y:T[1]-j[1]*M},I=[[0,0],[u,f]];t.setViewportConstrained({x:D.x,y:D.y,zoom:T[2]},I,c)},_=wI().on("start",E).on("zoom",p?v:null).on("zoom.wheel",y?x:null);s.call(_,{})}function o(){s.on("zoom",null)}return{update:a,destroy:o,pointer:Is}}const hg=e=>({x:e.x,y:e.y,zoom:e.k}),zx=({x:e,y:t,zoom:n})=>ug.translate(e,t).scale(n),cc=(e,t)=>e.target.closest(`.${t}`),XI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ole=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Bx=(e,t=0,n=Ole,i=()=>{})=>{const s=typeof t=="number"&&t>0;return s||i(),s?e.transition().duration(t).ease(n).on("end",i):e},QI=e=>{const t=e.ctrlKey&&Yd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Lle({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:f}){return m=>{if(cc(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(m.ctrlKey&&o){const E=Is(m),v=QI(m),_=p*Math.pow(2,v);i.scaleTo(n,_,E,m);return}const y=m.deltaMode===1?20:1;let b=s===Jo.Vertical?0:m.deltaX*y,x=s===Jo.Horizontal?0:m.deltaY*y;!Yd()&&m.shiftKey&&s!==Jo.Vertical&&(b=m.deltaY*y,x=0),i.translateBy(n,-(b/p)*a,-(x/p)*a,{internal:!0});const w=hg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(m,w),e.panScrollTimeout=setTimeout(()=>{f==null||f(m,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,w))}}function Ile({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,s){const a=i.type==="wheel",o=!t&&a&&!i.ctrlKey,c=cc(i,e);if(i.ctrlKey&&a&&c&&i.preventDefault(),o||c)return null;i.preventDefault(),n.call(this,i,s)}}function Ple({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var a,o,c;if((a=i.sourceEvent)!=null&&a.internal)return;const s=hg(i.transform);e.mouseButton=((o=i.sourceEvent)==null?void 0:o.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((c=i.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,s))}}function zle({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:s}){return a=>{var o,c;e.usedRightMouseButton=!!(n&&XI(t,e.mouseButton??0)),(o=a.sourceEvent)!=null&&o.sync||i([a.transform.x,a.transform.y,a.transform.k]),s&&!((c=a.sourceEvent)!=null&&c.internal)&&(s==null||s(a.sourceEvent,hg(a.transform)))}}function Ble({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:s,onPaneContextMenu:a}){return o=>{var c;if(!((c=o.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,a&&XI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,i(!1),s)){const u=hg(o.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,u)},n?150:0)}}}function Ule({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:c,noPanClassName:u,lib:f,connectionInProgress:m}){return p=>{var E;const y=e||t,b=n&&p.ctrlKey,x=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(cc(p,`${f}-flow__node`)||cc(p,`${f}-flow__edge`)))return!0;if(!i&&!y&&!s&&!a&&!n||o||m&&!x||cc(p,c)&&x||cc(p,u)&&(!x||s&&x&&!e)||!n&&p.ctrlKey&&x)return!1;if(!n&&p.type==="touchstart"&&((E=p.touches)==null?void 0:E.length)>1)return p.preventDefault(),!1;if(!y&&!s&&!b&&x||!i&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(i)&&!i.includes(p.button)&&p.type==="mousedown")return!1;const w=Array.isArray(i)&&i.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||x)&&w}}function Fle({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:s,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:c,onDraggingChange:u}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=wI().scaleExtent([t,n]).translateExtent(i),y=ns(e).call(p);_({x:s.x,y:s.y,zoom:Uc(s.zoom,t,n)},[[0,0],[m.width,m.height]],i);const b=y.on("wheel.zoom"),x=y.on("dblclick.zoom");p.wheelDelta(QI);async function w(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).transform(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}function E({noWheelClassName:U,noPanClassName:q,onPaneContextMenu:V,userSelectionActive:O,panOnScroll:R,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Y,preventScrolling:K,zoomOnPinch:B,zoomOnScroll:F,zoomOnDoubleClick:W,zoomActivationKeyPressed:$,lib:ae,onTransformChange:be,connectionInProgress:le,paneClickDistance:Ne,selectionOnDrag:re}){O&&!f.isZoomingOrPanning&&v();const me=R&&!$&&!O;p.clickDistance(re?1/0:!Bs(Ne)||Ne<0?0:Ne);const se=me?Lle({zoomPanValues:f,noWheelClassName:U,d3Selection:y,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Y,zoomOnPinch:B,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:c}):Ile({noWheelClassName:U,preventScrolling:K,d3ZoomHandler:b});y.on("wheel.zoom",se,{passive:!1});const Q=Ple({zoomPanValues:f,onDraggingChange:u,onPanZoomStart:o});p.on("start",Q);const ye=zle({zoomPanValues:f,panOnDrag:z,onPaneContextMenu:!!V,onPanZoom:a,onTransformChange:be});p.on("zoom",ye);const _e=Ble({zoomPanValues:f,panOnDrag:z,panOnScroll:R,onPaneContextMenu:V,onPanZoomEnd:c,onDraggingChange:u});p.on("end",_e);const ze=Ule({zoomActivationKeyPressed:$,panOnDrag:z,zoomOnScroll:F,panOnScroll:R,zoomOnDoubleClick:W,zoomOnPinch:B,userSelectionActive:O,noPanClassName:q,noWheelClassName:U,lib:ae,connectionInProgress:le});p.filter(ze),W?y.on("dblclick.zoom",x):y.on("dblclick.zoom",null)}function v(){p.on("zoom",null)}async function _(U,q,V){const O=zx(U),R=p==null?void 0:p.constrain()(O,q,V);return R&&await w(R),R}async function k(U,q){const V=zx(U);return await w(V,q),V}function T(U){if(y){const q=zx(U),V=y.property("__zoom");(V.k!==U.zoom||V.x!==U.x||V.y!==U.y)&&(p==null||p.transform(y,q,null,{sync:!0}))}}function A(){const U=y?vI(y.node()):{x:0,y:0,k:1};return{x:U.x,y:U.y,zoom:U.k}}async function j(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).scaleTo(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}async function M(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).scaleBy(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}function D(U){p==null||p.scaleExtent(U)}function I(U){p==null||p.translateExtent(U)}function P(U){const q=!Bs(U)||U<0?0:U;p==null||p.clickDistance(q)}return{update:E,destroy:v,setViewport:k,setViewportConstrained:_,getViewport:A,scaleTo:j,scaleBy:M,setScaleExtent:D,setTranslateExtent:I,syncViewport:T,setClickDistance:P}}var $c;(function(e){e.Line="line",e.Handle="handle"})($c||($c={}));function $le({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:s,affectsY:a}){const o=e-t,c=n-i,u=[o>0?1:o<0?-1:0,c>0?1:c<0?-1:0];return o&&s&&(u[0]=u[0]*-1),c&&a&&(u[1]=u[1]*-1),u}function KT(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:s}}function Ia(e,t){return Math.max(0,t-e)}function Pa(e,t){return Math.max(0,e-t)}function mp(e,t,n){return Math.max(0,t-e,e-n)}function GT(e,t){return e?!t:t}function qle(e,t,n,i,s,a,o,c){let{affectsX:u,affectsY:f}=t;const{isHorizontal:m,isVertical:p}=t,y=m&&p,{xSnapped:b,ySnapped:x}=n,{minWidth:w,maxWidth:E,minHeight:v,maxHeight:_}=i,{x:k,y:T,width:A,height:j,aspectRatio:M}=e;let D=Math.floor(m?b-e.pointerX:0),I=Math.floor(p?x-e.pointerY:0);const P=A+(u?-D:D),U=j+(f?-I:I),q=-a[0]*A,V=-a[1]*j;let O=mp(P,w,E),R=mp(U,v,_);if(o){let Y=0,K=0;u&&D<0?Y=Ia(k+D+q,o[0][0]):!u&&D>0&&(Y=Pa(k+P+q,o[1][0])),f&&I<0?K=Ia(T+I+V,o[0][1]):!f&&I>0&&(K=Pa(T+U+V,o[1][1])),O=Math.max(O,Y),R=Math.max(R,K)}if(c){let Y=0,K=0;u&&D>0?Y=Pa(k+D,c[0][0]):!u&&D<0&&(Y=Ia(k+P,c[1][0])),f&&I>0?K=Pa(T+I,c[0][1]):!f&&I<0&&(K=Ia(T+U,c[1][1])),O=Math.max(O,Y),R=Math.max(R,K)}if(s){if(m){const Y=mp(P/M,v,_)*M;if(O=Math.max(O,Y),o){let K=0;!u&&!f||u&&!f&&y?K=Pa(T+V+P/M,o[1][1])*M:K=Ia(T+V+(u?D:-D)/M,o[0][1])*M,O=Math.max(O,K)}if(c){let K=0;!u&&!f||u&&!f&&y?K=Ia(T+P/M,c[1][1])*M:K=Pa(T+(u?D:-D)/M,c[0][1])*M,O=Math.max(O,K)}}if(p){const Y=mp(U*M,w,E)/M;if(R=Math.max(R,Y),o){let K=0;!u&&!f||f&&!u&&y?K=Pa(k+U*M+q,o[1][0])/M:K=Ia(k+(f?I:-I)*M+q,o[0][0])/M,R=Math.max(R,K)}if(c){let K=0;!u&&!f||f&&!u&&y?K=Ia(k+U*M,c[1][0])/M:K=Pa(k+(f?I:-I)*M,c[0][0])/M,R=Math.max(R,K)}}}I=I+(I<0?R:-R),D=D+(D<0?O:-O),s&&(y?P>U*M?I=(GT(u,f)?-D:D)/M:D=(GT(u,f)?-I:I)*M:m?(I=D/M,f=u):(D=I*M,u=f));const z=u?k+D:k,G=f?T+I:T;return{width:A+(u?-D:D),height:j+(f?-I:I),x:a[0]*D*(u?-1:1)+z,y:a[1]*I*(f?-1:1)+G}}const ZI={width:0,height:0,x:0,y:0},Hle={...ZI,pointerX:0,pointerY:0,aspectRatio:1};function Vle(e,t,n){const i=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,c=n[0]*a,u=n[1]*o;return[[i-c,s-u],[i+a-c,s+o-u]]}function Kle({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:s}){const a=ns(e);let o={controlDirection:KT("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:m,keepAspectRatio:p,resizeDirection:y,onResizeStart:b,onResize:x,onResizeEnd:w,shouldResize:E}){let v={...ZI},_={...Hle};o={boundaries:m,resizeDirection:y,keepAspectRatio:p,controlDirection:KT(f)};let k,T=null,A=[],j,M,D,I=!1;const P=aI().on("start",U=>{const{nodeLookup:q,transform:V,snapGrid:O,snapToGrid:R,nodeOrigin:z,paneDomNode:G}=n();if(k=q.get(t),!k)return;T=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Y,ySnapped:K}=_d(U.sourceEvent,{transform:V,snapGrid:O,snapToGrid:R,containerBounds:T});v={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},_={...v,pointerX:Y,pointerY:K,aspectRatio:v.width/v.height},j=void 0,M=cl(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(j=q.get(k.parentId)),j&&k.extent==="parent"&&(M=[[0,0],[j.measured.width,j.measured.height]]),A=[],D=void 0;for(const[B,F]of q)if(F.parentId===t&&(A.push({id:B,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const W=Vle(F,k,F.origin??z);D?D=[[Math.min(W[0][0],D[0][0]),Math.min(W[0][1],D[0][1])],[Math.max(W[1][0],D[1][0]),Math.max(W[1][1],D[1][1])]]:D=W}b==null||b(U,{...v})}).on("drag",U=>{const{transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R}=n(),z=_d(U.sourceEvent,{transform:q,snapGrid:V,snapToGrid:O,containerBounds:T}),G=[];if(!k)return;const{x:Y,y:K,width:B,height:F}=v,W={},$=k.origin??R,{width:ae,height:be,x:le,y:Ne}=qle(_,o.controlDirection,z,o.boundaries,o.keepAspectRatio,$,M,D),re=ae!==B,me=be!==F,se=le!==Y&&re,Q=Ne!==K&&me;if(!se&&!Q&&!re&&!me)return;if((se||Q||$[0]===1||$[1]===1)&&(W.x=se?le:v.x,W.y=Q?Ne:v.y,v.x=W.x,v.y=W.y,A.length>0)){const fe=le-Y,Se=Ne-K;for(const Re of A)Re.position={x:Re.position.x-fe+$[0]*(ae-B),y:Re.position.y-Se+$[1]*(be-F)},G.push(Re)}if((re||me)&&(W.width=re&&(!o.resizeDirection||o.resizeDirection==="horizontal")?ae:v.width,W.height=me&&(!o.resizeDirection||o.resizeDirection==="vertical")?be:v.height,v.width=W.width,v.height=W.height),j&&k.expandParent){const fe=$[0]*(W.width??0);W.x&&W.x<fe&&(v.x=fe,_.x=_.x-(W.x-fe));const Se=$[1]*(W.height??0);W.y&&W.y<Se&&(v.y=Se,_.y=_.y-(W.y-Se))}const ye=$le({width:v.width,prevWidth:B,height:v.height,prevHeight:F,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),_e={...v,direction:ye};(E==null?void 0:E(U,_e))!==!1&&(I=!0,x==null||x(U,_e),i(W,G))}).on("end",U=>{I&&(w==null||w(U,{...v}),s==null||s({...v}),I=!1)});a.call(P)}function u(){a.on(".drag",null)}return{update:c,destroy:u}}var Ux={exports:{}},Fx={},$x={exports:{}},qx={};/**
|
|
831
|
+
# ...`,"aria-label":t("skills.import.body")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:f.isPending||!u||!o.trim(),onClick:()=>f.mutate(),children:[f.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(zj,{size:14,strokeWidth:3}),t("skills.import.submit")]})]})})}function eie({onClose:e,onSubmit:t}){const n=Xe(),[i,s]=C.useState(""),[a,o]=C.useState(""),c=/^[a-z0-9][a-z0-9-]*$/.test(i);return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold flex items-center gap-2",children:[d.jsx(il,{size:16,strokeWidth:2.5}),n("skills.ai.title")]}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:e,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("skills.ai.name")}),d.jsx("input",{type:"text",value:i,onChange:u=>s(u.target.value),placeholder:"rust-error-handling",className:"nb-input w-full font-[family-name:var(--font-mono)]","aria-label":n("skills.ai.name")})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("skills.ai.intent")}),d.jsx("textarea",{value:a,onChange:u=>o(u.target.value),placeholder:n("skills.ai.placeholder"),rows:5,className:"nb-input w-full text-sm","aria-label":n("skills.ai.intent")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:!c||!a.trim(),onClick:()=>t(i,a),children:[d.jsx(il,{size:14,strokeWidth:2.5}),n("skills.ai.submit")]})]})})})}async function tie(e){const{files:t}=await Vte(e),n=t["SKILL.md"]??"",i=new Blob([n],{type:"text/markdown"}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=`${e}.SKILL.md`,a.click(),URL.revokeObjectURL(s)}const nie=[{value:"all",labelKey:"skills.category.all"},{value:"language",labelKey:"skills.category.language"},{value:"domain",labelKey:"skills.category.domain"},{value:"persona",labelKey:"skills.category.persona"},{value:"workflow",labelKey:"skills.category.workflow"},{value:"engine",labelKey:"skills.category.engine"},{value:"genre",labelKey:"skills.category.genre"},{value:"platform",labelKey:"skills.category.platform"},{value:"review",labelKey:"skills.category.review"},{value:"meta",labelKey:"skills.category.meta"},{value:"other",labelKey:"skills.category.other"}],iie={language:"var(--color-accent-purple)",domain:"var(--color-secondary)",persona:"var(--color-primary)",workflow:"var(--color-accent-mint)",engine:"var(--color-accent-yellow)",genre:"var(--color-accent-pink)",platform:"var(--color-secondary-dark)",review:"var(--color-primary-dark)",meta:"var(--surface-control)",other:"var(--surface-control)"};function sie(){var q,V;const e=Xe(),[t,n]=C.useState("all"),[i,s]=C.useState([]),[a,o]=C.useState(""),[c,u]=C.useState(null),[f,m]=C.useState(!1),[p,y]=C.useState(!1),b=tn(),w=(((q=at({queryKey:["gen-jobs"],queryFn:UL,refetchInterval:3e3}).data)==null?void 0:q.data)??[]).filter(O=>O.kind==="skill"),E=w.filter(O=>O.status!=="done"),v=C.useRef(new Set);C.useEffect(()=>{for(const O of w)(O.status==="done"||O.status==="error")&&!v.current.has(O.id)&&(v.current.add(O.id),b.invalidateQueries({queryKey:["skills"]}),b.invalidateQueries({queryKey:["skill-updates"]}))},[w,b]);const _=(O,R)=>{Kte(O,R).then(()=>b.invalidateQueries({queryKey:["gen-jobs"]})).catch(()=>{})},T=(((V=at({queryKey:["skill-updates"],queryFn:qte}).data)==null?void 0:V.data)??[]).filter(O=>O.status!=="same").length,{data:A,isLoading:j}=at({queryKey:["skills"],queryFn:()=>ig()}),M=at({queryKey:["projects"],queryFn:ro}),D=C.useMemo(()=>((A==null?void 0:A.data)??[]).filter(R=>!(t!=="all"&&R.category!==t||i.length>0&&!R.tags.some(z=>i.includes(z))||a&&!R.name.toLowerCase().includes(a.toLowerCase()))),[A,t,i,a]),I=C.useMemo(()=>{const O=(A==null?void 0:A.data)??[],R={all:O.length};for(const z of O)R[z.category]=(R[z.category]??0)+1;return R},[A]),P=C.useMemo(()=>{const O=new Map;for(const R of(A==null?void 0:A.data)??[])for(const z of R.tags)O.set(z,(O.get(z)??0)+1);return[...O.entries()].sort((R,z)=>z[1]-R[1]||R[0].localeCompare(z[0]))},[A]),U=O=>s(R=>R.includes(O)?R.filter(z=>z!==O):[...R,O]);return d.jsxs("div",{className:"flex flex-col gap-4 max-w-full",children:[d.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:"Skills"}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:j?e("common.loading"):e("skills.subtitleCount",{count:(A==null?void 0:A.data.length)??0})})]}),d.jsxs("div",{className:"flex gap-3 items-center",children:[T>0&&d.jsx("span",{className:"nb-badge text-[10px]",title:e("skills.updates.badge",{count:String(T)}),children:e("skills.updates.badge",{count:String(T)})}),d.jsxs("button",{className:"nb-btn",onClick:()=>y(!0),type:"button",children:[d.jsx(il,{size:14,strokeWidth:2.5}),e("skills.ai")]}),d.jsxs("button",{className:"nb-btn",onClick:()=>m(!0),type:"button",children:[d.jsx(zj,{size:14,strokeWidth:2.5}),e("skills.import")]}),d.jsxs("button",{className:"nb-btn nb-btn-mint",onClick:async()=>{await Ute(),b.invalidateQueries({queryKey:["skills"]}),b.invalidateQueries({queryKey:["skill-updates"]})},type:"button",children:[d.jsx(ea,{size:14,strokeWidth:2.5}),"Sync bundled"]})]})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"relative shrink-0 w-full max-w-xs",children:[d.jsx(cf,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),d.jsx("input",{className:"nb-input pl-9 w-full",placeholder:e("skills.search.placeholder"),value:a,onChange:O=>o(O.target.value),"aria-label":e("skills.search.aria")})]}),d.jsx(Zc,{ariaLabel:"skill categories",className:"flex-1 min-w-0",value:t,onChange:n,options:nie.filter(O=>O.value==="all"||(I[O.value]??0)>0).map(O=>({value:O.value,label:d.jsxs(d.Fragment,{children:[e(O.labelKey)," ",I[O.value]??0]})}))})]}),P.length>0&&d.jsxs("div",{className:"flex items-start gap-2 flex-wrap",children:[d.jsx("span",{className:"text-xs font-bold text-[var(--color-text-muted)] pt-1.5 uppercase tracking-wider",children:e("skills.tags.title")}),d.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1",children:[P.map(([O,R])=>{const z=i.includes(O);return d.jsxs("button",{type:"button",onClick:()=>U(O),className:["px-2.5 py-1 rounded-full text-xs font-[family-name:var(--font-mono)] border-2 border-[var(--color-text)] transition-colors",z?"bg-[var(--color-text)] text-[var(--color-bg)] font-bold":"bg-[var(--surface-control)] text-[var(--color-text-muted)] hover:bg-[var(--surface-control-hover)]"].join(" "),children:[O," ",d.jsx("span",{className:"opacity-60",children:R})]},O)}),i.length>0&&d.jsx("button",{type:"button",onClick:()=>s([]),className:"px-2.5 py-1 rounded-full text-xs font-bold text-[var(--color-crashed)] hover:underline",children:e("skills.tags.clear")})]})]}),d.jsxs("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(280px,1fr))]",children:[E.map(O=>d.jsxs("div",{className:`nb-card flex items-center gap-2 ${O.status==="error"?"bg-[var(--color-crashed-bg)]":"opacity-70"}`,children:[O.status==="running"?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(vn,{size:14,strokeWidth:3}),d.jsx("span",{className:"text-sm text-[var(--color-text-muted)] truncate",children:O.status==="running"?`${O.label} · ${e("skills.ai.wait")}`:`${O.label}: ${O.error??e("skills.ai.error")}`})]},O.id)),D.map(O=>{var R;return d.jsx(rie,{skill:O,projectCount:((R=M.data)==null?void 0:R.data.length)??0,onOpen:()=>u(O.name),onExport:()=>void tie(O.name)},O.name)})]}),c&&d.jsx(vL,{name:c,onClose:()=>u(null)}),f&&d.jsx(Jne,{onClose:()=>m(!1)}),p&&d.jsx(eie,{onClose:()=>y(!1),onSubmit:(O,R)=>{_(O,R),y(!1)}})]})}function rie({skill:e,projectCount:t,onOpen:n,onExport:i}){const s=Xe(),a=iie[e.category];return d.jsxs("article",{className:"nb-card nb-card-interactive relative flex flex-col gap-3",children:[d.jsx("button",{type:"button",onClick:n,"aria-label":`Open ${e.name}`,className:"absolute inset-0 cursor-pointer rounded-[inherit] border-0 bg-transparent"}),d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsx("h3",{className:"min-w-0 flex-1 overflow-hidden break-all font-[family-name:var(--font-heading)] text-lg font-bold leading-6 line-clamp-2",children:e.name}),d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[d.jsx("button",{type:"button",className:"nb-btn relative z-10 p-1",onClick:i,"aria-label":s("skills.export"),title:s("skills.export"),children:d.jsx(Tj,{size:12,strokeWidth:2.5})}),d.jsx("span",{className:"nb-badge text-[10px]",style:{background:a},children:e.category})]})]}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] leading-5 line-clamp-3",children:e.description||"(no description)"}),e.tags.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(o=>d.jsx("span",{className:"text-[10px] font-[family-name:var(--font-mono)] px-1.5 py-0.5 rounded-full bg-[var(--surface-control)] border border-[var(--control-border)]",children:o},o))}),d.jsxs("div",{className:"flex items-center justify-between text-xs font-[family-name:var(--font-mono)] pt-2 border-t-[1.5px] border-dashed border-[var(--color-border-light)] mt-auto",children:[d.jsx("span",{className:"font-bold",children:e.linkedProjects.length>0?`● linked in ${e.linkedProjects.length}`:"○ not linked"}),d.jsxs("span",{className:"text-[var(--color-text-subtle)]",children:[t," projects"]})]})]})}function aie(e){return _t("/api/prompts")}function FL(e){return _t(`/api/prompts/${encodeURIComponent(e)}`)}function oie(e){return Ks("/api/prompts",e)}function lie(e,t){return Rm(`/api/prompts/${encodeURIComponent(e)}`,t)}function cie(e){return Yv(`/api/prompts/${encodeURIComponent(e)}`)}function uie(e){return Ks("/api/prompts/generate",{intent:e})}function $L(e){const t=new Set,n=[];for(const i of e.matchAll(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g)){const s=i[1];s&&!t.has(s)&&(t.add(s),n.push(s))}return n}function die(){var M,D;const e=Xe(),[t,n]=Yr("prompts.last",""),[i,s]=C.useState(null),[a,o]=C.useState(!1),[c,u]=C.useState(""),[f,m]=C.useState(new Set),p=tn(),y=at({queryKey:["prompts"],queryFn:()=>aie()}),b=((M=y.data)==null?void 0:M.data)??[],x=C.useMemo(()=>[...new Set(b.flatMap(I=>I.tags))].sort(),[b]),E=(((D=at({queryKey:["gen-jobs"],queryFn:UL,refetchInterval:3e3}).data)==null?void 0:D.data)??[]).filter(I=>I.kind==="prompt"),v=E.filter(I=>I.status!=="done"),_=C.useRef(new Set),k=C.useRef(null);C.useEffect(()=>{for(const I of E)(I.status==="done"||I.status==="error")&&!_.current.has(I.id)&&(_.current.add(I.id),p.invalidateQueries({queryKey:["prompts"]}),I.status==="done"&&I.result&&n(I.result))},[E,p,n]);const T=I=>{uie(I).then(()=>p.invalidateQueries({queryKey:["gen-jobs"]})).catch(()=>{})},A=C.useMemo(()=>{const I=c.trim().toLowerCase();return b.filter(P=>!(f.size&&![...f].every(U=>P.tags.includes(U))||I&&!(P.name.toLowerCase().includes(I)||P.description.toLowerCase().includes(I)||P.tags.some(q=>q.toLowerCase().includes(I)))))},[b,f,c]);C.useEffect(()=>{t&&b.length&&!b.some(I=>I.name===t)&&n("")},[t,b,n]);const j=I=>m(P=>{const U=new Set(P);return U.has(I)?U.delete(I):U.add(I),U});return d.jsxs("div",{className:"flex flex-col flex-1 min-h-0 w-full gap-3",children:[d.jsxs("div",{className:"shrink-0 flex items-center justify-between gap-3",children:[d.jsxs("div",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("prompts.title")}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:e("prompts.desc")})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs("button",{className:"nb-btn",type:"button",onClick:()=>o(!0),children:[d.jsx(il,{size:14,strokeWidth:2.5}),e("prompts.ai")]}),d.jsxs("button",{className:"nb-btn nb-btn-mint",type:"button",onClick:()=>s({mode:"new"}),children:[d.jsx(Gn,{size:14,strokeWidth:3}),e("prompts.new")]})]})]}),d.jsxs("div",{className:"shrink-0 flex flex-col gap-2",children:[d.jsxs("label",{className:"nb-input flex items-center gap-2 w-full",children:[d.jsx(cf,{size:14}),d.jsx("input",{type:"text",value:c,onChange:I=>u(I.target.value),placeholder:e("prompts.search"),className:"bg-transparent outline-none flex-1 text-sm","aria-label":e("prompts.search")})]}),x.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.map(I=>d.jsx("button",{type:"button",onClick:()=>j(I),className:`nb-btn px-2 py-0.5 text-xs ${f.has(I)?"nb-btn-mint":""}`,children:I},I))})]}),d.jsxs("div",{className:"flex gap-5 flex-1 min-h-0",children:[d.jsx("aside",{className:"w-80 shrink-0 nb-card p-3 overflow-hidden flex h-full min-h-0 flex-col gap-2",children:d.jsxs("div",{ref:k,className:"edge-scroll-list flex-1 min-h-0 overflow-y-auto flex flex-col gap-0.5",children:[v.map(I=>d.jsxs("div",{className:`nb-card flex items-center gap-2 ${I.status==="error"?"bg-[var(--color-crashed-bg)]":"opacity-70"}`,style:{padding:"8px 10px"},children:[I.status==="running"?d.jsx(lt,{size:12,className:"animate-spin"}):d.jsx(vn,{size:12,strokeWidth:3}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)] truncate",children:I.status==="running"?e("prompts.ai.wait"):`${e("prompts.ai.error")}: ${I.error??""}`})]},I.id)),y.isLoading?d.jsx("div",{className:"nb-card",children:d.jsx(lt,{size:14,className:"animate-spin"})}):A.length===0?d.jsx("div",{className:"nb-card",children:d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:e("prompts.empty")})}):A.map((I,P)=>d.jsx(Qc,{index:P,root:k,children:d.jsxs("button",{type:"button",onClick:()=>n(I.name),className:["dimension-menu-item w-full min-w-0 flex-col items-stretch gap-1 px-3 py-2 pl-4 text-left",t===I.name?"dimension-menu-item-active":""].join(" "),children:[d.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[I.favorite&&d.jsx(Pj,{size:12,fill:"currentColor",className:"shrink-0"}),d.jsx("code",{className:"min-w-0 max-w-full truncate font-[family-name:var(--font-mono)] text-sm font-bold",children:I.name})]}),I.description&&d.jsx("span",{className:"block w-full min-w-0 truncate text-xs text-[var(--color-text-muted)]",children:I.description})]})},I.name))]})}),d.jsx("div",{className:"flex-1 min-w-0 min-h-0",children:t?d.jsx(hie,{name:t,onEdit:()=>s({mode:"edit",name:t}),onDeleted:()=>n("")},t):d.jsx("div",{className:"nb-card",children:d.jsx("p",{className:"text-[var(--color-text-muted)]",children:e("prompts.selectHint")})})})]}),i&&d.jsx(mie,{name:i.mode==="edit"?i.name:null,onClose:()=>s(null),onSaved:I=>{s(null),n(I)}}),a&&d.jsx(fie,{onClose:()=>o(!1),onSubmit:I=>{T(I),o(!1)}})]})}function fie({onClose:e,onSubmit:t}){const n=Xe(),[i,s]=C.useState("");return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold flex items-center gap-2",children:[d.jsx(il,{size:16,strokeWidth:2.5}),n("prompts.ai.title")]}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:e,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:n("prompts.ai.intent")}),d.jsx("textarea",{value:i,onChange:a=>s(a.target.value),placeholder:n("prompts.ai.placeholder"),rows:5,className:"nb-input w-full text-sm","aria-label":n("prompts.ai.intent")})]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint self-start",disabled:!i.trim(),onClick:()=>t(i),children:[d.jsx(il,{size:14,strokeWidth:2.5}),n("prompts.ai.submit")]})]})})})}function hie({name:e,onEdit:t,onDeleted:n}){const i=Xe(),s=tn(),{confirm:a}=Ln(),o=at({queryKey:["prompt",e],queryFn:()=>FL(e)}),c=zt({mutationFn:()=>cie(e),onSuccess:()=>{s.invalidateQueries({queryKey:["prompts"]}),n()}});if(o.isLoading)return d.jsx("div",{className:"nb-card",children:d.jsx(lt,{size:14,className:"animate-spin"})});const u=o.data;if(!u)return null;const f=$L(u.body);return d.jsxs("div",{className:"nb-card flex flex-col gap-3 h-full min-h-0",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 shrink-0",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold flex items-center gap-2",children:[u.favorite&&d.jsx(Pj,{size:16,fill:"currentColor"}),d.jsx("code",{className:"font-[family-name:var(--font-mono)] truncate",children:u.name})]}),u.description&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:u.description})]}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:t,children:[d.jsx(Hv,{size:14,strokeWidth:3}),i("common.edit")]}),d.jsx("button",{type:"button",className:"nb-btn",disabled:c.isPending,onClick:async()=>{await a({title:i("prompts.delete"),body:i("prompts.deleteConfirm",{name:e})})&&c.mutate()},"aria-label":i("prompts.delete"),children:d.jsx(qi,{size:14,strokeWidth:3})})]})]}),u.tags.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 shrink-0",children:u.tags.map(m=>d.jsx("span",{className:"nb-badge px-2 py-0.5 text-xs",children:m},m))}),d.jsx("pre",{className:"flex-1 bg-surface-input min-h-0 overflow-auto text-sm font-[family-name:var(--font-mono)] whitespace-pre-wrap break-words bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-3",children:u.body}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)] shrink-0",children:f.length?i("prompts.vars",{names:f.join(", ")}):i("prompts.noVars")})]})}function pie({tags:e,onChange:t}){const n=Xe(),[i,s]=C.useState(""),a=()=>{const o=i.trim();o&&!e.includes(o)&&t([...e,o]),s("")};return d.jsxs("div",{className:"nb-input w-full flex flex-wrap gap-1.5 items-center",children:[e.map(o=>d.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded px-1.5 py-0.5",children:[o,d.jsx("button",{type:"button",onClick:()=>t(e.filter(c=>c!==o)),"aria-label":`remove ${o}`,children:d.jsx(vn,{size:10,strokeWidth:3})})]},o)),d.jsx("input",{className:"flex-1 min-w-[90px] bg-transparent outline-none text-sm",value:i,onChange:o=>s(o.target.value),onKeyDown:o=>{o.key==="Enter"?(o.preventDefault(),a()):o.key==="Backspace"&&!i&&e.length&&t(e.slice(0,-1))},placeholder:e.length?"":n("prompts.tagAdd"),"aria-label":n("prompts.tags")})]})}function mie({name:e,onClose:t,onSaved:n}){const i=Xe(),s=tn(),{alert:a}=Ln(),o=e===null,c=at({queryKey:["prompt",e],queryFn:()=>FL(e),enabled:!o}),[u,f]=C.useState(o?{name:"",description:"",tags:[],body:"",favorite:!1}:null);C.useEffect(()=>{if(!o&&c.data&&u===null){const b=c.data;f({name:b.name,description:b.description,tags:b.tags,body:b.body,favorite:b.favorite})}},[o,c.data,u]);const m=zt({mutationFn:()=>{if(!u)throw new Error("no form");const b={description:u.description||void 0,tags:u.tags,favorite:u.favorite,body:u.body};return o?oie({name:u.name,...b}):lie(e,b)},onSuccess:b=>{s.invalidateQueries({queryKey:["prompts"]}),s.invalidateQueries({queryKey:["prompt",b.name]}),n(b.name)},onError:b=>void a({title:i("prompts.saveError"),body:b instanceof Error?b.message:String(b)})}),p=C.useMemo(()=>u?/^[a-z0-9][a-z0-9-]*$/.test(u.name):!1,[u]),y=C.useMemo(()=>u?$L(u.body):[],[u]);return d.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/30 p-4 overflow-auto",children:d.jsx("div",{className:"w-full max-w-2xl my-8",children:d.jsxs("div",{className:"nb-card flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold",children:o?i("prompts.new"):e}),d.jsx("button",{type:"button",className:"nb-btn p-2",onClick:t,"aria-label":"close",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),!o&&c.isLoading?d.jsx(lt,{size:14,className:"animate-spin"}):u?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.name")}),d.jsx("input",{type:"text",value:u.name,disabled:!o,onChange:b=>f({...u,name:b.target.value}),placeholder:i("prompts.namePlaceholder"),className:"nb-input w-full","aria-label":i("prompts.name")}),o&&u.name&&!p&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:i("prompts.nameError")})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.description")}),d.jsx("input",{type:"text",value:u.description,onChange:b=>f({...u,description:b.target.value}),className:"nb-input w-full","aria-label":i("prompts.description")})]})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.tags")}),d.jsx(pie,{tags:u.tags,onChange:b=>f({...u,tags:b})})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-sm font-bold",children:i("prompts.body")}),d.jsx("textarea",{value:u.body,onChange:b=>f({...u,body:b.target.value}),placeholder:i("prompts.bodyPlaceholder"),rows:12,className:"nb-input w-full font-[family-name:var(--font-mono)] text-sm","aria-label":i("prompts.body")}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:y.length?i("prompts.vars",{names:y.join(", ")}):i("prompts.noVars")})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",disabled:m.isPending||o&&!p||!u.body.trim(),onClick:()=>m.mutate(),children:[m.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3}),i("prompts.save")]}),d.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:u.favorite,onChange:b=>f({...u,favorite:b.target.checked})}),i("prompts.favorite")]})]})]}):null]})})})}function gie(){return _t("/api/processes").then(e=>e.data)}function yie(e){return Ks(`/api/processes/${e}/kill`)}function bie(){return _t("/api/processes/reclaim")}async function xie(e){const t=await fetch("/api/processes/reclaim",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({idleMinutes:e})});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return t.json()}const vie="nb-card";function wie(e){if(!e)return"—";const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t)||t<0)return"—";const n=Math.floor(t/6e4);if(n<1)return"<1m";if(n<60)return`${n}m`;const i=Math.floor(n/60);return i<24?`${i}h${n%60?` ${n%60}m`:""}`:`${Math.floor(i/24)}d${i%24?` ${i%24}h`:""}`}function Mx(e){return e.project?e.project:e.cwd?e.cwd.split("/").filter(Boolean).pop()??e.slot:e.slot}function lT(e){const t=/^session-chat-(.+)$/.exec(e.slot);return(t==null?void 0:t[1])??null}function Eie({p:e}){const t=e.alive?e.sessionState??"alive":"offline",n=e.alive?"bg-[var(--color-accent-mint)]":"bg-[var(--color-bg-cream)] text-[var(--color-text)]/60";return d.jsx("span",{className:`nb-status font-[family-name:var(--font-mono)] ${n}`,children:t})}function Sie({embedded:e}={}){var w;const t=Xe(),n=tn(),[i,s]=C.useState(null),[a,o]=C.useState("all"),c=at({queryKey:["processes"],queryFn:gie,refetchInterval:5e3}),u=zt({mutationFn:yie,onSuccess:E=>{s(E.message),n.invalidateQueries({queryKey:["processes"]})},onError:E=>s(E instanceof Error?E.message:String(E))}),f=at({queryKey:["reclaim"],queryFn:bie}),[m,p]=C.useState("");C.useEffect(()=>{f.data&&m===""&&p(String(f.data.idleMinutes))},[f.data,m]);const y=zt({mutationFn:E=>xie(E),onSuccess:E=>{s(`自动回收已设为 ${E.idleMinutes} 分钟空闲`),n.invalidateQueries({queryKey:["reclaim"]})},onError:E=>s(E instanceof Error?E.message:String(E))}),x=(c.data??[]).filter(E=>a==="all"?!0:E.kind===a);return d.jsxs("div",{className:"max-w-full flex-1 min-h-0 flex flex-col",children:[!e&&d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl mb-2 shrink-0",children:t("processes.title")}),i&&d.jsx("div",{className:"nb-card mb-3 px-3 py-2 text-sm font-mono",children:i}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[["all","worker","chat"].map(E=>d.jsx("button",{type:"button","aria-pressed":a===E,onClick:()=>o(E),className:`nb-btn px-3 py-1 text-sm ${a===E?"nb-btn-primary":""}`,children:t(`processes.kind.${E}`)},E)),d.jsxs("button",{type:"button","aria-label":t("processes.refresh"),onClick:()=>n.invalidateQueries({queryKey:["processes"]}),className:"nb-btn px-3 py-1 text-sm",children:[c.isFetching?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(ea,{size:14}),t("processes.refresh")]}),d.jsxs("div",{className:`${vie} px-3 py-1 flex items-center gap-2 shrink-0 ml-auto`,title:"自动回收:会话空闲 N 分钟自动停,下次访问 durable resume 续上,不丢上下文",children:[d.jsx(x6,{size:15,strokeWidth:2.5}),d.jsx("input",{type:"number",min:1,max:1440,value:m,onChange:E=>p(E.target.value),className:"nb-input w-14 px-2 py-1 font-[family-name:var(--font-mono)] text-sm","aria-label":"自动回收空闲分钟数"}),d.jsx("button",{type:"button",disabled:y.isPending||m===""||Number(m)===((w=f.data)==null?void 0:w.idleMinutes),onClick:()=>y.mutate(Math.round(Number(m))),className:"nb-btn nb-btn-primary text-sm disabled:opacity-50",style:{padding:"4px 8px"},"aria-label":"保存自动回收设置",title:"保存自动回收设置",children:y.isPending?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})})]})]}),d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] flex-1 min-h-0 overflow-hidden flex flex-col text-sm",children:[d.jsxs("div",{className:"shrink-0 grid grid-cols-[130px_minmax(140px,1.2fr)_minmax(140px,1.5fr)_80px_110px_90px_90px_100px] bg-[var(--surface-table-head)] font-[family-name:var(--font-heading)] border-b-2 border-[var(--color-text)]/15",children:[d.jsx("div",{className:"px-3 py-2",children:t("processes.col.kind")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.slot")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.project")}),d.jsx("div",{className:"px-3 py-2",children:"PID"}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.state")}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.memory")}),d.jsx("div",{className:"px-3 py-2",children:"运行时间"}),d.jsx("div",{className:"px-3 py-2",children:t("processes.col.action")})]}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto font-[family-name:var(--font-mono)]",children:[x.length===0&&d.jsx("div",{className:"px-3 py-6 text-center text-[var(--color-text)]/50",children:t("processes.empty")}),x.map(E=>d.jsxs("div",{className:"grid grid-cols-[130px_minmax(140px,1.2fr)_minmax(140px,1.5fr)_80px_110px_90px_90px_100px] border-t border-[var(--color-text)]/10 items-center",title:E.cwd??"",children:[d.jsxs("div",{className:"px-3 py-2 flex flex-col gap-0.5",children:[d.jsx("span",{className:`nb-badge text-xs whitespace-nowrap ${E.kind==="worker"?"bg-[var(--color-accent-yellow)]":"bg-[var(--color-accent-purple)]"}`,children:t(`processes.kind.${E.kind}`)}),d.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--color-text)]/45",children:E.tool})]}),d.jsx("div",{className:"px-3 py-2 truncate",children:E.slot}),d.jsx("div",{className:"px-3 py-2 truncate",children:E.kind==="chat"&&lT(E)?d.jsxs(jc,{to:`/chat/${lT(E)}`,className:"inline-flex items-center gap-1 font-semibold text-[var(--color-text)] underline decoration-2 underline-offset-2 hover:opacity-70",title:"打开对话窗口",children:[d.jsx(IU,{size:12,strokeWidth:2.5})," ",Mx(E)]}):E.kind==="worker"&&E.project?d.jsxs(jc,{to:`/board?project=${encodeURIComponent(E.project)}`,className:"inline-flex items-center gap-1 font-semibold text-[var(--color-text)] underline decoration-2 underline-offset-2 hover:opacity-70",title:"打开该项目看板",children:[d.jsx(QB,{size:12,strokeWidth:2.5})," ",Mx(E)]}):d.jsx("span",{children:Mx(E)})}),d.jsx("div",{className:"px-3 py-2",children:E.pid??"—"}),d.jsx("div",{className:"px-3 py-2",children:d.jsx(Eie,{p:E})}),d.jsx("div",{className:"px-3 py-2",children:E.memoryMB!=null?`${E.memoryMB} MB`:"—"}),d.jsx("div",{className:"px-3 py-2",children:wie(E.startedAt)}),d.jsx("div",{className:"px-3 py-2",children:E.alive&&E.pid!=null?d.jsxs("button",{type:"button","aria-label":`${t("processes.kill")} ${E.slot}`,onClick:()=>{confirm(t("processes.killConfirm").replace("{slot}",E.slot))&&u.mutate(E.pid)},className:"nb-btn nb-btn-danger px-2.5 py-1 text-xs",children:[d.jsx(_j,{size:13})," ",t("processes.kill")]}):d.jsx("span",{className:"text-[var(--color-text)]/40 text-xs",children:"—"})})]},E.slot))]})]})]})}function kie(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.action&&t.set("action",e.action);const n=t.toString();return _t(`/api/audit${n?`?${n}`:""}`).then(i=>i.data)}const Nie={create:"bg-[var(--color-accent-mint)]",modify:"bg-[var(--color-accent-yellow)]",delete:"bg-[var(--color-accent-pink)]",daemon:"bg-[var(--color-accent-purple)]"};function _ie({embedded:e}={}){const t=Xe(),n=tn(),[i,s]=C.useState(""),a=at({queryKey:["audit",i],queryFn:()=>kie(i?{action:i}:{}),refetchInterval:8e3}),o=a.data??[],c=u=>t(`audit.action.${u}`);return d.jsxs("div",{className:"max-w-full flex-1 min-h-0 flex flex-col",children:[!e&&d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl mb-2 shrink-0",children:t("audit.title")}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap shrink-0",children:[["","create","modify","delete","daemon"].map(u=>d.jsx("button",{type:"button","aria-pressed":i===u,onClick:()=>s(u),className:`nb-btn px-3 py-1 text-sm ${i===u?"nb-btn-primary":""}`,children:u?c(u):t("audit.filter.all")},u||"all")),d.jsxs("button",{type:"button","aria-label":t("audit.refresh"),onClick:()=>n.invalidateQueries({queryKey:["audit"]}),className:"nb-btn px-3 py-1 text-sm ml-auto",children:[a.isFetching?d.jsx(lt,{size:14,className:"animate-spin"}):d.jsx(ea,{size:14}),t("audit.refresh")]})]}),d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] flex-1 min-h-0 overflow-hidden flex flex-col text-sm",children:[d.jsxs("div",{className:"shrink-0 grid grid-cols-[180px_120px_minmax(100px,1fr)_minmax(160px,2fr)] bg-[var(--surface-table-head)] font-[family-name:var(--font-heading)] border-b-2 border-[var(--color-text)]/15",children:[d.jsx("div",{className:"px-3 py-2",children:t("audit.col.time")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.action")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.project")}),d.jsx("div",{className:"px-3 py-2",children:t("audit.col.detail")})]}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto font-[family-name:var(--font-mono)]",children:[o.length===0&&d.jsx("div",{className:"px-3 py-6 text-center text-[var(--color-text)]/50",children:t("audit.empty")}),o.map((u,f)=>d.jsxs("div",{className:"grid grid-cols-[180px_120px_minmax(100px,1fr)_minmax(160px,2fr)] border-t border-[var(--color-text)]/10 items-center",children:[d.jsx("div",{className:"px-3 py-2 whitespace-nowrap",children:new Date(u.ts).toLocaleString()}),d.jsx("div",{className:"px-3 py-2",children:d.jsx("span",{className:`nb-badge text-xs whitespace-nowrap ${Nie[u.action]}`,children:c(u.action)})}),d.jsx("div",{className:"px-3 py-2 truncate",title:u.project,children:u.project}),d.jsx("div",{className:"px-3 py-2 text-[var(--color-text)]/70 truncate",title:u.detail??"",children:u.detail??(u.source?`(${u.source})`:"—")})]},`${u.ts}-${f}`))]})]})]})}const qL=[{id:"git",fields:[{key:"GITLAB_URL",type:"text",placeholder:"https://gitlab.com"},{key:"GITLAB_TOKEN",type:"text"}]},{id:"matrix",fields:[{key:"MATRIX_HOMESERVER",type:"text",placeholder:"https://matrix.example.com"},{key:"MATRIX_ACCESS_TOKEN",type:"text"},{key:"MATRIX_ROOM_ID",type:"text",placeholder:"!room:example.com"}]},{id:"memory",fields:[{key:"SPS_MEMORY_MODE",type:"select",defaultValue:"local",options:["local","local+external","external","none"]},{key:"SPS_MEMORY_EXTERNAL_URL",type:"text",placeholder:"http://127.0.0.1:3111"},{key:"SPS_MEMORY_DISTILL",type:"select",options:["","on","off"]},{key:"SPS_MEMORY_IMPORT",type:"select",options:["","on","off"]},{key:"SPS_MEMORY_REDACT",type:"select",options:["","on","off"]}]},{id:"daemon",fields:[{key:"SPS_OPENAI_SANDBOX_PROVIDER",type:"select",options:["","unix_local","docker"]},{key:"SPS_DAEMON_MAX_CONCURRENT_RUNS",type:"number",placeholder:"按内存自动推导"},{key:"SPS_DAEMON_ORIGIN_QUOTAS",type:"text",placeholder:"coral-platform=30,gameforge=20"},{key:"SPS_DAEMON_QUEUE_WAIT_S",type:"number",defaultValue:"20"},{key:"SPS_DAEMON_MAX_QUEUE",type:"number",defaultValue:"200"},{key:"SPS_RUN_IDLE_MINUTES",type:"number",defaultValue:"5"},{key:"SPS_RUN_TOOL_IDLE_MINUTES",type:"number",defaultValue:"12"},{key:"SPS_STUCK_RUN_MINUTES",type:"number",defaultValue:"20"}]},{id:"console",fields:[{key:"SPS_CONSOLE_TOKEN",type:"text"},{key:"SPS_CONSOLE_MEMORY_VIEWER_URL",type:"text",placeholder:"https://memory.example.com"}]}],Cie=qL.flatMap(e=>e.fields),cT=new Set(Cie.map(e=>e.key)),Tie=[{value:"config",labelKey:"system.tab.config"},{value:"processes",labelKey:"system.tab.processes"},{value:"doctor",labelKey:"system.tab.doctor"},{value:"audit",labelKey:"system.tab.audit"}];function Aie(){var s,a;const e=Xe(),t=at({queryKey:["system-info"],queryFn:Gj}),[n,i]=Yr("system.tab","config");return d.jsxs("div",{className:"system-page-shell flex flex-col flex-1 min-h-0 w-full",children:[d.jsxs("header",{className:"system-page-header shrink-0 flex items-center justify-between gap-3 flex-wrap",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("system.h1")}),d.jsx(jie,{platform:(s=t.data)==null?void 0:s.platform,current:(a=t.data)==null?void 0:a.version})]}),d.jsx(Zc,{ariaLabel:e("system.h1"),className:"max-w-full",value:n,onChange:i,options:Tie.map(o=>({value:o.value,label:e(o.labelKey)}))}),d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[n==="config"&&d.jsx(Mie,{}),n==="processes"&&d.jsx(Sie,{embedded:!0}),n==="doctor"&&d.jsx(Die,{}),n==="audit"&&d.jsx(_ie,{embedded:!0})]})]})}function jie({platform:e,current:t}){const n=Xe(),{confirm:i,alert:s}=Ln(),[a,o]=C.useState(!1),c=at({queryKey:["latest-version"],queryFn:Z6,enabled:!1}),u=async()=>{const m=(await c.refetch()).data;if(!m)return;if(m.upToDate){s({title:n("system.upgrade.checkUpdate"),body:n("system.upgrade.upToDate",{version:t??"?"})});return}if(await i({title:n("system.upgrade.confirm.title"),body:n("system.upgrade.confirm.body",{current:t??"?",latest:m.latest}),confirm:n("system.upgrade.confirm.button")})){o(!0);try{const y=await J6();s({title:y.ok?n("system.upgrade.success.title"):n("system.upgrade.notEffective.title"),body:y.ok?n("system.upgrade.success.body",{version:y.installedVersion??"?"}):y.output||""})}catch(y){s({title:n("system.upgrade.error.title"),body:y.message})}finally{o(!1)}}};return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] whitespace-nowrap",children:[e??"—",t?` · v${t}`:""]}),d.jsxs("button",{className:"nb-btn",style:{padding:"6px 12px",fontSize:12},onClick:u,disabled:a||c.isFetching||!t,type:"button","aria-label":n("system.upgrade.checkUpdate"),children:[a||c.isFetching?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:12,strokeWidth:2.5}),n("system.upgrade.checkUpdate")]})]})}function Mie(){const e=Xe(),t=tn(),{alert:n}=Ln(),{data:i,isLoading:s,isError:a,error:o,dataUpdatedAt:c}=at({queryKey:["system-env-raw"],queryFn:G6}),[u,f]=C.useState(null),[m,p]=C.useState(""),[y,b]=C.useState(""),x=i?`${i.etag}:${c}`:null;C.useEffect(()=>{if(!i||x===null)return;const I=u!==null&&u.content!==u.baseContent;(u===null||!I&&u.sourceKey!==x)&&(f({content:i.content,baseContent:i.content,etag:i.etag,sourceKey:x}),p(""),b(""))},[i,u,x]);const w=u,E=w!==null&&w.content!==w.baseContent,v=(w==null?void 0:w.content)??(i==null?void 0:i.content)??"",_=(w==null?void 0:w.etag)??(i==null?void 0:i.etag)??null,k=CL(v,cT),T=m.trim().toUpperCase(),A=AL(T)&&!cT.has(T)&&!k.some(I=>I.key===T),j=(I,P)=>{f(U=>{const q=U??Rx(i,x);return{...q,content:mm(q.content,I.key,P,I)}})},M=(I,P)=>{f(U=>{const q=U??Rx(i,x);return{...q,content:mm(q.content,I,P)}})},D=zt({mutationFn:()=>{if(w===null)throw new Error("no draft");return W6(w.content,w.etag)},onSuccess:I=>{f(P=>P===null?P:{...P,baseContent:P.content,etag:I.etag,sourceKey:`${I.etag}:saved`}),t.invalidateQueries({queryKey:["system-env"]}),t.invalidateQueries({queryKey:["system-env-raw"]})},onError:I=>{const P=I.status;n({title:e(P===409?"system.env.error.conflict.title":"system.env.error.save.title"),body:P===409?e("system.env.error.conflict.body"):I instanceof Error?I.message:String(I)})}});return s?d.jsx("p",{className:"text-[var(--color-text-muted)]",children:e("common.loading")}):a?d.jsx("div",{className:"bg-[var(--color-crashed-bg)] border-2 border-[var(--color-crashed)] rounded-lg p-3",children:d.jsx("p",{className:"text-sm",children:o instanceof Error?o.message:String(o)})}):d.jsxs("div",{className:"system-env-settings-editor",children:[d.jsxs("div",{className:"project-config-toolbar",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-base font-bold mb-1",children:e("system.tab.config")}),d.jsx("p",{className:"text-xs text-[var(--color-stuck)] font-bold",children:e("system.env.warning")}),_&&d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] mt-1",children:["etag: ",_,E?e("system.env.dirtyMark"):""]})]}),d.jsx("div",{className:"flex gap-2",children:d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 12px"},onClick:()=>D.mutate(),disabled:!E||D.isPending,type:"button","aria-label":e("system.env.save.aria"),children:[D.isPending?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:12,strokeWidth:3}),e("system.env.save")]})})]}),d.jsxs("div",{className:"project-config-settings","aria-label":e("system.env.settingsAria"),children:[qL.map(I=>d.jsxs("section",{className:"project-config-section",children:[d.jsxs("div",{className:"project-config-section-head",children:[d.jsx("h3",{children:e(`system.env.section.${I.id}`)}),d.jsx("p",{children:e(`system.env.section.${I.id}.hint`)})]}),d.jsx("div",{className:"project-config-grid",children:I.fields.map(P=>d.jsx(Rie,{field:P,value:_L(v,P),rawValue:Ud(v,P.key),onChange:U=>j(P,U)},P.key))})]},I.id)),d.jsxs("section",{className:"project-config-section",children:[d.jsxs("div",{className:"project-config-section-head",children:[d.jsx("h3",{children:e("system.env.section.custom")}),d.jsx("p",{children:e("system.env.section.custom.hint")})]}),d.jsxs("div",{className:"project-config-custom-list",children:[k.length===0?d.jsx("p",{className:"project-config-empty",children:e("system.env.custom.empty")}):k.map(I=>d.jsxs("div",{className:"project-config-custom-row",children:[d.jsx("code",{children:I.key}),d.jsx("input",{className:"nb-input",value:I.value,onChange:P=>M(I.key,P.target.value),"aria-label":e("system.env.custom.valueAria",{key:I.key})}),d.jsx("button",{type:"button",className:"nb-btn",onClick:()=>f(P=>{const U=P??Rx(i,x);return{...U,content:TL(U.content,I.key)}}),"aria-label":e("system.env.custom.removeAria",{key:I.key}),children:d.jsx(vn,{size:12,strokeWidth:3})})]},I.key)),d.jsxs("div",{className:"project-config-custom-row project-config-custom-add",children:[d.jsx("input",{className:"nb-input",value:m,onChange:I=>p(I.target.value),placeholder:e("system.env.custom.keyPlaceholder"),"aria-label":e("system.env.custom.keyAria")}),d.jsx("input",{className:"nb-input",value:y,onChange:I=>b(I.target.value),placeholder:e("system.env.custom.valuePlaceholder"),"aria-label":e("system.env.custom.newValueAria")}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",disabled:!A||!y,onClick:()=>{M(T,y),p(""),b("")},children:[d.jsx(Gn,{size:12,strokeWidth:3}),e("system.env.custom.add")]})]})]})]})]})]})}function Rx(e,t){const n=(e==null?void 0:e.content)??"",i=(e==null?void 0:e.etag)??"";return{content:n,baseContent:n,etag:i,sourceKey:t??`${i}:empty`}}function Rie({field:e,value:t,rawValue:n,onChange:i}){const s=Xe(),a=s(`system.env.field.${e.key}`),o=s(`system.env.field.${e.key}.help`),c=e.type==="boolean",u=(n||e.defaultValue||"").toLowerCase()==="true";return d.jsxs("div",{className:["project-config-field",c?"project-config-field-toggle":""].join(" "),children:[d.jsxs("span",{className:"project-config-label",children:[d.jsx("span",{children:a}),d.jsx("code",{children:e.key})]}),c?d.jsxs("span",{className:"project-config-toggle-row",children:[d.jsx("input",{type:"checkbox",checked:u,onChange:f=>i(String(f.target.checked))}),d.jsx("span",{children:s(u?"common.yes":"common.no")})]}):e.type==="select"?d.jsx("select",{className:"nb-input",value:t,onChange:f=>i(f.target.value),"aria-label":a,children:(e.options??[]).map(f=>d.jsx("option",{value:f,children:f||s("projectDetail.config.option.empty")},f||"__empty"))}):d.jsx("input",{className:"nb-input",type:e.type==="number"?"number":"text",min:e.type==="number"?0:void 0,value:t,onChange:f=>i(f.target.value),placeholder:e.placeholder,"aria-label":a}),d.jsx("span",{className:"project-config-help",children:o})]})}function Die(){var y;const e=Xe(),{alert:t}=Ln(),n=at({queryKey:["projects"],queryFn:ro}),[i,s]=C.useState({}),[a,o]=C.useState({}),[c,u]=C.useState(null),f=(((y=n.data)==null?void 0:y.data)??[]).map(b=>({project:b.name})),m=async(b,x)=>{o(w=>({...w,[b]:x?"fix":"check"}));try{const w=await eF(b,x);s(E=>({...E,[b]:w})),u(b)}catch(w){t({title:e(x?"system.diagnostics.error.fix":"system.diagnostics.error.check"),body:w instanceof Error?w.message:String(w)})}finally{o(w=>({...w,[b]:null}))}},p=async()=>{for(const b of f)await m(b.project,!1)};return d.jsxs("section",{className:"nb-card system-panel system-panel-doctor flex-1 min-h-0",children:[d.jsxs("div",{className:"system-panel-titlebar",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:e("system.diagnostics.title")}),d.jsxs("button",{className:"nb-btn nb-btn-mint",style:{padding:"6px 12px",fontSize:12},onClick:()=>{p()},disabled:f.length===0||Object.values(a).some(Boolean),type:"button",children:[d.jsx(ea,{size:12,strokeWidth:2.5}),e("system.diagnostics.checkAll")]})]}),d.jsx("div",{className:"system-panel-body",children:f.length===0?d.jsx("p",{className:"text-[var(--color-text-muted)] text-sm",children:e("system.diagnostics.empty")}):d.jsx("ul",{className:"system-diagnostics-list",children:f.map(b=>{const x=i[b.project],w=a[b.project],E=x?x.checks.filter(T=>T.status==="fail").length:0,v=x?x.checks.filter(T=>T.status==="warn").length:0,_=c===b.project,k=x!=null;return d.jsxs("li",{className:["system-diagnostics-item",_?"system-diagnostics-item-expanded":""].join(" "),children:[d.jsxs("div",{className:"system-diagnostics-row",children:[d.jsxs("button",{type:"button",onClick:()=>u(_?null:b.project),disabled:!k,className:"system-diagnostics-summary","aria-label":e(_?"system.diagnostics.collapseAria":"system.diagnostics.expandAria"),"aria-expanded":k?_:void 0,children:[d.jsxs("span",{className:"system-diagnostics-project-main",children:[k&&x.ok?d.jsx(d0,{size:16,className:"text-[var(--color-running)] shrink-0",strokeWidth:2.5}):k?d.jsx(jd,{size:16,className:"text-[var(--color-stuck)] shrink-0",strokeWidth:2.5}):d.jsx(d0,{size:16,className:"text-[var(--color-text-subtle)] shrink-0",strokeWidth:2.5}),k&&(_?d.jsx(so,{size:12}):d.jsx(lf,{size:12})),d.jsx("span",{className:"system-diagnostics-project-name",children:b.project})]}),k?x.ok?d.jsx("span",{className:"system-diagnostics-status system-diagnostics-status-ok",children:"OK"}):d.jsxs("span",{className:"system-diagnostics-status system-diagnostics-status-warn",children:[E," fail · ",v," warn"]}):d.jsx("span",{className:"system-diagnostics-never",children:e("system.diagnostics.never")})]}),d.jsxs("div",{className:"system-diagnostics-actions",children:[d.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:11},onClick:()=>{m(b.project,!1)},disabled:!!w,type:"button","aria-label":e("system.diagnostics.checkAria"),children:[w==="check"?d.jsx(lt,{size:11,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:11,strokeWidth:2.5}),e("system.diagnostics.check")]}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 10px",fontSize:11},onClick:()=>{m(b.project,!0)},disabled:!!w||k&&x.ok,type:"button","aria-label":e("system.diagnostics.fixAria"),title:k&&x.ok?e("system.diagnostics.noFixesNeeded"):e("system.diagnostics.fix.tip"),children:[w==="fix"?d.jsx(lt,{size:11,strokeWidth:3,className:"animate-spin"}):d.jsx(Uj,{size:11,strokeWidth:2.5}),e("system.diagnostics.fix")]})]})]}),_&&k&&d.jsxs("div",{className:"system-diagnostics-detail",children:[d.jsx("ul",{className:"system-diagnostics-checks",children:x.checks.map((T,A)=>d.jsx(Oie,{check:T},`${T.name}-${A}`))}),x.fixes.length>0&&d.jsxs("div",{className:"mt-3 bg-[var(--color-running-bg)] border-2 border-[var(--color-running)] rounded p-2",children:[d.jsx("div",{className:"text-xs font-bold text-[var(--color-running)] mb-1",children:e("system.diagnostics.fixed")}),d.jsx("ul",{className:"text-xs list-disc pl-4",children:x.fixes.map((T,A)=>d.jsx("li",{children:T},A))})]})]})]},b.project)})})})]})}function Oie({check:e}){const t=e.status==="pass"?d.jsx(d0,{size:12,className:"text-[var(--color-running)]",strokeWidth:2.5}):e.status==="fail"?d.jsx(jd,{size:12,className:"text-[var(--color-crashed)]",strokeWidth:2.5}):e.status==="warn"?d.jsx(jd,{size:12,className:"text-[var(--color-stuck)]",strokeWidth:2.5}):d.jsx("span",{className:"system-diagnostics-info-dot"});return d.jsxs("li",{className:"system-diagnostics-check-row",children:[d.jsx("span",{className:"system-diagnostics-check-icon",children:t}),d.jsx("span",{className:"system-diagnostics-check-name",children:e.name}),d.jsx("span",{className:"system-diagnostics-check-message",children:e.message})]})}function pc({value:e,onChange:t,options:n,ariaLabel:i,disabled:s,className:a="",placeholder:o="选择…",align:c="left"}){var v;const[u,f]=C.useState(!1),m=C.useRef(null),p=C.useRef(null),y=C.useRef(null),[b,x]=C.useState(null),w=()=>{var k;const _=(k=m.current)==null?void 0:k.getBoundingClientRect();_&&x({top:_.bottom+6,left:_.left,right:window.innerWidth-_.right,width:_.width})};C.useLayoutEffect(()=>{u&&w()},[u]),C.useEffect(()=>{if(!u)return;const _=()=>w(),k=T=>{var A,j;(A=m.current)!=null&&A.contains(T.target)||(j=p.current)!=null&&j.contains(T.target)||f(!1)};return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),document.addEventListener("mousedown",k),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_),document.removeEventListener("mousedown",k)}},[u]);const E=((v=n.find(_=>_.value===e))==null?void 0:v.label)??o;return d.jsxs("div",{className:`relative ${a}`,children:[d.jsxs("button",{ref:m,type:"button",disabled:s,"aria-label":i,"aria-expanded":u,className:"nb-btn w-full justify-between text-sm disabled:opacity-50",onClick:()=>f(_=>!_),children:[d.jsx("span",{className:"truncate",children:E}),d.jsx(so,{size:14,strokeWidth:2.5,className:["shrink-0 transition-transform",u?"rotate-180":""].join(" ")})]}),u&&b&&Ej.createPortal(d.jsx("div",{ref:p,style:{position:"fixed",top:b.top,left:c==="right"?void 0:b.left,right:c==="right"?b.right:void 0,minWidth:b.width},className:"z-[100] nb-card p-1 overflow-hidden bg-[var(--surface-menu)]",children:d.jsx("div",{ref:y,className:"max-h-[60vh] overflow-y-auto",children:n.map((_,k)=>d.jsx(Qc,{index:k,root:y,delay:.02,children:d.jsx("button",{type:"button",onClick:()=>{t(_.value),f(!1)},className:["dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2 whitespace-nowrap",_.value===e?"dimension-menu-item-active":""].join(" "),children:_.label})},_.value))})}),document.body)]})}const Lie=["convention","decision","gotcha","pattern","reference","note"],Iie=["local","local+external","external","none"];function dw(e){return e!=null&&typeof e=="object"?e:{}}function mc(e){return Array.isArray(e)?e:[]}function Pie(e){switch(e){case"none":return"none";case"agentmemory":case"custom":return"external";case"builtin":default:return"local"}}function uT(e){const t=dw(e);return{mode:typeof t.mode=="string"&&t.mode?t.mode:Pie(t.provider),externalUrl:typeof t.externalUrl=="string"?t.externalUrl:typeof t.url=="string"?t.url:"",modeOptions:mc(t.modeOptions).length>0?mc(t.modeOptions):Iie}}function zie(e){const t=dw(e),n=t.scope==="global"||t.scope==="project"||t.scope==="agent"?t.scope:null;return n?{scope:n,project:typeof t.project=="string"?t.project:void 0,agentId:typeof t.agentId=="string"?t.agentId:void 0,count:typeof t.count=="number"?t.count:0,updated:typeof t.updated=="string"?t.updated:""}:null}function Bie(e){const t=dw(e);if(typeof t.id!="string")return null;const n=t.scope==="global"||t.scope==="project"||t.scope==="agent"?t.scope:"global";return{id:t.id,title:typeof t.title=="string"?t.title:t.id,scope:n,category:typeof t.category=="string"?t.category:"note",tags:mc(t.tags),salience:typeof t.salience=="number"?t.salience:3,source:typeof t.source=="string"?t.source:"human",project:typeof t.project=="string"?t.project:void 0,agentId:typeof t.agentId=="string"?t.agentId:void 0,created:typeof t.created=="string"?t.created:"",updated:typeof t.updated=="string"?t.updated:"",body:typeof t.body=="string"?t.body:""}}function jo(e){return`${e.scope}:${e.project??e.agentId??""}`}function lp(e){return e.scope==="global"?`全局 (${e.count})`:e.scope==="project"?`项目:${e.project} (${e.count})`:`会话:${e.agentId} (${e.count})`}function Mo(e){const t={scope:e.scope};return e.project&&(t.project=e.project),e.agentId&&(t.agentId=e.agentId),t}async function sr(e,t){const n=await fetch(e,t);if(!n.ok){const i=await n.json().catch(()=>null);throw new Error((i==null?void 0:i.detail)||(i==null?void 0:i.title)||`HTTP ${n.status}`)}return await n.json()}const Uie=()=>({title:"",body:"",category:"note",tags:"",salience:3});function Fie(){var re,me,se;const e=Xe(),[t,n]=C.useState([]),[i,s]=C.useState(null),[a,o]=C.useState(!1),[c,u]=C.useState([]),[f,m]=C.useState(null),[p,y]=C.useState(!1),[b,x]=C.useState(""),[w,E]=C.useState(!0),[v,_]=C.useState([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(null),[I,P]=C.useState(null),[U,q]=C.useState(""),[V,O]=C.useState(""),R=C.useCallback(async()=>{try{const{scopes:Q}=await sr("/api/memory/scopes"),ye=mc(Q).map(zie).filter(_e=>_e!=null);n(ye),s(_e=>_e??ye[0]??null)}catch(Q){m(Q instanceof Error?Q.message:String(Q))}},[]),z=C.useCallback(async Q=>{try{const ye=new URLSearchParams(Mo(Q)).toString(),{data:_e}=await sr(`/api/memory/entries?${ye}`);u(mc(_e).map(Bie).filter(ze=>ze!=null))}catch(ye){m(ye instanceof Error?ye.message:String(ye))}},[]);C.useEffect(()=>{R(),sr("/api/system/memory").then(Q=>{const ye=uT(Q);P(ye),q(ye.mode),O(ye.externalUrl)}).catch(()=>{})},[R]),C.useEffect(()=>{i&&z(i),(i==null?void 0:i.scope)==="project"&&i.project?sr(`/api/memory/external?project=${encodeURIComponent(i.project)}`).then(Q=>D(Q)).catch(()=>D(null)):D(null)},[i,z]);const G=C.useCallback(async()=>{if(!b.trim()){_([]);return}y(!0),m(null);try{const Q=new URLSearchParams({q:b,limit:"20"});if(w)Q.set("all","1");else if(i)for(const[_e,ze]of Object.entries(Mo(i)))Q.set(_e,ze);const{results:ye}=await sr(`/api/memory/recall?${Q.toString()}`);_(mc(ye))}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}},[b,w,i]),Y=C.useCallback(async()=>{if(!(!i||!k)){y(!0),m(null);try{await sr("/api/memory/entries",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...Mo(i),id:k.id,title:k.title,body:k.body,category:k.category,tags:k.tags.split(",").map(Q=>Q.trim()).filter(Boolean),salience:k.salience})}),T(null),await Promise.all([z(i),R()])}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}}},[i,k,z,R]),K=C.useCallback(async Q=>{if(i){y(!0),m(null);try{const ye=new URLSearchParams(Mo(i)).toString();await sr(`/api/memory/entries/${encodeURIComponent(Q)}?${ye}`,{method:"DELETE"}),await Promise.all([z(i),R()])}catch(ye){m(ye instanceof Error?ye.message:String(ye))}finally{y(!1)}}},[i,z,R]),B=C.useCallback(async(Q,ye,_e)=>{if(i){y(!0),m(null);try{await sr("/api/memory/promote",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({from:Mo(i),id:Q.id,to:Mo(ye),move:_e})}),j(null),await Promise.all([z(i),R()])}catch(ze){m(ze instanceof Error?ze.message:String(ze))}finally{y(!1)}}},[i,z,R]),F=C.useCallback(async()=>{if(i){y(!0),m(null);try{const ye=(await sr("/api/memory/gc",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(Mo(i))})).results[0];ye&&m(`收敛完成:清 tombstone ${ye.purged}、去重 ${ye.deduped}、剩余 ${ye.kept}`),await Promise.all([z(i),R()])}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}}},[i,z,R]),W=C.useCallback(async()=>{y(!0),m(null);try{const Q=uT(await sr("/api/system/memory",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({mode:U,externalUrl:V})}));P(Q),q(Q.mode),O(Q.externalUrl),m("模式已保存(重启 worker 生效)")}catch(Q){m(Q instanceof Error?Q.message:String(Q))}finally{y(!1)}},[U,V]),$=I!=null&&(U!==I.mode||V!==I.externalUrl),ae=U==="external"||U==="local+external",be=C.useMemo(()=>A?t.filter(Q=>jo(Q)!==jo(i??{scope:""})):[],[A,t,i]),le=Array.isArray((re=M==null?void 0:M.profile)==null?void 0:re.topConcepts)?M.profile.topConcepts:[],Ne=Array.isArray((me=M==null?void 0:M.graph)==null?void 0:me.edges)?M.graph.edges.length:0;return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] font-bold text-2xl text-[var(--color-text)]",children:e("nav.memory")}),d.jsx("span",{className:"text-xs text-[var(--color-text)] opacity-60",children:"本地记忆 v2 · markdown 真源"})]}),I&&d.jsxs("section",{className:"nb-card flex flex-wrap items-end gap-3",children:[d.jsxs("div",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:"记忆模式"}),d.jsx(pc,{value:U,onChange:q,ariaLabel:"记忆模式",options:I.modeOptions.map(Q=>({value:Q,label:Q}))})]}),ae&&d.jsxs("label",{className:"flex flex-col gap-1 text-sm flex-1 min-w-[220px]",children:[d.jsx("span",{className:"font-bold",children:"外部后端地址"}),d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-xs",value:V,onChange:Q=>O(Q.target.value),placeholder:"http://127.0.0.1:3113",spellCheck:!1,"aria-label":"外部后端地址"})]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:W,disabled:p||!$,"aria-label":"保存模式",children:"保存模式"})]}),(()=>{const Q=new Date(Date.now()-6048e5).toISOString(),ye=i?jo(i):"",_e=a?t:t.filter(fe=>fe.scope!=="project"||fe.updated>=Q||jo(fe)===ye),ze=t.length-_e.length;return d.jsxs("div",{className:"flex gap-2 flex-wrap items-center",children:[d.jsx("input",{value:b,onChange:fe=>x(fe.target.value),onKeyDown:fe=>fe.key==="Enter"&&G(),placeholder:"检索记忆…","aria-label":"检索记忆",className:"nb-input flex-1 min-w-[200px] font-[family-name:var(--font-mono)] text-sm"}),d.jsxs("label",{className:"flex items-center gap-1 text-sm font-semibold",children:[d.jsx("input",{type:"checkbox",checked:w,onChange:fe=>E(fe.target.checked),"aria-label":"全局检索"}),"全局"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:G,disabled:p,"aria-label":"检索",children:p?"…":"检索"}),d.jsx(pc,{className:"min-w-[180px]",value:ye,onChange:fe=>s(t.find(Se=>jo(Se)===fe)??null),ariaLabel:"选择作用域",placeholder:"选择作用域",options:_e.map(fe=>({value:jo(fe),label:lp(fe)}))}),(ze>0||a)&&d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>o(fe=>!fe),"aria-label":a?"收起更早项目":"显示更早项目",children:a?"收起更早":`含更早 (${ze})`}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>T(Uie()),disabled:!i,"aria-label":"新建记忆",children:"+ 新建"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-yellow",onClick:F,disabled:p||!i,"aria-label":"收敛去重",children:"收敛"})]})})(),f&&d.jsxs("div",{className:"text-sm text-[var(--color-text)] font-semibold nb-card py-2",children:["ℹ ",f]}),v.length>0&&d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:["检索结果(",v.length,")"]}),v.map(Q=>d.jsxs("div",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs opacity-60 font-[family-name:var(--font-mono)]",children:[d.jsx("span",{className:"nb-badge",children:Q.source==="external"?"🌐 外部":"📁 本地"}),d.jsx("span",{children:Q.source==="external"?Q.type??"":Q.scope==="project"?`项目:${Q.project}`:Q.scope}),Q.category&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"·"}),d.jsx("span",{children:Q.category})]})]}),d.jsx("div",{className:"font-bold text-sm mt-1",children:Q.title}),d.jsx("div",{className:"text-sm mt-1 whitespace-pre-wrap opacity-80",children:Q.snippet.slice(0,300)})]},Q.id))]}),M&&(le.length||Ne)?d.jsxs("section",{className:"nb-card flex flex-col gap-1",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:"🌐 外部智能(agentmemory)"}),le.length?d.jsxs("div",{className:"text-xs",children:[d.jsx("span",{className:"font-bold",children:"概念:"}),le.slice(0,8).map(Q=>d.jsx("span",{className:"nb-badge ml-1",children:Q.concept},Q.concept))]}):null,d.jsxs("div",{className:"text-xs opacity-70 font-[family-name:var(--font-mono)]",children:["知识图谱 ",Ne," 条边 · 观测 ",((se=M.profile)==null?void 0:se.totalObservations)??0]})]}):null,k&&d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-6 bg-black/30 overflow-hidden",onMouseDown:Q=>{Q.target===Q.currentTarget&&T(null)},children:d.jsxs("div",{className:"nb-card w-full max-w-2xl flex flex-col gap-2",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:k.id?"编辑记忆":"新建记忆"}),d.jsx("input",{className:"nb-input text-sm",value:k.title,onChange:Q=>T({...k,title:Q.target.value}),placeholder:"标题","aria-label":"标题"}),d.jsxs("div",{className:"flex gap-2 flex-wrap items-end",children:[d.jsx(pc,{className:"min-w-[140px]",value:k.category,onChange:Q=>T({...k,category:Q}),ariaLabel:"类别",options:Lie.map(Q=>({value:Q,label:Q}))}),d.jsx("input",{className:"nb-input flex-1 min-w-[160px] text-sm",value:k.tags,onChange:Q=>T({...k,tags:Q.target.value}),placeholder:"标签(逗号分隔)","aria-label":"标签"}),d.jsxs("label",{className:"flex items-center gap-1 text-sm",children:["显著度",d.jsx("input",{className:"nb-input w-16",type:"number",min:1,max:5,value:k.salience,onChange:Q=>T({...k,salience:Number(Q.target.value)}),"aria-label":"显著度"})]})]}),d.jsx("textarea",{className:"nb-input font-[family-name:var(--font-mono)] text-sm min-h-[120px]",value:k.body,onChange:Q=>T({...k,body:Q.target.value}),placeholder:"正文","aria-label":"正文"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint",onClick:Y,disabled:p||!k.title.trim()||!k.body.trim(),"aria-label":"保存",children:"保存"}),d.jsx("button",{type:"button",className:"nb-btn",onClick:()=>T(null),"aria-label":"取消",children:"取消"})]})]})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:i?lp(i):"条目"}),c.length===0&&d.jsx("div",{className:"nb-card text-sm opacity-60",children:"(无记忆)"}),c.map(Q=>d.jsxs("div",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs opacity-60 font-[family-name:var(--font-mono)] flex-wrap",children:[d.jsx("span",{className:"nb-badge",children:Q.category}),d.jsxs("span",{children:["s",Q.salience]}),d.jsx("span",{children:"·"}),d.jsx("span",{children:Q.source}),Q.tags.map(ye=>d.jsxs("span",{children:["#",ye]},ye))]}),d.jsx("div",{className:"font-bold text-sm mt-1",children:Q.title}),d.jsx("div",{className:"text-sm mt-1 whitespace-pre-wrap opacity-80",children:Q.body.slice(0,400)}),d.jsxs("div",{className:"flex gap-2 mt-2",children:[d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue text-xs",onClick:()=>T({id:Q.id,title:Q.title,body:Q.body,category:Q.category,tags:Q.tags.join(", "),salience:Q.salience}),"aria-label":"编辑",children:"编辑"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-purple text-xs",onClick:()=>j(Q),"aria-label":"提升",children:"提升"}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-danger text-xs",onClick:()=>K(Q.id),"aria-label":"删除",children:"删除"})]}),(A==null?void 0:A.id)===Q.id&&d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 border-t-[3px] border-[var(--color-text)] pt-2",children:[d.jsx("span",{className:"text-xs font-bold",children:"提升到:"}),be.map(ye=>d.jsx("button",{type:"button",className:"nb-btn nb-btn-mint text-xs",onClick:()=>B(Q,ye,!1),"aria-label":`复制到${lp(ye)}`,children:lp(ye)},jo(ye))),be.length===0&&d.jsx("span",{className:"text-xs opacity-60",children:"(无其它作用域)"}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>j(null),"aria-label":"取消提升",children:"取消"})]})]},Q.id))]})]})}async function $ie(){return(await _t("/api/channels")).data??{console:{},adapters:[]}}async function qie(e){return(await Rm("/api/channels",e)).data}async function Hie(){return(await _t("/api/codex-proxy")).data}async function Vie(){return(await Ks("/api/codex-proxy/install")).data}async function Kie(e){const t=await fetch(`/api/codex-proxy?purgeAuth=${e?"1":"0"}`,{method:"DELETE",headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return(await t.json()).data}async function Gie(){return(await Ks("/api/codex-proxy/auth/start")).data}async function Wie(){await Ks("/api/codex-proxy/auth/cancel")}function Yie(e){return _t(`/api/media-providers?capability=${encodeURIComponent(e)}`)}async function Xie(e){const t=await fetch("/api/media-providers",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return t.json()}function Qie(e){return Yv(`/api/media-providers/${encodeURIComponent(e)}`)}async function Zie(e,t){const n=await fetch(`/api/media-providers/default/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}const dv={image:"图片",video:"视频",music:"音乐",voice:"语音","3d":"3D",embedding:"向量(Embedding)",rerank:"重排(Rerank)"},Jie={image:["codex","openai","volcengine","minimax","tripo","agnes","bailian","openrouter"],video:["volcengine"],music:["minimax"],voice:["doubao"],"3d":["tripo"],embedding:["openai-compatible"],rerank:["openai-compatible"]},HL={codex:"",openai:"https://api.openai.com/v1",tripo:"https://openapi.tripo3d.ai",volcengine:"https://ark.cn-beijing.volces.com/api/v3",minimax:"https://api.minimaxi.com",doubao:"https://openspeech.bytedance.com",agnes:"https://apihub.agnes-ai.com",bailian:"https://dashscope.aliyuncs.com",openrouter:"https://openrouter.ai/api/v1","openai-compatible":""},ese=new Set(["codex"]);function tse({capability:e}){var E,v,_;const t=tn(),{alert:n,confirm:i}=Ln(),s=at({queryKey:["media-providers",e],queryFn:()=>Yie(e)}),[a,o]=C.useState(null),c=Jie[e]??[],u=((E=s.data)==null?void 0:E.providers)??[],f=(_=(v=s.data)==null?void 0:v.defaults)==null?void 0:_[e],m=zt({mutationFn:k=>Xie(k),onSuccess:()=>{o(null),t.invalidateQueries({queryKey:["media-providers",e]})},onError:k=>void n({title:"保存失败",body:k instanceof Error?k.message:String(k)})}),p=zt({mutationFn:k=>Qie(k),onSuccess:()=>void t.invalidateQueries({queryKey:["media-providers",e]}),onError:k=>void n({title:"删除失败",body:k instanceof Error?k.message:String(k)})}),y=zt({mutationFn:k=>Zie(e,k),onSuccess:()=>void t.invalidateQueries({queryKey:["media-providers",e]}),onError:k=>void n({title:"设默认失败",body:k instanceof Error?k.message:String(k)})}),b=(k,T)=>(f==null?void 0:f.providerId)===k&&(f==null?void 0:f.model)===T,x=()=>o({isNew:!0,entry:{id:"",name:"",capability:e,adapter:c[0]??"",baseUrl:c[0]?HL[c[0]]??"":"",apiKey:"",models:[]}}),w=k=>o({isNew:!1,entry:{id:k.id,name:k.name,capability:e,adapter:k.adapter,baseUrl:k.baseUrl,apiKey:"",models:k.models}});return d.jsxs("section",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[d.jsxs("div",{children:[d.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:[dv[e],"供应商"]}),d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:["增删该能力的第三方生成端点(adapter + Base URL + key + models)。**点模型标签设为该能力默认**;✓ = 当前默认。",f?d.jsxs(d.Fragment,{children:[" ","当前默认:",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:f.providerId}),f.model?d.jsxs(d.Fragment,{children:[" · ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:f.model})]}):null]}):" 当前默认:未设置"]})]}),d.jsxs("button",{className:"nb-btn nb-btn-primary shrink-0",style:{padding:"8px 16px"},type:"button",onClick:x,"aria-label":`添加${dv[e]}供应商`,children:[d.jsx(Gn,{size:14,strokeWidth:3})," 添加供应商"]})]}),d.jsxs("div",{className:"flex flex-col gap-2 mt-4",children:[s.isLoading&&d.jsxs("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 加载中…"]}),!s.isLoading&&u.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"(无供应商)"}),u.map(k=>d.jsxs("div",{className:"rounded-lg px-3 py-2 border-2 border-[var(--color-text)]",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:k.id}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm",children:[" · ",k.name]}),d.jsx("span",{className:"ml-2 text-[10px] font-bold px-2 py-0.5 rounded-md border-2 border-[var(--color-text)] bg-[var(--color-accent-yellow)]",children:k.adapter}),d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:[k.baseUrl," · key ",k.keyMasked||"未设置"]})]}),d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>w(k),"aria-label":`编辑 ${k.id}`,children:d.jsx(Vv,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:async()=>{await i({title:"删除供应商",body:`删除 ${k.id}?`,danger:!0})&&p.mutate(k.id)},"aria-label":`删除 ${k.id}`,children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),k.models.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:k.models.map(T=>{const A=b(k.id,T);return d.jsxs("button",{type:"button",onClick:()=>y.mutate({providerId:k.id,model:T}),disabled:y.isPending,"aria-pressed":A,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",A?"nb-btn-mint":""].join(" "),title:A?"当前默认":"设为该能力默认",children:[T,A?" ✓":""]},T)})})]},k.id))]}),a&&d.jsx(fw,{onClose:()=>o(null),children:d.jsx(ise,{state:a,adapters:c,onChange:k=>o({...a,entry:k}),onCancel:()=>o(null),onSave:k=>m.mutate(k),saving:m.isPending})})]})}function nse(e,t){const n=[...e];for(const i of t.split(/[,,\n\r]+/)){const s=i.trim();s&&!n.includes(s)&&n.push(s)}return n}function ise({state:e,adapters:t,onChange:n,onCancel:i,onSave:s,saving:a}){const o=e.entry,[c,u]=C.useState(""),f=b=>n({...o,...b}),m=ese.has(o.adapter),p=/^[a-zA-Z0-9_-]+$/.test(o.id)&&!!o.name.trim()&&!!o.adapter.trim()&&(m||!!o.baseUrl.trim()),y=b=>{f({adapter:b,baseUrl:HL[b]??""})};return d.jsxs("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,640px)] max-h-[88vh] overflow-y-auto",children:[d.jsxs("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:[e.isNew?"新增供应商":`编辑 ${o.id}`,d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-normal",children:[" (",dv[o.capability],")"]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["id(英数 _ -)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)]",value:o.id,disabled:!e.isNew,onChange:b=>f({id:b.target.value}),placeholder:"如 my-tripo",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["名称",d.jsx("input",{className:"nb-input",value:o.name,onChange:b=>f({name:b.target.value}),placeholder:"显示名"})]})]}),d.jsxs("div",{className:"flex flex-col gap-1 text-sm font-bold",children:["adapter",d.jsx(pc,{value:o.adapter,onChange:y,ariaLabel:"adapter",options:t.map(b=>({value:b,label:b}))})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Base URL",m&&"(订阅无需,可留空)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:o.baseUrl,onChange:b=>f({baseUrl:b.target.value}),placeholder:m?"订阅走本地凭据,无需填":"https://api.example.com",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["API Key",m?"(订阅无需)":!e.isNew&&"(留空=保留)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:o.apiKey??"",onChange:b=>f({apiKey:b.target.value}),placeholder:m?"订阅无需":e.isNew?"sk-...":"留空保留",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{htmlFor:"provider-models",className:"text-sm font-bold",children:"Models"}),d.jsx(VL,{models:o.models,draft:c,onModelsChange:b=>f({models:b}),onDraftChange:u}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"输入模型名,按 Enter 或逗号添加"})]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"8px 16px"},type:"button",onClick:i,children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"8px 16px"},type:"button",disabled:!p||a,onClick:()=>s({...o,models:nse(o.models,c)}),children:[a?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]})]})}const dT=[{key:"memory",labelKey:"plugins.tab.memory"},{key:"channel",labelKey:"plugins.tab.channel"},{key:"model",labelKey:"plugins.tab.model"},{key:"tool",labelKey:"plugins.tab.tool"}];function sse(){const e=Xe(),[t,n]=C.useState("memory");return d.jsxs("div",{className:"flex flex-col gap-6 w-full",children:[d.jsxs("header",{children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:e("plugins.h1")}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:e("plugins.desc")})]}),d.jsx(Zc,{ariaLabel:e("plugins.h1"),className:"",value:t,onChange:n,options:dT.map(i=>({value:i.key,label:e(i.labelKey)}))}),d.jsx("div",{role:"tabpanel",children:t==="memory"?d.jsx(ase,{}):t==="channel"?d.jsx(hse,{}):t==="model"?d.jsx(lse,{}):d.jsx(rse,{label:e(dT.find(i=>i.key===t).labelKey)})})]})}function rse({label:e}){const t=Xe();return d.jsx("section",{className:"nb-card",children:d.jsxs("p",{className:"text-[var(--color-text-muted)] text-sm",children:[e," — ",t("plugins.comingSoon")]})})}function ase(){var x,w,E;const e=Xe(),t=tn(),{alert:n}=Ln(),i=at({queryKey:["system-memory"],queryFn:Y6}),[s,a]=C.useState(null),[o,c]=C.useState(null);C.useEffect(()=>{i.data&&s===null&&(a(i.data.provider),c(i.data.url))},[i.data,s]);const u=s??((x=i.data)==null?void 0:x.provider)??"agentmemory",f=o??((w=i.data)==null?void 0:w.url)??"",m=i.data!=null&&(u!==i.data.provider||u==="custom"&&f!==i.data.url),p=v=>{const _=`system.memory.opt.${v}`;return e(_)},y=zt({mutationFn:()=>X6(u,u==="custom"?f:""),onSuccess:()=>{t.invalidateQueries({queryKey:["system-memory"]}),t.invalidateQueries({queryKey:["system-env"]})},onError:v=>{n({title:e("system.memory.error"),body:v instanceof Error?v.message:String(v)})}}),b=((E=i.data)==null?void 0:E.options)??["none","builtin","agentmemory","custom"];return d.jsxs("section",{className:"nb-card",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-1",children:e("system.memory.title")}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mb-3",children:e("system.memory.desc")}),d.jsxs("div",{className:"flex flex-col gap-3 max-w-md",children:[d.jsxs("div",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:e("system.memory.provider")}),d.jsx(pc,{value:u,onChange:a,ariaLabel:e("system.memory.provider"),options:b.map(v=>({value:v,label:p(v)}))})]}),u==="custom"&&d.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[d.jsx("span",{className:"font-bold",children:e("system.memory.url")}),d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-xs",type:"text",value:f,onChange:v=>c(v.target.value),placeholder:e("system.memory.url.placeholder"),spellCheck:!1,"aria-label":e("system.memory.url")})]}),d.jsx("div",{className:"flex justify-end",children:d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 12px",fontSize:12},onClick:()=>y.mutate(),disabled:!m||y.isPending,type:"button","aria-label":e("system.memory.save.aria"),children:[y.isPending?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:12,strokeWidth:3}),y.isSuccess&&!m?e("system.memory.saved"):e("system.memory.save")]})})]})]})}const ose=[{key:"llm",label:"sps agent"},{key:"image",label:"图片"},{key:"video",label:"视频"},{key:"music",label:"音乐"},{key:"voice",label:"语音"},{key:"3d",label:"3D"},{key:"embedding",label:"Embedding"},{key:"rerank",label:"Rerank"}];function lse(){const[e,t]=C.useState("llm");return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("div",{className:"flex flex-wrap gap-2",role:"tablist","aria-label":"模型/资源供应商",children:ose.map(n=>{const i=e===n.key;return d.jsx("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>t(n.key),className:["nb-btn",i?"nb-btn-primary":""].join(" "),style:{padding:"6px 14px"},children:n.label},n.key)})}),e==="llm"?d.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base border-b-2 border-[var(--color-text)] pb-1",children:["Anthropic 兼容 ",d.jsx("span",{className:"text-xs font-normal text-[var(--color-text-muted)]",children:"· 含 Claude 订阅"})]}),d.jsx(fT,{only:"anthropic"})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base border-b-2 border-[var(--color-text)] pb-1",children:["OpenAI 兼容 ",d.jsx("span",{className:"text-xs font-normal text-[var(--color-text-muted)]",children:"· 含 codex 订阅"})]}),d.jsx(fT,{only:"openai"})]})]}):d.jsx(tse,{capability:e})]})}function fT({only:e}={}){var _,k,T;const t=tn(),{alert:n,confirm:i}=Ln(),s=at({queryKey:["providers"],queryFn:x1}),o=(_=at({queryKey:["system-agents"],queryFn:Xv}).data)==null?void 0:_.agents,[c,u]=C.useState(null),f=zt({mutationFn:A=>IW(c.kind,A),onSuccess:()=>{u(null),t.invalidateQueries({queryKey:["providers"]})},onError:A=>void n({title:"保存失败",body:A instanceof Error?A.message:String(A)})}),m=zt({mutationFn:A=>PW(A.kind,A.id),onSuccess:()=>void t.invalidateQueries({queryKey:["providers"]}),onError:A=>void n({title:"删除失败",body:A instanceof Error?A.message:String(A)})}),p=zt({mutationFn:A=>Q6(A),onSuccess:()=>void t.invalidateQueries({queryKey:["system-agents"]}),onError:A=>void n({title:"设默认失败",body:A instanceof Error?A.message:String(A)})}),y=(A,j,M)=>{if(!o)return!1;const D=A==="anthropic"?o.worker:o.reviewer;return(D.providerId||"official")===j&&D.model===M},b=(A,j,M)=>{if(!o)return;let D;if(A==="anthropic"){const I={...o.worker,model:M};j==="official"?delete I.providerId:I.providerId=j,D={...o,worker:I}}else D={...o,reviewer:{...o.reviewer,providerId:j,model:M}};p.mutate(D)},x=[{kind:"anthropic",title:"Anthropic 兼容(worker / claude)",items:((k=s.data)==null?void 0:k.anthropic)??[]},{kind:"openai",title:"OpenAI 兼容(reviewer / openai agent)",items:((T=s.data)==null?void 0:T.openai)??[]}],w=e?x.filter(A=>A.kind===e):x,E=A=>u({kind:A,isNew:!0,entry:{id:"",name:"",baseUrl:"",apiKey:"",models:[]}}),v=(A,j)=>u({kind:A,isNew:!1,entry:{id:j.id,name:j.name,baseUrl:j.baseUrl,apiKey:"",models:j.models}});return d.jsxs("section",{className:"nb-card",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-1",children:"模型 API 端点"}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mb-4",children:"本地官方订阅(已登录验证)自动置顶,不可编辑;下方可增删第三方兼容端点。**点模型标签设为默认**(anthropic→worker / openai→监工);✓ = 当前默认。"}),d.jsx("div",{className:["grid grid-cols-1 gap-5",e?"":"lg:grid-cols-2"].join(" "),children:w.map(A=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"font-bold text-sm",children:A.title}),d.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:12},type:"button",onClick:()=>E(A.kind),"aria-label":`添加 ${A.title} 端点`,children:[d.jsx(Gn,{size:12,strokeWidth:3})," 添加"]})]}),A.items.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"(无端点)"}),A.items.map(j=>j.id==="codex-proxy"?d.jsx(use,{isDefault:M=>y(A.kind,j.id,M),pickDefault:M=>b(A.kind,j.id,M),setDefaultPending:p.isPending},j.id):d.jsxs("div",{className:["rounded-lg px-3 py-2 border-2",(j.builtin,"border-[var(--color-text)]")].join(" "),children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:j.id}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm",children:[" · ",j.name]}),j.builtin?d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:["本地订阅",j.detail?` · ${j.detail}`:""," · 已验证可用"]}):d.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:[j.baseUrl," · key ",j.hasKey?j.apiKey:"未设置"]})]}),j.builtin?d.jsx("span",{className:"shrink-0 text-[10px] font-bold px-2 py-0.5 rounded-md border-2 border-[var(--color-text)] bg-[var(--color-accent-yellow)]",children:"内置"}):d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>v(A.kind,j),"aria-label":`编辑 ${j.id}`,children:d.jsx(Vv,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:async()=>{await i({title:"删除端点",body:`删除 ${j.id}?`,danger:!0})&&m.mutate({kind:A.kind,id:j.id})},"aria-label":`删除 ${j.id}`,children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),j.models.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:j.models.map(M=>{const D=y(A.kind,j.id,M);return d.jsxs("button",{type:"button",onClick:()=>b(A.kind,j.id,M),disabled:p.isPending,"aria-pressed":D,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",D?"nb-btn-mint":""].join(" "),title:D?"当前默认":"设为默认",children:[M,D?" ✓":""]},M)})})]},j.id))]},A.kind))}),c&&d.jsx(fw,{onClose:()=>u(null),children:d.jsx(cse,{state:c,onChange:A=>u({...c,entry:A}),onCancel:()=>u(null),onSave:A=>f.mutate(A),saving:f.isPending})})]})}function fv(e,t){const n=[...e];for(const i of t.split(/[,,\n\r]+/)){const s=i.trim();s&&!n.includes(s)&&n.push(s)}return n}function VL({models:e,draft:t,onModelsChange:n,onDraftChange:i}){const s=a=>{n(fv(e,a)),i("")};return d.jsxs("div",{className:"nb-input min-h-[46px] w-full flex flex-wrap gap-1.5 items-center px-2.5 py-2",children:[e.map(a=>d.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-[var(--color-border-light)] bg-[var(--surface-control)] px-2 py-1 text-xs font-[family-name:var(--font-mono)]",children:[d.jsx("span",{className:"max-w-[480px] truncate",children:a}),d.jsx("button",{type:"button",className:"shrink-0 text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>n(e.filter(o=>o!==a)),"aria-label":`删除模型 ${a}`,children:d.jsx(vn,{size:12,strokeWidth:2.5})})]},a)),d.jsx("input",{id:"provider-models",className:"min-w-[180px] flex-1 bg-transparent px-1 py-0.5 text-sm outline-none font-[family-name:var(--font-mono)]",value:t,onChange:a=>{const o=a.target.value,c=o.split(/[,,\n\r]/);if(c.length===1){i(o);return}const u=c.pop()??"";n(fv(e,c.join(","))),i(u)},onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),s(t)):a.key==="Backspace"&&!t&&e.length>0&&n(e.slice(0,-1))},placeholder:e.length>0?"继续添加模型":"输入模型名后按 Enter","aria-label":"Models",spellCheck:!1})]})}function cse({state:e,onChange:t,onCancel:n,onSave:i,saving:s}){const a=e.entry,[o,c]=C.useState(""),u=m=>t({...a,...m}),f=/^[a-zA-Z0-9_-]+$/.test(a.id)&&a.name.trim()&&a.baseUrl.trim();return d.jsxs("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,640px)] max-h-[88vh] overflow-y-auto",children:[d.jsxs("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:[e.isNew?"新增端点":`编辑 ${a.id}`,d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-normal",children:["(",e.kind,")"]})]}),d.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["id(英数 _ -)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)]",value:a.id,disabled:!e.isNew,onChange:m=>u({id:m.target.value}),placeholder:"如 my-openai",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["名称",d.jsx("input",{className:"nb-input",value:a.name,onChange:m=>u({name:m.target.value}),placeholder:"显示名"})]})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Base URL",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:a.baseUrl,onChange:m=>u({baseUrl:m.target.value}),placeholder:"https://api.example.com/v1",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["API Key",!e.isNew&&"(留空=保留)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:a.apiKey??"",onChange:m=>u({apiKey:m.target.value}),placeholder:e.isNew?"sk-...":"••••(留空不改)",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{htmlFor:"provider-models",className:"text-sm font-bold",children:"Models"}),d.jsx(VL,{models:a.models,draft:o,onModelsChange:m=>u({models:m}),onDraftChange:c}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"输入模型名,按 Enter 或逗号添加"})]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"8px 16px"},type:"button",onClick:n,children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"8px 16px"},type:"button",disabled:!f||s,onClick:()=>i({...a,models:fv(a.models,o)}),children:[s?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]})]})}function use({isDefault:e,pickDefault:t,setDefaultPending:n}){const i=tn(),{alert:s,confirm:a}=Ln(),[o,c]=C.useState(!1),[u,f]=C.useState(null),[m,p]=C.useState(!1),[y,b]=C.useState(!1),[x,w]=C.useState(!1),E=at({queryKey:["codex-proxy"],queryFn:Hie,refetchInterval:o?3e3:!1}),v=E.data;C.useEffect(()=>{o&&(v!=null&&v.authed)?(c(!1),f(null),i.invalidateQueries({queryKey:["codex-proxy"]})):o&&(v!=null&&v.authError)&&(c(!1),f(null),s({title:"授权失败",body:v.authError}))},[o,v==null?void 0:v.authed,v==null?void 0:v.authError,i,s]);const _=zt({mutationFn:Vie,onSuccess:I=>{i.invalidateQueries({queryKey:["codex-proxy"]}),i.invalidateQueries({queryKey:["providers"]}),I.ok||s({title:"安装失败",body:(I.output||"未知错误").slice(-600)})},onError:I=>void s({title:"安装失败",body:I instanceof Error?I.message:String(I)})}),k=zt({mutationFn:I=>Kie(I),onSuccess:I=>{p(!1),b(!1),i.invalidateQueries({queryKey:["codex-proxy"]}),i.invalidateQueries({queryKey:["providers"]}),i.invalidateQueries({queryKey:["system-agents"]}),I.ok||s({title:"卸载未完成",body:I.note??"删除失败(可能需 sudo)"})},onError:I=>void s({title:"卸载失败",body:I instanceof Error?I.message:String(I)})}),T=async()=>{await a({title:"安装 claude-code-proxy",body:"将运行官方安装脚本(curl … install.sh | bash),下载预编译二进制到 ~/.local/bin。继续?"})&&_.mutate()},A=async()=>{c(!0),f(null);try{const I=await Gie();f(I)}catch(I){c(!1),s({title:"订阅失败",body:I instanceof Error?I.message:String(I)})}},j=()=>{Wie(),c(!1),f(null)},M=_.isPending||(v==null?void 0:v.installing),D=x&&(v!=null&&v.models.all.length)?v.models.all:(v==null?void 0:v.models.curated)??[];return d.jsxs("div",{className:"rounded-lg px-3 py-2 border-2 border-[var(--color-text)]",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm",children:"codex-proxy"}),d.jsx("span",{className:"text-[var(--color-text-muted)] text-sm",children:" · ChatGPT 订阅"}),d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] truncate",children:v?v.binInstalled?v.authed?`已订阅${v.account?` · ${v.account.slice(0,8)}…`:""} · worker 出 GPT`:v.nativeCodex.available?"已检测到本机 ChatGPT 订阅 · proxy 待独立授权":"已安装 · 未检测到 ChatGPT 登录":"未安装 claude-code-proxy":"加载中…"})]}),(v==null?void 0:v.binInstalled)&&d.jsxs("div",{className:"flex gap-1 shrink-0",children:[d.jsx("button",{className:"nb-btn",style:{padding:"4px 8px"},type:"button",onClick:()=>void E.refetch(),disabled:E.isFetching,"aria-label":"重新获取模型",title:"重新获取模型(codex-proxy 模型可能过期)",children:E.isFetching?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(ea,{size:12,strokeWidth:3})}),d.jsx("button",{className:"nb-btn nb-btn-danger",style:{padding:"4px 8px"},type:"button",onClick:()=>p(!0),"aria-label":"卸载 codex-proxy",children:d.jsx(qi,{size:12,strokeWidth:3})})]})]}),d.jsx("div",{className:"mt-2",children:v?v.binInstalled?v.authed?d.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[D.map(I=>{const P=e(I);return d.jsxs("button",{type:"button",onClick:()=>t(I),disabled:n,"aria-pressed":P,className:["nb-btn px-2 py-0.5 text-xs font-[family-name:var(--font-mono)]",P?"nb-btn-mint":""].join(" "),title:P?"当前默认":"设为 worker 默认",children:[I,P?" ✓":""]},I)}),v.models.all.length>v.models.curated.length&&d.jsx("button",{type:"button",className:"text-xs text-[var(--color-text-muted)] underline",onClick:()=>w(I=>!I),children:x?"收起":`显示全部(${v.models.all.length})`})]}):d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 12px",fontSize:12},type:"button",onClick:A,children:[d.jsx(_U,{size:12,strokeWidth:3})," ",v.nativeCodex.available?"授权 proxy":"授权 ChatGPT"]}):d.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"4px 12px",fontSize:12},type:"button",disabled:!!M,onClick:T,children:[M?d.jsx(lt,{size:12,strokeWidth:3,className:"animate-spin"}):d.jsx(Tj,{size:12,strokeWidth:3}),M?" 安装中…":" 安装插件"]}):d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin text-[var(--color-text-muted)]"})}),o&&d.jsxs(hT,{onClose:j,children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"授权 codex-proxy(浏览器)"}),(v==null?void 0:v.nativeCodex.available)&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"已检测到本机 Codex CLI 的 ChatGPT 登录。codex-proxy 使用独立凭据,不读取或修改 ~/.codex;为避免令牌轮换冲突,需要为 proxy 单独授权一次。"}),u!=null&&u.authorizationUrl?d.jsxs("div",{className:"flex flex-col gap-3 text-sm",children:[d.jsxs("div",{children:["① 打开"," ",d.jsxs("a",{href:u.authorizationUrl,target:"_blank",rel:"noreferrer",className:"font-bold underline inline-flex items-center gap-1",children:["ChatGPT 授权页面 ",d.jsx(iU,{size:12,strokeWidth:3})]})]}),d.jsx("div",{children:"② 在浏览器完成授权,成功后会自动返回本机回调页面"}),d.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 等待授权…(完成后自动刷新)"]})]}):d.jsxs("div",{className:"flex flex-col gap-2 text-sm text-[var(--color-text-muted)]",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 正在生成浏览器授权地址…"]}),d.jsxs("div",{children:["若长时间无响应,可在终端运行 ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:"sps codex-proxy auth"}),"。"]})]}),d.jsx("div",{className:"flex justify-end pt-1",children:d.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},type:"button",onClick:j,children:"取消"})})]}),m&&d.jsxs(hT,{onClose:()=>p(!1),children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"卸载 claude-code-proxy"}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"停止 proxy 并删除二进制。默认保留授权(重装免再授权)。"}),d.jsxs("label",{className:"flex items-center gap-2 text-sm font-bold",children:[d.jsx("input",{type:"checkbox",checked:y,onChange:I=>b(I.target.checked)}),"同时清除 proxy 独立授权(macOS 钥匙串或配置目录)"]}),d.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[d.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},type:"button",onClick:()=>p(!1),children:"取消"}),d.jsxs("button",{className:"nb-btn nb-btn-danger",style:{padding:"6px 14px"},type:"button",disabled:k.isPending,onClick:()=>k.mutate(y),children:[k.isPending?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(qi,{size:14,strokeWidth:3})," 卸载"]})]})]})]})}function fw({children:e,onClose:t}){return Ej.createPortal(d.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 p-4",onClick:t,children:d.jsx("div",{onClick:n=>n.stopPropagation(),children:e})}),document.body)}function hT({children:e,onClose:t}){return d.jsx(fw,{onClose:t,children:d.jsx("div",{className:"border-[3px] border-[var(--color-text)] rounded-2xl p-6 bg-[var(--color-bg-cream)] shadow-[6px_6px_0_var(--color-text)] flex flex-col gap-4 w-[min(92vw,520px)]",children:e})})}const dse=["telegram","dingtalk","matrix","slack","discord","feishu"],Fd={telegram:"Telegram",dingtalk:"钉钉 (Stream)",matrix:"Matrix",slack:"Slack",discord:"Discord",feishu:"飞书 / Lark"},fse={telegram:[{key:"token",label:"Bot Token(@BotFather)",type:"password",placeholder:"123456:ABC-..."},{key:"allowedChatIds",label:"允许的 Chat ID(白名单,空=全放)",type:"list",placeholder:"逗号/换行分隔"}],dingtalk:[{key:"clientId",label:"Client ID(AppKey)",type:"text"},{key:"clientSecret",label:"Client Secret(AppSecret)",type:"password"},{key:"allowedConversations",label:"允许的会话 ID(白名单,空=全放)",type:"list"}],matrix:[{key:"homeserver",label:"Homeserver URL",type:"text",placeholder:"https://matrix.org"},{key:"accessToken",label:"Access Token",type:"password"},{key:"allowedRooms",label:"允许的 Room ID(白名单,空=全放)",type:"list"}],slack:[{key:"appToken",label:"App Token(xapp-,Socket Mode)",type:"password",placeholder:"xapp-..."},{key:"botToken",label:"Bot Token(xoxb-)",type:"password",placeholder:"xoxb-..."},{key:"allowedChannels",label:"允许的 Channel(白名单,空=全放)",type:"list"}],discord:[{key:"token",label:"Bot Token",type:"password"},{key:"allowedChannels",label:"允许的 Channel ID(白名单,空=全放)",type:"list"}],feishu:[{key:"appId",label:"App ID",type:"text"},{key:"appSecret",label:"App Secret",type:"password"},{key:"verificationToken",label:"Verification Token",type:"text"},{key:"encryptKey",label:"Encrypt Key(设了则事件 AES 解密)",type:"password"},{key:"port",label:"本机监听端口(默认 9800)",type:"number",placeholder:"9800"},{key:"path",label:"监听路径(默认 /feishu)",type:"text",placeholder:"/feishu"},{key:"allowedChats",label:"允许的 chat_id(白名单,空=全放)",type:"list"}]};function hse(){var x,w,E;const e=tn(),{alert:t}=Ln(),n=at({queryKey:["channels"],queryFn:$ie}),[i,s]=C.useState(null),[a,o]=C.useState({type:"console"});C.useEffect(()=>{n.data&&!i&&s({console:n.data.console??{},adapters:n.data.adapters??[]})},[n.data,i]);const c=zt({mutationFn:()=>qie(i),onSuccess:v=>{s({console:v.console??{},adapters:v.adapters??[]}),e.invalidateQueries({queryKey:["channels"]})},onError:v=>void t({title:"保存失败",body:v instanceof Error?v.message:String(v)})});if(!i)return d.jsx("section",{className:"nb-card",children:d.jsxs("p",{className:"text-sm text-[var(--color-text-muted)] flex items-center gap-2",children:[d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"})," 加载频道配置…"]})});const u=i.adapters??[],f=JSON.stringify(i)!==JSON.stringify({console:((x=n.data)==null?void 0:x.console)??{},adapters:((w=n.data)==null?void 0:w.adapters)??[]}),m=v=>{const _=[...u,{kind:v,enabled:!0}];s({...i,adapters:_}),o({type:"adapter",index:_.length-1})},p=v=>{const _=u.filter((k,T)=>T!==v);s({...i,adapters:_}),o({type:"console"})},y=(v,_)=>{const k=u.map((T,A)=>A===v?{...T,..._}:T);s({...i,adapters:k})},b=v=>s({...i,console:{...i.console,...v}});return d.jsxs("section",{className:"nb-card",children:[d.jsxs("div",{className:"flex items-start justify-between gap-3 mb-1",children:[d.jsxs("div",{children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:"频道(IM 网关)"}),d.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:["接入 Telegram / 钉钉 / 飞书 / Slack / Discord / Matrix。左侧选频道,右侧改设置。保存后 ",d.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:"sps im"})," 重启生效。"]})]}),d.jsxs("button",{className:"nb-btn nb-btn-primary shrink-0",style:{padding:"8px 16px"},type:"button",disabled:!f||c.isPending,onClick:()=>c.mutate(),"aria-label":"保存频道配置",children:[c.isPending?d.jsx(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Ns,{size:14,strokeWidth:3})," 保存"]})]}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[220px_1fr] gap-5 mt-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)] p-2 flex flex-col gap-1",children:[d.jsx(pT,{label:"console 桥接",sub:((E=i.console)==null?void 0:E.url)||"未配置",active:a.type==="console",onClick:()=>o({type:"console"})}),d.jsx("div",{className:"h-px bg-[var(--color-text)] opacity-15 my-0.5"}),u.length===0&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] px-2 py-1",children:"(无频道)"}),u.map((v,_)=>d.jsx(pT,{label:Fd[v.kind]??v.kind,sub:v.enabled===!1?"已停用":"启用",active:a.type==="adapter"&&a.index===_,onClick:()=>o({type:"adapter",index:_})},_))]}),d.jsx(pse,{onAdd:m})]}),d.jsx("div",{className:"border-2 bg-surface-input border-[var(--color-text)] rounded-xl p-4 bg-[var(--color-bg-cream)]",children:(()=>{if(a.type!=="adapter")return d.jsx(mT,{console:i.console??{},onChange:b});const v=u[a.index];if(!v)return d.jsx(mT,{console:i.console??{},onChange:b});const _=a.index;return d.jsx(mse,{adapter:v,onChange:k=>y(_,k),onRemove:()=>p(_)})})()})]})]})}function pse({onAdd:e}){const[t,n]=C.useState(!1),i=C.useRef(null),s=C.useRef(null);return C.useEffect(()=>{const a=o=>{var c;(c=i.current)!=null&&c.contains(o.target)||n(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]),d.jsxs("div",{className:"relative",ref:i,children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary w-full justify-center",onClick:()=>n(a=>!a),"aria-expanded":t,"aria-label":"添加频道",children:[d.jsx(Gn,{size:13,strokeWidth:3})," 添加频道",d.jsx(so,{size:13,strokeWidth:2.5,className:["transition-transform",t?"rotate-180":""].join(" ")})]}),t&&d.jsx("div",{className:"absolute z-30 mt-2 left-0 min-w-full nb-card p-1 overflow-hidden bg-[var(--surface-menu)]",children:d.jsx("div",{ref:s,className:"max-h-[50vh] overflow-y-auto",children:dse.map((a,o)=>d.jsx(Qc,{index:o,root:s,delay:.02,children:d.jsxs("button",{type:"button",className:"dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2",onClick:()=>{e(a),n(!1)},"aria-label":`添加 ${Fd[a]} 频道`,children:[d.jsx(Gn,{size:12,strokeWidth:3,className:"shrink-0"})," ",Fd[a]]})},a))})})]})}function pT({label:e,sub:t,active:n,onClick:i}){return d.jsxs("button",{type:"button",onClick:i,"aria-pressed":n,className:["dimension-menu-item flex-col items-start gap-0.5 px-3 py-2 text-left",n?"dimension-menu-item-active":""].join(" "),children:[d.jsx("div",{className:"font-bold text-sm",children:e}),d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] truncate w-full font-[family-name:var(--font-mono)]",children:t})]})}function mT({console:e,onChange:t}){return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:"console 桥接"}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:"IM 纯文本消息桥接到项目 agent 对话。设了 URL 才启用桥接;token 为 console 鉴权令牌。"})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Console URL",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",value:e.url??"",onChange:n=>t({url:n.target.value}),placeholder:"http://localhost:4321",spellCheck:!1})]}),d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:["Console Token(SPS_CONSOLE_TOKEN)",d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:"password",value:e.token??"",onChange:n=>t({token:n.target.value}),placeholder:"鉴权令牌(可空)",spellCheck:!1})]}),d.jsxs("div",{className:"flex flex-col gap-1 text-sm font-bold",children:["对话后端",d.jsx(pc,{value:e.agentKind??"claude",onChange:n=>t({agentKind:n}),ariaLabel:"对话后端",options:[{value:"claude",label:"claude"},{value:"openai",label:"openai"}]})]})]})}function mse({adapter:e,onChange:t,onRemove:n}){const{confirm:i}=Ln(),s=fse[e.kind]??[],a=e.enabled!==!1;return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-start justify-between gap-2",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:Fd[e.kind]??e.kind}),d.jsxs("span",{className:"text-[var(--color-text-muted)] text-sm font-[family-name:var(--font-mono)]",children:[" · ",e.kind]})]}),d.jsxs("button",{className:"nb-btn nb-btn-danger shrink-0",style:{padding:"4px 10px",fontSize:12},type:"button",onClick:async()=>{await i({title:"删除频道",body:`删除 ${Fd[e.kind]??e.kind} 频道?`,danger:!0})&&n()},"aria-label":"删除频道",children:[d.jsx(qi,{size:12,strokeWidth:3})," 删除"]})]}),d.jsxs("label",{className:"flex items-center gap-2 text-sm font-bold",children:[d.jsx("input",{type:"checkbox",checked:a,onChange:o=>t({enabled:o.target.checked})}),"启用此频道"]}),s.map(o=>d.jsx(gse,{spec:o,value:e[o.key],onChange:c=>t({[o.key]:c})},o.key))]})}function gse({spec:e,value:t,onChange:n}){if(e.type==="list"){const i=Array.isArray(t)?t.map(String):[];return d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:[e.label,d.jsx("textarea",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",rows:2,value:i.join(", "),onChange:s=>{const a=s.target.value.split(/[,\n]/).map(o=>o.trim()).filter(Boolean);n(a.length?a:void 0)},placeholder:e.placeholder,spellCheck:!1})]})}return d.jsxs("label",{className:"flex flex-col gap-1 text-sm font-bold",children:[e.label,d.jsx("input",{className:"nb-input font-[family-name:var(--font-mono)] text-sm",type:e.type==="password"?"password":"text",value:t==null?"":String(t),onChange:i=>{const s=i.target.value;e.type==="number"?n(s.trim()===""?void 0:Number(s)):n(s===""?void 0:s)},placeholder:e.placeholder,spellCheck:!1})]})}function Wn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Wn(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var yse={value:()=>{}};function ag(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Pp(n)}function Pp(e){this._=e}function bse(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");if(s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Pp.prototype=ag.prototype={constructor:Pp,on:function(e,t){var n=this._,i=bse(e+"",n),s,a=-1,o=i.length;if(arguments.length<2){for(;++a<o;)if((s=(e=i[a]).type)&&(s=xse(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(s=(e=i[a]).type)n[s]=gT(n[s],e.name,t);else if(t==null)for(s in n)n[s]=gT(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Pp(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),i=0,s,a;i<s;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],i=0,s=a.length;i<s;++i)a[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],s=0,a=i.length;s<a;++s)i[s].value.apply(t,n)}};function xse(e,t){for(var n=0,i=e.length,s;n<i;++n)if((s=e[n]).name===t)return s.value}function gT(e,t,n){for(var i=0,s=e.length;i<s;++i)if(e[i].name===t){e[i]=yse,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var hv="http://www.w3.org/1999/xhtml";const yT={svg:"http://www.w3.org/2000/svg",xhtml:hv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function og(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),yT.hasOwnProperty(t)?{space:yT[t],local:e}:e}function vse(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hv&&t.documentElement.namespaceURI===hv?t.createElement(e):t.createElementNS(n,e)}}function wse(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function KL(e){var t=og(e);return(t.local?wse:vse)(t)}function Ese(){}function hw(e){return e==null?Ese:function(){return this.querySelector(e)}}function Sse(e){typeof e!="function"&&(e=hw(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=new Array(o),u,f,m=0;m<o;++m)(u=a[m])&&(f=e.call(u,u.__data__,m,a))&&("__data__"in u&&(f.__data__=u.__data__),c[m]=f);return new rs(i,this._parents)}function kse(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Nse(){return[]}function GL(e){return e==null?Nse:function(){return this.querySelectorAll(e)}}function _se(e){return function(){return kse(e.apply(this,arguments))}}function Cse(e){typeof e=="function"?e=_se(e):e=GL(e);for(var t=this._groups,n=t.length,i=[],s=[],a=0;a<n;++a)for(var o=t[a],c=o.length,u,f=0;f<c;++f)(u=o[f])&&(i.push(e.call(u,u.__data__,f,o)),s.push(u));return new rs(i,s)}function WL(e){return function(){return this.matches(e)}}function YL(e){return function(t){return t.matches(e)}}var Tse=Array.prototype.find;function Ase(e){return function(){return Tse.call(this.children,e)}}function jse(){return this.firstElementChild}function Mse(e){return this.select(e==null?jse:Ase(typeof e=="function"?e:YL(e)))}var Rse=Array.prototype.filter;function Dse(){return Array.from(this.children)}function Ose(e){return function(){return Rse.call(this.children,e)}}function Lse(e){return this.selectAll(e==null?Dse:Ose(typeof e=="function"?e:YL(e)))}function Ise(e){typeof e!="function"&&(e=WL(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=[],u,f=0;f<o;++f)(u=a[f])&&e.call(u,u.__data__,f,a)&&c.push(u);return new rs(i,this._parents)}function XL(e){return new Array(e.length)}function Pse(){return new rs(this._enter||this._groups.map(XL),this._parents)}function ym(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ym.prototype={constructor:ym,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function zse(e){return function(){return e}}function Bse(e,t,n,i,s,a){for(var o=0,c,u=t.length,f=a.length;o<f;++o)(c=t[o])?(c.__data__=a[o],i[o]=c):n[o]=new ym(e,a[o]);for(;o<u;++o)(c=t[o])&&(s[o]=c)}function Use(e,t,n,i,s,a,o){var c,u,f=new Map,m=t.length,p=a.length,y=new Array(m),b;for(c=0;c<m;++c)(u=t[c])&&(y[c]=b=o.call(u,u.__data__,c,t)+"",f.has(b)?s[c]=u:f.set(b,u));for(c=0;c<p;++c)b=o.call(e,a[c],c,a)+"",(u=f.get(b))?(i[c]=u,u.__data__=a[c],f.delete(b)):n[c]=new ym(e,a[c]);for(c=0;c<m;++c)(u=t[c])&&f.get(y[c])===u&&(s[c]=u)}function Fse(e){return e.__data__}function $se(e,t){if(!arguments.length)return Array.from(this,Fse);var n=t?Use:Bse,i=this._parents,s=this._groups;typeof e!="function"&&(e=zse(e));for(var a=s.length,o=new Array(a),c=new Array(a),u=new Array(a),f=0;f<a;++f){var m=i[f],p=s[f],y=p.length,b=qse(e.call(m,m&&m.__data__,f,i)),x=b.length,w=c[f]=new Array(x),E=o[f]=new Array(x),v=u[f]=new Array(y);n(m,p,w,E,v,b,t);for(var _=0,k=0,T,A;_<x;++_)if(T=w[_]){for(_>=k&&(k=_+1);!(A=E[k])&&++k<x;);T._next=A||null}}return o=new rs(o,i),o._enter=c,o._exit=u,o}function qse(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hse(){return new rs(this._exit||this._groups.map(XL),this._parents)}function Vse(e,t,n){var i=this.enter(),s=this,a=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),i&&s?i.merge(s).order():s}function Kse(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,s=n.length,a=i.length,o=Math.min(s,a),c=new Array(s),u=0;u<o;++u)for(var f=n[u],m=i[u],p=f.length,y=c[u]=new Array(p),b,x=0;x<p;++x)(b=f[x]||m[x])&&(y[x]=b);for(;u<s;++u)c[u]=n[u];return new rs(c,this._parents)}function Gse(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],s=i.length-1,a=i[s],o;--s>=0;)(o=i[s])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Wse(e){e||(e=Yse);function t(p,y){return p&&y?e(p.__data__,y.__data__):!p-!y}for(var n=this._groups,i=n.length,s=new Array(i),a=0;a<i;++a){for(var o=n[a],c=o.length,u=s[a]=new Array(c),f,m=0;m<c;++m)(f=o[m])&&(u[m]=f);u.sort(t)}return new rs(s,this._parents).order()}function Yse(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xse(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qse(){return Array.from(this)}function Zse(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,a=i.length;s<a;++s){var o=i[s];if(o)return o}return null}function Jse(){let e=0;for(const t of this)++e;return e}function ere(){return!this.node()}function tre(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var s=t[n],a=0,o=s.length,c;a<o;++a)(c=s[a])&&e.call(c,c.__data__,a,s);return this}function nre(e){return function(){this.removeAttribute(e)}}function ire(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sre(e,t){return function(){this.setAttribute(e,t)}}function rre(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function are(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ore(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function lre(e,t){var n=og(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?ire:nre:typeof t=="function"?n.local?ore:are:n.local?rre:sre)(n,t))}function QL(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function cre(e){return function(){this.style.removeProperty(e)}}function ure(e,t,n){return function(){this.style.setProperty(e,t,n)}}function dre(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function fre(e,t,n){return arguments.length>1?this.each((t==null?cre:typeof t=="function"?dre:ure)(e,t,n??"")):Pc(this.node(),e)}function Pc(e,t){return e.style.getPropertyValue(t)||QL(e).getComputedStyle(e,null).getPropertyValue(t)}function hre(e){return function(){delete this[e]}}function pre(e,t){return function(){this[e]=t}}function mre(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function gre(e,t){return arguments.length>1?this.each((t==null?hre:typeof t=="function"?mre:pre)(e,t)):this.node()[e]}function ZL(e){return e.trim().split(/^|\s+/)}function pw(e){return e.classList||new JL(e)}function JL(e){this._node=e,this._names=ZL(e.getAttribute("class")||"")}JL.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function eI(e,t){for(var n=pw(e),i=-1,s=t.length;++i<s;)n.add(t[i])}function tI(e,t){for(var n=pw(e),i=-1,s=t.length;++i<s;)n.remove(t[i])}function yre(e){return function(){eI(this,e)}}function bre(e){return function(){tI(this,e)}}function xre(e,t){return function(){(t.apply(this,arguments)?eI:tI)(this,e)}}function vre(e,t){var n=ZL(e+"");if(arguments.length<2){for(var i=pw(this.node()),s=-1,a=n.length;++s<a;)if(!i.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xre:t?yre:bre)(n,t))}function wre(){this.textContent=""}function Ere(e){return function(){this.textContent=e}}function Sre(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function kre(e){return arguments.length?this.each(e==null?wre:(typeof e=="function"?Sre:Ere)(e)):this.node().textContent}function Nre(){this.innerHTML=""}function _re(e){return function(){this.innerHTML=e}}function Cre(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tre(e){return arguments.length?this.each(e==null?Nre:(typeof e=="function"?Cre:_re)(e)):this.node().innerHTML}function Are(){this.nextSibling&&this.parentNode.appendChild(this)}function jre(){return this.each(Are)}function Mre(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Rre(){return this.each(Mre)}function Dre(e){var t=typeof e=="function"?e:KL(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ore(){return null}function Lre(e,t){var n=typeof e=="function"?e:KL(e),i=t==null?Ore:typeof t=="function"?t:hw(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Ire(){var e=this.parentNode;e&&e.removeChild(this)}function Pre(){return this.each(Ire)}function zre(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bre(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ure(e){return this.select(e?Bre:zre)}function Fre(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $re(e){return function(t){e.call(this,t,this.__data__)}}function qre(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function Hre(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++i]=a;++i?t.length=i:delete this.__on}}}function Vre(e,t,n){return function(){var i=this.__on,s,a=$re(t);if(i){for(var o=0,c=i.length;o<c;++o)if((s=i[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},i?i.push(s):this.__on=[s]}}function Kre(e,t,n){var i=qre(e+""),s,a=i.length,o;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,f=c.length,m;u<f;++u)for(s=0,m=c[u];s<a;++s)if((o=i[s]).type===m.type&&o.name===m.name)return m.value}return}for(c=t?Vre:Hre,s=0;s<a;++s)this.each(c(i[s],t,n));return this}function nI(e,t,n){var i=QL(e),s=i.CustomEvent;typeof s=="function"?s=new s(t,n):(s=i.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Gre(e,t){return function(){return nI(this,e,t)}}function Wre(e,t){return function(){return nI(this,e,t.apply(this,arguments))}}function Yre(e,t){return this.each((typeof t=="function"?Wre:Gre)(e,t))}function*Xre(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],s=0,a=i.length,o;s<a;++s)(o=i[s])&&(yield o)}var iI=[null];function rs(e,t){this._groups=e,this._parents=t}function wf(){return new rs([[document.documentElement]],iI)}function Qre(){return this}rs.prototype=wf.prototype={constructor:rs,select:Sse,selectAll:Cse,selectChild:Mse,selectChildren:Lse,filter:Ise,data:$se,enter:Pse,exit:Hse,join:Vse,merge:Kse,selection:Qre,order:Gse,sort:Wse,call:Xse,nodes:Qse,node:Zse,size:Jse,empty:ere,each:tre,attr:lre,style:fre,property:gre,classed:vre,text:kre,html:Tre,raise:jre,lower:Rre,append:Dre,insert:Lre,remove:Pre,clone:Ure,datum:Fre,on:Kre,dispatch:Yre,[Symbol.iterator]:Xre};function ns(e){return typeof e=="string"?new rs([[document.querySelector(e)]],[document.documentElement]):new rs([[e]],iI)}function Zre(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Is(e,t){if(e=Zre(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Jre={passive:!1},$d={capture:!0,passive:!1};function Dx(e){e.stopImmediatePropagation()}function gc(e){e.preventDefault(),e.stopImmediatePropagation()}function sI(e){var t=e.document.documentElement,n=ns(e).on("dragstart.drag",gc,$d);"onselectstart"in t?n.on("selectstart.drag",gc,$d):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function rI(e,t){var n=e.document.documentElement,i=ns(e).on("dragstart.drag",null);t&&(i.on("click.drag",gc,$d),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const cp=e=>()=>e;function pv(e,{sourceEvent:t,subject:n,target:i,identifier:s,active:a,x:o,y:c,dx:u,dy:f,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:m}})}pv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function eae(e){return!e.ctrlKey&&!e.button}function tae(){return this.parentNode}function nae(e,t){return t??{x:e.x,y:e.y}}function iae(){return navigator.maxTouchPoints||"ontouchstart"in this}function aI(){var e=eae,t=tae,n=nae,i=iae,s={},a=ag("start","drag","end"),o=0,c,u,f,m,p=0;function y(T){T.on("mousedown.drag",b).filter(i).on("touchstart.drag",E).on("touchmove.drag",v,Jre).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(T,A){if(!(m||!e.call(this,T,A))){var j=k(this,t.call(this,T,A),T,A,"mouse");j&&(ns(T.view).on("mousemove.drag",x,$d).on("mouseup.drag",w,$d),sI(T.view),Dx(T),f=!1,c=T.clientX,u=T.clientY,j("start",T))}}function x(T){if(gc(T),!f){var A=T.clientX-c,j=T.clientY-u;f=A*A+j*j>p}s.mouse("drag",T)}function w(T){ns(T.view).on("mousemove.drag mouseup.drag",null),rI(T.view,f),gc(T),s.mouse("end",T)}function E(T,A){if(e.call(this,T,A)){var j=T.changedTouches,M=t.call(this,T,A),D=j.length,I,P;for(I=0;I<D;++I)(P=k(this,M,T,A,j[I].identifier,j[I]))&&(Dx(T),P("start",T,j[I]))}}function v(T){var A=T.changedTouches,j=A.length,M,D;for(M=0;M<j;++M)(D=s[A[M].identifier])&&(gc(T),D("drag",T,A[M]))}function _(T){var A=T.changedTouches,j=A.length,M,D;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),M=0;M<j;++M)(D=s[A[M].identifier])&&(Dx(T),D("end",T,A[M]))}function k(T,A,j,M,D,I){var P=a.copy(),U=Is(I||j,A),q,V,O;if((O=n.call(T,new pv("beforestart",{sourceEvent:j,target:y,identifier:D,active:o,x:U[0],y:U[1],dx:0,dy:0,dispatch:P}),M))!=null)return q=O.x-U[0]||0,V=O.y-U[1]||0,function R(z,G,Y){var K=U,B;switch(z){case"start":s[D]=R,B=o++;break;case"end":delete s[D],--o;case"drag":U=Is(Y||G,A),B=o;break}P.call(z,T,new pv(z,{sourceEvent:G,subject:O,target:y,identifier:D,active:B,x:U[0]+q,y:U[1]+V,dx:U[0]-K[0],dy:U[1]-K[1],dispatch:P}),M)}}return y.filter=function(T){return arguments.length?(e=typeof T=="function"?T:cp(!!T),y):e},y.container=function(T){return arguments.length?(t=typeof T=="function"?T:cp(T),y):t},y.subject=function(T){return arguments.length?(n=typeof T=="function"?T:cp(T),y):n},y.touchable=function(T){return arguments.length?(i=typeof T=="function"?T:cp(!!T),y):i},y.on=function(){var T=a.on.apply(a,arguments);return T===a?y:T},y.clickDistance=function(T){return arguments.length?(p=(T=+T)*T,y):Math.sqrt(p)},y}function mw(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function oI(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Ef(){}var qd=.7,bm=1/qd,yc="\\s*([+-]?\\d+)\\s*",Hd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sae=/^#([0-9a-f]{3,8})$/,rae=new RegExp(`^rgb\\(${yc},${yc},${yc}\\)$`),aae=new RegExp(`^rgb\\(${mr},${mr},${mr}\\)$`),oae=new RegExp(`^rgba\\(${yc},${yc},${yc},${Hd}\\)$`),lae=new RegExp(`^rgba\\(${mr},${mr},${mr},${Hd}\\)$`),cae=new RegExp(`^hsl\\(${Hd},${mr},${mr}\\)$`),uae=new RegExp(`^hsla\\(${Hd},${mr},${mr},${Hd}\\)$`),bT={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};mw(Ef,al,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xT,formatHex:xT,formatHex8:dae,formatHsl:fae,formatRgb:vT,toString:vT});function xT(){return this.rgb().formatHex()}function dae(){return this.rgb().formatHex8()}function fae(){return lI(this).formatHsl()}function vT(){return this.rgb().formatRgb()}function al(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sae.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?wT(t):n===3?new $i(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?up(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?up(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=rae.exec(e))?new $i(t[1],t[2],t[3],1):(t=aae.exec(e))?new $i(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oae.exec(e))?up(t[1],t[2],t[3],t[4]):(t=lae.exec(e))?up(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cae.exec(e))?kT(t[1],t[2]/100,t[3]/100,1):(t=uae.exec(e))?kT(t[1],t[2]/100,t[3]/100,t[4]):bT.hasOwnProperty(e)?wT(bT[e]):e==="transparent"?new $i(NaN,NaN,NaN,0):null}function wT(e){return new $i(e>>16&255,e>>8&255,e&255,1)}function up(e,t,n,i){return i<=0&&(e=t=n=NaN),new $i(e,t,n,i)}function hae(e){return e instanceof Ef||(e=al(e)),e?(e=e.rgb(),new $i(e.r,e.g,e.b,e.opacity)):new $i}function mv(e,t,n,i){return arguments.length===1?hae(e):new $i(e,t,n,i??1)}function $i(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}mw($i,mv,oI(Ef,{brighter(e){return e=e==null?bm:Math.pow(bm,e),new $i(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new $i(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $i(Zo(this.r),Zo(this.g),Zo(this.b),xm(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ET,formatHex:ET,formatHex8:pae,formatRgb:ST,toString:ST}));function ET(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}`}function pae(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}${Uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function ST(){const e=xm(this.opacity);return`${e===1?"rgb(":"rgba("}${Zo(this.r)}, ${Zo(this.g)}, ${Zo(this.b)}${e===1?")":`, ${e})`}`}function xm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Zo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uo(e){return e=Zo(e),(e<16?"0":"")+e.toString(16)}function kT(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ps(e,t,n,i)}function lI(e){if(e instanceof Ps)return new Ps(e.h,e.s,e.l,e.opacity);if(e instanceof Ef||(e=al(e)),!e)return new Ps;if(e instanceof Ps)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,s=Math.min(t,n,i),a=Math.max(t,n,i),o=NaN,c=a-s,u=(a+s)/2;return c?(t===a?o=(n-i)/c+(n<i)*6:n===a?o=(i-t)/c+2:o=(t-n)/c+4,c/=u<.5?a+s:2-a-s,o*=60):c=u>0&&u<1?0:o,new Ps(o,c,u,e.opacity)}function mae(e,t,n,i){return arguments.length===1?lI(e):new Ps(e,t,n,i??1)}function Ps(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}mw(Ps,mae,oI(Ef,{brighter(e){return e=e==null?bm:Math.pow(bm,e),new Ps(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new Ps(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,s=2*n-i;return new $i(Ox(e>=240?e-240:e+120,s,i),Ox(e,s,i),Ox(e<120?e+240:e-120,s,i),this.opacity)},clamp(){return new Ps(NT(this.h),dp(this.s),dp(this.l),xm(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=xm(this.opacity);return`${e===1?"hsl(":"hsla("}${NT(this.h)}, ${dp(this.s)*100}%, ${dp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function NT(e){return e=(e||0)%360,e<0?e+360:e}function dp(e){return Math.max(0,Math.min(1,e||0))}function Ox(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const gw=e=>()=>e;function gae(e,t){return function(n){return e+n*t}}function yae(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function bae(e){return(e=+e)==1?cI:function(t,n){return n-t?yae(t,n,e):gw(isNaN(t)?n:t)}}function cI(e,t){var n=t-e;return n?gae(e,n):gw(isNaN(e)?t:e)}const vm=(function e(t){var n=bae(t);function i(s,a){var o=n((s=mv(s)).r,(a=mv(a)).r),c=n(s.g,a.g),u=n(s.b,a.b),f=cI(s.opacity,a.opacity);return function(m){return s.r=o(m),s.g=c(m),s.b=u(m),s.opacity=f(m),s+""}}return i.gamma=e,i})(1);function xae(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),s;return function(a){for(s=0;s<n;++s)i[s]=e[s]*(1-a)+t[s]*a;return i}}function vae(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function wae(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,s=new Array(i),a=new Array(n),o;for(o=0;o<i;++o)s[o]=Nd(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(c){for(o=0;o<i;++o)a[o]=s[o](c);return a}}function Eae(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function fr(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Sae(e,t){var n={},i={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=Nd(e[s],t[s]):i[s]=t[s];return function(a){for(s in n)i[s]=n[s](a);return i}}var gv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Lx=new RegExp(gv.source,"g");function kae(e){return function(){return e}}function Nae(e){return function(t){return e(t)+""}}function uI(e,t){var n=gv.lastIndex=Lx.lastIndex=0,i,s,a,o=-1,c=[],u=[];for(e=e+"",t=t+"";(i=gv.exec(e))&&(s=Lx.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),c[o]?c[o]+=a:c[++o]=a),(i=i[0])===(s=s[0])?c[o]?c[o]+=s:c[++o]=s:(c[++o]=null,u.push({i:o,x:fr(i,s)})),n=Lx.lastIndex;return n<t.length&&(a=t.slice(n),c[o]?c[o]+=a:c[++o]=a),c.length<2?u[0]?Nae(u[0].x):kae(t):(t=u.length,function(f){for(var m=0,p;m<t;++m)c[(p=u[m]).i]=p.x(f);return c.join("")})}function Nd(e,t){var n=typeof t,i;return t==null||n==="boolean"?gw(t):(n==="number"?fr:n==="string"?(i=al(t))?(t=i,vm):uI:t instanceof al?vm:t instanceof Date?Eae:vae(t)?xae:Array.isArray(t)?wae:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Sae:fr)(e,t)}var _T=180/Math.PI,yv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function dI(e,t,n,i,s,a){var o,c,u;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(u=e*n+t*i)&&(n-=e*u,i-=t*u),(c=Math.sqrt(n*n+i*i))&&(n/=c,i/=c,u/=c),e*i<t*n&&(e=-e,t=-t,u=-u,o=-o),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*_T,skewX:Math.atan(u)*_T,scaleX:o,scaleY:c}}var fp;function _ae(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?yv:dI(t.a,t.b,t.c,t.d,t.e,t.f)}function Cae(e){return e==null||(fp||(fp=document.createElementNS("http://www.w3.org/2000/svg","g")),fp.setAttribute("transform",e),!(e=fp.transform.baseVal.consolidate()))?yv:(e=e.matrix,dI(e.a,e.b,e.c,e.d,e.e,e.f))}function fI(e,t,n,i){function s(f){return f.length?f.pop()+" ":""}function a(f,m,p,y,b,x){if(f!==p||m!==y){var w=b.push("translate(",null,t,null,n);x.push({i:w-4,x:fr(f,p)},{i:w-2,x:fr(m,y)})}else(p||y)&&b.push("translate("+p+t+y+n)}function o(f,m,p,y){f!==m?(f-m>180?m+=360:m-f>180&&(f+=360),y.push({i:p.push(s(p)+"rotate(",null,i)-2,x:fr(f,m)})):m&&p.push(s(p)+"rotate("+m+i)}function c(f,m,p,y){f!==m?y.push({i:p.push(s(p)+"skewX(",null,i)-2,x:fr(f,m)}):m&&p.push(s(p)+"skewX("+m+i)}function u(f,m,p,y,b,x){if(f!==p||m!==y){var w=b.push(s(b)+"scale(",null,",",null,")");x.push({i:w-4,x:fr(f,p)},{i:w-2,x:fr(m,y)})}else(p!==1||y!==1)&&b.push(s(b)+"scale("+p+","+y+")")}return function(f,m){var p=[],y=[];return f=e(f),m=e(m),a(f.translateX,f.translateY,m.translateX,m.translateY,p,y),o(f.rotate,m.rotate,p,y),c(f.skewX,m.skewX,p,y),u(f.scaleX,f.scaleY,m.scaleX,m.scaleY,p,y),f=m=null,function(b){for(var x=-1,w=y.length,E;++x<w;)p[(E=y[x]).i]=E.x(b);return p.join("")}}}var Tae=fI(_ae,"px, ","px)","deg)"),Aae=fI(Cae,", ",")",")"),jae=1e-12;function CT(e){return((e=Math.exp(e))+1/e)/2}function Mae(e){return((e=Math.exp(e))-1/e)/2}function Rae(e){return((e=Math.exp(2*e))-1)/(e+1)}const zp=(function e(t,n,i){function s(a,o){var c=a[0],u=a[1],f=a[2],m=o[0],p=o[1],y=o[2],b=m-c,x=p-u,w=b*b+x*x,E,v;if(w<jae)v=Math.log(y/f)/t,E=function(M){return[c+M*b,u+M*x,f*Math.exp(t*M*v)]};else{var _=Math.sqrt(w),k=(y*y-f*f+i*w)/(2*f*n*_),T=(y*y-f*f-i*w)/(2*y*n*_),A=Math.log(Math.sqrt(k*k+1)-k),j=Math.log(Math.sqrt(T*T+1)-T);v=(j-A)/t,E=function(M){var D=M*v,I=CT(A),P=f/(n*_)*(I*Rae(t*D+A)-Mae(A));return[c+P*b,u+P*x,f*I/CT(t*D+A)]}}return E.duration=v*1e3*t/Math.SQRT2,E}return s.rho=function(a){var o=Math.max(.001,+a),c=o*o,u=c*c;return e(o,c,u)},s})(Math.SQRT2,2,4);var zc=0,hd=0,rd=0,hI=1e3,wm,pd,Em=0,ol=0,lg=0,Vd=typeof performance=="object"&&performance.now?performance:Date,pI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yw(){return ol||(pI(Dae),ol=Vd.now()+lg)}function Dae(){ol=0}function Sm(){this._call=this._time=this._next=null}Sm.prototype=mI.prototype={constructor:Sm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?yw():+n)+(t==null?0:+t),!this._next&&pd!==this&&(pd?pd._next=this:wm=this,pd=this),this._call=e,this._time=n,bv()},stop:function(){this._call&&(this._call=null,this._time=1/0,bv())}};function mI(e,t,n){var i=new Sm;return i.restart(e,t,n),i}function Oae(){yw(),++zc;for(var e=wm,t;e;)(t=ol-e._time)>=0&&e._call.call(void 0,t),e=e._next;--zc}function TT(){ol=(Em=Vd.now())+lg,zc=hd=0;try{Oae()}finally{zc=0,Iae(),ol=0}}function Lae(){var e=Vd.now(),t=e-Em;t>hI&&(lg-=t,Em=e)}function Iae(){for(var e,t=wm,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:wm=n);pd=e,bv(i)}function bv(e){if(!zc){hd&&(hd=clearTimeout(hd));var t=e-ol;t>24?(e<1/0&&(hd=setTimeout(TT,e-Vd.now()-lg)),rd&&(rd=clearInterval(rd))):(rd||(Em=Vd.now(),rd=setInterval(Lae,hI)),zc=1,pI(TT))}}function AT(e,t,n){var i=new Sm;return t=t==null?0:+t,i.restart(s=>{i.stop(),e(s+t)},t,n),i}var Pae=ag("start","end","cancel","interrupt"),zae=[],gI=0,jT=1,xv=2,Bp=3,MT=4,vv=5,Up=6;function cg(e,t,n,i,s,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Bae(e,n,{name:t,index:i,group:s,on:Pae,tween:zae,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:gI})}function bw(e,t){var n=Ws(e,t);if(n.state>gI)throw new Error("too late; already scheduled");return n}function vr(e,t){var n=Ws(e,t);if(n.state>Bp)throw new Error("too late; already running");return n}function Ws(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bae(e,t,n){var i=e.__transition,s;i[t]=n,n.timer=mI(a,0,n.time);function a(f){n.state=jT,n.timer.restart(o,n.delay,n.time),n.delay<=f&&o(f-n.delay)}function o(f){var m,p,y,b;if(n.state!==jT)return u();for(m in i)if(b=i[m],b.name===n.name){if(b.state===Bp)return AT(o);b.state===MT?(b.state=Up,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete i[m]):+m<t&&(b.state=Up,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete i[m])}if(AT(function(){n.state===Bp&&(n.state=MT,n.timer.restart(c,n.delay,n.time),c(f))}),n.state=xv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===xv){for(n.state=Bp,s=new Array(y=n.tween.length),m=0,p=-1;m<y;++m)(b=n.tween[m].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=b);s.length=p+1}}function c(f){for(var m=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(u),n.state=vv,1),p=-1,y=s.length;++p<y;)s[p].call(e,m);n.state===vv&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Up,n.timer.stop(),delete i[t];for(var f in i)return;delete e.__transition}}function Fp(e,t){var n=e.__transition,i,s,a=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((i=n[o]).name!==t){a=!1;continue}s=i.state>xv&&i.state<vv,i.state=Up,i.timer.stop(),i.on.call(s?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[o]}a&&delete e.__transition}}function Uae(e){return this.each(function(){Fp(this,e)})}function Fae(e,t){var n,i;return function(){var s=vr(this,e),a=s.tween;if(a!==n){i=n=a;for(var o=0,c=i.length;o<c;++o)if(i[o].name===t){i=i.slice(),i.splice(o,1);break}}s.tween=i}}function $ae(e,t,n){var i,s;if(typeof n!="function")throw new Error;return function(){var a=vr(this,e),o=a.tween;if(o!==i){s=(i=o).slice();for(var c={name:t,value:n},u=0,f=s.length;u<f;++u)if(s[u].name===t){s[u]=c;break}u===f&&s.push(c)}a.tween=s}}function qae(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Ws(this.node(),n).tween,s=0,a=i.length,o;s<a;++s)if((o=i[s]).name===e)return o.value;return null}return this.each((t==null?Fae:$ae)(n,e,t))}function xw(e,t,n){var i=e._id;return e.each(function(){var s=vr(this,i);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ws(s,i).value[t]}}function yI(e,t){var n;return(typeof t=="number"?fr:t instanceof al?vm:(n=al(t))?(t=n,vm):uI)(e,t)}function Hae(e){return function(){this.removeAttribute(e)}}function Vae(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kae(e,t,n){var i,s=n+"",a;return function(){var o=this.getAttribute(e);return o===s?null:o===i?a:a=t(i=o,n)}}function Gae(e,t,n){var i,s=n+"",a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===s?null:o===i?a:a=t(i=o,n)}}function Wae(e,t,n){var i,s,a;return function(){var o,c=n(this),u;return c==null?void this.removeAttribute(e):(o=this.getAttribute(e),u=c+"",o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c)))}}function Yae(e,t,n){var i,s,a;return function(){var o,c=n(this),u;return c==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),u=c+"",o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c)))}}function Xae(e,t){var n=og(e),i=n==="transform"?Aae:yI;return this.attrTween(e,typeof t=="function"?(n.local?Yae:Wae)(n,i,xw(this,"attr."+e,t)):t==null?(n.local?Vae:Hae)(n):(n.local?Gae:Kae)(n,i,t))}function Qae(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zae(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Jae(e,t){var n,i;function s(){var a=t.apply(this,arguments);return a!==i&&(n=(i=a)&&Zae(e,a)),n}return s._value=t,s}function eoe(e,t){var n,i;function s(){var a=t.apply(this,arguments);return a!==i&&(n=(i=a)&&Qae(e,a)),n}return s._value=t,s}function toe(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=og(e);return this.tween(n,(i.local?Jae:eoe)(i,t))}function noe(e,t){return function(){bw(this,e).delay=+t.apply(this,arguments)}}function ioe(e,t){return t=+t,function(){bw(this,e).delay=t}}function soe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?noe:ioe)(t,e)):Ws(this.node(),t).delay}function roe(e,t){return function(){vr(this,e).duration=+t.apply(this,arguments)}}function aoe(e,t){return t=+t,function(){vr(this,e).duration=t}}function ooe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?roe:aoe)(t,e)):Ws(this.node(),t).duration}function loe(e,t){if(typeof t!="function")throw new Error;return function(){vr(this,e).ease=t}}function coe(e){var t=this._id;return arguments.length?this.each(loe(t,e)):Ws(this.node(),t).ease}function uoe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;vr(this,e).ease=n}}function doe(e){if(typeof e!="function")throw new Error;return this.each(uoe(this._id,e))}function foe(e){typeof e!="function"&&(e=WL(e));for(var t=this._groups,n=t.length,i=new Array(n),s=0;s<n;++s)for(var a=t[s],o=a.length,c=i[s]=[],u,f=0;f<o;++f)(u=a[f])&&e.call(u,u.__data__,f,a)&&c.push(u);return new ta(i,this._parents,this._name,this._id)}function hoe(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,s=n.length,a=Math.min(i,s),o=new Array(i),c=0;c<a;++c)for(var u=t[c],f=n[c],m=u.length,p=o[c]=new Array(m),y,b=0;b<m;++b)(y=u[b]||f[b])&&(p[b]=y);for(;c<i;++c)o[c]=t[c];return new ta(o,this._parents,this._name,this._id)}function poe(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function moe(e,t,n){var i,s,a=poe(t)?bw:vr;return function(){var o=a(this,e),c=o.on;c!==i&&(s=(i=c).copy()).on(t,n),o.on=s}}function goe(e,t){var n=this._id;return arguments.length<2?Ws(this.node(),n).on.on(e):this.each(moe(n,e,t))}function yoe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function boe(){return this.on("end.remove",yoe(this._id))}function xoe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hw(e));for(var i=this._groups,s=i.length,a=new Array(s),o=0;o<s;++o)for(var c=i[o],u=c.length,f=a[o]=new Array(u),m,p,y=0;y<u;++y)(m=c[y])&&(p=e.call(m,m.__data__,y,c))&&("__data__"in m&&(p.__data__=m.__data__),f[y]=p,cg(f[y],t,n,y,f,Ws(m,n)));return new ta(a,this._parents,t,n)}function voe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=GL(e));for(var i=this._groups,s=i.length,a=[],o=[],c=0;c<s;++c)for(var u=i[c],f=u.length,m,p=0;p<f;++p)if(m=u[p]){for(var y=e.call(m,m.__data__,p,u),b,x=Ws(m,n),w=0,E=y.length;w<E;++w)(b=y[w])&&cg(b,t,n,w,y,x);a.push(y),o.push(m)}return new ta(a,o,t,n)}var woe=wf.prototype.constructor;function Eoe(){return new woe(this._groups,this._parents)}function Soe(e,t){var n,i,s;return function(){var a=Pc(this,e),o=(this.style.removeProperty(e),Pc(this,e));return a===o?null:a===n&&o===i?s:s=t(n=a,i=o)}}function bI(e){return function(){this.style.removeProperty(e)}}function koe(e,t,n){var i,s=n+"",a;return function(){var o=Pc(this,e);return o===s?null:o===i?a:a=t(i=o,n)}}function Noe(e,t,n){var i,s,a;return function(){var o=Pc(this,e),c=n(this),u=c+"";return c==null&&(u=c=(this.style.removeProperty(e),Pc(this,e))),o===u?null:o===i&&u===s?a:(s=u,a=t(i=o,c))}}function _oe(e,t){var n,i,s,a="style."+t,o="end."+a,c;return function(){var u=vr(this,e),f=u.on,m=u.value[a]==null?c||(c=bI(t)):void 0;(f!==n||s!==m)&&(i=(n=f).copy()).on(o,s=m),u.on=i}}function Coe(e,t,n){var i=(e+="")=="transform"?Tae:yI;return t==null?this.styleTween(e,Soe(e,i)).on("end.style."+e,bI(e)):typeof t=="function"?this.styleTween(e,Noe(e,i,xw(this,"style."+e,t))).each(_oe(this._id,e)):this.styleTween(e,koe(e,i,t),n).on("end.style."+e,null)}function Toe(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function Aoe(e,t,n){var i,s;function a(){var o=t.apply(this,arguments);return o!==s&&(i=(s=o)&&Toe(e,o,n)),i}return a._value=t,a}function joe(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,Aoe(e,t,n??""))}function Moe(e){return function(){this.textContent=e}}function Roe(e){return function(){var t=e(this);this.textContent=t??""}}function Doe(e){return this.tween("text",typeof e=="function"?Roe(xw(this,"text",e)):Moe(e==null?"":e+""))}function Ooe(e){return function(t){this.textContent=e.call(this,t)}}function Loe(e){var t,n;function i(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Ooe(s)),t}return i._value=e,i}function Ioe(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Loe(e))}function Poe(){for(var e=this._name,t=this._id,n=xI(),i=this._groups,s=i.length,a=0;a<s;++a)for(var o=i[a],c=o.length,u,f=0;f<c;++f)if(u=o[f]){var m=Ws(u,t);cg(u,e,n,f,o,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new ta(i,this._parents,e,n)}function zoe(){var e,t,n=this,i=n._id,s=n.size();return new Promise(function(a,o){var c={value:o},u={value:function(){--s===0&&a()}};n.each(function(){var f=vr(this,i),m=f.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(u)),f.on=t}),s===0&&a()})}var Boe=0;function ta(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function xI(){return++Boe}var Ur=wf.prototype;ta.prototype={constructor:ta,select:xoe,selectAll:voe,selectChild:Ur.selectChild,selectChildren:Ur.selectChildren,filter:foe,merge:hoe,selection:Eoe,transition:Poe,call:Ur.call,nodes:Ur.nodes,node:Ur.node,size:Ur.size,empty:Ur.empty,each:Ur.each,on:goe,attr:Xae,attrTween:toe,style:Coe,styleTween:joe,text:Doe,textTween:Ioe,remove:boe,tween:qae,delay:soe,duration:ooe,ease:coe,easeVarying:doe,end:zoe,[Symbol.iterator]:Ur[Symbol.iterator]};function Uoe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Foe={time:null,delay:0,duration:250,ease:Uoe};function $oe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function qoe(e){var t,n;e instanceof ta?(t=e._id,e=e._name):(t=xI(),(n=Foe).time=yw(),e=e==null?null:e+"");for(var i=this._groups,s=i.length,a=0;a<s;++a)for(var o=i[a],c=o.length,u,f=0;f<c;++f)(u=o[f])&&cg(u,e,t,f,o,n||$oe(u,t));return new ta(i,this._parents,e,t)}wf.prototype.interrupt=Uae;wf.prototype.transition=qoe;const hp=e=>()=>e;function Hoe(e,{sourceEvent:t,target:n,transform:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function Wr(e,t,n){this.k=e,this.x=t,this.y=n}Wr.prototype={constructor:Wr,scale:function(e){return e===1?this:new Wr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Wr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ug=new Wr(1,0,0);vI.prototype=Wr.prototype;function vI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ug;return e.__zoom}function Ix(e){e.stopImmediatePropagation()}function ad(e){e.preventDefault(),e.stopImmediatePropagation()}function Voe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Koe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function RT(){return this.__zoom||ug}function Goe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Woe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Yoe(e,t,n){var i=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function wI(){var e=Voe,t=Koe,n=Yoe,i=Goe,s=Woe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],c=250,u=zp,f=ag("start","zoom","end"),m,p,y,b=500,x=150,w=0,E=10;function v(O){O.property("__zoom",RT).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",U).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(O,R,z,G){var Y=O.selection?O.selection():O;Y.property("__zoom",RT),O!==Y?A(O,R,z,G):Y.interrupt().each(function(){j(this,arguments).event(G).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},v.scaleBy=function(O,R,z,G){v.scaleTo(O,function(){var Y=this.__zoom.k,K=typeof R=="function"?R.apply(this,arguments):R;return Y*K},z,G)},v.scaleTo=function(O,R,z,G){v.transform(O,function(){var Y=t.apply(this,arguments),K=this.__zoom,B=z==null?T(Y):typeof z=="function"?z.apply(this,arguments):z,F=K.invert(B),W=typeof R=="function"?R.apply(this,arguments):R;return n(k(_(K,W),B,F),Y,o)},z,G)},v.translateBy=function(O,R,z,G){v.transform(O,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),o)},null,G)},v.translateTo=function(O,R,z,G,Y){v.transform(O,function(){var K=t.apply(this,arguments),B=this.__zoom,F=G==null?T(K):typeof G=="function"?G.apply(this,arguments):G;return n(ug.translate(F[0],F[1]).scale(B.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof z=="function"?-z.apply(this,arguments):-z),K,o)},G,Y)};function _(O,R){return R=Math.max(a[0],Math.min(a[1],R)),R===O.k?O:new Wr(R,O.x,O.y)}function k(O,R,z){var G=R[0]-z[0]*O.k,Y=R[1]-z[1]*O.k;return G===O.x&&Y===O.y?O:new Wr(O.k,G,Y)}function T(O){return[(+O[0][0]+ +O[1][0])/2,(+O[0][1]+ +O[1][1])/2]}function A(O,R,z,G){O.on("start.zoom",function(){j(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(G).end()}).tween("zoom",function(){var Y=this,K=arguments,B=j(Y,K).event(G),F=t.apply(Y,K),W=z==null?T(F):typeof z=="function"?z.apply(Y,K):z,$=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),ae=Y.__zoom,be=typeof R=="function"?R.apply(Y,K):R,le=u(ae.invert(W).concat($/ae.k),be.invert(W).concat($/be.k));return function(Ne){if(Ne===1)Ne=be;else{var re=le(Ne),me=$/re[2];Ne=new Wr(me,W[0]-re[0]*me,W[1]-re[1]*me)}B.zoom(null,Ne)}})}function j(O,R,z){return!z&&O.__zooming||new M(O,R)}function M(O,R){this.that=O,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(O,R),this.taps=0}M.prototype={event:function(O){return O&&(this.sourceEvent=O),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(O,R){return this.mouse&&O!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&O!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&O!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(O){var R=ns(this.that).datum();f.call(O,this.that,new Hoe(O,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:f}),R)}};function D(O,...R){if(!e.apply(this,arguments))return;var z=j(this,R).event(O),G=this.__zoom,Y=Math.max(a[0],Math.min(a[1],G.k*Math.pow(2,i.apply(this,arguments)))),K=Is(O);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Y)return;z.mouse=[K,G.invert(K)],Fp(this),z.start()}ad(O),z.wheel=setTimeout(B,x),z.zoom("mouse",n(k(_(G,Y),z.mouse[0],z.mouse[1]),z.extent,o));function B(){z.wheel=null,z.end()}}function I(O,...R){if(y||!e.apply(this,arguments))return;var z=O.currentTarget,G=j(this,R,!0).event(O),Y=ns(O.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",$,!0),K=Is(O,z),B=O.clientX,F=O.clientY;sI(O.view),Ix(O),G.mouse=[K,this.__zoom.invert(K)],Fp(this),G.start();function W(ae){if(ad(ae),!G.moved){var be=ae.clientX-B,le=ae.clientY-F;G.moved=be*be+le*le>w}G.event(ae).zoom("mouse",n(k(G.that.__zoom,G.mouse[0]=Is(ae,z),G.mouse[1]),G.extent,o))}function $(ae){Y.on("mousemove.zoom mouseup.zoom",null),rI(ae.view,G.moved),ad(ae),G.event(ae).end()}}function P(O,...R){if(e.apply(this,arguments)){var z=this.__zoom,G=Is(O.changedTouches?O.changedTouches[0]:O,this),Y=z.invert(G),K=z.k*(O.shiftKey?.5:2),B=n(k(_(z,K),G,Y),t.apply(this,R),o);ad(O),c>0?ns(this).transition().duration(c).call(A,B,G,O):ns(this).call(v.transform,B,G,O)}}function U(O,...R){if(e.apply(this,arguments)){var z=O.touches,G=z.length,Y=j(this,R,O.changedTouches.length===G).event(O),K,B,F,W;for(Ix(O),B=0;B<G;++B)F=z[B],W=Is(F,this),W=[W,this.__zoom.invert(W),F.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==W[2]&&(Y.touch1=W,Y.taps=0):(Y.touch0=W,K=!0,Y.taps=1+!!m);m&&(m=clearTimeout(m)),K&&(Y.taps<2&&(p=W[0],m=setTimeout(function(){m=null},b)),Fp(this),Y.start())}}function q(O,...R){if(this.__zooming){var z=j(this,R).event(O),G=O.changedTouches,Y=G.length,K,B,F,W;for(ad(O),K=0;K<Y;++K)B=G[K],F=Is(B,this),z.touch0&&z.touch0[2]===B.identifier?z.touch0[0]=F:z.touch1&&z.touch1[2]===B.identifier&&(z.touch1[0]=F);if(B=z.that.__zoom,z.touch1){var $=z.touch0[0],ae=z.touch0[1],be=z.touch1[0],le=z.touch1[1],Ne=(Ne=be[0]-$[0])*Ne+(Ne=be[1]-$[1])*Ne,re=(re=le[0]-ae[0])*re+(re=le[1]-ae[1])*re;B=_(B,Math.sqrt(Ne/re)),F=[($[0]+be[0])/2,($[1]+be[1])/2],W=[(ae[0]+le[0])/2,(ae[1]+le[1])/2]}else if(z.touch0)F=z.touch0[0],W=z.touch0[1];else return;z.zoom("touch",n(k(B,F,W),z.extent,o))}}function V(O,...R){if(this.__zooming){var z=j(this,R).event(O),G=O.changedTouches,Y=G.length,K,B;for(Ix(O),y&&clearTimeout(y),y=setTimeout(function(){y=null},b),K=0;K<Y;++K)B=G[K],z.touch0&&z.touch0[2]===B.identifier?delete z.touch0:z.touch1&&z.touch1[2]===B.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(B=Is(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<E)){var F=ns(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return v.wheelDelta=function(O){return arguments.length?(i=typeof O=="function"?O:hp(+O),v):i},v.filter=function(O){return arguments.length?(e=typeof O=="function"?O:hp(!!O),v):e},v.touchable=function(O){return arguments.length?(s=typeof O=="function"?O:hp(!!O),v):s},v.extent=function(O){return arguments.length?(t=typeof O=="function"?O:hp([[+O[0][0],+O[0][1]],[+O[1][0],+O[1][1]]]),v):t},v.scaleExtent=function(O){return arguments.length?(a[0]=+O[0],a[1]=+O[1],v):[a[0],a[1]]},v.translateExtent=function(O){return arguments.length?(o[0][0]=+O[0][0],o[1][0]=+O[1][0],o[0][1]=+O[0][1],o[1][1]=+O[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(O){return arguments.length?(n=O,v):n},v.duration=function(O){return arguments.length?(c=+O,v):c},v.interpolate=function(O){return arguments.length?(u=O,v):u},v.on=function(){var O=f.on.apply(f,arguments);return O===f?v:O},v.clickDistance=function(O){return arguments.length?(w=(O=+O)*O,v):Math.sqrt(w)},v.tapDistance=function(O){return arguments.length?(E=+O,v):E},v}const as={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Kd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],EI=["Enter"," ","Escape"],SI={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Bc;(function(e){e.Strict="strict",e.Loose="loose"})(Bc||(Bc={}));var Jo;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Jo||(Jo={}));var Gd;(function(e){e.Partial="partial",e.Full="full"})(Gd||(Gd={}));const kI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fa||(Fa={}));var km;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(km||(km={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const DT={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top};function NI(e){return e===null?null:e?"valid":"invalid"}const _I=e=>"id"in e&&"source"in e&&"target"in e,Xoe=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),vw=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Sf=(e,t=[0,0])=>{const{width:n,height:i}=ia(e),s=e.origin??t,a=n*s[0],o=i*s[1];return{x:e.position.x-a,y:e.position.y-o}},Qoe=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,s)=>{const a=typeof s=="string";let o=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(o=a?t.nodeLookup.get(s):vw(s)?s:t.nodeLookup.get(s.id));const c=o?Nm(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return dg(i,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fg(n)},kf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=dg(n,Nm(s)),i=!0)}),i?fg(n):{x:0,y:0,width:0,height:0}},ww=(e,t,[n,i,s]=[0,0,1],a=!1,o=!1)=>{const c=(t.x-n)/s,u=(t.y-i)/s,f=t.width/s,m=t.height/s,p=[];for(const y of e.values()){const{measured:b,selectable:x=!0,hidden:w=!1}=y;if(o&&!x||w)continue;const E=b.width??y.width??y.initialWidth??0,v=b.height??y.height??y.initialHeight??0,{x:_,y:k}=y.internals.positionAbsolute,T=jI(c,u,f,m,_,k,E,v),A=E*v,j=a&&T>0;(!y.internals.handleBounds||j||T>=A||y.dragging)&&p.push(y)}return p},Zoe=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function Joe(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!i||i.has(s.id))&&n.set(s.id,s)}),n}async function ele({nodes:e,width:t,height:n,panZoom:i,minZoom:s,maxZoom:a},o){if(e.size===0)return!0;const c=Joe(e,o),u=kf(c),f=Sw(u,t,n,(o==null?void 0:o.minZoom)??s,(o==null?void 0:o.maxZoom)??a,(o==null?void 0:o.padding)??.1);return await i.setViewport(f,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0}function CI({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:s,onError:a}){const o=n.get(e),c=o.parentId?n.get(o.parentId):void 0,{x:u,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},m=o.origin??i;let p=o.extent||s;if(o.extent==="parent"&&!o.expandParent)if(!c)a==null||a("005",as.error005());else{const b=c.measured.width,x=c.measured.height;b&&x&&(p=[[u,f],[u+b,f+x]])}else c&&cl(o.extent)&&(p=[[o.extent[0][0]+u,o.extent[0][1]+f],[o.extent[1][0]+u,o.extent[1][1]+f]]);const y=cl(p)?ll(t,p,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&(a==null||a("015",as.error015())),{position:{x:y.x-u+(o.measured.width??0)*m[0],y:y.y-f+(o.measured.height??0)*m[1]},positionAbsolute:y}}async function tle({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:s}){const a=new Set(e.map(y=>y.id)),o=[];for(const y of n){if(y.deletable===!1)continue;const b=a.has(y.id),x=!b&&y.parentId&&o.find(w=>w.id===y.parentId);(b||x)&&o.push(y)}const c=new Set(t.map(y=>y.id)),u=i.filter(y=>y.deletable!==!1),m=Zoe(o,u);for(const y of u)c.has(y.id)&&!m.find(x=>x.id===y.id)&&m.push(y);if(!s)return{edges:m,nodes:o};const p=await s({nodes:o,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:o}:{edges:[],nodes:[]}:p}const Uc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ll=(e={x:0,y:0},t,n)=>({x:Uc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Uc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function TI(e,t,n){const{width:i,height:s}=ia(n),{x:a,y:o}=n.internals.positionAbsolute;return ll(e,[[a,o],[a+i,o+s]],t)}const OT=(e,t,n)=>e<t?Uc(Math.abs(e-t),1,t)/t:e>n?-Uc(Math.abs(e-n),1,t)/t:0,Ew=(e,t,n=15,i=40)=>{const s=OT(e.x,i,t.width-i)*n,a=OT(e.y,i,t.height-i)*n;return[s,a]},dg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wv=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),fg=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Wd=(e,t=[0,0])=>{var s,a;const{x:n,y:i}=vw(e)?e.internals.positionAbsolute:Sf(e,t);return{x:n,y:i,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((a=e.measured)==null?void 0:a.height)??e.height??e.initialHeight??0}},Nm=(e,t=[0,0])=>{var s,a;const{x:n,y:i}=vw(e)?e.internals.positionAbsolute:Sf(e,t);return{x:n,y:i,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:i+(((a=e.measured)==null?void 0:a.height)??e.height??e.initialHeight??0)}},AI=(e,t)=>fg(dg(wv(e),wv(t))),jI=(e,t,n,i,s,a,o,c)=>{const u=Math.max(0,Math.min(e+n,s+o)-Math.max(e,s)),f=Math.max(0,Math.min(t+i,a+c)-Math.max(t,a));return Math.ceil(u*f)},_m=(e,t)=>jI(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),LT=e=>Bs(e.width)&&Bs(e.height)&&Bs(e.x)&&Bs(e.y),Bs=e=>!isNaN(e)&&isFinite(e),MI=(e,t)=>(n,i)=>{},Nf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_f=({x:e,y:t},[n,i,s],a=!1,o=[1,1])=>{const c={x:(e-n)/s,y:(t-i)/s};return a?Nf(c,o):c},Fc=({x:e,y:t},[n,i,s])=>({x:e*s+n,y:t*s+i});function Ql(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function nle(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=Ql(e,n),s=Ql(e,t);return{top:i,right:s,bottom:i,left:s,x:s*2,y:i*2}}if(typeof e=="object"){const i=Ql(e.top??e.y??0,n),s=Ql(e.bottom??e.y??0,n),a=Ql(e.left??e.x??0,t),o=Ql(e.right??e.x??0,t);return{top:i,right:o,bottom:s,left:a,x:a+o,y:i+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ile(e,t,n,i,s,a){const{x:o,y:c}=Fc(e,[t,n,i]),{x:u,y:f}=Fc({x:e.x+e.width,y:e.y+e.height},[t,n,i]),m=s-u,p=a-f;return{left:Math.floor(o),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const Sw=(e,t,n,i,s,a)=>{const o=nle(a,t,n),c=(t-o.x)/e.width,u=(n-o.y)/e.height,f=Math.min(c,u),m=Uc(f,i,s),p=e.x+e.width/2,y=e.y+e.height/2,b=t/2-p*m,x=n/2-y*m,w=ile(e,b,x,m,t,n),E={left:Math.min(w.left-o.left,0),top:Math.min(w.top-o.top,0),right:Math.min(w.right-o.right,0),bottom:Math.min(w.bottom-o.bottom,0)};return{x:b-E.left+E.right,y:x-E.top+E.bottom,zoom:m}},Yd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function cl(e){return e!=null&&e!=="parent"}function ia(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function RI(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function DI(e,t={width:0,height:0},n,i,s){const a={...e},o=i.get(n);if(o){const c=o.origin||s;a.x+=o.internals.positionAbsolute.x-(t.width??0)*c[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*c[1]}return a}function IT(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sle(){let e,t;return{promise:new Promise((i,s)=>{e=i,t=s}),resolve:e,reject:t}}function rle(e){return{...SI,...e||{}}}function _d(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:s}){const{x:a,y:o}=Us(e),c=_f({x:a-((s==null?void 0:s.left)??0),y:o-((s==null?void 0:s.top)??0)},i),{x:u,y:f}=n?Nf(c,t):c;return{xSnapped:u,ySnapped:f,...c}}const kw=e=>({width:e.offsetWidth,height:e.offsetHeight}),OI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},ale=["INPUT","SELECT","TEXTAREA"];function LI(e){var i,s;const t=((s=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:ale.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const II=e=>"clientX"in e,Us=(e,t)=>{var a,o;const n=II(e),i=n?e.clientX:(a=e.touches)==null?void 0:a[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},PT=(e,t,n,i,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(o=>{const c=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:e,nodeId:s,position:o.getAttribute("data-handlepos"),x:(c.left-n.left)/i,y:(c.top-n.top)/i,...kw(o)}})};function PI({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:s,sourceControlY:a,targetControlX:o,targetControlY:c}){const u=e*.125+s*.375+o*.375+n*.125,f=t*.125+a*.375+c*.375+i*.125,m=Math.abs(u-e),p=Math.abs(f-t);return[u,f,m,p]}function pp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function zT({pos:e,x1:t,y1:n,x2:i,y2:s,c:a}){switch(e){case Je.Left:return[t-pp(t-i,a),n];case Je.Right:return[t+pp(i-t,a),n];case Je.Top:return[t,n-pp(n-s,a)];case Je.Bottom:return[t,n+pp(s-n,a)]}}function zI({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top,curvature:o=.25}){const[c,u]=zT({pos:n,x1:e,y1:t,x2:i,y2:s,c:o}),[f,m]=zT({pos:a,x1:i,y1:s,x2:e,y2:t,c:o}),[p,y,b,x]=PI({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:m});return[`M${e},${t} C${c},${u} ${f},${m} ${i},${s}`,p,y,b,x]}function BI({sourceX:e,sourceY:t,targetX:n,targetY:i}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,o=Math.abs(i-t)/2,c=i<t?i+o:i-o;return[a,c,s,o]}function ole({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return i;const o=s&&n?i+1e3:i,c=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return o+c}function lle({sourceNode:e,targetNode:t,width:n,height:i,transform:s}){const a=dg(Nm(e),Nm(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const o={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:i/s[2]};return _m(o,fg(a))>0}const UI=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,cle=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),ule=(e,t,n={})=>{var a;if(!e.source||!e.target)return(a=n.onError)==null||a.call(n,"006",as.error006()),t;const i=n.getEdgeId||UI;let s;return _I(e)?s={...e}:s={...e,id:i(e)},cle(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))},dle=(e,t,n,i={shouldReplaceId:!0})=>{var f,m;const{id:s,...a}=e;if(!t.source||!t.target)return(f=i.onError)==null||f.call(i,"006",as.error006()),n;if(!n.find(p=>p.id===e.id))return(m=i.onError)==null||m.call(i,"007",as.error007(s)),n;const c=i.getEdgeId||UI,u={...a,id:i.shouldReplaceId?c(t):s,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(p=>p.id!==s).concat(u)};function FI({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[s,a,o,c]=BI({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,s,a,o,c]}const BT={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},fle=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},UT=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hle({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:i=Je.Top,center:s,offset:a,stepPosition:o}){const c=BT[t],u=BT[i],f={x:e.x+c.x*a,y:e.y+c.y*a},m={x:n.x+u.x*a,y:n.y+u.y*a},p=fle({source:f,sourcePosition:t,target:m}),y=p.x!==0?"x":"y",b=p[y];let x=[],w,E;const v={x:0,y:0},_={x:0,y:0},[,,k,T]=BI({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[y]*u[y]===-1){y==="x"?(w=s.x??f.x+(m.x-f.x)*o,E=s.y??(f.y+m.y)/2):(w=s.x??(f.x+m.x)/2,E=s.y??f.y+(m.y-f.y)*o);const D=[{x:w,y:f.y},{x:w,y:m.y}],I=[{x:f.x,y:E},{x:m.x,y:E}];c[y]===b?x=y==="x"?D:I:x=y==="x"?I:D}else{const D=[{x:f.x,y:m.y}],I=[{x:m.x,y:f.y}];if(y==="x"?x=c.x===b?I:D:x=c.y===b?D:I,t===i){const O=Math.abs(e[y]-n[y]);if(O<=a){const R=Math.min(a-1,a-O);c[y]===b?v[y]=(f[y]>e[y]?-1:1)*R:_[y]=(m[y]>n[y]?-1:1)*R}}if(t!==i){const O=y==="x"?"y":"x",R=c[y]===u[O],z=f[O]>m[O],G=f[O]<m[O];(c[y]===1&&(!R&&z||R&&G)||c[y]!==1&&(!R&&G||R&&z))&&(x=y==="x"?D:I)}const P={x:f.x+v.x,y:f.y+v.y},U={x:m.x+_.x,y:m.y+_.y},q=Math.max(Math.abs(P.x-x[0].x),Math.abs(U.x-x[0].x)),V=Math.max(Math.abs(P.y-x[0].y),Math.abs(U.y-x[0].y));q>=V?(w=(P.x+U.x)/2,E=x[0].y):(w=x[0].x,E=(P.y+U.y)/2)}const A={x:f.x+v.x,y:f.y+v.y},j={x:m.x+_.x,y:m.y+_.y};return[[e,...A.x!==x[0].x||A.y!==x[0].y?[A]:[],...x,...j.x!==x[x.length-1].x||j.y!==x[x.length-1].y?[j]:[],n],w,E,k,T]}function ple(e,t,n,i){const s=Math.min(UT(e,t)/2,UT(t,n)/2,i),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){const f=e.x<n.x?-1:1,m=e.y<n.y?1:-1;return`L ${a+s*f},${o}Q ${a},${o} ${a},${o+s*m}`}const c=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${a},${o+s*u}Q ${a},${o} ${a+s*c},${o}`}function Ev({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top,borderRadius:o=5,centerX:c,centerY:u,offset:f=20,stepPosition:m=.5}){const[p,y,b,x,w]=hle({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:s},targetPosition:a,center:{x:c,y:u},offset:f,stepPosition:m});let E=`M${p[0].x} ${p[0].y}`;for(let v=1;v<p.length-1;v++)E+=ple(p[v-1],p[v],p[v+1],o);return E+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[E,y,b,x,w]}function FT(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mle(e){var p;const{sourceNode:t,targetNode:n}=e;if(!FT(t)||!FT(n))return null;const i=t.internals.handleBounds||$T(t.handles),s=n.internals.handleBounds||$T(n.handles),a=qT((i==null?void 0:i.source)??[],e.sourceHandle),o=qT(e.connectionMode===Bc.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!a||!o)return(p=e.onError)==null||p.call(e,"008",as.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(a==null?void 0:a.position)||Je.Bottom,u=(o==null?void 0:o.position)||Je.Top,f=ul(t,a,c),m=ul(n,o,u);return{sourceX:f.x,sourceY:f.y,targetX:m.x,targetY:m.y,sourcePosition:c,targetPosition:u}}function $T(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function ul(e,t,n=Je.Left,i=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,a=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:c}=t??ia(e);if(i)return{x:s+o/2,y:a+c/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:s+o/2,y:a};case Je.Right:return{x:s+o,y:a+c/2};case Je.Bottom:return{x:s+o/2,y:a+c};case Je.Left:return{x:s,y:a+c/2}}}function qT(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Sv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function gle(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:s}){const a=new Set;return e.reduce((o,c)=>([c.markerStart||i,c.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const f=Sv(u,t);a.has(f)||(o.push({id:f,color:u.color||n,...u}),a.add(f))}}),o),[]).sort((o,c)=>o.id.localeCompare(c.id))}const $I=1e3,yle=10,Nw={nodeOrigin:[0,0],nodeExtent:Kd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ble={...Nw,checkEquality:!0};function _w(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function xle(e,t,n){const i=_w(Nw,n);for(const s of e.values())if(s.parentId)Tw(s,e,t,i);else{const a=Sf(s,i.nodeOrigin),o=cl(s.extent)?s.extent:i.nodeExtent,c=ll(a,o,ia(s));s.internals.positionAbsolute=c}}function vle(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&i.push(a)}return{source:n,target:i}}function Cw(e){return e==="manual"}function kv(e,t,n,i={}){var m,p;const s=_w(ble,i),a={i:0},o=new Map(t),c=s!=null&&s.elevateNodesOnSelect&&!Cw(s.zIndexMode)?$I:0;let u=e.length>0,f=!1;t.clear(),n.clear();for(const y of e){let b=o.get(y.id);if(s.checkEquality&&y===(b==null?void 0:b.internals.userNode))t.set(y.id,b);else{const x=Sf(y,s.nodeOrigin),w=cl(y.extent)?y.extent:s.nodeExtent,E=ll(x,w,ia(y));b={...s.defaults,...y,measured:{width:(m=y.measured)==null?void 0:m.width,height:(p=y.measured)==null?void 0:p.height},internals:{positionAbsolute:E,handleBounds:vle(y,b),z:qI(y,c,s.zIndexMode),userNode:y}},t.set(y.id,b)}(b.measured===void 0||b.measured.width===void 0||b.measured.height===void 0)&&!b.hidden&&(u=!1),y.parentId&&Tw(b,t,n,i,a),f||(f=y.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:f}}function wle(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Tw(e,t,n,i,s){const{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:c,zIndexMode:u}=_w(Nw,i),f=e.parentId,m=t.get(f);if(!m){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}wle(e,n),s&&!m.parentId&&m.internals.rootParentIndex===void 0&&u==="auto"&&(m.internals.rootParentIndex=++s.i,m.internals.z=m.internals.z+s.i*yle),s&&m.internals.rootParentIndex!==void 0&&(s.i=m.internals.rootParentIndex);const p=a&&!Cw(u)?$I:0,{x:y,y:b,z:x}=Ele(e,m,o,c,p,u),{positionAbsolute:w}=e.internals,E=y!==w.x||b!==w.y;(E||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:E?{x:y,y:b}:w,z:x}})}function qI(e,t,n){const i=Bs(e.zIndex)?e.zIndex:0;return Cw(n)?i:i+(e.selected?t:0)}function Ele(e,t,n,i,s,a){const{x:o,y:c}=t.internals.positionAbsolute,u=ia(e),f=Sf(e,n),m=cl(e.extent)?ll(f,e.extent,u):f;let p=ll({x:o+m.x,y:c+m.y},i,u);e.extent==="parent"&&(p=TI(p,u,t));const y=qI(e,s,a),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=y?b+1:y}}function Aw(e,t,n,i=[0,0]){var o;const s=[],a=new Map;for(const c of e){const u=t.get(c.parentId);if(!u)continue;const f=((o=a.get(c.parentId))==null?void 0:o.expandedRect)??Wd(u),m=AI(f,c.rect);a.set(c.parentId,{expandedRect:m,parent:u})}return a.size>0&&a.forEach(({expandedRect:c,parent:u},f)=>{var k;const m=u.internals.positionAbsolute,p=ia(u),y=u.origin??i,b=c.x<m.x?Math.round(Math.abs(m.x-c.x)):0,x=c.y<m.y?Math.round(Math.abs(m.y-c.y)):0,w=Math.max(p.width,Math.round(c.width)),E=Math.max(p.height,Math.round(c.height)),v=(w-p.width)*y[0],_=(E-p.height)*y[1];(b>0||x>0||v||_)&&(s.push({id:f,type:"position",position:{x:u.position.x-b+v,y:u.position.y-x+_}}),(k=n.get(f))==null||k.forEach(T=>{e.some(A=>A.id===T.id)||s.push({id:T.id,type:"position",position:{x:T.position.x+b,y:T.position.y+x}})})),(p.width<c.width||p.height<c.height||b||x)&&s.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:w+(b?y[0]*b-v:0),height:E+(x?y[1]*x-_:0)}})}),s}function Sle(e,t,n,i,s,a,o){const c=i==null?void 0:i.querySelector(".xyflow__viewport");let u=!1;if(!c)return{changes:[],updatedInternals:u};const f=[],m=window.getComputedStyle(c),{m22:p}=new window.DOMMatrixReadOnly(m.transform),y=[];for(const b of e.values()){const x=t.get(b.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),u=!0;continue}const w=kw(b.nodeElement),E=x.measured.width!==w.width||x.measured.height!==w.height;if(!!(w.width&&w.height&&(E||!x.internals.handleBounds||b.force))){const _=b.nodeElement.getBoundingClientRect(),k=cl(x.extent)?x.extent:a;let{positionAbsolute:T}=x.internals;x.parentId&&x.extent==="parent"?T=TI(T,w,t.get(x.parentId)):k&&(T=ll(T,k,w));const A={...x,measured:w,internals:{...x.internals,positionAbsolute:T,handleBounds:{source:PT("source",b.nodeElement,_,p,x.id),target:PT("target",b.nodeElement,_,p,x.id)}}};t.set(x.id,A),x.parentId&&Tw(A,t,n,{nodeOrigin:s,zIndexMode:o}),u=!0,E&&(f.push({id:x.id,type:"dimensions",dimensions:w}),x.expandParent&&x.parentId&&y.push({id:x.id,parentId:x.parentId,rect:Wd(A,s)}))}}if(y.length>0){const b=Aw(y,t,n,s);f.push(...b)}return{changes:f,updatedInternals:u}}async function kle({delta:e,panZoom:t,transform:n,translateExtent:i,width:s,height:a}){if(!t||!e.x&&!e.y)return!1;const o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],i);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function HT(e,t,n,i,s,a){let o=s;const c=i.get(o)||new Map;i.set(o,c.set(n,t)),o=`${s}-${e}`;const u=i.get(o)||new Map;if(i.set(o,u.set(n,t)),a){o=`${s}-${e}-${a}`;const f=i.get(o)||new Map;i.set(o,f.set(n,t))}}function HI(e,t,n){e.clear(),t.clear();for(const i of n){const{source:s,target:a,sourceHandle:o=null,targetHandle:c=null}=i,u={edgeId:i.id,source:s,target:a,sourceHandle:o,targetHandle:c},f=`${s}-${o}--${a}-${c}`,m=`${a}-${c}--${s}-${o}`;HT("source",u,m,e,s,o),HT("target",u,f,e,a,c),t.set(i.id,i)}}function VI(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:VI(n,t):!1}function VT(e,t,n){var s;let i=e;do{if((s=i==null?void 0:i.matches)!=null&&s.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Nle(e,t,n,i){const s=new Map;for(const[a,o]of e)if((o.selected||o.id===i)&&(!o.parentId||!VI(o,e))&&(o.draggable||t&&typeof o.draggable>"u")){const c=e.get(a);c&&s.set(a,{id:a,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return s}function Px({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var o,c,u;const s=[];for(const[f,m]of t){const p=(o=n.get(f))==null?void 0:o.internals.userNode;p&&s.push({...p,position:m.position,dragging:i})}if(!e)return[s[0],s];const a=(c=n.get(e))==null?void 0:c.internals.userNode;return[a?{...a,position:((u=t.get(e))==null?void 0:u.position)||a.position,dragging:i}:s[0],s]}function _le({dragItems:e,snapGrid:t,x:n,y:i}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:i-s.distance.y},o=Nf(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Cle({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:s}){let a={x:null,y:null},o=0,c=new Map,u=!1,f={x:0,y:0},m=null,p=!1,y=null,b=!1,x=!1,w=null;function E({noDragClassName:_,handleSelector:k,domNode:T,isSelectable:A,nodeId:j,nodeClickDistance:M=0}){y=ns(T);function D({x:q,y:V}){const{nodeLookup:O,nodeExtent:R,snapGrid:z,snapToGrid:G,nodeOrigin:Y,onNodeDrag:K,onSelectionDrag:B,onError:F,updateNodePositions:W}=t();a={x:q,y:V};let $=!1;const ae=c.size>1,be=ae&&R?wv(kf(c)):null,le=ae&&G?_le({dragItems:c,snapGrid:z,x:q,y:V}):null;for(const[Ne,re]of c){if(!O.has(Ne))continue;let me={x:q-re.distance.x,y:V-re.distance.y};G&&(me=le?{x:Math.round(me.x+le.x),y:Math.round(me.y+le.y)}:Nf(me,z));let se=null;if(ae&&R&&!re.extent&&be){const{positionAbsolute:_e}=re.internals,ze=_e.x-be.x+R[0][0],fe=_e.x+re.measured.width-be.x2+R[1][0],Se=_e.y-be.y+R[0][1],Re=_e.y+re.measured.height-be.y2+R[1][1];se=[[ze,Se],[fe,Re]]}const{position:Q,positionAbsolute:ye}=CI({nodeId:Ne,nextPosition:me,nodeLookup:O,nodeExtent:se||R,nodeOrigin:Y,onError:F});$=$||re.position.x!==Q.x||re.position.y!==Q.y,re.position=Q,re.internals.positionAbsolute=ye}if(x=x||$,!!$&&(W(c,!0),w&&(i||K||!j&&B))){const[Ne,re]=Px({nodeId:j,dragItems:c,nodeLookup:O});i==null||i(w,c,Ne,re),K==null||K(w,Ne,re),j||B==null||B(w,re)}}async function I(){if(!m)return;const{transform:q,panBy:V,autoPanSpeed:O,autoPanOnNodeDrag:R}=t();if(!R){u=!1,cancelAnimationFrame(o);return}const[z,G]=Ew(f,m,O);(z!==0||G!==0)&&(a.x=(a.x??0)-z/q[2],a.y=(a.y??0)-G/q[2],await V({x:z,y:G})&&D(a)),o=requestAnimationFrame(I)}function P(q){var ae;const{nodeLookup:V,multiSelectionActive:O,nodesDraggable:R,transform:z,snapGrid:G,snapToGrid:Y,selectNodesOnDrag:K,onNodeDragStart:B,onSelectionDragStart:F,unselectNodesAndEdges:W}=t();p=!0,(!K||!A)&&!O&&j&&((ae=V.get(j))!=null&&ae.selected||W()),A&&K&&j&&(e==null||e(j));const $=_d(q.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Y,containerBounds:m});if(a=$,c=Nle(V,R,$,j),c.size>0&&(n||B||!j&&F)){const[be,le]=Px({nodeId:j,dragItems:c,nodeLookup:V});n==null||n(q.sourceEvent,c,be,le),B==null||B(q.sourceEvent,be,le),j||F==null||F(q.sourceEvent,le)}}const U=aI().clickDistance(M).on("start",q=>{const{domNode:V,nodeDragThreshold:O,transform:R,snapGrid:z,snapToGrid:G}=t();m=(V==null?void 0:V.getBoundingClientRect())||null,b=!1,x=!1,w=q.sourceEvent,O===0&&P(q),a=_d(q.sourceEvent,{transform:R,snapGrid:z,snapToGrid:G,containerBounds:m}),f=Us(q.sourceEvent,m)}).on("drag",q=>{const{autoPanOnNodeDrag:V,transform:O,snapGrid:R,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Y}=t(),K=_d(q.sourceEvent,{transform:O,snapGrid:R,snapToGrid:z,containerBounds:m});if(w=q.sourceEvent,(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||j&&!Y.has(j))&&(b=!0),!b){if(!u&&V&&p&&(u=!0,I()),!p){const B=Us(q.sourceEvent,m),F=B.x-f.x,W=B.y-f.y;Math.sqrt(F*F+W*W)>G&&P(q)}(a.x!==K.xSnapped||a.y!==K.ySnapped)&&c&&p&&(f=Us(q.sourceEvent,m),D(K))}}).on("end",q=>{if(!p||b){b&&c.size>0&&t().updateNodePositions(c,!1);return}if(u=!1,p=!1,cancelAnimationFrame(o),c.size>0){const{nodeLookup:V,updateNodePositions:O,onNodeDragStop:R,onSelectionDragStop:z}=t();if(x&&(O(c,!1),x=!1),s||R||!j&&z){const[G,Y]=Px({nodeId:j,dragItems:c,nodeLookup:V,dragging:!1});s==null||s(q.sourceEvent,c,G,Y),R==null||R(q.sourceEvent,G,Y),j||z==null||z(q.sourceEvent,Y)}}}).filter(q=>{const V=q.target;return!q.button&&(!_||!VT(V,`.${_}`,T))&&(!k||VT(V,k,T))});y.call(U)}function v(){y==null||y.on(".drag",null)}return{update:E,destroy:v}}function Tle(e,t,n){const i=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())_m(s,Wd(a))>0&&i.push(a);return i}const Ale=250;function jle(e,t,n,i){var c,u;let s=[],a=1/0;const o=Tle(e,n,t+Ale);for(const f of o){const m=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((u=f.internals.handleBounds)==null?void 0:u.target)??[]];for(const p of m){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:y,y:b}=ul(f,p,p.position,!0),x=Math.sqrt(Math.pow(y-e.x,2)+Math.pow(b-e.y,2));x>t||(x<a?(s=[{...p,x:y,y:b}],a=x):x===a&&s.push({...p,x:y,y:b}))}}if(!s.length)return null;if(s.length>1){const f=i.type==="source"?"target":"source";return s.find(m=>m.type===f)??s[0]}return s[0]}function KI(e,t,n,i,s,a=!1){var f,m,p;const o=i.get(e);if(!o)return null;const c=s==="strict"?(f=o.internals.handleBounds)==null?void 0:f[t]:[...((m=o.internals.handleBounds)==null?void 0:m.source)??[],...((p=o.internals.handleBounds)==null?void 0:p.target)??[]],u=(n?c==null?void 0:c.find(y=>y.id===n):c==null?void 0:c[0])??null;return u&&a?{...u,...ul(o,u,u.position,!0)}:u}function GI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Mle(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const WI=()=>!0;function Rle(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:s,edgeUpdaterType:a,isTarget:o,domNode:c,nodeLookup:u,lib:f,autoPanOnConnect:m,flowId:p,panBy:y,cancelConnection:b,onConnectStart:x,onConnect:w,onConnectEnd:E,isValidConnection:v=WI,onReconnectEnd:_,updateConnection:k,getTransform:T,getFromHandle:A,autoPanSpeed:j,dragThreshold:M=1,handleDomNode:D}){const I=OI(e.target);let P=0,U;const{x:q,y:V}=Us(e),O=GI(a,D),R=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!R||!O)return;const G=KI(s,O,i,u,t);if(!G)return;let Y=Us(e,R),K=!1,B=null,F=!1,W=null;function $(){if(!m||!R)return;const[Q,ye]=Ew(Y,R,j);y({x:Q,y:ye}),P=requestAnimationFrame($)}const ae={...G,nodeId:s,type:O,position:G.position},be=u.get(s);let Ne={inProgress:!0,isValid:null,from:ul(be,ae,Je.Left,!0),fromHandle:ae,fromPosition:ae.position,fromNode:be,to:Y,toHandle:null,toPosition:DT[ae.position],toNode:null,pointer:Y};function re(){z=!0,k(Ne),x==null||x(e,{nodeId:s,handleId:i,handleType:O})}M===0&&re();function me(Q){if(!z){const{x:Re,y:Qe}=Us(Q),ht=Re-q,it=Qe-V;if(!(ht*ht+it*it>M*M))return;re()}if(!A()||!ae){se(Q);return}const ye=T();Y=Us(Q,R),U=jle(_f(Y,ye,!1,[1,1]),n,u,ae),K||($(),K=!0);const _e=YI(Q,{handle:U,connectionMode:t,fromNodeId:s,fromHandleId:i,fromType:o?"target":"source",isValidConnection:v,doc:I,lib:f,flowId:p,nodeLookup:u});W=_e.handleDomNode,B=_e.connection,F=Mle(!!U,_e.isValid);const ze=u.get(s),fe=ze?ul(ze,ae,Je.Left,!0):Ne.from,Se={...Ne,from:fe,isValid:F,to:_e.toHandle&&F?Fc({x:_e.toHandle.x,y:_e.toHandle.y},ye):Y,toHandle:_e.toHandle,toPosition:F&&_e.toHandle?_e.toHandle.position:DT[ae.position],toNode:_e.toHandle?u.get(_e.toHandle.nodeId):null,pointer:Y};k(Se),Ne=Se}function se(Q){if(!("touches"in Q&&Q.touches.length>0)){if(z){(U||W)&&B&&F&&(w==null||w(B));const{inProgress:ye,..._e}=Ne,ze={..._e,toPosition:Ne.toHandle?Ne.toPosition:null};E==null||E(Q,ze),a&&(_==null||_(Q,ze))}b(),cancelAnimationFrame(P),K=!1,F=!1,B=null,W=null,I.removeEventListener("mousemove",me),I.removeEventListener("mouseup",se),I.removeEventListener("touchmove",me),I.removeEventListener("touchend",se)}}I.addEventListener("mousemove",me),I.addEventListener("mouseup",se),I.addEventListener("touchmove",me),I.addEventListener("touchend",se)}function YI(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:a,doc:o,lib:c,flowId:u,isValidConnection:f=WI,nodeLookup:m}){const p=a==="target",y=t?o.querySelector(`.${c}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:x}=Us(e),w=o.elementFromPoint(b,x),E=w!=null&&w.classList.contains(`${c}-flow__handle`)?w:y,v={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const _=GI(void 0,E),k=E.getAttribute("data-nodeid"),T=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),j=E.classList.contains("connectableend");if(!k||!_)return v;const M={source:p?k:i,sourceHandle:p?T:s,target:p?i:k,targetHandle:p?s:T};v.connection=M;const I=A&&j&&(n===Bc.Strict?p&&_==="source"||!p&&_==="target":k!==i||T!==s);v.isValid=I&&f(M),v.toHandle=KI(k,_,T,m,n,!0)}return v}const Nv={onPointerDown:Rle,isValid:YI};function Dle({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const s=ns(e);function a({translateExtent:c,width:u,height:f,zoomStep:m=1,pannable:p=!0,zoomable:y=!0,inversePan:b=!1}){const x=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const T=n(),A=k.sourceEvent.ctrlKey&&Yd()?10:1,j=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,M=T[2]*Math.pow(2,j*A);t.scaleTo(M)};let w=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(w=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},v=k=>{const T=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],j=[A[0]-w[0],A[1]-w[1]];w=A;const M=i()*Math.max(T[2],Math.log(T[2]))*(b?-1:1),D={x:T[0]-j[0]*M,y:T[1]-j[1]*M},I=[[0,0],[u,f]];t.setViewportConstrained({x:D.x,y:D.y,zoom:T[2]},I,c)},_=wI().on("start",E).on("zoom",p?v:null).on("zoom.wheel",y?x:null);s.call(_,{})}function o(){s.on("zoom",null)}return{update:a,destroy:o,pointer:Is}}const hg=e=>({x:e.x,y:e.y,zoom:e.k}),zx=({x:e,y:t,zoom:n})=>ug.translate(e,t).scale(n),cc=(e,t)=>e.target.closest(`.${t}`),XI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ole=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Bx=(e,t=0,n=Ole,i=()=>{})=>{const s=typeof t=="number"&&t>0;return s||i(),s?e.transition().duration(t).ease(n).on("end",i):e},QI=e=>{const t=e.ctrlKey&&Yd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Lle({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:f}){return m=>{if(cc(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(m.ctrlKey&&o){const E=Is(m),v=QI(m),_=p*Math.pow(2,v);i.scaleTo(n,_,E,m);return}const y=m.deltaMode===1?20:1;let b=s===Jo.Vertical?0:m.deltaX*y,x=s===Jo.Horizontal?0:m.deltaY*y;!Yd()&&m.shiftKey&&s!==Jo.Vertical&&(b=m.deltaY*y,x=0),i.translateBy(n,-(b/p)*a,-(x/p)*a,{internal:!0});const w=hg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(m,w),e.panScrollTimeout=setTimeout(()=>{f==null||f(m,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,w))}}function Ile({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,s){const a=i.type==="wheel",o=!t&&a&&!i.ctrlKey,c=cc(i,e);if(i.ctrlKey&&a&&c&&i.preventDefault(),o||c)return null;i.preventDefault(),n.call(this,i,s)}}function Ple({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var a,o,c;if((a=i.sourceEvent)!=null&&a.internal)return;const s=hg(i.transform);e.mouseButton=((o=i.sourceEvent)==null?void 0:o.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((c=i.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,s))}}function zle({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:s}){return a=>{var o,c;e.usedRightMouseButton=!!(n&&XI(t,e.mouseButton??0)),(o=a.sourceEvent)!=null&&o.sync||i([a.transform.x,a.transform.y,a.transform.k]),s&&!((c=a.sourceEvent)!=null&&c.internal)&&(s==null||s(a.sourceEvent,hg(a.transform)))}}function Ble({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:s,onPaneContextMenu:a}){return o=>{var c;if(!((c=o.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,a&&XI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,i(!1),s)){const u=hg(o.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,u)},n?150:0)}}}function Ule({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:c,noPanClassName:u,lib:f,connectionInProgress:m}){return p=>{var E;const y=e||t,b=n&&p.ctrlKey,x=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(cc(p,`${f}-flow__node`)||cc(p,`${f}-flow__edge`)))return!0;if(!i&&!y&&!s&&!a&&!n||o||m&&!x||cc(p,c)&&x||cc(p,u)&&(!x||s&&x&&!e)||!n&&p.ctrlKey&&x)return!1;if(!n&&p.type==="touchstart"&&((E=p.touches)==null?void 0:E.length)>1)return p.preventDefault(),!1;if(!y&&!s&&!b&&x||!i&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(i)&&!i.includes(p.button)&&p.type==="mousedown")return!1;const w=Array.isArray(i)&&i.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||x)&&w}}function Fle({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:s,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:c,onDraggingChange:u}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=wI().scaleExtent([t,n]).translateExtent(i),y=ns(e).call(p);_({x:s.x,y:s.y,zoom:Uc(s.zoom,t,n)},[[0,0],[m.width,m.height]],i);const b=y.on("wheel.zoom"),x=y.on("dblclick.zoom");p.wheelDelta(QI);async function w(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).transform(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}function E({noWheelClassName:U,noPanClassName:q,onPaneContextMenu:V,userSelectionActive:O,panOnScroll:R,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Y,preventScrolling:K,zoomOnPinch:B,zoomOnScroll:F,zoomOnDoubleClick:W,zoomActivationKeyPressed:$,lib:ae,onTransformChange:be,connectionInProgress:le,paneClickDistance:Ne,selectionOnDrag:re}){O&&!f.isZoomingOrPanning&&v();const me=R&&!$&&!O;p.clickDistance(re?1/0:!Bs(Ne)||Ne<0?0:Ne);const se=me?Lle({zoomPanValues:f,noWheelClassName:U,d3Selection:y,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Y,zoomOnPinch:B,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:c}):Ile({noWheelClassName:U,preventScrolling:K,d3ZoomHandler:b});y.on("wheel.zoom",se,{passive:!1});const Q=Ple({zoomPanValues:f,onDraggingChange:u,onPanZoomStart:o});p.on("start",Q);const ye=zle({zoomPanValues:f,panOnDrag:z,onPaneContextMenu:!!V,onPanZoom:a,onTransformChange:be});p.on("zoom",ye);const _e=Ble({zoomPanValues:f,panOnDrag:z,panOnScroll:R,onPaneContextMenu:V,onPanZoomEnd:c,onDraggingChange:u});p.on("end",_e);const ze=Ule({zoomActivationKeyPressed:$,panOnDrag:z,zoomOnScroll:F,panOnScroll:R,zoomOnDoubleClick:W,zoomOnPinch:B,userSelectionActive:O,noPanClassName:q,noWheelClassName:U,lib:ae,connectionInProgress:le});p.filter(ze),W?y.on("dblclick.zoom",x):y.on("dblclick.zoom",null)}function v(){p.on("zoom",null)}async function _(U,q,V){const O=zx(U),R=p==null?void 0:p.constrain()(O,q,V);return R&&await w(R),R}async function k(U,q){const V=zx(U);return await w(V,q),V}function T(U){if(y){const q=zx(U),V=y.property("__zoom");(V.k!==U.zoom||V.x!==U.x||V.y!==U.y)&&(p==null||p.transform(y,q,null,{sync:!0}))}}function A(){const U=y?vI(y.node()):{x:0,y:0,k:1};return{x:U.x,y:U.y,zoom:U.k}}async function j(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).scaleTo(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}async function M(U,q){return y?new Promise(V=>{p==null||p.interpolate((q==null?void 0:q.interpolate)==="linear"?Nd:zp).scaleBy(Bx(y,q==null?void 0:q.duration,q==null?void 0:q.ease,()=>V(!0)),U)}):!1}function D(U){p==null||p.scaleExtent(U)}function I(U){p==null||p.translateExtent(U)}function P(U){const q=!Bs(U)||U<0?0:U;p==null||p.clickDistance(q)}return{update:E,destroy:v,setViewport:k,setViewportConstrained:_,getViewport:A,scaleTo:j,scaleBy:M,setScaleExtent:D,setTranslateExtent:I,syncViewport:T,setClickDistance:P}}var $c;(function(e){e.Line="line",e.Handle="handle"})($c||($c={}));function $le({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:s,affectsY:a}){const o=e-t,c=n-i,u=[o>0?1:o<0?-1:0,c>0?1:c<0?-1:0];return o&&s&&(u[0]=u[0]*-1),c&&a&&(u[1]=u[1]*-1),u}function KT(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:s}}function Ia(e,t){return Math.max(0,t-e)}function Pa(e,t){return Math.max(0,e-t)}function mp(e,t,n){return Math.max(0,t-e,e-n)}function GT(e,t){return e?!t:t}function qle(e,t,n,i,s,a,o,c){let{affectsX:u,affectsY:f}=t;const{isHorizontal:m,isVertical:p}=t,y=m&&p,{xSnapped:b,ySnapped:x}=n,{minWidth:w,maxWidth:E,minHeight:v,maxHeight:_}=i,{x:k,y:T,width:A,height:j,aspectRatio:M}=e;let D=Math.floor(m?b-e.pointerX:0),I=Math.floor(p?x-e.pointerY:0);const P=A+(u?-D:D),U=j+(f?-I:I),q=-a[0]*A,V=-a[1]*j;let O=mp(P,w,E),R=mp(U,v,_);if(o){let Y=0,K=0;u&&D<0?Y=Ia(k+D+q,o[0][0]):!u&&D>0&&(Y=Pa(k+P+q,o[1][0])),f&&I<0?K=Ia(T+I+V,o[0][1]):!f&&I>0&&(K=Pa(T+U+V,o[1][1])),O=Math.max(O,Y),R=Math.max(R,K)}if(c){let Y=0,K=0;u&&D>0?Y=Pa(k+D,c[0][0]):!u&&D<0&&(Y=Ia(k+P,c[1][0])),f&&I>0?K=Pa(T+I,c[0][1]):!f&&I<0&&(K=Ia(T+U,c[1][1])),O=Math.max(O,Y),R=Math.max(R,K)}if(s){if(m){const Y=mp(P/M,v,_)*M;if(O=Math.max(O,Y),o){let K=0;!u&&!f||u&&!f&&y?K=Pa(T+V+P/M,o[1][1])*M:K=Ia(T+V+(u?D:-D)/M,o[0][1])*M,O=Math.max(O,K)}if(c){let K=0;!u&&!f||u&&!f&&y?K=Ia(T+P/M,c[1][1])*M:K=Pa(T+(u?D:-D)/M,c[0][1])*M,O=Math.max(O,K)}}if(p){const Y=mp(U*M,w,E)/M;if(R=Math.max(R,Y),o){let K=0;!u&&!f||f&&!u&&y?K=Pa(k+U*M+q,o[1][0])/M:K=Ia(k+(f?I:-I)*M+q,o[0][0])/M,R=Math.max(R,K)}if(c){let K=0;!u&&!f||f&&!u&&y?K=Ia(k+U*M,c[1][0])/M:K=Pa(k+(f?I:-I)*M,c[0][0])/M,R=Math.max(R,K)}}}I=I+(I<0?R:-R),D=D+(D<0?O:-O),s&&(y?P>U*M?I=(GT(u,f)?-D:D)/M:D=(GT(u,f)?-I:I)*M:m?(I=D/M,f=u):(D=I*M,u=f));const z=u?k+D:k,G=f?T+I:T;return{width:A+(u?-D:D),height:j+(f?-I:I),x:a[0]*D*(u?-1:1)+z,y:a[1]*I*(f?-1:1)+G}}const ZI={width:0,height:0,x:0,y:0},Hle={...ZI,pointerX:0,pointerY:0,aspectRatio:1};function Vle(e,t,n){const i=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,c=n[0]*a,u=n[1]*o;return[[i-c,s-u],[i+a-c,s+o-u]]}function Kle({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:s}){const a=ns(e);let o={controlDirection:KT("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:m,keepAspectRatio:p,resizeDirection:y,onResizeStart:b,onResize:x,onResizeEnd:w,shouldResize:E}){let v={...ZI},_={...Hle};o={boundaries:m,resizeDirection:y,keepAspectRatio:p,controlDirection:KT(f)};let k,T=null,A=[],j,M,D,I=!1;const P=aI().on("start",U=>{const{nodeLookup:q,transform:V,snapGrid:O,snapToGrid:R,nodeOrigin:z,paneDomNode:G}=n();if(k=q.get(t),!k)return;T=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Y,ySnapped:K}=_d(U.sourceEvent,{transform:V,snapGrid:O,snapToGrid:R,containerBounds:T});v={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},_={...v,pointerX:Y,pointerY:K,aspectRatio:v.width/v.height},j=void 0,M=cl(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(j=q.get(k.parentId)),j&&k.extent==="parent"&&(M=[[0,0],[j.measured.width,j.measured.height]]),A=[],D=void 0;for(const[B,F]of q)if(F.parentId===t&&(A.push({id:B,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const W=Vle(F,k,F.origin??z);D?D=[[Math.min(W[0][0],D[0][0]),Math.min(W[0][1],D[0][1])],[Math.max(W[1][0],D[1][0]),Math.max(W[1][1],D[1][1])]]:D=W}b==null||b(U,{...v})}).on("drag",U=>{const{transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R}=n(),z=_d(U.sourceEvent,{transform:q,snapGrid:V,snapToGrid:O,containerBounds:T}),G=[];if(!k)return;const{x:Y,y:K,width:B,height:F}=v,W={},$=k.origin??R,{width:ae,height:be,x:le,y:Ne}=qle(_,o.controlDirection,z,o.boundaries,o.keepAspectRatio,$,M,D),re=ae!==B,me=be!==F,se=le!==Y&&re,Q=Ne!==K&&me;if(!se&&!Q&&!re&&!me)return;if((se||Q||$[0]===1||$[1]===1)&&(W.x=se?le:v.x,W.y=Q?Ne:v.y,v.x=W.x,v.y=W.y,A.length>0)){const fe=le-Y,Se=Ne-K;for(const Re of A)Re.position={x:Re.position.x-fe+$[0]*(ae-B),y:Re.position.y-Se+$[1]*(be-F)},G.push(Re)}if((re||me)&&(W.width=re&&(!o.resizeDirection||o.resizeDirection==="horizontal")?ae:v.width,W.height=me&&(!o.resizeDirection||o.resizeDirection==="vertical")?be:v.height,v.width=W.width,v.height=W.height),j&&k.expandParent){const fe=$[0]*(W.width??0);W.x&&W.x<fe&&(v.x=fe,_.x=_.x-(W.x-fe));const Se=$[1]*(W.height??0);W.y&&W.y<Se&&(v.y=Se,_.y=_.y-(W.y-Se))}const ye=$le({width:v.width,prevWidth:B,height:v.height,prevHeight:F,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),_e={...v,direction:ye};(E==null?void 0:E(U,_e))!==!1&&(I=!0,x==null||x(U,_e),i(W,G))}).on("end",U=>{I&&(w==null||w(U,{...v}),s==null||s({...v}),I=!1)});a.call(P)}function u(){a.on(".drag",null)}return{update:c,destroy:u}}var Ux={exports:{}},Fx={},$x={exports:{}},qx={};/**
|
|
832
832
|
* @license React
|
|
833
833
|
* use-sync-external-store-shim.production.js
|
|
834
834
|
*
|
|
@@ -852,4 +852,4 @@ description: ...
|
|
|
852
852
|
`)),m=f.reduce((p,y)=>p.concat(...y),[]);return[f,m]}return[[],[]]},[e]);return C.useEffect(()=>{const u=(t==null?void 0:t.target)??rA,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var E,v;if(s.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!s.current||s.current&&!f)&&LI(b))return!1;const w=oA(b.code,c);if(a.current.add(b[w]),aA(o,a.current,!1)){const _=((v=(E=b.composedPath)==null?void 0:E.call(b))==null?void 0:v[0])||b.target,k=(_==null?void 0:_.nodeName)==="BUTTON"||(_==null?void 0:_.nodeName)==="A";t.preventDefault!==!1&&(s.current||!k)&&b.preventDefault(),i(!0)}},p=b=>{const x=oA(b.code,c);aA(o,a.current,!0)?(i(!1),a.current.clear()):a.current.delete(b[x]),b.key==="Meta"&&a.current.clear(),s.current=!1},y=()=>{a.current.clear(),i(!1)};return u==null||u.addEventListener("keydown",m),u==null||u.addEventListener("keyup",p),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{u==null||u.removeEventListener("keydown",m),u==null||u.removeEventListener("keyup",p),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[e,i]),n}function aA(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(s=>t.has(s)))}function oA(e,t){return t.includes(e)?"code":"key"}const Sce=()=>{const e=Sn();return C.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,s,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??i,y:t.y??s,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:s,minZoom:a,maxZoom:o,panZoom:c}=e.getState(),u=Sw(t,i,s,a,o,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:s,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;const{x:c,y:u}=o.getBoundingClientRect(),f={x:t.x-c,y:t.y-u},m=n.snapGrid??s,p=n.snapToGrid??a;return _f(f,i,p,m)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:s,y:a}=i.getBoundingClientRect(),o=Fc(t,n);return{x:o.x+s,y:o.y+a}}}),[])};function sP(e,t){const n=[],i=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")i.set(a.id,[a]);else{const o=i.get(a.id);o?o.push(a):i.set(a.id,[a])}for(const a of t){const o=i.get(a.id);if(!o){n.push(a);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const c={...a};for(const u of o)kce(u,c);n.push(c)}return s.length&&s.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function kce(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function rP(e,t){return sP(e,t)}function aP(e,t){return sP(e,t)}function Do(e,t){return{id:e,type:"select",selected:t}}function uc(e,t=new Set,n=!1){const i=[];for(const[s,a]of e){const o=t.has(s);!(a.selected===void 0&&!o)&&a.selected!==o&&(n&&(a.selected=o),i.push(Do(a.id,o)))}return i}function lA({items:e=[],lookup:t}){var s;const n=[],i=new Map(e.map(a=>[a.id,a]));for(const[a,o]of e.entries()){const c=t.get(o.id),u=((s=c==null?void 0:c.internals)==null?void 0:s.userNode)??c;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:a})}for(const[a]of t)i.get(a)===void 0&&n.push({id:a,type:"remove"});return n}function cA(e){return{id:e.id,type:"remove"}}const oP=MI();function lP(e,t,n={}){return ule(e,t,{...n,onError:n.onError??oP})}function Nce(e,t,n,i={shouldReplaceId:!0}){return dle(e,t,n,{...i,onError:i.onError??oP})}const uA=e=>Xoe(e),_ce=e=>_I(e);function cP(e){return C.forwardRef(e)}const Cce=typeof window<"u"?C.useLayoutEffect:C.useEffect;function dA(e){const[t,n]=C.useState(BigInt(0)),[i]=C.useState(()=>Tce(()=>n(s=>s+BigInt(1))));return Cce(()=>{const s=i.get();s.length&&(e(s),i.reset())},[t]),i}function Tce(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const uP=C.createContext(null);function Ace({children:e}){const t=Sn(),n=C.useCallback(c=>{const{nodes:u=[],setNodes:f,hasDefaultNodes:m,onNodesChange:p,nodeLookup:y,fitViewQueued:b,onNodesChangeMiddlewareMap:x}=t.getState();let w=u;for(const v of c)w=typeof v=="function"?v(w):v;let E=lA({items:w,lookup:y});for(const v of x.values())E=v(E);m&&f(w),E.length>0?p==null||p(E):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:_,setNodes:k}=t.getState();v&&k(_)})},[]),i=dA(n),s=C.useCallback(c=>{const{edges:u=[],setEdges:f,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:y}=t.getState();let b=u;for(const x of c)b=typeof x=="function"?x(b):x;m?f(b):p&&p(lA({items:b,lookup:y}))},[]),a=dA(s),o=C.useMemo(()=>({nodeQueue:i,edgeQueue:a}),[]);return d.jsx(uP.Provider,{value:o,children:e})}function jce(){const e=C.useContext(uP);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Mce=e=>!!e.panZoom;function gg(){const e=Sce(),t=Sn(),n=jce(),i=Ft(Mce),s=C.useMemo(()=>{const a=p=>t.getState().nodeLookup.get(p),o=p=>{n.nodeQueue.push(p)},c=p=>{n.edgeQueue.push(p)},u=p=>{var v,_;const{nodeLookup:y,nodeOrigin:b}=t.getState(),x=uA(p)?p:y.get(p.id),w=x.parentId?DI(x.position,x.measured,x.parentId,y,b):x.position,E={...x,position:w,width:((v=x.measured)==null?void 0:v.width)??x.width,height:((_=x.measured)==null?void 0:_.height)??x.height};return Wd(E)},f=(p,y,b={replace:!1})=>{o(x=>x.map(w=>{if(w.id===p){const E=typeof y=="function"?y(w):y;return b.replace&&uA(E)?E:{...w,...E}}return w}))},m=(p,y,b={replace:!1})=>{c(x=>x.map(w=>{if(w.id===p){const E=typeof y=="function"?y(w):y;return b.replace&&_ce(E)?E:{...w,...E}}return w}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var y;return(y=a(p))==null?void 0:y.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(y=>({...y}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:o,setEdges:c,addNodes:p=>{const y=Array.isArray(p)?p:[p];n.nodeQueue.push(b=>[...b,...y])},addEdges:p=>{const y=Array.isArray(p)?p:[p];n.edgeQueue.push(b=>[...b,...y])},toObject:()=>{const{nodes:p=[],edges:y=[],transform:b}=t.getState(),[x,w,E]=b;return{nodes:p.map(v=>({...v})),edges:y.map(v=>({...v})),viewport:{x,y:w,zoom:E}}},deleteElements:async({nodes:p=[],edges:y=[]})=>{const{nodes:b,edges:x,onNodesDelete:w,onEdgesDelete:E,triggerNodeChanges:v,triggerEdgeChanges:_,onDelete:k,onBeforeDelete:T}=t.getState(),{nodes:A,edges:j}=await tle({nodesToRemove:p,edgesToRemove:y,nodes:b,edges:x,onBeforeDelete:T}),M=j.length>0,D=A.length>0;if(M){const I=j.map(cA);E==null||E(j),_(I)}if(D){const I=A.map(cA);w==null||w(A),v(I)}return(D||M)&&(k==null||k({nodes:A,edges:j})),{deletedNodes:A,deletedEdges:j}},getIntersectingNodes:(p,y=!0,b)=>{const x=LT(p),w=x?p:u(p),E=b!==void 0;return w?(b||t.getState().nodes).filter(v=>{const _=t.getState().nodeLookup.get(v.id);if(_&&!x&&(v.id===p.id||!_.internals.positionAbsolute))return!1;const k=Wd(E?v:_),T=_m(k,w);return y&&T>0||T>=k.width*k.height||T>=w.width*w.height}):[]},isNodeIntersecting:(p,y,b=!0)=>{const w=LT(p)?p:u(p);if(!w)return!1;const E=_m(w,y);return b&&E>0||E>=y.width*y.height||E>=w.width*w.height},updateNode:f,updateNodeData:(p,y,b={replace:!1})=>{f(p,x=>{const w=typeof y=="function"?y(x):y;return b.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},b)},updateEdge:m,updateEdgeData:(p,y,b={replace:!1})=>{m(p,x=>{const w=typeof y=="function"?y(x):y;return b.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},b)},getNodesBounds:p=>{const{nodeLookup:y,nodeOrigin:b}=t.getState();return Qoe(p,{nodeLookup:y,nodeOrigin:b})},getHandleConnections:({type:p,id:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}-${p}${y?`-${y}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:p,handleId:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}${p?y?`-${p}-${y}`:`-${p}`:""}`))==null?void 0:x.values())??[])},fitView:async p=>{const y=t.getState().fitViewResolver??sle();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:y}),n.nodeQueue.push(b=>[...b]),y.promise}}},[]);return C.useMemo(()=>({...s,...e,viewportInitialized:i}),[i])}const fA=e=>e.selected,Rce=typeof window<"u"?window:void 0;function Dce({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Sn(),{deleteElements:i}=gg(),s=Xd(e,{actInsideInputWithModifier:!1}),a=Xd(t,{target:Rce});C.useEffect(()=>{if(s){const{edges:o,nodes:c}=n.getState();i({nodes:c.filter(fA),edges:o.filter(fA)}),n.setState({nodesSelectionActive:!1})}},[s]),C.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function Oce(e){const t=Sn();C.useEffect(()=>{const n=()=>{var s,a,o,c;if(!e.current||!(((a=(s=e.current).checkVisibility)==null?void 0:a.call(s))??!0))return!1;const i=kw(e.current);(i.height===0||i.width===0)&&((c=(o=t.getState()).onError)==null||c.call(o,"004",as.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const yg={position:"absolute",width:"100%",height:"100%",top:0,left:0},Lce=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Ice({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Jo.Free,zoomOnDoubleClick:o=!0,panOnDrag:c=!0,defaultViewport:u,translateExtent:f,minZoom:m,maxZoom:p,zoomActivationKeyCode:y,preventScrolling:b=!0,children:x,noWheelClassName:w,noPanClassName:E,onViewportChange:v,isControlledViewport:_,paneClickDistance:k,selectionOnDrag:T}){const A=Sn(),j=C.useRef(null),{userSelectionActive:M,lib:D,connectionInProgress:I}=Ft(Lce,En),P=Xd(y),U=C.useRef();Oce(j);const q=C.useCallback(V=>{v==null||v({x:V[0],y:V[1],zoom:V[2]}),_||A.setState({transform:V})},[v,_]);return C.useEffect(()=>{if(j.current){U.current=Fle({domNode:j.current,minZoom:m,maxZoom:p,translateExtent:f,viewport:u,onDraggingChange:z=>A.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Y,onMoveStart:K}=A.getState();K==null||K(z,G),Y==null||Y(G)},onPanZoom:(z,G)=>{const{onViewportChange:Y,onMove:K}=A.getState();K==null||K(z,G),Y==null||Y(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Y,onMoveEnd:K}=A.getState();K==null||K(z,G),Y==null||Y(G)}});const{x:V,y:O,zoom:R}=U.current.getViewport();return A.setState({panZoom:U.current,transform:[V,O,R],domNode:j.current.closest(".react-flow")}),()=>{var z;(z=U.current)==null||z.destroy()}}},[]),C.useEffect(()=>{var V;(V=U.current)==null||V.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:c,zoomActivationKeyPressed:P,preventScrolling:b,noPanClassName:E,userSelectionActive:M,noWheelClassName:w,lib:D,onTransformChange:q,connectionInProgress:I,selectionOnDrag:T,paneClickDistance:k})},[e,t,n,i,s,a,o,c,P,b,E,M,w,D,q,I,T,k]),d.jsx("div",{className:"react-flow__renderer",ref:j,style:yg,children:x})}const Pce=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function zce(){const{userSelectionActive:e,userSelectionRect:t}=Ft(Pce,En);return e&&t?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Hx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Bce=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Uce({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Gd.Full,panOnDrag:i,autoPanOnSelection:s,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:m,onPaneScroll:p,onPaneMouseEnter:y,onPaneMouseMove:b,onPaneMouseLeave:x,children:w}){const E=C.useRef(0),v=Sn(),{userSelectionActive:_,elementsSelectable:k,dragging:T,panBy:A,autoPanSpeed:j}=Ft(Bce,En),M=k&&(e||_),D=C.useRef(null),I=C.useRef(),P=C.useRef(new Set),U=C.useRef(new Set),q=C.useRef(!1),V=C.useRef(!1),O=C.useRef({x:0,y:0}),R=C.useRef(!1),z=re=>{if(V.current||q.current||v.getState().connection.inProgress){V.current=!1,q.current=!1;return}f==null||f(re),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},G=re=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){re.preventDefault();return}m==null||m(re)},Y=p?re=>p(re):void 0,K=re=>{V.current&&(re.stopPropagation(),V.current=!1)},B=re=>{var Re,Qe;const{domNode:me,transform:se}=v.getState();if(I.current=me==null?void 0:me.getBoundingClientRect(),!I.current)return;const Q=re.target===D.current;if(!Q&&!!re.target.closest(".nokey")||!e||!(o&&Q||t)||re.button!==0||!re.isPrimary)return;(Qe=(Re=re.target)==null?void 0:Re.setPointerCapture)==null||Qe.call(Re,re.pointerId),V.current=!1;const{x:ze,y:fe}=Us(re.nativeEvent,I.current),Se=_f({x:ze,y:fe},se);v.setState({userSelectionRect:{width:0,height:0,startX:Se.x,startY:Se.y,x:ze,y:fe}}),Q||(re.stopPropagation(),re.preventDefault())};function F(re,me){const{userSelectionRect:se}=v.getState();if(!se)return;const{transform:Q,nodeLookup:ye,edgeLookup:_e,connectionLookup:ze,triggerNodeChanges:fe,triggerEdgeChanges:Se,defaultEdgeOptions:Re}=v.getState(),Qe={x:se.startX,y:se.startY},{x:ht,y:it}=Fc(Qe,Q),Bt={startX:Qe.x,startY:Qe.y,x:re<ht?re:ht,y:me<it?me:it,width:Math.abs(re-ht),height:Math.abs(me-it)},mt=P.current,wt=U.current;P.current=new Set(ww(ye,Bt,Q,n===Gd.Partial,!0).map(ct=>ct.id)),U.current=new Set;const Te=(Re==null?void 0:Re.selectable)??!0;for(const ct of P.current){const ne=ze.get(ct);if(ne)for(const{edgeId:we}of ne.values()){const he=_e.get(we);he&&(he.selectable??Te)&&U.current.add(we)}}if(!IT(mt,P.current)){const ct=uc(ye,P.current,!0);fe(ct)}if(!IT(wt,U.current)){const ct=uc(_e,U.current);Se(ct)}v.setState({userSelectionRect:Bt,userSelectionActive:!0,nodesSelectionActive:!1})}function W(){if(!s||!I.current)return;const[re,me]=Ew(O.current,I.current,j);A({x:re,y:me}).then(se=>{if(!V.current||!se){E.current=requestAnimationFrame(W);return}const{x:Q,y:ye}=O.current;F(Q,ye),E.current=requestAnimationFrame(W)})}const $=()=>{cancelAnimationFrame(E.current),E.current=0,R.current=!1};C.useEffect(()=>()=>$(),[]);const ae=re=>{const{userSelectionRect:me,transform:se,resetSelectedElements:Q}=v.getState();if(!I.current||!me)return;const{x:ye,y:_e}=Us(re.nativeEvent,I.current);O.current={x:ye,y:_e};const ze=Fc({x:me.startX,y:me.startY},se);if(!V.current){const fe=t?0:a;if(Math.hypot(ye-ze.x,_e-ze.y)<=fe)return;Q(),c==null||c(re)}V.current=!0,R.current||(W(),R.current=!0),F(ye,_e)},be=re=>{var me,se;if(!M){re.target===D.current&&v.getState().connection.inProgress&&(q.current=!0);return}re.button===0&&((se=(me=re.target)==null?void 0:me.releasePointerCapture)==null||se.call(me,re.pointerId),!_&&re.target===D.current&&v.getState().userSelectionRect&&(z==null||z(re)),v.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(u==null||u(re),v.setState({nodesSelectionActive:P.current.size>0})),$())},le=re=>{var me,se;(se=(me=re.target)==null?void 0:me.releasePointerCapture)==null||se.call(me,re.pointerId),$()},Ne=i===!0||Array.isArray(i)&&i.includes(0);return d.jsxs("div",{className:Wn(["react-flow__pane",{draggable:Ne,dragging:T,selection:e}]),onClick:M?void 0:Hx(z,D),onContextMenu:Hx(G,D),onWheel:Hx(Y,D),onPointerEnter:M?void 0:y,onPointerMove:M?ae:b,onPointerUp:be,onPointerCancel:M?le:void 0,onPointerDownCapture:M?B:void 0,onClickCapture:M?K:void 0,onPointerLeave:x,ref:D,style:yg,children:[w,d.jsx(zce,{})]})}function _v({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:c,onError:u}=t.getState(),f=c.get(e);if(!f){u==null||u("012",as.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&o)&&(a({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):s([e])}function dP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:s,isSelectable:a,nodeClickDistance:o}){const c=Sn(),[u,f]=C.useState(!1),m=C.useRef();return C.useEffect(()=>{m.current=Cle({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{_v({id:p,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),C.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:o}),()=>{var p;(p=m.current)==null||p.destroy()}},[n,i,t,a,e,s,o]),u}const Fce=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function fP(){const e=Sn();return C.useCallback(n=>{const{nodeExtent:i,snapToGrid:s,snapGrid:a,nodesDraggable:o,onError:c,updateNodePositions:u,nodeLookup:f,nodeOrigin:m}=e.getState(),p=new Map,y=Fce(o),b=s?a[0]:5,x=s?a[1]:5,w=n.direction.x*b*n.factor,E=n.direction.y*x*n.factor;for(const[,v]of f){if(!y(v))continue;let _={x:v.internals.positionAbsolute.x+w,y:v.internals.positionAbsolute.y+E};s&&(_=Nf(_,a));const{position:k,positionAbsolute:T}=CI({nodeId:v.id,nextPosition:_,nodeLookup:f,nodeExtent:i,nodeOrigin:m,onError:c});v.position=k,v.internals.positionAbsolute=T,p.set(v.id,v)}u(p)},[])}const jw=C.createContext(null),$ce=jw.Provider;jw.Consumer;const hP=()=>C.useContext(jw),qce=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),pP=C.createContext(null);function Hce({children:e}){const t=Ft(qce,En);return d.jsx(pP.Provider,{value:t,children:e})}function Vce(){const e=C.useContext(pP);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Kce={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Gce=(e,t,n)=>i=>{const{connectionClickStartHandle:s,connectionMode:a,connection:o}=i,{fromHandle:c,toHandle:u,isValid:f}=o;if(!c&&!s)return Kce;const m=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:m,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:a===Bc.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!s,valid:m&&f}};function Wce({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:o,onConnect:c,children:u,className:f,onMouseDown:m,onTouchStart:p,...y},b){var R,z;const x=o||null,w=e==="target",E=Sn(),v=hP(),{connectOnClick:_,noPanClassName:k,rfId:T}=Vce(),{connectingFrom:A,connectingTo:j,clickConnecting:M,isPossibleEndHandle:D,connectionInProcess:I,clickConnectionInProcess:P,valid:U}=Ft(Gce(v,x,e),En);v||(z=(R=E.getState()).onError)==null||z.call(R,"010",as.error010());const q=G=>{const{defaultEdgeOptions:Y,onConnect:K,hasDefaultEdges:B}=E.getState(),F={...Y,...G};if(B){const{edges:W,setEdges:$,onError:ae}=E.getState();$(lP(F,W,{onError:ae}))}K==null||K(F),c==null||c(F)},V=G=>{if(!v)return;const Y=II(G.nativeEvent);if(s&&(Y&&G.button===0||!Y)){const K=E.getState();Nv.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:w,handleId:x,nodeId:v,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...B)=>{var F,W;return(W=(F=E.getState()).onConnectEnd)==null?void 0:W.call(F,...B)},updateConnection:K.updateConnection,onConnect:q,isValidConnection:n||((...B)=>{var F,W;return((W=(F=E.getState()).isValidConnection)==null?void 0:W.call(F,...B))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Y?m==null||m(G):p==null||p(G)},O=G=>{const{onClickConnectStart:Y,onClickConnectEnd:K,connectionClickStartHandle:B,connectionMode:F,isValidConnection:W,lib:$,rfId:ae,nodeLookup:be,connection:le}=E.getState();if(!v||!B&&!s)return;if(!B){Y==null||Y(G.nativeEvent,{nodeId:v,handleId:x,handleType:e}),E.setState({connectionClickStartHandle:{nodeId:v,type:e,id:x}});return}const Ne=OI(G.target),re=n||W,{connection:me,isValid:se}=Nv.isValid(G.nativeEvent,{handle:{nodeId:v,id:x,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:re,flowId:ae,doc:Ne,lib:$,nodeLookup:be});se&&me&&q(me);const Q=structuredClone(le);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,K==null||K(G,Q),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":x,"data-nodeid":v,"data-handlepos":t,"data-id":`${T}-${v}-${x}-${e}`,className:Wn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,f,{source:!w,target:w,connectable:i,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:A,connectingto:j,valid:U,connectionindicator:i&&(!I||D)&&(I||P?a:s)}]),onMouseDown:V,onTouchStart:V,onClick:_?O:void 0,ref:b,...y,children:u})}const Za=C.memo(cP(Wce));function Yce({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(Za,{type:"source",position:n,isConnectable:t})]})}function Xce({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:i=Je.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(Za,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,d.jsx(Za,{type:"source",position:i,isConnectable:t})]})}function Qce(){return null}function Zce({data:e,isConnectable:t,targetPosition:n=Je.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(Za,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Cm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hA={input:Yce,default:Xce,output:Zce,group:Qce};function Jce(e){var t,n,i,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const eue=e=>{const{width:t,height:n,x:i,y:s}=kf(e.nodeLookup,{filter:a=>!!a.selected});return{width:Bs(t)?t:null,height:Bs(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${s}px)`}};function tue({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=Sn(),{width:s,height:a,transformString:o,userSelectionActive:c}=Ft(eue,En),u=fP(),f=C.useRef(null);C.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const m=!c&&s!==null&&a!==null;if(dP({nodeRef:f,disabled:!m}),!m)return null;const p=e?b=>{const x=i.getState().nodes.filter(w=>w.selected);e(b,x)}:void 0,y=b=>{Object.prototype.hasOwnProperty.call(Cm,b.key)&&(b.preventDefault(),u({direction:Cm[b.key],factor:b.shiftKey?4:1}))};return d.jsx("div",{className:Wn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:d.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:y,style:{width:s,height:a}})})}const pA=typeof window<"u"?window:void 0,nue=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function mP({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:x,panActivationKeyCode:w,zoomActivationKeyCode:E,elementsSelectable:v,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:D,autoPanOnSelection:I,defaultViewport:P,translateExtent:U,minZoom:q,maxZoom:V,preventScrolling:O,onSelectionContextMenu:R,noWheelClassName:z,noPanClassName:G,disableKeyboardA11y:Y,onViewportChange:K,isControlledViewport:B}){const{nodesSelectionActive:F,userSelectionActive:W}=Ft(nue,En),$=Xd(f,{target:pA}),ae=Xd(w,{target:pA}),be=ae||D,le=ae||T,Ne=m&&be!==!0,re=$||W||Ne;return Dce({deleteKeyCode:u,multiSelectionKeyCode:x}),d.jsx(Ice,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:le,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:!$&&be,defaultViewport:P,translateExtent:U,minZoom:q,maxZoom:V,zoomActivationKeyCode:E,preventScrolling:O,noWheelClassName:z,noPanClassName:G,onViewportChange:K,isControlledViewport:B,paneClickDistance:c,selectionOnDrag:Ne,children:d.jsxs(Uce,{onSelectionStart:y,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:be,autoPanOnSelection:I,isSelecting:!!re,selectionMode:p,selectionKeyPressed:$,paneClickDistance:c,selectionOnDrag:Ne,children:[e,F&&d.jsx(tue,{onSelectionContextMenu:R,noPanClassName:G,disableKeyboardA11y:Y})]})})}mP.displayName="FlowRenderer";const iue=C.memo(mP),sue=e=>t=>e?ww(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function rue(e){return Ft(C.useCallback(sue(e),[e]),En)}const aue=e=>e.updateNodeInternals;function oue(){const e=Ft(aue),[t]=C.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");i.set(a,{id:a,nodeElement:s.target,force:!0})}),e(i)}));return C.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function lue({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const s=Sn(),a=C.useRef(null),o=C.useRef(null),c=C.useRef(e.sourcePosition),u=C.useRef(e.targetPosition),f=C.useRef(t),m=n&&!!e.internals.handleBounds;return C.useEffect(()=>{a.current&&!e.hidden&&(!m||o.current!==a.current)&&(o.current&&(i==null||i.unobserve(o.current)),i==null||i.observe(a.current),o.current=a.current)},[m,e.hidden]),C.useEffect(()=>()=>{o.current&&(i==null||i.unobserve(o.current),o.current=null)},[]),C.useEffect(()=>{if(a.current){const p=f.current!==t,y=c.current!==e.sourcePosition,b=u.current!==e.targetPosition;(p||y||b)&&(f.current=t,c.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function cue({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:s,onContextMenu:a,onDoubleClick:o,nodesDraggable:c,elementsSelectable:u,nodesConnectable:f,nodesFocusable:m,resizeObserver:p,noDragClassName:y,noPanClassName:b,disableKeyboardA11y:x,rfId:w,nodeTypes:E,nodeClickDistance:v,onError:_}){const{node:k,internals:T,isParent:A}=Ft(re=>{const me=re.nodeLookup.get(e),se=re.parentLookup.has(e);return{node:me,internals:me.internals,isParent:se}},En);let j=k.type||"default",M=(E==null?void 0:E[j])||hA[j];M===void 0&&(_==null||_("003",as.error003(j)),j="default",M=(E==null?void 0:E.default)||hA.default);const D=!!(k.draggable||c&&typeof k.draggable>"u"),I=!!(k.selectable||u&&typeof k.selectable>"u"),P=!!(k.connectable||f&&typeof k.connectable>"u"),U=!!(k.focusable||m&&typeof k.focusable>"u"),q=Sn(),V=RI(k),O=lue({node:k,nodeType:j,hasDimensions:V,resizeObserver:p}),R=dP({nodeRef:O,disabled:k.hidden||!D,noDragClassName:y,handleSelector:k.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:v}),z=fP();if(k.hidden)return null;const G=ia(k),Y=Jce(k),K=I||D||t||n||i||s,B=n?re=>n(re,{...T.userNode}):void 0,F=i?re=>i(re,{...T.userNode}):void 0,W=s?re=>s(re,{...T.userNode}):void 0,$=a?re=>a(re,{...T.userNode}):void 0,ae=o?re=>o(re,{...T.userNode}):void 0,be=re=>{const{selectNodesOnDrag:me,nodeDragThreshold:se}=q.getState();I&&(!me||!D||se>0)&&_v({id:e,store:q,nodeRef:O}),t&&t(re,{...T.userNode})},le=re=>{if(!(LI(re.nativeEvent)||x)){if(EI.includes(re.key)&&I){const me=re.key==="Escape";_v({id:e,store:q,unselect:me,nodeRef:O})}else if(D&&k.selected&&Object.prototype.hasOwnProperty.call(Cm,re.key)){re.preventDefault();const{ariaLabelConfig:me}=q.getState();q.setState({ariaLiveMessage:me["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:Cm[re.key],factor:re.shiftKey?4:1})}}},Ne=()=>{var ze;if(x||!((ze=O.current)!=null&&ze.matches(":focus-visible")))return;const{transform:re,width:me,height:se,autoPanOnNodeFocus:Q,setCenter:ye}=q.getState();if(!Q)return;ww(new Map([[e,k]]),{x:0,y:0,width:me,height:se},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return d.jsx("div",{className:Wn(["react-flow__node",`react-flow__node-${j}`,{[b]:D},k.className,{selected:k.selected,selectable:I,parent:A,draggable:D,dragging:R}]),ref:O,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:V?"visible":"hidden",...k.style,...Y},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:F,onMouseLeave:W,onContextMenu:$,onClick:be,onDoubleClick:ae,onKeyDown:U?le:void 0,tabIndex:U?0:void 0,onFocus:U?Ne:void 0,role:k.ariaRole??(U?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${tP}-${w}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx($ce,{value:e,children:d.jsx(M,{id:e,data:k.data,type:j,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:I,draggable:D,deletable:k.deletable??!0,isConnectable:P,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:R,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...G})})})}var uue=C.memo(cue);const due=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function gP(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:s,onError:a}=Ft(due,En),o=rue(e.onlyRenderVisibleElements),c=oue();return d.jsx("div",{className:"react-flow__nodes",style:yg,children:o.map(u=>d.jsx(uue,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},u))})}gP.displayName="NodeRenderer";const fue=C.memo(gP);function hue(e){return Ft(C.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const i=[];if(n.width&&n.height)for(const s of n.edges){const a=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);a&&o&&lle({sourceNode:a,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&i.push(s.id)}return i},[e]),En)}const pue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},mue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},mA={[km.Arrow]:pue,[km.ArrowClosed]:mue};function gue(e){const t=Sn();return C.useMemo(()=>{var s,a;return Object.prototype.hasOwnProperty.call(mA,e)?mA[e]:((a=(s=t.getState()).onError)==null||a.call(s,"009",as.error009(e)),null)},[e])}const yue=({id:e,type:t,color:n,width:i=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:o,orient:c="auto-start-reverse"})=>{const u=gue(t);return u?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:c,refX:"0",refY:"0",children:d.jsx(u,{color:n,strokeWidth:o})}):null},yP=({defaultColor:e,rfId:t})=>{const n=Ft(a=>a.edges),i=Ft(a=>a.defaultEdgeOptions),s=C.useMemo(()=>gle(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return s.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:s.map(a=>d.jsx(yue,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};yP.displayName="MarkerDefinitions";var bue=C.memo(yP);function bP({x:e,y:t,label:n,labelStyle:i,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:c=2,children:u,className:f,...m}){const[p,y]=C.useState({x:1,y:0,width:0,height:0}),b=Wn(["react-flow__edge-textwrapper",f]),x=C.useRef(null);return C.useEffect(()=>{if(x.current){const w=x.current.getBBox();y({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?d.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[s&&d.jsx("rect",{width:p.width+2*o[0],x:-o[0],y:-o[1],height:p.height+2*o[1],className:"react-flow__edge-textbg",style:a,rx:c,ry:c}),d.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:x,style:i,children:n}),u]}):null}bP.displayName="EdgeText";const xue=C.memo(bP);function bg({path:e,labelX:t,labelY:n,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:f=20,...m}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...m,d:e,fill:"none",className:Wn(["react-flow__edge-path",m.className])}),f?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&Bs(t)&&Bs(n)?d.jsx(xue,{x:t,y:n,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function gA({pos:e,x1:t,y1:n,x2:i,y2:s}){return e===Je.Left||e===Je.Right?[.5*(t+i),n]:[t,.5*(n+s)]}function xP({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top}){const[o,c]=gA({pos:n,x1:e,y1:t,x2:i,y2:s}),[u,f]=gA({pos:a,x1:i,y1:s,x2:e,y2:t}),[m,p,y,b]=PI({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${o},${c} ${u},${f} ${i},${s}`,m,p,y,b]}function vP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,sourcePosition:o,targetPosition:c,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:v})=>{const[_,k,T]=xP({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:a,targetPosition:c}),A=e.isInternal?void 0:t;return d.jsx(bg,{id:A,path:_,labelX:k,labelY:T,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:v})})}const vue=vP({isInternal:!1}),wP=vP({isInternal:!0});vue.displayName="SimpleBezierEdge";wP.displayName="SimpleBezierEdgeInternal";function EP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,sourcePosition:b=Je.Bottom,targetPosition:x=Je.Top,markerEnd:w,markerStart:E,pathOptions:v,interactionWidth:_})=>{const[k,T,A]=Ev({sourceX:n,sourceY:i,sourcePosition:b,targetX:s,targetY:a,targetPosition:x,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),j=e.isInternal?void 0:t;return d.jsx(bg,{id:j,path:k,labelX:T,labelY:A,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:w,markerStart:E,interactionWidth:_})})}const SP=EP({isInternal:!1}),kP=EP({isInternal:!0});SP.displayName="SmoothStepEdge";kP.displayName="SmoothStepEdgeInternal";function NP(e){return C.memo(({id:t,...n})=>{var s;const i=e.isInternal?void 0:t;return d.jsx(SP,{...n,id:i,pathOptions:C.useMemo(()=>{var a;return{borderRadius:0,offset:(a=n.pathOptions)==null?void 0:a.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const wue=NP({isInternal:!1}),_P=NP({isInternal:!0});wue.displayName="StepEdge";_P.displayName="StepEdgeInternal";function CP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:b,markerStart:x,interactionWidth:w})=>{const[E,v,_]=FI({sourceX:n,sourceY:i,targetX:s,targetY:a}),k=e.isInternal?void 0:t;return d.jsx(bg,{id:k,path:E,labelX:v,labelY:_,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:b,markerStart:x,interactionWidth:w})})}const Eue=CP({isInternal:!1}),TP=CP({isInternal:!0});Eue.displayName="StraightEdge";TP.displayName="StraightEdgeInternal";function AP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,sourcePosition:o=Je.Bottom,targetPosition:c=Je.Top,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,pathOptions:v,interactionWidth:_})=>{const[k,T,A]=zI({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:a,targetPosition:c,curvature:v==null?void 0:v.curvature}),j=e.isInternal?void 0:t;return d.jsx(bg,{id:j,path:k,labelX:T,labelY:A,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:_})})}const Sue=AP({isInternal:!1}),jP=AP({isInternal:!0});Sue.displayName="BezierEdge";jP.displayName="BezierEdgeInternal";const yA={default:jP,straight:TP,step:_P,smoothstep:kP,simplebezier:wP},bA={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},kue=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,Nue=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,xA="react-flow__edgeupdater";function vA({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:s,onMouseEnter:a,onMouseOut:o,type:c}){return d.jsx("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:o,className:Wn([xA,`${xA}-${c}`]),cx:kue(t,i,e),cy:Nue(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function _ue({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:s,targetX:a,targetY:o,sourcePosition:c,targetPosition:u,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,setReconnecting:y,setUpdateHover:b}){const x=Sn(),w=(T,A)=>{if(T.button!==0)return;const{autoPanOnConnect:j,domNode:M,connectionMode:D,connectionRadius:I,lib:P,onConnectStart:U,cancelConnection:q,nodeLookup:V,rfId:O,panBy:R,updateConnection:z}=x.getState(),G=A.type==="target",Y=(F,W)=>{y(!1),p==null||p(F,n,A.type,W)},K=F=>f==null?void 0:f(n,F),B=(F,W)=>{y(!0),m==null||m(T,n,A.type),U==null||U(F,W)};Nv.onPointerDown(T.nativeEvent,{autoPanOnConnect:j,connectionMode:D,connectionRadius:I,domNode:M,handleId:A.id,nodeId:A.nodeId,nodeLookup:V,isTarget:G,edgeUpdaterType:A.type,lib:P,flowId:O,cancelConnection:q,panBy:R,isValidConnection:(...F)=>{var W,$;return(($=(W=x.getState()).isValidConnection)==null?void 0:$.call(W,...F))??!0},onConnect:K,onConnectStart:B,onConnectEnd:(...F)=>{var W,$;return($=(W=x.getState()).onConnectEnd)==null?void 0:$.call(W,...F)},onReconnectEnd:Y,updateConnection:z,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},E=T=>w(T,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=T=>w(T,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),_=()=>b(!0),k=()=>b(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(vA,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:E,onMouseEnter:_,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&d.jsx(vA,{position:u,centerX:a,centerY:o,radius:t,onMouseDown:v,onMouseEnter:_,onMouseOut:k,type:"target"})]})}function Cue({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:s,onDoubleClick:a,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,reconnectRadius:m,onReconnect:p,onReconnectStart:y,onReconnectEnd:b,rfId:x,edgeTypes:w,noPanClassName:E,onError:v,disableKeyboardA11y:_}){let k=Ft(ye=>ye.edgeLookup.get(e));const T=Ft(ye=>ye.defaultEdgeOptions);k=T?{...T,...k}:k;let A=k.type||"default",j=(w==null?void 0:w[A])||yA[A];j===void 0&&(v==null||v("011",as.error011(A)),A="default",j=(w==null?void 0:w.default)||yA.default);const M=!!(k.focusable||t&&typeof k.focusable>"u"),D=typeof p<"u"&&(k.reconnectable||n&&typeof k.reconnectable>"u"),I=!!(k.selectable||i&&typeof k.selectable>"u"),P=C.useRef(null),[U,q]=C.useState(!1),[V,O]=C.useState(!1),R=Sn(),{zIndex:z=k.zIndex,sourceX:G,sourceY:Y,targetX:K,targetY:B,sourcePosition:F,targetPosition:W}=Ft(C.useCallback(ye=>{const _e=ye.nodeLookup.get(k.source),ze=ye.nodeLookup.get(k.target);if(!_e||!ze)return bA;const fe=mle({id:e,sourceNode:_e,targetNode:ze,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:v}),Se=ole({selected:k.selected,zIndex:k.zIndex,sourceNode:_e,targetNode:ze,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode});return{...fe||bA,zIndex:Se}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),En),$=C.useMemo(()=>k.markerStart?`url('#${Sv(k.markerStart,x)}')`:void 0,[k.markerStart,x]),ae=C.useMemo(()=>k.markerEnd?`url('#${Sv(k.markerEnd,x)}')`:void 0,[k.markerEnd,x]);if(k.hidden||G===null||Y===null||K===null||B===null)return null;const be=ye=>{var Se;const{addSelectedEdges:_e,unselectNodesAndEdges:ze,multiSelectionActive:fe}=R.getState();I&&(R.setState({nodesSelectionActive:!1}),k.selected&&fe?(ze({nodes:[],edges:[k]}),(Se=P.current)==null||Se.blur()):_e([e])),s&&s(ye,k)},le=a?ye=>{a(ye,{...k})}:void 0,Ne=o?ye=>{o(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,me=u?ye=>{u(ye,{...k})}:void 0,se=f?ye=>{f(ye,{...k})}:void 0,Q=ye=>{var _e;if(!_&&EI.includes(ye.key)&&I){const{unselectNodesAndEdges:ze,addSelectedEdges:fe}=R.getState();ye.key==="Escape"?((_e=P.current)==null||_e.blur(),ze({edges:[k]})):fe([e])}};return d.jsx("svg",{style:{zIndex:z},children:d.jsxs("g",{className:Wn(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!I&&!s,updating:U,selectable:I}]),onClick:be,onDoubleClick:le,onContextMenu:Ne,onMouseEnter:re,onMouseMove:me,onMouseLeave:se,onKeyDown:M?Q:void 0,tabIndex:M?0:void 0,role:k.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":M?`${nP}-${x}`:void 0,ref:P,...k.domAttributes,children:[!V&&d.jsx(j,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:I,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Y,targetX:K,targetY:B,sourcePosition:F,targetPosition:W,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:$,markerEnd:ae,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),D&&d.jsx(_ue,{edge:k,isReconnectable:D,reconnectRadius:m,onReconnect:p,onReconnectStart:y,onReconnectEnd:b,sourceX:G,sourceY:Y,targetX:K,targetY:B,sourcePosition:F,targetPosition:W,setUpdateHover:q,setReconnecting:O})]})})}var Tue=C.memo(Cue);const Aue=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function MP({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:s,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:f,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,disableKeyboardA11y:w}){const{edgesFocusable:E,edgesReconnectable:v,elementsSelectable:_,onError:k}=Ft(Aue,En),T=hue(t);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(bue,{defaultColor:e,rfId:n}),T.map(A=>d.jsx(Tue,{id:A,edgesFocusable:E,edgesReconnectable:v,elementsSelectable:_,noPanClassName:s,onReconnect:a,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,onClick:m,reconnectRadius:p,onDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,rfId:n,onError:k,edgeTypes:i,disableKeyboardA11y:w},A))]})}MP.displayName="EdgeRenderer";const jue=C.memo(MP),Mue=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Rue({children:e}){const t=Ft(Mue);return d.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Due(e){const t=gg(),n=C.useRef(!1);C.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Oue=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Lue(e){const t=Ft(Oue),n=Sn();return C.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Iue(e){return e.connection.inProgress?{...e.connection,to:_f(e.connection.to,e.transform)}:{...e.connection}}function Pue(e){return Iue}function zue(e){const t=Pue();return Ft(t,En)}const Bue=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Uue({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:s,width:a,height:o,isValid:c,inProgress:u}=Ft(Bue,En);return!(a&&s&&u)?null:d.jsx("svg",{style:e,width:a,height:o,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:Wn(["react-flow__connection",NI(c)]),children:d.jsx(RP,{style:t,type:n,CustomComponent:i,isValid:c})})})}const RP=({style:e,type:t=Fa.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:s,from:a,fromNode:o,fromHandle:c,fromPosition:u,to:f,toNode:m,toHandle:p,toPosition:y,pointer:b}=zue();if(!s)return;if(n)return d.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:c,fromX:a.x,fromY:a.y,toX:f.x,toY:f.y,fromPosition:u,toPosition:y,connectionStatus:NI(i),toNode:m,toHandle:p,pointer:b});let x="";const w={sourceX:a.x,sourceY:a.y,sourcePosition:u,targetX:f.x,targetY:f.y,targetPosition:y};switch(t){case Fa.Bezier:[x]=zI(w);break;case Fa.SimpleBezier:[x]=xP(w);break;case Fa.Step:[x]=Ev({...w,borderRadius:0});break;case Fa.SmoothStep:[x]=Ev(w);break;default:[x]=FI(w)}return d.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};RP.displayName="ConnectionLine";const Fue={};function wA(e=Fue){C.useRef(e),Sn(),C.useEffect(()=>{},[e])}function $ue(){Sn(),C.useRef(!1),C.useEffect(()=>{},[])}function DP({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:y,onSelectionEnd:b,connectionLineType:x,connectionLineStyle:w,connectionLineComponent:E,connectionLineContainerStyle:v,selectionKeyCode:_,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,deleteKeyCode:D,onlyRenderVisibleElements:I,elementsSelectable:P,defaultViewport:U,translateExtent:q,minZoom:V,maxZoom:O,preventScrolling:R,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Y,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:F,zoomOnDoubleClick:W,panOnDrag:$,autoPanOnSelection:ae,onPaneClick:be,onPaneMouseEnter:le,onPaneMouseMove:Ne,onPaneMouseLeave:re,onPaneScroll:me,onPaneContextMenu:se,paneClickDistance:Q,nodeClickDistance:ye,onEdgeContextMenu:_e,onEdgeMouseEnter:ze,onEdgeMouseMove:fe,onEdgeMouseLeave:Se,reconnectRadius:Re,onReconnect:Qe,onReconnectStart:ht,onReconnectEnd:it,noDragClassName:Bt,noWheelClassName:mt,noPanClassName:wt,disableKeyboardA11y:Te,nodeExtent:ct,rfId:ne,viewport:we,onViewportChange:he}){return wA(e),wA(t),$ue(),Due(n),Lue(we),d.jsx(iue,{onPaneClick:be,onPaneMouseEnter:le,onPaneMouseMove:Ne,onPaneMouseLeave:re,onPaneContextMenu:se,onPaneScroll:me,paneClickDistance:Q,deleteKeyCode:D,selectionKeyCode:_,selectionOnDrag:k,selectionMode:T,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,elementsSelectable:P,zoomOnScroll:G,zoomOnPinch:Y,zoomOnDoubleClick:W,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:F,panOnDrag:$,autoPanOnSelection:ae,defaultViewport:U,translateExtent:q,minZoom:V,maxZoom:O,onSelectionContextMenu:p,preventScrolling:R,noDragClassName:Bt,noWheelClassName:mt,noPanClassName:wt,disableKeyboardA11y:Te,onViewportChange:he,isControlledViewport:!!we,children:d.jsxs(Rue,{children:[d.jsx(jue,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:Qe,onReconnectStart:ht,onReconnectEnd:it,onlyRenderVisibleElements:I,onEdgeContextMenu:_e,onEdgeMouseEnter:ze,onEdgeMouseMove:fe,onEdgeMouseLeave:Se,reconnectRadius:Re,defaultMarkerColor:z,noPanClassName:wt,disableKeyboardA11y:Te,rfId:ne}),d.jsx(Uue,{style:w,type:x,component:E,containerStyle:v}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(fue,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:m,nodeClickDistance:ye,onlyRenderVisibleElements:I,noPanClassName:wt,noDragClassName:Bt,disableKeyboardA11y:Te,nodeExtent:ct,rfId:ne}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}DP.displayName="GraphView";const que=C.memo(DP),Hue=MI(),EA=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u=.5,maxZoom:f=2,nodeOrigin:m,nodeExtent:p,zIndexMode:y="basic"}={})=>{const b=new Map,x=new Map,w=new Map,E=new Map,v=i??t??[],_=n??e??[],k=m??[0,0],T=p??Kd;HI(w,E,v);const{nodesInitialized:A}=kv(_,b,x,{nodeOrigin:k,nodeExtent:T,zIndexMode:y});let j=[0,0,1];if(o&&s&&a){const M=kf(b,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:D,y:I,zoom:P}=Sw(M,s,a,u,f,(c==null?void 0:c.padding)??.1);j=[D,I,P]}return{rfId:"1",width:s??0,height:a??0,transform:j,nodes:_,nodesInitialized:A,nodeLookup:b,parentLookup:x,edges:v,edgeLookup:E,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:u,maxZoom:f,translateExtent:Kd,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Bc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:c,fitViewResolver:null,connection:{...kI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Hue,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:SI,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Vue=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:m,nodeExtent:p,zIndexMode:y})=>sce((b,x)=>{async function w(){const{nodeLookup:E,panZoom:v,fitViewOptions:_,fitViewResolver:k,width:T,height:A,minZoom:j,maxZoom:M}=x();v&&(await ele({nodes:E,width:T,height:A,panZoom:v,minZoom:j,maxZoom:M},_),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...EA({nodes:e,edges:t,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:m,nodeExtent:p,defaultNodes:n,defaultEdges:i,zIndexMode:y}),setNodes:E=>{const{nodeLookup:v,parentLookup:_,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:A,zIndexMode:j,nodesSelectionActive:M}=x(),{nodesInitialized:D,hasSelectedNodes:I}=kv(E,v,_,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:j}),P=M&&I;A&&D?(w(),b({nodes:E,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:P})):b({nodes:E,nodesInitialized:D,nodesSelectionActive:P})},setEdges:E=>{const{connectionLookup:v,edgeLookup:_}=x();HI(v,_,E),b({edges:E})},setDefaultNodesAndEdges:(E,v)=>{if(E){const{setNodes:_}=x();_(E),b({hasDefaultNodes:!0})}if(v){const{setEdges:_}=x();_(v),b({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:v,nodeLookup:_,parentLookup:k,domNode:T,nodeOrigin:A,nodeExtent:j,debug:M,fitViewQueued:D,zIndexMode:I}=x(),{changes:P,updatedInternals:U}=Sle(E,_,k,T,A,j,I);U&&(xle(_,k,{nodeOrigin:A,nodeExtent:j,zIndexMode:I}),D?(w(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(P==null?void 0:P.length)>0&&(M&&console.log("React Flow: trigger node changes",P),v==null||v(P)))},updateNodePositions:(E,v=!1)=>{const _=[];let k=[];const{nodeLookup:T,triggerNodeChanges:A,connection:j,updateConnection:M,onNodesChangeMiddlewareMap:D}=x();for(const[I,P]of E){const U=T.get(I),q=!!(U!=null&&U.expandParent&&(U!=null&&U.parentId)&&(P!=null&&P.position)),V={id:I,type:"position",position:q?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:v};if(U&&j.inProgress&&j.fromNode.id===U.id){const O=ul(U,j.fromHandle,Je.Left,!0);M({...j,from:O})}q&&U.parentId&&_.push({id:I,parentId:U.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),k.push(V)}if(_.length>0){const{parentLookup:I,nodeOrigin:P}=x(),U=Aw(_,T,I,P);k.push(...U)}for(const I of D.values())k=I(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:v,setNodes:_,nodes:k,hasDefaultNodes:T,debug:A}=x();if(E!=null&&E.length){if(T){const j=rP(E,k);_(j)}A&&console.log("React Flow: trigger node changes",E),v==null||v(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:v,setEdges:_,edges:k,hasDefaultEdges:T,debug:A}=x();if(E!=null&&E.length){if(T){const j=aP(E,k);_(j)}A&&console.log("React Flow: trigger edge changes",E),v==null||v(E)}},addSelectedNodes:E=>{const{multiSelectionActive:v,edgeLookup:_,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(v){const j=E.map(M=>Do(M,!0));T(j);return}T(uc(k,new Set([...E]),!0)),A(uc(_))},addSelectedEdges:E=>{const{multiSelectionActive:v,edgeLookup:_,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(v){const j=E.map(M=>Do(M,!0));A(j);return}A(uc(_,new Set([...E]))),T(uc(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:v}={})=>{const{edges:_,nodes:k,nodeLookup:T,triggerNodeChanges:A,triggerEdgeChanges:j}=x(),M=E||k,D=v||_,I=[];for(const U of M){if(!U.selected)continue;const q=T.get(U.id);q&&(q.selected=!1),I.push(Do(U.id,!1))}const P=[];for(const U of D)U.selected&&P.push(Do(U.id,!1));A(I),j(P)},setMinZoom:E=>{const{panZoom:v,maxZoom:_}=x();v==null||v.setScaleExtent([E,_]),b({minZoom:E})},setMaxZoom:E=>{const{panZoom:v,minZoom:_}=x();v==null||v.setScaleExtent([_,E]),b({maxZoom:E})},setTranslateExtent:E=>{var v;(v=x().panZoom)==null||v.setTranslateExtent(E),b({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:v,triggerNodeChanges:_,triggerEdgeChanges:k,elementsSelectable:T}=x();if(!T)return;const A=v.reduce((M,D)=>D.selected?[...M,Do(D.id,!1)]:M,[]),j=E.reduce((M,D)=>D.selected?[...M,Do(D.id,!1)]:M,[]);_(A),k(j)},setNodeExtent:E=>{const{nodes:v,nodeLookup:_,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:A,nodeExtent:j,zIndexMode:M}=x();E[0][0]===j[0][0]&&E[0][1]===j[0][1]&&E[1][0]===j[1][0]&&E[1][1]===j[1][1]||(kv(v,_,k,{nodeOrigin:T,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:M}),b({nodeExtent:E}))},panBy:E=>{const{transform:v,width:_,height:k,panZoom:T,translateExtent:A}=x();return kle({delta:E,panZoom:T,transform:v,translateExtent:A,width:_,height:k})},setCenter:async(E,v,_)=>{const{width:k,height:T,maxZoom:A,panZoom:j}=x();if(!j)return!1;const M=typeof(_==null?void 0:_.zoom)<"u"?_.zoom:A;return await j.setViewport({x:k/2-E*M,y:T/2-v*M,zoom:M},{duration:_==null?void 0:_.duration,ease:_==null?void 0:_.ease,interpolate:_==null?void 0:_.interpolate}),!0},cancelConnection:()=>{b({connection:{...kI}})},updateConnection:E=>{b({connection:E})},reset:()=>b({...EA()})}},Object.is);function OP({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:s,initialHeight:a,initialMinZoom:o,initialMaxZoom:c,initialFitViewOptions:u,fitView:f,nodeOrigin:m,nodeExtent:p,zIndexMode:y,children:b}){const[x]=C.useState(()=>Vue({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:f,minZoom:o,maxZoom:c,fitViewOptions:u,nodeOrigin:m,nodeExtent:p,zIndexMode:y}));return d.jsx(rce,{value:x,children:d.jsx(Ace,{children:d.jsx(Hce,{children:b})})})}function Kue({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:s,width:a,height:o,fitView:c,fitViewOptions:u,minZoom:f,maxZoom:m,nodeOrigin:p,nodeExtent:y,zIndexMode:b}){return C.useContext(pg)?d.jsx(d.Fragment,{children:e}):d.jsx(OP,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:s,initialWidth:a,initialHeight:o,fitView:c,initialFitViewOptions:u,initialMinZoom:f,initialMaxZoom:m,nodeOrigin:p,nodeExtent:y,zIndexMode:b,children:e})}const Gue={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Wue({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:s,nodeTypes:a,edgeTypes:o,onNodeClick:c,onEdgeClick:u,onInit:f,onMove:m,onMoveStart:p,onMoveEnd:y,onConnect:b,onConnectStart:x,onConnectEnd:w,onClickConnectStart:E,onClickConnectEnd:v,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:I,onNodesDelete:P,onEdgesDelete:U,onDelete:q,onSelectionChange:V,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Y,onSelectionEnd:K,onBeforeDelete:B,connectionMode:F,connectionLineType:W=Fa.Bezier,connectionLineStyle:$,connectionLineComponent:ae,connectionLineContainerStyle:be,deleteKeyCode:le="Backspace",selectionKeyCode:Ne="Shift",selectionOnDrag:re=!1,selectionMode:me=Gd.Full,panActivationKeyCode:se="Space",multiSelectionKeyCode:Q=Yd()?"Meta":"Control",zoomActivationKeyCode:ye=Yd()?"Meta":"Control",snapToGrid:_e,snapGrid:ze,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:Se,nodesDraggable:Re,autoPanOnNodeFocus:Qe,nodesConnectable:ht,nodesFocusable:it,nodeOrigin:Bt=iP,edgesFocusable:mt,edgesReconnectable:wt,elementsSelectable:Te=!0,defaultViewport:ct=bce,minZoom:ne=.5,maxZoom:we=2,translateExtent:he=Kd,preventScrolling:Ve=!0,nodeExtent:Ze,defaultMarkerColor:Ct="#b1b1b7",zoomOnScroll:Gt=!0,zoomOnPinch:ce=!0,panOnScroll:pe=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:je=Jo.Free,zoomOnDoubleClick:qe=!0,panOnDrag:st=!0,onPaneClick:Fe,onPaneMouseEnter:et,onPaneMouseMove:Qt,onPaneMouseLeave:Yn,onPaneScroll:Wt,onPaneContextMenu:Z,paneClickDistance:xe=1,nodeClickDistance:Ie=0,children:ut,onReconnect:Yt,onReconnectStart:Tt,onReconnectEnd:$e,onEdgeContextMenu:Ue,onEdgeDoubleClick:ot,onEdgeMouseEnter:hn,onEdgeMouseMove:Zt,onEdgeMouseLeave:Vi,reconnectRadius:Ys=10,onNodesChange:Jn,onEdgesChange:kn,noDragClassName:mn="nodrag",noWheelClassName:An="nowheel",noPanClassName:Ti="nopan",fitView:Xs,fitViewOptions:wr,connectOnClick:Qs,attributionPosition:sa,proOptions:_s,defaultEdgeOptions:Zs,elevateNodesOnSelect:Bn=!0,elevateEdgesOnSelect:Ai=!1,disableKeyboardA11y:In=!1,autoPanOnConnect:ri,autoPanOnNodeDrag:bn,autoPanOnSelection:ra=!0,autoPanSpeed:xi,connectionRadius:hi,isValidConnection:Me,onError:Ge,style:xt,id:Rt,nodeDragThreshold:on,connectionDragThreshold:Un,viewport:ei,onViewportChange:ti,width:Vt,height:ai,colorMode:aa="light",debug:Cs,onScroll:os,ariaLabelConfig:Ts,zIndexMode:Er="basic",...X},Ae){const Oe=Rt||"1",gt=Ece(aa),pt=C.useCallback(ji=>{ji.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),os==null||os(ji)},[os]);return d.jsx("div",{"data-testid":"rf__wrapper",...X,onScroll:pt,style:{...xt,...Gue},ref:Ae,className:Wn(["react-flow",s,gt]),id:Rt,role:"application",children:d.jsxs(Kue,{nodes:e,edges:t,width:Vt,height:ai,fitView:Xs,fitViewOptions:wr,minZoom:ne,maxZoom:we,nodeOrigin:Bt,nodeExtent:Ze,zIndexMode:Er,children:[d.jsx(wce,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:b,onConnectStart:x,onConnectEnd:w,onClickConnectStart:E,onClickConnectEnd:v,nodesDraggable:Re,autoPanOnNodeFocus:Qe,nodesConnectable:ht,nodesFocusable:it,edgesFocusable:mt,edgesReconnectable:wt,elementsSelectable:Te,elevateNodesOnSelect:Bn,elevateEdgesOnSelect:Ai,minZoom:ne,maxZoom:we,nodeExtent:Ze,onNodesChange:Jn,onEdgesChange:kn,snapToGrid:_e,snapGrid:ze,connectionMode:F,translateExtent:he,connectOnClick:Qs,defaultEdgeOptions:Zs,fitView:Xs,fitViewOptions:wr,onNodesDelete:P,onEdgesDelete:U,onDelete:q,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:I,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:y,noPanClassName:Ti,nodeOrigin:Bt,rfId:Oe,autoPanOnConnect:ri,autoPanOnNodeDrag:bn,autoPanSpeed:xi,onError:Ge,connectionRadius:hi,isValidConnection:Me,selectNodesOnDrag:Se,nodeDragThreshold:on,connectionDragThreshold:Un,onBeforeDelete:B,debug:Cs,ariaLabelConfig:Ts,zIndexMode:Er}),d.jsx(que,{onInit:f,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,nodeTypes:a,edgeTypes:o,connectionLineType:W,connectionLineStyle:$,connectionLineComponent:ae,connectionLineContainerStyle:be,selectionKeyCode:Ne,selectionOnDrag:re,selectionMode:me,deleteKeyCode:le,multiSelectionKeyCode:Q,panActivationKeyCode:se,zoomActivationKeyCode:ye,onlyRenderVisibleElements:fe,defaultViewport:ct,translateExtent:he,minZoom:ne,maxZoom:we,preventScrolling:Ve,zoomOnScroll:Gt,zoomOnPinch:ce,zoomOnDoubleClick:qe,panOnScroll:pe,panOnScrollSpeed:Ce,panOnScrollMode:je,panOnDrag:st,autoPanOnSelection:ra,onPaneClick:Fe,onPaneMouseEnter:et,onPaneMouseMove:Qt,onPaneMouseLeave:Yn,onPaneScroll:Wt,onPaneContextMenu:Z,paneClickDistance:xe,nodeClickDistance:Ie,onSelectionContextMenu:G,onSelectionStart:Y,onSelectionEnd:K,onReconnect:Yt,onReconnectStart:Tt,onReconnectEnd:$e,onEdgeContextMenu:Ue,onEdgeDoubleClick:ot,onEdgeMouseEnter:hn,onEdgeMouseMove:Zt,onEdgeMouseLeave:Vi,reconnectRadius:Ys,defaultMarkerColor:Ct,noDragClassName:mn,noWheelClassName:An,noPanClassName:Ti,rfId:Oe,disableKeyboardA11y:In,nodeExtent:Ze,viewport:ei,onViewportChange:ti}),d.jsx(yce,{onSelectionChange:V}),ut,d.jsx(fce,{proOptions:_s,position:sa}),d.jsx(dce,{rfId:Oe,disableKeyboardA11y:In})]})})}var Yue=cP(Wue);function Xue(e){const[t,n]=C.useState(e),i=C.useCallback(s=>n(a=>rP(s,a)),[]);return[t,n,i]}function Que(e){const[t,n]=C.useState(e),i=C.useCallback(s=>n(a=>aP(s,a)),[]);return[t,n,i]}function Zue({dimensions:e,lineWidth:t,variant:n,className:i}){return d.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Wn(["react-flow__background-pattern",n,i])})}function Jue({radius:e,className:t}){return d.jsx("circle",{cx:e,cy:e,r:e,className:Wn(["react-flow__background-pattern","dots",t])})}var Qr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Qr||(Qr={}));const ede={[Qr.Dots]:1,[Qr.Lines]:1,[Qr.Cross]:6},tde=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function LP({id:e,variant:t=Qr.Dots,gap:n=20,size:i,lineWidth:s=1,offset:a=0,color:o,bgColor:c,style:u,className:f,patternClassName:m}){const p=C.useRef(null),{transform:y,patternId:b}=Ft(tde,En),x=i||ede[t],w=t===Qr.Dots,E=t===Qr.Cross,v=Array.isArray(n)?n:[n,n],_=[v[0]*y[2]||1,v[1]*y[2]||1],k=x*y[2],T=Array.isArray(a)?a:[a,a],A=E?[k,k]:_,j=[T[0]*y[2]||1+A[0]/2,T[1]*y[2]||1+A[1]/2],M=`${b}${e||""}`;return d.jsxs("svg",{className:Wn(["react-flow__background",f]),style:{...u,...yg,"--xy-background-color-props":c,"--xy-background-pattern-color-props":o},ref:p,"data-testid":"rf__background",children:[d.jsx("pattern",{id:M,x:y[0]%_[0],y:y[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:w?d.jsx(Jue,{radius:k/2,className:m}):d.jsx(Zue,{dimensions:A,lineWidth:s,variant:t,className:m})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}LP.displayName="Background";const nde=C.memo(LP);function ide(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function sde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function rde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ade(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function ode(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function md({children:e,className:t,...n}){return d.jsx("button",{type:"button",className:Wn(["react-flow__controls-button",t]),...n,children:e})}const lde=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function IP({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:o,onFitView:c,onInteractiveChange:u,className:f,children:m,position:p="bottom-left",orientation:y="vertical","aria-label":b}){const x=Sn(),{isInteractive:w,minZoomReached:E,maxZoomReached:v,ariaLabelConfig:_}=Ft(lde,En),{zoomIn:k,zoomOut:T,fitView:A}=gg(),j=()=>{k(),a==null||a()},M=()=>{T(),o==null||o()},D=()=>{A(s),c==null||c()},I=()=>{x.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),u==null||u(!w)},P=y==="horizontal"?"horizontal":"vertical";return d.jsxs(mg,{className:Wn(["react-flow__controls",P,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??_["controls.ariaLabel"],children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(md,{onClick:j,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:v,children:d.jsx(ide,{})}),d.jsx(md,{onClick:M,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(sde,{})})]}),n&&d.jsx(md,{className:"react-flow__controls-fitview",onClick:D,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:d.jsx(rde,{})}),i&&d.jsx(md,{className:"react-flow__controls-interactive",onClick:I,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:w?d.jsx(ode,{}):d.jsx(ade,{})}),m]})}IP.displayName="Controls";const cde=C.memo(IP);function ude({id:e,x:t,y:n,width:i,height:s,style:a,color:o,strokeColor:c,strokeWidth:u,className:f,borderRadius:m,shapeRendering:p,selected:y,onClick:b}){const{background:x,backgroundColor:w}=a||{},E=o||x||w;return d.jsx("rect",{className:Wn(["react-flow__minimap-node",{selected:y},f]),x:t,y:n,rx:m,ry:m,width:i,height:s,style:{fill:E,stroke:c,strokeWidth:u},shapeRendering:p,onClick:b?v=>b(v,e):void 0})}const dde=C.memo(ude),fde=e=>e.nodes.map(t=>t.id),Vx=e=>e instanceof Function?e:()=>e;function hde({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a=dde,onClick:o}){const c=Ft(fde,En),u=Vx(t),f=Vx(e),m=Vx(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:c.map(y=>d.jsx(mde,{id:y,nodeColorFunc:u,nodeStrokeColorFunc:f,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:s,NodeComponent:a,onClick:o,shapeRendering:p},y))})}function pde({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:c,onClick:u}){const{node:f,x:m,y:p,width:y,height:b}=Ft(x=>{const w=x.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const E=w.internals.userNode,{x:v,y:_}=w.internals.positionAbsolute,{width:k,height:T}=ia(E);return{node:E,x:v,y:_,width:k,height:T}},En);return!f||f.hidden||!RI(f)?null:d.jsx(c,{x:m,y:p,width:y,height:b,style:f.style,selected:!!f.selected,className:i(f),color:t(f),borderRadius:s,strokeColor:n(f),strokeWidth:a,shapeRendering:o,onClick:u,id:f.id})}const mde=C.memo(pde);var gde=C.memo(hde);const yde=200,bde=150,xde=e=>!e.hidden,vde=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?AI(kf(e.nodeLookup,{filter:xde}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},wde="react-flow__minimap-desc";function PP({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:c,bgColor:u,maskColor:f,maskStrokeColor:m,maskStrokeWidth:p,position:y="bottom-right",onClick:b,onNodeClick:x,pannable:w=!1,zoomable:E=!1,ariaLabel:v,inversePan:_,zoomStep:k=1,offsetScale:T=5}){const A=Sn(),j=C.useRef(null),{boundingRect:M,viewBB:D,rfId:I,panZoom:P,translateExtent:U,flowWidth:q,flowHeight:V,ariaLabelConfig:O}=Ft(vde,En),R=(e==null?void 0:e.width)??yde,z=(e==null?void 0:e.height)??bde,G=M.width/R,Y=M.height/z,K=Math.max(G,Y),B=K*R,F=K*z,W=T*K,$=M.x-(B-M.width)/2-W,ae=M.y-(F-M.height)/2-W,be=B+W*2,le=F+W*2,Ne=`${wde}-${I}`,re=C.useRef(0),me=C.useRef();re.current=K,C.useEffect(()=>{if(j.current&&P)return me.current=Dle({domNode:j.current,panZoom:P,getTransform:()=>A.getState().transform,getViewScale:()=>re.current}),()=>{var _e;(_e=me.current)==null||_e.destroy()}},[P]),C.useEffect(()=>{var _e;(_e=me.current)==null||_e.update({translateExtent:U,width:q,height:V,inversePan:_,pannable:w,zoomStep:k,zoomable:E})},[w,E,_,k,U,q,V]);const se=b?_e=>{var Se;const[ze,fe]=((Se=me.current)==null?void 0:Se.pointer(_e))||[0,0];b(_e,{x:ze,y:fe})}:void 0,Q=x?C.useCallback((_e,ze)=>{const fe=A.getState().nodeLookup.get(ze).internals.userNode;x(_e,fe)},[]):void 0,ye=v??O["minimap.ariaLabel"];return d.jsx(mg,{position:y,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:Wn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:R,height:z,viewBox:`${$} ${ae} ${be} ${le}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Ne,ref:j,onClick:se,children:[ye&&d.jsx("title",{id:Ne,children:ye}),d.jsx(gde,{onClick:Q,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:c}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${$-W},${ae-W}h${be+W*2}v${le+W*2}h${-be-W*2}z
|
|
853
853
|
M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}PP.displayName="MiniMap";C.memo(PP);const Ede=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Sde={[$c.Line]:"right",[$c.Handle]:"bottom-right"};function kde({nodeId:e,position:t,variant:n=$c.Handle,className:i,style:s=void 0,children:a,color:o,minWidth:c=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:y,autoScale:b=!0,shouldResize:x,onResizeStart:w,onResize:E,onResizeEnd:v}){const _=hP(),k=typeof e=="string"?e:_,T=Sn(),A=C.useRef(null),j=n===$c.Handle,M=Ft(C.useCallback(Ede(j&&b),[j,b]),En),D=C.useRef(null),I=t??Sde[n];C.useEffect(()=>{if(!(!A.current||!k))return D.current||(D.current=Kle({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:U,transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R,domNode:z}=T.getState();return{nodeLookup:U,transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R,paneDomNode:z}},onChange:(U,q)=>{const{triggerNodeChanges:V,nodeLookup:O,parentLookup:R,nodeOrigin:z}=T.getState(),G=[],Y={x:U.x,y:U.y},K=O.get(k);if(K&&K.expandParent&&K.parentId){const B=K.origin??z,F=U.width??K.measured.width??0,W=U.height??K.measured.height??0,$={id:K.id,parentId:K.parentId,rect:{width:F,height:W,...DI({x:U.x??K.position.x,y:U.y??K.position.y},{width:F,height:W},K.parentId,O,B)}},ae=Aw([$],O,R,z);G.push(...ae),Y.x=U.x?Math.max(B[0]*F,U.x):void 0,Y.y=U.y?Math.max(B[1]*W,U.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const B={id:k,type:"position",position:{...Y}};G.push(B)}if(U.width!==void 0&&U.height!==void 0){const F={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:U.width,height:U.height}};G.push(F)}for(const B of q){const F={...B,type:"position"};G.push(F)}V(G)},onEnd:({width:U,height:q})=>{const V={id:k,type:"dimensions",resizing:!1,dimensions:{width:U,height:q}};T.getState().triggerNodeChanges([V])}})),D.current.update({controlPosition:I,boundaries:{minWidth:c,minHeight:u,maxWidth:f,maxHeight:m},keepAspectRatio:p,resizeDirection:y,onResizeStart:w,onResize:E,onResizeEnd:v,shouldResize:x}),()=>{var U;(U=D.current)==null||U.destroy()}},[I,c,u,f,m,p,w,E,v,x]);const P=I.split("-");return d.jsx("div",{className:Wn(["react-flow__resize-control","nodrag",...P,n,i]),ref:A,style:{...s,scale:M,...o&&{[j?"backgroundColor":"borderColor"]:o}},children:a})}C.memo(kde);function Nde(e){return _t(`/api/projects/${encodeURIComponent(e)}/flow`)}function _de(e,t){return Rm(`/api/projects/${encodeURIComponent(e)}/flow`,t)}const Cv={done:"var(--color-running)",doing:"var(--color-running)",todo:"var(--color-text-subtle)",stuck:"var(--color-crashed)"},SA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-purple)","var(--color-accent-yellow)","var(--color-running-bg)","var(--color-idle-bg)"];function Cde(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return SA[t%SA.length]}const yp={width:9,height:9,background:"var(--color-bg)",border:"1px solid var(--color-border-light)"},Tde=C.memo(function({id:t,data:n,selected:i}){const s=n,a=s.skills.split(",").map(o=>o.trim()).filter(Boolean);return d.jsxs("div",{className:`flow-node-glow${i?" is-selected":""}${s.status==="doing"?" is-running":""}`,children:[d.jsx(Za,{id:"l",type:"target",position:Je.Left,style:yp}),d.jsx(Za,{id:"t",type:"target",position:Je.Top,style:yp}),d.jsxs("div",{className:"rounded-2xl border border-[var(--color-border-light)] bg-[var(--color-bg-soft)] overflow-hidden cursor-pointer flex flex-col",style:{width:260,height:158,boxShadow:"var(--surface-card-border) 0 0 0 1px inset"},children:[d.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border-b border-[var(--color-border-light)]",style:{background:Cde(t)},children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] text-xs font-bold text-[var(--color-text)]",children:["#",s.seq]}),d.jsxs("span",{className:"relative shrink-0 ml-auto flex items-center justify-center w-2.5 h-2.5",title:s.status,children:[s.status==="doing"&&d.jsx("span",{className:"absolute inline-flex w-full h-full rounded-full animate-ping opacity-60",style:{background:Cv.doing}}),d.jsx("span",{className:"relative w-2.5 h-2.5 rounded-full",style:{background:Cv[s.status]??"var(--color-text-subtle)"}})]})]}),d.jsxs("div",{className:"px-2.5 py-2 flex-1 min-h-0 overflow-hidden",children:[d.jsx("p",{className:"text-[13px] font-semibold text-[var(--color-text)] leading-snug line-clamp-3",children:s.title||"任务"}),a.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1 mt-2 max-h-[46px] overflow-hidden",children:a.slice(0,6).map(o=>d.jsx("span",{className:"text-[10px] font-[family-name:var(--font-mono)] px-1.5 py-0.5 rounded bg-[var(--surface-code)] text-[var(--color-text)]",children:o},o))})]})]}),d.jsx(Za,{id:"r",type:"source",position:Je.Right,style:yp}),d.jsx(Za,{id:"b",type:"source",position:Je.Bottom,style:yp})]})});function Ade(e){if(!e)return"";const t=e.split(`
|
|
854
854
|
`),n=t.findIndex(s=>/^##\s+描述\s*$/.test(s));if(n===-1)return"";let i=t.length;for(let s=n+1;s<t.length;s+=1)if(/^##\s+/.test(t[s]??"")){i=s;break}return t.slice(n+1,i).join(`
|
|
855
|
-
`).trim()}function jde(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function Mde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var V;const a=Xe(),[o,c]=C.useState(!0),[u,f]=C.useState(!1),[m,p]=C.useState(""),[y,b]=C.useState(""),[x,w]=C.useState(new Set),[E,v]=C.useState(""),[_,k]=C.useState("todo"),[T,A]=C.useState(null),[j,M]=C.useState(""),D=at({queryKey:["skills-all",e],queryFn:()=>ig(e)}),I=((V=D.data)==null?void 0:V.data)??[];C.useEffect(()=>{const O=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[n]),C.useEffect(()=>{let O=!1;return c(!0),RL(e,t).then(R=>{O||(p(R.title),w(new Set(R.skills??[])),b(Ade(R.body)),v(R.state),k(jde(R.state,R.labels??[])),A(typeof R.order=="number"?R.order:null))}).catch(()=>{}).finally(()=>{O||c(!1)}),()=>{O=!0}},[e,t]);const P=O=>{w(R=>{const z=new Set(R);return z.has(O)?z.delete(O):z.add(O),z})},U=async()=>{M(""),f(!0);try{await gm(e,t,{title:m.trim()||a("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(O){M(O instanceof Error?O.message:String(O)),f(!1)}},q=()=>s(t);return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-4 md:p-6 bg-black/30 overflow-hidden",onClick:n,children:d.jsxs("div",{className:"nb-card w-full max-w-4xl flex flex-col bg-[var(--color-bg)]",style:{maxHeight:"calc(100vh - 48px)"},onClick:O=>O.stopPropagation(),children:[d.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),E&&d.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs px-2 py-0.5 border-2 border-[var(--color-text)] rounded-full font-semibold",children:[d.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block border border-[var(--color-text)]",style:{background:Cv[_]??"gray"}}),E]}),T!=null&&d.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded-full font-semibold",title:a("flow.lane.orderTip"),children:a("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":a("flow.node.close"),type:"button",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),o?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)] py-10 justify-center",children:[d.jsx(lt,{size:16,className:"animate-spin"})," …"]}):d.jsxs(d.Fragment,{children:[j&&d.jsx("div",{className:"text-sm text-[var(--color-crashed)] mb-3",children:j}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-4 overflow-y-auto pr-1 md:grid-cols-[minmax(0,1fr)_minmax(260px,340px)] md:overflow-hidden md:pr-0",children:[d.jsxs("div",{className:"flex min-h-0 flex-col gap-4 md:overflow-y-auto md:pr-1",children:[d.jsxs("label",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:m,onChange:O=>p(O.target.value),autoFocus:!0})]}),d.jsxs("label",{className:"flex flex-1 min-h-0 flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:O=>b(O.target.value)})]})]}),d.jsxs("section",{className:"flex min-h-[200px] flex-col gap-2 md:min-h-0 md:overflow-hidden",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.skills")}),d.jsx("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)]",children:d.jsxs("div",{className:"scroll-frame-body h-full p-2",children:[D.isLoading&&d.jsx(lt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),I.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(O=>{const R=x.has(O.name);return d.jsx("button",{type:"button",onClick:()=>P(O.name),className:["max-w-full break-all px-2.5 py-1 text-left text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",R?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),"aria-pressed":R,children:O.name},O.name)})})]})}),x.size>0&&d.jsx("p",{className:"max-h-14 overflow-y-auto break-words text-xs text-[var(--color-text-muted)]",children:[...x].join(", ")})]})]}),d.jsxs("div",{className:"flex gap-2 justify-between mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",onClick:()=>void q(),disabled:u,children:[d.jsx(qi,{size:14,strokeWidth:2.4})," ",a("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void U(),disabled:u,children:[u?d.jsx(lt,{size:14,className:"animate-spin"}):null,a("flow.node.save")]})]})]})]})})}const Rde=C.memo(function({data:t}){const n=t;return d.jsxs("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed border-[var(--color-text)]",children:[d.jsx("div",{className:"absolute inset-0 rounded-2xl",style:{background:n.color,opacity:.16}}),d.jsxs("span",{className:"absolute top-1.5 left-2.5 inline-flex items-center gap-1.5 px-2 py-0.5 text-[11px] font-bold rounded-md border-2 border-[var(--color-text)] bg-[var(--color-bg)] text-[var(--color-text)] whitespace-nowrap max-w-[90%]",children:[d.jsx("span",{className:"truncate",children:n.label}),n.sub&&d.jsx("span",{className:"font-normal text-[var(--color-text-muted)]",children:n.sub})]})]})});function Dde(e){const t=e;if(typeof t.seq=="number")return t.seq;const n=/#(\d+)/.exec(t.output??"");return n?Number(n[1]):null}const Ode={task:Tde,waveBox:Rde},kA="sps.flow.lastProject",NA="sps.flow.mode";function _A(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function Lde(e){return e==="done"?{animated:!1,style:{stroke:"var(--color-running)",strokeWidth:2.5}}:e==="doing"?{animated:!1,className:"arrange-flow-edge-working",style:{stroke:"var(--color-running)",strokeWidth:3,strokeDasharray:"8 6"}}:e==="stuck"?{animated:!1,style:{stroke:"var(--color-crashed)",strokeWidth:2.5,strokeDasharray:"6 4"}}:{animated:!1,style:{stroke:"var(--color-accent-yellow)",strokeWidth:2.5,strokeDasharray:"6 4"}}}const el=260,tl=158,Tm=28,bp=el+120,Kx=tl+28,CA=16,TA=44,xp=60,Gx=100,AA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-running-bg)","var(--color-idle-bg)"];function od(e){const t=new Map;for(const n of e){const i=t.get(n.order)??[];i.push(n),t.set(n.order,i)}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n.sort((i,s)=>i.seq-s.seq))}function Ide(e,t){return Math.abs(e.x-t.x)<el+Tm&&Math.abs(e.y-t.y)<tl+Tm}function Pde(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(el+Tm),y:60+t*(tl+Tm)};if(!e.some(s=>Ide(i,s)))return i}return{x:60,y:60}}function jA(e){return{x:e.position.x+el/2,y:e.position.y+tl/2}}function zde(e,t,n){const i=n.x-t.x,s=n.y-t.y,a=i*i+s*s;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/a;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function Bde(){var Ve,Ze,Ct,Gt;const e=Xe(),t=tn(),n=dl(),{confirm:i}=Ln(),{screenToFlowPosition:s,fitView:a}=gg(),o=C.useRef([]),[c,u]=C.useState(()=>localStorage.getItem(kA)??""),[f,m]=C.useState(()=>localStorage.getItem(NA)==="lanes"?"lanes":"free"),[p,y]=C.useState(!1),[b,x,w]=Xue([]),[E,v,_]=Que([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(!1),[I,P]=C.useState(""),[U,q]=C.useState(null),[V,O]=C.useState(null),[R,z]=C.useState(0),G=C.useRef({}),Y=C.useRef(E);Y.current=E;const K=C.useRef(b);K.current=b;const B=C.useRef(null),F=C.useRef(null),W=C.useRef(new Set),$=C.useRef(""),ae=C.useRef(null);LL(c||null);const be=at({queryKey:["cards",c],queryFn:()=>ML(c),enabled:!!c,refetchInterval:3e3}),le=((Ve=be.data)==null?void 0:Ve.data)??[],re=((Gt=(Ct=(Ze=at({queryKey:["projects"],queryFn:ro,refetchInterval:3e3}).data)==null?void 0:Ze.data)==null?void 0:Ct.find(ce=>ce.name===c))==null?void 0:Gt.pipelineStatus)==="running",me=C.useMemo(()=>{const ce={};for(const pe of le)ce[String(pe.seq)]=_A(pe);return ce},[le]),se=C.useMemo(()=>{if(f!=="lanes")return[];const ce=od(le),pe=[];for(let Ce=1;Ce<ce.length;Ce+=1)for(const je of ce[Ce-1]??[])for(const qe of ce[Ce]??[])pe.push({id:`w${je.seq}-${qe.seq}`,source:String(je.seq),target:String(qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return pe},[f,le]),Q=C.useMemo(()=>(f==="lanes"?se:E).map(ce=>{const pe=Lde(me[ce.target]);return ce.selected?{...ce,...pe,style:{...pe.style,strokeWidth:6}}:{...ce,...pe}}),[f,se,E,me]),ye=C.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),_e=C.useCallback(()=>{!c||B.current!==c||(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{_de(c,{positions:G.current,edges:Y.current.map(ce=>({id:ce.id,source:ce.source,target:ce.target,sourceHandle:ce.sourceHandle??null,targetHandle:ce.targetHandle??null}))}).catch(()=>{})},600))},[c]);C.useEffect(()=>{if(B.current=null,T(null),O(null),G.current={},W.current=new Set,$.current="",x([]),v([]),!c)return;localStorage.setItem(kA,c);let ce=!1;return Nde(c).then(pe=>{ce||(G.current=pe.positions??{},v((pe.edges??[]).map(Ce=>({id:Ce.id,source:Ce.source,target:Ce.target,sourceHandle:Ce.sourceHandle??void 0,targetHandle:Ce.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{ce||(B.current=c,z(pe=>pe+1))}),()=>{ce=!0}},[c,x,v]),C.useEffect(()=>{if(!c||B.current!==c)return;const ce=`${f}|`+le.map(Fe=>`${Fe.seq}:${Fe.title}:${Fe.state}:${Fe.order}:${(Fe.skills??[]).join("|")}`).join(",");if(ce===$.current)return;$.current=ce;const pe=Fe=>({seq:String(Fe.seq),title:Fe.title,skills:(Fe.skills??[]).join(", "),status:_A(Fe),label:Fe.title,desc:""});if(f==="lanes"){const Fe=od(le),et=Fe.map((Yn,Wt)=>({id:`wave-${Wt}`,type:"waveBox",position:{x:xp+Wt*bp-CA,y:Gx-TA},data:{label:e("flow.lane.wave",{n:Wt+1}),sub:Yn.length>1?e("flow.lane.parallel",{n:Yn.length}):"",color:AA[Wt%AA.length]},style:{width:el+CA*2,height:TA+(Yn.length-1)*Kx+tl+14},draggable:!1,selectable:!1,zIndex:0})),Qt=Fe.flatMap((Yn,Wt)=>Yn.map((Z,xe)=>({id:String(Z.seq),type:"task",position:{x:xp+Wt*bp,y:Gx+xe*Kx},deletable:!1,zIndex:1,data:pe(Z)})));x([...et,...Qt]);return}const Ce=new Map(K.current.map(Fe=>[Fe.id,Fe.position])),je=[];for(const Fe of le){const et=Ce.get(String(Fe.seq))??G.current[String(Fe.seq)];et&&je.push(et)}let qe=!1;const st=le.map(Fe=>{const et=String(Fe.seq);let Qt=Ce.get(et)??G.current[et];return Qt||(Qt=Pde(je),je.push(Qt),qe=!0),G.current[et]=Qt,{id:et,type:"task",position:Qt,deletable:!1,data:pe(Fe)}});x(st),qe&&_e()},[le,c,f,R,x,_e,e]),C.useEffect(()=>{if(B.current!==c)return;const ce=new Set(le.map(pe=>String(pe.seq)));v(pe=>{const Ce=pe.filter(je=>ce.has(je.source)&&ce.has(je.target));return Ce.length!==pe.length&&_e(),Ce.length===pe.length?pe:Ce})},[le,c,v,_e]),C.useEffect(()=>{if(!c||B.current!==c||f!=="free"||le.length<2)return;const ce=od(le),pe=[];for(let qe=1;qe<ce.length;qe+=1)for(const st of ce[qe-1]??[])for(const Fe of ce[qe]??[])pe.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Ce=Y.current,je=F.current!==c;if(F.current=c,je&&Ce.length===0)pe.length>0&&(v(pe),_e());else{const qe=new Set;for(const et of Ce)qe.add(et.source),qe.add(et.target);const st=new Set(Ce.map(et=>`${et.source}->${et.target}`)),Fe=new Set(le.map(et=>String(et.seq)).filter(et=>!W.current.has(et)&&!qe.has(et)));if(Fe.size>0){const et=pe.filter(Qt=>(Fe.has(Qt.source)||Fe.has(Qt.target))&&!st.has(`${Qt.source}->${Qt.target}`));et.length>0&&(v([...Ce,...et]),_e())}}W.current=new Set(le.map(qe=>String(qe.seq)))},[le,c,f,R,v,_e]);const ze=C.useCallback(ce=>{if(w(ce),f!=="free")return;let pe=!1;for(const Ce of ce)Ce.type==="position"&&Ce.position&&(G.current[Ce.id]=Ce.position,pe=!0);pe&&_e()},[w,_e,f]),fe=C.useCallback(ce=>{f==="free"&&(v(pe=>lP({...ce,animated:!1},pe)),_e())},[v,_e,f]),Se=C.useCallback(()=>{if(f!=="free"||le.length===0)return;const ce=od(le),pe={},Ce=[];ce.forEach((je,qe)=>{if(je.forEach((st,Fe)=>{pe[String(st.seq)]={x:xp+qe*bp,y:Gx+Fe*Kx}}),qe>0)for(const st of ce[qe-1]??[])for(const Fe of je)Ce.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),G.current={...G.current,...pe},x(je=>je.map(qe=>pe[qe.id]?{...qe,position:pe[qe.id]}:qe)),v(Ce),_e(),setTimeout(()=>a({padding:.2,duration:300}),60)},[f,le,x,v,_e,a]),Re=C.useCallback(async ce=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:ce}),danger:!0,confirm:e("flow.node.delete")}))return;P("");const Ce=Y.current.filter(je=>je.source===String(ce)||je.target===String(ce)).map(je=>({...je}));try{await DL(c,ce),o.current.push({seq:ce,edges:Ce})}catch(je){P(je instanceof Error?je.message:String(je))}finally{T(je=>je===ce?null:je),j(je=>je===ce?null:je),$.current="",z(je=>je+1),ye()}},[c,i,e,ye]),Qe=C.useCallback(async()=>{const ce=o.current.pop();if(ce){P("");try{await jne(c,ce.seq),v(pe=>{const Ce=new Set(pe.map(je=>je.id));return[...pe,...ce.edges.filter(je=>!Ce.has(je.id))]}),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}}},[c,v,_e,ye]),ht=C.useCallback((ce,pe)=>{var st;if(f!=="free"||pe.isValid)return;const Ce=pe.fromNode;if(!Ce||!c)return;const je="changedTouches"in ce?ce.changedTouches[0]:ce;if(!je)return;const qe=s({x:je.clientX,y:je.clientY});q({fromId:Ce.id,fromHandle:((st=pe.fromHandle)==null?void 0:st.id)??null,clientX:je.clientX,clientY:je.clientY,flowX:qe.x,flowY:qe.y})},[f,c,s]),it=C.useCallback(async()=>{const ce=U;if(q(null),!(!ce||!c))try{const pe=await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),Ce=Dde(pe);if(Ce==null)return;const je=String(Ce);G.current[je]={x:ce.flowX-el/2,y:ce.flowY-tl/2},v(qe=>[...qe,{id:`e-${ce.fromId}-${je}-drop`,source:ce.fromId,target:je,sourceHandle:ce.fromHandle??void 0,animated:!1}]),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}},[U,c,le.length,v,_e,e,ye]);C.useEffect(()=>{if(!U)return;const ce=pe=>{pe.key==="Escape"&&q(null)};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[U]);const Bt=C.useCallback((ce,pe)=>{f==="free"&&(v(Ce=>Nce(ce,pe,Ce)),_e())},[f,v,_e]);C.useEffect(()=>{const ce=pe=>{if(pe.key!=="Delete"&&pe.key!=="Backspace"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||k!=null&&(pe.preventDefault(),Re(k))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[k,A,Re]),C.useEffect(()=>{const ce=pe=>{if(!(pe.metaKey||pe.ctrlKey)||pe.key!=="z"&&pe.key!=="Z"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||(pe.preventDefault(),Qe())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[A,Qe]);const mt=C.useCallback(async ce=>{if(c){y(!0),P("");try{const pe=new Map(le.map(Ce=>[Ce.seq,Ce.order]));for(let Ce=0;Ce<ce.length;Ce+=1)for(const je of ce[Ce]??[])pe.get(je)!==Ce+1&&await gm(c,je,{order:Ce+1});ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}finally{y(!1)}}},[c,le,ye]),wt=C.useCallback(ce=>{const pe=Number(ce.id);if(!Number.isInteger(pe))return;const Ce=od(le).map(Fe=>Fe.map(et=>et.seq)),je=(ce.position.x-xp)/bp,qe=Math.round(je),st=Ce.map(Fe=>Fe.filter(et=>et!==pe));if(qe>=0&&qe<Ce.length&&Math.abs(je-qe)<=.35)st[qe].push(pe);else{const Fe=Math.max(0,Math.min(st.length,Math.ceil(je)));st.splice(Fe,0,[pe])}mt(st.filter(Fe=>Fe.length>0)).finally(()=>{$.current="",z(Fe=>Fe+1)})},[le,mt]),Te=C.useCallback((ce,pe)=>{if(f==="lanes"){wt(pe);return}const Ce=new Map(K.current.map(et=>[et.id,et])),je={x:pe.position.x+el/2,y:pe.position.y+tl/2};let qe=null,st=40;for(const et of Y.current){if(et.source===pe.id||et.target===pe.id)continue;const Qt=Ce.get(et.source),Yn=Ce.get(et.target);if(!Qt||!Yn)continue;const Wt=zde(je,jA(Qt),jA(Yn));Wt<st&&(st=Wt,qe=et)}if(!qe)return;const Fe=qe;v(et=>[...et.filter(Qt=>Qt.id!==Fe.id),{id:`e-${Fe.source}-${pe.id}-${Fe.id}`,source:Fe.source,target:pe.id,animated:!1},{id:`e-${pe.id}-${Fe.target}-${Fe.id}`,source:pe.id,target:Fe.target,animated:!1}]),_e()},[f,wt,v,_e]),ct=C.useCallback(ce=>{m(ce),localStorage.setItem(NA,ce)},[]);C.useEffect(()=>{const ce=setTimeout(()=>{a({padding:.2,duration:300})},80);return()=>clearTimeout(ce)},[f,a]);const ne=async()=>{if(c){P("");try{await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),ye()}catch(ce){P(ce instanceof Error?ce.message:String(ce))}}},we=async()=>{if(P(""),O(null),!c)return P(e("flow.err.noProject"));if(le.length===0)return P(e("flow.err.noNodes"));D(!0);try{const ce=le.filter(je=>je.state==="Planning"),pe=ce.length;let Ce=0;O({phase:"creating",made:Ce,total:pe});for(const je of ce)await gm(c,je.seq,{state:"Backlog",labels:Array.from(new Set([...je.labels??[],"AI-PIPELINE"]))}),Ce+=1,O({phase:"creating",made:Ce,total:pe});O({phase:"starting",made:Ce,total:pe}),await OL(c),ye(),O({phase:"done",made:Ce,total:pe})}catch(ce){P(ce instanceof Error?ce.message:String(ce))}finally{D(!1)}},he=be.isLoading&&!!c;return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("header",{className:"flex items-center gap-3 flex-wrap px-4 py-3 border-b border-[var(--surface-card-border)]",children:[d.jsxs("h1",{className:"text-lg font-[family-name:var(--font-heading)] flex items-center gap-2",children:[d.jsx(UN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(zL,{current:c,onChange:u}),d.jsxs("div",{className:"flex gap-1",role:"group","aria-label":e("flow.mode.aria"),children:[d.jsxs("button",{type:"button",className:["nb-btn",f==="free"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="free",onClick:()=>ct("free"),children:[d.jsx(UN,{size:14,strokeWidth:2.4})," ",e("flow.mode.free")]}),d.jsxs("button",{type:"button",className:["nb-btn",f==="lanes"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="lanes",onClick:()=>ct("lanes"),children:[d.jsx(WB,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),he&&d.jsx(lt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||he,children:[d.jsx(Gn,{size:15,strokeWidth:2.4})," ",e("flow.addNode")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta ml-auto",onClick:()=>void we(),disabled:M||re||he||!c,title:re?e("flow.pipelineRunning"):void 0,children:[M||re?d.jsx(lt,{size:15,className:"animate-spin"}):d.jsx(Mm,{size:15,strokeWidth:2.4}),e(M?"flow.running":re?"flow.pipelineRunning":"flow.run")]})]}),!c&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-text-muted)] border-b border-[var(--surface-card-border)]",children:e("flow.pickProject")}),I&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-crashed)] bg-[var(--color-crashed-bg)] border-b border-[var(--surface-card-border)]",children:I}),V&&d.jsxs("div",{className:"px-4 py-2 text-sm flex items-center gap-3 bg-[var(--surface-input)] border-b border-[var(--surface-card-border)]",children:[V.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",V.made,"/",V.total,"…"]}),V.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),V.phase==="done"&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"text-[var(--color-running)] font-bold",children:["✓ ",e("flow.status.done").replace("{n}",String(V.made))]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>n(`/board?project=${encodeURIComponent(c)}`),children:e("flow.goBoard")})]})]}),d.jsx("div",{className:"flex-1 min-h-0 arrange-flow-shell",children:d.jsxs(Yue,{nodes:b,edges:Q,nodeTypes:Ode,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:ze,onEdgesChange:ce=>{f==="free"&&(_(ce),_e())},onConnect:fe,onConnectEnd:ht,onReconnect:Bt,onNodeClick:(ce,pe)=>{const Ce=Number(pe.id);Number.isInteger(Ce)&&j(Ce)},onNodeDragStop:Te,onSelectionChange:({nodes:ce})=>{const pe=ce[0]?Number(ce[0].id):null;T(pe!=null&&Number.isInteger(pe)?pe:null)},fitView:!0,children:[d.jsx(nde,{variant:Qr.Dots,gap:18,size:1}),d.jsx(cde,{children:f==="free"&&d.jsx(md,{onClick:Se,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Dj,{size:14,strokeWidth:2.4})})})]})}),U&&d.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>q(null),children:d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta absolute -translate-x-1/2 -translate-y-1/2",style:{left:U.clientX,top:U.clientY},onClick:ce=>{ce.stopPropagation(),it()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),p&&d.jsxs("div",{className:"px-4 py-1 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] flex items-center gap-2",children:[d.jsx(lt,{size:12,className:"animate-spin"})," ",e("flow.lane.applying")]}),d.jsx("footer",{className:"px-4 py-2 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)]",children:e(f==="free"?"flow.hint":"flow.lane.hint")}),A!=null&&c&&d.jsx(Mde,{project:c,seq:A,onClose:()=>j(null),onChanged:ye,onDelete:ce=>void Re(ce)})]})}function Ude(){return d.jsx(OP,{children:d.jsx(Bde,{})})}function Fde(){const e=Xe();return d.jsxs("div",{className:"nb-card max-w-2xl mt-12",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold mb-2",children:e("notFound.title")}),d.jsx("p",{className:"text-[var(--color-text-muted)] mb-6",children:e("notFound.body")}),d.jsx(jc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const $de=C.lazy(()=>yB(()=>import("./ShowcasePage-DlksLyHb.js"),__vite__mapDeps([0,1])));function qde(){return d.jsx(gF,{children:d.jsxs(L5,{children:[d.jsx(ii,{path:"/showcase",element:d.jsx(C.Suspense,{fallback:null,children:d.jsx($de,{})})}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"workspace"}),children:[d.jsx(ii,{index:!0,element:d.jsx(bx,{})}),d.jsx(ii,{path:"/projects",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/projects/:name",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/board",element:d.jsx(Qne,{})}),d.jsx(ii,{path:"/prompts",element:d.jsx(die,{})}),d.jsx(ii,{path:"/chat",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/chat/:sessionId",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/arrange",element:d.jsx(Ude,{})})]}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"document"}),children:[d.jsx(ii,{path:"/projects/new",element:d.jsx(jL,{})}),d.jsx(ii,{path:"/skills",element:d.jsx(sie,{})}),d.jsx(ii,{path:"/system",element:d.jsx(Aie,{})}),d.jsx(ii,{path:"/memory",element:d.jsx(Fie,{})}),d.jsx(ii,{path:"/plugins",element:d.jsx(sse,{})}),d.jsx(ii,{path:"*",element:d.jsx(Fde,{})})]})]})})}mF();$6();const Hde=new S4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),zP=document.getElementById("root");if(!zP)throw new Error("#root not found");Zz.createRoot(zP).render(d.jsx(C.StrictMode,{children:d.jsx(R6,{children:d.jsx(k4,{client:Hde,children:d.jsx(aB,{children:d.jsx(BW,{children:d.jsx(qde,{})})})})})}));export{kj as A,VB as C,Aj as E,jc as L,Hv as P,f0 as S,_B as a,Pe as c,d as j,C as r,qj as u};
|
|
855
|
+
`).trim()}function jde(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function Mde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var V;const a=Xe(),[o,c]=C.useState(!0),[u,f]=C.useState(!1),[m,p]=C.useState(""),[y,b]=C.useState(""),[x,w]=C.useState(new Set),[E,v]=C.useState(""),[_,k]=C.useState("todo"),[T,A]=C.useState(null),[j,M]=C.useState(""),D=at({queryKey:["skills-all",e],queryFn:()=>ig(e)}),I=((V=D.data)==null?void 0:V.data)??[];C.useEffect(()=>{const O=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[n]),C.useEffect(()=>{let O=!1;return c(!0),RL(e,t).then(R=>{O||(p(R.title),w(new Set(R.skills??[])),b(Ade(R.body)),v(R.state),k(jde(R.state,R.labels??[])),A(typeof R.order=="number"?R.order:null))}).catch(()=>{}).finally(()=>{O||c(!1)}),()=>{O=!0}},[e,t]);const P=O=>{w(R=>{const z=new Set(R);return z.has(O)?z.delete(O):z.add(O),z})},U=async()=>{M(""),f(!0);try{await gm(e,t,{title:m.trim()||a("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(O){M(O instanceof Error?O.message:String(O)),f(!1)}},q=()=>s(t);return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-4 md:p-6 bg-black/30 overflow-hidden",onClick:n,children:d.jsxs("div",{className:"nb-card w-full max-w-4xl flex flex-col bg-[var(--color-bg)]",style:{maxHeight:"calc(100vh - 48px)"},onClick:O=>O.stopPropagation(),children:[d.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),E&&d.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs px-2 py-0.5 border-2 border-[var(--color-text)] rounded-full font-semibold",children:[d.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block border border-[var(--color-text)]",style:{background:Cv[_]??"gray"}}),E]}),T!=null&&d.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded-full font-semibold",title:a("flow.lane.orderTip"),children:a("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":a("flow.node.close"),type:"button",children:d.jsx(vn,{size:14,strokeWidth:3})})]}),o?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)] py-10 justify-center",children:[d.jsx(lt,{size:16,className:"animate-spin"})," …"]}):d.jsxs(d.Fragment,{children:[j&&d.jsx("div",{className:"text-sm text-[var(--color-crashed)] mb-3",children:j}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-4 overflow-y-auto pr-1 md:grid-cols-[minmax(0,1fr)_minmax(260px,340px)] md:overflow-hidden md:pr-0",children:[d.jsxs("div",{className:"flex min-h-0 flex-col gap-4 md:overflow-y-auto md:pr-1",children:[d.jsxs("label",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:m,onChange:O=>p(O.target.value),autoFocus:!0})]}),d.jsxs("label",{className:"flex flex-1 min-h-0 flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:O=>b(O.target.value)})]})]}),d.jsxs("section",{className:"flex min-h-[200px] flex-col gap-2 md:min-h-0 md:overflow-hidden",children:[d.jsx("span",{className:"text-sm font-bold",children:a("flow.node.skills")}),d.jsx("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)]",children:d.jsxs("div",{className:"scroll-frame-body h-full p-2",children:[D.isLoading&&d.jsx(lt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),I.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(O=>{const R=x.has(O.name);return d.jsx("button",{type:"button",onClick:()=>P(O.name),className:["max-w-full break-all px-2.5 py-1 text-left text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",R?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),"aria-pressed":R,children:O.name},O.name)})})]})}),x.size>0&&d.jsx("p",{className:"max-h-14 overflow-y-auto break-words text-xs text-[var(--color-text-muted)]",children:[...x].join(", ")})]})]}),d.jsxs("div",{className:"flex gap-2 justify-between mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",onClick:()=>void q(),disabled:u,children:[d.jsx(qi,{size:14,strokeWidth:2.4})," ",a("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void U(),disabled:u,children:[u?d.jsx(lt,{size:14,className:"animate-spin"}):null,a("flow.node.save")]})]})]})]})})}const Rde=C.memo(function({data:t}){const n=t;return d.jsxs("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed border-[var(--color-text)]",children:[d.jsx("div",{className:"absolute inset-0 rounded-2xl",style:{background:n.color,opacity:.16}}),d.jsxs("span",{className:"absolute top-1.5 left-2.5 inline-flex items-center gap-1.5 px-2 py-0.5 text-[11px] font-bold rounded-md border-2 border-[var(--color-text)] bg-[var(--color-bg)] text-[var(--color-text)] whitespace-nowrap max-w-[90%]",children:[d.jsx("span",{className:"truncate",children:n.label}),n.sub&&d.jsx("span",{className:"font-normal text-[var(--color-text-muted)]",children:n.sub})]})]})});function Dde(e){const t=e;if(typeof t.seq=="number")return t.seq;const n=/#(\d+)/.exec(t.output??"");return n?Number(n[1]):null}const Ode={task:Tde,waveBox:Rde},kA="sps.flow.lastProject",NA="sps.flow.mode";function _A(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function Lde(e){return e==="done"?{animated:!1,style:{stroke:"var(--color-running)",strokeWidth:2.5}}:e==="doing"?{animated:!1,className:"arrange-flow-edge-working",style:{stroke:"var(--color-running)",strokeWidth:3,strokeDasharray:"8 6"}}:e==="stuck"?{animated:!1,style:{stroke:"var(--color-crashed)",strokeWidth:2.5,strokeDasharray:"6 4"}}:{animated:!1,style:{stroke:"var(--color-accent-yellow)",strokeWidth:2.5,strokeDasharray:"6 4"}}}const el=260,tl=158,Tm=28,bp=el+120,Kx=tl+28,CA=16,TA=44,xp=60,Gx=100,AA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-running-bg)","var(--color-idle-bg)"];function od(e){const t=new Map;for(const n of e){const i=t.get(n.order)??[];i.push(n),t.set(n.order,i)}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n.sort((i,s)=>i.seq-s.seq))}function Ide(e,t){return Math.abs(e.x-t.x)<el+Tm&&Math.abs(e.y-t.y)<tl+Tm}function Pde(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(el+Tm),y:60+t*(tl+Tm)};if(!e.some(s=>Ide(i,s)))return i}return{x:60,y:60}}function jA(e){return{x:e.position.x+el/2,y:e.position.y+tl/2}}function zde(e,t,n){const i=n.x-t.x,s=n.y-t.y,a=i*i+s*s;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/a;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function Bde(){var Ve,Ze,Ct,Gt;const e=Xe(),t=tn(),n=dl(),{confirm:i}=Ln(),{screenToFlowPosition:s,fitView:a}=gg(),o=C.useRef([]),[c,u]=C.useState(()=>localStorage.getItem(kA)??""),[f,m]=C.useState(()=>localStorage.getItem(NA)==="lanes"?"lanes":"free"),[p,y]=C.useState(!1),[b,x,w]=Xue([]),[E,v,_]=Que([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(!1),[I,P]=C.useState(""),[U,q]=C.useState(null),[V,O]=C.useState(null),[R,z]=C.useState(0),G=C.useRef({}),Y=C.useRef(E);Y.current=E;const K=C.useRef(b);K.current=b;const B=C.useRef(null),F=C.useRef(null),W=C.useRef(new Set),$=C.useRef(""),ae=C.useRef(null);LL(c||null);const be=at({queryKey:["cards",c],queryFn:()=>ML(c),enabled:!!c,refetchInterval:3e3}),le=((Ve=be.data)==null?void 0:Ve.data)??[],re=((Gt=(Ct=(Ze=at({queryKey:["projects"],queryFn:ro,refetchInterval:3e3}).data)==null?void 0:Ze.data)==null?void 0:Ct.find(ce=>ce.name===c))==null?void 0:Gt.pipelineStatus)==="running",me=C.useMemo(()=>{const ce={};for(const pe of le)ce[String(pe.seq)]=_A(pe);return ce},[le]),se=C.useMemo(()=>{if(f!=="lanes")return[];const ce=od(le),pe=[];for(let Ce=1;Ce<ce.length;Ce+=1)for(const je of ce[Ce-1]??[])for(const qe of ce[Ce]??[])pe.push({id:`w${je.seq}-${qe.seq}`,source:String(je.seq),target:String(qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return pe},[f,le]),Q=C.useMemo(()=>(f==="lanes"?se:E).map(ce=>{const pe=Lde(me[ce.target]);return ce.selected?{...ce,...pe,style:{...pe.style,strokeWidth:6}}:{...ce,...pe}}),[f,se,E,me]),ye=C.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),_e=C.useCallback(()=>{!c||B.current!==c||(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{_de(c,{positions:G.current,edges:Y.current.map(ce=>({id:ce.id,source:ce.source,target:ce.target,sourceHandle:ce.sourceHandle??null,targetHandle:ce.targetHandle??null}))}).catch(()=>{})},600))},[c]);C.useEffect(()=>{if(B.current=null,T(null),O(null),G.current={},W.current=new Set,$.current="",x([]),v([]),!c)return;localStorage.setItem(kA,c);let ce=!1;return Nde(c).then(pe=>{ce||(G.current=pe.positions??{},v((pe.edges??[]).map(Ce=>({id:Ce.id,source:Ce.source,target:Ce.target,sourceHandle:Ce.sourceHandle??void 0,targetHandle:Ce.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{ce||(B.current=c,z(pe=>pe+1))}),()=>{ce=!0}},[c,x,v]),C.useEffect(()=>{if(!c||B.current!==c)return;const ce=`${f}|`+le.map(Fe=>`${Fe.seq}:${Fe.title}:${Fe.state}:${Fe.order}:${(Fe.skills??[]).join("|")}`).join(",");if(ce===$.current)return;$.current=ce;const pe=Fe=>({seq:String(Fe.seq),title:Fe.title,skills:(Fe.skills??[]).join(", "),status:_A(Fe),label:Fe.title,desc:""});if(f==="lanes"){const Fe=od(le),et=Fe.map((Yn,Wt)=>({id:`wave-${Wt}`,type:"waveBox",position:{x:xp+Wt*bp-CA,y:Gx-TA},data:{label:e("flow.lane.wave",{n:Wt+1}),sub:Yn.length>1?e("flow.lane.parallel",{n:Yn.length}):"",color:AA[Wt%AA.length]},style:{width:el+CA*2,height:TA+(Yn.length-1)*Kx+tl+14},draggable:!1,selectable:!1,zIndex:0})),Qt=Fe.flatMap((Yn,Wt)=>Yn.map((Z,xe)=>({id:String(Z.seq),type:"task",position:{x:xp+Wt*bp,y:Gx+xe*Kx},deletable:!1,zIndex:1,data:pe(Z)})));x([...et,...Qt]);return}const Ce=new Map(K.current.map(Fe=>[Fe.id,Fe.position])),je=[];for(const Fe of le){const et=Ce.get(String(Fe.seq))??G.current[String(Fe.seq)];et&&je.push(et)}let qe=!1;const st=le.map(Fe=>{const et=String(Fe.seq);let Qt=Ce.get(et)??G.current[et];return Qt||(Qt=Pde(je),je.push(Qt),qe=!0),G.current[et]=Qt,{id:et,type:"task",position:Qt,deletable:!1,data:pe(Fe)}});x(st),qe&&_e()},[le,c,f,R,x,_e,e]),C.useEffect(()=>{if(B.current!==c)return;const ce=new Set(le.map(pe=>String(pe.seq)));v(pe=>{const Ce=pe.filter(je=>ce.has(je.source)&&ce.has(je.target));return Ce.length!==pe.length&&_e(),Ce.length===pe.length?pe:Ce})},[le,c,v,_e]),C.useEffect(()=>{if(!c||B.current!==c||f!=="free"||le.length<2)return;const ce=od(le),pe=[];for(let qe=1;qe<ce.length;qe+=1)for(const st of ce[qe-1]??[])for(const Fe of ce[qe]??[])pe.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Ce=Y.current,je=F.current!==c;if(F.current=c,je&&Ce.length===0)pe.length>0&&(v(pe),_e());else{const qe=new Set;for(const et of Ce)qe.add(et.source),qe.add(et.target);const st=new Set(Ce.map(et=>`${et.source}->${et.target}`)),Fe=new Set(le.map(et=>String(et.seq)).filter(et=>!W.current.has(et)&&!qe.has(et)));if(Fe.size>0){const et=pe.filter(Qt=>(Fe.has(Qt.source)||Fe.has(Qt.target))&&!st.has(`${Qt.source}->${Qt.target}`));et.length>0&&(v([...Ce,...et]),_e())}}W.current=new Set(le.map(qe=>String(qe.seq)))},[le,c,f,R,v,_e]);const ze=C.useCallback(ce=>{if(w(ce),f!=="free")return;let pe=!1;for(const Ce of ce)Ce.type==="position"&&Ce.position&&(G.current[Ce.id]=Ce.position,pe=!0);pe&&_e()},[w,_e,f]),fe=C.useCallback(ce=>{f==="free"&&(v(pe=>lP({...ce,animated:!1},pe)),_e())},[v,_e,f]),Se=C.useCallback(()=>{if(f!=="free"||le.length===0)return;const ce=od(le),pe={},Ce=[];ce.forEach((je,qe)=>{if(je.forEach((st,Fe)=>{pe[String(st.seq)]={x:xp+qe*bp,y:Gx+Fe*Kx}}),qe>0)for(const st of ce[qe-1]??[])for(const Fe of je)Ce.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),G.current={...G.current,...pe},x(je=>je.map(qe=>pe[qe.id]?{...qe,position:pe[qe.id]}:qe)),v(Ce),_e(),setTimeout(()=>a({padding:.2,duration:300}),60)},[f,le,x,v,_e,a]),Re=C.useCallback(async ce=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:ce}),danger:!0,confirm:e("flow.node.delete")}))return;P("");const Ce=Y.current.filter(je=>je.source===String(ce)||je.target===String(ce)).map(je=>({...je}));try{await DL(c,ce),o.current.push({seq:ce,edges:Ce})}catch(je){P(je instanceof Error?je.message:String(je))}finally{T(je=>je===ce?null:je),j(je=>je===ce?null:je),$.current="",z(je=>je+1),ye()}},[c,i,e,ye]),Qe=C.useCallback(async()=>{const ce=o.current.pop();if(ce){P("");try{await jne(c,ce.seq),v(pe=>{const Ce=new Set(pe.map(je=>je.id));return[...pe,...ce.edges.filter(je=>!Ce.has(je.id))]}),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}}},[c,v,_e,ye]),ht=C.useCallback((ce,pe)=>{var st;if(f!=="free"||pe.isValid)return;const Ce=pe.fromNode;if(!Ce||!c)return;const je="changedTouches"in ce?ce.changedTouches[0]:ce;if(!je)return;const qe=s({x:je.clientX,y:je.clientY});q({fromId:Ce.id,fromHandle:((st=pe.fromHandle)==null?void 0:st.id)??null,clientX:je.clientX,clientY:je.clientY,flowX:qe.x,flowY:qe.y})},[f,c,s]),it=C.useCallback(async()=>{const ce=U;if(q(null),!(!ce||!c))try{const pe=await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),Ce=Dde(pe);if(Ce==null)return;const je=String(Ce);G.current[je]={x:ce.flowX-el/2,y:ce.flowY-tl/2},v(qe=>[...qe,{id:`e-${ce.fromId}-${je}-drop`,source:ce.fromId,target:je,sourceHandle:ce.fromHandle??void 0,animated:!1}]),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}},[U,c,le.length,v,_e,e,ye]);C.useEffect(()=>{if(!U)return;const ce=pe=>{pe.key==="Escape"&&q(null)};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[U]);const Bt=C.useCallback((ce,pe)=>{f==="free"&&(v(Ce=>Nce(ce,pe,Ce)),_e())},[f,v,_e]);C.useEffect(()=>{const ce=pe=>{if(pe.key!=="Delete"&&pe.key!=="Backspace"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||k!=null&&(pe.preventDefault(),Re(k))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[k,A,Re]),C.useEffect(()=>{const ce=pe=>{if(!(pe.metaKey||pe.ctrlKey)||pe.key!=="z"&&pe.key!=="Z"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||(pe.preventDefault(),Qe())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[A,Qe]);const mt=C.useCallback(async ce=>{if(c){y(!0),P("");try{const pe=new Map(le.map(Ce=>[Ce.seq,Ce.order]));for(let Ce=0;Ce<ce.length;Ce+=1)for(const je of ce[Ce]??[])pe.get(je)!==Ce+1&&await gm(c,je,{order:Ce+1});ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}finally{y(!1)}}},[c,le,ye]),wt=C.useCallback(ce=>{const pe=Number(ce.id);if(!Number.isInteger(pe))return;const Ce=od(le).map(Fe=>Fe.map(et=>et.seq)),je=(ce.position.x-xp)/bp,qe=Math.round(je),st=Ce.map(Fe=>Fe.filter(et=>et!==pe));if(qe>=0&&qe<Ce.length&&Math.abs(je-qe)<=.35)st[qe].push(pe);else{const Fe=Math.max(0,Math.min(st.length,Math.ceil(je)));st.splice(Fe,0,[pe])}mt(st.filter(Fe=>Fe.length>0)).finally(()=>{$.current="",z(Fe=>Fe+1)})},[le,mt]),Te=C.useCallback((ce,pe)=>{if(f==="lanes"){wt(pe);return}const Ce=new Map(K.current.map(et=>[et.id,et])),je={x:pe.position.x+el/2,y:pe.position.y+tl/2};let qe=null,st=40;for(const et of Y.current){if(et.source===pe.id||et.target===pe.id)continue;const Qt=Ce.get(et.source),Yn=Ce.get(et.target);if(!Qt||!Yn)continue;const Wt=zde(je,jA(Qt),jA(Yn));Wt<st&&(st=Wt,qe=et)}if(!qe)return;const Fe=qe;v(et=>[...et.filter(Qt=>Qt.id!==Fe.id),{id:`e-${Fe.source}-${pe.id}-${Fe.id}`,source:Fe.source,target:pe.id,animated:!1},{id:`e-${pe.id}-${Fe.target}-${Fe.id}`,source:pe.id,target:Fe.target,animated:!1}]),_e()},[f,wt,v,_e]),ct=C.useCallback(ce=>{m(ce),localStorage.setItem(NA,ce)},[]);C.useEffect(()=>{const ce=setTimeout(()=>{a({padding:.2,duration:300})},80);return()=>clearTimeout(ce)},[f,a]);const ne=async()=>{if(c){P("");try{await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),ye()}catch(ce){P(ce instanceof Error?ce.message:String(ce))}}},we=async()=>{if(P(""),O(null),!c)return P(e("flow.err.noProject"));if(le.length===0)return P(e("flow.err.noNodes"));D(!0);try{const ce=le.filter(je=>je.state==="Planning"),pe=ce.length;let Ce=0;O({phase:"creating",made:Ce,total:pe});for(const je of ce)await gm(c,je.seq,{state:"Backlog",labels:Array.from(new Set([...je.labels??[],"AI-PIPELINE"]))}),Ce+=1,O({phase:"creating",made:Ce,total:pe});O({phase:"starting",made:Ce,total:pe}),await OL(c),ye(),O({phase:"done",made:Ce,total:pe})}catch(ce){P(ce instanceof Error?ce.message:String(ce))}finally{D(!1)}},he=be.isLoading&&!!c;return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("header",{className:"flex items-center gap-3 flex-wrap px-4 py-3 border-b border-[var(--surface-card-border)]",children:[d.jsxs("h1",{className:"text-lg font-[family-name:var(--font-heading)] flex items-center gap-2",children:[d.jsx(UN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(zL,{current:c,onChange:u}),d.jsxs("div",{className:"flex gap-1",role:"group","aria-label":e("flow.mode.aria"),children:[d.jsxs("button",{type:"button",className:["nb-btn",f==="free"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="free",onClick:()=>ct("free"),children:[d.jsx(UN,{size:14,strokeWidth:2.4})," ",e("flow.mode.free")]}),d.jsxs("button",{type:"button",className:["nb-btn",f==="lanes"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="lanes",onClick:()=>ct("lanes"),children:[d.jsx(WB,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),he&&d.jsx(lt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||he,children:[d.jsx(Gn,{size:15,strokeWidth:2.4})," ",e("flow.addNode")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta ml-auto",onClick:()=>void we(),disabled:M||re||he||!c,title:re?e("flow.pipelineRunning"):void 0,children:[M||re?d.jsx(lt,{size:15,className:"animate-spin"}):d.jsx(Mm,{size:15,strokeWidth:2.4}),e(M?"flow.running":re?"flow.pipelineRunning":"flow.run")]})]}),!c&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-text-muted)] border-b border-[var(--surface-card-border)]",children:e("flow.pickProject")}),I&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-crashed)] bg-[var(--color-crashed-bg)] border-b border-[var(--surface-card-border)]",children:I}),V&&d.jsxs("div",{className:"px-4 py-2 text-sm flex items-center gap-3 bg-[var(--surface-input)] border-b border-[var(--surface-card-border)]",children:[V.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",V.made,"/",V.total,"…"]}),V.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),V.phase==="done"&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"text-[var(--color-running)] font-bold",children:["✓ ",e("flow.status.done").replace("{n}",String(V.made))]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>n(`/board?project=${encodeURIComponent(c)}`),children:e("flow.goBoard")})]})]}),d.jsx("div",{className:"flex-1 min-h-0 arrange-flow-shell",children:d.jsxs(Yue,{nodes:b,edges:Q,nodeTypes:Ode,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:ze,onEdgesChange:ce=>{f==="free"&&(_(ce),_e())},onConnect:fe,onConnectEnd:ht,onReconnect:Bt,onNodeClick:(ce,pe)=>{const Ce=Number(pe.id);Number.isInteger(Ce)&&j(Ce)},onNodeDragStop:Te,onSelectionChange:({nodes:ce})=>{const pe=ce[0]?Number(ce[0].id):null;T(pe!=null&&Number.isInteger(pe)?pe:null)},fitView:!0,children:[d.jsx(nde,{variant:Qr.Dots,gap:18,size:1}),d.jsx(cde,{children:f==="free"&&d.jsx(md,{onClick:Se,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Dj,{size:14,strokeWidth:2.4})})})]})}),U&&d.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>q(null),children:d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta absolute -translate-x-1/2 -translate-y-1/2",style:{left:U.clientX,top:U.clientY},onClick:ce=>{ce.stopPropagation(),it()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),p&&d.jsxs("div",{className:"px-4 py-1 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] flex items-center gap-2",children:[d.jsx(lt,{size:12,className:"animate-spin"})," ",e("flow.lane.applying")]}),d.jsx("footer",{className:"px-4 py-2 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)]",children:e(f==="free"?"flow.hint":"flow.lane.hint")}),A!=null&&c&&d.jsx(Mde,{project:c,seq:A,onClose:()=>j(null),onChanged:ye,onDelete:ce=>void Re(ce)})]})}function Ude(){return d.jsx(OP,{children:d.jsx(Bde,{})})}function Fde(){const e=Xe();return d.jsxs("div",{className:"nb-card max-w-2xl mt-12",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold mb-2",children:e("notFound.title")}),d.jsx("p",{className:"text-[var(--color-text-muted)] mb-6",children:e("notFound.body")}),d.jsx(jc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const $de=C.lazy(()=>yB(()=>import("./ShowcasePage-C-Qcrrsm.js"),__vite__mapDeps([0,1])));function qde(){return d.jsx(gF,{children:d.jsxs(L5,{children:[d.jsx(ii,{path:"/showcase",element:d.jsx(C.Suspense,{fallback:null,children:d.jsx($de,{})})}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"workspace"}),children:[d.jsx(ii,{index:!0,element:d.jsx(bx,{})}),d.jsx(ii,{path:"/projects",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/projects/:name",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/board",element:d.jsx(Qne,{})}),d.jsx(ii,{path:"/prompts",element:d.jsx(die,{})}),d.jsx(ii,{path:"/chat",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/chat/:sessionId",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/arrange",element:d.jsx(Ude,{})})]}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"document"}),children:[d.jsx(ii,{path:"/projects/new",element:d.jsx(jL,{})}),d.jsx(ii,{path:"/skills",element:d.jsx(sie,{})}),d.jsx(ii,{path:"/system",element:d.jsx(Aie,{})}),d.jsx(ii,{path:"/memory",element:d.jsx(Fie,{})}),d.jsx(ii,{path:"/plugins",element:d.jsx(sse,{})}),d.jsx(ii,{path:"*",element:d.jsx(Fde,{})})]})]})})}mF();$6();const Hde=new S4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),zP=document.getElementById("root");if(!zP)throw new Error("#root not found");Zz.createRoot(zP).render(d.jsx(C.StrictMode,{children:d.jsx(R6,{children:d.jsx(k4,{client:Hde,children:d.jsx(aB,{children:d.jsx(BW,{children:d.jsx(qde,{})})})})})}));export{kj as A,VB as C,Aj as E,jc as L,Hv as P,f0 as S,_B as a,Pe as c,d as j,C as r,qj as u};
|