1import{k as le,i as Zs,x as Ys,c as Js,r as h,j as e,y as A,L as Rs,t as k}from"./index-BtfH9wlj.js";import{B as m}from"./button-BOklcLP3.js";import{C as o,b,c as _,a as d}from"./card-DyZSDQ4d.js";import{B as S}from"./badge-aVCiQrRq.js";import{I as M}from"./input-BwcwB3Vl.js";import{L as x}from"./label-CIY4XlA3.js";import{T as $}from"./textarea-DdnFK6Er.js";import{C as Ps}from"./chart-column-B4i5mocx.js";import{B as ke}from"./building-2-Cm-JVYvo.js";import{T as qs}from"./triangle-alert-1fURXd3p.js";import{S as Me}from"./shield-check-B65fESfa.js";import{B as Se}from"./badge-check-Bld9CK8A.js";import{R as Re}from"./refresh-cw-_wRVqFRq.js";import{C as Xs}from"./credit-card-BAsheTHV.js";import{L as et}from"./layers-CuorFfHi.js";import{H as Is}from"./heart-pulse-B6TVhfGF.js";import{L as O}from"./loader-circle-DYPCNajK.js";import{C as st}from"./clipboard-check-D4utrNe2.js";import{S as ye}from"./search-DoCPjxsx.js";import{C as tt}from"./circle-check-DTl_RLyx.js";import{W as it}from"./wand-sparkles-BiTv8IYB.js";import{E as rt}from"./external-link-rfVmg7Xy.js";import"./index-F-KguS3Q.js";import"./index-CYtkBTWk.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const at=[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Pe=le("CopyCheck",at);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const nt=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]],lt=le("DatabaseBackup",nt);/** 12 * @license lucide-react v0.475.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ct=[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]],ot=le("FileClock",ct);/** 17 * @license lucide-react v0.475.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const dt=[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]],ne=le("MailPlus",dt);/** 22 * @license lucide-react v0.475.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const mt=[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]],As=le("UserRoundSearch",mt),c=r=>String(r||"").replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),E=r=>r?new Date(r).toLocaleDateString():"â",pt=r=>new Promise(n=>window.setTimeout(n,r)),ht=r=>{var n,l,w,p,f,D;return String(((l=(n=r==null?void 0:r.response)==null?void 0:n.data)==null?void 0:l.error)||((p=(w=r==null?void 0:r.response)==null?void 0:w.data)==null?void 0:p.message)||((f=r==null?void 0:r.data)==null?void 0:f.error)||((D=r==null?void 0:r.body)==null?void 0:D.error)||(r==null?void 0:r.message)||"").toLowerCase().includes("jwt issued at future")},xt=async()=>{const r=[0,1e3,2e3,4e3];let n;for(let l=0;l<r.length;l++){r[l]&&await pt(r[l]);try{return await k.functions.invoke("getMembershipOperations",{})}catch(w){if(n=w,!ht(w)||l===r.length-1)throw w}}throw n},Ne=r=>r==="critical"||r==="urgent"?"border-red-300 bg-red-50 text-red-800":r==="high"?"border-orange-300 bg-orange-50 text-orange-800":r==="warning"?"border-amber-300 bg-amber-50 text-amber-800":"border-slate-200 bg-white text-slate-700",ut=r=>r==="critical"?"bg-red-100 text-red-800":r==="at_risk"?"bg-orange-100 text-orange-800":r==="watch"?"bg-amber-100 text-amber-800":"bg-green-100 text-green-800",we=[["composition","80/2
260 & Policy",Ps],["partners","Partner Presentations",ke],["actions","Needs Action",qs],["health","Data Health",Me],["credentials","Credentials",Se],["renewals","Renewals",Re],["requests","Requests",ne],["payments","Membership Payments",Xs],["member360","Member 360",As],["organizations","Organizations",ke],["reports","Reports",Ps],["segments","Segments",et],["duplicates","Duplicates",Pe],["retention","Retention",Is],["backup","Backup",lt]];function Ht(){var Ze,Ye,Je,Xe,es,ss,ts,is,rs,as,ns,ls,cs,os,ds,ms,ps,hs,xs,us,js,fs,vs,gs,bs,_s,ys,Ns,ws,Cs;const{toast:r}=Zs(),n=Ys(),[l,w]=Js(),p=l.get("tab")||"actions",[f,D]=h.useState(we.some(([s])=>s===p)?p:"actions"),[t,ce]=h.useState(null),[G,J]=h.useState(!0),[X,ee]=h.useState(""),[v,ue]=h.useState(""),[g,u]=h.useState(""),[y,z]=h.useState(null),[qe,Ie]=h.useState({}),[se,Ae]=h.useState(null),[H,U]=h.useState({application_id:"",request_type:"credential",title:"Current credential requested",instructions:""}),[ze,oe]=h.useState(""),[Ee,te]=h.useState([]),[Le,Te]=h.useState(!1),[$e,zs]=h.useState(""),[de,je]=h.useState(null),[Oe,De]=h.useState(!1),[me,fe]=h.useState({name:"",organization_type:"travel_agency"}),[K,pe]=h.useState({organization_id:"",application_id:"",role_type:"advisor"}),[T,ie]=h.useState({name:"",search:"",application_type:"",state:""}),[he,Es]=h.useState(null),[I,xe]=h.useState({groupId:"",primary:"",secondary:"",preview:null,confirm:""}),[F,re]=h.useState({confirm:"",effective_date:"",authorization_note:"",governance_note:""}),[C,L]=h.useState(null),[Fe,Ls]=h.useState(null),ve=h.useRef(!1),ge=h.useRef(!1),Be=h.useRef(f),He=h.useRef(null),R=async(s=!1)=>{var i,a,j,P,ae,ks,Ms;if(ve.current){ge.current=!0;return}ve.current=!0,s||J(!0),s||ee("");try{const N=await xt(),Y=(N==null?void 0:N.data)||{};if(Y.error)throw new Error(Y.error);ce(Y),Ls(new Date)}catch(N){if(!s){const Y=((a=(i=N==null?void 0:N.response)==null?void 0:i.data)==null?void 0:a.error)||((P=(j=N==null?void 0:N.response)==null?void 0:j.data)==null?void 0:P.message)||((ae=N==null?void 0:N.data)==null?void 0:ae.error)||((ks=N==null?void 0:N.body)==null?void 0:ks.error)||"",Ss=Y?`${N.message} â server said: ${Y}`:`${N.message} â no server detail available (status ${((Ms=N==null?void 0:N.response)==null?void 0:Ms.status)||(N==null?void 0:N.status)||"unknown"})`;ee(Ss),r({title:"Membership operations could not load",description:Ss,variant:"destructive"})}}finally{ve.current=!1,s||J(!1),ge.current&&(ge.current=!1,window.setTimeout(()=>R(!0),0))}},Ts=async()=>{var i,a;const s=(a=(i=He.current)==null?void 0:i.anchor)==null?void 0:a.id;if(!(Be.current!=="member360"||!s))try{const j=await k.functions.invoke("getMember360",{application_id:s}),P=(j==null?void 0:j.data)||{};P.error||je(P)}catch{}};h.useEffect(()=>{Be.current=f},[f]),h.useEffect(()=>{He.current=de},[de]),h.useEffect(()=>{R(!1);const s=()=>{R(!0),Ts()},i=window.setInterval(s,3e4),a=()=>s(),j=()=>{document.visibilityState==="visible"&&s()};return window.addEventListener("focus",a),document.addEventListener("visibilitychange",j),()=>{window.clearInterval(i),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",j)}},[]),h.useEffect(()=>{we.some(([s])=>s===p)&&D(p)},[p]);const Q=s=>{D(s),w(i=>(i.set("tab",s),i))},V=v.trim().toLowerCase(),Z=s=>!V||[s.name,s.email,s.company,s.membership_number,s.reason,s.issue,s.credential_type,s.request_title,s.agency_name].filter(Boolean).join(" ").toLowerCase().includes(V),Ue=h.useMemo(()=>{var s;return((s=t==null?void 0:t.actions)==null?void 0:s.filter(Z))||[]},[t,V]),Ve=h.useMemo(()=>{var s;return((s=t==null?void 0:t.health)==null?void 0:s.filter(Z))||[]},[t,V]),We=h.useMemo(()=>{var s;return((s=t==null?void 0:t.credentials)==null?void 0:s.filter(Z))||[]},[t,V]),$s=async()=>{var s;if(y!=null&&y.application_id){u("case");try{const i=await k.functions.invoke("manageMembershipCase",{application_id:y.application_id,updates:{assigned_staff_id:y.assigned_staff_id||"",assigned_staff_name:y.assigned_staff_name||"",priority:y.priority||"normal",due_at:y.due_at||"",next_action:y.next_action||"",case_status:y.case_status||"open",cancellation_reason:y.cancellation_reason||"",cancellation_notes:y.cancellation_notes||"",lapse_reason:y.lapse_reason||"",staff_notes:y.staff_notes||""}});if((s=i==null?void 0:i.data)!=null&&s.error)throw new Error(i.data.error);r({title:"Membership case updated"}),z(null),await R(!0)}catch(i){r({title:"Save failed",description:i.message,variant:"destructive"})}finally{u("")}}}
26,Os=async s=>{u(s.id);try{const i=await k.functions.invoke("repairMembershipHealthIssue",{application_id:s.application_id,code:s.code}),a=(i==null?void 0:i.data)||{};if(a.error)throw new Error(a.error);r({title:a.fixed?"Issue repaired":"Review still required",description:a.message}),await R(!0)}catch(i){r({title:"Repair failed",description:i.message,variant:"destructive"})}finally{u("")}},be=async(s,i)=>{u(s.id);try{const a=await k.functions.invoke("reviewMembershipCredential",{application_id:s.application_id,validation_id:s.validation_id||"",credential_index:s.credential_index,decision:i,notes:qe[s.id]||""}),j=(a==null?void 0:a.data)||{};if(j.error)throw new Error(j.error);r({title:`Credential ${c(i)}`}),Ie(P=>{const ae={...P};return delete ae[s.id],ae}),await R(!0)}catch(a){r({title:"Credential review failed",description:a.message,variant:"destructive"})}finally{u("")}},Ds=async()=>{u("renewal-preview");try{const s=await k.functions.invoke("processMembershipRenewals",{mode:"preview"}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);Ae(i),r({title:"Renewal reminder preview ready",description:`${i.count||0} reminder(s) are currently due.`})}catch(s){r({title:"Preview failed",description:s.message,variant:"destructive"})}finally{u("")}},Fs=async()=>{if(se){u("renewal-send");try{const s=await k.functions.invoke("processMembershipRenewals",{mode:"send_due"}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:"Renewal reminders processed",description:`${i.sent||0} sent · ${i.failed||0} failed.`}),Ae(null),await R(!0)}catch(s){r({title:"Renewal send failed",description:s.message,variant:"destructive"})}finally{u("")}}},Ge=async()=>{const s=ze.trim();if(s){Te(!0);try{const i=await k.functions.invoke("getMembershipQueue",{view:"applications",search:s,sub_filter:"all",page:1,page_size:10}),a=(i==null?void 0:i.data)||{};if(a.error)throw new Error(a.error);te(a.applications||[])}catch(i){r({title:"Member search failed",description:i.message,variant:"destructive"})}finally{Te(!1)}}},Bs=async()=>{u("request");try{const s=await k.functions.invoke("manageMembershipDocumentRequest",{action:"create",...H}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:i.sent?"Secure request sent":"Request created",description:i.sent?"The member received a secure 14-day link.":"The request was saved but email delivery failed."}),U({application_id:"",request_type:"credential",title:"Current credential requested",instructions:""}),oe(""),te([]),await R(!0)}catch(s){r({title:"Request failed",description:s.message,variant:"destructive"})}finally{u("")}},Hs=async s=>{var i;u(s);try{const a=await k.functions.invoke("manageMembershipDocumentRequest",{action:"complete",request_id:s,note:"Reviewed and completed by Membership."});if((i=a==null?void 0:a.data)!=null&&i.error)throw new Error(a.data.error);r({title:"Request completed"}),await R(!0)}catch(a){r({title:"Could not complete request",description:a.message,variant:"destructive"})}finally{u("")}},B=async(s=$e)=>{const i=String(s||"").trim();if(i){De(!0),je(null);try{const a=i.includes("@")?{email:i}:i.toUpperCase().startsWith("TIA-")?{membership_number:i}:{application_id:i},j=await k.functions.invoke("getMember360",a),P=(j==null?void 0:j.data)||{};if(P.error)throw new Error(P.error);je(P),Q("member360")}catch(a){r({title:"Member not found",description:a.message,variant:"destructive"})}finally{De(!1)}}},Us=async()=>{u("org");try{const s=await k.functions.invoke("manageMembershipOrganization",{action:"create",organization:me}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:"Organization created"}),fe({name:"",organization_type:"travel_agency"}),await R(!0)}catch(s){r({title:"Organization creation failed",description:s.message,variant:"destructive"})}finally{u("")}},Vs=async()=>{u("org-link");try{const s=await k.functions.invoke("manageMembershipOrganization",{action:"link_member",...K}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:"Member linked to organization"}),pe(a=>({...a,application_id:""})),await R(!0)}catch(s){r({title:"Link failed",description:s.message,variant:"destructive"})}finally{u("")}},Ws=async()=>{u("segment");try{const s={search:T.search||"",application_type:T.application_type||"",state:T.state||""},i=await k.functions.invoke("manageMembershipSegment",{action:"create",name:T.name,filters:s}),a=(i==null?void 0:i.data)||{};if(a.error)throw new Error(a.error);r({title:"Saved segment created"}),ie({name:"",search:"",application_type:"",state:""}),await R(!0)}catch(s){r({title:"Segment save failed",description:s.message,variant:"destructive"})}finally{u("")}},Gs=async s=>{u(s.id);try{const i=await k.functions.invoke("manageMembershipSegment",{action:"run",segment_id:s.id,filters:s.filters||{}}),a=(i==null?void 0:i.data)||{};if(a.error)throw new Error(a.error);Es({name:s.name,...a})}catch(i){r({title:"Segment failed",description:i.message,variant:"destructive"})}finally{u("")}},Ke=async(s,i,a)=>{u("merge-preview");try{const j=await k.functions.invoke("mergeMembershipRecords",{action:"preview",primary_application_id:i,duplicate_application_id:a}),P=(j==null?void 0:j.data)||{};if(P.error)throw new Error(P.error);xe({groupId:s.id,primary:i,secondary:a,preview:P.preview,confirm:""})}catch(j){r({title:"Merge preview failed",description:j.message,variant:"destructive"})}finally{u("")}},Ks=async()=>{u("merge");try{const s=await k.functions.invoke("mergeMembershipRecords",{action:"merge",primary_application_id:I.primary,duplicate_application_id:I.secondary,confirm:I.confirm}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:"Duplicate identity merged",description:"All annual application/history records were preserved."}),xe({groupId:"",primary:"",secondary:"",preview:null,confirm:""}),await R(!0)}catch(s){r({title:"Merge failed",description:s.message,variant:"destructive"})}finally{u("")}},Qs=async()=>{u("policy");try{const s=await k.functions.invoke("manageMembershipGovernancePolicy",{action:"activate_presentation_model",...F,presentation_required_per_cycle:1,presentation_requirement_text:"Each Industry Partner/vendor member must provide one TIA presentation during each paid membership cycle."}),i=(s==null?void 0:s.data)||{};if(i.error)throw new Error(i.error);r({title:"Membership governance policy changed",description:"The presentation-based Industry Partner model is now effective from the recorded date."}),re({confirm:"",effective_date:"",authorization_note:"",governance_note:""}),await R(!0)}catch(s){r({title:"Policy was not changed",description:s.message,variant:"destructive"})}finally{u("")}},_e=async s=>{if(C!=null&&C.id){u("presentation");try{const i={action:s,commitment_id:C.id,scheduled_date:C.scheduled_date||"",completed_date:C.completed_date||"",presentation_title:C.presentation_title||"",presentation_description:C.presentation_description||"",presentation_format:C.presentation_format||"other",admin_notes:C.admin_notes||"",waive_reason:C.waive_reason||""},a=await k.functions.invoke("manageIndustryPartnerPresentation",i),j=(a==null?void 0:a.data)||{};if(j.error)throw new Error(j.error);r({title:s==="complete"?"Presentation marked completed":s==="waive"?"Presentation requirement waived":"Presentation scheduled"}),L(null),await R(!0)}catch(i){r({title:"Presentation update failed",description:i.message,variant:"destructive"})}finally{u("")}}},Qe=async(s,i)=>{u(`class:${s.id}`);try{const a=await k.functions.invoke("resolveMembershipClassification",{application_id:s.id,classification:i,note:`Reviewed against the preserved legacy membership category (${c(s.category_slug)}) and current application type (${c(s.application_type)}).`}),j=(a==null?void 0:a.data)||{};if(j.error)throw new Error(j.error);r({title:"Membership classification reconciled",description:`${s.name} is now classified as ${c(i)} in both membership fields.`}),await R(!0)}catch(a){r({title:"Classification update failed",description:a.message,variant:"destructive"})}finally{u("")}};return G&&!t?e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-16 flex justify-center",children:e.jsx(O,{className:"w-7 h-7 animate-spin"})}):e.jsxs("div",{className:"max-w-7xl mx-auto px-5 sm:px-6 py-7 space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(st,{className:"w-6 h-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Membership Operations Center"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"One work center for daily membership action, data quality, compliance, renewals, retention, companies, reporting, and member history."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["Auto-refresh on · every 30 sec",Fe?` · Updated ${Fe.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}`:""]}),e.jsxs(m,{variant:"outline",onClick:()=>R(!1),disabled:G,children:[G?e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Re,{className:"w-4 h-4 mr-2"}
26),"Refresh now"]})]})]}),X&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700",children:X}),(t==null?void 0:t.composition)&&e.jsxs(o,{className:t.composition.classification_review_required?"border-amber-400":t.composition.compliant?"border-green-300":"border-red-400",children:[e.jsx(b,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx(_,{className:"text-lg",children:"Membership Composition â Current Bylaws 80/20"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.composition.bylaws_reference})]}),e.jsx(S,{className:t.composition.classification_review_required?"bg-amber-100 text-amber-800":t.composition.compliant?"bg-green-100 text-green-800":"bg-red-100 text-red-800",children:t.composition.classification_review_required?"CLASSIFICATION REVIEW REQUIRED":t.composition.compliant?"COMPLIANT":"NOT COMPLIANT"})]})}),e.jsxs(d,{children:[t.composition.classification_review_required&&e.jsxs("div",{className:"mb-3 rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:[e.jsxs("strong",{children:["The confirmed Industry Partner count is ",t.composition.confirmed_industry_partners,"."]})," Legacy source data still flags ",t.composition.legacy_source_industry_partners," records as Industry Partners, but ",t.composition.industry_partner_review_pending," of those conflict with the current membership classification. There are ",t.composition.classification_review_pending," active records total that still require classification review, so the system is temporarily withholding a final 80/20 compliance determination."]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[e.jsx(q,{label:"Active Members",value:t.composition.total_active,detail:"Current roster"}),e.jsx(q,{label:"Confirmed Travel Advisors",value:t.composition.travel_advisors,detail:`${t.composition.travel_advisor_pct}% of ${t.composition.confirmed_classification_total||0} confirmed classifications`}),e.jsx(q,{label:"Confirmed Industry Partners",value:t.composition.industry_partners,detail:`${t.composition.industry_partner_pct}% of ${t.composition.confirmed_classification_total||0} confirmed classifications`}),e.jsx(q,{label:"Classification Review Pending",value:t.composition.classification_review_pending||0,detail:`${t.composition.classification_conflicts||0} direct conflict(s)`}),e.jsx(q,{label:"Partner Capacity",value:t.composition.additional_industry_partner_capacity??"â",detail:t.composition.classification_review_required?"Pending classification review":"Additional partners allowed today"})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 flex-wrap rounded-md bg-slate-50 border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Future model under discussion â not active"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"If the bylaws are formally amended to remove the percentage cap, Industry Partner/vendor members would be required to provide one TIA presentation during each paid membership cycle."})]}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>Q("composition"),children:"Review Classification & Policy"})]})]})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6",children:[["Needs Action",((Ze=t==null?void 0:t.summary)==null?void 0:Ze.needs_action)||0,qs,"actions"],["Health Issues",((Ye=t==null?void 0:t.summary)==null?void 0:Ye.health_issues)||0,Me,"health"],["Credential Queue",((Je=t==null?void 0:t.summary)==null?void 0:Je.credential_queue)||0,Se,"credentials"],["Renewal Attention",((Xe=t==null?void 0:t.summary)==null?void 0:Xe.renewal_attention)||0,Re,"renewals"],["Duplicate Groups",((es=t==null?void 0:t.summary)==null?void 0:es.duplicate_groups)||0,Pe,"duplicates"],["At Risk",((ss=t==null?void 0:t.summary)==null?void 0:ss.at_risk)||0,Is,"retention"]].map(([s,i,a,j])=>e.jsx("button",{onClick:()=>Q(j),className:"text-left",children:e.jsx(o,{className:"h-full hover:shadow-sm",children:e.jsxs(d,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/10 text-primary p-2",children:e.jsx(a,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:i}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s})]})]})})},j))}),e.jsx("div",{className:"flex flex-wrap gap-1 border-b",children:we.map(([s,i,a])=>e.jsxs("button",{onClick:()=>Q(s),className:`px-3 py-2 text-xs sm:text-sm font-medium border-b-2 -mb-px flex items-center gap-1.5 ${f===s?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(a,{className:"w-3.5 h-3.5"}),i]},s))}),["actions","health","credentials","retention","duplicates"].includes(f)&&e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(ye,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}
26),e.jsx(M,{className:"pl-9",value:v,onChange:s=>ue(s.target.value),placeholder:"Search this work queue"})]}),f==="composition"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Current Bylaws Rule â Active Now"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-sm ${(ts=t==null?void 0:t.composition)!=null&&ts.classification_review_required?"border-amber-300 bg-amber-50 text-amber-900":"border-green-300 bg-green-50 text-green-900"}`,children:[e.jsxs("strong",{children:[((is=t==null?void 0:t.composition)==null?void 0:is.travel_advisor_minimum_pct)||80,"% Travel Advisors / ",((rs=t==null?void 0:t.composition)==null?void 0:rs.industry_partner_maximum_pct)||20,"% Industry Partners"]}),e.jsxs("p",{className:"text-xs mt-1",children:["The bylaw rule remains active. ",((as=t==null?void 0:t.composition)==null?void 0:as.classification_review_pending)||0," active record(s) still need classification review, including ",((ns=t==null?void 0:t.composition)==null?void 0:ns.classification_conflicts)||0," direct conflict(s), so new Industry Partner capacity is held until the review list is reconciled."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{className:"rounded border p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Travel Advisors"}),e.jsx("p",{className:"text-xl font-bold",children:((ls=t==null?void 0:t.composition)==null?void 0:ls.travel_advisors)||0}),e.jsxs("p",{className:"text-xs",children:[((cs=t==null?void 0:t.composition)==null?void 0:cs.travel_advisor_pct)||0,"%"]})]}),e.jsxs("div",{className:"rounded border p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Industry Partners"}),e.jsx("p",{className:"text-xl font-bold",children:((os=t==null?void 0:t.composition)==null?void 0:os.industry_partners)||0}),e.jsxs("p",{className:"text-xs",children:[((ds=t==null?void 0:t.composition)==null?void 0:ds.industry_partner_pct)||0,"%"]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["There are ",e.jsx("strong",{children:((ms=t==null?void 0:t.composition)==null?void 0:ms.industry_partners)||0})," confirmed Industry Partners. The legacy source data still identifies ",e.jsx("strong",{children:((ps=t==null?void 0:t.composition)==null?void 0:ps.legacy_source_industry_partners)||0}),", while the current application-type field identifies ",e.jsx("strong",{children:((hs=t==null?void 0:t.composition)==null?void 0:hs.current_application_type_industry_partners)||0}),". Capacity will be recalculated automatically after the remaining classification reviews are resolved."]})]})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Future Vendor / Industry Partner Model â Discussion Only"})}),e.jsx(d,{className:"space-y-3",children:((t==null?void 0:t.policy_drafts)||[]).length?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium",children:t.policy_drafts[0].title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.policy_drafts[0].rationale}),e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-900",children:[e.jsx("strong",{children:"Proposed membership obligation:"}),e.jsx("p",{className:"mt-1",children:t.policy_drafts[0].presentation_requirement_text})]}),e.jsxs(S,{variant:"outline",children:["Status: ",c(t.policy_drafts[0].status)]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No future policy draft is recorded."})})]})]}),((t==null?void 0:t.classification_conflicts)||[]).length>0&&e.jsxs(o,{className:"border-amber-300",children:[e.jsx(b,{children:e.jsxs(_,{className:"text-base",children:["Membership Classification Reconciliation â ",t.classification_conflicts.length," Record(s)"]})}),e.jsxs(d,{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These active records say Industry Partner in the preserved source/category data but a different category in the current application field, or vice versa. Review each one before the 80/20 grid is treated as final."}),t.classification_conflicts.map(s=>e.jsx("div",{className:"rounded-lg border p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.company," · ",s.membership_number]}),e.jsxs("p",{className:"text-xs mt-1",children:["Preserved category: ",e.jsx("strong",{children:c(s.category_slug)})," · Current application type: ",e.jsx("strong",{children:c(s.application_type)}),s.legacy_plan?` · Legacy plan: ${s.legacy_plan}`:""]})]}),A(n,"membership.review_applications")&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{size:"sm",variant:"outline",disabled:g===`class:${s.id}`,onClick:()=>Qe(s,"travel_advisor"),children:"Confirm Travel Advisor"}),e.jsx(m,{size:"sm",disabled:g===`class:${s.id}`,onClick:()=>Qe(s,"industry_partner"),children:"Confirm Industry Partner"})]})]})},s.id))]})]}),(n==null?void 0:n.isOwner)&&((xs=t==null?void 0:t.governance_policy)==null?void 0:xs.mode)==="bylaw_ratio"&&e.jsxs(o,{className:"border-amber-300",children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Governance Change Control â System Owner Only"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsx("div",{className:"rounded-md bg-amber-50 border border-amber-200 p-3 text-xs text-amber-900",children:"Do not use this control unless TIA has formally amended the bylaws to authorize the future model. Do not enter the current bylaws date unless that is also the effective date of the actual amendment. The future model cannot be activated by Membership staff."}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Effective date of future amendment"}
26),e.jsx(M,{type:"date",value:F.effective_date,onChange:s=>re(i=>({...i,effective_date:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Confirmation"}),e.jsx(M,{value:F.confirm,onChange:s=>re(i=>({...i,confirm:s.target.value})),placeholder:"Type BYLAWS AMENDED"})]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Authorization / amendment record"}),e.jsx($,{rows:3,value:F.authorization_note,onChange:s=>re(i=>({...i,authorization_note:s.target.value})),placeholder:"Record the board/member authorization, amendment date, resolution, or other governing reference."})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Governance note"}),e.jsx($,{rows:2,value:F.governance_note,onChange:s=>re(i=>({...i,governance_note:s.target.value})),placeholder:"Optional operational note"})]}),e.jsxs(m,{className:"bg-amber-600 hover:bg-amber-700",disabled:g==="policy"||F.confirm!=="BYLAWS AMENDED"||!F.effective_date||F.authorization_note.trim().length<10,onClick:Qs,children:[g==="policy"&&e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Activate Presentation-Based Model After Amendment"]})]})]}),((t==null?void 0:t.governance_audits)||[]).length>0&&e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Governance Audit History"})}),e.jsx(d,{className:"space-y-2",children:t.governance_audits.slice(0,10).map(s=>e.jsxs("div",{className:"rounded border p-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("strong",{children:c(s.action)}),e.jsx("span",{className:"text-muted-foreground",children:E(s.changed_at)})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s.authorization_note||"No note recorded"})]},s.id))})]})]}),f==="partners"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-sm ${((us=t==null?void 0:t.governance_policy)==null?void 0:us.mode)==="open_industry_partner_with_presentation"?"border-blue-300 bg-blue-50 text-blue-900":"border-slate-200 bg-slate-50 text-slate-700"}`,children:[e.jsx("strong",{children:((js=t==null?void 0:t.governance_policy)==null?void 0:js.mode)==="open_industry_partner_with_presentation"?"Presentation requirement is active":"Presentation tracker is prepared but not active"}),e.jsx("p",{className:"text-xs mt-1",children:((fs=t==null?void 0:t.governance_policy)==null?void 0:fs.mode)==="open_industry_partner_with_presentation"?"Each Industry Partner/vendor membership activated or renewed on or after the policy effective date receives one presentation commitment for that membership cycle.":"Current Industry Partners remain governed by the existing 80/20 bylaws model. The proposed presentation requirement will not be imposed unless the bylaws are formally amended and the future policy is activated."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(q,{label:"Confirmed Industry Partners",value:((vs=t==null?void 0:t.composition)==null?void 0:vs.confirmed_industry_partners)||0,detail:"Reconciled partner records"}),e.jsx(q,{label:"Partner Review Pending",value:((gs=t==null?void 0:t.composition)==null?void 0:gs.industry_partner_review_pending)||0,detail:"Not counted as confirmed until reviewed"}),e.jsx(q,{label:"Open Presentation Commitments",value:((bs=t==null?void 0:t.summary)==null?void 0:bs.industry_partner_presentations_open)||0,detail:"Unscheduled, scheduled, or overdue"}),e.jsx(q,{label:"Required Per Cycle",value:((_s=t==null?void 0:t.governance_policy)==null?void 0:_s.presentation_required_per_cycle)||1,detail:"When presentation model is active"})]}),((t==null?void 0:t.presentation_commitments)||[]).length?e.jsx("div",{className:"space-y-2",children:t.presentation_commitments.map(s=>e.jsx(o,{className:s.derived_status==="overdue"?"border-red-300":"",children:e.jsx(d,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-semibold",children:s.member_name}),e.jsx(S,{variant:"outline",children:c(s.derived_status)}),e.jsx(S,{variant:"outline",children:s.membership_year})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.company," · ",s.membership_number]}),e.jsxs("p",{className:"text-xs mt-1",children:["Cycle ",E(s.cycle_start_date)," â ",E(s.cycle_end_date),s.scheduled_date?` · Scheduled ${E(s.scheduled_date)}`:""]}),s.presentation_title&&e.jsx("p",{className:"text-sm mt-1",children:e.jsx("strong",{children:s.presentation_title})})]}),A(n,"membership.review_applications")&&e.jsx(m,{size:"sm",variant:"outline",onClick:()=>L({...s,presentation_format:s.presentation_format||"in_person",completed_date:s.completed_date||new Date().toISOString().slice(0,10),waive_reason:""}),children:"Manage"})]})})},s.id))}):e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Current Industry Partner Members"})}),e.jsx(d,{className:"space-y-2",children:((t==null?void 0:t.industry_partners)||[]).length?t.industry_partners.map(s=>e.jsx("div",{className:"rounded border p-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.company," · ",s.membership_number]})]}),e.jsx(S,{variant:"outline",children:"No presentation obligation under current policy"})]})},s.id)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active Industry Partner memberships."})})]}),C&&e.jsxs(o,{className:"border-blue-300",children:[e.jsx(b,{children:e.jsxs(_,{className:"text-base",children:["Manage Presentation â ",C.member_name]})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Presentation title"}),e.jsx(M,{value:C.presentation_title||"",onChange:s=>L(i=>({...i,presentation_title:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Format"}),e.jsx("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:C.presentation_format||"in_person",onChange:s=>L(i=>({...i,presentation_format:s.target.value})),children:["in_person","virtual","webinar","event_program","other"].map(s=>e.jsx("option",{value:s,children:c(s)},s))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Scheduled date"}
26),e.jsx(M,{type:"date",value:C.scheduled_date||"",onChange:s=>L(i=>({...i,scheduled_date:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Completed date"}),e.jsx(M,{type:"date",value:C.completed_date||"",onChange:s=>L(i=>({...i,completed_date:s.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Description / topic"}),e.jsx($,{rows:3,value:C.presentation_description||"",onChange:s=>L(i=>({...i,presentation_description:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Membership notes"}),e.jsx($,{rows:2,value:C.admin_notes||"",onChange:s=>L(i=>({...i,admin_notes:s.target.value}))})]}),(n==null?void 0:n.isOwner)&&e.jsxs("div",{children:[e.jsx(x,{children:"Waiver reason â owner only"}),e.jsx($,{rows:2,value:C.waive_reason||"",onChange:s=>L(i=>({...i,waive_reason:s.target.value}))})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(m,{onClick:()=>_e("schedule"),disabled:g==="presentation"||!C.scheduled_date,children:"Save Schedule"}),e.jsx(m,{onClick:()=>_e("complete"),disabled:g==="presentation",className:"bg-green-600 hover:bg-green-700",children:"Mark Completed"}),(n==null?void 0:n.isOwner)&&e.jsx(m,{variant:"outline",className:"text-amber-700",onClick:()=>_e("waive"),disabled:g==="presentation"||String(C.waive_reason||"").trim().length<10,children:"Waive Requirement"}),e.jsx(m,{variant:"outline",onClick:()=>L(null),children:"Cancel"})]})]})]})]}),f==="actions"&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1fr_360px]",children:[e.jsx("div",{className:"space-y-2",children:Ue.length?Ue.map(s=>e.jsx(o,{className:Ne(s.severity),children:e.jsx(d,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx(S,{variant:"outline",children:c(s.type)}),e.jsx(S,{variant:"outline",children:c(s.severity)})]}),e.jsx("p",{className:"text-sm mt-1",children:s.reason}),e.jsx("p",{className:"text-xs opacity-75 mt-1",children:[s.membership_number,s.company,s.email].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap justify-end",children:[s.path&&e.jsx(m,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(Rs,{to:s.path,children:"Open"})}),s.application_id&&e.jsx(m,{size:"sm",variant:"outline",onClick:()=>B(s.application_id),children:"360"}),s.application_id&&A(n,"membership.review_applications")&&e.jsx(m,{size:"sm",onClick:()=>z({application_id:s.application_id,name:s.name,priority:s.severity==="high"?"high":"normal",due_at:"",next_action:s.reason,case_status:"open",assigned_staff_id:"",assigned_staff_name:"",cancellation_reason:"",cancellation_notes:"",lapse_reason:"",staff_notes:""}),children:"Assign"})]})]})})},s.id)):e.jsx(W,{text:"Nothing needs immediate Membership action right now.",icon:tt})}),e.jsxs(o,{className:"h-fit lg:sticky lg:top-4",children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Case Assignment"})}),e.jsx(d,{children:y?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:y.name}),e.jsxs("div",{children:[e.jsx(x,{children:"Assigned staff"}),e.jsxs("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:y.assigned_staff_id,onChange:s=>{const i=((t==null?void 0:t.staff)||[]).find(a=>a.id===s.target.value);z(a=>({...a,assigned_staff_id:s.target.value,assigned_staff_name:(i==null?void 0:i.display_name)||""}))},children:[e.jsx("option",{value:"",children:"Unassigned"}),((t==null?void 0:t.staff)||[]).map(s=>e.jsx("option",{value:s.id,children:s.display_name||s.email},s.id))]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Priority"}),e.jsx("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:y.priority,onChange:s=>z(i=>({...i,priority:s.target.value})),children:["low","normal","high","urgent"].map(s=>e.jsx("option",{children:s},s))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Due"}
26),e.jsx(M,{type:"datetime-local",value:y.due_at,onChange:s=>z(i=>({...i,due_at:s.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Next action"}),e.jsx($,{rows:3,value:y.next_action,onChange:s=>z(i=>({...i,next_action:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Cancellation / departure reason"}),e.jsxs("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:y.cancellation_reason||"",onChange:s=>z(i=>({...i,cancellation_reason:s.target.value})),children:[e.jsx("option",{value:"",children:"Not applicable"}),["did_not_renew","left_industry","cost","left_company","retired","moved_or_changed_business","dissatisfied","duplicate","other"].map(s=>e.jsx("option",{value:s,children:c(s)},s))]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Lapse reason / retention note"}),e.jsx(M,{value:y.lapse_reason||"",onChange:s=>z(i=>({...i,lapse_reason:s.target.value})),placeholder:"Why the membership lapsed or is at risk"})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Cancellation details"}),e.jsx($,{rows:2,value:y.cancellation_notes||"",onChange:s=>z(i=>({...i,cancellation_notes:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Internal note"}),e.jsx($,{rows:3,value:y.staff_notes,onChange:s=>z(i=>({...i,staff_notes:s.target.value}))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(m,{onClick:$s,disabled:g==="case",children:[g==="case"&&e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}),"Save"]}),e.jsx(m,{variant:"outline",onClick:()=>z(null),children:"Cancel"})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose Assign on a member case to set responsibility, priority, due date, and next action."})})]})]}),f==="health"&&e.jsx("div",{className:"space-y-2",children:Ve.length?Ve.map(s=>{const i=["WAIVER_FLAG_MISMATCH","PROFILE_EMAIL_MISMATCH","PROFILE_COMPANY_MISMATCH","PROFILE_NAME_MISMATCH","NO_PROFILE_LINK"].includes(s.code);return e.jsx(o,{className:Ne(s.severity),children:e.jsxs(d,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx(S,{variant:"outline",children:s.code}),e.jsx(S,{variant:"outline",children:c(s.severity)})]}),e.jsx("p",{className:"text-sm mt-1",children:s.issue}),e.jsx("p",{className:"text-xs opacity-75 mt-1",children:[s.membership_number,s.company].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex gap-2",children:[i&&A(n,"membership.approve_applications")&&e.jsxs(m,{size:"sm",onClick:()=>Os(s),disabled:g===s.id,children:[e.jsx(it,{className:"w-3.5 h-3.5 mr-1"}),"Repair"]}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>B(s.application_id),children:"Review 360"})]})]})},s.id)}):e.jsx(W,{text:"Membership Data Health is clean.",icon:Me})}),f==="credentials"&&e.jsx("div",{className:"space-y-3",children:We.length?We.map(s=>e.jsx(o,{className:Ne(s.severity),children:e.jsxs(d,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx(S,{variant:"outline",children:s.credential_type||"Credential"}),e.jsx(S,{variant:"outline",children:c(s.verification_status)})]}),e.jsx("p",{className:"text-sm mt-1",children:s.queue_reason}),e.jsx("p",{className:"text-xs opacity-75 mt-1",children:[s.membership_number,s.credential_number,s.expiration_date&&`Expires ${s.expiration_date}`].filter(Boolean).join(" · ")})]}),s.document_url&&e.jsx(m,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:s.document_url,target:"_blank",rel:"noreferrer",children:[e.jsx(rt,{className:"w-3.5 h-3.5 mr-1"}),"View Card"]})})]}),A(n,"membership.review_credentials")&&e.jsxs("div",{className:"mt-3 flex flex-col sm:flex-row gap-2",children:[e.jsx(M,{value:qe[s.id]||"",onChange:i=>Ie(a=>({...a,[s.id]:i.target.value})),placeholder:"Credential review note"}),e.jsx(m,{size:"sm",onClick:()=>be(s,"verified"),disabled:g===s.id,children:"Verify"}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>be(s,"manual_review_required"),disabled:g===s.id,children:"Hold"}),e.jsx(m,{size:"sm",variant:"outline",className:"text-red-600",onClick:()=>be(s,"rejected"),disabled:g===s.id,children:"Reject"})]})]})},s.id)):e.jsx(W,{text:"No credentials are waiting for review or expiration attention.",icon:Se})}),f==="renewals"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(o,{children:e.jsxs(d,{className:"p-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Automated Renewal Campaign"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Rules are ready for 90, 60, 30, 14, 7 day, expired, and lapsed reminders. Preview before sending."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(m,{variant:"outline",onClick:Ds,disabled:g==="renewal-preview"||!A(n,"membership.send_membership_comms"),children:[g==="renewal-preview"?e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ot,{className:"w-4 h-4 mr-2"}),"Preview Due"]}),se&&e.jsxs(m,{onClick:Fs,disabled:g==="renewal-send"||!A(n,"membership.send_membership_comms"),children:[g==="renewal-send"?e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ne,{className:"w-4 h-4 mr-2"}),"Send ",se.count||0," Due Reminder(s)"]})]})]})}),se&&e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800",children:[e.jsx("strong",{children:"Preview:"})," ",se.count||0," reminder(s) are currently due. No messages are sent until you click the Send button."]}),e.jsx("div",{className:"space-y-2",children:((t==null?void 0:t.renewals)||[]).map(s=>e.jsx(o,{children:e.jsxs(d,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.company||""}),e.jsxs("p",{className:"text-xs mt-1",children:["Expires ",E(s.expiration_date)," · ",s.days_remaining," days · ",c(s.stage)," · Renewal ",c(s.renewal_status)]})]}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>B(s.application_id),children:"Member 360"})]})},s.application_id))})]}),f==="requests"&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[380px_1fr]",children:[e.jsxs(o,{className:"h-fit",children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Send Secure Information Request"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Member / Applicant"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(M,{value:ze,onChange:s=>{oe(s.target.value),U(i=>({...i,application_id:""})),te([])},onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Ge())},placeholder:"Name, email, company, or TIA member number"}),e.jsx(m,{type:"button",variant:"outline",onClick:Ge,disabled:Le,children:Le?e.jsx(O,{className:"w-4 h-4 animate-spin"}):e.jsx(ye,{className:"w-4 h-4"})})]}),Ee.length>0&&e.jsx("div",{className:"mt-2 max-h-48 overflow-auto rounded-md border divide-y",children:Ee.map(s=>e.jsxs("button",{type:"button",onClick:()=>{U(i=>({...i,application_id:s.id})),oe(`${s.name||s.email}${s.membership_number?` â ${s.membership_number}`:""}`),te([])},className:"w-full px-3 py-2 text-left text-xs hover:bg-muted",children:[e.jsx("strong",{children:s.name||s.email}),e.jsxs("p",{className:"text-muted-foreground",children:[s.email," · ",s.company||"No company"," · ",s.membership_number||"No member number"]})]},s.id))}),H.application_id&&e.jsx("p",{className:"mt-1 text-[11px] text-green-700",children:"Member selected for this secure request."})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Request type"}),e.jsx("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:H.request_type,onCh
26ange:s=>U(i=>({...i,request_type:s.target.value})),children:["profile_photo","credential","employer_credential","sot_document","signature_correction","agency_verification","application_correction","other"].map(s=>e.jsx("option",{value:s,children:c(s)},s))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Title"}),e.jsx(M,{value:H.title,onChange:s=>U(i=>({...i,title:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Instructions"}),e.jsx($,{rows:5,value:H.instructions,onChange:s=>U(i=>({...i,instructions:s.target.value})),placeholder:"Tell the member exactly what needs to be corrected or uploaded."})]}),e.jsxs(m,{onClick:Bs,disabled:!A(n,"membership.request_documents")||g==="request"||!H.application_id||!H.title,className:"w-full",children:[g==="request"?e.jsx(O,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ne,{className:"w-4 h-4 mr-2"}),"Send Secure Request"]})]})]}),e.jsx("div",{className:"space-y-2",children:((t==null?void 0:t.document_requests)||[]).length?(t.document_requests||[]).map(s=>e.jsx(o,{children:e.jsx(d,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:s.member_name||s.recipient_email}),e.jsx("p",{className:"text-sm",children:s.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c(s.request_type)," · ",c(s.status)," · Sent ",E(s.sent_at||s.created_date)]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{variant:"outline",children:c(s.status)}),s.status==="submitted"&&A(n,"membership.request_documents")&&e.jsx(m,{size:"sm",onClick:()=>Hs(s.id),disabled:g===s.id,children:"Mark Reviewed"})]})]})})},s.id)):e.jsx(W,{text:"No secure member information requests have been created yet.",icon:ne})})]}),f==="payments"&&e.jsx(ft,{payments:(t==null?void 0:t.payments)||[],summary:(t==null?void 0:t.payment_summary)||{}}),f==="member360"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(o,{children:e.jsx(d,{className:"p-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(M,{value:$e,onChange:s=>zs(s.target.value),onKeyDown:s=>s.key==="Enter"&&B(),placeholder:"Membership number, email, or application ID"}),e.jsx(m,{onClick:()=>B(),disabled:Oe,children:Oe?e.jsx(O,{className:"w-4 h-4 animate-spin"}):e.jsx(ye,{className:"w-4 h-4"})})]})})}),de?e.jsx(vt,{data:de,onRequest:s=>{U(i=>({...i,application_id:s.id,title:"Membership information requested"})),oe(`${s.name||s.email}${s.membership_number?` â ${s.membership_number}`:""}`),te([]),Q("requests")}}):e.jsx(W,{text:"Search for a member to see membership, annual applications, payments, Academy, events, communications, compliance, documents, and the complete activity timeline.",icon:As})]}),f==="organizations"&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[360px_1fr]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Create Organization Account"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Organization name"}),e.jsx(M,{value:me.name,onChange:s=>fe(i=>({...i,name:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Type"}),e.jsx("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:me.organization_type,onCh
26ange:s=>fe(i=>({...i,organization_type:s.target.value})),children:["travel_agency","host_agency","consortium","industry_partner","supplier","tourism_board","hotel","cruise_line","tour_operator","other"].map(s=>e.jsx("option",{value:s,children:c(s)},s))})]}),e.jsx(m,{className:"w-full",onClick:Us,disabled:g==="org"||!me.name||!A(n,"membership.review_affiliations"),children:"Create Organization"})]})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Link Member"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Organization"}),e.jsxs("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:K.organization_id,onChange:s=>pe(i=>({...i,organization_id:s.target.value})),children:[e.jsx("option",{value:"",children:"Select"}),((t==null?void 0:t.organizations)||[]).map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Application ID"}),e.jsx(M,{value:K.application_id,onChange:s=>pe(i=>({...i,application_id:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Organization role"}),e.jsx("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:K.role_type,onChange:s=>pe(i=>({...i,role_type:s.target.value})),children:["primary_representative","additional_representative","owner_principal","employee","independent_contractor","hosted_advisor","advisor","other"].map(s=>e.jsx("option",{value:s,children:c(s)},s))})]}),e.jsx(m,{className:"w-full",onClick:Vs,disabled:g==="org-link"||!K.organization_id||!K.application_id||!A(n,"membership.review_affiliations"),children:"Link Member"})]})]})]}),e.jsx("div",{className:"space-y-2",children:((t==null?void 0:t.organizations)||[]).length?(t.organizations||[]).map(s=>{const i=(t.organization_members||[]).filter(a=>a.organization_id===s.id&&a.status!=="ended");return e.jsx(o,{children:e.jsxs(d,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c(s.organization_type)," · ",c(s.status)," · ",i.length," linked member(s)"]})]}),e.jsxs(S,{variant:"outline",children:[i.length," people"]})]}),i.length>0&&e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:i.map(a=>e.jsxs("div",{className:"rounded-lg border p-2 text-xs",children:[e.jsx("p",{className:"font-medium",children:a.member_name}),e.jsxs("p",{className:"text-muted-foreground",children:[a.membership_number," · ",c(a.role_type)]})]},a.id))})]})},s.id)}):e.jsx(W,{text:"No organization accounts yet.",icon:ke})})]}),f==="reports"&&e.jsx(jt,{report:(t==null?void 0:t.report)||{}}),f==="segments"&&e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[360px_1fr]",children:[e.jsxs(o,{className:"h-fit",children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Save Member Segment"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Segment name"}),e.jsx(M,{value:T.name,onChange:s=>ie(i=>({...i,name:s.target.value})),placeholder:"Cruise specialists â Florida"})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Search term"}),e.jsx(M,{value:T.search,onChange:s=>ie(i=>({...i,search:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Membership type"}),e.jsxs("select",{className:"w-full h-9 rounded-md border px-2 text-sm",value:T.application_type,onCh
26ange:s=>ie(i=>({...i,application_type:s.target.value})),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"travel_advisor",children:"Travel Advisor"}),e.jsx("option",{value:"industry_partner",children:"Industry Partner"})]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"State"}),e.jsx(M,{value:T.state,onChange:s=>ie(i=>({...i,state:s.target.value})),placeholder:"FL"})]}),e.jsx(m,{className:"w-full",onClick:Ws,disabled:g==="segment"||!T.name,children:"Save Segment"})]})]}),e.jsxs("div",{className:"space-y-3",children:[((t==null?void 0:t.segments)||[]).map(s=>e.jsx(o,{children:e.jsxs(d,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description||JSON.stringify(s.filters||{})}),s.last_run_at&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last run: ",E(s.last_run_at)," · ",s.last_result_count||0," members"]})]}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>Gs(s),disabled:g===s.id,children:"Run"})]})},s.id)),he&&e.jsxs(o,{className:"border-blue-300",children:[e.jsx(b,{children:e.jsxs(_,{className:"text-base",children:[he.name,": ",he.count," member(s)"]})}),e.jsx(d,{className:"max-h-96 overflow-auto space-y-1",children:(he.applications||[]).map(s=>e.jsxs("button",{className:"w-full text-left rounded border px-3 py-2 text-xs hover:bg-muted",onClick:()=>B(s.id),children:[e.jsx("strong",{children:s.name||s.email})," · ",s.company||""," · ",s.membership_number||""]},s.id))})]})]})]}),f==="duplicates"&&e.jsxs("div",{className:"space-y-3",children:[((t==null?void 0:t.duplicate_groups)||[]).filter(s=>!V||s.records.some(Z)).length?(t.duplicate_groups||[]).filter(s=>!V||s.records.some(Z)).map(s=>e.jsx(o,{children:e.jsxs(d,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:["Possible duplicate â ",c(s.match_type)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Match: ",s.match_value," · Confidence: ",c(s.confidence)]})]}),e.jsxs(S,{variant:"outline",children:[s.records.length," records"]})]}),e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:s.records.map(i=>e.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[e.jsx("p",{className:"font-medium",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.email," · ",i.membership_number," · ",i.membership_year," · ",c(i.status)]}),e.jsx(m,{className:"mt-2",size:"sm",variant:"outline",onClick:()=>B(i.id),children:"Review 360"})]},i.id))}),s.records.length===2&&A(n,"membership.delete_members")&&e.jsxs("div",{className:"mt-3 rounded-lg border bg-muted/30 p-3",children:[e.jsx("p",{className:"text-xs font-medium mb-2",children:"Merge identity without deleting annual history"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>Ke(s,s.records[0].id,s.records[1].id),children:["Keep ",s.records[0].membership_number||"first"," as primary"]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>Ke(s,s.records[1].id,s.records[0].id),children:["Keep ",s.records[1].membership_number||"second"," as primary"]})]})]})]})},s.id)):e.jsx(W,{text:"No duplicate membership groups are currently detected.",icon:Pe})," ",I.preview&&e.jsxs(o,{className:"border-red-300",children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Duplicate Merge Confirmation"})}),e.jsxs(d,{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm",children:["Primary: ",e.jsx("strong",{children:I.preview.primary.name})," (",I.preview.primary.membership_number,")"]}),e.jsxs("p",{className:"text-sm",children:["Secondary: ",e.jsx("strong",{children:I.preview.duplicate.name})," (",I.preview.duplicate.membership_number,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.preview.preservation}),((ys=I.preview.warnings)==null?void 0:ys.length)>0&&e.jsx("div",{className:"rounded border border-amber-300 bg-amber-50 p-3 text-xs text-amber-800",children:I.preview.warnings.map(s=>e.jsxs("p",{children:["⢠",s]},s))}),e.jsxs("div",{children:[e.jsx(x,{children:"Type MERGE to confirm"}
26),e.jsx(M,{value:I.confirm,onChange:s=>xe(i=>({...i,confirm:s.target.value}))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{className:"bg-red-600 hover:bg-red-700",disabled:I.confirm!=="MERGE"||g==="merge",onClick:Ks,children:"Merge Identity"}),e.jsx(m,{variant:"outline",onClick:()=>xe({groupId:"",primary:"",secondary:"",preview:null,confirm:""}),children:"Cancel"})]})]})]})]}),f==="retention"&&e.jsx("div",{className:"space-y-2",children:((t==null?void 0:t.retention)||[]).filter(Z).map(s=>e.jsx(o,{children:e.jsxs(d,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("p",{className:"font-semibold",children:s.name}),e.jsx(S,{className:ut(s.level),children:c(s.level)})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.membership_number," · ",s.company||""]}),e.jsxs("p",{className:"text-xs mt-1",children:["Rules-based engagement score: ",e.jsxs("strong",{children:[s.score,"/100"]})," · ",s.completed_courses," completed Academy course(s) · ",s.event_registrations," event registration(s)"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{size:"sm",variant:"outline",onClick:()=>B(s.application_id),children:"Member 360"}),A(n,"membership.review_applications")&&e.jsx(m,{size:"sm",onClick:()=>{z({application_id:s.application_id,name:s.name,priority:s.level==="critical"?"urgent":s.level==="at_risk"?"high":"normal",due_at:"",next_action:"Retention follow-up",case_status:"open",assigned_staff_id:"",assigned_staff_name:"",cancellation_reason:"",cancellation_notes:"",lapse_reason:"",staff_notes:""}),Q("actions")},children:"Record Outcome"})]})]})},s.application_id))}),f==="backup"&&e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(Ce,{title:"Last Complete Export",record:(Ns=t==null?void 0:t.backup)==null?void 0:Ns.last_export,dateField:"requested_at",text:s=>s?`${s.member_count||0} member(s) · ${s.application_count||0} application(s)`:""}),e.jsx(Ce,{title:"Last Membership Import",record:(ws=t==null?void 0:t.backup)==null?void 0:ws.last_import,dateField:"requested_at",text:s=>s?`${s.created_count||0} created · ${s.updated_count||0} updated`:""}),e.jsx(Ce,{title:"Backup Health",record:(Cs=t==null?void 0:t.backup)==null?void 0:Cs.last_health,dateField:"checked_at",text:s=>s?s.message||c(s.status):""}),e.jsx(o,{className:"md:col-span-3",children:e.jsxs(d,{className:"p-4 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Complete Backup ZIP"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate a portable membership archive. Every full export now records a backup-health checkpoint automatically."})]}),e.jsx(m,{asChild:!0,variant:"outline",children:e.jsx(Rs,{to:"/admin/membership?tab=members",children:"Open Membership Backup Controls"})})]})})]})]})}function q({label:r,value:n,detail:l}){return e.jsxs("div",{className:"rounded-lg border bg-white p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:r}),e.jsx("p",{className:"text-2xl font-bold mt-0.5",children:n}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1 leading-snug",children:l})]})}function W({text:r,icon:n}){return e.jsx(o,{children:e.jsxs(d,{className:"py-12 text-center",children:[e.jsx(n,{className:"w-9 h-9 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r})]})})}function Ce({title:r,record:n,dateField:l,text:w}){return e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:r})}),e.jsx(d,{children:n?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium",children:w(n)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:E(n[l])}),n.export_filename&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-1",children:n.export_filename})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No checkpoint recorded yet."})})]})}function jt({report:r}){const n=(l,w)=>e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:l})}),e.jsx(d,{className:"space-y-2",children:Object.entries(w||{}).sort((p,f)=>Number(f[1])-Number(p[1])).slice(0,15).map(([p,f])=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:c(p)}),e.jsx("strong",{children:f})]},p))})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[["Active Members",r.total_active_members],["Open Applications",r.open_applications],["Re
26newal Rate",`${r.renewal_rate_pct||0}%`],["Lead Conversion",`${r.lead_conversion_pct||0}%`],["Waived Active",r.waived_active]].map(([l,w])=>e.jsx(o,{children:e.jsxs(d,{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold",children:w||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l})]})},l))}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[n("Membership by Category",r.by_category),n("Membership by Chapter",r.by_chapter),n("Membership by State",r.by_state),n("Credentials",r.credentials),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Top Niches"})}),e.jsx(d,{className:"space-y-2",children:(r.top_niches||[]).map(([l,w])=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:l}),e.jsx("strong",{children:w})]},l))})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Top Destinations"})}),e.jsx(d,{className:"space-y-2",children:(r.top_destinations||[]).map(([l,w])=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:l}),e.jsx("strong",{children:w})]},l))})]})]})]})}function ft({payments:r,summary:n}){const l=p=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(Number(p||0)),w=p=>p==="confirmed"?"bg-green-100 text-green-800":p==="waived"||p==="complimentary"?"bg-blue-100 text-blue-800":"bg-amber-100 text-amber-800";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 text-sm text-blue-900",children:[e.jsx("strong",{children:"Read-only membership payment verification."})," Payments are confirmed automatically by Stripe or the verified Zelle intake. Membership staff cannot edit, post, refund, or reconcile financial records here."]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[e.jsx(q,{label:"Confirmed Payments",value:n.confirmed_count||0,detail:l(n.confirmed_total)}),e.jsx(q,{label:"Pending Payments",value:n.pending_count||0,detail:"Not yet received or confirmed"}),e.jsx(q,{label:"Stripe Received",value:l(n.stripe_total),detail:"Confirmed card payments"}),e.jsx(q,{label:"Zelle Received",value:l(n.zelle_total),detail:"Confirmed Zelle payments"}),e.jsx(q,{label:"Total Received",value:l(n.confirmed_total),detail:"Confirmed membership dues"})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Membership Payments â Stripe & Zelle"})}),e.jsx(d,{className:"p-0 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Applicant / Member"}),e.jsx("th",{className:"text-left p-3",children:"Type"}),e.jsx("th",{className:"text-left p-3",children:"Payment"}),e.jsx("th",{className:"text-left p-3",children:"Method"}),e.jsx("th",{className:"text-left p-3",children:"Date"}),e.jsx("th",{className:"text-right p-3",children:"Amount"}),e.jsx("th",{className:"text-left p-3",children:"Membership Status"}),e.jsx("th",{className:"text-left p-3",children:"Reference"})]})}),e.jsxs("tbody",{className:"divide-y",children:[r.map(p=>e.jsxs("tr",{children:[e.jsxs("td",{className:"p-3",children:[e.jsx("p",{className:"font-medium",children:p.applicant_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[p.email,p.membership_number?` · ${p.membership_number}`:"",p.company?` · ${p.company}`:""]})]}),e.jsx("td",{className:"p-3",children:c(p.application_type)||"â"}),e.jsx("td",{className:"p-3",children:e.jsx(S,{className:w(p.payment_status),children:c(p.payment_status)||"Unpaid"})}),e.jsx("td",{className:"p-3 font-medium",children:p.payment_method==="card"?"Stripe":c(p.payment_method)||"â"}),e.jsx("td",{className:"p-3 whitespace-nowrap",children:p.payment_date?E(p.payment_date):"â"}),e.jsx("td",{className:"p-3 text-right font-semibold",children:l(p.amount)}),e.jsx("td",{className:"p-3",children:c(p.application_status)||"â"}),e.jsx("td",{className:"p-3 max-w-[220px]",children:e.jsx("span",{className:"text-xs break-all",children:p.reference||"â"})})]}
26,p.id)),!r.length&&e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"p-8 text-center text-muted-foreground",children:"No membership payment records are available. [build-check-v2]"})})]})]})})]})]})}function vt({data:r,onRequest:n}){var w,p,f,D,t,ce,G,J,X,ee;const l=r.anchor||{};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(o,{children:e.jsx(d,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:l.name||l.email}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.membership_number||"No member number"," · ",l.company||""," · ",c(l.application_type)," · ",c(l.status)]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[l.email," · ",l.cell_phone||l.phone||""]})]}),e.jsxs(m,{size:"sm",onClick:()=>n(l),children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1"}),"Request Info"]})]})})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Membership History"})}),e.jsx(d,{className:"space-y-2",children:(r.applications||[]).map(v=>e.jsxs("div",{className:"rounded border p-2 text-xs",children:[e.jsxs("strong",{children:[v.membership_year||"â"," ",v.application_type_choice||"Application"]}),e.jsxs("p",{children:[c(v.status)," · ",c(v.payment_status)]}),e.jsxs("p",{children:["Submitted ",E(v.submitted_at||v.created_date)]})]},v.id))})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Academy & Events"})}),e.jsxs(d,{className:"text-sm space-y-2",children:[e.jsxs("p",{children:[e.jsx("strong",{children:((p=(w=r.academy)==null?void 0:w.enrollments)==null?void 0:p.length)||0})," Academy enrollment(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((D=(f=r.academy)==null?void 0:f.certificates)==null?void 0:D.length)||0})," certificate(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((t=r.events)==null?void 0:t.length)||0})," event registration(s)"]})]})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Compliance & Documents"})}),e.jsxs(d,{className:"text-sm space-y-2",children:[e.jsxs("p",{children:[e.jsx("strong",{children:((ce=r.annual_archives)==null?void 0:ce.length)||0})," annual archive package(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((G=r.sot_reviews)==null?void 0:G.length)||0})," SOT review(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((J=r.affiliations)==null?void 0:J.length)||0})," agency affiliation record(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((X=r.document_requests)==null?void 0:X.length)||0})," information request(s)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:((ee=r.verification_reports)==null?void 0:ee.length)||0})," accreditation verification report(s)"]})]})]})]}),(r.verification_reports||[]).length>0&&e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Accreditation Verification Reports"})}),e.jsx(d,{className:"space-y-2",children:r.verification_reports.map(v=>e.jsxs("div",{className:"rounded border p-3 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("strong",{children:[v.issuer," · ",v.credential_number_masked||"Credential"]}),e.jsx(S,{variant:"outline",children:c(v.decision)})]}),e.jsx("p",{className:"mt-1",children:v.provider_status||"No provider status recorded"}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:["Name match: ",v.name_match===!0?"Yes":v.name_match===!1?"No":"Not available"," · Checked ",E(v.checked_at)]}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap font-sans text-[11px] text-muted-foreground",children:v.report_text})]},v.id))})]}),e.jsxs(o,{children:[e.jsx(b,{children:e.jsx(_,{className:"text-base",children:"Complete Activity Timeline"})}),e.jsx(d,{className:"max-h-[520px] overflow-auto",children:e.jsx("div",{className:"space-y-2",children:(r.timeline||[]).map((v,ue)=>e.jsxs("div",{className:"grid grid-cols-[105px_1fr] gap-3 border-b pb-2 text-xs",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("p",{children:E(v.at)}),e.jsx(S,{variant:"outline",className:"mt-1",children:c(v.type)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:v.title}),e.jsx("p",{className:"text-muted-foreground mt-0.5",children:v.detail})]})]},`${v.type}-${v.record_id}-${ue}`))})})]})]})}export{Ht as default};
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.