| 123 |
- import{a as e,n as t,r as n}from"./react-dom-stZKkA6x.js";import{a as r,c as i,d as a,r as o,u as s}from"./theme-DI8XQWlV.js";import{G as c,i as l,kt as u,n as d,st as f,t as p}from"./jsx-runtime-dm82oUI8.js";import{a as ee,i as m,o as h,t as te}from"./grid-CbrYQCAq.js";import{n as ne,t as re}from"./table-Cy9MyhM5.js";import{t as g}from"./badge-CT2dDAGA.js";import{a as ie,n as ae,r as oe,t as se}from"./StatusPill-DYejnVUU.js";import{t as ce}from"./input-number-5vwSxUlw.js";import{t as _}from"./descriptions-vs1os_w7.js";import{t as v}from"./form-DcO_GhUr.js";import{t as y}from"./input-0_Xo22Fl.js";import{t as b}from"./list-BBhECcFB.js";import{t as le}from"./modal-tQWt4gNJ.js";import{t as ue}from"./CopyOutlined-DIsSRLKB.js";import{n as x,t as de}from"./EditOutlined-D5870S0F.js";import{t as fe}from"./PlusOutlined-BsubesQg.js";import{t as pe}from"./ReloadOutlined-CymPmaTf.js";import{t as me}from"./SearchOutlined-D3DEMDXm.js";import{_ as he,a as S,b as ge,f as _e,h as ve,i as ye,m as be,n as xe,p as Se,r as Ce,s as C,t as we}from"./index-8y_yP12y.js";import{t as w}from"./EmptyState-rI31ioMm.js";import{t as T}from"./CodeBlock-B8oVHT9c.js";import{n as E,t as Te}from"./navigation-state-ixI_efPF.js";var D=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-40 824H232V687h97.9c11.6 32.8 32 62.3 59.1 84.7 34.5 28.5 78.2 44.3 123 44.3s88.5-15.7 123-44.3c27.1-22.4 47.5-51.9 59.1-84.7H792v-63H643.6l-5.2 24.7C626.4 708.5 573.2 752 512 752s-114.4-43.5-126.5-103.3l-5.2-24.7H232V136h560v752zM320 341h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8zm0 160h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z`}}]},name:`container`,theme:`outlined`}})),O=e(t()),k=e(D());function A(){return A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(this,arguments)}var Ee=O.forwardRef((e,t)=>O.createElement(s,A({},e,{ref:t,icon:k.default}))),j=e(n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z`}}]},name:`file-text`,theme:`outlined`}}))());function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},M.apply(this,arguments)}var N=O.forwardRef((e,t)=>O.createElement(s,M({},e,{ref:t,icon:j.default}))),De=e(n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z`}}]},name:`folder`,theme:`outlined`}}))());function P(){return P=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},P.apply(this,arguments)}var F=O.forwardRef((e,t)=>O.createElement(s,P({},e,{ref:t,icon:De.default}))),I=p(),Oe=[`INBOX`,`Sent`,`Drafts`,`Trash`,`Junk`,`Archive`];function L(){let{message:e}=a.useApp(),t=te.useBreakpoint(),n=we(`(min-width: 1280px)`),{locale:s,t:p}=r(),{config:g,user:ue}=xe(),x=_e(),S=Se(),Ce=be(),[C,T]=ve(),[D]=v.useForm(),[k]=v.useForm(),[A,Ee]=(0,O.useState)([]),[j,M]=(0,O.useState)([]),[N,De]=(0,O.useState)([]),[P,F]=(0,O.useState)(We()),[Oe,L]=(0,O.useState)([]),[Ne,Pe]=(0,O.useState)(0),[R,z]=(0,O.useState)(null),[Ke,qe]=(0,O.useState)(!0),[B,Xe]=(0,O.useState)(!1),[Ze,Qe]=(0,O.useState)(!1),[$e,et]=(0,O.useState)(!1),[tt,nt]=(0,O.useState)(``),[rt,it]=(0,O.useState)(``),[at,ot]=(0,O.useState)(``),[st,ct]=(0,O.useState)(``),[lt,ut]=(0,O.useState)(``),[dt,ft]=(0,O.useState)(``),[pt,mt]=(0,O.useState)(``),[ht,gt]=(0,O.useState)(C.get(`q`)||``),[_t,vt]=(0,O.useState)(!1),[V,yt]=(0,O.useState)(null),[bt,xt]=(0,O.useState)(``),[St,Ct]=(0,O.useState)(`activity`),[wt,Tt]=(0,O.useState)(``),[Et,Dt]=(0,O.useState)(`domain`),[Ot,H]=(0,O.useState)(null),[kt,At]=(0,O.useState)(null),jt=(0,O.useRef)(null),Mt=(0,O.useRef)(0),U=(0,O.useRef)(0),W=(0,O.useRef)(0),G=(0,O.useRef)(0),K=(0,O.useRef)(0),q=C.get(`workspace`)===`routing`?`routing`:`messages`,J=Number(C.get(`mailboxId`)||0)||null,Nt=C.get(`folder`)||`INBOX`,Pt=C.get(`read`)||`all`,Y=C.get(`q`)||``,Ft=Math.max(1,Number(C.get(`page`)||1)||1),X=Number(Ce.messageId||0)||null,It=Me(C.get(`tab`));(0,O.useEffect)(()=>{gt(Y)},[Y]);let Lt=(0,O.useMemo)(()=>N.map(e=>({value:e.id,label:s.startsWith(`en`)?`${e.address} · ${e.unreadCount} unread / ${e.messageCount} total`:`${e.address} · ${e.unreadCount} 未读 / ${e.messageCount} 封`})),[s,N]),Rt=(0,O.useMemo)(()=>j.map(e=>{let t=ue?.id===e.userId;return{value:e.domain,label:(0,I.jsxs)(l,{size:8,children:[(0,I.jsxs)(d.Text,{children:[`@`,e.domain]}),(0,I.jsx)(he,{color:t?`blue`:`purple`,children:p(t?`inbox.ownDomain`:`inbox.sharedDomain`)})]})}}),[j,p,ue?.id]),zt=(0,O.useMemo)(()=>ze(Re(N,bt),St),[bt,St,N]),Bt=(0,O.useMemo)(()=>He(Ve(A,wt),Et),[A,wt,Et]),Z=(0,O.useCallback)(async()=>{let e=++Mt.current;qe(!0),nt(``),it(``);let[t,n,r]=await Promise.allSettled([o.domains(),o.inboundMailboxDomains(),o.inboundMailboxes()]);e===Mt.current&&(t.status===`fulfilled`?Ee(t.value.domains||[]):it(t.reason instanceof Error?t.reason.message:p(`common.error`)),n.status===`fulfilled`?M(n.value.domains||[]):it(n.reason instanceof Error?n.reason.message:p(`common.error`)),r.status===`fulfilled`?De(r.value.mailboxes||[]):nt(r.reason instanceof Error?r.reason.message:p(`common.error`)),qe(!1))},[p]);(0,O.useEffect)(()=>(Z(),()=>{Mt.current+=1}),[Z]),(0,O.useEffect)(()=>{if(!N.length||X&&(!C.has(`mailboxId`)||!C.has(`folder`))||J&&N.some(e=>e.id===J))return;let e=Le(N,J);if(!e)return;let t=new URLSearchParams(C);t.set(`mailboxId`,String(e)),t.set(`folder`,`INBOX`),t.set(`page`,`1`),T(t,{replace:!0})},[N,X,C,J,T]);let Q=(0,O.useCallback)(async()=>{let e=++U.current;if(!J){F(We()),ut(``),et(!1);return}et(!0),ut(``),F(We());try{let t=await o.inboundFolders(J);if(e!==U.current)return;if(!t.folders?.length)throw Error(s.startsWith(`en`)?`Folder counts are unavailable.`:`文件夹计数暂不可用。`);F(t.folders.map(e=>({...e,countsAvailable:!0})))}catch(t){if(e!==U.current)return;F(We()),ut(t instanceof Error?t.message:s.startsWith(`en`)?`Unable to load folder counts.`:`文件夹计数加载失败。`)}finally{e===U.current&&et(!1)}},[s,J]);(0,O.useEffect)(()=>(Q(),()=>{U.current+=1}),[Q]);let $=(0,O.useCallback)(async()=>{let e=++W.current;if(!J||q!==`messages`){L([]),Pe(0),ot(``),Xe(!1);return}Xe(!0),ot(``);try{let t=await o.inboundMessages({mailboxId:J,folder:Nt,page:Ft,pageSize:25,q:Y||void 0,read:Pt===`read`?!0:Pt===`unread`?!1:void 0});if(e!==W.current)return;L(t.messages||[]),Pe(t.total??t.messages?.length??0)}catch(t){e===W.current&&ot(t instanceof Error?t.message:p(`common.error`))}finally{e===W.current&&Xe(!1)}},[Nt,Ft,Y,Pt,J,p,q]);(0,O.useEffect)(()=>($(),()=>{W.current+=1}),[$]),(0,O.useEffect)(()=>{let e=++G.current;if(K.current+=1,ft(``),!X){z(null),ct(``),Qe(!1);return}return Qe(!0),ct(``),o.inboundMessage(X).then(t=>{if(e!==G.current)return;let n=t.message;if(!n){ct(p(`inbox.messageNotFound`));return}if(z(n),!n.read){let t=++K.current;o.markInboundMessageRead(n.id,!0).then(()=>{e!==G.current||t!==K.current||(z(e=>e?.id===n.id?{...e,read:!0}:e),L(e=>e.map(e=>e.id===n.id?{...e,read:!0}:e)),De(e=>e.map(e=>e.id===n.mailboxId?{...e,unreadCount:Math.max(0,e.unreadCount-1)}:e)),Q())}).catch(n=>{e!==G.current||t!==K.current||ft(n instanceof Error?n.message:s.startsWith(`en`)?`Unable to mark this message as read.`:`邮件标记已读失败。`)})}}).catch(t=>{e===G.current&&ct(t instanceof Error?t.message:p(`inbox.detailLoadFailed`))}).finally(()=>{e===G.current&&Qe(!1)}),()=>{G.current===e&&(G.current+=1),K.current+=1}},[Q,s,X,p]),(0,O.useEffect)(()=>{if(!X||R?.id!==X||C.has(`mailboxId`)&&C.has(`folder`))return;let e=new URLSearchParams(C);e.set(`mailboxId`,String(R.mailboxId)),e.set(`folder`,R.folder||`INBOX`),T(e,{replace:!0})},[X,C,R,T]),(0,O.useEffect)(()=>{let e=jt.current;!e||E(x.state)?.origin===`direct`||(jt.current=null,S(e,{replace:!0}))},[x.key,x.state,S]);function Vt(e){let t=new URLSearchParams(C);Object.entries(e).forEach(([e,n])=>{n===null||n===``?t.delete(e):t.set(e,String(n))}),T(t)}function Ht(e){let t=new URLSearchParams(C);e===`routing`?t.set(`workspace`,`routing`):t.delete(`workspace`);let n=t.toString();S(`/inbox${n?`?${n}`:``}`)}function Ut(e){let t=new URLSearchParams(C);t.set(`mailboxId`,String(e)),t.set(`folder`,`INBOX`),t.set(`page`,`1`);let n=t.toString();S(`/inbox${n?`?${n}`:``}`)}function Wt(e){let t=new URLSearchParams(C);t.set(`folder`,e),t.set(`page`,`1`);let n=t.toString();S(`/inbox${n?`?${n}`:``}`)}function Gt(e){z(e);let t=C.toString(),n=`/inbox/messages/${e.id}${t?`?${t}`:``}`,r=E(x.state);if(r){S(n,{state:Te(r.listPath,r.depth+1,r.origin)});return}if(X){S(n,{replace:!0});return}S(n,{state:Te(`${x.pathname}${x.search}`,1)})}function Kt(){let e=E(x.state);if(e?.origin===`list`){S(-e.depth);return}let t=R?.id===X?R:null,n=Fe(C,t);if(e?.origin===`direct`){jt.current=n,S(-e.depth);return}S(n,{replace:!0})}function qt(e){let t=new URLSearchParams(C);e===`text`?t.delete(`tab`):t.set(`tab`,e);let n=E(x.state),r=R?.id===X?R:null,i=t.toString();S({pathname:x.pathname,search:i?`?${i}`:``},{state:Te(n?.listPath||Fe(C,r),(n?.depth||0)+1,n?.origin||`direct`)})}async function Jt(t){t&&(await navigator.clipboard.writeText(t),e.success(p(`common.copied`)))}function Yt(){yt(null),D.resetFields(),D.setFieldsValue({domain:j[0]?.domain,password:Ye(),quotaMb:1024,keepForwarded:!0,status:`active`}),vt(!0)}function Xt(e){yt(e),D.resetFields(),D.setFieldsValue({localPart:e.localPart,domain:e.domain,password:``,displayName:e.displayName,quotaMb:e.quotaMb,aliases:e.aliases.join(`
- `),forwardTo:e.forwardTo.join(`
- `),keepForwarded:e.keepForwarded,status:e.status}),vt(!0)}function Zt(){vt(!1),yt(null),D.resetFields()}async function Qt(){let t=await D.validateFields(),n=V?`mailbox:update:${V.id}`:`mailbox:create`;mt(n);try{if(V){let n=String(t.password||``).trim(),r=await o.updateInboundMailbox(V.id,{displayName:t.displayName||``,aliases:t.aliases||``,forwardTo:t.forwardTo||``,keepForwarded:!!t.keepForwarded,quotaMb:t.quotaMb??null,status:t.status||V.status,...n?{password:n}:{}});e.success(s.startsWith(`en`)?`Mailbox updated`:`收信邮箱已更新`),n&&H(r.clientConfig||Je(r.mailbox,g,n))}else{let n=await o.createInboundMailbox({address:`${t.localPart}@${t.domain}`,displayName:t.displayName,password:t.password,aliases:t.aliases,forwardTo:t.forwardTo,keepForwarded:t.keepForwarded,quotaMb:t.quotaMb});e.success(p(`actions.inboundMailboxCreated`)),H(n.clientConfig||Je(n.mailbox,g,t.password))}Zt(),await Z()}catch(t){e.error(t instanceof Error?t.message:p(`common.error`))}finally{mt(``)}}function $t(e){At(e),k.setFieldsValue({catchAllAddress:e.catchAllAddress||``})}async function en(){if(!kt)return;let t=await k.validateFields();mt(`catch-all:${kt.id}`);try{let n=await o.patchDomain(kt.id,{catchAllAddress:String(t.catchAllAddress||``).trim()});Ee(e=>e.map(e=>e.id===n.domain.id?n.domain:e)),At(null),e.success(p(`actions.domainSaved`))}catch(t){e.error(t instanceof Error?t.message:p(`common.error`))}finally{mt(``)}}let tn=[{title:p(`inbox.mailboxAddress`),dataIndex:`address`,render:(e,t)=>(0,I.jsxs)(l,{direction:`vertical`,size:0,children:[(0,I.jsx)(d.Text,{strong:!0,children:e}),t.displayName?(0,I.jsx)(d.Text,{type:`secondary`,children:t.displayName}):null]})},{title:p(`common.status`),dataIndex:`status`,width:120,render:e=>(0,I.jsx)(se,{tone:e===`active`?`success`:`warning`,children:e})},{title:p(`inbox.forwardTo`),dataIndex:`forwardTo`,render:(e,t)=>e?.length?(0,I.jsxs)(l,{direction:`vertical`,size:2,children:[(0,I.jsx)(d.Text,{children:e.join(`, `)}),(0,I.jsx)(he,{children:t.keepForwarded?p(`inbox.keepForwarded`):p(`inbox.forwardOnly`)})]}):`—`},{title:p(`inbox.unread`),dataIndex:`unreadCount`,width:90},{title:p(`inbox.messageCount`),dataIndex:`messageCount`,width:100},{title:p(`common.actions`),width:330,render:(e,t)=>(0,I.jsxs)(l,{wrap:!0,children:[(0,I.jsx)(u,{icon:(0,I.jsx)(de,{}),onClick:()=>Xt(t),children:p(`common.edit`)}),(0,I.jsx)(u,{icon:(0,I.jsx)(ye,{}),onClick:()=>H(Je(t,g)),children:p(`inbox.clientConfig`)}),(0,I.jsx)(u,{icon:(0,I.jsx)(i,{}),onClick:()=>S(`/integrations/webhooks?mailboxId=${t.id}`),children:p(`inbox.mailboxWebhooks`)})]})}],nn=[{title:p(`domains.domain`),dataIndex:`domain`,render:e=>(0,I.jsx)(d.Text,{strong:!0,children:e})},{title:p(`inbox.catchAllAddress`),dataIndex:`catchAllAddress`,render:e=>e?(0,I.jsx)(he,{color:e===`/dev/null`?`default`:`blue`,children:e}):(0,I.jsx)(he,{children:p(`inbox.catchAllDisabled`)})},{title:p(`common.actions`),width:130,render:(e,t)=>(0,I.jsx)(u,{icon:(0,I.jsx)(ye,{}),onClick:()=>$t(t),children:p(`common.edit`)})}];return Ke?(0,I.jsx)(ae,{children:(0,I.jsx)(f,{active:!0,paragraph:{rows:12}})}):(0,I.jsxs)(l,{direction:`vertical`,size:20,className:`full-width`,children:[(0,I.jsx)(oe,{title:p(`inbox.title`),subtitle:p(`inbox.subtitle`),extra:q===`routing`?(0,I.jsx)(u,{type:`primary`,icon:(0,I.jsx)(fe,{}),disabled:!j.length,onClick:Yt,style:{minHeight:44},children:p(`inbox.createMailbox`)}):null}),tt?(0,I.jsx)(h,{type:`error`,showIcon:!0,message:tt,action:(0,I.jsx)(u,{icon:(0,I.jsx)(pe,{}),onClick:()=>void Z(),children:p(`common.refresh`)})}):null,rt?(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:s.startsWith(`en`)?`Domain and routing options are temporarily unavailable.`:`域名与路由选项暂不可用。`,description:rt,action:(0,I.jsx)(u,{icon:(0,I.jsx)(pe,{}),onClick:()=>void Z(),children:p(`common.refresh`)})}):null,g?.submission?.inboundEnabled===!1?(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:p(`inbox.inboundDisabled`)}):null,(0,I.jsx)(ee,{activeKey:q,onChange:Ht,items:[{key:`messages`,label:(0,I.jsxs)(l,{children:[(0,I.jsx)(i,{}),s.startsWith(`en`)?`Mail`:`邮件`]})},{key:`routing`,label:(0,I.jsxs)(l,{children:[(0,I.jsx)(ye,{}),s.startsWith(`en`)?`Mailboxes & routing`:`邮箱与路由`]})}]}),q===`messages`?tt&&!N.length?null:N.length?(0,I.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:n?`220px minmax(320px, 380px) minmax(0, 1fr)`:t.md?`220px minmax(0, 1fr)`:`minmax(0, 1fr)`,gap:16,minWidth:0},children:[t.md?(0,I.jsx)(ke,{mailboxOptions:Lt,selectedMailboxId:J,folders:P,foldersLoading:$e,foldersError:lt,activeFolder:Nt,onMailbox:Ut,onFolder:Wt,onRetryFolders:Q,locale:s,mailboxLabel:p(`inbox.mailboxFilter`),refreshLabel:p(`common.refresh`)}):null,(0,I.jsxs)(m,{styles:{body:{padding:0,minWidth:0}},children:[(0,I.jsxs)(`div`,{style:{padding:12,borderBottom:`1px solid #EAECF0`},children:[t.md?null:(0,I.jsxs)(l,{direction:`vertical`,size:8,className:`full-width`,style:{marginBottom:8},children:[(0,I.jsx)(c,{value:J||void 0,onChange:Ut,options:Lt,showSearch:!0,optionFilterProp:`label`,className:`full-width`,"aria-label":p(`inbox.mailboxFilter`)}),lt?(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:s.startsWith(`en`)?`Folder counts are unavailable.`:`文件夹计数暂不可用。`,action:(0,I.jsx)(u,{size:`small`,loading:$e,onClick:()=>void Q(),children:p(`common.refresh`)})}):null,(0,I.jsx)(c,{value:Nt,onChange:Wt,loading:$e,options:P.map(e=>({value:e.name,label:Ge(e,s)})),className:`full-width`,"aria-label":s.startsWith(`en`)?`Folder`:`文件夹`})]}),(0,I.jsxs)(l.Compact,{block:!0,children:[(0,I.jsx)(y,{value:ht,allowClear:!0,prefix:(0,I.jsx)(me,{}),placeholder:p(`inbox.searchPlaceholder`),onChange:e=>gt(e.target.value),onPressEnter:()=>Vt({q:ht.trim(),page:1})}),(0,I.jsx)(u,{"aria-label":p(`common.refresh`),icon:(0,I.jsx)(pe,{}),loading:B,onClick:()=>void $()})]}),(0,I.jsx)(c,{value:Pt,onChange:e=>Vt({read:e===`all`?null:e,page:1}),style:{width:`100%`,marginTop:8},"aria-label":s.startsWith(`en`)?`Read state`:`阅读状态`,options:[{value:`all`,label:s.startsWith(`en`)?`All mail`:`全部邮件`},{value:`unread`,label:p(`inbox.unread`)},{value:`read`,label:p(`inbox.read`)}]})]}),at?(0,I.jsx)(h,{type:`error`,showIcon:!0,message:at,action:(0,I.jsx)(u,{onClick:()=>void $(),children:p(`common.refresh`)})}):null,(0,I.jsx)(Ae,{items:Oe,loading:B,activeId:X,onOpen:Gt,locale:s,t:p}),Ne>25?(0,I.jsx)(`div`,{style:{padding:12,display:`flex`,justifyContent:`center`},children:(0,I.jsx)(ie,{size:`small`,current:Ft,pageSize:25,total:Ne,showSizeChanger:!1,onChange:e=>Vt({page:e})})}):null]}),n?(0,I.jsx)(m,{styles:{body:{padding:20,minWidth:0}},children:(0,I.jsx)(je,{message:R,loading:Ze,error:st,mutationError:dt,activeTab:It,onTabChange:qt,onCopy:Jt,t:p})}):null]}):(0,I.jsx)(w,{description:j.length?s.startsWith(`en`)?`No receiving mailbox has been created yet.`:`尚未创建收信邮箱。`:p(`inbox.noMailboxDomain`),action:(0,I.jsx)(u,{icon:(0,I.jsx)(fe,{}),disabled:!j.length,onClick:()=>{Ht(`routing`),Yt()},children:p(`inbox.createMailbox`)})}):(0,I.jsxs)(l,{direction:`vertical`,size:20,className:`full-width`,children:[(0,I.jsx)(ae,{title:p(`inbox.mailboxes`),extra:(0,I.jsx)(se,{tone:`neutral`,children:N.length}),children:N.length?(0,I.jsxs)(l,{direction:`vertical`,size:12,className:`full-width`,children:[(0,I.jsxs)(l,{wrap:!0,className:`full-width`,children:[(0,I.jsx)(y,{allowClear:!0,"aria-label":s.startsWith(`en`)?`Search mailboxes`:`搜索收信邮箱`,prefix:(0,I.jsx)(me,{}),placeholder:s.startsWith(`en`)?`Search address, alias, or forwarding target`:`搜索邮箱、别名或转发地址`,value:bt,onChange:e=>xt(e.target.value),style:{flex:`1 1 280px`}}),(0,I.jsx)(c,{"aria-label":s.startsWith(`en`)?`Sort mailboxes`:`收信邮箱排序`,value:St,onChange:Ct,style:{minWidth:180},options:Be(s)})]}),t.md?(0,I.jsx)(re,{rowKey:`id`,columns:tn,dataSource:zt,scroll:{x:1040}}):(0,I.jsx)(b,{dataSource:zt,renderItem:e=>(0,I.jsx)(b.Item,{children:(0,I.jsx)(m,{size:`small`,className:`full-width`,title:e.address,children:(0,I.jsxs)(l,{direction:`vertical`,className:`full-width`,children:[(0,I.jsxs)(d.Text,{type:`secondary`,children:[e.messageCount,` `,p(`inbox.messageCount`),` · `,e.unreadCount,` `,p(`inbox.unread`)]}),(0,I.jsxs)(l,{wrap:!0,children:[(0,I.jsx)(u,{icon:(0,I.jsx)(de,{}),onClick:()=>Xt(e),children:p(`common.edit`)}),(0,I.jsx)(u,{onClick:()=>H(Je(e,g)),children:p(`inbox.clientConfig`)}),(0,I.jsx)(u,{onClick:()=>S(`/integrations/webhooks?mailboxId=${e.id}`),children:p(`inbox.mailboxWebhooks`)})]})]})})})})]}):tt?null:(0,I.jsx)(w,{description:j.length?s.startsWith(`en`)?`No receiving mailbox has been created yet.`:`尚未创建收信邮箱。`:p(`inbox.noMailboxDomain`),action:(0,I.jsx)(u,{icon:(0,I.jsx)(fe,{}),disabled:!j.length,onClick:Yt,children:p(`inbox.createMailbox`)})})}),(0,I.jsx)(ae,{title:p(`inbox.domainRoutes`),extra:(0,I.jsx)(se,{tone:`neutral`,children:A.length}),children:A.length?(0,I.jsxs)(l,{direction:`vertical`,size:12,className:`full-width`,children:[(0,I.jsxs)(l,{wrap:!0,className:`full-width`,children:[(0,I.jsx)(y,{allowClear:!0,"aria-label":s.startsWith(`en`)?`Search receiving routes`:`搜索域名收信路由`,prefix:(0,I.jsx)(me,{}),placeholder:s.startsWith(`en`)?`Search domain or catch-all address`:`搜索域名或未知地址收件邮箱`,value:wt,onChange:e=>Tt(e.target.value),style:{flex:`1 1 280px`}}),(0,I.jsx)(c,{"aria-label":s.startsWith(`en`)?`Sort receiving routes`:`域名收信路由排序`,value:Et,onChange:Dt,style:{minWidth:180},options:Ue(s)})]}),t.md?(0,I.jsx)(re,{rowKey:`id`,columns:nn,dataSource:Bt}):(0,I.jsx)(b,{dataSource:Bt,renderItem:e=>(0,I.jsx)(b.Item,{actions:[(0,I.jsx)(u,{onClick:()=>$t(e),children:p(`common.edit`)},`edit`)],children:(0,I.jsx)(b.Item.Meta,{title:e.domain,description:e.catchAllAddress||p(`inbox.catchAllDisabled`)})})})]}):rt?null:(0,I.jsx)(w,{description:p(`inbox.noDomain`),action:(0,I.jsx)(u,{onClick:()=>S(`/domains?create=1`),children:p(`common.addDomain`)})})})]}),n?null:(0,I.jsx)(ge,{title:p(`inbox.messageDetail`),width:t.md?680:`100%`,open:!!X,onClose:Kt,children:(0,I.jsx)(je,{message:R,loading:Ze,error:st,mutationError:dt,activeTab:It,onTabChange:qt,onCopy:Jt,t:p})}),(0,I.jsx)(ge,{title:V?s.startsWith(`en`)?`Edit mailbox`:`编辑收信邮箱`:p(`inbox.createMailbox`),width:560,open:_t,onClose:Zt,destroyOnHidden:!0,footer:(0,I.jsxs)(l,{style:{display:`flex`,justifyContent:`flex-end`},children:[(0,I.jsx)(u,{onClick:Zt,children:p(`common.cancel`)}),(0,I.jsx)(u,{type:`primary`,loading:pt===`mailbox:create`||pt===`mailbox:update:${V?.id}`,onClick:()=>void Qt(),children:p(V?`common.save`:`inbox.createMailbox`)})]}),children:j.length?(0,I.jsxs)(v,{form:D,layout:`vertical`,children:[V?(0,I.jsx)(_,{bordered:!0,column:1,size:`small`,style:{marginBottom:20},children:(0,I.jsx)(_.Item,{label:p(`inbox.mailboxAddress`),children:(0,I.jsx)(d.Text,{code:!0,children:V.address})})}):(0,I.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:t.sm?`minmax(0, 1fr) minmax(220px, 0.8fr)`:`minmax(0, 1fr)`,columnGap:t.sm?0:8},children:[(0,I.jsx)(v.Item,{name:`localPart`,label:p(`inbox.localPart`),rules:[{required:!0,message:p(`inbox.localPartRequired`)},{pattern:/^[^@\s]+$/,message:p(`inbox.localPartInvalid`)}],children:(0,I.jsx)(y,{autoComplete:`off`})}),(0,I.jsx)(v.Item,{name:`domain`,label:p(`domains.domain`),rules:[{required:!0,message:p(`inbox.domainRequired`)}],children:(0,I.jsx)(c,{options:Rt})})]}),(0,I.jsx)(v.Item,{name:`displayName`,label:p(`inbox.displayName`),children:(0,I.jsx)(y,{})}),(0,I.jsx)(v.Item,{name:`password`,label:V?s.startsWith(`en`)?`New password`:`新密码`:p(`inbox.password`),extra:V?s.startsWith(`en`)?`Leave blank to keep the current password.`:`留空表示保留当前密码。`:void 0,rules:[{required:!V,message:p(`inbox.passwordRequired`)},{min:8,message:p(`inbox.passwordMin`)}],children:(0,I.jsx)(y.Password,{autoComplete:`new-password`})}),(0,I.jsx)(u,{onClick:()=>D.setFieldValue(`password`,Ye()),children:p(`inbox.generatePassword`)}),(0,I.jsx)(v.Item,{name:`quotaMb`,label:`${p(`inbox.quotaMb`)} (MB)`,style:{marginTop:20},children:(0,I.jsx)(ce,{min:1,className:`full-width`})}),(0,I.jsx)(v.Item,{name:`aliases`,label:p(`inbox.aliases`),extra:p(`inbox.aliasesExtra`),children:(0,I.jsx)(y.TextArea,{rows:3})}),(0,I.jsx)(v.Item,{name:`forwardTo`,label:p(`inbox.forwardTo`),extra:p(`inbox.forwardToExtra`),children:(0,I.jsx)(y.TextArea,{rows:3})}),(0,I.jsx)(v.Item,{name:`keepForwarded`,valuePropName:`checked`,children:(0,I.jsx)(ne,{children:p(`inbox.keepForwarded`)})}),V?(0,I.jsx)(v.Item,{name:`status`,label:p(`common.status`),rules:[{required:!0}],children:(0,I.jsx)(c,{options:[{value:`active`,label:s.startsWith(`en`)?`Active`:`启用`},{value:`disabled`,label:s.startsWith(`en`)?`Disabled`:`停用`}]})}):null]}):(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:p(`inbox.noMailboxDomain`)})}),(0,I.jsx)(le,{title:p(`inbox.catchAllTitle`),open:!!kt,confirmLoading:pt.startsWith(`catch-all:`),onCancel:()=>At(null),onOk:()=>void en(),children:(0,I.jsx)(v,{form:k,layout:`vertical`,children:(0,I.jsx)(v.Item,{name:`catchAllAddress`,label:p(`inbox.catchAllAddress`),extra:p(`inbox.catchAllExtra`),children:(0,I.jsx)(y,{placeholder:`catchall@example.com / /dev/null`})})})}),(0,I.jsx)(le,{title:p(`inbox.clientConfig`),open:!!Ot,width:720,footer:(0,I.jsx)(u,{type:`primary`,onClick:()=>H(null),children:p(`common.confirm`)}),onCancel:()=>H(null),children:Ot?(0,I.jsx)(Ie,{config:Ot,onCopy:Jt,t:p}):null})]})}function ke({mailboxOptions:e,selectedMailboxId:t,folders:n,foldersLoading:r,foldersError:i,activeFolder:a,onMailbox:o,onFolder:s,onRetryFolders:f,locale:p,mailboxLabel:ee,refreshLabel:te}){return(0,I.jsxs)(m,{styles:{body:{padding:8}},children:[(0,I.jsx)(c,{"aria-label":ee,value:t||void 0,onChange:o,options:e,showSearch:!0,optionFilterProp:`label`,className:`full-width`,style:{marginBottom:12}}),i?(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:p.startsWith(`en`)?`Folder counts are unavailable.`:`文件夹计数暂不可用。`,description:i,action:(0,I.jsx)(u,{size:`small`,loading:r,onClick:()=>void f(),children:te}),style:{marginBottom:8}}):null,(0,I.jsx)(l,{direction:`vertical`,size:2,className:`full-width`,children:n.map(e=>(0,I.jsxs)(u,{type:a===e.name?`primary`:`text`,icon:qe(e.name),onClick:()=>s(e.name),style:{width:`100%`,minHeight:44,display:`flex`,alignItems:`center`,justifyContent:`flex-start`},children:[(0,I.jsx)(`span`,{style:{flex:1,textAlign:`left`},children:Ke(e.name,p)}),e.countsAvailable?e.unreadCount?(0,I.jsx)(g,{count:e.unreadCount,size:`small`}):(0,I.jsx)(d.Text,{type:`secondary`,children:e.messageCount}):(0,I.jsx)(d.Text,{type:`secondary`,"aria-label":p.startsWith(`en`)?`Count unavailable`:`计数不可用`,children:`—`})]},e.name))})]})}function Ae({items:e,loading:t,activeId:n,onOpen:r,locale:i,t:a}){return t?(0,I.jsx)(`div`,{style:{padding:16},children:(0,I.jsx)(f,{active:!0,paragraph:{rows:8}})}):e.length?(0,I.jsx)(b,{dataSource:e,split:!0,renderItem:e=>(0,I.jsx)(b.Item,{style:{padding:0},children:(0,I.jsx)(`button`,{type:`button`,"aria-label":`${e.subject||a(`inbox.noSubject`)} · ${e.sender}`,onClick:()=>r(e),style:{width:`100%`,minHeight:88,padding:`12px 16px`,border:0,textAlign:`left`,background:n===e.id?`#EEF2FF`:e.read?`#FFFFFF`:`#F8FAFF`,cursor:`pointer`},children:(0,I.jsxs)(l,{direction:`vertical`,size:4,style:{width:`100%`},children:[(0,I.jsxs)(l,{style:{width:`100%`,justifyContent:`space-between`},children:[(0,I.jsx)(d.Text,{strong:!e.read,ellipsis:!0,style:{maxWidth:`65%`},children:e.sender||`—`}),(0,I.jsx)(d.Text,{type:`secondary`,style:{fontSize:12},children:Xe(e.receivedAt)})]}),(0,I.jsx)(d.Text,{strong:!e.read,ellipsis:!0,children:e.subject||a(`inbox.noSubject`)}),(0,I.jsx)(d.Text,{type:`secondary`,ellipsis:!0,children:e.preview||`—`})]})})})}):(0,I.jsx)(w,{description:i.startsWith(`en`)?`No messages match this folder and filter.`:`当前文件夹和筛选条件下没有邮件。`})}function je({message:e,loading:t,error:n,mutationError:r,activeTab:i,onTabChange:a,onCopy:o,t:s}){if(t)return(0,I.jsx)(f,{active:!0,paragraph:{rows:12}});if(n)return(0,I.jsx)(h,{type:`error`,showIcon:!0,message:n});if(!e)return(0,I.jsx)(w,{description:s(`inbox.messageDetail`)});let c=i===`text`&&!e.textBody&&e.htmlBody?`html`:i;return(0,I.jsxs)(l,{direction:`vertical`,size:20,className:`full-width`,children:[r?(0,I.jsx)(h,{type:`warning`,showIcon:!0,message:r}):null,(0,I.jsxs)(`div`,{children:[(0,I.jsx)(d.Title,{level:4,style:{marginBottom:4},children:e.subject||s(`inbox.noSubject`)}),(0,I.jsx)(d.Text,{type:`secondary`,children:Ze(e.receivedAt)})]}),(0,I.jsxs)(_,{column:1,size:`small`,children:[(0,I.jsx)(_.Item,{label:s(`inbox.sender`),children:e.sender||`—`}),(0,I.jsx)(_.Item,{label:s(`inbox.recipients`),children:e.recipients.join(`, `)||`—`}),(0,I.jsx)(_.Item,{label:s(`logs.messageId`),children:(0,I.jsx)(d.Text,{code:!0,copyable:{onCopy:()=>o(e.messageId)},children:e.messageId||`—`})})]}),(0,I.jsx)(ee,{activeKey:c,onChange:e=>a(Me(e)),items:[{key:`text`,label:s(`inbox.textBody`),children:e.textBody?(0,I.jsx)(`pre`,{className:`inbox-message-body`,children:e.textBody}):(0,I.jsx)(w,{description:s(`inbox.noTextBody`)})},{key:`html`,label:s(`inbox.htmlBody`),children:e.htmlBody?(0,I.jsx)(Ne,{html:e.htmlBody,title:s(`inbox.htmlBody`)}):(0,I.jsx)(w,{description:s(`inbox.noHtmlBody`)})},{key:`source`,label:s(`inbox.htmlSource`),children:e.htmlBody?(0,I.jsx)(T,{value:e.htmlBody,onCopy:o}):(0,I.jsx)(w,{description:s(`inbox.noHtmlBody`)})},{key:`raw`,label:s(`inbox.rawMessage`),children:e.rawMessage?(0,I.jsx)(T,{value:e.rawMessage,onCopy:o}):(0,I.jsx)(w,{description:s(`inbox.noRawMessage`)})}]})]})}function Me(e){return e===`html`||e===`source`||e===`raw`?e:`text`}function Ne({html:e,title:t}){return(0,I.jsx)(`iframe`,{title:t,className:`inbox-html-preview`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:Pe(e)})}function Pe(e){let t=[`<meta charset="utf-8">`,`<meta name="viewport" content="width=device-width, initial-scale=1">`,`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: blob: http: https:; style-src 'unsafe-inline' http: https:; font-src data: http: https:; script-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'">`,`<base target="_blank">`,`<style>html,body{margin:0;padding:12px;background:#fff;color:#111827;font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;overflow-wrap:anywhere;}img{max-width:100%;height:auto;}table{max-width:100%;}a{color:#4F46E5;}</style>`].join(``),n=String(e||``);return/<head(?:\s[^>]*)?>/i.test(n)?n.replace(/<head(?:\s[^>]*)?>/i,e=>`${e}${t}`):/<html(?:\s[^>]*)?>/i.test(n)?n.replace(/<html(?:\s[^>]*)?>/i,e=>`${e}<head>${t}</head>`):`<!doctype html><html><head>${t}</head><body>${n}</body></html>`}function Fe(e,t){let n=new URLSearchParams(e);n.delete(`tab`),t&&(!n.has(`mailboxId`)||!n.has(`folder`))&&(n.set(`mailboxId`,String(t.mailboxId)),n.set(`folder`,t.folder||`INBOX`));let r=n.toString();return`/inbox${r?`?${r}`:``}`}function Ie({config:e,onCopy:t,t:n}){let r=[{key:`imap`,label:n(`inbox.incomingConfig`),value:e.incoming},...e.pop3?[{key:`pop3`,label:n(`inbox.pop3Config`),value:e.pop3}]:[],{key:`smtp`,label:n(`inbox.outgoingConfig`),value:e.outgoing}];return(0,I.jsxs)(l,{direction:`vertical`,size:16,className:`full-width`,children:[(0,I.jsx)(h,{type:`info`,showIcon:!0,message:n(`inbox.clientConfigHelpSummary`)}),(0,I.jsxs)(_,{bordered:!0,column:1,size:`small`,children:[(0,I.jsx)(_.Item,{label:n(`inbox.configUsername`),children:R(e.username,t)}),(0,I.jsx)(_.Item,{label:n(`inbox.configPassword`),children:e.password?R(e.password,t):(0,I.jsx)(d.Text,{type:`secondary`,children:n(`inbox.passwordNotShown`)})})]}),(0,I.jsx)(ee,{items:r.map(e=>({key:e.key,label:e.label,children:(0,I.jsxs)(_,{bordered:!0,column:1,size:`small`,children:[(0,I.jsx)(_.Item,{label:n(`inbox.configHost`),children:R(e.value.host,t)}),(0,I.jsx)(_.Item,{label:n(`inbox.configPort`),children:R(e.value.port,t)}),(0,I.jsx)(_.Item,{label:n(`inbox.configSecurity`),children:e.value.security}),(0,I.jsx)(_.Item,{label:n(`inbox.configAuthMethod`),children:e.value.authMethod})]})}))})]})}function R(e,t){return(0,I.jsxs)(l,{children:[(0,I.jsx)(d.Text,{code:!0,children:e}),(0,I.jsx)(u,{"aria-label":`Copy`,icon:(0,I.jsx)(ue,{}),onClick:()=>void t(String(e))})]})}function Le(e,t){return t&&e.some(e=>e.id===t)?t:[...e].filter(e=>e.lastMessageAt).sort((e,t)=>Date.parse(t.lastMessageAt||``)-Date.parse(e.lastMessageAt||``))[0]?.id||e.find(e=>e.messageCount>0)?.id||e[0]?.id||null}function Re(e,t){let n=t.trim().toLocaleLowerCase();return n?e.filter(e=>[e.address,e.displayName,...e.aliases,...e.forwardTo].some(e=>String(e||``).toLocaleLowerCase().includes(n))):e}function ze(e,t){return[...e].sort((e,n)=>{if(t===`address`)return e.address.localeCompare(n.address);if(t===`unread`)return n.unreadCount-e.unreadCount||e.address.localeCompare(n.address);if(t===`messages`)return n.messageCount-e.messageCount||e.address.localeCompare(n.address);let r=Date.parse(e.lastMessageAt||``)||0;return(Date.parse(n.lastMessageAt||``)||0)-r||e.address.localeCompare(n.address)})}function Be(e){return e.startsWith(`en`)?[{value:`activity`,label:`Recent activity`},{value:`address`,label:`Address`},{value:`unread`,label:`Unread count`},{value:`messages`,label:`Message count`}]:[{value:`activity`,label:`最近收信`},{value:`address`,label:`邮箱地址`},{value:`unread`,label:`未读数`},{value:`messages`,label:`邮件数`}]}function Ve(e,t){let n=t.trim().toLocaleLowerCase();return n?e.filter(e=>[e.domain,e.catchAllAddress].some(e=>String(e||``).toLocaleLowerCase().includes(n))):e}function He(e,t){return[...e].sort((e,n)=>{if(t===`configured`){let t=Number(!!n.catchAllAddress)-Number(!!e.catchAllAddress);if(t)return t}return e.domain.localeCompare(n.domain)})}function Ue(e){return e.startsWith(`en`)?[{value:`domain`,label:`Domain`},{value:`configured`,label:`Configured first`}]:[{value:`domain`,label:`域名`},{value:`configured`,label:`已配置优先`}]}function We(){return Oe.map(e=>({name:e,specialUse:z(e),messageCount:0,unreadCount:0,countsAvailable:!1}))}function Ge(e,t){let n=e.countsAvailable?e.unreadCount:`—`;return`${Ke(e.name,t)} (${n})`}function z(e){return{INBOX:null,Sent:`\\Sent`,Drafts:`\\Drafts`,Trash:`\\Trash`,Junk:`\\Junk`,Archive:`\\Archive`}[e]??null}function Ke(e,t){return t.startsWith(`en`)?e:{INBOX:`收件箱`,Sent:`已发送`,Drafts:`草稿`,Trash:`已删除`,Junk:`垃圾邮件`,Archive:`归档`}[e]||e}function qe(e){return e===`INBOX`?(0,I.jsx)(C,{}):e===`Sent`?(0,I.jsx)(S,{}):e===`Drafts`?(0,I.jsx)(N,{}):e===`Trash`?(0,I.jsx)(x,{}):e===`Junk`?(0,I.jsx)(Ce,{}):e===`Archive`?(0,I.jsx)(Ee,{}):(0,I.jsx)(F,{})}function Je(e,t,n=``){let r=B(t?.submission?.ports||[],[587,465]),i=B(t?.mailAccess?.imap.ports||[],[993,143]),a=B(t?.mailAccess?.pop3.ports||[],[995,110]),o=t?.mailAccess?.host||t?.submission?.host||t?.mailHostname||e.domain;return{username:e.address,password:n,incoming:{protocol:`IMAP`,host:o,port:i?.port||143,security:i?.protocol||`IMAP + STARTTLS`,authMethod:`Normal password`,username:e.address,password:n},pop3:{protocol:`POP3`,host:o,port:a?.port||110,security:a?.protocol||`POP3 + STLS`,authMethod:`Normal password`,username:e.address,password:n},outgoing:{protocol:`SMTP`,host:t?.submission?.host||t?.mailHostname||e.domain,port:r?.port||587,security:r?.protocol||`SMTP + STARTTLS`,authMethod:`Normal password`,username:e.address,password:n}}}function B(e,t){for(let n of t){let t=e.find(e=>e.port===n);if(t)return t}return e[0]||null}function Ye(){let e=new Uint8Array(14);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>(e%36).toString(36)).join(``)}function Xe(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t.toLocaleDateString()}function Ze(e){return e?new Date(e).toLocaleString():`—`}export{L as default};
|