PageSourceSearch

https://mycpd.ca/assets/partner-NV62ruTo.js

js mycpd.ca collected 2026-10-08 22:58:11 UTC 56,739 bytes, 3 lines download raw bytes

vendor: 4,810 bytes, line 1
1import{j as e,r as a,f as na,u as ia,e as oa,L as la,t as m,s as b}from"./index-iswyaaTO.js";import{u as cs}from"./useQuery-BBAtYsS7.js";import{u as ca,a as da,P as ua,c as ie,b as pa}from"./index-C16gbEIF.js";import{u as ws,c as ma,B as y}from"./button-DLMQ6Uve.js";import{P as ha,D as xa}from"./index-z53ibKyz.js";import{R as ga,A as fa,e as Cs,C as _a,f as ba,g as ja,S as ht,a as xt,b as gt,c as ft,d as G}from"./select-L7uLTc-m.js";import{P as Ss}from"./index-2m0Fgmjk.js";import{D as _t,f as va,a as bt,b as jt,c as vt,d as yt,e as Nt}from"./dialog-CijxN6eE.js";import{pdf as ya,Document as Na,Page as wa,View as W,Text as x,StyleSheet as Ca}from"./react-pdf.browser-CNXN02MD.js";import{C as K}from"./card-DwAJiWd5.js";import{I as D}from"./input-B0sgrqfa.js";import{L as j}from"./label-uhlLVwp-.js";import{T as de}from"./textarea-BOs68Z4K.js";import{C as Te}from"./checkbox-BuJf9BiG.js";import{S as Sa}from"./skeleton-C9p-zhXk.js";import{B as ds}from"./badge-Cm_VJqFY.js";import{S as ka}from"./switch-Ckaslcgk.js";import{C as Ta,a as Ea,b as Pa}from"./collapsible-Bih80FFj.js";import{T as us,a as ps,b as ue,c as H,d as ms,e as U}from"./table-D2HCYH8k.js";import{f as hs}from"./cpd-m3WgmBav.js";import{a as Ee,S as Aa}from"./sparkles-CVBzQam0.js";import{c as Ae}from"./createLucideIcon-NQplnISs.js";import{D as xs,U as pe,F as gs}from"./upload-Dp_OC1k9.js";import{L as F}from"./loader-circle-5YkpO55X.js";import{C as Da}from"./circle-check-DfvdZdxE.js";import{T as Ra}from"./trash-2-C1IexxI3.js";import"./index-MpgxoVHZ.js";import"./check-Brk3nAWo.js";import"./index-2CxEMR5X.js";import"./x-BxvCx92L.js";import"./index-Cb1mz3yA.js";const Ba=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ia=Ae("arrow-left",Ba);const Oa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Fa=Ae("info",Oa);const La=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],fs=Ae("save",La);const Ua=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],_s=Ae("send",Ua);var za=Symbol("radix.slottable");function $a(s){const o=({children:r})=>e.jsx(e.Fragment,{children:r});return o.displayName=`${s}.Slottable`,o.__radixId=za,o}var[De]=pa("Tooltip",[Cs]),Re=Cs(),ks="TooltipProvider",Ha=700,Ct="tooltip.open",[Ma,Tt]=De(ks),Ts=s=>{const{__scopeTooltip:o,delayDuration:r=Ha,skipDelayDuration:l=300,disableHoverableContent:i=!1,children:p}=s,_=a.useRef(!0),k=a.useRef(!1),g=a.useRef(0);return a.useEffect(()=>{const w=g.current;return()=>window.clearTimeout(w)},[]),e.jsx(Ma,{scope:o,isOpenDelayedRef:_,delayDuration:r,onOpen:a.useCallback(()=>{window.clearTimeout(g.current),_.current=!1},[]),onClose:a.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>_.current=!0,l)},[l]),isPointerInTransitRef:k,onPointerInTransitChange:a.useCallback(w=>{k.current=w},[]),disableHoverableContent:i,children:p})};Ts.displayName=ks;var he="Tooltip",[qa,xe]=De(he),Es=s=>{const{__scopeTooltip:o,children:r,open:l,defaultOpen:i,onOpenChange:p,disableHoverableContent:_,delayDuration:k}=s,g=Tt(he,s.__scopeTooltip),w=Re(o),[v,S]=a.useState(null),T=ca(),C=a.useRef(0),E=_??g.disableHoverableContent,R=k??g.delayDuration,B=a.useRef(!1),[z,L]=da({prop:l,defaultProp:i??!1,onChange:Z=>{Z?(g.onOpen(),document.dispatchEvent(new CustomEvent(Ct))):g.onClose(),p?.(Z)},caller:he}),Q=a.useMemo(()=>z?B.current?"delayed-open":"instant-open":"closed",[z]),M=a.useCallback(()=>{window.clearTimeout(C.current),C.current=0,B.current=!1,L(!0)},[L]),q=a.useCallback(()=>{window.clearTimeout(C.current),C.current=0,L(!1)},[L]),X=a.useCallback(()=>{window.clearTimeout(C.current),C.current=window.setTimeout(()=>{B.current=!0,L(!0),C.current=0},R)},[R,L]);return a.useEffect(()=>()=>{C.current&&(window.clearTimeout(C.current),C.current=0)},[]),e.jsx(ga,{...w,children:e.jsx(qa,{scope:o,contentId:T,open:z,stateAttribute:Q,trigger:v,onTriggerChange:S,onTriggerEnter:a.useCallback(()=>{g.isOpenDelayedRef.current?X():M()},[g.isOpenDelayedRef,X,M]),onTriggerLeave:a.useCallback(()=>{E?q():(window.clearTimeout(C.current),C.current=0)},[q,E]),onOpen:M,onClose:q,disableHoverableContent:E,children:r})})};Es.displayName=he;var St="TooltipTrigger",Ps=a.forwardRef((s,o)=>{const{__scopeTooltip:r,...l}=s,i=xe(St,r),p=Tt(St,r),_=Re(r),k=a.useRef(null),g=ws(o,k,i.onTriggerChange),w=a.useRef(!1),v=a.useRef(!1),S=a.useCallback(()=>w.current=!1,[]);return a.useEffect(()=>()=>
vendor: 5,617 bytes, line 1
1document.removeEventListener("pointerup",S),[S]),e.jsx(fa,{asChild:!0,..._,children:e.jsx(ua.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...l,ref:g,onPointerMove:ie(s.onPointerMove,T=>{T.pointerType!=="touch"&&!v.current&&!p.isPointerInTransitRef.current&&(i.onTriggerEnter(),v.current=!0)}),onPointerLeave:ie(s.onPointerLeave,()=>{i.onTriggerLeave(),v.current=!1}),onPointerDown:ie(s.onPointerDown,()=>{i.open&&i.onClose(),w.current=!0,document.addEventListener("pointerup",S,{once:!0})}),onFocus:ie(s.onFocus,()=>{w.current||i.onOpen()}),onBlur:ie(s.onBlur,i.onClose),onClick:ie(s.onClick,i.onClose)})})});Ps.displayName=St;var Et="TooltipPortal",[Ga,Va]=De(Et,{forceMount:void 0}),As=s=>{const{__scopeTooltip:o,forceMount:r,children:l,container:i}=s,p=xe(Et,o);return e.jsx(Ga,{scope:o,forceMount:r,children:e.jsx(Ss,{present:r||p.open,children:e.jsx(ha,{asChild:!0,container:i,children:l})})})};As.displayName=Et;var oe="TooltipContent",Ds=a.forwardRef((s,o)=>{const r=Va(oe,s.__scopeTooltip),{forceMount:l=r.forceMount,side:i="top",...p}=s,_=xe(oe,s.__scopeTooltip);return e.jsx(Ss,{present:l||_.open,children:_.disableHoverableContent?e.jsx(Rs,{side:i,...p,ref:o}):e.jsx(Wa,{side:i,...p,ref:o})})}),Wa=a.forwardRef((s,o)=>{const r=xe(oe,s.__scopeTooltip),l=Tt(oe,s.__scopeTooltip),i=a.useRef(null),p=ws(o,i),[_,k]=a.useState(null),{trigger:g,onClose:w}=r,v=i.current,{onPointerInTransitChange:S}=l,T=a.useCallback(()=>{k(null),S(!1)},[S]),C=a.useCallback((E,R)=>{const B=E.currentTarget,z={x:E.clientX,y:E.clientY},L=Za(z,B.getBoundingClientRect()),Q=Ja(z,L),M=er(R.getBoundingClientRect()),q=sr([...Q,...M]);k(q),S(!0)},[S]);return a.useEffect(()=>()=>T(),[T]),a.useEffect(()=>{if(g&&v){const E=B=>C(B,v),R=B=>C(B,g);return g.addEventListener("pointerleave",E),v.addEventListener("pointerleave",R),()=>{g.removeEventListener("pointerleave",E),v.removeEventListener("pointerleave",R)}}},[g,v,C,T]),a.useEffect(()=>{if(_){const E=R=>{const B=R.target,z={x:R.clientX,y:R.clientY},L=g?.contains(B)||v?.contains(B),Q=!tr(z,_);L?T():Q&&(T(),w())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[g,v,_,w,T]),e.jsx(Rs,{...s,ref:p})}),[Qa,Ya]=De(he,{isInside:!1}),Ka=$a("TooltipContent"),Rs=a.forwardRef((s,o)=>{const{__scopeTooltip:r,children:l,"aria-label":i,onEscapeKeyDown:p,onPointerDownOutside:_,...k}=s,g=xe(oe,r),w=Re(r),{onClose:v}=g;return a.useEffect(()=>(document.addEventListener(Ct,v),()=>document.removeEventListener(Ct,v)),[v]),a.useEffect(()=>{if(g.trigger){const S=T=>{T.target?.contains(g.trigger)&&v()};return window.addEventListener("scroll",S,{capture:!0}),()=>window.removeEventListener("scroll",S,{capture:!0})}},[g.trigger,v]),e.jsx(xa,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:p,onPointerDownOutside:_,onFocusOutside:S=>S.preventDefault(),onDismiss:v,children:e.jsxs(_a,{"data-state":g.stateAttribute,...w,...k,ref:o,style:{...k.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(Ka,{children:l}),e.jsx(Qa,{scope:r,isInside:!0,children:e.jsx(ba,{id:g.contentId,role:"tooltip",children:i||l})})]})})});Ds.displayName=oe;var Bs="TooltipArrow",Xa=a.forwardRef((s,o)=>{const{__scopeTooltip:r,...l}=s,i=Re(r);return Ya(Bs,r).isInside?null:e.jsx(ja,{...i,...l,ref:o})});Xa.displayName=Bs;function Za(s,o){const r=Math.abs(o.top-s.y),l=Math.abs(o.bottom-s.y),i=Math.abs(o.right-s.x),p=Math.abs(o.left-s.x);switch(Math.min(r,l,i,p)){case p:return"left";case i:return"right";case r:return"top";case l:return"bottom";default:throw new Error("unreachable")}}function Ja(s,o,r=5){const l=[];switch(o){case"top":l.push({x:s.x-r,y:s.y+r},{x:s.x+r,y:s.y+r});break;case"bottom":l.push({x:s.x-r,y:s.y-r},{x:s.x+r,y:s.y-r});break;case"left":l.push({x:s.x+r,y:s.y-r},{x:s.x+r,y:s.y+r});break;case"right":l.push({x:s.x-r,y:s.y-r},{x:s.x-r,y:s.y+r});break}return l}function er(s){const{top:o,right:r,bottom:l,left:i}=s;return[{x:i,y:o},{x:r,y:o},{x:r,y:l},{x:i,y:l}]}function tr(s,o){const{x:r,y:l}=s;let i=!1;for(let p=0,_=o.length-1;p<o.length;_=p++){const k=o[p],g=o[_],w=k.x,v=k.y,S=g.x,T=g.y;v>l!=T>l&&r<(S-w)*(l-v)/(T-v)+w&&(i=!i)}return i}function sr(s){const o=s.slice();return o.sort((r,l)=>r.x<l.x?-1:r.x>l.x?1:r.y<l.y?-1:r.y>l.y?1:0),ar(o)}function ar(s){if(s.length<=1)return s.slice();const o=[];for(let l=0;l<s.length;l++){const i=s[l];for(;o.length>=2;){const p=o[o.length-1],_=o[o.length-2];if((p.x-_.x)*(i.y-_.y)>=(p.y-_.y)*(i.x-_.x))o.pop();else break}o.push(i)}o.pop();const r=[];for(let l=s.length-1;l>=0;l--){const i=s[l];for(;r.length>=2;){const p=r[r.length-1],_=r[r.length-2];if((p.x-_.x)*(i.y-_.y)>=(p.y-_.y)*(i.x-_.x))r.pop();else break}r.push(i)}return r.pop(),o.length===1&&r.length===1&&o[0].x===r[0].x&&o[0].y===r[0].y?o:o.concat(r)}var rr=Ts,nr=Es,ir=Ps,or=As,Is=Ds;const bs=rr,js=nr,vs=ir,kt=a.forwardRef(({className:s,sideOffset:o=4,...r},l)=>e.jsx(or,{children:e.jsx(Is,{ref:l,sideOffset:o,className:ma("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
1de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-tooltip-content-transform-origin)",s),...r})}));kt.displayName=Is.displayName;const Pe="#1d4ed8",me="#6b7280",ys="#e5e7eb",u=Ca.create({page:{paddingTop:36,paddingBottom:50,paddingHorizontal:36,fontSize:9,color:"#111827",fontFamily:"Helvetica"},headerRow:{flexDirection:"row",justifyContent:"space-between",borderBottomWidth:2,borderBottomColor:Pe,paddingBottom:10,marginBottom:14},brand:{fontSize:16,fontWeight:700,color:Pe},brandSub:{fontSize:8,color:me,marginTop:2},headerInfo:{textAlign:"right",fontSize:9},sessionBlock:{marginBottom:18,borderWidth:1,borderColor:ys,borderRadius:4,padding:10},sessionTitle:{fontSize:12,fontWeight:700,color:Pe},metaRow:{flexDirection:"row",flexWrap:"wrap",marginTop:4,marginBottom:6},metaItem:{marginRight:12,fontSize:8,color:me},subHead:{fontSize:9,fontWeight:700,marginTop:8,marginBottom:3,color:"#111827"},bullet:{fontSize:8,marginBottom:1},tableHead:{flexDirection:"row",backgroundColor:Pe,color:"#fff",paddingVertical:3,paddingHorizontal:4,fontSize:8,fontWeight:700},tableRow:{flexDirection:"row",paddingVertical:3,paddingHorizontal:4,borderBottomWidth:1,borderBottomColor:ys,fontSize:8},c50:{width:"50%"},c25:{width:"25%"},c20:{width:"20%"},c30:{width:"30%"},footer:{position:"absolute",bottom:24,left:36,right:36,fontSize:7,color:me,textAlign:"center"}});function Ns(s){if(!s)return"—";try{return new Date(s).toISOString().slice(0,10)}catch{return s}}function lr({s,includeFeedbackText:o}){const r=s.feedback.map(i=>i.feedback_rating).filter(i=>typeof i=="number"),l=r.length?(r.reduce((i,p)=>i+p,0)/r.length).toFixed(2):"—";return e.jsxs(W,{style:u.sessionBlock,wrap:!0,children:[e.jsx(x,{style:u.sessionTitle,children:s.session_title}),e.jsxs(W,{style:u.metaRow,children:[e.jsxs(x,{style:u.metaItem,children:["Date: ",Ns(s.session_date)]}),e.jsxs(x,{style:u.metaItem,children:["Hours: ",s.hours]}),e.jsxs(x,{style:u.metaItem,children:["Attendees: ",s.attendee_emails?.length??0]}),e.jsxs(x,{style:u.metaItem,children:["Applies to: ",[s.applies_to_cpbao&&"CPBAO",s.applies_to_bacb&&"BACB"].filter(
1Boolean).join(", ")||"—"]})]}),s.applies_to_bacb&&e.jsxs(x,{style:u.bullet,children:["BACB breakdown — Ethics: ",s.suggested_bacb_ethics_hours??0,", Supervision: ",s.suggested_bacb_supervision_hours??0,", General: ",s.suggested_bacb_general_hours??0]}),s.applies_to_cpbao&&e.jsxs(x,{style:u.bullet,children:["CPBAO content — Ethics: ",s.suggested_ethics_hours??0,", EDI: ",s.suggested_edi_hours??0,", Supervision: ",s.suggested_supervision_hours??0]}),e.jsxs(x,{style:u.subHead,children:["Attendees (",s.attendee_emails?.length??0,")"]}),(s.attendee_emails??[]).length===0?e.jsx(x,{style:u.bullet,children:"—"}):(s.attendee_emails??[]).map(i=>e.jsxs(x,{style:u.bullet,children:["• ",i]},i)),e.jsxs(x,{style:u.subHead,children:["Certificates issued (",s.certificates.length,")"]}),s.certificates.length===0?e.jsx(x,{style:u.bullet,children:"None"}):e.jsxs(e.Fragment,{children:[e.jsxs(W,{style:u.tableHead,children:[e.jsx(x,{style:u.c50,children:"Attendee"}),e.jsx(x,{style:u.c25,children:"Hours certified"}),e.jsx(x,{style:u.c25,children:"Issued"})]}),s.certificates.map((i,p)=>e.jsxs(W,{style:u.tableRow,children:[e.jsx(x,{style:u.c50,children:i.attendee_email}),e.jsx(x,{style:u.c25,children:i.ceu_hours_certified}),e.jsx(x,{style:u.c25,children:Ns(i.issued_at)})]},p))]}),e.jsxs(x,{style:u.subHead,children:["Feedback (",s.feedback.length," response",s.feedback.length===1?"":"s",") · Avg rating: ",l]}),s.feedback.length===0?e.jsx(x,{style:u.bullet,children:"No feedback received"}):o?e.jsxs(e.Fragment,{children:[e.jsxs(W,{style:u.tableHead,children:[e.jsx(x,{style:u.c30,children:"Attendee"}),e.jsx(x,{style:u.c20,children:"Rating"}),e.jsx(x,{style:u.c50,children:"Comment"})]}),s.feedback.map((i,p)=>e.jsxs(W,{style:u.tableRow,children:[e.jsx(x,{style:u.c30,children:i.attendee_email}),e.jsx(x,{style:u.c20,children:i.feedback_rating??"—"}),e.jsx(x,{style:u.c50,children:i.feedback_text??""})]},p))]}):e.jsxs(x,{style:u.bullet,children:["Rating distribution: ",[5,4,3,2,1].map(i=>`${i}★:${s.feedback.filter(p=>p.feedback_rating===i).length}`).join("  ")]}),e.jsxs(x,{style:u.subHead,children:["Pending sign-ups (",s.pending.length,")"]}),s.pending.length===0?e.jsx(x,{style:u.bullet,children:"None"}):s.pending.map((i,p)=>e.jsxs(x,{style:u.bullet,children:["• ",i.attendee_email]},p))]})}function cr({data:s}){return e.jsx(Na,{children:e.jsxs(wa,{size:"LETTER",style:u.page,children:[e.jsxs(W,{style:u.headerRow,fixed:!0,children:[e.jsxs(W,{children:[e.jsx(x,{style:u.brand,children:s.partner_name}),e.jsxs(x,{style:u.brandSub,children:[s.ace_provider_name?`ACE Provider: ${s.ace_provider_name}`:"Partner audit export",s.ace_provider_number?` · #${s.ace_provider_number}`:""]})]}),e.jsxs(W,{style:u.headerInfo,children:[e.jsx(x,{children:"Audit Records"}),e.jsx(x,{style:{color:me,fontSize:8},children:s.date_range_label}),e.jsxs(x,{style:{color:me,fontSize:8},children:["Generated ",s.generated_at]})]})]}),s.sessions.length===0?e.jsx(x,{children:"No sessions in the selected range."}):s.sessions.map(o=>e.jsx(lr,{s:o,includeFeedbackText:s.include_feedback_text},o.id)),e.jsx(x,{style:u.footer,render:({pageNumber:o,totalPages:r})=>`Page ${o} of ${r}`,fixed:!0})]})})}function dr(s){return s.trim().replace(/[^a-zA-Z0-9-_ ]/g,"").replace(/\s+/g,"_").slice(0,60)||"partner"}async function ur(s){const o=na.createElement(cr,{data:s}),r=await ya(o).toBlob(),l=URL.createObjectURL(r),i=document.createElement("a");i.href=l,i.download=`audit_export_${dr(s.partner_name)}_${s.date_range_label.replace(/[^a-zA-Z0-9]/g,"_")}.pdf`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),1e3)}function wt(){const s=new Date;return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}function Mr(){const{user:s}=ia(),[o,r]=a.useState("upload"),[l,i]=a.useState(!1),[p,_]=a.useState(!1),[k,g]=a.useState(0),w=oa(),[v,S]=a.useState(!1),[T,C]=a.useState(!1),[E,R]=a.useState(!1),[B,z]=a.useState(!1),[L,Q]=a.useState(!1),M=a.useRef(null),q=a.useRef(null),X=a.useRef(null),Z=a.useRef(null),[Pt,At]=a.useState(""),[Dt,Rt]=a.useState(""),[Os,ge]=a.useState(!1),[fe,Fs]=a.use
1State(()=>{const t=new Date;return t.setFullYear(t.getFullYear()-1),t.toISOString().slice(0,10)}),[_e,Ls]=a.useState(wt()),[Be,Ie]=a.useState(new Set),[be,je]=a.useState("range"),[Bt,Us]=a.useState(!0),[Oe,ve]=a.useState(!1),[te,It]=a.useState(""),[se,Ot]=a.useState(wt()),[I,Ft]=a.useState("1"),[Lt,Ut]=a.useState("in_person_sync"),[ae,zs]=a.useState(!0),[re,$s]=a.useState(!0),[le,zt]=a.useState(""),[$t,Ht]=a.useState(""),[ce,Fe]=a.useState("ai"),[Hs,Mt]=a.useState(!1),[Le,Ue]=a.useState(""),[ze,$e]=a.useState(""),[He,qt]=a.useState(!1),Gt=a.useRef(null),[ye,Ne]=a.useState(null),[Vt,Wt]=a.useState(!1),[Y,we]=a.useState(null),[Qt,Me]=a.useState(""),[Yt,Kt]=a.useState(!1),[J,Xt]=a.useState(!1),[qe,Zt]=a.useState(null),[Ge,Ce]=a.useState(""),[Jt,Ve]=a.useState("section_a"),[We,Qe]=a.useState("0"),[Ye,Ke]=a.useState("0"),[Xe,Ze]=a.useState("0"),[es,Je]=a.useState("general"),[et,tt]=a.useState("0"),[st,at]=a.useState("0"),[rt,nt]=a.useState("1"),[it,ts]=a.useState(!1),[ot,Se]=a.useState(!1),[ss,as]=a.useState({}),f=cs({queryKey:["partner-profile",s?.id],enabled:!!s?.id,queryFn:async()=>{const{data:t,error:n}=await b.from("profiles").select("is_partner, full_name, partner_business_name, partner_ace_provider_name, partner_ace_provider_number, partner_logo_url, partner_require_feedback, partner_certificate_template_url, partner_signature_url, partner_signatory_name, partner_signatory_title, partner_ace_seal_url").eq("id",s.id).maybeSingle();if(n)throw n;return t}}),ee=cs({queryKey:["partner-sessions",s?.id],enabled:!!s?.id&&!!f.data?.is_partner,queryFn:async()=>{const{data:t,error:n}=await b.from("partner_sessions").select("id, session_title, session_date, hours, status, matched_user_count, drafts_completed_count, pending_signup_count, certificates_issued_count, feedback_received_count, attendee_emails, created_at, sent_at, applies_to_cpbao, applies_to_bacb").eq("partner_id",s.id).order("created_at",{ascending:!1});if(n)throw n;return t??[]}});if(a.useEffect(()=>{f.data&&(At(t=>t||f.data.partner_signatory_name||f.data.full_name||""),Rt(t=>t||f.data.partner_signatory_title||""))},[f.data]),f.isLoading)return e.jsx(Sa,{className:"h-64 w-full"});if(!f.data?.is_partner)return e.jsxs(K,{className:"p-8 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Partner Portal"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This area is for CE provider partners. If you're a CE provider interested in offering pre-filled draft activities to your attendees, please contact us."}),e.jsx(y,{asChild:!0,className:"mt-4",children:e.jsx(la,{to:"/contact",children:"Contact us"})})]});const lt=f.data.partner_business_name||f.data.partner_ace_provider_name||"Partner",rs=t=>t.split(/[\s,;\n]+/).map(n=>n.trim().toLowerCase()).filter(n=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(n)),V=rs($t),ct=async()=>{if(!te.trim()||!se||!I||!le.trim()){m.error("Please fill in title, date, hours, and transcript");return}const t=Number(I);if(!Number.isFinite(t)||t<=0){m.error("Hours must be greater than 0");return}if(!ae&&!re){m.error("Select at least one regulatory body");return}Xt(!0);try{const{data:n,error:d}=await b.functions.invoke("mycpd-partner-extract",{body:{transcript:le.trim(),session_title:te.trim(),session_date:se,hours:t}});if(d)throw d;const c=n.extracted;Ce(c.description??""),Ve(c.cpbao_section||"section_a"),Qe(String(c.ethics_hours??0)),Ke(String(c.edi_hours??0)),Ze(String(c.supervision_hours??0)),Je(c.bacb_content_category||"general"),tt(String(c.bacb_ethics_hours??0)),at(String(c.bacb_supervision_hours??0)),nt(String(c.bacb_general_hours??t)),Mt(!0),r("review"),m.success("AI extraction complete — review and edit before sending")}catch(n){m.error(n.message||"Extraction failed")}finally{Xt(!1)}},Ms=()=>{if(!te.trim()||!se||!I)return m.error("Please fill in title, date and hours"),!1;const t=Number(I);return!Number.isFinite(t)||t<=0?(m.error("Hours must be greater than 0"),!1):!ae&&!re?(m.error("Select at least one regulatory body"),!1):!0},ns=()=>{Ms()&&r("review")},qs=async t=>{if(t.size>10*1024*1024){m.error("File must be 10MB or smaller");return}qt(!0);const n=t.name.split(".").pop()??"pdf",d=`${s.id}/partner-shared/${Date.now()}.${n}`,{error:c}=await b.storage.from("cpd-documents").upload(d,t,{upsert:!0});if(qt(!1),c){m.error(c.message);return}Ue(d),$e(t.name),m.success("Supporting document attached")},Gs=async()=>
1{if(!ye)return;Wt(!0),await b.from("pending_partner_drafts").delete().eq("partner_session_id",ye.id).eq("claimed",!1);const{error:t}=await b.from("partner_sessions").delete().eq("id",ye.id).eq("partner_id",s.id);if(Wt(!1),t){m.error(t.message);return}m.success("Session deleted"),Ne(null),ee.refetch()},Vs=async()=>{if(!Y)return;const t=rs(Qt),n=(Y.attendee_emails??[]).map(c=>c.toLowerCase()),d=t.filter(c=>!n.includes(c));if(d.length===0){m.error("No new email addresses to add");return}Kt(!0);try{const{error:c}=await b.from("partner_sessions").update({attendee_emails:d}).eq("id",Y.id);if(c)throw c;const{data:N,error:O}=await b.functions.invoke("mycpd-partner-send-drafts",{body:{session_id:Y.id}});if(O)throw O;await b.from("partner_sessions").update({attendee_emails:[...n,...d],status:"sent",matched_user_count:(Y.matched_user_count??0)+(N?.matched_user_count??0),pending_signup_count:(Y.pending_signup_count??0)+(N?.pending_signup_count??0)}).eq("id",Y.id),m.success(`Added ${d.length} attendee${d.length===1?"":"s"}`),we(null),Me(""),ee.refetch()}catch(c){m.error(c.message||"Could not add attendees")}finally{Kt(!1)}},dt=()=>{const t=Number(I),n={};for(const d of V){const c=ss[d];if(c==null||c==="")continue;const N=Number(c);!Number.isFinite(N)||N<=0||Math.abs(N-t)<.001||(n[d]=Math.min(N,t))}return{partner_id:s.id,session_title:te.trim(),session_date:se,hours:t,delivery_type:Lt,suggested_description:Ge.trim()||null,suggested_cpbao_section:Jt,suggested_ethics_hours:Number(We)||0,suggested_edi_hours:Number(Ye)||0,suggested_supervision_hours:Number(Xe)||0,suggested_bacb_content_category:es,suggested_bacb_ethics_hours:Number(et)||0,suggested_bacb_supervision_hours:Number(st)||0,suggested_bacb_general_hours:Number(rt)||0,applies_to_cpbao:ae,applies_to_bacb:re,transcript_raw:le.trim()||null,attendee_emails:V,attendee_hours_overrides:n,shared_document_url:Le||null,shared_document_name:ze||null,status:"draft_review"}},is=()=>{if(!re)return!0;const t=Number(I),n=(Number(et)||0)+(Number(st)||0)+(Number(rt)||0);return Math.abs(n-t)>.01?(m.error(`BACB Ethics + Supervision + General must equal ${t} hours`),!1):!0},os=()=>{if(!ae)return!0;const t=Number(I);return(Number(We)||0)>t||(Number(Ye)||0)>t||(Number(Xe)||0)>t?(m.error("CPBAO content hours cannot exceed total hours"),!1):!0},Ws=async()=>{if(!os()||!is())return;ts(!0);const t=dt();let n;if(qe)({error:n}=await b.from("partner_sessions").update(t).eq("id",qe));else{const d=await b.from("partner_sessions").insert(t).select("id").single();n=d.error,d.data?.id&&Zt(d.data.id)}if(ts(!1),n){m.error(n.message);return}m.success("Saved as draft"),ee.refetch()},Qs=async()=>{if(!os()||!is())return;if(V.length===0){m.error("Add at least one valid attendee email");return}Se(!0);let t=qe;if(t){const{error:c}=await b.from("partner_sessions").update(dt()).eq("id",t);if(c){Se(!1),m.error(c.message);return}}else{const c=await b.from("partner_sessions").insert(dt()).select("id").single();if(c.error){Se(!1),m.error(c.error.message);return}t=c.data.id}const{data:n,error:d}=await b.functions.invoke("mycpd-partner-send-drafts",{body:{session_id:t}});if(Se(!1),d){m.error(d.message);return}m.success(`Drafts sent — matched ${n?.matched_user_count??0} member${n?.matched_user_count===1?"":"s"}`),ee.refetch(),Ys()},Ys=()=>{It(""),Ot(wt()),Ft("1"),Ut("in_person_sync"),zt(""),Ht(""),Ce(""),Ve("section_a"),Qe("0"),Ke("0"),Ze("0"),Je("general"),tt("0"),at("0"),nt("1"),Zt(null),as({}),Mt(!1),Fe("ai"),Ue(""),$e(""),r("upload")},$=ee.data??[],ne={sessions:$.length,attendees:$.reduce((t,n)=>t+(n.attendee_emails?.length??0),0),completed:$.reduce((t,n)=>t+(n.drafts_completed_count??0),0),pending:$.reduce((t,n)=>t+(n.pending_signup_count??0),0),certs:$.reduce((t,n)=>t+(n.certificates_issued_count??0),0),feedback:$.reduce((t,n)=>t+(n.feedback_received_count??0),0)},ke=t=>t?k?`${t}${t.includes("?")?"&":"?"}t=${k}`:t:t??void 0,Ks=async t=>{const n=t.target.files?.[0];if(!(!n||!s?.id)){_(!0);try{const d=n.name.split(".").pop()||"png",c=`${s.id}/partner-logo.${d}`,{error:N}=await b.storage.from("avatars").upload(c,n,{upsert:!0,contentType:n.type});if(N)throw N;const{data:O}=b.storage.from("avatars").getPublicUrl(c),{error:P}=await b.from("profiles").update({partner_logo_url:O.publicUrl}).eq("id",s.id);if(P)throw P;m.success("Logo uploaded"),g(Date.now()),await w.invalidateQueries({queryKey:["partner-profile",s.id]}),await f.refetch()}catch(d){m.error(d.message||"Upload failed")}finally{_(!1),M.current&&(M.current.value="")}}},Xs=async t=>{if(!s?.id)return;z(!0);const{error:n}=await b.from("profiles").update({partner_require_feedback:t}).eq("id",s.id);if(z(!1),n){m.error(n.message);return}m.success("Preference saved"),f.refetch()},Zs=async t=>{const n=t.target.files?.[0];if(!(!n||!s?.id)){S(!0);try{const d=n.name.split(".").pop()||"pdf",c=`${s.id}/partner-cert-template.${d}`,{error:N}=await b.storage.from("avatars").upload(c,n,{upsert:!0,contentType:n.type});if(N)throw N;const{data:O}=b.storage.from("avatars").getPublicUrl(c),{error:P}=await b.from("profiles").update({partner_certificate_template_url:O.publicUrl}).eq("id",s.id);if(P)throw P;m.success("Certificate template uploaded"),g(Date.now()),await w.invalidateQueries({queryKey:["partner-profile",s.id]}),await f.refetch()}catch(d){m.error(d.message||"Upload failed")}finally{S(!1),q.current&&(q.current.value="")}}},Js=async t=>{const n=t.target.files?.[0];if(!(!n||!s?.id)){C(!0);try{const d=n.name.split(".").pop()||"png",c=`${s.id}/partner-signature.${d}`,{error:N}=await b.storage.from("avatars").upload(c,n,{upsert:!0,contentType:n.type});if(N)throw N;const{data:O}=b.storage.from("avatars").getPublicUrl(c),{error:P}=await b.from("profiles").update({partner_signature_url:O.publicUrl}).eq("id",s.id);if(P)throw P;m.success("Signature uploaded"),g(Date.now()),await w.invalidateQueries({queryKey:["partner-profile",s.id]}),await f.refetch()}catch(d){m.error(d.message||"Upload failed")}finally{C(!1),X.current&&(X.current.value="")}}},ea=async t=>{const n=t.target.files?.[0];if(!(!n||!s?.id)){R(!0);try{const d=n.name.split(".").pop()||"png",c=`${s.id}/partner-ace-seal.${d}`,{error:N}=await b.storage.from("avatars").upload(c,n,{upsert:!0,contentType:n.type});if(N)throw N;const{data:O}=b.storage.from("avatars").getPublicUrl(c),{error:P}=await b.from("profiles").update({partner_ace_seal_url:O.publicUrl}).eq("id",s.id);if(P)throw P;m.success("ACE Provider seal uploaded"),g(Date.now()),await w.invalidateQueries({queryKey:["partner-profile",s.id]}),await f.refetch()}catch(d){m.error(d.message||"Upload failed")}finally{R(!1),Z.current&&(Z.current.value="")}}},ta=async()=>
1{if(!s?.id)return;Q(!0);const{error:t}=await b.from("profiles").update({partner_signatory_name:Pt.trim()||null,partner_signatory_title:Dt.trim()||null}).eq("id",s.id);if(Q(!1),t){m.error(t.message);return}m.success("Signatory saved"),f.refetch()},sa=t=>{je("selected"),Ie(new Set([t])),ge(!0)},aa=async()=>{if(s?.id){ve(!0);try{let t=$,n;if(be==="selected"){if(Be.size===0){m.error("Select at least one session"),ve(!1);return}t=$.filter(h=>Be.has(h.id)),n=`${t.length}_sessions`}else{if(!fe||!_e){m.error("Pick a date range"),ve(!1);return}t=$.filter(h=>h.session_date>=fe&&h.session_date<=_e),n=`${fe}_to_${_e}`}const d=t.map(h=>h.id),[c,N,O,P]=await Promise.all([d.length?b.from("partner_session_feedback").select("partner_session_id, attendee_email, feedback_rating, feedback_text, submitted_at").in("partner_session_id",d):Promise.resolve({data:[],error:null}),d.length?b.from("partner_certificates").select("partner_session_id, attendee_email, ceu_hours_certified, issued_at").in("partner_session_id",d):Promise.resolve({data:[],error:null}),d.length?b.from("pending_partner_drafts").select("partner_session_id, attendee_email, claimed").in("partner_session_id",d).eq("claimed",!1):Promise.resolve({data:[],error:null}),d.length?b.from("partner_sessions").select("id, suggested_bacb_ethics_hours, suggested_bacb_supervision_hours, suggested_bacb_general_hours, suggested_ethics_hours, suggested_edi_hours, suggested_supervision_hours").in("id",d):Promise.resolve({data:[],error:null})]);if(c.error)throw c.error;if(N.error)throw N.error;if(O.error)throw O.error;if(P.error)throw P.error;const ut=new Map;for(const h of c.data??[]){const A=ut.get(h.partner_session_id)??[];A.push({attendee_email:h.attendee_email,feedback_rating:h.feedback_rating,feedback_text:h.feedback_text,submitted_at:h.submitted_at}),ut.set(h.partner_session_id,A)}const pt=new Map;for(const h of N.data??[]){const A=pt.get(h.partner_session_id)??[];A.push({attendee_email:h.attendee_email,ceu_hours_certified:h.ceu_hours_certified,issued_at:h.issued_at}),pt.set(h.partner_session_id,A)}const mt=new Map;for(const h of O.data??[]){const A=mt.get(h.partner_session_id)??[];A.push({attendee_email:h.attendee_email}),mt.set(h.partner_session_id,A)}const ls=new Map;for(const h of P.data??[])ls.set(h.id,h);const ra=t.map(h=>{const A=ls.get(h.id);return{id:h.id,session_title:h.session_title,session_date:h.session_date,hours:h.hours,applies_to_cpbao:h.applies_to_cpbao,applies_to_bacb:h.applies_to_bacb,suggested_bacb_ethics_hours:A?.suggested_bacb_ethics_hours,suggested_bacb_supervision_hours:A?.suggested_bacb_supervision_hours,suggested_bacb_general_hours:A?.suggested_bacb_general_hours,suggested_ethics_hours:A?.suggested_ethics_hours,suggested_edi_hours:A?.suggested_edi_hours,suggested_supervision_hours:A?.suggested_supervision_hours,attendee_emails:h.attendee_emails,feedback:ut.get(h.id)??[],certificates:pt.get(h.id)??[],pending:mt.get(h.id)??[]}});await ur({partner_name:lt,ace_provider_name:f.data?.partner_ace_provider_name??null,ace_provider_number:f.data?.partner_ace_provider_number??null,date_range_label:n,generated_at:new Date().toISOString().slice(0,16).replace("T"," "),include_feedback_text:Bt,sessions:ra}),m.success("Audit export generated"),ge(!1)}catch(t){m.error(t.message||"Export failed")}finally{ve(!1)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{className:"p-6 text-center",children:[f.data?.partner_logo_url?e.jsx("img",{src:ke(f.data.partner_logo_url),alt:`${lt} logo`,className:"mx-auto max-h-20 w-auto object-contain"}):e.jsx("div",{className:"mx-auto h-20 flex items-center justify-center",children:e.jsx(Ee,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"mt-3 text-2xl font-semibold",children:lt}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Partner Portal"})]}),e.jsx(bs,{delayDuration:150,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[{label:"Total Sessions Hosted",value:ne.sessions,tip:null},{label:"Total Attendees Reached",value:ne.attendees,tip:null},{label:"Drafts Completed",value:ne.completed,tip:null},{label:"Pending Sign-ups",value:ne.pending,tip:"Attendees who haven't created a myCPD account yet. They'll receive their session automatically once they sign up with the email you provided."},{label:"Certificates Issued",value:ne.certs,tip:"Number of BACB CEU certificates generated for this session's attendees."},{label:"Feedback Received",value:ne.feedback,tip:null}].map(t=>e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"text-xs uppercase tracking-wide text-muted-foreground flex items-center gap-1",children:[e.jsx("span",{children:t.label}),t.tip&&e.jsxs(js,{children:[e.jsx(vs,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground","aria-label":`About ${t.label}`,children:e.jsx(Fa,{className:"h-3.5 w-3.5"})})}),e.jsx(kt,{className:"max-w-xs text-xs",children:t.tip})]})]}),e.jsx("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:t.value})]},t.label))})}),e.jsxs(K,{className:"p-5 md:p-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Audit records"}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-prose",children:"BACB requires ACE Providers to retain event records for 5 years. Use this export to keep organized backups."})]}),e.jsxs(_t,{open:Os,onOpenChange:ge,children:[e.jsx(va,{asChild:!0,children:e.jsxs(y,{variant:"outline",className:"gap-2",onClick:()=>{je("range"),Ie(new Set)},children:[e.jsx(xs,{className:"h-4 w-4"})," Export Audit Records"]})}),e.jsxs(bt,{className:"max-w-lg",children:[e.jsxs(jt,{children:[e.jsx(vt,{children:"Export audit records"}),e.jsx(yt,{children:"Generate a PDF of session records, attendees, certificates, and feedback."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{type:"button",size:"sm",variant:be==="range"?"default":"outline",onClick:()=>je("range"),children:"By date range"}),e.jsx(y,{type:"button",size:"sm",variant:be==="selected"?"default":"outline",onClick:()=>je("selected"),children:"Pick sessions"})]}),be==="range"?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{htmlFor:"export-from",children:"From"}),e.jsx(D,{id:"export-from",type:"date",className:"text-base",value:fe,onChange:t=>Fs(t.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{htmlFor:"export-to",children:"To"}),e.jsx(D,{id:"export-to",type:"date",className:"text-base",value:_e,onChange:t=>Ls(t.target.value)})]})]}):e.jsxs("div",{className:"max-h-64 overflow-y-auto rounded border p-2 space-y-1",children:[$.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground p-2",children:"No sessions yet."}),$.map(t=>e.jsxs("label",{className:"flex items-center gap-2 text-sm py-1 px-1 hover:bg-muted/40 rounded cursor-pointer",children:[e.jsx(Te,{checked:Be.has(t.id),onCheckedChange:n=>{Ie(d=>{const c=new Set(d);return n?c.add(t.id):c.delete(t.id),c})}}),e.jsx("span",{className:"flex-1 truncate",children:t.session_title}),e.jsx("span",{className:"text-xs text-muted-foreground",children:hs(t.session_date)})]},t.id))]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm pt-2 border-t",children:[e.jsx(Te,{checked:Bt,onCheckedChange:t=>Us(!!t),className:"mt-0.5"}),e.jsxs("span",{children:["Include full feedback text",e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Off = show only rating distribution counts."})]})]})]}),e.jsxs(Nt,{children:[e.jsx(y,{variant:"outline",onClick:()=>ge(!1),disabled:Oe,children:"Cancel"}),e.jsxs(y,{onClick:aa,disabled:Oe,className:"gap-2",children:[Oe?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(xs,{className:"h-4 w-4"}),"Generate Export"]})]})]})]})]}),e.jsx(K,{className:"overflow-hidden",children:e.jsxs(Ta,{open:l,onOpenChange:i,children:[e.jsx(Ea,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center justify-between p-5 md:p-6 text-left hover:bg-muted/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-semibold",children:"Settings"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l?"Hide":"Show"})]})}),e.jsx(Pa,{children:e.jsxs("div",{className:"p-5 md:p-6 pt-0 space-y-5 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Partner logo"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f.data?.partner_logo_url&&e.jsx("img",{src:ke(f.data.partner_logo_url),alt:"Current logo",className:"h-12 w-auto object-contain rounded border bg-white p-1"}),e.jsx("input",{ref:M,type:"file",accept:"image/*",onChange:Ks,className:"hidden"}),e.jsxs(y,{variant:"outline",onClick:()=>M.current?.click(),disabled:p,className:"gap-2",children:[p?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),f.data?.partner_logo_url?"Replace logo":"Upload logo"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown at the top of your Partner Portal and (soon) on attendee certificates."})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t",children:[e.jsx(j,{children:"Signature & signatory"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f.data?.partner_signature_url&&e.jsx("img",{src:ke(f.data.partner_signature_url),alt:"Current signature",className:"h-14 w-auto object-contain rounded border bg-white p-1"}),e.jsx("input",{ref:X,type:"file",accept:"image/png,image/jpeg,image/*",onChange:Js,className:"hidden"}),e.jsxs(y,{variant:"outline",onClick:()=>X.current?.click(),disabled:T,className:"gap-2",children:[T?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),f.data?.partner_signature_url?"Replace signature":"Upload signature"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG with a transparent background works best."}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"sig-name",children:"Signatory name"}
1),e.jsx(D,{id:"sig-name",className:"text-base",value:Pt,onChange:t=>At(t.target.value),placeholder:"Full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"sig-title",children:"Signatory title / credentials"}),e.jsx(D,{id:"sig-title",className:"text-base",value:Dt,onChange:t=>Rt(t.target.value),placeholder:"e.g., RBA(Ont.), BCBA"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(y,{onClick:ta,disabled:L,size:"sm",className:"gap-2",children:[L?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(fs,{className:"h-4 w-4"}),"Save signatory"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This signature and name will appear on certificates issued to your session attendees."})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx(j,{children:"ACE Provider seal"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f.data?.partner_ace_seal_url&&e.jsx("img",{src:ke(f.data.partner_ace_seal_url),alt:"Current ACE seal",className:"h-16 w-16 object-contain rounded border bg-white p-1"}),e.jsx("input",{ref:Z,type:"file",accept:"image/png,image/jpeg,image/webp",onChange:ea,className:"hidden"}),e.jsxs(y,{variant:"outline",onClick:()=>Z.current?.click(),disabled:E,className:"gap-2",children:[E?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),f.data?.partner_ace_seal_url?"Replace seal":"Upload seal"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-prose",children:'Optional — small circular seal/badge (PNG with transparent background recommended) that appears in the top-right of issued certificates. If not uploaded, a text-based "ACE PROVIDER" placeholder is used.'}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-prose border-l-2 border-amber-400 pl-3 mt-2",children:"By uploading an image here, you confirm that you are an Authorized Continuing Education (ACE) Provider in good standing with the BACB and that you have the right to use this seal on certificates you issue. You are solely responsible for the accuracy and authorized use of this image. myCPD does not verify ACE Provider status and is not responsible for misuse of this seal."})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx(j,{children:"Certificate template"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f.data?.partner_certificate_template_url&&e.jsxs("a",{href:f.data.partner_certificate_template_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-sm text-primary underline",children:[e.jsx(gs,{className:"h-4 w-4"})," View current"]}),e.jsx("input",{ref:q,type:"file",accept:"application/pdf,image/*",onChange:Zs,className:"hidden"}),e.jsxs(y,{variant:"outline",onClick:()=>q.current?.click(),disabled:v,className:"gap-2",children:[v?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),f.data?.partner_certificate_template_url?"Replace template":"Upload template"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-prose",children:"Optional — upload your certificate template (PDF or image). Make sure it includes the current BACB ACE logo (required as of late 2025). If not provided, myCPD will use a standard certificate layout."})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{htmlFor:"require-feedback",children:"Require feedback before certificate issuance"}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-prose",children:"BACB requires offering attendees the chance to give feedback. This toggle makes it required before their certificate is issued — your choice."})]}),e.jsx(ka,{id:"require-feedback",checked:!!f.data?.partner_require_feedback,onCheckedChange:Xs,disabled:B})]})]})})]})}),o==="upload"&&e.jsxs(K,{className:"p-5 md:p-6 space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Upload session"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Session title"}),e.jsx(D,{id:"title",className:"text-base",value:te,onChange:t=>It(t.target.value),placeholder:"e.g. Ethics in Supervision Workshop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"date",children:"Session date"}),e.jsx(D,{id:"date",type:"date",className:"text-base",value:se,onChange:t=>Ot(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"hours",children:"Total hours"}),e.jsx(D,{id:"hours",type:"number",step:"0.25",min:"0.25",className:"text-base",value:I,onChange:t=>Ft(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"delivery",children:"Delivery type"}),e.jsxs(ht,{value:Lt,onValueChange:Ut,children:[e.jsx(xt,{id:"delivery",className:"text-base",children:e.jsx(gt,{})}),e.jsxs(ft,{children:[e.jsx(G,{value:"in_person_sync",children:"In-Person (Synchronous)"}),e.jsx(G,{value:"online_sync",children:"Online (Synchronous)"}),e.jsx(G,{value:"online_async",children:"Online (Asynchronous)"}),e.jsx(G,{value:"hybrid",children:"Hybrid"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Applies to"}),e.jsxs("div",{className:"flex items-center gap-5 h-10",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Te,{checked:ae,onCheckedChange:t=>zs(!!t)})," CPBAO"]}
1),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Te,{checked:re,onCheckedChange:t=>$s(!!t)})," BACB"]})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(y,{type:"button",variant:ce==="ai"?"default":"outline",size:"sm",onClick:()=>Fe("ai"),children:"Use AI extraction"}),e.jsx(y,{type:"button",variant:ce==="manual"?"default":"outline",size:"sm",onClick:()=>Fe("manual"),children:"Enter manually"})]}),ce==="ai"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"transcript",children:"Session transcript (optional)"}),e.jsx(de,{id:"transcript",rows:10,className:"text-base",value:le,onChange:t=>zt(t.target.value),placeholder:"Paste the session transcript here. The AI will use it to extract topic categorization, ethics/supervision content, and a description."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste your session transcript for AI-powered extraction of session details. Or choose “Enter manually” to fill in the details yourself."})]}),ce==="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"manual-desc",children:"Session description"}),e.jsx(de,{id:"manual-desc",rows:4,className:"text-base",value:Ge,onChange:t=>Ce(t.target.value),placeholder:"Describe the session content for attendees."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No AI call is made. You'll set the CPBAO section, content hours and BACB breakdown on the next step."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"emails",children:"Attendee emails"}),e.jsx(de,{id:"emails",rows:4,className:"text-base",value:$t,onChange:t=>Ht(t.target.value),placeholder:`One per line or comma-separated
2[email protected]
3[email protected]`}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[V.length," valid email",V.length===1?"":"s"," detected"]})]}),e.jsx("div",{className:"flex flex-col sm:flex-row justify-end gap-3",children:ce==="manual"?e.jsx(y,{onClick:ns,size:"lg",className:"gap-2",children:"Continue to review"}):Hs?e.jsxs(e.Fragment,{children:[e.jsxs(y,{variant:"outline",onClick:ct,disabled:J,className:"gap-2",children:[J?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(Ee,{className:"h-4 w-4"}),"Re-analyze"]}),e.jsx(y,{onClick:ns,size:"lg",className:"gap-2",children:"Continue to review"})]}):e.jsxs(y,{onClick:ct,disabled:J,size:"lg",className:"gap-2",children:[J?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(Ee,{className:"h-4 w-4"}),J?"Analyzing transcript…":"Analyze with AI"]})})]}),o==="review"&&e.jsxs(K,{className:"p-5 md:p-6 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Review session details"}),e.jsxs("div",{className:"flex items-center gap-2",children:[le.trim()&&e.jsxs(y,{variant:"outline",size:"sm",onClick:ct,disabled:J,className:"gap-1",children:[J?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(Ee,{className:"h-4 w-4"}),"Re-analyze"]}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>r("upload"),className:"gap-1",children:[e.jsx(Ia,{className:"h-4 w-4"})," Back"]})]})]}),e.jsxs("div",{className:"rounded-md bg-muted/40 p-3 text-sm",children:[e.jsx("strong",{children:te})," · ",se," · ",I," hours · ",V.length," attendee",V.length===1?"":"s"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"desc",children:"Description"}),e.jsx(de,{id:"desc",rows:3,className:"text-base",value:Ge,onChange:t=>Ce(t.target.value)})]}),ae&&e.jsxs("div",{className:"border rounded-md p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"CPBAO suggestion"}),e.jsxs("div",{className:"grid md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-1",children:[e.jsx(j,{children:"Section"}),e.jsxs(ht,{value:Jt,onValueChange:Ve,children:[e.jsx(xt,{className:"text-base",children:e.jsx(gt,{})}),e.jsxs(ft,{children:[e.jsx(G,{value:"section_a",children:"Section A"}),e.jsx(G,{value:"section_b",children:"Section B"}),e.jsx(G,{value:"section_c",children:"Section C"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Ethics hrs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:We,onChange:t=>Qe(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"EDI hrs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:Ye,onChange:t=>Ke(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Supervision hrs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:Xe,onChange:t=>Ze(t.target.value)})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Each content hour ≤ total (",I,"). Content hours can overlap."]})]}),re&&e.jsxs("div",{className:"border rounded-md p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"BACB suggestion"}),e.jsxs("div",{className:"grid md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-1",children:[e.jsx(j,{children:"Primary content"}),e.jsxs(ht,{value:es,onValueChange:Je,children:[e.jsx(xt,{className:"text-base",children:e.jsx(gt,{})}),e.jsxs(ft,{children:[e.jsx(G,{value:"ethics",children:"Ethics"}),e.jsx(G,{value:"supervision",children:"Supervision"}),e.jsx(G,{value:"general",children:"General"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Ethics CEUs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:et,onChange:t=>tt(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Supervision CEUs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:st,onChange:t=>at(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"General CEUs"}),e.jsx(D,{type:"number",step:"0.25",min:"0",className:"text-base",value:rt,onChange:t=>nt(t.target.value)})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Ethics + Supervision + General must equal ",I,"."]})]}),V.length>0&&e.jsxs("div",{className:"border rounded-md p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Per-attendee hours (optional)"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Defaults to the full session hours (",I,"). Lower an attendee's hours if they only attended part of the session — their certificate and draft will use the reduced amount."]})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded border",children:e.jsxs(us,{children:[e.jsx(ps,{children:e.jsxs(ue,{children:[e.jsx(H,{children:"Attendee email"}),e.jsx(H,{className:"w-32 text-right",children:"Hours"})]})}),e.jsx(ms,{children:V.map(t=>e.jsxs(ue,{children:[e.jsx(U,{className:"text-sm truncate",children:t}),e.jsx(U,{className:"text-right",children:e.jsx(D,{type:"number",step:"0.25",min:"0",max:I,className:"text-base h-9 w-24 ml-auto text-right",placeholder:I,value:ss[t]??"",onChange:n=>as(d=>({...d,[t]:n.target.value}))})})]},t))})]})})]}),e.jsxs("div",{className:"border rounded-md p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Attach supporting document for attendees (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a PDF, PNG or JPEG (max 10MB), or paste a link to an externally hosted resource. It will appear on each attendee's Documents page."})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Upload file"}),e.jsx("input",{ref:Gt,type:"file",accept:".pdf,.png,.jpg,.jpeg",className:"hidden",onChange:t=>{const n=t.target.files?.[0];n&&qs(n),t.target.value=""}}),e.jsxs(y,{type:"button",variant:"outline",className:"gap-2",disabled:He,onClick:()=>Gt.current?.click(),children:[He?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),He?"Uploading…":"Choose file"]}),ze&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(gs,{className:"h-3 w-3"})," ",ze]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"shared-doc-url",children:"Or link (URL)"}),e.jsx(D,{id:"shared-doc-url",className:"text-base",placeholder:"https://…",value:/^https?:\/\//i.test(Le)?Le:"",onChange:t=>{Ue(t.target.value),$e(n=>n||"Provider resource link")}})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-end gap-3 pt-2",children:[e.jsxs(y,{variant:"outline",onClick:Ws,disabled:it||ot,className:"gap-2",children:[it?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(fs,{className:"h-4 w-4"}),"Save as draft"]}),e.jsxs(y,{onClick:Qs,disabled:it||ot,size:"lg",className:"gap-2",children:[ot?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(_s,{className:"h-4 w-4"}),"Send to members"]})]})]}),e.jsxs(K,{className:"p-0 overflow-hidden",children:[e.jsxs("div",{className:"p-5 md:p-6 border-b",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Session history"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Past partner sessions you've uploaded."})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(us,{children:[e.jsx(ps,{children:e.jsxs(ue,{children:[e.jsx(H,{children:"Date"}),e.jsx(H,{children:"Title"}),e.jsx(H,{children:"Status"}),e.jsx(H,{className:"text-right",children:"Matched"}),e.jsx(H,{className:"text-right",children:"Completed"}),e.jsx(H,{className:"text-right",children:"Pending sign-ups"}),e.jsx(H,{className:"text-right",children:"Certificates"}),e.jsx(H,{className:"text-right",children:"Feedback"}),e.jsx(H,{className:"text-right",children:"Audit"})]})}
3),e.jsxs(ms,{children:[(ee.data??[]).map(t=>{const n=t.certificates_issued_count??0;return e.jsxs(ue,{children:[e.jsx(U,{className:"whitespace-nowrap",children:hs(t.session_date)}),e.jsx(U,{className:"font-medium",children:t.session_title}),e.jsx(U,{children:t.status==="sent"?e.jsx(ds,{className:"bg-emerald-100 text-emerald-800 border-emerald-200",children:"Sent"}):e.jsx(ds,{variant:"outline",children:"Draft"})}),e.jsx(U,{className:"text-right tabular-nums",children:t.matched_user_count??0}),e.jsx(U,{className:"text-right tabular-nums",children:t.drafts_completed_count??0}),e.jsx(U,{className:"text-right tabular-nums",children:t.pending_signup_count??0}),e.jsx(U,{className:"text-right tabular-nums",children:e.jsxs("span",{className:"inline-flex items-center gap-1 justify-end",children:[n>0&&e.jsx(Da,{className:"h-4 w-4 text-emerald-600","aria-label":"Certificates issued"}),n]})}),e.jsx(U,{className:"text-right tabular-nums",children:t.feedback_received_count??0}),e.jsx(U,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>sa(t.id),className:"text-xs text-primary hover:underline",children:"View audit trail"}),t.status==="sent"&&e.jsx("button",{type:"button",onClick:()=>{we(t),Me("")},className:"text-xs text-primary hover:underline",children:"Add missed attendees"}),e.jsx(bs,{children:e.jsxs(js,{children:[e.jsx(vs,{asChild:!0,children:e.jsx("span",{children:e.jsx(y,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:t.status==="sent","aria-label":"Delete session",onClick:()=>Ne(t),children:e.jsx(Ra,{className:"h-4 w-4"})})})}),e.jsx(kt,{children:t.status==="sent"?"Sent sessions cannot be deleted as activities have already been created for attendees.":"Delete this draft session"})]})})]})})]},t.id)}),(ee.data??[]).length===0&&e.jsx(ue,{children:e.jsx(U,{colSpan:9,className:"text-center text-sm text-muted-foreground py-12",children:"No sessions yet. Upload your first session transcript above to get started."})})]})]})})]}),e.jsx(_t,{open:!!ye,onOpenChange:t=>!t&&Ne(null),children:e.jsxs(bt,{children:[e.jsxs(jt,{children:[e.jsx(vt,{children:"Delete this session?"}),e.jsx(yt,{children:"This cannot be undone."})]}),e.jsxs(Nt,{children:[e.jsx(y,{variant:"outline",onClick:()=>Ne(null),children:"Cancel"}),e.jsxs(y,{variant:"destructive",onClick:Gs,disabled:Vt,className:"gap-2",children:[Vt&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Delete"]})]})]})}),e.jsx(_t,{open:!!Y,onOpenChange:t=>!t&&we(null),children:e.jsxs(bt,{children:[e.jsxs(jt,{children:[e.jsx(vt,{children:"Add missed attendees"}),e.jsx(yt,{children:"Drafts are created only for the new addresses below — attendees already on this session are skipped."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"add-emails",children:"Add email addresses"}),e.jsx(de,{id:"add-emails",rows:4,className:"text-base",value:Qt,onChange:t=>Me(t.target.value),placeholder:"One per line or comma-separated"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"To correct hours or content for existing attendees, use the per-attendee override on a new session entry."})]}),e.jsxs(Nt,{children:[e.jsx(y,{variant:"outline",onClick:()=>we(null),children:"Cancel"}),e.jsxs(y,{onClick:Vs,disabled:Yt,className:"gap-2",children:[Yt?e.jsx(F,{className:"h-4 w-4 animate-spin"}):e.jsx(_s,{className:"h-4 w-4"}),"Send"]})]})]})})]})}export{Mr as component};

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.