import{j as e,aT as $,X as v,L as _,al as r,aY as U,bg as X,T as N,bh as z,bi as F,bj as H,bb as B,aS as V,bk as G,bl as J,bm as O}from"./vendor-mui-core-CDEc-eG6.js";import{bj as Q,as as Y,bk as I,J as q,bi as K,aa as Z}from"./vendor-ux-PO0jFgJf.js";import{r as m}from"./vendor-react-DX7tU9aY.js";import{i as ee,A as te}from"./vendor-hooks-Ca2cSNuD.js";import{w as D,l as L,H as se,k as oe,b as ae,d as ne,c as re}from"./index-CgSpL7jz.js";import{M as ie}from"./vendor-utils-_C9URqjS.js";import{N as ce}from"./index-BvUXcJcd.js";import{W as le}from"./did-address-BNKX5oDP.js";import{w as pe}from"./wrap-locale-AxlzuLIu.js";import{u as de}from"./use-passport-id-B-b-_oYF.js";import{g as me}from"./get-safe-url-uxJSMQTF.js";import{c as ue}from"./passport-2AVRJTQK.js";import"./vendor-arcblock-BVQTtbN-.js";import"./purify.es-HRjpPm7y.js";import"./index-C2_MQP4T.js";import"./create-passport-svg-DNOT-xbE.js";function M({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),b=n=>{if(n<0||n>s.length-1)return;g(n);const c=w.current.clientWidth;d(n*(l+p)-(c-l)/2+p*.5),i(n)};m.useEffect(()=>{b(f);const n=c=>c.preventDefault();w.current.addEventListener("touchmove",n,{passive:!1})},[]);let a;const k=n=>{a=n.touches[0].clientX},y=n=>{const c=n.changedTouches[0],j=a-c.clientX;Math.abs(j)>60&&(j>0?b(x+1):b(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((n,c)=>e.jsx("div",{className:`card-item ${c===x?"selected":""}`,style:{width:l,height:u,margin:p/2},onClick:()=>b(c),children:n.display?e.jsx("div",{className:"card-content",children:e.jsx(ce,{data:n.display,style:{width:"100%",height:"100%"}})}):e.jsx("div",{className:"card-content",dangerouslySetInnerHTML:{__html:n.src}})},n.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;
      }
    }
  }
`;M.propTypes={list:v.array,width:v.number,height:v.number,cardSpace:v.number,onSelect:v.func,defaultIndex:v.number};function fe({icon:s,active:l,completed:u}){const p={1:e.jsx(O,{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=_(t=>t.breakpoints.down("sm")),o=ee({user:null,passport:null,success:!1,activeStep:0}),d=m.useRef({sessionToken:"",refreshToken:"",csrfToken:""}),{setPassportId:w,clearPassportId:b}=de(),{t:a,locale:k}=m.useContext(Q),{wallet:y}=Y(),[n,c]=m.useState(0),{searchParams:j}=new URL(window.location.href),P=()=>{o.activeStep++},W=t=>{o.user=t.user},A=()=>{P()},E=(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()){q(()=>import("./index-qpadg6GT.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}b(),window.location.replace("/")},R=t=>{o.passport=t.target.value},[S]=te({leftTime:n,onEnd:()=>{T()}}),C=[{label:a("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:600*1e3,webWalletUrl:l,onSuccess:W,locale:k,messages:{title:a("lostPassport.recoverDialog.title"),scan:a("lostPassport.recoverDialog.scan"),confirm:a("lostPassport.recoverDialog.confirm"),success:a("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(U,{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(M,{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=>R({target:{value:o.user.passportTypes[t].id}}),defaultIndex:0})}),e.jsx(r,{sx:{textAlign:"center"},children:e.jsx(I,{variant:"contained",color:"primary",onClick:()=>A(),disabled:!o.passport,children:a("common.next")})})]})}},{label:a("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:600*1e3,webWalletUrl:l,onSuccess:E,forceConnected:!1,locale:k,messages:{title:`${a("lostPassport.receiveDialog.title")}`,scan:a("lostPassport.receiveDialog.scan"),confirm:a("lostPassport.receiveDialog.confirm"),success:a("lostPassport.receiveDialog.success")},extraParams:t})}},{label:a("common.complete"),content:()=>(n===0&&c(3e3),e.jsxs(r,{sx:{textAlign:"center"},children:[e.jsx(r,{sx:{mb:3,color:"success.main"},children:e.jsx(X,{style:{fontSize:60}})}),e.jsx(N,{component:"p",variant:"body1",className:"subheader",children:a("issuePassport.dialog.success")}),e.jsx(N,{component:"p",variant:"body2",color:"gray",children:y&&L()?a("issuePassport.dialog.autoClose",{seconds:Math.round(S/1e3)}):a("issuePassport.dialog.autoJump",{seconds:Math.round(S/1e3)})}),e.jsx(I,{style:{marginTop:40},variant:"contained",color:"primary",onClick:T,children:a("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(F,{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:a("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;
  }
`,be=pe(xe);function Ae(){const s=K(),{t:l}=Z(),u=({sessionToken:p,refreshToken:i,csrfToken:f}={})=>{p&&ae(p),i&&ne(i),f&&re(f)};return e.jsxs(e.Fragment,{children:[e.jsx(se,{children:e.jsx("title",{children:l("pageTitle.lostPassport")})}),e.jsx(be,{SessionContext:oe,webWalletUrl:s,createPassportSvg:ue,passportColor:window?.env?.passportColor||"auto",onLogin:u})]})}export{Ae as default};
