1import{u as e,k as s,j as t,S as n,T as o,B as a,C as r,a as i,A as c,x as l,v as d,a3 as p,a4 as u,w as h,D as m,b as v,Q as x,R as j,U as g,V as y,W as C,X as w,g as f}from"./mui-BIt7sjlH.js";import{u as b,r as S}from"./vendor-DeDd1S9d.js";import{u as k,D as L}from"./money-ov5fU57B.js";import{D as _}from"./DigiMeetInput-B3krFOjE.js";import{B as z,b as I,Q as W,ab as $}from"./MainRoot-FScJt-ZS.js";import"./detectCountry-CTPjzCUo.js";import"./authSlice-CxxidS2C.js";import"./tokenStorage-CeXMvGe6.js";import"./auth.service-C7ZLVihG.js";import{D as R}from"./DigiMeetQRScanner-fWDxy8p3.js";import"./notistack.esm-BGCormb5.js";import{S as A}from"./types-8qtgno_0.js";import{a as D,u as E}from"./utils-DBxTrBUE.js";import{L as N}from"./LockOutlined-DkBIXJI4.js";import"./redux-lwcHWwR4.js";import"./index-eA1xtCXN.js";import"./auth-8xEyIOu9.js";import"./common-Dm41EYmf.js";import"./validation-FYHBKRea.js";import"./events-CLGt6NDe.js";import"./auth-BQKCBePa.js";import"./common-G9QmiqkL.js";import"./validation-CJweYQ-K.js";import"./events-DGEr86Un.js";import"./auth-DcIBvBaz.js";import"./common-CEU27LaV.js";import"./validation-BofHafM3.js";import"./events-CISlmPeU.js";import"./auth-zDok9JUf.js";import"./common-B_Kk5GYn.js";import"./validation-ma0VSr3d.js";import"./events-hSI99kJl.js";import"./index-B00SL2qx.js";import"./ArrowBack-p_gctqnQ.js";import"./ArrowForward-DXmyo7Mf.js";import"./firebase-zcDYupuk.js";import"./PaymentGatewayHost-DZuZ2Q6z.js";const P=D.create({baseURL:"https://api.digimeet.ai/api/organization/sponsor-capture",timeout:3e4,headers:{Accept:"application/json"}}),T=e=>`sponsor_session_${e}`,O=e=>sessionStorage.getItem(T(e)),Q=(e,s)=>sessionStorage.setItem(T(e),s),U=e=>sessionStorage.removeItem(T(e));function M(e){const s=O(e);return s?{Authorization:`Bearer ${s}`}:{}}const B={getInfo:async e=>(await P.get(`/${e}/info`)).data.data,async authenticate(e,s){const t=await P.post(`/${e}/authenticate`,{password:s});Q(e,t.data.data.token)},scan:async(e,s)=>(await P.post(`/${e}/scan`,{scannedValue:s},{headers:M(e)})).data.data.capture,listLeads:async e=>(await P.post(`/${e}/leads`,{},{headers:M(e)})).data.data.leads,exportCsv:async e=>(await P.post(`/${e}/export`,{},{headers:M(e),responseType:"blob"})).data},H=()=>{const{token:D=""}=b(),{t:P}=E(["events","common"]),T=e(),Q=s(T.breakpoints.down("sm")),{trackEvent:M}=k(),H={height:"100dvh",width:"100%",overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},[F,V]=S.useState(!0),[G,K]=S.useState(null),[X,Y]=S.useState(null),[q,Z]=S.useState(!1),[J,ee]=S.useState(""),[se,te]=S.useState(!1),[ne,oe]=S.useState([]),[ae,re]=S.useState(!1),[ie,ce]=S.useState({open:!1,message:"",severity:"success"}),le=S.useCallback((e,s="success")=>{ce({open:!0,message:e,severity:s})},[]);S.useEffect(()=>{let e=!1;return(async()=>{var s,t;V(!0);try{const s=await B.getInfo(D);if(e)return;K(s),Z(!!O(D)),M("page_viewed",{page_name:"sponsor_lead_capture",page_section:"public"})}catch(n){e||Y((null==(t=null==(s=null==n?void 0:n.response)?void 0:s.data)?void 0:t.message)||P("events:sponsorCapture.linkError","This sponsor link is invalid or no longer active."))}finally{e||V(!1)}})(),()=>{e=!0}},[D]);const de=S.useCallback(async()=>{var e;try{const e=await B.listLeads(D);oe(e)}catch(s){401===(null==(e=null==s?void 0:s.response)?void 0:e.status)&&(U(D),Z(!1),le(P("events:sponsorCapture.sessionExpired","Session expired. Please enter the password again."),"error"))}},[D,le,P]);S.useEffect(()=>{q&&de()},[q,de]);const pe=S.useCallback(async()=>{var e,s;if(J){te(!0);try{await B.authenticate(D,J),Z(!0),ee(""),M("sponsor_capture_authenticated",{token:D}),le(P("events:sponsorCapture.accessGranted","Access granted"),"success")}catch(t){le((null==(s=null==(e=null==t?void 0:t.response)?void 0:e.data)?void 0:s.message)||P("events:sponsorCapture.invalidPassword","Invalid password"),"error")}finally{te(!1)}}},[J,D,le,P,M]),ue=S.useCallback(async e=>{var s,t,n;re(!1);try{const s=await B.scan(D,e);M("sponsor_lead_scanned",{token:D,success:!0}),oe(e=>{const t=e.filter(e=>e._id!==s._id);return[s,...t]}),le(P("events:sponsorCapture.leadCaptured","Captured {{name}}",{name:`${s.contact.firstName} ${s.contact.lastName}`.trim()||P("events:sponsorCapture.attendee","attendee")}),"success")}catch(o){M("sponsor_lead_scanned",{token:D,success:!1}),401===(null==(s=null==o?void 0:o.response)?void 0:s.status)&&(U(D),Z(!1)),le((null==(n=null==(t=null==o?void 0:o.response)?void 0:t.data)?void 0:n.message)||P("events:sponsorCapture.scanFailed","Could not read that code"),"error")}},[D,le,P,M]),he=S.useCallback(async()=>{var e,s;try{const e=await B.exportCsv(D),s=window.URL.createObjectURL(e),t=document.createElement("a");t.href=s,t.download=`my-leads-${D}.csv`,document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(s),M("sponsor_leads_exported",{event_id:"",link_id:D,scope:"sponsor"})}catch(t){le((null==(s=null==(e=null==t?void 0:t.response)?void 0:e.data)?void 0:s.message)||P("common:errors.generic","Something went wrong"),"error")}},[D,le,P,M]),me=S.useMemo(()=>{const e=ne.filter(e=>"approved"===e.approvalStatus).length,s=ne.filter(e=>"pending"===e.approvalStatus).length;return{total:ne.length,approved:e,pending:s}},[ne]),ve=e=>{const s={approved:{color:T.palette.success.main,label:P("events:sponsorLeads.status.approved","Approved")},rejected:{color:T.palette.error.main,label:P("events:sponsorLeads.status.rejected","Rejected")},pending:{color:T.palette.warning.main,label:P("events:sponsorLeads.status.pending","Pending")}},{color:n,label:o}=s[e];return t.jsx(d,{size:"small",label:o,sx:{bgcolor:f(n,.12),color:n,fontWeight:600}})},xe=t.jsxs(n,{direction:"row",spacing:.75,alignItems:"center",children:[t.jsx(N,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o,{variant:"body2",color:"text.secondary",children:P("events:sponsorCapture.contactHidden","Contact hidden until approved")})]});if(F)return t.jsx(a,{display:"flex",justifyContent:"center",alignItems:"center",sx:{height:"100dvh",width:"100%"},children:t.jsx(r,{})});if(X)return t.jsx(a,{sx:H,children:t.jsx(i,{maxWidth:"sm",sx:{py:8},children:t.jsx(c,{severity:"error",children:X})})});const je=t.jsxs(a,{sx:{textAlign:"center",mb:3},children:[t.jsx(l,{sx:{bgcolor:T.palette.primary.main,width:44,height:44,mx:"auto",mb:1},children:t.jsx(z,{fontSize:"small"})}),t.jsx(o,{variant:"subtitle1",fontWeight:700,children:(null==G?void 0:G.sponsorName)||P("events:sponsorCapture.sponsor","Sponsor")}),(null==G?void 0:G.sponsorCompany)&&t.jsx(o,{variant:"body2",color:"text.secondary",children:G.sponsorCompany}),(null==G?void 0:G.eventTitle)&&t.jsx(d,{size:"small",label:G.eventTitle,sx:{mt:1}})]});return q?t.jsx(a,{sx:H,children:t.jsxs(i,{maxWidth:"md",sx:{py:4},children:[t.jsxs(a,{sx:{maxWidth:480,mx:"auto"},children:[je,t.jsxs(n,{direction:"row",spacing:1,justifyContent:"center",mb:2,children:[t.jsx(d,{label:P("events:sponsorCapture.totalLeads","{{n}} leads",{n:me.total})}),t.jsx(d,{color:"success",variant:"outlined",label:P("events:sponsorCapture.approvedLeads","{{n}} approved",{n:me.approved})}),t.jsx(d,{color:"warning",variant:"outlined",label:P("events:sponsorCapture.pendingLeads","{{n}} pending",{n:me.pending})})]}),t.jsx(L,{fullWidth:!0,size:"small",icon:t.jsx(W,{}),onClick:()=>re(!0),children:P("events:sponsorCapture.scanAttendee","Scan attendee QR")}),t.jsxs(n,{direction:"row",spacing:.75,alignItems:"center",justifyContent:"center",sx:{mt:1},children:[t.jsx(N,{sx:{fontSize:15,color:"text.secondary"}}),t.jsx(o,{variant:"caption",color:"text.secondary",children:P("events:sponsorCapture.privacyNote","Contact details unlock after the organizer approves.")})]})]}),t.jsx(m,{sx:{my:2.5}}),t.jsxs(n,{direction:"row",justifyContent:"space-between",alignItems:"center",mb:1,children:[t.jsx(o,{variant:"subtitle1",fontWeight:700,children:P("events:sponsorCapture.myLeads","My leads")}),t.jsx(v,{size:"small",color:"inherit",startIcon:t.jsx($,{}),onClick:he,disabled:0===ne.length,children:P("events:sponsorCapture.downloadCsv","Download CSV")})]}),0===ne.length?t.jsx(c,{severity:"info",children:P("events:sponsorCapture.noLeads","No leads yet. Scan an attendee QR to start.")}):Q?t.jsx(n,{spacing:1.25,children:ne.map(e=>{const s="approved"===e.approvalStatus,r=`${e.contact.firstName} ${e.contact.lastName}`.trim();return t.jsx(p,{children:t.jsxs(u,{sx:{py:1.5,"&:last-child":{pb:1.5}},children:[t.jsxs(n,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[t.jsxs(a,{children:[t.jsx(o,{fontWeight:700,children:r||P("events:sponsorCapture.attendee","Attendee")}),(e.contact.designation||e.contact.company)&&t.jsx(o,{variant:"body2",color:"text.secondary",children:[e.contact.designation,e.contact.company].filter(
1Boolean).join(" · ")})]}),ve(e.approvalStatus)]}),t.jsx(m,{sx:{my:1}}),s?t.jsxs(n,{spacing:.25,children:[e.contact.email&&t.jsx(o,{variant:"body2",children:e.contact.email}),e.contact.phoneCountryCode&&t.jsxs(o,{variant:"body2",color:"text.secondary",children:[P("events:sponsorLeads.col.countryCode","Country Code"),": ",e.contact.phoneCountryCode]}),e.contact.phone&&t.jsxs(o,{variant:"body2",color:"text.secondary",children:[P("events:sponsorLeads.col.phone","Phone"),": ",e.contact.phone]})]}):xe]})},e._id)})}):t.jsx(x,{component:p,sx:{border:`1px solid ${T.palette.divider}`,boxShadow:"none"},children:t.jsxs(j,{size:"small",children:[t.jsx(g,{children:t.jsxs(y,{children:[t.jsx(C,{children:P("events:sponsorLeads.col.name","Name")}),t.jsx(C,{children:P("events:sponsorLeads.col.designation","Designation")}),t.jsx(C,{children:P("events:sponsorLeads.col.company","Company")}),t.jsx(C,{children:P("events:sponsorLeads.col.email","Email")}),t.jsx(C,{children:P("events:sponsorLeads.col.countryCode","Country Code")}),t.jsx(C,{children:P("events:sponsorLeads.col.phone","Phone")}),t.jsx(C,{children:P("events:sponsorLeads.col.status","Status")})]})}),t.jsx(w,{children:ne.map(e=>{const s="approved"===e.approvalStatus,n=`${e.contact.firstName} ${e.contact.lastName}`.trim();return t.jsxs(y,{hover:!0,children:[t.jsx(C,{sx:{fontWeight:600},children:n||P("events:sponsorCapture.attendee","Attendee")}),t.jsx(C,{children:e.contact.designation||"â"}),t.jsx(C,{children:e.contact.company||"â"}),s?t.jsxs(t.Fragment,{children:[t.jsx(C,{children:e.contact.email||"â"}),t.jsx(C,{children:e.contact.phoneCountryCode||"â"}),t.jsx(C,{children:e.contact.phone||"â"})]}):t.jsx(C,{colSpan:3,children:xe}),t.jsx(C,{children:ve(e.approvalStatus)})]},e._id)})})]})}),t.jsx(R,{open:ae,onClose:()=>re(!1),onScanSuccess:ue,context:A.DIRECT_SCAN,title:P("events:sponsorCapture.scanTitle","Scan attendee QR"),description:P("events:sponsorCapture.scanDescription","Point the camera at the attendeeâs event QR code")}),t.jsx(h,{open:ie.open,autoHideDuration:3e3,onClose:()=>ce(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:t.jsx(c,{severity:ie.severity,sx:{width:"100%"},children:ie.message})})]})}):t.jsx(a,{sx:H,children:t.jsxs(i,{maxWidth:"xs",sx:{py:6},children:[je,t.jsx(p,{children:t.jsx(u,{children:t.jsxs(n,{spacing:2,alignItems:"center",children:[t.jsx(I,{color:"primary"}),t.jsx(o,{variant:"subtitle1",fontWeight:600,children:P("events:sponsorCapture.enterPassword","Enter access password")}),t.jsx(o,{variant:"body2",color:"text.secondary",textAlign:"center",children:P("events:sponsorCapture.passwordPrompt","Enter the password the organizer shared with you.")}),t.jsx(a,{width:"100%",children:t.jsx(_,{fullWidth:!0,type:"password",showPasswordToggle:!0,label:P("events:sponsorCapture.password","Password"),value:J,onChange:e=>ee(e.target.value),onKeyDown:e=>"Enter"===e.key&&pe()})}),t.jsx(L,{fullWidth:!0,onClick:pe,loading:se,disabled:!J,children:P("events:sponsorCapture.unlock","Unlock")})]})})}),t.jsx(h,{open:ie.open,autoHideDuration:3e3,onClose:()=>ce(e=>({...e,open:!1})),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:t.jsx(c,{severity:ie.severity,sx:{width:"100%"},children:ie.message})})]})})};export{H 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.