import{j as e,at as $,W as b,J as A,ak as r,b4 as F,b0 as U,T as N,bP as z,bQ as X,bR as H,a$ as B,av as V,bF as G,bS as J,bT as Q}from"./vendor-mui-core-B5XNUjey.js";import{p as O,d as q,n as I,_ as K,s as Y,V as Z}from"./vendor-ux-BX9dSNUy.js";import{r as m}from"./vendor-react-CUXIiAnY.js";import{g as ee,n as te}from"./vendor-hooks-U4TTuKG0.js";import{v as D,M as L,H as se,S as oe,s as ne,b as ae,av as re}from"./index-Dijoh4El.js";import{T as ie}from"./vendor-utils-CFxoplqC.js";import{N as ce}from"./index-CUIcSX4q.js";import{W as le}from"./did-address-Qmm0nyiR.js";import{w as pe}from"./wrap-locale-Dk2yVg3Y.js";import{u as de}from"./use-passport-id-B-b-_oYF.js";import{g as me}from"./get-safe-url-pZvXlaJu.js";import{c as ue}from"./passport-BcfDxGFq.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D4Rvz_D3.js";import"./index-5B_H2zYd.js";import"./create-passport-svg-BwqsyTOz.js";function W({list:s=[],width:l=300,height:u=400,cardSpace:p=40,onSelect:i=()=>{},defaultIndex:f=0}){const[x,g]=m.useState(0),[o,d]=m.useState(0),w=m.useRef(null),v=a=>{if(a<0||a>s.length-1)return;g(a);const c=w.current.clientWidth;d(a*(l+p)-(c-l)/2+p*.5),i(a)};m.useEffect(()=>{v(f);const a=c=>c.preventDefault();w.current.addEventListener("touchmove",a,{passive:!1})},[]);let n;const k=a=>{n=a.touches[0].clientX},y=a=>{const c=a.changedTouches[0],j=n-c.clientX;Math.abs(j)>60&&(j>0?v(x+1):v(x-1))};return e.jsx(he,{ref:w,onTouchStart:k,onTouchEnd:y,children:e.jsx("div",{className:"card-container",style:{transform:`translate(${-o}px, 0)`},children:s.map((a,c)=>e.jsx("div",{className:`card-item ${c===x?"selected":""}`,style:{width:l,height:u,margin:p/2},onClick:()=>v(c),children:a.display?e.jsx("div",{className:"card-content",children:e.jsx(ce,{data:a.display,style:{width:"100%",height:"100%"}})}):e.jsx("div",{className:"card-content",dangerouslySetInnerHTML:{__html:a.src}})},a.id))})})}const he=$.div`
  overflow: hidden;
  mask-image: linear-gradient(to left, transparent, black 3%, black 97%, transparent);
  overflow: hidden;
  .card-container {
    display: flex;
    white-space: nowrap;
    width: max-content;
    transition: all ease 0.3s;
  }
  .card-item {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;

    .card-content {
      pointer-events: none;
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
      outline: #526ded solid 0;
      transition: all ease 0.2s;
      box-shadow: rgba(0, 0, 0, 0.2) 0 0 10px;
    }
    &.selected {
      cursor: default;
      .card-content {
        outline: #526ded solid 5px;
      }
    }
  }
`;W.propTypes={list:b.array,width:b.number,height:b.number,cardSpace:b.number,onSelect:b.func,defaultIndex:b.number};function fe({icon:s,active:l,completed:u}){const p={1:e.jsx(Q,{className:"step-icon"}),2:e.jsx(J,{className:"step-icon"}),3:e.jsx(G,{className:"step-icon"})},i=["step-icon-w"];return l&&i.push("step-icon-w--active"),u&&i.push("step-icon-w--completed"),e.jsx("div",{className:i.join(" "),children:p[String(s)]})}function xe({SessionContext:s,webWalletUrl:l,createPassportSvg:u,passportColor:p,onLogin:i,teamDid:f}){const{api:x}=m.useContext(s),g=A(t=>t.breakpoints.down("sm")),o=ee({user:null,passport:null,success:!1,activeStep:0}),d=m.useRef({sessionToken:"",refreshToken:"",csrfToken:""}),{setPassportId:w,clearPassportId:v}=de(),{t:n,locale:k}=m.useContext(O),{wallet:y}=q(),[a,c]=m.useState(0),{searchParams:j}=new URL(window.location.href),P=()=>{o.activeStep++},M=t=>{o.user=t.user},E=()=>{P()},R=(t,h)=>{t?.passportId&&w(t.passportId),t?.sessionToken&&(d.current.sessionToken=h(t.sessionToken)),t?.refreshToken&&(d.current.refreshToken=h(t.refreshToken)),t?.csrfToken&&(d.current.csrfToken=h(t.csrfToken)),o.success=!0,P()},T=async()=>{if(y&&L()){K(()=>import("./index-CMec_woq.js").then(h=>h.i),[],import.meta.url).then(h=>{h.call("arcClosePage")});return}ie(i)&&i({sessionToken:d.current.sessionToken,refreshToken:d.current.refreshToken,csrfToken:d.current.csrfToken});const t=j.get("redirect");if(t){window.location.replace(me(t));return}v(),window.location.replace("/")},_=t=>{o.passport=t.target.value},[S]=te({leftTime:a,onEnd:()=>{T()}}),C=[{label:n("lostPassport.recoverPassport"),content:()=>{if(!o.user){const t=j.get("scope")||"passport";return e.jsx(D,{popup:!0,open:!0,hideCloseButton:!0,className:"connect",action:"lost-passport-list",forceConnected:!1,autoConnect:!1,checkFn:x.get,checkTimeout:10*60*1e3,webWalletUrl:l,onSuccess:M,locale:k,messages:{title:n("lostPassport.recoverDialog.title"),scan:n("lostPassport.recoverDialog.scan"),confirm:n("lostPassport.recoverDialog.confirm"),success:n("lostPassport.recoverDialog.success")},extraParams:{scope:t}})}return e.jsxs(r,{className:"select-passport",children:[e.jsxs(r,{className:"user-info",sx:{my:1,display:"flex",alignItems:"center"},children:[e.jsx(F,{src:o.user.avatar,style:{width:48,height:48,backgroundColor:"transparent",marginRight:16}}),e.jsxs(r,{children:[e.jsx(r,{className:"name",children:o.user.fullName}),e.jsx(r,{className:"did",sx:{mt:1},children:e.jsx(le,{responsive:!g,compact:g,did:o.user.did})})]})]}),e.jsx(r,{children:e.jsx(W,{width:g?180:230,height:g?240:306,cardSpace:24,list:o.user.passportTypes.map(t=>({src:u({scope:t.scope,role:t.role,title:t.scope==="kyc"?t.name:t.title,issuer:t.issuer.name,issuerDid:t.issuer.id,ownerDid:o.user.did,ownerName:o.user.fullName,ownerAvatarUrl:o.user.avatar,preferredColor:p||"auto",extra:t.scope==="kyc"?{key:"Email",value:t.name}:void 0}),name:t.title,id:t.id,display:t.display})),onSelect:t=>_({target:{value:o.user.passportTypes[t].id}}),defaultIndex:0})}),e.jsx(r,{sx:{textAlign:"center"},children:e.jsx(I,{variant:"contained",color:"primary",onClick:()=>E(),disabled:!o.passport,children:n("common.next")})})]})}},{label:n("lostPassport.receivePassport"),content:()=>{const t={receiverDid:o.user.did,passportId:o.passport,teamDid:f||window?.blocklet?.did};return e.jsx(D,{popup:!0,open:!0,hideCloseButton:!0,className:"connect",action:"lost-passport-issue",checkFn:x.get,checkTimeout:10*60*1e3,webWalletUrl:l,onSuccess:R,forceConnected:!1,locale:k,messages:{title:`${n("lostPassport.receiveDialog.title")}`,scan:n("lostPassport.receiveDialog.scan"),confirm:n("lostPassport.receiveDialog.confirm"),success:n("lostPassport.receiveDialog.success")},extraParams:t})}},{label:n("common.complete"),content:()=>(a===0&&c(3e3),e.jsxs(r,{sx:{textAlign:"center"},children:[e.jsx(r,{sx:{mb:3,color:"success.main"},children:e.jsx(U,{style:{fontSize:60}})}),e.jsx(N,{component:"p",variant:"body1",className:"subheader",children:n("issuePassport.dialog.success")}),e.jsx(N,{component:"p",variant:"body2",color:"gray",children:y&&L()?n("issuePassport.dialog.autoClose",{seconds:Math.round(S/1e3)}):n("issuePassport.dialog.autoJump",{seconds:Math.round(S/1e3)})}),e.jsx(I,{style:{marginTop:40},variant:"contained",color:"primary",onClick:T,children:n("issuePassport.dialog.loginWithPassport")})]}))}];return e.jsx(ge,{children:e.jsxs(r,{className:"stepper",children:[e.jsx(z,{className:"stepper-progress",alternativeLabel:!0,activeStep:o.activeStep,children:C.map(({label:t})=>e.jsx(X,{children:e.jsx(H,{slots:{stepIcon:fe},children:t})},t))}),e.jsx(r,{className:"stepper-content",children:C[o.activeStep].content()}),!o.success&&e.jsx(r,{sx:{textAlign:"center",fontSize:12},children:e.jsx(B,{href:"/",sx:{color:"#4598FA",textDecoration:"none"},children:n("lostPassport.return")})})]})})}const ge=$(V)`
  padding-top: 46px;
  padding-bottom: 46px;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
    display: block;
  }
  .header {
    text-align: center;
    margin-bottom: 24px;
  }

  .stepper {
    padding: 24px;
    height: auto;
    width: 100%;
    min-height: 640px;
    display: flex;
    flex-direction: column;

    @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
      min-height: auto;
    }

    .stepper-progress {
      padding: 0;
      flex: 0;
      margin-bottom: 24px;

      .MuiStepLabel-label.MuiStepLabel-alternativeLabel {
        margin-top: 8px;
      }

      .MuiStepConnector-alternativeLabel {
        top: 24px;
      }

      .MuiStepConnector-lineHorizontal {
        height: 3px;
        border: none;
        background-color: #eaeaf0;
        border-radius: 1px;
      }

      .step-icon-w {
        background-color: ${s=>s.theme.palette.grey[500]};
        z-index: 1;
        color: ${s=>s.theme.palette.common.white};
        width: 50px;
        height: 50px;
        display: flex;
        border-radius: 50%;
        justify-content: center;
        align-items: center;
        .step-icon {
          font-size: 30px;
        }
      }

      .step-icon-w--active {
        background-color: ${s=>s.theme.palette.primary.main};
      }

      .step-icon-w--completed {
        background-color: ${s=>s.theme.palette.secondary.main};
      }
    }

    .stepper-content {
      padding: 0 64px;
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-bottom: 24px;

      .stepper-icon {
        margin-left: 40px;
      }

      .stepper-auth {
        padding: 0;

        .auth-title {
          margin-bottom: 16px;
        }
      }

      .stepper-tip {
        text-align: center;
        margin-bottom: 16px;
      }
      @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
        padding: 0;
      }
    }

    .stepper-actions {
      flex: 0;
      text-align: right;
      padding: 0 64px;
      display: none;
      .step-button {
        margin-right: 8px;
      }
    }

    .select-passport {
      width: 80%;
      @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
        width: 100%;
      }
    }

    .user-info {
      .name {
        font-weight: 500;
        font-size: 18px;
        line-height: 25px;
        color: ${s=>s.theme.palette.text.primary};
      }
    }
  }

  .connect {
    background: #fafafa;
  }
`,ve=pe(xe);function Ee(){const s=Y(),{t:l}=Z(),u=({sessionToken:p,refreshToken:i,csrfToken:f}={})=>{p&&ne(p),i&&ae(i),f&&re(f)};return e.jsxs(e.Fragment,{children:[e.jsx(se,{children:e.jsx("title",{children:l("pageTitle.lostPassport")})}),e.jsx(ve,{SessionContext:oe,webWalletUrl:s,createPassportSvg:ue,passportColor:window?.env?.passportColor||"auto",onLogin:u})]})}export{Ee as default};
