import{r as t,j as e}from"./react-B-lWpQRQ.js";import{u as j,k as y,J as N,L as u}from"./index-DyMS-nC-.js";import"./@google-xfXoiafW.js";import"./marked-CesSW9Du.js";import"./@braintree-DY5JYOZd.js";import"./react-dom-CU2yWD-Y.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./axe-core-CA05Kxsw.js";import"./@mermaid-js-Ce0__7Tp.js";import"./langium-B_PGe6V2.js";import"./vscode-jsonrpc-2tvYB2ki.js";import"./chevrotain-D5DQZOif.js";import"./@chevrotain-DMYZVohV.js";import"./lodash-es-CKTcnrxn.js";import"./chevrotain-allstar-eFSt8-qu.js";import"./vscode-languageserver-types-NoPvPymt.js";import"./vscode-languageserver-textdocument-CKBVUiR3.js";import"./vscode-uri-CoxP0whD.js";const v=`diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 1b2c3d4..5e6f7g8 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,7 +1,7 @@ import React from 'react'; interface ButtonProps { - text: string; + label: string; onClick: () => void; } `,K=({diff:r})=>{const[d,x]=t.useState(r||v),[a,f]=t.useState(""),[s,p]=t.useState(!1),[c,l]=t.useState(""),{addNotification:g}=j(),m=t.useCallback(async o=>{if(!o.trim()){l("Please paste a diff to generate a message.");return}p(!0),l(""),f("");try{const n=y(o);let i="";for await(const b of n)i+=b,f(i)}catch(n){const i=n instanceof Error?n.message:"An unknown error occurred.";l(`Failed to generate message: ${i}`)}finally{p(!1)}},[]);t.useEffect(()=>{r&&(x(r),m(r))},[r,m]);const h=()=>{navigator.clipboard.writeText(a),g("Commit message copied!","success")};return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(N,{}),e.jsx("span",{className:"ml-3",children:"AI Commit Message Generator"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Paste your diff and let Gemini craft the perfect commit message."})]}),e.jsxs("div",{className:"flex-grow grid grid-cols-1 lg:grid-cols-2 gap-6 min-h-0",children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("label",{htmlFor:"diff-input",className:"text-sm font-medium text-text-secondary mb-2",children:"Git Diff"}),e.jsx("textarea",{id:"diff-input",value:d,onChange:o=>x(o.target.value),placeholder:"Paste your git diff here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm",spellCheck:"false"}),e.jsx("button",{onClick:()=>m(d),disabled:s,className:"btn-primary mt-4 w-full flex items-center justify-center px-6 py-3",children:s?e.jsx(u,{}):"Generate Message"})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"Generated Message"}),a&&!s&&e.jsx("button",{onClick:h,className:"px-3 py-1 bg-gray-100 dark:bg-slate-700 text-xs rounded-md hover:bg-gray-200 dark:hover:bg-slate-600",children:"Copy Message"})]}),e.jsxs("div",{className:"flex-grow p-4 bg-background border border-border rounded-md overflow-y-auto",children:[s&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(u,{})}),c&&e.jsx("p",{className:"text-red-500",children:c}),a&&!s&&e.jsx("pre",{className:"whitespace-pre-wrap font-sans text-sm",children:a}),!s&&!a&&!c&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"Commit message will appear here."})]})]})]})]})};export{K as AiCommitGenerator}; //# sourceMappingURL=AiCommitGenerator-BDAAla-r.js.map