mantur-components 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@arco-design/web-react`),require(`@arco-design/web-react/icon`),require(`react-i18next`),require(`react/jsx-runtime`),require(`next-themes`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@arco-design/web-react`,`@arco-design/web-react/icon`,`react-i18next`,`react/jsx-runtime`,`next-themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ManturComponents={},e.React,e.ArcoDesign,e.ArcoDesignIcon,e.ReactI18next,e.jsxRuntime,e.nextThemes))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=`/api`,c=`/users/me/points`,l=`mantur-points-refresh`,u=`mantur-tenant-context-change`;function d(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_API_BASE__?window.__MANTUR_COMPONENTS_API_BASE__:s}function f(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__?window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__:c}function p(e){if(typeof document>`u`)return;let t=`${encodeURIComponent(e)}=`;return document.cookie.split(`; `).find(e=>e.startsWith(t))?.slice(t.length)}function m(e){if(typeof document>`u`)return;let t=encodeURIComponent(e),n=window.location.hostname,r=[void 0,n],i=n.split(`.`);i.length>=2&&r.push(`.${i.slice(-2).join(`.`)}`),r.forEach(e=>{document.cookie=`${t}=; path=/; max-age=0${e?`; domain=${e}`:``}`})}function h(e){let t=JSON.parse(e||`null`);if(!t)throw Error(`Request failed`);if(t.code!==0)throw Error(t.message||`Request failed`);return t}async function g(e,t={}){let n=p(`front-token`),r=p(`Accept-Language`),i=t.headers||{};return n&&(i.Authorization=decodeURIComponent(n)),r&&(i[`Accept-Language`]=decodeURIComponent(r)),new Promise((n,r)=>{let a=new XMLHttpRequest;a.open(t.method||`GET`,`${d()}${e}`,!0),a.timeout=t.timeout||1e4,Object.entries(i).forEach(([e,t])=>{a.setRequestHeader(e,t)}),a.onload=()=>{try{let e=h(a.responseText);if(a.status<200||a.status>=300){r(Error(e.message||a.statusText));return}n(e)}catch(e){r(e)}},a.onerror=()=>r(Error(`Network request failed`)),a.ontimeout=()=>r(Error(`Network request timed out`)),a.send(t.body??null)})}async function _(){try{await g(`/auth/front-logout`,{method:`DELETE`})}catch(e){console.warn(`Logout request failed, continuing local logout.`,e)}finally{m(`front-token`),m(`refreshToken`),typeof window<`u`&&window.location.reload()}}async function v(e){let t;if(e.avatarFile){let n=new FormData;n.append(`file`,e.avatarFile),t=(await g(`/users/me/avatar`,{method:`POST`,body:n})).data}return(await g(`/users/me`,{method:`PUT`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({nickname:e.nickname})})).data||t}function y(e){let t=(...t)=>{let n=t.map(t=>e?.[t]).find(e=>e!==void 0);return typeof n==`number`?n:Number(n||0)};return{total:t(`total`,`totalPoints`,`balance`,`points`),recharge:t(`recharge`,`rechargePoints`,`paidPoints`),gifted:t(`gifted`,`giftedPoints`,`bonusPoints`)}}async function b(){return y((await g(f())).data)}async function x(){let e=await b();return typeof window<`u`&&window.dispatchEvent(new CustomEvent(l,{detail:e})),e}function S(e,t){return t?.tenantId?e.find(e=>e.tenantId===t.tenantId)||{tenantId:t.tenantId,tenantName:t.tenantName||t.tenantId,roles:t.roles?.map(e=>({roleCode:e,roleName:e}))}:e.find(e=>e.isOwner)||e[0]}function C(e){typeof window<`u`&&(window.__MANTUR_COMPONENTS_TENANT_CONTEXT__=e,window.dispatchEvent(new CustomEvent(u,{detail:e})))}function w(){if(!(typeof window>`u`))return window.__MANTUR_COMPONENTS_TENANT_CONTEXT__}async function T(){return(await g(`/users/me/tenants`)).data||[]}async function E(){return(await g(`/auth/current-tenant`)).data}async function D(e){return(await g(`/auth/current-tenant/${e}`,{method:`PUT`})).data}async function O(e=`refresh`){let[t,n]=await Promise.all([T(),E()]),r={tenants:t,currentTenant:S(t,n),auth:n,reason:e};return C(r),r}async function k(e){let t=await D(e),n=await T(),r={tenants:n,currentTenant:S(n,t),auth:t,reason:`switch`};return C(r),r}var A={title:`Mantur`,switchTeam:`Switch Team`,personalSettings:`Personal Settings`,logout:`Logout`,loading:`Loading...`,owner:`Owner`,member:`Member`,createTeam:`Create Team`,createTeamComingSoon:`Create team is coming soon`,switchedToTeam:`Switched team`,error:`Request failed`,profileTitle:`Profile`,profileNickname:`Nickname`,profileNicknamePlaceholder:`Please enter nickname`,profileAvatar:`Avatar`,profileUploadAvatar:`Upload Avatar`,profileAvatarHint:`JPG/PNG/WebP, max 2MB, max 2048px.`,profileAvatarTooLarge:`Avatar must be less than 2MB`,profileAvatarDimensionExceeded:`Avatar dimensions must be within 2048px`,profileAvatarInvalidImage:`Invalid image`,profileUpdateSuccess:`Profile updated`,profileSave:`Save`,profileCancel:`Cancel`,myPoints:`My Points`,totalBalance:`Total Balance`,rechargePoints:`Recharge Points`,giftedPoints:`Gifted Points`,recharge:`Recharge`,rechargeTitle:`Recharge Points`,pointsDetail:`Points Detail`,close:`Close`,currentBalance:`Current Balance`,pointsUnit:`points`,rechargeHint:`Recharge points are valid for 2 years after arrival.`,payNow:`Pay Now`,rechargeSuccess:`Recharge successful`,all:`All`,income:`Income`,expense:`Expense`,source:`Source`,sourceAll:`All Sources`,sourceRecharge:`Recharge`,sourceGifted:`Gifted`,dateRange:`Date Range`,startDate:`Start Date`,endDate:`End Date`,dateTo:`to`,query:`Query`,refreshed:`Refreshed`,pointsDeductionTip:`Points expiring soon are deducted first.`,pointsNoteTitle:`Note`,pointsAccountNote:`Points are attached to your personal account. You recharge, consume, and manage them yourself. Others cannot recharge or use them for you. Recharge points are valid for 2 years; gifted points follow the validity set by operations.`};function j(e){return{...A,...e}}var M=`i18nextLng`,N=`manturLanguageSource`,P=`mantur-language-change`,F={"zh-CN":{title:`漫途`,switchTeam:`切换团队`,personalSettings:`个人设置`,logout:`退出登录`,loading:`加载中...`,owner:`管理员`,member:`成员`,createTeam:`创建团队`,createTeamComingSoon:`创建团队功能即将上线`,switchedToTeam:`已切换团队`,error:`请求失败`,profileTitle:`个人资料`,profileNickname:`昵称`,profileNicknamePlaceholder:`请输入昵称`,profileAvatar:`头像`,profileUploadAvatar:`上传头像`,profileAvatarHint:`支持 JPG/PNG/WebP,最大 2MB,尺寸不超过 2048px。`,profileAvatarTooLarge:`头像不能超过 2MB`,profileAvatarDimensionExceeded:`头像尺寸不能超过 2048px`,profileAvatarInvalidImage:`图片无效`,profileUpdateSuccess:`个人资料已更新`,profileSave:`保存`,profileCancel:`取消`,myPoints:`我的积分`,totalBalance:`总余额`,rechargePoints:`充值积分`,giftedPoints:`赠送积分`,recharge:`去充值`,rechargeTitle:`充值积分`,pointsDetail:`积分明细`,close:`关闭`,currentBalance:`当前余额`,pointsUnit:`积分`,rechargeHint:`充值积分有效期 2 年(自到账日起算),支付后不可退换。`,payNow:`立即支付`,rechargeSuccess:`充值成功`,all:`全部`,income:`获得`,expense:`消耗`,source:`来源`,sourceAll:`全部来源`,sourceRecharge:`充值`,sourceGifted:`赠送`,dateRange:`日期查询`,startDate:`开始日期`,endDate:`结束日期`,dateTo:`至`,query:`查询`,refreshed:`已刷新`,pointsDeductionTip:`优先扣减即将到期的积分`,pointsNoteTitle:`说明`,pointsAccountNote:`积分账户挂在你的个人账号上,自己充值、自己消耗、自己负责;他人不能代充、不能代用。充值积分有效期固定 2 年;赠送积分有效期由后台运营发放时设置。`,languageZh:`中文`,languageEn:`English`},"en-US":{...A,languageZh:`中文`,languageEn:`English`}};function I(e){return e?.toLowerCase().startsWith(`en`)?`en-US`:`zh-CN`}function L(){return typeof window>`u`?`zh-CN`:I(window.localStorage.getItem(`i18nextLng`)||document.documentElement.lang||navigator.language)}function R(e){return F[I(e)]}var z=M,B=N;function V(e,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`}function H(){let{i18n:e}=(0,i.useTranslation)(),[o,s]=(0,t.useState)(()=>L()),c=R(o);return(0,t.useEffect)(()=>{s(I(e.language))},[e.language]),(0,a.jsx)(n.Dropdown,{droplist:(0,a.jsxs)(n.Menu,{selectedKeys:[o],onClickMenuItem:t=>{let n=I(t);localStorage.setItem(z,t),localStorage.setItem(B,`manual`),s(n),e.changeLanguage(t),V(`Accept-Language`,t),window.dispatchEvent(new CustomEvent(P,{detail:n})),window.location.reload()},children:[(0,a.jsx)(n.Menu.Item,{children:c.languageZh},`zh-CN`),(0,a.jsx)(n.Menu.Item,{children:c.languageEn},`en-US`)]}),trigger:`click`,position:`br`,children:(0,a.jsx)(n.Button,{shape:`circle`,icon:(0,a.jsx)(r.IconLanguage,{})})})}function U(){let{resolvedTheme:e,setTheme:t}=(0,o.useTheme)();return(0,a.jsx)(n.Button,{shape:`circle`,icon:e===`light`?(0,a.jsx)(r.IconMoonFill,{}):(0,a.jsx)(r.IconSunFill,{}),onClick:()=>{t(e===`light`?`dark`:`light`)}})}var W=[{id:`points-500`,points:500,price:5},{id:`points-1000`,points:1e3,price:10},{id:`points-5500`,points:5500,price:50,recommended:!0},{id:`points-24000`,points:24e3,price:200}],G=[{id:`recharge-1`,type:`income`,source:`recharge`,name:`积分充值`,meta:`2026-05-10 14:00:00 · 订单号 R20260510140000 · 套餐 $50`,date:`2026-05-10`,amount:5500,badgeKind:`recharge`,badgeText:`充值`},{id:`gift-1`,type:`income`,source:`gift`,name:`系统赠送 · 新人礼包`,meta:`2026-05-08 09:00:00 · 有效期 30 天`,date:`2026-05-08`,amount:1e3,badgeKind:`gift`,badgeText:`赠送`},{id:`expense-1`,type:`expense`,name:`视频生成 — Sora 40秒 4K`,meta:`2026-05-10 16:45:22 · 制作中心`,date:`2026-05-10`,amount:-400,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-2`,type:`expense`,name:`视频生成 — Sora 25秒 1080p`,meta:`2026-05-11 09:15:42 · 制作中心`,date:`2026-05-11`,amount:-250,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expire-1`,type:`expense`,name:`积分过期`,meta:`2026-05-01 00:00:00 · 2026-04 批次到期未使用`,date:`2026-05-01`,amount:-100,badgeKind:`expired`,badgeText:`自然过期`},{id:`expense-3`,type:`expense`,name:`AI 对话 — GPT-4o 5轮`,meta:`2026-05-07 10:08:55 · 剧本中心`,date:`2026-05-07`,amount:-10,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-4`,type:`expense`,name:`图片生成 — DALL-E 5张`,meta:`2026-05-04 14:20:11 · 制作中心`,date:`2026-05-04`,amount:-75,badgeKind:`deducted`,badgeText:`已扣除`}],{RangePicker:K}=n.DatePicker,q=21,J=7;function Y(e){return e===`recharge`?`arcoblue`:e===`gift`?`cyan`:e===`expired`?`gray`:`orange`}function ee({visible:e,points:i,text:o,onCancel:s,onRecharge:c}){let[l,u]=(0,t.useState)(`all`),[d,f]=(0,t.useState)(`all`),[p,m]=(0,t.useState)([`2026-04-15`,`2026-05-15`]),[h,g]=(0,t.useState)(1),_=e=>new Intl.NumberFormat().format(e),v=(0,t.useMemo)(()=>{let[e,t]=p;return G.filter(n=>{let r=l===`all`||n.type===l,i=d===`all`||n.source===d,a=!e||n.date>=e,o=!t||n.date<=t;return r&&i&&a&&o})},[p,d,l]),y=[{title:o.pointsDetail,dataIndex:`name`,render:(e,t)=>(0,a.jsxs)(`div`,{className:`min-w-0`,children:[(0,a.jsx)(n.Typography.Text,{className:`font-medium!`,children:t.name}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-xs!`,children:t.meta})]})},{title:o.pointsUnit,dataIndex:`amount`,width:120,align:`right`,render:(e,t)=>(0,a.jsxs)(n.Typography.Text,{className:`font-semibold! ${t.amount>0?`text-arco-success-6!`:`text-arco-danger-6!`}`,children:[t.amount>0?`+`:``,_(t.amount)]})},{title:o.source,dataIndex:`badgeText`,width:110,align:`right`,render:(e,t)=>(0,a.jsx)(n.Tag,{color:Y(t.badgeKind),children:t.badgeText})}];return(0,a.jsx)(n.Modal,{title:o.pointsDetail,visible:e,footer:(0,a.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,a.jsx)(n.Button,{onClick:s,children:o.close}),(0,a.jsx)(n.Button,{type:`primary`,icon:(0,a.jsx)(r.IconPlus,{}),onClick:()=>{s(),c()},children:o.recharge})]}),onCancel:s,style:{width:780,maxWidth:`calc(100vw - 48px)`},children:(0,a.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto`,children:[(0,a.jsxs)(n.Card,{bordered:!1,className:`from-arco-primary-light-1/40 to-cyan-400/5 rounded-none! bg-linear-to-br!`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.totalBalance}),(0,a.jsxs)(`div`,{className:`mt-1.5 mb-3.5 `,children:[(0,a.jsx)(n.Typography.Text,{className:`text-3xl! font-bold!`,children:_(i.total)}),(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`ml-2 text-sm! `,children:[`🪙 `,o.pointsUnit]})]}),(0,a.jsxs)(n.Grid.Row,{gutter:12,children:[(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.rechargePoints}),(0,a.jsx)(n.Tag,{color:`arcoblue`,children:o.sourceRecharge})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.recharge)})]})}),(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.giftedPoints}),(0,a.jsx)(n.Tag,{color:`success`,children:o.sourceGifted})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.gifted)})]})})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-2.5 block! text-xs!`,children:o.pointsDeductionTip})]}),(0,a.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,a.jsxs)(n.Tabs,{activeTab:l,onChange:e=>u(e),children:[(0,a.jsx)(n.Tabs.TabPane,{title:o.all},`all`),(0,a.jsx)(n.Tabs.TabPane,{title:o.income},`income`),(0,a.jsx)(n.Tabs.TabPane,{title:o.expense},`expense`)]}),(0,a.jsxs)(`div`,{className:`mt-2 mb-3.5 flex flex-wrap items-center gap-2.5`,children:[(0,a.jsxs)(n.Select,{value:d,style:{width:140},onChange:e=>f(e),children:[(0,a.jsx)(n.Select.Option,{value:`all`,children:o.sourceAll}),(0,a.jsx)(n.Select.Option,{value:`recharge`,children:o.sourceRecharge}),(0,a.jsx)(n.Select.Option,{value:`gift`,children:o.sourceGifted})]}),(0,a.jsx)(K,{value:p,onChange:e=>m(e),style:{width:260}}),(0,a.jsx)(n.Button,{onClick:()=>n.Message.success(o.refreshed),children:o.query})]}),(0,a.jsx)(n.Table,{rowKey:`id`,columns:y,data:v,pagination:!1,border:!1}),(0,a.jsx)(n.Pagination,{className:`mt-3 flex justify-center!`,current:h,pageSize:J,total:q,onChange:g})]}),(0,a.jsx)(n.Card,{bordered:!1,className:`bg-arco-primary-light-1/30 rounded-none!`,children:(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`text-xs! leading-6!`,children:[(0,a.jsxs)(`strong`,{children:[o.pointsNoteTitle,`:`]}),o.pointsAccountNote]})})]})})}var X=2048,te=2*1024*1024;function ne(e){return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`invalid image`))},i.src=r})}function re({visible:e,user:i,labels:o,onCancel:s,onSubmit:c}){let l=j(o),[u]=n.Form.useForm(),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null);(0,t.useEffect)(()=>()=>{_.current&&=(URL.revokeObjectURL(_.current),null)},[]),(0,t.useEffect)(()=>{e&&(u.setFieldsValue({nickname:i?.nickname||i?.username||``}),m(null),g(e=>(e&&URL.revokeObjectURL(e),_.current=null,null)))},[e,i,u]);let v=(e,t)=>{console.error(t),n.Message.error(e)},y=e=>{n.Message.success(e)};return(0,a.jsx)(n.Modal,{title:l.profileTitle,visible:e,onOk:async()=>{try{let e=await u.validate();f(!0),await c({nickname:e.nickname,avatarFile:p}),y(l.profileUpdateSuccess),s()}catch(e){e instanceof Error&&v(e.message||l.error,e)}finally{f(!1)}},onCancel:s,confirmLoading:d,okText:l.profileSave,cancelText:l.profileCancel,children:(0,a.jsxs)(n.Form,{form:u,layout:`vertical`,children:[(0,a.jsx)(n.Form.Item,{label:l.profileNickname,field:`nickname`,rules:[{required:!0,message:l.profileNicknamePlaceholder}],children:(0,a.jsx)(n.Input,{placeholder:l.profileNicknamePlaceholder,allowClear:!0})}),(0,a.jsx)(n.Form.Item,{label:l.profileAvatar,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,a.jsx)(n.Avatar,{size:64,className:`shrink-0 bg-arco-primary-light-1!`,children:h||i?.avatar?(0,a.jsx)(`img`,{src:h||i?.avatar,alt:``,className:`block h-full w-full object-cover`}):i?.nickname?.[0]||i?.username?.[0]||`U`}),(0,a.jsx)(n.Upload,{accept:`image/*`,showUploadList:!1,beforeUpload:async e=>{if(e.size>te)return v(l.profileAvatarTooLarge),!1;try{let{width:t,height:n}=await ne(e);if(t>X||n>X)return v(l.profileAvatarDimensionExceeded),!1}catch(e){return v(l.profileAvatarInvalidImage,e),!1}return g(t=>{t&&URL.revokeObjectURL(t);let n=URL.createObjectURL(e);return _.current=n,n}),m(e),!1},children:(0,a.jsx)(n.Button,{type:`outline`,size:`small`,icon:(0,a.jsx)(r.IconUpload,{}),children:l.profileUploadAvatar})})]}),(0,a.jsx)(`span`,{className:`text-xs text-arco-text-3`,children:l.profileAvatarHint})]})})]})})}function ie(e){return e?.nickname?.[0]||e?.username?.[0]||`U`}function Z({user:e,size:t,className:r=``}){return(0,a.jsx)(n.Avatar,{size:t,className:`bg-arco-primary/20! text-arco-primary-6 border-2 font-bold ${r}`,children:e?.avatar?(0,a.jsx)(`img`,{src:e.avatar,alt:`avatar`,className:`h-full w-full object-cover`}):ie(e)})}function ae({visible:e,user:i,points:o,text:s,onCancel:c,onPay:l}){let[u,d]=(0,t.useState)(W[2].id),f=e=>new Intl.NumberFormat().format(e),p=W.find(e=>e.id===u)||W[0];return(0,a.jsx)(n.Modal,{title:s.rechargeTitle,visible:e,footer:(0,a.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-2 text-sm leading-6`,children:s.rechargeHint}),(0,a.jsxs)(n.Button,{type:`primary`,size:`large`,className:`min-w-48! font-bold!`,onClick:()=>l(p),children:[s.payNow,` · $`,p.price]})]}),onCancel:c,alignCenter:!1,wrapClassName:`overflow-hidden!`,style:{width:`100vw`,maxWidth:`100vw`,top:0,paddingBottom:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-hidden! [&_.arco-modal-body]:p-0! [&_.arco-modal-close-icon]:top-1.5! [&_.arco-modal-close-icon]:right-4! [&_.arco-modal-close-icon]:inline-flex! [&_.arco-modal-close-icon]:h-9! [&_.arco-modal-close-icon]:w-9! [&_.arco-modal-close-icon]:items-center! [&_.arco-modal-close-icon]:justify-center! [&_.arco-modal-close-icon]:rounded-lg! [&_.arco-modal-close-icon]:text-lg! [&_.arco-modal-close-icon]:leading-9! [&_.arco-modal-close-icon]:transition-colors [&_.arco-modal-close-icon:hover]:bg-arco-fill-2 [&_.arco-modal-close-icon:hover]:text-arco-primary-6 [&_.arco-modal-close-icon_svg]:h-[18px]! [&_.arco-modal-close-icon_svg]:w-[18px]! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-auto! [&_.arco-modal-content]:min-h-0! [&_.arco-modal-content]:flex-1! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:overflow-hidden! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-footer]:shrink-0! [&_.arco-modal-header]:shrink-0!`,children:(0,a.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-7xl flex-col items-center `,children:[(0,a.jsxs)(`div`,{className:`w-full border-arco-border-1 bg-arco-fill-1 text-arco-text-2 flex items-center gap-2.5 rounded-lg border px-3.5 py-3 text-sm`,children:[(0,a.jsx)(Z,{user:i,size:32,className:`shrink-0`}),(0,a.jsxs)(`span`,{children:[i?.nickname||i?.username,` · `,s.currentBalance,` `,(0,a.jsx)(`strong`,{className:`text-arco-text-1`,children:f(o.total)}),` `,s.pointsUnit]})]}),(0,a.jsx)(`div`,{className:`mt-6 w-full`,children:(0,a.jsx)(n.Grid.Row,{gutter:[16,16],children:W.map(e=>(0,a.jsx)(n.Grid.Col,{xs:24,sm:12,lg:6,children:(0,a.jsxs)(n.Card,{hoverable:!0,role:`button`,tabIndex:0,onClick:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},bodyStyle:{minHeight:192,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},className:`border-arco-border-2! bg-arco-bg-2! relative cursor-pointer overflow-hidden rounded-lg! shadow-sm! transition-all duration-200 before:absolute before:inset-x-0 before:top-0 before:h-1 before:bg-linear-to-r before:from-arco-primary before:to-transparent hover:shadow-md! ${u===e.id?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:`hover:border-arco-primary-6!`}`,children:[u===e.id?(0,a.jsx)(r.IconCheckCircleFill,{className:`text-arco-primary-6! absolute bottom-4 left-4 text-xl`}):null,`recommended`in e&&e.recommended?(0,a.jsx)(n.Tag,{color:`arcoblue`,className:`absolute top-4 right-4 text-xs! font-bold!`,children:`HOT`}):null,(0,a.jsxs)(`div`,{className:`min-w-0 pr-16`,children:[(0,a.jsxs)(n.Typography.Text,{className:`flex items-center text-3xl! leading-tight! font-bold!`,children:[f(e.points),(0,a.jsx)(`span`,{className:`ml-1 text-2xl`,children:`🪙`})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-sm!`,children:s.pointsUnit})]}),(0,a.jsx)(`div`,{className:`mt-7 flex w-full justify-end`,children:(0,a.jsxs)(n.Typography.Text,{className:`text-arco-primary-6! text-right text-2xl! leading-tight! font-bold!`,children:[`$`,e.price]})})]})},e.id))})})]})})}function oe({user:e,points:t,text:i,onEditProfile:o,onRecharge:s,onPointsDetail:c,onLogout:l}){let u=e=>new Intl.NumberFormat().format(e);return(0,a.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,a.jsx)(Z,{user:e,size:48,className:`shrink-0`}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,a.jsx)(n.Button,{type:`text`,size:`mini`,icon:(0,a.jsx)(r.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:o})]}),e?.email?(0,a.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.myPoints}),(0,a.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:u(t.total)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.rechargePoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.recharge)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.giftedPoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.gifted)})]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[(0,a.jsx)(n.Button,{type:`primary`,long:!0,icon:(0,a.jsx)(r.IconPlus,{}),className:`h-10! rounded-md! font-semibold!`,onClick:s,children:i.recharge}),(0,a.jsx)(n.Button,{long:!0,icon:(0,a.jsx)(r.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! rounded-md! font-semibold!`,onClick:c,children:i.pointsDetail})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsx)(`div`,{className:`px-6 py-4`,children:(0,a.jsx)(n.Button,{icon:(0,a.jsx)(r.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void l?.(),children:i.logout})})]})}var se=`https://mantur.ai/images/logo.png`,Q=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function $(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${Q[e%Q.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function ce(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function le(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function ue({user:e,disabled:i=!1,brandSlot:o,children:s}){let[c,d]=(0,t.useState)(()=>L()),f=R(c),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[S,C]=(0,t.useState)(e),[w,T]=(0,t.useState)([]),[E,D]=(0,t.useState)(),[A,j]=(0,t.useState)(!1),[M,N]=(0,t.useState)({total:0,recharge:0,gifted:0}),F=E?.tenantId||``,z=i,B={total:M.total??0,recharge:M.recharge??0,gifted:M.gifted??0},V=async e=>{let t=await v(e);return t&&C(t),t};(0,t.useEffect)(()=>{C(e)},[e]),(0,t.useEffect)(()=>{let e=e=>{T(e.tenants),D(e.currentTenant)},t=t=>{t instanceof CustomEvent&&e(t.detail)};return window.addEventListener(u,t),j(!0),O().then(e).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),n.Message.error(f.error)}).finally(()=>j(!1)),()=>{window.removeEventListener(u,t)}},[f.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&N(e.detail)};return window.addEventListener(l,e),x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(l,e)}},[]),(0,t.useEffect)(()=>{let e=e=>{d(e instanceof CustomEvent?I(e.detail):L())};return window.addEventListener(P,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(P,e),window.removeEventListener(`storage`,e)}},[]);let W=e=>{n.Message.success(e)},G=(e,t)=>{console.error(t),n.Message.error(e)},K=(0,t.useCallback)(async e=>{if(!z&&e!==F)try{j(!0);let t=await k(e);T(t.tenants),D(t.currentTenant),W(f.switchedToTeam)}catch(e){G(f.error,e)}finally{j(!1)}},[F,z,f.error,f.switchedToTeam]),q=e=>{let t={total:B.total+e.points,recharge:B.recharge+e.points,gifted:B.gifted};N(t),window.dispatchEvent(new CustomEvent(l,{detail:t})),n.Message.success(f.rechargeSuccess),g(!1)},J=(0,t.useMemo)(()=>(0,a.jsxs)(n.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:F?[F]:[],onClickMenuItem:K,children:[(0,a.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:f.switchTeam}),w.map((e,t)=>(0,a.jsx)(n.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,a.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,a.jsx)(`div`,{className:$(t),children:ce(e)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,a.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,a.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:le(e,f.owner,f.member)})]})]})},e.tenantId))]}),[K,F,w,f]),Y=(0,a.jsx)(oe,{user:S,points:B,text:f,onEditProfile:()=>m(!0),onRecharge:()=>g(!0),onPointsDetail:()=>b(!0),onLogout:_}),X=Math.max(0,w.findIndex(e=>e.tenantId===E?.tenantId));return(0,a.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,a.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,a.jsx)(`div`,{className:`relative flex w-12 items-center justify-center overflow-hidden `,children:(0,a.jsx)(`img`,{src:se,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})}),o??(0,a.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:f.title})]}),(0,a.jsx)(n.Dropdown,{droplist:J,trigger:`click`,position:`bl`,disabled:z,children:(0,a.jsxs)(`div`,{"aria-disabled":z,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${z?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,a.jsx)(`div`,{className:$(X,!0),children:ce(E)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:A?f.loading:E?.tenantName||f.loading}),(0,a.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:le(E,f.owner,f.member)})]}),(0,a.jsx)(r.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,a.jsx)(`div`,{className:`flex-1`,children:s}),(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsx)(U,{}),(0,a.jsx)(H,{})]}),(0,a.jsx)(n.Dropdown,{droplist:Y,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&x().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})},children:(0,a.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,a.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,a.jsx)(Z,{user:S,size:36}),(0,a.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,a.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,a.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:S?.nickname||S?.username})}),(0,a.jsx)(r.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,a.jsx)(re,{visible:p,user:S,labels:f,onCancel:()=>m(!1),onSubmit:V}),(0,a.jsx)(ae,{visible:h,user:S,points:B,text:f,onCancel:()=>g(!1),onPay:q}),(0,a.jsx)(ee,{visible:y,points:B,text:f,onCancel:()=>b(!1),onRecharge:()=>g(!0)})]})}e.LANGUAGE_SOURCE_STORAGE_KEY=B,e.LANGUAGE_STORAGE_KEY=z,e.LangSwitch=H,e.MANTUR_LANGUAGE_CHANGE_EVENT=P,e.MANTUR_LANGUAGE_SOURCE_STORAGE_KEY=N,e.MANTUR_LANGUAGE_STORAGE_KEY=M,e.MANTUR_MESSAGES=F,e.MANTUR_POINTS_REFRESH_EVENT=l,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=u,e.ManturHeader=ue,e.ThemeSwitch=U,e.getManturCurrentTenant=E,e.getManturMessages=R,e.getManturTenantContextSnapshot=w,e.getManturTenants=T,e.getManturUserPoints=b,e.getStoredManturLocale=L,e.normalizeManturLocale=I,e.refreshManturTenantContext=O,e.refreshManturUserPoints=x,e.switchAndRefreshManturTenant=k,e.switchManturTenant=D});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@arco-design/web-react`),require(`@arco-design/web-react/icon`),require(`react-i18next`),require(`react/jsx-runtime`),require(`next-themes`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@arco-design/web-react`,`@arco-design/web-react/icon`,`react-i18next`,`react/jsx-runtime`,`next-themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ManturComponents={},e.React,e.ArcoDesign,e.ArcoDesignIcon,e.ReactI18next,e.jsxRuntime,e.nextThemes))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)),g=`/api`,_=`/users/me/points`,v=`mantur-points-refresh`,y=`mantur-tenant-context-change`;function b(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_API_BASE__?window.__MANTUR_COMPONENTS_API_BASE__:g}function x(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__?window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__:_}function S(e){if(typeof document>`u`)return;let t=`${encodeURIComponent(e)}=`;return document.cookie.split(`; `).find(e=>e.startsWith(t))?.slice(t.length)}function C(e){if(typeof document>`u`)return;let t=encodeURIComponent(e),n=window.location.hostname,r=[void 0,n],i=n.split(`.`);i.length>=2&&r.push(`.${i.slice(-2).join(`.`)}`),r.forEach(e=>{document.cookie=`${t}=; path=/; max-age=0${e?`; domain=${e}`:``}`})}function w(e){let t=JSON.parse(e||`null`);if(!t)throw Error(`Request failed`);if(t.code!==0)throw Error(t.message||`Request failed`);return t}async function T(e,t={}){let n=S(`front-token`),r=S(`Accept-Language`),i=t.headers||{};return n&&(i.Authorization=decodeURIComponent(n)),r&&(i[`Accept-Language`]=decodeURIComponent(r)),new Promise((n,r)=>{let a=new XMLHttpRequest;a.open(t.method||`GET`,`${b()}${e}`,!0),a.timeout=t.timeout||1e4,Object.entries(i).forEach(([e,t])=>{a.setRequestHeader(e,t)}),a.onload=()=>{try{let e=w(a.responseText);if(a.status<200||a.status>=300){r(Error(e.message||a.statusText));return}n(e)}catch(e){r(e)}},a.onerror=()=>r(Error(`Network request failed`)),a.ontimeout=()=>r(Error(`Network request timed out`)),a.send(t.body??null)})}async function E(){try{await T(`/auth/front-logout`,{method:`DELETE`})}catch(e){console.warn(`Logout request failed, continuing local logout.`,e)}finally{C(`front-token`),C(`refreshToken`),typeof window<`u`&&window.location.reload()}}async function D(e){let t;if(e.avatarFile){let n=new FormData;n.append(`file`,e.avatarFile),t=(await T(`/users/me/avatar`,{method:`POST`,body:n})).data}return(await T(`/users/me`,{method:`PUT`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({nickname:e.nickname})})).data||t}function O(e){let t=(...t)=>{let n=t.map(t=>e?.[t]).find(e=>e!==void 0);return typeof n==`number`?n:Number(n||0)};return{total:t(`total`,`totalPoints`,`balance`,`points`),recharge:t(`recharge`,`rechargePoints`,`paidPoints`),gifted:t(`gifted`,`giftedPoints`,`bonusPoints`)}}async function k(){return O((await T(x())).data)}async function A(){let e=await k();return typeof window<`u`&&window.dispatchEvent(new CustomEvent(v,{detail:e})),e}function j(e,t){return t?.tenantId?e.find(e=>e.tenantId===t.tenantId)||{tenantId:t.tenantId,tenantName:t.tenantName||t.tenantId,roles:t.roles?.map(e=>({roleCode:e,roleName:e}))}:e.find(e=>e.isOwner)||e[0]}function M(e){typeof window<`u`&&(window.__MANTUR_COMPONENTS_TENANT_CONTEXT__=e,window.dispatchEvent(new CustomEvent(y,{detail:e})))}function N(){if(!(typeof window>`u`))return window.__MANTUR_COMPONENTS_TENANT_CONTEXT__}async function P(){return(await T(`/users/me/tenants`)).data||[]}async function F(){return(await T(`/auth/current-tenant`)).data}async function I(e){return(await T(`/auth/current-tenant/${e}`,{method:`PUT`})).data}async function ee(e=`refresh`){let[t,n]=await Promise.all([P(),F()]),r={tenants:t,currentTenant:j(t,n),auth:n,reason:e};return M(r),r}async function te(e){let t=await I(e),n=await P(),r={tenants:n,currentTenant:j(n,t),auth:t,reason:`switch`};return M(r),r}var L={title:`Mantur`,switchTeam:`Switch Team`,personalSettings:`Personal Settings`,logout:`Logout`,loading:`Loading...`,owner:`Owner`,member:`Member`,createTeam:`Create Team`,createTeamComingSoon:`Create team is coming soon`,switchedToTeam:`Switched team`,error:`Request failed`,profileTitle:`Profile`,profileNickname:`Nickname`,profileNicknamePlaceholder:`Please enter nickname`,profileAvatar:`Avatar`,profileUploadAvatar:`Upload Avatar`,profileAvatarHint:`JPG/PNG/WebP, max 2MB, max 2048px.`,profileAvatarTooLarge:`Avatar must be less than 2MB`,profileAvatarDimensionExceeded:`Avatar dimensions must be within 2048px`,profileAvatarInvalidImage:`Invalid image`,profileUpdateSuccess:`Profile updated`,profileSave:`Save`,profileCancel:`Cancel`,myPoints:`My Points`,totalBalance:`Total Balance`,rechargePoints:`Recharge Points`,giftedPoints:`Gifted Points`,recharge:`Recharge`,rechargeTitle:`Recharge Points`,pointsDetail:`Points Detail`,close:`Close`,currentBalance:`Current Balance`,pointsUnit:`points`,rechargeHint:`Recharge points are valid for 2 years after arrival.`,payNow:`Pay Now`,rechargeSuccess:`Recharge successful`,all:`All`,income:`Income`,expense:`Expense`,source:`Source`,sourceAll:`All Sources`,sourceRecharge:`Recharge`,sourceGifted:`Gifted`,dateRange:`Date Range`,startDate:`Start Date`,endDate:`End Date`,dateTo:`to`,query:`Query`,refreshed:`Refreshed`,pointsDeductionTip:`Points expiring soon are deducted first.`,pointsNoteTitle:`Note`,pointsAccountNote:`Points are attached to your personal account. You recharge, consume, and manage them yourself. Others cannot recharge or use them for you. Recharge points are valid for 2 years; gifted points follow the validity set by operations.`},R={languageZh:`中文`,languageEn:`English`},z={title:`漫途`,switchTeam:`切换团队`,personalSettings:`个人设置`,logout:`退出登录`,loading:`加载中...`,owner:`管理员`,member:`成员`,createTeam:`创建团队`,createTeamComingSoon:`创建团队功能即将上线`,switchedToTeam:`已切换团队`,error:`请求失败`,profileTitle:`个人资料`,profileNickname:`昵称`,profileNicknamePlaceholder:`请输入昵称`,profileAvatar:`头像`,profileUploadAvatar:`上传头像`,profileAvatarHint:`支持 JPG/PNG/WebP,最大 2MB,尺寸不超过 2048px。`,profileAvatarTooLarge:`头像不能超过 2MB`,profileAvatarDimensionExceeded:`头像尺寸不能超过 2048px`,profileAvatarInvalidImage:`图片无效`,profileUpdateSuccess:`个人资料已更新`,profileSave:`保存`,profileCancel:`取消`,myPoints:`我的积分`,totalBalance:`总余额`,rechargePoints:`充值积分`,giftedPoints:`赠送积分`,recharge:`去充值`,rechargeTitle:`充值积分`,pointsDetail:`积分明细`,close:`关闭`,currentBalance:`当前余额`,pointsUnit:`积分`,rechargeHint:`充值积分有效期 2 年(自到账日起算),支付后不可退换。`,payNow:`立即支付`,rechargeSuccess:`充值成功`,all:`全部`,income:`获得`,expense:`消耗`,source:`来源`,sourceAll:`全部来源`,sourceRecharge:`充值`,sourceGifted:`赠送`,dateRange:`日期查询`,startDate:`开始日期`,endDate:`结束日期`,dateTo:`至`,query:`查询`,refreshed:`已刷新`,pointsDeductionTip:`优先扣减即将到期的积分`,pointsNoteTitle:`说明`,pointsAccountNote:`积分账户挂在你的个人账号上,自己充值、自己消耗、自己负责;他人不能代充、不能代用。充值积分有效期固定 2 年;赠送积分有效期由后台运营发放时设置。`},B={languageZh:`中文`,languageEn:`English`},V=`i18nextLng`,H=`manturLanguageSource`,U=`mantur-language-change`,W={"zh-CN":{...z,...B},"en-US":{...L,...R}};function G(e){return e?.toLowerCase().startsWith(`en`)?`en-US`:`zh-CN`}function K(){return typeof window>`u`?`zh-CN`:G(window.localStorage.getItem(`i18nextLng`)||document.documentElement.lang||navigator.language)}function q(e){return W[G(e)]}var J=V,Y=H;function ne(e,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`}function X(){let{i18n:e}=(0,i.useTranslation)(),[o,s]=(0,t.useState)(()=>K()),c=q(o);return(0,t.useEffect)(()=>{s(G(e.language))},[e.language]),(0,a.jsx)(n.Dropdown,{droplist:(0,a.jsxs)(n.Menu,{selectedKeys:[o],onClickMenuItem:t=>{let n=G(t);localStorage.setItem(J,t),localStorage.setItem(Y,`manual`),s(n),e.changeLanguage(t),ne(`Accept-Language`,t),window.dispatchEvent(new CustomEvent(U,{detail:n})),window.location.reload()},children:[(0,a.jsx)(n.Menu.Item,{children:c.languageZh},`zh-CN`),(0,a.jsx)(n.Menu.Item,{children:c.languageEn},`en-US`)]}),trigger:`click`,position:`br`,children:(0,a.jsx)(n.Button,{shape:`circle`,icon:(0,a.jsx)(r.IconLanguage,{})})})}function Z(){let{resolvedTheme:e,setTheme:t}=(0,o.useTheme)();return(0,a.jsx)(n.Button,{shape:`circle`,icon:e===`light`?(0,a.jsx)(r.IconMoonFill,{}):(0,a.jsx)(r.IconSunFill,{}),onClick:()=>{t(e===`light`?`dark`:`light`)}})}var Q=[{id:`points-500`,points:500,price:5},{id:`points-1000`,points:1e3,price:10},{id:`points-5500`,points:5500,price:50,recommended:!0},{id:`points-24000`,points:24e3,price:200}],re=[{id:`recharge-1`,type:`income`,source:`recharge`,name:`积分充值`,meta:`2026-05-10 14:00:00 · 订单号 R20260510140000 · 套餐 $50`,date:`2026-05-10`,amount:5500,badgeKind:`recharge`,badgeText:`充值`},{id:`gift-1`,type:`income`,source:`gift`,name:`系统赠送 · 新人礼包`,meta:`2026-05-08 09:00:00 · 有效期 30 天`,date:`2026-05-08`,amount:1e3,badgeKind:`gift`,badgeText:`赠送`},{id:`expense-1`,type:`expense`,name:`视频生成 — Sora 40秒 4K`,meta:`2026-05-10 16:45:22 · 制作中心`,date:`2026-05-10`,amount:-400,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-2`,type:`expense`,name:`视频生成 — Sora 25秒 1080p`,meta:`2026-05-11 09:15:42 · 制作中心`,date:`2026-05-11`,amount:-250,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expire-1`,type:`expense`,name:`积分过期`,meta:`2026-05-01 00:00:00 · 2026-04 批次到期未使用`,date:`2026-05-01`,amount:-100,badgeKind:`expired`,badgeText:`自然过期`},{id:`expense-3`,type:`expense`,name:`AI 对话 — GPT-4o 5轮`,meta:`2026-05-07 10:08:55 · 剧本中心`,date:`2026-05-07`,amount:-10,badgeKind:`deducted`,badgeText:`已扣除`},{id:`expense-4`,type:`expense`,name:`图片生成 — DALL-E 5张`,meta:`2026-05-04 14:20:11 · 制作中心`,date:`2026-05-04`,amount:-75,badgeKind:`deducted`,badgeText:`已扣除`}],{RangePicker:ie}=n.DatePicker,ae=21,oe=7;function se(e){return e===`recharge`?`arcoblue`:e===`gift`?`cyan`:e===`expired`?`gray`:`orange`}function ce({visible:e,points:i,text:o,onCancel:s,onRecharge:c}){let[l,u]=(0,t.useState)(`all`),[d,f]=(0,t.useState)(`all`),[p,m]=(0,t.useState)([`2026-04-15`,`2026-05-15`]),[h,g]=(0,t.useState)(1),_=e=>new Intl.NumberFormat().format(e),v=(0,t.useMemo)(()=>{let[e,t]=p;return re.filter(n=>{let r=l===`all`||n.type===l,i=d===`all`||n.source===d,a=!e||n.date>=e,o=!t||n.date<=t;return r&&i&&a&&o})},[p,d,l]),y=[{title:o.pointsDetail,dataIndex:`name`,render:(e,t)=>(0,a.jsxs)(`div`,{className:`min-w-0`,children:[(0,a.jsx)(n.Typography.Text,{className:`font-medium!`,children:t.name}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-xs!`,children:t.meta})]})},{title:o.pointsUnit,dataIndex:`amount`,width:120,align:`right`,render:(e,t)=>(0,a.jsxs)(n.Typography.Text,{className:`font-semibold! ${t.amount>0?`text-arco-success-6!`:`text-arco-danger-6!`}`,children:[t.amount>0?`+`:``,_(t.amount)]})},{title:o.source,dataIndex:`badgeText`,width:110,align:`right`,render:(e,t)=>(0,a.jsx)(n.Tag,{color:se(t.badgeKind),children:t.badgeText})}];return(0,a.jsx)(n.Modal,{title:o.pointsDetail,visible:e,footer:(0,a.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,a.jsx)(n.Button,{onClick:s,children:o.close}),(0,a.jsx)(n.Button,{type:`primary`,icon:(0,a.jsx)(r.IconPlus,{}),onClick:()=>{s(),c()},children:o.recharge})]}),onCancel:s,style:{width:780,maxWidth:`calc(100vw - 48px)`},children:(0,a.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto`,children:[(0,a.jsxs)(n.Card,{bordered:!1,className:`from-arco-primary-light-1/40 to-cyan-400/5 rounded-none! bg-linear-to-br!`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.totalBalance}),(0,a.jsxs)(`div`,{className:`mt-1.5 mb-3.5 `,children:[(0,a.jsx)(n.Typography.Text,{className:`text-3xl! font-bold!`,children:_(i.total)}),(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`ml-2 text-sm! `,children:[`🪙 `,o.pointsUnit]})]}),(0,a.jsxs)(n.Grid.Row,{gutter:12,children:[(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.rechargePoints}),(0,a.jsx)(n.Tag,{color:`arcoblue`,children:o.sourceRecharge})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.recharge)})]})}),(0,a.jsx)(n.Grid.Col,{span:12,children:(0,a.jsxs)(n.Card,{size:`small`,children:[(0,a.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`text-xs!`,children:o.giftedPoints}),(0,a.jsx)(n.Tag,{color:`success`,children:o.sourceGifted})]}),(0,a.jsx)(n.Typography.Text,{className:`text-lg! font-semibold!`,children:_(i.gifted)})]})})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-2.5 block! text-xs!`,children:o.pointsDeductionTip})]}),(0,a.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,a.jsxs)(n.Tabs,{activeTab:l,onChange:e=>u(e),children:[(0,a.jsx)(n.Tabs.TabPane,{title:o.all},`all`),(0,a.jsx)(n.Tabs.TabPane,{title:o.income},`income`),(0,a.jsx)(n.Tabs.TabPane,{title:o.expense},`expense`)]}),(0,a.jsxs)(`div`,{className:`mt-2 mb-3.5 flex flex-wrap items-center gap-2.5`,children:[(0,a.jsxs)(n.Select,{value:d,style:{width:140},onChange:e=>f(e),children:[(0,a.jsx)(n.Select.Option,{value:`all`,children:o.sourceAll}),(0,a.jsx)(n.Select.Option,{value:`recharge`,children:o.sourceRecharge}),(0,a.jsx)(n.Select.Option,{value:`gift`,children:o.sourceGifted})]}),(0,a.jsx)(ie,{value:p,onChange:e=>m(e),style:{width:260}}),(0,a.jsx)(n.Button,{onClick:()=>n.Message.success(o.refreshed),children:o.query})]}),(0,a.jsx)(n.Table,{rowKey:`id`,columns:y,data:v,pagination:!1,border:!1}),(0,a.jsx)(n.Pagination,{className:`mt-3 flex justify-center!`,current:h,pageSize:oe,total:ae,onChange:g})]}),(0,a.jsx)(n.Card,{bordered:!1,className:`bg-arco-primary-light-1/30 rounded-none!`,children:(0,a.jsxs)(n.Typography.Text,{type:`secondary`,className:`text-xs! leading-6!`,children:[(0,a.jsxs)(`strong`,{children:[o.pointsNoteTitle,`:`]}),o.pointsAccountNote]})})]})})}var le=L;function ue(e){return{...le,...e}}var de=2048,fe=2*1024*1024;function pe(e){return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`invalid image`))},i.src=r})}function me({visible:e,user:i,labels:o,onCancel:s,onSubmit:c}){let l=ue(o),[u]=n.Form.useForm(),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null);(0,t.useEffect)(()=>()=>{_.current&&=(URL.revokeObjectURL(_.current),null)},[]),(0,t.useEffect)(()=>{e&&(u.setFieldsValue({nickname:i?.nickname||i?.username||``}),m(null),g(e=>(e&&URL.revokeObjectURL(e),_.current=null,null)))},[e,i,u]);let v=(e,t)=>{console.error(t),n.Message.error(e)},y=e=>{n.Message.success(e)};return(0,a.jsx)(n.Modal,{title:l.profileTitle,visible:e,onOk:async()=>{try{let e=await u.validate();f(!0),await c({nickname:e.nickname,avatarFile:p}),y(l.profileUpdateSuccess),s()}catch(e){e instanceof Error&&v(e.message||l.error,e)}finally{f(!1)}},onCancel:s,confirmLoading:d,okText:l.profileSave,cancelText:l.profileCancel,children:(0,a.jsxs)(n.Form,{form:u,layout:`vertical`,children:[(0,a.jsx)(n.Form.Item,{label:l.profileNickname,field:`nickname`,rules:[{required:!0,message:l.profileNicknamePlaceholder}],children:(0,a.jsx)(n.Input,{placeholder:l.profileNicknamePlaceholder,allowClear:!0})}),(0,a.jsx)(n.Form.Item,{label:l.profileAvatar,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,a.jsx)(n.Avatar,{size:64,className:`shrink-0 bg-arco-primary-light-1!`,children:h||i?.avatar?(0,a.jsx)(`img`,{src:h||i?.avatar,alt:``,className:`block h-full w-full object-cover`}):i?.nickname?.[0]||i?.username?.[0]||`U`}),(0,a.jsx)(n.Upload,{accept:`image/*`,showUploadList:!1,beforeUpload:async e=>{if(e.size>fe)return v(l.profileAvatarTooLarge),!1;try{let{width:t,height:n}=await pe(e);if(t>de||n>de)return v(l.profileAvatarDimensionExceeded),!1}catch(e){return v(l.profileAvatarInvalidImage,e),!1}return g(t=>{t&&URL.revokeObjectURL(t);let n=URL.createObjectURL(e);return _.current=n,n}),m(e),!1},children:(0,a.jsx)(n.Button,{type:`outline`,size:`small`,icon:(0,a.jsx)(r.IconUpload,{}),children:l.profileUploadAvatar})})]}),(0,a.jsx)(`span`,{className:`text-xs text-arco-text-3`,children:l.profileAvatarHint})]})})]})})}function he(e){return e?.nickname?.[0]||e?.username?.[0]||`U`}function $({user:e,size:t,className:r=``}){return(0,a.jsx)(n.Avatar,{size:t,className:`bg-arco-primary/20! text-arco-primary-6 border-2 font-bold ${r}`,children:e?.avatar?(0,a.jsx)(`img`,{src:e.avatar,alt:`avatar`,className:`h-full w-full object-cover`}):he(e)})}function ge({visible:e,user:i,points:o,text:s,onCancel:c,onPay:l}){let[u,d]=(0,t.useState)(Q[2].id),f=e=>new Intl.NumberFormat().format(e),p=Q.find(e=>e.id===u)||Q[0];return(0,a.jsx)(n.Modal,{title:s.rechargeTitle,visible:e,footer:(0,a.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-2 text-sm leading-6`,children:s.rechargeHint}),(0,a.jsxs)(n.Button,{type:`primary`,size:`large`,className:`min-w-48! font-bold!`,onClick:()=>l(p),children:[s.payNow,` · $`,p.price]})]}),onCancel:c,alignCenter:!1,wrapClassName:`overflow-hidden!`,style:{width:`100vw`,maxWidth:`100vw`,top:0,paddingBottom:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-hidden! [&_.arco-modal-body]:p-0! [&_.arco-modal-close-icon]:top-1.5! [&_.arco-modal-close-icon]:right-4! [&_.arco-modal-close-icon]:inline-flex! [&_.arco-modal-close-icon]:h-9! [&_.arco-modal-close-icon]:w-9! [&_.arco-modal-close-icon]:items-center! [&_.arco-modal-close-icon]:justify-center! [&_.arco-modal-close-icon]:rounded-lg! [&_.arco-modal-close-icon]:text-lg! [&_.arco-modal-close-icon]:leading-9! [&_.arco-modal-close-icon]:transition-colors [&_.arco-modal-close-icon:hover]:bg-arco-fill-2 [&_.arco-modal-close-icon:hover]:text-arco-primary-6 [&_.arco-modal-close-icon_svg]:h-[18px]! [&_.arco-modal-close-icon_svg]:w-[18px]! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-auto! [&_.arco-modal-content]:min-h-0! [&_.arco-modal-content]:flex-1! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:overflow-hidden! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-footer]:shrink-0! [&_.arco-modal-header]:shrink-0!`,children:(0,a.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-7xl flex-col items-center `,children:[(0,a.jsxs)(`div`,{className:`w-full border-arco-border-1 bg-arco-fill-1 text-arco-text-2 flex items-center gap-2.5 rounded-lg border px-3.5 py-3 text-sm`,children:[(0,a.jsx)($,{user:i,size:32,className:`shrink-0`}),(0,a.jsxs)(`span`,{children:[i?.nickname||i?.username,` · `,s.currentBalance,` `,(0,a.jsx)(`strong`,{className:`text-arco-text-1`,children:f(o.total)}),` `,s.pointsUnit]})]}),(0,a.jsx)(`div`,{className:`mt-6 w-full`,children:(0,a.jsx)(n.Grid.Row,{gutter:[16,16],children:Q.map(e=>(0,a.jsx)(n.Grid.Col,{xs:24,sm:12,lg:6,children:(0,a.jsxs)(n.Card,{hoverable:!0,role:`button`,tabIndex:0,onClick:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},bodyStyle:{minHeight:192,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},className:`border-arco-border-2! bg-arco-bg-2! relative cursor-pointer overflow-hidden rounded-lg! shadow-sm! transition-all duration-200 before:absolute before:inset-x-0 before:top-0 before:h-1 before:bg-linear-to-r before:from-arco-primary before:to-transparent hover:shadow-md! ${u===e.id?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:`hover:border-arco-primary-6!`}`,children:[u===e.id?(0,a.jsx)(r.IconCheckCircleFill,{className:`text-arco-primary-6! absolute bottom-4 left-4 text-xl`}):null,`recommended`in e&&e.recommended?(0,a.jsx)(n.Tag,{color:`arcoblue`,className:`absolute top-4 right-4 text-xs! font-bold!`,children:`HOT`}):null,(0,a.jsxs)(`div`,{className:`min-w-0 pr-16`,children:[(0,a.jsxs)(n.Typography.Text,{className:`flex items-center text-3xl! leading-tight! font-bold!`,children:[f(e.points),(0,a.jsx)(`span`,{className:`ml-1 text-2xl`,children:`🪙`})]}),(0,a.jsx)(n.Typography.Text,{type:`secondary`,className:`mt-1 block! text-sm!`,children:s.pointsUnit})]}),(0,a.jsx)(`div`,{className:`mt-7 flex w-full justify-end`,children:(0,a.jsxs)(n.Typography.Text,{className:`text-arco-primary-6! text-right text-2xl! leading-tight! font-bold!`,children:[`$`,e.price]})})]})},e.id))})})]})})}function _e({user:e,points:t,text:i,onEditProfile:o,onRecharge:s,onPointsDetail:c,onLogout:l}){let u=e=>new Intl.NumberFormat().format(e);return(0,a.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,a.jsx)($,{user:e,size:48,className:`shrink-0`}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,a.jsx)(n.Button,{type:`text`,size:`mini`,icon:(0,a.jsx)(r.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:o})]}),e?.email?(0,a.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.myPoints}),(0,a.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:u(t.total)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.rechargePoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.recharge)})]}),(0,a.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,a.jsx)(`span`,{children:i.giftedPoints}),(0,a.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:u(t.gifted)})]})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[(0,a.jsx)(n.Button,{type:`primary`,long:!0,icon:(0,a.jsx)(r.IconPlus,{}),className:`h-10! rounded-md! font-semibold!`,onClick:s,children:i.recharge}),(0,a.jsx)(n.Button,{long:!0,icon:(0,a.jsx)(r.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! rounded-md! font-semibold!`,onClick:c,children:i.pointsDetail})]}),(0,a.jsx)(n.Divider,{className:`m-0!`}),(0,a.jsx)(`div`,{className:`px-6 py-4`,children:(0,a.jsx)(n.Button,{icon:(0,a.jsx)(r.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void l?.(),children:i.logout})})]})}var ve=`https://mantur.ai/images/logo.png`,ye=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function be(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${ye[e%ye.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function xe(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function Se(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function Ce({user:e,disabled:i=!1,brandSlot:o,children:s,onTenantContextChange:c}){let[l,u]=(0,t.useState)(()=>K()),d=q(l),[f,p]=(0,t.useState)(!1),[m,h]=(0,t.useState)(!1),[g,_]=(0,t.useState)(!1),[y,b]=(0,t.useState)(e),[x,S]=(0,t.useState)([]),[C,w]=(0,t.useState)(),[T,O]=(0,t.useState)(!1),k=(0,t.useRef)(c),[j,M]=(0,t.useState)({total:0,recharge:0,gifted:0}),N=C?.tenantId||``,P=i,F={total:j.total??0,recharge:j.recharge??0,gifted:j.gifted??0},I=async e=>{let t=await D(e);return t&&b(t),t};(0,t.useEffect)(()=>{b(e)},[e]),(0,t.useEffect)(()=>{k.current=c},[c]);let L=(0,t.useCallback)(e=>{S(e.tenants),w(e.currentTenant),k.current?.(e)},[]);(0,t.useEffect)(()=>{O(!0),ee().then(L).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),n.Message.error(d.error)}).finally(()=>O(!1))},[L,d.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&M(e.detail)};return window.addEventListener(v,e),A().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(v,e)}},[]),(0,t.useEffect)(()=>{let e=e=>{u(e instanceof CustomEvent?G(e.detail):K())};return window.addEventListener(U,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(U,e),window.removeEventListener(`storage`,e)}},[]);let R=e=>{n.Message.success(e)},z=(e,t)=>{console.error(t),n.Message.error(e)},B=(0,t.useCallback)(async e=>{if(!P&&e!==N)try{O(!0),L(await te(e)),R(d.switchedToTeam)}catch(e){z(d.error,e)}finally{O(!1)}},[L,N,P,d.error,d.switchedToTeam]),V=e=>{let t={total:F.total+e.points,recharge:F.recharge+e.points,gifted:F.gifted};M(t),window.dispatchEvent(new CustomEvent(v,{detail:t})),n.Message.success(d.rechargeSuccess),h(!1)},H=(0,t.useMemo)(()=>(0,a.jsxs)(n.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:N?[N]:[],onClickMenuItem:B,children:[(0,a.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:d.switchTeam}),x.map((e,t)=>(0,a.jsx)(n.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,a.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,a.jsx)(`div`,{className:be(t),children:xe(e)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,a.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,a.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:Se(e,d.owner,d.member)})]})]})},e.tenantId))]}),[B,N,x,d]),W=(0,a.jsx)(_e,{user:y,points:F,text:d,onEditProfile:()=>p(!0),onRecharge:()=>h(!0),onPointsDetail:()=>_(!0),onLogout:E}),J=Math.max(0,x.findIndex(e=>e.tenantId===C?.tenantId));return(0,a.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,a.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,a.jsx)(`div`,{className:`relative flex w-12 items-center justify-center overflow-hidden `,children:(0,a.jsx)(`img`,{src:ve,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})}),o??(0,a.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:d.title})]}),(0,a.jsx)(n.Dropdown,{droplist:H,trigger:`click`,position:`bl`,disabled:P,children:(0,a.jsxs)(`div`,{"aria-disabled":P,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${P?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,a.jsx)(`div`,{className:be(J,!0),children:xe(C)}),(0,a.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:T?d.loading:C?.tenantName||d.loading}),(0,a.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:Se(C,d.owner,d.member)})]}),(0,a.jsx)(r.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,a.jsx)(`div`,{className:`flex-1`,children:s}),(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,a.jsx)(Z,{}),(0,a.jsx)(X,{})]}),(0,a.jsx)(n.Dropdown,{droplist:W,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&A().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})},children:(0,a.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,a.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,a.jsx)($,{user:y,size:36}),(0,a.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,a.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,a.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:y?.nickname||y?.username})}),(0,a.jsx)(r.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,a.jsx)(me,{visible:f,user:y,labels:d,onCancel:()=>p(!1),onSubmit:I}),(0,a.jsx)(ge,{visible:m,user:y,points:F,text:d,onCancel:()=>h(!1),onPay:V}),(0,a.jsx)(ce,{visible:g,points:F,text:d,onCancel:()=>_(!1),onRecharge:()=>h(!0)})]})}var we=h(p(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function Te(e,t=`datetime`,n){if(!e)return`-`;let r=(n?G(n):K()).startsWith(`en`),i=t===`date`?r?`MM/DD/YYYY`:`YYYY-MM-DD`:r?`MM/DD/YYYY HH:mm:ss`:`YYYY-MM-DD HH:mm:ss`;return(0,we.default)(e).format(i)}e.LANGUAGE_SOURCE_STORAGE_KEY=Y,e.LANGUAGE_STORAGE_KEY=J,e.LangSwitch=X,e.MANTUR_LANGUAGE_CHANGE_EVENT=U,e.MANTUR_LANGUAGE_SOURCE_STORAGE_KEY=H,e.MANTUR_LANGUAGE_STORAGE_KEY=V,e.MANTUR_MESSAGES=W,e.MANTUR_POINTS_REFRESH_EVENT=v,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=y,e.ManturHeader=Ce,e.ThemeSwitch=Z,e.formatDateByLang=Te,e.getManturCurrentTenant=F,e.getManturMessages=q,e.getManturTenantContextSnapshot=N,e.getManturTenants=P,e.getManturUserPoints=k,e.getStoredManturLocale=K,e.normalizeManturLocale=G,e.refreshManturTenantContext=ee,e.refreshManturUserPoints=A,e.switchAndRefreshManturTenant=te,e.switchManturTenant=I});
package/dist/types.d.ts CHANGED
@@ -103,6 +103,7 @@ export interface ManturHeaderProps {
103
103
  disabled?: boolean;
104
104
  brandSlot?: ReactNode;
105
105
  children?: ReactNode;
106
+ onTenantContextChange?: (detail: ManturTenantContextDetail) => void;
106
107
  }
107
108
  export interface ProfileModalProps {
108
109
  visible: boolean;
@@ -0,0 +1,6 @@
1
+ export type ManturDateFormatType = "date" | "datetime";
2
+ export type ManturDateInput = string | number | Date | null | undefined;
3
+ /**
4
+ * 根据指定语言格式化日期;未传语言时读取组件库当前语言。
5
+ */
6
+ export declare function formatDateByLang(date: ManturDateInput, formatType?: ManturDateFormatType, language?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mantur-components",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Reusable Mantur React component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/mantur-components.umd.cjs",
@@ -36,5 +36,8 @@
36
36
  "react-i18next": "^16.6.5",
37
37
  "typescript": "~5.9.3",
38
38
  "vite": "^8.0.1"
39
+ },
40
+ "dependencies": {
41
+ "dayjs": "^1.11.20"
39
42
  }
40
43
  }