dns-worker 1.1.1 → 1.1.2

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.
Files changed (51) hide show
  1. package/README.md +3 -3
  2. package/dist/serverfull.mjs +73 -69
  3. package/dist/serverfull.mjs.map +4 -4
  4. package/package.json +3 -1
  5. package/static/assets/AccountView-p5jSjMAE.js +4 -0
  6. package/static/assets/{AnalyticsView-C_g_jz14.js → AnalyticsView-BywwDzah.js} +2 -2
  7. package/static/assets/AuthView-qoUKd5PS.js +2 -0
  8. package/static/assets/{DestinationMap-jSW7gimP.js → DestinationMap-9Yc54Mdj.js} +1 -1
  9. package/static/assets/FilteringView-Bs3__NpV.js +1 -0
  10. package/static/assets/LogsView-B-U9oaxB.js +5 -0
  11. package/static/assets/{QRCodeCanvas-Cu_-aNyM.js → QRCodeCanvas-DQ-xNuwF.js} +2 -2
  12. package/static/assets/{RulesView-CfVeQv0-.js → RulesView-B2kL1QhI.js} +1 -1
  13. package/static/assets/SettingsView-DTGI6eSd.js +1 -0
  14. package/static/assets/SetupView-DE9MM-32.js +1 -0
  15. package/static/assets/{SwipeableDrawer-BrmEzhuP.js → SwipeableDrawer-B81ANpsc.js} +1 -1
  16. package/static/assets/{TrendChart-Dc5yJndv.js → TrendChart-CCR1W3fC.js} +3 -3
  17. package/static/assets/browser-Dc5iKjY4.js +1 -0
  18. package/static/assets/date-CpvuBM37.js +1 -0
  19. package/static/assets/{de-DE-CA3VPcoz.js → de-DE-kDnumQOF.js} +1 -1
  20. package/static/assets/{es-ES-CHvRWwd-.js → es-ES-CqKS7vHl.js} +1 -1
  21. package/static/assets/{fr-FR-CqGOuepx.js → fr-FR-BRcdpT35.js} +1 -1
  22. package/static/assets/getFlagEmoji-DRubsb7D.js +1 -0
  23. package/static/assets/index-Bheo8y3N.css +2 -0
  24. package/static/assets/index-dXN_pYn1.js +16 -0
  25. package/static/assets/{ja-JP-BJSbUSmh.js → ja-JP-C5jk6SuH.js} +1 -1
  26. package/static/assets/{ko-KR-Chzg6jwO.js → ko-KR-z38NtMFa.js} +1 -1
  27. package/static/assets/{ru-RU-CSyCGGPn.js → ru-RU-Bicx52lz.js} +1 -1
  28. package/static/assets/services-BVnEJBDq.js +1 -0
  29. package/static/assets/vendor-i18next-BKUzkAKP.js +1 -0
  30. package/static/assets/vendor-react-BmoHsW1x.js +11 -0
  31. package/static/assets/{vendor-ui-core-sfZn2C08.js → vendor-ui-core-CY_WyMIf.js} +1 -1
  32. package/static/assets/{vendor-utils-CnB7BG7m.js → vendor-utils-BWSB0jGn.js} +1 -1
  33. package/static/assets/{vi-VN-D7rcA1IX.js → vi-VN-CvS_mTAu.js} +1 -1
  34. package/static/assets/{zh-CN-CSPdaOkF.js → zh-CN-B0nRgJTD.js} +1 -1
  35. package/static/assets/{zh-TW-DETA1X3X.js → zh-TW-lc_SSoVI.js} +1 -1
  36. package/static/index.html +6 -6
  37. package/static/sw.js +1 -1
  38. package/static/assets/AccountView-CGRwz6ae.js +0 -4
  39. package/static/assets/AuthView-BQzmEyvO.js +0 -2
  40. package/static/assets/FilteringView-CQ7sX3Rp.js +0 -1
  41. package/static/assets/LogsView-eLfZMRVo.js +0 -5
  42. package/static/assets/SettingsView-agJiYEt5.js +0 -1
  43. package/static/assets/SetupView-CTgCUAgk.js +0 -1
  44. package/static/assets/browser-DPi2BX_1.js +0 -1
  45. package/static/assets/date-IKj2stuv.js +0 -1
  46. package/static/assets/getFlagEmoji-_Wxhq0lT.js +0 -1
  47. package/static/assets/index-919BqnYI.css +0 -2
  48. package/static/assets/index-CbTjGMTZ.js +0 -16
  49. package/static/assets/services-Cwvmit1q.js +0 -1
  50. package/static/assets/vendor-i18next-cO7FDf_e.js +0 -1
  51. package/static/assets/vendor-react-CHk5ngkq.js +0 -11
@@ -0,0 +1,5 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/services-BVnEJBDq.js","assets/index-dXN_pYn1.js","assets/vendor-icons-other-Bme3ywH9.js","assets/vendor-icons-16-BgwRBCeU.js","assets/rolldown-runtime-C4Xdq4VV.js","assets/vendor-icons-20-X5NPN60g.js","assets/vendor-react-BmoHsW1x.js","assets/vendor-ui-core-CY_WyMIf.js","assets/vendor-utils-BWSB0jGn.js","assets/vendor-i18next-BKUzkAKP.js","assets/index-Bheo8y3N.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,Et as n,G as r,H as i,Q as a,Qt as o,V as s,X as c,b as l,gt as u,j as d,lt as f,nt as p,q as m,tt as h,vt as g,xt as _}from"./vendor-react-BmoHsW1x.js";import{S as v,b as y,x as b}from"./vendor-icons-other-Bme3ywH9.js";import{C as x,E as S,L as C,M as w,N as T,O as E,P as D,R as O,S as k,T as A,V as j,a as M,f as N,h as P,l as F,o as I,p as L,r as R,u as z,w as B,x as V,z as H}from"./vendor-ui-core-CY_WyMIf.js";import{_t as U}from"./vendor-utils-BWSB0jGn.js";import{D as W,at as ee,j as G,k as K,ln as te,lt as ne,ot as q,st as re,ut as ie,w as ae,zt as oe}from"./index-dXN_pYn1.js";import{n as se,t as J}from"./formatCountryName-CSBD8pP8.js";import{t as Y}from"./getFlagEmoji-DRubsb7D.js";import{t as ce}from"./SwipeableDrawer-B81ANpsc.js";var X=e(v(),1),Z=e(y(),1);const le=({range:e,setRange:t,customRange:n,setCustomRange:r,nowStr:i,fetchLogs:a,isMobile:s,logRetentionDays:c})=>{let{t:l}=o(),u=[{key:`10m`,days:.007},{key:`1h`,days:.0416},{key:`24h`,days:1},{key:`7d`,days:7},{key:`30d`,days:30}].filter(e=>e.days<=c).map(e=>e.key);return(0,Z.jsx)(`div`,{className:`overflow-x-auto pb-1 -mx-4 px-4 md:mx-0 md:px-0`,children:(0,Z.jsxs)(x,{minimal:s,variant:s?void 0:`minimal`,children:[u.map(n=>(0,Z.jsx)(T,{active:e===n,onClick:()=>t(n),text:n.toUpperCase(),small:s},n)),(0,Z.jsx)(A,{content:(0,Z.jsxs)(`div`,{className:`p-4 space-y-2 w-64`,children:[(0,Z.jsx)(w,{children:l(`analytics.customRange`)}),(0,Z.jsx)(L,{label:l(`analytics.startTime`),children:(0,Z.jsx)(N,{type:`datetime-local`,max:n.end||i,value:n.start,onChange:e=>r({...n,start:e.target.value})})}),(0,Z.jsx)(L,{label:l(`analytics.endTime`),children:(0,Z.jsx)(N,{type:`datetime-local`,min:n.start,max:i,value:n.end,onChange:e=>r({...n,end:e.target.value})})}),(0,Z.jsx)(T,{fill:!0,intent:j.PRIMARY,text:l(`analytics.apply`),onClick:()=>{t(`custom`),a(`custom`,!0)}})]}),children:(0,Z.jsx)(T,{active:e===`custom`,icon:(0,Z.jsx)(g,{size:14}),text:s?``:l(`analytics.custom`),small:s})})]})})},ue=({statusFilter:e,setStatusFilter:t,isMobile:n})=>{let{t:r}=o(),i=(0,Z.jsxs)(S,{children:[(0,Z.jsx)(B,{icon:e===null?`tick`:void 0,text:r(`logs.allStatus`),onClick:()=>t(null)}),(0,Z.jsx)(F,{}),(0,Z.jsx)(B,{icon:e===`PASS`?`tick`:void 0,intent:j.SUCCESS,text:r(`logs.onlyPass`),onClick:()=>t(`PASS`)}),(0,Z.jsx)(B,{icon:e===`BLOCK`?`tick`:void 0,intent:j.DANGER,text:r(`logs.onlyBlock`),onClick:()=>t(`BLOCK`)}),(0,Z.jsx)(B,{icon:e===`REDIRECT`?`tick`:void 0,intent:j.WARNING,text:r(`logs.onlyRedirect`),onClick:()=>t(`REDIRECT`)})]}),a=(()=>{switch(e){case`PASS`:return{text:r(`logs.statusPass`),intent:j.SUCCESS};case`BLOCK`:return{text:r(`logs.statusBlock`),intent:j.DANGER};case`REDIRECT`:return{text:r(`logs.statusRedirect`),intent:j.WARNING};default:return{text:r(`logs.allStatus`),intent:j.NONE}}})();return(0,Z.jsx)(A,{content:i,placement:`bottom-start`,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(p,{size:14}),rightIcon:`caret-down`,intent:a.intent,text:a.text,variant:`outlined`,fill:n})})},de=({accessPointIdFilter:e,setAccessPointIdFilter:t,accessPoints:n,isMobile:i})=>{let{t:a}=o(),s=(0,Z.jsxs)(S,{children:[(0,Z.jsx)(B,{icon:e===null?`tick`:void 0,text:a(`logs.allAccessPoint`),onClick:()=>t(null)}),(0,Z.jsx)(F,{}),n.map(n=>(0,Z.jsx)(B,{icon:e===n.id?`tick`:void 0,text:n.name,onClick:()=>t(n.id)},n.id))]}),c=e&&n.find(t=>t.id===e)?.name||a(`logs.allAccessPoint`);return(0,Z.jsx)(A,{content:s,placement:`bottom-start`,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(r,{size:14}),rightIcon:`caret-down`,intent:e?j.PRIMARY:j.NONE,text:c,variant:`outlined`,fill:i})})},fe=Array.from(new Set(Object.values(se))).sort((e,t)=>e.localeCompare(t)),pe=({destCountryFilter:e,setDestCountryFilter:t,isMobile:n})=>{let{t:r,i18n:i}=o(),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(``),u=(0,X.useMemo)(()=>{let e=i.language;return fe.map(t=>{let n=J(t,e),r=J(t,`en`);return{code:t,name:n||r||t,searchStr:`${t} ${n} ${r}`.toLowerCase()}})},[i.language]),d=(0,X.useMemo)(()=>{let e=c.trim().toLowerCase();return e?u.filter(t=>t.searchStr.includes(e)):u},[u,c]),f=(0,Z.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:r(`logs.searchCountry`,`Search country...`),value:c,onChange:e=>l(e.target.value),small:!0,autoFocus:!0,rightElement:c?(0,Z.jsx)(T,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>l(``)}):void 0})}),(0,Z.jsxs)(S,{className:`max-h-64 overflow-y-auto`,children:[!c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(B,{icon:e===null?`tick`:void 0,text:r(`logs.allCountry`),onClick:()=>{t(null),s(!1)}}),(0,Z.jsx)(F,{})]}),d.length===0?(0,Z.jsx)(B,{disabled:!0,text:r(`logs.noMatchingCountries`,`No matching countries found`)}):d.map(n=>(0,Z.jsx)(B,{icon:e===n.code?`tick`:void 0,text:(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,Z.jsxs)(`span`,{className:`truncate`,children:[Y(n.code),` `,n.name]}),(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:n.code})]}),onClick:()=>{t(n.code),s(!1)}},n.code))]})]}),p=e?`${Y(e)} ${J(e,i.language)||e} (${e})`:r(`logs.allCountry`);return(0,Z.jsx)(A,{content:f,placement:`bottom-start`,isOpen:a,onInteraction:e=>{s(e),e||l(``)},children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(h,{size:14}),rightIcon:`caret-down`,intent:e?j.PRIMARY:j.NONE,text:p,variant:`outlined`,fill:n})})},me=({profileId:e,range:t,customRange:n,destCountryFilter:r,accessPointIdFilter:a,ispFilter:s,setIspFilter:c,isMobile:l})=>{let{t:u}=o(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),y=(0,X.useRef)(``),b=`${e}:${t}:${n.start?Math.floor(new Date(n.start).getTime()/1e3):``}:${n.end?Math.floor(new Date(n.end).getTime()/1e3):``}:${r||``}:${a||``}`,x=async()=>{g(!0);try{let i=Math.floor(Date.now()/1e3),o,s=i,c=new URLSearchParams;if(t===`custom`&&n.start&&n.end)o=Math.floor(new Date(n.start).getTime()/1e3),s=Math.floor(new Date(n.end).getTime()/1e3),c.set(`range`,`custom`),c.set(`start`,String(o)),c.set(`end`,String(s));else{switch(t){case`10m`:o=i-600;break;case`1h`:o=i-3600;break;case`24h`:o=i-86400;break;case`7d`:o=i-604800;break;case`30d`:o=i-2592e3;break;default:o=i-86400;break}c.set(`range`,t)}r&&c.set(`country_code`,r),a&&c.set(`access_point_id`,a);try{let t=await K.queryISPs({profileId:e,countryCode:r||void 0,since:o,until:s,accessPointId:a||void 0});if(t&&t.length>0){m(t),y.current=b,g(!1);return}}catch(e){console.warn(`[IspFilter] Local SQLite query failed, falling back to server:`,e)}let l=await q(e,`isps`,c.toString());m(Array.isArray(l)?l:[]),y.current=b}catch(e){console.error(`Failed to fetch ISPs for filter`,e)}finally{g(!1)}},C=e=>{f(e),e?y.current!==b&&x():v(``)},w=(0,X.useMemo)(()=>{let e=_.trim().toLowerCase();return e?p.filter(t=>t.name.toLowerCase().includes(e)):p},[p,_]),E=(0,Z.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:u(`logs.searchIsp`,`Search ISP...`),value:_,onChange:e=>v(e.target.value),small:!0,autoFocus:!0,rightElement:_?(0,Z.jsx)(T,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>v(``)}):void 0})}),(0,Z.jsx)(S,{className:`max-h-64 overflow-y-auto`,children:h?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-gray-500 gap-2`,children:[(0,Z.jsx)(D,{size:16}),(0,Z.jsx)(`span`,{className:`text-xs`,children:u(`logs.loadingIsps`,`Loading ISPs...`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[!_&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(B,{icon:s===null?`tick`:void 0,text:u(`logs.allIsp`),onClick:()=>{c(null),f(!1)}}),(0,Z.jsx)(F,{})]}),w.length===0?(0,Z.jsx)(B,{disabled:!0,text:u(`logs.noMatchingIsps`,`No matching ISPs found`)}):w.map(e=>(0,Z.jsx)(B,{icon:s===e.name?`tick`:void 0,text:(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,Z.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:e.count.toLocaleString()})]}),onClick:()=>{c(e.name),f(!1)}},e.name))]})})]}),O=s||u(`logs.allIsp`);return(0,Z.jsx)(A,{content:E,placement:`bottom-start`,isOpen:d,onInteraction:C,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(i,{size:14}),rightIcon:`caret-down`,intent:s?j.PRIMARY:j.NONE,text:O,variant:`outlined`,fill:l})})},he=({profileId:e,range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:s,isMobile:c,realtimeRefresh:l,setRealtimeRefresh:u,statusFilter:d,setStatusFilter:f,accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,destCountryFilter:g,setDestCountryFilter:_,ispFilter:v,setIspFilter:y,searchQuery:b,setSearchQuery:x,stats:S,logRetentionDays:C,onExport:w,exporting:E})=>{let{t:D}=o(),[O,k]=(0,X.useState)(!0),A=d!==null||p!==null||g!==null||v!==null;return(0,Z.jsxs)(`div`,{className:`p-4 ${c&&O?`space-y-0`:`space-y-4`} shrink-0 bg-white/50 dark:bg-gray-900/50 backdrop-blur-sm border-b border-gray-100 dark:border-gray-800`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between w-full md:w-auto`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`bp6-heading flex flex-wrap items-center gap-2 text-xl md:text-2xl m-0`,children:[D(`logs.title`),` `,(!c||!O)&&(0,Z.jsx)(R,{minimal:!0,round:!0,children:t===`custom`?D(`analytics.custom`):t.toUpperCase()}),S&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{minimal:!0,round:!0,children:S.total.toLocaleString()}),(0,Z.jsx)(R,{minimal:!0,round:!0,intent:j.SUCCESS,children:S.pass.toLocaleString()}),(0,Z.jsx)(R,{minimal:!0,round:!0,intent:j.DANGER,children:S.block.toLocaleString()}),(0,Z.jsx)(R,{minimal:!0,round:!0,intent:j.WARNING,children:S.redirect.toLocaleString()})]})]}),!c&&(0,Z.jsx)(`p`,{className:`bp6-text-muted mt-1`,children:D(`logs.subtitle`)})]}),c&&(0,Z.jsx)(T,{icon:O?`chevron-down`:`chevron-up`,variant:`minimal`,onClick:()=>k(!O)})]}),(!c||!O)&&(0,Z.jsxs)(`div`,{className:`flex flex-col items-stretch md:items-end gap-2`,children:[(0,Z.jsx)(le,{range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:s,isMobile:c,logRetentionDays:C}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-4`,children:[(0,Z.jsx)(T,{icon:`download`,onClick:w,loading:E,title:D(`logs.export`,`Export Logs`),text:c?void 0:D(`logs.export`,`Export Logs`)}),(0,Z.jsx)(P,{label:D(`logs.realtime`),checked:l,onChange:e=>u(e.target.checked),className:`mb-0!`}),(0,Z.jsx)(T,{icon:`refresh`,onClick:()=>s(t,!0,!1,!0),variant:`minimal`,small:c})]})]})]}),(!c||!O)&&(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 md:flex md:items-center gap-2`,children:[A&&(0,Z.jsx)(`div`,{className:`col-span-2 md:contents`,children:(0,Z.jsx)(T,{icon:`filter-remove`,onClick:()=>{f(null),m(null),_(null),y(null)},variant:`minimal`,title:D(`logs.clearFilters`),text:c?D(`logs.clearFilters`):void 0,fill:c})}),(0,Z.jsx)(ue,{statusFilter:d,setStatusFilter:f,isMobile:c}),h.length>0&&(0,Z.jsx)(de,{accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,isMobile:c}),(0,Z.jsx)(pe,{destCountryFilter:g,setDestCountryFilter:_,isMobile:c}),(0,Z.jsx)(me,{profileId:e,range:t,customRange:r,destCountryFilter:g,accessPointIdFilter:p,ispFilter:v,setIspFilter:y,isMobile:c})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 flex-1 md:max-w-md justify-end`,children:(0,Z.jsx)(`div`,{className:`flex-1 md:max-w-xs`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:D(`logs.searchPlaceholder`),value:b,onChange:e=>x(e.target.value),rightElement:b?(0,Z.jsx)(T,{icon:`cross`,minimal:!0,onClick:()=>x(``)}):void 0,fill:!0})})})]})]})},ge=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>{let{t:s}=o();return(0,Z.jsx)(`div`,{className:`space-y-3 py-4`,children:e.map((o,l)=>{let u=a&&i!==null&&o.timestamp>i,d=(o.encrypt_version??0)>0||!!(o.kem_key_id||o.encrypted_payload),f=d&&(!o.domain||o.domain===`[Encrypted]`),p=d&&!!(o.domain&&o.domain!==`[Encrypted]`);return(0,Z.jsxs)(V,{interactive:!0,onClick:()=>{t(o),n(!0)},className:U(`p-3 dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-hidden`,{"animate-row-glow":u}),ref:l===e.length-1?r:null,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-start mb-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f?(0,Z.jsx)(c,{size:14,className:`text-amber-500 shrink-0`}):(0,Z.jsx)(`img`,{src:`/api/icon/${o.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm shrink-0`,alt:``,referrerPolicy:`no-referrer`,onError:e=>e.currentTarget.style.opacity=`0`}),(0,Z.jsx)(`span`,{className:U(`font-bold text-sm truncate`,{"italic text-gray-400 dark:text-gray-500":f}),children:f?s(`logs.encryptedRecord`,`[加密记录]`):o.domain}),p&&(0,Z.jsx)(c,{size:12,className:`text-emerald-500 shrink-0 opacity-80`})]}),(0,Z.jsx)(R,{minimal:!0,round:!0,intent:o.action===`PASS`?j.SUCCESS:o.action===`BLOCK`?j.DANGER:j.WARNING,className:`text-[10px] shrink-0`,children:o.action})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-mono opacity-50`,children:new Date(o.timestamp*1e3).toLocaleTimeString([],{hour12:!1})}),(0,Z.jsx)(`span`,{className:`text-[10px] bg-gray-100 dark:bg-gray-800 px-1 rounded opacity-60`,children:o.record_type}),o.access_point_name&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-50 truncate max-w-25`,children:o.access_point_name})]}),(0,Z.jsx)(`div`,{className:`text-[10px] opacity-40 font-mono italic`,children:o.latency?`${o.latency}ms`:``})]})]},o.id)})})},_e=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>{let{t:s}=o(),l=[{key:`time`,header:s(`logs.tableTime`),headerClassName:`w-24 rounded-tl-xl`,cellClassName:`font-mono text-[11px] opacity-60`,render:e=>new Date(e.timestamp*1e3).toLocaleTimeString([],{hour12:!1})},{key:`domain`,header:s(`logs.tableDomain`),headerClassName:`w-1/4`,render:e=>{let t=(e.encrypt_version??0)>0||!!(e.kem_key_id||e.encrypted_payload),n=t&&(!e.domain||e.domain===`[Encrypted]`),r=t&&!!(e.domain&&e.domain!==`[Encrypted]`);return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[n?(0,Z.jsx)(c,{size:14,className:`text-amber-500 shrink-0`}):(0,Z.jsx)(`img`,{src:`/api/icon/${e.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm shrink-0`,alt:``,referrerPolicy:`no-referrer`}),(0,Z.jsx)(`span`,{className:U(`font-bold text-sm truncate`,{"italic text-gray-400 dark:text-gray-500":n}),children:n?s(`logs.encryptedRecord`,`[加密记录]`):e.domain}),r&&(0,Z.jsx)(`span`,{title:s(`settings.e2eeEnabled`,`已加密`),className:`inline-flex items-center`,children:(0,Z.jsx)(c,{size:12,className:`text-emerald-500 shrink-0 opacity-80`})})]})}},{key:`answer`,header:s(`logs.tableAnswer`),headerClassName:`w-1/4`,cellClassName:`truncate font-mono text-[11px] opacity-70`,render:e=>e.answer||`-`},{key:`source`,header:s(`logs.tableSource`),headerClassName:`w-32`,render:e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{minimal:!0,className:`font-mono text-[10px]`,title:e.geo_country||`Unknown`,children:Y(e.geo_country)}),e.access_point_name&&(0,Z.jsx)(`span`,{className:`text-xs opacity-70 truncate max-w-20`,title:e.access_point_name,children:e.access_point_name})]})},{key:`type`,header:s(`logs.tableType`),headerClassName:`w-20`,cellClassName:`text-center`,render:e=>(0,Z.jsx)(`code`,{className:`text-[10px]`,children:e.record_type})},{key:`status`,header:s(`logs.tableStatus`),headerClassName:`w-28`,cellClassName:`text-center`,render:e=>(0,Z.jsx)(`span`,{className:U(`bp6-tag`,`bp6-fill`,`bp6-minimal`,`bp6-round`,{"bp6-intent-success":e.action===`PASS`,"bp6-intent-danger":e.action===`BLOCK`,"bp6-intent-warning":e.action===`REDIRECT`}),children:(0,Z.jsx)(`span`,{className:`bp6-text-overflow-ellipsis bp6-fill text-center`,children:e.action})})},{key:`reason`,header:s(`logs.tableReason`),headerClassName:`rounded-tr-xl`,cellClassName:`text-xs text-gray-500 italic truncate`,render:e=>e.reason||`-`}];return(0,Z.jsx)(`div`,{className:`min-w-full inline-block align-middle py-0`,children:(0,Z.jsx)(`div`,{className:`bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-visible`,children:(0,Z.jsxs)(z,{interactive:!0,striped:!0,className:`w-full table-fixed`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 z-20 backdrop-blur-md`,children:(0,Z.jsx)(`tr`,{children:l.map(e=>(0,Z.jsx)(`th`,{className:U(`px-4 py-3 text-xs font-bold uppercase text-gray-500 bg-white/80 dark:bg-gray-900/80 border-b border-gray-100 dark:border-gray-800`,e.headerClassName),children:e.header},e.key))})}),(0,Z.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.map((o,s)=>{let c=a&&i!==null&&o.timestamp>i;return(0,Z.jsx)(`tr`,{onClick:()=>{t(o),n(!0)},className:U(`cursor-pointer`,{"animate-row-glow":c}),ref:s===e.length-1?r:null,children:l.map(e=>(0,Z.jsx)(`td`,{className:U(`px-4 py-3`,e.cellClassName),children:e.render(o,s)},e.key))},o.id)})})]})})})},ve=({logs:e,loading:t,loadingMore:n,hasMore:r,realtimeRefresh:i,isMobile:a,searchQuery:s,scrollContainerRef:c,lastLogElementRef:l,prevLatestTimestamp:u,setSelectedLog:d,setIsDrawerOpen:f,logRetentionDays:p})=>{let{t:m}=o();return(0,Z.jsxs)(`div`,{ref:c,className:U(`flex-1 overflow-y-auto relative`,a?`px-1`:`px-4`),children:[e.length===0&&!t?(0,Z.jsx)(`div`,{className:`py-20`,children:(0,Z.jsx)(k,{title:p===0?m(`logs.loggingDisabledTitle`,`日志记录已关闭`):m(s?`logs.noResults`:`logs.noRecords`),icon:p===0?`disable`:s?`search`:`outdated`,intent:p===0?j.WARNING:j.NONE,children:p===0?m(`logs.loggingDisabledDesc`,`当前配置的日志留存已设置为“关闭”,系统不记录任何查询日志。如需查看,请在设置中启用日志留存。`):s?m(`logs.noResultsDesc`,{query:s}):m(`logs.noRecordsDesc`)})}):a?(0,Z.jsx)(ge,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}):(0,Z.jsx)(_e,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}),(0,Z.jsx)(`div`,{className:`p-6 flex flex-col items-center`,children:n?(0,Z.jsx)(D,{size:16}):i?e.length>0&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.realtimeLoadMoreTip`)}):!r&&e.length>0&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.loadedAll`,{count:e.length})})})]})};function ye(e,t,n){let[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(e&&t?.id){o(!0),i(t);let e=new AbortController;return ne(n,t.id,t.timestamp,{signal:e.signal}).then(async r=>{if(!e.signal.aborted)try{let e=r?.encrypt_version??t.encrypt_version,a=await G.decryptLogEntry(n,r);i(n=>({...n||t,...a,encrypt_version:e??a.encrypt_version}))}catch{i(e=>({...e||t,...r}))}}).catch(e=>{e.name!==`AbortError`&&(console.error(e),i(e=>e||t))}).finally(()=>{e.signal.aborted||o(!1)}),()=>{e.abort()}}else i(null)},[e,t?.id,n]),{detailedLog:r,loading:a}}const Q=({label:e,value:t,bold:n,italic:r})=>(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:e}),(0,Z.jsx)(`span`,{className:U(`text-sm text-right`,n&&`font-bold`,r&&`italic`),children:t})]}),be=({selectedLog:e,detailedLog:t,loading:r})=>{let{t:i}=o(),a=t?.encrypt_version??e.encrypt_version??(t?.kem_key_id||e.kem_key_id?2:0),s=a>0||!!(e.kem_key_id||e.encrypted_payload||t?.kem_key_id||t?.encrypted_payload),l=a===2||!!(e.kem_key_id||t?.kem_key_id),u=s&&(!e.domain||e.domain===`[Encrypted]`);return(0,Z.jsx)(I,{title:i(`logs.basicInfo`),icon:(0,Z.jsx)(n,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Q,{label:i(`logs.detailDomain`),value:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-end font-bold`,children:[u?(0,Z.jsx)(c,{size:14,className:`text-amber-500`}):(0,Z.jsx)(`img`,{src:`/api/icon/${e.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm`,alt:``,referrerPolicy:`no-referrer`,onError:e=>e.currentTarget.style.display=`none`}),(0,Z.jsx)(`span`,{className:U({"italic text-gray-400 dark:text-gray-500":u}),children:u?i(`logs.encryptedRecord`,`[加密记录]`):e.domain})]}),bold:!0}),(0,Z.jsx)(Q,{label:i(`logs.detailType`),value:e.record_type}),(0,Z.jsx)(Q,{label:i(`logs.detailLatency`),value:e.latency?`${e.latency} ms`:`-`}),(0,Z.jsx)(Q,{label:i(`logs.detailAccessPoint`),value:(()=>{let n=t?.access_point_name||e.access_point_name,i=t?.access_point_id||e.access_point_id;return n?i&&i!==n?(0,Z.jsx)(`span`,{title:i,className:`cursor-help`,children:n}):n:i?(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:i}):r?(0,Z.jsx)(D,{size:12}):`-`})()}),(0,Z.jsx)(Q,{label:i(`logs.detailProfile`),value:t?.profile_name||t?.client_ip||e.client_ip||(r?(0,Z.jsx)(D,{size:12}):`-`)}),(0,Z.jsx)(Q,{label:i(`logs.detailTime`),value:ae(new Date(e.timestamp*1e3))}),(0,Z.jsx)(Q,{label:i(`logs.detailStatus`),value:(0,Z.jsx)(R,{minimal:!0,intent:e.action===`PASS`?j.SUCCESS:e.action===`BLOCK`?j.DANGER:j.WARNING,children:e.action})}),(0,Z.jsx)(Q,{label:i(`logs.detailUpstream`),value:t?.upstream||e.upstream||(r?(0,Z.jsx)(D,{size:12}):`-`)}),(0,Z.jsx)(Q,{label:i(`logs.detailReason`),value:e.reason||i(`logs.detailNoReason`),italic:!0}),(0,Z.jsx)(Q,{label:i(`logs.detailECS`),value:t?.ecs||e.ecs||(r?(0,Z.jsx)(D,{size:12}):`-`),italic:!0}),(0,Z.jsx)(Q,{label:i(`logs.detailIsClientEncrypted`,`是否用户端加密`),value:s?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 justify-end`,children:[(0,Z.jsx)(c,{size:13,className:u?`text-amber-500`:`text-emerald-500`}),(0,Z.jsxs)(`span`,{className:U(`text-xs font-medium`,u?`text-amber-600 dark:text-amber-400`:`text-emerald-600 dark:text-emerald-400`),children:[u?i(`logs.encryptedLocked`,`是 (未解锁)`):i(`logs.encryptedYes`,`是`),l?` (PQC)`:``]})]}):(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:i(`logs.notEncrypted`,`否`)})})]})})})},xe=({selectedLog:e})=>{let{t}=o(),n=e.record_type===`HTTPS`||e.record_type===`SVCB`||e.record_type===`TYPE65`||e.record_type===`TYPE64`,r=n&&(e.reason===`ECH Rewritten`||(e.reason?.toLowerCase().includes(`rewritten`)??!1));return(0,Z.jsx)(I,{title:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between w-full pr-2`,children:[(0,Z.jsx)(`span`,{children:t(`logs.resolutionResult`)}),r&&(0,Z.jsx)(R,{minimal:!0,intent:j.PRIMARY,className:`text-xs`,children:t(`logs.rewritten`,`已重写`)})]}),icon:(0,Z.jsx)(h,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-3 font-mono text-xs break-all leading-relaxed rounded-lg`,children:(()=>{if(!e.answer)return t(`logs.noResult`);let r=e.answer.split(`
3
+ `).map(e=>e.trim()).filter(Boolean);return r.length===0?t(`logs.noResult`):(0,Z.jsx)(`div`,{className:`space-y-2`,children:r.map((e,t)=>{let r=e.match(/^(\d+)\s+([^\s]+)(?:\s+(.*))?$/);if(r&&(n||e.includes(`alpn=`)||e.includes(`ech=`)||e.includes(`ipv4hint=`))){let e=r[1],n=r[2],i=(r[3]||``).split(/\s+/).filter(Boolean);return(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-2.5 rounded-md space-y-2 border border-gray-200 dark:border-gray-700`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(R,{minimal:!0,intent:j.PRIMARY,children:[`Priority `,e]}),(0,Z.jsxs)(`span`,{className:`font-semibold text-gray-700 dark:text-gray-300`,children:[`Target: `,n]})]}),i.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1 border-t border-gray-100 dark:border-gray-800 text-xs`,children:i.map((e,t)=>{let n=e.indexOf(`=`);if(n===-1)return(0,Z.jsx)(R,{minimal:!0,className:`font-mono`,children:e},t);let r=e.substring(0,n),i=e.substring(n+1);return r===`ech`?(0,Z.jsxs)(R,{minimal:!0,intent:j.SUCCESS,className:`font-mono break-all max-w-full select-all text-left whitespace-normal h-auto py-1 inline-block`,title:i,children:[(0,Z.jsx)(`span`,{className:`font-bold`,children:`ech:`}),` `,i]},t):r===`alpn`?(0,Z.jsxs)(R,{minimal:!0,intent:j.WARNING,className:`font-mono`,children:[(0,Z.jsx)(`span`,{className:`font-bold`,children:`alpn:`}),` `,i]},t):(0,Z.jsxs)(R,{minimal:!0,className:`font-mono`,children:[(0,Z.jsxs)(`span`,{className:`font-bold`,children:[r,`:`]}),` `,i]},t)})})]},t)}return(0,Z.jsx)(`div`,{className:`space-y-1`,children:e.split(`,`).map(e=>e.trim()).filter(Boolean).map((e,t)=>(0,Z.jsx)(`div`,{className:`text-xs font-mono text-gray-800 dark:text-gray-200 select-all`,children:e},t))},t)})})})()})})})},Se=({selectedLog:e,detailedLog:t,loading:n})=>{let{t:r,i18n:i}=o(),a=t?.client_ip||e.client_ip,s=t?.geo_country||e.geo_country,c=`Unknown`;if(s){let e=s.toUpperCase().trim();c=e===`LAN`||e===`LOCAL`||e===`PRIVATE`||e===`PRIVATE NETWORK`?r(`setup.privateNetwork`,`Private Network`):e===`UN`||e===`UNKNOWN`||e===`XX`?r(`common.unknown`,`Unknown`):J(s,i.language)||s}let u=t?.dest_country_code||e.dest_country_code,d=t?.dest_country||e.dest_country,f=t?.dest_isp||e.dest_isp,p=null,h=t?.dest_geoip||e.dest_geoip;if(h)try{let e=JSON.parse(h);!u&&e.country_code&&(u=e.country_code);let t=[e.city,e.region,e.country].filter(Boolean),n=d||u||void 0;p={locationTitle:t.length>0?t.join(`, `):n,isp:e.isp||f||void 0,as:e.as||void 0}}catch{}return!p&&(d||u||f)&&(p={locationTitle:d||u||void 0,isp:f||void 0}),(0,Z.jsx)(I,{title:r(`logs.networkDetails`),icon:(0,Z.jsx)(l,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50 mb-1`,children:r(`logs.clientSource`)}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:a||(n?(0,Z.jsx)(D,{size:12}):`-`)}),(s||n)&&(0,Z.jsx)(R,{minimal:!0,title:c,children:s?Y(s):`-`})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50`,children:r(`logs.destination`)}),(u||n)&&(0,Z.jsx)(R,{minimal:!0,title:d||u||`Unknown`,children:u?Y(u):`-`})]}),n&&!p?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Z.jsx)(D,{size:16})}):p?(0,Z.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-3 rounded-lg mt-1`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(m,{size:16,className:`oklch(60.9% 0.126 221.723) mt-1 shrink-0`}),(0,Z.jsxs)(`div`,{children:[p.locationTitle&&(0,Z.jsx)(`div`,{className:`font-bold text-sm`,children:p.locationTitle}),(p.isp||p.as)&&(0,Z.jsxs)(`div`,{className:`text-xs opacity-70 mt-1`,children:[p.isp,p.as&&(0,Z.jsx)(`span`,{className:`opacity-60 block mt-0.5`,children:p.as})]})]})]})}):(0,Z.jsx)(`div`,{className:`text-xs opacity-50 py-1`,children:`-`})]})]})})})},Ce=({selectedLog:e,onQuickAction:n})=>{let{t:r}=o(),i=(e.encrypt_version??0)>0&&(!e.domain||e.domain===`[Encrypted]`);return(0,Z.jsx)(I,{title:r(`logs.quickActions`),icon:(0,Z.jsx)(s,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:i?(0,Z.jsx)(`p`,{className:`text-xs text-center text-gray-500 italic py-2 m-0`,children:r(`settings.e2eeUnlockPrompt`,`此记录已加密,请先解锁私钥后再进行操作。`)}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(T,{fill:!0,intent:j.SUCCESS,icon:(0,Z.jsx)(t,{size:16}),text:r(`logs.actionAllow`),onClick:()=>n?.(e.domain,`ALLOW`)}),(0,Z.jsx)(T,{fill:!0,intent:j.DANGER,icon:(0,Z.jsx)(d,{size:16}),text:r(`logs.actionBlock`),onClick:()=>n?.(e.domain,`BLOCK`)}),(0,Z.jsx)(T,{fill:!0,icon:(0,Z.jsx)(_,{size:16}),text:r(`logs.actionRedirect`),onClick:()=>n?.(e.domain,`REDIRECT`,e.record_type)})]})})})},we=({isDrawerOpen:e,setIsDrawerOpen:t,selectedLog:r,profileId:i,isMobile:a,onQuickAction:s})=>{let{t:c}=o(),{detailedLog:l,loading:u}=ye(e,r,i);return(0,Z.jsx)(ce,{isOpen:e&&r!==null,onClose:()=>t(!1),title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(n,{size:18}),(0,Z.jsx)(`span`,{children:c(`logs.logDetails`)})]}),icon:`info-sign`,size:a?`100%`:`450px`,children:r&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(be,{selectedLog:r,detailedLog:l,loading:u}),(0,Z.jsx)(xe,{selectedLog:r}),(0,Z.jsx)(Se,{selectedLog:r,detailedLog:l,loading:u}),(0,Z.jsx)(Ce,{selectedLog:r,onQuickAction:s})]})})},Te=({isMobile:e,unlocking:t,onUnlockPasskey:n,onOpenRecoveryDialog:r})=>{let{t:i}=o();return(0,Z.jsx)(`div`,{className:U(`mb-2 shrink-0`,e?`px-2`:`px-4`),children:(0,Z.jsx)(k,{intent:j.PRIMARY,icon:`lock`,title:i(`settings.e2eeTitle`,`端到端加密日志`),children:(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 mt-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs opacity-80 m-0`,children:i(`settings.e2eeUnlockPrompt`,`日志已通过端到端加密保护。请验证已授权的硬件 Passkey 或输入紧急恢复密钥以在本地解密。`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap shrink-0`,children:[(0,Z.jsx)(T,{intent:j.PRIMARY,icon:`key`,small:!0,loading:t,onClick:n,className:`font-medium`,children:i(`settings.e2eeUnlockNow`,`验证 Passkey 解锁`)}),(0,Z.jsx)(T,{intent:j.NONE,icon:(0,Z.jsx)(a,{size:14}),small:!0,disabled:t,onClick:r,className:`font-medium`,children:i(`settings.e2eeUnlockRecovery`,`使用恢复密钥解锁`)})]})]})})})},Ee=({isOpen:e,onClose:t,recoveryKeyInput:n,setRecoveryKeyInput:r,recoveryError:i,unlocking:a,onSubmit:s})=>{let{t:c}=o();return(0,Z.jsx)(E,{isOpen:e,onClose:t,title:c(`account.e2ee.unlockWithRecoveryTitle`,`使用恢复密钥解锁`),icon:`key`,className:`dark:bg-gray-900`,children:(0,Z.jsxs)(`form`,{onSubmit:s,autoComplete:`off`,children:[(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:c(`account.e2ee.unlockWithRecoveryDesc`,`请输入 30 位紧急恢复密钥。注意:根据单次使用规则,恢复密钥验证成功后将立即自动轮换。`)}),i&&(0,Z.jsx)(k,{intent:j.DANGER,className:`mb-3 text-xs`,children:i}),(0,Z.jsx)(L,{label:c(`account.e2ee.recoveryKeyInputLabel`,`恢复密钥`),labelFor:`recovery-key-input-logs`,children:(0,Z.jsx)(N,{id:`recovery-key-input-logs`,name:`recovery_key_input_logs`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-bwignore":`true`,placeholder:`123456-789012-345678-901234-567890`,value:n,onChange:e=>r(e.target.value),leftIcon:`key`,className:`font-mono text-xs`,autoFocus:!0})})]}),(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsxs)(`div`,{className:H,children:[(0,Z.jsx)(T,{onClick:t,text:c(`common.cancel`,`取消`)}),(0,Z.jsx)(T,{type:`submit`,intent:j.PRIMARY,loading:a,disabled:!n.trim(),text:c(`account.e2ee.unlockConfirm`,`解锁日志`)})]})})]})})},De=({rotatedKey:e,onClose:t,copiedKey:n,onCopyKey:r})=>{let{t:i}=o();return(0,Z.jsxs)(E,{isOpen:!!e,onClose:t,title:i(`account.recoveryKey.autoRotatedTitle`,`恢复密钥已自动轮换`),icon:`warning-sign`,isCloseButtonShown:!1,canOutsideClickClose:!1,className:`dark:bg-gray-900`,children:[(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(k,{intent:j.WARNING,icon:(0,Z.jsx)(d,{size:16}),className:`mb-4 text-xs`,children:i(`account.recoveryKey.autoRotatedNotice`,`根据恢复密钥单次使用规则,您的原恢复密钥已失效,系统已为您生成全新 30 位紧急恢复密钥。请务必立即复制并妥善离线保存,关闭后将无法再次查看!`)}),e&&(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`p-3 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 font-mono text-center text-lg font-bold tracking-widest select-all text-gray-900 dark:text-gray-100`,children:e}),(0,Z.jsx)(`div`,{className:`flex justify-center`,children:(0,Z.jsx)(T,{intent:j.PRIMARY,icon:n?(0,Z.jsx)(u,{size:14,className:`text-green-400`}):(0,Z.jsx)(f,{size:14}),text:n?i(`common.copied`,`已复制`):i(`common.copyKey`,`复制新恢复密钥`),onClick:()=>r(e)})})]})]}),(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(`div`,{className:H,children:(0,Z.jsx)(T,{intent:j.SUCCESS,onClick:t,text:i(`account.recoveryKey.savedAndClose`,`我已妥善保存并继续`)})})})]})};function Oe(e){let[t,n]=(0,X.useState)(`24h`),[r,i]=(0,X.useState)({start:``,end:``}),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``);return(0,X.useEffect)(()=>{ee(e).then(u).catch(console.error)},[e]),(0,X.useEffect)(()=>{m(null)},[d]),{range:t,setRange:n,customRange:r,setCustomRange:i,statusFilter:a,setStatusFilter:o,accessPointIdFilter:s,setAccessPointIdFilter:c,accessPoints:l,destCountryFilter:d,setDestCountryFilter:f,ispFilter:p,setIspFilter:m,searchQuery:h,setSearchQuery:g}}function ke(e){let[t,n]=(0,X.useState)(30);return(0,X.useEffect)(()=>{re(e).then(e=>{try{let t=JSON.parse(e.settings||`{}`);n(t.log_retention_days===void 0?30:Number(t.log_retention_days))}catch(e){console.error(`[useProfileRetention] Failed to parse settings:`,e)}}).catch(e=>console.error(`[useProfileRetention] Failed to fetch profile details:`,e))},[e]),t}function Ae(e,t){let n=Math.floor(Date.now()/1e3);if(e===`custom`&&t.start&&t.end)return{since:Math.floor(new Date(t.start).getTime()/1e3),until:Math.floor(new Date(t.end).getTime()/1e3)};let r;switch(e){case`10m`:r=n-600;break;case`1h`:r=n-3600;break;case`24h`:r=n-86400;break;case`7d`:r=n-604800;break;case`30d`:r=n-2592e3;break;default:r=n-86400;break}return{since:r,until:n}}function je({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c}){let[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(!0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!0),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),x=(0,X.useRef)([]);(0,X.useEffect)(()=>{x.current=l},[l]);let S=(0,X.useRef)(null),C=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{S.current&&S.current.abort()},[]),{logs:l,setLogs:u,loading:d,loadingMore:p,hasMore:h,setHasMore:g,stats:_,setStats:v,prevLatestTimestamp:y,setPrevLatestTimestamp:b,fetchLogs:(0,X.useCallback)(async(t,l=!0,d=!1,p=!1)=>{S.current&&S.current.abort();let h=new AbortController;S.current=h,C.current=!0,l?f(!0):m(!0);try{let _=c?25:50,{since:y,until:w}=Ae(t,n),T=!1;try{if(await K.init()&&!h.signal.aborted){let t=!l&&x.current.length>0?x.current[x.current.length-1].timestamp:void 0;if(l){let t=await K.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:void 0,limit:_,offset:0});if(h.signal.aborted)return;t.rows.length>0&&(T=!0,b(d&&x.current.length>0?x.current[0].timestamp:null),u(t.rows),g(c?!1:t.rows.length>=_),c&&t.rows.length>0&&W.updateCursor(t.rows[0].timestamp,t.rows[0].id),t.stats&&v(t.stats),f(!1));try{let n=await K.syncProfileLogs(e,void 0,y,h.signal,p);if(!h.signal.aborted&&(n>0||t.rows.length===0)){if(t=await K.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:void 0,limit:_,offset:0}),h.signal.aborted)return;T=!0,b(d&&x.current.length>0?x.current[0].timestamp:null),u(t.rows),g(c?!1:t.rows.length>=_),c&&t.rows.length>0&&W.updateCursor(t.rows[0].timestamp,t.rows[0].id),t.stats&&v(t.stats)}else !h.signal.aborted&&t.rows.length>0&&(T=!0)}catch(e){e.name!==`AbortError`&&console.warn(`[useLogsFetcher] Incremental sync error:`,e)}}else if(t!==void 0){let n=await K.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:t,limit:_,offset:0});if(h.signal.aborted)return;if(n.rows.length>=_)T=!0,u(e=>[...e,...n.rows]),g(c?!1:n.rows.length>=_);else if(t>y)try{let l=await K.backfillLogs(e,t,y,_,h.signal);if(h.signal.aborted)return;if(T=!0,l.length>0){let n=await K.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:t,limit:_,offset:0});if(h.signal.aborted)return;u(e=>[...e,...n.rows]),g(c?!1:n.rows.length>=_&&l.length>=_)}else n.rows.length>0&&u(e=>[...e,...n.rows]),g(!1)}catch(e){e.name!==`AbortError`&&console.warn(`[useLogsFetcher] Backfill error:`,e),n.rows.length>0&&u(e=>[...e,...n.rows]),T=!0,g(!1)}else T=!0,n.rows.length>0&&u(e=>[...e,...n.rows]),g(!1)}else T=!0,g(!1);if(T&&x.current.length>0){let e=Array.from(new Set(x.current.map(e=>e.domain)));`serviceWorker`in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:`PREFETCH_ICONS`,domains:e})}}}catch(e){console.warn(`[useLogsFetcher] Local SQLite failed, falling back to server:`,e),T=!1}if(T){S.current===h&&(f(!1),m(!1),C.current=!1);return}let E=new URLSearchParams({range:t,limit:String(_)});t===`custom`&&n.start&&n.end&&(E.set(`start`,String(y)),E.set(`end`,String(w))),r&&E.set(`status`,r),i&&E.set(`access_point_id`,i),a&&E.set(`dest_country`,a),o&&E.set(`isp`,o),s&&E.set(`search`,s),!l&&x.current.length>0&&E.set(`before`,String(x.current[x.current.length-1].timestamp));let D=ie(e,E.toString(),{signal:h.signal}),O=Promise.resolve(null);if(l){let r=new URLSearchParams({range:t});t===`custom`&&n.start&&n.end&&(r.set(`start`,String(y)),r.set(`end`,String(w))),s&&r.set(`search`,s),O=q(e,`summary`,r.toString(),{signal:h.signal})}let[k,A]=await Promise.all([D,O]);if(l){if(b(d&&x.current.length>0?x.current[0].timestamp:null),u(k),g(c?!1:k.length>=_),A){let e={total:0,pass:0,block:0,redirect:0};A.forEach(t=>{let n=t.count;e.total+=n,t.action===`PASS`?e.pass=n:t.action===`BLOCK`?e.block=n:t.action===`REDIRECT`&&(e.redirect=n)}),v(e)}}else u(e=>[...e,...k]),g(c?!1:k.length>=_);if(k&&k.length>0){c&&W.updateCursor(k[0].timestamp,k[0].id);let e=Array.from(new Set(k.map(e=>e.domain)));`serviceWorker`in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:`PREFETCH_ICONS`,domains:e})}}catch(e){e.name!==`AbortError`&&console.error(e)}finally{S.current===h&&(f(!1),m(!1),C.current=!1)}},[e,c,n,s,r,i,a,o]),isFetchingRef:C,logsRef:x}}function Me({realtimeRefresh:e,statusFilter:t,accessPointIdFilter:n,destCountryFilter:r,ispFilter:i,searchQuery:a,pageSize:o,logsRef:s,setLogs:c,setStats:l,setPrevLatestTimestamp:u}){(0,X.useEffect)(()=>{if(e)return W.onNewLogs(e=>{if(!e||e.length===0)return;let d=e.filter(e=>{if(t&&e.action!==t||n&&e.access_point_id!==n||r&&(e.dest_country_code||e.dest_country)!==r||i&&e.dest_isp!==i)return!1;if(a){let t=a.toLowerCase(),n=e.domain?.toLowerCase().includes(t),r=e.client_ip?.toLowerCase().includes(t),i=e.reason?.toLowerCase().includes(t);if(!n&&!r&&!i)return!1}return!0});d.length!==0&&(u(s.current.length>0?s.current[0].timestamp:null),c(e=>{let t=new Set(e.map(e=>`${e.timestamp}-${e.id}`)),n=d.filter(e=>!t.has(`${e.timestamp}-${e.id}`));return n.length===0?e:[...n,...e].slice(0,o)}),l(t=>{if(!t)return t;let n=0,r=0,i=0;for(let t of e)t.action===`PASS`?n++:t.action===`BLOCK`?r++:t.action===`REDIRECT`&&i++;return{total:t.total+e.length,pass:t.pass+n,block:t.block+r,redirect:t.redirect+i}}))})},[e,t,n,r,i,a,o,s,c,l,u])}function Ne({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c}){let l=ke(e),{logs:u,setLogs:d,loading:f,loadingMore:p,hasMore:m,stats:h,setStats:g,prevLatestTimestamp:_,setPrevLatestTimestamp:v,fetchLogs:y,isFetchingRef:b,logsRef:x}=je({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c});Me({realtimeRefresh:c,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,pageSize:25,logsRef:x,setLogs:d,setStats:g,setPrevLatestTimestamp:v});let S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useCallback)(()=>{c||b.current||f||p||!m||y(t,!1)},[f,p,m,t,c,y,b]),T=(0,X.useCallback)(e=>{C.current&&C.current.disconnect(),!(f||p||c||!m)&&(C.current=new IntersectionObserver(e=>{e[0]?.isIntersecting&&m&&!b.current&&w()},{root:S.current,rootMargin:`100px`}),e&&C.current.observe(e))},[f,p,m,w,c,b]);return(0,X.useEffect)(()=>{if(t===`custom`&&(!n.start||!n.end))return;let e=setTimeout(()=>{y(t,!0)},s?500:0);return()=>clearTimeout(e)},[t,n.start,n.end,s,y]),{logs:u,loading:f,loadingMore:p,hasMore:m,stats:h,logRetentionDays:l,prevLatestTimestamp:_,scrollContainerRef:S,lastLogElementRef:T,fetchLogs:y,isFetchingRef:b,logsRef:x}}function Pe({profileId:e,range:t,searchQuery:n,realtimeRefresh:r,scrollContainerRef:i,isFetchingRef:a,fetchLogs:o,logsRef:s}){let c=(0,X.useRef)({range:t,searchQuery:n,fetchLogs:o,logsRef:s});(0,X.useEffect)(()=>{c.current={range:t,searchQuery:n,fetchLogs:o,logsRef:s}}),(0,X.useEffect)(()=>{if(!r){W.disconnect();return}let t=!1,n=null,o=()=>{n||=setInterval(()=>{let{range:e,searchQuery:n,fetchLogs:r}=c.current;!t&&document.visibilityState===`visible`&&i.current&&i.current.scrollTop<50&&!a.current&&!n&&e!==`custom`&&r(e,!0,!0)},8e3)},s=()=>{n&&=(clearInterval(n),null)},l=W.onStatusChange(e=>{t=e,e?s():o()}),u=c.current.logsRef.current,d=u.length>0?u[0]:null,f=d?d.timestamp:Math.floor(Date.now()/1e3)-60,p=d?d.id:0;W.connect(e,f,p);let m=setTimeout(()=>{t||o()},2500),h=()=>{if(document.visibilityState===`visible`)if(t){let e=c.current.logsRef.current,t=e.length>0?e[0]:null;t&&W.updateCursor(t.timestamp,t.id)}else{let{range:e,fetchLogs:t}=c.current;t(e,!0,!0)}};return document.addEventListener(`visibilitychange`,h),()=>{clearTimeout(m),s(),l(),W.disconnect(),document.removeEventListener(`visibilitychange`,h)}},[e,r])}function $(e){let t=new Date(e*1e3),n=-t.getTimezoneOffset(),r=n>=0?`+`:`-`,i=e=>String(e).padStart(2,`0`);return t.getFullYear()+`-`+i(t.getMonth()+1)+`-`+i(t.getDate())+`T`+i(t.getHours())+`:`+i(t.getMinutes())+`:`+i(t.getSeconds())+`.`+(e=>String(e).padStart(3,`0`))(t.getMilliseconds())+(n===0?`Z`:r+i(Math.floor(Math.abs(n)/60))+`:`+i(Math.abs(n)%60))}function Fe(e){let t=[`profile_id`,`access_point_id`,`time`,`client_ip`,`geo_country`,`domain`,`record_type`,`action`,`reason`,`answer`,`dest_geoip`,`ecs`,`upstream`,`latency`],n=[t.join(`,`)];for(let r of e){let e=t.map(e=>{let t=``;t=e===`time`?$(r.timestamp):r[e]!==null&&r[e]!==void 0?String(r[e]):``;let n=t.replace(/"/g,`""`);return n.includes(`,`)||n.includes(`
4
+ `)||n.includes(`\r`)||n.includes(`"`)?`"${n}"`:n});n.push(e.join(`,`))}return n.join(`
5
+ `)}function Ie(e,t){let n=new Blob([e],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.setAttribute(`href`,r),i.setAttribute(`download`,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function Le(e,t,n,r){return`query_logs_${e}_${$(t)}_${$(n)}_${r.toString()}.csv`}function Re({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:s,searchQuery:c,toasterRef:l}){let{t:u}=o(),[d,f]=(0,X.useState)(!1);return{exporting:d,handleExportLogs:async()=>{f(!0);try{let o=new URLSearchParams({range:t});if(t===`custom`&&n.start&&n.end){let e=Math.floor(new Date(n.start).getTime()/1e3),t=Math.floor(new Date(n.end).getTime()/1e3);o.set(`start`,String(e)),o.set(`end`,String(t))}r&&o.set(`status`,r),i&&o.set(`access_point_id`,i),a&&o.set(`dest_country`,a),s&&o.set(`isp`,s),c&&o.set(`search`,c);let{exportProfileLogs:d}=await b(async()=>{let{exportProfileLogs:e}=await import(`./services-BVnEJBDq.js`);return{exportProfileLogs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),f=await d(e,o.toString());if(!f||f.length===0){l?.current?.show({message:u(`logs.noResults`,`No logs found to export`),intent:j.WARNING});return}Ie(Fe(f),Le(e,f[0].timestamp,f[f.length-1].timestamp,o)),l?.current?.show({message:u(`logs.exportSuccess`,`Logs exported successfully`),intent:j.SUCCESS})}catch(e){console.error(`Failed to export logs`,e),l?.current?.show({message:u(`logs.exportError`,`Failed to export logs`),intent:j.DANGER})}finally{f(!1)}}}}function ze({profileId:e,toasterRef:t}){let[n,r]=(0,X.useState)(!1),i=Oe(e),a=Ne({profileId:e,realtimeRefresh:n,range:i.range,customRange:i.customRange,statusFilter:i.statusFilter,accessPointIdFilter:i.accessPointIdFilter,destCountryFilter:i.destCountryFilter,ispFilter:i.ispFilter,searchQuery:i.searchQuery});Pe({profileId:e,realtimeRefresh:n,range:i.range,searchQuery:i.searchQuery,scrollContainerRef:a.scrollContainerRef,isFetchingRef:a.isFetchingRef,fetchLogs:a.fetchLogs,logsRef:a.logsRef});let o=Re({profileId:e,range:i.range,customRange:i.customRange,statusFilter:i.statusFilter,accessPointIdFilter:i.accessPointIdFilter,destCountryFilter:i.destCountryFilter,ispFilter:i.ispFilter,searchQuery:i.searchQuery,toasterRef:t});return{realtimeRefresh:n,setRealtimeRefresh:r,...i,...a,...o}}function Be({profileId:e,range:t,fetchLogs:n,toasterRef:r}){let{t:i}=o(),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(!1),S=(0,X.useRef)(!1),C=(0,X.useRef)(e);C.current!==e&&(C.current=e,S.current=!1);let w=(0,X.useCallback)(async()=>{try{let r=await G.getStatus(e),i=!!r.enabled;s(i);let a=G.isProfileUnlocked(e);if(l(a),i&&!a&&r.wrappedPasskeys&&r.wrappedPasskeys.length>0&&!S.current){S.current=!0;try{await G.unlockProfile(e)&&(l(!0),await K.reDecryptLocalLogs(e),n(t,!0))}catch(e){console.debug(`[useLogsE2ee] Silent auto-unlock skipped or cancelled:`,e)}}}catch{s(!1)}},[e,n,t]);return(0,X.useEffect)(()=>{w()},[w]),{isE2eeEnabled:a,isE2eeUnlocked:c,unlocking:u,recoveryDialogOpen:f,setRecoveryDialogOpen:p,recoveryKeyInput:m,setRecoveryKeyInput:h,recoveryError:g,setRecoveryError:_,rotatedKey:v,setRotatedKey:y,copiedKey:b,handleCopyRotatedKey:e=>{navigator.clipboard.writeText(e),x(!0),setTimeout(()=>x(!1),2e3)},handleUnlockPasskey:async()=>{try{d(!0),await G.unlockProfile(e)&&(l(!0),await K.reDecryptLocalLogs(e),r?.current?.show({message:i(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:j.SUCCESS}),n(t,!0))}catch(e){console.error(`Failed to unlock E2EE via Passkey:`,e),r?.current?.show({message:e.message||i(`settings.e2eeUnlockError`,`验证 Passkey 解锁失败`),intent:j.DANGER})}finally{d(!1)}},handleUnlockRecoveryKey:async a=>{a.preventDefault();let o=m.trim();if(o){d(!0),_(``);try{await G.unlockWithRecoveryKey(o);try{let e=await oe({recoveryKey:o});await G.wrapCurrentKeyForRecovery(e.recovery_key),y(e.recovery_key)}catch(e){console.warn(`[useLogsE2ee] Recovery key auto-rotation failed:`,e)}l(!0),p(!1),h(``),await K.reDecryptLocalLogs(e),r?.current?.show({message:i(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:j.SUCCESS}),n(t,!0)}catch(e){console.error(`Failed to unlock E2EE via recovery key:`,e),_(e.message||i(`account.e2ee.recoveryUnlockFailed`,`恢复密钥无效或解析失败`))}finally{d(!1)}}}}}const Ve=({profileId:e,onQuickAction:t,toasterRef:n})=>{let r=te(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),{realtimeRefresh:c,setRealtimeRefresh:l,range:u,setRange:d,customRange:f,setCustomRange:p,statusFilter:m,setStatusFilter:h,accessPointIdFilter:g,setAccessPointIdFilter:_,accessPoints:v,destCountryFilter:y,setDestCountryFilter:b,ispFilter:x,setIspFilter:S,searchQuery:C,setSearchQuery:w,logs:T,loading:E,loadingMore:O,hasMore:k,stats:A,logRetentionDays:j,prevLatestTimestamp:M,scrollContainerRef:N,lastLogElementRef:P,fetchLogs:F,exporting:I,handleExportLogs:L}=ze({profileId:e,toasterRef:n}),{isE2eeEnabled:R,isE2eeUnlocked:z,unlocking:B,recoveryDialogOpen:V,setRecoveryDialogOpen:H,recoveryKeyInput:U,setRecoveryKeyInput:W,recoveryError:ee,setRecoveryError:G,rotatedKey:K,setRotatedKey:ne,copiedKey:q,handleCopyRotatedKey:re,handleUnlockPasskey:ie,handleUnlockRecoveryKey:ae}=Be({profileId:e,range:u,fetchLogs:F,toasterRef:n}),oe=new Date().toLocaleString(`sv-SE`).replace(` `,`T`).slice(0,16);return E&&T.length===0?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Z.jsx)(D,{})}):(0,Z.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden bg-gray-50/30 dark:bg-gray-950/10 max-w-7xl mx-auto w-full pt-14`,children:[(0,Z.jsx)(he,{profileId:e,range:u,setRange:d,customRange:f,setCustomRange:p,nowStr:oe,fetchLogs:F,isMobile:r,realtimeRefresh:c,setRealtimeRefresh:l,statusFilter:m,setStatusFilter:h,accessPointIdFilter:g,setAccessPointIdFilter:_,accessPoints:v,destCountryFilter:y,setDestCountryFilter:b,ispFilter:x,setIspFilter:S,searchQuery:C,setSearchQuery:w,stats:A,logRetentionDays:j,onExport:L,exporting:I}),R&&!z&&(0,Z.jsx)(Te,{isMobile:r,unlocking:B,onUnlockPasskey:ie,onOpenRecoveryDialog:()=>{G(``),W(``),H(!0)}}),(0,Z.jsx)(ve,{logs:T,loading:E,loadingMore:O,hasMore:k,realtimeRefresh:c,isMobile:r,searchQuery:C,scrollContainerRef:N,lastLogElementRef:P,prevLatestTimestamp:M,setSelectedLog:a,setIsDrawerOpen:s,logRetentionDays:j}),(0,Z.jsx)(we,{isDrawerOpen:o,setIsDrawerOpen:s,selectedLog:i,profileId:e,isMobile:r,onQuickAction:t}),(0,Z.jsx)(Ee,{isOpen:V,onClose:()=>H(!1),recoveryKeyInput:U,setRecoveryKeyInput:W,recoveryError:ee,unlocking:B,onSubmit:ae}),(0,Z.jsx)(De,{rotatedKey:K,onClose:()=>ne(null),copiedKey:q,onCopyKey:re})]})};export{Ve as LogsView};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-DPi2BX_1.js","assets/vendor-utils-CnB7BG7m.js","assets/vendor-icons-other-Bme3ywH9.js","assets/vendor-icons-16-BgwRBCeU.js","assets/rolldown-runtime-C4Xdq4VV.js","assets/vendor-icons-20-X5NPN60g.js","assets/vendor-react-CHk5ngkq.js"])))=>i.map(i=>d[i]);
2
- import{i as e,r as t}from"./rolldown-runtime-C4Xdq4VV.js";import{S as n,b as r,x as i}from"./vendor-icons-other-Bme3ywH9.js";var a=e(n(),1),o=e(r(),1);const s=({uri:e})=>{let n=(0,a.useRef)(null),[r,s]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{!n.current||!e||i(()=>import(`./browser-DPi2BX_1.js`).then(t(1)),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>{t.toCanvas(n.current,e,{width:200,margin:2,color:{dark:`#1a1a2e`,light:`#ffffff`}},e=>{e&&(console.error(e),s(!0))})}).catch(()=>s(!0))},[e]),r?(0,o.jsx)(`div`,{className:`w-50 h-50 border border-gray-200 rounded-lg flex flex-col items-center justify-center text-center p-4 text-xs text-gray-500`,children:(0,o.jsx)(`p`,{className:`break-all`,children:e})}):(0,o.jsx)(`canvas`,{ref:n,className:`rounded-lg border border-gray-100`})};export{s as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-Dc5iKjY4.js","assets/vendor-utils-BWSB0jGn.js","assets/vendor-icons-other-Bme3ywH9.js","assets/vendor-icons-16-BgwRBCeU.js","assets/rolldown-runtime-C4Xdq4VV.js","assets/vendor-icons-20-X5NPN60g.js","assets/vendor-react-BmoHsW1x.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,r as t}from"./rolldown-runtime-C4Xdq4VV.js";import{S as n,b as r,x as i}from"./vendor-icons-other-Bme3ywH9.js";var a=e(n(),1),o=e(r(),1);const s=({uri:e})=>{let n=(0,a.useRef)(null),[r,s]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{!n.current||!e||i(()=>import(`./browser-Dc5iKjY4.js`).then(t(1)),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>{t.toCanvas(n.current,e,{width:200,margin:2,color:{dark:`#1a1a2e`,light:`#ffffff`}},e=>{e&&(console.error(e),s(!0))})}).catch(()=>s(!0))},[e]),r?(0,o.jsx)(`div`,{className:`w-50 h-50 border border-gray-200 rounded-lg flex flex-col items-center justify-center text-center p-4 text-xs text-gray-500`,children:(0,o.jsx)(`p`,{className:`break-all`,children:e})}):(0,o.jsx)(`canvas`,{ref:n,className:`rounded-lg border border-gray-100`})};export{s as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{C as t,Ct as n,O as r,Zt as i,ft as a,jt as o,tt as s,vt as c,xt as l,yt as u,z as d}from"./vendor-react-CHk5ngkq.js";import{S as f,b as p}from"./vendor-icons-other-Bme3ywH9.js";import{C as m,H as h,N as g,O as _,S as v,V as y,b,d as x,f as S,p as C,r as w,u as T,x as E,y as D}from"./vendor-ui-core-sfZn2C08.js";import{_t as O}from"./vendor-utils-CnB7BG7m.js";import{$ as k,Ct as A,mt as j,on as M,ot as N,ut as P,w as F}from"./index-CbTjGMTZ.js";var I=e(f(),1),L=e(p(),1);const R=({newRule:e,setNewRule:t,addRule:n})=>{let{t:r}=i();return(0,L.jsx)(E,{elevation:h.ONE,className:`mb-8 p-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col lg:flex-row justify-between gap-4 items-start lg:items-end`,children:[(0,L.jsx)(`div`,{className:`w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.action`),labelFor:`rule-type`,children:(0,L.jsx)(x,{id:`rule-type`,fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:r(`rules.typeBlock`),value:`BLOCK`},{label:r(`rules.typeAllow`),value:`ALLOW`},{label:r(`rules.typeRedirect`),value:`REDIRECT`}]})})}),(0,L.jsx)(`div`,{className:`flex-1 w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.pattern`),labelFor:`rule-pattern`,children:(0,L.jsx)(S,{id:`rule-pattern`,size:`large`,placeholder:r(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})}),e.type!==`REDIRECT`&&(0,L.jsx)(C,{label:``,labelFor:``,children:(0,L.jsx)(g,{intent:y.PRIMARY,size:`large`,icon:(0,L.jsx)(d,{size:18}),onClick:n,children:r(`rules.addRule`)})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(s,{size:16}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:r(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,L.jsx)(C,{label:r(`rules.aRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv4Placeholder`),value:e.v_a,onChange:n=>t({...e,v_a:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.aaaaRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv6Placeholder`),value:e.v_aaaa,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.cnameRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.cnamePlaceholder`),value:e.v_cname,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.txtRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.txtPlaceholder`),value:e.v_txt,onChange:n=>t({...e,v_txt:n.target.value})})})]}),(0,L.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 flex justify-end`,children:(0,L.jsx)(g,{intent:y.PRIMARY,large:!0,icon:(0,L.jsx)(d,{size:18}),onClick:n,text:r(`rules.saveRedirectRule`)})})]})]})})},z=({rules:e,startEdit:t,getBlockDetail:o})=>{let{t:s}=i(),[d,f]=(0,I.useState)(`created_at`),[p,m]=(0,I.useState)(`desc`),h=e=>{d===e?m(e=>e===`asc`?`desc`:`asc`):(f(e),m(e===`created_at`?`desc`:`asc`))},g=e=>e.type===`REDIRECT`?[e.v_a,e.v_aaaa,e.v_cname,e.v_txt].filter(Boolean).join(` `):e.type===`BLOCK`?o():s(`rules.detailAllow`,`Forward to upstream`),_=(0,I.useMemo)(()=>[...e].sort((e,t)=>{let n=0;switch(d){case`action`:n=e.type.localeCompare(t.type);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`details`:n=g(e).localeCompare(g(t));break;case`created_at`:n=(e.created_at??e.id)-(t.created_at??t.id);break}return n===0&&(n=e.id-t.id),p===`asc`?n:-n}),[e,d,p,o,s]),v=[{key:`action`,header:s(`rules.tableAction`),headerClassName:`w-32`,render:e=>(0,L.jsxs)(L.Fragment,{children:[e.type===`BLOCK`&&(0,L.jsx)(w,{intent:y.DANGER,minimal:!0,icon:(0,L.jsx)(r,{size:12,className:`mr-1`}),children:s(`rules.labelBlock`)}),e.type===`ALLOW`&&(0,L.jsx)(w,{intent:y.SUCCESS,minimal:!0,icon:(0,L.jsx)(a,{size:12,className:`mr-1`}),children:s(`rules.labelAllow`)}),e.type===`REDIRECT`&&(0,L.jsx)(w,{intent:y.WARNING,minimal:!0,icon:(0,L.jsx)(l,{size:12,className:`mr-1`}),children:s(`rules.labelRedirect`)})]})},{key:`pattern`,header:s(`rules.tablePattern`),headerClassName:`w-1/4`,cellClassName:`font-mono font-bold`,render:e=>e.pattern},{key:`details`,header:s(`rules.tableDetails`),cellClassName:`py-2`,render:e=>(0,L.jsx)(L.Fragment,{children:e.type===`REDIRECT`?(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.v_a&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`A: `,e.v_a]}),e.v_aaaa&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`AAAA: `,e.v_aaaa]}),e.v_cname&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`CNAME: `,e.v_cname]}),e.v_txt&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`TXT: `,e.v_txt]})]}):e.type===`BLOCK`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:s(`rules.detailBlock`)}),(0,L.jsx)(w,{minimal:!0,round:!0,className:`text-[9px] px-1.5 opacity-70`,children:o()})]}):(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:s(`rules.detailAllow`)})})},{key:`created_at`,header:s(`rules.tableCreatedAt`,`添加时间`),headerClassName:`w-44`,cellClassName:`text-xs text-gray-500 align-middle`,render:e=>e.created_at?F(new Date(e.created_at*1e3)):`—`}];return(0,L.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,L.jsxs)(T,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:v.map(e=>(0,L.jsx)(`th`,{onClick:()=>h(e.key),className:O(e.headerClassName,`cursor-pointer select-none transition-colors hover:text-blue-500`),title:s(`rules.clickToSort`,`点击排序`),children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{children:e.header}),d===e.key?p===`asc`?(0,L.jsx)(c,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(n,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(u,{size:12,className:`opacity-30 hover:opacity-75 shrink-0`})]})},e.key))})}),(0,L.jsx)(`tbody`,{children:_.map(e=>(0,L.jsx)(`tr`,{onClick:()=>t(e),className:`cursor-pointer`,children:v.map(t=>(0,L.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},B=({editRule:e,setEditRule:n,saveEditRule:r,cancelEdit:a,deleteRule:o})=>{let{t:c}=i();return(0,L.jsxs)(_,{isOpen:!!e,onClose:a,title:c(`rules.editRule`,`Edit Rule`),style:{width:`600px`},children:[(0,L.jsx)(b,{children:e&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(C,{label:c(`rules.action`),className:`w-40 mb-0`,children:(0,L.jsx)(x,{fill:!0,value:e.type,onChange:t=>n({...e,type:t.target.value}),options:[{label:c(`rules.typeBlock`),value:`BLOCK`},{label:c(`rules.typeAllow`),value:`ALLOW`},{label:c(`rules.typeRedirect`),value:`REDIRECT`}]})}),(0,L.jsx)(C,{label:c(`rules.pattern`),className:`flex-1 mb-0`,children:(0,L.jsx)(S,{placeholder:c(`rules.patternPlaceholder`),value:e.pattern,onChange:t=>n({...e,pattern:t.target.value})})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(s,{size:14}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:c(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsx)(C,{label:c(`rules.aRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:c(`rules.ipv4Placeholder`),value:e.v_a||``,onChange:t=>n({...e,v_a:t.target.value})})}),(0,L.jsx)(C,{label:c(`rules.aaaaRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:c(`rules.ipv6Placeholder`),value:e.v_aaaa||``,onChange:t=>n({...e,v_aaaa:t.target.value})})}),(0,L.jsx)(C,{label:c(`rules.cnameRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:c(`rules.cnamePlaceholder`),value:e.v_cname||``,onChange:t=>n({...e,v_cname:t.target.value})})}),(0,L.jsx)(C,{label:c(`rules.txtRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:c(`rules.txtPlaceholder`),value:e.v_txt||``,onChange:t=>n({...e,v_txt:t.target.value})})})]})]})]})}),(0,L.jsx)(D,{actions:(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(g,{onClick:a,children:c(`rules.cancel`,`Cancel`)}),(0,L.jsx)(g,{intent:y.PRIMARY,onClick:r,children:c(`rules.saveChanges`,`Save Changes`)})]}),children:(0,L.jsx)(g,{icon:(0,L.jsx)(t,{size:14}),intent:y.DANGER,text:c(`rules.delete`,`Delete`),onClick:()=>{e&&o(e.id)}})})]})},V=({profileId:e,prefill:t,onPrefillUsed:n,toasterRef:r})=>{let a=o(),[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(null),[,d]=(0,I.useState)(!0),{t:f}=i(),p=M(),[h,_]=(0,I.useState)({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),[b,x]=(0,I.useState)(null);(0,I.useEffect)(()=>{t&&(_({type:t.type,pattern:t.domain,v_a:t.recordType===`A`?`0.0.0.0`:``,v_aaaa:t.recordType===`AAAA`?`::`:``,v_txt:t.recordType===`TXT`?`Pre-filled`:``,v_cname:t.recordType===`CNAME`?`target.com`:``}),n?.())},[t,n]);let S=async()=>{d(!0);try{let[t,n]=await Promise.all([j(e),P(e)]);c(t),u(JSON.parse(n.settings||`{}`))}catch(e){console.error(`Failed to fetch data`,e)}finally{d(!1)}};return(0,I.useEffect)(()=>{S()},[e]),(0,L.jsxs)(`div`,{className:O(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,p?`p-1`:`px-8`),children:[(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(`div`,{className:`flex flex-col md:flex-row justify-between items-start gap-4`,children:(0,L.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[p?(0,L.jsxs)(m,{minimal:!0,fill:p,children:[(0,L.jsx)(g,{active:!0,onClick:()=>a(`/dash/${e}/rules`),text:f(`rules.title`),large:!0}),(0,L.jsx)(g,{active:!1,onClick:()=>a(`/dash/${e}/filter`),text:f(`filtering.title`),large:!0})]}):(0,L.jsx)(`h1`,{className:`bp6-heading`,children:f(`rules.title`)}),(0,L.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:f(`rules.subtitle`)})]})})}),(0,L.jsx)(R,{newRule:h,setNewRule:_,addRule:async()=>{let t=h.pattern.trim();if(!t){r?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.pattern.trim().toLowerCase()===n)){r?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await k(e,{...h,pattern:t}),r?.current?.show({message:f(`rules.addSuccess`,`Rule added successfully`),intent:y.SUCCESS}),_({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),S()}catch(e){r?.current?.show({message:e.message||f(`rules.addFailed`,`Failed to add rule`),intent:y.DANGER})}}}),s.length===0?(0,L.jsx)(v,{title:f(`rules.noRulesTitle`),children:f(`rules.noRulesDesc`)}):(0,L.jsx)(z,{rules:s,startEdit:e=>{x({...e})},getBlockDetail:()=>{if(!l)return f(`rules.detailBlock`);switch(l.block_mode||`NULL_IP`){case`NXDOMAIN`:return`NXDOMAIN`;case`NODATA`:return`NODATA`;case`CUSTOM_IP`:return`${l.custom_block_ipv4||`0.0.0.0`} / ${l.custom_block_ipv6||`::`}`;default:return`0.0.0.0 / ::`}}}),(0,L.jsx)(B,{editRule:b,setEditRule:x,saveEditRule:async()=>{if(!b)return;let t=b.pattern.trim();if(!t){r?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.id!==b.id&&e.pattern.trim().toLowerCase()===n)){r?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await A(e,{...b,pattern:t}),r?.current?.show({message:f(`rules.updateSuccess`,`Rule updated successfully`),intent:y.SUCCESS}),x(null),S()}catch(e){r?.current?.show({message:e.message||f(`rules.updateFailed`,`Failed to update rule`),intent:y.DANGER})}},cancelEdit:()=>{x(null)},deleteRule:async t=>{try{await N(e,t)}catch(e){console.error(e)}x(null),S()}})]})};export{V as RulesView};
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{C as t,Mt as n,O as r,Qt as i,St as a,bt as o,pt as s,tt as c,wt as l,yt as u,z as d}from"./vendor-react-BmoHsW1x.js";import{S as f,b as p}from"./vendor-icons-other-Bme3ywH9.js";import{C as m,H as h,N as g,O as _,S as v,V as y,b,d as x,f as S,p as C,r as w,u as T,x as E,y as D}from"./vendor-ui-core-CY_WyMIf.js";import{_t as O}from"./vendor-utils-BWSB0jGn.js";import{X as k,bt as A,dt as j,ln as M,rt as N,st as P,w as F}from"./index-dXN_pYn1.js";var I=e(f(),1),L=e(p(),1);const R=({newRule:e,setNewRule:t,addRule:n})=>{let{t:r}=i();return(0,L.jsx)(E,{elevation:h.ONE,className:`mb-8 p-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col lg:flex-row justify-between gap-4 items-start lg:items-end`,children:[(0,L.jsx)(`div`,{className:`w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.action`),labelFor:`rule-type`,children:(0,L.jsx)(x,{id:`rule-type`,fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:r(`rules.typeBlock`),value:`BLOCK`},{label:r(`rules.typeAllow`),value:`ALLOW`},{label:r(`rules.typeRedirect`),value:`REDIRECT`}]})})}),(0,L.jsx)(`div`,{className:`flex-1 w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.pattern`),labelFor:`rule-pattern`,children:(0,L.jsx)(S,{id:`rule-pattern`,size:`large`,placeholder:r(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})}),e.type!==`REDIRECT`&&(0,L.jsx)(C,{label:``,labelFor:``,children:(0,L.jsx)(g,{intent:y.PRIMARY,size:`large`,icon:(0,L.jsx)(d,{size:18}),onClick:n,children:r(`rules.addRule`)})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(c,{size:16}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:r(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,L.jsx)(C,{label:r(`rules.aRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv4Placeholder`),value:e.v_a,onChange:n=>t({...e,v_a:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.aaaaRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv6Placeholder`),value:e.v_aaaa,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.cnameRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.cnamePlaceholder`),value:e.v_cname,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.txtRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.txtPlaceholder`),value:e.v_txt,onChange:n=>t({...e,v_txt:n.target.value})})})]}),(0,L.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 flex justify-end`,children:(0,L.jsx)(g,{intent:y.PRIMARY,large:!0,icon:(0,L.jsx)(d,{size:18}),onClick:n,text:r(`rules.saveRedirectRule`)})})]})]})})},z=({rules:e,startEdit:t,getBlockDetail:n})=>{let{t:c}=i(),[d,f]=(0,I.useState)(`created_at`),[p,m]=(0,I.useState)(`desc`),h=e=>{d===e?m(e=>e===`asc`?`desc`:`asc`):(f(e),m(e===`created_at`?`desc`:`asc`))},g=e=>e.type===`REDIRECT`?[e.v_a,e.v_aaaa,e.v_cname,e.v_txt].filter(Boolean).join(` `):e.type===`BLOCK`?n():c(`rules.detailAllow`,`Forward to upstream`),_=(0,I.useMemo)(()=>[...e].sort((e,t)=>{let n=0;switch(d){case`action`:n=e.type.localeCompare(t.type);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`details`:n=g(e).localeCompare(g(t));break;case`created_at`:n=(e.created_at??e.id)-(t.created_at??t.id);break}return n===0&&(n=e.id-t.id),p===`asc`?n:-n}),[e,d,p,n,c]),v=[{key:`action`,header:c(`rules.tableAction`),headerClassName:`w-32`,render:e=>(0,L.jsxs)(L.Fragment,{children:[e.type===`BLOCK`&&(0,L.jsx)(w,{intent:y.DANGER,minimal:!0,icon:(0,L.jsx)(r,{size:12,className:`mr-1`}),children:c(`rules.labelBlock`)}),e.type===`ALLOW`&&(0,L.jsx)(w,{intent:y.SUCCESS,minimal:!0,icon:(0,L.jsx)(s,{size:12,className:`mr-1`}),children:c(`rules.labelAllow`)}),e.type===`REDIRECT`&&(0,L.jsx)(w,{intent:y.WARNING,minimal:!0,icon:(0,L.jsx)(a,{size:12,className:`mr-1`}),children:c(`rules.labelRedirect`)})]})},{key:`pattern`,header:c(`rules.tablePattern`),headerClassName:`w-1/4`,cellClassName:`font-mono font-bold`,render:e=>e.pattern},{key:`details`,header:c(`rules.tableDetails`),cellClassName:`py-2`,render:e=>(0,L.jsx)(L.Fragment,{children:e.type===`REDIRECT`?(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.v_a&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`A: `,e.v_a]}),e.v_aaaa&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`AAAA: `,e.v_aaaa]}),e.v_cname&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`CNAME: `,e.v_cname]}),e.v_txt&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`TXT: `,e.v_txt]})]}):e.type===`BLOCK`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:c(`rules.detailBlock`)}),(0,L.jsx)(w,{minimal:!0,round:!0,className:`text-[9px] px-1.5 opacity-70`,children:n()})]}):(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:c(`rules.detailAllow`)})})},{key:`created_at`,header:c(`rules.tableCreatedAt`,`添加时间`),headerClassName:`w-44`,cellClassName:`text-xs text-gray-500 align-middle`,render:e=>e.created_at?F(new Date(e.created_at*1e3)):`—`}];return(0,L.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,L.jsxs)(T,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:v.map(e=>(0,L.jsx)(`th`,{onClick:()=>h(e.key),className:O(e.headerClassName,`cursor-pointer select-none transition-colors hover:text-blue-500`),title:c(`rules.clickToSort`,`点击排序`),children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{children:e.header}),d===e.key?p===`asc`?(0,L.jsx)(u,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(l,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(o,{size:12,className:`opacity-30 hover:opacity-75 shrink-0`})]})},e.key))})}),(0,L.jsx)(`tbody`,{children:_.map(e=>(0,L.jsx)(`tr`,{onClick:()=>t(e),className:`cursor-pointer`,children:v.map(t=>(0,L.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},B=({editRule:e,setEditRule:n,saveEditRule:r,cancelEdit:a,deleteRule:o})=>{let{t:s}=i();return(0,L.jsxs)(_,{isOpen:!!e,onClose:a,title:s(`rules.editRule`,`Edit Rule`),style:{width:`600px`},children:[(0,L.jsx)(b,{children:e&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(C,{label:s(`rules.action`),className:`w-40 mb-0`,children:(0,L.jsx)(x,{fill:!0,value:e.type,onChange:t=>n({...e,type:t.target.value}),options:[{label:s(`rules.typeBlock`),value:`BLOCK`},{label:s(`rules.typeAllow`),value:`ALLOW`},{label:s(`rules.typeRedirect`),value:`REDIRECT`}]})}),(0,L.jsx)(C,{label:s(`rules.pattern`),className:`flex-1 mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.patternPlaceholder`),value:e.pattern,onChange:t=>n({...e,pattern:t.target.value})})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(c,{size:14}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:s(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsx)(C,{label:s(`rules.aRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.ipv4Placeholder`),value:e.v_a||``,onChange:t=>n({...e,v_a:t.target.value})})}),(0,L.jsx)(C,{label:s(`rules.aaaaRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.ipv6Placeholder`),value:e.v_aaaa||``,onChange:t=>n({...e,v_aaaa:t.target.value})})}),(0,L.jsx)(C,{label:s(`rules.cnameRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.cnamePlaceholder`),value:e.v_cname||``,onChange:t=>n({...e,v_cname:t.target.value})})}),(0,L.jsx)(C,{label:s(`rules.txtRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.txtPlaceholder`),value:e.v_txt||``,onChange:t=>n({...e,v_txt:t.target.value})})})]})]})]})}),(0,L.jsx)(D,{actions:(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(g,{onClick:a,children:s(`rules.cancel`,`Cancel`)}),(0,L.jsx)(g,{intent:y.PRIMARY,onClick:r,children:s(`rules.saveChanges`,`Save Changes`)})]}),children:(0,L.jsx)(g,{icon:(0,L.jsx)(t,{size:14}),intent:y.DANGER,text:s(`rules.delete`,`Delete`),onClick:()=>{e&&o(e.id)}})})]})},V=({profileId:e,prefill:t,onPrefillUsed:r,toasterRef:a})=>{let o=n(),[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(null),[,d]=(0,I.useState)(!0),{t:f}=i(),p=M(),[h,_]=(0,I.useState)({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),[b,x]=(0,I.useState)(null);(0,I.useEffect)(()=>{t&&(_({type:t.type,pattern:t.domain,v_a:t.recordType===`A`?`0.0.0.0`:``,v_aaaa:t.recordType===`AAAA`?`::`:``,v_txt:t.recordType===`TXT`?`Pre-filled`:``,v_cname:t.recordType===`CNAME`?`target.com`:``}),r?.())},[t,r]);let S=async()=>{d(!0);try{let[t,n]=await Promise.all([j(e),P(e)]);c(t),u(JSON.parse(n.settings||`{}`))}catch(e){console.error(`Failed to fetch data`,e)}finally{d(!1)}};return(0,I.useEffect)(()=>{S()},[e]),(0,L.jsxs)(`div`,{className:O(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,p?`p-1`:`px-8`),children:[(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(`div`,{className:`flex flex-col md:flex-row justify-between items-start gap-4`,children:(0,L.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[p?(0,L.jsxs)(m,{minimal:!0,fill:p,children:[(0,L.jsx)(g,{active:!0,onClick:()=>o(`/dash/${e}/rules`),text:f(`rules.title`),large:!0}),(0,L.jsx)(g,{active:!1,onClick:()=>o(`/dash/${e}/filter`),text:f(`filtering.title`),large:!0})]}):(0,L.jsx)(`h1`,{className:`bp6-heading`,children:f(`rules.title`)}),(0,L.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:f(`rules.subtitle`)})]})})}),(0,L.jsx)(R,{newRule:h,setNewRule:_,addRule:async()=>{let t=h.pattern.trim();if(!t){a?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.pattern.trim().toLowerCase()===n)){a?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await k(e,{...h,pattern:t}),a?.current?.show({message:f(`rules.addSuccess`,`Rule added successfully`),intent:y.SUCCESS}),_({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),S()}catch(e){a?.current?.show({message:e.message||f(`rules.addFailed`,`Failed to add rule`),intent:y.DANGER})}}}),s.length===0?(0,L.jsx)(v,{title:f(`rules.noRulesTitle`),children:f(`rules.noRulesDesc`)}):(0,L.jsx)(z,{rules:s,startEdit:e=>{x({...e})},getBlockDetail:()=>{if(!l)return f(`rules.detailBlock`);switch(l.block_mode||`NULL_IP`){case`NXDOMAIN`:return`NXDOMAIN`;case`NODATA`:return`NODATA`;case`CUSTOM_IP`:return`${l.custom_block_ipv4||`0.0.0.0`} / ${l.custom_block_ipv6||`::`}`;default:return`0.0.0.0 / ::`}}}),(0,L.jsx)(B,{editRule:b,setEditRule:x,saveEditRule:async()=>{if(!b)return;let t=b.pattern.trim();if(!t){a?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.id!==b.id&&e.pattern.trim().toLowerCase()===n)){a?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await A(e,{...b,pattern:t}),a?.current?.show({message:f(`rules.updateSuccess`,`Rule updated successfully`),intent:y.SUCCESS}),x(null),S()}catch(e){a?.current?.show({message:e.message||f(`rules.updateFailed`,`Failed to update rule`),intent:y.DANGER})}},cancelEdit:()=>{x(null)},deleteRule:async t=>{try{await N(e,t)}catch(e){console.error(e)}x(null),S()}})]})};export{V as RulesView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{B as t,C as n,D as r,Et as i,P as a,Qt as o,X as s,at as c,dt as l,et as u,gt as d,ot as f,q as p,st as m,tt as h,v as g,y as _}from"./vendor-react-BmoHsW1x.js";import{S as v,b as y}from"./vendor-icons-other-Bme3ywH9.js";import{B as b,D as x,E as S,H as C,M as w,N as T,P as E,S as D,T as O,V as k,_ as A,d as j,f as M,h as N,p as P,r as F,v as I,w as L,x as R}from"./vendor-ui-core-CY_WyMIf.js";import"./vendor-utils-BWSB0jGn.js";import{B as z,H as B,c as V,ct as H,dt as U,k as W,mt as G,st as K,vt as q,xt as J}from"./index-dXN_pYn1.js";var Y=e(v(),1),X=e(y(),1);const Z=({profile:e,isEditingName:n,setIsEditingName:r,editName:i,setEditName:a,updateProfileName:s,exportProfile:c})=>{let{t:l}=o(),[u,p]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col justify-start`,children:[n?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,X.jsx)(I,{content:l(`common.profileNameFormatTip`,`Profile Name tip: 1-30 characters, duplicates not allowed`),isOpen:u,position:b.TOP,intent:k.PRIMARY,className:`flex-1`,children:(0,X.jsx)(`div`,{className:`w-full block`,children:(0,X.jsx)(M,{value:i,onChange:e=>a(e.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),autoFocus:!0,onKeyDown:t=>{t.key===`Enter`&&s(),t.key===`Escape`&&(r(!1),a(e?.name||``))}})})}),(0,X.jsx)(T,{icon:(0,X.jsx)(d,{size:16}),intent:k.SUCCESS,minimal:!0,onClick:s,disabled:!V.test(i)}),(0,X.jsx)(T,{icon:(0,X.jsx)(_,{size:16}),minimal:!0,onClick:()=>{r(!1),a(e?.name||``)}})]}):(0,X.jsxs)(`div`,{className:`group flex items-center gap-2 mb-1 cursor-pointer`,onClick:()=>r(!0),children:[(0,X.jsx)(`h2`,{className:`bp6-heading mb-0`,children:e?.name}),(0,X.jsx)(T,{icon:(0,X.jsx)(t,{size:14}),minimal:!0,className:`opacity-30 group-hover:opacity-100 transition-opacity`})]}),(0,X.jsx)(`p`,{className:`bp6-text-muted`,children:l(`settings.subtitle`)})]}),(0,X.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,X.jsx)(T,{size:`large`,icon:(0,X.jsx)(f,{size:18}),text:l(`settings.export`,`导出配置`),onClick:c})})]})},Q=()=>{let{t:e}=o(),[t,n]=(0,Y.useState)([]);return(0,Y.useEffect)(()=>{B().then(t=>{t&&Array.isArray(t)&&n(t.map(t=>({label:e(t.label),url:t.url})))}).catch(e=>console.warn(`Failed to fetch preset upstreams from API`,e))},[e]),t},$=(e,t)=>{let{t:n}=o();return(0,Y.useMemo)(()=>{let e=t>0?t:30,r=n(`settings.retentionMaxSuffix`,`(最长)`),i=[{label:n(`settings.retentionDisabled`,`关闭 (隐私需要)`),value:0},{label:n(`settings.retention10m`,`10 分钟`),value:.007},{label:n(`settings.retention1h`,`1 小时`),value:.0416},{label:n(`settings.retention24h`,`24 小时`),value:1},{label:n(`settings.retention7d`,`7 天`),value:7},{label:n(`settings.retention30d`,`30 天`),value:30},{label:n(`settings.retention90d`,`90 天`),value:90},{label:n(`settings.retention180d`,`180 天`),value:180},{label:n(`settings.retention360d`,`360 天`),value:360}],a=i.filter(t=>t.value<=e);return e>0&&!a.some(t=>t.value===e)&&(a.push({label:`${e} ${n(`settings.daysUnit`,`天`)}`,value:e}),a.sort((e,t)=>e.value-t.value)),a.length===0?[i[0]]:a.map(t=>t.value===e&&t.value>0?{...t,label:`${t.label} ${r}`}:t)},[n,t])},ee=({settings:e,setSettings:t})=>{let{t:n}=o(),r=(0,X.jsx)(S,{className:`min-w-96`,children:Q().map((n,r)=>(0,X.jsx)(L,{text:n.label,onClick:()=>t({...e,upstream:[n.url]}),labelElement:(0,X.jsx)(`div`,{className:`flex flex-col items-end text-right`,children:(0,X.jsx)(`span`,{className:`text-[9px] opacity-85 max-w-64 truncate`,title:n.url,children:n.url})})},r))});return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(a,{size:18,className:`text-blue-500`}),` `,n(`settings.upstreamTitle`)]}),(0,X.jsx)(P,{label:`DoH (https://) / DoT (tls://) / DNS Stamp (sdns://) / ${n(`settings.classicDns`)}`,children:(0,X.jsx)(M,{fill:!0,placeholder:`https://... | tls://... | sdns://... | 1.1.1.1`,value:e.upstream?.[0]||``,onChange:n=>t({...e,upstream:[n.target.value]}),onFocus:e=>e.target.select(),rightElement:(0,X.jsx)(O,{content:r,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,X.jsx)(T,{variant:`minimal`,icon:`chevron-down`})})})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.upstreamDesc`)})]})},te=({settings:e,setSettings:t})=>{let{t:n}=o();return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(r,{size:18,className:`text-green-500`}),` `,n(`settings.defaultPolicyTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:n(`settings.onNoMatch`),children:(0,X.jsxs)(j,{fill:!0,value:e.default_policy,onChange:n=>t({...e,default_policy:n.target.value}),children:[(0,X.jsx)(`option`,{value:`ALLOW`,children:n(`settings.allowAll`)}),(0,X.jsx)(`option`,{value:`BLOCK`,children:n(`settings.blockAll`)})]})}),(0,X.jsx)(A,{}),(0,X.jsx)(P,{label:n(`settings.blockModeTitle`),helperText:n(`settings.blockModeDesc`),children:(0,X.jsxs)(j,{fill:!0,value:e.block_mode||`NULL_IP`,onChange:n=>t({...e,block_mode:n.target.value}),children:[(0,X.jsxs)(`option`,{value:`NULL_IP`,children:[`0.0.0.0 / :: (`,n(`settings.default`),`)`]}),(0,X.jsxs)(`option`,{value:`NXDOMAIN`,children:[`NXDOMAIN (`,n(`settings.NXDOMAIN`),`)`]}),(0,X.jsxs)(`option`,{value:`NODATA`,children:[`NODATA (`,n(`settings.NODATA`),`)`]}),(0,X.jsx)(`option`,{value:`CUSTOM_IP`,children:n(`settings.customIP`)})]})}),e.block_mode===`CUSTOM_IP`&&(0,X.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1`,children:[(0,X.jsx)(M,{placeholder:`IPv4: 127.0.0.1`,value:e.custom_block_ipv4||``,onChange:n=>t({...e,custom_block_ipv4:n.target.value})}),(0,X.jsx)(M,{placeholder:`IPv6: ::1`,value:e.custom_block_ipv6||``,onChange:n=>t({...e,custom_block_ipv6:n.target.value})})]})]})]})},ne=({settings:e,setSettings:t,isAdmin:n,maxRetentionDays:r})=>{let{t:i}=o(),a=$(n,r);Y.useEffect(()=>{if(r>0&&e.log_retention_days>r&&a.length>0){let n=a[a.length-1];n&&e.log_retention_days!==n.value&&t({...e,log_retention_days:n.value})}},[r,e.log_retention_days,a,t]);let s=e.log_retention_days===0;return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(l,{size:18,className:`text-purple-500`}),` `,i(`settings.logRetentionTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:i(`settings.retentionDuration`),children:(0,X.jsx)(j,{fill:!0,value:e.log_retention_days,onChange:n=>t({...e,log_retention_days:parseFloat(n.target.value)}),children:a.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:s?i(`settings.retentionDisabledDesc`,`已关闭日志记录。系统将不会记录任何 DNS 查询日志并立即清空历史日志。`):i(`settings.retentionDesc`)}),(0,X.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80`,children:[(0,X.jsx)(N,{label:i(`settings.skipLogOnPass`,`不记录放行记录`),checked:!s&&!!e.skip_log_on_pass,disabled:s,onChange:n=>t({...e,skip_log_on_pass:n.currentTarget.checked})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60 mt-1`,children:i(`settings.skipLogOnPassDesc`,`启用后不记录正常放行的 DNS 查询,仅记录被拦截、重定向或解析失败的记录。可大幅减少存储占用与写操作。`)})]})]})]})},re=({profileId:e,toasterRef:t})=>{let{t:r}=o(),[i,a]=(0,Y.useState)(()=>W.getLocalRetentionDays()),[s,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),_=(0,Y.useCallback)(async()=>{try{await W.init();let t=await W.getStorageInfo();c(t?.isOpfs??W.getIsOpfs());let n=t.profileStats.find(t=>t.profile_id===e);d(n?n.count:0)}catch(e){console.error(`[LocalRetentionCard] Failed to load storage info:`,e),c(W.getIsOpfs()),d(0)}},[e]);(0,Y.useEffect)(()=>{_()},[_]);let v=e=>{a(e),W.setLocalRetentionDays(e),_()};return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(m,{size:18,className:`text-cyan-500`}),` `,r(`settings.localRetentionTitle`,`本地存储与留存`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:r(`settings.localRetentionDuration`,`本地保留时长`),children:(0,X.jsxs)(j,{fill:!0,value:i,onChange:e=>v(parseInt(e.target.value,10)),children:[(0,X.jsx)(`option`,{value:30,children:r(`settings.localRetention30d`,`30 天`)}),(0,X.jsx)(`option`,{value:90,children:r(`settings.localRetention90d`,`90 天 (推荐)`)}),(0,X.jsx)(`option`,{value:180,children:r(`settings.localRetention180d`,`180 天`)}),(0,X.jsx)(`option`,{value:365,children:r(`settings.localRetention365d`,`365 天 (1 年)`)}),(0,X.jsx)(`option`,{value:0,children:r(`settings.localRetentionUnlimited`,`永久保留 (直到手动清除)`)})]})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:r(`settings.localRetentionDesc`,`日志将持久化保存在当前浏览器本地的 SQLite 数据库 (OPFS) 中,提供秒级本地搜索并节省云端存储费用。超出此时长的本地日志将自动清除。`)}),(0,X.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 opacity-70`,children:[(0,X.jsx)(u,{size:14}),r(`settings.localEngineStorage`,`存储引擎`),`:`]}),(0,X.jsx)(F,{minimal:!0,intent:s?k.SUCCESS:k.WARNING,className:`text-[11px]`,children:s?r(`settings.localEngineOpfs`,`OPFS 本地持久化`):r(`settings.localEngineMemory`,`内存临时存储 (无痕/私密模式)`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,X.jsxs)(`span`,{className:`opacity-70`,children:[r(`settings.localCachedCount`,`本地已缓存日志`),`:`]}),(0,X.jsx)(`span`,{className:`font-mono font-medium`,children:l===null?`...`:r(`settings.localCachedCountUnit`,`{{count}} 条记录`,{count:l})})]}),(0,X.jsx)(`div`,{className:`pt-1 flex justify-end`,children:(0,X.jsx)(T,{minimal:!0,small:!0,intent:k.DANGER,icon:(0,X.jsx)(n,{size:13}),text:r(`settings.clearLocalData`,`清空本地日志`),disabled:l===0||l===null||h,onClick:()=>p(!0)})})]})]}),(0,X.jsx)(x,{isOpen:f,confirmButtonText:r(`common.confirm`,`确认清空`),cancelButtonText:r(`common.cancel`,`取消`),intent:k.DANGER,icon:`trash`,onConfirm:async()=>{g(!0);try{await W.clearProfile(e),d(0),t?.current?.show({message:r(`settings.clearLocalDataSuccess`,`本地日志已成功清空`),intent:k.SUCCESS,icon:`tick`})}catch(e){console.error(`[LocalRetentionCard] Failed to clear local profile logs:`,e),t?.current?.show({message:r(`settings.clearLocalDataError`,`清空本地日志失败`),intent:k.DANGER,icon:`error`})}finally{g(!1),p(!1)}},onCancel:()=>p(!1),loading:h,children:(0,X.jsx)(`p`,{children:r(`settings.clearLocalDataConfirm`,`确定要清空此配置在本地保存的所有日志吗?(云端日志不受影响)`)})})]})},ie=({settings:e,setSettings:t})=>{let{t:n}=o();return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-3 font-bold`,children:[(0,X.jsx)(h,{size:18,className:`text-orange-500`}),` `,n(`settings.ecsTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(N,{label:n(`settings.sendEcs`),checked:e.ecs.enabled,onChange:n=>t({...e,ecs:{...e.ecs,enabled:n.currentTarget.checked}})}),(0,X.jsx)(N,{label:n(`settings.customSubnet`),disabled:!e.ecs.enabled,checked:!e.ecs.use_client_ip,onChange:n=>t({...e,ecs:{...e.ecs,use_client_ip:!n.currentTarget.checked}})}),(0,X.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,X.jsx)(P,{label:n(`settings.customIpv4`),labelInfo:n(`settings.ipv4Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,X.jsx)(M,{placeholder:`0.0.0.0/0`,value:e.ecs.ipv4_cidr||``,disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),onChange:n=>t({...e,ecs:{...e.ecs,ipv4_cidr:n.target.value}})})}),(0,X.jsx)(P,{label:n(`settings.customIpv6`),labelInfo:n(`settings.ipv6Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,X.jsx)(M,{placeholder:`::/0`,value:e.ecs.ipv6_cidr||``,disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),onChange:n=>t({...e,ecs:{...e.ecs,ipv6_cidr:n.target.value}})})})]}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.ecsUpstreamHint`)})]})]})};var ae=[{domain:`cloudflare-ech.com`,isPreferred:!0},{domain:`crypto.cloudflare.com`,isPreferred:!1},{domain:`one.one.one.one`,isPreferred:!1},{domain:`www.cloudflare.com`,isPreferred:!1},{domain:`encryptedsni.com`,isPreferred:!1},{domain:`cdnjs.com`,isPreferred:!1}];const oe=({settings:e,setSettings:t})=>{let{t:n}=o(),[r,i]=Y.useState(ae);Y.useEffect(()=>{z().then(e=>{Array.isArray(e)&&e.length>0&&i(e.map(e=>typeof e==`string`?{domain:e,isPreferred:e===`cloudflare-ech.com`}:{domain:e.domain,isPreferred:!!e.isPreferred}))}).catch(e=>console.warn(`Failed to fetch preset ECH fronting domains from API`,e))},[]);let a=typeof e.best_effort_ech==`boolean`?e.best_effort_ech:!!e.best_effort_ech?.enabled,l=typeof e.best_effort_ech==`object`&&e.best_effort_ech?.fronting_domain?e.best_effort_ech.fronting_domain:`cloudflare-ech.com`,u=n=>{t({...e,best_effort_ech:{enabled:n,fronting_domain:l||`cloudflare-ech.com`}})},d=n=>{t({...e,best_effort_ech:{enabled:a,fronting_domain:n}})},f=(0,X.jsx)(S,{className:`min-w-72`,children:r.map(e=>(0,X.jsx)(L,{text:e.domain,onClick:()=>d(e.domain),labelElement:e.isPreferred?(0,X.jsx)(F,{minimal:!0,intent:k.PRIMARY,className:`text-[10px]`,children:n(`settings.echPreferred`,`首选`)}):void 0},e.domain))});return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 m-0 font-bold text-purple-600 dark:text-purple-400`,children:[(0,X.jsx)(s,{size:18}),` `,n(`settings.echTitle`)]}),(0,X.jsx)(O,{placement:`bottom-end`,usePortal:!0,content:(0,X.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,X.jsx)(w,{children:n(`settings.whatIsEch`,`何为 ECH (Encrypted Client Hello)?`)}),(0,X.jsx)(`p`,{className:`text-sm mb-2`,children:n(`settings.echHelpDesc`)}),(0,X.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,X.jsx)(`li`,{children:n(`settings.echHelpBenefit1`)}),(0,X.jsx)(`li`,{children:n(`settings.echHelpBenefit2`)})]}),(0,X.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,X.jsxs)(`a`,{href:`https://en.wikipedia.org/wiki/Encrypted_Client_Hello`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-blue-500 hover:underline`,children:[(0,X.jsx)(c,{size:10}),` `,n(`setup.learnMore`,`了解更多`)]})})]}),children:(0,X.jsx)(T,{icon:`help`,variant:`minimal`,intent:k.NONE})})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(N,{label:n(`settings.enableEch`,`启用重写 ECH`),checked:a,onChange:e=>u(e.currentTarget.checked)}),(0,X.jsx)(`p`,{className:`text-xs opacity-60 leading-relaxed`,children:n(`settings.echDesc`,`针对由 Cloudflare 代理的域名,当查询 HTTPS (Type 65) 或 SVCB (Type 64) 记录且上游未配置 ECH 时,自动重写注入 ECH 参数以保护 SNI 隐私。`)}),a&&(0,X.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100 dark:border-gray-800`,children:(0,X.jsx)(P,{label:n(`settings.echFrontingTitle`,`表层 SNI (ECH Fronting)`),labelInfo:(0,X.jsx)(`span`,{className:`text-xs opacity-60`,children:n(`settings.echFrontingDesc`,`TLS 握手外层可见的伪装域名`)}),children:(0,X.jsx)(M,{fill:!0,placeholder:n(`settings.echFrontingCustomPlaceholder`,`输入自定义表层域名,例如 crypto.cloudflare.com`),value:l,onChange:e=>d(e.target.value),onFocus:e=>e.target.select(),className:`font-mono text-sm`,rightElement:(0,X.jsx)(O,{content:f,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,X.jsx)(T,{variant:`minimal`,icon:`chevron-down`})})})})})]})]})},se=({testInput:e,setTestInput:t,handleDnsTest:n,testing:r,testResult:a})=>{let{t:s}=o();return(0,X.jsxs)(R,{elevation:C.TWO,className:`dark:bg-gray-900 border-t-2 border-blue-500`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-6 font-bold`,children:[(0,X.jsx)(g,{size:20,className:`text-yellow-500 fill-yellow-500`}),` `,s(`settings.testToolTitle`)]}),(0,X.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,X.jsx)(P,{label:s(`settings.testDomain`),className:`mb-0`,children:(0,X.jsx)(M,{fill:!0,large:!0,placeholder:s(`settings.domainPlaceholder`),value:e.domain,onChange:n=>t({...e,domain:n.target.value}),onKeyDown:e=>e.key===`Enter`&&n()})}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-4 items-end`,children:[(0,X.jsx)(P,{label:s(`settings.recordType`),className:`w-32 mb-0`,children:(0,X.jsxs)(j,{fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),children:[(0,X.jsx)(`option`,{value:`A`,children:`A`}),(0,X.jsx)(`option`,{value:`AAAA`,children:`AAAA`}),(0,X.jsx)(`option`,{value:`CNAME`,children:`CNAME`}),(0,X.jsx)(`option`,{value:`TXT`,children:`TXT`})]})}),(0,X.jsx)(P,{label:`\xA0`,className:`mb-0`,children:(0,X.jsx)(T,{size:`large`,intent:k.PRIMARY,icon:`search`,text:s(`settings.runTest`),onClick:n,loading:r})})]}),a&&(0,X.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-100 dark:border-gray-800 space-y-6 animate-in fade-in slide-in-from-top-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-4 items-center`,children:[(0,X.jsx)(F,{large:!0,round:!0,intent:a.action===`PASS`?k.SUCCESS:a.action===`BLOCK`?k.DANGER:k.WARNING,className:`px-4 font-bold`,children:a.action}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.hitRule`)}),(0,X.jsx)(`span`,{className:`text-sm font-bold`,children:a.reason||s(`settings.defaultAllow`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col border-l border-gray-200 dark:border-gray-700 pl-4`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.parseLatency`)}),(0,X.jsx)(`span`,{className:`text-sm font-mono font-bold`,children:a.latency?`${a.latency}ms`:`-`})]}),a.timings&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 border-l border-gray-200 dark:border-gray-700 pl-4 max-w-md`,children:Object.entries(a.timings).map(([e,t])=>(0,X.jsxs)(`div`,{className:`flex gap-1 items-baseline`,children:[(0,X.jsxs)(`span`,{className:`text-[9px] opacity-40 uppercase font-mono`,children:[e,`:`]}),(0,X.jsxs)(`span`,{className:`text-[10px] font-mono font-bold`,children:[t,`ms`]})]},e))}),(0,X.jsx)(A,{}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-white dark:bg-gray-900 px-3 py-1.5 rounded-lg shadow-sm border border-gray-100 dark:border-gray-800`,children:[(0,X.jsx)(p,{size:14,className:`text-red-500`}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40 leading-none`,children:s(`settings.sourceIp`)}),(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[a.client_ip,` (`,a.geo_country,`)`]})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] uppercase font-bold opacity-40 flex items-center gap-1`,children:[(0,X.jsx)(i,{size:10}),` `,s(`settings.answerSection`)]}),(0,X.jsx)(`div`,{className:`font-mono text-sm leading-relaxed bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-100 dark:border-gray-800 shadow-inner`,children:a.answers&&a.answers.length>0?a.answers.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex gap-4 py-1 border-b border-gray-50 dark:border-gray-800 last:border-0 hover:bg-blue-50/50 dark:hover:bg-blue-900/10 transition-colors px-2`,children:[(0,X.jsx)(`span`,{className:`w-16 font-bold text-blue-500`,children:e.type}),(0,X.jsx)(`span`,{className:`flex-1 dark:text-gray-300`,children:e.data}),(0,X.jsxs)(`span`,{className:`text-[10px] opacity-30 italic`,children:[`TTL: `,e.ttl,`s`]})]},t)):(0,X.jsx)(`div`,{className:`p-4 opacity-40 italic text-center`,children:s(`settings.noRecordsReturned`)})})]}),a.diagnostics&&(0,X.jsx)(D,{minimal:!0,intent:a.action===`FAIL`?k.DANGER:k.NONE,className:`text-xs font-mono`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,X.jsx)(`span`,{className:`font-bold uppercase tracking-wider`,children:s(`settings.diagnostics`)}),(0,X.jsx)(`span`,{className:`font-bold`,children:a.action===`FAIL`?a.diagnostics.status>0?`HTTP ${a.diagnostics.status}${a.diagnostics.status_text?` (${a.diagnostics.status_text})`:``}`:`Network / Connection Error`:a.diagnostics.method===`POST`||a.diagnostics.method===`GET`?`HTTP ${a.diagnostics.status}${a.diagnostics.status_text?` (${a.diagnostics.status_text})`:``}`:`Connected (OK)`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-80`,children:[(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-200 dark:bg-gray-700 rounded text-[10px] font-bold`,children:a.diagnostics.method}),(0,X.jsx)(`span`,{className:`break-all`,children:a.diagnostics.upstream_url})]}),a.diagnostics.cf_ray&&(0,X.jsxs)(`div`,{className:`text-[11px] opacity-75`,children:[`CF-Ray: `,(0,X.jsx)(`span`,{className:`font-bold`,children:a.diagnostics.cf_ray})]}),a.diagnostics.error_detail&&a.action===`FAIL`&&(0,X.jsxs)(`div`,{className:`p-2 bg-red-50 dark:bg-red-950/40 rounded border border-red-200 dark:border-red-900/50 text-red-700 dark:text-red-300 break-words`,children:[(0,X.jsxs)(`div`,{className:`font-bold mb-0.5`,children:[s(`settings.errorDetail`),`:`]}),(0,X.jsx)(`div`,{children:a.diagnostics.error_detail})]}),a.diagnostics.response_body&&(0,X.jsxs)(`div`,{className:`p-2 bg-gray-100 dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 break-words text-[11px]`,children:[(0,X.jsxs)(`div`,{className:`font-bold mb-0.5 opacity-60`,children:[s(`settings.upstreamResponse`),`:`]}),(0,X.jsx)(`div`,{className:`line-clamp-3`,children:a.diagnostics.response_body})]})]})})]})]})]})},ce=({profileId:e,toasterRef:t,currentUser:n,onSavingChange:r})=>{let[i,a]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!0),[d,f]=(0,Y.useState)(!1),{t:p}=o();(0,Y.useEffect)(()=>(r?.(d),()=>{r?.(!1)}),[d,r]);let m=(0,Y.useRef)(!0),h=(0,Y.useRef)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)({domain:`o-o.myaddr.l.google.com`,type:`TXT`}),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{(async()=>{try{let t=await K(e);return a(t),y(t.name),c(JSON.parse(t.settings)),i}catch(e){console.error(e)}finally{u(!1)}})()},[e]),(0,Y.useEffect)(()=>{if(!l&&s){let e=setTimeout(()=>{m.current=!1},500);return()=>clearTimeout(e)}},[l,s]),(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let D=async()=>{if(!v||v===i?.name){_(!1);return}try{await G(e,v),a(e=>e?{...e,name:v}:null),_(!1),t?.current?.show({message:p(`settings.nameUpdateSuccess`,`名称已更新`),intent:k.SUCCESS})}catch(e){console.error(e);let n=e.message,r=n;n===`The profile name already exists`?r=p(`common.profileNameExists`,`The profile name already exists`):n===`Invalid Profile Name format`&&(r=p(`common.profileNameFormatError`,`Invalid Profile Name format`)),t?.current?.show({message:r||p(`settings.nameUpdateFailed`,`更新失败`),intent:k.DANGER})}},O=(0,Y.useCallback)(async n=>{if(n){f(!0);try{await J(e,n)}catch(e){console.error(e),t?.current?.show({message:p(`settings.saveError`),intent:k.DANGER,icon:`error`})}finally{f(!1)}}},[e,t,p]),A=(0,Y.useCallback)(e=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{O(e)},600)},[O]),j=(0,Y.useCallback)(e=>{c(e),m.current||A(e)},[A]);return l||!s?(0,X.jsx)(`div`,{className:`p-20 flex justify-center`,children:(0,X.jsx)(E,{})}):(0,X.jsxs)(`div`,{className:`p-0 sm:px-4 lg:px-8 max-w-5xl mx-auto space-y-8 pb-20`,children:[(0,X.jsx)(Z,{profile:i,isEditingName:g,setIsEditingName:_,editName:v,setEditName:y,updateProfileName:D,exportProfile:async()=>{if(!(!i||!s))try{let[n,r]=await Promise.all([U(e).catch(()=>[]),H(e).catch(()=>[])]),a=new Set,o=(n||[]).filter(e=>{let t=(e.pattern||``).trim().toLowerCase();return!t||a.has(t)?!1:(a.add(t),!0)}),c=new Set,l=(r||[]).filter(e=>{let t=(e.url||``).trim().toLowerCase();return!t||c.has(t)?!1:(c.add(t),!0)}).map(e=>({url:e.url,enabled:!!e.enabled})),u={version:2,name:i.name,settings:s,rules:o,filters:l,exported_at:Math.floor(Date.now()/1e3)},d=new Blob([JSON.stringify(u,null,2)],{type:`application/json`}),f=URL.createObjectURL(d),m=document.createElement(`a`);m.href=f,m.download=`dns-worker-${i.name||e}.json`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(f),t?.current?.show({message:p(`settings.exportSuccess`,`配置成功导出`),intent:k.SUCCESS,icon:`download`})}catch(e){console.error(e),t?.current?.show({message:p(`settings.exportError`,`导出失败`),intent:k.DANGER,icon:`error`})}}}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,X.jsx)(ee,{settings:s,setSettings:j}),(0,X.jsx)(te,{settings:s,setSettings:j}),(0,X.jsx)(ne,{settings:s,setSettings:j,isAdmin:n?.role===`admin`,maxRetentionDays:n?.max_log_retention_days??(n?.role===`admin`?30:7)}),(0,X.jsx)(re,{profileId:e,toasterRef:t}),(0,X.jsx)(ie,{settings:s,setSettings:j}),(0,X.jsx)(oe,{settings:s,setSettings:j})]}),(0,X.jsx)(se,{testInput:b,setTestInput:x,handleDnsTest:async()=>{if(b.domain){T(!0),C(null);try{C(await q(e,b))}catch(e){console.error(e)}finally{T(!1)}}},testing:w,testResult:S})]})};export{ce as SettingsView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,B as n,C as r,E as i,Et as a,F as o,G as s,I as c,N as l,P as u,Qt as d,R as f,Tt as p,W as m,at as h,it as g,lt as _,q as v,rt as y,tt as b,w as x,z as S}from"./vendor-react-BmoHsW1x.js";import{S as C,b as w}from"./vendor-icons-other-Bme3ywH9.js";import{A as T,B as E,F as D,L as O,M as k,N as A,O as j,P as M,R as N,S as P,T as F,V as I,a as L,d as R,f as z,i as B,n as V,o as H,r as U,v as W,z as G}from"./vendor-ui-core-CY_WyMIf.js";import{_t as K,t as ee,vt as q}from"./vendor-utils-BWSB0jGn.js";import{E as te,J as ne,K as re,L as ie,R as ae,U as oe,W as J,a as se,at as ce,gt as le,ht as ue,ln as de,n as Y,nt as fe,st as pe,t as me,w as he}from"./index-dXN_pYn1.js";import{t as ge}from"./SwipeableDrawer-B81ANpsc.js";var X=e(C(),1),Z=e(w(),1);const _e=()=>{let{t:e}=d();return(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(T,{className:`font-bold text-gray-900 dark:text-white m-0`,children:e(`setup.title`)}),(0,Z.jsx)(`p`,{className:`bp6-text-muted m-0 mt-1`,children:e(`setup.subtitle`)})]}),(0,Z.jsx)(`div`,{className:`flex items-center`,children:(0,Z.jsx)(me,{})})]})},ve=({isVerifying:e,verifyResult:n,handleVerify:r,isMobile:i,clientInfo:o,showIp:s,setShowIp:c,showLocation:l,setShowLocation:f,traceInfo:p,edgeLocation:m})=>{let{t:h}=d(),{isServerfull:_}=Y();return(0,Z.jsx)(H,{title:h(`setup.verifyConnection`),icon:(0,Z.jsx)(a,{size:16}),children:(0,Z.jsx)(L,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-100 dark:border-gray-800 gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center gap-4 text-center md:text-left`,children:[(0,Z.jsx)(`div`,{className:`p-3 rounded-full ${n?.success?`bg-green-100 text-green-600`:n?`bg-red-100 text-red-600`:`bg-blue-100 text-blue-600`}`,children:e?(0,Z.jsx)(M,{size:24}):n?.success?(0,Z.jsx)(t,{size:24}):(0,Z.jsx)(u,{size:24})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-bold text-lg`,children:e?h(`setup.verifying`):n?.success?h(`setup.connected`):h(`setup.notConnected`)}),(0,Z.jsx)(`div`,{className:`text-sm opacity-60`,children:n?.success?n.profileMatch?h(`setup.profileMatch`):h(`setup.profileMismatch`):h(`setup.verifyHint`)})]})]}),(0,Z.jsx)(A,{size:`large`,intent:n?.success?I.SUCCESS:I.PRIMARY,icon:`refresh`,text:h(`setup.refreshStatus`),onClick:r,loading:e,fill:i})]}),o&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(b,{size:18,className:`text-blue-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:h(`setup.egressIp`)}),(0,Z.jsx)(`button`,{onClick:()=>c(!s),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:s?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(g,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-mono font-bold text-blue-600 dark:text-blue-400 truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!s&&`filter blur-[6px] select-none`),children:o.ip})})]})]}),(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(v,{size:18,className:`text-red-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:h(`setup.currentLocation`)}),(0,Z.jsx)(`button`,{onClick:()=>f(!l),className:`text-gray-400 hover:text-red-500 transition-colors`,children:l?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(g,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!l&&`filter blur-[6px] select-none`),children:(()=>{let e=[o.city,o.region,o.country].filter(e=>!!(e&&e!==`UNKNOWN`));return e.length>0?e.join(`, `):h(`setup.detecting`)})()})})]})]}),(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3 select-none`,children:[(0,Z.jsx)(u,{size:18,className:`text-purple-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:_?h(`setup.serverLocation`,`服务器位置`):h(`setup.edgeServer`)}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,title:_?m||``:m||p?.colo||``,children:_?m||h(`setup.detecting`):m||p?.colo||h(`setup.detecting`)})]})]})]})]})})})},Q=({step:e,className:t,size:n=144})=>{let r=e===1?47:50,i=e===1?45.5:45;return(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:K(`absolute -top-7 -left-7 pointer-events-none select-none z-0`,`text-blue-600/[0.08] dark:text-blue-400/[0.12]`,`transition-all duration-500 ease-out`,`blur-none group-hover:blur-md group-hover:opacity-0`,t),style:{width:n,height:n},children:(0,Z.jsxs)(`svg`,{viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`w-full h-full`,children:[(0,Z.jsx)(`circle`,{cx:`50`,cy:`50`,r:`46`,stroke:`currentColor`,strokeWidth:`4`}),(0,Z.jsx)(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`central`,fill:`currentColor`,fontSize:`80`,fontWeight:`900`,fontFamily:`'Helvetica Neue', Helvetica, Arial, sans-serif`,children:e})]})})},ye=({accessPoints:e,selectedApId:t,onSelectAp:n,accessPointName:r,onManageAccessPoints:i,isMobile:a})=>{let{t:o}=d();return(0,Z.jsxs)(H,{title:o(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Z.jsx)(s,{size:16}),className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,children:[(0,Z.jsx)(Q,{step:1}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full sm:w-auto`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 font-medium`,children:o(`setup.selectAccessPointToConfigure`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.length>0?(0,Z.jsx)(R,{value:t||``,onChange:e=>n(e.target.value),options:e.map(e=>({label:e.name,value:e.id})),className:`font-semibold text-gray-900 dark:text-gray-100`}):(0,Z.jsx)(`div`,{className:`font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:r||o(`setup.defaultAccessPointName`,`设备-1`)}),e.length>0&&(0,Z.jsx)(U,{minimal:!0,round:!0,intent:I.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Z.jsx)(A,{variant:`outlined`,intent:I.NONE,icon:(0,Z.jsx)(l,{size:14}),text:o(`setup.manageAccessPoints`,`管理接入点`),onClick:i,fill:a,className:`shrink-0`})]})})]})},be=({dohUrl:e,copyToClipboard:t,isMobile:n})=>{let{t:r}=d();return(0,Z.jsxs)(H,{title:r(`setup.accessPointTitle`,`Access DoH URL`),icon:`globe`,className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,rightElement:(0,Z.jsx)(F,{placement:`bottom-end`,usePortal:!0,content:(0,Z.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Z.jsx)(k,{children:r(`setup.whatIsDoh`)}),(0,Z.jsx)(`p`,{className:`text-sm mb-2`,children:r(`setup.dohDesc`)}),(0,Z.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,Z.jsx)(`li`,{children:r(`setup.dohBenefit1`)}),(0,Z.jsx)(`li`,{children:r(`setup.dohBenefit2`)})]}),(0,Z.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,Z.jsxs)(`a`,{href:`https://en.wikipedia.org/wiki/DNS_over_HTTPS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-blue-500 hover:underline`,children:[(0,Z.jsx)(h,{size:10}),` `,r(`setup.learnMore`)]})})]}),children:(0,Z.jsx)(A,{icon:`help`,variant:`minimal`,intent:I.NONE})}),children:[(0,Z.jsx)(Q,{step:2}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(`div`,{className:`w-full bg-gray-100 dark:bg-gray-800 p-3 rounded-lg border border-gray-200 dark:border-gray-700 flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-blue-600 dark:text-blue-400 break-all text-xs sm:text-sm`,children:e}),(0,Z.jsx)(A,{intent:I.PRIMARY,icon:`duplicate`,text:r(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0`})]})})]})};function $(e){let t=e.trim();try{return new URL(t.startsWith(`http://`)||t.startsWith(`https://`)?t:`https://${t}`).hostname||t}catch{return t.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0]||t}}function xe(e,t){let n=(e||``).trim(),r=(t||``).trim();if(!r&&n.includes(`(`)&&n.endsWith(`)`)){let e=n.match(/^(.+?)\s*\((.+?)\)$/);e&&(n=e[1].trim(),r=e[2].trim())}let i=n&&n!==`DNS Worker`?n:``,a=r&&r!==`DNS Worker`?r:``;return i&&a?i.toLowerCase()===a.toLowerCase()?i:`${i} - ${a}`:i||a||``}function Se(e,t,n,r){let i,a,o,s;typeof e==`object`?(i=e.profileKey,a=e.profileName,o=e.accessPointName,s=e.origin):(i=e,a=t,s=n||``,o=r);let c=s.trim(),l=$(c),u=`${c}/${i}`,d=xe(a,o),f=crypto.randomUUID(),p=crypto.randomUUID(),m=d?`DNS Worker - ${l} (${d})`:`DNS Worker (${l})`,h=d?`DNS Worker DoH - ${l} (${d})`:`DNS Worker DoH - ${l}`,g=d?`DNS Worker DoH configuration profile for ${d} via ${l}`:`DNS Worker DoH configuration profile via ${l}`,_=d?`Configures encrypted DNS over HTTPS (DoH) for ${d} via ${l}`:`Configures encrypted DNS over HTTPS (DoH) via ${l}`;return ee({PayloadContent:[{DNSSettings:{DNSProtocol:`HTTPS`,ServerHTTPVersion:3,ServerURL:u},OnDemandRules:[{Action:`Connect`,InterfaceTypeMatch:`WiFi`},{Action:`Connect`,InterfaceTypeMatch:`Cellular`},{Action:`Disconnect`}],PayloadDescription:_,PayloadDisplayName:h,PayloadIdentifier:`com.apple.dnsSettings.managed.${f}`,PayloadName:h,PayloadType:`com.apple.dnsSettings.managed`,PayloadUUID:f,PayloadVersion:1}],PayloadDescription:g,PayloadDisplayName:m,PayloadIdentifier:`com.dnsworker.profile.${i}`,PayloadName:m,PayloadRemovalDisallowed:!1,PayloadType:`Configuration`,PayloadUUID:p,PayloadVersion:1},{indent:` `})}const Ce=({isMobile:e,copyToClipboard:t,profileKey:n,profileName:r,accessPointName:a,currentIps:o,dotDomain:s})=>{let{t:l}=d(),{isCloudflare:u}=Y();return(0,Z.jsxs)(`div`,{className:`group relative overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm`,children:[(0,Z.jsx)(Q,{step:3}),(0,Z.jsxs)(V,{id:`setup-tabs`,renderActiveTabPanelOnly:!0,vertical:!e,size:`large`,className:K(`p-4 md:p-6 setup-tabs-container relative z-10 bg-transparent`,e&&[`[&_.bp6-tab-list]:overflow-x-auto!`,`[&_.bp6-tab-list]:flex-nowrap!`,`[&_.bp6-tab-list]:pb-1`,`[&_.bp6-tab-list]:scrollbar-none`,`[&_.bp6-tab-list]:[-ms-overflow-style:none]`,`[&_.bp6-tab-list::-webkit-scrollbar]:hidden`,`[&_.bp6-tab]:shrink-0`]),children:[(0,Z.jsx)(B,{id:`browsers`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(b,{size:16,className:`inline mr-2`}),l(`setup.browsers`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.browserTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.browserSteps`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>t(`chrome://settings/security`),children:l(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Z.jsx)(B,{id:`apple`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(p,{size:16,className:`inline mr-2`}),l(`setup.apple`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.appleTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.appleDesc`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:l(`setup.appleWarning`)}),(0,Z.jsxs)(`div`,{className:`p-6 bg-gray-50 dark:bg-gray-800 rounded-xl border border-dashed border-gray-300 dark:border-gray-700 flex flex-col items-center justify-center`,children:[(0,Z.jsx)(D,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Z.jsx)(A,{intent:I.PRIMARY,text:l(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Se({profileKey:n,profileName:r,accessPointName:a,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),i=URL.createObjectURL(t),o=document.createElement(`a`);o.href=i;let s=xe(r,a),c=$(window.location.origin);o.download=`dns_worker-${(s||c).replace(/[^a-zA-Z0-9_\-\u4e00-\u9fa5]/g,`_`).replace(/_+/g,`_`).replace(/^_|_$/g,``)}-${n}.mobileconfig`,o.click(),URL.revokeObjectURL(i)}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:l(`setup.appleInstallHint`)})]})}),(0,Z.jsx)(B,{id:`windows`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(m,{size:16,className:`inline mr-2`}),l(`setup.windows`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.windowsTitle`)}),(0,Z.jsxs)(`ol`,{className:`list-decimal list-inside space-y-4 text-sm leading-relaxed`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`a`,{href:`ms-settings:network-status`,children:l(`setup.windowsStep0`)})}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep1`)}),(0,Z.jsxs)(`li`,{children:[l(`setup.windowsStep2`),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(n=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(n.ip),icon:`duplicate`,className:`font-mono`,children:n.ip}),!e&&(0,Z.jsx)(`span`,{className:`text-[9px] opacity-40 ml-1`,children:n.area})]},n.ip))})]}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep3`)}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep4`)})]})]})}),(0,Z.jsx)(B,{id:`linux`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(x,{size:16,className:`inline mr-2`}),l(`setup.linux`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.linuxTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.linuxDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:l(`setup.linuxStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`})}),(0,Z.jsx)(A,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`)}})]})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(`p`,{className:`text-sm font-bold`,children:l(`setup.linuxStep2`)})})]})}),(0,Z.jsx)(B,{id:`routeros`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(c,{size:16,className:`inline mr-2`}),l(`setup.routeros`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.routerosTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.routerosDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:l(`setup.routerosStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`})}),(0,Z.jsx)(A,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`)}})]})]}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.routerosNote`)}),(0,Z.jsxs)(`a`,{href:`https://help.mikrotik.com/docs/spaces/ROS/pages/37748767/DNS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-xs text-blue-500 hover:underline`,children:[(0,Z.jsx)(h,{size:10}),` `,l(`setup.routerosDocs`)]})]})}),(0,Z.jsx)(B,{id:`android`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(i,{size:16,className:`inline mr-2`}),l(`setup.android`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.androidTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.androidDesc`)}),u?(0,Z.jsxs)(P,{intent:I.WARNING,icon:`warning-sign`,className:`text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-semibold mb-1`,children:l(`setup.dotUnavailableCfTitle`)}),(0,Z.jsx)(`div`,{children:l(`setup.dotUnavailableCfDesc`)})]}):(()=>{let e=/^(\d{1,3}\.){3}\d{1,3}$/.test(window.location.hostname)||window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname.includes(`:`),r=(s||``).trim().replace(/^\*\./,``),i=!J(r)&&r||(e?``:window.location.hostname);return(0,Z.jsxs)(`div`,{className:`p-4 bg-gray-50 dark:bg-gray-800/60 rounded-xl border border-gray-200 dark:border-gray-700 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-gray-700 dark:text-gray-300`,children:l(`setup.androidDotTitle`,`私有 DNS (DoT / DoQ)`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:l(`setup.androidDotDesc`,`支持 Android 原生“私有 DNS (DoT)”及各类现代 DoQ 客户端。提供商主机名:`)}),i?(0,Z.jsx)(`div`,{className:`space-y-3 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-1.5 sm:gap-2`,children:(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(`${n}.${i}`),icon:`duplicate`,className:`font-mono text-xs sm:text-sm py-1 px-3 self-start`,intent:I.PRIMARY,children:`${n}.${i}`})})}):(0,Z.jsx)(P,{intent:I.WARNING,icon:`warning-sign`,className:`text-xs`,children:l(`setup.androidIpNotice`,`检测到当前通过 IP 或本地地址访问面板。DoT / DoQ 仅接受域名,请在 .env 中配置 SERVERFULL_DOT_DOMAIN (例如 dns.example.com) 后刷新。`)})]})})(),!u&&(0,Z.jsx)(P,{intent:I.PRIMARY,icon:`info-sign`,className:`text-xs`,children:l(`setup.androidWarning`)})]})})]})]})};function we({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=d(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:f,setRenameApId:p,renameApName:m,setRenameApName:h,isRenaming:g,rotatingApId:v,deletingApId:b,newApNameFocused:S,setNewApNameFocused:C,renameApNameFocused:w,setRenameApNameFocused:T,rotateConfirmApId:E,setRotateConfirmApId:D,isSearchOpen:O,setIsSearchOpen:k,searchQuery:A,setSearchQuery:j,filteredAccessPoints:t.filter(e=>e.name.toLowerCase().includes(A.toLowerCase())||e.token.toLowerCase().includes(A.toLowerCase())),isValidApName:e=>se.test(e),handleAdd:async()=>{let a=s.trim();if(a){if(t.some(e=>e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:I.DANGER});return}u(!0);try{await ne(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:I.SUCCESS}),o(!1),c(``),n()}catch(e){let t=e.message||`Failed to create access point`,n=t;if(t.startsWith(`Access point limit exceeded`)){let e=t.match(/\(max (\d+)\)/),r=e?e[1]:`100`;n=i(`setup.accessPointLimitExceeded`,{max:r,defaultValue:`Access Point limit exceeded (max ${r})`})}r.current?.show({message:n,intent:I.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=m.trim();if(!(!a||!f)){if(t.some(e=>e.id!==f&&e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:I.DANGER});return}_(!0);try{await ue(e,f,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:I.SUCCESS}),p(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:I.DANGER})}finally{_(!1)}}},handleRotate:async t=>{y(t);try{await le(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:I.SUCCESS}),n()}catch(e){console.error(e)}finally{y(null)}},handleDelete:async t=>{if(confirm(i(`setup.deleteAccessPointConfirm`))){x(t);try{await fe(e,t),r.current?.show({message:i(`setup.accessPointDeleted`),intent:I.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Te=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=d();return(0,Z.jsxs)(j,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:E.TOP,intent:I.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(z,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsxs)(`div`,{className:G,children:[(0,Z.jsx)(A,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(A,{intent:I.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},Ee=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=d();return(0,Z.jsxs)(j,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:E.TOP,intent:I.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(z,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsxs)(`div`,{className:G,children:[(0,Z.jsx)(A,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(A,{intent:I.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},De=({ap:e,totalApCount:t,toasterRef:i,onRenameTrigger:a,rotateConfirmApId:o,setRotateConfirmApId:c,rotatingApId:l,handleRotate:u,deletingApId:p,handleDelete:m})=>{let{t:h}=d();return(0,Z.jsx)(H,{title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(s,{size:16}),(0,Z.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`DoH URL`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-mono bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400 px-2 py-1 rounded cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/40 transition-colors break-all`,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/${e.token}`),i.current?.show({message:h(`setup.copied`),intent:I.SUCCESS})},title:h(`setup.copyUrl`),children:[(0,Z.jsx)(`span`,{className:`select-all`,children:`${window.location.origin}/${e.token}`}),(0,Z.jsx)(_,{size:14,className:`shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:h(`setup.accessPointToken`)}),(0,Z.jsx)(`span`,{className:`text-sm font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded select-all break-all`,children:e.token})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`Created`}),(0,Z.jsx)(`span`,{className:`text-sm`,children:he(new Date(e.created_at*1e3))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Z.jsx)(A,{small:!0,icon:(0,Z.jsx)(n,{size:14}),text:h(`setup.renameAccessPoint`),onClick:()=>a(e.id,e.name)}),(0,Z.jsx)(F,{isOpen:o===e.id,onInteraction:e=>{e||c(null)},content:(0,Z.jsxs)(`div`,{className:`p-4 space-y-3 dark:bg-gray-800 dark:text-white max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed`,children:h(`setup.rotateTokenConfirmDesc`,`Rotating the key will immediately disconnect devices using the old key. Are you sure you want to continue?`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(A,{small:!0,minimal:!0,text:h(`common.cancel`,`Cancel`),onClick:()=>c(null)}),(0,Z.jsx)(A,{small:!0,intent:I.DANGER,text:h(`common.confirm`,`Confirm`),onClick:()=>{c(null),u(e.id)}})]})]}),placement:`top`,children:(0,Z.jsx)(A,{small:!0,icon:(0,Z.jsx)(f,{size:14}),text:h(`setup.rotateToken`),loading:l===e.id,onClick:()=>c(e.id)})}),(0,Z.jsx)(A,{small:!0,intent:I.DANGER,icon:(0,Z.jsx)(r,{size:14}),text:h(`setup.deleteAccessPoint`),loading:p===e.id,onClick:()=>m(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},Oe=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:a,onRefresh:s,toasterRef:c})=>{let{t:l}=d(),{isAddDialogOpen:u,setIsAddDialogOpen:f,newApName:p,setNewApName:m,isAdding:h,renameApId:g,setRenameApId:_,renameApName:v,setRenameApName:y,isRenaming:b,rotatingApId:x,deletingApId:C,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:O,setRotateConfirmApId:k,isSearchOpen:j,setIsSearchOpen:N,searchQuery:P,setSearchQuery:F,filteredAccessPoints:L,isValidApName:R,handleAdd:B,handleRename:V,handleRotate:H,handleDelete:U}=we({profileId:n,accessPoints:i,onRefresh:s,toasterRef:c});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ge,{isOpen:e,onClose:t,title:j?(0,Z.jsx)(z,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:P,onChange:e=>F(e.target.value),rightElement:(0,Z.jsx)(A,{icon:`cross`,minimal:!0,onClick:()=>{N(!1),F(``)}}),autoFocus:!0}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Z.jsx)(A,{icon:(0,Z.jsx)(o,{size:14}),minimal:!0,onClick:()=>N(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Z.jsx)(A,{fill:!0,intent:I.PRIMARY,icon:(0,Z.jsx)(S,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>f(!0),large:!0}),a?(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(M,{})}):(0,Z.jsx)(`div`,{className:`space-y-4 mt-4`,children:L.map(e=>(0,Z.jsx)(De,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),y(t)},rotateConfirmApId:O,setRotateConfirmApId:k,rotatingApId:x,handleRotate:H,deletingApId:C,handleDelete:U},e.id))})]}),(0,Z.jsx)(Te,{isOpen:u,onClose:()=>{f(!1),m(``)},newApName:p,setNewApName:m,newApNameFocused:w,setNewApNameFocused:T,handleAdd:B,isAdding:h,isValidApName:R}),(0,Z.jsx)(Ee,{isOpen:!!g,onClose:()=>_(null),renameApName:v,setRenameApName:y,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:V,isRenaming:b,isValidApName:R})]})},ke=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=de(),{t:a}=d(),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=async()=>{l(!0);try{s(await ce(e))}catch(e){console.error(e)}finally{l(!1)}};(0,X.useEffect)(()=>{h()},[e]);let[g,_]=(0,X.useState)(n||``);(0,X.useEffect)(()=>{n?_(n):e&&pe(e).then(e=>{e?.name&&_(e.name)}).catch(()=>{})},[e,n]);let v=(0,X.useMemo)(()=>o.length===0?null:o.find(e=>e.id===p)||o[0],[o,p]),y=v?v.token:t,b=v?v.name:void 0,x=`${window.location.origin}/${y}`,[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)({ipv4:[],ipv6:[]}),[L,R]=(0,X.useState)(null),z=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:I.SUCCESS})},B=async()=>{T(!0),R(null);try{let[t,n]=await Promise.all([ie(),oe()]);if(t.ip&&(t.country===`UNKNOWN`||!t.country))try{let e=await fetch(`/api/geoip?ip=${encodeURIComponent(t.ip)}`);if(e.ok){let n=await e.json();n.success&&(n.country&&(t.country=n.country),n.region&&(t.region=n.region),n.city&&(t.city=n.city),n.timezone?.id&&(t.timezone=n.timezone.id),n.connection?.org&&(t.asOrganization=n.connection.org))}}catch{}C(t),j(n),t.timezone&&t.timezone!==`UNKNOWN`&&te(t.timezone);let r=window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname===`::1`||window.location.hostname.startsWith(`192.168.`)||window.location.hostname.startsWith(`10.`)||/^172\.(1[6-9]|2\d|3[01])\./.test(window.location.hostname),i=!!(t.dotDomain&&!J(t.dotDomain)),a=r&&i||i?t.dotDomain:window.location.hostname||``;ae(a).then(e=>N(e)).catch(e=>console.warn(`Failed fetching domain geo location:`,e)),re(a).then(e=>F(e)).catch(e=>console.warn(`Failed resolving domain DNS IPs:`,e)),R({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{T(!1)}};(0,X.useEffect)(()=>{B()},[e]);let V=(0,X.useMemo)(()=>{let e=[];for(let t of P.ipv4)e.push({ip:t,area:`IPv4`});for(let t of P.ipv6)e.push({ip:t,area:`IPv6`});return e},[P]);return(0,Z.jsxs)(`div`,{className:`mx-auto space-y-8 pb-24 ${i?`p-1`:`px-8 max-w-5xl`}`,children:[(0,Z.jsx)(_e,{isMobile:i}),(0,Z.jsx)(ve,{isVerifying:w,verifyResult:L,handleVerify:B,isMobile:i,clientInfo:S,showIp:E,setShowIp:D,showLocation:O,setShowLocation:k,traceInfo:A,edgeLocation:M}),(0,Z.jsx)(ye,{accessPoints:o,selectedApId:v?.id||null,onSelectAp:m,accessPointName:b,onManageAccessPoints:()=>f(!0),isMobile:i}),(0,Z.jsx)(be,{dohUrl:x,copyToClipboard:z,isMobile:i}),(0,Z.jsx)(Ce,{isMobile:i,copyToClipboard:z,profileKey:y,profileName:g||void 0,accessPointName:b,currentIps:V,dotDomain:S?.dotDomain}),(0,Z.jsx)(Oe,{isOpen:u,onClose:()=>f(!1),profileId:e,isMobile:i,accessPoints:o,loading:c,onRefresh:h,toasterRef:r})]})};export{ke as SetupView};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{S as t,b as n}from"./vendor-icons-other-Bme3ywH9.js";import{B as r,g as i}from"./vendor-ui-core-sfZn2C08.js";var a=e(t(),1),o=e(n(),1);const s=({isOpen:e,onClose:t,title:n,icon:s,size:c,className:l,children:u,...d})=>{let f=(0,a.useRef)(null),p=e=>{let t=e.touches[0];f.current={x:t.clientX,y:t.clientY}},m=e=>{if(!f.current)return;let n=e.touches[0],r=n.clientX-f.current.x,i=n.clientY-f.current.y;r>80&&Math.abs(r)>Math.abs(i)*1.5&&(t(),f.current=null)},h=()=>{f.current=null},g=`dark:bg-gray-900 dark:text-white shadow-none! bg-transparent! bg-bulletin! backdrop-blur-sm! ${l||``}`;return(0,o.jsx)(i,{isOpen:e,onClose:t,title:n,icon:s,position:r.RIGHT,size:c,className:g,...d,children:(0,o.jsx)(`div`,{className:`p-6 space-y-4 overflow-y-auto h-full pb-safe`,onTouchStart:p,onTouchMove:m,onTouchEnd:h,children:u})})};export{s as t};
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{S as t,b as n}from"./vendor-icons-other-Bme3ywH9.js";import{B as r,g as i}from"./vendor-ui-core-CY_WyMIf.js";var a=e(t(),1),o=e(n(),1);const s=({isOpen:e,onClose:t,title:n,icon:s,size:c,className:l,children:u,...d})=>{let f=(0,a.useRef)(null),p=e=>{let t=e.touches[0];f.current={x:t.clientX,y:t.clientY}},m=e=>{if(!f.current)return;let n=e.touches[0],r=n.clientX-f.current.x,i=n.clientY-f.current.y;r>80&&Math.abs(r)>Math.abs(i)*1.5&&(t(),f.current=null)},h=()=>{f.current=null},g=`dark:bg-gray-900 dark:text-white shadow-none! bg-transparent! bg-bulletin! backdrop-blur-sm! ${l||``}`;return(0,o.jsx)(i,{isOpen:e,onClose:t,title:n,icon:s,position:r.RIGHT,size:c,className:g,...d,children:(0,o.jsx)(`div`,{className:`p-6 space-y-4 overflow-y-auto h-full pb-safe`,onTouchStart:p,onTouchMove:m,onTouchEnd:h,children:u})})};export{s as t};