@fudrouter/fsrouter 0.6.118 → 0.6.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/assets/EndpointPageClient.Di2YqgPf.js +6 -0
- package/public/assets/Loading.D9qCFX3R.js +1 -0
- package/public/assets/NoAuthProxyCard.DMCykSRG.js +89 -0
- package/public/assets/index.C5VWu_q7.js +89 -0
- package/public/assets/page.BFEjgGXd.js +2 -0
- package/public/assets/page.BIksOupz.js +1 -0
- package/public/assets/page.BN35ziqx.js +6 -0
- package/public/assets/page.BY-Z5lJc.js +1 -0
- package/public/assets/page.BYuvYI81.js +1 -0
- package/public/assets/page.BZn6EjgR.js +1 -0
- package/public/assets/page.BqDkuLBL.js +1 -0
- package/public/assets/page.Brx8iIwy.js +31 -0
- package/public/assets/page.ByoxqtTd.js +1 -0
- package/public/assets/page.C-2PY_Ek.js +6 -0
- package/public/assets/page.CBJ3PIz6.js +1 -0
- package/public/assets/page.CC2igP7g.js +5 -0
- package/public/assets/page.CJV7n_Cb.js +1 -0
- package/public/assets/page.CadeLR3B.js +2 -0
- package/public/assets/page.Cn9VXlxl.js +1 -0
- package/public/assets/page.Cnk5NKtT.js +1 -0
- package/public/assets/page.Ctr5GGfe.js +23 -0
- package/public/assets/page.CvY1-VAN.js +5 -0
- package/public/assets/page.DD2_vWM3.js +1 -0
- package/public/assets/page.DFOtpzzq.js +7 -0
- package/public/assets/page.DGqaAFu_.js +1 -0
- package/public/assets/page.DSCWOtet.js +1 -0
- package/public/assets/page.DUXPs518.js +1 -0
- package/public/assets/page.DV-sp6Ji.js +1 -0
- package/public/assets/page.DarYN1Wo.js +1 -0
- package/public/assets/page.DsnVF9ld.js +1 -0
- package/public/assets/page.DuJrvy6q.js +1 -0
- package/public/assets/page.DvVWtaJ8.js +1 -0
- package/public/assets/page.Dvoll2rR.js +64 -0
- package/public/assets/page.K41VgPhA.js +1 -0
- package/public/assets/page.LA8kHbDi.js +4 -0
- package/public/assets/page.UGWWqB47.js +1 -0
- package/public/assets/page.eObJ7Eqq.js +1 -0
- package/public/assets/page.hGYtnZEk.js +1 -0
- package/public/assets/page.hr04hSjp.js +1 -0
- package/public/assets/page.imKuq2A5.js +1 -0
- package/public/assets/page.zF9qqJjX.js +1 -0
- package/public/index.html +4 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as t}from"./index.C5VWu_q7.js";import{b as a}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function g(){const[s,u]=a.useState(""),[n,i]=a.useState(""),[r,l]=a.useState(null),[o,c]=a.useState(!1),d=async()=>{c(!0);try{const e=await fetch("/api/rerank",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,documents:n.split(`
|
|
2
|
+
`).filter(Boolean)})});l(await e.json())}catch(e){l({error:e.message})}c(!1)};return t.jsxs("div",{className:"space-y-6 p-6",children:[t.jsx("h1",{className:"text-2xl font-bold",children:"Rerank"}),t.jsx("p",{className:"text-text-muted",children:"Rerank documents by relevance using Cohere-compatible API"}),t.jsx("input",{className:"w-full p-3 rounded-lg border",placeholder:"Query",value:s,onChange:e=>u(e.target.value)}),t.jsx("textarea",{className:"w-full p-3 rounded-lg border h-40",placeholder:"Documents (one per line)",value:n,onChange:e=>i(e.target.value)}),t.jsx("button",{onClick:d,disabled:o,className:"px-4 py-2 bg-primary text-white rounded-lg",children:o?"Reranking...":"Rerank"}),r&&t.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto",children:JSON.stringify(r,null,2)})]})}export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./index.C5VWu_q7.js";import{b as o}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[i,n]=o.useState({}),l=t=>{navigator.clipboard.writeText(t),n(r=>({...r,[t]:!0})),setTimeout(()=>{n(r=>({...r,[t]:!1}))},1500)},a=({value:t,text:r="Copy",className:d=""})=>{const s=i[t];return e.jsxs("button",{type:"button",onClick:()=>l(t),className:`text-xs px-3 py-1 rounded cursor-pointer transition-all duration-150 flex items-center gap-1 border font-semibold shrink-0 ${s?"text-green-400 bg-green-500/10 border-green-500/20":"text-white/50 hover:text-white bg-white/5 hover:bg-white/10 border-transparent"} ${d}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:s?"check":"content_copy"}),s?"Copied":r]})};return e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4 text-white space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[28px]",children:"auto_stories"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Panduan Lengkap Deploy Temp Mail"}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Panduan integrasi Cloudflare Worker & D1 Database untuk fsrouter"})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("a",{href:"/dashboard/automation",className:"px-3.5 py-1.5 rounded-lg bg-white/5 border border-white/10 text-xs font-semibold hover:bg-white/10 transition-colors cursor-pointer",children:"Kembali ke Dashboard"})})]}),e.jsxs("div",{className:"space-y-6 text-sm leading-relaxed text-white/80",children:[e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-xl p-4 text-xs text-primary/95 flex items-start gap-3",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"lightbulb"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Info Penting:"})," Panduan ini ditujukan jika Anda ingin melakukan deployment secara manual ke Cloudflare menggunakan CLI. Jika Anda ingin setup otomatis, silakan kembali ke Dashboard dan gunakan form ",e.jsx("strong",{children:"⚡ Auto Deploy (Cloudflare)"})," untuk setup 1-klik."]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"1"}),"Prasyarat & Login Cloudflare"]}),e.jsx("p",{children:"Pastikan Node.js telah terinstal di komputer Anda. Buka terminal lalu autentikasikan akun Cloudflare Anda menggunakan Wrangler CLI:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler login"}),e.jsx(a,{value:"npx wrangler login"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"2"}),"Masuk Folder & Install Dependencies"]}),e.jsx("p",{children:"Buka terminal pada direktori worker lokal Anda (`tempmail`) lalu install package dependencies:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"cd /home/data/Project/fsrouter/tempmail && npm install"}),e.jsx(a,{value:"cd /home/data/Project/fsrouter/tempmail && npm install"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"3"}),"Buat Database Cloudflare D1"]}),e.jsxs("p",{children:["Buat database baru bernama ",e.jsx("code",{children:"tempmail"})," pada Cloudflare D1 untuk menyimpan data kotak surat dan isi pesan:"]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 create tempmail"}),e.jsx(a,{value:"npx wrangler d1 create tempmail"})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:["Perintah di atas akan menghasilkan **database_id** (UUID). Salin ID tersebut, kemudian buka berkas ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"})," di folder proyek tempmail Anda, ganti nilai ",e.jsx("code",{children:"database_id"})," di baris terbawah dengan ID baru Anda."]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"4"}),"Jalankan Migrasi Database D1"]}),e.jsx("p",{children:"Buat struktur tabel database yang diperlukan dengan menerapkan migrasi database baik secara lokal maupun langsung di Cloudflare:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 migrations apply tempmail --remote"}),e.jsx(a,{value:"npx wrangler d1 migrations apply tempmail --remote"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"5"}),"Buat API Access Key untuk fsrouter"]}),e.jsx("p",{children:"fsrouter berkomunikasi dengan Worker menggunakan API Key yang aman. Jalankan perintah SQL berikut untuk mendaftarkan fsrouter admin ke database D1 Anda:"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all overflow-hidden text-ellipsis",children:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`}),e.jsx(a,{value:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"info"}),e.jsxs("span",{children:["Ganti ",e.jsx("code",{children:"tm_YOUR_SECURE_API_KEY"})," dengan API Key acak pilihan Anda (misalnya menggunakan format ",e.jsx("code",{children:"tm_"})," diikuti oleh karakter hex acak). Salin API Key ini ke pengaturan fsrouter Anda."]})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"6"}),"Atur Secret Tokens (Telegram & Webhook)"]}),e.jsx("p",{children:"Simpan token bot Telegram dan webhook secret ke dalam Cloudflare secret variables secara aman:"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_BOT_TOKEN"}),e.jsx(a,{value:"npx wrangler secret put TELEGRAM_BOT_TOKEN"})]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"}),e.jsx(a,{value:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"7"}),"Deploy ke Cloudflare Workers"]}),e.jsxs("p",{children:["Buka file ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"}),", sesuaikan parameter ",e.jsx("code",{children:"vars"})," (domain, base URL) agar sesuai dengan domain milik Anda. Setelah itu, deploy ke Cloudflare:"]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler deploy"}),e.jsx(a,{value:"npx wrangler deploy"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"8"}),"Daftarkan Webhook Telegram Bot (Opsional)"]}),e.jsx("p",{children:"Daftarkan URL domain worker Anda ke API Telegram agar bot Anda dapat menerima chat command secara instan:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 gap-4",children:[e.jsx("span",{className:"break-all",children:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`}),e.jsx(a,{value:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"9"}),"Konfigurasi Cloudflare Email Routing & DNS (Paling Penting!)"]}),e.jsx("p",{children:"Ini adalah langkah krusial agar email dapat diterima dan diproses oleh Worker yang telah dideploy. Masuk ke panel Cloudflare Anda, lalu ikuti panduan berikut:"}),e.jsxs("div",{className:"space-y-4 border-l-2 border-primary/30 pl-4 mt-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian A: Sinkronkan dan Kunci Rekaman DNS"]}),e.jsxs("p",{className:"text-xs text-white/70 mt-1",children:["Jika status DNS Anda tertulis ",e.jsx("code",{className:"bg-white/10 text-white px-1 rounded",children:"Not configured"})," atau ada rekaman dengan status ",e.jsx("code",{className:"bg-amber-500/10 text-amber-300 px-1 rounded border border-amber-500/20",children:"Unlocked"})," (misalnya TXT SPF):"]}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsxs("li",{children:["Buka menu ",e.jsx("strong",{children:"Email Routing"})," di panel domain Cloudflare Anda."]}),e.jsx("li",{children:"Pilih tab **`Settings`** di sebelah atas."}),e.jsx("li",{children:"Di sebelah kanan judul **`DNS records`**, klik tombol **`Lock`** (ikon gembok). Cloudflare akan otomatis mengunci dan menerapkan semua MX dan TXT records yang dibutuhkan untuk rute email."})]})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian B: Buat Aturan Rute Catch-All"]}),e.jsx("p",{className:"text-xs text-white/70 mt-1",children:"Agar semua email masuk diteruskan ke database Worker Anda:"}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsx("li",{children:"Klik tab **`Routing rules`** (tab ketiga dari kiri)."}),e.jsx("li",{children:"Scroll ke bawah ke bagian **Catch-all address**."}),e.jsx("li",{children:"Klik **Edit** / **Configure**."}),e.jsx("li",{children:"Pada kolom **Action** (Aksi), pilih opsi **`Send to a Worker`** (Kirim ke Worker)."}),e.jsx("li",{children:"Pada kolom **Destination** (Worker tujuan), pilih nama Worker yang baru saja dideploy (contohnya: **`tempmail-pixelnest`**)."}),e.jsx("li",{children:"Klik **Save** untuk menyimpan aturan perutean."})]})]})]})]})]})]})}export{u as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{j as e}from"./index.C5VWu_q7.js";import{b as l}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function b({value:r,label:d="Copy"}){const[t,i]=l.useState(!1),a=async()=>{if(r)try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),1500)}catch{const n=document.createElement("textarea");n.value=r,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),i(!0),setTimeout(()=>i(!1),1500)}};return e.jsx("button",{onClick:a,disabled:!r,title:r?r.slice(0,60)+(r.length>60?"…":""):"Tidak tersedia",style:{padding:"2px 10px",fontSize:11,borderRadius:4,border:"1px solid",cursor:r?"pointer":"not-allowed",borderColor:t?"#22c55e":r?"#6366f1":"#374151",background:t?"#166534":r?"#1e1b4b":"#111827",color:t?"#86efac":r?"#a5b4fc":"#4b5563",transition:"all 0.15s",whiteSpace:"nowrap",minWidth:60},children:t?"✓ Copied!":d})}function y({value:r,maxLen:d=22}){const[t,i]=l.useState(!1);if(!r)return e.jsx("span",{style:{color:"#6b7280",fontSize:12},children:"—"});const a=t?r:r.slice(0,d)+"…";return e.jsxs("span",{style:{fontFamily:"monospace",fontSize:11,color:"#d1d5db"},children:[a,e.jsx("button",{onClick:()=>i(n=>!n),style:{marginLeft:4,fontSize:10,color:"#6366f1",background:"none",border:"none",cursor:"pointer"},children:t?"hide":"show"})]})}function w(r){const d=r.map(s=>({email:s.email,firebase_refresh_token:s.firebaseRefreshToken,firebase_api_key:s.firebaseApiKey,jwt:s.jwt,jwt_expires_at:s.jwtExpiresAt,balance:s.balance})),t=JSON.stringify(d,null,2),i=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-tokens-${Date.now()}.json`,n.click(),URL.revokeObjectURL(a)}function S(r){const t=`email,firebase_refresh_token,firebase_api_key
|
|
2
|
+
`+r.filter(s=>s.firebaseRefreshToken&&s.firebaseApiKey).map(s=>`${s.email},${s.firebaseRefreshToken},${s.firebaseApiKey}`).join(`
|
|
3
|
+
`),i=new Blob([t],{type:"text/csv"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-refresh-tokens-${Date.now()}.csv`,n.click(),URL.revokeObjectURL(a)}function C(){const[r,d]=l.useState([]),[t,i]=l.useState(null),[a,n]=l.useState(!0),[s,g]=l.useState(""),[x,m]=l.useState(""),[p,j]=l.useState("all"),h=l.useCallback(async()=>{n(!0),g("");try{const c=await(await fetch("/api/providers/weavy/pool")).json();if(!c.ok)throw new Error(c.error||"Failed");d(c.pool||[]),i(c.stats||null)}catch(o){g(o.message)}finally{n(!1)}},[]);l.useEffect(()=>{h()},[h]);const u=r.filter(o=>{const c=!x||o.email.toLowerCase().includes(x.toLowerCase()),k=p==="all"?!0:p==="hasToken"?!!o.firebaseRefreshToken:p==="noToken"?!o.firebaseRefreshToken:p==="validJwt"?o.jwtValid:!0;return c&&k}),v={background:"#111827",border:"1px solid #1f2937",borderRadius:8,padding:"10px 14px",marginBottom:8},f=(o,c,k="#6366f1")=>e.jsxs("div",{style:{background:"#0f172a",borderRadius:8,padding:"12px 20px",border:"1px solid #1f2937",textAlign:"center",minWidth:100},children:[e.jsx("div",{style:{fontSize:28,fontWeight:700,color:k},children:c}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:2},children:o})]});return e.jsxs("div",{style:{minHeight:"100vh",background:"#030712",color:"#e5e7eb",padding:"24px 32px",fontFamily:"Inter, sans-serif"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,color:"#f9fafb"},children:"🪄 Weavy Token Pool"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#6b7280"},children:"Copy firebase_refresh_token + firebase_api_key ke kliperspro atau sistem lain"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:h,style:{padding:"6px 14px",borderRadius:6,background:"#1f2937",border:"1px solid #374151",color:"#d1d5db",cursor:"pointer",fontSize:13},children:"↻ Refresh"}),e.jsx("button",{onClick:()=>S(r),style:{padding:"6px 14px",borderRadius:6,background:"#1e1b4b",border:"1px solid #4338ca",color:"#a5b4fc",cursor:"pointer",fontSize:13},children:"⬇ Export CSV"}),e.jsx("button",{onClick:()=>w(r),style:{padding:"6px 14px",borderRadius:6,background:"#14532d",border:"1px solid #166534",color:"#86efac",cursor:"pointer",fontSize:13},children:"⬇ Export JSON"})]})]}),t&&e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:24,flexWrap:"wrap"},children:[f("Total Akun",t.total,"#e5e7eb"),f("Aktif",t.active,"#22c55e"),f("JWT Valid",t.jwtValid,"#6366f1"),f("Punya Refresh Token",t.hasRefreshToken,"#f59e0b")]}),t&&t.hasRefreshToken===0&&e.jsxs("div",{style:{background:"#431407",border:"1px solid #7c2d12",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:13,color:"#fed7aa"},children:["⚠️ ",e.jsx("strong",{children:"firebase_refresh_token masih kosong"})," untuk semua akun. Jalankan ulang signup untuk akun-akun ini agar refresh token tertangkap dari IndexedDB."]}),e.jsxs("div",{style:{background:"#0c1a2e",border:"1px solid #1e3a5f",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:12},children:[e.jsx("strong",{style:{color:"#60a5fa"},children:"📋 Cara pakai di kliperspro (production):"}),e.jsx("pre",{style:{margin:"8px 0 0",color:"#93c5fd",fontSize:11,overflow:"auto"},children:`POST https://securetoken.googleapis.com/v1/token?key=<firebase_api_key>
|
|
4
|
+
Body: grant_type=refresh_token&refresh_token=<firebase_refresh_token>
|
|
5
|
+
→ Response: { id_token: "<JWT baru>", refresh_token: "<update ini>" }
|
|
6
|
+
→ Gunakan id_token sebagai: Authorization: Bearer <JWT>`})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[e.jsx("input",{value:x,onChange:o=>m(o.target.value),placeholder:"Cari email…",style:{flex:1,minWidth:200,background:"#111827",border:"1px solid #374151",borderRadius:6,padding:"6px 12px",color:"#e5e7eb",fontSize:13}}),["all","hasToken","noToken","validJwt"].map(o=>e.jsx("button",{onClick:()=>j(o),style:{padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer",border:"1px solid",borderColor:p===o?"#6366f1":"#374151",background:p===o?"#1e1b4b":"#111827",color:p===o?"#a5b4fc":"#9ca3af"},children:{all:"Semua",hasToken:"✅ Punya Token",noToken:"❌ Tanpa Token",validJwt:"🔑 JWT Valid"}[o]},o))]}),a?e.jsx("div",{style:{textAlign:"center",color:"#6b7280",padding:40},children:"Memuat…"}):s?e.jsxs("div",{style:{color:"#f87171",padding:20},children:["Error: ",s]}):e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#6b7280",fontSize:12,marginBottom:8},children:["Menampilkan ",u.length," dari ",r.length," akun"]}),u.map(o=>e.jsxs("div",{style:{...v,opacity:o.isActive?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:13,minWidth:220,color:o.isActive?"#f9fafb":"#6b7280"},children:o.email}),e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,fontWeight:600,background:o.jwtValid?"#14532d":"#7f1d1d",color:o.jwtValid?"#86efac":"#fca5a5"},children:o.jwtValid?`JWT valid ${Math.ceil(o.jwtSecondsLeft/60)}m`:"JWT expired"}),e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,fontWeight:600,background:o.firebaseRefreshToken?"#1c1917":"#1f2937",color:o.firebaseRefreshToken?"#fbbf24":"#4b5563"},children:o.firebaseRefreshToken?"🔑 refresh_token ✓":"❌ no refresh_token"}),e.jsxs("span",{style:{fontSize:11,color:"#6b7280"},children:["💰 ",o.balance," credits"]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(b,{value:o.firebaseRefreshToken,label:"Copy refresh_token"}),e.jsx(b,{value:o.firebaseApiKey,label:"Copy api_key"}),e.jsx(b,{value:o.jwt,label:"Copy JWT"}),e.jsx(b,{value:o.firebaseRefreshToken&&o.firebaseApiKey?JSON.stringify({email:o.email,firebase_refresh_token:o.firebaseRefreshToken,firebase_api_key:o.firebaseApiKey},null,2):"",label:"Copy All"})]})]}),e.jsxs("div",{style:{marginTop:6,display:"flex",gap:16,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"refresh_token: "}),e.jsx(y,{value:o.firebaseRefreshToken})]}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"api_key: "}),e.jsx(y,{value:o.firebaseApiKey,maxLen:16})]}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"JWT: "}),e.jsx(y,{value:o.jwt})]})]})]},o.id)),u.length===0&&e.jsx("div",{style:{textAlign:"center",color:"#6b7280",padding:40},children:"Tidak ada akun ditemukan"})]})]})}export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,L as Qe,D as Xe,E as ye,G as je,H as Ze,n as he,B as v,I as ge,C as es}from"./index.C5VWu_q7.js";import{b as o,c as ss,d as ts}from"./router.Cjj1--8t.js";import{C as T,T as C,I as m}from"./NoAuthProxyCard.DMCykSRG.js";import"./zustand.akaTi5uX.js";function as(){if(typeof document>"u")return"en";const g=document.cookie.split(";").find(S=>S.trim().startsWith(`${ye}=`)),k=g?decodeURIComponent(g.split("=")[1]):"en";return je(k)}const oe=g=>({en:{name:"English",flag:"🇺🇸"},vi:{name:"Tiếng Việt",flag:"🇻🇳"},"zh-CN":{name:"简体中文",flag:"🇨🇳"},"zh-TW":{name:"繁體中文",flag:"🇹🇼"},ja:{name:"日本語",flag:"🇯🇵"},"pt-BR":{name:"Português (Brasil)",flag:"🇧🇷"},"pt-PT":{name:"Português (Portugal)",flag:"🇵🇹"},ko:{name:"한국어",flag:"🇰🇷"},es:{name:"Español",flag:"🇪🇸"},de:{name:"Deutsch",flag:"🇩🇪"},fr:{name:"Français",flag:"🇫🇷"},he:{name:"עברית",flag:"🇮🇱"},ar:{name:"العربية",flag:"🇸🇦"},ru:{name:"Русский",flag:"🇷🇺"},pl:{name:"Polski",flag:"🇵🇱"},cs:{name:"Čeština",flag:"🇨🇿"},nl:{name:"Nederlands",flag:"🇳🇱"},tr:{name:"Türkçe",flag:"🇹🇷"},uk:{name:"Українська",flag:"🇺🇦"},tl:{name:"Tagalog",flag:"🇵🇭"},id:{name:"Indonesia",flag:"🇮🇩"},th:{name:"ไทย",flag:"🇹🇭"},hi:{name:"हिन्दी",flag:"🇮🇳"},bn:{name:"বাংলা",flag:"🇧🇩"},ur:{name:"اردو",flag:"🇵🇰"},ro:{name:"Română",flag:"🇷🇴"},sv:{name:"Svenska",flag:"🇸🇪"},it:{name:"Italiano",flag:"🇮🇹"},el:{name:"Ελληνικά",flag:"🇬🇷"},hu:{name:"Magyar",flag:"🇭🇺"},fi:{name:"Suomi",flag:"🇫🇮"},da:{name:"Dansk",flag:"🇩🇰"},no:{name:"Norsk",flag:"🇳🇴"}})[g]||{name:g,flag:"🌐"};function os({className:g="",isOpen:k,onClose:S,hideTrigger:re=!1}){const[P,U]=o.useState("en"),[R,H]=o.useState(!1),[E,V]=o.useState(!1),F=o.useRef(null),r=typeof k=="boolean",x=r?k:E,i=c=>{r?!c&&S&&S(P):V(c)};o.useEffect(()=>{U(as())},[]),o.useEffect(()=>{function c(N){F.current&&!F.current.contains(N.target)&&i(!1)}if(x)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[x]);const B=async c=>{if(!(c===P||R)){H(!0),i(!1);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:c})}),await Xe(),U(c)}catch(N){console.error("Failed to set locale:",N)}finally{H(!1)}}};return e.jsxs("div",{className:g,children:[!re&&e.jsxs("button",{onClick:()=>i(!x),disabled:R,className:"flex items-center gap-2 px-3 py-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/60 transition-colors",title:"Language","data-i18n-skip":"true",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"language"}),e.jsx("span",{className:"text-sm font-medium",children:oe(P).name}),e.jsx("span",{className:"text-lg",children:oe(P).flag})]}),x&&ss.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4","data-i18n-skip":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>i(!1)}),e.jsxs("div",{ref:F,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-2xl flex flex-col max-h-[80vh]",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-main",children:"Select Language"}),e.jsx("button",{onClick:()=>i(!1),className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:Qe.map(c=>{const N=P===c,O=oe(c);return e.jsxs("button",{onClick:()=>B(c),disabled:R,className:`flex flex-col items-center justify-start gap-1 px-2 py-3 rounded-lg text-xs font-medium transition-colors w-full ${N?"bg-primary/15 text-primary ring-2 ring-primary":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"} ${R?"opacity-70 cursor-wait":""}`,title:O.name,children:[e.jsx("span",{className:"text-2xl",children:O.flag}),e.jsx("span",{className:"text-center leading-tight line-clamp-2 h-8 flex items-center",children:O.name}),N&&e.jsx("span",{className:"material-symbols-outlined text-sm",children:"check"})]},c)})})})]})]}),document.body)]})}function rs(){if(typeof document>"u")return"en";const g=document.cookie.split(";").find(S=>S.trim().startsWith(`${ye}=`)),k=g?decodeURIComponent(g.split("=")[1]):"en";return je(k)}function ds(){const g=ts(),{theme:k,setTheme:S}=Ze(),[re,P]=o.useState("en"),[U,R]=o.useState(!1),[H,E]=o.useState(!1),[V,F]=o.useState(!1),[r,x]=o.useState({fallbackStrategy:"fill-first"}),[i,B]=o.useState(!0),[c,N]=o.useState({current:"",new:"",confirm:""}),[O,M]=o.useState({type:"",message:""}),[we,ie]=o.useState(!1),[le,W]=o.useState(!1),[Y,D]=o.useState({type:"",message:""}),[p,Q]=o.useState({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[X,Z]=o.useState(""),[ee,A]=o.useState({type:"",message:""}),[L,ne]=o.useState(!1),[ve,ce]=o.useState(!1),[se,I]=o.useState({type:"",message:""}),[Ne,_e]=o.useState("/api/auth/oidc/callback"),[de,me]=o.useState(!1),K=o.useRef(null),[J,z]=o.useState({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[te,y]=o.useState({type:"",message:""}),[$,G]=o.useState(!1),[ke,xe]=o.useState(!1),[l,j]=o.useState({codebuddy_auto_fsrouter:!1,codebuddy_leave_canva_team:!1,codebuddy_browser_headless:!0,codebuddy_proxy_enabled:!1,codebuddy_proxy_server:"",codebuddy_proxy_username:"",codebuddy_proxy_password:"",fsmail_base_url:"",fsmail_api_key:"",fsmail_default_domain:"",fsmail_webhook_secret:""}),[ae,f]=o.useState({type:"",message:""}),[w,ue]=o.useState(!1),[Ce,pe]=o.useState(!1),[Se,be]=o.useState(!1),[fe,Pe]=o.useState(!1);o.useEffect(()=>{P(rs())},[U]),o.useEffect(()=>{fetch("/api/settings").then(s=>s.json()).then(s=>{x(s),Q({authMode:(s==null?void 0:s.authMode)||"password",oidcIssuerUrl:(s==null?void 0:s.oidcIssuerUrl)||"",oidcClientId:(s==null?void 0:s.oidcClientId)||"",oidcScopes:(s==null?void 0:s.oidcScopes)||"openid profile email",oidcLoginLabel:(s==null?void 0:s.oidcLoginLabel)||"Sign in with OIDC"}),Z(""),((s==null?void 0:s.authMode)==="oidc"||(s==null?void 0:s.authMode)==="both")&&me(!0),z({outboundProxyEnabled:(s==null?void 0:s.outboundProxyEnabled)===!0,outboundProxyUrl:(s==null?void 0:s.outboundProxyUrl)||"",outboundNoProxy:(s==null?void 0:s.outboundNoProxy)||""}),j({codebuddy_auto_fsrouter:(s==null?void 0:s.codebuddy_auto_fsrouter)==="1",codebuddy_leave_canva_team:(s==null?void 0:s.codebuddy_leave_canva_team)==="1",codebuddy_browser_headless:(s==null?void 0:s.codebuddy_browser_headless)!=="0",codebuddy_proxy_enabled:(s==null?void 0:s.codebuddy_proxy_enabled)==="1",codebuddy_proxy_server:(s==null?void 0:s.codebuddy_proxy_server)||"",codebuddy_proxy_username:(s==null?void 0:s.codebuddy_proxy_username)||"",codebuddy_proxy_password:(s==null?void 0:s.codebuddy_proxy_password)||"",fsmail_base_url:(s==null?void 0:s.fsmail_base_url)||"",fsmail_api_key:(s==null?void 0:s.fsmail_api_key)||"",fsmail_default_domain:(s==null?void 0:s.fsmail_default_domain)||"",fsmail_webhook_secret:(s==null?void 0:s.fsmail_webhook_secret)||""}),B(!1)}).catch(s=>{console.error("Failed to fetch settings:",s),B(!1)})},[]),o.useEffect(()=>{typeof window<"u"&&_e(`${window.location.origin}/api/auth/oidc/callback`)},[]);const Oe=async s=>{ue(!0),f({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({codebuddy_auto_fsrouter:l.codebuddy_auto_fsrouter?"1":"0",codebuddy_leave_canva_team:l.codebuddy_leave_canva_team?"1":"0",codebuddy_browser_headless:l.codebuddy_browser_headless?"1":"0",codebuddy_proxy_enabled:l.codebuddy_proxy_enabled?"1":"0",codebuddy_proxy_server:l.codebuddy_proxy_server,codebuddy_proxy_username:l.codebuddy_proxy_username,codebuddy_proxy_password:l.codebuddy_proxy_password,fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})}),a=await t.json();t.ok?(x(n=>({...n,...a})),f({type:"success",message:"Automation settings saved successfully."})):f({type:"error",message:a.error||"Failed to update automation settings"})}catch{f({type:"error",message:"An error occurred"})}finally{ue(!1)}},Le=async()=>{pe(!0),f({type:"",message:""});try{const s=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})});if(!s.ok){const n=await s.json().catch(()=>({}));f({type:"error",message:n.error||"Failed to save settings before testing connection"});return}const t=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test-connection"})}),a=await t.json().catch(()=>({}));t.ok?f({type:"success",message:"FSMail Connection Successful!"}):f({type:"error",message:a.error||"FSMail Connection Failed."})}catch(s){f({type:"error",message:s.message||"An error occurred"})}finally{pe(!1)}},Ie=async()=>{var s;be(!0),f({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fsmail_base_url:l.fsmail_base_url,fsmail_api_key:l.fsmail_api_key,fsmail_default_domain:l.fsmail_default_domain,fsmail_webhook_secret:l.fsmail_webhook_secret})});if(!t.ok){const b=await t.json().catch(()=>({}));f({type:"error",message:b.error||"Failed to save settings before registering webhook"});return}const a=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"webhook-register"})}),n=await a.json().catch(()=>({}));a.ok?(f({type:"success",message:"FSMail Webhook Registered Successfully!"}),(s=n.webhook)!=null&&s.secret&&j(b=>({...b,fsmail_webhook_secret:n.webhook.secret}))):f({type:"error",message:n.error||"FSMail Webhook Registration Failed."})}catch(t){f({type:"error",message:t.message||"An error occurred"})}finally{be(!1)}},Te=async s=>{if(s.preventDefault(),r.outboundProxyEnabled===!0){G(!0),y({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:J.outboundProxyUrl,outboundNoProxy:J.outboundNoProxy})}),a=await t.json();t.ok?(x(n=>({...n,...a})),y({type:"success",message:"Proxy settings applied"})):y({type:"error",message:a.error||"Failed to update proxy settings"})}catch{y({type:"error",message:"An error occurred"})}finally{G(!1)}}},Re=async()=>{if(r.outboundProxyEnabled!==!0)return;const s=(J.outboundProxyUrl||"").trim();if(!s){y({type:"error",message:"Please enter a Proxy URL to test"});return}xe(!0),y({type:"",message:""});try{const t=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:s})}),a=await t.json();t.ok&&(a!=null&&a.ok)?y({type:"success",message:`Proxy test OK (${a.status}) in ${a.elapsedMs}ms`}):y({type:"error",message:(a==null?void 0:a.error)||"Proxy test failed"})}catch{y({type:"error",message:"An error occurred"})}finally{xe(!1)}},Fe=async s=>{G(!0),y({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:s})}),a=await t.json();t.ok?(x(n=>({...n,...a})),z(n=>({...n,outboundProxyEnabled:(a==null?void 0:a.outboundProxyEnabled)===!0})),y({type:"success",message:s?"Proxy enabled":"Proxy disabled"})):y({type:"error",message:a.error||"Failed to update proxy settings"})}catch{y({type:"error",message:"An error occurred"})}finally{G(!1)}},De=async s=>{if(s.preventDefault(),c.new!==c.confirm){M({type:"error",message:"Passwords do not match"});return}ie(!0),M({type:"",message:""});try{const t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:c.current,newPassword:c.new})}),a=await t.json();t.ok?(M({type:"success",message:"Password updated successfully"}),N({current:"",new:"",confirm:""})):M({type:"error",message:a.error||"Failed to update password"})}catch{M({type:"error",message:"An error occurred"})}finally{ie(!1)}},Ae=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:s})})).ok&&x(a=>({...a,fallbackStrategy:s}))}catch(t){console.error("Failed to update settings:",t)}},Ue=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:s})})).ok&&x(a=>({...a,comboStrategy:s}))}catch(t){console.error("Failed to update combo strategy:",t)}},Ee=async s=>{const t=parseInt(s);if(!(isNaN(t)||t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:t})})).ok&&x(n=>({...n,stickyRoundRobinLimit:t}))}catch(a){console.error("Failed to update sticky limit:",a)}},Me=async s=>{const t=parseInt(s);if(!(isNaN(t)||t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:t})})).ok&&x(n=>({...n,comboStickyRoundRobinLimit:t}))}catch(a){console.error("Failed to update combo sticky limit:",a)}},Je=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:s})})).ok&&x(a=>({...a,requireLogin:s}))}catch(t){console.error("Failed to update require login:",t)}},q=(s,t)=>{Q(a=>({...a,[s]:t}))},$e=async(s=p.authMode||"password")=>{const t=p.oidcIssuerUrl.trim(),a=p.oidcClientId.trim(),n=p.oidcScopes.trim(),b=p.oidcLoginLabel.trim(),u=X.trim();if(s!=="password"&&(!t||!a||!u)&&!r.oidcConfigured){A({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});return}ne(!0),A({type:"",message:""}),I({type:"",message:""});try{const _={authMode:s,oidcIssuerUrl:t,oidcClientId:a,oidcScopes:n||"openid profile email",oidcLoginLabel:b||"Sign in with OIDC"};u&&(_.oidcClientSecret=u);const h=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),d=await h.json();h.ok?(x(Ye=>({...Ye,...d})),Q({authMode:(d==null?void 0:d.authMode)||s,oidcIssuerUrl:(d==null?void 0:d.oidcIssuerUrl)||t,oidcClientId:(d==null?void 0:d.oidcClientId)||a,oidcScopes:(d==null?void 0:d.oidcScopes)||n||"openid profile email",oidcLoginLabel:(d==null?void 0:d.oidcLoginLabel)||b||"Sign in with OIDC"}),Z(""),A({type:"success",message:s==="oidc"?"OIDC login enabled":s==="both"?"Password and OIDC login enabled":"OIDC settings saved"})):A({type:"error",message:d.error||"Failed to save OIDC settings"})}catch{A({type:"error",message:"An error occurred"})}finally{ne(!1)}},qe=async()=>{const s=p.oidcIssuerUrl.trim(),t=p.oidcClientId.trim(),a=p.oidcScopes.trim(),n=X.trim();if(!s||!t){I({type:"error",message:"Issuer URL and client ID are required to test the connection."});return}ce(!0),A({type:"",message:""}),I({type:"",message:""});try{const b=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:p.authMode||r.authMode||"password",oidcIssuerUrl:s,oidcClientId:t,oidcScopes:a||"openid profile email",oidcLoginLabel:p.oidcLoginLabel.trim()||"Sign in with OIDC",...n?{oidcClientSecret:n}:{}})}),u=await b.json().catch(()=>({}));if(!b.ok){I({type:"error",message:u.error||"Failed to save OIDC settings before testing"});return}const _=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:u.oidcIssuerUrl||s,clientId:u.oidcClientId||t,scopes:u.oidcScopes||a||"openid profile email"})}),h=await _.json().catch(()=>({}));if(_.ok&&(h!=null&&h.ok)){const d=h.clientSecretTested?h.clientSecretValid===!0?`Connection OK. Discovery loaded from ${h.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${h.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${h.issuerUrl}.`;I({type:"success",message:d})}else I({type:"error",message:h.error||"OIDC connection test failed"})}catch{I({type:"error",message:"An error occurred"})}finally{ce(!1)}},He=async s=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:s})})).ok&&x(a=>({...a,enableObservability:s}))}catch(t){console.error("Failed to update enableObservability:",t)}},Be=async()=>{try{const s=await fetch("/api/settings");if(!s.ok)return;const t=await s.json();x(t)}catch(s){console.error("Failed to reload settings:",s)}},We=async()=>{W(!0),D({type:"",message:""});try{const s=await fetch("/api/settings/database");if(!s.ok){const h=await s.json().catch(()=>({}));throw new Error(h.error||"Failed to export database")}const t=await s.json(),a=JSON.stringify(t,null,2),n=new Blob([a],{type:"application/json"}),b=URL.createObjectURL(n),u=document.createElement("a"),_=new Date().toISOString().replace(/[.:]/g,"-");u.href=b,u.download=`fsrouter-backup-${_}.json`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(b),D({type:"success",message:"Database backup downloaded"})}catch(s){D({type:"error",message:s.message||"Failed to export database"})}finally{W(!1)}},Ke=async s=>{var a;const t=(a=s.target.files)==null?void 0:a[0];if(t){W(!0),D({type:"",message:""});try{const n=await t.text(),b=JSON.parse(n),u=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),_=await u.json().catch(()=>({}));if(!u.ok)throw new Error(_.error||"Failed to import database");await Be(),D({type:"success",message:"Database imported successfully"})}catch(n){D({type:"error",message:n.message||"Invalid backup file"})}finally{K.current&&(K.current.value=""),W(!1)}}},ze=r.enableObservability===!0,Ge=async()=>{F(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}F(!1),E(!1)},Ve=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(localStorage.removeItem("9r_authed"),g("/login"),g(0))}catch(s){console.error("Failed to logout:",s)}};return e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-0",children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(T,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"size-10 sm:size-12 rounded-lg bg-green-500/10 text-green-500 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-xl sm:text-2xl",children:"computer"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold",children:"Local Mode"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Running on your machine"})]})]}),e.jsx("div",{className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5 w-full sm:w-auto",children:["light","dark","system"].map(s=>e.jsxs("button",{type:"button",onClick:()=>S(s),className:he("flex items-center justify-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-md font-medium transition-all flex-1 sm:flex-initial",k===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:s==="light"?"light_mode":s==="dark"?"dark_mode":"contrast"}),e.jsx("span",{className:"capitalize text-xs sm:text-sm",children:s})]},s))})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-4 border-t border-border",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-3 rounded-lg bg-bg border border-border gap-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Database Location"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted font-mono break-all",children:"~/.fsrouter/db/data.sqlite"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(v,{variant:"secondary",icon:"download",onClick:We,loading:le,className:"w-full sm:w-auto",children:"Download Backup"}),e.jsx(v,{variant:"outline",icon:"upload",onClick:()=>{var s;return(s=K.current)==null?void 0:s.click()},disabled:le,className:"w-full sm:w-auto",children:"Import Backup"}),e.jsx("input",{ref:K,type:"file",accept:"application/json,.json",className:"hidden",onChange:Ke})]}),Y.message&&e.jsx("p",{className:`text-sm ${Y.type==="error"?"text-red-500":"text-green-600 dark:text-green-400"}`,children:Y.message})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"shield"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Security"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),e.jsx(C,{checked:r.requireLogin===!0,onChange:()=>Je(!r.requireLogin),disabled:i})]}),r.requireLogin===!0&&e.jsxs("form",{onSubmit:De,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[r.hasPassword&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"Current Password"}),e.jsx(m,{type:"password",placeholder:"Enter current password",value:c.current,onChange:s=>N({...c,current:s.target.value}),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"New Password"}),e.jsx(m,{type:"password",placeholder:"Enter new password",value:c.new,onChange:s=>N({...c,new:s.target.value}),required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium",children:"Confirm New Password"}),e.jsx(m,{type:"password",placeholder:"Confirm new password",value:c.confirm,onChange:s=>N({...c,confirm:s.target.value}),required:!0})]})]}),O.message&&e.jsx("p",{className:`text-xs sm:text-sm ${O.type==="error"?"text-red-500":"text-green-500"}`,children:O.message}),e.jsx("div",{className:"pt-2",children:e.jsx(v,{type:"submit",variant:"primary",loading:we,className:"w-full sm:w-auto",children:r.hasPassword?"Update Password":"Set Password"})})]})]})]}),e.jsxs(T,{children:[e.jsxs("button",{type:"button",onClick:()=>me(s=>!s),className:"w-full flex items-center gap-3 text-left",children:[e.jsx("div",{className:"p-2 rounded-lg bg-indigo-500/10 text-indigo-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"OIDC Dashboard Login"}),e.jsx("p",{className:"text-xs text-text-muted",children:r.authMode==="oidc"?"OIDC active":r.authMode==="both"?"Password + OIDC active":"Optional SSO via Authentik/Keycloak/Google"})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:de?"expand_less":"expand_more"})]}),de&&e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Use Authentik or any OIDC provider to sign in to the dashboard. You can enable password-only, OIDC-only, or both for the dashboard; model API access still uses API keys."}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Auth Mode"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep the legacy password login."},{value:"oidc",title:"OIDC only",desc:"Require OIDC for dashboard access."},{value:"both",title:"Both",desc:"Allow either password or OIDC."}].map(s=>{const t=p.authMode===s.value;return e.jsxs("button",{type:"button",onClick:()=>q("authMode",s.value),className:he("text-left rounded-lg border p-3 transition-colors",t?"border-primary bg-primary/5":"border-border bg-bg hover:bg-black/5 dark:hover:bg-white/5"),disabled:i||L,children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:s.title}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted mt-1",children:s.desc})]},s.value)})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Issuer URL"}),e.jsx(m,{placeholder:"https://auth.example.com/application/o/fsrouter/",value:p.oidcIssuerUrl,onChange:s=>q("oidcIssuerUrl",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Client ID"}),e.jsx(m,{placeholder:"fsrouter-dashboard",value:p.oidcClientId,onChange:s=>q("oidcClientId",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Client Secret"}),e.jsx(m,{type:"password",placeholder:"Leave blank to keep existing secret",value:X,onChange:s=>Z(s.target.value),disabled:i||L}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"This value is write-only after saving."})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Scopes"}),e.jsx(m,{placeholder:"openid profile email",value:p.oidcScopes,onChange:s=>q("oidcScopes",s.target.value),disabled:i||L})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Login Button Label"}),e.jsx(m,{placeholder:"Sign in with OIDC",value:p.oidcLoginLabel,onChange:s=>q("oidcLoginLabel",s.target.value),disabled:i||L})]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-bg p-3 text-xs sm:text-sm text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),e.jsx("code",{className:"block break-all font-mono",children:Ne})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[e.jsx(v,{type:"button",variant:"primary",loading:L,onClick:()=>$e(),className:"w-full sm:w-auto",children:"Save auth mode"}),e.jsx(v,{type:"button",variant:"outline",loading:ve,onClick:qe,className:"w-full sm:w-auto",children:"Test connection"})]}),se.message&&e.jsx("p",{className:`text-xs sm:text-sm ${se.type==="error"?"text-red-500":"text-green-500"}`,children:se.message}),ee.message&&e.jsx("p",{className:`text-xs sm:text-sm ${ee.type==="error"?"text-red-500":"text-green-500"}`,children:ee.message}),r.authMode==="oidc"&&e.jsx("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"OIDC login is currently active. Password login is disabled until you switch back."}),r.authMode==="both"&&e.jsx("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:"Password and OIDC login are both active."})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"route"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Routing Strategy"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),e.jsx(C,{checked:r.fallbackStrategy==="round-robin",onChange:()=>Ae(r.fallbackStrategy==="round-robin"?"fill-first":"round-robin"),disabled:i})]}),r.fallbackStrategy==="round-robin"&&e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),e.jsx(m,{type:"number",min:"1",max:"10",value:r.stickyRoundRobinLimit||3,onChange:s=>Ee(s.target.value),disabled:i,className:"w-16 sm:w-20 text-center shrink-0"})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-4 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),e.jsx(C,{checked:r.comboStrategy==="round-robin",onChange:()=>Ue(r.comboStrategy==="round-robin"?"fallback":"round-robin"),disabled:i})]}),r.comboStrategy==="round-robin"&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Combo Sticky Limit"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),e.jsx(m,{type:"number",min:"1",max:"100",value:r.comboStickyRoundRobinLimit||1,onChange:s=>Me(s.target.value),disabled:i,className:"w-20 text-center"})]}),e.jsxs("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:[r.fallbackStrategy==="round-robin"?`Currently distributing requests across all available accounts with ${r.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).",r.comboStrategy==="round-robin"?` Combos rotate after ${r.comboStickyRoundRobinLimit||1} call${(r.comboStickyRoundRobinLimit||1)===1?"":"s"} per model.`:" Combos always start with their first model."]})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"wifi"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Network"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),e.jsx(C,{checked:r.outboundProxyEnabled===!0,onChange:()=>Fe(r.outboundProxyEnabled!==!0),disabled:i||$})]}),r.outboundProxyEnabled===!0&&e.jsxs("form",{onSubmit:Te,className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Proxy URL"}),e.jsx(m,{placeholder:"http://127.0.0.1:7897",value:J.outboundProxyUrl,onChange:s=>z(t=>({...t,outboundProxyUrl:s.target.value})),disabled:i||$}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Leave empty to inherit existing env proxy (if any)."})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border/50",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"No Proxy"}),e.jsx(m,{placeholder:"localhost,127.0.0.1",value:J.outboundNoProxy,onChange:s=>z(t=>({...t,outboundNoProxy:s.target.value})),disabled:i||$}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Comma-separated hostnames/domains to bypass the proxy."})]}),e.jsxs("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(v,{type:"button",variant:"secondary",loading:ke,disabled:i||$,onClick:Re,className:"w-full sm:w-auto",children:"Test proxy URL"}),e.jsx(v,{type:"submit",variant:"primary",loading:$,className:"w-full sm:w-auto",children:"Apply"})]})]}),te.message&&e.jsx("p",{className:`text-xs sm:text-sm ${te.type==="error"?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:te.message})]})]}),e.jsxs(T,{children:[e.jsxs("button",{type:"button",onClick:()=>Pe(s=>!s),className:"w-full flex items-center gap-3 text-left focus:outline-none",children:[e.jsx("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"smart_toy"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Automation Settings"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Manage CodeBuddy browser signup & FSMail temporary email configurations."})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:fe?"expand_less":"expand_more"})]}),fe&&e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-text-main flex items-center gap-1.5 border-b border-border/55 pb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"smart_toy"}),"CodeBuddy API Gen Settings"]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Headless Browser"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Run the automated signup browser in headless mode (no visual window)."})]}),e.jsx(C,{checked:l.codebuddy_browser_headless,onChange:s=>j(t=>({...t,codebuddy_browser_headless:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Auto Inject to fsrouter"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Automatically add newly generated CodeBuddy API keys to fsrouter connections."})]}),e.jsx(C,{checked:l.codebuddy_auto_fsrouter,onChange:s=>j(t=>({...t,codebuddy_auto_fsrouter:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Leave Canva Team after Leonardo Registration"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Automatically leave the Canva team after completing Leonardo registration to free up team invite slots."})]}),e.jsx(C,{checked:l.codebuddy_leave_canva_team,onChange:s=>j(t=>({...t,codebuddy_leave_canva_team:s})),disabled:i||w})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Use Outbound Proxy"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Route the automation browser traffic through a proxy server."})]}),e.jsx(C,{checked:l.codebuddy_proxy_enabled,onChange:s=>j(t=>({...t,codebuddy_proxy_enabled:s})),disabled:i||w})]}),l.codebuddy_proxy_enabled&&e.jsxs("div",{className:"flex flex-col gap-3 pl-4 border-l-2 border-primary/20 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Server"}),e.jsx(m,{placeholder:"host:port (e.g. 127.0.0.1:8080)",value:l.codebuddy_proxy_server,onChange:s=>j(t=>({...t,codebuddy_proxy_server:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Username (Optional)"}),e.jsx(m,{placeholder:"username",value:l.codebuddy_proxy_username,onChange:s=>j(t=>({...t,codebuddy_proxy_username:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-main",children:"Proxy Password (Optional)"}),e.jsx(m,{type:"password",placeholder:"password",value:l.codebuddy_proxy_password,onChange:s=>j(t=>({...t,codebuddy_proxy_password:s.target.value})),disabled:i||w})]})]})]})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t border-border/55",children:[e.jsxs("h4",{className:"font-semibold text-sm text-text-main flex items-center gap-1.5 border-b border-border/55 pb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"mail"}),"FSMail Temp Mail Settings"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Base URL"}),e.jsx(m,{placeholder:"https://fsmail.example.com",value:l.fsmail_base_url,onChange:s=>j(t=>({...t,fsmail_base_url:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"API Key"}),e.jsx(m,{type:"password",placeholder:"FSMail API Key",value:l.fsmail_api_key,onChange:s=>j(t=>({...t,fsmail_api_key:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Default Domain"}),e.jsx(m,{placeholder:"example.com",value:l.fsmail_default_domain,onChange:s=>j(t=>({...t,fsmail_default_domain:s.target.value})),disabled:i||w})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"font-medium text-sm sm:text-base",children:"Webhook Secret"}),e.jsx(m,{type:"password",placeholder:"Leave empty to auto-generate",value:l.fsmail_webhook_secret,onChange:s=>j(t=>({...t,fsmail_webhook_secret:s.target.value})),disabled:i||w})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-4 border-t border-border/50",children:[e.jsx(v,{type:"button",variant:"primary",loading:w,onClick:()=>Oe(),className:"w-full sm:w-auto",children:"Save Settings"}),e.jsx(v,{type:"button",variant:"secondary",loading:Ce,onClick:Le,className:"w-full sm:w-auto",children:"Test FSMail Connection"}),e.jsx(v,{type:"button",variant:"outline",loading:Se,onClick:Ie,className:"w-full sm:w-auto",children:"Register Webhook"})]}),ae.message&&e.jsx("p",{className:`text-xs sm:text-sm ${ae.type==="error"?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:ae.message})]})]}),e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500 shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"monitoring"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:"Observability"})]}),e.jsxs("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),e.jsx("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),e.jsx(C,{checked:ze,onChange:He,disabled:i})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(v,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>E(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"}),e.jsx(v,{variant:"outline",fullWidth:!0,icon:"logout",onClick:Ve,children:"Logout"})]}),e.jsxs("div",{className:"text-center text-xs sm:text-sm text-text-muted py-4",children:[e.jsxs("p",{children:[ge.name," v",ge.version]}),e.jsx("p",{className:"mt-1",children:"Local Mode - All data stored on your machine"})]})]}),e.jsx(os,{hideTrigger:!0,isOpen:U,onClose:s=>{R(!1),P(s)}}),e.jsx(es,{isOpen:H,onClose:()=>E(!1),onConfirm:Ge,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:V})]})}export{ds as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,u}from"./index.C5VWu_q7.js";import{C as l,B as d}from"./NoAuthProxyCard.DMCykSRG.js";import"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";const c="nexusrouters/fsrouter",m="main",x="skills",h=`https://github.com/${c}`,f=`https://raw.githubusercontent.com/${c}/refs/heads/${m}/${x}`,b=`https://github.com/${c}/blob/${m}/${x}`,n=[{id:"fsrouter",name:"FSRouter (Entry)",description:"Setup + index of all capabilities. Start here — covers base URL, auth, model discovery, and links to every capability skill.",endpoint:null,icon:"hub",isEntry:!0},{id:"fsrouter-chat",name:"Chat",description:"Chat / code-gen via OpenAI or Anthropic format with streaming.",endpoint:"/v1/chat/completions",icon:"chat"},{id:"fsrouter-image",name:"Image Generation",description:"Text-to-image via DALL-E, Imagen, FLUX, MiniMax, SDWebUI…",endpoint:"/v1/images/generations",icon:"image"},{id:"fsrouter-tts",name:"Text-to-Speech",description:"OpenAI / ElevenLabs / Edge / Google / Deepgram voices.",endpoint:"/v1/audio/speech",icon:"record_voice_over"},{id:"fsrouter-stt",name:"Speech-to-Text",description:"Transcribe audio via OpenAI Whisper, Groq, Gemini, Deepgram, AssemblyAI…",endpoint:"/v1/audio/transcriptions",icon:"mic"},{id:"fsrouter-embeddings",name:"Embeddings",description:"Vectors for RAG / semantic search via OpenAI, Gemini, Mistral…",endpoint:"/v1/embeddings",icon:"scatter_plot"},{id:"fsrouter-web-search",name:"Web Search",description:"Tavily / Exa / Brave / Serper / SearXNG / Google PSE / You.com.",endpoint:"/v1/search",icon:"search"},{id:"fsrouter-web-fetch",name:"Web Fetch",description:"URL → markdown / text / HTML via Firecrawl, Jina, Tavily, Exa.",endpoint:"/v1/web/fetch",icon:"language"},{id:"using-superpowers",name:"Using Superpowers",description:"Use when starting any conversation — establishes how to find and use skills before ANY response.",endpoint:null,icon:"bolt"},{id:"multi-brain",name:"Multi-Brain Memory",description:"Share work and memory across Claude Code, OpenCode, Codex, and other agents via a two-level memory index.",endpoint:null,icon:"memory"}];function o(t){return`${f}/${t}/SKILL.md`}function g(t){return`${b}/${t}/SKILL.md`}function p({value:t,label:i="Copy link"}){const{copied:r,copy:s}=u(2e3);return e.jsxs("button",{onClick:()=>s(t),className:"px-2 py-1 rounded-md bg-primary text-white text-[11px] font-medium hover:bg-primary/90 transition-colors cursor-pointer shrink-0 inline-flex items-center gap-1",title:t,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:r?"check":"content_copy"}),r?"Copied!":i]})}function a({skill:t}){const i=o(t.id);return e.jsxs("div",{className:`flex items-start gap-3 p-4 rounded-[14px] border shadow-[var(--shadow-soft)] transition-colors ${t.isEntry?"border-primary/40 bg-primary/5":"border-border-subtle bg-surface hover:bg-surface-2"}`,children:[e.jsx("div",{className:`size-9 rounded-lg flex items-center justify-center shrink-0 ${t.isEntry?"bg-primary text-white":"bg-primary/10 text-primary"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t.icon})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-sm text-text-main",children:t.name}),t.isEntry&&e.jsx(d,{variant:"primary",size:"sm",children:"START HERE"}),t.endpoint&&e.jsx(d,{variant:"default",size:"sm",children:e.jsx("code",{className:"text-[10px]",children:t.endpoint})})]}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:t.description}),e.jsxs("a",{href:g(t.id),target:"_blank",rel:"noreferrer",className:"text-[11px] text-text-muted hover:text-primary mt-1 inline-flex items-center gap-1 break-all",children:[i,e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"})]})]}),e.jsx(p,{value:i})]})}const y=["fsrouter-chat","fsrouter-image","fsrouter-tts","fsrouter-stt","fsrouter-embeddings","fsrouter-web-search","fsrouter-web-fetch"],j=["using-superpowers","multi-brain"];function L(){const t=n.find(s=>s.isEntry),i=n.filter(s=>y.includes(s.id)),r=n.filter(s=>j.includes(s.id));return e.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"size-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"extension"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-text-main",children:"Agent Skills"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Raw SKILL.md URLs to paste into any AI agent or coding assistant."})]})]})}),e.jsxs(l,{padding:"md",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"rocket_launch"}),e.jsx("span",{className:"text-xs font-semibold text-text-main uppercase tracking-wide",children:"Quick Start — Paste this to your AI"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex-1 px-3 py-2 rounded-lg bg-surface-2 font-mono text-[12px] text-text-main border border-border-subtle min-w-0 break-all",children:["Read this skill and use it: ",o("fsrouter")]}),e.jsx(p,{value:`Read this skill and use it: ${o("fsrouter")}`,label:"Copy prompt"})]}),e.jsx("p",{className:"text-[11px] text-text-muted mt-2",children:"This entry skill covers setup, authentication, model discovery, and links to all capability skills below."})]}),t&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"Entry Point"}),e.jsx(a,{skill:t})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"API Capabilities"}),e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsx(a,{skill:s},s.id))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"Agent Workflow"}),e.jsx("div",{className:"space-y-2",children:r.map(s=>e.jsx(a,{skill:s},s.id))})]}),e.jsx(l,{padding:"md",children:e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"Browse on GitHub"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"View source, README, and full skill documentation."})]}),e.jsxs("a",{href:`${h}/tree/master/skills`,target:"_blank",rel:"noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"open_in_new"}),"View on GitHub"]})]})})]})}export{L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.C5VWu_q7.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.DMCykSRG.js";import"./zustand.akaTi5uX.js";const O={sessions:"basic-chat.sessions",activeSessionId:"basic-chat.activeSessionId",activeProviderId:"basic-chat.activeProviderId",draft:"basic-chat.draft"};function J(){var e;return(e=globalThis.crypto)!=null&&e.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Fe(e,a){try{return JSON.parse(e)}catch{return a}}function S(e){if(typeof e=="string")return e;if(e==null)return"";if(Array.isArray(e))return e.map(S).filter(Boolean).join(" ");if(typeof e=="object"){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function He(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase()).trim()||"Unknown"}function Je(e){if(!e)return"Now";const a=new Date(e).getTime();if(Number.isNaN(a))return"Now";const m=Math.max(1,Math.round((Date.now()-a)/6e4));if(m<60)return`${m}m`;const u=Math.round(m/60);return u<24?`${u}h`:`${Math.round(u/24)}d`}function Ne(e=""){const a=S(e).replace(/\s+/g," ").trim();return a?a.length>52?`${a.slice(0,52).trimEnd()}…`:a:"New chat"}function Ke(e){const a=S(e.content).trim(),m=Array.isArray(e.attachments)?e.attachments:[];if(m.length===0)return a;const u=[];a&&u.push({type:"text",text:a});for(const w of m)w!=null&&w.dataUrl&&u.push({type:"image_url",image_url:{url:w.dataUrl}});return u.length>0?u:a}function We(e){var w,A;if(!e||typeof e!="object")return"";const a=(w=e.choices)==null?void 0:w[0];return[((a==null?void 0:a.delta)||{}).content,(A=a==null?void 0:a.message)==null?void 0:A.content,e.output_text,e.text].map(S).filter(Boolean)[0]||""}async function Ye(e){return await new Promise((a,m)=>{const u=new FileReader;u.onload=()=>a(String(u.result||"")),u.onerror=()=>m(u.error||new Error("Failed to read file")),u.readAsDataURL(e)})}function Ve(e){return{...e,messages:Array.isArray(e.messages)?e.messages.map(a=>({...a})):[]}}function de(e){return(e==null?void 0:e.name)||He((e==null?void 0:e.provider)||(e==null?void 0:e.id)||"provider")}function Ge(e,a){return e!=null&&e.id?{id:`${a.provider}/${e.id}`,requestModel:`${a.provider}/${e.id}`,name:e.name||e.id,providerId:a.provider,providerName:de(a),source:"static"}:null}function Qe(e,a){const m=typeof e=="string"?e:(e==null?void 0:e.id)||(e==null?void 0:e.name)||(e==null?void 0:e.model)||"";if(!m)return null;const u=typeof e=="string"?e:(e==null?void 0:e.name)||(e==null?void 0:e.displayName)||m;let w=m;return(je(a.provider)||Ie(a.provider))&&!m.includes("/")&&(w=`${a.provider}/${m}`),{id:w,requestModel:w,name:u,providerId:a.provider,providerName:de(a),source:"live"}}function Xe(e){return Array.isArray(e==null?void 0:e.models)?e.models:Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e==null?void 0:e.results)?e.results:Array.isArray(e)?e:[]}function Ze(e){const a=new Map;for(const m of e)m!=null&&m.id&&(a.has(m.id)||a.set(m.id,m));return Array.from(a.values())}function et(){const[e,a]=d.useState([]),[m,u]=d.useState(!0),[w,A]=d.useState(""),[h,D]=d.useState(()=>{if(typeof window>"u")return[];try{const t=Fe(globalThis.localStorage.getItem(O.sessions),[]);return Array.isArray(t)?t.map(r=>({...r,messages:Array.isArray(r.messages)?r.messages:[]})):[]}catch{return[]}}),[g,M]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeSessionId)||""),[R,P]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeProviderId)||""),[I,U]=d.useState(""),[_,ce]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.draft)||""),[z,Q]=d.useState([]),[me,ue]=d.useState(!1),[Se,pe]=d.useState(""),[fe,X]=d.useState(""),[K,Ae]=d.useState(!1),[Me,Z]=d.useState(!1),[De,ee]=d.useState(!1),xe=d.useRef(null),B=d.useRef(null),te=d.useRef(!1),se=d.useRef(null),re=d.useRef(null);d.useEffect(()=>{Ae(!0)},[]),d.useEffect(()=>{let t=!1;async function r(){u(!0),A("");try{const n=await(await fetch("/api/providers",{cache:"no-store"})).json().catch(()=>({})),o=Array.isArray(n.connections)?n.connections.filter(c=>(c==null?void 0:c.isActive)!==!1):[];if(o.length===0){t||(a([]),A("No providers connected yet."));return}const x=new Map;for(const c of o){const p=c.provider||c.id,b=de(c),$=je(p)?"openai-compatible":Ie(p)?"anthropic-compatible":p;x.has(p)||x.set(p,{providerId:p,providerName:b,providerType:$,connections:[],models:[]});const N=x.get(p);N.providerName=N.providerName||b,N.providerType=N.providerType||$,N.connections.push(c);const W=Le(p).map(Y=>Ge(Y,c)).filter(Boolean);N.models.push(...W)}const k=await Promise.all(o.map(async c=>{try{const p=await fetch(`/api/providers/${c.id}/models`,{cache:"no-store"}),b=await p.json().catch(()=>({}));if(!p.ok)return{connection:c,models:[]};const $=Xe(b).map(N=>Qe(N,c)).filter(Boolean);return{connection:c,models:$}}catch{return{connection:c,models:[]}}}));for(const c of k){const p=c.connection.provider||c.connection.id,b=x.get(p);b&&b.models.push(...c.models)}const q=Array.from(x.values()).map(c=>({...c,models:Ze(c.models).sort((p,b)=>p.name.localeCompare(b.name))})).filter(c=>c.models.length>0).sort((c,p)=>c.providerName.localeCompare(p.providerName));t||(a(q),q.length===0&&A("Providers connected but no models available."))}catch(i){t||(A(S(i==null?void 0:i.message)||"Failed to load providers/models."),a([]))}finally{t||u(!1)}}return r(),()=>{t=!0}},[]),d.useEffect(()=>{const t=r=>{se.current&&!se.current.contains(r.target)&&Z(!1),re.current&&!re.current.contains(r.target)&&ee(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const y=d.useMemo(()=>{const t=new Map;for(const r of e)for(const i of r.models)t.set(i.id,{...i,providerId:r.providerId,providerName:r.providerName});return t},[e]),E=d.useMemo(()=>e.find(t=>t.providerId===R)||e[0]||null,[e,R]),v=d.useMemo(()=>{var t;if(I&&y.has(I))return y.get(I);if(g){const r=h.find(i=>i.id===g);if(r!=null&&r.modelId&&y.has(r.modelId))return y.get(r.modelId)}return((t=E==null?void 0:E.models)==null?void 0:t[0])||null},[I,y,E,h,g]),ie=d.useMemo(()=>h.find(t=>t.id===g)||null,[h,g]),he=(ie==null?void 0:ie.messages)||[],ge=d.useMemo(()=>[...h].sort((t,r)=>new Date(r.updatedAt).getTime()-new Date(t.updatedAt).getTime()),[h]),ae=!me&&!!v&&(_.trim().length>0||z.length>0);d.useEffect(()=>{if(K)try{globalThis.localStorage.setItem(O.sessions,JSON.stringify(h)),globalThis.localStorage.setItem(O.activeSessionId,g),globalThis.localStorage.setItem(O.activeProviderId,R),globalThis.localStorage.setItem(O.draft,_)}catch{}},[K,h,g,R,_]),d.useEffect(()=>{if(!K||m||te.current||e.length===0)return;const t=e.find(n=>n.providerId===R)||e[0],r=I&&y.has(I)?y.get(I):t.models[0];if(h.length>0){const n=h.find(x=>x.id===g)||h[0],o=n!=null&&n.modelId&&y.has(n.modelId)?y.get(n.modelId):r;te.current=!0,M(n.id),P((o==null?void 0:o.providerId)||t.providerId),U((o==null?void 0:o.id)||r.id);return}const i={id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:r.id,modelName:r.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};te.current=!0,D([i]),M(i.id),P(t.providerId),U(r.id)},[K,m,e,y,h,g,R,I]);const L=(t,r)=>{D(i=>i.map(n=>n.id===t?r(Ve(n)):n))},ne=t=>t?{id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ke=t=>{const r=h.find(i=>i.id===t);r&&(M(t),P(r.providerId||R),U(r.modelId||I),ee(!1))},Te=()=>{if(!g)return;const t=h.filter(i=>i.id!==g),r=t[0]||null;D(t),r?(M(r.id),P(r.providerId),U(r.modelId)):(M(""),P(""),U(""))},Ce=t=>{const r=y.get(t);if(!r)return;const i=h.find(n=>n.id===g);if(i&&i.messages.length>0){const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}else if(i)D(n=>n.map(o=>o.id===i.id?{...o,providerId:r.providerId,providerName:r.providerName,modelId:r.id,modelName:r.name}:o)),M(i.id);else{const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}P(r.providerId),U(r.id),Z(!1)},Oe=async t=>{const r=Array.from(t.target.files||[]);if(r.length===0)return;const i=r.filter(o=>o.type.startsWith("image/"));if(i.length===0){t.target.value="";return}const n=await Promise.all(i.map(async o=>({id:J(),name:o.name,type:o.type,size:o.size,dataUrl:await Ye(o)})));Q(o=>[...o,...n]),t.target.value=""},Re=t=>{Q(r=>r.filter(i=>i.id!==t))},Ee=()=>{var t;(t=B.current)==null||t.abort()},$e=(t,r)=>{const i=Ne(r);L(t,n=>({...n,title:n.title==="New chat"?i:n.title,updatedAt:new Date().toISOString()}))},we=async()=>{var p,b,$,N,W,Y;const t=v||((p=E==null?void 0:E.models)==null?void 0:p[0])||null;if(!t)return;const r=_.trim();if(!r&&z.length===0)return;let i=g,n=h.find(l=>l.id===i);if(!n){if(n=ne(t),!n)return;i=n.id,D(l=>[n,...l]),M(i)}const o={id:J(),role:"user",content:r,attachments:z.map(l=>({id:l.id,name:l.name,type:l.type,dataUrl:l.dataUrl})),createdAt:new Date().toISOString()},x=J(),k={id:x,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},q=[...n.messages||[],o,k];D(l=>l.map(j=>j.id===i?{...j,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:q,updatedAt:new Date().toISOString(),title:j.title==="New chat"?Ne(r):j.title}:j)),ce(""),Q([]),ue(!0),pe(x),X(""),(b=B.current)==null||b.abort(),B.current=new AbortController;const c=q.filter(l=>!(l.role==="assistant"&&l.id===x)).map(l=>({role:l.role,content:l.role==="user"?Ke(l):l.content}));try{const l=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:c,stream:!0}),signal:B.current.signal});if(!l.ok){const f=await l.json().catch(()=>({}));throw new Error(S(f.error||f.message||`Request failed (${l.status})`))}const j=($=l.body)==null?void 0:$.getReader();if(!j){const f=await l.json().catch(()=>({})),C=S(((Y=(W=(N=f==null?void 0:f.choices)==null?void 0:N[0])==null?void 0:W.message)==null?void 0:Y.content)||(f==null?void 0:f.output_text)||(f==null?void 0:f.error)||(f==null?void 0:f.message)||"");L(i,F=>({...F,messages:F.messages.map(H=>H.id===x?{...H,content:C,status:"done"}:H),updatedAt:new Date().toISOString()}));return}const V=new TextDecoder;let T="",G="";for(;;){const{value:f,done:C}=await j.read();if(C)break;T+=V.decode(f,{stream:!0});const F=T.split(/\r?\n/);T=F.pop()||"";for(const H of F){const ve=H.trim();if(!ve.startsWith("data:"))continue;const oe=ve.slice(5).trim();if(!(!oe||oe==="[DONE]"))try{const ze=JSON.parse(oe),be=We(ze);if(!be)continue;G+=be,X(G),L(i,ye=>({...ye,messages:ye.messages.map(le=>le.id===x?{...le,content:G,status:"streaming"}:le),updatedAt:new Date().toISOString()}))}catch{}}}L(i,f=>({...f,messages:f.messages.map(C=>C.id===x?{...C,content:G||C.content,status:"done"}:C),updatedAt:new Date().toISOString()})),$e(i,r)}catch(l){if(l.name!=="AbortError"){const j=S((l==null?void 0:l.message)||l);L(i,V=>({...V,messages:V.messages.map(T=>T.id===x?{...T,content:T.content||`Error: ${j}`,status:"error"}:T),updatedAt:new Date().toISOString()})),A(j||"Failed to send message.")}}finally{ue(!1),pe(""),X(""),B.current=null}},Pe=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ae&&we())},Ue=v?`${v.name}`:"Select model",_e=v?v.requestModel:"Choose from connected providers";return s.jsx("div",{className:"relative flex-1 flex flex-col h-full min-h-0 min-w-0 bg-[#212121] text-white overflow-hidden",children:s.jsxs("div",{className:"relative mx-auto flex flex-1 h-full min-h-0 w-full max-w-4xl flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-4 py-3 lg:px-6",children:[s.jsxs("div",{ref:se,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>Z(t=>!t),className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-left transition hover:bg-white/8",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold text-white",children:Ue}),s.jsx("span",{className:"material-symbols-outlined text-[18px] text-white/70",children:"expand_more"})]}),s.jsx("p",{className:"truncate text-xs text-white/55",children:_e})]})}),Me?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+10px)] z-30 w-[min(520px,calc(100vw-2rem))] overflow-hidden rounded-[20px] border border-white/10 bg-[#262626] shadow-2xl shadow-black/50",children:[s.jsxs("div",{className:"border-b border-white/10 px-4 py-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Models"}),s.jsx("p",{className:"text-sm text-white/75",children:"Only from connected providers"})]}),s.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-2 custom-scrollbar",children:e.map(t=>s.jsxs("div",{className:"mb-2 rounded-[16px] border border-white/10 bg-black/20 p-2",children:[s.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[s.jsx("p",{className:"text-sm font-semibold text-white",children:t.providerName}),s.jsx(qe,{size:"sm",variant:"default",children:t.models.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:t.models.map(r=>{const i=r.id===I;return s.jsx("button",{type:"button",onClick:()=>Ce(r.id),className:`rounded-[14px] border px-3 py-3 text-left transition ${i?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:r.name}),s.jsx("p",{className:"truncate text-[11px] text-white/45",children:r.requestModel})]}),i?s.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-300",children:"check_circle"}):null]})},r.id)})})]},t.providerId))})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ee(t=>!t),className:"rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80 transition hover:bg-white/8",children:"History"}),s.jsx(Be,{variant:"ghost",size:"sm",icon:"delete",onClick:Te,disabled:!g||h.length===0,children:"Clear"})]})]}),De?s.jsxs("div",{ref:re,className:"absolute right-4 top-[72px] z-20 w-[min(360px,calc(100vw-2rem))] rounded-[20px] border border-white/10 bg-[#262626] p-2 shadow-2xl shadow-black/50 lg:right-6",children:[s.jsx("div",{className:"px-3 py-2",children:s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Recent chats"})}),s.jsx("div",{className:"max-h-[48vh] space-y-2 overflow-y-auto p-1 custom-scrollbar",children:ge.length===0?s.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/5 p-4 text-sm text-white/55",children:"No conversations yet."}):ge.map(t=>{var n;const r=t.id===g,i=[...t.messages||[]].reverse().find(o=>o.role==="user")||((n=t.messages)==null?void 0:n[0]);return s.jsx("button",{type:"button",onClick:()=>ke(t.id),className:`w-full rounded-[16px] border px-3 py-3 text-left transition ${r?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:t.title}),s.jsx("p",{className:"mt-1 truncate text-xs text-white/50",children:S(i==null?void 0:i.content)||"Empty chat"})]}),s.jsx("span",{className:"text-[10px] text-white/40 shrink-0",children:Je(t.updatedAt)})]})},t.id)})})]}):null,w?s.jsx("div",{className:"mt-4 rounded-[18px] border border-rose-500/20 bg-rose-500/10 px-4 py-3 text-rose-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),s.jsx("p",{className:"text-sm leading-6",children:w})]})}):null,s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-4 custom-scrollbar",children:[he.length===0?s.jsx("div",{className:"flex min-h-[50vh] items-center justify-center px-4 text-center",children:s.jsxs("div",{className:"max-w-xl space-y-4",children:[s.jsx("div",{className:"mx-auto flex size-16 items-center justify-center rounded-[20px] border border-white/10 bg-white/5 text-white/80",children:s.jsx("span",{className:"material-symbols-outlined text-[30px]",children:"chat"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-white",children:"Start a conversation"}),s.jsx("p",{className:"text-sm leading-6 text-white/60",children:"Simple chat interface to interact with any AI model from connected providers. Select a model and start chatting!"})]})]})}):null,s.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-4",children:he.map(t=>{var x;const r=t.role==="user",i=t.role==="assistant",n=i&&t.id===Se&&t.status==="streaming",o=S(t.content)||(i?fe:"");return s.jsx("div",{className:`flex w-full ${r?"justify-end":"justify-start"} mb-6`,children:s.jsxs("div",{className:`max-w-[min(88%,42rem)] ${r?"rounded-3xl bg-[#2f2f2f] px-5 py-3.5 text-white":"text-white/90"}`,children:[s.jsx("div",{className:"mb-1 flex items-center justify-between gap-3",children:s.jsx("span",{className:"text-xs font-semibold",children:r?"You":(v==null?void 0:v.name)||"Assistant"})}),(x=t.attachments)!=null&&x.length?s.jsx("div",{className:"mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 mt-2",children:t.attachments.map(k=>s.jsx("a",{href:k.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-[18px] border border-white/10 bg-black/20",children:s.jsx("img",{src:k.dataUrl,alt:k.name,className:"h-28 w-full object-cover"})},k.id))}):null,s.jsxs("div",{className:"whitespace-pre-wrap break-words text-[15px] leading-7",children:[o,i&&n&&!fe?s.jsx("span",{className:"inline-block animate-pulse",children:"▋"}):null]})]})},t.id)})})]}),s.jsxs("div",{className:"shrink-0 pt-2",children:[z.length>0?s.jsx("div",{className:"mx-auto mb-3 flex w-full max-w-3xl flex-wrap gap-2 px-4",children:z.map(t=>s.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-white/80 max-w-[12rem] truncate",children:t.name}),s.jsx("button",{type:"button",onClick:()=>Re(t.id),className:"text-white/55 hover:text-white","aria-label":"Remove attachment",children:s.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]},t.id))}):null,s.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 pb-2",children:s.jsxs("div",{className:"rounded-[26px] bg-[#2f2f2f] px-3 pt-3 pb-2 shadow-[0_0_15px_rgba(0,0,0,0.10)] ring-1 ring-white/5",children:[s.jsx("textarea",{value:_,onChange:t=>ce(t.target.value),onKeyDown:Pe,placeholder:"Message AI",rows:1,className:"w-full resize-none bg-transparent px-2 text-[15px] leading-6 text-white outline-none placeholder:text-white/40 custom-scrollbar max-h-[25vh] overflow-y-auto"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{var t;return(t=xe.current)==null?void 0:t.click()},disabled:!v||m,className:"p-2 text-white/50 hover:text-white transition rounded-full hover:bg-white/5",children:s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"attach_file"})}),s.jsx("input",{ref:xe,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Oe}),s.jsx("span",{className:"text-xs font-medium text-white/30 truncate max-w-[120px]",children:v?v.name:"No model"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[me?s.jsx("button",{type:"button",onClick:Ee,className:"p-2 text-white bg-white/10 hover:bg-white/20 transition rounded-full h-8 w-8 flex items-center justify-center",children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"stop"})}):null,s.jsx("button",{onClick:we,disabled:!ae,className:`h-8 w-8 rounded-full flex items-center justify-center transition ${ae?"bg-white text-black hover:opacity-90":"bg-white/10 text-white/30 cursor-not-allowed"}`,children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})})]})]})]})})]}),s.jsx("p",{className:"mx-auto mt-2 max-w-3xl px-4 pb-4 text-center text-[11px] text-white/30",children:"Model list is filtered from connected providers."})]})]})})}function at(){return s.jsx(et,{})}export{at as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./index.C5VWu_q7.js";import{b as t,d as H}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function z(){const[x,N]=t.useState(""),[m,c]=t.useState(""),[W,b]=t.useState(""),[r,f]=t.useState(0),[g,w]=t.useState(!1),[y,u]=t.useState(null),[n,k]=t.useState("password"),[i,L]=t.useState(!1),[S,C]=t.useState("Sign in with OIDC"),[h,M]=t.useState(!1),l=H();t.useEffect(()=>{if(r<=0)return;const a=setInterval(()=>f(s=>s>0?s-1:0),1e3);return()=>clearInterval(a)},[r]),t.useEffect(()=>{async function a(){const s=new AbortController,o=setTimeout(()=>s.abort(),5e3),R=typeof window<"u"?window.location.origin:"";try{const v=await fetch(`${R}/api/auth/status`,{signal:s.signal});if(clearTimeout(o),v.ok){const d=await v.json(),j=new URLSearchParams(window.location.search),E=j.get("force")==="true"||j.get("force")==="1";if(d.requireLogin===!1&&!E){localStorage.setItem("9r_authed","1"),l("/dashboard"),l(0);return}u(!!d.hasPassword),k(d.authMode||"password"),L(d.oidcConfigured===!0),C(d.oidcLoginLabel||"Sign in with OIDC")}else u(!0)}catch{clearTimeout(o),u(!0)}}a()},[l]);const P=async a=>{a.preventDefault(),w(!0),c(""),b("");try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:x})});if(s.ok)localStorage.setItem("9r_authed","1"),l("/dashboard"),l(0);else{const o=await s.json();c(o.error||"Invalid password"),o.resetHint&&b(o.resetHint),o.retryAfter&&f(Number(o.retryAfter))}}catch{c("An error occurred. Please try again.")}finally{w(!1)}},I=()=>{window.location.href="/api/auth/oidc/start"},A=i&&["oidc","both"].includes(n),p=n!=="oidc"||!i,O=n==="oidc"&&!i||n==="both"&&!i,D=n==="both"&&i;return y===null?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-slate-400"})}):e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-slate-100 p-4",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-violet-200/30 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-blue-200/30 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-sm",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-200/60 p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-violet-500 to-blue-500 mb-4 shadow-lg shadow-violet-500/25",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 tracking-tight",children:"FSRouter"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:n==="oidc"&&i?"Sign in with your OIDC provider":"Enter your password to continue"})]}),O&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-amber-50 border border-amber-200 text-xs text-amber-700",children:"OIDC not configured yet. Password login is available."}),D&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-violet-50 border border-violet-200 text-xs text-violet-700 text-center",children:"Password and OIDC login are both enabled."}),p&&e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-600 block mb-1.5",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{name:"password",type:h?"text":"password",placeholder:"••••••••",value:x,onChange:a=>N(a.target.value),required:!0,autoFocus:!0,className:"w-full bg-slate-50 border border-slate-200 text-slate-900 text-sm p-3 pr-10 rounded-xl focus:outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 placeholder-slate-400 transition-all"}),e.jsx("button",{type:"button",onClick:()=>M(!h),className:"absolute inset-y-0 right-3 flex items-center text-slate-400 hover:text-slate-600",children:h?e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878l4.242 4.242M21 21l-3.122-3.122"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]}),m&&e.jsx("p",{className:"text-xs text-red-500 mt-1.5",children:m}),r>0&&e.jsxs("p",{className:"text-xs text-amber-600 mt-1.5",children:["Locked. Retry in ",r,"s."]})]}),e.jsx("button",{type:"submit",disabled:g||r>0,className:"w-full bg-gradient-to-r from-violet-500 to-blue-500 hover:from-violet-600 hover:to-blue-600 text-white font-medium text-sm py-3 rounded-xl transition-all shadow-lg shadow-violet-500/25 disabled:opacity-50 cursor-pointer",children:g?"Logging in...":r>0?`Wait ${r}s`:"Login"}),e.jsxs("p",{className:"text-center text-xs text-slate-400",children:["Default password is ",e.jsx("code",{className:"bg-slate-100 px-1.5 py-0.5 rounded text-slate-500 font-mono",children:"123456"})]})]}),A&&e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:"relative flex items-center justify-center py-4",children:[e.jsx("span",{className:"w-full border-t border-slate-200"}),e.jsx("span",{className:"px-3 text-xs text-slate-400 bg-white absolute",children:"or"})]}),e.jsxs("button",{onClick:I,type:"button",className:"w-full flex items-center justify-center gap-2 border border-slate-200 rounded-xl py-3 hover:bg-slate-50 transition-colors text-slate-600 text-sm cursor-pointer",children:[e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),S]})]})]}),e.jsx("p",{className:"text-center text-xs text-slate-400 mt-6",children:"Powered by FSRouter"})]})]})}export{z as default};
|