import{r as i,j as e,L}from"./vendor-react-BwKDLVNL.js";import{l as D,aD as K,v as b,w as f,x as n,y as c,A as g,H as N,z as u,aM as G,X as Q,F as v,I as C,B as h,ay as Y,ax as J,J as U,K as R,L as F,aK as W,W as O}from"./index-C1ye5P3I.js";import"./vendor-dayjs-5tvLiZdS.js";import{M as X,d as q}from"./MarketingShell-pJlumM7K.js";import{k as V,K as E}from"./kbArticlesApi-BgZHE3Wr.js";import{u as j}from"./vendor-i18n-C6wqqoou.js";import{B as P}from"./bot-r8PTpTqy.js";import{S as Z,P as ee}from"./users-BQu_O3JR.js";import{F as re}from"./file-text-cRwgk8Y4.js";import{S as se}from"./sparkles-f6q4l6Kf.js";import"./vendor-query-D-sr233n.js";import"./vendor-sentry-B6ofghpF.js";import"./vendor-antd-core-4y2ghozH.js";import"./zap-Bd320S-h.js";import"./globe-C6LFgqFt.js";import"./shield-check-CUe1YrFZ.js";import"./SiteFooter-CMa-vyJL.js";import"./send-BPZS28JS.js";import"./building-2-BaHHBpzk.js";const ae={async search(s){const{data:a}=await D.post("/help/search",{query:s});return a}},I={payment:re,delivery:J,documents:q,applications:ee,account:Z,supplier:Y},z=["payment","delivery","documents","applications","account","supplier"],te={high:{label:"Высокая уверенность",color:"text-green-600"},medium:{label:"Средняя уверенность",color:"text-amber-600"},low:{label:"Совпадений мало",color:"text-gray-400"}};function le({result:s}){const{t:a}=j(),o=te[s.confidence];return e.jsxs(v,{className:"border-primary/20 bg-primary/5",children:[e.jsx(R,{className:"pb-2",children:e.jsxs(F,{className:"text-sm flex items-center gap-2",children:[e.jsx(P,{className:"w-4 h-4 text-primary"}),a("helpCenter.aiHelp.answerTitle","Ответ AI"),e.jsx(g,{variant:"neutral",className:`ml-auto text-xs font-normal ${o.color}`,children:a(`helpCenter.aiHelp.confidence.${s.confidence}`,o.label)})]})}),e.jsxs(C,{className:"space-y-4",children:[e.jsx(u,{className:"text-sm leading-relaxed",children:s.answer}),s.sources.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-gray-400 mb-2 flex items-center gap-1",children:[e.jsx(se,{className:"w-3 h-3"}),a("helpCenter.aiHelp.sources","Рсточники")]}),e.jsx(n,{gap:2,children:s.sources.map(t=>e.jsx(L,{to:`/help/article/${t.slug}`,className:"block rounded-lg border border-border bg-white dark:bg-gray-900 px-3 py-2.5 hover:border-primary/40 hover:bg-primary/5 transition-colors group",children:e.jsxs(c,{gap:2,align:"center",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white group-hover:text-primary truncate",children:t.title}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5 line-clamp-1",children:t.excerpt})]}),e.jsx(O,{className:"w-3.5 h-3.5 text-gray-300 group-hover:text-primary shrink-0"})]})},t.articleId))})]})]})]})}function ie(){const{t:s}=j();return e.jsxs(v,{className:"border-primary/20 bg-primary/5",children:[e.jsx(R,{className:"pb-2",children:e.jsxs(F,{className:"text-sm flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-primary animate-spin"}),s("helpCenter.aiHelp.searching","Рщу ответ...")]})}),e.jsxs(C,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-full"}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-4/5"}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/5"})]}),e.jsx("div",{className:"space-y-2 pt-2",children:[1,2].map(a=>e.jsx("div",{className:"h-12 bg-gray-100 dark:bg-gray-800 rounded-lg animate-pulse"},a))})]})]})}function B({article:s}){const{t:a}=j();return e.jsx(L,{to:`/help/article/${s.id}`,className:"block rounded-lg border border-border bg-white dark:bg-gray-900 px-4 py-3 hover:border-primary/40 hover:bg-primary/5 transition-colors group",children:e.jsxs(c,{gap:2,align:"center",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white group-hover:text-primary",children:s.title}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5 line-clamp-1",children:s.body.slice(0,100)})]}),s.popular&&e.jsx(g,{variant:"neutral",className:"text-xs shrink-0",children:a("helpCenter.aiHelp.popularBadge","Популярное")}),e.jsx(O,{className:"w-3.5 h-3.5 text-gray-300 group-hover:text-primary shrink-0"})]})})}function Ae(){const{t:s}=j(),[a,o]=i.useState(""),[t,w]=i.useState(null),[d,_]=i.useState([]),[$,k]=i.useState(!0),[m,x]=i.useState({status:"idle"}),A=i.useRef(null),p=i.useRef(null);i.useEffect(()=>{k(!0),V.list({category:t??void 0}).then(_).finally(()=>k(!1))},[t]),i.useEffect(()=>{const r=a.trim();if(!r){x({status:"idle"});return}return p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{x({status:"searching"}),ae.search(r).then(l=>x({status:"done",result:l})).catch(()=>x({status:"error"}))},600),()=>{p.current&&clearTimeout(p.current)}},[a]);const H=i.useMemo(()=>d.filter(r=>r.popular),[d]),M=i.useMemo(()=>{const r={};for(const l of d)r[l.category]||(r[l.category]=[]),r[l.category].push(l);return r},[d]),S=a.trim().length>0;return e.jsxs(X,{children:[e.jsxs(K,{children:[e.jsx("title",{children:s("helpCenter.aiHelp.seoTitle","Центр помощи — Avalog")}),e.jsx("meta",{name:"description",content:s("helpCenter.aiHelp.seoDescription","Ответы РЅР° РІРѕРїСЂРѕСЃС‹ Рѕ доставке РіСЂСѓР·РѕРІ, таможне, документах Рё оплате. AI-РїРѕРёСЃРє РїРѕ базе знаний Avalog.")})]}),e.jsxs(b,{py:"xl",bg:"surface",className:"relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 to-transparent pointer-events-none"}),e.jsx(f,{size:"2xl",className:"px-4 sm:px-6",children:e.jsxs(n,{gap:6,align:"center",className:"text-center max-w-2xl mx-auto",children:[e.jsxs(c,{gap:2,align:"center",justify:"center",children:[e.jsx(P,{className:"w-6 h-6 text-primary"}),e.jsx(g,{variant:"neutral",className:"text-xs",children:s("helpCenter.aiHelp.aiSearchBadge","AI-РїРѕРёСЃРє")})]}),e.jsx(N,{size:"h1",className:"text-3xl sm:text-4xl font-bold",children:s("helpCenter.aiHelp.heroTitle","Чем РјРѕРіСѓ помочь?")}),e.jsx(u,{className:"text-lg text-gray-500",children:s("helpCenter.aiHelp.heroSubtitle","Задайте РІРѕРїСЂРѕСЃ — AI найдёт ответ РІ базе знаний Avalog")}),e.jsxs("div",{className:"relative w-full max-w-xl",children:[e.jsx(G,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 pointer-events-none"}),e.jsx("input",{ref:A,type:"text",value:a,onChange:r=>o(r.target.value),placeholder:s("helpCenter.aiHelp.searchPlaceholder","Например: как оплатить счёт или сколько идёт таможня..."),className:"w-full h-14 pl-12 pr-12 rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-sm shadow-sm focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary transition",autoFocus:!0}),a&&e.jsx("button",{type:"button",onClick:()=>{var r;o(""),(r=A.current)==null||r.focus()},className:"absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:e.jsx(Q,{className:"w-5 h-5"})})]}),!S&&e.jsx(c,{gap:2,justify:"center",wrap:!0,children:[s("helpCenter.aiHelp.suggested.payInvoice","Как оплатить счёт"),s("helpCenter.aiHelp.suggested.deliveryTimes","РЎСЂРѕРєРё доставки"),s("helpCenter.aiHelp.suggested.customsDuties","Таможенные пошлины"),s("helpCenter.aiHelp.suggested.getUpd","Получить РЈРџР”")].map(r=>e.jsx("button",{type:"button",onClick:()=>o(r),className:"text-xs px-3 py-1.5 rounded-full border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-600 hover:border-primary/40 hover:text-primary transition",children:r},r))})]})})]}),e.jsx(b,{py:"lg",bg:"base",children:e.jsx(f,{size:"2xl",className:"px-4 sm:px-6",children:S?e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[m.status==="searching"&&e.jsx(ie,{}),m.status==="done"&&e.jsx(le,{result:m.result}),m.status==="error"&&e.jsx(v,{className:"border-red-200 bg-red-50",children:e.jsx(C,{className:"py-4",children:e.jsx(u,{className:"text-sm text-red-700",children:s("helpCenter.aiHelp.searchError","РќРµ удалось выполнить РїРѕРёСЃРє. Попробуйте ещё раз или обратитесь РІ поддержку.")})})})]}):e.jsxs(n,{gap:8,children:[e.jsxs(c,{gap:2,justify:"center",wrap:!0,children:[e.jsx(h,{variant:t===null?"default":"outline",size:"sm",onClick:()=>w(null),children:s("helpCenter.aiHelp.allTopics","Р’СЃРµ темы")}),z.map(r=>{const l=I[r];return e.jsxs(h,{variant:t===r?"default":"outline",size:"sm",onClick:()=>w(y=>y===r?null:r),children:[e.jsx(l,{className:"w-3.5 h-3.5"}),s(`helpCenter.aiHelp.categories.${r}`,E[r])]},r)})]}),$?e.jsx(n,{gap:3,children:[1,2,3,4].map(r=>e.jsx("div",{className:"h-14 rounded-lg bg-gray-100 dark:bg-gray-800 animate-pulse"},r))}):e.jsxs(e.Fragment,{children:[H.length>0&&!t&&e.jsxs(n,{gap:3,children:[e.jsx(N,{size:"h2",className:"text-lg font-semibold",children:s("helpCenter.aiHelp.popularQuestions","Популярные РІРѕРїСЂРѕСЃС‹")}),H.map(r=>e.jsx(B,{article:r},r.id)),e.jsx(U,{})]}),e.jsx("div",{className:"grid gap-8 md:grid-cols-2",children:z.filter(r=>!t||t===r).map(r=>{const l=M[r]??[];if(!l.length)return null;const y=I[r];return e.jsxs(n,{gap:3,children:[e.jsxs(c,{gap:2,align:"center",children:[e.jsx(y,{className:"w-4 h-4 text-primary"}),e.jsx(N,{size:"h3",className:"text-base font-semibold",children:s(`helpCenter.aiHelp.categories.${r}`,E[r])}),e.jsx(g,{variant:"neutral",className:"text-xs ml-auto",children:l.length})]}),l.map(T=>e.jsx(B,{article:T},T.id))]},r)})})]})]})})}),e.jsx(b,{py:"md",bg:"surface",className:"text-center",children:e.jsx(f,{size:"sm",className:"px-4",children:e.jsxs(n,{gap:3,align:"center",children:[e.jsx(u,{className:"font-medium",children:s("helpCenter.aiHelp.noAnswerTitle","РќРµ нашли ответ?")}),e.jsxs(c,{gap:3,justify:"center",children:[e.jsx(h,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:"mailto:support@avalog.ru",children:s("helpCenter.aiHelp.writeEmail","Написать РЅР° email")})}),e.jsx(h,{size:"sm",asChild:!0,children:e.jsx("a",{href:"https://t.me/avalog_support",target:"_blank",rel:"noopener noreferrer",children:"Telegram"})})]})]})})})]})}export{Ae as default};