1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[35455],{35455:(e,t,n)=>{n.r(t),n.d(t,{default:()=>y});var i=n(95155),o=n(12115),r=n(4373);let l=[{documentType:"LAB_CERTIFICATION_CLIA",category:"LAB",title:"CLIA Certificate",group:"Licensing & Accreditation",expiryTracked:!0,renewalLeadDays:90,hint:"Clinical lab certification"},{documentType:"CAP_ACCREDITATION",category:"LAB",title:"CAP Accreditation",group:"Licensing & Accreditation",expiryTracked:!0,renewalLeadDays:90},{documentType:"PHARMACY_LICENSE",category:"PHARMACY",title:"Pharmacy License",group:"Pharmacy & Drug",expiryTracked:!0,renewalLeadDays:60,hint:"State board of pharmacy"},{documentType:"DEA_REGISTRATION",category:"PHARMACY",title:"DEA Registration",group:"Pharmacy & Drug",expiryTracked:!0,renewalLeadDays:60},{documentType:"INSURANCE_INDEMNIFICATION",category:"ADMINISTRATIVE",title:"General Liability Insurance (COI)",group:"Insurance & Financial",expiryTracked:!0,renewalLeadDays:60,hint:"Certificate of insurance"},{documentType:"FACILITY_DESCRIPTION",category:"ADMINISTRATIVE",title:"Facility Description",group:"Facility & Quality",expiryTracked:!1,hint:"Rooms, equipment, storage, monitoring"},{documentType:"INSTITUTIONAL_POLICIES",category:"ADMINISTRATIVE",title:"Institutional Policies & SOPs",group:"Facility & Quality",expiryTracked:!1},{documentType:"IRB_ROSTER",category:"IRB",title:"IRB Roster",group:"Facility & Quality",expiryTracked:!1},{documentType:"LAB_NORMAL_RANGES",category:"LAB",title:"Lab Normal Ranges",group:"Facility & Quality",expiryTracked:!0,renewalLeadDays:90},{documentType:"TEMP_MONITORING_EQUIPMENT_CERT",category:"LAB",title:"Temperature Monitoring / Equipment Calibration",group:"Facility & Quality",expiryTracked:!0,renewalLeadDays:90},{documentType:"PI_CV",category:"PERSONNEL",title:"Investigator CV",group:"Personnel & Training",expiryTracked:!1,hint:"Keep current; sponsors expect a signed & dated CV"},{documentType:"MEDICAL_LICENSE",category:"PERSONNEL",title:"Medical License",group:"Personnel & Training",expiryTracked:!0,renewalLeadDays:60},{documentType:"GCP_TRAINING",category:"TRAINING",title:"GCP Training Certificate",group:"Personnel & Training",expiryTracked:!0,renewalLeadDays:90,hint:"ICH GCP â typically refreshed every 2â3 years"},{documentType:"STAFF_RESPONSIBILITY_LOG",category:"LOGS",title:"Staff Responsibility / Signature & Initials Log",group:"Personnel & Training",expiryTracked:!1}],a=["Licensing & Accreditation","Pharmacy & Drug","Insurance & Financial","Facility & Quality","Personnel & Training"],d=Object.fromEntries(l.map(e=>[e.documentType,e])),s={fontFamily:'"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",sans-serif'},c={"Licensing & Accreditation":"\uD83D\uDCDC","Pharmacy & Drug":"âï¸","Insurance & Financial":"\uD83D\uDEE1ï¸","Facility & Quality":"\uD83C\uDFE5","Personnel & Training":"\uD83C\uDF93",Other:"\uD83D\uDCC4"};function u(e){var t,n;if(!e.expiryDate)return{level:"none",label:"no expiry"};let i=Date.now(),o=Math.ceil((new Date(e.expiryDate).getTime()-i)/864e5);return o<0?{level:"bad",label:"expired ".concat(Math.abs(o),"d ago")}:o<=(Number(e.renewalLeadDays)>0?Number(e.renewalLeadDays):null!=(n=null==(t=d[e.documentType])?void 0:t.renewalLeadDays)?n:90)?{level:"warn",label:"".concat(o,"d left")}:{level:"good",label:"".concat(o,"d left")}}let p={good:{bg:"rgba(16,185,129,.14)",fg:r.C.green},warn:{bg:"rgba(245,158,11,.16)",fg:r.C.amber},bad:{bg:"rgba(239,68,68,.16)",fg:r.C.red},none:{bg:"rgba(148,163,184,.14)",fg:r.C.muted}};function y(e){let{siteId:t,studies:n}=e,[l,p]=(0,o.useState)(null),[y,j]=(0,o.useState)(null!=t?t:null),[v,I]=(0,o.useState)([]),[w,L]=(0,o.useState)(!0),[D,A]=(0,o.useState)(null),[R,E]=(0,o.useState)(null),[N,z]=(0,o.useState)(!1),[P,O]=(0,o.useState)(null),[W,_]=(0,o.useState)(!1),M=(0,o.useMemo)(()=>(null!=n?n:[]).filter(e=>e&&e.id),[n]),F=(0,o.useRef)(null),B=(0,o.useRef)(null),U=(0,o.useCallback)(e=>{let t=e||l;return(null==t?void 0:t.sessionToken)?{"x-session":t.sessionToken}:{}},[l]),G=(e,t)=>{A({t:e,c:t}),setTimeout(()=>A(null),3500)},V=(0,o.useCallback)(async(e,t)=>{try{let n=await fetch("/api/sites/".concat(t,"/regulatory-documents?layer=SITE"),{headers:U(e)});if(n.ok){let e=await n.json();I(e.documents||[])}}catch(e){}},[U]);async function H(e,t){if(y){E(e);try{let n=await fetch("/api/sites/".concat(y,"/regulatory-documents/").concat(e),{method:"PATCH",headers:{"Content-Type":"application/json",...U()},body:JSON.stringify(t)});if(n.ok){let t=await n.json();I(n=>n.map(n=>n.id===e?{...n,...t.document}:n))}else{let e=await n.json().catch(()=>({}));G(e.error||"Update failed",r.C.red)}}finally{E(null)}}}function Y(e){var t;B.current=e,null==(t=F.current)||t.click()}async function Q(e){var t;let n=null==(t=e.target.files)?void 0:t[0];if(e.target.value="",!n||!y)return;let i=B.current;E(i||"new");try{let e=new FormData;e.append("file",n),i&&e.append("docId",i);let t=await fetch("/api/sites/".concat(y,"/regulatory-documents/upload"),{method:"POST",headers:U(),body:e});if(t.ok)G("Uploaded",r.C.green),await V(l,y);else{let e=await t.json().catch(()=>({}));G(e.error||"Upload failed",r.C.red)}}catch(e){G("Upload failed",r.C.red)}finally{E(null),B.current=null}}async function J(e){if(y)try{let t=await fetch("/api/sites/".concat(y,"/regulatory-documents/").concat(e,"/file"),{headers:U()}),n=await t.json();t.ok&&n.url?window.open(n.url,"_blank","noopener"):G(n.error||"Could not open file",r.C.red)}catch(e){G("Could not open file",r.C.red)}}(0,o.useEffect)(()=>{let e=!1;return(async()=>{let n,i=localStorage.getItem("user");if(!i)return L(!1);try{n=JSON.parse(i)}catch(e){L(!1);return}let o=t||n.orgId;if(!e){p(n),j(o);try{await fetch("/api/sites/".concat(o,"/regulatory-documents/ensure-binder"),{method:"POST",headers:{"x-session":n.sessionToken}})}catch(e){}!e&&(await V(n,o),e||L(!1))}})(),()=>{e=!0}},[t,V]);let q=(0,o.useMemo)(()=>v.filter(e=>"NOT_APPLICABLE"!==e.status),[v]),K=(0,o.useMemo)(()=>q.filter(e=>!!e.fileUrl||"NOT_STARTED"!==e.status).length,[q]),X=q.length||1,Z=Math.round(K/X*100),$=(0,o.useMemo)(()=>q.map(e=>({d:e,e:u(e)})).filter(e=>"bad"===e.e.level||"warn"===e.e.level).sort((e,t)=>
1("bad"===e.e.level?-1:1)-("bad"===t.e.level?-1:1)),[q]),ee=(0,o.useMemo)(()=>{let e=new Map;for(let n of v){var t;let i=function(e){var t,n;return(null==(t=e.formData)?void 0:t.group)||(null==(n=d[e.documentType])?void 0:n.group)||"Other"}(n),o=null!=(t=e.get(i))?t:[];o.push(n),e.set(i,o)}return[...a,"Other"].filter(t=>e.has(t)).map(t=>[t,e.get(t).filter(e=>"NOT_APPLICABLE"!==e.status)]).filter(e=>{let[,t]=e;return t.length})},[v]);return w?(0,i.jsx)("div",{style:{padding:40,color:r.C.muted,...s},children:"Loading your regulatory libraryâ¦"}):(0,i.jsxs)("div",{style:{padding:24,maxWidth:1040,margin:"0 auto"},children:[(0,i.jsx)("input",{ref:F,type:"file",onChange:Q,style:{display:"none"},accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.tif,.tiff"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16,flexWrap:"wrap",marginBottom:20},children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("h1",{style:{fontSize:22,fontWeight:800,color:r.C.text,margin:0,display:"flex",alignItems:"center",gap:10},children:[(0,i.jsx)("span",{style:s,children:"\uD83D\uDCC1"})," General Library"]}),(0,i.jsxs)("p",{style:{color:r.C.muted,fontSize:13.5,margin:"6px 0 0",maxWidth:"62ch"},children:["Your organization's regulatory documents that apply to ",(0,i.jsx)("strong",{style:{color:r.C.sub},children:"every study"})," â licensing, training, CVs, SOPs, insurance. Upload once; when you're contracted to a study, link them in without re-uploading."]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:7,fontSize:12,fontWeight:700,padding:"7px 12px",borderRadius:999,border:"1px solid ".concat(r.C.border),color:r.C.green,background:"rgba(16,185,129,.08)"},children:[(0,i.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:r.C.green}})," Free â no study required"]}),M.length>0&&(0,i.jsxs)("button",{onClick:()=>_(!0),style:T,title:"Link your general documents into a study you're contracted to",children:[(0,i.jsx)("span",{style:s,children:"\uD83D\uDD17"})," Link binder to a study"]}),(0,i.jsxs)("button",{onClick:()=>z(!0),style:S,children:[(0,i.jsx)("span",{style:s,children:"ï¼"})," Add document"]})]})]}),D&&(0,i.jsx)("div",{style:{marginBottom:14,padding:"10px 14px",borderRadius:10,fontSize:13.5,fontWeight:600,color:D.c,background:"".concat(D.c,"1a"),border:"1px solid ".concat(D.c,"44")},children:D.t}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(240px,1fr) minmax(240px,1.4fr)",gap:14,marginBottom:22},children:[(0,i.jsxs)("div",{style:{...b,display:"flex",alignItems:"center",gap:18},children:[(0,i.jsx)(m,{pct:Z}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:800,fontSize:16,color:r.C.text},children:100===Z?"Binder complete":"Build your site binder"}),(0,i.jsxs)("div",{style:{color:r.C.muted,fontSize:13,marginTop:4},children:[(0,i.jsx)("strong",{style:{color:r.C.sub},children:K})," of ",X," general documents on file."]}),Z<100&&(0,i.jsx)("div",{style:{color:r.C.muted,fontSize:12.5,marginTop:6},children:"Add the rest below â we'll track every expiry and remind you to renew."})]})]}),(0,i.jsxs)("div",{style:{...b},children:[(0,i.jsxs)("div",{style:{fontSize:12,fontWeight:700,letterSpacing:".05em",textTransform:"uppercase",color:r.C.muted,marginBottom:10,display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:s,children:"â°"})," Expiring & renewals"]}),0===$.length?(0,i.jsx)("div",{style:{color:r.C.muted,fontSize:13},children:"Nothing expiring soon. Set an expiry date on a document and we'll watch it for you."}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:$.slice(0,4).map(e=>{let{d:t,e:n}=e;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:13},children:[(0,i.jsx)(C,{e:n}),(0,i.jsx)("span",{style:{color:r.C.text,fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.title}),(0,i.jsx)("button",{onClick:()=>Y(t.id),style:{...k,marginLeft:"auto"},children:"Renew"})]},t.id)})})]})]}),ee.map(e=>{let[t,n]=e;return(0,i.jsxs)("section",{style:{marginBottom:22},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:9,margin:"0 0 10px"},children:[(0,i.jsx)("span",{style:{...s,fontSize:15},children:c[t]||"\uD83D\uDCC4"}),(0,i.jsx)("h2",{style:{fontSize:14,fontWeight:750,color:r.C.sub,margin:0},children:t}),(0,i.jsxs)("span",{style:{fontSize:11.5,color:r.C.muted},children:[n.filter(e=>e.fileUrl||"NOT_STARTED"!==e.status).length,"/",n.length]})]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.map(e=>(0,i.jsx)(g,{d:e,busy:R===e.id,canLink:M.length>0,onUpload:()=>Y(e.id),onView:()=>J(e.id),onLink:()=>O(e),onExpiry:t=>H(e.id,{expiryDate:t||null}),onNA:()=>H(e.id,{status:"NOT_APPLICABLE"})},e.id))})]},t)}),N&&(0,i.jsx)(h,{siteId:y,getHeader:U,onClose:()=>z(!1),onDone:()=>{z(!1),y&&V(l,y),G("Document added",r.C.green)}}),P&&(0,i.jsx)(x,{doc:P,siteId:y,studies:M,getHeader:U,onClose:()=>O(null),onChange:e=>{y&&V(l,y),e&&G(e,r.C.green)}}),W&&(0,i.jsx)(f,{siteId:y,studies:M,docs:q.filter(e=>!!e.fileUrl),getHeader:U,onClose:()=>_(!1),onDone:e=>{_(!1),y&&V(l,y),e&&G(e,r.C.green)}})]})}function g(e){var t,n,o,l;let{d:a,busy:s,canLink:c,onUpload:p,onView:y,onLink:g,onExpiry:x,onNA:h}=e,f=u(a),m=!!a.fileUrl,b=null==(t=d[a.documentType])?void 0:t.hint,S=null!=(o=null==(n=d[a.documentType])?void 0:n.expiryTracked)&&o,v=(null!=(l=a.accessGrants)?l:[]).filter(e=>"REVOKED"!==e.status).length;return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center",padding:"12px 14px",border:"1px solid ".concat(r.C.border),borderRadius:12,background:r.C.card,opacity:s?.6:1},children:[(0,i.jsxs)("div",{style:{minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontWeight:650,fontSize:14,color:r.C.text},children:a.title}),m?(0,i.jsx)("span",{style:{...j,color:r.C.green,background:"rgba(16,185,129,.12)"},children:"on file"}):(0,i.jsx)("span",{style:{...j,color:r.C.muted,background:"rgba(148,163,184,.12)"},children:"not started"}),S&&(0,i.jsx)(C,{e:f}),v>0&&(0,i.jsxs)("button",{onClick:g,style:{...j,color:r.C.cyan,background:"rgba(56,189,248,.12)",border:0,cursor:"pointer"},title:"Manage study links",children:["\uD83D\uDD17 Linked to ",v," stud",1===v?"y":"ies"]})]}),(0,i.jsxs)("div",{style:{fontFamily:"ui-monospace,Consolas,monospace",fontSize:11,color:r.C.muted,marginTop:3},children:[a.documentType,b?" \xb7 ".concat(b):""]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",justifyContent:"flex-end"},children:[S&&(0,i.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11.5,color:r.C.muted},children:["exp",(0,i.jsx)("input",{type:"date",defaultValue:a.expiryDate?new Date(a.expiryDate).toISOString().slice(0,10):"",onCh
1ange:e=>x(e.target.value),style:{background:r.C.inputBg,color:r.C.text,border:"1px solid ".concat(r.C.border),borderRadius:7,padding:"4px 6px",fontSize:12}})]}),m&&c&&(0,i.jsx)("button",{onClick:g,style:T,title:"Link this document into a study you're contracted to",children:"Link to study"}),m&&(0,i.jsx)("button",{onClick:y,style:T,children:"View"}),(0,i.jsx)("button",{onClick:p,style:T,children:m?"Replace":"Upload"}),!m&&!1===a.isRequired&&(0,i.jsx)("button",{onClick:h,style:{...k,fontSize:12},title:"Mark not applicable",children:"N/A"})]})]})}function x(e){var t;let{doc:n,siteId:l,studies:a,getHeader:d,onClose:s,onChange:c}=e,[u,p]=(0,o.useState)(null),[y,g]=(0,o.useState)(""),x=(null!=(t=n.accessGrants)?t:[]).filter(e=>"REVOKED"!==e.status),h=new Set(x.map(e=>e.grantedToStudyId).filter(Boolean));async function f(e){p(e),g("");try{let t=await fetch("/api/sites/".concat(l,"/regulatory-documents/").concat(n.id,"/link-study"),{method:"POST",headers:{"Content-Type":"application/json",...d()},body:JSON.stringify({studyId:e})}),i=await t.json();t.ok?(c(i.alreadyLinked?void 0:"Linked to ".concat(i.linkedTo||"study")),s()):g(i.error||"Could not link")}catch(e){g("Could not link")}finally{p(null)}}async function m(e){p(e),g("");try{let t=await fetch("/api/sites/".concat(l,"/regulatory-documents/").concat(n.id,"/link-study"),{method:"DELETE",headers:{"Content-Type":"application/json",...d()},body:JSON.stringify({grantId:e})});if(t.ok)c("Unlinked"),s();else{let e=await t.json().catch(()=>({}));g(e.error||"Could not unlink")}}catch(e){g("Could not unlink")}finally{p(null)}}return(0,i.jsx)("div",{onClick:s,style:{position:"fixed",inset:0,background:"rgba(2,6,16,.6)",display:"grid",placeItems:"center",zIndex:100,padding:16},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(500px,100%)",maxHeight:"82vh",overflowY:"auto",background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:16,padding:22,boxShadow:"0 24px 60px -20px rgba(0,0,0,.6)"},children:[(0,i.jsx)("h3",{style:{margin:0,fontSize:17,fontWeight:800,color:r.C.text},children:"Link to a study"}),(0,i.jsx)("p",{style:{color:r.C.muted,fontSize:12.5,margin:"6px 0 4px"},children:(0,i.jsx)("strong",{style:{color:r.C.sub},children:n.title})}),(0,i.jsx)("p",{style:{color:r.C.muted,fontSize:12.5,margin:"0 0 16px"},children:"Shares a certified, version-pinned copy with the study's sponsor. You can unlink anytime â their copy is retained per Part 11."}),0===a.length&&(0,i.jsx)("div",{style:{color:r.C.muted,fontSize:13},children:"You're not contracted to any studies yet. Once a sponsor engages you, they'll appear here."}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:a.map(e=>{let t=h.has(e.id),n=x.find(t=>t.grantedToStudyId===e.id);return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",border:"1px solid ".concat(r.C.border),borderRadius:11,background:t?"rgba(56,189,248,.06)":"transparent"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontWeight:640,fontSize:13.5,color:r.C.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.shortName||e.code||e.title||e.id}),e.code&&(0,i.jsx)("div",{style:{fontFamily:"ui-monospace,Consolas,monospace",fontSize:11,color:r.C.muted},children:e.code})]}),t?(0,i.jsx)("button",{onClick:()=>n&&m(n.id),disabled:!!u,style:{...T,color:r.C.red,borderColor:"".concat(r.C.red,"55")},children:u===(null==n?void 0:n.id)?"â¦":"Unlink"}):(0,i.jsx)("button",{onClick:()=>f(e.id),disabled:!!u,style:{...S,opacity:u?.6:1},children:u===e.id?"Linkingâ¦":"Link"})]},e.id)})}),y&&(0,i.jsx)("div",{style:{color:r.C.red,fontSize:13,marginTop:12},children:y}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:18},children:(0,i.jsx)("button",{onClick:s,style:T,children:"Done"})})]})})}function h(e){var t;let{siteId:n,getHeader:a,onClose:s,onDone:c}=e,[u,p]=(0,o.useState)(l[0].documentType),[y,g]=(0,o.useState)(l[0].title),[x,h]=(0,o.useState)(""),[f,m]=(0,o.useState)(null),[C,b]=(0,o.useState)(!1),[j,k]=(0,o.useState)(""),w=(null==(t=d[u])?void 0:t.category)||"ADMINISTRATIVE";async function L(){if(!f)return void k("Choose a file to upload");if(!y.trim())return void k("Give the document a title");b(!0),k("");try{let e=new FormData;e.append("file",f),e.append("documentType",u),e.append("category",w),e.append("title",y.trim()),x&&e.append("expiryDate",x);let t=await fetch("/api/sites/".concat(n,"/regulatory-documents/upload"),{method:"POST",headers:a(),body:e});if(t.ok)c();else{let e=await t.json().catch(()=>({}));k(e.error||"Upload failed")}}catch(e){k("Upload failed")}finally{b(!1)}}return(0,i.jsx)("div",{onClick:s,style:{position:"fixed",inset:0,background:"rgba(2,6,16,.6)",display:"grid",placeItems:"center",zIndex:100,padding:16},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(480px,100%)",background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:16,padding:22,boxShadow:"0 24px 60px -20px rgba(0,0,0,.6)"},children:[(0,i.jsx)("h3",{style:{margin:0,fontSize:17,fontWeight:800,color:r.C.text},children:"Add a general document"}),(0,i.jsx)("p",{style:{color:r.C.muted,fontSize:12.5,margin:"6px 0 16px"},children:"Applies to every study. Stored privately to your site."}),(0,i.jsx)("label",{style:v,children:"Document type"}),(0,i.jsx)("select",{value:u,onChange:e=>{p(e.target.value);let t=d[e.target.value];t&&g(t.title)},style:I,children:l.map(e=>(0,i.jsxs)("option",{value:e.documentType,children:[e.title," â ",e.group]},e.documentType))}),(0,i.jsx)("label",{style:v,children:"Title"}),(0,i.jsx)("input",{value:y,onChange:e=>g(e.target.value),style:I,placeholder:"e.g. CLIA Certificate â Riverside Labs"}),(0,i.jsxs)("label",{style:v,children:["Expiry date ",(0,i.jsx)("span",{style:{color:r.C.muted,fontWeight:400},children:"(optional â we'll remind you)"})]}),(0,i.jsx)("input",{type:"date",value:x,onChange:e=>h(e.target.value),style:I}),(0,i.jsx)("label",{style:v,children:"File"}),(0,i.jsx)("input",{type:"file",onChange:e=>{var t;return m((null==(t=e.target.files)?void 0:t[0])||null)},accept:".pdf,.doc,.docx,.png,.jpg,.jpeg,.tif,.tiff",style:{...I,padding:8}}),j&&(0,i.jsx)("div",{style:{color:r.C.red,fontSize:13,marginTop:10},children:j}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:18},children:[(0,i.jsx)("button",{onClick:s,style:T,children:"Cancel"}),(0,i.jsx)("button",{onClick:L,disabled:C,style:{...S,opacity:C?.6:1},children:C?"Uploadingâ¦":"Upload"})]})]})})}function f(e){var t,n;let{siteId:l,studies:a,docs:d,getHeader:s,onClose:c,onDone:u}=e,[p,y]=(0,o.useState)(null!=(n=null==(t=a[0])?void 0:t.id)?n:""),[g,x]=(0,o.useState)({}),[h,f]=(0,o.useState)(!1),[m,C]=(0,o.useState)(""),b=e=>e.shortName||e.code||e.title||e.id,j=(0,o.useMemo)(()=>d.filter(e=>{var t;return!(null!=(t=e.accessGrants)?t:[]).some(e=>"REVOKED"!==e.status&&e.grantedToStudyId===p)}),[d,p]);(0,o.useEffect)(()=>{let e={};
1j.forEach(t=>{e[t.id]=!0}),x(e)},[p,j.length]);let k=j.filter(e=>g[e.id]);async function w(){if(!p||0===k.length)return;f(!0),C("");let e=await Promise.allSettled(k.map(e=>fetch("/api/sites/".concat(l,"/regulatory-documents/").concat(e.id,"/link-study"),{method:"POST",headers:{"Content-Type":"application/json",...s()},body:JSON.stringify({studyId:p})}).then(e=>{if(!e.ok)throw Error();return e})));f(!1);let t=e.filter(e=>"fulfilled"===e.status).length,n=a.find(e=>e.id===p);if(0===t)return void C("Could not link the documents â please try again.");u("Linked ".concat(t," document").concat(1===t?"":"s"," to ").concat(n?b(n):"the study"))}return(0,i.jsx)("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(2,6,16,.6)",display:"grid",placeItems:"center",zIndex:100,padding:16},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:"min(520px,100%)",maxHeight:"84vh",overflowY:"auto",background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:16,padding:22,boxShadow:"0 24px 60px -20px rgba(0,0,0,.6)"},children:[(0,i.jsx)("h3",{style:{margin:0,fontSize:17,fontWeight:800,color:r.C.text},children:"Bring your binder to a study"}),(0,i.jsx)("p",{style:{color:r.C.muted,fontSize:12.5,margin:"6px 0 16px"},children:"Link your general documents into a study you're contracted to â a certified, version-pinned copy each. Nothing is shared until you confirm."}),(0,i.jsx)("label",{style:v,children:"Study"}),(0,i.jsx)("select",{value:p,onChange:e=>y(e.target.value),style:I,children:a.map(e=>(0,i.jsxs)("option",{value:e.id,children:[b(e),e.code?" â ".concat(e.code):""]},e.id))}),(0,i.jsxs)("div",{style:{margin:"16px 0 6px",fontSize:12,fontWeight:700,letterSpacing:".04em",textTransform:"uppercase",color:r.C.muted},children:["Documents to link (",k.length,"/",j.length,")"]}),0===j.length?(0,i.jsx)("div",{style:{color:r.C.muted,fontSize:13,padding:"10px 0"},children:"Every on-file general document is already linked to this study. \uD83C\uDF89"}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:7},children:j.map(e=>(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 11px",border:"1px solid ".concat(r.C.border),borderRadius:10,cursor:"pointer",background:g[e.id]?"rgba(56,189,248,.06)":"transparent"},children:[(0,i.jsx)("input",{type:"checkbox",checked:!!g[e.id],onChange:t=>x(n=>({...n,[e.id]:t.target.checked}))}),(0,i.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("span",{style:{fontWeight:620,fontSize:13.5,color:r.C.text},children:e.title}),(0,i.jsx)("span",{style:{display:"block",fontFamily:"ui-monospace,Consolas,monospace",fontSize:10.5,color:r.C.muted},children:e.documentType})]})]},e.id))}),m&&(0,i.jsx)("div",{style:{color:r.C.red,fontSize:13,marginTop:12},children:m}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:18},children:[(0,i.jsx)("button",{onClick:c,style:T,children:"Cancel"}),(0,i.jsx)("button",{onClick:w,disabled:h||0===k.length,style:{...S,opacity:h||0===k.length?.6:1},children:h?"Linkingâ¦":"Link ".concat(k.length," document").concat(1===k.length?"":"s")})]})]})})}function m(e){let{pct:t}=e,n=100===t?r.C.green:r.C.gold;return(0,i.jsxs)("div",{style:{width:84,height:84,borderRadius:"50%",flex:"none",display:"grid",placeItems:"center",position:"relative",background:"conic-gradient(".concat(n," ").concat(3.6*t,"deg, ").concat(r.C.border," 0)")},children:[(0,i.jsx)("div",{style:{position:"absolute",inset:9,borderRadius:"50%",background:r.C.card}}),(0,i.jsxs)("div",{style:{position:"relative",fontWeight:800,fontSize:19,color:r.C.text,fontVariantNumeric:"tabular-nums"},children:[t,"%"]})]})}function C(e){let{e:t}=e,n=p[t.level];return(0,i.jsx)("span",{style:{fontSize:11,fontWeight:700,padding:"3px 9px",borderRadius:999,color:n.fg,background:n.bg,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:t.label})}let b={background:r.C.card,border:"1px solid ".concat(r.C.border),borderRadius:14,padding:18},j={fontSize:10.5,fontWeight:700,padding:"2px 8px",borderRadius:999},S={border:0,borderRadius:10,padding:"9px 15px",fontWeight:700,fontSize:13,cursor:"pointer",color:"#12100a",background:r.C.gold,display:"inline-flex",alignItems:"center",gap:6},T={border:"1px solid ".concat(r.C.border),borderRadius:9,padding:"7px 13px",fontWeight:650,fontSize:12.5,cursor:"pointer",color:r.C.text,background:"transparent"},k={border:0,background:"transparent",color:r.C.gold,fontWeight:700,fontSize:12.5,cursor:"pointer",padding:0},v={display:"block",fontSize:12,fontWeight:600,color:r.C.sub,margin:"12px 0 5px"},I={width:"100%",background:r.C.inputBg,color:r.C.text,border:"1px solid ".concat(r.C.border),borderRadius:9,padding:"9px 11px",fontSize:13.5,boxSizing:"border-box"}}}]);
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.