@lovelybunch/api 1.0.75-alpha.0 → 1.0.75-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/api/v1/events/status/route.d.ts +1 -1
- package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
- package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
- package/package.json +4 -4
- package/static/assets/{ActivityPage-Dl3u61DF.js → ActivityPage-BYrDJlH6.js} +1 -1
- package/static/assets/{AgentDetailPage-BJD22FSv.js → AgentDetailPage-D6yg4CtT.js} +1 -1
- package/static/assets/{AgentEditPage-ZYd0Rode.js → AgentEditPage-CTnjxjX7.js} +1 -1
- package/static/assets/{AgentsPage-CUuxxQ2o.js → AgentsPage-NdB5OB1C.js} +1 -1
- package/static/assets/{AgentsSettingsPage-Dd8MrsKx.js → AgentsSettingsPage-CYXp908g.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-DTZStkII.js → ApiKeysSettingsPage-Jl6vvVmW.js} +1 -1
- package/static/assets/{ArchitectureEditPage-CVxBD88N.js → ArchitectureEditPage-Bw2d_hmk.js} +1 -1
- package/static/assets/{ArchitecturePage-GchbFR8L.js → ArchitecturePage-36wO0UD7.js} +1 -1
- package/static/assets/{AuthSettingsPage-B7a-i1_T.js → AuthSettingsPage-CKifiWsx.js} +1 -1
- package/static/assets/{CallbackPage-xYgfYT1Z.js → CallbackPage-Ck0dddEW.js} +1 -1
- package/static/assets/{CodePage-xpXX0hlR.js → CodePage-b3JR4eWW.js} +1 -1
- package/static/assets/{CollapsibleSection-ka7CEJhS.js → CollapsibleSection-BKY-lfsm.js} +1 -1
- package/static/assets/{DashboardPage-DQFlhP54.js → DashboardPage-Cv2-duAx.js} +1 -1
- package/static/assets/{GitPage-B-aSKe9Z.js → GitPage-BgCxzm-C.js} +1 -1
- package/static/assets/{GitSettingsPage-vLNJs4r3.js → GitSettingsPage-CKIWkAnw.js} +1 -1
- package/static/assets/{IdentityPage-ZAp_iARt.js → IdentityPage-BsZnszF-.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-BC8bzHNj.js → ImplementationStepsEditor-iqrCqyOb.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-CqWZ8GUI.js → IntegrationsSettingsPage-C1dC_vVy.js} +1 -1
- package/static/assets/{JobDetailPage-BWq4XLO2.js → JobDetailPage-BgGQJkND.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-C8evStGp.js → KnowledgeDetailPage-Dzy2V7yT.js} +1 -1
- package/static/assets/{KnowledgeEditPage-DquJprU_.js → KnowledgeEditPage-av1ALt0h.js} +1 -1
- package/static/assets/{KnowledgePage-BBUKBhzS.js → KnowledgePage-C_UDfD9X.js} +1 -1
- package/static/assets/{LoginPage-Dp6lQSZW.js → LoginPage-DqbNxfY6.js} +1 -1
- package/static/assets/{McpSettingsPage-BGIEripM.js → McpSettingsPage-BqbErEWS.js} +1 -1
- package/static/assets/{NewAgentPage-D9hL7NY6.js → NewAgentPage-UEVIYkt3.js} +1 -1
- package/static/assets/{NewKnowledgePage-CEdd8Yns.js → NewKnowledgePage-CzYXdoDb.js} +1 -1
- package/static/assets/{NewProposalPage-B152OXnT.js → NewProposalPage-DrU0ihJX.js} +1 -1
- package/static/assets/{ProjectEditPage-D0uSaGy0.js → ProjectEditPage-j4KporiC.js} +1 -1
- package/static/assets/{ProjectPage-DzWJky4Y.js → ProjectPage-BQNa0qA-.js} +1 -1
- package/static/assets/{PromptsSettingsPage-DH-4vcbF.js → PromptsSettingsPage-sYphs8Dn.js} +1 -1
- package/static/assets/ProposalDetailPage-CHR1MmwC.js +1 -0
- package/static/assets/{ProposalEditPage-D4412azZ.js → ProposalEditPage-CkcZqgax.js} +1 -1
- package/static/assets/{ProposalsPage-D2gMbCBV.js → ProposalsPage-CUB_aLXW.js} +2 -2
- package/static/assets/{ResourcesPage-7tbvXxDb.js → ResourcesPage-DzjwPoyS.js} +1 -1
- package/static/assets/{RoleEditPage-Ne8Dh8Tt.js → RoleEditPage-DhVneoNR.js} +1 -1
- package/static/assets/{RolePage-3sb7lhw8.js → RolePage-BOI2T8QG.js} +1 -1
- package/static/assets/{RulesSettingsPage-CEWEvNFC.js → RulesSettingsPage-VsteFA-j.js} +1 -1
- package/static/assets/{SchedulePage-Crd-VMiL.js → SchedulePage-_v4YfdHo.js} +1 -1
- package/static/assets/{SourceInput-fvbAHpzT.js → SourceInput-BFxoOvqS.js} +1 -1
- package/static/assets/{TagInput-DRSgjTau.js → TagInput-BWLBdW8h.js} +1 -1
- package/static/assets/{TerminalPage-BGZJDqvR.js → TerminalPage-DtVDWX7G.js} +1 -1
- package/static/assets/{TerminalSessionPage-DILvcnLG.js → TerminalSessionPage-BUHzje8A.js} +1 -1
- package/static/assets/{UserPreferencesPage-ChHrBs8H.js → UserPreferencesPage-CkXJuogz.js} +1 -1
- package/static/assets/{UserSettingsPage-Cv60YInV.js → UserSettingsPage-Dz-R1ijS.js} +1 -1
- package/static/assets/{UtilitiesPage-ChLTn_u9.js → UtilitiesPage-CRqQYVsb.js} +1 -1
- package/static/assets/{alert-CBWqAyb9.js → alert-C7sSXJf0.js} +1 -1
- package/static/assets/{arrow-down-PY3QZW33.js → arrow-down-DNa4SyO2.js} +1 -1
- package/static/assets/{arrow-left-JpEq5x30.js → arrow-left-DkoECaEJ.js} +1 -1
- package/static/assets/{arrow-up-qJ-_eNlY.js → arrow-up-DQlu6uQE.js} +1 -1
- package/static/assets/{badge-D6QJCkgl.js → badge-2ZOe5ynf.js} +1 -1
- package/static/assets/{browser-modal-DT5zGtM2.js → browser-modal-DUCXGaha.js} +1 -1
- package/static/assets/{calendar-sFw_mHQb.js → calendar-tNgwmWmG.js} +1 -1
- package/static/assets/{card-CjY6k9qN.js → card-By4vbQ_f.js} +1 -1
- package/static/assets/{chevron-left-DiMUBSvf.js → chevron-left-CJfNRqcH.js} +1 -1
- package/static/assets/{chevrons-up-CKVPmJ25.js → chevrons-up-DoBrp0tt.js} +1 -1
- package/static/assets/{circle-alert-Bc4Eo-aL.js → circle-alert-B4JJ0jKl.js} +1 -1
- package/static/assets/{circle-check-C8DZc7FJ.js → circle-check-DC5Ek4MP.js} +1 -1
- package/static/assets/{circle-check-big-D_PvuS7-.js → circle-check-big-Dw4YJZos.js} +1 -1
- package/static/assets/{circle-play-Ba60SPvN.js → circle-play-D9VS6Vdc.js} +1 -1
- package/static/assets/{circle-x-BYe1-ctZ.js → circle-x-BReHgv4g.js} +1 -1
- package/static/assets/{clipboard-DZHDxSAN.js → clipboard-CuF9OlXN.js} +1 -1
- package/static/assets/{clock-E0FNqZih.js → clock-CDTi2Cen.js} +1 -1
- package/static/assets/{download-DbHXGD3a.js → download-DHIAgGlY.js} +1 -1
- package/static/assets/droid-BvMEm3eg.js +8 -0
- package/static/assets/{eye-CvcvqrS0.js → eye-Ch7ecV9Z.js} +1 -1
- package/static/assets/{folder-git-2-DK9b1q2x.js → folder-git-2-BYI_osdA.js} +1 -1
- package/static/assets/{index-C4LGSoHO.js → index-CCs6x1Au.js} +2 -2
- package/static/assets/{label-DGhQh35t.js → label-BUv8Ltyw.js} +1 -1
- package/static/assets/{markdown-editor-52vxb0rp.js → markdown-editor-BP8Xkecg.js} +1 -1
- package/static/assets/{pause-B7dyLcuH.js → pause-B0clczfE.js} +1 -1
- package/static/assets/{play-C3zkOZiK.js → play-BHUpJCX1.js} +1 -1
- package/static/assets/{plus-BCs8PAn6.js → plus-D0SUNNMH.js} +1 -1
- package/static/assets/{radio-group-BseQ4OVV.js → radio-group-CSBH8ca-.js} +1 -1
- package/static/assets/{refresh-cw-ucF4I6xx.js → refresh-cw-C-yGwsHL.js} +1 -1
- package/static/assets/{search-TqAjHy3_.js → search-DFtqbVgP.js} +1 -1
- package/static/assets/{switch-B6px80Oh.js → switch-WtOd8h5Z.js} +1 -1
- package/static/assets/{tabs-BHSWuVOa.js → tabs-D93ZjKR7.js} +1 -1
- package/static/assets/{tag-DjI_1POr.js → tag-EEDDoCc_.js} +1 -1
- package/static/assets/{terminal-preview-C0DTE3G7.js → terminal-preview-sns5QTN_.js} +1 -1
- package/static/assets/{use-terminal-KpWB08HL.js → use-terminal-BW9XYY8N.js} +1 -1
- package/static/assets/{zap-DruahTJJ.js → zap-BYFYWzmj.js} +1 -1
- package/static/index.html +1 -1
- package/static/assets/ProposalDetailPage-BI5HDp5I.js +0 -1
- package/static/assets/droid-Caom7ttu.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,a7 as p,B as r,R as h,an as j,W as u,I as l,h as g,i as f,k as v,l as N,m as y}from"./index-
|
|
1
|
+
import{j as e,a7 as p,B as r,R as h,an as j,W as u,I as l,h as g,i as f,k as v,l as N,m as y}from"./index-CCs6x1Au.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-By4vbQ_f.js";import{L as a}from"./label-BUv8Ltyw.js";import{B as o}from"./badge-2ZOe5ynf.js";import{P as w}from"./plus-D0SUNNMH.js";import{E as b}from"./eye-Ch7ecV9Z.js";import{D as C}from"./download-DHIAgGlY.js";function T(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(w,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(o,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(o,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(b,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(h,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(l,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(g,{children:[e.jsx(f,{children:e.jsx(v,{placeholder:"Select category"})}),e.jsx(N,{children:x.map(s=>e.jsx(y,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptDescription",children:"Description"}),e.jsx(l,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Q as re,u as ne,r as l,a as le,j as e,B as n,L as h,R as ie,U as oe,V as ce,W as de,Y as me,Z as he,_ as xe,$ as pe,a0 as ue,a1 as je,a2 as fe,a3 as I,a4 as F,q as ge,D as R,a5 as B,b as V,d as z,f as H,g as q,h as ve,i as Ne,k as Ce,l as ye,m as c,a6 as J,w as we,a7 as Se,A as g}from"./index-CCs6x1Au.js";import{c as be}from"./clipboard-B9ndUJKl.js";import{C as d,b as x,a as m,c as u,d as _}from"./card-By4vbQ_f.js";import{B as p}from"./badge-2ZOe5ynf.js";import{L as M}from"./label-BUv8Ltyw.js";import{A as S}from"./arrow-left-DkoECaEJ.js";import{C as De,a as Ae}from"./clipboard-CuF9OlXN.js";import{D as ke}from"./download-DHIAgGlY.js";import{C as Te}from"./calendar-tNgwmWmG.js";import{C as Ee}from"./clock-CDTi2Cen.js";function Q(r){switch(r){case"ready":case"done":return"default";case"review":case"active":case"queued":return"secondary";case"canceled":return"destructive";default:return"outline"}}function W(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function ze(){const{id:r}=re(),Y=ne(),[s,v]=l.useState(null),[Z,b]=l.useState(!0),[N,D]=l.useState(null),[A,k]=l.useState(!1),[T,E]=l.useState(!1),[P,$]=l.useState(!1),[j,C]=l.useState(""),[G,y]=l.useState(!1),[K,w]=l.useState(!1),[f,U]=l.useState("draft"),[X,L]=l.useState(!1),{toast:O}=le();l.useEffect(()=>{async function a(){if(r)try{b(!0);const o=await(await fetch(`${g}/api/v1/proposals/${r}`)).json();o.success?v(o.data):D(o.error?.message||"Failed to fetch proposal")}catch(t){D(t instanceof Error?t.message:"Unknown error")}finally{b(!1)}}a()},[r]);const ee=async()=>{if(r){k(!0);try{const t=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"DELETE"})).json();t.success?Y("/proposals"):alert(t.error?.message||"Failed to delete proposal")}catch(a){alert(`Error deleting proposal: ${a instanceof Error?a.message:"Unknown error"}`)}finally{k(!1)}}},se=async()=>{if(!(!s||!r||f===s.status)){E(!0);try{const t=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).json();t.success?(v(t.data),y(!1)):alert(t.error?.message||"Failed to update status")}catch(a){alert(`Error updating status: ${a instanceof Error?a.message:"Unknown error"}`)}finally{E(!1)}}},ae=async()=>{if(!(!s||!r||!j.trim())){$(!0);try{const a={id:`comment-${Date.now()}`,text:j,author:"current-user",timestamp:new Date().toISOString()},t=[...s.metadata.comments||[],a],i=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:t})})).json();i.success?(v(i.data),C(""),w(!1)):alert(i.error?.message||"Failed to add comment")}catch(a){alert(`Error adding comment: ${a instanceof Error?a.message:"Unknown error"}`)}finally{$(!1)}}},te=()=>{if(!s)return;const a={...s,exportedAt:new Date().toISOString()},t=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),o=URL.createObjectURL(t),i=document.createElement("a");i.href=o,i.download=`proposal-${s.id}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)};return Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]}):N||!s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:N||"Proposal not found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:N||"Proposal not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The proposal with ID "',r,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(h,{to:"/proposals",children:"Back to Proposals"})})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.intent}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(h,{to:"/proposals",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(h,{to:`/proposals/${r}/edit`,children:[e.jsx(ie,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:A,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:A?"Deleting...":"Delete"})]})}),e.jsxs(me,{children:[e.jsxs(he,{children:[e.jsx(xe,{children:"Are you absolutely sure?"}),e.jsxs(pe,{children:["This action cannot be undone. This will permanently delete the change proposal",e.jsxs("span",{className:"font-semibold",children:[' "',s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(ue,{children:[e.jsx(je,{children:"Cancel"}),e.jsx(fe,{onClick:ee,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Proposal"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const a=`.nut/proposals/${s.id}.md`;try{await be(a),L(!0),O({title:"Copied!",description:`${a} copied to clipboard`}),setTimeout(()=>L(!1),2e3)}catch(t){console.error("Failed to copy path:",t),O({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/proposals/${s.id}.md`}),X?e.jsx(De,{className:"h-3.5 w-3.5"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(u,{children:"Task Details"}),e.jsxs("div",{className:"flex gap-2",children:[s.metadata.priority&&e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority}),e.jsx(p,{variant:Q(s.status),children:s.status})]})]})}),e.jsx(m,{className:"space-y-4",children:s.content?e.jsx(I,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this proposal."})})]}),s.planSteps&&s.planSteps.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Implementation Steps"}),e.jsxs(_,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((a,t)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:t+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:a.description}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:e.jsx(p,{variant:"outline",className:"text-xs",children:a.status})})]})]},a.id))})})]}),s.metadata.comments&&s.metadata.comments.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Comments"}),e.jsxs(_,{children:[s.metadata.comments.length," comment",s.metadata.comments.length!==1?"s":""]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-4",children:s.metadata.comments.map((a,t)=>e.jsxs("div",{className:"border-l-2 border-muted pl-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(F,{className:"h-3 w-3"}),e.jsx("span",{children:a.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(a.timestamp).toLocaleString()})]}),e.jsx(I,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:a.text})]},a.id||t))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Task Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsx(n,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(h,{to:`/terminal/${r}`,children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Prepare Agent"]})}),e.jsxs(R,{open:G,onOpenChange:y,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",onClick:()=>U(s?.status||"draft"),children:"Change Status"})}),e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsx(H,{children:"Change Proposal Status"}),e.jsx(q,{children:"Update the status of this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(M,{htmlFor:"status",children:"Status"}),e.jsxs(ve,{value:f,onValueChange:a=>U(a),children:[e.jsx(Ne,{children:e.jsx(Ce,{placeholder:"Select status"})}),e.jsxs(ye,{children:[e.jsx(c,{value:"draft",children:"Draft"}),e.jsx(c,{value:"proposed",children:"Proposed"}),e.jsx(c,{value:"in-review",children:"In Review"}),e.jsx(c,{value:"approved",children:"Approved"}),e.jsx(c,{value:"code-complete",children:"Code Complete"}),e.jsx(c,{value:"merged",children:"Merged"}),e.jsx(c,{value:"rejected",children:"Rejected"})]})]})]})}),e.jsxs(J,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:se,disabled:T||f===s?.status,children:T?"Updating...":"Update Status"})]})]})]}),e.jsxs(R,{open:K,onOpenChange:w,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",children:"Add Comment"})}),e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsx(H,{children:"Add Comment"}),e.jsx(q,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(M,{htmlFor:"comment",children:"Comment"}),e.jsx(we,{id:"comment",placeholder:"Enter your comment...",value:j,onChange:a=>C(a.target.value),rows:4})]})}),e.jsxs(J,{children:[e.jsx(n,{variant:"outline",onClick:()=>{w(!1),C("")},children:"Cancel"}),e.jsx(n,{onClick:ae,disabled:P||!j.trim(),children:P?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:te,children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(F,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Author:"}),e.jsx("span",{children:s.author.name})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Te,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:new Date(s.metadata.createdAt).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:new Date(s.metadata.updatedAt).toLocaleString()})]}),e.jsx(Se,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:Q(s.status),children:s.status})})]}),s.metadata.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Priority:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority})})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.metadata.tags.map(a=>e.jsx(p,{variant:"outline",className:"text-xs",children:a},a))})]})]})]})]})]})]})}export{ze as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as R,u as U,a as H,r as o,A,j as e,B as m,L as x,I as O,h as P,i as L,k as D,l as F,m as r,X as V,a8 as _}from"./index-
|
|
1
|
+
import{Q as R,u as U,a as H,r as o,A,j as e,B as m,L as x,I as O,h as P,i as L,k as D,l as F,m as r,X as V,a8 as _}from"./index-CCs6x1Au.js";import{L as j}from"./label-BUv8Ltyw.js";import{C as f,b as I,a as v,c as q,d as J}from"./card-By4vbQ_f.js";import{M as K}from"./markdown-editor-BP8Xkecg.js";import{C as Q}from"./CollapsibleSection-BKY-lfsm.js";import{I as W,L as X}from"./ImplementationStepsEditor-iqrCqyOb.js";import{T as G}from"./TagInput-BWLBdW8h.js";import{A as N}from"./arrow-left-DkoECaEJ.js";import"./plus-D0SUNNMH.js";import"./badge-2ZOe5ynf.js";function oe(){const{id:i}=R(),$=U(),{toast:y}=H(),[z,S]=o.useState(!0),[h,C]=o.useState(!1),[w,b]=o.useState(null),[l,d]=o.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[p,E]=o.useState([]),[T,k]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/proposals/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;d({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];E(g.map((c,u)=>({id:c.id||`step-${u+1}`,description:c.description||"",status:c.status||"pending"}))),k(a.metadata?.tags||[])}else b(s.error?.message||"Failed to fetch proposal")}catch(t){b(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),C(!0);try{const s=p.map(n=>({id:n.id,description:n.description.trim(),status:n.status})).filter(n=>n.description.length>0),a=T.map(n=>n.trim()).filter(n=>n.length>0),g={title:l.title,status:l.status,planSteps:s,metadata:{priority:l.priority,tags:a},content:l.description},c=await fetch(`${A}/api/v1/proposals/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),u=await c.json();if(u.success||c.ok)y({title:"Success",description:"Proposal updated successfully."}),$(`/proposals/${i}`);else throw new Error(u.error?.message||"Failed to update proposal")}catch(s){y({title:"Error",description:`Failed to update proposal: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{C(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading proposal data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx(I,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):w?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:w})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs(I,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your change proposal"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:l.title,onChange:t=>d(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:l.description,onChange:t=>d(s=>({...s,description:t||""})),placeholder:"Write your proposal description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(P,{value:l.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(D,{placeholder:"Select status"})}),e.jsxs(F,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(Q,{defaultOpen:!0,icon:e.jsx(X,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(P,{value:l.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(D,{placeholder:"Select priority"})}),e.jsxs(F,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),p.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," step",p.length===1?"":"s"]})]}),e.jsx(W,{steps:p,onChange:E,disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the proposal list."}),e.jsx(G,{tags:T,onChange:k,disabled:h,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(m,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(x,{to:`/proposals/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(m,{type:"submit",disabled:h||!l.title,children:h?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{oe as ProposalEditPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as xe,O as _e,u as Ie,z as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Te,x as Oe,P as $e,v as Pe,h as ie,i as ae,k as ce,l as ue,m as
|
|
1
|
+
import{c as xe,O as _e,u as Ie,z as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Te,x as Oe,P as $e,v as Pe,h as ie,i as ae,k as ce,l as ue,m as w,G as Ke,A as ze}from"./index-CCs6x1Au.js";import{C as J,b as Ve,a as Z,c as We}from"./card-By4vbQ_f.js";import{B as q}from"./badge-2ZOe5ynf.js";import{P as ee}from"./plus-D0SUNNMH.js";import{S as Ue}from"./search-DFtqbVgP.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,5 +13,5 @@ import{c as xe,O as _e,u as Ie,z as Le,r as j,j as t,B as V,L as Y,I as Re,X,K a
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Xe=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ae=xe("funnel",Xe);function T(s){return Array.isArray?Array.isArray(s):ve(s)==="[object Array]"}function Je(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function Ze(s){return s==null?"":Je(s)}function R(s){return typeof s=="string"}function Ee(s){return typeof s=="number"}function qe(s){return s===!0||s===!1||et(s)&&ve(s)=="[object Boolean]"}function be(s){return typeof s=="object"}function et(s){return be(s)&&s!==null}function B(s){return s!=null}function le(s){return!s.trim().length}function ve(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const tt="Incorrect 'index' type",st=s=>`Invalid value for key ${s}`,rt=s=>`Pattern length exceeds max of ${s}.`,nt=s=>`Missing ${s} property in key`,it=s=>`Property 'weight' in key '${s}' must be a positive integer`,je=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let i=Fe(n);this._keys.push(i),this._keyMap[i.id]=i,r+=i.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Fe(s){let e=null,r=null,n=null,i=1,a=null;if(R(s)||T(s))n=s,e=ye(s),r=oe(s);else{if(!je.call(s,"name"))throw new Error(nt("name"));const c=s.name;if(n=c,je.call(s,"weight")&&(i=s.weight,i<=0))throw new Error(it(c));e=ye(c),r=oe(c),a=s.getFn}return{path:e,id:r,weight:i,src:n,getFn:a}}function ye(s){return T(s)?s:s.split(".")}function oe(s){return T(s)?s.join("."):s}function ct(s,e){let r=[],n=!1;const i=(a,c,l)=>{if(B(a))if(!c[l])r.push(a);else{let o=c[l];const h=a[o];if(!B(h))return;if(l===c.length-1&&(R(h)||Ee(h)||qe(h)))r.push(Ze(h));else if(T(h)){n=!0;for(let d=0,m=h.length;d<m;d+=1)i(h[d],c,l+1)}else c.length&&i(h,c,l+1)}};return i(s,R(e)?e.split("."):e,0),n?r:r[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},ot={location:0,threshold:.6,distance:100},ht={useExtendedSearch:!1,getFn:ct,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var f={...lt,...ut,...ot,...ht};const dt=/[^ ]+/g;function ft(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(i){const a=i.match(dt).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*s),l=parseFloat(Math.round(c*n)/n);return r.set(a,l),l},clear(){r.clear()}}}class pe{constructor({getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){this.norm=ft(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,R(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();R(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!B(e)||le(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((i,a)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(B(c)){if(T(c)){let l=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(B(d))if(R(d)&&!le(d)){let m={v:d,i:h,n:this.norm.get(d)};l.push(m)}else T(d)&&d.forEach((m,x)=>{o.push({nestedArrIndex:x,value:m})})}n.$[a]=l}else if(R(c)&&!le(c)){let l={v:c,n:this.norm.get(c)};n.$[a]=l}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function De(s,e,{getFn:r=f.getFn,fieldNormWeight:n=f.fieldNormWeight}={}){const i=new pe({getFn:r,fieldNormWeight:n});return i.setKeys(s.map(Fe)),i.setSources(e),i.create(),i}function mt(s,{getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const{keys:n,records:i}=s,a=new pe({getFn:e,fieldNormWeight:r});return a.setKeys(n),a.setIndexRecords(i),a}function te(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:i=f.distance,ignoreLocation:a=f.ignoreLocation}={}){const c=e/s.length;if(a)return c;const l=Math.abs(n-r);return i?c+l/i:l?1:c}function gt(s=[],e=f.minMatchCharLength){let r=[],n=-1,i=-1,a=0;for(let c=s.length;a<c;a+=1){let l=s[a];l&&n===-1?n=a:!l&&n!==-1&&(i=a-1,i-n+1>=e&&r.push([n,i]),n=-1)}return s[a-1]&&a-n>=e&&r.push([n,a-1]),r}const W=32;function xt(s,e,r,{location:n=f.location,distance:i=f.distance,threshold:a=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,includeMatches:o=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>W)throw new Error(rt(W));const d=e.length,m=s.length,x=Math.max(0,Math.min(n,m));let g=a,A=x;const w=l>1||o,D=w?Array(m):[];let b;for(;(b=s.indexOf(e,A))>-1;){let F=te(e,{currentLocation:b,expectedLocation:x,distance:i,ignoreLocation:h});if(g=Math.min(F,g),A=b+d,w){let S=0;for(;S<d;)D[b+S]=1,S+=1}}A=-1;let _=[],v=1,L=d+m;const G=1<<d-1;for(let F=0;F<d;F+=1){let S=0,C=L;for(;S<C;)te(e,{errors:F,currentLocation:x+C,expectedLocation:x,distance:i,ignoreLocation:h})<=g?S=C:L=C,C=Math.floor((L-S)/2+S);L=C;let z=Math.max(1,x-C+1),O=c?m:Math.min(x+C,m)+d,I=Array(O+2);I[O+1]=(1<<F)-1;for(let M=O;M>=z;M-=1){let $=M-1,Q=r[s.charAt($)];if(w&&(D[$]=+!!Q),I[M]=(I[M+1]<<1|1)&Q,F&&(I[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),I[M]&G&&(v=te(e,{errors:F,currentLocation:$,expectedLocation:x,distance:i,ignoreLocation:h}),v<=g)){if(g=v,A=$,A<=x)break;z=Math.max(1,2*x-A)}}if(te(e,{errors:F+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:h})>g)break;_=I}const H={isMatch:A>=0,score:Math.max(.001,v)};if(w){const F=gt(D,l);F.length?o&&(H.indices=F):H.isMatch=!1}return H}function pt(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const i=s.charAt(r);e[i]=(e[i]||0)|1<<n-r-1}return e}const se=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class Me{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?se(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(g,A)=>{this.chunks.push({pattern:g,alphabet:pt(g),startIndex:A})},x=this.pattern.length;if(x>W){let g=0;const A=x%W,w=x-A;for(;g<w;)m(this.pattern.substr(g,W),g),g+=W;if(A){const D=x-W;m(this.pattern.substr(D),D)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i}=this.options;if(e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern===e){let w={isMatch:!0,score:0};return i&&(w.indices=[[0,e.length-1]]),w}const{location:a,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let m=[],x=0,g=!1;this.chunks.forEach(({pattern:w,alphabet:D,startIndex:b})=>{const{isMatch:_,score:v,indices:L}=xt(e,w,D,{location:a+b,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,includeMatches:i,ignoreLocation:d});_&&(g=!0),x+=v,_&&L&&(m=[...m,...L])});let A={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(A.indices=m),A}}class K{constructor(e){this.pattern=e}static isMultiMatch(e){return Ce(e,this.multiRegex)}static isSingleMatch(e){return Ce(e,this.singleRegex)}search(){}}function Ce(s,e){const r=s.match(e);return r?r[1]:null}class At extends K{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class jt extends K{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class yt extends K{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends K{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class wt extends K{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Nt extends K{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class ke extends K{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){super(e),this._bitapSearch=new Me(e,{location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Be extends K{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const i=[],a=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+a,i.push([n,r-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const he=[At,Be,yt,Ct,Nt,wt,jt,ke],we=he.length,Et=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,bt="|";function vt(s,e={}){return s.split(bt).map(r=>{let n=r.trim().split(Et).filter(a=>a&&!!a.trim()),i=[];for(let a=0,c=n.length;a<c;a+=1){const l=n[a];let o=!1,h=-1;for(;!o&&++h<we;){const d=he[h];let m=d.isMultiMatch(l);m&&(i.push(new d(m,e)),o=!0)}if(!o)for(h=-1;++h<we;){const d=he[h];let m=d.isSingleMatch(l);if(m){i.push(new d(m,e));break}}}return i})}const Ft=new Set([ke.type,Be.type]);class Dt{constructor(e,{isCaseSensitive:r=f.isCaseSensitive,ignoreDiacritics:n=f.ignoreDiacritics,includeMatches:i=f.includeMatches,minMatchCharLength:a=f.minMatchCharLength,ignoreLocation:c=f.ignoreLocation,findAllMatches:l=f.findAllMatches,location:o=f.location,threshold:h=f.threshold,distance:d=f.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern=e,this.query=vt(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:a}=this.options;e=i?e:e.toLowerCase(),e=a?se(e):e;let c=0,l=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const m=r[h];l.length=0,c=0;for(let x=0,g=m.length;x<g;x+=1){const A=m[x],{isMatch:w,indices:D,score:b}=A.search(e);if(w){if(c+=1,o+=b,n){const _=A.constructor.type;Ft.has(_)?l=[...l,...D]:l.push(D)}}else{o=0,c=0,l.length=0;break}}if(c){let x={isMatch:!0,score:o/c};return n&&(x.indices=l),x}}return{isMatch:!1,score:1}}}const de=[];function Mt(...s){de.push(...s)}function fe(s,e){for(let r=0,n=de.length;r<n;r+=1){let i=de[r];if(i.condition(s,e))return new i(s,e)}return new Me(s,e)}const re={AND:"$and",OR:"$or"},me={PATH:"$path",PATTERN:"$val"},ge=s=>!!(s[re.AND]||s[re.OR]),kt=s=>!!s[me.PATH],Bt=s=>!T(s)&&be(s)&&!ge(s),Ne=s=>({[re.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Se(s,e,{auto:r=!0}={}){const n=i=>{let a=Object.keys(i);const c=kt(i);if(!c&&a.length>1&&!ge(i))return n(Ne(i));if(Bt(i)){const o=c?i[me.PATH]:a[0],h=c?i[me.PATTERN]:i[o];if(!R(h))throw new Error(st(o));const d={keyId:oe(o),pattern:h};return r&&(d.searcher=fe(h,e)),d}let l={children:[],operator:a[0]};return a.forEach(o=>{const h=i[o];T(h)&&h.forEach(d=>{l.children.push(n(d))})}),l};return ge(s)||(s=Ne(s)),n(s)}function St(s,{ignoreFieldNorm:e=f.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:i,norm:a,score:c})=>{const l=i?i.weight:null;n*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(e?1:a))}),r.score=n})}function _t(s,e){const r=s.matches;e.matches=[],B(r)&&r.forEach(n=>{if(!B(n.indices)||!n.indices.length)return;const{indices:i,value:a}=n;let c={indices:i,value:a};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function It(s,e){e.score=s.score}function Lt(s,e,{includeMatches:r=f.includeMatches,includeScore:n=f.includeScore}={}){const i=[];return r&&i.push(_t),n&&i.push(It),s.map(a=>{const{idx:c}=a,l={item:e[c],refIndex:c};return i.length&&i.forEach(o=>{o(a,l)}),l})}class U{constructor(e,r={},n){this.options={...f,...r},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof pe))throw new Error(tt);this._myIndex=r||De(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){B(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,i=this._docs.length;n<i;n+=1){const a=this._docs[n];e(a,n)&&(this.removeAt(n),n-=1,i-=1,r.push(a))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let o=R(e)?R(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return St(o,{ignoreFieldNorm:l}),a&&o.sort(c),Ee(r)&&r>-1&&(o=o.slice(0,r)),Lt(o,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const r=fe(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:a,i:c,n:l})=>{if(!B(a))return;const{isMatch:o,score:h,indices:d}=r.searchIn(a);o&&i.push({item:a,idx:c,matches:[{score:h,value:a,norm:l,indices:d}]})}),i}_searchLogical(e){const r=Se(e,this.options),n=(l,o,h)=>{if(!l.children){const{keyId:m,searcher:x}=l,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(o,m),searcher:x});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const d=[];for(let m=0,x=l.children.length;m<x;m+=1){const g=l.children[m],A=n(g,o,h);if(A.length)d.push(...A);else if(l.operator===re.AND)return[]}return d},i=this._myIndex.records,a={},c=[];return i.forEach(({$:l,i:o})=>{if(B(l)){let h=n(r,l,o);h.length&&(a[o]||(a[o]={idx:o,item:l,matches:[]},c.push(a[o])),h.forEach(({matches:d})=>{a[o].matches.push(...d)}))}}),c}_searchObjectList(e){const r=fe(e,this.options),{keys:n,records:i}=this._myIndex,a=[];return i.forEach(({$:c,i:l})=>{if(!B(c))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:c[d],searcher:r}))}),o.length&&a.push({idx:l,item:c,matches:o})}),a}_findMatches({key:e,value:r,searcher:n}){if(!B(r))return[];let i=[];if(T(r))r.forEach(({v:a,i:c,n:l})=>{if(!B(a))return;const{isMatch:o,score:h,indices:d}=n.searchIn(a);o&&i.push({score:h,key:e,value:a,idx:c,norm:l,indices:d})});else{const{v:a,n:c}=r,{isMatch:l,score:o,indices:h}=n.searchIn(a);l&&i.push({score:o,key:e,value:a,norm:c,indices:h})}return i}}U.version="7.1.0";U.createIndex=De;U.parseIndex=mt;U.config=f;U.parseQuery=Se;Mt(Dt);function Rt(s){switch(s){case"ready":case"done":return"default";case"queued":case"active":case"review":return"secondary";case"blocked":case"canceled":return"destructive";default:return"outline"}}function Tt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Vt(){const[s]=_e(),e=Ie(),r=Le(),[n,i]=j.useState([]),[a,c]=j.useState([]),[l,o]=j.useState(!0),[h,d]=j.useState(null),[m,x]=j.useState(s.get("status")||"open"),[g,A]=j.useState(s.get("priority")||"all"),[w,D]=j.useState(s.get("search")||""),[b,_]=j.useState(s.get("sortBy")||"created"),[v,L]=j.useState(s.get("order")||"desc"),[G,H]=j.useState(!1),F=j.useRef(null),S=[m!=="open",g!=="all",b!=="created",v!=="desc"].filter(Boolean).length,C=j.useCallback(u=>{const p=new URLSearchParams(s);Object.entries(u).forEach(([k,P])=>{P&&P!=="all"&&P!=="open"&&P!==""?p.set(k,P):p.delete(k)});const N=p.toString(),E=N?`?${N}`:"";e(`${r.pathname}${E}`)},[s,e,r.pathname]),z=j.useCallback(u=>{x(u),C({status:u==="open"?null:u})},[C]),O=j.useCallback(u=>{A(u),C({priority:u==="all"?null:u})},[C]),I=j.useCallback(u=>{D(u),C({search:u||null})},[C]),ne=j.useCallback(u=>{_(u),C({sortBy:u==="created"?null:u})},[C]),M=j.useCallback(()=>{const u=v==="asc"?"desc":"asc";L(u),C({order:u==="desc"?null:u})},[v,C]),$=j.useCallback(u=>{if(u.key==="s"||u.key==="S"){const p=document.activeElement;p?.tagName==="INPUT"||p?.tagName==="TEXTAREA"||p?.getAttribute("contenteditable")==="true"||(u.preventDefault(),F.current?.focus())}},[]);j.useEffect(()=>(document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$)}),[$]);const Q=j.useMemo(()=>{const u={keys:[{name:"intent",weight:.4},{name:"id",weight:.3},{name:"author.name",weight:.2},{name:"metadata.tags",weight:.1}],threshold:.3,includeScore:!0};return new U(n,u)},[n]);return j.useEffect(()=>{async function u(){try{o(!0);const N=await(await fetch(`${ze}/api/v1/proposals`)).json();N.success?(i(N.data),c(N.data)):d(N.error?.message||"Failed to fetch proposals")}catch(p){d(p instanceof Error?p.message:"Unknown error")}finally{o(!1)}}u()},[]),j.useEffect(()=>{let u=n;if(m==="open"?u=u.filter(p=>["draft","backlog","ready","queued","active","blocked","review"].includes(p.status)):m==="ready"?u=u.filter(p=>["ready","done"].includes(p.status)):m!=="all"&&(u=u.filter(p=>p.status===m)),g!=="all"&&(u=u.filter(p=>p.metadata.priority===g)),w.trim()){const p=Q.search(w),N=new Set(p.map(E=>E.item.id));u=u.filter(E=>N.has(E.id))}u=u.sort((p,N)=>{let E,k;switch(b){case"created":{E=new Date(p.metadata.createdAt).getTime(),k=new Date(N.metadata.createdAt).getTime();break}case"updated":{E=new Date(p.metadata.updatedAt).getTime(),k=new Date(N.metadata.updatedAt).getTime();break}case"status":{E=p.status,k=N.status;break}case"priority":{const P={critical:4,high:3,medium:2,low:1};E=P[p.metadata.priority]||0,k=P[N.metadata.priority]||0;break}case"intent":{E=(p.title||p.intent||"").toLowerCase(),k=(N.title||N.intent||"").toLowerCase();break}default:E=new Date(p.metadata.createdAt).getTime(),k=new Date(N.metadata.createdAt).getTime()}return v==="asc"?E<k?-1:E>k?1:0:E>k?-1:E<k?1:0}),c(u)},[n,m,g,w,b,v,Q]),l?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx("div",{className:"space-y-4",children:[...Array(3)].map((u,p)=>t.jsx(J,{children:t.jsx(Ve,{children:t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4 animate-pulse"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]}),t.jsx("div",{className:"h-6 bg-muted rounded w-20 animate-pulse"})]})})},p))})]}):h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(Re,{ref:F,placeholder:"Search tasks...",value:w,onChange:u=>I(u.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:w?t.jsx("button",{onClick:()=>I(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Te,{children:t.jsx(Oe,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>H(!G),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(Ae,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),S>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:S}),G?t.jsx($e,{className:"h-4 w-4 ml-1"}):t.jsx(Pe,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[m!=="open"&&t.jsxs("button",{onClick:()=>z("open"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[m,t.jsx(X,{className:"h-3 w-3"})]}),g!=="all"&&t.jsxs("button",{onClick:()=>O("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[g," priority",t.jsx(X,{className:"h-3 w-3"})]}),(b!=="created"||v!=="desc")&&t.jsxs("button",{onClick:()=>{ne("created"),L("desc"),C({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[b," ",v==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[a.length," result",a.length!==1?"s":""]})]}),G&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(ie,{value:m,onValueChange:z,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by status"})}),t.jsxs(ue,{children:[t.jsx(y,{value:"open",children:"Open (Default)"}),t.jsx(y,{value:"all",children:"All statuses"}),t.jsx(y,{value:"draft",children:"Draft"}),t.jsx(y,{value:"backlog",children:"Backlog"}),t.jsx(y,{value:"ready",children:"Ready"}),t.jsx(y,{value:"queued",children:"Queued"}),t.jsx(y,{value:"active",children:"Active"}),t.jsx(y,{value:"blocked",children:"Blocked"}),t.jsx(y,{value:"review",children:"Review"}),t.jsx(y,{value:"done",children:"Done"}),t.jsx(y,{value:"canceled",children:"Canceled"}),t.jsx(y,{value:"duplicate",children:"Duplicate"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(ie,{value:g,onValueChange:O,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by priority"})}),t.jsxs(ue,{children:[t.jsx(y,{value:"all",children:"All priorities"}),t.jsx(y,{value:"low",children:"Low"}),t.jsx(y,{value:"medium",children:"Medium"}),t.jsx(y,{value:"high",children:"High"}),t.jsx(y,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(ie,{value:b,onValueChange:u=>ne(u),children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{})}),t.jsxs(ue,{children:[t.jsx(y,{value:"created",children:"Created Date"}),t.jsx(y,{value:"updated",children:"Updated Date"}),t.jsx(y,{value:"status",children:"Status"}),t.jsx(y,{value:"priority",children:"Priority"}),t.jsx(y,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(V,{variant:"outline",onClick:M,className:"w-full justify-between bg-background",children:v==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(Ye,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(He,{className:"h-4 w-4"})]})})]})]}),S>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>{z("open"),O("all"),I("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),a.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ae,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(V,{variant:"outline",className:"mt-4",onClick:()=>{z("open"),O("all"),I("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ke,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),t.jsx(V,{asChild:!0,className:"mt-4",children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsx("div",{className:"space-y-4",children:a.map(u=>t.jsx(Y,{to:`/proposals/${u.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(We,{className:"text-base leading-tight",children:u.title||u.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[u.metadata.priority&&t.jsx(q,{variant:Tt(u.metadata.priority),className:"text-xs",children:u.metadata.priority}),t.jsx(q,{variant:Rt(u.status),className:"text-xs",children:u.status})]})]}),u.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[u.content.split(`
|
|
16
|
+
*/const Xe=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ae=xe("funnel",Xe);function T(s){return Array.isArray?Array.isArray(s):be(s)==="[object Array]"}function Je(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function Ze(s){return s==null?"":Je(s)}function R(s){return typeof s=="string"}function ve(s){return typeof s=="number"}function qe(s){return s===!0||s===!1||et(s)&&be(s)=="[object Boolean]"}function Ee(s){return typeof s=="object"}function et(s){return Ee(s)&&s!==null}function k(s){return s!=null}function le(s){return!s.trim().length}function be(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const tt="Incorrect 'index' type",st=s=>`Invalid value for key ${s}`,rt=s=>`Pattern length exceeds max of ${s}.`,nt=s=>`Missing ${s} property in key`,it=s=>`Property 'weight' in key '${s}' must be a positive integer`,je=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let i=Fe(n);this._keys.push(i),this._keyMap[i.id]=i,r+=i.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Fe(s){let e=null,r=null,n=null,i=1,a=null;if(R(s)||T(s))n=s,e=ye(s),r=oe(s);else{if(!je.call(s,"name"))throw new Error(nt("name"));const c=s.name;if(n=c,je.call(s,"weight")&&(i=s.weight,i<=0))throw new Error(it(c));e=ye(c),r=oe(c),a=s.getFn}return{path:e,id:r,weight:i,src:n,getFn:a}}function ye(s){return T(s)?s:s.split(".")}function oe(s){return T(s)?s.join("."):s}function ct(s,e){let r=[],n=!1;const i=(a,c,l)=>{if(k(a))if(!c[l])r.push(a);else{let o=c[l];const h=a[o];if(!k(h))return;if(l===c.length-1&&(R(h)||ve(h)||qe(h)))r.push(Ze(h));else if(T(h)){n=!0;for(let d=0,m=h.length;d<m;d+=1)i(h[d],c,l+1)}else c.length&&i(h,c,l+1)}};return i(s,R(e)?e.split("."):e,0),n?r:r[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},ot={location:0,threshold:.6,distance:100},ht={useExtendedSearch:!1,getFn:ct,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var f={...lt,...ut,...ot,...ht};const dt=/[^ ]+/g;function ft(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(i){const a=i.match(dt).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*s),l=parseFloat(Math.round(c*n)/n);return r.set(a,l),l},clear(){r.clear()}}}class pe{constructor({getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){this.norm=ft(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,R(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();R(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!k(e)||le(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((i,a)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(k(c)){if(T(c)){let l=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(k(d))if(R(d)&&!le(d)){let m={v:d,i:h,n:this.norm.get(d)};l.push(m)}else T(d)&&d.forEach((m,x)=>{o.push({nestedArrIndex:x,value:m})})}n.$[a]=l}else if(R(c)&&!le(c)){let l={v:c,n:this.norm.get(c)};n.$[a]=l}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Me(s,e,{getFn:r=f.getFn,fieldNormWeight:n=f.fieldNormWeight}={}){const i=new pe({getFn:r,fieldNormWeight:n});return i.setKeys(s.map(Fe)),i.setSources(e),i.create(),i}function mt(s,{getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const{keys:n,records:i}=s,a=new pe({getFn:e,fieldNormWeight:r});return a.setKeys(n),a.setIndexRecords(i),a}function te(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:i=f.distance,ignoreLocation:a=f.ignoreLocation}={}){const c=e/s.length;if(a)return c;const l=Math.abs(n-r);return i?c+l/i:l?1:c}function gt(s=[],e=f.minMatchCharLength){let r=[],n=-1,i=-1,a=0;for(let c=s.length;a<c;a+=1){let l=s[a];l&&n===-1?n=a:!l&&n!==-1&&(i=a-1,i-n+1>=e&&r.push([n,i]),n=-1)}return s[a-1]&&a-n>=e&&r.push([n,a-1]),r}const W=32;function xt(s,e,r,{location:n=f.location,distance:i=f.distance,threshold:a=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,includeMatches:o=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>W)throw new Error(rt(W));const d=e.length,m=s.length,x=Math.max(0,Math.min(n,m));let g=a,A=x;const C=l>1||o,M=C?Array(m):[];let E;for(;(E=s.indexOf(e,A))>-1;){let F=te(e,{currentLocation:E,expectedLocation:x,distance:i,ignoreLocation:h});if(g=Math.min(F,g),A=E+d,C){let S=0;for(;S<d;)M[E+S]=1,S+=1}}A=-1;let _=[],b=1,L=d+m;const G=1<<d-1;for(let F=0;F<d;F+=1){let S=0,y=L;for(;S<y;)te(e,{errors:F,currentLocation:x+y,expectedLocation:x,distance:i,ignoreLocation:h})<=g?S=y:L=y,y=Math.floor((L-S)/2+S);L=y;let z=Math.max(1,x-y+1),O=c?m:Math.min(x+y,m)+d,I=Array(O+2);I[O+1]=(1<<F)-1;for(let D=O;D>=z;D-=1){let $=D-1,Q=r[s.charAt($)];if(C&&(M[$]=+!!Q),I[D]=(I[D+1]<<1|1)&Q,F&&(I[D]|=(_[D+1]|_[D])<<1|1|_[D+1]),I[D]&G&&(b=te(e,{errors:F,currentLocation:$,expectedLocation:x,distance:i,ignoreLocation:h}),b<=g)){if(g=b,A=$,A<=x)break;z=Math.max(1,2*x-A)}}if(te(e,{errors:F+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:h})>g)break;_=I}const H={isMatch:A>=0,score:Math.max(.001,b)};if(C){const F=gt(M,l);F.length?o&&(H.indices=F):H.isMatch=!1}return H}function pt(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const i=s.charAt(r);e[i]=(e[i]||0)|1<<n-r-1}return e}const se=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class De{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?se(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(g,A)=>{this.chunks.push({pattern:g,alphabet:pt(g),startIndex:A})},x=this.pattern.length;if(x>W){let g=0;const A=x%W,C=x-A;for(;g<C;)m(this.pattern.substr(g,W),g),g+=W;if(A){const M=x-W;m(this.pattern.substr(M),M)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i}=this.options;if(e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern===e){let C={isMatch:!0,score:0};return i&&(C.indices=[[0,e.length-1]]),C}const{location:a,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let m=[],x=0,g=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:E})=>{const{isMatch:_,score:b,indices:L}=xt(e,C,M,{location:a+E,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,includeMatches:i,ignoreLocation:d});_&&(g=!0),x+=b,_&&L&&(m=[...m,...L])});let A={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(A.indices=m),A}}class K{constructor(e){this.pattern=e}static isMultiMatch(e){return Ce(e,this.multiRegex)}static isSingleMatch(e){return Ce(e,this.singleRegex)}search(){}}function Ce(s,e){const r=s.match(e);return r?r[1]:null}class At extends K{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class jt extends K{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class yt extends K{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends K{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class wt extends K{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Nt extends K{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Be extends K{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){super(e),this._bitapSearch=new De(e,{location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ke extends K{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const i=[],a=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+a,i.push([n,r-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const he=[At,ke,yt,Ct,Nt,wt,jt,Be],we=he.length,vt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Et="|";function bt(s,e={}){return s.split(Et).map(r=>{let n=r.trim().split(vt).filter(a=>a&&!!a.trim()),i=[];for(let a=0,c=n.length;a<c;a+=1){const l=n[a];let o=!1,h=-1;for(;!o&&++h<we;){const d=he[h];let m=d.isMultiMatch(l);m&&(i.push(new d(m,e)),o=!0)}if(!o)for(h=-1;++h<we;){const d=he[h];let m=d.isSingleMatch(l);if(m){i.push(new d(m,e));break}}}return i})}const Ft=new Set([Be.type,ke.type]);class Mt{constructor(e,{isCaseSensitive:r=f.isCaseSensitive,ignoreDiacritics:n=f.ignoreDiacritics,includeMatches:i=f.includeMatches,minMatchCharLength:a=f.minMatchCharLength,ignoreLocation:c=f.ignoreLocation,findAllMatches:l=f.findAllMatches,location:o=f.location,threshold:h=f.threshold,distance:d=f.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:a}=this.options;e=i?e:e.toLowerCase(),e=a?se(e):e;let c=0,l=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const m=r[h];l.length=0,c=0;for(let x=0,g=m.length;x<g;x+=1){const A=m[x],{isMatch:C,indices:M,score:E}=A.search(e);if(C){if(c+=1,o+=E,n){const _=A.constructor.type;Ft.has(_)?l=[...l,...M]:l.push(M)}}else{o=0,c=0,l.length=0;break}}if(c){let x={isMatch:!0,score:o/c};return n&&(x.indices=l),x}}return{isMatch:!1,score:1}}}const de=[];function Dt(...s){de.push(...s)}function fe(s,e){for(let r=0,n=de.length;r<n;r+=1){let i=de[r];if(i.condition(s,e))return new i(s,e)}return new De(s,e)}const re={AND:"$and",OR:"$or"},me={PATH:"$path",PATTERN:"$val"},ge=s=>!!(s[re.AND]||s[re.OR]),Bt=s=>!!s[me.PATH],kt=s=>!T(s)&&Ee(s)&&!ge(s),Ne=s=>({[re.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Se(s,e,{auto:r=!0}={}){const n=i=>{let a=Object.keys(i);const c=Bt(i);if(!c&&a.length>1&&!ge(i))return n(Ne(i));if(kt(i)){const o=c?i[me.PATH]:a[0],h=c?i[me.PATTERN]:i[o];if(!R(h))throw new Error(st(o));const d={keyId:oe(o),pattern:h};return r&&(d.searcher=fe(h,e)),d}let l={children:[],operator:a[0]};return a.forEach(o=>{const h=i[o];T(h)&&h.forEach(d=>{l.children.push(n(d))})}),l};return ge(s)||(s=Ne(s)),n(s)}function St(s,{ignoreFieldNorm:e=f.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:i,norm:a,score:c})=>{const l=i?i.weight:null;n*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(e?1:a))}),r.score=n})}function _t(s,e){const r=s.matches;e.matches=[],k(r)&&r.forEach(n=>{if(!k(n.indices)||!n.indices.length)return;const{indices:i,value:a}=n;let c={indices:i,value:a};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function It(s,e){e.score=s.score}function Lt(s,e,{includeMatches:r=f.includeMatches,includeScore:n=f.includeScore}={}){const i=[];return r&&i.push(_t),n&&i.push(It),s.map(a=>{const{idx:c}=a,l={item:e[c],refIndex:c};return i.length&&i.forEach(o=>{o(a,l)}),l})}class U{constructor(e,r={},n){this.options={...f,...r},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof pe))throw new Error(tt);this._myIndex=r||Me(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){k(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,i=this._docs.length;n<i;n+=1){const a=this._docs[n];e(a,n)&&(this.removeAt(n),n-=1,i-=1,r.push(a))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let o=R(e)?R(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return St(o,{ignoreFieldNorm:l}),a&&o.sort(c),ve(r)&&r>-1&&(o=o.slice(0,r)),Lt(o,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const r=fe(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:a,i:c,n:l})=>{if(!k(a))return;const{isMatch:o,score:h,indices:d}=r.searchIn(a);o&&i.push({item:a,idx:c,matches:[{score:h,value:a,norm:l,indices:d}]})}),i}_searchLogical(e){const r=Se(e,this.options),n=(l,o,h)=>{if(!l.children){const{keyId:m,searcher:x}=l,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(o,m),searcher:x});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const d=[];for(let m=0,x=l.children.length;m<x;m+=1){const g=l.children[m],A=n(g,o,h);if(A.length)d.push(...A);else if(l.operator===re.AND)return[]}return d},i=this._myIndex.records,a={},c=[];return i.forEach(({$:l,i:o})=>{if(k(l)){let h=n(r,l,o);h.length&&(a[o]||(a[o]={idx:o,item:l,matches:[]},c.push(a[o])),h.forEach(({matches:d})=>{a[o].matches.push(...d)}))}}),c}_searchObjectList(e){const r=fe(e,this.options),{keys:n,records:i}=this._myIndex,a=[];return i.forEach(({$:c,i:l})=>{if(!k(c))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:c[d],searcher:r}))}),o.length&&a.push({idx:l,item:c,matches:o})}),a}_findMatches({key:e,value:r,searcher:n}){if(!k(r))return[];let i=[];if(T(r))r.forEach(({v:a,i:c,n:l})=>{if(!k(a))return;const{isMatch:o,score:h,indices:d}=n.searchIn(a);o&&i.push({score:h,key:e,value:a,idx:c,norm:l,indices:d})});else{const{v:a,n:c}=r,{isMatch:l,score:o,indices:h}=n.searchIn(a);l&&i.push({score:o,key:e,value:a,norm:c,indices:h})}return i}}U.version="7.1.0";U.createIndex=Me;U.parseIndex=mt;U.config=f;U.parseQuery=Se;Dt(Mt);function Rt(s){switch(s){case"ready":case"done":return"default";case"review":case"active":case"queued":return"secondary";case"canceled":return"destructive";default:return"outline"}}function Tt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Vt(){const[s]=_e(),e=Ie(),r=Le(),[n,i]=j.useState([]),[a,c]=j.useState([]),[l,o]=j.useState(!0),[h,d]=j.useState(null),[m,x]=j.useState(s.get("status")||"active"),[g,A]=j.useState(s.get("priority")||"all"),[C,M]=j.useState(s.get("search")||""),[E,_]=j.useState(s.get("sortBy")||"created"),[b,L]=j.useState(s.get("order")||"desc"),[G,H]=j.useState(!1),F=j.useRef(null),S=[m!=="active",g!=="all",E!=="created",b!=="desc"].filter(Boolean).length,y=j.useCallback(u=>{const p=new URLSearchParams(s);Object.entries(u).forEach(([B,P])=>{P&&P!=="all"&&P!=="active"&&P!==""?p.set(B,P):p.delete(B)});const N=p.toString(),v=N?`?${N}`:"";e(`${r.pathname}${v}`)},[s,e,r.pathname]),z=j.useCallback(u=>{x(u),y({status:u==="active"?null:u})},[y]),O=j.useCallback(u=>{A(u),y({priority:u==="all"?null:u})},[y]),I=j.useCallback(u=>{M(u),y({search:u||null})},[y]),ne=j.useCallback(u=>{_(u),y({sortBy:u==="created"?null:u})},[y]),D=j.useCallback(()=>{const u=b==="asc"?"desc":"asc";L(u),y({order:u==="desc"?null:u})},[b,y]),$=j.useCallback(u=>{if(u.key==="s"||u.key==="S"){const p=document.activeElement;p?.tagName==="INPUT"||p?.tagName==="TEXTAREA"||p?.getAttribute("contenteditable")==="true"||(u.preventDefault(),F.current?.focus())}},[]);j.useEffect(()=>(document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$)}),[$]);const Q=j.useMemo(()=>{const u={keys:[{name:"intent",weight:.4},{name:"id",weight:.3},{name:"author.name",weight:.2},{name:"metadata.tags",weight:.1}],threshold:.3,includeScore:!0};return new U(n,u)},[n]);return j.useEffect(()=>{async function u(){try{o(!0);const N=await(await fetch(`${ze}/api/v1/proposals`)).json();N.success?(i(N.data),c(N.data)):d(N.error?.message||"Failed to fetch proposals")}catch(p){d(p instanceof Error?p.message:"Unknown error")}finally{o(!1)}}u()},[]),j.useEffect(()=>{let u=n;if(m==="active"?u=u.filter(p=>["draft","proposed","in-review","approved","code-complete"].includes(p.status)):m==="approved"?u=u.filter(p=>["approved","code-complete"].includes(p.status)):m!=="all"&&(u=u.filter(p=>p.status===m)),g!=="all"&&(u=u.filter(p=>p.metadata.priority===g)),C.trim()){const p=Q.search(C),N=new Set(p.map(v=>v.item.id));u=u.filter(v=>N.has(v.id))}u=u.sort((p,N)=>{let v,B;switch(E){case"created":{v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime();break}case"updated":{v=new Date(p.metadata.updatedAt).getTime(),B=new Date(N.metadata.updatedAt).getTime();break}case"status":{v=p.status,B=N.status;break}case"priority":{const P={critical:4,high:3,medium:2,low:1};v=P[p.metadata.priority]||0,B=P[N.metadata.priority]||0;break}case"intent":{v=(p.title||p.intent||"").toLowerCase(),B=(N.title||N.intent||"").toLowerCase();break}default:v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime()}return b==="asc"?v<B?-1:v>B?1:0:v>B?-1:v<B?1:0}),c(u)},[n,m,g,C,E,b,Q]),l?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx("div",{className:"space-y-4",children:[...Array(3)].map((u,p)=>t.jsx(J,{children:t.jsx(Ve,{children:t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4 animate-pulse"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]}),t.jsx("div",{className:"h-6 bg-muted rounded w-20 animate-pulse"})]})})},p))})]}):h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(Re,{ref:F,placeholder:"Search tasks...",value:C,onChange:u=>I(u.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>I(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Te,{children:t.jsx(Oe,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>H(!G),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(Ae,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),S>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:S}),G?t.jsx($e,{className:"h-4 w-4 ml-1"}):t.jsx(Pe,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[m!=="active"&&t.jsxs("button",{onClick:()=>z("active"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[m,t.jsx(X,{className:"h-3 w-3"})]}),g!=="all"&&t.jsxs("button",{onClick:()=>O("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[g," priority",t.jsx(X,{className:"h-3 w-3"})]}),(E!=="created"||b!=="desc")&&t.jsxs("button",{onClick:()=>{ne("created"),L("desc"),y({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[E," ",b==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[a.length," result",a.length!==1?"s":""]})]}),G&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(ie,{value:m,onValueChange:z,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by status"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"active",children:"Active (Default)"}),t.jsx(w,{value:"all",children:"All statuses"}),t.jsx(w,{value:"draft",children:"Draft"}),t.jsx(w,{value:"proposed",children:"Proposed"}),t.jsx(w,{value:"in-review",children:"In Review"}),t.jsx(w,{value:"approved",children:"Approved"}),t.jsx(w,{value:"code-complete",children:"Code Complete"}),t.jsx(w,{value:"merged",children:"Merged"}),t.jsx(w,{value:"rejected",children:"Rejected"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(ie,{value:g,onValueChange:O,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by priority"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"all",children:"All priorities"}),t.jsx(w,{value:"low",children:"Low"}),t.jsx(w,{value:"medium",children:"Medium"}),t.jsx(w,{value:"high",children:"High"}),t.jsx(w,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(ie,{value:E,onValueChange:u=>ne(u),children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{})}),t.jsxs(ue,{children:[t.jsx(w,{value:"created",children:"Created Date"}),t.jsx(w,{value:"updated",children:"Updated Date"}),t.jsx(w,{value:"status",children:"Status"}),t.jsx(w,{value:"priority",children:"Priority"}),t.jsx(w,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(V,{variant:"outline",onClick:D,className:"w-full justify-between bg-background",children:b==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(Ye,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(He,{className:"h-4 w-4"})]})})]})]}),S>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>{z("active"),O("all"),I("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),a.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ae,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(V,{variant:"outline",className:"mt-4",onClick:()=>{z("active"),O("all"),I("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ke,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),t.jsx(V,{asChild:!0,className:"mt-4",children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsx("div",{className:"space-y-4",children:a.map(u=>t.jsx(Y,{to:`/proposals/${u.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(We,{className:"text-base leading-tight",children:u.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[u.metadata.priority&&t.jsx(q,{variant:Tt(u.metadata.priority),className:"text-xs",children:u.metadata.priority}),t.jsx(q,{variant:Rt(u.status),className:"text-xs",children:u.status})]})]}),u.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[u.content.split(`
|
|
17
17
|
`).slice(0,2).join(" ").substring(0,150),u.content.length>150?"...":""]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"text-xs text-muted-foreground",children:[u.id," • by ",u.author.name," • ",new Date(u.metadata.createdAt).toLocaleDateString()]}),t.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[u.planSteps.length>0&&t.jsxs("span",{children:[u.planSteps.length," step",u.planSteps.length!==1?"s":""]}),u.evidence.length>0&&t.jsxs("span",{children:[u.evidence.length," evidence"]}),u.metadata.tags&&u.metadata.tags.length>0&&t.jsxs("span",{children:[u.metadata.tags.length," tag",u.metadata.tags.length!==1?"s":""]})]})]}),u.metadata.tags&&u.metadata.tags.length>0&&t.jsxs("div",{className:"flex gap-1 mt-2",children:[u.metadata.tags.slice(0,3).map(p=>t.jsx(q,{variant:"outline",className:"text-xs",children:p},p)),u.metadata.tags.length>3&&t.jsxs(q,{variant:"outline",className:"text-xs",children:["+",u.metadata.tags.length-3]})]})]})})})})},u.id))})]})}export{Vt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as oe,r as t,j as e,D as pe,b as ge,d as ve,f as je,J as le,S as is,B as R,am as os,n as Ee,a as $e,A as ae,w as ye,h as W,i as B,k as $,l as U,m as G,ah as Ve,x as me,ao as ca,ap as da,aq as ua,ar as be,as as Fe,at as _e,au as ma,av as Bs,aw as ha,ax as xa,e as fa,I as We,an as Xe,X as cs,C as $s,F as we,ay as Ze,az as pa,aA as ga,aB as va,aa as ja,ab as ya,v as ba,ac as wa,af as Je,g as ds,W as us,aC as Na}from"./index-
|
|
1
|
+
import{c as oe,r as t,j as e,D as pe,b as ge,d as ve,f as je,J as le,S as is,B as R,am as os,n as Ee,a as $e,A as ae,w as ye,h as W,i as B,k as $,l as U,m as G,ah as Ve,x as me,ao as ca,ap as da,aq as ua,ar as be,as as Fe,at as _e,au as ma,av as Bs,aw as ha,ax as xa,e as fa,I as We,an as Xe,X as cs,C as $s,F as we,ay as Ze,az as pa,aA as ga,aB as va,aa as ja,ab as ya,v as ba,ac as wa,af as Je,g as ds,W as us,aC as Na}from"./index-CCs6x1Au.js";import{C as Ye,b as ms,a as Qe,c as _a,d as Sa}from"./card-By4vbQ_f.js";import{L as C}from"./label-BUv8Ltyw.js";import{B as Me}from"./badge-2ZOe5ynf.js";import{c as Ca}from"./clipboard-B9ndUJKl.js";import{R as Us}from"./registry-ANRa5WBi.js";import{D as es}from"./download-DHIAgGlY.js";import{C as zs}from"./chevron-left-CJfNRqcH.js";import{C as ka}from"./calendar-tNgwmWmG.js";import{T as Pa}from"./tag-EEDDoCc_.js";import{P as hs}from"./plus-D0SUNNMH.js";import{S as Ea}from"./search-DFtqbVgP.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as j,a as v,r as n,A as d,j as e,B as h,L as g,a8 as y}from"./index-
|
|
1
|
+
import{u as j,a as v,r as n,A as d,j as e,B as h,L as g,a8 as y}from"./index-CCs6x1Au.js";import{C as m,a as x,b as N,c as C}from"./card-By4vbQ_f.js";import{M as w}from"./markdown-editor-BP8Xkecg.js";import{A as S}from"./arrow-left-DkoECaEJ.js";import{C as b}from"./circle-check-big-Dw4YJZos.js";function B(){const u=j(),{toast:t}=v(),[i,a]=n.useState(""),[f,r]=n.useState(!0),[o,l]=n.useState(!1);n.useEffect(()=>{fetch(`${d}/api/v1/context/role`).then(s=>s.json()).then(s=>{s.success&&a(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load role definition",variant:"destructive"}),r(!1)})},[t]);const p=async()=>{l(!0);try{const c=await(await fetch(`${d}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,metadata:{}})})).json();if(c.success)t({title:"Success",description:"Role definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/role");else throw new Error(c.error||"Failed to save context")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{l(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Role Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define your role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:p,disabled:o,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(N,{children:e.jsx(C,{children:"Role Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:i,onChange:s=>a(s||""),placeholder:`Write your role definition in markdown...
|
|
2
2
|
|
|
3
3
|
## Your Role
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N,r as t,A as v,j as e,J as C,F as g,B as a,L as c,R as d,M as w,aC as y,az as b}from"./index-
|
|
1
|
+
import{a as N,r as t,A as v,j as e,J as C,F as g,B as a,L as c,R as d,M as w,aC as y,az as b}from"./index-CCs6x1Au.js";import{C as i,a as r,b as E}from"./card-By4vbQ_f.js";import{c as R}from"./clipboard-B9ndUJKl.js";function F(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await R(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Role Definition"}),e.jsx("p",{className:"text-muted-foreground",children:"The Coconut's role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{F as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as f,r,A as p,j as e,a7 as F,B as l,I as c,W as L}from"./index-
|
|
1
|
+
import{c as f,r,A as p,j as e,a7 as F,B as l,I as c,W as L}from"./index-CCs6x1Au.js";import{C as T,b as I,a as z}from"./card-By4vbQ_f.js";import{L as n}from"./label-BUv8Ltyw.js";import{B as _}from"./badge-2ZOe5ynf.js";import{P as D}from"./plus-D0SUNNMH.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Qe,al as Xe,r as m,j as e,B as u,J,bh as pe,U as q,V as ge,W as fe,Y as V,Z as Y,_ as G,$ as K,a0 as Z,a1 as Q,a2 as X,L as ve,p as ee,ai as je,bi as es,C as ss,P as ts,v as se,D as Ne,b as be,d as ye,f as we,g as Se,I as te,h as as,i as rs,k as ns,l as is,m as ls,aa as Ce,ab as ke,ac as Ae,ad as De,ae as Ie,aj as Te,w as ds,ah as cs,a6 as Fe,A as j}from"./index-C4LGSoHO.js";import{C as O,a as ae,c as re,b as Pe}from"./card-CjY6k9qN.js";import{B as F}from"./badge-D6QJCkgl.js";import{L as v}from"./label-DGhQh35t.js";import{S as os}from"./switch-B6px80Oh.js";import{T as ms,a as us,b as ne,c as ie}from"./tabs-BHSWuVOa.js";import{R as hs}from"./refresh-cw-ucF4I6xx.js";import{P as $e}from"./plus-BCs8PAn6.js";import{P as Me}from"./play-C3zkOZiK.js";import{P as xs}from"./pause-B7dyLcuH.js";import{C as ps}from"./clock-E0FNqZih.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],gs=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Je=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Je(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},vs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ee),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},js=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Fs(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,T]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,$]=m.useState(null),[Oe,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Ze=>Ze.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Ue=(s,t)=>{if(!t&&R.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ye=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ge=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ke=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(M(!1),$(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(hs,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(O,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(O,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx($e,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(O,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(O,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(ve,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(re,{className:"text-lg truncate",children:s.name})}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(ve,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(xs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ps,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:fs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:vs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(je,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(es,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(ss,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=ze.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ts,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(Ne,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(be,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(ye,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(we,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Se,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(ms,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(us,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(as,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(rs,{id:"job-model",className:"h-11",children:e.jsx(ns,{placeholder:"Select a model"})}),e.jsx(is,{children:ce.map(s=>e.jsx(ls,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available Agents"}),e.jsx(Ie,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(je,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available MCP Servers"}),e.jsx(Ie,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ds,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
|
|
1
|
+
import{a as Qe,al as Xe,r as m,j as e,B as u,J,bh as pe,U as q,V as ge,W as fe,Y as V,Z as Y,_ as G,$ as K,a0 as Z,a1 as Q,a2 as X,L as ve,p as ee,ai as je,bi as es,C as ss,P as ts,v as se,D as Ne,b as be,d as ye,f as we,g as Se,I as te,h as as,i as rs,k as ns,l as is,m as ls,aa as Ce,ab as ke,ac as Ae,ad as De,ae as Ie,aj as Te,w as ds,ah as cs,a6 as Fe,A as j}from"./index-CCs6x1Au.js";import{C as O,a as ae,c as re,b as Pe}from"./card-By4vbQ_f.js";import{B as F}from"./badge-2ZOe5ynf.js";import{L as v}from"./label-BUv8Ltyw.js";import{S as os}from"./switch-WtOd8h5Z.js";import{T as ms,a as us,b as ne,c as ie}from"./tabs-D93ZjKR7.js";import{R as hs}from"./refresh-cw-C-yGwsHL.js";import{P as $e}from"./plus-D0SUNNMH.js";import{P as Me}from"./play-BHUpJCX1.js";import{P as xs}from"./pause-B0clczfE.js";import{C as ps}from"./clock-CDTi2Cen.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],gs=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Je=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Je(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},vs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ee),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},js=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Fs(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,T]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,$]=m.useState(null),[Oe,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Ze=>Ze.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Ue=(s,t)=>{if(!t&&R.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ye=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ge=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ke=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(M(!1),$(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(hs,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(O,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(O,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx($e,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(O,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(O,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(ve,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(re,{className:"text-lg truncate",children:s.name})}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(ve,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(xs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ps,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:fs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:vs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(je,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(es,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(ss,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=ze.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ts,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(Ne,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(be,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(ye,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(we,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Se,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(ms,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(us,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(as,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(rs,{id:"job-model",className:"h-11",children:e.jsx(ns,{placeholder:"Select a model"})}),e.jsx(is,{children:ce.map(s=>e.jsx(ls,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available Agents"}),e.jsx(Ie,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(je,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available MCP Servers"}),e.jsx(Ie,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ds,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
|
|
2
2
|
Example: Focus on performance optimizations`:`Example:
|
|
3
3
|
Run the following command and append the output to .nut/context/knowledge/runs.md:
|
|
4
4
|
pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:gs.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(cs,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>qe(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(ie,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(os,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Fe,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(Ne,{open:Oe,onOpenChange:s=>{M(s),s||$(null)},children:e.jsxs(be,{className:"max-w-3xl",children:[e.jsxs(ye,{children:[e.jsxs(we,{children:["Run history — ",g?.name]}),e.jsxs(Se,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Je(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Fe,{children:e.jsx(u,{variant:"outline",onClick:()=>M(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:_e,children:"OK"})]})]})})]})}export{Fs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as t,I as x,B as d,E as j,X as N}from"./index-
|
|
1
|
+
import{r as h,j as t,I as x,B as d,E as j,X as N}from"./index-CCs6x1Au.js";import{P as v}from"./plus-D0SUNNMH.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(v,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(j,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as t,I as d,B as m,X as x}from"./index-
|
|
1
|
+
import{r as p,j as t,I as d,B as m,X as x}from"./index-CCs6x1Au.js";import{B as f}from"./badge-2ZOe5ynf.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
|