1import{r as h,j as e,aM as u,bD as g,bF as y,L as b}from"./index-Dz0Ir0TL.js";import{u as f}from"./useMutation-BDakb1ef.js";import{l as j,a as v,b as N,m as w}from"./translations.functions-_rmaunRr.js";import{t as S}from"./supplier-translate.functions-DEW_FB3Z.js";const E=[{value:"content",label:"Content"},{value:"author",label:"Authors"},{value:"term",label:"Terms"},{value:"ui",label:"UI strings"}],T=[{value:"",label:"All types"},{value:"post",label:"Posts"},{value:"product_type",label:"Product types"},{value:"supplier",label:"Suppliers"},{value:"production_country",label:"Countries"},{value:"solution",label:"Solutions"},{value:"download",label:"Downloads"}],_=[{value:"all",label:"All"},{value:"translated",label:"Translated"},{value:"missing",label:"Missing DE"},{value:"stale",label:"Stale DE"},{value:"orphan",label:"Orphan DE"}];function L(){const[t,n]=h.useState("content");return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h1",{className:"text-xl font-semibold",children:"Translations"})}),e.jsx("div",{className:"mt-4 flex gap-1 border-b border-border-strong",children:E.map(l=>e.jsx("button",{type:"button",onClick:()=>n(l.value),className:"px-3 py-2 text-sm -mb-px border-b-2",style:{borderColor:t===l.value?"hsl(var(--accent, 18 95% 55%))":"transparent",color:t===l.value?"var(--fg)":"var(--fg-muted)",fontWeight:t===l.value?600:400},children:l.label},l.value))}),e.jsx("div",{className:"mt-6",children:t==="ui"?e.jsx(F,{}):e.jsx(k,{scope:t})})]})}function k({scope:t}){const[n,l]=h.useState(""),[x,p]=h.useState("all"),d=u(v),{data:c,isLoading:r,refetch:a}=g({queryKey:["admin-translations",t,n,x],queryFn:()=>d({data:{scope:t,type:t==="content"&&n?n:void 0,status:x,limit:300}})}),i=c??[],o={total:i.length,translated:i.filter(s=>s.en&&s.de&&!s.stale).length,stale:i.filter(s=>s.stale).length,missing:i.filter(s=>s.en&&!s.de).length,orphan:i.filter(s=>!s.en&&s.de).length};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[t==="content"&&e.jsx("select",{value:n,onChange:s=>l(s.target.value),className:"rounded-md border border-border-strong bg-bg-elevated px-2 py-1",children:T.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("select",{value:x,onChange:s=>p(s.target.value),className:"rounded-md border border-border-strong bg-bg-elevated px-2 py-1",children:_.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsxs("div",{className:"ml-auto text-fg-muted",children:[o.translated," ok · ",o.stale," stale · ",o.missing," missing · ",o.orphan," orphan · ",o.total," total"]})]}),e.jsx("div",{className:"mt-4 rounded-lg border border-border-strong overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated text-fg-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Type"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"EN title"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"DE status"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Last update"}),e.jsx("th",{className:"px-4 py-2 text-right font-medium",children:"Actions"})]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-fg-muted",children:"Loadingâ¦"})}),!r&&i.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-fg-muted",children:"No rows."})}),i.map(s=>e.jsx(D,{g:s,scope:t,onChange:a},s.translation_group_id))]})]})})]})}function D({g:t,scope:n,onChange:l}){const x=u(N),p=u(w),d=u(S),c=y(),r=f({mutationFn:m=>x({data:{sourceId:m}}),onSuccess:()=>{c.invalidateQueries({queryKey:["admin-translations"]}),l()}}),a=f({mutationFn:m=>p({data:{id:m}}),onSuccess:()=>{c.invalidateQueries({queryKey:["admin-translations"]}),l()}}),i=f({mutationFn:m=>d({data:{id:m,fields:["profile_description_html","company_tagline","listing_description","core_products_html","general_moqs","trust_description","supplier_faq","moq_table","featured_labels"]}}),onSuccess:()=>{c.invalidateQueries({queryKey:["admin-translations"]}),l()}}),o=n==="content",s=n==="content"&&t.type!=="solution";return e.jsxs("tr",{className:"border-t border-border-strong align-top",children:[e.jsx("td",{className:"px-4 py-2 text-fg-muted whitespace-nowrap",children:t.type}),e.jsxs("td",{className:"px-4 py-2",children:[o&&t.en?e.jsx(b,{to:"/admin/content/$id/",params:{id:t.en.id},className:"hover:underline",children:t.en.title}):t.en?.title??e.jsx("span",{className:"text-fg-muted italic",children:"(no EN)"}),e.jsx("div",{className:"text-[11px] text-fg-muted",children:t.en?.slug})]}),e.jsx("td",{className:"px-4 py-2",children:t.type==="solution"?e.jsx("span",{className:"inline-flex items-center rounded-full bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-700",title:"Money page; translated via i18n extraction in the route file, not via the DB pipeline.",children:"N/A · hardcoded route"}):!t.en&&t.de?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-[11px] font-medium text-purple-800",children:["Orphan · ",t.de.slug]}):t.stale?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-[11px] font-medium text-orange-800",title:"EN was updated after DE was last reviewed",children:["Stale · ",t.de?.slug]}):t.de?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-800",children:["OK · ",t.de.slug]}):e.jsx("span",{className:"inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-800",children:"Missing"})}),e.jsx("td",{className:"px-4 py-2 text-fg-muted whitespace-nowrap",children:t.de?.updated_at?new Date(t.de.updated_at).toLocaleStr
1ing():t.en?.updated_at?new Date(t.en.updated_at).toLocaleString():"â"}),e.jsxs("td",{className:"px-4 py-2 text-right whitespace-nowrap",children:[o&&t.de&&e.jsx(b,{to:"/admin/content/$id/",params:{id:t.de.id},className:"mr-2 text-xs text-fg-muted hover:underline",children:"Open DE"}),s&&t.en&&(t.stale||!t.de)&&e.jsx("button",{type:"button",onClick:()=>{t.de&&!confirm("Overwrite the existing DE translation?")||r.mutate(t.en.id)},disabled:r.isPending,className:"mr-2 inline-flex items-center rounded-md bg-accent px-2.5 py-1 text-xs font-medium text-fg-on-accent disabled:opacity-50",title:"Translate ENâDE with Lovable AI using the Wonnda glossary",children:r.isPending?"Translatingâ¦":t.de?"Retranslate":"AI translate"}),n==="content"&&t.type==="supplier"&&t.de&&e.jsx("button",{type:"button",onClick:()=>{confirm("Overwrite all German supplier profile fields (description, tagline, MOQs, FAQ, labels) with fresh AI translations?")&&i.mutate(t.de.id)},disabled:i.isPending,className:"mr-2 rounded-md border border-border-strong px-2 py-1 text-xs font-medium disabled:opacity-50",title:"Translate the supplier-specific fields (profile description, tagline, MOQ table, FAQ, labels) EN -> DE",children:i.isPending?"Translatingâ¦":"Supplier fields"}),o&&t.de&&t.stale&&e.jsx("button",{type:"button",onClick:()=>a.mutate(t.de.id),disabled:a.isPending,className:"text-xs text-fg-muted underline disabled:opacity-50",title:"Mark current DE as reviewed (clears stale flag)",children:"Mark reviewed"}),i.isError&&e.jsx("div",{className:"text-[11px] text-red-600 mt-1 max-w-xs whitespace-normal text-right",children:i.error?.message}),r.isError&&e.jsx("div",{className:"text-[11px] text-red-600 mt-1 max-w-xs whitespace-normal text-right",children:r.error?.message})]})]})}function F(){const t=u(j),[n,l]=h.useState("untranslated"),{data:x,isLoading:p}=g({queryKey:["admin-ui-strings"],queryFn:()=>t()}),d=x??[],c=d.filter(a=>n==="all"||a.status===n),r={total:d.length,ok:d.filter(a=>a.status==="ok").length,untranslated:d.filter(a=>a.status==="untranslated").length,empty:d.filter(a=>a.status==="empty").length};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("select",{value:n,onChange:a=>l(a.target.value),className:"rounded-md border border-border-strong bg-bg-elevated px-2 py-1",children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"untranslated",children:"Untranslated (DE = EN)"}),e.jsx("option",{value:"empty",children:"Empty"})]}),e.jsxs("div",{className:"ml-auto text-fg-muted",children:[r.ok," ok · ",r.untranslated," untranslated · ",r.empty," empty · ",r.total," total"]})]}),e.jsxs("p",{className:"mt-3 text-xs text-fg-muted",children:["UI strings live in ",e.jsx("code",{children:"src/i18n/messages/en.ts"})," and"," ",e.jsx("code",{children:"src/i18n/messages/de.ts"}),". Translate flagged keys directly in those files. TypeScript enforces presence; this view flags values that are empty or identical to EN (likely never translated)."]}),e.jsx("div",{className:"mt-4 rounded-lg border border-border-strong overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated text-fg-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Key"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"EN"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"DE"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Status"})]})}),e.jsxs("tbody",{children:[p&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-fg-muted",children:"Loadingâ¦"})}),!p&&c.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-8 text-center text-fg-muted",children:"No matching rows."})}),c.map(a=>e.jsxs("tr",{className:"border-t border-border-strong align-top",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-[11px] text-fg-muted whitespace-nowrap",children:a.key}),e.jsx("td",{className:"px-4 py-2 max-w-md whitespace-pre-wrap",children:a.en}),e.jsx("td",{className:"px-4 py-2 max-w-md whitespace-pre-wrap",children:a.de||e.jsx("span",{className:"italic text-fg-muted",children:"(empty)"})}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:a.status==="ok"?e.jsx("span",{className:"inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-800",children:"OK"}):a.status==="untranslated"?e.jsx("span",{className:"inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-[11px] font-medium text-orange-800",children:"Untranslated"}):e.jsx("span",{className:"inline-flex items-center rounded-full bg-red-100 px-2 py-0.5 text-[11px] font-medium text-red-800",children:"Empty"})})]},a.key))]})]})})]})}export{L 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.