1import{r as l,a as Z,u as W,j as e,W as X,X as $,Z as K,C as p,b as u,c as h,U as R,g as T,e as x,B as j,F as H,Y as Q,E as ee,G as se,H as ae,J as te,N as P,Q as ne,_ as ie,D as re,z as le,$ as O,d as t,s as ce}from"./index-0skl7k4W.js";import{u as oe}from"./useFeatureGating-DJl3rQed.js";function ue(){const[c,C]=l.useState([]),[o,U]=l.useState(""),[f,L]=l.useState(""),[S,w]=l.useState(!1),[I,k]=l.useState(!1),[r,J]=l.useState(null),[A,z]=l.useState(0),[D,v]=l.useState(!1),{toast:n}=Z(),{user:B}=W(),{currentPlan:de,isPlan:b}=oe(),E=5,N=b("free")?A<E:!0,M=async()=>{k(!0);try{J({supabaseConfig:{url:"https://udpldrrpebdyuiqdtqnq.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVkcGxkcnJwZWJkeXVpcWR0cW5xIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE2NjA4ODgsImV4cCI6MjA2NzIzNjg4OH0.Gsb6STpmSRsyspSsGIMJ_GJ03-fFR7W3Zizz7cCRnkc"},authentication:"Supabase Auth with RLS policies",database:{tables:["ai_usage","chat_conversations","chat_messages","crider_chat_users","crider_chat_messages","stories","friendships","friend_requests","blocked_users","direct_messages","profiles"],features:["Row Level Security","Real-time subscriptions","File storage"]},edgeFunctions:["chat-with-ai","generate-code","text-to-speech","generate-ai-image","document-ai-analysis","stripe-webhooks","chat-operations"],storage:["user-files","chat-images","default-bucket"],integrations:["OpenAI","Stripe","ElevenLabs"]}),n({title:"Backend Analysis Complete",description:"Your Supabase setup has been analyzed and will be preserved in the conversion."})}catch(s){console.error("Backend analysis failed:",s),n({title:"Analysis Warning",description:"Could not fully analyze backend setup. Conversion will use default configuration.",variant:"destructive"})}finally{k(!1)}};l.useEffect(()=>{M()},[]);const F=s=>{if(!s)return;const i=Array.from(s).filter(d=>{var a;const m=[".tsx",".ts",".jsx",".js",".json",".css",".html",".md"],g="."+((a=d.name.split(".").pop())==null?void 0:a.toLowerCase());return m.includes(g)&&d.size<10*1024*1024});if(i.length===0){n({title:"Invalid Files",description:"Please upload valid web development files (.tsx, .ts, .jsx, .js, .json, .css, .html, .md)",variant:"destructive"});return}C(d=>[...d,...i]),n({title:"Files Uploaded",description:`${i.length} file(s) uploaded successfully.`})},q=s=>{C(i=>i.filter((d,m)=>m!==s))},y=s=>{s.preventDefault(),s.stopPropagation(),s.type==="dragenter"||s.type==="dragover"?v(!0):s.type==="dragleave"&&v(!1)},V=s=>{s.preventDefault(),s.stopPropagation(),v(!1),F(s.dataTransfer.files)},G=async()=>{if(!B){n({title:"Authentication Required",description:"Please sign in to use the app converter.",variant:"destructive"});return}if(!N){n({title:"Usage Limit Reached",description:"Upgrade to Pro or Plus to continue using the app converter.",variant:"destructive"});return}if(c.length===0||!o){n({title:"Missing Information",description:"Please upload your project files and select a target platform.",variant:"destructive"});return}w(!0);try{const s=await Promise.all(c.map(async a=>{const _=await a.text();return{name:a.name,path:a.webkitRelativePath||a.name,content:_}})),d=`You are an expert mobile app developer. Convert the following complete React/TypeScript web application to a fully functional ${o==="android"?"Android (Kotlin/Java with Jetpack Compose)":"iOS (Swift with SwiftUI)"} application while PRESERVING ALL BACKEND CONNECTIVITY. 2 3CRITICAL REQUIREMENTS: 41. PRESERVE ALL SUPABASE CONNECTIONS - The mobile app MUST connect to the same Supabase backend 52. MAINTAIN EXACT SAME FUNCTIONALITY - Every feature must work identically to the web version 63. AUTO-DETECT what to convert vs preserve - Keep all backend logic, convert only UI layer 74. ANALYZE ALL FILES - Convert components, hooks, utilities, and configurations as needed 8 9CURRENT SUPABASE SETUP TO PRESERVE: 10${r?JSON.stringify(r,null,2):"Backend analysis pending..."} 11 12UPLOADED PROJECT FILES: 13${s.map(a=>` 14=== FILE: ${a.path} === 15${a.content} 16`).join(` 17`)} 18 19CONVERSION REQUIREMENTS: 20- Supabase Project URL: https://udpldrrpebdyuiqdtqnq.supabase.co 21- Anon Key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVkcGxkcnJwZWJkeXVpcWR0cW5xIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE2NjA4ODgsImV4cCI6MjA2NzIzNjg4OH0.Gsb6STpmSRsyspSsGIMJ_GJ03-fFR7W3Zizz7cCRnkc 22- Preserve authentication flows with Supabase Auth 23- Keep all database operations (RLS policies remain the same) 24- Maintain edge function calls 25- Include storage bucket access 26- Keep real-time subscriptions working 27 28MOBILE PLATFORM SPECIFICS: 291. Convert React components to ${o==="android"?"Jetpack Compose":"SwiftUI"} 302. Replace web navigation with native navigation 313. Convert Tailwind/CSS to native styling 324. Implement native Supabase client setup 335. Add proper error handling and loading states 346. Include offline data caching where appropriate 357. Convert all hooks and utilities to platform equivalents 368. Maintain state management patterns 37 38DELIVERABLES: 391. Complete ${o} app source code with Supabase integration 402. Dependency/requirements file (build.gradle for Android, Package.swift for iOS) 413. Supabase client configuration matching web setup 424. Authentication flow implementation 435. Database operation examples 446. Build instructions and app store deployment guide 457. Complete file structure and organization 468. Converted utilities and helper functions 47 48The converted app should work with your existing Supabase backend WITHOUT requiring any backend changes. All authentication, database operations, edge functions, and storage should work identically to your web version.`,{data:m,error:g}=await ce.functions.invoke("chat-with-ai",{body:{message:d,model:"gpt-5-2025-08-0
487"}});if(g)throw g;L(m.response),b("free")&&z(a=>a+1),n({title:"Code Converted Successfully",description:`Your web code has been converted to ${o==="android"?"Android":"iOS"} format.`})}catch(s){console.error("Error converting code:",s),n({title:"Conversion Failed",description:"Failed to convert code. Please try again.",variant:"destructive"})}finally{w(!1)}},Y=async()=>{try{await navigator.clipboard.writeText(f),n({title:"Copied to Clipboard",description:"Converted code copied successfully."})}catch{n({title:"Copy Failed",description:"Failed to copy to clipboard.",variant:"destructive"})}};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-4",children:[e.jsx(X,{className:"h-8 w-8 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold",children:"AI App Converter"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Convert your website code to Android or iOS apps while preserving all Supabase backend connections"}),r&&e.jsx("div",{className:"mt-4 p-3 bg-green-50 dark:bg-green-950/20 rounded-lg border border-green-200 dark:border-green-800",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 text-green-700 dark:text-green-300",children:[e.jsx($,{className:"h-4 w-4"}),e.jsxs("span",{className:"text-sm font-medium",children:["Backend Analysis Complete - ",r.database.tables.length," tables, ",r.edgeFunctions.length," edge functions detected"]})]})}),b("free")&&e.jsx("div",{className:"mt-4 p-3 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-800",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 text-amber-700 dark:text-amber-300",children:[e.jsx(K,{className:"h-4 w-4"}),e.jsxs("span",{className:"text-sm font-medium",children:["Free Plan: ",A,"/",E," conversions used"]})]})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(p,{children:[e.jsxs(u,{children:[e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"Upload Project Files"]}),e.jsx(T,{children:"Upload your entire website project files (.tsx, .ts, .jsx, .js, .json, .css, .html). The converter will analyze everything and preserve all Supabase backend connections."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${D?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"}`,onDragEnter:y,onDragLeave:y,onDragOver:y,onDrop:V,children:[e.jsx(R,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Drag and drop your project files here, or click to browse"}),e.jsx("input",{type:"file",multiple:!0,accept:".tsx,.ts,.jsx,.js,.json,.css,.html,.md",onChange:s=>F(s.target.files),className:"hidden",id:"file-upload"}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>{var s;return(s=document.getElementById("file-upload"))==null?void 0:s.click()},children:"Choose Files"})]}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium",children:["Uploaded Files (",c.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto space-y-1",children:c.map((s,i)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded text-sm",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-3 w-3"}),s.name]}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>q(i),className:"h-6 w-6 p-0",children:e.jsx(Q,{className:"h-3 w-3"})})]},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Target Platform"}),e.jsxs(ee,{value:o,onValueChange:U,children:[e.jsx(se,{children:e.jsx(ae,{placeholder:"Select target platform"})}),e.jsxs(te,{children:[e.jsx(P,{value:"android",children:"Android (Kotlin/Java)"}),e.jsx(P,{value:"ios",children:"iOS (Swift)"})]})]})]}),e.jsx(j,{onClick:G,disabled:S||!N||c.length===0||!o||I,className:"w-full",children:S?e.jsxs(e.Fragment,{children:["Convert
48ing ",c.length," Files with Backend Integration..."]}):I?e.jsx(e.Fragment,{children:"Analyzing Backend Setup..."}):N?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Convert to ",o==="android"?"Android":"iOS"," (",c.length," Files)"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-4 w-4 mr-2"}),"Upgrade Required"]})})]})]}),e.jsxs(p,{children:[e.jsxs(u,{children:[e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),"Converted Mobile App"]}),e.jsx(T,{children:"Complete mobile app project with full Supabase backend integration preserved"})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx(le,{value:f,readOnly:!0,placeholder:"Your complete mobile app project will appear here. All files analyzed and converted with Supabase connections preserved...",className:"min-h-[200px] font-mono text-sm"}),f&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{onClick:Y,variant:"outline",className:"w-full",children:"Copy Complete Mobile Project"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Includes: Source code, dependencies, build config, deployment guide"})]})]})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(p,{children:[e.jsx(u,{children:e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-5 w-5"}),"Your Backend Setup"]})}),e.jsx(x,{children:r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(t,{className:"mb-2",children:"Supabase Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Project: udpldrrpebdyuiqdtqnq"})]}),e.jsxs("div",{children:[e.jsx(t,{className:"mb-2",children:"Database Tables"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.database.tables.length," tables detected"]})]}),e.jsxs("div",{children:[e.jsx(t,{className:"mb-2",children:"Edge Functions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.edgeFunctions.length," functions available"]})]}),e.jsxs("div",{children:[e.jsx(t,{className:"mb-2",children:"Integrations"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.integrations.join(", ")})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Analyzing backend setup..."})]})})]}),e.jsxs(p,{children:[e.jsx(u,{children:e.jsx(h,{children:"Conversion Features"})}),e.jsx(x,{children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ð"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Smart Conversion"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Preserves backend connections, converts only UI"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ðï¸"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Database Integration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Same RLS policies and queries work on mobile"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ð"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Auth Preservation"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"User sessions and authentication flows maintained"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"â¡"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Edge Functions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All serverless functions work identically"})]})]})]})})]})]}),e.jsxs(p,{children:[e.jsx(u,{children:e.jsx(h,{children:"What You Get"})}),e.jsx(x,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ð±"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Native App Code"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Complete native application code"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ð¦"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Dependencies"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All required packages and libraries"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"âï¸"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Build Config"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ready-to-use build configuration"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t,{className:"mt-1",children:"ð"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"Store Ready"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"App store deployment guide"})]})]})]})})]})]})}export{ue as AppConverterPanel};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.