Files
NianAIGC/out/_next/static/chunks/app/billing/page-4cdd57347d4d5c28.js
T
2026-09-02 17:02:02 +08:00

1 line
48 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([[522],{2885:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>em});var l=i(5155),a=i(2115),t=i(5299),s=i(9559),r=i(5468),c=i(1847);let d=(0,c.A)("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]),o=(0,c.A)("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);var u=i(6191),h=i(8514);let g=(0,c.A)("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);var m=i(5917),b=i(4274);let x=(0,c.A)("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);var p=i(9408),j=i(7937);let v=(0,c.A)("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);var f=i(5229);let y=(0,c.A)("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);var N=i(4166);function k(e,n,i){throw Error("".concat(e,"数据格式错误:").concat(n).concat("响应"===n?"":" ","必须是").concat(i,"。"))}function w(e,n,i){return("object"!=typeof e||null===e||Array.isArray(e))&&k(i,n,"对象"),e}function A(e,n,i){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;return Array.isArray(e[n])||k(i,l,"数组"),e[n]}function M(e,n,i,l){"string"!=typeof e[n]&&k(i,l,"字符串")}function F(e,n,i,l){void 0!==e[n]&&null!==e[n]&&"string"!=typeof e[n]&&k(i,l,"字符串")}function z(e,n,i,l){"number"==typeof e[n]&&Number.isFinite(e[n])||k(i,l,"有限数字")}function C(e,n,i,l){"boolean"!=typeof e[n]&&k(i,l,"布尔值")}function E(e,n,i){["string","number","boolean"].includes(typeof e)||k(n,i,"字符串、数字或布尔值"),"number"!=typeof e||Number.isFinite(e)||k(n,i,"有限数字")}function S(e,n,i){let l=w(e,i,n);for(let e of["accountName","bankName","accountNumber","contact"])F(l,e,n,"".concat(i,".").concat(e))}function I(e,n,i){let l=w(e,i,n);for(let e of(M(l,"organizationId",n,"".concat(i,".organizationId")),["balanceFen","totalRechargedFen","totalChargedFen"]))z(l,e,n,"".concat(i,".").concat(e));M(l,"updatedAt",n,"".concat(i,".updatedAt"))}function O(e,n,i){let l=w(e,i,n);for(let e of["rechargeFen","chargedFen","refundedFen","netConsumedFen"])z(l,e,n,"".concat(i,".").concat(e))}function R(e,n,i){let l=w(e,i,n);M(l,"id",n,"".concat(i,".id")),M(l,"organizationId",n,"".concat(i,".organizationId")),F(l,"accountId",n,"".concat(i,".accountId")),F(l,"jobId",n,"".concat(i,".jobId")),M(l,"kind",n,"".concat(i,".kind")),z(l,"deltaFen",n,"".concat(i,".deltaFen")),z(l,"balanceAfterFen",n,"".concat(i,".balanceAfterFen")),M(l,"description",n,"".concat(i,".description")),w(l.metadata,"".concat(i,".metadata"),n),M(l,"createdAt",n,"".concat(i,".createdAt")),Number.isNaN(Date.parse(l.createdAt))&&k(n,"".concat(i,".createdAt"),"有效时间字符串")}var J=i(7612);let q={accountName:"",bankName:"",accountNumber:"",contact:""},P={organizationId:"",direction:"credit",amountYuan:"",note:""};function D(e){let{isSuperAdmin:n}=e,[i,r]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[o,u]=(0,a.useState)(q),[h,g]=(0,a.useState)(P),[m,b]=(0,a.useState)("overview"),[x,p]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!0),[f,y]=(0,a.useState)(!1),[D,L]=(0,a.useState)(null),[Z,Q]=(0,a.useState)(null),[X,$]=(0,a.useState)(null),ee=(0,a.useRef)(null),en=(0,a.useRef)(null),el=(0,a.useMemo)(()=>n?[{id:"overview",label:"概览"},{id:"pricing",label:"价格与计费"},{id:"balance",label:"余额与上账"},{id:"account",label:"收款设置"}]:[{id:"overview",label:"概览"},{id:"ledger",label:"账务流水"}],[n]),ea=(0,a.useMemo)(()=>null==c?void 0:c.organizations.find(e=>e.id===h.organizationId),[null==c?void 0:c.organizations,h.organizationId]);async function et(){v(!0),L(null);try{if(n){let e=await fetch("/api/admin/billing",{cache:"no-store"}),n=await _(e);if(!e.ok)throw Error(n.error||"读取超管计费数据失败");let i=function(e){let n="超管计费",i=w(e,"响应",n);return S(i.billingAccount,n,"billingAccount"),A(i,"organizations",n).forEach((e,i)=>(function(e,n,i){let l=w(e,i,n);M(l,"id",n,"".concat(i,".id")),M(l,"name",n,"".concat(i,".name")),M(l,"status",n,"".concat(i,".status")),I(l.wallet,n,"".concat(i,".wallet"))})(e,n,"organizations[".concat(i,"]"))),A(i,"members",n).forEach((e,i)=>(function(e,n,i){let l=w(e,i,n);for(let e of["id","displayName","phone","role","status"])M(l,e,n,"".concat(i,".").concat(e));F(l,"organizationId",n,"".concat(i,".organizationId"))})(e,n,"members[".concat(i,"]"))),A(i,"ledger",n).forEach((e,i)=>R(e,n,"ledger[".concat(i,"]"))),A(i,"priceRules",n).forEach((e,i)=>(function(e,n,i){let l=w(e,i,n);for(let e of["id","provider","capability","unit"])M(l,e,n,"".concat(i,".").concat(e));F(l,"reqKey",n,"".concat(i,".reqKey")),F(l,"variantKey",n,"".concat(i,".variantKey")),F(l,"note",n,"".concat(i,".note")),z(l,"standardUnitPriceFen",n,"".concat(i,".standardUnitPriceFen")),z(l,"markupMultiplier",n,"".concat(i,".markupMultiplier")),C(l,"enabled",n,"".concat(i,".enabled")),void 0!==l.conditions&&null!==l.conditions&&w(l.conditions,"".concat(i,".conditions"),n),void 0!==l.source&&null!==l.source&&F(w(l.source,"".concat(i,".source"),n),"url",n,"".concat(i,".source.url")),void 0!==l.parameterDimensions&&null!==l.parameterDimensions&&(Array.isArray(l.parameterDimensions)||k(n,"".concat(i,".parameterDimensions"),"数组"),l.parameterDimensions.forEach((e,l)=>{let a="".concat(i,".parameterDimensions[").concat(l,"]"),t=w(e,a,n);M(t,"key",n,"".concat(a,".key")),F(t,"label",n,"".concat(a,".label")),E(t.baselineValue,n,"".concat(a,".baselineValue")),void 0!==t.defaultValue&&null!==t.defaultValue&&E(t.defaultValue,n,"".concat(a,".defaultValue")),A(t,"tiers",n,"".concat(a,".tiers")).forEach((e,i)=>{let l="".concat(a,".tiers[").concat(i,"]"),t=w(e,l,n);E(t.value,n,"".concat(l,".value")),F(t,"label",n,"".concat(l,".label")),z(t,"standardFactor",n,"".concat(l,".standardFactor")),z(t,"markupMultiplier",n,"".concat(l,".markupMultiplier")),C(t,"enabled",n,"".concat(l,".enabled")),F(t,"note",n,"".concat(l,".note"))})}))})(e,n,"priceRules[".concat(i,"]"))),e}(n);d(i),r(function(e){let n=e.organizations.reduce((e,n)=>({organizationId:"platform",balanceFen:e.balanceFen+n.wallet.balanceFen,totalRechargedFen:e.totalRechargedFen+n.wallet.totalRechargedFen,totalChargedFen:e.totalChargedFen+n.wallet.totalChargedFen,updatedAt:e.updatedAt>n.wallet.updatedAt?e.updatedAt:n.wallet.updatedAt}),{organizationId:"platform",balanceFen:0,totalRechargedFen:0,totalChargedFen:0,updatedAt:new Date(0).toISOString()});return{organization:{id:"platform",name:"全平台组织"},billingAccount:e.billingAccount,wallet:n,ledger:e.ledger,summary:function(e){let n=e.filter(e=>"recharge"===e.kind||"adjustment"===e.kind&&e.deltaFen>0).reduce((e,n)=>e+Math.max(0,n.deltaFen),0),i=e.filter(e=>"charge"===e.kind).reduce((e,n)=>e+Math.max(0,-n.deltaFen),0),l=e.filter(e=>"refund"===e.kind).reduce((e,n)=>e+Math.max(0,n.deltaFen),0);return{rechargeFen:n,chargedFen:i,refundedFen:l,netConsumedFen:Math.max(0,i-l)}}(e.ledger),personal:{rechargeFen:0,chargedFen:0,refundedFen:0,netConsumedFen:0}}}(i)),u({...q,...i.billingAccount}),g(e=>{var n;return{...e,organizationId:e.organizationId||(null==(n=i.organizations[0])?void 0:n.id)||""}})}else{let e=await fetch("/api/billing",{cache:"no-store"}),n=await _(e);if(!e.ok)throw Error(n.error||"读取计费数据失败");let i=function(e){let n="成员计费",i=w(e,"响应",n);var l=i.organization,a="organization";let t=w(l,a,n);return M(t,"id",n,"".concat(a,".id")),M(t,"name",n,"".concat(a,".name")),S(i.billingAccount,n,"billingAccount"),I(i.wallet,n,"wallet"),A(i,"ledger",n).forEach((e,i)=>R(e,n,"ledger[".concat(i,"]"))),O(i.summary,n,"summary"),O(i.personal,n,"personal"),e}(n);r(i)}}catch(e){L(e instanceof Error?e.message:String(e))}finally{v(!1)}}async function es(e){e.preventDefault(),y(!0),L(null),Q(null);try{let e=await fetch("/api/admin/billing/account",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),n=await _(e);if(!e.ok)throw Error(n.error||"保存收款账户失败");u({...q,...n.billingAccount||o}),p(!1),Q("对公收款账户已更新,成员将看到最新信息。"),await et()}catch(e){L(e instanceof Error?e.message:String(e))}finally{y(!1)}}async function er(e){e.preventDefault(),y(!0),L(null),Q(null);try{var n;let e=await fetch("/api/admin/billing/adjustments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organizationId:h.organizationId,direction:h.direction,amountYuan:h.amountYuan,note:h.note})}),i=await _(e);if(!e.ok)throw Error(i.error||"余额调整失败");g(e=>({...e,amountYuan:"",note:""})),Q("".concat("credit"===h.direction?"上账":"扣减","已完成,").concat((null==ea?void 0:ea.name)||"组织","余额为 ").concat((0,N.JO)((null==(n=i.wallet)?void 0:n.balanceFen)||0),"。")),await et()}catch(e){L(e instanceof Error?e.message:String(e))}finally{y(!1)}}async function ec(e){if(!X)return;let{rule:n,target:i}=X;await ed("/api/admin/billing/prices/".concat(encodeURIComponent(n.id)),{markupMultiplier:e,...i.dimensionKey&&void 0!==i.tierValue?{dimensionKey:i.dimensionKey,tierValue:i.tierValue}:{}},"".concat(i.label,"倍率已更新。"))&&$(null)}async function ed(e,n,i){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"PATCH";y(!0),L(null),Q(null);try{let a=await fetch(e,{method:l,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),t=await _(a);if(!a.ok)throw Error(t.error||"保存失败");return Q(i),await et(),!0}catch(e){return L(e instanceof Error?e.message:String(e)),!1}finally{y(!1)}}return(0,a.useEffect)(()=>{et(),b("overview")},[n]),(0,a.useEffect)(()=>(0,J.It)(ee,e=>(0,J.xr)(e)),[]),(0,a.useEffect)(()=>{(0,J.Js)(en.current)},[D,Z]),(0,l.jsxs)("div",{className:"billing-manager billing-modern",ref:ee,children:[(0,l.jsxs)("header",{className:"billing-page-header","data-animate":!0,children:[(0,l.jsx)("div",{className:"billing-page-heading",children:(0,l.jsxs)("div",{className:"billing-title-row",children:[(0,l.jsx)("h1",{children:"计费中心"}),(0,l.jsx)("span",{className:"billing-view-tag",children:n?"超级管理员":"成员视图"})]})}),(0,l.jsxs)("button",{className:"billing-refresh",type:"button",onClick:()=>void et(),disabled:j||f,children:[j?(0,l.jsx)(t.A,{className:"spin",size:16}):(0,l.jsx)(s.A,{size:16}),"刷新数据"]})]}),(0,l.jsxs)("div",{className:"billing-feedback",ref:en,children:[D?(0,l.jsx)("div",{className:"billing-alert billing-alert-error",role:"alert",children:D}):null,Z?(0,l.jsx)("div",{className:"billing-alert billing-alert-success",role:"status",children:Z}):null]}),i?(0,l.jsx)(B,{billing:i,isSuperAdmin:n}):j?(0,l.jsx)(G,{}):null,i?(0,l.jsx)(K,{tabs:el,activeTab:m,onChange:b}):null,!n&&i?(0,l.jsxs)(l.Fragment,{children:["overview"===m?(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(Y,{entries:i.ledger,limit:8,title:"最近账务",action:(0,l.jsx)(W,{label:"查看全部流水",onClick:()=>b("ledger")})})}):null,"ledger"===m?(0,l.jsx)(Y,{entries:i.ledger,title:"账务流水",action:(0,l.jsxs)("span",{className:"billing-section-count",children:["最近 ",Math.min(i.ledger.length,100)," 条"]})}):null]}):null,n&&c&&i?(0,l.jsxs)(l.Fragment,{children:["overview"===m?(0,l.jsx)(T,{billing:i,admin:c,onChangeTab:b}):null,"pricing"===m?(0,l.jsx)(V,{admin:c,saving:f,onEdit:(e,n)=>$({rule:e,target:n})}):null,"balance"===m?(0,l.jsx)(U,{admin:c,adjustmentDraft:h,setAdjustmentDraft:g,selectedOrganization:ea,saving:f,onSubmit:er}):null,"account"===m?(0,l.jsx)(H,{account:c.billingAccount,draft:o,editing:x,saving:f,onEdit:()=>p(!0),onCancel:()=>{p(!1),u({...q,...c.billingAccount})},onChange:(e,n)=>u(i=>({...i,[e]:n})),onSubmit:es}):null]}):null,X?(0,l.jsx)(ei,{state:X,saving:f,onClose:()=>$(null),onSubmit:ec}):null]})}async function _(e){let n=await e.text();if(!n.trim())return{error:e.status>=500?"计费服务暂时不可用,请检查服务端日志和 PostgreSQL 迁移状态。":"服务器未返回有效内容。"};try{return JSON.parse(n)}catch(n){return{error:e.status>=500?"计费服务返回了服务器错误,请检查 Go API 状态和服务端日志。":"服务器返回了无效响应(HTTP ".concat(e.status,")。")}}}function K(e){let{tabs:n,activeTab:i,onChange:t}=e,s=(0,a.useRef)([]);return(0,l.jsx)("nav",{className:"billing-tabs-shell","aria-label":"计费中心功能",children:(0,l.jsx)("div",{className:"billing-tabs",role:"tablist",children:n.map((e,a)=>(0,l.jsx)("button",{className:"billing-tab".concat(i===e.id?" is-active":""),id:"billing-tab-".concat(e.id),ref:e=>{s.current[a]=e},type:"button",role:"tab","aria-selected":i===e.id,"aria-controls":"billing-panel-".concat(e.id),tabIndex:i===e.id?0:-1,onClick:()=>t(e.id),onKeyDown:e=>(function(e,i){if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();let l="Home"===e.key?0:"End"===e.key?n.length-1:(i+("ArrowRight"===e.key?1:-1)+n.length)%n.length,a=n[l];a&&(t(a.id),window.requestAnimationFrame(()=>{var e;return null==(e=s.current[l])?void 0:e.focus()}))})(e,a),children:(0,l.jsx)("span",{children:e.label})},e.id))})})}function T(e){let{billing:n,admin:i,onChangeTab:a}=e,t=i.priceRules.filter(e=>e.enabled).length;return(0,l.jsxs)("div",{id:"billing-panel-overview",role:"tabpanel","aria-labelledby":"billing-tab-overview",className:"billing-tab-panel",children:[(0,l.jsxs)("div",{className:"billing-admin-overview-grid","data-animate":!0,children:[(0,l.jsxs)("button",{className:"billing-admin-stat",type:"button",onClick:()=>a("pricing"),children:[(0,l.jsx)("span",{children:"启用中的价格规则"}),(0,l.jsxs)("strong",{children:[t,(0,l.jsxs)("small",{children:[" / ",i.priceRules.length]})]})]}),(0,l.jsxs)("button",{className:"billing-admin-stat",type:"button",onClick:()=>a("balance"),children:[(0,l.jsx)("span",{children:"管理中的组织"}),(0,l.jsx)("strong",{children:i.organizations.length})]}),(0,l.jsxs)("button",{className:"billing-admin-stat",type:"button",onClick:()=>a("balance"),children:[(0,l.jsx)("span",{children:"组织累计扣费"}),(0,l.jsx)("strong",{children:(0,N.JO)(n.summary.chargedFen)})]})]}),(0,l.jsx)(Y,{entries:n.ledger,limit:8,title:"最近账务",action:(0,l.jsx)("span",{className:"billing-section-count",children:"组织流水"})})]})}function V(e){let{admin:n,saving:i,onEdit:a}=e;return(0,l.jsxs)("section",{id:"billing-panel-pricing",role:"tabpanel","aria-labelledby":"billing-tab-pricing",className:"billing-section billing-pricing-section billing-tab-panel","data-animate":!0,children:[(0,l.jsxs)("div",{className:"billing-section-heading billing-pricing-heading",children:[(0,l.jsx)("div",{children:(0,l.jsx)("h2",{children:"价格目录"})}),(0,l.jsxs)("div",{className:"billing-formula","aria-label":"计费公式",children:[(0,l.jsx)("span",{children:"标准成本"}),(0,l.jsx)("b",{children:"\xd7"}),(0,l.jsx)("span",{children:"倍率"}),(0,l.jsx)("b",{children:"="}),(0,l.jsx)("strong",{children:"用户价"})]})]}),(0,l.jsx)(el,{rules:n.priceRules,onEdit:a,disabled:i})]})}function U(e){let{admin:n,adjustmentDraft:i,setAdjustmentDraft:a,selectedOrganization:t,saving:s,onSubmit:c}=e;return(0,l.jsxs)("section",{id:"billing-panel-balance",role:"tabpanel","aria-labelledby":"billing-tab-balance",className:"billing-section billing-tab-panel","data-animate":!0,children:[(0,l.jsx)(Z,{title:"余额与上账",action:(0,l.jsxs)("span",{className:"billing-section-count",children:[n.organizations.length," 个组织"]})}),(0,l.jsxs)("div",{className:"billing-balance-admin-layout",children:[(0,l.jsxs)("div",{className:"billing-subpanel",children:[(0,l.jsxs)("div",{className:"billing-subpanel-heading",children:[(0,l.jsx)("div",{children:(0,l.jsx)("h3",{children:"组织钱包"})}),(0,l.jsx)(r.A,{size:18})]}),(0,l.jsx)(ed,{wallets:n.organizations})]}),(0,l.jsx)(L,{draft:i,selectedOrganization:t,organizations:n.organizations,saving:s,onChange:a,onSubmit:c})]}),(0,l.jsxs)("div",{className:"billing-member-balance-panel",children:[(0,l.jsxs)("div",{className:"billing-subpanel-heading",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{children:"组织成员用量"}),(0,l.jsx)("p",{children:"余额和上账都归组织所有,成员数据仅用于查看各自的额度消耗。"})]}),(0,l.jsx)(d,{size:18})]}),(0,l.jsx)(eo,{members:n.members,entries:n.ledger})]})]})}function L(e){let{draft:n,selectedOrganization:i,organizations:a,saving:t,onChange:s,onSubmit:c}=e;return(0,l.jsxs)("form",{className:"billing-form billing-adjustment-form",onSubmit:c,children:[(0,l.jsxs)("div",{className:"billing-form-heading",children:[(0,l.jsx)("div",{children:(0,l.jsx)("strong",{children:"手工上账 / 余额调整"})}),(0,l.jsx)(o,{size:19,"aria-hidden":"true"})]}),(0,l.jsxs)("div",{className:"billing-adjustment-note",children:[(0,l.jsx)(r.A,{size:15}),(0,l.jsxs)("span",{children:["组织当前余额 ",(0,l.jsx)("b",{children:(0,N.JO)((null==i?void 0:i.wallet.balanceFen)||0)})]})]}),(0,l.jsxs)("div",{className:"billing-form-grid",children:[(0,l.jsx)(X,{label:"组织",value:n.organizationId,onChange:e=>s({...n,organizationId:e}),options:a.map(e=>({value:e.id,label:"".concat(e.name).concat("active"===e.status?"":"(已停用)")}))}),(0,l.jsx)(X,{label:"变动方式",value:n.direction,onChange:e=>s({...n,direction:e}),options:[{value:"credit",label:"上账增加余额"},{value:"debit",label:"扣减余额"}]}),(0,l.jsx)(Q,{label:"金额(元)",value:n.amountYuan,onChange:e=>s({...n,amountYuan:e}),placeholder:"例如 1000",required:!0,inputMode:"decimal"}),(0,l.jsx)("div",{className:"billing-adjustment-full-field",children:(0,l.jsx)(Q,{label:"备注",value:n.note,onChange:e=>s({...n,note:e}),placeholder:"例如:2026 年度服务预存",required:!0})})]}),(0,l.jsxs)("div",{className:"billing-form-footer",children:[(0,l.jsx)("span",{children:"本次变动全部计入组织额度,管理员与员工共同使用"}),(0,l.jsxs)("button",{className:"billing-action-button",type:"submit",disabled:t||!n.organizationId,children:[(0,l.jsx)(u.A,{size:16}),"credit"===n.direction?"确认上账":"确认扣减"]})]})]})}function H(e){let{account:n,draft:i,editing:a,saving:t,onEdit:s,onCancel:r,onChange:c,onSubmit:d}=e;return(0,l.jsxs)("section",{id:"billing-panel-account",role:"tabpanel","aria-labelledby":"billing-tab-account",className:"billing-section billing-tab-panel","data-animate":!0,children:[(0,l.jsx)(Z,{title:"收款设置",action:a?null:(0,l.jsxs)("button",{className:"billing-secondary-button",type:"button",onClick:s,children:[(0,l.jsx)(h.A,{size:14}),"编辑账户"]})}),(0,l.jsxs)("div",{className:"billing-account-settings-layout",children:[(0,l.jsx)($,{account:a?i:n,admin:!0}),a?(0,l.jsxs)("form",{className:"billing-form billing-account-editor",onSubmit:d,children:[(0,l.jsxs)("div",{className:"billing-form-heading",children:[(0,l.jsx)("div",{children:(0,l.jsx)("strong",{children:"配置对公账户"})}),(0,l.jsx)(g,{size:19,"aria-hidden":"true"})]}),(0,l.jsxs)("div",{className:"billing-form-grid billing-account-editor-grid",children:[(0,l.jsx)(Q,{label:"账户名称",value:i.accountName||"",onChange:e=>c("accountName",e),placeholder:"公司或平台对公账户名称"}),(0,l.jsx)(Q,{label:"开户行",value:i.bankName||"",onChange:e=>c("bankName",e),placeholder:"例如:中国银行北京分行"}),(0,l.jsx)(Q,{label:"银行账号",value:i.accountNumber||"",onChange:e=>c("accountNumber",e),placeholder:"对公银行账号"}),(0,l.jsx)(Q,{label:"收款对接信息",value:i.contact||"",onChange:e=>c("contact",e),placeholder:"联系人、电话或邮箱"})]}),(0,l.jsxs)("div",{className:"billing-form-footer",children:[(0,l.jsx)("span",{children:"留空字段会在成员端显示为未配置"}),(0,l.jsxs)("div",{className:"billing-form-actions",children:[(0,l.jsx)("button",{className:"billing-secondary-button",type:"button",onClick:r,children:"取消"}),(0,l.jsxs)("button",{className:"billing-action-button",type:"submit",disabled:t,children:[(0,l.jsx)(m.A,{size:16}),"保存账户"]})]})]})]}):null]})]})}function B(e){let{billing:n,isSuperAdmin:i}=e;return(0,l.jsxs)("section",{className:"billing-overview","data-animate":!0,"aria-label":"余额与消耗概览",children:[(0,l.jsxs)("article",{className:"billing-balance-card",children:[(0,l.jsxs)("div",{className:"billing-balance-topline",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"组织可用余额"}),(0,l.jsx)("strong",{children:n.organization.name})]}),(0,l.jsxs)("span",{className:"billing-shared-badge",children:[(0,l.jsx)(r.A,{size:14}),"共享账本"]})]}),(0,l.jsx)("strong",{className:"billing-balance-value",children:(0,N.JO)(n.wallet.balanceFen)}),(0,l.jsxs)("div",{className:"billing-balance-footer",children:[(0,l.jsxs)("span",{children:["累计充值 ",(0,l.jsx)("b",{children:(0,N.JO)(n.summary.rechargeFen)})]}),(0,l.jsxs)("span",{children:["累计扣费 ",(0,l.jsx)("b",{children:(0,N.JO)(n.summary.chargedFen)})]}),(0,l.jsxs)("span",{children:[i?"账本状态":"我的净消耗"," ",(0,l.jsx)("b",{children:i?"正常":(0,N.JO)(n.personal.netConsumedFen)})]})]})]}),(0,l.jsxs)("div",{className:"billing-usage-stack",children:[(0,l.jsxs)("article",{className:"billing-usage-card",children:[(0,l.jsx)("div",{className:"billing-usage-icon billing-usage-icon-blue",children:(0,l.jsx)(b.A,{size:18})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"我的净消耗"}),(0,l.jsx)("strong",{children:(0,N.JO)(n.personal.netConsumedFen)})]}),(0,l.jsx)(x,{size:17,"aria-hidden":"true"})]}),(0,l.jsxs)("article",{className:"billing-usage-card",children:[(0,l.jsx)("div",{className:"billing-usage-icon billing-usage-icon-green",children:(0,l.jsx)(p.A,{size:18})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"组织净消耗"}),(0,l.jsx)("strong",{children:(0,N.JO)(n.summary.netConsumedFen)})]}),(0,l.jsx)(x,{size:17,"aria-hidden":"true"})]})]})]})}function Y(e){let{entries:n,title:i,limit:a=100,action:t}=e;return(0,l.jsxs)("section",{id:"billing-panel-ledger",role:"tabpanel",className:"billing-section billing-ledger-section billing-tab-panel","data-animate":!0,children:[(0,l.jsx)(Z,{title:i,action:t}),(0,l.jsx)(en,{entries:n.slice(0,a)})]})}function W(e){let{label:n,onClick:i}=e;return(0,l.jsxs)("button",{className:"billing-text-button",type:"button",onClick:i,children:[n,(0,l.jsx)(j.A,{size:14})]})}function G(){return(0,l.jsxs)("div",{className:"billing-loading","aria-label":"正在读取计费数据",children:[(0,l.jsx)("div",{className:"billing-skeleton billing-skeleton-large"}),(0,l.jsxs)("div",{className:"billing-skeleton-grid",children:[(0,l.jsx)("div",{className:"billing-skeleton"}),(0,l.jsx)("div",{className:"billing-skeleton"})]}),(0,l.jsx)("div",{className:"billing-skeleton billing-skeleton-section"})]})}function Z(e){let{title:n,action:i}=e;return(0,l.jsxs)("div",{className:"billing-section-heading",children:[(0,l.jsx)("div",{children:(0,l.jsx)("h2",{children:n})}),i?(0,l.jsx)("div",{className:"billing-section-action",children:i}):null]})}function Q(e){let{label:n,value:i,onChange:a,placeholder:t,required:s=!1,inputMode:r}=e;return(0,l.jsxs)("label",{className:"billing-field",children:[(0,l.jsx)("span",{children:n}),(0,l.jsx)("input",{value:i,onChange:e=>a(e.target.value),placeholder:t,required:s,inputMode:r})]})}function X(e){let{label:n,value:i,onChange:a,options:t}=e;return(0,l.jsxs)("label",{className:"billing-field",children:[(0,l.jsx)("span",{children:n}),(0,l.jsx)("select",{value:i,onChange:e=>a(e.target.value),children:t.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))})]})}function $(e){let{account:n,admin:i=!1}=e,a=!!(n.accountName||n.bankName||n.accountNumber);return(0,l.jsxs)("article",{className:"billing-account-card","aria-label":"对公收款账户",children:[(0,l.jsxs)("div",{className:"billing-account-heading",children:[(0,l.jsx)("div",{className:"billing-account-icon",children:(0,l.jsx)(g,{size:18})}),(0,l.jsx)("div",{children:(0,l.jsx)("h3",{children:"对公收款账户"})}),(0,l.jsx)("span",{className:a?"billing-configured":"billing-unconfigured",children:a?"已配置":"待配置"})]}),a?(0,l.jsxs)("div",{className:"billing-account-grid",children:[(0,l.jsx)(ee,{label:"账户名称",value:n.accountName}),(0,l.jsx)(ee,{label:"开户行",value:n.bankName}),(0,l.jsx)(ee,{label:"银行账号",value:n.accountNumber}),(0,l.jsx)(ee,{label:"收款对接",value:n.contact})]}):(0,l.jsx)("p",{className:"billing-empty-note",children:"超级管理员尚未配置对公收款账户信息,请先在收款设置中补充。"})]})}function ee(e){let{label:n,value:i}=e;return(0,l.jsxs)("div",{className:"billing-account-field",children:[(0,l.jsx)("span",{children:n}),(0,l.jsx)("strong",{children:i||"—"})]})}function en(e){let{entries:n}=e;return(0,l.jsxs)("div",{className:"billing-ledger-list",children:[(0,l.jsxs)("div",{className:"billing-list-head",children:[(0,l.jsx)("span",{children:"事项"}),(0,l.jsx)("span",{children:"变动 / 余额"})]}),n.length?n.map(e=>{var n;return(0,l.jsxs)("div",{className:"billing-ledger-row",children:[(0,l.jsxs)("div",{className:"billing-ledger-main",children:[(0,l.jsx)("span",{className:"billing-ledger-icon billing-ledger-icon-".concat(e.kind),children:(0,l.jsx)(v,{size:16})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:e.description}),(0,l.jsxs)("small",{children:[(0,l.jsx)("time",{dateTime:e.createdAt,children:(n=e.createdAt,new Intl.DateTimeFormat("zh-CN",{timeZone:"Asia/Shanghai",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)))}),"recharge"!==e.kind&&"adjustment"!==e.kind&&e.metadata.accountName?" \xb7 ".concat(String(e.metadata.accountName)):e.jobId?" \xb7 任务 ".concat(e.jobId.slice(0,10)):""]})]})]}),(0,l.jsxs)("div",{className:"billing-ledger-amount",children:[(0,l.jsxs)("strong",{className:e.deltaFen<0?"billing-negative":"billing-positive",children:[e.deltaFen<0?"−":"+",(0,N.JO)(Math.abs(e.deltaFen))]}),(0,l.jsxs)("small",{children:["余额 ",(0,N.JO)(e.balanceAfterFen)]})]})]},e.id)}):(0,l.jsxs)("div",{className:"billing-empty-state",children:[(0,l.jsx)(v,{size:19}),(0,l.jsx)("span",{children:"暂无账务流水"})]})]})}function ei(e){let{state:n,saving:i,onClose:s,onSubmit:r}=e,[c,d]=(0,a.useState)(String(n.target.markupMultiplier)),o=(0,a.useRef)(null),u=function(e,n){var i;if(!n.dimensionKey||void 0===n.tierValue)return e.standardUnitPriceFen;let l=null==(i=e.parameterDimensions)?void 0:i.find(e=>e.key===n.dimensionKey),a=null==l?void 0:l.tiers.find(e=>String(e.value)===n.tierValue);return Math.ceil(e.standardUnitPriceFen*Number((null==a?void 0:a.standardFactor)||1))}(n.rule,n.target),h=Number(c),g=""!==c.trim()&&Number.isFinite(h)&&h>=1&&h<=1e3,x=eu(u,n.target.markupMultiplier),p=g?eu(u,h):null;return(0,a.useEffect)(()=>{d(String(n.target.markupMultiplier)),window.requestAnimationFrame(()=>{var e;return null==(e=o.current)?void 0:e.focus()})},[n.rule.id,n.target.dimensionKey,n.target.tierValue,n.target.markupMultiplier]),(0,a.useEffect)(()=>{function e(e){"Escape"!==e.key||i||s()}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s,i]),(0,l.jsx)("div",{className:"billing-modal-backdrop",role:"presentation",onMouseDown:e=>{e.target!==e.currentTarget||i||s()},children:(0,l.jsxs)("section",{className:"billing-modal billing-price-edit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"billing-price-edit-title","aria-describedby":"billing-price-edit-description",onMouseDown:e=>e.stopPropagation(),children:[(0,l.jsxs)("div",{className:"billing-modal-header",children:[(0,l.jsxs)("div",{className:"billing-modal-title-wrap",children:[(0,l.jsx)("span",{className:"billing-modal-icon","aria-hidden":"true",children:(0,l.jsx)(b.A,{size:18})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{id:"billing-price-edit-title",children:"调整上浮倍率"}),(0,l.jsx)("p",{id:"billing-price-edit-description",children:n.target.label})]})]}),(0,l.jsx)("button",{className:"billing-modal-close",type:"button",onClick:s,disabled:i,"aria-label":"关闭",title:"关闭",children:(0,l.jsx)(f.A,{size:17})})]}),(0,l.jsxs)("form",{className:"billing-price-edit-form",onSubmit:function(e){e.preventDefault(),g&&!i&&r(c.trim())},children:[(0,l.jsxs)("label",{className:"billing-modal-field",htmlFor:"billing-price-multiplier",children:[(0,l.jsx)("span",{children:"平台上浮倍率"}),(0,l.jsxs)("div",{className:"billing-modal-input-wrap",children:[(0,l.jsx)("input",{ref:o,id:"billing-price-multiplier",value:c,onChange:e=>d(e.target.value),inputMode:"decimal",min:"1",max:"1000",step:"0.01","aria-invalid":""!==c.trim()&&!g}),(0,l.jsx)("strong",{children:"\xd7"})]}),(0,l.jsx)("small",{children:"可设置范围 1.00\xd7 至 1000.00\xd7"})]}),(0,l.jsxs)("div",{className:"billing-price-edit-preview","aria-label":"倍率调整预览",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"标准成本"}),(0,l.jsxs)("strong",{children:[(0,N.JO)(u),(0,l.jsxs)("small",{children:[" / ",(0,N._M)(n.rule.unit)]})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{children:"当前用户价"}),(0,l.jsx)("strong",{children:(0,N.JO)(x)})]}),(0,l.jsxs)("div",{className:"billing-price-edit-preview-next",children:[(0,l.jsx)("span",{children:"调整后用户价"}),(0,l.jsx)("strong",{children:null===p?"—":(0,N.JO)(p)})]})]}),(0,l.jsxs)("div",{className:"billing-modal-footer",children:[(0,l.jsx)("button",{className:"billing-secondary-button",type:"button",onClick:s,disabled:i,children:"取消"}),(0,l.jsxs)("button",{className:"billing-action-button",type:"submit",disabled:!g||i,children:[i?(0,l.jsx)(t.A,{className:"spin",size:15}):(0,l.jsx)(m.A,{size:15}),i?"保存中":"保存倍率"]})]})]})]})})}function el(e){let{rules:n,onEdit:i,disabled:a}=e,t=function(e){let n=new Map;for(let i of e){let e=[i.provider,i.capability,i.reqKey||""].join("\0"),l=n.get(e)||[];l.push(i),n.set(e,l)}return[...n.entries()]}(n);return(0,l.jsx)("div",{className:"billing-price-catalog",children:t.length?t.map(e=>{let[n,t]=e;return 1===t.length?(0,l.jsx)(ea,{rule:t[0],onEdit:i,disabled:a},n):(0,l.jsx)(et,{rules:t,onEdit:i,disabled:a},n)}):(0,l.jsxs)("div",{className:"billing-empty-state",children:[(0,l.jsx)(y,{size:19}),(0,l.jsx)("span",{children:"暂无平台价格标准。"})]})})}function ea(e){var n,i;let{rule:a,onEdit:t,disabled:s}=e,r=(null==(n=a.parameterDimensions)?void 0:n.filter(e=>e.tiers.length))||[];return(0,l.jsxs)("article",{className:"billing-price-service-card",children:[(0,l.jsxs)("div",{className:"billing-price-service-heading",children:[(0,l.jsxs)("div",{className:"billing-price-service-title",children:[(0,l.jsx)("span",{className:"billing-provider-mark",children:eh(a.provider).slice(0,2)}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("strong",{children:[eh(a.provider)," \xb7 ","video.generate"===a.capability?"视频生成":"图片生成"]}),(0,l.jsxs)("small",{children:[a.reqKey||"默认服务",a.variantKey?" \xb7 ".concat(a.variantKey):""]})]})]}),(0,l.jsxs)("div",{className:"billing-price-base",children:[(0,l.jsx)("span",{children:"基准成本"}),(0,l.jsxs)("strong",{children:[(0,N.JO)(a.standardUnitPriceFen),(0,l.jsxs)("small",{children:["/",(0,N._M)(a.unit)]})]})]})]}),(0,l.jsxs)("div",{className:"billing-price-service-meta",children:[(null==(i=a.source)?void 0:i.url)?(0,l.jsxs)("a",{href:a.source.url,target:"_blank",rel:"noreferrer",children:["查看价格来源 ",(0,l.jsx)(x,{size:12,"aria-hidden":"true"})]}):(0,l.jsx)("span",{className:"billing-price-source-placeholder",children:"平台标准目录"}),(0,l.jsx)("span",{className:"billing-price-note",children:a.note||"平台标准目录"})]}),r.length?(0,l.jsx)("div",{className:"billing-price-dimensions",children:r.map(e=>(0,l.jsx)(es,{rule:a,dimension:e,onEdit:t,disabled:s},e.key))}):(0,l.jsx)(ec,{rule:a,onEdit:t,disabled:s})]})}function et(e){var n;let{rules:i,onEdit:a,disabled:t}=e,s=i[0];return(0,l.jsxs)("article",{className:"billing-price-service-card",children:[(0,l.jsxs)("div",{className:"billing-price-service-heading",children:[(0,l.jsxs)("div",{className:"billing-price-service-title",children:[(0,l.jsx)("span",{className:"billing-provider-mark",children:eh(s.provider).slice(0,2)}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("strong",{children:[eh(s.provider)," \xb7 ","video.generate"===s.capability?"视频生成":"图片生成"]}),(0,l.jsx)("small",{children:s.reqKey||"默认服务"})]})]}),(0,l.jsxs)("div",{className:"billing-price-base",children:[(0,l.jsx)("span",{children:"平台参数档位"}),(0,l.jsxs)("strong",{children:[i.length,(0,l.jsx)("small",{children:" 个"})]})]})]}),(0,l.jsxs)("div",{className:"billing-price-service-meta",children:[(null==(n=s.source)?void 0:n.url)?(0,l.jsxs)("a",{href:s.source.url,target:"_blank",rel:"noreferrer",children:["查看价格来源 ",(0,l.jsx)(x,{size:12,"aria-hidden":"true"})]}):(0,l.jsx)("span",{className:"billing-price-source-placeholder",children:"平台标准目录"}),(0,l.jsx)("span",{className:"billing-price-note",children:"平台标准目录按参数档位列出,用户选择后自动匹配。"})]}),(0,l.jsxs)("section",{className:"billing-price-dimension",children:[(0,l.jsx)("div",{className:"billing-price-dimension-heading",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:"参数档位"}),(0,l.jsx)("small",{children:"不同标准费率独立计费,倍率仅影响用户价"})]})}),(0,l.jsxs)("div",{className:"billing-price-tier-head",children:[(0,l.jsx)("span",{children:"参数档位"}),(0,l.jsx)("span",{children:"标准成本"}),(0,l.jsx)("span",{children:"用户价"}),(0,l.jsx)("span",{children:"倍率"}),(0,l.jsx)("span",{children:"操作"})]}),(0,l.jsx)("div",{className:"billing-price-tier-list",children:i.map(e=>(0,l.jsx)(ec,{rule:e,onEdit:a,disabled:t},e.id))})]})]})}function es(e){let{rule:n,dimension:i,onEdit:a,disabled:t}=e,s=i.tiers.find(e=>String(e.value).toLowerCase()===String(i.baselineValue).toLowerCase());return(0,l.jsxs)("section",{className:"billing-price-dimension",children:[(0,l.jsx)("div",{className:"billing-price-dimension-heading",children:(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:i.label}),(0,l.jsxs)("small",{children:["基准档位:",(null==s?void 0:s.label)||String(i.baselineValue)," \xb7 组合报价按实际选择自动计算"]})]})}),(0,l.jsxs)("div",{className:"billing-price-tier-head",children:[(0,l.jsx)("span",{children:"参数档位"}),(0,l.jsx)("span",{children:"标准成本"}),(0,l.jsx)("span",{children:"用户价"}),(0,l.jsx)("span",{children:"倍率"}),(0,l.jsx)("span",{children:"操作"})]}),(0,l.jsx)("div",{className:"billing-price-tier-list",children:i.tiers.map(e=>(0,l.jsx)(er,{rule:n,dimension:i,tier:e,onEdit:a,disabled:t},"".concat(i.key,"-").concat(String(e.value))))})]})}function er(e){let{rule:n,dimension:i,tier:a,onEdit:t,disabled:s}=e,r=Math.ceil(n.standardUnitPriceFen*a.standardFactor);return(0,l.jsxs)("div",{className:"billing-price-tier-row".concat(a.enabled?"":" billing-price-tier-row-disabled"),children:[(0,l.jsxs)("div",{className:"billing-price-tier-name",children:[(0,l.jsx)("strong",{children:a.label}),(0,l.jsxs)("small",{children:[String(a.value),a.note?" \xb7 ".concat(a.note):""]})]}),(0,l.jsxs)("div",{className:"billing-price-values",children:[(0,l.jsx)("strong",{children:(0,N.JO)(r)}),(0,l.jsxs)("small",{children:["/",(0,N._M)(n.unit)]})]}),(0,l.jsxs)("div",{className:"billing-price-values",children:[(0,l.jsx)("strong",{children:(0,N.JO)(eu(r,a.markupMultiplier))}),(0,l.jsxs)("small",{children:["/",(0,N._M)(n.unit)]})]}),(0,l.jsxs)("span",{className:"billing-multiplier",children:[a.markupMultiplier.toFixed(2),"\xd7"]}),(0,l.jsx)("div",{className:"billing-price-actions",children:(0,l.jsx)("button",{type:"button",onClick:()=>t(n,{dimensionKey:i.key,tierValue:String(a.value),label:"".concat(i.label," \xb7 ").concat(a.label),markupMultiplier:a.markupMultiplier}),disabled:s||!a.enabled,children:"调整倍率"})})]})}function ec(e){let{rule:n,onEdit:i,disabled:a}=e;return(0,l.jsxs)("div",{className:"billing-price-legacy-row",children:[(0,l.jsxs)("div",{className:"billing-price-tier-name",children:[(0,l.jsx)("strong",{children:n.variantKey||function(e){let n=Object.entries(e.conditions||{});return n.length?n.map(e=>{var n;let[i,l]=e;return"".concat({resolution:"分辨率",size:"尺寸",aspectRatio:"比例",quality:"质量",duration:"时长",imageCount:"张数",referenceImageCount:"参考图",model:"模型"}[n=i]||n,"=").concat(function(e){if("object"==typeof e&&null!==e&&!Array.isArray(e)){var n,i,l;if(null==(n=e.values)?void 0:n.length)return e.values.join("/");if(void 0!==e.min||void 0!==e.max)return"".concat(null!=(i=e.min)?i:"-∞","~").concat(null!=(l=e.max)?l:"+∞")}return String(e)}(l))}).join(" \xb7 "):""}(n)||"默认参数"}),(0,l.jsx)("small",{children:n.enabled?"平台标准档位":"已停用"})]}),(0,l.jsxs)("div",{className:"billing-price-values",children:[(0,l.jsx)("strong",{children:(0,N.JO)(n.standardUnitPriceFen)}),(0,l.jsxs)("small",{children:["/",(0,N._M)(n.unit)]})]}),(0,l.jsxs)("div",{className:"billing-price-values",children:[(0,l.jsx)("strong",{children:(0,N.JO)(eu(n.standardUnitPriceFen,n.markupMultiplier))}),(0,l.jsxs)("small",{children:["/",(0,N._M)(n.unit)]})]}),(0,l.jsxs)("span",{className:"billing-multiplier",children:[n.markupMultiplier.toFixed(2),"\xd7"]}),(0,l.jsx)("div",{className:"billing-price-actions",children:(0,l.jsx)("button",{type:"button",onClick:()=>i(n,{label:"服务",markupMultiplier:n.markupMultiplier}),disabled:a||!n.enabled,children:"调整倍率"})})]})}function ed(e){let{wallets:n}=e;return(0,l.jsxs)("div",{className:"billing-wallet-list",children:[(0,l.jsxs)("div",{className:"billing-list-head",children:[(0,l.jsx)("span",{children:"组织"}),(0,l.jsx)("span",{children:"余额 / 累计扣费"})]}),n.length?n.map(e=>(0,l.jsxs)("div",{className:"billing-wallet-row",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:e.name}),(0,l.jsxs)("small",{children:[(0,l.jsx)("span",{className:"billing-org-dot billing-org-dot-".concat(e.status)}),"active"===e.status?"正常":"已停用"]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:(0,N.JO)(e.wallet.balanceFen)}),(0,l.jsxs)("small",{children:["累计扣费 ",(0,N.JO)(e.wallet.totalChargedFen)]})]})]},e.id)):(0,l.jsxs)("div",{className:"billing-empty-state",children:[(0,l.jsx)(p.A,{size:19}),(0,l.jsx)("span",{children:"暂无组织"})]})]})}function eo(e){let{members:n,entries:i}=e,a=n.filter(e=>e.organizationId);return(0,l.jsxs)("div",{className:"billing-member-balance-list",children:[(0,l.jsxs)("div",{className:"billing-member-balance-head",children:[(0,l.jsx)("span",{children:"成员"}),(0,l.jsx)("span",{children:"净消耗"})]}),a.length?a.map(e=>{let n=function(e,n){let i=e.filter(e=>e.accountId===n),l=i.filter(e=>"charge"===e.kind).reduce((e,n)=>e+Math.max(0,-n.deltaFen),0),a=i.filter(e=>"refund"===e.kind).reduce((e,n)=>e+Math.max(0,n.deltaFen),0);return{chargedFen:l,refundedFen:a,netConsumedFen:Math.max(0,l-a)}}(i,e.id);return(0,l.jsxs)("div",{className:"billing-member-balance-row",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:e.displayName}),(0,l.jsxs)("small",{children:[e.phone,"disabled"===e.status?" \xb7 已停用":""]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:(0,N.JO)(n.netConsumedFen)}),(0,l.jsxs)("small",{children:["扣费 ",(0,N.JO)(n.chargedFen)," \xb7 退款 ",(0,N.JO)(n.refundedFen)]})]})]},e.id)}):(0,l.jsxs)("div",{className:"billing-empty-state",children:[(0,l.jsx)(d,{size:19}),(0,l.jsx)("span",{children:"暂无组织成员"})]})]})}function eu(e,n){return Math.ceil(e*n)}function eh(e){return"volcengine-visual"===e?"即梦":"evolink"===e?"EvoLink":"seedance"===e?"Seedance":"seedream"===e?"Seedream 5.0 Pro":"bailian"===e?"百炼":e}var eg=i(4577);function em(){return(0,l.jsx)(eg.BrowserAuthGuard,{children:(0,l.jsx)(eb,{})})}function eb(){let{isSuperAdmin:e}=(0,eg.a)();return(0,l.jsx)(D,{isSuperAdmin:e})}},4166:(e,n,i)=>{"use strict";i.d(n,{JO:()=>a,_M:()=>t});let l=[{value:"request",label:"按次"},{value:"image",label:"按张"},{value:"video_second",label:"按秒"}];function a(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"CNY",i=Math.max(0,Number(e||0))/100;return new Intl.NumberFormat("zh-CN",{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}function t(e){var n;return(null==(n=l.find(n=>n.value===e))?void 0:n.label)||e}},4274:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]])},4577:(e,n,i)=>{"use strict";i.d(n,{BrowserAuthGuard:()=>o,BrowserAuthProvider:()=>c,ClientRedirect:()=>u,a:()=>d});var l=i(5155),a=i(2115),t=i(63),s=i(6660);let r=(0,a.createContext)(null);function c(e){let{children:n}=e,[i,t]=(0,a.useState)(null),[c,d]=(0,a.useState)("loading"),[o,u]=(0,a.useState)(null),h=(0,a.useCallback)(async e=>{try{let n=await (0,s.uK)(e);t(n),d("ready"),u(null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;d("error"),u(e instanceof Error?e.message:"无法读取认证状态")}},[]);(0,a.useEffect)(()=>{let e=new AbortController;return h(e.signal),()=>e.abort()},[h]);let g=(0,a.useMemo)(()=>{var e,n;let l=(null==i?void 0:i.user)||null,a=null==(e=null==i?void 0:i.authRequired)||e,t=!a||(null==l?void 0:l.role)==="super_admin",s=t||(null==l?void 0:l.role)==="organization_admin";return{status:c,user:l,authMode:(null==i?void 0:i.authMode)||null,authRequired:a,authConfigured:null!=(n=null==i?void 0:i.authConfigured)&&n,isAdmin:s,isSuperAdmin:t,error:o,refresh:()=>h()}},[o,h,i,c]);return(0,l.jsx)(r.Provider,{value:g,children:n})}function d(){let e=(0,a.useContext)(r);if(!e)throw Error("useBrowserAuth must be used inside BrowserAuthProvider");return e}function o(e){let{children:n,role:i="user"}=e,r=d(),c=(0,t.usePathname)(),o=(0,t.useRouter)(),u="ready"===r.status&&r.authRequired&&!r.user;return((0,a.useEffect)(()=>{if(u){let e=(0,s.M6)(window.location,c||"/create");o.replace("/auth/login?next=".concat(encodeURIComponent(e)))}},[u,c,o]),"loading"===r.status||u)?(0,l.jsx)(h,{message:"正在确认登录状态…"}):"error"===r.status?(0,l.jsx)(h,{message:r.error||"无法读取认证状态",actionLabel:"重试",onAction:()=>void r.refresh()}):("admin"!==i||r.isAdmin)&&("super"!==i||r.isSuperAdmin)?(0,l.jsx)(l.Fragment,{children:n}):(0,l.jsx)(h,{message:"当前账号无权访问此页面。"})}function u(e){let{to:n,forwardNext:i=!1}=e;return(0,a.useEffect)(()=>{let e=i?new URLSearchParams(window.location.search).get("next"):null,l=e?"".concat(n,"?next=").concat(encodeURIComponent(e)):n;window.location.replace(l)},[i,n]),(0,l.jsx)(h,{message:"正在跳转…"})}function h(e){let{message:n,actionLabel:i,onAction:a}=e;return(0,l.jsxs)("section",{className:"panel",children:[(0,l.jsx)("p",{className:"muted",children:n}),i&&a?(0,l.jsx)("button",{className:"button",type:"button",onClick:a,children:i}):null]})}},5229:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},5468:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]])},5917:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},6191:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},6660:(e,n,i)=>{"use strict";async function l(e){let n=await fetch("/api/auth/me",{method:"GET",cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json"},signal:e});if(!n.ok)throw Error("认证状态请求失败(".concat(n.status,")"));var i,l=await n.json();if(!s(l)||"boolean"!=typeof l.authenticated||"boolean"!=typeof l.authRequired||"boolean"!=typeof l.authConfigured)throw Error("认证状态响应格式无效");if(!l.authenticated){if(null!==l.authMode||null!==l.user)throw Error("认证状态响应格式无效");return{authenticated:!1,authRequired:l.authRequired,authConfigured:l.authConfigured,authMode:null,user:null}}if(!l.authConfigured||"user"!==l.authMode&&"admin"!==l.authMode||!(s(i=l.user)&&"string"==typeof i.id&&i.id.length>0&&"string"==typeof i.subject&&i.subject===i.id&&"string"==typeof i.displayName&&"string"==typeof i.clientId&&("user"===i.role||"organization_admin"===i.role||"super_admin"===i.role)&&"active"===i.status&&("super_admin"===i.role||"string"==typeof i.organizationId&&i.organizationId.length>0)&&Array.isArray(i.authorities)&&i.authorities.every(e=>"string"==typeof e)&&Array.isArray(i.scope)&&i.scope.every(e=>"string"==typeof e)))throw Error("认证用户响应格式无效");let a="user"===l.user.role?"user":"admin";if(l.authMode!==a)throw Error("认证用户响应格式无效");return{authenticated:!0,authRequired:l.authRequired,authConfigured:l.authConfigured,authMode:l.authMode,user:l.user}}function a(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/create";if(!e||!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))return n;try{let i="http://zhinian.local",l=new URL(e,i);if(l.origin!==i)return n;let a="".concat(l.pathname).concat(l.search).concat(l.hash);if(l.pathname.startsWith("/api/auth")||l.pathname.startsWith("/auth/login")||l.pathname.startsWith("/auth/admin-login"))return n;return a}catch(e){return n}}function t(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/create";return a("".concat(e.pathname).concat(e.search).concat(e.hash),n)}function s(e){return"object"==typeof e&&null!==e}i.d(n,{M6:()=>t,uK:()=>l,z3:()=>a})},7612:(e,n,i)=>{"use strict";i.d(n,{It:()=>s,Js:()=>d,c8:()=>c,xr:()=>r});var l=i(7605);let a="power2.out";function t(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function s(e,n){let i=e.current;if(!i||t())return;let a=l.os.context(()=>n(i),i);return()=>a.revert()}function r(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"[data-animate]";if(t())return;let i=l.os.utils.toArray(n,e);i.length&&l.os.fromTo(i,{autoAlpha:0,y:14},{autoAlpha:1,y:0,duration:.28,ease:a,stagger:.045,clearProps:"transform,opacity,visibility"})}function c(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;!e||t()||l.os.fromTo(e,{autoAlpha:0,y:n},{autoAlpha:1,y:0,duration:.28,ease:a,clearProps:"transform,opacity,visibility"})}function d(e){!e||t()||l.os.fromTo(e,{scale:.985},{scale:1,duration:.22,ease:a,clearProps:"transform"})}},7937:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},8514:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(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"}]])},9408:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(1847).A)("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]])},9559:(e,n,i)=>{"use strict";i.d(n,{A:()=>l});let l=(0,i(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"}]])},9962:(e,n,i)=>{Promise.resolve().then(i.bind(i,2885))}},e=>{e.O(0,[592,274,441,255,358],()=>e(e.s=9962)),_N_E=e.O()}]);