import{J as ee,_ as A,bK as P,bL as E,m as o,t as g,v as c,n as d,bM as te,bN as ne,aL as ae,h as K,z as oe,j as t,bO as ie,a0 as re,x as se,p as D,L as de,G as ce,k as pe,u as le,a3 as ge,ar as ue,r as k,y as z,a6 as me,a8 as he,a9 as xe,N as fe,aa as ye}from"./index-6o6UQuBv.js";import{u as we,P as Ce,a as Se}from"./useBoardConfig-B3Iz3qvh.js";import{T as be}from"./index-BLTRYsWo.js";import{M as Ne}from"./index-93wKImOf.js";const Ie=({boardNo:e,searchParams:a,options:i})=>ee({queryKey:P.list(e,a),queryFn:async()=>{const{data:r}=await E.getArticleList(e,a);return r},placeholderData:A,enabled:e!=="",...i}),q=o(te).withConfig({componentId:"sc-c6ac0220-0"})(["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;}"],g.white,c.SM),U=o(ne).withConfig({componentId:"sc-c6ac0220-1"})(["display:flex;width:auto;"]);q.displayName="SwiperWrapper";U.displayName="SwiperSlide";const je=o(ae).withConfig({componentId:"sc-c6ac0220-2"})(["border:1px solid ",";color:",";padding:0 10px;height:30px;white-space:nowrap;",";","{",";height:37px;padding:0 15px;}"],({$isSelected:e})=>e?g.primary:g.gray,({$isSelected:e})=>e?g.primary:g.darkGray,d(12),c.SM,d(14)),j={CategorySwiper:q,CategorySwiperSlide:U,CategoryButton:je},Te=({categories:e,onClickCategory:a,isAllButtonVisible:i=!0,selectedCategoryParamName:r="categoryNo",allButtonLabel:s="전체"})=>{const[m,f]=K(),h=m.get(r)??"",x={slidesPerView:"auto",spaceBetween:10,centerInsufficientSlides:!0,watchOverflow:!0,breakpoints:{[ie.SM]:{spaceBetween:16}}},w=p=>{if(a){a(p);return}f(p?{[r]:p.toString()}:{},{replace:!0})};return oe(e)?null:t.jsxs(j.CategorySwiper,{...x,children:[i&&t.jsx(j.CategorySwiperSlide,{children:t.jsx(j.CategoryButton,{onClick:()=>w(),$isSelected:!h,children:s})}),e.map(p=>t.jsx(j.CategorySwiperSlide,{children:t.jsx(j.CategoryButton,{onClick:()=>w(p.categoryNo),$isSelected:h===p.categoryNo.toString(),children:p.label})},p.categoryNo))]})},Me=({boardNo:e,searchParams:a,options:i})=>re({queryKey:P.infiniteList(e,a),queryFn:async({pageParam:r})=>{const{data:s}=await E.getArticleList(e,{...a,pageNumber:r});return{data:s,pageNumber:r}},initialPageParam:1,getNextPageParam:(r,s)=>{if(a.pageSize)return s.length*a.pageSize>=r.data.totalCount?void 0:r.pageNumber+1},placeholderData:A,...i}),Be=({boardNo:e,options:a})=>se({queryKey:P.category(e),queryFn:async()=>{const{data:i}=await E.getCategories(e);return i},staleTime:1e3*60*100,gcTime:1e3*60*100,...a}),ke=o.article.withConfig({componentId:"sc-a695d8e0-0"})(["width:100%;margin:0 auto;padding:20px 20px 0;","{padding:0;}"],c.SM);o.div.withConfig({componentId:"sc-a695d8e0-1"})(["display:flex;align-items:center;justify-content:space-between;gap:12px;padding:30px 0;","{padding:50px 0 30px;justify-content:center;gap:16px;}"],c.SM);const Le=o.h1.withConfig({componentId:"sc-a695d8e0-2"})(["flex-shrink:0;margin:30px 0;"," "," text-align:center;","{margin:50px 0;","}"],d(16),D.extraBold,c.SM,d(24)),ve=o.section.withConfig({componentId:"sc-a695d8e0-3"})([""]);o.div.withConfig({componentId:"sc-a695d8e0-4"})(["flex-shrink:0;min-width:80px;svg{flex-shrink:0;}","{min-width:auto;}"],c.SM);const Pe=o.div.withConfig({componentId:"sc-a695d8e0-5"})(["width:100%;"]),Ee=o.div.withConfig({componentId:"sc-a695d8e0-6"})(["display:flex;justify-content:space-between;align-items:flex-end;width:100%;border-bottom:2px solid ",";",";padding-bottom:16px;","{}"],g.black,d(16),c.SM);o.div.withConfig({componentId:"sc-a695d8e0-7"})(["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;}}"],g.black,d(16),c.SM,d(14));const De=o.span.withConfig({componentId:"sc-a695d8e0-8"})(["",";b{color:",";}",";b{color:",";}","{",";}"],d(12),g.primary,d(12),g.primary,c.SM,d(14)),Re=o.div.withConfig({componentId:"sc-a695d8e0-9"})(["display:flex;flex-direction:column;width:100%;"]);o.ul.withConfig({componentId:"sc-a695d8e0-10"})(["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;}"],c.SM);o.li.withConfig({componentId:"sc-a695d8e0-11"})(["width:100%;"]);const We=o(de).withConfig({componentId:"sc-a695d8e0-12"})(["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;}"],g.gray,({$isBlind:e})=>e?`${g.gray}`:`${g.black}`,({$isBlind:e})=>e?"default":"pointer",c.SM),Ge=o.div.withConfig({componentId:"sc-a695d8e0-13"})(["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;}}"],d(14),D.regular,c.SM,d(16)),Ye=o.div.withConfig({componentId:"sc-a695d8e0-14"})(["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;}}"],d(11),D.regular,g.darkGray,c.SM,d(14)),Oe=o.div.withConfig({componentId:"sc-a695d8e0-15"})(["width:100%;display:flex;justify-content:center;"]);o.div.withConfig({componentId:"sc-a695d8e0-16"})(["height:1px;margin-top:100px;visibility:hidden;"]);const $e=o.div.withConfig({componentId:"sc-a695d8e0-17"})(["display:flex;justify-content:flex-end;button{width:fit-content;height:28px;}","{button{height:32px;}}"],c.SM),u={Container:ke,Title:Le,ContentsContainer:ve,BoardListContainer:Pe,ListHeader:Ee,TotalCount:De,BoardList:Re,BoardItem:We,BoardTitle:Ge,BoardInfo:Ye,PagingContainer:Oe,WriteButtonContainer:$e},ze=(e,a)=>{var m,f;if(!e)return!1;const i=(m=e.authorityConfig)==null?void 0:m.postWriteConfig;if(!i||i.type==="NOT_USED")return!1;const r=!!a,s=i.type;if(s==="ADMIN")return!1;if(s==="ALL")return r?e.memberPostingUsed===!0:e.guestPostingUsed===!0;if(s==="MEMBER_ONLY")return r&&e.memberPostingUsed===!0;if(s==="SPECIFIC_MEMBERS"){if(!r||!a||e.memberPostingUsed!==!0)return!1;const h=i.groupNos||[],x=i.gradeNos||[];if(h.length===0&&x.length===0)return!1;const w=((f=a.memberGroups)==null?void 0:f.map(l=>l.memberGroupNo))||[],p=h.length>0&&h.some(l=>w.includes(l)),T=a.memberGradeNo,y=x.length>0&&T!=null&&x.includes(T);return p||y}return!1},_e=()=>{var G,Y;const{isMobile:e}=ce(),{t:a}=pe(),i=le(),{data:r}=ge(),{boardId:s}=ue(),[m,f]=K(),h=m.get("keyword")??"",x=m.get("categoryNo"),w=[{label:"제목",value:"TITLE"},{label:"내용",value:"CONTENT"},{label:"작성자",value:"WRITER"}],p=m.get("searchType")??void 0,T=k.useMemo(()=>{switch(p){case"TITLE":return"TITLE";case"CONTENT":return"CONTENT";case"WRITER":return"WRITER";default:return"TITLE"}},[p]),{data:y}=we(),l=k.useMemo(()=>y!=null&&y.boardConfigs?y.boardConfigs.find(n=>n.boardId===s):null,[y,s]),C=l!=null&&l.boardNo?l.boardNo.toString():"",{data:L}=Be({boardNo:C||"0"}),I={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:T,startYmd:"2021-01-01",endYmd:z().format("YYYY-MM-DD")},{data:S,isLoading:_}=Ie({boardNo:C,searchParams:I,options:{enabled:!!C&&!e}}),{data:b,hasNextPage:R,fetchNextPage:F,isLoading:H}=Me({boardNo:C,searchParams:I,options:{enabled:!!C&&e}}),Q=e?H:_,W=e?(b==null?void 0:b.pages.flatMap(n=>n.data.items))??[]:(S==null?void 0:S.items)??[],J=n=>{f(N=>{if(!n){const M=new URLSearchParams(N);return M.delete("categoryNo"),M.toString()}return{...Object.fromEntries(N.entries()),categoryNo:n.toString()}})},V=k.useCallback(()=>{i({pathname:`/boards/${s}/write`},{state:{categoryNo:I.categoryNo||void 0}})},[i,s]),v=e?((Y=(G=b==null?void 0:b.pages[0])==null?void 0:G.data)==null?void 0:Y.totalCount)??0:(S==null?void 0:S.totalCount)??0,X=k.useMemo(()=>ze(l??null,r),[l,r]);return t.jsxs(u.Container,{children:[!e&&t.jsx(u.Title,{children:(l==null?void 0:l.name)||a("게시판")}),L&&L.length>0&&t.jsx(Te,{categories:L,onClickCategory:J,selectedCategoryParamName:"categoryNo",allButtonLabel:"전체"}),t.jsxs(u.ContentsContainer,{children:[t.jsx(Ne,{searchTypeList:w,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:a("총 {{count}}건",{count:v})}}),X&&t.jsx(u.WriteButtonContainer,{children:t.jsx(be,{onClick:V,children:a("게시글 작성")})})]}),t.jsx(me,{isLoading:Q,children:W.length>0?t.jsxs(t.Fragment,{children:[t.jsx(u.BoardList,{children:W.map(n=>{const N=Z=>{if(n.secreted){Z.preventDefault();const O={boardNo:C,articleNo:n.articleNo},$=B=>{i({pathname:`/boards/${s}/${n.articleNo}`},{state:{password:B}})};ye.open(B=>e?t.jsx(Ce,{...B,boardData:O,onConfirm:$}):t.jsx(Se,{...B,boardData:O,onConfirm:$}))}},M=n.secreted?"#":`/boards/${s}/${n.articleNo}`;return t.jsxs(u.BoardItem,{to:M,onClick:n.secreted?N:void 0,$isBlind:n.displayStatusType==="BLIND",children:[t.jsx(u.BoardTitle,{children:n.displayStatusType==="BLIND"?t.jsx("span",{children:a("블라인드 처리된 게시글 입니다.")}):t.jsx("span",{children:n.title})}),t.jsxs(u.BoardInfo,{children:[t.jsx("span",{children:n.registerName||n.memberId||n.memberNickname}),t.jsx("span",{children:z(n.registerYmdt).format("YYYY.MM.DD")})]})]},n.articleNo)})}),e?t.jsx(he,{handleChange:n=>n&&R&&F(),hasNextPage:R,totalCount:v}):t.jsx(u.PagingContainer,{children:t.jsx(xe,{totalCount:v,currentPage:I.pageNumber,pageSize:I.pageSize,onPageClick:n=>{f(N=>({...Object.fromEntries(N),pageNumber:n.toString()}))}})})]}):t.jsx(fe,{text:a("등록된 게시글이 없습니다.")})})]})]})]})};export{_e as default};