1import{a as n,j as e}from"./vendor-react-5BUW_FQY.js";import{m as L}from"./vendor-motion-BMdIFYxW.js";import{bM as P,a as E,X as $,L as G,C as z,aQ as B}from"./vendor-icons-C_vOXKuu.js";const x=[{code:"en",label:"English",flag:"ðºð¸"},{code:"es",label:"Spanish",flag:"ðªð¸"},{code:"fr",label:"French",flag:"ð«ð·"},{code:"pt",label:"Portuguese",flag:"ð§ð·"},{code:"de",label:"German",flag:"ð©ðª"},{code:"it",label:"Italian",flag:"ð®ð¹"},{code:"nl",label:"Dutch",flag:"ð³ð±"},{code:"ru",label:"Russian",flag:"ð·ðº"},{code:"zh",label:"Chinese",flag:"ð¨ð³"},{code:"ja",label:"Japanese",flag:"ð¯ðµ"},{code:"ko",label:"Korean",flag:"ð°ð·"},{code:"ar",label:"Arabic",flag:"ð¸ð¦"},{code:"hi",label:"Hindi",flag:"ð®ð³"},{code:"tr",label:"Turkish",flag:"ð¹ð·"},{code:"pl",label:"Polish",flag:"ðµð±"},{code:"vi",label:"Vietnamese",flag:"ð»ð³"},{code:"th",label:"Thai",flag:"ð¹ð"},{code:"sv",label:"Swedish",flag:"ð¸ðª"},{code:"uk",label:"Ukrainian",flag:"ðºð¦"},{code:"id",label:"Indonesian",flag:"ð®ð©"},{code:"el",label:"Greek",flag:"ð¬ð·"},{code:"cs",label:"Czech",flag:"ð¨ð¿"},{code:"ro",label:"Romanian",flag:"ð·ð´"},{code:"hu",label:"Hungarian",flag:"ððº"},{code:"he",label:"Hebrew",flag:"ð®ð±"},{code:"fa",label:"Persian",flag:"ð®ð·"},{code:"ms",label:"Malay",flag:"ð²ð¾"},{code:"tl",label:"Filipino",flag:"ðµð"},{code:"sw",label:"Swahili",flag:"ð°ðª"},{code:"bn",label:"Bengali",flag:"ð§ð©"}],R="kairo-trans-lang";function K(){try{return sessionStorage.getItem(R)??"es"}catch{return"es"}}function j(r){try{sessionStorage.setItem(R,r)}catch{}}function U(r){const a=r.toLowerCase();return/\b(spanish|español)\b/.test(a)?"es":/\b(french|français)\b/.test(a)?"fr":/\b(german|deutsch)\b/.test(a)?"de":/\b(italian|italiano)\b/.test(a)?"it":/\b(portuguese|português)\b/.test(a)?"pt":/\b(chinese|mandarin|䏿)\b/.test(a)?"zh":/\b(japanese|æ¥æ¬èª)\b/.test(a)?"ja":/\b(korean|íêµì´)\b/.test(a)?"ko":/\b(arabic|عربÙ)\b/.test(a)?"ar":/\b(hindi|हिà¤à¤¦à¥)\b/.test(a)?"hi":/\b(russian|ÑÑÑÑкий)\b/.test(a)?"ru":/\b(turkish|türkçe)\b/.test(a)?"tr":null}function D(r){const a=/translate\s+["']?(.+?)["']?\s+(?:to|into)\s+\w+/i.exec(r);if(a)return a[1].trim();const o=/how\s+(?:do\s+you\s+say|to\s+say)\s+["']?(.+?)["']?\s+in\s+\w+/i.exec(r);return o?o[1].trim():""}async function M(r,a,o){if(!r.trim())return"";const t=`${a}|${o}`,u=`https://api.mymemory.translated.net/get?q=${encodeURIComponent(r)}&langpair=${t}`,l=await fetch(u);if(!l.ok)throw new Error("Translation API error");const i=await l.json();if(i.responseStatus!==200)throw new Error(i.responseDetails||"Translation failed");return i.responseData.translatedText||""}function I({value:r,onChange:a,exclude:o}){return e.jsx("select",{value:r,onChange:t=>a(t.target.value),className:"flex-1 rounded-xl px-3 py-2 text-sm font-semibold outline-none appearance-none cursor-pointer",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.85)"},children:x.filter(t=>t.code!==o).map(t=>e.jsxs("option",{value:t.code,style:{background:"#111"},children:[t.flag," ",t.label]},t.code))})}function X({query:r}){const[a,o]=n.useState("en"),[t,u]=n.useState(()=>{const s=U(r||"");return s?(j(s),s):K()}),[l,i]=n.useState(()=>D(r||"")),[c,g]=n.useState(""),[w,N]=n.useState(!1),[v,f]=n.useState(""),[A,k]=n.useState(!1),b=n.useRef(null),p=500,m=n.useCallback(async(s,d,h)=>{if(!s.trim()){g(""),f("");return}N(!0),f("");try{const S=await M(s,d,h);g(S)}catch{f("Translation failed â check your connection"),g("")}finally{N(!1)}},[]);n.useEffect(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{m(l,a,t)},600),()=>{b.current&&clearTimeout(b.current)}),[l,a,t,m]),n.useEffect(()=>{l&&m(l,a,t)},[]);const F=()=>{const s=t,d=a;o(s),u(d),j(d),i(c),g(l)},T=(s,d)=>{if(!s||!("speechSynthesis"in window))return;const h=new SpeechSynthesisUtterance(s);h.lang=d,window.speechSynthesis.speak(h)},H=()=>{c&&(navigator.clipboard.writeText(c).catch(()=>{}),k(!0),setTimeout(()=>k(!1),1800))},y=x.find(s=>s.code===a),C=x.find(s=>s.code===t);return e.jsxs(L.div,{initial:{opacity:0,y:6}
1,animate:{opacity:1,y:0},className:"rounded-2xl overflow-hidden w-full",style:{background:"rgba(15,17,26,0.95)",border:"1px solid rgba(255,255,255,0.1)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255,255,255,0.07)"},children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"rgba(56,189,248,0.8)"},children:"ð Kairo Translator"}),e.jsxs("span",{className:"text-[10px]",style:{color:"rgba(255,255,255,0.25)"},children:[x.length," languages"]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4 pb-3",children:[e.jsx(I,{value:a,onChange:o,exclude:t}),e.jsx(L.button,{whileTap:{rotate:180,scale:.9},onClick:F,className:"shrink-0 p-2 rounded-xl hover:bg-white/5 transition-colors",style:{border:"1px solid rgba(255,255,255,0.1)"},children:e.jsx(P,{className:"w-4 h-4 text-sky-400"})}),e.jsx(I,{value:t,onChange:s=>{u(s),j(s)},exclude:a})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-0",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"relative",style:{borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-1.5",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[e.jsxs("span",{className:"text-xs font-semibold",style:{color:"rgba(255,255,255,0.35)"},children:[y?.flag," ",y?.label]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>T(l,a),className:"p-1 rounded hover:bg-white/5 transition-colors",children:e.jsx(E,{className:"w-3 h-3 text-gray-600"})}),l&&e.jsx("button",{onClick:()=>{i(""),g("")},className:"p-1 rounded hover:bg-white/5 transition-colors",children:e.jsx($,{className:"w-3 h-3 text-gray-600"})})]}),e.jsx("textarea",{value:l,onChange:s=>{s.target.value.length<=p&&i(s.target.value)},placeholder:`Type in ${y?.label}...`,className:"w-full resize-none text-sm text-white placeholder-gray-600 outline-none p-3 min-h-[120px]",style:{background:"transparent"}}),e.jsx("div",{className:"px-3 pb-2 text-right",children:e.jsxs("span",{className:"text-[10px]",style:{color:l.length>p*.9?"rgba(251,146,60,0.7)":"rgba(255,255,255,0.2)"},children:[l.length,"/",p]})})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-1.5",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[e.jsxs("span",{className:"text-xs font-semibold",style:{color:"rgba(255,255,255,0.35)"},children:[C?.flag," ",C?.label]}),e.jsx("div",{className:"flex-1"}),w&&e.jsx(G,{className:"w-3 h-3 text-sky-400 animate-spin"}),e.jsx("button",{onClick:()=>T(c,t),className:"p-1 rounded hover:bg-white/5 transition-colors",disabled:!c,children:e.jsx(E,{className:"w-3 h-3 text-gray-600"})}),e.jsx("button",{onClick:H,className:"p-1 rounded hover:bg-white/5 transition-colors",disabled:!c,children:A?e.jsx(z,{className:"w-3 h-3 text-green-400"}):e.jsx(B,{className:"w-3 h-3 text-gray-600"})})]}),e.jsx("div",{className:"p-3 min-h-[120px]",children:v?e.jsx("p",{className:"text-xs text-red-400/70",children:v}):c?e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"rgba(255,255,255,0.85)",fontFamily:"inherit"},children:c}):w?e.jsx("div",{className:"space-y-2 pt-1",children:[70,90,55].map((s,d)=>e.jsx("div",{className:"h-2 rounded animate-pulse",style:{background:"rgba(255,255,255,0.06)",width:`${s}%`}},d))}):e.jsx("p",{className:"text-sm",style:{color:"rgba(255,255,255,0.2)"},children:"Translation appears here"})})]})]}),e.jsx("div",{className:"px-4 py-3 flex flex-wrap gap-2",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:["Hello","Thank you","How much?","Where is...?","I need help"].map(s=>e.jsx("button",{onClick:()=>i(s),className:"text-xs px-2.5 py-1 rounded-lg transition-all hover:brightness-125",style:{background:"rgba(56,189,248,0.08)",border:"1px solid rgba(56,189,248,0.15)",color:"rgba(56,189,248,0.7)"},children:s},s))})]})}export{X as KairoTranslator};
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.