import{M as ee,O as A,bv as I,bw as E,m as n,t as s,v as l,n as c,bx as te,by as re,aG as q,h as K,z as ae,j as t,bz as ne,_ as se,x as ie,p as G,L as oe,G as de,k as ce,u as le,a1 as pe,aq as ge,r as v,a3 as ue,y as me,a5 as he,N as xe,a6 as ye}from"./index-E0AVXOTn.js";import{u as fe,P as be,a as Se}from"./useBoardConfig-Ce0hVxtU.js";import{P as we}from"./index-Dq8xrBOI.js";import{M as Ne}from"./index-BH6iPLZy.js";import"./search-NhYI7xr8.js";const Ce=({boardNo:e,searchParams:r,options:i})=>ee({queryKey:I.list(e,r),queryFn:async()=>{const{data:o}=await E.getArticleList(e,r);return o},placeholderData:A,enabled:e!=="",...i}),U=n(te)(["width:calc(100% + 40px);margin-left:-20px;padding:8px 20px;margin-top:-8px;position:sticky;top:var(--header-top);left:0;background-color:",";z-index:6;","{margin-top:-8px;}"],s.white,l.SM),Y=n(re)(["display:flex;width:auto;"]);U.displayName="SwiperWrapper";Y.displayName="SwiperSlide";const je=n(q)(["border:1px solid ",";color:",";padding:0 10px;height:30px;white-space:nowrap;",";","{",";height:37px;padding:0 15px;}"],({$isSelected:e})=>e?s.primary:s.gray,({$isSelected:e})=>e?s.primary:s.darkGray,c(12),l.SM,c(14)),T={CategorySwiper:U,CategorySwiperSlide:Y,CategoryButton:je},Te=({categories:e,onClickCategory:r,isAllButtonVisible:i=!0,selectedCategoryParamName:o="categoryNo",allButtonLabel:d="전체"})=>{const[m,y]=K(),h=m.get(o)??"",x={slidesPerView:"auto",spaceBetween:10,centerInsufficientSlides:!0,watchOverflow:!0,breakpoints:{[ne.SM+1]:{spaceBetween:16}}},b=p=>{if(r){r(p);return}y(p?{[o]:p.toString()}:{},{replace:!0})};return ae(e)?null:t.jsxs(T.CategorySwiper,{...x,children:[i&&t.jsx(T.CategorySwiperSlide,{children:t.jsx(T.CategoryButton,{onClick:()=>b(),$isSelected:!h,children:d})}),e.map(p=>t.jsx(T.CategorySwiperSlide,{children:t.jsx(T.CategoryButton,{onClick:()=>b(p.categoryNo),$isSelected:h===p.categoryNo.toString(),children:p.label})},p.categoryNo))]})},Be=n(q)(["color:",";background-color:",";border:1px solid ",";&:disabled{background-color:",";border:1px solid ",";}"],s.primary,s.white,s.primary,s.darkGray,s.darkGray),ke={TertiaryButton:Be},Me=({children:e,...r})=>t.jsx(ke.TertiaryButton,{...r,children:e}),ve=({boardNo:e,searchParams:r,options:i})=>se({queryKey:I.infiniteList(e,r),queryFn:async({pageParam:o})=>{const{data:d}=await E.getArticleList(e,{...r,pageNumber:o});return{data:d,pageNumber:o}},initialPageParam:1,getNextPageParam:(o,d)=>{if(r.pageSize)return d.length*r.pageSize>=o.data.totalCount?void 0:o.pageNumber+1},placeholderData:A,...i}),Pe=({boardNo:e,options:r})=>ie({queryKey:I.category(e),queryFn:async()=>{const{data:i}=await E.getCategories(e);return i},staleTime:1e3*60*100,gcTime:1e3*60*100,...r}),Le=n.article(["width:100%;margin:0 auto;padding:20px 20px 0;","{padding:0;}"],l.SM);n.div(["display:flex;align-items:center;justify-content:space-between;gap:12px;padding:30px 0;","{padding:50px 0 30px;justify-content:center;gap:16px;}"],l.SM);const Ie=n.h1(["flex-shrink:0;margin:30px 0;"," "," text-align:center;","{margin:50px 0;","}"],c(16),G.extraBold,l.SM,c(24)),Ee=n.section([""]);n.div(["flex-shrink:0;min-width:80px;svg{flex-shrink:0;}","{min-width:auto;}"],l.SM);const Ge=n.div(["width:100%;"]),Re=n.div(["display:flex;justify-content:space-between;align-items:flex-end;width:100%;border-bottom:2px solid ",";",";padding-bottom:16px;","{}"],s.black,c(16),l.SM);n.div(["display:flex;justify-content:space-between;align-items:center;width:100%;border-bottom:2px solid ",";",";padding-bottom:16px;","{margin-left:0;width:100%;padding:0 0 16px;span{",";}button{height:32px;}}"],s.black,c(16),l.SM,c(14));const We=n.span(["",";b{color:",";}",";b{color:",";}","{",";}"],c(12),s.primary,c(12),s.primary,l.SM,c(14)),De=n.div(["display:flex;flex-direction:column;width:100%;"]);n.ul(["display:grid;grid-template-columns:repeat(2,1fr);grid-column-gap:20px;grid-row-gap:20px;width:100%;padding:20px 0;","{grid-template-columns:repeat(4,1fr);grid-column-gap:40px;grid-row-gap:60px;padding:50px 0;}"],l.SM);n.li(["width:100%;"]);const Oe=n(oe)(["width:100%;min-height:20px;display:flex;justify-content:start;align-items:flex-start;flex-direction:column;gap:10px;padding:16px 0;border-bottom:1px solid ",";color:",";cursor:",";","{justify-content:space-between;flex-direction:row;align-items:center;min-height:70px;padding:0;}"],s.gray,({$isBlind:e})=>e?`${s.gray}`:`${s.black}`,({$isBlind:e})=>e?"default":"pointer",l.SM),$e=n.div(["width:100%;height:auto;display:flex;align-items:center;justify-content:flex-start;flex:1;span{"," "," padding:0;}","{width:fit-content;span{"," padding:0 20px;}}"],c(14),G.regular,l.SM,c(16)),ze=n.div(["width:fit-content;display:flex;align-items:center;height:auto;span{"," "," color:",";margin-right:9px;}","{width:fit-content;span{"," padding:0 20px;margin-right:0;}}"],c(11),G.regular,s.darkGray,l.SM,c(14)),Ae=n.div(["width:100%;display:flex;justify-content:center;"]);n.div(["height:1px;margin-top:100px;visibility:hidden;"]);const qe=n.div(["display:flex;justify-content:flex-end;button{width:fit-content;height:28px;}","{button{height:32px;}}"],l.SM),u={Container:Le,Title:Ie,ContentsContainer:Ee,BoardListContainer:Ge,ListHeader:Re,TotalCount:We,BoardList:De,BoardItem:Oe,BoardTitle:$e,BoardInfo:ze,PagingContainer:Ae,WriteButtonContainer:qe},Ke=(e,r)=>{var m,y;if(!e)return!1;const i=(m=e.authorityConfig)==null?void 0:m.postWriteConfig;if(!i||i.type==="NOT_USED")return!1;const o=!!r,d=i.type;if(d==="ADMIN")return!1;if(d==="ALL")return o?e.memberPostingUsed===!0:e.guestPostingUsed===!0;if(d==="MEMBER_ONLY")return o&&e.memberPostingUsed===!0;if(d==="SPECIFIC_MEMBERS"){if(!o||!r||e.memberPostingUsed!==!0)return!1;const h=i.groupNos||[],x=i.gradeNos||[];if(h.length===0&&x.length===0)return!1;const b=((y=r.memberGroups)==null?void 0:y.map(g=>g.memberGroupNo))||[],p=h.length>0&&h.some(g=>b.includes(g)),B=r.memberGradeNo,f=x.length>0&&B!=null&&x.includes(B);return p||f}return!1},Qe=()=>{var D,O;const{isMobile:e}=de(),{t:r}=ce(),i=le(),{data:o}=pe(),{boardId:d}=ge(),[m,y]=K(),h=m.get("keyword")??"",x=m.get("categoryNo"),b=[{label:"제목",value:"TITLE"},{label:"내용",value:"CONTENT"},{label:"작성자",value:"WRITER"}],p=m.get("searchType")??void 0,B=v.useMemo(()=>{switch(p){case"TITLE":return"TITLE";case"CONTENT":return"CONTENT";case"WRITER":return"WRITER";default:return"TITLE"}},[p]),{data:f}=fe(),g=v.useMemo(()=>f!=null&&f.boardConfigs?f.boardConfigs.find(a=>a.boardId===d):null,[f,d]),S=g!=null&&g.boardNo?g.boardNo.toString():"",{data:P}=Pe({boardNo:S||"0"}),j={pageNumber:Number(m.get("pageNumber")??1),pageSize:Number(m.get("pageSize")??(e?8:12)),hasTotalCount:!0,keyword:h||void 0,categoryNo:x?Number(x):void 0,isNoticed:m.get("isNoticed")==="true"?!0:void 0,searchType:B},{data:w,isLoading:_}=Ce({boardNo:S,searchParams:j,options:{enabled:!!S&&!e}}),{data:N,hasNextPage:R,fetchNextPage:F,isLoading:H}=ve({boardNo:S,searchParams:j,options:{enabled:!!S&&e}}),Q=e?H:_,W=e?(N==null?void 0:N.pages.flatMap(a=>a.data.items))??[]:(w==null?void 0:w.items)??[],V=a=>{y(C=>{if(!a){const k=new URLSearchParams(C);return k.delete("categoryNo"),k.toString()}return{...Object.fromEntries(C.entries()),categoryNo:a.toString()}})},J=v.useCallback(()=>{i({pathname:`/boards/${d}/write`},{state:{categoryNo:j.categoryNo||void 0}})},[i,d]),L=e?((O=(D=N==null?void 0:N.pages[0])==null?void 0:D.data)==null?void 0:O.totalCount)??0:(w==null?void 0:w.totalCount)??0,X=v.useMemo(()=>Ke(g??null,o),[g,o]);return t.jsxs(u.Container,{children:[!e&&t.jsx(u.Title,{children:(g==null?void 0:g.name)||r("게시판")}),P&&P.length>0&&t.jsx(Te,{categories:P,onClickCategory:V,selectedCategoryParamName:"categoryNo",allButtonLabel:"전체"}),t.jsxs(u.ContentsContainer,{children:[t.jsx(Ne,{searchTypeList:b,customKeyInfo:{searchKeyword:"keyword"},placeholder:"궁금하신 내용을 입력해 보세요.",containerStyle:{margin:e?"12px 0 25px":"12px 0 65px",width:"100%",height:e?"38px":"50px",gridTemplateColumns:e?"1fr 2fr":"1fr 4fr"}}),t.jsxs(u.BoardListContainer,{children:[t.jsxs(u.ListHeader,{children:[t.jsx(u.TotalCount,{dangerouslySetInnerHTML:{__html:r("총 {{count}}건",{count:L})}}),X&&t.jsx(u.WriteButtonContainer,{children:t.jsx(Me,{onClick:J,children:r("게시글 작성")})})]}),t.jsx(ue,{isLoading:Q,children:W.length>0?t.jsxs(t.Fragment,{children:[t.jsx(u.BoardList,{children:W.map(a=>{const C=Z=>{if(a.secreted){Z.preventDefault();const $={boardNo:S,articleNo:a.articleNo},z=M=>{i({pathname:`/boards/${d}/${a.articleNo}`},{state:{password:M}})};ye.open(M=>e?t.jsx(be,{...M,boardData:$,onConfirm:z}):t.jsx(Se,{...M,boardData:$,onConfirm:z}))}},k=a.secreted?"#":`/boards/${d}/${a.articleNo}`;return t.jsxs(u.BoardItem,{to:k,onClick:a.secreted?C:void 0,$isBlind:a.displayStatusType==="BLIND",children:[t.jsx(u.BoardTitle,{children:a.displayStatusType==="BLIND"?t.jsx("span",{children:r("블라인드 처리된 게시글 입니다.")}):t.jsx("span",{children:a.title})}),t.jsxs(u.BoardInfo,{children:[t.jsx("span",{children:a.registerName||a.memberId||a.memberNickname}),t.jsx("span",{children:me(a.registerYmdt).format("YYYY.MM.DD")})]})]},a.articleNo)})}),e?t.jsx(he,{handleChange:a=>a&&R&&F(),hasNextPage:R,totalCount:L}):t.jsx(u.PagingContainer,{children:t.jsx(we,{totalCount:L,currentPage:j.pageNumber,pageSize:j.pageSize,onPageClick:a=>{y(C=>({...Object.fromEntries(C),pageNumber:a.toString()}))}})})]}):t.jsx(xe,{text:r("등록된 게시글이 없습니다.")})})]})]})]})};export{Qe as default};