const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DBOqxRpP.js","./index-CCv_8omK.js","./index-DGkT7afN.css"])))=>i.map(i=>d[i]);
import{r as d,cx as z,c6 as U,cy as F,cz as X,aF as B,j as s,s as E,o as k,E as H,aP as V,p as G,cA as K,w as D,K as p,cB as O,W as J,v as L,b8 as Q,T as I,cC as M,L as q,cD as Y,bK as Z,cE as ee,cF as te,u as se,x as ae,bC as oe,ar as ne,af as re}from"./index-CCv_8omK.js";import{V as ie}from"./ViewList-CvnWfuPG.js";import{D as ce}from"./Done-BuJjZzMV.js";import{N as le}from"./index-g_RqxcM4.js";import{w as pe}from"./wrap-locale-B1uKF2jP.js";import{g as de}from"./get-safe-url-B_yWzv49.js";import{S as ue,a as me,b as fe}from"./Stepper-D4Zig93k.js";import"./emotion-cache.browser.esm-CdT-VIlA.js";import"./index-gqKcev8E.js";var T=function(e){if(!e)return 0;var r=X(e).valueOf()-Date.now();return r<0?0:r},he=function(e){return{days:Math.floor(e/864e5),hours:Math.floor(e/36e5)%24,minutes:Math.floor(e/6e4)%60,seconds:Math.floor(e/1e3)%60,milliseconds:Math.floor(e)%1e3}},xe=function(e){e===void 0&&(e={});var r=e||{},l=r.leftTime,i=r.targetDate,u=r.interval,w=u===void 0?1e3:u,x=r.onEnd,g=d.useMemo(function(){return z(l)&&l>0?Date.now()+l:void 0},[l]),a="leftTime"in e?g:i,m=U(d.useState(function(){return T(a)}),2),h=m[0],f=m[1],o=F(x);d.useEffect(function(){if(!a){f(0);return}f(T(a));var v=setInterval(function(){var n,c=T(a);f(c),c===0&&(clearInterval(v),(n=o.current)===null||n===void 0||n.call(o))},w);return function(){return clearInterval(v)}},[a,w]);var j=d.useMemo(function(){return he(h)},[h]);return[h,j]};const ge=B(s.jsx("path",{d:"M19 9h-4V3H9v6H5l7 7zM5 18v2h14v-2z"}));function _({list:e=[],width:r=300,height:l=400,cardSpace:i=40,onSelect:u=()=>{},defaultIndex:w=0}){const[x,g]=d.useState(0),[a,m]=d.useState(0),h=d.useRef(null),f=n=>{if(n<0||n>e.length-1)return;g(n);const c=h.current.clientWidth;m(n*(r+i)-(c-r)/2+i*.5),u(n)};d.useEffect(()=>{f(w);const n=c=>c.preventDefault();h.current.addEventListener("touchmove",n,{passive:!1})},[]);let o;const j=n=>{o=n.touches[0].clientX},v=n=>{const c=n.changedTouches[0],y=o-c.clientX;Math.abs(y)>60&&(y>0?f(x+1):f(x-1))};return s.jsx(ve,{ref:h,onTouchStart:j,onTouchEnd:v,children:s.jsx("div",{className:"card-container",style:{transform:`translate(${-a}px, 0)`},children:e.map((n,c)=>s.jsx("div",{className:`card-item ${c===x?"selected":""}`,style:{width:r,height:l,margin:i/2},onClick:()=>f(c),children:n.display?s.jsx("div",{className:"card-content",children:s.jsx(le,{data:n.display,style:{width:"100%",height:"100%"}})}):s.jsx("div",{className:"card-content",dangerouslySetInnerHTML:{__html:n.src}})},n.id))})})}const ve=E.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;
      }
    }
  }
`;_.propTypes={list:k.array,width:k.number,height:k.number,cardSpace:k.number,onSelect:k.func,defaultIndex:k.number};function be({icon:e,active:r,completed:l}){const i={1:s.jsx(ie,{className:"step-icon"}),2:s.jsx(ge,{className:"step-icon"}),3:s.jsx(ce,{className:"step-icon"})},u=["step-icon-w"];return r&&u.push("step-icon-w--active"),l&&u.push("step-icon-w--completed"),s.jsx("div",{className:u.join(" "),children:i[String(e)]})}function we({SessionContext:e,webWalletUrl:r,createPassportSvg:l,passportColor:i,onLogin:u,teamDid:w}){const{api:x}=d.useContext(e),g=H(t=>t.breakpoints.down("sm")),a=V({user:null,passport:null,success:!1,activeStep:0}),m=d.useRef({sessionToken:"",refreshToken:"",csrfToken:""}),{setPassportId:h,clearPassportId:f}=Y(),{t:o,locale:j}=d.useContext(G),{wallet:v}=K(),[n,c]=d.useState(0),{searchParams:y}=new URL(window.location.href),P=()=>{a.activeStep++},$=t=>{a.user=t.user},W=()=>{P()},A=(t,b)=>{t?.passportId&&h(t.passportId),t?.sessionToken&&(m.current.sessionToken=b(t.sessionToken)),t?.refreshToken&&(m.current.refreshToken=b(t.refreshToken)),t?.csrfToken&&(m.current.csrfToken=b(t.csrfToken)),a.success=!0,P()},S=async()=>{if(v&&M()){Z(()=>import("./index-DBOqxRpP.js").then(b=>b.i),__vite__mapDeps([0,1,2]),import.meta.url).then(b=>{b.call("arcClosePage")});return}ee(u)&&u({sessionToken:m.current.sessionToken,refreshToken:m.current.refreshToken,csrfToken:m.current.csrfToken});const t=y.get("redirect");if(t){window.location.replace(de(t));return}f(),window.location.replace("/")},R=t=>{a.passport=t.target.value},[C]=xe({leftTime:n,onEnd:()=>{S()}}),N=[{label:o("lostPassport.recoverPassport"),content:()=>{if(!a.user){const t=y.get("scope")||"passport";return s.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:r,onSuccess:$,locale:j,messages:{title:o("lostPassport.recoverDialog.title"),scan:o("lostPassport.recoverDialog.scan"),confirm:o("lostPassport.recoverDialog.confirm"),success:o("lostPassport.recoverDialog.success")},extraParams:{scope:t}})}return s.jsxs(p,{className:"select-passport",children:[s.jsxs(p,{className:"user-info",sx:{my:1,display:"flex",alignItems:"center"},children:[s.jsx(O,{src:a.user.avatar,style:{width:48,height:48,backgroundColor:"transparent",marginRight:16}}),s.jsxs(p,{children:[s.jsx(p,{className:"name",children:a.user.fullName}),s.jsx(p,{className:"did",sx:{mt:1},children:s.jsx(J,{responsive:!g,compact:g,did:a.user.did})})]})]}),s.jsx(p,{children:s.jsx(_,{width:g?180:230,height:g?240:306,cardSpace:24,list:a.user.passportTypes.map(t=>({src:l({scope:t.scope,role:t.role,title:t.scope==="kyc"?t.name:t.title,issuer:t.issuer.name,issuerDid:t.issuer.id,ownerDid:a.user.did,ownerName:a.user.fullName,ownerAvatarUrl:a.user.avatar,preferredColor:i||"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:a.user.passportTypes[t].id}}),defaultIndex:0})}),s.jsx(p,{sx:{textAlign:"center"},children:s.jsx(L,{variant:"contained",color:"primary",onClick:()=>W(),disabled:!a.passport,children:o("common.next")})})]})}},{label:o("lostPassport.receivePassport"),content:()=>{const t={receiverDid:a.user.did,passportId:a.passport,teamDid:w||window?.blocklet?.did};return s.jsx(D,{popup:!0,open:!0,hideCloseButton:!0,className:"connect",action:"lost-passport-issue",checkFn:x.get,checkTimeout:10*60*1e3,webWalletUrl:r,onSuccess:A,forceConnected:!1,locale:j,messages:{title:`${o("lostPassport.receiveDialog.title")}`,scan:o("lostPassport.receiveDialog.scan"),confirm:o("lostPassport.receiveDialog.confirm"),success:o("lostPassport.receiveDialog.success")},extraParams:t})}},{label:o("common.complete"),content:()=>(n===0&&c(3e3),s.jsxs(p,{sx:{textAlign:"center"},children:[s.jsx(p,{sx:{mb:3,color:"success.main"},children:s.jsx(Q,{style:{fontSize:60}})}),s.jsx(I,{component:"p",variant:"body1",className:"subheader",children:o("issuePassport.dialog.success")}),s.jsx(I,{component:"p",variant:"body2",color:"gray",children:v&&M()?o("issuePassport.dialog.autoClose",{seconds:Math.round(C/1e3)}):o("issuePassport.dialog.autoJump",{seconds:Math.round(C/1e3)})}),s.jsx(L,{style:{marginTop:40},variant:"contained",color:"primary",onClick:S,children:o("issuePassport.dialog.loginWithPassport")})]}))}];return s.jsx(je,{children:s.jsxs(p,{className:"stepper",children:[s.jsx(ue,{className:"stepper-progress",alternativeLabel:!0,activeStep:a.activeStep,children:N.map(({label:t})=>s.jsx(me,{children:s.jsx(fe,{slots:{stepIcon:be},children:t})},t))}),s.jsx(p,{className:"stepper-content",children:N[a.activeStep].content()}),!a.success&&s.jsx(p,{sx:{textAlign:"center",fontSize:12},children:s.jsx(q,{href:"/",sx:{color:"#4598FA",textDecoration:"none"},children:o("lostPassport.return")})})]})})}const je=E(te)`
  padding-top: 46px;
  padding-bottom: 46px;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  @media (max-width: ${e=>e.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: ${e=>e.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: ${e=>e.theme.palette.grey[500]};
        z-index: 1;
        color: ${e=>e.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: ${e=>e.theme.palette.primary.main};
      }

      .step-icon-w--completed {
        background-color: ${e=>e.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: ${e=>e.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: ${e=>e.theme.breakpoints.values.sm}px) {
        width: 100%;
      }
    }

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

  .connect {
    background: #fafafa;
  }
`,ke=pe(we);function Me(){const{info:e}=se(),r=ae(e),l=({sessionToken:i}={})=>{i&&re(i)};return s.jsx(ke,{SessionContext:ne,webWalletUrl:r,createPassportSvg:i=>oe(i,e),passportColor:"default",onLogin:l,teamDid:e.did})}export{Me as default};
