@turinhub/atomix-common-ui 0.3.0 → 0.5.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.
Files changed (161) hide show
  1. package/README.md +50 -17
  2. package/dist/AuthPanel-C_2JBE7t.cjs +2 -0
  3. package/dist/AuthPanel-C_2JBE7t.cjs.map +1 -0
  4. package/dist/AuthPanel-D2HFX8eN.js +656 -0
  5. package/dist/AuthPanel-D2HFX8eN.js.map +1 -0
  6. package/dist/PDFSidebar-BBtucLK6.js +232 -0
  7. package/dist/PDFSidebar-BBtucLK6.js.map +1 -0
  8. package/dist/PDFSidebar-Di0D-yPS.cjs +2 -0
  9. package/dist/PDFSidebar-Di0D-yPS.cjs.map +1 -0
  10. package/dist/auth.cjs +2 -0
  11. package/dist/auth.cjs.map +1 -0
  12. package/dist/auth.d.ts +11 -0
  13. package/dist/auth.d.ts.map +1 -0
  14. package/dist/auth.js +9 -0
  15. package/dist/auth.js.map +1 -0
  16. package/dist/component-types.cjs +2 -0
  17. package/dist/component-types.cjs.map +1 -0
  18. package/dist/component-types.d.ts +2 -0
  19. package/dist/component-types.d.ts.map +1 -0
  20. package/dist/component-types.js +2 -0
  21. package/dist/component-types.js.map +1 -0
  22. package/dist/components/AuthLoginPanel.d.ts +55 -0
  23. package/dist/components/AuthLoginPanel.d.ts.map +1 -0
  24. package/dist/components/AuthPageShell.d.ts +11 -0
  25. package/dist/components/AuthPageShell.d.ts.map +1 -0
  26. package/dist/components/AuthPanel.d.ts +20 -0
  27. package/dist/components/AuthPanel.d.ts.map +1 -0
  28. package/dist/components/AuthRegisterPanel.d.ts +34 -0
  29. package/dist/components/AuthRegisterPanel.d.ts.map +1 -0
  30. package/dist/components/AuthVisualCarousel.d.ts +20 -0
  31. package/dist/components/AuthVisualCarousel.d.ts.map +1 -0
  32. package/dist/components/DataTable.d.ts +2 -2
  33. package/dist/components/DataTable.d.ts.map +1 -1
  34. package/dist/components/ImageReader.d.ts +44 -0
  35. package/dist/components/ImageReader.d.ts.map +1 -0
  36. package/dist/components/MarkdownReader.d.ts +26 -0
  37. package/dist/components/MarkdownReader.d.ts.map +1 -0
  38. package/dist/components/PDFReader.d.ts +2 -2
  39. package/dist/components/PDFReader.d.ts.map +1 -1
  40. package/dist/components/PDFSidebar.d.ts +1 -1
  41. package/dist/components/PDFSidebar.d.ts.map +1 -1
  42. package/dist/components/SimplePDFReader.d.ts +1 -1
  43. package/dist/components/VideoReader.d.ts +39 -0
  44. package/dist/components/VideoReader.d.ts.map +1 -0
  45. package/dist/components/media-utils.d.ts +9 -0
  46. package/dist/components/media-utils.d.ts.map +1 -0
  47. package/dist/data-table.cjs +2 -0
  48. package/dist/data-table.cjs.map +1 -0
  49. package/dist/data-table.d.ts +3 -0
  50. package/dist/data-table.d.ts.map +1 -0
  51. package/dist/data-table.js +169 -0
  52. package/dist/data-table.js.map +1 -0
  53. package/dist/delete-confirm-dialog.cjs +2 -0
  54. package/dist/delete-confirm-dialog.cjs.map +1 -0
  55. package/dist/delete-confirm-dialog.d.ts +3 -0
  56. package/dist/delete-confirm-dialog.d.ts.map +1 -0
  57. package/dist/delete-confirm-dialog.js +109 -0
  58. package/dist/delete-confirm-dialog.js.map +1 -0
  59. package/dist/file-upload.cjs +2 -0
  60. package/dist/file-upload.cjs.map +1 -0
  61. package/dist/file-upload.d.ts +3 -0
  62. package/dist/file-upload.d.ts.map +1 -0
  63. package/dist/file-upload.js +354 -0
  64. package/dist/file-upload.js.map +1 -0
  65. package/dist/image-reader.cjs +2 -0
  66. package/dist/image-reader.cjs.map +1 -0
  67. package/dist/image-reader.d.ts +3 -0
  68. package/dist/image-reader.d.ts.map +1 -0
  69. package/dist/image-reader.js +214 -0
  70. package/dist/image-reader.js.map +1 -0
  71. package/dist/index.cjs +2 -0
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +10 -20
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +8 -12
  76. package/dist/index.js.map +1 -1
  77. package/dist/jsx-runtime-B4hRZ52C.js +283 -0
  78. package/dist/jsx-runtime-B4hRZ52C.js.map +1 -0
  79. package/dist/jsx-runtime-BB_1_6y_.cjs +23 -0
  80. package/dist/jsx-runtime-BB_1_6y_.cjs.map +1 -0
  81. package/dist/markdown-reader.cjs +2 -0
  82. package/dist/markdown-reader.cjs.map +1 -0
  83. package/dist/markdown-reader.d.ts +3 -0
  84. package/dist/markdown-reader.d.ts.map +1 -0
  85. package/dist/markdown-reader.js +145 -0
  86. package/dist/markdown-reader.js.map +1 -0
  87. package/dist/media-utils-5UPuocc1.js +23 -0
  88. package/dist/media-utils-5UPuocc1.js.map +1 -0
  89. package/dist/media-utils-X1dDYP9W.cjs +2 -0
  90. package/dist/media-utils-X1dDYP9W.cjs.map +1 -0
  91. package/dist/pdf-reader.cjs +2 -0
  92. package/dist/pdf-reader.cjs.map +1 -0
  93. package/dist/pdf-reader.d.ts +3 -0
  94. package/dist/pdf-reader.d.ts.map +1 -0
  95. package/dist/pdf-reader.js +427 -0
  96. package/dist/pdf-reader.js.map +1 -0
  97. package/dist/pdf-sidebar.cjs +2 -0
  98. package/dist/pdf-sidebar.cjs.map +1 -0
  99. package/dist/pdf-sidebar.d.ts +3 -0
  100. package/dist/pdf-sidebar.d.ts.map +1 -0
  101. package/dist/pdf-sidebar.js +5 -0
  102. package/dist/pdf-sidebar.js.map +1 -0
  103. package/dist/simple-pdf-reader.cjs +2 -0
  104. package/dist/simple-pdf-reader.cjs.map +1 -0
  105. package/dist/simple-pdf-reader.d.ts +3 -0
  106. package/dist/simple-pdf-reader.d.ts.map +1 -0
  107. package/dist/simple-pdf-reader.js +268 -0
  108. package/dist/simple-pdf-reader.js.map +1 -0
  109. package/dist/table-header.cjs +2 -0
  110. package/dist/table-header.cjs.map +1 -0
  111. package/dist/table-header.d.ts +3 -0
  112. package/dist/table-header.d.ts.map +1 -0
  113. package/dist/table-header.js +63 -0
  114. package/dist/table-header.js.map +1 -0
  115. package/dist/table-pagination.cjs +2 -0
  116. package/dist/table-pagination.cjs.map +1 -0
  117. package/dist/table-pagination.d.ts +3 -0
  118. package/dist/table-pagination.d.ts.map +1 -0
  119. package/dist/table-pagination.js +172 -0
  120. package/dist/table-pagination.js.map +1 -0
  121. package/dist/theme-switcher-content.cjs +2 -0
  122. package/dist/theme-switcher-content.cjs.map +1 -0
  123. package/dist/theme-switcher-content.d.ts +3 -0
  124. package/dist/theme-switcher-content.d.ts.map +1 -0
  125. package/dist/theme-switcher-content.js +103 -0
  126. package/dist/theme-switcher-content.js.map +1 -0
  127. package/dist/theme-switcher.cjs +2 -0
  128. package/dist/theme-switcher.cjs.map +1 -0
  129. package/dist/theme-switcher.d.ts +3 -0
  130. package/dist/theme-switcher.d.ts.map +1 -0
  131. package/dist/theme-switcher.js +140 -0
  132. package/dist/theme-switcher.js.map +1 -0
  133. package/dist/types/component-types.d.ts +1 -0
  134. package/dist/types/component-types.d.ts.map +1 -1
  135. package/dist/utils-B6yFEsav.js +9 -0
  136. package/dist/utils-B6yFEsav.js.map +1 -0
  137. package/dist/utils-IjLH3w2e.cjs +2 -0
  138. package/dist/utils-IjLH3w2e.cjs.map +1 -0
  139. package/dist/utils.cjs +2 -0
  140. package/dist/utils.cjs.map +1 -0
  141. package/dist/utils.d.ts +2 -0
  142. package/dist/utils.d.ts.map +1 -0
  143. package/dist/utils.js +5 -0
  144. package/dist/utils.js.map +1 -0
  145. package/dist/video-reader.cjs +2 -0
  146. package/dist/video-reader.cjs.map +1 -0
  147. package/dist/video-reader.d.ts +3 -0
  148. package/dist/video-reader.d.ts.map +1 -0
  149. package/dist/video-reader.js +158 -0
  150. package/dist/video-reader.js.map +1 -0
  151. package/package.json +191 -3
  152. package/dist/index-DJdfLA8M.js +0 -2140
  153. package/dist/index-DJdfLA8M.js.map +0 -1
  154. package/dist/index-DUxYhmkV.js +0 -18821
  155. package/dist/index-DUxYhmkV.js.map +0 -1
  156. package/dist/index-miejqTjn.cjs +0 -13
  157. package/dist/index-miejqTjn.cjs.map +0 -1
  158. package/dist/index-tIca-Q_M.cjs +0 -23
  159. package/dist/index-tIca-Q_M.cjs.map +0 -1
  160. package/dist/index.c.js +0 -2
  161. package/dist/index.c.js.map +0 -1
@@ -1,23 +0,0 @@
1
- "use strict";const Ke=require("clsx"),Je=require("tailwind-merge"),n=require("react"),F=require("lucide-react");function ke(...r){return Je.twMerge(Ke.clsx(r))}var we={exports:{}},be={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Pe;function He(){if(Pe)return be;Pe=1;var r=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function d(p,i,g){var N=null;if(g!==void 0&&(N=""+g),i.key!==void 0&&(N=""+i.key),"key"in i){g={};for(var x in i)x!=="key"&&(g[x]=i[x])}else g=i;return i=g.ref,{$$typeof:r,type:p,key:N,ref:i!==void 0?i:null,props:g}}return be.Fragment=m,be.jsx=d,be.jsxs=d,be}var ye={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Re;function Ue(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&(function(){function r(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===J?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case G:return"Fragment";case C:return"Profiler";case V:return"StrictMode";case X:return"Suspense";case z:return"SuspenseList";case K:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case U:return"Portal";case b:return s.displayName||"Context";case P:return(s._context.displayName||"Context")+".Consumer";case q:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case W:return a=s.displayName||null,a!==null?a:r(s.type)||"Memo";case B:a=s._payload,s=s._init;try{return r(s(a))}catch{}}return null}function m(s){return""+s}function d(s){try{m(s);var a=!1}catch{a=!0}if(a){a=console;var v=a.error,I=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return v.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",I),m(s)}}function p(s){if(s===G)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===B)return"<...>";try{var a=r(s);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function i(){var s=f.A;return s===null?null:s.getOwner()}function g(){return Error("react-stack-top-frame")}function N(s){if(_.call(s,"key")){var a=Object.getOwnPropertyDescriptor(s,"key").get;if(a&&a.isReactWarning)return!1}return s.key!==void 0}function x(s,a){function v(){Z||(Z=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}v.isReactWarning=!0,Object.defineProperty(s,"key",{get:v,configurable:!0})}function j(){var s=r(this.type);return oe[s]||(oe[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function k(s,a,v,I,ee,ne){var M=v.ref;return s={$$typeof:L,type:s,key:a,props:v,_owner:I},(M!==void 0?M:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:j}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function c(s,a,v,I,ee,ne){var M=a.children;if(M!==void 0)if(I)if(R(M)){for(I=0;I<M.length;I++)S(M[I]);Object.freeze&&Object.freeze(M)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else S(M);if(_.call(a,"key")){M=r(s);var H=Object.keys(a).filter(function(w){return w!=="key"});I=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",re[M+I]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
- let props = %s;
19
- <%s {...props} />
20
- React keys must be passed directly to JSX without using spread:
21
- let props = %s;
22
- <%s key={someKey} {...props} />`,I,M,H,M),re[M+I]=!0)}if(M=null,v!==void 0&&(d(v),M=""+v),N(a)&&(d(a.key),M=""+a.key),"key"in a){v={};for(var y in a)y!=="key"&&(v[y]=a[y])}else v=a;return M&&x(v,typeof s=="function"?s.displayName||s.name||"Unknown":s),k(s,M,v,i(),ee,ne)}function S(s){O(s)?s._store&&(s._store.validated=1):typeof s=="object"&&s!==null&&s.$$typeof===B&&(s._payload.status==="fulfilled"?O(s._payload.value)&&s._payload.value._store&&(s._payload.value._store.validated=1):s._store&&(s._store.validated=1))}function O(s){return typeof s=="object"&&s!==null&&s.$$typeof===L}var E=n,L=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),G=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),b=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),f=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=Object.prototype.hasOwnProperty,R=Array.isArray,D=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(s){return s()}};var Z,oe={},se=E.react_stack_bottom_frame.bind(E,g)(),Y=D(p(g)),re={};ye.Fragment=G,ye.jsx=function(s,a,v){var I=1e4>f.recentlyCreatedOwnerStacks++;return c(s,a,v,!1,I?Error("react-stack-top-frame"):se,I?D(p(s)):Y)},ye.jsxs=function(s,a,v){var I=1e4>f.recentlyCreatedOwnerStacks++;return c(s,a,v,!0,I?Error("react-stack-top-frame"):se,I?D(p(s)):Y)}})()),ye}var De;function Ze(){return De||(De=1,process.env.NODE_ENV==="production"?we.exports=He():we.exports=Ue()),we.exports}var e=Ze();function Xe({data:r,loading:m=!1,columns:d,rowKey:p,emptyText:i="暂无数据",searchActiveEmptyText:g="未找到匹配的记录",header:N,pagination:x,rowClassName:j,onRow:k,actions:c,components:S,renderCard:O,renderTable:E,renderActions:L}){var M,H;if(!S)return e.jsxs("div",{className:"p-4 text-center text-destructive",children:["错误:请通过 components prop 注入 UI 组件",e.jsx("br",{}),e.jsx("code",{className:"text-sm",children:'import { Card, Table, Button, ... } from "@/components/ui"'})]});const{Card:U,CardContent:G,CardFooter:V,Table:C,TableBody:P,TableCell:b,TableHead:q,TableHeader:X,TableRow:z,Button:W,DropdownMenu:B,DropdownMenuTrigger:K,DropdownMenuContent:J,DropdownMenuItem:f,DropdownMenuSeparator:_,Skeleton:R,TableHeaderComponent:D,TablePaginationComponent:Z}=S,oe=(y,w)=>{if(typeof p=="function")return p(y);const $=y[p];return $!=null?String($):`row-${w}`},se=!!(N!=null&&N.searchValue&&N.searchValue.trim().length>0),Y=!!(c!=null&&c.render||(M=c==null?void 0:c.items)!=null&&M.length),re=(c==null?void 0:c.mode)??((H=c==null?void 0:c.items)!=null&&H.length?"collapsed":"expanded"),s=y=>y.separator===!0,a=(y,w)=>!c||!Y?null:re==="collapsed"&&c.items&&c.items.length>0?e.jsxs(B,{children:[e.jsx(K,{asChild:!0,children:e.jsx(W,{variant:"ghost",className:"h-8 w-8 p-0","aria-label":"打开行操作菜单",children:e.jsx(F.MoreVertical,{className:"h-4 w-4"})})}),e.jsx(J,{align:"end",children:c.items.map(($,ie)=>s($)?e.jsx(_,{},`separator-${ie}`):e.jsxs(f,{onClick:()=>$.onClick(y,w),className:$.className,children:[$.icon&&e.jsx("span",{className:"mr-2 h-4 w-4",children:$.icon}),$.label]},`action-${ie}`))})]}):c.render?c.render(y,w):null,v=()=>e.jsx(X,{children:e.jsxs(z,{className:"bg-muted/50 hover:bg-muted/50",children:[d.map(y=>e.jsx(q,{className:`font-semibold text-foreground ${y.align==="center"?"text-center":y.align==="right"?"text-right":"text-left"}`,style:{width:y.width},children:y.title},String(y.key))),Y&&e.jsx(q,{className:"text-right font-semibold text-foreground",children:(c==null?void 0:c.title)||"操作"})]})}),I=()=>m?e.jsx(P,{children:Array.from({length:5}).map((y,w)=>e.jsxs(z,{children:[d.map($=>e.jsx(b,{style:{width:$.width},className:$.align==="center"?"text-center":$.align==="right"?"text-right":"",children:e.jsx(R,{className:"h-4 w-full"})},String($.key))),Y&&e.jsx(b,{children:e.jsx(R,{className:"ml-auto h-4 w-8"})})]},w))}):r.length===0?e.jsx(P,{children:e.jsx(z,{children:e.jsx(b,{colSpan:d.length+(Y?1:0),className:"py-8 text-center text-muted-foreground",children:se?g:i})})}):e.jsx(P,{children:r.map((y,w)=>{const $=oe(y,w),ie=k==null?void 0:k(y,w),le=j==null?void 0:j(y,w);return e.jsxs(z,{className:`${le||""} hover:bg-muted/50`,...ie,children:[d.map(te=>{const ue=y[te.key],de=te.render?te.render(ue,y,w):ue;return e.jsx(b,{className:te.align==="center"?"text-center":te.align==="right"?"text-right":"",children:de},String(te.key))}),Y&&e.jsx(b,{className:"text-right",children:L?L(y,w):a(y,w)})]},$)})}),ee=y=>e.jsxs(U,{children:[N&&e.jsx("div",{className:"p-6 pb-0",children:e.jsx(D,{...N})}),e.jsx(G,{className:"p-0",children:y}),(x==null?void 0:x.show)!==!1&&x&&e.jsx(V,{className:"border-t py-4",children:e.jsx(Z,{currentPage:x.currentPage,pageSize:x.pageSize,total:x.total,onPageChange:x.onPageChange,onPageSizeChange:x.onPageSizeChange,pageSizeOptions:x.pageSizeOptions,showPageSizeSelector:x.showPageSizeSelector,showJumpToPage:x.showJumpToPage,showTotal:x.showTotal,searchActive:se})})]}),ne=(y,w)=>e.jsxs(C,{children:[y,w]});return O?O(E?E(v(),I()):ne(v(),I())):ee(E?E(v(),I()):ne(v(),I()))}function Qe({open:r,onOpenChange:m,title:d,description:p,onConfirm:i,loading:g=!1,confirmText:N="确认删除",cancelText:x="取消",confirmButtonVariant:j="destructive",verification:k,components:c,loadingIcon:S}){const[O,E]=n.useState("");if(n.useEffect(()=>{r&&E("")},[r,k==null?void 0:k.targetValue]),!c)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{Dialog:L,DialogContent:U,DialogHeader:G,DialogFooter:V,DialogTitle:C,DialogDescription:P,Button:b,Input:q,Label:X}=c,z=k?O!==k.targetValue:!1,W=()=>{z||i()};return e.jsx(L,{open:r,onOpenChange:m,children:e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsx(C,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-2",children:d})}),e.jsx(P,{asChild:!0,children:e.jsx("div",{children:p})})]}),k&&e.jsx("div",{className:"space-y-4 py-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"confirm-input",children:k.label||"请输入以确认"}),e.jsx(q,{id:"confirm-input",value:O,onChange:B=>E(B.target.value),placeholder:k.placeholder,disabled:g})]})}),e.jsxs(V,{children:[e.jsx(b,{variant:"outline",onClick:()=>m(!1),disabled:g,children:x}),e.jsxs(b,{variant:j,onClick:W,disabled:z||g,children:[g&&e.jsx("span",{className:"mr-2",children:S||e.jsxs("svg",{className:"h-4 w-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),N]})]})]})})}function et({title:r,searchPlaceholder:m="搜索...",searchValue:d="",onSearchChange:p,onSearch:i,showSearch:g=!0,action:N,actionLabel:x,onActionClick:j,loading:k=!1,components:c}){if(!c)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{Input:S,Button:O}=c,E=L=>{L.key==="Enter"&&i&&i()};return e.jsxs("div",{className:"flex flex-col gap-4 p-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-lg font-semibold leading-none tracking-tight",children:r}),e.jsxs("div",{className:"flex items-center gap-2",children:[N&&e.jsx("div",{className:"flex items-center gap-2",children:N}),!N&&x&&j&&e.jsxs(O,{onClick:j,disabled:k,size:"sm",children:[e.jsx(F.Plus,{className:"mr-2 h-4 w-4"}),x]})]})]}),g&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(F.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(S,{placeholder:m,value:d,onChange:L=>p==null?void 0:p(L.target.value),onKeyPress:E,className:"h-9 pl-8",disabled:k})]}),i&&e.jsx(O,{onClick:i,disabled:k,variant:"secondary",size:"sm",children:"搜索"})]})]})}function tt({currentPage:r,pageSize:m,total:d,onPageChange:p,onPageSizeChange:i,pageSizeOptions:g=[10,20,50],showPageSizeSelector:N=!0,showJumpToPage:x=!0,showTotal:j=!0,searchActive:k=!1,components:c}){const[S,O]=n.useState(String(r+1));if(n.useEffect(()=>{O(String(r+1))},[r]),!c)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{Button:E,Select:L,SelectTrigger:U,SelectContent:G,SelectItem:V,SelectValue:C}=c,P=Math.ceil(d/m),b=Math.max(P,1),q=r*m+1,X=Math.min((r+1)*m,d),z=Array.from(new Set([...g,m])).sort((f,_)=>f-_),W=N&&!!i,B=b>1,K=f=>{const _=Math.max(0,Math.min(f,b-1));_!==r&&p(_)},J=(()=>{if(b<=7)return Array.from({length:b},(D,Z)=>Z);const f=new Set([0,1,b-2,b-1,r-1,r,r+1]),_=Array.from(f).filter(D=>D>=0&&D<b).sort((D,Z)=>D-Z),R=[];for(const D of _){const Z=R[R.length-1];typeof Z=="number"&&D-Z>1&&R.push("ellipsis"),R.push(D)}return R})();return d===0?null:e.jsxs("div",{className:`flex w-full items-center gap-3 ${j?"justify-between":"justify-end"}`,children:[j&&e.jsx("div",{className:"text-sm text-muted-foreground",children:k?`找到 ${d} 条匹配记录`:d>0?`显示 ${q} - ${X} 条,共 ${d} 条记录`:"暂无数据"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[W&&e.jsxs("div",{className:"mr-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"每页"}),e.jsxs(L,{value:String(m),onValueChange:f=>{const _=Number(f);Number.isNaN(_)||_===m||!i||i(_)},children:[e.jsx(U,{className:"h-8 w-[90px]",children:e.jsx(C,{})}),e.jsx(G,{children:z.map(f=>e.jsx(V,{value:String(f),children:f},f))})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"条"})]}),e.jsxs("div",{className:"mr-4 text-sm text-muted-foreground",children:["第 ",r+1," 页,共 ",b," 页"]}),e.jsx(E,{variant:"outline",size:"icon",onClick:()=>K(r-1),disabled:r===0||!B,"aria-label":"上一页",children:e.jsx(F.ChevronLeft,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:J.map((f,_)=>f==="ellipsis"?e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",children:"..."},`ellipsis-${_}`):e.jsx(E,{variant:f===r?"default":"outline",size:"sm",onClick:()=>K(f),disabled:f===r,"aria-current":f===r?"page":void 0,children:f+1},f))}),e.jsx(E,{variant:"outline",size:"icon",onClick:()=>K(r+1),disabled:r>=b-1||!B,"aria-label":"下一页",children:e.jsx(F.ChevronRight,{className:"h-4 w-4"})}),x&&e.jsxs("form",{className:"ml-1 flex items-center gap-2",onSubmit:f=>{f.preventDefault();const _=Number.parseInt(S,10);Number.isNaN(_)||K(_-1)},children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"跳至"}),e.jsx("input",{type:"number",min:1,max:b,value:S,disabled:!B,onChange:f=>O(f.target.value),className:"h-8 w-16 rounded-md border border-input bg-background px-2 text-sm","aria-label":"跳转页码"}),e.jsx(E,{type:"submit",variant:"outline",size:"sm",disabled:!B,children:"跳转"})]})]})]})}const st=[{value:"light",label:"浅色",icon:e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"2"}),e.jsx("path",{className:"opacity-75",d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",strokeWidth:"2",strokeLinecap:"round"})]})},{value:"dark",label:"深色",icon:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{value:"system",label:"跟随系统",icon:e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2",strokeWidth:"2"}),e.jsx("path",{d:"M8 21h8m-4-4v4",strokeWidth:"2",strokeLinecap:"round"})]})}];function rt({value:r,onValueChange:m,themes:d=st,triggerVariant:p="ghost",triggerSize:i="icon",triggerClassName:g,iconSize:N=16,showCurrentIcon:x=!0,enableSSRHandling:j=!0,triggerContent:k,components:c,themeIcons:S}){const[O,E]=n.useState(!1);if(n.useEffect(()=>{E(!0)},[]),j&&!O)return null;if(!c)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{DropdownMenu:L,DropdownMenuTrigger:U,DropdownMenuContent:G,DropdownMenuRadioGroup:V,DropdownMenuRadioItem:C,Button:P}=c,b=W=>{if(S&&S[W])return S[W];const B=d.find(K=>K.value===W);return B==null?void 0:B.icon},q=b(r),X=x?q:null,z=N?{width:N,height:N}:{};return e.jsxs(L,{children:[e.jsx(U,{asChild:!0,children:e.jsx(P,{variant:p,size:i,className:g,children:k||e.jsx("span",{style:z,className:"inline-flex items-center justify-center",children:X})})}),e.jsx(G,{children:e.jsx(V,{value:r,onValueChange:m,children:d.map(W=>e.jsxs(C,{value:W.value,children:[e.jsx("span",{className:"mr-2 inline-flex items-center",children:b(W.value)}),e.jsx("span",{children:W.label})]},W.value))})})]})}const nt=[{value:"light",label:"浅色",icon:e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"2"}),e.jsx("path",{className:"opacity-75",d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",strokeWidth:"2",strokeLinecap:"round"})]})},{value:"dark",label:"深色",icon:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{value:"system",label:"跟随系统",icon:e.jsxs("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2",strokeWidth:"2"}),e.jsx("path",{d:"M8 21h8m-4-4v4",strokeWidth:"2",strokeLinecap:"round"})]})}];function at({value:r,onValueChange:m,themes:d=nt,iconSize:p=16,components:i,themeIcons:g}){if(!i)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{DropdownMenuRadioGroup:N,DropdownMenuRadioItem:x}=i,j=c=>{if(g&&g[c])return g[c];const S=d.find(O=>O.value===c);return S==null?void 0:S.icon},k=p?{width:p,height:p}:{};return e.jsx(N,{value:r,onValueChange:m,children:d.map(c=>e.jsxs(x,{value:c.value,children:[e.jsx("span",{className:"mr-2 inline-flex items-center",style:k,children:j(c.value)}),e.jsx("span",{children:c.label})]},c.value))})}function lt({url:r,initialPage:m=1,initialScale:d=1,scale:p,onScaleChange:i,minScale:g=.5,maxScale:N=3,currentPage:x,onPageChange:j,showToolbar:k=!0,showPagination:c=!0,enableHotkeys:S=!0,className:O,containerClassName:E,pageClassName:L,components:U,onLoadSuccess:G,onLoadError:V,loadingText:C="加载中...",errorText:P="加载失败"}){const[b,q]=n.useState(null),[X,z]=n.useState(m),[W,B]=n.useState(d),[K,J]=n.useState(!0),[f,_]=n.useState(null),[R,D]=n.useState(0),[Z,oe]=n.useState(!1),se=n.useRef(null),Y=n.useRef(null),[re,s]=n.useState(null),a=x??X,v=p??W,I=n.useMemo(()=>{const t=[a];return a>1&&t.push(a-1),a<R&&t.push(a+1),t},[a,R]),ee=n.useCallback(t=>{const o=Math.max(R,1),l=Math.min(Math.max(t,1),o);x===void 0&&z(l),j==null||j(l)},[R,x,j]),ne=n.useCallback(()=>{a>1&&ee(a-1)},[a,ee]),M=n.useCallback(()=>{a<R&&ee(a+1)},[a,R,ee]),H=n.useCallback(()=>{const t=Math.min(v+.25,N);p===void 0&&B(t),i==null||i(t)},[v,N,p,i]),y=n.useCallback(()=>{const t=Math.max(v-.25,g);p===void 0&&B(t),i==null||i(t)},[v,g,p,i]),w=n.useCallback(async()=>{var t,o,l;if(!(typeof document>"u")){if(!document.fullscreenElement){await((o=(t=se.current)==null?void 0:t.requestFullscreen)==null?void 0:o.call(t));return}await((l=document.exitFullscreen)==null?void 0:l.call(document))}},[]);if(n.useEffect(()=>{let t=!0;return(async()=>{try{const l=await Promise.resolve().then(()=>require("./index-miejqTjn.cjs"));if(typeof window<"u"){const h=l.pdfjs,T=h==null?void 0:h.version;h!=null&&h.GlobalWorkerOptions&&T&&(h.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${T}/build/pdf.worker.min.mjs`)}t&&s(l)}catch(l){if(t){const h=l instanceof Error?l:new Error("无法加载 react-pdf 库");_(h),J(!1),V==null||V(h)}}})(),()=>{t=!1}},[]),n.useEffect(()=>{if(!re||!r)return;let t=!0;return(async()=>{J(!0),_(null);try{const{Document:l}=re;if(!l)throw new Error("react-pdf Document 组件不可用");const h=re.pdfjs.getDocument(r);Y.current=h;const T=await h.promise;t&&(q(T),D(T.numPages),x===void 0&&z(ce=>Math.max(1,Math.min(ce,T.numPages))),J(!1),G==null||G(T))}catch(l){if(t){const h=l instanceof Error?l:new Error("PDF 加载失败");_(h),J(!1),V==null||V(h)}}})(),()=>{t=!1,Y.current&&typeof Y.current.destroy=="function"&&(Y.current.destroy(),Y.current=null)}},[re,r,x,G,V]),n.useEffect(()=>{if(typeof document>"u")return;const t=()=>{oe(document.fullscreenElement===se.current)};return document.addEventListener("fullscreenchange",t),()=>{document.removeEventListener("fullscreenchange",t)}},[]),n.useEffect(()=>{if(!S)return;const t=o=>{const l=document.activeElement;l&&(l.tagName==="INPUT"||l.getAttribute("role")==="input")||((o.ctrlKey||o.metaKey)&&(o.key==="="||o.key==="+")?(o.preventDefault(),H()):(o.ctrlKey||o.metaKey)&&o.key==="-"?(o.preventDefault(),y()):o.key==="ArrowLeft"?(o.preventDefault(),ne()):o.key==="ArrowRight"?(o.preventDefault(),M()):(o.key==="f"||o.key==="F")&&(o.preventDefault(),w()))};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[S,H,y,ne,M,w]),!U)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{Card:$,CardContent:ie,Button:le,Input:te,Skeleton:ue}=U,de=()=>k?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{variant:"outline",size:"sm",onClick:y,disabled:v<=g,children:e.jsx(F.ZoomOut,{})}),e.jsxs("span",{className:"text-sm",children:[Math.round(v*100),"%"]}),e.jsx(le,{variant:"outline",size:"sm",onClick:H,disabled:v>=N,children:e.jsx(F.ZoomIn,{})}),e.jsx(le,{variant:"outline",size:"icon",onClick:()=>{w()},children:Z?e.jsx(F.Minimize2,{}):e.jsx(F.Maximize2,{})})]}):null,xe=()=>c?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{variant:"outline",size:"icon",onClick:ne,disabled:a<=1,children:e.jsx(F.ChevronLeft,{})}),te?e.jsx(te,{type:"number",min:1,max:Math.max(R,1),value:a,onChange:t=>ee(parseInt(t.target.value,10)||1),className:"w-16 text-center"}):e.jsx("input",{type:"number",min:1,max:Math.max(R,1),value:a,onChange:t=>ee(parseInt(t.target.value,10)||1),className:"w-16 rounded-md border border-input bg-background px-2 text-center text-sm"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["/ ",R]}),e.jsx(le,{variant:"outline",size:"icon",onClick:M,disabled:a>=R,children:e.jsx(F.ChevronRight,{})})]}):null,he=()=>!k&&!c?null:e.jsxs("div",{"data-testid":"pdf-operations-bar",className:"flex items-center justify-between gap-4 border-b px-4 py-2",children:[de(),xe()]}),ve=()=>e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 p-8",children:[e.jsx(ue,{className:"h-8 w-32"}),e.jsx(ue,{className:"h-64 w-full max-w-2xl"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C})]}),pe=()=>e.jsx("div",{className:"flex flex-col items-center justify-center space-y-4 p-8",children:e.jsxs("div",{className:"text-center text-destructive",children:[e.jsx("p",{className:"font-medium",children:P}),f&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:f.message})]})}),je=()=>{if(!re||!b)return null;const{Page:t}=re;return e.jsx("div",{className:`flex flex-col items-center justify-center ${Z?"h-[calc(100vh-56px)] overflow-auto":"overflow-visible"}`,children:I.map(o=>e.jsx("div",{className:L,style:{display:o===a?"block":"none"},children:e.jsx(t,{pdf:b,pageNumber:o,scale:v,renderTextLayer:!1,renderAnnotationLayer:!1,className:"shadow-md"})},o))})};return e.jsx("div",{ref:se,children:e.jsxs($,{className:O,children:[he(),e.jsx(ie,{className:E,children:K?ve():f?pe():je()})]})})}const Me=n.memo(({thumbnail:r,isCurrentPage:m,onClick:d})=>e.jsxs("div",{className:`flex w-full flex-col items-center rounded p-1 ${m?"bg-primary/10":""}`,children:[e.jsx("img",{src:r.url,alt:`Page ${r.pageNumber}`,className:"w-48 cursor-pointer border transition-opacity hover:opacity-80",onClick:d,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),d())},role:"button",tabIndex:0}),e.jsxs("span",{className:"mt-1 text-sm",children:["第 ",r.pageNumber," 页"]})]}));Me.displayName="PDFThumbnail";const _e=({bookmark:r,depth:m,onClick:d})=>e.jsxs("div",{style:{paddingLeft:`${m*16}px`},children:[e.jsx("button",{onClick:()=>d(r),className:"w-full rounded px-2 py-1 text-left text-sm hover:bg-primary/10 hover:text-primary",children:r.title}),r.items&&r.items.map((p,i)=>e.jsx(_e,{bookmark:p,depth:m+1,onClick:d},`${r.title}-${i}`))]});function Ae({pdfDocument:r,currentPage:m,onPageClick:d,components:p}){const[i,g]=n.useState([]),[N,x]=n.useState([]),[j,k]=n.useState(!0),{Tabs:c,TabsList:S,TabsTrigger:O,TabsContent:E,ScrollArea:L,Skeleton:U}=p;n.useEffect(()=>{(async()=>{if(!r)return;k(!0);const P=[];for(let b=1;b<=r.numPages;b++)try{const q=await r.getPage(b),X=q.getViewport({scale:.2}),z=document.createElement("canvas"),W=z.getContext("2d");if(!W)continue;z.width=X.width,z.height=X.height,await q.render({canvasContext:W,viewport:X,canvas:z}).promise,P.push({pageNumber:b,url:z.toDataURL()})}catch(q){console.error(`Error loading thumbnail for page ${b}:`,q)}g(P),k(!1)})()},[r]),n.useEffect(()=>{(async()=>{if(r)try{const P=await r.getOutline();x(P||[])}catch(P){console.error("Error loading bookmarks:",P),x([])}})()},[r]);const G=async C=>{if(r)try{let P;if(C.dest)if(typeof C.dest=="string"){const b=await r.getDestination(C.dest);b&&b[0]&&(P=await r.getPageIndex(b[0]))}else Array.isArray(C.dest)&&C.dest[0]&&(P=await r.getPageIndex(C.dest[0]));else C.pageNumber&&(P=C.pageNumber-1);typeof P=="number"&&d(P+1)}catch(P){console.error("Error navigating to bookmark:",P)}},V=()=>e.jsx("div",{className:"space-y-2 p-4",children:Array.from({length:(r==null?void 0:r.numPages)||5},(C,P)=>e.jsxs("div",{className:"flex flex-col items-center p-1",children:[e.jsx(U,{className:"h-32 w-48"}),e.jsx(U,{className:"mt-1 h-4 w-16"})]},P))});return e.jsx("div",{className:"w-64 border-r bg-muted",children:e.jsxs(c,{defaultValue:"thumbnails",children:[e.jsxs(S,{className:"w-full p-2",children:[e.jsx(O,{value:"thumbnails",className:"flex-1 bg-transparent",children:"缩略图"}),e.jsx(O,{value:"bookmarks",className:"flex-1 bg-transparent",children:"书签"})]}),e.jsx(E,{value:"thumbnails",children:e.jsx(L,{className:"h-[calc(100vh-8rem)]",children:j?V():e.jsx("div",{className:"space-y-2 p-4",children:i.map(C=>e.jsx(Me,{thumbnail:C,isCurrentPage:m===C.pageNumber,onClick:()=>d(C.pageNumber)},C.pageNumber))})})}),e.jsx(E,{value:"bookmarks",children:e.jsx(L,{className:"h-[calc(100vh-8rem)]",children:e.jsx("div",{className:"p-4",children:N.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"没有可用的书签"}):e.jsx("div",{className:"space-y-2",children:N.map((C,P)=>e.jsx(_e,{bookmark:C,depth:0,onClick:G},`${C.title}-${P}`))})})})})]})})}function it(r,m){const d=n.useRef(void 0);return n.useCallback((...p)=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>r(...p),m)},[r,m])}function ct({url:r,initialPage:m=1,initialScale:d=1,initialRotation:p=0,currentPage:i,onPageChange:g,scale:N,onScaleChange:x,rotation:j,onRotationChange:k,minScale:c=.5,maxScale:S=2.5,showToolbar:O=!0,showSidebar:E=!0,showRotation:L=!0,showModeToggle:U=!0,showFullscreen:G=!0,enableHotkeys:V=!0,enableMobileNav:C=!0,displayMode:P="scroll",className:b,toolbarClassName:q,contentClassName:X,contentHeight:z="80vh",pageClassName:W,workerUrl:B,cMapUrl:K,standardFontDataUrl:J,components:f,onLoadSuccess:_,onLoadError:R,onPageRender:D,loadingText:Z="正在加载PDF文档...",errorText:oe="PDF加载失败"}){const[se,Y]=n.useState(null),[re,s]=n.useState(m),[a,v]=n.useState(d),[I,ee]=n.useState(p),[ne,M]=n.useState(!1),[H,y]=n.useState(null),[w,$]=n.useState(0),[ie,le]=n.useState(!1),[te,ue]=n.useState(P==="scroll"),[de,xe]=n.useState(E);n.useEffect(()=>{xe(E)},[E]);const[he,ve]=n.useState(void 0),[pe,je]=n.useState(null),t=n.useRef(null),o=n.useRef(null),l=i??re,h=N??a,T=j??I,{Card:ce,CardContent:Ie,Button:fe,Input:$e,Skeleton:Fe}=f||{},Oe=n.useMemo(()=>{const u={withCredentials:!1};return K&&(u.cMapUrl=K,u.cMapPacked=!0),J&&(u.standardFontDataUrl=J),u},[K,J]);n.useEffect(()=>{let u=!0;return(async()=>{try{const ae=await Promise.resolve().then(()=>require("./index-miejqTjn.cjs"));if(typeof window<"u"){const Q=ae.pdfjs,Ne=Q==null?void 0:Q.version;Q!=null&&Q.GlobalWorkerOptions&&Ne&&(B?Q.GlobalWorkerOptions.workerSrc=B:Q.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${Ne}/build/pdf.worker.min.mjs`,!K&&Q.GlobalWorkerOptions&&(Q.GlobalWorkerOptions.cMapUrl=`https://unpkg.com/pdfjs-dist@${Ne}/cmaps/`),!J&&Q.GlobalWorkerOptions&&(Q.GlobalWorkerOptions.standardFontDataUrl=`https://unpkg.com/pdfjs-dist@${Ne}/standard_fonts/`))}u&&je(ae)}catch(ae){if(u){const Q=ae instanceof Error?ae:new Error("无法加载 react-pdf 库");y(Q),M(!1),R==null||R(Q)}}})(),()=>{u=!1}},[B,K,J,R]);const ze=n.useCallback(u=>{console.error("PDF加载失败:",u),console.error("PDF URL:",r),y(new Error(`${oe}: ${u.message||"请检查文件路径或网络连接"}`)),R==null||R(u)},[r,oe,R]),me=n.useCallback(u=>{const A=w>0?Math.max(1,Math.min(u,w)):u;i===void 0&&s(A),g==null||g(A)},[w,i,g]),ge=n.useCallback(u=>{const A=Math.max(c,Math.min(S,h+u));N===void 0&&v(A),x==null||x(A)},[h,c,S,N,x]),We=n.useCallback(()=>{const u=(T+90)%360;j===void 0&&ee(u),k==null||k(u)},[T,j,k]),Ce=it(u=>{ve(u)},100);n.useEffect(()=>{if(!o.current)return;const u=o.current,A=()=>{Ce(u.clientWidth)};A();const ae=new ResizeObserver(()=>{A()});return ae.observe(u),()=>{ae.disconnect()}},[Ce]),n.useEffect(()=>{if(!V)return;const u=A=>{(A.ctrlKey||A.metaKey)&&(A.key==="="||A.key==="+")?(A.preventDefault(),ge(.1)):(A.ctrlKey||A.metaKey)&&A.key==="-"?(A.preventDefault(),ge(-.1)):A.key==="ArrowLeft"?(A.preventDefault(),me(l-1)):A.key==="ArrowRight"&&(A.preventDefault(),me(l+1))};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[V,l,me,ge]);const Be=n.useCallback(async()=>{var u,A;if(!(typeof document>"u"))if(document.fullscreenElement)document.exitFullscreen&&(await document.exitFullscreen(),le(!1));else try{await((A=(u=t.current)==null?void 0:u.requestFullscreen)==null?void 0:A.call(u)),le(!0)}catch(ae){console.error("Error attempting to enable fullscreen:",ae)}},[]);n.useEffect(()=>{if(typeof document>"u")return;const u=()=>{le(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",u),()=>{document.removeEventListener("fullscreenchange",u)}},[]);const Le=n.useCallback(u=>{me(u),ue(!1)},[me]),Ve=()=>O?e.jsxs("div",{className:`flex items-center justify-between gap-4 border-b px-4 py-2 ${q||""}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[E&&e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>xe(!de),title:de?"隐藏侧边栏":"显示侧边栏",children:e.jsx(F.PanelLeft,{})}),e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>ge(-.1),disabled:h<=c,children:e.jsx(F.ZoomOut,{})}),e.jsxs("span",{className:"min-w-[3rem] text-center text-sm",children:[Math.round(h*100),"%"]}),e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>ge(.1),disabled:h>=S,children:e.jsx(F.ZoomIn,{})}),L&&e.jsx(fe,{variant:"outline",size:"icon",onClick:We,children:e.jsx(F.RotateCw,{})}),U&&e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>ue(!te),title:te?"单页模式":"滚动模式",children:te?e.jsx(F.ScrollText,{}):e.jsx(F.FileText,{})}),G&&e.jsx(fe,{variant:"outline",size:"icon",onClick:Be,children:ie?e.jsx(F.Minimize2,{}):e.jsx(F.Maximize2,{})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>me(l-1),disabled:l<=1,children:e.jsx(F.ChevronLeft,{})}),e.jsx($e,{type:"number",min:1,max:w,value:l,onChange:u=>me(parseInt(u.target.value)||1),className:"w-16 text-center"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["/ ",w]}),e.jsx(fe,{variant:"outline",size:"icon",onClick:()=>me(l+1),disabled:w>0&&l>=w,children:e.jsx(F.ChevronRight,{})})]})]}):null,Te=()=>e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:Z})}),Ee=()=>e.jsx("div",{className:"flex h-full min-h-[400px] items-center justify-center px-4 text-center text-destructive",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("p",{className:"mb-2 text-lg font-medium",children:"文件加载失败"}),e.jsx("p",{className:"text-sm opacity-80",children:H==null?void 0:H.message})]})}),Ye=()=>{if(!pe)return Te();const{Document:u,Page:A}=pe;return e.jsx("div",{ref:o,className:`pdf-container flex-1 overflow-y-auto ${X||""}`,children:e.jsx("div",{className:"flex min-h-full justify-center px-4",children:e.jsx(u,{file:r,onLoadError:ze,options:Oe,loading:Te(),error:Ee(),onLoadSuccess:ae=>{se||(Y(ae),$(ae.numPages),M(!1),_==null||_(ae))},children:H?Ee():te?Array.from(new Array(w),(ae,Q)=>e.jsx("div",{className:`mb-4 ${W||""}`,children:e.jsx(A,{pageNumber:Q+1,renderTextLayer:!1,renderAnnotationLayer:!1,width:he,scale:h,rotate:T,onRenderSuccess:()=>D==null?void 0:D(Q+1)})},`page_${Q+1}`)):e.jsx("div",{className:W||"",children:e.jsx(A,{pageNumber:l,renderTextLayer:!1,renderAnnotationLayer:!1,width:he,scale:h,rotate:T,onRenderSuccess:()=>D==null?void 0:D(l)})})})})})},Ge=()=>{if(!E||!de||!se)return null;const u=Ae;return e.jsx(u,{pdfDocument:se,currentPage:l,onPageClick:Le,components:{Tabs:f.Tabs,TabsList:f.TabsList,TabsTrigger:f.TabsTrigger,TabsContent:f.TabsContent,ScrollArea:f.ScrollArea,Skeleton:Fe}})},qe=()=>C?e.jsxs("div",{className:"fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 gap-2 md:hidden",children:[e.jsxs(fe,{variant:"secondary",size:"sm",onClick:()=>me(l-1),disabled:l<=1,children:[e.jsx(F.ChevronLeft,{}),e.jsx("span",{className:"ml-1",children:"上一页"})]}),e.jsxs(fe,{variant:"secondary",size:"sm",onClick:()=>me(l+1),disabled:l>=w,children:[e.jsx("span",{className:"mr-1",children:"下一页"}),e.jsx(F.ChevronRight,{})]})]}):null;if(!f)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});if(E){const u=[];if(f.Tabs||u.push("Tabs"),f.TabsList||u.push("TabsList"),f.TabsTrigger||u.push("TabsTrigger"),f.TabsContent||u.push("TabsContent"),f.ScrollArea||u.push("ScrollArea"),u.length>0){const A=u.length===1?u[0]:`${u.slice(0,-1).join("、")} 和 ${u[u.length-1]}`;return e.jsxs("div",{className:"p-4 text-center text-destructive",children:["错误:侧边栏功能需要注入 ",A," 组件"]})}}return e.jsxs("div",{ref:t,children:[e.jsxs(ce,{className:b,children:[Ve(),e.jsx(Ie,{className:"p-0",style:{height:ie?"100vh":z},children:e.jsx("div",{className:"flex h-full flex-col",children:e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[Ge(),ne?Te():H?Ee():Ye()]})})})]}),qe()]})}const ot=r=>r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:r<1024*1024*1024?`${(r/1024/1024).toFixed(1)} MB`:`${(r/1024/1024/1024).toFixed(1)} GB`,Se=r=>`${r.name}-${r.size}-${r.lastModified}-${Math.random().toString(36).slice(2)}`,ut=r=>{const m=r.lastIndexOf(".");return m>-1?r.slice(m).toLowerCase():""},dt=(r,m)=>{if(!m)return!0;const d=r.type.toLowerCase(),p=ut(r.name);return m.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?p===i:i.endsWith("/*")?d.startsWith(i.slice(0,-1)):d===i)},ft=(r,m)=>r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:m;function mt({components:r,title:m="文件上传",description:d="选择文件后开始上传,支持 Tale SDK 的直接上传和预签名上传流程。",helperText:p,accept:i,multiple:g=!1,maxFiles:N,maxSize:x,disabled:j=!1,autoUpload:k=!1,showUploadButton:c,showResetButton:S=!0,selectLabel:O="选择文件",uploadLabel:E="开始上传",retryLabel:L="重试",resetLabel:U="清空",emptyLabel:G="尚未选择文件",dropzoneLabel:V="拖拽文件到这里,或点击选择",dropzoneDescription:C="上传前会先完成文件校验,上传逻辑由业务侧注入。",uploadingText:P="上传中",successText:b="上传完成",errorText:q="上传失败",className:X,dropzoneClassName:z,listClassName:W,formatFileSize:B=ot,validateFile:K,onFilesChange:J,onUpload:f,onUploadComplete:_,onUploadError:R}){const[D,Z]=n.useState([]),[oe,se]=n.useState(!1),Y=n.useRef(null),re=c??!!f,s=g?N:1,a=D.some(t=>t.status==="ready"),v=D.some(t=>t.status==="uploading");if(n.useEffect(()=>{J==null||J(D)},[D,J]),!r)return e.jsx("div",{className:"p-4 text-center text-destructive",children:"错误:请通过 components prop 注入 UI 组件"});const{Card:I,CardHeader:ee,CardTitle:ne,CardDescription:M,CardContent:H,CardFooter:y,Button:w}=r,$=t=>{Z(o=>t(o))},ie=(t,o)=>x&&t.size>x?`文件不能超过 ${B(x)}`:dt(t,i)?K==null?void 0:K(t,o):"文件类型不符合要求",le=(t,o)=>{const l=g?[...o]:[],h=s===void 0?t.length:Math.max(s-l.length,0);return t.slice(0,h).forEach(T=>{const ce=ie(T,l);l.push({id:Se(T),file:T,name:T.name,size:T.size,type:T.type,status:ce?"error":"ready",progress:0,error:ce})}),s!==void 0&&t.length>h&&t.slice(h).forEach(T=>{l.push({id:Se(T),file:T,name:T.name,size:T.size,type:T.type,status:"error",progress:0,error:`最多只能选择 ${s} 个文件`})}),l},te=async t=>{if(!f||t.status==="uploading")return;$(l=>l.map(h=>h.id===t.id?{...h,status:"uploading",progress:h.progress||5}:h));const o=l=>{$(h=>h.map(T=>T.id===t.id?{...T,progress:Math.max(0,Math.min(100,Math.round(l)))}:T))};try{const l=await f(t,{setProgress:o}),h={...t,status:"success",progress:100,error:void 0,result:l};$(T=>T.map(ce=>ce.id===t.id?h:ce)),_==null||_(h)}catch(l){const h={...t,status:"error",progress:0,error:ft(l,q)};$(T=>T.map(ce=>ce.id===t.id?h:ce)),R==null||R(h,l)}},ue=async()=>{const t=D.filter(o=>o.status==="ready");for(const o of t)await te(o)},de=t=>{if(!t||j)return;const o=Array.from(t);$(l=>{const h=le(o,l);return k&&f&&h.filter(T=>T.status==="ready").forEach(T=>{window.setTimeout(()=>te(T),0)}),h}),Y.current&&(Y.current.value="")},xe=t=>{t.preventDefault(),se(!1),de(t.dataTransfer.files)},he=t=>{$(o=>o.filter(l=>l.id!==t))},ve=t=>{const o=ie(t.file,D.filter(l=>l.id!==t.id));if(o){$(l=>l.map(h=>h.id===t.id?{...h,error:o}:h));return}te({...t,status:"ready",error:void 0,progress:0})},pe=t=>t.status==="uploading"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-blue-600 dark:text-blue-300",children:[e.jsx(F.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),P]}):t.status==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-600 dark:text-emerald-300",children:[e.jsx(F.CheckCircle2,{className:"h-3.5 w-3.5"}),b]}):t.status==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-destructive",children:[e.jsx(F.XCircle,{className:"h-3.5 w-3.5"}),q]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"待上传"}),je=e.jsxs(e.Fragment,{children:[m&&ne&&e.jsx(ne,{children:m}),m&&!ne&&e.jsx("div",{className:"text-lg font-semibold leading-none tracking-tight",children:m}),d&&M&&e.jsx(M,{children:d}),d&&!M&&e.jsx("div",{className:"text-sm text-muted-foreground",children:d})]});return e.jsxs(I,{className:ke("overflow-hidden",X),children:[ee&&(m||d)?e.jsx(ee,{children:je}):(m||d)&&e.jsx("div",{className:"space-y-1.5 p-6",children:je}),e.jsxs(H,{className:"space-y-4",children:[e.jsx("input",{ref:Y,type:"file",accept:i,multiple:g,className:"sr-only",onChange:t=>de(t.target.files),disabled:j}),e.jsxs("div",{role:"button",tabIndex:j?-1:0,"aria-disabled":j,className:ke("flex min-h-40 cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20 px-6 py-8 text-center transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",oe&&"border-primary bg-primary/5",j&&"cursor-not-allowed opacity-60",z),onClick:()=>{var t;j||(t=Y.current)==null||t.click()},onKeyDown:t=>{var o;!j&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),(o=Y.current)==null||o.click())},onDragOver:t=>{t.preventDefault(),j||se(!0)},onDragLeave:()=>se(!1),onDrop:xe,children:[e.jsx("div",{className:"mb-3 rounded-full bg-primary/10 p-3 text-primary",children:e.jsx(F.UploadCloud,{className:"h-6 w-6"})}),e.jsx("div",{className:"text-sm font-medium",children:V}),C&&e.jsx("div",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:C}),e.jsx(w,{type:"button",size:"sm",variant:"secondary",className:"mt-4",disabled:j,onClick:t=>{var o;t.stopPropagation(),(o=Y.current)==null||o.click()},children:O})]}),p&&e.jsx("div",{className:"text-sm text-muted-foreground",children:p}),e.jsx("div",{className:ke("space-y-3",W),children:D.length===0?e.jsx("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:G}):D.map(t=>e.jsx("div",{className:"rounded-lg border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded-md bg-muted p-2 text-muted-foreground",children:e.jsx(F.FileText,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:t.name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[B(t.size),t.type?` · ${t.type}`:""]})]}),pe(t)]}),t.status==="uploading"&&e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-muted","aria-label":`${t.name} 上传进度`,role:"progressbar","aria-valuenow":t.progress,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${t.progress}%`}})}),t.error&&e.jsx("div",{className:"text-xs text-destructive",children:t.error})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.status==="error"&&f&&e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:j||v,onClick:()=>ve(t),children:L}),e.jsx(w,{type:"button",variant:"ghost",size:"icon","aria-label":`移除 ${t.name}`,disabled:j||t.status==="uploading",onClick:()=>he(t.id),children:e.jsx(F.X,{className:"h-4 w-4"})})]})]})},t.id))})]}),(re||S)&&(y?e.jsxs(y,{className:"justify-end gap-2",children:[S&&e.jsx(w,{type:"button",variant:"outline",disabled:j||v||D.length===0,onClick:()=>Z([]),children:U}),re&&e.jsx(w,{type:"button",disabled:j||v||!a||!f,onClick:ue,children:E})]}):e.jsxs("div",{className:"flex justify-end gap-2 p-6 pt-0",children:[S&&e.jsx(w,{type:"button",variant:"outline",disabled:j||v||D.length===0,onClick:()=>Z([]),children:U}),re&&e.jsx(w,{type:"button",disabled:j||v||!a||!f,onClick:ue,children:E})]}))]})}exports.DataTable=Xe;exports.DeleteConfirmDialog=Qe;exports.FileUpload=mt;exports.PDFReader=ct;exports.PDFSidebar=Ae;exports.SimplePDFReader=lt;exports.TableHeader=et;exports.TablePagination=tt;exports.ThemeSwitcher=rt;exports.ThemeSwitcherContent=at;exports.cn=ke;exports.jsxRuntimeExports=e;
23
- //# sourceMappingURL=index-tIca-Q_M.cjs.map