PageSourceSearch

https://skooltranslate.com/assets/index-DK2TlWJy.js

js skooltranslate.com collected 2026-10-02 01:43:42 UTC 51,472 bytes, 11 lines download raw bytes

1import{c as dt,r as o,j as e,f as Mt,X as Et,T as ke,d as $t,R as tt,b as ue}from"./index-kf0RRqQ6.js";import{u as _e}from"./useTranslation-Bw2i4kRp.js";import{R as oe}from"./RealtimeIcon-Cu4lwUmL.js";import{V as st}from"./VoiceIcon-BcdWKhBk.js";import{S as Ot}from"./SecurityIcon-D6_HABwK.js";import{D as Rt}from"./DashboardIcon-DXJrquNS.js";import{S as at}from"./StarIcon-bC0hxQhr.js";import{T as ge}from"./TrendingUpIcon-DW1zsLtS.js";import{B as I}from"./Button-C9TnB3_F.js";import{C as O,a as Q,b as Z,d as R}from"./Card-Brqmo-pU.js";import{B as be}from"./Badge-DPADZJoE.js";import{D as rt}from"./DashboardLayout-C_esy_v_.js";import{R as Ft,C as Pt,X as Vt,Y as Ut,T as zt}from"./CartesianChart-DQ6x0nji.js";import{A as Ht,a as nt}from"./AreaChart-w8S-GjOB.js";import{u as Bt}from"./useProfile-CM4zkS83.js";import{g as ot}from"./subscriptionPlans-CrSiI0R5.js";import{f as Yt,a as Kt}from"./formatters-pswLO2J9.js";import{C as Gt}from"./ConfirmDialog-lcrjfUUW.js";import{a as Ne,g as qt,f as Wt}from"./api-BZSkX9IR.js";import{u as Xt}from"./useByokAccess-CkE0XkoZ.js";import{C as Jt}from"./credit-card-DoDuc8tO.js";import{M as Qt}from"./mic-tgc84GsL.js";import{T as Zt}from"./trash-2-Bwul3UY2.js";import{S as es}from"./star-CX03BUWl.js";import{S as lt}from"./settings-wMwx6_yh.js";import{V as it}from"./volume-x-BIrMZjop.js";import{C as ts}from"./chevron-left-Cg2Uiy56.js";import{C as ss}from"./chevron-right-CGYSSnmW.js";import"./SummaryIcon-BdeRgiPs.js";import"./index-DOFqMbwA.js";import"./index-B4FAjX2L.js";import"./Logo-XfpNXZMK.js";import"./loader-circle-BSrRsRgY.js";import"./send-C40d3rCz.js";import"./file-text-geLHpaMD.js";import"./circle-help-C2Ej7XU8.js";import"./download-BHfpWwCY.js";import"./external-link-D4ZfArH6.js";import"./menu-Rz5Y4TAJ.js";import"./globe-PWZpm1zk.js";import"./with-selector-BTytM5sm.js";import"./endpoints-Cx8vVhwh.js";import"./api-DoeX5bbq.js";/**
2 * @license lucide-react v0.468.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ct=dt("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
7 * @license lucide-react v0.468.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const as=dt("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),mt=o.forwardRef(({className:s,value:c,...r},C)=>e.jsx("div",{ref:C,className:Mt("relative h-4 w-full overflow-hidden rounded-full bg-gray-200",s),...r,children:e.jsx("div",{className:"h-full w-full flex-1 bg-orange-600 transition-all",style:{transform:`translateX(-${100-(c||0)}%)`}})}));mt.displayName="Progress";function rs({data:s,className:c,totalTranslations:r,uniqueVideos:C,successRate:F,averageTranslationTime:y}){const{t:i}=_e();return!s||s.length===0?e.jsxs(O,{className:c,children:[e.jsx(Q,{children:e.jsx(Z,{className:"text-sm font-medium text-slate-600",children:i("dashboard.metrics.title")})}),e.jsx(R,{className:"h-[200px] flex items-center justify-center text-slate-400",children:i("dashboard.noDataAvailable")})]}):e.jsxs(O,{className:c,children:[e.jsx(Q,{children:e.jsx(Z,{className:"text-sm font-medium text-slate-600",children:i("dashboard.metrics.title")})}),e.jsxs(R,{children:[e.jsxs("div",{className:`mb-4 grid gap-4 ${C?"grid-cols-4":"grid-cols-3"}`,children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900",children:r||0}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i("dashboard.translations")})]}),C?e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900",children:C}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i("dashboard.videos")})]}):null,e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900",children:F!==void 0?`${F}%`:"-"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i("dashboard.successRate",{},"Success rate")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-slate-900",children:y!==void 0?`${y}s`:"-"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:i("dashboard.avgSpeed",{},"Avg speed")})]})]}),e.jsx("div",{className:"h-[200px] w-full",children:e.jsx(Ft,{width:"100%",height:"100%",children:e.jsxs(Ht,{data:s,margin:{top:5,right:10,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"colorChars",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
11stopColor:"#8884d8",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#8884d8",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"colorTrans",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#10b981",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#10b981",stopOpacity:0})]})]}),e.jsx(Pt,{strokeDasharray:"3 3",vertical:!1,stroke:"#f1f5f9"}),e.jsx(Vt,{dataKey:"date",tick:{fontSize:12,fill:"#64748b"},axisLine:!1,tickLine:!1,tickFormatter:g=>new Date(g).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),e.jsx(Ut,{tick:{fontSize:12,fill:"#64748b"},axisLine:!1,tickLine:!1}),e.jsx(zt,{contentStyle:{backgroundColor:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"},formatter:(g,k)=>k==="characters"?[g,"Characters"]:k==="translations"?[g,i("dashboard.translations")]:[g,k],labelFormatter:g=>new Date(g).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}),e.jsx(nt,{type:"monotone",dataKey:"characters",stroke:"#8884d8",fillOpacity:1,fill:"url(#colorChars)",name:i("dashboard.usage.chars")}),e.jsx(nt,{type:"monotone",dataKey:"translations",stroke:"#10b981",fillOpacity:.3,fill:"url(#colorTrans)",name:i("dashboard.translations")})]})})})]})]})}const w={TRANSLATIONS_TODAY:"paywall_translations_today",TRANSLATIONS_DATE:"paywall_translations_date",ACTIONS_24H:"paywall_actions_24h",ACTIONS_24H_DATE:"paywall_actions_24h_date",MODAL_LAST_SHOWN:"paywall_modal_last_shown",MODAL_DISMISSED_AT:"paywall_modal_dismissed_at"};function Se(s,c){return s.getFullYear()===c.getFullYear()&&s.getMonth()===c.getMonth()&&s.getDate()===c.getDate()}const ns=()=>{const[s,c]=o.useState(0),[r,C]=o.useState(0),[F,y]=o.useState(null),[i,g]=o.useState(!0),[k,V]=o.useState(null),[L,j]=o.useState(null);o.useEffect(()=>{const f=new Date,N=localStorage.getItem(w.TRANSLATIONS_DATE),A=localStorage.getItem(w.TRANSLATIONS_TODAY);if(N&&A){const q=new Date(N);Se(f,q)?c(parseInt(A,10)):(localStorage.removeItem(w.TRANSLATIONS_TODAY),localStorage.removeItem(w.TRANSLATIONS_DATE))}const v=localStorage.getItem(w.ACTIONS_24H_DATE),b=localStorage.getItem(w.ACTIONS_24H);if(v&&b){const q=new Date(v),W=new Date(f);W.setDate(W.getDate()-1),Se(q,f)||Se(q,W)?C(parseInt(b,10)):(localStorage.removeItem(w.ACTIONS_24H),localStorage.removeItem(w.ACTIONS_24H_DATE))}const le=localStorage.getItem(w.MODAL_LAST_SHOWN);le&&V(parseInt(le,10));const H=localStorage.getItem(w.MODAL_DISMISSED_AT);H&&j(parseInt(H,10))},[]),o.useEffect(()=>{const f=()=>{g(!document.hidden)};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[]);const T=o.useCallback(()=>{const f=Date.now(),N=new Date().toISOString().split("T")[0];c(A=>{const v=A+1;return localStorage.setItem(w.TRANSLATIONS_TODAY,v.toString()),localStorage.setItem(w.TRANSLATIONS_DATE,N),v}),y(f)},[]),U=o.useCallback(()=>{const f=new Date().toISOString().split("T")[0];C(N=>{const A=N+1;return localStorage.setItem(w.ACTIONS_24H,A.toString()),localStorage.setItem(w.ACTIONS_24H_DATE,f),A})},[]),G=o.useCallback(()=>{const f=Date.now();V(f),localStorage.setItem(w.MODAL_LAST_SHOWN,f.toString())},[]),E=o.useCallback(()=>{const f=Date.now();j(f),localStorage.setItem(w.MODAL_DISMISSED_AT,f.toString())},[]),z=o.useCallback(f=>{const N=Date.now(),A=1440*60*1e3;if(f==="blocked_user")return k&&N-k<A?{shouldShow:!1,reason:"shown_recently"}:{shouldShow:!0,reason:"blocked"};if(f==="critical_user"){if(L&&N-L<A)return{shouldShow:!1,reason:"dismissed_recently"};if(k&&N-k<A)return{shouldShow:!1,reason:"shown_recently"};const v=r>3;return i&&v?{shouldShow:!0,reason:"high_intent"}:{shouldShow:!1,reason:"low_intent"}}return{shouldShow:!1,reason:"not_critical"}},[L,k,r,i]),_=o.useCallback(()=>{localStorage.removeItem(w.TRANSLATIONS_TODAY),localStorage.removeItem(w.TRANSLATIONS_DATE),localStorage.removeItem(w.ACTIONS_24H),localStorage.removeItem(w.ACTIONS_24H_DATE),c(0),C(0)},[]);return{translationsToday:s,actionsLast24h:r,lastTranslationAt:F,isActiveSession:i,modalLastShownAt:k,modalDismissedAt:L,recordTranslation:T,recordAction:U,setModalShown:G,setModalDismissed:E,canShowModal:z,resetDailyCounters:_}};function os(s){return s>=100?"blocked_user":s>=95?"critical_user":s>80?"power_user":s>=50?"active_user":"casual_user"}const ls=({isOpen:s,onClose:c,onUpgrade:r,segment:C,remainingTranslations:F,usagePercentage:y})=>{const{t:i}=_e(),[g,k]=o.useState(!1);if(o.useEffect(()=>{if(s){if(window.__paywall_modal_open)return;window.__paywall_modal_open=!0,k(!0)}else k(!1),window.__paywall_modal_open=!1;return()=>{window.__paywall_modal_open=!1}},[s]),!g||!s)return null;
11const V=F.toLocaleString(),L=C==="blocked_user",T=C==="critical_user"?{icon:ke,iconBg:"bg-orange-100",iconColor:"text-orange-600",title:i("dashboard.paywall.critical.title"),message:i("dashboard.paywall.critical.message",{remaining:V}),social:i("dashboard.paywall.critical.social"),primaryCta:i("dashboard.paywall.actions.upgrade"),showSecondary:!0,secondaryCta:i("dashboard.paywall.actions.later")}:{icon:oe,iconBg:"bg-red-100",iconColor:"text-red-600",title:i("dashboard.paywall.blocked.title"),message:i("dashboard.paywall.blocked.message"),social:null,primaryCta:i("dashboard.paywall.actions.upgradeContinue"),showSecondary:!1,secondaryCta:i("dashboard.paywall.actions.viewPlans")},U=T.icon,G=()=>{r(),c()},E=()=>{c()},z=_=>{_.target===_.currentTarget&&(L||c())};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",onClick:z,children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-xl shadow-2xl max-w-md w-full p-6 relative animate-in fade-in zoom-in-95 duration-200",children:[!L&&e.jsx("button",{onClick:c,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(Et,{className:"h-5 w-5"})}),e.jsx("div",{className:`w-12 h-12 ${T.iconBg} rounded-full flex items-center justify-center mx-auto mb-4`,children:e.jsx(U,{className:`h-6 w-6 ${T.iconColor}`})}),e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white text-center mb-2",children:T.title}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 text-center mb-4 leading-relaxed",children:T.message}),T.social&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center mb-6",children:T.social}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(I,{onClick:G,className:`w-full py-3 text-base font-medium ${L?"bg-red-600 hover:bg-red-700 text-white":"bg-orange-600 hover:bg-orange-700 text-white"}`,children:T.primaryCta}),T.showSecondary&&e.jsx("button",{onClick:E,className:"w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 py-2 transition-colors",children:T.secondaryCta}),C==="blocked_user"&&e.jsx("button",{onClick:c,className:"w-full text-sm text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400 py-2 transition-colors",children:i("common.close")})]}),e.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:i("dashboard.monthlyUsage")}),e.jsxs("span",{children:[y,"%"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-1.5 mt-2",children:e.jsx("div",{className:`h-1.5 rounded-full ${L?"bg-red-500":"bg-orange-500"}`,style:{width:`${Math.min(y,100)}%`}})})]})]})})};function Qs(){var Ee,$e,Oe,Re,Fe,Pe,Ve,Ue,ze,He,Be,Ye,Ke,Ge,qe,We,Xe,Je,Qe,Ze,et;const{t:s}=_e(),{user:c}=$t(),{profile:r,loading:C,refreshSubscription:F}=Bt(),y=Xt(),i=new Intl.NumberFormat(void 0,{style:"currency",currency:y.priceCurrency.toUpperCase()}).format(y.priceAmount/100),[g,k]=o.useState({monthlyLimit:ot("free"),charactersTranslated:0,addonCredits:0}),[V,L]=o.useState({totalCharacters:0,totalTranslations:0}),[j,T]=o.useState({summary:{totalTranslations:0,uniqueVideos:0,successRate:100,averageTranslationTime:2.3},trends:[]}),[U,G]=o.useState(!0),[E,z]=o.useState([]),[_,f]=o.useState(1),[N,A]=o.useState(0),v=5,[b,le]=o.useState(0),[H,q]=o.useState(null),W=tt.useMemo(()=>{if(H)return{daysRemaining:H.daysRemaining,nextResetDate:new Date(H.nextResetDate)};const t=new Date,a=new Date(t.getFullYear(),t.getMonth()+1,0),n=Math.ceil((a.getTime()-t.getTime())/(1e3*60*60*24));return{daysRemaining:Math.max(0,n),nextResetDate:a}},[H]),[ht,fe]=o.useState(!1),[xt,Ce]=o.useState(!1),[ee,ie]=o.useState(null),[pe,ut]=o.useState([]),[X,P]=o.useState(null),[Te,Ae]=o.useState(!1),te=ns(),ce=g.monthlyLimit>0?Math.min(g.charactersTranslated/g.monthlyLimit*100,100):0,J=os(ce),gt=Math.max(0,g.monthlyLimit-g.charactersTranslated);o.useEffect(()=>{if(J==="critical_user"||J==="blocked_user"){const{shouldShow:t}=te.canShowModal(J);t&&(J==="blocked_user"||te.isActiveSession&&ce>=95)&&(Ae(!0),te.setModalShown())}},[J,ce,te]);const bt=()=>{Ae(!1),te.setModalDismissed()},ft=()=>{window.location.href="/dashboard/subscription"},[B,de]=o.useState(new Map),Y=o.useRef(null),[pt,ye]=o.useState(new Set),[De,Le]=o.useState(null),[$,yt]=o.useState(!1);o.useEffect(()=>{var a;Y.current=window.speechSynthesis;const t=()=>{var l;const n=((l=Y.current)==null?void 0:l.getVoices())||[];ut(n)};return t(),(a=Y.current)==null||a.addEventListener("voiceschanged",t),()=>{var n;(n=Y.current)==null||n.removeEventListener("voiceschanged",t)}},[]),o.useEffect(()=>{c&&me()},[c]),o.useEffect(()=>{const t=()=>{document.visibilityState==="visible"&&c&&me()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[c]),o.useEffect(()=>{c&&_>1&&wt()},[_]);const wt=async()=>{var t,a,n;try{const l=(_-1)*v,m=l+v-1,h=new URLSearchParams({from:l.toString(),to:m.toString()}),p=localStorage.getItem("token")||localStorage.getItem("access_token");if(!p)return;const u=await fetch(`/api/translations/history?${h.toString()}`,{headers:{Authorization:`Bearer ${p}`}});if(u.ok){const d=await u.json();if(d.success){const x=Array.isArray(d.data)?d.data:((t=d.data)==null?void 0:t.translations)||[];z(x),A(d.count||((n=(a=d.data)==null?void 0:a.pagination)==null?void 0:n.totalItems)||0);const M=new Set;x.forEach(K=>{K.is_favorite&&M.add(K.id)}),ye(M)}}}catch(l){console.error("❌ [Dashboard] Error loading translations for page:",l)}},jt=async()=>{try{Ce(!0);const t=localStorage.getItem("token")||localStorage.getItem("access_token");if(!t)throw new Error("No token");if(!(await fetch("/api/translations/history",{method:"DELETE",headers:{Authorization:`Bearer ${t}`}})).ok)throw new Error("Failed to delete history");console.log("✅ [Dashboard] Translation history deleted successfully"),await me(),alert(s("dashboard.history.success")),fe(!1)}catch(t){console.error("❌ [Dashboard] Error deleting history:",t),alert(s("dashboard.history.error"))}finally{Ce(!1)}},vt=t=>{var p;const a={Inglés:"en",English:"en",Español:"es",Spanish:"es",Francés:"fr",French:"fr",Alemán:"de",German:"de",Italiano:"it",Italian:"it",Portugués:"pt",Portuguese:"pt",Ruso:"ru",Russian:"ru",Japonés:"ja",Japanese:"ja",Coreano:"ko",Korean:"ko",Chino:"zh",Chinese:"zh",Árabe:"ar",Arabic:"ar",Hindi:"hi",Turco:"tr",Turkish:"tr",Polaco:"pl",Polish:"pl",Holandés:"nl",Dutch:"nl",Sueco:"sv",Swedis
11h:"sv",Danés:"da",Danish:"da",Noruego:"nb",Norwegian:"nb",Finlandés:"fi",Finnish:"fi",Checo:"cs",Czech:"cs",Eslovaco:"sk",Slovak:"sk",Húngaro:"hu",Hungarian:"hu",Rumano:"ro",Romanian:"ro",Búlgaro:"bg",Bulgarian:"bg",Croata:"hr",Croatian:"hr",Esloveno:"sl",Slovenian:"sl",Estonio:"et",Estonian:"et",Letón:"lv",Latvian:"lv",Lituano:"lt",Lithuanian:"lt",Griego:"el",Greek:"el",Hebreo:"he",Hebrew:"he",Tailandés:"th",Thai:"th",Vietnamita:"vi",Vietnamese:"vi",Indonesio:"id",Indonesian:"id",Malayo:"ms",Malay:"ms",Ucraniano:"uk",Ukrainian:"uk",Bielorruso:"be",Belarusian:"be",Catalán:"ca",Catalan:"ca",Vasco:"eu",Basque:"eu",Gallego:"gl",Galician:"gl"},n=a[t]||a[t.toLowerCase()]||"en",l=pe.filter(u=>u.lang.startsWith(n));if(l.length===0)return null;const m=[/Neural/i,/Google/i,/WaveNet/i,/Premium/i,/Natural/i,/Studio/i,/Enhanced/i],h=l.map(u=>{let d=0;return m.forEach((x,M)=>{x.test(u.name)&&(d+=m.length-M)}),u.remote||(d+=.5),{voice:u,score:d}});return h.sort((u,d)=>d.score-u.score),((p=h[0])==null?void 0:p.voice)||l[0]},Nt=t=>{if(!t||t.length<15)return"Unknown";const a=t.toLowerCase().trim();if(/[\u4e00-\u9fff]/.test(a))return"Chinese";if(/[\u3040-\u309f\u30a0-\u30ff]/.test(a))return"Japanese";if(/[\uac00-\ud7af]/.test(a))return"Korean";if(/[\u0600-\u06ff]/.test(a))return"Arabic";if(/[\u0590-\u05ff]/.test(a))return"Hebrew";if(/[а-яА-ЯёЁ]/.test(a))return"Russian";if(/[\u0370-\u03ff]/.test(a))return"Greek";if(/[\u0900-\u097f]/.test(a))return"Hindi";const n={spanish:{score:0,patterns:[/[ñáéíóúü]/g,/ción/g,/dad/g,/\b(el|la|los|las|un|una|es|en|de|por|para|que|con|sin|sobre)\b/g,/\b(es|tá|stá|ndo|ándo)\b/g]},french:{score:0,patterns:[/[éèêëàâùûüîôïç]/g,/tion/g,/ment/g,/\b(le|la|les|un|une|et|en|de|pour|que|avec|sans|sur|dans)\b/g,/\b(est|é|és|ée|ées|ez|er)\b/g]},german:{score:0,patterns:[/[äöüß]/g,/ung/g,/heit/g,/schaft/g,/\b(der|die|das|ein|eine|und|in|zu|für|dass|mit|ohne|auf)\b/g]},portuguese:{score:0,patterns:[/[ãõáéíóúâêîôûà]/g,/ção/g,/dade/g,/mente/g,/\b(o|a|os|as|um|uma|e|em|de|por|para|que|com|sem|sobre)\b/g]},italian:{score:0,patterns:[/[àèéìòù]/g,/zione/g,/tà/g,/mente/g,/\b(il|la|lo|gli|le|un|una|e|in|di|per|che|con|senza|su)\b/g]},english:{score:0,patterns:[/th/g,/ing/g,/tion/g,/ly/g,/\b(the|be|to|of|and|a|in|that|have|i|it|for|not|on|with)\b/g]}};for(const h in n){const p=n[h];for(const u of p.patterns){const d=a.match(u);p.score+=d?d.length:0}}let l=0,m="English";for(const h in n)n[h].score>l&&(l=n[h].score,m=h.charAt(0).toUpperCase()+h.slice(1));return l>=2?m:"English"},Ie=(t,a,n,l=!1)=>{var d,x,M;const m=`${n}-${l?"source":"target"}`;if(ee===m){(d=Y.current)==null||d.cancel(),ie(null);return}(x=Y.current)==null||x.cancel();const h=new SpeechSynthesisUtterance(t),p=`${n}-${l?"source":"target"}`,u=B.get(p);if(u)h.voice=u;else{const K=vt(a);K&&(h.voice=K)}h.rate=.9,h.pitch=1,ie(m),h.onend=()=>{ie(null)},h.onerror=()=>{ie(null)},(M=Y.current)==null||M.speak(h)},St=async t=>{try{Le(t);const a=await Wt.toggle(t);if(a.success){const n=new Set(pt);a.data.is_favorite?n.add(t):n.delete(t),ye(n),z(l=>l.map(m=>m.id===t?{...m,is_favorite:a.data.is_favorite}:m))}}catch(a){console.error("❌ [Dashboard] Error toggling favorite:",a)}finally{Le(null)}},me=async()=>{var t,a,n,l,m,h;try{if(G(!0),!(c!=null&&c.id))return;const p=async(S,xe=2)=>{let re;for(let ne=0;ne<xe;ne++)try{return await S()}catch(Lt){re=Lt,await new Promise(It=>setTimeout(It,250))}throw re},u=await p(async()=>{const S=await Ne.get("/dashboard/stats");return S&&typeof S=="object"?S:null});u&&le(u.streak||0);try{const S=await qt();q(S)}catch(S){console.error("Error fetching billing cycle:",S)}const d=await p(async()=>Ne.get("/user/status")),x=d!=null&&d.success&&(d!=null&&d.data)?{currentMonthCharacters:((t=d.data.usage)==null?void 0:t.currentMonth)||0,monthlyLimit:((a=d.data.usage)==null?void 0:a.monthlyLimit)||0,addonCredits:((n=d.data.usage)==null?void 0:n.addonRemaining)||0,lifetimeCharacters:((l=d.data.totals)==null?void 0:l.allTimeCharacters)||0,totalTranslations:((m=d.data.totals)==null?void 0:m.allTimeTranslations)||0,uniqueVideos:0}:null,M=(_-1)*v,K=M+v-1,Ct=new URLSearchParams({from:M.toString(),to:K.toString()}),ae=await Ne.get(`/translations/history?${Ct.toString()}`);if(ae!=null&&ae.success){const S=ae.data,xe=Array.isArray(S)?S:(S==null?void 0:S.translations)||[];z(xe),A(ae.count||((h=S==null?void 0:S.pagination)==null?void 0:h.totalItems)||0);const re=new Set;xe.forEach(ne=>{ne.is_favorite&&re.add(ne.id)}),ye(re)}const Tt=(u==null?void 0:u.trends)||[],At=(x==null?void 0:x.currentMonthCharacters)??0,Dt=(x==null?void 0:x.monthlyLimit)??ot("free");k({monthlyLimit:Dt,charactersTranslated:At,addonCredits:(x==null?void 0:x.addonCredits)||0}),L({totalCharacters:(x==null?void 0:x.lifetimeCharacters)||0,totalTranslations:(x==null?void 0:x.totalTranslations)||0}),T({summary:{totalTranslations:(x==null?void 0:x.totalTranslations)||0,uniqueVideos:(x==null?void 0:x.uniqueVideos)||0,successRate:100,averageTranslationTime:2.3},trends:Tt})}catch(p){console.error("Error loading dashboard data:",p)}finally{G(!1)}},se=(g==null?void 0:g.monthlyLimit)||0,we=(g==null?void 0:g.charactersTranslated)||0,je=(g==null?void 0:g.addonCredits)||0,kt=Math.max(0,se-we)+je,D=se>0?Math.min(we/se*100,100):0,Me=((($e=(Ee=r==null?void 0:r.subscription)==null?void 0:Ee.plan)==null?void 0:$e.toLowerCase())||"free").replace(/_(monthly|yearly)$/,""),he=Me!=="free",ve=Me==="ultra";if(C||U)return e.jsx(rt,{children:e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-700"})})});const _t=((j==null?void 0:j.trends)||[]).map(t=>({date:t.date,characters:t.characters,translations:t.translations}));return e.jsx(rt,{children:e.jsxs("div",{className:"space-y-8","data-testid":"dashboard-container",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-slate-900 to-slate-700",children:s("dashboard.welcome",{name:((Oe=r==null?void 0:r.full_name)==null?void 0:Oe.split(" ")[0])||((Re=c==null?void 0:c.email)==null?void 0:Re.split("@")[0])||s("dashboard.friend")})}),e.jsx("p",{className:"text-slate-500 mt-1",children:s("dashboard.subtitle")})]}),e.jsx("div",{className:"flex gap-3",children:!ve&&e.jsxs(I,{onClick:()=>window.location.href="/dashboard/subscription",className:"bg-gradient-to-r from-primary-700 to-earth-600 hover:shadow-lg hover:shadow-orange-500/20 transition-all border-0 text-white font-medium",children:[e.jsx(oe,{className:"w-4 h-4 mr-2 fill-current"}),s("dashboard.upgrade")]})})]}),D>=50&&!ve&&e.jsx(O,{"data-testid":"upgrade-prompt",className:`border-2 shadow-lg ${D>=100?"border-red-300 bg-gradient-to-r from-red-100 to-red-50":D>=80?"border-orange-200 bg-gradient-to-r from-orange-50 to-amber-50":"border-amber-200 bg-gradient-to-r from-amber-50 to-yellow-50"}`,children:e.jsx(R,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:`p-3 rounded-full ${D>=100?"bg-red-200":D>=80?"bg-orange-100":"bg-amber-100"}`,children:D>=100?e.jsx(ke,{className:"w-6 h-6 text-red-700"}):D>=80?e.jsx(ge,{className:"w-6 h-6 text-orange-600"}):e.jsx(ge,{className:"w-6 h-6 text-amber-600"})}),e.jsx("div",{className:"flex-1",children:D>=100?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900 mb-1",children:s("dashboard.limitReached",{},"Limit reached 🚫")}),e.jsx("p",{className:"text-sm text-slate-700",children:s("dashboard.limitReachedMessage",{},"You've reached your monthly translation limit. Upgrade your plan to continue translating.")})]}):D>=80?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"text-lg font-bold text-slate-900 mb-1",children:[s("streak.almostThere")," 🔥"]}),e.jsx("p",{className:"text-sm text-slate-700",children:s("dashboard.usageWarningMessage",{},"You've used {percent}% of your monthly quota. Upgrade soon to keep translating without interruptions.").replace("{percent}",D.toFixed(0))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"text-lg font-bold text-slate-900 mb-1",children:[s("streak.greatProgress")," 🚀"]}),e.jsx("p",{className:"text-sm text-slate-700",children:s("dashboard.usageTrackMessage",{},"You've used {percent}% of your monthly plan. You're on track to need more characters soon.").replace("{percent}",D.toFixed(0))})]})})]}),e.jsxs(I,{onClick:()=>window.location.href="/dashboard/subscription",className:`shrink-0 font-semibold shadow-md hover:shadow-lg ${D>=100?"bg-gradient-to-r from-red-700 to-red-600 hover:from-red-800 hover:to-red-700 text-white":D>=80?"bg-gradient-to-r from-orange-600 to-amber-600 hover:from-orange-700 hover:to-amber-700 text-white":"bg-gradient-to-r from-amber-600 to-yellow-600 hover:from-amber-700 hover:to-yellow-700 text-white"}`,children:[e.jsx(oe,{className:"w-4 h-4 mr-2 fill-current"}),s("dashboard.upgradePlan",{},"Upgrade Plan")]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-2 gap-6",children:[e.jsxs(O,{className:"border-2 border-orange-200/60 shadow-md hover:shadow-lg transition-all bg-gradient-to-br from-orange-50 via-white to-yellow-50 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-100/20 to-yellow-100/20 animate-pulse"}),e.jsx("div",{className:"absolute -top-8 -right-8 w-24 h-24 bg-gradient-to-br from-orange-200/30 to-yellow-200/30 rounded-full blur-2xl"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-24 h-24 bg-gradient-to-br from-orange-200/30 to-red-200/30 rounded-full blur-2xl"}),e.jsxs(Q,{className:"flex flex-row items-center justify-between space-y-0 pb-2 relative z-10",children:[e.jsx(Z,{className:"text-sm font-semibold text-slate-700",children:s("dashboard.learningStreak",{},"Learning Streak")}),e.jsx("div",{className:"bg-gradient-to-br from-orange-100 to-yellow-100 p-2 rounded-lg border border-orange-200/50 shadow-sm",children:e.jsx(ct,{className:"h-5 w-5 text-orange-600"})})]}),e.jsx(R,{className:"relative z-10",children:e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("div",{className:"text-5xl font-black bg-gradient-to-br from-orange-600 to-red-600 bg-clip-text text-transparent drop-shadow-sm",children:b}),e.jsx("div",{className:"text-lg font-semibold text-slate-600",children:b===1?s("dashboard.day",{},"day"):s("dashboard.days",{},"days")})]}),e.jsx("p",{className:"text-sm text-slate-700 mt-3 font-medium leading-relaxed",children:b===0?e.jsxs(e.Fragment,{children:[s("streak.startToday")," 🔑",e.jsx("span",{className:"block text-slate-500 text-xs mt-1",children:s("streak.buildMomentum")})]}):b===1?e.jsxs(e.Fragment,{children:[s("streak.greatStart")," 🎉",e.jsx("span",{className:"block text-slate-500 text-xs mt-1",children:s("streak.comeBack")})]}):b<7?e.jsxs(e.Fragment,{children:[s("streak.keepGoing")," 💪",e.jsxs("span",{className:"block text-slate-500 text-xs mt-1",children:[7-b," ",s("dashboard.daysUntilWeek",{},"until your first week")]})]}):b<30?e.jsxs(e.Fragment,{children:[s("dashboard.amazingConsistency",{},"Amazing consistency! 🌟"),e.jsxs("span",{className:"block text-slate-500 text-xs mt-1",children:[30-b," ",s("dashboard.daysToMonth",{}
11,"to one month streak")]})]}):b<100?e.jsxs(e.Fragment,{children:["You're on fire! 🔥",e.jsxs("span",{className:"block text-slate-500 text-xs mt-1",children:[b," ",s("dashboard.daysOfLearning",{},"days of daily learning")]})]}):e.jsxs(e.Fragment,{children:[s("streak.legendary")," 🏆",e.jsxs("span",{className:"block text-slate-500 text-xs mt-1",children:[b," ",s("dashboard.daysUnstoppable",{},"days - you're unstoppable!")]})]})}),b>0&&e.jsx("div",{className:"mt-4 flex items-center gap-1.5",children:e.jsxs("div",{className:"flex gap-1.5",children:[[...Array(Math.min(b,7))].map((t,a)=>e.jsx("div",{className:"relative group",style:{animationDelay:`${a*100}ms`},children:e.jsx(ct,{className:"w-5 h-5 text-orange-500 drop-shadow-md transition-transform group-hover:scale-110",style:{filter:`drop-shadow(0 2px ${4+a%2*2}px rgba(249, 115, 22, 0.3))`}})},a)),b>7&&e.jsxs("span",{className:"text-slate-600 font-bold text-sm ml-1",children:["+",b-7]})]})}),b>0&&b<30&&e.jsxs("div",{className:"mt-3 bg-white/80 backdrop-blur-sm rounded-lg p-2.5 border border-slate-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-600 mb-1.5",children:[e.jsx("span",{className:"font-medium",children:s("dashboard.nextMilestone",{},"Next milestone")}),e.jsx("span",{className:"font-bold text-orange-600",children:b<7?`7 ${s("dashboard.days",{},"days")}`:`30 ${s("dashboard.days",{},"days")}`})]}),e.jsx("div",{className:"w-full bg-slate-100 rounded-full h-2 overflow-hidden shadow-inner",children:e.jsx("div",{className:"bg-gradient-to-r from-orange-400 to-orange-500 h-full rounded-full transition-all duration-700 ease-out shadow-sm",style:{width:`${Math.min(b<7?b/7*100:(b-7)/23*100,100)}%`}})})]})]})})]}),e.jsxs(O,{"data-testid":"usage-card",className:"border-slate-200 shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs(Q,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Z,{className:"text-sm font-medium text-slate-600",children:s("dashboard.usage.title")}),e.jsx(Rt,{className:"h-4 w-4 text-orange-500"})]}),e.jsx(R,{children:e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-end justify-between mb-2",children:[e.jsxs("span",{className:"text-3xl font-bold text-slate-900","data-testid":"current-month-usage",children:[(we/1e3).toFixed(1),"k"]}),e.jsxs("span",{className:"text-sm font-medium text-slate-500 mb-1",children:["/ ",e.jsxs("span",{"data-testid":"monthly-limit",children:[(se/1e3).toFixed(0),"k"]})," ",s("dashboard.usage.chars")]})]}),e.jsx(mt,{value:D,className:"h-2 bg-slate-100","data-testid":"usage-percentage"}),je>0&&!((Pe=(Fe=r==null?void 0:r.subscription)==null?void 0:Fe.voiceUnlimited)!=null&&Pe.active)&&e.jsxs("div",{className:"mt-2 bg-green-50 border border-green-200 rounded-md px-3 py-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-medium text-green-700",children:["+",(je/1e3).toFixed(1),"k gifted credits"]}),e.jsxs("span",{className:"text-xs font-semibold text-green-600",children:[(kt/1e3).toFixed(1),"k total available"]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-100",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-1",children:[e.jsx("span",{className:"font-semibold text-slate-700",children:W.daysRemaining})," ",s("dashboard.daysRemaining",{},"days remaining until reset")]}),e.jsxs("p",{className:"text-xs text-slate-400",children:[s("dashboard.resetsOn",{},"Resets on")," ",W.nextResetDate.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]})]}),e.jsxs("div",{className:"mt-2.5 pt-2.5 border-t border-slate-100 flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("span",{className:"font-medium text-slate-600",children:["⚡ ",s("dashboard.byok.title",{},"BYOK"),":"]}),y.loading?e.jsx("span",{className:"text-slate-400",children:"..."}):y.error?e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-medium bg-slate-100 text-slate-600 text-[11px]",children:s("dashboard.byok.unavailable",{},"Status unavailable")}):y.active?e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-semibold bg-emerald-100 text-emerald-800 text-[11px]",children:[s("dashboard.byok.paid",{},"BYOK paid")," · ",y.paymentProvider||"Stripe"]}):y.pending?e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-medium bg-amber-50 text-amber-800 border border-amber-200 text-[11px]",children:s("dashboard.byok.pending",{},"Payment pending")}):y.trialRemainingSeconds>0?e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-medium bg-amber-50 text-amber-800 border border-amber-200 text-[11px]",children:s("dashboard.byok.trialRemaining",{minutes:y.trialRemainingLabel},`${y.trialRemainingLabel} trial`)}):e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded font-medium bg-slate-100 text-slate-600 text-[11px]",children:s("dashboard.byok.trialExhausted",{},"Prueba agotada")})]}),!y.loading&&!y.error&&!y.active&&e.jsx("a",{href:"/dashboard/subscription#byok",className:"font-semibold text-orange-600 hover:text-orange-700 hover:underline shrink-0 ml-1.5",children:y.trialRemainingSeconds>0?s("dashboard.byok.upgrade",{price:i},`Subscribe (${i})`):s("dashboard.byok.activate",{price:i},`Activate (${i})`)})]})]})})]}),e.jsxs(O,{className:"border-slate-200 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 p-3 op
11acity-10",children:e.jsx(ge,{className:"w-24 h-24 text-primary-600"})}),e.jsxs(Q,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Z,{className:"text-sm font-medium text-slate-600",children:s("dashboard.totalCharacters",{},"Total Characters Used")}),e.jsx(ge,{className:"h-4 w-4 text-primary-600"})]}),e.jsx(R,{children:e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"text-3xl font-bold text-slate-900 mb-1",children:[(V.totalCharacters/1e3).toFixed(1),"k"]}),e.jsx("div",{className:"text-sm text-slate-600 font-medium mb-3",children:s("dashboard.charactersTranslated",{},"characters translated")}),e.jsx("div",{className:"pt-3 border-t border-slate-100",children:e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-600",children:[e.jsxs("span",{children:[s("dashboard.allTimeTranslations",{},"All-time translations"),":"]}),e.jsx("span",{className:"font-bold text-slate-900",children:V.totalTranslations})]})})]})})]}),e.jsxs(O,{"data-testid":"subscription-info",className:"border-slate-200 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 p-3 opacity-10",children:e.jsx(Ot,{className:"w-24 h-24 text-primary-600"})}),e.jsxs(Q,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Z,{className:"text-sm font-medium text-slate-600",children:s("dashboard.plan.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-4 w-4 text-orange-600"}),e.jsx(I,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs","data-testid":"refresh-usage",onClick:async()=>{(await F()).success&&await me()},disabled:U,title:"Refresh subscription status from Stripe",children:U?e.jsx("div",{className:"w-3 h-3 border-2 border-orange-600 border-t-transparent rounded-full animate-spin"}):e.jsx("span",{className:"text-orange-600",children:"↻"})})]})]}),e.jsxs(R,{children:[e.jsxs("div",{className:"mt-2 text-3xl font-bold text-slate-900 flex items-center gap-3","data-testid":"current-plan",children:[Yt(((Ve=r==null?void 0:r.subscription)==null?void 0:Ve.plan)||"free"),((Ue=r==null?void 0:r.subscription)==null?void 0:Ue.status)&&!(((He=(ze=r==null?void 0:r.subscription)==null?void 0:ze.plan)==null?void 0:He.toLowerCase())==="free"&&((Be=r==null?void 0:r.subscription)==null?void 0:Be.status)==="canceled")&&e.jsx(be,{variant:he?"default":"secondary",className:"text-xs font-semibold uppercase tracking-wider",children:r.subscription.status==="active"?s("dashboard.active",{},"active"):r.subscription.status==="trialing"?s("dashboard.trialing",{},"trialing"):r.subscription.status}),((Ke=(Ye=r==null?void 0:r.subscription)==null?void 0:Ye.voiceUnlimited)==null?void 0:Ke.active)&&e.jsxs(be,{className:"bg-orange-100 text-orange-800 border border-orange-200 text-xs font-semibold gap-1",children:[e.jsx(Qt,{className:"h-3 w-3"})," Voice ∞"]})]}),!!((Ge=r==null?void 0:r.subscription)!=null&&Ge.current_period_start)&&e.jsx("div",{className:"mt-1 flex items-center text-sm text-slate-500",children:e.jsxs("span",{children:[s("dashboard.started",{},"Started on")," ",Kt(r.subscription.current_period_start)]})}),((qe=r==null?void 0:r.subscription)==null?void 0:qe.cancel_at_period_end)&&he&&e.jsx("div",{className:"mt-3 p-3 bg-orange-50 border border-orange-200 rounded-lg",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-orange-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-orange-900",children:s("common.cancellationPending")}),e.jsxs("p",{className:"text-orange-700 mt-1",children:["Your subscription will return to Free plan in"," ",(()=>{const t=Math.ceil((r.subscription.current_period_end*1e3-Date.now())/864e5);return`${t} day${t!==1?"s":""}`})()]})]})]})}),e.jsxs("div",{className:"mt-4 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center text-sm text-slate-600",children:[e.jsx(ue,{className:"w-4 h-4 text-green-500 mr-2"}
11),ve?s("dashboard.plan.unlimited"):`${se.toLocaleString()} ${s("dashboard.plan.chars_per_month")}`]}),(Xe=(We=r==null?void 0:r.subscription)==null?void 0:We.premium_voice_balance)!=null&&Xe.minutes_purchased?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center text-sm text-slate-600",children:[e.jsx(ue,{className:"w-4 h-4 text-green-500 mr-2"}),e.jsxs("span",{children:[r.subscription.premium_voice_balance.minutes_purchased," ",s("dashboard.voicePack",{},"min voice pack")]})]}),e.jsx("div",{className:"text-xs text-slate-400",children:e.jsxs("span",{children:["(",r.subscription.premium_voice_balance.minutes_used||0," ",s("dashboard.used",{},"used")," / ",r.subscription.premium_voice_balance.minutes_remaining," ",s("dashboard.remaining",{},"remaining"),")"]})})]}):e.jsxs("div",{className:"flex items-center text-sm text-slate-600","data-testid":"premium-voices",style:{display:he?"flex":"none"},children:[e.jsx(ue,{className:"w-4 h-4 text-green-500 mr-2"}),s(he?"dashboard.plan.premium_voices":"dashboard.plan.standard_voices")]})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-6",children:e.jsx("div",{className:"col-span-1",children:e.jsx(rs,{data:_t,className:"border-slate-200 shadow-sm",totalTranslations:(Je=j==null?void 0:j.summary)==null?void 0:Je.totalTranslations,uniqueVideos:(Qe=j==null?void 0:j.summary)==null?void 0:Qe.uniqueVideos,successRate:(Ze=j==null?void 0:j.summary)==null?void 0:Ze.successRate,averageTranslationTime:(et=j==null?void 0:j.summary)==null?void 0:et.averageTranslationTime})})}),e.jsxs("div",{id:"recent-activity",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-slate-900",children:s("dashboard.recentActivity.title")}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:s("dashboard.recentActivity.subtitle")})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full sm:w-auto",children:[E.length>0&&e.jsxs(I,{onClick:()=>fe(!0),variant:"outline",className:"border-red-200 text-red-600 hover:bg-red-50 w-full sm:w-auto",children:[e.jsx(Zt,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:s("dashboard.history.delete_button")}),e.jsx("span",{className:"sm:hidden",children:s("common.delete")})]}),E.length>0&&e.jsxs(I,{onClick:()=>yt(!$),variant:$?"default":"outline",className:$?"bg-yellow-500 hover:bg-yellow-600 text-white border-yellow-500 w-full sm:w-auto":"border-yellow-200 text-yellow-600 hover:bg-yellow-50 w-full sm:w-auto",children:[e.jsx(at,{className:`w-4 h-4 mr-2 ${$?"fill-current":""}`}),e.jsx("span",{className:"hidden sm:inline",children:$?s("dashboard.allTranslations",{},"All Translations"):s("dashboard.showFavorites",{},"Show Favorites")}),e.jsx("span",{className:"sm:hidden",children:$?s("dashboard.all",{},"All"):s("dashboard.favorites",{},"Favorites")})]}),e.jsxs(I,{onClick:()=>window.location.href="/dashboard/history",variant:"outline",className:"border-slate-200 text-slate-600 hover:bg-slate-50 w-full sm:w-auto",children:[e.jsx(as,{className:"w-4 h-4 mr-2"}),s("dashboard.viewAll",{},"View All")]})]})]}),E.length>0&&(!$||E.some(t=>t.is_favorite))?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-4",children:E.filter(t=>!$||t.is_favorite).map(t=>e.jsx(O,{className:"border-slate-200 shadow-sm hover:shadow-md transition-all duration-200 hover:border-slate-300",children:e.jsxs(R,{className:"p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start justify-between gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex-1 space-y-3 w-full",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(be,{variant:"outline",className:"text-xs font-medium",children:t.source_language==="auto"||!t.source_language?Nt(t.source_text||""):t.source_language}),e.jsx("span",{className:"text-slate-400",children:"→"}),e.jsx(be,{variant:"outline",className:"text-xs font-medium",children:t.target_language||"Unknown"}),e.jsx("button",{onClick:()=>St(t.id),disabled:De===t.id,className:`ml-auto p-1.5 rounded-full transition-all ${De===t.id?"opacity-50 cursor-not-allowed":"hover:scale-110 active:scale-95"}`,title:t.is_favorite?"Remove from favorites":"Add to favorites",children:e.jsx(es,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":"text-slate-300 hover:text-yellow-400"}`})}),e.jsxs("span",{className:"text-xs text-slate-400",children:[new Date(t.created_at).toLocaleDateString()," at"," ",new Date(t.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),(t.video_title||t.website_domain)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 bg-slate-50 rounded-md px-2 py-1.5",children:[e.jsx("span",{className:"text-slate-400",children:"📍"}),t.video_title&&e.jsx("span",{className:"font-medium text-slate-600 truncate max-w-[200px]",title:t.video_title,children:t.video_title}),t.video_title&&t.website_domain&&e.jsx("span",{className:"text-slate-300",children:"•"}),t.website_domain&&(t.website_url?e.jsx("a",{href:t.website_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-600 hover:text-primary-700 hover:underline",children:t.website_domain}):e.jsx("span",{className:"text-slate-500",children:t.website_domain}))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 group relative",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-slate-600 line-clamp-2",children:t.source_text||"No source text available"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>{const a=`${t.id}-source`;P(X===a?null:a)},className:`p-2 rounded-full transition-all flex-shrink-0 ${X===`${t.id}
11-source`?"bg-orange-100 text-orange-600":"bg-slate-100 text-slate-500 hover:bg-slate-200"}`,title:"Select voice",children:e.jsx(lt,{className:"w-4 h-4"})}),X===`${t.id}-source`&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-72 bg-white rounded-lg shadow-xl border border-slate-200 z-50",children:e.jsxs("div",{className:"p-2 max-h-64 overflow-y-auto",children:[e.jsx("button",{onClick:()=>{const a=new Map(B);a.delete(`${t.id}-source`),de(a),P(null)},className:"w-full text-left px-3 py-2 text-sm hover:bg-slate-50 rounded-md mb-1 bg-primary-50 text-primary-700 font-medium",children:"🌟 Auto (Best Voice for Language)"}),(()=>{const a=t.source_language||"en";return pe.filter(n=>n.lang.startsWith(a)?![/bubble/i,/bell/i,/boing/i,/buzzer/i,/click/i,/clong/i,/ding/i,/echo/i,/effect/i,/fanfare/i,/growl/i,/horn/i,/klaxon/i,/laughter/i,/monster/i,/robot/i,/scream/i,/whisper/i,/wobble/i,/zip/i].some(m=>m.test(n.name)):!1).slice(0,10).map((n,l)=>{var p;const m=`${t.id}-source`,h=((p=B.get(m))==null?void 0:p.name)===n.name;return e.jsx("button",{onClick:()=>{const u=new Map(B);u.set(m,n),de(u),P(null)},className:`w-full text-left px-3 py-2 text-sm hover:bg-slate-50 rounded-md mb-1 ${h?"bg-primary-50 text-primary-700 font-medium":""}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-xs text-slate-400 ml-2",children:n.lang})]})},l)})})()]})})]}),e.jsx("button",{onClick:()=>Ie(t.source_text||"",t.source_language,t.id,!0),className:`p-2 rounded-full transition-all flex-shrink-0 ${ee===`${t.id}-source`?"bg-slate-200 text-slate-700 animate-pulse":"bg-slate-100 text-slate-500 hover:bg-slate-200"}`,title:"Listen to original",children:ee===`${t.id}-source`?e.jsx(it,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:[(t.source_text||"").length," characters"]})]}),t.translated_text&&e.jsx("div",{className:"bg-blue-50 rounded-lg p-3 group relative",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-slate-700 line-clamp-2",children:t.translated_text}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>{const a=`${t.id}-target`;P(X===a?null:a)},className:`p-2 rounded-full transition-all flex-shrink-0 ${X===`${t.id}-target`?"bg-orange-100 text-orange-600":"bg-primary-50 text-primary-600 hover:bg-primary-100"}`,title:"Select voice",children:e.jsx(lt,{className:"w-4 h-4"})}),X===`${t.id}-target`&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-72 bg-white rounded-lg shadow-xl border border-slate-200 z-50",children:e.jsxs("div",{className:"p-2 max-h-64 overflow-y-auto",children:[e.jsx("button",{onClick:()=>{const a=new Map(B);a.delete(`${t.id}-target`),de(a),P(null)},className:"w-full text-left px-3 py-2 text-sm hover:bg-slate-50 rounded-md mb-1 bg-primary-50 text-primary-700 font-medium",children:"🌟 Auto (Best Voice for Language)"}),(()=>{const a=t.target_language||"en";return pe.filter(n=>n.lang.startsWith(a)?![/bubble/i,/bell/i,/boing/i,/buzzer/i,/click/i,/clong/i,/ding/i,/echo/i,/effect/i,/fanfare/i,/growl/i,/horn/i,/klaxon/i,/laughter/i,/monster/i,/robot/i,/scream/i,/whisper/i,/wobble/i,/zip/i].some(m=>m.test(n.name)):!1).slice(0,10).map((n,l)=>{var p;const m=`${t.id}-target`,h=((p=B.get(m))==null?void 0:p.name)===n.name;return e.jsx("button",{onClick:()=>{const u=new Map(B);u.set(m,n),de(u),P(null)},className:`w-full text-left px-3 py-2 text-sm hover:bg-slate-50 rounded-md mb-1 ${h?"bg-primary-50 text-primary-700 font-medium":""}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-xs text-slate-400 ml-2",children:n.lang})]})},l)})})()]})})]}),e.jsx("button",{onClick:()=>Ie(t.translated_text,t.target_language,t.id,!1),className:`p-2 rounded-full transition-all flex-shrink-0 ${ee===`${t.id}-target`?"bg-primary-100 text-primary-600 animate-pulse":"bg-primary-50 text-primary-600 hover:bg-primary-100"}`,title:"Listen to translation",children:ee===`${t.id}-target`?e.jsx(it,{className:"w-4 h-4"}):e.jsx(st,{className:"w-4 h-4"})})]})]})})]})]})}),e.jsx("div",{className:"hidden sm:flex absolute top-6 right-6 flex-shrink-0",children:e.jsx("div",{className:"bg-green-100 text-green-700 p-2 rounded-full",children:e.jsx(ue,{className:"w-5 h-5"})})})]})},t.id))}),N>v&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mt-6 pt-4 border-t border-slate-200",children:[e.jsxs("div",{className:"text-sm text-slate-600 w-full sm:w-auto",children:["Showing ",(_-1)*v+1," to ",Math.min(_*v,N)," of ",N," translations"]}),e.jsxs("div",{className:"flex items-center justify-between w-full sm:w-auto gap-2",children:[e.jsxs(I,{onClick:()=>f(t=>Math.max(t-1,1)),disabled:_===1,variant:"outline",size:"sm",className:"border-slate-200 text-slate-600 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed shrink-0",children:[e.jsx(ts,{className:"w-4 h-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:s("common.previous")})]}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 sm:pb-0 max-w-[200px] sm:max-w-none",children:Array.from({length:Math.ceil(N/v)},(t,a)=>a+1).filter(t=>t===1||t===Math.ceil(N/v)||t>=_-1&&t<=_+1).map((t,a,n)=>{const l=n[a-1],m=l&&t-l>1,h=n[a+1],p=h&&h-t>1;return e.jsxs(tt.Fragment,{children:[m&&e.jsx("span",{className:"px-2 text-slate-400 shrink-0",children:"..."}),e.jsx(I,{onClick:()=>f(t),variant:_===t?"default":"outline",size:"sm",className:_===t?"bg-primary-600 text-white hover:bg-primary-700 shrink-0":"border-slate-200 text-slate-600 hover:bg-slate-50 shrink-0",children:t}),p&&e.jsx("span",{className:"px-2 text-slate-400 shrink-0",children:"..."})]},t)})}),e.jsxs(I,{onClick:()=>f(t=>Math.min(t+1,Math.ceil(N/v))),disabled:_===Math.ceil(N/v),variant:"outline",size:"sm",className:"border-slate-200 text-slate-600 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed shrink-0",children:[e.jsx("span",{className:"hidden sm:inline",children:s("common.next")}),e.jsx(ss,{className:"w-4 h-4 sm:ml-1"})]})]})]})]}):e.jsx(O,{className:"border-slate-200",children:e.jsx(R,{className:"p-12",children:e.jsx("div",{className:"flex flex-col items-center justify-center text-center space-y-4",children:$?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-yellow-100 p-4 rounded-full",children:e.jsx(at,{className:"w-8 h-8 text-yellow-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-1",children:s("dashboard.noFavoritesYet",{},"No favorites yet")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm",children:s("dashboard.markFavoritesHint",{},"Mark your most important translations as favorites to find them easily here")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-slate-100 p-4 rounded-full",children:e.jsx(oe,{className:"w-8 h-8 text-slate-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-1",children:s("dashboard.noTranslationsYet",{},"No translations yet")}),e.jsx("p",{className:"text-sm text-slate-500 max-w-sm",children:s("dashboard.startTranslating",{},"Start translating video content to see your recent activity here")})]}),e.jsxs(I,{onClick:()=>window.location.href="/dashboard/subscription",className:"bg-gradient-to-r from-primary-700 to-earth-600 hover:shadow-lg hover:shadow-orange-500/20 transition-all border-0 text-white",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),s("common.startTranslating")]})]})})})})]}),e.jsx(Gt,{isOpen:ht,onClose:()=>fe(!1),onConfirm:jt,title:s("dashboard.history.confirm_title"),message:s("dashboard.history.confirm_message"),warning:s("dashboard.history.confirm_warning"),confirmText:s("dashboard.history.confirm_delete"),cancelText:s("dashboard.history.confirm_cancel"),loading:xt}),Te&&e.jsx(ls,{isOpen:Te,onClose:bt,onUpgrade:ft,segment:J,remainingTranslations:gt,usagePercentage:ce})]})})}export{Qs as default};

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.