import{a as K,r as i,j as e,A as Tn,T as S,S as Le,R as Fn,L as O,F as ve,E as _e,u as xt,b as qt,I as V,c as In,B as E,d as gt,e as mt,f as yt,g as qe,C as Ye,h as _t,i as q,k as ee,l as vt,W as Rn,m as Bt,n as Dn,D as Gt,o as En,p as Mn,q as Ln,N as $n,O as Pn,s as Qe,t as X,v as Ee,w as Xe,x as Ut,M as $e,y as Vt,z as ne,G as Wn,Q as An,H as de,P as zn,J as je,K as be,U as Se,V as Nn,X as Hn,Y as On,Z as Kt,_ as Zt,$ as Yt,a0 as Ke,a1 as ut,a2 as Te,a3 as Qt,a4 as Xt,a5 as Jt,a6 as en,a7 as qn,a8 as Bn,a9 as St,aa as Gn,ab as Un,ac as Vn,ad as Kn,ae as Zn}from"./vendor-BaNm9Q0w.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const l of r)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function s(r){const l={};return r.integrity&&(l.integrity=r.integrity),r.referrerPolicy&&(l.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?l.credentials="include":r.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(r){if(r.ep)return;r.ep=!0;const l=s(r);fetch(r.href,l)}})();const Be="/api",Je=`${Be}/v2`,jt=`${Je}/campaign`;function tn(){const t=document.cookie.match(/csrftoken=([^ ;]+)/);if(t)return t[1]}function G(t,n){return K.get(`${Be}/${t}`,n)}function Q(t,n,s){const a={"X-CSRFToken":tn()},r={withCredentials:!0,...s,headers:a};return K.post(`${Be}/${t}`,n,r)}function Yn(t,n){const s={"X-CSRFToken":tn()},a={withCredentials:!0,...n,headers:s};return K.delete(`${Be}/${t}`,a)}function W(t,n){return G(`v2/${t}/`,n)}function oe(t,n,s){return Q(`v2/${t}/`,n,s)}function Qn(t,n){return Yn(`v2/${t}/`,n)}function et(t){var s;const n=(s=t.response)==null?void 0:s.data;return n!=null&&n.detail?n.detail:n!=null&&n.error?n.error:t.message}const y={bluePale:{300:"#80BDFD",500:"#007BFB"},blue:{500:"#0002F3"},cyan:{500:"#00A2E8"},green:{200:"#ADE5D2",500:"#00B774"},primary:{50:"#FFFBF3",200:"#FFE3AB",500:"#F9AB0D"},orange:{500:"#FC8816"},red:{500:"#FF3F3F"},redPale:{400:"#FD7967"},greyF:{100:"#EFF1F5",700:"#6E7788"},greyS:{200:"#D1D1D6"},dark:{500:"#383540"}},Xn={token:{colorPrimary:"#F9AB0D",colorError:"#FF3F3F",colorText:"#383540",colorTextSecondary:"#6E7788",colorTextDisabled:"#C3C3C3",colorBgLayout:"#F7F8FA",borderRadius:6}},Jn=[],es=(t,n)=>{switch(n.type){case"ADD":return[n.payload,...t];case"REMOVE":return t.filter(s=>s.id!==n.payload);default:return t}},nn=i.createContext(Jn),A=()=>i.useContext(nn);function ts({children:t}){const[n,s]=i.useReducer(es,[]),a=(o,u)=>{const p=Math.round(Math.random()*1e9);s({type:"ADD",payload:{id:p,severity:"info",text:o,...u}}),setTimeout(()=>{r(p)},5e3)},r=o=>{s({type:"REMOVE",payload:o})},l=(o,u={})=>{a(o,{...u,severity:"error"})},h={showMessage:a,showError:l,showRequestError:o=>{l(et(o))}};return e.jsxs(nn.Provider,{value:h,children:[t,e.jsx("div",{style:{position:"fixed",left:0,bottom:0,zIndex:2e3,display:"flex",flexDirection:"column",gap:4,padding:4},children:n.map(o=>e.jsx(Tn,{type:o.severity==="error"?"error":"info",title:o.text,closable:!0,onClose:()=>r(o.id),showIcon:!0},o.id))})]})}const Ve="Панель";function Ne({current:t,prev:n}){if(t==null||n==null)return"—";const s=t-n,a=n?(s/n*100).toFixed(1):0,r=s>=0,l=r?y.green[500]:y.red[500],c=r?mt:yt;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2},children:[e.jsx("span",{style:{fontWeight:500},children:t.toLocaleString("ru-RU")}),e.jsxs("span",{style:{fontSize:12,color:l,display:"flex",alignItems:"center",gap:2},children:[e.jsx(c,{style:{fontSize:10}}),Math.abs(s).toLocaleString("ru-RU")," (",r?"+":"",a,"%)"]})]})}function Ct({placeholder:t,onSearch:n,options:s,onSelect:a,notFoundText:r}){const[l,c]=i.useState(""),[h,o]=xt("",300);i.useEffect(()=>{n(h)},[h]);const u=d=>{c(d),o(d)},p=(d,f)=>{a(d,f),c(""),o("")};return e.jsx(qt,{value:l,options:l.length>=2?s:[],onSelect:p,onChange:u,style:{width:"100%"},notFoundContent:l.length<2?null:e.jsx(_e,{image:_e.PRESENTED_IMAGE_SIMPLE,description:r||"Ничего не найдено"}),children:e.jsx(V,{placeholder:t,prefix:e.jsx(In,{style:{color:y.greyF[500]}}),allowClear:!0})})}function ns(t){return[{title:"Предмет",dataIndex:"subject_name",key:"name",render:(n,s)=>e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:n}),e.jsx("div",{style:{fontSize:12,color:y.greyF[700]},children:s.category_name})]})},{title:"Продавцы",key:"sellers",align:"right",render:(n,s)=>e.jsx(Ne,{current:s.sellers,prev:s.sellers_prev})},{title:"Карточки",key:"cards",align:"right",render:(n,s)=>e.jsx(Ne,{current:s.cards,prev:s.cards_prev})},{title:"Заказы",key:"orders",align:"right",render:(n,s)=>e.jsx(Ne,{current:s.orders,prev:s.orders_prev})},{title:"",key:"actions",width:40,render:(n,s)=>e.jsx(E,{type:"text",size:"small",icon:e.jsx(gt,{style:{fontSize:10,color:y.greyF[500]}}),onClick:a=>{a.stopPropagation(),t(s.key)}})}]}function ss(t){return[{title:"Запрос",dataIndex:"text",key:"text",render:n=>e.jsx("span",{style:{fontWeight:500},children:n})},{title:"Вчера",key:"day",align:"right",render:(n,s)=>e.jsx(Ne,{current:s.day,prev:s.day_prev})},{title:"Неделя",key:"week",align:"right",render:(n,s)=>e.jsx(Ne,{current:s.week,prev:s.week_prev})},{title:"",key:"actions",width:40,render:(n,s)=>e.jsx(E,{type:"text",size:"small",icon:e.jsx(gt,{style:{fontSize:10,color:y.greyF[500]}}),onClick:a=>{a.stopPropagation(),t(s.record_id)}})}]}function as(){const{showRequestError:t}=A(),[n,s]=i.useState(!0),[a,r]=i.useState(!1),[l,c]=i.useState([]),[h,o]=i.useState([]),[u,p]=i.useState([]),[d,f]=i.useState([]),g=i.useRef(null),_=i.useRef(null),[m,v]=i.useState([]),[k,b]=i.useState([]);i.useEffect(()=>{const x=sessionStorage.getItem("wb_key");x&&(sessionStorage.removeItem("wb_key"),oe("user/key-check",{key:x}))},[]),i.useEffect(()=>{T()},[]);const C=i.useCallback(x=>{if(x.length<2){v([]);return}G("wbstat/subjects/search/",{params:{query:x}}).then(j=>{v(j.data||[])})},[]),F=i.useCallback(x=>{if(x.length<2){b([]);return}G("wbstat/phrases/search/",{params:{query:x}}).then(j=>{b(j.data||[])})},[]);async function T(){var x,j;s(!0);try{const[w,R]=await Promise.all([G("wbstat/dashboard/phrase-groups/"),G("wbstat/dashboard/subject-groups/")]),D=(w.data||[]).find(We=>We.name===Ve),M=(R.data||[]).find(We=>We.name===Ve);g.current=D||null,_.current=M||null;const[N,te]=await Promise.all([D?G(`wbstat/dashboard/phrase-groups/${D.id}/phrases/`):Promise.resolve({data:{phrases:[]}}),M?G(`wbstat/dashboard/subject-groups/${M.id}/subjects/`):Promise.resolve({data:{subjects:[]}})]),ye=((x=N.data)==null?void 0:x.phrases)||[],ke=((j=te.data)==null?void 0:j.subjects)||[];o(ye),c(ke),await L(ke,ye)}catch(w){t(w)}finally{s(!1)}}async function L(x=l,j=h){var D,M;const w=x.map(N=>N.subject_id),R=j.map(N=>N.text);if(w.length===0&&R.length===0){p([]),f([]);return}r(!0);try{const N=await Q("wbstat/dashboard/tables/",{subject_ids:w,queries:R});p(((D=N.data)==null?void 0:D.subjects)||[]),f(((M=N.data)==null?void 0:M.queries)||[])}catch(N){t(N)}finally{r(!1)}}async function I(){if(g.current)return g.current;const x=await Q("wbstat/dashboard/phrase-groups/",{name:Ve,description:"Dashboard panel"});return g.current=x.data,x.data}async function Z(){if(_.current)return _.current;const x=await Q("wbstat/dashboard/subject-groups/",{name:Ve,description:"Dashboard panel"});return _.current=x.data,x.data}async function fe(x){var w;const j=Number(x);if(!(!j||l.some(R=>R.subject_id===j)))try{const R=await Z(),M=((w=(await Q(`wbstat/dashboard/subject-groups/${R.id}/add/`,{subjects:[j]})).data)==null?void 0:w.subjects)||[];c(M),await L(M,h)}catch(R){t(R)}}async function xe(x){var w;const j=l.find(R=>R.subject_id===x);if(j)try{const R=_.current,M=((w=(await Q(`wbstat/dashboard/subject-groups/${R.id}/remove/`,{ids:[j.id]})).data)==null?void 0:w.subjects)||[];c(M),await L(M,h)}catch(R){t(R)}}async function $(x){var j;if(!(!x||h.some(w=>w.text===x)))try{const w=await I(),D=((j=(await Q(`wbstat/dashboard/phrase-groups/${w.id}/add/`,{phrases:[x]})).data)==null?void 0:j.phrases)||[];o(D),await L(l,D)}catch(w){t(w)}}async function z(x){var j;try{const w=g.current,D=((j=(await Q(`wbstat/dashboard/phrase-groups/${w.id}/remove/`,{ids:[x]})).data)==null?void 0:j.phrases)||[];o(D),await L(l,D)}catch(w){t(w)}}const ae=new Set(l.map(x=>x.subject_id)),ge=m.filter(x=>!ae.has(x.id)).map(x=>{var j;return{value:String(x.id),label:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:x.name}),e.jsx(S.Text,{type:"secondary",style:{fontSize:12},children:(j=x.category)==null?void 0:j.name})]})}}),me=new Set(h.map(x=>x.text)),Pe=k.filter(x=>!me.has(x.text)).map(x=>{var j;return{value:x.text,label:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:x.text}),e.jsxs(S.Text,{type:"secondary",style:{fontSize:12},children:[x.subject&&e.jsxs(e.Fragment,{children:[x.subject," · "]}),(j=x.count)==null?void 0:j.toLocaleString("ru-RU")]})]})}}),st=u.map(x=>({key:x.subject_id,subject_name:x.subject_name,category_name:x.category_name,sellers:x.suppliers_with_sells,sellers_prev:x.suppliers_with_sells_prev,cards:x.cards_with_orders_count,cards_prev:x.cards_with_orders_count_prev,orders:x.orders_qty,orders_prev:x.orders_qty_prev})),at=d.map(x=>{const j=h.find(w=>w.text===x.text);return{key:x.text,record_id:j==null?void 0:j.id,text:x.text,day:x.yesterday_count,day_prev:x.yesterday_prev_count,week:x.week_count,week_prev:x.week_prev_count}}),rt=ns(xe),it=ss(z);return n?e.jsx("div",{style:{display:"flex",justifyContent:"center",paddingTop:100},children:e.jsx(Le,{indicator:e.jsx(Fn,{style:{fontSize:32},spin:!0})})}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:32,maxWidth:720},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12},children:[e.jsx(S.Title,{level:4,style:{margin:0},children:"Предметы"}),e.jsx(O,{to:"/external-analytics/niche-analysis",style:{textDecoration:"none",color:y.primary[500],fontWeight:600,fontSize:13},children:"Смотреть все"})]}),e.jsx(Ct,{placeholder:"Найти предмет...",onSearch:C,options:ge,onSelect:fe,notFoundText:"Предмет не найден"}),l.length>0?e.jsx(ve,{dataSource:st,columns:rt,pagination:!1,size:"small",bordered:!1,loading:a,locale:{emptyText:e.jsx(_e,{description:"Нет данных",image:_e.PRESENTED_IMAGE_SIMPLE})}}):e.jsx(S.Text,{type:"secondary",style:{padding:"8px 0"},children:"Добавьте предметы для отслеживания"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12},children:[e.jsx(S.Title,{level:4,style:{margin:0},children:"Запросы"}),e.jsx(O,{to:"/search-queries",style:{textDecoration:"none",color:y.primary[500],fontWeight:600,fontSize:13},children:"Смотреть все"})]}),e.jsx(Ct,{placeholder:"Найти запрос...",onSearch:F,options:Pe,onSelect:$,notFoundText:"Запрос не найден"}),h.length>0?e.jsx(ve,{dataSource:at,columns:it,pagination:!1,size:"small",bordered:!1,loading:a,locale:{emptyText:e.jsx(_e,{description:"Нет данных",image:_e.PRESENTED_IMAGE_SIMPLE})}}):e.jsx(S.Text,{type:"secondary",style:{padding:"8px 0"},children:"Добавьте запросы для отслеживания"})]})]})}const Ge=[{id:6,name:"Поиск"},{id:5,name:"Карточки"}],rs=[{id:0,name:"Все"},{id:1,name:"Активные"},{id:2,name:"Остановлены"},{id:3,name:"Неактивные"},{id:4,name:"Без биддера"}],sn=[{id:7,name:"Завершена"},{id:9,name:"Активна"},{id:11,name:"Приостановлена"}],is=[{id:0,name:"Все"},...sn],ls=t=>{const n=sn.find(s=>s.id===t);return n?n.name:""},os=[{title:"Кампания",dataIndex:"id",key:"id"},{title:"Параметры",key:"name",render:(t,n)=>{var s,a;return n.name||((s=n.bidder)==null?void 0:s.query)||((a=n.bidder)==null?void 0:a.name)}},{title:"Статус",key:"status",render:(t,n)=>ls(n.status)},{title:"Текущая ставка",key:"bet",align:"right",render:(t,n)=>{var s;return(s=n.bidder)==null?void 0:s.bet}},{title:"Позиция",key:"place",align:"right",render:(t,n)=>{var s;return(s=n.bidder)==null?void 0:s.place}},{title:"Биддер",key:"active",render:(t,n)=>{var s;return e.jsx(Ye,{checked:((s=n.bidder)==null?void 0:s.active)||!1})}},{title:"Макс ставка",key:"maxbet",align:"right",render:(t,n)=>{var s;return(s=n.bidder)==null?void 0:s.maxbet}},{title:"Макс позиция",key:"top_place",align:"right",render:(t,n)=>{var s;return(s=n.bidder)==null?void 0:s.top_place}},{title:"Мин позиция",key:"low_place",align:"right",render:(t,n)=>{var s;return(s=n.bidder)==null?void 0:s.low_place}}];function cs({rows:t}){const n=qe();return e.jsx(ve,{columns:os,dataSource:t||[],rowKey:(s,a)=>a,size:"small",pagination:!1,scroll:{x:900},onRow:s=>({onClick:()=>{const a=s.bidder?`/campaigns/${s.bidder.id}/bidder`:`/campaigns/${s.id}`;n(a)},style:{cursor:"pointer"}})})}function ds({options:t,value:n,onChange:s}){function a(l){return t.findIndex(c=>c.id===l)}const r=t.map((l,c)=>({key:String(c),label:l.name}));return e.jsxs("div",{children:[e.jsx("h4",{children:"Типы кампаний"}),e.jsx(_t,{tabPosition:"left",activeKey:String(a(n)),onChange:l=>{s&&s(t[parseInt(l)].id)},items:r})]})}function us({options:t,value:n,onChange:s}){const a=t.map((r,l)=>({key:String(l),label:r.name}));return e.jsxs("div",{children:[e.jsx("h4",{children:"Магазины"}),e.jsx(_t,{tabPosition:"left",activeKey:String(n),onChange:r=>{s&&s(parseInt(r))},items:a})]})}function re({count:t=4}){return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[...Array(t)].map((n,s)=>e.jsx(q.Input,{active:!0,block:!0,style:{height:32,width:"100%"}},s))})}function hs({status:t,bidder:n,onChange:s}){return e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8},children:[e.jsx(ee,{style:{flex:1},size:"small",value:t||0,onChange:a=>s&&s("status",a),options:is.map(a=>({value:a.id,label:a.name})),placeholder:"Статус"}),e.jsx(ee,{style:{flex:1},size:"small",value:n||0,onChange:a=>s&&s("bidder",a),options:rs.map(a=>({value:a.id,label:a.name})),placeholder:"Биддер"})]})}const ps=`${Je}/supplier/`,fs=(t,n,s)=>{const a=new URLSearchParams({...s,advert_type:t,supplier_id:n});return`${jt}/?${a.toString()}`};function xs(){const[t,n]=vt(),[s,a]=i.useState(!0),[r,l]=i.useState([]),[c,h]=i.useState([]),[o,u]=i.useState(void 0),p=parseInt(t.get("type")||6),d=parseInt(t.get("supplier")||0),f=parseInt(t.get("status")||0),g=parseInt(t.get("bidder")||0),_=(m,v)=>{const k=new URLSearchParams(t);k.set(m,v),n(k)};return i.useEffect(()=>(r.length===0&&(a(!0),K.get(ps).then(m=>{l(m.data)}).finally(()=>a(!1))),()=>{}),[]),i.useEffect(()=>{var m;if(r.length>0){const v=fs(p,(m=r[d])==null?void 0:m.id,{status:f,bidder:g});a(!0),K.get(v).then(k=>{h(k.data)}).finally(()=>a(!1))}},[r,t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(S.Title,{level:4,style:{margin:0},children:"Кампании"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(ds,{options:Ge,value:p,onChange:m=>_("type",m)}),e.jsx(us,{options:r,value:d,onChange:m=>_("supplier",m)})]}),e.jsxs("div",{style:{flexGrow:1},children:[e.jsx(hs,{status:f,bidder:g,onChange:(m,v)=>_(m,v)}),s?e.jsx(re,{count:5}):e.jsx(cs,{rows:c})]})]})]})}const gs="ooo_mkeeper_web",Me=new Rn({clientId:gs,redirectUri:`${window.location.protocol}//${window.location.host}/wb-id-sdk/callback`,scope:"openid phone"}),an="data:image/svg+xml,%3csvg%20width='128'%20height='128'%20viewBox='0%200%20128%20128'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='128'%20height='128'%20rx='64'%20fill='url(%23paint0_linear_0_1)'/%3e%3cpath%20d='M21.8564%2045.3936H27.9404V50.5889C29.3988%2048.7887%2030.7204%2047.4785%2031.9053%2046.6582C33.9333%2045.2682%2036.2347%2044.5732%2038.8096%2044.5732C41.7262%2044.5732%2044.0732%2045.291%2045.8506%2046.7266C46.8532%2047.5469%2047.7646%2048.7546%2048.585%2050.3496C49.9521%2048.39%2051.5586%2046.943%2053.4043%2046.0088C55.25%2045.0518%2057.3236%2044.5732%2059.625%2044.5732C64.5469%2044.5732%2067.8965%2046.3506%2069.6738%2049.9053C70.6309%2051.8193%2071.1094%2054.3942%2071.1094%2057.6299V82H64.7178V56.5703C64.7178%2054.1322%2064.1025%2052.4574%2062.8721%2051.5459C61.6644%2050.6344%2060.1833%2050.1787%2058.4287%2050.1787C56.0133%2050.1787%2053.9284%2050.9876%2052.1738%2052.6055C50.4421%2054.2233%2049.5762%2056.9235%2049.5762%2060.7061V82H43.3213V58.1084C43.3213%2055.6247%2043.0251%2053.8132%2042.4326%2052.6738C41.4984%2050.9648%2039.7552%2050.1104%2037.2031%2050.1104C34.8789%2050.1104%2032.7598%2051.0104%2030.8457%2052.8105C28.9544%2054.6107%2028.0088%2057.8691%2028.0088%2062.5859V82H21.8564V45.3936ZM80.0303%2031.79H85.9434V60.9453L101.734%2045.3936H109.596L95.582%2059.0996L110.382%2082H102.521L91.1045%2063.543L85.9434%2068.2598V82H80.0303V31.79Z'%20fill='black'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_0_1'%20x1='64'%20y1='32'%20x2='64'%20y2='82'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F27420'/%3e%3cstop%20offset='1'%20stop-color='%23F9AB0D'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",ms="auth_redirect",rn=()=>{const[t,n]=i.useState(!1),s=Bt(),a=()=>{var l;const r=(l=s.state)==null?void 0:l.from;r&&r!=="/auth/login"&&localStorage.setItem(ms,r),Me.login()};return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"calc(100vh - 200px)"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:32},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("img",{src:an,style:{width:48,height:48,borderRadius:24},alt:"mkeeper"}),e.jsx("span",{style:{fontSize:28,fontFamily:"Tahoma, Verdana, Segoe, sans-serif",color:y.dark[500]},children:"mkeeper"})]}),e.jsxs("button",{type:"button",onClick:()=>{n(!0),a()},disabled:t,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,width:320,height:52,padding:"0 24px",background:"#F6F6F9",border:"none",borderRadius:20,cursor:"pointer",fontSize:16,color:"#242429",transition:"background-color 0.2s"},onMouseEnter:r=>r.currentTarget.style.backgroundColor="#EDEDF0",onMouseLeave:r=>r.currentTarget.style.backgroundColor="#F6F6F9",children:[e.jsx("span",{children:"Войти с"}),e.jsxs("svg",{width:"40",height:"20",viewBox:"0 0 40 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M9.585 20C7.007 20 5.451 20 3.917 19.214C2.558 18.518 1.474 17.428 0.782 16.062C0 14.519 0 12.954 0 10.362V9.638C0 7.046 0 5.481 0.782 3.938C1.474 2.572 2.558 1.482 3.917 0.786C5.451 0 7.007 0 9.585 0H30.415C32.993 0 34.549 0 36.083 0.786C37.442 1.482 38.526 2.572 39.218 3.938C40 5.481 40 7.046 40 9.638V10.362C40 12.954 40 14.519 39.218 16.062C38.526 17.428 37.442 18.518 36.083 19.214C34.549 20 32.993 20 30.415 20H9.585Z",fill:"#242429"}),e.jsx("path",{d:"M17.271 6.879C16.552 6.879 15.902 7.098 15.348 7.472V4.052H13.815V10.36C13.815 12.279 15.365 13.824 17.261 13.824C19.158 13.824 20.725 12.289 20.725 10.342C20.725 8.396 19.192 6.879 17.27 6.879ZM10.313 10.806L8.91 7.124H7.836L6.425 10.806L5.014 7.124H3.341L5.81 13.598H6.883L8.364 9.742L9.854 13.598H10.927L13.387 7.124H11.724L10.313 10.806ZM17.262 12.28C16.223 12.28 15.348 11.443 15.348 10.352C15.348 9.261 16.171 8.433 17.271 8.433C18.37 8.433 19.193 9.296 19.193 10.352C19.193 11.407 18.318 12.28 17.262 12.28Z",fill:"#F6F6F9"}),e.jsx("path",{d:"M31.068 7.76H30.071V12.242H31.068C32.242 12.242 33.247 11.346 33.247 10.012C33.247 8.649 32.242 7.76 31.068 7.76Z",fill:"#F6F6F9"}),e.jsx("path",{d:"M36.408 5.378C36.023 4.618 35.408 3.999 34.652 3.612C33.792 3.171 32.666 3.171 30.415 3.171H29.648C27.397 3.171 26.272 3.171 25.412 3.612C24.656 3.999 24.041 4.618 23.656 5.378C23.218 6.242 23.218 7.374 23.218 9.637V10.362C23.218 12.625 23.218 13.757 23.656 14.621C24.041 15.382 24.656 16 25.412 16.387C26.272 16.828 27.397 16.828 29.648 16.828H30.415C32.666 16.828 33.792 16.828 34.652 16.387C35.408 16 36.023 15.382 36.408 14.621C36.846 13.757 36.846 12.625 36.846 10.362V9.637C36.846 7.374 36.846 6.242 36.408 5.378ZM27.425 13.713H25.892V6.286H27.425V13.713ZM31.046 13.713H28.54V6.286H31.046C33.308 6.286 34.781 7.917 34.781 10.01C34.781 12.082 33.308 13.713 31.046 13.713Z",fill:"#F6F6F9"})]})]})]})})},ht={},ln=i.createContext(ht);function ys({children:t}){const[n,s]=i.useState(ht),a=i.useRef(null),r=i.useRef(0),l=i.useCallback(()=>{const o=++r.current;return W("user/profile").then(u=>{o===r.current&&s({...u.data})})},[]),c=()=>{s({...ht,auth:!1})};i.useEffect(()=>{l()},[]),i.useEffect(()=>{if(!n.wb_id)return;const o=new Dn([{transport:"websocket",endpoint:"/api/centrifugo/connection/websocket"}],{getToken:()=>W("user/centrifugo-token").then(p=>p.data.token)}),u=o.newSubscription(`#wb_${n.wb_id}`);return u.on("publication",p=>{var d;((d=p.data)==null?void 0:d.op)==="getProfile"&&l()}),u.subscribe(),o.connect(),a.current=o,()=>{u.unsubscribe(),o.disconnect(),a.current=null}},[n.wb_id,l]);const h={profile:n,getProfile:l,clearProfile:c};return e.jsx(ln.Provider,{value:h,children:t})}const se=()=>i.useContext(ln);function _s(){const t=qe(),{clearProfile:n,profile:s}=se(),a=()=>{Me.logout().then(()=>{}).catch(l=>console.log("wb logout error:",l)),Q("user/logout").then(()=>{n(),t("/")}).catch(l=>{})};if(!s.auth)return e.jsx(O,{to:"/auth/login",style:{color:"inherit",textDecoration:"none"},children:e.jsx(E,{type:"text",children:"Войти"})});const r=[{key:"profile",label:e.jsx(O,{to:"/profile",style:{color:"inherit",textDecoration:"none"},children:"Управление"})},{key:"logout",label:"Выйти",onClick:a}];return e.jsx(Gt,{menu:{items:r},trigger:["click"],children:e.jsx(E,{type:"text",icon:e.jsx(En,{}),style:{fontSize:"20px"}})})}const vs=[{key:"niche-analysis",label:e.jsx(O,{to:"/external-analytics/niche-analysis",style:{color:"inherit",textDecoration:"none"},children:"Анализ ниш"})},{key:"category-analysis",label:e.jsx(O,{to:"/external-analytics/category-analysis",style:{color:"inherit",textDecoration:"none"},children:"Анализ категорий"})},{key:"category-matrix",label:e.jsx(O,{to:"/external-analytics/category-matrix",style:{color:"inherit",textDecoration:"none"},children:"Матрица категорий"})},{key:"subject-matrix",label:e.jsx(O,{to:"/external-analytics/subject-matrix",style:{color:"inherit",textDecoration:"none"},children:"Матрица предметов"})},{key:"search-queries",label:e.jsx(O,{to:"/search-queries",style:{color:"inherit",textDecoration:"none"},children:"Запросы"})}];function js(){const{profile:t}=se(),n=t.auth===!0;return e.jsxs("header",{style:{position:"fixed",top:0,left:0,right:0,zIndex:1001,background:"#fff",boxShadow:"0 2px 8px rgba(0,0,0,0.06)",height:"56px",display:"flex",alignItems:"center",padding:"0 24px",justifyContent:"space-between",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs(O,{to:"/",style:{display:"flex",alignItems:"center",fontWeight:700,textDecoration:"none",fontSize:"18px",color:y.dark[500],marginRight:"16px"},children:[e.jsx("span",{style:{marginRight:"8px",height:"32px"},children:e.jsx("img",{src:an,style:{width:"32px",height:"32px",borderRadius:"16px"}})}),e.jsx("span",{style:{color:y.dark[500],fontWeight:400,fontFamily:"Tahoma, Verdana, Segoe, sans-serif",lineHeight:1},children:"mkeeper"})]}),n&&e.jsx(Gt,{menu:{items:vs},trigger:["hover"],children:e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"6px 12px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,color:y.dark[500],background:"#f5f5f5"},children:["Внешняя аналитика",e.jsx("span",{style:{fontSize:"10px",fontWeight:400,lineHeight:1,padding:"2px 5px",borderRadius:"4px",background:y.primary[500],color:y.dark[500],letterSpacing:"0.02em"},children:"BETA"}),e.jsx(Mn,{style:{fontSize:"10px"}})]})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n&&e.jsx(O,{to:"/wishes",children:e.jsx(E,{type:"text",icon:e.jsx(Ln,{}),style:{fontSize:"20px"}})}),e.jsx(_s,{})]})]})}function wt(){return e.jsx("div",{children:e.jsx(js,{})})}const bs="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20style='margin:%20auto;%20background:%20none;%20display:%20block;%20shape-rendering:%20auto;'%20width='200px'%20height='200px'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='xMidYMid'%3e%3cg%20transform='translate(80,50)'%3e%3cg%20transform='rotate(0)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='1'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.875s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.875s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(71.21320343559643,71.21320343559643)'%3e%3cg%20transform='rotate(45)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.875'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.75s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.75s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(50,80)'%3e%3cg%20transform='rotate(90)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.75'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.625s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.625s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(28.786796564403577,71.21320343559643)'%3e%3cg%20transform='rotate(135)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.625'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.5s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.5s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(20,50.00000000000001)'%3e%3cg%20transform='rotate(180)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.5'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.375s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.375s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(28.78679656440357,28.786796564403577)'%3e%3cg%20transform='rotate(225)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.375'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.25s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.25s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(49.99999999999999,20)'%3e%3cg%20transform='rotate(270)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.25'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='-0.125s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='-0.125s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3cg%20transform='translate(71.21320343559643,28.78679656440357)'%3e%3cg%20transform='rotate(315)'%3e%3ccircle%20cx='0'%20cy='0'%20r='6'%20fill='%23d8ebf9'%20fill-opacity='0.125'%3e%3canimateTransform%20attributeName='transform'%20type='scale'%20begin='0s'%20values='1.5%201.5;1%201'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%3e%3c/animateTransform%3e%3canimate%20attributeName='fill-opacity'%20keyTimes='0;1'%20dur='1s'%20repeatCount='indefinite'%20values='1;0'%20begin='0s'%3e%3c/animate%3e%3c/circle%3e%3c/g%3e%3c/g%3e%3c!--%20[ldio]%20generated%20by%20https://loading.io/%20--%3e%3c/svg%3e";function Ue(){const[t,n]=i.useState(0);return i.useEffect(()=>(n(1),()=>{n(0)}),[]),e.jsx("div",{className:"spinner-wrapper",children:e.jsx("img",{src:bs,className:"spinner-img",style:{opacity:t}})})}const kt="cookie_banner_dismissed";function Ss(){const[t,n]=i.useState(()=>!localStorage.getItem(kt));if(!t)return null;const s=()=>{localStorage.setItem(kt,"1"),n(!1)};return e.jsxs("div",{style:{position:"fixed",bottom:24,right:24,zIndex:2e3,background:"#fff",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",borderRadius:12,padding:"14px 18px",maxWidth:320,display:"flex",flexDirection:"column",gap:10,fontSize:13,color:y.dark[500]},children:[e.jsx("span",{children:"Мы используем файлы куки для корректной работы сервиса и аналитики. Продолжая использовать сайт, вы соглашаетесь с их использованием."}),e.jsx("button",{onClick:s,style:{alignSelf:"flex-end",background:y.primary[500],border:"none",borderRadius:8,padding:"6px 16px",fontSize:13,fontWeight:600,color:"#fff",cursor:"pointer"},children:"Закрыть"})]})}const Cs=["/auth/login","/auth/logout","/auth/ext-auth","/wb-id-sdk/callback","/auth/wblogin"];function ws(){const{profile:t}=se(),n=Bt(),s=Cs.includes(n.pathname);return t.auth===void 0?e.jsxs("div",{style:{display:"flex"},children:[e.jsx(wt,{}),e.jsxs("main",{style:{flexGrow:1,minWidth:0,overflowX:"hidden",padding:"0 24px 24px 24px"},children:[e.jsx("div",{style:{height:"72px"}}),e.jsx(Ue,{})]})]}):t.auth===!1&&!s?e.jsx($n,{to:"/auth/login",replace:!0,state:{from:n.pathname+n.search+n.hash}}):e.jsxs("div",{style:{display:"flex"},children:[e.jsx(wt,{}),e.jsxs("main",{style:{flexGrow:1,minWidth:0,overflowX:"hidden",padding:"0 24px 24px 24px"},children:[e.jsx("div",{style:{height:"72px"}}),e.jsx(Pn,{})]}),e.jsx(Ss,{})]})}const on=({label:t,headers:n,rows:s})=>e.jsxs("div",{children:[t&&e.jsx(S.Title,{level:4,style:{padding:"16px"},children:t}),e.jsx(ve,{columns:n,dataSource:s||[],rowKey:(a,r)=>r,size:"small",pagination:!1,scroll:{x:900},locale:{emptyText:"Empty..."}})]}),ks=()=>{let{subjectId:t}=Qe();const[n,s]=i.useState(!0),[a,r]=i.useState([]),l="Запросы по категории",c=[{title:"ПОИСКОВЫЙ ЗАПРОС",key:"text",dataIndex:"text"},{title:"ПРИОРИТЕТ",key:"priority",dataIndex:"priority",align:"right"},{title:"ПОКАЗОВ В МЕСЯЦ",key:"requestCount",dataIndex:"requestCount",align:"right"}];return i.useEffect(()=>{s(!0),W("wbstat/priority-subjects",{params:{id:t}}).then(o=>{var u;r(((u=o.data)==null?void 0:u.results)||[])}).finally(()=>s(!1))},[]),n?e.jsx(Le,{}):e.jsx("div",{children:e.jsx(on,{label:l,headers:c,rows:a})})},Ts=()=>e.jsxs("div",{style:{background:"#fff",borderRadius:4,padding:16,marginBottom:8,boxShadow:"0 1px 2px rgba(0,0,0,0.06)"},children:[e.jsxs(X.Group,{style:{marginBottom:8},children:[e.jsx(X,{value:"isByWord",children:"По словам"}),e.jsx(X,{value:"isBySearch",children:"История запросов"}),e.jsx(X,{value:"isByCategory",children:"По категории"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(V,{placeholder:"Поисковый запрос",size:"small",style:{flex:1}}),e.jsx(E,{type:"primary",style:{padding:"0 25px",fontSize:12,fontWeight:700},children:"Подобрать"})]})]}),Fs=()=>{const t=[{title:"СТАТИСТИКА ПО СЛОВАМ",align:"left"},{title:"ПОКАЗОВ В МЕСЯЦ",align:"left"}];return e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(Ts,{}),e.jsx(on,{headers:t})]})};function Is({options:t,onChange:n,value:s}){return e.jsx(Ee,{dataSource:t||[],renderItem:(a,r)=>{var l;return e.jsx(Ee.Item,{onClick:()=>{n(a)},style:{cursor:"pointer",background:(a==null?void 0:a.id)===(s==null?void 0:s.id)?"#FFFBF3":"transparent",padding:"8px 16px"},children:e.jsx(Ee.Item.Meta,{title:a.name,description:(l=a.category)==null?void 0:l.name})},r)}})}function Y(t){return t.toLocaleString()}const Rs=[{title:"Фраза",dataIndex:"text",key:"text"},{title:"Приоритет",dataIndex:"priority",key:"priority"},{title:"Запросов за неделю",key:"weekRequestCount",render:(t,n)=>Y(n.weekRequestCount)},{title:"Запросов за месяц",key:"monthRequestCount",render:(t,n)=>Y(n.monthRequestCount)},{title:"Запросов за 3 месяца",key:"quarterRequestCount",render:(t,n)=>Y(n.quarterRequestCount)}];function cn({rows:t}){return t!=null&&t.length?e.jsx(ve,{columns:Rs,dataSource:t||[],rowKey:(n,s)=>s,size:"small",pagination:!1,scroll:{x:900}}):null}function Ds(){const[t,n]=i.useState(!1),[s,a]=i.useState([]),[r,l]=i.useState(""),[c,h]=i.useState([]),[o,u]=i.useState([]),[p,d]=i.useState(void 0),[f,g]=xt("",300);i.useEffect(()=>{p&&(n(!0),W(`wbstat/subjects/phrases/${p.id}`).then(v=>{var k,b;h(((k=v.data)==null?void 0:k.results)||[]),u(((b=v.data)==null?void 0:b.count)||0)}).finally(()=>n(!1)))},[p]),i.useEffect(()=>{if(r.length<3){a([]);return}W("wbstat/subjects/search",{params:{query:r}}).then(k=>{var b;a(((b=k.data)==null?void 0:b.results)||[])}).finally(()=>n(!1))},[f]);const _=v=>{l(v),g(v)},m=()=>{window.location.href=`/api/wbstat/subjects/phrases/${p.id}/xlsx/${p.name}.xlsx`};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(S.Title,{level:4,style:{margin:0},children:"Фразы по категориям"}),e.jsx("div",{children:e.jsx(V,{onChange:v=>{_(v.target.value)},value:r,placeholder:"Введите текст для поиска категории",size:"large"})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr",gap:"20px"},children:[e.jsx("div",{children:e.jsx(Is,{options:s,onChange:d,value:p})}),e.jsxs("div",{style:{flexGrow:1},children:[t?e.jsx(re,{count:1}):e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:!!(c!=null&&c.length)&&e.jsxs(E,{onClick:m,icon:e.jsx(Xe,{}),children:["Скачать ",o," фраз в xlsx"]})}),t?e.jsx(re,{count:5}):e.jsx(cn,{rows:c})]})]})]})}function Es(){const{subjectId:t}=Qe(),[n,s]=i.useState(!1),[a,r]=i.useState([]),[l,c]=i.useState(0),[h,o]=i.useState(void 0);i.useEffect(()=>{W("wbstat/subjects/search",{params:{id:t}}).then(d=>{var f,g,_;o(((g=(f=d.data)==null?void 0:f.results)==null?void 0:g.length)>0?(_=d.data)==null?void 0:_.results[0]:void 0)}).finally(()=>s(!1))},[]),i.useEffect(()=>{h&&(s(!0),W(`wbstat/subjects/phrases/${t}`).then(p=>{var d,f;r(((d=p.data)==null?void 0:d.results)||[]),c(((f=p.data)==null?void 0:f.count)||0)}).finally(()=>s(!1)))},[h]);const u=()=>{window.location.href=`/api/wbstat/subjects/phrases/${t}/xlsx/${h.name}.xlsx`};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs(S.Title,{level:4,style:{margin:0},children:["Приоритетные фразы по категории ",h==null?void 0:h.name]}),e.jsxs("div",{style:{flexGrow:1},children:[n?e.jsx(re,{count:1}):e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsxs(E,{onClick:u,icon:e.jsx(Xe,{}),children:["Скачать ",l," фраз в xlsx"]})}),n?e.jsx(re,{count:5}):e.jsx(cn,{rows:a})]})]})}const Ms=t=>`/campaigns/${t}`,Ls=t=>`/campaigns/${t}/bidder`;function $s({instance:t,campaignId:n}){var s,a,r;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",columnGap:8,alignItems:"center",justifyContent:"space-between"},children:["Актуальная ставка: 0",e.jsx("a",{href:Ms(n),children:e.jsx(E,{type:"link",children:"Изменить параметры"})})]}),e.jsx(S.Title,{level:5,style:{margin:0},children:"Параметры биддера"}),e.jsx(V,{id:"max-cpm",placeholder:"Максимальная ставка",value:((s=t.bidder)==null?void 0:s.maxbet)??"",size:"small"}),e.jsx(V,{id:"top-place",placeholder:"Верхняя позиция",value:((a=t.bidder)==null?void 0:a.top_place)??"",size:"small"}),e.jsx(V,{id:"low-place",placeholder:"Нижняя позиция",value:((r=t.bidder)==null?void 0:r.low_place)??"",size:"small"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(E,{type:"primary",children:"Сохранить изменения"}),e.jsx(E,{children:"Запустить биддер"})]})]})}const Ps=[{title:"Позиция",dataIndex:"place",key:"place"},{title:"Бренд",key:"brand",render:(t,n)=>`${n.brand} (${n.advert_id})`},{title:"Ставка",dataIndex:"cpm",key:"cpm",align:"right"}];function dn({data:t,place:n,campaignId:s}){const a=t==null?void 0:t.filter(r=>!n&&r.place<=20||r.place<4||r.place>t.length-3||0<=n-r.place&&n-r.place<10||0<=r.place-n&&r.place-n<5);return e.jsx(ve,{columns:Ps,dataSource:a||[],rowKey:"place",size:"small",pagination:!1,rowClassName:r=>r.advert_id===s?"ant-table-row-bold":""})}function Ws({instance:t}){const n=t.updated_at?new Date(t.updated_at):void 0,s=[{label:"Статус",value:t.active?"Активна":"Не активна"},{label:"Актуальная ставка",value:t.bet},{label:"Ожидаемое место",value:t.place},{label:"Обновлено",value:n==null?void 0:n.toLocaleString()}];return e.jsxs("div",{children:[e.jsx(S.Title,{level:5,style:{margin:0},children:"Состояние"}),e.jsx(Ee,{dataSource:s,renderItem:a=>e.jsx(Ee.Item,{children:e.jsx(Ee.Item.Meta,{title:a.value,description:a.label})})})]})}const As=(t,n)=>(Ge.find(s=>s.id===t),`${jt}/${n}`),zs=t=>`${Je}/auction/${t}/`;function Ns(){var u,p;const{campaignId:t}=Qe(),[n,s]=i.useState(!0),[a,r]=i.useState([]),[l,c]=i.useState([]),[h,o]=i.useState(void 0);return i.useEffect(()=>{s(!0),K.get(As(6,t)).then(d=>{r(d.data)}).finally(()=>s(!1)),K.get(zs(t)).then(d=>{var f,g;(g=(f=d.data)==null?void 0:f.data)==null||g.forEach((_,m)=>{_.place=m+1}),c(d.data)})},[t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(Ut,{items:[{title:e.jsx("a",{href:"/campaigns",children:"Мои кампании"})},{title:t}]}),e.jsxs(S.Title,{level:5,style:{margin:0},children:[(u=Ge.find(d=>d.id===a.advert_type))==null?void 0:u.name,": ",a.name]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"20px"},children:[e.jsx($s,{instance:a,campaignId:t}),e.jsx("div",{children:e.jsx(Ws,{instance:a.bidder||{}})}),e.jsx("div",{children:e.jsx(dn,{...l,campaignId:t,place:(p=a.bidder)==null?void 0:p.place})})]})]})}function Hs({supplierId:t}){const[n,s]=i.useState(!1),a=()=>{s(!0)},r=()=>{s(!1)},l=()=>"Ключ API";return e.jsxs(e.Fragment,{children:[e.jsx(E,{onClick:a,type:"link",children:"Добавить"}),e.jsxs($e,{open:n,onCancel:r,title:`Добавить ${l()} API`,onOk:r,okText:"Сохранить",cancelText:"Отмена",children:[e.jsx("p",{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsx(V,{autoFocus:!0,id:"api_key",placeholder:l()})]})]})}function Os({item:t}){return e.jsxs("div",{style:{border:"solid thin #ccc",borderRadius:"8px",padding:4},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(S.Title,{level:5,style:{margin:0},children:t.name}),e.jsx(E,{type:"text",children:"Удалить"})]}),e.jsxs("div",{children:["Ключ API: ",t!=null&&t.api_key?"Есть":e.jsx(Hs,{supplierId:t.id,keyType:"uni"})]})]})}function qs(){const[t,n]=i.useState(!1),s=()=>{n(!0)},a=()=>{n(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(E,{onClick:s,type:"primary",children:"Добавить поставщика"}),e.jsxs($e,{open:t,onCancel:a,title:"Добавить поставщика",onOk:a,okText:"Сохранить",cancelText:"Отмена",children:[e.jsx("p",{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(V,{autoFocus:!0,id:"name",placeholder:"Наименование"}),e.jsx(V,{id:"api_key",placeholder:"Ключ API"})]})]})]})}const ce=({children:t,...n})=>{const{variant:s,color:a,sx:r,size:l,type:c,disabled:h,onClick:o,component:u,href:p,target:d,...f}=n;let g="default",_=!1;s==="contained"?g="primary":s==="outlined"&&(g="default"),a==="error"&&(_=!0);const m={fontSize:"16px",lineHeight:"26px",fontWeight:500,padding:"8px 20px",height:"auto",...r||{}};return u==="a"||p?e.jsx("a",{href:p,target:d,style:{textDecoration:"none"},children:e.jsx(E,{type:g,danger:_,disabled:h,onClick:o,style:m,htmlType:c,children:t})}):e.jsx(E,{type:g,danger:_,disabled:h,onClick:o,style:m,htmlType:c,children:t})},un=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"12",fill:"#F7F8FA"}),e.jsx("path",{d:"M7 6.99988L17 16.9999",stroke:"#6E7788","stroke-width":"1.3","stroke-linecap":"square","stroke-linejoin":"round"}),e.jsx("path",{d:"M17 6.99988L7 16.9999",stroke:"#6E7788","stroke-width":"1.3","stroke-linecap":"square","stroke-linejoin":"round"})]}),Bs=[{label:"1 месяц (30 дней)",value:1},{label:"3 месяца (90 дней)",value:3},{label:"6 месяцев (180 дней)",value:6},{label:"1 год (365 дней)",value:12}],Gs=[{value:"russia",label:"Российская Федерация",icon:"🇷🇺"},{value:"foreign",label:"Иностранная карта",icon:"🌐"}];function Us({method:t,selected:n,onClick:s}){return e.jsxs("div",{onClick:s,style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 12px",border:`1px solid ${n?y.primary[500]:y.greyS[200]}`,borderRadius:8,background:n?y.primary[50]:"#fff",cursor:"pointer",transition:"border-color 0.2s, background 0.2s"},children:[e.jsx("span",{style:{fontSize:32,lineHeight:1},children:t.icon}),e.jsx(S.Text,{style:{fontSize:13,textAlign:"center"},children:t.label})]})}function He({children:t,disabled:n,variant:s="contained",licenseKey:a}){const[r,l]=Vt.useState(!1),[c,h]=i.useState([]),[o,u]=i.useState(!0),[p,d]=i.useState(!1),[f,g]=i.useState(null),[_,m]=i.useState(1),[v,k]=i.useState("russia"),[b,C]=i.useState(!1),{showRequestError:F}=A(),T=()=>{u(!0),Promise.all([W("user/tariff"),W("user/tariff/current").catch(()=>null)]).then(([$,z])=>{const ae=$.data??[],ge=z==null?void 0:z.data,me=ge?[ge,...ae.filter(Pe=>Pe.id!==ge.id)]:ae;me.length&&(h(me),g(me[0].id))}).catch($=>{F($)}).finally(()=>u(!1))};i.useEffect(()=>{r&&T()},[r]);const L=()=>{d(!0);const $=v!=="foreign"?b?"cloudpayments2":"cloudpayments":void 0;Q("billing/get_payment_link",{tariff:f,period:_,payment_method:v,autopay:v==="russia"?b:!1,...$?{agent:$}:{},...a?{key:a}:{}}).then(z=>{z.data.url?(window.open(z.data.url,"_blank").focus(),Z()):F("Ошибка при создании платежа")}).catch(z=>{F(`Ошибка при создании платежа: ${et(z)}`)}).finally(()=>d(!1))},I=()=>l(!0),Z=()=>l(!1),fe=c.find($=>$.id===f),xe=fe?fe.price*_:null;return e.jsxs(e.Fragment,{children:[e.jsx(ce,{disabled:n,variant:s,onClick:I,color:"primary",children:t}),e.jsx($e,{open:!!r,onCancel:Z,title:"Покупка тарифа",footer:null,closeIcon:e.jsx(un,{}),width:500,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingTop:8},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(S.Text,{style:{color:y.greyF[700]},children:"Тариф:"}),e.jsx(ee,{style:{width:"100%"},loading:o,value:f,onChange:g,options:c.map($=>({label:$.name,value:$.id}))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(S.Text,{style:{color:y.greyF[700]},children:"Срок оплаты:"}),e.jsx(ee,{style:{width:"100%"},value:_,onChange:m,options:Bs})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx(S.Text,{style:{color:y.greyF[700]},children:"Способ оплаты:"}),e.jsx("div",{style:{display:"flex",gap:8},children:Gs.map($=>e.jsx(Us,{method:$,selected:v===$.value,onClick:()=>k($.value)},$.value))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx(Ye,{checked:b&&v==="russia",onChange:$=>C($.target.checked),disabled:v==="foreign",children:"Подключить автоплатёж"}),v==="foreign"&&e.jsx(S.Text,{style:{fontSize:12,color:y.greyF[700]},children:"При оплате методом «Иностранная карта» нет возможности подключить автоплатёж."})]}),e.jsx(ne,{style:{margin:0}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:y.primary[50],border:`1px solid ${y.primary[200]}`,borderRadius:8,padding:"12px 16px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(S.Text,{style:{color:y.greyF[700],fontSize:13},children:"Итого:"}),e.jsx(S.Text,{strong:!0,style:{fontSize:22},children:xe!==null?`${xe.toLocaleString("ru-RU")} ₽`:"—"})]}),e.jsx(ce,{variant:"contained",color:"primary",onClick:L,disabled:!f||p,loading:p,children:"Оплатить"})]}),e.jsxs(S.Text,{style:{textAlign:"center",color:y.greyF[700],fontSize:13},children:["По вопросам с оплатой — ",e.jsx(S.Link,{href:"https://t.me/adm_mkeeper",target:"_blank",children:"@adm_mkeeper"})]})]})})]})}function Vs(){var p;const[t,n]=i.useState(!1),[s,a]=i.useState(void 0),{showRequestError:r,showError:l}=A();i.useEffect(()=>{n(!0),W("user/license").then(d=>{a(d.data)}).catch(d=>r(d)).finally(()=>n(!1))},[]);const c=()=>{Q("billing/get_payment_link",{}).then(d=>{d.data.url?window.open(d.data.url,"_blank").focus():l("Ошибка при создании платежа")}).catch(d=>{r(`Ошибка при создании платежа: ${et(d)}`)})};if(t)return e.jsx(re,{count:3});let h=!1;if(!(s!=null&&s.length))h=!0;else{const d=s[0];new Date(d.action_date).getFullYear()<2020&&(h=!0)}if(h)return e.jsxs("div",{style:{display:"flex",columnGap:12,alignItems:"center"},children:[e.jsx(S.Text,{children:"Отстутствует лицензия"}),e.jsx(He,{children:"Активировать подписку"})]});const o=s[0],u=new Date(o.action_date);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs(S.Text,{style:{lineHeight:1.4},children:["Номер лицензии: ",o.key]}),e.jsxs(S.Text,{style:{lineHeight:1.4},children:["Тариф ",(p=o.tariff)==null?void 0:p.name]}),o.is_active?e.jsxs(S.Text,{style:{lineHeight:1.4},children:["Подписка активна до ",u.toLocaleDateString()]}):e.jsxs(S.Text,{style:{lineHeight:1.4},children:["Подписка закончилась ",u.toLocaleDateString()]})]}),e.jsx("div",{style:{marginTop:8,display:"flex",gap:8},children:o.tariff===void 0?e.jsx(He,{children:"Выбрать тариф"}):e.jsx(e.Fragment,{children:e.jsx(ce,{variant:"contained",onClick:c,children:"Продлить подписку"})})})]})}const Ks="user/suppliers";function Zs(){const[t,n]=i.useState(!0),[s,a]=i.useState([]);return i.useEffect(()=>{n(!0),W(Ks).then(r=>{a(r.data)}).finally(()=>n(!1))},[]),t?e.jsx("div",{children:"Загрузка..."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",columnGap:12,alignItems:"center"},children:[e.jsx(qs,{}),e.jsx(Vs,{}),e.jsx(O,{to:"/devices",children:e.jsx(E,{children:"Расширение Chrome"})})]}),s.map((r,l)=>e.jsx(Os,{item:r},l))]})}const Ys=`${Be}/cabinet/supplier_full/`;function Qs(){const[t,n]=i.useState([]),[s,a]=i.useState(!0);return i.useEffect(()=>{t.length===0&&(a(!0),K.get(Ys).then(r=>{n(r.data)}).finally(()=>a(!1)))},[]),e.jsxs("div",{children:[e.jsx("h1",{children:"Поставщики и ключи API"}),e.jsx(Zs,{suppliers:t})]})}function Xs({instance:t,campaignId:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx(V,{id:"name",placeholder:"Наименование кампании",value:t.name??"",size:"small"}),e.jsx(V,{id:"cpm",placeholder:"Ставка",value:t.bet??"",size:"small",type:"number"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:8},children:[e.jsx(E,{type:"primary",children:"Сохранить изменения"}),e.jsx("a",{href:Ls(n),children:e.jsx(E,{type:"link",children:"Запустить биддер"})})]})]})}const Js=(t,n)=>(Ge.find(s=>s.id===t),`${jt}/${n}`),ea=t=>`${Je}/auction/${t}/`;function ta(){var u;const{campaignId:t}=Qe(),[n,s]=i.useState(!0),[a,r]=i.useState([]),[l,c]=i.useState([]),[h,o]=i.useState(void 0);return i.useEffect(()=>{s(!0),K.get(Js(6,t)).then(p=>{r(p.data)}).finally(()=>s(!1)),K.get(ea(t)).then(p=>{var d,f;(f=(d=p.data)==null?void 0:d.data)==null||f.forEach((g,_)=>{g.place=_+1}),c(p.data)})},[t]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(Ut,{items:[{title:e.jsx("a",{href:"/campaigns",children:"Мои кампании"})},{title:t}]}),e.jsxs(S.Title,{level:5,style:{margin:0},children:["Изменение: ",(u=Ge.find(p=>p.id===a.advert_type))==null?void 0:u.name,": ",a.name]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"20px"},children:[n?e.jsx("div",{style:{width:"100%"},children:e.jsx(re,{})}):e.jsx(Xs,{instance:a,campaignId:t}),e.jsx("div",{}),e.jsx(dn,{...l,campaignId:t})]})]})}const na="&appType=1&curr=rub&dest=-1257786®ions=80,38,83,4,64,33,68,70,30,40,86,75,69,22,1,31,66,110,48,71,114&spp=0",sa=async t=>{let{data:n}=await K.get(`https://catalog-ads.wildberries.ru/api/v5/search?keyword=${t}`);if(!n.adverts)return null;const s=[];n.adverts.forEach(h=>s.push(h.id));let a=localStorage.getItem("geoData")||na;const{data:r}=await K.get(`/api/wp/clist/?${a}&nm=${s.join(";")}`);if(!r)return null;const l=r.data.products.map(h=>(h.deliveryHours=h.time1+h.time2,h.nmId=h.id,h));return{advData:n,advGoods:l}};async function aa(t){const{data:n}=await K.get("https://static-basket-01.wb.ru/vol0/data/subject-base.json");let s=[];const a=(r,l)=>{r.forEach(c=>{if(c.id==l){const h={id:c.id,subj_name:c.name};s.push(h)}else c.childs&&a(c.childs,l)})};return t.forEach(r=>a(n,r)),s}const ra=function(t,n,s){const{advData:a}=t;a.pages.sort((l,c)=>l.page-c.page);const r={};return s=la(s,a),a.pages.forEach(l=>{let c=s.splice(0,l.positions.length);c.forEach((h,o)=>{const u=a.adverts.find(p=>p.id===h.nmId);ia(h,u,l.positions[o],l.page)}),l.page===1&&(c=n.concat(c)),c.sort((h,o)=>h.advStatFields.position-o.advStatFields.position),r[l.page]=c}),r},ia=function(t,n,s,a=1){var r,l,c,h;t.advStatFields={advertId:n.advertId,position:s,cpm:(r=(l=t.advStatFields)===null||l===void 0?void 0:l.cpm)!==null&&r!==void 0?r:n.cpm,subjectId:t.subjectId,brandId:t.brandCod,kindId:t.kindId,page:a,mk_cpmweight:(c=(h=t.advStatFields)===null||h===void 0?void 0:h.mk_cpmweight)!==null&&c!==void 0?c:0,mk_deliveryweight:(c=(h=t.advStatFields)===null||h===void 0?void 0:h.mk_deliveryweight)!==null&&c!==void 0?c:0,totalWeight:(c=(h=t.advStatFields)===null||h===void 0?void 0:h.totalWeight)!==null&&c!==void 0?c:0,cpmRatio:t.advStatFields.cpmRatio,deliveryRatio:t.advStatFields.deliveryRatio}},la=function(t,n){var s,a;if((s=n.adverts)===null||s===void 0||!s.length||t==null||!t.length)return[];const r=n.adverts.reduce((c,h)=>c.set(h.id,h),new Map);if((a=n.prioritySubjects)!==null&&a!==void 0&&a.length)return oa(t,n,r);const l=hn(t,n.adverts.length);return pn(l,n,r)},hn=function(t,n){return{advertsCount:n??0,products:t??[]}},oa=function(t,n,s){const a=t.reduce((c,h)=>c.set(h.nmId,h),new Map),r=n.adverts.reduce((c,h)=>{var o;const u=h.subject,p=a.get(h.id),d=(o=c.get(u))!==null&&o!==void 0?o:hn();return d.advertsCount++,p&&d.products.push(p),c.set(u,d)},new Map),l=[];for(let c=0;co.advStatFields.totalWeight==u.advStatFields.totalWeight&&u.advStatFields.cpm!=o.advStatFields.cpm?u.advStatFields.cpm-o.advStatFields.cpm:u.advStatFields.totalWeight-o.advStatFields.totalWeight),a},ca=function(t,n,s){const{cpms:a,deliveries:r}=t.reduce((o,u)=>{if(!u)return;const p=n.get(u.nmId);return o.deliveries.add(u.deliveryHours),o.cpms.add(p.cpm),o},{cpms:new Set,deliveries:new Set}),l=1/s.advertsCount;function c(o){let u=1;return o.reduce((p,d)=>p.has(d)?p:(p.size>0&&(u-=l),p.set(d,u)),new Map)}function h(o,u){const p=Array.from(o);return p.sort(u),p}return{weightMapCpm:c(h(a,(o,u)=>u-o)),weightMapDelivery:c(h(r,(o,u)=>o-u))}},da=function(t){var n,s;let a=.6666666666666666,r=1/3;if(t!=null&&(n=t.sortWeights)!==null&&n!==void 0&&n.cpm&&t!=null&&(s=t.sortWeights)!==null&&s!==void 0&&s.delivery){const l=t.sortWeights.cpm+t.sortWeights.delivery;l&&(a=t.sortWeights.cpm/l,r=t.sortWeights.delivery/l)}return{cpmRatio:a,deliveryRatio:r}};function ua(t,n){const s=new Map;t.advData.adverts.forEach(u=>{s.has(u.id)||s.set(u.id,u)});const a=ra(t,[],t.advGoods),r=[];let l=0,c=0,h=0;Object.entries(a).forEach((u,p)=>{u[1].forEach(d=>{const f=++l;let g;n&&(g=n.find(m=>m.id===d.advStatFields.subjectId)),c||(c=d.advStatFields.cpmRatio),h||(h=d.advStatFields.deliveryRatio);const _={brand:d.brand,deliveryHours:d.deliveryHours,id:d.cod1S||d.id,n:f,page:d.advStatFields.page,pl:l,position:d.advStatFields.position,subj_name:g?g.subj_name:"",cpm:d.advStatFields.cpm,cpmWeight:d.advStatFields.mk_cpmweight.toFixed(3),deliveryWeight:d.advStatFields.mk_deliveryweight.toFixed(3),totalWeight:d.advStatFields.totalWeight.toFixed(3),subject:"",name:d.name};r.push(_)})});const o={cpm:"",delivery:"",cpmPercentages:null,deliveryPercentages:null};return t.advData.sortWeights&&(o.cpm=`${t.advData.sortWeights.cpm}/${t.advData.sortWeights.cpm+t.advData.sortWeights.delivery}`,o.delivery=`${t.advData.sortWeights.delivery}/${t.advData.sortWeights.cpm+t.advData.sortWeights.delivery}`),o.cpmPercentages=c*100,o.deliveryPercentages=h*100,{data:r,ratio:o}}async function ha(t){const n=await sa(t);if(n===null)return new Promise((r,l)=>r([]));const s=await aa(n.advData.prioritySubjects),a=ua(n,s);return new Promise((r,l)=>r(a.data))}var le=(t=>(t[t.Small=360]="Small",t[t.Mobile=414]="Mobile",t[t.Tablet=768]="Tablet",t[t.Medium=1280]="Medium",t[t.Laptop=1366]="Laptop",t[t.Large=1920]="Large",t))(le||{});const tt=i.createContext({resolution:1920}),Tt=()=>document.body.clientWidth<=360?360:document.body.clientWidth<=414?414:document.body.clientWidth<=768?768:document.body.clientWidth<=1280?1280:document.body.clientWidth<=1366?1366:1920;function pa({children:t}){const[n,s]=i.useState(document.body.clientWidth);return i.useEffect(()=>{window.addEventListener("resize",()=>s(Tt())),s(Tt())},[]),e.jsx(tt.Provider,{value:{resolution:n},children:t})}function fn(t,n=246,s=328){return`//basket-${fa(Math.floor(t/1e5))}.wb.ru/vol${Math.floor(t/1e5)}/part${Math.floor(t/1e3)}/${t}/images/c${n}x${s}/1.jpg`}function fa(t){return t>=0&&t<=143?"01":t>=144&&t<=287?"02":t>=288&&t<=431?"03":t>=432&&t<=719?"04":t>=720&&t<=1007?"05":t>=1008&&t<=1061?"06":t>=1062&&t<=1115?"07":t>=1116&&t<=1169?"08":t>=1170&&t<=1313?"09":t>=1314&&t<=1601?"10":t>=1602&&t<=1655?"11":"12"}function xa({rows:t,skeleton:n}){return n?e.jsx("div",{children:[...Array(5)].map((s,a)=>e.jsxs("div",{style:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",marginTop:a>0?"15px":0},children:[e.jsx(q.Input,{active:!0,block:!0,style:{height:15,width:"100%"}}),e.jsxs("div",{style:{display:"flex",marginTop:"4px",width:"100%"},children:[e.jsx(q.Image,{active:!0,style:{height:80,width:60,marginRight:"4px"}}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(q.Input,{active:!0,block:!0,style:{height:15,width:"100%"}}),e.jsx(q.Input,{active:!0,block:!0,style:{height:15,width:"100%",marginTop:"4px"}}),e.jsx(q.Input,{active:!0,block:!0,style:{height:15,width:"100%",marginTop:"4px"}})]})]})]},a))}):t.length?e.jsx("div",{children:t.map(s=>e.jsxs("div",{style:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",marginTop:"15px"},children:[e.jsxs("div",{style:{display:"flex"},children:[e.jsx("span",{style:{marginRight:"5px",fontSize:"12px"},children:s.n}),e.jsx("span",{style:{fontSize:"12px"},children:s.name})]}),e.jsxs("div",{style:{display:"flex",width:"100%",marginTop:"4px"},children:[e.jsx("a",{href:`https://www.wildberries.ru/catalog/${s.id}/detail.aspx`,target:"_blank",style:{height:"80px",marginRight:"5px"},children:e.jsx("img",{height:"80px",src:`${fn(s.id)}`,style:{borderRadius:"5px"}})}),e.jsxs("div",{style:{marginRight:"16px",flexGrow:1},children:[e.jsxs("div",{style:{fontSize:"12px"},children:["Артикул: ",s.id]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Бренд: ",s.brand]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Категория: ",s.subj_name]})]}),e.jsxs("div",{style:{minWidth:"90px"},children:[e.jsxs("div",{style:{fontSize:"12px"},children:["Ставка: ",s.cpm," ₽"]}),e.jsxs("div",{style:{fontSize:"12px"},children:["Доставка: ",s.deliveryHours," ч."]})]})]})]},s.id))}):e.jsx("div",{style:{width:"100%",textAlign:"center"},children:"Пусто..."})}const ga=[{title:"№",dataIndex:"n",key:"n",align:"center",render:t=>Y(t)},{title:"",key:"img",align:"center",render:(t,n)=>e.jsx("a",{href:`https://www.wildberries.ru/catalog/${n.id}/detail.aspx`,target:"_blank",children:e.jsx("img",{height:"22px",src:`${fn(n.id)}`})})},{title:"Артикул",key:"id",align:"center",render:(t,n)=>e.jsx("a",{href:`https://www.wildberries.ru/catalog/${n.id}/detail.aspx`,target:"_blank",children:n.id})},{title:"Бренд",dataIndex:"brand",key:"brand",align:"center"},{title:"Категория",dataIndex:"subj_name",key:"subj_name",align:"center"},{title:"Ставка",key:"cpm",align:"center",render:(t,n)=>`${Y(n.cpm)} ₽`},{title:"Вес ставки",key:"cpmWeight",align:"center",render:(t,n)=>Y(n.cpmWeight)},{title:"Доставка",key:"deliveryHours",align:"center",render:(t,n)=>`${Y(n.deliveryHours)} ч.`},{title:"Вес доставки",key:"deliveryWeight",align:"center",render:(t,n)=>Y(n.deliveryWeight)},{title:"Общий вес",key:"totalWeight",align:"center",render:(t,n)=>Y(n.totalWeight)},{title:"Место",key:"pl",align:"center",render:(t,n)=>Y(n.pl)},{title:"Страница",key:"page",align:"center",render:(t,n)=>Y(n.page)},{title:"Позиция",key:"position",align:"center",render:(t,n)=>Y(n.position)}];function ma({rows:t,skeleton:n}){return n?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[...Array(8)].map((s,a)=>e.jsx(q.Input,{active:!0,block:!0,style:{height:32,width:"100%"}},a))}):e.jsx(ve,{columns:ga,dataSource:t||[],rowKey:"id",size:"small",pagination:!1,locale:{emptyText:"Пусто..."}})}function ya({rows:t,skeleton:n}){const{resolution:s}=i.useContext(tt);return e.jsx(e.Fragment,{children:s<=le.Mobile?e.jsx(xa,{skeleton:n,rows:t}):e.jsx(ma,{skeleton:n,rows:t})})}const _a=async t=>{const{data:n}=await K.get(`https://search.wb.ru/suggests/api/v3/hint?query=${t}&gender=common&locale=ru&lang=ru`);let s=[];return n.forEach(a=>{a.type==="suggest"&&s.push({label:a.name})}),new Promise((a,r)=>a(s))};function va(){const[t,n]=i.useState(""),[s,a]=i.useState(!1),[r,l]=xt("",300),[c,h]=i.useState([]),[o,u]=i.useState([]),p=f=>{n(f),f&&(l(f),a(!0))};i.useEffect(()=>{if(!t){h([]),u([]),a(!1);return}ha(t).then(f=>{h(f),a(!1)}),_a(t).then(f=>{Array.isArray(f)&&u(f)})},[r]);const d=o.map(f=>({value:f.label,label:f.label}));return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(S.Title,{level:4,style:{margin:0},children:"Аукцион поиска"}),e.jsx("div",{children:e.jsx(qt,{style:{width:"100%"},options:d,value:t,onSelect:f=>p(f),onSearch:f=>p(f),children:e.jsx(V.Search,{placeholder:"Введите текст для поиска",size:"large"})})}),e.jsx("div",{children:e.jsx(ya,{rows:c,skeleton:s})})]})}const ja="mkeeper_direct_bot";function ba(){const{profile:t}=se(),[n,s]=i.useState(null),[a,r]=i.useState(!1);if(i.useEffect(()=>{t.tg_id||(r(!0),oe("user/tg-link-code").then(c=>{s(c.data.code)}).finally(()=>{r(!1)}))},[t.tg_id]),a||!n)return e.jsx(Ue,{});const l=`https://t.me/${ja}?start=tg_mk_${n}`;return e.jsxs("div",{children:[e.jsx(S.Text,{type:"secondary",style:{display:"block",marginBottom:16},children:"Отсканируйте QR-код или перейдите по ссылке для привязки аккаунта"}),e.jsxs(Wn,{align:"center",gap:24,wrap:"wrap",children:[e.jsx(An,{value:l,size:160,fgColor:y.text,level:"M"}),e.jsx(S.Link,{href:l,target:"_blank",children:l})]})]})}function Sa({onConfirm:t,title:n,button:s,children:a}){const[r,l]=i.useState(!1),c=()=>{l(!0)},h=()=>{l(!1)},o=()=>{t&&t(),l(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:c,className:"hoverable-icon",children:s}),e.jsxs($e,{open:r,onCancel:h,title:n,footer:null,closeIcon:e.jsx(un,{}),width:455,styles:{body:{padding:"16px 16px 0"}},children:[a&&e.jsx("div",{style:{marginBottom:16},children:a}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(ce,{onClick:o,variant:"outlined",color:"error",sx:{width:"100%"},children:"Подтвердить"}),e.jsx(ce,{onClick:h,variant:"outlined",color:"secondary",sx:{width:"100%"},children:"Отмена"})]})]})]})}const Ca=30,Ce=44,wa=30,we=40,ka="_textCell_j8spt_1",Ft={textCell:ka},U=({value:t,textAlignment:n="left",link:s,routerLink:a,afterIcon:r})=>{let l=t;return a?l=e.jsx(O,{to:a,children:t}):s&&(l=e.jsx("a",{href:s,target:"_blank",children:t})),e.jsxs("div",{className:Ft.textCell,style:{textAlign:n},children:[e.jsx("span",{className:Ft.text,style:{fontSize:"16px",lineHeight:1.4,color:"#383540"},children:l}),r||""]})},Ta="_headerContainer_1o3pk_1",Fa="_customHeaderLabel_1o3pk_19",It={headerContainer:Ta,customHeaderLabel:Fa},Ia=({size:t=16,color:n,direction:s="right"})=>{const a={up:"0deg",right:"90deg",down:"180deg"},r=n||y.dark[500];return e.jsx("svg",{style:{transform:`rotate(${a[s]})`},xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M8.61193 13.5L7.39003 13.5L7.40317 5.84127L7.16667 6.06614L4.36813 8.89683L3.50098 8.05026L7.99441 3.5L12.501 8.03704L11.6338 8.89682L8.59879 5.82804L8.61193 13.5Z",fill:r})})},ue=t=>{const[n,s]=i.useState(!1),[a,r]=i.useState(!1),l=()=>{const h=t.column.getSort();s(h==="asc"),r(h==="desc")},c=h=>{const o=n?"desc":"asc";t.setSort(o,h.shiftKey)};return i.useEffect(()=>{t.column.addEventListener("sortChanged",l),l()},[]),e.jsxs("div",{className:It.headerContainer,onClick:c,onTouchEnd:c,style:t.enableSorting?{cursor:"pointer"}:{},children:[e.jsx("span",{className:It.customHeaderLabel,style:{fontSize:"16px",lineHeight:1.4,color:y.greyF[700],...t.wrapText?{whiteSpace:"normal"}:{}},children:t.displayName}),t.enableSorting?e.jsx("span",{style:{minWidth:"16px",maxWidth:"16px",minHeight:"16px",maxHeight:"16px"},children:e.jsx(Ia,{direction:a?"down":"up",color:n||a?y.blue[500]:y.greyF[700]})}):""]})},Ra=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[e.jsxs("g",{clipPath:"url(#clip0_7578_23038)",children:[e.jsx("mask",{id:"mask0_7578_23038",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"24",children:e.jsx("rect",{width:"24",height:"24",fill:"#D9D9D9"})}),e.jsx("g",{mask:"url(#mask0_7578_23038)",children:e.jsx("path",{d:"M7 21C6.45 21 5.97917 20.8042 5.5875 20.4125C5.19583 20.0208 5 19.55 5 19V6H4V4H9V3H15V4H20V6H19V19C19 19.55 18.8042 20.0208 18.4125 20.4125C18.0208 20.8042 17.55 21 17 21H7ZM9 17H11V8H9V17ZM13 17H15V8H13V17Z",fill:y.redPale[400]})})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_7578_23038",children:e.jsx("rect",{width:"24",height:"24",fill:"white"})})})]}),he=({message:t})=>e.jsx("div",{style:{padding:"20px",color:"#666666",fontSize:"16px",pointerEvents:"all",lineHeight:"1.5",display:"block"},children:e.jsx("span",{children:t||"Нет данных"})}),Rt="user/device";function Da(){const[t,n]=i.useState(!0),[s,a]=i.useState([]),{showRequestError:r}=A(),l=()=>{n(!0),W(Rt).then(u=>{a(u.data)}).catch(u=>{r(u)}).finally(()=>n(!1))};i.useEffect(()=>{l()},[]);const c=u=>u?new Date(u).toLocaleString("ru-RU",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",h=u=>{Qn(`${Rt}/${u}`).then(p=>{l()})};if(t)return e.jsx(re,{count:2});const o=[{headerName:"Ключ активации",field:"key",cellRenderer:u=>e.jsx(U,{value:u.value})},{headerName:"User Agent",field:"user_agent",cellRenderer:u=>e.jsx(U,{value:u.value})},{headerName:"Дата использования",field:"last_check",cellRenderer:u=>e.jsx(U,{value:c(u.value)})},{headerName:"Дата активации",field:"activation_date",cellRenderer:u=>e.jsx(U,{value:c(u.value),afterIcon:e.jsx("div",{style:{height:"24px",marginLeft:"auto"},children:e.jsx(Sa,{button:e.jsx(Ra,{}),title:"Деактивировать устройство?",onConfirm:()=>h(u.data.dev_num)})})})}];return e.jsx(e.Fragment,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:wa,headerHeight:Ca,rowData:s,columnDefs:o,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue},onFirstDataRendered:u=>u.api.sizeColumnsToFit(),noRowsOverlayComponent:he})})})})}function xn(){const{profile:t}=se();return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsx(S.Title,{level:5,style:{margin:0},children:"Устройства"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:e.jsx(Da,{})})]})}function gn({hidden:t}){const n=qe(),{profile:s}=se(),{showRequestError:a,showError:r}=A(),[l,c]=i.useState("");return i.useEffect(()=>{s.auth?oe("user/device/new").then(h=>{var o;(o=h.data)!=null&&o.key?c(h.data.key):(r("Нет свободных активаций. Отвяжите одно устройство или повысьте тариф"),n("/"))}).catch(h=>{}):n("/auth/login")},[]),e.jsxs("div",{children:[!t&&e.jsx(Ue,{}),e.jsx("input",{type:"hidden",id:"new-device-key",value:l})]})}function ie({label:t,value:n}){return e.jsxs("div",{style:{display:"flex",gap:16,paddingBlock:10},children:[e.jsx(S.Text,{style:{minWidth:180,color:"#888"},children:t}),e.jsx(S.Text,{children:n})]})}function lt({children:t}){return e.jsx(S.Title,{level:5,style:{margin:0},children:t})}function Ea({onDevicesClick:t}){var _;const{profile:n}=se(),[s,a]=i.useState(void 0),[r,l]=i.useState(!0),[c,h]=i.useState(!1),{showRequestError:o,showError:u,showMessage:p}=A();if(i.useEffect(()=>{n.tg_id&&h(!1)},[n.tg_id]),i.useEffect(()=>{l(!0),W("user/license").then(m=>{a(m.data)}).catch(m=>o(m)).finally(()=>l(!1))},[]),r)return e.jsx(re,{count:4});const d=s==null?void 0:s[0],f=d&&new Date(d.action_date).getFullYear()>=2020,g=f?new Date(d.action_date).toLocaleDateString("ru-RU"):null;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",maxWidth:560},children:[e.jsx(lt,{children:"Общая информация"}),e.jsx(ne,{style:{marginTop:8,marginBottom:0}}),n.wb_id&&e.jsx(ie,{label:"WB ID:",value:n.wb_id}),e.jsx(ie,{label:"Telegram:",value:n.tg_id?e.jsx(S.Text,{children:n.tg_username?`${n.tg_username} (${n.tg_id})`:n.tg_id}):e.jsx(S.Link,{onClick:()=>h(!0),children:"Привязать"})}),e.jsx($e,{open:c,onCancel:()=>h(!1),title:"Привязка Telegram",footer:null,width:480,children:e.jsx("div",{style:{paddingTop:8},children:e.jsx(ba,{})})}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(lt,{children:"Информация о тарифе"}),e.jsx(ne,{style:{marginTop:8,marginBottom:0}}),f?e.jsxs(e.Fragment,{children:[e.jsx(ie,{label:"Тариф:",value:((_=d.tariff)==null?void 0:_.name)??"—"}),e.jsx(ie,{label:"Лицензионный ключ:",value:d.key}),e.jsx(ie,{label:"Действует до:",value:e.jsx(S.Text,{style:new Date(d.action_date)0&&e.jsx(ie,{label:"Подключено устройств:",value:e.jsxs(S.Link,{onClick:t,children:[d.devices_used??0," из ",d.devices]})}),e.jsxs("div",{style:{marginTop:16,display:"flex",gap:8},children:[e.jsx(He,{variant:"contained",licenseKey:d.key,children:"Продлить тариф"}),e.jsx(He,{disabled:!0,variant:"outlined",licenseKey:d.key,children:"Сменить тариф"}),e.jsx(ce,{disabled:!0,variant:"outlined",children:"История оплат"})]})]}):e.jsx("div",{style:{paddingTop:12},children:e.jsx(He,{children:"Активировать подписку"})})]}),f&&d.autopay&&e.jsxs("div",{style:{marginTop:24},children:[e.jsx(lt,{children:"Автоплатёж"}),e.jsx(ne,{style:{marginTop:8,marginBottom:0}}),d.next_pay_at&&e.jsx(ie,{label:"Следующее списание:",value:new Date(d.next_pay_at).toLocaleDateString("ru-RU")}),d.next_pay_amount!=null&&e.jsx(ie,{label:"Сумма списания:",value:`${d.next_pay_amount.toLocaleString("ru-RU")} ₽`}),d.autopay&&e.jsxs("div",{style:{paddingTop:10},children:[e.jsx(S.Text,{children:"Автоплатёж подключён. Вы можете "}),e.jsx(zn,{title:"Отключить автоплатёж?",description:"Автоплатёж будет отключён. Текущий период останется активным.",okText:"Отключить",cancelText:"Назад",okButtonProps:{danger:!0},onConfirm:()=>{oe("user/cancel-payment",{}).then(m=>{var v;(v=m.data)!=null&&v.message&&p(m.data.message),a(k=>k.map((b,C)=>C===0?{...b,autopay:!1,next_pay_at:null}:b))}).catch(m=>{var v,k;u(((k=(v=m.response)==null?void 0:v.data)==null?void 0:k.error)??et(m))})},children:e.jsx(S.Link,{children:"Отключить автоплатёж"})})]})]})]})}function Ma(){const{profile:t}=se(),[n]=vt(),[s,a]=i.useState("general"),r=n.get("auth")==="success";if(t.auth===void 0)return e.jsx(Ue,{});if(t.auth===!1)return e.jsx(rn,{});const l=[{key:"general",label:"Общее",children:e.jsx(Ea,{onDevicesClick:()=>a("devices")})},{key:"payment",label:"Оплата",children:null},{key:"devices",label:"Устройства",children:e.jsx(xn,{})},{key:"shops",label:"Магазины",children:null},{key:"employees",label:"Сотрудники",children:null},{key:"referral",label:"Партнёрская программа",children:null}];return e.jsxs("div",{style:{maxWidth:900},children:[e.jsx(S.Title,{level:4,style:{margin:0,marginBottom:24},children:"Профиль"}),e.jsx(_t,{items:l,activeKey:s,onChange:a}),r&&e.jsx(gn,{hidden:!0})]})}const La=()=>{const{clearProfile:t}=se(),n=qe(),s=()=>{Me.logout().then(()=>{}).catch(a=>console.log("wb logout error:",a)),Q("user/logout").then(()=>{t(),n("/")}).catch(a=>{})};return i.useEffect(()=>{s()},[s]),e.jsx("div",{className:"auth-page",children:"Выход..."})},$a="_numberCell_1xqpf_1",Pa="_number_1xqpf_1",Wa="_tag_1xqpf_17",Fe={numberCell:$a,number:Pa,tag:Wa},P=({value:t,digits:n,cellStyle:s,textAlignment:a="end",tag:r=!1,icon:l=!1,prefix:c=!1,suffix:h=!1})=>{const o=u=>isNaN(u)||!isFinite(u)?"--":n!==void 0?u.toLocaleString("ru-RU",{minimumFractionDigits:n,maximumFractionDigits:n}):u.toLocaleString("ru-RU");return e.jsxs("div",{className:Fe.numberCell,style:{...s,justifyContent:a},children:[r&&e.jsx("div",{className:Fe.tag,children:r}),l&&e.jsx("div",{className:Fe.icon,children:l}),e.jsxs("span",{className:Fe.number,style:{fontSize:"16px",lineHeight:1.4,color:"#383540"},children:[c&&t!=null&&e.jsx("div",{className:Fe.prefix,children:c}),o(Number(t)),h&&t!=null&&e.jsx("div",{className:Fe.suffix,children:h})]})]})},Aa="_container_10jp5_1",za="_input_10jp5_10",ot={container:Aa,input:za},Na=500,pe=i.forwardRef((t,n)=>{const[s,a]=i.useState(""),[r,l]=i.useState(""),c=i.useRef(null);i.useImperativeHandle(n,()=>({onParentModelChanged(d){d||(a(""),l(""))}}));const h=(d,f)=>{const g=d?Number(d):null,_=f?Number(f):null;g!=null&&_!=null?t.onModelChange({type:"inRange",filter:g,filterTo:_}):g!=null?t.onModelChange({type:"greaterThanOrEqual",filter:g}):_!=null?t.onModelChange({type:"lessThanOrEqual",filter:_}):t.onModelChange(null)},o=(d,f)=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{h(d,f)},Na)},u=d=>{const f=d.target.value;a(f),o(f,r)},p=d=>{const f=d.target.value;l(f),o(s,f)};return e.jsxs("div",{className:ot.container,children:[e.jsx("input",{className:ot.input,type:"number",placeholder:"От",value:s,onChange:u}),e.jsx("input",{className:ot.input,type:"number",placeholder:"До",value:r,onChange:p})]})});pe.displayName="RangeFloatingFilter";je.setLicenseKey("key");be.registerModules([Se]);const Ha=64,Oa=10,qa=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),Oe=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(qa,{}):t(n)},Ba={category_name:{text:"category"},subject_name:{text:"subject_name"},revenue:{min:"revenue_min",max:"revenue_max"},revenue_change_pc:{min:"revenue_change_pc_min",max:"revenue_change_pc_max"},cards_count:{min:"cards_count_min",max:"cards_count_max"},cards_count_change_pc:{min:"cards_count_change_pc_min",max:"cards_count_change_pc_max"},cards_with_orders_count:{min:"cards_with_orders_count_min",max:"cards_with_orders_count_max"},cards_with_orders_count_change_pc:{min:"cards_with_orders_count_change_pc_min",max:"cards_with_orders_count_change_pc_max"},suppliers:{min:"suppliers_min",max:"suppliers_max"},suppliers_change_pc:{min:"suppliers_change_pc_min",max:"suppliers_change_pc_max"},suppliers_with_sells:{min:"suppliers_with_sells_min",max:"suppliers_with_sells_max"},suppliers_with_sells_change_pc:{min:"suppliers_with_sells_change_pc_min",max:"suppliers_with_sells_change_pc_max"},redemption_pc:{min:"redemption_pc_min",max:"redemption_pc_max"},redemption_pc_change_pc:{min:"redemption_pc_change_pc_min",max:"redemption_pc_change_pc_max"},buyouts_qty:{min:"buyouts_qty_min",max:"buyouts_qty_max"},buyouts_qty_change_pc:{min:"buyouts_qty_change_pc_min",max:"buyouts_qty_change_pc_max"},orders_qty:{min:"orders_qty_min",max:"orders_qty_max"},orders_qty_change_pc:{min:"orders_qty_change_pc_min",max:"orders_qty_change_pc_max"},orders_rub:{min:"orders_rub_min",max:"orders_rub_max"},orders_rub_change_pc:{min:"orders_rub_change_pc_min",max:"orders_rub_change_pc_max"},buyouts_rub:{min:"buyouts_rub_min",max:"buyouts_rub_max"},buyouts_rub_change_pc:{min:"buyouts_rub_change_pc_min",max:"buyouts_rub_change_pc_max"},avg_check:{min:"avg_check_min",max:"avg_check_max"},avg_check_change_pc:{min:"avg_check_change_pc_min",max:"avg_check_change_pc_max"},weekly_turnover_days:{min:"weekly_turnover_days_min",max:"weekly_turnover_days_max"},weekly_turnover_days_change_pc:{min:"weekly_turnover_days_change_pc_min",max:"weekly_turnover_days_change_pc_max"},monopolization_pc:{min:"monopolization_pc_min",max:"monopolization_pc_max"},monopolization_pc_change_pc:{min:"monopolization_pc_change_pc_min",max:"monopolization_pc_change_pc_max"},remaining_count:{min:"remaining_count_min",max:"remaining_count_max"},remaining_count_change_pc:{min:"remaining_count_change_pc_min",max:"remaining_count_change_pc_max"},avg_rating:{min:"avg_rating_min",max:"avg_rating_max"},avg_rating_change_pc:{min:"avg_rating_change_pc_min",max:"avg_rating_change_pc_max"}};function Ga(t){const n={};for(const[s,a]of Object.entries(t)){const r=Ba[s];r&&("text"in r?a.filter&&(n[r.text]=a.filter):a.type==="inRange"?(a.filter!=null&&(n[r.min]=String(a.filter)),a.filterTo!=null&&(n[r.max]=String(a.filterTo))):a.type==="greaterThanOrEqual"?a.filter!=null&&(n[r.min]=String(a.filter)):a.type==="lessThanOrEqual"&&a.filter!=null&&(n[r.max]=String(a.filter)))}return n}const B=(t,n,s={})=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:130,cellRenderer:Oe(a=>e.jsx(P,{value:a.value,...s}))}),Ua=t=>t==null||isNaN(t)||!isFinite(t)?"--":t.toLocaleString("ru-RU"),H=(t,n)=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:170,cellRenderer:Oe(s=>{const a=s.value;if(a==null)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",width:"100%",height:"100%"},children:"--"});const r=a>=0,l=r?y.green[500]:y.red[500],c=r?mt:yt;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,width:"100%",height:"100%",color:l,fontSize:16,lineHeight:1.4,whiteSpace:"nowrap"},children:[e.jsx(c,{style:{fontSize:10}}),Ua(a),"%"]})})}),pt=[{headerName:"Категория",field:"category_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,cellRenderer:Oe(t=>e.jsx(U,{value:t.value}))},{headerName:"Предмет",field:"subject_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:150,cellRenderer:Oe(t=>e.jsx(U,{value:t.value,routerLink:`/external-analytics/niche-analysis/${t.data.subject}`}))},B("Выручка","revenue",{suffix:" ₽"}),H("Δ Выручка, %","revenue_change_pc"),B("Карточек товаров","cards_count"),H("Δ Карточек товаров, %","cards_count_change_pc"),{...B("Карточек с заказами","cards_with_orders_count"),minWidth:140},{...H("Δ Карточек с заказами, %","cards_with_orders_count_change_pc"),minWidth:160},{...B("Продавцы","suppliers"),minWidth:110},H("Δ Продавцы, %","suppliers_change_pc"),{...B("Продавцы с заказами","suppliers_with_sells"),minWidth:140},{...H("Δ Продавцы с заказами, %","suppliers_with_sells_change_pc"),minWidth:160},{...B("% выкупа","redemption_pc",{suffix:"%"}),minWidth:110},H("Δ % выкупа, %","redemption_pc_change_pc"),B("Заказы, шт","orders_qty"),H("Δ Заказы шт, %","orders_qty_change_pc"),B("Заказы, ₽","orders_rub",{suffix:" ₽"}),H("Δ Заказы ₽, %","orders_rub_change_pc"),B("Выкупы, шт","buyouts_qty"),H("Δ Выкупы шт, %","buyouts_qty_change_pc"),B("Выкупы, ₽","buyouts_rub",{suffix:" ₽"}),H("Δ Выкупы ₽, %","buyouts_rub_change_pc"),{...B("Средний чек","avg_check",{suffix:" ₽"}),minWidth:120},H("Δ Средний чек, %","avg_check_change_pc"),B("Оборачиваемость","weekly_turnover_days"),H("Δ Оборачиваемость, %","weekly_turnover_days_change_pc"),B("Монополизация","monopolization_pc"),H("Δ Монополизация, %","monopolization_pc_change_pc"),{...B("Среднее кол-во остатков","remaining_count"),minWidth:160},{...H("Δ Среднее кол-во остатков, %","remaining_count_change_pc"),minWidth:180},{headerName:"Средний рейтинг",field:"avg_rating",filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:130,cellRenderer:Oe(t=>e.jsx(P,{value:t.value,digits:1,icon:e.jsx(Nn,{style:{color:y.primary[500],fontSize:14}})}))},H("Δ Средний рейтинг, %","avg_rating_change_pc")],Dt=pt.map(t=>({field:t.field,headerName:t.headerName})),Va=t=>Array.from({length:t},(n,s)=>({_id:s}));function Ka({rowData:t,loading:n,onFilterChanged:s,onSortChanged:a,hiddenColumns:r=[]}){const l=i.useRef(Oa);!n&&t.length&&(l.current=t.length);const c=i.useMemo(()=>n?Va(l.current):t,[n,t]),h=i.useMemo(()=>({loading:n}),[n]),o=i.useMemo(()=>r.length?pt.filter(d=>!r.includes(d.field)):pt,[r]),u=i.useCallback(d=>{if(!s)return;const f=d.api.getFilterModel(),g=Ga(f);s(g)},[s]),p=i.useCallback(d=>{if(!a)return;const f=d.api.getColumnState().filter(g=>g.sort).map(g=>g.sort==="desc"?`-${g.colId}`:g.colId);a(f.length?f.join(","):null)},[a]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:we,headerHeight:Ce,floatingFiltersHeight:Ha,rowData:c,columnDefs:o,context:h,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue,headerComponentParams:{enableSorting:!0,wrapText:!0}},onGridReady:d=>{d.api.sizeColumnsToFit()},onGridSizeChanged:d=>{d.api.sizeColumnsToFit()},onFilterChanged:u,onSortChanged:p,noRowsOverlayComponent:he})})}function mn(t,n){const[s,a]=i.useState(()=>{try{const p=localStorage.getItem(t);return p?JSON.parse(p):[]}catch{return[]}}),[r,l]=i.useState(!1),c=i.useCallback(()=>l(!0),[]),h=i.useCallback(()=>l(!1),[]),o=i.useCallback((p,d)=>{a(f=>{const g=d?f.filter(_=>_!==p):[...f,p];return localStorage.setItem(t,JSON.stringify(g)),g})},[t]),u=i.useMemo(()=>new Set(n.map(p=>p.field).filter(p=>!s.includes(p))),[n,s]);return{hiddenColumns:s,visibleColumns:u,open:r,openModal:c,closeModal:h,toggleColumn:o}}function yn({columns:t,hiddenColumns:n,open:s,onClose:a,onToggle:r}){return e.jsx($e,{open:s,onCancel:a,title:"Настройка колонок",footer:null,width:420,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:480,overflowY:"auto"},children:t.map(l=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:14},children:l.headerName}),e.jsx(Hn,{size:"small",checked:!n.includes(l.field),onChange:c=>r(l.field,c)})]},l.field))})})}function _n({onClick:t}){return e.jsx(E,{icon:e.jsx(On,{}),onClick:t,children:"Настроить колонки"})}const{Title:Za}=S,Ya="wbstat/external_analytics",Qa=[{label:"Неделя",value:"week"},{label:"Месяц",value:"month"},{label:"Квартал",value:"quarter"}];function Xa(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState({}),[c,h]=i.useState(null),[o,u]=i.useState("month"),{showRequestError:p}=A(),d=mn("niche_analysis_columns",Dt),f=i.useCallback(m=>{a(!0),G(`${Ya}/`,{params:m}).then(v=>{n(v.data.results)}).catch(v=>{p(v)}).finally(()=>{a(!1)})},[p]);i.useEffect(()=>{const m={...r,period:o,page_size:100};c&&(m.ordering=c),f(m)},[r,c,o]);const g=i.useCallback(m=>{l(m)},[]),_=i.useCallback(m=>{h(m)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(Za,{level:3,style:{margin:0},children:"Анализ ниш"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx(X.Group,{options:Qa,value:o,onChange:m=>u(m.target.value),optionType:"button",buttonStyle:"solid"}),e.jsx(_n,{onClick:d.openModal})]}),e.jsx(yn,{columns:Dt,hiddenColumns:d.hiddenColumns,open:d.open,onClose:d.closeModal,onToggle:d.toggleColumn}),e.jsx(Ka,{rowData:t,loading:s,onFilterChanged:g,onSortChanged:_,hiddenColumns:d.hiddenColumns})]})}const Et=[{key:"orders_qty",name:"Заказы (шт)",color:y.bluePale[500]},{key:"buyouts_qty",name:"Выкупы (шт)",color:y.green[500]},{key:"orders_rub",name:"Заказы (₽)",color:y.orange[500]},{key:"buyouts_rub",name:"Выкупы (₽)",color:y.cyan[500]},{key:"sellers_with_orders",name:"Продавцы с заказами",color:y.primary[500]},{key:"sellers_with_buyouts",name:"Продавцы с выкупами",color:y.red[500]},{key:"cards_with_orders",name:"Карточки с заказами",color:y.bluePale[300]},{key:"cards_with_buyouts",name:"Карточки с выкупами",color:y.green[200]}],Ja=["orders_qty","buyouts_qty","orders_rub","buyouts_rub"];function er(t){if(t==null)return"";const n=Math.abs(t);return n>=1e9?(t/1e9).toFixed(1).replace(/\.0$/,"")+" млрд":n>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+" млн":n>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+" тыс":String(t)}function tr(t){return t?new Date(t).toLocaleDateString("ru-RU",{day:"2-digit",month:"2-digit"}):""}function nr({data:t}){const[n,s]=i.useState(Ja),a=i.useMemo(()=>[...t].sort((o,u)=>new Date(o.period_start)-new Date(u.period_start)),[t]),r=i.useMemo(()=>a.map(o=>tr(o.period_start)),[a]),l=i.useCallback((o,u)=>{s(p=>u?[...p,o]:p.filter(d=>d!==o))},[]),c=i.useMemo(()=>Et.filter(o=>n.includes(o.key)),[n]),h=i.useMemo(()=>{const o=c.map((p,d)=>({type:"log",name:p.name,nameTextStyle:{color:p.color,fontSize:11},position:d%2===0?"left":"right",offset:Math.floor(d/2)*70,axisLine:{show:!0,lineStyle:{color:p.color}},axisLabel:{fontSize:11,color:p.color,formatter:er},splitLine:{show:d===0}})),u=c.map((p,d)=>({name:p.name,type:"line",yAxisIndex:d,data:a.map(f=>f[p.key]),smooth:!0,symbol:"none",lineStyle:{width:2,color:p.color},itemStyle:{color:p.color}}));return{tooltip:{trigger:"axis",axisPointer:{type:"cross"}},grid:{left:20+Math.floor(c.filter((p,d)=>d%2===0).length/1)*35,right:20+Math.floor(c.filter((p,d)=>d%2!==0).length/1)*35,top:40,bottom:30,containLabel:!0},xAxis:{type:"category",data:r,axisLabel:{fontSize:11}},yAxis:o.length>0?o:[{type:"log"}],series:u}},[c,a,r]);return e.jsxs("div",{style:{background:"#fff",borderRadius:8,padding:16,border:"1px solid #EFF1F5"},children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginBottom:12},children:Et.map(o=>e.jsx(Ye,{checked:n.includes(o.key),onChange:u=>l(o.key,u.target.checked),style:{color:o.color,fontWeight:500},children:e.jsx("span",{style:{color:o.color},children:o.name})},o.key))}),e.jsx(Kt,{option:h,style:{height:400},notMerge:!0})]})}je.setLicenseKey("key");be.registerModules([Se]);const sr=10,ar=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),J=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(ar,{}):t(n)};function rr(t){return t?new Date(t).toLocaleDateString("ru-RU"):""}const ir=[{headerName:"Период",field:"period_start",minWidth:120,cellRenderer:J(t=>e.jsx(U,{value:rr(t.value)}))},{headerName:"Брендов с выкупами",field:"brands_with_buyouts",minWidth:140,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Брендов с заказами",field:"brands_with_orders",minWidth:140,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Продавцов с заказами",field:"sellers_with_orders",minWidth:150,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Продавцов с выкупами",field:"sellers_with_buyouts",minWidth:150,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Карточек с выкупами",field:"cards_with_buyouts",minWidth:150,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Карточек с заказами",field:"cards_with_orders",minWidth:150,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Заказы (шт)",field:"orders_qty",minWidth:120,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Заказы (₽)",field:"orders_rub",minWidth:130,cellRenderer:J(t=>e.jsx(P,{value:t.value,suffix:" ₽"}))},{headerName:"Выкупы (шт)",field:"buyouts_qty",minWidth:120,cellRenderer:J(t=>e.jsx(P,{value:t.value}))},{headerName:"Выкупы (₽)",field:"buyouts_rub",minWidth:130,cellRenderer:J(t=>e.jsx(P,{value:t.value,suffix:" ₽"}))}],lr=t=>Array.from({length:t},(n,s)=>({_id:s}));function or({rowData:t,loading:n}){const s=i.useRef(sr);!n&&t.length&&(s.current=t.length);const a=i.useMemo(()=>n?lr(s.current):t,[n,t]),r=i.useMemo(()=>({loading:n}),[n]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:we,headerHeight:Ce,rowData:a,columnDefs:ir,context:r,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue},onGridReady:l=>{l.api.sizeColumnsToFit()},onGridSizeChanged:l=>{l.api.sizeColumnsToFit()},noRowsOverlayComponent:he})})}const{Title:cr}=S,dr="sales/subject-dynamic",ur=[{label:"День",value:"day"},{label:"Неделя",value:"week"},{label:"Месяц",value:"month"}];async function hr(t,n){let s=1,a=[];for(;;){const r=await G(`${dr}/`,{params:{subject_id:t,period:n,page:s}}),{results:l,next:c}=r.data;if(a=a.concat(l),!c)break;s++}return a}function pr(){const{subjectId:t}=Zt(),[n,s]=i.useState([]),[a,r]=i.useState(!0),[l,c]=i.useState("month"),{showRequestError:h}=A(),o=i.useCallback(()=>{r(!0),hr(t,l).then(p=>s(p)).catch(p=>h(p)).finally(()=>r(!1))},[t,l,h]);i.useEffect(()=>{o()},[o]);const u=n.length>0?n[0].subject_name:"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(O,{to:"/external-analytics/niche-analysis",children:e.jsx(Yt,{style:{fontSize:20,color:"#383540"}})}),e.jsx(cr,{level:3,style:{margin:0},children:a&&!u?e.jsx(Le,{size:"small"}):`Динамика ниши: ${u}`})]}),e.jsx(X.Group,{options:ur,value:l,onChange:p=>c(p.target.value),optionType:"button",buttonStyle:"solid"}),!a&&n.length>0&&e.jsx(nr,{data:n}),e.jsx(or,{rowData:n,loading:a})]})}je.setLicenseKey("key");be.registerModules([Se]);const fr=64,xr=10,gr=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),bt=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(gr,{}):t(n)},mr={category__name:{text:"category"},orders_rub:{min:"orders_rub_min",max:"orders_rub_max"},orders_rub_change_pc:{min:"orders_rub_change_pc_min",max:"orders_rub_change_pc_max"},orders_qty:{min:"orders_qty_min",max:"orders_qty_max"},orders_qty_change_pc:{min:"orders_qty_change_pc_min",max:"orders_qty_change_pc_max"},buyouts_rub:{min:"buyouts_rub_min",max:"buyouts_rub_max"},buyouts_rub_change_pc:{min:"buyouts_rub_change_pc_min",max:"buyouts_rub_change_pc_max"},buyouts_qty:{min:"buyouts_qty_min",max:"buyouts_qty_max"},buyouts_qty_change_pc:{min:"buyouts_qty_change_pc_min",max:"buyouts_qty_change_pc_max"},cards_count:{min:"cards_count_min",max:"cards_count_max"},cards_count_change_pc:{min:"cards_count_change_pc_min",max:"cards_count_change_pc_max"},cards_with_orders_count:{min:"cards_with_orders_count_min",max:"cards_with_orders_count_max"},cards_with_orders_count_change_pc:{min:"cards_with_orders_count_change_pc_min",max:"cards_with_orders_count_change_pc_max"}};function yr(t){const n={};for(const[s,a]of Object.entries(t)){const r=mr[s];r&&("text"in r?a.filter&&(n[r.text]=a.filter):a.type==="inRange"?(a.filter!=null&&(n[r.min]=String(a.filter)),a.filterTo!=null&&(n[r.max]=String(a.filterTo))):a.type==="greaterThanOrEqual"?a.filter!=null&&(n[r.min]=String(a.filter)):a.type==="lessThanOrEqual"&&a.filter!=null&&(n[r.max]=String(a.filter)))}return n}const Ie=(t,n,s={})=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:130,cellRenderer:bt(a=>e.jsx(P,{value:a.value,...s}))}),_r=t=>t==null||isNaN(t)||!isFinite(t)?"--":t.toLocaleString("ru-RU"),Re=(t,n)=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:170,cellRenderer:bt(s=>{const a=s.value;if(a==null)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",width:"100%",height:"100%"},children:"--"});const r=a>=0,l=r?y.green[500]:y.red[500],c=r?mt:yt;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,width:"100%",height:"100%",color:l,fontSize:16,lineHeight:1.4,whiteSpace:"nowrap"},children:[e.jsx(c,{style:{fontSize:10}}),_r(a),"%"]})})}),ft=[{headerName:"Категория",field:"category_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,cellRenderer:bt(t=>e.jsx(U,{value:t.value}))},Ie("Заказы, ₽","orders_rub",{suffix:" ₽"}),Re("Δ Заказы ₽, %","orders_rub_change_pc"),Ie("Заказы, шт","orders_qty"),Re("Δ Заказы шт, %","orders_qty_change_pc"),Ie("Выкупы, ₽","buyouts_rub",{suffix:" ₽"}),Re("Δ Выкупы ₽, %","buyouts_rub_change_pc"),Ie("Выкупы, шт","buyouts_qty"),Re("Δ Выкупы шт, %","buyouts_qty_change_pc"),Ie("Карточек товаров","cards_count"),Re("Δ Карточек товаров, %","cards_count_change_pc"),{...Ie("Карточек с заказами","cards_with_orders_count"),minWidth:140},{...Re("Δ Карточек с заказами, %","cards_with_orders_count_change_pc"),minWidth:160}],Mt=ft.map(t=>({field:t.field,headerName:t.headerName})),vr=t=>Array.from({length:t},(n,s)=>({_id:s}));function jr({rowData:t,loading:n,onFilterChanged:s,onSortChanged:a,hiddenColumns:r=[]}){const l=i.useRef(xr);!n&&t.length&&(l.current=t.length);const c=i.useMemo(()=>n?vr(l.current):t,[n,t]),h=i.useMemo(()=>({loading:n}),[n]),o=i.useMemo(()=>r.length?ft.filter(d=>!r.includes(d.field)):ft,[r]),u=i.useCallback(d=>{if(!s)return;const f=d.api.getFilterModel(),g=yr(f);s(g)},[s]),p=i.useCallback(d=>{if(!a)return;const f=d.api.getColumnState().filter(g=>g.sort).map(g=>g.sort==="desc"?`-${g.colId}`:g.colId);a(f.length?f.join(","):null)},[a]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:we,headerHeight:Ce,floatingFiltersHeight:fr,rowData:c,columnDefs:o,context:h,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue,headerComponentParams:{enableSorting:!0,wrapText:!0}},onGridReady:d=>{d.api.sizeColumnsToFit()},onGridSizeChanged:d=>{d.api.sizeColumnsToFit()},onFilterChanged:u,onSortChanged:p,noRowsOverlayComponent:he})})}const{Title:br}=S,Sr="wbstat/external_analytics_category",Cr=[{label:"Неделя",value:"week"},{label:"Месяц",value:"month"},{label:"Квартал",value:"quarter"}];function wr(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState({}),[c,h]=i.useState(null),[o,u]=i.useState("month"),{showRequestError:p}=A(),d=mn("category_analysis_columns",Mt),f=i.useCallback(m=>{a(!0),G(`${Sr}/`,{params:m}).then(v=>{n(v.data.results)}).catch(v=>{p(v)}).finally(()=>{a(!1)})},[p]);i.useEffect(()=>{const m={...r,period:o,page_size:100};c&&(m.ordering=c),f(m)},[r,c,o]);const g=i.useCallback(m=>{l(m)},[]),_=i.useCallback(m=>{h(m)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(br,{level:3,style:{margin:0},children:"Анализ категорий"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx(X.Group,{options:Cr,value:o,onChange:m=>u(m.target.value),optionType:"button",buttonStyle:"solid"}),e.jsx(_n,{onClick:d.openModal})]}),e.jsx(yn,{columns:Mt,hiddenColumns:d.hiddenColumns,open:d.open,onClose:d.closeModal,onToggle:d.toggleColumn}),e.jsx(jr,{rowData:t,loading:s,onFilterChanged:g,onSortChanged:_,hiddenColumns:d.hiddenColumns})]})}function Ze(t,n,s,a,r){if(n===s)return;let l;if(a==="log"){const h=Math.log1p(n),o=Math.log1p(s);l=(Math.log1p(t)-h)/(o-h)}else if(a==="quantile"){if(!r||r.length<2)return;let h=0,o=r.length-1;for(;h>1;r[u]n.date_from.slice(0,7))}function jn(t){const[n,s]=t.split("-"),r=new Date(Number(n),Number(s)-1,1).toLocaleDateString("ru-RU",{month:"long",year:"numeric"});return r.charAt(0).toUpperCase()+r.slice(1)}function bn(t,n){let s=1/0,a=-1/0;for(const r of t)for(const l of n){const c=r[l];c!=null&&isFinite(c)&&(ca&&(a=c))}return isFinite(s)?{min:s,max:a}:{min:0,max:0}}function Sn(t,n){const s=[];for(const a of t)for(const r of n){const l=a[r];l!=null&&isFinite(l)&&s.push(l)}return s.sort((a,r)=>a-r),s}function Cn(t,n){let s=1/0;for(const a of n){const r=t[a];r!=null&&isFinite(r)&&r>0&&rArray.from({length:t},(n,s)=>({_id:s}));je.setLicenseKey("key");be.registerModules([Se]);const kr=10,Tr=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),Lt=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(Tr,{}):t(n)};function Fr(t){return!t||!t.length?[]:t.map(n=>{const s={category_name:n.category_name};return n.values&&n.values.forEach(a=>{const r=a.date_from.slice(0,7);s[r]=a.value}),s})}const Ir={category_name:{text:"category"}};function Rr(t){const n={};for(const[s,a]of Object.entries(t)){const r=Ir[s];r&&"text"in r&&a.filter&&(n[r.text]=a.filter)}return n}function Dr({rowData:t,loading:n,onFilterChanged:s,onSortChanged:a}){const r=i.useRef(null),l=i.useRef(kr),[c,h]=i.useState("linear"),o=i.useMemo(()=>vn(t),[t]),u=i.useMemo(()=>Fr(t),[t]),{min:p,max:d}=i.useMemo(()=>bn(u,o),[u,o]),f=i.useMemo(()=>Sn(u,o),[u,o]);!n&&u.length&&(l.current=u.length);const g=i.useMemo(()=>n?kn(l.current):u,[n,u]),_=i.useMemo(()=>({loading:n}),[n]),m=i.useMemo(()=>{const C=[{headerName:"Категория",field:"category_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,pinned:"left",cellRenderer:Lt(F=>e.jsx(U,{value:F.value}))}];return o.forEach(F=>{C.push({headerName:jn(F),field:F,filter:"agNumberColumnFilter",minWidth:140,cellRenderer:Lt(T=>e.jsx(P,{value:T.value})),cellStyle:T=>{if(T.value==null||!isFinite(T.value))return;let L;if(c==="dynamics"){const I=Cn(T.data,o);L=Ze(T.value,I,I*3,"linear")}else L=Ze(T.value,p,d,c,f);return L?{backgroundColor:L}:void 0}})}),C},[o,p,d,c,f]),v=i.useCallback(C=>{if(!s)return;const F=C.api.getFilterModel(),T=Rr(F);s(T)},[s]),k=i.useCallback(C=>{if(!a)return;const F=C.api.getColumnState().filter(T=>T.sort).map(T=>T.sort==="desc"?`-${T.colId}`:T.colId);a(F.length?F.join(","):null)},[a]),b=i.useCallback(()=>{var C;(C=r.current)!=null&&C.api&&r.current.api.exportDataAsCsv()},[]);return e.jsxs("div",{style:{width:"100%",height:"calc(100vh - 200px)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx(X.Group,{options:wn,value:c,onChange:C=>h(C.target.value),optionType:"button",size:"small"}),e.jsx(E,{icon:e.jsx(Xe,{}),onClick:b,children:"Скачать"})]}),e.jsx(de,{ref:r,rowHeight:we,headerHeight:Ce,rowData:g,columnDefs:m,context:_,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue,headerComponentParams:{enableSorting:!0,wrapText:!0}},onGridReady:()=>{},onGridSizeChanged:()=>{},onFilterChanged:v,onSortChanged:k,noRowsOverlayComponent:he})]})}const{Title:Er}=S,Mr="wbstat/category_matrix",Lr=[{label:"Заказы, ₽",value:"orders_rub"},{label:"Заказы, шт",value:"orders_qty"},{label:"Выкупы, ₽",value:"buyouts_rub"},{label:"Выкупы, шт",value:"buyouts_qty"},{label:"Карточек товаров",value:"cards_count"},{label:"Карточек с заказами",value:"cards_with_orders_count"}];function $r(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState({}),[c,h]=i.useState(null),[o,u]=i.useState("orders_qty"),[p,d]=i.useState(null),[f,g]=i.useState(null),{showRequestError:_}=A(),m=i.useCallback(b=>{a(!0),G(`${Mr}/`,{params:b}).then(C=>{n(C.data.results)}).catch(C=>{_(C)}).finally(()=>{a(!1)})},[_]);i.useEffect(()=>{const b={...r,indicator:o,page_size:100};c&&(b.ordering=c),p!=null&&(b.value_min=p),f!=null&&(b.value_max=f),m(b)},[r,c,o,p,f]);const v=i.useCallback(b=>{l(b)},[]),k=i.useCallback(b=>{h(b)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(Er,{level:3,style:{margin:0},children:"Матрица категорий"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsx(ee,{options:Lr,value:o,onChange:u,style:{width:260}}),e.jsx(Ke,{placeholder:"От",value:p,onChange:d,style:{width:140}}),e.jsx(Ke,{placeholder:"До",value:f,onChange:g,style:{width:140}})]}),e.jsx(Dr,{rowData:t,loading:s,onFilterChanged:v,onSortChanged:k})]})}je.setLicenseKey("key");be.registerModules([Se]);const Pr=10,Wr=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),ct=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(Wr,{}):t(n)};function Ar(t){return!t||!t.length?[]:t.map(n=>{const s={category_name:n.category_name,subject_name:n.subject_name};return n.values&&n.values.forEach(a=>{const r=a.date_from.slice(0,7);s[r]=a.value}),s})}const zr={category_name:{text:"category"},subject_name:{text:"subject_name"}};function Nr(t){const n={};for(const[s,a]of Object.entries(t)){const r=zr[s];r&&"text"in r&&a.filter&&(n[r.text]=a.filter)}return n}function Hr({rowData:t,loading:n,onFilterChanged:s,onSortChanged:a}){const r=i.useRef(null),l=i.useRef(Pr),[c,h]=i.useState("linear"),o=i.useMemo(()=>vn(t),[t]),u=i.useMemo(()=>Ar(t),[t]),{min:p,max:d}=i.useMemo(()=>bn(u,o),[u,o]),f=i.useMemo(()=>Sn(u,o),[u,o]);!n&&u.length&&(l.current=u.length);const g=i.useMemo(()=>n?kn(l.current):u,[n,u]),_=i.useMemo(()=>({loading:n}),[n]),m=i.useMemo(()=>{const C=[{headerName:"Категория",field:"category_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,pinned:"left",cellRenderer:ct(F=>e.jsx(U,{value:F.value}))},{headerName:"Предмет",field:"subject_name",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:180,pinned:"left",cellRenderer:ct(F=>e.jsx(U,{value:F.value}))}];return o.forEach(F=>{C.push({headerName:jn(F),field:F,filter:"agNumberColumnFilter",minWidth:140,cellRenderer:ct(T=>e.jsx(P,{value:T.value})),cellStyle:T=>{if(T.value==null||!isFinite(T.value))return;let L;if(c==="dynamics"){const I=Cn(T.data,o);L=Ze(T.value,I,I*3,"linear")}else L=Ze(T.value,p,d,c,f);return L?{backgroundColor:L}:void 0}})}),C},[o,p,d,c,f]),v=i.useCallback(C=>{if(!s)return;const F=C.api.getFilterModel(),T=Nr(F);s(T)},[s]),k=i.useCallback(C=>{if(!a)return;const F=C.api.getColumnState().filter(T=>T.sort).map(T=>T.sort==="desc"?`-${T.colId}`:T.colId);a(F.length?F.join(","):null)},[a]),b=i.useCallback(()=>{var C;(C=r.current)!=null&&C.api&&r.current.api.exportDataAsCsv()},[]);return e.jsxs("div",{style:{width:"100%",height:"calc(100vh - 200px)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx(X.Group,{options:wn,value:c,onChange:C=>h(C.target.value),optionType:"button",size:"small"}),e.jsx(E,{icon:e.jsx(Xe,{}),onClick:b,children:"Скачать"})]}),e.jsx(de,{ref:r,rowHeight:we,headerHeight:Ce,rowData:g,columnDefs:m,context:_,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue,headerComponentParams:{enableSorting:!0,wrapText:!0}},onGridReady:()=>{},onGridSizeChanged:()=>{},onFilterChanged:v,onSortChanged:k,noRowsOverlayComponent:he})]})}const{Title:Or}=S,qr="wbstat/subject_matrix",Br=[{label:"Заказы, шт",value:"orders_qty"},{label:"Заказы, ₽",value:"orders_rub"},{label:"Выкупы, шт",value:"buyouts_qty"},{label:"Выкупы, ₽",value:"buyouts_rub"},{label:"Выручка",value:"revenue"},{label:"Средний чек",value:"avg_check"},{label:"Карточек товаров",value:"cards_count"},{label:"Карточек с заказами",value:"cards_with_orders_count"},{label:"Продавцы",value:"suppliers"},{label:"Продавцы с продажами",value:"suppliers_with_sells"},{label:"Монополизация, %",value:"monopolization_pc"},{label:"Оборачиваемость, дн",value:"weekly_turnover_days"},{label:"Остатки",value:"remaining_count"},{label:"% выкупа",value:"redemption_pc"},{label:"Средний рейтинг",value:"avg_rating"},{label:"Наличие",value:"availability"}];function Gr(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState({}),[c,h]=i.useState(null),[o,u]=i.useState("orders_qty"),[p,d]=i.useState(null),[f,g]=i.useState(null),{showRequestError:_}=A(),m=i.useCallback(b=>{a(!0),G(`${qr}/`,{params:b}).then(C=>{n(C.data.results)}).catch(C=>{_(C)}).finally(()=>{a(!1)})},[_]);i.useEffect(()=>{const b={...r,indicator:o,page_size:100};c&&(b.ordering=c),p!=null&&(b.value_min=p),f!=null&&(b.value_max=f),m(b)},[r,c,o,p,f]);const v=i.useCallback(b=>{l(b)},[]),k=i.useCallback(b=>{h(b)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(Or,{level:3,style:{margin:0},children:"Матрица предметов"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsx(ee,{options:Br,value:o,onChange:u,style:{width:260}}),e.jsx(Ke,{placeholder:"От",value:p,onChange:d,style:{width:140}}),e.jsx(Ke,{placeholder:"До",value:f,onChange:g,style:{width:140}})]}),e.jsx(Hr,{rowData:t,loading:s,onFilterChanged:v,onSortChanged:k})]})}je.setLicenseKey("key");be.registerModules([Se]);const Ur=64,Vr=10,Kr=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),nt=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(Kr,{}):t(n)},Zr={text:{text:"text"},subject:{text:"subject"},count:{min:"count_min",max:"count_max"},prev_count:{min:"prev_count_min",max:"prev_count_max"},views:{min:"views_min",max:"views_max"},added:{min:"added_min",max:"added_max"},added_conv:{min:"added_conv_min",max:"added_conv_max"},orders:{min:"orders_min",max:"orders_max"},orders_conv:{min:"orders_conv_min",max:"orders_conv_max"},subjects:{min:"subjects_min",max:"subjects_max"}};function Yr(t){const n={};for(const[s,a]of Object.entries(t)){const r=Zr[s];r&&("text"in r?a.filter&&(n[r.text]=a.filter):a.type==="inRange"?(a.filter!=null&&(n[r.min]=String(a.filter)),a.filterTo!=null&&(n[r.max]=String(a.filterTo))):a.type==="greaterThanOrEqual"?a.filter!=null&&(n[r.min]=String(a.filter)):a.type==="lessThanOrEqual"&&a.filter!=null&&(n[r.max]=String(a.filter)))}return n}const Qr=(t,n,s={})=>({headerName:t,field:n,filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:200,cellRenderer:nt(a=>e.jsx(U,{value:a.value})),...s}),De=(t,n,s={})=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:130,cellRenderer:nt(a=>e.jsx(P,{value:a.value,...s}))}),$t=(t,n)=>({headerName:t,field:n,filter:"agNumberColumnFilter",floatingFilter:!0,floatingFilterComponent:pe,minWidth:130,cellRenderer:nt(s=>s.value==null?null:e.jsx(P,{value:s.value,suffix:"%"}))}),Xr=[{headerName:"Запрос",field:"text",filter:"agTextColumnFilter",filterParams:{debounceMs:500},floatingFilter:!0,minWidth:250,cellRenderer:nt(t=>e.jsx(U,{value:t.value,routerLink:`/search-queries/${encodeURIComponent(t.value)}`}))},De("Частота","count"),De("Пред. частота","prev_count"),Qr("Предмет","subject",{minWidth:160}),De("Просмотры","views"),De("В корзину","added"),$t("В корзину, %","added_conv"),De("Заказы","orders"),$t("Заказы, %","orders_conv"),De("Предметов","subjects")],Jr=t=>Array.from({length:t},(n,s)=>({_id:s}));function ei({rowData:t,loading:n,onFilterChanged:s,onSortChanged:a}){const r=i.useRef(Vr);!n&&t.length&&(r.current=t.length);const l=i.useMemo(()=>n?Jr(r.current):t,[n,t]),c=i.useMemo(()=>({loading:n}),[n]),h=i.useCallback(u=>{if(!s)return;const p=u.api.getFilterModel(),d=Yr(p);s(d)},[s]),o=i.useCallback(u=>{if(!a)return;const p=u.api.getColumnState().filter(d=>d.sort).map(d=>d.sort==="desc"?`-${d.colId}`:d.colId);a(p.length?p.join(","):null)},[a]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:we,headerHeight:Ce,floatingFiltersHeight:Ur,rowData:l,columnDefs:Xr,context:c,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!0,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue,headerComponentParams:{enableSorting:!0,wrapText:!0}},onGridReady:u=>{u.api.sizeColumnsToFit()},onGridSizeChanged:u=>{u.api.sizeColumnsToFit()},onFilterChanged:h,onSortChanged:o,noRowsOverlayComponent:he})})}const{Title:ti}=S,ni="wbstat/queries",si=[50,100,200],ai=[{label:"День",value:"yesterday"},{label:"Неделя",value:"week"},{label:"Месяц",value:"month"}];function ri(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState("week"),[c,h]=i.useState({}),[o,u]=i.useState(null),[p,d]=i.useState(1),[f,g]=i.useState(100),[_,m]=i.useState(0),{showRequestError:v}=A(),k=i.useCallback(I=>{a(!0),G(`${ni}/`,{params:I}).then(Z=>{n(Z.data.results),m(Z.data.count)}).catch(Z=>{v(Z)}).finally(()=>{a(!1)})},[v]);i.useEffect(()=>{const I={...c,period:r,page:p,page_size:f};o&&(I.ordering=o),k(I)},[c,r,o,p,f]);const b=i.useCallback(I=>{l(I.target.value),d(1)},[]),C=i.useCallback(I=>{h(I),d(1)},[]),F=i.useCallback(I=>{u(I),d(1)},[]),T=i.useCallback(I=>{d(I)},[]),L=i.useCallback(I=>{g(I),d(1)},[]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(ti,{level:3,style:{margin:0},children:"Поисковые запросы"}),e.jsx(X.Group,{options:ai,value:r,onChange:b,optionType:"button",buttonStyle:"solid"}),e.jsx(ei,{rowData:t,loading:s,onFilterChanged:C,onSortChanged:F}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:12},children:[e.jsx(ut,{current:p,total:_,pageSize:f,onChange:T,showSizeChanger:!1,showTotal:I=>`Всего ${I}`}),e.jsx(ee,{value:f,onChange:L,options:si.map(I=>({value:I,label:`${I} / стр`})),style:{width:110}})]})]})}const Pt=[{key:"queries_week",name:"Запросы (неделя)",color:y.bluePale[500]},{key:"queries_month",name:"Запросы (месяц)",color:y.green[500]},{key:"items_count",name:"Товаров в выдаче",color:y.cyan[500]},{key:"yesterday_count",name:"Запросов вчера",color:y.red[500]}],ii=["queries_week","queries_month"];function li(t){if(t==null)return"";const n=Math.abs(t);return n>=1e9?(t/1e9).toFixed(1).replace(/\.0$/,"")+" млрд":n>=1e6?(t/1e6).toFixed(1).replace(/\.0$/,"")+" млн":n>=1e3?(t/1e3).toFixed(1).replace(/\.0$/,"")+" тыс":String(t)}function oi(t){return t?new Date(t).toLocaleDateString("ru-RU",{day:"2-digit",month:"2-digit"}):""}function ci({data:t}){const[n,s]=i.useState(ii),a=i.useMemo(()=>[...t].sort((o,u)=>new Date(o.period_start)-new Date(u.period_start)),[t]),r=i.useMemo(()=>a.map(o=>oi(o.period_start)),[a]),l=i.useCallback((o,u)=>{s(p=>u?[...p,o]:p.filter(d=>d!==o))},[]),c=i.useMemo(()=>Pt.filter(o=>n.includes(o.key)),[n]),h=i.useMemo(()=>{const o=c.map((p,d)=>({type:"log",name:p.name,nameTextStyle:{color:p.color,fontSize:11},position:d%2===0?"left":"right",offset:Math.floor(d/2)*70,axisLine:{show:!0,lineStyle:{color:p.color}},axisLabel:{fontSize:11,color:p.color,formatter:li},splitLine:{show:d===0}})),u=c.map((p,d)=>({name:p.name,type:"line",yAxisIndex:d,data:a.map(f=>f[p.key]||null),smooth:!0,symbol:"none",lineStyle:{width:2,color:p.color},itemStyle:{color:p.color}}));return{tooltip:{trigger:"axis",axisPointer:{type:"cross"}},grid:{left:20+Math.floor(c.filter((p,d)=>d%2===0).length/1)*35,right:20+Math.floor(c.filter((p,d)=>d%2!==0).length/1)*35,top:40,bottom:30,containLabel:!0},xAxis:{type:"category",data:r,axisLabel:{fontSize:11}},yAxis:o.length>0?o:[{type:"log"}],series:u}},[c,a,r]);return e.jsxs("div",{style:{background:"#fff",borderRadius:8,padding:16,border:"1px solid #EFF1F5"},children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginBottom:12},children:Pt.map(o=>e.jsx(Ye,{checked:n.includes(o.key),onChange:u=>l(o.key,u.target.checked),style:{color:o.color,fontWeight:500},children:e.jsx("span",{style:{color:o.color},children:o.name})},o.key))}),e.jsx(Kt,{option:h,style:{height:400},notMerge:!0})]})}je.setLicenseKey("key");be.registerModules([Se]);const di=10,ui=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 8px",width:"100%",height:"100%"},children:e.jsx(q.Input,{active:!0,size:"small",block:!0,style:{height:20,minWidth:0}})}),Ae=t=>n=>{var s;return(s=n.context)!=null&&s.loading?e.jsx(ui,{}):t(n)};function hi(t){return t?new Date(t).toLocaleDateString("ru-RU"):""}const pi=[{headerName:"Период",field:"period_start",minWidth:120,cellRenderer:Ae(t=>e.jsx(U,{value:hi(t.value)}))},{headerName:"Запросы (неделя)",field:"queries_week",minWidth:140,cellRenderer:Ae(t=>e.jsx(P,{value:t.value}))},{headerName:"Запросы (месяц)",field:"queries_month",minWidth:140,cellRenderer:Ae(t=>e.jsx(P,{value:t.value}))},{headerName:"Товаров в выдаче",field:"items_count",minWidth:140,cellRenderer:Ae(t=>e.jsx(P,{value:t.value}))},{headerName:"Запросов вчера",field:"yesterday_count",minWidth:140,cellRenderer:Ae(t=>e.jsx(P,{value:t.value}))}],fi=t=>Array.from({length:t},(n,s)=>({_id:s}));function xi({rowData:t,loading:n}){const s=i.useRef(di);!n&&t.length&&(s.current=t.length);const a=i.useMemo(()=>n?fi(s.current):t,[n,t]),r=i.useMemo(()=>({loading:n}),[n]);return e.jsx("div",{style:{width:"100%"},children:e.jsx(de,{domLayout:"autoHeight",rowHeight:we,headerHeight:Ce,rowData:a,columnDefs:pi,context:r,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!0,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:ue},onGridReady:l=>{l.api.sizeColumnsToFit()},onGridSizeChanged:l=>{l.api.sizeColumnsToFit()},noRowsOverlayComponent:he})})}const{Title:gi}=S,mi="wbstat/phrase_analysis",yi=[{label:"День",value:"day"},{label:"Неделя",value:"week"},{label:"Месяц",value:"month"}];async function _i(t,n){let s=1,a=[],r=null;for(;;){const l=await G(`${mi}/`,{params:{query:t,period:n,page:s,page_size:20}}),{results:c,next:h,cluster_summary:o}=l.data;if(a=a.concat(c),o&&(r=o),!h)break;s++}return{results:a,clusterSummary:r}}function vi(){var d,f;const{query:t}=Zt(),[n,s]=i.useState([]),[a,r]=i.useState(null),[l,c]=i.useState(!0),[h,o]=i.useState("week"),{showRequestError:u}=A(),p=i.useCallback(()=>{c(!0),_i(t,h).then(({results:g,clusterSummary:_})=>{s(g),r(_)}).catch(g=>u(g)).finally(()=>c(!1))},[t,h]);return i.useEffect(()=>{p()},[p]),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(O,{to:"/search-queries",children:e.jsx(Yt,{style:{fontSize:20,color:"#383540"}})}),e.jsx(gi,{level:3,style:{margin:0},children:l&&!n.length?e.jsx(Le,{size:"small"}):`Анализ фразы: ${t}`})]}),e.jsx(X.Group,{options:yi,value:h,onChange:g=>o(g.target.value),optionType:"button",buttonStyle:"solid"}),a&&!l&&e.jsx("div",{style:{background:"#fff",borderRadius:8,padding:16,border:"1px solid #EFF1F5"},children:e.jsxs(Te,{title:"Кластер",size:"small",column:{xs:1,sm:2,md:3},children:[e.jsx(Te.Item,{label:"Фраза",children:a.text}),e.jsx(Te.Item,{label:"Норм. фраза",children:a.norm_text}),e.jsx(Te.Item,{label:"Запросы (неделя)",children:(d=a.cluster_week_count)==null?void 0:d.toLocaleString("ru-RU")}),e.jsx(Te.Item,{label:"Запросы (месяц)",children:(f=a.cluster_month_count)==null?void 0:f.toLocaleString("ru-RU")}),e.jsx(Te.Item,{label:"Обновлено",children:a.updated_at})]})}),!l&&n.length>0&&e.jsx(ci,{data:n}),e.jsx(xi,{rowData:n,loading:l})]})}function ji(){const t=qe(),{getProfile:n}=se(),{showRequestError:s}=A();return i.useEffect(()=>{Me.handleCallback().then(()=>{const a=Me.accessToken;return oe("user/wb-login",{access_token:a})}).then(a=>{var r;((r=a.data)==null?void 0:r.is_new)===!0&&ym(107086743,"reachGoal","ym-register")}).then(()=>n()).then(()=>{const a=sessionStorage.getItem("wb_key");if(a)return sessionStorage.removeItem("wb_key"),oe("user/key-check",{key:a}).then(()=>n()).catch(()=>{})}).then(()=>{const a=localStorage.getItem("auth_redirect");a?(localStorage.removeItem("auth_redirect"),t(a,{replace:!0})):t("/")}).catch(a=>{console.error("WB ID callback error:",a),s(a),t("/auth/login")})},[]),e.jsx(Ue,{})}const bi=()=>{const[t]=vt();return i.useEffect(()=>{const n=t.get("key");n&&sessionStorage.setItem("wb_key",n),Me.login()},[]),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"calc(100vh - 200px)"},children:e.jsx(Le,{size:"large"})})};function Si(t){return t?new Date(t).toLocaleDateString("ru-RU",{day:"numeric",month:"short",year:"numeric"}):""}function Ci(t){return!!(t!=null&&t.official_response)}function Wt({wishId:t,open:n,onVote:s,onLoad:a,variant:r="sidebar"}){const[l,c]=i.useState(null),[h,o]=i.useState(!1),{showRequestError:u}=A(),{resolution:p}=i.useContext(tt);i.useEffect(()=>{n&&t?(o(!0),W(`wishes/${t}`).then(k=>{c(k.data),a==null||a(k.data)}).catch(k=>{u(k)}).finally(()=>{o(!1)})):n||c(null)},[n,t]);const d=()=>{l!=null&&l.has_voted||s(t).then(k=>{k!=null&&k.has_voted&&c(b=>b&&{...b,votes_count:k.votes_count,has_voted:!0})}).catch(()=>{})},f=l?Si(l.created_at):"",g=l?l.votes_count>0||l.has_voted:!1,_=r==="sheet",m=r==="sidebar"&&p>le.Tablet;if(!n)return null;const v={display:"flex",flexDirection:"column",gap:16,..._?{}:m?{maxHeight:"calc(100vh - 96px)",overflowY:"auto",position:"sticky",top:72}:{}};return e.jsx("div",{style:v,children:h?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:220},children:e.jsx(Le,{})}):l?e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{fontSize:_?24:28,fontWeight:400,lineHeight:1.2,margin:0},children:l.title}),e.jsx(Qt,{color:y.greyF[700],style:{margin:0,borderRadius:4,alignSelf:"flex-start"},children:l.status}),e.jsx(ne,{style:{margin:0}}),e.jsx("p",{style:{fontSize:14,lineHeight:1.45,margin:0,color:y.dark[500]},children:l.description}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,color:y.dark[500]},children:[e.jsx(E,{size:"small",icon:e.jsx(Xt,{}),disabled:l.has_voted,onClick:d,style:{background:l.has_voted?y.primary[50]:y.greyF[100],borderColor:l.has_voted?y.primary[500]:"transparent",color:l.has_voted?y.dark[500]:y.greyF[700]},children:g?l.votes_count:null}),Ci(l)?e.jsxs(e.Fragment,{children:[e.jsx(ne,{type:"vertical",style:{margin:0}}),e.jsxs("span",{style:{alignItems:"center",color:y.dark[500],display:"inline-flex",fontSize:14,gap:4,lineHeight:1.2},children:[e.jsx(Jt,{style:{fontSize:14,color:y.greyF[700]}}),"Есть ответ"]})]}):null,e.jsx(ne,{type:"vertical",style:{margin:0}}),e.jsx("span",{style:{fontSize:14,lineHeight:1.2},children:f})]}),l.official_response&&e.jsxs("div",{style:{borderLeft:`2px solid ${y.primary[500]}`,display:"flex",flexDirection:"column",gap:12,paddingLeft:12},children:[e.jsx("p",{style:{fontSize:14,fontWeight:500,lineHeight:1.2,margin:0},children:"Официальный ответ"}),e.jsx("p",{style:{fontSize:14,lineHeight:1.45,margin:0,color:y.dark[500]},children:l.official_response})]})]}):null})}const{TextArea:wi}=V,ki=50,Ti=500;function At({onClose:t,onSubmit:n,variant:s="inline"}){const[a,r]=i.useState(""),[l,c]=i.useState(""),[h,o]=i.useState(!1),u=()=>{!a.trim()||!l.trim()||h||(o(!0),n({title:a.trim(),description:l.trim()}).then(()=>{r(""),c(""),t()}).catch(()=>{}).finally(()=>{o(!1)}))},p=()=>{h||(r(""),c(""),t())},d=a.trim().length>0&&l.trim().length>0,f=s==="sheet";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,...f?{flex:1,minHeight:0}:{}},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("span",{style:{fontSize:14,fontWeight:500},children:"Заголовок"}),e.jsx(V,{placeholder:"Кратко опишите идею",value:a,onChange:g=>r(g.target.value),maxLength:ki,showCount:!0,disabled:h})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("span",{style:{fontSize:14,fontWeight:500},children:"Описание"}),e.jsx(wi,{placeholder:"Подробно опишите вашу идею",value:l,onChange:g=>c(g.target.value),maxLength:Ti,showCount:!0,rows:5,disabled:h,style:{resize:"none"}})]})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginTop:f?"auto":4,paddingBottom:f?20:0},children:[e.jsxs(ce,{variant:"contained",onClick:u,disabled:!d||h,sx:{flex:f?1:void 0,minWidth:f?void 0:226,height:40,fontSize:14,padding:"0 20px"},children:[e.jsx(en,{}),h?"Отправка...":"Предложить"]}),e.jsx(E,{onClick:p,disabled:h,icon:e.jsx(gt,{}),style:{width:56,height:40},"aria-label":f?"Закрыть форму":"Закрыть форму создания"})]})]})}const{Title:zt}=S,Nt=[{label:"Все",value:"all"},{label:"Новые",value:"Новое"},{label:"Запланировано",value:"Запланировано"},{label:"Сделано",value:"Сделано"}],Fi=[{label:"Все теги",value:"all"},{label:"Новые",value:"Новое"},{label:"Запланировано",value:"Запланировано"},{label:"Сделано",value:"Сделано"}],Ht=[{label:"Больше голосов",value:"most_votes"},{label:"Меньше голосов",value:"least_votes"},{label:"Сначала новые",value:"newest"},{label:"Сначала старые",value:"oldest"}],ze=20;function Ii(t){return t?new Date(t).toLocaleDateString("ru-RU",{day:"numeric",month:"short",year:"numeric"}):""}function Ri(t){return!!(t!=null&&t.official_response)}function dt(t,n){return n!=null&&n.id?t.map(s=>s.id===n.id?{...s,...n}:s):t}function Di(){const[t,n]=i.useState([]),[s,a]=i.useState(!0),[r,l]=i.useState("all"),[c,h]=i.useState("most_votes"),[o,u]=i.useState(1),[p,d]=i.useState(0),[f,g]=i.useState(null),[_,m]=i.useState(!1),{showMessage:v,showRequestError:k}=A(),{resolution:b}=i.useContext(tt),C=b<=le.Tablet,F=i.useRef(new Map),T=i.useRef(new Set),L=x=>(x!=null&&x.id&&F.current.set(x.id,x),x),I=x=>{const j=F.current.get(x.id);return j?{...x,...j}:x};i.useEffect(()=>{let x=!0;a(!0);const j={ordering:c,page:o,limit:ze};return r!=="all"&&(j.status=r),W("wishes",{params:j}).then(w=>{if(!x)return;const R=w.data.results.map(I);n(R),d(w.data.count);const D=R.filter(M=>!M.description&&!T.current.has(M.id));D.length!==0&&(D.forEach(M=>{T.current.add(M.id)}),Promise.allSettled(D.map(M=>W(`wishes/${M.id}`))).then(M=>{if(!x)return;const N=M.reduce((te,ye,ke)=>{const We=D[ke].id;return T.current.delete(We),ye.status==="fulfilled"&&te.push(L(ye.value.data)),te},[]);N.length>0&&n(te=>N.reduce((ye,ke)=>dt(ye,ke),te))}))}).catch(w=>{x&&k(w)}).finally(()=>{x&&a(!1)}),()=>{x=!1}},[r,c,o]),i.useEffect(()=>{if(!f)return;t.some(j=>j.id===f)||g(null)},[f,t]),i.useEffect(()=>{if(C&&(_||f))return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[C,_,f]);const Z=x=>{l(x),u(1)},fe=x=>{h(x),u(1)},xe=x=>{m(!1),g(j=>j===x.id?null:x.id)},$=x=>oe("wishes",x).then(()=>{m(!1),v("Идея отправлена на модерацию")}).catch(j=>{throw k(j),j}),z=x=>{const j=t.find(w=>w.id===x);return j!=null&&j.has_voted?Promise.resolve({has_voted:!0,votes_count:j.votes_count}):oe(`wishes/${x}/vote`).then(w=>(n(R=>R.map(D=>D.id===x?{...D,votes_count:w.data.votes_count,has_voted:!0}:D)),v("Ваш голос учтён!"),{has_voted:!0,votes_count:w.data.votes_count})).catch(w=>{var R,D,M;if(((R=w.response)==null?void 0:R.status)===400&&((M=(D=w.response)==null?void 0:D.data)!=null&&M.detail)){if(v(w.response.data.detail),w.response.data.has_voted)return n(N=>N.map(te=>te.id===x?{...te,votes_count:w.response.data.votes_count,has_voted:!0}:te)),{has_voted:!0,votes_count:w.response.data.votes_count}}else k(w);throw w})},ae=!!f&&!_&&!C,ge=b<=le.Tablet,me=i.useRef(null),[Pe,st]=i.useState(!1),at=i.useCallback(x=>{if(me.current=x,!x)return;const j=new ResizeObserver(([w])=>{st(w.contentRect.width<600)});return j.observe(x),()=>j.disconnect()},[]),rt=ae?{display:"grid",gap:16,gridTemplateColumns:b>=le.Large?"693px minmax(0, 687px)":b>le.Tablet?"minmax(0, 1fr) minmax(0, 1fr)":"minmax(0, 1fr)",alignItems:"stretch",padding:"16px 20px 24px",height:"calc(100vh - 112px)"}:{maxWidth:693,padding:"16px 20px 24px"},it={alignItems:"flex-start",display:"flex",gap:10,justifyContent:"space-between",...b<=le.Tablet?{flexDirection:"column",alignItems:"stretch"}:{}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{background:"#fff",color:y.dark[500],fontFamily:"'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",margin:"0 -24px -24px",minHeight:"calc(100vh - 72px)"},children:C?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{borderBottom:`1px solid ${y.greyF[100]}`,display:"flex",flexDirection:"column",gap:12,padding:"8px 20px 12px"},children:[e.jsx(zt,{level:3,style:{margin:0},children:"Пожелания"}),e.jsxs("div",{style:{display:"flex",gap:8,width:"100%"},children:[e.jsx(ee,{options:Fi,value:r,onChange:Z,variant:"filled",style:{flex:"0 0 146px"}}),e.jsx(ee,{options:Ht,value:c,onChange:fe,variant:"filled",style:{flex:"1 1 0",minWidth:0}})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 20px 108px"},children:[e.jsx(Ot,{loading:s,onVote:z,onWishClick:xe,selectedWishId:f,wishes:t}),p>ze?e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:4},children:e.jsx(ut,{current:o,total:p,pageSize:ze,onChange:u,showSizeChanger:!1})}):null]}),e.jsx(qn,{type:"primary",icon:e.jsx(Bn,{style:{fontSize:24}}),onClick:()=>{g(null),m(!0)},"aria-label":"Предложить идею",style:{width:64,height:64}})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"12px 20px 0"},children:e.jsx(zt,{level:3,style:{margin:0},children:"Пожелания"})}),e.jsxs("div",{style:rt,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,minWidth:0,overflowY:"auto"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:_?e.jsx(At,{onClose:()=>m(!1),onSubmit:$}):e.jsxs(ce,{variant:"outlined",onClick:()=>{g(null),m(!0)},sx:{height:36,fontSize:13,padding:"0 16px",alignSelf:"flex-start"},children:[e.jsx(en,{}),"Предложить идею"]})}),e.jsx(ne,{style:{margin:0}}),e.jsxs("div",{ref:at,style:it,children:[Pe?e.jsx(ee,{options:Nt,value:r,onChange:Z,variant:"filled",style:{flex:"0 0 146px"}}):e.jsx(X.Group,{options:Nt,value:r,onChange:x=>Z(x.target.value),optionType:"button",buttonStyle:"solid"}),e.jsx(ee,{options:Ht,value:c,onChange:fe,variant:"filled",style:{minWidth:180}})]}),e.jsx(Ot,{loading:s,onVote:z,onWishClick:xe,selectedWishId:f,wishes:t}),p>ze?e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:4},children:e.jsx(ut,{current:o,total:p,pageSize:ze,onChange:u,showSizeChanger:!1})}):null]}),ae?e.jsx("div",{style:{alignSelf:"stretch",minWidth:0,overflowY:"auto",...ge?{borderTop:`1px solid ${y.greyF[100]}`,paddingTop:16}:{borderLeft:`1px solid ${y.greyF[100]}`,paddingLeft:16}},children:e.jsx(Wt,{wishId:f,open:ae,onLoad:x=>{L(x),n(j=>dt(j,x))},onVote:z,variant:"sidebar"})}):null]})]})}),e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:1e3,pointerEvents:"none"},children:[e.jsx(St,{open:C&&_,onClose:()=>m(!1),placement:"bottom",height:"75%",closable:!1,getContainer:!1,rootStyle:{pointerEvents:_?"auto":"none"},styles:{wrapper:{borderRadius:"20px 20px 0 0",overflow:"hidden"},body:{padding:"16px 20px 20px",display:"flex",flexDirection:"column",height:"100%"}},children:e.jsx(At,{onClose:()=>m(!1),onSubmit:$,variant:"sheet"})}),e.jsx(St,{open:C&&!!f,onClose:()=>g(null),placement:"bottom",height:"75%",closable:!1,getContainer:!1,rootStyle:{pointerEvents:f?"auto":"none"},styles:{wrapper:{borderRadius:"20px 20px 0 0",overflow:"hidden"},body:{padding:"16px 20px 20px"}},children:e.jsx(Wt,{wishId:f,open:!!f,onLoad:x=>{L(x),n(j=>dt(j,x))},onVote:z,variant:"sheet"})})]})]})}function Ot({wishes:t,loading:n,selectedWishId:s,onWishClick:a,onVote:r}){return n?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:Array.from({length:5}).map((l,c)=>e.jsx(q,{active:!0,paragraph:{rows:2}},`wish-skeleton-${c}`))}):t.length===0?e.jsx(_e,{description:"Нет идей для отображения"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:t.map(l=>e.jsx(Ei,{onClick:()=>a(l),onVote:r,selected:l.id===s,wish:l},l.id))})}function Ei({wish:t,selected:n,onClick:s,onVote:a}){const r=Ii(t.created_at),l=t.votes_count>0||t.has_voted,c=Ri(t);return e.jsxs(Gn,{hoverable:!0,role:"button",tabIndex:0,onClick:s,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),s())},style:{borderColor:n?y.bluePale[500]:void 0,boxShadow:n?"0 8px 20px rgba(0, 123, 251, 0.08)":void 0},styles:{body:{padding:8,display:"flex",flexDirection:"column",gap:12}},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,minWidth:0},children:[e.jsx("h3",{style:{flex:"1 1 220px",fontSize:16,fontWeight:500,lineHeight:1.2,margin:0,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title}),e.jsx(Qt,{color:y.greyF[700],style:{margin:0,borderRadius:4},children:t.status})]}),e.jsx("p",{style:{color:y.dark[500],display:"-webkit-box",fontSize:14,lineHeight:1.2,margin:0,overflow:"hidden",WebkitBoxOrient:"vertical",WebkitLineClamp:1},children:t.description}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,color:y.greyF[700]},children:[e.jsx(E,{size:"small",icon:e.jsx(Xt,{}),disabled:t.has_voted,onClick:h=>{h.stopPropagation(),a(t.id)},style:{background:t.has_voted?y.primary[50]:y.greyF[100],borderColor:t.has_voted?y.primary[500]:"transparent",color:t.has_voted?y.dark[500]:y.greyF[700]},children:l?t.votes_count:null}),c?e.jsxs(e.Fragment,{children:[e.jsx(ne,{type:"vertical",style:{margin:0}}),e.jsxs("span",{style:{alignItems:"center",color:y.dark[500],display:"inline-flex",fontSize:14,gap:4,lineHeight:1.2},children:[e.jsx(Jt,{style:{fontSize:14,color:y.greyF[700]}}),"Есть ответ"]})]}):null,e.jsx(ne,{type:"vertical",style:{margin:0}}),e.jsx("span",{style:{fontSize:14,lineHeight:1.2},children:r})]})]})}const Mi=Un([{element:e.jsx(ws,{}),path:"/",children:[{path:"/",index:!0,element:e.jsx(as,{})},{path:"/auth/login",element:e.jsx(rn,{})},{path:"/auth/logout",element:e.jsx(La,{})},{path:"/auth/wblogin",element:e.jsx(bi,{})},{path:"/auth/ext-auth",element:e.jsx(gn,{})},{path:"/wb-id-sdk/callback",element:e.jsx(ji,{})},{path:"/profile",element:e.jsx(Ma,{})},{path:"/devices",element:e.jsx(xn,{})},{path:"/campaigns/:campaignId/bidder",element:e.jsx(Ns,{})},{path:"/campaigns/:campaignId",element:e.jsx(ta,{})},{path:"/campaigns",element:e.jsx(xs,{})},{path:"/subjects/:subjectId",element:e.jsx(Es,{})},{path:"/subjects",element:e.jsx(Ds,{})},{path:"/priority-subjects/:subjectId",element:e.jsx(ks,{})},{path:"/priority-subjects",element:e.jsx(Fs,{})},{path:"/suppliers",element:e.jsx(Qs,{})},{path:"/search-auction",element:e.jsx(va,{})},{path:"/external-analytics/niche-analysis/:subjectId",element:e.jsx(pr,{})},{path:"/external-analytics/niche-analysis",element:e.jsx(Xa,{})},{path:"/external-analytics/category-analysis",element:e.jsx(wr,{})},{path:"/external-analytics/category-matrix",element:e.jsx($r,{})},{path:"/external-analytics/subject-matrix",element:e.jsx(Gr,{})},{path:"/search-queries",element:e.jsx(ri,{})},{path:"/search-queries/:query",element:e.jsx(vi,{})},{path:"/wishes",element:e.jsx(Di,{})}]}]);function Li(){return e.jsx(Vn,{router:Mi})}function $i(){return e.jsx(e.Fragment,{children:e.jsx(Li,{})})}Kn.createRoot(document.getElementById("root")).render(e.jsx(Vt.StrictMode,{children:e.jsx(Zn,{theme:Xn,children:e.jsx(pa,{children:e.jsx(ts,{children:e.jsx(ys,{children:e.jsx($i,{})})})})})}));