1import{a as s,c as L,T as P,U as I,r,j as e,bh as A,cB as M,cC as T,cP as E,bj as F,W as h,B as S,k as z,n as ne,cQ as G,cR as O,cS as B,cT as $,cU as R,e as J,a4 as Me,cV as Te,cW as Ee}from"./main-DkzorUIT.js";import{C as Fe}from"./container-DfHu8uKD.js";import{D as Ue}from"./dashboard-header-CUNDdyQv.js";import{T as U}from"./textarea-DgSmlL-R.js";import{I as X,d as Q}from"./download-C2kX-p9o.js";import{a as re}from"./ai_page_common_prompt-DSkZZ7iV.js";import{a as Z}from"./ai_page_common_download-BOANSrBg.js";import"./IconArrowLeft-4NJIgW7Y.js";const De=()=>"Caption Image",Le=((t={},a={})=>(a.locale??s(),De())),Ge=()=>"Powered by Cloudflare Workers AI to describe an image or answer a question about it.",Oe=((t={},a={})=>(a.locale??s(),Ge())),Be=()=>"The caption will appear here.",$e=((t={},a={})=>(a.locale??s(),Be())),Re=()=>"Upload an image to caption.",We=((t={},a={})=>(a.locale??s(),Re())),qe=()=>"Failed to caption image.",Ke=((t={},a={})=>(a.locale??s(),qe())),Ve=()=>"Image (max 1 MB)",He=((t={},a={})=>(a.locale??s(),Ve())),Ye=()=>"Result",Je=((t={},a={})=>(a.locale??s(),Ye())),Xe=()=>"Captioning...",Qe=((t={},a={})=>(a.locale??s(),Xe())),Ze=()=>"Generate a caption for this image.",ea=((t={},a={})=>(a.locale??s(),Ze())),aa=()=>"Describe what you see in this image in detail.",ta=((t={},a={})=>(a.locale??s(),aa())),sa=()=>"List 5 keywords that describe this image, comma-separated.",na=((t={},a={})=>(a.locale??s(),sa())),ra=()=>"What objects are in this image?",ia=((t={},a={})=>(a.locale??s(),ra())),la=()=>"Preview",oa=((t={},a={})=>(a.locale??s(),la())),ca=()=>"Prompt",pa=((t={},a={})=>(a.locale??s(),ca())),da=()=>"Reading the image...",_a=((t={},a={})=>(a.locale??s(),da())),ua=()=>"Image Captioning",ma=((t={},a={})=>(a.locale??s(),ua())),ga=()=>"Change image",ie=((t={},a={})=>(a.locale??s(),ga())),xa=()=>"characters",W=((t={},a={})=>(a.locale??s(),xa())),ha=()=>"custom prompt",le=((t={},a={})=>
1(a.locale??s(),ha())),fa=()=>"AI generated",oe=((t={},a={})=>(a.locale??s(),fa())),ba=()=>"Please use one under 1 MB.",ce=((t={},a={})=>(a.locale??s(),ba())),ja=()=>"Model",pe=((t={},a={})=>(a.locale??s(),ja())),va=()=>"Could not read the selected file.",de=((t={},a={})=>(a.locale??s(),va())),ya=()=>"Result",ee=((t={},a={})=>(a.locale??s(),ya())),Na=()=>"Upload image",_e=((t={},a={})=>(a.locale??s(),Na())),Sa=()=>"Please upload an image file.",ue=((t={},a={})=>(a.locale??s(),Sa())),wa=()=>"Built with TanStack AI, Cloudflare Workers AI, and fal.ai.",za=((t={},a={})=>(a.locale??s(),wa())),ka=()=>"Generate Image",me=((t={},a={})=>(a.locale??s(),ka())),Ca=()=>"Powered by Cloudflare Workers AI to generate images directly from a text prompt.",Pa=((t={},a={})=>(a.locale??s(),Ca())),Ia=()=>"Powered by fal.ai with switchable models to generate vivid images from text prompts.",Aa=((t={},a={})=>(a.locale??s(),Ia())),Ma=()=>"Stylize",Ta=((t={},a={})=>(a.locale??s(),Ma())),Ea=()=>"Powered by fal.ai to turn an uploaded portrait into a stylized cartoon, caricature, or anime version.",Fa=((t={},a={})=>(a.locale??s(),Ea())),Ua=()=>"Your stylized portrait will appear here.",Da=((t={},a={})=>(a.locale??s(),Ua())),La=()=>"Upload a portrait to stylize.",Ga=((t={},a={})=>(a.locale??s(),La())),Oa=()=>"Failed to edit image.",Ba=((t={},a={})=>(a.locale??s(),Oa())),$a=()=>"Source portrait (max 1 MB)",Ra=((t={},a={})=>(a.locale??s(),$a())),Wa=()=>"Stylizing...",qa=((t={},a={})=>(a.locale??s(),Wa())),Ka=()=>"Describe the style you want...",Va=((t={},a={})=>(a.locale??s(),Ka())),Ha=()=>"Bobblehead Caricature",Ya=((t={},a={})=>(a.locale??s(),Ha())),Ja=()=>"Transform this person into a cute bobblehead-style cartoon caricature: oversized round head, tiny shoulders, glossy clean line art, vibrant flat colors, rosy cheeks, friendly smile, plain solid pastel background, sticker-style, keep the original facial features recognizable.",Xa=((t={},a={})=>(a.locale??s(),Ja())),Qa=()=>"Pixar 3D",Za=((t={},a={})=>(a.locale??s(),Qa())),et=()=>"Transform this person into a Pixar-style 3D animated character with big expressive eyes, smooth shaded skin, soft cinematic lighting, friendly smile, clean studio background, keep the original identity recognizable.",at=((t={},a={})=>(a.locale??s(),et())),tt=()=>"Anime Portrait",st=((t={},a={})=>(a.locale??s(),tt())),nt=()=>"Transform this person into a high-quality anime character portrait, cel-shaded with crisp linework, expressive sparkling eyes, soft pastel background, Japanese animation style, keep the original facial features recognizable.",rt=((t={},a={})=>(a.locale??s(),nt())),it=()=>"Source preview",lt=((t={},a={})=>(a.locale??s(),it())),ot=()=>"Style prompt",ct=((t={},a={})=>(a.locale??s(),ot())),pt=()=>"Stylized result",dt=((t={},a={})=>(a.locale??s(),pt())),_t=()=>"Image Editing · Avatar Stylizer",ut=((t={},a={})=>(a.locale??s(),_t())),mt=()=>"Your generated image will appear here.",ge=((t={},a={})=>(a.locale??s(),mt())),gt=()=>"Failed to generate image.",xe=((t={},a={})=>(a.locale??s(),gt())),xt=()=>"Generating...",he=((t={},a={})=>(a.locale??s(),xt())),ht=()=>"Describe the image you want to generate...",fe=((t={},a={})=>(a.locale??s(),ht())),ft=()=>"Astronaut Panda",be=((t={},a={})=>(a.locale??s(),ft())),bt=()=>"A cute red panda wearing a tiny astronaut helmet floating among nebulas, cinematic lighting, ultra detailed",je=((t={},a={})=>(a.locale??s(),bt())),jt=()=>"Cyberpunk Tokyo",ve=((t={},a={})=>(a.locale??s(),jt())),vt=()=>"Cyberpunk Tokyo street at night, rain-soaked neon reflections, holographic billboards, cinematic, ultra detailed",ye=((t={},a={})=>(a.locale??s(),vt())),yt=()=>"Watercolor Village",Ne=((t={},a={})=>(a.locale??s(),yt())),Nt=()=>"A peaceful Japanese mountain village at sunrise, watercolor painting style, soft light, delicate brush strokes",Se=((t={},a={})=>(a.locale??s(),Nt())),St=()=>"Product Shot",we=((t={},a={})=>(a.locale??s(),St())),wt=()=>"Minimalist product photo of sleek matte-black wireless earbuds on white marble, soft studio lighting, shallow depth of field",ze=((t={},a={})=>(a.locale??s(),wt())),zt=()=>"Pixel Dragon",ke=((t={},a={})=>(a.locale??s(),zt())),kt=()=>"16-bit pixel art of a tiny dragon guarding a glowing crystal cave, retro game aesthetic, vibrant colors",Ce=((t={},a={})=>(a.locale??s(),kt())),Ct=()=>"Image Generation · Workers AI",Pt=((t={},a={})=>(a.locale??s(),Ct())),It=()=>"Image Generation · fal.ai",At=((t={},a={})=>(a.locale??s(),It())),Mt=()=>"Summarize",Tt=((t={},a={})=>(a.locale??s(),Mt())),Et=()=>"Powered by Cloudflare Workers AI to condense long text into a concise summary.",Ft=((t={},a={})=>(a.locale??s(),Et())),Ut=()=>"The summary will appear here.",Dt=((t={},a={})=>(a.locale??s(),Ut())),Lt=()=>"Failed to summarize text.",Gt=((t={},a={})=>(a.locale??s(),Lt())),Ot=()=>"Summary",Bt=((t={},a={})=>(a.locale??s(),Ot())),$t=()=>"Summarizing...",Rt=((t={},a={})=>(a.locale??s(),$t())),Wt=()=>"Paste a long article or paragraph here...",qt=((t={},a={})=>(a.locale??s(),Wt())),Kt=()=>"Cloudflare Workers AI lets developers run machine learning models on the Cloudflare global network. It provides a serverless GPU-powered inference platform that brings popular open-source models close to end users without managing any infrastru
1cture. Combined with Cloudflare AI Gateway, teams gain caching, analytics, rate limiting, and unified billing across many AI providers, making it easy to ship reliable AI features in production.",Vt=((t={},a={})=>(a.locale??s(),Kt())),Ht=()=>"Source content",Yt=((t={},a={})=>(a.locale??s(),Ht())),Jt=()=>"Summarization",Xt=((t={},a={})=>(a.locale??s(),Jt())),Qt=()=>"Generate Taglines",Zt=((t={},a={})=>(a.locale??s(),Qt())),es=()=>"Powered by Cloudflare Workers AI to generate punchy SaaS taglines from a description.",as=((t={},a={})=>(a.locale??s(),es())),ts=()=>"Five generated taglines will appear here.",ss=((t={},a={})=>(a.locale??s(),ts())),ns=()=>"Failed to generate taglines.",rs=((t={},a={})=>(a.locale??s(),ns())),is=()=>"Product description",ls=((t={},a={})=>(a.locale??s(),is())),os=()=>"Suggested taglines",cs=((t={},a={})=>(a.locale??s(),os())),ps=()=>"Generating...",ds=((t={},a={})=>(a.locale??s(),ps())),_s=()=>"Describe what your SaaS does in one or two sentences...",us=((t={},a={})=>(a.locale??s(),_s())),ms=()=>"A SaaS boilerplate built with TanStack Start, Cloudflare Workers, Better Auth, and Drizzle ORM. Helps indie developers ship a production-ready app over a weekend.",gs=((t={},a={})=>(a.locale??s(),ms())),xs=()=>"SaaS Tagline Generator",hs=((t={},a={})=>(a.locale??s(),xs())),fs=()=>"Translate",bs=((t={},a={})=>(a.locale??s(),fs())),js=()=>"Powered by Cloudflare Workers AI to translate text across many languages.",vs=((t={},a={})=>(a.locale??s(),js())),ys=()=>"The translation will appear here.",Ns=((t={},a={})=>(a.locale??s(),ys())),Ss=()=>"Failed to translate text.",ws=((t={},a={})=>(a.locale??s(),Ss())),zs=()=>"From",ks=((t={},a={})=>(a.locale??s(),zs())),Cs=()=>"Translation",Ps=((t={},a={})=>(a.locale??s(),Cs())),Is=()=>"Translating...",As=((t={},a={})=>(a.locale??s(),Is())),Ms=()=>"Type or paste text to translate...",Ts=((t={},a={})=>(a.locale??s(),Ms())),Es=()=>"Source and target languages must be different.",Fs=((t={},a={})=>(a.locale??s(),Es())),Us=()=>"Cloudflare Workers AI lets developers run machine learning models on the edge.",Ds=((t={},a={})=>(a.locale??s(),Us())),Ls=()=>"Source text",Gs=((t={},a={})=>(a.locale??s(),Ls())),Os=()=>"Swap languages",Bs=((t={},a={})=>(a.locale??s(),Os())),$s=()=>"Translation",Rs=((t={},a={})=>(a.locale??s(),$s())),Ws=()=>"To",qs=((t={},a={})=>(a.locale??s(),Ws())),Ks=()=>"Synthesize Speech",Vs=((t={},a={})=>(a.locale??s(),Ks())),Hs=()=>"per request",Ys=((t={},a={})=>(a.locale??s(),Hs())),Js=()=>"Powered by Cloudflare Workers AI to synthesize natural speech from text input.",Xs=((t={},a={})=>
1(a.locale??s(),Js())),Qs=()=>"The generated audio will appear here.",Zs=((t={},a={})=>(a.locale??s(),Qs())),en=()=>"Failed to synthesize speech.",an=((t={},a={})=>(a.locale??s(),en())),tn=()=>"Text",sn=((t={},a={})=>(a.locale??s(),tn())),nn=()=>"Audio",rn=((t={},a={})=>(a.locale??s(),nn())),ln=()=>"Synthesizing...",on=((t={},a={})=>(a.locale??s(),ln())),cn=()=>"Type or paste the text you want to read aloud...",pn=((t={},a={})=>(a.locale??s(),cn())),dn=()=>"Hello from Cloudflare Workers AI. This demo turns text into natural-sounding speech in just one API call.",_n=((t={},a={})=>(a.locale??s(),dn())),un=()=>"Text to Speech",mn=((t={},a={})=>(a.locale??s(),un())),gn=()=>"Voice",xn=((t={},a={})=>(a.locale??s(),gn()));const hn=[["path",{d:"M7 10h14l-4 -4",key:"svg-0"}],["path",{d:"M17 14h-14l4 4",key:"svg-1"}]],fn=L("outline","arrows-exchange","ArrowsExchange",hn);const bn=[["path",{d:"M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5",key:"svg-0"}],["path",{d:"M5 10a7 7 0 0 0 14 0",key:"svg-1"}],["path",{d:"M8 21l8 0",key:"svg-2"}],["path",{d:"M12 17l0 4",key:"svg-3"}]],jn=L("outline","microphone","Microphone",bn);const vn=[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M11 20h-4a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v4",key:"svg-1"}],["path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-2"}],["path",{d:"M14 14l1 -1c.31 -.298 .644 -.497 .987 -.596",key:"svg-3"}],["path",{d:"M18.42 15.61a2.1 2.1 0 0 1 2.97 2.97l-3.39 3.42h-3v-3l3.42 -3.39",key:"svg-4"}]],yn=L("outline","photo-edit","PhotoEdit",vn);const Nn=[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M6 13l2.644 -2.644a1.21 1.21 0 0 1 1.712 0l3.644 3.644",key:"svg-1"}],["path",{d:"M13 13l1.644 -1.644a1.21 1.21 0 0 1 1.712 0l1.644 1.644",key:"svg-2"}],["path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2",key:"svg-3"}],["path",{d:"M4 16v2a2 2 0 0 0 2 2h2",key:"svg-4"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"svg-5"}],["path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2",key:"svg-6"}]],Sn=L("outline","photo-scan","PhotoScan",Nn);const wn=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],Pe=L("outline","upload","Upload",wn);const zn=[["path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3",key:"svg-0"}],["path",{d:"M15 6l3 3",key:"svg-1"}],["path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-2"}],["path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-3"}]],kn=L("outline","wand","Wand",zn),Cn=P({method:"POST"}).handler(I("187e529cef0f3031f66cb9ad7c4e6c750801c48be9a735e8ad181bb0a481aa49")),Pn=P({method:"POST"}).handler(I("1460ae44e155c8dfecd6ceee24db8a80cf69b7802860fdd62e18a67c8b6e6704")),In=P({method:"POST"}).handler(I("8f87b9b75a7c2d7fb4abff62475835586541d2d14874a3a42e699a6f45fedd16")),An=P({method:"POST"}).handler(I("dead70b057543f333c2f7b5c04e801fa0c491907f3dbc3e60f89bcb9c171c67e")),Mn=P({method:"POST"}).handler(I("3265ad4bc7d0b71fac892879d87de9a2580aefd06396a4669167b7fd68a71494")),Tn=P({method:"POST"}).handler(I("becedfafb9962dc48114658bdba43d852f72733856e7d99d711b3b750735a273")),En=P({method:"POST"}).handler(I("70a7cf203b4794de95cf7c27fd80881c2dd37c08787ebc75fe059ee0ba5d8287")),Fn=P({method:"POST"}).handler(I("d840745e32a78659650dc65d87b6fd58d92806852028942a629730b71a101fa6")),q={summarization:"@cf/meta/llama-3.2-3b-instruct",tagline:"@cf/meta/llama-3.2-3b-instruct",translation:"@cf/meta/m2m100-1.2b",textToSpeech:"@cf/deepgram/aura-1",imageCaption:"@cf/llava-hf/llava-1.5-7b-hf"},H=["@cf/black-forest-labs/flux-1-schnell","@cf/bytedance/stable-diffusion-xl-lightning","@cf/lykon/dreamshaper-8-lcm"],Un=H[0],Dn=["fal-ai/flux/schnell","fal-ai/nano-banana","openai/gpt-image-2"],Ie="fal-ai/nano-banana",Ln="fal-ai/nano-banana/edit",Gn="openai/gpt-image-2",On=1e6;function Bn(){const t=[ea(),ta(),na(),ia()],a=r.useRef(null),[m,g]=r.useState(),[p,d]=r.useState(),[_,u]=r.useState(),[x,l]=r.useState(t[0]),[v,o]=r.useState(""),[y,j]=r.useState(),[w,i]=r.useState(!1);function k(c){const f=c.target.files?.[0];if(!f)return;if(!f.type.startsWith("image/")){j(ue());return}
1if(f.size>On){j(`Image is too large (${(f.size/1024).toFixed(0)} KB). ${ce()}`);return}const D=new FileReader;D.onloadend=()=>{const K=D.result;g(K),d(K.replace(/^data:image\/[^;]+;base64,/,"")),u({name:f.name,size:f.size}),o(""),j(void 0)},D.onerror=()=>j(de()),D.readAsDataURL(f)}async function n(){if(p){j(void 0),o(""),i(!0);try{const c=await Fn({data:{imageBase64:p,prompt:x}});o(c.description)}catch(c){j(c instanceof Error?c.message:Ke())}finally{i(!1)}}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"size-5 text-primary"}),ma()]}),e.jsxs(E,{children:[Oe()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:q.imageCaption})]})]}),e.jsx(F,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:He()}),e.jsx("input",{ref:a,type:"file",accept:"image/*",className:"hidden",onChange:k}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>a.current?.click(),children:[e.jsx(Pe,{className:"mr-1 size-4"}),_?ie():_e()]}),_&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_.name," · ",(_.size/1024).toFixed(0)," KB"]})]}),e.jsx("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border bg-muted/30",children:m?e.jsx("img",{src:m,alt:oa(),className:"size-full object-cover"}):e.jsx("span",{className:"px-4 text-center text-sm text-muted-foreground",children:We()})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-caption-prompt",children:pa()}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(c=>{const f=x===c;return e.jsx("button",{type:"button",onClick:()=>l(c),className:f?"rounded-full border border-primary bg-primary px-3 py-1 text-xs text-primary-foreground":"rounded-full border border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted",children:c.length>28?`${c.slice(0,28)}â¦`:c},c)})}),e.jsx(U,{id:"ai-caption-prompt",rows:3,value:x,onChange:c=>l(c.target.value)}),e.jsx(S,{type:"button",onClick:n,disabled:w||!p||x.trim().length===0,children:w?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),Qe()]}):Le()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:Je()}),e.jsx("div",{className:"min-h-[160px] rounded-md border bg-muted/30 p-4 text-sm leading-relaxed whitespace-pre-wrap",children:y?e.jsx("span",{className:"text-destructive",children:y}):w?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(z,{className:"size-4 animate-spin"}),_a()]}):v||e.jsx("span",{className:"text-muted-foreground",children:$e()})})]})]})]})})]})}const Ae=[{value:H[0],label:"Flux.1 Schnell",hint:"Default · 12B distilled flow transformer"},{value:H[1],label:"SDXL Lightning",hint:"Lightning-fast 1024px generations",beta:!0},{value:H[2],label:"DreamShaper 8 LCM",hint:"Photorealistic Stable Diffusion fine-tune"}],te=Ae.map(t=>({...t,label:t.beta?`${t.label} (Beta)`:t.label}));function $n(){const t=[{id:"astronaut-panda",label:be(),prompt:je()},{id:"cyberpunk-tokyo",label:ve(),prompt:ye()},{id:"watercolor-village",label:Ne(),prompt:Se()},{id:"product-earbuds",label:we(),prompt:ze()},{id:"pixel-dragon",label:ke(),prompt:Ce()}],[a,m]=r.useState(t[0].id),[g,p]=r.useState(t[0].prompt),[d,_]=r.useState(Un),[u,x]=r.useState(),[l,v]=r.useState(),[o,y]=r.useState(!1),j=Ae.find(n=>n.value===d);function w(n){const c=t.find(f=>f.id===n);c&&(m(n),p(c.prompt))}function i(n){p(n);const c=t.find(f=>f.prompt===n);m(c?.id??null)}async function k(){v(void 0),x(void 0),y(!0);try{const n=await En({data:{prompt:g,model:d}});x(n.imageUrl)}catch(n){v(n instanceof Error?n.message:xe())}finally{y(!1)}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"size-5 text-primary"}),Pt()]}),e.jsxs(E,{children:[Pa()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:d})," "]})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"mb-4 space-y-1.5",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:pe()}),e.jsxs(G,{items:te,value:d,onValueChange:n=>{n&&_(n)},children:[e.jsx(O,{className:"w-72",size:"sm",children:e.jsx(B,{})}),e.jsx($,{children:te.map(n=>e.jsx(R,{value:n.value,label:n.label,children:n.label},n.value))})]}),j&&e.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-cf-image-prompt",children:re()}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(n=>{const c=a===n.id;return e.jsx("button",{type:"button",onClick:()=>w(n.id),className:J("rounded-full border px-3 py-1 text-xs transition-colors",c?"border-primary bg-primary text-primary-foreground":"border-border bg-muted/40 text-muted-foreground hover:bg-muted"),children:n.label},n.id)})}),e.jsx(U,{id:"ai-cf-image-prompt",rows:6,value:g,onChange:n=>i(n.target.value),placeholder:fe()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.length," ",W(),a===null&&` · ${le()}`]}),e.jsx(S,{type:"button",onClick:k,disabled:o||g.trim().length<3,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),he()]}):me()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(h,{children:ee()}),u&&!o&&e.jsxs(S,{type:"button",size:"sm",variant:"outline",onClick:()=>Q(u,`cf-${d.replace(/[@/]/g,"-")}-${Date.now()}.jpg`),children:[e.jsx(X,{className:"mr-1 size-4"}),Z()]})]}),e.jsx("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border bg-muted/30",children:l?e.jsx("span",{className:"px-4 text-center text-sm text-destructive",children:l}):o?e.jsx(z,{className:"size-8 animate-spin text-muted-foreground"}):u?e.jsx("img",{src:u,alt:oe(),className:"size-full object-cover"}):e.jsx("span",{className:"px-4 text-center text-sm text-muted-foreground",children:ge()})})]})]})]})]})}
1const Y=[{value:Ie,label:"Nano Banana",hint:"Google's image model · ~$0.039 / image"},{value:Dn[0],label:"Flux Schnell",hint:"Fast & cheap · ~$0.003 / image"},{value:Gn,label:"GPT Image 2",hint:"OpenAI's premium model · sharp text & photoreal · slower (~30s, quality=low)"}];function Rn(){const t=[{id:"astronaut-panda",label:be(),prompt:je()},{id:"cyberpunk-tokyo",label:ve(),prompt:ye()},{id:"watercolor-village",label:Ne(),prompt:Se()},{id:"product-earbuds",label:we(),prompt:ze()},{id:"pixel-dragon",label:ke(),prompt:Ce()}],[a,m]=r.useState(t[0].id),[g,p]=r.useState(t[0].prompt),[d,_]=r.useState(Ie),[u,x]=r.useState(),[l,v]=r.useState(),[o,y]=r.useState(!1),j=Y.find(n=>n.value===d);function w(n){const c=t.find(f=>f.id===n);c&&(m(n),p(c.prompt))}function i(n){p(n);const c=t.find(f=>f.prompt===n);m(c?.id??null)}async function k(){v(void 0),x(void 0),y(!0);try{const n=await An({data:{prompt:g,model:d}});x(n.imageUrl)}catch(n){v(n instanceof Error?n.message:xe())}finally{y(!1)}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"size-5 text-primary"}),At()]}),e.jsxs(E,{children:[Aa()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:d})," "]})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"mb-4 space-y-1.5",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:pe()}),e.jsxs(G,{items:Y,value:d,onValueChange:n=>{n&&_(n)},children:[e.jsx(O,{className:"w-72",size:"sm",children:e.jsx(B,{})}),e.jsx($,{children:Y.map(n=>e.jsx(R,{value:n.value,label:n.label,children:n.label},n.value))})]}),j&&e.jsx("p",{className:"text-xs text-muted-foreground",children:j.hint})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-image-prompt",children:re()}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(n=>{const c=a===n.id;return e.jsx("button",{type:"button",onClick:()=>w(n.id),className:J("rounded-full border px-3 py-1 text-xs transition-colors",c?"border-primary bg-primary text-primary-foreground":"border-border bg-muted/40 text-muted-foreground hover:bg-muted"),children:n.label},n.id)})}),e.jsx(U,{id:"ai-image-prompt",rows:6,value:g,onChange:n=>i(n.target.value),placeholder:fe()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.length," ",W(),a===null&&` · ${le()}`]}),e.jsx(S,{type:"button",onClick:k,disabled:o||g.trim().length<3,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),he()]}):me()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(h,{children:ee()}),u&&!o&&e.jsxs(S,{type:"button",size:"sm",variant:"outline",onClick:()=>Q(u,`fal-${d.replace(/[/]/g,"-")}-${Date.now()}.jpg`),children:[e.jsx(X,{className:"mr-1 size-4"}),Z()]})]}),e.jsx("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border bg-muted/30",children:l?e.jsx("span",{className:"px-4 text-center text-sm text-destructive",children:l}):o?e.jsx(z,{className:"size-8 animate-spin text-muted-foreground"}):u?e.jsx("img",{src:u,alt:oe(),className:"size-full object-cover"}):e.jsx("span",{className:"px-4 text-center text-sm text-muted-foreground",children:ge()})})]})]})]})]})}const Wn=1e6;function qn(){const t=[{id:"caricature",label:Ya(),prompt:Xa()},{id:"pixar",label:Za(),prompt:at()},{id:"anime",label:st(),prompt:rt()}],a=r.useRef(null),[m,g]=r.useState(),[p,d]=r.useState(),[_,u]=r.useState(),[x,l]=r.useState(t[0].id),[v,o]=r.useState(t[0].prompt),[y,j]=r.useState(),[w,i]=r.useState(),[k,n]=r.useState(!1);function c(b){const N=t.find(C=>C.id===b);N&&(l(b),o(N.prompt))}function f(b){o(b);const N=t.find(C=>C.prompt===b);l(N?.id??null)}function D(b){const N=b.target.files?.[0];if(!N)return;if(!N.type.startsWith("image/")){i(ue());return}if(N.size>Wn){i(`Image is too large (${(N.size/1024).toFixed(0)} KB). ${ce()}`);return}const C=new FileReader;C.onloadend=()=>{const ae=C.result;g(ae),d(ae),u({name:N.name,size:N.size}),j(void 0),i(void 0)},C.onerror=()=>i(de()),C.readAsDataURL(N)}async function K(){if(p){i(void 0),j(void 0),n(!0);try{const b=await Mn({data:{imageBase64:p,prompt:v}});j(b.imageUrl)}catch(b){i(b instanceof Error?b.message:Ba())}finally{n(!1)}}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"size-5 text-primary"}),ut()]}),e.jsxs(E,{children:[Fa()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:Ln})]})]}),e.jsx(F,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:Ra()}),e.jsx("input",{ref:a,type:"file",accept:"image/*",className:"hidden",onChange:D}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>a.current?.click(),children:[e.jsx(Pe,{className:"mr-1 size-4"}),_?ie():_e()]}),_&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_.name," · ",(_.size/1024).toFixed(0)," KB"]}
1)]}),e.jsx("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border bg-muted/30",children:m?e.jsx("img",{src:m,alt:lt(),className:"size-full object-cover"}):e.jsx("span",{className:"px-4 text-center text-sm text-muted-foreground",children:Ga()})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-image-edit-prompt",children:ct()}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(b=>{const N=x===b.id;return e.jsx("button",{type:"button",onClick:()=>c(b.id),className:J("rounded-full border px-3 py-1 text-xs transition-colors",N?"border-primary bg-primary text-primary-foreground":"border-border bg-muted/40 text-muted-foreground hover:bg-muted"),children:b.label},b.id)})}),e.jsx(U,{id:"ai-image-edit-prompt",rows:4,value:v,onChange:b=>f(b.target.value),placeholder:Va()}),e.jsx(S,{type:"button",onClick:K,disabled:k||!p||v.trim().length<5,children:k?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),qa()]}):Ta()})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(h,{children:ee()}),y&&!k&&e.jsxs(S,{type:"button",size:"sm",variant:"outline",onClick:()=>Q(y,`avatar-stylized-${Date.now()}.png`),children:[e.jsx(X,{className:"mr-1 size-4"}),Z()]})]}),e.jsx("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border bg-muted/30",children:w?e.jsx("span",{className:"px-4 text-center text-sm text-destructive",children:w}):k?e.jsx(z,{className:"size-8 animate-spin text-muted-foreground"}):y?e.jsx("img",{src:y,alt:dt(),className:"size-full object-cover"}):e.jsx("span",{className:"px-4 text-center text-sm text-muted-foreground",children:Da()})})]})]})})]})}function Kn(){const[t,a]=r.useState(Vt().trim()),[m,g]=r.useState(""),[p,d]=r.useState(),[_,u]=r.useState(!1);async function x(){d(void 0),g(""),u(!0);try{const l=await Cn({data:{text:t}});g(l.summary)}catch(l){d(l instanceof Error?l.message:Gt())}finally{u(!1)}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"size-5 text-primary"}),Xt()]}),e.jsxs(E,{children:[Ft()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:q.summarization})]})]}),e.jsx(F,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-summarization-input",children:Yt()}),e.jsx(U,{id:"ai-summarization-input",rows:10,value:t,onChange:l=>a(l.target.value),placeholder:qt()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," ",W()]}),e.jsx(S,{type:"button",onClick:x,disabled:_||t.trim().length<50,children:_?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),Rt()]}):Tt()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:Bt()}),e.jsx("div",{className:"min-h-[256px] rounded-md border bg-muted/30 p-4 text-sm leading-relaxed whitespace-pre-wrap",children:p?e.jsx("span",{className:"text-destructive",children:p}):m||e.jsx("span",{className:"text-muted-foreground",children:Dt()})})]})]})})]})}function Vn(){const[t,a]=r.useState(gs()),[m,g]=r.useState([]),[p,d]=r.useState(),[_,u]=r.useState(!1);async function x(){d(void 0),g([]),u(!0);try{const l=await In({data:{product:t}});g(l.taglines)}catch(l){d(l instanceof Error?l.message:rs())}finally{u(!1)}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"size-5 text-primary"}),hs()]}),e.jsxs(E,{children:[as()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:q.tagline})]})]}),e.jsx(F,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-tagline-input",children:ls()}),e.jsx(U,{id:"ai-tagline-input",rows:8,value:t,onChange:l=>a(l.target.value),placeholder:us()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," ",W()]}),e.jsx(S,{type:"button",onClick:x,disabled:_||t.trim().length<10,children:_?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),ds()]}):Zt()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:cs()}),e.jsx("div",{className:"min-h-[208px] rounded-md border bg-muted/30 p-4 text-sm leading-relaxed",children:p?e.jsx("span",{className:"text-destructive",children:p}):m.length>0?e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:m.map(l=>e.jsx("li",{children:l},l))}):e.jsx("span",{className:"text-muted-foreground",children:ss()})})]})]})})]})}const V=[{value:"english",label:"English"},{value:"chinese",label:"䏿 Chinese"},{value:"french",label:"Français French"},{value:"german",label:"Deutsch German"},{value:"spanish",label:"Español Spanish"},{value:"japanese",label:"æ¥æ¬èª Japanese"},{value:"korean",label:"Korean"},{value:"russian",label:"Ð ÑÑÑкий Russian"},{value:"portuguese",label:"Português Portuguese"},{value:"arabic",label:"Ø§ÙØ¹Ø±Ø¨ÙØ© Arabic"}];function Hn(){const[t,a]=r.useState(Ds()),[m,g]=r.useState("english"),[p,d]=r.useState("chinese"),[_,u]=r.useState(""),[x,l]=r.useState(),[v,o]=r.useState(!1);function y(){g(p),d(m),a(_||t),u("")}async function j(){l(void 0),u(""),o(!0);try{const i=await Pn({data:{text:t,sourceLang:m,targetLang:p}});u(i.translatedText)}catch(i){l(i instanceof Error?i.message:ws())}finally{o(!1)}}const w=m===p;return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"size-5 text-primary"}),Rs()]}),e.jsxs(E,{children:[vs()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:q.translation})]})]}),e.jsxs(F,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:ks()}),e.jsxs(G,{items:V,value:m,onValueChange:i=>{i&&g(i)},children:[e.jsx(O,{className:"w-44",size:"sm",children:e.jsx(B,{})}),e.jsx($,{children:V.map(i=>e.jsx(R,{value:i.value,label:i.label,children:i.label},i.value))})]})]}),e.jsx(S,{type:"button",variant:"outline",size:"icon",className:"mb-0.5 shrink-0",onClick:y,"aria-label":Bs(),children:e.jsx(fn,{className:"size-4"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:qs()}),e.jsxs(G,{items:V,value:p,onValueChange:i=>{i&&d(i)},children:[e.jsx(O,{className:"w-44",size:"sm",children:e.jsx(B,{})}),e.jsx($,{children:V.map(i=>e.jsx(R,{value:i.value,label:i.label,children:i.label},i.value))})]})]})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-translation-input",children:Gs()}),e.jsx(U,{id:"ai-translation-input",rows:6,value:t,onChange:i=>a(i.target.value),placeholder:Ts()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," ",W()]}),e.jsx(S,{type:"button",onClick:j,disabled:v||w||t.trim().length===0,children:v?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),As()]}):bs()}),w&&e.jsx("p",{className:"text-xs text-destructive",children:Fs()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:Ps()}),e.jsx("div",{className:"min-h-[160px] rounded-md border bg-muted/30 p-4 text-sm leading-relaxed whitespace-pre-wrap",children:x?e.jsx("span",{className:"text-destructive",children:x}):_||e.jsx("span",{className:"text-muted-foreground",children:Ns()})})]})]})]})]})}const se=[{value:"asteria",label:"Asteria · Female (US)"},{value:"luna",label:"Luna · Female (US)"},{value:"stella",label:"Stella · Female (US)"},{value:"athena",label:"Athena · Female (UK)"},{value:"hera",label:"Hera · Female (US)"},{value:"angus",label:"Angus · Male (IE)"},{value:"arcas",label:"Arcas · Male (US)"},{value:"orion",label:"Orion · Male (US)"},{value:"orpheus",label:"Orpheus · Male (US)"},{value:"perseus",label:"Perseus · Male (US)"},{value:"helios",label:"Helios · Male (UK)"},{value:"zeus",label:"Zeus · Male (US)"}];function Yn(){const[t,a]=r.useState(_n()),[m,g]=r.useState("asteria"),[p,d]=r.useState(),[_,u]=r.useState(),[x,l]=r.useState(!1);async function v(){u(void 0),d(void 0),l(!0);try{const o=await Tn({data:{text:t,speaker:m}});d(o.audioUrl)}catch(o){u(o instanceof Error?o.message:an())}finally{l(!1)}}return e.jsxs(A,{children:[e.jsxs(M,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(jn,{className:"size-5 text-primary"}),mn()]}),e.jsxs(E,{children:[Xs()," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:q.textToSpeech})]})]}),e.jsxs(F,{children:[e.jsx("div",{className:"mb-4 flex flex-wrap items-end gap-3",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-xs text-muted-foreground",children:xn()}),e.jsxs(G,{items:se,value:m,onValueChange:o=>{o&&g(o)},children:[e.jsx(O,{className:"w-56",size:"sm",children:e.jsx(B,{})}),e.jsx($,{children:se.map(o=>e.jsx(R,{value:o.value,label:o.label,children:o.label},o.value))})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"ai-tts-input",children:sn()}),e.jsx(U,{id:"ai-tts-input",rows:6,value:t,onChange:o=>a(o.target.value),placeholder:pn()}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.length," characters · ~$",(t.length/1e3*.015).toFixed(4)," ",Ys()]}),e.jsx(S,{type:"button",onClick:v,disabled:x||t.trim().length===0,children:x?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-1 size-4 animate-spin"}),on()]}):Vs()})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:rn()}),e.jsx("div",{className:"flex min-h-[160px] w-full items-center justify-center rounded-md border bg-muted/30 p-4",children:_?e.jsx("span",{className:"text-center text-sm text-destructive",children:_}):x?e.jsx(z,{className:"size-8 animate-spin text-muted-foreground"}):p?e.jsx("audio",{controls:!0,src:p,className:"w-full",children:e.jsx("track",{kind:"captions"})}):e.jsx("span",{className:"text-center text-sm text-muted-foreground",children:Zs()})})]})]})]})]})}function nr(){return e.jsxs("div",{className:"flex min-h-svh flex-col",children:[e.jsx(Ue,{showBack:!0}),e.jsx(Fe,{className:"py-16 px-4",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-10 pb-16",children:[e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:Ee()}),e.jsx("p",{className:"text-lg text-muted-foreground",children:za()})]}),e.jsx("section",{id:"text-summarization",className:"scroll-mt-20",children:e.jsx(Kn,{})}),e.jsx("section",{id:"translation",className:"scroll-mt-20",children:e.jsx(Hn,{})}),e.jsx("section",{id:"tagline-generator",className:"scroll-mt-20",children:e.jsx(Vn,{})}),e.jsx("section",{id:"text-to-speech",className:"scroll-mt-20",children:e.jsx(Yn,{})}),e.jsx("section",{id:"image-captioning",className:"scroll-mt-20",children:e.jsx(Bn,{})}),e.jsx("section",{id:"image-generator-cloudflare",className:"scroll-mt-20",children:e.jsx($n,{})}),e.jsx("section",{id:"image-generator-fal",className:"scroll-mt-20",children:e.jsx(Rn,{})}),e.jsx("section",{id:"image-editing",className:"scroll-mt-20",children:e.jsx(qn,{})})]})})]})}export{nr as component};
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.