1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3142],{3142:(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});var n=i(95155),l=i(12115),a=i(68209),r=i(4373);let s={card:{...r.f.card,background:r.C.card,border:"1px solid ".concat(r.C.border),marginBottom:16},btn:{...r.f.btn,border:"none",cursor:"pointer"},btnPrimary:{background:r.C.accent,color:"#fff"},btnGhost:{background:"transparent",border:"1px solid ".concat(r.C.border),color:r.C.muted},btnSm:{...r.f.btnSm},input:{...r.f.input,width:"100%",padding:"11px 14px",background:r.C.inputBg,border:"1px solid ".concat(r.C.border),color:r.C.text,outline:"none",boxSizing:"border-box",minHeight:44},label:{...r.f.label,display:"block"},badge:{...r.f.badge,display:"inline-block",padding:"3px 10px"}};function o(e){var t;let{mobile:i,orgId:o,studies:d}=e,[c,u]=(0,l.useState)([]),[p,h]=(0,l.useState)(!0),[g,m]=(0,l.useState)(!1),[y,x]=(0,l.useState)(""),[b,f]=(0,l.useState)([]),[j,v]=(0,l.useState)(!1),[C,S]=(0,l.useState)(!1),[k,I]=(0,l.useState)(!1),[P,w]=(0,l.useState)(""),[N,T]=(0,l.useState)(!1),z=!!o&&(null!=(t=null==d?void 0:d.length)?t:0)>0,[A,B]=(0,l.useState)(!1),[R,E]=(0,l.useState)(""),[D,_]=(0,l.useState)("PRIMARY_PI"),[O,F]=(0,l.useState)(""),[L,G]=(0,l.useState)([]),[Y,W]=(0,l.useState)(!1),[H,V]=(0,l.useState)(!1),[q,M]=(0,l.useState)(null),[U,J]=(0,l.useState)(null),[K,$]=(0,l.useState)({name:"",email:"",npiNumber:"",specialty:"",licenseNumber:""}),[Q,X]=(0,l.useState)([]),Z=e=>{w(e),setTimeout(()=>w(""),3500)},ee=(0,l.useCallback)(async()=>{try{let e=await (0,a.apiFetch)("/api/orgs/pis"),t=await e.json();u(Array.isArray(t)?t:[])}catch(e){}h(!1)},[]);(0,l.useEffect)(()=>{ee()},[ee]);let et=(0,l.useCallback)(async()=>{if(y.trim()){v(!0),S(!0);try{var e;let t=/^\d{5,10}$/.test(y.trim())?"npi=".concat(y.trim()):"q=".concat(encodeURIComponent(y.trim())),i=await (0,a.apiFetch)("/api/orgs/pis/search?".concat(t)),n=await i.json();f(null!=(e=n.results)?e:[])}catch(e){f([])}v(!1)}},[y]),ei=async e=>{T(!0);try{let i=await (0,a.apiFetch)("/api/orgs/pis/link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"link",piId:e})}),n=await i.json();if(!i.ok){var t;Z(null!=(t=n.error)?t:"Link failed"),T(!1);return}Z("PI linked successfully"),m(!1),x(""),f([]),S(!1),ee()}catch(e){Z("Link failed")}T(!1)},en=async()=>{if(!K.name.trim()||!K.email.trim())return void Z("Name and email are required");T(!0);try{let i=await (0,a.apiFetch)("/api/orgs/pis/link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create-pending",...K})}),n=await i.json();if(!i.ok){var e,t;n.existingPi?Z("PI already exists at ".concat(null!=(e=n.existingPi.orgName)?e:"another org"," â use Link instead")):Z(null!=(t=n.error)?t:"Create failed"),T(!1);return}Z("PI created â verification invitation sent"),m(!1),I(!1),$({name:"",email:"",npiNumber:"",specialty:"",licenseNumber:""}),ee()}catch(e){Z("Create failed")}T(!1)},el=(0,l.useCallback)(async e=>{if(e.length<2)return void X([]);try{let t=await (0,a.apiFetch)("/api/npi-lookup?q=".concat(encodeURIComponent(e))),i=((await t.json()).results||[]).map(e=>({npi:e.npi,type:e.specialty||"",name:"".concat(e.lastName,", ").concat(e.firstName),address:[e.address,e.city,e.state].filter(Boolean).join(", ")}));X(i)}catch(e){X([])}},[]),ea=async e=>{try{await (0,a.apiFetch)("/api/orgs/pis?id=".concat(e),{method:"DELETE"}),Z("PI removed"),ee()}catch(e){Z("Remove failed")}},er=(0,l.useCallback)(async(e,t)=>{var i,n;if(!e||!o)return void G([]);W(!0),M(null);try{let n=await (0,a.apiFetch)("/api/studies/".concat(e,"/sites/").concat(o,"/investigators?candidates=1&limit=20&q=").concat(encodeURIComponent(t))),l=await n.json().catch(()=>({}));G((null!=(i=l.candidates)?i:[]).filter(e=>e.id))}catch(e){M(null!=(n=null==e?void 0:e.message)?n:"Search failed")}finally{W(!1)}},[o]),es=async(e,t)=>{var i,n,l,r;if(R&&o){V(!0),M(null);try{let r=await (0,a.apiFetch)("/api/studies/".concat(R,"/sites/").concat(o,"/investigators"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,role:D})}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(null!=(i=null==s?void 0:s.error)?i:"HTTP ".concat(r.status));J({name:t,creds:null!=(n=s.credentialRequestsCreated)?n:[],docs:null!=(l=s.studyDocumentsCreated)?l:[]}),Z("".concat(t," assigned as ").concat(D.replace(/_/g," ").toLowerCase())),er(R,O)}catch(e){M(null!=(r=null==e?void 0:e.message)?r:"Assign failed")}finally{V(!1)}}},eo=e=>"ACTIVE"===e?r.C.green:"PENDING_VERIFICATION"===e?"#f59e0b":r.C.muted;return(0,n.jsxs)("div",{children:[P&&(0,n.jsx)("div",{style:{position:"fixed",top:20,right:20,background:r.C.card,border:"1px solid ".concat((0,r.u)(r.C.accent,27)),borderRadius:10,padding:"12px 20px",fontSize:13,color:r.C.text,zIndex:999,boxShadow:"0 4px 20px rgba(0,0,0,0.4)"},children:P}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:18,fontWeight:700,color:r.C.text},children:"Principal Investigators"}),(0,n.jsx)("div",{style:{fontSize:12,color:r.C.muted,marginTop:2},children:"Manage PIs associated with your site"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[z&&(0,n.jsx)("button",{onClick:()=>{var e,t;
1let i=null!=(t=null==d||null==(e=d[0])?void 0:e.id)?t:"";B(!0),M(null),J(null),_("PRIMARY_PI"),F(""),E(i),i&&er(i,"")},style:{...s.btn,...s.btnPrimary},children:"Assign to a Study"}),(0,n.jsx)("button",{onClick:()=>{m(!0),S(!1),x(""),f([]),I(!1)},style:{...s.btn,...z?s.btnGhost:s.btnPrimary},children:"+ Add PI"})]})]}),(0,n.jsxs)("div",{style:{...s.card,background:(0,r.u)(r.C.accent,5),borderColor:(0,r.u)(r.C.accent,20),display:"flex",gap:12,alignItems:"flex-start",padding:14},children:[(0,n.jsx)("div",{style:{fontSize:18,lineHeight:1},children:"\uD83D\uDCA1"}),(0,n.jsxs)("div",{style:{fontSize:12,color:r.C.muted,lineHeight:1.5},children:["This is your siteâs ",(0,n.jsx)("strong",{style:{color:r.C.text},children:"investigator directory"})," â the people who work at your site. To put an investigator ",(0,n.jsx)("strong",{style:{color:r.C.text},children:"on a specific study"})," (which opens their study binder and starts tracking their CV, medical license, GCP, DEA & board certification with expiration reminders, plus the FDA 1572/3454/3455), use ",(0,n.jsx)("strong",{style:{color:r.C.text},children:z?"Assign to a Study":"Investigators in the studyâs Regulatory Binder"}),z?" above":"",". Anyone on your siteâs team can be linked â no separate profile needed."]})]}),p?(0,n.jsx)("div",{style:{...s.card,textAlign:"center",padding:40,color:r.C.muted},children:"Loading..."}):0===c.length?(0,n.jsxs)("div",{style:{...s.card,textAlign:"center",padding:40},children:[(0,n.jsx)("div",{style:{fontSize:32,marginBottom:8},children:"\uD83D\uDC64"}),(0,n.jsx)("div",{style:{color:r.C.muted,fontSize:13},children:'No PIs added yet. Click "Add PI" to search and link or create a PI.'})]}):(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:i?"1fr":"repeat(auto-fill, minmax(320px, 1fr))",gap:12},children:c.map(e=>(0,n.jsxs)("div",{style:s.card,children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:15,fontWeight:700,color:r.C.text},children:e.name}),e.specialty&&(0,n.jsx)("div",{style:{fontSize:12,color:r.C.muted,marginTop:2},children:e.specialty})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[(0,n.jsx)("span",{style:{...s.badge,background:"".concat(eo(e.status),"22"),color:eo(e.status),border:"1px solid ".concat(eo(e.status),"44")},children:"PENDING_VERIFICATION"===e.status?"PENDING":e.status}),e.isPrimary&&(0,n.jsx)("span",{style:{...s.badge,background:"#8b5cf622",color:"#a78bfa",border:"1px solid #8b5cf644"},children:"PRIMARY"})]})]}),(0,n.jsxs)("div",{style:{marginTop:10,display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[e.npiNumber&&(0,n.jsxs)("div",{style:{fontSize:11,color:r.C.muted},children:["NPI: ",(0,n.jsx)("span",{style:{color:r.C.text},children:e.npiNumber})]}),e.email&&(0,n.jsxs)("div",{style:{fontSize:11,color:r.C.muted},children:["Email: ",(0,n.jsx)("span",{style:{color:r.C.text},children:e.email})]}),e.licenseNumber&&(0,n.jsxs)("div",{style:{fontSize:11,color:r.C.muted},children:["License: ",(0,n.jsx)("span",{style:{color:r.C.text},children:e.licenseNumber})]})]}),(0,n.jsx)("div",{style:{marginTop:10,display:"flex",gap:6},children:(0,n.jsx)("button",{onClick:()=>ea(e.id),style:{...s.btn,...s.btnSm,background:"#ef444422",border:"1px solid #ef444444",color:"#f87171"},children:"Remove"})})]},e.id))}),g&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",display:"flex",alignItems:i?"flex-end":"center",justifyContent:"center",zIndex:100},onClick:()=>m(!1),children:(0,n.jsxs)("div",{style:{background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:i?"14px 14px 0 0":14,padding:i?"24px 20px":32,width:i?"100%":560,maxHeight:"90vh",overflowY:"auto"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{style:{fontSize:17,fontWeight:700,color:r.C.text,marginBottom:4},children:"Add Principal Investigator"}),(0,n.jsx)("div",{style:{fontSize:12,color:r.C.muted,marginBottom:16},children:"Search for an existing PI on the platform first. If not found, create a new profile."}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:12},children:[(0,n.jsx)("input",{value:y,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&et(),placeholder:"Search by name, email, or NPI...",style:{...s.input,flex:1}}),(0,n.jsx)("button",{onClick:et,disabled:j,style:{...s.btn,...s.btnPrimary,whiteSpace:"nowrap"},children:j?"Searching...":"Search"})]}),C&&(0,n.jsxs)("div",{style:{marginBottom:16},children:[b.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{fontSize:12,color:r.C.muted,marginBottom:8},children:[b.length," PI(s) found on the platform:"]}),b.map(e=>(0,n.jsxs)("div",{style:{...s.card,display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:600,color:r.C.text},children:e.name}),(0,n.jsx)("div",{style:{fontSize:11,color:r.C.muted},children:[e.specialty,e.npiNumber&&"NPI: ".concat(e.npiNumber)].filter(
1Boolean).join(" ⢠")}),e.email&&(0,n.jsx)("div",{style:{fontSize:11,color:r.C.muted},children:e.email}),e.inYourOrg&&(0,n.jsx)("div",{style:{fontSize:11,color:r.C.green,fontWeight:600},children:"Already at your site"})]}),(0,n.jsx)("button",{onClick:()=>ei(e.id),disabled:N||e.inYourOrg,style:{...s.btn,...s.btnSm,...s.btnPrimary,whiteSpace:"nowrap",...e.inYourOrg?{opacity:.5,cursor:"default"}:{}},children:e.inYourOrg?"Linked":"Link to Site"})]},e.id))]}):(0,n.jsxs)("div",{style:{...s.card,textAlign:"center",padding:20,color:r.C.muted,fontSize:13},children:['No PIs found matching "',y,'".']}),(0,n.jsx)("button",{onClick:()=>I(!0),style:{...s.btn,...s.btnGhost,width:"100%",marginTop:8},children:b.length>0?"Not the right person? Create New PI Profile":"Create New PI Profile"})]}),k&&(0,n.jsxs)("div",{style:{borderTop:"1px solid ".concat(r.C.border),paddingTop:16,marginTop:8},children:[(0,n.jsx)("div",{style:{fontSize:14,fontWeight:700,color:r.C.text,marginBottom:12},children:"Create New PI (Pending Verification)"}),(0,n.jsx)("div",{style:{fontSize:11,color:r.C.muted,marginBottom:12},children:"A verification invitation will be sent to the PI's email so they can claim and verify their profile."}),(0,n.jsx)("label",{style:s.label,children:'NPI Lookup (type full name, e.g. "Azriel Hirschfeld")'}),(0,n.jsx)("input",{placeholder:"Type first and last name to search NPI registry...",onChange:e=>{let t=e.target.value;clearTimeout(window.__npiTimer),window.__npiTimer=setTimeout(()=>el(t),400)},style:{...s.input,marginBottom:4}}),Q.length>0&&(0,n.jsx)("div",{style:{background:r.C.inputBg,border:"1px solid ".concat(r.C.border),borderRadius:8,maxHeight:160,overflowY:"auto",marginBottom:12},children:Q.map((e,t)=>(0,n.jsxs)("div",{onClick:()=>{var t;let i=(null!=(t=e.name)?t:"").split(","),n=i.length>=2?"".concat(i[1].trim()," ").concat(i[0].trim()):e.name;$(t=>({...t,name:n,npiNumber:e.npi,specialty:e.type||t.specialty})),X([])},style:{padding:"8px 12px",cursor:"pointer",borderBottom:"1px solid ".concat((0,r.u)(r.C.border,13)),fontSize:12,color:r.C.text},children:[(0,n.jsx)("span",{style:{fontWeight:600},children:e.name}),(0,n.jsxs)("span",{style:{color:r.C.muted,marginLeft:8},children:["NPI: ",e.npi]}),e.address&&(0,n.jsx)("span",{style:{color:r.C.muted,marginLeft:8},children:e.address})]},t))}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"Full Name *"}),(0,n.jsx)("input",{value:K.name,onChange:e=>$(t=>({...t,name:e.target.value})),style:s.input})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"Email *"}),(0,n.jsx)("input",{value:K.email,onChange:e=>$(t=>({...t,email:e.target.value})),type:"email",style:s.input})]})]}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12,marginBottom:16},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"NPI Number"}),(0,n.jsx)("input",{value:K.npiNumber,onChange:e=>$(t=>({...t,npiNumber:e.target.value})),maxLength:10,style:s.input})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"Specialty"}),(0,n.jsx)("input",{value:K.specialty,onChange:e=>$(t=>({...t,specialty:e.target.value})),style:s.input,placeholder:"e.g. Oncology"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"License #"}),(0,n.jsx)("input",{value:K.licenseNumber,onChange:e=>$(t=>({...t,licenseNumber:e.target.value})),style:s.input})]})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("button",{onClick:en,disabled:N,style:{...s.btn,...s.btnPrimary,flex:1},children:N?"Creating...":"Create & Send Invitation"}),(0,n.jsx)("button",{onClick:()=>I(!1),style:{...s.btn,...s.btnGhost},children:"Cancel"})]})]}),!k&&(0,n.jsx)("div",{style:{marginTop:12,textAlign:"right"},children:(0,n.jsx)("button",{onClick:()=>m(!1),style:{...s.btn,...s.btnGhost},children:"Close"})})]})}),A&&(0,n.jsx)("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",display:"flex",alignItems:i?"flex-end":"center",justifyContent:"center",zIndex:100},onClick:()=>B(!1),children:(0,n.jsxs)("div",{style:{background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:i?"14px 14px 0 0":14,padding:i?"24px 20px":32,width:i?"100%":560,maxHeight:"90vh",overflowY:"auto"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{style:{fontSize:17,fontWeight:700,color:r.C.text,marginBottom:4},children:"Assign investigator to a study"}),(0,n.jsx)("div",{style:{fontSize:12,color:r.C.muted,marginBottom:16},children:"Links the person to the studyâs regulatory binder and starts tracking their credentials (CV, license, GCP, DEA, board cert) with expiration reminders, plus the FDA 1572/3454/3455."}),(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:i?"1fr":"1fr 1fr",gap:12,marginBottom:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"Study"}),(0,n.jsx)("select",{value:R,onChange:e=>{var t;E(t=e.target.value),J(null),M(null),er(t,O)},style:{...s.input,cursor:"pointer"},children:(null!=d?d:[]).map(e=>(0,n.jsx)("option",{value:e.id,children:[e.code,e.title].filter(
1Boolean).join(" â ")||e.id},e.id))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:s.label,children:"Role"}),(0,n.jsxs)("select",{value:D,onChange:e=>_(e.target.value),style:{...s.input,cursor:"pointer"},children:[(0,n.jsx)("option",{value:"PRIMARY_PI",children:"Principal Investigator"}),(0,n.jsx)("option",{value:"SUB_INVESTIGATOR",children:"Sub-Investigator"}),(0,n.jsx)("option",{value:"CO_INVESTIGATOR",children:"Co-Investigator"})]})]})]}),U?(0,n.jsxs)("div",{style:{...s.card,background:"".concat(r.C.green,"12"),borderColor:"".concat(r.C.green,"44"),marginBottom:12},children:[(0,n.jsxs)("div",{style:{fontSize:14,fontWeight:700,color:r.C.text,marginBottom:6},children:["â ",U.name," assigned"]}),U.creds.length>0&&(0,n.jsxs)("div",{style:{fontSize:11,color:r.C.muted},children:["Credential requests started: ",U.creds.map(e=>e.replace(/_/g," ")).join(", ")]}),U.docs.length>0&&(0,n.jsxs)("div",{style:{fontSize:11,color:r.C.muted,marginTop:2},children:["Binder forms created: ",U.docs.map(e=>e.replace(/_/g," ")).join(", ")]}),(0,n.jsx)("button",{onClick:()=>J(null),style:{...s.btn,...s.btnGhost,...s.btnSm,marginTop:10},children:"Assign another"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:10},children:[(0,n.jsx)("input",{value:O,onChange:e=>F(e.target.value),onKeyDown:e=>"Enter"===e.key&&er(R,O),placeholder:"Search your site's people by name or emailâ¦",style:{...s.input,flex:1}}),(0,n.jsx)("button",{onClick:()=>er(R,O),disabled:Y,style:{...s.btn,...s.btnPrimary,whiteSpace:"nowrap"},children:Y?"â¦":"Search"})]}),q&&(0,n.jsx)("div",{style:{fontSize:11,color:"#f87171",marginBottom:8},children:q}),0!==L.length||Y?(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:L.map(e=>(0,n.jsxs)("div",{style:{...s.card,padding:12,display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:0},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{style:{fontSize:13,fontWeight:600,color:r.C.text},children:e.name}),e.email&&(0,n.jsx)("div",{style:{fontSize:11,color:r.C.muted},children:e.email})]}),(0,n.jsx)("button",{disabled:H,onClick:()=>es(e.id,e.name),style:{...s.btn,...s.btnSm,...s.btnPrimary,whiteSpace:"nowrap"},children:"Assign"})]},e.id))}):(0,n.jsx)("div",{style:{...s.card,textAlign:"center",padding:18,color:r.C.muted,fontSize:12},children:"No one available to assign. Anyone with an active account on your siteâs team can be assigned â add them under Team first if theyâre missing."})]}),(0,n.jsx)("div",{style:{marginTop:12,textAlign:"right"},children:(0,n.jsx)("button",{onClick:()=>B(!1),style:{...s.btn,...s.btnGhost},children:"Close"})})]})})]})}}}]);
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.