@sapienx/agentos 0.6.10 → 0.7.0
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/bundle/.next/BUILD_ID +1 -1
- package/bundle/.next/app-path-routes-manifest.json +2 -2
- package/bundle/.next/build-manifest.json +3 -3
- package/bundle/.next/prerender-manifest.json +3 -3
- package/bundle/.next/react-loadable-manifest.json +2 -2
- package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_global-error.html +1 -1
- package/bundle/.next/server/app/_global-error.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_not-found.html +1 -1
- package/bundle/.next/server/app/_not-found.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/bundle/.next/server/app/accounts/page.js +1 -1
- package/bundle/.next/server/app/accounts/page.js.nft.json +1 -1
- package/bundle/.next/server/app/accounts/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/agents/page.js +1 -1
- package/bundle/.next/server/app/agents/page.js.nft.json +1 -1
- package/bundle/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/api/accounts/access-rules/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/accounts/browser-profiles/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/accounts/login-targets/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js +2 -2
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/agents/route.js +1 -1
- package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/integrations/[integrationId]/status/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/mission/route.js +2 -2
- package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/catalog/route.js +1 -1
- package/bundle/.next/server/app/api/models/catalog/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/providers/route.js +1 -1
- package/bundle/.next/server/app/api/models/providers/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/models/route.js +2 -2
- package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/route.js +2 -2
- package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/openclaw/capabilities/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/openclaw/compatibility-smoke/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/route.js +1 -1
- package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/reset/route.js +2 -2
- package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/config-pacing/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js +1 -1
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/workspace-root/route.js +1 -1
- package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/stream/route.js +2 -2
- package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/control/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/control/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js +2 -2
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/update/route.js +2 -2
- package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/reconcile/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/reconcile/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/route.js +2 -2
- package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/bundle/.next/server/app/dashboard/page.js +1 -1
- package/bundle/.next/server/app/dashboard/page.js.nft.json +1 -1
- package/bundle/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/files/page.js +1 -1
- package/bundle/.next/server/app/files/page.js.nft.json +1 -1
- package/bundle/.next/server/app/files/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/integrations/page.js +1 -1
- package/bundle/.next/server/app/integrations/page.js.nft.json +1 -1
- package/bundle/.next/server/app/integrations/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/mission-control/page.js +1 -1
- package/bundle/.next/server/app/mission-control/page.js.nft.json +1 -1
- package/bundle/.next/server/app/mission-control/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/models/page.js +1 -1
- package/bundle/.next/server/app/models/page.js.nft.json +1 -1
- package/bundle/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/page.js +1 -1
- package/bundle/.next/server/app/page.js.nft.json +1 -1
- package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/settings/page.js +1 -1
- package/bundle/.next/server/app/settings/page.js.nft.json +1 -1
- package/bundle/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/tasks/page.js +1 -1
- package/bundle/.next/server/app/tasks/page.js.nft.json +1 -1
- package/bundle/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app-paths-manifest.json +2 -2
- package/bundle/.next/server/chunks/4020.js +2 -2
- package/bundle/.next/server/chunks/4391.js +2 -2
- package/bundle/.next/server/chunks/4983.js +2 -2
- package/bundle/.next/server/chunks/5110.js +1 -1
- package/bundle/.next/server/chunks/7092.js +1 -1
- package/bundle/.next/server/chunks/7639.js +1 -1
- package/bundle/.next/server/chunks/{4767.js → 849.js} +11 -9
- package/bundle/.next/server/middleware-build-manifest.js +1 -1
- package/bundle/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/bundle/.next/server/pages/404.html +1 -1
- package/bundle/.next/server/pages/500.html +1 -1
- package/bundle/.next/server/server-reference-manifest.json +1 -1
- package/bundle/.next/static/chunks/2125-550587dbe8706439.js +3 -0
- package/bundle/.next/static/chunks/5922-156b66daaaf768a5.js +174 -0
- package/bundle/.next/static/chunks/7197.43cef56b1689bb96.js +1 -0
- package/bundle/.next/static/chunks/{7442-f6bbc0b14b5ca5e5.js → 7442-305daba070b016f8.js} +10 -10
- package/bundle/.next/static/chunks/webpack-b743b1572b052c61.js +1 -0
- package/bundle/.next/static/css/b65c0ec3db2a737c.css +3 -0
- package/bundle/public/assets/screenshots/0.jpeg +0 -0
- package/bundle/public/assets/screenshots/8.jpeg +0 -0
- package/bundle/public/assets/screenshots/hero.jpeg +0 -0
- package/package.json +1 -1
- package/bundle/.next/static/chunks/2125-ee3186e76863c0c0.js +0 -3
- package/bundle/.next/static/chunks/5922-bd40755edb9a1242.js +0 -174
- package/bundle/.next/static/chunks/7197.9a3977e98b2a1fe9.js +0 -1
- package/bundle/.next/static/chunks/webpack-82d9aaa9ef1f9bdf.js +0 -1
- package/bundle/.next/static/css/2f74db4938189dc1.css +0 -3
- /package/bundle/.next/static/{9xNgkJTOL7J6_GGDUZWeG → EEOvGgtsvMlezk0mE5jQb}/_buildManifest.js +0 -0
- /package/bundle/.next/static/{9xNgkJTOL7J6_GGDUZWeG → EEOvGgtsvMlezk0mE5jQb}/_ssgManifest.js +0 -0
|
@@ -182,4 +182,4 @@ ${f.join("\n\n")}
|
|
|
182
182
|
`:""}let S=[{value:"empty",label:"Empty workspace",description:"Create a fresh project folder and scaffold the shared OpenClaw context."},{value:"clone",label:"Clone repo",description:"Clone a repository first, then layer workspace docs, memory, and agents on top."},{value:"existing",label:"Use existing folder",description:"Attach OpenClaw to a folder that already exists and preserve any current files."}],T=[{value:"software",label:"Software project",description:"Balanced software delivery setup for product and engineering work."},{value:"frontend",label:"Frontend app",description:"UI-focused team with browser coverage and product-facing documentation."},{value:"backend",label:"Backend/API",description:"Service and API template with strong testing and delivery defaults."},{value:"research",label:"Research",description:"Exploration-first workspace for investigation, synthesis, and durable notes."},{value:"content",label:"Content/Growth",description:"Campaign and content setup for strategy, writing, review, and analytics."}],U=[{value:"solo",label:"Solo",description:"One primary agent with a shared workspace scaffold."},{value:"core",label:"Core team",description:"Multi-agent setup with role-specific specialists and a strong shared context."},{value:"custom",label:"Custom",description:"Start from a recommended team and toggle which specialist agents are enabled."}],V=[{value:"balanced",label:"Balanced",description:"General-purpose default for daily execution, review, and coordination."},{value:"fast",label:"Fast",description:"Favor speed and iteration for high-throughput tasking and first passes."},{value:"quality",label:"Quality",description:"Favor deeper reasoning and more careful outputs for critical work."}],W={workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0},X={software:{label:"Software project",description:"Default project template for engineering delivery.",icon:"\uD83D\uDEE0"},frontend:{label:"Frontend app",description:"UI and experience work with browser-aware support.",icon:"\uD83C\uDFA8"},backend:{label:"Backend/API",description:"Services, infrastructure, and backend-oriented workflows.",icon:"⚙️"},research:{label:"Research",description:"Investigation-heavy workspace with synthesis and memory capture.",icon:"\uD83E\uDDE0"},content:{label:"Content/Growth",description:"Messaging, content production, campaign review, and analysis.",icon:"\uD83D\uDCE3"}},Y={software:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements requested changes and drives delivery forward."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews work for correctness, regressions, and product risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates behavior, tests, and environment assumptions."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Consolidates durable project knowledge and memory."}],frontend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements UI and frontend product work."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews interaction, correctness, and regression risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Checks behavior, responsive states, and verification gaps."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains stable product and implementation knowledge."},{id:"browser",role:"Browser Agent",name:"Browser Agent",emoji:"\uD83C\uDF10",theme:"blue",skillId:"project-browser",description:"Exercises browser flows, captures UI evidence, and validates user paths."}],backend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements service, API, and infrastructure changes."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Catches correctness, data handling, and operational risks."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates APIs, background jobs, migrations, and failure paths."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains architecture notes and durable operational memory."}],research:[{id:"researcher",role:"Research Lead",name:"Research Lead",emoji:"\uD83D\uDD2C",theme:"violet",skillId:"project-researcher",isPrimary:!0,description:"Runs investigations, frames questions, and synthesizes findings."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Pressure-tests claims, assumptions, and interpretation quality."},{id:"learner",role:"Archivist",name:"Archivist",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Distills durable research notes, memory, and takeaways."}],content:[{id:"strategist",role:"Strategist",name:"Strategist",emoji:"\uD83D\uDCE3",theme:"orange",skillId:"project-strategist",isPrimary:!0,description:"Frames audience, goals, positioning, and campaign direction."},{id:"writer",role:"Writer",name:"Writer",emoji:"✍️",theme:"sky",skillId:"project-writer",description:"Drafts content, messaging, and campaign assets."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Edits for clarity, quality, and consistency."},{id:"analyst",role:"Analyst",name:"Analyst",emoji:"\uD83D\uDCC8",theme:"emerald",skillId:"project-analyst",description:"Tracks results, experiments, and performance insights."}]};function Z(a,b,c){let d=Y[a];if("solo"===b){let a=d.find(a=>a.isPrimary)??d[0];return[{...a,name:$(c,a.role,"Builder"===a.role?"Default Agent":a.name),policy:(0,A.g0)("browser"===a.id?"browser":"worker"),enabled:!0}]}return d.map(a=>({id:a.id,role:a.role,name:a.isPrimary?$(c,a.role,a.name):a.name,emoji:a.emoji,theme:a.theme,skillId:a.skillId,modelId:a.modelId,isPrimary:!!a.isPrimary,policy:(0,A.g0)("browser"===a.id?"browser":"worker"),enabled:!0}))}function $(a,b,c){let d=function(a){let b=a?.trim();if(!b)return"";let c=(!/\s/.test(b)&&b.includes(".")?b.split(".")[0]:b).replace(/[^A-Za-z0-9\u00C0-\u024F]+/g," ").trim();return c?c.split(/\s+/).filter(Boolean).map(a=>a[0].toUpperCase()+a.slice(1)).join(" "):""}(a);if(!d)return c;let e=b.trim();return e?`${d} ${e}`:d}function _({open:a,surfaceTheme:b,plan:c,focus:f,busy:h=!1,onClose:i,onSave:j}){var k;let[l,m]=(0,p.useState)(()=>"raw"===f?"raw":"fields"),[n,o]=(0,p.useState)(()=>{var a;return c?{companyName:(a=c).company.name,companyMission:a.company.mission,companyTargetCustomer:a.company.targetCustomer,companyConstraints:ab(a.company.constraints),companySuccessSignals:ab(a.company.successSignals),productOffer:a.product.offer,productRevenueModel:a.product.revenueModel,productScopeV1:ab(a.product.scopeV1),productNonGoals:ab(a.product.nonGoals),productLaunchPriority:ab(a.product.launchPriority),workspaceName:a.workspace.name,workspaceDirectory:a.workspace.directory??"",workspaceSourceMode:a.workspace.sourceMode,workspaceRepoUrl:a.workspace.repoUrl??"",workspaceExistingPath:a.workspace.existingPath??"",workspaceTemplate:a.workspace.template,workspaceModelProfile:a.workspace.modelProfile,workspaceModelId:a.workspace.modelId??"",workspaceStackDecisions:ab(a.workspace.stackDecisions),workspaceDocs:ab(a.workspace.docs),workspaceRuleGenerateStarterDocs:a.workspace.rules.generateStarterDocs,workspaceRuleGenerateMemory:a.workspace.rules.generateMemory,workspaceRuleKickoffMission:a.workspace.rules.kickoffMission,intakeReviewRequested:a.intake.reviewRequested,intakeAutopilot:a.autopilot,teamAllowEphemeralSubagents:a.team.allowEphemeralSubagents,teamMaxParallelRuns:String(a.team.maxParallelRuns),teamEscalationRules:ab(a.team.escalationRules),deployBlockers:ab(a.deploy.blockers),deployWarnings:ab(a.deploy.warnings),deployFirstMissions:ab(a.deploy.firstMissions)}:null}),[q,s]=(0,p.useState)(()=>c?JSON.stringify(c,null,2):""),[w,A]=(0,p.useState)(null),B=(0,p.useRef)({}),C=(0,p.useRef)({}),D="light"===b,E=f&&"raw"!==f?function(a){if("raw"===a)return"workspace";let[b]=a.split(".");return b}(f):null,F=f&&"raw"!==f&&(k=f).includes(".")?k:null,G=!!(c&&n);if(!a||!c||!n)return null;let H=(a,b)=>{o(c=>c?{...c,[a]:b}:c)},I=a=>b=>{C.current[a]=b},J=async()=>{var a,b,d,e;let f,g,h,k,l,m,o,p,q=(a=c,b=n,f=structuredClone(a),g=a.company.name.trim(),h=a.workspace.name.trim(),k=b.companyName.trim(),l=b.workspaceName.trim(),m=k!==g,o=l!==h,f.company.name=k,f.company.mission=b.companyMission.trim(),f.company.targetCustomer=b.companyTargetCustomer.trim(),f.company.constraints=ac(b.companyConstraints),f.company.successSignals=ac(b.companySuccessSignals),f.product.offer=b.productOffer.trim(),f.product.revenueModel=b.productRevenueModel.trim(),f.product.scopeV1=ac(b.productScopeV1),f.product.nonGoals=ac(b.productNonGoals),f.product.launchPriority=ac(b.productLaunchPriority),f.workspace.name=l,f.workspace.directory=ad(b.workspaceDirectory),f.workspace.sourceMode=b.workspaceSourceMode,f.workspace.repoUrl=ad(b.workspaceRepoUrl),f.workspace.existingPath=ad(b.workspaceExistingPath),f.workspace.template=b.workspaceTemplate,f.workspace.modelProfile=b.workspaceModelProfile,f.workspace.modelId=ad(b.workspaceModelId),f.workspace.stackDecisions=ac(b.workspaceStackDecisions),f.workspace.docs=ac(b.workspaceDocs),f.workspace.rules={...f.workspace.rules,workspaceOnly:!0,generateStarterDocs:b.workspaceRuleGenerateStarterDocs,generateMemory:b.workspaceRuleGenerateMemory,kickoffMission:b.workspaceRuleKickoffMission},o&&!m?f.company.name=l:m&&!o&&(f.workspace.name=k),f.team.allowEphemeralSubagents=b.teamAllowEphemeralSubagents,f.team.maxParallelRuns=Number.isFinite(Number(b.teamMaxParallelRuns))?Math.max(1,Number(b.teamMaxParallelRuns)):f.team.maxParallelRuns,f.team.escalationRules=ac(b.teamEscalationRules),f.intake.reviewRequested=b.intakeReviewRequested,f.autopilot=b.intakeAutopilot,f.deploy.blockers=ac(b.deployBlockers),f.deploy.warnings=ac(b.deployWarnings),f.deploy.firstMissions=ac(b.deployFirstMissions),f),r=(d=c,e=q,p=[],(aa(d.company,e.company)&&p.push("company"),aa(d.product,e.product)&&p.push("product"),aa(d.workspace,e.workspace)&&p.push("workspace"),aa(d.team,e.team)&&p.push("team"),aa({reviewRequested:d.intake.reviewRequested,autopilot:d.autopilot},{reviewRequested:e.intake.reviewRequested,autopilot:e.autopilot})&&p.push("intake"),aa(d.deploy,e.deploy)&&p.push("deploy"),0===p.length)?"Manual blueprint edit applied.":`Manual blueprint edit applied to ${p.join(", ")}.`);await j(q,r)&&i()},K=async()=>{try{let a=JSON.parse(q);await j(a,"Manual raw blueprint edit applied.")&&i()}catch(a){A(a instanceof Error?a.message:"Raw JSON could not be parsed.")}};return(0,d.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,d.jsx)("button",{type:"button","aria-label":"Close blueprint editor",onClick:i,className:(0,r.cn)("absolute inset-0 h-full w-full cursor-default",D?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,d.jsxs)("div",{className:(0,r.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[760px]",D?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:(0,r.cn)("flex items-start justify-between gap-4 border-b px-4 py-4 md:px-5",D?"border-[#e7dfd4]":"border-white/10"),children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",D?"text-[#9a9085]":"text-slate-500"),children:"Blueprint editor"}),(0,d.jsx)("h2",{className:(0,r.cn)("mt-1 text-[18px] font-semibold tracking-[-0.03em]",D?"text-[#171410]":"text-white"),children:"Edit any detail, then keep chatting with Architect"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",D?"text-[#6f675e]":"text-slate-300"),children:"Structured fields cover the common edits. Raw JSON lets you change anything else in the same plan."})]}),(0,d.jsx)("button",{type:"button",onClick:i,className:(0,r.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",D?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,d.jsx)(e.A,{className:"h-4 w-4"})})]}),(0,d.jsxs)("div",{className:(0,r.cn)("flex items-center gap-2 border-b px-4 py-3 md:px-5",D?"border-[#e7dfd4]":"border-white/10"),children:[(0,d.jsx)(ae,{surfaceTheme:b,label:`Stage \xb7 ${c.stage}`}),(0,d.jsx)(ae,{surfaceTheme:b,label:`Status \xb7 ${c.status}`}),(0,d.jsx)(ae,{surfaceTheme:b,label:`Readiness \xb7 ${c.readinessScore}%`})]}),(0,d.jsxs)(y.tU,{value:l,onValueChange:a=>m(a),className:"flex min-h-0 flex-1 flex-col px-4 py-4 md:px-5",children:[(0,d.jsxs)(y.j7,{className:(0,r.cn)("w-fit",D?"bg-[#f2ece4] text-[#645b52]":"bg-white/5"),children:[(0,d.jsx)(y.Xi,{value:"fields",children:"Fields"}),(0,d.jsx)(y.Xi,{value:"raw",children:"Raw JSON"})]}),(0,d.jsx)(y.av,{value:"fields",className:"min-h-0 flex-1",children:(0,d.jsx)(x.F,{className:"h-full pr-1",children:(0,d.jsxs)("div",{className:"space-y-4 pb-4",children:[(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,d.jsxs)(af,{surfaceTheme:b,sectionId:"company",highlighted:"company"===E,title:"Company",description:"Mission and audience details.",register:a=>{B.current.company=a},children:[(0,d.jsx)(ag,{label:"Name",children:(0,d.jsx)(v.p,{ref:I("company.name"),value:n.companyName,onChange:a=>H("companyName",a.target.value)})}),(0,d.jsx)(ag,{label:"Mission",children:(0,d.jsx)(z.T,{ref:I("company.mission"),value:n.companyMission,onChange:a=>H("companyMission",a.target.value),className:"min-h-[96px]"})}),(0,d.jsx)(ag,{label:"Target customer",children:(0,d.jsx)(v.p,{ref:I("company.targetCustomer"),value:n.companyTargetCustomer,onChange:a=>H("companyTargetCustomer",a.target.value)})}),(0,d.jsx)(ag,{label:"Constraints",children:(0,d.jsx)(z.T,{ref:I("company.constraints"),value:n.companyConstraints,onChange:a=>H("companyConstraints",a.target.value),placeholder:"One constraint per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"Success signals",children:(0,d.jsx)(z.T,{ref:I("company.successSignals"),value:n.companySuccessSignals,onChange:a=>H("companySuccessSignals",a.target.value),placeholder:"One signal per line",className:"min-h-[84px]"})})]}),(0,d.jsxs)(af,{surfaceTheme:b,sectionId:"product",highlighted:"product"===E,title:"Product",description:"Offer and V1 shape.",register:a=>{B.current.product=a},children:[(0,d.jsx)(ag,{label:"Offer",children:(0,d.jsx)(z.T,{ref:I("product.offer"),value:n.productOffer,onChange:a=>H("productOffer",a.target.value),className:"min-h-[96px]"})}),(0,d.jsx)(ag,{label:"Revenue model",children:(0,d.jsx)(v.p,{ref:I("product.revenueModel"),value:n.productRevenueModel,onChange:a=>H("productRevenueModel",a.target.value)})}),(0,d.jsx)(ag,{label:"Scope V1",children:(0,d.jsx)(z.T,{ref:I("product.scopeV1"),value:n.productScopeV1,onChange:a=>H("productScopeV1",a.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"Non-goals",children:(0,d.jsx)(z.T,{ref:I("product.nonGoals"),value:n.productNonGoals,onChange:a=>H("productNonGoals",a.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"Launch priority",children:(0,d.jsx)(z.T,{ref:I("product.launchPriority"),value:n.productLaunchPriority,onChange:a=>H("productLaunchPriority",a.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]})]}),(0,d.jsxs)(af,{surfaceTheme:b,sectionId:"workspace",highlighted:"workspace"===E,title:"Workspace",description:"Provisioning path and bootstrap rules.",register:a=>{B.current.workspace=a},children:[(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,d.jsx)(ag,{label:"Workspace name",children:(0,d.jsx)(v.p,{ref:I("workspace.name"),value:n.workspaceName,onChange:a=>H("workspaceName",a.target.value)})}),(0,d.jsx)(ag,{label:"Workspace directory",children:(0,d.jsx)(v.p,{ref:I("workspace.directory"),value:n.workspaceDirectory,onChange:a=>H("workspaceDirectory",a.target.value)})}),(0,d.jsx)(ag,{label:"Repository URL",children:(0,d.jsx)(v.p,{ref:I("workspace.repoUrl"),value:n.workspaceRepoUrl,onChange:a=>H("workspaceRepoUrl",a.target.value)})}),(0,d.jsx)(ag,{label:"Existing folder path",children:(0,d.jsx)(v.p,{ref:I("workspace.existingPath"),value:n.workspaceExistingPath,onChange:a=>H("workspaceExistingPath",a.target.value)})}),(0,d.jsx)(ag,{label:"Model id",children:(0,d.jsx)(v.p,{ref:I("workspace.modelId"),value:n.workspaceModelId,onChange:a=>H("workspaceModelId",a.target.value)})})]}),(0,d.jsx)(ah,{surfaceTheme:b,label:"Source mode",value:n.workspaceSourceMode,options:S,onChange:a=>H("workspaceSourceMode",a),fieldRef:I("workspace.sourceMode"),highlighted:"workspace.sourceMode"===F}),(0,d.jsx)(ah,{surfaceTheme:b,label:"Template",value:n.workspaceTemplate,options:T,onChange:a=>H("workspaceTemplate",a),fieldRef:I("workspace.template"),highlighted:"workspace.template"===F}),(0,d.jsx)(ah,{surfaceTheme:b,label:"Model profile",value:n.workspaceModelProfile,options:V,onChange:a=>H("workspaceModelProfile",a),fieldRef:I("workspace.modelProfile"),highlighted:"workspace.modelProfile"===F}),(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,d.jsx)(ag,{label:"Stack decisions",children:(0,d.jsx)(z.T,{ref:I("workspace.stackDecisions"),value:n.workspaceStackDecisions,onChange:a=>H("workspaceStackDecisions",a.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"Docs",children:(0,d.jsx)(z.T,{ref:I("workspace.docs"),value:n.workspaceDocs,onChange:a=>H("workspaceDocs",a.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]}),(0,d.jsx)(ai,{surfaceTheme:b,label:"Starter docs",description:"Generate the first brief, architecture, and deliverables scaffold.",checked:n.workspaceRuleGenerateStarterDocs,onToggle:()=>H("workspaceRuleGenerateStarterDocs",!n.workspaceRuleGenerateStarterDocs),fieldRef:I("workspace.ruleGenerateStarterDocs"),highlighted:"workspace.ruleGenerateStarterDocs"===F}),(0,d.jsx)(ai,{surfaceTheme:b,label:"Memory",description:"Generate the persistent memory files for blueprint decisions.",checked:n.workspaceRuleGenerateMemory,onToggle:()=>H("workspaceRuleGenerateMemory",!n.workspaceRuleGenerateMemory),fieldRef:I("workspace.ruleGenerateMemory"),highlighted:"workspace.ruleGenerateMemory"===F}),(0,d.jsx)(ai,{surfaceTheme:b,label:"Kickoff mission",description:"Run the first mission immediately after bootstrap.",checked:n.workspaceRuleKickoffMission,onToggle:()=>H("workspaceRuleKickoffMission",!n.workspaceRuleKickoffMission),fieldRef:I("workspace.ruleKickoffMission"),highlighted:"workspace.ruleKickoffMission"===F})]}),(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,d.jsxs)(af,{surfaceTheme:b,sectionId:"team",highlighted:"team"===E,title:"Team",description:"Planner behavior and coordination rules.",register:a=>{B.current.team=a},children:[(0,d.jsx)(ai,{surfaceTheme:b,label:"Allow ephemeral subagents",description:"Let the planner spin up temporary helpers when useful.",checked:n.teamAllowEphemeralSubagents,onToggle:()=>H("teamAllowEphemeralSubagents",!n.teamAllowEphemeralSubagents),fieldRef:I("team.allowEphemeralSubagents"),highlighted:"team.allowEphemeralSubagents"===F}),(0,d.jsx)(ai,{surfaceTheme:b,label:"Autopilot",description:"Let the planner take a stronger lead when the shape is clear.",checked:n.intakeAutopilot,onToggle:()=>H("intakeAutopilot",!n.intakeAutopilot),fieldRef:I("team.autopilot"),highlighted:"team.autopilot"===F}),(0,d.jsx)(ai,{surfaceTheme:b,label:"Review requested",description:"Keep the planner in a review-heavy shaping mode.",checked:n.intakeReviewRequested,onToggle:()=>H("intakeReviewRequested",!n.intakeReviewRequested),fieldRef:I("team.reviewRequested"),highlighted:"team.reviewRequested"===F}),(0,d.jsx)(ag,{label:"Max parallel runs",children:(0,d.jsx)(v.p,{ref:I("team.maxParallelRuns"),type:"number",min:1,value:n.teamMaxParallelRuns,onChange:a=>H("teamMaxParallelRuns",a.target.value)})}),(0,d.jsx)(ag,{label:"Escalation rules",children:(0,d.jsx)(z.T,{ref:I("team.escalationRules"),value:n.teamEscalationRules,onChange:a=>H("teamEscalationRules",a.target.value),placeholder:"One rule per line",className:"min-h-[84px]"})})]}),(0,d.jsxs)(af,{surfaceTheme:b,sectionId:"deploy",highlighted:"deploy"===E,title:"Deploy",description:"Review blockers, warnings, and first missions.",register:a=>{B.current.deploy=a},children:[(0,d.jsx)(ag,{label:"Blockers",children:(0,d.jsx)(z.T,{ref:I("deploy.blockers"),value:n.deployBlockers,onChange:a=>H("deployBlockers",a.target.value),placeholder:"One blocker per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"Warnings",children:(0,d.jsx)(z.T,{ref:I("deploy.warnings"),value:n.deployWarnings,onChange:a=>H("deployWarnings",a.target.value),placeholder:"One warning per line",className:"min-h-[84px]"})}),(0,d.jsx)(ag,{label:"First missions",children:(0,d.jsx)(z.T,{ref:I("deploy.firstMissions"),value:n.deployFirstMissions,onChange:a=>H("deployFirstMissions",a.target.value),placeholder:"One mission per line",className:"min-h-[84px]"})})]}),(0,d.jsxs)(af,{surfaceTheme:b,title:"Note",description:"What happens on save?",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] leading-6",D?"text-[#6f675e]":"text-slate-300"),children:"Derived plan fields like readiness score, stage, and recommended missions are recalculated after you save."}),(0,d.jsx)("p",{className:(0,r.cn)("mt-3 text-[13px] leading-6",D?"text-[#6f675e]":"text-slate-300"),children:"If you want to edit something that is not shown here, switch to Raw JSON and change the exact nested field."})]})]})]})})}),(0,d.jsx)(y.av,{value:"raw",className:"min-h-0 flex-1",children:(0,d.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[(0,d.jsx)("div",{className:(0,r.cn)("rounded-[18px] border px-4 py-3",D?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] leading-6",D?"text-[#6f675e]":"text-slate-300"),children:"This view edits the full blueprint JSON. It is the fastest way to change nested fields, agents, workflows, and any other detail."})}),(0,d.jsx)(z.T,{value:q,onChange:a=>{s(a.target.value),A(null)},className:(0,r.cn)("min-h-0 flex-1 font-mono text-[12px] leading-5",D?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100")}),w?(0,d.jsx)("p",{className:"rounded-xl border border-rose-300/30 bg-rose-500/10 px-3 py-2 text-[13px] leading-5 text-rose-200",children:w}):null,(0,d.jsx)("p",{className:(0,r.cn)("text-[12px] leading-5",D?"text-[#7b7268]":"text-slate-400"),children:"Current draft JSON snapshot loaded on open. Changes are saved through the same planner draft path as the structured editor."})]})})]}),(0,d.jsxs)("div",{className:(0,r.cn)("flex items-center justify-between gap-3 border-t px-4 py-4 md:px-5",D?"border-[#e7dfd4]":"border-white/10"),children:[(0,d.jsx)(u.$,{type:"button",variant:"secondary",onClick:i,className:D?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Cancel"}),(0,d.jsxs)(u.$,{type:"button",onClick:"raw"===l?K:J,disabled:!G||h,className:D?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[h?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(t.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]})]})]})}function aa(a,b){return JSON.stringify(a)!==JSON.stringify(b)}function ab(a){return a.join("\n")}function ac(a){return a.split(/\r?\n/).map(a=>a.trim()).filter(Boolean)}function ad(a){let b=a.trim();return b.length>0?b:void 0}function ae({surfaceTheme:a,label:b}){return(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","light"===a?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),children:b})}function af({surfaceTheme:a,sectionId:b,highlighted:c=!1,title:e,description:f,register:g,children:h}){let i="light"===a;return(0,d.jsxs)("section",{ref:g,"data-blueprint-section":b,className:(0,r.cn)("rounded-[22px] border p-4 transition-all duration-300",i?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]",c&&(i?"ring-2 ring-[#d8b184]/70 shadow-[0_0_0_1px_rgba(216,177,132,0.18),0_18px_36px_rgba(102,78,47,0.16)]":"ring-2 ring-cyan-300/45 shadow-[0_0_0_1px_rgba(103,232,249,0.14),0_18px_36px_rgba(6,182,212,0.16)]")),children:[(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",i?"text-[#a0978b]":"text-slate-500"),children:e}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",i?"text-[#6f675e]":"text-slate-300"),children:f})]}),(0,d.jsx)("div",{className:"space-y-4",children:h})]})}function ag({label:a,children:b}){return(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)(w.J,{children:a}),b]})}function ah({surfaceTheme:a,label:b,value:c,options:e,onChange:f,fieldRef:g,highlighted:h=!1}){let i="light"===a;return(0,d.jsxs)("div",{ref:g,tabIndex:-1,className:(0,r.cn)("space-y-2 rounded-[18px] border p-3 transition-all",i?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",h&&(i?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),children:[(0,d.jsx)(w.J,{children:b}),(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:e.map(a=>{let b=a.value===c;return(0,d.jsx)("button",{type:"button",onClick:()=>f(a.value),className:(0,r.cn)("rounded-[16px] border px-3 py-3 text-left transition-colors",b?i?"border-[#161514] bg-[#161514] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":i?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]"),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[13px] font-medium",children:a.label}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",b?"opacity-80":i?"text-[#70685e]":"text-slate-400"),children:a.description})]}),b?(0,d.jsx)(o.A,{className:"mt-0.5 h-4 w-4 shrink-0"}):null]})},a.value)})})]})}function ai({surfaceTheme:a,label:b,description:c,checked:e,onToggle:f,fieldRef:g,highlighted:h=!1}){let i="light"===a;return(0,d.jsx)("button",{type:"button",onClick:f,ref:g,className:(0,r.cn)("w-full rounded-[16px] border px-3 py-3 text-left transition-colors",e?i?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":i?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]",h&&(i?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[13px] font-medium",children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",e?"opacity-80":i?"text-[#70685e]":"text-slate-400"),children:c})]}),(0,d.jsx)("span",{className:(0,r.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full border",e?i?"border-white/25 bg-white text-[#171410]":"border-white/20 bg-white text-slate-950":i?"border-[#cfc6ba] bg-transparent text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})})]})})}var aj=c(84086);function ak({open:a,surfaceTheme:b,plan:c,path:f,busy:i=!1,rewriteBusy:j=!1,onClose:k,onSave:l,onRewriteWithArchitect:m}){let n="light"===b,o=(0,p.useMemo)(()=>a&&c?M({name:c.workspace.name||"Workspace",brief:c.company.mission||c.product.offer||void 0,template:c.workspace.template,sourceMode:c.workspace.sourceMode,rules:c.workspace.rules,agents:c.team.persistentAgents.filter(a=>a.enabled),docOverrides:c.workspace.docOverrides,toolExamples:[],contextSources:c.intake.sources}).find(a=>a.path===f)??null:null,[a,f,c]),[q,s]=(0,p.useState)(()=>o?.content??""),[v,w]=(0,p.useState)(""),[y,A]=(0,p.useState)(null),B=i||j||!!y;if(!a||!c||!o)return null;let C=async()=>{let a=await m({path:o.path,currentContent:q,instruction:v.trim()||void 0});if(!a)return;let b=function(a,b){if(a===b)return null;let c=a.split(/\r?\n/),d=b.split(/\r?\n/),e=0;for(;e<c.length&&e<d.length&&c[e]===d[e];)e+=1;let f=0;for(;f<c.length-e&&f<d.length-e&&c[c.length-1-f]===d[d.length-1-f];)f+=1;let g=d.slice(0,e),h=c.slice(e,c.length-f),i=d.slice(e,d.length-f),j=d.slice(d.length-f),k=i.join("\n"),l=Array.from(k).length;return{prefixLines:g,changedFromLines:h,changedToLines:i,suffixLines:j,changedToText:k,changedToCharCount:l,revealedCharCount:0,nextContent:b}}(q,a);if(!b){s(a),w("");return}A(b),w("")},D=async()=>{let a=structuredClone(c),b=N([...a.workspace.docOverrides.filter(a=>a.path!==o.path),...q===o.baseContent?[]:[{path:o.path,content:q}]]);a.workspace.docOverrides=b;let d=q===o.baseContent?o.generated?`Reset ${o.path} to the generated default scaffold.`:`Kept ${o.path} at the loaded workspace content.`:o.generated?`Updated ${o.path} scaffold content.`:`Updated ${o.path} existing file content.`;await l(a,d)&&k()};return(0,d.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,d.jsx)("button",{type:"button","aria-label":"Close document editor",onClick:k,className:(0,r.cn)("absolute inset-0 h-full w-full cursor-default",n?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,d.jsxs)("div",{className:(0,r.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[860px]",n?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:(0,r.cn)("flex items-center justify-between gap-4 border-b px-4 py-3 md:px-5",n?"border-[#e7dfd4]":"border-white/10"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#9a9085]":"text-slate-500"),children:"Document editor"}),(0,d.jsx)("span",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#c2b6a5]":"text-slate-600"),children:"/"}),(0,d.jsx)("p",{className:(0,r.cn)("truncate font-mono text-[12px]",n?"text-[#4a433b]":"text-slate-300"),children:o.path}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",o.generated?o.overridden?n?"border-emerald-200 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":n?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400":n?"border-cyan-200 bg-cyan-50 text-cyan-900":"border-cyan-300/25 bg-cyan-300/12 text-cyan-100"),children:o.generated?o.overridden?"Customized":"Generated":"Existing"})]}),(0,d.jsx)("button",{type:"button",onClick:k,className:(0,r.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",n?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,d.jsx)(e.A,{className:"h-4 w-4"})})]}),(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 py-3 md:px-5",children:[(0,d.jsx)(x.F,{className:"min-h-0 flex-1",children:y?(0,d.jsx)(al,{surfaceTheme:b,animation:y}):(0,d.jsx)(z.T,{value:q,onChange:a=>s(a.target.value),className:(0,r.cn)("min-h-[60vh] font-mono text-[12px] leading-5",n?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:B})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t pt-2",style:{borderColor:n?"#e7dfd4":"rgba(255,255,255,0.1)"},children:[(0,d.jsx)(u.$,{type:"button",variant:"secondary",onClick:()=>{s(o.baseContent)},disabled:B,className:n?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:o.generated?"Reset to default":"Reset to loaded content"}),(0,d.jsxs)(u.$,{type:"button",onClick:D,disabled:B,className:n?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[i?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(t.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}),(0,d.jsx)("div",{className:(0,r.cn)("rounded-[18px] border px-4 py-3",n?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,d.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr),auto] md:items-end",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("label",{htmlFor:"architect-rewrite-prompt",className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8b8278]":"text-slate-400"),children:"Architect instructions"}),(0,d.jsx)(z.T,{id:"architect-rewrite-prompt",value:v,onChange:a=>w(a.target.value),placeholder:"Tell Architect what to rewrite in this document.",className:(0,r.cn)("mt-2 min-h-[88px] font-sans text-[13px] leading-6",n?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:B}),(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[12px] leading-5",n?"text-[#7b7268]":"text-slate-400"),children:"Leave it blank for a general pass. Architect will rewrite only the changed block and keep the rest intact."})]}),(0,d.jsxs)(u.$,{type:"button",variant:"secondary",onClick:C,disabled:B,className:n?"rounded-full border-[#d8d0c4] bg-[#f8f3eb] text-[#3f3831] hover:bg-[#f1ebe4]":"rounded-full border-cyan-300/20 bg-cyan-300/10 text-cyan-100 hover:bg-cyan-300/16",children:[j?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Rewrite with Architect"]})]})})]})]})]})}function al({surfaceTheme:a,animation:b}){var c,e;let f="light"===a,g=(0,r.cn)("whitespace-pre-wrap break-words rounded-lg border px-3 py-2",f?"border-[#e4ddd2] bg-white text-[#1a1714]":"border-white/10 bg-[#040810] text-slate-100"),h=(c=b.changedToText,(e=b.revealedCharCount)<=0?"":Array.from(c).slice(0,e).join(""));return(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-4 py-3",f?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:(0,r.cn)("flex items-center justify-between gap-2 whitespace-nowrap text-[9px] uppercase tracking-[0.18em] leading-none",f?"text-[#8b8278]":"text-slate-400"),children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:"Rewriting"}),(0,d.jsxs)("span",{className:(0,r.cn)("shrink-0 rounded-full border px-2 py-0.5",f?"border-[#dfd7cc] bg-[#faf6f1] text-[#6e6458]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[b.revealedCharCount,"/",b.changedToCharCount||1]})]}),(0,d.jsxs)("div",{className:"mt-2 space-y-2 font-mono text-[12px] leading-5",children:[b.prefixLines.length?(0,d.jsx)("div",{className:(0,r.cn)("space-y-1.5",f?"text-[#27231e]":"text-slate-100"),children:b.prefixLines.map((a,b)=>(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a||"\xa0"},`prefix-${b}`))}):null,(0,d.jsx)("div",{className:(0,r.cn)("rounded-2xl border px-3 py-2.5",f?"border-[#d8cdbc] bg-[#f9f5ef]":"border-cyan-300/20 bg-cyan-300/6"),children:(0,d.jsxs)("div",{className:"grid gap-2 md:grid-cols-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",f?"text-[#968a7c]":"text-slate-400"),children:"Old"}),(0,d.jsx)("div",{className:g,children:b.changedFromLines.length?b.changedFromLines.map((a,b)=>(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words opacity-55 line-through",children:a||"\xa0"},`before-${b}`)):(0,d.jsx)("div",{className:"opacity-45",children:"[empty]"})})]}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",f?"text-[#968a7c]":"text-slate-400"),children:"New"}),(0,d.jsx)("div",{className:(0,r.cn)(g,"min-h-[96px]"),children:b.changedToCharCount>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"whitespace-pre-wrap break-words",children:h}),b.revealedCharCount<b.changedToCharCount?(0,d.jsx)(aj.P.span,{"aria-hidden":"true",className:(0,r.cn)("ml-0.5 inline-block align-[-0.15em] text-[1.1em] leading-none",f?"text-[#161514]":"text-cyan-100"),animate:{opacity:[0,1,0]},transition:{duration:.8,repeat:1/0,ease:"easeInOut"},children:"|"}):null]}):(0,d.jsx)("span",{className:(0,r.cn)("opacity-45",f?"text-[#7d7266]":"text-slate-400"),children:"[removed]"})})]})]})}),b.suffixLines.length?(0,d.jsx)("div",{className:(0,r.cn)("space-y-1.5",f?"text-[#27231e]":"text-slate-100"),children:b.suffixLines.map((a,b)=>(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words",children:a||"\xa0"},`suffix-${b}`))}):null]})]})}var am=c(63685),an=c(40739),ao=c(50872),ap=c(81187),aq=c(32946),ar=c(49580),as=c(51962),at=c(75682);let au=[{id:"company",label:"Company",icon:ar.A},{id:"product",label:"Product",icon:as.A},{id:"workspace",label:"Workspace",icon:aq.A},{id:"team",label:"Team",icon:j.A},{id:"operations",label:"Operations",icon:at.A},{id:"deploy",label:"Deploy",icon:an.A}],av=[{id:"intake",label:"Intake",section:"company"},{id:"context-harvest",label:"Context",section:"workspace"},{id:"team-synthesis",label:"Team",section:"team"},{id:"pressure-test",label:"Review",section:"operations"},{id:"decision-lock",label:"Lock",section:"deploy"},{id:"ready",label:"Ready",section:"deploy"},{id:"deploying",label:"Deploying",section:"deploy"},{id:"deployed",label:"Live",section:"deploy"}];function aw(a){return av.find(b=>b.id===a)?.label??"Draft"}function ax(a,b){switch(b){case"company":{let b=[a.company.name,a.company.mission,a.company.targetCustomer].filter(a=>!a.trim()).length;return 0===b?{label:"Ready to review",variant:"success"}:{label:`${b} core field${1===b?"":"s"} missing`,variant:"warning"}}case"product":{let b=[+!a.product.offer.trim(),a.product.scopeV1.length>0?0:1,a.product.launchPriority.length>0?0:1].reduce((a,b)=>a+b,0);return 0===b?{label:"Scope is defined",variant:"success"}:{label:`${b} product decision${1===b?"":"s"} pending`,variant:"warning"}}case"workspace":{let b=+!a.workspace.name.trim();return"clone"!==a.workspace.sourceMode||a.workspace.repoUrl?.trim()||(b+=1),"existing"!==a.workspace.sourceMode||a.workspace.existingPath?.trim()||(b+=1),0===b?{label:"Provisioning path set",variant:"success"}:{label:`${b} workspace input${1===b?"":"s"} missing`,variant:"warning"}}case"team":{let b=a.team.persistentAgents.filter(a=>a.enabled).length,c=a.team.persistentAgents.some(a=>a.enabled&&a.isPrimary);if(0===b)return{label:"Add at least one agent",variant:"danger"};if(!c)return{label:"Primary agent missing",variant:"warning"};return{label:`${b} active agent${1===b?"":"s"}`,variant:"success"}}case"operations":{let b=a.operations.workflows.filter(a=>a.enabled).length,c=a.operations.automations.filter(a=>a.enabled).length;if(0===b&&0===c)return{label:"No runtime loops yet",variant:"warning"};return{label:`${b} workflows, ${c} automations`,variant:"success"}}default:if(!a.intake.reviewRequested&&"deploying"!==a.status&&"deployed"!==a.status)return{label:"Review not opened yet",variant:"muted"};if(a.deploy.blockers.length>0)return{label:`${a.deploy.blockers.length} blocker${1===a.deploy.blockers.length?"":"s"}`,variant:"danger"};if(a.deploy.warnings.length>0)return{label:`${a.deploy.warnings.length} warning${1===a.deploy.warnings.length?"":"s"}`,variant:"warning"};return{label:"Ready to deploy",variant:"success"}}}function ay(a,b){switch(b){case"company":return a.company.name?`${a.company.name}${a.company.mission?` \xb7 ${a.company.mission}`:""}`:"Mission and audience are still being shaped.";case"product":return a.product.offer||"Offer and V1 scope are still being drafted.";case"workspace":return`${az(a.workspace.template)} \xb7 ${az(a.workspace.sourceMode)}`;case"team":return`${a.team.persistentAgents.filter(a=>a.enabled).length} agents drafted`;case"operations":return`${a.operations.workflows.filter(a=>a.enabled).length} workflows \xb7 ${a.operations.automations.filter(a=>a.enabled).length} automations`;default:return a.intake.reviewRequested?"Deploy review is open.":"Review not started."}}function az(a){return a.split(/[-_]/g).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}let aA=Object.fromEntries(T.map(a=>[a.value,a.label])),aB={prompt:{label:"Prompt",icon:h.A},website:{label:"Website",icon:l.A},repo:{label:"Repo",icon:k.A},folder:{label:"Folder",icon:m.A}};function aC({surfaceTheme:a,plan:b,variant:c="panel",summaryText:e,className:f,onOpenBlueprintEditor:g,onOpenDocumentEditor:j}){var n;let o,q="light"===a,s=(0,p.useMemo)(()=>K(b.workspace.template,b.workspace.rules),[b.workspace.rules,b.workspace.template]),v=(0,p.useMemo)(()=>new Set(N(b.workspace.docOverrides).map(a=>a.path)),[b.workspace.docOverrides]),w=b.company.name||b.workspace.name||"Workspace",x=b.company.mission||b.product.offer||"Mission still being shaped.",y=b.company.targetCustomer||"Audience still being confirmed.",z=az(b.workspace.sourceMode),A=aA[b.workspace.template],B=az(b.company.type),C=aw(b.stage),D="blocked"===b.status?"Blocked":"ready"===b.status?"Ready":"deployed"===b.status?"Live":"deploying"===b.status?"Deploying":"Draft",E=e?.trim()||b.architectSummary,F=b.intake.sources.find(a=>"ready"===a.status)??b.intake.sources[0]??null,G=b.intake.inferences.slice(0,4),H=s.resources.length,I=((o=(n=w).trim().split(/\s+/).filter(Boolean)).length>1?`${o[0][0]??""}${o[1][0]??""}`:n.slice(0,2)).toUpperCase(),J=F?aB[F.kind].icon:"clone"===b.workspace.sourceMode?k.A:"existing"===b.workspace.sourceMode?m.A:h.A,L=F?F.label:z,M=F?`${aB[F.kind].label} \xb7 ${aN(F.status)}`:z,O=function(a){switch(a){case"blocked":return"danger";case"ready":case"deployed":return"success";case"review":return"warning";default:return"muted"}}(b.status),P="panel"===c,[Q,R]=(0,p.useState)(0),S=P?["Collecting context from the prompt and sources…","Shaping the draft with the first signal set…","Writing the scaffold files now…","Draft ready."]:["Collecting context from the prompt and sources…","Pulling evidence from the website and files…","Extracting structured facts…","Grouping the file scaffold…","Checking remaining decisions…","Draft ready."],T=S[Math.min(Q,S.length-1)]??S[0],U=Q>=1,V=Q>=1,W=Q>=2,X=Q>=(P?3:5),Y=!P&&Q>=3,Z=!P&&Q>=4,$=!P&&Q>=5,_=P?s.sections.filter(a=>a.enabled):s.sections,aa=_.reduce((a,b)=>a+b.resources.length,0),ab=P?aa:H;return P?(0,d.jsxs)("div",{className:(0,r.cn)("workspace-architect-card-enter relative overflow-hidden rounded-[28px] border p-4 md:p-5",q?"border-[#e5ddd2] bg-white shadow-[0_16px_42px_rgba(56,47,38,0.06)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_16px_42px_rgba(0,0,0,0.2)]",f),children:[(0,d.jsx)("div",{className:(0,r.cn)("pointer-events-none absolute inset-0",q?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.14),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.06),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.12),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.12),transparent_42%)]")}),(0,d.jsxs)("div",{className:"relative space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("div",{className:(0,r.cn)("inline-flex size-11 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",q?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:I}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.24em]",q?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,d.jsx)(aE,{surfaceTheme:a,text:w,className:(0,r.cn)("text-[18px] font-semibold tracking-[-0.04em]",q?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:95},`hero-title:${P?"panel":"message"}:${w}`),(0,d.jsx)(aL,{surfaceTheme:a,tone:O,label:D})]}),(0,d.jsx)(aE,{surfaceTheme:a,text:U?E:T,className:(0,r.cn)("workspace-architect-card-enter mt-1 line-clamp-2 text-[12px] leading-5",q?"text-[#6f685f]":"text-slate-300",!U&&"italic"),startDelayMs:80,wordDelayMs:115},`hero-status:${P?"panel":"message"}:${U?E:T}`)]})]}),(0,d.jsxs)("div",{className:"shrink-0 text-right",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",q?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,d.jsxs)("p",{className:(0,r.cn)("mt-1 text-[24px] font-semibold tracking-[-0.05em]",q?"text-[#181612]":"text-white"),children:[b.readinessScore,"%"]}),g?(0,d.jsxs)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>g("workspace.name"),className:q?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] px-3 text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] px-3 text-slate-200 hover:bg-white/[0.08]",children:[(0,d.jsx)(t.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),V?(0,d.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:aO(90),children:[(0,d.jsx)(aD,{surfaceTheme:a,label:"Mission",value:x,icon:h.A,revealDelayMs:120}),(0,d.jsx)(aD,{surfaceTheme:a,label:"Audience",value:y,icon:ap.A,revealDelayMs:220}),(0,d.jsx)(aD,{surfaceTheme:a,label:"Source",value:L,detail:M,icon:J,revealDelayMs:320})]}):null,W?(0,d.jsxs)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:aO(170),children:[(0,d.jsx)(aF,{surfaceTheme:a,label:"Mission",value:aK(x,48),icon:h.A,revealDelayMs:0}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Source",value:aK(L,34),icon:J,revealDelayMs:110}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Template",value:A,icon:aq.A,revealDelayMs:220}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Files",value:String(H),icon:am.A,revealDelayMs:330})]}):null,X?(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,d.jsx)(aG,{surfaceTheme:a,title:"Files",subtitle:`${_.length} groups in the canonical scaffold.`})}),(0,d.jsx)("div",{className:"space-y-2",children:_.map((b,c)=>(0,d.jsxs)("div",{className:(0,r.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",q?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:aO(72*c),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(aE,{surfaceTheme:a,text:b.title,className:(0,r.cn)("text-[13px] font-semibold",q?"text-[#171410]":"text-white"),startDelayMs:120*c,wordDelayMs:70},`files-section-title:${b.id}:${c}:${b.title}`),(0,d.jsx)(aL,{surfaceTheme:a,tone:b.enabled?"success":"muted",label:b.enabled?"Included":"Skipped"})]}),P?null:(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[11px] leading-5",q?"text-[#7a7168]":"text-slate-400"),children:b.description})]}),(0,d.jsxs)("span",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.16em]",q?"text-[#95897c]":"text-slate-500"),children:[b.resources.length," file",1===b.resources.length?"":"s"]})]}),b.resources.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.resources.map((e,f)=>(0,d.jsx)(aJ,{surfaceTheme:a,label:e.label,tone:v.has(e.relativePath)?"success":"core"===b.id?"default":"accent",animated:!0,delayMs:(6*c+f)*88,interactive:!!j,onClick:j?()=>j(e.relativePath):void 0},e.relativePath))}):(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",q?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},b.id))})]}):null]})]}):(0,d.jsxs)("div",{className:(0,r.cn)("workspace-architect-card-enter relative overflow-hidden border",P?"rounded-[28px] p-4 md:p-5":"rounded-[26px] p-3.5 md:p-4",q?"border-[#e5ddd2] bg-white shadow-[0_22px_60px_rgba(56,47,38,0.07)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_22px_60px_rgba(0,0,0,0.22)]",f),children:[(0,d.jsx)("div",{className:(0,r.cn)("pointer-events-none absolute inset-0",q?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.16),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.08),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.18),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.16),transparent_42%)]")}),(0,d.jsxs)("div",{className:"relative space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("div",{className:(0,r.cn)("inline-flex size-12 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",q?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:I}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.24em]",q?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[20px] font-semibold tracking-[-0.04em]",q?"text-[#171410]":"text-white"),children:w}),(0,d.jsx)(aL,{surfaceTheme:a,tone:O,label:D})]}),(0,d.jsx)(aE,{surfaceTheme:a,text:U?E:T,className:(0,r.cn)("workspace-architect-card-enter mt-1 line-clamp-3 text-[13px] leading-6",q?"text-[#6f685f]":"text-slate-300",!U&&"italic"),startDelayMs:80,wordDelayMs:120},`hero-status:${P?"panel":"message"}:${U?E:T}`)]})]}),(0,d.jsxs)("div",{className:"shrink-0 text-right",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",q?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,d.jsxs)("p",{className:(0,r.cn)("mt-1 text-[28px] font-semibold tracking-[-0.05em]",q?"text-[#181612]":"text-white"),children:[b.readinessScore,"%"]}),P&&g?(0,d.jsxs)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>g("workspace.name"),className:q?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,d.jsx)(t.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null]})]}),V?(0,d.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:aO(90),children:[(0,d.jsx)(aD,{surfaceTheme:a,label:"Mission",value:x,icon:h.A,revealDelayMs:120}),(0,d.jsx)(aD,{surfaceTheme:a,label:"Audience",value:y,icon:ap.A,revealDelayMs:220}),(0,d.jsx)(aD,{surfaceTheme:a,label:"Source",value:L,detail:M,icon:J,revealDelayMs:320})]}):null,W?(0,d.jsx)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:aO(170),children:P?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(aF,{surfaceTheme:a,label:"Template",value:A,icon:aq.A,revealDelayMs:0}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Stage",value:C,icon:i.A,revealDelayMs:110}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Files",value:String(ab),icon:am.A,revealDelayMs:220})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(aF,{surfaceTheme:a,label:"Template",value:A,icon:aq.A,revealDelayMs:0}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Company",value:B,icon:ar.A,revealDelayMs:110}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Stage",value:C,icon:i.A,revealDelayMs:220}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Sources",value:String(b.intake.sources.length),icon:l.A,revealDelayMs:330}),(0,d.jsx)(aF,{surfaceTheme:a,label:"Files",value:String(H),icon:am.A,revealDelayMs:440})]})}):null,Y?(0,d.jsxs)("section",{className:"space-y-3",children:[(0,d.jsx)(aG,{surfaceTheme:a,title:"Evidence",subtitle:"What the architect pulled from the prompt, website, repo, or existing folder.",revealDelayMs:0}),b.intake.sources.length>0?(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:b.intake.sources.map((b,c)=>(0,d.jsx)(aH,{surfaceTheme:a,source:b,delayMs:120*c},b.id))}):(0,d.jsx)(aM,{surfaceTheme:a,title:"No sources yet",description:"Add a website, repo, folder, or short brief and the architect will start grounding the draft."})]}):null,Z?(0,d.jsxs)("section",{className:"space-y-3",children:[(0,d.jsx)(aG,{surfaceTheme:a,title:"Inferred facts",subtitle:"Structured fields the architect is using to shape the workspace.",revealDelayMs:0}),G.length>0?(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:G.map((b,c)=>(0,d.jsx)(aI,{surfaceTheme:a,inference:b,delayMs:120*c},b.id))}):(0,d.jsx)(aM,{surfaceTheme:a,title:"No inferences yet",description:"Architect will populate structured facts once it has enough source signal."})]}):null,X?(0,d.jsxs)("section",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)(aG,{surfaceTheme:a,title:"Files to create",subtitle:P?"Canonical scaffold derived from the current workspace rules.":"The same file set the workspace will scaffold on the next pass.",revealDelayMs:0}),(0,d.jsx)(aL,{surfaceTheme:a,tone:"muted",label:`${ab} file${1===ab?"":"s"}`})]}),(0,d.jsx)("div",{className:"space-y-2.5",children:_.map((b,c)=>(0,d.jsxs)("div",{className:(0,r.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",q?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:aO(72*c),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsx)("div",{className:"min-w-0",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] font-semibold",q?"text-[#171410]":"text-white"),children:b.title}),(0,d.jsx)(aL,{surfaceTheme:a,tone:b.enabled?"success":"muted",label:b.enabled?"Included":"Skipped"})]})}),(0,d.jsxs)("span",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.16em]",q?"text-[#95897c]":"text-slate-500"),children:[b.resources.length," file",1===b.resources.length?"":"s"]})]}),b.resources.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.resources.map((e,f)=>(0,d.jsx)(aJ,{surfaceTheme:a,label:e.label,tone:v.has(e.relativePath)?"success":"core"===b.id?"default":"accent",animated:!0,delayMs:(6*c+f)*52,interactive:!!j,onClick:j?()=>j(e.relativePath):void 0},e.relativePath))}):(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",q?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},b.id))})]}):null,$&&b.intake.confirmations.length>0?(0,d.jsxs)("section",{className:"space-y-3",children:[(0,d.jsx)(aG,{surfaceTheme:a,title:"Open decisions",subtitle:"These are the remaining items the architect still wants to confirm."}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.intake.confirmations.map((a,b)=>(0,d.jsxs)("span",{className:(0,r.cn)("workspace-architect-chip-enter inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] leading-4",q?"border-[#ddd6cb] bg-white text-[#6a6157]":"border-white/10 bg-white/[0.05] text-slate-300"),style:aO(48*b),children:[(0,d.jsx)(i.A,{className:"mr-1 h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"max-w-[28rem] truncate",children:a})]},`decision:${b}:${a}`))})]}):null]})]})}function aD({surfaceTheme:a,label:b,value:c,detail:e,icon:f,revealDelayMs:g=0}){let h="light"===a;return(0,d.jsx)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-3",h?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,d.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",h?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(f,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(aE,{surfaceTheme:a,text:b,className:(0,r.cn)("text-[10px] uppercase tracking-[0.18em]",h?"text-[#8f8274]":"text-slate-500"),startDelayMs:g,wordDelayMs:55},`detail-label:${b}:${g}`),(0,d.jsx)(aE,{surfaceTheme:a,text:c,className:(0,r.cn)("mt-1 text-[13px] font-medium leading-5",h?"text-[#171410]":"text-white"),startDelayMs:g+80,wordDelayMs:110},`detail-value:${b}:${g}`),e?(0,d.jsx)(aE,{surfaceTheme:a,text:e,className:(0,r.cn)("mt-1 text-[11px] leading-5",h?"text-[#7a7168]":"text-slate-400"),startDelayMs:g+200,wordDelayMs:95},`detail-extra:${b}:${g}`):null]})]})})}function aE({surfaceTheme:a,text:b,className:c,startDelayMs:e=0,wordDelayMs:f=110}){let g=(0,p.useMemo)(()=>b.trim().split(/\s+/).filter(Boolean),[b]),[h,i]=(0,p.useState)(0);return(0,d.jsxs)("p",{className:c,children:[g.slice(0,h).map((a,b)=>(0,d.jsxs)("span",{children:[b>0?" ":"",a]},`${b}:${a}`)),h<g.length?(0,d.jsx)("span",{"aria-hidden":"true",className:(0,r.cn)("ml-0.5 inline-block animate-pulse","light"===a?"text-[#6f685f]":"text-slate-300"),children:"▍"}):null]})}function aF({surfaceTheme:a,label:b,value:c,icon:e,revealDelayMs:f=0}){let g="light"===a;return(0,d.jsxs)("div",{className:(0,r.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-[11px]",g?"border-[#e4ddd2] bg-white text-[#5f5851]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,d.jsx)(e,{className:"h-3.5 w-3.5 shrink-0"}),(0,d.jsx)(aE,{surfaceTheme:a,text:b,className:"uppercase tracking-[0.16em]",startDelayMs:f,wordDelayMs:55},`stat-label:${b}:${f}`),(0,d.jsx)(aE,{surfaceTheme:a,text:c,className:"font-medium normal-case tracking-normal",startDelayMs:f+80,wordDelayMs:80},`stat-value:${b}:${f}`)]})}function aG({surfaceTheme:a,title:b,subtitle:c,revealDelayMs:e=0}){let f="light"===a;return(0,d.jsxs)("div",{children:[(0,d.jsx)(aE,{surfaceTheme:a,text:b,className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#8f8274]":"text-slate-500"),startDelayMs:e,wordDelayMs:60},`heading-title:${b}:${e}`),(0,d.jsx)(aE,{surfaceTheme:a,text:c,className:(0,r.cn)("mt-1 text-[12px] leading-5",f?"text-[#70665c]":"text-slate-400"),startDelayMs:e+100,wordDelayMs:90},`heading-subtitle:${b}:${e}`)]})}function aH({surfaceTheme:a,source:b,delayMs:c=0}){var e;let f="light"===a,g=aB[b.kind].icon;return(0,d.jsx)("div",{className:(0,r.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",f?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:aO(c),children:(0,d.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",f?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(g,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(aE,{surfaceTheme:a,text:b.label,className:(0,r.cn)("text-[12px] font-semibold",f?"text-[#171410]":"text-white"),startDelayMs:c,wordDelayMs:70},`source-label:${b.id}:${c}`),(0,d.jsx)(aE,{surfaceTheme:a,text:b.summary,className:(0,r.cn)("mt-1 text-[11px] leading-5",f?"text-[#7a7168]":"text-slate-400"),startDelayMs:c+90,wordDelayMs:95},`source-summary:${b.id}:${c}`)]}),(0,d.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,d.jsx)(aL,{surfaceTheme:a,tone:"ready"===b.status?"success":"danger",label:aN(b.status)}),"number"==typeof b.confidence?(0,d.jsx)("span",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",f?"text-[#8f8274]":"text-slate-500"),children:(e=b.confidence,`${Math.round(100*e)}%`)}):null]})]}),b.details.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.details.slice(0,2).map((a,c)=>(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",f?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:a},`source-detail:${b.id}:${c}:${a}`))}):null]})]})})}function aI({surfaceTheme:a,inference:b,delayMs:c}){let e="light"===a;return(0,d.jsxs)("div",{className:(0,r.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",e?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:aO(c),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(aE,{surfaceTheme:a,text:az(b.section),className:(0,r.cn)("text-[10px] uppercase tracking-[0.18em]",e?"text-[#8f8274]":"text-slate-500"),startDelayMs:c,wordDelayMs:55},`inference-section:${b.id}:${c}`),(0,d.jsx)(aE,{surfaceTheme:a,text:b.label,className:(0,r.cn)("mt-1 text-[12px] font-semibold leading-5",e?"text-[#171410]":"text-white"),startDelayMs:c+80,wordDelayMs:75},`inference-label:${b.id}:${c}`)]}),(0,d.jsx)(aL,{surfaceTheme:a,tone:function(a){switch(a){case"confirmed":return"success";case"needs-confirmation":return"warning";default:return"muted"}}(b.status),label:"confirmed"===b.status?"Confirmed":"needs-confirmation"===b.status?"Needs check":"Inferred"})]}),(0,d.jsx)(aE,{surfaceTheme:a,text:b.value,className:(0,r.cn)("mt-2 text-[13px] leading-6",e?"text-[#5f564e]":"text-slate-300"),startDelayMs:c+120,wordDelayMs:100},`inference-value:${b.id}:${c}`),(0,d.jsx)(aE,{surfaceTheme:a,text:b.rationale,className:(0,r.cn)("mt-2 text-[11px] leading-5",e?"text-[#7a7168]":"text-slate-400"),startDelayMs:c+250,wordDelayMs:90},`inference-rationale:${b.id}:${c}`),b.sourceLabels.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.sourceLabels.slice(0,3).map((a,c)=>(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",e?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:a},`inference-source:${b.id}:${c}:${a}`))}):null]})}function aJ({surfaceTheme:a,label:b,tone:c="default",animated:e=!1,delayMs:f=0,interactive:g=!1,onClick:h}){let i="light"===a,j=(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] leading-4 transition-colors",e&&"workspace-architect-chip-enter","accent"===c?i?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===c?i?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"muted"===c?i?"border-[#e4ddd3] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-400":i?"border-[#e4ddd3] bg-white text-[#6d645b]":"border-white/10 bg-white/[0.05] text-slate-300",g?"success"===c?i?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":i?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":""),k=g?t.A:o.A;return g?(0,d.jsxs)("button",{type:"button",onClick:h,"aria-label":`Edit ${b}`,className:j,style:aO(f),children:[(0,d.jsx)(k,{className:"mr-1 h-3 w-3"}),b]}):(0,d.jsxs)("span",{className:j,style:aO(f),children:[(0,d.jsx)(k,{className:"mr-1 h-3 w-3"}),b]})}function aK(a,b){let c=a.trim();return c.length<=b?c:`${c.slice(0,Math.max(0,b-1)).trimEnd()}…`}function aL({surfaceTheme:a,tone:b,label:c}){return(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","muted"===b&&("light"===a?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),"success"===b&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===b&&"border-amber-200 bg-amber-50 text-amber-700","danger"===b&&"border-rose-200 bg-rose-50 text-rose-700"),children:c})}function aM({surfaceTheme:a,title:b,description:c}){let e="light"===a;return(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border border-dashed px-3 py-3",e?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)(aE,{surfaceTheme:a,text:b,className:(0,r.cn)("text-[12px] font-medium",e?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:65},`empty-title:${b}`),(0,d.jsx)(aE,{surfaceTheme:a,text:c,className:(0,r.cn)("mt-1 text-[12px] leading-5",e?"text-[#70665c]":"text-slate-400"),startDelayMs:90,wordDelayMs:90},`empty-description:${b}`)]})}function aN(a){return"ready"===a?"Ready":"Needs check"}function aO(a){return{animationDelay:`${a}ms`}}let aP=Object.fromEntries(T.map(a=>[a.value,a.label]));function aQ({className:a,surfaceTheme:b,workspaceMode:c="create",mode:e,snapshot:f,plan:g,resolvedName:h,resolvedTemplate:i,sourceAnalysis:k,workspacePath:l,notice:m,basicRules:n,basicPreset:o,onOpenBlueprintEditor:q,onOpenDocumentEditor:v,onBasicPresetChange:w,onBasicRuleToggle:y,progress:z}){let A="light"===b,B=(0,p.useRef)({});(0,p.useRef)(null);let[C,D]=(0,p.useState)(null),E=(a="workspace.name")=>{q?.(a)};(0,p.useMemo)(()=>(function({mode:a,plan:b,notice:c,progress:d,resolvedName:e,resolvedTemplate:f,basicRules:g,basicPreset:h,sourceAnalysis:i,workspacePath:j}){return{mode:a,noticeSignature:c?`${c.tone}:${c.title}:${c.description}`:"",progressSignature:d?JSON.stringify(d):"",basic:{architectSignature:b?[b.architectSummary,b.company.name,b.company.mission,b.company.targetCustomer,b.workspace.template,JSON.stringify(b.workspace.rules),b.intake.sources.map(a=>`${a.kind}:${a.status}:${a.label}:${Math.round((a.confidence??0)*100)}`).join("|"),b.intake.inferences.map(a=>`${a.section}:${a.status}:${a.label}:${a.value}`).join("|"),b.intake.confirmations.join("|")].join(":"):"",summarySignature:[e,f,i.kind,i.label,i.hint,i.repoUrl??"",i.existingPath??"",i.websiteUrl??"",j].join(":"),defaultsSignature:`${h}:${g.generateStarterDocs}:${g.generateMemory}:${g.kickoffMission}`},advanced:{stage:b?.stage??null,readinessSignature:b?`${b.readinessScore}:${b.architectSummary}`:"",deploySignature:b?`${b.intake.reviewRequested}:${b.deploy.blockers.join("|")}:${b.deploy.warnings.join("|")}`:"",sectionSignatures:Object.fromEntries(au.map(a=>[a.id,b?`${ax(b,a.id).label}:${ax(b,a.id).variant}:${ay(b,a.id)}`:""]))}}})({mode:e,plan:g,notice:m,progress:z,resolvedName:h,resolvedTemplate:i,basicRules:n,basicPreset:o,sourceAnalysis:k,workspacePath:l}),[o,n,e,m,g,z,h,i,k,l]);let F=(0,p.useMemo)(()=>g?M({name:g.workspace.name||"Workspace",brief:g.company.mission||g.product.offer||void 0,template:g.workspace.template,sourceMode:g.workspace.sourceMode,rules:g.workspace.rules,agents:g.team.persistentAgents.filter(a=>a.enabled),docOverrides:g.workspace.docOverrides,toolExamples:[],contextSources:g.intake.sources}):[],[g]),G=(0,p.useMemo)(()=>new Map(F.map(a=>[a.path,a])),[F]),H=(0,p.useMemo)(()=>K(g?.workspace.template??i,g?.workspace.rules??n),[n,g?.workspace.rules,g?.workspace.template,i]);return(0,d.jsx)("aside",{className:(0,r.cn)("min-h-0 border-t lg:border-l lg:border-t-0",A?"border-[#ebe5dd] bg-[#f7f2eb]":"border-white/10 bg-[rgba(5,9,18,0.92)]",a),children:(0,d.jsx)(x.F,{className:"h-full",children:(0,d.jsxs)("div",{className:"space-y-4 p-4 md:p-5",children:[(0,d.jsx)(aS,{surfaceTheme:b,title:"basic"===e?"Workspace draft":"Workspace blueprint",subtitle:"basic"===e?"Live draft view. The fast path stays available while Architect fills in the details.":"Structured blueprint synced with the conversation.",action:g&&q?(0,d.jsxs)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>E("workspace.name"),className:A?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,d.jsx)(t.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null}),"create"===c?(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(aR,{sectionKey:"setup-speed",activeSection:C,surfaceTheme:b,register:a=>{B.current["setup-speed"]=a},children:(0,d.jsx)(aX,{surfaceTheme:b,mode:e,preset:o,onPresetChange:w,onOpenBlueprintEditor:E})})}):null,m?(0,d.jsx)(aR,{sectionKey:"notice",activeSection:C,surfaceTheme:b,register:a=>{B.current.notice=a},children:(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-4 py-3","warning"===m.tone?A?"border-amber-200 bg-amber-50 text-amber-900":"border-amber-400/25 bg-amber-400/10 text-amber-100":A?"border-[#e3ddd4] bg-white text-[#3f3933]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",A?"text-[#9c9389]":"text-slate-500"),children:m.title}),(0,d.jsx)("p",{className:"mt-1 text-[13px] leading-6",children:m.description})]})}):null,z?(0,d.jsx)(aR,{sectionKey:"progress",activeSection:C,surfaceTheme:b,register:a=>{B.current.progress=a},children:(0,d.jsx)(s,{progress:z,className:(0,r.cn)(A?"border-[#e5ded3] bg-white text-slate-900 [&_p]:text-inherit":"border-white/10 bg-slate-950/50")})}):null,"basic"===e?(0,d.jsxs)("div",{className:"space-y-3",children:[g?(0,d.jsx)(aR,{sectionKey:"architect-readout",activeSection:C,surfaceTheme:b,register:a=>{B.current["architect-readout"]=a},children:(0,d.jsx)(aC,{surfaceTheme:b,plan:g,variant:"panel",onOpenBlueprintEditor:E,onOpenDocumentEditor:v},g.updatedAt)}):null,(0,d.jsx)(aR,{sectionKey:"summary",activeSection:C,surfaceTheme:b,register:a=>{B.current.summary=a},children:(0,d.jsx)(aT,{surfaceTheme:b,resolvedName:h,resolvedTemplate:i,sourceAnalysis:k,workspacePath:l,workspaceRoot:f.diagnostics.workspaceRoot,summaryLabel:g?"Architect refreshed the draft.":"Resolved from quick setup.",onOpenBlueprintEditor:E})}),(0,d.jsx)(aR,{sectionKey:"defaults",activeSection:C,surfaceTheme:b,register:a=>{B.current.defaults=a},children:(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[22px] border p-4",A?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",A?"text-[#a0978b]":"text-slate-500"),children:"Fast-path defaults"}),(0,d.jsx)(aW,{surfaceTheme:b,plan:g,template:i,rules:n,preset:o,onRuleToggle:y,onOpenBlueprintEditor:E,onOpenDocumentEditor:v})]})})]}):g?(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)(aR,{sectionKey:"readiness",activeSection:C,surfaceTheme:b,register:a=>{B.current.readiness=a},children:(0,d.jsx)("button",{type:"button",onClick:()=>E("deploy.blockers"),className:(0,r.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",A?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",A?"text-[#a0978b]":"text-slate-500"),children:"Readiness"}),(0,d.jsxs)("p",{className:(0,r.cn)("mt-1 text-[28px] font-semibold tracking-[-0.03em]",A?"text-[#181612]":"text-white"),children:[g.readinessScore,"%"]}),(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] leading-6",A?"text-[#6e665d]":"text-slate-300"),children:g.architectSummary})]}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-10 items-center justify-center rounded-full border",A?"border-[#e5ddd2] bg-[#f5f0e8] text-[#6a635b]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(j.A,{className:"h-4 w-4"})})]})})}),au.map(a=>{let c=ax(g,a.id),e=a.icon,f=`section-${a.id}`;return(0,d.jsx)(aR,{sectionKey:f,activeSection:C,surfaceTheme:b,register:a=>{B.current[f]=a},children:(0,d.jsx)("button",{type:"button",onClick:()=>E("company"===a.id?"company.mission":"product"===a.id?"product.offer":"workspace"===a.id?"workspace.name":"team"===a.id?"team.maxParallelRuns":"deploy.blockers"),className:(0,r.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",A?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",A?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(e,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[14px] font-semibold",A?"text-[#171410]":"text-white"),children:a.label}),(0,d.jsx)(aV,{surfaceTheme:b,tone:c.variant,label:c.label})]}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",A?"text-[#70685f]":"text-slate-300"),children:ay(g,a.id)})]})]})})},a.id)}),(0,d.jsx)(aR,{sectionKey:"documents",activeSection:C,surfaceTheme:b,register:a=>{B.current.documents=a},children:(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[22px] border p-4",A?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(am.A,{className:(0,r.cn)("h-4 w-4",A?"text-[#5f5952]":"text-slate-300")}),(0,d.jsx)("p",{className:(0,r.cn)("text-[14px] font-semibold",A?"text-[#171410]":"text-white"),children:"Documents"})]}),(0,d.jsx)("div",{className:"mt-3 space-y-3",children:H.sections.map(a=>{let c=a.resources.map(a=>G.get(a.relativePath)).filter(a=>!!a);return(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-3",A?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[12px] font-semibold",A?"text-[#171410]":"text-white"),children:a.title}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[11px] leading-5",A?"text-[#7a7168]":"text-slate-400"),children:a.description})]}),(0,d.jsx)(aV,{surfaceTheme:b,tone:a.enabled?"success":"muted",label:a.enabled?"Included":"Skipped"})]}),c.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:c.map(a=>(0,d.jsx)(aZ,{surfaceTheme:b,label:a.path,tone:a.generated?a.overridden?"success":"default":"accent",interactive:!!v,onClick:v?()=>v(a.path):void 0},a.path))}):(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",A?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},a.id)})}),v?(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",A?"text-[#7a7168]":"text-slate-400"),children:"edit"===c?"These are the current workspace files grouped by the canonical context manifest.":"These are the scaffold documents that will be written for this workspace."}):null]})}),(0,d.jsx)(aR,{sectionKey:"deploy-review",activeSection:C,surfaceTheme:b,register:a=>{B.current["deploy-review"]=a},children:(0,d.jsxs)("button",{type:"button",onClick:()=>E("deploy.blockers"),className:(0,r.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",A?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(an.A,{className:(0,r.cn)("h-4 w-4",A?"text-[#5f5952]":"text-slate-300")}),(0,d.jsx)("p",{className:(0,r.cn)("text-[14px] font-semibold",A?"text-[#171410]":"text-white"),children:"Deploy review"})]}),g.deploy.blockers.length>0?(0,d.jsx)(a$,{surfaceTheme:b,title:"Blockers",tone:"danger",items:g.deploy.blockers}):null,g.deploy.warnings.length>0?(0,d.jsx)(a$,{surfaceTheme:b,title:"Warnings",tone:"warning",items:g.deploy.warnings}):null,0===g.deploy.blockers.length&&0===g.deploy.warnings.length?(0,d.jsx)("p",{className:(0,r.cn)("mt-3 text-[13px] leading-6",A?"text-[#70685f]":"text-slate-300"),children:"Architect has not surfaced blockers or warnings yet. Request review when the blueprint feels directionally right."}):null]})})]}):(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[22px] border border-dashed p-5",A?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[14px] font-medium",A?"text-[#211d19]":"text-white"),children:"Architect is preparing the blueprint."}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",A?"text-[#776f65]":"text-slate-300"),children:"Once the first plan is ready, this pane will start reflecting the structured workspace draft."})]})]})})})}function aR({sectionKey:a,activeSection:b,surfaceTheme:c,register:e,children:f}){return(0,d.jsx)("div",{ref:e,className:(0,r.cn)("scroll-mt-6 rounded-[26px] transition-all duration-500",b===a&&("light"===c?"ring-2 ring-[#d8b184]/70 shadow-[0_0_0_1px_rgba(216,177,132,0.18),0_18px_36px_rgba(102,78,47,0.16)]":"ring-2 ring-cyan-300/45 shadow-[0_0_0_1px_rgba(103,232,249,0.14),0_18px_36px_rgba(6,182,212,0.16)]")),children:f})}function aS({surfaceTheme:a,title:b,subtitle:c,action:e}){let f="light"===a;return(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#8b7262]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",f?"text-[#705b4d]":"text-slate-300"),children:c})]}),e?(0,d.jsx)("div",{className:"shrink-0",children:e}):null]})}function aT({surfaceTheme:a,resolvedName:b,resolvedTemplate:c,sourceAnalysis:e,workspacePath:f,workspaceRoot:g,summaryLabel:i,onOpenBlueprintEditor:j}){let o="light"===a;return(0,d.jsx)("div",{className:(0,r.cn)("rounded-[22px] border p-4",o?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",o?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(h.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",o?"text-[#a0978b]":"text-slate-500"),children:"Fast-path snapshot"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",o?"text-[#776f65]":"text-slate-400"),children:i}),(0,d.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,d.jsx)(aU,{surfaceTheme:a,label:"Name",value:b,icon:h.A,onClick:()=>j?.("workspace.name")}),(0,d.jsx)(aU,{surfaceTheme:a,label:"Template",value:aP[c],icon:n.A,onClick:()=>j?.("workspace.template")}),(0,d.jsx)(aU,{surfaceTheme:a,label:"Source",value:e.label,icon:"clone"===e.kind?k.A:"website"===e.kind?l.A:m.A,onClick:()=>j?.("workspace.sourceMode")}),(0,d.jsx)(aU,{surfaceTheme:a,label:"Path",value:f,icon:m.A,mono:!0,title:`Root: ${g}`,onClick:()=>j?.("workspace.directory")})]})]})]})})}function aU({surfaceTheme:a,label:b,value:c,icon:e,detail:f,mono:g=!1,title:h,onClick:i}){let j="light"===a,k=!!i;return(0,d.jsx)("button",{type:"button",onClick:i,className:(0,r.cn)("w-full rounded-[14px] border px-3 py-2.5 text-left transition-colors",j?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",k&&(j?"cursor-pointer hover:border-[#d9b78b] hover:bg-[#f7efe3] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#d9b78b]/60":"cursor-pointer hover:border-cyan-300/30 hover:bg-white/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/30")),title:h,children:(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",j?"border-[#e0d7cc] bg-white text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(e,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",j?"text-[#8d8276]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-[12px] font-medium leading-4",j?"text-[#171410]":"text-white",g&&"font-mono text-[12px]"),title:c,children:c})]}),k?(0,d.jsx)(t.A,{className:(0,r.cn)("h-3.5 w-3.5 shrink-0",j?"text-[#8f8377]":"text-slate-400")}):null,f?(0,d.jsx)("span",{className:(0,r.cn)("shrink-0 text-[10px] leading-4",j?"text-[#776f65]":"text-slate-400"),children:f}):null]})})}function aV({surfaceTheme:a,tone:b,label:c}){return(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","muted"===b&&("light"===a?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),"success"===b&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===b&&"border-amber-200 bg-amber-50 text-amber-700","danger"===b&&"border-rose-200 bg-rose-50 text-rose-700"),children:c})}function aW({surfaceTheme:a,plan:b,template:c,rules:e,preset:f,onRuleToggle:g,onOpenBlueprintEditor:h,onOpenDocumentEditor:i}){var j,k;let l,m,n,q,s,v="light"===a,w=K(c,e),x=(j=c,k=e,l=J(j),m=new Set(G),n=l.filter(a=>m.has(a.relativePath)).map(a=>a.label),q=l.filter(a=>a.relativePath.startsWith("docs/")||a.relativePath.startsWith("deliverables/")).map(a=>a.label),s=l.filter(a=>"MEMORY.md"===a.relativePath||a.relativePath.startsWith("memory/")).map(a=>a.label),[{id:"core",title:"Core agent files",description:"Identity and operating rules.",checked:!0,locked:!0,files:n,rule:void 0},{id:"docs",title:"Starter docs",description:"Brief, architecture, handoff.",checked:k.generateStarterDocs,locked:!1,files:q,rule:"generateStarterDocs"},{id:"memory",title:"Memory files",description:"Durable decisions and context.",checked:k.generateMemory,locked:!1,files:s,rule:"generateMemory"},{id:"kickoff",title:"Kickoff mission",description:"Starts the first mission.",checked:k.kickoffMission,locked:!1,files:[],rule:"kickoffMission"}]),y=(0,p.useMemo)(()=>new Set(N(b?.workspace.docOverrides).map(a=>a.path)),[b?.workspace.docOverrides]),z=!!b;return(0,d.jsxs)("div",{className:"mt-3 space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:["custom"===f?(0,d.jsx)(aV,{surfaceTheme:a,tone:"muted",label:"Custom mix"}):(0,d.jsx)("span",{}),h?(0,d.jsxs)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>h("workspace.ruleGenerateStarterDocs"),className:v?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,d.jsx)(t.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit section"]}):null]}),(0,d.jsx)("div",{className:"space-y-2",children:x.map(b=>(0,d.jsx)("button",{type:"button",onClick:b.rule?()=>g(b.rule):void 0,disabled:!b.rule,className:(0,r.cn)("w-full rounded-[18px] border px-3 py-3 text-left transition-colors",v?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",b.rule?v?"hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"hover:border-white/15 hover:bg-white/[0.05]":"cursor-default"),children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:(0,r.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",b.checked?v?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":v?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] font-medium",v?"text-[#171410]":"text-white"),children:b.title}),b.locked?(0,d.jsxs)("span",{className:(0,r.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",v?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400"),children:[(0,d.jsx)(ao.A,{className:"h-3 w-3"}),"Required"]}):null]}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",v?"text-[#776f65]":"text-slate-400"),children:b.description}),b.files.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.files.map(b=>(0,d.jsx)(aZ,{surfaceTheme:a,label:b},b))}):null]})]})},b.id))}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-3",v?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(am.A,{className:(0,r.cn)("h-4 w-4",v?"text-[#5f5952]":"text-slate-300")}),(0,d.jsx)("p",{className:(0,r.cn)("text-[12px] uppercase tracking-[0.16em]",v?"text-[#8d8276]":"text-slate-500"),children:"Canonical manifest"})]}),(0,d.jsx)("div",{className:"mt-3 space-y-3",children:w.sections.map(b=>(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[16px] border px-3 py-3",v?"border-[#e2d9cc] bg-white":"border-white/10 bg-white/[0.02]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[12px] font-semibold",v?"text-[#171410]":"text-white"),children:b.title}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[11px] leading-5",v?"text-[#7b7269]":"text-slate-400"),children:b.description})]}),(0,d.jsx)(aV,{surfaceTheme:a,tone:b.enabled?"success":"muted",label:b.enabled?"Included":"Skipped"})]}),b.resources.length>0?(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.resources.map(b=>(0,d.jsx)(aZ,{surfaceTheme:a,label:b.label,tone:y.has(b.relativePath)?"success":"default",interactive:!!(z&&i),onClick:z&&i?()=>i(b.relativePath):void 0},b.relativePath))}):(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",v?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},b.id))}),e.kickoffMission?(0,d.jsx)(aZ,{surfaceTheme:a,label:"Kickoff mission",tone:"accent"}):null,z&&i?(0,d.jsx)("p",{className:(0,r.cn)("mt-2 text-[11px] leading-5",v?"text-[#7a7168]":"text-slate-400"),children:"Click a file chip to edit its scaffold or override."}):null]}),(0,d.jsxs)("p",{className:(0,r.cn)("text-[13px] leading-6",v?"text-[#70685f]":"text-slate-300"),children:["fastest"===f?"Core files only.":"custom"===f?"Only the extras you kept.":"Starter docs, memory, kickoff."," Switch to Advanced later if you need more control."]})]})}function aX({surfaceTheme:a,mode:b,preset:c,onPresetChange:e,onOpenBlueprintEditor:f}){let g="light"===a;return(0,d.jsxs)("div",{className:(0,r.cn)("rounded-xl border p-3",g?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.18em]",g?"text-[#a0978b]":"text-slate-500"),children:"Setup speed"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[11px] leading-5",g?"text-[#70685f]":"text-slate-300"),children:"basic"===b?"Choose how much scaffold the fast path should write.":"These presets also update the bootstrap rules."})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:["custom"===c?(0,d.jsx)(aV,{surfaceTheme:a,tone:"muted",label:"Custom"}):null,f?(0,d.jsxs)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>f("workspace.ruleGenerateStarterDocs"),className:g?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,d.jsx)(t.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),(0,d.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,d.jsx)(aY,{surfaceTheme:a,active:"standard"===c,title:"Standard",description:"Docs, memory, kickoff",onClick:()=>e("standard")}),(0,d.jsx)(aY,{surfaceTheme:a,active:"fastest"===c,title:"Fastest setup",description:"Core files only",onClick:()=>e("fastest")})]})]})}function aY({surfaceTheme:a,active:b,title:c,description:e,onClick:f}){let g="light"===a;return(0,d.jsx)("button",{type:"button",onClick:f,className:(0,r.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",b?g?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":g?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]"),children:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)(n.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,d.jsx)("p",{className:"truncate text-[12px] font-medium",children:c})]}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-right text-[11px] leading-4",b?"opacity-80":g?"text-[#776f65]":"text-slate-400"),children:e})]})})}function aZ({surfaceTheme:a,label:b,tone:c="default",interactive:e=!1,onClick:f}){let g=(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] transition-colors","accent"===c?"light"===a?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===c?"light"===a?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"light"===a?"border-[#e4ddd3] bg-white text-[#6c645b]":"border-white/10 bg-white/[0.05] text-slate-300",e?"success"===c?"light"===a?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":"light"===a?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":"");return e?(0,d.jsxs)("button",{type:"button",onClick:f,"aria-label":`Edit ${b}`,className:g,children:[(0,d.jsx)(t.A,{className:"mr-1 h-3 w-3"}),b]}):(0,d.jsxs)("span",{className:g,children:[(0,d.jsx)(o.A,{className:"mr-1 h-3 w-3"}),b]})}function a$({surfaceTheme:a,title:b,tone:c,items:e}){let f="light"===a;return(0,d.jsxs)("div",{className:(0,r.cn)("mt-3 rounded-[18px] border px-4 py-3","danger"===c?f?"border-rose-200 bg-rose-50":"border-rose-400/25 bg-rose-400/10":f?"border-amber-200 bg-amber-50":"border-amber-400/25 bg-amber-400/10"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#9f958a]":"text-slate-500"),children:b}),(0,d.jsx)("div",{className:"mt-2 space-y-2",children:e.map(a=>(0,d.jsxs)("div",{className:(0,r.cn)("flex items-start gap-2 text-[13px] leading-6",f?"text-[#403934]":"text-slate-200"),children:[(0,d.jsx)(q.A,{className:"mt-1 h-3.5 w-3.5 shrink-0"}),(0,d.jsx)("span",{children:a})]},a))})]})}var a_=c(68123);function a0({surfaceTheme:a,mode:b,onModeChange:c,onNewDraft:e,badges:f,title:g="Create workspace",showModeToggle:h=!0,showNewDraft:i=!0}){let k="light"===a;return(0,d.jsx)("div",{className:(0,r.cn)("relative z-[1] border-b px-4 py-2 md:px-5",k?"border-[#e7e1d8] bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,244,237,0.94))]":"border-white/10 bg-[linear-gradient(180deg,rgba(10,16,29,0.96),rgba(6,11,21,0.94))]"),children:(0,d.jsxs)("div",{className:"flex flex-col gap-2 md:flex-nowrap md:flex-row md:items-center md:justify-between md:gap-3",children:[(0,d.jsx)("div",{className:"min-w-0",children:(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border shadow-[0_8px_20px_rgba(56,47,38,0.08)]",k?"border-[#e3ddd4] bg-white text-[#4c4640]":"border-white/10 bg-white/[0.05] text-slate-200 shadow-[0_16px_36px_rgba(0,0,0,0.28)]"),children:(0,d.jsx)(j.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.22em]",k?"text-[#7f6554]":"text-slate-500"),children:"Architect"}),(0,d.jsx)("span",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.18em]",k?"text-[#a59a8e]":"text-slate-600"),children:"/"}),(0,d.jsx)("h2",{className:(0,r.cn)("truncate text-[16px] font-semibold tracking-[-0.02em]",k?"text-[#2d2118]":"text-white"),children:g})]})]})}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 md:flex-nowrap md:justify-end",children:[f.length>0?(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 md:flex-nowrap",children:f.map(a=>(0,d.jsx)("span",{className:(0,r.cn)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.16em]","success"===a.tone&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===a.tone&&"border-amber-200 bg-amber-50 text-amber-700","danger"===a.tone&&"border-rose-200 bg-rose-50 text-rose-700",(!a.tone||"muted"===a.tone)&&(k?"border-[#e4ddd3] bg-white text-[#5f5348]":"border-white/10 bg-white/[0.05] text-slate-300")),children:a.label},a.id))}):null,h?(0,d.jsxs)("div",{className:(0,r.cn)("inline-flex rounded-full border p-0.5",k?"border-[#e4ddd3] bg-[#f4efe7]":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsx)(a1,{surfaceTheme:a,active:"basic"===b,label:"Basic",onClick:()=>c("basic")}),(0,d.jsx)(a1,{surfaceTheme:a,active:"advanced"===b,label:"Advanced",onClick:()=>c("advanced")})]}):null,i&&e?(0,d.jsxs)("button",{type:"button",onClick:e,className:(0,r.cn)("inline-flex h-8 items-center gap-2 rounded-full border px-2.5 text-[11px] transition-colors",k?"border-[#dfd8ce] bg-white text-[#38322d] hover:bg-[#f5f1ea]":"border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]"),children:[(0,d.jsx)(a_.A,{className:"h-3.5 w-3.5"}),"New draft"]}):null]})]})})}function a1({surfaceTheme:a,active:b,label:c,onClick:e}){let f="light"===a;return(0,d.jsx)("button",{type:"button",onClick:e,className:(0,r.cn)("inline-flex min-w-[78px] items-center justify-center rounded-full px-2.5 py-1 text-[11px] transition-colors",b?f?"bg-white text-[#151310] shadow-sm":"bg-[#0f1726] text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)]":f?"text-[#6d584a] hover:text-[#2d2824]":"text-slate-400 hover:text-slate-100"),children:c})}var a2=c(91622);function a3({surfaceTheme:a,value:b,placeholder:c,onChange:e,onSubmit:f,disabled:h=!1,isBusy:i=!1,helperText:j,toolbar:k,className:l}){let m=(0,p.useRef)(null),n=!!b.trim()&&!h,o=async a=>{a.preventDefault(),n&&await f()},q=async a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),n&&await f())},s="light"===a;return(0,d.jsxs)("form",{onSubmit:o,className:(0,r.cn)("rounded-[20px] border p-2.5 transition-all duration-200 focus-within:shadow-[0_0_0_1px_rgba(0,0,0,0.02)]",s?"border-[#ddd6cb] bg-white shadow-[0_18px_56px_rgba(56,47,38,0.08)] focus-within:border-[#cfc6ba]":"border-white/10 bg-[rgba(7,12,22,0.92)] shadow-[0_18px_56px_rgba(0,0,0,0.34)] focus-within:border-cyan-300/30",l),children:[(0,d.jsx)("textarea",{ref:m,value:b,onChange:a=>e(a.target.value),onKeyDown:q,placeholder:c,className:(0,r.cn)("min-h-[44px] max-h-[200px] w-full resize-none overflow-y-auto border-0 bg-transparent px-1.5 py-1.5 text-[15px] leading-6 outline-none",s?"text-[#191714] placeholder:text-[#9b948c]":"text-slate-100 placeholder:text-slate-500")}),(0,d.jsxs)("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex min-h-8 items-center gap-2",children:[k,j?(0,d.jsx)("p",{className:(0,r.cn)("text-[11px]",s?"text-[#8b837a]":"text-slate-400"),children:j}):null]}),(0,d.jsx)("button",{type:"submit",disabled:!n,className:(0,r.cn)("inline-flex size-8 items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed",s?"bg-[#161514] text-white hover:bg-[#26231f] disabled:bg-[#d5cec5] disabled:text-[#8d857c]":"bg-cyan-300 text-slate-950 hover:bg-cyan-200 disabled:bg-white/[0.08] disabled:text-slate-500"),children:i?(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(a2.A,{className:"h-3.5 w-3.5"})})]})]})}function a4({surfaceTheme:a,messages:b,architectMessageId:c=null,architectPlan:e=null,isTyping:f=!1,typingLabel:g="Typing…",emptyState:h,auxiliary:i,className:j}){let k=(0,p.useRef)(null),l=(0,p.useRef)(null);return(0,d.jsx)(x.F,{className:(0,r.cn)("h-full",j),children:(0,d.jsxs)("div",{ref:l,className:"mx-auto flex min-h-full w-full max-w-3xl flex-col gap-4 px-2 py-4 md:gap-5 md:px-4",children:[h,i,b.map(b=>(0,d.jsx)(a5,{message:b,surfaceTheme:a,architectMessageId:c,architectPlan:e},b.id)),f?(0,d.jsx)(a6,{surfaceTheme:a,label:g}):null,(0,d.jsx)("div",{ref:k,className:"h-6 w-full shrink-0"})]})})}function a5({message:a,surfaceTheme:b,architectMessageId:c,architectPlan:e}){let f="light"===b;if("assistant"===a.role&&e&&a.id===c)return(0,d.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,d.jsx)(aC,{surfaceTheme:b,plan:e,variant:"message",summaryText:a.text},`${a.id}:${e.updatedAt}`)});if("system"===a.role)return(0,d.jsxs)("div",{className:(0,r.cn)("mx-auto w-full max-w-2xl rounded-2xl border px-4 py-3 text-[13px] leading-6",f?"border-[#e3ddd4] bg-[#f5f0e8] text-[#5b544d]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#8b8074]":"text-slate-500"),children:a.author||"Workspace Wizard"}),(0,d.jsx)("p",{className:"mt-1",children:a.text})]});let g="user"===a.role,i="pending"===a.status;return(0,d.jsxs)("div",{className:(0,r.cn)("flex w-full items-start gap-2.5",g?"justify-end":"justify-start"),children:[g?null:(0,d.jsx)("div",{className:(0,r.cn)("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",f?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"Architect"===a.author?(0,d.jsx)(j.A,{className:"h-3.5 w-3.5"}):(0,d.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:(0,r.cn)("max-w-[min(100%,680px)]",g?f?"rounded-2xl border border-[#ddd6cb] bg-[#1a1715] px-3 py-2 text-white":"rounded-2xl border border-cyan-200/40 bg-cyan-300 px-3 py-2 text-slate-950":"space-y-1 px-0 py-0",i&&"opacity-75"),children:[!g&&a.author?(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",f?"text-[#8f857a]":"text-slate-500"),children:a.author}):null,(0,d.jsx)("p",{className:(0,r.cn)("whitespace-pre-wrap text-[14px] leading-7",g&&"leading-6"),children:a.text})]})]})}function a6({surfaceTheme:a,label:b}){let c="light"===a;return(0,d.jsxs)("div",{className:"flex w-full items-start gap-2.5",children:[(0,d.jsx)("div",{className:(0,r.cn)("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",c?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(j.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"max-w-[min(100%,680px)]",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",c?"text-[#8f857a]":"text-slate-500"),children:"Architect"}),(0,d.jsxs)("div",{className:"mt-1 flex items-center gap-2.5",children:[(0,d.jsxs)("div",{className:(0,r.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5",c?"border-[#e6dfd5] bg-white text-[#5a534c]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-1.5 animate-pulse rounded-full",c?"bg-[#5a534c]":"bg-slate-300")}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:120ms]",c?"bg-[#5a534c]":"bg-slate-300")}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:240ms]",c?"bg-[#5a534c]":"bg-slate-300")})]}),(0,d.jsx)("p",{className:(0,r.cn)("text-[12px] leading-5",c?"text-[#6f685f]":"text-slate-400"),children:b})]})]})]})}var a7=c(5813),a8=c(37674),a9=c(43081),ba=c(30094);let bb={founder:"Founder",product:"Product Lead",architect:"System Architect",ops:"Operations",growth:"Growth",reviewer:"Reviewer"},bc={small:{label:"Small",agentCount:1,workflowCount:1,automationCount:0,externalChannelCount:0,confirmationLimit:1,suggestedReplyLimit:2},medium:{label:"Medium",agentCount:3,workflowCount:3,automationCount:1,externalChannelCount:0,confirmationLimit:2,suggestedReplyLimit:3},large:{label:"Large",agentCount:5,workflowCount:4,automationCount:2,externalChannelCount:1,confirmationLimit:3,suggestedReplyLimit:4}};function bd(a){return bc[a]??bc.medium}let be={internal:{label:"Internal",requiresCredentials:!1,credentials:[]},slack:{label:"Slack",requiresCredentials:!0,credentials:[{key:"botToken",label:"Bot token",placeholder:"xoxb-...",secret:!0}]},telegram:{label:"Telegram",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"123456:ABC...",secret:!0}]},discord:{label:"Discord",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"Discord bot token",secret:!0}]},googlechat:{label:"Google Chat",requiresCredentials:!0,credentials:[{key:"webhookUrl",label:"Webhook URL",placeholder:"https://chat.googleapis.com/...",secret:!0}]}};function bf(){return globalThis.crypto?.randomUUID?.()??`plan-${Date.now()}`}function bg(a,b,c){return{id:bf(),role:a,author:b,text:c,createdAt:new Date().toISOString()}}function bh(a){return{id:a.id?.trim()||bf(),kind:a.kind,label:a.label.trim(),summary:a.summary.trim(),details:bC(a.details),status:a.status??"ready",createdAt:a.createdAt??new Date().toISOString(),confidence:"number"==typeof a.confidence?Math.max(0,Math.min(100,Math.round(a.confidence))):void 0,url:bB(a.url),error:bB(a.error)}}function bi(a){return{id:a.id?.trim()||bf(),section:a.section,label:a.label.trim(),value:a.value.trim(),confidence:Math.max(0,Math.min(100,Math.round(a.confidence??72))),status:a.status??"inferred",rationale:bA(a.rationale??""),sourceLabels:bC(a.sourceLabels)}}function bj(a){let b=bF(a?.id||a?.name||"operator")||"operator",c=a?.role?.trim()||"Operator",d=a?.name?.trim()||bG(b);return{id:b,role:c,name:d,purpose:a?.purpose?.trim()||`${d} owns ${c.toLowerCase()} execution and handoffs.`,enabled:a?.enabled!==!1,isPrimary:!!a?.isPrimary,emoji:a?.emoji?.trim(),theme:a?.theme?.trim(),skillId:a?.skillId?.trim(),modelId:a?.modelId?.trim(),policy:a?.policy??(0,A.g0)("worker"),heartbeat:a?.heartbeat??{enabled:!1},responsibilities:bC(a?.responsibilities),outputs:bC(a?.outputs),channelIds:bC(a?.channelIds)}}function bk(a){return{id:bF(a?.id||a?.name||`workflow-${Date.now()}`)||`workflow-${Date.now()}`,name:a?.name?.trim()||"New workflow",goal:a?.goal?.trim()||"",trigger:a?.trigger??"manual",ownerAgentId:a?.ownerAgentId?.trim(),collaboratorAgentIds:bC(a?.collaboratorAgentIds),successDefinition:a?.successDefinition?.trim()||"",outputs:bC(a?.outputs),channelIds:bC(a?.channelIds),enabled:a?.enabled!==!1}}function bl(a="internal",b){let c=be[a];return{id:bF(b?.id||b?.name||`${a}-${Date.now()}`)||`${a}-${Date.now()}`,type:a,name:b?.name?.trim()||c.label,purpose:b?.purpose?.trim()||"",target:b?.target?.trim(),enabled:b?.enabled!==!1,announce:!!b?.announce,requiresCredentials:c.requiresCredentials,accountId:b?.accountId?.trim(),primaryAgentId:b?.primaryAgentId?.trim()??null,allowedChatIds:bC(b?.allowedChatIds),groupAssignments:Array.isArray(b?.groupAssignments)?b.groupAssignments.map(a=>({chatId:"string"==typeof a.chatId?a.chatId.trim():"",agentId:"string"==typeof a.agentId?a.agentId.trim():null,title:"string"==typeof a.title?a.title.trim():null,enabled:!1!==a.enabled})).filter(a=>!!a.chatId):[],credentials:b?.credentials?.map(a=>({...a,value:a.value??""}))??c.credentials.map(a=>({...a,value:""}))}}function bm(a){return{id:bF(a?.id||a?.name||`automation-${Date.now()}`)||`automation-${Date.now()}`,name:a?.name?.trim()||"New automation",description:a?.description?.trim()||"",enabled:a?.enabled!==!1,scheduleKind:a?.scheduleKind??"every",scheduleValue:a?.scheduleValue?.trim()||"24h",agentId:a?.agentId?.trim(),mission:a?.mission?.trim()||"",thinking:a?.thinking??"medium",announce:!!a?.announce,channelId:a?.channelId?.trim()}}function bn(a,b){return Z(a,"core",b).map(b=>{var c,d,e,f,g,h,i;return bj({id:b.id,role:b.role,name:b.name,purpose:(c=b.id,d=b.role,e=a,/review/i.test(c)||/review/i.test(d)?`Pressure-test ${e} work for correctness, regression risk, and missing validation.`:/test/i.test(c)||/test/i.test(d)?`Validate behavior, environment assumptions, and release confidence for this ${e} workspace.`:/learn/i.test(c)||/learn/i.test(d)?"Keep the workspace memory, conventions, and durable decisions coherent over time.":/browser/i.test(c)||/browser/i.test(d)?"Exercise real UI flows and collect evidence for browser-facing work.":`Own hands-on delivery and keep the ${e} workspace moving.`),enabled:b.enabled,isPrimary:b.isPrimary,emoji:b.emoji,theme:b.theme,skillId:b.skillId,modelId:b.modelId,policy:b.policy??(0,A.g0)("worker"),heartbeat:b.heartbeat??{enabled:!1},responsibilities:(f=b.id,g=a,/review/i.test(f)?["Review active work","Call out regressions","Protect launch quality"]:/test/i.test(f)?["Run verification loops","Capture evidence","Surface failing assumptions"]:/learn/i.test(f)?["Update durable memory","Track decisions","Reduce restart friction"]:/browser/i.test(f)?["Exercise flows","Capture screenshots","Validate responsive states"]:"content"===g?["Drive content production","Coordinate handoffs","Prepare launch artifacts"]:["Implement the next increment","Coordinate specialists","Keep execution momentum"]),outputs:(h=b.id,i=a,/review/i.test(h)?["review notes","risk checklist"]:/test/i.test(h)?["verification report","repro steps"]:/learn/i.test(h)?["memory updates","decision log entries"]:/browser/i.test(h)?["screenshots","browser validation notes"]:"research"===i?["research summary","evidence log"]:["implementation artifacts","handoff summary"])})})}function bo(a,b){let c=b.find(a=>a.enabled&&a.isPrimary)?.id,d=by(b,"review"),e=by(b,"test"),f=by(b,"learn"),g=by(b,"browser");if("research"===a)return[bk({id:"research-loop",name:"Research loop",goal:"Turn the main question into evidence-backed findings and explicit unknowns.",trigger:"manual",ownerAgentId:c,collaboratorAgentIds:[f,d].filter(Boolean),successDefinition:"Question, evidence, synthesis, and next-step recommendations are documented.",outputs:["docs/research-plan.md","deliverables/<run>/research-summary.md"]}),bk({id:"finding-review",name:"Finding review",goal:"Pressure-test claims before publishing or acting on them.",trigger:"manual",ownerAgentId:d??c,collaboratorAgentIds:[c].filter(Boolean),successDefinition:"Assumptions, risks, and evidence gaps are explicit.",outputs:["deliverables/<run>/review-notes.md"]})];if("content"===a)return[bk({id:"strategy",name:"Strategy and briefing",goal:"Clarify audience, offer, channels, and campaign bets before production.",trigger:"manual",ownerAgentId:c,collaboratorAgentIds:[d,f].filter(Boolean),successDefinition:"The team agrees on brief, priorities, and success signals.",outputs:["docs/content-brief.md","deliverables/<run>/campaign-brief.md"]}),bk({id:"production",name:"Production and QA",goal:"Create assets, review them, and prepare a launch package.",trigger:"manual",ownerAgentId:c,collaboratorAgentIds:[d].filter(Boolean),successDefinition:"Assets are approved and delivery-ready.",outputs:["deliverables/<run>/drafts/","deliverables/<run>/launch-package.md"]}),bk({id:"performance-loop",name:"Performance loop",goal:"Review outcomes, learn from results, and feed the next iteration.",trigger:"cron",ownerAgentId:f??d??c,collaboratorAgentIds:[c].filter(Boolean),successDefinition:"Measured results and next changes are documented.",outputs:["deliverables/<run>/performance-review.md"]})];let h=g&&"frontend"===a?g:c;return[bk({id:"scope-v1",name:"V1 shaping",goal:"Turn the product goal into a constrained first delivery batch.",trigger:"manual",ownerAgentId:c,collaboratorAgentIds:[f,d].filter(Boolean),successDefinition:"Scope, non-goals, and critical path are documented.",outputs:["docs/brief.md","memory/blueprint.md"]}),bk({id:"delivery",name:"Delivery loop",goal:"Implement, validate, and hand off the next meaningful increment.",trigger:"manual",ownerAgentId:h,collaboratorAgentIds:[e,d].filter(Boolean),successDefinition:"A tested increment ships with review notes and clear handoff.",outputs:["deliverables/<run>/release-notes.md","deliverables/<run>/verification.md"]}),bk({id:"launch-readiness",name:"Launch readiness",goal:"Check blockers, rollback posture, and communication before launch.",trigger:"launch",ownerAgentId:d??c,collaboratorAgentIds:[e,f].filter(Boolean),successDefinition:"Launch risks, open blockers, and go/no-go signal are explicit.",outputs:["deliverables/<run>/launch-checklist.md"]})]}function bp(){return[bl("internal",{id:"internal-ops",name:"Internal ops",purpose:"Default internal coordination surface for planner outputs and deploy notes.",announce:!1})]}function bq(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;let D,E,F,G,H,I,J,K,L,M,P,Q,R,S,T,U,V,W,X,Y,Z=bE(a),_=Z.intake.sources.some(a=>"workspace-edit-source"===a.id);if(Z.runtime=(b=Z.id,c=Z.runtime,T=c?.architectSessionId?.trim()||`planner-${b}-architect`,U=Object.fromEntries(Object.entries(c?.advisorAgentIds??{}).filter(([,a])=>"string"==typeof a&&a.trim())),V=Object.fromEntries(Object.entries(bb).map(([a])=>[a,c?.advisorSessionIds?.[a]?.trim()||`planner-${b}-${a}`])),{mode:c?.mode==="fallback"?"fallback":"agent",status:c?.status==="error"?"error":c?.status==="ready"?"ready":"pending",workspaceId:bB(c?.workspaceId),workspacePath:bB(c?.workspacePath),architectAgentId:bB(c?.architectAgentId),architectSessionId:T,advisorAgentIds:U,advisorSessionIds:V,lastArchitectRunId:bB(c?.lastArchitectRunId),lastAdvisorRunIds:bC(c?.lastAdvisorRunIds),lastError:bB(c?.lastError)}),Z.intake=(d={...Z.intake,started:!!Z.intake?.started||Z.conversation.some(a=>"user"===a.role)},{started:!!d?.started,initialPrompt:bA(d?.initialPrompt??""),latestPrompt:bA(d?.latestPrompt??""),sources:(d?.sources??[]).map(a=>bh(a)),confirmations:bC(d?.confirmations).map(a=>a.trim()).filter(Boolean).slice(0,3),mode:d?.mode==="advanced"?"advanced":"guided",size:d?.size==="small"||d?.size==="large"?d.size:"medium",reviewRequested:!!d?.reviewRequested,turnCount:Math.max(0,Math.floor(d?.turnCount??0)),inferences:(d?.inferences??[]).map(a=>bi(a)),suggestedReplies:bC(d?.suggestedReplies).slice(0,4)}),Z.company.name=bA(Z.company.name),Z.company.mission=bA(Z.company.mission),Z.company.targetCustomer=bA(Z.company.targetCustomer),Z.company.constraints=bC(Z.company.constraints),Z.company.successSignals=bC(Z.company.successSignals),Z.product.offer=bA(Z.product.offer),Z.product.scopeV1=bC(Z.product.scopeV1),Z.product.nonGoals=bC(Z.product.nonGoals),Z.product.revenueModel=bA(Z.product.revenueModel),Z.product.launchPriority=bC(Z.product.launchPriority),Z.workspace.name=bA(Z.workspace.name),Z.workspace.directory=bB(Z.workspace.directory),Z.workspace.repoUrl=bB(Z.workspace.repoUrl),Z.workspace.existingPath=bB(Z.workspace.existingPath),Z.workspace.stackDecisions=bC(Z.workspace.stackDecisions),Z.workspace.docs=bD(bC(Z.workspace.docs).concat((g=Z.workspace.template,O(g,Z.workspace.rules).map(a=>a.path)))),Z.workspace.docOverrides=N(Z.workspace.docOverrides),Z.team.persistentAgents=Z.team.persistentAgents.map(a=>bj({...a,id:a.id,role:a.role,name:a.name,purpose:a.purpose,enabled:a.enabled,isPrimary:a.isPrimary,emoji:a.emoji,theme:a.theme,skillId:a.skillId,modelId:a.modelId,policy:a.policy,heartbeat:a.heartbeat,responsibilities:a.responsibilities,outputs:a.outputs})).filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b),_){if(!Z.team.persistentAgents.some(a=>a.enabled&&a.isPrimary)){let a=Z.team.persistentAgents.find(a=>a.enabled);a&&(a.isPrimary=!0)}}else{let a,b;if(0===Z.team.persistentAgents.length&&(Z.team.persistentAgents=bn(Z.workspace.template,Z.workspace.name)),!Z.team.persistentAgents.some(a=>a.enabled&&a.isPrimary)){let a=Z.team.persistentAgents.find(a=>a.enabled);a&&(a.isPrimary=!0)}let c=Z.team.persistentAgents.find(a=>a.enabled&&a.isPrimary);c&&Z.workspace.name&&(h=c.name,i=c.role,a=h.trim().toLowerCase(),b=i.trim().toLowerCase(),!a||"default agent"===a||a===b||"primary agent"===a||"workspace agent"===a)&&(c.name=$(Z.workspace.name,c.role,c.name))}Z.operations.channels=Z.operations.channels.map(a=>bl(a.type,a)).filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b),_||0!==Z.operations.channels.length||(Z.operations.channels=bp()),Z.operations.workflows=Z.operations.workflows.map(a=>bk(a)).filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b),_||0!==Z.operations.workflows.length||(Z.operations.workflows=bo(Z.workspace.template,Z.team.persistentAgents)),Z.operations.automations=Z.operations.automations.map(a=>bm(a)).filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b),_||(X=bd((W=bE(Z)).intake.size),W.team.persistentAgents=function(a,b,c){var d;let e,f;if(c<=0)return[];return bz((f=(d=[...b,...bn(a),...(e=bj({id:"ops-lead",role:"Operations Lead",name:"Operations Lead",purpose:"Own automations, reporting cadence, and cross-agent handoffs for the workspace.",responsibilities:["Maintain the operating cadence","Wire recurring automations","Keep handoffs durable"],outputs:["ops brief","automation notes"]}),"research"===a?[bj({id:"analyst",role:"Analyst",name:"Analyst",purpose:"Turn gathered evidence into patterns, themes, and decision-ready summaries.",responsibilities:["Cluster findings","Spot repeated signals","Prepare concise summaries"],outputs:["insight summary","theme map"]}),e]:[e])]).find(a=>a.isPrimary)??d[0])?[f,...d.filter(a=>a.id!==f.id)]:d).slice(0,c).map((a,b)=>bj({...a,enabled:!0,isPrimary:a.isPrimary||0===b}))}(W.workspace.template,W.team.persistentAgents,X.agentCount),W.operations.channels=function(a,b,c){let d=b.find(a=>"internal"===a.type)??bp()[0],e=[...b.filter(a=>"internal"!==a.type),...("content"===a?["telegram","discord","slack"]:["slack","discord","telegram"]).map(b=>bl(b,{id:`${b}-ops`,purpose:"content"===a?"Optional distribution or community surface for a larger operating setup.":"Optional external operating surface for a larger workspace.",enabled:!1,announce:!0}))].filter((a,b,c)=>c.findIndex(b=>b.type===a.type)===b);return[bl("internal",{...d,enabled:!0}),...e.slice(0,c)]}(W.workspace.template,W.operations.channels,X.externalChannelCount),W.operations.workflows=function(a,b,c,d){let e,f,g,h;return d<=0?[]:bz([...b,...bo(a,c),...(e=c.find(a=>a.enabled&&a.isPrimary)?.id,f=by(c,"review"),g=by(c,"learn"),h=by(c,"ops"),[bk({id:"context-sync",name:"research"===a?"Evidence sync":"Context sync",goal:"Pull new context from linked sources and keep the blueprint aligned with reality.",trigger:"manual",ownerAgentId:g??e,collaboratorAgentIds:[e,f].filter(Boolean),successDefinition:"New context is reflected in durable docs, scope, and decision notes.",outputs:["memory/blueprint.md","deliverables/<run>/context-sync.md"]}),bk({id:"ops-rhythm",name:"Operating rhythm",goal:"Review handoffs, automations, and next-step ownership on a repeatable cadence.",trigger:"cron",ownerAgentId:h??f??g??e,collaboratorAgentIds:[e].filter(Boolean),successDefinition:"The workspace has a fresh operator brief and an explicit next batch of work.",outputs:["deliverables/<run>/ops-rhythm.md"]})])]).slice(0,d).map(a=>{var b,d;let e,f,g,h,i;return b=a,e=new Set((d=c).filter(a=>a.enabled).map(a=>a.id)),f=d.find(a=>a.enabled&&a.isPrimary)?.id,g=by(d,"review"),h=by(d,"learn"),i=b.ownerAgentId&&e.has(b.ownerAgentId)?b.ownerAgentId:g??h??f,bk({...b,ownerAgentId:i,collaboratorAgentIds:b.collaboratorAgentIds.filter(a=>e.has(a)&&a!==i),enabled:!0})})}(W.workspace.template,W.operations.workflows,W.team.persistentAgents,X.workflowCount),W.operations.automations=function(a,b,c,d,e){let f,g,h;return e<=0?[]:bz([...b,...(f=by(c,"review")??c.find(a=>a.enabled)?.id,g=by(c,"learn")??f,[bm({id:"daily-triage",name:"Daily triage",description:"Review drift, blockers, and next handoffs every day.",scheduleKind:"every",scheduleValue:"24h",agentId:f,mission:"content"===a?"Review active campaigns, blockers, and next content handoffs. Leave a concise operator brief.":"Inspect the workspace, surface blockers, and leave a concise next-step handoff for the team.",thinking:"medium",channelId:h=d[0]?.id}),bm({id:"weekly-review",name:"Weekly review",description:"Capture progress, decisions, and next bets once per week.",scheduleKind:"every",scheduleValue:"168h",agentId:g,mission:"research"===a?"Summarize evidence gathered this week, open questions, and the next investigation batch.":"Summarize progress, major decisions, and the next delivery batch for this workspace.",thinking:"high",channelId:h})].filter(a=>a.agentId))]).slice(0,e).map(a=>{var b,e,f;let g,h,i,j,k;return b=a,e=c,f=d,g=new Set(e.filter(a=>a.enabled).map(a=>a.id)),h=new Set(f.map(a=>a.id)),i=e.find(a=>a.enabled&&a.isPrimary)?.id,j=by(e,"review"),k=by(e,"learn"),bm({...b,agentId:b.agentId&&g.has(b.agentId)?b.agentId:j??k??i,channelId:b.channelId&&h.has(b.channelId)?b.channelId:f[0]?.id,enabled:!0})})}(W.workspace.template,W.operations.automations,W.team.persistentAgents,W.operations.channels,X.automationCount),Z=W),Z.operations.hooks=Z.operations.hooks.map(a=>({id:bF(a?.id||a?.name||`hook-${Date.now()}`)||`hook-${Date.now()}`,name:a?.name?.trim()||"New hook",source:a?.source?.trim()||"",enabled:a?.enabled!==!1,notes:a?.notes?.trim()||""})).filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b),Z.operations.sandbox=(e=Z.operations.sandbox,{workspaceOnly:e?.workspaceOnly??!0,mode:e?.mode??"default",notes:bC(e?.notes)}),_||(Z.deploy.firstMissions=(Y=(f=Z).team.persistentAgents.find(a=>a.enabled&&a.isPrimary),bD([Y?"Inspect the new workspace, refine docs to match the blueprint, and break the first delivery batch into concrete tasks.":"",f.team.persistentAgents.find(a=>/review/i.test(a.role)&&a.enabled)?"Review the blueprint against the created workspace, call out execution risks, and leave a launch-readiness checklist.":"",f.team.persistentAgents.find(a=>/learn/i.test(a.role)&&a.enabled)?"Capture durable facts, decisions, and conventions in memory files so the team can continue without drift.":""].filter(Boolean))));let aa=bw(Z.company.name),ab=bw(Z.workspace.name);if((!Z.company.name||aa)&&Z.workspace.name&&!ab&&(Z.company.name=Z.workspace.name),(!Z.workspace.name||ab)&&Z.company.name&&!aa&&(Z.workspace.name=Z.company.name),!Z.intake.started)return Z.deploy.blockers=[],Z.deploy.warnings=[],Z.intake.confirmations=[],Z.intake.inferences=[],Z.intake.suggestedReplies=[],Z.readinessScore=0,Z.architectSummary="Start with one prompt. Paste the project goal, website URL, repo, or existing folder and the architect will draft the workspace for you.",Z.stage="intake",Z.status="draft",Z.updatedAt=new Date().toISOString(),Z;let ac=function(a){let b=[],c=bd(a.intake.size);for(let c of a.intake.sources.filter(a=>"error"===a.status))b.push("tr"===bs(a)?`${c.label} kaynağını inceleyemedim. Bu kaynak \xf6nemliyse şirket bağlamını manuel olarak doğrula.`:`I could not inspect ${c.label}. Confirm the company context manually if this source matters.`);return bD(b).slice(0,c.confirmationLimit)}(Z),ad=function(a){let b=[];for(let c of(a.company.name||b.push("Company or workspace name is missing."),a.company.mission||b.push("Mission is missing."),a.company.targetCustomer||b.push("Target customer is missing."),a.workspace.name||b.push("Workspace name is missing."),"clone"!==a.workspace.sourceMode||a.workspace.repoUrl||b.push("Clone mode needs a repository URL."),"existing"!==a.workspace.sourceMode||a.workspace.existingPath||b.push("Existing-folder mode needs a folder path."),a.team.persistentAgents.some(a=>a.enabled)||b.push("At least one persistent agent must be enabled."),a.team.persistentAgents.some(a=>a.enabled&&a.isPrimary)||b.push("One enabled agent must be marked as primary."),a.operations.workflows.some(a=>a.enabled)||b.push("At least one enabled workflow is required."),a.operations.workflows.filter(a=>a.enabled)))c.name&&c.goal&&c.successDefinition||b.push(`Workflow "${c.name||c.id}" is incomplete.`),c.ownerAgentId&&!a.team.persistentAgents.some(a=>a.id===c.ownerAgentId&&a.enabled)&&b.push(`Workflow "${c.name}" points to a missing or disabled owner agent.`);for(let c of a.operations.automations.filter(a=>a.enabled))c.mission&&c.scheduleValue||b.push(`Automation "${c.name}" is incomplete.`),c.agentId&&!a.team.persistentAgents.some(a=>a.id===c.agentId&&a.enabled)&&b.push(`Automation "${c.name}" points to a missing or disabled agent.`);for(let c of a.operations.channels.filter(a=>a.enabled&&a.requiresCredentials))c.credentials.filter(a=>!a.value.trim()).length>0&&b.push(`Channel "${c.name}" is missing required credentials.`);return bD(b)}(Z),ae=(D=[],E=bd((j=Z).intake.size),0===j.product.nonGoals.length&&D.push("No non-goals are defined for V1."),0===j.product.launchPriority.length&&D.push("Launch priorities are not ordered yet."),0===j.company.successSignals.length&&D.push("Success signals are still empty."),0===j.workspace.stackDecisions.length&&"content"!==j.workspace.template&&D.push("Critical stack decisions are not captured yet."),E.automationCount>0&&!j.operations.automations.some(a=>a.enabled)&&D.push("No automation loops are enabled."),E.externalChannelCount>0&&!j.operations.channels.some(a=>"internal"!==a.type)&&D.push("Only internal channels are configured."),E.agentCount>=3&&j.team.maxParallelRuns<2&&D.push("Parallel run limit is conservative for a multi-agent workspace."),bD(D)),af=(k=Z).intake.reviewRequested||"deploying"===k.status||"deployed"===k.status;return Z.intake.confirmations=ac,Z.intake.inferences=(F=[],G=(l=Z).intake.sources.filter(a=>"ready"===a.status).map(a=>a.label),H=l.intake.confirmations.join(" ").toLowerCase(),l.company.name&&F.push(bi({section:"company",label:"Company",value:l.company.name,confidence:bu(l,"company-name"),status:bv(H,"company"),rationale:G.length>0?"Derived from linked context and the current brief.":"Derived from the current brief.",sourceLabels:G})),l.company.mission&&F.push(bi({section:"company",label:"Mission",value:l.company.mission,confidence:bu(l,"mission"),status:bv(H,"outcome"),rationale:"Architect condensed the first business outcome from the request.",sourceLabels:G})),l.company.targetCustomer&&F.push(bi({section:"company",label:"First audience",value:l.company.targetCustomer,confidence:bu(l,"target-customer"),status:bv(H,"audience"),rationale:"This is the current best guess for the first user or buyer segment.",sourceLabels:G})),F.push(bi({section:"workspace",label:"Workspace type",value:bG(l.workspace.template),confidence:bu(l,"template"),status:"inferred",rationale:"Template is inferred from the requested operating model and linked context.",sourceLabels:G})),F.push(bi({section:"workspace",label:"Starting point",value:"clone"===l.workspace.sourceMode?l.workspace.repoUrl||"Clone an existing repository":"existing"===l.workspace.sourceMode?l.workspace.existingPath||"Attach an existing folder":"Start from scratch",confidence:bu(l,"source-mode"),status:bv(H,"start"),rationale:"This is how the workspace will be materialized when you deploy.",sourceLabels:G})),l.product.offer&&F.push(bi({section:"product",label:"Offer",value:l.product.offer,confidence:bu(l,"offer"),status:"inferred",rationale:"Architect turned the brief into a concrete operator-facing offer.",sourceLabels:G})),(I=l.operations.channels.filter(a=>a.enabled&&"internal"!==a.type)).length>0&&F.push(bi({section:"operations",label:"External channels",value:I.map(a=>a.name).join(", "),confidence:bu(l,"channels"),status:"inferred",rationale:"The request implies these operating channels should exist after deploy.",sourceLabels:G})),(J=l.team.persistentAgents.find(a=>a.enabled&&a.isPrimary))&&F.push(bi({section:"team",label:"Primary operator",value:`${J.name} (${J.role})`,confidence:bu(l,"team"),status:"inferred",rationale:"Architect drafted a primary agent to own the first delivery loop.",sourceLabels:G})),(K=l.operations.workflows.find(a=>a.enabled))&&F.push(bi({section:"operations",label:"First workflow",value:K.name,confidence:bu(l,"workflow"),status:"inferred",rationale:"This is the first operational loop the company would run after deploy.",sourceLabels:G})),F.slice(0,8)),Z.intake.suggestedReplies=(m=Z,n=ac,L=bs(m),M=[],P=bd(m.intake.size),Q=function(a){let b=a.intake.sources.filter(a=>"ready"===a.status).flatMap(a=>[a.label,a.summary,...a.details]).join(" ").toLowerCase();if(!b)return;let c=/\bweb3|onchain|crypto|blockchain|token\b/.test(b),d=/\bstartup|startups|founder|founders|business(?:es)?\b/.test(b),e=/\bcommunity|communities|member|members|holder|holders|nft|dao|governance\b/.test(b),f=/\bdeveloper|developers|builder|builders|engineer|engineers\b/.test(b),g=/\boperator|operators|moderator|moderators|admin|admins|ops\b/.test(b);return d&&e?c?"Web3 startups and token-led communities":"startups and their communities":d?c?"Web3 startups and founders":"startups and founders":e?c?"DAO, NFT, and Web3 communities":"community leads and members":f&&g?"developers and internal operators":f?"developers and technical teams":g?"internal operators and moderators":void 0}(m),R=br(m),m.company.targetCustomer||(Q&&M.push("tr"===L?`İlk hedef kitle ${bx(Q)} gibi g\xf6r\xfcn\xfcyor.`:`The first audience looks like ${bx(Q)}.`),"content"===m.workspace.template?(M.push("tr"===L?"İlk kullanıcılar topluluk y\xf6neticileri ve moderat\xf6rler.":"The first users are community managers and moderators."),M.push("tr"===L?"İlk kullanıcılar daha hızlı moderasyon ve onboarding isteyen Telegram \xfcyeleri.":"The first users are Telegram members who need faster moderation and onboarding.")):M.push("tr"===L?"İlk kullanıcılar bu iş akışını her g\xfcn y\xfcr\xfcten operat\xf6rler.":"The first users are the operators running this workflow every day.")),m.company.mission||M.push("tr"===L?"İlk hedef, hacmi en y\xfcksek manuel iş akışını otomatikleştirmek.":"The first outcome is automating the highest-volume manual workflow."),!m.product.scopeV1.length&&m.company.mission&&m.company.targetCustomer&&M.push("tr"===L?"V1, genişlemeden \xf6nce en dar ama faydalı d\xf6ng\xfcy\xfc u\xe7tan uca \xe7\xf6zmeli.":"V1 should handle the narrowest useful loop end to end before we expand."),m.workspace.repoUrl||m.workspace.existingPath||bt(m.intake.latestPrompt||m.intake.initialPrompt)||(M.push("tr"===L?"Şimdilik varsayılan bir başlangı\xe7la ilerleyelim; kaynak t\xfcr\xfcn\xfc daha sonra istediğin gibi revize edebiliriz.":"We can proceed with a default starting point and revise the source later if you want."),M.push("tr"===L?"Eğer bir repo ya da mevcut klas\xf6r istiyorsan sonraki mesajda sadece onu s\xf6ylemen yeterli.":"If you want a repo or existing folder, just say so in the next edit.")),0===m.company.successSignals.length&&m.intake.turnCount>=2&&M.push("tr"===L?"Başarı; daha az manuel iş, daha hızlı yanıt s\xfcreleri ve daha net bir operasyon ritmi demek.":"Success means less manual work, faster response times, and a clearer operating cadence."),0!==n.length||R||(M.push("tr"===L?"İstersen bu taslağı şimdi daha keskin hale getirebiliriz.":"If you want, we can tighten this draft right now."),M.push("tr"===L?"Gelişmiş edit\xf6r\xfc a\xe7.":"Open the advanced editor.")),bD(M).slice(0,P.suggestedReplyLimit)),Z.deploy.blockers=af?ad:[],Z.deploy.warnings=af?ae:[],Z.readinessScore=(o=Z,p=ad,q=ae,r=af,S=14,o.company.name&&(S+=10),o.company.mission&&(S+=15),o.company.targetCustomer&&(S+=15),o.product.offer&&(S+=10),o.product.scopeV1.length>0&&(S+=10),o.workspace.name&&(S+=10),o.intake.sources.length>0&&(S+=6),o.team.persistentAgents.some(a=>a.enabled&&a.isPrimary)&&(S+=10),o.operations.workflows.some(a=>a.enabled)&&(S+=10),o.operations.automations.some(a=>a.enabled)&&(S+=5),r?(S-=12*p.length,S-=3*q.length):S-=4*Math.max(0,o.intake.confirmations.length-1),Math.max(0,Math.min(100,S))),Z.architectSummary=function(a,b,c,d){let e=bs(a),f=br(a),g=a.intake.sources.find(a=>"website"===a.kind&&"ready"===a.status&&"number"==typeof a.confidence&&a.confidence<80&&!!a.label),h=a.team.persistentAgents.filter(a=>a.enabled).length,i=a.operations.workflows.filter(a=>a.enabled).length,j=a.operations.automations.filter(a=>a.enabled).length,k=a.intake.confirmations.length;if(!a.intake.started)return"tr"===e?"Tek mesajla başla.":"Start with one prompt.";if(!d&&f){let b=a.company.mission||a.product.offer||a.company.name||a.workspace.name,c="clone"===a.workspace.sourceMode?"tr"===e?"klon repo":"a cloned repo":"existing"===a.workspace.sourceMode?"tr"===e?"mevcut klas\xf6r":"an existing folder":"tr"===e?"sıfırdan":"scratch",d=!g||a.company.name||a.workspace.name?"":"tr"===e?`Site adı i\xe7in ${g.label} varsayımını kullandım.`:`I used ${g.label} as the site name.`;return"tr"===e?[d,b?`İlk taslak ${b} etrafında hazır.`:`İlk taslak ${c} başlangıcıyla hazır.`].filter(Boolean).join(" "):[d,b?`First pass ready around ${b}.`:`First pass ready from ${c}.`].filter(Boolean).join(" ")}return d?"tr"===e?[a.company.mission?`Odak: ${a.company.mission}.`:"Misyon kısa bir c\xfcmle istiyor.",a.company.targetCustomer?`Kitle: ${a.company.targetCustomer}.`:"Kitle a\xe7ık.",`${h} agent, ${i} g\xf6rev, ${j} automation.`,k>0?`${k} revizyon kaldı.`:b.length>0?`${b.length} blocker kaldı.`:c.length>0?`${c.length} warning var.`:"Deploy'a hazır."].join(" "):[a.company.mission?`Focus: ${a.company.mission}.`:"Mission still needs a short sentence.",a.company.targetCustomer?`Audience: ${a.company.targetCustomer}.`:"Audience open.",`${h} agents, ${i} workflows, ${j} automations.`,k>0?`${k} revision${1===k?"":"s"} left.`:b.length>0?`${b.length} blocker${1===b.length?"":"s"} remain.`:c.length>0?`${c.length} warning${1===c.length?"":"s"} remain.`:"Ready to deploy."].join(" "):"tr"===e?[a.company.mission?`Odak: ${a.company.mission}.`:a.company.name||a.workspace.name?`İlk \xe7ıktı: ${a.company.name||a.workspace.name}.`:"İlk \xe7ıktı netleşiyor.",a.company.targetCustomer?`Kitle: ${a.company.targetCustomer}.`:"Kitle a\xe7ık.",a.intake.sources.length>0?`${a.intake.sources.length} kaynak topladım.`:"URL, repo ya da kısa brief yeterli.",`${h} agent, ${i} g\xf6rev, ${j} automation.`,k>0?`${k} revizyon kaldı.`:"Revizyona hazır."].join(" "):[a.company.mission?`Focus: ${a.company.mission}.`:`First outcome: ${a.company.name||a.workspace.name||"this workspace"}.`,a.company.targetCustomer?`Audience: ${a.company.targetCustomer}.`:"Audience open.",a.intake.sources.length>0?`I have ${a.intake.sources.length} source${1===a.intake.sources.length?"":"s"}.`:"Add a URL, repo, or short brief.",`${h} agents, ${i} workflows, ${j} automations.`,k>0?`${k} revision${1===k?"":"s"} left.`:"Ready to revise."].join(" ")}(Z,ad,ae,af),Z.stage=(s=Z,t=ad,u=ae,v=ac,w=af,s.intake.started?!w&&br(s)?s.intake.sources.length>0?"context-harvest":"intake":"deploying"===s.status?"deploying":"deployed"===s.status?"deployed":(x=s).company.mission||x.product.offer||x.workspace.name||x.intake.sources.length>0?((y=s).company.name||y.workspace.name)&&y.company.mission&&y.team.persistentAgents.some(a=>a.enabled)&&y.operations.workflows.some(a=>a.enabled)?w?t.length>0?"pressure-test":u.length>0||s.readinessScore<90?"decision-lock":"ready":v.length>0?"team-synthesis":"decision-lock":"team-synthesis":s.intake.turnCount>1?"context-harvest":"intake":"intake"),Z.status=(z=Z,A=ad,B=ac,C=af,z.intake.started?"deploying"===z.status||"deployed"===z.status?z.status:C?"blocked"===z.status&&A.length>0||A.length>0?"blocked":z.readinessScore>=90?"ready":"review":br(z)||B.length>0?"draft":"review":"draft"),Z.updatedAt=new Date().toISOString(),Z}function br(a){return a.intake.turnCount<=1&&!a.intake.reviewRequested}function bs(a,b){for(let d of[b,...a.conversation.slice().reverse().filter(a=>"user"===a.role).map(a=>a.text),a.intake.latestPrompt,a.intake.initialPrompt]){var c;let a=!function(a){let b=a?.trim();if(!b)return!1;if(/[çğıöşüÇĞİÖŞÜ]/.test(b))return!0;let c=b.toLowerCase().match(/\b(ve|bir|bu|şu|için|ile|olarak|olan|mı|mi|mu|mü|ne|nasıl|hangi|neden|hedef|ilk|müşteri|kullanıcı|oluştur|gerekli|alanları|yardımcı)\b/g);return!!(c&&c.length>=2)}(c=d)?!function(a){let b=a?.trim();if(!b||/[çğıöşüÇĞİÖŞÜ]/.test(b))return!1;let c=b.toLowerCase().match(/\b(let'?s|the|and|for|with|from|this|that|what|how|why|when|where|who|should|could|would|need|want|start|build|create|launch|project|workspace|customer|user|team|goal|mission|review|deploy|product|website|repo|folder)\b/g);return!!(c&&c.length>=2)}(c)?null:"en":"tr";if(a)return a}return"en"}function bt(a){return/\b(from scratch|greenfield|empty workspace|clone|repo|existing folder|existing workspace|s[ıi]f[ıi]rdan|mevcut klas[oö]r|mevcut repo|bo[sş])\b/i.test(a)}function bu(a,b){let c=`${a.intake.initialPrompt} ${a.intake.latestPrompt}`.toLowerCase(),d=a.intake.sources.filter(a=>"ready"===a.status),e=66;return d.length>0&&(e+=8),a.intake.turnCount>1&&(e+=6),("template"===b&&/\b(telegram|discord|community|topluluk|grup|content|marketing|research|frontend|backend)\b/.test(c)||"source-mode"===b&&bt(c)||"channels"===b&&/\b(slack|telegram|discord|google chat)\b/.test(c))&&(e+=10),"company-name"===b&&d.some(a=>"website"===a.kind)&&(e+=6),"target-customer"!==b||a.company.targetCustomer||(e-=18),("workflow"===b||"team"===b)&&(e-=4),Math.max(52,Math.min(96,e))}function bv(a,b){return a.includes(b)?"needs-confirmation":"inferred"}function bw(a){let b=a.toLowerCase();return/\b(yapal[ıi]m|ekleyelim|başlatal[ıi]m|kural[ıi]m|olsun|diyelim|verelim|koyal[ıi]m|kurmak|kurulum|oluşturmak|oluşturma|başlatmak|başlama|yapmak|yapma|istiyorum|istiyoruz|istemek|want|build|create|make|start|launch|setup|set up)\b/.test(b)}function bx(a){return a?a.charAt(0).toLowerCase()+a.slice(1):a}function by(a,b){return a.find(a=>RegExp(b,"i").test(`${a.id} ${a.role} ${a.name}`))?.id}function bz(a){return a.filter((a,b,c)=>c.findIndex(b=>b.id===a.id)===b)}function bA(a){return a.trim()}function bB(a){return a?.trim()||void 0}function bC(a){return bD((a??[]).flatMap(a=>a.split(/\r?\n|,/g).map(a=>a.trim()).filter(Boolean)).map(a=>a.trim()).filter(Boolean))}function bD(a){return Array.from(new Set(a.filter(Boolean)))}function bE(a){return structuredClone(a)}function bF(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function bG(a){return a.split(/[-_]/g).filter(Boolean).map(a=>a[0].toUpperCase()+a.slice(1)).join(" ")}var bH=c(98895),bI=c(90665);let bJ=new Set(["a","an","and","autonomous","automate","automated","automation","build","create","for","from","in","launch","new","of","on","project","run","runs","set","setup","start","that","the","to","up","workspace","adı","agent","ajan","asistan","benim","bide","bir","birde","de","diye","ekleyelim","gibi","i\xe7in","olarak","olsun","proje","şahsi","verelim","yeni"]);function bK(){return{name:"",goal:"",source:""}}function bL(a){let b=a.trim();if(!b)return{kind:"empty",createSourceMode:"empty",label:"Fresh workspace",hint:"AgentOS will scaffold a new project folder."};if(bP(b))return{kind:"existing",createSourceMode:"existing",label:"Existing folder",hint:b,existingPath:b};if(bQ(b))return{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:b,repoUrl:b};let c=bR(b);return c?bS(c)?{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:c,repoUrl:c}:{kind:"website",createSourceMode:"empty",label:"Fresh workspace + website",hint:c,websiteUrl:c}:{kind:"context",createSourceMode:"empty",label:"Fresh workspace + context",hint:"The pasted source will be attached to the brief.",contextText:b}}function bM(a){let b=a.toLowerCase();return/\b(telegram|discord|community|channel automation|campaign|content|marketing|growth|seo|newsletter)\b/.test(b)?"content":/\b(frontend|ui|website|landing page|design system|dashboard)\b/.test(b)?"frontend":/\b(backend|api|service|microservice|worker|cron|queue|sdk)\b/.test(b)?"backend":/\b(research|investigation|analysis|benchmark|thesis)\b/.test(b)?"research":"software"}function bN(a){return a.name.trim()||function(a,b){let c=function(a){let b=a.trim();if(!b)return;if(bQ(b))return bT(b.split(":").at(-1)??"");let c=bR(b);return c?bS(c)?bT(new URL(c).pathname):function(a){try{let[b]=new URL(a).hostname.replace(/^www\./,"").split(".");if(!b)return;return b.split(/[-_]+/g).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}catch{return}}(c):bP(b)?bT(b):void 0}(a);if(c)return c;let d=function(a){let b=a.match(/["“]([^"”]+)["”]/)?.[1]?.trim();if(b)return b;for(let b of[/\b(?:adı|ismi|name)\s*(?:olarak|:|=)?\s*([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})(?=\s+(?:olsun|olacak|diyelim|verelim|koyalım|olarak|için)\b|[.!?,]|$)/iu,/\b([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})\s+diye\b/iu]){let c=(a.match(b)?.[1]??"").replace(/\b(yeni|bir|workspace|project|proje|ekleyelim|kuralım|başlatalım|oluşturalım)\b/giu," ").replace(/\b(diye|olarak|benim|bide|bir de)\b.*$/iu,"").replace(/\s+/g," ").trim();if(c)return c}}(b);if(d)return d;let e=b.toLowerCase().replace(/[^a-z0-9\s-]+/g," ").split(/\s+/).map(a=>a.trim()).filter(a=>a&&!bJ.has(a)).slice(0,4);return 0===e.length?"":e.map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}(a.source,a.goal)||"New Workspace"}function bO(a){let b=a.workspace.repoUrl?.trim()||a.workspace.existingPath?.trim()||a.intake.sources.find(a=>"website"===a.kind)?.url||a.intake.sources.find(a=>"prompt"===a.kind)?.summary||"";return{name:a.workspace.name||"",goal:a.company.mission||a.product.offer||a.intake.latestPrompt||"",source:b}}function bP(a){return a.startsWith("/")||a.startsWith("./")||a.startsWith("../")}function bQ(a){return/^git@[^:]+:[^/].+/.test(a)}function bR(a){if(a.includes("@"))return null;let b=a.replace(/[),.;!?]+$/g,""),c=/^https?:\/\//i.test(b)?b:`https://${b}`;try{let a=new URL(c);return a.hostname.includes(".")?a.toString():null}catch{return null}}function bS(a){try{let b=new URL(a),c=b.hostname.toLowerCase(),d=b.pathname.toLowerCase();return"github.com"===c||"gitlab.com"===c||"bitbucket.org"===c||d.endsWith(".git")}catch{return!1}}function bT(a){let b=a.replace(/\\/g,"/").replace(/\/+$/g,"").split("/").filter(Boolean).at(-1)?.replace(/\.git$/i,"");if(b)return b.split(/[-_]+/g).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}let bU="workspace-wizard-basic-source",bV="Imported quick setup assumptions:";function bW(a="standard"){return{...W,workspaceOnly:!0,generateStarterDocs:"fastest"!==a,generateMemory:"fastest"!==a,kickoffMission:"fastest"!==a}}function bX(a){return{...bW(),...a,workspaceOnly:!0}}function bY(a,b,c,d){let e=structuredClone(a),f=bL(b.source),g=bN(b),h=b.goal.trim();return e.intake.mode=e.intake.mode||"guided",e.intake.started=!!(h||b.source.trim()),h&&(e.intake.initialPrompt||(e.intake.initialPrompt=h),e.intake.latestPrompt=h,e.company.mission=h,e.product.offer.trim()||(e.product.offer=h)),e.workspace.name=g,e.workspace.sourceMode=f.createSourceMode,e.workspace.repoUrl=f.repoUrl,e.workspace.existingPath=f.existingPath,e.workspace.template=d?.template??bM(`${h}
|
|
183
183
|
${b.source}`),e.workspace.modelProfile=d?.modelProfile??e.workspace.modelProfile??"balanced",e.workspace.rules=bX(c??e.workspace.rules),e.intake.sources=e.intake.sources.filter(a=>a.id!==bU),"empty"!==f.kind&&e.intake.sources.unshift(bh({id:bU,kind:"clone"===f.kind?"repo":"existing"===f.kind?"folder":"website"===f.kind?"website":"prompt",label:f.label,summary:f.hint,details:[f.hint],url:f.repoUrl??f.websiteUrl})),bq(e)}function bZ(a){return bX(a.workspace.rules)}let b$="mission-control-workspace-plan-id";function b_({open:a,onOpenChange:b,initialMode:c="basic",workspaceEditId:k=null,surfaceTheme:l,snapshot:m,onRefresh:n,onWorkspaceCreated:o,onWorkspaceUpdated:q}){let r=!!k,t=function({open:a,initialMode:b,workspaceEditId:c,onRefresh:d,onWorkspaceCreated:e,onWorkspaceUpdated:f}){let[g,h]=(0,p.useState)(b),[i,j]=(0,p.useState)(null),[k,l]=(0,p.useState)(null),[m,n]=(0,p.useState)(!1),[o,q]=(0,p.useState)(bK),[r,s]=(0,p.useState)(()=>bW("fastest")),[t,u]=(0,p.useState)(!0),[v,w]=(0,p.useState)(()=>bM("")),[x,y]=(0,p.useState)("solo"),[z,A]=(0,p.useState)("balanced"),[B,C]=(0,p.useState)(null),[D,E]=(0,p.useState)(!1),[F,G]=(0,p.useState)(!1),[H,I]=(0,p.useState)(!1),[J,K]=(0,p.useState)(!1),[M,N]=(0,p.useState)(!1),[O,P]=(0,p.useState)(!1),[Q,R]=(0,p.useState)(!1),[S,T]=(0,p.useState)(!1),[,U]=(0,p.useState)(null),[V,W]=(0,p.useState)(null),[X,Y]=(0,p.useState)(null),[$,_]=(0,p.useState)(0),[aa,ab]=(0,p.useState)(null),ac=(0,p.useRef)(null),ad=(0,p.useRef)(null),ae=(0,p.useRef)(null),af=(0,p.useMemo)(()=>c?`${b$}:${c}`:b$,[c]),ag=(0,p.useMemo)(()=>bL(o.source),[o.source]),ah=(0,p.useMemo)(()=>{let a;return(a=bX(r)).generateStarterDocs||a.generateMemory||a.kickoffMission?a.generateStarterDocs&&a.generateMemory&&a.kickoffMission?"standard":"custom":"fastest"},[r]),ai=(0,p.useMemo)(()=>(function({initialTurn:a,step:b,active:c}){return c?a?b>=2?{title:"Still working",description:"The first turn is the slowest. The planner is usually inspecting links, extracting intent, and narrowing the plan."}:b>=1?{title:"Collecting context",description:"The architect is reading the prompt, extracting intent, and drafting the next clarifying question."}:{title:"Starting planner",description:"The architect is opening the planning session and preparing the first intent pass."}:b>=2?{title:"Still working",description:"The architect is waiting on the planner runtime. This can happen when linked context or advisor runs take longer."}:b>=1?{title:"Updating draft",description:"Refreshing context, specialist notes, and the current workspace plan."}:{title:"Architect thinking",description:"Applying your latest direction to the workspace draft."}:null})({initialTurn:!i?.intake.started,step:F?$:0,active:F||Q||S}),[S,Q,F,i?.intake.started,$]),aj=(0,p.useCallback)(a=>(ad.current=a,j(a),n(!!a),a)?(l(a.id),q(bO(a)),s(bZ(a)),globalThis.localStorage?.setItem(af,a.id),a):(l(null),null),[af]),ak=(0,p.useCallback)(a=>{if(!i)return null;let b=bq(a(structuredClone(i)));return aj(b),b},[aj,i]),al=(0,p.useCallback)(()=>globalThis.localStorage?.getItem(af)??null,[af]),am=(0,p.useCallback)(()=>{globalThis.localStorage?.removeItem(af),n(!1)},[af]),an=(0,p.useCallback)(async({resumeStored:a})=>{if(c){let b=a?globalThis.localStorage?.getItem(af):null;if(b){let a=await fetch(`/api/planner/${b}`,{cache:"no-store"});if(a.ok)return(await a.json()).plan}let d=await fetch(`/api/workspaces/${c}/edit-draft`,{method:"POST"}),e=await d.json();if(!d.ok||!e.plan)throw Error(e.error||"Unable to create workspace edit draft.");return e.seed&&(ae.current=e.seed,U(e.seed)),e.plan}let b=a?globalThis.localStorage?.getItem(af):null;if(b){let a=await fetch(`/api/planner/${b}`,{cache:"no-store"});if(a.ok)return(await a.json()).plan}let d=await fetch("/api/planner",{method:"POST"}),e=await d.json();if(!d.ok||!e.plan)throw Error(e.error||"Unable to create planner workspace.");return e.plan},[af,c]),ao=(0,p.useCallback)(async({resumeStored:a,draftOverride:b})=>{if(i)return i;if(ac.current)return ac.current;let c=(async()=>{E(!0);try{let c=await an({resumeStored:a}),d=b??o,e=d.goal.trim()||d.source.trim()||d.name.trim()?bY(c,d,r,{template:v,modelProfile:z}):c;return aj(e)}catch(a){return a9.o.error("Workspace architect could not start.",{description:a instanceof Error?a.message:"Unknown planner error."}),null}finally{E(!1),ac.current=null}})();return ac.current=c,c},[o,z,r,v,aj,i,an]),ap=(0,p.useCallback)(async()=>{if(C(null),W(null),Y(null),G(!1),I(!1),K(!1),N(!1),P(!1),R(!1),ab(null),ac.current=null,c){am(),j(null),ad.current=null,l(null),await ao({resumeStored:!1,draftOverride:void 0})&&h("advanced");return}if("basic"===g){am(),j(null),ad.current=null,l(null),q(bK()),s(bW("fastest")),u(!0),w(bM("")),y("solo"),A("balanced");return}am(),j(null),ad.current=null,l(null);let a=bK();q(a),s(bW("fastest")),u(!0),w(bM("")),y("solo"),A("balanced"),await ao({resumeStored:!1,draftOverride:a})&&h("advanced")},[am,ao,g,c]),aq=(0,p.useCallback)(()=>{am(),C(null)},[am]),ar=(0,p.useCallback)(async a=>{let b=a??ad.current;if(!b||!k)return!1;I(!0);try{let a=await fetch(`/api/planner/${k}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:b})}),c=await a.json();if(!a.ok||!c.plan)throw Error(c.error||"Unable to save planner workspace.");return aj(c.plan),a9.o.success("Planner draft saved."),!0}catch(a){return a9.o.error("Planner draft could not be saved.",{description:a instanceof Error?a.message:"Unknown planner save error."}),!1}finally{I(!1)}},[aj,k]),as=(0,p.useCallback)(async a=>{let b=a??ad.current;if(!b||!k)return!1;K(!0);try{let a=await fetch(`/api/planner/${k}/simulate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:b})}),c=await a.json();if(!a.ok||!c.plan)throw Error(c.error||"Unable to simulate planner team.");return aj(c.plan),a9.o.success("Planner team simulated."),!0}catch(a){return a9.o.error("Planner simulation failed.",{description:a instanceof Error?a.message:"Unknown planner simulation error."}),!1}finally{K(!1)}},[aj,k]),at=(0,p.useCallback)(()=>{ak(a=>(a.intake.mode="advanced",a.intake.reviewRequested=!0,a.advisorNotes=[],a.conversation.push(bg("assistant","Workspace Architect","Deploy review is open now. I am surfacing the real blockers and warnings that matter before launch.")),a))},[ak]),au=(0,p.useCallback)(async()=>{if(c)return null;let a=await ao({resumeStored:!1,draftOverride:o})??ad.current;if(!a)return null;let b=bY(a,o,r,{template:v,modelProfile:z});aj(b),P(!0),Y((0,bH.sg)({...(0,bH.fV)({sourceMode:b.workspace.sourceMode,agentCount:Z(b.workspace.template,x,b.workspace.name).filter(a=>a.enabled).length,kickoffMission:b.workspace.rules.kickoffMission??!0})}));try{let a=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...function(a,b={}){var c;return{name:a.workspace.name,brief:[(c=a).company.mission.trim()||c.product.offer.trim(),c.company.name.trim()?`Company: ${c.company.name.trim()}`:null,c.company.targetCustomer.trim()?`Audience: ${c.company.targetCustomer.trim()}`:null,c.product.offer.trim()?`Offer: ${c.product.offer.trim()}`:null,c.company.successSignals.length>0?`Success signals: ${c.company.successSignals.join(", ")}`:null,c.product.scopeV1.length>0?`Scope: ${c.product.scopeV1.join(", ")}`:null,...c.intake.sources.flatMap(a=>{if(a.id!==bU&&"website"!==a.kind)return[];if("repo"===a.kind&&a.url)return[`Bootstrap source: clone ${a.url}`];if("folder"===a.kind)return[`Bootstrap source: existing folder ${a.summary}`];if("website"===a.kind&&a.url){let b="number"==typeof a.confidence?` (${a.confidence}%)`:"";return[`Reference website${b}: ${a.url} - ${a.summary}`]}return"prompt"===a.kind?[`Additional context: ${a.summary}`]:[]})].filter(a=>!!a?.trim()).join("\n"),directory:a.workspace.directory,modelId:a.workspace.modelId,sourceMode:a.workspace.sourceMode,repoUrl:a.workspace.repoUrl,existingPath:a.workspace.existingPath,template:a.workspace.template,teamPreset:b.teamPreset??"solo",modelProfile:a.workspace.modelProfile||"balanced",docOverrides:a.workspace.docOverrides,rules:bX(a.workspace.rules),contextSources:a.intake.sources}}(b,{teamPreset:x}),stream:!0})});if(!a.ok){let b=await a.json().catch(()=>null);throw Error(b?.error||"OpenClaw could not create the workspace.")}let c=null,f=null;if(await (0,ba.z)(a,async a=>{"progress"===a.type?Y(a.progress):(a.progress&&Y(a.progress),a.ok?c=a.result:f=a.error)}),f||!c)throw Error(f||"OpenClaw could not create the workspace.");let g=c;return am(),await d(),e(g.workspaceId),a9.o.success("Workspace created.",{description:`${g.agentIds.length} agent${1===g.agentIds.length?"":"s"} created at ${g.workspacePath}`}),g.warnings?.length&&a9.o.message("Workspace created with a sync warning.",{description:g.warnings[0]}),g.kickoffError&&a9.o.message("Workspace created, but kickoff needs attention.",{description:g.kickoffError}),g}catch(a){return a9.o.error("Workspace creation failed.",{description:a instanceof Error?a.message:"Unknown workspace error."}),null}finally{P(!1)}},[o,z,r,x,v,am,aj,ao,d,e,c]),av=(0,p.useCallback)(async()=>{let a=ad.current,b=ae.current;if(!a||!c)return null;T(!0);try{let e=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:c,name:a.workspace.name,directory:a.workspace.directory,plan:a,baseline:b})}),g=await e.json();if(!e.ok||g.error)throw Error(g.error||"OpenClaw could not update the workspace.");return am(),await d(),f?.(g.workspaceId??c),a9.o.success("Workspace updated.",{description:g.workspacePath||a.workspace.directory||a.workspace.name}),g}catch(a){return a9.o.error("Workspace update failed.",{description:a instanceof Error?a.message:"Unknown workspace error."}),null}finally{T(!1)}},[am,d,f,c]),aw=(0,p.useCallback)(async()=>{let a=ad.current;if(!a||!k)return null;N(!0),W((0,bH.sg)((0,bH.Bb)({sourceMode:a.workspace.sourceMode??"empty",agentCount:a.team.persistentAgents.filter(a=>a.enabled).length,kickoffMission:a.workspace.rules.kickoffMission??!0,hasChannels:!!a.operations.channels.some(a=>a.enabled&&"internal"!==a.type),hasAutomations:!!a.operations.automations.some(a=>a.enabled),hasPlannerKickoffs:!!a.deploy.firstMissions.some(a=>a.trim().length>0)})));try{let b=await fetch(`/api/planner/${k}/deploy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:a,stream:!0})});if(!b.ok){let a=await b.json().catch(()=>null);throw Error(a?.error||"Unable to deploy planner workspace.")}let c=null,f=null;if(await (0,ba.z)(b,async a=>{"progress"===a.type?W(a.progress):(a.progress&&W(a.progress),a.ok?c=a.result:f=a.error)}),f||!c)throw Error(f||"Unable to deploy planner workspace.");let g=c;return aj(g.plan),am(),await d(),e(g.workspaceId),a9.o.success("Workspace deployed.",{description:g.workspacePath}),g}catch(a){return a9.o.error("Planner deploy failed.",{description:a instanceof Error?a.message:"Unknown deploy error."}),null}finally{N(!1)}},[am,aj,d,e,k]),ax=(0,p.useCallback)(async a=>{if(!a.trim())return!1;G(!0),ab(a.trim());try{let c="advanced"===b&&!i&&!o.goal.trim()&&!o.source.trim()&&!o.name.trim(),d=await ao({resumeStored:c,draftOverride:o})??i;if(!d)return!1;let e=await fetch(`/api/planner/${d.id}/turn`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:a,plan:d})}),f=await e.json();if(!e.ok||!f.plan)throw Error(f.error||"Unable to process planner turn.");return aj(f.plan),C(null),!0}catch(a){return a9.o.error("Planner turn failed.",{description:a instanceof Error?a.message:"Unknown planner turn error."}),!1}finally{ab(null),G(!1)}},[o,aj,ao,b,i]),ay=(0,p.useCallback)(async({path:a,currentContent:b,instruction:c})=>{if(!i||!k)return null;let d=a.trim();if(!d)return null;R(!0);try{let a=await fetch(`/api/planner/${k}/document-rewrite`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:i,path:d,currentContent:b,instruction:c?.trim()||"Rewrite this document to improve clarity, usefulness, and consistency with the workspace context."})}),e=await a.json();if(!a.ok||!e.plan)throw Error(e.error||"Unable to rewrite the document.");aj(e.plan),C(null);let f=L({name:e.plan.workspace.name||"Workspace",brief:e.plan.company.mission||e.plan.product.offer||void 0,template:e.plan.workspace.template,sourceMode:e.plan.workspace.sourceMode,rules:e.plan.workspace.rules,agents:e.plan.team.persistentAgents.filter(a=>a.enabled),docOverrides:e.plan.workspace.docOverrides,toolExamples:[],contextSources:e.plan.intake.sources}).find(a=>a.path===d);return a9.o.success(`Architect rewrote ${d}.`,{description:e.reply||"The document override has been updated."}),f?.content??null}catch(a){return a9.o.error("Document rewrite failed.",{description:a instanceof Error?a.message:"Unknown document rewrite error."}),null}finally{R(!1)}},[aj,i,k]),az=(0,p.useCallback)(async()=>{let a=al();if(!a)return n(!1),!1;E(!0);try{let b=await fetch(`/api/planner/${a}`,{cache:"no-store"}),d=await b.json();if(!b.ok||!d.plan)throw Error(d.error||"Unable to load the stored planner draft.");return aj(d.plan),w(d.plan.workspace.template),A(d.plan.workspace.modelProfile),y(d.plan.team.persistentAgents.filter(a=>a.enabled).length>1?"core":"solo"),h("advanced"),C({tone:"muted",title:c?"Resumed workspace edit":"Resumed previous draft",description:c?"Architect restored your earlier edit session so you can keep shaping the same workspace.":"Architect restored your earlier blueprint so you can keep shaping the same workspace."}),!0}catch(a){return a9.o.error("Stored draft could not be resumed.",{description:a instanceof Error?a.message:"Unknown planner error."}),!1}finally{E(!1),ac.current=null}},[aj,al,c]),aA=(0,p.useCallback)(async a=>{if(a!==g){if(c){if("basic"===a)return;h("advanced");return}if("advanced"===a){let a=await ao({resumeStored:!1,draftOverride:o});if(!a)return;let b=bY(a,o,r,{template:v,modelProfile:z}),c=!b.intake.started&&b.conversation.filter(a=>"system"!==a.role).length<=1?function(a,b){let c=structuredClone(a),d=b.goal.trim(),e=b.source.trim();if(c.conversation=c.conversation.filter(a=>!("system"===a.role&&"Workspace Wizard"===a.author&&a.text.startsWith(bV))),!d&&!e)return bq(c);let f=[d?`goal: ${d}`:null,e?`source: ${e}`:null,`fast-path name: ${bN(b)}`].filter(Boolean);return c.conversation.push(bg("system","Workspace Wizard",`${bV} ${f.join(" \xb7 ")}`)),bq(c)}(b,o):b;aj(c),C(c.intake.started||o.goal.trim()||o.source.trim()?{tone:"muted",title:"Same draft, deeper controls",description:"Architect will keep extending the exact same conversation and blueprint as you move into Advanced."}:null),h("advanced");return}if(i)q(bO(i)),s(bZ(i)),w(i.workspace.template),A(i.workspace.modelProfile),y(i.team.persistentAgents.filter(a=>a.enabled).length>1?"core":"solo"),C(i&&(i.team.persistentAgents.filter(a=>a.enabled).length>1||i.operations.workflows.some(a=>a.enabled)||i.operations.automations.some(a=>a.enabled)||i.operations.channels.some(a=>a.enabled&&"internal"!==a.type)||i.operations.hooks.some(a=>a.enabled))?{tone:"warning",title:"Advanced details preserved",description:"Basic mode will keep showing the fast path, but the richer blueprint remains in memory if you switch back."}:null);else C(null);h("basic")}},[o,z,r,v,aj,ao,g,i,c]),aB=(0,p.useCallback)(a=>{q(b=>{let c={...b,goal:a},d=t?bM(`${c.goal}
|
|
184
184
|
${c.source}`):v;return t&&w(d),"basic"===g&&j(a=>{let b=a?bY(a,c,r,{template:d,modelProfile:z}):a;return ad.current=b,b}),c})},[z,r,v,t,g]),aC=(0,p.useCallback)(a=>{q(b=>{let c={...b,source:a},d=t?bM(`${c.goal}
|
|
185
|
-
${c.source}`):v;return t&&w(d),"basic"===g&&j(a=>{let b=a?bY(a,c,r,{template:d,modelProfile:z}):a;return ad.current=b,b}),c})},[z,r,v,t,g]),aD=(0,p.useCallback)(a=>{q(b=>{let c={...b,name:a};return"basic"===g&&j(a=>{let b=a?bY(a,c,r,{template:v,modelProfile:z}):a;return ad.current=b,b}),c})},[z,r,v,g]),aE=(0,p.useCallback)(a=>{u(!1),w(a),j(b=>{let c=b?bY(b,o,r,{template:a,modelProfile:z}):b;return ad.current=c,c})},[o,z,r]),aF=(0,p.useCallback)(a=>{y(a)},[]),aG=(0,p.useCallback)(a=>{A(a),j(b=>{let c=b?bY(b,o,r,{template:v,modelProfile:a}):b;return ad.current=c,c})},[o,r,v]),aH=(0,p.useCallback)(a=>{let b=bW(a);s(b),j(a=>{let c=a?bY(a,o,b,{template:v,modelProfile:z}):a;return ad.current=c,c})},[o,z,v]),aI=(0,p.useCallback)(a=>{s(b=>{let c={...b,[a]:!b[a],workspaceOnly:!0};return j(a=>{let b=a?bY(a,o,c,{template:v,modelProfile:z}):a;return ad.current=b,b}),c})},[o,z,v]);return{mode:g,plan:i,planId:k,hasStoredDraft:m,notice:B,sourceAnalysis:ag,basicDraft:o,basicRules:r,basicPreset:ah,basicTemplate:v,basicTeamPreset:x,basicModelProfile:z,isPlanLoading:D,isSending:F,isSaving:H,isSimulating:J,isDeploying:M,isCreating:O,isApplyingWorkspaceChanges:S,isDocumentRewriting:Q,createProgress:X,deployProgress:V,architectBusyStatus:ai,pendingUserMessage:aa,setBasicGoal:aB,setBasicSource:aC,setBasicName:aD,setBasicTemplate:aE,setBasicTeamPreset:aF,setBasicModelProfile:aG,setBasicPreset:aH,toggleBasicRule:aI,setNotice:C,updatePlan:ak,switchMode:aA,startFreshDraft:ap,discardStoredDraft:aq,resumeStoredDraft:az,savePlan:ar,simulatePlan:as,requestReview:at,createWorkspace:au,deployPlan:aw,applyWorkspaceChanges:av,submitArchitectTurn:ax,rewriteDocumentWithArchitect:ay}}({open:a,initialMode:c,workspaceEditId:k,onRefresh:n,onWorkspaceCreated:o,onWorkspaceUpdated:q}),[v,w]=(0,p.useState)(""),[x,y]=(0,p.useState)(!1),[z,A]=(0,p.useState)(!1),[B,C]=(0,p.useState)(!1),[D,E]=(0,p.useState)("intake"),[F,G]=(0,p.useState)("workspace.name"),[H,I]=(0,p.useState)("AGENTS.md"),J="light"===l,K=r?m.workspaces.find(a=>a.id===k)??null:null,M=a=>{a||(w(""),y(!1),A(!1),C(!1),E("intake"),G("workspace.name"),I("AGENTS.md")),b(a)},N=r?t.plan?.workspace.name??K?.name??bN(t.basicDraft):bN(t.basicDraft),O=r?t.plan?.workspace.template??K?.bootstrap.template??t.basicTemplate:t.plan?.workspace.template??t.basicTemplate,P=r?t.plan?.workspace.directory??K?.path??m.diagnostics.workspaceRoot:function(a,b,c=bL(b.source)){if("existing"===c.kind&&c.existingPath)return c.existingPath;let d=bN(b).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return`${(0,bI.$7)(a)}/${d||"workspace"}`}(m.diagnostics.workspaceRoot,t.basicDraft,t.sourceAnalysis),Q=(0,p.useMemo)(()=>(function(a,b,c,d){let e=[{id:"surface",label:c?"Editing workspace":"basic"===a?"Architect-assisted fast path":"Architect co-design",tone:"muted"}];return!c&&"basic"===a&&d&&e.push({id:"step",label:`Step ${b6.findIndex(a=>a.id===d)+1} / 3 \xb7 ${b6.find(a=>a.id===d)?.label??"Intake"}`,tone:"muted"}),b&&("basic"===a?b.intake.confirmations.length>0?e.push({id:"confirmations",label:`${b.intake.confirmations.length} decision${1===b.intake.confirmations.length?"":"s"} needed`,tone:b.intake.confirmations.length>1?"warning":"muted"}):b.intake.started&&e.push({id:"draft",label:"Draft synced live",tone:"muted"}):(b.intake.confirmations.length>0&&e.push({id:"confirmations",label:`${b.intake.confirmations.length} decision${1===b.intake.confirmations.length?"":"s"} needed`,tone:b.intake.confirmations.length>1?"warning":"muted"}),e.push({id:"stage",label:`Stage \xb7 ${aw(b.stage)}`,tone:"muted"}),e.push({id:"readiness",label:`${b.readinessScore}% drafted`,tone:b.readinessScore>=85?"success":b.readinessScore>=45?"warning":"muted"}),e.push({id:"status",label:`Status \xb7 ${b.status}`,tone:"blocked"===b.status?"danger":"ready"===b.status||"deployed"===b.status?"success":"review"===b.status?"warning":"muted"}))),e})(t.mode,t.plan,r,D),[D,r,t.mode,t.plan]),R=(0,p.useMemo)(()=>{var a,b;let c;return a=t.plan,b=t.pendingUserMessage,c=a?.conversation.map(a=>({id:a.id,role:a.role,author:"assistant"===a.role?"Architect":"system"===a.role?"Workspace Wizard":a.author,text:a.text}))??[],b?.trim()&&c.push({id:"pending-user-message",role:"user",text:b.trim(),status:"pending"}),c},[t.pendingUserMessage,t.plan]),S=(0,p.useMemo)(()=>{for(let a=R.length-1;a>=0;a-=1){let b=R[a];if("assistant"===b.role&&"Architect"===b.author)return b.id}return null},[R]),T=t.isCreating?t.createProgress:t.isDeploying?t.deployProgress:null,U=t.isSending||t.isPlanLoading||t.isDeploying||t.isCreating||t.isDocumentRewriting||t.isApplyingWorkspaceChanges,V="basic"===t.mode&&t.hasStoredDraft&&!t.plan&&!t.isPlanLoading,W=r?!!(t.plan||v.trim()):!!(t.plan?.intake.started||t.basicDraft.goal.trim()||v.trim()),X=!!(t.plan?.intake.started||t.basicDraft.name.trim()||t.basicDraft.goal.trim()||t.basicDraft.source.trim()||v.trim()),Y=async a=>{let b=(a??v).trim();if(!b)return!1;let c=void 0===a;c&&w("");let d=await t.submitArchitectTurn(b);return!d&&c&&w(v),d},$=async()=>{if(r){if(!(!v.trim()||await Y()))return;await t.applyWorkspaceChanges()&&M(!1);return}(!v.trim()||await Y())&&await t.createWorkspace()&&M(!1)},aa=async()=>{r||await t.deployPlan()&&M(!1)},ab=async(a,b)=>{let c=b.trim()?{...a,conversation:[...a.conversation,bg("system","Workspace Wizard",b)]}:a;return t.savePlan(c)},ac=async(a,b)=>{let c=b.trim()?{...a,conversation:[...a.conversation,bg("system","Workspace Wizard",b)]}:a;return t.savePlan(c)},ad=(a="workspace.name")=>{G(a),y(!1),A(!0),C(!1)},ae=a=>{I(a),y(!1),A(!1),C(!0)};return(0,d.jsx)(a8.lG,{open:a,onOpenChange:M,children:(0,d.jsxs)(a8.Cf,{className:J?"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-[#e7dfd4] bg-[#fcfaf6] p-0 text-[#161411] shadow-[0_40px_140px_rgba(16,12,8,0.45)]":"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-white/10 bg-[rgba(4,8,15,0.96)] p-0 text-white shadow-[0_40px_140px_rgba(0,0,0,0.58)]",children:[(0,d.jsx)(a8.L3,{className:"sr-only",children:r?"Edit workspace":"Create workspace"}),(0,d.jsx)(a8.rr,{className:"sr-only",children:r?"Edit the existing workspace blueprint, documents, and agents using Architect.":"Create a workspace in Basic or Advanced mode using the Architect wizard."}),(0,d.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",children:[(0,d.jsx)("div",{className:J?"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.86),transparent_34%),linear-gradient(180deg,rgba(248,244,237,0.92),rgba(252,250,246,0.86)_24%,rgba(244,238,230,0.82)_100%)]":"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(59,130,246,0.14),transparent_28%),radial-gradient(circle_at_80%_18%,rgba(56,189,248,0.12),transparent_24%),linear-gradient(180deg,rgba(9,15,27,0.98),rgba(4,8,15,0.96)_28%,rgba(2,6,13,0.98)_100%)]"}),(0,d.jsx)(a0,{surfaceTheme:l,mode:t.mode,onModeChange:a=>{t.switchMode(a)},onNewDraft:r?void 0:()=>{w(""),y(!1),A(!1),C(!1),E("intake"),t.startFreshDraft()},title:r?"Edit workspace":"Create workspace",showModeToggle:!r,showNewDraft:!r,badges:Q}),(0,d.jsxs)("div",{className:"relative z-[1] grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr),390px] xl:grid-cols-[minmax(0,1fr),420px]",children:[(0,d.jsx)("div",{className:J?"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))]":"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(8,13,24,0.2),rgba(6,10,18,0.42))]",children:"basic"!==t.mode||r?(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.architectBusyStatus?(0,d.jsx)("div",{className:J?"border-b border-[#ece5db] px-4 py-2.5 md:px-5":"border-b border-white/10 px-4 py-2.5 md:px-5",children:(0,d.jsxs)("div",{className:J?"rounded-2xl border border-[#e6dfd5] bg-white px-3 py-2":"rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2",children:[(0,d.jsx)("p",{className:J?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:t.architectBusyStatus.title}),(0,d.jsx)("p",{className:J?"mt-1 text-[12px] leading-5 text-[#6d665e]":"mt-1 text-[12px] leading-5 text-slate-300",children:t.architectBusyStatus.description})]})}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1",children:(0,d.jsx)(a4,{surfaceTheme:l,messages:R,architectMessageId:S,architectPlan:t.plan,isTyping:t.isSending,typingLabel:"Architect is shaping the next pass...",emptyState:t.isPlanLoading&&0===R.length?(0,d.jsx)(b2,{surfaceTheme:l}):0===R.length&&"basic"===t.mode?(0,d.jsx)(b0,{surfaceTheme:l}):0===R.length?(0,d.jsx)(b1,{surfaceTheme:l}):null,auxiliary:(0,d.jsxs)(d.Fragment,{children:[V?(0,d.jsx)(b4,{surfaceTheme:l,isBusy:U,onResume:()=>{t.resumeStoredDraft()},onStartFresh:t.discardStoredDraft}):null,T?(0,d.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,d.jsx)(s,{progress:T,className:J?"border-[#e6dfd5] bg-white":"border-white/10 bg-slate-950/50"})}):null]})})}),(0,d.jsx)("div",{className:J?"border-t border-[#ece5db] bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))] px-4 py-4 md:px-5":"border-t border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.68),rgba(4,8,15,0.94))] px-4 py-4 md:px-5",children:(0,d.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,d.jsx)(a3,{surfaceTheme:l,value:v,onChange:w,onSubmit:async()=>{await Y()},placeholder:r?"Tell Architect what to change in this workspace...":"basic"===t.mode?"Describe what this workspace should do...":"Refine the blueprint with Architect...",disabled:U,isBusy:t.isSending,helperText:r?"Architect updates the existing workspace draft as you chat.":"basic"===t.mode?"Architect keeps the fast-path draft synced as you chat.":"Architect updates the shared blueprint on every turn.",toolbar:r?(0,d.jsx)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Editing draft"}):"basic"!==t.mode||t.plan?t.plan?(0,d.jsxs)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:["Stage \xb7 ",aw(t.plan.stage)]}):null:(0,d.jsx)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Live draft"})})})})]}):(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 md:px-5",children:(0,d.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4",children:[V?(0,d.jsx)(b4,{surfaceTheme:l,isBusy:U,onResume:()=>{t.resumeStoredDraft()},onStartFresh:t.discardStoredDraft}):null,t.isPlanLoading?(0,d.jsx)(b2,{surfaceTheme:l}):(0,d.jsx)(b0,{surfaceTheme:l}),(0,d.jsx)(b7,{surfaceTheme:l,step:D,isBusy:U,basicDraft:t.basicDraft,basicTemplate:t.basicTemplate,basicTeamPreset:t.basicTeamPreset,basicModelProfile:t.basicModelProfile,basicRules:t.basicRules,basicPreset:t.basicPreset,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,onStepChange:E,onBasicNameChange:t.setBasicName,onBasicGoalChange:t.setBasicGoal,onBasicSourceChange:t.setBasicSource,onBasicTemplateChange:t.setBasicTemplate,onBasicTeamPresetChange:t.setBasicTeamPreset,onBasicModelProfileChange:t.setBasicModelProfile,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule})]})})})}),(0,d.jsx)(aQ,{className:"hidden lg:block",surfaceTheme:l,workspaceMode:r?"edit":"create",mode:t.mode,snapshot:m,plan:t.plan,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,notice:t.notice,basicRules:t.basicRules,basicPreset:t.basicPreset,onOpenBlueprintEditor:ad,onOpenDocumentEditor:ae,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule,progress:r?null:"basic"===t.mode?t.createProgress:t.isDeploying?t.deployProgress:null})]}),x?(0,d.jsxs)("div",{className:J?"absolute inset-0 z-20 flex flex-col bg-[rgba(22,18,14,0.18)] backdrop-blur-sm lg:hidden":"absolute inset-0 z-20 flex flex-col bg-[rgba(2,6,13,0.56)] backdrop-blur-sm lg:hidden",children:[(0,d.jsxs)("div",{className:J?"flex items-center justify-between border-b border-[#e7dfd4] bg-[#fcfaf6] px-4 py-3":"flex items-center justify-between border-b border-white/10 bg-[rgba(4,8,15,0.96)] px-4 py-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:J?"text-[11px] uppercase tracking-[0.18em] text-[#9f958a]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"basic"===t.mode?"Workspace draft":"Workspace blueprint"}),(0,d.jsx)("p",{className:J?"text-[13px] text-[#6f675e]":"text-[13px] text-slate-300",children:"Review the structured side of the same wizard."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[t.plan?(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>ad(),className:J?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit details"}):null,(0,d.jsx)("button",{type:"button",onClick:()=>y(!1),className:J?"inline-flex size-9 items-center justify-center rounded-full border border-[#e4ddd3] bg-white text-[#4f4943] transition-colors hover:bg-[#f4efe7]":"inline-flex size-9 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-200 transition-colors hover:bg-white/[0.08]",children:(0,d.jsx)(e.A,{className:"h-4 w-4"})})]})]}),(0,d.jsx)(aQ,{className:"min-h-0 flex-1 border-t-0 lg:hidden",surfaceTheme:l,workspaceMode:r?"edit":"create",mode:t.mode,snapshot:m,plan:t.plan,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,notice:t.notice,basicRules:t.basicRules,basicPreset:t.basicPreset,onOpenBlueprintEditor:ad,onOpenDocumentEditor:ae,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule,progress:r?null:"basic"===t.mode?t.createProgress:t.isDeploying?t.deployProgress:null})]}):null,z&&t.plan?(0,d.jsx)(_,{open:z,surfaceTheme:l,plan:t.plan,busy:t.isSaving,focus:F,onClose:()=>A(!1),onSave:ab},`${t.plan.id}:${F}`):null,B&&t.plan?(0,d.jsx)(ak,{open:B,surfaceTheme:l,plan:t.plan,path:H,busy:t.isSaving,rewriteBusy:t.isDocumentRewriting,onClose:()=>C(!1),onSave:ac,onRewriteWithArchitect:t.rewriteDocumentWithArchitect},`${t.plan.id}:${H}`):null,(0,d.jsx)("div",{className:J?"relative z-[1] border-t border-[#e7dfd4] bg-white/90 px-4 py-3 backdrop-blur-sm md:px-5":"relative z-[1] border-t border-white/10 bg-[rgba(4,8,15,0.88)] px-4 py-3 backdrop-blur-sm md:px-5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,d.jsx)("p",{className:J?"text-[13px] text-[#776f65]":"text-[13px] text-slate-300",children:"basic"===t.mode?"intake"===D?"Step 1 of 3. Capture the mission and source first.":"shape"===D?"Step 2 of 3. Pick the template and default shape.":"Step 3 of 3. Review the draft before creating.":"Chat and blueprint stay synced as you refine the plan."}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3] lg:hidden":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08] lg:hidden",onClick:()=>y(!0),children:[(0,d.jsx)(f.A,{className:"mr-2 h-4 w-4"}),"View blueprint"]}),r?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void t.savePlan(),disabled:!t.plan||t.isSaving||t.isPlanLoading,children:[t.isSaving?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void $(),disabled:!W||t.isPlanLoading||t.isSending||t.isSaving||t.isApplyingWorkspaceChanges,children:[t.isApplyingWorkspaceChanges?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}):"basic"===t.mode?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:"intake"===D?()=>{t.switchMode("advanced")}:()=>{"shape"===D?E("intake"):"review"===D&&E("shape")},disabled:t.isCreating||t.isSending||t.isPlanLoading,children:"intake"===D?"Advanced details":"Back"}),(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>{"intake"===D?E("shape"):"shape"===D?E("review"):$()},disabled:t.isCreating||t.isSending||t.isPlanLoading||"review"===D&&!X,children:["review"===D?t.isCreating?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(h.A,{className:"mr-2 h-4 w-4"}):(0,d.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"intake"===D?"Continue":"shape"===D?"Review draft":"Create workspace"]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void t.savePlan(),disabled:!t.plan||t.isSaving||t.isPlanLoading,children:[t.isSaving?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),t.plan?.intake.reviewRequested?(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void aa(),disabled:!t.plan||t.plan.deploy.blockers.length>0||t.isDeploying||t.isPlanLoading,children:[t.isDeploying?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(j.A,{className:"mr-2 h-4 w-4"}),"Deploy workspace"]}):(0,d.jsx)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>t.requestReview(),disabled:!t.plan||t.isSending||t.isDeploying,children:"Review blueprint"})]})]})]})})]})]})})}function b0({surfaceTheme:a}){let b="light"===a;return(0,d.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.22em]",b?"text-[#8b7262]":"text-slate-500"),children:"Fast path"}),(0,d.jsx)("p",{className:b?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Start with one prompt."}),(0,d.jsx)("p",{className:b?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Tell Architect what this workspace should do. It will reflect the intent back and ask the next critical question."})]})}function b1({surfaceTheme:a}){let b="light"===a;return(0,d.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.22em]",b?"text-[#8b7262]":"text-slate-500"),children:"Blueprint mode"}),(0,d.jsx)("p",{className:b?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Shape the workspace with Architect."}),(0,d.jsx)("p",{className:b?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Describe the operating model, and the structured draft updates as you chat."})]})}function b2({surfaceTheme:a}){return(0,d.jsxs)("div",{className:"light"===a?"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-[#e6dfd5] bg-white px-4 py-3 text-[13px] text-[#6d665e]":"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.04] px-4 py-3 text-[13px] text-slate-300",children:[(0,d.jsx)(g.A,{className:"h-4 w-4 animate-spin"}),"Architect is opening the planning session and extracting intent from the latest brief."]})}function b3({surfaceTheme:a,name:b,goal:c,source:e,resolvedName:f,resolvedTemplate:g,workspacePath:i,sourceAnalysis:j,disabled:o,onNameChange:p,onGoalChange:q,onSourceChange:s}){let t="light"===a,u="clone"===j.kind?k.A:"website"===j.kind?l.A:m.A;return(0,d.jsxs)("div",{className:(0,r.cn)("mx-auto w-full rounded-[24px] border p-4 shadow-[0_18px_56px_rgba(56,47,38,0.06)] md:p-5",t?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",t?"border-[#e4ddd3] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:t?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Step 1 \xb7 Intake"}),(0,d.jsx)("p",{className:t?"mt-1 text-[12px] leading-5 text-[#70685f]":"mt-1 text-[12px] leading-5 text-slate-300",children:"Give Architect the mission and source. The name can stay optional."})]})]}),(0,d.jsxs)("div",{className:"mt-4 grid gap-3",children:[(0,d.jsx)(b5,{surfaceTheme:a,label:"Workspace name",children:(0,d.jsx)(v.p,{value:b,onChange:a=>p(a.target.value),placeholder:"Optional. Architect can infer it.",disabled:o,className:t?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,d.jsx)(b5,{surfaceTheme:a,label:"Goal",children:(0,d.jsx)(z.T,{value:c,onChange:a=>q(a.target.value),placeholder:"What should this workspace help you accomplish?",disabled:o,className:t?"min-h-[100px] border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"min-h-[100px] border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,d.jsx)(b5,{surfaceTheme:a,label:"Source",children:(0,d.jsx)(v.p,{value:e,onChange:a=>s(a.target.value),placeholder:"Repo URL, website URL, or existing folder path",disabled:o,className:t?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})})]}),(0,d.jsxs)("div",{className:(0,r.cn)("mt-4 rounded-[20px] border px-3 py-3",t?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.A,{className:(0,r.cn)("h-4 w-4",t?"text-[#5f5952]":"text-slate-300")}),(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",t?"text-[#a0978b]":"text-slate-500"),children:"Live preview"})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[(0,d.jsx)(cf,{surfaceTheme:a,label:"Name",value:f,icon:h.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Template",value:X[g].label,icon:n.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Source",value:j.label,icon:u}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Path",value:i,icon:m.A,mono:!0})]})]})]})}function b4({surfaceTheme:a,isBusy:b,onResume:c,onStartFresh:e}){let f="light"===a;return(0,d.jsx)("div",{className:f?"mx-auto w-full max-w-3xl rounded-[22px] border border-[#e4ddd3] bg-[#fffaf3] px-4 py-4 shadow-[0_18px_48px_rgba(56,47,38,0.05)]":"mx-auto w-full max-w-3xl rounded-[22px] border border-white/10 bg-white/[0.05] px-4 py-4",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:f?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Previous draft found"}),(0,d.jsx)("p",{className:f?"mt-1 text-[14px] leading-6 text-[#30261d]":"mt-1 text-[14px] leading-6 text-white",children:"Architect still has an earlier workspace blueprint. Resume it or start fresh before creating a new one."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(u.$,{variant:"secondary",size:"sm",className:f?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:e,disabled:b,children:"Start fresh"}),(0,d.jsx)(u.$,{size:"sm",className:f?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:c,disabled:b,children:"Resume blueprint"})]})]})})}function b5({surfaceTheme:a,label:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("p",{className:"light"===a?"text-[11px] uppercase tracking-[0.16em] text-[#8d8276]":"text-[11px] uppercase tracking-[0.16em] text-slate-500",children:b}),c]})}let b6=[{id:"intake",label:"Intake",hint:"Mission, name, source"},{id:"shape",label:"Shape",hint:"Template and defaults"},{id:"review",label:"Review",hint:"Confirm and launch"}];function b7({surfaceTheme:a,step:b,isBusy:c,basicDraft:e,basicTemplate:f,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,resolvedName:k,resolvedTemplate:l,sourceAnalysis:m,workspacePath:n,onStepChange:o,onBasicNameChange:p,onBasicGoalChange:q,onBasicSourceChange:r,onBasicTemplateChange:s,onBasicTeamPresetChange:t,onBasicModelProfileChange:u,onBasicPresetChange:v,onBasicRuleToggle:w}){return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(b8,{surfaceTheme:a,step:b,onStepChange:o}),"intake"===b?(0,d.jsx)(b3,{surfaceTheme:a,name:e.name,goal:e.goal,source:e.source,resolvedName:k,resolvedTemplate:l,workspacePath:n,sourceAnalysis:m,onNameChange:p,onGoalChange:q,onSourceChange:r}):"shape"===b?(0,d.jsx)(b9,{surfaceTheme:a,basicTemplate:f,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,onBasicTemplateChange:s,onBasicTeamPresetChange:t,onBasicModelProfileChange:u,onBasicPresetChange:v,onBasicRuleToggle:w,isBusy:c}):(0,d.jsx)(ca,{surfaceTheme:a,basicDraft:e,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,resolvedName:k,resolvedTemplate:l,sourceAnalysis:m,workspacePath:n,onStepChange:o})]})}function b8({surfaceTheme:a,step:b,onStepChange:c}){let e="light"===a,f=b6.findIndex(a=>a.id===b);return(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:b6.map((a,g)=>{let h=a.id===b,i=g<f;return(0,d.jsxs)("button",{type:"button",onClick:()=>c(a.id),className:(0,r.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-left transition-colors",h?e?"border-[#c89e73]/35 bg-[#f8efe4] text-[#5d4331]":"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":i?e?"border-[#dccfc3] bg-white text-[#7e6757]":"border-emerald-300/20 bg-emerald-400/10 text-emerald-50":e?"border-[#e6dbd0] bg-white/80 text-[#8b7563]":"border-white/10 bg-white/[0.04] text-slate-400"),children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium",h?e?"bg-[#c89e73]/15 text-[#5d4331]":"bg-cyan-300/20 text-cyan-50":i?e?"bg-[#f0e7de] text-[#7a6556]":"bg-emerald-300/20 text-emerald-50":e?"bg-[#f2ece6] text-[#917866]":"bg-white/10 text-slate-400"),children:g+1}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsx)("span",{className:"block text-[10px] font-medium uppercase tracking-[0.16em]",children:a.label}),(0,d.jsx)("span",{className:"block text-[10px] leading-4 opacity-75",children:a.hint})]})]},a.id)})})}function b9({surfaceTheme:a,basicTemplate:b,basicTeamPreset:c,basicModelProfile:e,basicRules:f,basicPreset:g,onBasicTemplateChange:h,onBasicTeamPresetChange:i,onBasicModelProfileChange:k,onBasicPresetChange:l,onBasicRuleToggle:m,isBusy:o}){let p="light"===a,q=X[b];return(0,d.jsxs)("section",{className:(0,r.cn)("rounded-[24px] border p-4 md:p-5",p?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",p?"text-[#8b7262]":"text-slate-500"),children:"Step 2 \xb7 Shape"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#70685f]":"text-slate-300"),children:"Pick the template and defaults that best match the workspace."})]}),(0,d.jsx)(a7.E,{variant:"muted",className:(0,r.cn)("shrink-0",p?"border-[#ddd6cb] bg-[#f7f2eb] text-[#574a40]":""),children:q.label})]}),(0,d.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,d.jsx)(cb,{surfaceTheme:a,title:"Template",summary:"This sets the scaffold, documents, and default capabilities.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-2 xl:grid-cols-3",children:T.map(c=>{let e=X[c.value];return(0,d.jsx)(cc,{surfaceTheme:a,selected:b===c.value,title:c.label,description:c.description,icon:(0,d.jsx)("span",{className:"text-[14px] leading-none","aria-hidden":"true",children:e.icon}),onClick:()=>h(c.value),disabled:o},c.value)})})}),(0,d.jsx)(cb,{surfaceTheme:a,title:"Team preset",summary:"Choose how many permanent agents the workspace should start with.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:U.map(b=>(0,d.jsx)(cc,{surfaceTheme:a,selected:c===b.value,title:b.label,description:b.description,icon:(0,d.jsx)(j.A,{className:"h-4 w-4"}),onClick:()=>i(b.value),disabled:o},b.value))})}),(0,d.jsx)(cb,{surfaceTheme:a,title:"Model profile",summary:"Favor speed, balance, or quality for the default workspace runs.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(b=>(0,d.jsx)(cc,{surfaceTheme:a,selected:e===b.value,title:b.label,description:b.description,icon:(0,d.jsx)(n.A,{className:"h-4 w-4"}),onClick:()=>k(b.value),disabled:o},b.value))})}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[20px] border p-3",p?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#8d8276]":"text-slate-500"),children:"Bootstrap speed"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#766e64]":"text-slate-400"),children:"Use a preset or tune the bootstrap rules manually."})]}),(0,d.jsx)(a7.E,{variant:"muted",children:g})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-3",children:[(0,d.jsx)(ce,{surfaceTheme:a,active:"standard"===g,title:"Standard",description:"Docs, memory, kickoff",disabled:o,onClick:()=>l("standard")}),(0,d.jsx)(ce,{surfaceTheme:a,active:"fastest"===g,title:"Fastest",description:"Core files only",disabled:o,onClick:()=>l("fastest")}),(0,d.jsx)(ce,{surfaceTheme:a,active:"custom"===g,title:"Custom",description:"Manually choose rules",disabled:o,onClick:()=>l("custom")})]})]}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[20px] border p-3",p?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#8d8276]":"text-slate-500"),children:"Workspace rules"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#766e64]":"text-slate-400"),children:"Toggle the bootstrap steps that should ship with the workspace."})]}),(0,d.jsxs)(a7.E,{variant:"muted",children:[[f.generateStarterDocs,f.generateMemory,f.kickoffMission].filter(Boolean).length,"/3"]})]}),(0,d.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,d.jsx)(cd,{surfaceTheme:a,title:"Starter docs",description:"Generate the brief, scaffolding notes, and handoff docs.",checked:f.generateStarterDocs,disabled:o,onToggle:()=>m("generateStarterDocs")}),(0,d.jsx)(cd,{surfaceTheme:a,title:"Memory",description:"Write durable context and decisions into memory files.",checked:f.generateMemory,disabled:o,onToggle:()=>m("generateMemory")}),(0,d.jsx)(cd,{surfaceTheme:a,title:"Kickoff mission",description:"Launch the first mission right after bootstrap.",checked:f.kickoffMission,disabled:o,onToggle:()=>m("kickoffMission")})]})]})]})]})}function ca({surfaceTheme:a,basicDraft:b,basicTeamPreset:c,basicModelProfile:e,basicRules:f,basicPreset:g,resolvedName:i,resolvedTemplate:o,sourceAnalysis:p,workspacePath:q,onStepChange:s}){let t="light"===a,v="clone"===p.kind?k.A:"website"===p.kind?l.A:m.A,w=[f.generateStarterDocs,f.generateMemory,f.kickoffMission].filter(Boolean).length;return(0,d.jsxs)("section",{className:(0,r.cn)("rounded-[24px] border p-4 md:p-5",t?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",t?"text-[#8b7262]":"text-slate-500"),children:"Step 3 \xb7 Review"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",t?"text-[#70685f]":"text-slate-300"),children:"Check the final draft before creating the workspace."})]}),(0,d.jsx)(a7.E,{variant:"success",children:"Ready"})]}),(0,d.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2",children:[(0,d.jsx)(cf,{surfaceTheme:a,label:"Name",value:i,icon:h.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Template",value:X[o].label,icon:n.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Source",value:p.label,icon:v}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Path",value:q,icon:m.A,mono:!0}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Team",value:U.find(a=>a.value===c)?.label??c,icon:j.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Model",value:V.find(a=>a.value===e)?.label??e,icon:n.A})]}),(0,d.jsxs)("div",{className:(0,r.cn)("mt-4 rounded-[20px] border p-3",t?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",t?"text-[#8d8276]":"text-slate-500"),children:"Launch summary"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",t?"text-[#766e64]":"text-slate-400"),children:"fastest"===g?"Fast path will keep the scaffold lean.":"custom"===g?"Custom bootstrap rules are active.":"Starter docs, memory, and kickoff are enabled."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(a7.E,{variant:"muted",children:[w,"/3 rules"]}),(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>s("intake"),className:t?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit intake"}),(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>s("shape"),className:t?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit shape"})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:[(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-2.5",t?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",t?"text-[#8d8276]":"text-slate-500"),children:"Goal"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",t?"text-[#34281f]":"text-slate-200"),children:b.goal.trim()||"No goal provided yet."})]}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-2.5",t?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",t?"text-[#8d8276]":"text-slate-500"),children:"Source kind"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",t?"text-[#34281f]":"text-slate-200"),children:"empty"===p.kind?"Fresh workspace":p.label})]})]})]})]})}function cb({surfaceTheme:a,title:b,summary:c,children:e}){let f="light"===a;return(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#8d8276]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",f?"text-[#766e64]":"text-slate-400"),children:c})]}),e]})}function cc({surfaceTheme:a,selected:b,title:c,description:e,icon:f,onClick:g,disabled:h=!1}){let i="light"===a;return(0,d.jsxs)("button",{type:"button",onClick:g,disabled:h,className:(0,r.cn)("group flex h-full min-h-[90px] flex-col justify-between rounded-[18px] border p-3 text-left transition-colors",b?i?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/10 text-white":i?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d7c8ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",h&&"cursor-not-allowed opacity-70"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",b?"border-white/15 bg-white/10 text-white":i?"border-[#ddd3c5] bg-white text-[#5f564b]":"border-white/10 bg-white/[0.04] text-slate-200"),children:f}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[13px] font-medium",children:c}),(0,d.jsx)("p",{className:(0,r.cn)("mt-0.5 text-[11px] leading-4",b?"text-current/80":i?"text-[#766e64]":"text-slate-400"),children:e})]})]}),b?(0,d.jsx)(a7.E,{variant:i?"muted":"default",className:i?"bg-white text-[#3d342b]":"",children:"Selected"}):null]}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",b?"text-current/70":i?"text-[#8d8276]":"text-slate-500"),children:b?"Active choice":"Select"}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-5 items-center justify-center rounded-full border",b?"border-white/15 bg-white/10 text-white":i?"border-[#d9cec2] bg-white text-transparent":"border-white/10 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})})]})]})}function cd({surfaceTheme:a,title:b,description:c,checked:e,onToggle:f,disabled:g=!1}){let h="light"===a;return(0,d.jsxs)("button",{type:"button",onClick:f,disabled:g,className:(0,r.cn)("flex w-full items-start gap-3 rounded-[18px] border px-3 py-3 text-left transition-colors",h?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]",g?"cursor-not-allowed opacity-70":h?"hover:border-[#d7c8ba] hover:bg-[#f7f0e6]":"hover:border-white/15 hover:bg-white/[0.05]"),children:[(0,d.jsx)("span",{className:(0,r.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",e?h?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":h?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] font-medium",h?"text-[#171410]":"text-white"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",h?"text-[#766e64]":"text-slate-400"),children:c})]})]})}function ce({surfaceTheme:a,active:b,title:c,description:e,disabled:f=!1,onClick:g}){let h="light"===a;return(0,d.jsx)("button",{type:"button",onClick:g,disabled:f,className:(0,r.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",b?h?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":h?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",f&&"cursor-not-allowed opacity-70"),children:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)(n.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,d.jsx)("p",{className:"truncate text-[12px] font-medium",children:c})]}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-right text-[11px] leading-4",b?"opacity-80":h?"text-[#776f65]":"text-slate-400"),children:e})]})})}function cf({surfaceTheme:a,label:b,value:c,icon:e,mono:f=!1}){let g="light"===a;return(0,d.jsx)("div",{className:(0,r.cn)("rounded-[16px] border px-3 py-2.5",g?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",g?"border-[#e0d7cc] bg-[#faf6f1] text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(e,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",g?"text-[#8d8276]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-[12px] font-medium leading-4",f&&"font-mono text-[12px]",g?"text-[#171410]":"text-white"),title:c,children:c})]})]})})}},29849:(a,b,c)=>{"use strict";c.d(b,{d:()=>I});var d=c(3814),e=c(6247),f=c(49113),g=c(11917),h=c(74234),i=c(84086),j=c(80990),k=c(74952),l=c(43081);function m(a){return`mission-control-agent-chat:v1:${a}`}function n(a){return"object"==typeof a&&null!==a&&("user"===a.role||"assistant"===a.role||"system"===a.role)&&"string"==typeof a.id&&"string"==typeof a.text&&"number"==typeof a.createdAt&&(void 0===a.errorMessage||null===a.errorMessage||"string"==typeof a.errorMessage)&&(void 0===a.status||"sending"===a.status||"sent"===a.status||"error"===a.status)}function o(a){try{let b=globalThis.localStorage?.getItem(m(a));if(!b)return[];let c=JSON.parse(b);if(!Array.isArray(c))return[];return c.filter(n).slice(-60)}catch{return[]}}function p(a,b){try{globalThis.localStorage?.setItem(m(a),JSON.stringify(b.slice(-60)))}catch{}}var q=c(30094);function r(a){let b=a.toLowerCase();return(b.includes("couldn't recover")||b.includes("couldn’t recover"))&&b.includes("prior")&&b.includes("context")||b.includes("no prior transcript")&&b.includes("memory")||b.includes("send me")&&b.includes("last goal")&&b.includes("file")||b.includes("can't continue")&&b.includes("recoverable task context")||b.includes("can’t continue")&&b.includes("recoverable task context")||b.includes("checked")&&b.includes("workspace files")&&b.includes("recent session metadata")||b.includes("task state")&&b.includes("resume")||b.includes("failed attempt")&&b.includes("last task")&&b.includes("error")||b.includes("workspace")&&b.includes("memory")&&b.includes("session metadata")&&(b.includes("resume")||b.includes("continue"))}function s(a){let b=a.toLowerCase();return/\b(name|ad[ıi]n|ismin|called)\b/.test(b)&&/\b(age|old|ya[sş][ıi]n|kaç yaş)\b/.test(b)||/\b(who are you|kimsin)\b/.test(b)}let t="mission-control-action";function u(a){return function(a){if(!a)return"";let b=a.toLowerCase(),c=`<${t}>`,d=`</${t}>`,e=b.lastIndexOf(c),f=b.lastIndexOf(d);return e>=0&&e>f?a.slice(0,e).trim():a}(function(a){if("string"!=typeof a||!a.trim())return{action:null,cleanText:""};let b=RegExp(`<${t}>\\s*([\\s\\S]*?)\\s*<\\/${t}>`,"gi"),c=null,d=a.replace(b,(a,b)=>(c||(c=function(a){try{let b=JSON.parse(a);if("rename_agent"!==b.type)return null;let c=function(a){if("string"!=typeof a)return null;let b=a.trim().replace(/^["'`“”‘’]+|["'`“”‘’]+$/g,"").trim();return b.length>0?b:null}(b.name);if(!c)return null;return{type:"rename_agent",name:c}}catch{return null}}(b)),"")).replace(/\n{3,}/g,"\n\n").trim();return{action:c,cleanText:d}}("string"!=typeof a?"":function(a){if(!v(a))return a;let b=Math.max(a.lastIndexOf("\nOperator:"),a.startsWith("Operator:")?0:-1),c=(b>=0?a.slice(b):a).match(/\n(?:Agent|Assistant):\s*([\s\S]+)$/i),d=c?.[1]?.trim()??"";return d&&!v(d)?d:""}(function(a){if(!a||!/^\[thinking\]\b/i.test(a))return a;let b=a.split(/\n{2,}/).map(a=>a.trim()).filter(Boolean);return b.length<=2?"":b.slice(2).join("\n\n").trim()}(a.trim()))).cleanText)}function v(a){return/^You are chatting directly with the operator inside AgentOS\./i.test(a)||/You are chatting directly with the operator inside AgentOS\./i.test(a)&&/Do not create tasks or mention task cards\./i.test(a)||/Use the workspace root `AGENTS\.md` file as the source of truth/i.test(a)&&/Direct chat mode takes priority over workspace operating docs/i.test(a)}let w=new Map;function x({agentId:a,agentName:b,text:c,onRefresh:d,onSnapshotChange:e,onError:f}){let g=c.trim();if(!g)return Promise.resolve();let h=w.get(a);if(h)return h.promise;let i=Date.now(),j=globalThis.crypto?.randomUUID?.()||`user:${i}`,k=globalThis.crypto?.randomUUID?.()||`assistant:${i}`,l=o(a),m={userMessageId:j,assistantMessageId:k,statusMessage:"Starting agent turn...",promise:Promise.resolve()};w.set(a,m),p(a,[...l,{id:j,role:"user",text:g,createdAt:i,status:"sending"},{id:k,role:"assistant",text:"",createdAt:i+1,status:"sending"}].slice(-60));let n=l.filter(a=>("user"===a.role||"assistant"===a.role)&&"error"!==a.status&&a.text.trim().length>0).slice(-16).map(a=>({role:a.role,text:a.text})),q=new Set(n.filter(a=>"assistant"===a.role).map(a=>A(a.text)).filter(Boolean));return m.promise=y({agentId:a,payload:{message:g,rawMessage:g,history:n,thinking:"low"},agentName:b,userMessageId:j,assistantMessageId:k,previousAssistantTexts:q,run:m,onRefresh:d,onSnapshotChange:e,onError:f}),m.promise}async function y({agentId:a,payload:b,agentName:c,userMessageId:d,assistantMessageId:e,previousAssistantTexts:f,run:g,onRefresh:h,onSnapshotChange:i,onError:j}){let k="",l=!1;try{let j=await fetch(`/api/agents/${encodeURIComponent(a)}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),m=j.headers.get("content-type")||"";if(!j.ok||!m.includes("application/x-ndjson")){let a=await j.json().catch(()=>null);throw Error(a?.error||"OpenClaw rejected the message.")}z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a));let n=null;if(await (0,q.z)(j,async j=>{var m;if("status"===j.type){g.statusMessage=j.message;return}if("assistant"===j.type){let c=u(j.text),h=A(c),i=s(b.rawMessage)&&r(c);if(!c){g.statusMessage="Agent is thinking...";return}if(i||!l&&h&&f.has(h)){g.statusMessage="Agent is drafting a reply...";return}l=!0,k=c,g.statusMessage="Agent is drafting a reply...",z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a.id===e?{...a,text:c,status:"sending"}:a));return}if(!j.ok)throw Error(j.message);n=j.response??null;let o=function(a,b,c){return s(c)&&r(a)?`My name is ${b}. I do not have a real age; I am an AI agent running inside AgentOS.`:a}(n?(m=n).payloads.map(a=>u(a.text)).filter(Boolean).join("\n\n")||u(m.summary):k,c,b.rawMessage);n&&(k=o),z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a.id===e?{...a,text:o,status:"sent",runId:n?.runId??a.runId}:a));let p=n?function(a){let b=a?.missionControlAction;if(!b||"object"!=typeof b||"rename_agent"!==b.type||!0!==b.applied||"string"!=typeof b.name)return null;let c=b.name.trim();return c.length>0?c:null}(n.meta):null;p&&i&&i(b=>{var c,d,e;return c=b,d=a,e=p,{...c,agents:c.agents.map(a=>a.id===d?{...a,name:e,identityName:e}:a),tasks:c.tasks.map(a=>a.primaryAgentId===d?{...a,primaryAgentName:e}:a)}}),h?.().catch(()=>null)}),!n)throw Error("OpenClaw completed without returning a response.")}catch(f){let b=f instanceof Error?f.message:"Unknown send error.",c=l?k.trim():"";z(a,a=>a.map(a=>a.id===d?{...a,status:"error",errorMessage:b}:a.id===e&&c.length>0?{...a,text:c,status:"error",errorMessage:b}:a).filter(a=>a.id!==e||c.length>0)),j?.(b)}finally{w.delete(a)}}function z(a,b){p(a,b(o(a)).slice(-60))}function A(a){return a.replace(/\s+/g," ").trim()}var B=c(60557),C=c(12557),D=c(90665),E=c(32905);function F({surfaceTheme:a}){return(0,d.jsx)("span",{className:"inline-flex items-center gap-[3px] align-middle",children:[0,1,2].map(b=>(0,d.jsx)(i.P.span,{animate:{opacity:[.35,1,.35],y:[0,-1,0]},transition:{duration:1.1,repeat:1/0,delay:.14*b,ease:"easeInOut"},className:(0,E.cn)("h-1.5 w-1.5 rounded-full","light"===a?"bg-[#8f7263]":"bg-cyan-300")},b))})}function G({agentLabel:a,statusLabel:b,surfaceTheme:c}){return(0,d.jsxs)("div",{className:(0,E.cn)("flex min-w-0 items-center justify-between gap-3 text-[9px] uppercase tracking-[0.24em]","light"===c?"text-[#8b7262]":"text-slate-400"),children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:a}),b?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)("span",{children:b}),(0,d.jsx)(F,{surfaceTheme:c})]}):null]})}function H({statusMessage:a,expanded:b,onToggle:c,surfaceTheme:e}){var f;let g,h=function(a){let b,c=(b=a?.toLowerCase()??"").includes("finalizing")||b.includes("drafting")?"Shaping the reply before it appears here.":b.includes("thinking")?"Checking recent context before answering.":"Reading your message and preparing a reply.";return c.includes("Shaping")?["Shaping the reply","Preparing the final wording"]:c.includes("Checking")?["Reading your message","Checking recent context"]:["Reading your message","Preparing a reply"]}(a),j=(f=a,(g=f?.toLowerCase()??"").includes("finalizing")||g.includes("drafting")?["The agent has enough context to answer.","It is tightening the response before showing it here.","Raw reasoning stays hidden; only the final reply is saved."]:g.includes("thinking")?["The agent is reading the direct message.","It is checking recent chat and workspace context.","It will replace this activity card with the final reply."]:["The message was sent to the selected agent.","AgentOS is waiting for the first response signal.","This activity is temporary and is not saved to chat history."]);return(0,d.jsxs)("div",{className:(0,E.cn)("mt-2 overflow-hidden rounded-[14px] border px-3 py-2","light"===e?"border-[#e7d8cc] bg-[#fff7f1]/70":"border-cyan-300/10 bg-slate-950/24"),children:[(0,d.jsx)("div",{className:"space-y-1.5",children:h.map((a,b)=>(0,d.jsx)(i.P.div,{animate:{opacity:[.48,.92,.48]},transition:{duration:1.8,repeat:1/0,delay:.18*b,ease:"easeInOut"},className:(0,E.cn)("h-3.5 rounded-full","light"===e?"bg-[linear-gradient(90deg,rgba(139,114,98,0.16),rgba(139,114,98,0.34),rgba(139,114,98,0.14))]":"bg-[linear-gradient(90deg,rgba(125,211,252,0.10),rgba(125,211,252,0.27),rgba(125,211,252,0.08))]",0===b?"w-[72%]":"w-[54%]"),children:(0,d.jsx)("span",{className:(0,E.cn)("block truncate px-2 text-[10px] leading-3.5","light"===e?"text-[#7d6556]/78":"text-slate-300/72"),children:a})},a))}),(0,d.jsx)("div",{className:"mt-2 flex justify-end",children:(0,d.jsx)("button",{type:"button",onClick:c,className:(0,E.cn)("text-[8px] uppercase tracking-[0.18em] transition hover:opacity-80","light"===e?"text-[#8b7262]":"text-cyan-200/70"),children:b?"Hide details":"Show details"})}),b?(0,d.jsx)(i.P.ul,{initial:{opacity:0,y:-3},animate:{opacity:1,y:0},className:(0,E.cn)("mt-2 space-y-1 border-t pt-2 text-[11px] leading-4","light"===e?"border-[#e7d8cc] text-[#7d6556]":"border-white/[0.07] text-slate-400"),children:j.map(a=>(0,d.jsxs)("li",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:(0,E.cn)("mt-[7px] h-1 w-1 shrink-0 rounded-full","light"===e?"bg-[#b28f78]":"bg-cyan-300/70")}),(0,d.jsx)("span",{children:a})]},a))}):null]})}function I({agent:a,surfaceTheme:b,isVisible:c,onRefresh:m,onSnapshotChange:n,onConnectModelProvider:o}){let[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)(()=>{var b;let c;return b=a.id,{isRunning:!!(c=w.get(b)),userMessageId:c?.userMessageId??null,assistantMessageId:c?.assistantMessageId??null,statusMessage:c?.statusMessage??null}}),[v,y]=(0,e.useState)(null),[z,A]=(0,e.useState)({}),[F,J]=(0,e.useState)({}),[K,L]=(0,e.useState)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(c);(0,e.useRef)(null);let P=(0,D.CK)(a),Q=!!p.trim()&&!t.isRunning,R=t.assistantMessageId,S=r.length>0?r:[{id:"system:empty",role:"system",text:"Start a direct chat with this agent. Messages stay in this drawer and are stored locally in your browser.",createdAt:Date.now()}],T=async()=>{let b=p.trim();if(b&&!t.isRunning){q("");try{await x({agentId:a.id,agentName:P,text:b,onRefresh:m,onSnapshotChange:n,onError:a=>{l.o.error("Chat message failed.",{description:a})}})}finally{O.current&&requestAnimationFrame(()=>N.current?.focus())}}},U=async(b,c,d)=>{let e=c.trim();if(e&&!K&&!t.isRunning){L(b);try{let b=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:d.apiAction})}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||"Gateway access could not be repaired.");if(c?.authStatus?.native&&!1===c.authStatus.native.ok)throw Error(c.authStatus.native.issue||"Gateway access still needs attention.");l.o.success(`${d.label} repaired.`,{description:"Retrying the chat message."}),await m?.().catch(()=>void 0),L(null),await x({agentId:a.id,agentName:P,text:e,onRefresh:m,onSnapshotChange:n,onError:a=>{l.o.error("Chat message failed.",{description:a})}})}catch(a){l.o.error("Gateway repair failed.",{description:a instanceof Error?a.message:"Unable to repair Gateway access."})}finally{L(null),O.current&&requestAnimationFrame(()=>N.current?.focus())}}};return(0,d.jsxs)("div",{className:(0,E.cn)("flex h-full min-h-0 flex-col overflow-hidden","light"===b?"text-[#4a382c]":"text-slate-200"),children:[(0,d.jsx)("div",{ref:M,className:(0,E.cn)("mission-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1","light"===b?"text-[#4a382c]":"text-slate-200"),children:(0,d.jsx)("div",{className:"space-y-2.5",children:S.map(c=>{let e="user"===c.role,h="system"===c.role,k="assistant"===c.role,l=k&&c.id===R&&t.isRunning,m=l&&!c.text.trim(),n=k?z[c.id]:void 0,p=n??c.text,q=k&&!!n&&p!==c.text,r=l||q,s=m?"Thinking":r?"Replying":null,u="user"===c.role&&c.id===t.userMessageId&&t.isRunning,v="sending"===c.status&&u,w=c.errorMessage?.trim(),x=w?(0,C.Ek)(w):null,y=w&&!x?function(a,b){var c,d,e;let f,g=a?.trim()??"";if(!g||(c=g,!/\b(auth|authentication|authenticate|unauthorized|unauthorised|forbidden|expired|token|oauth|api[-\s]?key|credential|login|sign[ -]?in|reconnect|401|403)\b/i.test(c)))return null;let h=function(a){let b=a.match(/\bmodels\s+auth\s+(login|paste-token)\b[\s\S]*?--provider(?:=|\s+)(["']?)([a-z0-9_-]+)\2/i);if(b?.[1]==="login"&&"openai"===b[3])return"openai-codex";if(b?.[3])return(0,B.d4)(b[3]);let c=a.match(/\b--provider(?:=|\s+)(["']?)([a-z0-9_-]+)\1/i);return(0,B.d4)(c?.[2]??null)}(g)??function(a){if(/\bChatGPT\/Codex\b|\bChatGPT\b|\bCodex\b/i.test(a))return"openai-codex";let b=a.toLowerCase();for(let a of B.y8){let c=a.id.toLowerCase(),d=a.label.toLowerCase(),e=a.shortLabel.toLowerCase();if(b.includes(c)||b.includes(d)||b.includes(e))return a.id}return null}(g)??(d=b,e=g,(f=d?.split("/",1)[0]?.trim()??"")?"openai"===f&&/\bChatGPT\b|\bCodex\b/i.test(e)?"openai-codex":(0,B.d4)(f):null);if(!h)return null;let i=(0,B.S)(h);return{provider:h,label:i,detail:`Connect ${i}, then retry this chat message.`}}(w,a.modelId):null;return(0,d.jsx)("div",{className:(0,E.cn)("flex",e?"justify-end":"justify-start"),children:(0,d.jsxs)("div",{className:(0,E.cn)("min-w-0 max-w-[92%] rounded-[18px] border px-3 py-2 text-[13px] leading-5 shadow-[0_14px_34px_rgba(0,0,0,0.14)]",u&&"opacity-85",h?"light"===b?"border-[#e3d4c8] bg-[#fffaf6] text-[#6c5647]":"border-white/[0.08] bg-white/[0.03] text-slate-400":e?"light"===b?"border-[#e3d4c8] bg-[#fff3f6] text-[#4a382c]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(255,255,255,0.07),rgba(255,255,255,0.03))] text-slate-100":"light"===b?"border-[#e3d4c8] bg-[#fffaf6] text-[#4a382c]":"border-cyan-300/12 bg-[linear-gradient(180deg,rgba(34,211,238,0.10),rgba(59,130,246,0.06))] text-slate-100"),children:[m?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(G,{agentLabel:P,statusLabel:s,surfaceTheme:b}),(0,d.jsx)(H,{statusMessage:t.statusMessage,expanded:!!F[c.id],onToggle:()=>J(a=>({...a,[c.id]:!a[c.id]})),surfaceTheme:b})]}):(0,d.jsxs)(d.Fragment,{children:[k?(0,d.jsx)(G,{agentLabel:P,statusLabel:s,surfaceTheme:b}):null,(0,d.jsx)("p",{className:(0,E.cn)("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",k&&"mt-1.5"),children:k?p:c.text}),r?(0,d.jsx)(i.P.span,{"aria-hidden":"true",animate:{opacity:[.2,1,.2]},transition:{duration:.9,repeat:1/0,ease:"easeInOut"},className:"ml-0.5 inline-block h-[1em] w-[1px] translate-y-[2px] bg-current"}):null]}),!m&&v?(0,d.jsx)("p",{className:(0,E.cn)("mt-1.5 text-[10px] uppercase tracking-[0.18em]","light"===b?"text-[#8b7262]":"text-slate-500"),children:e?"Sending…":"Drafting…"}):m||"error"!==c.status?null:(0,d.jsxs)("div",{className:"mt-1.5 space-y-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-rose-300",children:"Failed to send"}),w?(0,d.jsx)("p",{className:(0,E.cn)("text-[11px] leading-4 [overflow-wrap:anywhere]","light"===b?"text-rose-700":"text-rose-200"),children:w}):null,y&&o?(0,d.jsxs)(j.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>o(y.provider),className:(0,E.cn)("mt-1 h-8 rounded-full px-3 text-[11px]","light"===b?"border-rose-200 bg-white text-rose-800 hover:bg-rose-50":"border-rose-300/20 bg-rose-300/10 text-rose-100 hover:bg-rose-300/16"),children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect ",y.label]}):null,x?(0,d.jsxs)(j.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>void U(c.id,c.text,x),disabled:!!K||t.isRunning,title:x.detail,className:(0,E.cn)("mt-1 h-8 rounded-full px-3 text-[11px]","light"===b?"border-emerald-200 bg-white text-emerald-800 hover:bg-emerald-50":"border-emerald-300/20 bg-emerald-300/10 text-emerald-100 hover:bg-emerald-300/16"),children:[K===c.id?(0,d.jsx)(g.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5"}),x.cta]}):null]})]})},c.id)})})}),(0,d.jsxs)("div",{className:(0,E.cn)("mt-2 shrink-0 rounded-[18px] border p-3","light"===b?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))]"),onPointerDown:a=>{let b=a.target;!b||b.closest("textarea")||b.closest("button")||N.current?.focus()},children:[(0,d.jsx)(k.T,{ref:N,value:p,onChange:a=>q(a.target.value),onKeyDown:async a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),await T())},placeholder:`Message to ${P}...`,className:(0,E.cn)("min-h-[60px] cursor-text resize-none border-0 bg-transparent px-3.5 py-2.5 text-[13px] leading-[1.5] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0","light"===b?"text-[#3f2f24] placeholder:text-[#8f7664]":"text-white placeholder:text-slate-500")}),(0,d.jsx)("div",{className:"mt-1.5 flex items-center justify-end gap-1.5",children:(0,d.jsxs)(j.$,{disabled:!Q,className:(0,E.cn)("h-8 rounded-full px-3 shadow-none","light"===b?"bg-[#4a382c] text-[#fffaf6] hover:bg-[#3f2f24]":"bg-white text-slate-950 hover:bg-white/92"),onClick:T,children:[t.isRunning?(0,d.jsx)(g.A,{className:"mr-[5px] h-[13px] w-[13px] animate-spin"}):(0,d.jsx)(h.A,{className:"mr-[5px] h-[13px] w-[13px]"}),"Send"]})})]})]})}},30094:(a,b,c)=>{"use strict";async function d(a,b){if(!a.body)throw Error("The server did not return a readable stream.");let c=a.body.getReader(),d=new TextDecoder,e="";for(;;){let{value:a,done:f}=await c.read();if(f)break;let g=(e+=d.decode(a,{stream:!0})).indexOf("\n");for(;g>=0;){let a=e.slice(0,g).trim();e=e.slice(g+1),a&&await b(JSON.parse(a)),g=e.indexOf("\n")}}let f=e.trim();f&&await b(JSON.parse(f))}c.d(b,{z:()=>d})},30540:(a,b,c)=>{"use strict";c.d(b,{T:()=>e,j:()=>d});let d=[{name:"exec",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"process",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"bash",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"code_execution",description:"Run sandboxed remote Python analysis.",source:"OpenClaw built-in",category:"builtin"},{name:"browser",description:"Control a Chromium browser (navigate, click, screenshot).",source:"OpenClaw built-in",category:"builtin"},{name:"web_search",description:"Search the web and fetch search results.",source:"OpenClaw built-in",category:"builtin"},{name:"x_search",description:"Search X posts.",source:"OpenClaw built-in",category:"builtin"},{name:"web_fetch",description:"Fetch page content.",source:"OpenClaw built-in",category:"builtin"},{name:"read",description:"Read files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"write",description:"Write files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"edit",description:"Edit files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"apply_patch",description:"Apply structured multi-hunk patches.",source:"OpenClaw built-in",category:"builtin"},{name:"message",description:"Send messages across channels.",source:"OpenClaw built-in",category:"builtin"},{name:"canvas",description:"Drive node canvas workflows.",source:"OpenClaw built-in",category:"builtin"},{name:"nodes",description:"Discover and target paired devices.",source:"OpenClaw built-in",category:"builtin"},{name:"cron",description:"Manage scheduled jobs.",source:"OpenClaw built-in",category:"builtin"},{name:"gateway",description:"Inspect and restart gateway services.",source:"OpenClaw built-in",category:"builtin"},{name:"image",description:"Analyze images.",source:"OpenClaw built-in",category:"builtin"},{name:"image_generate",description:"Generate or edit images.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_history",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_send",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_spawn",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_yield",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"subagents",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"session_status",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"agents_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"}],e=[{name:"group:runtime",description:"exec, bash, process, code_execution",source:"OpenClaw docs",category:"group"},{name:"group:fs",description:"read, write, edit, apply_patch",source:"OpenClaw docs",category:"group"},{name:"group:sessions",description:"sessions_list, sessions_history, sessions_send, sessions_spawn, sessions_yield, subagents, session_status",source:"OpenClaw docs",category:"group"},{name:"group:memory",description:"memory_search, memory_get",source:"OpenClaw docs",category:"group"},{name:"group:web",description:"web_search, x_search, web_fetch",source:"OpenClaw docs",category:"group"},{name:"group:ui",description:"browser, canvas",source:"OpenClaw docs",category:"group"},{name:"group:automation",description:"cron, gateway",source:"OpenClaw docs",category:"group"},{name:"group:messaging",description:"message",source:"OpenClaw docs",category:"group"},{name:"group:nodes",description:"nodes",source:"OpenClaw docs",category:"group"},{name:"group:openclaw",description:"All built-in OpenClaw tools (excludes plugin tools).",source:"OpenClaw docs",category:"group"}]},31210:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(30248);function e(){return(0,d.jsx)("main",{className:"flex min-h-screen items-center justify-center bg-[#050816] px-6 text-white",children:(0,d.jsxs)("div",{className:"rounded-[24px] border border-white/10 bg-white/[0.03] px-8 py-10 text-center shadow-[0_24px_80px_rgba(0,0,0,0.35)] backdrop-blur-xl",children:[(0,d.jsx)("p",{className:"text-[11px] uppercase tracking-[0.32em] text-slate-500",children:"OpenClaw"}),(0,d.jsx)("h1",{className:"mt-3 font-display text-3xl",children:"Page not found"}),(0,d.jsx)("p",{className:"mt-3 max-w-md text-sm leading-6 text-slate-400",children:"The requested AgentOS route does not exist in this workspace."})]})})}},32905:(a,b,c)=>{"use strict";c.d(b,{cn:()=>f});var d=c(81938),e=c(53077);function f(...a){return(0,e.QP)((0,d.$)(a))}},34118:(a,b,c)=>{"use strict";c.d(b,{J:()=>j});var d=c(3814),e=c(6247),f=c(10011),g=c(9082),h=c(32905);let i=(0,g.F)("text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground"),j=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.b,{ref:c,className:(0,h.cn)(i(),a),...b}));j.displayName=f.b.displayName},37674:(a,b,c)=>{"use strict";c.d(b,{Cf:()=>n,Es:()=>p,HM:()=>l,L3:()=>q,c7:()=>o,lG:()=>i,rr:()=>r,zM:()=>j});var d=c(3814),e=c(6247),f=c(58346),g=c(57531),h=c(32905);let i=f.bL,j=f.l9,k=f.ZL,l=f.bm,m=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hJ,{ref:c,className:(0,h.cn)("fixed inset-0 z-50 bg-slate-950/70 backdrop-blur-md",a),...b}));m.displayName=f.hJ.displayName;let n=e.forwardRef(({className:a,children:b,overlayClassName:c,closeClassName:e,...i},j)=>(0,d.jsxs)(k,{children:[(0,d.jsx)(m,{className:c}),(0,d.jsxs)(f.UC,{ref:j,className:(0,h.cn)("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-popover p-6 text-popover-foreground shadow-panel backdrop-blur-xl duration-200",a),...i,children:[b,(0,d.jsxs)(f.bm,{className:(0,h.cn)("absolute right-4 top-4 rounded-full p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",e),children:[(0,d.jsx)(g.A,{className:"h-4 w-4"}),(0,d.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));n.displayName=f.UC.displayName;let o=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col space-y-2 text-left",a),...b}),p=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...b}),q=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hE,{ref:c,className:(0,h.cn)("font-display text-xl font-semibold text-popover-foreground",a),...b}));q.displayName=f.hE.displayName;let r=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.VY,{ref:c,className:(0,h.cn)("text-sm text-muted-foreground",a),...b}));r.displayName=f.VY.displayName},40299:(a,b,c)=>{"use strict";c.d(b,{F3:()=>i,rY:()=>f,yQ:()=>h});let d=[{provider:"telegram",label:"Telegram",kind:"chat",description:"Bot accounts, public groups, and delegated community routing.",iconKey:"siTelegram",accentColor:"#26A5E4",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Bot token",placeholder:"123456:ABC...",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!0,providerManagedByOpenClaw:!0},{provider:"discord",label:"Discord",kind:"chat",description:"Servers, channels, DMs, and thread-aware team routing.",iconKey:"siDiscord",accentColor:"#5865F2",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Bot token",placeholder:"Discord bot token",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!0,providerManagedByOpenClaw:!0},{provider:"slack",label:"Slack",kind:"chat",description:"Workspace apps, channels, and internal team handoffs.",iconKey:"siSlack",accentColor:"#4A154B",supportsProvisioning:!0,provisionFields:[{key:"botToken",label:"Bot token",placeholder:"xoxb-...",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"googlechat",label:"Google Chat",kind:"chat",description:"Spaces and enterprise chat surfaces backed by OpenClaw.",iconKey:"siGooglechat",accentColor:"#34A853",supportsProvisioning:!0,provisionFields:[{key:"webhookUrl",label:"Webhook URL",placeholder:"https://chat.googleapis.com/...",inputType:"url",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"gmail",label:"Gmail",kind:"inbox",description:"Inbox ownership, draft/send workflows, and Gmail-triggered automations.",iconKey:"siGmail",accentColor:"#EA4335",supportsProvisioning:!0,provisionFields:[{key:"account",label:"Account email",placeholder:"agent@example.com",inputType:"text",required:!0,section:"basic"},{key:"project",label:"Project ID",placeholder:"openclaw-project",section:"basic"},{key:"label",label:"Label",placeholder:"inbox",section:"basic"},{key:"hookToken",label:"Hook token",placeholder:"shared-secret",inputType:"password",secret:!0,section:"basic"},{key:"hookUrl",label:"Hook URL",placeholder:"https://your-host.example/gmail-pubsub",inputType:"url",section:"advanced"},{key:"topic",label:"Topic",placeholder:"gmail-topic",section:"advanced"},{key:"subscription",label:"Subscription",placeholder:"gmail-subscription",section:"advanced"},{key:"pushToken",label:"Push token",placeholder:"push-secret",inputType:"password",secret:!0,section:"advanced"},{label:"Serve port",placeholder:"8788",key:"serve.port",inputType:"number",section:"advanced"},{key:"serve.bind",label:"Serve bind",placeholder:"127.0.0.1",section:"advanced"},{key:"serve.path",label:"Serve path",placeholder:"/",section:"advanced"},{key:"includeBody",label:"Include body",inputType:"checkbox",defaultValue:!0,section:"advanced"},{key:"maxBytes",label:"Max bytes",placeholder:"20000",inputType:"number",section:"advanced"},{key:"renewEveryMinutes",label:"Renew interval (minutes)",placeholder:"720",inputType:"number",section:"advanced"},{key:"tailscale.mode",label:"Tailscale mode",placeholder:"funnel",defaultValue:"funnel",inputType:"select",options:[{label:"Off",value:"off"},{label:"Serve",value:"serve"},{label:"Funnel",value:"funnel"}],helpText:"One of funnel, serve, or off.",section:"advanced"},{key:"tailscale.path",label:"Tailscale path",placeholder:"/gmail-pubsub",section:"advanced"},{key:"tailscale.target",label:"Tailscale target",placeholder:"http://127.0.0.1:8788/gmail-pubsub",inputType:"url",section:"advanced"},{key:"pushEndpoint",label:"Push endpoint",placeholder:"https://public.example/gmail-push",inputType:"url",section:"advanced"},{key:"model",label:"Model",placeholder:"openrouter/meta-llama/llama-3.3-70b-instruct:free",section:"advanced"},{key:"thinking",label:"Thinking",placeholder:"off",section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"email",label:"Email",kind:"inbox",description:"Generic email inboxes and send/read workflows exposed through OpenClaw.",iconKey:"siMaildotru",accentColor:"#0F172A",supportsProvisioning:!0,provisionFields:[{key:"address",label:"Address",placeholder:"inbox@example.com",inputType:"text",required:!0,section:"basic"},{key:"oauth",label:"OAuth config",placeholder:'{"clientId":"...","clientSecret":"..."}',inputType:"textarea",helpText:"Paste JSON or a provider-specific OAuth configuration blob.",section:"basic"},{key:"watch",label:"Watch",inputType:"checkbox",defaultValue:!0,section:"basic"},{key:"pubsub",label:"Pub/Sub",placeholder:"projects/project-id/topics/email-events",section:"basic"},{key:"imap.host",label:"IMAP host",placeholder:"imap.example.com",inputType:"text",section:"advanced"},{key:"imap.port",label:"IMAP port",placeholder:"993",inputType:"number",section:"advanced"},{key:"smtp.host",label:"SMTP host",placeholder:"smtp.example.com",inputType:"text",section:"advanced"},{key:"smtp.port",label:"SMTP port",placeholder:"587",inputType:"number",section:"advanced"},{key:"username",label:"Username",placeholder:"mailbox-user",inputType:"text",section:"advanced"},{key:"password",label:"Password",placeholder:"app password",inputType:"password",secret:!0,section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"webhook",label:"Webhook",kind:"trigger",description:"External event triggers delivered into OpenClaw automations.",iconKey:"siWebhook",accentColor:"#0EA5E9",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Hook token",placeholder:"shared-secret",inputType:"password",secret:!0,required:!0,section:"basic"},{key:"path",label:"Path",placeholder:"/hooks",section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"cron",label:"Cron",kind:"trigger",description:"Scheduled tasks and recurring automation entry points.",iconKey:"siClockify",accentColor:"#F59E0B",supportsProvisioning:!0,provisionFields:[{key:"webhookToken",label:"Webhook token",placeholder:"replace-with-dedicated-webhook-token",inputType:"password",secret:!0,required:!0,section:"basic"},{key:"sessionRetention",label:"Session retention",placeholder:"24h",section:"basic"},{key:"maxConcurrentRuns",label:"Max concurrent runs",placeholder:"1",inputType:"number",section:"basic"},{key:"store",label:"Store path",placeholder:"~/.openclaw/cron/jobs.json",section:"advanced"},{key:"runLog.maxBytes",label:"Run log max bytes",placeholder:"2mb",section:"advanced"},{key:"runLog.keepLines",label:"Run log keep lines",placeholder:"2000",inputType:"number",section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0}],e=new Map(d.map(a=>[a.provider,a]));function f(a){return e.get(a)??{provider:a,label:g(a),kind:"chat",description:"OpenClaw-managed integration surface.",supportsProvisioning:!1,provisionFields:[],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0}}function g(a){let b=e.get(a);return b?b.label:a.split(/[-_]/).filter(Boolean).map(a=>a.slice(0,1).toUpperCase()+a.slice(1)).join(" ")}function h(a){return[...a].sort((a,b)=>{let c=f(a.type),d=f(b.type);return c.kind!==d.kind?c.kind.localeCompare(d.kind):a.type!==b.type?g(a.type).localeCompare(g(b.type)):a.name.localeCompare(b.name)})}function i(a={}){let b=new Map(d.map(a=>[a.provider,a])),c=new Set;for(let b of a.channelAccounts??[])c.add(b.type);for(let b of a.surfaceRuntime?.providerOrder??[])c.add(b);for(let b of Object.keys(a.surfaceRuntime?.accountsByProvider??{}))c.add(b);for(let d of c){var e;b.has(d)||b.set(d,{provider:d,label:a.surfaceRuntime?.providerLabels[d]??g(d),kind:(e=d,/gmail|mail|email|inbox/i.test(e)?"inbox":/cron|hook|webhook|trigger|event/i.test(e)?"trigger":"chat"),description:"OpenClaw-managed channel exposed through Gateway status or configuration.",supportsProvisioning:!1,provisionFields:[],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0})}return Array.from(b.values()).sort((a,b)=>a.kind!==b.kind?a.kind.localeCompare(b.kind):a.label.localeCompare(b.label))}},42180:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,77990,23))},42601:(a,b,c)=>{"use strict";c.d(b,{_:()=>X});var d=c(3814),e=c(6247),f=c(11917),g=c(73596),h=c(49113),i=c(33500),j=c(36130),k=c(98773),l=c(68123),m=c(56815),n=c(55421),o=c.n(n),p=c(52846),q=c(5813),r=c(80990),s=c(34118),t=c(40299);let u=/(^|[^a-z])rate limit(?:ed|ing)?\b|retry after|too many requests|HTTP\s*429/i,v=/config\.(?:get|schema|patch|apply|set|unset)|gateway config|config updates?/i;function w(a){let b=a?.trim()??"";return u.test(b)&&v.test(b)}function x(a,b,c){return c?[...a.filter(a=>a.workspaceId!==c),...b]:b}function y(a){return!w(a)&&/gateway|websocket|connection closed|service restart|ECONNREFUSED|ECONNRESET|socket hang up|unreachable|not reachable|timed out|timeout|scope upgrade|scope mismatch|missing operator/i.test(a)}function z(a,b,c){return a.surfaceRuntime.accountsByKey[`${b}:${c}`]??a.surfaceRuntime.accountsByKey[`${b}:${F(c)}`]??null}function A(a){switch(a){case"gateway-probe":return"Gateway probe";case"gateway-status":return"Gateway status";case"config-only":return"Config only";case"unavailable":return"Unavailable"}}function B(a,b){if(b&&!a)return"Gateway blocked";if(!a)return"Unknown";switch(a.status){case"connected":return"Connected";case"running":return"Running";case"linked":return"Linked";case"configured":return"Configured";case"disabled":return"Disabled";case"failed":return"Failed";case"gateway-blocked":return"Gateway blocked";case"unknown":return"Unknown"}}function C(a,b){if(b&&!a)return"border-amber-300/25 bg-amber-400/10 text-amber-100";switch(a?.status){case"connected":case"running":case"linked":return"border-emerald-300/25 bg-emerald-400/10 text-emerald-100";case"configured":return"border-cyan-300/25 bg-cyan-400/10 text-cyan-100";case"disabled":return"border-slate-300/15 bg-slate-400/10 text-slate-300";case"failed":return"border-rose-300/25 bg-rose-400/10 text-rose-100";default:return"border-white/10 bg-white/[0.04] text-slate-300"}}function D(a,b,c){let d=new Map;for(let b of a)d.set(b.routeId,b);for(let a of b)d.set(a.chatId,{routeId:a.chatId,provider:c,kind:function(a,b){if("telegram"===a)return"group";if("discord"===a){if(b.startsWith("thread:"))return"thread";if(b.startsWith("role:"))return"role"}return"channel"}(c,a.chatId),title:a.title??d.get(a.chatId)?.title??null,subtitle:d.get(a.chatId)?.subtitle??null,lastSeen:d.get(a.chatId)?.lastSeen??null});return Array.from(d.values()).sort((a,b)=>{let c=a.title??a.routeId,d=b.title??b.routeId;return c.localeCompare(d)})}function E(a){return a.slice(0,1).toUpperCase()+a.slice(1)}function F(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var G=c(90665),H=c(32905);function I({workspaceAgents:a,selectedAgentId:b,onSelectedAgentIdChange:c,accountTargets:e,accountRulesByTargetId:f,isSaving:g,onToggleAccountAccess:j,onRefreshAccounts:k}){let l,n=a.find(a=>a.id===b)??null,s=!!n&&(l=[...n.tools??[],...n.observedTools??[]].map(a=>a.toLowerCase()),"browser"===n.policy.preset||l.some(a=>"browser"===a||a.includes("chrome")));return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-white/10 bg-white/[0.025] p-3.5",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-white",children:"Accounts"}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[e.length," target",1===e.length?"":"s"]})]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-500",children:"Attach saved browser-profile account targets to an agent. AgentOS enforces these bindings before account-target task launch."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[(0,d.jsx)(r.$,{asChild:!0,type:"button",variant:"default",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",children:(0,d.jsxs)(o(),{href:"/accounts?connect=1",children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect Account"]})}),(0,d.jsxs)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:g,onClick:k,children:[(0,d.jsx)(m.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[(0,d.jsxs)("div",{className:"rounded-xl border border-white/8 bg-white/[0.02] p-3",children:[(0,d.jsx)(J,{label:"Agent",htmlFor:"account-agent",children:(0,d.jsxs)("select",{id:"account-agent",value:b,disabled:g||0===a.length,onChange:a=>c(a.target.value),className:"flex h-10 w-full rounded-xl border border-white/10 bg-white/5 px-3 py-2 text-sm text-white outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),a.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-white/8 bg-black/15 px-3 py-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-slate-500",children:"Browser capability"}),(0,d.jsx)("p",{className:"mt-1 text-xs text-slate-300",children:n?s?"This agent has browser-capable tools.":"This agent needs browser/chrome tools before it can use account sessions.":"Select an agent to manage account access."})]})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-amber-300/15 bg-amber-400/[0.06] p-3",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-amber-50",children:"OpenClaw limitation"}),(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-5 text-amber-100/75",children:"OpenClaw does not expose a direct browser-profile dispatch parameter to AgentOS yet. These bindings are real AgentOS access rules and are shown on the canvas, but task launch still passes the selected profile as account context."})]})]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-white/10 bg-white/[0.025] p-3.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("p",{className:"min-w-0 truncate text-sm font-medium text-white",children:"Workspace account targets"}),(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:n?(0,G.CK)(n):"No agent"})]}),0===e.length?(0,d.jsx)("div",{className:"mt-3 rounded-xl border border-dashed border-white/10 bg-white/[0.02] px-3 py-3 text-sm leading-5 text-slate-500",children:"No account targets are connected for this workspace. Use the Accounts page Connect Account flow to open a real OpenClaw browser login target first."}):(0,d.jsx)("div",{className:"mt-3 space-y-2.5",children:e.map(a=>{let c,e=f.get(a.id)??[],h=e.some(a=>a.agentId===b&&"use_browser_profile"===a.permission),k=e.filter(a=>"use_browser_profile"===a.permission),l=n?s?"":"Enable browser/chrome tools for this agent before attaching accounts.":"Select an agent before attaching this account.";return(0,d.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-white/8 bg-white/[0.02] px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(p.J,{serviceId:a.serviceId,serviceName:a.serviceName,primaryDomain:a.primaryDomain,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-white",children:a.serviceName}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",h?"border-emerald-300/25 bg-emerald-400/10 text-emerald-100":"border-white/10 bg-white/[0.04] text-slate-300"),children:h?"Linked to agent":"Not linked"})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-500",children:[a.primaryDomain," \xb7 profile ",a.browserProfileName]}),k.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] leading-4 text-slate-500",children:["Linked agents: ",(c=k.map(a=>a.agentName).sort((a,b)=>a.localeCompare(b))).length<=3?c.join(", "):`${c.slice(0,3).join(", ")} +${c.length-3} more`]}):null]})]}),(0,d.jsx)(r.$,{type:"button",size:"sm",variant:h?"secondary":"default",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:g||!!l,title:l||(h?"Remove this account from the selected agent.":"Attach this account to the selected agent."),onClick:()=>j(a,h),children:h?"Remove":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Add to agent"]})})]},a.id)})})]})]})}function J({label:a,htmlFor:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(s.J,{htmlFor:b,className:"text-[10px] uppercase tracking-[0.16em] text-slate-400",children:a}),c]})}var K=c(98036);function L({provider:a,className:b}){let c=(0,t.rY)(a),e=c.iconKey?K[c.iconKey]:void 0;return(0,d.jsx)("div",{className:(0,H.cn)("flex items-center justify-center rounded-full border border-white/12 bg-slate-950/72 text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)] backdrop-blur-xl",b),"aria-hidden":"true",children:e?(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[58%] w-[58%] select-none",fill:c.accentColor||`#${e.hex}`,children:(0,d.jsx)("path",{d:e.path})}):(0,d.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/88",children:c.label.slice(0,1)})})}var M=c(43081),N=c(37674),O=c(49444),P=c(8910),Q=c(74952),R=c(45084);function S(a,b){let c=a[b];return"string"==typeof c?c:""}function T(a){let b={name:""};for(let c of a.provisionFields){if("boolean"==typeof c.defaultValue||"string"==typeof c.defaultValue){b[c.key]=c.defaultValue;continue}b[c.key]="checkbox"!==c.inputType&&""}return b}function U(a,b){let c={};for(let d of a){let a,e=b[d.key];if("checkbox"===d.inputType)a=!!e;else if("number"===d.inputType){let b="string"==typeof e?Number(e.trim()):Number(e);if(!Number.isFinite(b))continue;a=b}else{if("string"!=typeof e)continue;let b=e.trim();if(0===b.length)continue;a=function(a){if(a.startsWith("{")&&a.endsWith("}")||a.startsWith("[")&&a.endsWith("]"))try{return JSON.parse(a)}catch{}return a}(b)}!function(a,b,c){let d=b.split(".").filter(Boolean);if(d.length<=1){a[b]=c;return}let e=a;for(let a of d.slice(0,-1)){var f;(f=e[a])&&"object"==typeof f&&!Array.isArray(f)||(e[a]={}),e=e[a]}e[d[d.length-1]]=c}(c,d.key,a)}return c}var V=c(12557);let W=["chat","inbox","trigger"];function X({snapshot:a,workspaceId:b,accountTargets:c=[],accountAccessRules:n=[],initialAgentId:o=null,open:p,initialProvider:s=null,onOpenChange:u,onRefresh:v,onSnapshotChange:J,onAccountAccessRulesChange:K,onAccountTargetsChange:$}){let _=(0,e.useMemo)(()=>a.workspaces.find(a=>a.id===b)??null,[a.workspaces,b]),aa=(0,e.useMemo)(()=>a.agents.filter(a=>a.workspaceId===_?.id),[a.agents,_?.id]),ab=(0,e.useMemo)(()=>_?(0,R.mG)(a,_.id):[],[a,_]),ac=(0,e.useMemo)(()=>(0,t.yQ)(a.channelAccounts),[a.channelAccounts]),ad=(0,e.useMemo)(()=>(0,t.F3)({channelAccounts:ac,surfaceRuntime:a.surfaceRuntime}),[ac,a.surfaceRuntime]),ae=(0,e.useMemo)(()=>new Map(ad.map(a=>[a.provider,a])),[ad]),af=(0,e.useMemo)(()=>{let a=new Set(ad.map(a=>a.kind));return W.filter(b=>a.has(b))},[ad]),[ag,ah]=(0,e.useState)("surfaces"),[ai,aj]=(0,e.useState)("chat"),[ak,al]=(0,e.useState)("telegram"),[am,an]=(0,e.useState)(!1),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(""),[as,at]=(0,e.useState)({}),[au,av]=(0,e.useState)({}),[aw,ax]=(0,e.useState)({}),[ay,az]=(0,e.useState)({}),[aA,aB]=(0,e.useState)({}),[aC,aD]=(0,e.useState)(null),[aE,aF]=(0,e.useState)(""),[aG,aH]=(0,e.useState)(null),[aI,aJ]=(0,e.useState)(T((0,t.rY)(ak))),aK=(0,e.useCallback)(a=>{an(!0),ap(a)},[]),aL=(0,e.useCallback)(()=>{an(!1),ap(null)},[]),aM=(0,e.useMemo)(()=>(function(a,b){let c=new Map(a.map(a=>[a.id,a]));for(let a of b)c.has(a.accountId)||c.set(a.accountId,{id:a.accountId,type:a.provider,name:a.name||a.label||a.accountId,enabled:a.enabled,kind:(0,t.rY)(a.provider).kind,metadata:{runtimeOnly:!0}});return(0,t.yQ)(Array.from(c.values()))})(ac.filter(a=>a.type===ak),Object.values(a.surfaceRuntime.accountsByProvider[ak]??{})),[ak,ac,a.surfaceRuntime.accountsByProvider]),aN=(0,e.useMemo)(()=>ab.filter(a=>a.type===ak),[ak,ab]),aO=(0,e.useMemo)(()=>ae.get(ak)??(0,t.rY)(ak),[ak,ae]),aP=a.surfaceRuntime.gatewayAccess,aQ=(0,e.useMemo)(()=>{var b,c;return b=a.surfaceDrift.issues,(c=_?.id??null)?b.filter(a=>!a.workspaceId||a.workspaceId===c):b},[a.surfaceDrift.issues,_?.id]),aR=(0,e.useMemo)(()=>aQ.reduce((a,b)=>("missing-binding"===b.kind?a.missingBindings+=1:"extra-binding"===b.kind?a.extraBindings+=1:"agent-mismatch"===b.kind?a.agentMismatch+=1:"account-missing"===b.kind?a.accountMissing+=1:"provider-disabled"===b.kind&&(a.providerDisabled+=1),a),{missingBindings:0,extraBindings:0,agentMismatch:0,accountMissing:0,providerDisabled:0}),[aQ]),aS=(0,e.useMemo)(()=>aQ.filter(a=>a.provider===ak),[ak,aQ]),aT=aO.provisionFields.filter(a=>"advanced"!==a.section),aU=aO.provisionFields.filter(a=>"advanced"===a.section),aV=(0,e.useCallback)(a=>aN.some(b=>b.id===a||b.id===F(a)),[aN]),{accountRulesByTargetId:aW,refreshAccounts:aX,selectedAccountAgentId:aY,setSelectedAccountAgentId:aZ,updateAgentAccountAccess:a$,workspaceAccountTargets:a_}=function({open:a,workspaceId:b,workspaceAgents:c,accountTargets:d,accountAccessRules:f,initialAgentId:g,beginSaving:h,endSaving:i,onAccountAccessRulesChange:j,onAccountTargetsChange:k}){let[l,m]=(0,e.useState)(""),n=(0,e.useMemo)(()=>b?d.filter(a=>a.workspaceId===b):[],[d,b]),o=(0,e.useMemo)(()=>b?f.filter(a=>a.workspaceId===b):[],[f,b]),p=(0,e.useMemo)(()=>{let a=new Map;for(let b of o){let c=a.get(b.targetId)??[];c.push(b),a.set(b.targetId,c)}return a},[o]),q=(0,e.useMemo)(()=>c.find(a=>a.id===l)??null,[l,c]),r=(0,e.useCallback)(async()=>{var a;let c=b?`?workspaceId=${encodeURIComponent(b)}`:"",[e,g]=await Promise.all([fetch(`/api/accounts/login-targets${c}`,{cache:"no-store"}),fetch(`/api/accounts/access-rules${c}`,{cache:"no-store"})]),h=await e.json().catch(()=>null),i=await g.json().catch(()=>null);if(!e.ok||!h?.ok)throw Error(h?.error??"Account targets could not be loaded.");if(!g.ok||!i?.ok)throw Error(i?.error??"Account access rules could not be loaded.");k?.((a=h.targets,!b?a:[...d.filter(a=>a.workspaceId!==b),...a])),j?.(x(f,i.rules,b))},[f,d,j,k,b]),s=(0,e.useCallback)(async(a,c)=>{if(b&&q){h(c?"Removing account access...":"Adding account access...");try{let d=[...(p.get(a.id)??[]).filter(a=>a.agentId!==q.id).map(a=>({agentId:a.agentId,agentName:a.agentName,permission:a.permission,notes:a.notes})),...c?[]:[{agentId:q.id,agentName:(0,G.CK)(q),permission:"use_browser_profile",notes:`Granted from Workspace Surfaces for ${a.serviceName}.`}]],e=await fetch("/api/accounts/access-rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:b,targetId:a.id,rules:d})}),g=await e.json().catch(()=>null);if(!e.ok||!g?.ok)throw Error(g?.error??"Account access could not be updated.");j?.(x(f,g.rules,b)),M.o.success(c?"Account access removed.":"Account access added.",{description:`${(0,G.CK)(q)} ${c?"can no longer use":"can use"} ${a.serviceName}.`})}catch(a){M.o.error("Account access update failed.",{description:a instanceof Error?a.message:"Unknown account access error."})}finally{i()}}},[f,p,h,i,j,q,b]);return{accountRulesByTargetId:p,refreshAccounts:r,selectedAccountAgentId:l,setSelectedAccountAgentId:m,updateAgentAccountAccess:s,workspaceAccountTargets:n}}({open:p,workspaceId:_?.id??null,workspaceAgents:aa,accountTargets:c,accountAccessRules:n,initialAgentId:o,beginSaving:aK,endSaving:aL,onAccountAccessRulesChange:K,onAccountTargetsChange:$}),a0=(0,e.useCallback)((b,c="Unset")=>b?(0,G.CK)(a.agents.find(a=>a.id===b)??{name:b}):c,[a.agents]),a1=(0,e.useCallback)(b=>a.workspaces.find(a=>a.id===b)?.name??b,[a.workspaces]),a2=(0,e.useMemo)(()=>ad.filter(a=>a.kind===ai).map(a=>a.provider),[ai,ad]),a3=(0,e.useCallback)(async(a,b)=>{if(_?.id){az(b=>({...b,[a]:!0})),aB(b=>({...b,[a]:null}));try{let c=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/discovery?provider=${encodeURIComponent(b)}&accountId=${encodeURIComponent(a)}`),d=await c.json();if(!c.ok||d.error)throw Error(d.error||`${(0,t.rY)(b).label} route discovery failed.`);if(ax(b=>({...b,[a]:!1!==d.supported&&Array.isArray(d.routes)?d.routes:[]})),"telegram"===b&&Array.isArray(d.routes)&&d.routes.length>0){let b=ab.find(b=>b.id===a)??null,c=b?.workspaces.find(a=>a.workspaceId===_.id)??null;if(b&&c){let b=(c.groupAssignments??[]).filter(a=>!1!==a.enabled),e=new Set(b.map(a=>a.chatId)),f=d.routes.filter(a=>a.routeId&&!e.has(a.routeId)),g=new Map(d.routes.filter(a=>a.routeId&&a.title?.trim()).map(a=>[a.routeId,a.title?.trim()??null])),h=b.map(a=>{let b=g.get(a.chatId);return b&&a.title!==b?{...a,title:b}:a}),i=h.some((a,c)=>a.title!==b[c]?.title);if(f.length>0||i)try{let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"groups",channelId:a,groupAssignments:[...h,...f.map(a=>({chatId:a.routeId,title:a.title??null,agentId:null,enabled:!0}))]})}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"Discovered groups could not be enabled.");c.registry&&J&&J(a=>(0,R.z$)(a,c.registry)),M.o.success("Telegram routes enabled.",{description:1===f.length?`${f[0].title??f[0].routeId} now falls back to the primary agent.`:f.length>1?`${f.length} discovered groups now fall back to the primary agent.`:"Discovered group names were synced."}),v().catch(()=>{})}catch(a){M.o.error("Telegram route sync failed.",{description:a instanceof Error?a.message:"Discovered groups could not be enabled."})}}}}catch(c){aB(d=>({...d,[a]:c instanceof Error?c.message:`${(0,t.rY)(b).label} discovery failed.`}))}finally{az(b=>({...b,[a]:!1}))}}},[v,J,_,ab]),a4=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a5=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a6=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a7=a=>{a.registry&&J&&J(b=>{let c=(0,R.z$)(b,a.registry);return a.account&&(c=(0,R.Iz)(c,a.account)),c})},a8=async a=>{let b=(0,V.Ek)(a);if(b)return b;if(!y(a))return null;try{let b=await fetch("/api/settings/gateway",{method:"GET"}),c=await b.json().catch(()=>null),d=c?.authStatus?.native?.issue??null,e=c?.authStatus?.recommendation??null;return(0,V.Ek)([a,d,e].filter(Boolean).join("\n"))}catch{return null}},a9=async(a,b,c=["operator.admin"])=>{aK(`${a.label} repair...`);try{let d=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a.apiAction,scopes:c})}),e=await d.json().catch(()=>null);if(!d.ok)throw Error(e?.error||"Gateway access could not be repaired.");if(e?.authStatus?.native&&!1===e.authStatus.native.ok)throw Error(e.authStatus.native.issue||"Gateway access still needs attention.");M.o.success(`${a.label} repaired.`,{description:"Retrying the surface operation."}),await v().catch(()=>void 0),await b()}catch(a){M.o.error("Gateway repair failed.",{description:a instanceof Error?a.message:"Unable to repair Gateway access."})}finally{aL()}},ba=async(a,b,c,d=["operator.admin"])=>{let e=b instanceof Error?b.message:"Unknown surface error.";if(w(e)&&c)return void M.o.error(a,{description:function(a,b="the config action"){let c=function(a){if(!w(a))return null;let b=(a??"").match(/retry after\s+(\d+(?:\.\d+)?)\s*(ms|msec|millisecond(?:s)?|s|sec|second(?:s)?|m|min|minute(?:s)?)?/i);if(!b)return null;let c=Number(b[1]);if(!Number.isFinite(c)||c<0)return null;let d=b[2]?.toLowerCase()??"s";return"ms"===d||"msec"===d||d.startsWith("millisecond")?Math.round(c):"m"===d||"min"===d||d.startsWith("minute")?Math.round(6e4*c):Math.round(1e3*c)}(a),d=c?`about ${function(a){if(a<1e3)return`${a}ms`;let b=Math.ceil(a/1e3);if(b<60)return`${b} second${1===b?"":"s"}`;let c=Math.ceil(b/60);return`${c} minute${1===c?"":"s"}`}(c)}`:"for the Gateway config cooldown";return`OpenClaw Gateway is rate limiting config updates. Wait ${d}, then retry ${b}. AgentOS did not use CLI fallback for this operation.`}(e,"the surface operation"),duration:12e3,action:{label:"Retry",onClick:()=>void c()}});let f=await a8(e)??(y(e)?{apiAction:"repairDeviceAccess",cta:"Repair access",label:"Gateway access",detail:"Approve any pending local AgentOS Gateway scope request, then retry."}:null);f&&c?M.o.error(a,{description:`${e} ${f.detail}`,duration:12e3,action:{label:"Repair & retry",onClick:()=>void a9(f,c,d)}}):y(e)&&c?M.o.error(a,{description:`${e} Wait for the OpenClaw Gateway to finish restarting, then retry.`,duration:1e4,action:{label:"Retry",onClick:()=>void c()}}):M.o.error(a,{description:e})},bb=async a=>{if(_){aK(`Connecting ${a.name}...`);try{let b=await a4({channelId:a.id,type:ak,name:a.name,workspacePath:_.path,primaryAgentId:aq||null,agentId:aq||void 0});a7(b),M.o.success(`${(0,t.rY)(ak).label} connected to this workspace.`),v().catch(()=>{})}catch(b){await ba("Surface connection failed.",b,()=>bb(a))}finally{aL()}}},bc=async()=>{if(_){if(!S(aI,"name").trim())return void M.o.error("A surface name is required.");aK(`Provisioning ${aO.label}...`);try{let a=U(aO.provisionFields,aI),b={type:ak,name:S(aI,"name").trim(),workspacePath:_.path,config:a,primaryAgentId:aq||null,agentId:aq||void 0};for(let c of aO.provisionFields)"token"===c.key&&"string"==typeof a.token&&(b.token=a.token),"botToken"===c.key&&"string"==typeof a.botToken&&(b.botToken=a.botToken),"webhookUrl"===c.key&&"string"==typeof a.webhookUrl&&(b.webhookUrl=a.webhookUrl);let c=await a4(b);a7(c),aJ(T(aO)),M.o.success(`${aO.label} provisioned and connected.`),v().catch(()=>{})}catch(a){await ba("Surface provisioning failed.",a,bc)}finally{aL()}}},bd=async(a,b)=>{if(_&&b){aK("Updating owner agent...");try{let c=ab.find(b=>b.id===a)??null,d=c?.workspaces.find(a=>a.workspaceId===_.id)??null;if(c&&d&&!d.agentIds.includes(b)){let c=await a5({action:"bind-agent",channelId:a,agentId:b,workspacePath:_.path});a7(c)}let e=await a5({action:"primary",channelId:a,primaryAgentId:b});a7(e),M.o.success("Owner agent updated."),v().catch(()=>{})}catch(a){M.o.error("Surface update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},be=async a=>{aK("Disconnecting surface from workspace...");try{let b=await a6({channelId:a});a7(b),M.o.success("Surface disconnected from this workspace."),v().catch(()=>{})}catch(a){M.o.error("Surface disconnect failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}},bf=async a=>{let b=as[a]?.trim(),c=au[a]?.trim();if(_&&b){aK(c?"Adding assistant and assigning route...":"Adding assistant agent...");try{let d=await a5({action:"bind-agent",channelId:a,agentId:b,workspacePath:_.path});a7(d);let e=null;if(c){let d=ab.find(b=>b.id===a)??null,f=d?.workspaces.find(a=>a.workspaceId===_.id)??null;if(!d||!f)throw Error("Surface route binding was not found.");let g=(f.groupAssignments??[]).filter(a=>!1!==a.enabled),h=d.workspaces.flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled)),i=D(aw[a]??[],h,d.type).find(a=>a.routeId===c)??null;e=i?.title??c;let j={chatId:c,title:i?.title??g.find(a=>a.chatId===c)?.title??null,agentId:b,enabled:!0},k=g.some(a=>a.chatId===c)?g.map(a=>a.chatId===c?{...a,...j}:a):[...g,j],l=await a5({action:"groups",channelId:a,groupAssignments:k});a7(l)}at(b=>({...b,[a]:""})),av(b=>({...b,[a]:""})),M.o.success(c?"Assistant added and assigned.":"Assistant agent added.",{description:c&&e?`${a0(b,b)} now owns ${e}.`:void 0}),v().catch(()=>{})}catch(a){M.o.error("Assistant update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},bg=async(a,b)=>{aK("Removing assistant agent...");try{let c=await a5({action:"unbind-agent",channelId:a,agentId:b});a7(c),M.o.success("Assistant agent removed."),v().catch(()=>{})}catch(a){M.o.error("Assistant update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}},bh=async(a,b)=>{aK("Updating surface routes...");try{let c=await a5({action:"groups",channelId:a,groupAssignments:b});a7(c),v().catch(()=>{})}catch(a){M.o.error("Surface route update failed.",{description:a instanceof Error?a.message:"Unknown surface routing error."})}finally{aL()}},bi=async()=>{if(aC){aK(`Deleting ${aC.name} from OpenClaw...`);try{let a=await a6({channelId:aC.id,scope:"global"});a.registry&&J&&J(b=>(0,R.fY)((0,R.z$)(b,a.registry),aC.id)),aD(null),aF(""),M.o.success("Surface account deleted everywhere."),v().catch(()=>{})}catch(a){M.o.error("Surface deletion failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},bj=async()=>{if(_){aK("Previewing OpenClaw binding repair...");try{let a=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/reconcile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"workspace",dryRun:!0})}),b=await a.json();if(!a.ok||b.error||!b.repair?.auditId)throw Error(b.error||"OpenClaw binding repair preview could not be created.");let c=b.repair;aH(c),M.o.info("Binding repair preview created.",{description:`Audit ${c.auditId} was written without changing OpenClaw config.`})}catch(a){await ba("Binding repair preview failed.",a,bj,["operator.admin"])}finally{aL()}}},bk=async()=>{if(_&&aG?.auditId)try{aK("Applying OpenClaw binding repair...");let a=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/reconcile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"workspace",dryRun:!1,confirm:"apply-surface-reconcile",previewAuditId:aG.auditId})}),b=await a.json();if(!a.ok||b.error)throw Error(b.error||"OpenClaw bindings could not be reconciled.");b.snapshot&&J&&J(()=>b.snapshot);let c=b.repair;aH(null),M.o.success("OpenClaw bindings repaired.",{description:c?`${c.addedBindingCount} added, ${c.removedBindingCount} removed. Backup ${c.backupId||"recorded"}.`:"Managed bindings were rewritten from the AgentOS registry."}),v().catch(()=>{})}catch(a){await ba("Binding repair failed.",a,void 0,["operator.admin"])}finally{aL()}},bl=!!aC&&aE.trim().toLowerCase()===aC.name.trim().toLowerCase(),bm="chat"===aO.kind?null:U(aO.provisionFields,aI),bn="chat"===aO.kind?null:function(a){switch(a){case"gmail":return"hooks.gmail";case"email":return"email";case"webhook":return"hooks";case"cron":return"cron";default:return a}}(aO.provider),bo=aO.provisionFields.every(a=>(function(a,b){if(!a.required)return!0;let c=b[a.key];return"checkbox"===a.inputType?!0===c:"number"===a.inputType?"string"==typeof c&&c.trim().length>0&&Number.isFinite(Number(c.trim())):"string"==typeof c&&c.trim().length>0})(a,aI)),bp=aO.supportsProvisioning&&!am&&!!aq&&!!S(aI,"name").trim()&&bo,bq=aG?.restorePlan?.configPaths??[],br=a=>{let b=`surface-${a.key}`,c=aI[a.key];return"checkbox"===a.inputType?(0,d.jsxs)("label",{htmlFor:b,className:"flex cursor-pointer items-start gap-3 rounded-xl border border-white/8 bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[(0,d.jsx)("input",{id:b,type:"checkbox",checked:!!c,disabled:am,onChange:b=>aJ(c=>({...c,[a.key]:b.target.checked})),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-white/5 text-cyan-400 focus:ring-cyan-400/60"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-white",children:a.label}),a.helpText?(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-4 text-slate-500",children:a.helpText}):null]})]},a.key):(0,d.jsxs)(Y,{label:a.label,htmlFor:b,children:["select"===a.inputType?(0,d.jsxs)("select",{id:b,value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),className:"flex h-10 w-full rounded-xl border border-white/10 bg-white/5 px-3 py-2 text-sm text-white outline-none",disabled:am,children:[(0,d.jsx)("option",{value:"",children:"Select one"}),(a.options??[]).map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))]}):"textarea"===a.inputType?(0,d.jsx)(Q.T,{id:b,value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),placeholder:a.placeholder,disabled:am,className:"min-h-20 rounded-xl px-3 py-2"}):(0,d.jsx)(O.p,{id:b,type:"number"===a.inputType?"number":a.secret?"password":a.inputType??"text",value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),placeholder:a.placeholder,disabled:am,className:"h-10 rounded-xl px-3"}),a.helpText?(0,d.jsx)("p",{className:"text-[11px] leading-4 text-slate-500",children:a.helpText}):null]},a.key)};return(0,d.jsxs)(N.lG,{open:p,onOpenChange:u,children:[(0,d.jsx)(N.Cf,{className:"flex max-h-[calc(100dvh-2rem)] w-[calc(100vw-1rem)] max-w-5xl flex-col overflow-hidden rounded-[22px] p-0",closeClassName:"right-3 top-3",children:(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsx)(N.c7,{className:"border-b border-white/10 px-4 py-3 pr-12 sm:px-5",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(N.L3,{className:"text-lg",children:"Workspace surfaces"}),(0,d.jsx)(N.rr,{className:"mt-1 text-xs",children:"Manage accounts, owners, and routes for this workspace."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-slate-400",children:[(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[ab.length," linked"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[ac.length," accounts"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[a_.length," account targets"]})]})]})}),am&&ao?(0,d.jsx)("div",{className:"mx-4 mt-4 rounded-2xl border border-cyan-300/20 bg-cyan-400/[0.08] px-3 py-2 sm:mx-6",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-cyan-50",children:[(0,d.jsx)(f.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,d.jsx)("span",{children:ao})]})}):null,aP.blocked?(0,d.jsx)("div",{className:"mx-4 mt-4 rounded-2xl border border-amber-300/25 bg-amber-400/[0.08] px-3 py-3 sm:mx-6",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-50",children:"Gateway access blocked"}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-100/80",children:aP.issue??"OpenClaw Gateway pairing or scope approval is blocking live channel status."}),aP.missingScopes.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] text-amber-100/70",children:["Missing scopes: ",aP.missingScopes.join(", ")]}):null]})]}),aP.repairAction?(0,d.jsx)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am,onClick:()=>void a9(aP.repairAction,async()=>{await v()},aP.missingScopes.length>0?aP.missingScopes:["operator.read"]),children:"Repair Gateway Access"}):null]})}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 sm:px-5",children:(0,d.jsxs)("div",{className:"grid min-h-0 gap-4 sm:grid-cols-[220px_minmax(0,1fr)]",children:[(0,d.jsxs)("aside",{className:"h-fit rounded-2xl border border-white/10 bg-white/[0.025] p-2.5 sm:sticky sm:top-0",children:[(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1 rounded-xl border border-white/8 bg-black/15 p-1",children:["surfaces","accounts"].map(a=>(0,d.jsx)("button",{type:"button",onClick:()=>ah(a),className:(0,H.cn)("rounded-lg px-2 py-1.5 text-[11px] font-medium transition-colors",ag===a?"bg-cyan-300/14 text-cyan-50":"text-slate-400 hover:bg-white/[0.04] hover:text-slate-200"),children:"surfaces"===a?"Surfaces":"Accounts"},a))}),"surfaces"===ag?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(P.tU,{value:ai,onValueChange:a=>aj(a),className:"mt-2.5",children:(0,d.jsx)(P.j7,{className:"grid h-9 w-full grid-cols-3 rounded-xl",children:af.map(a=>(0,d.jsx)(P.Xi,{className:"h-7 rounded-lg px-2 text-[11px]",value:a,children:E(a)},a))})}),(0,d.jsx)("div",{className:"mt-2.5 space-y-1.5",children:a2.map(b=>{let c=ae.get(b)??(0,t.rY)(b),e=ab.filter(a=>a.type===b).length,f=ac.filter(a=>a.type===b).length,g=Object.keys(a.surfaceRuntime.accountsByProvider[b]??{}).length;return(0,d.jsxs)("button",{type:"button",onClick:()=>al(b),className:(0,H.cn)("flex w-full items-center justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors",ak===b?"border-cyan-300/35 bg-cyan-400/[0.08]":"border-white/8 bg-white/[0.02] hover:bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,d.jsx)(L,{provider:b,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-white",children:c.label}),(0,d.jsxs)("p",{className:"mt-0.5 truncate text-[10px] text-slate-500",children:[Math.max(f,g)," account",1===Math.max(f,g)?"":"s"," \xb7"," ",A(a.surfaceRuntime.source)]})]})]}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 shrink-0 rounded-full px-2 text-[10px]",children:e})]},b)})})]}):(0,d.jsxs)("div",{className:"mt-2.5 space-y-2 rounded-xl border border-white/8 bg-white/[0.02] p-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.A,{className:"h-3.5 w-3.5 text-amber-200"}),(0,d.jsx)("p",{className:"text-xs font-medium text-white",children:"Workspace accounts"})]}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-slate-500",children:"Grant saved browser-profile account targets to workspace agents."}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 w-fit rounded-full px-2 text-[10px]",children:[a_.length," available"]})]})]}),(0,d.jsx)("div",{className:"min-w-0 space-y-4",children:"accounts"===ag?(0,d.jsx)(I,{workspaceAgents:aa,selectedAgentId:aY,onSelectedAgentIdChange:aZ,accountTargets:a_,accountRulesByTargetId:aW,isSaving:am,onToggleAccountAccess:(a,b)=>void a$(a,b),onRefreshAccounts:()=>void aX().catch(a=>{M.o.error("Accounts refresh failed.",{description:a instanceof Error?a.message:"Unknown account refresh error."})})}):(0,d.jsxs)(d.Fragment,{children:[aQ.length>0?(0,d.jsxs)("section",{className:"rounded-2xl border border-amber-300/20 bg-amber-400/[0.06] p-3.5",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-50",children:"OpenClaw binding drift"}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[aQ.length," issue",1===aQ.length?"":"s"]})]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-100/75",children:"AgentOS registry and OpenClaw runtime bindings differ for this workspace."}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[aR.missingBindings>0?`${aR.missingBindings} missing`:null,aR.extraBindings>0?`${aR.extraBindings} extra`:null,aR.agentMismatch>0?`${aR.agentMismatch} mismatch`:null,aR.accountMissing>0?`${aR.accountMissing} account missing`:null,aR.providerDisabled>0?`${aR.providerDisabled} disabled`:null].filter(a=>!!a).map(a=>(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:a},a))})]}),(0,d.jsx)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am||!a.surfaceDrift.checked,onClick:()=>void bj(),children:"Repair bindings"})]}),(0,d.jsxs)("div",{className:"mt-3 space-y-2",children:[aQ.slice(0,4).map(a=>{var b;let c,e,f,g;return(0,d.jsxs)("div",{className:"rounded-xl border border-white/8 bg-black/15 px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:(b=a.provider,ae.get(b)?.label??(0,t.rY)(b).label)}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:function(a){switch(a){case"missing-binding":return"Missing";case"extra-binding":return"Extra";case"agent-mismatch":return"Mismatch";case"account-missing":return"Account";case"provider-disabled":return"Disabled"}}(a.kind)}),(0,d.jsx)("p",{className:"min-w-0 flex-1 truncate text-xs font-medium text-white",children:a.title})]}),(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-4 text-amber-100/75",children:(c=a.routeId?` route ${a.routeId}`:"",e=a.accountId?`${a.provider}:${a.accountId}`:a.provider,f=a.expectedAgentId?a0(a.expectedAgentId,a.expectedAgentId):null,g=a.actualAgentId?a0(a.actualAgentId,a.actualAgentId):null,f&&g?`${e}${c}: expected ${f}, OpenClaw has ${g}.`:f?`${e}${c}: expected ${f}. ${a.detail}`:g?`${e}${c}: OpenClaw has ${g}. ${a.detail}`:`${e}${c}: ${a.detail}`)})]},a.id)}),aQ.length>4?(0,d.jsxs)("p",{className:"text-[11px] text-amber-100/65",children:[aQ.length-4," more drift issue",aQ.length-4==1?"":"s"," hidden."]}):null]})]}):null,(0,d.jsxs)("section",{className:"rounded-2xl border border-white/10 bg-white/[0.025] p-3.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("p",{className:"min-w-0 truncate text-sm font-medium text-white",children:[aO.label," surfaces"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[aN.length," linked"]})]}),aN.length>0?(0,d.jsx)("div",{className:"mt-3 space-y-2.5",children:aN.map(b=>{var c;let e=b.workspaces.find(a=>a.workspaceId===_?.id)??null,g=(e?.agentIds??[]).filter(a=>a!==b.primaryAgentId),h=aa.filter(a=>a.id!==b.primaryAgentId&&!(e?.agentIds??[]).includes(a.id)),n=(e?.groupAssignments??[]).filter(a=>!1!==a.enabled),o=b.workspaces.flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled)),p=b.workspaces.filter(a=>a.workspaceId!==_?.id).flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled&&a.chatId).map(c=>({routeId:c.chatId,workspaceName:a1(a.workspaceId),ownerName:c.agentId?a0(c.agentId,c.agentId):`${a0(b.primaryAgentId,"Primary agent")} fallback`}))).reduce((a,b)=>({...a,[b.routeId]:[...a[b.routeId]??[],{workspaceName:b.workspaceName,ownerName:b.ownerName}]}),{}),s=aw[b.id]??[],u=!!ay[b.id],v=aA[b.id]??null,w=D(s,o.length>0?o:n,b.type),x=aa.some(a=>a.id===b.primaryAgentId),y=z(a,b.type,b.id),I=aS.filter(a=>a.accountId===b.id||a.accountId===F(b.id));return(0,d.jsxs)("div",{className:"rounded-2xl border border-white/8 bg-white/[0.02] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(L,{provider:b.type,className:"h-9 w-9 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-white",children:b.name}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:E(aO.kind)}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",C(y,aP.blocked)),children:B(y,aP.blocked)}),I.length>0?(0,d.jsx)(q.E,{className:"h-5 rounded-full border-amber-300/25 bg-amber-400/10 px-2 text-[10px] text-amber-100",children:"Drift"}):null]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-500",children:[b.type,":",b.id," \xb7 ",A(y?.source??a.surfaceRuntime.source)]})]})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,d.jsxs)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:am,onClick:()=>void be(b.id),children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Disconnect"]}),(0,d.jsx)(r.$,{type:"button",variant:"destructive",size:"sm",className:"h-8 w-8 rounded-full p-0",disabled:am,"aria-label":`Delete ${b.name}`,title:"Delete everywhere",onClick:()=>{let a=aM.find(a=>a.id===b.id)??null,c=a??aM.find(a=>F(a.id)===b.id)??null,d=a??(c?{...c,id:b.id}:null);d&&(aD(d),aF(""))},children:(0,d.jsx)(j.A,{className:"h-3.5 w-3.5"})})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 text-[11px] text-slate-400 sm:grid-cols-4",children:[(0,d.jsx)(Z,{label:"Primary",value:a0(b.primaryAgentId)}),(0,d.jsx)(Z,{label:"Assistants",value:String(g.length)}),(0,d.jsx)(Z,{label:"Routes",value:String(n.length)}),(0,d.jsx)(Z,{label:"Health",value:B(y,aP.blocked)})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)(Y,{label:"chat"===aO.kind?"Primary agent":"Owner agent",htmlFor:`primary-${b.id}`,children:(0,d.jsxs)("select",{id:`primary-${b.id}`,value:b.primaryAgentId??"",disabled:am,onChange:a=>void bd(b.id,a.target.value),className:"flex h-9 w-full rounded-xl border border-white/10 bg-white/5 px-3 text-sm text-white outline-none",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),b.primaryAgentId&&!x?(0,d.jsxs)("option",{value:b.primaryAgentId,children:[a0(b.primaryAgentId,b.primaryAgentId)," \xb7 outside this workspace"]}):null,aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsxs)("p",{className:"flex items-center gap-1.5 text-[11px] text-slate-500",children:[(0,d.jsx)(k.A,{className:"h-3 w-3"}),a0(b.primaryAgentId)]})]}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-slate-400",children:"Assistants available for routes"}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-slate-500",children:"Add an agent to the surface, then optionally assign it to a route."})]}),g.length>0?(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:g.map(a=>(0,d.jsxs)("button",{type:"button",disabled:am,onClick:()=>void bg(b.id,a),className:"inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-2.5 py-1 text-[11px] text-slate-200 transition-colors hover:bg-white/[0.08]",children:[(0,d.jsx)("span",{children:a0(a,a)}),(0,d.jsx)("span",{className:"text-slate-500",children:"remove"})]},`${b.id}-${a}`))}):(0,d.jsx)("p",{className:"text-[11px] text-slate-400",children:"No assistant agents attached yet."}),h.length>0?(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,d.jsxs)("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:[(0,d.jsxs)("select",{value:as[b.id]??"",disabled:am,"aria-label":"Assistant agent",onChange:a=>at(c=>({...c,[b.id]:a.target.value})),className:"flex h-9 w-full rounded-xl border border-white/10 bg-white/5 px-3 text-sm text-white outline-none",children:[(0,d.jsx)("option",{value:"",children:"Select assistant"}),h.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]}),(0,d.jsxs)("select",{value:au[b.id]??"",disabled:am||0===w.length,"aria-label":"Initial route assignment",onChange:a=>av(c=>({...c,[b.id]:a.target.value})),className:"flex h-9 w-full rounded-xl border border-white/10 bg-white/5 px-3 text-sm text-white outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[(0,d.jsx)("option",{value:"",children:w.length>0?"No route yet":"No discovered routes"}),w.map(a=>(0,d.jsxs)("option",{value:a.routeId,children:["Assign to ",a.title??a.routeId]},`${b.id}-target-${a.routeId}`))]})]}),(0,d.jsxs)(r.$,{type:"button",size:"sm",className:"h-9 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am||!(as[b.id]??"").trim(),onClick:()=>void bf(b.id),children:[(0,d.jsx)(l.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Add"]})]}):null]})]}),aO.supportsRouteDiscovery?(0,d.jsxs)("div",{className:"mt-3 rounded-2xl border border-white/8 bg-white/[0.025] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("p",{className:"text-sm font-medium text-white",children:[(0,t.rY)(b.type).label," routes"]}),(0,d.jsx)("p",{className:"mt-0.5 text-[11px] text-slate-500",children:"Unassigned routes use the primary agent."})]}),(0,d.jsxs)(r.$,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:am||u,onClick:()=>void a3(b.id,b.type),children:[u?(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(m.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Routes"]})]}),v?(0,d.jsx)("p",{className:"mt-3 text-[11px] text-rose-300",children:v}):null,w.length>0?(0,d.jsx)("div",{className:"mt-3 space-y-2",children:w.map(a=>{var c;let e,f=n.find(b=>b.chatId===a.routeId)??null,g=p[a.routeId]??[],h=!!f,i=h?n.filter(b=>b.chatId!==a.routeId):[...n,{chatId:a.routeId,title:a.title??null,agentId:null,enabled:!0}];return(0,d.jsx)("div",{className:"rounded-xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-white/15 bg-white/5 accent-cyan-300",checked:h,disabled:am,onChange:()=>void bh(b.id,i)}),(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-white",children:a.title??a.routeId}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:a.kind})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-500",children:[a.subtitle??a.routeId,a.lastSeen?` \xb7 seen ${Number.isNaN(e=Date.parse(c=a.lastSeen))?c:new Date(e).toISOString().replace("T"," ").slice(0,16)}`:""]}),g.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] leading-4 text-amber-100/75",children:["Also routed in"," ",g.map(a=>`${a.workspaceName} by ${a.ownerName}`).join(", ")]}):null]}),(0,d.jsxs)("div",{className:"min-w-[190px] space-y-1",children:[(0,d.jsx)("p",{className:"px-1 text-[9px] uppercase tracking-[0.14em] text-slate-500",children:"Route owner"}),(0,d.jsxs)("select",{value:f?.agentId??"",disabled:am||!h,onChange:c=>void bh(b.id,n.map(b=>b.chatId===a.routeId?{...b,title:a.title??b.title??null,agentId:c.target.value||null}:b)),className:"flex h-8 w-full rounded-full border border-white/10 bg-white/5 px-3 text-[11px] text-white outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[(0,d.jsx)("option",{value:"",children:"Primary fallback"}),aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})]})]})})]})},`${b.id}:${a.routeId}`)})}):(0,d.jsx)("div",{className:"mt-3 rounded-xl border border-dashed border-white/10 bg-white/[0.02] px-3 py-3 text-[11px] text-slate-500",children:"telegram"===(c=b.type)?"No Telegram groups found yet. Send one message in the target group, then refresh surface discovery.":"discord"===c?"No Discord surfaces were discovered yet. Send one message in the target server, then refresh surface discovery.":"No surfaces were discovered yet for this provider."})]}):null]},b.id)})}):(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-dashed border-white/10 bg-white/[0.02] px-3 py-3 text-sm text-slate-500",children:["No ",aO.label," surfaces are linked to this workspace yet."]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-white/10 bg-white/[0.025] p-3.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("p",{className:"min-w-0 truncate text-sm font-medium text-white",children:["Connect ",aO.label]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[aM.length," available"]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-slate-500",children:"Existing accounts"}),aM.length>0?aM.map(b=>{let c=aV(b.id),e=z(a,b.type,b.id);return(0,d.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-white/8 bg-white/[0.02] px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(L,{provider:b.type,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-white",children:b.name}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",C(e,aP.blocked)),children:B(e,aP.blocked)})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-500",children:[b.id," \xb7 ",A(e?.source??a.surfaceRuntime.source)]})]})]}),(0,d.jsx)(r.$,{type:"button",size:"sm",variant:c?"secondary":"default",className:"h-8 rounded-full px-3 text-[11px]",disabled:am||c,onClick:()=>void bb(b),children:c?"Linked":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect"]})})]},b.id)}):(0,d.jsxs)("div",{className:"rounded-xl border border-dashed border-white/10 bg-white/[0.02] px-3 py-3 text-sm text-slate-500",children:["No ",aO.label," accounts found."]})]}),(0,d.jsxs)("div",{className:"space-y-3 rounded-xl border border-white/8 bg-white/[0.02] p-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-white",children:"Provision"}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:aO.supportsProvisioning?"AgentOS":"OpenClaw"})]}),aO.supportsProvisioning?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Y,{label:"Surface name",htmlFor:"surface-name",children:(0,d.jsx)(O.p,{id:"surface-name",value:S(aI,"name"),onChange:a=>aJ(b=>({...b,name:a.target.value})),placeholder:`${aO.label} workspace surface`,className:"h-10 rounded-xl px-3"})}),aT.length>0?(0,d.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:aT.map(br)}):null,aU.length>0?(0,d.jsxs)("details",{className:"rounded-xl border border-white/8 bg-white/[0.015] p-3",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none text-xs font-medium uppercase tracking-[0.16em] text-slate-500",children:"Advanced settings"}),(0,d.jsx)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:aU.map(br)})]}):null,bm&&bn?(0,d.jsxs)("details",{className:"rounded-xl border border-cyan-300/15 bg-cyan-400/[0.04] p-3",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none text-xs font-medium uppercase tracking-[0.16em] text-cyan-100",children:"Config preview"}),(0,d.jsx)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:bn})}),"gmail"===aO.provider?(0,d.jsx)("p",{className:"mt-2 text-[11px] leading-5 text-cyan-100/70",children:"Includes Gmail hook enablement."}):null,(0,d.jsx)("pre",{className:"mt-3 max-h-52 overflow-auto rounded-xl border border-white/10 bg-slate-950/80 p-3 text-[11px] leading-5 text-slate-100",children:JSON.stringify(bm,null,2)})]}):null,(0,d.jsx)(Y,{label:"Primary agent",htmlFor:"surface-primary-agent",children:(0,d.jsxs)("select",{id:"surface-primary-agent",value:aq,onChange:a=>ar(a.target.value),className:"flex h-10 w-full rounded-xl border border-white/10 bg-white/5 px-3 py-2 text-sm text-white outline-none",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsx)(r.$,{type:"button",className:"h-10 rounded-full px-4 text-sm",disabled:!bp,onClick:()=>void bc(),children:am?"Provisioning...":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.A,{className:"mr-1.5 h-4 w-4"}),"Provision"]})})]}):(0,d.jsx)("div",{className:"rounded-xl border border-white/8 bg-white/[0.02] px-3 py-3 text-sm leading-5 text-slate-400",children:"Provisioning is not exposed for this OpenClaw provider in AgentOS. Existing OpenClaw accounts can still be attached, monitored, and routed from this workspace."})]})]})]})]})})]})}),(0,d.jsx)(N.Es,{className:"border-t border-white/10 px-4 py-3 sm:px-5",children:(0,d.jsx)(r.$,{variant:"secondary",onClick:()=>u(!1),children:"Close"})})]})}),(0,d.jsx)(N.lG,{open:!!aC,onOpenChange:a=>!a&&aD(null),children:(0,d.jsxs)(N.Cf,{className:"sm:max-w-2xl",children:[(0,d.jsxs)(N.c7,{children:[(0,d.jsx)(N.L3,{children:"Delete OpenClaw account"}),(0,d.jsx)(N.rr,{children:"This removes the account from every workspace overlay. For provider-backed chat accounts, AgentOS also asks OpenClaw to delete the underlying account when supported."})]}),(0,d.jsx)("div",{className:"rounded-[20px] border border-rose-500/25 bg-rose-500/[0.08] p-4",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-rose-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("p",{className:"text-sm font-medium text-rose-50",children:["Type ",aC?.name??"the account name"," to confirm deletion."]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-rose-100/80",children:"This action removes the account overlay everywhere and may delete the underlying OpenClaw provider account if the provider supports it."})]})]})}),(0,d.jsx)(Y,{label:`Type ${aC?.name??""} to confirm`,htmlFor:"delete-surface-confirm",children:(0,d.jsx)(O.p,{id:"delete-surface-confirm",value:aE,onChange:a=>aF(a.target.value),placeholder:aC?.name??""})}),(0,d.jsxs)(N.Es,{children:[(0,d.jsx)(r.$,{variant:"secondary",onClick:()=>{aD(null),aF("")},children:"Cancel"}),(0,d.jsx)(r.$,{variant:"destructive",disabled:!bl||am,onClick:()=>void bi(),children:am?"Deleting...":"Delete everywhere"})]})]})}),(0,d.jsx)(N.lG,{open:!!aG,onOpenChange:a=>{a||am||aH(null)},children:(0,d.jsxs)(N.Cf,{className:"sm:max-w-2xl",children:[(0,d.jsxs)(N.c7,{children:[(0,d.jsx)(N.L3,{children:"Apply OpenClaw binding repair"}),(0,d.jsx)(N.rr,{children:"Confirm the previewed repair before AgentOS writes a bounded OpenClaw config patch."})]}),(0,d.jsx)("div",{className:"rounded-[20px] border border-amber-300/25 bg-amber-400/[0.08] p-4",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-50",children:"Operator confirmation required"}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-100/80",children:"AgentOS will write a redacted backup snapshot before changing only the approved OpenClaw config paths shown here."})]})]})}),(0,d.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,d.jsx)(Z,{label:"Bindings added",value:String(aG?.addedBindingCount??0)}),(0,d.jsx)(Z,{label:"Bindings removed",value:String(aG?.removedBindingCount??0)})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-white/8 bg-white/[0.02] p-3",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-slate-500",children:"Preview audit"}),(0,d.jsx)("p",{className:"mt-1 break-all font-mono text-[11px] leading-5 text-slate-200",children:aG?.auditId??"unknown"})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-white/8 bg-white/[0.02] p-3",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-slate-500",children:"Approved config paths"}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:bq.length>0?bq.map(a=>(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:a},a)):(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:"no config changes"})})]}),(0,d.jsxs)(N.Es,{children:[(0,d.jsx)(r.$,{variant:"secondary",disabled:am,onClick:()=>aH(null),children:"Cancel"}),(0,d.jsx)(r.$,{disabled:am||!aG?.auditId,onClick:()=>void bk(),children:am?"Applying...":"Apply repair"})]})]})})]})}function Y({label:a,htmlFor:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(s.J,{htmlFor:b,className:"text-[10px] uppercase tracking-[0.16em] text-slate-400",children:a}),c]})}function Z({label:a,value:b}){return(0,d.jsxs)("div",{className:"rounded-xl border border-white/8 bg-white/[0.018] px-3 py-2",children:[(0,d.jsx)("p",{className:"truncate text-[9px] uppercase tracking-[0.14em] text-slate-500",children:a}),(0,d.jsx)("p",{className:"mt-1 truncate text-[11px] text-slate-200",children:b})]})}},43081:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d.l$,o:()=>d.oR});var d=c(57825)},45084:(a,b,c)=>{"use strict";c.d(b,{Iz:()=>i,XS:()=>g,fY:()=>j,mG:()=>f,rz:()=>k,z$:()=>h});var d=c(40299);function e(a){return Array.from(new Set(a.map(a=>a.trim()).filter(Boolean).filter(Boolean)))}function f(a,b){return a.channelRegistry.channels.filter(a=>a.workspaces.some(a=>a.workspaceId===b)).sort((a,b)=>{let c=(0,d.rY)(a.type).kind,e=(0,d.rY)(b.type).kind;return c!==e?c.localeCompare(e):a.type!==b.type?(0,d.rY)(a.type).label.localeCompare((0,d.rY)(b.type).label):a.name.localeCompare(b.name)})}function g(a,b,c){return f(a,b).filter(a=>a.primaryAgentId===c||a.workspaces.some(a=>a.workspaceId===b&&(a.agentIds.includes(c)||a.groupAssignments.some(a=>!1!==a.enabled&&a.agentId===c)))).map(a=>a.id)}function h(a,b){return{...a,channelRegistry:b}}function i(a,b){let c=a.channelAccounts.filter(a=>a.id!==b.id);return{...a,channelAccounts:[...c,b]}}function j(a,b){return{...a,channelAccounts:a.channelAccounts.filter(a=>a.id!==b)}}async function k(a){let b=e(a.currentChannelIds),c=e(a.nextChannelIds),d=c.filter(a=>!b.includes(a)),f=b.filter(a=>!c.includes(a));for(let b of d){let c=await fetch(`/api/workspaces/${encodeURIComponent(a.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"bind-agent",channelId:b,agentId:a.agentId,workspacePath:a.workspacePath})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error||"OpenClaw could not bind the channel.");d.registry&&a.onRegistryChange&&a.onRegistryChange(a=>h(a,d.registry))}for(let b of f){let c=await fetch(`/api/workspaces/${encodeURIComponent(a.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unbind-agent",channelId:b,agentId:a.agentId})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error||"OpenClaw could not unbind the channel.");d.registry&&a.onRegistryChange&&a.onRegistryChange(a=>h(a,d.registry))}}},45100:(a,b,c)=>{"use strict";c.d(b,{I:()=>l});var d=c(3814),e=c(5813),f=c(47221),g=c(98036),h=c(32905);let i={"openai-codex":{kind:"image",src:"/assets/provider-logos/openai.svg"},openai:{kind:"image",src:"/assets/provider-logos/openai.svg"},anthropic:{kind:"simple",icon:j("siAnthropic","Anthropic")},google:{kind:"simple",icon:j("siGooglegemini","Gemini")},gemini:{kind:"simple",icon:j("siGooglegemini","Gemini")},deepseek:{kind:"image",src:"/assets/provider-logos/deepseek.svg"},mistral:{kind:"simple",icon:j("siMistralai","Mistral")},openrouter:{kind:"simple",icon:j("siOpenrouter","OpenRouter")},ollama:{kind:"simple",icon:j("siOllama","Ollama")},xai:{kind:"image",src:"/assets/provider-logos/xai.svg"}};function j(a,b){let c=g[a];return c||{title:b,hex:"ffffff",path:"M0 0h24v24H0z"}}function k({provider:a,className:b}){let c=i[a.trim().toLowerCase()];return c?(0,d.jsx)("div",{className:(0,h.cn)("flex shrink-0 items-center justify-center overflow-hidden rounded-[16px] border border-black/5 bg-white/95 text-slate-900 shadow-[0_1px_1px_rgba(0,0,0,0.04)]",b),"aria-hidden":"true",children:"image"===c.kind?(0,d.jsx)(f.default,{src:c.src,alt:"",width:18,height:18,className:"h-[72%] w-[72%] select-none object-contain",unoptimized:!0}):(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[72%] w-[72%] select-none",fill:`#${c.icon.hex}`,children:(0,d.jsx)("path",{d:c.icon.path})})}):null}function l({descriptor:a,active:b,compact:c=!1,micro:f=!1,connected:g=!1,detail:i,onClick:j}){return(0,d.jsxs)("button",{type:"button",onClick:j,className:(0,h.cn)("group w-full rounded-[20px] border text-left transition-all",f?"rounded-[16px] p-1.5":c?"p-2.5":"p-3.5",b?f?"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_8px_16px_rgba(10,16,28,0.18)]":c?"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_12px_26px_rgba(10,16,28,0.22)]":"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_16px_36px_rgba(10,16,28,0.26)]":"border-white/10 bg-[linear-gradient(180deg,rgba(15,23,42,0.92),rgba(10,15,28,0.92))] hover:border-white/18 hover:bg-[linear-gradient(180deg,rgba(20,29,49,0.96),rgba(12,18,31,0.96))]"),children:[(0,d.jsxs)("div",{className:(0,h.cn)("flex items-start justify-between",f?"gap-1.5":"gap-2.5"),children:[(0,d.jsx)(k,{className:(0,h.cn)(f?"h-5 w-5":c?"h-7 w-7":"h-9 w-9",b?"ring-1 ring-cyan-300/20":""),provider:a.id}),(0,d.jsx)(e.E,{variant:g?"success":b?"default":"muted",className:(0,h.cn)("tracking-[0.12em]",f?"px-1 py-0.5 text-[7px]":c?"px-1.5 py-0.5 text-[9px]":"px-2 py-0.5 text-[10px]"),children:g?"Connected":b?"Selected":"Provider"})]}),(0,d.jsxs)("div",{className:(0,h.cn)(f?"mt-1.5":c?"mt-2":"mt-3.5"),children:[(0,d.jsx)("p",{className:(0,h.cn)("font-display text-white",f?"text-[0.72rem]":c?"text-[0.82rem]":"text-[0.94rem]"),children:a.label}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-slate-300",f?"line-clamp-2 text-[8px] leading-[0.85rem]":c?"text-[9px] leading-[0.95rem]":"text-[11px] leading-5"),children:a.description}),(0,d.jsx)("p",{className:(0,h.cn)("mt-2.5 uppercase tracking-[0.18em] text-slate-500",f?"line-clamp-1 text-[7px]":c?"text-[8px]":"text-[9px]"),children:i||a.helperText})]})]})}},45317:(a,b,c)=>{"use strict";c.d(b,{Bc:()=>h,ZI:()=>k,k$:()=>j,m_:()=>i});var d=c(3814),e=c(6247),f=c(20491),g=c(32905);let h=f.Kq,i=f.bL,j=f.l9,k=e.forwardRef(({className:a,sideOffset:b=6,children:c,...e},h)=>(0,d.jsx)(f.ZL,{children:(0,d.jsx)(f.UC,{ref:h,sideOffset:b,className:(0,g.cn)("relative z-[9999] overflow-hidden rounded-lg border border-border bg-popover px-4 py-3 text-xs text-popover-foreground shadow-panel backdrop-blur-xl",a),...e,children:(0,d.jsx)("div",{className:"relative z-10",children:c})})}));k.displayName=f.UC.displayName},45738:(a,b,c)=>{"use strict";c.d(b,{X:()=>k});var d=c(3814),e=c(5813),f=c(80990),g=c(90665),h=c(32905),i=c(45084),j=c(11917);function k({snapshot:a,workspaceId:b,channelIds:c,agentId:l,isSaving:m,onChange:n,surfaceTheme:o="dark"}){let p=(0,i.mG)(a,b),q=new Set(c),r="light"===o;return 0===p.length?(0,d.jsx)("div",{className:(0,h.cn)("rounded-[22px] border p-3.5",r?"border-[#e1d5c8] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03]"),children:(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,h.cn)("text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:"Surface participation"}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-[11px] leading-4",r?"text-[#7b6657]":"text-slate-400"),children:"Connect workspace surfaces first. Primary agents own the surface; selected agents assist behind the scenes."})]})})}):(0,d.jsxs)("div",{className:(0,h.cn)("rounded-[22px] border p-3.5",r?"border-[#e1d5c8] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,h.cn)("text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:"Surface participation"}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-[11px] leading-4",r?"text-[#7b6657]":"text-slate-400"),children:"Primary agents own the surface. Selected surfaces let this agent assist the owner internally."})]})}),m?(0,d.jsxs)("div",{className:(0,h.cn)("mt-3 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-[10px]",r?"border-[#c89e73]/25 bg-[#f5eadf] text-[#6b4f39]":"border-cyan-300/20 bg-cyan-400/[0.08] text-cyan-50"),children:[(0,d.jsx)(j.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,d.jsx)("span",{children:"Applying surface changes..."})]}):null,(0,d.jsx)("div",{className:"mt-4 space-y-3",children:p.map(i=>{var j;let k=q.has(i.id),o=!!(l&&i.primaryAgentId===l),p=(j=i.primaryAgentId)?(0,g.CK)(a.agents.find(a=>a.id===j)??{name:j}):null,s=i.workspaces.find(a=>a.workspaceId===b)??null,t=s?.agentIds.length??0;return(0,d.jsxs)("div",{className:(0,h.cn)("flex items-center justify-between gap-3 rounded-[18px] border px-3.5 py-2.5",k?r?"border-[#c89e73]/45 bg-[#fff7ef]":"border-cyan-300/40 bg-cyan-400/[0.08]":r?"border-[#e2d6ca] bg-white":"border-white/8 bg-white/[0.02]"),children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:(0,h.cn)("truncate text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:i.name}),(0,d.jsx)(e.E,{variant:"muted",className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:i.type}),o?(0,d.jsx)(e.E,{className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":""),children:"Owner"}):k?(0,d.jsx)(e.E,{className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":""),children:"Assistant"}):null,t>1?(0,d.jsx)(e.E,{variant:"muted",className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:"Team"}):null]}),(0,d.jsxs)("p",{className:(0,h.cn)("mt-1 truncate text-[10px]",r?"text-[#7f6958]":"text-slate-400"),children:[i.id,p?` \xb7 owner ${p}`:""]})]}),(0,d.jsx)(f.$,{type:"button",variant:k?"secondary":"default",size:"sm",className:(0,h.cn)("h-8 rounded-full px-2.5 text-[10px]",r&&!k?"shadow-none":""),disabled:!!m||k&&o,onClick:()=>n(q.has(i.id)?c.filter(a=>a!==i.id):[...c,i.id]),children:k?o?"Owner":"Remove":"Assist"})]},i.id)})})]})}},46856:(a,b,c)=>{"use strict";c.d(b,{o:()=>H});var d=c(3814),e=c(6247),f=c(11917),g=c(25393),h=c(67882),i=c(56815),j=c(23761),k=c(14847),l=c(32956),m=c(29075),n=c(73596),o=c(5813),p=c(80990),q=c(49444),r=c(60557),s=c(90665),t=c(32905);function u({models:a,selectedModelIds:b,search:c,onSearchChange:e,onToggleModel:g,onAddSelected:h,onOpenProviders:i,onLoadMore:j,visibleModelCount:v,isAdding:w,isLoading:x}){let y,z=(y=c.trim().toLowerCase())?a.filter(a=>`${a.name} ${a.id} ${a.provider} ${a.input} ${a.tags.join(" ")}`.toLowerCase().includes(y)):a,A=c.trim().length>0,B=A?z:z.slice(0,v),C=!A&&v<z.length,D=z.length-v,E=b.filter(b=>{let c=a.find(a=>a.id===b);return!!c&&!c.alreadyAdded}).length,F=new Set(a.map(a=>a.provider)).size,G=a.filter(a=>a.alreadyAdded).length;return(0,d.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(10,15,26,0.94),rgba(7,11,20,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"Catalog"}),(0,d.jsx)("p",{className:"mt-1 text-[10px] leading-[0.98rem] text-slate-400",children:"Browse the full OpenClaw catalog. Unavailable entries show which provider setup is missing."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[a.length," models"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[F," providers"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[G," added"]})]})]}),(0,d.jsxs)("div",{className:"relative mt-3",children:[(0,d.jsx)(k.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,d.jsx)(q.p,{value:c,onChange:a=>e(a.target.value),placeholder:"Search all discovered models",className:"h-8 pl-8 text-[11px]"})]}),x?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:[(0,d.jsx)(f.A,{className:"mx-auto mb-2 h-4 w-4 animate-spin text-slate-400"}),"Loading OpenClaw catalog..."]}):B.length>0?(0,d.jsxs)("div",{className:"mt-3 max-h-[min(38vh,340px)] space-y-1 overflow-y-auto pr-1",children:[B.map(a=>{var c,e;let f=b.includes(a.id),h=a.alreadyAdded,i=!h&&(!1===a.available||a.missing),j=(0,r.a3)(a.provider)?(0,r.W2)(a.provider):null,k=(c=a,e=j?.shortLabel??a.provider,c.missing?`${e} is configured, but this model is not available locally yet. You can still add it now, then finish setup in Providers.`:!1===c.available?`${e} needs a one-time setup before this model can be used. You can add it now, then connect it in Add Models > Providers.`:"");return(0,d.jsxs)("button",{type:"button",disabled:h,"aria-pressed":f,onClick:()=>{h||g(a.provider,a.id)},className:(0,t.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",h?"cursor-not-allowed border-white/8 bg-white/[0.02] opacity-70":f?"border-cyan-300/35 bg-cyan-300/[0.08]":i?"border-amber-300/20 bg-amber-300/[0.06] hover:border-amber-300/30 hover:bg-amber-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,d.jsx)("div",{className:(0,t.cn)("mt-0.5 flex h-[16px] w-[16px] shrink-0 items-center justify-center rounded-md border",h?"border-white/10 bg-white/[0.03] text-slate-500":f?"border-cyan-300/50 bg-cyan-300/15 text-cyan-100":i?"border-amber-300/30 bg-amber-300/10 text-amber-100":"border-white/12 bg-white/[0.03] text-transparent"),children:h?(0,d.jsx)(l.A,{className:"h-2 w-2"}):f?(0,d.jsx)(m.A,{className:"h-2 w-2"}):(0,d.jsx)(n.A,{className:"h-2 w-2"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:a.name}),(0,d.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:a.id}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,d.jsx)("span",{children:(0,r.S)(a.provider)}),a.input?(0,d.jsx)("span",{children:a.input}):null,a.contextWindow?(0,d.jsxs)("span",{children:[(0,s.FO)(a.contextWindow)," ctx"]}):null]}),i?(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-4 text-amber-100/85",children:k}):null]})]}),(0,d.jsx)("div",{className:"shrink-0",children:h?(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Already added"}):i?(0,d.jsx)(o.E,{variant:"warning",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Needs setup"}):a.recommended?(0,d.jsx)(o.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):a.local?(0,d.jsx)(o.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},a.id)}),C?(0,d.jsx)("div",{className:"pt-2",children:(0,d.jsxs)(p.$,{type:"button",variant:"secondary",onClick:j,className:"h-8 w-full rounded-full px-3 text-[10px]",children:["Load ",Math.min(5,D)," more"]})}):null]}):(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-dashed border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:[c.trim()?"No models matched this search.":"OpenClaw did not return any supported models yet.",(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(p.$,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3 text-[10px]",onClick:()=>i(),children:"Open providers"})})]}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/10 pt-3",children:[(0,d.jsx)("p",{className:"text-[9px] leading-4 text-slate-400",children:E>0?`${E} model${1===E?"":"s"} selected`:"Choose one or more models to add"}),(0,d.jsx)(p.$,{type:"button",onClick:h,disabled:0===E||w,className:"h-7 rounded-full px-2.5 text-[10px]",children:w?"Adding...":"Add selected models"})]})]})}var v=c(8910);function w(a,b){let c=b.trim().toLowerCase();return c?a.filter(a=>`${a.name} ${a.id} ${a.tags.join(" ")}`.toLowerCase().includes(c)):a}function x({provider:a,models:b,selectedModelIds:c,search:e,onSearchChange:f,onToggleModel:g,onAddSelected:h,isAdding:i}){let j=b.filter(a=>a.recommended),l=c.filter(a=>!b.find(b=>b.id===a)?.alreadyAdded).length,m="openrouter"===a,n=(0,r.W2)(a).searchPlaceholder,s=b.length>8||!!n,t=w(j,e),u=w(b,e);return(0,d.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(10,15,26,0.94),rgba(7,11,20,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"Select models to add"})}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[b.filter(a=>a.alreadyAdded).length," already added"]})]}),s?(0,d.jsxs)("div",{className:"relative mt-3",children:[(0,d.jsx)(k.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,d.jsx)(q.p,{value:e,onChange:a=>f(a.target.value),placeholder:n??"Search models",className:"h-8 pl-8 text-[11px]"})]}):null,m?(0,d.jsxs)(v.tU,{defaultValue:"recommended",className:"mt-3",children:[(0,d.jsxs)(v.j7,{className:"h-8 rounded-[16px] p-0.5",children:[(0,d.jsx)(v.Xi,{value:"recommended",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"Recommended"}),(0,d.jsx)(v.Xi,{value:"all",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"All models"})]}),(0,d.jsx)(v.av,{value:"recommended",children:(0,d.jsx)(y,{models:t,selectedModelIds:c,onToggleModel:g,emptyMessage:"No recommended matches. Switch to All models to browse the full catalog."})}),(0,d.jsx)(v.av,{value:"all",children:(0,d.jsx)(y,{models:u,selectedModelIds:c,onToggleModel:g,emptyMessage:"No models matched this search."})})]}):(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(y,{models:u,selectedModelIds:c,onToggleModel:g,emptyMessage:"No models matched this search."})}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/10 pt-3",children:[(0,d.jsx)("p",{className:"text-[9px] leading-4 text-slate-400",children:l>0?`${l} model${1===l?"":"s"} selected`:"Choose at least one model to add"}),(0,d.jsx)(p.$,{type:"button",onClick:h,disabled:0===l||i,className:"h-7 rounded-full px-2.5 text-[10px]",children:i?"Adding...":"Add selected models"})]})]})}function y({models:a,selectedModelIds:b,onToggleModel:c,emptyMessage:e}){return 0===a.length?(0,d.jsx)("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:e}):(0,d.jsx)("div",{className:"max-h-[min(28vh,220px)] space-y-1 overflow-y-auto pr-1",children:a.map(a=>{var e;let f=b.includes(a.id),g=!a.alreadyAdded&&(!1===a.available||a.missing);return(0,d.jsxs)("button",{type:"button",disabled:a.alreadyAdded,onClick:()=>c(a.id),className:(0,t.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",a.alreadyAdded?"cursor-not-allowed border-white/8 bg-white/[0.02] opacity-70":f?"border-cyan-300/35 bg-cyan-300/[0.08]":g?"border-amber-300/20 bg-amber-300/[0.06] hover:border-amber-300/30 hover:bg-amber-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,d.jsx)("div",{className:(0,t.cn)("mt-0.5 flex h-[16px] w-[16px] shrink-0 items-center justify-center rounded-md border",a.alreadyAdded?"border-white/10 bg-white/[0.03] text-slate-500":f?"border-cyan-300/50 bg-cyan-300/15 text-cyan-100":g?"border-amber-300/30 bg-amber-300/10 text-amber-100":"border-white/12 bg-white/[0.03] text-transparent"),children:a.alreadyAdded?(0,d.jsx)(l.A,{className:"h-2 w-2"}):f?(0,d.jsx)(m.A,{className:"h-2 w-2"}):(0,d.jsx)(n.A,{className:"h-2 w-2"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:a.name}),(0,d.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:a.id}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,d.jsx)("span",{children:a.input}),a.contextWindow?(0,d.jsxs)("span",{children:[Intl.NumberFormat().format(a.contextWindow)," ctx"]}):null,a.isFree?(0,d.jsx)("span",{children:"free"}):null]}),g?(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-4 text-amber-100/85",children:(e=a).missing?"This model is configured, but not available locally yet. You can still add it now, then finish setup in Providers.":!1===e.available?"This model needs provider setup before it will work. You can add it now, then connect the provider in Add Models > Providers.":""}):null]})]}),(0,d.jsx)("div",{className:"shrink-0",children:a.alreadyAdded?(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Already added"}):g?(0,d.jsx)(o.E,{variant:"warning",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Needs setup"}):a.recommended?(0,d.jsx)(o.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):a.local?(0,d.jsx)(o.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},a.id)})})}var z=c(45100),A=c(37674),B=c(89478),C=c(52188),D=c(58372),E=c(68885),F=c(43081);let G=()=>({flowState:"idle",connection:null,statusMessage:null,errorMessage:null,emptyState:null,manualCommand:null,docsUrl:null,models:[],selectedModelIds:[],apiKey:"",search:"",loaded:!1});function H({open:a,onOpenChange:b,snapshot:c,initialProvider:k=null,onSnapshotChange:l}){var m,n,s;let w,y,C,M,N=(0,r.d4)(k),[O,P]=(0,e.useState)("providers"),[Q,R]=(0,e.useState)(N),[S,T]=(0,e.useState)({}),[U,V]=(0,e.useState)(!1),[W,X]=(0,e.useState)(!1),[Y,Z]=(0,e.useState)(""),[$,_]=(0,e.useState)(5),[aa,ab]=(0,e.useState)([]),[ac,ad]=(0,e.useState)(!1),[ae,af]=(0,e.useState)(null);(0,e.useEffectEvent)(a=>{P("providers"),az(a)}),(0,e.useEffectEvent)(async()=>{ad(!0),af(null);try{let a=await fetch("/api/models/catalog"),b=await a.json().catch(()=>null);if(!a.ok||!b)throw Error(b?.error||"OpenClaw catalog could not be loaded.");ab(Array.isArray(b.models)?b.models:[])}catch(b){let a=b instanceof Error?b.message:"OpenClaw catalog could not be loaded.";ab([]),af(a),F.o.error("OpenClaw catalog could not be loaded.",{description:a})}finally{ad(!1)}});let ag=(0,r.a3)(Q)?Q:null,ah=ag?J(S[ag]):G(),ai=ag?(0,r.W2)(ag):null,aj=ag?L(c,S,ag):null,ak=!!(ag&&ai)&&("discovery-loading"===ah.flowState||"connecting"===ah.flowState&&!ah.manualCommand||ah.statusMessage?.startsWith("Checking ")===!0&&!aj?.connected),al="discovery-loading"===ah.flowState?`Discovering ${ai?.shortLabel??"provider"} models...`:"connecting"===ah.flowState?ah.statusMessage||`Connecting ${ai?.shortLabel??"provider"}...`:ah.statusMessage||`Checking ${ai?.shortLabel??"provider"}...`,am="discovery-loading"===ah.flowState?"Pulling the provider catalog into AgentOS.":"connecting"===ah.flowState?"Preparing the provider connection.":"Checking provider status before discovery.",an=!!(ag&&ai),ao="discovery-loading"===ah.flowState,ap=ah.models.length>0?"Refresh discovery":"Discover models",aq=ao?"Discovering...":ap,ar=aj?.connected?"The provider is connected. Pull the available models into this workspace before choosing one.":ai?.connectKind==="oauth"?"Use your account login first, then pull the available models into this workspace.":"Connect the provider first, then pull the available models into this workspace.",as=!!(ah.errorMessage&&ah.manualCommand&&(/gateway/i.test(ah.errorMessage)||/\bgateway\s+status\b/i.test(ah.manualCommand))),at=(0,e.useMemo)(()=>{let a=new Set(c.models.map(a=>a.id));return aa.map(b=>({...b,alreadyAdded:a.has(b.id)})).sort((a,b)=>{let c=a.alreadyAdded;if(c!==b.alreadyAdded)return c?1:-1;let d=a.provider.localeCompare(b.provider);if(0!==d)return d;let e=!K(a);if(!K(b)!==e)return e?1:-1;let f=Number(a.recommended)+Number(a.local),g=Number(b.recommended)+Number(b.local);if(f!==g)return g-f;let h=a.name.localeCompare(b.name);return 0!==h?h:a.id.localeCompare(b.id)})},[aa,c.models]),au=(0,e.useMemo)(()=>Object.values(S).flatMap(a=>a?.selectedModelIds??[]),[S]),av=(0,e.useMemo)(()=>new Map(at.map(a=>[a.id,a])),[at]),aw=(0,e.useMemo)(()=>new Set(at.map(a=>a.provider)).size,[at]),ax=(0,e.useMemo)(()=>at.filter(a=>a.alreadyAdded).length,[at]),ay=(0,e.useMemo)(()=>{let a=new Set(au),b=new Map;for(let c of at){let d=c.provider;if(!a.has(c.id)||c.alreadyAdded)continue;let e=b.get(d)??[];e.push(c.id),b.set(d,e)}return b},[at,au]);async function az(a){R(a),P("providers");let b=J(S[a]);if(b.loaded&&b.models.length>0)return;let c=await aA(a);"ollama"===a&&c?.connection.connected&&await aC(a,!0)}async function aA(a){let b=(0,B.oZ)(a);aI(a,{flowState:"idle",errorMessage:null});try{let c=await b.getConnectionStatus(),d=J(S[a]);return aK(a,c,c.emptyState?"discovery-empty":"idle",{models:d.loaded&&d.models.length>0?d.models:c.models}),c.snapshot&&l(c.snapshot),c}catch(b){return aI(a,{flowState:"auth-error",errorMessage:b instanceof Error?b.message:"Provider status could not be loaded.",loaded:!0}),null}}async function aB(a,b){let c=(0,B.oZ)(a),d=J(S[a]);aI(a,{flowState:"connecting",errorMessage:null,statusMessage:"openai-codex"===a?b?.force?"Refreshing Codex app-server setup...":"Checking Codex app-server setup...":`Connecting ${(0,r.W2)(a).shortLabel}...`});try{let e=await c.connect({apiKey:d.apiKey,force:b?.force});aK(a,e,"openai-codex"===a?"connecting":e.models.length?"discovery-success":"idle",{apiKey:""}),e.snapshot&&l(e.snapshot)}catch(b){aI(a,{flowState:"auth-error",errorMessage:b instanceof Error?b.message:"Provider connection failed."})}}async function aC(a,b=!1){let c=(0,B.oZ)(a),d=J(S[a]);if(b||"discovery-loading"!==d.flowState){aI(a,{flowState:"discovery-loading",errorMessage:null,statusMessage:"ollama"===a?"Checking the local Ollama runtime...":"Discovering available models..."});try{let b=await c.discoverModels();return aK(a,b,b.models.length>0?"discovery-success":b.emptyState?"discovery-empty":"idle"),b.snapshot&&l(b.snapshot),b}catch(c){let b=aJ(c);return aI(a,{flowState:"auth-error",errorMessage:c instanceof Error?c.message:"Model discovery failed.",manualCommand:b?.manualCommand??null,docsUrl:b?.docsUrl??null}),null}}}async function aD(a,b){let c=(0,B.oZ)(a),d=J(S[a]),e=(b?.selectedModelIds??d.selectedModelIds).filter(a=>{let b=av.get(a)??d.models.find(b=>b.id===a);return!!b&&!b.alreadyAdded});if(0===e.length)return!1;aI(a,{flowState:"connecting",errorMessage:null,statusMessage:"Adding selected models..."});try{let f=await c.addModels(e);return aK(a,f,"add-success",{selectedModelIds:b?.selectedModelIds?d.selectedModelIds.filter(a=>!e.includes(a)):[]}),f.snapshot&&l(f.snapshot),b?.silent||F.o.success("Models added.",{description:f.message}),!0}catch(c){let b=aJ(c);return aI(a,{flowState:"add-error",errorMessage:c instanceof Error?c.message:"Models could not be added.",connection:b?.connection??d.connection,models:b?.models??d.models,manualCommand:b?.manualCommand??null,docsUrl:b?.docsUrl??null}),!1}}async function aE(){let a=[...ay.keys()];if(0!==a.length){X(!0);try{let b=0;for(let[a,c]of ay.entries())((0,r.a3)(a)?await aD(a,{silent:!0,selectedModelIds:c}):await aF(a,c))&&(b+=c.length);b>0?F.o.success("Models added.",{description:`Added ${b} model${1===b?"":"s"} from ${a.length} provider${1===a.length?"":"s"}.`}):F.o.error("Models could not be added.",{description:"Select a different catalog entry or open the Providers tab and try again."})}catch(a){F.o.error("Models could not be added.",{description:a instanceof Error?a.message:"Select a different catalog entry or open the Providers tab and try again."})}finally{X(!1)}}}async function aF(a,b){let c=b.filter(a=>{let b=av.get(a);return b&&!b.alreadyAdded});if(0===c.length)return!1;let d=await fetch("/api/models/catalog",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,modelIds:c})}),e=await d.json().catch(()=>null);if(!d.ok||!e)throw Error(e?.error||e?.message||"Catalog models could not be added.");return e.snapshot&&l(e.snapshot),T(a=>Object.fromEntries(Object.entries(a).map(([a,b])=>[a,b?{...b,selectedModelIds:b.selectedModelIds.filter(a=>!c.includes(a))}:b]))),!0}async function aG(a){try{V(!0);let b=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:a})}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||"Terminal could not be opened.");F.o.success("Terminal opened.",{description:"Finish the provider login there, then return here to discover models."})}catch(a){F.o.error("Unable to open Terminal.",{description:a instanceof Error?a.message:"Unknown terminal error."})}finally{V(!1)}}async function aH(a){try{await navigator.clipboard.writeText(a),F.o.success("Copied.",{description:"Command copied to your clipboard."})}catch{F.o.error("Copy failed.",{description:"Clipboard access is not available."})}}function aI(a,b){T(c=>({...c,[a]:{...J(c[a]),...b}}))}function aJ(a){return a instanceof B.jZ?a.result:null}function aK(a,b,c,d){aI(a,{flowState:c,connection:b.connection,statusMessage:b.message,errorMessage:null,emptyState:b.emptyState??null,manualCommand:b.manualCommand??null,docsUrl:b.docsUrl??null,models:b.models,loaded:!0,...d})}return(0,d.jsx)(A.lG,{open:a,onOpenChange:b,children:(0,d.jsxs)(A.Cf,{className:"flex h-[80dvh] max-h-[80dvh] w-[calc(100vw-16px)] max-w-[760px] flex-col gap-0 overflow-hidden p-0 sm:h-[min(80dvh,700px)] sm:max-h-[min(80dvh,700px)] sm:w-[min(760px,calc(100vw-40px))]",children:[(0,d.jsxs)(A.c7,{className:"shrink-0 border-b border-white/10 bg-[linear-gradient(180deg,rgba(12,18,31,0.96),rgba(9,13,24,0.98))] px-4 py-3.5 pr-10",children:[(0,d.jsx)(A.L3,{className:"text-[1.05rem]",children:"Add Models"}),(0,d.jsx)(A.rr,{className:"max-w-[560px] text-[11px] leading-[1rem] text-slate-400",children:"Connect or refresh providers first, then browse the catalog when you want to add models in bulk."})]}),(0,d.jsxs)(v.tU,{value:O,onValueChange:a=>P(a),className:"min-h-0 flex flex-1 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 border-b border-white/10 px-4 py-3",children:(0,d.jsxs)(v.j7,{className:"h-8 rounded-[16px] p-0.5",children:[(0,d.jsx)(v.Xi,{value:"providers",className:"rounded-[13px] px-2.5 py-1 text-[10px]",children:"Providers"}),(0,d.jsx)(v.Xi,{value:"catalog",className:"rounded-[13px] px-2.5 py-1 text-[10px]",children:"Catalog"})]})}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[(0,d.jsx)(v.av,{value:"providers",className:"!mt-0 m-0 h-full",children:(0,d.jsxs)("div",{className:"space-y-4 px-3 py-3 sm:px-4 sm:py-4",children:[(0,d.jsxs)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(13,20,34,0.94),rgba(9,13,24,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"All providers"}),(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-[0.95rem] text-slate-400",children:"Connect or refresh a provider, then return to the catalog when you want to add models in one pass."})]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[r.y8.length," total"]})]}),(0,d.jsxs)("div",{className:"relative mt-2.5",children:[(0,d.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-gradient-to-r from-[rgba(13,20,34,0.96)] to-transparent"}),(0,d.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-gradient-to-l from-[rgba(13,20,34,0.96)] to-transparent"}),(0,d.jsx)("div",{className:"-mx-1 overflow-x-auto overscroll-x-contain pb-1",children:(0,d.jsx)("div",{className:"flex min-w-max gap-2.5 px-1",children:r.y8.map(a=>(0,d.jsx)("div",{className:"w-[236px] shrink-0 snap-start sm:w-[244px]",children:(0,d.jsx)(z.I,{descriptor:a,active:ag===a.id,compact:!0,connected:L(c,S,a.id).connected,detail:L(c,S,a.id).detail,onClick:()=>{az(a.id)}})},a.id))})}),(0,d.jsx)("div",{className:"pointer-events-none absolute bottom-1.5 right-3 z-10 rounded-full border border-white/10 bg-slate-950/70 px-2 py-0.5 text-[8px] uppercase tracking-[0.14em] text-slate-400",children:"Scroll ->"})]})]}),(0,d.jsx)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:ag&&ai?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:ai.label})}),(0,d.jsx)(o.E,{variant:aj?.connected?"success":"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:aj?.connected?"Connected":"Not connected"})]}),(0,d.jsx)("div",{className:"mt-3 flex flex-wrap gap-1",children:(m=ag,n=ah,s=aj,w="ollama"===m?!!(s?.connected||n.emptyState):!!(s?.connected||n.manualCommand),y=n.models.length>0||!!n.emptyState,C=n.selectedModelIds.length>0,M="add-success"===n.flowState,[{label:"Choose provider",status:"done"},{label:"ollama"===m?"Local check":"Connect",status:"connecting"!==n.flowState||w?w?"done":"pending":"active"},{label:"Discover",status:"discovery-loading"===n.flowState?"active":y?"done":"pending"},{label:"Select",status:M?"done":C?"active":"pending"},{label:"Add",status:M?"done":"add-error"===n.flowState?"active":"pending"}]).map(a=>(0,d.jsxs)("div",{className:(0,t.cn)("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[9px] uppercase tracking-[0.14em]","done"===a.status?"border-emerald-300/20 bg-emerald-300/10 text-emerald-100":"active"===a.status?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/10 bg-white/[0.03] text-slate-500"),children:[(0,d.jsx)("span",{className:(0,t.cn)("h-1.5 w-1.5 rounded-full","done"===a.status?"bg-emerald-300":"active"===a.status?"bg-cyan-300":"bg-slate-600")}),a.label]},a.label))}),ah.statusMessage&&!ak?(0,d.jsx)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-2",children:(0,d.jsx)("p",{className:"text-[11px] text-slate-200",children:ah.statusMessage})}):null,ah.errorMessage?(0,d.jsx)("div",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/[0.08] px-3 py-2 text-[11px] text-rose-100",children:ah.errorMessage}):null,as?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-amber-300/20 bg-amber-300/[0.08] px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-amber-50",children:"Gateway recovery"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-amber-100/78",children:"Automatic Gateway auth repair did not finish. Inspect Gateway status, then retry adding models."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,D.T)(ah.manualCommand)?(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aG(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null,(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aH(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null,ak?(0,d.jsx)("div",{className:"mt-4 flex min-h-[260px] items-center justify-center overflow-hidden rounded-[24px] border border-cyan-300/20 bg-[radial-gradient(circle_at_top,rgba(34,211,238,0.16),rgba(8,15,28,0.98)_70%)] px-4 py-10 text-center shadow-[0_22px_52px_rgba(7,11,20,0.32)]",children:(0,d.jsxs)("div",{className:"relative flex max-w-[340px] flex-col items-center",children:[(0,d.jsx)("div",{className:"absolute inset-x-8 top-8 h-px bg-gradient-to-r from-transparent via-cyan-200/70 to-transparent blur-sm animate-pulse"}),(0,d.jsx)("div",{className:"absolute inset-x-8 bottom-8 h-px bg-gradient-to-r from-transparent via-cyan-200/30 to-transparent blur-sm animate-pulse [animation-delay:180ms]"}),(0,d.jsx)("div",{className:"absolute left-8 top-8 h-24 w-24 rounded-full border border-cyan-300/15 bg-cyan-300/[0.04] blur-[1px] animate-pulse"}),(0,d.jsx)("div",{className:"absolute right-10 top-14 h-16 w-16 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:120ms]"}),(0,d.jsx)("div",{className:"absolute bottom-10 left-1/2 h-20 w-20 -translate-x-1/2 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:240ms]"}),(0,d.jsx)("div",{className:"relative mb-4 flex h-16 w-16 items-center justify-center rounded-full border border-cyan-300/20 bg-cyan-300/[0.08] shadow-[0_0_0_8px_rgba(34,211,238,0.05)]",children:(0,d.jsx)(f.A,{className:"h-8 w-8 animate-spin text-cyan-200"})}),(0,d.jsx)("p",{className:"font-display text-[1.1rem] leading-[1.2rem] tracking-[0.01em] text-white",children:al}),(0,d.jsx)("p",{className:"mt-2 max-w-[280px] text-[11px] leading-[1rem] text-slate-400",children:am}),(0,d.jsxs)("div",{className:"mt-4 flex gap-1.5",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/90"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/60 [animation-delay:120ms]"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/30 [animation-delay:240ms]"})]})]})}):(0,d.jsxs)(d.Fragment,{children:["openai-codex"===ag?(0,d.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Use Codex app-server"}),(0,d.jsxs)("p",{className:"mt-1 max-w-[500px] text-[10px] leading-[0.98rem] text-slate-400",children:["OpenClaw ",E.L," uses the Codex app-server plugin for ChatGPT-backed models."]})]}),(0,d.jsx)(p.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState&&!ah.manualCommand,onClick:()=>{aB(ag)},children:"connecting"!==ah.flowState||ah.manualCommand?aj?.connected?"Refresh setup":"Connect ChatGPT":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]})}),(0,d.jsx)(p.$,{type:"button",variant:"ghost",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState&&!ah.manualCommand,onClick:()=>{aB(ag,{force:!0})},children:"Refresh app-server"})]}),ah.manualCommand?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish setup in Terminal"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, complete the Codex app-server setup, then return here and check discovery."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aG(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aH(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aC(ag)},children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null]}):null,"apiKey"===ai.connectKind?(0,d.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("label",{className:"block text-[9px] uppercase tracking-[0.16em] text-slate-500",children:"API key"}),(0,d.jsx)(q.p,{type:"password",value:ah.apiKey,onChange:a=>aI(ag,{apiKey:a.target.value}),placeholder:"openrouter"===ag?"sk-or-v1-...":"Paste API key",className:"mt-1.5 h-8 text-[11px]"})]}),(0,d.jsx)(p.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState||!ah.apiKey.trim(),onClick:()=>{aB(ag)},children:"connecting"===ah.flowState?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]}):`Connect ${ai.shortLabel}`})]}),ah.manualCommand?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish setup in Terminal"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, paste the provider API key there, then return here and check discovery."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aG(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aH(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aC(ag)},children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null]}):null,an?(0,d.jsx)("div",{className:"mt-4 rounded-[24px] border border-cyan-300/20 bg-[linear-gradient(180deg,rgba(17,28,47,0.98),rgba(10,16,28,0.98))] p-4 shadow-[0_18px_42px_rgba(7,11,20,0.28)]",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"font-display text-[0.92rem] text-white",children:ao?"Discovering models...":ap}),(0,d.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[1rem] text-slate-400",children:ao?"OpenClaw is pulling the provider catalog into this workspace.":ar})]}),(0,d.jsxs)("div",{className:"flex shrink-0 flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"default",className:"h-11 rounded-full px-5 text-[12px] font-medium",disabled:ao,onClick:()=>{aC(ag)},children:ao?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Discovering..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-2 h-4 w-4"}),aq]})}),(0,d.jsx)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 rounded-full px-4 text-[10px]",onClick:()=>{aA(ag)},children:"Refresh status"})]})]})}):null,ah.emptyState?(0,d.jsx)(I,{emptyState:ah.emptyState,onCopyCommand:a=>{aH(a)}}):null,ah.models.length>0?(0,d.jsx)("div",{className:"mt-5",children:(0,d.jsx)(x,{provider:ag,models:ah.models,selectedModelIds:ah.selectedModelIds,search:ah.search,onSearchChange:a=>aI(ag,{search:a}),onToggleModel:a=>{aI(ag,{selectedModelIds:ah.selectedModelIds.includes(a)?ah.selectedModelIds.filter(b=>b!==a):[...ah.selectedModelIds,a]})},onAddSelected:()=>{aD(ag)},isAdding:"connecting"===ah.flowState&&"Adding selected models..."===ah.statusMessage})}):null,"add-success"===ah.flowState?(0,d.jsxs)("div",{className:"mt-3 flex items-center gap-2.5 rounded-[16px] border border-emerald-300/20 bg-emerald-300/[0.08] px-3 py-2",children:[(0,d.jsx)(j.A,{className:"h-3.5 w-3.5 text-emerald-200"}),(0,d.jsx)("p",{className:"text-[11px] text-emerald-50",children:ah.statusMessage||"Models were added successfully."})]}):null,ah.docsUrl?(0,d.jsx)("a",{href:ah.docsUrl,target:"_blank",rel:"noreferrer",className:"mt-3 inline-flex text-[10px] text-slate-300 underline underline-offset-4",children:"OpenClaw model docs"}):null]})]}):(0,d.jsx)("div",{className:"flex min-h-[180px] items-center justify-center rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-6 text-center",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Choose a provider to begin"}),(0,d.jsx)("p",{className:"mt-1.5 max-w-[360px] text-[11px] leading-[0.98rem] text-slate-400",children:"Start with ChatGPT, OpenRouter, Gemini, DeepSeek, Mistral, or Ollama Local. The flow will guide you through connect, discovery, selection, and add."})]})})})]})}),(0,d.jsx)(v.av,{value:"catalog",className:"!mt-0 m-0 h-full",children:(0,d.jsxs)("div",{className:"space-y-4 px-3 py-3 sm:px-4 sm:py-4",children:[(0,d.jsx)("div",{className:"rounded-[20px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"OpenClaw catalog"}),(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-[0.95rem] text-slate-400",children:"Search the full OpenClaw model catalog, then load five more whenever you want to extend the list."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[at.length," models"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[aw," providers"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[ax," added"]})]})]})}),ae?(0,d.jsx)("div",{className:"rounded-[18px] border border-rose-400/20 bg-rose-400/[0.08] px-4 py-3 text-[11px] text-rose-100",children:ae}):null,(0,d.jsx)(u,{models:at,selectedModelIds:au,search:Y,onSearchChange:Z,onToggleModel:(a,b)=>{let c=J(S[a]);aI(a,{selectedModelIds:c.selectedModelIds.includes(b)?c.selectedModelIds.filter(a=>a!==b):[...c.selectedModelIds,b]})},onAddSelected:()=>{aE()},onOpenProviders:a=>{P("providers"),(0,r.a3)(a)&&az(a)},onLoadMore:()=>_(a=>a+5),visibleModelCount:$,isAdding:W,isLoading:ac&&0===at.length}),ac||0!==at.length||ae?null:(0,d.jsx)("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-5 text-center text-[11px] text-slate-400",children:"OpenClaw did not return any supported models yet. Check your installation or refresh providers."})]})})]})]})]})})}function I({emptyState:a,onCopyCommand:b}){return(0,d.jsxs)("div",{className:"mt-3 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:a.title}),(0,d.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[0.98rem] text-slate-400",children:a.description}),a.commands?.length?(0,d.jsx)("div",{className:"mt-3 space-y-1.5",children:a.commands.map(a=>(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:[(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:a}),(0,d.jsxs)(p.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>b(a),children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy"]})]},a))}):null]})}function J(a){return a||G()}function K(a){return!a.missing&&!1!==a.available}function L(a,b,c){let d=b[c]?.connection;if(d)return d;let e=a.diagnostics.modelReadiness.authProviders.find(a=>a.provider===c),f=a.models.filter(a=>{var b,d,e;return b=c,d=a.id,e=a.provider,(0,C.Pr)(b,d,e)}).length;if("ollama"===c)return{provider:c,connected:f>0,canConnect:!0,needsTerminal:!1,detail:f>0?`${f} model${1===f?"":"s"} already visible in AgentOS.`:"Detect local models from this machine."};let g=!!e?.connected;return{provider:c,connected:g,canConnect:!0,needsTerminal:"openai-codex"===c,detail:g?e?.detail||(0,r.W2)(c).helperText:f>0?`${f} model${1===f?"":"s"} are already saved in AgentOS. Connect ${(0,r.W2)(c).shortLabel} to use them.`:(0,r.W2)(c).helperText}}},49444:(a,b,c)=>{"use strict";c.d(b,{p:()=>g});var d=c(3814),e=c(6247),f=c(32905);let g=e.forwardRef(({className:a,type:b,...c},e)=>(0,d.jsx)("input",{type:b,className:(0,f.cn)("flex h-11 w-full rounded-lg border border-input bg-card px-4 py-2 text-sm text-foreground placeholder:text-muted-foreground shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",a),ref:e,...c}));g.displayName="Input"},52188:(a,b,c)=>{"use strict";function d(a,b,c){let d=c||b.split("/",1)[0]||"";return"openai-codex"===a?"codex"===d||"openai-codex"===d||g(b):d===a}function e(a){let b=a.trim(),c=/^(?:codex|openai-codex)\/(.+)$/i.exec(b);return c?`openai/${c[1]}`:b}function f(a,b){let c=e(a);return"openai-codex"===b||/^codex\//i.test(a)||/^openai-codex\//i.test(a)||g(c)?`openai-codex:${c.toLowerCase()}`:`${b}:${c.toLowerCase()}`}function g(a){return/^openai\/(?:gpt-5\.5|gpt-5\.4-mini)$/i.test(a)||/^openai\/.*codex/i.test(a)}c.d(b,{JN:()=>e,Pr:()=>d,gt:()=>f,jw:()=>g}),c(60557)},52846:(a,b,c)=>{"use strict";c.d(b,{J:()=>k});var d=c(3814),e=c(6247),f=c(98036),g=c(49113);let h={"product-hunt":"siProducthunt","producthunt.com":"siProducthunt",gmail:"siGmail","mail.google.com":"siGmail","accounts.google.com":"siGmail","x-twitter":"siX","x.com":"siX","twitter.com":"siX",github:"siGithub","github.com":"siGithub",discord:"siDiscord","discord.com":"siDiscord",telegram:"siTelegram","web.telegram.org":"siTelegram"};function i(a){return a?.trim().toLowerCase()||null}var j=c(32905);function k({serviceId:a,serviceName:b,primaryDomain:c,className:m}){let n=(0,e.useMemo)(()=>{let d;return(d=function(a){for(let b of[a.primaryDomain,a.serviceId,a.serviceName]){let a=function(a){let b=a?.trim().toLowerCase();if(!b)return null;let c=b.includes("://")?b:`https://${b}`;try{let a=new URL(c).hostname.replace(/^www\./,"");if(!a||"localhost"===a||!a.includes(".")||!/^[a-z0-9.-]+$/.test(a))return null;return a}catch{return null}}(b);if(a)return a}return null}({serviceId:a,serviceName:b,primaryDomain:c}))?[`https://${d}/favicon.ico`,`https://www.google.com/s2/favicons?domain=${encodeURIComponent(d)}&sz=64`]:[]},[c,a,b]),o=n.join("\0"),p=function(a){for(let b of[i(a.serviceId),i(a.primaryDomain),i(a.serviceName)].filter(a=>!!a)){let a=h[b];if(a)return a;let c=b.replace(/^www\./,"");if(h[c])return h[c]}return null}({serviceId:a,primaryDomain:c,serviceName:b}),q=p?f[p]:void 0,r=(b||c||a||"Account").trim().slice(0,1).toUpperCase(),s=q?(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[58%] w-[58%] select-none",fill:`#${q.hex}`,children:(0,d.jsx)("path",{d:q.path})}):r?(0,d.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/88",children:r}):(0,d.jsx)(g.A,{className:"h-[54%] w-[54%] text-white/88"});return(0,d.jsx)("div",{className:(0,j.cn)("flex items-center justify-center overflow-hidden rounded-full border border-white/12 bg-slate-950/72 text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)] backdrop-blur-xl",m),"aria-hidden":"true",children:n.length>0?(0,d.jsx)(l,{sources:n,fallback:s},o):s})}function l({sources:a,fallback:b}){let[c,f]=(0,e.useState)(0),g=a[c];return g?(0,d.jsx)("img",{src:g,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",className:"h-[70%] w-[70%] select-none rounded-[4px] object-contain",onError:()=>f(a=>a+1)}):b}},58372:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=a?.trim();if(!b)return[];let c=[],d=0,e=0,f="unquoted";for(;e<b.length;){let a=b[e],g=b[e+1];if("single"===f){"'"===a&&(f="unquoted"),e+=1;continue}if("double"===f){if("\\"===a){e+=2;continue}'"'===a&&(f="unquoted"),e+=1;continue}if("'"===a){f="single",e+=1;continue}if('"'===a){f="double",e+=1;continue}if("&"===a&&"&"===g){let a=b.slice(d,e).trim();if(!a)return[];c.push(a),e+=2,d=e;continue}if(";"===a||"|"===a||"\n"===a||"\r"===a||"`"===a||"<"===a||">"===a||"$"===a&&"("===g)return[];e+=1}let g=b.slice(d).trim();return g?(c.push(g),c):[]}(a);return 0!==b.length&&b.every(a=>{var b;return!!("openclaw"===(b=(function(a){let b=a?.trim();if(!b)return null;let c=0;for(;c<b.length&&/\s/.test(b[c]);)c+=1;if(c>=b.length)return null;let d="",e="unquoted";for(;c<b.length;){let a=b[c];if("unquoted"===e){if(/\s/.test(a))break;if("'"===a){e="single",c+=1;continue}if('"'===a){e="double",c+=1;continue}if("\\"===a&&c+1<b.length){d+=b[c+1],c+=2;continue}d+=a,c+=1;continue}if("single"===e){if("'"===a){e="unquoted",c+=1;continue}d+=a,c+=1;continue}if('"'===a){e="unquoted",c+=1;continue}if("\\"===a&&c+1<b.length){d+=b[c+1],c+=2;continue}d+=a,c+=1}return d})(a)?.toLowerCase())||b?.endsWith("/openclaw")||b?.endsWith("\\openclaw"))})}c.d(b,{T:()=>d})},59056:(a,b,c)=>{"use strict";c.d(b,{v:()=>e});var d=c(6247);function e(a){let[b,c]=(0,d.useState)(a),[e,f]=(0,d.useState)("connecting"),g=async(a={})=>{let b=a.force?"/api/snapshot?force=true":"/api/snapshot",e=await fetch(b,{cache:"no-store"}),g=await e.json();return(0,d.startTransition)(()=>{c(a=>!function(a,b){let c=a.revision??0,d=b.revision??0;if(c!==d)return c>d;if("live"===b.mode&&"fallback"===a.mode)return!1;if("fallback"===b.mode&&"live"===a.mode)return!0;let e=Date.parse(a.generatedAt),f=Date.parse(b.generatedAt);return!!(Number.isNaN(e)||Number.isNaN(f))||e>=f}(g,a)?a:g),f("live")}),g};return{snapshot:b,connectionState:e,refresh:async()=>{await g()},refreshSnapshot:g,setSnapshot:c}}},60251:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,83316,23)),Promise.resolve().then(c.t.bind(c,64943,23)),Promise.resolve().then(c.t.bind(c,87907,23)),Promise.resolve().then(c.t.bind(c,966,23)),Promise.resolve().then(c.t.bind(c,19698,23)),Promise.resolve().then(c.t.bind(c,12582,23)),Promise.resolve().then(c.t.bind(c,53635,23)),Promise.resolve().then(c.t.bind(c,4246,23))},60557:(a,b,c)=>{"use strict";c.d(b,{S:()=>i,W2:()=>f,a3:()=>g,d4:()=>h,y8:()=>e});var d=c(68885);let e=[{id:"openai-codex",label:"ChatGPT",shortLabel:"ChatGPT",description:"Use OpenClaw's Codex app-server provider and pull in Codex-ready models.",category:"primary",connectKind:"oauth",accent:"from-[#d8f5eb] via-[#ebfbf5] to-white",helperText:`OpenClaw ${d.L} uses the Codex app-server plugin for this route.`},{id:"openrouter",label:"OpenRouter",shortLabel:"OpenRouter",description:"Add an API key, discover the full catalog, and curate the models you want.",category:"primary",connectKind:"apiKey",accent:"from-[#fff2d7] via-[#fff7ea] to-white",helperText:"Best for broad model access and curated remote routes.",searchPlaceholder:"Search OpenRouter models"},{id:"ollama",label:"Ollama Local",shortLabel:"Ollama",description:"Discover models already available on this machine and add them instantly.",category:"primary",connectKind:"local",accent:"from-[#deefff] via-[#f2f8ff] to-white",helperText:"Local-first discovery with helpful pull commands when empty."},{id:"anthropic",label:"Anthropic",shortLabel:"Anthropic",description:"Paste an API key and add Claude models through the same flow.",category:"other",connectKind:"apiKey",accent:"from-[#efe9ff] via-[#f7f3ff] to-white",helperText:"Simple API key connection."},{id:"openai",label:"OpenAI API",shortLabel:"OpenAI",description:"Connect a standard OpenAI API key for direct GPT model access.",category:"other",connectKind:"apiKey",accent:"from-[#e8f8e8] via-[#f4fbf4] to-white",helperText:"Use this for API-key-based OpenAI routing."},{id:"google",label:"Gemini",shortLabel:"Gemini",description:"Add a Gemini API key, discover Google models, and pick the routes you want.",category:"other",connectKind:"apiKey",accent:"from-[#e6f7ff] via-[#f4fbff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Gemini models"},{id:"deepseek",label:"DeepSeek",shortLabel:"DeepSeek",description:"Add a DeepSeek API key, discover the catalog, and add the models you need.",category:"other",connectKind:"apiKey",accent:"from-[#e7eeff] via-[#f4f7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search DeepSeek models"},{id:"mistral",label:"Mistral",shortLabel:"Mistral",description:"Add a Mistral API key, discover Mistral and Codestral models, and curate your routes.",category:"other",connectKind:"apiKey",accent:"from-[#f2e8ff] via-[#fbf7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Mistral models"},{id:"xai",label:"xAI",shortLabel:"xAI",description:"Use an xAI API key to bring Grok models into AgentOS.",category:"other",connectKind:"apiKey",accent:"from-[#ffe6ea] via-[#fff3f5] to-white",helperText:"Simple API key connection."}];function f(a){let b=e.find(b=>b.id===a);if(!b)throw Error(`Unknown model provider: ${a}`);return b}function g(a){return"string"==typeof a&&e.some(b=>b.id===a)}function h(a){if("codex"===a)return"openai-codex";if("gemini"===a)return"google";if(g(a))return a;if(a&&"object"==typeof a&&"id"in a){let b=a.id;if("codex"===b)return"openai-codex";if("gemini"===b)return"google";if(g(b))return b}return null}function i(a){if("codex"===a)return"Codex";let b=e.find(b=>b.id===a);return b?b.shortLabel:a.split("-").map(a=>a?a[0].toUpperCase()+a.slice(1):a).join(" ")}e.filter(a=>"primary"===a.category),e.filter(a=>"other"===a.category)},60740:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,83316,23))},61655:(a,b,c)=>{"use strict";c.d(b,{F:()=>h});var d=c(3814),e=c(6247),f=c(84504),g=c(32905);let h=e.forwardRef(({className:a,children:b,...c},e)=>(0,d.jsxs)(f.bL,{ref:e,className:(0,g.cn)("relative overflow-hidden",a),...c,children:[(0,d.jsx)(f.LM,{className:"mission-scroll h-full w-full rounded-[inherit] [&>div]:!block [&>div]:!w-full [&>div]:!min-w-0",children:b}),(0,d.jsx)(i,{}),(0,d.jsx)(f.OK,{})]}));h.displayName=f.bL.displayName;let i=e.forwardRef(({className:a,orientation:b="vertical",...c},e)=>(0,d.jsx)(f.VM,{ref:e,orientation:b,className:(0,g.cn)("flex touch-none select-none transition-colors","vertical"===b&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===b&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...c,children:(0,d.jsx)(f.lr,{className:"relative flex-1 rounded-full bg-muted-foreground/25"})}));i.displayName=f.VM.displayName},63292:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(3814),e=c(45317),f=c(32905);function g({label:a,side:b,surfaceTheme:c,panelCollapsed:h,children:i}){return(0,d.jsx)(e.Bc,{delayDuration:120,children:(0,d.jsxs)(e.m_,{children:[(0,d.jsx)(e.k$,{asChild:!0,children:i}),(0,d.jsx)(e.ZI,{side:b,align:"center",sideOffset:10,className:(0,f.cn)("rounded-[10px] px-2.5 py-1.5 text-[10px] font-medium leading-none tracking-[0.12em] whitespace-nowrap shadow-[0_16px_40px_rgba(0,0,0,0.32)]","light"===c?h?"border border-slate-200/80 bg-white/96 text-slate-900 shadow-[0_16px_40px_rgba(15,23,42,0.18)]":"border border-white/10 bg-slate-950/94 text-white shadow-[0_16px_40px_rgba(0,0,0,0.36)]":"border border-white/10 bg-slate-950/92 text-slate-100"),children:a})]})})}},63381:()=>{},68885:(a,b,c)=>{"use strict";c.d(b,{L:()=>d});let d="2026.6.1"},69903:(a,b,c)=>{"use strict";c.d(b,{nK:()=>l,TY:()=>f,qk:()=>j,w6:()=>i,nd:()=>g});var d=c(9494),e=c(92078);function f(a,b={}){let c=(0,e.g0)(b.policy?.preset??"worker",b.policy),g=(0,e.Cf)(c.preset),h=(0,d.iq)(c.preset,b.heartbeat);return{workspaceId:a,modelId:b.modelId??"",name:b.name??g.defaultName,emoji:b.emoji??g.defaultEmoji,theme:b.theme??g.defaultTheme,avatar:b.avatar??"",policy:c,heartbeat:h,channelIds:Array.from(new Set((b.channelIds??[]).filter(a=>"string"==typeof a&&!!a.trim())))}}function g(a,b){let c=a.diagnostics.modelReadiness.defaultModelReady?h(a.diagnostics.modelReadiness.resolvedDefaultModel||a.diagnostics.modelReadiness.defaultModel):null;if(c&&i(a,c))return c;let d=a.agents.filter(a=>!b||a.workspaceId===b).map(a=>h(a.modelId)).find(b=>b&&i(a,b));if(d)return d;let e=h(a.diagnostics.modelReadiness.recommendedModelId);return e&&i(a,e)?e:a.models.map(a=>h(a.id)).find(b=>b&&i(a,b))??""}function h(a){let b=a?.trim();return b&&"unassigned"!==b?b:null}function i(a,b){let c=a.models.find(a=>a.id===b);return!!c&&!0!==c.missing&&!1!==c.available}function j(a,b,c){var d,e;let f,g,h=(d=b,e=c,f=k(d??""),g=k(e)||"agent",f?`${f}-${g}`:g);if(!h)return"";let i=new Set(a.map(a=>a.id));if(!i.has(h))return h;let j=2,l=`${h}-${j}`;for(;i.has(l);)j+=1,l=`${h}-${j}`;return l}function k(a){return a.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function l(a,b){let c=(0,e.Cf)(a.policy.preset),f=(0,e.Cf)(b),g=(0,e.g0)(b);return{...a,name:a.name&&a.name!==c.defaultName?a.name:f.defaultName,emoji:a.emoji&&a.emoji!==c.defaultEmoji?a.emoji:f.defaultEmoji,theme:a.theme&&a.theme!==c.defaultTheme?a.theme:f.defaultTheme,policy:g,heartbeat:(0,d.I$)(a.heartbeat,a.policy.preset,b)}}},72349:(a,b,c)=>{"use strict";function d(a){return f(a)}function e(a){var b;return f(a)&&(a.diagnostics.modelReadiness.ready||!!(b=a).agents.map(a=>{var b;let c;return b=a.modelId,(c=b?.trim())&&"unassigned"!==c?c:null}).find(a=>{var c,d,e,f,g;let h;return a&&(c=b,d=a,!!(h=(e=c,f=d,e.models.find(a=>a.id===f)))&&!0!==(g=h).missing&&!1!==g.available)}))}function f(a){return a.diagnostics.installed&&a.diagnostics.rpcOk&&!!(a.diagnostics.runtime?.stateWritable&&a.diagnostics.runtime?.sessionStoreWritable)}c.d(b,{X2:()=>e,h6:()=>d,iN:()=>f})},73767:(a,b,c)=>{Promise.resolve().then(c.bind(c,43081)),Promise.resolve().then(c.t.bind(c,98296,23))},74952:(a,b,c)=>{"use strict";c.d(b,{T:()=>g});var d=c(3814),e=c(6247),f=c(32905);let g=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)("textarea",{className:(0,f.cn)("flex min-h-[96px] w-full rounded-lg border border-input bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",a),ref:c,...b}));g.displayName="Textarea"},80990:(a,b,c)=>{"use strict";c.d(b,{$:()=>j});var d=c(3814),e=c(6247),f=c(69598),g=c(9082),h=c(32905);let i=(0,g.F)("inline-flex items-center justify-center whitespace-nowrap rounded-lg text-sm font-semibold transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-lg shadow-primary/20 hover:bg-primary/90",secondary:"border border-border bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"text-muted-foreground hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive text-destructive-foreground shadow-lg shadow-destructive/20 hover:bg-destructive/90"},size:{default:"h-11 px-4 py-2",sm:"h-9 rounded-lg px-3",lg:"h-12 rounded-lg px-5",icon:"h-11 w-11"}},defaultVariants:{variant:"default",size:"default"}}),j=e.forwardRef(({className:a,variant:b,size:c,asChild:e=!1,...g},j)=>{let k=e?f.DX:"button";return(0,d.jsx)(k,{className:(0,h.cn)(i({variant:b,size:c,className:a})),ref:j,...g})});j.displayName="Button"},82425:(a,b,c)=>{"use strict";c.d(b,{z:()=>A});var d=c(3814),e=c(6247),f=c(11917),g=c(57825),h=c(32956),i=c(57531),j=c(5813),k=c(49444),l=c(32905);function m({title:a,selectedValues:b,selectedTone:c,selectedEmptyLabel:e,lockedValues:f=[],observedValues:g=[],inputRef:o,inputValue:p,onInputValueChange:q,onRemove:r,onPick:s,suggestions:t,emptySuggestionLabel:u,loading:v,catalogError:w,helperLabel:x,currentHintLabel:y,highlight:z}){let A="cyan"===c?{border:"border-cyan-300/20",chip:"border-cyan-300/15 bg-cyan-400/10 text-cyan-50",chipHover:"hover:border-cyan-200/30 hover:bg-cyan-400/15"}:{border:"border-amber-300/20",chip:"border-amber-300/15 bg-amber-400/10 text-amber-50",chipHover:"hover:border-amber-200/30 hover:bg-amber-400/15"},B=f.length>0,C=new Set(f),D=`Current ${a.toLowerCase()}`,E=`${a}:${p}:${t.length}:${t[0]?.value??""}`;return(0,d.jsxs)("div",{className:(0,l.cn)("rounded-[18px] border bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] p-3.5",A.border,z&&"shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,d.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:a}),(0,d.jsx)(j.E,{variant:"muted",children:"Declared"})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:D}),(0,d.jsx)("p",{className:"text-[10px] leading-4 text-slate-400",children:y})]}),(0,d.jsxs)(j.E,{variant:"muted",children:[b.length," current"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.length>0?b.map(a=>{let b=C.has(a);return(0,d.jsxs)("div",{className:(0,l.cn)("inline-flex max-w-full items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] transition-colors",A.chip,A.chipHover,b&&"cursor-not-allowed pr-2.5"),title:b?`Managed by policy: ${a}`:a,children:[(0,d.jsx)("span",{className:"max-w-full truncate",children:a}),b?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 text-white/70",children:(0,d.jsx)(h.A,{className:"h-3 w-3"})}):(0,d.jsx)("button",{type:"button","aria-label":`Remove ${a}`,title:`Remove ${a}`,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/10 text-white/70 transition-colors hover:border-white/20 hover:bg-white/20 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/60 focus-visible:ring-offset-0",onClick:()=>r(a),children:(0,d.jsx)(i.A,{className:"h-2.5 w-2.5"})})]},a)}):(0,d.jsx)(j.E,{variant:"muted",children:e})})]}),(0,d.jsx)("div",{children:(0,d.jsx)(k.p,{ref:o,value:p,onChange:a=>q(a.target.value),onKeyDown:a=>(function(a,b,c){if("Enter"!==a.key)return;a.preventDefault();let d=b[0];d&&c(d.value)})(a,t,s),placeholder:"Skills"===a?"Search OpenClaw or workspace skills":"Search built-in tools or plugin tools",className:"h-8 flex-1 rounded-xl border-white/10 bg-white/5 px-3 text-[12px]"})}),(0,d.jsx)("div",{className:"space-y-2",children:(0,d.jsx)(n,{kind:"Skills"===a?"skill":"tool",suggestions:t,onPick:s,emptyLabel:u},E)}),B?(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Policy locked"}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:f.map(a=>(0,d.jsxs)(j.E,{variant:"success",children:[(0,d.jsx)(h.A,{className:"mr-1 h-3 w-3"}),a]},a))})]}):null,g.length>0?(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed"}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:g.slice(0,10).map(a=>(0,d.jsx)(j.E,{variant:"muted",children:a},a))})]}):null,(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:x}),w?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:w}):null,v&&0===t.length?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:"Loading OpenClaw catalog..."}):null]})]})}function n({kind:a,suggestions:b,onPick:c,emptyLabel:f}){let[g,h]=(0,e.useState)(8),i=b.slice(0,g),k=Math.max(b.length-i.length,0);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Available to add"}),(0,d.jsxs)(j.E,{variant:"muted",children:[b.length," total"]})]}),(0,d.jsx)("div",{className:"max-h-[280px] space-y-1.5 overflow-y-auto pr-1",children:(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(o,{kind:a,options:i,onPick:c,emptyLabel:f}),k>0?(0,d.jsxs)("button",{type:"button",onClick:()=>h(a=>a+8),className:"group flex w-full items-center justify-center gap-2 rounded-xl border border-dashed border-cyan-300/20 bg-cyan-400/[0.04] px-3 py-2 text-[11px] text-cyan-100 transition-colors hover:border-cyan-200/35 hover:bg-cyan-400/[0.08] hover:text-white",children:[(0,d.jsx)("span",{className:"uppercase tracking-[0.18em]",children:"Load more"}),(0,d.jsxs)(j.E,{variant:"muted",className:"h-5 px-2 py-0 text-[10px]",children:["+",k]})]}):null]})})]})}function o({kind:a,options:b,onPick:c,emptyLabel:e}){return 0===b.length?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:e}):(0,d.jsx)("div",{className:"space-y-1.5",children:b.map(b=>{var e;return(0,d.jsxs)("button",{type:"button",className:(0,l.cn)("group flex w-full items-start justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.03] px-3 py-1.5 text-left transition-colors hover:border-cyan-300/20 hover:bg-cyan-400/[0.05]","tool"===a&&"hover:border-amber-300/20 hover:bg-amber-400/[0.05]"),onClick:()=>c(b.value),title:b.description,children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-[12px] leading-4 text-white",children:b.label}),"group"===b.category?(0,d.jsx)(j.E,{variant:"muted",children:"group"}):null]}),(0,d.jsx)("p",{className:"line-clamp-2 text-[11px] leading-4 text-slate-400",children:b.description})]}),(0,d.jsx)(j.E,{variant:"skill"===(e=b).kind?"workspace"===e.category?"success":"custom"===e.category?"muted":"default":"plugin"===e.category?"warning":"group"===e.category||"custom"===e.category?"muted":"default",className:"shrink-0 h-4 max-w-[132px] px-1.5 py-0 text-[8px] font-medium tracking-[0.08em] normal-case",children:(0,d.jsx)("span",{className:"truncate",children:b.sourceLabel})})]},b.value)})})}var p=c(80990),q=c(37674),r=c(92078),s=c(90665);function t(a,b){let c=new Map;for(let e of a){var d;let a=e.value.trim();if(!a)continue;let f=c.get(a);if(!f){c.set(a,{...e,value:a,label:e.label||a,description:e.description||"",sourceLabel:e.sourceLabel||"OpenClaw",sourceRank:e.sourceRank??99,kind:e.kind||b,category:e.category});continue}f.description=f.description||e.description,d=f.sourceLabel,f.sourceLabel=w([d,e.sourceLabel].filter(a=>!!a)).join(" \xb7 "),f.sourceRank=Math.min(f.sourceRank,e.sourceRank??f.sourceRank),f.category=f.category??e.category}return Array.from(c.values()).sort((a,b)=>{let c=a.sourceRank-b.sourceRank;if(0!==c)return c;let d=a.label.localeCompare(b.label);return 0!==d?d:a.value.localeCompare(b.value)})}function u(a,b,c,d=8){let e=b.trim().toLowerCase(),f=new Set(w(c));return a.filter(a=>!f.has(a.value)).filter(a=>!e||5>y(a,e)).sort((a,b)=>{let c=y(a,e),d=y(b,e);if(c!==d)return c-d;let f=a.sourceRank-b.sourceRank;return 0!==f?f:a.label.localeCompare(b.label)}).slice(0,d)}function v(a){return"builtin"===a.category?"OpenClaw built-in":"group"===a.category?"OpenClaw docs":a.source}function w(a){let b=new Set,c=[];for(let d of a){if("string"!=typeof d)continue;let a=d.trim();!a||b.has(a)||(b.add(a),c.push(a))}return c}function x(a,b){return a.length===b.length&&a.every((a,c)=>a===b[c])}function y(a,b){if(!b)return 0;let c=[a.value.toLowerCase(),a.label.toLowerCase(),a.description.toLowerCase(),a.sourceLabel.toLowerCase()];return c.some(a=>a===b)?0:c.some(a=>a.startsWith(b))?1:c.some(a=>a.includes(b))?2:5}var z=c(30540);function A({open:a,agentId:b,initialFocus:c="skills",snapshot:h,onOpenChange:i,onSnapshotChange:k,onRefresh:l}){let n=b?h.agents.find(a=>a.id===b)??null:null,o=h.workspaces.find(a=>a.id===n?.workspaceId),[y,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(null),[K,L]=(0,e.useState)(""),[M,N]=(0,e.useState)(""),[O,P]=(0,e.useState)([]),[Q,R]=(0,e.useState)([]),S=(0,e.useRef)(null),T=(0,e.useRef)(null);(0,e.useRef)(h);let U="tools"===c?"tools":"skills",V="skills"===U,W="tools"===U,X=n?(0,r.Cf)(n.policy.preset):null,Y=w(n?.skills??[]),Z=w((n?.tools??[]).filter(a=>"fs.workspaceOnly"!==a)),$=Y.length>0?Y:w(X?.skillIds??[]),_=Z.length>0?Z:w(X?.tools??[]),aa=n?.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[],ab=w(n?.observedTools??[]),ac=w(o?.bootstrap.localSkillIds??[]),ad=(0,e.useMemo)(()=>[...z.j,...z.T],[]),ae=(0,e.useMemo)(()=>t([...(y?.skills??[]).map(a=>{var b;return{value:a.name,label:a.name,description:a.description,sourceLabel:"openclaw-bundled"===(b=a.source)?"OpenClaw bundled":"workspace"===b?"Workspace":b,sourceRank:+("openclaw-bundled"!==a.source),kind:"skill"}}),...ac.map(a=>({value:a,label:a,description:"Workspace-local SKILL.md scaffold.",sourceLabel:"Workspace",sourceRank:0,kind:"skill",category:"workspace"})),...O.filter(a=>!(y?.skills??[]).some(b=>b.name===a)).map(a=>({value:a,label:a,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:2,kind:"skill",category:"custom"}))],"skill"),[y?.skills,O,ac]),af=(0,e.useMemo)(()=>t([...ad.map(a=>({value:a.name,label:a.name,description:a.description,sourceLabel:v(a),sourceRank:"builtin"===a.category?0:"plugin"===a.category?1:2,kind:"tool",category:a.category})),...(y?.tools??[]).map(a=>({value:a.name,label:a.name,description:a.description,sourceLabel:v(a),sourceRank:"builtin"===a.category?0:"plugin"===a.category?1:2,kind:"tool",category:a.category})),...Q.filter(a=>"fs.workspaceOnly"!==a&&!(y?.tools??[]).some(b=>b.name===a)).map(a=>({value:a,label:a,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:3,kind:"tool",category:"custom"})),...ab.filter(a=>"fs.workspaceOnly"!==a&&!(y?.tools??[]).some(b=>b.name===a)&&!Z.includes(a)).map(a=>({value:a,label:a,description:"Recovered from runtime transcripts.",sourceLabel:"Observed",sourceRank:4,kind:"tool",category:"custom"}))],"tool"),[y?.tools,Z,Q,ad,ab]),ag=(0,e.useMemo)(()=>u(ae,K,O,1/0),[O,K,ae]),ah=(0,e.useMemo)(()=>u(af,M,Q,1/0),[Q,M,af]);if(!n)return null;let ai=V?$:Y,aj=W?_:Z,ak=V?w(O):Y,al=W?w(Q):Z,am=!x(ak,ai)||!x(al,aj),an=async()=>{if(x(ak,ai)&&x(al,aj))return void i(!1);H(!0),J(null);try{let a={id:n.id};V?a.skills=ak:a.tools=al;let b=await fetch("/api/agents",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok)throw Error(c.error||"Unable to update agent capabilities.");k?.(a=>(function(a,b,c,d){let e=w(c),f=a.agents.map(a=>a.id===b?{...a,skills:e,tools:w([...d,...a.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[]])}:a),g=f.find(a=>a.id===b);if(!g)return a;let h=a.workspaces.map(a=>{if(a.id!==g.workspaceId)return a;let b=f.filter(b=>b.workspaceId===a.id);return{...a,capabilities:{...a.capabilities,skills:w(b.flatMap(a=>a.skills)),tools:w(b.flatMap(a=>a.tools)),workspaceOnlyAgentCount:b.filter(a=>a.tools.includes("fs.workspaceOnly")).length}}});return{...a,agents:f,workspaces:h}})(a,n.id,ak,al)),g.oR.success("Agent capabilities updated."),i(!1);let d=l?.();d&&d.catch(()=>void 0)}catch(b){let a=b instanceof Error?b.message:"Unable to update agent capabilities.";J(a),g.oR.error(a)}finally{H(!1)}};return(0,d.jsx)(q.lG,{open:a,onOpenChange:i,children:(0,d.jsx)(q.Cf,{className:"w-[min(680px,calc(100vw-1.5rem))] max-h-[calc(100dvh-1.5rem)] overflow-hidden rounded-[24px] border-white/10 bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(4,7,14,0.98))] p-0",children:(0,d.jsxs)("div",{className:"flex max-h-[calc(100dvh-1.5rem)] min-h-0 flex-col",children:[(0,d.jsxs)(q.c7,{className:"border-b border-white/[0.08] px-4 py-2.5",children:[(0,d.jsx)(q.L3,{className:"text-[0.95rem]",children:`Edit ${V?"skills":"tools"} \xb7 ${(0,s.CK)(n)}`}),(0,d.jsx)(q.rr,{className:"sr-only",children:"Edit the selected agent's skills or tools and save the updated capability set."}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1 pt-0.5",children:(0,d.jsx)(j.E,{variant:"muted",className:"h-5 border-white/[0.08] px-2 py-0 text-[10px] font-normal tracking-[0.06em] normal-case",children:(0,r._P)(n.policy.preset)})})]}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,d.jsx)("div",{className:"px-4 py-4",children:(0,d.jsx)(m,{title:V?"Skills":"Tools",selectedValues:V?O:Q,selectedTone:V?"cyan":"amber",selectedEmptyLabel:V?"No explicit skills":"No explicit tools configured",lockedValues:W?aa:[],observedValues:W?ab:[],inputRef:V?S:T,inputValue:V?K:M,onInputValueChange:V?L:N,onRemove:a=>{V?P(b=>b.filter(b=>b!==a)):R(b=>b.filter(b=>b!==a))},onPick:a=>{V?(P(b=>w([...b,a])),L("")):(R(b=>w([...b,a])),N(""))},suggestions:V?ag:ah,emptySuggestionLabel:E&&(V?ag.length:ah.length)===0?V?"Loading OpenClaw skill catalog...":"Loading OpenClaw tool catalog...":V?"No matching skills found.":"No matching tools found.",loading:E,catalogError:C,helperLabel:V?"Workspace skills and OpenClaw skills are shown first in Available to add.":"Built-ins, plugins, and groups are shown first in Available to add. Observed tools are read-only.",currentHintLabel:V?"Click \xd7 on a current skill to remove it.":"Click \xd7 on a current tool to remove it.",highlight:!0})}),I?(0,d.jsx)("div",{className:"border-t border-white/[0.08] px-4 py-3",children:(0,d.jsx)("p",{className:"text-[12px] leading-5 text-rose-300",children:I})}):null]}),(0,d.jsxs)(q.Es,{className:"border-t border-white/[0.08] px-4 py-2 sm:flex-row",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",onClick:()=>i(!1),disabled:G,className:"h-8 rounded-full px-2.5 text-[10px]",children:"Cancel"}),(0,d.jsxs)(p.$,{type:"button",onClick:()=>{an()},disabled:G||!am,className:"h-8 rounded-full px-2.5 text-[10px]",children:[G?(0,d.jsx)(f.A,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):null,"Save changes"]})]})]})})})}},89478:(a,b,c)=>{"use strict";c.d(b,{jZ:()=>e,oZ:()=>h});var d=c(60557);class e extends Error{constructor(a,b){super(a),this.result=b,this.name="ModelProviderActionError"}}async function f(a){let b=await fetch("/api/models/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok||!c)throw Error(c?.error||c?.message||"Model provider request failed.");if(!c.ok&&c.message)throw new e(c.message,c);return c}let g=Object.fromEntries(d.y8.map(a=>{var b;return[a.id,{id:b=a.id,descriptor:(0,d.W2)(b),getConnectionStatus:()=>f({action:"status",provider:b}),connect:a=>f({action:"connect",provider:b,apiKey:a?.apiKey?.trim()?a.apiKey.trim():void 0,endpoint:a?.endpoint?.trim()?a.endpoint.trim():void 0,force:a?.force===!0||void 0}),discoverModels:()=>f({action:"discover",provider:b}),addModels:a=>f({action:"add-models",provider:b,modelIds:a})}]}));function h(a){return g[a]}},90639:(a,b,c)=>{Promise.resolve().then(c.bind(c,927)),Promise.resolve().then(c.t.bind(c,95258,23))},90665:(a,b,c)=>{"use strict";c.d(b,{$7:()=>n,$m:()=>p,CK:()=>j,FO:()=>g,JZ:()=>i,Uu:()=>l,_y:()=>h,fw:()=>e,hv:()=>f,m_:()=>m,sY:()=>k});var d=c(3844);function e(a,b=Date.now()){return null==a||Number.isNaN(a)?"No activity":`${(0,d.k)(a,b,{addSuffix:!0})}`}function f(a){if(!a)return Date.now();let b=Date.parse(a);return Number.isNaN(b)?Date.now():b}function g(a){return a?a>=1e3?`${Math.round(a/1e3)}k`:String(a):"n/a"}function h(a){return"number"!=typeof a?"n/a":a>=1e3?`${(a/1e3).toFixed(a>=1e4?0:1)}k`:String(a)}function i(a){return a.split("/").at(1)||a}function j(a){return a.name?.trim()||a.identityName?.trim()||"OpenClaw"}function k(a){switch(a){case"running":return"text-cyan-300";case"completed":return"text-emerald-300";case"cancelled":return"text-rose-300";case"stalled":case"queued":return"text-amber-200";default:return"text-slate-400"}}function l(a){switch(a){case"running":return"default";case"completed":return"success";case"cancelled":return"danger";case"stalled":return"warning";default:return"muted"}}function m(a,b=8){return a?a.length<=b?a:a.slice(0,b):"n/a"}function n(a){return a.replace(/^\/Users\/[^/]+/,"~")}let o=[/^Task output routing:/i,/^Agent operating policy:/i];function p(a,b=64){if(!a)return"";let c=function(a){let b=a.replace(/\r\n/g,"\n").trim();if(!b)return"";let c=[];for(let a of b.split("\n")){let b=a.trim();if(o.some(a=>a.test(b)))break;c.push(a)}return c.join(" ").replace(/\s+/g," ").trim()}(a);return c?c.length<=b?c:`${c.slice(0,Math.max(b-1,1)).trimEnd()}…`:""}},92078:(a,b,c)=>{"use strict";c.d(b,{$x:()=>i,A_:()=>g,Bw:()=>r,Cf:()=>k,DS:()=>j,UJ:()=>p,_P:()=>m,aB:()=>n,bQ:()=>q,bt:()=>f,g0:()=>l,sH:()=>h,zR:()=>o}),c(30540).j.map(a=>a.name);let d={worker:{label:"Worker",description:"Default execution agent for code changes, docs, research, and review work. Best when the task stays inside the workspace and does not need system-level changes.",defaultName:"Worker",defaultEmoji:"\uD83D\uDEE0️",defaultTheme:"slate",badgeVariant:"default",tools:["exec","read","write","edit","apply_patch"],skillIds:["project-builder","project-reviewer","project-tester"]},setup:{label:"Setup / Operator",description:"Bootstraps environments, handles installs, and unblocks the workspace so other agents can move faster.",defaultName:"Setup Operator",defaultEmoji:"\uD83E\uDDF0",defaultTheme:"amber",badgeVariant:"warning",tools:["exec","process","gateway","read","write"],skillIds:["project-builder","project-analyst","project-learner"]},browser:{label:"Browser",description:"Captures browser evidence, screenshots, and user-path validation for UI-heavy work.",defaultName:"Browser Agent",defaultEmoji:"\uD83C\uDF10",defaultTheme:"blue",badgeVariant:"success",tools:["browser","web_search","web_fetch","image"],skillIds:["project-browser","project-tester","project-researcher"]},monitoring:{label:"Monitoring",description:"Runs on a watch cycle, checks health and drift, and leaves concise triage handoffs.",defaultName:"Monitoring Agent",defaultEmoji:"\uD83D\uDEF0️",defaultTheme:"teal",badgeVariant:"warning",tools:["cron","gateway","sessions_list","message","web_fetch"],skillIds:["project-analyst","project-reviewer","project-learner"]},custom:{label:"Custom",description:"Starts from the safe baseline and lets you fine-tune identity, policy, and operating style by hand.",defaultName:"Custom Agent",defaultEmoji:"\uD83E\uDDE9",defaultTheme:"violet",badgeVariant:"muted",tools:["exec","read","edit","message"],skillIds:[]}},e={worker:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},setup:{missingToolBehavior:"allow-install",installScope:"workspace",fileAccess:"workspace-only",networkAccess:"enabled"},browser:{missingToolBehavior:"ask-setup",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},monitoring:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},custom:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"}},f=Object.entries(d).map(([a,b])=>({value:a,label:b.label,description:b.description})),g=[{value:"fallback",label:"Fallback",description:"Produce the nearest viable output format instead of failing the task."},{value:"ask-setup",label:"Ask for setup",description:"Stop before environment changes and report the missing capability clearly."},{value:"route-setup",label:"Route to setup agent",description:"Leave an explicit setup handoff instead of attempting installs directly."},{value:"allow-install",label:"Allow install",description:"Install missing tooling when policy allows it and the task truly depends on it."}],h=[{value:"none",label:"None",description:"Do not install workspace or system dependencies."},{value:"workspace",label:"Workspace only",description:"Only install dependencies inside the project or workspace environment."},{value:"system",label:"System",description:"Permit system-wide installs when they are necessary and intentional."}],i=[{value:"workspace-only",label:"Workspace only",description:"Keep file work grounded inside the attached workspace."},{value:"extended",label:"Extended",description:"Allow broader file access when the task explicitly needs it."}],j=[{value:"restricted",label:"Off",description:"Avoid network access unless the task explicitly depends on it."},{value:"enabled",label:"On",description:"Use network access when the task needs external information or downloads."}];function k(a){return d[a]}function l(a="worker",b){return{...e[a],...b??{},preset:a}}function m(a){return d[a].label}function n(a){return"fs.workspaceOnly"===a?"Workspace only":a.replace(/^agent-policy-/,"").replace(/^project-/,"").replace(/[._-]+/g," ").trim().replace(/\b\w/g,a=>a.toUpperCase())}function o(a){return g.find(b=>b.value===a)?.label??a}function p(a){return h.find(b=>b.value===a)?.label??a}function q(a){return i.find(b=>b.value===a)?.label??a}function r(a){return j.find(b=>b.value===a)?.label??a}},97078:(a,b,c)=>{"use strict";c.d(b,{O:()=>B});var d=c(3814),e=c(6247),f=c(68123),g=c(58664),h=c(78282),i=c(76179),j=c(11917),k=c(63685),l=c(45738),m=c(5813),n=c(34118),o=c(9494),p=c(92078),q=c(32905);function r({label:a,htmlFor:b,children:c,surfaceTheme:e="dark"}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(n.J,{htmlFor:b,className:(0,q.cn)("text-[10px] uppercase tracking-[0.16em]","light"===e?"text-[#8d7766]":"text-slate-400"),children:a}),c]})}function s({preset:a,active:b,onClick:c,surfaceTheme:e="dark"}){let f=(0,p.Cf)(a),h=(0,o.A6)(a),i="light"===e;return(0,d.jsx)("button",{type:"button",onClick:c,"aria-pressed":b,className:(0,q.cn)("flex h-full min-h-[200px] min-w-0 flex-col justify-between rounded-[24px] border p-4 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 snap-start",i?"border-[#e3d7cc] bg-white/92 shadow-[0_16px_34px_rgba(161,125,101,0.08)] focus-visible:ring-[#c89e73]/30 hover:border-[#d3c0b2] hover:bg-white":"border-white/10 bg-white/[0.03] shadow-[0_12px_28px_rgba(0,0,0,0.22)] focus-visible:ring-cyan-300/40 hover:border-white/20 hover:bg-white/[0.05]",b&&(i?"border-[#c89e73] bg-[#fff8f0] shadow-[0_18px_44px_rgba(161,125,101,0.14)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.08)]")),children:(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border text-[15px]",i?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-white"),children:f.defaultEmoji??(0,d.jsx)(g.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("line-clamp-2 break-words text-[14px] font-semibold leading-5",i?"text-[#2f2016]":"text-white"),children:f.label}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 line-clamp-3 text-[12px] leading-5",i?"text-[#6d5849]":"text-slate-400"),children:f.description})]})]}),(0,d.jsx)(m.E,{variant:b?"default":"muted",className:(0,q.cn)("shrink-0 px-2 py-0.5 text-[9px] normal-case tracking-normal",i?b?"border-[#c89e73]/35 bg-[#f4e6d8] text-[#5f432f]":"border-[#e1d5c8] bg-white text-[#846a58]":b?"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":"border-white/10 bg-white/5 text-slate-300"),children:b?"selected":"preset"})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsxs)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:[f.tools.length," tools"]}),(0,d.jsxs)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:[f.skillIds.length," skills"]}),(0,d.jsxs)(m.E,{variant:h.enabled?"success":"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?h.enabled?"border-emerald-300/40 bg-emerald-100 text-emerald-800":"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:["Heartbeat ",h.enabled?h.every:"off"]})]})]})})}function t({label:a,htmlFor:b,value:c,options:e,onChange:f,surfaceTheme:g="dark"}){let h="light"===g,i=e.find(a=>a.value===c);return(0,d.jsxs)(r,{label:a,htmlFor:b,surfaceTheme:g,children:[(0,d.jsx)("select",{id:b,value:c,onChange:a=>f(a.target.value),style:h?{colorScheme:"light"}:void 0,className:(0,q.cn)("flex h-10 w-full rounded-2xl border px-3.5 py-2 text-[13px] outline-none transition-colors",h?"border-[#dccfc3] bg-white text-[#3f2f24] placeholder:text-[#9b8573] focus:border-[#c89e73] focus:ring-2 focus:ring-[#c89e73]/15":"border-white/10 bg-white/5 text-white placeholder:text-slate-500 focus:border-cyan-300/30 focus:ring-2 focus:ring-cyan-300/15"),children:e.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}),i?.description?(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[10px] leading-[1.4]",h?"text-[#9a8070]":"text-slate-500"),children:i.description}):null]})}var u=c(80990),v=c(37674),w=c(49444),x=c(43081),y=c(45084),z=c(90665),A=c(69903);function B({snapshot:a,defaultWorkspaceId:b,onRefresh:c,onSnapshotChange:k,onAgentCreationPending:n,onAgentCreated:L,onAgentCreatedVisible:M,trigger:N,surfaceTheme:O="dark"}){var P,Q,R,S,T;let U="light"===O,V=b??a.workspaces[0]?.id??"",[W,X]=(0,e.useState)(!1),[Y,Z]=(0,e.useState)(!1),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)("start"),[ac,ad]=(0,e.useState)(null),[ae,af]=(0,e.useState)("worker"),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(""),[ak,al]=(0,e.useState)(!1),[am,an]=(0,e.useState)("idle"),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(null),as=(0,e.useRef)(!1),at=(0,e.useRef)(null),[au,av]=(0,e.useState)(()=>C(V,a)),aw=(0,e.useRef)(null),ax=a.workspaces.find(a=>a.id===au.workspaceId)??null,ay=(0,A.nd)(a,au.workspaceId||V),az=au.modelId.trim()||ay,aA=au.modelId.trim()&&!(0,A.w6)(a,au.modelId.trim())?`Model ${au.modelId.trim()} is not ready. AgentOS will create the agent with a ready fallback when available and show a warning on the card.`:null,aB=(0,p.Cf)(au.policy.preset),aC=(0,A.qk)(a.agents,ax?.slug,au.name||aB.defaultName),aD=ag?a.agents.find(a=>a.id===ag)??null:null,aE=aD?a.workspaces.find(a=>a.id===aD.workspaceId)??null:null,aF=(0,e.useMemo)(()=>{let b=ai.trim().toLowerCase();return[...a.agents].filter(c=>{if(!b)return!0;let d=a.workspaces.find(a=>a.id===c.workspaceId)?.name??c.workspaceId,e=(0,p.Cf)(c.policy.preset).label;return[(0,z.CK)(c),c.id,c.workspaceId,d,e,c.modelId].join(" ").toLowerCase().includes(b)}).sort((a,b)=>{if(ag){if(a.id===ag)return -1;if(b.id===ag)return 1}return(0,z.CK)(a).localeCompare((0,z.CK)(b))})},[ai,ag,a.agents,a.workspaces]),aG=D(ac),aH=E(ac,aa),aI=!!(aC&&ax&&az)&&!ak,aJ="details"===aa?aI:(P=aa,Q=ac,R=ag,"start"===P?!!Q:"preset"===P||"import"!==P||!!R);ao&&a.agents.some(a=>a.id===ao);let aK="creating"===am?"Creating the agent and updating the workspace AGENTS.md role section.":"syncing"===am?"Agent created. Waiting for the canvas card to appear.":null,aL=(0,e.useCallback)(b=>{let c=C(b,a);ab("start"),ad(null),af("worker"),ah(null),aj(""),av(c),al(!1),an("idle"),ap(null),ar(null),aw.current&&(clearTimeout(aw.current),aw.current=null),as.current=!1},[a]),aM=a=>{(a||!ak&&"idle"===am)&&(_(a),a||aL(V))},aN=b=>{let c=au.workspaceId||V,d=C(c,a);d.modelId=au.modelId||(0,A.nd)(a,c),ad(b),af("worker"),ah(null),aj(""),av(d),"empty"===b?ab("details"):ab("start")},aO=async()=>{if(!as.current&&aC&&ax){as.current=!0,al(!0),an("creating"),ap(null),ar(null);try{let a=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...au,modelId:az,id:aC})}),b=await a.json();if(!a.ok||b.error||!b.agentId)throw Error(b.error||"OpenClaw could not create the agent.");au.channelIds.length>0&&await (0,y.rz)({workspaceId:au.workspaceId,workspacePath:ax.path,agentId:b.agentId,currentChannelIds:[],nextChannelIds:au.channelIds,onRegistryChange:k});let d=(0,p.Cf)(au.policy.preset);n?.({id:b.agentId,workspaceId:au.workspaceId,workspacePath:ax.path,name:au.name.trim()||b.agentId,modelId:az,emoji:au.emoji.trim()||d.defaultEmoji,theme:au.theme.trim()||d.defaultTheme,policy:au.policy,heartbeat:{enabled:au.heartbeat.enabled,every:au.heartbeat.every},skills:d.skillIds,tools:d.tools,createdAt:Date.now(),warning:b.warning??b.warnings?.[0]??null}),an("syncing"),ap(b.agentId),ar(b.warning??b.warnings?.[0]??null),c().catch(()=>{})}catch(a){aw.current&&(clearTimeout(aw.current),aw.current=null),an("idle"),ap(null),ar(null),al(!1),x.o.error("Agent creation failed.",{description:a instanceof Error?a.message:"Unknown agent error."})}finally{as.current=!1}}};return W?(0,d.jsxs)(v.lG,{open:$,onOpenChange:aM,children:[(0,d.jsx)(v.zM,{asChild:!0,children:N}),(0,d.jsx)(v.Cf,{overlayClassName:U?"bg-[#eadfd4]/72 backdrop-blur-[18px]":void 0,closeClassName:"hidden",className:(0,q.cn)("flex h-[min(84dvh,800px)] w-[calc(100vw-10px)] max-w-[920px] flex-col overflow-hidden p-0 sm:w-[min(920px,calc(100vw-20px))]",U?"border-[#dfd2c5] bg-[linear-gradient(180deg,rgba(255,252,248,0.99),rgba(247,239,231,0.99))] text-[#3f2f24] shadow-[0_36px_120px_rgba(161,125,101,0.18)]":"border-white/10 bg-[linear-gradient(180deg,rgba(12,18,29,0.98),rgba(7,11,18,0.98))] text-slate-50 shadow-[0_36px_120px_rgba(0,0,0,0.48)]"),style:U?{colorScheme:"light"}:void 0,children:(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:(0,q.cn)("shrink-0 border-b px-4 py-2.5 pr-10",U?"border-[#e5d8cb] bg-[linear-gradient(180deg,rgba(255,252,248,0.98),rgba(244,235,224,0.96))]":"border-white/10 bg-[linear-gradient(180deg,rgba(14,20,34,0.98),rgba(9,13,24,0.99))]"),children:[(0,d.jsx)(v.rr,{className:"sr-only",children:"Create a new OpenClaw agent by choosing a starter mode, editing profile and policy, and saving the workspace agent."}),"start"===aa?(0,d.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(v.L3,{className:(0,q.cn)("text-[18px] font-medium sm:text-[20px]",U?"text-[#37291f]":"text-white"),children:"Create New Agent"}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[12px] leading-4",U?"text-[#9a8574]":"text-slate-500"),children:"Choose a starting point."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("div",{className:(0,q.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1 text-[11px]",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7e6554]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium",U?"bg-[#eadccf] text-[#6f5646]":"bg-white/10 text-slate-200"),children:"1"}),(0,d.jsx)("span",{children:"Start"})]}),(0,d.jsx)(v.HM,{asChild:!0,children:(0,d.jsx)("button",{type:"button","aria-label":"Close dialog",className:(0,q.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7b6657] hover:bg-[#f2e8df] hover:text-[#3f2f24]":"border-white/10 bg-white/[0.04] text-slate-300 hover:bg-white/[0.08] hover:text-white"),children:(0,d.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:[(0,d.jsx)("path",{d:"M18 6 6 18"}),(0,d.jsx)("path",{d:"m6 6 12 12"})]})})})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,d.jsx)(v.L3,{className:(0,q.cn)("text-[15px] font-medium sm:text-[17px]",U?"text-[#37291f]":"text-white"),children:"Create New Agent"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(G,{labels:aG,activeIndex:aH,surfaceTheme:O,onStepClick:a=>{if(a>=E(ac,aa))return;let b=D(ac)[a];"Start"===b?ab("start"):"Preset"===b?ab("preset"):"Import"===b&&ab("import")}}),(0,d.jsx)(v.HM,{asChild:!0,children:(0,d.jsx)("button",{type:"button","aria-label":"Close dialog",className:(0,q.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7b6657] hover:bg-[#f2e8df] hover:text-[#3f2f24]":"border-white/10 bg-white/[0.04] text-slate-300 hover:bg-white/[0.08] hover:text-white"),children:(0,d.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:[(0,d.jsx)("path",{d:"M18 6 6 18"}),(0,d.jsx)("path",{d:"m6 6 12 12"})]})})})]})]}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1.5 max-w-[520px] text-[10px] leading-4",U?"text-[#8c7664]":"text-slate-500"),children:(S=ac,"start"===(T=aa)?"empty"===S?"Empty / Custom is selected. Continue to details.":"preset"===S?"Preset Library is selected. Click Next to browse presets.":"import"===S?"Import Agent is selected. Click Next to choose a source agent.":"Choose a starting point.":"preset"===T?"Pick a preset. Details come next.":"import"===T?"Select an existing agent to clone.":"empty"===S?"Custom baseline loaded. Finish the details and create it.":"preset"===S?"Preset baseline loaded. Finish the details and create it.":"import"===S?"Imported baseline loaded. Review and create.":"")})]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3.5",children:"start"===aa?(0,d.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-[804px] flex-col items-center justify-center space-y-3 py-6",children:[(0,d.jsxs)("div",{className:"grid w-full gap-4 md:grid-cols-3 md:justify-items-center lg:gap-5",children:[(0,d.jsx)(I,{icon:f.A,title:"Empty / Custom",description:"Start from scratch.",helper:"Fastest if you know the shape.",selected:"empty"===ac,surfaceTheme:O,onSelect:()=>aN("empty")}),(0,d.jsx)(I,{icon:g.A,title:"Preset Library",description:"Use a role template.",helper:"Good for common worker roles.",selected:"preset"===ac,surfaceTheme:O,onSelect:()=>aN("preset")}),(0,d.jsx)(I,{icon:h.A,title:"Import Agent",description:"Clone an existing agent.",helper:"Best when a baseline already exists.",selected:"import"===ac,surfaceTheme:O,onSelect:()=>aN("import")})]}),(0,d.jsx)("p",{className:(0,q.cn)("max-w-[760px] text-center text-[10px] leading-4",U?"text-[#8c7664]":"text-slate-500"),children:"Empty is the fastest path. Preset and import prefill the draft so you only adjust what matters."})]}):"preset"===aa?(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsx)(H,{title:"Browse presets",description:"Choose the role that fits the first job.",surfaceTheme:O,className:"min-w-0",children:(0,d.jsx)("div",{className:"mt-3.5 grid gap-3 sm:grid-cols-2 xl:grid-cols-2",children:p.bt.map(a=>(0,d.jsx)(s,{preset:a.value,active:ae===a.value,surfaceTheme:O,onClick:()=>{var b;af(b=a.value),av(a=>(0,A.nK)(a,b))}},a.value))})}),(0,d.jsx)(H,{title:"Selected preset",description:"This seeds the draft before details.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:(0,p.Cf)(ae).defaultEmoji}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:(0,p.Cf)(ae).label}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:(0,p.Cf)(ae).description})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsxs)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:[(0,p.Cf)(ae).tools.length," tools"]}),(0,d.jsxs)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:[(0,p.Cf)(ae).skillIds.length," skills"]}),(0,d.jsxs)(m.E,{variant:(0,o.A6)(ae).enabled?"success":"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:["Heartbeat ",(0,o.A6)(ae).enabled?(0,o.A6)(ae).every:"off"]})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:"The preset seeds the draft. You can fine-tune the name, model, policy, and heartbeat next."})]})})]}):"import"===aa?(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsx)(H,{title:"Import an existing agent",description:"Select an agent to clone.",surfaceTheme:O,className:"min-w-0",children:(0,d.jsxs)("div",{className:"mt-3.5 space-y-3",children:[(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(w.p,{value:ai,onChange:a=>aj(a.target.value),placeholder:"Search by name, id, workspace, preset, or model",className:F(O)})}),(0,d.jsx)("div",{className:"space-y-2.5",children:aF.length>0?aF.map(b=>(0,d.jsx)(J,{agent:b,workspaceName:a.workspaces.find(a=>a.id===b.workspaceId)?.name??b.workspaceId,selected:ag===b.id,surfaceTheme:O,onSelect:()=>(b=>{var c,d,e;let f=a.agents.find(a=>a.id===b);if(!f)return;let g=au.workspaceId||V,h=g===f.workspaceId?(0,y.XS)(a,f.workspaceId,f.id):[];ah(b),av((c=g,d=f,e=h,(0,A.TY)(c,{modelId:"unassigned"===d.modelId?"":d.modelId,name:(0,z.CK)(d),emoji:d.identity.emoji??"",theme:d.identity.theme??"",avatar:d.identity.avatar??"",policy:d.policy,heartbeat:(0,o.iq)(d.policy.preset,{enabled:d.heartbeat.enabled,every:d.heartbeat.every??void 0}),channelIds:e})))})(b.id)},b.id)):(0,d.jsx)("div",{className:(0,q.cn)("rounded-[20px] border border-dashed p-4 text-sm leading-6",U?"border-[#e1d5c8] bg-white text-[#7f6958]":"border-white/10 bg-white/[0.02] text-slate-400"),children:"No agents match this search. Clear the search or go back to choose another start."})})]})}),(0,d.jsx)(H,{title:"Import summary",description:"The selected agent seeds the draft.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:aD?(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:aD.identity.emoji??"\uD83E\uDD16"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:(0,z.CK)(aD)}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:aD.id})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:aE?.name??aD.workspaceId}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:(0,p.Cf)(aD.policy.preset).label}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:"unassigned"===aD.modelId?"default model":aD.modelId})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:"The cloned draft keeps the source baseline. You can adjust workspace-specific details next."})]}):(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border border-dashed p-4 text-sm leading-6",U?"border-[#e1d5c8] bg-white text-[#7f6958]":"border-white/10 bg-white/[0.02] text-slate-400"),children:"Choose an existing agent on the left. Its configuration will be cloned into the new draft."}),(0,d.jsx)(K,{surfaceTheme:O})]})})]}):(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsx)(H,{title:"Core details",description:"Name, workspace, and model.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(r,{label:"Display name",htmlFor:"create-agent-name",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-name",ref:at,value:au.name,onChange:a=>av(b=>({...b,name:a.target.value})),placeholder:aB.defaultName,className:F(O)})}),(0,d.jsx)(r,{label:"Workspace",htmlFor:"create-agent-workspace",surfaceTheme:O,children:(0,d.jsx)("select",{id:"create-agent-workspace",value:au.workspaceId,onChange:b=>av(c=>({...c,workspaceId:b.target.value,modelId:c.modelId.trim()?c.modelId:(0,A.nd)(a,b.target.value),channelIds:[]})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:a.workspaces.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))})}),(0,d.jsxs)(r,{label:"Model",htmlFor:"create-agent-model",surfaceTheme:O,children:[(0,d.jsxs)("select",{id:"create-agent-model",value:au.modelId,onChange:a=>av(b=>({...b,modelId:a.target.value})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:[(0,d.jsx)("option",{value:"",children:a.diagnostics.modelReadiness.defaultModelReady?"Use OpenClaw default":ay?`Use suggested model (${ay})`:"Choose a model"}),a.models.map(b=>{let c=(0,A.w6)(a,b.id);return(0,d.jsxs)("option",{value:b.id,children:[b.id,c?"":" (not ready)"]},b.id)})]}),aA?(0,d.jsx)("p",{className:(0,q.cn)("mt-2 text-[11px] leading-4",U?"text-[#9b5f34]":"text-amber-200/85"),children:aA}):null]}),(0,d.jsx)("p",{className:(0,q.cn)("text-[10px] leading-4",U?"text-[#9a8070]":"text-slate-500"),children:"OpenClaw generates the agent id automatically. Review it in the Summary panel."})]})}),(0,d.jsx)(H,{title:"Visual identity",description:"Emoji and display customization.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsx)(r,{label:"Emoji",htmlFor:"create-agent-emoji",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 select-none text-base leading-none",children:au.emoji||aB.defaultEmoji}),(0,d.jsx)(w.p,{id:"create-agent-emoji",value:au.emoji,onChange:a=>av(b=>({...b,emoji:a.target.value})),placeholder:aB.defaultEmoji,className:(0,q.cn)(F(O),"pl-9")})]})}),(0,d.jsxs)("button",{type:"button",onClick:()=>Z(a=>!a),className:(0,q.cn)("inline-flex items-center gap-1.5 text-[10px] uppercase tracking-[0.16em] transition-colors",U?"text-[#8b7462] hover:text-[#5d4331]":"text-slate-500 hover:text-slate-300"),children:[(0,d.jsx)(i.A,{className:(0,q.cn)("h-3 w-3 transition-transform duration-200",Y&&"rotate-90")}),Y?"Hide":"Show","theme & avatar"]}),Y?(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(r,{label:"Theme",htmlFor:"create-agent-theme",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-theme",value:au.theme,onChange:a=>av(b=>({...b,theme:a.target.value})),placeholder:aB.defaultTheme,className:F(O)})}),(0,d.jsx)(r,{label:"Avatar URL",htmlFor:"create-agent-avatar",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-avatar",value:au.avatar,onChange:a=>av(b=>({...b,avatar:a.target.value})),placeholder:"https://example.com/avatar.png",className:F(O)})})]}):null]})}),(0,d.jsx)(l.X,{snapshot:a,workspaceId:au.workspaceId,channelIds:au.channelIds,isSaving:ak,surfaceTheme:O,onChange:a=>av(b=>({...b,channelIds:a}))}),(0,d.jsx)(H,{title:"Heartbeat and policy",description:"Only override what you need.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,q.cn)("text-sm font-medium",U?"text-[#3f2f24]":"text-white"),children:"Heartbeat"}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-xs leading-5",U?"text-[#7f6958]":"text-slate-400"),children:"Enable only for periodic watch or triage agents."})]}),(0,d.jsx)("button",{type:"button",role:"switch","aria-checked":au.heartbeat.enabled,"aria-label":"Toggle heartbeat",onClick:()=>av(a=>({...a,heartbeat:a.heartbeat.enabled?{...a.heartbeat,enabled:!1}:{...a.heartbeat,enabled:!0,every:a.heartbeat.every||(0,o.A6)(a.policy.preset).every}})),className:(0,q.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2",U?au.heartbeat.enabled?"bg-[#c89e73] focus-visible:ring-[#c89e73]/40":"bg-[#ddd0c6] focus-visible:ring-[#c89e73]/40":au.heartbeat.enabled?"bg-cyan-400 focus-visible:ring-cyan-300/40":"bg-white/20 focus-visible:ring-cyan-300/40"),children:(0,d.jsx)("span",{className:(0,q.cn)("pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow-md ring-0 transition-transform duration-200",au.heartbeat.enabled?"translate-x-5":"translate-x-0")})})]}),au.heartbeat.enabled?(0,d.jsx)(r,{label:"Interval",htmlFor:"create-agent-heartbeat-every",surfaceTheme:O,children:(0,d.jsx)("select",{id:"create-agent-heartbeat-every",value:au.heartbeat.every,onChange:a=>av(b=>({...b,heartbeat:{...b.heartbeat,every:a.target.value}})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:o.MQ.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))})}):null,(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(t,{label:"Missing tool behavior",htmlFor:"create-agent-missing-tools",value:au.policy.missingToolBehavior,options:p.A_,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,missingToolBehavior:a}}))}),(0,d.jsx)(t,{label:"Install scope",htmlFor:"create-agent-install-scope",value:au.policy.installScope,options:p.sH,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,installScope:a}}))}),(0,d.jsx)(t,{label:"File access",htmlFor:"create-agent-file-access",value:au.policy.fileAccess,options:p.$x,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,fileAccess:a}}))}),(0,d.jsx)(t,{label:"Network access",htmlFor:"create-agent-network-access",value:au.policy.networkAccess,options:p.DS,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,networkAccess:a}}))})]})]})})]}),(0,d.jsx)("div",{className:"space-y-4",children:(0,d.jsx)(H,{title:"Summary",description:"Review the draft before creating.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:au.emoji||aB.defaultEmoji}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:au.name||aB.defaultName}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:ax?.name??"No workspace selected"})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:"empty"===ac?"Empty / Custom":"preset"===ac?`${(0,p.Cf)(ae).label} preset`:"import"===ac?"Imported agent":"Start a flow"}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:au.modelId||ay||"OpenClaw default"}),(0,d.jsxs)(m.E,{variant:au.heartbeat.enabled?"success":"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:["Heartbeat ",au.heartbeat.enabled?au.heartbeat.every:"off"]})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsxs)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[10px] uppercase tracking-[0.18em]",U?"text-[#8b7462]":"text-slate-500"),children:"Generated id"}),(0,d.jsx)("code",{className:(0,q.cn)("mt-1.5 block break-all rounded-2xl border px-3 py-1.5 text-[11px]",U?"border-[#dccfc3] bg-white text-[#4d392e]":"border-white/10 bg-white/5 text-slate-200"),children:aC||"unavailable"})]})]})})})]})}),(0,d.jsx)(v.Es,{className:(0,q.cn)("shrink-0 border-t px-6 py-4",U?"border-[#e5d8cb] bg-[#faf6f1]":"border-white/10 bg-transparent"),children:(0,d.jsxs)("div",{className:"flex w-full flex-col gap-3",children:[aK?(0,d.jsxs)("div",{className:(0,q.cn)("inline-flex items-start gap-2 rounded-2xl border px-3 py-2 text-[11px] leading-4",U?"border-[#ddcfbf] bg-white text-[#6e5646]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,d.jsx)(j.A,{className:"mt-0.5 h-3.5 w-3.5 animate-spin shrink-0"}),(0,d.jsx)("span",{children:aK})]}):null,(0,d.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>aM(!1),disabled:ak,className:U?"border-[#d8c7b8] bg-white text-[#4d392f] hover:bg-[#f5efe9]":void 0,children:"Cancel"}),(0,d.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center",children:["start"!==aa?(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{"details"===aa?ab("empty"===ac?"start":ac??"start"):("preset"===aa||"import"===aa)&&ab("start")},disabled:ak,className:U?"border-[#d8c7b8] bg-white text-[#4d392f] hover:bg-[#f5efe9]":void 0,children:"Back"}):null,(0,d.jsx)(u.$,{type:"button",size:"sm",onClick:()=>{"details"===aa?aO():(()=>{if("start"===aa){if(!ac)return;if("empty"===ac)return ab("details");if("preset"===ac){av(a=>(0,A.nK)(a,ae)),ab("preset");return}return ab(ac)}if("preset"===aa)return ab("details");if("import"===aa){if(!ag)return;ab("details")}})()},disabled:!aJ,className:U?"bg-[#c89e73] text-white shadow-[0_10px_26px_rgba(161,125,101,0.22)] hover:bg-[#b47f53]":void 0,children:"details"===aa?ak?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"syncing"===am?"Syncing canvas...":"Creating..."]}):"Create agent":"start"===aa&&"empty"===ac?"Continue":"Next"})]})]})]})})]})})]}):(0,d.jsx)(d.Fragment,{children:N})}function C(a,b){return(0,A.nK)((0,A.TY)(a,{modelId:(0,A.nd)(b,a)}),"custom")}function D(a){return a?"empty"===a?["Start","Details"]:"preset"===a?["Start","Preset","Details"]:["Start","Import","Details"]:["Start"]}function E(a,b){return a&&"start"!==b?"details"===b?"empty"===a?1:2:1:0}function F(a){return(0,q.cn)("flex h-10 w-full rounded-2xl border px-3.5 py-2 text-[13px] outline-none transition-colors","light"===a?"border-[#dccfc3] bg-white text-[#3f2f24] placeholder:text-[#9b8573] focus:border-[#c89e73] focus:ring-2 focus:ring-[#c89e73]/15":"border-white/10 bg-white/5 text-white placeholder:text-slate-500 focus:border-cyan-300/30 focus:ring-2 focus:ring-cyan-300/15")}function G({labels:a,activeIndex:b,surfaceTheme:c="dark",onStepClick:e}){let f="light"===c;return(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:a.map((a,c)=>{let g=c===b,h=c<b,i=h&&!!e,j=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[9px] font-medium",g?f?"bg-[#c89e73]/15 text-[#5d4331]":"bg-cyan-300/20 text-cyan-50":h?f?"bg-[#f0e7de] text-[#7a6556]":"bg-emerald-300/20 text-emerald-50":f?"bg-[#f2ece6] text-[#917866]":"bg-white/10 text-slate-400"),children:c+1}),(0,d.jsx)("span",{children:a})]}),k=(0,q.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[10px] transition-colors",g?f?"border-[#c89e73]/35 bg-[#f8efe4] text-[#5d4331]":"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":h?f?"border-[#dccfc3] bg-white text-[#7e6757]":"border-emerald-300/20 bg-emerald-400/10 text-emerald-50":f?"border-[#e6dbd0] bg-white/80 text-[#8b7563]":"border-white/10 bg-white/[0.04] text-slate-400",i&&(f?"cursor-pointer hover:border-[#c89e73]/50 hover:bg-[#faf3ea]":"cursor-pointer hover:border-emerald-300/30 hover:bg-emerald-400/15"));return i?(0,d.jsx)("button",{type:"button",onClick:()=>e?.(c),className:k,children:j},`${a}-${c}`):(0,d.jsx)("div",{className:k,children:j},`${a}-${c}`)})})}function H({title:a,description:b,children:c,className:e,surfaceTheme:f="dark"}){let g="light"===f;return(0,d.jsxs)("section",{className:(0,q.cn)("rounded-[22px] border p-3.5",g?"border-[#e2d5c9] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03] shadow-[0_14px_34px_rgba(0,0,0,0.18)]",e),children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[13px] font-medium",g?"text-[#3f2f24]":"text-white"),children:a}),b?(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[11px] leading-4",g?"text-[#7f6958]":"text-slate-400"),children:b}):null]})}),(0,d.jsx)("div",{className:"mt-3 min-w-0",children:c})]})}function I({icon:a,title:b,description:c,helper:e,selected:f,surfaceTheme:g="dark",onSelect:h}){let j="light"===g;return(0,d.jsxs)("button",{type:"button",onClick:h,"aria-pressed":f,className:(0,q.cn)("flex w-full min-h-[272px] flex-col rounded-[28px] border p-3.5 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 md:max-w-[248px]",j?"focus-visible:ring-[#c89e73]/30":"focus-visible:ring-cyan-300/40",f?j?"border-[#d7c1ae] bg-[#fdf7ef] shadow-[0_14px_28px_rgba(161,125,101,0.08)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.1)]":j?"border-[#e7dbcf] bg-[rgba(255,252,247,0.9)] shadow-[0_10px_24px_rgba(161,125,101,0.05)] hover:border-[#d9c7b8] hover:bg-[#fffdf9]":"border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsx)("div",{className:(0,q.cn)("inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-[18px] border",j?"border-[#e0d3c6] bg-[#faf6f0] text-[#7a5f4c]":"border-white/10 bg-white/5 text-white"),children:(0,d.jsx)(a,{className:"h-[17px] w-[17px]"})}),(0,d.jsx)(m.E,{variant:f?"default":"muted",className:(0,q.cn)("shrink-0 rounded-full px-2.5 py-0.5 text-[9px] normal-case tracking-normal",j?f?"border-[#d7c1ae] bg-[#f3e5d8] text-[#6a4b38]":"border-[#e3d6c8] bg-[rgba(255,255,255,0.82)] text-[#8a6f5d]":""),children:f?"Selected":"Available"})]}),(0,d.jsxs)("div",{className:"mt-6 space-y-1.5",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[15px] font-medium leading-5",j?"text-[#413126]":"text-white"),children:b}),(0,d.jsx)("p",{className:(0,q.cn)("text-[12px] leading-5",j?"text-[#8a7463]":"text-slate-400"),children:c})]}),(0,d.jsx)("div",{className:"mt-auto pt-6",children:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("max-w-[116px] text-[9px] uppercase leading-[1.35] tracking-[0.2em]",j?"text-[#9a8572]":"text-slate-500"),children:e}),(0,d.jsxs)("span",{className:(0,q.cn)("inline-flex items-center gap-1 text-[9px] uppercase tracking-[0.18em]",j?"text-[#7f6958]":"text-slate-400"),children:["Select",(0,d.jsx)(i.A,{className:"h-3 w-3"})]})]})})]})}function J({agent:a,workspaceName:b,selected:c,surfaceTheme:e="dark",onSelect:f}){let g=(0,p.Cf)(a.policy.preset),h="unassigned"===a.modelId?"default model":a.modelId,j="light"===e;return(0,d.jsxs)("button",{type:"button",onClick:f,"aria-pressed":c,className:(0,q.cn)("flex w-full flex-col rounded-[22px] border p-3.5 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2",j?"focus-visible:ring-[#c89e73]/30":"focus-visible:ring-cyan-300/40",c?j?"border-[#c89e73]/45 bg-[#fff8f0] shadow-[0_16px_40px_rgba(161,125,101,0.12)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.1)]":j?"border-[#e3d7cc] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)] hover:border-[#d4c2b4] hover:bg-white":"border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border text-[15px]",j?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5"),children:a.identity.emoji??"\uD83E\uDD16"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",j?"text-[#3f2f24]":"text-white"),children:(0,z.CK)(a)}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 truncate text-[11px] leading-4",j?"text-[#7f6958]":"text-slate-500"),children:a.id})]})]}),(0,d.jsx)(m.E,{variant:c?"default":"muted",className:(0,q.cn)("shrink-0 px-2 py-0.5 text-[9px] normal-case tracking-normal",j?c?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":"border-[#e1d5c8] bg-white text-[#846a58]":""),children:c?"Selected":g.label})]}),(0,d.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:b}),(0,d.jsx)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:h}),(0,d.jsx)(m.E,{variant:"ready"===a.status?"success":"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"ready"===a.status?"border-emerald-300/40 bg-emerald-100 text-emerald-800":"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:a.status})]}),(0,d.jsx)("p",{className:(0,q.cn)("mt-3 text-[12px] leading-5",j?"text-[#7f6958]":"text-slate-400"),children:g.description}),(0,d.jsxs)("div",{className:"mt-3.5 flex items-center justify-between gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("text-[10px] uppercase tracking-[0.16em]",j?"text-[#8b7462]":"text-slate-500"),children:"Import this agent as a new draft"}),(0,d.jsxs)("span",{className:(0,q.cn)("inline-flex items-center gap-1 text-[10px] uppercase tracking-[0.16em]",j?"text-[#7f6958]":"text-slate-400"),children:["Select",(0,d.jsx)(i.A,{className:"h-3 w-3"})]})]})]})}function K({surfaceTheme:a}){let b="light"===a;return(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-3 text-[11px] leading-5",b?"border-[#e2d5c9] bg-[#faf6f1] text-[#6f5849]":"border-white/10 bg-white/[0.03] text-slate-400"),children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)(k.A,{className:(0,q.cn)("mt-0.5 h-3.5 w-3.5 shrink-0",b?"text-[#8b6d56]":"text-cyan-200")}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[12px] font-medium",b?"text-[#3f2f24]":"text-slate-100"),children:"Workspace-root context"}),(0,d.jsxs)("p",{className:"mt-1",children:["This agent profile is written to the workspace root ",(0,d.jsx)("code",{children:"AGENTS.md"}),". OpenClaw loads that file as shared runtime context."]})]})]})})}},98895:(a,b,c)=>{"use strict";function d(a){let b="clone"===a.sourceMode?{label:"Cloning repository",description:"The repository is being cloned before workspace files are added."}:"existing"===a.sourceMode?{label:"Attaching existing folder",description:"AgentOS is validating the existing directory and preparing it for bootstrap."}:{label:"Preparing workspace folder",description:"A fresh workspace directory is being created inside the configured workspace root."};return{title:"Provisioning workspace",description:"AgentOS is creating the workspace and reporting each real bootstrap step as it finishes.",steps:[{id:"validate",label:"Checking input and target path",description:"Workspace input, agent ids, and the destination directory are being validated."},{id:"source",label:b.label,description:b.description},{id:"scaffold",label:"Scaffolding workspace files",description:"Core docs, local state, starter memory, and shared workspace metadata are being written."},{id:"agents",label:1===a.agentCount?"Creating the first agent":"Creating workspace agents",description:1===a.agentCount?"The primary agent is being provisioned and linked to the workspace.":"Each enabled agent is being provisioned and linked to the workspace."},{id:"kickoff",label:a.kickoffMission?"Running kickoff mission":"Finalizing workspace",description:a.kickoffMission?"The primary agent is inspecting the new workspace and refining the initial setup.":"Workspace bootstrap is wrapping up without a kickoff mission."}]}}function e(a){return{title:"Deploying workspace",description:"The planner is turning the blueprint into a live workspace and streaming each deploy stage.",steps:[{id:"plan",label:"Locking deploy plan",description:"Deploy blockers are being checked and the planner state is being locked for launch."},...d({sourceMode:a.sourceMode,agentCount:a.agentCount,kickoffMission:a.kickoffMission}).steps,{id:"blueprint",label:"Writing planner files",description:"Planner blueprint, company notes, and workflow docs are being written into the workspace."},{id:"channels",label:a.hasChannels?"Provisioning channels":"Checking channels",description:a.hasChannels?"Enabled external channels are being provisioned and connected.":"No external channels are enabled, so this stage will pass quickly."},{id:"automations",label:a.hasAutomations?"Provisioning automations":"Checking automation loops",description:a.hasAutomations?"Enabled recurring loops are being attached to their target agents.":"No recurring automations are enabled, so this stage is mostly validation."},{id:"planner-kickoff",label:a.hasPlannerKickoffs?"Running planner kickoff missions":"Finalizing deploy",description:a.hasPlannerKickoffs?"The first missions are being dispatched so the new workspace starts with clear momentum.":"The workspace is being finalized and the deploy request is wrapping up."}]}}function f(a){return{title:a.title,description:a.description,percent:0,steps:a.steps.map(a=>({...a,status:"pending",percent:0,activities:[]}))}}c.d(b,{Bb:()=>e,fV:()=>d,sg:()=>f})}};
|
|
185
|
+
${c.source}`):v;return t&&w(d),"basic"===g&&j(a=>{let b=a?bY(a,c,r,{template:d,modelProfile:z}):a;return ad.current=b,b}),c})},[z,r,v,t,g]),aD=(0,p.useCallback)(a=>{q(b=>{let c={...b,name:a};return"basic"===g&&j(a=>{let b=a?bY(a,c,r,{template:v,modelProfile:z}):a;return ad.current=b,b}),c})},[z,r,v,g]),aE=(0,p.useCallback)(a=>{u(!1),w(a),j(b=>{let c=b?bY(b,o,r,{template:a,modelProfile:z}):b;return ad.current=c,c})},[o,z,r]),aF=(0,p.useCallback)(a=>{y(a)},[]),aG=(0,p.useCallback)(a=>{A(a),j(b=>{let c=b?bY(b,o,r,{template:v,modelProfile:a}):b;return ad.current=c,c})},[o,r,v]),aH=(0,p.useCallback)(a=>{let b=bW(a);s(b),j(a=>{let c=a?bY(a,o,b,{template:v,modelProfile:z}):a;return ad.current=c,c})},[o,z,v]),aI=(0,p.useCallback)(a=>{s(b=>{let c={...b,[a]:!b[a],workspaceOnly:!0};return j(a=>{let b=a?bY(a,o,c,{template:v,modelProfile:z}):a;return ad.current=b,b}),c})},[o,z,v]);return{mode:g,plan:i,planId:k,hasStoredDraft:m,notice:B,sourceAnalysis:ag,basicDraft:o,basicRules:r,basicPreset:ah,basicTemplate:v,basicTeamPreset:x,basicModelProfile:z,isPlanLoading:D,isSending:F,isSaving:H,isSimulating:J,isDeploying:M,isCreating:O,isApplyingWorkspaceChanges:S,isDocumentRewriting:Q,createProgress:X,deployProgress:V,architectBusyStatus:ai,pendingUserMessage:aa,setBasicGoal:aB,setBasicSource:aC,setBasicName:aD,setBasicTemplate:aE,setBasicTeamPreset:aF,setBasicModelProfile:aG,setBasicPreset:aH,toggleBasicRule:aI,setNotice:C,updatePlan:ak,switchMode:aA,startFreshDraft:ap,discardStoredDraft:aq,resumeStoredDraft:az,savePlan:ar,simulatePlan:as,requestReview:at,createWorkspace:au,deployPlan:aw,applyWorkspaceChanges:av,submitArchitectTurn:ax,rewriteDocumentWithArchitect:ay}}({open:a,initialMode:c,workspaceEditId:k,onRefresh:n,onWorkspaceCreated:o,onWorkspaceUpdated:q}),[v,w]=(0,p.useState)(""),[x,y]=(0,p.useState)(!1),[z,A]=(0,p.useState)(!1),[B,C]=(0,p.useState)(!1),[D,E]=(0,p.useState)("intake"),[F,G]=(0,p.useState)("workspace.name"),[H,I]=(0,p.useState)("AGENTS.md"),J="light"===l,K=r?m.workspaces.find(a=>a.id===k)??null:null,M=a=>{a||(w(""),y(!1),A(!1),C(!1),E("intake"),G("workspace.name"),I("AGENTS.md")),b(a)},N=r?t.plan?.workspace.name??K?.name??bN(t.basicDraft):bN(t.basicDraft),O=r?t.plan?.workspace.template??K?.bootstrap.template??t.basicTemplate:t.plan?.workspace.template??t.basicTemplate,P=r?t.plan?.workspace.directory??K?.path??m.diagnostics.workspaceRoot:function(a,b,c=bL(b.source)){if("existing"===c.kind&&c.existingPath)return c.existingPath;let d=bN(b).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return`${(0,bI.$7)(a)}/${d||"workspace"}`}(m.diagnostics.workspaceRoot,t.basicDraft,t.sourceAnalysis),Q=(0,p.useMemo)(()=>(function(a,b,c,d){let e=[{id:"surface",label:c?"Editing workspace":"basic"===a?"Architect-assisted fast path":"Architect co-design",tone:"muted"}];return!c&&"basic"===a&&d&&e.push({id:"step",label:`Step ${b6.findIndex(a=>a.id===d)+1} / 3 \xb7 ${b6.find(a=>a.id===d)?.label??"Intake"}`,tone:"muted"}),b&&("basic"===a?b.intake.confirmations.length>0?e.push({id:"confirmations",label:`${b.intake.confirmations.length} decision${1===b.intake.confirmations.length?"":"s"} needed`,tone:b.intake.confirmations.length>1?"warning":"muted"}):b.intake.started&&e.push({id:"draft",label:"Draft synced live",tone:"muted"}):(b.intake.confirmations.length>0&&e.push({id:"confirmations",label:`${b.intake.confirmations.length} decision${1===b.intake.confirmations.length?"":"s"} needed`,tone:b.intake.confirmations.length>1?"warning":"muted"}),e.push({id:"stage",label:`Stage \xb7 ${aw(b.stage)}`,tone:"muted"}),e.push({id:"readiness",label:`${b.readinessScore}% drafted`,tone:b.readinessScore>=85?"success":b.readinessScore>=45?"warning":"muted"}),e.push({id:"status",label:`Status \xb7 ${b.status}`,tone:"blocked"===b.status?"danger":"ready"===b.status||"deployed"===b.status?"success":"review"===b.status?"warning":"muted"}))),e})(t.mode,t.plan,r,D),[D,r,t.mode,t.plan]),R=(0,p.useMemo)(()=>{var a,b;let c;return a=t.plan,b=t.pendingUserMessage,c=a?.conversation.map(a=>({id:a.id,role:a.role,author:"assistant"===a.role?"Architect":"system"===a.role?"Workspace Wizard":a.author,text:a.text}))??[],b?.trim()&&c.push({id:"pending-user-message",role:"user",text:b.trim(),status:"pending"}),c},[t.pendingUserMessage,t.plan]),S=(0,p.useMemo)(()=>{for(let a=R.length-1;a>=0;a-=1){let b=R[a];if("assistant"===b.role&&"Architect"===b.author)return b.id}return null},[R]),T=t.isCreating?t.createProgress:t.isDeploying?t.deployProgress:null,U=t.isSending||t.isPlanLoading||t.isDeploying||t.isCreating||t.isDocumentRewriting||t.isApplyingWorkspaceChanges,V="basic"===t.mode&&t.hasStoredDraft&&!t.plan&&!t.isPlanLoading,W=r?!!(t.plan||v.trim()):!!(t.plan?.intake.started||t.basicDraft.goal.trim()||v.trim()),X=!!(t.plan?.intake.started||t.basicDraft.name.trim()||t.basicDraft.goal.trim()||t.basicDraft.source.trim()||v.trim()),Y=async a=>{let b=(a??v).trim();if(!b)return!1;let c=void 0===a;c&&w("");let d=await t.submitArchitectTurn(b);return!d&&c&&w(v),d},$=async()=>{if(r){if(!(!v.trim()||await Y()))return;await t.applyWorkspaceChanges()&&M(!1);return}(!v.trim()||await Y())&&await t.createWorkspace()&&M(!1)},aa=async()=>{r||await t.deployPlan()&&M(!1)},ab=async(a,b)=>{let c=b.trim()?{...a,conversation:[...a.conversation,bg("system","Workspace Wizard",b)]}:a;return t.savePlan(c)},ac=async(a,b)=>{let c=b.trim()?{...a,conversation:[...a.conversation,bg("system","Workspace Wizard",b)]}:a;return t.savePlan(c)},ad=(a="workspace.name")=>{G(a),y(!1),A(!0),C(!1)},ae=a=>{I(a),y(!1),A(!1),C(!0)};return(0,d.jsx)(a8.lG,{open:a,onOpenChange:M,children:(0,d.jsxs)(a8.Cf,{className:J?"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-[#e7dfd4] bg-[#fcfaf6] p-0 text-[#161411] shadow-[0_40px_140px_rgba(16,12,8,0.45)]":"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-white/10 bg-[rgba(4,8,15,0.96)] p-0 text-white shadow-[0_40px_140px_rgba(0,0,0,0.58)]",children:[(0,d.jsx)(a8.L3,{className:"sr-only",children:r?"Edit workspace":"Create workspace"}),(0,d.jsx)(a8.rr,{className:"sr-only",children:r?"Edit the existing workspace blueprint, documents, and agents using Architect.":"Create a workspace in Basic or Advanced mode using the Architect wizard."}),(0,d.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",children:[(0,d.jsx)("div",{className:J?"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.86),transparent_34%),linear-gradient(180deg,rgba(248,244,237,0.92),rgba(252,250,246,0.86)_24%,rgba(244,238,230,0.82)_100%)]":"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(59,130,246,0.14),transparent_28%),radial-gradient(circle_at_80%_18%,rgba(56,189,248,0.12),transparent_24%),linear-gradient(180deg,rgba(9,15,27,0.98),rgba(4,8,15,0.96)_28%,rgba(2,6,13,0.98)_100%)]"}),(0,d.jsx)(a0,{surfaceTheme:l,mode:t.mode,onModeChange:a=>{t.switchMode(a)},onNewDraft:r?void 0:()=>{w(""),y(!1),A(!1),C(!1),E("intake"),t.startFreshDraft()},title:r?"Edit workspace":"Create workspace",showModeToggle:!r,showNewDraft:!r,badges:Q}),(0,d.jsxs)("div",{className:"relative z-[1] grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr),390px] xl:grid-cols-[minmax(0,1fr),420px]",children:[(0,d.jsx)("div",{className:J?"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))]":"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(8,13,24,0.2),rgba(6,10,18,0.42))]",children:"basic"!==t.mode||r?(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.architectBusyStatus?(0,d.jsx)("div",{className:J?"border-b border-[#ece5db] px-4 py-2.5 md:px-5":"border-b border-white/10 px-4 py-2.5 md:px-5",children:(0,d.jsxs)("div",{className:J?"rounded-2xl border border-[#e6dfd5] bg-white px-3 py-2":"rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2",children:[(0,d.jsx)("p",{className:J?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:t.architectBusyStatus.title}),(0,d.jsx)("p",{className:J?"mt-1 text-[12px] leading-5 text-[#6d665e]":"mt-1 text-[12px] leading-5 text-slate-300",children:t.architectBusyStatus.description})]})}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1",children:(0,d.jsx)(a4,{surfaceTheme:l,messages:R,architectMessageId:S,architectPlan:t.plan,isTyping:t.isSending,typingLabel:"Architect is shaping the next pass...",emptyState:t.isPlanLoading&&0===R.length?(0,d.jsx)(b2,{surfaceTheme:l}):0===R.length&&"basic"===t.mode?(0,d.jsx)(b0,{surfaceTheme:l}):0===R.length?(0,d.jsx)(b1,{surfaceTheme:l}):null,auxiliary:(0,d.jsxs)(d.Fragment,{children:[V?(0,d.jsx)(b4,{surfaceTheme:l,isBusy:U,onResume:()=>{t.resumeStoredDraft()},onStartFresh:t.discardStoredDraft}):null,T?(0,d.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,d.jsx)(s,{progress:T,className:J?"border-[#e6dfd5] bg-white":"border-white/10 bg-slate-950/50"})}):null]})})}),(0,d.jsx)("div",{className:J?"border-t border-[#ece5db] bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))] px-4 py-4 md:px-5":"border-t border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.68),rgba(4,8,15,0.94))] px-4 py-4 md:px-5",children:(0,d.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,d.jsx)(a3,{surfaceTheme:l,value:v,onChange:w,onSubmit:async()=>{await Y()},placeholder:r?"Tell Architect what to change in this workspace...":"basic"===t.mode?"Describe what this workspace should do...":"Refine the blueprint with Architect...",disabled:U,isBusy:t.isSending,helperText:r?"Architect updates the existing workspace draft as you chat.":"basic"===t.mode?"Architect keeps the fast-path draft synced as you chat.":"Architect updates the shared blueprint on every turn.",toolbar:r?(0,d.jsx)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Editing draft"}):"basic"!==t.mode||t.plan?t.plan?(0,d.jsxs)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:["Stage \xb7 ",aw(t.plan.stage)]}):null:(0,d.jsx)("span",{className:J?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Live draft"})})})})]}):(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 md:px-5",children:(0,d.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4",children:[V?(0,d.jsx)(b4,{surfaceTheme:l,isBusy:U,onResume:()=>{t.resumeStoredDraft()},onStartFresh:t.discardStoredDraft}):null,t.isPlanLoading?(0,d.jsx)(b2,{surfaceTheme:l}):(0,d.jsx)(b0,{surfaceTheme:l}),(0,d.jsx)(b7,{surfaceTheme:l,step:D,isBusy:U,basicDraft:t.basicDraft,basicTemplate:t.basicTemplate,basicTeamPreset:t.basicTeamPreset,basicModelProfile:t.basicModelProfile,basicRules:t.basicRules,basicPreset:t.basicPreset,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,onStepChange:E,onBasicNameChange:t.setBasicName,onBasicGoalChange:t.setBasicGoal,onBasicSourceChange:t.setBasicSource,onBasicTemplateChange:t.setBasicTemplate,onBasicTeamPresetChange:t.setBasicTeamPreset,onBasicModelProfileChange:t.setBasicModelProfile,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule})]})})})}),(0,d.jsx)(aQ,{className:"hidden lg:block",surfaceTheme:l,workspaceMode:r?"edit":"create",mode:t.mode,snapshot:m,plan:t.plan,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,notice:t.notice,basicRules:t.basicRules,basicPreset:t.basicPreset,onOpenBlueprintEditor:ad,onOpenDocumentEditor:ae,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule,progress:r?null:"basic"===t.mode?t.createProgress:t.isDeploying?t.deployProgress:null})]}),x?(0,d.jsxs)("div",{className:J?"absolute inset-0 z-20 flex flex-col bg-[rgba(22,18,14,0.18)] backdrop-blur-sm lg:hidden":"absolute inset-0 z-20 flex flex-col bg-[rgba(2,6,13,0.56)] backdrop-blur-sm lg:hidden",children:[(0,d.jsxs)("div",{className:J?"flex items-center justify-between border-b border-[#e7dfd4] bg-[#fcfaf6] px-4 py-3":"flex items-center justify-between border-b border-white/10 bg-[rgba(4,8,15,0.96)] px-4 py-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:J?"text-[11px] uppercase tracking-[0.18em] text-[#9f958a]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"basic"===t.mode?"Workspace draft":"Workspace blueprint"}),(0,d.jsx)("p",{className:J?"text-[13px] text-[#6f675e]":"text-[13px] text-slate-300",children:"Review the structured side of the same wizard."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[t.plan?(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>ad(),className:J?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit details"}):null,(0,d.jsx)("button",{type:"button",onClick:()=>y(!1),className:J?"inline-flex size-9 items-center justify-center rounded-full border border-[#e4ddd3] bg-white text-[#4f4943] transition-colors hover:bg-[#f4efe7]":"inline-flex size-9 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-200 transition-colors hover:bg-white/[0.08]",children:(0,d.jsx)(e.A,{className:"h-4 w-4"})})]})]}),(0,d.jsx)(aQ,{className:"min-h-0 flex-1 border-t-0 lg:hidden",surfaceTheme:l,workspaceMode:r?"edit":"create",mode:t.mode,snapshot:m,plan:t.plan,resolvedName:N,resolvedTemplate:O,sourceAnalysis:t.sourceAnalysis,workspacePath:P,notice:t.notice,basicRules:t.basicRules,basicPreset:t.basicPreset,onOpenBlueprintEditor:ad,onOpenDocumentEditor:ae,onBasicPresetChange:t.setBasicPreset,onBasicRuleToggle:t.toggleBasicRule,progress:r?null:"basic"===t.mode?t.createProgress:t.isDeploying?t.deployProgress:null})]}):null,z&&t.plan?(0,d.jsx)(_,{open:z,surfaceTheme:l,plan:t.plan,busy:t.isSaving,focus:F,onClose:()=>A(!1),onSave:ab},`${t.plan.id}:${F}`):null,B&&t.plan?(0,d.jsx)(ak,{open:B,surfaceTheme:l,plan:t.plan,path:H,busy:t.isSaving,rewriteBusy:t.isDocumentRewriting,onClose:()=>C(!1),onSave:ac,onRewriteWithArchitect:t.rewriteDocumentWithArchitect},`${t.plan.id}:${H}`):null,(0,d.jsx)("div",{className:J?"relative z-[1] border-t border-[#e7dfd4] bg-white/90 px-4 py-3 backdrop-blur-sm md:px-5":"relative z-[1] border-t border-white/10 bg-[rgba(4,8,15,0.88)] px-4 py-3 backdrop-blur-sm md:px-5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,d.jsx)("p",{className:J?"text-[13px] text-[#776f65]":"text-[13px] text-slate-300",children:"basic"===t.mode?"intake"===D?"Step 1 of 3. Capture the mission and source first.":"shape"===D?"Step 2 of 3. Pick the template and default shape.":"Step 3 of 3. Review the draft before creating.":"Chat and blueprint stay synced as you refine the plan."}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3] lg:hidden":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08] lg:hidden",onClick:()=>y(!0),children:[(0,d.jsx)(f.A,{className:"mr-2 h-4 w-4"}),"View blueprint"]}),r?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void t.savePlan(),disabled:!t.plan||t.isSaving||t.isPlanLoading,children:[t.isSaving?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void $(),disabled:!W||t.isPlanLoading||t.isSending||t.isSaving||t.isApplyingWorkspaceChanges,children:[t.isApplyingWorkspaceChanges?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}):"basic"===t.mode?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:"intake"===D?()=>{t.switchMode("advanced")}:()=>{"shape"===D?E("intake"):"review"===D&&E("shape")},disabled:t.isCreating||t.isSending||t.isPlanLoading,children:"intake"===D?"Advanced details":"Back"}),(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>{"intake"===D?E("shape"):"shape"===D?E("review"):$()},disabled:t.isCreating||t.isSending||t.isPlanLoading||"review"===D&&!X,children:["review"===D?t.isCreating?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(h.A,{className:"mr-2 h-4 w-4"}):(0,d.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"intake"===D?"Continue":"shape"===D?"Review draft":"Create workspace"]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(u.$,{variant:"secondary",size:"sm",className:J?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void t.savePlan(),disabled:!t.plan||t.isSaving||t.isPlanLoading,children:[t.isSaving?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),t.plan?.intake.reviewRequested?(0,d.jsxs)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void aa(),disabled:!t.plan||t.plan.deploy.blockers.length>0||t.isDeploying||t.isPlanLoading,children:[t.isDeploying?(0,d.jsx)(g.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,d.jsx)(j.A,{className:"mr-2 h-4 w-4"}),"Deploy workspace"]}):(0,d.jsx)(u.$,{size:"sm",className:J?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>t.requestReview(),disabled:!t.plan||t.isSending||t.isDeploying,children:"Review blueprint"})]})]})]})})]})]})})}function b0({surfaceTheme:a}){let b="light"===a;return(0,d.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.22em]",b?"text-[#8b7262]":"text-slate-500"),children:"Fast path"}),(0,d.jsx)("p",{className:b?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Start with one prompt."}),(0,d.jsx)("p",{className:b?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Tell Architect what this workspace should do. It will reflect the intent back and ask the next critical question."})]})}function b1({surfaceTheme:a}){let b="light"===a;return(0,d.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.22em]",b?"text-[#8b7262]":"text-slate-500"),children:"Blueprint mode"}),(0,d.jsx)("p",{className:b?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Shape the workspace with Architect."}),(0,d.jsx)("p",{className:b?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Describe the operating model, and the structured draft updates as you chat."})]})}function b2({surfaceTheme:a}){return(0,d.jsxs)("div",{className:"light"===a?"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-[#e6dfd5] bg-white px-4 py-3 text-[13px] text-[#6d665e]":"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.04] px-4 py-3 text-[13px] text-slate-300",children:[(0,d.jsx)(g.A,{className:"h-4 w-4 animate-spin"}),"Architect is opening the planning session and extracting intent from the latest brief."]})}function b3({surfaceTheme:a,name:b,goal:c,source:e,resolvedName:f,resolvedTemplate:g,workspacePath:i,sourceAnalysis:j,disabled:o,onNameChange:p,onGoalChange:q,onSourceChange:s}){let t="light"===a,u="clone"===j.kind?k.A:"website"===j.kind?l.A:m.A;return(0,d.jsxs)("div",{className:(0,r.cn)("mx-auto w-full rounded-[24px] border p-4 shadow-[0_18px_56px_rgba(56,47,38,0.06)] md:p-5",t?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",t?"border-[#e4ddd3] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:t?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Step 1 \xb7 Intake"}),(0,d.jsx)("p",{className:t?"mt-1 text-[12px] leading-5 text-[#70685f]":"mt-1 text-[12px] leading-5 text-slate-300",children:"Give Architect the mission and source. The name can stay optional."})]})]}),(0,d.jsxs)("div",{className:"mt-4 grid gap-3",children:[(0,d.jsx)(b5,{surfaceTheme:a,label:"Workspace name",children:(0,d.jsx)(v.p,{value:b,onChange:a=>p(a.target.value),placeholder:"Optional. Architect can infer it.",disabled:o,className:t?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,d.jsx)(b5,{surfaceTheme:a,label:"Goal",children:(0,d.jsx)(z.T,{value:c,onChange:a=>q(a.target.value),placeholder:"What should this workspace help you accomplish?",disabled:o,className:t?"min-h-[100px] border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"min-h-[100px] border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,d.jsx)(b5,{surfaceTheme:a,label:"Source",children:(0,d.jsx)(v.p,{value:e,onChange:a=>s(a.target.value),placeholder:"Repo URL, website URL, or existing folder path",disabled:o,className:t?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})})]}),(0,d.jsxs)("div",{className:(0,r.cn)("mt-4 rounded-[20px] border px-3 py-3",t?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.A,{className:(0,r.cn)("h-4 w-4",t?"text-[#5f5952]":"text-slate-300")}),(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",t?"text-[#a0978b]":"text-slate-500"),children:"Live preview"})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[(0,d.jsx)(cf,{surfaceTheme:a,label:"Name",value:f,icon:h.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Template",value:X[g].label,icon:n.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Source",value:j.label,icon:u}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Path",value:i,icon:m.A,mono:!0})]})]})]})}function b4({surfaceTheme:a,isBusy:b,onResume:c,onStartFresh:e}){let f="light"===a;return(0,d.jsx)("div",{className:f?"mx-auto w-full max-w-3xl rounded-[22px] border border-[#e4ddd3] bg-[#fffaf3] px-4 py-4 shadow-[0_18px_48px_rgba(56,47,38,0.05)]":"mx-auto w-full max-w-3xl rounded-[22px] border border-white/10 bg-white/[0.05] px-4 py-4",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:f?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Previous draft found"}),(0,d.jsx)("p",{className:f?"mt-1 text-[14px] leading-6 text-[#30261d]":"mt-1 text-[14px] leading-6 text-white",children:"Architect still has an earlier workspace blueprint. Resume it or start fresh before creating a new one."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(u.$,{variant:"secondary",size:"sm",className:f?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:e,disabled:b,children:"Start fresh"}),(0,d.jsx)(u.$,{size:"sm",className:f?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:c,disabled:b,children:"Resume blueprint"})]})]})})}function b5({surfaceTheme:a,label:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("p",{className:"light"===a?"text-[11px] uppercase tracking-[0.16em] text-[#8d8276]":"text-[11px] uppercase tracking-[0.16em] text-slate-500",children:b}),c]})}let b6=[{id:"intake",label:"Intake",hint:"Mission, name, source"},{id:"shape",label:"Shape",hint:"Template and defaults"},{id:"review",label:"Review",hint:"Confirm and launch"}];function b7({surfaceTheme:a,step:b,isBusy:c,basicDraft:e,basicTemplate:f,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,resolvedName:k,resolvedTemplate:l,sourceAnalysis:m,workspacePath:n,onStepChange:o,onBasicNameChange:p,onBasicGoalChange:q,onBasicSourceChange:r,onBasicTemplateChange:s,onBasicTeamPresetChange:t,onBasicModelProfileChange:u,onBasicPresetChange:v,onBasicRuleToggle:w}){return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(b8,{surfaceTheme:a,step:b,onStepChange:o}),"intake"===b?(0,d.jsx)(b3,{surfaceTheme:a,name:e.name,goal:e.goal,source:e.source,resolvedName:k,resolvedTemplate:l,workspacePath:n,sourceAnalysis:m,onNameChange:p,onGoalChange:q,onSourceChange:r}):"shape"===b?(0,d.jsx)(b9,{surfaceTheme:a,basicTemplate:f,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,onBasicTemplateChange:s,onBasicTeamPresetChange:t,onBasicModelProfileChange:u,onBasicPresetChange:v,onBasicRuleToggle:w,isBusy:c}):(0,d.jsx)(ca,{surfaceTheme:a,basicDraft:e,basicTeamPreset:g,basicModelProfile:h,basicRules:i,basicPreset:j,resolvedName:k,resolvedTemplate:l,sourceAnalysis:m,workspacePath:n,onStepChange:o})]})}function b8({surfaceTheme:a,step:b,onStepChange:c}){let e="light"===a,f=b6.findIndex(a=>a.id===b);return(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:b6.map((a,g)=>{let h=a.id===b,i=g<f;return(0,d.jsxs)("button",{type:"button",onClick:()=>c(a.id),className:(0,r.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-left transition-colors",h?e?"border-[#c89e73]/35 bg-[#f8efe4] text-[#5d4331]":"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":i?e?"border-[#dccfc3] bg-white text-[#7e6757]":"border-emerald-300/20 bg-emerald-400/10 text-emerald-50":e?"border-[#e6dbd0] bg-white/80 text-[#8b7563]":"border-white/10 bg-white/[0.04] text-slate-400"),children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium",h?e?"bg-[#c89e73]/15 text-[#5d4331]":"bg-cyan-300/20 text-cyan-50":i?e?"bg-[#f0e7de] text-[#7a6556]":"bg-emerald-300/20 text-emerald-50":e?"bg-[#f2ece6] text-[#917866]":"bg-white/10 text-slate-400"),children:g+1}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsx)("span",{className:"block text-[10px] font-medium uppercase tracking-[0.16em]",children:a.label}),(0,d.jsx)("span",{className:"block text-[10px] leading-4 opacity-75",children:a.hint})]})]},a.id)})})}function b9({surfaceTheme:a,basicTemplate:b,basicTeamPreset:c,basicModelProfile:e,basicRules:f,basicPreset:g,onBasicTemplateChange:h,onBasicTeamPresetChange:i,onBasicModelProfileChange:k,onBasicPresetChange:l,onBasicRuleToggle:m,isBusy:o}){let p="light"===a,q=X[b];return(0,d.jsxs)("section",{className:(0,r.cn)("rounded-[24px] border p-4 md:p-5",p?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",p?"text-[#8b7262]":"text-slate-500"),children:"Step 2 \xb7 Shape"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#70685f]":"text-slate-300"),children:"Pick the template and defaults that best match the workspace."})]}),(0,d.jsx)(a7.E,{variant:"muted",className:(0,r.cn)("shrink-0",p?"border-[#ddd6cb] bg-[#f7f2eb] text-[#574a40]":""),children:q.label})]}),(0,d.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,d.jsx)(cb,{surfaceTheme:a,title:"Template",summary:"This sets the scaffold, documents, and default capabilities.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-2 xl:grid-cols-3",children:T.map(c=>{let e=X[c.value];return(0,d.jsx)(cc,{surfaceTheme:a,selected:b===c.value,title:c.label,description:c.description,icon:(0,d.jsx)("span",{className:"text-[14px] leading-none","aria-hidden":"true",children:e.icon}),onClick:()=>h(c.value),disabled:o},c.value)})})}),(0,d.jsx)(cb,{surfaceTheme:a,title:"Team preset",summary:"Choose how many permanent agents the workspace should start with.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:U.map(b=>(0,d.jsx)(cc,{surfaceTheme:a,selected:c===b.value,title:b.label,description:b.description,icon:(0,d.jsx)(j.A,{className:"h-4 w-4"}),onClick:()=>i(b.value),disabled:o},b.value))})}),(0,d.jsx)(cb,{surfaceTheme:a,title:"Model profile",summary:"Favor speed, balance, or quality for the default workspace runs.",children:(0,d.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(b=>(0,d.jsx)(cc,{surfaceTheme:a,selected:e===b.value,title:b.label,description:b.description,icon:(0,d.jsx)(n.A,{className:"h-4 w-4"}),onClick:()=>k(b.value),disabled:o},b.value))})}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[20px] border p-3",p?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#8d8276]":"text-slate-500"),children:"Bootstrap speed"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#766e64]":"text-slate-400"),children:"Use a preset or tune the bootstrap rules manually."})]}),(0,d.jsx)(a7.E,{variant:"muted",children:g})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-3",children:[(0,d.jsx)(ce,{surfaceTheme:a,active:"standard"===g,title:"Standard",description:"Docs, memory, kickoff",disabled:o,onClick:()=>l("standard")}),(0,d.jsx)(ce,{surfaceTheme:a,active:"fastest"===g,title:"Fastest",description:"Core files only",disabled:o,onClick:()=>l("fastest")}),(0,d.jsx)(ce,{surfaceTheme:a,active:"custom"===g,title:"Custom",description:"Manually choose rules",disabled:o,onClick:()=>l("custom")})]})]}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[20px] border p-3",p?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#8d8276]":"text-slate-500"),children:"Workspace rules"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",p?"text-[#766e64]":"text-slate-400"),children:"Toggle the bootstrap steps that should ship with the workspace."})]}),(0,d.jsxs)(a7.E,{variant:"muted",children:[[f.generateStarterDocs,f.generateMemory,f.kickoffMission].filter(Boolean).length,"/3"]})]}),(0,d.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,d.jsx)(cd,{surfaceTheme:a,title:"Starter docs",description:"Generate the brief, scaffolding notes, and handoff docs.",checked:f.generateStarterDocs,disabled:o,onToggle:()=>m("generateStarterDocs")}),(0,d.jsx)(cd,{surfaceTheme:a,title:"Memory",description:"Write durable context and decisions into memory files.",checked:f.generateMemory,disabled:o,onToggle:()=>m("generateMemory")}),(0,d.jsx)(cd,{surfaceTheme:a,title:"Kickoff mission",description:"Launch the first mission right after bootstrap.",checked:f.kickoffMission,disabled:o,onToggle:()=>m("kickoffMission")})]})]})]})]})}function ca({surfaceTheme:a,basicDraft:b,basicTeamPreset:c,basicModelProfile:e,basicRules:f,basicPreset:g,resolvedName:i,resolvedTemplate:o,sourceAnalysis:p,workspacePath:q,onStepChange:s}){let t="light"===a,v="clone"===p.kind?k.A:"website"===p.kind?l.A:m.A,w=[f.generateStarterDocs,f.generateMemory,f.kickoffMission].filter(Boolean).length;return(0,d.jsxs)("section",{className:(0,r.cn)("rounded-[24px] border p-4 md:p-5",t?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.2em]",t?"text-[#8b7262]":"text-slate-500"),children:"Step 3 \xb7 Review"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",t?"text-[#70685f]":"text-slate-300"),children:"Check the final draft before creating the workspace."})]}),(0,d.jsx)(a7.E,{variant:"success",children:"Ready"})]}),(0,d.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2",children:[(0,d.jsx)(cf,{surfaceTheme:a,label:"Name",value:i,icon:h.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Template",value:X[o].label,icon:n.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Source",value:p.label,icon:v}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Path",value:q,icon:m.A,mono:!0}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Team",value:U.find(a=>a.value===c)?.label??c,icon:j.A}),(0,d.jsx)(cf,{surfaceTheme:a,label:"Model",value:V.find(a=>a.value===e)?.label??e,icon:n.A})]}),(0,d.jsxs)("div",{className:(0,r.cn)("mt-4 rounded-[20px] border p-3",t?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",t?"text-[#8d8276]":"text-slate-500"),children:"Launch summary"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",t?"text-[#766e64]":"text-slate-400"),children:"fastest"===g?"Fast path will keep the scaffold lean.":"custom"===g?"Custom bootstrap rules are active.":"Starter docs, memory, and kickoff are enabled."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(a7.E,{variant:"muted",children:[w,"/3 rules"]}),(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>s("intake"),className:t?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit intake"}),(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>s("shape"),className:t?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit shape"})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:[(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-2.5",t?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",t?"text-[#8d8276]":"text-slate-500"),children:"Goal"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",t?"text-[#34281f]":"text-slate-200"),children:b.goal.trim()||"No goal provided yet."})]}),(0,d.jsxs)("div",{className:(0,r.cn)("rounded-[18px] border px-3 py-2.5",t?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",t?"text-[#8d8276]":"text-slate-500"),children:"Source kind"}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[13px] leading-6",t?"text-[#34281f]":"text-slate-200"),children:"empty"===p.kind?"Fresh workspace":p.label})]})]})]})]})}function cb({surfaceTheme:a,title:b,summary:c,children:e}){let f="light"===a;return(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[11px] uppercase tracking-[0.18em]",f?"text-[#8d8276]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",f?"text-[#766e64]":"text-slate-400"),children:c})]}),e]})}function cc({surfaceTheme:a,selected:b,title:c,description:e,icon:f,onClick:g,disabled:h=!1}){let i="light"===a;return(0,d.jsxs)("button",{type:"button",onClick:g,disabled:h,className:(0,r.cn)("group flex h-full min-h-[90px] flex-col justify-between rounded-[18px] border p-3 text-left transition-colors",b?i?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/10 text-white":i?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d7c8ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",h&&"cursor-not-allowed opacity-70"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",b?"border-white/15 bg-white/10 text-white":i?"border-[#ddd3c5] bg-white text-[#5f564b]":"border-white/10 bg-white/[0.04] text-slate-200"),children:f}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[13px] font-medium",children:c}),(0,d.jsx)("p",{className:(0,r.cn)("mt-0.5 text-[11px] leading-4",b?"text-current/80":i?"text-[#766e64]":"text-slate-400"),children:e})]})]}),b?(0,d.jsx)(a7.E,{variant:i?"muted":"default",className:i?"bg-white text-[#3d342b]":"",children:"Selected"}):null]}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",b?"text-current/70":i?"text-[#8d8276]":"text-slate-500"),children:b?"Active choice":"Select"}),(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-5 items-center justify-center rounded-full border",b?"border-white/15 bg-white/10 text-white":i?"border-[#d9cec2] bg-white text-transparent":"border-white/10 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})})]})]})}function cd({surfaceTheme:a,title:b,description:c,checked:e,onToggle:f,disabled:g=!1}){let h="light"===a;return(0,d.jsxs)("button",{type:"button",onClick:f,disabled:g,className:(0,r.cn)("flex w-full items-start gap-3 rounded-[18px] border px-3 py-3 text-left transition-colors",h?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]",g?"cursor-not-allowed opacity-70":h?"hover:border-[#d7c8ba] hover:bg-[#f7f0e6]":"hover:border-white/15 hover:bg-white/[0.05]"),children:[(0,d.jsx)("span",{className:(0,r.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",e?h?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":h?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,d.jsx)(o.A,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[13px] font-medium",h?"text-[#171410]":"text-white"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("mt-1 text-[12px] leading-5",h?"text-[#766e64]":"text-slate-400"),children:c})]})]})}function ce({surfaceTheme:a,active:b,title:c,description:e,disabled:f=!1,onClick:g}){let h="light"===a;return(0,d.jsx)("button",{type:"button",onClick:g,disabled:f,className:(0,r.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",b?h?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":h?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",f&&"cursor-not-allowed opacity-70"),children:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,d.jsx)(n.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,d.jsx)("p",{className:"truncate text-[12px] font-medium",children:c})]}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-right text-[11px] leading-4",b?"opacity-80":h?"text-[#776f65]":"text-slate-400"),children:e})]})})}function cf({surfaceTheme:a,label:b,value:c,icon:e,mono:f=!1}){let g="light"===a;return(0,d.jsx)("div",{className:(0,r.cn)("rounded-[16px] border px-3 py-2.5",g?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,r.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",g?"border-[#e0d7cc] bg-[#faf6f1] text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,d.jsx)(e,{className:"h-3 w-3"})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:(0,r.cn)("text-[10px] uppercase tracking-[0.16em]",g?"text-[#8d8276]":"text-slate-500"),children:b}),(0,d.jsx)("p",{className:(0,r.cn)("truncate text-[12px] font-medium leading-4",f&&"font-mono text-[12px]",g?"text-[#171410]":"text-white"),title:c,children:c})]})]})})}},29849:(a,b,c)=>{"use strict";c.d(b,{d:()=>I});var d=c(3814),e=c(6247),f=c(49113),g=c(11917),h=c(74234),i=c(84086),j=c(80990),k=c(74952),l=c(43081);function m(a){return`mission-control-agent-chat:v1:${a}`}function n(a){return"object"==typeof a&&null!==a&&("user"===a.role||"assistant"===a.role||"system"===a.role)&&"string"==typeof a.id&&"string"==typeof a.text&&"number"==typeof a.createdAt&&(void 0===a.errorMessage||null===a.errorMessage||"string"==typeof a.errorMessage)&&(void 0===a.status||"sending"===a.status||"sent"===a.status||"error"===a.status)}function o(a){try{let b=globalThis.localStorage?.getItem(m(a));if(!b)return[];let c=JSON.parse(b);if(!Array.isArray(c))return[];return c.filter(n).slice(-60)}catch{return[]}}function p(a,b){try{globalThis.localStorage?.setItem(m(a),JSON.stringify(b.slice(-60)))}catch{}}var q=c(30094);function r(a){let b=a.toLowerCase();return(b.includes("couldn't recover")||b.includes("couldn’t recover"))&&b.includes("prior")&&b.includes("context")||b.includes("no prior transcript")&&b.includes("memory")||b.includes("send me")&&b.includes("last goal")&&b.includes("file")||b.includes("can't continue")&&b.includes("recoverable task context")||b.includes("can’t continue")&&b.includes("recoverable task context")||b.includes("checked")&&b.includes("workspace files")&&b.includes("recent session metadata")||b.includes("task state")&&b.includes("resume")||b.includes("failed attempt")&&b.includes("last task")&&b.includes("error")||b.includes("workspace")&&b.includes("memory")&&b.includes("session metadata")&&(b.includes("resume")||b.includes("continue"))}function s(a){let b=a.toLowerCase();return/\b(name|ad[ıi]n|ismin|called)\b/.test(b)&&/\b(age|old|ya[sş][ıi]n|kaç yaş)\b/.test(b)||/\b(who are you|kimsin)\b/.test(b)}let t="mission-control-action";function u(a){return function(a){if(!a)return"";let b=a.toLowerCase(),c=`<${t}>`,d=`</${t}>`,e=b.lastIndexOf(c),f=b.lastIndexOf(d);return e>=0&&e>f?a.slice(0,e).trim():a}(function(a){if("string"!=typeof a||!a.trim())return{action:null,cleanText:""};let b=RegExp(`<${t}>\\s*([\\s\\S]*?)\\s*<\\/${t}>`,"gi"),c=null,d=a.replace(b,(a,b)=>(c||(c=function(a){try{let b=JSON.parse(a);if("rename_agent"!==b.type)return null;let c=function(a){if("string"!=typeof a)return null;let b=a.trim().replace(/^["'`“”‘’]+|["'`“”‘’]+$/g,"").trim();return b.length>0?b:null}(b.name);if(!c)return null;return{type:"rename_agent",name:c}}catch{return null}}(b)),"")).replace(/\n{3,}/g,"\n\n").trim();return{action:c,cleanText:d}}("string"!=typeof a?"":function(a){if(!v(a))return a;let b=Math.max(a.lastIndexOf("\nOperator:"),a.startsWith("Operator:")?0:-1),c=(b>=0?a.slice(b):a).match(/\n(?:Agent|Assistant):\s*([\s\S]+)$/i),d=c?.[1]?.trim()??"";return d&&!v(d)?d:""}(function(a){if(!a||!/^\[thinking\]\b/i.test(a))return a;let b=a.split(/\n{2,}/).map(a=>a.trim()).filter(Boolean);return b.length<=2?"":b.slice(2).join("\n\n").trim()}(a.trim()))).cleanText)}function v(a){return/^You are chatting directly with the operator inside AgentOS\./i.test(a)||/You are chatting directly with the operator inside AgentOS\./i.test(a)&&/Do not create tasks or mention task cards\./i.test(a)||/Use the workspace root `AGENTS\.md` file as the source of truth/i.test(a)&&/Direct chat mode takes priority over workspace operating docs/i.test(a)}let w=new Map;function x({agentId:a,agentName:b,text:c,onRefresh:d,onSnapshotChange:e,onError:f}){let g=c.trim();if(!g)return Promise.resolve();let h=w.get(a);if(h)return h.promise;let i=Date.now(),j=globalThis.crypto?.randomUUID?.()||`user:${i}`,k=globalThis.crypto?.randomUUID?.()||`assistant:${i}`,l=o(a),m={userMessageId:j,assistantMessageId:k,statusMessage:"Starting agent turn...",promise:Promise.resolve()};w.set(a,m),p(a,[...l,{id:j,role:"user",text:g,createdAt:i,status:"sending"},{id:k,role:"assistant",text:"",createdAt:i+1,status:"sending"}].slice(-60));let n=l.filter(a=>("user"===a.role||"assistant"===a.role)&&"error"!==a.status&&a.text.trim().length>0).slice(-16).map(a=>({role:a.role,text:a.text})),q=new Set(n.filter(a=>"assistant"===a.role).map(a=>A(a.text)).filter(Boolean));return m.promise=y({agentId:a,payload:{message:g,rawMessage:g,history:n,thinking:"low"},agentName:b,userMessageId:j,assistantMessageId:k,previousAssistantTexts:q,run:m,onRefresh:d,onSnapshotChange:e,onError:f}),m.promise}async function y({agentId:a,payload:b,agentName:c,userMessageId:d,assistantMessageId:e,previousAssistantTexts:f,run:g,onRefresh:h,onSnapshotChange:i,onError:j}){let k="",l=!1;try{let j=await fetch(`/api/agents/${encodeURIComponent(a)}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),m=j.headers.get("content-type")||"";if(!j.ok||!m.includes("application/x-ndjson")){let a=await j.json().catch(()=>null);throw Error(a?.error||"OpenClaw rejected the message.")}z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a));let n=null;if(await (0,q.z)(j,async j=>{var m;if("status"===j.type){g.statusMessage=j.message;return}if("assistant"===j.type){let c=u(j.text),h=A(c),i=s(b.rawMessage)&&r(c);if(!c){g.statusMessage="Agent is thinking...";return}if(i||!l&&h&&f.has(h)){g.statusMessage="Agent is drafting a reply...";return}l=!0,k=c,g.statusMessage="Agent is drafting a reply...",z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a.id===e?{...a,text:c,status:"sending"}:a));return}if(!j.ok)throw Error(j.message);n=j.response??null;let o=function(a,b,c){return s(c)&&r(a)?`My name is ${b}. I do not have a real age; I am an AI agent running inside AgentOS.`:a}(n?(m=n).payloads.map(a=>u(a.text)).filter(Boolean).join("\n\n")||u(m.summary):k,c,b.rawMessage);n&&(k=o),z(a,a=>a.map(a=>a.id===d?{...a,status:"sent"}:a.id===e?{...a,text:o,status:"sent",runId:n?.runId??a.runId}:a));let p=n?function(a){let b=a?.missionControlAction;if(!b||"object"!=typeof b||"rename_agent"!==b.type||!0!==b.applied||"string"!=typeof b.name)return null;let c=b.name.trim();return c.length>0?c:null}(n.meta):null;p&&i&&i(b=>{var c,d,e;return c=b,d=a,e=p,{...c,agents:c.agents.map(a=>a.id===d?{...a,name:e,identityName:e}:a),tasks:c.tasks.map(a=>a.primaryAgentId===d?{...a,primaryAgentName:e}:a)}}),h?.().catch(()=>null)}),!n)throw Error("OpenClaw completed without returning a response.")}catch(f){let b=f instanceof Error?f.message:"Unknown send error.",c=l?k.trim():"";z(a,a=>a.map(a=>a.id===d?{...a,status:"error",errorMessage:b}:a.id===e&&c.length>0?{...a,text:c,status:"error",errorMessage:b}:a).filter(a=>a.id!==e||c.length>0)),j?.(b)}finally{w.delete(a)}}function z(a,b){p(a,b(o(a)).slice(-60))}function A(a){return a.replace(/\s+/g," ").trim()}var B=c(60557),C=c(12557),D=c(90665),E=c(32905);function F({surfaceTheme:a}){return(0,d.jsx)("span",{className:"inline-flex items-center gap-[3px] align-middle",children:[0,1,2].map(b=>(0,d.jsx)(i.P.span,{animate:{opacity:[.35,1,.35],y:[0,-1,0]},transition:{duration:1.1,repeat:1/0,delay:.14*b,ease:"easeInOut"},className:(0,E.cn)("h-1.5 w-1.5 rounded-full","light"===a?"bg-[#8f7263]":"bg-cyan-300")},b))})}function G({agentLabel:a,statusLabel:b,surfaceTheme:c}){return(0,d.jsxs)("div",{className:(0,E.cn)("flex min-w-0 items-center justify-between gap-3 text-[9px] uppercase tracking-[0.24em]","light"===c?"text-[#8b7262]":"text-slate-400"),children:[(0,d.jsx)("span",{className:"min-w-0 truncate",children:a}),b?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)("span",{children:b}),(0,d.jsx)(F,{surfaceTheme:c})]}):null]})}function H({statusMessage:a,expanded:b,onToggle:c,surfaceTheme:e}){var f;let g,h=function(a){let b,c=(b=a?.toLowerCase()??"").includes("finalizing")||b.includes("drafting")?"Shaping the reply before it appears here.":b.includes("thinking")?"Checking recent context before answering.":"Reading your message and preparing a reply.";return c.includes("Shaping")?["Shaping the reply","Preparing the final wording"]:c.includes("Checking")?["Reading your message","Checking recent context"]:["Reading your message","Preparing a reply"]}(a),j=(f=a,(g=f?.toLowerCase()??"").includes("finalizing")||g.includes("drafting")?["The agent has enough context to answer.","It is tightening the response before showing it here.","Raw reasoning stays hidden; only the final reply is saved."]:g.includes("thinking")?["The agent is reading the direct message.","It is checking recent chat and workspace context.","It will replace this activity card with the final reply."]:["The message was sent to the selected agent.","AgentOS is waiting for the first response signal.","This activity is temporary and is not saved to chat history."]);return(0,d.jsxs)("div",{className:(0,E.cn)("mt-2 overflow-hidden rounded-[14px] border px-3 py-2","light"===e?"border-[#e7d8cc] bg-[#fff7f1]/70":"border-cyan-300/10 bg-slate-950/24"),children:[(0,d.jsx)("div",{className:"space-y-1.5",children:h.map((a,b)=>(0,d.jsx)(i.P.div,{animate:{opacity:[.48,.92,.48]},transition:{duration:1.8,repeat:1/0,delay:.18*b,ease:"easeInOut"},className:(0,E.cn)("h-3.5 rounded-full","light"===e?"bg-[linear-gradient(90deg,rgba(139,114,98,0.16),rgba(139,114,98,0.34),rgba(139,114,98,0.14))]":"bg-[linear-gradient(90deg,rgba(125,211,252,0.10),rgba(125,211,252,0.27),rgba(125,211,252,0.08))]",0===b?"w-[72%]":"w-[54%]"),children:(0,d.jsx)("span",{className:(0,E.cn)("block truncate px-2 text-[10px] leading-3.5","light"===e?"text-[#7d6556]/78":"text-slate-300/72"),children:a})},a))}),(0,d.jsx)("div",{className:"mt-2 flex justify-end",children:(0,d.jsx)("button",{type:"button",onClick:c,className:(0,E.cn)("text-[8px] uppercase tracking-[0.18em] transition hover:opacity-80","light"===e?"text-[#8b7262]":"text-cyan-200/70"),children:b?"Hide details":"Show details"})}),b?(0,d.jsx)(i.P.ul,{initial:{opacity:0,y:-3},animate:{opacity:1,y:0},className:(0,E.cn)("mt-2 space-y-1 border-t pt-2 text-[11px] leading-4","light"===e?"border-[#e7d8cc] text-[#7d6556]":"border-white/[0.07] text-slate-400"),children:j.map(a=>(0,d.jsxs)("li",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:(0,E.cn)("mt-[7px] h-1 w-1 shrink-0 rounded-full","light"===e?"bg-[#b28f78]":"bg-cyan-300/70")}),(0,d.jsx)("span",{children:a})]},a))}):null]})}function I({agent:a,surfaceTheme:b,isVisible:c,onRefresh:m,onSnapshotChange:n,onConnectModelProvider:o}){let[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)([]),[t,u]=(0,e.useState)(()=>{var b;let c;return b=a.id,{isRunning:!!(c=w.get(b)),userMessageId:c?.userMessageId??null,assistantMessageId:c?.assistantMessageId??null,statusMessage:c?.statusMessage??null}}),[v,y]=(0,e.useState)(null),[z,A]=(0,e.useState)({}),[F,J]=(0,e.useState)({}),[K,L]=(0,e.useState)(null),M=(0,e.useRef)(null),N=(0,e.useRef)(null),O=(0,e.useRef)(c);(0,e.useRef)(null);let P=(0,D.CK)(a),Q=!!p.trim()&&!t.isRunning,R=t.assistantMessageId,S=r.length>0?r:[{id:"system:empty",role:"system",text:"Start a direct chat with this agent. Messages stay in this drawer and are stored locally in your browser.",createdAt:Date.now()}],T=async()=>{let b=p.trim();if(b&&!t.isRunning){q("");try{await x({agentId:a.id,agentName:P,text:b,onRefresh:m,onSnapshotChange:n,onError:a=>{l.o.error("Chat message failed.",{description:a})}})}finally{O.current&&requestAnimationFrame(()=>N.current?.focus())}}},U=async(b,c,d)=>{let e=c.trim();if(e&&!K&&!t.isRunning){L(b);try{let b=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:d.apiAction})}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||"Gateway access could not be repaired.");if(c?.authStatus?.native&&!1===c.authStatus.native.ok)throw Error(c.authStatus.native.issue||"Gateway access still needs attention.");l.o.success(`${d.label} repaired.`,{description:"Retrying the chat message."}),await m?.().catch(()=>void 0),L(null),await x({agentId:a.id,agentName:P,text:e,onRefresh:m,onSnapshotChange:n,onError:a=>{l.o.error("Chat message failed.",{description:a})}})}catch(a){l.o.error("Gateway repair failed.",{description:a instanceof Error?a.message:"Unable to repair Gateway access."})}finally{L(null),O.current&&requestAnimationFrame(()=>N.current?.focus())}}};return(0,d.jsxs)("div",{className:(0,E.cn)("flex h-full min-h-0 flex-col overflow-hidden","light"===b?"text-[#4a382c]":"text-slate-200"),children:[(0,d.jsx)("div",{ref:M,className:(0,E.cn)("mission-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1","light"===b?"text-[#4a382c]":"text-slate-200"),children:(0,d.jsx)("div",{className:"space-y-2.5",children:S.map(c=>{let e="user"===c.role,h="system"===c.role,k="assistant"===c.role,l=k&&c.id===R&&t.isRunning,m=l&&!c.text.trim(),n=k?z[c.id]:void 0,p=n??c.text,q=k&&!!n&&p!==c.text,r=l||q,s=m?"Thinking":r?"Replying":null,u="user"===c.role&&c.id===t.userMessageId&&t.isRunning,v="sending"===c.status&&u,w=c.errorMessage?.trim(),x=w?(0,C.Ek)(w):null,y=w&&!x?function(a,b){var c,d,e;let f,g=a?.trim()??"";if(!g||(c=g,!/\b(auth|authentication|authenticate|unauthorized|unauthorised|forbidden|expired|token|oauth|api[-\s]?key|credential|login|sign[ -]?in|reconnect|401|403)\b/i.test(c)))return null;let h=function(a){let b=a.match(/\bmodels\s+auth\s+(login|paste-token)\b[\s\S]*?--provider(?:=|\s+)(["']?)([a-z0-9_-]+)\2/i);if(b?.[1]==="login"&&"openai"===b[3])return"openai-codex";if(b?.[3])return(0,B.d4)(b[3]);let c=a.match(/\b--provider(?:=|\s+)(["']?)([a-z0-9_-]+)\1/i);return(0,B.d4)(c?.[2]??null)}(g)??function(a){if(/\bChatGPT\/Codex\b|\bChatGPT\b|\bCodex\b/i.test(a))return"openai-codex";let b=a.toLowerCase();for(let a of B.y8){let c=a.id.toLowerCase(),d=a.label.toLowerCase(),e=a.shortLabel.toLowerCase();if(b.includes(c)||b.includes(d)||b.includes(e))return a.id}return null}(g)??(d=b,e=g,(f=d?.split("/",1)[0]?.trim()??"")?"openai"===f&&/\bChatGPT\b|\bCodex\b/i.test(e)?"openai-codex":(0,B.d4)(f):null);if(!h)return null;let i=(0,B.S)(h);return{provider:h,label:i,detail:`Connect ${i}, then retry this chat message.`}}(w,a.modelId):null;return(0,d.jsx)("div",{className:(0,E.cn)("flex",e?"justify-end":"justify-start"),children:(0,d.jsxs)("div",{className:(0,E.cn)("min-w-0 max-w-[92%] rounded-[18px] border px-3 py-2 text-[13px] leading-5 shadow-[0_14px_34px_rgba(0,0,0,0.14)]",u&&"opacity-85",h?"light"===b?"border-[#e3d4c8] bg-[#fffaf6] text-[#6c5647]":"border-white/[0.08] bg-white/[0.03] text-slate-400":e?"light"===b?"border-[#e3d4c8] bg-[#fff3f6] text-[#4a382c]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(255,255,255,0.07),rgba(255,255,255,0.03))] text-slate-100":"light"===b?"border-[#e3d4c8] bg-[#fffaf6] text-[#4a382c]":"border-cyan-300/12 bg-[linear-gradient(180deg,rgba(34,211,238,0.10),rgba(59,130,246,0.06))] text-slate-100"),children:[m?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(G,{agentLabel:P,statusLabel:s,surfaceTheme:b}),(0,d.jsx)(H,{statusMessage:t.statusMessage,expanded:!!F[c.id],onToggle:()=>J(a=>({...a,[c.id]:!a[c.id]})),surfaceTheme:b})]}):(0,d.jsxs)(d.Fragment,{children:[k?(0,d.jsx)(G,{agentLabel:P,statusLabel:s,surfaceTheme:b}):null,(0,d.jsx)("p",{className:(0,E.cn)("whitespace-pre-wrap break-words [overflow-wrap:anywhere]",k&&"mt-1.5"),children:k?p:c.text}),r?(0,d.jsx)(i.P.span,{"aria-hidden":"true",animate:{opacity:[.2,1,.2]},transition:{duration:.9,repeat:1/0,ease:"easeInOut"},className:"ml-0.5 inline-block h-[1em] w-[1px] translate-y-[2px] bg-current"}):null]}),!m&&v?(0,d.jsx)("p",{className:(0,E.cn)("mt-1.5 text-[10px] uppercase tracking-[0.18em]","light"===b?"text-[#8b7262]":"text-slate-500"),children:e?"Sending…":"Drafting…"}):m||"error"!==c.status?null:(0,d.jsxs)("div",{className:"mt-1.5 space-y-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-rose-300",children:"Failed to send"}),w?(0,d.jsx)("p",{className:(0,E.cn)("text-[11px] leading-4 [overflow-wrap:anywhere]","light"===b?"text-rose-700":"text-rose-200"),children:w}):null,y&&o?(0,d.jsxs)(j.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>o(y.provider),className:(0,E.cn)("mt-1 h-8 rounded-full px-3 text-[11px]","light"===b?"border-rose-200 bg-white text-rose-800 hover:bg-rose-50":"border-rose-300/20 bg-rose-300/10 text-rose-100 hover:bg-rose-300/16"),children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect ",y.label]}):null,x?(0,d.jsxs)(j.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>void U(c.id,c.text,x),disabled:!!K||t.isRunning,title:x.detail,className:(0,E.cn)("mt-1 h-8 rounded-full px-3 text-[11px]","light"===b?"border-emerald-200 bg-white text-emerald-800 hover:bg-emerald-50":"border-emerald-300/20 bg-emerald-300/10 text-emerald-100 hover:bg-emerald-300/16"),children:[K===c.id?(0,d.jsx)(g.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5"}),x.cta]}):null]})]})},c.id)})})}),(0,d.jsxs)("div",{className:(0,E.cn)("mt-2 shrink-0 rounded-[18px] border p-3","light"===b?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))]"),onPointerDown:a=>{let b=a.target;!b||b.closest("textarea")||b.closest("button")||N.current?.focus()},children:[(0,d.jsx)(k.T,{ref:N,value:p,onChange:a=>q(a.target.value),onKeyDown:async a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),await T())},placeholder:`Message to ${P}...`,className:(0,E.cn)("min-h-[60px] cursor-text resize-none border-0 bg-transparent px-3.5 py-2.5 text-[13px] leading-[1.5] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0","light"===b?"text-[#3f2f24] placeholder:text-[#8f7664]":"text-white placeholder:text-slate-500")}),(0,d.jsx)("div",{className:"mt-1.5 flex items-center justify-end gap-1.5",children:(0,d.jsxs)(j.$,{disabled:!Q,className:(0,E.cn)("h-8 rounded-full px-3 shadow-none","light"===b?"bg-[#4a382c] text-[#fffaf6] hover:bg-[#3f2f24]":"bg-white text-slate-950 hover:bg-white/92"),onClick:T,children:[t.isRunning?(0,d.jsx)(g.A,{className:"mr-[5px] h-[13px] w-[13px] animate-spin"}):(0,d.jsx)(h.A,{className:"mr-[5px] h-[13px] w-[13px]"}),"Send"]})})]})]})}},30094:(a,b,c)=>{"use strict";async function d(a,b){if(!a.body)throw Error("The server did not return a readable stream.");let c=a.body.getReader(),d=new TextDecoder,e="";for(;;){let{value:a,done:f}=await c.read();if(f)break;let g=(e+=d.decode(a,{stream:!0})).indexOf("\n");for(;g>=0;){let a=e.slice(0,g).trim();e=e.slice(g+1),a&&await b(JSON.parse(a)),g=e.indexOf("\n")}}let f=e.trim();f&&await b(JSON.parse(f))}c.d(b,{z:()=>d})},30540:(a,b,c)=>{"use strict";c.d(b,{T:()=>e,j:()=>d});let d=[{name:"exec",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"process",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"bash",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"code_execution",description:"Run sandboxed remote Python analysis.",source:"OpenClaw built-in",category:"builtin"},{name:"browser",description:"Control a Chromium browser (navigate, click, screenshot).",source:"OpenClaw built-in",category:"builtin"},{name:"web_search",description:"Search the web and fetch search results.",source:"OpenClaw built-in",category:"builtin"},{name:"x_search",description:"Search X posts.",source:"OpenClaw built-in",category:"builtin"},{name:"web_fetch",description:"Fetch page content.",source:"OpenClaw built-in",category:"builtin"},{name:"read",description:"Read files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"write",description:"Write files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"edit",description:"Edit files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"apply_patch",description:"Apply structured multi-hunk patches.",source:"OpenClaw built-in",category:"builtin"},{name:"message",description:"Send messages across channels.",source:"OpenClaw built-in",category:"builtin"},{name:"canvas",description:"Drive node canvas workflows.",source:"OpenClaw built-in",category:"builtin"},{name:"nodes",description:"Discover and target paired devices.",source:"OpenClaw built-in",category:"builtin"},{name:"cron",description:"Manage scheduled jobs.",source:"OpenClaw built-in",category:"builtin"},{name:"gateway",description:"Inspect and restart gateway services.",source:"OpenClaw built-in",category:"builtin"},{name:"image",description:"Analyze images.",source:"OpenClaw built-in",category:"builtin"},{name:"image_generate",description:"Generate or edit images.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_history",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_send",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_spawn",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_yield",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"subagents",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"session_status",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"agents_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"}],e=[{name:"group:runtime",description:"exec, bash, process, code_execution",source:"OpenClaw docs",category:"group"},{name:"group:fs",description:"read, write, edit, apply_patch",source:"OpenClaw docs",category:"group"},{name:"group:sessions",description:"sessions_list, sessions_history, sessions_send, sessions_spawn, sessions_yield, subagents, session_status",source:"OpenClaw docs",category:"group"},{name:"group:memory",description:"memory_search, memory_get",source:"OpenClaw docs",category:"group"},{name:"group:web",description:"web_search, x_search, web_fetch",source:"OpenClaw docs",category:"group"},{name:"group:ui",description:"browser, canvas",source:"OpenClaw docs",category:"group"},{name:"group:automation",description:"cron, gateway",source:"OpenClaw docs",category:"group"},{name:"group:messaging",description:"message",source:"OpenClaw docs",category:"group"},{name:"group:nodes",description:"nodes",source:"OpenClaw docs",category:"group"},{name:"group:openclaw",description:"All built-in OpenClaw tools (excludes plugin tools).",source:"OpenClaw docs",category:"group"}]},31210:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(30248);function e(){return(0,d.jsx)("main",{className:"flex min-h-screen items-center justify-center bg-[#050816] px-6 text-white",children:(0,d.jsxs)("div",{className:"rounded-[24px] border border-white/10 bg-white/[0.03] px-8 py-10 text-center shadow-[0_24px_80px_rgba(0,0,0,0.35)] backdrop-blur-xl",children:[(0,d.jsx)("p",{className:"text-[11px] uppercase tracking-[0.32em] text-slate-500",children:"OpenClaw"}),(0,d.jsx)("h1",{className:"mt-3 font-display text-3xl",children:"Page not found"}),(0,d.jsx)("p",{className:"mt-3 max-w-md text-sm leading-6 text-slate-400",children:"The requested AgentOS route does not exist in this workspace."})]})})}},32905:(a,b,c)=>{"use strict";c.d(b,{cn:()=>f});var d=c(81938),e=c(53077);function f(...a){return(0,e.QP)((0,d.$)(a))}},34118:(a,b,c)=>{"use strict";c.d(b,{J:()=>j});var d=c(3814),e=c(6247),f=c(10011),g=c(9082),h=c(32905);let i=(0,g.F)("text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground"),j=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.b,{ref:c,className:(0,h.cn)(i(),a),...b}));j.displayName=f.b.displayName},37674:(a,b,c)=>{"use strict";c.d(b,{Cf:()=>n,Es:()=>p,HM:()=>l,L3:()=>q,c7:()=>o,lG:()=>i,rr:()=>r,zM:()=>j});var d=c(3814),e=c(6247),f=c(58346),g=c(57531),h=c(32905);let i=f.bL,j=f.l9,k=f.ZL,l=f.bm,m=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hJ,{ref:c,className:(0,h.cn)("fixed inset-0 z-50 bg-slate-950/70 backdrop-blur-md",a),...b}));m.displayName=f.hJ.displayName;let n=e.forwardRef(({className:a,children:b,overlayClassName:c,closeClassName:e,...i},j)=>(0,d.jsxs)(k,{children:[(0,d.jsx)(m,{className:c}),(0,d.jsxs)(f.UC,{ref:j,className:(0,h.cn)("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-popover p-6 text-popover-foreground shadow-panel backdrop-blur-xl duration-200",a),...i,children:[b,(0,d.jsxs)(f.bm,{className:(0,h.cn)("absolute right-4 top-4 rounded-full p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",e),children:[(0,d.jsx)(g.A,{className:"h-4 w-4"}),(0,d.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));n.displayName=f.UC.displayName;let o=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col space-y-2 text-left",a),...b}),p=({className:a,...b})=>(0,d.jsx)("div",{className:(0,h.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...b}),q=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.hE,{ref:c,className:(0,h.cn)("font-display text-xl font-semibold text-popover-foreground",a),...b}));q.displayName=f.hE.displayName;let r=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)(f.VY,{ref:c,className:(0,h.cn)("text-sm text-muted-foreground",a),...b}));r.displayName=f.VY.displayName},40299:(a,b,c)=>{"use strict";c.d(b,{F3:()=>i,rY:()=>f,yQ:()=>h});let d=[{provider:"telegram",label:"Telegram",kind:"chat",description:"Bot accounts, public groups, and delegated community routing.",iconKey:"siTelegram",accentColor:"#26A5E4",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Bot token",placeholder:"123456:ABC...",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!0,providerManagedByOpenClaw:!0},{provider:"discord",label:"Discord",kind:"chat",description:"Servers, channels, DMs, and thread-aware team routing.",iconKey:"siDiscord",accentColor:"#5865F2",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Bot token",placeholder:"Discord bot token",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!0,providerManagedByOpenClaw:!0},{provider:"slack",label:"Slack",kind:"chat",description:"Workspace apps, channels, and internal team handoffs.",iconKey:"siSlack",accentColor:"#4A154B",supportsProvisioning:!0,provisionFields:[{key:"botToken",label:"Bot token",placeholder:"xoxb-...",inputType:"password",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"googlechat",label:"Google Chat",kind:"chat",description:"Spaces and enterprise chat surfaces backed by OpenClaw.",iconKey:"siGooglechat",accentColor:"#34A853",supportsProvisioning:!0,provisionFields:[{key:"webhookUrl",label:"Webhook URL",placeholder:"https://chat.googleapis.com/...",inputType:"url",secret:!0,required:!0,section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"gmail",label:"Gmail",kind:"inbox",description:"Inbox ownership, draft/send workflows, and Gmail-triggered automations.",iconKey:"siGmail",accentColor:"#EA4335",supportsProvisioning:!0,provisionFields:[{key:"account",label:"Account email",placeholder:"agent@example.com",inputType:"text",required:!0,section:"basic"},{key:"project",label:"Project ID",placeholder:"openclaw-project",section:"basic"},{key:"label",label:"Label",placeholder:"inbox",section:"basic"},{key:"hookToken",label:"Hook token",placeholder:"shared-secret",inputType:"password",secret:!0,section:"basic"},{key:"hookUrl",label:"Hook URL",placeholder:"https://your-host.example/gmail-pubsub",inputType:"url",section:"advanced"},{key:"topic",label:"Topic",placeholder:"gmail-topic",section:"advanced"},{key:"subscription",label:"Subscription",placeholder:"gmail-subscription",section:"advanced"},{key:"pushToken",label:"Push token",placeholder:"push-secret",inputType:"password",secret:!0,section:"advanced"},{label:"Serve port",placeholder:"8788",key:"serve.port",inputType:"number",section:"advanced"},{key:"serve.bind",label:"Serve bind",placeholder:"127.0.0.1",section:"advanced"},{key:"serve.path",label:"Serve path",placeholder:"/",section:"advanced"},{key:"includeBody",label:"Include body",inputType:"checkbox",defaultValue:!0,section:"advanced"},{key:"maxBytes",label:"Max bytes",placeholder:"20000",inputType:"number",section:"advanced"},{key:"renewEveryMinutes",label:"Renew interval (minutes)",placeholder:"720",inputType:"number",section:"advanced"},{key:"tailscale.mode",label:"Tailscale mode",placeholder:"funnel",defaultValue:"funnel",inputType:"select",options:[{label:"Off",value:"off"},{label:"Serve",value:"serve"},{label:"Funnel",value:"funnel"}],helpText:"One of funnel, serve, or off.",section:"advanced"},{key:"tailscale.path",label:"Tailscale path",placeholder:"/gmail-pubsub",section:"advanced"},{key:"tailscale.target",label:"Tailscale target",placeholder:"http://127.0.0.1:8788/gmail-pubsub",inputType:"url",section:"advanced"},{key:"pushEndpoint",label:"Push endpoint",placeholder:"https://public.example/gmail-push",inputType:"url",section:"advanced"},{key:"model",label:"Model",placeholder:"openrouter/meta-llama/llama-3.3-70b-instruct:free",section:"advanced"},{key:"thinking",label:"Thinking",placeholder:"off",section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"email",label:"Email",kind:"inbox",description:"Generic email inboxes and send/read workflows exposed through OpenClaw.",iconKey:"siMaildotru",accentColor:"#0F172A",supportsProvisioning:!0,provisionFields:[{key:"address",label:"Address",placeholder:"inbox@example.com",inputType:"text",required:!0,section:"basic"},{key:"oauth",label:"OAuth config",placeholder:'{"clientId":"...","clientSecret":"..."}',inputType:"textarea",helpText:"Paste JSON or a provider-specific OAuth configuration blob.",section:"basic"},{key:"watch",label:"Watch",inputType:"checkbox",defaultValue:!0,section:"basic"},{key:"pubsub",label:"Pub/Sub",placeholder:"projects/project-id/topics/email-events",section:"basic"},{key:"imap.host",label:"IMAP host",placeholder:"imap.example.com",inputType:"text",section:"advanced"},{key:"imap.port",label:"IMAP port",placeholder:"993",inputType:"number",section:"advanced"},{key:"smtp.host",label:"SMTP host",placeholder:"smtp.example.com",inputType:"text",section:"advanced"},{key:"smtp.port",label:"SMTP port",placeholder:"587",inputType:"number",section:"advanced"},{key:"username",label:"Username",placeholder:"mailbox-user",inputType:"text",section:"advanced"},{key:"password",label:"Password",placeholder:"app password",inputType:"password",secret:!0,section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"webhook",label:"Webhook",kind:"trigger",description:"External event triggers delivered into OpenClaw automations.",iconKey:"siWebhook",accentColor:"#0EA5E9",supportsProvisioning:!0,provisionFields:[{key:"token",label:"Hook token",placeholder:"shared-secret",inputType:"password",secret:!0,required:!0,section:"basic"},{key:"path",label:"Path",placeholder:"/hooks",section:"basic"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0},{provider:"cron",label:"Cron",kind:"trigger",description:"Scheduled tasks and recurring automation entry points.",iconKey:"siClockify",accentColor:"#F59E0B",supportsProvisioning:!0,provisionFields:[{key:"webhookToken",label:"Webhook token",placeholder:"replace-with-dedicated-webhook-token",inputType:"password",secret:!0,required:!0,section:"basic"},{key:"sessionRetention",label:"Session retention",placeholder:"24h",section:"basic"},{key:"maxConcurrentRuns",label:"Max concurrent runs",placeholder:"1",inputType:"number",section:"basic"},{key:"store",label:"Store path",placeholder:"~/.openclaw/cron/jobs.json",section:"advanced"},{key:"runLog.maxBytes",label:"Run log max bytes",placeholder:"2mb",section:"advanced"},{key:"runLog.keepLines",label:"Run log keep lines",placeholder:"2000",inputType:"number",section:"advanced"}],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0}],e=new Map(d.map(a=>[a.provider,a]));function f(a){return e.get(a)??{provider:a,label:g(a),kind:"chat",description:"OpenClaw-managed integration surface.",supportsProvisioning:!1,provisionFields:[],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0}}function g(a){let b=e.get(a);return b?b.label:a.split(/[-_]/).filter(Boolean).map(a=>a.slice(0,1).toUpperCase()+a.slice(1)).join(" ")}function h(a){return[...a].sort((a,b)=>{let c=f(a.type),d=f(b.type);return c.kind!==d.kind?c.kind.localeCompare(d.kind):a.type!==b.type?g(a.type).localeCompare(g(b.type)):a.name.localeCompare(b.name)})}function i(a={}){let b=new Map(d.map(a=>[a.provider,a])),c=new Set;for(let b of a.channelAccounts??[])c.add(b.type);for(let b of a.surfaceRuntime?.providerOrder??[])c.add(b);for(let b of Object.keys(a.surfaceRuntime?.accountsByProvider??{}))c.add(b);for(let d of c){var e;b.has(d)||b.set(d,{provider:d,label:a.surfaceRuntime?.providerLabels[d]??g(d),kind:(e=d,/gmail|mail|email|inbox/i.test(e)?"inbox":/cron|hook|webhook|trigger|event/i.test(e)?"trigger":"chat"),description:"OpenClaw-managed channel exposed through Gateway status or configuration.",supportsProvisioning:!1,provisionFields:[],supportsRouteDiscovery:!1,providerManagedByOpenClaw:!0})}return Array.from(b.values()).sort((a,b)=>a.kind!==b.kind?a.kind.localeCompare(b.kind):a.label.localeCompare(b.label))}},42180:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,77990,23))},42601:(a,b,c)=>{"use strict";c.d(b,{_:()=>X});var d=c(3814),e=c(6247),f=c(11917),g=c(73596),h=c(49113),i=c(33500),j=c(36130),k=c(98773),l=c(68123),m=c(56815),n=c(55421),o=c.n(n),p=c(52846),q=c(5813),r=c(80990),s=c(34118),t=c(40299);let u=/(^|[^a-z])rate limit(?:ed|ing)?\b|retry after|too many requests|HTTP\s*429/i,v=/config\.(?:get|schema|patch|apply|set|unset)|gateway config|config updates?/i;function w(a){let b=a?.trim()??"";return u.test(b)&&v.test(b)}function x(a,b,c){return c?[...a.filter(a=>a.workspaceId!==c),...b]:b}function y(a){return!w(a)&&/gateway|websocket|connection closed|service restart|ECONNREFUSED|ECONNRESET|socket hang up|unreachable|not reachable|timed out|timeout|scope upgrade|scope mismatch|missing operator/i.test(a)}function z(a,b,c){return a.surfaceRuntime.accountsByKey[`${b}:${c}`]??a.surfaceRuntime.accountsByKey[`${b}:${F(c)}`]??null}function A(a){switch(a){case"gateway-probe":return"Gateway probe";case"gateway-status":return"Gateway status";case"config-only":return"Config only";case"unavailable":return"Unavailable"}}function B(a,b){if(b&&!a)return"Gateway blocked";if(!a)return"Unknown";switch(a.status){case"connected":return"Connected";case"running":return"Running";case"linked":return"Linked";case"configured":return"Configured";case"disabled":return"Disabled";case"failed":return"Failed";case"gateway-blocked":return"Gateway blocked";case"unknown":return"Unknown"}}function C(a,b){if(b&&!a)return"border-amber-300/45 bg-amber-100 text-amber-800 dark:border-amber-300/25 dark:bg-amber-400/10 dark:text-amber-100";switch(a?.status){case"connected":case"running":case"linked":return"border-emerald-300/45 bg-emerald-50 text-emerald-700 dark:border-emerald-300/25 dark:bg-emerald-400/10 dark:text-emerald-100";case"configured":return"border-cyan-300/45 bg-cyan-50 text-cyan-700 dark:border-cyan-300/25 dark:bg-cyan-400/10 dark:text-cyan-100";case"disabled":return"border-border bg-muted text-muted-foreground dark:border-slate-300/15 dark:bg-slate-400/10 dark:text-slate-300";case"failed":return"border-rose-300/45 bg-rose-50 text-rose-700 dark:border-rose-300/25 dark:bg-rose-400/10 dark:text-rose-100";default:return"border-border bg-muted text-muted-foreground dark:border-white/10 dark:bg-white/[0.04] dark:text-slate-300"}}function D(a,b,c){let d=new Map;for(let b of a)d.set(b.routeId,b);for(let a of b)d.set(a.chatId,{routeId:a.chatId,provider:c,kind:function(a,b){if("telegram"===a)return"group";if("discord"===a){if(b.startsWith("thread:"))return"thread";if(b.startsWith("role:"))return"role"}return"channel"}(c,a.chatId),title:a.title??d.get(a.chatId)?.title??null,subtitle:d.get(a.chatId)?.subtitle??null,lastSeen:d.get(a.chatId)?.lastSeen??null});return Array.from(d.values()).sort((a,b)=>{let c=a.title??a.routeId,d=b.title??b.routeId;return c.localeCompare(d)})}function E(a){return a.slice(0,1).toUpperCase()+a.slice(1)}function F(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var G=c(90665),H=c(32905);function I({workspaceAgents:a,selectedAgentId:b,onSelectedAgentIdChange:c,accountTargets:e,accountRulesByTargetId:f,isSaving:g,onToggleAccountAccess:j,onRefreshAccounts:k}){let l,n=a.find(a=>a.id===b)??null,s=!!n&&(l=[...n.tools??[],...n.observedTools??[]].map(a=>a.toLowerCase()),"browser"===n.policy.preset||l.some(a=>"browser"===a||a.includes("chrome")));return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-border bg-card p-3.5 shadow-sm dark:border-white/10 dark:bg-white/[0.025] dark:shadow-none",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-foreground dark:text-white",children:"Accounts"}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[e.length," target",1===e.length?"":"s"]})]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground dark:text-slate-500",children:"Attach saved browser-profile account targets to an agent. AgentOS enforces these bindings before account-target task launch."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[(0,d.jsx)(r.$,{asChild:!0,type:"button",variant:"default",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",children:(0,d.jsxs)(o(),{href:"/accounts?connect=1",children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect Account"]})}),(0,d.jsxs)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:g,onClick:k,children:[(0,d.jsx)(m.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[(0,d.jsxs)("div",{className:"rounded-xl border border-border/80 bg-muted/30 p-3 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsx)(J,{label:"Agent",htmlFor:"account-agent",children:(0,d.jsxs)("select",{id:"account-agent",value:b,disabled:g||0===a.length,onChange:a=>c(a.target.value),className:"flex h-10 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),a.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-border/80 bg-background px-3 py-2 dark:border-white/8 dark:bg-black/15",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-500",children:"Browser capability"}),(0,d.jsx)("p",{className:"mt-1 text-xs text-foreground/80 dark:text-slate-300",children:n?s?"This agent has browser-capable tools.":"This agent needs browser/chrome tools before it can use account sessions.":"Select an agent to manage account access."})]})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-amber-300/35 bg-amber-50 p-3 dark:border-amber-300/15 dark:bg-amber-400/[0.06]",children:[(0,d.jsx)("p",{className:"text-xs font-medium text-amber-950 dark:text-amber-50",children:"OpenClaw limitation"}),(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-5 text-amber-900/80 dark:text-amber-100/75",children:"OpenClaw does not expose a direct browser-profile dispatch parameter to AgentOS yet. These bindings are real AgentOS access rules and are shown on the canvas, but task launch still passes the selected profile as account context."})]})]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-border bg-card p-3.5 shadow-sm dark:border-white/10 dark:bg-white/[0.025] dark:shadow-none",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("p",{className:"min-w-0 truncate text-sm font-medium text-foreground dark:text-white",children:"Workspace account targets"}),(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:n?(0,G.CK)(n):"No agent"})]}),0===e.length?(0,d.jsx)("div",{className:"mt-3 rounded-xl border border-dashed border-border bg-muted/30 px-3 py-3 text-sm leading-5 text-muted-foreground dark:border-white/10 dark:bg-white/[0.02] dark:text-slate-500",children:"No account targets are connected for this workspace. Use the Accounts page Connect Account flow to open a real OpenClaw browser login target first."}):(0,d.jsx)("div",{className:"mt-3 space-y-2.5",children:e.map(a=>{let c,e=f.get(a.id)??[],h=e.some(a=>a.agentId===b&&"use_browser_profile"===a.permission),k=e.filter(a=>"use_browser_profile"===a.permission),l=n?s?"":"Enable browser/chrome tools for this agent before attaching accounts.":"Select an agent before attaching this account.";return(0,d.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-border/80 bg-muted/30 px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(p.J,{serviceId:a.serviceId,serviceName:a.serviceName,primaryDomain:a.primaryDomain,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-foreground dark:text-white",children:a.serviceName}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",h?"border-emerald-300/45 bg-emerald-50 text-emerald-700 dark:border-emerald-300/25 dark:bg-emerald-400/10 dark:text-emerald-100":"border-border bg-muted text-muted-foreground dark:border-white/10 dark:bg-white/[0.04] dark:text-slate-300"),children:h?"Linked to agent":"Not linked"})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-muted-foreground dark:text-slate-500",children:[a.primaryDomain," \xb7 profile ",a.browserProfileName]}),k.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground dark:text-slate-500",children:["Linked agents: ",(c=k.map(a=>a.agentName).sort((a,b)=>a.localeCompare(b))).length<=3?c.join(", "):`${c.slice(0,3).join(", ")} +${c.length-3} more`]}):null]})]}),(0,d.jsx)(r.$,{type:"button",size:"sm",variant:h?"secondary":"default",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:g||!!l,title:l||(h?"Remove this account from the selected agent.":"Attach this account to the selected agent."),onClick:()=>j(a,h),children:h?"Remove":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Add to agent"]})})]},a.id)})})]})]})}function J({label:a,htmlFor:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(s.J,{htmlFor:b,className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-400",children:a}),c]})}var K=c(98036);function L({provider:a,className:b}){let c=(0,t.rY)(a),e=c.iconKey?K[c.iconKey]:void 0;return(0,d.jsx)("div",{className:(0,H.cn)("flex items-center justify-center rounded-full border border-white/12 bg-slate-950/72 text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)] backdrop-blur-xl",b),"aria-hidden":"true",children:e?(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[58%] w-[58%] select-none",fill:c.accentColor||`#${e.hex}`,children:(0,d.jsx)("path",{d:e.path})}):(0,d.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/88",children:c.label.slice(0,1)})})}var M=c(43081),N=c(37674),O=c(49444),P=c(8910),Q=c(74952),R=c(45084);function S(a,b){let c=a[b];return"string"==typeof c?c:""}function T(a){let b={name:""};for(let c of a.provisionFields){if("boolean"==typeof c.defaultValue||"string"==typeof c.defaultValue){b[c.key]=c.defaultValue;continue}b[c.key]="checkbox"!==c.inputType&&""}return b}function U(a,b){let c={};for(let d of a){let a,e=b[d.key];if("checkbox"===d.inputType)a=!!e;else if("number"===d.inputType){let b="string"==typeof e?Number(e.trim()):Number(e);if(!Number.isFinite(b))continue;a=b}else{if("string"!=typeof e)continue;let b=e.trim();if(0===b.length)continue;a=function(a){if(a.startsWith("{")&&a.endsWith("}")||a.startsWith("[")&&a.endsWith("]"))try{return JSON.parse(a)}catch{}return a}(b)}!function(a,b,c){let d=b.split(".").filter(Boolean);if(d.length<=1){a[b]=c;return}let e=a;for(let a of d.slice(0,-1)){var f;(f=e[a])&&"object"==typeof f&&!Array.isArray(f)||(e[a]={}),e=e[a]}e[d[d.length-1]]=c}(c,d.key,a)}return c}var V=c(12557);let W=["chat","inbox","trigger"];function X({snapshot:a,workspaceId:b,accountTargets:c=[],accountAccessRules:n=[],initialAgentId:o=null,open:p,initialProvider:s=null,onOpenChange:u,onRefresh:v,onSnapshotChange:J,onAccountAccessRulesChange:K,onAccountTargetsChange:$}){let _=(0,e.useMemo)(()=>a.workspaces.find(a=>a.id===b)??null,[a.workspaces,b]),aa=(0,e.useMemo)(()=>a.agents.filter(a=>a.workspaceId===_?.id),[a.agents,_?.id]),ab=(0,e.useMemo)(()=>_?(0,R.mG)(a,_.id):[],[a,_]),ac=(0,e.useMemo)(()=>(0,t.yQ)(a.channelAccounts),[a.channelAccounts]),ad=(0,e.useMemo)(()=>(0,t.F3)({channelAccounts:ac,surfaceRuntime:a.surfaceRuntime}),[ac,a.surfaceRuntime]),ae=(0,e.useMemo)(()=>new Map(ad.map(a=>[a.provider,a])),[ad]),af=(0,e.useMemo)(()=>{let a=new Set(ad.map(a=>a.kind));return W.filter(b=>a.has(b))},[ad]),[ag,ah]=(0,e.useState)("surfaces"),[ai,aj]=(0,e.useState)("chat"),[ak,al]=(0,e.useState)("telegram"),[am,an]=(0,e.useState)(!1),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(""),[as,at]=(0,e.useState)({}),[au,av]=(0,e.useState)({}),[aw,ax]=(0,e.useState)({}),[ay,az]=(0,e.useState)({}),[aA,aB]=(0,e.useState)({}),[aC,aD]=(0,e.useState)(null),[aE,aF]=(0,e.useState)(""),[aG,aH]=(0,e.useState)(null),[aI,aJ]=(0,e.useState)(T((0,t.rY)(ak))),aK=(0,e.useCallback)(a=>{an(!0),ap(a)},[]),aL=(0,e.useCallback)(()=>{an(!1),ap(null)},[]),aM=(0,e.useMemo)(()=>(function(a,b){let c=new Map(a.map(a=>[a.id,a]));for(let a of b)c.has(a.accountId)||c.set(a.accountId,{id:a.accountId,type:a.provider,name:a.name||a.label||a.accountId,enabled:a.enabled,kind:(0,t.rY)(a.provider).kind,metadata:{runtimeOnly:!0}});return(0,t.yQ)(Array.from(c.values()))})(ac.filter(a=>a.type===ak),Object.values(a.surfaceRuntime.accountsByProvider[ak]??{})),[ak,ac,a.surfaceRuntime.accountsByProvider]),aN=(0,e.useMemo)(()=>ab.filter(a=>a.type===ak),[ak,ab]),aO=(0,e.useMemo)(()=>ae.get(ak)??(0,t.rY)(ak),[ak,ae]),aP=a.surfaceRuntime.gatewayAccess,aQ=(0,e.useMemo)(()=>{var b,c;return b=a.surfaceDrift.issues,(c=_?.id??null)?b.filter(a=>!a.workspaceId||a.workspaceId===c):b},[a.surfaceDrift.issues,_?.id]),aR=(0,e.useMemo)(()=>aQ.reduce((a,b)=>("missing-binding"===b.kind?a.missingBindings+=1:"extra-binding"===b.kind?a.extraBindings+=1:"agent-mismatch"===b.kind?a.agentMismatch+=1:"account-missing"===b.kind?a.accountMissing+=1:"provider-disabled"===b.kind&&(a.providerDisabled+=1),a),{missingBindings:0,extraBindings:0,agentMismatch:0,accountMissing:0,providerDisabled:0}),[aQ]),aS=(0,e.useMemo)(()=>aQ.filter(a=>a.provider===ak),[ak,aQ]),aT=aO.provisionFields.filter(a=>"advanced"!==a.section),aU=aO.provisionFields.filter(a=>"advanced"===a.section),aV=(0,e.useCallback)(a=>aN.some(b=>b.id===a||b.id===F(a)),[aN]),{accountRulesByTargetId:aW,refreshAccounts:aX,selectedAccountAgentId:aY,setSelectedAccountAgentId:aZ,updateAgentAccountAccess:a$,workspaceAccountTargets:a_}=function({open:a,workspaceId:b,workspaceAgents:c,accountTargets:d,accountAccessRules:f,initialAgentId:g,beginSaving:h,endSaving:i,onAccountAccessRulesChange:j,onAccountTargetsChange:k}){let[l,m]=(0,e.useState)(""),n=(0,e.useMemo)(()=>b?d.filter(a=>a.workspaceId===b):[],[d,b]),o=(0,e.useMemo)(()=>b?f.filter(a=>a.workspaceId===b):[],[f,b]),p=(0,e.useMemo)(()=>{let a=new Map;for(let b of o){let c=a.get(b.targetId)??[];c.push(b),a.set(b.targetId,c)}return a},[o]),q=(0,e.useMemo)(()=>c.find(a=>a.id===l)??null,[l,c]),r=(0,e.useCallback)(async()=>{var a;let c=b?`?workspaceId=${encodeURIComponent(b)}`:"",[e,g]=await Promise.all([fetch(`/api/accounts/login-targets${c}`,{cache:"no-store"}),fetch(`/api/accounts/access-rules${c}`,{cache:"no-store"})]),h=await e.json().catch(()=>null),i=await g.json().catch(()=>null);if(!e.ok||!h?.ok)throw Error(h?.error??"Account targets could not be loaded.");if(!g.ok||!i?.ok)throw Error(i?.error??"Account access rules could not be loaded.");k?.((a=h.targets,!b?a:[...d.filter(a=>a.workspaceId!==b),...a])),j?.(x(f,i.rules,b))},[f,d,j,k,b]),s=(0,e.useCallback)(async(a,c)=>{if(b&&q){h(c?"Removing account access...":"Adding account access...");try{let d=[...(p.get(a.id)??[]).filter(a=>a.agentId!==q.id).map(a=>({agentId:a.agentId,agentName:a.agentName,permission:a.permission,notes:a.notes})),...c?[]:[{agentId:q.id,agentName:(0,G.CK)(q),permission:"use_browser_profile",notes:`Granted from Workspace Surfaces for ${a.serviceName}.`}]],e=await fetch("/api/accounts/access-rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:b,targetId:a.id,rules:d})}),g=await e.json().catch(()=>null);if(!e.ok||!g?.ok)throw Error(g?.error??"Account access could not be updated.");j?.(x(f,g.rules,b)),M.o.success(c?"Account access removed.":"Account access added.",{description:`${(0,G.CK)(q)} ${c?"can no longer use":"can use"} ${a.serviceName}.`})}catch(a){M.o.error("Account access update failed.",{description:a instanceof Error?a.message:"Unknown account access error."})}finally{i()}}},[f,p,h,i,j,q,b]);return{accountRulesByTargetId:p,refreshAccounts:r,selectedAccountAgentId:l,setSelectedAccountAgentId:m,updateAgentAccountAccess:s,workspaceAccountTargets:n}}({open:p,workspaceId:_?.id??null,workspaceAgents:aa,accountTargets:c,accountAccessRules:n,initialAgentId:o,beginSaving:aK,endSaving:aL,onAccountAccessRulesChange:K,onAccountTargetsChange:$}),a0=(0,e.useCallback)((b,c="Unset")=>b?(0,G.CK)(a.agents.find(a=>a.id===b)??{name:b}):c,[a.agents]),a1=(0,e.useCallback)(b=>a.workspaces.find(a=>a.id===b)?.name??b,[a.workspaces]),a2=(0,e.useMemo)(()=>ad.filter(a=>a.kind===ai).map(a=>a.provider),[ai,ad]),a3=(0,e.useCallback)(async(a,b)=>{if(_?.id){az(b=>({...b,[a]:!0})),aB(b=>({...b,[a]:null}));try{let c=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/discovery?provider=${encodeURIComponent(b)}&accountId=${encodeURIComponent(a)}`),d=await c.json();if(!c.ok||d.error)throw Error(d.error||`${(0,t.rY)(b).label} route discovery failed.`);if(ax(b=>({...b,[a]:!1!==d.supported&&Array.isArray(d.routes)?d.routes:[]})),"telegram"===b&&Array.isArray(d.routes)&&d.routes.length>0){let b=ab.find(b=>b.id===a)??null,c=b?.workspaces.find(a=>a.workspaceId===_.id)??null;if(b&&c){let b=(c.groupAssignments??[]).filter(a=>!1!==a.enabled),e=new Set(b.map(a=>a.chatId)),f=d.routes.filter(a=>a.routeId&&!e.has(a.routeId)),g=new Map(d.routes.filter(a=>a.routeId&&a.title?.trim()).map(a=>[a.routeId,a.title?.trim()??null])),h=b.map(a=>{let b=g.get(a.chatId);return b&&a.title!==b?{...a,title:b}:a}),i=h.some((a,c)=>a.title!==b[c]?.title);if(f.length>0||i)try{let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"groups",channelId:a,groupAssignments:[...h,...f.map(a=>({chatId:a.routeId,title:a.title??null,agentId:null,enabled:!0}))]})}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"Discovered groups could not be enabled.");c.registry&&J&&J(a=>(0,R.z$)(a,c.registry)),M.o.success("Telegram routes enabled.",{description:1===f.length?`${f[0].title??f[0].routeId} now falls back to the primary agent.`:f.length>1?`${f.length} discovered groups now fall back to the primary agent.`:"Discovered group names were synced."}),v().catch(()=>{})}catch(a){M.o.error("Telegram route sync failed.",{description:a instanceof Error?a.message:"Discovered groups could not be enabled."})}}}}catch(c){aB(d=>({...d,[a]:c instanceof Error?c.message:`${(0,t.rY)(b).label} discovery failed.`}))}finally{az(b=>({...b,[a]:!1}))}}},[v,J,_,ab]),a4=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a5=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a6=async a=>{if(!_)throw Error("Workspace was not found.");let b=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/channels`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok||c.error)throw Error(c.error||"OpenClaw could not update this surface right now.");return c},a7=a=>{a.registry&&J&&J(b=>{let c=(0,R.z$)(b,a.registry);return a.account&&(c=(0,R.Iz)(c,a.account)),c})},a8=async a=>{let b=(0,V.Ek)(a);if(b)return b;if(!y(a))return null;try{let b=await fetch("/api/settings/gateway",{method:"GET"}),c=await b.json().catch(()=>null),d=c?.authStatus?.native?.issue??null,e=c?.authStatus?.recommendation??null;return(0,V.Ek)([a,d,e].filter(Boolean).join("\n"))}catch{return null}},a9=async(a,b,c=["operator.admin"])=>{aK(`${a.label} repair...`);try{let d=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a.apiAction,scopes:c})}),e=await d.json().catch(()=>null);if(!d.ok)throw Error(e?.error||"Gateway access could not be repaired.");if(e?.authStatus?.native&&!1===e.authStatus.native.ok)throw Error(e.authStatus.native.issue||"Gateway access still needs attention.");M.o.success(`${a.label} repaired.`,{description:"Retrying the surface operation."}),await v().catch(()=>void 0),await b()}catch(a){M.o.error("Gateway repair failed.",{description:a instanceof Error?a.message:"Unable to repair Gateway access."})}finally{aL()}},ba=async(a,b,c,d=["operator.admin"])=>{let e=b instanceof Error?b.message:"Unknown surface error.";if(w(e)&&c)return void M.o.error(a,{description:function(a,b="the config action"){let c=function(a){if(!w(a))return null;let b=(a??"").match(/retry after\s+(\d+(?:\.\d+)?)\s*(ms|msec|millisecond(?:s)?|s|sec|second(?:s)?|m|min|minute(?:s)?)?/i);if(!b)return null;let c=Number(b[1]);if(!Number.isFinite(c)||c<0)return null;let d=b[2]?.toLowerCase()??"s";return"ms"===d||"msec"===d||d.startsWith("millisecond")?Math.round(c):"m"===d||"min"===d||d.startsWith("minute")?Math.round(6e4*c):Math.round(1e3*c)}(a),d=c?`about ${function(a){if(a<1e3)return`${a}ms`;let b=Math.ceil(a/1e3);if(b<60)return`${b} second${1===b?"":"s"}`;let c=Math.ceil(b/60);return`${c} minute${1===c?"":"s"}`}(c)}`:"for the Gateway config cooldown";return`OpenClaw Gateway is rate limiting config updates. Wait ${d}, then retry ${b}. AgentOS did not use CLI fallback for this operation.`}(e,"the surface operation"),duration:12e3,action:{label:"Retry",onClick:()=>void c()}});let f=await a8(e)??(y(e)?{apiAction:"repairDeviceAccess",cta:"Repair access",label:"Gateway access",detail:"Approve any pending local AgentOS Gateway scope request, then retry."}:null);f&&c?M.o.error(a,{description:`${e} ${f.detail}`,duration:12e3,action:{label:"Repair & retry",onClick:()=>void a9(f,c,d)}}):y(e)&&c?M.o.error(a,{description:`${e} Wait for the OpenClaw Gateway to finish restarting, then retry.`,duration:1e4,action:{label:"Retry",onClick:()=>void c()}}):M.o.error(a,{description:e})},bb=async a=>{if(_){aK(`Connecting ${a.name}...`);try{let b=await a4({channelId:a.id,type:ak,name:a.name,workspacePath:_.path,primaryAgentId:aq||null,agentId:aq||void 0});a7(b),M.o.success(`${(0,t.rY)(ak).label} connected to this workspace.`),v().catch(()=>{})}catch(b){await ba("Surface connection failed.",b,()=>bb(a))}finally{aL()}}},bc=async()=>{if(_){if(!S(aI,"name").trim())return void M.o.error("A surface name is required.");aK(`Provisioning ${aO.label}...`);try{let a=U(aO.provisionFields,aI),b={type:ak,name:S(aI,"name").trim(),workspacePath:_.path,config:a,primaryAgentId:aq||null,agentId:aq||void 0};for(let c of aO.provisionFields)"token"===c.key&&"string"==typeof a.token&&(b.token=a.token),"botToken"===c.key&&"string"==typeof a.botToken&&(b.botToken=a.botToken),"webhookUrl"===c.key&&"string"==typeof a.webhookUrl&&(b.webhookUrl=a.webhookUrl);let c=await a4(b);a7(c),aJ(T(aO)),M.o.success(`${aO.label} provisioned and connected.`),v().catch(()=>{})}catch(a){await ba("Surface provisioning failed.",a,bc)}finally{aL()}}},bd=async(a,b)=>{if(_&&b){aK("Updating owner agent...");try{let c=ab.find(b=>b.id===a)??null,d=c?.workspaces.find(a=>a.workspaceId===_.id)??null;if(c&&d&&!d.agentIds.includes(b)){let c=await a5({action:"bind-agent",channelId:a,agentId:b,workspacePath:_.path});a7(c)}let e=await a5({action:"primary",channelId:a,primaryAgentId:b});a7(e),M.o.success("Owner agent updated."),v().catch(()=>{})}catch(a){M.o.error("Surface update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},be=async a=>{aK("Disconnecting surface from workspace...");try{let b=await a6({channelId:a});a7(b),M.o.success("Surface disconnected from this workspace."),v().catch(()=>{})}catch(a){M.o.error("Surface disconnect failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}},bf=async a=>{let b=as[a]?.trim(),c=au[a]?.trim();if(_&&b){aK(c?"Adding assistant and assigning route...":"Adding assistant agent...");try{let d=await a5({action:"bind-agent",channelId:a,agentId:b,workspacePath:_.path});a7(d);let e=null;if(c){let d=ab.find(b=>b.id===a)??null,f=d?.workspaces.find(a=>a.workspaceId===_.id)??null;if(!d||!f)throw Error("Surface route binding was not found.");let g=(f.groupAssignments??[]).filter(a=>!1!==a.enabled),h=d.workspaces.flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled)),i=D(aw[a]??[],h,d.type).find(a=>a.routeId===c)??null;e=i?.title??c;let j={chatId:c,title:i?.title??g.find(a=>a.chatId===c)?.title??null,agentId:b,enabled:!0},k=g.some(a=>a.chatId===c)?g.map(a=>a.chatId===c?{...a,...j}:a):[...g,j],l=await a5({action:"groups",channelId:a,groupAssignments:k});a7(l)}at(b=>({...b,[a]:""})),av(b=>({...b,[a]:""})),M.o.success(c?"Assistant added and assigned.":"Assistant agent added.",{description:c&&e?`${a0(b,b)} now owns ${e}.`:void 0}),v().catch(()=>{})}catch(a){M.o.error("Assistant update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},bg=async(a,b)=>{aK("Removing assistant agent...");try{let c=await a5({action:"unbind-agent",channelId:a,agentId:b});a7(c),M.o.success("Assistant agent removed."),v().catch(()=>{})}catch(a){M.o.error("Assistant update failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}},bh=async(a,b)=>{aK("Updating surface routes...");try{let c=await a5({action:"groups",channelId:a,groupAssignments:b});a7(c),v().catch(()=>{})}catch(a){M.o.error("Surface route update failed.",{description:a instanceof Error?a.message:"Unknown surface routing error."})}finally{aL()}},bi=async()=>{if(aC){aK(`Deleting ${aC.name} from OpenClaw...`);try{let a=await a6({channelId:aC.id,scope:"global"});a.registry&&J&&J(b=>(0,R.fY)((0,R.z$)(b,a.registry),aC.id)),aD(null),aF(""),M.o.success("Surface account deleted everywhere."),v().catch(()=>{})}catch(a){M.o.error("Surface deletion failed.",{description:a instanceof Error?a.message:"Unknown surface error."})}finally{aL()}}},bj=async()=>{if(_){aK("Previewing OpenClaw binding repair...");try{let a=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/reconcile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"workspace",dryRun:!0})}),b=await a.json();if(!a.ok||b.error||!b.repair?.auditId)throw Error(b.error||"OpenClaw binding repair preview could not be created.");let c=b.repair;aH(c),M.o.info("Binding repair preview created.",{description:`Audit ${c.auditId} was written without changing OpenClaw config.`})}catch(a){await ba("Binding repair preview failed.",a,bj,["operator.admin"])}finally{aL()}}},bk=async()=>{if(_&&aG?.auditId)try{aK("Applying OpenClaw binding repair...");let a=await fetch(`/api/workspaces/${encodeURIComponent(_.id)}/surfaces/reconcile`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:"workspace",dryRun:!1,confirm:"apply-surface-reconcile",previewAuditId:aG.auditId})}),b=await a.json();if(!a.ok||b.error)throw Error(b.error||"OpenClaw bindings could not be reconciled.");b.snapshot&&J&&J(()=>b.snapshot);let c=b.repair;aH(null),M.o.success("OpenClaw bindings repaired.",{description:c?`${c.addedBindingCount} added, ${c.removedBindingCount} removed. Backup ${c.backupId||"recorded"}.`:"Managed bindings were rewritten from the AgentOS registry."}),v().catch(()=>{})}catch(a){await ba("Binding repair failed.",a,void 0,["operator.admin"])}finally{aL()}},bl=!!aC&&aE.trim().toLowerCase()===aC.name.trim().toLowerCase(),bm="chat"===aO.kind?null:U(aO.provisionFields,aI),bn="chat"===aO.kind?null:function(a){switch(a){case"gmail":return"hooks.gmail";case"email":return"email";case"webhook":return"hooks";case"cron":return"cron";default:return a}}(aO.provider),bo=aO.provisionFields.every(a=>(function(a,b){if(!a.required)return!0;let c=b[a.key];return"checkbox"===a.inputType?!0===c:"number"===a.inputType?"string"==typeof c&&c.trim().length>0&&Number.isFinite(Number(c.trim())):"string"==typeof c&&c.trim().length>0})(a,aI)),bp=aO.supportsProvisioning&&!am&&!!aq&&!!S(aI,"name").trim()&&bo,bq=aG?.restorePlan?.configPaths??[],br=a=>{let b=`surface-${a.key}`,c=aI[a.key];return"checkbox"===a.inputType?(0,d.jsxs)("label",{htmlFor:b,className:"flex cursor-pointer items-start gap-3 rounded-xl border border-border/80 bg-muted/30 px-3 py-2.5 transition-colors hover:bg-muted/50 dark:border-white/8 dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[(0,d.jsx)("input",{id:b,type:"checkbox",checked:!!c,disabled:am,onChange:b=>aJ(c=>({...c,[a.key]:b.target.checked})),className:"mt-0.5 h-4 w-4 rounded border-border bg-background text-cyan-600 focus:ring-cyan-500/60 dark:border-white/20 dark:bg-white/5 dark:text-cyan-400 dark:focus:ring-cyan-400/60"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-foreground dark:text-white",children:a.label}),a.helpText?(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground dark:text-slate-500",children:a.helpText}):null]})]},a.key):(0,d.jsxs)(Y,{label:a.label,htmlFor:b,children:["select"===a.inputType?(0,d.jsxs)("select",{id:b,value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),className:"flex h-10 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm text-foreground outline-none dark:border-white/10 dark:bg-white/5 dark:text-white",disabled:am,children:[(0,d.jsx)("option",{value:"",children:"Select one"}),(a.options??[]).map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))]}):"textarea"===a.inputType?(0,d.jsx)(Q.T,{id:b,value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),placeholder:a.placeholder,disabled:am,className:"min-h-20 rounded-xl px-3 py-2"}):(0,d.jsx)(O.p,{id:b,type:"number"===a.inputType?"number":a.secret?"password":a.inputType??"text",value:"string"==typeof c?c:"",onChange:b=>aJ(c=>({...c,[a.key]:b.target.value})),placeholder:a.placeholder,disabled:am,className:"h-10 rounded-xl px-3"}),a.helpText?(0,d.jsx)("p",{className:"text-[11px] leading-4 text-muted-foreground dark:text-slate-500",children:a.helpText}):null]},a.key)};return(0,d.jsxs)(N.lG,{open:p,onOpenChange:u,children:[(0,d.jsx)(N.Cf,{className:"flex max-h-[calc(100dvh-2rem)] w-[calc(100vw-1rem)] max-w-5xl flex-col overflow-hidden rounded-[22px] border-border bg-popover p-0 text-popover-foreground dark:border-white/10 dark:bg-slate-950 dark:text-white",closeClassName:"right-3 top-3",children:(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsx)(N.c7,{className:"border-b border-border px-4 py-3 pr-12 sm:px-5 dark:border-white/10",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(N.L3,{className:"text-lg",children:"Workspace surfaces"}),(0,d.jsx)(N.rr,{className:"mt-1 text-xs",children:"Manage accounts, owners, and routes for this workspace."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground dark:text-slate-400",children:[(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[ab.length," linked"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[ac.length," accounts"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[a_.length," account targets"]})]})]})}),am&&ao?(0,d.jsx)("div",{className:"mx-4 mt-4 rounded-2xl border border-cyan-300/35 bg-cyan-50 px-3 py-2 sm:mx-6 dark:border-cyan-300/20 dark:bg-cyan-400/[0.08]",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-cyan-900 dark:text-cyan-50",children:[(0,d.jsx)(f.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,d.jsx)("span",{children:ao})]})}):null,aP.blocked?(0,d.jsx)("div",{className:"mx-4 mt-4 rounded-2xl border border-amber-300/40 bg-amber-50 px-3 py-3 sm:mx-6 dark:border-amber-300/25 dark:bg-amber-400/[0.08]",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700 dark:text-amber-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-950 dark:text-amber-50",children:"Gateway access blocked"}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-900/80 dark:text-amber-100/80",children:aP.issue??"OpenClaw Gateway pairing or scope approval is blocking live channel status."}),aP.missingScopes.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] text-amber-900/70 dark:text-amber-100/70",children:["Missing scopes: ",aP.missingScopes.join(", ")]}):null]})]}),aP.repairAction?(0,d.jsx)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am,onClick:()=>void a9(aP.repairAction,async()=>{await v()},aP.missingScopes.length>0?aP.missingScopes:["operator.read"]),children:"Repair Gateway Access"}):null]})}):null,(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 sm:px-5",children:(0,d.jsxs)("div",{className:"grid min-h-0 gap-4 sm:grid-cols-[220px_minmax(0,1fr)]",children:[(0,d.jsxs)("aside",{className:"h-fit rounded-2xl border border-border bg-card p-2.5 shadow-sm sm:sticky sm:top-0 dark:border-white/10 dark:bg-white/[0.025] dark:shadow-none",children:[(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1 rounded-xl border border-border/80 bg-muted/40 p-1 dark:border-white/8 dark:bg-black/15",children:["surfaces","accounts"].map(a=>(0,d.jsx)("button",{type:"button",onClick:()=>ah(a),className:(0,H.cn)("rounded-lg px-2 py-1.5 text-[11px] font-medium transition-colors",ag===a?"bg-primary/10 text-primary dark:bg-cyan-300/14 dark:text-cyan-50":"text-muted-foreground hover:bg-background hover:text-foreground dark:text-slate-400 dark:hover:bg-white/[0.04] dark:hover:text-slate-200"),children:"surfaces"===a?"Surfaces":"Accounts"},a))}),"surfaces"===ag?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(P.tU,{value:ai,onValueChange:a=>aj(a),className:"mt-2.5",children:(0,d.jsx)(P.j7,{className:"grid h-9 w-full grid-cols-3 rounded-xl",children:af.map(a=>(0,d.jsx)(P.Xi,{className:"h-7 rounded-lg px-2 text-[11px]",value:a,children:E(a)},a))})}),(0,d.jsx)("div",{className:"mt-2.5 space-y-1.5",children:a2.map(b=>{let c=ae.get(b)??(0,t.rY)(b),e=ab.filter(a=>a.type===b).length,f=ac.filter(a=>a.type===b).length,g=Object.keys(a.surfaceRuntime.accountsByProvider[b]??{}).length;return(0,d.jsxs)("button",{type:"button",onClick:()=>al(b),className:(0,H.cn)("flex w-full items-center justify-between gap-3 rounded-xl border px-2.5 py-2 text-left transition-colors",ak===b?"border-primary/25 bg-primary/10 dark:border-cyan-300/35 dark:bg-cyan-400/[0.08]":"border-border/80 bg-muted/30 hover:bg-muted/50 dark:border-white/8 dark:bg-white/[0.02] dark:hover:bg-white/[0.04]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,d.jsx)(L,{provider:b,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-foreground dark:text-white",children:c.label}),(0,d.jsxs)("p",{className:"mt-0.5 truncate text-[10px] text-muted-foreground dark:text-slate-500",children:[Math.max(f,g)," account",1===Math.max(f,g)?"":"s"," \xb7"," ",A(a.surfaceRuntime.source)]})]})]}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 shrink-0 rounded-full px-2 text-[10px]",children:e})]},b)})})]}):(0,d.jsxs)("div",{className:"mt-2.5 space-y-2 rounded-xl border border-border/80 bg-muted/30 p-2.5 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(h.A,{className:"h-3.5 w-3.5 text-amber-600 dark:text-amber-200"}),(0,d.jsx)("p",{className:"text-xs font-medium text-foreground dark:text-white",children:"Workspace accounts"})]}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-muted-foreground dark:text-slate-500",children:"Grant saved browser-profile account targets to workspace agents."}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 w-fit rounded-full px-2 text-[10px]",children:[a_.length," available"]})]})]}),(0,d.jsx)("div",{className:"min-w-0 space-y-4",children:"accounts"===ag?(0,d.jsx)(I,{workspaceAgents:aa,selectedAgentId:aY,onSelectedAgentIdChange:aZ,accountTargets:a_,accountRulesByTargetId:aW,isSaving:am,onToggleAccountAccess:(a,b)=>void a$(a,b),onRefreshAccounts:()=>void aX().catch(a=>{M.o.error("Accounts refresh failed.",{description:a instanceof Error?a.message:"Unknown account refresh error."})})}):(0,d.jsxs)(d.Fragment,{children:[aQ.length>0?(0,d.jsxs)("section",{className:"rounded-2xl border border-amber-300/35 bg-amber-50 p-3.5 dark:border-amber-300/20 dark:bg-amber-400/[0.06]",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-950 dark:text-amber-50",children:"OpenClaw binding drift"}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[aQ.length," issue",1===aQ.length?"":"s"]})]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-900/80 dark:text-amber-100/75",children:"AgentOS registry and OpenClaw runtime bindings differ for this workspace."}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[aR.missingBindings>0?`${aR.missingBindings} missing`:null,aR.extraBindings>0?`${aR.extraBindings} extra`:null,aR.agentMismatch>0?`${aR.agentMismatch} mismatch`:null,aR.accountMissing>0?`${aR.accountMissing} account missing`:null,aR.providerDisabled>0?`${aR.providerDisabled} disabled`:null].filter(a=>!!a).map(a=>(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:a},a))})]}),(0,d.jsx)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am||!a.surfaceDrift.checked,onClick:()=>void bj(),children:"Repair bindings"})]}),(0,d.jsxs)("div",{className:"mt-3 space-y-2",children:[aQ.slice(0,4).map(a=>{var b;let c,e,f,g;return(0,d.jsxs)("div",{className:"rounded-xl border border-amber-300/30 bg-white px-3 py-2 dark:border-white/8 dark:bg-black/15",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:(b=a.provider,ae.get(b)?.label??(0,t.rY)(b).label)}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:function(a){switch(a){case"missing-binding":return"Missing";case"extra-binding":return"Extra";case"agent-mismatch":return"Mismatch";case"account-missing":return"Account";case"provider-disabled":return"Disabled"}}(a.kind)}),(0,d.jsx)("p",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground dark:text-white",children:a.title})]}),(0,d.jsx)("p",{className:"mt-1 text-[11px] leading-4 text-amber-900/80 dark:text-amber-100/75",children:(c=a.routeId?` route ${a.routeId}`:"",e=a.accountId?`${a.provider}:${a.accountId}`:a.provider,f=a.expectedAgentId?a0(a.expectedAgentId,a.expectedAgentId):null,g=a.actualAgentId?a0(a.actualAgentId,a.actualAgentId):null,f&&g?`${e}${c}: expected ${f}, OpenClaw has ${g}.`:f?`${e}${c}: expected ${f}. ${a.detail}`:g?`${e}${c}: OpenClaw has ${g}. ${a.detail}`:`${e}${c}: ${a.detail}`)})]},a.id)}),aQ.length>4?(0,d.jsxs)("p",{className:"text-[11px] text-amber-900/70 dark:text-amber-100/65",children:[aQ.length-4," more drift issue",aQ.length-4==1?"":"s"," hidden."]}):null]})]}):null,(0,d.jsxs)("section",{className:"rounded-2xl border border-border bg-card p-3.5 shadow-sm dark:border-white/10 dark:bg-white/[0.025] dark:shadow-none",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("p",{className:"min-w-0 truncate text-sm font-medium text-foreground dark:text-white",children:[aO.label," surfaces"]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[aN.length," linked"]})]}),aN.length>0?(0,d.jsx)("div",{className:"mt-3 space-y-2.5",children:aN.map(b=>{var c;let e=b.workspaces.find(a=>a.workspaceId===_?.id)??null,g=(e?.agentIds??[]).filter(a=>a!==b.primaryAgentId),h=aa.filter(a=>a.id!==b.primaryAgentId&&!(e?.agentIds??[]).includes(a.id)),n=(e?.groupAssignments??[]).filter(a=>!1!==a.enabled),o=b.workspaces.flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled)),p=b.workspaces.filter(a=>a.workspaceId!==_?.id).flatMap(a=>(a.groupAssignments??[]).filter(a=>!1!==a.enabled&&a.chatId).map(c=>({routeId:c.chatId,workspaceName:a1(a.workspaceId),ownerName:c.agentId?a0(c.agentId,c.agentId):`${a0(b.primaryAgentId,"Primary agent")} fallback`}))).reduce((a,b)=>({...a,[b.routeId]:[...a[b.routeId]??[],{workspaceName:b.workspaceName,ownerName:b.ownerName}]}),{}),s=aw[b.id]??[],u=!!ay[b.id],v=aA[b.id]??null,w=D(s,o.length>0?o:n,b.type),x=aa.some(a=>a.id===b.primaryAgentId),y=z(a,b.type,b.id),I=aS.filter(a=>a.accountId===b.id||a.accountId===F(b.id));return(0,d.jsxs)("div",{className:"rounded-2xl border border-border/80 bg-muted/30 p-3 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(L,{provider:b.type,className:"h-9 w-9 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-foreground dark:text-white",children:b.name}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:E(aO.kind)}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",C(y,aP.blocked)),children:B(y,aP.blocked)}),I.length>0?(0,d.jsx)(q.E,{className:"h-5 rounded-full border-amber-300/40 bg-amber-100 px-2 text-[10px] text-amber-800 dark:border-amber-300/25 dark:bg-amber-400/10 dark:text-amber-100",children:"Drift"}):null]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-muted-foreground dark:text-slate-500",children:[b.type,":",b.id," \xb7 ",A(y?.source??a.surfaceRuntime.source)]})]})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,d.jsxs)(r.$,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:am,onClick:()=>void be(b.id),children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Disconnect"]}),(0,d.jsx)(r.$,{type:"button",variant:"destructive",size:"sm",className:"h-8 w-8 rounded-full p-0",disabled:am,"aria-label":`Delete ${b.name}`,title:"Delete everywhere",onClick:()=>{let a=aM.find(a=>a.id===b.id)??null,c=a??aM.find(a=>F(a.id)===b.id)??null,d=a??(c?{...c,id:b.id}:null);d&&(aD(d),aF(""))},children:(0,d.jsx)(j.A,{className:"h-3.5 w-3.5"})})]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-2 text-[11px] text-muted-foreground dark:text-slate-400 sm:grid-cols-4",children:[(0,d.jsx)(Z,{label:"Primary",value:a0(b.primaryAgentId)}),(0,d.jsx)(Z,{label:"Assistants",value:String(g.length)}),(0,d.jsx)(Z,{label:"Routes",value:String(n.length)}),(0,d.jsx)(Z,{label:"Health",value:B(y,aP.blocked)})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)(Y,{label:"chat"===aO.kind?"Primary agent":"Owner agent",htmlFor:`primary-${b.id}`,children:(0,d.jsxs)("select",{id:`primary-${b.id}`,value:b.primaryAgentId??"",disabled:am,onChange:a=>void bd(b.id,a.target.value),className:"flex h-9 w-full rounded-xl border border-input bg-background px-3 text-sm text-foreground outline-none dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),b.primaryAgentId&&!x?(0,d.jsxs)("option",{value:b.primaryAgentId,children:[a0(b.primaryAgentId,b.primaryAgentId)," \xb7 outside this workspace"]}):null,aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsxs)("p",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground dark:text-slate-500",children:[(0,d.jsx)(k.A,{className:"h-3 w-3"}),a0(b.primaryAgentId)]})]}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-400",children:"Assistants available for routes"}),(0,d.jsx)("p",{className:"text-[11px] leading-4 text-muted-foreground dark:text-slate-500",children:"Add an agent to the surface, then optionally assign it to a route."})]}),g.length>0?(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:g.map(a=>(0,d.jsxs)("button",{type:"button",disabled:am,onClick:()=>void bg(b.id,a),className:"inline-flex items-center gap-2 rounded-full border border-border bg-background px-2.5 py-1 text-[11px] text-foreground transition-colors hover:bg-muted dark:border-white/10 dark:bg-white/[0.04] dark:text-slate-200 dark:hover:bg-white/[0.08]",children:[(0,d.jsx)("span",{children:a0(a,a)}),(0,d.jsx)("span",{className:"text-muted-foreground dark:text-slate-500",children:"remove"})]},`${b.id}-${a}`))}):(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground dark:text-slate-400",children:"No assistant agents attached yet."}),h.length>0?(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,d.jsxs)("div",{className:"grid flex-1 gap-2 sm:grid-cols-2",children:[(0,d.jsxs)("select",{value:as[b.id]??"",disabled:am,"aria-label":"Assistant agent",onChange:a=>at(c=>({...c,[b.id]:a.target.value})),className:"flex h-9 w-full rounded-xl border border-input bg-background px-3 text-sm text-foreground outline-none dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:"Select assistant"}),h.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]}),(0,d.jsxs)("select",{value:au[b.id]??"",disabled:am||0===w.length,"aria-label":"Initial route assignment",onChange:a=>av(c=>({...c,[b.id]:a.target.value})),className:"flex h-9 w-full rounded-xl border border-input bg-background px-3 text-sm text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:w.length>0?"No route yet":"No discovered routes"}),w.map(a=>(0,d.jsxs)("option",{value:a.routeId,children:["Assign to ",a.title??a.routeId]},`${b.id}-target-${a.routeId}`))]})]}),(0,d.jsxs)(r.$,{type:"button",size:"sm",className:"h-9 rounded-full px-3 text-[11px] sm:shrink-0",disabled:am||!(as[b.id]??"").trim(),onClick:()=>void bf(b.id),children:[(0,d.jsx)(l.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Add"]})]}):null]})]}),aO.supportsRouteDiscovery?(0,d.jsxs)("div",{className:"mt-3 rounded-2xl border border-border/80 bg-background p-3 dark:border-white/8 dark:bg-white/[0.025]",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("p",{className:"text-sm font-medium text-foreground dark:text-white",children:[(0,t.rY)(b.type).label," routes"]}),(0,d.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground dark:text-slate-500",children:"Unassigned routes use the primary agent."})]}),(0,d.jsxs)(r.$,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:am||u,onClick:()=>void a3(b.id,b.type),children:[u?(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(m.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Routes"]})]}),v?(0,d.jsx)("p",{className:"mt-3 text-[11px] text-rose-300",children:v}):null,w.length>0?(0,d.jsx)("div",{className:"mt-3 space-y-2",children:w.map(a=>{var c;let e,f=n.find(b=>b.chatId===a.routeId)??null,g=p[a.routeId]??[],h=!!f,i=h?n.filter(b=>b.chatId!==a.routeId):[...n,{chatId:a.routeId,title:a.title??null,agentId:null,enabled:!0}];return(0,d.jsx)("div",{className:"rounded-xl border border-border/80 bg-muted/30 px-3 py-2.5 dark:border-white/8 dark:bg-white/[0.02]",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-border bg-background accent-cyan-600 dark:border-white/15 dark:bg-white/5 dark:accent-cyan-300",checked:h,disabled:am,onChange:()=>void bh(b.id,i)}),(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-foreground dark:text-white",children:a.title??a.routeId}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:a.kind})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-muted-foreground dark:text-slate-500",children:[a.subtitle??a.routeId,a.lastSeen?` \xb7 seen ${Number.isNaN(e=Date.parse(c=a.lastSeen))?c:new Date(e).toISOString().replace("T"," ").slice(0,16)}`:""]}),g.length>0?(0,d.jsxs)("p",{className:"mt-1 text-[11px] leading-4 text-amber-800 dark:text-amber-100/75",children:["Also routed in"," ",g.map(a=>`${a.workspaceName} by ${a.ownerName}`).join(", ")]}):null]}),(0,d.jsxs)("div",{className:"min-w-[190px] space-y-1",children:[(0,d.jsx)("p",{className:"px-1 text-[9px] uppercase tracking-[0.14em] text-muted-foreground dark:text-slate-500",children:"Route owner"}),(0,d.jsxs)("select",{value:f?.agentId??"",disabled:am||!h,onChange:c=>void bh(b.id,n.map(b=>b.chatId===a.routeId?{...b,title:a.title??b.title??null,agentId:c.target.value||null}:b)),className:"flex h-8 w-full rounded-full border border-input bg-background px-3 text-[11px] text-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:"Primary fallback"}),aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})]})]})})]})},`${b.id}:${a.routeId}`)})}):(0,d.jsx)("div",{className:"mt-3 rounded-xl border border-dashed border-border bg-muted/30 px-3 py-3 text-[11px] text-muted-foreground dark:border-white/10 dark:bg-white/[0.02] dark:text-slate-500",children:"telegram"===(c=b.type)?"No Telegram groups found yet. Send one message in the target group, then refresh surface discovery.":"discord"===c?"No Discord surfaces were discovered yet. Send one message in the target server, then refresh surface discovery.":"No surfaces were discovered yet for this provider."})]}):null]},b.id)})}):(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-dashed border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground dark:border-white/10 dark:bg-white/[0.02] dark:text-slate-500",children:["No ",aO.label," surfaces are linked to this workspace yet."]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-border bg-card p-3.5 shadow-sm dark:border-white/10 dark:bg-white/[0.025] dark:shadow-none",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsxs)("p",{className:"min-w-0 truncate text-sm font-medium text-foreground dark:text-white",children:["Connect ",aO.label]}),(0,d.jsxs)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[aM.length," available"]})]}),(0,d.jsxs)("div",{className:"mt-3 grid gap-3 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-500",children:"Existing accounts"}),aM.length>0?aM.map(b=>{let c=aV(b.id),e=z(a,b.type,b.id);return(0,d.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-border/80 bg-muted/30 px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)(L,{provider:b.type,className:"h-8 w-8 shrink-0"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-sm font-medium text-foreground dark:text-white",children:b.name}),(0,d.jsx)(q.E,{variant:"muted",className:(0,H.cn)("h-5 rounded-full px-2 text-[10px]",C(e,aP.blocked)),children:B(e,aP.blocked)})]}),(0,d.jsxs)("p",{className:"mt-1 truncate text-[11px] text-muted-foreground dark:text-slate-500",children:[b.id," \xb7 ",A(e?.source??a.surfaceRuntime.source)]})]})]}),(0,d.jsx)(r.$,{type:"button",size:"sm",variant:c?"secondary":"default",className:"h-8 rounded-full px-3 text-[11px]",disabled:am||c,onClick:()=>void bb(b),children:c?"Linked":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Connect"]})})]},b.id)}):(0,d.jsxs)("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground dark:border-white/10 dark:bg-white/[0.02] dark:text-slate-500",children:["No ",aO.label," accounts found."]})]}),(0,d.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/80 bg-muted/30 p-3 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-foreground dark:text-white",children:"Provision"}),(0,d.jsx)(q.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:aO.supportsProvisioning?"AgentOS":"OpenClaw"})]}),aO.supportsProvisioning?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Y,{label:"Surface name",htmlFor:"surface-name",children:(0,d.jsx)(O.p,{id:"surface-name",value:S(aI,"name"),onChange:a=>aJ(b=>({...b,name:a.target.value})),placeholder:`${aO.label} workspace surface`,className:"h-10 rounded-xl px-3"})}),aT.length>0?(0,d.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:aT.map(br)}):null,aU.length>0?(0,d.jsxs)("details",{className:"rounded-xl border border-border/80 bg-background p-3 dark:border-white/8 dark:bg-white/[0.015]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none text-xs font-medium uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-500",children:"Advanced settings"}),(0,d.jsx)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:aU.map(br)})]}):null,bm&&bn?(0,d.jsxs)("details",{className:"rounded-xl border border-cyan-300/30 bg-cyan-50 p-3 dark:border-cyan-300/15 dark:bg-cyan-400/[0.04]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none text-xs font-medium uppercase tracking-[0.16em] text-cyan-800 dark:text-cyan-100",children:"Config preview"}),(0,d.jsx)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:bn})}),"gmail"===aO.provider?(0,d.jsx)("p",{className:"mt-2 text-[11px] leading-5 text-cyan-800/75 dark:text-cyan-100/70",children:"Includes Gmail hook enablement."}):null,(0,d.jsx)("pre",{className:"mt-3 max-h-52 overflow-auto rounded-xl border border-border bg-slate-950 p-3 text-[11px] leading-5 text-slate-100 dark:border-white/10 dark:bg-slate-950/80",children:JSON.stringify(bm,null,2)})]}):null,(0,d.jsx)(Y,{label:"Primary agent",htmlFor:"surface-primary-agent",children:(0,d.jsxs)("select",{id:"surface-primary-agent",value:aq,onChange:a=>ar(a.target.value),className:"flex h-10 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm text-foreground outline-none dark:border-white/10 dark:bg-white/5 dark:text-white",children:[(0,d.jsx)("option",{value:"",children:"Select agent"}),aa.map(a=>(0,d.jsx)("option",{value:a.id,children:(0,G.CK)(a)},a.id))]})}),(0,d.jsx)(r.$,{type:"button",className:"h-10 rounded-full px-4 text-sm",disabled:!bp,onClick:()=>void bc(),children:am?"Provisioning...":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.A,{className:"mr-1.5 h-4 w-4"}),"Provision"]})})]}):(0,d.jsx)("div",{className:"rounded-xl border border-border/80 bg-background px-3 py-3 text-sm leading-5 text-muted-foreground dark:border-white/8 dark:bg-white/[0.02] dark:text-slate-400",children:"Provisioning is not exposed for this OpenClaw provider in AgentOS. Existing OpenClaw accounts can still be attached, monitored, and routed from this workspace."})]})]})]})]})})]})}),(0,d.jsx)(N.Es,{className:"border-t border-border px-4 py-3 sm:px-5 dark:border-white/10",children:(0,d.jsx)(r.$,{variant:"secondary",onClick:()=>u(!1),children:"Close"})})]})}),(0,d.jsx)(N.lG,{open:!!aC,onOpenChange:a=>!a&&aD(null),children:(0,d.jsxs)(N.Cf,{className:"sm:max-w-2xl",children:[(0,d.jsxs)(N.c7,{children:[(0,d.jsx)(N.L3,{children:"Delete OpenClaw account"}),(0,d.jsx)(N.rr,{children:"This removes the account from every workspace overlay. For provider-backed chat accounts, AgentOS also asks OpenClaw to delete the underlying account when supported."})]}),(0,d.jsx)("div",{className:"rounded-[20px] border border-rose-300/40 bg-rose-50 p-4 dark:border-rose-500/25 dark:bg-rose-500/[0.08]",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-rose-700 dark:text-rose-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("p",{className:"text-sm font-medium text-rose-950 dark:text-rose-50",children:["Type ",aC?.name??"the account name"," to confirm deletion."]}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-rose-900/80 dark:text-rose-100/80",children:"This action removes the account overlay everywhere and may delete the underlying OpenClaw provider account if the provider supports it."})]})]})}),(0,d.jsx)(Y,{label:`Type ${aC?.name??""} to confirm`,htmlFor:"delete-surface-confirm",children:(0,d.jsx)(O.p,{id:"delete-surface-confirm",value:aE,onChange:a=>aF(a.target.value),placeholder:aC?.name??""})}),(0,d.jsxs)(N.Es,{children:[(0,d.jsx)(r.$,{variant:"secondary",onClick:()=>{aD(null),aF("")},children:"Cancel"}),(0,d.jsx)(r.$,{variant:"destructive",disabled:!bl||am,onClick:()=>void bi(),children:am?"Deleting...":"Delete everywhere"})]})]})}),(0,d.jsx)(N.lG,{open:!!aG,onOpenChange:a=>{a||am||aH(null)},children:(0,d.jsxs)(N.Cf,{className:"sm:max-w-2xl",children:[(0,d.jsxs)(N.c7,{children:[(0,d.jsx)(N.L3,{children:"Apply OpenClaw binding repair"}),(0,d.jsx)(N.rr,{children:"Confirm the previewed repair before AgentOS writes a bounded OpenClaw config patch."})]}),(0,d.jsx)("div",{className:"rounded-[20px] border border-amber-300/40 bg-amber-50 p-4 dark:border-amber-300/25 dark:bg-amber-400/[0.08]",children:(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(g.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700 dark:text-amber-200"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-amber-950 dark:text-amber-50",children:"Operator confirmation required"}),(0,d.jsx)("p",{className:"mt-1 text-xs leading-5 text-amber-900/80 dark:text-amber-100/80",children:"AgentOS will write a redacted backup snapshot before changing only the approved OpenClaw config paths shown here."})]})]})}),(0,d.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,d.jsx)(Z,{label:"Bindings added",value:String(aG?.addedBindingCount??0)}),(0,d.jsx)(Z,{label:"Bindings removed",value:String(aG?.removedBindingCount??0)})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-border/80 bg-muted/30 p-3 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-500",children:"Preview audit"}),(0,d.jsx)("p",{className:"mt-1 break-all font-mono text-[11px] leading-5 text-foreground dark:text-slate-200",children:aG?.auditId??"unknown"})]}),(0,d.jsxs)("div",{className:"rounded-xl border border-border/80 bg-muted/30 p-3 dark:border-white/8 dark:bg-white/[0.02]",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-500",children:"Approved config paths"}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:bq.length>0?bq.map(a=>(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:a},a)):(0,d.jsx)(q.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:"no config changes"})})]}),(0,d.jsxs)(N.Es,{children:[(0,d.jsx)(r.$,{variant:"secondary",disabled:am,onClick:()=>aH(null),children:"Cancel"}),(0,d.jsx)(r.$,{disabled:am||!aG?.auditId,onClick:()=>void bk(),children:am?"Applying...":"Apply repair"})]})]})})]})}function Y({label:a,htmlFor:b,children:c}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(s.J,{htmlFor:b,className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground dark:text-slate-400",children:a}),c]})}function Z({label:a,value:b}){return(0,d.jsxs)("div",{className:"rounded-xl border border-border/80 bg-background px-3 py-2 dark:border-white/8 dark:bg-white/[0.018]",children:[(0,d.jsx)("p",{className:"truncate text-[9px] uppercase tracking-[0.14em] text-muted-foreground dark:text-slate-500",children:a}),(0,d.jsx)("p",{className:"mt-1 truncate text-[11px] text-foreground dark:text-slate-200",children:b})]})}},43081:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d.l$,o:()=>d.oR});var d=c(57825)},45084:(a,b,c)=>{"use strict";c.d(b,{Iz:()=>i,XS:()=>g,fY:()=>j,mG:()=>f,rz:()=>k,z$:()=>h});var d=c(40299);function e(a){return Array.from(new Set(a.map(a=>a.trim()).filter(Boolean).filter(Boolean)))}function f(a,b){return a.channelRegistry.channels.filter(a=>a.workspaces.some(a=>a.workspaceId===b)).sort((a,b)=>{let c=(0,d.rY)(a.type).kind,e=(0,d.rY)(b.type).kind;return c!==e?c.localeCompare(e):a.type!==b.type?(0,d.rY)(a.type).label.localeCompare((0,d.rY)(b.type).label):a.name.localeCompare(b.name)})}function g(a,b,c){return f(a,b).filter(a=>a.primaryAgentId===c||a.workspaces.some(a=>a.workspaceId===b&&(a.agentIds.includes(c)||a.groupAssignments.some(a=>!1!==a.enabled&&a.agentId===c)))).map(a=>a.id)}function h(a,b){return{...a,channelRegistry:b}}function i(a,b){let c=a.channelAccounts.filter(a=>a.id!==b.id);return{...a,channelAccounts:[...c,b]}}function j(a,b){return{...a,channelAccounts:a.channelAccounts.filter(a=>a.id!==b)}}async function k(a){let b=e(a.currentChannelIds),c=e(a.nextChannelIds),d=c.filter(a=>!b.includes(a)),f=b.filter(a=>!c.includes(a));for(let b of d){let c=await fetch(`/api/workspaces/${encodeURIComponent(a.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"bind-agent",channelId:b,agentId:a.agentId,workspacePath:a.workspacePath})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error||"OpenClaw could not bind the channel.");d.registry&&a.onRegistryChange&&a.onRegistryChange(a=>h(a,d.registry))}for(let b of f){let c=await fetch(`/api/workspaces/${encodeURIComponent(a.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unbind-agent",channelId:b,agentId:a.agentId})}),d=await c.json();if(!c.ok||d.error)throw Error(d.error||"OpenClaw could not unbind the channel.");d.registry&&a.onRegistryChange&&a.onRegistryChange(a=>h(a,d.registry))}}},45100:(a,b,c)=>{"use strict";c.d(b,{I:()=>l});var d=c(3814),e=c(5813),f=c(47221),g=c(98036),h=c(32905);let i={"openai-codex":{kind:"image",src:"/assets/provider-logos/openai.svg"},openai:{kind:"image",src:"/assets/provider-logos/openai.svg"},anthropic:{kind:"simple",icon:j("siAnthropic","Anthropic")},google:{kind:"simple",icon:j("siGooglegemini","Gemini")},gemini:{kind:"simple",icon:j("siGooglegemini","Gemini")},deepseek:{kind:"image",src:"/assets/provider-logos/deepseek.svg"},mistral:{kind:"simple",icon:j("siMistralai","Mistral")},openrouter:{kind:"simple",icon:j("siOpenrouter","OpenRouter")},ollama:{kind:"simple",icon:j("siOllama","Ollama")},xai:{kind:"image",src:"/assets/provider-logos/xai.svg"}};function j(a,b){let c=g[a];return c||{title:b,hex:"ffffff",path:"M0 0h24v24H0z"}}function k({provider:a,className:b}){let c=i[a.trim().toLowerCase()];return c?(0,d.jsx)("div",{className:(0,h.cn)("flex shrink-0 items-center justify-center overflow-hidden rounded-[16px] border border-black/5 bg-white/95 text-slate-900 shadow-[0_1px_1px_rgba(0,0,0,0.04)]",b),"aria-hidden":"true",children:"image"===c.kind?(0,d.jsx)(f.default,{src:c.src,alt:"",width:18,height:18,className:"h-[72%] w-[72%] select-none object-contain",unoptimized:!0}):(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[72%] w-[72%] select-none",fill:`#${c.icon.hex}`,children:(0,d.jsx)("path",{d:c.icon.path})})}):null}function l({descriptor:a,active:b,compact:c=!1,micro:f=!1,connected:g=!1,detail:i,onClick:j}){return(0,d.jsxs)("button",{type:"button",onClick:j,className:(0,h.cn)("group w-full rounded-[20px] border text-left transition-all",f?"rounded-[16px] p-1.5":c?"p-2.5":"p-3.5",b?f?"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_8px_16px_rgba(10,16,28,0.18)]":c?"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_12px_26px_rgba(10,16,28,0.22)]":"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_16px_36px_rgba(10,16,28,0.26)]":"border-white/10 bg-[linear-gradient(180deg,rgba(15,23,42,0.92),rgba(10,15,28,0.92))] hover:border-white/18 hover:bg-[linear-gradient(180deg,rgba(20,29,49,0.96),rgba(12,18,31,0.96))]"),children:[(0,d.jsxs)("div",{className:(0,h.cn)("flex items-start justify-between",f?"gap-1.5":"gap-2.5"),children:[(0,d.jsx)(k,{className:(0,h.cn)(f?"h-5 w-5":c?"h-7 w-7":"h-9 w-9",b?"ring-1 ring-cyan-300/20":""),provider:a.id}),(0,d.jsx)(e.E,{variant:g?"success":b?"default":"muted",className:(0,h.cn)("tracking-[0.12em]",f?"px-1 py-0.5 text-[7px]":c?"px-1.5 py-0.5 text-[9px]":"px-2 py-0.5 text-[10px]"),children:g?"Connected":b?"Selected":"Provider"})]}),(0,d.jsxs)("div",{className:(0,h.cn)(f?"mt-1.5":c?"mt-2":"mt-3.5"),children:[(0,d.jsx)("p",{className:(0,h.cn)("font-display text-white",f?"text-[0.72rem]":c?"text-[0.82rem]":"text-[0.94rem]"),children:a.label}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-slate-300",f?"line-clamp-2 text-[8px] leading-[0.85rem]":c?"text-[9px] leading-[0.95rem]":"text-[11px] leading-5"),children:a.description}),(0,d.jsx)("p",{className:(0,h.cn)("mt-2.5 uppercase tracking-[0.18em] text-slate-500",f?"line-clamp-1 text-[7px]":c?"text-[8px]":"text-[9px]"),children:i||a.helperText})]})]})}},45317:(a,b,c)=>{"use strict";c.d(b,{Bc:()=>h,ZI:()=>k,k$:()=>j,m_:()=>i});var d=c(3814),e=c(6247),f=c(20491),g=c(32905);let h=f.Kq,i=f.bL,j=f.l9,k=e.forwardRef(({className:a,sideOffset:b=6,children:c,...e},h)=>(0,d.jsx)(f.ZL,{children:(0,d.jsx)(f.UC,{ref:h,sideOffset:b,className:(0,g.cn)("relative z-[9999] overflow-hidden rounded-lg border border-border bg-popover px-4 py-3 text-xs text-popover-foreground shadow-panel backdrop-blur-xl",a),...e,children:(0,d.jsx)("div",{className:"relative z-10",children:c})})}));k.displayName=f.UC.displayName},45738:(a,b,c)=>{"use strict";c.d(b,{X:()=>k});var d=c(3814),e=c(5813),f=c(80990),g=c(90665),h=c(32905),i=c(45084),j=c(11917);function k({snapshot:a,workspaceId:b,channelIds:c,agentId:l,isSaving:m,onChange:n,surfaceTheme:o="dark"}){let p=(0,i.mG)(a,b),q=new Set(c),r="light"===o;return 0===p.length?(0,d.jsx)("div",{className:(0,h.cn)("rounded-[22px] border p-3.5",r?"border-[#e1d5c8] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03]"),children:(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,h.cn)("text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:"Surface participation"}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-[11px] leading-4",r?"text-[#7b6657]":"text-slate-400"),children:"Connect workspace surfaces first. Primary agents own the surface; selected agents assist behind the scenes."})]})})}):(0,d.jsxs)("div",{className:(0,h.cn)("rounded-[22px] border p-3.5",r?"border-[#e1d5c8] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03]"),children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,h.cn)("text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:"Surface participation"}),(0,d.jsx)("p",{className:(0,h.cn)("mt-1 text-[11px] leading-4",r?"text-[#7b6657]":"text-slate-400"),children:"Primary agents own the surface. Selected surfaces let this agent assist the owner internally."})]})}),m?(0,d.jsxs)("div",{className:(0,h.cn)("mt-3 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-[10px]",r?"border-[#c89e73]/25 bg-[#f5eadf] text-[#6b4f39]":"border-cyan-300/20 bg-cyan-400/[0.08] text-cyan-50"),children:[(0,d.jsx)(j.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,d.jsx)("span",{children:"Applying surface changes..."})]}):null,(0,d.jsx)("div",{className:"mt-4 space-y-3",children:p.map(i=>{var j;let k=q.has(i.id),o=!!(l&&i.primaryAgentId===l),p=(j=i.primaryAgentId)?(0,g.CK)(a.agents.find(a=>a.id===j)??{name:j}):null,s=i.workspaces.find(a=>a.workspaceId===b)??null,t=s?.agentIds.length??0;return(0,d.jsxs)("div",{className:(0,h.cn)("flex items-center justify-between gap-3 rounded-[18px] border px-3.5 py-2.5",k?r?"border-[#c89e73]/45 bg-[#fff7ef]":"border-cyan-300/40 bg-cyan-400/[0.08]":r?"border-[#e2d6ca] bg-white":"border-white/8 bg-white/[0.02]"),children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:(0,h.cn)("truncate text-[13px] font-medium",r?"text-[#3f2f24]":"text-white"),children:i.name}),(0,d.jsx)(e.E,{variant:"muted",className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:i.type}),o?(0,d.jsx)(e.E,{className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":""),children:"Owner"}):k?(0,d.jsx)(e.E,{className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":""),children:"Assistant"}):null,t>1?(0,d.jsx)(e.E,{variant:"muted",className:(0,h.cn)("h-4 rounded-full px-2 text-[9px]",r?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:"Team"}):null]}),(0,d.jsxs)("p",{className:(0,h.cn)("mt-1 truncate text-[10px]",r?"text-[#7f6958]":"text-slate-400"),children:[i.id,p?` \xb7 owner ${p}`:""]})]}),(0,d.jsx)(f.$,{type:"button",variant:k?"secondary":"default",size:"sm",className:(0,h.cn)("h-8 rounded-full px-2.5 text-[10px]",r&&!k?"shadow-none":""),disabled:!!m||k&&o,onClick:()=>n(q.has(i.id)?c.filter(a=>a!==i.id):[...c,i.id]),children:k?o?"Owner":"Remove":"Assist"})]},i.id)})})]})}},46856:(a,b,c)=>{"use strict";c.d(b,{o:()=>H});var d=c(3814),e=c(6247),f=c(11917),g=c(25393),h=c(67882),i=c(56815),j=c(23761),k=c(14847),l=c(32956),m=c(29075),n=c(73596),o=c(5813),p=c(80990),q=c(49444),r=c(60557),s=c(90665),t=c(32905);function u({models:a,selectedModelIds:b,search:c,onSearchChange:e,onToggleModel:g,onAddSelected:h,onOpenProviders:i,onLoadMore:j,visibleModelCount:v,isAdding:w,isLoading:x}){let y,z=(y=c.trim().toLowerCase())?a.filter(a=>`${a.name} ${a.id} ${a.provider} ${a.input} ${a.tags.join(" ")}`.toLowerCase().includes(y)):a,A=c.trim().length>0,B=A?z:z.slice(0,v),C=!A&&v<z.length,D=z.length-v,E=b.filter(b=>{let c=a.find(a=>a.id===b);return!!c&&!c.alreadyAdded}).length,F=new Set(a.map(a=>a.provider)).size,G=a.filter(a=>a.alreadyAdded).length;return(0,d.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(10,15,26,0.94),rgba(7,11,20,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"Catalog"}),(0,d.jsx)("p",{className:"mt-1 text-[10px] leading-[0.98rem] text-slate-400",children:"Browse the full OpenClaw catalog. Unavailable entries show which provider setup is missing."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[a.length," models"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[F," providers"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[G," added"]})]})]}),(0,d.jsxs)("div",{className:"relative mt-3",children:[(0,d.jsx)(k.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,d.jsx)(q.p,{value:c,onChange:a=>e(a.target.value),placeholder:"Search all discovered models",className:"h-8 pl-8 text-[11px]"})]}),x?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:[(0,d.jsx)(f.A,{className:"mx-auto mb-2 h-4 w-4 animate-spin text-slate-400"}),"Loading OpenClaw catalog..."]}):B.length>0?(0,d.jsxs)("div",{className:"mt-3 max-h-[min(38vh,340px)] space-y-1 overflow-y-auto pr-1",children:[B.map(a=>{var c,e;let f=b.includes(a.id),h=a.alreadyAdded,i=!h&&(!1===a.available||a.missing),j=(0,r.a3)(a.provider)?(0,r.W2)(a.provider):null,k=(c=a,e=j?.shortLabel??a.provider,c.missing?`${e} is configured, but this model is not available locally yet. You can still add it now, then finish setup in Providers.`:!1===c.available?`${e} needs a one-time setup before this model can be used. You can add it now, then connect it in Add Models > Providers.`:"");return(0,d.jsxs)("button",{type:"button",disabled:h,"aria-pressed":f,onClick:()=>{h||g(a.provider,a.id)},className:(0,t.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",h?"cursor-not-allowed border-white/8 bg-white/[0.02] opacity-70":f?"border-cyan-300/35 bg-cyan-300/[0.08]":i?"border-amber-300/20 bg-amber-300/[0.06] hover:border-amber-300/30 hover:bg-amber-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,d.jsx)("div",{className:(0,t.cn)("mt-0.5 flex h-[16px] w-[16px] shrink-0 items-center justify-center rounded-md border",h?"border-white/10 bg-white/[0.03] text-slate-500":f?"border-cyan-300/50 bg-cyan-300/15 text-cyan-100":i?"border-amber-300/30 bg-amber-300/10 text-amber-100":"border-white/12 bg-white/[0.03] text-transparent"),children:h?(0,d.jsx)(l.A,{className:"h-2 w-2"}):f?(0,d.jsx)(m.A,{className:"h-2 w-2"}):(0,d.jsx)(n.A,{className:"h-2 w-2"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:a.name}),(0,d.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:a.id}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,d.jsx)("span",{children:(0,r.S)(a.provider)}),a.input?(0,d.jsx)("span",{children:a.input}):null,a.contextWindow?(0,d.jsxs)("span",{children:[(0,s.FO)(a.contextWindow)," ctx"]}):null]}),i?(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-4 text-amber-100/85",children:k}):null]})]}),(0,d.jsx)("div",{className:"shrink-0",children:h?(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Already added"}):i?(0,d.jsx)(o.E,{variant:"warning",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Needs setup"}):a.recommended?(0,d.jsx)(o.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):a.local?(0,d.jsx)(o.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},a.id)}),C?(0,d.jsx)("div",{className:"pt-2",children:(0,d.jsxs)(p.$,{type:"button",variant:"secondary",onClick:j,className:"h-8 w-full rounded-full px-3 text-[10px]",children:["Load ",Math.min(5,D)," more"]})}):null]}):(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-dashed border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:[c.trim()?"No models matched this search.":"OpenClaw did not return any supported models yet.",(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(p.$,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3 text-[10px]",onClick:()=>i(),children:"Open providers"})})]}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/10 pt-3",children:[(0,d.jsx)("p",{className:"text-[9px] leading-4 text-slate-400",children:E>0?`${E} model${1===E?"":"s"} selected`:"Choose one or more models to add"}),(0,d.jsx)(p.$,{type:"button",onClick:h,disabled:0===E||w,className:"h-7 rounded-full px-2.5 text-[10px]",children:w?"Adding...":"Add selected models"})]})]})}var v=c(8910);function w(a,b){let c=b.trim().toLowerCase();return c?a.filter(a=>`${a.name} ${a.id} ${a.tags.join(" ")}`.toLowerCase().includes(c)):a}function x({provider:a,models:b,selectedModelIds:c,search:e,onSearchChange:f,onToggleModel:g,onAddSelected:h,isAdding:i}){let j=b.filter(a=>a.recommended),l=c.filter(a=>!b.find(b=>b.id===a)?.alreadyAdded).length,m="openrouter"===a,n=(0,r.W2)(a).searchPlaceholder,s=b.length>8||!!n,t=w(j,e),u=w(b,e);return(0,d.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(10,15,26,0.94),rgba(7,11,20,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"Select models to add"})}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[b.filter(a=>a.alreadyAdded).length," already added"]})]}),s?(0,d.jsxs)("div",{className:"relative mt-3",children:[(0,d.jsx)(k.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,d.jsx)(q.p,{value:e,onChange:a=>f(a.target.value),placeholder:n??"Search models",className:"h-8 pl-8 text-[11px]"})]}):null,m?(0,d.jsxs)(v.tU,{defaultValue:"recommended",className:"mt-3",children:[(0,d.jsxs)(v.j7,{className:"h-8 rounded-[16px] p-0.5",children:[(0,d.jsx)(v.Xi,{value:"recommended",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"Recommended"}),(0,d.jsx)(v.Xi,{value:"all",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"All models"})]}),(0,d.jsx)(v.av,{value:"recommended",children:(0,d.jsx)(y,{models:t,selectedModelIds:c,onToggleModel:g,emptyMessage:"No recommended matches. Switch to All models to browse the full catalog."})}),(0,d.jsx)(v.av,{value:"all",children:(0,d.jsx)(y,{models:u,selectedModelIds:c,onToggleModel:g,emptyMessage:"No models matched this search."})})]}):(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(y,{models:u,selectedModelIds:c,onToggleModel:g,emptyMessage:"No models matched this search."})}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/10 pt-3",children:[(0,d.jsx)("p",{className:"text-[9px] leading-4 text-slate-400",children:l>0?`${l} model${1===l?"":"s"} selected`:"Choose at least one model to add"}),(0,d.jsx)(p.$,{type:"button",onClick:h,disabled:0===l||i,className:"h-7 rounded-full px-2.5 text-[10px]",children:i?"Adding...":"Add selected models"})]})]})}function y({models:a,selectedModelIds:b,onToggleModel:c,emptyMessage:e}){return 0===a.length?(0,d.jsx)("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:e}):(0,d.jsx)("div",{className:"max-h-[min(28vh,220px)] space-y-1 overflow-y-auto pr-1",children:a.map(a=>{var e;let f=b.includes(a.id),g=!a.alreadyAdded&&(!1===a.available||a.missing);return(0,d.jsxs)("button",{type:"button",disabled:a.alreadyAdded,onClick:()=>c(a.id),className:(0,t.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",a.alreadyAdded?"cursor-not-allowed border-white/8 bg-white/[0.02] opacity-70":f?"border-cyan-300/35 bg-cyan-300/[0.08]":g?"border-amber-300/20 bg-amber-300/[0.06] hover:border-amber-300/30 hover:bg-amber-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,d.jsx)("div",{className:(0,t.cn)("mt-0.5 flex h-[16px] w-[16px] shrink-0 items-center justify-center rounded-md border",a.alreadyAdded?"border-white/10 bg-white/[0.03] text-slate-500":f?"border-cyan-300/50 bg-cyan-300/15 text-cyan-100":g?"border-amber-300/30 bg-amber-300/10 text-amber-100":"border-white/12 bg-white/[0.03] text-transparent"),children:a.alreadyAdded?(0,d.jsx)(l.A,{className:"h-2 w-2"}):f?(0,d.jsx)(m.A,{className:"h-2 w-2"}):(0,d.jsx)(n.A,{className:"h-2 w-2"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:a.name}),(0,d.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:a.id}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,d.jsx)("span",{children:a.input}),a.contextWindow?(0,d.jsxs)("span",{children:[Intl.NumberFormat().format(a.contextWindow)," ctx"]}):null,a.isFree?(0,d.jsx)("span",{children:"free"}):null]}),g?(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-4 text-amber-100/85",children:(e=a).missing?"This model is configured, but not available locally yet. You can still add it now, then finish setup in Providers.":!1===e.available?"This model needs provider setup before it will work. You can add it now, then connect the provider in Add Models > Providers.":""}):null]})]}),(0,d.jsx)("div",{className:"shrink-0",children:a.alreadyAdded?(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Already added"}):g?(0,d.jsx)(o.E,{variant:"warning",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Needs setup"}):a.recommended?(0,d.jsx)(o.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):a.local?(0,d.jsx)(o.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,d.jsx)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},a.id)})})}var z=c(45100),A=c(37674),B=c(89478),C=c(52188),D=c(58372),E=c(68885),F=c(43081);let G=()=>({flowState:"idle",connection:null,statusMessage:null,errorMessage:null,emptyState:null,manualCommand:null,docsUrl:null,models:[],selectedModelIds:[],apiKey:"",search:"",loaded:!1});function H({open:a,onOpenChange:b,snapshot:c,initialProvider:k=null,onSnapshotChange:l}){var m,n,s;let w,y,C,M,N=(0,r.d4)(k),[O,P]=(0,e.useState)("providers"),[Q,R]=(0,e.useState)(N),[S,T]=(0,e.useState)({}),[U,V]=(0,e.useState)(!1),[W,X]=(0,e.useState)(!1),[Y,Z]=(0,e.useState)(""),[$,_]=(0,e.useState)(5),[aa,ab]=(0,e.useState)([]),[ac,ad]=(0,e.useState)(!1),[ae,af]=(0,e.useState)(null);(0,e.useEffectEvent)(a=>{P("providers"),az(a)}),(0,e.useEffectEvent)(async()=>{ad(!0),af(null);try{let a=await fetch("/api/models/catalog"),b=await a.json().catch(()=>null);if(!a.ok||!b)throw Error(b?.error||"OpenClaw catalog could not be loaded.");ab(Array.isArray(b.models)?b.models:[])}catch(b){let a=b instanceof Error?b.message:"OpenClaw catalog could not be loaded.";ab([]),af(a),F.o.error("OpenClaw catalog could not be loaded.",{description:a})}finally{ad(!1)}});let ag=(0,r.a3)(Q)?Q:null,ah=ag?J(S[ag]):G(),ai=ag?(0,r.W2)(ag):null,aj=ag?L(c,S,ag):null,ak=!!(ag&&ai)&&("discovery-loading"===ah.flowState||"connecting"===ah.flowState&&!ah.manualCommand||ah.statusMessage?.startsWith("Checking ")===!0&&!aj?.connected),al="discovery-loading"===ah.flowState?`Discovering ${ai?.shortLabel??"provider"} models...`:"connecting"===ah.flowState?ah.statusMessage||`Connecting ${ai?.shortLabel??"provider"}...`:ah.statusMessage||`Checking ${ai?.shortLabel??"provider"}...`,am="discovery-loading"===ah.flowState?"Pulling the provider catalog into AgentOS.":"connecting"===ah.flowState?"Preparing the provider connection.":"Checking provider status before discovery.",an=!!(ag&&ai),ao="discovery-loading"===ah.flowState,ap=ah.models.length>0?"Refresh discovery":"Discover models",aq=ao?"Discovering...":ap,ar=aj?.connected?"The provider is connected. Pull the available models into this workspace before choosing one.":ai?.connectKind==="oauth"?"Use your account login first, then pull the available models into this workspace.":"Connect the provider first, then pull the available models into this workspace.",as=!!(ah.errorMessage&&ah.manualCommand&&(/gateway/i.test(ah.errorMessage)||/\bgateway\s+status\b/i.test(ah.manualCommand))),at=(0,e.useMemo)(()=>{let a=new Set(c.models.map(a=>a.id));return aa.map(b=>({...b,alreadyAdded:a.has(b.id)})).sort((a,b)=>{let c=a.alreadyAdded;if(c!==b.alreadyAdded)return c?1:-1;let d=a.provider.localeCompare(b.provider);if(0!==d)return d;let e=!K(a);if(!K(b)!==e)return e?1:-1;let f=Number(a.recommended)+Number(a.local),g=Number(b.recommended)+Number(b.local);if(f!==g)return g-f;let h=a.name.localeCompare(b.name);return 0!==h?h:a.id.localeCompare(b.id)})},[aa,c.models]),au=(0,e.useMemo)(()=>Object.values(S).flatMap(a=>a?.selectedModelIds??[]),[S]),av=(0,e.useMemo)(()=>new Map(at.map(a=>[a.id,a])),[at]),aw=(0,e.useMemo)(()=>new Set(at.map(a=>a.provider)).size,[at]),ax=(0,e.useMemo)(()=>at.filter(a=>a.alreadyAdded).length,[at]),ay=(0,e.useMemo)(()=>{let a=new Set(au),b=new Map;for(let c of at){let d=c.provider;if(!a.has(c.id)||c.alreadyAdded)continue;let e=b.get(d)??[];e.push(c.id),b.set(d,e)}return b},[at,au]);async function az(a){R(a),P("providers");let b=J(S[a]);if(b.loaded&&b.models.length>0)return;let c=await aA(a);"ollama"===a&&c?.connection.connected&&await aD(a,!0)}async function aA(a){let b=(0,B.oZ)(a);aJ(a,{flowState:"idle",errorMessage:null});try{let c=await b.getConnectionStatus(),d=J(S[a]);return aL(a,c,c.emptyState?"discovery-empty":"idle",{models:d.loaded&&d.models.length>0?d.models:c.models}),c.snapshot&&l(c.snapshot),c}catch(b){return aJ(a,{flowState:"auth-error",errorMessage:b instanceof Error?b.message:"Provider status could not be loaded.",loaded:!0}),null}}async function aB(a,b){let c=(0,B.oZ)(a),d=J(S[a]);aJ(a,{flowState:"connecting",errorMessage:null,statusMessage:"openai-codex"===a?b?.force?"Refreshing Codex app-server setup...":"Checking Codex app-server setup...":`Connecting ${(0,r.W2)(a).shortLabel}...`});try{let e=await c.connect({apiKey:d.apiKey,force:b?.force});aL(a,e,"openai-codex"===a?"connecting":e.models.length?"discovery-success":"idle",{apiKey:""}),e.snapshot&&l(e.snapshot)}catch(b){aJ(a,{flowState:"auth-error",errorMessage:b instanceof Error?b.message:"Provider connection failed."})}}async function aC(a){let b=(0,B.oZ)(a);aJ(a,{flowState:"connecting",errorMessage:null,statusMessage:"Preparing ChatGPT account switch..."});try{let c=await b.switchAccount();aL(a,c,"connecting"),c.snapshot&&l(c.snapshot)}catch(c){let b=aK(c);aJ(a,{flowState:"auth-error",errorMessage:c instanceof Error?c.message:"Provider account switch failed.",manualCommand:b?.manualCommand??null,docsUrl:b?.docsUrl??null})}}async function aD(a,b=!1){let c=(0,B.oZ)(a),d=J(S[a]);if(b||"discovery-loading"!==d.flowState){aJ(a,{flowState:"discovery-loading",errorMessage:null,statusMessage:"ollama"===a?"Checking the local Ollama runtime...":"Discovering available models..."});try{let b=await c.discoverModels();return aL(a,b,b.models.length>0?"discovery-success":b.emptyState?"discovery-empty":"idle"),b.snapshot&&l(b.snapshot),b}catch(c){let b=aK(c);return aJ(a,{flowState:"auth-error",errorMessage:c instanceof Error?c.message:"Model discovery failed.",manualCommand:b?.manualCommand??null,docsUrl:b?.docsUrl??null}),null}}}async function aE(a,b){let c=(0,B.oZ)(a),d=J(S[a]),e=(b?.selectedModelIds??d.selectedModelIds).filter(a=>{let b=av.get(a)??d.models.find(b=>b.id===a);return!!b&&!b.alreadyAdded});if(0===e.length)return!1;aJ(a,{flowState:"connecting",errorMessage:null,statusMessage:"Adding selected models..."});try{let f=await c.addModels(e);return aL(a,f,"add-success",{selectedModelIds:b?.selectedModelIds?d.selectedModelIds.filter(a=>!e.includes(a)):[]}),f.snapshot&&l(f.snapshot),b?.silent||F.o.success("Models added.",{description:f.message}),!0}catch(c){let b=aK(c);return aJ(a,{flowState:"add-error",errorMessage:c instanceof Error?c.message:"Models could not be added.",connection:b?.connection??d.connection,models:b?.models??d.models,manualCommand:b?.manualCommand??null,docsUrl:b?.docsUrl??null}),!1}}async function aF(){let a=[...ay.keys()];if(0!==a.length){X(!0);try{let b=0;for(let[a,c]of ay.entries())((0,r.a3)(a)?await aE(a,{silent:!0,selectedModelIds:c}):await aG(a,c))&&(b+=c.length);b>0?F.o.success("Models added.",{description:`Added ${b} model${1===b?"":"s"} from ${a.length} provider${1===a.length?"":"s"}.`}):F.o.error("Models could not be added.",{description:"Select a different catalog entry or open the Providers tab and try again."})}catch(a){F.o.error("Models could not be added.",{description:a instanceof Error?a.message:"Select a different catalog entry or open the Providers tab and try again."})}finally{X(!1)}}}async function aG(a,b){let c=b.filter(a=>{let b=av.get(a);return b&&!b.alreadyAdded});if(0===c.length)return!1;let d=await fetch("/api/models/catalog",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,modelIds:c})}),e=await d.json().catch(()=>null);if(!d.ok||!e)throw Error(e?.error||e?.message||"Catalog models could not be added.");return e.snapshot&&l(e.snapshot),T(a=>Object.fromEntries(Object.entries(a).map(([a,b])=>[a,b?{...b,selectedModelIds:b.selectedModelIds.filter(a=>!c.includes(a))}:b]))),!0}async function aH(a){try{V(!0);let b=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:a})}),c=await b.json().catch(()=>null);if(!b.ok)throw Error(c?.error||"Terminal could not be opened.");F.o.success("Terminal opened.",{description:"Finish the provider login there, then return here to discover models."})}catch(a){F.o.error("Unable to open Terminal.",{description:a instanceof Error?a.message:"Unknown terminal error."})}finally{V(!1)}}async function aI(a){try{await navigator.clipboard.writeText(a),F.o.success("Copied.",{description:"Command copied to your clipboard."})}catch{F.o.error("Copy failed.",{description:"Clipboard access is not available."})}}function aJ(a,b){T(c=>({...c,[a]:{...J(c[a]),...b}}))}function aK(a){return a instanceof B.jZ?a.result:null}function aL(a,b,c,d){aJ(a,{flowState:c,connection:b.connection,statusMessage:b.message,errorMessage:null,emptyState:b.emptyState??null,manualCommand:b.manualCommand??null,docsUrl:b.docsUrl??null,models:b.models,loaded:!0,...d})}return(0,d.jsx)(A.lG,{open:a,onOpenChange:b,children:(0,d.jsxs)(A.Cf,{className:"flex h-[80dvh] max-h-[80dvh] w-[calc(100vw-16px)] max-w-[760px] flex-col gap-0 overflow-hidden p-0 sm:h-[min(80dvh,700px)] sm:max-h-[min(80dvh,700px)] sm:w-[min(760px,calc(100vw-40px))]",children:[(0,d.jsxs)(A.c7,{className:"shrink-0 border-b border-white/10 bg-[linear-gradient(180deg,rgba(12,18,31,0.96),rgba(9,13,24,0.98))] px-4 py-3.5 pr-10",children:[(0,d.jsx)(A.L3,{className:"text-[1.05rem]",children:"Add Models"}),(0,d.jsx)(A.rr,{className:"max-w-[560px] text-[11px] leading-[1rem] text-slate-400",children:"Connect or refresh providers first, then browse the catalog when you want to add models in bulk."})]}),(0,d.jsxs)(v.tU,{value:O,onValueChange:a=>P(a),className:"min-h-0 flex flex-1 flex-col",children:[(0,d.jsx)("div",{className:"shrink-0 border-b border-white/10 px-4 py-3",children:(0,d.jsxs)(v.j7,{className:"h-8 rounded-[16px] p-0.5",children:[(0,d.jsx)(v.Xi,{value:"providers",className:"rounded-[13px] px-2.5 py-1 text-[10px]",children:"Providers"}),(0,d.jsx)(v.Xi,{value:"catalog",className:"rounded-[13px] px-2.5 py-1 text-[10px]",children:"Catalog"})]})}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[(0,d.jsx)(v.av,{value:"providers",className:"!mt-0 m-0 h-full",children:(0,d.jsxs)("div",{className:"space-y-4 px-3 py-3 sm:px-4 sm:py-4",children:[(0,d.jsxs)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(13,20,34,0.94),rgba(9,13,24,0.96))] p-3",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"All providers"}),(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-[0.95rem] text-slate-400",children:"Connect or refresh a provider, then return to the catalog when you want to add models in one pass."})]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[r.y8.length," total"]})]}),(0,d.jsxs)("div",{className:"relative mt-2.5",children:[(0,d.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-gradient-to-r from-[rgba(13,20,34,0.96)] to-transparent"}),(0,d.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-gradient-to-l from-[rgba(13,20,34,0.96)] to-transparent"}),(0,d.jsx)("div",{className:"-mx-1 overflow-x-auto overscroll-x-contain pb-1",children:(0,d.jsx)("div",{className:"flex min-w-max gap-2.5 px-1",children:r.y8.map(a=>(0,d.jsx)("div",{className:"w-[236px] shrink-0 snap-start sm:w-[244px]",children:(0,d.jsx)(z.I,{descriptor:a,active:ag===a.id,compact:!0,connected:L(c,S,a.id).connected,detail:L(c,S,a.id).detail,onClick:()=>{az(a.id)}})},a.id))})}),(0,d.jsx)("div",{className:"pointer-events-none absolute bottom-1.5 right-3 z-10 rounded-full border border-white/10 bg-slate-950/70 px-2 py-0.5 text-[8px] uppercase tracking-[0.14em] text-slate-400",children:"Scroll ->"})]})]}),(0,d.jsx)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:ag&&ai?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{children:(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:ai.label})}),(0,d.jsx)(o.E,{variant:aj?.connected?"success":"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:aj?.connected?"Connected":"Not connected"})]}),(0,d.jsx)("div",{className:"mt-3 flex flex-wrap gap-1",children:(m=ag,n=ah,s=aj,w="ollama"===m?!!(s?.connected||n.emptyState):!!(s?.connected||n.manualCommand),y=n.models.length>0||!!n.emptyState,C=n.selectedModelIds.length>0,M="add-success"===n.flowState,[{label:"Choose provider",status:"done"},{label:"ollama"===m?"Local check":"Connect",status:"connecting"!==n.flowState||w?w?"done":"pending":"active"},{label:"Discover",status:"discovery-loading"===n.flowState?"active":y?"done":"pending"},{label:"Select",status:M?"done":C?"active":"pending"},{label:"Add",status:M?"done":"add-error"===n.flowState?"active":"pending"}]).map(a=>(0,d.jsxs)("div",{className:(0,t.cn)("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[9px] uppercase tracking-[0.14em]","done"===a.status?"border-emerald-300/20 bg-emerald-300/10 text-emerald-100":"active"===a.status?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/10 bg-white/[0.03] text-slate-500"),children:[(0,d.jsx)("span",{className:(0,t.cn)("h-1.5 w-1.5 rounded-full","done"===a.status?"bg-emerald-300":"active"===a.status?"bg-cyan-300":"bg-slate-600")}),a.label]},a.label))}),ah.statusMessage&&!ak?(0,d.jsx)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-2",children:(0,d.jsx)("p",{className:"text-[11px] text-slate-200",children:ah.statusMessage})}):null,ah.errorMessage?(0,d.jsx)("div",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/[0.08] px-3 py-2 text-[11px] text-rose-100",children:ah.errorMessage}):null,as?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-amber-300/20 bg-amber-300/[0.08] px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-amber-50",children:"Gateway recovery"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-amber-100/78",children:"Automatic Gateway auth repair did not finish. Inspect Gateway status, then retry adding models."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,D.T)(ah.manualCommand)?(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aH(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null,(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aI(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null,ak?(0,d.jsx)("div",{className:"mt-4 flex min-h-[260px] items-center justify-center overflow-hidden rounded-[24px] border border-cyan-300/20 bg-[radial-gradient(circle_at_top,rgba(34,211,238,0.16),rgba(8,15,28,0.98)_70%)] px-4 py-10 text-center shadow-[0_22px_52px_rgba(7,11,20,0.32)]",children:(0,d.jsxs)("div",{className:"relative flex max-w-[340px] flex-col items-center",children:[(0,d.jsx)("div",{className:"absolute inset-x-8 top-8 h-px bg-gradient-to-r from-transparent via-cyan-200/70 to-transparent blur-sm animate-pulse"}),(0,d.jsx)("div",{className:"absolute inset-x-8 bottom-8 h-px bg-gradient-to-r from-transparent via-cyan-200/30 to-transparent blur-sm animate-pulse [animation-delay:180ms]"}),(0,d.jsx)("div",{className:"absolute left-8 top-8 h-24 w-24 rounded-full border border-cyan-300/15 bg-cyan-300/[0.04] blur-[1px] animate-pulse"}),(0,d.jsx)("div",{className:"absolute right-10 top-14 h-16 w-16 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:120ms]"}),(0,d.jsx)("div",{className:"absolute bottom-10 left-1/2 h-20 w-20 -translate-x-1/2 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:240ms]"}),(0,d.jsx)("div",{className:"relative mb-4 flex h-16 w-16 items-center justify-center rounded-full border border-cyan-300/20 bg-cyan-300/[0.08] shadow-[0_0_0_8px_rgba(34,211,238,0.05)]",children:(0,d.jsx)(f.A,{className:"h-8 w-8 animate-spin text-cyan-200"})}),(0,d.jsx)("p",{className:"font-display text-[1.1rem] leading-[1.2rem] tracking-[0.01em] text-white",children:al}),(0,d.jsx)("p",{className:"mt-2 max-w-[280px] text-[11px] leading-[1rem] text-slate-400",children:am}),(0,d.jsxs)("div",{className:"mt-4 flex gap-1.5",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/90"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/60 [animation-delay:120ms]"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/30 [animation-delay:240ms]"})]})]})}):(0,d.jsxs)(d.Fragment,{children:["openai-codex"===ag?(0,d.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Use Codex app-server"}),(0,d.jsxs)("p",{className:"mt-1 max-w-[500px] text-[10px] leading-[0.98rem] text-slate-400",children:["OpenClaw ",E.L," uses the Codex app-server plugin for ChatGPT-backed models."]})]}),(0,d.jsx)(p.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState&&!ah.manualCommand,onClick:()=>{aj?.connected?aA(ag):aB(ag)},children:"connecting"!==ah.flowState||ah.manualCommand?aj?.connected?"Refresh status":"Connect ChatGPT":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]})}),(0,d.jsx)(p.$,{type:"button",variant:"ghost",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState&&!ah.manualCommand,onClick:()=>{aj?.connected?aC(ag):aB(ag,{force:!0})},children:aj?.connected?"Switch account":"Refresh setup"})]}),ah.manualCommand?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish setup in Terminal"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, complete the Codex app-server setup, then return here and check discovery."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aH(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aI(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aD(ag)},children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null]}):null,"apiKey"===ai.connectKind?(0,d.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("label",{className:"block text-[9px] uppercase tracking-[0.16em] text-slate-500",children:"API key"}),(0,d.jsx)(q.p,{type:"password",value:ah.apiKey,onChange:a=>aJ(ag,{apiKey:a.target.value}),placeholder:"openrouter"===ag?"sk-or-v1-...":"Paste API key",className:"mt-1.5 h-8 text-[11px]"})]}),(0,d.jsx)(p.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===ah.flowState||!ah.apiKey.trim(),onClick:()=>{aB(ag)},children:"connecting"===ah.flowState?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]}):`Connect ${ai.shortLabel}`})]}),ah.manualCommand?(0,d.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish setup in Terminal"}),(0,d.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, paste the provider API key there, then return here and check discovery."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:U,onClick:()=>{aH(ah.manualCommand||"")},children:U?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aI(ah.manualCommand||"")},children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,d.jsxs)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{aD(ag)},children:[(0,d.jsx)(i.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,d.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:ah.manualCommand})})]}):null]}):null,an?(0,d.jsx)("div",{className:"mt-4 rounded-[24px] border border-cyan-300/20 bg-[linear-gradient(180deg,rgba(17,28,47,0.98),rgba(10,16,28,0.98))] p-4 shadow-[0_18px_42px_rgba(7,11,20,0.28)]",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"font-display text-[0.92rem] text-white",children:ao?"Discovering models...":ap}),(0,d.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[1rem] text-slate-400",children:ao?"OpenClaw is pulling the provider catalog into this workspace.":ar})]}),(0,d.jsxs)("div",{className:"flex shrink-0 flex-wrap gap-2",children:[(0,d.jsx)(p.$,{type:"button",variant:"default",className:"h-11 rounded-full px-5 text-[12px] font-medium",disabled:ao,onClick:()=>{aD(ag)},children:ao?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Discovering..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.A,{className:"mr-2 h-4 w-4"}),aq]})}),(0,d.jsx)(p.$,{type:"button",variant:"ghost",size:"sm",className:"h-11 rounded-full px-4 text-[10px]",onClick:()=>{aA(ag)},children:"Refresh status"})]})]})}):null,ah.emptyState?(0,d.jsx)(I,{emptyState:ah.emptyState,onCopyCommand:a=>{aI(a)}}):null,ah.models.length>0?(0,d.jsx)("div",{className:"mt-5",children:(0,d.jsx)(x,{provider:ag,models:ah.models,selectedModelIds:ah.selectedModelIds,search:ah.search,onSearchChange:a=>aJ(ag,{search:a}),onToggleModel:a=>{aJ(ag,{selectedModelIds:ah.selectedModelIds.includes(a)?ah.selectedModelIds.filter(b=>b!==a):[...ah.selectedModelIds,a]})},onAddSelected:()=>{aE(ag)},isAdding:"connecting"===ah.flowState&&"Adding selected models..."===ah.statusMessage})}):null,"add-success"===ah.flowState?(0,d.jsxs)("div",{className:"mt-3 flex items-center gap-2.5 rounded-[16px] border border-emerald-300/20 bg-emerald-300/[0.08] px-3 py-2",children:[(0,d.jsx)(j.A,{className:"h-3.5 w-3.5 text-emerald-200"}),(0,d.jsx)("p",{className:"text-[11px] text-emerald-50",children:ah.statusMessage||"Models were added successfully."})]}):null,ah.docsUrl?(0,d.jsx)("a",{href:ah.docsUrl,target:"_blank",rel:"noreferrer",className:"mt-3 inline-flex text-[10px] text-slate-300 underline underline-offset-4",children:"OpenClaw model docs"}):null]})]}):(0,d.jsx)("div",{className:"flex min-h-[180px] items-center justify-center rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-6 text-center",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Choose a provider to begin"}),(0,d.jsx)("p",{className:"mt-1.5 max-w-[360px] text-[11px] leading-[0.98rem] text-slate-400",children:"Start with ChatGPT, OpenRouter, Gemini, DeepSeek, Mistral, or Ollama Local. The flow will guide you through connect, discovery, selection, and add."})]})})})]})}),(0,d.jsx)(v.av,{value:"catalog",className:"!mt-0 m-0 h-full",children:(0,d.jsxs)("div",{className:"space-y-4 px-3 py-3 sm:px-4 sm:py-4",children:[(0,d.jsx)("div",{className:"rounded-[20px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"OpenClaw catalog"}),(0,d.jsx)("p",{className:"mt-1 text-[9px] leading-[0.95rem] text-slate-400",children:"Search the full OpenClaw model catalog, then load five more whenever you want to extend the list."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[at.length," models"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[aw," providers"]}),(0,d.jsxs)(o.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[ax," added"]})]})]})}),ae?(0,d.jsx)("div",{className:"rounded-[18px] border border-rose-400/20 bg-rose-400/[0.08] px-4 py-3 text-[11px] text-rose-100",children:ae}):null,(0,d.jsx)(u,{models:at,selectedModelIds:au,search:Y,onSearchChange:Z,onToggleModel:(a,b)=>{let c=J(S[a]);aJ(a,{selectedModelIds:c.selectedModelIds.includes(b)?c.selectedModelIds.filter(a=>a!==b):[...c.selectedModelIds,b]})},onAddSelected:()=>{aF()},onOpenProviders:a=>{P("providers"),(0,r.a3)(a)&&az(a)},onLoadMore:()=>_(a=>a+5),visibleModelCount:$,isAdding:W,isLoading:ac&&0===at.length}),ac||0!==at.length||ae?null:(0,d.jsx)("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-5 text-center text-[11px] text-slate-400",children:"OpenClaw did not return any supported models yet. Check your installation or refresh providers."})]})})]})]})]})})}function I({emptyState:a,onCopyCommand:b}){return(0,d.jsxs)("div",{className:"mt-3 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,d.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:a.title}),(0,d.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[0.98rem] text-slate-400",children:a.description}),a.commands?.length?(0,d.jsx)("div",{className:"mt-3 space-y-1.5",children:a.commands.map(a=>(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:[(0,d.jsx)("code",{className:"text-[10px] text-slate-200",children:a}),(0,d.jsxs)(p.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>b(a),children:[(0,d.jsx)(h.A,{className:"mr-1.5 h-3 w-3"}),"Copy"]})]},a))}):null]})}function J(a){return a||G()}function K(a){return!a.missing&&!1!==a.available}function L(a,b,c){let d=b[c]?.connection;if(d)return d;let e=a.diagnostics.modelReadiness.authProviders.find(a=>a.provider===c),f=a.models.filter(a=>{var b,d,e;return b=c,d=a.id,e=a.provider,(0,C.Pr)(b,d,e)}).length;if("ollama"===c)return{provider:c,connected:f>0,canConnect:!0,needsTerminal:!1,detail:f>0?`${f} model${1===f?"":"s"} already visible in AgentOS.`:"Detect local models from this machine."};let g=!!e?.connected;return{provider:c,connected:g,canConnect:!0,needsTerminal:"openai-codex"===c,detail:g?e?.detail||(0,r.W2)(c).helperText:f>0?`${f} model${1===f?"":"s"} are already saved in AgentOS. Connect ${(0,r.W2)(c).shortLabel} to use them.`:(0,r.W2)(c).helperText}}},49444:(a,b,c)=>{"use strict";c.d(b,{p:()=>g});var d=c(3814),e=c(6247),f=c(32905);let g=e.forwardRef(({className:a,type:b,...c},e)=>(0,d.jsx)("input",{type:b,className:(0,f.cn)("flex h-11 w-full rounded-lg border border-input bg-card px-4 py-2 text-sm text-foreground placeholder:text-muted-foreground shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",a),ref:e,...c}));g.displayName="Input"},52188:(a,b,c)=>{"use strict";function d(a,b,c){let d=c||b.split("/",1)[0]||"";return"openai-codex"===a?"codex"===d||"openai-codex"===d||g(b):d===a}function e(a){let b=a.trim(),c=/^(?:codex|openai-codex)\/(.+)$/i.exec(b);return c?`openai/${c[1]}`:b}function f(a,b){let c=e(a);return"openai-codex"===b||/^codex\//i.test(a)||/^openai-codex\//i.test(a)||g(c)?`openai-codex:${c.toLowerCase()}`:`${b}:${c.toLowerCase()}`}function g(a){return/^openai\/(?:gpt-5\.5|gpt-5\.4-mini)$/i.test(a)||/^openai\/.*codex/i.test(a)}c.d(b,{JN:()=>e,Pr:()=>d,gt:()=>f,jw:()=>g}),c(60557)},52846:(a,b,c)=>{"use strict";c.d(b,{J:()=>k});var d=c(3814),e=c(6247),f=c(98036),g=c(49113);let h={"product-hunt":"siProducthunt","producthunt.com":"siProducthunt",gmail:"siGmail","mail.google.com":"siGmail","accounts.google.com":"siGmail","x-twitter":"siX","x.com":"siX","twitter.com":"siX",github:"siGithub","github.com":"siGithub",discord:"siDiscord","discord.com":"siDiscord",telegram:"siTelegram","web.telegram.org":"siTelegram"};function i(a){return a?.trim().toLowerCase()||null}var j=c(32905);function k({serviceId:a,serviceName:b,primaryDomain:c,className:m}){let n=(0,e.useMemo)(()=>{let d;return(d=function(a){for(let b of[a.primaryDomain,a.serviceId,a.serviceName]){let a=function(a){let b=a?.trim().toLowerCase();if(!b)return null;let c=b.includes("://")?b:`https://${b}`;try{let a=new URL(c).hostname.replace(/^www\./,"");if(!a||"localhost"===a||!a.includes(".")||!/^[a-z0-9.-]+$/.test(a))return null;return a}catch{return null}}(b);if(a)return a}return null}({serviceId:a,serviceName:b,primaryDomain:c}))?[`https://${d}/favicon.ico`,`https://www.google.com/s2/favicons?domain=${encodeURIComponent(d)}&sz=64`]:[]},[c,a,b]),o=n.join("\0"),p=function(a){for(let b of[i(a.serviceId),i(a.primaryDomain),i(a.serviceName)].filter(a=>!!a)){let a=h[b];if(a)return a;let c=b.replace(/^www\./,"");if(h[c])return h[c]}return null}({serviceId:a,primaryDomain:c,serviceName:b}),q=p?f[p]:void 0,r=(b||c||a||"Account").trim().slice(0,1).toUpperCase(),s=q?(0,d.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[58%] w-[58%] select-none",fill:`#${q.hex}`,children:(0,d.jsx)("path",{d:q.path})}):r?(0,d.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-white/88",children:r}):(0,d.jsx)(g.A,{className:"h-[54%] w-[54%] text-white/88"});return(0,d.jsx)("div",{className:(0,j.cn)("flex items-center justify-center overflow-hidden rounded-full border border-white/12 bg-slate-950/72 text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)] backdrop-blur-xl",m),"aria-hidden":"true",children:n.length>0?(0,d.jsx)(l,{sources:n,fallback:s},o):s})}function l({sources:a,fallback:b}){let[c,f]=(0,e.useState)(0),g=a[c];return g?(0,d.jsx)("img",{src:g,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",className:"h-[70%] w-[70%] select-none rounded-[4px] object-contain",onError:()=>f(a=>a+1)}):b}},58372:(a,b,c)=>{"use strict";function d(a){let b=function(a){let b=a?.trim();if(!b)return[];let c=[],d=0,e=0,f="unquoted";for(;e<b.length;){let a=b[e],g=b[e+1];if("single"===f){"'"===a&&(f="unquoted"),e+=1;continue}if("double"===f){if("\\"===a){e+=2;continue}'"'===a&&(f="unquoted"),e+=1;continue}if("'"===a){f="single",e+=1;continue}if('"'===a){f="double",e+=1;continue}if("&"===a&&"&"===g){let a=b.slice(d,e).trim();if(!a)return[];c.push(a),e+=2,d=e;continue}if(";"===a||"|"===a||"\n"===a||"\r"===a||"`"===a||"<"===a||">"===a||"$"===a&&"("===g)return[];e+=1}let g=b.slice(d).trim();return g?(c.push(g),c):[]}(a);return 0!==b.length&&b.every(a=>{var b;return!!("openclaw"===(b=(function(a){let b=a?.trim();if(!b)return null;let c=0;for(;c<b.length&&/\s/.test(b[c]);)c+=1;if(c>=b.length)return null;let d="",e="unquoted";for(;c<b.length;){let a=b[c];if("unquoted"===e){if(/\s/.test(a))break;if("'"===a){e="single",c+=1;continue}if('"'===a){e="double",c+=1;continue}if("\\"===a&&c+1<b.length){d+=b[c+1],c+=2;continue}d+=a,c+=1;continue}if("single"===e){if("'"===a){e="unquoted",c+=1;continue}d+=a,c+=1;continue}if('"'===a){e="unquoted",c+=1;continue}if("\\"===a&&c+1<b.length){d+=b[c+1],c+=2;continue}d+=a,c+=1}return d})(a)?.toLowerCase())||b?.endsWith("/openclaw")||b?.endsWith("\\openclaw"))})}c.d(b,{T:()=>d})},59056:(a,b,c)=>{"use strict";c.d(b,{v:()=>e});var d=c(6247);function e(a){let[b,c]=(0,d.useState)(a),[e,f]=(0,d.useState)("connecting"),g=async(a={})=>{let b=a.force?"/api/snapshot?force=true":"/api/snapshot",e=await fetch(b,{cache:"no-store"}),g=await e.json();return(0,d.startTransition)(()=>{c(a=>!function(a,b){let c=a.revision??0,d=b.revision??0;if(c!==d)return c>d;if("live"===b.mode&&"fallback"===a.mode)return!1;if("fallback"===b.mode&&"live"===a.mode)return!0;let e=Date.parse(a.generatedAt),f=Date.parse(b.generatedAt);return!!(Number.isNaN(e)||Number.isNaN(f))||e>=f}(g,a)?a:g),f("live")}),g};return{snapshot:b,connectionState:e,refresh:async()=>{await g()},refreshSnapshot:g,setSnapshot:c}}},60251:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,83316,23)),Promise.resolve().then(c.t.bind(c,64943,23)),Promise.resolve().then(c.t.bind(c,87907,23)),Promise.resolve().then(c.t.bind(c,966,23)),Promise.resolve().then(c.t.bind(c,19698,23)),Promise.resolve().then(c.t.bind(c,12582,23)),Promise.resolve().then(c.t.bind(c,53635,23)),Promise.resolve().then(c.t.bind(c,4246,23))},60557:(a,b,c)=>{"use strict";c.d(b,{S:()=>i,W2:()=>f,a3:()=>g,d4:()=>h,y8:()=>e});var d=c(68885);let e=[{id:"openai-codex",label:"ChatGPT",shortLabel:"ChatGPT",description:"Use OpenClaw's Codex app-server provider and pull in Codex-ready models.",category:"primary",connectKind:"oauth",accent:"from-[#d8f5eb] via-[#ebfbf5] to-white",helperText:`OpenClaw ${d.L} uses the Codex app-server plugin for this route.`},{id:"openrouter",label:"OpenRouter",shortLabel:"OpenRouter",description:"Add an API key, discover the full catalog, and curate the models you want.",category:"primary",connectKind:"apiKey",accent:"from-[#fff2d7] via-[#fff7ea] to-white",helperText:"Best for broad model access and curated remote routes.",searchPlaceholder:"Search OpenRouter models"},{id:"ollama",label:"Ollama Local",shortLabel:"Ollama",description:"Discover models already available on this machine and add them instantly.",category:"primary",connectKind:"local",accent:"from-[#deefff] via-[#f2f8ff] to-white",helperText:"Local-first discovery with helpful pull commands when empty."},{id:"anthropic",label:"Anthropic",shortLabel:"Anthropic",description:"Paste an API key and add Claude models through the same flow.",category:"other",connectKind:"apiKey",accent:"from-[#efe9ff] via-[#f7f3ff] to-white",helperText:"Simple API key connection."},{id:"openai",label:"OpenAI API",shortLabel:"OpenAI",description:"Connect a standard OpenAI API key for direct GPT model access.",category:"other",connectKind:"apiKey",accent:"from-[#e8f8e8] via-[#f4fbf4] to-white",helperText:"Use this for API-key-based OpenAI routing."},{id:"google",label:"Gemini",shortLabel:"Gemini",description:"Add a Gemini API key, discover Google models, and pick the routes you want.",category:"other",connectKind:"apiKey",accent:"from-[#e6f7ff] via-[#f4fbff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Gemini models"},{id:"deepseek",label:"DeepSeek",shortLabel:"DeepSeek",description:"Add a DeepSeek API key, discover the catalog, and add the models you need.",category:"other",connectKind:"apiKey",accent:"from-[#e7eeff] via-[#f4f7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search DeepSeek models"},{id:"mistral",label:"Mistral",shortLabel:"Mistral",description:"Add a Mistral API key, discover Mistral and Codestral models, and curate your routes.",category:"other",connectKind:"apiKey",accent:"from-[#f2e8ff] via-[#fbf7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Mistral models"},{id:"xai",label:"xAI",shortLabel:"xAI",description:"Use an xAI API key to bring Grok models into AgentOS.",category:"other",connectKind:"apiKey",accent:"from-[#ffe6ea] via-[#fff3f5] to-white",helperText:"Simple API key connection."}];function f(a){let b=e.find(b=>b.id===a);if(!b)throw Error(`Unknown model provider: ${a}`);return b}function g(a){return"string"==typeof a&&e.some(b=>b.id===a)}function h(a){if("codex"===a)return"openai-codex";if("gemini"===a)return"google";if(g(a))return a;if(a&&"object"==typeof a&&"id"in a){let b=a.id;if("codex"===b)return"openai-codex";if("gemini"===b)return"google";if(g(b))return b}return null}function i(a){if("codex"===a)return"Codex";let b=e.find(b=>b.id===a);return b?b.shortLabel:a.split("-").map(a=>a?a[0].toUpperCase()+a.slice(1):a).join(" ")}e.filter(a=>"primary"===a.category),e.filter(a=>"other"===a.category)},60740:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,83316,23))},61655:(a,b,c)=>{"use strict";c.d(b,{F:()=>h});var d=c(3814),e=c(6247),f=c(84504),g=c(32905);let h=e.forwardRef(({className:a,children:b,...c},e)=>(0,d.jsxs)(f.bL,{ref:e,className:(0,g.cn)("relative overflow-hidden",a),...c,children:[(0,d.jsx)(f.LM,{className:"mission-scroll h-full w-full rounded-[inherit] [&>div]:!block [&>div]:!w-full [&>div]:!min-w-0",children:b}),(0,d.jsx)(i,{}),(0,d.jsx)(f.OK,{})]}));h.displayName=f.bL.displayName;let i=e.forwardRef(({className:a,orientation:b="vertical",...c},e)=>(0,d.jsx)(f.VM,{ref:e,orientation:b,className:(0,g.cn)("flex touch-none select-none transition-colors","vertical"===b&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===b&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...c,children:(0,d.jsx)(f.lr,{className:"relative flex-1 rounded-full bg-muted-foreground/25"})}));i.displayName=f.VM.displayName},63292:(a,b,c)=>{"use strict";c.d(b,{A:()=>g});var d=c(3814),e=c(45317),f=c(32905);function g({label:a,side:b,surfaceTheme:c,panelCollapsed:h,children:i}){return(0,d.jsx)(e.Bc,{delayDuration:120,children:(0,d.jsxs)(e.m_,{children:[(0,d.jsx)(e.k$,{asChild:!0,children:i}),(0,d.jsx)(e.ZI,{side:b,align:"center",sideOffset:10,className:(0,f.cn)("rounded-[10px] px-2.5 py-1.5 text-[10px] font-medium leading-none tracking-[0.12em] whitespace-nowrap shadow-[0_16px_40px_rgba(0,0,0,0.32)]","light"===c?h?"border border-slate-200/80 bg-white/96 text-slate-900 shadow-[0_16px_40px_rgba(15,23,42,0.18)]":"border border-white/10 bg-slate-950/94 text-white shadow-[0_16px_40px_rgba(0,0,0,0.36)]":"border border-white/10 bg-slate-950/92 text-slate-100"),children:a})]})})}},63381:()=>{},68885:(a,b,c)=>{"use strict";c.d(b,{L:()=>d});let d="2026.6.1"},69903:(a,b,c)=>{"use strict";c.d(b,{nK:()=>l,TY:()=>f,qk:()=>j,w6:()=>i,nd:()=>g});var d=c(9494),e=c(92078);function f(a,b={}){let c=(0,e.g0)(b.policy?.preset??"worker",b.policy),g=(0,e.Cf)(c.preset),h=(0,d.iq)(c.preset,b.heartbeat);return{workspaceId:a,modelId:b.modelId??"",name:b.name??g.defaultName,emoji:b.emoji??g.defaultEmoji,theme:b.theme??g.defaultTheme,avatar:b.avatar??"",policy:c,heartbeat:h,channelIds:Array.from(new Set((b.channelIds??[]).filter(a=>"string"==typeof a&&!!a.trim())))}}function g(a,b){let c=a.diagnostics.modelReadiness.defaultModelReady?h(a.diagnostics.modelReadiness.resolvedDefaultModel||a.diagnostics.modelReadiness.defaultModel):null;if(c&&i(a,c))return c;let d=a.agents.filter(a=>!b||a.workspaceId===b).map(a=>h(a.modelId)).find(b=>b&&i(a,b));if(d)return d;let e=h(a.diagnostics.modelReadiness.recommendedModelId);return e&&i(a,e)?e:a.models.map(a=>h(a.id)).find(b=>b&&i(a,b))??""}function h(a){let b=a?.trim();return b&&"unassigned"!==b?b:null}function i(a,b){let c=a.models.find(a=>a.id===b);return!!c&&!0!==c.missing&&!1!==c.available}function j(a,b,c){var d,e;let f,g,h=(d=b,e=c,f=k(d??""),g=k(e)||"agent",f?`${f}-${g}`:g);if(!h)return"";let i=new Set(a.map(a=>a.id));if(!i.has(h))return h;let j=2,l=`${h}-${j}`;for(;i.has(l);)j+=1,l=`${h}-${j}`;return l}function k(a){return a.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function l(a,b){let c=(0,e.Cf)(a.policy.preset),f=(0,e.Cf)(b),g=(0,e.g0)(b);return{...a,name:a.name&&a.name!==c.defaultName?a.name:f.defaultName,emoji:a.emoji&&a.emoji!==c.defaultEmoji?a.emoji:f.defaultEmoji,theme:a.theme&&a.theme!==c.defaultTheme?a.theme:f.defaultTheme,policy:g,heartbeat:(0,d.I$)(a.heartbeat,a.policy.preset,b)}}},72349:(a,b,c)=>{"use strict";function d(a){return f(a)}function e(a){var b;return f(a)&&(a.diagnostics.modelReadiness.ready||!!(b=a).agents.map(a=>{var b;let c;return b=a.modelId,(c=b?.trim())&&"unassigned"!==c?c:null}).find(a=>{var c,d,e,f,g;let h;return a&&(c=b,d=a,!!(h=(e=c,f=d,e.models.find(a=>a.id===f)))&&!0!==(g=h).missing&&!1!==g.available)}))}function f(a){return a.diagnostics.installed&&a.diagnostics.rpcOk&&!!(a.diagnostics.runtime?.stateWritable&&a.diagnostics.runtime?.sessionStoreWritable)}c.d(b,{X2:()=>e,h6:()=>d,iN:()=>f})},73767:(a,b,c)=>{Promise.resolve().then(c.bind(c,43081)),Promise.resolve().then(c.t.bind(c,98296,23))},74952:(a,b,c)=>{"use strict";c.d(b,{T:()=>g});var d=c(3814),e=c(6247),f=c(32905);let g=e.forwardRef(({className:a,...b},c)=>(0,d.jsx)("textarea",{className:(0,f.cn)("flex min-h-[96px] w-full rounded-lg border border-input bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50",a),ref:c,...b}));g.displayName="Textarea"},80990:(a,b,c)=>{"use strict";c.d(b,{$:()=>j});var d=c(3814),e=c(6247),f=c(69598),g=c(9082),h=c(32905);let i=(0,g.F)("inline-flex items-center justify-center whitespace-nowrap rounded-lg text-sm font-semibold transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-lg shadow-primary/20 hover:bg-primary/90",secondary:"border border-border bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"text-muted-foreground hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive text-destructive-foreground shadow-lg shadow-destructive/20 hover:bg-destructive/90"},size:{default:"h-11 px-4 py-2",sm:"h-9 rounded-lg px-3",lg:"h-12 rounded-lg px-5",icon:"h-11 w-11"}},defaultVariants:{variant:"default",size:"default"}}),j=e.forwardRef(({className:a,variant:b,size:c,asChild:e=!1,...g},j)=>{let k=e?f.DX:"button";return(0,d.jsx)(k,{className:(0,h.cn)(i({variant:b,size:c,className:a})),ref:j,...g})});j.displayName="Button"},82425:(a,b,c)=>{"use strict";c.d(b,{z:()=>A});var d=c(3814),e=c(6247),f=c(11917),g=c(57825),h=c(32956),i=c(57531),j=c(5813),k=c(49444),l=c(32905);function m({title:a,selectedValues:b,selectedTone:c,selectedEmptyLabel:e,lockedValues:f=[],observedValues:g=[],inputRef:o,inputValue:p,onInputValueChange:q,onRemove:r,onPick:s,suggestions:t,emptySuggestionLabel:u,loading:v,catalogError:w,helperLabel:x,currentHintLabel:y,highlight:z}){let A="cyan"===c?{border:"border-cyan-300/20",chip:"border-cyan-300/15 bg-cyan-400/10 text-cyan-50",chipHover:"hover:border-cyan-200/30 hover:bg-cyan-400/15"}:{border:"border-amber-300/20",chip:"border-amber-300/15 bg-amber-400/10 text-amber-50",chipHover:"hover:border-amber-200/30 hover:bg-amber-400/15"},B=f.length>0,C=new Set(f),D=`Current ${a.toLowerCase()}`,E=`${a}:${p}:${t.length}:${t[0]?.value??""}`;return(0,d.jsxs)("div",{className:(0,l.cn)("rounded-[18px] border bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] p-3.5",A.border,z&&"shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,d.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:a}),(0,d.jsx)(j.E,{variant:"muted",children:"Declared"})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:D}),(0,d.jsx)("p",{className:"text-[10px] leading-4 text-slate-400",children:y})]}),(0,d.jsxs)(j.E,{variant:"muted",children:[b.length," current"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.length>0?b.map(a=>{let b=C.has(a);return(0,d.jsxs)("div",{className:(0,l.cn)("inline-flex max-w-full items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] transition-colors",A.chip,A.chipHover,b&&"cursor-not-allowed pr-2.5"),title:b?`Managed by policy: ${a}`:a,children:[(0,d.jsx)("span",{className:"max-w-full truncate",children:a}),b?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 text-white/70",children:(0,d.jsx)(h.A,{className:"h-3 w-3"})}):(0,d.jsx)("button",{type:"button","aria-label":`Remove ${a}`,title:`Remove ${a}`,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/10 text-white/70 transition-colors hover:border-white/20 hover:bg-white/20 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/60 focus-visible:ring-offset-0",onClick:()=>r(a),children:(0,d.jsx)(i.A,{className:"h-2.5 w-2.5"})})]},a)}):(0,d.jsx)(j.E,{variant:"muted",children:e})})]}),(0,d.jsx)("div",{children:(0,d.jsx)(k.p,{ref:o,value:p,onChange:a=>q(a.target.value),onKeyDown:a=>(function(a,b,c){if("Enter"!==a.key)return;a.preventDefault();let d=b[0];d&&c(d.value)})(a,t,s),placeholder:"Skills"===a?"Search OpenClaw or workspace skills":"Search built-in tools or plugin tools",className:"h-8 flex-1 rounded-xl border-white/10 bg-white/5 px-3 text-[12px]"})}),(0,d.jsx)("div",{className:"space-y-2",children:(0,d.jsx)(n,{kind:"Skills"===a?"skill":"tool",suggestions:t,onPick:s,emptyLabel:u},E)}),B?(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Policy locked"}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:f.map(a=>(0,d.jsxs)(j.E,{variant:"success",children:[(0,d.jsx)(h.A,{className:"mr-1 h-3 w-3"}),a]},a))})]}):null,g.length>0?(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed"}),(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:g.slice(0,10).map(a=>(0,d.jsx)(j.E,{variant:"muted",children:a},a))})]}):null,(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:x}),w?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:w}):null,v&&0===t.length?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:"Loading OpenClaw catalog..."}):null]})]})}function n({kind:a,suggestions:b,onPick:c,emptyLabel:f}){let[g,h]=(0,e.useState)(8),i=b.slice(0,g),k=Math.max(b.length-i.length,0);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Available to add"}),(0,d.jsxs)(j.E,{variant:"muted",children:[b.length," total"]})]}),(0,d.jsx)("div",{className:"max-h-[280px] space-y-1.5 overflow-y-auto pr-1",children:(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(o,{kind:a,options:i,onPick:c,emptyLabel:f}),k>0?(0,d.jsxs)("button",{type:"button",onClick:()=>h(a=>a+8),className:"group flex w-full items-center justify-center gap-2 rounded-xl border border-dashed border-cyan-300/20 bg-cyan-400/[0.04] px-3 py-2 text-[11px] text-cyan-100 transition-colors hover:border-cyan-200/35 hover:bg-cyan-400/[0.08] hover:text-white",children:[(0,d.jsx)("span",{className:"uppercase tracking-[0.18em]",children:"Load more"}),(0,d.jsxs)(j.E,{variant:"muted",className:"h-5 px-2 py-0 text-[10px]",children:["+",k]})]}):null]})})]})}function o({kind:a,options:b,onPick:c,emptyLabel:e}){return 0===b.length?(0,d.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:e}):(0,d.jsx)("div",{className:"space-y-1.5",children:b.map(b=>{var e;return(0,d.jsxs)("button",{type:"button",className:(0,l.cn)("group flex w-full items-start justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.03] px-3 py-1.5 text-left transition-colors hover:border-cyan-300/20 hover:bg-cyan-400/[0.05]","tool"===a&&"hover:border-amber-300/20 hover:bg-amber-400/[0.05]"),onClick:()=>c(b.value),title:b.description,children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("p",{className:"truncate text-[12px] leading-4 text-white",children:b.label}),"group"===b.category?(0,d.jsx)(j.E,{variant:"muted",children:"group"}):null]}),(0,d.jsx)("p",{className:"line-clamp-2 text-[11px] leading-4 text-slate-400",children:b.description})]}),(0,d.jsx)(j.E,{variant:"skill"===(e=b).kind?"workspace"===e.category?"success":"custom"===e.category?"muted":"default":"plugin"===e.category?"warning":"group"===e.category||"custom"===e.category?"muted":"default",className:"shrink-0 h-4 max-w-[132px] px-1.5 py-0 text-[8px] font-medium tracking-[0.08em] normal-case",children:(0,d.jsx)("span",{className:"truncate",children:b.sourceLabel})})]},b.value)})})}var p=c(80990),q=c(37674),r=c(92078),s=c(90665);function t(a,b){let c=new Map;for(let e of a){var d;let a=e.value.trim();if(!a)continue;let f=c.get(a);if(!f){c.set(a,{...e,value:a,label:e.label||a,description:e.description||"",sourceLabel:e.sourceLabel||"OpenClaw",sourceRank:e.sourceRank??99,kind:e.kind||b,category:e.category});continue}f.description=f.description||e.description,d=f.sourceLabel,f.sourceLabel=w([d,e.sourceLabel].filter(a=>!!a)).join(" \xb7 "),f.sourceRank=Math.min(f.sourceRank,e.sourceRank??f.sourceRank),f.category=f.category??e.category}return Array.from(c.values()).sort((a,b)=>{let c=a.sourceRank-b.sourceRank;if(0!==c)return c;let d=a.label.localeCompare(b.label);return 0!==d?d:a.value.localeCompare(b.value)})}function u(a,b,c,d=8){let e=b.trim().toLowerCase(),f=new Set(w(c));return a.filter(a=>!f.has(a.value)).filter(a=>!e||5>y(a,e)).sort((a,b)=>{let c=y(a,e),d=y(b,e);if(c!==d)return c-d;let f=a.sourceRank-b.sourceRank;return 0!==f?f:a.label.localeCompare(b.label)}).slice(0,d)}function v(a){return"builtin"===a.category?"OpenClaw built-in":"group"===a.category?"OpenClaw docs":a.source}function w(a){let b=new Set,c=[];for(let d of a){if("string"!=typeof d)continue;let a=d.trim();!a||b.has(a)||(b.add(a),c.push(a))}return c}function x(a,b){return a.length===b.length&&a.every((a,c)=>a===b[c])}function y(a,b){if(!b)return 0;let c=[a.value.toLowerCase(),a.label.toLowerCase(),a.description.toLowerCase(),a.sourceLabel.toLowerCase()];return c.some(a=>a===b)?0:c.some(a=>a.startsWith(b))?1:c.some(a=>a.includes(b))?2:5}var z=c(30540);function A({open:a,agentId:b,initialFocus:c="skills",snapshot:h,onOpenChange:i,onSnapshotChange:k,onRefresh:l}){let n=b?h.agents.find(a=>a.id===b)??null:null,o=h.workspaces.find(a=>a.id===n?.workspaceId),[y,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(null),[K,L]=(0,e.useState)(""),[M,N]=(0,e.useState)(""),[O,P]=(0,e.useState)([]),[Q,R]=(0,e.useState)([]),S=(0,e.useRef)(null),T=(0,e.useRef)(null);(0,e.useRef)(h);let U="tools"===c?"tools":"skills",V="skills"===U,W="tools"===U,X=n?(0,r.Cf)(n.policy.preset):null,Y=w(n?.skills??[]),Z=w((n?.tools??[]).filter(a=>"fs.workspaceOnly"!==a)),$=Y.length>0?Y:w(X?.skillIds??[]),_=Z.length>0?Z:w(X?.tools??[]),aa=n?.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[],ab=w(n?.observedTools??[]),ac=w(o?.bootstrap.localSkillIds??[]),ad=(0,e.useMemo)(()=>[...z.j,...z.T],[]),ae=(0,e.useMemo)(()=>t([...(y?.skills??[]).map(a=>{var b;return{value:a.name,label:a.name,description:a.description,sourceLabel:"openclaw-bundled"===(b=a.source)?"OpenClaw bundled":"workspace"===b?"Workspace":b,sourceRank:+("openclaw-bundled"!==a.source),kind:"skill"}}),...ac.map(a=>({value:a,label:a,description:"Workspace-local SKILL.md scaffold.",sourceLabel:"Workspace",sourceRank:0,kind:"skill",category:"workspace"})),...O.filter(a=>!(y?.skills??[]).some(b=>b.name===a)).map(a=>({value:a,label:a,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:2,kind:"skill",category:"custom"}))],"skill"),[y?.skills,O,ac]),af=(0,e.useMemo)(()=>t([...ad.map(a=>({value:a.name,label:a.name,description:a.description,sourceLabel:v(a),sourceRank:"builtin"===a.category?0:"plugin"===a.category?1:2,kind:"tool",category:a.category})),...(y?.tools??[]).map(a=>({value:a.name,label:a.name,description:a.description,sourceLabel:v(a),sourceRank:"builtin"===a.category?0:"plugin"===a.category?1:2,kind:"tool",category:a.category})),...Q.filter(a=>"fs.workspaceOnly"!==a&&!(y?.tools??[]).some(b=>b.name===a)).map(a=>({value:a,label:a,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:3,kind:"tool",category:"custom"})),...ab.filter(a=>"fs.workspaceOnly"!==a&&!(y?.tools??[]).some(b=>b.name===a)&&!Z.includes(a)).map(a=>({value:a,label:a,description:"Recovered from runtime transcripts.",sourceLabel:"Observed",sourceRank:4,kind:"tool",category:"custom"}))],"tool"),[y?.tools,Z,Q,ad,ab]),ag=(0,e.useMemo)(()=>u(ae,K,O,1/0),[O,K,ae]),ah=(0,e.useMemo)(()=>u(af,M,Q,1/0),[Q,M,af]);if(!n)return null;let ai=V?$:Y,aj=W?_:Z,ak=V?w(O):Y,al=W?w(Q):Z,am=!x(ak,ai)||!x(al,aj),an=async()=>{if(x(ak,ai)&&x(al,aj))return void i(!1);H(!0),J(null);try{let a={id:n.id};V?a.skills=ak:a.tools=al;let b=await fetch("/api/agents",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json();if(!b.ok)throw Error(c.error||"Unable to update agent capabilities.");k?.(a=>(function(a,b,c,d){let e=w(c),f=a.agents.map(a=>a.id===b?{...a,skills:e,tools:w([...d,...a.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[]])}:a),g=f.find(a=>a.id===b);if(!g)return a;let h=a.workspaces.map(a=>{if(a.id!==g.workspaceId)return a;let b=f.filter(b=>b.workspaceId===a.id);return{...a,capabilities:{...a.capabilities,skills:w(b.flatMap(a=>a.skills)),tools:w(b.flatMap(a=>a.tools)),workspaceOnlyAgentCount:b.filter(a=>a.tools.includes("fs.workspaceOnly")).length}}});return{...a,agents:f,workspaces:h}})(a,n.id,ak,al)),g.oR.success("Agent capabilities updated."),i(!1);let d=l?.();d&&d.catch(()=>void 0)}catch(b){let a=b instanceof Error?b.message:"Unable to update agent capabilities.";J(a),g.oR.error(a)}finally{H(!1)}};return(0,d.jsx)(q.lG,{open:a,onOpenChange:i,children:(0,d.jsx)(q.Cf,{className:"w-[min(680px,calc(100vw-1.5rem))] max-h-[calc(100dvh-1.5rem)] overflow-hidden rounded-[24px] border-white/10 bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(4,7,14,0.98))] p-0",children:(0,d.jsxs)("div",{className:"flex max-h-[calc(100dvh-1.5rem)] min-h-0 flex-col",children:[(0,d.jsxs)(q.c7,{className:"border-b border-white/[0.08] px-4 py-2.5",children:[(0,d.jsx)(q.L3,{className:"text-[0.95rem]",children:`Edit ${V?"skills":"tools"} \xb7 ${(0,s.CK)(n)}`}),(0,d.jsx)(q.rr,{className:"sr-only",children:"Edit the selected agent's skills or tools and save the updated capability set."}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1 pt-0.5",children:(0,d.jsx)(j.E,{variant:"muted",className:"h-5 border-white/[0.08] px-2 py-0 text-[10px] font-normal tracking-[0.06em] normal-case",children:(0,r._P)(n.policy.preset)})})]}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,d.jsx)("div",{className:"px-4 py-4",children:(0,d.jsx)(m,{title:V?"Skills":"Tools",selectedValues:V?O:Q,selectedTone:V?"cyan":"amber",selectedEmptyLabel:V?"No explicit skills":"No explicit tools configured",lockedValues:W?aa:[],observedValues:W?ab:[],inputRef:V?S:T,inputValue:V?K:M,onInputValueChange:V?L:N,onRemove:a=>{V?P(b=>b.filter(b=>b!==a)):R(b=>b.filter(b=>b!==a))},onPick:a=>{V?(P(b=>w([...b,a])),L("")):(R(b=>w([...b,a])),N(""))},suggestions:V?ag:ah,emptySuggestionLabel:E&&(V?ag.length:ah.length)===0?V?"Loading OpenClaw skill catalog...":"Loading OpenClaw tool catalog...":V?"No matching skills found.":"No matching tools found.",loading:E,catalogError:C,helperLabel:V?"Workspace skills and OpenClaw skills are shown first in Available to add.":"Built-ins, plugins, and groups are shown first in Available to add. Observed tools are read-only.",currentHintLabel:V?"Click \xd7 on a current skill to remove it.":"Click \xd7 on a current tool to remove it.",highlight:!0})}),I?(0,d.jsx)("div",{className:"border-t border-white/[0.08] px-4 py-3",children:(0,d.jsx)("p",{className:"text-[12px] leading-5 text-rose-300",children:I})}):null]}),(0,d.jsxs)(q.Es,{className:"border-t border-white/[0.08] px-4 py-2 sm:flex-row",children:[(0,d.jsx)(p.$,{type:"button",variant:"secondary",onClick:()=>i(!1),disabled:G,className:"h-8 rounded-full px-2.5 text-[10px]",children:"Cancel"}),(0,d.jsxs)(p.$,{type:"button",onClick:()=>{an()},disabled:G||!am,className:"h-8 rounded-full px-2.5 text-[10px]",children:[G?(0,d.jsx)(f.A,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):null,"Save changes"]})]})]})})})}},89478:(a,b,c)=>{"use strict";c.d(b,{jZ:()=>e,oZ:()=>h});var d=c(60557);class e extends Error{constructor(a,b){super(a),this.result=b,this.name="ModelProviderActionError"}}async function f(a){let b=await fetch("/api/models/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>null);if(!b.ok||!c)throw Error(c?.error||c?.message||"Model provider request failed.");if(!c.ok&&c.message)throw new e(c.message,c);return c}let g=Object.fromEntries(d.y8.map(a=>{var b;return[a.id,{id:b=a.id,descriptor:(0,d.W2)(b),getConnectionStatus:()=>f({action:"status",provider:b}),connect:a=>f({action:"connect",provider:b,apiKey:a?.apiKey?.trim()?a.apiKey.trim():void 0,endpoint:a?.endpoint?.trim()?a.endpoint.trim():void 0,force:a?.force===!0||void 0}),switchAccount:()=>f({action:"switch-account",provider:b}),discoverModels:()=>f({action:"discover",provider:b}),addModels:a=>f({action:"add-models",provider:b,modelIds:a})}]}));function h(a){return g[a]}},90639:(a,b,c)=>{Promise.resolve().then(c.bind(c,927)),Promise.resolve().then(c.t.bind(c,95258,23))},90665:(a,b,c)=>{"use strict";c.d(b,{$7:()=>n,$m:()=>p,CK:()=>j,FO:()=>g,JZ:()=>i,Uu:()=>l,_y:()=>h,fw:()=>e,hv:()=>f,m_:()=>m,sY:()=>k});var d=c(3844);function e(a,b=Date.now()){return null==a||Number.isNaN(a)?"No activity":`${(0,d.k)(a,b,{addSuffix:!0})}`}function f(a){if(!a)return Date.now();let b=Date.parse(a);return Number.isNaN(b)?Date.now():b}function g(a){return a?a>=1e3?`${Math.round(a/1e3)}k`:String(a):"n/a"}function h(a){return"number"!=typeof a?"n/a":a>=1e3?`${(a/1e3).toFixed(a>=1e4?0:1)}k`:String(a)}function i(a){return a.split("/").at(1)||a}function j(a){return a.name?.trim()||a.identityName?.trim()||"OpenClaw"}function k(a){switch(a){case"running":return"text-cyan-300";case"completed":return"text-emerald-300";case"cancelled":return"text-rose-300";case"stalled":case"queued":return"text-amber-200";default:return"text-slate-400"}}function l(a){switch(a){case"running":return"default";case"completed":return"success";case"cancelled":return"danger";case"stalled":return"warning";default:return"muted"}}function m(a,b=8){return a?a.length<=b?a:a.slice(0,b):"n/a"}function n(a){return a.replace(/^\/Users\/[^/]+/,"~")}let o=[/^Task output routing:/i,/^Agent operating policy:/i];function p(a,b=64){if(!a)return"";let c=function(a){let b=a.replace(/\r\n/g,"\n").trim();if(!b)return"";let c=[];for(let a of b.split("\n")){let b=a.trim();if(o.some(a=>a.test(b)))break;c.push(a)}return c.join(" ").replace(/\s+/g," ").trim()}(a);return c?c.length<=b?c:`${c.slice(0,Math.max(b-1,1)).trimEnd()}…`:""}},92078:(a,b,c)=>{"use strict";c.d(b,{$x:()=>i,A_:()=>g,Bw:()=>r,Cf:()=>k,DS:()=>j,UJ:()=>p,_P:()=>m,aB:()=>n,bQ:()=>q,bt:()=>f,g0:()=>l,sH:()=>h,zR:()=>o}),c(30540).j.map(a=>a.name);let d={worker:{label:"Worker",description:"Default execution agent for code changes, docs, research, and review work. Best when the task stays inside the workspace and does not need system-level changes.",defaultName:"Worker",defaultEmoji:"\uD83D\uDEE0️",defaultTheme:"slate",badgeVariant:"default",tools:["exec","read","write","edit","apply_patch"],skillIds:["project-builder","project-reviewer","project-tester"]},setup:{label:"Setup / Operator",description:"Bootstraps environments, handles installs, and unblocks the workspace so other agents can move faster.",defaultName:"Setup Operator",defaultEmoji:"\uD83E\uDDF0",defaultTheme:"amber",badgeVariant:"warning",tools:["exec","process","gateway","read","write"],skillIds:["project-builder","project-analyst","project-learner"]},browser:{label:"Browser",description:"Captures browser evidence, screenshots, and user-path validation for UI-heavy work.",defaultName:"Browser Agent",defaultEmoji:"\uD83C\uDF10",defaultTheme:"blue",badgeVariant:"success",tools:["browser","web_search","web_fetch","image"],skillIds:["project-browser","project-tester","project-researcher"]},monitoring:{label:"Monitoring",description:"Runs on a watch cycle, checks health and drift, and leaves concise triage handoffs.",defaultName:"Monitoring Agent",defaultEmoji:"\uD83D\uDEF0️",defaultTheme:"teal",badgeVariant:"warning",tools:["cron","gateway","sessions_list","message","web_fetch"],skillIds:["project-analyst","project-reviewer","project-learner"]},custom:{label:"Custom",description:"Starts from the safe baseline and lets you fine-tune identity, policy, and operating style by hand.",defaultName:"Custom Agent",defaultEmoji:"\uD83E\uDDE9",defaultTheme:"violet",badgeVariant:"muted",tools:["exec","read","edit","message"],skillIds:[]}},e={worker:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},setup:{missingToolBehavior:"allow-install",installScope:"workspace",fileAccess:"workspace-only",networkAccess:"enabled"},browser:{missingToolBehavior:"ask-setup",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},monitoring:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},custom:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"}},f=Object.entries(d).map(([a,b])=>({value:a,label:b.label,description:b.description})),g=[{value:"fallback",label:"Fallback",description:"Produce the nearest viable output format instead of failing the task."},{value:"ask-setup",label:"Ask for setup",description:"Stop before environment changes and report the missing capability clearly."},{value:"route-setup",label:"Route to setup agent",description:"Leave an explicit setup handoff instead of attempting installs directly."},{value:"allow-install",label:"Allow install",description:"Install missing tooling when policy allows it and the task truly depends on it."}],h=[{value:"none",label:"None",description:"Do not install workspace or system dependencies."},{value:"workspace",label:"Workspace only",description:"Only install dependencies inside the project or workspace environment."},{value:"system",label:"System",description:"Permit system-wide installs when they are necessary and intentional."}],i=[{value:"workspace-only",label:"Workspace only",description:"Keep file work grounded inside the attached workspace."},{value:"extended",label:"Extended",description:"Allow broader file access when the task explicitly needs it."}],j=[{value:"restricted",label:"Off",description:"Avoid network access unless the task explicitly depends on it."},{value:"enabled",label:"On",description:"Use network access when the task needs external information or downloads."}];function k(a){return d[a]}function l(a="worker",b){return{...e[a],...b??{},preset:a}}function m(a){return d[a].label}function n(a){return"fs.workspaceOnly"===a?"Workspace only":a.replace(/^agent-policy-/,"").replace(/^project-/,"").replace(/[._-]+/g," ").trim().replace(/\b\w/g,a=>a.toUpperCase())}function o(a){return g.find(b=>b.value===a)?.label??a}function p(a){return h.find(b=>b.value===a)?.label??a}function q(a){return i.find(b=>b.value===a)?.label??a}function r(a){return j.find(b=>b.value===a)?.label??a}},97078:(a,b,c)=>{"use strict";c.d(b,{O:()=>B});var d=c(3814),e=c(6247),f=c(68123),g=c(58664),h=c(78282),i=c(76179),j=c(11917),k=c(63685),l=c(45738),m=c(5813),n=c(34118),o=c(9494),p=c(92078),q=c(32905);function r({label:a,htmlFor:b,children:c,surfaceTheme:e="dark"}){return(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)(n.J,{htmlFor:b,className:(0,q.cn)("text-[10px] uppercase tracking-[0.16em]","light"===e?"text-[#8d7766]":"text-slate-400"),children:a}),c]})}function s({preset:a,active:b,onClick:c,surfaceTheme:e="dark"}){let f=(0,p.Cf)(a),h=(0,o.A6)(a),i="light"===e;return(0,d.jsx)("button",{type:"button",onClick:c,"aria-pressed":b,className:(0,q.cn)("flex h-full min-h-[200px] min-w-0 flex-col justify-between rounded-[24px] border p-4 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 snap-start",i?"border-[#e3d7cc] bg-white/92 shadow-[0_16px_34px_rgba(161,125,101,0.08)] focus-visible:ring-[#c89e73]/30 hover:border-[#d3c0b2] hover:bg-white":"border-white/10 bg-white/[0.03] shadow-[0_12px_28px_rgba(0,0,0,0.22)] focus-visible:ring-cyan-300/40 hover:border-white/20 hover:bg-white/[0.05]",b&&(i?"border-[#c89e73] bg-[#fff8f0] shadow-[0_18px_44px_rgba(161,125,101,0.14)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.08)]")),children:(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border text-[15px]",i?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-white"),children:f.defaultEmoji??(0,d.jsx)(g.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("line-clamp-2 break-words text-[14px] font-semibold leading-5",i?"text-[#2f2016]":"text-white"),children:f.label}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 line-clamp-3 text-[12px] leading-5",i?"text-[#6d5849]":"text-slate-400"),children:f.description})]})]}),(0,d.jsx)(m.E,{variant:b?"default":"muted",className:(0,q.cn)("shrink-0 px-2 py-0.5 text-[9px] normal-case tracking-normal",i?b?"border-[#c89e73]/35 bg-[#f4e6d8] text-[#5f432f]":"border-[#e1d5c8] bg-white text-[#846a58]":b?"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":"border-white/10 bg-white/5 text-slate-300"),children:b?"selected":"preset"})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsxs)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:[f.tools.length," tools"]}),(0,d.jsxs)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:[f.skillIds.length," skills"]}),(0,d.jsxs)(m.E,{variant:h.enabled?"success":"muted",className:(0,q.cn)("px-2 py-0.5 text-[10px] normal-case tracking-normal",i?h.enabled?"border-emerald-300/40 bg-emerald-100 text-emerald-800":"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:["Heartbeat ",h.enabled?h.every:"off"]})]})]})})}function t({label:a,htmlFor:b,value:c,options:e,onChange:f,surfaceTheme:g="dark"}){let h="light"===g,i=e.find(a=>a.value===c);return(0,d.jsxs)(r,{label:a,htmlFor:b,surfaceTheme:g,children:[(0,d.jsx)("select",{id:b,value:c,onChange:a=>f(a.target.value),style:h?{colorScheme:"light"}:void 0,className:(0,q.cn)("flex h-10 w-full rounded-2xl border px-3.5 py-2 text-[13px] outline-none transition-colors",h?"border-[#dccfc3] bg-white text-[#3f2f24] placeholder:text-[#9b8573] focus:border-[#c89e73] focus:ring-2 focus:ring-[#c89e73]/15":"border-white/10 bg-white/5 text-white placeholder:text-slate-500 focus:border-cyan-300/30 focus:ring-2 focus:ring-cyan-300/15"),children:e.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}),i?.description?(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[10px] leading-[1.4]",h?"text-[#9a8070]":"text-slate-500"),children:i.description}):null]})}var u=c(80990),v=c(37674),w=c(49444),x=c(43081),y=c(45084),z=c(90665),A=c(69903);function B({snapshot:a,defaultWorkspaceId:b,onRefresh:c,onSnapshotChange:k,onAgentCreationPending:n,onAgentCreated:L,onAgentCreatedVisible:M,trigger:N,surfaceTheme:O="dark"}){var P,Q,R,S,T;let U="light"===O,V=b??a.workspaces[0]?.id??"",[W,X]=(0,e.useState)(!1),[Y,Z]=(0,e.useState)(!1),[$,_]=(0,e.useState)(!1),[aa,ab]=(0,e.useState)("start"),[ac,ad]=(0,e.useState)(null),[ae,af]=(0,e.useState)("worker"),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(""),[ak,al]=(0,e.useState)(!1),[am,an]=(0,e.useState)("idle"),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(null),as=(0,e.useRef)(!1),at=(0,e.useRef)(null),[au,av]=(0,e.useState)(()=>C(V,a)),aw=(0,e.useRef)(null),ax=a.workspaces.find(a=>a.id===au.workspaceId)??null,ay=(0,A.nd)(a,au.workspaceId||V),az=au.modelId.trim()||ay,aA=au.modelId.trim()&&!(0,A.w6)(a,au.modelId.trim())?`Model ${au.modelId.trim()} is not ready. AgentOS will create the agent with a ready fallback when available and show a warning on the card.`:null,aB=(0,p.Cf)(au.policy.preset),aC=(0,A.qk)(a.agents,ax?.slug,au.name||aB.defaultName),aD=ag?a.agents.find(a=>a.id===ag)??null:null,aE=aD?a.workspaces.find(a=>a.id===aD.workspaceId)??null:null,aF=(0,e.useMemo)(()=>{let b=ai.trim().toLowerCase();return[...a.agents].filter(c=>{if(!b)return!0;let d=a.workspaces.find(a=>a.id===c.workspaceId)?.name??c.workspaceId,e=(0,p.Cf)(c.policy.preset).label;return[(0,z.CK)(c),c.id,c.workspaceId,d,e,c.modelId].join(" ").toLowerCase().includes(b)}).sort((a,b)=>{if(ag){if(a.id===ag)return -1;if(b.id===ag)return 1}return(0,z.CK)(a).localeCompare((0,z.CK)(b))})},[ai,ag,a.agents,a.workspaces]),aG=D(ac),aH=E(ac,aa),aI=!!(aC&&ax&&az)&&!ak,aJ="details"===aa?aI:(P=aa,Q=ac,R=ag,"start"===P?!!Q:"preset"===P||"import"!==P||!!R);ao&&a.agents.some(a=>a.id===ao);let aK="creating"===am?"Creating the agent and updating the workspace AGENTS.md role section.":"syncing"===am?"Agent created. Waiting for the canvas card to appear.":null,aL=(0,e.useCallback)(b=>{let c=C(b,a);ab("start"),ad(null),af("worker"),ah(null),aj(""),av(c),al(!1),an("idle"),ap(null),ar(null),aw.current&&(clearTimeout(aw.current),aw.current=null),as.current=!1},[a]),aM=a=>{(a||!ak&&"idle"===am)&&(_(a),a||aL(V))},aN=b=>{let c=au.workspaceId||V,d=C(c,a);d.modelId=au.modelId||(0,A.nd)(a,c),ad(b),af("worker"),ah(null),aj(""),av(d),"empty"===b?ab("details"):ab("start")},aO=async()=>{if(!as.current&&aC&&ax){as.current=!0,al(!0),an("creating"),ap(null),ar(null);try{let a=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...au,modelId:az,id:aC})}),b=await a.json();if(!a.ok||b.error||!b.agentId)throw Error(b.error||"OpenClaw could not create the agent.");au.channelIds.length>0&&await (0,y.rz)({workspaceId:au.workspaceId,workspacePath:ax.path,agentId:b.agentId,currentChannelIds:[],nextChannelIds:au.channelIds,onRegistryChange:k});let d=(0,p.Cf)(au.policy.preset);n?.({id:b.agentId,workspaceId:au.workspaceId,workspacePath:ax.path,name:au.name.trim()||b.agentId,modelId:az,emoji:au.emoji.trim()||d.defaultEmoji,theme:au.theme.trim()||d.defaultTheme,policy:au.policy,heartbeat:{enabled:au.heartbeat.enabled,every:au.heartbeat.every},skills:d.skillIds,tools:d.tools,createdAt:Date.now(),warning:b.warning??b.warnings?.[0]??null}),an("syncing"),ap(b.agentId),ar(b.warning??b.warnings?.[0]??null),c().catch(()=>{})}catch(a){aw.current&&(clearTimeout(aw.current),aw.current=null),an("idle"),ap(null),ar(null),al(!1),x.o.error("Agent creation failed.",{description:a instanceof Error?a.message:"Unknown agent error."})}finally{as.current=!1}}};return W?(0,d.jsxs)(v.lG,{open:$,onOpenChange:aM,children:[(0,d.jsx)(v.zM,{asChild:!0,children:N}),(0,d.jsx)(v.Cf,{overlayClassName:U?"bg-[#eadfd4]/72 backdrop-blur-[18px]":void 0,closeClassName:"hidden",className:(0,q.cn)("flex h-[min(84dvh,800px)] w-[calc(100vw-10px)] max-w-[920px] flex-col overflow-hidden p-0 sm:w-[min(920px,calc(100vw-20px))]",U?"border-[#dfd2c5] bg-[linear-gradient(180deg,rgba(255,252,248,0.99),rgba(247,239,231,0.99))] text-[#3f2f24] shadow-[0_36px_120px_rgba(161,125,101,0.18)]":"border-white/10 bg-[linear-gradient(180deg,rgba(12,18,29,0.98),rgba(7,11,18,0.98))] text-slate-50 shadow-[0_36px_120px_rgba(0,0,0,0.48)]"),style:U?{colorScheme:"light"}:void 0,children:(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:(0,q.cn)("shrink-0 border-b px-4 py-2.5 pr-10",U?"border-[#e5d8cb] bg-[linear-gradient(180deg,rgba(255,252,248,0.98),rgba(244,235,224,0.96))]":"border-white/10 bg-[linear-gradient(180deg,rgba(14,20,34,0.98),rgba(9,13,24,0.99))]"),children:[(0,d.jsx)(v.rr,{className:"sr-only",children:"Create a new OpenClaw agent by choosing a starter mode, editing profile and policy, and saving the workspace agent."}),"start"===aa?(0,d.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)(v.L3,{className:(0,q.cn)("text-[18px] font-medium sm:text-[20px]",U?"text-[#37291f]":"text-white"),children:"Create New Agent"}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[12px] leading-4",U?"text-[#9a8574]":"text-slate-500"),children:"Choose a starting point."})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("div",{className:(0,q.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1 text-[11px]",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7e6554]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium",U?"bg-[#eadccf] text-[#6f5646]":"bg-white/10 text-slate-200"),children:"1"}),(0,d.jsx)("span",{children:"Start"})]}),(0,d.jsx)(v.HM,{asChild:!0,children:(0,d.jsx)("button",{type:"button","aria-label":"Close dialog",className:(0,q.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7b6657] hover:bg-[#f2e8df] hover:text-[#3f2f24]":"border-white/10 bg-white/[0.04] text-slate-300 hover:bg-white/[0.08] hover:text-white"),children:(0,d.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:[(0,d.jsx)("path",{d:"M18 6 6 18"}),(0,d.jsx)("path",{d:"m6 6 12 12"})]})})})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,d.jsx)(v.L3,{className:(0,q.cn)("text-[15px] font-medium sm:text-[17px]",U?"text-[#37291f]":"text-white"),children:"Create New Agent"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(G,{labels:aG,activeIndex:aH,surfaceTheme:O,onStepClick:a=>{if(a>=E(ac,aa))return;let b=D(ac)[a];"Start"===b?ab("start"):"Preset"===b?ab("preset"):"Import"===b&&ab("import")}}),(0,d.jsx)(v.HM,{asChild:!0,children:(0,d.jsx)("button",{type:"button","aria-label":"Close dialog",className:(0,q.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors",U?"border-[#e2d3c2] bg-[#f5ece1] text-[#7b6657] hover:bg-[#f2e8df] hover:text-[#3f2f24]":"border-white/10 bg-white/[0.04] text-slate-300 hover:bg-white/[0.08] hover:text-white"),children:(0,d.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:[(0,d.jsx)("path",{d:"M18 6 6 18"}),(0,d.jsx)("path",{d:"m6 6 12 12"})]})})})]})]}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1.5 max-w-[520px] text-[10px] leading-4",U?"text-[#8c7664]":"text-slate-500"),children:(S=ac,"start"===(T=aa)?"empty"===S?"Empty / Custom is selected. Continue to details.":"preset"===S?"Preset Library is selected. Click Next to browse presets.":"import"===S?"Import Agent is selected. Click Next to choose a source agent.":"Choose a starting point.":"preset"===T?"Pick a preset. Details come next.":"import"===T?"Select an existing agent to clone.":"empty"===S?"Custom baseline loaded. Finish the details and create it.":"preset"===S?"Preset baseline loaded. Finish the details and create it.":"import"===S?"Imported baseline loaded. Review and create.":"")})]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3.5",children:"start"===aa?(0,d.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-[804px] flex-col items-center justify-center space-y-3 py-6",children:[(0,d.jsxs)("div",{className:"grid w-full gap-4 md:grid-cols-3 md:justify-items-center lg:gap-5",children:[(0,d.jsx)(I,{icon:f.A,title:"Empty / Custom",description:"Start from scratch.",helper:"Fastest if you know the shape.",selected:"empty"===ac,surfaceTheme:O,onSelect:()=>aN("empty")}),(0,d.jsx)(I,{icon:g.A,title:"Preset Library",description:"Use a role template.",helper:"Good for common worker roles.",selected:"preset"===ac,surfaceTheme:O,onSelect:()=>aN("preset")}),(0,d.jsx)(I,{icon:h.A,title:"Import Agent",description:"Clone an existing agent.",helper:"Best when a baseline already exists.",selected:"import"===ac,surfaceTheme:O,onSelect:()=>aN("import")})]}),(0,d.jsx)("p",{className:(0,q.cn)("max-w-[760px] text-center text-[10px] leading-4",U?"text-[#8c7664]":"text-slate-500"),children:"Empty is the fastest path. Preset and import prefill the draft so you only adjust what matters."})]}):"preset"===aa?(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsx)(H,{title:"Browse presets",description:"Choose the role that fits the first job.",surfaceTheme:O,className:"min-w-0",children:(0,d.jsx)("div",{className:"mt-3.5 grid gap-3 sm:grid-cols-2 xl:grid-cols-2",children:p.bt.map(a=>(0,d.jsx)(s,{preset:a.value,active:ae===a.value,surfaceTheme:O,onClick:()=>{var b;af(b=a.value),av(a=>(0,A.nK)(a,b))}},a.value))})}),(0,d.jsx)(H,{title:"Selected preset",description:"This seeds the draft before details.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:(0,p.Cf)(ae).defaultEmoji}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:(0,p.Cf)(ae).label}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:(0,p.Cf)(ae).description})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsxs)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:[(0,p.Cf)(ae).tools.length," tools"]}),(0,d.jsxs)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:[(0,p.Cf)(ae).skillIds.length," skills"]}),(0,d.jsxs)(m.E,{variant:(0,o.A6)(ae).enabled?"success":"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:["Heartbeat ",(0,o.A6)(ae).enabled?(0,o.A6)(ae).every:"off"]})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:"The preset seeds the draft. You can fine-tune the name, model, policy, and heartbeat next."})]})})]}):"import"===aa?(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsx)(H,{title:"Import an existing agent",description:"Select an agent to clone.",surfaceTheme:O,className:"min-w-0",children:(0,d.jsxs)("div",{className:"mt-3.5 space-y-3",children:[(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(w.p,{value:ai,onChange:a=>aj(a.target.value),placeholder:"Search by name, id, workspace, preset, or model",className:F(O)})}),(0,d.jsx)("div",{className:"space-y-2.5",children:aF.length>0?aF.map(b=>(0,d.jsx)(J,{agent:b,workspaceName:a.workspaces.find(a=>a.id===b.workspaceId)?.name??b.workspaceId,selected:ag===b.id,surfaceTheme:O,onSelect:()=>(b=>{var c,d,e;let f=a.agents.find(a=>a.id===b);if(!f)return;let g=au.workspaceId||V,h=g===f.workspaceId?(0,y.XS)(a,f.workspaceId,f.id):[];ah(b),av((c=g,d=f,e=h,(0,A.TY)(c,{modelId:"unassigned"===d.modelId?"":d.modelId,name:(0,z.CK)(d),emoji:d.identity.emoji??"",theme:d.identity.theme??"",avatar:d.identity.avatar??"",policy:d.policy,heartbeat:(0,o.iq)(d.policy.preset,{enabled:d.heartbeat.enabled,every:d.heartbeat.every??void 0}),channelIds:e})))})(b.id)},b.id)):(0,d.jsx)("div",{className:(0,q.cn)("rounded-[20px] border border-dashed p-4 text-sm leading-6",U?"border-[#e1d5c8] bg-white text-[#7f6958]":"border-white/10 bg-white/[0.02] text-slate-400"),children:"No agents match this search. Clear the search or go back to choose another start."})})]})}),(0,d.jsx)(H,{title:"Import summary",description:"The selected agent seeds the draft.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:aD?(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:aD.identity.emoji??"\uD83E\uDD16"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:(0,z.CK)(aD)}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:aD.id})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:aE?.name??aD.workspaceId}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:(0,p.Cf)(aD.policy.preset).label}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:"unassigned"===aD.modelId?"default model":aD.modelId})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:"The cloned draft keeps the source baseline. You can adjust workspace-specific details next."})]}):(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border border-dashed p-4 text-sm leading-6",U?"border-[#e1d5c8] bg-white text-[#7f6958]":"border-white/10 bg-white/[0.02] text-slate-400"),children:"Choose an existing agent on the left. Its configuration will be cloned into the new draft."}),(0,d.jsx)(K,{surfaceTheme:O})]})})]}):(0,d.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsx)(H,{title:"Core details",description:"Name, workspace, and model.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(r,{label:"Display name",htmlFor:"create-agent-name",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-name",ref:at,value:au.name,onChange:a=>av(b=>({...b,name:a.target.value})),placeholder:aB.defaultName,className:F(O)})}),(0,d.jsx)(r,{label:"Workspace",htmlFor:"create-agent-workspace",surfaceTheme:O,children:(0,d.jsx)("select",{id:"create-agent-workspace",value:au.workspaceId,onChange:b=>av(c=>({...c,workspaceId:b.target.value,modelId:c.modelId.trim()?c.modelId:(0,A.nd)(a,b.target.value),channelIds:[]})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:a.workspaces.map(a=>(0,d.jsx)("option",{value:a.id,children:a.name},a.id))})}),(0,d.jsxs)(r,{label:"Model",htmlFor:"create-agent-model",surfaceTheme:O,children:[(0,d.jsxs)("select",{id:"create-agent-model",value:au.modelId,onChange:a=>av(b=>({...b,modelId:a.target.value})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:[(0,d.jsx)("option",{value:"",children:a.diagnostics.modelReadiness.defaultModelReady?"Use OpenClaw default":ay?`Use suggested model (${ay})`:"Choose a model"}),a.models.map(b=>{let c=(0,A.w6)(a,b.id);return(0,d.jsxs)("option",{value:b.id,children:[b.id,c?"":" (not ready)"]},b.id)})]}),aA?(0,d.jsx)("p",{className:(0,q.cn)("mt-2 text-[11px] leading-4",U?"text-[#9b5f34]":"text-amber-200/85"),children:aA}):null]}),(0,d.jsx)("p",{className:(0,q.cn)("text-[10px] leading-4",U?"text-[#9a8070]":"text-slate-500"),children:"OpenClaw generates the agent id automatically. Review it in the Summary panel."})]})}),(0,d.jsx)(H,{title:"Visual identity",description:"Emoji and display customization.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsx)(r,{label:"Emoji",htmlFor:"create-agent-emoji",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 select-none text-base leading-none",children:au.emoji||aB.defaultEmoji}),(0,d.jsx)(w.p,{id:"create-agent-emoji",value:au.emoji,onChange:a=>av(b=>({...b,emoji:a.target.value})),placeholder:aB.defaultEmoji,className:(0,q.cn)(F(O),"pl-9")})]})}),(0,d.jsxs)("button",{type:"button",onClick:()=>Z(a=>!a),className:(0,q.cn)("inline-flex items-center gap-1.5 text-[10px] uppercase tracking-[0.16em] transition-colors",U?"text-[#8b7462] hover:text-[#5d4331]":"text-slate-500 hover:text-slate-300"),children:[(0,d.jsx)(i.A,{className:(0,q.cn)("h-3 w-3 transition-transform duration-200",Y&&"rotate-90")}),Y?"Hide":"Show","theme & avatar"]}),Y?(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(r,{label:"Theme",htmlFor:"create-agent-theme",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-theme",value:au.theme,onChange:a=>av(b=>({...b,theme:a.target.value})),placeholder:aB.defaultTheme,className:F(O)})}),(0,d.jsx)(r,{label:"Avatar URL",htmlFor:"create-agent-avatar",surfaceTheme:O,children:(0,d.jsx)(w.p,{id:"create-agent-avatar",value:au.avatar,onChange:a=>av(b=>({...b,avatar:a.target.value})),placeholder:"https://example.com/avatar.png",className:F(O)})})]}):null]})}),(0,d.jsx)(l.X,{snapshot:a,workspaceId:au.workspaceId,channelIds:au.channelIds,isSaving:ak,surfaceTheme:O,onChange:a=>av(b=>({...b,channelIds:a}))}),(0,d.jsx)(H,{title:"Heartbeat and policy",description:"Only override what you need.",surfaceTheme:O,children:(0,d.jsxs)("div",{className:"space-y-3.5",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:(0,q.cn)("text-sm font-medium",U?"text-[#3f2f24]":"text-white"),children:"Heartbeat"}),(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-xs leading-5",U?"text-[#7f6958]":"text-slate-400"),children:"Enable only for periodic watch or triage agents."})]}),(0,d.jsx)("button",{type:"button",role:"switch","aria-checked":au.heartbeat.enabled,"aria-label":"Toggle heartbeat",onClick:()=>av(a=>({...a,heartbeat:a.heartbeat.enabled?{...a.heartbeat,enabled:!1}:{...a.heartbeat,enabled:!0,every:a.heartbeat.every||(0,o.A6)(a.policy.preset).every}})),className:(0,q.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2",U?au.heartbeat.enabled?"bg-[#c89e73] focus-visible:ring-[#c89e73]/40":"bg-[#ddd0c6] focus-visible:ring-[#c89e73]/40":au.heartbeat.enabled?"bg-cyan-400 focus-visible:ring-cyan-300/40":"bg-white/20 focus-visible:ring-cyan-300/40"),children:(0,d.jsx)("span",{className:(0,q.cn)("pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow-md ring-0 transition-transform duration-200",au.heartbeat.enabled?"translate-x-5":"translate-x-0")})})]}),au.heartbeat.enabled?(0,d.jsx)(r,{label:"Interval",htmlFor:"create-agent-heartbeat-every",surfaceTheme:O,children:(0,d.jsx)("select",{id:"create-agent-heartbeat-every",value:au.heartbeat.every,onChange:a=>av(b=>({...b,heartbeat:{...b.heartbeat,every:a.target.value}})),style:U?{colorScheme:"light"}:void 0,className:F(O),children:o.MQ.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))})}):null,(0,d.jsxs)("div",{className:"grid gap-3.5 sm:grid-cols-2",children:[(0,d.jsx)(t,{label:"Missing tool behavior",htmlFor:"create-agent-missing-tools",value:au.policy.missingToolBehavior,options:p.A_,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,missingToolBehavior:a}}))}),(0,d.jsx)(t,{label:"Install scope",htmlFor:"create-agent-install-scope",value:au.policy.installScope,options:p.sH,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,installScope:a}}))}),(0,d.jsx)(t,{label:"File access",htmlFor:"create-agent-file-access",value:au.policy.fileAccess,options:p.$x,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,fileAccess:a}}))}),(0,d.jsx)(t,{label:"Network access",htmlFor:"create-agent-network-access",value:au.policy.networkAccess,options:p.DS,surfaceTheme:O,onChange:a=>av(b=>({...b,policy:{...b.policy,networkAccess:a}}))})]})]})})]}),(0,d.jsx)("div",{className:"space-y-4",children:(0,d.jsx)(H,{title:"Summary",description:"Review the draft before creating.",surfaceTheme:O,className:"xl:sticky xl:top-4 xl:self-start xl:h-fit",children:(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-2xl border text-[14px]",U?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5 text-base"),children:au.emoji||aB.defaultEmoji}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",U?"text-[#3f2f24]":"text-white"),children:au.name||aB.defaultName}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 text-[11px] leading-4",U?"text-[#7f6958]":"text-slate-400"),children:ax?.name??"No workspace selected"})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:"empty"===ac?"Empty / Custom":"preset"===ac?`${(0,p.Cf)(ae).label} preset`:"import"===ac?"Imported agent":"Start a flow"}),(0,d.jsx)(m.E,{variant:"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:au.modelId||ay||"OpenClaw default"}),(0,d.jsxs)(m.E,{variant:au.heartbeat.enabled?"success":"muted",className:"px-2 py-0.5 text-[9px] normal-case tracking-normal",children:["Heartbeat ",au.heartbeat.enabled?au.heartbeat.every:"off"]})]}),(0,d.jsx)(K,{surfaceTheme:O}),(0,d.jsxs)("div",{className:(0,q.cn)("rounded-[18px] border p-2.5 text-[11px] leading-5",U?"border-[#e2d5c9] bg-[#faf6f1] text-[#7b6657]":"border-white/10 bg-white/[0.03] text-slate-400"),children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[10px] uppercase tracking-[0.18em]",U?"text-[#8b7462]":"text-slate-500"),children:"Generated id"}),(0,d.jsx)("code",{className:(0,q.cn)("mt-1.5 block break-all rounded-2xl border px-3 py-1.5 text-[11px]",U?"border-[#dccfc3] bg-white text-[#4d392e]":"border-white/10 bg-white/5 text-slate-200"),children:aC||"unavailable"})]})]})})})]})}),(0,d.jsx)(v.Es,{className:(0,q.cn)("shrink-0 border-t px-6 py-4",U?"border-[#e5d8cb] bg-[#faf6f1]":"border-white/10 bg-transparent"),children:(0,d.jsxs)("div",{className:"flex w-full flex-col gap-3",children:[aK?(0,d.jsxs)("div",{className:(0,q.cn)("inline-flex items-start gap-2 rounded-2xl border px-3 py-2 text-[11px] leading-4",U?"border-[#ddcfbf] bg-white text-[#6e5646]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,d.jsx)(j.A,{className:"mt-0.5 h-3.5 w-3.5 animate-spin shrink-0"}),(0,d.jsx)("span",{children:aK})]}):null,(0,d.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>aM(!1),disabled:ak,className:U?"border-[#d8c7b8] bg-white text-[#4d392f] hover:bg-[#f5efe9]":void 0,children:"Cancel"}),(0,d.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center",children:["start"!==aa?(0,d.jsx)(u.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{"details"===aa?ab("empty"===ac?"start":ac??"start"):("preset"===aa||"import"===aa)&&ab("start")},disabled:ak,className:U?"border-[#d8c7b8] bg-white text-[#4d392f] hover:bg-[#f5efe9]":void 0,children:"Back"}):null,(0,d.jsx)(u.$,{type:"button",size:"sm",onClick:()=>{"details"===aa?aO():(()=>{if("start"===aa){if(!ac)return;if("empty"===ac)return ab("details");if("preset"===ac){av(a=>(0,A.nK)(a,ae)),ab("preset");return}return ab(ac)}if("preset"===aa)return ab("details");if("import"===aa){if(!ag)return;ab("details")}})()},disabled:!aJ,className:U?"bg-[#c89e73] text-white shadow-[0_10px_26px_rgba(161,125,101,0.22)] hover:bg-[#b47f53]":void 0,children:"details"===aa?ak?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"syncing"===am?"Syncing canvas...":"Creating..."]}):"Create agent":"start"===aa&&"empty"===ac?"Continue":"Next"})]})]})]})})]})})]}):(0,d.jsx)(d.Fragment,{children:N})}function C(a,b){return(0,A.nK)((0,A.TY)(a,{modelId:(0,A.nd)(b,a)}),"custom")}function D(a){return a?"empty"===a?["Start","Details"]:"preset"===a?["Start","Preset","Details"]:["Start","Import","Details"]:["Start"]}function E(a,b){return a&&"start"!==b?"details"===b?"empty"===a?1:2:1:0}function F(a){return(0,q.cn)("flex h-10 w-full rounded-2xl border px-3.5 py-2 text-[13px] outline-none transition-colors","light"===a?"border-[#dccfc3] bg-white text-[#3f2f24] placeholder:text-[#9b8573] focus:border-[#c89e73] focus:ring-2 focus:ring-[#c89e73]/15":"border-white/10 bg-white/5 text-white placeholder:text-slate-500 focus:border-cyan-300/30 focus:ring-2 focus:ring-cyan-300/15")}function G({labels:a,activeIndex:b,surfaceTheme:c="dark",onStepClick:e}){let f="light"===c;return(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:a.map((a,c)=>{let g=c===b,h=c<b,i=h&&!!e,j=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[9px] font-medium",g?f?"bg-[#c89e73]/15 text-[#5d4331]":"bg-cyan-300/20 text-cyan-50":h?f?"bg-[#f0e7de] text-[#7a6556]":"bg-emerald-300/20 text-emerald-50":f?"bg-[#f2ece6] text-[#917866]":"bg-white/10 text-slate-400"),children:c+1}),(0,d.jsx)("span",{children:a})]}),k=(0,q.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[10px] transition-colors",g?f?"border-[#c89e73]/35 bg-[#f8efe4] text-[#5d4331]":"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":h?f?"border-[#dccfc3] bg-white text-[#7e6757]":"border-emerald-300/20 bg-emerald-400/10 text-emerald-50":f?"border-[#e6dbd0] bg-white/80 text-[#8b7563]":"border-white/10 bg-white/[0.04] text-slate-400",i&&(f?"cursor-pointer hover:border-[#c89e73]/50 hover:bg-[#faf3ea]":"cursor-pointer hover:border-emerald-300/30 hover:bg-emerald-400/15"));return i?(0,d.jsx)("button",{type:"button",onClick:()=>e?.(c),className:k,children:j},`${a}-${c}`):(0,d.jsx)("div",{className:k,children:j},`${a}-${c}`)})})}function H({title:a,description:b,children:c,className:e,surfaceTheme:f="dark"}){let g="light"===f;return(0,d.jsxs)("section",{className:(0,q.cn)("rounded-[22px] border p-3.5",g?"border-[#e2d5c9] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)]":"border-white/10 bg-white/[0.03] shadow-[0_14px_34px_rgba(0,0,0,0.18)]",e),children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[13px] font-medium",g?"text-[#3f2f24]":"text-white"),children:a}),b?(0,d.jsx)("p",{className:(0,q.cn)("mt-1 text-[11px] leading-4",g?"text-[#7f6958]":"text-slate-400"),children:b}):null]})}),(0,d.jsx)("div",{className:"mt-3 min-w-0",children:c})]})}function I({icon:a,title:b,description:c,helper:e,selected:f,surfaceTheme:g="dark",onSelect:h}){let j="light"===g;return(0,d.jsxs)("button",{type:"button",onClick:h,"aria-pressed":f,className:(0,q.cn)("flex w-full min-h-[272px] flex-col rounded-[28px] border p-3.5 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 md:max-w-[248px]",j?"focus-visible:ring-[#c89e73]/30":"focus-visible:ring-cyan-300/40",f?j?"border-[#d7c1ae] bg-[#fdf7ef] shadow-[0_14px_28px_rgba(161,125,101,0.08)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.1)]":j?"border-[#e7dbcf] bg-[rgba(255,252,247,0.9)] shadow-[0_10px_24px_rgba(161,125,101,0.05)] hover:border-[#d9c7b8] hover:bg-[#fffdf9]":"border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsx)("div",{className:(0,q.cn)("inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-[18px] border",j?"border-[#e0d3c6] bg-[#faf6f0] text-[#7a5f4c]":"border-white/10 bg-white/5 text-white"),children:(0,d.jsx)(a,{className:"h-[17px] w-[17px]"})}),(0,d.jsx)(m.E,{variant:f?"default":"muted",className:(0,q.cn)("shrink-0 rounded-full px-2.5 py-0.5 text-[9px] normal-case tracking-normal",j?f?"border-[#d7c1ae] bg-[#f3e5d8] text-[#6a4b38]":"border-[#e3d6c8] bg-[rgba(255,255,255,0.82)] text-[#8a6f5d]":""),children:f?"Selected":"Available"})]}),(0,d.jsxs)("div",{className:"mt-6 space-y-1.5",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[15px] font-medium leading-5",j?"text-[#413126]":"text-white"),children:b}),(0,d.jsx)("p",{className:(0,q.cn)("text-[12px] leading-5",j?"text-[#8a7463]":"text-slate-400"),children:c})]}),(0,d.jsx)("div",{className:"mt-auto pt-6",children:(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("max-w-[116px] text-[9px] uppercase leading-[1.35] tracking-[0.2em]",j?"text-[#9a8572]":"text-slate-500"),children:e}),(0,d.jsxs)("span",{className:(0,q.cn)("inline-flex items-center gap-1 text-[9px] uppercase tracking-[0.18em]",j?"text-[#7f6958]":"text-slate-400"),children:["Select",(0,d.jsx)(i.A,{className:"h-3 w-3"})]})]})})]})}function J({agent:a,workspaceName:b,selected:c,surfaceTheme:e="dark",onSelect:f}){let g=(0,p.Cf)(a.policy.preset),h="unassigned"===a.modelId?"default model":a.modelId,j="light"===e;return(0,d.jsxs)("button",{type:"button",onClick:f,"aria-pressed":c,className:(0,q.cn)("flex w-full flex-col rounded-[22px] border p-3.5 text-left transition-all duration-200 focus-visible:outline-none focus-visible:ring-2",j?"focus-visible:ring-[#c89e73]/30":"focus-visible:ring-cyan-300/40",c?j?"border-[#c89e73]/45 bg-[#fff8f0] shadow-[0_16px_40px_rgba(161,125,101,0.12)]":"border-cyan-300/30 bg-cyan-400/10 shadow-[0_0_0_1px_rgba(34,211,238,0.1)]":j?"border-[#e3d7cc] bg-white/92 shadow-[0_14px_34px_rgba(161,125,101,0.08)] hover:border-[#d4c2b4] hover:bg-white":"border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.05]"),children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-2xl border text-[15px]",j?"border-[#ded0c2] bg-[#faf5ef] text-[#7b604c]":"border-white/10 bg-white/5"),children:a.identity.emoji??"\uD83E\uDD16"}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("truncate text-[13px] font-medium",j?"text-[#3f2f24]":"text-white"),children:(0,z.CK)(a)}),(0,d.jsx)("p",{className:(0,q.cn)("mt-0.5 truncate text-[11px] leading-4",j?"text-[#7f6958]":"text-slate-500"),children:a.id})]})]}),(0,d.jsx)(m.E,{variant:c?"default":"muted",className:(0,q.cn)("shrink-0 px-2 py-0.5 text-[9px] normal-case tracking-normal",j?c?"border-[#c89e73]/35 bg-[#f5e7d8] text-[#6a4a34]":"border-[#e1d5c8] bg-white text-[#846a58]":""),children:c?"Selected":g.label})]}),(0,d.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,d.jsx)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:b}),(0,d.jsx)(m.E,{variant:"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:h}),(0,d.jsx)(m.E,{variant:"ready"===a.status?"success":"muted",className:(0,q.cn)("px-2 py-0.5 text-[9px] normal-case tracking-normal",j?"ready"===a.status?"border-emerald-300/40 bg-emerald-100 text-emerald-800":"border-[#e1d5c8] bg-[#fbf7f2] text-[#6f5747]":""),children:a.status})]}),(0,d.jsx)("p",{className:(0,q.cn)("mt-3 text-[12px] leading-5",j?"text-[#7f6958]":"text-slate-400"),children:g.description}),(0,d.jsxs)("div",{className:"mt-3.5 flex items-center justify-between gap-3",children:[(0,d.jsx)("span",{className:(0,q.cn)("text-[10px] uppercase tracking-[0.16em]",j?"text-[#8b7462]":"text-slate-500"),children:"Import this agent as a new draft"}),(0,d.jsxs)("span",{className:(0,q.cn)("inline-flex items-center gap-1 text-[10px] uppercase tracking-[0.16em]",j?"text-[#7f6958]":"text-slate-400"),children:["Select",(0,d.jsx)(i.A,{className:"h-3 w-3"})]})]})]})}function K({surfaceTheme:a}){let b="light"===a;return(0,d.jsx)("div",{className:(0,q.cn)("rounded-[18px] border p-3 text-[11px] leading-5",b?"border-[#e2d5c9] bg-[#faf6f1] text-[#6f5849]":"border-white/10 bg-white/[0.03] text-slate-400"),children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)(k.A,{className:(0,q.cn)("mt-0.5 h-3.5 w-3.5 shrink-0",b?"text-[#8b6d56]":"text-cyan-200")}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:(0,q.cn)("text-[12px] font-medium",b?"text-[#3f2f24]":"text-slate-100"),children:"Workspace-root context"}),(0,d.jsxs)("p",{className:"mt-1",children:["This agent profile is written to the workspace root ",(0,d.jsx)("code",{children:"AGENTS.md"}),". OpenClaw loads that file as shared runtime context."]})]})]})})}},98895:(a,b,c)=>{"use strict";function d(a){let b="clone"===a.sourceMode?{label:"Cloning repository",description:"The repository is being cloned before workspace files are added."}:"existing"===a.sourceMode?{label:"Attaching existing folder",description:"AgentOS is validating the existing directory and preparing it for bootstrap."}:{label:"Preparing workspace folder",description:"A fresh workspace directory is being created inside the configured workspace root."};return{title:"Provisioning workspace",description:"AgentOS is creating the workspace and reporting each real bootstrap step as it finishes.",steps:[{id:"validate",label:"Checking input and target path",description:"Workspace input, agent ids, and the destination directory are being validated."},{id:"source",label:b.label,description:b.description},{id:"scaffold",label:"Scaffolding workspace files",description:"Core docs, local state, starter memory, and shared workspace metadata are being written."},{id:"agents",label:1===a.agentCount?"Creating the first agent":"Creating workspace agents",description:1===a.agentCount?"The primary agent is being provisioned and linked to the workspace.":"Each enabled agent is being provisioned and linked to the workspace."},{id:"kickoff",label:a.kickoffMission?"Running kickoff mission":"Finalizing workspace",description:a.kickoffMission?"The primary agent is inspecting the new workspace and refining the initial setup.":"Workspace bootstrap is wrapping up without a kickoff mission."}]}}function e(a){return{title:"Deploying workspace",description:"The planner is turning the blueprint into a live workspace and streaming each deploy stage.",steps:[{id:"plan",label:"Locking deploy plan",description:"Deploy blockers are being checked and the planner state is being locked for launch."},...d({sourceMode:a.sourceMode,agentCount:a.agentCount,kickoffMission:a.kickoffMission}).steps,{id:"blueprint",label:"Writing planner files",description:"Planner blueprint, company notes, and workflow docs are being written into the workspace."},{id:"channels",label:a.hasChannels?"Provisioning channels":"Checking channels",description:a.hasChannels?"Enabled external channels are being provisioned and connected.":"No external channels are enabled, so this stage will pass quickly."},{id:"automations",label:a.hasAutomations?"Provisioning automations":"Checking automation loops",description:a.hasAutomations?"Enabled recurring loops are being attached to their target agents.":"No recurring automations are enabled, so this stage is mostly validation."},{id:"planner-kickoff",label:a.hasPlannerKickoffs?"Running planner kickoff missions":"Finalizing deploy",description:a.hasPlannerKickoffs?"The first missions are being dispatched so the new workspace starts with clear momentum.":"The workspace is being finalized and the deploy request is wrapping up."}]}}function f(a){return{title:a.title,description:a.description,percent:0,steps:a.steps.map(a=>({...a,status:"pending",percent:0,activities:[]}))}}c.d(b,{Bb:()=>e,fV:()=>d,sg:()=>f})}};
|