1import{u as _,r as n,bx as O,j as e,ct as Z,cu as $,cv as J,q as ee,I as te,B as se,F as re,cy as ae,a_ as ne,c$ as oe,ck as le}from"./elements-DVh2jUIM.js";import{M as ie}from"./ModernPortalPage-C8UaH3aE.js";import{A as ce}from"./authorization-CE7gncHO.js";import{G as de,p as C,a0 as L,B as A,aX as me,am as ue}from"./index-DeQvL4I7.js";import{M as j}from"./MobileField-CqNLiG0-.js";import{M as fe}from"./MobileTable-3_DrS7X0.js";import"./useAuthorization-D7B2eQha.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";const pe=10,T={},ye={displayName:"nameFilter",phone:"phoneFilter",email:"emailFilter",address:"addressFilter",boardDescription:"groupFilter",roleName:"titleFilter"},R=({associationId:s,boardTypeId:r,search:a,columnFilters:p,page:o=1,pageSize:y=10})=>{const x=p??T;return L({queryKey:["directory",s,r,a,x,o,y],queryFn:()=>A.getDirectory(s,{boardTypeId:r,search:a,page:o,pageSize:y,...x}),enabled:!!s&&r>=1&&r<=3})},he=s=>L({queryKey:["directoryTypes",s],queryFn:()=>{if(s===void 0)throw new Error("Association ID is required");return A.getDirectoryTypes(s)},enabled:s!==void 0,staleTime:1e3*60*60}),ge=()=>{const{t:s}=_(),r=de(),[a,p]=n.useState(null),[o,y]=n.useState(""),[x,b]=n.useState(""),[F,E]=n.useState(T),[P,h]=n.useState(0),[D,K]=n.useState(pe),w=n.useRef(null),q=n.useCallback(t=>{w.current=t},[]),{data:c,isLoading:B,error:M}=C(he(r==null?void 0:r.id));n.useEffect(()=>{p(null)},[r==null?void 0:r.id]),n.useEffect(()=>{c&&c.length>0&&a===null&&p(c[0].id)},[c,a]),n.useEffect(()=>{const t=setTimeout(()=>{b(o),h(0)},300);return()=>clearTimeout(t)},[o]),n.useEffect(()=>{var t,l,d,f;y(""),b(""),E(T),h(0),(l=(t=w.current)==null?void 0:t.api)==null||l.setFilterModel(null),(f=(d=w.current)==null?void 0:d.api)==null||f.applyColumnState({defaultState:{sort:null}})},[a]);const{data:i,isFetching:H}=C({...R({associationId:(r==null?void 0:r.id)??0,boardTypeId:a??1,search:x||void 0,columnFilters:F,page:P+1,pageSize:D}),enabled:a!==null&&!!(r!=null&&r.id),placeholderData:me,refetchOnMount:"always",staleTime:0}),z=n.useMemo(()=>(i==null?void 0:i.member)??[],[i]),S=(i==null?void 0:i.lastPage)??0,G=(i==null?void 0:i.totalItems)??0,Q=t=>{t.key==="Enter"&&(t.preventDefault(),b(o),h(0))},U=()=>{b(o),h(0)},V=n.useCallback(t=>{var f;const l=t.api.getFilterModel(),d={};for(const[m,v]of Object.entries(ye)){const u=(f=l[m])==null?void 0:f.filter,g=typeof u=="string"?u.trim():"";g.length>0&&(d[v]=g)}E(m=>{const v=Object.keys(m),u=Object.keys(d);return v.length===u.length&&u.every(k=>m[k]===d[k])?m:(h(0),d)})},[]),N=a===3,Y=n.useMemo(()=>({filter:"agTextColumnFilter",floatingFilter:!0,suppressHeaderMenuButton:!0,sortable:!0,filterParams:{filterOptions:["contains"],maxNumConditions:1,buttons:["reset"],debounceMs:300,textMatcher:()=>!0}}),[]),W=n.useMemo(()=>[{field:"displayName",headerName:s("main.directory.columns.name")},...N?[{field:"address",headerName:s("main.directory.columns.address")}]:[],{field:"phone",headerName:s("main.directory.columns.phone"),valueFormatter:({value:t})=>O(t)},{field:"email",headerName:s("main.directory.columns.email")},...N?[]:[{field:"boardDescription",headerName:s("main.directory.columns.group")},{field:"roleName",headerName:s("main.directory.columns.title")}]],[N,s]),X=t=>{p(t)};if(B)return e.jsx("div",{className:"w-full px-6 py-4 bg-base-fill rounded-xl",children:e.jsx("div",{className:"flex items-center justify-center p-8",children:s("main.common.loading")})});if(M||!c||c.length===0)return e.jsx("div",{className:"w-full px-6 py-4 bg-base-fill rounded-xl",children:e.jsx("div",{className:"flex items-center justify-center p-8 text-error",children:M?s("main.common.error")||"Error loading directory tabs":s("main.common.noResults")||"No directory types available"})});const I=c.findIndex(t=>t.id===a);return e.jsxs("div",{className:"w-full px-6 py-4 bg-base-fill rounded-xl",children:[e.jsx(Z,{selectedIndex:I>=0?I:0,onChange:t=>{const l=c[t];l&&X(l.id)},className:"mb-6 w-full border-b-2",children:e.jsx($,{children:c.map(t=>e.jsx(J,{as:"button",className:({selected:l})=>ee("px-6 py-2 font-semibold text-input-fg focus:outline-none","hover:border-b-2 hover:border-base-link hover:text-base-link",l&&"border-b-2 border-base-link text-base-link"),children:t.name},t.id))})}),e.jsxs("div",{className:"w-full h-full",children:[e.jsxs("div",{className:"max-mobile:hidden",children:[e.jsxs("div",{className:"mb-4 items-center justify-end gap-2 flex",children:[e.jsx(te,{type:"text",placeholder:s("main.common.search"),className:"w-full mobile:w-96",value:o,onChange:t=>y(t.target.value),onKeyDown:Q}),e.jsx(se,{variant:"primary",onClick:U,className:"h-9",children:e.jsx(re,{icon:ae,className:"text-white"})})]}),e.jsx(ne,{rowData:z,columnDefs:W,defaultColDef:Y,onFilterChanged:V,getGridRef:q,pagination:!1,enableExport:!1,loading:H,overlayNoRowsTemplate:s("main.common.noResults")}),S>0&&e.jsxs("div",{className:"ag-theme-alpine flex justify-between items-center gap-2 flex-wrap py-4",children:[e.jsx(oe,{onChangePageSize:t=>{K(t),h(0)},currentPage:P,paginationPageSize:D,totalPages:S,totalCount:G}),e.jsx(le,{numberOfPages:S,currentPage:P,onChangePage:h})]})]}),e.jsx("div",{className:"mobile:hidden",children:e.jsx(fe,{renderItem:t=>
1e.jsx(xe,{item:t,isHomeownersDirectory:N}),serverSide:{useQueryHook:({search:t,page:l,pageSize:d,sortDirection:f})=>C({...R({associationId:(r==null?void 0:r.id)||0,boardTypeId:a||1,search:t,page:l,pageSize:d}),select:({member:m,lastPage:v})=>({items:f==="asc"?[...m].sort((u,g)=>u.displayName.localeCompare(g.displayName)):f==="desc"?[...m].sort((u,g)=>g.displayName.localeCompare(u.displayName)):m||[],totalPages:v||0})})}})})]})]})},xe=({item:s,isHomeownersDirectory:r})=>{const{t:a}=_(),{displayName:p,phone:o,email:y,boardDescription:x,roleName:b,address:F}=s;return e.jsxs("div",{className:"p-3 w-full rounded-md border border-base-border flex flex-col gap-2 text-sm",children:[e.jsx(j,{field:a("main.directory.columns.name"),value:p}),e.jsx(j,{field:a("main.directory.columns.phone"),value:o?O(o):""}),e.jsx(j,{field:a("main.directory.columns.email"),value:y||""}),r?e.jsx(j,{field:a("main.directory.columns.address"),value:F||""}):e.jsxs(e.Fragment,{children:[e.jsx(j,{field:a("main.directory.columns.group"),value:x||""}),e.jsx(j,{field:a("main.directory.columns.title"),value:b||""})]})]})},Ee={title:"Community Directory",showPropertySelector:!0,redesignPage:"directoryPage",redesignHandle:{customContentId:["Directory","Homeowner_v2"]},showAi:!0};function De(){const s=ue("directoryPage");return e.jsx(ce,{controller:"Homeowner_v2",action:"Directory",children:s?e.jsx(ge,{}):e.jsx(ie,{action:"Directory"})})}export{De as Component,Ee as handle};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.