mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 02:06:16 +00:00
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
import{r as e}from"./chunk-DECur_0Z.js";import{o as t}from"./auth-store-CeX2QaQI.js";import{t as n}from"./react-CO2uhaBc.js";import{$l as r,Bl as i,Cf as a,Gl as o,Hl as s,Jl as c,Kl as l,Ll as u,Ql as d,Rl as f,Ul as p,Vl as m,Wl as h,Xl as g,Yl as _,Zl as v,au as y,cu as b,du as ee,eu as x,fu as te,iu as ne,lu as S,nu as re,ou as ie,pu as ae,ql as oe,ru as se,su as ce,tu as le,uu as ue,zl as C}from"./messages-CA0k74Lg.js";import{t as de}from"./link-FSeyVZmM.js";import{i as w,r as fe,t as T}from"./button-CfqkRSM8.js";import{n as pe,r as me,t as he}from"./popover-G6mM7wba.js";import{t as ge}from"./createLucideIcon-Br0Bd5k2.js";import{t as _e}from"./check-DldThLle.js";import{t as ve}from"./chevron-down-BPPKEraq.js";import{n as E,t as D}from"./copy-to-clipboard--eZunBzP.js";import{t as O}from"./eye-off-CNvoUNxR.js";import{t as k}from"./eye-CnTTVkb2.js";import{n as A,t as j}from"./theme-switch-KnQlFw6B.js";import{t as M}from"./loader-circle-DRj7MiMc.js";import{a as N,i as P,o as F,r as ye,s as be,t as xe}from"./command-BS0F4xWI.js";import{t as Se}from"./shield-check-LJiSka38.js";import{t as Ce}from"./triangle-alert-D6KmQYVs.js";import{n as I}from"./dist-BJ92XTI_.js";import{c as L,n as R,s as we}from"./zod-CtXLSkFW.js";import{t as Te}from"./logo-3EWDGjCa.js";import{a as z,c as Ee,i as B,l as De,n as V,o as H,s as U,t as Oe}from"./form-C3PRruHl.js";import{t as W}from"./input-Dyq5zXZe.js";import{t as G}from"./badge-B9hxlwTp.js";import{a as ke,i as Ae,n as je,r as Me,t as Ne}from"./card-BfCogr2y.js";var Pe=ge(`lock-keyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),Fe=e(D(),1),K=e(n(),1),q=a(),Ie=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&`,J=14,Y=20,Le={slow:400,medium:200,fast:80},X=e=>e[Math.floor(Math.random()*e.length)],Z=()=>Ie[Math.floor(Math.random()*41)];function Re({glitchColors:e=[`#2b4539`,`#61dca3`,`#61b3dc`],glitchSpeed:t=`medium`,centerVignette:n=!1,outerVignette:r=!0,smooth:i=!0,className:a}){let o=(0,K.useRef)(null),s=(0,K.useRef)(0),c=(0,K.useRef)([]),l=(0,K.useRef)(0),u=(0,K.useRef)(0),d=(0,K.useCallback)((t,n)=>{c.current=Array.from({length:t*n},()=>({char:Z(),color:X(e),opacity:Math.random()*.5+.1}))},[e]),f=(0,K.useCallback)(()=>{let e=o.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;t.clearRect(0,0,e.width,e.height),t.font=`${J}px monospace`;let n=c.current,r=l.current,i=u.current;for(let e=0;e<i;e++)for(let i=0;i<r;i++){let a=n[e*r+i];a&&(t.globalAlpha=a.opacity,t.fillStyle=a.color,t.fillText(a.char,i*Y+4,e*Y+J))}t.globalAlpha=1},[]),p=(0,K.useCallback)(()=>{let t=c.current,n=t.length,r=Math.floor(n*.05);for(let a=0;a<r;a++){let r=Math.floor(Math.random()*n);t[r]&&(t[r].char=Z(),t[r].color=X(e),t[r].opacity=i?t[r].opacity:Math.random()*.5+.1)}f()},[e,i,f]);return(0,K.useEffect)(()=>{let e=o.current;if(!e)return;let n=()=>{let t=e.parentElement;t&&(e.width=t.clientWidth,e.height=t.clientHeight,l.current=Math.ceil(e.width/Y),u.current=Math.ceil(e.height/Y),d(l.current,u.current),f())},r=new ResizeObserver(n);e.parentElement&&r.observe(e.parentElement),n();let i=setInterval(p,Le[t]);return()=>{r.disconnect(),clearInterval(i),cancelAnimationFrame(s.current)}},[p,f,d,t]),(0,q.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden ${a??``}`,children:[(0,q.jsx)(`canvas`,{className:`absolute inset-0`,ref:o}),r&&(0,q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.85) 100%)`}}),n&&(0,q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`radial-gradient(ellipse at center, rgba(0,0,0,0.6) 0%, transparent 70%)`}})]})}var Q=fe(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function ze({className:e,variant:t,...n}){return(0,q.jsx)(`div`,{className:w(Q({variant:t}),e),"data-slot":`alert`,role:`alert`,...n})}function Be({className:e,...t}){return(0,q.jsx)(`div`,{className:w(`col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight`,e),"data-slot":`alert-title`,...t})}function Ve({className:e,...t}){return(0,q.jsx)(`div`,{className:w(`col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed`,e),"data-slot":`alert-description`,...t})}function He({value:e,onChange:t,options:n,placeholder:r=``,searchPlaceholder:i=`Search...`,emptyText:a=`No options found.`,className:o,disabled:s}){let[c,l]=(0,K.useState)(!1),u=n.map(e=>typeof e==`string`?{value:e,label:e}:e);return(0,q.jsxs)(he,{onOpenChange:l,open:c,children:[(0,q.jsxs)(`div`,{className:w(`relative`,o),children:[(0,q.jsx)(W,{className:`pr-10`,disabled:s,onChange:e=>t(e.target.value),placeholder:r,value:e}),(0,q.jsx)(me,{asChild:!0,children:(0,q.jsx)(T,{"aria-expanded":c,"aria-label":`Show options`,className:`absolute top-1/2 right-1 size-8 -translate-y-1/2`,disabled:s,size:`icon`,type:`button`,variant:`ghost`,children:(0,q.jsx)(ve,{className:`size-4`})})})]}),(0,q.jsx)(pe,{align:`end`,className:`w-48 p-0`,children:(0,q.jsxs)(xe,{children:[(0,q.jsx)(N,{placeholder:i}),(0,q.jsxs)(be,{children:[(0,q.jsx)(ye,{children:a}),(0,q.jsx)(P,{children:u.map(n=>(0,q.jsxs)(F,{onSelect:()=>{t(n.value),l(!1)},value:n.value,children:[(0,q.jsx)(_e,{className:w(`size-4`,e===n.value?`opacity-100`:`opacity-0`)}),n.label??n.value]},n.value))})]})]})})]})}var Ue=[`0.0.0.0`,`127.0.0.1`,`localhost`];function We({form:e,loading:t,onSubmit:n,submitText:r}){return(0,q.jsx)(Oe,{...e,children:(0,q.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e.handleSubmit(n),children:[(0,q.jsx)(B,{control:e.control,name:`app_name`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:ee()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`epusdt`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`app_uri`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsxs)(H,{children:[ue(),` *`]}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`http://your-server-ip:8000`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsx)(B,{control:e.control,name:`http_bind_addr`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:S()}),(0,q.jsx)(V,{children:(0,q.jsx)(He,{onChange:e.onChange,options:Ue,placeholder:`0.0.0.0`,value:e.value??``})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`http_bind_port`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:b()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`8000`,type:`number`,...e,value:e.value??``})}),(0,q.jsx)(U,{})]})})]}),(0,q.jsx)(B,{control:e.control,name:`runtime_root_path`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:ce()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`./runtime`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`log_save_path`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:ie()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`./logs`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsx)(B,{control:e.control,name:`order_expiration_time`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:y()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`10`,type:`number`,...e})}),(0,q.jsx)(U,{})]})}),(0,q.jsx)(B,{control:e.control,name:`order_notice_max_retry`,render:({field:e})=>(0,q.jsxs)(z,{children:[(0,q.jsx)(H,{children:ne()}),(0,q.jsx)(V,{children:(0,q.jsx)(W,{placeholder:`1`,type:`number`,...e})}),(0,q.jsx)(U,{})]})})]}),(0,q.jsxs)(T,{className:`mt-2 w-full`,disabled:t,type:`submit`,children:[t?(0,q.jsx)(M,{className:`animate-spin`}):null,r]})]})})}function Ge({credentials:e,onCopy:t,onTogglePassword:n,passwordLookupFailed:r,showPassword:a}){return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`grid gap-4 rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-4 shadow-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-emerald-500/12 text-emerald-600 dark:text-emerald-400`,children:(0,q.jsx)(Se,{className:`size-5`})}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`font-semibold text-base text-foreground`,children:v()}),e?(0,q.jsx)(G,{className:`rounded-md`,variant:`secondary`,children:_()}):null]}),(0,q.jsx)(`p`,{className:`text-muted-foreground text-sm leading-6`,children:g()})]})]}),e?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/85 p-4 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(`p`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:o()}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`min-w-0 flex-1 truncate font-medium text-base text-foreground`,children:e.username}),(0,q.jsxs)(T,{"aria-label":C(),className:`scale-95 rounded-full`,onClick:()=>t(e.username),size:`icon`,type:`button`,variant:`ghost`,children:[(0,q.jsx)(E,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:C()})]})]})]})}),(0,q.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/85 p-4 shadow-sm`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsx)(G,{className:`w-fit rounded-md border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-300`,variant:`outline`,children:p()}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`text-muted-foreground text-xs uppercase tracking-wide`,children:h()}),(0,q.jsxs)(G,{className:`rounded-md`,variant:`outline`,children:[(0,q.jsx)(Pe,{className:`size-3.5`}),i()]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`p`,{className:`min-w-0 flex-1 break-all font-medium text-base text-foreground`,children:a?e.password:`•`.repeat(Math.max(e.password.length,10))}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsxs)(T,{"aria-label":a?m():s(),className:`scale-95 rounded-full`,onClick:n,size:`icon`,type:`button`,variant:`ghost`,children:[a?(0,q.jsx)(O,{}):(0,q.jsx)(k,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:a?m():s()})]}),(0,q.jsxs)(T,{"aria-label":C(),className:`scale-95 rounded-full`,onClick:()=>t(e.password),size:`icon`,type:`button`,variant:`ghost`,children:[(0,q.jsx)(E,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:C()})]})]})]})]})})]}):null,r?(0,q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100`,children:[(0,q.jsx)(Ce,{className:`mt-0.5 size-4 shrink-0`}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`font-medium text-sm`,children:c()}),(0,q.jsx)(`p`,{className:`text-amber-800/80 text-sm leading-6 dark:text-amber-100/75`,children:oe()})]})]}):null]}),(0,q.jsx)(T,{asChild:!0,className:`w-full`,type:`button`,children:(0,q.jsx)(de,{to:`/sign-in`,children:l()})})]})}var Ke=we({app_name:L().min(1,`App Name is required`),app_uri:L().min(1,`App URI is required`).url(`Must be a valid URL (e.g. http://your-server-ip:8000)`),http_bind_addr:L().min(1,`Bind address is required`),http_bind_port:R({error:`Port must be a number`}).int().min(1,`Port must be ≥ 1`).max(65535,`Port must be ≤ 65535`),runtime_root_path:L().min(1,`Runtime root path is required`),log_save_path:L().min(1,`Log save path is required`),order_expiration_time:R({error:`Must be a number`}).int().min(1,`Must be ≥ 1 minute`),order_notice_max_retry:R({error:`Must be a number`}).int().min(0,`Must be ≥ 0`)}),$={app_name:`epusdt`,app_uri:``,http_bind_addr:`0.0.0.0`,http_bind_port:8e3,runtime_root_path:`./runtime`,log_save_path:`./logs`,order_expiration_time:10,order_notice_max_retry:1};function qe(){let[e,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(!1),_=De({resolver:Ee(Ke),defaultValues:$,mode:`onChange`});(0,K.useEffect)(()=>{let e=!0;async function n(){try{let{data:n}=await t.GET(`/api/install/defaults`);if(!(e&&n))return;let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==``&&e!=null));_.reset({...$,...r})}catch{}}return n().catch(()=>void 0),()=>{e=!1}},[_]);function v(e){if(!(0,Fe.default)(e)){I.error(u());return}I.success(f())}async function y(e){n(!0),s(null),m(!1);try{let{error:n,response:r}=await t.POST(`/api/install`,{body:e});if(!r.ok||n){s({variant:`destructive`,message:n?.error||x()});return}let i=null;try{let{data:e,error:n,response:r}=await t.GET(`/admin/api/v1/auth/init-password`),a=e?.data?.password?.trim()||``;if(!(r.ok&&!n&&a))throw Error(`Failed to load initial password`);i={username:e?.data?.username?.trim()||`admin`,password:a}}catch{i=null,m(!0)}a(!0),l(i)}catch{s({variant:`destructive`,message:x()})}finally{n(!1)}}let b=se();return e&&(b=re()),i&&(b=le()),(0,q.jsxs)(`div`,{className:`relative flex min-h-svh items-center justify-center px-4 py-10`,children:[(0,q.jsx)(Re,{centerVignette:!1,glitchColors:[`#3f3f46`,`#71717a`,`#a1a1aa`],glitchSpeed:`fast`,outerVignette:!1,smooth:!0}),(0,q.jsxs)(Ne,{className:`max-w-2xl border border-border/40 bg-card/55 shadow-xl backdrop-blur-xl`,children:[(0,q.jsxs)(Ae,{className:`space-y-6 border-border/40 border-b pb-8`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(Te,{className:`size-10 shrink-0`}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`font-medium text-xl leading-tight`,children:`GMPay`}),(0,q.jsx)(`p`,{className:`mt-1 whitespace-nowrap text-muted-foreground text-xs`,children:d()})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(A,{}),(0,q.jsx)(j,{})]})]}),i?null:(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(ke,{className:`text-2xl tracking-tight`,children:ae()}),(0,q.jsx)(Me,{className:`max-w-xl text-sm leading-6`,children:te()})]})]}),(0,q.jsx)(je,{children:(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[o?(0,q.jsxs)(ze,{variant:o.variant,children:[(0,q.jsx)(Be,{children:r()}),(0,q.jsx)(Ve,{children:o.message})]}):null,i?(0,q.jsx)(Ge,{credentials:c,onCopy:v,onTogglePassword:()=>g(e=>!e),passwordLookupFailed:p,showPassword:h}):(0,q.jsx)(We,{form:_,loading:e,onSubmit:y,submitText:b})]})})]})]})}var Je=qe;export{Je as component}; |