@quantabit/account-type-sdk 1.0.0

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.
@@ -0,0 +1,882 @@
1
+ 'use client';
2
+ import { BaseApiClient } from '@quantabit/sdk-config';
3
+ import React, { useState, useCallback, useEffect } from 'react';
4
+
5
+ /**
6
+ * Account Type SDK - 类型定义
7
+ */
8
+
9
+ // 账号类型
10
+ const AccountType = {
11
+ PERSONAL: 'personal',
12
+ // 个人账号
13
+ CREATOR: 'creator',
14
+ // 创作者账号
15
+ BUSINESS: 'business',
16
+ // 企业账号
17
+ INSTITUTION: 'institution',
18
+ // 机构账号
19
+ DEVELOPER: 'developer' // 开发者账号
20
+ };
21
+
22
+ // 认证级别
23
+ const VerificationLevel = {
24
+ NONE: 'none',
25
+ BASIC: 'basic',
26
+ VERIFIED: 'verified',
27
+ OFFICIAL: 'official'
28
+ };
29
+
30
+ // 认证标识颜色
31
+ const VerificationBadge$1 = {
32
+ BLUE: 'blue',
33
+ // 蓝V - 个人认证
34
+ YELLOW: 'yellow',
35
+ // 黄V - 企业认证
36
+ RED: 'red',
37
+ // 红V - 官方认证
38
+ PURPLE: 'purple' // 紫V - 机构认证
39
+ };
40
+
41
+ // 申请状态
42
+ const ApplicationStatus = {
43
+ PENDING: 'pending',
44
+ REVIEWING: 'reviewing',
45
+ APPROVED: 'approved',
46
+ REJECTED: 'rejected',
47
+ NEED_INFO: 'need_info'
48
+ };
49
+
50
+ /**
51
+ * 账号类型配置
52
+ */
53
+ const ACCOUNT_TYPE_CONFIG = {
54
+ [AccountType.PERSONAL]: {
55
+ name: '个人账号',
56
+ icon: '👤',
57
+ badge: null,
58
+ features: ['基础功能', '社交互动', '内容发布'],
59
+ limits: {
60
+ dailyPosts: 10,
61
+ followers: 5000
62
+ }
63
+ },
64
+ [AccountType.CREATOR]: {
65
+ name: '创作者账号',
66
+ icon: '✨',
67
+ badge: VerificationBadge$1.BLUE,
68
+ features: ['数据分析', '粉丝运营', '收益提现', '专属标识'],
69
+ limits: {
70
+ dailyPosts: 50,
71
+ followers: null
72
+ },
73
+ requirements: {
74
+ followers: 1000,
75
+ posts: 10
76
+ }
77
+ },
78
+ [AccountType.BUSINESS]: {
79
+ name: '企业账号',
80
+ icon: '🏢',
81
+ badge: VerificationBadge$1.YELLOW,
82
+ features: ['企业主页', '客户管理', '数据面板', '优先客服'],
83
+ limits: {
84
+ dailyPosts: 100,
85
+ followers: null
86
+ },
87
+ requirements: {
88
+ businessLicense: true
89
+ }
90
+ },
91
+ [AccountType.INSTITUTION]: {
92
+ name: '机构账号',
93
+ icon: '🏛️',
94
+ badge: VerificationBadge$1.PURPLE,
95
+ features: ['多账号管理', '团队协作', 'API接入', '专属客服'],
96
+ limits: {
97
+ dailyPosts: 200,
98
+ subAccounts: 50
99
+ },
100
+ requirements: {
101
+ institutionLicense: true
102
+ }
103
+ },
104
+ [AccountType.DEVELOPER]: {
105
+ name: '开发者账号',
106
+ icon: '👨‍💻',
107
+ badge: null,
108
+ features: ['API访问', '开发文档', '沙箱环境', '技术支持'],
109
+ limits: {
110
+ apiCalls: 10000
111
+ },
112
+ requirements: {
113
+ email: true
114
+ }
115
+ }
116
+ };
117
+
118
+ /**
119
+ * 获取账号类型信息
120
+ */
121
+ function getAccountTypeInfo(type) {
122
+ return ACCOUNT_TYPE_CONFIG[type] || ACCOUNT_TYPE_CONFIG[AccountType.PERSONAL];
123
+ }
124
+
125
+ /**
126
+ * 获取认证图标
127
+ */
128
+ function getVerificationBadgeIcon(badge) {
129
+ const icons = {
130
+ [VerificationBadge$1.BLUE]: '✓',
131
+ [VerificationBadge$1.YELLOW]: '✓',
132
+ [VerificationBadge$1.RED]: '★',
133
+ [VerificationBadge$1.PURPLE]: '✓'
134
+ };
135
+ return icons[badge] || '';
136
+ }
137
+
138
+ /**
139
+ * 获取认证颜色
140
+ */
141
+ function getVerificationColor(badge) {
142
+ const colors = {
143
+ [VerificationBadge$1.BLUE]: '#3b82f6',
144
+ [VerificationBadge$1.YELLOW]: '#f59e0b',
145
+ [VerificationBadge$1.RED]: '#ef4444',
146
+ [VerificationBadge$1.PURPLE]: '#8b5cf6'
147
+ };
148
+ return colors[badge] || '#6b7280';
149
+ }
150
+
151
+ /**
152
+ * 检查升级条件
153
+ */
154
+ function checkUpgradeEligibility(currentType, targetType, userStats) {
155
+ const config = ACCOUNT_TYPE_CONFIG[targetType];
156
+ if (!config?.requirements) return {
157
+ eligible: true,
158
+ missing: []
159
+ };
160
+ const missing = [];
161
+ const {
162
+ requirements
163
+ } = config;
164
+ if (requirements.followers && userStats.followers < requirements.followers) {
165
+ missing.push(`粉丝数需达到 ${requirements.followers}`);
166
+ }
167
+ if (requirements.posts && userStats.posts < requirements.posts) {
168
+ missing.push(`发布内容需达到 ${requirements.posts} 条`);
169
+ }
170
+ if (requirements.businessLicense && !userStats.hasBusinessLicense) {
171
+ missing.push('需要营业执照');
172
+ }
173
+ return {
174
+ eligible: missing.length === 0,
175
+ missing
176
+ };
177
+ }
178
+
179
+ /**
180
+ * Account Type SDK - API 客户端
181
+ * 账号类型管理系统后端接口封装
182
+ *
183
+ * 使用 BaseApiClient 基类简化代码
184
+ */
185
+
186
+
187
+ /**
188
+ * 账号类型 API 客户端
189
+ */
190
+ class AccountTypeApiClient extends BaseApiClient {
191
+ constructor(config = {}) {
192
+ super('/account-type', config);
193
+ }
194
+
195
+ // ============ 账号类型查询 ============
196
+
197
+ /**
198
+ * 获取当前账号类型
199
+ */
200
+ async getMyAccountType() {
201
+ return this.get('/me');
202
+ }
203
+
204
+ /**
205
+ * 获取可用账号类型列表
206
+ */
207
+ async getAvailableTypes() {
208
+ return this.get('/types');
209
+ }
210
+
211
+ /**
212
+ * 获取类型详情
213
+ * @param {string} type - 类型标识
214
+ */
215
+ async getTypeDetails(type) {
216
+ return this.get(`/types/${type}`);
217
+ }
218
+
219
+ /**
220
+ * 获取权益对比
221
+ * @param {string} type1 - 类型1
222
+ * @param {string} type2 - 类型2
223
+ */
224
+ async compareBenefits(type1, type2) {
225
+ return this.get('/compare', {
226
+ type1,
227
+ type2
228
+ });
229
+ }
230
+
231
+ // ============ 升级申请 ============
232
+
233
+ /**
234
+ * 检查升级资格
235
+ * @param {string} targetType - 目标类型
236
+ */
237
+ async checkEligibility(targetType) {
238
+ return this.get('/upgrade/check', {
239
+ type: targetType
240
+ });
241
+ }
242
+
243
+ /**
244
+ * 申请升级
245
+ * @param {string} targetType - 目标类型
246
+ * @param {Object} documents - 证明材料
247
+ */
248
+ async applyUpgrade(targetType, documents = {}) {
249
+ return this.post('/upgrade/apply', {
250
+ targetType,
251
+ documents
252
+ });
253
+ }
254
+
255
+ /**
256
+ * 获取申请状态
257
+ */
258
+ async getApplicationStatus() {
259
+ return this.get('/upgrade/status');
260
+ }
261
+
262
+ /**
263
+ * 取消申请
264
+ * @param {string} applicationId - 申请 ID
265
+ */
266
+ async cancelApplication(applicationId) {
267
+ return this.post(`/upgrade/${applicationId}/cancel`);
268
+ }
269
+
270
+ /**
271
+ * 补充材料
272
+ * @param {string} applicationId - 申请 ID
273
+ * @param {Object} documents - 补充材料
274
+ */
275
+ async submitAdditionalDocs(applicationId, documents) {
276
+ return this.post(`/upgrade/${applicationId}/documents`, {
277
+ documents
278
+ });
279
+ }
280
+
281
+ /**
282
+ * 获取升级历史
283
+ */
284
+ async getUpgradeHistory() {
285
+ return this.get('/upgrade/history');
286
+ }
287
+
288
+ // ============ 认证申请 ============
289
+
290
+ /**
291
+ * 申请企业认证
292
+ * @param {Object} data - 企业信息
293
+ */
294
+ async applyBusinessVerification(data) {
295
+ return this.post('/verification/business', data);
296
+ }
297
+
298
+ /**
299
+ * 申请创作者认证
300
+ * @param {Object} data - 创作者信息
301
+ */
302
+ async applyCreatorVerification(data) {
303
+ return this.post('/verification/creator', data);
304
+ }
305
+
306
+ /**
307
+ * 申请机构认证
308
+ * @param {Object} data - 机构信息
309
+ */
310
+ async applyOrganizationVerification(data) {
311
+ return this.post('/verification/organization', data);
312
+ }
313
+
314
+ /**
315
+ * 获取认证状态
316
+ * @param {string} type - 认证类型
317
+ */
318
+ async getVerificationStatus(type) {
319
+ return this.get(`/verification/${type}/status`);
320
+ }
321
+ }
322
+
323
+ // 创建默认实例
324
+ const accountTypeApi = new AccountTypeApiClient();
325
+
326
+ /**
327
+ * Account Type SDK - 国际化支持
328
+ */
329
+
330
+ const messages = {
331
+ en: {
332
+ accountType: 'Account Type',
333
+ personal: 'Personal',
334
+ creator: 'Creator',
335
+ business: 'Business',
336
+ institution: 'Institution',
337
+ developer: 'Developer',
338
+ currentType: 'Current Type',
339
+ upgrade: 'Upgrade',
340
+ downgrade: 'Downgrade',
341
+ apply: 'Apply',
342
+ cancel: 'Cancel',
343
+ verified: 'Verified',
344
+ unverified: 'Unverified',
345
+ features: 'Features',
346
+ benefits: 'Benefits',
347
+ requirements: 'Requirements',
348
+ applicationPending: 'Application Pending',
349
+ applicationApproved: 'Approved',
350
+ applicationRejected: 'Rejected',
351
+ needMoreInfo: 'Need More Info',
352
+ followers: 'Followers',
353
+ posts: 'Posts',
354
+ businessLicense: 'Business License',
355
+ upgradeSuccess: 'Upgrade Successful!',
356
+ applicationSubmitted: 'Application Submitted'
357
+ },
358
+ zh: {
359
+ accountType: '账号类型',
360
+ personal: '个人账号',
361
+ creator: '创作者',
362
+ business: '企业账号',
363
+ institution: '机构账号',
364
+ developer: '开发者',
365
+ currentType: '当前类型',
366
+ upgrade: '升级',
367
+ downgrade: '降级',
368
+ apply: '申请',
369
+ cancel: '取消',
370
+ verified: '已认证',
371
+ unverified: '未认证',
372
+ features: '功能特权',
373
+ benefits: '权益',
374
+ requirements: '申请条件',
375
+ applicationPending: '申请审核中',
376
+ applicationApproved: '已通过',
377
+ applicationRejected: '已拒绝',
378
+ needMoreInfo: '需要补充材料',
379
+ followers: '粉丝数',
380
+ posts: '发布内容',
381
+ businessLicense: '营业执照',
382
+ upgradeSuccess: '升级成功!',
383
+ applicationSubmitted: '申请已提交'
384
+ },
385
+ ja: {
386
+ accountType: 'アカウントタイプ',
387
+ personal: '個人',
388
+ creator: 'クリエイター',
389
+ business: 'ビジネス',
390
+ institution: '機関',
391
+ developer: '開発者',
392
+ currentType: '現在のタイプ',
393
+ upgrade: 'アップグレード',
394
+ downgrade: 'ダウングレード',
395
+ apply: '申請',
396
+ cancel: 'キャンセル',
397
+ verified: '認証済み',
398
+ unverified: '未認証',
399
+ features: '機能',
400
+ benefits: '特典',
401
+ requirements: '申請条件',
402
+ applicationPending: '審査中',
403
+ applicationApproved: '承認済み',
404
+ applicationRejected: '却下',
405
+ needMoreInfo: '追加情報が必要',
406
+ followers: 'フォロワー',
407
+ posts: '投稿',
408
+ businessLicense: '事業許可証',
409
+ upgradeSuccess: 'アップグレード成功!',
410
+ applicationSubmitted: '申請完了'
411
+ },
412
+ ko: {
413
+ accountType: '계정 유형',
414
+ personal: '개인',
415
+ creator: '크리에이터',
416
+ business: '비즈니스',
417
+ institution: '기관',
418
+ developer: '개발자',
419
+ currentType: '현재 유형',
420
+ upgrade: '업그레이드',
421
+ downgrade: '다운그레이드',
422
+ apply: '신청',
423
+ cancel: '취소',
424
+ verified: '인증됨',
425
+ unverified: '미인증',
426
+ features: '기능',
427
+ benefits: '혜택',
428
+ requirements: '신청 조건',
429
+ applicationPending: '심사 중',
430
+ applicationApproved: '승인됨',
431
+ applicationRejected: '거절됨',
432
+ needMoreInfo: '추가 정보 필요',
433
+ followers: '팔로워',
434
+ posts: '게시물',
435
+ businessLicense: '사업자등록증',
436
+ upgradeSuccess: '업그레이드 성공!',
437
+ applicationSubmitted: '신청 완료'
438
+ }
439
+ };
440
+ const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
441
+ let currentLanguage = 'zh';
442
+ function setLanguage(lang) {
443
+ if (SUPPORTED_LANGUAGES.includes(lang)) {
444
+ currentLanguage = lang;
445
+ }
446
+ }
447
+ function getLanguage() {
448
+ return currentLanguage;
449
+ }
450
+ function t(key, params = {}) {
451
+ let text = messages[currentLanguage]?.[key] || messages.en[key] || key;
452
+ Object.keys(params).forEach(param => {
453
+ text = text.replace(`{${param}}`, params[param]);
454
+ });
455
+ return text;
456
+ }
457
+
458
+ /**
459
+ * Account Type SDK - React Hooks
460
+ */
461
+
462
+
463
+ // 获取当前账号类型
464
+ function useAccountType() {
465
+ const [accountType, setAccountType] = useState(null);
466
+ const [loading, setLoading] = useState(true);
467
+ const [error, setError] = useState(null);
468
+ const refresh = useCallback(async () => {
469
+ try {
470
+ setLoading(true);
471
+ const data = await accountTypeApi.getMyAccountType();
472
+ setAccountType(data);
473
+ setError(null);
474
+ } catch (err) {
475
+ setError(err.message);
476
+ } finally {
477
+ setLoading(false);
478
+ }
479
+ }, []);
480
+ useEffect(() => {
481
+ refresh();
482
+ }, [refresh]);
483
+ return {
484
+ accountType,
485
+ loading,
486
+ error,
487
+ refresh
488
+ };
489
+ }
490
+
491
+ // 获取可用类型
492
+ function useAvailableTypes() {
493
+ const [types, setTypes] = useState([]);
494
+ const [loading, setLoading] = useState(true);
495
+ const [error, setError] = useState(null);
496
+ useEffect(() => {
497
+ accountTypeApi.getAvailableTypes().then(setTypes).catch(err => setError(err.message)).finally(() => setLoading(false));
498
+ }, []);
499
+ return {
500
+ types,
501
+ loading,
502
+ error
503
+ };
504
+ }
505
+
506
+ // 升级申请
507
+ function useUpgradeApplication() {
508
+ const [status, setStatus] = useState(null);
509
+ const [loading, setLoading] = useState(false);
510
+ const [error, setError] = useState(null);
511
+ const fetchStatus = useCallback(async () => {
512
+ try {
513
+ const data = await accountTypeApi.getApplicationStatus();
514
+ setStatus(data);
515
+ } catch (err) {
516
+ // 可能没有申请记录
517
+ setStatus(null);
518
+ }
519
+ }, []);
520
+ const apply = useCallback(async (targetType, documents = {}) => {
521
+ try {
522
+ setLoading(true);
523
+ setError(null);
524
+ const result = await accountTypeApi.applyUpgrade(targetType, documents);
525
+ await fetchStatus();
526
+ return result;
527
+ } catch (err) {
528
+ setError(err.message);
529
+ throw err;
530
+ } finally {
531
+ setLoading(false);
532
+ }
533
+ }, [fetchStatus]);
534
+ const cancel = useCallback(async applicationId => {
535
+ try {
536
+ setLoading(true);
537
+ await accountTypeApi.cancelApplication(applicationId);
538
+ await fetchStatus();
539
+ } catch (err) {
540
+ setError(err.message);
541
+ throw err;
542
+ } finally {
543
+ setLoading(false);
544
+ }
545
+ }, [fetchStatus]);
546
+ const submitDocs = useCallback(async (applicationId, documents) => {
547
+ try {
548
+ setLoading(true);
549
+ await accountTypeApi.submitAdditionalDocs(applicationId, documents);
550
+ await fetchStatus();
551
+ } catch (err) {
552
+ setError(err.message);
553
+ throw err;
554
+ } finally {
555
+ setLoading(false);
556
+ }
557
+ }, [fetchStatus]);
558
+ useEffect(() => {
559
+ fetchStatus();
560
+ }, [fetchStatus]);
561
+ return {
562
+ status,
563
+ apply,
564
+ cancel,
565
+ submitDocs,
566
+ loading,
567
+ error,
568
+ refresh: fetchStatus
569
+ };
570
+ }
571
+
572
+ // 资格检查
573
+ function useEligibilityCheck(targetType) {
574
+ const [eligibility, setEligibility] = useState(null);
575
+ const [loading, setLoading] = useState(true);
576
+ const [error, setError] = useState(null);
577
+ useEffect(() => {
578
+ if (!targetType) return;
579
+ accountTypeApi.checkEligibility(targetType).then(setEligibility).catch(err => setError(err.message)).finally(() => setLoading(false));
580
+ }, [targetType]);
581
+ return {
582
+ eligibility,
583
+ loading,
584
+ error
585
+ };
586
+ }
587
+
588
+ // 权益对比
589
+ function useBenefitsComparison(type1, type2) {
590
+ const [comparison, setComparison] = useState(null);
591
+ const [loading, setLoading] = useState(true);
592
+ const [error, setError] = useState(null);
593
+ useEffect(() => {
594
+ if (!type1 || !type2) return;
595
+ accountTypeApi.compareBenefits(type1, type2).then(setComparison).catch(err => setError(err.message)).finally(() => setLoading(false));
596
+ }, [type1, type2]);
597
+ return {
598
+ comparison,
599
+ loading,
600
+ error
601
+ };
602
+ }
603
+
604
+ /**
605
+ * 认证徽章
606
+ */
607
+ function VerificationBadge({
608
+ badge,
609
+ size = 'medium'
610
+ }) {
611
+ if (!badge) return null;
612
+ const color = getVerificationColor(badge);
613
+ const icon = getVerificationBadgeIcon(badge);
614
+ const sizeClass = {
615
+ small: 'badge-sm',
616
+ medium: 'badge-md',
617
+ large: 'badge-lg'
618
+ };
619
+ return /*#__PURE__*/React.createElement("span", {
620
+ className: `account-badge ${sizeClass[size]}`,
621
+ style: {
622
+ backgroundColor: color
623
+ }
624
+ }, icon);
625
+ }
626
+
627
+ /**
628
+ * 账号类型卡片
629
+ */
630
+ function AccountTypeCard({
631
+ type,
632
+ isCurrent = false,
633
+ isSelected = false,
634
+ onSelect,
635
+ disabled = false
636
+ }) {
637
+ const info = getAccountTypeInfo(type);
638
+ return /*#__PURE__*/React.createElement("div", {
639
+ className: `account-type-card ${isCurrent ? 'current' : ''} ${isSelected ? 'selected' : ''} ${disabled ? 'disabled' : ''}`,
640
+ onClick: () => !disabled && onSelect?.(type)
641
+ }, isCurrent && /*#__PURE__*/React.createElement("span", {
642
+ className: "account-current-tag"
643
+ }, "\u5F53\u524D"), /*#__PURE__*/React.createElement("div", {
644
+ className: "account-type-icon"
645
+ }, info.icon), /*#__PURE__*/React.createElement("div", {
646
+ className: "account-type-name"
647
+ }, info.name, info.badge && /*#__PURE__*/React.createElement(VerificationBadge, {
648
+ badge: info.badge,
649
+ size: "small"
650
+ })), /*#__PURE__*/React.createElement("ul", {
651
+ className: "account-type-features"
652
+ }, info.features.map((feature, i) => /*#__PURE__*/React.createElement("li", {
653
+ key: i
654
+ }, "\u2713 ", feature))), info.requirements && /*#__PURE__*/React.createElement("div", {
655
+ className: "account-type-requirements"
656
+ }, "\u9700\u8981\u6EE1\u8DB3\u6761\u4EF6"));
657
+ }
658
+
659
+ /**
660
+ * 类型选择器
661
+ */
662
+ function AccountTypeSelector({
663
+ currentType,
664
+ selectedType,
665
+ onSelect,
666
+ types = Object.values(AccountType)
667
+ }) {
668
+ return /*#__PURE__*/React.createElement("div", {
669
+ className: "account-type-selector"
670
+ }, types.map(type => /*#__PURE__*/React.createElement(AccountTypeCard, {
671
+ key: type,
672
+ type: type,
673
+ isCurrent: type === currentType,
674
+ isSelected: type === selectedType,
675
+ onSelect: onSelect
676
+ })));
677
+ }
678
+
679
+ /**
680
+ * 申请状态卡片
681
+ */
682
+ function ApplicationStatusCard({
683
+ application,
684
+ onCancel,
685
+ onSubmitDocs
686
+ }) {
687
+ if (!application) return null;
688
+ const statusConfig = {
689
+ [ApplicationStatus.PENDING]: {
690
+ label: '待审核',
691
+ color: '#f59e0b',
692
+ icon: '⏳'
693
+ },
694
+ [ApplicationStatus.REVIEWING]: {
695
+ label: '审核中',
696
+ color: '#3b82f6',
697
+ icon: '🔍'
698
+ },
699
+ [ApplicationStatus.APPROVED]: {
700
+ label: '已通过',
701
+ color: '#22c55e',
702
+ icon: '✅'
703
+ },
704
+ [ApplicationStatus.REJECTED]: {
705
+ label: '已拒绝',
706
+ color: '#ef4444',
707
+ icon: '❌'
708
+ },
709
+ [ApplicationStatus.NEED_INFO]: {
710
+ label: '需补充材料',
711
+ color: '#f97316',
712
+ icon: '📝'
713
+ }
714
+ };
715
+ const config = statusConfig[application.status] || statusConfig[ApplicationStatus.PENDING];
716
+ const targetInfo = getAccountTypeInfo(application.targetType);
717
+ return /*#__PURE__*/React.createElement("div", {
718
+ className: "account-application-card"
719
+ }, /*#__PURE__*/React.createElement("div", {
720
+ className: "account-application-header"
721
+ }, /*#__PURE__*/React.createElement("span", {
722
+ className: "account-application-target"
723
+ }, targetInfo.icon, " \u5347\u7EA7\u81F3 ", targetInfo.name), /*#__PURE__*/React.createElement("span", {
724
+ className: "account-application-status",
725
+ style: {
726
+ backgroundColor: config.color
727
+ }
728
+ }, config.icon, " ", config.label)), /*#__PURE__*/React.createElement("div", {
729
+ className: "account-application-info"
730
+ }, /*#__PURE__*/React.createElement("div", null, "\u7533\u8BF7\u65F6\u95F4: ", new Date(application.createdAt).toLocaleDateString()), application.message && /*#__PURE__*/React.createElement("div", null, "\u5907\u6CE8: ", application.message)), application.status === ApplicationStatus.NEED_INFO && /*#__PURE__*/React.createElement("button", {
731
+ className: "account-btn primary",
732
+ onClick: () => onSubmitDocs?.(application.id)
733
+ }, "\u8865\u5145\u6750\u6599"), [ApplicationStatus.PENDING, ApplicationStatus.REVIEWING].includes(application.status) && /*#__PURE__*/React.createElement("button", {
734
+ className: "account-btn secondary",
735
+ onClick: () => onCancel?.(application.id)
736
+ }, "\u53D6\u6D88\u7533\u8BF7"));
737
+ }
738
+
739
+ /**
740
+ * 权益对比表
741
+ */
742
+ function BenefitsComparison({
743
+ currentType,
744
+ targetType
745
+ }) {
746
+ const currentInfo = getAccountTypeInfo(currentType);
747
+ const targetInfo = getAccountTypeInfo(targetType);
748
+ return /*#__PURE__*/React.createElement("div", {
749
+ className: "account-comparison"
750
+ }, /*#__PURE__*/React.createElement("div", {
751
+ className: "account-comparison-header"
752
+ }, /*#__PURE__*/React.createElement("div", {
753
+ className: "account-comparison-col"
754
+ }, /*#__PURE__*/React.createElement("span", {
755
+ className: "account-comparison-type current"
756
+ }, currentInfo.icon, " ", currentInfo.name)), /*#__PURE__*/React.createElement("div", {
757
+ className: "account-comparison-arrow"
758
+ }, "\u2192"), /*#__PURE__*/React.createElement("div", {
759
+ className: "account-comparison-col"
760
+ }, /*#__PURE__*/React.createElement("span", {
761
+ className: "account-comparison-type target"
762
+ }, targetInfo.icon, " ", targetInfo.name))), /*#__PURE__*/React.createElement("div", {
763
+ className: "account-comparison-body"
764
+ }, /*#__PURE__*/React.createElement("div", {
765
+ className: "account-comparison-section"
766
+ }, /*#__PURE__*/React.createElement("h4", null, "\u65B0\u589E\u6743\u76CA"), targetInfo.features.filter(f => !currentInfo.features.includes(f)).map((feature, i) => /*#__PURE__*/React.createElement("div", {
767
+ key: i,
768
+ className: "account-comparison-item new"
769
+ }, "\u2728 ", feature)))));
770
+ }
771
+
772
+ /**
773
+ * 升级表单
774
+ */
775
+ function UpgradeForm({
776
+ targetType,
777
+ onSubmit,
778
+ loading = false
779
+ }) {
780
+ const [documents, setDocuments] = useState({});
781
+ const info = getAccountTypeInfo(targetType);
782
+ const handleSubmit = e => {
783
+ e.preventDefault();
784
+ onSubmit?.(documents);
785
+ };
786
+ return /*#__PURE__*/React.createElement("form", {
787
+ className: "account-upgrade-form",
788
+ onSubmit: handleSubmit
789
+ }, /*#__PURE__*/React.createElement("h3", null, "\u7533\u8BF7\u5347\u7EA7\u81F3 ", info.name), targetType === AccountType.BUSINESS && /*#__PURE__*/React.createElement("div", {
790
+ className: "account-form-group"
791
+ }, /*#__PURE__*/React.createElement("label", null, "\u8425\u4E1A\u6267\u7167"), /*#__PURE__*/React.createElement("input", {
792
+ type: "file",
793
+ accept: "image/*,.pdf",
794
+ onChange: e => setDocuments({
795
+ ...documents,
796
+ businessLicense: e.target.files[0]
797
+ })
798
+ })), targetType === AccountType.CREATOR && /*#__PURE__*/React.createElement("div", {
799
+ className: "account-form-group"
800
+ }, /*#__PURE__*/React.createElement("label", null, "\u521B\u4F5C\u9886\u57DF"), /*#__PURE__*/React.createElement("select", {
801
+ value: documents.category || '',
802
+ onChange: e => setDocuments({
803
+ ...documents,
804
+ category: e.target.value
805
+ })
806
+ }, /*#__PURE__*/React.createElement("option", {
807
+ value: ""
808
+ }, "\u8BF7\u9009\u62E9"), /*#__PURE__*/React.createElement("option", {
809
+ value: "tech"
810
+ }, "\u79D1\u6280"), /*#__PURE__*/React.createElement("option", {
811
+ value: "lifestyle"
812
+ }, "\u751F\u6D3B"), /*#__PURE__*/React.createElement("option", {
813
+ value: "entertainment"
814
+ }, "\u5A31\u4E50"), /*#__PURE__*/React.createElement("option", {
815
+ value: "education"
816
+ }, "\u6559\u80B2"))), /*#__PURE__*/React.createElement("div", {
817
+ className: "account-form-group"
818
+ }, /*#__PURE__*/React.createElement("label", null, "\u7533\u8BF7\u8BF4\u660E\uFF08\u9009\u586B\uFF09"), /*#__PURE__*/React.createElement("textarea", {
819
+ placeholder: "\u8BF7\u7B80\u8981\u8BF4\u660E\u60A8\u7684\u7533\u8BF7\u7406\u7531",
820
+ value: documents.description || '',
821
+ onChange: e => setDocuments({
822
+ ...documents,
823
+ description: e.target.value
824
+ })
825
+ })), /*#__PURE__*/React.createElement("button", {
826
+ type: "submit",
827
+ className: "account-btn primary large",
828
+ disabled: loading
829
+ }, loading ? '提交中...' : '提交申请'));
830
+ }
831
+
832
+ /**
833
+ * 账号类型页面
834
+ */
835
+ function AccountTypePage({
836
+ currentType,
837
+ application,
838
+ onApply,
839
+ onCancelApplication,
840
+ loading = false
841
+ }) {
842
+ const [selectedType, setSelectedType] = useState(null);
843
+ const [showForm, setShowForm] = useState(false);
844
+ const handleSelect = type => {
845
+ if (type !== currentType) {
846
+ setSelectedType(type);
847
+ }
848
+ };
849
+ const handleApply = documents => {
850
+ onApply?.(selectedType, documents);
851
+ setShowForm(false);
852
+ };
853
+ return /*#__PURE__*/React.createElement("div", {
854
+ className: "account-type-page"
855
+ }, /*#__PURE__*/React.createElement("h1", null, "\u8D26\u53F7\u7C7B\u578B"), application && /*#__PURE__*/React.createElement(ApplicationStatusCard, {
856
+ application: application,
857
+ onCancel: onCancelApplication
858
+ }), /*#__PURE__*/React.createElement("section", null, /*#__PURE__*/React.createElement("h2", null, "\u9009\u62E9\u8D26\u53F7\u7C7B\u578B"), /*#__PURE__*/React.createElement(AccountTypeSelector, {
859
+ currentType: currentType,
860
+ selectedType: selectedType,
861
+ onSelect: handleSelect
862
+ })), selectedType && selectedType !== currentType && /*#__PURE__*/React.createElement("section", null, /*#__PURE__*/React.createElement(BenefitsComparison, {
863
+ currentType: currentType,
864
+ targetType: selectedType
865
+ }), /*#__PURE__*/React.createElement("button", {
866
+ className: "account-btn primary large",
867
+ onClick: () => setShowForm(true)
868
+ }, "\u7533\u8BF7\u5347\u7EA7")), showForm && /*#__PURE__*/React.createElement("div", {
869
+ className: "account-modal-overlay",
870
+ onClick: () => setShowForm(false)
871
+ }, /*#__PURE__*/React.createElement("div", {
872
+ className: "account-modal",
873
+ onClick: e => e.stopPropagation()
874
+ }, /*#__PURE__*/React.createElement(UpgradeForm, {
875
+ targetType: selectedType,
876
+ onSubmit: handleApply,
877
+ loading: loading
878
+ }))));
879
+ }
880
+
881
+ export { ACCOUNT_TYPE_CONFIG, AccountType, AccountTypeApiClient, AccountTypeCard, AccountTypePage, AccountTypeSelector, ApplicationStatus, ApplicationStatusCard, BenefitsComparison, SUPPORTED_LANGUAGES, UpgradeForm, VerificationBadge$1 as VerificationBadge, VerificationBadge as VerificationBadgeComponent, VerificationLevel, accountTypeApi, checkUpgradeEligibility, getAccountTypeInfo, getLanguage, getVerificationBadgeIcon, getVerificationColor, messages, setLanguage, t, useAccountType, useAvailableTypes, useBenefitsComparison, useEligibilityCheck, useUpgradeApplication };
882
+ //# sourceMappingURL=index.esm.js.map