seeder-st2110-components 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,1983 @@
1
+ import { useState, useCallback, useEffect, memo, useMemo, useRef } from 'react';
2
+ import { useWebSocket, useInterval } from 'ahooks';
3
+ import { Tooltip, Space, Flex, Divider, App, Modal, Form, Input, Alert, message, Dropdown, Spin } from 'antd';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import { LoadingOutlined, ExclamationCircleFilled } from '@ant-design/icons';
6
+ import axios from 'axios';
7
+
8
+ const useHardwareWebSocket = socketUrl => {
9
+ // cpu_percent cpu使用率
10
+ // cpu_freq.current cpu频率
11
+ // mem.percent 内存使用率
12
+ // sensors_temperatures.coretemp[0].current cpu温度
13
+ // gpu_stats[0]["utilization.gpu"] gpu使用率
14
+ // 若机器没有显卡,gpu_stats数组为空
15
+
16
+ const [systemStatus, setSystemStatus] = useState();
17
+
18
+ // ## 获取系统资源使用情况
19
+ const {
20
+ latestMessage
21
+ } = useWebSocket(socketUrl);
22
+ const handleMessage = useCallback(message => {
23
+ try {
24
+ if (message) {
25
+ setSystemStatus(prev => ({
26
+ ...prev,
27
+ ...message,
28
+ lastUpdated: Date.now() // 添加更新时间戳
29
+ }));
30
+ }
31
+ } catch (error) {
32
+ console.error('Message processing error:', error);
33
+ }
34
+ }, []);
35
+
36
+ // 监听消息 如果latestMessage变化,说明有新消息
37
+ useEffect(() => {
38
+ if (!latestMessage?.data) return;
39
+ try {
40
+ const parsedMessage = JSON.parse(latestMessage.data);
41
+ handleMessage(parsedMessage);
42
+ } catch (error) {
43
+ console.error('Message parsing error:', error);
44
+ console.debug('Raw message:', latestMessage.data);
45
+ }
46
+ }, [latestMessage?.data, handleMessage]);
47
+ return {
48
+ ps_status: systemStatus
49
+ };
50
+ };
51
+
52
+ const UsageItem = /*#__PURE__*/memo(_ref => {
53
+ let {
54
+ iconClass,
55
+ text,
56
+ children,
57
+ ram
58
+ } = _ref;
59
+ const tooltipContent = useMemo(() => /*#__PURE__*/jsx(Tooltip, {
60
+ title: /*#__PURE__*/jsxs(Fragment, {
61
+ children: [/*#__PURE__*/jsx("div", {
62
+ children: text
63
+ }), ram && /*#__PURE__*/jsxs("div", {
64
+ children: ["Total Memory: ", ram, "GB"]
65
+ })]
66
+ }),
67
+ destroyOnHidden: false,
68
+ children: /*#__PURE__*/jsxs(Space, {
69
+ size: 4,
70
+ children: [/*#__PURE__*/jsx("i", {
71
+ className: `iconfont ${iconClass} text-xl`
72
+ }), /*#__PURE__*/jsx("span", {
73
+ className: "inline-block w-10 text-center",
74
+ children: children
75
+ })]
76
+ })
77
+ }), [text, iconClass, children]);
78
+ return /*#__PURE__*/jsxs(Flex, {
79
+ align: "center",
80
+ children: [tooltipContent, /*#__PURE__*/jsx(Divider, {
81
+ type: "vertical"
82
+ })]
83
+ });
84
+ });
85
+
86
+ const getTemperature = (supermicro, sensors) => {
87
+ return supermicro?.cpu_temperature ?? sensors?.temperatures?.coretemp?.[0]?.current;
88
+ };
89
+ const useHardwareUsage = ps_status => {
90
+ return useMemo(() => {
91
+ if (!ps_status || typeof ps_status !== 'object') return null;
92
+ const {
93
+ cpu_percent,
94
+ sensors_temperatures,
95
+ mem,
96
+ gpu_stats,
97
+ supermicro
98
+ } = ps_status;
99
+ return /*#__PURE__*/jsxs("div", {
100
+ className: "flex",
101
+ children: [/*#__PURE__*/jsxs(UsageItem, {
102
+ text: "CPU Usage",
103
+ iconClass: "icon-CPU",
104
+ children: [cpu_percent, "%"]
105
+ }), /*#__PURE__*/jsxs(UsageItem, {
106
+ text: "CPU Temperature",
107
+ iconClass: "icon-wendu",
108
+ children: [getTemperature(supermicro, sensors_temperatures), "\u2103"]
109
+ }), mem && /*#__PURE__*/jsxs(UsageItem, {
110
+ text: "Memory Usage",
111
+ iconClass: "icon-shiyongshuai",
112
+ ram: false,
113
+ children: [mem.percent, "%"]
114
+ }), supermicro?.nic_temperature && /*#__PURE__*/jsxs(UsageItem, {
115
+ text: "NIC Temperature",
116
+ iconClass: "icon-wuliwangka",
117
+ children: [supermicro.nic_temperature, "\u2103"]
118
+ }), gpu_stats?.length > 0 && /*#__PURE__*/jsx(UsageItem, {
119
+ text: "GPU Usage",
120
+ iconClass: "icon-gpufuwu",
121
+ children: gpu_stats[0]["utilization.gpu"]
122
+ }), supermicro?.gpu_temperature && /*#__PURE__*/jsxs(UsageItem, {
123
+ text: "GPU Temperature",
124
+ iconClass: "icon-wendu",
125
+ children: [supermicro.gpu_temperature, "\u2103"]
126
+ })]
127
+ });
128
+ }, [ps_status]);
129
+ };
130
+
131
+ const AuthorizationModal = _ref => {
132
+ let {
133
+ onCancel,
134
+ onOk,
135
+ authData,
136
+ title = 'Register License',
137
+ okText,
138
+ cancelText = 'Ignore',
139
+ width = 600
140
+ } = _ref;
141
+ const {
142
+ message
143
+ } = App.useApp();
144
+ const [code, setCode] = useState('');
145
+ const {
146
+ accredit_status: isActivated,
147
+ message: statusMessage = 'Unactivated',
148
+ bios_id: uuid,
149
+ expires_time: expiresTime
150
+ } = authData || {};
151
+ const handleOk = () => {
152
+ const trimmedCode = code.trim();
153
+ if (!trimmedCode) {
154
+ message.error('License key cannot be empty');
155
+ return;
156
+ }
157
+ onOk(trimmedCode);
158
+ };
159
+ const statusAlert = isActivated ? /*#__PURE__*/jsx(Alert, {
160
+ message: `${statusMessage}, will expire on ${expiresTime}`,
161
+ type: "success",
162
+ showIcon: true
163
+ }) : /*#__PURE__*/jsx(Alert, {
164
+ message: statusMessage,
165
+ type: "warning",
166
+ showIcon: true
167
+ });
168
+ const defaultOkText = isActivated ? "Reactivate" : "Activate Now";
169
+ return /*#__PURE__*/jsx(Modal, {
170
+ title: title,
171
+ open: true,
172
+ onCancel: onCancel,
173
+ onOk: handleOk,
174
+ okText: okText || defaultOkText,
175
+ cancelText: cancelText,
176
+ width: width,
177
+ maskClosable: false,
178
+ closable: false,
179
+ cancelButtonProps: {
180
+ disabled: !isActivated
181
+ },
182
+ children: /*#__PURE__*/jsxs(Form, {
183
+ name: "auth_form",
184
+ labelCol: {
185
+ span: 6
186
+ },
187
+ wrapperCol: {
188
+ span: 18
189
+ },
190
+ autoComplete: "off",
191
+ children: [/*#__PURE__*/jsx("div", {
192
+ style: {
193
+ marginBottom: 16
194
+ },
195
+ children: statusAlert
196
+ }), /*#__PURE__*/jsx(Form.Item, {
197
+ label: "Machine Code",
198
+ required: true,
199
+ children: /*#__PURE__*/jsx(Input, {
200
+ value: uuid,
201
+ readOnly: true
202
+ })
203
+ }), /*#__PURE__*/jsx(Form.Item, {
204
+ label: "License Key",
205
+ required: true,
206
+ children: /*#__PURE__*/jsx(Input.TextArea, {
207
+ value: code,
208
+ onChange: e => setCode(e.target.value),
209
+ autoSize: {
210
+ minRows: 6,
211
+ maxRows: 6
212
+ },
213
+ placeholder: "Enter your license key"
214
+ })
215
+ })]
216
+ })
217
+ });
218
+ };
219
+
220
+ const DEFAULT_AUTH = {
221
+ accredit_status: false,
222
+ // 授权状态
223
+ bios_id: '',
224
+ // 主机id
225
+ message: 'Unactivated',
226
+ // 激活信息
227
+ expires_time: '' // 授权到期时间
228
+ };
229
+ const useAuth = options => {
230
+ const {
231
+ fetchAuthInfo,
232
+ authorize,
233
+ defaultAuthData = DEFAULT_AUTH,
234
+ autoShowModal = true
235
+ } = options || {};
236
+ const [messageApi, contextHolder] = message.useMessage();
237
+ const [showModal, setShowModal] = useState(false); // 默认隐藏
238
+ const [authData, setAuthData] = useState(defaultAuthData);
239
+ const [isRegistered, setIsRegistered] = useState(false);
240
+ const [loading, setLoading] = useState(false);
241
+ const openModal = useCallback(() => setShowModal(true), []);
242
+ const closeModal = useCallback(() => setShowModal(false), []);
243
+ useEffect(() => {
244
+ async function loadAuthInfo() {
245
+ try {
246
+ setLoading(true);
247
+ const result = await fetchAuthInfo();
248
+ if (result?.commands) {
249
+ const commands = result.commands;
250
+ setAuthData(commands);
251
+ setIsRegistered(commands.accredit_status);
252
+ if (autoShowModal) {
253
+ commands.accredit_status ? closeModal() : openModal();
254
+ }
255
+ }
256
+ } catch (error) {
257
+ console.error('Failed to fetch auth info:', error);
258
+ } finally {
259
+ setLoading(false);
260
+ }
261
+ }
262
+ loadAuthInfo();
263
+ }, [fetchAuthInfo, autoShowModal, openModal, closeModal]);
264
+ const auth = async code => {
265
+ try {
266
+ setLoading(true);
267
+ const result = await authorize({
268
+ type: "accredit_command",
269
+ commands: {
270
+ id: "LICENSE",
271
+ license_data: code
272
+ }
273
+ });
274
+ if (result?.commands) {
275
+ const commands = result.commands;
276
+ // type accredit_message
277
+ if (commands?.accredit_status) {
278
+ setIsRegistered(true);
279
+ setAuthData(commands);
280
+ closeModal();
281
+ } else {
282
+ messageApi.error(commands.ciphertext_status || 'Authorization failed');
283
+ }
284
+ }
285
+ } catch (error) {
286
+ console.error('Authorization error:', error);
287
+ } finally {
288
+ setLoading(false);
289
+ }
290
+ };
291
+ const modal = showModal && /*#__PURE__*/jsxs(Fragment, {
292
+ children: [/*#__PURE__*/jsx(AuthorizationModal, {
293
+ onOk: auth,
294
+ onCancel: closeModal,
295
+ authData: authData
296
+ }), contextHolder]
297
+ });
298
+ return {
299
+ AuthModal: modal,
300
+ openAuthModal: openModal,
301
+ closeAuthModal: closeModal,
302
+ isRegistered,
303
+ authData,
304
+ loading
305
+ };
306
+ };
307
+
308
+ const useUpgrade = _ref => {
309
+ let {
310
+ menuItems = [],
311
+ onMenuClick,
312
+ downloadFiles,
313
+ upgradeExecute,
314
+ upgradeStatus,
315
+ acceptFileTypes = "application/octet-stream",
316
+ uploadCompleteDelay = 3000,
317
+ statusPollingInterval = 1000
318
+ } = _ref;
319
+ const [isSpinning, setIsSpinning] = useState(false);
320
+ const [interval, setInterval] = useState(undefined); // 间隔时间,当设置值为 undefined 时会停止计时器
321
+ const inputRef = useRef(null);
322
+ const [currentStatus, setCurrentStatus] = useState('idle'); // 'idle' | 'uploading' | 'upgrading'
323
+ const isUploadCompleteRef = useRef(false); // 安装包上传是否完成
324
+ const [uploadProgress, setUploadProgress] = useState(0);
325
+
326
+ // 分别创建独立的取消令牌
327
+ const uploadCancelToken = useRef(axios.CancelToken.source());
328
+ const statusCancelToken = useRef(axios.CancelToken.source());
329
+ const showLoader = () => setIsSpinning(true);
330
+ const hideLoader = () => setIsSpinning(false);
331
+
332
+ // 构建菜单项 - 确保至少包含download和upload
333
+ const finalMenuItems = useMemo(() => {
334
+ const hasDownload = menuItems.some(item => item.key === 'download');
335
+ const hasUpload = menuItems.some(item => item.key === 'upload');
336
+
337
+ // 如果都已经存在,直接返回
338
+ if (hasDownload && hasUpload) {
339
+ return menuItems;
340
+ }
341
+ let finalItems = [...menuItems];
342
+
343
+ // 查找license项的位置
344
+ const licenseIndex = finalItems.findIndex(item => item.key === 'license');
345
+
346
+ // 查找最后一个分隔符的位置(在license之前)
347
+ let insertIndex = finalItems.length;
348
+ let hasPrecedingDivider = false;
349
+ if (licenseIndex !== -1) {
350
+ // 如果找到license,在其前面插入
351
+ insertIndex = licenseIndex;
352
+
353
+ // 检查license前面是否有分隔符
354
+ if (licenseIndex > 0 && finalItems[licenseIndex - 1].type === 'divider') {
355
+ hasPrecedingDivider = true;
356
+ insertIndex = licenseIndex - 1; // 在分隔符前面插入
357
+ }
358
+ } else {
359
+ // 如果没有license,查找最后一个分隔符
360
+ const lastDividerIndex = finalItems.map((item, idx) => item.type === 'divider' ? idx : -1).filter(idx => idx !== -1).pop();
361
+ if (lastDividerIndex !== undefined) {
362
+ insertIndex = lastDividerIndex + 1;
363
+ }
364
+ }
365
+ const itemsToInsert = [];
366
+
367
+ // 添加缺少的download项
368
+ if (!hasDownload) {
369
+ itemsToInsert.push({
370
+ key: "download",
371
+ label: "Download Config File"
372
+ });
373
+ }
374
+
375
+ // 添加缺少的upload项
376
+ if (!hasUpload) {
377
+ itemsToInsert.push({
378
+ key: "upload",
379
+ label: "Software Update"
380
+ });
381
+ }
382
+
383
+ // 在前面插入分隔符(如果还没有且需要插入项)
384
+ if (!hasPrecedingDivider && itemsToInsert.length > 0 && insertIndex > 0) {
385
+ itemsToInsert.unshift({
386
+ type: 'divider'
387
+ });
388
+ }
389
+
390
+ // 在指定位置插入项
391
+ if (itemsToInsert.length > 0) {
392
+ finalItems.splice(insertIndex, 0, ...itemsToInsert);
393
+ }
394
+ return finalItems;
395
+ }, [menuItems]);
396
+ const handleMenuClick = _ref2 => {
397
+ let {
398
+ key
399
+ } = _ref2;
400
+ switch (key) {
401
+ case 'download':
402
+ onDownload();
403
+ return;
404
+ case 'upload':
405
+ onUpload();
406
+ return;
407
+ default:
408
+ // 其他菜单项交给外部回调处理
409
+ if (onMenuClick) {
410
+ onMenuClick(key);
411
+ } else {
412
+ console.warn(`Unknown menu key: ${key} and no onMenuClick provided`);
413
+ }
414
+ }
415
+ };
416
+ const onDownload = async () => {
417
+ if (!downloadFiles) {
418
+ console.error('downloadFiles function is required for download operation');
419
+ message.error('Download functionality not configured');
420
+ return;
421
+ }
422
+ try {
423
+ const res = await downloadFiles();
424
+ if (res.status !== 200) {
425
+ throw new Error(`Unexpected status code: ${res.status}`);
426
+ }
427
+
428
+ // 默认值,兼容接口响应头没有定义文件名
429
+ let fileName = 'config.tar.gz';
430
+ const contentDisposition = res.headers['content-disposition'] || '';
431
+
432
+ // 获取接口响应的content-disposition字段值,以便获取到文件名
433
+ if (contentDisposition) {
434
+ const filenameMatch = contentDisposition.match(/filename\s*=\s*"?([^";]+)"?/i);
435
+ if (filenameMatch?.[1]) {
436
+ fileName = decodeURIComponent(filenameMatch[1]); // 处理编码后的文件名(如 %20 转空格)
437
+ }
438
+ }
439
+
440
+ // 创建并下载文件
441
+ const blob = new Blob([res.data], {
442
+ type: 'application/octet-stream'
443
+ });
444
+ const url = window.URL.createObjectURL(blob);
445
+
446
+ // 下面就是创建一个a标签并触发click事件,来下载该文件
447
+ const link = document.createElement('a');
448
+ link.style.display = 'none';
449
+ link.href = url;
450
+ link.target = '_blank';
451
+ link.download = fileName;
452
+ document.body.appendChild(link);
453
+ link.click();
454
+
455
+ // 最后移除a标签并删除创建的ObjectURL对象,防止内存泄漏
456
+ link.parentNode.removeChild(link);
457
+ window.URL.revokeObjectURL(url);
458
+ } catch (error) {
459
+ console.error('Download failed:', error);
460
+ message.error('Download failed');
461
+ }
462
+ };
463
+ const onUpload = () => {
464
+ if (inputRef?.current) {
465
+ inputRef.current.click();
466
+ }
467
+ };
468
+ const updatePackage = async event => {
469
+ if (!upgradeExecute) {
470
+ console.error('upgradeExecute function is required for upload operation');
471
+ message.error('Upload functionality not configured');
472
+ return;
473
+ }
474
+ try {
475
+ const file = event.target.files?.[0];
476
+ if (!file) return;
477
+ showLoader();
478
+ setCurrentStatus('Uploading...');
479
+ setUploadProgress(0); // 重置进度
480
+
481
+ const formData = new FormData();
482
+ formData.append('file', file);
483
+ isUploadCompleteRef.current = false;
484
+
485
+ // 上传文件(不等待响应)
486
+ upgradeExecute(formData, {
487
+ onUploadProgress: progressEvent => {
488
+ const percentCompleted = Math.round(progressEvent.loaded * 100 / progressEvent.total);
489
+ setUploadProgress(percentCompleted); // 更新进度状态
490
+
491
+ if (percentCompleted === 100) {
492
+ isUploadCompleteRef.current = true;
493
+ // 等待3秒 开始状态轮询
494
+ setTimeout(() => {
495
+ setInterval(statusPollingInterval);
496
+ setCurrentStatus('Upgrading...');
497
+ }, uploadCompleteDelay);
498
+ }
499
+ },
500
+ cancelToken: uploadCancelToken.current.token
501
+ });
502
+
503
+ // 清除文件选择
504
+ if (inputRef.current) inputRef.current.value = "";
505
+ } catch (error) {
506
+ if (!axios.isCancel(error)) {
507
+ console.error("Upload error:", error);
508
+ message.error('Upload failed');
509
+ }
510
+ cancelRequest();
511
+ }
512
+ };
513
+ const fetchUpgradeStatus = async () => {
514
+ if (!upgradeStatus) {
515
+ console.error('upgradeStatus function is required for status checking');
516
+ cancelRequest();
517
+ return;
518
+ }
519
+ try {
520
+ const response = await upgradeStatus({
521
+ cancelToken: statusCancelToken.current.token
522
+ });
523
+ if (response?.status === 200) {
524
+ const {
525
+ code,
526
+ message: statusMessage
527
+ } = response.data;
528
+
529
+ // 状态处理
530
+ switch (code) {
531
+ case 200:
532
+ // 升级成功
533
+ message.success(statusMessage, 2.5, () => {
534
+ cancelRequest();
535
+ window.location.reload();
536
+ });
537
+ break;
538
+ case 201:
539
+ // 升级中
540
+ // code为201时,每隔一秒请求一次。直到请求到其他的code,直接弹出message提示。
541
+ break;
542
+ case 202: // 升级失败
543
+ case 203:
544
+ // 升级异常
545
+ message.error(statusMessage);
546
+ cancelRequest();
547
+ break;
548
+ default:
549
+ break;
550
+ }
551
+ }
552
+ } catch (error) {
553
+ if (axios.isCancel(error)) {
554
+ console.log('Status polling canceled');
555
+ } else {
556
+ console.error('Status check failed:', error);
557
+ // 网络错误时自动重试
558
+ }
559
+ }
560
+ };
561
+ const cancelRequest = () => {
562
+ // 取消状态轮询
563
+ uploadCancelToken.current.cancel('Operation canceled');
564
+ statusCancelToken.current.cancel('Operation canceled');
565
+ uploadCancelToken.current = axios.CancelToken.source();
566
+ statusCancelToken.current = axios.CancelToken.source();
567
+
568
+ // 重置所有状态
569
+ setInterval(undefined);
570
+ setCurrentStatus('idle');
571
+ hideLoader();
572
+ };
573
+
574
+ // 轮询状态
575
+ useInterval(fetchUpgradeStatus, interval);
576
+
577
+ // 组件卸载时清理
578
+ useEffect(() => {
579
+ return () => {
580
+ uploadCancelToken.current.cancel();
581
+ statusCancelToken.current.cancel();
582
+ };
583
+ }, []);
584
+ const upgradeElement = /*#__PURE__*/jsxs("div", {
585
+ children: [/*#__PURE__*/jsx(Dropdown, {
586
+ menu: {
587
+ items: finalMenuItems,
588
+ onClick: handleMenuClick
589
+ },
590
+ trigger: ["hover"],
591
+ children: /*#__PURE__*/jsx("a", {
592
+ onClick: e => e.preventDefault(),
593
+ children: /*#__PURE__*/jsx("i", {
594
+ className: "iconfont icon-liebiao2 text-2xl text-neutral-400"
595
+ })
596
+ })
597
+ }), /*#__PURE__*/jsx("input", {
598
+ ref: inputRef,
599
+ type: "file",
600
+ onChange: updatePackage,
601
+ className: "hidden",
602
+ accept: acceptFileTypes
603
+ }), /*#__PURE__*/jsx(Spin, {
604
+ spinning: isSpinning,
605
+ indicator: /*#__PURE__*/jsx(LoadingOutlined, {
606
+ style: {
607
+ fontSize: 60
608
+ },
609
+ spin: true
610
+ }),
611
+ tip: currentStatus === "Uploading..." ? `${currentStatus} ${uploadProgress}%` : currentStatus,
612
+ size: "large",
613
+ fullscreen: true
614
+ })]
615
+ });
616
+ return [upgradeElement];
617
+ };
618
+
619
+ const useSystemOperations = function () {
620
+ let {
621
+ onPowerOff,
622
+ onRestart,
623
+ confirmTitle = "Confirm",
624
+ cancelText = "No",
625
+ okText = "Yes"
626
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
627
+ const {
628
+ modal: AntdModal
629
+ } = App.useApp();
630
+ const doAction = useCallback(action => {
631
+ try {
632
+ AntdModal.confirm({
633
+ icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
634
+ title: `${confirmTitle} ${action}?`,
635
+ cancelText,
636
+ okText,
637
+ onOk: () => {
638
+ if (action === 'poweroff' && onPowerOff) {
639
+ onPowerOff();
640
+ } else if (action === 'restart' && onRestart) {
641
+ onRestart();
642
+ }
643
+ }
644
+ });
645
+ } catch (error) {
646
+ console.error(`${action.toUpperCase()} ERROR: `, error);
647
+ }
648
+ }, [AntdModal, confirmTitle, cancelText, okText, onPowerOff, onRestart]);
649
+ const getMenuItems = useCallback(() => [{
650
+ key: "poweroff",
651
+ label: "Power Off"
652
+ }, {
653
+ key: "restart",
654
+ label: "Restart"
655
+ }], []);
656
+ const handleMenuClick = useCallback(_ref => {
657
+ let {
658
+ key
659
+ } = _ref;
660
+ doAction(key);
661
+ }, [doAction]);
662
+ return {
663
+ menuItems: getMenuItems(),
664
+ handleMenuClick
665
+ };
666
+ };
667
+
668
+ const UpgradeManager = _ref => {
669
+ let {
670
+ menuItems = [],
671
+ onMenuClick,
672
+ downloadFiles,
673
+ upgradeExecute,
674
+ upgradeStatus,
675
+ acceptFileTypes = "application/octet-stream",
676
+ uploadCompleteDelay = 3000,
677
+ statusPollingInterval = 1000,
678
+ children,
679
+ ...dropdownProps
680
+ } = _ref;
681
+ const [upgradeElement] = useUpgrade({
682
+ menuItems,
683
+ onMenuClick,
684
+ downloadFiles,
685
+ upgradeExecute,
686
+ upgradeStatus,
687
+ acceptFileTypes,
688
+ uploadCompleteDelay,
689
+ statusPollingInterval
690
+ });
691
+ if (children) {
692
+ // 提取Dropdown组件和其menu属性
693
+ const dropdownElement = upgradeElement.props.children[0];
694
+ const otherElements = upgradeElement.props.children.slice(1);
695
+ return /*#__PURE__*/jsxs(Fragment, {
696
+ children: [/*#__PURE__*/jsx(Dropdown, {
697
+ ...dropdownProps,
698
+ ...dropdownElement.props,
699
+ children: children
700
+ }), otherElements]
701
+ });
702
+ }
703
+
704
+ // 如果没有children,直接返回完整的升级元素
705
+ return upgradeElement;
706
+ };
707
+ UpgradeManager.defaultProps = {
708
+ trigger: ["hover"],
709
+ placement: "bottomRight"
710
+ };
711
+
712
+ function getDefaultExportFromCjs (x) {
713
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
714
+ }
715
+
716
+ var propTypes = {exports: {}};
717
+
718
+ var reactIs = {exports: {}};
719
+
720
+ var reactIs_production_min = {};
721
+
722
+ /** @license React v16.13.1
723
+ * react-is.production.min.js
724
+ *
725
+ * Copyright (c) Facebook, Inc. and its affiliates.
726
+ *
727
+ * This source code is licensed under the MIT license found in the
728
+ * LICENSE file in the root directory of this source tree.
729
+ */
730
+
731
+ var hasRequiredReactIs_production_min;
732
+
733
+ function requireReactIs_production_min () {
734
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
735
+ hasRequiredReactIs_production_min = 1;
736
+ var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
737
+ Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
738
+ function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
739
+ reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
740
+ reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
741
+ reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
742
+ return reactIs_production_min;
743
+ }
744
+
745
+ var reactIs_development = {};
746
+
747
+ /** @license React v16.13.1
748
+ * react-is.development.js
749
+ *
750
+ * Copyright (c) Facebook, Inc. and its affiliates.
751
+ *
752
+ * This source code is licensed under the MIT license found in the
753
+ * LICENSE file in the root directory of this source tree.
754
+ */
755
+
756
+ var hasRequiredReactIs_development;
757
+
758
+ function requireReactIs_development () {
759
+ if (hasRequiredReactIs_development) return reactIs_development;
760
+ hasRequiredReactIs_development = 1;
761
+
762
+
763
+
764
+ if (process.env.NODE_ENV !== "production") {
765
+ (function() {
766
+
767
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
768
+ // nor polyfill, then a plain number is used for performance.
769
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
770
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
771
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
772
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
773
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
774
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
775
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
776
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
777
+ // (unstable) APIs that have been removed. Can we remove the symbols?
778
+
779
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
780
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
781
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
782
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
783
+ var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
784
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
785
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
786
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
787
+ var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
788
+ var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
789
+ var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
790
+
791
+ function isValidElementType(type) {
792
+ return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
793
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
794
+ }
795
+
796
+ function typeOf(object) {
797
+ if (typeof object === 'object' && object !== null) {
798
+ var $$typeof = object.$$typeof;
799
+
800
+ switch ($$typeof) {
801
+ case REACT_ELEMENT_TYPE:
802
+ var type = object.type;
803
+
804
+ switch (type) {
805
+ case REACT_ASYNC_MODE_TYPE:
806
+ case REACT_CONCURRENT_MODE_TYPE:
807
+ case REACT_FRAGMENT_TYPE:
808
+ case REACT_PROFILER_TYPE:
809
+ case REACT_STRICT_MODE_TYPE:
810
+ case REACT_SUSPENSE_TYPE:
811
+ return type;
812
+
813
+ default:
814
+ var $$typeofType = type && type.$$typeof;
815
+
816
+ switch ($$typeofType) {
817
+ case REACT_CONTEXT_TYPE:
818
+ case REACT_FORWARD_REF_TYPE:
819
+ case REACT_LAZY_TYPE:
820
+ case REACT_MEMO_TYPE:
821
+ case REACT_PROVIDER_TYPE:
822
+ return $$typeofType;
823
+
824
+ default:
825
+ return $$typeof;
826
+ }
827
+
828
+ }
829
+
830
+ case REACT_PORTAL_TYPE:
831
+ return $$typeof;
832
+ }
833
+ }
834
+
835
+ return undefined;
836
+ } // AsyncMode is deprecated along with isAsyncMode
837
+
838
+ var AsyncMode = REACT_ASYNC_MODE_TYPE;
839
+ var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
840
+ var ContextConsumer = REACT_CONTEXT_TYPE;
841
+ var ContextProvider = REACT_PROVIDER_TYPE;
842
+ var Element = REACT_ELEMENT_TYPE;
843
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
844
+ var Fragment = REACT_FRAGMENT_TYPE;
845
+ var Lazy = REACT_LAZY_TYPE;
846
+ var Memo = REACT_MEMO_TYPE;
847
+ var Portal = REACT_PORTAL_TYPE;
848
+ var Profiler = REACT_PROFILER_TYPE;
849
+ var StrictMode = REACT_STRICT_MODE_TYPE;
850
+ var Suspense = REACT_SUSPENSE_TYPE;
851
+ var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
852
+
853
+ function isAsyncMode(object) {
854
+ {
855
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
856
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
857
+
858
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
859
+ }
860
+ }
861
+
862
+ return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
863
+ }
864
+ function isConcurrentMode(object) {
865
+ return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
866
+ }
867
+ function isContextConsumer(object) {
868
+ return typeOf(object) === REACT_CONTEXT_TYPE;
869
+ }
870
+ function isContextProvider(object) {
871
+ return typeOf(object) === REACT_PROVIDER_TYPE;
872
+ }
873
+ function isElement(object) {
874
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
875
+ }
876
+ function isForwardRef(object) {
877
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
878
+ }
879
+ function isFragment(object) {
880
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
881
+ }
882
+ function isLazy(object) {
883
+ return typeOf(object) === REACT_LAZY_TYPE;
884
+ }
885
+ function isMemo(object) {
886
+ return typeOf(object) === REACT_MEMO_TYPE;
887
+ }
888
+ function isPortal(object) {
889
+ return typeOf(object) === REACT_PORTAL_TYPE;
890
+ }
891
+ function isProfiler(object) {
892
+ return typeOf(object) === REACT_PROFILER_TYPE;
893
+ }
894
+ function isStrictMode(object) {
895
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
896
+ }
897
+ function isSuspense(object) {
898
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
899
+ }
900
+
901
+ reactIs_development.AsyncMode = AsyncMode;
902
+ reactIs_development.ConcurrentMode = ConcurrentMode;
903
+ reactIs_development.ContextConsumer = ContextConsumer;
904
+ reactIs_development.ContextProvider = ContextProvider;
905
+ reactIs_development.Element = Element;
906
+ reactIs_development.ForwardRef = ForwardRef;
907
+ reactIs_development.Fragment = Fragment;
908
+ reactIs_development.Lazy = Lazy;
909
+ reactIs_development.Memo = Memo;
910
+ reactIs_development.Portal = Portal;
911
+ reactIs_development.Profiler = Profiler;
912
+ reactIs_development.StrictMode = StrictMode;
913
+ reactIs_development.Suspense = Suspense;
914
+ reactIs_development.isAsyncMode = isAsyncMode;
915
+ reactIs_development.isConcurrentMode = isConcurrentMode;
916
+ reactIs_development.isContextConsumer = isContextConsumer;
917
+ reactIs_development.isContextProvider = isContextProvider;
918
+ reactIs_development.isElement = isElement;
919
+ reactIs_development.isForwardRef = isForwardRef;
920
+ reactIs_development.isFragment = isFragment;
921
+ reactIs_development.isLazy = isLazy;
922
+ reactIs_development.isMemo = isMemo;
923
+ reactIs_development.isPortal = isPortal;
924
+ reactIs_development.isProfiler = isProfiler;
925
+ reactIs_development.isStrictMode = isStrictMode;
926
+ reactIs_development.isSuspense = isSuspense;
927
+ reactIs_development.isValidElementType = isValidElementType;
928
+ reactIs_development.typeOf = typeOf;
929
+ })();
930
+ }
931
+ return reactIs_development;
932
+ }
933
+
934
+ var hasRequiredReactIs;
935
+
936
+ function requireReactIs () {
937
+ if (hasRequiredReactIs) return reactIs.exports;
938
+ hasRequiredReactIs = 1;
939
+
940
+ if (process.env.NODE_ENV === 'production') {
941
+ reactIs.exports = requireReactIs_production_min();
942
+ } else {
943
+ reactIs.exports = requireReactIs_development();
944
+ }
945
+ return reactIs.exports;
946
+ }
947
+
948
+ /*
949
+ object-assign
950
+ (c) Sindre Sorhus
951
+ @license MIT
952
+ */
953
+
954
+ var objectAssign;
955
+ var hasRequiredObjectAssign;
956
+
957
+ function requireObjectAssign () {
958
+ if (hasRequiredObjectAssign) return objectAssign;
959
+ hasRequiredObjectAssign = 1;
960
+ /* eslint-disable no-unused-vars */
961
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
962
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
963
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
964
+
965
+ function toObject(val) {
966
+ if (val === null || val === undefined) {
967
+ throw new TypeError('Object.assign cannot be called with null or undefined');
968
+ }
969
+
970
+ return Object(val);
971
+ }
972
+
973
+ function shouldUseNative() {
974
+ try {
975
+ if (!Object.assign) {
976
+ return false;
977
+ }
978
+
979
+ // Detect buggy property enumeration order in older V8 versions.
980
+
981
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
982
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
983
+ test1[5] = 'de';
984
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
985
+ return false;
986
+ }
987
+
988
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
989
+ var test2 = {};
990
+ for (var i = 0; i < 10; i++) {
991
+ test2['_' + String.fromCharCode(i)] = i;
992
+ }
993
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
994
+ return test2[n];
995
+ });
996
+ if (order2.join('') !== '0123456789') {
997
+ return false;
998
+ }
999
+
1000
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
1001
+ var test3 = {};
1002
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
1003
+ test3[letter] = letter;
1004
+ });
1005
+ if (Object.keys(Object.assign({}, test3)).join('') !==
1006
+ 'abcdefghijklmnopqrst') {
1007
+ return false;
1008
+ }
1009
+
1010
+ return true;
1011
+ } catch (err) {
1012
+ // We don't expect any of the above to throw, but better to be safe.
1013
+ return false;
1014
+ }
1015
+ }
1016
+
1017
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
1018
+ var from;
1019
+ var to = toObject(target);
1020
+ var symbols;
1021
+
1022
+ for (var s = 1; s < arguments.length; s++) {
1023
+ from = Object(arguments[s]);
1024
+
1025
+ for (var key in from) {
1026
+ if (hasOwnProperty.call(from, key)) {
1027
+ to[key] = from[key];
1028
+ }
1029
+ }
1030
+
1031
+ if (getOwnPropertySymbols) {
1032
+ symbols = getOwnPropertySymbols(from);
1033
+ for (var i = 0; i < symbols.length; i++) {
1034
+ if (propIsEnumerable.call(from, symbols[i])) {
1035
+ to[symbols[i]] = from[symbols[i]];
1036
+ }
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ return to;
1042
+ };
1043
+ return objectAssign;
1044
+ }
1045
+
1046
+ /**
1047
+ * Copyright (c) 2013-present, Facebook, Inc.
1048
+ *
1049
+ * This source code is licensed under the MIT license found in the
1050
+ * LICENSE file in the root directory of this source tree.
1051
+ */
1052
+
1053
+ var ReactPropTypesSecret_1;
1054
+ var hasRequiredReactPropTypesSecret;
1055
+
1056
+ function requireReactPropTypesSecret () {
1057
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
1058
+ hasRequiredReactPropTypesSecret = 1;
1059
+
1060
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1061
+
1062
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
1063
+ return ReactPropTypesSecret_1;
1064
+ }
1065
+
1066
+ var has;
1067
+ var hasRequiredHas;
1068
+
1069
+ function requireHas () {
1070
+ if (hasRequiredHas) return has;
1071
+ hasRequiredHas = 1;
1072
+ has = Function.call.bind(Object.prototype.hasOwnProperty);
1073
+ return has;
1074
+ }
1075
+
1076
+ /**
1077
+ * Copyright (c) 2013-present, Facebook, Inc.
1078
+ *
1079
+ * This source code is licensed under the MIT license found in the
1080
+ * LICENSE file in the root directory of this source tree.
1081
+ */
1082
+
1083
+ var checkPropTypes_1;
1084
+ var hasRequiredCheckPropTypes;
1085
+
1086
+ function requireCheckPropTypes () {
1087
+ if (hasRequiredCheckPropTypes) return checkPropTypes_1;
1088
+ hasRequiredCheckPropTypes = 1;
1089
+
1090
+ var printWarning = function() {};
1091
+
1092
+ if (process.env.NODE_ENV !== 'production') {
1093
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
1094
+ var loggedTypeFailures = {};
1095
+ var has = /*@__PURE__*/ requireHas();
1096
+
1097
+ printWarning = function(text) {
1098
+ var message = 'Warning: ' + text;
1099
+ if (typeof console !== 'undefined') {
1100
+ console.error(message);
1101
+ }
1102
+ try {
1103
+ // --- Welcome to debugging React ---
1104
+ // This error was thrown as a convenience so that you can use this stack
1105
+ // to find the callsite that caused this warning to fire.
1106
+ throw new Error(message);
1107
+ } catch (x) { /**/ }
1108
+ };
1109
+ }
1110
+
1111
+ /**
1112
+ * Assert that the values match with the type specs.
1113
+ * Error messages are memorized and will only be shown once.
1114
+ *
1115
+ * @param {object} typeSpecs Map of name to a ReactPropType
1116
+ * @param {object} values Runtime values that need to be type-checked
1117
+ * @param {string} location e.g. "prop", "context", "child context"
1118
+ * @param {string} componentName Name of the component for error messages.
1119
+ * @param {?Function} getStack Returns the component stack.
1120
+ * @private
1121
+ */
1122
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1123
+ if (process.env.NODE_ENV !== 'production') {
1124
+ for (var typeSpecName in typeSpecs) {
1125
+ if (has(typeSpecs, typeSpecName)) {
1126
+ var error;
1127
+ // Prop type validation may throw. In case they do, we don't want to
1128
+ // fail the render phase where it didn't fail before. So we log it.
1129
+ // After these have been cleaned up, we'll let them throw.
1130
+ try {
1131
+ // This is intentionally an invariant that gets caught. It's the same
1132
+ // behavior as without this statement except with a better message.
1133
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
1134
+ var err = Error(
1135
+ (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
1136
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
1137
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
1138
+ );
1139
+ err.name = 'Invariant Violation';
1140
+ throw err;
1141
+ }
1142
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
1143
+ } catch (ex) {
1144
+ error = ex;
1145
+ }
1146
+ if (error && !(error instanceof Error)) {
1147
+ printWarning(
1148
+ (componentName || 'React class') + ': type specification of ' +
1149
+ location + ' `' + typeSpecName + '` is invalid; the type checker ' +
1150
+ 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
1151
+ 'You may have forgotten to pass an argument to the type checker ' +
1152
+ 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
1153
+ 'shape all require an argument).'
1154
+ );
1155
+ }
1156
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1157
+ // Only monitor this failure once because there tends to be a lot of the
1158
+ // same error.
1159
+ loggedTypeFailures[error.message] = true;
1160
+
1161
+ var stack = getStack ? getStack() : '';
1162
+
1163
+ printWarning(
1164
+ 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
1165
+ );
1166
+ }
1167
+ }
1168
+ }
1169
+ }
1170
+ }
1171
+
1172
+ /**
1173
+ * Resets warning cache when testing.
1174
+ *
1175
+ * @private
1176
+ */
1177
+ checkPropTypes.resetWarningCache = function() {
1178
+ if (process.env.NODE_ENV !== 'production') {
1179
+ loggedTypeFailures = {};
1180
+ }
1181
+ };
1182
+
1183
+ checkPropTypes_1 = checkPropTypes;
1184
+ return checkPropTypes_1;
1185
+ }
1186
+
1187
+ /**
1188
+ * Copyright (c) 2013-present, Facebook, Inc.
1189
+ *
1190
+ * This source code is licensed under the MIT license found in the
1191
+ * LICENSE file in the root directory of this source tree.
1192
+ */
1193
+
1194
+ var factoryWithTypeCheckers;
1195
+ var hasRequiredFactoryWithTypeCheckers;
1196
+
1197
+ function requireFactoryWithTypeCheckers () {
1198
+ if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
1199
+ hasRequiredFactoryWithTypeCheckers = 1;
1200
+
1201
+ var ReactIs = requireReactIs();
1202
+ var assign = requireObjectAssign();
1203
+
1204
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
1205
+ var has = /*@__PURE__*/ requireHas();
1206
+ var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
1207
+
1208
+ var printWarning = function() {};
1209
+
1210
+ if (process.env.NODE_ENV !== 'production') {
1211
+ printWarning = function(text) {
1212
+ var message = 'Warning: ' + text;
1213
+ if (typeof console !== 'undefined') {
1214
+ console.error(message);
1215
+ }
1216
+ try {
1217
+ // --- Welcome to debugging React ---
1218
+ // This error was thrown as a convenience so that you can use this stack
1219
+ // to find the callsite that caused this warning to fire.
1220
+ throw new Error(message);
1221
+ } catch (x) {}
1222
+ };
1223
+ }
1224
+
1225
+ function emptyFunctionThatReturnsNull() {
1226
+ return null;
1227
+ }
1228
+
1229
+ factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
1230
+ /* global Symbol */
1231
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1232
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1233
+
1234
+ /**
1235
+ * Returns the iterator method function contained on the iterable object.
1236
+ *
1237
+ * Be sure to invoke the function with the iterable as context:
1238
+ *
1239
+ * var iteratorFn = getIteratorFn(myIterable);
1240
+ * if (iteratorFn) {
1241
+ * var iterator = iteratorFn.call(myIterable);
1242
+ * ...
1243
+ * }
1244
+ *
1245
+ * @param {?object} maybeIterable
1246
+ * @return {?function}
1247
+ */
1248
+ function getIteratorFn(maybeIterable) {
1249
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1250
+ if (typeof iteratorFn === 'function') {
1251
+ return iteratorFn;
1252
+ }
1253
+ }
1254
+
1255
+ /**
1256
+ * Collection of methods that allow declaration and validation of props that are
1257
+ * supplied to React components. Example usage:
1258
+ *
1259
+ * var Props = require('ReactPropTypes');
1260
+ * var MyArticle = React.createClass({
1261
+ * propTypes: {
1262
+ * // An optional string prop named "description".
1263
+ * description: Props.string,
1264
+ *
1265
+ * // A required enum prop named "category".
1266
+ * category: Props.oneOf(['News','Photos']).isRequired,
1267
+ *
1268
+ * // A prop named "dialog" that requires an instance of Dialog.
1269
+ * dialog: Props.instanceOf(Dialog).isRequired
1270
+ * },
1271
+ * render: function() { ... }
1272
+ * });
1273
+ *
1274
+ * A more formal specification of how these methods are used:
1275
+ *
1276
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1277
+ * decl := ReactPropTypes.{type}(.isRequired)?
1278
+ *
1279
+ * Each and every declaration produces a function with the same signature. This
1280
+ * allows the creation of custom validation functions. For example:
1281
+ *
1282
+ * var MyLink = React.createClass({
1283
+ * propTypes: {
1284
+ * // An optional string or URI prop named "href".
1285
+ * href: function(props, propName, componentName) {
1286
+ * var propValue = props[propName];
1287
+ * if (propValue != null && typeof propValue !== 'string' &&
1288
+ * !(propValue instanceof URI)) {
1289
+ * return new Error(
1290
+ * 'Expected a string or an URI for ' + propName + ' in ' +
1291
+ * componentName
1292
+ * );
1293
+ * }
1294
+ * }
1295
+ * },
1296
+ * render: function() {...}
1297
+ * });
1298
+ *
1299
+ * @internal
1300
+ */
1301
+
1302
+ var ANONYMOUS = '<<anonymous>>';
1303
+
1304
+ // Important!
1305
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
1306
+ var ReactPropTypes = {
1307
+ array: createPrimitiveTypeChecker('array'),
1308
+ bigint: createPrimitiveTypeChecker('bigint'),
1309
+ bool: createPrimitiveTypeChecker('boolean'),
1310
+ func: createPrimitiveTypeChecker('function'),
1311
+ number: createPrimitiveTypeChecker('number'),
1312
+ object: createPrimitiveTypeChecker('object'),
1313
+ string: createPrimitiveTypeChecker('string'),
1314
+ symbol: createPrimitiveTypeChecker('symbol'),
1315
+
1316
+ any: createAnyTypeChecker(),
1317
+ arrayOf: createArrayOfTypeChecker,
1318
+ element: createElementTypeChecker(),
1319
+ elementType: createElementTypeTypeChecker(),
1320
+ instanceOf: createInstanceTypeChecker,
1321
+ node: createNodeChecker(),
1322
+ objectOf: createObjectOfTypeChecker,
1323
+ oneOf: createEnumTypeChecker,
1324
+ oneOfType: createUnionTypeChecker,
1325
+ shape: createShapeTypeChecker,
1326
+ exact: createStrictShapeTypeChecker,
1327
+ };
1328
+
1329
+ /**
1330
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
1331
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1332
+ */
1333
+ /*eslint-disable no-self-compare*/
1334
+ function is(x, y) {
1335
+ // SameValue algorithm
1336
+ if (x === y) {
1337
+ // Steps 1-5, 7-10
1338
+ // Steps 6.b-6.e: +0 != -0
1339
+ return x !== 0 || 1 / x === 1 / y;
1340
+ } else {
1341
+ // Step 6.a: NaN == NaN
1342
+ return x !== x && y !== y;
1343
+ }
1344
+ }
1345
+ /*eslint-enable no-self-compare*/
1346
+
1347
+ /**
1348
+ * We use an Error-like object for backward compatibility as people may call
1349
+ * PropTypes directly and inspect their output. However, we don't use real
1350
+ * Errors anymore. We don't inspect their stack anyway, and creating them
1351
+ * is prohibitively expensive if they are created too often, such as what
1352
+ * happens in oneOfType() for any type before the one that matched.
1353
+ */
1354
+ function PropTypeError(message, data) {
1355
+ this.message = message;
1356
+ this.data = data && typeof data === 'object' ? data: {};
1357
+ this.stack = '';
1358
+ }
1359
+ // Make `instanceof Error` still work for returned errors.
1360
+ PropTypeError.prototype = Error.prototype;
1361
+
1362
+ function createChainableTypeChecker(validate) {
1363
+ if (process.env.NODE_ENV !== 'production') {
1364
+ var manualPropTypeCallCache = {};
1365
+ var manualPropTypeWarningCount = 0;
1366
+ }
1367
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
1368
+ componentName = componentName || ANONYMOUS;
1369
+ propFullName = propFullName || propName;
1370
+
1371
+ if (secret !== ReactPropTypesSecret) {
1372
+ if (throwOnDirectAccess) {
1373
+ // New behavior only for users of `prop-types` package
1374
+ var err = new Error(
1375
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1376
+ 'Use `PropTypes.checkPropTypes()` to call them. ' +
1377
+ 'Read more at http://fb.me/use-check-prop-types'
1378
+ );
1379
+ err.name = 'Invariant Violation';
1380
+ throw err;
1381
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
1382
+ // Old behavior for people using React.PropTypes
1383
+ var cacheKey = componentName + ':' + propName;
1384
+ if (
1385
+ !manualPropTypeCallCache[cacheKey] &&
1386
+ // Avoid spamming the console because they are often not actionable except for lib authors
1387
+ manualPropTypeWarningCount < 3
1388
+ ) {
1389
+ printWarning(
1390
+ 'You are manually calling a React.PropTypes validation ' +
1391
+ 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
1392
+ 'and will throw in the standalone `prop-types` package. ' +
1393
+ 'You may be seeing this warning due to a third-party PropTypes ' +
1394
+ 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
1395
+ );
1396
+ manualPropTypeCallCache[cacheKey] = true;
1397
+ manualPropTypeWarningCount++;
1398
+ }
1399
+ }
1400
+ }
1401
+ if (props[propName] == null) {
1402
+ if (isRequired) {
1403
+ if (props[propName] === null) {
1404
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
1405
+ }
1406
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
1407
+ }
1408
+ return null;
1409
+ } else {
1410
+ return validate(props, propName, componentName, location, propFullName);
1411
+ }
1412
+ }
1413
+
1414
+ var chainedCheckType = checkType.bind(null, false);
1415
+ chainedCheckType.isRequired = checkType.bind(null, true);
1416
+
1417
+ return chainedCheckType;
1418
+ }
1419
+
1420
+ function createPrimitiveTypeChecker(expectedType) {
1421
+ function validate(props, propName, componentName, location, propFullName, secret) {
1422
+ var propValue = props[propName];
1423
+ var propType = getPropType(propValue);
1424
+ if (propType !== expectedType) {
1425
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
1426
+ // check, but we can offer a more precise error message here rather than
1427
+ // 'of type `object`'.
1428
+ var preciseType = getPreciseType(propValue);
1429
+
1430
+ return new PropTypeError(
1431
+ 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
1432
+ {expectedType: expectedType}
1433
+ );
1434
+ }
1435
+ return null;
1436
+ }
1437
+ return createChainableTypeChecker(validate);
1438
+ }
1439
+
1440
+ function createAnyTypeChecker() {
1441
+ return createChainableTypeChecker(emptyFunctionThatReturnsNull);
1442
+ }
1443
+
1444
+ function createArrayOfTypeChecker(typeChecker) {
1445
+ function validate(props, propName, componentName, location, propFullName) {
1446
+ if (typeof typeChecker !== 'function') {
1447
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
1448
+ }
1449
+ var propValue = props[propName];
1450
+ if (!Array.isArray(propValue)) {
1451
+ var propType = getPropType(propValue);
1452
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
1453
+ }
1454
+ for (var i = 0; i < propValue.length; i++) {
1455
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
1456
+ if (error instanceof Error) {
1457
+ return error;
1458
+ }
1459
+ }
1460
+ return null;
1461
+ }
1462
+ return createChainableTypeChecker(validate);
1463
+ }
1464
+
1465
+ function createElementTypeChecker() {
1466
+ function validate(props, propName, componentName, location, propFullName) {
1467
+ var propValue = props[propName];
1468
+ if (!isValidElement(propValue)) {
1469
+ var propType = getPropType(propValue);
1470
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
1471
+ }
1472
+ return null;
1473
+ }
1474
+ return createChainableTypeChecker(validate);
1475
+ }
1476
+
1477
+ function createElementTypeTypeChecker() {
1478
+ function validate(props, propName, componentName, location, propFullName) {
1479
+ var propValue = props[propName];
1480
+ if (!ReactIs.isValidElementType(propValue)) {
1481
+ var propType = getPropType(propValue);
1482
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
1483
+ }
1484
+ return null;
1485
+ }
1486
+ return createChainableTypeChecker(validate);
1487
+ }
1488
+
1489
+ function createInstanceTypeChecker(expectedClass) {
1490
+ function validate(props, propName, componentName, location, propFullName) {
1491
+ if (!(props[propName] instanceof expectedClass)) {
1492
+ var expectedClassName = expectedClass.name || ANONYMOUS;
1493
+ var actualClassName = getClassName(props[propName]);
1494
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
1495
+ }
1496
+ return null;
1497
+ }
1498
+ return createChainableTypeChecker(validate);
1499
+ }
1500
+
1501
+ function createEnumTypeChecker(expectedValues) {
1502
+ if (!Array.isArray(expectedValues)) {
1503
+ if (process.env.NODE_ENV !== 'production') {
1504
+ if (arguments.length > 1) {
1505
+ printWarning(
1506
+ 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
1507
+ 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
1508
+ );
1509
+ } else {
1510
+ printWarning('Invalid argument supplied to oneOf, expected an array.');
1511
+ }
1512
+ }
1513
+ return emptyFunctionThatReturnsNull;
1514
+ }
1515
+
1516
+ function validate(props, propName, componentName, location, propFullName) {
1517
+ var propValue = props[propName];
1518
+ for (var i = 0; i < expectedValues.length; i++) {
1519
+ if (is(propValue, expectedValues[i])) {
1520
+ return null;
1521
+ }
1522
+ }
1523
+
1524
+ var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1525
+ var type = getPreciseType(value);
1526
+ if (type === 'symbol') {
1527
+ return String(value);
1528
+ }
1529
+ return value;
1530
+ });
1531
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
1532
+ }
1533
+ return createChainableTypeChecker(validate);
1534
+ }
1535
+
1536
+ function createObjectOfTypeChecker(typeChecker) {
1537
+ function validate(props, propName, componentName, location, propFullName) {
1538
+ if (typeof typeChecker !== 'function') {
1539
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
1540
+ }
1541
+ var propValue = props[propName];
1542
+ var propType = getPropType(propValue);
1543
+ if (propType !== 'object') {
1544
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
1545
+ }
1546
+ for (var key in propValue) {
1547
+ if (has(propValue, key)) {
1548
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1549
+ if (error instanceof Error) {
1550
+ return error;
1551
+ }
1552
+ }
1553
+ }
1554
+ return null;
1555
+ }
1556
+ return createChainableTypeChecker(validate);
1557
+ }
1558
+
1559
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
1560
+ if (!Array.isArray(arrayOfTypeCheckers)) {
1561
+ process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
1562
+ return emptyFunctionThatReturnsNull;
1563
+ }
1564
+
1565
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1566
+ var checker = arrayOfTypeCheckers[i];
1567
+ if (typeof checker !== 'function') {
1568
+ printWarning(
1569
+ 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
1570
+ 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
1571
+ );
1572
+ return emptyFunctionThatReturnsNull;
1573
+ }
1574
+ }
1575
+
1576
+ function validate(props, propName, componentName, location, propFullName) {
1577
+ var expectedTypes = [];
1578
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1579
+ var checker = arrayOfTypeCheckers[i];
1580
+ var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
1581
+ if (checkerResult == null) {
1582
+ return null;
1583
+ }
1584
+ if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
1585
+ expectedTypes.push(checkerResult.data.expectedType);
1586
+ }
1587
+ }
1588
+ var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
1589
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
1590
+ }
1591
+ return createChainableTypeChecker(validate);
1592
+ }
1593
+
1594
+ function createNodeChecker() {
1595
+ function validate(props, propName, componentName, location, propFullName) {
1596
+ if (!isNode(props[propName])) {
1597
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
1598
+ }
1599
+ return null;
1600
+ }
1601
+ return createChainableTypeChecker(validate);
1602
+ }
1603
+
1604
+ function invalidValidatorError(componentName, location, propFullName, key, type) {
1605
+ return new PropTypeError(
1606
+ (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
1607
+ 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
1608
+ );
1609
+ }
1610
+
1611
+ function createShapeTypeChecker(shapeTypes) {
1612
+ function validate(props, propName, componentName, location, propFullName) {
1613
+ var propValue = props[propName];
1614
+ var propType = getPropType(propValue);
1615
+ if (propType !== 'object') {
1616
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1617
+ }
1618
+ for (var key in shapeTypes) {
1619
+ var checker = shapeTypes[key];
1620
+ if (typeof checker !== 'function') {
1621
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1622
+ }
1623
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1624
+ if (error) {
1625
+ return error;
1626
+ }
1627
+ }
1628
+ return null;
1629
+ }
1630
+ return createChainableTypeChecker(validate);
1631
+ }
1632
+
1633
+ function createStrictShapeTypeChecker(shapeTypes) {
1634
+ function validate(props, propName, componentName, location, propFullName) {
1635
+ var propValue = props[propName];
1636
+ var propType = getPropType(propValue);
1637
+ if (propType !== 'object') {
1638
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1639
+ }
1640
+ // We need to check all keys in case some are required but missing from props.
1641
+ var allKeys = assign({}, props[propName], shapeTypes);
1642
+ for (var key in allKeys) {
1643
+ var checker = shapeTypes[key];
1644
+ if (has(shapeTypes, key) && typeof checker !== 'function') {
1645
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1646
+ }
1647
+ if (!checker) {
1648
+ return new PropTypeError(
1649
+ 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1650
+ '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1651
+ '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1652
+ );
1653
+ }
1654
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1655
+ if (error) {
1656
+ return error;
1657
+ }
1658
+ }
1659
+ return null;
1660
+ }
1661
+
1662
+ return createChainableTypeChecker(validate);
1663
+ }
1664
+
1665
+ function isNode(propValue) {
1666
+ switch (typeof propValue) {
1667
+ case 'number':
1668
+ case 'string':
1669
+ case 'undefined':
1670
+ return true;
1671
+ case 'boolean':
1672
+ return !propValue;
1673
+ case 'object':
1674
+ if (Array.isArray(propValue)) {
1675
+ return propValue.every(isNode);
1676
+ }
1677
+ if (propValue === null || isValidElement(propValue)) {
1678
+ return true;
1679
+ }
1680
+
1681
+ var iteratorFn = getIteratorFn(propValue);
1682
+ if (iteratorFn) {
1683
+ var iterator = iteratorFn.call(propValue);
1684
+ var step;
1685
+ if (iteratorFn !== propValue.entries) {
1686
+ while (!(step = iterator.next()).done) {
1687
+ if (!isNode(step.value)) {
1688
+ return false;
1689
+ }
1690
+ }
1691
+ } else {
1692
+ // Iterator will provide entry [k,v] tuples rather than values.
1693
+ while (!(step = iterator.next()).done) {
1694
+ var entry = step.value;
1695
+ if (entry) {
1696
+ if (!isNode(entry[1])) {
1697
+ return false;
1698
+ }
1699
+ }
1700
+ }
1701
+ }
1702
+ } else {
1703
+ return false;
1704
+ }
1705
+
1706
+ return true;
1707
+ default:
1708
+ return false;
1709
+ }
1710
+ }
1711
+
1712
+ function isSymbol(propType, propValue) {
1713
+ // Native Symbol.
1714
+ if (propType === 'symbol') {
1715
+ return true;
1716
+ }
1717
+
1718
+ // falsy value can't be a Symbol
1719
+ if (!propValue) {
1720
+ return false;
1721
+ }
1722
+
1723
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1724
+ if (propValue['@@toStringTag'] === 'Symbol') {
1725
+ return true;
1726
+ }
1727
+
1728
+ // Fallback for non-spec compliant Symbols which are polyfilled.
1729
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1730
+ return true;
1731
+ }
1732
+
1733
+ return false;
1734
+ }
1735
+
1736
+ // Equivalent of `typeof` but with special handling for array and regexp.
1737
+ function getPropType(propValue) {
1738
+ var propType = typeof propValue;
1739
+ if (Array.isArray(propValue)) {
1740
+ return 'array';
1741
+ }
1742
+ if (propValue instanceof RegExp) {
1743
+ // Old webkits (at least until Android 4.0) return 'function' rather than
1744
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1745
+ // passes PropTypes.object.
1746
+ return 'object';
1747
+ }
1748
+ if (isSymbol(propType, propValue)) {
1749
+ return 'symbol';
1750
+ }
1751
+ return propType;
1752
+ }
1753
+
1754
+ // This handles more types than `getPropType`. Only used for error messages.
1755
+ // See `createPrimitiveTypeChecker`.
1756
+ function getPreciseType(propValue) {
1757
+ if (typeof propValue === 'undefined' || propValue === null) {
1758
+ return '' + propValue;
1759
+ }
1760
+ var propType = getPropType(propValue);
1761
+ if (propType === 'object') {
1762
+ if (propValue instanceof Date) {
1763
+ return 'date';
1764
+ } else if (propValue instanceof RegExp) {
1765
+ return 'regexp';
1766
+ }
1767
+ }
1768
+ return propType;
1769
+ }
1770
+
1771
+ // Returns a string that is postfixed to a warning about an invalid type.
1772
+ // For example, "undefined" or "of type array"
1773
+ function getPostfixForTypeWarning(value) {
1774
+ var type = getPreciseType(value);
1775
+ switch (type) {
1776
+ case 'array':
1777
+ case 'object':
1778
+ return 'an ' + type;
1779
+ case 'boolean':
1780
+ case 'date':
1781
+ case 'regexp':
1782
+ return 'a ' + type;
1783
+ default:
1784
+ return type;
1785
+ }
1786
+ }
1787
+
1788
+ // Returns class name of the object, if any.
1789
+ function getClassName(propValue) {
1790
+ if (!propValue.constructor || !propValue.constructor.name) {
1791
+ return ANONYMOUS;
1792
+ }
1793
+ return propValue.constructor.name;
1794
+ }
1795
+
1796
+ ReactPropTypes.checkPropTypes = checkPropTypes;
1797
+ ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
1798
+ ReactPropTypes.PropTypes = ReactPropTypes;
1799
+
1800
+ return ReactPropTypes;
1801
+ };
1802
+ return factoryWithTypeCheckers;
1803
+ }
1804
+
1805
+ /**
1806
+ * Copyright (c) 2013-present, Facebook, Inc.
1807
+ *
1808
+ * This source code is licensed under the MIT license found in the
1809
+ * LICENSE file in the root directory of this source tree.
1810
+ */
1811
+
1812
+ var factoryWithThrowingShims;
1813
+ var hasRequiredFactoryWithThrowingShims;
1814
+
1815
+ function requireFactoryWithThrowingShims () {
1816
+ if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
1817
+ hasRequiredFactoryWithThrowingShims = 1;
1818
+
1819
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
1820
+
1821
+ function emptyFunction() {}
1822
+ function emptyFunctionWithReset() {}
1823
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
1824
+
1825
+ factoryWithThrowingShims = function() {
1826
+ function shim(props, propName, componentName, location, propFullName, secret) {
1827
+ if (secret === ReactPropTypesSecret) {
1828
+ // It is still safe when called from React.
1829
+ return;
1830
+ }
1831
+ var err = new Error(
1832
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1833
+ 'Use PropTypes.checkPropTypes() to call them. ' +
1834
+ 'Read more at http://fb.me/use-check-prop-types'
1835
+ );
1836
+ err.name = 'Invariant Violation';
1837
+ throw err;
1838
+ } shim.isRequired = shim;
1839
+ function getShim() {
1840
+ return shim;
1841
+ } // Important!
1842
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1843
+ var ReactPropTypes = {
1844
+ array: shim,
1845
+ bigint: shim,
1846
+ bool: shim,
1847
+ func: shim,
1848
+ number: shim,
1849
+ object: shim,
1850
+ string: shim,
1851
+ symbol: shim,
1852
+
1853
+ any: shim,
1854
+ arrayOf: getShim,
1855
+ element: shim,
1856
+ elementType: shim,
1857
+ instanceOf: getShim,
1858
+ node: shim,
1859
+ objectOf: getShim,
1860
+ oneOf: getShim,
1861
+ oneOfType: getShim,
1862
+ shape: getShim,
1863
+ exact: getShim,
1864
+
1865
+ checkPropTypes: emptyFunctionWithReset,
1866
+ resetWarningCache: emptyFunction
1867
+ };
1868
+
1869
+ ReactPropTypes.PropTypes = ReactPropTypes;
1870
+
1871
+ return ReactPropTypes;
1872
+ };
1873
+ return factoryWithThrowingShims;
1874
+ }
1875
+
1876
+ /**
1877
+ * Copyright (c) 2013-present, Facebook, Inc.
1878
+ *
1879
+ * This source code is licensed under the MIT license found in the
1880
+ * LICENSE file in the root directory of this source tree.
1881
+ */
1882
+
1883
+ var hasRequiredPropTypes;
1884
+
1885
+ function requirePropTypes () {
1886
+ if (hasRequiredPropTypes) return propTypes.exports;
1887
+ hasRequiredPropTypes = 1;
1888
+ if (process.env.NODE_ENV !== 'production') {
1889
+ var ReactIs = requireReactIs();
1890
+
1891
+ // By explicitly using `prop-types` you are opting into new development behavior.
1892
+ // http://fb.me/prop-types-in-prod
1893
+ var throwOnDirectAccess = true;
1894
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
1895
+ } else {
1896
+ // By explicitly using `prop-types` you are opting into new production behavior.
1897
+ // http://fb.me/prop-types-in-prod
1898
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
1899
+ }
1900
+ return propTypes.exports;
1901
+ }
1902
+
1903
+ var propTypesExports = /*@__PURE__*/ requirePropTypes();
1904
+ var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
1905
+
1906
+ const SystemOperations = _ref => {
1907
+ let {
1908
+ onPowerOff,
1909
+ onRestart,
1910
+ powerOffLabel = "Power Off",
1911
+ restartLabel = "Restart",
1912
+ iconClassName = "iconfont icon-guanji1 text-2xl text-neutral-400",
1913
+ confirmTitle = "Confirm",
1914
+ cancelText = "No",
1915
+ okText = "Yes"
1916
+ } = _ref;
1917
+ const {
1918
+ modal: AntdModal
1919
+ } = App.useApp();
1920
+ const menuItems = [{
1921
+ key: "poweroff",
1922
+ label: powerOffLabel
1923
+ },
1924
+ // {
1925
+ // key: "reboot",
1926
+ // label: rebootLabel, // 硬重启 物理重启
1927
+ // },
1928
+ {
1929
+ key: "restart",
1930
+ label: restartLabel // 软重启 服务重启
1931
+ }];
1932
+ const doAction = action => {
1933
+ try {
1934
+ AntdModal.confirm({
1935
+ icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
1936
+ title: `${confirmTitle} ${action}?`,
1937
+ cancelText,
1938
+ okText,
1939
+ onOk: () => {
1940
+ if (action === 'poweroff' && onPowerOff) {
1941
+ onPowerOff();
1942
+ } else if (action === 'restart' && onRestart) {
1943
+ onRestart();
1944
+ }
1945
+ }
1946
+ });
1947
+ } catch (error) {
1948
+ console.error(`${action.toUpperCase()} ERROR: `, error);
1949
+ }
1950
+ };
1951
+ const handleMenuClick = _ref2 => {
1952
+ let {
1953
+ key
1954
+ } = _ref2;
1955
+ doAction(key);
1956
+ };
1957
+ return /*#__PURE__*/jsx(Dropdown, {
1958
+ menu: {
1959
+ items: menuItems,
1960
+ onClick: handleMenuClick
1961
+ },
1962
+ trigger: ["hover"],
1963
+ children: /*#__PURE__*/jsx("a", {
1964
+ onClick: e => e.preventDefault(),
1965
+ children: /*#__PURE__*/jsx("i", {
1966
+ className: iconClassName
1967
+ })
1968
+ })
1969
+ });
1970
+ };
1971
+ SystemOperations.propTypes = {
1972
+ onPowerOff: PropTypes.func,
1973
+ onRestart: PropTypes.func,
1974
+ powerOffLabel: PropTypes.string,
1975
+ restartLabel: PropTypes.string,
1976
+ iconClassName: PropTypes.string,
1977
+ confirmTitle: PropTypes.string,
1978
+ cancelText: PropTypes.string,
1979
+ okText: PropTypes.string
1980
+ };
1981
+
1982
+ export { AuthorizationModal, SystemOperations, UpgradeManager, useAuth, useHardwareUsage, useHardwareWebSocket, useSystemOperations, useUpgrade };
1983
+ //# sourceMappingURL=index.esm.js.map