1import{h as L,V as H,r as v,j as s,bP as q,_ as w}from"./app-CL7tOXJE.js";import{p as R}from"./projectCommercial-BcXy4EUu.js";import{u as F,L as W,E as I,b as T,h as P,v as z,f as B,P as J,j as $,d as O,i as V,e as K,W as Q,M as G,F as U,S as X,g as Y}from"./WorkspaceShell-t0rNJqHE.js";import{S as D}from"./workspaceLinks-CH8ZeY4T.js";import"./ParityModuleNav-bhsU3VJi.js";import"./projects-D4bLCy0h.js";import"./arrow-left-DDdzRZMD.js";import"./refresh-cw-CfyLWpqZ.js";import"./wrench-BgkooGmq.js";import"./file-pen-line-C5BgFvkc.js";import"./user-check-Of3A318o.js";import"./chart-column-CDiJHygD.js";import"./receipt-text-CXrU8vJ2.js";import"./book-open-BbHlDuhv.js";const E={approve:"Approve",reject:"Reject","needs-info":"Ask for info"};function he(){const e=L.c(34),{id:t}=H(),l=t===void 0?"":t,[r,p]=v.useState("pending");let m;e[0]!==l||e[1]!==r?(m=()=>R.listProjectApprovals(l,r||void 0),e[0]=l,e[1]=r,e[2]=m):m=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[3]=d):d=e[3];let o;e[4]!==l||e[5]!==r?(o=[l,r],e[4]=l,e[5]=r,e[6]=o):o=e[6];const a=F(m,d,o),[n,c]=v.useState(null),[g,M]=v.useState(null),k=`${a.data.length} approval${a.data.length===1?"":"s"}`;let y,b,N,S,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=i=>p(i.target.value),b=s.jsx("option",{value:"pending",children:"Pending"}),N=s.jsx("option",{value:"approved",children:"Approved"}),S=s.jsx("option",{value:"rejected",children:"Rejected"}),C=s.jsx("option",{value:"",children:"All"}),e[7]=y,e[8]=b,e[9]=N,e[10]=S,e[11]=C):(y=e[7],b=e[8],N=e[9],S=e[10],C=e[11]);let u;e[12]!==r?(u=s.jsxs("select",{"aria-label":"Status",className:`${V} w-40`,value:r,onChange:y,children:[b,N,S,C]}),e[12]=r,e[13]=u):u=e[13];let x;e[14]!==a.data||e[15]!==a.error||e[16]!==a.loading||e[17]!==a.reload||e[18]!==r?(x=a.loading?s.jsx(W,{}):a.error?s.jsx(I,{message:a.error,onRetry:a.reload}):a.data.length===0?s.jsx(T,{icon:D,message:r==="pending"?"Nothing waiting for a decision on this project.":"No approvals match this filter."}):s.jsx("ul",{className:"divide-y divide-neutral-100 dark:divide-neutral-800",children:a.data.map(i=>s.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"font-semibold text-neutral-800 dark:text-neutral-100",children:i.title}),s.jsxs("p",{className:"mt-0.5 text-xs text-neutral-500",children:[P(i.approval_type||i.entity_type),i.amount!==void 0?` · ${z(i.amount)}`:""," · Requested ",B(i.requested_at)]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(J,{value:i.status}),s.jsx("button",{type:"button",className:$,onClick:()=>M(i),"aria-label":"Comments",children:s.jsx(q,{className:"h-4 w-4"})}),i.status==="pending"&&["needs-info","reject","approve"].map(_=>s.jsx("button",{type:"button",className:_==="approve"?O:$,onClick:()=>c({item:i,action:_}),children:E[_]},_))]})]},i.id))}),e[14]=a.data,e[15]=a.error,e[16]=a.loading,e[17]=a.reload,e[18]=r,e[19]=x):x=e[19];let j;e[20]!==u||e[21]!==x||e[22]!==k?(j=s.jsx(K,{title:k,action:u,children:x}),e[20]=u,e[21]=x,e[22]=k,e[23]=j):j=e[23];let h;e[24]!==n||e[25]!==a?(h=n&&s.jsx(Z,{item:n.item,action:n.action,onClose:()=>c(null),onDone:()=>{c(null),a.reload()}}),e[24]=n,e[25]=a,e[26]=h):h=e[26];let f;e[27]!==g?(f=g&&s.jsx(ee,{item:g,onClose:()=>M(null)}),e[27]=g,e[28]=f):f=e[28];let A;return e[29]!==l||e[30]!==j||e[31]!==h||e[32]!==f?(A=s.jsxs(Q,{projectId:l,title:"Approvals",subtitle:"Decisions waiting on this project.",icon:D,children:[j,h,f]}),e[29]=l,e[30]=j,e[31]=h,e[32]=f,e[33]=A):A=e[33],A}function Z({item:e,action:t,onClose:l,onDone:r}){const[p,m]=v.useState(""),[d,o]=v.useState(!1),a=t==="needs-info",n=async()=>{if(a&&!p.trim())return w.error("Say what information you need.");o(!0);try{await R.decideApproval(e.id,t,p),w.success(t==="approve"?"Approved":t==="reject"?"Rejected":"Asked for more information"),r()}catch(c){w.error(Y(c,"Could not record the decision.")),o(!1)}};return s.jsxs(G,{title:`${E[t]}
1: ${e.title}`,onClose:l,children:[e.amount!==void 0&&s.jsxs("p",{className:"mb-3 text-sm text-neutral-600 dark:text-neutral-300",children:["Amount: ",z(e.amount)]}),s.jsx(U,{label:a?"What do you need?":"Comment (optional)",children:s.jsx("textarea",{className:V,rows:3,value:p,onChange:c=>m(c.target.value)})}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx("button",{type:"button",className:$,onClick:l,children:"Cancel"}),s.jsxs("button",{type:"button",className:O,disabled:d,onClick:()=>void n(),children:[d&&s.jsx(X,{})," ",E[t]]})]})]})}function ee(e){const t=L.c(14),{item:l,onClose:r}=e;let p;t[0]!==l.id?(p=()=>R.listApprovalComments(l.id),t[0]=l.id,t[1]=p):p=t[1];let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[2]=m):m=t[2];let d;t[3]!==l.id?(d=[l.id],t[3]=l.id,t[4]=d):d=t[4];const o=F(p,m,d),a=`Comments · ${l.title}`;let n;t[5]!==o.data||t[6]!==o.error||t[7]!==o.loading||t[8]!==o.reload?(n=o.loading?s.jsx(W,{rows:2}):o.error?s.jsx(I,{message:o.error,onRetry:o.reload}):o.data.length===0?s.jsx(T,{icon:q,message:"No comments on this approval."}):s.jsx("ol",{className:"space-y-2",children:o.data.map(te)}),t[5]=o.data,t[6]=o.error,t[7]=o.loading,t[8]=o.reload,t[9]=n):n=t[9];let c;return t[10]!==r||t[11]!==a||t[12]!==n?(c=s.jsx(G,{title:a,onClose:r,children:n}),t[10]=r,t[11]=a,t[12]=n,t[13]=c):c=t[13],c}function te(e){return s.jsxs("li",{className:"rounded-lg bg-neutral-50 px-3 py-2 text-sm dark:bg-neutral-800/60",children:[s.jsx("p",{className:"text-neutral-800 dark:text-neutral-100",children:e.body||P(e.action)}),s.jsxs("p",{className:"text-xs text-neutral-400",children:[P(e.action||e.author)," · ",B(e.created_at,!0)]})]},e.id)}export{he as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.