import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{T as r,j as i}from"./useActiveWallet-CEs8euQ3.js";var a=e(t());function o({title:e,titleId:t,...n},r){return a.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?a.createElement(`title`,{id:t},e):null,a.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M10.5 1.5H8.25A2.25 2.25 0 0 0 6 3.75v16.5a2.25 2.25 0 0 0 2.25 2.25h7.5A2.25 2.25 0 0 0 18 20.25V3.75a2.25 2.25 0 0 0-2.25-2.25H13.5m-3 0V3h3V1.5m-3 0h3m-3 18.75h3`}))}var s=a.forwardRef(o),c=n(),l=e(i(),1),u=r.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0px 0px 30px;
  @media (max-width: 440px) {
    padding: 10px 10px 20px;
  }
`,d=r.div`
  font-size: 18px;
  line-height: 30px;
  text-align: center;
  font-weight: 600;
  margin-bottom: 10px;
`,f=r.div`
  font-size: 0.875rem;

  text-align: center;
`,p=r.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
  padding: 20px 0;
  @media (max-width: 440px) {
    padding: 10px 10px 20px;
  }
`,m=r.div`
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding: 1rem 0rem 0rem;
  flex-grow: 1;
  width: 100%;
`,h=r.div`
  width: 25px;
  display: flex;
  align-items: center;
  justify-content: flex-start;

  > svg {
    z-index: 2;
    height: 25px !important;
    width: 25px !important;
    color: var(--privy-color-accent);
  }
`,g=r.div`
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  line-height: 1rem;
  text-align: left;
`,_=r.div`
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 20px;
`,v=r.div`
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: 1rem 0rem 0rem;
  flex-grow: 1;
  width: 100%;
`,y=r.div`
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
`,b=r.button`
  && {
    background-color: transparent;
    color: var(--privy-color-foreground-3);
    margin-left: auto;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    height: 100%;

    > svg {
      z-index: 2;
      height: 20px !important;
      width: 20px !important;
    }
  }

  &&:hover {
    color: var(--privy-color-error);
  }
`,x=r.div`
  display: flex;
  align-items: center;
  gap: 0.5rem;

  > svg {
    z-index: 2;
    height: 20px !important;
    width: 20px !important;
  }
`,S=r.div`
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400 !important;
  color: ${e=>e.$isAccent?`var(--privy-color-accent)`:`var(--privy-color-foreground-3)`};

  > svg {
    z-index: 2;
    height: 18px !important;
    width: 18px !important;
    display: flex !important;
    align-items: flex-end;
  }
`,C=r.div`
  width: 100%;
  display: flex;
  justify-content: space-between;
`,w=r.p`
  text-align: left;
  width: 100%;
  color: var(--privy-color-foreground-3) !important;
`,T=r.button`
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  user-select: none;

  & {
    width: 100%;
    cursor: pointer;
    border-radius: var(--privy-border-radius-md);

    font-size: 0.875rem;
    line-height: 1rem;
    font-style: normal;
    font-weight: 500;
    line-height: 22px; /* 137.5% */
    letter-spacing: -0.016px;
  }

  && {
    color: ${e=>e.theme===`dark`?`var(--privy-color-foreground-2)`:`var(--privy-color-accent)`};
    background-color: transparent;

    padding: 0.5rem 0px;
  }

  &:hover {
    text-decoration: underline;
  }
`,E=r.div`
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--privy-color-accent);
  width: 100%;

  > svg {
    z-index: 2;
    width: 3rem;
    height: 3rem;
  }
`,D=r.div`
  color: var(--privy-color-error);
`,O=({style:e,...t})=>(0,c.jsx)(`svg`,{x:0,y:0,width:`65`,height:`64`,viewBox:`0 0 65 64`,style:{height:`64px`,width:`65px`,...e},fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,c.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z`})}),k=[,,,,,,].fill(``),A,j=((A=j||{})[A.RESET_AFTER_DELAY=0]=`RESET_AFTER_DELAY`,A[A.CLEAR_ON_NEXT_VALID_INPUT=1]=`CLEAR_ON_NEXT_VALID_INPUT`,A);function M(e){return/^[0-9]{1}$/.test(e)}function N(e){return e.length===6&&e.every(M)}var P=({onChange:e,disabled:t,errorReasonOverride:n,success:r})=>{let[i,o]=(0,a.useState)(k),[s,u]=(0,a.useState)(null),[d,f]=(0,a.useState)(null),p=async t=>{t.preventDefault();let n=t.currentTarget.value.replace(/\s+/g,``);if(n===``)return;let r=i.reduce(((e,t)=>e+Number(M(t))),0),a=n.split(``),s=!a.every(M),c=a.length+r>6;if(s)return u(`Passcode can only be numbers`),void f(1);if(c)return u(`Passcode must be exactly 6 numbers`),void f(1);u(null),f(null);let l=Number(t.currentTarget.name?.charAt(4)),d=[...n||[``]].slice(0,6-l),p=[...i.slice(0,l),...d,...i.slice(l+d.length)];o(p);let m=Math.min(Math.max(l+d.length,0),5);if(document.querySelector(`input[name=pin-${m}]`)?.focus({preventScroll:!0}),N(p))try{await e(p.join(``)),document.querySelector(`input[name=pin-${m}]`)?.blur()}catch(e){f(1),u(e.message)}else try{await e(null)}catch(e){f(1),u(e.message)}},m=r?`success`:!n&&!s?``:`fail`;return(0,c.jsx)(c.Fragment,{children:(0,c.jsxs)(F,{children:[(0,c.jsx)(`div`,{children:i.map(((n,r)=>(0,c.jsx)(`input`,{name:`pin-${r}`,type:`text`,value:i[r],onChange:p,onKeyUp:t=>{t.key===`Backspace`&&(t=>{d===1&&(u(null),f(null));let n=[...i.slice(0,t),``,...i.slice(t+1)];o(n),t>0&&document.querySelector(`input[name=pin-${t-1}]`)?.focus({preventScroll:!0}),N(n)?e(n.join(``)):e(null)})(r)},inputMode:`numeric`,autoFocus:r===0,pattern:`[0-9]`,className:m,autoComplete:l.isMobile?`one-time-code`:`off`,disabled:t},r)))}),(0,c.jsx)(`div`,{children:(0,c.jsx)(I,{$fail:!!n||!!s,children:n||s})})]})})},F=r.div`
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;

  @media (max-width: 440px) {
    margin-top: 8px;
    margin-bottom: 8px;
  }

  > div:nth-child(1) {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    border-radius: var(--privy-border-radius-md);

    > input {
      border: 1px solid var(--privy-color-foreground-4);
      background: var(--privy-color-background);
      border-radius: var(--privy-border-radius-md);
      padding: 8px 10px;
      height: 58px;
      width: 46px;
      text-align: center;
      font-size: 18px;
    }

    > input:disabled {
      /* Use light-theme-bg-2 instead of disabled-bg for consistency with
      the callout bubble */
      background: var(--privy-color-background-2);
    }

    > input:focus {
      border: 1px solid var(--privy-color-accent);
    }

    > input:invalid {
      border: 1px solid var(--privy-color-error);
    }

    > input.success {
      border: 1px solid var(--privy-color-success);
    }

    > input.fail {
      border: 1px solid var(--privy-color-error);
      animation: shake 180ms;
      animation-iteration-count: 2;
    }
  }

  @keyframes shake {
    0% {
      transform: translate(1px, 0px);
    }
    33% {
      transform: translate(-1px, 0px);
    }
    67% {
      transform: translate(-1px, 0px);
    }
    100% {
      transform: translate(1px, 0px);
    }
  }
`,I=r.div`
  line-height: 20px;
  font-size: 13px;
  display: flex;
  justify-content: flex-start;
  width: 100%;

  color: ${e=>e.$fail?`var(--privy-color-error)`:`var(--privy-color-foreground-3)`};
`;export{b as _,T as a,C as b,x as c,d,_ as f,v as g,m as h,D as i,y as l,p as m,O as n,h as o,u as p,P as r,f as s,w as t,S as u,E as v,s as x,g as y};