Files
NianAIGC/out/_next/static/chunks/app/accounts/page-94363e0dd44b5076.js
T
2026-09-02 17:02:02 +08:00

1 line
23 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[339],{63:(e,a,t)=>{"use strict";var n=t(7260);t.o(n,"usePathname")&&t.d(a,{usePathname:function(){return n.usePathname}}),t.o(n,"useRouter")&&t.d(a,{useRouter:function(){return n.useRouter}})},525:(e,a,t)=>{Promise.resolve().then(t.bind(t,6006))},1360:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1847:(e,a,t)=>{"use strict";t.d(a,{A:()=>l});var n=t(2115);let s=function(){for(var e=arguments.length,a=Array(e),t=0;t<e;t++)a[t]=arguments[t];return a.filter((e,a,t)=>!!e&&""!==e.trim()&&t.indexOf(e)===a).join(" ").trim()};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let r=(0,n.forwardRef)((e,a)=>{let{color:t="currentColor",size:r=24,strokeWidth:l=2,absoluteStrokeWidth:o,className:c="",children:u,iconNode:d,...h}=e;return(0,n.createElement)("svg",{ref:a,...i,width:r,height:r,stroke:t,strokeWidth:o?24*Number(l)/Number(r):l,className:s("lucide",c),...h},[...d.map(e=>{let[a,t]=e;return(0,n.createElement)(a,t)}),...Array.isArray(u)?u:[u]])}),l=(e,a)=>{let t=(0,n.forwardRef)((t,i)=>{let{className:l,...o}=t;return(0,n.createElement)(r,{ref:i,iconNode:a,className:s("lucide-".concat(e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),l),...o})});return t.displayName="".concat(e),t}},4577:(e,a,t)=>{"use strict";t.d(a,{BrowserAuthGuard:()=>u,BrowserAuthProvider:()=>o,ClientRedirect:()=>d,a:()=>c});var n=t(5155),s=t(2115),i=t(63),r=t(6660);let l=(0,s.createContext)(null);function o(e){let{children:a}=e,[t,i]=(0,s.useState)(null),[o,c]=(0,s.useState)("loading"),[u,d]=(0,s.useState)(null),h=(0,s.useCallback)(async e=>{try{let a=await (0,r.uK)(e);i(a),c("ready"),d(null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;c("error"),d(e instanceof Error?e.message:"无法读取认证状态")}},[]);(0,s.useEffect)(()=>{let e=new AbortController;return h(e.signal),()=>e.abort()},[h]);let m=(0,s.useMemo)(()=>{var e,a;let n=(null==t?void 0:t.user)||null,s=null==(e=null==t?void 0:t.authRequired)||e,i=!s||(null==n?void 0:n.role)==="super_admin",r=i||(null==n?void 0:n.role)==="organization_admin";return{status:o,user:n,authMode:(null==t?void 0:t.authMode)||null,authRequired:s,authConfigured:null!=(a=null==t?void 0:t.authConfigured)&&a,isAdmin:r,isSuperAdmin:i,error:u,refresh:()=>h()}},[u,h,t,o]);return(0,n.jsx)(l.Provider,{value:m,children:a})}function c(){let e=(0,s.useContext)(l);if(!e)throw Error("useBrowserAuth must be used inside BrowserAuthProvider");return e}function u(e){let{children:a,role:t="user"}=e,l=c(),o=(0,i.usePathname)(),u=(0,i.useRouter)(),d="ready"===l.status&&l.authRequired&&!l.user;return((0,s.useEffect)(()=>{if(d){let e=(0,r.M6)(window.location,o||"/create");u.replace("/auth/login?next=".concat(encodeURIComponent(e)))}},[d,o,u]),"loading"===l.status||d)?(0,n.jsx)(h,{message:"正在确认登录状态…"}):"error"===l.status?(0,n.jsx)(h,{message:l.error||"无法读取认证状态",actionLabel:"重试",onAction:()=>void l.refresh()}):("admin"!==t||l.isAdmin)&&("super"!==t||l.isSuperAdmin)?(0,n.jsx)(n.Fragment,{children:a}):(0,n.jsx)(h,{message:"当前账号无权访问此页面。"})}function d(e){let{to:a,forwardNext:t=!1}=e;return(0,s.useEffect)(()=>{let e=t?new URLSearchParams(window.location.search).get("next"):null,n=e?"".concat(a,"?next=").concat(encodeURIComponent(e)):a;window.location.replace(n)},[t,a]),(0,n.jsx)(h,{message:"正在跳转…"})}function h(e){let{message:a,actionLabel:t,onAction:s}=e;return(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("p",{className:"muted",children:a}),t&&s?(0,n.jsx)("button",{className:"button",type:"button",onClick:s,children:t}):null]})}},5299:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},6006:(e,a,t)=>{"use strict";t.r(a),t.d(a,{default:()=>g});var n=t(5155),s=t(2115),i=t(6907),r=t(1847);let l=(0,r.A)("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);var o=t(6191),c=t(8514),u=t(9559),d=t(1360);let h=(0,r.A)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var m=t(5299);function p(){let[e,a]=(0,s.useState)(""),[t,i]=(0,s.useState)(""),[r,l]=(0,s.useState)(""),[o,c]=(0,s.useState)(null),[u,d]=(0,s.useState)(null),[p,x]=(0,s.useState)(!1);async function v(n){if(n.preventDefault(),c(null),d(null),t.length<8)return void d("新密码至少需要 8 位。");if(t!==r)return void d("两次输入的新密码不一致。");x(!0);try{let n=await fetch("/api/auth/password/change",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,newPassword:t,confirmPassword:r})}),s=await n.json().catch(()=>({}));if(!n.ok)throw Error(s.error||"密码修改失败。");a(""),i(""),l(""),c("密码已修改。")}catch(e){d(e instanceof Error?e.message:String(e))}finally{x(!1)}}return(0,n.jsxs)("section",{className:"account-security-card","aria-labelledby":"account-security-title",children:[(0,n.jsxs)("header",{className:"account-panel-heading account-security-heading",children:[(0,n.jsx)("div",{children:(0,n.jsx)("h2",{id:"account-security-title",children:"修改密码"})}),(0,n.jsx)("span",{className:"account-panel-icon","aria-hidden":"true",children:(0,n.jsx)(h,{})})]}),o?(0,n.jsx)("div",{className:"account-feedback success",role:"status",children:o}):null,u?(0,n.jsx)("div",{className:"account-feedback error",role:"alert",children:u}):null,(0,n.jsxs)("form",{className:"account-security-form",onSubmit:v,children:[(0,n.jsxs)("div",{className:"account-security-fields",children:[(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"当前密码"}),(0,n.jsx)("input",{type:"password",autoComplete:"current-password",value:e,onChange:e=>a(e.target.value)})]}),(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"新密码"}),(0,n.jsx)("input",{type:"password",autoComplete:"new-password",value:t,onChange:e=>i(e.target.value)})]}),(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"确认新密码"}),(0,n.jsx)("input",{type:"password",autoComplete:"new-password",value:r,onChange:e=>l(e.target.value)})]})]}),(0,n.jsx)("footer",{className:"account-form-footer",children:(0,n.jsxs)("button",{className:"button primary",type:"submit",disabled:p||!e||!t||!r,children:[p?(0,n.jsx)(m.A,{className:"spin",size:17}):(0,n.jsx)(h,{size:17}),"保存密码"]})})]})]})}let x={super_admin:"超级管理员",organization_admin:"组织管理员",user:"普通用户"};function v(e){let{canManageAccounts:a}=e,[t,r]=(0,s.useState)(null),[m,v]=(0,s.useState)(a),[f,g]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),[w,N]=(0,s.useState)(null),[k,C]=(0,s.useState)(""),[A,z]=(0,s.useState)({phone:"",displayName:"",password:"",role:"user"}),[E,S]=(0,s.useState)(""),M=(0,s.useMemo)(()=>null==t?void 0:t.organizations.find(e=>e.id===k),[null==t?void 0:t.organizations,k]),O=(null==t?void 0:t.members)||[];async function P(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k;if(a){v(!0),N(null);try{let a=e?"?organizationId=".concat(encodeURIComponent(e)):"",t=await fetch("/api/admin/accounts".concat(a),{cache:"no-store"}),n=await t.json();if(!t.ok)throw Error(n.error||"账号列表加载失败。");r(n),C(n.currentOrganizationId||"")}catch(e){N(e instanceof Error?e.message:String(e))}finally{v(!1)}}}async function R(e){e.preventDefault(),g(!0),b(null),N(null);try{let e=await fetch("/api/admin/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phone:A.phone,displayName:A.displayName,password:A.password,role:A.role,organizationId:null==M?void 0:M.id})}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"账号创建失败。");b("账号已创建。"),z({phone:"",displayName:"",password:"",role:"user"}),await P((null==M?void 0:M.id)||"")}catch(e){N(e instanceof Error?e.message:String(e))}finally{g(!1)}}async function _(e){if(e.preventDefault(),E.trim()){g(!0),b(null),N(null);try{let e=await fetch("/api/admin/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E})}),a=await e.json().catch(()=>({}));if(!e.ok)throw Error(a.error||"组织创建失败。");S(""),b("组织已创建。"),await P()}catch(e){N(e instanceof Error?e.message:String(e))}finally{g(!1)}}}async function T(e){var a;let t=null==(a=window.prompt("请输入新的组织名称",e.name))?void 0:a.trim();t&&t!==e.name&&await L("PATCH",{organizationId:e.id,name:t},"组织名称已更新。")}async function I(e){let a="active"===e.status?"disabled":"active";await L("PATCH",{organizationId:e.id,status:a},"active"===a?"组织已启用。":"组织已停用。登录和新账号创建会受到限制。")}async function q(e){window.confirm("确定删除“".concat(e.name,"”吗?只有没有任何账号的组织才可以删除。"))&&await L("DELETE",{organizationId:e.id},"组织已删除。")}async function L(e,a,t){N(null),b(null);try{let n=await fetch("/api/admin/organizations",{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),s=await n.json().catch(()=>({}));if(!n.ok)throw Error(s.error||"组织操作失败。");b(t),"DELETE"===e?(C(""),await P("")):await P(k)}catch(e){N(e instanceof Error?e.message:String(e))}}async function D(e){let a="active"===e.status?"disabled":"active";await H("PUT",{userId:e.id,status:a},"active"===a?"账号已启用。":"账号已停用。")}async function U(e){let a=window.prompt("为 ".concat(e.displayName," 设置新密码(至少 8 位)"));a&&await H("POST",{userId:e.id,newPassword:a},"密码已重置。","/api/admin/accounts/password")}async function W(e,a){await H("PATCH",{userId:e.id,role:a},"账号角色已更新。")}async function B(e){window.confirm("确定彻底删除“".concat(e.displayName,"”吗?素材和任务会转移到组织归档账号,用量记录保留。"))&&await H("DELETE",{userId:e.id},"账号已删除。")}async function H(e,a,t){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/api/admin/accounts";N(null),b(null);try{let s=await fetch(n,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),i=await s.json().catch(()=>({}));if(!s.ok)throw Error(i.error||"操作失败。");b(t),await P(k)}catch(e){N(e instanceof Error?e.message:String(e))}}return(0,s.useEffect)(()=>{a?P():v(!1)},[a]),(0,n.jsxs)("div",{className:"account-directory",children:[(0,n.jsx)("header",{className:"account-directory-head",children:(0,n.jsx)("div",{className:"account-directory-intro",children:(0,n.jsx)("h1",{children:"账户与访问"})})}),y?(0,n.jsx)("div",{className:"account-feedback success",role:"status",children:y}):null,w?(0,n.jsx)("div",{className:"account-feedback error",role:"alert",children:w}):null,(0,n.jsxs)("section",{className:"account-workspace","aria-label":"账户工作区",children:[(0,n.jsx)(p,{}),a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("section",{className:"account-management-section","aria-labelledby":"account-management-title",children:[(0,n.jsxs)("div",{className:"account-workspace-heading",children:[(0,n.jsx)("div",{children:(0,n.jsx)("h2",{id:"account-management-title",children:"组织与成员管理"})}),(0,n.jsx)(i.A,{"aria-hidden":"true"})]}),(0,n.jsxs)("div",{className:"account-management-grid",children:[(0,n.jsxs)("div",{className:"account-management-form",children:[(0,n.jsx)("div",{className:"account-subsection-heading",children:(0,n.jsx)("h3",{children:"创建账号"})}),(0,n.jsxs)("form",{className:"account-form-grid",onSubmit:R,children:[(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"手机号"}),(0,n.jsx)("input",{inputMode:"tel",value:A.phone,onChange:e=>z(a=>({...a,phone:e.target.value})),placeholder:"请输入手机号"})]}),(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"显示名称"}),(0,n.jsx)("input",{value:A.displayName,onChange:e=>z(a=>({...a,displayName:e.target.value})),placeholder:"请输入名称"})]}),(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"初始密码"}),(0,n.jsx)("input",{type:"password",autoComplete:"new-password",value:A.password,onChange:e=>z(a=>({...a,password:e.target.value})),placeholder:"至少 8 位"})]}),(null==t?void 0:t.canAssignOrganizationAdmin)?(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"角色"}),(0,n.jsxs)("select",{value:A.role,onChange:e=>z(a=>({...a,role:e.target.value})),children:[(0,n.jsx)("option",{value:"user",children:"普通用户"}),(0,n.jsx)("option",{value:"organization_admin",children:"组织管理员"}),(0,n.jsx)("option",{value:"super_admin",children:"超级管理员"})]})]}):null,(0,n.jsxs)("label",{className:"field account-form-wide",children:[(0,n.jsx)("span",{children:"组织"}),(0,n.jsxs)("select",{value:(null==M?void 0:M.id)||"",onChange:e=>{C(e.target.value),P(e.target.value)},disabled:!(null==t?void 0:t.canManageOrganizations)&&!!M,children:[(0,n.jsx)("option",{value:"",children:(null==t?void 0:t.canManageOrganizations)?"全平台 / 未归属":"选择组织"}),null==t?void 0:t.organizations.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,n.jsxs)("button",{className:"button primary account-create-submit account-form-wide",type:"submit",disabled:f||m||"super_admin"!==A.role&&!(null==M?void 0:M.id)||!A.phone||!A.displayName||!A.password,children:[(0,n.jsx)(l,{size:17}),f?"创建中":"创建账号"]})]})]}),(null==t?void 0:t.canManageOrganizations)?(0,n.jsxs)("div",{className:"account-management-form account-organization-form",children:[(0,n.jsx)("div",{className:"account-subsection-heading",children:(0,n.jsx)("h3",{children:"组织目录"})}),(0,n.jsxs)("form",{className:"account-department-form",onSubmit:_,children:[(0,n.jsxs)("label",{className:"field",children:[(0,n.jsx)("span",{children:"新组织名称"}),(0,n.jsx)("input",{value:E,onChange:e=>S(e.target.value),placeholder:"例如:华东运营组"})]}),(0,n.jsxs)("button",{className:"button secondary",type:"submit",disabled:f||!E.trim(),children:[(0,n.jsx)(o.A,{size:17}),"创建组织"]})]}),(0,n.jsx)("div",{className:"account-org-list",children:t.organizations.map(e=>(0,n.jsxs)("div",{className:"account-org-item",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:e.name}),(0,n.jsx)("small",{className:"active"===e.status?"org-active":"org-disabled",children:"active"===e.status?"启用":"停用"})]}),(0,n.jsxs)("div",{className:"account-org-actions",children:[(0,n.jsx)("button",{className:"icon-button",type:"button",onClick:()=>void T(e),title:"重命名","aria-label":"重命名 ".concat(e.name),children:(0,n.jsx)(c.A,{size:15})}),(0,n.jsx)("button",{className:"icon-button",type:"button",onClick:()=>void I(e),title:"active"===e.status?"停用组织":"启用组织","aria-label":"".concat("active"===e.status?"停用":"启用"," ").concat(e.name),children:(0,n.jsx)(u.A,{size:15})}),(0,n.jsx)("button",{className:"icon-button danger-icon",type:"button",onClick:()=>void q(e),title:"删除组织","aria-label":"删除 ".concat(e.name),children:(0,n.jsx)(d.A,{size:15})})]})]},e.id))})]}):null]})]}),(0,n.jsxs)("section",{className:"account-members-panel","aria-labelledby":"account-members-title",children:[(0,n.jsxs)("div",{className:"account-panel-heading account-members-heading",children:[(0,n.jsx)("div",{children:(0,n.jsx)("h2",{id:"account-members-title",children:(null==M?void 0:M.name)||"全平台账号"})}),(0,n.jsxs)("div",{className:"account-members-tools",children:[(0,n.jsxs)("label",{className:"account-filter-field",children:[(0,n.jsx)("span",{children:"组织"}),(0,n.jsxs)("select",{value:(null==M?void 0:M.id)||"",onChange:e=>{C(e.target.value),P(e.target.value)},disabled:!(null==t?void 0:t.canManageOrganizations)&&!!M,"aria-label":"按组织筛选账号",children:[(0,n.jsx)("option",{value:"",children:(null==t?void 0:t.canManageOrganizations)?"全平台":"当前组织"}),null==t?void 0:t.organizations.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,n.jsx)("button",{className:"icon-button",type:"button",onClick:()=>void P(k),title:"刷新账号列表","aria-label":"刷新账号列表",children:(0,n.jsx)(u.A,{size:17})})]})]}),m?(0,n.jsx)(j,{}):O.length?(0,n.jsxs)("div",{className:"account-table",role:"table","aria-label":"账号列表",children:[(0,n.jsxs)("div",{className:"account-row account-head",role:"row",children:[(0,n.jsx)("span",{role:"columnheader",children:"账号"}),(0,n.jsx)("span",{role:"columnheader",children:"角色"}),(0,n.jsx)("span",{role:"columnheader",children:"状态"}),(0,n.jsx)("span",{role:"columnheader",children:"操作"})]}),O.map(e=>(0,n.jsxs)("div",{className:"account-row",role:"row",children:[(0,n.jsxs)("div",{className:"account-member-identity",role:"cell",children:[(0,n.jsx)("span",{className:"account-avatar","aria-hidden":"true",children:e.displayName.trim().slice(0,2)||"账"}),(0,n.jsxs)("div",{className:"account-member-main",children:[(0,n.jsx)("strong",{children:e.displayName}),(0,n.jsx)("small",{children:e.phone})]})]}),(0,n.jsx)("div",{className:"account-role-cell",role:"cell",children:(null==t?void 0:t.canAssignOrganizationAdmin)?(0,n.jsxs)("select",{className:"account-status-select",value:e.role,onChange:a=>void W(e,a.target.value),"aria-label":"".concat(e.displayName,"的角色"),children:[(0,n.jsx)("option",{value:"user",children:x.user}),(0,n.jsx)("option",{value:"organization_admin",children:x.organization_admin}),(0,n.jsx)("option",{value:"super_admin",children:x.super_admin})]}):(0,n.jsx)("span",{children:x[e.role]})}),(0,n.jsx)("div",{role:"cell",children:(0,n.jsx)("span",{className:"account-status-badge ".concat("active"===e.status?"active":"disabled"),children:"active"===e.status?"启用":"停用"})}),(0,n.jsxs)("div",{className:"account-row-actions",role:"cell",children:[(0,n.jsx)("button",{className:"icon-button",type:"button",onClick:()=>void U(e),title:"重置密码","aria-label":"重置 ".concat(e.displayName," 密码"),children:(0,n.jsx)(h,{size:16})}),(0,n.jsx)("button",{className:"icon-button",type:"button",onClick:()=>void D(e),title:"active"===e.status?"停用":"启用","aria-label":"".concat("active"===e.status?"停用":"启用"," ").concat(e.displayName),children:(0,n.jsx)(u.A,{size:16})}),(0,n.jsx)("button",{className:"icon-button danger-icon",type:"button",onClick:()=>void B(e),title:"彻底删除","aria-label":"删除 ".concat(e.displayName),children:(0,n.jsx)(d.A,{size:16})})]})]},e.id))]}):(0,n.jsx)("div",{className:"account-empty",children:"当前组织还没有账号。"})]})]}):null]})]})}function j(){return(0,n.jsxs)("div",{className:"account-loading",role:"status","aria-live":"polite",children:[(0,n.jsxs)("div",{className:"account-skeleton-list","aria-hidden":"true",children:[(0,n.jsx)("span",{}),(0,n.jsx)("span",{}),(0,n.jsx)("span",{})]}),(0,n.jsx)("span",{children:"正在加载账号"})]})}var f=t(4577);function g(){return(0,n.jsx)(f.BrowserAuthGuard,{children:(0,n.jsx)(y,{})})}function y(){let{isAdmin:e}=(0,f.a)();return(0,n.jsx)(v,{canManageAccounts:e})}},6191:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},6660:(e,a,t)=>{"use strict";async function n(e){let a=await fetch("/api/auth/me",{method:"GET",cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json"},signal:e});if(!a.ok)throw Error("认证状态请求失败(".concat(a.status,")"));var t,n=await a.json();if(!r(n)||"boolean"!=typeof n.authenticated||"boolean"!=typeof n.authRequired||"boolean"!=typeof n.authConfigured)throw Error("认证状态响应格式无效");if(!n.authenticated){if(null!==n.authMode||null!==n.user)throw Error("认证状态响应格式无效");return{authenticated:!1,authRequired:n.authRequired,authConfigured:n.authConfigured,authMode:null,user:null}}if(!n.authConfigured||"user"!==n.authMode&&"admin"!==n.authMode||!(r(t=n.user)&&"string"==typeof t.id&&t.id.length>0&&"string"==typeof t.subject&&t.subject===t.id&&"string"==typeof t.displayName&&"string"==typeof t.clientId&&("user"===t.role||"organization_admin"===t.role||"super_admin"===t.role)&&"active"===t.status&&("super_admin"===t.role||"string"==typeof t.organizationId&&t.organizationId.length>0)&&Array.isArray(t.authorities)&&t.authorities.every(e=>"string"==typeof e)&&Array.isArray(t.scope)&&t.scope.every(e=>"string"==typeof e)))throw Error("认证用户响应格式无效");let s="user"===n.user.role?"user":"admin";if(n.authMode!==s)throw Error("认证用户响应格式无效");return{authenticated:!0,authRequired:n.authRequired,authConfigured:n.authConfigured,authMode:n.authMode,user:n.user}}function s(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/create";if(!e||!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))return a;try{let t="http://zhinian.local",n=new URL(e,t);if(n.origin!==t)return a;let s="".concat(n.pathname).concat(n.search).concat(n.hash);if(n.pathname.startsWith("/api/auth")||n.pathname.startsWith("/auth/login")||n.pathname.startsWith("/auth/admin-login"))return a;return s}catch(e){return a}}function i(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/create";return s("".concat(e.pathname).concat(e.search).concat(e.hash),a)}function r(e){return"object"==typeof e&&null!==e}t.d(a,{M6:()=>i,uK:()=>n,z3:()=>s})},6907:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},8514:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},9559:(e,a,t)=>{"use strict";t.d(a,{A:()=>n});let n=(0,t(1847).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])}},e=>{e.O(0,[441,255,358],()=>e(e.s=525)),_N_E=e.O()}]);