import{c as pe,t as fe,j as t,u as Oe,b as ne,a as ke,h as Be,r as i,v as Ue,w as De,x as Ge,y as Ye,S as He,T as ze,V as j,U as re,o as Ze,z as Qe,A as $e,C as qe}from"./index-DAC_nvu_.js";import{S as Ke}from"./SearchBar-Dc7XFObO.js";import{V as We}from"./VacancyItem-CuRiWs3N.js";/* empty css                   */import{V as Je}from"./VacancyItemSkeleton-LrT57mIm.js";import{B as Xe}from"./BreadcrumbNav-CEt_qco_.js";import{E as N}from"./ErrorTooltip-CSGzOk8l.js";import{V as oe}from"./VacancyFilter-BrSvpJ76.js";import{D,S as et}from"./sort_icon-Bn8Ztyya.js";import{I as G}from"./InputRadio-BxN_ivj-.js";import{N as tt}from"./Notification-D8DhTeIU.js";import{S as at}from"./SEO-D3SqufAR.js";import"./MatchBadge-CrcSn9i_.js";import"./checkbox_icon-Ce4kOCJ6.js";import"./HoverHint-Ca4hoDjb.js";import"./Skeleton-B9qjVT1Z.js";import"./formatters-CnUSUV7p.js";import"./info_icon-CdnwKllQ.js";const st="data:image/svg+xml,%3csvg%20width='29'%20height='28'%20viewBox='0%200%2029%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_8470_3701)'%3e%3cpath%20d='M27.8168%2010.9888C26.0073%208.04183%2021.8913%203.0975%2014.6673%203.0975C7.4433%203.0975%203.3273%208.04183%201.5178%2010.9888C0.958412%2011.8936%200.662109%2012.9363%200.662109%2014C0.662109%2015.0637%200.958412%2016.1064%201.5178%2017.0112C3.3273%2019.9582%207.4433%2024.9025%2014.6673%2024.9025C21.8913%2024.9025%2026.0073%2019.9582%2027.8168%2017.0112C28.3762%2016.1064%2028.6725%2015.0637%2028.6725%2014C28.6725%2012.9363%2028.3762%2011.8936%2027.8168%2010.9888ZM25.8276%2015.7897C24.2736%2018.3167%2020.7561%2022.5692%2014.6673%2022.5692C8.57846%2022.5692%205.06096%2018.3167%203.50696%2015.7897C3.17462%2015.2519%202.99859%2014.6322%202.99859%2014C2.99859%2013.3678%203.17462%2012.7481%203.50696%2012.2103C5.06096%209.68333%208.57846%205.43083%2014.6673%205.43083C20.7561%205.43083%2024.2736%209.67867%2025.8276%2012.2103C26.16%2012.7481%2026.336%2013.3678%2026.336%2014C26.336%2014.6322%2026.16%2015.2519%2025.8276%2015.7897Z'%20fill='%239A9CB0'/%3e%3cpath%20d='M14.6673%208.16667C13.5136%208.16667%2012.3858%208.50878%2011.4265%209.14976C10.4672%209.79073%209.71953%2010.7018%209.27802%2011.7677C8.83651%2012.8336%208.72099%2014.0065%208.94607%2015.138C9.17115%2016.2696%209.72672%2017.309%2010.5425%2018.1248C11.3583%2018.9406%2012.3977%2019.4962%2013.5293%2019.7212C14.6608%2019.9463%2015.8337%2019.8308%2016.8996%2019.3893C17.9655%2018.9478%2018.8766%2018.2001%2019.5176%2017.2408C20.1585%2016.2815%2020.5007%2015.1537%2020.5007%2014C20.4988%2012.4535%2019.8836%2010.9708%2018.7901%209.87726C17.6965%208.7837%2016.2138%208.16852%2014.6673%208.16667ZM14.6673%2017.5C13.9751%2017.5%2013.2984%2017.2947%2012.7228%2016.9101C12.1473%2016.5256%2011.6986%2015.9789%2011.4337%2015.3394C11.1688%2014.6999%2011.0995%2013.9961%2011.2346%2013.3172C11.3696%2012.6382%2011.703%2012.0146%2012.1924%2011.5251C12.6819%2011.0356%2013.3056%2010.7023%2013.9845%2010.5673C14.6634%2010.4322%2015.3672%2010.5015%2016.0067%2010.7664C16.6463%2011.0313%2017.1929%2011.4799%2017.5775%2012.0555C17.962%2012.6311%2018.1673%2013.3078%2018.1673%2014C18.1673%2014.9283%2017.7986%2015.8185%2017.1422%2016.4749C16.4858%2017.1313%2015.5956%2017.5%2014.6673%2017.5Z'%20fill='%239A9CB0'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_8470_3701'%3e%3crect%20width='28'%20height='28'%20fill='white'%20transform='translate(0.666992)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ct="data:image/svg+xml,%3csvg%20width='29'%20height='28'%20viewBox='0%200%2029%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_8470_4439)'%3e%3cpath%20d='M22.8337%201.16666H6.50033C4.9538%201.16852%203.47114%201.78369%202.37758%202.87725C1.28402%203.97081%200.668845%205.45347%200.666992%207L0.666992%2021C0.668845%2022.5465%201.28402%2024.0292%202.37758%2025.1227C3.47114%2026.2163%204.9538%2026.8315%206.50033%2026.8333H22.8337C24.3802%2026.8315%2025.8628%2026.2163%2026.9564%2025.1227C28.05%2024.0292%2028.6651%2022.5465%2028.667%2021V7C28.6651%205.45347%2028.05%203.97081%2026.9564%202.87725C25.8628%201.78369%2024.3802%201.16852%2022.8337%201.16666ZM6.50033%203.5H22.8337C23.5322%203.50137%2024.2144%203.71176%2024.7924%204.1041C25.3704%204.49644%2025.8178%205.05277%2026.077%205.7015L17.1427%2014.637C16.4852%2015.2919%2015.595%2015.6595%2014.667%2015.6595C13.739%2015.6595%2012.8488%2015.2919%2012.1913%2014.637L3.25699%205.7015C3.51617%205.05277%203.96354%204.49644%204.54155%204.1041C5.11955%203.71176%205.80174%203.50137%206.50033%203.5ZM22.8337%2024.5H6.50033C5.57207%2024.5%204.68183%2024.1312%204.02545%2023.4749C3.36907%2022.8185%203.00033%2021.9283%203.00033%2021V8.75L10.5417%2016.2867C11.6367%2017.379%2013.1203%2017.9924%2014.667%2017.9924C16.2137%2017.9924%2017.6973%2017.379%2018.7923%2016.2867L26.3337%208.75V21C26.3337%2021.9283%2025.9649%2022.8185%2025.3085%2023.4749C24.6522%2024.1312%2023.7619%2024.5%2022.8337%2024.5Z'%20fill='%239A9CB0'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_8470_4439'%3e%3crect%20width='28'%20height='28'%20fill='white'%20transform='translate(0.666992)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ue=({viewsCount:n=0,appliesCount:p=0})=>{const g=pe(),m=fe(),v=()=>{const S=new URLSearchParams(m.search);S.delete("tab");const w=S.toString();return w?`?${w}`:""},I=()=>{g(`/vacancies/viewed${v()}`)},E=()=>{g(`/vacancies/applied${v()}`)};return t.jsx(t.Fragment,{children:t.jsx("div",{className:"vacancy__aside",children:t.jsxs("div",{className:"vacancy__aside-links",children:[t.jsxs("div",{className:"vacancy__aside-container",onClick:I,children:[t.jsxs("div",{className:"vacancy__aside-data",children:[t.jsx("span",{className:"vacancy__count",children:n}),t.jsx("p",{className:"vacancy__category",children:"Просмотренные вакансии"})]}),t.jsx("img",{className:"vacancy__icon",src:st,alt:"Eye Icon"})]}),t.jsxs("div",{className:"vacancy__aside-container",onClick:E,children:[t.jsxs("div",{className:"vacancy__aside-data",children:[t.jsx("span",{className:"vacancy__count",children:p}),t.jsx("p",{className:"vacancy__category",children:"Отклики"})]}),t.jsx("img",{className:"vacancy__icon",src:ct,alt:"Envelope Icon"})]})]})})})},Y=[{value:"FILTER_SORTING_UNSPECIFIED",label:"По соответствию"},{value:"FILTER_SORTING_BY_DATE",label:"По дате изменения"},{value:"FILTER_SORTING_BY_SALARY_DESC",label:"По убыванию зарплаты"},{value:"FILTER_SORTING_BY_SALARY_ASC",label:"По возрастанию зарплаты"}],de=[...Y,{value:"FILTER_SORTING_BY_SIMILARITY",label:"По убыванию % совместимости"}],me=[{value:"all",label:"Все просмотры"},{value:"today",label:"Сегодня"},{value:"week",label:"За неделю"}],he=[{value:"all",label:"Все отклики"},{value:"viewed",label:"Просмотрен"},{value:"not_viewed",label:"Не просмотрен"},{value:"rejected",label:"Отказ"}],it=(n=768)=>{const[p,g]=i.useState(window.innerWidth<n);return i.useEffect(()=>{const m=()=>g(window.innerWidth<n);return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[n]),p};function xt(){Oe();const{isAuthenticated:n,userId:p}=ne(e=>e.auth),{vacancies:g,totalCount:m,isLoading:v,isFetchingMore:I,error:E,nextPageToken:S,hasMore:w}=ne(e=>e.vacancy),C=ke(),{filterType:c}=Be(),_=pe(),f=fe(),h=it(),[T,H]=i.useState(""),[ge,M]=i.useState([]),[z,ve]=i.useState(0),[Z,Q]=i.useState(0),[F,V]=i.useState(!0),[P,$]=i.useState(!1),[Ce,q]=i.useState(!1),[L,K]=i.useState("all"),[b,W]=i.useState("all"),[J,X]=i.useState(0),[ee,te]=i.useState(0),ae=i.useMemo(()=>new URLSearchParams(f.search),[f.search]),l=ae.get("tab")==="compatible"?"compatible":"all",R=ae.get("sorting")||"FILTER_SORTING_UNSPECIFIED",O=i.useRef(null),se=i.useRef(0),o=i.useMemo(()=>{const e=new URLSearchParams(f.search),a={},s=["workingExperience","workingSchedule","officeType"],r=new Set;return e.forEach((d,U)=>r.add(U)),r.forEach(d=>{d!=="tab"&&(a[d]=s.includes(d)?e.getAll(d):e.get(d))}),a},[f.search]),Se=i.useMemo(()=>JSON.stringify(o),[o]),A=i.useMemo(()=>{const{sorting:e,...a}=o;return a},[o]),_e=i.useMemo(()=>JSON.stringify(A),[A]);i.useEffect(()=>{K("all"),W("all"),window.scrollTo(0,0)},[c]);const y=Ue(T,500);De(P),i.useEffect(()=>{H(o.searchField||"")},[o.searchField]),i.useEffect(()=>{c||v||(l==="all"?X(m):l==="compatible"&&te(m))},[m,l,c,v]),i.useEffect(()=>{if(c)return;let e=!1;return(async()=>{try{let s=0;l==="compatible"?s=await j.fetchVacanciesTotal({...A}):n&&l==="all"&&(s=await j.fetchVacanciesTotal({...A,similarity:!0})),e||(l==="compatible"?X(s):n&&l==="all"&&te(s))}catch(s){console.error(s)}})(),()=>{e=!0}},[_e,l,n,c]),i.useEffect(()=>{if(c||!n){V(!1);return}let e=!1;return V(!0),(async()=>{try{const[s,r]=await Promise.all([j.fetchVacanciesTotal({viewed:!0}),j.fetchVacanciesTotal({applied:!0})]);e||(ve(s||0),Q(r||0))}catch(s){console.error(s)}finally{e||V(!1)}})(),()=>{e=!0}},[n,c]);const ce=i.useMemo(()=>Object.entries(o).reduce((e,[a,s])=>s==null||s===""?e:a==="sorting"?s!=="FILTER_SORTING_UNSPECIFIED"?e+1:e:Array.isArray(s)?e+s.length:e+1,0),[o]);i.useEffect(()=>{if(c==="filter")return;const e={...o,similarity:l==="compatible"?!0:void 0},a=C(Ge({filters:e,filterType:c,selectedResponse:b}));return()=>{a.abort()}},[C,Se,c,b,l]),i.useEffect(()=>{var e;!c&&!h&&((e=document.querySelector(".vacancy__search-field input"))==null||e.focus())},[c,h]),i.useEffect(()=>{(async()=>{if(y.trim().length<2){M([]);return}try{const[a,s,r]=await Promise.all([re.fetchAvailableSkills(y),re.fetchAvailablePersonalQualities(y),j.fetchVacancies({searchField:y,pageSize:5})]),d=a.slice(0,3).map(u=>({label:u.skillName,value:u.id})),U=s.slice(0,3).map(u=>({label:u.qualityName,value:u.id})),Ve=y.toLowerCase(),Pe=Array.from(new Set((r.vacancies||[]).map(u=>u.title).filter(u=>typeof u=="string"&&u.toLowerCase().includes(Ve)))).map(u=>({label:u,value:u}));M([...Pe,...d,...U])}catch(a){console.error("Error fetching suggestions:",a),M([])}})()},[y]);const k=i.useCallback(()=>{const e=document.documentElement.scrollTop,a=e>se.current;if(se.current=e<=0?0:e,!a||I||!w||!S)return;const s=document.documentElement.scrollHeight,r=document.documentElement.clientHeight;if(e+r>=s-300){const d={...o,similarity:l==="compatible"?!0:void 0};C(Ye({filters:d,pageToken:S,filterType:c}))}},[I,S,C,o,c,l,w]);i.useEffect(()=>(window.addEventListener("scroll",k),()=>window.removeEventListener("scroll",k)),[k]);const be=e=>H(e),ie=e=>{const a=typeof e=="string"?e:e.label,s=new URLSearchParams(f.search);a?s.set("searchField",a):s.delete("searchField"),_({search:s.toString()})},ye=()=>{const e=new URLSearchParams(f.search);T&&e.set("searchField",T),h?$(!0):_({pathname:"/vacancies/filter",search:e.toString()})},B=()=>{q(!0),setTimeout(()=>{$(!1),q(!1)},300)},le=e=>{const a=new URLSearchParams;Object.entries(e).forEach(([s,r])=>{Array.isArray(r)?r.forEach(d=>a.append(s,d)):r&&a.set(s,r)}),h&&B(),_({pathname:"/vacancies",search:a.toString()})},we=e=>{n&&C(qe({vacancyId:e})).unwrap().then(()=>Q(a=>a+1)).catch(a=>console.error("Failed to apply:",a))},Te=(e,a)=>{n&&p&&C(a?Qe({vacancyId:e,applicantId:p}):$e({vacancyId:e,applicantId:p}))},xe=e=>{c==="filter"&&O.current&&(e.preventDefault(),O.current.applyFilters())},je=e=>{if(e==="compatible"&&!n){C(Ze("auth"));return}const a=new URLSearchParams(f.search);e==="compatible"?(a.set("tab","compatible"),a.delete("sorting")):(a.delete("tab"),R==="FILTER_SORTING_BY_SIMILARITY"&&a.delete("sorting")),_({search:a.toString()},{replace:!0})},Ne=e=>{const a=String(e),s=new URLSearchParams(f.search);a==="FILTER_SORTING_UNSPECIFIED"?s.delete("sorting"):s.set("sorting",a),_({search:s.toString()})},Ie=i.useMemo(()=>{const a=(l==="compatible"?de:Y).find(s=>s.value===R);return a?a.label:"По соответствию"},[R,l]),Ee=i.useMemo(()=>{const e=me.find(a=>a.value===L);return e?e.label:"Фильтр"},[L]),Fe=i.useMemo(()=>{const e=he.find(a=>a.value===b);return e?e.label:"Фильтр"},[b]),x=c?{viewed:"Просмотры",applied:"Отклики",liked:"Избранное",filter:"Фильтры"}[c]:null,Le=i.useMemo(()=>{let e="Вакансии";return x?e+=` - ${x}`:l==="compatible"&&(e+=" - По совместимости"),e},[x,l]),Re=c?[{label:"Все вакансии",href:"/vacancies",onClick:xe},{label:x,isCurrent:!0}]:[],Ae=()=>{if(c==="applied"&&b!=="all")return t.jsx(N,{title:"Отклики не найдены",message:"В выбранном статусе у вас пока нет откликов."});if(c==="viewed"&&L!=="all")return t.jsx(N,{title:"Просмотры не найдены",message:"За выбранный период вы не просматривали вакансии."});const e={viewed:{title:"Нет просмотренных вакансий",message:"Вы ещё не просматривали ни одной вакансии."},applied:{title:"Нет откликов",message:"Вы ещё не откликались на вакансии."},liked:{title:"Нет избранных вакансий",message:"Вы ещё не добавляли вакансии в избранное."},filtered:{title:"Вакансии не найдены",message:"По вашему запросу ничего не найдено. Попробуйте изменить фильтры."},default:{title:"Вакансии пока отсутствуют",message:"Вы можете заполнить информацию о себе в разделе Профиль. Там же можно ознакомиться с тестами."}};let a="default";c&&e[c]?a=c:!c&&ce>0&&(a="filtered");const{title:s,message:r}=e[a];return t.jsx(N,{title:s,message:r})},Me=!P&&c||c&&!h;return t.jsxs(t.Fragment,{children:[t.jsx(at,{title:Le,description:"Найти работу в лучших компаниях без резюме. Сервис подберет вакансии персонально для вас по совместимости ценностей и ожиданий от будущей работы.",canonicalUrl:"/vacancies",type:"website"}),t.jsxs("div",{className:"vacancy",children:[Me&&t.jsx(Xe,{className:"vacancy__breadcrumbnav",items:Re,mobile:!1}),n&&!c&&t.jsx(ue,{viewsCount:F?0:z,appliesCount:F?0:Z}),!c&&t.jsx("div",{className:"vacancy__search-field",children:t.jsx(Ke,{type:"forward",placeholder:"Название, навык или качество",filter:"display",onSearch:()=>ie(T),value:T,onInputValueChange:be,onFilterClick:ye,suggestions:ge,onSuggestionSelect:ie,filterCount:ce,allowClear:!0})}),t.jsxs("div",{className:"main",children:[t.jsxs("div",{className:"vacancy__container",children:[(c||!h)&&t.jsx("div",{className:"vacancy__container-header",children:c&&c!=="filter"?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"/vacancies",className:"vacancy__container-header-icon",onClick:e=>{e.preventDefault(),_("/vacancies")},children:t.jsx(He,{className:"vacancy__header-icon"})}),t.jsx("h1",{className:"vacancy__container-title h1",children:x}),t.jsx("span",{className:"vacancy__count-filter body-3",children:v?0:c?m:l==="compatible"?ee:J}),!h&&c==="viewed"&&t.jsx(D,{buttonText:Ee,position:"right",className:"vacancy__filter-dropdownbutton",children:t.jsx(G,{name:"views",options:me,value:L,onChange:e=>K(String(e))})}),!h&&c==="applied"&&t.jsx(D,{buttonText:Fe,position:"right",className:"vacancy__filter-dropdownbutton",children:t.jsx(G,{name:"responses",options:he,value:b,onChange:e=>W(String(e))})})]}):null}),!c&&t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"vacancy__container-title h1",children:"Вакансии"}),t.jsxs("div",{className:"toggletab__container-vacancy",children:[t.jsx(ze,{items:[{id:"all",label:"Все",count:J},{id:"compatible",label:"По совместимости",count:n?ee:0}],activeTab:l,onTabChange:je}),t.jsx(D,{buttonText:Ie,position:h?"left":"right",icon:t.jsx(et,{}),children:t.jsx(G,{name:"vacanciesSort",options:l==="compatible"?de:Y,value:R,onChange:Ne})})]})]}),c==="filter"?t.jsx(oe,{ref:O,onApplyFilters:le,initialFilters:o}):v?t.jsx("ul",{className:"vacancy__list",children:Array.from({length:5}).map((e,a)=>t.jsx(Je,{},a))}):E?t.jsx("ul",{className:"vacancy__list",children:t.jsx(N,{message:E})}):g.length>0?t.jsxs(t.Fragment,{children:[l==="compatible"&&t.jsx(tt,{type:"accent",className:"compatibility-notification",children:"Вакансии ниже имеют процент совместимости персонально для вас. Чем выше %, тем больше вам подходят эти вакансии согласно вашим личным качествам, мотивационным и ценностным ожиданиям от будущей работы."}),t.jsx("ul",{className:"vacancy__list",children:g.map(e=>t.jsx(We,{vacancy:e,applicantId:p,onApplySuccess:we,onLikeToggle:Te},e.id))})]}):t.jsx("div",{className:"vacancy__list",children:l==="compatible"?t.jsx(N,{title:"Нет подходящих вакансий",message:"Мы не смогли найти вакансии, которые соответствуют вашему профилю. Попробуйте пройти тесты или заполнить профиль."}):Ae()})]}),n&&!c&&t.jsx(ue,{viewsCount:F?0:z,appliesCount:F?0:Z})]}),P&&t.jsx("div",{className:"mobile-filter-overlay",onClick:B,children:t.jsx("div",{className:`mobile-filter-sheet ${Ce?"closing":""}`,onClick:e=>e.stopPropagation(),children:t.jsx(oe,{isMobileView:!0,onApplyFilters:le,onCloseMobileView:B,initialFilters:o})})})]})]})}export{xt as VacancyPage};