1import{w as K,t as J,r as o,bh as Q,bi as W,j as e,C as m,F as X,i as p,S as x,k as z,a5 as E,g as k,T as h,G as R,B as L,p as Z,v as F}from"./index-B1JCX_-d.js";import{S as u}from"./SEOHead-x5xN8jU_.js";import{C as ee}from"./CommentInput-D0CPnCAR.js";import{E as O}from"./ErrorDisplay-DhLlAZAz.js";import{e as se}from"./errors-j4AVLOck.js";import{R as re}from"./ResponsePanel-DFJbKUVr.js";import{u as te,s as ne,S as oe,I as ie,R as ae,j as le}from"./RecipientTable-DDdRkGPF.js";import{T as S}from"./Tooltip-V1HmJPbW.js";import{S as ce}from"./SegmentedControl-Ddrz7gA9.js";import{I as de}from"./IconTable-U-GBBQPS.js";import"./Textarea-S6TImZwF.js";import"./get-env-uyVen0u2.js";import"./InputBase-CWPbF_yb.js";import"./List-Bq6CPE7n.js";import"./index-C-iJI7vH.js";import"./ActionIcon-BGKkh9bM.js";import"./TextInput-D-E7ywd3.js";import"./Badge-BbXJu9l1.js";import"./IconX-PlZO4ulH.js";import"./IconSend-BnXFd0vC.js";import"./IconFileText-B1imSeiA.js";import"./Timeline-D8nsbBI5.js";import"./get-auto-contrast-value-Da6zqqWm.js";import"./IconInfoCircle-BUY0Ko0n.js";import"./IconUserEdit-DCGAQfzv.js";import"./Image-75lcnSv1.js";import"./Table-FcL28oTk.js";import"./get-style-object-DUJZA7T_.js";const me={approve:"approve",decline:"decline",sign:"submit your signature",recommend:"recommend","dont-recommend":"not recommend","request-more-info":"request more information",acknowledge:"acknowledge",accept:"accept this task",action:"complete this task",cancel:"cancel this request"},ue={edit:"Needs to Edit",acknowledge:"Needs to Acknowledge",recommend:"Needs to Recommend",action:"Needs to Action",sign:"Needs to Sign"};function Ye(){const{action:t,formId:c,responseId:a,participantKey:i}=K(),[d]=J(),g=d.get("role"),j=d.get("editURL"),M=j&&/^https?:\/\//i.test(j)?j:void 0,f=d.get("request"),$=d.get("requestor"),U=o.useMemo(()=>{if(!f)return;const[s,n]=f.split("/");if(s)return n&&n!=="0"?`#${s} (${n})`:`#${s}`},[f]),[Y,q]=o.useState(!1),[r,_]=o.useState(null),[A,B]=o.useState(!1),[l,D]=o.useState(""),[N,V]=te({key:"fa-recipient-view",defaultValue:"table"}),b=o.useRef(!1),v=!(t==="comment"),T=d.get("user")||"",P=o.useMemo(()=>!t||!i?null:{email:"",status:"Current",issue_date:null,response_date:null,comment:"",settings:{Role:g&&ue[g]||"Needs to Approve",Order:1},participant_number:0,participant_key:i},[t,g,i]),C=o.useCallback(s=>{if(s.redirect){window.location.href=s.redirect;return}_(s)},[]),y=o.useCallback(async()=>{if(!(!t||!c||!a||!i)){q(!0);try{const s={user:T};t==="cancel"&&l.trim()&&(s.comment=l.trim());const n=await ne(t,c,a,i,s);C(n)}catch(s){const n=se(s,"Failed to submit response.");_({response_type:"error",response_message:n.error,error_code:n.error_code,error_context:n.context})}finally{q(!1)}}},[t,c,a,i,T,l,C]);o.useEffect(()=>{if(!(!v||b.current)){if(t!=="cancel"&&localStorage.getItem("fa-human-verified")){b.current=!0,y();return}B(!0)}},[v,t,y]);const w=Q[t??""]||(t?t.charAt(0).toUpperCase()+t.slice(1):"");if(!t||!c||!a||!i||!W.has(t))return e.jsxs(e.Fragment,{children:[e.jsx(u,{title:"Invalid Link",noIndex:!0}),e.jsx(m,{size:"sm",py:"xl",children:e.jsx(O,{message:"This response link is invalid. Please check the link and try again."})})]});if(v&&!r&&!A)return e.jsx(X,{});if(A&&!r){const s=t==="cancel";return e.jsxs(e.Fragment,{children:[e.jsx(u,{title:`Confirm ${w}`,noIndex:!0}),e.jsx(m,{size:"sm",py:"xl",children:e.jsx(p,{shadow:"sm",p:"xl",radius:"md",children:e.jsxs(x,{align:"center",gap:"lg",children:[e.jsx(z,{size:80,radius:"xl",variant:"light",color:"yellow",children:e.jsx(E,{size:40})}),e.jsxs(k,{order:4,ta:"center",children:["Are you sure you want to ",me[t??""]??w.toLowerCase(),"?"]}),!s&&e.jsx(h,{ta:"center",c:"dimmed",size:"sm",children:"This one-time check confirms you are a person, not an automated email scanner. You won't be asked again on this browser."}),s&&e.jsx("div",{style:{width:"100%"},children:e.jsx(ee,{value:l,onChange:D,label:"Provide a reason for cancelling",required:!0})}),e.jsxs(R,{children:[e.jsx(S,{label:"Enter a reason before cancelling",disabled:!s||!!l.trim(),children:e.jsx("span",{children:e.jsx(L,{color:s?"red":"brand",loading:Y,disabled:s&&!l.trim(),onClick:()=>{b.current=!0,localStorage.setItem("fa-human-verified","1"),y()},children:s?"Yes, cancel":"Yes"})})}),e.jsx(L,{variant:"default",onClick:()=>_({response_type:"warning",response_message:"No action was taken. You can safely close this tab."}),children:"No"})]})]})})})]})}const I=r?.recipients?.length?{response_id:a,request_num:parseInt(r.request_num||"0")||0,revision_num:r.revision_num||0,overall_status:r.overall_status||"",request_date:r.request_date||"",requestor:r.requestor||"",requestor_key:"",edit_url:"",recipients:r.recipients}:null;if(r){const s=r.response_type;if(s==="error")return e.jsxs(e.Fragment,{children:[e.jsx(u,{title:"Response Submitted",noIndex:!0}),e.jsx(m,{size:"sm",py:"xl",children:e.jsx(O,{message:r.response_message,errorCode:r.error_code,context:r.error_context})})]});const n=s==="warning"?"yellow":"green",G=s==="warning"?E:Z,H=s==="warning"?"Response not recorded":"Response submitted";return e.jsxs(e.Fragment,{children:[e.jsx(u,{title:"Response Submitted",noIndex:!0}),e.jsxs(m,{size:"sm",py:"xl",children:[e.jsx(p,{shadow:"sm",p:"xl",radiu
1s:"md",children:e.jsxs(x,{align:"center",gap:"lg",children:[e.jsx(z,{size:80,radius:"xl",variant:"light",color:n,className:s==="success"?"stroke-draw":void 0,children:e.jsx(G,{size:40})}),e.jsx(k,{order:3,ta:"center",children:H}),e.jsx(h,{ta:"center",c:"dimmed",children:r.response_message}),e.jsx(h,{size:"sm",c:"dimmed",children:"You can safely close this tab."})]})}),I&&!r.exclude_tracking&&e.jsx(p,{shadow:"sm",p:"xl",radius:"md",mt:"lg",children:e.jsxs(x,{gap:"md",children:[e.jsxs(R,{gap:"sm",children:[e.jsxs(k,{order:4,children:["Request #",r.request_num||"0",!!r.revision_num&&` (${r.revision_num})`]}),e.jsx(oe,{status:r.overall_status||"",size:"md"})]}),e.jsx(R,{justify:"flex-end",children:e.jsx(ce,{value:N,onChange:V,size:"xs",data:[{label:e.jsx(F,{style:{gap:4},children:e.jsx(S,{label:"Table view",children:e.jsx(de,{size:16})})}),value:"table"},{label:e.jsx(F,{style:{gap:4},children:e.jsx(S,{label:"Timeline view",children:e.jsx(ie,{size:16})})}),value:"timeline"}]})}),N==="timeline"?e.jsx(ae,{record:I,requestNum:r.request_num||"0",formId:"",readOnly:!0,hideComments:!0}):e.jsx(le,{record:I,requestNum:r.request_num||"0",formId:"",readOnly:!0,hideComments:!0})]})})]})]})}return e.jsxs(e.Fragment,{children:[e.jsx(u,{title:`${w} Request`,noIndex:!0}),e.jsx(m,{size:"sm",py:"xl",children:e.jsx(p,{shadow:"sm",p:"xl",radius:"md",children:e.jsx(x,{gap:"lg",children:P?e.jsx(re,{recipient:P,formId:c,responseId:a,editUrl:M??void 0,onComplete:C,requestLabel:U,hideRequestMoreInfo:$==="false"}):e.jsx(h,{ta:"center",c:"dimmed",children:"No actions available for this link."})})})})]})}export{Ye 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.