admin08077/Githubgemini
0
1import{r as n,j as e}from"./react-CIdJ77ke.js";import{c as A}from"./diff-CqM5-8zX.js";import{l as j,a as G,u as k,aI as C,aJ as E,L as x,D as I,aK as R}from"./index-CX7Qxd1D.js";import"./accessibilityService-PX6aNbbc.js";import{e as w}from"./googleApiService-B4BzT3uR.js";import"./workspaceConnectorService-KhhKdOYD.js";const _=async r=>{try{if(!await w())throw new Error("Google API client not ready.");await gapi.client.load("https://docs.googleapis.com/$discovery/rest?version=v1");const l=(await gapi.client.docs.documents.create({title:r})).result;return{documentId:l.documentId,webViewLink:`https://docs.google.com/document/d/${l.documentId}/edit`}}catch(c){throw j(c,{service:"workspaceService",function:"createDocument"}),c}},D=async(r,c)=>{try{if(!await w())throw new Error("Google API client not ready.");await gapi.client.load("https://docs.googleapis.com/$discovery/rest?version=v1"),await gapi.client.docs.documents.batchUpdate({documentId:r,resource:{requests:[{insertText:{text:c,location:{index:1}}}]}})}catch(s){throw j(s,{service:"workspaceService",function:"insertText"}),s}},L=`function Greeter(props) {2 return <h1>Hello, {props.name}!</h1>;3}`,T=`function Greeter({ name, enthusiasmLevel = 1 }) {4 const punctuation = '!'.repeat(enthusiasmLevel);5 return <h1>Hello, {name}{punctuation}</h1>;6}`,v=()=>{const[r,c]=n.useState(L),[s,l]=n.useState(T),[i,f]=n.useState(!1),[p,h]=n.useState(!1),[g,d]=n.useState(""),[a,y]=n.useState(null),{addNotification:m}=G(),{state:N}=k(),{user:b}=N,u=n.useMemo(()=>A("component.tsx",r,s),[r,s]),S=n.useCallback(async()=>{if(!r.trim()&&!s.trim()){d("Please provide code to generate a summary.");return}f(!0),d(""),y(null);try{const t=await C(u);y(t)}catch(t){const o=t instanceof Error?t.message:"An unknown error occurred.";d(`Failed to generate summary: ${o}`)}finally{f(!1)}},[u,r,s]),P=async()=>{if(!a||!b){m("Please generate a summary first and ensure you are signed in.","error");return}h(!0);try{const t=await R(u,a),o=await _(`Tech Spec: ${a.title}`);await D(o.documentId,t),m("Successfully exported to Google Docs!","success"),window.open(o.webViewLink,"_blank")}catch(t){const o=t instanceof Error?t.message:"An unknown error occurred.";m(`Failed to export: ${o}`,"error")}finally{h(!1)}};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(E,{}),e.jsx("span",{className:"ml-3",children:"AI Pull Request Assistant"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Generate a PR summary from code changes and export a full tech spec."})]}),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 gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"before-code",className:"text-sm font-medium text-text-secondary mb-2",children:"Before"}),e.jsx("textarea",{id:"before-code",value:r,onChange:t=>c(t.target.value),className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"after-code",className:"text-sm font-medium text-text-secondary mb-2",children:"After"}),e.jsx("textarea",{id:"after-code",value:s,onChange:t=>l(t.target.value),className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsx("button",{onClick:S,disabled:i,className:"btn-primary w-full flex items-center justify-center px-6 py-3",children:i?e.jsx(x,{}):"Generate Summary"}),g&&e.jsx("p",{className:"text-red-500 text-xs text-center",children:g})]}),e.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:e.jsxs("div",{className:"flex flex-col bg-surface border border-border p-4 rounded-lg flex-grow min-h-0",children:[e.jsx("h3",{className:"text-lg font-bold mb-2",children:"Generated Summary"}),e.jsx("div",{className:"flex-grow overflow-y-auto pr-2 space-y-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",readOnly:!0,value:a.title,className:"w-full font-bold p-2 bg-background rounded"}),e.jsx("textarea",{readOnly:!0,value:a.summary,className:"w-full h-24 p-2 bg-background rounded resize-none"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:"Changes:"}),e.jsx("ul",{className:"list-disc list-inside text-sm",children:a.changes.map((t,o)=>e.jsx("li",{children:t},o))})]})]}):e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:i?e.jsx(x,{}):"PR summary will appear here."})}),a&&b&&e.jsx("div",{className:"mt-4 pt-4 border-t border-border",children:e.jsx("button",{onClick:P,disabled:p,className:"w-full btn-primary bg-blue-600 flex items-center justify-center gap-2 py-2",children:p?e.jsx(x,{}):e.jsxs(e.Fragment,{children:[e.jsx(I,{})," Export to Google Docs"]})})})]})})]})]})},B=Object.freeze(Object.defineProperty({__proto__:null,AiPullRequestAssistant:v},Symbol.toStringTag,{value:"Module"})),H=Object.freeze(Object.defineProperty({__proto__:null,PrSummaryGenerator:v},Symbol.toStringTag,{value:"Module"}));export{B as A,H as P};7//# sourceMappingURL=PrSummaryGenerator-BY4XKruc.js.map8 