@lovelybunch/api 1.0.71-alpha.5 → 1.0.71-alpha.7

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.
Files changed (88) hide show
  1. package/dist/routes/api/v1/resources/generate/route.js +6 -0
  2. package/dist/routes/api/v1/resources/generate-audio/route.js +6 -0
  3. package/dist/routes/api/v1/resources/generate-video/index.d.ts +3 -0
  4. package/dist/routes/api/v1/resources/generate-video/index.js +5 -0
  5. package/dist/routes/api/v1/resources/generate-video/route.d.ts +19 -0
  6. package/dist/routes/api/v1/resources/generate-video/route.js +241 -0
  7. package/dist/routes/api/v1/resources/index.js +2 -0
  8. package/dist/routes/api/v1/resources/route.d.ts +4 -0
  9. package/dist/routes/api/v1/resources/route.js +8 -4
  10. package/package.json +4 -4
  11. package/static/assets/{AgentDetailPage-B3CFO9Vg.js → AgentDetailPage-Opv1vviq.js} +1 -1
  12. package/static/assets/{AgentEditPage-Cc8k9uYb.js → AgentEditPage-uLCBQAKt.js} +1 -1
  13. package/static/assets/{AgentsPage-CcRVHD2p.js → AgentsPage-CbwDfB0S.js} +1 -1
  14. package/static/assets/{AgentsSettingsPage-BMphtJ6C.js → AgentsSettingsPage-wqr9YnHr.js} +1 -1
  15. package/static/assets/{ApiKeysSettingsPage-BLlmALn1.js → ApiKeysSettingsPage-16htmPFV.js} +1 -1
  16. package/static/assets/{ArchitectureEditPage-B8YrHerA.js → ArchitectureEditPage-Dvfb4b-o.js} +1 -1
  17. package/static/assets/{ArchitecturePage-fIoEV_ow.js → ArchitecturePage-CzD1Oize.js} +1 -1
  18. package/static/assets/{AuthSettingsPage-CICO_5eb.js → AuthSettingsPage-BP2zlNfC.js} +1 -1
  19. package/static/assets/{CallbackPage-6lJyGru9.js → CallbackPage-DEnicyfd.js} +1 -1
  20. package/static/assets/{CodePage-gGhNXTQn.js → CodePage-wBG-_Rs8.js} +1 -1
  21. package/static/assets/{CollapsibleSection-CkCVMSBD.js → CollapsibleSection-DSatk0YZ.js} +1 -1
  22. package/static/assets/{DashboardPage-qkyq1COW.js → DashboardPage-DmXHKAfY.js} +1 -1
  23. package/static/assets/{GitPage-Dj9uMiQV.js → GitPage-C-ZudM8s.js} +1 -1
  24. package/static/assets/{GitSettingsPage--hjPt4zu.js → GitSettingsPage-DtvqZDAp.js} +1 -1
  25. package/static/assets/{IdentityPage-DzqrsAU2.js → IdentityPage-WwVp_vBZ.js} +1 -1
  26. package/static/assets/{ImplementationStepsEditor-GxhD-g8y.js → ImplementationStepsEditor-BKDdpUue.js} +1 -1
  27. package/static/assets/{IntegrationsSettingsPage-DR_v_Fbo.js → IntegrationsSettingsPage-Vhh08Jjd.js} +1 -1
  28. package/static/assets/{KnowledgeDetailPage-BEHrLcNg.js → KnowledgeDetailPage-B8jlP-NF.js} +1 -1
  29. package/static/assets/{KnowledgeEditPage-CETMgdZf.js → KnowledgeEditPage-BppjRoZZ.js} +1 -1
  30. package/static/assets/{KnowledgePage-Dz2YIqdH.js → KnowledgePage-CasWW1a1.js} +1 -1
  31. package/static/assets/{LoginPage-DSxl4xGK.js → LoginPage-DkguuNDQ.js} +1 -1
  32. package/static/assets/{McpSettingsPage-CLDzqlt3.js → McpSettingsPage-CZfBLxIj.js} +1 -1
  33. package/static/assets/{NewAgentPage-DlEnBUUY.js → NewAgentPage-BbANsmjr.js} +1 -1
  34. package/static/assets/{NewKnowledgePage-CI8D1NRB.js → NewKnowledgePage-BE18vt4E.js} +1 -1
  35. package/static/assets/{NewProposalPage-B1hVwad9.js → NewProposalPage-BxKHijwN.js} +1 -1
  36. package/static/assets/{ProjectEditPage-t_oD7x6f.js → ProjectEditPage-uwwvFm_Y.js} +1 -1
  37. package/static/assets/{ProjectPage-CMez4KRO.js → ProjectPage-DJvT8Jwp.js} +1 -1
  38. package/static/assets/{PromptsSettingsPage-DXvS4JX8.js → PromptsSettingsPage-CWdSTKxS.js} +1 -1
  39. package/static/assets/{ProposalDetailPage-Cbld0UYO.js → ProposalDetailPage-CDyosWFj.js} +1 -1
  40. package/static/assets/{ProposalEditPage-Dujm4G1-.js → ProposalEditPage-D9b0X_vT.js} +1 -1
  41. package/static/assets/{ProposalsPage-0L4kWC5Y.js → ProposalsPage-DdfAejqH.js} +1 -1
  42. package/static/assets/ResourcesPage-DCJ-ob0_.js +71 -0
  43. package/static/assets/{RulesSettingsPage-D6qjkKbl.js → RulesSettingsPage-CrIrk78x.js} +1 -1
  44. package/static/assets/{SchedulePage-CgnTsib0.js → SchedulePage-Dq53Q6fB.js} +1 -1
  45. package/static/assets/{TagInput-DJMwLVTn.js → TagInput-DtQl22K7.js} +1 -1
  46. package/static/assets/{TerminalPage-EYVbapc9.js → TerminalPage-BcclpXIS.js} +1 -1
  47. package/static/assets/{TerminalSessionPage-CQCLFjOR.js → TerminalSessionPage-Tecaum7f.js} +1 -1
  48. package/static/assets/{UserPreferencesPage-KAsCdvFQ.js → UserPreferencesPage-B4jeTbEe.js} +1 -1
  49. package/static/assets/{UserSettingsPage-DclI2Mhd.js → UserSettingsPage-D_fTJGEB.js} +1 -1
  50. package/static/assets/{UtilitiesPage-BKdyva6y.js → UtilitiesPage-BVSfnezp.js} +1 -1
  51. package/static/assets/{alert-p2sQnjrU.js → alert-DT5dIcQb.js} +1 -1
  52. package/static/assets/{arrow-down-DGeJDsho.js → arrow-down-D5JMw0I7.js} +1 -1
  53. package/static/assets/{arrow-left-BRSAC1N6.js → arrow-left-BbL7bi4b.js} +1 -1
  54. package/static/assets/{arrow-up-C5ecpR5U.js → arrow-up-D5zdohVZ.js} +1 -1
  55. package/static/assets/{badge-DaM4gF82.js → badge-CxMDR-vz.js} +1 -1
  56. package/static/assets/{browser-modal-CyeEbzDK.js → browser-modal-DZprh22G.js} +1 -1
  57. package/static/assets/{calendar-CV2haPQ9.js → calendar-DjIpzqju.js} +1 -1
  58. package/static/assets/{card-B9ym6neB.js → card-Cq3qftln.js} +1 -1
  59. package/static/assets/{chevron-left-D8aMFTU2.js → chevron-left-8PdSXGp8.js} +1 -1
  60. package/static/assets/{circle-alert-C-piOZLm.js → circle-alert-CPeWHRYV.js} +1 -1
  61. package/static/assets/{circle-check-4zzXsmHH.js → circle-check-BsF5HxbR.js} +1 -1
  62. package/static/assets/{circle-check-big-AlE11jqb.js → circle-check-big-DViAc1A0.js} +1 -1
  63. package/static/assets/{circle-play-cWY3nlZW.js → circle-play-C0yQlVR9.js} +1 -1
  64. package/static/assets/{circle-x-D58MbKgZ.js → circle-x-CT_9xyVN.js} +1 -1
  65. package/static/assets/{clipboard-BFF6-pdC.js → clipboard-D-CHbLVc.js} +1 -1
  66. package/static/assets/{clock-B-uSJOTR.js → clock-D5nAa1In.js} +1 -1
  67. package/static/assets/{download-DrQn0jny.js → download-Bl3cP1zr.js} +1 -1
  68. package/static/assets/{eye-BcjteMts.js → eye-DgdIekU1.js} +1 -1
  69. package/static/assets/{folder-git-2-B_ezHf_E.js → folder-git-2-BD7LL99o.js} +1 -1
  70. package/static/assets/{index-B0JO3x3V.js → index-CKcm92Kn.js} +3 -3
  71. package/static/assets/index-D9b0oysW.css +2 -0
  72. package/static/assets/{label-BHOOQ99D.js → label-COUiN2Pd.js} +1 -1
  73. package/static/assets/{markdown-editor-B0i_LOAR.js → markdown-editor-Cln2Jo2-.js} +1 -1
  74. package/static/assets/{pause-DqQ7Twc6.js → pause-CupPWZ26.js} +1 -1
  75. package/static/assets/{play-Y2N8OVBu.js → play-sWUKmZEy.js} +1 -1
  76. package/static/assets/{plus-D737EJ5S.js → plus-DM62ve-p.js} +1 -1
  77. package/static/assets/{radio-group-nRRUTZ_w.js → radio-group-B6pYL4p4.js} +1 -1
  78. package/static/assets/{refresh-cw-uBnPtZwp.js → refresh-cw-ClU12bdt.js} +1 -1
  79. package/static/assets/{search-cntvIhnF.js → search-DHLiojAp.js} +1 -1
  80. package/static/assets/{switch-BYf9VEgx.js → switch-DC_em8xh.js} +1 -1
  81. package/static/assets/{tabs-BnsC3AY5.js → tabs-KzUqSzqd.js} +1 -1
  82. package/static/assets/{tag-C_HL28Xd.js → tag-cF4ktw0a.js} +1 -1
  83. package/static/assets/{terminal-preview-Qv4UvCJz.js → terminal-preview-D-pmjUNP.js} +1 -1
  84. package/static/assets/{use-terminal-5sW1t6SD.js → use-terminal-C1j4Pa5C.js} +1 -1
  85. package/static/assets/{zap-CrLPiVyl.js → zap-DGHMgsd8.js} +1 -1
  86. package/static/index.html +2 -2
  87. package/static/assets/ResourcesPage-5sZL01s_.js +0 -66
  88. package/static/assets/index-C8p-lTq9.css +0 -2
@@ -1 +1 @@
1
- import{H as w,r,A as y,j as e,n as C,g as b,B as n,az as P,ay as k,L as E,J as L,aA as z,av as B}from"./index-B0JO3x3V.js";import{C as c,a as i,b as p,c as D}from"./card-B9ym6neB.js";import{B as x}from"./badge-DaM4gF82.js";import{c as F}from"./clipboard-B9ndUJKl.js";function T(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await F(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{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 Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;return 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:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(k,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(E,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(p,{className:"pb-3",children:e.jsx(D,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(z,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(x,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(x,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(p,{}),e.jsx(i,{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{T as default};
1
+ import{H as w,r,A as y,j as e,n as C,g as b,B as n,az as P,ay as k,L as E,J as L,aA as z,av as B}from"./index-CKcm92Kn.js";import{C as c,a as i,b as p,c as D}from"./card-Cq3qftln.js";import{B as x}from"./badge-CxMDR-vz.js";import{c as F}from"./clipboard-B9ndUJKl.js";function T(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await F(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{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 Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;return 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:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(k,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(E,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(p,{className:"pb-3",children:e.jsx(D,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(z,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(x,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(x,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(p,{}),e.jsx(i,{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{T as default};
@@ -1 +1 @@
1
- import{j as e,a1 as p,B as r,J as h,ai as j,T as u,I as l,v as g,w as f,x as v,y as N,z as y}from"./index-B0JO3x3V.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-B9ym6neB.js";import{L as a}from"./label-BHOOQ99D.js";import{B as o}from"./badge-DaM4gF82.js";import{P as w}from"./plus-D737EJ5S.js";import{E as b}from"./eye-BcjteMts.js";import{D as C}from"./download-DrQn0jny.js";function E(){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{E as default};
1
+ import{j as e,a1 as p,B as r,J as h,ai as j,T as u,I as l,v as g,w as f,x as v,y as N,z as y}from"./index-CKcm92Kn.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-Cq3qftln.js";import{L as a}from"./label-COUiN2Pd.js";import{B as o}from"./badge-CxMDR-vz.js";import{P as w}from"./plus-DM62ve-p.js";import{E as b}from"./eye-DgdIekU1.js";import{D as C}from"./download-Bl3cP1zr.js";function E(){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{E as default};
@@ -1 +1 @@
1
- import{E as re,u as ne,r as l,H as le,j as e,B as n,L as h,J as ie,M as oe,N as ce,T as de,O as me,P as he,Q as xe,R as pe,U as ue,V as je,W as fe,Y as I,Z as F,k as ge,D as R,_ as B,a as z,b as H,d as V,e as J,v as ve,w as Ne,x as Ce,y as ye,z as c,$ as M,a0 as we,a1 as Se,A as g}from"./index-B0JO3x3V.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-B9ym6neB.js";import{B as p}from"./badge-DaM4gF82.js";import{L as q}from"./label-BHOOQ99D.js";import{A as S}from"./arrow-left-BRSAC1N6.js";import{C as De,a as Ae}from"./clipboard-BFF6-pdC.js";import{D as Pe}from"./download-DrQn0jny.js";import{C as ke}from"./calendar-CV2haPQ9.js";import{C as Ee}from"./clock-B-uSJOTR.js";function Q(r){switch(r){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function W(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function He(){const{id:r}=re(),Y=ne(),[s,v]=l.useState(null),[Z,b]=l.useState(!0),[N,D]=l.useState(null),[A,P]=l.useState(!1),[k,E]=l.useState(!1),[T,$]=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 t(){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(a){D(a instanceof Error?a.message:"Unknown error")}finally{b(!1)}}t()},[r]);const ee=async()=>{if(r){P(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"DELETE"})).json();a.success?Y("/proposals"):alert(a.error?.message||"Failed to delete proposal")}catch(t){alert(`Error deleting proposal: ${t instanceof Error?t.message:"Unknown error"}`)}finally{P(!1)}}},se=async()=>{if(!(!s||!r||f===s.status)){E(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).json();a.success?(v(a.data),y(!1)):alert(a.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{E(!1)}}},te=async()=>{if(!(!s||!r||!j.trim())){$(!0);try{const t={id:`comment-${Date.now()}`,text:j,author:"current-user",timestamp:new Date().toISOString()},a=[...s.metadata.comments||[],t],i=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:a})})).json();i.success?(v(i.data),C(""),w(!1)):alert(i.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},ae=()=>{if(!s)return;const t={...s,exportedAt:new Date().toISOString()},a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(a),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 t=`.nut/proposals/${s.id}.md`;try{await be(t),L(!0),O({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>L(!1),2e3)}catch(a){console.error("Failed to copy path:",a),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:"Proposal 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((t,a)=>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:a+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.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:t.status})})]})]},t.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((t,a)=>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:t.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(t.timestamp).toLocaleString()})]}),e.jsx(I,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:t.text})]},t.id||a))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Proposal 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 Coding 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(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Change Proposal Status"}),e.jsx(J,{children:"Update the status of this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"status",children:"Status"}),e.jsxs(ve,{value:f,onValueChange:t=>U(t),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(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:se,disabled:k||f===s?.status,children:k?"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(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Add Comment"}),e.jsx(J,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"comment",children:"Comment"}),e.jsx(we,{id:"comment",placeholder:"Enter your comment...",value:j,onChange:t=>C(t.target.value),rows:4})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>{w(!1),C("")},children:"Cancel"}),e.jsx(n,{onClick:te,disabled:T||!j.trim(),children:T?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:ae,children:[e.jsx(Pe,{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(ke,{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).toLocaleDateString()})]}),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).toLocaleDateString()})]}),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(t=>e.jsx(p,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{He as default};
1
+ import{E as re,u as ne,r as l,H as le,j as e,B as n,L as h,J as ie,M as oe,N as ce,T as de,O as me,P as he,Q as xe,R as pe,U as ue,V as je,W as fe,Y as I,Z as F,k as ge,D as R,_ as B,a as z,b as H,d as V,e as J,v as ve,w as Ne,x as Ce,y as ye,z as c,$ as M,a0 as we,a1 as Se,A as g}from"./index-CKcm92Kn.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-Cq3qftln.js";import{B as p}from"./badge-CxMDR-vz.js";import{L as q}from"./label-COUiN2Pd.js";import{A as S}from"./arrow-left-BbL7bi4b.js";import{C as De,a as Ae}from"./clipboard-D-CHbLVc.js";import{D as Pe}from"./download-Bl3cP1zr.js";import{C as ke}from"./calendar-DjIpzqju.js";import{C as Ee}from"./clock-D5nAa1In.js";function Q(r){switch(r){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function W(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function He(){const{id:r}=re(),Y=ne(),[s,v]=l.useState(null),[Z,b]=l.useState(!0),[N,D]=l.useState(null),[A,P]=l.useState(!1),[k,E]=l.useState(!1),[T,$]=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 t(){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(a){D(a instanceof Error?a.message:"Unknown error")}finally{b(!1)}}t()},[r]);const ee=async()=>{if(r){P(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"DELETE"})).json();a.success?Y("/proposals"):alert(a.error?.message||"Failed to delete proposal")}catch(t){alert(`Error deleting proposal: ${t instanceof Error?t.message:"Unknown error"}`)}finally{P(!1)}}},se=async()=>{if(!(!s||!r||f===s.status)){E(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).json();a.success?(v(a.data),y(!1)):alert(a.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{E(!1)}}},te=async()=>{if(!(!s||!r||!j.trim())){$(!0);try{const t={id:`comment-${Date.now()}`,text:j,author:"current-user",timestamp:new Date().toISOString()},a=[...s.metadata.comments||[],t],i=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:a})})).json();i.success?(v(i.data),C(""),w(!1)):alert(i.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},ae=()=>{if(!s)return;const t={...s,exportedAt:new Date().toISOString()},a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(a),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 t=`.nut/proposals/${s.id}.md`;try{await be(t),L(!0),O({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>L(!1),2e3)}catch(a){console.error("Failed to copy path:",a),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:"Proposal 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((t,a)=>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:a+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.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:t.status})})]})]},t.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((t,a)=>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:t.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(t.timestamp).toLocaleString()})]}),e.jsx(I,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:t.text})]},t.id||a))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Proposal 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 Coding 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(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Change Proposal Status"}),e.jsx(J,{children:"Update the status of this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"status",children:"Status"}),e.jsxs(ve,{value:f,onValueChange:t=>U(t),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(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:se,disabled:k||f===s?.status,children:k?"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(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Add Comment"}),e.jsx(J,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"comment",children:"Comment"}),e.jsx(we,{id:"comment",placeholder:"Enter your comment...",value:j,onChange:t=>C(t.target.value),rows:4})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>{w(!1),C("")},children:"Cancel"}),e.jsx(n,{onClick:te,disabled:T||!j.trim(),children:T?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:ae,children:[e.jsx(Pe,{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(ke,{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).toLocaleDateString()})]}),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).toLocaleDateString()})]}),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(t=>e.jsx(p,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{He as default};
@@ -1 +1 @@
1
- import{E as M,u as R,H as U,r as o,A as I,j as e,B as m,L as x,I as O,v as L,w as T,x as k,y as D,z as r,X as V,a2 as _}from"./index-B0JO3x3V.js";import{L as j}from"./label-BHOOQ99D.js";import{C as f,b as F,a as v,c as q,d as J}from"./card-B9ym6neB.js";import{M as K}from"./markdown-editor-B0i_LOAR.js";import{C as W}from"./CollapsibleSection-CkCVMSBD.js";import{I as X,L as G}from"./ImplementationStepsEditor-GxhD-g8y.js";import{T as Q}from"./TagInput-DJMwLVTn.js";import{A as N}from"./arrow-left-BRSAC1N6.js";import"./plus-D737EJ5S.js";import"./badge-DaM4gF82.js";function oe(){const{id:i}=M(),$=R(),{toast:y}=U(),[z,S]=o.useState(!0),[h,w]=o.useState(!1),[C,b]=o.useState(null),[n,d]=o.useState({intent:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[p,E]=o.useState([]),[P,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${I}/api/v1/proposals/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;d({intent: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"}))),A(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)}},H=async t=>{t.preventDefault(),w(!0);try{const s=p.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=P.map(l=>l.trim()).filter(l=>l.length>0),g={intent:n.intent,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},c=await fetch(`${I}/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{w(!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(F,{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"})]})})]})]}):C?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:C})]})})})]}):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:H,children:e.jsxs(f,{children:[e.jsxs(F,{children:[e.jsx(q,{children:"Proposal 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:"intent",children:"Intent *"}),e.jsx(O,{id:"intent",placeholder:"Brief description of what you want to change",value:n.intent,onChange:t=>d(s=>({...s,intent:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.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(L,{value:n.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(T,{children:e.jsx(k,{placeholder:"Select status"})}),e.jsxs(D,{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(W,{defaultOpen:!0,icon:e.jsx(G,{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(L,{value:n.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(T,{children:e.jsx(k,{placeholder:"Select priority"})}),e.jsxs(D,{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(X,{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(Q,{tags:P,onChange:A,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||!n.intent,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
+ import{E as M,u as R,H as U,r as o,A as I,j as e,B as m,L as x,I as O,v as L,w as T,x as k,y as D,z as r,X as V,a2 as _}from"./index-CKcm92Kn.js";import{L as j}from"./label-COUiN2Pd.js";import{C as f,b as F,a as v,c as q,d as J}from"./card-Cq3qftln.js";import{M as K}from"./markdown-editor-Cln2Jo2-.js";import{C as W}from"./CollapsibleSection-DSatk0YZ.js";import{I as X,L as G}from"./ImplementationStepsEditor-BKDdpUue.js";import{T as Q}from"./TagInput-DtQl22K7.js";import{A as N}from"./arrow-left-BbL7bi4b.js";import"./plus-DM62ve-p.js";import"./badge-CxMDR-vz.js";function oe(){const{id:i}=M(),$=R(),{toast:y}=U(),[z,S]=o.useState(!0),[h,w]=o.useState(!1),[C,b]=o.useState(null),[n,d]=o.useState({intent:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[p,E]=o.useState([]),[P,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${I}/api/v1/proposals/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;d({intent: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"}))),A(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)}},H=async t=>{t.preventDefault(),w(!0);try{const s=p.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=P.map(l=>l.trim()).filter(l=>l.length>0),g={intent:n.intent,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},c=await fetch(`${I}/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{w(!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(F,{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"})]})})]})]}):C?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:C})]})})})]}):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:H,children:e.jsxs(f,{children:[e.jsxs(F,{children:[e.jsx(q,{children:"Proposal 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:"intent",children:"Intent *"}),e.jsx(O,{id:"intent",placeholder:"Brief description of what you want to change",value:n.intent,onChange:t=>d(s=>({...s,intent:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.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(L,{value:n.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(T,{children:e.jsx(k,{placeholder:"Select status"})}),e.jsxs(D,{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(W,{defaultOpen:!0,icon:e.jsx(G,{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(L,{value:n.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(T,{children:e.jsx(k,{placeholder:"Select priority"})}),e.jsxs(D,{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(X,{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(Q,{tags:P,onChange:A,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||!n.intent,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,l as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Pe,p as Oe,q as $e,s as Te,v as ie,w as ae,x as ce,y as ue,z as w,G as Ke,A as ze}from"./index-B0JO3x3V.js";import{C as J,b as Ve,a as Z,c as We}from"./card-B9ym6neB.js";import{B as q}from"./badge-DaM4gF82.js";import{P as ee}from"./plus-D737EJ5S.js";import{S as Ue}from"./search-cntvIhnF.js";/**
1
+ import{c as xe,o as _e,u as Ie,l as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Pe,p as Oe,q as $e,s as Te,v as ie,w as ae,x as ce,y as ue,z as w,G as Ke,A as ze}from"./index-CKcm92Kn.js";import{C as J,b as Ve,a as Z,c as We}from"./card-Cq3qftln.js";import{B as q}from"./badge-CxMDR-vz.js";import{P as ee}from"./plus-DM62ve-p.js";import{S as Ue}from"./search-DHLiojAp.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,71 @@
1
+ import{c as re,r as n,j as e,D as fe,a as pe,b as ge,d as ve,n as te,S as ts,B as R,ah as ns,aj as Fe,H as Oe,A as se,a0 as je,v as U,w as H,x as J,y as Y,z as W,ac as Le,p as ue,ak as ia,al as oa,am as ca,an as be,ao as Re,ap as Ce,aq as da,ar as As,as as ua,at as ma,f as ha,I as Ke,ai as He,X as rs,C as Ls,g as _e,au as Je,av as xa,aw as fa,ax as pa,a5 as ga,a6 as va,s as ja,a7 as wa,aa as Be,e as ls,T as is,ay as ya}from"./index-CKcm92Kn.js";import{C as ze,b as os,a as Ue,c as Na,d as ba}from"./card-Cq3qftln.js";import{L as k}from"./label-COUiN2Pd.js";import{B as Ie}from"./badge-CxMDR-vz.js";import{c as _a}from"./clipboard-B9ndUJKl.js";import{R as Ks}from"./registry-ANRa5WBi.js";import{D as Ye}from"./download-Bl3cP1zr.js";import{C as Vs}from"./chevron-left-8PdSXGp8.js";import{C as Sa}from"./calendar-DjIpzqju.js";import{T as Ca}from"./tag-cF4ktw0a.js";import{P as cs}from"./plus-DM62ve-p.js";import{S as ka}from"./search-DHLiojAp.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Pa=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],ds=re("file-audio",Pa);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Ma=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],Qe=re("file-code",Ma);/**
12
+ * @license lucide-react v0.542.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ea=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],us=re("file-image",Ea);/**
17
+ * @license lucide-react v0.542.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Fa=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ms=re("file-json",Fa);/**
22
+ * @license lucide-react v0.542.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ia=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z",key:"1tzo1f"}]],hs=re("file-play",Ia);/**
27
+ * @license lucide-react v0.542.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Ra=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],xs=re("file-spreadsheet",Ra);/**
32
+ * @license lucide-react v0.542.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ta=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],fs=re("file-type",Ta);/**
37
+ * @license lucide-react v0.542.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Da=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Ga=re("hard-drive",Da);/**
42
+ * @license lucide-react v0.542.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Aa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Se=re("image",Aa);/**
47
+ * @license lucide-react v0.542.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const La=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ps=re("maximize-2",La);/**
52
+ * @license lucide-react v0.542.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Ka=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],xe=re("music",Ka);/**
57
+ * @license lucide-react v0.542.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const Va=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],gs=re("presentation",Va);/**
62
+ * @license lucide-react v0.542.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Oa=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Wa=re("upload",Oa);/**
67
+ * @license lucide-react v0.542.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const $a=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ve=re("video",$a);async function Os(r){const c=r.startsWith("http")?r:`${Ks}${r}`,t=await fetch(c,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!t.ok)throw new Error(`Failed to fetch registry resource: ${t.status}`);return t.json()}async function Ba(){return Os("/registry/resources/root.json")}async function vs(r){return Os(r)}function Ae(r){if(r)return r.startsWith("http")?r:`${Ks}${r}`}function za({open:r,onOpenChange:c,onSelectExample:t,onCustomizeInAssistant:p}){const[h,d]=n.useState([]),[u,g]=n.useState(!1),[j,C]=n.useState(null),[w,m]=n.useState(null),[x,N]=n.useState(null),[S,b]=n.useState(!1),[y,_]=n.useState(null);n.useEffect(()=>{r&&(g(!0),C(null),m(null),N(null),_(null),Ba().then(f=>{d(f.elements??[]),f.elements&&f.elements.length>0&&A(f.elements[0])}).catch(f=>{console.error("Failed to load registry resources",f),d([]),C("Failed to load examples from registry")}).finally(()=>g(!1)))},[r]);const A=async f=>{m(f.id),_(null),N(null),b(!0);try{const M=await vs(f.endpoint);N(M)}catch(M){console.error("Failed to load resource detail",M),_("Unable to load details for this example")}finally{b(!1)}},P=()=>{x?.prompt&&(t(x.prompt),c(!1))},E=()=>{x?.prompt&&p&&(p(x.prompt),c(!1))},L=async f=>{if(w===f.id&&x?.prompt){t(x.prompt),c(!1);return}try{const M=await vs(f.endpoint);M.prompt&&(t(M.prompt),c(!1))}catch(M){console.error("Failed to load resource detail",M)}};return e.jsx(fe,{open:r,onOpenChange:c,children:e.jsxs(pe,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ge,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ve,{className:"text-base sm:text-lg",children:"Example Prompts"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden relative",children:[e.jsx("div",{className:"h-[40%] min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:S?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(te,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):y?e.jsx("p",{className:"text-sm text-muted-foreground",children:y}):x?e.jsx("img",{src:Ae(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example"})}),e.jsxs("div",{className:"flex-1 min-h-0 border-t flex flex-col",children:[u?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(te,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):h.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(ts,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:h.map(f=>e.jsxs("button",{onClick:()=>A(f),onDoubleClick:()=>L(f),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${w===f.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[f.thumbnailUrl&&e.jsx("img",{src:Ae(f.thumbnailUrl),alt:"",className:"w-12 h-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:f.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:f.description})]})]},f.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(R,{onClick:P,disabled:!x?.prompt||S,className:"w-full",children:[e.jsx(ns,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),x&&p&&e.jsx("div",{className:"absolute bottom-16 right-3 z-10",children:e.jsxs(R,{size:"sm",variant:"secondary",onClick:E,children:[e.jsx(Fe,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize"]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsxs("div",{className:"w-[35%] border-r flex flex-col",children:[u?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(te,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):h.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(ts,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:h.map(f=>e.jsxs("button",{onClick:()=>A(f),onDoubleClick:()=>L(f),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${w===f.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[f.thumbnailUrl&&e.jsx("img",{src:Ae(f.thumbnailUrl),alt:"",className:"w-16 h-16 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:f.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:f.description}),f.tags&&f.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[f.tags.slice(0,3).map(M=>e.jsx(Ie,{variant:"secondary",className:"text-[10px]",children:M},M)),f.tags.length>3&&e.jsxs(Ie,{variant:"outline",className:"text-[10px]",children:["+",f.tags.length-3]})]})]})]},f.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(R,{onClick:P,disabled:!x?.prompt||S,className:"w-full",children:[e.jsx(ns,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:S?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(te,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):y?e.jsx("p",{className:"text-sm text-muted-foreground",children:y}):x?e.jsx("img",{src:Ae(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example to preview"})}),x&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2 font-medium",children:"Full Prompt:"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:x.prompt})]}),x&&p&&e.jsx("div",{className:"absolute bottom-4 right-4 z-10",children:e.jsxs(R,{size:"sm",variant:"secondary",onClick:E,children:[e.jsx(Fe,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})})]})]})]})})}const js="image-generator-settings";function ws(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const qe={"nano-banana-pro":{id:"nano-banana-pro",label:"Nano Banana Pro",replicateId:"google/nano-banana-pro",features:{resolution:!0,outputQuality:!1,goFast:!1,safetyTolerance:!1,matchInputImage:!1},resolutionOptions:[{value:"1K",label:"1K"},{value:"2K",label:"2K"},{value:"4K",label:"4K"}],defaults:{resolution:"2K"}},"flux-2-dev":{id:"flux-2-dev",label:"FLUX.2 Dev",replicateId:"black-forest-labs/flux-2-dev",features:{resolution:!1,outputQuality:!0,goFast:!0,safetyTolerance:!1,matchInputImage:!0},defaults:{outputQuality:80,goFast:!0}},"flux-2-pro":{id:"flux-2-pro",label:"FLUX.2 Pro",replicateId:"black-forest-labs/flux-2-pro",features:{resolution:!0,outputQuality:!0,goFast:!1,safetyTolerance:!0,matchInputImage:!1},resolutionOptions:[{value:"0.5 MP",label:"0.5 MP"},{value:"1 MP",label:"1 MP"},{value:"2 MP",label:"2 MP"},{value:"4 MP",label:"4 MP"}],defaults:{resolution:"2 MP",outputQuality:80,safetyTolerance:2}}},ys=Object.values(qe).map(r=>({value:r.id,label:r.label})),Ns=[{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"3:2",label:"3:2"},{value:"3:4",label:"3:4"},{value:"4:3",label:"4:3"},{value:"4:5",label:"4:5"},{value:"5:4",label:"5:4"},{value:"9:16",label:"9:16"},{value:"16:9",label:"16:9"},{value:"21:9",label:"21:9"}],Ua={value:"match_input_image",label:"Match Input"},bs=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],_s=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],Ss=[{value:"1",label:"1 (Strict)"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6 (Relaxed)"}];function Ha({open:r,onOpenChange:c,onSave:t,onCustomizeInAssistant:p}){const d=(()=>{if(typeof window>"u")return null;try{const a=localStorage.getItem(js);return a?JSON.parse(a):null}catch{return null}})(),[u,g]=n.useState(""),[j,C]=n.useState(d?.model||"nano-banana-pro"),[w,m]=n.useState(d?.aspectRatio||"3:4"),[x,N]=n.useState(d?.resolution||"2K"),[S,b]=n.useState(d?.outputFormat||"png"),[y,_]=n.useState(d?.outputQuality||"80"),[A,P]=n.useState(d?.goFast??!0),[E,L]=n.useState(d?.safetyTolerance||"2"),[f,M]=n.useState(null),[T,$]=n.useState(!1),[F,D]=n.useState(!1),[v,z]=n.useState([]),[K,Q]=n.useState([]),[q,Z]=n.useState(!0),[V,ee]=n.useState(!1),[o,X]=n.useState(0),l=n.useRef(null),{toast:G}=Oe();n.useEffect(()=>{const a={model:j,aspectRatio:w,resolution:x,outputFormat:S,outputQuality:y,goFast:A,safetyTolerance:E};localStorage.setItem(js,JSON.stringify(a))},[j,w,x,S,y,A,E]),n.useEffect(()=>(T?(X(0),l.current=setInterval(()=>{X(a=>a+1)},1e3)):l.current&&(clearInterval(l.current),l.current=null),()=>{l.current&&clearInterval(l.current)}),[T]);const B=qe[j],ne=B.features.matchInputImage?[Ua,...Ns]:Ns,me=B.resolutionOptions||[];n.useEffect(()=>{const a=qe[j];a.defaults.resolution&&a.features.resolution&&N(a.defaults.resolution),a.defaults.outputQuality!==void 0&&_(String(a.defaults.outputQuality)),a.defaults.goFast!==void 0&&P(a.defaults.goFast),a.defaults.safetyTolerance!==void 0&&L(String(a.defaults.safetyTolerance)),m(O=>O==="match_input_image"&&!a.features.matchInputImage?"3:4":O)},[j]),n.useEffect(()=>{r&&we()},[r]);const we=async()=>{try{const O=await(await fetch(`${se}/api/v1/resources`)).json();if(O.success){const he=(O.data||[]).filter(le=>{const Ne=le.type==="image/jpeg"||le.name.toLowerCase().endsWith(".jpg")||le.name.toLowerCase().endsWith(".jpeg"),Me=le.type==="image/png"||le.name.toLowerCase().endsWith(".png");return(Ne||Me)&&le.thumbnailPath});z(he)}}catch(a){console.error("Failed to fetch image resources:",a)}},Pe=async()=>{if(!u.trim()){G({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}$(!0),M(null);try{const a=q||K.length===0?[]:[...K],O=await fetch(`${se}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u,model:j,dimensions:w,resolution:B.features.resolution?x:void 0,output_format:S,output_quality:B.features.outputQuality?parseInt(y):void 0,go_fast:B.features.goFast?A:void 0,safety_tolerance:B.features.safetyTolerance?parseInt(E):void 0,image_input:a})});if(O.status===504||O.status===502||O.status===408)throw new Error("Request timed out. The image model may be warming up - please try again.");const he=O.headers.get("content-type");if(!he||!he.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const le=await O.json();if(!O.ok||!le.success){const Ne=le.error?.message||"Failed to generate image",Me=le.error?.code==="MISSING_API_TOKEN";throw new Error(Me?"Replicate API token not configured. Please add it in Settings → Integrations.":Ne)}M(le.data.imageUrl),G({title:"Image generated",description:"Your image has been generated successfully"})}catch(a){console.error("Generation error:",a);const O=a instanceof Error?a.message:"Failed to generate image.",he=O.toLowerCase().includes("timeout")||O.toLowerCase().includes("timed out");G({title:he?"Generation timed out":"Generation failed",description:O,variant:"destructive"})}finally{$(!1)}};n.useEffect(()=>{const a=O=>{r&&(O.metaKey||O.ctrlKey)&&O.key==="Enter"&&(O.preventDefault(),u.trim()&&!T&&!F&&Pe())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r,u,T,F]);const Te=async()=>{if(f){D(!0);try{await t(f,{prompt:u,model:j}),g(""),C("nano-banana-pro"),m("3:4"),N("2K"),b("png"),_("80"),P(!0),L("2"),M(null),Z(!0),Q([]),c(!1)}catch(a){G({title:"Save failed",description:a instanceof Error?a.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{D(!1)}}},$e=()=>{!T&&!F&&c(!1)},De=()=>{Z(!0),Q([])},ie=a=>{q&&Z(!1),K.includes(a)?(Q(K.filter(O=>O!==a)),K.length===1&&Z(!0)):K.length<3?Q([...K,a]):G({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},ye=a=>{g(a)},Ge=a=>{p&&(ee(!1),c(!1),p(`"${a}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(fe,{open:r,onOpenChange:$e,children:[e.jsxs(pe,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ge,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ve,{className:"text-base sm:text-lg",children:"Generate Image"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(te,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):f?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:f,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Se,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(R,{size:"sm",onClick:()=>ee(!0),className:"mt-2",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-2 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:De,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${q?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),v.map(a=>{const O=K.includes(a.id);return e.jsx("button",{onClick:()=>ie(a.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${O?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${se}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[45vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(je,{id:"prompt-mobile",placeholder:"Describe the image...",value:u,onChange:a=>g(a.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"model-mobile",className:"text-xs",children:"Model"}),e.jsxs(U,{value:j,onValueChange:a=>C(a),children:[e.jsx(H,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:ys.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"outputFormat-mobile",className:"text-xs",children:"Format"}),e.jsxs(U,{value:S,onValueChange:b,children:[e.jsx(H,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:bs.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),B.features.goFast&&e.jsx("div",{className:"space-y-1 flex flex-col justify-end",children:e.jsxs("div",{className:"flex items-center space-x-2 h-8",children:[e.jsx(Le,{id:"goFast-mobile",checked:A,onCheckedChange:a=>P(a===!0)}),e.jsx(k,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),B.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(U,{value:E,onValueChange:L,children:[e.jsx(H,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Ss.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[B.features.resolution&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(k,{htmlFor:"resolution-mobile",className:"text-xs",children:"Resolution"}),e.jsxs(U,{value:x,onValueChange:N,children:[e.jsx(H,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:me.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(k,{htmlFor:"aspectRatio-mobile",className:"text-xs",children:"Ratio"}),e.jsxs(U,{value:w,onValueChange:m,children:[e.jsx(H,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:ne.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),B.features.outputQuality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(k,{htmlFor:"outputQuality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(U,{value:y,onValueChange:_,children:[e.jsx(H,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:_s.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:Pe,disabled:!u.trim()||T||F,className:"flex-1 h-9",size:"sm",children:T?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ws,{}),e.jsxs("span",{children:[o,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:Te,disabled:!f||T||F,variant:"outline",className:"flex-1 h-9",size:"sm",children:F?e.jsx(te,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"prompt",children:"Prompt"}),e.jsx(je,{id:"prompt",placeholder:"Describe the image you want to generate...",value:u,onChange:a=>g(a.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"model",children:"Model"}),e.jsxs(U,{value:j,onValueChange:a=>C(a),children:[e.jsx(H,{id:"model",children:e.jsx(J,{})}),e.jsx(Y,{children:ys.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(U,{value:w,onValueChange:m,children:[e.jsx(H,{id:"aspectRatio",children:e.jsx(J,{})}),e.jsx(Y,{children:ne.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),B.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(U,{value:x,onValueChange:N,children:[e.jsx(H,{id:"resolution",children:e.jsx(J,{})}),e.jsx(Y,{children:me.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(U,{value:S,onValueChange:b,children:[e.jsx(H,{id:"outputFormat",children:e.jsx(J,{})}),e.jsx(Y,{children:bs.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),B.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(U,{value:y,onValueChange:_,children:[e.jsx(H,{id:"outputQuality",children:e.jsx(J,{})}),e.jsx(Y,{children:_s.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),B.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Le,{id:"goFast",checked:A,onCheckedChange:a=>P(a===!0)}),e.jsx(k,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),B.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(U,{value:E,onValueChange:L,children:[e.jsx(H,{id:"safetyTolerance",children:e.jsx(J,{})}),e.jsx(Y,{children:Ss.map(a=>e.jsx(W,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:Pe,disabled:!u.trim()||T||F,className:"w-full",children:T?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ws,{}),e.jsxs("span",{children:["Generating... ",o,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(R,{onClick:Te,disabled:!f||T||F,variant:"outline",className:"w-full",children:F?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(te,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):f?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:f,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Se,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(R,{onClick:()=>ee(!0),className:"mt-2",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-4 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:De,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${q?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),v.map(a=>{const O=K.includes(a.id);return e.jsx("button",{onClick:()=>ie(a.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${O?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${se}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})})]})]})]}),e.jsx(za,{open:V,onOpenChange:ee,onSelectExample:ye,onCustomizeInAssistant:p?Ge:void 0})]})}var Ws=["PageUp","PageDown"],$s=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Bs={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ke="Slider",[Xe,Ja,Ya]=ca(ke),[zs,kt]=oa(ke,[Ya]),[Qa,We]=zs(ke),Us=n.forwardRef((r,c)=>{const{name:t,min:p=0,max:h=100,step:d=1,orientation:u="horizontal",disabled:g=!1,minStepsBetweenThumbs:j=0,defaultValue:C=[p],value:w,onValueChange:m=()=>{},onValueCommit:x=()=>{},inverted:N=!1,form:S,...b}=r,y=n.useRef(new Set),_=n.useRef(0),P=u==="horizontal"?qa:Xa,[E=[],L]=ia({prop:w,defaultProp:C,onChange:D=>{[...y.current][_.current]?.focus(),m(D)}}),f=n.useRef(E);function M(D){const v=tt(E,D);F(D,v)}function T(D){F(D,_.current)}function $(){const D=f.current[_.current];E[_.current]!==D&&x(E)}function F(D,v,{commit:z}={commit:!1}){const K=it(d),Q=ot(Math.round((D-p)/d)*d+p,K),q=As(Q,[p,h]);L((Z=[])=>{const V=st(Z,q,v);if(lt(V,j*d)){_.current=V.indexOf(q);const ee=String(V)!==String(Z);return ee&&z&&x(V),ee?V:Z}else return Z})}return e.jsx(Qa,{scope:r.__scopeSlider,name:t,disabled:g,min:p,max:h,valueIndexToChangeRef:_,thumbs:y.current,values:E,orientation:u,form:S,children:e.jsx(Xe.Provider,{scope:r.__scopeSlider,children:e.jsx(Xe.Slot,{scope:r.__scopeSlider,children:e.jsx(P,{"aria-disabled":g,"data-disabled":g?"":void 0,...b,ref:c,onPointerDown:be(b.onPointerDown,()=>{g||(f.current=E)}),min:p,max:h,inverted:N,onSlideStart:g?void 0:M,onSlideMove:g?void 0:T,onSlideEnd:g?void 0:$,onHomeKeyDown:()=>!g&&F(p,0,{commit:!0}),onEndKeyDown:()=>!g&&F(h,E.length-1,{commit:!0}),onStepKeyDown:({event:D,direction:v})=>{if(!g){const Q=Ws.includes(D.key)||D.shiftKey&&$s.includes(D.key)?10:1,q=_.current,Z=E[q],V=d*Q*v;F(Z+V,q,{commit:!0})}}})})})})});Us.displayName=ke;var[Hs,Js]=zs(ke,{startEdge:"left",endEdge:"right",size:"width",direction:1}),qa=n.forwardRef((r,c)=>{const{min:t,max:p,dir:h,inverted:d,onSlideStart:u,onSlideMove:g,onSlideEnd:j,onStepKeyDown:C,...w}=r,[m,x]=n.useState(null),N=Ce(c,P=>x(P)),S=n.useRef(void 0),b=da(h),y=b==="ltr",_=y&&!d||!y&&d;function A(P){const E=S.current||m.getBoundingClientRect(),L=[0,E.width],M=ss(L,_?[t,p]:[p,t]);return S.current=E,M(P-E.left)}return e.jsx(Hs,{scope:r.__scopeSlider,startEdge:_?"left":"right",endEdge:_?"right":"left",direction:_?1:-1,size:"width",children:e.jsx(Ys,{dir:b,"data-orientation":"horizontal",...w,ref:N,style:{...w.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:P=>{const E=A(P.clientX);u?.(E)},onSlideMove:P=>{const E=A(P.clientX);g?.(E)},onSlideEnd:()=>{S.current=void 0,j?.()},onStepKeyDown:P=>{const L=Bs[_?"from-left":"from-right"].includes(P.key);C?.({event:P,direction:L?-1:1})}})})}),Xa=n.forwardRef((r,c)=>{const{min:t,max:p,inverted:h,onSlideStart:d,onSlideMove:u,onSlideEnd:g,onStepKeyDown:j,...C}=r,w=n.useRef(null),m=Ce(c,w),x=n.useRef(void 0),N=!h;function S(b){const y=x.current||w.current.getBoundingClientRect(),_=[0,y.height],P=ss(_,N?[p,t]:[t,p]);return x.current=y,P(b-y.top)}return e.jsx(Hs,{scope:r.__scopeSlider,startEdge:N?"bottom":"top",endEdge:N?"top":"bottom",size:"height",direction:N?1:-1,children:e.jsx(Ys,{"data-orientation":"vertical",...C,ref:m,style:{...C.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const y=S(b.clientY);d?.(y)},onSlideMove:b=>{const y=S(b.clientY);u?.(y)},onSlideEnd:()=>{x.current=void 0,g?.()},onStepKeyDown:b=>{const _=Bs[N?"from-bottom":"from-top"].includes(b.key);j?.({event:b,direction:_?-1:1})}})})}),Ys=n.forwardRef((r,c)=>{const{__scopeSlider:t,onSlideStart:p,onSlideMove:h,onSlideEnd:d,onHomeKeyDown:u,onEndKeyDown:g,onStepKeyDown:j,...C}=r,w=We(ke,t);return e.jsx(Re.span,{...C,ref:c,onKeyDown:be(r.onKeyDown,m=>{m.key==="Home"?(u(m),m.preventDefault()):m.key==="End"?(g(m),m.preventDefault()):Ws.concat($s).includes(m.key)&&(j(m),m.preventDefault())}),onPointerDown:be(r.onPointerDown,m=>{const x=m.target;x.setPointerCapture(m.pointerId),m.preventDefault(),w.thumbs.has(x)?x.focus():p(m)}),onPointerMove:be(r.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&h(m)}),onPointerUp:be(r.onPointerUp,m=>{const x=m.target;x.hasPointerCapture(m.pointerId)&&(x.releasePointerCapture(m.pointerId),d(m))})})}),Qs="SliderTrack",qs=n.forwardRef((r,c)=>{const{__scopeSlider:t,...p}=r,h=We(Qs,t);return e.jsx(Re.span,{"data-disabled":h.disabled?"":void 0,"data-orientation":h.orientation,...p,ref:c})});qs.displayName=Qs;var Ze="SliderRange",Xs=n.forwardRef((r,c)=>{const{__scopeSlider:t,...p}=r,h=We(Ze,t),d=Js(Ze,t),u=n.useRef(null),g=Ce(c,u),j=h.values.length,C=h.values.map(x=>sa(x,h.min,h.max)),w=j>1?Math.min(...C):0,m=100-Math.max(...C);return e.jsx(Re.span,{"data-orientation":h.orientation,"data-disabled":h.disabled?"":void 0,...p,ref:g,style:{...r.style,[d.startEdge]:w+"%",[d.endEdge]:m+"%"}})});Xs.displayName=Ze;var es="SliderThumb",Zs=n.forwardRef((r,c)=>{const t=Ja(r.__scopeSlider),[p,h]=n.useState(null),d=Ce(c,g=>h(g)),u=n.useMemo(()=>p?t().findIndex(g=>g.ref.current===p):-1,[t,p]);return e.jsx(Za,{...r,ref:d,index:u})}),Za=n.forwardRef((r,c)=>{const{__scopeSlider:t,index:p,name:h,...d}=r,u=We(es,t),g=Js(es,t),[j,C]=n.useState(null),w=Ce(c,A=>C(A)),m=j?u.form||!!j.closest("form"):!0,x=ua(j),N=u.values[p],S=N===void 0?0:sa(N,u.min,u.max),b=at(p,u.values.length),y=x?.[g.size],_=y?nt(y,S,g.direction):0;return n.useEffect(()=>{if(j)return u.thumbs.add(j),()=>{u.thumbs.delete(j)}},[j,u.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[g.startEdge]:`calc(${S}% + ${_}px)`},children:[e.jsx(Xe.ItemSlot,{scope:r.__scopeSlider,children:e.jsx(Re.span,{role:"slider","aria-label":r["aria-label"]||b,"aria-valuemin":u.min,"aria-valuenow":N,"aria-valuemax":u.max,"aria-orientation":u.orientation,"data-orientation":u.orientation,"data-disabled":u.disabled?"":void 0,tabIndex:u.disabled?void 0:0,...d,ref:w,style:N===void 0?{display:"none"}:r.style,onFocus:be(r.onFocus,()=>{u.valueIndexToChangeRef.current=p})})}),m&&e.jsx(ea,{name:h??(u.name?u.name+(u.values.length>1?"[]":""):void 0),form:u.form,value:N},p)]})});Zs.displayName=es;var et="RadioBubbleInput",ea=n.forwardRef(({__scopeSlider:r,value:c,...t},p)=>{const h=n.useRef(null),d=Ce(h,p),u=ma(c);return n.useEffect(()=>{const g=h.current;if(!g)return;const j=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(j,"value").set;if(u!==c&&w){const m=new Event("input",{bubbles:!0});w.call(g,c),g.dispatchEvent(m)}},[u,c]),e.jsx(Re.input,{style:{display:"none"},...t,ref:d,defaultValue:c})});ea.displayName=et;function st(r=[],c,t){const p=[...r];return p[t]=c,p.sort((h,d)=>h-d)}function sa(r,c,t){const d=100/(t-c)*(r-c);return As(d,[0,100])}function at(r,c){return c>2?`Value ${r+1} of ${c}`:c===2?["Minimum","Maximum"][r]:void 0}function tt(r,c){if(r.length===1)return 0;const t=r.map(h=>Math.abs(h-c)),p=Math.min(...t);return t.indexOf(p)}function nt(r,c,t){const p=r/2,d=ss([0,50],[0,p]);return(p-d(c)*t)*t}function rt(r){return r.slice(0,-1).map((c,t)=>r[t+1]-c)}function lt(r,c){if(c>0){const t=rt(r);return Math.min(...t)>=c}return!0}function ss(r,c){return t=>{if(r[0]===r[1]||c[0]===c[1])return c[0];const p=(c[1]-c[0])/(r[1]-r[0]);return c[0]+p*(t-r[0])}}function it(r){return(String(r).split(".")[1]||"").length}function ot(r,c){const t=Math.pow(10,c);return Math.round(r*t)/t}var aa=Us,ct=qs,dt=Xs,ut=Zs;const Ee=n.forwardRef(({className:r,...c},t)=>e.jsxs(aa,{ref:t,className:ha("relative flex w-full touch-none select-none items-center",r),...c,children:[e.jsx(ct,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(dt,{className:"absolute h-full bg-primary"})}),e.jsx(ut,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Ee.displayName=aa.displayName;const Cs="audio-generator-settings";function ks(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Ps=["English_Trustworth_Man","English_Aussie_Bloke","English_CalmWoman","English_UpsetGirl","English_Gentle-voiced_man","English_Whispering_girl","English_Diligent_Man","English_Graceful_Lady","English_ReservedYoungMan","English_PlayfulGirl","English_ManWithDeepVoice","English_MaturePartner","English_FriendlyPerson","English_MatureBoss","English_Debator","English_LovelyGirl","English_Steadymentor","English_Deep-VoicedGentleman","English_Wiselady","English_CaptivatingStoryteller","English_DecentYoungMan","English_SentimentalLady","English_ImposingManner","English_SadTeen","English_PassionateWarrior","English_WiseScholar","English_Soft-spokenGirl","English_SereneWoman","English_ConfidentWoman","English_PatientMan","English_Comedian","English_BossyLeader","English_Strong-WilledBoy","English_StressedLady","English_AssertiveQueen","English_AnimeCharacter","English_Jovialman","English_WhimsicalGirl","English_Kind-heartedGirl","Chinese (Mandarin)_Reliable_Executive","Chinese (Mandarin)_News_Anchor","Chinese (Mandarin)_Unrestrained_Young_Man","Chinese (Mandarin)_Mature_Woman","Arrogant_Miss","Robot_Armor","Chinese (Mandarin)_Kind-hearted_Antie","Chinese (Mandarin)_Refreshing_Young_Man","Chinese (Mandarin)_HK_Flight_Attendant","Chinese (Mandarin)_Humorous_Elder","Chinese (Mandarin)_Gentleman","Chinese (Mandarin)_Warm_Bestie","Chinese (Mandarin)_Stubborn_Friend","Chinese (Mandarin)_Sweet_Lady","Chinese (Mandarin)_Southern_Young_Man","Chinese (Mandarin)_Wise_Women","Chinese (Mandarin)_Gentle_Youth","Chinese (Mandarin)_Warm_Girl","Chinese (Mandarin)_Male_Announcer","Chinese (Mandarin)_Kind-hearted_Elder","Chinese (Mandarin)_Cute_Spirit","Chinese (Mandarin)_Radio_Host","Chinese (Mandarin)_Lyrical_Voice","Chinese (Mandarin)_Straightforward_Boy","Chinese (Mandarin)_Sincere_Adult","Chinese (Mandarin)_Gentle_Senior","Chinese (Mandarin)_Crisp_Girl","Chinese (Mandarin)_Pure-hearted_Boy","Chinese (Mandarin)_Soft_Girl","Chinese (Mandarin)_IntellectualGirl","Chinese (Mandarin)_Warm_HeartedGirl","Chinese (Mandarin)_Laid_BackGirl","Chinese (Mandarin)_ExplorativeGirl","Chinese (Mandarin)_Warm-HeartedAunt","Chinese (Mandarin)_BashfulGirl","Japanese_IntellectualSenior","Japanese_DecisivePrincess","Japanese_LoyalKnight","Japanese_DominantMan","Japanese_SeriousCommander","Japanese_ColdQueen","Japanese_DependableWoman","Japanese_GentleButler","Japanese_KindLady","Japanese_CalmLady","Japanese_OptimisticYouth","Japanese_GenerousIzakayaOwner","Japanese_SportyStudent","Japanese_InnocentBoy","Japanese_GracefulMaiden","Cantonese_ProfessionalHost(F)","Cantonese_GentleLady","Cantonese_ProfessionalHost(M)","Cantonese_PlayfulMan","Cantonese_CuteGirl","Cantonese_KindWoman","Korean_SweetGirl","Korean_CheerfulBoyfriend","Korean_EnchantingSister","Korean_ShyGirl","Korean_ReliableSister","Korean_StrictBoss","Korean_SassyGirl","Korean_ChildhoodFriendGirl","Korean_PlayboyCharmer","Korean_ElegantPrincess","Korean_BraveFemaleWarrior","Korean_BraveYouth","Korean_CalmLady","Korean_EnthusiasticTeen","Korean_SoothingLady","Korean_IntellectualSenior","Korean_LonelyWarrior","Korean_MatureLady","Korean_InnocentBoy","Korean_CharmingSister","Korean_AthleticStudent","Korean_BraveAdventurer","Korean_CalmGentleman","Korean_WiseElf","Korean_CheerfulCoolJunior","Korean_DecisiveQueen","Korean_ColdYoungMan","Korean_MysteriousGirl","Korean_QuirkyGirl","Korean_ConsiderateSenior","Korean_CheerfulLittleSister","Korean_DominantMan","Korean_AirheadedGirl","Korean_ReliableYouth","Korean_FriendlyBigSister","Korean_GentleBoss","Korean_ColdGirl","Korean_HaughtyLady","Korean_CharmingElderSister","Korean_IntellectualMan","Korean_CaringWoman","Korean_WiseTeacher","Korean_ConfidentBoss","Korean_AthleticGirl","Korean_PossessiveMan","Korean_GentleWoman","Korean_CockyGuy","Korean_ThoughtfulWoman","Korean_OptimisticYouth","Spanish_SereneWoman","Spanish_MaturePartner","Spanish_CaptivatingStoryteller","Spanish_Narrator","Spanish_WiseScholar","Spanish_Kind-heartedGirl","Spanish_DeterminedManager","Spanish_BossyLeader","Spanish_ReservedYoungMan","Spanish_ConfidentWoman","Spanish_ThoughtfulMan","Spanish_Strong-WilledBoy","Spanish_SophisticatedLady","Spanish_RationalMan","Spanish_AnimeCharacter","Spanish_Deep-tonedMan","Spanish_Fussyhostess","Spanish_SincereTeen","Spanish_FrankLady","Spanish_Comedian","Spanish_Debator","Spanish_ToughBoss","Spanish_Wiselady","Spanish_Steadymentor","Spanish_Jovialman","Spanish_SantaClaus","Spanish_Rudolph","Spanish_Intonategirl","Spanish_Arnold","Spanish_Ghost","Spanish_HumorousElder","Spanish_EnergeticBoy","Spanish_WhimsicalGirl","Spanish_StrictBoss","Spanish_ReliableMan","Spanish_SereneElder","Spanish_AngryMan","Spanish_AssertiveQueen","Spanish_CaringGirlfriend","Spanish_PowerfulSoldier","Spanish_PassionateWarrior","Spanish_ChattyGirl","Spanish_RomanticHusband","Spanish_CompellingGirl","Spanish_PowerfulVeteran","Spanish_SensibleManager","Spanish_ThoughtfulLady","Portuguese_SentimentalLady","Portuguese_BossyLeader","Portuguese_Wiselady","Portuguese_Strong-WilledBoy","Portuguese_Deep-VoicedGentleman","Portuguese_UpsetGirl","Portuguese_PassionateWarrior","Portuguese_AnimeCharacter","Portuguese_ConfidentWoman","Portuguese_AngryMan","Portuguese_CaptivatingStoryteller","Portuguese_Godfather","Portuguese_ReservedYoungMan","Portuguese_SmartYoungGirl","Portuguese_Kind-heartedGirl","Portuguese_Pompouslady","Portuguese_Grinch","Portuguese_Debator","Portuguese_SweetGirl","Portuguese_AttractiveGirl","Portuguese_ThoughtfulMan","Portuguese_PlayfulGirl","Portuguese_GorgeousLady","Portuguese_LovelyLady","Portuguese_SereneWoman","Portuguese_SadTeen","Portuguese_MaturePartner","Portuguese_Comedian","Portuguese_NaughtySchoolgirl","Portuguese_Narrator","Portuguese_ToughBoss","Portuguese_Fussyhostess","Portuguese_Dramatist","Portuguese_Steadymentor","Portuguese_Jovialman","Portuguese_CharmingQueen","Portuguese_SantaClaus","Portuguese_Rudolph","Portuguese_Arnold","Portuguese_CharmingSanta","Portuguese_CharmingLady","Portuguese_Ghost","Portuguese_HumorousElder","Portuguese_CalmLeader","Portuguese_GentleTeacher","Portuguese_EnergeticBoy","Portuguese_ReliableMan","Portuguese_SereneElder","Portuguese_GrimReaper","Portuguese_AssertiveQueen","Portuguese_WhimsicalGirl","Portuguese_StressedLady","Portuguese_FriendlyNeighbor","Portuguese_CaringGirlfriend","Portuguese_PowerfulSoldier","Portuguese_FascinatingBoy","Portuguese_RomanticHusband","Portuguese_StrictBoss","Portuguese_InspiringLady","Portuguese_PlayfulSpirit","Portuguese_ElegantGirl","Portuguese_CompellingGirl","Portuguese_PowerfulVeteran","Portuguese_SensibleManager","Portuguese_ThoughtfulLady","Portuguese_TheatricalActor","Portuguese_FragileBoy","Portuguese_ChattyGirl","Portuguese_Conscientiousinstructor","Portuguese_RationalMan","Portuguese_WiseScholar","Portuguese_FrankLady","Portuguese_DeterminedManager","French_Male_Speech_New","French_Female_News Anchor","French_CasualMan","French_MovieLeadFemale","French_FemaleAnchor","French_MaleNarrator","Indonesian_SweetGirl","Indonesian_ReservedYoungMan","Indonesian_CharmingGirl","Indonesian_CalmWoman","Indonesian_ConfidentWoman","Indonesian_CaringMan","Indonesian_BossyLeader","Indonesian_DeterminedBoy","Indonesian_GentleGirl","German_FriendlyMan","German_SweetLady","German_PlayfulMan","Russian_HandsomeChildhoodFriend","Russian_BrightHeroine","Russian_AmbitiousWoman","Russian_ReliableMan","Russian_CrazyQueen","Russian_PessimisticGirl","Russian_AttractiveGuy","Russian_Bad-temperedBoy","Italian_BraveHeroine","Italian_Narrator","Italian_WanderingSorcerer","Italian_DiligentLeader","Dutch_kindhearted_girl","Dutch_bossy_leader","Vietnamese_kindhearted_girl","Arabic_CalmWoman","Arabic_FriendlyGuy","Turkish_CalmWoman","Turkish_Trustworthyman","Ukrainian_CalmWoman"],Ms=[{value:"auto",label:"Auto"},{value:"happy",label:"Happy"},{value:"sad",label:"Sad"},{value:"angry",label:"Angry"},{value:"fearful",label:"Fearful"},{value:"disgusted",label:"Disgusted"},{value:"surprised",label:"Surprised"},{value:"neutral",label:"Neutral"}],Es=[{value:"English",label:"English"},{value:"Chinese",label:"Chinese"},{value:"Japanese",label:"Japanese"},{value:"Korean",label:"Korean"},{value:"Spanish",label:"Spanish"},{value:"Portuguese",label:"Portuguese"},{value:"French",label:"French"},{value:"Indonesian",label:"Indonesian"},{value:"German",label:"German"},{value:"Russian",label:"Russian"},{value:"Italian",label:"Italian"},{value:"Dutch",label:"Dutch"},{value:"Vietnamese",label:"Vietnamese"},{value:"Arabic",label:"Arabic"},{value:"Turkish",label:"Turkish"},{value:"Ukrainian",label:"Ukrainian"},{value:"Cantonese",label:"Cantonese"}],Fs=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function mt({open:r,onOpenChange:c,onSave:t}){const h=(()=>{if(typeof window>"u")return null;try{const o=localStorage.getItem(Cs);return o?JSON.parse(o):null}catch{return null}})(),[d,u]=n.useState(""),[g,j]=n.useState(h?.voiceId||"English_Trustworth_Man"),[C,w]=n.useState(h?.useCustomVoice||!1),[m,x]=n.useState(h?.customVoiceId||""),[N,S]=n.useState(h?.speed??1),[b,y]=n.useState(h?.pitch??0),[_,A]=n.useState(h?.emotion||"auto"),[P,E]=n.useState(h?.languageBoost||"English"),[L,f]=n.useState(h?.audioFormat||"mp3"),[M,T]=n.useState(null),[$,F]=n.useState(!1),[D,v]=n.useState(!1),[z,K]=n.useState(0),Q=n.useRef(null),{toast:q}=Oe();n.useEffect(()=>{const o={voiceId:g,useCustomVoice:C,customVoiceId:m,speed:N,pitch:b,emotion:_,languageBoost:P,audioFormat:L};localStorage.setItem(Cs,JSON.stringify(o))},[g,C,m,N,b,_,P,L]),n.useEffect(()=>($?(K(0),Q.current=setInterval(()=>{K(o=>o+1)},1e3)):Q.current&&(clearInterval(Q.current),Q.current=null),()=>{Q.current&&clearInterval(Q.current)}),[$]);const Z=async()=>{if(!d.trim()){q({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}F(!0),T(null);try{const o=C?m:g,X=await fetch(`${se}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:d,voice_id:o,speed:N,pitch:b,emotion:_,language_boost:P,audio_format:L})});if(X.status===504||X.status===502||X.status===408)throw new Error("Request timed out. The audio model may be warming up - please try again.");const l=X.headers.get("content-type");if(!l||!l.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const G=await X.json();if(!X.ok||!G.success){const B=G.error?.message||"Failed to generate audio",ne=G.error?.code==="MISSING_API_TOKEN";throw new Error(ne?"Replicate API token not configured. Please add it in Settings → Integrations.":B)}T(G.data.audioUrl),q({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(o){console.error("Generation error:",o);const X=o instanceof Error?o.message:"Failed to generate audio.",l=X.toLowerCase().includes("timeout")||X.toLowerCase().includes("timed out");q({title:l?"Generation timed out":"Generation failed",description:X,variant:"destructive"})}finally{F(!1)}};n.useEffect(()=>{const o=X=>{r&&(X.metaKey||X.ctrlKey)&&X.key==="Enter"&&(X.preventDefault(),d.trim()&&!$&&!D&&Z())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r,d,$,D]);const V=async()=>{if(M){v(!0);try{await t(M),u(""),j("English_Trustworth_Man"),w(!1),x(""),S(1),y(0),A("auto"),E("English"),f("mp3"),T(null),c(!1)}catch(o){q({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{v(!1)}}},ee=()=>{!$&&!D&&c(!1)};return e.jsx(fe,{open:r,onOpenChange:ee,children:e.jsxs(pe,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ge,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ve,{className:"text-base sm:text-lg",children:"Generate Audio"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:$?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(te,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):M?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(xe,{className:"h-16 w-16 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-4 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:M,controls:!0,className:"w-full max-w-[90%]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(xe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[55vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"text-mobile",className:"text-xs",children:"Text"}),e.jsx(je,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>u(o.target.value),rows:3,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Voice"}),e.jsxs(U,{value:C?"__custom__":g,onValueChange:o=>{o==="__custom__"?w(!0):(w(!1),j(o))},children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsxs(Y,{className:"max-h-60",children:[Ps.map(o=>e.jsx(W,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(W,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),C&&e.jsx(Ke,{placeholder:"Enter custom voice ID",value:m,onChange:o=>x(o.target.value),className:"h-8 text-xs mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-xs",children:["Speed: ",N.toFixed(1),"x"]}),e.jsx(Ee,{value:[N],onValueChange:([o])=>S(o),min:.5,max:2,step:.1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(k,{className:"text-xs",children:["Pitch: ",b>0?"+":"",b]}),e.jsx(Ee,{value:[b],onValueChange:([o])=>y(o),min:-12,max:12,step:1,className:"w-full"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Emotion"}),e.jsxs(U,{value:_,onValueChange:A,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Ms.map(o=>e.jsx(W,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Language"}),e.jsxs(U,{value:P,onValueChange:E,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Es.map(o=>e.jsx(W,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Format"}),e.jsxs(U,{value:L,onValueChange:f,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Fs.map(o=>e.jsx(W,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:Z,disabled:!d.trim()||$||D,className:"flex-1 h-9",size:"sm",children:$?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ks,{}),e.jsxs("span",{children:[z,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:V,disabled:!M||$||D,variant:"outline",className:"flex-1 h-9",size:"sm",children:D?e.jsx(te,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[30%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"text",children:"Text"}),e.jsx(je,{id:"text",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>u(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Voice"}),e.jsxs(U,{value:C?"__custom__":g,onValueChange:o=>{o==="__custom__"?w(!0):(w(!1),j(o))},children:[e.jsx(H,{children:e.jsx(J,{})}),e.jsxs(Y,{className:"max-h-80",children:[Ps.map(o=>e.jsx(W,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(W,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),C&&e.jsx(Ke,{placeholder:"Enter custom voice ID",value:m,onChange:o=>x(o.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{children:["Speed: ",N.toFixed(1),"x"]}),e.jsx(Ee,{value:[N],onValueChange:([o])=>S(o),min:.5,max:2,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.5x"}),e.jsx("span",{children:"2x"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{children:["Pitch: ",b>0?"+":"",b]}),e.jsx(Ee,{value:[b],onValueChange:([o])=>y(o),min:-12,max:12,step:1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"-12"}),e.jsx("span",{children:"+12"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Emotion"}),e.jsxs(U,{value:_,onValueChange:A,children:[e.jsx(H,{children:e.jsx(J,{})}),e.jsx(Y,{children:Ms.map(o=>e.jsx(W,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Language Boost"}),e.jsxs(U,{value:P,onValueChange:E,children:[e.jsx(H,{children:e.jsx(J,{})}),e.jsx(Y,{children:Es.map(o=>e.jsx(W,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Audio Format"}),e.jsxs(U,{value:L,onValueChange:f,children:[e.jsx(H,{children:e.jsx(J,{})}),e.jsx(Y,{children:Fs.map(o=>e.jsx(W,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:Z,disabled:!d.trim()||$||D,className:"w-full",children:$?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ks,{}),e.jsxs("span",{children:["Generating... ",z,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(R,{onClick:V,disabled:!M||$||D,variant:"outline",className:"w-full",children:D?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:$?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(te,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):M?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(xe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:M,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(xe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated audio will appear here"})]})})})]})]})})}const Is="video-generator-settings";function Rs(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Ts=[{value:"5",label:"5 seconds"},{value:"8",label:"8 seconds"},{value:"10",label:"10 seconds"}],Ds=[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}],Gs=[{value:"16:9",label:"16:9 (Landscape)"},{value:"9:16",label:"9:16 (Portrait)"},{value:"1:1",label:"1:1 (Square)"}];function ht({open:r,onOpenChange:c,onSave:t}){const h=(()=>{if(typeof window>"u")return null;try{const l=localStorage.getItem(Is);return l?JSON.parse(l):null}catch{return null}})(),[d,u]=n.useState(""),[g,j]=n.useState(h?.duration||"8"),[C,w]=n.useState(h?.resolution||"720p"),[m,x]=n.useState(h?.aspectRatio||"16:9"),[N,S]=n.useState(h?.generateAudio??!0),[b,y]=n.useState(null),[_,A]=n.useState(null),[P,E]=n.useState(null),[L,f]=n.useState(0),M=n.useRef(null),[T,$]=n.useState(!1),[F,D]=n.useState(!1),[v,z]=n.useState([]),{toast:K}=Oe();n.useEffect(()=>{const l={duration:g,resolution:C,aspectRatio:m,generateAudio:N};localStorage.setItem(Is,JSON.stringify(l))},[g,C,m,N]),n.useEffect(()=>(T?(f(0),M.current=setInterval(()=>{f(l=>l+1)},1e3)):M.current&&(clearInterval(M.current),M.current=null),()=>{M.current&&clearInterval(M.current)}),[T]),n.useEffect(()=>{r&&Q()},[r]);const Q=async()=>{try{const G=await(await fetch(`${se}/api/v1/resources`)).json();if(G.success){const B=(G.data||[]).filter(ne=>{const me=ne.type==="image/jpeg"||ne.name.toLowerCase().endsWith(".jpg")||ne.name.toLowerCase().endsWith(".jpeg"),we=ne.type==="image/png"||ne.name.toLowerCase().endsWith(".png");return(me||we)&&ne.thumbnailPath});z(B)}}catch(l){console.error("Failed to fetch image resources:",l)}},q=l=>{l===_?A(null):l===b?(y(null),A(l)):b?A(l):y(l)},Z=()=>{y(null),A(null)},V=async()=>{if(!d.trim()){K({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}$(!0),E(null);try{const l=await fetch(`${se}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d,image:b||void 0,last_frame:_||void 0,duration:parseInt(g),resolution:C,aspect_ratio:m,generate_audio:N})});if(l.status===504||l.status===502||l.status===408)throw new Error("Request timed out. The video model may be warming up - please try again.");const G=l.headers.get("content-type");if(!G||!G.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const B=await l.json();if(!l.ok||!B.success){const ne=B.error?.message||"Failed to generate video",me=B.error?.code==="MISSING_API_TOKEN";throw new Error(me?"Replicate API token not configured. Please add it in Settings → Integrations.":ne)}E(B.data.videoUrl),K({title:"Video generated",description:"Your video has been generated successfully"})}catch(l){console.error("Generation error:",l);const G=l instanceof Error?l.message:"Failed to generate video.",B=G.toLowerCase().includes("timeout")||G.toLowerCase().includes("timed out");K({title:B?"Generation timed out":"Generation failed",description:G,variant:"destructive"})}finally{$(!1)}};n.useEffect(()=>{const l=G=>{r&&(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),d.trim()&&!T&&!F&&V())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r,d,T,F]);const ee=async()=>{if(P){D(!0);try{await t(P),u(""),j("8"),w("720p"),x("16:9"),S(!0),y(null),A(null),E(null),c(!1)}catch(l){K({title:"Save failed",description:l instanceof Error?l.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{D(!1)}}},o=()=>{!T&&!F&&c(!1)},X=l=>l===b?"start":l===_?"end":null;return e.jsx(fe,{open:r,onOpenChange:o,children:e.jsxs(pe,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ge,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ve,{className:"text-base sm:text-lg",children:"Generate Video"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(te,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):P?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:P,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Ve,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsxs("div",{className:"border-t bg-background p-2 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 px-1",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:Z,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!b&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),v.map(l=>{const G=X(l.id);return e.jsxs("button",{onClick:()=>q(l.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${G?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${se}/api/v1/resources/${l.id}/thumbnail`,alt:l.name,className:"w-full h-full object-cover"}),G&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-[10px] font-medium text-center py-0.5",children:G==="start"?"Start":"End"})]},l.id)})]})]}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[40vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(je,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:d,onChange:l=>u(l.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Duration"}),e.jsxs(U,{value:g,onValueChange:j,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Ts.map(l=>e.jsx(W,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Resolution"}),e.jsxs(U,{value:C,onValueChange:w,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Ds.map(l=>e.jsx(W,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(k,{className:"text-xs",children:"Ratio"}),e.jsxs(U,{value:m,onValueChange:x,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(J,{})}),e.jsx(Y,{children:Gs.map(l=>e.jsx(W,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Le,{id:"generateAudio-mobile",checked:N,onCheckedChange:l=>S(l===!0)}),e.jsx(k,{htmlFor:"generateAudio-mobile",className:"text-xs cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:V,disabled:!d.trim()||T||F,className:"flex-1 h-9",size:"sm",children:T?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Rs,{}),e.jsxs("span",{children:[L,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:ee,disabled:!P||T||F,variant:"outline",className:"flex-1 h-9",size:"sm",children:F?e.jsx(te,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"prompt",children:"Prompt"}),e.jsx(je,{id:"prompt",placeholder:"Describe the video you want to generate...",value:d,onChange:l=>u(l.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"duration",children:"Duration"}),e.jsxs(U,{value:g,onValueChange:j,children:[e.jsx(H,{id:"duration",children:e.jsx(J,{})}),e.jsx(Y,{children:Ts.map(l=>e.jsx(W,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(U,{value:C,onValueChange:w,children:[e.jsx(H,{id:"resolution",children:e.jsx(J,{})}),e.jsx(Y,{children:Ds.map(l=>e.jsx(W,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(U,{value:m,onValueChange:x,children:[e.jsx(H,{id:"aspectRatio",children:e.jsx(J,{})}),e.jsx(Y,{children:Gs.map(l=>e.jsx(W,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Le,{id:"generateAudio",checked:N,onCheckedChange:l=>S(l===!0)}),e.jsx(k,{htmlFor:"generateAudio",className:"cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:V,disabled:!d.trim()||T||F,className:"w-full",children:T?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Rs,{}),e.jsxs("span",{children:["Generating... ",L,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(R,{onClick:ee,disabled:!P||T||F,variant:"outline",className:"w-full",children:F?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(te,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating video..."})]}):P?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:P,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Ve,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated video will appear here"})]})}),e.jsxs("div",{className:"border-t bg-background p-4 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:Z,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!b&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),v.map(l=>{const G=X(l.id);return e.jsxs("button",{onClick:()=>q(l.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${G?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${se}/api/v1/resources/${l.id}/thumbnail`,alt:l.name,className:"w-full h-full object-cover"}),G&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-xs font-medium text-center py-1",children:G==="start"?"Start":"End"})]},l.id)})]})]})]})]})]})})}function xt({open:r,onOpenChange:c,resource:t,onCopyPath:p,onDownload:h,onNavigate:d,canNavigatePrev:u,canNavigateNext:g}){const[j,C]=n.useState(null),[w,m]=n.useState(!1),[x,N]=n.useState(!1);n.useEffect(()=>{N(!1)},[t?.id,r]);const S=t?`${se}/api/v1/resources/${t.id}`:"",b=t?.type.startsWith("image/")??!1,y=t?t.type==="image/svg+xml"||t.name.toLowerCase().endsWith(".svg"):!1,_=t?t.type==="application/pdf"||t.name.toLowerCase().endsWith(".pdf"):!1,A=t?.type.startsWith("video/")??!1,P=t?.type.startsWith("audio/")??!1,E=t?t.type.startsWith("text/")||t.type==="application/json"||t.type.includes("javascript")||t.type.includes("typescript")||t.type.includes("xml")||t.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,L=t?t.name.toLowerCase().endsWith(".md")||t.name.toLowerCase().endsWith(".markdown"):!1,f=t?t.type==="application/json"||t.name.toLowerCase().endsWith(".json"):!1,M=t?t.type==="text/html"||t.name.toLowerCase().endsWith(".html"):!1;if(n.useEffect(()=>{const v=z=>{if(r){if(z.key==="Escape"){x?N(!1):c(!1);return}if(!x){if(z.key==="ArrowLeft"&&u){z.preventDefault(),d("prev");return}z.key==="ArrowRight"&&g&&(z.preventDefault(),d("next"))}}};if(r)return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r,c,d,u,g,x]),n.useEffect(()=>{r&&t&&(E||L||f||M)?(m(!0),fetch(S).then(v=>{if(v.ok)return v.text();throw new Error("Failed to load file")}).then(v=>{C(v)}).catch(v=>{console.error("Failed to load text content:",v),C(null)}).finally(()=>{m(!1)})):C(null)},[r,t?.id,E,L,f,M,S]),!t)return null;const T=v=>{if(v===0)return"0 B";const z=1024,K=["B","KB","MB","GB"],Q=Math.floor(Math.log(v)/Math.log(z));return parseFloat((v/Math.pow(z,Q)).toFixed(2))+" "+K[Q]},$=v=>new Date(v).toLocaleString(),F=v=>v.startsWith("image/")?e.jsx(Se,{className:"h-6 w-6"}):v.startsWith("video/")?e.jsx(Ve,{className:"h-6 w-6"}):v.startsWith("audio/")?e.jsx(xe,{className:"h-6 w-6"}):v.includes("text")||v.includes("document")||v.includes("code")?e.jsx(_e,{className:"h-6 w-6"}):v.includes("json")||v.includes("javascript")||v.includes("typescript")?e.jsx(Qe,{className:"h-6 w-6"}):e.jsx(Je,{className:"h-6 w-6"}),D=()=>{if(y)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:S,alt:t.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>N(!0),children:e.jsx(ps,{className:"h-4 w-4"})})]});if(_)return e.jsx("iframe",{src:S,className:"w-full h-full min-h-[600px] rounded-lg border",title:t.name});if(A)return e.jsx("video",{src:S,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(P)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(xe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:S,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(L&&j!==null)return w?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(xa,{remarkPlugins:[pa],rehypePlugins:[fa],children:j})});if(M&&j!==null)return w?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:j,className:"w-full h-full min-h-[600px] rounded-lg border",title:t.name,sandbox:"allow-same-origin"});if(f&&j!==null){if(w)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let v=j;try{const z=JSON.parse(j);v=JSON.stringify(z,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:v})})})}return E&&j!==null?w?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:j})})}):b?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:S,alt:t.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>N(!0),children:e.jsx(ps,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[F(t.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(R,{variant:"outline",onClick:()=>h(t),children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsxs(e.Fragment,{children:[e.jsx(fe,{open:r,onOpenChange:c,children:e.jsxs(pe,{className:"max-w-[90vw] w-[90vw] max-h-[90vh] h-[90vh] p-0 gap-0 flex flex-col [&>button]:hidden",children:[e.jsx(ge,{className:"px-6 pt-6 pb-4 border-b flex-shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[F(t.type),e.jsxs("div",{className:"flex-1 min-w-0 flex items-baseline gap-3",children:[e.jsx(ve,{className:"text-xl truncate",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:t.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>p(t),title:"Copy path to clipboard",children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>h(t),title:"Download",children:e.jsx(Ye,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>c(!1),title:"Close",children:e.jsx(rs,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden",children:[u&&e.jsx("button",{type:"button",onClick:()=>d("prev"),className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Previous resource",children:e.jsx(Vs,{className:"h-5 w-5"})}),g&&e.jsx("button",{type:"button",onClick:()=>d("next"),className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Next resource",children:e.jsx(Ls,{className:"h-5 w-5"})}),D()]}),e.jsx("div",{className:"border-t p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ga,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:T(t.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:$(t.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:t.metadata.tags&&t.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.metadata.tags.map(v=>e.jsx(Ie,{variant:"secondary",className:"text-xs",children:v},v))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:t.metadata.description,children:t.metadata.description})]}):e.jsx("div",{className:"flex-1"}),t.metadata.generationPrompt&&e.jsxs(R,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(t.metadata.generationPrompt||"")},children:[e.jsx(He,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]})})]})}),x&&(b||y)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>N(!1),children:[e.jsx(R,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>N(!1),children:e.jsx(rs,{className:"h-6 w-6"})}),e.jsx("img",{src:S,alt:t.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:v=>v.stopPropagation()})]})]})}function Pt(){const[r,c]=n.useState([]),[t,p]=n.useState(!0),[h,d]=n.useState(!1),[u,g]=n.useState(""),[j,C]=n.useState(!1),[w,m]=n.useState([]),[x,N]=n.useState(""),[S,b]=n.useState(""),[y,_]=n.useState([]),[A,P]=n.useState(!1),[E,L]=n.useState(!1),[f,M]=n.useState(!1),[T,$]=n.useState(null),[F,D]=n.useState(null),[v,z]=n.useState(null),[K,Q]=n.useState(1),q=12,Z=n.useRef(null),{toast:V}=Oe();n.useEffect(()=>{ee()},[]);const ee=async()=>{try{p(!0);const i=await(await fetch(`${se}/api/v1/resources`)).json();i.success&&c(i.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{p(!1)}},o=s=>{s.length!==0&&_(Array.from(s))},X=async()=>{if(y.length!==0){d(!0);try{for(const s of y){const i=new FormData;if(i.append("file",s),i.append("tags",w.join(", ")),i.append("description",S),!(await fetch(`${se}/api/v1/resources`,{method:"POST",body:i})).ok)throw new Error("Upload failed")}m([]),N(""),b(""),_([]),C(!1),await ee(),V({title:"Upload successful",description:`${y.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),V({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{d(!1)}}},l=()=>{m([]),N(""),b(""),_([]),C(!1)},G=s=>{if(s.key==="Enter"){s.preventDefault();const i=x.trim();i&&!w.includes(i)&&(m([...w,i]),N(""))}},B=s=>{m(w.filter(i=>i!==s))},ne=s=>{_(y.filter((i,I)=>I!==s))},me=async()=>{if(v)try{if((await fetch(`${se}/api/v1/resources/${v.id}`,{method:"DELETE"})).ok)await ee(),V({title:"Resource deleted",description:`${v.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),V({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{z(null)}},we=async s=>{try{const i=`.nut/resources/files/${s.path}`;await _a(i),V({title:"Path copied!",description:`Copied ${i} to clipboard`})}catch(i){console.error("Failed to copy path:",i),V({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},Pe=s=>{if(s===0)return"0 B";const i=1024,I=["B","KB","MB","GB"],ae=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,ae)).toFixed(2))+" "+I[ae]},Te=(s,i)=>{const I=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||I.endsWith(".svg")?e.jsx(us,{className:"h-4 w-4"}):e.jsx(Se,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(hs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(ds,{className:"h-4 w-4"}):s==="application/pdf"||I.endsWith(".pdf")?e.jsx(_e,{className:"h-4 w-4"}):I.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(Qe,{className:"h-4 w-4"}):s==="application/json"||I.endsWith(".json")?e.jsx(ms,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||I.match(/\.(xls|xlsx|csv)$/)?e.jsx(xs,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||I.match(/\.(ppt|pptx)$/)?e.jsx(gs,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(_e,{className:"h-4 w-4"}):s.includes("font")||I.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(fs,{className:"h-4 w-4"}):e.jsx(Je,{className:"h-4 w-4"})},$e=(s,i)=>{const I=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||I.endsWith(".svg")?e.jsx(us,{className:"h-16 w-16"}):e.jsx(Se,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(hs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(ds,{className:"h-16 w-16"}):s==="application/pdf"||I.endsWith(".pdf")?e.jsx(_e,{className:"h-16 w-16"}):I.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(Qe,{className:"h-16 w-16"}):s==="application/json"||I.endsWith(".json")?e.jsx(ms,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||I.match(/\.(xls|xlsx|csv)$/)?e.jsx(xs,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||I.match(/\.(ppt|pptx)$/)?e.jsx(gs,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(_e,{className:"h-16 w-16"}):s.includes("font")||I.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(fs,{className:"h-16 w-16"}):e.jsx(Je,{className:"h-16 w-16"})},De=s=>{const i=s.name.toLowerCase(),I=s.type.startsWith("image/");return s.type==="image/svg+xml"||i.endsWith(".svg")?e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/30 rounded-md border overflow-hidden p-2",children:e.jsx("img",{src:`${se}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):I&&s.thumbnailPath?e.jsx("img",{src:`${se}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:de=>{de.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/50 rounded-md border",children:e.jsx("div",{className:"text-muted-foreground",children:$e(s.type,s.name)})})},ie=r.filter(s=>{if(!u)return!0;const i=u.toLowerCase();return s.name.toLowerCase().includes(i)||s.metadata.description?.toLowerCase().includes(i)||s.metadata.tags?.some(I=>I.toLowerCase().includes(i))}),ye=Math.ceil(ie.length/q),Ge=(K-1)*q,a=ie.slice(Ge,Ge+q);n.useEffect(()=>{Q(1)},[u]);const O=s=>{s.preventDefault(),s.stopPropagation()},he=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&o(s.dataTransfer.files)},le=(s,i)=>{if(i.target.closest("button"))return;$(s);const ae=ie.findIndex(de=>de.id===s.id);D(ae>=0?ae:null)},Ne=s=>{window.open(`${se}/api/v1/resources/${s.id}?download=true`)},Me=async(s,i)=>{d(!0);try{const I=await fetch(s);if(!I.ok)throw new Error("Failed to download generated image");const ae=await I.blob(),de=`generated-image-${Date.now()}.png`,ce=new FormData;ce.append("file",ae,de),ce.append("tags",w.join(","));const oe=i?.prompt?`Generated with: "${i.prompt}"${i.model?` (${i.model})`:""}`:S;if(ce.append("description",oe),i?.prompt&&ce.append("generationPrompt",i.prompt),i?.model&&ce.append("generationModel",i.model),!(await fetch(`${se}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await ee(),V({title:"Image saved",description:"Generated image has been saved to resources"})}catch(I){throw console.error("Failed to save generated image:",I),V({title:"Save failed",description:I instanceof Error?I.message:"Failed to save generated image",variant:"destructive"}),I}finally{d(!1)}},ta=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},na=async s=>{d(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated audio");const I=await i.blob();let ae="mp3";const de=i.headers.get("content-type");de?.includes("wav")?ae="wav":de?.includes("flac")?ae="flac":s.includes(".wav")?ae="wav":s.includes(".flac")&&(ae="flac");const ce=`generated-audio-${Date.now()}.${ae}`,oe=new FormData;if(oe.append("file",I,ce),oe.append("tags",w.join(",")),oe.append("description",S),!(await fetch(`${se}/api/v1/resources`,{method:"POST",body:oe})).ok)throw new Error("Upload failed");await ee(),V({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(i){throw console.error("Failed to save generated audio:",i),V({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated audio",variant:"destructive"}),i}finally{d(!1)}},ra=async s=>{d(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated video");const I=await i.blob();let ae="mp4";(i.headers.get("content-type")?.includes("webm")||s.includes(".webm"))&&(ae="webm");const ce=`generated-video-${Date.now()}.${ae}`,oe=new FormData;if(oe.append("file",I,ce),oe.append("tags",w.join(",")),oe.append("description",S),!(await fetch(`${se}/api/v1/resources`,{method:"POST",body:oe})).ok)throw new Error("Upload failed");await ee(),V({title:"Video saved",description:"Generated video has been saved to resources"})}catch(i){throw console.error("Failed to save generated video:",i),V({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated video",variant:"destructive"}),i}finally{d(!1)}},la=s=>{if(F===null)return;const i=s==="next"?F+1:F-1;if(i<0||i>=ie.length)return;const I=ie[i];D(i),$(I)};return 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-2xl font-bold tracking-tight",children:"Resources"}),e.jsx("p",{className:"text-muted-foreground",children:"Upload and generate media assets for your project"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(ga,{children:[e.jsx(va,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate"}),e.jsx(ja,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(wa,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Be,{onClick:()=>P(!0),children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Be,{onClick:()=>L(!0),children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Audio"]}),e.jsxs(Be,{onClick:()=>M(!0),children:[e.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Video"]})]})]}),e.jsxs(R,{size:"sm",onClick:()=>C(!j),children:[e.jsx(cs,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(fe,{open:j,onOpenChange:s=>!s&&l(),children:e.jsxs(pe,{className:"max-w-2xl",children:[e.jsxs(ge,{children:[e.jsx(ve,{children:"Upload Resource"}),e.jsx(ls,{children:"Add files to your project resources"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-muted-foreground/50 transition-colors",onDragOver:O,onDrop:he,onClick:()=>Z.current?.click(),children:[e.jsx(Wa,{className:"mx-auto h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"mt-2 text-sm font-medium",children:"Drop files here or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Support for images, documents, and other files"})]}),e.jsx("input",{ref:Z,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&o(s.target.files)}),y.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{children:["Selected Files (",y.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:y.map((s,i)=>e.jsxs("div",{className:"flex items-center justify-between text-sm bg-muted/50 rounded px-3 py-2",children:[e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>ne(i),className:"h-6 w-6 p-0 ml-2",children:e.jsx(is,{className:"h-3 w-3"})})]},i))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"tags",children:"Tags"}),e.jsx(Ke,{id:"tags",placeholder:"Type a tag and press Enter",value:x,onChange:s=>N(s.target.value),onKeyDown:G}),w.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:w.map(s=>e.jsxs(Ie,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>B(s),className:"ml-1 hover:text-destructive",children:"×"})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"description",children:"Description"}),e.jsx(je,{id:"description",placeholder:"Brief description of this resource...",value:S,onChange:s=>b(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:l,disabled:h,children:"Cancel"}),e.jsx(R,{onClick:X,disabled:y.length===0||h,children:h?"Uploading...":`Upload ${y.length>0?`(${y.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(ka,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ke,{placeholder:"Search resources...",value:u,onChange:s=>g(s.target.value),className:"pl-8"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t?Array.from({length:6}).map((s,i)=>e.jsxs(ze,{className:"animate-pulse",children:[e.jsxs(os,{children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]}),e.jsx(Ue,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},i)):ie.length>0?a.map(s=>e.jsxs(ze,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:i=>le(s,i),children:[e.jsxs(os,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Te(s.type,s.name),e.jsx(Na,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(ba,{className:"text-xs",children:[Pe(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),we(s)},title:"Copy path to clipboard",children:e.jsx(He,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),Ne(s)},children:e.jsx(Ye,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),z(s)},children:e.jsx(is,{className:"h-3 w-3"})})]})]}),e.jsxs(Ue,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:De(s)}),s.metadata.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:s.metadata.description}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(i=>e.jsx(Ie,{variant:"secondary",className:"text-xs",children:i},i))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(ze,{children:e.jsxs(Ue,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ya,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No resources yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground text-center max-w-sm",children:"Upload files to get started. Resources can be referenced by LLMs and team members for enhanced context."}),e.jsxs(R,{className:"mt-4",onClick:()=>C(!0),children:[e.jsx(cs,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),ie.length>q&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(R,{variant:K===1?"outline":"default",size:"sm",onClick:()=>Q(s=>Math.max(1,s-1)),disabled:K===1,children:[e.jsx(Vs,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",K," of ",ye]}),e.jsxs(R,{variant:K===ye?"outline":"default",size:"sm",onClick:()=>Q(s=>Math.min(ye,s+1)),disabled:K===ye,children:["Next",e.jsx(Ls,{className:"h-4 w-4 ml-1"})]})]}),h&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-background border rounded-lg shadow-lg p-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),e.jsx("span",{className:"text-sm",children:"Uploading files..."})]})}),e.jsx(Ha,{open:A,onOpenChange:P,onSave:Me,onCustomizeInAssistant:ta}),e.jsx(mt,{open:E,onOpenChange:L,onSave:na}),e.jsx(ht,{open:f,onOpenChange:M,onSave:ra}),e.jsx(xt,{open:!!T,onOpenChange:s=>{s||$(null),s||D(null)},resource:T,onCopyPath:we,onDownload:Ne,onNavigate:la,canNavigatePrev:F!==null&&F>0,canNavigateNext:F!==null&&F<ie.length-1}),e.jsx(fe,{open:!!v,onOpenChange:s=>!s&&z(null),children:e.jsxs(pe,{className:"max-w-md",children:[e.jsxs(ge,{children:[e.jsx(ve,{children:"Delete Resource"}),e.jsxs(ls,{children:["Are you sure you want to delete ",e.jsx("strong",{children:v?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:()=>z(null),children:"Cancel"}),e.jsx(R,{variant:"destructive",onClick:me,children:"Delete"})]})]})})]})}export{Pt as default};
@@ -1,4 +1,4 @@
1
- import{c as f,r,A as p,j as e,a1 as F,B as l,I as c,T as L}from"./index-B0JO3x3V.js";import{C as T,b as I,a as z}from"./card-B9ym6neB.js";import{L as n}from"./label-BHOOQ99D.js";import{B as _}from"./badge-DaM4gF82.js";import{P as D}from"./plus-D737EJ5S.js";/**
1
+ import{c as f,r,A as p,j as e,a1 as F,B as l,I as c,T as L}from"./index-CKcm92Kn.js";import{C as T,b as I,a as z}from"./card-Cq3qftln.js";import{L as n}from"./label-COUiN2Pd.js";import{B as _}from"./badge-CxMDR-vz.js";import{P as D}from"./plus-DM62ve-p.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.