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