Spaces:
Running
Running
| import{r as a,j as e}from"./react-D_B_5QVd.js";import{H as b,I as y,L as g}from"./index-QBya0NjG.js";import{M as N}from"./MarkdownRenderer-BDaVxTSW.js";import"./jszip-C9ownNzX.js";import"./react-dom-EAO2-NBm.js";import"./scheduler-DYLXRpC5.js";import"./@google-4tyssLU_.js";import"./idb-Dob3nYDb.js";import"./marked-CesSW9Du.js";const v=["SASS","CSS","JavaScript","TypeScript","Python","Go","React","Vue","Angular","Tailwind CSS"],C=`// SASS | |
| $primary-color: #333; | |
| body { | |
| color: $primary-color; | |
| font-family: sans-serif; | |
| }`,R=()=>{const[o,p]=a.useState(C),[n,x]=a.useState(""),[c,h]=a.useState("SASS"),[i,j]=a.useState("CSS"),[l,u]=a.useState(!1),[d,m]=a.useState(""),S=a.useCallback(async()=>{if(!o.trim()){m("Please enter some code to migrate.");return}u(!0),m(""),x("");try{const s=b(o,c,i);let r="";for await(const t of s)r+=t,x(r)}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred.";m(`Failed to migrate code: ${r}`)}finally{u(!1)}},[o,c,i]),f=({value:s,onChange:r})=>e.jsx("select",{value:s,onChange:t=>r(t.target.value),className:"w-full px-3 py-2 rounded-md bg-slate-800 border border-slate-700",children:v.map(t=>e.jsx("option",{value:t,children:t},t))});return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold text-slate-100 flex items-center",children:[e.jsx(y,{}),e.jsx("span",{className:"ml-3",children:"AI Code Migrator"})]}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Translate code between languages, frameworks, and syntax styles."})]}),e.jsxs("div",{className:"flex-grow flex flex-col min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 flex-grow min-h-0",children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-400",children:"From:"}),e.jsx(f,{value:c,onChange:h})]}),e.jsx("textarea",{value:o,onChange:s=>p(s.target.value),placeholder:"Paste your source code here...",className:"flex-grow p-4 bg-slate-900 border border-slate-700 rounded-md resize-none font-mono text-sm"})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-slate-400",children:"To:"}),e.jsx(f,{value:i,onChange:j})]}),e.jsxs("div",{className:"flex-grow p-1 bg-slate-800/50 border border-slate-700/50 rounded-md overflow-y-auto",children:[l&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(g,{})}),d&&e.jsx("p",{className:"p-4 text-red-400",children:d}),n&&!l&&e.jsx(N,{content:n}),!l&&!n&&!d&&e.jsx("div",{className:"text-slate-500 h-full flex items-center justify-center",children:"Migrated code will appear here."})]})]})]}),e.jsx("button",{onClick:S,disabled:l,className:"mt-4 w-full max-w-sm mx-auto flex items-center justify-center px-6 py-3 bg-cyan-500 text-slate-900 font-bold rounded-md hover:bg-cyan-400 disabled:bg-slate-600",children:l?e.jsx(g,{}):"Migrate Code"})]})]})};export{R as AiCodeMigrator}; | |
| //# sourceMappingURL=AiCodeMigrator-D1DuZhlC.js.map | |