PageSourceSearch

https://portal.commoninterest.com/assets/attachments._id_-Ix6KLt7B.js

js commoninterest.com collected 2026-09-24 13:27:14 UTC 5,918 bytes, 1 lines download raw bytes

1import{u as N,j as e,r as m,S as v,B as R,a7 as C,a_ as L,F as u,v as A,aP as U,a$ as k,b0 as I,b1 as T,n as w}from"./elements-DVh2jUIM.js";import{u as E,$ as S,a0 as F,W as O,a1 as D,Y as M,N as $,A as B,a2 as P}from"./index-DeQvL4I7.js";import{E as q}from"./react-error-boundary.esm-DhomiJMX.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";function _(){const n=E(),{t:c}=N(),{id:s}=S(),l=n.fetchQuery(F({queryKey:["attachments",s],queryFn:()=>O.getAttachmentsByActionItem(Number(s)).catch(r=>{var a,x,f;const d=(x=(a=r.response)==null?void 0:a.data)==null?void 0:x.detail;if(r instanceof D&&((f=r.response)==null?void 0:f.status)===400&&typeof d=="string"&&d.includes("No attachments"))return{attachments:[]};throw r})})),o=Number(s);return e.jsxs(e.Fragment,{children:[e.jsx(q,{fallbackRender:()=>e.jsxs("div",{className:"p-6 text-center flex flex-col items-center justify-center gap-8 w-screen h-screen",children:[e.jsx("h1",{className:"text-2xl font-bold",children:c("main.attachments.anErrorOccurred")}),e.jsx("p",{className:"text-lg",children:c("main.attachments.errorMessage")}),e.jsx(R,{onClick:()=>window.location.reload(),children:c("main.attachments.errorTryAgain")})]}),children:e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"p-6 text-center flex flex-col items-center justify-center gap-8 w-screen h-screen",children:e.jsx(v,{})}),children:e.jsx(M,{resolve:l,children:({attachments:r})=>e.jsx(V,{attachments:r,actionItemId:o})})})}),e.jsx(C,{position:"bottom-right"})]})}const V=({attachments:n,actionItemId:c})=>{const{t:s}=N(),{embedded:l}=$(),[o]=B(),r=o.get("attachment"),d=o.get("title"),[a,x]=m.useState(()=>(r?n.find(({imgId:t})=>t===Number(r)):void 0)??n[0]),f=m.useRef(!1);m.useEffect(()=>{r&&(o.delete("attachment"),window.history.replaceState(null,"",o.toString()?`?${o}`:window.location.pathname),l&&a&&!f.current&&(f.current=!0,b(a)))},[]);const b=m.useCallback(t=>{P({content:t.content,contentType:t.contentType,fileName:t.fileName},()=>{fetch(`data:${t.contentType};base64,${t.content}`).then(i=>i.blob()).then(i=>{const g=URL.createObjectURL(i),p=document.createElement("a");p.href=g,p.setAttribute("download",t.fileName),document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(g),w({message:s("main.attachments.downloadComplete"),type:"success",position:"top-right"})}).catch(i=>{console.error(i),w({message:s("main.attachments.downloadError",{error:String(i)}),type:"error"})})})},[s]),h=m.useMemo(()=>n.findIndex(({imgId:t})=>t===(a==null?void 0:a.imgId)),[n,a]),j=m.useCallback(t=>{const i=n[h+t];i&&x(i)},[n,h]),y=m.useMemo(()=>[{field:"humanReadableFileName",headerName:s("main.attachments.name"),flex:1,floatingFilter:!1,suppressMovable:!0,resizable:!1}],[s]);return n.length===0?e.jsxs("div",{className:"p-6 text-center flex flex-col items-center justify-center gap-8 w-screen h-screen",children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("main.attachments.noAttachments")}),e.jsx("p",{className:"text-lg",children:s("main.attachments.noAttachmentsDetails")})]}):l?e.jsxs("div",{className:"h-screen w-screen flex flex-col px-4 pt-8 pb-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[d&&e.jsx("h3",{className:"text-2xl font-bold text-base-header",children:d}),e.jsx("p",{className:"text-base-header",children:`XN ${c}`})]}),e.jsx(L,{rowData:n,columnDefs:y,rowHeight:70,getRowId:t=>t.data.imgId.toString(),enableExport:!1,isMobile:!0,onRowClicked:t=>{t.data&&b(t.data)}})]}):e.jsxs("div",{className:"h-screen w-screen flex flex-col",children:[e.jsxs("div",{className:"flex items-end justify-center p-4 gap-4",children:[e.jsxs("button",{className:"p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:s("main.attachments.previous"),disabled:h<=0,onClick:()=>j(-1),children:[e.jsx("span",{className:"sr-only",children:s("main.attachments.previous")}),e.jsx(u,{icon:A,className:"text-base-fg text-base"})]}),e.jsx(U,{className:"flex-grow sm:flex-grow-0 sm:min-w-96",label:"",options:n,displaySelected:t=>t.humanReadableFileName,displayOption:t=>t.humanReadableFileName??e.jsx(e.Fragment,{children:" "}),deriveKey:t=>`img-${t.imgId}`,value:a,onChange:t=>{x(t)}}),e.jsxs("button",{className:"p-2 disabled:opacity-40 disabled:cursor-not-allowed",title:s("main.attachments.next"),disabled:h<0||h>=n.length-1,onClick:()=>j(1),children:[e.jsx("span",{className:"sr-only",children:s("main.attachments.next")}),e.jsx(u,{icon:k,className:"text-base-fg text-base"})]}),e.jsxs("button",{className:"p-2",title:s("main.attachments.download"),onClick:()=>{a&&b(a)},children:[e.jsx("span",{className:"sr-only",children:s("main.attachments.download")}),e.jsx(u,{icon:I,className:"text-base-fg text-base"})]})]}),(a==null?void 0:a.contentType)==="application/pdf"&&e.jsx(W,{fileName:a.fileName,contents:a.content}),(a==null?void 0:a.contentType.startsWith("image/"))&&e.jsx(K,{fileName:a.fileName,contents:a.content,type:a.contentType}),!["application/pdf","image/"].some(t=>a==null?void 0:a.contentType.startsWith(t))&&e.jsx("div",{className:"flex-grow flex items-center justify-center",children:e.jsxs("p",{className:"space-x-2",children:[e.jsx(u,{icon:T,className:"text-yellow-500"}),e.jsx("span",{children:s("main.attachments.noPreview")})]})})]})},W=({fileName:n,contents:c})=>{const s=new Blob([Uint8Array.from(atob(c),o=>
1o.charCodeAt(0))],{type:"application/pdf"}),l=URL.createObjectURL(s);return e.jsx("iframe",{className:"flex-grow overflow-auto",title:n,src:l,onLoad:()=>URL.revokeObjectURL(l)})},K=({fileName:n,contents:c,type:s})=>{const l=new Blob([Uint8Array.from(atob(c),r=>r.charCodeAt(0))],{type:s}),o=URL.createObjectURL(l);return e.jsx("div",{className:"flex-grow overflow-auto flex items-center justify-center",children:e.jsx("img",{onLoad:()=>URL.revokeObjectURL(o),className:"max-w-[calc(100%-50px)] max-h-[calc(100%-50px)] object-contain",src:o,alt:n})})};export{_ 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.