import{u as G,j as e,T as O,P as U,a as q,b as Z,c as w,d as x,e as M,C as it,f as F,r as h,S as v,A as rt,B as y,g as m,L as ee,I as at,h as lt,M as ct,i as te,k as ot,l as Te,m as f,n as dt,o as Ie,p as _e,q as H,F as ve,s as ye,t as be,v as Ee,w as W,x as Le,y as D,O as ut,z as se,D as ht,E as Re,R as pt,G as xt,H as le,J as ne,K as gt,N as V,Q as He,U as Pe,V as ie,W as $,X as We,Y as K,Z as X,_ as Y,$ as re,a0 as pe,a1 as ft,a2 as mt,a3 as jt,a4 as Ae,a5 as $e,a6 as vt,a7 as yt,a8 as bt,a9 as xe,aa as Ct,ab as St,ac as wt}from"./vendor-kwmh5xBq.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();const J=[{id:6,name:"Поиск"},{id:5,name:"Карточки"}],kt=[{id:0,name:"Все"},{id:1,name:"Активные"},{id:2,name:"Остановлены"},{id:3,name:"Неактивные"},{id:4,name:"Без биддера"}],Me=[{id:7,name:"Завершена"},{id:9,name:"Активна"},{id:11,name:"Приостановлена"}],Ft=[{id:0,name:"Все"},...Me],Dt=t=>{const n=Me.find(s=>s.id===t);return n?n.name:""},Tt=[{title:"Кампания",align:"left"},{title:"Параметры",align:"left"},{title:"Статус",align:"left"},{title:"Текущая ставка",align:"right"},{title:"Позиция",align:"right"},{title:"Биддер",align:"left"},{title:"Макс ставка",align:"right"},{title:"Макс позиция",align:"right"},{title:"Мин позиция",align:"right"}];function It({rows:t}){const n=G();return e.jsx(O,{component:U,sx:{boxShadow:1},children:e.jsxs(q,{sx:{minWidth:900},size:"small",children:[e.jsx(Z,{children:e.jsx(w,{children:Tt.map((s,r)=>e.jsx(x,{sx:{color:"rgba(29, 36, 51, 0.8)",fontSize:"12px",fontWeight:"700"},align:s.align,children:s.title},r))})}),e.jsx(M,{children:t?t==null?void 0:t.map((s,r)=>{var i,a,l,c,o,d,p,u;return e.jsxs(w,{hover:!0,sx:{"&:last-child td, &:last-child th":{border:0}},onClick:()=>{const g=s.bidder?`/campaigns/${s.bidder.id}/bidder`:`/campaigns/${s.id}`;n(g)},children:[e.jsx(x,{children:s.id}),e.jsx(x,{component:"th",scope:"row",children:s.name||((i=s.bidder)==null?void 0:i.query)||((a=s.bidder)==null?void 0:a.name)}),e.jsx(x,{children:Dt(s.status)}),e.jsx(x,{align:"right",children:(l=s.bidder)==null?void 0:l.bet}),e.jsx(x,{align:"right",children:(c=s.bidder)==null?void 0:c.place}),e.jsx(x,{children:e.jsx(it,{checked:((o=s.bidder)==null?void 0:o.active)||!1})}),e.jsx(x,{align:"right",children:(d=s.bidder)==null?void 0:d.maxbet}),e.jsx(x,{align:"right",children:(p=s.bidder)==null?void 0:p.top_place}),e.jsx(x,{align:"right",children:(u=s.bidder)==null?void 0:u.low_place})]},r)}):e.jsx(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:e.jsx(x,{component:"th",scope:"row",children:"Empty..."})})})]})})}const Q="/api",ae=`${Q}/v2`,ge=`${ae}/campaign`;function Be(){const t=document.cookie.match(/csrftoken=([^ ;]+)/);if(t)return t[1]}function _t(t,n){return F.get(`${Q}/${t}`,n)}function B(t,n,s){const r={"X-CSRFToken":Be()},i={withCredentials:!0,...s,headers:r};return F.post(`${Q}/${t}`,n,i)}function Et(t,n){const s={"X-CSRFToken":Be()},r={withCredentials:!0,...n,headers:s};return F.delete(`${Q}/${t}`,r)}function I(t,n){return _t(`v2/${t}/`,n)}function Ne(t,n,s){return B(`v2/${t}/`,n,s)}function Lt(t,n){return Et(`v2/${t}/`,n)}function fe(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 Rt="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 me(){const[t,n]=h.useState(0);return h.useEffect(()=>(n(1),()=>{n(0)}),[]),e.jsx("div",{className:"spinner-wrapper",children:e.jsx("img",{src:Rt,className:"spinner-img",style:{opacity:t}})})}const Ht=[],Pt=(t,n)=>{switch(n.type){case"ADD":return[n.payload,...t];case"REMOVE":return t.filter(s=>s.id!==n.payload);default:return t}},ze=h.createContext(Ht),N=()=>h.useContext(ze);function Wt({children:t}){const[n,s]=h.useReducer(Pt,[]),r=(o,d)=>{const p=Math.round(Math.random()*1e9);s({type:"ADD",payload:{id:p,severity:"info",text:o,...d}}),setTimeout(()=>{i(p)},5e3)},i=o=>{s({type:"REMOVE",payload:o})},a=(o,d={})=>{r(o,{...d,severity:"error"})},c={showMessage:r,showError:a,showRequestError:o=>{a(fe(o))}};return e.jsxs(ze.Provider,{value:c,children:[t,e.jsx(v,{spacing:1,padding:1,sx:{position:"fixed",left:0,bottom:0},children:n.map(o=>e.jsx(rt,{severity:o.severity,onClose:()=>i(o.id),children:o.text},o.id))})]})}const de={},Ve=h.createContext(de);function At({children:t}){const[n,s]=h.useState(de),r=()=>{I("user/profile").then(l=>{s({...l.data})})},i=()=>{s({...de,auth:!1})};h.useEffect(()=>{r()},[]);const a={profile:n,getProfile:r,clearProfile:i};return e.jsx(Ve.Provider,{value:a,children:t})}const L=()=>h.useContext(Ve),$t="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";function Mt(){const[t,n]=h.useState(null),s=G(),{clearProfile:r,profile:i}=L(),a=o=>{n(o.currentTarget)},l=()=>{n(null)},c=()=>{l(),B("user/logout").then(()=>{r(),s("/")}).catch(o=>{})};return i.auth?e.jsxs("div",{children:[e.jsx(at,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:a,color:"inherit",children:e.jsx(lt,{})}),e.jsxs(ct,{id:"menu-appbar",anchorEl:t,anchorOrigin:{vertical:"top",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:l,children:[e.jsx(te,{onClick:l,children:e.jsx(m,{component:ee,to:"/profile",sx:{color:"inherit",textDecoration:"none"},children:"Управление"})}),e.jsx(te,{onClick:c,children:"Выйти"})]})]}):e.jsx(y,{color:"inherit",children:e.jsx(m,{component:ee,to:"/auth/login",sx:{color:"inherit",textDecoration:"none"},children:"Войти"})})}function Bt({auth:t}){const{profile:n}=L();return e.jsx(ot,{position:"fixed",sx:{zIndex:s=>s.zIndex.drawer+1},color:"inherit",children:e.jsxs(Te,{sx:{display:{md:"flex"},justifyContent:"space-between",flexGrow:1},children:[e.jsxs(m,{variant:"h6",component:ee,to:"/",sx:{mr:2,display:"flex",fontWeight:700,textDecoration:"none",flexGrow:1,maxWidth:"130px",color:"primary.main"},children:[e.jsx(f,{sx:{mr:1,height:"32px"},children:e.jsx("img",{src:$t,style:{width:"32px",height:"32px",borderRadius:"16px"}})})," mkeeper"]}),e.jsx(Mt,{})]})})}function Nt(){return e.jsxs(f,{children:[e.jsx(dt,{}),e.jsx(Bt,{})]})}function zt({options:t,value:n,onChange:s}){function r(a){return t[a].id}function i(a){return t.findIndex(l=>l.id===a)}return e.jsxs(f,{children:[e.jsx("h4",{children:"Типы кампаний"}),e.jsx(Ie,{orientation:"vertical",variant:"scrollable",value:i(n),onChange:(a,l)=>{s&&s(r(l))},"aria-label":"Типы кампаний",sx:{borderRight:1,borderColor:"divider"},children:t.map(a=>e.jsx(_e,{label:a.name},a.id))})]})}function Vt({options:t,value:n,onChange:s}){return e.jsxs(f,{children:[e.jsx("h4",{children:"Магазины"}),e.jsx(Ie,{orientation:"vertical",variant:"scrollable",value:n,onChange:(r,i)=>{s&&s(i)},"aria-label":"Магазины",sx:{borderRight:1,borderColor:"divider"},children:t.map(r=>e.jsx(_e,{label:r.name},r.id))})]})}function E({count:t=4}){return e.jsx(v,{spacing:1,children:[...Array(t)].map((n,s)=>e.jsx(H,{variant:"rectangular",height:32},s))})}function Gt({status:t,bidder:n,onChange:s}){const r=i=>{s&&s(i.target.name,i.target.value)};return e.jsxs(v,{spacing:2,direction:"row",justifyContent:"stretch",mb:2,children:[e.jsxs(ve,{fullWidth:!0,children:[e.jsx(ye,{id:"campaign-status-filter-label",children:"Статус"}),e.jsx(be,{fullWidth:!0,size:"small",value:t||0,labelId:"campaign-status-filter-label",label:"Статус",name:"status",onChange:r,children:Ft.map(i=>e.jsx(te,{value:i.id,children:i.name},i.id))})]}),e.jsxs(ve,{fullWidth:!0,children:[e.jsx(ye,{id:"campaign-bidder-filter-label",children:"Биддер"}),e.jsx(be,{fullWidth:!0,size:"small",value:n||0,labelId:"campaign-bidder-filter-label",label:"Биддер",name:"bidder",onChange:r,children:kt.map(i=>e.jsx(te,{value:i.id,children:i.name},i.id))})]})]})}const Ot=`${ae}/supplier/`,Ut=(t,n,s)=>{const r=new URLSearchParams({...s,advert_type:t,supplier_id:n});return`${ge}/?${r.toString()}`};function qt(){const[t,n]=Ee(),[s,r]=h.useState(!0),[i,a]=h.useState([]),[l,c]=h.useState([]),[o,d]=h.useState(void 0),p=parseInt(t.get("type")||6),u=parseInt(t.get("supplier")||0),g=parseInt(t.get("status")||0),j=parseInt(t.get("bidder")||0),b=(C,k)=>{const _=new URLSearchParams(t);_.set(C,k),n(_)};return h.useEffect(()=>(i.length===0&&(r(!0),F.get(Ot).then(C=>{a(C.data)}).finally(()=>r(!1))),()=>{}),[]),h.useEffect(()=>{var C;if(i.length>0){const k=Ut(p,(C=i[u])==null?void 0:C.id,{status:g,bidder:j});r(!0),F.get(k).then(_=>{c(_.data)}).finally(()=>r(!1))}},[i,t]),e.jsxs(v,{spacing:3,children:[e.jsx(m,{variant:"h4",children:"Кампании"}),e.jsxs(f,{sx:{display:"grid",gridTemplateColumns:"240px 1fr"},children:[e.jsxs(v,{sx:{mr:3},spacing:2,children:[e.jsx(zt,{options:J,value:p,onChange:C=>b("type",C)}),e.jsx(Vt,{options:i,value:u,onChange:C=>b("supplier",C)})]}),e.jsxs(f,{sx:{flexGrow:1},children:[e.jsx(Gt,{status:g,bidder:j,onChange:(C,k)=>b(C,k)}),s?e.jsx(E,{count:5}):e.jsx(It,{rows:l})]})]})]})}const P=({children:t,...n})=>{const s=W(),{variant:r,color:i}=n,{sx:a,...l}=n;if(r==="outlined"){let c="text.primary";switch(i){case"secondary":c="text.primary";break;case"error":c="error.main";break;default:c=i}return e.jsx(y,{sx:{fontSize:"16px",lineHeight:"26px",fontWeight:500,color:c,borderColor:"border.dark",padding:s.spacing(2,5),"&:hover":{color:c,borderColor:"border.dark"},...a},...l,children:t})}return e.jsx(y,{sx:{fontSize:"16px",lineHeight:"26px",fontWeight:500,boxShadow:"none",padding:s.spacing(2,5),"&:hover":{boxShadow:"none"}},...n,children:t})},Ge=()=>{const t=G(),{getProfile:n}=L(),{showRequestError:s}=N(),[r,i]=h.useState(!1),a=l=>{l.preventDefault(),i(!0),B("user/login",{login:l.target[0].value,password:l.target[2].value}).then(c=>{n(),t("/?auth=success")}).catch(c=>{console.log(c),s(c)}).finally(()=>i(!1))};return e.jsx(e.Fragment,{children:e.jsxs(Le,{maxWidth:"xs",spacing:8,children:[e.jsx("h1",{children:"Авторизация"}),e.jsx("div",{children:e.jsxs(v,{spacing:4,component:"form",onSubmit:a,children:[e.jsxs(v,{spacing:3,children:[e.jsx(D,{id:"login",label:"Введите логин",variant:"outlined",fullWidth:!0,margin:"normal",required:!0,type:"tel",autocomplete:"on",color:"secondary"}),e.jsx(D,{id:"password",label:"Введите пароль",variant:"outlined",type:"password",fullWidth:!0,margin:"normal",required:!0,autocomplete:"on",color:"secondary"})]}),e.jsxs(v,{spacing:3,children:[e.jsx(P,{variant:"contained",size:"large",type:"submit",disabled:r,color:"primary",children:"Войти"}),e.jsx(P,{variant:"outlined",size:"large",component:"a",href:"https://t.me/mkeeper_direct_bot",target:"_blank",color:"secondary",children:"Получить логин и пароль"})]})]})})]})})};function Zt(){const{profile:t}=L();return e.jsx(e.Fragment,{children:e.jsxs(f,{sx:{display:"flex"},children:[e.jsx(Nt,{}),e.jsxs(f,{component:"main",sx:{flexGrow:1,p:{md:3,lg:3}},children:[e.jsx(Te,{}),t.auth===void 0?e.jsx(me,{}):e.jsx(ut,{})]})]})})}const Oe=({label:t,headers:n,rows:s})=>e.jsx(O,{component:U,sx:{boxShadow:1},children:e.jsxs(q,{sx:{minWidth:900},size:"small",children:[e.jsxs(Z,{children:[t&&e.jsx(w,{children:e.jsx(x,{sx:{minWidth:"300px",padding:"16px",fontSize:"24px",fontWeight:"500",border:"none"},children:t})}),e.jsx(w,{children:n.map((r,i)=>e.jsx(x,{sx:{color:"rgba(29, 36, 51, 0.8)",fontSize:"12px",fontWeight:"700"},align:r.align,children:r.title},i))})]}),e.jsx(M,{children:s!=null&&s.length?s==null?void 0:s.map((r,i)=>e.jsxs(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[e.jsx(x,{component:"th",scope:"row",children:r.text}),e.jsx(x,{align:"right",children:r.priority}),e.jsx(x,{align:"right",children:r.requestCount})]},i)):e.jsx(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:e.jsx(x,{component:"th",scope:"row",children:"Empty..."})})})]})}),Kt=()=>{let{subjectId:t}=se();const[n,s]=h.useState(!0),[r,i]=h.useState([]),a="Запросы по категории",l=[{title:"ПОИСКОВЫЙ ЗАПРОС",align:"left"},{title:"ПРИОРИТЕТ",align:"right"},{title:"ПОКАЗОВ В МЕСЯЦ",align:"right"}];return h.useEffect(()=>{s(!0),I("wbstat/priority-subjects",{params:{id:t}}).then(o=>{var d;i(((d=o.data)==null?void 0:d.results)||[])}).finally(()=>s(!1))},[]),n?e.jsx(ht,{}):e.jsx("div",{children:e.jsx(Oe,{label:a,headers:l,rows:r})})},ce=Re(pt)(({theme:t})=>({color:t.palette.primary[200]})),Xt=()=>e.jsxs(v,{sx:{bgcolor:"background.paper",borderRadius:1,padding:"16px","margin-bottom":"8px",boxShadow:1},children:[e.jsxs(xt,{sx:{"margin-bottom":"8px"},row:!0,children:[e.jsx(le,{value:"isByWord",control:e.jsx(ce,{}),label:"По словам"}),e.jsx(le,{value:"isBySearch",control:e.jsx(ce,{}),label:"История запросов"}),e.jsx(le,{value:"isByCategory",control:e.jsx(ce,{}),label:"По категории"})]}),e.jsxs(v,{direction:"row",children:[e.jsx(D,{sx:{"margin-right":"8px"},id:"outlined-basic",label:"Поисковый запрос",color:"primary",variant:"outlined",size:"small",fullWidth:!0}),e.jsx(y,{sx:{padding:"0 25px",fontSize:"12px",fontWeight:"700"},variant:"contained",color:"primary",children:"Подобрать"})]})]}),Yt=()=>{const t=[{title:"СТАТИСТИКА ПО СЛОВАМ",align:"left"},{title:"ПОКАЗОВ В МЕСЯЦ",align:"left"}];return e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(Xt,{}),e.jsx(Oe,{headers:t})]})};function Jt({options:t,onChange:n,value:s}){return e.jsx(ne,{component:"nav",sx:{width:"100%",maxWidth:360,bgcolor:"background.paper"},children:t==null?void 0:t.map((r,i)=>{var a;return e.jsx(gt,{onClick:()=>{n(r)},selected:(r==null?void 0:r.id)===(s==null?void 0:s.id),children:e.jsx(V,{primary:r.name,secondary:(a=r.category)==null?void 0:a.name})},i)})})}function T(t){return t.toLocaleString()}const Qt=[{title:"Фраза",align:"left"},{title:"Приоритет",align:"left"},{title:"Запросов за неделю",align:"left"},{title:"Запросов за месяц",align:"left"},{title:"Запросов за 3 месяца",align:"left"}];function Ue({rows:t}){return t!=null&&t.length?e.jsx(O,{component:U,sx:{boxShadow:1},children:e.jsxs(q,{sx:{minWidth:900},size:"small",children:[e.jsx(Z,{children:e.jsx(w,{children:Qt.map((n,s)=>e.jsx(x,{sx:{color:"rgba(29, 36, 51, 0.8)",fontSize:"12px",fontWeight:"700"},align:n.align,children:n.title},s))})}),e.jsx(M,{children:t?t==null?void 0:t.map((n,s)=>e.jsxs(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[e.jsx(x,{children:n.text}),e.jsx(x,{children:n.priority}),e.jsx(x,{children:T(n.weekRequestCount)}),e.jsx(x,{children:T(n.monthRequestCount)}),e.jsx(x,{children:T(n.quarterRequestCount)})]},s)):e.jsx(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:e.jsx(x,{component:"th",scope:"row",children:"Empty..."})})})]})}):null}function en(){const[t,n]=h.useState(!1),[s,r]=h.useState([]),[i,a]=h.useState(""),[l,c]=h.useState([]),[o,d]=h.useState([]),[p,u]=h.useState(void 0),[g,j]=He("",300);h.useEffect(()=>{p&&(n(!0),I(`wbstat/subjects/phrases/${p.id}`).then(k=>{var _,z;c(((_=k.data)==null?void 0:_.results)||[]),d(((z=k.data)==null?void 0:z.count)||0)}).finally(()=>n(!1)))},[p]),h.useEffect(()=>{if(i.length<3){r([]);return}I("wbstat/subjects/search",{params:{query:i}}).then(_=>{var z;r(((z=_.data)==null?void 0:z.results)||[])}).finally(()=>n(!1))},[g]);const b=k=>{a(k),j(k)},C=()=>{window.location.href=`/api/wbstat/subjects/phrases/${p.id}/xlsx/${p.name}.xlsx`};return e.jsxs(v,{spacing:3,children:[e.jsx(m,{variant:"h4",children:"Фразы по категориям"}),e.jsx(f,{children:e.jsx(D,{onChange:k=>{b(k.target.value)},value:i,label:"Введите текст для поиска категории",fullWidth:!0})}),e.jsxs(f,{sx:{display:"grid",gridTemplateColumns:"240px 1fr",gridGap:"20px"},children:[e.jsx(f,{children:e.jsx(Jt,{options:s,onChange:u,value:p})}),e.jsxs(f,{sx:{flexGrow:1},children:[t?e.jsx(E,{count:1}):e.jsx(f,{display:"flex",justifyContent:"flex-end",children:!!(l!=null&&l.length)&&e.jsxs(y,{onClick:C,children:[e.jsx(Pe,{})," Скачать ",o," фраз в xlsx"]})}),t?e.jsx(E,{count:5}):e.jsx(Ue,{rows:l})]})]})]})}function tn(){const{subjectId:t}=se(),[n,s]=h.useState(!1),[r,i]=h.useState([]),[a,l]=h.useState(0),[c,o]=h.useState(void 0);h.useEffect(()=>{I("wbstat/subjects/search",{params:{id:t}}).then(u=>{var g,j,b;o(((j=(g=u.data)==null?void 0:g.results)==null?void 0:j.length)>0?(b=u.data)==null?void 0:b.results[0]:void 0)}).finally(()=>s(!1))},[]),h.useEffect(()=>{c&&(s(!0),I(`wbstat/subjects/phrases/${t}`).then(p=>{var u,g;i(((u=p.data)==null?void 0:u.results)||[]),l(((g=p.data)==null?void 0:g.count)||0)}).finally(()=>s(!1)))},[c]);const d=()=>{window.location.href=`/api/wbstat/subjects/phrases/${t}/xlsx/${c.name}.xlsx`};return e.jsxs(v,{spacing:3,children:[e.jsxs(m,{variant:"h4",children:["Приоритетные фразы по категории ",c==null?void 0:c.name]}),e.jsxs(f,{sx:{flexGrow:1},children:[n?e.jsx(E,{count:1}):e.jsx(f,{display:"flex",justifyContent:"flex-end",children:e.jsxs(y,{onClick:d,children:[e.jsx(Pe,{})," Скачать ",a," фраз в xlsx"]})}),n?e.jsx(E,{count:5}):e.jsx(Ue,{rows:r})]})]})}const nn=t=>`/campaigns/${t}`,sn=t=>`/campaigns/${t}/bidder`;function rn({instance:t,campaignId:n}){var s,r,i;return e.jsx(e.Fragment,{children:e.jsxs(v,{spacing:2,children:[e.jsxs(f,{sx:{display:"flex",columnGap:2,alignItems:"center",justifyContent:"space-between"},children:["Актуальная ставка: 0",e.jsx(y,{component:ie,href:nn(n),children:"Изменить параметры"})]}),e.jsx(m,{variant:"h6",children:"Параметры биддера"}),e.jsx(D,{id:"max-cpm",label:"Максимальная ставка",variant:"outlined",value:((s=t.bidder)==null?void 0:s.maxbet)??"",size:"small"}),e.jsx(D,{id:"top-place",label:"Верхняя позиция",variant:"outlined",value:((r=t.bidder)==null?void 0:r.top_place)??"",size:"small"}),e.jsx(D,{id:"low-place",label:"Нижняя позиция",variant:"outlined",value:((i=t.bidder)==null?void 0:i.low_place)??"",size:"small"}),e.jsxs(v,{spacing:2,direction:"row",children:[e.jsx(y,{variant:"contained",children:"Сохранить изменения"}),e.jsx(y,{variant:"outlined",children:"Запустить биддер"})]})]})})}const an=[{title:"Позиция",align:"left"},{title:"Бренд",align:"left"},{title:"Ставка",align:"right"}];function qe({data:t,place:n,campaignId:s}){const r=t==null?void 0:t.filter(i=>!n&&i.place<=20||i.place<4||i.place>t.length-3||0<=n-i.place&&n-i.place<10||0<=i.place-n&&i.place-n<5);return e.jsx(O,{component:U,sx:{boxShadow:1},children:e.jsxs(q,{size:"small",children:[e.jsx(Z,{children:e.jsx(w,{children:an.map((i,a)=>e.jsx(x,{sx:{color:"rgba(29, 36, 51, 0.8)",fontSize:"12px",fontWeight:"700"},align:i.align,children:i.title},a))})}),e.jsx(M,{children:r==null?void 0:r.map((i,a)=>e.jsxs(w,{sx:{"&:last-child td, &:last-child th":{border:0},td:{fontWeight:i.advert_id===s?700:400,borderTop:i.place===n?"dashed #FFB400":"none"}},children:[e.jsx(x,{children:i.place}),e.jsxs(x,{children:[i.brand," (",i.advert_id,")"]}),e.jsx(x,{align:"right",children:i.cpm})]},i.place))})]})})}function ln({instance:t}){const n=t.updated_at?new Date(t.updated_at):void 0;return e.jsxs(v,{children:[e.jsx(m,{variant:"h6",children:"Состояние"}),e.jsxs(ne,{children:[e.jsx($,{children:e.jsx(V,{secondary:"Статус",primary:t.active?"Активна":"Не активна"})}),e.jsx($,{children:e.jsx(V,{secondary:"Актуальная ставка",primary:t.bet})}),e.jsx($,{children:e.jsx(V,{secondary:"Ожидаемое место",primary:t.place})}),e.jsx($,{children:e.jsx(V,{secondary:"Обновлено",primary:n==null?void 0:n.toLocaleString()})})]})]})}const cn=(t,n)=>(J.find(s=>s.id===t),`${ge}/${n}`),on=t=>`${ae}/auction/${t}/`;function dn(){var d,p;const{campaignId:t}=se(),[n,s]=h.useState(!0),[r,i]=h.useState([]),[a,l]=h.useState([]),[c,o]=h.useState(void 0);return h.useEffect(()=>{s(!0),F.get(cn(6,t)).then(u=>{i(u.data)}).finally(()=>s(!1)),F.get(on(t)).then(u=>{var g,j;(j=(g=u.data)==null?void 0:g.data)==null||j.forEach((b,C)=>{b.place=C+1}),l(u.data)})},[t]),e.jsxs(v,{spacing:3,children:[e.jsxs(We,{"aria-label":"breadcrumb",children:[e.jsx(ie,{underline:"hover",href:"/campaigns",children:"Мои кампании"}),e.jsx(m,{color:"text.primary",children:t})]}),e.jsxs(m,{variant:"h5",children:[(d=J.find(u=>u.id===r.advert_type))==null?void 0:d.name,": ",r.name]}),e.jsxs(f,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gridGap:"20px"},children:[e.jsx(rn,{instance:r,campaignId:t}),e.jsx(f,{children:e.jsx(ln,{instance:r.bidder||{}})}),e.jsx(f,{children:e.jsx(qe,{...a,campaignId:t,place:(p=r.bidder)==null?void 0:p.place})})]})]})}function un({supplierId:t}){const[n,s]=h.useState(!1),r=()=>{s(!0)},i=()=>{s(!1)},a=()=>"Ключ API";return e.jsxs(e.Fragment,{children:[e.jsx(y,{onClick:r,children:"Добавить"}),e.jsxs(K,{open:n,onClose:i,children:[e.jsxs(X,{children:["Добавить ",a()," API"]}),e.jsxs(Y,{children:[e.jsx(re,{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsx(D,{autoFocus:!0,margin:"dense",id:"api_key",label:a(),fullWidth:!0,variant:"standard"})]}),e.jsxs(pe,{children:[e.jsx(y,{onClick:i,children:"Сохранить"}),e.jsx(y,{onClick:i,children:"Отмена"})]})]})]})}function hn({item:t}){return e.jsxs(f,{sx:{border:"solid thin #ccc",borderRadius:"8px",padding:1},children:[e.jsxs(f,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(m,{variant:"h6",children:t.name}),e.jsx(y,{children:"Удалить"})]}),e.jsxs(f,{children:["Ключ API: ",t!=null&&t.api_key?"Есть":e.jsx(un,{supplierId:t.id,keyType:"uni"})]})]})}function pn(){const[t,n]=h.useState(!1),s=()=>{n(!0)},r=()=>{n(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(y,{onClick:s,variant:"contained",children:"Добавить поставщика"}),e.jsxs(K,{open:t,onClose:r,children:[e.jsx(X,{children:"Добавить поставщика"}),e.jsxs(Y,{children:[e.jsx(re,{children:"Добавьте ключ API в кабинете поставщика и вставьте его сюда"}),e.jsx(D,{autoFocus:!0,margin:"dense",id:"name",label:"Наименование",fullWidth:!0,variant:"standard"}),e.jsx(D,{autoFocus:!0,margin:"dense",id:"api_key",label:"Ключ API",fullWidth:!0,variant:"standard"})]}),e.jsxs(pe,{children:[e.jsx(y,{onClick:r,children:"Сохранить"}),e.jsx(y,{onClick:r,children:"Отмена"})]})]})]})}const je=()=>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"})]}),xn="_headerContainer_1o3pk_1",gn="_customHeaderLabel_1o3pk_19",Ce={headerContainer:xn,customHeaderLabel:gn},fn=({size:t=16,color:n,direction:s="right"})=>{const r=W(),i={up:"0deg",right:"90deg",down:"180deg"},a=n||r.palette.text.primary;return e.jsx("svg",{style:{transform:`rotate(${i[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:a})})},Ze=t=>{const n=W(),[s,r]=h.useState(!1),[i,a]=h.useState(!1),l=()=>{const o=t.column.getSort();r(o==="asc"),a(o==="desc")},c=o=>{const d=s?"desc":"asc";t.setSort(d,o.shiftKey)};return h.useEffect(()=>{t.column.addEventListener("sortChanged",l),l()},[]),e.jsxs("div",{className:Ce.headerContainer,onClick:c,onTouchEnd:c,style:t.enableSorting?{cursor:"pointer"}:{},children:[e.jsx(m,{className:Ce.customHeaderLabel,sx:{fontSize:"16px",lineHeight:1.4,color:n.palette.text.secondary},children:t.displayName}),t.enableSorting?e.jsx("span",{style:{minWidth:"16px",maxWidth:"16px",minHeight:"16px",maxHeight:"16px"},children:e.jsx(fn,{direction:i?"down":"up",color:s||i?n.palette.blue[500]:n.palette.text.secondary})}):""]})},mn="_textCell_cfweo_1",Se={textCell:mn},ue=({value:t,textAlignment:n="left",link:s,afterIcon:r})=>{const i=W();return e.jsxs("div",{className:Se.textCell,style:{textAlign:n},children:[e.jsx(m,{className:Se.text,sx:{fontSize:"16px",lineHeight:1.4,color:i.palette.text.primary},children:s?e.jsx("a",{href:s,target:"_blank",children:t}):t}),r||""]})},jn="_numberCell_1xqpf_1",vn="_number_1xqpf_1",yn="_tag_1xqpf_17",A={numberCell:jn,number:vn,tag:yn},oe=({value:t,digits:n,cellStyle:s,textAlignment:r="end",tag:i=!1,icon:a=!1,prefix:l=!1,suffix:c=!1})=>{const o=W(),d=p=>isNaN(p)||!isFinite(p)?"--":n!==void 0?p.toLocaleString("ru-RU",{minimumFractionDigits:n,maximumFractionDigits:n}):p.toLocaleString("ru-RU");return e.jsxs("div",{className:A.numberCell,style:{...s,justifyContent:r},children:[i&&e.jsx("div",{className:A.tag,children:i}),a&&e.jsx("div",{className:A.icon,children:a}),e.jsxs(m,{className:A.number,sx:{fontSize:"16px",lineHeight:1.4,color:o.palette.text.primary},children:[l&&t&&e.jsx("div",{className:A.prefix,children:l}),d(Number(t)),c&&t&&e.jsx("div",{className:A.suffix,children:c})]})]})},Ke=30,bn=30,Cn=40;ft.setLicenseKey("key");mt.registerModules([jt]);const Sn=[{headerName:"Тариф",field:"name",cellRenderer:t=>e.jsx(ue,{value:t.value})},{headerName:"Цена",field:"price",cellRenderer:t=>e.jsx(oe,{value:t.value}),width:70},{headerName:"Устройств",field:"devices",cellRenderer:t=>e.jsx(oe,{value:t.value}),width:100},{headerName:"Биддеров",field:"limit",cellRenderer:t=>e.jsx(oe,{value:t.value}),width:100}];function we({children:t}){const[n,s]=Ae.useState(!1),[r,i]=h.useState([]),[a,l]=h.useState(!0),{showRequestError:c}=N(),o=()=>{l(!0),I("user/tariff").then(g=>{g.data&&i(g.data)}).catch(g=>{c(g)}).finally(()=>l(!1))},d=g=>{B("billing/get_payment_link",{tariff:g}).then(j=>{j.data.url?(window.open(j.data.url,"_blank").focus(),u()):setErrorMessage("Ошибка при создании платежа")}).catch(j=>{setErrorMessage(`Ошибка при создании платежа: ${fe(j)}`)})},p=()=>{s(!0),o()},u=()=>{s(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"contained",onClick:p,color:"primary",children:t}),e.jsxs(K,{open:!!n,onClose:u,sx:{"& .MuiDialog-paper":{borderRadius:"10px",width:"500px"}},children:[e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:4,pb:6},children:["Выберите тариф",e.jsx(f,{onClick:u,sx:{cursor:"pointer",marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",lineHeight:"26px"},children:e.jsx(je,{})})]}),e.jsx(Y,{sx:{p:4,pt:6},children:e.jsx(f,{sx:{width:"100%"},children:e.jsx($e,{domLayout:"autoHeight",rowHeight:Cn,headerHeight:Ke,rowData:r,columnDefs:Sn,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!1,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:Ze},onRowDataUpdated:g=>{g.api.sizeColumnsToFit()},onRowClicked:g=>{console.log("props",g),d(g.data.id)}})})})]})]})}function Xe(){var p;W();const[t,n]=h.useState(!1),[s,r]=h.useState(void 0),{showRequestError:i,showError:a}=N();h.useEffect(()=>{n(!0),I("user/license").then(u=>{r(u.data)}).catch(u=>i(u)).finally(()=>n(!1))},[]);const l=()=>{B("billing/get_payment_link",{}).then(u=>{u.data.url?window.open(u.data.url,"_blank").focus():a("Ошибка при создании платежа")}).catch(u=>{i(`Ошибка при создании платежа: ${fe(u)}`)})};if(t)return e.jsx(E,{count:3});let c=!1;if(!(s!=null&&s.length))c=!0;else{const u=s[0];new Date(u.action_date).getFullYear()<2020&&(c=!0)}if(c)return e.jsxs(f,{sx:{display:"flex",columnGap:3,alignItems:"center"},children:[e.jsx(m,{children:"Отстутствует лицензия"}),e.jsx(we,{children:"Активировать подписку"})]});const o=s[0],d=new Date(o.action_date);return e.jsxs(v,{spacing:4,children:[e.jsxs(v,{spacing:2,children:[e.jsxs(m,{lineHeight:1.4,children:["Номер лицензии: ",o.key]}),e.jsxs(m,{lineHeight:1.4,children:["Тариф ",(p=o.tariff)==null?void 0:p.name]}),o.is_active?e.jsxs(m,{lineHeight:1.4,children:["Подписка активна до ",d.toLocaleDateString()]}):e.jsxs(m,{lineHeight:1.4,children:["Подписка закончилась ",d.toLocaleDateString()]})]}),e.jsx(f,{sx:{mt:2,display:"flex",gap:2},children:o.tariff===void 0?e.jsx(we,{children:"Выбрать тариф"}):e.jsx(e.Fragment,{children:e.jsx(P,{variant:"contained",onClick:l,children:"Продлить подписку"})})})]})}const wn="user/suppliers";function kn(){const[t,n]=h.useState(!0),[s,r]=h.useState([]);return h.useEffect(()=>{n(!0),I(wn).then(i=>{r(i.data)}).finally(()=>n(!1))},[]),t?e.jsx("div",{children:"Загрузка..."}):e.jsxs(v,{spacing:2,children:[e.jsxs(f,{sx:{display:"flex",columnGap:3,alignItems:"center"},children:[e.jsx(pn,{}),e.jsx(Xe,{}),e.jsx(ee,{to:"/devices",children:e.jsx(y,{variant:"outlined",children:"Расширение Chrome"})})]}),s.map((i,a)=>e.jsx(hn,{item:i},a))]})}const Fn=`${Q}/cabinet/supplier_full/`;function Dn(){const[t,n]=h.useState([]),[s,r]=h.useState(!0);return h.useEffect(()=>{t.length===0&&(r(!0),F.get(Fn).then(i=>{n(i.data)}).finally(()=>r(!1)))},[]),e.jsxs("div",{children:[e.jsx("h1",{children:"Поставщики и ключи API"}),e.jsx(kn,{suppliers:t})]})}function Tn({instance:t,campaignId:n}){return e.jsxs(v,{spacing:2,children:[e.jsx(D,{id:"name",label:"Наименование кампании",variant:"outlined",value:t.name??"",size:"small"}),e.jsx(D,{id:"cpm",label:"Ставка",variant:"outlined",value:t.bet??"",size:"small",type:"number"}),e.jsxs(f,{sx:{display:"flex",alignItems:"center",columnGap:2},children:[e.jsx(y,{variant:"contained",children:"Сохранить изменения"}),e.jsx(y,{component:ie,href:sn(n),children:"Запустить биддер"})]})]})}const In=(t,n)=>(J.find(s=>s.id===t),`${ge}/${n}`),_n=t=>`${ae}/auction/${t}/`;function En(){var d;const{campaignId:t}=se(),[n,s]=h.useState(!0),[r,i]=h.useState([]),[a,l]=h.useState([]),[c,o]=h.useState(void 0);return h.useEffect(()=>{s(!0),F.get(In(6,t)).then(p=>{i(p.data)}).finally(()=>s(!1)),F.get(_n(t)).then(p=>{var u,g;(g=(u=p.data)==null?void 0:u.data)==null||g.forEach((j,b)=>{j.place=b+1}),l(p.data)})},[t]),e.jsxs(v,{spacing:3,children:[e.jsxs(We,{"aria-label":"breadcrumb",children:[e.jsx(ie,{underline:"hover",href:"/campaigns",children:"Мои кампании"}),e.jsx(m,{color:"text.primary",children:t})]}),e.jsxs(m,{variant:"h5",children:["Изменение: ",(d=J.find(p=>p.id===r.advert_type))==null?void 0:d.name,": ",r.name]}),e.jsxs(f,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gridGap:"20px"},children:[n?e.jsx(f,{sx:{width:"100%"},children:e.jsx(E,{})}):e.jsx(Tn,{instance:r,campaignId:t}),e.jsx(f,{}),e.jsx(qe,{...a,campaignId:t})]})]})}const Ln="&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",Rn=async t=>{let{data:n}=await F.get(`https://catalog-ads.wildberries.ru/api/v5/search?keyword=${t}`);if(!n.adverts)return null;const s=[];n.adverts.forEach(c=>s.push(c.id));let r=localStorage.getItem("geoData")||Ln;const{data:i}=await F.get(`https://prod.mkeeper.ru/api/wp/clist/?${r}&nm=${s.join(";")}`);if(!i)return null;const a=i.data.products.map(c=>(c.deliveryHours=c.time1+c.time2,c.nmId=c.id,c));return{advData:n,advGoods:a}};async function Hn(t){const{data:n}=await F.get("https://static-basket-01.wb.ru/vol0/data/subject-base.json");let s=[];const r=(i,a)=>{i.forEach(l=>{if(l.id==a){const c={id:l.id,subj_name:l.name};s.push(c)}else l.childs&&r(l.childs,a)})};return t.forEach(i=>r(n,i)),s}const Pn=function(t,n,s){const{advData:r}=t;r.pages.sort((a,l)=>a.page-l.page);const i={};return s=An(s,r),r.pages.forEach(a=>{let l=s.splice(0,a.positions.length);l.forEach((c,o)=>{const d=r.adverts.find(p=>p.id===c.nmId);Wn(c,d,a.positions[o],a.page)}),a.page===1&&(l=n.concat(l)),l.sort((c,o)=>c.advStatFields.position-o.advStatFields.position),i[a.page]=l}),i},Wn=function(t,n,s,r=1){var i,a,l,c;t.advStatFields={advertId:n.advertId,position:s,cpm:(i=(a=t.advStatFields)===null||a===void 0?void 0:a.cpm)!==null&&i!==void 0?i:n.cpm,subjectId:t.subjectId,brandId:t.brandCod,kindId:t.kindId,page:r,mk_cpmweight:(l=(c=t.advStatFields)===null||c===void 0?void 0:c.mk_cpmweight)!==null&&l!==void 0?l:0,mk_deliveryweight:(l=(c=t.advStatFields)===null||c===void 0?void 0:c.mk_deliveryweight)!==null&&l!==void 0?l:0,totalWeight:(l=(c=t.advStatFields)===null||c===void 0?void 0:c.totalWeight)!==null&&l!==void 0?l:0,cpmRatio:t.advStatFields.cpmRatio,deliveryRatio:t.advStatFields.deliveryRatio}},An=function(t,n){var s,r;if((s=n.adverts)===null||s===void 0||!s.length||t==null||!t.length)return[];const i=n.adverts.reduce((l,c)=>l.set(c.id,c),new Map);if((r=n.prioritySubjects)!==null&&r!==void 0&&r.length)return $n(t,n,i);const a=Ye(t,n.adverts.length);return Je(a,n,i)},Ye=function(t,n){return{advertsCount:n??0,products:t??[]}},$n=function(t,n,s){const r=t.reduce((l,c)=>l.set(c.nmId,c),new Map),i=n.adverts.reduce((l,c)=>{var o;const d=c.subject,p=r.get(c.id),u=(o=l.get(d))!==null&&o!==void 0?o:Ye();return u.advertsCount++,p&&u.products.push(p),l.set(d,u)},new Map),a=[];for(let l=0;lo.advStatFields.totalWeight==d.advStatFields.totalWeight&&d.advStatFields.cpm!=o.advStatFields.cpm?d.advStatFields.cpm-o.advStatFields.cpm:d.advStatFields.totalWeight-o.advStatFields.totalWeight),r},Mn=function(t,n,s){const{cpms:r,deliveries:i}=t.reduce((o,d)=>{if(!d)return;const p=n.get(d.nmId);return o.deliveries.add(d.deliveryHours),o.cpms.add(p.cpm),o},{cpms:new Set,deliveries:new Set}),a=1/s.advertsCount;function l(o){let d=1;return o.reduce((p,u)=>p.has(u)?p:(p.size>0&&(d-=a),p.set(u,d)),new Map)}function c(o,d){const p=Array.from(o);return p.sort(d),p}return{weightMapCpm:l(c(r,(o,d)=>d-o)),weightMapDelivery:l(c(i,(o,d)=>o-d))}},Bn=function(t){var n,s;let r=.6666666666666666,i=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 a=t.sortWeights.cpm+t.sortWeights.delivery;a&&(r=t.sortWeights.cpm/a,i=t.sortWeights.delivery/a)}return{cpmRatio:r,deliveryRatio:i}};function Nn(t,n){const s=new Map;t.advData.adverts.forEach(d=>{s.has(d.id)||s.set(d.id,d)});const r=Pn(t,[],t.advGoods),i=[];let a=0,l=0,c=0;Object.entries(r).forEach((d,p)=>{d[1].forEach(u=>{const g=++a;let j;n&&(j=n.find(C=>C.id===u.advStatFields.subjectId)),l||(l=u.advStatFields.cpmRatio),c||(c=u.advStatFields.deliveryRatio);const b={brand:u.brand,deliveryHours:u.deliveryHours,id:u.cod1S||u.id,n:g,page:u.advStatFields.page,pl:a,position:u.advStatFields.position,subj_name:j?j.subj_name:"",cpm:u.advStatFields.cpm,cpmWeight:u.advStatFields.mk_cpmweight.toFixed(3),deliveryWeight:u.advStatFields.mk_deliveryweight.toFixed(3),totalWeight:u.advStatFields.totalWeight.toFixed(3),subject:"",name:u.name};i.push(b)})});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=l*100,o.deliveryPercentages=c*100,{data:i,ratio:o}}async function zn(t){const n=await Rn(t);if(n===null)return new Promise((i,a)=>i([]));const s=await Hn(n.advData.prioritySubjects),r=Nn(n,s);return new Promise((i,a)=>i(r.data))}var Qe=(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))(Qe||{});const et=h.createContext({resolution:1920}),ke=()=>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 Vn({children:t}){const[n,s]=h.useState(document.body.clientWidth);return h.useEffect(()=>{window.addEventListener("resize",()=>s(ke())),s(ke())},[]),e.jsx(et.Provider,{value:{resolution:n},children:t})}function tt(t,n=246,s=328){return`//basket-${Gn(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 Gn(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"}const R=Re(m)({fontSize:"12px"});function On({rows:t,skeleton:n}){return n?e.jsx(ne,{children:[...Array(5)].map((s,r)=>e.jsxs($,{alignItems:"flex-start",sx:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",flexDirection:"column","&:not(:first-child)":{marginTop:"15px"}},children:[e.jsx(H,{variant:"rounded",height:15,width:"100%"}),e.jsxs("div",{style:{display:"flex",marginTop:"4px",width:"100%"},children:[e.jsx(H,{variant:"rounded",height:80,width:60,style:{marginRight:"4px"}}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(H,{variant:"rounded",height:15,width:"100%"}),e.jsx(H,{variant:"rounded",height:15,width:"100%",style:{marginTop:"4px"}}),e.jsx(H,{variant:"rounded",height:15,width:"100%",style:{marginTop:"4px"}})]})]})]},r))}):t.length?e.jsx(ne,{children:t.map(s=>e.jsxs($,{alignItems:"flex-start",sx:{border:"1px solid #d5d5d5",padding:"8px",borderRadius:"10px",flexDirection:"column","&:not(:first-child)":{marginTop:"15px"}},children:[e.jsxs("div",{style:{display:"flex"},children:[e.jsx(R,{sx:{marginRight:"5px"},children:s.n}),e.jsx(R,{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:`${tt(s.id)}`,style:{borderRadius:"5px"}})}),e.jsxs("div",{style:{marginRight:"16px",flexGrow:1},children:[e.jsxs(R,{children:["Артикул: ",s.id]}),e.jsxs(R,{children:["Бренд: ",s.brand]}),e.jsxs(R,{children:["Категория: ",s.subj_name]})]}),e.jsxs("div",{style:{minWidth:"90px"},children:[e.jsxs(R,{children:["Ставка: ",s.cpm," ₽"]}),e.jsxs(R,{children:["Доставка: ",s.deliveryHours," ч."]})]})]})]},s.id))}):e.jsx("div",{style:{width:"100%",textAlign:"center"},children:"Пусто..."})}const he=[{title:"№",align:"center"},{title:"",align:"center"},{title:"Артикул",align:"center"},{title:"Бренд",align:"center"},{title:"Категория",align:"center"},{title:"Ставка",align:"center"},{title:"Вес ставки",align:"center"},{title:"Доставка",align:"center"},{title:"Вес доставки",align:"center"},{title:"Общий вес",align:"center"},{title:"Место",align:"center"},{title:"Страница",align:"center"},{title:"Позиция",align:"center"}];function Un({rows:t,skeleton:n}){return e.jsx(O,{component:U,sx:{boxShadow:1},children:e.jsxs(q,{size:"small",children:[e.jsx(Z,{children:e.jsx(w,{children:he.map((s,r)=>e.jsx(x,{sx:{color:"rgba(29, 36, 51, 0.8)",fontSize:"14px",fontWeight:"700"},align:s.align,children:s.title},r))})}),n?e.jsx(M,{children:[...Array(8)].map((s,r)=>e.jsx(w,{children:e.jsx(x,{colSpan:he.length,width:"100%",children:e.jsx(H,{variant:"rectangular",height:32,width:"100%"},r)})},r))}):e.jsx(qn,{rows:t})]})})}function qn({rows:t}){return t.length?e.jsx(M,{children:t==null?void 0:t.map((n,s)=>e.jsxs(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[e.jsx(x,{align:"center",children:T(n.n)}),e.jsx(x,{align:"center",children:e.jsx("a",{href:`https://www.wildberries.ru/catalog/${n.id}/detail.aspx`,target:"_blank",children:e.jsx("img",{height:"22px",src:`${tt(n.id)}`})})}),e.jsx(x,{align:"center",children:e.jsx("a",{href:`https://www.wildberries.ru/catalog/${n.id}/detail.aspx`,target:"_blank",children:n.id})}),e.jsx(x,{align:"center",children:n.brand}),e.jsx(x,{align:"center",children:n.subj_name}),e.jsxs(x,{align:"center",children:[T(n.cpm)," ₽"]}),e.jsx(x,{align:"center",children:T(n.cpmWeight)}),e.jsxs(x,{align:"center",children:[T(n.deliveryHours)," ч."]}),e.jsx(x,{align:"center",children:T(n.deliveryWeight)}),e.jsx(x,{align:"center",children:T(n.totalWeight)}),e.jsx(x,{align:"center",children:T(n.pl)}),e.jsx(x,{align:"center",children:T(n.page)}),e.jsx(x,{align:"center",children:T(n.position)})]},n.id))}):e.jsx(w,{sx:{"&:last-child td, &:last-child th":{border:0}},children:e.jsx(x,{component:"th",scope:"row",align:"center",colSpan:he.length,children:"Пусто..."})})}function Zn({rows:t,skeleton:n}){const{resolution:s}=h.useContext(et);return e.jsx(e.Fragment,{children:s<=Qe.Mobile?e.jsx(On,{skeleton:n,rows:t}):e.jsx(Un,{skeleton:n,rows:t})})}const Kn=async t=>{const{data:n}=await F.get(`https://search.wb.ru/suggests/api/v3/hint?query=${t}&gender=common&locale=ru&lang=ru`);let s=[];return n.forEach(r=>{r.type==="suggest"&&s.push({label:r.name})}),new Promise((r,i)=>r(s))};function Xn(){const[t,n]=h.useState(""),[s,r]=h.useState(!1),[i,a]=He("",300),[l,c]=h.useState([]),[o,d]=h.useState([]),p=u=>{n(u),u&&(a(u),r(!0))};return h.useEffect(()=>{if(!t){c([]),d([]),r(!1);return}zn(t).then(u=>{c(u),r(!1)}),Kn(t).then(u=>{Array.isArray(u)&&d(u)})},[i]),e.jsxs(v,{spacing:3,children:[e.jsx(m,{variant:"h4",children:"Аукцион поиска"}),e.jsx(f,{children:e.jsx(vt,{freeSolo:!0,disableClearable:!0,autoComplete:!0,inputValue:t,options:o.map(u=>u.label),onInputChange:u=>{const{target:g}=u;if(g.attributes["data-option-index"]){const j=o[parseInt(g.attributes["data-option-index"].value)];return p(j.label)}p(g.value)},renderInput:u=>e.jsx(D,{label:"Введите текст для поиска",...u,InputProps:{...u.InputProps,type:"search"}})})}),e.jsx(f,{children:e.jsx(Zn,{rows:l,skeleton:s})})]})}function Yn({onConfirm:t,title:n,button:s,children:r}){const[i,a]=h.useState(!1),l=()=>{a(!0)},c=()=>{a(!1)},o=()=>{t&&t(),a(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:l,className:"hoverable-icon",children:s}),e.jsxs(K,{open:i,onClose:c,sx:{"& .MuiDialog-paper":{borderRadius:"10px",width:"455px"}},children:[e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:4,pb:6},children:[n,e.jsx(f,{onClick:c,sx:{cursor:"pointer",marginLeft:"auto",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"24px",lineHeight:"26px"},children:e.jsx(je,{})})]}),r?e.jsx(Y,{sx:{p:4,pb:6,pt:6},children:e.jsx(re,{children:r})}):"",e.jsxs(pe,{sx:{p:4,pt:0},children:[e.jsx(P,{onClick:o,variant:"outlined",color:"error",sx:{width:"100%"},children:"Подтвердить"}),e.jsx(P,{onClick:c,variant:"outlined",color:"secondary",sx:{width:"100%"},children:"Отмена"})]})]})]})}const Jn=()=>{const t=W();return 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",{"clip-path":"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:t.palette.redPale[400]})})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_7578_23038",children:e.jsx("rect",{width:"24",height:"24",fill:"white"})})})]})},Qn=({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||"Нет данных"})}),Fe="user/device";function es(){const[t,n]=h.useState(!0),[s,r]=h.useState([]),{showRequestError:i}=N(),a=()=>{n(!0),I(Fe).then(d=>{r(d.data)}).catch(d=>{i(d)}).finally(()=>n(!1))};h.useEffect(()=>{a()},[]);const l=d=>{Lt(`${Fe}/${d}`).then(p=>{a()})},c=d=>`${d.license}${d.dev_num>0?`-${d.dev_num}`:""}`;if(t)return e.jsx(E,{count:2});const o=[{headerName:"Ключ активации",field:"license",valueFormatter:d=>c(d.value),cellRenderer:d=>e.jsx(ue,{value:d.value})},{headerName:"Дата активации",field:"activation_date",cellRenderer:d=>e.jsx(ue,{value:d.value,afterIcon:e.jsx(f,{sx:{height:"24px",marginLeft:"auto"},children:e.jsx(Yn,{button:e.jsx(Jn,{}),title:"Деактивировать устройство?",onConfirm:()=>l(d.data.dev_num)})})})}];return e.jsx(e.Fragment,{children:e.jsx(v,{spacing:3,children:e.jsx(f,{sx:{width:"100%"},children:e.jsx($e,{domLayout:"autoHeight",rowHeight:bn,headerHeight:Ke,rowData:s,columnDefs:o,defaultColDef:{suppressHeaderMenuButton:!0,sortable:!1,suppressMovable:!0,resizable:!1,suppressHeaderFilterButton:!0,suppressFloatingFilterButton:!0,headerComponent:Ze},onRowDataUpdated:d=>{d.api.sizeColumnsToFit()},noRowsOverlayComponent:Qn})})})})}const ts=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.0026 4.00065V9.33398C12.0026 10.8067 10.8087 12.0007 9.33594 12.0007H4.0026C2.52984 12.0007 1.33594 10.8067 1.33594 9.33398V4.00065C1.33594 2.52789 2.52984 1.33398 4.0026 1.33398H9.33594C10.8087 1.33398 12.0026 2.52789 12.0026 4.00065ZM2.33594 4.00065V9.33398C2.33594 9.77601 2.51153 10.1999 2.82409 10.5125C3.13665 10.8251 3.56058 11.0007 4.0026 11.0007H9.33594C10.2564 11.0007 11.0026 10.2545 11.0026 9.33398V4.00065C11.0026 3.08018 10.2564 2.33398 9.33594 2.33398H4.0026C3.08213 2.33398 2.33594 3.08018 2.33594 4.00065Z",fill:"#007BFB"}),e.jsx("path",{d:"M14.0026 5.50065C13.728 5.50424 13.5062 5.72601 13.5026 6.00065V11.334C13.4989 12.5291 12.531 13.497 11.3359 13.5007H6.0026C5.72646 13.5007 5.5026 13.7245 5.5026 14.0007C5.5026 14.2768 5.72646 14.5007 6.0026 14.5007H11.3359C13.0848 14.5007 14.5026 13.0829 14.5026 11.334V6.00065C14.499 5.72601 14.2772 5.50424 14.0026 5.50065Z",fill:"#007BFB"}),e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.0026 4.00065V9.33398C12.0026 10.8067 10.8087 12.0007 9.33594 12.0007H4.0026C2.52984 12.0007 1.33594 10.8067 1.33594 9.33398V4.00065C1.33594 2.52789 2.52984 1.33398 4.0026 1.33398H9.33594C10.8087 1.33398 12.0026 2.52789 12.0026 4.00065ZM2.33594 4.00065V9.33398C2.33594 9.77601 2.51153 10.1999 2.82409 10.5125C3.13665 10.8251 3.56058 11.0007 4.0026 11.0007H9.33594C10.2564 11.0007 11.0026 10.2545 11.0026 9.33398V4.00065C11.0026 3.08018 10.2564 2.33398 9.33594 2.33398H4.0026C3.08213 2.33398 2.33594 3.08018 2.33594 4.00065Z",stroke:"#007BFB","stroke-width":"0.2"}),e.jsx("path",{d:"M14.0026 5.50065C13.728 5.50424 13.5062 5.72601 13.5026 6.00065V11.334C13.4989 12.5291 12.531 13.497 11.3359 13.5007H6.0026C5.72646 13.5007 5.5026 13.7245 5.5026 14.0007C5.5026 14.2768 5.72646 14.5007 6.0026 14.5007H11.3359C13.0848 14.5007 14.5026 13.0829 14.5026 11.334V6.00065C14.499 5.72601 14.2772 5.50424 14.0026 5.50065Z",stroke:"#007BFB","stroke-width":"0.2"})]});function ns(){const[t,n]=h.useState(""),{showRequestError:s}=N(),r=()=>{Ne("user/device/new").then(a=>{var l;(l=a.data)!=null&&l.key&&n(a.data.key)}).catch(a=>{s(a)})},i=()=>{n("")};return e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outlined",onClick:r,color:"secondary",children:"Активировать новое устройство"}),e.jsxs(K,{open:!!t,onClose:i,sx:{"& .MuiDialog-paper":{borderRadius:"10px"}},children:[e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",p:4,pb:6,fontSize:"24px",lineHeight:"26px"},children:["Активация нового устройства",e.jsx(f,{onClick:i,sx:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(je,{})})]}),e.jsx(Y,{sx:{p:4,pb:6},children:e.jsxs(re,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(m,{color:"text.secondary",sx:{fontSize:"16px",lineHeight:1.4,fontWeight:400},children:"Ключ активации:"}),e.jsxs(m,{color:"text.primary",sx:{fontSize:"16px",lineHeight:1.4,fontWeight:600,display:"flex",alignItems:"center",gap:1},children:[t,e.jsx("div",{style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>navigator.clipboard.writeText(t),children:e.jsx(ts,{})})]})]})})]})]})}function nt(){const{profile:t}=L();return e.jsxs(v,{spacing:6,children:[e.jsx(m,{variant:"h5",children:"Устройства"}),e.jsxs(v,{spacing:4,children:[e.jsx(f,{sx:{display:"flex",gap:4},children:e.jsx(ns,{})}),e.jsx(es,{})]})]})}function st({hidden:t}){const n=G(),{profile:s}=L(),{showRequestError:r,showError:i}=N(),[a,l]=h.useState("");return h.useEffect(()=>{s.auth?Ne("user/device/new").then(c=>{var o;(o=c.data)!=null&&o.key?l(c.data.key):(i("Нет свободных активаций. Отвяжите одно устройство или повысьте тариф"),n("/"))}).catch(c=>{}):n("/auth/login")},[]),e.jsxs("div",{children:[!t&&e.jsx(me,{}),e.jsx("input",{type:"hidden",id:"new-device-key",value:a})]})}function De(){const{profile:t}=L(),[n,s]=Ee(),r=n.get("auth")==="success";return t.auth===void 0?e.jsx(me,{}):t.auth===!1?e.jsx(Ge,{}):e.jsxs(Le,{maxWidth:"md",children:[e.jsxs(v,{spacing:8,children:[e.jsx(m,{variant:"h4",children:"Панель управления"}),e.jsx(Xe,{}),e.jsx(nt,{})]}),r&&e.jsx(st,{hidden:!0})]})}const ss=()=>{const{clearProfile:t}=L(),n=G(),s=()=>{B("user/logout").then(()=>{t(),n("/")}).catch(r=>{})};return h.useEffect(()=>{s()},[s]),e.jsx("div",{className:"auth-page",children:"Выход..."})},is=yt([{element:e.jsx(Zt,{}),path:"/",children:[{path:"/",index:!0,element:e.jsx(De,{})},{path:"/auth/login",element:e.jsx(Ge,{})},{path:"/auth/logout",element:e.jsx(ss,{})},{path:"/auth/ext-auth",element:e.jsx(st,{})},{path:"/profile",element:e.jsx(De,{})},{path:"/devices",element:e.jsx(nt,{})},{path:"/campaigns/:campaignId/bidder",element:e.jsx(dn,{})},{path:"/campaigns/:campaignId",element:e.jsx(En,{})},{path:"/campaigns",element:e.jsx(qt,{})},{path:"/subjects/:subjectId",element:e.jsx(tn,{})},{path:"/subjects",element:e.jsx(en,{})},{path:"/priority-subjects/:subjectId",element:e.jsx(Kt,{})},{path:"/priority-subjects",element:e.jsx(Yt,{})},{path:"/suppliers",element:e.jsx(Dn,{})},{path:"/search-auction",element:e.jsx(Xn,{})}]}]);function rs(){return e.jsx(bt,{router:is})}function as(){return e.jsx(e.Fragment,{children:e.jsx(rs,{})})}let S=xe({palette:{bluePale:{200:"#BFDEFE",300:"#80BDFD",500:"#007BFB",600:"#0067D2"},blue:{500:"#0002F3"},cyan:{100:"#E6F6FD",500:"#00A2E8"},green:{100:"#E6F8F1",200:"#ADE5D2",500:"#00B774"},primary:{50:"#FFFBF3",200:"#FFE3AB",300:"#FCD586",500:"#F9AB0D",600:"#F1A200"},orange:{500:"#FC8816"},red:{100:"#FFECEC",500:"#FF3F3F"},redPale:{100:"#FFF2F0",200:"#FEDDD9",300:"#FEBCB3",400:"#FD7967"},greyF:{50:"#F7F8FA",100:"#EFF1F5",600:"#9AA0AC",700:"#6E7788"},greyG:{100:"#DDDDDE",200:"#C3C3C3"},greyS:{100:"#F1F1F3",200:"#D1D1D6"},dark:{500:"#383540"}},spacing:4}),ls=xe(S,{palette:{primary:{light:S.palette.primary[50],main:S.palette.primary[500],dark:S.palette.primary[600],contrastText:S.palette.dark[500]},secondary:{light:S.palette.greyF[50],main:S.palette.greyF[600],dark:S.palette.greyF[700],text:S.palette.dark[500],contrastText:(Ct(S.palette.greyF[600],"#fff")>4.5,S.palette.dark[500])},text:{primary:S.palette.dark[500],secondary:S.palette.greyF[700],disabled:S.palette.greyG[200]},error:{main:S.palette.red[500]}}});xe({palette:{primary:{main:"#FFB400"}},spacing:4});St.createRoot(document.getElementById("root")).render(e.jsx(Ae.StrictMode,{children:e.jsx(wt,{theme:ls,children:e.jsx(Vn,{children:e.jsx(Wt,{children:e.jsx(At,{children:e.jsx(as,{})})})})})}));