dns-worker 1.2.2 → 1.2.3-alpha.ad2f231

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 (43) hide show
  1. package/README.md +11 -11
  2. package/dist/serverfull.mjs +318 -198
  3. package/dist/serverfull.mjs.map +4 -4
  4. package/migrations/0068_add_isp_hourly_rollups.sql +34 -0
  5. package/migrations/0069_drop_redundant_logs_indexes.sql +7 -0
  6. package/package.json +7 -7
  7. package/static/assets/AccountView-CzK6jlJu.js +4 -0
  8. package/static/assets/AnalyticsView-Bp2qt8dV.js +2 -0
  9. package/static/assets/DestinationMap-ZgPnUgEF.js +1 -0
  10. package/static/assets/FilteringView-mzs-ZoqY.js +1 -0
  11. package/static/assets/LogsView-Cba7lpWX.js +5 -0
  12. package/static/assets/{RulesView-Br-TGI0S.js → RulesView-DZzsSQCl.js} +1 -1
  13. package/static/assets/SettingsView-BZHg4Pph.js +1 -0
  14. package/static/assets/SetupView-C1qEcs8Y.js +1 -0
  15. package/static/assets/SystemView-BdTAOyN-.js +1 -0
  16. package/static/assets/{TrendChart-CTcw6KTh.js → TrendChart-hjrEEcbA.js} +1 -1
  17. package/static/assets/date-DwyPy0zg.js +1 -0
  18. package/static/assets/{de-DE-B5QHxkUz.js → de-DE-ChqTmNoZ.js} +15 -2
  19. package/static/assets/{es-ES-DVG_43hu.js → es-ES-DJyD_FHe.js} +15 -2
  20. package/static/assets/{fr-FR-C_o9fNbs.js → fr-FR-BA1vQe8U.js} +15 -2
  21. package/static/assets/index-BLk8QVje.js +30 -0
  22. package/static/assets/{index-Dya4nLaI.css → index-BlF_HYXE.css} +1 -1
  23. package/static/assets/{ja-JP-h0clNIRK.js → ja-JP-ndkxicCP.js} +15 -2
  24. package/static/assets/{ko-KR-Rr4R4ErI.js → ko-KR--ebX4PUe.js} +15 -2
  25. package/static/assets/{ru-RU-BKC7ewDw.js → ru-RU-DOZjzIx2.js} +15 -2
  26. package/static/assets/{services-OOd28yfV.js → services-OE4AhS4L.js} +1 -1
  27. package/static/assets/{sqlite.worker-DfuIqYyd.js → sqlite.worker-BQk-r3bK.js} +8 -4
  28. package/static/assets/{useLogsE2ee-BG2dwwV0.js → useLogsE2ee-cajzvZkK.js} +1 -1
  29. package/static/assets/{vi-VN-DO0is0TQ.js → vi-VN-DgVTajq8.js} +15 -2
  30. package/static/assets/{zh-CN-D9qLjfXt.js → zh-CN-C_Po-z3K.js} +15 -2
  31. package/static/assets/{zh-TW-qJFPjt4I.js → zh-TW-C4h6ckgV.js} +15 -2
  32. package/static/index.html +2 -2
  33. package/static/sw.js +1 -1
  34. package/static/assets/AccountView-CKn8YPlP.js +0 -4
  35. package/static/assets/AnalyticsView-DtwAFAS2.js +0 -2
  36. package/static/assets/DestinationMap-BQ-SJwVY.js +0 -1
  37. package/static/assets/FilteringView-C3o6cUlv.js +0 -1
  38. package/static/assets/LogsView-CB5qSS6F.js +0 -5
  39. package/static/assets/SettingsView-DfNd-8A4.js +0 -1
  40. package/static/assets/SetupView-CWmyacJn.js +0 -1
  41. package/static/assets/SystemView-C-AbCiPA.js +0 -1
  42. package/static/assets/date-CsFxSeKu.js +0 -1
  43. package/static/assets/index-DAjmisEt.js +0 -17
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{Ct as t,Et as n,It as r,Ot as i,V as a,_t as o,it as s,k as c,nn as l,w as u,wt as d}from"./vendor-react-DYK5a2J9.js";import{S as f,b as p}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{C as m,E as h,F as g,H as _,P as v,S as y,U as b,b as x,d as S,f as C,k as w,p as T,r as E,u as D,w as O,y as k}from"./vendor-ui-core-CodM8CpF.js";import{_t as A}from"./vendor-utils-Bab4qB3W.js";import{H as j,Ot as M,gn as N,h as P,mt as F,nt as I,ut as L,vt as R}from"./index-DAjmisEt.js";var z=e(f(),1),B=e(p(),1);const V=({newRule:e,setNewRule:t,addRule:n,loading:r})=>{let{t:i}=l();return(0,B.jsx)(y,{elevation:b.ONE,className:`mb-8 p-6`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col lg:flex-row justify-between gap-4 items-start lg:items-end`,children:[(0,B.jsx)(`div`,{className:`w-full lg:w-48`,children:(0,B.jsx)(T,{label:i(`rules.action`),labelFor:`rule-type`,className:`mb-0`,children:(0,B.jsx)(S,{id:`rule-type`,fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:i(`rules.typeBlock`),value:`BLOCK`},{label:i(`rules.typeAllow`),value:`ALLOW`},{label:i(`rules.typeRedirect`),value:`REDIRECT`}]})})}),(0,B.jsx)(`div`,{className:`flex-1 w-full`,children:(0,B.jsx)(T,{label:i(`rules.pattern`),labelFor:`rule-pattern`,className:`mb-0`,children:(0,B.jsx)(C,{id:`rule-pattern`,size:`large`,placeholder:i(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})}),e.type!==`REDIRECT`&&(0,B.jsx)(T,{label:``,labelFor:``,className:`mb-0`,children:(0,B.jsx)(v,{intent:_.PRIMARY,size:`large`,icon:(0,B.jsx)(a,{size:18}),onClick:n,loading:r,disabled:r,children:i(`rules.addRule`)})})]}),e.type===`REDIRECT`&&(0,B.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,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,B.jsx)(s,{size:16}),(0,B.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:i(`rules.redirectSettings`)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,B.jsx)(T,{label:i(`rules.aRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.ipv4Placeholder`),value:e.v_a,onChange:n=>t({...e,v_a:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.aaaaRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.ipv6Placeholder`),value:e.v_aaaa,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.cnameRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.cnamePlaceholder`),value:e.v_cname,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.txtRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.txtPlaceholder`),value:e.v_txt,onChange:n=>t({...e,v_txt:n.target.value})})})]}),(0,B.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 flex justify-end`,children:(0,B.jsx)(v,{intent:_.PRIMARY,large:!0,icon:(0,B.jsx)(a,{size:18}),onClick:n,text:i(`rules.saveRedirectRule`),loading:r,disabled:r})})]})]})})},H=({rules:e,startEdit:r,getBlockDetail:a})=>{let{t:s}=l(),[u,f]=(0,z.useState)(`created_at`),[p,m]=(0,z.useState)(`desc`),h=e=>{u===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`?a():s(`rules.detailAllow`,`Forward to upstream`),v=(0,z.useMemo)(()=>[...e].sort((e,t)=>{let n=0;switch(u){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,u,p,a,s]),y=[{key:`action`,header:s(`rules.tableAction`),headerClassName:`w-32`,render:e=>(0,B.jsxs)(B.Fragment,{children:[e.type===`BLOCK`&&(0,B.jsx)(E,{intent:_.DANGER,minimal:!0,icon:(0,B.jsx)(c,{size:12,className:`mr-1`}),children:s(`rules.labelBlock`)}),e.type===`ALLOW`&&(0,B.jsx)(E,{intent:_.SUCCESS,minimal:!0,icon:(0,B.jsx)(o,{size:12,className:`mr-1`}),children:s(`rules.labelAllow`)}),e.type===`REDIRECT`&&(0,B.jsx)(E,{intent:_.WARNING,minimal:!0,icon:(0,B.jsx)(n,{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=>(0,B.jsx)(`span`,{children:e.pattern})},{key:`details`,header:s(`rules.tableDetails`),cellClassName:`py-2`,render:e=>(0,B.jsx)(B.Fragment,{children:e.type===`REDIRECT`?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.v_a&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`A: `,e.v_a]}),e.v_aaaa&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`AAAA: `,e.v_aaaa]}),e.v_cname&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`CNAME: `,e.v_cname]}),e.v_txt&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`TXT: `,e.v_txt]})]}):e.type===`BLOCK`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:s(`rules.detailBlock`)}),(0,B.jsx)(E,{minimal:!0,round:!0,className:`text-[9px] px-1.5 opacity-70`,children:a()})]}):(0,B.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?P(new Date(e.created_at*1e3)):`—`}];return(0,B.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,B.jsxs)(D,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{children:y.map(e=>(0,B.jsx)(`th`,{onClick:()=>h(e.key),className:A(e.headerClassName,`cursor-pointer select-none transition-colors hover:text-blue-500`),title:s(`rules.clickToSort`,`点击排序`),children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{children:e.header}),u===e.key?p===`asc`?(0,B.jsx)(t,{size:13,className:`text-blue-500 shrink-0`}):(0,B.jsx)(i,{size:13,className:`text-blue-500 shrink-0`}):(0,B.jsx)(d,{size:12,className:`opacity-30 hover:opacity-75 shrink-0`})]})},e.key))})}),(0,B.jsx)(`tbody`,{children:v.map(e=>(0,B.jsx)(`tr`,{onClick:()=>r(e),className:`cursor-pointer`,children:y.map(t=>(0,B.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},U=({editRule:e,setEditRule:t,saveEditRule:n,cancelEdit:r,deleteRule:i,isSaving:a,isDeleting:o})=>{let{t:c}=l();return(0,B.jsxs)(w,{isOpen:!!e,onClose:r,title:c(`rules.editRule`,`Edit Rule`),style:{width:`600px`},children:[(0,B.jsx)(x,{children:e&&(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex gap-4`,children:[(0,B.jsx)(T,{label:c(`rules.action`),className:`w-40 mb-0`,children:(0,B.jsx)(S,{fill:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:c(`rules.typeBlock`),value:`BLOCK`},{label:c(`rules.typeAllow`),value:`ALLOW`},{label:c(`rules.typeRedirect`),value:`REDIRECT`}]})}),(0,B.jsx)(T,{label:c(`rules.pattern`),className:`flex-1 mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})]}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`rules.wildcardDisclaimer`)}),e.type===`REDIRECT`&&(0,B.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,B.jsx)(s,{size:14}),(0,B.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:c(`rules.redirectSettings`)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,B.jsx)(T,{label:c(`rules.aRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.ipv4Placeholder`),value:e.v_a||``,onChange:n=>t({...e,v_a:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.aaaaRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.ipv6Placeholder`),value:e.v_aaaa||``,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.cnameRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.cnamePlaceholder`),value:e.v_cname||``,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.txtRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.txtPlaceholder`),value:e.v_txt||``,onChange:n=>t({...e,v_txt:n.target.value})})})]})]})]})}),(0,B.jsx)(k,{actions:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(v,{onClick:r,disabled:a||o,children:c(`rules.cancel`,`Cancel`)}),(0,B.jsx)(v,{intent:_.PRIMARY,onClick:n,loading:a,disabled:a||o,children:c(`rules.saveChanges`,`Save Changes`)})]}),children:(0,B.jsx)(v,{icon:(0,B.jsx)(u,{size:14}),intent:_.DANGER,text:c(`rules.delete`,`Delete`),onClick:()=>{e&&i(e.id)},loading:o,disabled:a||o})})]})},W=({profileId:e,prefill:t,onPrefillUsed:n,toasterRef:i})=>{let a=r(),[o,s]=(0,z.useState)([]),[c,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!0),[p,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!1),[S,C]=(0,z.useState)(!1),{t:w}=l(),T=N(),[D,k]=(0,z.useState)({type:`BLOCK`,pattern:``,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),[P,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(`www.okx.com`),[q,J]=(0,z.useState)(!1);(0,z.useEffect)(()=>{j().then(e=>{e.substituteDomain&&K(e.substituteDomain)}).catch(e=>console.warn(`Failed to fetch clientInfo for substituteDomain:`,e))},[]);let Y=(0,z.useMemo)(()=>{let e=window.location.hostname.trim().toLowerCase();return e?o.some(t=>{if(t.type!==`REDIRECT`)return!1;let n=t.pattern.trim().toLowerCase();return n===e||n===`*.${e}`}):!1},[o]),X=()=>{J(!1),k({type:`REDIRECT`,pattern:window.location.hostname,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:G||`www.okx.com`}),setTimeout(()=>{document.getElementById(`rule-pattern`)?.focus()},100)};(0,z.useEffect)(()=>{t&&(k({type:t.type,pattern:t.domain,include_subdomains:!1,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 Z=async()=>{f(!0);try{let[t,n]=await Promise.all([R(e),F(e)]);s(t),u(JSON.parse(n.settings||`{}`))}catch(e){console.error(`Failed to fetch data`,e)}finally{f(!1)}};return(0,z.useEffect)(()=>{Z()},[e]),(0,B.jsxs)(`div`,{className:A(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,T?`p-1`:`px-8`),children:[(0,B.jsx)(`div`,{className:`mb-8`,children:(0,B.jsxs)(`div`,{className:`flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,B.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[T?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(O,{minimal:!0,fill:T,className:`flex-1`,children:[(0,B.jsx)(v,{active:!0,onClick:()=>a(`/dash/${e}/rules`),text:w(`rules.title`),large:!0}),(0,B.jsx)(v,{active:!1,onClick:()=>a(`/dash/${e}/filter`),text:w(`filtering.title`),large:!0})]}),d&&(0,B.jsx)(g,{size:16})]}):(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`bp6-heading m-0`,children:w(`rules.title`)}),d&&(0,B.jsx)(g,{size:20})]}),(0,B.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:w(`rules.subtitle`)})]}),!d&&!Y&&(0,B.jsx)(`div`,{className:`flex items-center gap-3 self-start md:self-auto`,children:(0,B.jsx)(h,{isOpen:q,onInteraction:J,placement:`bottom-end`,portalClassName:`z-20000`,content:(0,B.jsxs)(`div`,{className:`p-4 w-72 sm:w-80 space-y-3 text-sm`,children:[(0,B.jsx)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300 leading-relaxed m-0`,children:w(`rules.addSelfRedirectPrompt`,`是否增加指向本站的 CNAME 规则,用于地区网络优化(中国大陆用户推荐)?`)}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,B.jsx)(v,{size:`small`,variant:`minimal`,text:w(`common.no`,`否`),onClick:()=>J(!1)}),(0,B.jsx)(v,{size:`small`,intent:_.PRIMARY,text:w(`common.yes`,`是`),onClick:X})]})]}),children:(0,B.jsx)(E,{minimal:!0,interactive:!0,intent:_.PRIMARY,className:`cursor-pointer select-none font-medium`,children:w(`rules.addSelfRedirectTag`,`增加本站重定向?`)})})})]})}),(0,B.jsx)(m,{intent:_.PRIMARY,icon:`info-sign`,className:`mb-6`,children:(0,B.jsx)(`p`,{children:w(`rules.wildcardDisclaimer`,`若要匹配子域名,需使用通配符 *.example.com ,example.com 不会匹配子域名。`)})}),(0,B.jsx)(V,{newRule:D,setNewRule:k,addRule:async()=>{let t=D.pattern.trim();if(!t){i?.current?.show({message:w(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:_.DANGER});return}let n=t.toLowerCase();if(o.some(e=>e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:w(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:_.DANGER});return}y(!0);try{await I(e,{...D,pattern:t,include_subdomains:0}),i?.current?.show({message:w(`rules.addSuccess`,`Rule added successfully`),intent:_.SUCCESS}),k({type:`BLOCK`,pattern:``,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),await Z()}catch(e){i?.current?.show({message:e.message||w(`rules.addFailed`,`Failed to add rule`),intent:_.DANGER})}finally{y(!1)}},loading:p}),d&&o.length===0?(0,B.jsxs)(`div`,{className:`p-16 flex flex-col justify-center items-center gap-3`,children:[(0,B.jsx)(g,{size:32}),(0,B.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 font-medium`,children:w(`common.loading`,`加载中...`)})]}):o.length===0?(0,B.jsx)(m,{title:w(`rules.noRulesTitle`),children:w(`rules.noRulesDesc`)}):(0,B.jsxs)(`div`,{className:`relative`,children:[d&&(0,B.jsx)(`div`,{className:`absolute inset-0 bg-white/40 dark:bg-gray-900/40 backdrop-blur-xs flex items-center justify-center z-10 rounded-lg`,children:(0,B.jsx)(g,{size:32})}),(0,B.jsx)(H,{rules:o,startEdit:e=>{W({...e,include_subdomains:e.include_subdomains===1||e.include_subdomains===!0})},getBlockDetail:()=>{if(!c)return w(`rules.detailBlock`);switch(c.block_mode||`NULL_IP`){case`NXDOMAIN`:return`NXDOMAIN`;case`NODATA`:return`NODATA`;case`CUSTOM_IP`:return`${c.custom_block_ipv4||`0.0.0.0`} / ${c.custom_block_ipv6||`::`}`;default:return`0.0.0.0 / ::`}}})]}),(0,B.jsx)(U,{editRule:P,setEditRule:W,saveEditRule:async()=>{if(!P)return;let t=P.pattern.trim();if(!t){i?.current?.show({message:w(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:_.DANGER});return}let n=t.toLowerCase();if(o.some(e=>e.id!==P.id&&e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:w(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:_.DANGER});return}x(!0);try{await M(e,{...P,pattern:t,include_subdomains:0}),i?.current?.show({message:w(`rules.updateSuccess`,`Rule updated successfully`),intent:_.SUCCESS}),W(null),await Z()}catch(e){i?.current?.show({message:e.message||w(`rules.updateFailed`,`Failed to update rule`),intent:_.DANGER})}finally{x(!1)}},cancelEdit:()=>{W(null)},deleteRule:async t=>{C(!0);try{await L(e,t)}catch(e){console.error(e)}finally{C(!1)}W(null),await Z()},isSaving:b,isDeleting:S})]})};export{W as RulesView};
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{Ct as t,Et as n,It as r,Ot as i,V as a,_t as o,it as s,k as c,nn as l,w as u,wt as d}from"./vendor-react-DYK5a2J9.js";import{S as f,b as p}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{C as m,E as h,F as g,H as _,P as v,S as y,U as b,b as x,d as S,f as C,k as w,p as T,r as E,u as D,w as O,y as k}from"./vendor-ui-core-CodM8CpF.js";import{_t as A}from"./vendor-utils-Bab4qB3W.js";import{U as j,_n as M,dt as N,g as P,ht as F,kt as I,rt as L,yt as R}from"./index-BLk8QVje.js";var z=e(f(),1),B=e(p(),1);const V=({newRule:e,setNewRule:t,addRule:n,loading:r})=>{let{t:i}=l();return(0,B.jsx)(y,{elevation:b.ONE,className:`mb-8 p-6`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col lg:flex-row justify-between gap-4 items-start lg:items-end`,children:[(0,B.jsx)(`div`,{className:`w-full lg:w-48`,children:(0,B.jsx)(T,{label:i(`rules.action`),labelFor:`rule-type`,className:`mb-0`,children:(0,B.jsx)(S,{id:`rule-type`,fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:i(`rules.typeBlock`),value:`BLOCK`},{label:i(`rules.typeAllow`),value:`ALLOW`},{label:i(`rules.typeRedirect`),value:`REDIRECT`}]})})}),(0,B.jsx)(`div`,{className:`flex-1 w-full`,children:(0,B.jsx)(T,{label:i(`rules.pattern`),labelFor:`rule-pattern`,className:`mb-0`,children:(0,B.jsx)(C,{id:`rule-pattern`,size:`large`,placeholder:i(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})}),e.type!==`REDIRECT`&&(0,B.jsx)(T,{label:``,labelFor:``,className:`mb-0`,children:(0,B.jsx)(v,{intent:_.PRIMARY,size:`large`,icon:(0,B.jsx)(a,{size:18}),onClick:n,loading:r,disabled:r,children:i(`rules.addRule`)})})]}),e.type===`REDIRECT`&&(0,B.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,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,B.jsx)(s,{size:16}),(0,B.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:i(`rules.redirectSettings`)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,B.jsx)(T,{label:i(`rules.aRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.ipv4Placeholder`),value:e.v_a,onChange:n=>t({...e,v_a:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.aaaaRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.ipv6Placeholder`),value:e.v_aaaa,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.cnameRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.cnamePlaceholder`),value:e.v_cname,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,B.jsx)(T,{label:i(`rules.txtRecord`),labelInfo:i(`rules.optional`),children:(0,B.jsx)(C,{placeholder:i(`rules.txtPlaceholder`),value:e.v_txt,onChange:n=>t({...e,v_txt:n.target.value})})})]}),(0,B.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 flex justify-end`,children:(0,B.jsx)(v,{intent:_.PRIMARY,large:!0,icon:(0,B.jsx)(a,{size:18}),onClick:n,text:i(`rules.saveRedirectRule`),loading:r,disabled:r})})]})]})})},H=({rules:e,startEdit:r,getBlockDetail:a})=>{let{t:s}=l(),[u,f]=(0,z.useState)(`created_at`),[p,m]=(0,z.useState)(`desc`),h=e=>{u===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`?a():s(`rules.detailAllow`,`Forward to upstream`),v=(0,z.useMemo)(()=>[...e].sort((e,t)=>{let n=0;switch(u){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,u,p,a,s]),y=[{key:`action`,header:s(`rules.tableAction`),headerClassName:`w-32`,render:e=>(0,B.jsxs)(B.Fragment,{children:[e.type===`BLOCK`&&(0,B.jsx)(E,{intent:_.DANGER,minimal:!0,icon:(0,B.jsx)(c,{size:12,className:`mr-1`}),children:s(`rules.labelBlock`)}),e.type===`ALLOW`&&(0,B.jsx)(E,{intent:_.SUCCESS,minimal:!0,icon:(0,B.jsx)(o,{size:12,className:`mr-1`}),children:s(`rules.labelAllow`)}),e.type===`REDIRECT`&&(0,B.jsx)(E,{intent:_.WARNING,minimal:!0,icon:(0,B.jsx)(n,{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=>(0,B.jsx)(`span`,{children:e.pattern})},{key:`details`,header:s(`rules.tableDetails`),cellClassName:`py-2`,render:e=>(0,B.jsx)(B.Fragment,{children:e.type===`REDIRECT`?(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.v_a&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`A: `,e.v_a]}),e.v_aaaa&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`AAAA: `,e.v_aaaa]}),e.v_cname&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`CNAME: `,e.v_cname]}),e.v_txt&&(0,B.jsxs)(E,{minimal:!0,className:`font-mono text-[10px]`,children:[`TXT: `,e.v_txt]})]}):e.type===`BLOCK`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:s(`rules.detailBlock`)}),(0,B.jsx)(E,{minimal:!0,round:!0,className:`text-[9px] px-1.5 opacity-70`,children:a()})]}):(0,B.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?P(new Date(e.created_at*1e3)):`—`}];return(0,B.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,B.jsxs)(D,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{children:y.map(e=>(0,B.jsx)(`th`,{onClick:()=>h(e.key),className:A(e.headerClassName,`cursor-pointer select-none transition-colors hover:text-blue-500`),title:s(`rules.clickToSort`,`点击排序`),children:(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{children:e.header}),u===e.key?p===`asc`?(0,B.jsx)(t,{size:13,className:`text-blue-500 shrink-0`}):(0,B.jsx)(i,{size:13,className:`text-blue-500 shrink-0`}):(0,B.jsx)(d,{size:12,className:`opacity-30 hover:opacity-75 shrink-0`})]})},e.key))})}),(0,B.jsx)(`tbody`,{children:v.map(e=>(0,B.jsx)(`tr`,{onClick:()=>r(e),className:`cursor-pointer`,children:y.map(t=>(0,B.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},U=({editRule:e,setEditRule:t,saveEditRule:n,cancelEdit:r,deleteRule:i,isSaving:a,isDeleting:o})=>{let{t:c}=l();return(0,B.jsxs)(w,{isOpen:!!e,onClose:r,title:c(`rules.editRule`,`Edit Rule`),style:{width:`600px`},children:[(0,B.jsx)(x,{children:e&&(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex gap-4`,children:[(0,B.jsx)(T,{label:c(`rules.action`),className:`w-40 mb-0`,children:(0,B.jsx)(S,{fill:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:c(`rules.typeBlock`),value:`BLOCK`},{label:c(`rules.typeAllow`),value:`ALLOW`},{label:c(`rules.typeRedirect`),value:`REDIRECT`}]})}),(0,B.jsx)(T,{label:c(`rules.pattern`),className:`flex-1 mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})]}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`rules.wildcardDisclaimer`)}),e.type===`REDIRECT`&&(0,B.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,B.jsx)(s,{size:14}),(0,B.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:c(`rules.redirectSettings`)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,B.jsx)(T,{label:c(`rules.aRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.ipv4Placeholder`),value:e.v_a||``,onChange:n=>t({...e,v_a:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.aaaaRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.ipv6Placeholder`),value:e.v_aaaa||``,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.cnameRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.cnamePlaceholder`),value:e.v_cname||``,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,B.jsx)(T,{label:c(`rules.txtRecord`),className:`mb-0`,children:(0,B.jsx)(C,{placeholder:c(`rules.txtPlaceholder`),value:e.v_txt||``,onChange:n=>t({...e,v_txt:n.target.value})})})]})]})]})}),(0,B.jsx)(k,{actions:(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(v,{onClick:r,disabled:a||o,children:c(`rules.cancel`,`Cancel`)}),(0,B.jsx)(v,{intent:_.PRIMARY,onClick:n,loading:a,disabled:a||o,children:c(`rules.saveChanges`,`Save Changes`)})]}),children:(0,B.jsx)(v,{icon:(0,B.jsx)(u,{size:14}),intent:_.DANGER,text:c(`rules.delete`,`Delete`),onClick:()=>{e&&i(e.id)},loading:o,disabled:a||o})})]})},W=({profileId:e,prefill:t,onPrefillUsed:n,toasterRef:i})=>{let a=r(),[o,s]=(0,z.useState)([]),[c,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!0),[p,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!1),[S,C]=(0,z.useState)(!1),{t:w}=l(),T=M(),[D,k]=(0,z.useState)({type:`BLOCK`,pattern:``,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),[P,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(`www.okx.com`),[q,J]=(0,z.useState)(!1);(0,z.useEffect)(()=>{j().then(e=>{e.substituteDomain&&K(e.substituteDomain)}).catch(e=>console.warn(`Failed to fetch clientInfo for substituteDomain:`,e))},[]);let Y=(0,z.useMemo)(()=>{let e=window.location.hostname.trim().toLowerCase();return e?o.some(t=>{if(t.type!==`REDIRECT`)return!1;let n=t.pattern.trim().toLowerCase();return n===e||n===`*.${e}`}):!1},[o]),X=()=>{J(!1),k({type:`REDIRECT`,pattern:window.location.hostname,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:G||`www.okx.com`}),setTimeout(()=>{document.getElementById(`rule-pattern`)?.focus()},100)};(0,z.useEffect)(()=>{t&&(k({type:t.type,pattern:t.domain,include_subdomains:!1,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 Z=async()=>{f(!0);try{let[t,n]=await Promise.all([R(e),F(e)]);s(t),u(JSON.parse(n.settings||`{}`))}catch(e){console.error(`Failed to fetch data`,e)}finally{f(!1)}};return(0,z.useEffect)(()=>{Z()},[e]),(0,B.jsxs)(`div`,{className:A(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,T?`p-1`:`px-8`),children:[(0,B.jsx)(`div`,{className:`mb-8`,children:(0,B.jsxs)(`div`,{className:`flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,B.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[T?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(O,{minimal:!0,fill:T,className:`flex-1`,children:[(0,B.jsx)(v,{active:!0,onClick:()=>a(`/dash/${e}/rules`),text:w(`rules.title`),large:!0}),(0,B.jsx)(v,{active:!1,onClick:()=>a(`/dash/${e}/filter`),text:w(`filtering.title`),large:!0})]}),d&&(0,B.jsx)(g,{size:16})]}):(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`bp6-heading m-0`,children:w(`rules.title`)}),d&&(0,B.jsx)(g,{size:20})]}),(0,B.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:w(`rules.subtitle`)})]}),!d&&!Y&&(0,B.jsx)(`div`,{className:`flex items-center gap-3 self-start md:self-auto`,children:(0,B.jsx)(h,{isOpen:q,onInteraction:J,placement:`bottom-end`,portalClassName:`z-20000`,content:(0,B.jsxs)(`div`,{className:`p-4 w-72 sm:w-80 space-y-3 text-sm`,children:[(0,B.jsx)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300 leading-relaxed m-0`,children:w(`rules.addSelfRedirectPrompt`,`是否增加指向本站的 CNAME 规则,用于地区网络优化(中国大陆用户推荐)?`)}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,B.jsx)(v,{size:`small`,variant:`minimal`,text:w(`common.no`,`否`),onClick:()=>J(!1)}),(0,B.jsx)(v,{size:`small`,intent:_.PRIMARY,text:w(`common.yes`,`是`),onClick:X})]})]}),children:(0,B.jsx)(E,{minimal:!0,interactive:!0,intent:_.PRIMARY,className:`cursor-pointer select-none font-medium`,children:w(`rules.addSelfRedirectTag`,`增加本站重定向?`)})})})]})}),(0,B.jsx)(m,{intent:_.PRIMARY,icon:`info-sign`,className:`mb-6`,children:(0,B.jsx)(`p`,{children:w(`rules.wildcardDisclaimer`,`若要匹配子域名,需使用通配符 *.example.com ,example.com 不会匹配子域名。`)})}),(0,B.jsx)(V,{newRule:D,setNewRule:k,addRule:async()=>{let t=D.pattern.trim();if(!t){i?.current?.show({message:w(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:_.DANGER});return}let n=t.toLowerCase();if(o.some(e=>e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:w(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:_.DANGER});return}y(!0);try{await L(e,{...D,pattern:t,include_subdomains:0}),i?.current?.show({message:w(`rules.addSuccess`,`Rule added successfully`),intent:_.SUCCESS}),k({type:`BLOCK`,pattern:``,include_subdomains:!1,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),await Z()}catch(e){i?.current?.show({message:e.message||w(`rules.addFailed`,`Failed to add rule`),intent:_.DANGER})}finally{y(!1)}},loading:p}),d&&o.length===0?(0,B.jsxs)(`div`,{className:`p-16 flex flex-col justify-center items-center gap-3`,children:[(0,B.jsx)(g,{size:32}),(0,B.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 font-medium`,children:w(`common.loading`,`加载中...`)})]}):o.length===0?(0,B.jsx)(m,{title:w(`rules.noRulesTitle`),children:w(`rules.noRulesDesc`)}):(0,B.jsxs)(`div`,{className:`relative`,children:[d&&(0,B.jsx)(`div`,{className:`absolute inset-0 bg-white/40 dark:bg-gray-900/40 backdrop-blur-xs flex items-center justify-center z-10 rounded-lg`,children:(0,B.jsx)(g,{size:32})}),(0,B.jsx)(H,{rules:o,startEdit:e=>{W({...e,include_subdomains:e.include_subdomains===1||e.include_subdomains===!0})},getBlockDetail:()=>{if(!c)return w(`rules.detailBlock`);switch(c.block_mode||`NULL_IP`){case`NXDOMAIN`:return`NXDOMAIN`;case`NODATA`:return`NODATA`;case`CUSTOM_IP`:return`${c.custom_block_ipv4||`0.0.0.0`} / ${c.custom_block_ipv6||`::`}`;default:return`0.0.0.0 / ::`}}})]}),(0,B.jsx)(U,{editRule:P,setEditRule:W,saveEditRule:async()=>{if(!P)return;let t=P.pattern.trim();if(!t){i?.current?.show({message:w(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:_.DANGER});return}let n=t.toLowerCase();if(o.some(e=>e.id!==P.id&&e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:w(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:_.DANGER});return}x(!0);try{await I(e,{...P,pattern:t,include_subdomains:0}),i?.current?.show({message:w(`rules.updateSuccess`,`Rule updated successfully`),intent:_.SUCCESS}),W(null),await Z()}catch(e){i?.current?.show({message:e.message||w(`rules.updateFailed`,`Failed to update rule`),intent:_.DANGER})}finally{x(!1)}},cancelEdit:()=>{W(null)},deleteRule:async t=>{C(!0);try{await N(e,t)}catch(e){console.error(e)}finally{C(!1)}W(null),await Z()},isSaving:b,isDeleting:S})]})};export{W as RulesView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{$ as t,At as n,O as r,P as i,U as a,X as o,bt as s,ct as c,it as l,lt as u,mt as d,nn as f,rt as p,ut as m,v as h,w as g,y as _,yt as v}from"./vendor-react-DYK5a2J9.js";import{S as y,b}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{C as x,D as S,E as C,F as ee,H as w,M as T,N as E,O as D,P as O,S as k,T as A,U as j,V as M,_ as N,d as P,f as F,h as I,p as L,r as R,v as z,x as te}from"./vendor-ui-core-CodM8CpF.js";import{_t as ne}from"./vendor-utils-Bab4qB3W.js";import{At as re,Dt as B,J as V,K as H,St as U,T as W,c as G,gt as K,ht as q,ot as J,yt as Y}from"./index-BLk8QVje.js";import{t as X}from"./async-R_IFRE5c.js";var Z=e(y(),1),Q=e(b(),1);const ie=({profile:e,isEditingName:t,setIsEditingName:n,editName:r,setEditName:i,updateProfileName:o,exportProfile:c})=>{let{t:l}=f(),[d,p]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`mb-6 flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col justify-start`,children:[t?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,Q.jsx)(z,{content:l(`common.profileNameFormatTip`,`Profile Name tip: 1-30 characters, duplicates not allowed`),isOpen:d,position:M.TOP,intent:w.PRIMARY,className:`flex-1`,children:(0,Q.jsx)(`div`,{className:`w-full block`,children:(0,Q.jsx)(F,{value:r,onChange:e=>i(e.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),autoFocus:!0,onKeyDown:t=>{t.key===`Enter`&&o(),t.key===`Escape`&&(n(!1),i(e?.name||``))}})})}),(0,Q.jsx)(O,{icon:(0,Q.jsx)(s,{size:16}),intent:w.SUCCESS,minimal:!0,onClick:o,disabled:!G.test(r)}),(0,Q.jsx)(O,{icon:(0,Q.jsx)(_,{size:16}),minimal:!0,onClick:()=>{n(!1),i(e?.name||``)}})]}):(0,Q.jsxs)(`div`,{className:`group flex items-center gap-2 mb-1 cursor-pointer`,onClick:()=>n(!0),children:[(0,Q.jsx)(`h2`,{className:`bp6-heading mb-0`,children:e?.name}),(0,Q.jsx)(O,{icon:(0,Q.jsx)(a,{size:14}),minimal:!0,className:`opacity-30 group-hover:opacity-100 transition-opacity`})]}),(0,Q.jsx)(`p`,{className:`bp6-text-muted`,children:l(`settings.subtitle`)})]}),(0,Q.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,Q.jsx)(O,{size:`large`,icon:(0,Q.jsx)(u,{size:18}),text:l(`settings.export`,`导出配置`),onClick:c})})]})},ae=()=>{let{t:e}=f(),[t,n]=(0,Z.useState)([]);return(0,Z.useEffect)(()=>{V().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},oe=(e,t)=>{let{t:n}=f();return(0,Z.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.retention3d`,`3 天`),value:3},{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])},$=({settings:e,setSettings:t})=>{let{t:n}=f(),r=(0,Q.jsx)(S,{className:`min-w-96`,children:ae().map((n,r)=>(0,Q.jsx)(A,{text:n.label,onClick:()=>t({...e,upstream:[n.url]}),labelElement:(0,Q.jsx)(`div`,{className:`flex flex-col items-end text-right`,children:(0,Q.jsx)(`span`,{className:`text-[9px] opacity-85 max-w-64 truncate`,title:n.url,children:n.url})})},r))});return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,Q.jsx)(i,{size:18,className:`text-blue-500`}),` `,n(`settings.upstreamTitle`)]}),(0,Q.jsx)(L,{label:`DoH (https://) / DoT (tls://) / DNS Stamp (sdns://) / ${n(`settings.classicDns`)}`,children:(0,Q.jsx)(F,{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,Q.jsx)(C,{content:r,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,Q.jsx)(O,{variant:`minimal`,icon:`chevron-down`})})})}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.upstreamDesc`)})]})},se=({settings:e,setSettings:t})=>{let{t:n}=f();return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,Q.jsx)(r,{size:18,className:`text-green-500`}),` `,n(`settings.defaultPolicyTitle`)]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(L,{label:n(`settings.onNoMatch`),children:(0,Q.jsxs)(P,{fill:!0,value:e.default_policy,onChange:n=>t({...e,default_policy:n.target.value}),children:[(0,Q.jsx)(`option`,{value:`ALLOW`,children:n(`settings.allowAll`)}),(0,Q.jsx)(`option`,{value:`BLOCK`,children:n(`settings.blockAll`)})]})}),(0,Q.jsx)(N,{}),(0,Q.jsx)(L,{label:n(`settings.blockModeTitle`),helperText:n(`settings.blockModeDesc`),children:(0,Q.jsxs)(P,{fill:!0,value:e.block_mode||`NULL_IP`,onChange:n=>t({...e,block_mode:n.target.value}),children:[(0,Q.jsxs)(`option`,{value:`NULL_IP`,children:[`0.0.0.0 / :: (`,n(`settings.default`),`)`]}),(0,Q.jsxs)(`option`,{value:`NXDOMAIN`,children:[`NXDOMAIN (`,n(`settings.NXDOMAIN`),`)`]}),(0,Q.jsxs)(`option`,{value:`NODATA`,children:[`NODATA (`,n(`settings.NODATA`),`)`]}),(0,Q.jsx)(`option`,{value:`CUSTOM_IP`,children:n(`settings.customIP`)})]})}),e.block_mode===`CUSTOM_IP`&&(0,Q.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1`,children:[(0,Q.jsx)(F,{placeholder:`IPv4: 127.0.0.1`,value:e.custom_block_ipv4||``,onChange:n=>t({...e,custom_block_ipv4:n.target.value})}),(0,Q.jsx)(F,{placeholder:`IPv6: ::1`,value:e.custom_block_ipv6||``,onChange:n=>t({...e,custom_block_ipv6:n.target.value})})]})]})]})},ce=({settings:e,setSettings:t,isAdmin:n,maxRetentionDays:r})=>{let{t:i}=f(),a=oe(n,r);Z.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 o=e.log_retention_days===0;return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,Q.jsx)(d,{size:18,className:`text-purple-500`}),` `,i(`settings.logRetentionTitle`)]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(L,{label:i(`settings.retentionDuration`),children:(0,Q.jsx)(P,{fill:!0,value:e.log_retention_days,onChange:n=>t({...e,log_retention_days:parseFloat(n.target.value)}),children:a.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60`,children:o?i(`settings.retentionDisabledDesc`,`已关闭日志记录。系统将不会记录任何 DNS 查询日志并立即清空历史日志。`):i(`settings.retentionDesc`)}),(0,Q.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80`,children:[(0,Q.jsx)(I,{label:i(`settings.skipLogOnPass`,`不记录放行记录`),checked:!o&&!!e.skip_log_on_pass,disabled:o,onChange:n=>t({...e,skip_log_on_pass:n.currentTarget.checked})}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60 mt-1`,children:i(`settings.skipLogOnPassDesc`,`启用后不记录正常放行的 DNS 查询,仅记录被拦截、重定向或解析失败的记录。可大幅减少存储占用与写操作。`)})]})]})]})},le=({profileId:e,toasterRef:t})=>{let{t:n}=f(),[r,i]=(0,Z.useState)(()=>W.getLocalRetentionDays()),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,h]=(0,Z.useState)(!1),_=(0,Z.useCallback)(async()=>{try{await W.init();let t=await W.getStorageInfo();o(t?.isOpfs??W.getIsOpfs());let n=t.profileStats.find(t=>t.profile_id===e);c(n?n.count:0)}catch(e){console.error(`[LocalRetentionCard] Failed to load storage info:`,e),o(W.getIsOpfs()),c(0)}},[e]);(0,Z.useEffect)(()=>{_()},[_]);let v=e=>{i(e),W.setLocalRetentionDays(e),_()};return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,Q.jsx)(m,{size:18,className:`text-cyan-500`}),` `,n(`settings.localRetentionTitle`,`本地存储与留存`)]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(L,{label:n(`settings.localRetentionDuration`,`本地保留时长`),children:(0,Q.jsxs)(P,{fill:!0,value:r,onChange:e=>v(parseInt(e.target.value,10)),children:[(0,Q.jsx)(`option`,{value:30,children:n(`settings.localRetention30d`,`30 天`)}),(0,Q.jsx)(`option`,{value:90,children:n(`settings.localRetention90d`,`90 天 (推荐)`)}),(0,Q.jsx)(`option`,{value:180,children:n(`settings.localRetention180d`,`180 天`)}),(0,Q.jsx)(`option`,{value:365,children:n(`settings.localRetention365d`,`365 天 (1 年)`)}),(0,Q.jsx)(`option`,{value:0,children:n(`settings.localRetentionUnlimited`,`永久保留 (直到手动清除)`)})]})}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.localRetentionDesc`,`日志将持久化保存在当前浏览器本地的 SQLite 数据库 (OPFS) 中,提供秒级本地搜索并节省云端存储费用。超出此时长的本地日志将自动清除。`)}),(0,Q.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 opacity-70`,children:[(0,Q.jsx)(p,{size:14}),n(`settings.localEngineStorage`,`存储引擎`),`:`]}),(0,Q.jsx)(R,{minimal:!0,intent:a?w.SUCCESS:w.WARNING,className:`text-[11px]`,children:a?n(`settings.localEngineOpfs`,`OPFS 本地持久化`):n(`settings.localEngineMemory`,`内存临时存储 (无痕/私密模式)`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Q.jsxs)(`span`,{className:`opacity-70`,children:[n(`settings.localCachedCount`,`本地已缓存日志`),`:`]}),(0,Q.jsx)(`span`,{className:`font-mono font-medium`,children:s===null?`...`:n(`settings.localCachedCountUnit`,`{{count}} 条记录`,{count:s})})]}),(0,Q.jsx)(`div`,{className:`pt-1 flex justify-end`,children:(0,Q.jsx)(O,{minimal:!0,small:!0,intent:w.DANGER,icon:(0,Q.jsx)(g,{size:13}),text:n(`settings.clearLocalData`,`清空本地日志`),disabled:s===0||s===null||d,onClick:()=>u(!0)})})]})]}),(0,Q.jsx)(D,{isOpen:l,confirmButtonText:n(`common.confirm`,`确认清空`),cancelButtonText:n(`common.cancel`,`取消`),intent:w.DANGER,icon:`trash`,onConfirm:async()=>{h(!0);try{await W.clearProfile(e),c(0),t?.current?.show({message:n(`settings.clearLocalDataSuccess`,`本地日志已成功清空`),intent:w.SUCCESS,icon:`tick`})}catch(e){console.error(`[LocalRetentionCard] Failed to clear local profile logs:`,e),t?.current?.show({message:n(`settings.clearLocalDataError`,`清空本地日志失败`),intent:w.DANGER,icon:`error`})}finally{h(!1),u(!1)}},onCancel:()=>u(!1),loading:d,children:(0,Q.jsx)(`p`,{children:n(`settings.clearLocalDataConfirm`,`确定要清空此配置在本地保存的所有日志吗?(云端日志不受影响)`)})})]})},ue=({settings:e,setSettings:t})=>{let{t:n}=f();return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-3 font-bold`,children:[(0,Q.jsx)(l,{size:18,className:`text-orange-500`}),` `,n(`settings.ecsTitle`)]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(I,{label:n(`settings.sendEcs`),checked:e.ecs.enabled,onChange:n=>t({...e,ecs:{...e.ecs,enabled:n.currentTarget.checked}})}),(0,Q.jsx)(I,{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,Q.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,Q.jsx)(L,{label:n(`settings.customIpv4`),labelInfo:n(`settings.ipv4Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,Q.jsx)(F,{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,Q.jsx)(L,{label:n(`settings.customIpv6`),labelInfo:n(`settings.ipv6Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,Q.jsx)(F,{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,Q.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.ecsUpstreamHint`)})]})]})};var de=[{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 fe=({settings:e,setSettings:n})=>{let{t:r}=f(),[i,a]=Z.useState(de);Z.useEffect(()=>{H().then(e=>{Array.isArray(e)&&e.length>0&&a(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 o=typeof e.best_effort_ech==`boolean`?e.best_effort_ech:!!e.best_effort_ech?.enabled,s=typeof e.best_effort_ech==`object`&&e.best_effort_ech?.fronting_domain?e.best_effort_ech.fronting_domain:`cloudflare-ech.com`,l=t=>{n({...e,best_effort_ech:{enabled:t,fronting_domain:s||`cloudflare-ech.com`}})},u=t=>{n({...e,best_effort_ech:{enabled:o,fronting_domain:t}})},d=(0,Q.jsx)(S,{className:`min-w-72`,children:i.map(e=>(0,Q.jsx)(A,{text:e.domain,onClick:()=>u(e.domain),labelElement:e.isPreferred?(0,Q.jsx)(R,{minimal:!0,intent:w.PRIMARY,className:`text-[10px]`,children:r(`settings.echPreferred`,`首选`)}):void 0},e.domain))});return(0,Q.jsxs)(k,{elevation:j.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 m-0 font-bold text-purple-600 dark:text-purple-400`,children:[(0,Q.jsx)(t,{size:18}),` `,r(`settings.echTitle`)]}),(0,Q.jsx)(C,{placement:`bottom-end`,usePortal:!0,content:(0,Q.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Q.jsx)(E,{children:r(`settings.whatIsEch`,`何为 ECH (Encrypted Client Hello)?`)}),(0,Q.jsx)(`p`,{className:`text-sm mb-2`,children:r(`settings.echHelpDesc`)}),(0,Q.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,Q.jsx)(`li`,{children:r(`settings.echHelpBenefit1`)}),(0,Q.jsx)(`li`,{children:r(`settings.echHelpBenefit2`)})]}),(0,Q.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,Q.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,Q.jsx)(c,{size:10}),` `,r(`setup.learnMore`,`了解更多`)]})})]}),children:(0,Q.jsx)(O,{icon:`help`,variant:`minimal`,intent:w.NONE})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(I,{label:r(`settings.enableEch`,`启用重写 ECH`),checked:o,onChange:e=>l(e.currentTarget.checked)}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60 leading-relaxed`,children:r(`settings.echDesc`,`针对由 Cloudflare 代理的域名,当查询 HTTPS (Type 65) 或 SVCB (Type 64) 记录且上游未配置 ECH 时,自动重写注入 ECH 参数以保护 SNI 隐私。`)}),o&&(0,Q.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100 dark:border-gray-800`,children:(0,Q.jsx)(L,{label:r(`settings.echFrontingTitle`,`表层 SNI (ECH Fronting)`),labelInfo:(0,Q.jsx)(`span`,{className:`text-xs opacity-60`,children:r(`settings.echFrontingDesc`,`TLS 握手外层可见的伪装域名`)}),children:(0,Q.jsx)(F,{fill:!0,placeholder:r(`settings.echFrontingCustomPlaceholder`,`输入自定义表层域名,例如 crypto.cloudflare.com`),value:s,onChange:e=>u(e.target.value),onFocus:e=>e.target.select(),className:`font-mono text-sm`,rightElement:(0,Q.jsx)(C,{content:d,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,Q.jsx)(O,{variant:`minimal`,icon:`chevron-down`})})})})})]})]})},pe=({testInput:e,setTestInput:t,handleDnsTest:r,testing:i,testResult:a})=>{let{t:s}=f();return(0,Q.jsxs)(k,{elevation:j.TWO,className:`dark:bg-gray-900 border-t-2 border-blue-500`,children:[(0,Q.jsxs)(E,{className:`flex items-center gap-2 mb-6 font-bold`,children:[(0,Q.jsx)(h,{size:20,className:`text-yellow-500 fill-yellow-500`}),` `,s(`settings.testToolTitle`)]}),(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,Q.jsx)(L,{label:s(`settings.testDomain`),className:`mb-0`,children:(0,Q.jsx)(F,{fill:!0,large:!0,placeholder:s(`settings.domainPlaceholder`),value:e.domain,onChange:n=>t({...e,domain:n.target.value}),onKeyDown:e=>e.key===`Enter`&&r()})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-4 items-end`,children:[(0,Q.jsx)(L,{label:s(`settings.recordType`),className:`w-32 mb-0`,children:(0,Q.jsxs)(P,{fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),children:[(0,Q.jsx)(`option`,{value:`A`,children:`A`}),(0,Q.jsx)(`option`,{value:`AAAA`,children:`AAAA`}),(0,Q.jsx)(`option`,{value:`CNAME`,children:`CNAME`}),(0,Q.jsx)(`option`,{value:`TXT`,children:`TXT`})]})}),(0,Q.jsx)(L,{label:`\xA0`,className:`mb-0`,children:(0,Q.jsx)(O,{size:`large`,intent:w.PRIMARY,icon:`search`,text:s(`settings.runTest`),onClick:r,loading:i})})]}),a&&(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap gap-4 items-center`,children:[(0,Q.jsx)(R,{large:!0,round:!0,intent:a.action===`PASS`?w.SUCCESS:a.action===`BLOCK`?w.DANGER:w.WARNING,className:`px-4 font-bold`,children:a.action}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.hitRule`)}),(0,Q.jsx)(`span`,{className:`text-sm font-bold`,children:a.reason||s(`settings.defaultAllow`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col border-l border-gray-200 dark:border-gray-700 pl-4`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.parseLatency`)}),(0,Q.jsx)(`span`,{className:`text-sm font-mono font-bold`,children:a.latency?`${a.latency}ms`:`-`})]}),a.timings&&(0,Q.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,Q.jsxs)(`div`,{className:`flex gap-1 items-baseline`,children:[(0,Q.jsxs)(`span`,{className:`text-[9px] opacity-40 uppercase font-mono`,children:[e,`:`]}),(0,Q.jsxs)(`span`,{className:`text-[10px] font-mono font-bold`,children:[t,`ms`]})]},e))}),(0,Q.jsx)(N,{}),(0,Q.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,Q.jsx)(o,{size:14,className:`text-red-500`}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40 leading-none`,children:s(`settings.sourceIp`)}),(0,Q.jsxs)(`span`,{className:`text-xs font-mono`,children:[a.client_ip,` (`,a.geo_country,`)`]})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`text-[10px] uppercase font-bold opacity-40 flex items-center gap-1`,children:[(0,Q.jsx)(n,{size:10}),` `,s(`settings.answerSection`)]}),(0,Q.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,Q.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,Q.jsx)(`span`,{className:`w-16 font-bold text-blue-500`,children:e.type}),(0,Q.jsx)(`span`,{className:`flex-1 dark:text-gray-300`,children:e.data}),(0,Q.jsxs)(`span`,{className:`text-[10px] opacity-30 italic`,children:[`TTL: `,e.ttl,`s`]})]},t)):(0,Q.jsx)(`div`,{className:`p-4 opacity-40 italic text-center`,children:s(`settings.noRecordsReturned`)})})]}),a.diagnostics&&(0,Q.jsx)(x,{minimal:!0,intent:a.action===`FAIL`?w.DANGER:w.NONE,className:`text-xs font-mono`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Q.jsx)(`span`,{className:`font-bold uppercase tracking-wider`,children:s(`settings.diagnostics`)}),(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-80`,children:[(0,Q.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,Q.jsx)(`span`,{className:`break-all`,children:a.diagnostics.upstream_url})]}),a.diagnostics.cf_ray&&(0,Q.jsxs)(`div`,{className:`text-[11px] opacity-75`,children:[`CF-Ray: `,(0,Q.jsx)(`span`,{className:`font-bold`,children:a.diagnostics.cf_ray})]}),a.diagnostics.error_detail&&a.action===`FAIL`&&(0,Q.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,Q.jsxs)(`div`,{className:`font-bold mb-0.5`,children:[s(`settings.errorDetail`),`:`]}),(0,Q.jsx)(`div`,{children:a.diagnostics.error_detail})]}),a.diagnostics.response_body&&(0,Q.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,Q.jsxs)(`div`,{className:`font-bold mb-0.5 opacity-60`,children:[s(`settings.upstreamResponse`),`:`]}),(0,Q.jsx)(`div`,{className:`line-clamp-3`,children:a.diagnostics.response_body})]})]})})]})]})]})},me=({profileId:e,toasterRef:t,onLogsCleared:n})=>{let{t:r}=f(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=async()=>{if(confirm(r(`settings.confirmClearProfileLogs`,`确定要清空当前配置的所有查询日志吗?此操作不可恢复。`))){s(!0);try{await J(e),await W.clearProfile(e).catch(()=>{}),typeof window<`u`&&`caches`in window&&await caches.delete(`dns-worker-logs-v1`).catch(()=>{}),t?.current?.show({message:r(`settings.clearProfileLogsSuccess`,`配置日志已成功清空`),intent:w.SUCCESS,icon:`tick`}),n?.()}catch(e){console.error(`[ProfileDangerZone] Clear profile logs failed:`,e);let n=e instanceof Error?e.message:String(e);t?.current?.show({message:n||r(`common.errorNetwork`,`网络请求失败`),intent:w.DANGER,icon:`error`})}finally{s(!1)}}};return(0,Q.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-gray-800`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer select-none py-1 group`,onClick:()=>a(!i),role:`button`,tabIndex:0,"aria-expanded":i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(!i))},children:[(0,Q.jsxs)(T,{className:`text-red-500 flex items-center gap-2 m-0! group-hover:text-red-600 dark:group-hover:text-red-400 transition-colors`,children:[(0,Q.jsx)(g,{size:20}),` `,r(`settings.dangerZone`,`危险区域`)]}),(0,Q.jsx)(O,{variant:`minimal`,icon:(0,Q.jsx)(v,{size:18,className:ne(`transition-transform duration-200 text-red-500`,!i&&`-rotate-90`)}),text:i?r(`common.collapse`,`收起`):r(`common.expand`,`展开`),className:`text-red-500 hover:text-red-600 dark:hover:text-red-400`,onClick:e=>{e.stopPropagation(),a(!i)},"aria-label":i?r(`common.collapse`,`收起`):r(`common.expand`,`展开`)})]}),(0,Q.jsx)(te,{isOpen:i,keepChildrenMounted:!0,children:(0,Q.jsx)(`div`,{className:`space-y-4 pt-3`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:(0,Q.jsxs)(k,{elevation:j.ONE,className:`flex flex-col justify-between dark:bg-gray-900 dark:border-gray-800`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(T,{children:r(`settings.clearProfileLogs`,`清空当前配置所有日志`)}),(0,Q.jsx)(`p`,{className:`text-xs opacity-60 mb-3`,children:r(`settings.clearProfileLogsDesc`,`这将删除当前 DNS 配置生成的所有查询日志(包含服务端日志与本地缓存)。此操作不可恢复。`)})]}),(0,Q.jsx)(O,{fill:!0,intent:w.DANGER,text:r(`settings.clearProfileLogsBtn`,`立即清空配置日志`),icon:`trash`,loading:o,onClick:c})]})})})})]})},he=({profileId:e,toasterRef:t,currentUser:n,onSavingChange:r})=>{let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(!1),{t:p}=f();(0,Z.useEffect)(()=>(r?.(u),()=>{r?.(!1)}),[u,r]);let m=(0,Z.useRef)(!0),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(0),v=e=>typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e)),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,T]=(0,Z.useState)({domain:`o-o.myaddr.l.google.com`,type:`TXT`}),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{m.current=!0,h.current&&=(clearTimeout(h.current),null),(async()=>{l(!0);try{let t=await q(e);a(t),S(t.name);let n=JSON.parse(t.settings);return g.current=v(n),s(n),i}catch(e){console.error(e)}finally{l(!1)}})()},[e]),(0,Z.useEffect)(()=>{if(!c&&o&&m.current){let e=setTimeout(()=>{m.current=!1,o&&(g.current=v(o))},500);return()=>clearTimeout(e)}},[c,o]),(0,Z.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let A=async()=>{if(!x||x===i?.name){b(!1);return}let n=i?.name||``;d(!0);try{await X(U(e,x),1e4),a(e=>e?{...e,name:x}:null),b(!1),t?.current?.show({message:p(`common.saveSuccess`,`保存成功`),intent:w.SUCCESS,icon:`tick`})}catch(e){console.error(e),S(n),b(!1);let r=e.message,i=r;r===`The profile name already exists`?i=p(`common.profileNameExists`,`The profile name already exists`):r===`Invalid Profile Name format`&&(i=p(`common.profileNameFormatError`,`Invalid Profile Name format`)),t?.current?.show({message:i||p(`common.saveFailed`,`保存失败`),intent:w.DANGER,icon:`error`})}finally{d(!1)}},j=(0,Z.useCallback)(async n=>{if(!n)return;let r=++_.current;d(!0);try{await X(re(e,n),1e4),r===_.current&&(g.current=v(n),t?.current?.show({message:p(`common.saveSuccess`,`保存成功`),intent:w.SUCCESS,icon:`tick`}))}catch(e){console.error(e),r===_.current&&(h.current&&=(clearTimeout(h.current),null),g.current&&s(v(g.current)),t?.current?.show({message:p(`common.saveFailed`,`保存失败`),intent:w.DANGER,icon:`error`}))}finally{r===_.current&&d(!1)}},[e,t,p]),M=(0,Z.useCallback)(e=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{j(e)},600)},[j]),N=(0,Z.useCallback)(e=>{s(e),m.current||M(e)},[M]);return c||!o?(0,Q.jsx)(`div`,{className:`p-20 flex justify-center`,children:(0,Q.jsx)(ee,{})}):(0,Q.jsxs)(`div`,{className:`p-0 sm:px-4 lg:px-8 max-w-5xl mx-auto space-y-8 pb-20`,children:[(0,Q.jsx)(ie,{profile:i,isEditingName:y,setIsEditingName:b,editName:x,setEditName:S,updateProfileName:A,exportProfile:async()=>{if(!(!i||!o))try{let[n,r]=await Promise.all([Y(e).catch(()=>[]),K(e).catch(()=>[])]),a=new Set,s=(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:o,rules:s,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:w.SUCCESS,icon:`download`})}catch(e){console.error(e),t?.current?.show({message:p(`settings.exportError`,`导出失败`),intent:w.DANGER,icon:`error`})}}}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,Q.jsx)($,{settings:o,setSettings:N}),(0,Q.jsx)(se,{settings:o,setSettings:N}),(0,Q.jsx)(ce,{settings:o,setSettings:N,isAdmin:n?.role===`admin`,maxRetentionDays:n?.max_log_retention_days??(n?.role===`admin`?30:7)}),(0,Q.jsx)(le,{profileId:e,toasterRef:t}),(0,Q.jsx)(ue,{settings:o,setSettings:N}),(0,Q.jsx)(fe,{settings:o,setSettings:N})]}),(0,Q.jsx)(pe,{testInput:C,setTestInput:T,handleDnsTest:async()=>{if(C.domain){k(!0),D(null);try{D(await B(e,C))}catch(e){console.error(e)}finally{k(!1)}}},testing:O,testResult:E}),(0,Q.jsx)(me,{profileId:e,toasterRef:t})]})};export{he as SettingsView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{At as t,B as n,D as r,F as i,J as a,L as o,M as s,P as c,R as l,T as u,U as d,V as f,X as p,ct as m,ft as h,it as g,kt as _,nn as v,ot as y,q as b,st as x,w as S}from"./vendor-react-DYK5a2J9.js";import{S as C,b as w}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{B as T,C as E,E as D,F as O,H as k,I as A,N as j,P as M,R as N,V as P,a as F,d as I,f as L,i as R,j as z,k as B,n as V,o as H,r as U,v as W,z as G}from"./vendor-ui-core-CodM8CpF.js";import{_t as K,t as ee,vt as q}from"./vendor-utils-Bab4qB3W.js";import{$ as te,Ct as ne,U as re,W as ie,X as ae,Y as oe,Z as J,_n as se,a as ce,g as le,ht as ue,n as Y,pt as de,t as fe,tt as pe,ut as me,v as he,wt as ge}from"./index-BLk8QVje.js";import{t as _e}from"./SwipeableDrawer-UY1QWnPj.js";var X=e(C(),1),Z=e(w(),1);const ve=()=>{let{t:e}=v();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)(z,{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)(fe,{})})]})},ye=({isVerifying:e,verifyResult:n,handleVerify:r,isMobile:i,clientInfo:a,showIp:o,setShowIp:l,showLocation:u,setShowLocation:d,traceInfo:f,edgeLocation:m})=>{let{t:h}=v(),{isServerfull:_}=Y(),[b,S]=(0,X.useState)(!1),C=(0,Z.jsxs)(`div`,{className:q(`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 h-full transition-all`,!_),children:[(0,Z.jsx)(c,{size:18,className:`text-purple-500 mt-1 shrink-0`}),(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||f?.colo||``,children:_?m||h(`setup.detecting`):m||f?.colo||h(`setup.detecting`)})]})]});return(0,Z.jsx)(H,{title:h(`setup.verifyConnection`),icon:(0,Z.jsx)(t,{size:16}),children:(0,Z.jsx)(F,{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)(O,{size:24}):n?.success?(0,Z.jsx)(s,{size:24}):(0,Z.jsx)(c,{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)(M,{size:`large`,intent:n?.success?k.SUCCESS:k.PRIMARY,icon:`refresh`,text:h(`setup.refreshStatus`),onClick:r,loading:e,fill:i})]}),a&&(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)(g,{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:()=>l(!o),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:o?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{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`,!o&&`filter blur-[6px] select-none`),children:a.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)(p,{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:()=>d(!u),className:`text-gray-400 hover:text-red-500 transition-colors`,children:u?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!u&&`filter blur-[6px] select-none`),children:(()=>{let e=[a.city,a.region,a.country].filter(e=>!!(e&&e!==`UNKNOWN`));return e.length>0?e.join(`, `):h(`setup.detecting`)})()})})]})]}),_?C:(0,Z.jsx)(D,{isOpen:b,onInteraction:S,placement:`bottom-end`,portalClassName:`z-20000`,fill:!0,targetProps:{className:`h-full`},content:(0,Z.jsxs)(`div`,{className:`p-3 select-text w-72 sm:w-80 max-w-[85vw] space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-mono font-bold text-gray-500 dark:text-gray-400 tracking-wide border-b border-gray-100 dark:border-gray-800 pb-1.5`,children:`/cdn-cgi/trace`}),(0,Z.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap break-all overflow-x-hidden max-h-64 overflow-y-auto text-gray-800 dark:text-gray-200`,children:f?.raw||h(`setup.noTraceData`,`暂无 Trace 数据`)})]}),children:C})]})]})})})},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})]})})},be=({accessPoints:e,selectedApId:t,onSelectAp:n,accessPointName:r,onManageAccessPoints:o,isMobile:s})=>{let{t:c}=v();return(0,Z.jsxs)(H,{title:c(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Z.jsx)(a,{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)(F,{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:c(`setup.selectAccessPointToConfigure`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.length>0?(0,Z.jsx)(I,{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||c(`setup.defaultAccessPointName`,`设备-1`)}),e.length>0&&(0,Z.jsx)(U,{minimal:!0,round:!0,intent:k.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Z.jsx)(M,{variant:`outlined`,intent:k.NONE,icon:(0,Z.jsx)(i,{size:14}),text:c(`setup.manageAccessPoints`,`管理接入点`),onClick:o,fill:s,className:`shrink-0`})]})})]})},xe=({dohUrl:e,copyToClipboard:t,isMobile:n,flashTrigger:r=0})=>{let{t:i}=v();return(0,Z.jsxs)(H,{title:i(`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)(D,{placement:`bottom-end`,usePortal:!0,content:(0,Z.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Z.jsx)(j,{children:i(`setup.whatIsDoh`)}),(0,Z.jsx)(`p`,{className:`text-sm mb-2`,children:i(`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:i(`setup.dohBenefit1`)}),(0,Z.jsx)(`li`,{children:i(`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)(m,{size:10}),` `,i(`setup.learnMore`)]})})]}),children:(0,Z.jsx)(M,{icon:`help`,variant:`minimal`,intent:k.NONE})}),children:[(0,Z.jsx)(Q,{step:2}),(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:`w-full bg-gray-100 dark:bg-gray-800 px-4 py-4 sm:px-6 sm:py-5 rounded-lg border border-gray-200 dark:border-gray-700 flex items-center justify-center ${r>0?`animate-box-glow`:``}`,children:(0,Z.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-medium text-center text-blue-600 dark:text-blue-400 break-all select-all`,children:e})},r),(0,Z.jsx)(`div`,{className:`w-full flex justify-center`,children:(0,Z.jsx)(M,{intent:k.PRIMARY,icon:`duplicate`,text:i(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0 whitespace-nowrap min-w-fit`})})]})})]})};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 Se(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 Ce(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=Se(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 we=({isMobile:e,copyToClipboard:t,profileKey:n,profileName:i,accessPointName:a,currentIps:o,dotDomain:s})=>{let{t:c}=v(),{isCloudflare:d}=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)(R,{id:`browsers`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(g,{size:16,className:`inline mr-2`}),c(`setup.browsers`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.browserTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.browserSteps`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>t(`chrome://settings/security`),children:c(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Z.jsx)(R,{id:`apple`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(_,{size:16,className:`inline mr-2`}),c(`setup.apple`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.appleTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.appleDesc`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:c(`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)(A,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Z.jsx)(M,{intent:k.PRIMARY,text:c(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Ce({profileKey:n,profileName:i,accessPointName:a,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),r=URL.createObjectURL(t),o=document.createElement(`a`);o.href=r;let s=Se(i,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(r)}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:c(`setup.appleInstallHint`)})]})}),(0,Z.jsx)(R,{id:`windows`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(b,{size:16,className:`inline mr-2`}),c(`setup.windows`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`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:c(`setup.windowsStep0`)})}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep1`)}),(0,Z.jsxs)(`li`,{children:[c(`setup.windowsStep2`),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(e.ip),icon:`duplicate`,className:`font-mono`,children:e.ip}),(0,Z.jsx)(`span`,{className:`text-[9px] opacity-50 ml-1 font-mono`,children:e.area})]},e.ip))})]}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep3`)}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep4`)})]})]})}),(0,Z.jsx)(R,{id:`linux`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(u,{size:16,className:`inline mr-2`}),c(`setup.linux`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.linuxTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.linuxDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:c(`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)(M,{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:c(`setup.linuxStep2`)})})]})}),(0,Z.jsx)(R,{id:`routeros`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(l,{size:16,className:`inline mr-2`}),c(`setup.routeros`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.routerosTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.routerosDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:c(`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)(M,{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:c(`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)(m,{size:10}),` `,c(`setup.routerosDocs`)]})]})}),(0,Z.jsx)(R,{id:`android`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(r,{size:16,className:`inline mr-2`}),c(`setup.android`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.androidTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.androidDesc`)}),d?(0,Z.jsxs)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-semibold mb-1`,children:c(`setup.dotUnavailableCfTitle`)}),(0,Z.jsx)(`div`,{children:c(`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:c(`setup.androidDotTitle`,`私有 DNS (DoT / DoQ)`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`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:k.PRIMARY,children:`${n}.${i}`})})}):(0,Z.jsx)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:c(`setup.androidIpNotice`,`检测到当前通过 IP 或本地地址访问面板。DoT / DoQ 仅接受域名,请在 .env 中配置 SERVERFULL_DOT_DOMAIN (例如 dns.example.com) 后刷新。`)})]})})(),!d&&(0,Z.jsx)(E,{intent:k.PRIMARY,icon:`info-sign`,className:`text-xs`,children:c(`setup.androidWarning`)})]})})]})]})};function Te({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=v(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,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,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:d,setRenameApId:f,renameApName:p,setRenameApName:m,isRenaming:h,rotatingApId:_,deletingApId:b,newApNameFocused:S,setNewApNameFocused:C,renameApNameFocused:w,setRenameApNameFocused:T,rotateConfirmApId:E,setRotateConfirmApId:D,isSearchOpen:O,setIsSearchOpen:A,searchQuery:j,setSearchQuery:M,filteredAccessPoints:t.filter(e=>e.name.toLowerCase().includes(j.toLowerCase())||e.token.toLowerCase().includes(j.toLowerCase())),isValidApName:e=>ce.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:k.DANGER});return}u(!0);try{await pe(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:k.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:k.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=p.trim();if(!(!a||!d)){if(t.some(e=>e.id!==d&&e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:k.DANGER});return}g(!0);try{await ne(e,d,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:k.SUCCESS}),f(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:k.DANGER})}finally{g(!1)}}},handleRotate:async t=>{y(t);try{await ge(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{y(null)}},handleDelete:async t=>{if(confirm(i(`setup.deleteAccessPointConfirm`))){x(t);try{await me(e,t),r.current?.show({message:i(`setup.accessPointDeleted`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Ee=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=v();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{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:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},De=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=v();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{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:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},Oe=({ap:e,totalApCount:t,toasterRef:r,onRenameTrigger:i,rotateConfirmApId:o,setRotateConfirmApId:s,rotatingApId:c,handleRotate:l,deletingApId:u,handleDelete:f})=>{let{t:p}=v();return(0,Z.jsx)(H,{title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{size:16}),(0,Z.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsxs)(F,{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}`),r.current?.show({message:p(`setup.copied`),intent:k.SUCCESS})},title:p(`setup.copyUrl`),children:[(0,Z.jsx)(`span`,{className:`select-all`,children:`${window.location.origin}/${e.token}`}),(0,Z.jsx)(h,{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:p(`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:le(new Date(e.created_at*1e3))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(d,{size:14}),text:p(`setup.renameAccessPoint`),onClick:()=>i(e.id,e.name)}),(0,Z.jsx)(D,{isOpen:o===e.id,onInteraction:e=>{e||s(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:p(`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)(M,{small:!0,minimal:!0,text:p(`common.cancel`,`Cancel`),onClick:()=>s(null)}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,text:p(`common.confirm`,`Confirm`),onClick:()=>{s(null),l(e.id)}})]})]}),placement:`top`,children:(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(n,{size:14}),text:p(`setup.rotateToken`),loading:c===e.id,onClick:()=>s(e.id)})}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,icon:(0,Z.jsx)(S,{size:14}),text:p(`setup.deleteAccessPoint`),loading:u===e.id,onClick:()=>f(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},ke=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:a,onRefresh:s,toasterRef:c})=>{let{t:l}=v(),{isAddDialogOpen:u,setIsAddDialogOpen:d,newApName:p,setNewApName:m,isAdding:h,renameApId:g,setRenameApId:_,renameApName:y,setRenameApName:b,isRenaming:x,rotatingApId:S,deletingApId:C,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:A,setRotateConfirmApId:j,isSearchOpen:N,setIsSearchOpen:P,searchQuery:F,setSearchQuery:I,filteredAccessPoints:R,isValidApName:z,handleAdd:B,handleRename:V,handleRotate:H,handleDelete:U}=Te({profileId:n,accessPoints:i,onRefresh:s,toasterRef:c});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(_e,{isOpen:e,onClose:t,title:N?(0,Z.jsx)(L,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:F,onChange:e=>I(e.target.value),rightElement:(0,Z.jsx)(M,{icon:`cross`,minimal:!0,onClick:()=>{P(!1),I(``)}}),autoFocus:!0}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Z.jsx)(M,{icon:(0,Z.jsx)(o,{size:14}),minimal:!0,onClick:()=>P(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Z.jsx)(M,{fill:!0,intent:k.PRIMARY,icon:(0,Z.jsx)(f,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>d(!0),large:!0}),a?(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(O,{})}):(0,Z.jsx)(`div`,{className:`space-y-4 mt-4`,children:R.map(e=>(0,Z.jsx)(Oe,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),b(t)},rotateConfirmApId:A,setRotateConfirmApId:j,rotatingApId:S,handleRotate:H,deletingApId:C,handleDelete:U},e.id))})]}),(0,Z.jsx)(Ee,{isOpen:u,onClose:()=>{d(!1),m(``)},newApName:p,setNewApName:m,newApNameFocused:w,setNewApNameFocused:T,handleAdd:B,isAdding:h,isValidApName:z}),(0,Z.jsx)(De,{isOpen:!!g,onClose:()=>_(null),renameApName:y,setRenameApName:b,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:V,isRenaming:x,isValidApName:z})]})},Ae=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=se(),{t:a}=v(),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(0),g=e=>{e!==f&&(p(e),h(e=>e+1))},_=async()=>{l(!0);try{s(await de(e))}catch(e){console.error(e)}finally{l(!1)}};(0,X.useEffect)(()=>{_()},[e]);let[y,b]=(0,X.useState)(n||``);(0,X.useEffect)(()=>{n?b(n):e&&ue(e).then(e=>{e?.name&&b(e.name)}).catch(()=>{})},[e,n]);let x=(0,X.useMemo)(()=>o.length===0?null:o.find(e=>e.id===f)||o[0],[o,f]),S=x?x.token:t,C=x?x.name:void 0,w=`${window.location.origin}/${S}`,[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[R,z]=(0,X.useState)({ipv4:[],ipv6:[]}),[B,V]=(0,X.useState)(null),H=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:k.SUCCESS})},U=async()=>{O(!0),V(null);try{let[t,n]=await Promise.all([re(),ae()]);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{}E(t),F(n),t.timezone&&t.timezone!==`UNKNOWN`&&he(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));ie(r&&i||i?t.dotDomain:window.location.hostname||``).then(e=>L(e)).catch(e=>console.warn(`Failed fetching domain geo location:`,e));let a=t.substituteDomain||`www.okx.com`;oe().then(e=>{z(t=>t.ipv4.length>0||t.ipv6.length>0?t:{ipv4:e.ip?[e.ip]:[],ipv6:e.ipv6?[e.ipv6]:[]})}).catch(()=>{}),te(a).then(e=>{(e.ipv4.length>0||e.ipv6.length>0)&&z(e)}).catch(e=>console.warn(`Failed resolving substitute domain DNS IPs:`,e)),V({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{O(!1)}};(0,X.useEffect)(()=>{U()},[e]);let W=(0,X.useMemo)(()=>{let e=[],t=(R.ipv4||[]).slice(0,2),n=(R.ipv6||[]).slice(0,2),r=T?.substituteDomain||`www.okx.com`;for(let n of t)e.push({ip:n,area:`${r} IPv4`});for(let t of n)e.push({ip:t,area:`${r} IPv6`});return e},[R,T?.substituteDomain]);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)(ve,{isMobile:i}),(0,Z.jsx)(ye,{isVerifying:D,verifyResult:B,handleVerify:U,isMobile:i,clientInfo:T,showIp:A,setShowIp:j,showLocation:M,setShowLocation:N,traceInfo:P,edgeLocation:I}),(0,Z.jsx)(be,{accessPoints:o,selectedApId:x?.id||null,onSelectAp:g,accessPointName:C,onManageAccessPoints:()=>d(!0),isMobile:i}),(0,Z.jsx)(xe,{dohUrl:w,copyToClipboard:H,isMobile:i,flashTrigger:m}),(0,Z.jsx)(we,{isMobile:i,copyToClipboard:H,profileKey:S,profileName:y||void 0,accessPointName:C,currentIps:W,dotDomain:T?.dotDomain}),(0,Z.jsx)(ke,{isOpen:u,onClose:()=>d(!1),profileId:e,isMobile:i,accessPoints:o,loading:c,onRefresh:_,toasterRef:r})]})};export{Ae as SetupView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{B as t,C as n,H as r,I as i,M as a,N as o,S as s,at as c,et as l,gt as u,ht as d,nn as f,ut as p,w as m,x as h}from"./vendor-react-DYK5a2J9.js";import{S as g,b as _}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{C as v,E as y,H as b,M as x,N as S,P as C,S as w,U as T,_ as E,d as D,f as O,h as k,k as A,p as j,r as M,u as N}from"./vendor-ui-core-CodM8CpF.js";import{_t as P}from"./vendor-utils-Bab4qB3W.js";import{B as F,F as I,H as L,I as R,L as z,N as B,P as V,R as H,Rt as U,V as W,_n as G,d as K,f as ee,g as q,l as te,o as ne,q as J,u as re,z as Y}from"./index-BLk8QVje.js";import{t as X}from"./async-R_IFRE5c.js";var Z=e(g(),1),Q=e(_(),1);const $=({users:e,currentUserId:t,onRefresh:n,registrationEnabled:r=!0,maxUsers:i,onRefreshSettings:o,onSavingChange:s,toasterRef:c})=>{let{t:l}=f(),[u,d]=(0,Z.useState)(!1),[p,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,S]=(0,Z.useState)(`user`),[E,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(r),[H,U]=(0,Z.useState)(!1),W=i!=null&&i!==``?parseInt(String(i),10):0,G=W>0&&e.length>=W;(0,Z.useEffect)(()=>{z(r)},[r]);let J=async e=>{let t=R;z(e),U(!0),s?.(!0);try{await X(L({registration_enabled:String(e)}),1e4),c?.current?.show({message:l(`common.saveSuccess`,`保存成功`),intent:b.SUCCESS,icon:`tick`}),o?.()}catch(e){console.error(e),z(t),c?.current?.show({message:e.message||l(`common.saveFailed`,`保存失败`),intent:b.DANGER,icon:`error`})}finally{U(!1),s?.(!1)}},Y=async()=>{if(!te.test(p)){alert(l(`account.formatTipUsername`));return}if(!ne.test(_)){alert(l(`account.formatTipPassword`));return}P(!0);try{if((await re(_,p)).breached){alert(l(`auth.passwordLeaked`,`This password has been exposed in a data breach or is too predictable. Please choose a different password.`)),P(!1);return}await B({username:p,password:await ee(_,p),role:y}),d(!1),g(``),v(``),I(!1),n()}catch(e){console.error(e),alert(K(e,l))}finally{P(!1)}},$=async e=>{if(confirm(l(`account.confirmDeleteUser`)))try{await V(e),n()}catch(e){console.error(e)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{size:20,className:`text-red-500`}),(0,Q.jsx)(x,{style:{margin:0},children:l(`account.userManagement`)}),W>0?(0,Q.jsxs)(M,{minimal:!0,intent:G?b.DANGER:b.PRIMARY,round:!0,children:[e.length,` / `,W]}):(0,Q.jsx)(M,{minimal:!0,round:!0,children:e.length})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,Q.jsx)(k,{label:l(`account.enableRegistration`,`开放新用户注册`),checked:R,disabled:H,onChange:e=>J(e.currentTarget.checked),className:`mb-0`}),(0,Q.jsx)(C,{className:`whitespace-nowrap`,icon:(0,Q.jsx)(h,{size:16}),intent:b.SUCCESS,text:l(`account.createUser`),disabled:G,title:G?l(`auth.maxUsersReached`,`当前系统已达到用户数量上限,无法创建新用户。`):void 0,onClick:()=>d(!0)})]})]}),(0,Q.jsx)(w,{elevation:T.ONE,className:`p-0 overflow-hidden overflow-x-auto`,children:(0,Q.jsxs)(N,{interactive:!0,striped:!0,className:`w-full whitespace-nowrap`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.username`)}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.role`)}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:`MFA`}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:`ID`}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.createdAt`)}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.lastActive`)}),(0,Q.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.lastResolve`)}),(0,Q.jsx)(`th`,{className:`text-right whitespace-nowrap`,children:l(`account.actions`)})]})}),(0,Q.jsx)(`tbody`,{children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{className:`font-bold whitespace-nowrap`,children:e.username}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,Q.jsx)(M,{minimal:!0,intent:e.role===`admin`?b.DANGER:b.NONE,className:`whitespace-nowrap`,children:e.role===`admin`?l(`account.roleAdmin`):l(`account.roleUser`)})}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[!!e.totp_enabled&&(0,Q.jsx)(M,{minimal:!0,intent:b.SUCCESS,className:`whitespace-nowrap`,children:`TOTP`}),!!(e.passkeys_count&&e.passkeys_count>0)&&(0,Q.jsx)(M,{minimal:!0,intent:b.PRIMARY,className:`whitespace-nowrap`,children:`Passkey`}),!e.totp_enabled&&!(e.passkeys_count&&e.passkeys_count>0)&&(0,Q.jsx)(M,{minimal:!0,intent:b.NONE,style:{color:`#8a9ba8`},className:`whitespace-nowrap`,children:l(`account.mfaNone`,`无`)})]})}),(0,Q.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,Q.jsx)(`code`,{className:`text-xs`,children:e.id})}),(0,Q.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.created_at?q(new Date(e.created_at*1e3)):`-`}),(0,Q.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.last_active_at?q(new Date(e.last_active_at*1e3)):`-`}),(0,Q.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.last_resolve_at?q(new Date(e.last_resolve_at*1e3)):`-`}),(0,Q.jsx)(`td`,{className:`text-right whitespace-nowrap`,children:(0,Q.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:(0,Q.jsx)(C,{minimal:!0,intent:b.DANGER,icon:(0,Q.jsx)(m,{size:14}),disabled:e.id===t,onClick:()=>$(e.id)})})})]},e.id))})]})}),(0,Q.jsx)(A,{isOpen:u,onClose:()=>{d(!1),I(!1)},title:l(`account.createNewUser`),icon:`user`,children:(0,Q.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,Q.jsx)(j,{label:l(`account.username`),children:(0,Q.jsx)(O,{value:p,onChange:e=>g(e.target.value),placeholder:l(`auth.usernamePlaceholder`)})}),(0,Q.jsx)(j,{label:l(`account.initialPassword`),children:(0,Q.jsx)(O,{type:F?`text`:`password`,value:_,onChange:e=>v(e.target.value),placeholder:l(`auth.passwordPlaceholder`),rightElement:(0,Q.jsx)(C,{minimal:!0,icon:F?`eye-open`:`eye-off`,onClick:()=>I(!F),title:F?l(`auth.hidePassword`,`Hide password`):l(`auth.showPassword`,`Show password`)})})}),(0,Q.jsx)(j,{label:l(`account.userRole`),children:(0,Q.jsx)(D,{fill:!0,value:y,onChange:e=>S(e.target.value),options:[{label:l(`account.roleUser`),value:`user`},{label:l(`account.roleAdmin`),value:`admin`}]})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,Q.jsx)(C,{text:l(`account.cancel`),onClick:()=>d(!1)}),(0,Q.jsx)(C,{intent:b.PRIMARY,text:l(`account.createNow`),loading:E,onClick:Y})]})]})})]})},ie=({toasterRef:e,onSavingChange:t})=>{let{t:n}=f(),[r,a]=(0,Z.useState)(``),[o,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[D,k]=(0,Z.useState)(null),[A,N]=(0,Z.useState)([]),[P,L]=(0,Z.useState)(!1),[R,B]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(null),U=(0,Z.useCallback)(async()=>{L(!0);try{N(await z())}catch(e){console.warn(`Failed to fetch distributed filter lists`,e)}finally{L(!1)}},[]);(0,Z.useEffect)(()=>{J().then(e=>{e&&Array.isArray(e)&&h(e.map(e=>({label:String(n(e.label,{defaultValue:e.label})),url:String(e.url||``)})))}).catch(e=>console.warn(`Failed to fetch preset filters`,e)),U()},[n,U]);let W=async()=>{let i=r.trim();if(i){p(!0),k(null),_(null),t?.(!0);try{let t=await I(i);_(t),a(``);let r=t.failedCount>0?n(`admin.distributeFilter.toastPartialSuccess`,`系统过滤列表已下发至 {{added}} 位用户,{{failed}} 位用户下发失败`,{added:t.addedCount,failed:t.failedCount}):n(`admin.distributeFilter.toastSuccess`,`系统过滤列表已成功下发至 {{count}} 位用户`,{count:t.addedCount});e?.current?.show({message:r,intent:t.failedCount>0&&t.addedCount===0?b.DANGER:t.failedCount>0?b.WARNING:b.SUCCESS,icon:t.failedCount>0&&t.addedCount===0?`error`:`tick`}),t.addedCount>0&&N(e=>e.some(e=>e.url===t.url)?e.map(e=>e.url===t.url?{...e,userCount:e.userCount+t.addedCount,usernames:Array.from(new Set([...e.usernames,...t.addedUsernames]))}:e):[...e,{url:t.url,profileCount:t.affectedProfilesCount,userCount:t.addedCount,usernames:t.addedUsernames}].sort((e,t)=>e.url.localeCompare(t.url))),await U()}catch(t){let n=t instanceof Error?t.message:String(t);k(n),e?.current?.show({message:n,intent:b.DANGER,icon:`error`})}finally{p(!1),t?.(!1)}}},G=async r=>{B(r),H(null),t?.(!0);try{let t=await F(r);e?.current?.show({message:n(`admin.distributeFilter.toastRevokeSuccess`,`已成功撤回系统过滤列表,移除了 {{count}} 位用户的系统规则`,{count:t.revokedCount}),intent:b.SUCCESS,icon:`tick`}),N(e=>e.filter(e=>e.url!==r&&e.url!==t.url)),await U()}catch(t){let n=t instanceof Error?t.message:String(t);e?.current?.show({message:n,intent:b.DANGER,icon:`error`})}finally{B(null),t?.(!1)}};return(0,Q.jsxs)(w,{elevation:T.ZERO,className:`p-6 border border-gray-200 dark:border-gray-800 rounded-xl space-y-6`,children:[(0,Q.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(x,{className:`flex items-center space-x-2 text-base font-semibold`,children:[(0,Q.jsx)(i,{className:`w-5 h-5 text-indigo-500`}),(0,Q.jsx)(`span`,{children:n(`admin.distributeFilter.title`,`系统过滤列表 (管理员)`)})]}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:n(`admin.distributeFilter.description`,`向系统中所有用户账号下发系统级过滤列表。规则自动继承并应用于所有用户账号,带有“系统”标签。如果用户已存在相同规则则自动跳过。`)})]})}),m.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center space-x-1`,children:[(0,Q.jsx)(c,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{children:n(`admin.distributeFilter.quickPresets`,`快捷预设`)})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,Q.jsx)(C,{minimal:!0,small:!0,className:`text-xs`,intent:r===e.url?b.PRIMARY:b.NONE,onClick:()=>a(e.url),children:e.label},e.url))})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(j,{label:n(`admin.distributeFilter.urlLabel`,`规则列表 URL`),labelFor:`distribute-filter-url`,helperText:n(`admin.distributeFilter.urlHelper`,`支持 AdGuard、Hosts、EasyList 等标准格式 URL`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,Q.jsx)(O,{id:`distribute-filter-url`,fill:!0,placeholder:`https://example.com/filter.txt`,value:r,onChange:e=>a(e.target.value),disabled:o,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&r.trim()&&!o&&W()}}),(0,Q.jsx)(C,{intent:b.PRIMARY,icon:(0,Q.jsx)(i,{className:`w-4 h-4 mr-1`}),text:n(`admin.distributeFilter.submitBtn`,`立即下发`),loading:o,disabled:!r.trim(),onClick:W,className:`shrink-0`})]})}),D&&(0,Q.jsxs)(v,{intent:b.DANGER,icon:null,children:[(0,Q.jsxs)(S,{className:`flex items-center gap-2 mb-2 font-semibold`,children:[(0,Q.jsx)(d,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:n(`common.error`,`错误`)})]}),(0,Q.jsx)(`div`,{className:`text-sm`,children:D})]}),g&&(0,Q.jsxs)(v,{intent:g.failedCount>0?g.addedCount>0?b.WARNING:b.DANGER:b.SUCCESS,icon:null,children:[(0,Q.jsxs)(S,{className:`flex items-center gap-2 mb-2 font-semibold`,children:[g.failedCount>0&&g.addedCount===0?(0,Q.jsx)(d,{className:`w-4 h-4 shrink-0 text-red-500`}):(0,Q.jsx)(u,{className:`w-4 h-4 shrink-0 text-green-500`}),(0,Q.jsx)(`span`,{children:n(`admin.distributeFilter.resultTitle`,`下发执行完成`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,Q.jsx)(`p`,{children:g.failedCount>0?n(`admin.distributeFilter.resultSummaryWithFailed`,`系统共 {{total}} 位用户:成功下发至 {{added}} 位用户,跳过 {{skipped}} 位已存在该规则的用户,{{failed}} 位用户下发失败。`,{total:g.totalUsers,added:g.addedCount,skipped:g.skippedCount,failed:g.failedCount}):n(`admin.distributeFilter.resultSummary`,`系统共 {{total}} 位用户:成功下发至 {{added}} 位用户,跳过 {{skipped}} 位已存在该规则的用户。`,{total:g.totalUsers,added:g.addedCount,skipped:g.skippedCount})}),g.addedUsernames.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-gray-500`,children:[n(`admin.distributeFilter.addedUsers`,`下发成功用户`),`:`]}),g.addedUsernames.map(e=>(0,Q.jsx)(M,{intent:b.SUCCESS,minimal:!0,round:!0,children:e},e))]}),g.skippedUsernames.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-gray-500`,children:[n(`admin.distributeFilter.skippedUsers`,`已存在规则用户`),`:`]}),g.skippedUsernames.map(e=>(0,Q.jsx)(M,{intent:b.NONE,minimal:!0,round:!0,children:e},e))]}),g.failedUsernames.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-red-500 dark:text-red-400`,children:[n(`admin.distributeFilter.failedUsers`,`下发失败用户`),`:`]}),g.failedUsernames.map(e=>(0,Q.jsx)(M,{intent:b.DANGER,minimal:!0,round:!0,children:e},e))]})]})]})]}),(0,Q.jsx)(E,{}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`text-sm font-semibold flex items-center space-x-2`,children:[(0,Q.jsx)(l,{className:`w-4 h-4 text-indigo-500`}),(0,Q.jsx)(`span`,{children:n(`admin.distributeFilter.activeDistributedTitle`,`已下发系统规则`)})]}),A.length>0&&(0,Q.jsx)(M,{minimal:!0,round:!0,intent:b.PRIMARY,children:A.length})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:n(`admin.distributeFilter.activeDistributedDesc`,`当前处于系统下发状态且带有“系统”标签的规则列表。撤回后将从所有用户账号中移除此系统规则,用户自建的同名规则不受影响。`)}),P?(0,Q.jsx)(`div`,{className:`text-xs text-gray-400 py-3 text-center`,children:n(`common.loading`,`加载中...`)}):A.length===0?(0,Q.jsx)(`div`,{className:`text-xs text-gray-400 dark:text-gray-500 py-4 px-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg text-center border border-dashed border-gray-200 dark:border-gray-700`,children:n(`admin.distributeFilter.noDistributedFilters`,`当前系统中无已下发的系统过滤列表`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-gray-800 border border-gray-200 dark:border-gray-800 rounded-lg overflow-hidden`,children:A.map(e=>(0,Q.jsxs)(`div`,{className:`p-3 bg-white dark:bg-gray-900 flex flex-col sm:flex-row sm:items-center justify-between gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`font-mono text-xs text-gray-800 dark:text-gray-200 truncate select-all`,title:e.url,children:e.url}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-gray-500`,children:[(0,Q.jsx)(M,{minimal:!0,round:!0,intent:b.PRIMARY,children:n(`admin.distributeFilter.usersCount`,`{{count}} 位用户`,{count:e.userCount})}),e.usernames.length>0&&(0,Q.jsxs)(`span`,{className:`text-xs text-gray-400 truncate max-w-xs`,children:[`(`,e.usernames.join(`, `),`)`]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(y,{isOpen:V===e.url,onInteraction:t=>H(t?e.url:null),placement:`top-end`,portalClassName:`z-20000`,content:(0,Q.jsxs)(`div`,{className:`p-3 space-y-3 max-w-xs`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed m-0 text-gray-800 dark:text-gray-200`,children:n(`admin.distributeFilter.revokeConfirm`,`确定撤回此系统过滤列表?系统将从所有用户账号中移除此系统规则,用户自建的同名规则不受影响。`)}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(C,{small:!0,variant:`minimal`,text:n(`common.cancel`,`取消`),onClick:()=>H(null)}),(0,Q.jsx)(C,{small:!0,intent:b.DANGER,loading:R===e.url,text:n(`admin.distributeFilter.confirmRevoke`,`确认撤回`),onClick:()=>G(e.url)})]})]}),children:(0,Q.jsx)(C,{small:!0,intent:b.DANGER,minimal:!0,icon:(0,Q.jsx)(s,{className:`w-3.5 h-3.5`}),text:n(`admin.distributeFilter.revokeBtn`,`撤回`),loading:R===e.url,onClick:()=>H(e.url)})})})]},e.url))})]})]})},ae=({initialSettings:e,onRefresh:t,onSavingChange:n,toasterRef:r})=>{let{t:i}=f(),[a,s]=(0,Z.useState)(e),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{s(e)},[e]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(o,{size:20,className:`text-gray-500`}),(0,Q.jsx)(x,{style:{margin:0},children:i(`account.systemSettings`,`System Settings`)})]}),(0,Q.jsxs)(w,{elevation:T.ONE,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(x,{className:`text-sm font-bold opacity-70 text-blue-500`,children:`Cloudflare Turnstile`}),(0,Q.jsx)(j,{label:`Site Key`,children:(0,Q.jsx)(O,{value:a.turnstile_site_key||``,onChange:e=>s({...a,turnstile_site_key:e.target.value}),placeholder:`0x000...`})}),(0,Q.jsx)(j,{label:`Secret Key`,children:(0,Q.jsx)(O,{type:u?`text`:`password`,value:a.turnstile_secret_key||``,onChange:e=>s({...a,turnstile_secret_key:e.target.value}),placeholder:`0x000...`,rightElement:(0,Q.jsx)(C,{minimal:!0,icon:u?`eye-open`:`eye-off`,onClick:()=>d(!u),title:u?i(`auth.hidePassword`,`Hide password`):i(`auth.showPassword`,`Show password`)})})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(x,{className:`text-sm font-bold opacity-70 text-green-500`,children:i(`account.featureToggle`,`Feature Toggle`)}),(0,Q.jsx)(k,{label:i(`account.enableTurnstileSignup`,`Enable verification on Signup`),checked:a.turnstile_enabled_signup===`true`,onChange:e=>s({...a,turnstile_enabled_signup:String(e.currentTarget.checked)})}),(0,Q.jsx)(k,{label:i(`account.enableTurnstileLogin`,`Enable verification on Login`),checked:a.turnstile_enabled_login===`true`,onChange:e=>s({...a,turnstile_enabled_login:String(e.currentTarget.checked)})}),(0,Q.jsx)(E,{className:`my-2`}),(0,Q.jsx)(x,{className:`text-sm font-bold opacity-70 text-indigo-500`,children:i(`account.userLimits`,`User Quota`)}),(0,Q.jsx)(j,{label:i(`account.maxUsers`,`Max Users`),helperText:i(`account.maxUsersHelper`,`Maximum number of users allowed in the system (0 for unlimited).`),children:(0,Q.jsx)(O,{type:`number`,min:0,value:a.max_users||``,onChange:e=>s({...a,max_users:e.target.value}),placeholder:`0`})})]})]}),(0,Q.jsx)(E,{className:`my-4`}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(C,{intent:b.PRIMARY,icon:`floppy-disk`,text:i(`common.save`,`Save`),loading:c,onClick:async()=>{l(!0),n?.(!0);try{await X(L({turnstile_site_key:a.turnstile_site_key||``,turnstile_secret_key:a.turnstile_secret_key||``,turnstile_enabled_signup:a.turnstile_enabled_signup||`false`,turnstile_enabled_login:a.turnstile_enabled_login||`false`,max_users:a.max_users||`0`}),1e4),r?.current?.show({message:i(`common.saveSuccess`,`保存成功`),intent:b.SUCCESS,icon:`tick`}),t()}catch(t){console.error(t),s(e),r?.current?.show({message:t.message||i(`common.saveFailed`,`保存失败`),intent:b.DANGER,icon:`error`})}finally{l(!1),n?.(!1)}}})})]})]})},oe=({status:e,onRefresh:n,toasterRef:i})=>{let{t:a}=f(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),m=e?.migrations,h=m?.completed??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(p,{size:20,className:`text-gray-500`}),(0,Q.jsx)(x,{style:{margin:0},children:a(`account.databaseSettings`,`数据库 (管理员)`)})]}),m?(0,Q.jsx)(M,{large:!0,round:!0,intent:h?b.SUCCESS:b.WARNING,icon:h?(0,Q.jsx)(u,{size:16}):(0,Q.jsx)(d,{size:16}),className:`whitespace-nowrap self-start sm:self-auto`,children:h?a(`account.migrationCompleted`,`迁移已完成`):a(`account.migrationPending`,`有待执行迁移`)}):(0,Q.jsx)(M,{large:!0,round:!0,intent:b.NONE,className:`whitespace-nowrap self-start sm:self-auto`,children:a(`common.loading`,`加载中...`)})]}),(0,Q.jsx)(w,{elevation:T.ONE,children:(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.databaseEngine`,`数据库服务`)}),(0,Q.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:(e=>e===`Turso`?`Turso (libSQL)`:e===`D1`?`Cloudflare D1`:e===`File`?`SQLite (Local File)`:e||`SQLite`)(e?.databaseService)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.lastAppliedMigration`,`最近应用版本`)}),(0,Q.jsx)(`div`,{className:`text-sm font-medium font-mono text-gray-700 dark:text-gray-300 mt-1 truncate`,children:m?.lastApplied||a(`account.noMigrationsApplied`,`无`)})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.migrationStatus`,`架构状态`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-300 mt-1`,children:m?h?a(`account.migrationCompletedDesc`,{total:m?.totalAvailable||0}):a(`account.migrationPendingDesc`,{applied:m?.appliedCount||0,total:m?.totalAvailable||0,pending:m?.pendingCount||0}):a(`common.loading`,`加载中...`)})]}),!h&&m&&m.pendingFiles.length>0&&(0,Q.jsxs)(v,{intent:b.WARNING,icon:null,children:[(0,Q.jsxs)(S,{className:`flex items-center gap-2 mb-1 text-xs font-semibold`,children:[(0,Q.jsx)(d,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:a(`account.pendingMigrationsList`,`待应用的架构迁移文件:`)})]}),(0,Q.jsx)(`ul`,{className:`list-disc list-inside text-xs font-mono space-y-0.5 text-gray-700 dark:text-gray-300 max-h-32 overflow-y-auto`,children:m.pendingFiles.map(e=>(0,Q.jsx)(`li`,{children:e},e))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,Q.jsx)(C,{minimal:!0,icon:(0,Q.jsx)(t,{size:14,className:c?`animate-spin`:``}),text:a(`account.checkMigration`,`刷新状态`),onClick:async()=>{l(!0);try{await n(),window.dispatchEvent(new Event(`db-migration-updated`))}finally{l(!1)}},disabled:o||c}),(0,Q.jsx)(C,{intent:b.PRIMARY,icon:(0,Q.jsx)(r,{size:14}),text:o?a(`account.runningMigration`,`正在迁移...`):a(`account.runMigration`,`执行迁移`),loading:o,disabled:h||o,onClick:async()=>{s(!0);try{let e=await W();i?.current?.show({message:a(`account.migrationSuccess`,{count:e.appliedCount}),intent:b.SUCCESS,icon:`tick`}),await n(),window.dispatchEvent(new Event(`db-migration-updated`))}catch(e){console.error(e),i?.current?.show({message:e.message||a(`account.migrationFailed`),intent:b.DANGER,icon:`error`})}finally{s(!1)}}})]})]})})]})},se=({onSavingChange:e,toasterRef:t})=>{let[r,i]=(0,Z.useState)(null),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!0),{t:u}=f(),d=G(),[p,m]=(0,Z.useState)({}),[h,g]=(0,Z.useState)(null),_=async()=>{try{s(await Y())}catch(e){console.error(e)}},y=async()=>{try{m(await H())}catch(e){console.error(e)}},x=(0,Z.useCallback)(async()=>{try{g(await R())}catch(e){console.error(`Failed to fetch database status:`,e)}},[]),C=(0,Z.useCallback)(async()=>{try{let e=await U();i(e),e.role===`admin`&&(_(),y(),x())}catch(e){console.error(e)}finally{l(!1)}},[x]);return(0,Z.useEffect)(()=>{C()},[C]),c?(0,Q.jsx)(`div`,{className:`p-8 text-center`,children:u(`common.loading`,`加载中...`)}):r?.role===`admin`?(0,Q.jsxs)(`div`,{className:P(`max-w-5xl mx-auto space-y-8`,d?`p-0`:`px-8`),children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-start sm:items-end gap-3 flex-wrap sm:flex-nowrap`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`bp6-heading`,children:u(`system.title`,`系统管理`)}),(0,Q.jsx)(`p`,{className:`bp6-text-muted`,children:u(`system.subtitle`,`管理用户、系统过滤列表、系统配置与数据库维护`)})]}),(0,Q.jsx)(M,{large:!0,round:!0,intent:b.DANGER,icon:(0,Q.jsx)(a,{size:16}),className:`shrink-0 whitespace-nowrap`,children:u(`account.roleAdmin`,`管理员`)})]}),r?.jwt_secret_warning&&(0,Q.jsxs)(v,{intent:b.WARNING,icon:null,children:[(0,Q.jsxs)(S,{className:`flex items-center gap-2 mb-1 font-semibold`,children:[(0,Q.jsx)(n,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:u(`account.jwtSecretWarningTitle`)})]}),(0,Q.jsx)(`div`,{className:`text-sm leading-relaxed mt-1`,children:u(`account.jwtSecretWarningDesc`)})]}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)($,{users:o,currentUserId:r.id,onRefresh:_,registrationEnabled:p.registration_enabled!==`false`,maxUsers:p.max_users,onRefreshSettings:y,onSavingChange:e,toasterRef:t})}),(0,Q.jsx)(E,{}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(ie,{onSavingChange:e,toasterRef:t})}),(0,Q.jsx)(E,{}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(ae,{initialSettings:p,onRefresh:y,onSavingChange:e,toasterRef:t})}),(0,Q.jsx)(E,{}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(oe,{status:h,onRefresh:x,toasterRef:t})})]}):(0,Q.jsx)(`div`,{className:P(`max-w-5xl mx-auto space-y-6`,d?`p-0`:`px-8`),children:(0,Q.jsx)(v,{intent:b.DANGER,icon:`error`,title:u(`system.accessDenied`,`访问受限`),children:u(`system.accessDeniedDesc`,`当前页面仅限管理员访问。`)})})};export{se as SystemView};
@@ -1,4 +1,4 @@
1
- import{i as e,n as t}from"./rolldown-runtime-C4Xdq4VV.js";import{an as n,n as r,t as i}from"./vendor-react-DYK5a2J9.js";import{S as a,b as o}from"./vendor-icons-other-BTYC6Wvz.js";import{$ as s,A as c,B as l,C as u,D as d,E as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as ee,V as O,W as k,X as A,Y as te,Z as ne,_ as re,_t as j,a as ie,at as ae,b as oe,c as se,ct as ce,d as le,dt as ue,et as de,f as fe,ft as pe,g as me,h as he,ht as ge,i as _e,it as ve,j as ye,k as be,l as xe,lt as Se,m as Ce,mt as we,n as Te,nt as Ee,o as De,ot as Oe,p as ke,pt as Ae,q as je,r as Me,rt as Ne,s as Pe,st as Fe,tt as Ie,u as Le,ut as Re,v as ze,w as Be,x as Ve,y as He,z as M}from"./vendor-utils-Bab4qB3W.js";import{h as Ue}from"./index-DAjmisEt.js";var We=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`);function Ge(e){return typeof e==`string`?We.includes(e):!1}var N=e(a()),Ke=new Set(`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`));function qe(e){return typeof e==`string`?Ke.has(e):!1}function Je(e){return typeof e==`string`&&e.startsWith(`data-`)}function Ye(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qe(n)||Je(n))&&(t[n]=e[n]);return t}function Xe(e){if(e==null)return null;if((0,N.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return Ye(t)}return typeof e==`object`&&!Array.isArray(e)?Ye(e):null}function Ze(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qe(n)||Je(n)||Ge(n))&&(t[n]=e[n]);return t}function Qe(e){return e==null?null:(0,N.isValidElement)(e)?Ze(e.props):typeof e==`object`&&!Array.isArray(e)?Ze(e):null}var $e=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function et(){return et=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},et.apply(null,arguments)}function tt(e,t){if(e==null)return{};var n,r,i=nt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function nt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var rt=(0,N.forwardRef)((e,t)=>{var n=e.children,r=e.width,i=e.height,a=e.viewBox,o=e.className,s=e.style,c=e.title,l=e.desc,u=tt(e,$e),d=a||{width:r,height:i,x:0,y:0},f=j(`recharts-surface`,o);return N.createElement(`svg`,et({},Ze(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),N.createElement(`title`,null,c),N.createElement(`desc`,null,l),n)}),it=[`children`,`className`];function at(){return at=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},at.apply(null,arguments)}function ot(e,t){if(e==null)return{};var n,r,i=st(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function st(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ct=N.forwardRef((e,t)=>{var n=e.children,r=e.className,i=ot(e,it),a=j(`recharts-layer`,r);return N.createElement(`g`,at({className:a},Ze(i),{ref:t}),n)}),lt=4;function ut(e){var t=10**(arguments.length>1&&arguments[1]!==void 0?arguments[1]:lt),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function P(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+ut(i)+n},``)}var dt=e=>e===0?0:e>0?1:-1,ft=e=>typeof e==`number`&&e!=+e,pt=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,F=e=>(typeof e==`number`||e instanceof Number)&&!ft(e),mt=e=>F(e)||typeof e==`string`,ht=0,gt=e=>{var t=++ht;return`${e||``}${t}`},_t=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!F(e)&&typeof e!=`string`)return n;var i;if(pt(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return ft(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},vt=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[String(e[r])])n[String(e[r])]=!0;else return!0;return!1};function yt(e,t,n){return F(e)&&F(t)?ut(e+n*(t-e)):t}function bt(e,t,n){if(!(!e||!e.length))return e.find(e=>e&&(typeof t==`function`?t(e):ge(e,t))===n)}var I=e=>e==null,xt=e=>I(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function St(e){return e!=null}function Ct(){}function wt(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function Tt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Et(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Tt(Object(n),!0).forEach(function(t){Dt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dt(e,t,n){return(t=Ot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ot(e){var t=kt(e,`string`);return typeof t==`symbol`?t:t+``}function kt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var At=e=>{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=wt(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var ee={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(ee.height=Math.max(E.y+E.height-(l+u),0),ee.width=f),ee}if(n===`left`){var O={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(O.width=Math.max(O.x-E.x,0),O.height=u),O}if(n===`right`){var k={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(E.x+E.width-k.x,0),k.height=u),k}var A=o&&E?{width:g,height:u}:{};return n===`insideLeft`?Et({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},A):n===`insideRight`?Et({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},A):n===`insideTop`?Et({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},A):n===`insideBottom`?Et({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},A):n===`insideTopLeft`?Et({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},A):n===`insideTopRight`?Et({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},A):n===`insideBottomLeft`?Et({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},A):n===`insideBottomRight`?Et({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},A):n&&typeof n==`object`&&(F(n.x)||pt(n.x))&&(F(n.y)||pt(n.y))?Et({x:c+_t(n.x,g),y:l+_t(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},A):Et({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},A)},jt=[`top`,`left`,`right`,`bottom`];function Mt(e){return e==null?!1:typeof e==`object`?!0:jt.includes(e)}var Nt=(0,N.createContext)(null),Pt=e=>`radius`in e&&`startAngle`in e&&`endAngle`in e,Ft=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,N.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{Ge(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},It=(e,t,n)=>r=>(e(t,n,r),null),Lt=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];Ge(i)&&typeof a==`function`&&(r||={},r[i]=It(a,t,n))}),r};function Rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Rt(Object(n),!0).forEach(function(t){Bt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Bt(e,t,n){return(t=Vt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vt(e){var t=Ht(e,`string`);return typeof t==`symbol`?t:t+``}function Ht(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ut(e,t){var n=zt({},e),r=t;return Object.keys(t).reduce((e,t)=>(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function Wt(e,t,n){return t===!0?je(e,n):typeof t==`function`?je(e,t):e}var Gt=(0,N.createContext)(null),Kt=v(),qt=e=>e,L=()=>{var e=(0,N.useContext)(Gt);return e?e.store.dispatch:qt},Jt=()=>{},Yt=()=>Jt,Xt=(e,t)=>e===t;function R(e){var t=(0,N.useContext)(Gt),n=(0,N.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:Jt,[t,e]);return(0,Kt.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Yt,t?t.store.getState:Jt,t?t.store.getState:Jt,n,Xt)}var Zt=e=>e.legend.settings,Qt=e=>e.legend.size;m([e=>e.legend.payload,Zt],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?k(r,n):r});function $t(e,t){return an(e)||rn(e,t)||tn(e,t)||en()}function en(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{i as e,n as t}from"./rolldown-runtime-C4Xdq4VV.js";import{an as n,n as r,t as i}from"./vendor-react-DYK5a2J9.js";import{S as a,b as o}from"./vendor-icons-other-BTYC6Wvz.js";import{$ as s,A as c,B as l,C as u,D as d,E as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as ee,V as O,W as k,X as A,Y as te,Z as ne,_ as re,_t as j,a as ie,at as ae,b as oe,c as se,ct as ce,d as le,dt as ue,et as de,f as fe,ft as pe,g as me,h as he,ht as ge,i as _e,it as ve,j as ye,k as be,l as xe,lt as Se,m as Ce,mt as we,n as Te,nt as Ee,o as De,ot as Oe,p as ke,pt as Ae,q as je,r as Me,rt as Ne,s as Pe,st as Fe,tt as Ie,u as Le,ut as Re,v as ze,w as Be,x as Ve,y as He,z as M}from"./vendor-utils-Bab4qB3W.js";import{g as Ue}from"./index-BLk8QVje.js";var We=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`);function Ge(e){return typeof e==`string`?We.includes(e):!1}var N=e(a()),Ke=new Set(`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`));function qe(e){return typeof e==`string`?Ke.has(e):!1}function Je(e){return typeof e==`string`&&e.startsWith(`data-`)}function Ye(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qe(n)||Je(n))&&(t[n]=e[n]);return t}function Xe(e){if(e==null)return null;if((0,N.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return Ye(t)}return typeof e==`object`&&!Array.isArray(e)?Ye(e):null}function Ze(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qe(n)||Je(n)||Ge(n))&&(t[n]=e[n]);return t}function Qe(e){return e==null?null:(0,N.isValidElement)(e)?Ze(e.props):typeof e==`object`&&!Array.isArray(e)?Ze(e):null}var $e=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function et(){return et=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},et.apply(null,arguments)}function tt(e,t){if(e==null)return{};var n,r,i=nt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function nt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var rt=(0,N.forwardRef)((e,t)=>{var n=e.children,r=e.width,i=e.height,a=e.viewBox,o=e.className,s=e.style,c=e.title,l=e.desc,u=tt(e,$e),d=a||{width:r,height:i,x:0,y:0},f=j(`recharts-surface`,o);return N.createElement(`svg`,et({},Ze(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),N.createElement(`title`,null,c),N.createElement(`desc`,null,l),n)}),it=[`children`,`className`];function at(){return at=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},at.apply(null,arguments)}function ot(e,t){if(e==null)return{};var n,r,i=st(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function st(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var ct=N.forwardRef((e,t)=>{var n=e.children,r=e.className,i=ot(e,it),a=j(`recharts-layer`,r);return N.createElement(`g`,at({className:a},Ze(i),{ref:t}),n)}),lt=4;function ut(e){var t=10**(arguments.length>1&&arguments[1]!==void 0?arguments[1]:lt),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function P(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+ut(i)+n},``)}var dt=e=>e===0?0:e>0?1:-1,ft=e=>typeof e==`number`&&e!=+e,pt=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,F=e=>(typeof e==`number`||e instanceof Number)&&!ft(e),mt=e=>F(e)||typeof e==`string`,ht=0,gt=e=>{var t=++ht;return`${e||``}${t}`},_t=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!F(e)&&typeof e!=`string`)return n;var i;if(pt(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return ft(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},vt=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[String(e[r])])n[String(e[r])]=!0;else return!0;return!1};function yt(e,t,n){return F(e)&&F(t)?ut(e+n*(t-e)):t}function bt(e,t,n){if(!(!e||!e.length))return e.find(e=>e&&(typeof t==`function`?t(e):ge(e,t))===n)}var I=e=>e==null,xt=e=>I(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function St(e){return e!=null}function Ct(){}function wt(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function Tt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Et(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Tt(Object(n),!0).forEach(function(t){Dt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dt(e,t,n){return(t=Ot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ot(e){var t=kt(e,`string`);return typeof t==`symbol`?t:t+``}function kt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var At=e=>{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=wt(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var ee={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(ee.height=Math.max(E.y+E.height-(l+u),0),ee.width=f),ee}if(n===`left`){var O={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(O.width=Math.max(O.x-E.x,0),O.height=u),O}if(n===`right`){var k={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(E.x+E.width-k.x,0),k.height=u),k}var A=o&&E?{width:g,height:u}:{};return n===`insideLeft`?Et({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},A):n===`insideRight`?Et({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},A):n===`insideTop`?Et({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},A):n===`insideBottom`?Et({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},A):n===`insideTopLeft`?Et({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},A):n===`insideTopRight`?Et({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},A):n===`insideBottomLeft`?Et({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},A):n===`insideBottomRight`?Et({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},A):n&&typeof n==`object`&&(F(n.x)||pt(n.x))&&(F(n.y)||pt(n.y))?Et({x:c+_t(n.x,g),y:l+_t(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},A):Et({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},A)},jt=[`top`,`left`,`right`,`bottom`];function Mt(e){return e==null?!1:typeof e==`object`?!0:jt.includes(e)}var Nt=(0,N.createContext)(null),Pt=e=>`radius`in e&&`startAngle`in e&&`endAngle`in e,Ft=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,N.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{Ge(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},It=(e,t,n)=>r=>(e(t,n,r),null),Lt=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];Ge(i)&&typeof a==`function`&&(r||={},r[i]=It(a,t,n))}),r};function Rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Rt(Object(n),!0).forEach(function(t){Bt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Bt(e,t,n){return(t=Vt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vt(e){var t=Ht(e,`string`);return typeof t==`symbol`?t:t+``}function Ht(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ut(e,t){var n=zt({},e),r=t;return Object.keys(t).reduce((e,t)=>(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function Wt(e,t,n){return t===!0?je(e,n):typeof t==`function`?je(e,t):e}var Gt=(0,N.createContext)(null),Kt=v(),qt=e=>e,L=()=>{var e=(0,N.useContext)(Gt);return e?e.store.dispatch:qt},Jt=()=>{},Yt=()=>Jt,Xt=(e,t)=>e===t;function R(e){var t=(0,N.useContext)(Gt),n=(0,N.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:Jt,[t,e]);return(0,Kt.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Yt,t?t.store.getState:Jt,t?t.store.getState:Jt,n,Xt)}var Zt=e=>e.legend.settings,Qt=e=>e.legend.size;m([e=>e.legend.payload,Zt],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?k(r,n):r});function $t(e,t){return an(e)||rn(e,t)||tn(e,t)||en()}function en(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tn(e,t){if(e){if(typeof e==`string`)return nn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nn(e,t):void 0}}function nn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function rn(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function an(e){if(Array.isArray(e))return e}var on=1;function sn(e,t){return Math.abs(e.height-t.height)>on||Math.abs(e.left-t.left)>on||Math.abs(e.top-t.top)>on||Math.abs(e.width-t.width)>on}function cn(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function ln(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=$t((0,N.useState)({height:0,left:0,top:0,width:0}),2),n=t[0],r=t[1],i=(0,N.useRef)(null),a=(0,N.useRef)(n);a.current=n;var o=(0,N.useCallback)(e=>{if(i.current!=null&&(i.current.disconnect(),i.current=null),e!=null){var t=cn(e);if(sn(t,a.current)&&r(t),typeof ResizeObserver<`u`){var n=new ResizeObserver(()=>{var t=cn(e);sn(t,a.current)&&r(t)});n.observe(e),i.current=n}}},[...e]);return(0,N.useEffect)(()=>()=>{var e;(e=i.current)==null||e.disconnect()},[]),[n,o]}var un=M({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),dn=un.actions,fn=dn.setMargin,pn=dn.setLayout,mn=dn.setChartSize,hn=dn.setScale,gn=un.reducer;function _n(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function z(e){return Number.isFinite(e)}function vn(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function yn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yn(Object(n),!0).forEach(function(t){xn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xn(e,t,n){return(t=Sn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sn(e){var t=Cn(e,`string`);return typeof t==`symbol`?t:t+``}function Cn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function B(e,t,n){return I(e)||I(t)?n:mt(t)?ge(e,t,n):typeof t==`function`?t(e):n}var wn=(e,t,n)=>{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout,c=t.position,l=t.offset,u=l===void 0?0:l;if(c!=null){if(Mt(c)){if(c===`top`&&F(e.top))return bn(bn({},e),{},{top:e.top+(i||0)+u});if(c===`bottom`&&F(e.bottom))return bn(bn({},e),{},{bottom:e.bottom+(i||0)+u});if(c===`left`&&F(e.left))return bn(bn({},e),{},{left:e.left+(r||0)+u});if(c===`right`&&F(e.right))return bn(bn({},e),{},{right:e.right+(r||0)+u})}return e}if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&F(e[a]))return bn(bn({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&F(e[o]))return bn(bn({},e),{},{[o]:e[o]+(i||0)})}return e},Tn=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,En=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},Dn=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?dt(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return z(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(St):c&&l?l.map((e,t)=>{var n=o.map(e);return z(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(St):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return z(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(St):o.domain().map((e,t)=>{var n=o.map(e);return z(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(St)},On={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r<n;++r)for(var i=0,a=0,o=0;o<t;++o){var s=e[o]?.[r];if(s!=null){var c=s[1],l=s[0],u=ft(c)?l:c;u>=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:A,none:s,silhouette:te,wiggle:_,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r<n;++r)for(var i=0,a=0;a<t;++a){var o=e[a]?.[r];if(o!=null){var s=ft(o[1])?o[0]:o[1];s>=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},kn=(e,t,n)=>{var r=On[n]??s,i=ne().keys(t).value((e,t)=>Number(B(e,t,0))).order(w).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=B(e[i],t[r],0);Array.isArray(a)&&a.length===2&&F(a[0])&&F(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function An(e){return e==null?void 0:String(e)}function jn(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!I(i[t.dataKey])){var s=bt(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=B(i,I(o)?t.dataKey:o),l=t.scale.map(c);return F(l)?l:null}var Mn=e=>{var t=e.flat(2).filter(F);return[Math.min(...t),Math.max(...t)]},Nn=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],Pn=(e,t,n)=>{if(!(e==null||Object.keys(e).length===0))return Nn(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=Mn(_n(r,t,n));return!z(i[0])||!z(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},Fn=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,In=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ln=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=k(t,e=>e.coordinate),a=[],o=0,s=1,c=i.length;s<c;s++){var l=(i[s]?.coordinate||0)-(i[s-1]?.coordinate||0);a.push(l),o=Math.max(l,o)}var u=o*1e-4,d=1/0;for(var f of a)f>u&&(d=Math.min(f,d));return d===1/0?0:d}return n?void 0:0};function Rn(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return bn(bn({},t),{},{dataKey:n,payload:r,value:i,name:a})}function zn(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var Bn=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},Vn=(e,t)=>t===`centric`?e.angle:e.radius,Hn=e=>e.layout.width,Un=e=>e.layout.height,Wn=e=>e.layout.scale,Gn=e=>e.layout.margin,Kn=m(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),qn=m(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Jn=`data-recharts-item-index`;function Yn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Xn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Yn(Object(n),!0).forEach(function(t){Zn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zn(e,t,n){return(t=Qn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qn(e){var t=$n(e,`string`);return typeof t==`symbol`?t:t+``}function $n(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var er=e=>e.brush.height;function tr(e){return qn(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function nr(e){return qn(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function rr(e){return Kn(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}function ir(e){return Kn(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}var V=m([Hn,Un,Gn,er,tr,nr,rr,ir,Zt,Qt],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=Xn(Xn({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=wn(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return Xn(Xn({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),ar=m(V,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),or=m(Hn,Un,(e,t)=>({x:0,y:0,width:e,height:t})),sr=(0,N.createContext)(null),cr=()=>(0,N.useContext)(sr)!=null,lr=e=>e.brush,ur=m([lr,V,Gn],(e,t,n)=>({height:e.height,x:F(e.x)?e.x:t.left,y:F(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:F(e.width)?e.width:t.width})),dr=!0,fr=function(e,t){var n=[...arguments].slice(2);if(dr&&typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e))if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}},pr={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},mr=(e,t,n)=>{var r=n.width,i=r===void 0?pr.width:r,a=n.height,o=a===void 0?pr.height:a,s=n.aspect,c=n.maxHeight,l=pt(i)?e:Number(i),u=pt(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},hr={width:0,height:0,overflow:`visible`},gr={width:0,overflowX:`visible`},_r={height:0,overflowY:`visible`},vr={},yr=e=>{var t=e.width,n=e.height,r=pt(t),i=pt(n);return r&&i?hr:r?gr:i?_r:vr};function br(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=pr.width,a=pr.height):i===void 0?i=r&&r>0?void 0:pr.width:a===void 0&&(a=r&&r>0?void 0:pr.height),{width:i,height:a}}var xr=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function Sr(){return Sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Sr.apply(null,arguments)}function Cr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Cr(Object(n),!0).forEach(function(t){Tr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tr(e,t,n){return(t=Er(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Er(e){var t=Dr(e,`string`);return typeof t==`symbol`?t:t+``}function Dr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Or(e,t){return Nr(e)||Mr(e,t)||Ar(e,t)||kr()}function kr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ar(e,t){if(e){if(typeof e==`string`)return jr(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jr(e,t):void 0}}function jr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Mr(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Nr(e){if(Array.isArray(e))return e}function Pr(e,t){if(e==null)return{};var n,r,i=Fr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Fr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ir=(0,N.createContext)(pr.initialDimension);function Lr(e){return vn(e.width)&&vn(e.height)}function Rr(e){var t=e.children,n=e.width,r=e.height,i=(0,N.useMemo)(()=>({width:n,height:r}),[n,r]);return Lr(i)?N.createElement(Ir.Provider,{value:i},t):null}var zr=()=>(0,N.useContext)(Ir),Br=(0,N.forwardRef)((e,t)=>{var n=e.aspect,r=e.initialDimension,i=r===void 0?pr.initialDimension:r,a=e.width,o=e.height,s=e.minWidth,c=s===void 0?pr.minWidth:s,l=e.minHeight,u=e.maxHeight,d=e.children,f=e.debounce,p=f===void 0?pr.debounce:f,m=e.id,h=e.className,g=e.onResize,_=e.style,v=_===void 0?{}:_,y=Pr(e,xr),b=(0,N.useRef)(null),x=(0,N.useRef)();x.current=g,(0,N.useImperativeHandle)(t,()=>b.current);var S=Or((0,N.useState)({containerWidth:i.width,containerHeight:i.height}),2),w=S[0],T=S[1],E=(0,N.useCallback)((e,t)=>{T(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,N.useEffect)(()=>{if(b.current==null||typeof ResizeObserver>`u`)return Ct;var e=e=>{var t,n=e[0];if(n!=null){var r=n.contentRect,i=r.width,a=r.height;E(i,a),(t=x.current)==null||t.call(x,i,a)}};p>0&&(e=C(e,p,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),n=b.current.getBoundingClientRect(),r=n.width,i=n.height;return E(r,i),t.observe(b.current),()=>{t.disconnect()}},[E,p]);var D=w.containerWidth,ee=w.containerHeight;fr(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var O=mr(D,ee,{width:a,height:o,aspect:n,maxHeight:u}),k=O.calculatedWidth,A=O.calculatedHeight;return fr(D<0||ee<0||k!=null&&k>0||A!=null&&A>0,`The width(%s) and height(%s) of chart should be greater than 0,
4
4
  please check the style of container, or the props width(%s) and height(%s),
@@ -0,0 +1 @@
1
+ import{_ as e,g as t,v as n}from"./index-BLk8QVje.js";export{e as setSystemLocale,n as setSystemTimeZone};