openlearn-next 0.4.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +26 -21
  2. package/cli-data.mjs +535 -40
  3. package/cli-doctor.mjs +456 -17
  4. package/cli.mjs +214 -12
  5. package/dist/assets/AcademicYearFilter-DUUGpDKt.js +1 -0
  6. package/dist/assets/ActivityWorkspaceWidget-5PzyxF6a.js +1 -0
  7. package/dist/assets/AdminDirectoryView-BCtmQTEK.js +5 -0
  8. package/dist/assets/AssessmentCenter-B43ojHG-.js +1 -0
  9. package/dist/assets/BatchPickerModal-CbmjInp7.js +1 -0
  10. package/dist/assets/ClassesView-DEnMaDOt.js +32 -0
  11. package/dist/assets/ClassroomCountdownWidget-CHq4983w.js +2 -0
  12. package/dist/assets/CloudDriveModal-D2t3Uyzr.js +1 -0
  13. package/dist/assets/ComputerLabView-YtnoT5Rb.js +1 -0
  14. package/dist/assets/CourseManagement-DOXyJ_j-.js +1 -0
  15. package/dist/assets/CourseWizardModal-Dbi6Caw2.js +3 -0
  16. package/dist/assets/CoursewareHubPanel-CyxDIJAF.js +1 -0
  17. package/dist/assets/Dashboard-2rLu_ZBy.js +8 -0
  18. package/dist/assets/ExportWeightModal-BrmAh6VX.js +1 -0
  19. package/dist/assets/GLTFLoader-CZJbo_y1.js +1 -0
  20. package/dist/assets/HelpTour-D_q1z_MI.js +1 -0
  21. package/dist/assets/HelpView-CVBrKDrd.js +204 -0
  22. package/dist/assets/ImportLessonsModal-PhHtX31R.js +1 -0
  23. package/dist/assets/ImportModal-DqjqNeH4.js +2 -0
  24. package/dist/assets/InteractiveCoursewareViewer-Vi6lLz7a.js +1 -0
  25. package/dist/assets/InteractiveWhiteboard-lTzeayX5.js +65 -0
  26. package/dist/assets/LazyCourseware-KIt0rGtW.js +2 -0
  27. package/dist/assets/LazyWhiteboard-CCN3pYcW.js +2 -0
  28. package/dist/assets/LessonEditorView-D_GVhHuM.js +1 -0
  29. package/dist/assets/LiveClassroomView-BRsZ6QEq.js +61 -0
  30. package/dist/assets/NotificationDetailModal-tY5rxYCN.js +1 -0
  31. package/dist/assets/OrbitControls-CQjN_uwS.js +1 -0
  32. package/dist/assets/PluginView-CedpAW6d.js +77 -0
  33. package/dist/assets/ProcessLogsModal-Cfr-T9Gd.js +1 -0
  34. package/dist/assets/QuizGeneratorModal-bUA002kP.js +1 -0
  35. package/dist/assets/StudentAssignmentView-BhAz6Hfk.js +1 -0
  36. package/dist/assets/StudentLessonView-DC1yX4kG.js +1 -0
  37. package/dist/assets/StudentView-PHKxIV9T.js +2 -0
  38. package/dist/assets/SystemResourceLibraryModal-DgXYe6_x.js +1 -0
  39. package/dist/assets/TeacherView-DscJtOJ9.js +2 -0
  40. package/dist/assets/TimetableView-D2ozoj_D.js +6 -0
  41. package/dist/assets/UTIF-FfCsrHhe.js +1 -0
  42. package/dist/assets/__vite-optional-peer-dep_ai_ooxml-ui-BIHI7g3E.js +1 -0
  43. package/dist/assets/browser-DEI0QxZC.js +1 -0
  44. package/dist/assets/html2canvas-pro.esm-Bo50djkB.js +12 -0
  45. package/dist/assets/index-2676X8YB.js +131 -0
  46. package/dist/assets/index-C6hlh8pw.css +1 -0
  47. package/dist/assets/{index.es-C5eWEO4o.js → index.es-DyEF0CZ9.js} +1 -1
  48. package/dist/assets/pluginParsers-e4PSm2Iy.js +1 -0
  49. package/dist/assets/react_pptx-react-viewer-BIHI7g3E.js +1 -0
  50. package/dist/assets/teaching-modes-client-BeVaDdJ-.js +1 -0
  51. package/dist/assets/three.module-iOYB3rD4.js +4228 -0
  52. package/dist/assets/timeline-duration-BgdJCSrW.js +1 -0
  53. package/dist/assets/{vendor-charts-qLbgF1eL.js → vendor-charts-SrpBsvM3.js} +2 -2
  54. package/dist/assets/{vendor-icons-BRmhY6fg.js → vendor-icons-CXrZ3R2V.js} +2 -2
  55. package/dist/assets/{vendor-konva-CEOq4dcl.js → vendor-konva-Dne0Z-WC.js} +1 -1
  56. package/dist/assets/{vendor-pdf-D7rGevI1.js → vendor-pdf-C1Vh2Aqq.js} +56 -56
  57. package/dist/assets/vendor-pptx-Bzn6whfK.js +11311 -0
  58. package/dist/assets/vendor-pptx-DIWdXF1L.css +1 -0
  59. package/dist/assets/{vendor-react-B0t7H3hh.js → vendor-react-Kv_JATwr.js} +1 -1
  60. package/dist/assets/vendor-utils-aM7aYvPP.js +1 -0
  61. package/dist/cli-migrator.cjs +310 -0
  62. package/dist/env-validation.cjs +351 -0
  63. package/dist/index.html +13 -10
  64. package/dist/plugin-net-preload.cjs +263 -0
  65. package/dist/server.cjs +51140 -27229
  66. package/migrations/000_initial_schema.sql +410 -0
  67. package/migrations/001_add_execution_mode.sql +6 -0
  68. package/migrations/002_add_client_session_expiry.sql +6 -0
  69. package/migrations/003_classroom_runtime.sql +33 -0
  70. package/migrations/004_courseware_score_config.sql +26 -0
  71. package/migrations/005_assignment_hub.sql +155 -0
  72. package/migrations/006_classroom_event_bus.sql +28 -0
  73. package/migrations/007_interactive_classroom.sql +119 -0
  74. package/migrations/008_teaching_modes.sql +36 -0
  75. package/migrations/009_classroom_peer_review.sql +159 -0
  76. package/migrations/010_class_groups.sql +33 -0
  77. package/migrations/011_classroom_feed.sql +34 -0
  78. package/migrations/012_auto_record_score.sql +48 -0
  79. package/migrations/013_score_source_strategy.sql +81 -0
  80. package/migrations/014_performance_indexes.sql +21 -0
  81. package/migrations/015_demo_data_registry.sql +26 -0
  82. package/migrations/016_preset_polls_and_passcode_expiry.sql +33 -0
  83. package/migrations/017_pacing_signals_segment.sql +6 -0
  84. package/migrations/018_processes_plugin_owner.sql +26 -0
  85. package/migrations/019_plugins_version.sql +61 -0
  86. package/migrations/020_upload_max_file_mb.sql +14 -0
  87. package/migrations/021_class_owner_and_password_gate.sql +11 -0
  88. package/migrations/022_plugin_public_routes.sql +14 -0
  89. package/migrations/023_encrypt_class_passcodes.sql +18 -0
  90. package/migrations/024_segment_gates.sql +37 -0
  91. package/migrations/025_assignment_lookup_indexes.sql +11 -0
  92. package/migrations/026_plugin_grants.sql +21 -0
  93. package/migrations/027_academic_year.sql +26 -0
  94. package/migrations/028_classroom_indexes.sql +14 -0
  95. package/migrations/029_clean_lesson_think_artifacts.sql +13 -0
  96. package/migrations/030_backfill_academic_year.sql +30 -0
  97. package/migrations/031_assessment_core.sql +158 -0
  98. package/migrations/032_progress_verification.sql +17 -0
  99. package/migrations/033_student_lock_mode.sql +9 -0
  100. package/migrations/034_plugin_orphan_data.sql +27 -0
  101. package/migrations/035_icebreaker_checkins.sql +26 -0
  102. package/migrations/036_student_read_notifications_created_at.sql +19 -0
  103. package/migrations/037_plugin_config_scopes.sql +40 -0
  104. package/migrations/038_assessment_ai_grading_suggestion.sql +10 -0
  105. package/migrations/039_question_bank_sharing_and_papers.sql +14 -0
  106. package/migrations/040_assignment_grade_history.sql +37 -0
  107. package/migrations/041_course_package_idempotency.sql +33 -0
  108. package/migrations/042_assignment_grade_resubmit_audit.sql +12 -0
  109. package/migrations/043_mark_sha256_passwords.sql +31 -0
  110. package/migrations/README.md +61 -0
  111. package/migrations/schema-golden.json +640 -0
  112. package/package.json +54 -28
  113. package/dist/assets/AdminDirectoryView-DY--WM5Z.js +0 -1
  114. package/dist/assets/BatchPickerModal-BpWu0Lil.js +0 -1
  115. package/dist/assets/ClassesView-KbHEqJto.js +0 -22
  116. package/dist/assets/ClassroomCountdownWidget-96WFRO9A.js +0 -2
  117. package/dist/assets/CloudDriveModal-DEQ1nkNk.js +0 -1
  118. package/dist/assets/ComputerLabView-1qWDNRQ2.js +0 -1
  119. package/dist/assets/CourseManagement-D3ZpxY0l.js +0 -1
  120. package/dist/assets/CourseWizardModal-Ck_-M8pk.js +0 -3
  121. package/dist/assets/CoursewareHubPanel-CaEizhxl.js +0 -1
  122. package/dist/assets/Dashboard-CYbpbofV.js +0 -8
  123. package/dist/assets/ExportWeightModal-DW2bu9Zz.js +0 -1
  124. package/dist/assets/HelpTour-CMJbbGne.js +0 -1
  125. package/dist/assets/HelpView-CtzdqhBq.js +0 -204
  126. package/dist/assets/ImportLessonsModal-jBuIK453.js +0 -1
  127. package/dist/assets/ImportModal-D7L-KNhZ.js +0 -1
  128. package/dist/assets/InteractiveCoursewareViewer-Bj7ahXMs.js +0 -1
  129. package/dist/assets/InteractiveWhiteboard-B7JcJvDu.js +0 -77
  130. package/dist/assets/LazyCourseware-CuiPxhDg.js +0 -2
  131. package/dist/assets/LazyWhiteboard-BJwCEZAU.js +0 -2
  132. package/dist/assets/LessonEditorView-DFrOp2qp.js +0 -1
  133. package/dist/assets/LiveClassroomView-BZ5nGee3.js +0 -59
  134. package/dist/assets/NotificationDetailModal-Baqnc5pU.js +0 -1
  135. package/dist/assets/PluginView-CCbIuZ24.js +0 -66
  136. package/dist/assets/ProcessLogsModal-DmFXg9mG.js +0 -1
  137. package/dist/assets/QuizGeneratorModal-BBEDssp7.js +0 -1
  138. package/dist/assets/StudentAssignmentView-DgIjUsXz.js +0 -1
  139. package/dist/assets/StudentLessonView-CBJbI5x6.js +0 -1
  140. package/dist/assets/StudentPreviewModal-Bh8OZs0t.js +0 -1
  141. package/dist/assets/StudentView--uGxc5TJ.js +0 -2
  142. package/dist/assets/SystemResourceLibraryModal-BVCclcqA.js +0 -1
  143. package/dist/assets/TeacherView-D4Zsc0eZ.js +0 -2
  144. package/dist/assets/TimetableView-BQG-rEb5.js +0 -6
  145. package/dist/assets/index-BKBCBKvy.js +0 -217
  146. package/dist/assets/index-CvGu7LSj.css +0 -1
  147. package/dist/assets/purify.es-CYR4BTuT.js +0 -3
  148. package/dist/assets/vendor-pptx-C5-U7ieS.js +0 -39
  149. package/dist/assets/vendor-utils-m0Urvtws.js +0 -1
@@ -0,0 +1,77 @@
1
+ import{r as K,j as e,c as Ee,g as ot,R as ve}from"./vendor-react-Kv_JATwr.js";import{c as ye,ao as lt,bg as dt,ac as Pe,T as _e,ak as ct,bS as ht,bw as Ue,X as ze,ae as ut,S as $e,z as Le,aT as ft,aA as mt,f as Ge,a3 as pt,ba as xt,U as gt,bT as Me,R as Ne,w as bt,bU as Be,a$ as yt,aX as vt,bV as wt,D as Oe,p as jt,E as et,o as Ce,b as Te,a8 as tt,ar as _t,P as st,ap as Ze,bp as kt,bW as Nt,as as zt}from"./vendor-icons-CXrZ3R2V.js";import{c as Ae}from"./vendor-pptx-Bzn6whfK.js";import{d as Ve,s as je,c as St}from"./index-2676X8YB.js";import{p as Ct}from"./pluginParsers-e4PSm2Iy.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-C1Vh2Aqq.js";import"./vendor-charts-SrpBsvM3.js";import"./vendor-motion-BFAPOs-b.js";function It({pluginId:R,lang:C}){const a=C==="zh",N=(v,j)=>a?v:j,[c,o]=K.useState(null),[h,n]=K.useState(!0),[f,p]=K.useState(!1),[k,b]=K.useState(null),[w,i]=K.useState(null),x=`/api/plugins/${encodeURIComponent(R)}/network-grants`,s=K.useCallback(async()=>{n(!0);try{const v=await fetch(x);if(v.status===403||v.status===404){p(!0);return}const j=await v.json().catch(()=>({}));if(!v.ok||j?.success===!1){p(!0);return}o({proposed:Array.isArray(j.proposed)?j.proposed:[],approved:Array.isArray(j.approved)?j.approved:[],rejected:Array.isArray(j.rejected)?j.rejected:[]}),p(!1)}catch{p(!0)}finally{n(!1)}},[x]);K.useEffect(()=>{s()},[s]);const d=K.useCallback(async v=>{b(v),i(null);try{const j=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hosts:[v]})}),P=await j.json().catch(()=>({}));(!j.ok||P?.success!==!0)&&i(P?.error||N("批准失败","Approval failed"))}catch(j){i(j?.message||N("批准失败","Approval failed"))}finally{b(null),await s()}},[x,s,N]),l=K.useCallback(async v=>{b(v),i(null);try{const j=await fetch(`${x}?host=${encodeURIComponent(v)}`,{method:"DELETE"}),P=await j.json().catch(()=>({}));(!j.ok||P?.success!==!0)&&i(P?.error||N("撤销失败","Revoke failed"))}catch(j){i(j?.message||N("撤销失败","Revoke failed"))}finally{b(null),await s()}},[x,s,N]),g=c&&(c.approved.length>0||c.proposed.length>0||c.rejected.length>0);if(f||!h&&!g)return null;if(h)return e.jsxs("div",{className:"py-4 flex items-center gap-2 text-xs text-gray-400","data-testid":"network-grants-loading",children:[e.jsx(ye,{size:14,className:"animate-spin"}),N("正在读取出站域名授权…","Loading outbound grants…")]});const y=(c?.proposed??[]).filter(v=>!(c?.approved??[]).includes(v));return e.jsxs("div",{className:"pt-4 mt-2 border-t border-gray-100","data-testid":"network-grants-panel",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(lt,{size:15,className:"text-gray-500"}),e.jsx("h4",{className:"text-sm font-medium text-gray-700",children:N("出站网络域名","Outbound network hosts")}),e.jsxs("span",{className:"text-[10px] font-mono text-gray-400 bg-gray-50 border border-gray-200 rounded px-1.5 py-0.5",children:[c?.approved.length??0," ",N("已批准","approved")]})]}),e.jsx("p",{className:"text-xs text-gray-400 mb-3 leading-relaxed",children:N("清单声明的域名只是申请,只有「已批准」的才会被运行时放行。回环、私有与保留地址永远不会被批准。","Hosts declared in the manifest are requests only; the runtime allows just the approved ones. Loopback, private and reserved addresses are never granted.")}),w&&e.jsx("div",{className:"mb-2 text-xs text-rose-600 bg-rose-50 border border-rose-100 rounded-lg px-2.5 py-1.5",role:"alert",children:w}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-emerald-700 mb-1.5 flex items-center gap-1",children:[e.jsx(dt,{size:12}),N("已批准(运行时放行)","Approved (allowed at runtime)")]}),c&&c.approved.length>0?e.jsx("ul",{className:"space-y-1",children:c.approved.map(v=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-emerald-50/60 border border-emerald-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-emerald-900 font-mono truncate",children:v}),e.jsxs("button",{type:"button",onClick:()=>void l(v),disabled:k===v,"data-testid":`revoke-${v}`,className:"text-[11px] font-bold text-rose-600 hover:text-rose-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[k===v?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(Pe,{size:11}),N("撤销","Revoke")]})]},v))}):e.jsx("p",{className:"text-xs text-gray-400 italic","data-testid":"no-approved",children:N("尚未批准任何域名 —— 该插件无法发起出站请求。","No host approved yet — this plugin cannot make outbound requests.")})]}),y.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-amber-700 mb-1.5 flex items-center gap-1",children:[e.jsx(_e,{size:12}),N("清单申请中(未生效)","Requested by manifest (not active)")]}),e.jsx("ul",{className:"space-y-1",children:y.map(v=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-amber-50/60 border border-amber-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-amber-900 font-mono truncate",children:v}),e.jsxs("button",{type:"button",onClick:()=>void d(v),disabled:k===v,"data-testid":`approve-${v}`,className:"text-[11px] font-bold text-indigo-600 hover:text-indigo-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[k===v?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(ct,{size:11}),N("批准","Approve")]})]},v))})]}),c&&c.rejected.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] font-bold text-rose-700 mb-1.5 flex items-center gap-1",children:[e.jsx(ht,{size:12}),N("不可批准","Not approvable")]}),e.jsx("ul",{className:"space-y-1","data-testid":"rejected-hosts",children:c.rejected.map(v=>e.jsxs("li",{className:"text-xs text-gray-500 leading-relaxed",children:[e.jsx("code",{className:"font-mono text-rose-700 line-through",children:v.host}),v.reason?e.jsxs("span",{className:"ml-1.5 text-gray-400",children:["— ",v.reason]}):null]},`${v.host}-${v.reason??""}`))})]})]})}function Et({pluginId:R,pluginName:C,manifestStr:a,lang:N,onClose:c}){const[o,h]=K.useState(null),[n,f]=K.useState({}),[p,k]=K.useState(!0),[b,w]=K.useState(!1),[i,x]=K.useState(null),s=K.useCallback(async()=>{k(!0);try{const j=await fetch(`/api/plugins/${encodeURIComponent(R)}/config`);if(j.ok){const P=await j.json();if(P.success){h(P.result.schema),f(P.result.values);return}}}catch{}try{const P=JSON.parse(a).configuration?.properties??{};h(P);const E={};for(const[M,T]of Object.entries(P))E[M]=T.default;f(E)}catch{h({})}k(!1)},[R,a]);K.useEffect(()=>{s().finally(()=>k(!1))},[s]);const d=async()=>{w(!0),x(null);try{const P=await(await fetch(`/api/plugins/${encodeURIComponent(R)}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json();P.success?x(N==="zh"?"✓ 已保存":"✓ Saved"):x(`✗ ${P.error}`)}catch(j){x(`✗ ${j.message}`)}w(!1)},l=(j,P)=>{f(E=>({...E,[j]:P})),x(null)},g=(j,P)=>N==="zh"?j:P,y=(j,P)=>{const E=n[j],M=P.description??"";switch(P.type){case"boolean":return e.jsxs("div",{className:"flex items-center justify-between py-2.5 border-b border-gray-100",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:j}),M&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:M})]}),e.jsx("button",{type:"button",onClick:()=>l(j,!E),className:`relative w-10 h-5 rounded-full transition-colors ${E?"bg-indigo-600":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${E?"translate-x-5":"translate-x-0.5"}`})})]},j);case"number":case"integer":return e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:j}),M&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:M}),e.jsx("input",{type:"number",step:P.type==="integer"?1:"any",min:P.minimum,max:P.maximum,value:E!=null?String(E):"",onChange:T=>{const G=T.target.value===""?void 0:Number(T.target.value);l(j,G)},className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:P.default!==void 0?String(P.default):""})]},j);default:return P.enum&&P.enum.length>0?e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:j}),M&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:M}),e.jsx("select",{value:String(E??P.default??""),onChange:T=>l(j,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none bg-white",children:P.enum.map(T=>e.jsx("option",{value:String(T),children:String(T)},String(T)))})]},j):e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:j}),M&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:M}),e.jsx("input",{type:"text",value:E!=null?String(E):"",onChange:T=>l(j,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:P.default!==void 0?String(P.default):""})]},j)}},v=o&&Object.keys(o).length>0;return e.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",onClick:c,children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-md flex flex-col max-h-[85vh]",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{size:18,className:"text-gray-500"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 text-sm",children:g("插件设置","Plugin Settings")}),e.jsx("p",{className:"text-xs text-gray-400",children:C})]})]}),e.jsx("button",{onClick:c,className:"text-gray-400 hover:text-gray-600 p-1",children:e.jsx(ze,{size:18})})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-auto",children:[p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ye,{size:24,className:"text-gray-400 animate-spin"})}):v?e.jsx("div",{className:"space-y-0.5",children:Object.entries(o).map(([j,P])=>y(j,P))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Ue,{size:32,className:"text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:g("此插件没有可配置项。","This plugin has no configurable settings.")}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:g("在 manifest.configuration 中声明配置项即可在此处显示。","Declare settings in manifest.configuration to see them here.")})]}),e.jsx(It,{pluginId:R,lang:N})]}),v&&e.jsxs("div",{className:"p-4 border-t border-gray-100 flex items-center justify-between",children:[i&&e.jsx("span",{className:`text-xs ${i.startsWith("✓")?"text-green-600":"text-red-500"}`,children:i}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx("button",{onClick:c,className:"px-4 py-2 text-xs font-medium text-gray-600 hover:bg-gray-50 rounded-lg transition-colors",children:g("取消","Cancel")}),e.jsxs("button",{onClick:d,disabled:b,className:"px-4 py-2 text-xs font-medium bg-indigo-600 text-white hover:bg-indigo-700 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[b?e.jsx(ye,{size:14,className:"animate-spin"}):e.jsx(ut,{size:14}),g("保存","Save")]})]})]})]})})}var Re={exports:{}};/*!
2
+
3
+ JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4
+ <http://stuartk.com/jszip>
5
+
6
+ (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
7
+ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
8
+
9
+ JSZip uses the library pako released under the MIT license :
10
+ https://github.com/nodeca/pako/blob/main/LICENSE
11
+ */var qe;function At(){return qe||(qe=1,(function(R,C){(function(a){R.exports=a()})(function(){return(function a(N,c,o){function h(p,k){if(!c[p]){if(!N[p]){var b=typeof Ae=="function"&&Ae;if(!k&&b)return b(p,!0);if(n)return n(p,!0);var w=new Error("Cannot find module '"+p+"'");throw w.code="MODULE_NOT_FOUND",w}var i=c[p]={exports:{}};N[p][0].call(i.exports,function(x){var s=N[p][1][x];return h(s||x)},i,i.exports,a,N,c,o)}return c[p].exports}for(var n=typeof Ae=="function"&&Ae,f=0;f<o.length;f++)h(o[f]);return h})({1:[function(a,N,c){var o=a("./utils"),h=a("./support"),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";c.encode=function(f){for(var p,k,b,w,i,x,s,d=[],l=0,g=f.length,y=g,v=o.getTypeOf(f)!=="string";l<f.length;)y=g-l,b=v?(p=f[l++],k=l<g?f[l++]:0,l<g?f[l++]:0):(p=f.charCodeAt(l++),k=l<g?f.charCodeAt(l++):0,l<g?f.charCodeAt(l++):0),w=p>>2,i=(3&p)<<4|k>>4,x=1<y?(15&k)<<2|b>>6:64,s=2<y?63&b:64,d.push(n.charAt(w)+n.charAt(i)+n.charAt(x)+n.charAt(s));return d.join("")},c.decode=function(f){var p,k,b,w,i,x,s=0,d=0,l="data:";if(f.substr(0,l.length)===l)throw new Error("Invalid base64 input, it looks like a data url.");var g,y=3*(f=f.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(f.charAt(f.length-1)===n.charAt(64)&&y--,f.charAt(f.length-2)===n.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(g=h.uint8array?new Uint8Array(0|y):new Array(0|y);s<f.length;)p=n.indexOf(f.charAt(s++))<<2|(w=n.indexOf(f.charAt(s++)))>>4,k=(15&w)<<4|(i=n.indexOf(f.charAt(s++)))>>2,b=(3&i)<<6|(x=n.indexOf(f.charAt(s++))),g[d++]=p,i!==64&&(g[d++]=k),x!==64&&(g[d++]=b);return g}},{"./support":30,"./utils":32}],2:[function(a,N,c){var o=a("./external"),h=a("./stream/DataWorker"),n=a("./stream/Crc32Probe"),f=a("./stream/DataLengthProbe");function p(k,b,w,i,x){this.compressedSize=k,this.uncompressedSize=b,this.crc32=w,this.compression=i,this.compressedContent=x}p.prototype={getContentWorker:function(){var k=new h(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new f("data_length")),b=this;return k.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),k},getCompressedWorker:function(){return new h(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},p.createWorkerFrom=function(k,b,w){return k.pipe(new n).pipe(new f("uncompressedSize")).pipe(b.compressWorker(w)).pipe(new f("compressedSize")).withStreamInfo("compression",b)},N.exports=p},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(a,N,c){var o=a("./stream/GenericWorker");c.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},c.DEFLATE=a("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(a,N,c){var o=a("./utils"),h=(function(){for(var n,f=[],p=0;p<256;p++){n=p;for(var k=0;k<8;k++)n=1&n?3988292384^n>>>1:n>>>1;f[p]=n}return f})();N.exports=function(n,f){return n!==void 0&&n.length?o.getTypeOf(n)!=="string"?(function(p,k,b,w){var i=h,x=w+b;p^=-1;for(var s=w;s<x;s++)p=p>>>8^i[255&(p^k[s])];return-1^p})(0|f,n,n.length,0):(function(p,k,b,w){var i=h,x=w+b;p^=-1;for(var s=w;s<x;s++)p=p>>>8^i[255&(p^k.charCodeAt(s))];return-1^p})(0|f,n,n.length,0):0}},{"./utils":32}],5:[function(a,N,c){c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!0,c.date=null,c.compression=null,c.compressionOptions=null,c.comment=null,c.unixPermissions=null,c.dosPermissions=null},{}],6:[function(a,N,c){var o=null;o=typeof Promise<"u"?Promise:a("lie"),N.exports={Promise:o}},{lie:37}],7:[function(a,N,c){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",h=a("pako"),n=a("./utils"),f=a("./stream/GenericWorker"),p=o?"uint8array":"array";function k(b,w){f.call(this,"FlateWorker/"+b),this._pako=null,this._pakoAction=b,this._pakoOptions=w,this.meta={}}c.magic="\b\0",n.inherits(k,f),k.prototype.processChunk=function(b){this.meta=b.meta,this._pako===null&&this._createPako(),this._pako.push(n.transformTo(p,b.data),!1)},k.prototype.flush=function(){f.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},k.prototype.cleanUp=function(){f.prototype.cleanUp.call(this),this._pako=null},k.prototype._createPako=function(){this._pako=new h[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var b=this;this._pako.onData=function(w){b.push({data:w,meta:b.meta})}},c.compressWorker=function(b){return new k("Deflate",b)},c.uncompressWorker=function(){return new k("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(a,N,c){function o(i,x){var s,d="";for(s=0;s<x;s++)d+=String.fromCharCode(255&i),i>>>=8;return d}function h(i,x,s,d,l,g){var y,v,j=i.file,P=i.compression,E=g!==p.utf8encode,M=n.transformTo("string",g(j.name)),T=n.transformTo("string",p.utf8encode(j.name)),G=j.comment,te=n.transformTo("string",g(G)),_=n.transformTo("string",p.utf8encode(G)),B=T.length!==j.name.length,r=_.length!==G.length,L="",ee="",W="",ne=j.dir,H=j.date,O={crc32:0,compressedSize:0,uncompressedSize:0};x&&!s||(O.crc32=i.crc32,O.compressedSize=i.compressedSize,O.uncompressedSize=i.uncompressedSize);var I=0;x&&(I|=8),E||!B&&!r||(I|=2048);var z=0,Q=0;ne&&(z|=16),l==="UNIX"?(Q=798,z|=(function(q,ue){var he=q;return q||(he=ue?16893:33204),(65535&he)<<16})(j.unixPermissions,ne)):(Q=20,z|=(function(q){return 63&(q||0)})(j.dosPermissions)),y=H.getUTCHours(),y<<=6,y|=H.getUTCMinutes(),y<<=5,y|=H.getUTCSeconds()/2,v=H.getUTCFullYear()-1980,v<<=4,v|=H.getUTCMonth()+1,v<<=5,v|=H.getUTCDate(),B&&(ee=o(1,1)+o(k(M),4)+T,L+="up"+o(ee.length,2)+ee),r&&(W=o(1,1)+o(k(te),4)+_,L+="uc"+o(W.length,2)+W);var Y="";return Y+=`
12
+ \0`,Y+=o(I,2),Y+=P.magic,Y+=o(y,2),Y+=o(v,2),Y+=o(O.crc32,4),Y+=o(O.compressedSize,4),Y+=o(O.uncompressedSize,4),Y+=o(M.length,2),Y+=o(L.length,2),{fileRecord:b.LOCAL_FILE_HEADER+Y+M+L,dirRecord:b.CENTRAL_FILE_HEADER+o(Q,2)+Y+o(te.length,2)+"\0\0\0\0"+o(z,4)+o(d,4)+M+L+te}}var n=a("../utils"),f=a("../stream/GenericWorker"),p=a("../utf8"),k=a("../crc32"),b=a("../signature");function w(i,x,s,d){f.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=s,this.encodeFileName=d,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}n.inherits(w,f),w.prototype.push=function(i){var x=i.meta.percent||0,s=this.entriesCount,d=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,f.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:s?(x+100*(s-d-1))/s:100}}))},w.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var x=this.streamFiles&&!i.file.dir;if(x){var s=h(i,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:s.fileRecord,meta:{percent:0}})}else this.accumulate=!0},w.prototype.closedSource=function(i){this.accumulate=!1;var x=this.streamFiles&&!i.file.dir,s=h(i,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(s.dirRecord),x)this.push({data:(function(d){return b.DATA_DESCRIPTOR+o(d.crc32,4)+o(d.compressedSize,4)+o(d.uncompressedSize,4)})(i),meta:{percent:100}});else for(this.push({data:s.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},w.prototype.flush=function(){for(var i=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var s=this.bytesWritten-i,d=(function(l,g,y,v,j){var P=n.transformTo("string",j(v));return b.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(l,2)+o(l,2)+o(g,4)+o(y,4)+o(P.length,2)+P})(this.dirRecords.length,s,i,this.zipComment,this.encodeFileName);this.push({data:d,meta:{percent:100}})},w.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},w.prototype.registerPrevious=function(i){this._sources.push(i);var x=this;return i.on("data",function(s){x.processChunk(s)}),i.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),i.on("error",function(s){x.error(s)}),this},w.prototype.resume=function(){return!!f.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},w.prototype.error=function(i){var x=this._sources;if(!f.prototype.error.call(this,i))return!1;for(var s=0;s<x.length;s++)try{x[s].error(i)}catch{}return!0},w.prototype.lock=function(){f.prototype.lock.call(this);for(var i=this._sources,x=0;x<i.length;x++)i[x].lock()},N.exports=w},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(a,N,c){var o=a("../compressions"),h=a("./ZipFileWorker");c.generateWorker=function(n,f,p){var k=new h(f.streamFiles,p,f.platform,f.encodeFileName),b=0;try{n.forEach(function(w,i){b++;var x=(function(g,y){var v=g||y,j=o[v];if(!j)throw new Error(v+" is not a valid compression method !");return j})(i.options.compression,f.compression),s=i.options.compressionOptions||f.compressionOptions||{},d=i.dir,l=i.date;i._compressWorker(x,s).withStreamInfo("file",{name:w,dir:d,date:l,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(k)}),k.entriesCount=b}catch(w){k.error(w)}return k}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(a,N,c){function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var h=new o;for(var n in this)typeof this[n]!="function"&&(h[n]=this[n]);return h}}(o.prototype=a("./object")).loadAsync=a("./load"),o.support=a("./support"),o.defaults=a("./defaults"),o.version="3.10.1",o.loadAsync=function(h,n){return new o().loadAsync(h,n)},o.external=a("./external"),N.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(a,N,c){var o=a("./utils"),h=a("./external"),n=a("./utf8"),f=a("./zipEntries"),p=a("./stream/Crc32Probe"),k=a("./nodejsUtils");function b(w){return new h.Promise(function(i,x){var s=w.decompressed.getContentWorker().pipe(new p);s.on("error",function(d){x(d)}).on("end",function(){s.streamInfo.crc32!==w.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):i()}).resume()})}N.exports=function(w,i){var x=this;return i=o.extend(i||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),k.isNode&&k.isStream(w)?h.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",w,!0,i.optimizedBinaryString,i.base64).then(function(s){var d=new f(i);return d.load(s),d}).then(function(s){var d=[h.Promise.resolve(s)],l=s.files;if(i.checkCRC32)for(var g=0;g<l.length;g++)d.push(b(l[g]));return h.Promise.all(d)}).then(function(s){for(var d=s.shift(),l=d.files,g=0;g<l.length;g++){var y=l[g],v=y.fileNameStr,j=o.resolve(y.fileNameStr);x.file(j,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:i.createFolders}),y.dir||(x.file(j).unsafeOriginalName=v)}return d.zipComment.length&&(x.comment=d.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(a,N,c){var o=a("../utils"),h=a("../stream/GenericWorker");function n(f,p){h.call(this,"Nodejs stream input adapter for "+f),this._upstreamEnded=!1,this._bindStream(p)}o.inherits(n,h),n.prototype._bindStream=function(f){var p=this;(this._stream=f).pause(),f.on("data",function(k){p.push({data:k,meta:{percent:0}})}).on("error",function(k){p.isPaused?this.generatedError=k:p.error(k)}).on("end",function(){p.isPaused?p._upstreamEnded=!0:p.end()})},n.prototype.pause=function(){return!!h.prototype.pause.call(this)&&(this._stream.pause(),!0)},n.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},N.exports=n},{"../stream/GenericWorker":28,"../utils":32}],13:[function(a,N,c){var o=a("readable-stream").Readable;function h(n,f,p){o.call(this,f),this._helper=n;var k=this;n.on("data",function(b,w){k.push(b)||k._helper.pause(),p&&p(w)}).on("error",function(b){k.emit("error",b)}).on("end",function(){k.push(null)})}a("../utils").inherits(h,o),h.prototype._read=function(){this._helper.resume()},N.exports=h},{"../utils":32,"readable-stream":16}],14:[function(a,N,c){N.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,h){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,h);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,h)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var h=new Buffer(o);return h.fill(0),h},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(a,N,c){function o(j,P,E){var M,T=n.getTypeOf(P),G=n.extend(E||{},k);G.date=G.date||new Date,G.compression!==null&&(G.compression=G.compression.toUpperCase()),typeof G.unixPermissions=="string"&&(G.unixPermissions=parseInt(G.unixPermissions,8)),G.unixPermissions&&16384&G.unixPermissions&&(G.dir=!0),G.dosPermissions&&16&G.dosPermissions&&(G.dir=!0),G.dir&&(j=l(j)),G.createFolders&&(M=d(j))&&g.call(this,M,!0);var te=T==="string"&&G.binary===!1&&G.base64===!1;E&&E.binary!==void 0||(G.binary=!te),(P instanceof b&&P.uncompressedSize===0||G.dir||!P||P.length===0)&&(G.base64=!1,G.binary=!0,P="",G.compression="STORE",T="string");var _=null;_=P instanceof b||P instanceof f?P:x.isNode&&x.isStream(P)?new s(j,P):n.prepareContent(j,P,G.binary,G.optimizedBinaryString,G.base64);var B=new w(j,_,G);this.files[j]=B}var h=a("./utf8"),n=a("./utils"),f=a("./stream/GenericWorker"),p=a("./stream/StreamHelper"),k=a("./defaults"),b=a("./compressedObject"),w=a("./zipObject"),i=a("./generate"),x=a("./nodejsUtils"),s=a("./nodejs/NodejsStreamInputAdapter"),d=function(j){j.slice(-1)==="/"&&(j=j.substring(0,j.length-1));var P=j.lastIndexOf("/");return 0<P?j.substring(0,P):""},l=function(j){return j.slice(-1)!=="/"&&(j+="/"),j},g=function(j,P){return P=P!==void 0?P:k.createFolders,j=l(j),this.files[j]||o.call(this,j,null,{dir:!0,createFolders:P}),this.files[j]};function y(j){return Object.prototype.toString.call(j)==="[object RegExp]"}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(j){var P,E,M;for(P in this.files)M=this.files[P],(E=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&j(E,M)},filter:function(j){var P=[];return this.forEach(function(E,M){j(E,M)&&P.push(M)}),P},file:function(j,P,E){if(arguments.length!==1)return j=this.root+j,o.call(this,j,P,E),this;if(y(j)){var M=j;return this.filter(function(G,te){return!te.dir&&M.test(G)})}var T=this.files[this.root+j];return T&&!T.dir?T:null},folder:function(j){if(!j)return this;if(y(j))return this.filter(function(T,G){return G.dir&&j.test(T)});var P=this.root+j,E=g.call(this,P),M=this.clone();return M.root=E.name,M},remove:function(j){j=this.root+j;var P=this.files[j];if(P||(j.slice(-1)!=="/"&&(j+="/"),P=this.files[j]),P&&!P.dir)delete this.files[j];else for(var E=this.filter(function(T,G){return G.name.slice(0,j.length)===j}),M=0;M<E.length;M++)delete this.files[E[M].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(j){var P,E={};try{if((E=n.extend(j||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:h.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");n.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var M=E.comment||this.comment||"";P=i.generateWorker(this,E,M)}catch(T){(P=new f("error")).error(T)}return new p(P,E.type||"string",E.mimeType)},generateAsync:function(j,P){return this.generateInternalStream(j).accumulate(P)},generateNodeStream:function(j,P){return(j=j||{}).type||(j.type="nodebuffer"),this.generateInternalStream(j).toNodejsStream(P)}};N.exports=v},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(a,N,c){N.exports=a("stream")},{stream:void 0}],17:[function(a,N,c){var o=a("./DataReader");function h(n){o.call(this,n);for(var f=0;f<this.data.length;f++)n[f]=255&n[f]}a("../utils").inherits(h,o),h.prototype.byteAt=function(n){return this.data[this.zero+n]},h.prototype.lastIndexOfSignature=function(n){for(var f=n.charCodeAt(0),p=n.charCodeAt(1),k=n.charCodeAt(2),b=n.charCodeAt(3),w=this.length-4;0<=w;--w)if(this.data[w]===f&&this.data[w+1]===p&&this.data[w+2]===k&&this.data[w+3]===b)return w-this.zero;return-1},h.prototype.readAndCheckSignature=function(n){var f=n.charCodeAt(0),p=n.charCodeAt(1),k=n.charCodeAt(2),b=n.charCodeAt(3),w=this.readData(4);return f===w[0]&&p===w[1]&&k===w[2]&&b===w[3]},h.prototype.readData=function(n){if(this.checkOffset(n),n===0)return[];var f=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,f},N.exports=h},{"../utils":32,"./DataReader":18}],18:[function(a,N,c){var o=a("../utils");function h(n){this.data=n,this.length=n.length,this.index=0,this.zero=0}h.prototype={checkOffset:function(n){this.checkIndex(this.index+n)},checkIndex:function(n){if(this.length<this.zero+n||n<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+n+"). Corrupted zip ?")},setIndex:function(n){this.checkIndex(n),this.index=n},skip:function(n){this.setIndex(this.index+n)},byteAt:function(){},readInt:function(n){var f,p=0;for(this.checkOffset(n),f=this.index+n-1;f>=this.index;f--)p=(p<<8)+this.byteAt(f);return this.index+=n,p},readString:function(n){return o.transformTo("string",this.readData(n))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var n=this.readInt(4);return new Date(Date.UTC(1980+(n>>25&127),(n>>21&15)-1,n>>16&31,n>>11&31,n>>5&63,(31&n)<<1))}},N.exports=h},{"../utils":32}],19:[function(a,N,c){var o=a("./Uint8ArrayReader");function h(n){o.call(this,n)}a("../utils").inherits(h,o),h.prototype.readData=function(n){this.checkOffset(n);var f=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,f},N.exports=h},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(a,N,c){var o=a("./DataReader");function h(n){o.call(this,n)}a("../utils").inherits(h,o),h.prototype.byteAt=function(n){return this.data.charCodeAt(this.zero+n)},h.prototype.lastIndexOfSignature=function(n){return this.data.lastIndexOf(n)-this.zero},h.prototype.readAndCheckSignature=function(n){return n===this.readData(4)},h.prototype.readData=function(n){this.checkOffset(n);var f=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,f},N.exports=h},{"../utils":32,"./DataReader":18}],21:[function(a,N,c){var o=a("./ArrayReader");function h(n){o.call(this,n)}a("../utils").inherits(h,o),h.prototype.readData=function(n){if(this.checkOffset(n),n===0)return new Uint8Array(0);var f=this.data.subarray(this.zero+this.index,this.zero+this.index+n);return this.index+=n,f},N.exports=h},{"../utils":32,"./ArrayReader":17}],22:[function(a,N,c){var o=a("../utils"),h=a("../support"),n=a("./ArrayReader"),f=a("./StringReader"),p=a("./NodeBufferReader"),k=a("./Uint8ArrayReader");N.exports=function(b){var w=o.getTypeOf(b);return o.checkSupport(w),w!=="string"||h.uint8array?w==="nodebuffer"?new p(b):h.uint8array?new k(o.transformTo("uint8array",b)):new n(o.transformTo("array",b)):new f(b)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(a,N,c){c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(a,N,c){var o=a("./GenericWorker"),h=a("../utils");function n(f){o.call(this,"ConvertWorker to "+f),this.destType=f}h.inherits(n,o),n.prototype.processChunk=function(f){this.push({data:h.transformTo(this.destType,f.data),meta:f.meta})},N.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(a,N,c){var o=a("./GenericWorker"),h=a("../crc32");function n(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}a("../utils").inherits(n,o),n.prototype.processChunk=function(f){this.streamInfo.crc32=h(f.data,this.streamInfo.crc32||0),this.push(f)},N.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(a,N,c){var o=a("../utils"),h=a("./GenericWorker");function n(f){h.call(this,"DataLengthProbe for "+f),this.propName=f,this.withStreamInfo(f,0)}o.inherits(n,h),n.prototype.processChunk=function(f){if(f){var p=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=p+f.data.length}h.prototype.processChunk.call(this,f)},N.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(a,N,c){var o=a("../utils"),h=a("./GenericWorker");function n(f){h.call(this,"DataWorker");var p=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,f.then(function(k){p.dataIsReady=!0,p.data=k,p.max=k&&k.length||0,p.type=o.getTypeOf(k),p.isPaused||p._tickAndRepeat()},function(k){p.error(k)})}o.inherits(n,h),n.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var f=null,p=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":f=this.data.substring(this.index,p);break;case"uint8array":f=this.data.subarray(this.index,p);break;case"array":case"nodebuffer":f=this.data.slice(this.index,p)}return this.index=p,this.push({data:f,meta:{percent:this.max?this.index/this.max*100:0}})},N.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(a,N,c){function o(h){this.name=h||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(h){this.emit("data",h)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(h){this.emit("error",h)}return!0},error:function(h){return!this.isFinished&&(this.isPaused?this.generatedError=h:(this.isFinished=!0,this.emit("error",h),this.previous&&this.previous.error(h),this.cleanUp()),!0)},on:function(h,n){return this._listeners[h].push(n),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(h,n){if(this._listeners[h])for(var f=0;f<this._listeners[h].length;f++)this._listeners[h][f].call(this,n)},pipe:function(h){return h.registerPrevious(this)},registerPrevious:function(h){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=h.streamInfo,this.mergeStreamInfo(),this.previous=h;var n=this;return h.on("data",function(f){n.processChunk(f)}),h.on("end",function(){n.end()}),h.on("error",function(f){n.error(f)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var h=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),h=!0),this.previous&&this.previous.resume(),!h},flush:function(){},processChunk:function(h){this.push(h)},withStreamInfo:function(h,n){return this.extraStreamInfo[h]=n,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var h in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,h)&&(this.streamInfo[h]=this.extraStreamInfo[h])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var h="Worker "+this.name;return this.previous?this.previous+" -> "+h:h}},N.exports=o},{}],29:[function(a,N,c){var o=a("../utils"),h=a("./ConvertWorker"),n=a("./GenericWorker"),f=a("../base64"),p=a("../support"),k=a("../external"),b=null;if(p.nodestream)try{b=a("../nodejs/NodejsStreamOutputAdapter")}catch{}function w(x,s){return new k.Promise(function(d,l){var g=[],y=x._internalType,v=x._outputType,j=x._mimeType;x.on("data",function(P,E){g.push(P),s&&s(E)}).on("error",function(P){g=[],l(P)}).on("end",function(){try{var P=(function(E,M,T){switch(E){case"blob":return o.newBlob(o.transformTo("arraybuffer",M),T);case"base64":return f.encode(M);default:return o.transformTo(E,M)}})(v,(function(E,M){var T,G=0,te=null,_=0;for(T=0;T<M.length;T++)_+=M[T].length;switch(E){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(te=new Uint8Array(_),T=0;T<M.length;T++)te.set(M[T],G),G+=M[T].length;return te;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+E+"'")}})(y,g),j);d(P)}catch(E){l(E)}g=[]}).resume()})}function i(x,s,d){var l=s;switch(s){case"blob":case"arraybuffer":l="uint8array";break;case"base64":l="string"}try{this._internalType=l,this._outputType=s,this._mimeType=d,o.checkSupport(l),this._worker=x.pipe(new h(l)),x.lock()}catch(g){this._worker=new n("error"),this._worker.error(g)}}i.prototype={accumulate:function(x){return w(this,x)},on:function(x,s){var d=this;return x==="data"?this._worker.on(x,function(l){s.call(d,l.data,l.meta)}):this._worker.on(x,function(){o.delay(s,arguments,d)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new b(this,{objectMode:this._outputType!=="nodebuffer"},x)}},N.exports=i},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(a,N,c){if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",c.nodebuffer=typeof Buffer<"u",c.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")c.blob=!1;else{var o=new ArrayBuffer(0);try{c.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var h=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);h.append(o),c.blob=h.getBlob("application/zip").size===0}catch{c.blob=!1}}}try{c.nodestream=!!a("readable-stream").Readable}catch{c.nodestream=!1}},{"readable-stream":16}],31:[function(a,N,c){for(var o=a("./utils"),h=a("./support"),n=a("./nodejsUtils"),f=a("./stream/GenericWorker"),p=new Array(256),k=0;k<256;k++)p[k]=252<=k?6:248<=k?5:240<=k?4:224<=k?3:192<=k?2:1;p[254]=p[254]=1;function b(){f.call(this,"utf-8 decode"),this.leftOver=null}function w(){f.call(this,"utf-8 encode")}c.utf8encode=function(i){return h.nodebuffer?n.newBufferFrom(i,"utf-8"):(function(x){var s,d,l,g,y,v=x.length,j=0;for(g=0;g<v;g++)(64512&(d=x.charCodeAt(g)))==55296&&g+1<v&&(64512&(l=x.charCodeAt(g+1)))==56320&&(d=65536+(d-55296<<10)+(l-56320),g++),j+=d<128?1:d<2048?2:d<65536?3:4;for(s=h.uint8array?new Uint8Array(j):new Array(j),g=y=0;y<j;g++)(64512&(d=x.charCodeAt(g)))==55296&&g+1<v&&(64512&(l=x.charCodeAt(g+1)))==56320&&(d=65536+(d-55296<<10)+(l-56320),g++),d<128?s[y++]=d:(d<2048?s[y++]=192|d>>>6:(d<65536?s[y++]=224|d>>>12:(s[y++]=240|d>>>18,s[y++]=128|d>>>12&63),s[y++]=128|d>>>6&63),s[y++]=128|63&d);return s})(i)},c.utf8decode=function(i){return h.nodebuffer?o.transformTo("nodebuffer",i).toString("utf-8"):(function(x){var s,d,l,g,y=x.length,v=new Array(2*y);for(s=d=0;s<y;)if((l=x[s++])<128)v[d++]=l;else if(4<(g=p[l]))v[d++]=65533,s+=g-1;else{for(l&=g===2?31:g===3?15:7;1<g&&s<y;)l=l<<6|63&x[s++],g--;1<g?v[d++]=65533:l<65536?v[d++]=l:(l-=65536,v[d++]=55296|l>>10&1023,v[d++]=56320|1023&l)}return v.length!==d&&(v.subarray?v=v.subarray(0,d):v.length=d),o.applyFromCharCode(v)})(i=o.transformTo(h.uint8array?"uint8array":"array",i))},o.inherits(b,f),b.prototype.processChunk=function(i){var x=o.transformTo(h.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var s=x;(x=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),x.set(s,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var d=(function(g,y){var v;for((y=y||g.length)>g.length&&(y=g.length),v=y-1;0<=v&&(192&g[v])==128;)v--;return v<0||v===0?y:v+p[g[v]]>y?v:y})(x),l=x;d!==x.length&&(h.uint8array?(l=x.subarray(0,d),this.leftOver=x.subarray(d,x.length)):(l=x.slice(0,d),this.leftOver=x.slice(d,x.length))),this.push({data:c.utf8decode(l),meta:i.meta})},b.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:c.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},c.Utf8DecodeWorker=b,o.inherits(w,f),w.prototype.processChunk=function(i){this.push({data:c.utf8encode(i.data),meta:i.meta})},c.Utf8EncodeWorker=w},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(a,N,c){var o=a("./support"),h=a("./base64"),n=a("./nodejsUtils"),f=a("./external");function p(s){return s}function k(s,d){for(var l=0;l<s.length;++l)d[l]=255&s.charCodeAt(l);return d}a("setimmediate"),c.newBlob=function(s,d){c.checkSupport("blob");try{return new Blob([s],{type:d})}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return l.append(s),l.getBlob(d)}catch{throw new Error("Bug : can't construct the Blob.")}}};var b={stringifyByChunk:function(s,d,l){var g=[],y=0,v=s.length;if(v<=l)return String.fromCharCode.apply(null,s);for(;y<v;)d==="array"||d==="nodebuffer"?g.push(String.fromCharCode.apply(null,s.slice(y,Math.min(y+l,v)))):g.push(String.fromCharCode.apply(null,s.subarray(y,Math.min(y+l,v)))),y+=l;return g.join("")},stringifyByChar:function(s){for(var d="",l=0;l<s.length;l++)d+=String.fromCharCode(s[l]);return d},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,n.allocBuffer(1)).length===1}catch{return!1}})()}};function w(s){var d=65536,l=c.getTypeOf(s),g=!0;if(l==="uint8array"?g=b.applyCanBeUsed.uint8array:l==="nodebuffer"&&(g=b.applyCanBeUsed.nodebuffer),g)for(;1<d;)try{return b.stringifyByChunk(s,l,d)}catch{d=Math.floor(d/2)}return b.stringifyByChar(s)}function i(s,d){for(var l=0;l<s.length;l++)d[l]=s[l];return d}c.applyFromCharCode=w;var x={};x.string={string:p,array:function(s){return k(s,new Array(s.length))},arraybuffer:function(s){return x.string.uint8array(s).buffer},uint8array:function(s){return k(s,new Uint8Array(s.length))},nodebuffer:function(s){return k(s,n.allocBuffer(s.length))}},x.array={string:w,array:p,arraybuffer:function(s){return new Uint8Array(s).buffer},uint8array:function(s){return new Uint8Array(s)},nodebuffer:function(s){return n.newBufferFrom(s)}},x.arraybuffer={string:function(s){return w(new Uint8Array(s))},array:function(s){return i(new Uint8Array(s),new Array(s.byteLength))},arraybuffer:p,uint8array:function(s){return new Uint8Array(s)},nodebuffer:function(s){return n.newBufferFrom(new Uint8Array(s))}},x.uint8array={string:w,array:function(s){return i(s,new Array(s.length))},arraybuffer:function(s){return s.buffer},uint8array:p,nodebuffer:function(s){return n.newBufferFrom(s)}},x.nodebuffer={string:w,array:function(s){return i(s,new Array(s.length))},arraybuffer:function(s){return x.nodebuffer.uint8array(s).buffer},uint8array:function(s){return i(s,new Uint8Array(s.length))},nodebuffer:p},c.transformTo=function(s,d){if(d=d||"",!s)return d;c.checkSupport(s);var l=c.getTypeOf(d);return x[l][s](d)},c.resolve=function(s){for(var d=s.split("/"),l=[],g=0;g<d.length;g++){var y=d[g];y==="."||y===""&&g!==0&&g!==d.length-1||(y===".."?l.pop():l.push(y))}return l.join("/")},c.getTypeOf=function(s){return typeof s=="string"?"string":Object.prototype.toString.call(s)==="[object Array]"?"array":o.nodebuffer&&n.isBuffer(s)?"nodebuffer":o.uint8array&&s instanceof Uint8Array?"uint8array":o.arraybuffer&&s instanceof ArrayBuffer?"arraybuffer":void 0},c.checkSupport=function(s){if(!o[s.toLowerCase()])throw new Error(s+" is not supported by this platform")},c.MAX_VALUE_16BITS=65535,c.MAX_VALUE_32BITS=-1,c.pretty=function(s){var d,l,g="";for(l=0;l<(s||"").length;l++)g+="\\x"+((d=s.charCodeAt(l))<16?"0":"")+d.toString(16).toUpperCase();return g},c.delay=function(s,d,l){setImmediate(function(){s.apply(l||null,d||[])})},c.inherits=function(s,d){function l(){}l.prototype=d.prototype,s.prototype=new l},c.extend=function(){var s,d,l={};for(s=0;s<arguments.length;s++)for(d in arguments[s])Object.prototype.hasOwnProperty.call(arguments[s],d)&&l[d]===void 0&&(l[d]=arguments[s][d]);return l},c.prepareContent=function(s,d,l,g,y){return f.Promise.resolve(d).then(function(v){return o.blob&&(v instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(v))!==-1)&&typeof FileReader<"u"?new f.Promise(function(j,P){var E=new FileReader;E.onload=function(M){j(M.target.result)},E.onerror=function(M){P(M.target.error)},E.readAsArrayBuffer(v)}):v}).then(function(v){var j=c.getTypeOf(v);return j?(j==="arraybuffer"?v=c.transformTo("uint8array",v):j==="string"&&(y?v=h.decode(v):l&&g!==!0&&(v=(function(P){return k(P,o.uint8array?new Uint8Array(P.length):new Array(P.length))})(v))),v):f.Promise.reject(new Error("Can't read the data of '"+s+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(a,N,c){var o=a("./reader/readerFor"),h=a("./utils"),n=a("./signature"),f=a("./zipEntry"),p=a("./support");function k(b){this.files=[],this.loadOptions=b}k.prototype={checkSignature:function(b){if(!this.reader.readAndCheckSignature(b)){this.reader.index-=4;var w=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+h.pretty(w)+", expected "+h.pretty(b)+")")}},isSignature:function(b,w){var i=this.reader.index;this.reader.setIndex(b);var x=this.reader.readString(4)===w;return this.reader.setIndex(i),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var b=this.reader.readData(this.zipCommentLength),w=p.uint8array?"uint8array":"array",i=h.transformTo(w,b);this.zipComment=this.loadOptions.decodeFileName(i)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var b,w,i,x=this.zip64EndOfCentralSize-44;0<x;)b=this.reader.readInt(2),w=this.reader.readInt(4),i=this.reader.readData(w),this.zip64ExtensibleData[b]={id:b,length:w,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var b,w;for(b=0;b<this.files.length;b++)w=this.files[b],this.reader.setIndex(w.localHeaderOffset),this.checkSignature(n.LOCAL_FILE_HEADER),w.readLocalPart(this.reader),w.handleUTF8(),w.processAttributes()},readCentralDir:function(){var b;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(n.CENTRAL_FILE_HEADER);)(b=new f({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(b);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var b=this.reader.lastIndexOfSignature(n.CENTRAL_DIRECTORY_END);if(b<0)throw this.isSignature(0,n.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(b);var w=b;if(this.checkSignature(n.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===h.MAX_VALUE_16BITS||this.diskWithCentralDirStart===h.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===h.MAX_VALUE_16BITS||this.centralDirRecords===h.MAX_VALUE_16BITS||this.centralDirSize===h.MAX_VALUE_32BITS||this.centralDirOffset===h.MAX_VALUE_32BITS){if(this.zip64=!0,(b=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(b),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,n.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var x=w-i;if(0<x)this.isSignature(w,n.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(b){this.reader=o(b)},load:function(b){this.prepareReader(b),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},N.exports=k},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(a,N,c){var o=a("./reader/readerFor"),h=a("./utils"),n=a("./compressedObject"),f=a("./crc32"),p=a("./utf8"),k=a("./compressions"),b=a("./support");function w(i,x){this.options=i,this.loadOptions=x}w.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(i){var x,s;if(i.skip(22),this.fileNameLength=i.readInt(2),s=i.readInt(2),this.fileName=i.readData(this.fileNameLength),i.skip(s),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(d){for(var l in k)if(Object.prototype.hasOwnProperty.call(k,l)&&k[l].magic===d)return k[l];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+h.pretty(this.compressionMethod)+" unknown (inner file : "+h.transformTo("string",this.fileName)+")");this.decompressed=new n(this.compressedSize,this.uncompressedSize,this.crc32,x,i.readData(this.compressedSize))},readCentralPart:function(i){this.versionMadeBy=i.readInt(2),i.skip(2),this.bitFlag=i.readInt(2),this.compressionMethod=i.readString(2),this.date=i.readDate(),this.crc32=i.readInt(4),this.compressedSize=i.readInt(4),this.uncompressedSize=i.readInt(4);var x=i.readInt(2);if(this.extraFieldsLength=i.readInt(2),this.fileCommentLength=i.readInt(2),this.diskNumberStart=i.readInt(2),this.internalFileAttributes=i.readInt(2),this.externalFileAttributes=i.readInt(4),this.localHeaderOffset=i.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");i.skip(x),this.readExtraFields(i),this.parseZIP64ExtraField(i),this.fileComment=i.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var i=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=o(this.extraFields[1].value);this.uncompressedSize===h.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===h.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===h.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===h.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var x,s,d,l=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4<l;)x=i.readInt(2),s=i.readInt(2),d=i.readData(s),this.extraFields[x]={id:x,length:s,value:d};i.setIndex(l)},handleUTF8:function(){var i=b.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=p.utf8decode(this.fileName),this.fileCommentStr=p.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var s=h.transformTo(i,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(s)}var d=this.findExtraFieldUnicodeComment();if(d!==null)this.fileCommentStr=d;else{var l=h.transformTo(i,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(l)}}},findExtraFieldUnicodePath:function(){var i=this.extraFields[28789];if(i){var x=o(i.value);return x.readInt(1)!==1||f(this.fileName)!==x.readInt(4)?null:p.utf8decode(x.readData(i.length-5))}return null},findExtraFieldUnicodeComment:function(){var i=this.extraFields[25461];if(i){var x=o(i.value);return x.readInt(1)!==1||f(this.fileComment)!==x.readInt(4)?null:p.utf8decode(x.readData(i.length-5))}return null}},N.exports=w},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(a,N,c){function o(x,s,d){this.name=x,this.dir=d.dir,this.date=d.date,this.comment=d.comment,this.unixPermissions=d.unixPermissions,this.dosPermissions=d.dosPermissions,this._data=s,this._dataBinary=d.binary,this.options={compression:d.compression,compressionOptions:d.compressionOptions}}var h=a("./stream/StreamHelper"),n=a("./stream/DataWorker"),f=a("./utf8"),p=a("./compressedObject"),k=a("./stream/GenericWorker");o.prototype={internalStream:function(x){var s=null,d="string";try{if(!x)throw new Error("No output type specified.");var l=(d=x.toLowerCase())==="string"||d==="text";d!=="binarystring"&&d!=="text"||(d="string"),s=this._decompressWorker();var g=!this._dataBinary;g&&!l&&(s=s.pipe(new f.Utf8EncodeWorker)),!g&&l&&(s=s.pipe(new f.Utf8DecodeWorker))}catch(y){(s=new k("error")).error(y)}return new h(s,d,"")},async:function(x,s){return this.internalStream(x).accumulate(s)},nodeStream:function(x,s){return this.internalStream(x||"nodebuffer").toNodejsStream(s)},_compressWorker:function(x,s){if(this._data instanceof p&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var d=this._decompressWorker();return this._dataBinary||(d=d.pipe(new f.Utf8EncodeWorker)),p.createWorkerFrom(d,x,s)},_decompressWorker:function(){return this._data instanceof p?this._data.getContentWorker():this._data instanceof k?this._data:new n(this._data)}};for(var b=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],w=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},i=0;i<b.length;i++)o.prototype[b[i]]=w;N.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(a,N,c){(function(o){var h,n,f=o.MutationObserver||o.WebKitMutationObserver;if(f){var p=0,k=new f(x),b=o.document.createTextNode("");k.observe(b,{characterData:!0}),h=function(){b.data=p=++p%2}}else if(o.setImmediate||o.MessageChannel===void 0)h="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var s=o.document.createElement("script");s.onreadystatechange=function(){x(),s.onreadystatechange=null,s.parentNode.removeChild(s),s=null},o.document.documentElement.appendChild(s)}:function(){setTimeout(x,0)};else{var w=new o.MessageChannel;w.port1.onmessage=x,h=function(){w.port2.postMessage(0)}}var i=[];function x(){var s,d;n=!0;for(var l=i.length;l;){for(d=i,i=[],s=-1;++s<l;)d[s]();l=i.length}n=!1}N.exports=function(s){i.push(s)!==1||n||h()}}).call(this,typeof Ee<"u"?Ee:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(a,N,c){var o=a("immediate");function h(){}var n={},f=["REJECTED"],p=["FULFILLED"],k=["PENDING"];function b(l){if(typeof l!="function")throw new TypeError("resolver must be a function");this.state=k,this.queue=[],this.outcome=void 0,l!==h&&s(this,l)}function w(l,g,y){this.promise=l,typeof g=="function"&&(this.onFulfilled=g,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function i(l,g,y){o(function(){var v;try{v=g(y)}catch(j){return n.reject(l,j)}v===l?n.reject(l,new TypeError("Cannot resolve promise with itself")):n.resolve(l,v)})}function x(l){var g=l&&l.then;if(l&&(typeof l=="object"||typeof l=="function")&&typeof g=="function")return function(){g.apply(l,arguments)}}function s(l,g){var y=!1;function v(E){y||(y=!0,n.reject(l,E))}function j(E){y||(y=!0,n.resolve(l,E))}var P=d(function(){g(j,v)});P.status==="error"&&v(P.value)}function d(l,g){var y={};try{y.value=l(g),y.status="success"}catch(v){y.status="error",y.value=v}return y}(N.exports=b).prototype.finally=function(l){if(typeof l!="function")return this;var g=this.constructor;return this.then(function(y){return g.resolve(l()).then(function(){return y})},function(y){return g.resolve(l()).then(function(){throw y})})},b.prototype.catch=function(l){return this.then(null,l)},b.prototype.then=function(l,g){if(typeof l!="function"&&this.state===p||typeof g!="function"&&this.state===f)return this;var y=new this.constructor(h);return this.state!==k?i(y,this.state===p?l:g,this.outcome):this.queue.push(new w(y,l,g)),y},w.prototype.callFulfilled=function(l){n.resolve(this.promise,l)},w.prototype.otherCallFulfilled=function(l){i(this.promise,this.onFulfilled,l)},w.prototype.callRejected=function(l){n.reject(this.promise,l)},w.prototype.otherCallRejected=function(l){i(this.promise,this.onRejected,l)},n.resolve=function(l,g){var y=d(x,g);if(y.status==="error")return n.reject(l,y.value);var v=y.value;if(v)s(l,v);else{l.state=p,l.outcome=g;for(var j=-1,P=l.queue.length;++j<P;)l.queue[j].callFulfilled(g)}return l},n.reject=function(l,g){l.state=f,l.outcome=g;for(var y=-1,v=l.queue.length;++y<v;)l.queue[y].callRejected(g);return l},b.resolve=function(l){return l instanceof this?l:n.resolve(new this(h),l)},b.reject=function(l){var g=new this(h);return n.reject(g,l)},b.all=function(l){var g=this;if(Object.prototype.toString.call(l)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=l.length,v=!1;if(!y)return this.resolve([]);for(var j=new Array(y),P=0,E=-1,M=new this(h);++E<y;)T(l[E],E);return M;function T(G,te){g.resolve(G).then(function(_){j[te]=_,++P!==y||v||(v=!0,n.resolve(M,j))},function(_){v||(v=!0,n.reject(M,_))})}},b.race=function(l){var g=this;if(Object.prototype.toString.call(l)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=l.length,v=!1;if(!y)return this.resolve([]);for(var j=-1,P=new this(h);++j<y;)E=l[j],g.resolve(E).then(function(M){v||(v=!0,n.resolve(P,M))},function(M){v||(v=!0,n.reject(P,M))});var E;return P}},{immediate:36}],38:[function(a,N,c){var o={};(0,a("./lib/utils/common").assign)(o,a("./lib/deflate"),a("./lib/inflate"),a("./lib/zlib/constants")),N.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(a,N,c){var o=a("./zlib/deflate"),h=a("./utils/common"),n=a("./utils/strings"),f=a("./zlib/messages"),p=a("./zlib/zstream"),k=Object.prototype.toString,b=0,w=-1,i=0,x=8;function s(l){if(!(this instanceof s))return new s(l);this.options=h.assign({level:w,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:i,to:""},l||{});var g=this.options;g.raw&&0<g.windowBits?g.windowBits=-g.windowBits:g.gzip&&0<g.windowBits&&g.windowBits<16&&(g.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new p,this.strm.avail_out=0;var y=o.deflateInit2(this.strm,g.level,g.method,g.windowBits,g.memLevel,g.strategy);if(y!==b)throw new Error(f[y]);if(g.header&&o.deflateSetHeader(this.strm,g.header),g.dictionary){var v;if(v=typeof g.dictionary=="string"?n.string2buf(g.dictionary):k.call(g.dictionary)==="[object ArrayBuffer]"?new Uint8Array(g.dictionary):g.dictionary,(y=o.deflateSetDictionary(this.strm,v))!==b)throw new Error(f[y]);this._dict_set=!0}}function d(l,g){var y=new s(g);if(y.push(l,!0),y.err)throw y.msg||f[y.err];return y.result}s.prototype.push=function(l,g){var y,v,j=this.strm,P=this.options.chunkSize;if(this.ended)return!1;v=g===~~g?g:g===!0?4:0,typeof l=="string"?j.input=n.string2buf(l):k.call(l)==="[object ArrayBuffer]"?j.input=new Uint8Array(l):j.input=l,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new h.Buf8(P),j.next_out=0,j.avail_out=P),(y=o.deflate(j,v))!==1&&y!==b)return this.onEnd(y),!(this.ended=!0);j.avail_out!==0&&(j.avail_in!==0||v!==4&&v!==2)||(this.options.to==="string"?this.onData(n.buf2binstring(h.shrinkBuf(j.output,j.next_out))):this.onData(h.shrinkBuf(j.output,j.next_out)))}while((0<j.avail_in||j.avail_out===0)&&y!==1);return v===4?(y=o.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===b):v!==2||(this.onEnd(b),!(j.avail_out=0))},s.prototype.onData=function(l){this.chunks.push(l)},s.prototype.onEnd=function(l){l===b&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=h.flattenChunks(this.chunks)),this.chunks=[],this.err=l,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=function(l,g){return(g=g||{}).raw=!0,d(l,g)},c.gzip=function(l,g){return(g=g||{}).gzip=!0,d(l,g)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(a,N,c){var o=a("./zlib/inflate"),h=a("./utils/common"),n=a("./utils/strings"),f=a("./zlib/constants"),p=a("./zlib/messages"),k=a("./zlib/zstream"),b=a("./zlib/gzheader"),w=Object.prototype.toString;function i(s){if(!(this instanceof i))return new i(s);this.options=h.assign({chunkSize:16384,windowBits:0,to:""},s||{});var d=this.options;d.raw&&0<=d.windowBits&&d.windowBits<16&&(d.windowBits=-d.windowBits,d.windowBits===0&&(d.windowBits=-15)),!(0<=d.windowBits&&d.windowBits<16)||s&&s.windowBits||(d.windowBits+=32),15<d.windowBits&&d.windowBits<48&&(15&d.windowBits)==0&&(d.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var l=o.inflateInit2(this.strm,d.windowBits);if(l!==f.Z_OK)throw new Error(p[l]);this.header=new b,o.inflateGetHeader(this.strm,this.header)}function x(s,d){var l=new i(d);if(l.push(s,!0),l.err)throw l.msg||p[l.err];return l.result}i.prototype.push=function(s,d){var l,g,y,v,j,P,E=this.strm,M=this.options.chunkSize,T=this.options.dictionary,G=!1;if(this.ended)return!1;g=d===~~d?d:d===!0?f.Z_FINISH:f.Z_NO_FLUSH,typeof s=="string"?E.input=n.binstring2buf(s):w.call(s)==="[object ArrayBuffer]"?E.input=new Uint8Array(s):E.input=s,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new h.Buf8(M),E.next_out=0,E.avail_out=M),(l=o.inflate(E,f.Z_NO_FLUSH))===f.Z_NEED_DICT&&T&&(P=typeof T=="string"?n.string2buf(T):w.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,l=o.inflateSetDictionary(this.strm,P)),l===f.Z_BUF_ERROR&&G===!0&&(l=f.Z_OK,G=!1),l!==f.Z_STREAM_END&&l!==f.Z_OK)return this.onEnd(l),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&l!==f.Z_STREAM_END&&(E.avail_in!==0||g!==f.Z_FINISH&&g!==f.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=n.utf8border(E.output,E.next_out),v=E.next_out-y,j=n.buf2string(E.output,y),E.next_out=v,E.avail_out=M-v,v&&h.arraySet(E.output,E.output,y,v,0),this.onData(j)):this.onData(h.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(G=!0)}while((0<E.avail_in||E.avail_out===0)&&l!==f.Z_STREAM_END);return l===f.Z_STREAM_END&&(g=f.Z_FINISH),g===f.Z_FINISH?(l=o.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,l===f.Z_OK):g!==f.Z_SYNC_FLUSH||(this.onEnd(f.Z_OK),!(E.avail_out=0))},i.prototype.onData=function(s){this.chunks.push(s)},i.prototype.onEnd=function(s){s===f.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=h.flattenChunks(this.chunks)),this.chunks=[],this.err=s,this.msg=this.strm.msg},c.Inflate=i,c.inflate=x,c.inflateRaw=function(s,d){return(d=d||{}).raw=!0,x(s,d)},c.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(a,N,c){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";c.assign=function(f){for(var p=Array.prototype.slice.call(arguments,1);p.length;){var k=p.shift();if(k){if(typeof k!="object")throw new TypeError(k+"must be non-object");for(var b in k)k.hasOwnProperty(b)&&(f[b]=k[b])}}return f},c.shrinkBuf=function(f,p){return f.length===p?f:f.subarray?f.subarray(0,p):(f.length=p,f)};var h={arraySet:function(f,p,k,b,w){if(p.subarray&&f.subarray)f.set(p.subarray(k,k+b),w);else for(var i=0;i<b;i++)f[w+i]=p[k+i]},flattenChunks:function(f){var p,k,b,w,i,x;for(p=b=0,k=f.length;p<k;p++)b+=f[p].length;for(x=new Uint8Array(b),p=w=0,k=f.length;p<k;p++)i=f[p],x.set(i,w),w+=i.length;return x}},n={arraySet:function(f,p,k,b,w){for(var i=0;i<b;i++)f[w+i]=p[k+i]},flattenChunks:function(f){return[].concat.apply([],f)}};c.setTyped=function(f){f?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,h)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,n))},c.setTyped(o)},{}],42:[function(a,N,c){var o=a("./common"),h=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch{h=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{n=!1}for(var f=new o.Buf8(256),p=0;p<256;p++)f[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;function k(b,w){if(w<65537&&(b.subarray&&n||!b.subarray&&h))return String.fromCharCode.apply(null,o.shrinkBuf(b,w));for(var i="",x=0;x<w;x++)i+=String.fromCharCode(b[x]);return i}f[254]=f[254]=1,c.string2buf=function(b){var w,i,x,s,d,l=b.length,g=0;for(s=0;s<l;s++)(64512&(i=b.charCodeAt(s)))==55296&&s+1<l&&(64512&(x=b.charCodeAt(s+1)))==56320&&(i=65536+(i-55296<<10)+(x-56320),s++),g+=i<128?1:i<2048?2:i<65536?3:4;for(w=new o.Buf8(g),s=d=0;d<g;s++)(64512&(i=b.charCodeAt(s)))==55296&&s+1<l&&(64512&(x=b.charCodeAt(s+1)))==56320&&(i=65536+(i-55296<<10)+(x-56320),s++),i<128?w[d++]=i:(i<2048?w[d++]=192|i>>>6:(i<65536?w[d++]=224|i>>>12:(w[d++]=240|i>>>18,w[d++]=128|i>>>12&63),w[d++]=128|i>>>6&63),w[d++]=128|63&i);return w},c.buf2binstring=function(b){return k(b,b.length)},c.binstring2buf=function(b){for(var w=new o.Buf8(b.length),i=0,x=w.length;i<x;i++)w[i]=b.charCodeAt(i);return w},c.buf2string=function(b,w){var i,x,s,d,l=w||b.length,g=new Array(2*l);for(i=x=0;i<l;)if((s=b[i++])<128)g[x++]=s;else if(4<(d=f[s]))g[x++]=65533,i+=d-1;else{for(s&=d===2?31:d===3?15:7;1<d&&i<l;)s=s<<6|63&b[i++],d--;1<d?g[x++]=65533:s<65536?g[x++]=s:(s-=65536,g[x++]=55296|s>>10&1023,g[x++]=56320|1023&s)}return k(g,x)},c.utf8border=function(b,w){var i;for((w=w||b.length)>b.length&&(w=b.length),i=w-1;0<=i&&(192&b[i])==128;)i--;return i<0||i===0?w:i+f[b[i]]>w?i:w}},{"./common":41}],43:[function(a,N,c){N.exports=function(o,h,n,f){for(var p=65535&o|0,k=o>>>16&65535|0,b=0;n!==0;){for(n-=b=2e3<n?2e3:n;k=k+(p=p+h[f++]|0)|0,--b;);p%=65521,k%=65521}return p|k<<16|0}},{}],44:[function(a,N,c){N.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(a,N,c){var o=(function(){for(var h,n=[],f=0;f<256;f++){h=f;for(var p=0;p<8;p++)h=1&h?3988292384^h>>>1:h>>>1;n[f]=h}return n})();N.exports=function(h,n,f,p){var k=o,b=p+f;h^=-1;for(var w=p;w<b;w++)h=h>>>8^k[255&(h^n[w])];return-1^h}},{}],46:[function(a,N,c){var o,h=a("../utils/common"),n=a("./trees"),f=a("./adler32"),p=a("./crc32"),k=a("./messages"),b=0,w=4,i=0,x=-2,s=-1,d=4,l=2,g=8,y=9,v=286,j=30,P=19,E=2*v+1,M=15,T=3,G=258,te=G+T+1,_=42,B=113,r=1,L=2,ee=3,W=4;function ne(t,$){return t.msg=k[$],$}function H(t){return(t<<1)-(4<t?9:0)}function O(t){for(var $=t.length;0<=--$;)t[$]=0}function I(t){var $=t.state,D=$.pending;D>t.avail_out&&(D=t.avail_out),D!==0&&(h.arraySet(t.output,$.pending_buf,$.pending_out,D,t.next_out),t.next_out+=D,$.pending_out+=D,t.total_out+=D,t.avail_out-=D,$.pending-=D,$.pending===0&&($.pending_out=0))}function z(t,$){n._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,$),t.block_start=t.strstart,I(t.strm)}function Q(t,$){t.pending_buf[t.pending++]=$}function Y(t,$){t.pending_buf[t.pending++]=$>>>8&255,t.pending_buf[t.pending++]=255&$}function q(t,$){var D,m,u=t.max_chain_length,S=t.strstart,F=t.prev_length,U=t.nice_match,A=t.strstart>t.w_size-te?t.strstart-(t.w_size-te):0,V=t.window,X=t.w_mask,J=t.prev,se=t.strstart+G,fe=V[S+F-1],oe=V[S+F];t.prev_length>=t.good_match&&(u>>=2),U>t.lookahead&&(U=t.lookahead);do if(V[(D=$)+F]===oe&&V[D+F-1]===fe&&V[D]===V[S]&&V[++D]===V[S+1]){S+=2,D++;do;while(V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&V[++S]===V[++D]&&S<se);if(m=G-(se-S),S=se-G,F<m){if(t.match_start=$,U<=(F=m))break;fe=V[S+F-1],oe=V[S+F]}}while(($=J[$&X])>A&&--u!=0);return F<=t.lookahead?F:t.lookahead}function ue(t){var $,D,m,u,S,F,U,A,V,X,J=t.w_size;do{if(u=t.window_size-t.lookahead-t.strstart,t.strstart>=J+(J-te)){for(h.arraySet(t.window,t.window,J,J,0),t.match_start-=J,t.strstart-=J,t.block_start-=J,$=D=t.hash_size;m=t.head[--$],t.head[$]=J<=m?m-J:0,--D;);for($=D=J;m=t.prev[--$],t.prev[$]=J<=m?m-J:0,--D;);u+=J}if(t.strm.avail_in===0)break;if(F=t.strm,U=t.window,A=t.strstart+t.lookahead,V=u,X=void 0,X=F.avail_in,V<X&&(X=V),D=X===0?0:(F.avail_in-=X,h.arraySet(U,F.input,F.next_in,X,A),F.state.wrap===1?F.adler=f(F.adler,U,X,A):F.state.wrap===2&&(F.adler=p(F.adler,U,X,A)),F.next_in+=X,F.total_in+=X,X),t.lookahead+=D,t.lookahead+t.insert>=T)for(S=t.strstart-t.insert,t.ins_h=t.window[S],t.ins_h=(t.ins_h<<t.hash_shift^t.window[S+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[S+T-1])&t.hash_mask,t.prev[S&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=S,S++,t.insert--,!(t.lookahead+t.insert<T)););}while(t.lookahead<te&&t.strm.avail_in!==0)}function he(t,$){for(var D,m;;){if(t.lookahead<te){if(ue(t),t.lookahead<te&&$===b)return r;if(t.lookahead===0)break}if(D=0,t.lookahead>=T&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+T-1])&t.hash_mask,D=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),D!==0&&t.strstart-D<=t.w_size-te&&(t.match_length=q(t,D)),t.match_length>=T)if(m=n._tr_tally(t,t.strstart-t.match_start,t.match_length-T),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=T){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+T-1])&t.hash_mask,D=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,--t.match_length!=0;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else m=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(m&&(z(t,!1),t.strm.avail_out===0))return r}return t.insert=t.strstart<T-1?t.strstart:T-1,$===w?(z(t,!0),t.strm.avail_out===0?ee:W):t.last_lit&&(z(t,!1),t.strm.avail_out===0)?r:L}function ae(t,$){for(var D,m,u;;){if(t.lookahead<te){if(ue(t),t.lookahead<te&&$===b)return r;if(t.lookahead===0)break}if(D=0,t.lookahead>=T&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+T-1])&t.hash_mask,D=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=T-1,D!==0&&t.prev_length<t.max_lazy_match&&t.strstart-D<=t.w_size-te&&(t.match_length=q(t,D),t.match_length<=5&&(t.strategy===1||t.match_length===T&&4096<t.strstart-t.match_start)&&(t.match_length=T-1)),t.prev_length>=T&&t.match_length<=t.prev_length){for(u=t.strstart+t.lookahead-T,m=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-T),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=u&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+T-1])&t.hash_mask,D=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),--t.prev_length!=0;);if(t.match_available=0,t.match_length=T-1,t.strstart++,m&&(z(t,!1),t.strm.avail_out===0))return r}else if(t.match_available){if((m=n._tr_tally(t,0,t.window[t.strstart-1]))&&z(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return r}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(m=n._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<T-1?t.strstart:T-1,$===w?(z(t,!0),t.strm.avail_out===0?ee:W):t.last_lit&&(z(t,!1),t.strm.avail_out===0)?r:L}function de(t,$,D,m,u){this.good_length=t,this.max_lazy=$,this.nice_length=D,this.max_chain=m,this.func=u}function ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=g,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new h.Buf16(2*E),this.dyn_dtree=new h.Buf16(2*(2*j+1)),this.bl_tree=new h.Buf16(2*(2*P+1)),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new h.Buf16(M+1),this.heap=new h.Buf16(2*v+1),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new h.Buf16(2*v+1),O(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ie(t){var $;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=l,($=t.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?_:B,t.adler=$.wrap===2?0:1,$.last_flush=b,n._tr_init($),i):ne(t,x)}function ge(t){var $=ie(t);return $===i&&(function(D){D.window_size=2*D.w_size,O(D.head),D.max_lazy_match=o[D.level].max_lazy,D.good_match=o[D.level].good_length,D.nice_match=o[D.level].nice_length,D.max_chain_length=o[D.level].max_chain,D.strstart=0,D.block_start=0,D.lookahead=0,D.insert=0,D.match_length=D.prev_length=T-1,D.match_available=0,D.ins_h=0})(t.state),$}function xe(t,$,D,m,u,S){if(!t)return x;var F=1;if($===s&&($=6),m<0?(F=0,m=-m):15<m&&(F=2,m-=16),u<1||y<u||D!==g||m<8||15<m||$<0||9<$||S<0||d<S)return ne(t,x);m===8&&(m=9);var U=new ce;return(t.state=U).strm=t,U.wrap=F,U.gzhead=null,U.w_bits=m,U.w_size=1<<U.w_bits,U.w_mask=U.w_size-1,U.hash_bits=u+7,U.hash_size=1<<U.hash_bits,U.hash_mask=U.hash_size-1,U.hash_shift=~~((U.hash_bits+T-1)/T),U.window=new h.Buf8(2*U.w_size),U.head=new h.Buf16(U.hash_size),U.prev=new h.Buf16(U.w_size),U.lit_bufsize=1<<u+6,U.pending_buf_size=4*U.lit_bufsize,U.pending_buf=new h.Buf8(U.pending_buf_size),U.d_buf=1*U.lit_bufsize,U.l_buf=3*U.lit_bufsize,U.level=$,U.strategy=S,U.method=D,ge(t)}o=[new de(0,0,0,0,function(t,$){var D=65535;for(D>t.pending_buf_size-5&&(D=t.pending_buf_size-5);;){if(t.lookahead<=1){if(ue(t),t.lookahead===0&&$===b)return r;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var m=t.block_start+D;if((t.strstart===0||t.strstart>=m)&&(t.lookahead=t.strstart-m,t.strstart=m,z(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-te&&(z(t,!1),t.strm.avail_out===0))return r}return t.insert=0,$===w?(z(t,!0),t.strm.avail_out===0?ee:W):(t.strstart>t.block_start&&(z(t,!1),t.strm.avail_out),r)}),new de(4,4,8,4,he),new de(4,5,16,8,he),new de(4,6,32,32,he),new de(4,4,16,16,ae),new de(8,16,32,32,ae),new de(8,16,128,128,ae),new de(8,32,128,256,ae),new de(32,128,258,1024,ae),new de(32,258,258,4096,ae)],c.deflateInit=function(t,$){return xe(t,$,g,15,8,0)},c.deflateInit2=xe,c.deflateReset=ge,c.deflateResetKeep=ie,c.deflateSetHeader=function(t,$){return t&&t.state?t.state.wrap!==2?x:(t.state.gzhead=$,i):x},c.deflate=function(t,$){var D,m,u,S;if(!t||!t.state||5<$||$<0)return t?ne(t,x):x;if(m=t.state,!t.output||!t.input&&t.avail_in!==0||m.status===666&&$!==w)return ne(t,t.avail_out===0?-5:x);if(m.strm=t,D=m.last_flush,m.last_flush=$,m.status===_)if(m.wrap===2)t.adler=0,Q(m,31),Q(m,139),Q(m,8),m.gzhead?(Q(m,(m.gzhead.text?1:0)+(m.gzhead.hcrc?2:0)+(m.gzhead.extra?4:0)+(m.gzhead.name?8:0)+(m.gzhead.comment?16:0)),Q(m,255&m.gzhead.time),Q(m,m.gzhead.time>>8&255),Q(m,m.gzhead.time>>16&255),Q(m,m.gzhead.time>>24&255),Q(m,m.level===9?2:2<=m.strategy||m.level<2?4:0),Q(m,255&m.gzhead.os),m.gzhead.extra&&m.gzhead.extra.length&&(Q(m,255&m.gzhead.extra.length),Q(m,m.gzhead.extra.length>>8&255)),m.gzhead.hcrc&&(t.adler=p(t.adler,m.pending_buf,m.pending,0)),m.gzindex=0,m.status=69):(Q(m,0),Q(m,0),Q(m,0),Q(m,0),Q(m,0),Q(m,m.level===9?2:2<=m.strategy||m.level<2?4:0),Q(m,3),m.status=B);else{var F=g+(m.w_bits-8<<4)<<8;F|=(2<=m.strategy||m.level<2?0:m.level<6?1:m.level===6?2:3)<<6,m.strstart!==0&&(F|=32),F+=31-F%31,m.status=B,Y(m,F),m.strstart!==0&&(Y(m,t.adler>>>16),Y(m,65535&t.adler)),t.adler=1}if(m.status===69)if(m.gzhead.extra){for(u=m.pending;m.gzindex<(65535&m.gzhead.extra.length)&&(m.pending!==m.pending_buf_size||(m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),I(t),u=m.pending,m.pending!==m.pending_buf_size));)Q(m,255&m.gzhead.extra[m.gzindex]),m.gzindex++;m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),m.gzindex===m.gzhead.extra.length&&(m.gzindex=0,m.status=73)}else m.status=73;if(m.status===73)if(m.gzhead.name){u=m.pending;do{if(m.pending===m.pending_buf_size&&(m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),I(t),u=m.pending,m.pending===m.pending_buf_size)){S=1;break}S=m.gzindex<m.gzhead.name.length?255&m.gzhead.name.charCodeAt(m.gzindex++):0,Q(m,S)}while(S!==0);m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),S===0&&(m.gzindex=0,m.status=91)}else m.status=91;if(m.status===91)if(m.gzhead.comment){u=m.pending;do{if(m.pending===m.pending_buf_size&&(m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),I(t),u=m.pending,m.pending===m.pending_buf_size)){S=1;break}S=m.gzindex<m.gzhead.comment.length?255&m.gzhead.comment.charCodeAt(m.gzindex++):0,Q(m,S)}while(S!==0);m.gzhead.hcrc&&m.pending>u&&(t.adler=p(t.adler,m.pending_buf,m.pending-u,u)),S===0&&(m.status=103)}else m.status=103;if(m.status===103&&(m.gzhead.hcrc?(m.pending+2>m.pending_buf_size&&I(t),m.pending+2<=m.pending_buf_size&&(Q(m,255&t.adler),Q(m,t.adler>>8&255),t.adler=0,m.status=B)):m.status=B),m.pending!==0){if(I(t),t.avail_out===0)return m.last_flush=-1,i}else if(t.avail_in===0&&H($)<=H(D)&&$!==w)return ne(t,-5);if(m.status===666&&t.avail_in!==0)return ne(t,-5);if(t.avail_in!==0||m.lookahead!==0||$!==b&&m.status!==666){var U=m.strategy===2?(function(A,V){for(var X;;){if(A.lookahead===0&&(ue(A),A.lookahead===0)){if(V===b)return r;break}if(A.match_length=0,X=n._tr_tally(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++,X&&(z(A,!1),A.strm.avail_out===0))return r}return A.insert=0,V===w?(z(A,!0),A.strm.avail_out===0?ee:W):A.last_lit&&(z(A,!1),A.strm.avail_out===0)?r:L})(m,$):m.strategy===3?(function(A,V){for(var X,J,se,fe,oe=A.window;;){if(A.lookahead<=G){if(ue(A),A.lookahead<=G&&V===b)return r;if(A.lookahead===0)break}if(A.match_length=0,A.lookahead>=T&&0<A.strstart&&(J=oe[se=A.strstart-1])===oe[++se]&&J===oe[++se]&&J===oe[++se]){fe=A.strstart+G;do;while(J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&J===oe[++se]&&se<fe);A.match_length=G-(fe-se),A.match_length>A.lookahead&&(A.match_length=A.lookahead)}if(A.match_length>=T?(X=n._tr_tally(A,1,A.match_length-T),A.lookahead-=A.match_length,A.strstart+=A.match_length,A.match_length=0):(X=n._tr_tally(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++),X&&(z(A,!1),A.strm.avail_out===0))return r}return A.insert=0,V===w?(z(A,!0),A.strm.avail_out===0?ee:W):A.last_lit&&(z(A,!1),A.strm.avail_out===0)?r:L})(m,$):o[m.level].func(m,$);if(U!==ee&&U!==W||(m.status=666),U===r||U===ee)return t.avail_out===0&&(m.last_flush=-1),i;if(U===L&&($===1?n._tr_align(m):$!==5&&(n._tr_stored_block(m,0,0,!1),$===3&&(O(m.head),m.lookahead===0&&(m.strstart=0,m.block_start=0,m.insert=0))),I(t),t.avail_out===0))return m.last_flush=-1,i}return $!==w?i:m.wrap<=0?1:(m.wrap===2?(Q(m,255&t.adler),Q(m,t.adler>>8&255),Q(m,t.adler>>16&255),Q(m,t.adler>>24&255),Q(m,255&t.total_in),Q(m,t.total_in>>8&255),Q(m,t.total_in>>16&255),Q(m,t.total_in>>24&255)):(Y(m,t.adler>>>16),Y(m,65535&t.adler)),I(t),0<m.wrap&&(m.wrap=-m.wrap),m.pending!==0?i:1)},c.deflateEnd=function(t){var $;return t&&t.state?($=t.state.status)!==_&&$!==69&&$!==73&&$!==91&&$!==103&&$!==B&&$!==666?ne(t,x):(t.state=null,$===B?ne(t,-3):i):x},c.deflateSetDictionary=function(t,$){var D,m,u,S,F,U,A,V,X=$.length;if(!t||!t.state||(S=(D=t.state).wrap)===2||S===1&&D.status!==_||D.lookahead)return x;for(S===1&&(t.adler=f(t.adler,$,X,0)),D.wrap=0,X>=D.w_size&&(S===0&&(O(D.head),D.strstart=0,D.block_start=0,D.insert=0),V=new h.Buf8(D.w_size),h.arraySet(V,$,X-D.w_size,D.w_size,0),$=V,X=D.w_size),F=t.avail_in,U=t.next_in,A=t.input,t.avail_in=X,t.next_in=0,t.input=$,ue(D);D.lookahead>=T;){for(m=D.strstart,u=D.lookahead-(T-1);D.ins_h=(D.ins_h<<D.hash_shift^D.window[m+T-1])&D.hash_mask,D.prev[m&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=m,m++,--u;);D.strstart=m,D.lookahead=T-1,ue(D)}return D.strstart+=D.lookahead,D.block_start=D.strstart,D.insert=D.lookahead,D.lookahead=0,D.match_length=D.prev_length=T-1,D.match_available=0,t.next_in=U,t.input=A,t.avail_in=F,D.wrap=S,i},c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(a,N,c){N.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(a,N,c){N.exports=function(o,h){var n,f,p,k,b,w,i,x,s,d,l,g,y,v,j,P,E,M,T,G,te,_,B,r,L;n=o.state,f=o.next_in,r=o.input,p=f+(o.avail_in-5),k=o.next_out,L=o.output,b=k-(h-o.avail_out),w=k+(o.avail_out-257),i=n.dmax,x=n.wsize,s=n.whave,d=n.wnext,l=n.window,g=n.hold,y=n.bits,v=n.lencode,j=n.distcode,P=(1<<n.lenbits)-1,E=(1<<n.distbits)-1;e:do{y<15&&(g+=r[f++]<<y,y+=8,g+=r[f++]<<y,y+=8),M=v[g&P];t:for(;;){if(g>>>=T=M>>>24,y-=T,(T=M>>>16&255)===0)L[k++]=65535&M;else{if(!(16&T)){if((64&T)==0){M=v[(65535&M)+(g&(1<<T)-1)];continue t}if(32&T){n.mode=12;break e}o.msg="invalid literal/length code",n.mode=30;break e}G=65535&M,(T&=15)&&(y<T&&(g+=r[f++]<<y,y+=8),G+=g&(1<<T)-1,g>>>=T,y-=T),y<15&&(g+=r[f++]<<y,y+=8,g+=r[f++]<<y,y+=8),M=j[g&E];s:for(;;){if(g>>>=T=M>>>24,y-=T,!(16&(T=M>>>16&255))){if((64&T)==0){M=j[(65535&M)+(g&(1<<T)-1)];continue s}o.msg="invalid distance code",n.mode=30;break e}if(te=65535&M,y<(T&=15)&&(g+=r[f++]<<y,(y+=8)<T&&(g+=r[f++]<<y,y+=8)),i<(te+=g&(1<<T)-1)){o.msg="invalid distance too far back",n.mode=30;break e}if(g>>>=T,y-=T,(T=k-b)<te){if(s<(T=te-T)&&n.sane){o.msg="invalid distance too far back",n.mode=30;break e}if(B=l,(_=0)===d){if(_+=x-T,T<G){for(G-=T;L[k++]=l[_++],--T;);_=k-te,B=L}}else if(d<T){if(_+=x+d-T,(T-=d)<G){for(G-=T;L[k++]=l[_++],--T;);if(_=0,d<G){for(G-=T=d;L[k++]=l[_++],--T;);_=k-te,B=L}}}else if(_+=d-T,T<G){for(G-=T;L[k++]=l[_++],--T;);_=k-te,B=L}for(;2<G;)L[k++]=B[_++],L[k++]=B[_++],L[k++]=B[_++],G-=3;G&&(L[k++]=B[_++],1<G&&(L[k++]=B[_++]))}else{for(_=k-te;L[k++]=L[_++],L[k++]=L[_++],L[k++]=L[_++],2<(G-=3););G&&(L[k++]=L[_++],1<G&&(L[k++]=L[_++]))}break}}break}}while(f<p&&k<w);f-=G=y>>3,g&=(1<<(y-=G<<3))-1,o.next_in=f,o.next_out=k,o.avail_in=f<p?p-f+5:5-(f-p),o.avail_out=k<w?w-k+257:257-(k-w),n.hold=g,n.bits=y}},{}],49:[function(a,N,c){var o=a("../utils/common"),h=a("./adler32"),n=a("./crc32"),f=a("./inffast"),p=a("./inftrees"),k=1,b=2,w=0,i=-2,x=1,s=852,d=592;function l(_){return(_>>>24&255)+(_>>>8&65280)+((65280&_)<<8)+((255&_)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(_){var B;return _&&_.state?(B=_.state,_.total_in=_.total_out=B.total=0,_.msg="",B.wrap&&(_.adler=1&B.wrap),B.mode=x,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new o.Buf32(s),B.distcode=B.distdyn=new o.Buf32(d),B.sane=1,B.back=-1,w):i}function v(_){var B;return _&&_.state?((B=_.state).wsize=0,B.whave=0,B.wnext=0,y(_)):i}function j(_,B){var r,L;return _&&_.state?(L=_.state,B<0?(r=0,B=-B):(r=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?i:(L.window!==null&&L.wbits!==B&&(L.window=null),L.wrap=r,L.wbits=B,v(_))):i}function P(_,B){var r,L;return _?(L=new g,(_.state=L).window=null,(r=j(_,B))!==w&&(_.state=null),r):i}var E,M,T=!0;function G(_){if(T){var B;for(E=new o.Buf32(512),M=new o.Buf32(32),B=0;B<144;)_.lens[B++]=8;for(;B<256;)_.lens[B++]=9;for(;B<280;)_.lens[B++]=7;for(;B<288;)_.lens[B++]=8;for(p(k,_.lens,0,288,E,0,_.work,{bits:9}),B=0;B<32;)_.lens[B++]=5;p(b,_.lens,0,32,M,0,_.work,{bits:5}),T=!1}_.lencode=E,_.lenbits=9,_.distcode=M,_.distbits=5}function te(_,B,r,L){var ee,W=_.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new o.Buf8(W.wsize)),L>=W.wsize?(o.arraySet(W.window,B,r-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(L<(ee=W.wsize-W.wnext)&&(ee=L),o.arraySet(W.window,B,r-L,ee,W.wnext),(L-=ee)?(o.arraySet(W.window,B,r-L,L,0),W.wnext=L,W.whave=W.wsize):(W.wnext+=ee,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=ee))),0}c.inflateReset=v,c.inflateReset2=j,c.inflateResetKeep=y,c.inflateInit=function(_){return P(_,15)},c.inflateInit2=P,c.inflate=function(_,B){var r,L,ee,W,ne,H,O,I,z,Q,Y,q,ue,he,ae,de,ce,ie,ge,xe,t,$,D,m,u=0,S=new o.Buf8(4),F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!_||!_.state||!_.output||!_.input&&_.avail_in!==0)return i;(r=_.state).mode===12&&(r.mode=13),ne=_.next_out,ee=_.output,O=_.avail_out,W=_.next_in,L=_.input,H=_.avail_in,I=r.hold,z=r.bits,Q=H,Y=O,$=w;e:for(;;)switch(r.mode){case x:if(r.wrap===0){r.mode=13;break}for(;z<16;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(2&r.wrap&&I===35615){S[r.check=0]=255&I,S[1]=I>>>8&255,r.check=n(r.check,S,2,0),z=I=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&I)<<8)+(I>>8))%31){_.msg="incorrect header check",r.mode=30;break}if((15&I)!=8){_.msg="unknown compression method",r.mode=30;break}if(z-=4,t=8+(15&(I>>>=4)),r.wbits===0)r.wbits=t;else if(t>r.wbits){_.msg="invalid window size",r.mode=30;break}r.dmax=1<<t,_.adler=r.check=1,r.mode=512&I?10:12,z=I=0;break;case 2:for(;z<16;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(r.flags=I,(255&r.flags)!=8){_.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){_.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=I>>8&1),512&r.flags&&(S[0]=255&I,S[1]=I>>>8&255,r.check=n(r.check,S,2,0)),z=I=0,r.mode=3;case 3:for(;z<32;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.head&&(r.head.time=I),512&r.flags&&(S[0]=255&I,S[1]=I>>>8&255,S[2]=I>>>16&255,S[3]=I>>>24&255,r.check=n(r.check,S,4,0)),z=I=0,r.mode=4;case 4:for(;z<16;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.head&&(r.head.xflags=255&I,r.head.os=I>>8),512&r.flags&&(S[0]=255&I,S[1]=I>>>8&255,r.check=n(r.check,S,2,0)),z=I=0,r.mode=5;case 5:if(1024&r.flags){for(;z<16;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.length=I,r.head&&(r.head.extra_len=I),512&r.flags&&(S[0]=255&I,S[1]=I>>>8&255,r.check=n(r.check,S,2,0)),z=I=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(H<(q=r.length)&&(q=H),q&&(r.head&&(t=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),o.arraySet(r.head.extra,L,W,q,t)),512&r.flags&&(r.check=n(r.check,L,q,W)),H-=q,W+=q,r.length-=q),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(H===0)break e;for(q=0;t=L[W+q++],r.head&&t&&r.length<65536&&(r.head.name+=String.fromCharCode(t)),t&&q<H;);if(512&r.flags&&(r.check=n(r.check,L,q,W)),H-=q,W+=q,t)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(H===0)break e;for(q=0;t=L[W+q++],r.head&&t&&r.length<65536&&(r.head.comment+=String.fromCharCode(t)),t&&q<H;);if(512&r.flags&&(r.check=n(r.check,L,q,W)),H-=q,W+=q,t)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;z<16;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(I!==(65535&r.check)){_.msg="header crc mismatch",r.mode=30;break}z=I=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),_.adler=r.check=0,r.mode=12;break;case 10:for(;z<32;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}_.adler=r.check=l(I),z=I=0,r.mode=11;case 11:if(r.havedict===0)return _.next_out=ne,_.avail_out=O,_.next_in=W,_.avail_in=H,r.hold=I,r.bits=z,2;_.adler=r.check=1,r.mode=12;case 12:if(B===5||B===6)break e;case 13:if(r.last){I>>>=7&z,z-=7&z,r.mode=27;break}for(;z<3;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}switch(r.last=1&I,z-=1,3&(I>>>=1)){case 0:r.mode=14;break;case 1:if(G(r),r.mode=20,B!==6)break;I>>>=2,z-=2;break e;case 2:r.mode=17;break;case 3:_.msg="invalid block type",r.mode=30}I>>>=2,z-=2;break;case 14:for(I>>>=7&z,z-=7&z;z<32;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if((65535&I)!=(I>>>16^65535)){_.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&I,z=I=0,r.mode=15,B===6)break e;case 15:r.mode=16;case 16:if(q=r.length){if(H<q&&(q=H),O<q&&(q=O),q===0)break e;o.arraySet(ee,L,W,q,ne),H-=q,W+=q,O-=q,ne+=q,r.length-=q;break}r.mode=12;break;case 17:for(;z<14;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(r.nlen=257+(31&I),I>>>=5,z-=5,r.ndist=1+(31&I),I>>>=5,z-=5,r.ncode=4+(15&I),I>>>=4,z-=4,286<r.nlen||30<r.ndist){_.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;z<3;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.lens[F[r.have++]]=7&I,I>>>=3,z-=3}for(;r.have<19;)r.lens[F[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,D={bits:r.lenbits},$=p(0,r.lens,0,19,r.lencode,0,r.work,D),r.lenbits=D.bits,$){_.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;de=(u=r.lencode[I&(1<<r.lenbits)-1])>>>16&255,ce=65535&u,!((ae=u>>>24)<=z);){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(ce<16)I>>>=ae,z-=ae,r.lens[r.have++]=ce;else{if(ce===16){for(m=ae+2;z<m;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(I>>>=ae,z-=ae,r.have===0){_.msg="invalid bit length repeat",r.mode=30;break}t=r.lens[r.have-1],q=3+(3&I),I>>>=2,z-=2}else if(ce===17){for(m=ae+3;z<m;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}z-=ae,t=0,q=3+(7&(I>>>=ae)),I>>>=3,z-=3}else{for(m=ae+7;z<m;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}z-=ae,t=0,q=11+(127&(I>>>=ae)),I>>>=7,z-=7}if(r.have+q>r.nlen+r.ndist){_.msg="invalid bit length repeat",r.mode=30;break}for(;q--;)r.lens[r.have++]=t}}if(r.mode===30)break;if(r.lens[256]===0){_.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,D={bits:r.lenbits},$=p(k,r.lens,0,r.nlen,r.lencode,0,r.work,D),r.lenbits=D.bits,$){_.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,D={bits:r.distbits},$=p(b,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,D),r.distbits=D.bits,$){_.msg="invalid distances set",r.mode=30;break}if(r.mode=20,B===6)break e;case 20:r.mode=21;case 21:if(6<=H&&258<=O){_.next_out=ne,_.avail_out=O,_.next_in=W,_.avail_in=H,r.hold=I,r.bits=z,f(_,Y),ne=_.next_out,ee=_.output,O=_.avail_out,W=_.next_in,L=_.input,H=_.avail_in,I=r.hold,z=r.bits,r.mode===12&&(r.back=-1);break}for(r.back=0;de=(u=r.lencode[I&(1<<r.lenbits)-1])>>>16&255,ce=65535&u,!((ae=u>>>24)<=z);){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(de&&(240&de)==0){for(ie=ae,ge=de,xe=ce;de=(u=r.lencode[xe+((I&(1<<ie+ge)-1)>>ie)])>>>16&255,ce=65535&u,!(ie+(ae=u>>>24)<=z);){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}I>>>=ie,z-=ie,r.back+=ie}if(I>>>=ae,z-=ae,r.back+=ae,r.length=ce,de===0){r.mode=26;break}if(32&de){r.back=-1,r.mode=12;break}if(64&de){_.msg="invalid literal/length code",r.mode=30;break}r.extra=15&de,r.mode=22;case 22:if(r.extra){for(m=r.extra;z<m;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.length+=I&(1<<r.extra)-1,I>>>=r.extra,z-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;de=(u=r.distcode[I&(1<<r.distbits)-1])>>>16&255,ce=65535&u,!((ae=u>>>24)<=z);){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if((240&de)==0){for(ie=ae,ge=de,xe=ce;de=(u=r.distcode[xe+((I&(1<<ie+ge)-1)>>ie)])>>>16&255,ce=65535&u,!(ie+(ae=u>>>24)<=z);){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}I>>>=ie,z-=ie,r.back+=ie}if(I>>>=ae,z-=ae,r.back+=ae,64&de){_.msg="invalid distance code",r.mode=30;break}r.offset=ce,r.extra=15&de,r.mode=24;case 24:if(r.extra){for(m=r.extra;z<m;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}r.offset+=I&(1<<r.extra)-1,I>>>=r.extra,z-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){_.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(O===0)break e;if(q=Y-O,r.offset>q){if((q=r.offset-q)>r.whave&&r.sane){_.msg="invalid distance too far back",r.mode=30;break}ue=q>r.wnext?(q-=r.wnext,r.wsize-q):r.wnext-q,q>r.length&&(q=r.length),he=r.window}else he=ee,ue=ne-r.offset,q=r.length;for(O<q&&(q=O),O-=q,r.length-=q;ee[ne++]=he[ue++],--q;);r.length===0&&(r.mode=21);break;case 26:if(O===0)break e;ee[ne++]=r.length,O--,r.mode=21;break;case 27:if(r.wrap){for(;z<32;){if(H===0)break e;H--,I|=L[W++]<<z,z+=8}if(Y-=O,_.total_out+=Y,r.total+=Y,Y&&(_.adler=r.check=r.flags?n(r.check,ee,Y,ne-Y):h(r.check,ee,Y,ne-Y)),Y=O,(r.flags?I:l(I))!==r.check){_.msg="incorrect data check",r.mode=30;break}z=I=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;z<32;){if(H===0)break e;H--,I+=L[W++]<<z,z+=8}if(I!==(4294967295&r.total)){_.msg="incorrect length check",r.mode=30;break}z=I=0}r.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return i}return _.next_out=ne,_.avail_out=O,_.next_in=W,_.avail_in=H,r.hold=I,r.bits=z,(r.wsize||Y!==_.avail_out&&r.mode<30&&(r.mode<27||B!==4))&&te(_,_.output,_.next_out,Y-_.avail_out)?(r.mode=31,-4):(Q-=_.avail_in,Y-=_.avail_out,_.total_in+=Q,_.total_out+=Y,r.total+=Y,r.wrap&&Y&&(_.adler=r.check=r.flags?n(r.check,ee,Y,_.next_out-Y):h(r.check,ee,Y,_.next_out-Y)),_.data_type=r.bits+(r.last?64:0)+(r.mode===12?128:0)+(r.mode===20||r.mode===15?256:0),(Q==0&&Y===0||B===4)&&$===w&&($=-5),$)},c.inflateEnd=function(_){if(!_||!_.state)return i;var B=_.state;return B.window&&(B.window=null),_.state=null,w},c.inflateGetHeader=function(_,B){var r;return _&&_.state?(2&(r=_.state).wrap)==0?i:((r.head=B).done=!1,w):i},c.inflateSetDictionary=function(_,B){var r,L=B.length;return _&&_.state?(r=_.state).wrap!==0&&r.mode!==11?i:r.mode===11&&h(1,B,L,0)!==r.check?-3:te(_,B,L,L)?(r.mode=31,-4):(r.havedict=1,w):i},c.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(a,N,c){var o=a("../utils/common"),h=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],f=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],p=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];N.exports=function(k,b,w,i,x,s,d,l){var g,y,v,j,P,E,M,T,G,te=l.bits,_=0,B=0,r=0,L=0,ee=0,W=0,ne=0,H=0,O=0,I=0,z=null,Q=0,Y=new o.Buf16(16),q=new o.Buf16(16),ue=null,he=0;for(_=0;_<=15;_++)Y[_]=0;for(B=0;B<i;B++)Y[b[w+B]]++;for(ee=te,L=15;1<=L&&Y[L]===0;L--);if(L<ee&&(ee=L),L===0)return x[s++]=20971520,x[s++]=20971520,l.bits=1,0;for(r=1;r<L&&Y[r]===0;r++);for(ee<r&&(ee=r),_=H=1;_<=15;_++)if(H<<=1,(H-=Y[_])<0)return-1;if(0<H&&(k===0||L!==1))return-1;for(q[1]=0,_=1;_<15;_++)q[_+1]=q[_]+Y[_];for(B=0;B<i;B++)b[w+B]!==0&&(d[q[b[w+B]]++]=B);if(E=k===0?(z=ue=d,19):k===1?(z=h,Q-=257,ue=n,he-=257,256):(z=f,ue=p,-1),_=r,P=s,ne=B=I=0,v=-1,j=(O=1<<(W=ee))-1,k===1&&852<O||k===2&&592<O)return 1;for(;;){for(M=_-ne,G=d[B]<E?(T=0,d[B]):d[B]>E?(T=ue[he+d[B]],z[Q+d[B]]):(T=96,0),g=1<<_-ne,r=y=1<<W;x[P+(I>>ne)+(y-=g)]=M<<24|T<<16|G|0,y!==0;);for(g=1<<_-1;I&g;)g>>=1;if(g!==0?(I&=g-1,I+=g):I=0,B++,--Y[_]==0){if(_===L)break;_=b[w+d[B]]}if(ee<_&&(I&j)!==v){for(ne===0&&(ne=ee),P+=r,H=1<<(W=_-ne);W+ne<L&&!((H-=Y[W+ne])<=0);)W++,H<<=1;if(O+=1<<W,k===1&&852<O||k===2&&592<O)return 1;x[v=I&j]=ee<<24|W<<16|P-s|0}}return I!==0&&(x[P+I]=_-ne<<24|64<<16|0),l.bits=ee,0}},{"../utils/common":41}],51:[function(a,N,c){N.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(a,N,c){var o=a("../utils/common"),h=0,n=1;function f(u){for(var S=u.length;0<=--S;)u[S]=0}var p=0,k=29,b=256,w=b+1+k,i=30,x=19,s=2*w+1,d=15,l=16,g=7,y=256,v=16,j=17,P=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],te=new Array(2*(w+2));f(te);var _=new Array(2*i);f(_);var B=new Array(512);f(B);var r=new Array(256);f(r);var L=new Array(k);f(L);var ee,W,ne,H=new Array(i);function O(u,S,F,U,A){this.static_tree=u,this.extra_bits=S,this.extra_base=F,this.elems=U,this.max_length=A,this.has_stree=u&&u.length}function I(u,S){this.dyn_tree=u,this.max_code=0,this.stat_desc=S}function z(u){return u<256?B[u]:B[256+(u>>>7)]}function Q(u,S){u.pending_buf[u.pending++]=255&S,u.pending_buf[u.pending++]=S>>>8&255}function Y(u,S,F){u.bi_valid>l-F?(u.bi_buf|=S<<u.bi_valid&65535,Q(u,u.bi_buf),u.bi_buf=S>>l-u.bi_valid,u.bi_valid+=F-l):(u.bi_buf|=S<<u.bi_valid&65535,u.bi_valid+=F)}function q(u,S,F){Y(u,F[2*S],F[2*S+1])}function ue(u,S){for(var F=0;F|=1&u,u>>>=1,F<<=1,0<--S;);return F>>>1}function he(u,S,F){var U,A,V=new Array(d+1),X=0;for(U=1;U<=d;U++)V[U]=X=X+F[U-1]<<1;for(A=0;A<=S;A++){var J=u[2*A+1];J!==0&&(u[2*A]=ue(V[J]++,J))}}function ae(u){var S;for(S=0;S<w;S++)u.dyn_ltree[2*S]=0;for(S=0;S<i;S++)u.dyn_dtree[2*S]=0;for(S=0;S<x;S++)u.bl_tree[2*S]=0;u.dyn_ltree[2*y]=1,u.opt_len=u.static_len=0,u.last_lit=u.matches=0}function de(u){8<u.bi_valid?Q(u,u.bi_buf):0<u.bi_valid&&(u.pending_buf[u.pending++]=u.bi_buf),u.bi_buf=0,u.bi_valid=0}function ce(u,S,F,U){var A=2*S,V=2*F;return u[A]<u[V]||u[A]===u[V]&&U[S]<=U[F]}function ie(u,S,F){for(var U=u.heap[F],A=F<<1;A<=u.heap_len&&(A<u.heap_len&&ce(S,u.heap[A+1],u.heap[A],u.depth)&&A++,!ce(S,U,u.heap[A],u.depth));)u.heap[F]=u.heap[A],F=A,A<<=1;u.heap[F]=U}function ge(u,S,F){var U,A,V,X,J=0;if(u.last_lit!==0)for(;U=u.pending_buf[u.d_buf+2*J]<<8|u.pending_buf[u.d_buf+2*J+1],A=u.pending_buf[u.l_buf+J],J++,U===0?q(u,A,S):(q(u,(V=r[A])+b+1,S),(X=E[V])!==0&&Y(u,A-=L[V],X),q(u,V=z(--U),F),(X=M[V])!==0&&Y(u,U-=H[V],X)),J<u.last_lit;);q(u,y,S)}function xe(u,S){var F,U,A,V=S.dyn_tree,X=S.stat_desc.static_tree,J=S.stat_desc.has_stree,se=S.stat_desc.elems,fe=-1;for(u.heap_len=0,u.heap_max=s,F=0;F<se;F++)V[2*F]!==0?(u.heap[++u.heap_len]=fe=F,u.depth[F]=0):V[2*F+1]=0;for(;u.heap_len<2;)V[2*(A=u.heap[++u.heap_len]=fe<2?++fe:0)]=1,u.depth[A]=0,u.opt_len--,J&&(u.static_len-=X[2*A+1]);for(S.max_code=fe,F=u.heap_len>>1;1<=F;F--)ie(u,V,F);for(A=se;F=u.heap[1],u.heap[1]=u.heap[u.heap_len--],ie(u,V,1),U=u.heap[1],u.heap[--u.heap_max]=F,u.heap[--u.heap_max]=U,V[2*A]=V[2*F]+V[2*U],u.depth[A]=(u.depth[F]>=u.depth[U]?u.depth[F]:u.depth[U])+1,V[2*F+1]=V[2*U+1]=A,u.heap[1]=A++,ie(u,V,1),2<=u.heap_len;);u.heap[--u.heap_max]=u.heap[1],(function(oe,pe){var ke,Z,le,re,me,be,we=pe.dyn_tree,We=pe.max_code,nt=pe.stat_desc.static_tree,at=pe.stat_desc.has_stree,it=pe.stat_desc.extra_bits,He=pe.stat_desc.extra_base,Se=pe.stat_desc.max_length,Ie=0;for(re=0;re<=d;re++)oe.bl_count[re]=0;for(we[2*oe.heap[oe.heap_max]+1]=0,ke=oe.heap_max+1;ke<s;ke++)Se<(re=we[2*we[2*(Z=oe.heap[ke])+1]+1]+1)&&(re=Se,Ie++),we[2*Z+1]=re,We<Z||(oe.bl_count[re]++,me=0,He<=Z&&(me=it[Z-He]),be=we[2*Z],oe.opt_len+=be*(re+me),at&&(oe.static_len+=be*(nt[2*Z+1]+me)));if(Ie!==0){do{for(re=Se-1;oe.bl_count[re]===0;)re--;oe.bl_count[re]--,oe.bl_count[re+1]+=2,oe.bl_count[Se]--,Ie-=2}while(0<Ie);for(re=Se;re!==0;re--)for(Z=oe.bl_count[re];Z!==0;)We<(le=oe.heap[--ke])||(we[2*le+1]!==re&&(oe.opt_len+=(re-we[2*le+1])*we[2*le],we[2*le+1]=re),Z--)}})(u,S),he(V,fe,u.bl_count)}function t(u,S,F){var U,A,V=-1,X=S[1],J=0,se=7,fe=4;for(X===0&&(se=138,fe=3),S[2*(F+1)+1]=65535,U=0;U<=F;U++)A=X,X=S[2*(U+1)+1],++J<se&&A===X||(J<fe?u.bl_tree[2*A]+=J:A!==0?(A!==V&&u.bl_tree[2*A]++,u.bl_tree[2*v]++):J<=10?u.bl_tree[2*j]++:u.bl_tree[2*P]++,V=A,fe=(J=0)===X?(se=138,3):A===X?(se=6,3):(se=7,4))}function $(u,S,F){var U,A,V=-1,X=S[1],J=0,se=7,fe=4;for(X===0&&(se=138,fe=3),U=0;U<=F;U++)if(A=X,X=S[2*(U+1)+1],!(++J<se&&A===X)){if(J<fe)for(;q(u,A,u.bl_tree),--J!=0;);else A!==0?(A!==V&&(q(u,A,u.bl_tree),J--),q(u,v,u.bl_tree),Y(u,J-3,2)):J<=10?(q(u,j,u.bl_tree),Y(u,J-3,3)):(q(u,P,u.bl_tree),Y(u,J-11,7));V=A,fe=(J=0)===X?(se=138,3):A===X?(se=6,3):(se=7,4)}}f(H);var D=!1;function m(u,S,F,U){Y(u,(p<<1)+(U?1:0),3),(function(A,V,X,J){de(A),Q(A,X),Q(A,~X),o.arraySet(A.pending_buf,A.window,V,X,A.pending),A.pending+=X})(u,S,F)}c._tr_init=function(u){D||((function(){var S,F,U,A,V,X=new Array(d+1);for(A=U=0;A<k-1;A++)for(L[A]=U,S=0;S<1<<E[A];S++)r[U++]=A;for(r[U-1]=A,A=V=0;A<16;A++)for(H[A]=V,S=0;S<1<<M[A];S++)B[V++]=A;for(V>>=7;A<i;A++)for(H[A]=V<<7,S=0;S<1<<M[A]-7;S++)B[256+V++]=A;for(F=0;F<=d;F++)X[F]=0;for(S=0;S<=143;)te[2*S+1]=8,S++,X[8]++;for(;S<=255;)te[2*S+1]=9,S++,X[9]++;for(;S<=279;)te[2*S+1]=7,S++,X[7]++;for(;S<=287;)te[2*S+1]=8,S++,X[8]++;for(he(te,w+1,X),S=0;S<i;S++)_[2*S+1]=5,_[2*S]=ue(S,5);ee=new O(te,E,b+1,w,d),W=new O(_,M,0,i,d),ne=new O(new Array(0),T,0,x,g)})(),D=!0),u.l_desc=new I(u.dyn_ltree,ee),u.d_desc=new I(u.dyn_dtree,W),u.bl_desc=new I(u.bl_tree,ne),u.bi_buf=0,u.bi_valid=0,ae(u)},c._tr_stored_block=m,c._tr_flush_block=function(u,S,F,U){var A,V,X=0;0<u.level?(u.strm.data_type===2&&(u.strm.data_type=(function(J){var se,fe=4093624447;for(se=0;se<=31;se++,fe>>>=1)if(1&fe&&J.dyn_ltree[2*se]!==0)return h;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return n;for(se=32;se<b;se++)if(J.dyn_ltree[2*se]!==0)return n;return h})(u)),xe(u,u.l_desc),xe(u,u.d_desc),X=(function(J){var se;for(t(J,J.dyn_ltree,J.l_desc.max_code),t(J,J.dyn_dtree,J.d_desc.max_code),xe(J,J.bl_desc),se=x-1;3<=se&&J.bl_tree[2*G[se]+1]===0;se--);return J.opt_len+=3*(se+1)+5+5+4,se})(u),A=u.opt_len+3+7>>>3,(V=u.static_len+3+7>>>3)<=A&&(A=V)):A=V=F+5,F+4<=A&&S!==-1?m(u,S,F,U):u.strategy===4||V===A?(Y(u,2+(U?1:0),3),ge(u,te,_)):(Y(u,4+(U?1:0),3),(function(J,se,fe,oe){var pe;for(Y(J,se-257,5),Y(J,fe-1,5),Y(J,oe-4,4),pe=0;pe<oe;pe++)Y(J,J.bl_tree[2*G[pe]+1],3);$(J,J.dyn_ltree,se-1),$(J,J.dyn_dtree,fe-1)})(u,u.l_desc.max_code+1,u.d_desc.max_code+1,X+1),ge(u,u.dyn_ltree,u.dyn_dtree)),ae(u),U&&de(u)},c._tr_tally=function(u,S,F){return u.pending_buf[u.d_buf+2*u.last_lit]=S>>>8&255,u.pending_buf[u.d_buf+2*u.last_lit+1]=255&S,u.pending_buf[u.l_buf+u.last_lit]=255&F,u.last_lit++,S===0?u.dyn_ltree[2*F]++:(u.matches++,S--,u.dyn_ltree[2*(r[F]+b+1)]++,u.dyn_dtree[2*z(S)]++),u.last_lit===u.lit_bufsize-1},c._tr_align=function(u){Y(u,2,3),q(u,y,te),(function(S){S.bi_valid===16?(Q(S,S.bi_buf),S.bi_buf=0,S.bi_valid=0):8<=S.bi_valid&&(S.pending_buf[S.pending++]=255&S.bi_buf,S.bi_buf>>=8,S.bi_valid-=8)})(u)}},{"../utils/common":41}],53:[function(a,N,c){N.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(a,N,c){(function(o){(function(h,n){if(!h.setImmediate){var f,p,k,b,w=1,i={},x=!1,s=h.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(h);d=d&&d.setTimeout?d:h,f={}.toString.call(h.process)==="[object process]"?function(v){process.nextTick(function(){g(v)})}:(function(){if(h.postMessage&&!h.importScripts){var v=!0,j=h.onmessage;return h.onmessage=function(){v=!1},h.postMessage("","*"),h.onmessage=j,v}})()?(b="setImmediate$"+Math.random()+"$",h.addEventListener?h.addEventListener("message",y,!1):h.attachEvent("onmessage",y),function(v){h.postMessage(b+v,"*")}):h.MessageChannel?((k=new MessageChannel).port1.onmessage=function(v){g(v.data)},function(v){k.port2.postMessage(v)}):s&&"onreadystatechange"in s.createElement("script")?(p=s.documentElement,function(v){var j=s.createElement("script");j.onreadystatechange=function(){g(v),j.onreadystatechange=null,p.removeChild(j),j=null},p.appendChild(j)}):function(v){setTimeout(g,0,v)},d.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var j=new Array(arguments.length-1),P=0;P<j.length;P++)j[P]=arguments[P+1];var E={callback:v,args:j};return i[w]=E,f(w),w++},d.clearImmediate=l}function l(v){delete i[v]}function g(v){if(x)setTimeout(g,0,v);else{var j=i[v];if(j){x=!0;try{(function(P){var E=P.callback,M=P.args;switch(M.length){case 0:E();break;case 1:E(M[0]);break;case 2:E(M[0],M[1]);break;case 3:E(M[0],M[1],M[2]);break;default:E.apply(n,M)}})(j)}finally{l(v),x=!1}}}}function y(v){v.source===h&&typeof v.data=="string"&&v.data.indexOf(b)===0&&g(+v.data.slice(b.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof Ee<"u"?Ee:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Re)),Re.exports}var Pt=At();const Ot=ot(Pt);function Tt(R){const C=[];for(const a of R){if(typeof a!="string"){C.push({raw:String(a),host:null,approvable:!1,reason:"不是字符串"});continue}const N=a.trim(),c=Rt(N);if(c){C.push({raw:N,host:c,approvable:!0});continue}let o="不是合法的域名或 IP";N?N.length>253?o="域名过长(>253)":N.includes("*")?o="不支持通配符,请逐个列出域名":N.includes("/")||N.includes(":")||N.includes(" ")?o="只能写主机名,不能带协议、端口或路径":rt(N)?o="回环/私有/保留地址一律拒绝(SSRF 防线)":/^\d+\.\d+\.\d+\.\d+$/.test(N)&&(o="非法 IPv4 字面量"):o="空字符串",C.push({raw:N,host:null,approvable:!1,reason:o})}return C}function Je(R){const[C,a,N]=R;return C===0||C===10||C===127||C===100&&a>=64&&a<=127||C===169&&a===254||C===172&&a>=16&&a<=31||C===192&&a===0&&N===0||C===192&&a===0&&N===2||C===192&&a===168||C===198&&(a===18||a===19)||C===198&&a===51&&N===100||C===203&&a===0&&N===113||C>=224}function Fe(R){if(/^(0[xX][0-9a-fA-F]+|\d+)$/.test(R)){let c;return/^0[xX]/.test(R)?c=parseInt(R.slice(2),16):/^0\d+$/.test(R)&&/^[0-7]+$/.test(R.slice(1))?c=parseInt(R.slice(1),8):c=Number(R),!Number.isSafeInteger(c)||c<0||c>=2**32?null:[c>>>24&255,c>>>16&255,c>>>8&255,c&255]}const C=R.split(".");if(C.length!==4)return null;const a=/^(0[xX][0-9a-fA-F]+|0[0-7]*|\d+)$/;if(!C.every(c=>a.test(c)))return null;const N=C.map(c=>{let o;return/^0[xX]/.test(c)?o=parseInt(c.slice(2),16):/^0\d/.test(c)?o=parseInt(c.slice(1),8):o=parseInt(c,10),Number.isSafeInteger(o)&&o>=0&&o<=255?o:-1});return N.some(c=>c<0)?null:N}function rt(R){const C=R.trim().toLowerCase().replace(/\.$/,"");if(!C||C==="localhost"||C.endsWith(".localhost")||C.endsWith(".local")||C==="0.0.0.0"||C==="::"||C==="::1"||C==="[::]"||C==="[::1]")return!0;const a=C.startsWith("[")&&C.endsWith("]")?C.slice(1,-1):C;if(a.includes(":")){if(a==="::"||a==="::1"||/^0*:0*:0*:0*:0*:0*:0*:0*1$/i.test(a)||/^0*:0*:0*:0*:0*:0*:0*:0*$/i.test(a)||/^f[cd][0-9a-f]{2}:/i.test(a)||/^fe[89ab][0-9a-f]:/i.test(a)||/^ff[0-9a-f]{2}:/i.test(a))return!0;const c=/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i.exec(a);if(c){const o=Fe(c[1]);return o?Je(o):!0}return!1}const N=Fe(a);return N?Je(N):!1}function Rt(R){if(typeof R!="string")return null;const C=R.trim().toLowerCase().replace(/\.$/,"");return!C||C.length>253||C.includes("/")||C.includes(":")||C.includes(" ")||C.includes("*")||rt(C)||/^\d+\.\d+\.\d+\.\d+$/.test(C)&&!Fe(C)?null:C}function De(R){return R.replace(/\\u\{([0-9a-fA-F]+)\}/g,(C,a)=>{try{return String.fromCodePoint(parseInt(a,16))}catch{return C}}).replace(/\\u([0-9a-fA-F]{4})/g,(C,a)=>String.fromCharCode(parseInt(a,16))).replace(/\\x([0-9a-fA-F]{2})/g,(C,a)=>String.fromCharCode(parseInt(a,16))).replace(/\\n/g,`
13
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\'/g,"'").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}function Ke(R,C){if(!R)return C;for(const a of["label","name","title","displayName"]){const N=R[a];if(typeof N=="string"&&N.trim())return N.trim()}return C}function Ye(R){if(!R||typeof R!="object")return[];const C=[],a=new Set,N=(o,h,n)=>{const f=`${o}::${h}`;a.has(f)||(a.add(f),C.push({slot:o,id:h,label:n||h||o,source:"manifest"}))},c=R.contributes;if(c&&typeof c=="object"){for(const[o,h]of Object.entries(c))if(Array.isArray(h))for(const n of h){const f=n&&typeof n=="object"?n:{},p=typeof f.id=="string"?f.id:"?";N(o,p,Ke(f,p))}}if(Array.isArray(R.classroomTools))for(const o of R.classroomTools){const h=o&&typeof o=="object"?o:{},n=typeof h.id=="string"?h.id:"?";N("classroom.tool",n,Ke(h,n))}return C}function Dt(R){if(!R)return[];const C=[],a=/registerExtensionPoint\s*\(\s*['"]([^'"]+)['"]\s*,\s*\{((?:[^{}]|\{[^{}]*\})*)\}/g;let N;for(;(N=a.exec(R))!==null;){const c=De(N[1]),o=N[2],h=o.match(/\bid\s*:\s*['"]([^'"]*)['"]/),n=o.match(/\blabel\s*:\s*['"]([^'"]*)['"]/),f=o.match(/\bname\s*:\s*['"]([^'"]*)['"]/),p=De(h?.[1]||"?"),k=n?.[1]??f?.[1]??p;C.push({slot:c,id:p,label:De(k)||p||c,source:"frontend"})}return C}function Ut(R,C){const a=new Map;for(const N of R)a.set(`${N.slot}::${N.id}`,N);for(const N of C){const c=`${N.slot}::${N.id}`,o=a.get(c);if(!o){a.set(c,N);continue}const h=o.label&&o.label!==o.id&&o.label!==o.slot?o.label:N.label;a.set(c,{...o,label:h||o.label})}return Array.from(a.values())}const Bt=new Set(["teacher.tab","teacher.dashboard.widget","workspace.view","classroom.tool","command.palette"]),Ft=new Set(["student.view","student.dashboard.widget"]);function Xe(R){if(!R||typeof R!="string")return"0.0.0";const C=R.trim().match(/(\d+)(?:\.(\d+))?(?:\.(\d+))?/);return C?`${C[1]}.${C[2]||"0"}.${C[3]||"0"}`:"0.0.0"}function $t(R,C){const a=Xe(R).split(".").map(c=>parseInt(c,10)),N=Xe(C).split(".").map(c=>parseInt(c,10));for(let c=0;c<3;c++){if(a[c]<N[c])return-1;if(a[c]>N[c])return 1}return 0}function Lt({isOpen:R,onClose:C,lang:a,file:N,onConfirmInstall:c,lockedTargetPluginId:o=null,installedPlugins:h=[]}){const[n,f]=K.useState(0),[p,k]=K.useState(null),[b,w]=K.useState([]),[i,x]=K.useState([]),[s,d]=K.useState(null),[l,g]=K.useState(!1),[y,v]=K.useState(!1),[j,P]=K.useState("process"),[E,M]=K.useState(!1),[T,G]=K.useState(!1),[te,_]=K.useState(!1),[B,r]=K.useState(null),[L,ee]=K.useState(null),[W,ne]=K.useState(!1),[H,O]=K.useState(!1),[I,z]=K.useState(""),[Q,Y]=K.useState(0),[q,ue]=K.useState("teacher"),[he,ae]=K.useState([]),[de,ce]=K.useState(!1),[ie,ge]=K.useState(null),[xe,t]=K.useState(!1),[$,D]=K.useState(!1);K.useEffect(()=>{R&&N&&(f(0),k(null),w([]),d(null),g(!1),v(!1),P("process"),M(!1),r(null),ee(null),ae([]),x([]),ue("teacher"),ge(null),t(!1),D(!1),m(N))},[R,N]);const m=async Z=>{ne(!0),ee(null);try{const le=await Ot.loadAsync(Z);r(le);const re=le.file("manifest.json");if(!re)throw new Error(a==="zh"?"ZIP 包中缺少 manifest.json 声明文件":"manifest.json missing in ZIP package");const me=await re.async("string"),be=JSON.parse(me);if(!be.id||!be.name)throw new Error(a==="zh"?"manifest.json 缺少必填字段 id 或 name":"manifest.json missing required id or name field");k(be),w(be.capabilitiesProposed||[]),d(be.contributes||null),g(!!le.file("frontend.js")),ae(Ye(be)),P("process"),await u(be)}catch(le){ee(le.message||"ZIP parse error")}finally{ne(!1)}},u=async Z=>{if(ge(null),t(!1),D(!1),!Z?.id)return;if(o){const re=h.find(be=>be.id===o);let me=null;try{me=re?JSON.parse(re.manifest):null}catch{me=null}if(me?.id&&me.id!==Z.id){ee(a==="zh"?`ZIP 的插件 ID(${Z.id})与当前卡片(${me.id})不一致,无法更新。`:`ZIP manifest.id (${Z.id}) does not match this plugin (${me.id}).`);return}ge({pluginId:o,name:re?.name||me?.name||Z.name,version:re?.version||me?.version||"0.0.0",status:re?.status||"unknown",isSystem:!1,manifestId:Z.id});return}const le=h.find(re=>{try{return JSON.parse(re.manifest)?.id===Z.id}catch{return!1}});if(le){let re={};try{re=JSON.parse(le.manifest)}catch{re={}}ge({pluginId:le.id,name:le.name||re.name||Z.name,version:le.version||re.version||"0.0.0",status:le.status,isSystem:!1,manifestId:Z.id});return}try{const me=await(await fetch(`/api/plugins/by-manifest/${encodeURIComponent(Z.id)}`)).json();if(me?.success&&me.installed){if(me.isSystem){ee(a==="zh"?"系统核心插件禁止通过插件中心更新。":"System plugins cannot be updated here.");return}ge({pluginId:me.pluginId,name:me.name,version:me.version||"0.0.0",status:me.status,isSystem:!!me.isSystem,manifestId:Z.id})}}catch(re){console.warn("Failed to detect existing plugin install",re)}};K.useEffect(()=>{if(n!==3||!B)return;let Z=!1;return(async()=>{ce(!0);try{const le=B.file("frontend.js"),re=le?await le.async("string"):"",me=Ye(p),be=Dt(re);if(Z)return;ae(Ut(me,be)),x([{name:"index.js",size:B.file("index.js")?(await B.file("index.js").async("string")).length:0},{name:"frontend.js",size:re.length},{name:"manifest.json",size:B.file("manifest.json")?(await B.file("manifest.json").async("string")).length:0}])}catch(le){console.warn("Extension point preview failed:",le)}finally{Z||ce(!1)}})(),()=>{Z=!0}},[n,B,p,l]);const S=K.useMemo(()=>{const Z=q==="teacher"?Bt:Ft,le=he.filter(re=>Z.has(re.slot));return le.length>0?le:he},[he,q]),F="process",U=!!ie,A=U&&$t(p?.version||"0.0.0",ie.version)<0,V=U&&ie.status==="active"&&(he.some(Z=>["classroom.tool","student.view","teacher.tab","workspace.view"].includes(Z.slot))||!!(p?.classroomTools&&p.classroomTools.length>0)||!!(p?.contributes&&Object.keys(p.contributes).length>0)),X=!(!N||!p||ie?.isSystem||A&&!xe||V&&!$),J=async()=>{if(!(!N||!X)){O(!0),ee(null),Y(10),z(a==="zh"?U?"正在上传并更新...":"正在上传并安装...":U?"Uploading and updating...":"Uploading and installing...");try{await c(N,F,{mode:U?"update":"install",targetPluginId:ie?.pluginId,allowDowngrade:A?xe:!1,approvePublicRoutes:E,approveCapabilities:T,approveNetworkHosts:te}),Y(100),z(a==="zh"?U?"更新完成":"安装完成":U?"Updated":"Complete"),C()}catch(Z){console.error(Z),ee(Z?.message||(a==="zh"?U?"更新失败":"安装失败":U?"Update failed":"Installation failed")),Y(0),z("")}finally{O(!1)}}},se=async()=>{if(!(!N||W||H)){v(!0),t(!0),D(!0),O(!0),ee(null),Y(20),z(a==="zh"?U?"极速同意全套授权,正在更新...":"极速同意全套授权,正在安装...":U?"Express approving terms & updating...":"Express approving terms & installing...");try{await c(N,F,{mode:U?"update":"install",targetPluginId:ie?.pluginId,allowDowngrade:!0,approvePublicRoutes:E,approveCapabilities:T,approveNetworkHosts:te}),Y(100),z(a==="zh"?U?"更新完成":"安装完成":U?"Updated":"Complete"),C()}catch(Z){console.error(Z),ee(Z?.message||(a==="zh"?U?"更新失败":"安装失败":U?"Update failed":"Installation failed")),Y(0),z("")}finally{O(!1)}}};if(!R)return null;const fe=Tt(Array.isArray(p?.network?.outbound)?p.network.outbound:[]),oe=fe.filter(Z=>Z.approvable).map(Z=>Z.host),pe=fe.filter(Z=>!Z.approvable).map(Z=>({raw:Z.raw,reason:Z.reason||""})),ke=Z=>{const le=["db:schema","management:write","network:access"],re=["whiteboard:write","vfs:write","lesson:write","class:write"];return le.includes(Z)?{level:"high",label:a==="zh"?"🔴 高危":"🔴 High",desc:a==="zh"?"可读写数据库、获取网络数据,存在敏感信息暴露与跨站点数据隐患。":"Can read/write DB or access network, sensitive data risk.",rowClass:"bg-rose-50/80 border-rose-200/90 hover:border-rose-300 shadow-2xs text-rose-950",badgeClass:"bg-rose-100 text-rose-700 border-rose-200 font-extrabold",codeClass:"bg-white border-rose-200 text-rose-900",descClass:"text-rose-800/90"}:re.includes(Z)?{level:"medium",label:a==="zh"?"🟡 中危":"🟡 Medium",desc:a==="zh"?"可在课表、白板中进行绘制修改或写入局部业务持久化数据。":"Can write to whiteboards or control course schedules.",rowClass:"bg-amber-50/80 border-amber-200/90 hover:border-amber-300 shadow-2xs text-amber-950",badgeClass:"bg-amber-100 text-amber-800 border-amber-200 font-extrabold",codeClass:"bg-white border-amber-200 text-amber-900",descClass:"text-amber-800/90"}:{level:"low",label:a==="zh"?"🟢 低危":"🟢 Low",desc:a==="zh"?"常规的基础界面弹窗与局域隔离存储能力,安全可信。":"Basic UI elements or isolated local storage.",rowClass:"bg-emerald-50/70 border-emerald-200/90 hover:border-emerald-300 shadow-2xs text-emerald-950",badgeClass:"bg-emerald-100 text-emerald-800 border-emerald-200 font-extrabold",codeClass:"bg-white border-emerald-200 text-emerald-900",descClass:"text-emerald-800/90"}};return e.jsx("div",{className:"fixed inset-0 bg-slate-900/60 backdrop-blur-2xs flex items-center justify-center overflow-y-auto select-none",style:{zIndex:9999},children:e.jsxs("div",{className:"bg-white border border-slate-200 shadow-2xl rounded-2xl w-full max-w-2xl p-6 md:p-7 relative flex flex-col justify-between max-h-[90vh]",children:[e.jsxs("div",{className:"flex justify-between items-center border-b border-slate-100 pb-4 shrink-0",children:[e.jsxs("h2",{className:"font-extrabold text-base md:text-lg text-slate-800 flex items-center gap-2",children:[e.jsx($e,{className:"text-indigo-600 animate-pulse",size:20}),a==="zh"?`${U?"三方插件更新向导":"三方插件安装向导"} (${n+1}/5)`:`${U?"Plugin Update Wizard":"Plugin Setup Wizard"} (${n+1}/5)`]}),e.jsx("button",{onClick:C,className:"text-gray-400 hover:text-gray-650 cursor-pointer",children:e.jsx(ze,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-5 min-h-[300px]",children:W?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-indigo-600 gap-2",children:[e.jsx(ye,{size:36,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-semibold",children:a==="zh"?"正在解压并审计文件...":"Extracting and auditing package..."})]}):L?e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-xl p-4 text-red-700 flex items-start gap-2.5",children:[e.jsx(_e,{size:18,className:"shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-sm",children:a==="zh"?"校验未通过,安装中断":"Verification Failed"}),e.jsx("p",{className:"text-xs mt-1 leading-relaxed",children:L})]})]}):e.jsxs(e.Fragment,{children:[n===0&&p&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-indigo-50/50 border border-indigo-100 rounded-xl p-4 flex gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-indigo-600 text-white rounded-lg flex items-center justify-center shrink-0 shadow-sm font-bold text-lg uppercase",children:p.name.charAt(0)}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-extrabold text-slate-900 text-base",children:p.name}),e.jsxs("p",{className:"text-xs font-mono text-gray-500 mt-1",children:["ID: ",p.id," | v",p.version||"1.0.0"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-slate-700 text-xs mb-1.5",children:a==="zh"?"功能描述":"Description"}),e.jsx("p",{className:"text-xs text-gray-600 leading-relaxed bg-slate-50 border border-slate-100 p-3 rounded-lg font-medium",children:p.description||(a==="zh"?"该插件暂无详细描述信息。":"No description provided for this plugin.")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[e.jsxs("div",{className:"border border-slate-100 rounded-xl p-3 bg-slate-50/30",children:[e.jsx("span",{className:"text-xs text-gray-400 block font-semibold",children:a==="zh"?"主程序入口":"Main Entry"}),e.jsx("span",{className:"text-xs font-bold text-slate-700 font-mono mt-0.5 block",children:p.main||"index.js"})]}),e.jsxs("div",{className:"border border-slate-100 rounded-xl p-3 bg-slate-50/30",children:[e.jsx("span",{className:"text-xs text-gray-400 block font-semibold",children:a==="zh"?"前端沙箱包":"Frontend UI Asset"}),e.jsx("span",{className:`text-xs font-bold mt-0.5 block ${l?"text-indigo-600":"text-gray-500"}`,children:l?a==="zh"?"包含 (frontend.js)":"Included (frontend.js)":a==="zh"?"无":"None"})]})]}),ie&&e.jsxs("div",{className:`mt-1 rounded-xl border p-4 ${A?"border-red-200 bg-red-50/50":"border-amber-200 bg-amber-50/40"}`,children:[e.jsx("h4",{className:"text-xs font-extrabold text-slate-800 mb-2",children:a==="zh"?"检测到已安装同一插件 — 将执行原地更新":"Same plugin already installed — in-place update"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"bg-white/70 border border-slate-100 rounded-lg p-2",children:[e.jsx("div",{className:"text-slate-400 font-semibold",children:a==="zh"?"当前版本":"Installed"}),e.jsxs("div",{className:"font-bold text-slate-800 mt-0.5",children:[ie.name,e.jsxs("span",{className:"font-mono text-slate-500 ml-1",children:["v",ie.version]})]}),e.jsx("div",{className:"text-xs text-slate-400 mt-1 font-mono",children:ie.status==="active"?a==="zh"?"状态: 运行中":"status: active":a==="zh"?"状态: 未启用":"status: inactive"})]}),e.jsxs("div",{className:"bg-white/70 border border-slate-100 rounded-lg p-2",children:[e.jsx("div",{className:"text-slate-400 font-semibold",children:a==="zh"?"ZIP 新版本":"Package"}),e.jsxs("div",{className:"font-bold text-slate-800 mt-0.5",children:[p.name,e.jsxs("span",{className:"font-mono text-indigo-600 ml-1",children:["v",p.version||"0.0.0"]})]}),e.jsx("div",{className:"text-xs text-slate-400 mt-1",children:a==="zh"?"保留配置 / 业务数据 / UUID":"Keeps config, data & UUID"})]})]}),A&&e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-xs font-bold text-red-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:xe,onChange:Z=>t(Z.target.checked)}),e.jsx("span",{children:a==="zh"?`确认强制降级:v${ie.version} → v${p.version||"0.0.0"}(可能不兼容)`:`Force downgrade v${ie.version} → v${p.version||"0.0.0"} (may be incompatible)`})]}),V&&e.jsxs("label",{className:"mt-2 flex items-start gap-2 text-xs font-bold text-amber-800 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:$,onChange:Z=>D(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"该插件当前为启用状态且声明了课堂/教学扩展点,热更新可能导致课中 UI 短暂异常。我已知晓并继续。":"Plugin is active with classroom UI contributions. Hot-update may briefly disrupt live class UI. I understand."})]})]})]}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium mb-1",children:a==="zh"?"此插件申请了以下系统权限,请仔细评估安装后可能产生的风控隐患:":"This plugin requests the following capabilities, please review carefully:"}),b.length===0?e.jsx("div",{className:"text-center p-8 bg-emerald-50 border border-emerald-100 rounded-xl text-emerald-700 font-bold text-xs",children:a==="zh"?"✓ 该插件未申请任何敏感系统权限,可安全安装。":"✓ This plugin requires no system capabilities, very safe."}):e.jsx("div",{className:"space-y-3 max-h-[220px] overflow-y-auto pr-1",children:b.map(Z=>{const le=ke(Z);return e.jsxs("div",{className:`border rounded-xl p-3.5 flex flex-col gap-1 transition-all ${le.rowClass}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`font-mono text-xs font-bold rounded px-2 py-0.5 shadow-2xs ${le.codeClass}`,children:Z}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-md border ${le.badgeClass}`,children:le.label})]}),e.jsx("p",{className:`text-xs leading-relaxed font-medium mt-1 ${le.descClass}`,children:le.desc})]},Z)})}),b.length>0&&e.jsxs("label",{className:"flex items-start gap-2 border border-orange-100 rounded-xl p-3 bg-orange-50/30 cursor-pointer mt-2 text-xs text-orange-850 font-bold leading-normal",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:Z=>v(Z.target.checked),className:"mt-0.5 w-3.5 h-3.5 rounded text-orange-600 border-orange-300 focus:ring-orange-500 cursor-pointer shrink-0"}),e.jsx("span",{children:a==="zh"?"我已了解并信任此插件的提供商,愿意授予上述高级系统权限。":"I trust the developer and agree to grant all requested capabilities."})]})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:a==="zh"?"插件将向系统注册并扩展以下槽位(Slots)与自定义命令:":"The plugin will inject UI slots or register custom commands:"}),e.jsx("div",{className:"border border-slate-150/65 rounded-xl p-4 bg-slate-50/50 space-y-4",children:s?e.jsxs(e.Fragment,{children:[s.teacher?.dashboard?.widget&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-bold text-slate-700 block mb-1",children:"插槽: 教师端侧栏卡片"}),e.jsxs("span",{className:"text-gray-500 font-mono",children:["teacher.dashboard.widget → ",s.teacher.dashboard.widget]})]}),s.student?.view&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-bold text-slate-700 block mb-1",children:"插槽: 学生答题看板"}),e.jsxs("span",{className:"text-gray-500 font-mono",children:["student.view → ",s.student.view]})]}),p.capabilitiesProposed&&p.capabilitiesProposed.length>0&&e.jsxs("div",{className:"text-xs border-t border-slate-100 pt-3",children:[e.jsx("span",{className:"font-bold text-slate-700 block mb-1",children:a==="zh"?"注册指令集":"Commands Registered"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:p.capabilitiesProposed.map(Z=>e.jsx("span",{className:"bg-indigo-50 border border-indigo-150/60 rounded px-1.5 py-0.5 text-indigo-700 font-mono",children:Z.replace(":write",".create")},Z))})]})]}):e.jsx("div",{className:"text-center text-xs text-slate-400 italic py-6",children:a==="zh"?"此插件没有提供任何额外的槽位注册项。":"This plugin contributes no extension points."})})]}),n===3&&e.jsxs("div",{className:"flex flex-col gap-3 h-full",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0 gap-3",children:[e.jsx("p",{className:"text-xs text-slate-500 font-semibold",children:a==="zh"?"检测到的扩展点(静态分析预览):":"Detected extension points (static analysis):"}),e.jsxs("div",{className:"flex bg-slate-100 p-0.5 rounded-lg border border-slate-200 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>ue("teacher"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer ${q==="teacher"?"bg-white shadow text-indigo-650":"text-slate-550 hover:text-slate-800"}`,children:a==="zh"?"教师端相关":"Teacher slots"}),e.jsx("button",{type:"button",onClick:()=>ue("student"),className:`px-3 py-1 rounded-md text-xs font-bold transition-all cursor-pointer ${q==="student"?"bg-white shadow text-indigo-650":"text-slate-550 hover:text-slate-800"}`,children:a==="zh"?"学生端相关":"Student slots"})]})]}),e.jsx("div",{className:"border border-slate-200/80 rounded-xl p-4 bg-slate-50/50 flex-grow overflow-auto min-h-[220px] max-h-[300px]",children:e.jsx("div",{className:"h-full bg-white rounded-lg p-4 border border-slate-100 shadow-sm",children:de?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-indigo-600",children:[e.jsx(ye,{size:22,className:"animate-spin"}),e.jsx("span",{className:"text-xs font-semibold",children:a==="zh"?"正在分析扩展点…":"Analyzing extension points…"})]}):S.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-center text-xs text-slate-400 italic px-4",children:a==="zh"?"未检测到扩展点注册(manifest.contributes / frontend.js)。":"No extension points detected in manifest or frontend.js."}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-500",children:a==="zh"?`共 ${S.length} 项(按「${q==="teacher"?"教师端":"学生端"}」筛选)`:`${S.length} item(s) for ${q} view`}),e.jsx("ul",{className:"space-y-2",children:S.map(Z=>e.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-lg border border-slate-100 bg-slate-50/60 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-bold text-slate-800 truncate",children:Z.label}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono mt-0.5 truncate",children:[Z.slot,Z.id&&Z.id!=="?"?` · ${Z.id}`:""]})]}),e.jsx("span",{className:`shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded border ${Z.source==="manifest"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-indigo-50 text-indigo-700 border-indigo-100"}`,children:Z.source==="manifest"?"manifest":"frontend.js"})]},`${Z.source}-${Z.slot}-${Z.id}`))}),i.length>0&&e.jsxs("div",{className:"pt-2 border-t border-slate-100",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-400 mb-1",children:a==="zh"?"包内文件":"Package files"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(Z=>e.jsxs("span",{className:"text-xs font-mono bg-white border border-slate-150 rounded px-1.5 py-0.5 text-slate-600",children:[Z.name,Z.size>0?` (${Math.max(1,Math.round(Z.size/1024))} KB)`:""]},Z.name))})]})]})})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-550 font-medium shrink-0 bg-indigo-50/40 p-2 border border-indigo-100/40 rounded-lg",children:[e.jsx(Le,{size:11,className:"text-indigo-600"}),e.jsx("span",{children:a==="zh"?"此步骤为静态扫描结果,不会执行插件代码。中文标签已从 JS 转义序列还原;优先展示 manifest 声明,frontend.js 作为补充。":"Static scan only — plugin code is not executed. Unicode escapes in JS labels are decoded; manifest entries take priority over frontend.js."})]})]}),n===4&&e.jsxs("div",{className:"flex flex-col gap-4",children:[ie&&e.jsxs("div",{className:`rounded-xl border p-3 text-xs ${A?"border-red-200 bg-red-50/60":"border-amber-200 bg-amber-50/50"}`,children:[e.jsx("div",{className:"font-extrabold text-slate-800 mb-1",children:a==="zh"?`更新确认:v${ie.version} → v${p?.version||"0.0.0"}`:`Update: v${ie.version} → v${p?.version||"0.0.0"}`}),e.jsx("div",{className:"text-slate-600",children:a==="zh"?"将原地替换代码与静态资源,保留 UUID、配置与业务数据。":"Replaces code/assets in place. UUID, config and data are preserved."}),A&&e.jsxs("label",{className:"mt-2 flex items-start gap-2 font-bold text-red-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:xe,onChange:Z=>t(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"确认强制降级":"Confirm forced downgrade"})]}),V&&e.jsxs("label",{className:"mt-2 flex items-start gap-2 font-bold text-amber-800 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:$,onChange:Z=>D(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"已知晓课中热更新风险":"I accept live-class hot-update risk"})]}),!X&&e.jsx("p",{className:"mt-2 text-red-600 font-semibold",children:a==="zh"?"请先完成上方确认项后再更新。":"Complete the confirmation checks above before updating."})]}),e.jsx("p",{className:"text-xs text-slate-500 font-medium",children:a==="zh"?"设置该插件启动时的执行隔离:":"Choose how this plugin is isolated at startup:"}),e.jsxs("div",{"data-testid":"wizard-isolation-lock",className:"border border-sky-200 bg-sky-50/70 rounded-xl p-4 text-xs text-sky-950 leading-relaxed",children:[e.jsx("h4",{className:"font-extrabold text-sm",children:a==="zh"?"子进程隔离(已锁定)":"Child-process isolation (locked)"}),e.jsx("p",{className:"mt-1",children:a==="zh"?"上传的包固定以独立子进程运行,不继承密钥类环境变量。id 前缀不能证明它是内置插件。只有内置目录或 OPENLEARN_TRUSTED_INLINE_PLUGINS 白名单里的包才可以进程内运行,而且那一步由服务端决定。":"Uploaded packages stay in a child process and do not inherit secret environment variables. An id prefix does not make a package built-in. Only the built-in directory or OPENLEARN_TRUSTED_INLINE_PLUGINS can run in-process, and the server makes that decision."})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:E,onChange:Z=>M(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"批准清单中声明为公开的路由(auth: false)。不勾选则这些路由仍要求登录。":"Approve routes the manifest marks public (auth: false). Leave unchecked and those routes still require a session."})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5",checked:T,onChange:Z=>G(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"确认授予清单申请的能力。不勾选则这些能力不会生效。通配符 * 不会被授予。":"Approve the capabilities this manifest requests. Leave unchecked and they stay inactive. Wildcard capabilities are never granted."})]}),oe.length>0&&e.jsxs("div",{className:"border border-amber-200 bg-amber-50/60 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-extrabold text-amber-900",children:a==="zh"?"出站网络域名(清单申请)":"Outbound hosts requested by the manifest"}),e.jsx("span",{className:"text-[10px] font-mono text-amber-700 bg-amber-100 border border-amber-200 rounded px-1.5 py-0.5",children:oe.length})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:oe.map(Z=>{const le=pe.some(re=>re.raw===Z);return e.jsx("span",{title:le?pe.find(re=>re.raw===Z)?.reason:a==="zh"?"批准后该域名可被插件访问":"Approve to allow the plugin to reach this host",className:"font-mono text-[11px] rounded px-1.5 py-0.5 border "+(le?"bg-rose-50 text-rose-700 border-rose-200 line-through":"bg-white text-slate-700 border-slate-200"),children:Z},Z)})}),pe.length>0&&e.jsx("p",{className:"text-[11px] text-rose-700 leading-relaxed",children:a==="zh"?`${pe.length} 项声明永远不会被批准:${pe.map(Z=>`${Z.raw}(${Z.reason})`).join("、")}`:`${pe.length} declaration(s) can never be approved: ${pe.map(Z=>`${Z.raw} (${Z.reason})`).join(", ")}`}),e.jsxs("label",{className:"flex items-start gap-2 text-xs text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5","data-testid":"approve-network-hosts",checked:te,onChange:Z=>_(Z.target.checked)}),e.jsx("span",{children:a==="zh"?"批准清单申请的上方可访问域名。不勾选则插件无法发起任何出站请求(默认拒绝)。私有/回环/通配符即使勾选也不会被授予。":"Approve the outbound hosts above. Leave unchecked and the plugin cannot reach any external host (default deny). Private/loopback/wildcard entries are never granted."})]})]})]})]})}),e.jsxs("div",{className:"flex items-center justify-between border-t border-slate-100 pt-4 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2,3,4].map(Z=>e.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${Z===n?"w-4 bg-indigo-650":"w-1.5 bg-slate-200"}`},Z))}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0?e.jsxs("button",{type:"button",onClick:()=>f(Z=>Z-1),className:"flex items-center gap-1.5 px-3.5 py-2 border border-slate-200 rounded-lg text-xs font-semibold text-slate-600 hover:bg-slate-50 transition-colors cursor-pointer",children:[e.jsx(ft,{size:12}),a==="zh"?"上一步":"Back"]}):e.jsx("button",{type:"button",onClick:C,className:"px-3.5 py-2 border border-slate-200 rounded-lg text-xs font-semibold text-slate-400 hover:bg-slate-50 transition-colors cursor-pointer",children:a==="zh"?"取消":"Cancel"}),!H&&N&&p&&!ie?.isSystem&&e.jsxs("button",{type:"button",onClick:se,className:"flex items-center gap-1.5 px-3.5 py-2 bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-600 hover:to-amber-700 text-white rounded-lg text-xs font-bold shadow-xs transition-all cursor-pointer",title:a==="zh"?"同意全套权限与提示,直接安装完成":"Approve terms and install directly",children:[e.jsx(mt,{size:13,className:"fill-amber-200"}),e.jsx("span",{children:a==="zh"?U?"一键极速更新":"一键极速安装":U?"Express Update":"Express Install"})]}),n===1&&b.length>0&&!y?e.jsxs("button",{type:"button",disabled:!0,className:"flex items-center gap-1.5 px-4 py-2 bg-gray-200 text-gray-400 rounded-lg text-xs font-semibold cursor-not-allowed",children:[a==="zh"?"请先授权同意":"Accept terms first",e.jsx(Ge,{size:12})]}):n<4?e.jsxs("button",{type:"button",onClick:()=>f(Z=>Z+1),className:"flex items-center gap-1.5 px-4 py-2 bg-slate-900 text-white rounded-lg text-xs font-semibold hover:bg-slate-800 transition-colors cursor-pointer",children:[a==="zh"?"下一步":"Next",e.jsx(Ge,{size:12})]}):e.jsx("button",{type:"button",onClick:J,disabled:H||!X,className:"flex items-center gap-1.5 px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-bold shadow-sm transition-colors cursor-pointer disabled:bg-indigo-400",children:H?e.jsxs("div",{className:"flex flex-col gap-1.5 min-w-32",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ye,{size:13,className:"animate-spin"}),e.jsx("span",{children:a==="zh"?U?"更新中...":"安装中...":U?"Updating...":"Installing..."})]}),e.jsx("div",{className:"w-full h-1 bg-indigo-400/30 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-white/80 rounded-full transition-all duration-500",style:{width:`${Math.max(Q,5)}%`}})}),I&&e.jsxs("div",{className:"text-xs text-indigo-200 truncate max-w-40",children:[Q,"% — ",I]})]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{size:13}),a==="zh"?U?"确认更新并上传":"确认安装并上传":U?"Confirm & Update":"Confirm & Install"]})})]})]})]})})}function Mt({lang:R}){return e.jsxs("span",{className:"inline-flex items-center gap-1 bg-amber-50 text-amber-700 border border-amber-200 text-xs font-bold px-2 py-1 rounded uppercase tracking-wider",title:R==="zh"?"该插件使用旧执行格式运行。新格式版本可能可用。":"This plugin uses the old execution format. A new-format version may be available.",children:[e.jsx(_e,{size:10}),R==="zh"?"可迁移":"Migratable"]})}function Zt({plugins:R,lang:C,showSystemPlugins:a,marketMap:N,checkingUpdateId:c,oneClickUpdatingId:o,handleCheckUpdate:h,handleOneClickUpdate:n,setChangelogModalPlugin:f,setSettingsPlugin:p,setUpdateTargetPluginId:k,updateFileInputRef:b,onToggle:w,onDelete:i}){const x=Ve(s=>s.dashboardVisibility);return e.jsx("div",{className:"flex-1 overflow-y-auto p-6 bg-gray-50/30",children:e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-4 gap-4",children:R.filter(s=>{const d=s.id.startsWith("@openlearn/");return a?!0:!d}).map(s=>{let d={description:"扩展 Openlearn Next 功能的自定义插件。",author:"Community",version:"",manifestId:"",capabilities:[],toolCount:0,studentViewCount:0,teacherWidgetCount:0,hasConfig:!1,repository:"",homepage:""};try{const E=JSON.parse(s.manifest);E.description&&(d.description=E.description),E.author&&(d.author=E.author),E.version&&(d.version=E.version),E.id&&(d.manifestId=E.id),E.repository&&(d.repository=typeof E.repository=="string"?E.repository:E.repository.url||""),E.homepage&&(d.homepage=E.homepage),E.capabilitiesProposed&&(d.capabilities=E.capabilitiesProposed),E.contributes?.["classroom.tool"]?d.toolCount=E.contributes["classroom.tool"].length:E.classroomTools&&(d.toolCount=E.classroomTools.length),E.contributes?.["student.view"]&&(d.studentViewCount=E.contributes["student.view"].length),E.contributes?.["teacher.dashboard.widget"]&&(d.teacherWidgetCount=E.contributes["teacher.dashboard.widget"].length);const M=E.configuration?.properties;M&&Object.keys(M).length>0&&(d.hasConfig=!0),E.updateSource?.type&&E.updateSource?.repo&&(d.updateSource=E.updateSource)}catch{}const l=s.created_at?new Date(s.created_at).toLocaleDateString(C==="zh"?"zh-CN":"en-US",{year:"numeric",month:"short",day:"numeric"}):"—",g=s.id.startsWith("@openlearn/"),y=x.get(s.id)??!0,v=N.get(d.manifestId||s.id),j=!!v?.hasUpdate,P=v?.error||null;return e.jsxs("div",{className:`bg-white rounded-xl border border-gray-200 p-5 shadow-sm hover:shadow-md transition-all relative overflow-hidden group flex flex-col gap-3 h-full ${s.status!=="active"?"opacity-75":""}`,children:[e.jsxs("div",{className:"absolute top-0 right-0 p-3 flex items-center gap-1.5 flex-wrap justify-end",children:[j&&e.jsx("span",{title:C==="zh"?`点击查看新特性${v.isPrerelease?"(预发布版本)":""}并升级至 v${v.latestVersion}`:`Upgradeable to v${v.latestVersion}${v.isPrerelease?" (pre-release)":""}`,className:`text-xs font-bold px-2.5 py-0.5 rounded-full shadow-sm flex items-center gap-1 shrink-0 cursor-pointer ${v.isPrerelease?"bg-gradient-to-r from-amber-500 to-orange-500 text-white animate-pulse":"bg-gradient-to-r from-blue-600 to-indigo-600 text-white animate-pulse"}`,onClick:()=>f({...s,marketItem:v}),children:e.jsxs("span",{children:[v.isPrerelease?"🔶 ":"⚡ ",C==="zh"?`${v.isPrerelease?"预发布 ":"发现新版本 "}v${v.latestVersion}`:`${v.isPrerelease?"Pre-release ":"New "}v${v.latestVersion}`]})}),P&&!j&&e.jsx("span",{title:P,className:"text-xs font-semibold bg-amber-50 text-amber-700 border border-amber-200 px-2.5 py-0.5 rounded-full flex items-center gap-1 shrink-0 cursor-default",children:e.jsxs("span",{children:["⚠️ ",C==="zh"?"检查失败":"Check failed"]})}),e.jsxs("span",{className:`text-xs font-semibold px-2.5 py-0.5 rounded-full flex items-center gap-1 border transition-all ${s.status==="active"?"bg-emerald-50 text-emerald-750 border-emerald-250":"bg-slate-100 text-slate-500 border-slate-200"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.status==="active"?"bg-emerald-500 animate-pulse":"bg-slate-400"}`}),e.jsx("span",{children:s.status==="active"?C==="zh"?"已启用":"ACTIVE":C==="zh"?"已停用":"INACTIVE"})]}),s.execution_mode==="esm"&&e.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 border border-indigo-150 px-1.5 py-0.5 rounded uppercase tracking-wider",children:"ESM"}),s.execution_mode==="legacy"&&e.jsx(Mt,{lang:C}),s.isolation_mode==="process"&&e.jsx("span",{className:"text-xs font-bold bg-sky-50 text-sky-800 border border-sky-200 px-1.5 py-0.5 rounded",children:C==="zh"?"子进程":"PROCESS"}),s.isolation_mode==="worker"&&e.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 border border-indigo-200 px-1.5 py-0.5 rounded",children:"Worker"}),s.isolation_mode==="inline"&&e.jsx("span",{className:"text-xs font-bold bg-amber-50 text-amber-800 border border-amber-200 px-1.5 py-0.5 rounded",children:C==="zh"?"进程内":"IN-PROCESS"}),g&&e.jsx("span",{className:"text-xs font-bold bg-violet-50 text-violet-700 border border-violet-200 px-1.5 py-0.5 rounded uppercase tracking-wider",children:C==="zh"?"系统":"SYSTEM"})]}),e.jsxs("div",{className:"flex items-start gap-3 pr-24",children:[e.jsx("div",{className:"w-11 h-11 bg-indigo-50 text-indigo-600 rounded-lg flex items-center justify-center border border-indigo-100 group-hover:bg-indigo-600 group-hover:text-white transition-colors shrink-0",children:e.jsx(xt,{size:22})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-semibold text-gray-900 line-clamp-1",children:s.name}),d.version&&e.jsxs("span",{className:"text-xs font-mono font-bold bg-gray-100 text-gray-500 border border-gray-200 px-1.5 py-0.5 rounded shrink-0",children:["v",d.version]})]}),d.manifestId&&e.jsx("p",{className:"text-xs text-gray-400 font-mono truncate mt-0.5",title:d.manifestId,children:d.manifestId})]})]}),e.jsx("p",{className:"text-xs text-gray-500 line-clamp-2 leading-relaxed",children:d.description}),(d.toolCount>0||d.studentViewCount>0||d.teacherWidgetCount>0)&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[d.toolCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium bg-indigo-50 text-indigo-600 border border-indigo-100 px-2 py-0.5 rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-400"}),C==="zh"?`${d.toolCount} 个课堂工具`:`${d.toolCount} classroom tool${d.toolCount>1?"s":""}`]}),d.studentViewCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium bg-sky-50 text-sky-600 border border-sky-100 px-2 py-0.5 rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400"}),C==="zh"?`${d.studentViewCount} 个学生视图`:`${d.studentViewCount} student view${d.studentViewCount>1?"s":""}`]}),d.teacherWidgetCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium bg-amber-50 text-amber-600 border border-amber-100 px-2 py-0.5 rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),C==="zh"?`${d.teacherWidgetCount} 个教师组件`:`${d.teacherWidgetCount} teacher widget${d.teacherWidgetCount>1?"s":""}`]}),d.capabilities.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium bg-rose-50 text-rose-600 border border-rose-100 px-2 py-0.5 rounded-full",children:[e.jsx($e,{size:9}),C==="zh"?`${d.capabilities.length} 项权限`:`${d.capabilities.length} permission${d.capabilities.length>1?"s":""}`]})]}),e.jsxs("div",{className:"mt-auto flex flex-col gap-3 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 border-t border-gray-100 pt-2 gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[e.jsx(gt,{size:10,className:"shrink-0 text-gray-400"}),e.jsx("span",{className:"truncate",children:d.author})]}),je(d.repository||d.homepage||v?.repository)&&e.jsxs("a",{href:je(d.repository||d.homepage||v?.repository),target:"_blank",rel:"noopener noreferrer",title:C==="zh"?"查看 Git 开源仓库 (GitHub/Gitee)":"View Git Repository",className:"inline-flex items-center gap-1 text-xs font-mono text-indigo-600 hover:text-indigo-800 bg-indigo-50 hover:bg-indigo-100 px-1.5 py-0.5 rounded border border-indigo-200/60 transition-colors shrink-0",children:[e.jsx(Me,{size:10}),e.jsx("span",{className:"truncate max-w-[130px]",children:(d.repository||d.homepage||v?.repository).replace(/^https?:\/\//,"")})]})]}),e.jsxs("span",{className:"flex items-center gap-1 shrink-0 ml-auto",children:[e.jsx("span",{children:C==="zh"?"安装于":"Installed"}),e.jsx("span",{className:"font-mono",children:l})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap min-h-[34px]",children:[d.updateSource&&e.jsxs("button",{onClick:()=>h(s.id,d.manifestId||s.id),disabled:c===s.id,className:`px-2.5 py-1.5 text-xs font-medium rounded-lg border transition-colors flex items-center gap-1 cursor-pointer disabled:opacity-50 ${j?"border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100":P?"border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100":"border-gray-200 bg-gray-50 text-gray-600 hover:bg-gray-100"}`,title:C==="zh"?"手动检查远端更新":"Check for updates",children:[c===s.id?e.jsx(Ne,{size:12,className:"animate-spin"}):e.jsx(Ne,{size:12}),e.jsx("span",{children:C==="zh"?"检查更新":"Check"})]}),j?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>n(s.id,v),disabled:o===s.id,className:"px-3 py-1.5 text-xs font-semibold rounded-lg bg-gradient-to-r from-blue-600 to-indigo-600 text-white hover:from-blue-700 hover:to-indigo-700 shadow-sm transition-all flex items-center gap-1.5 disabled:opacity-50 cursor-pointer",children:o===s.id?e.jsx(Ne,{size:12,className:"animate-spin"}):e.jsxs("span",{children:["🚀"," ",C==="zh"?`一键热更新 v${v.latestVersion}`:`Update v${v.latestVersion}`]})}),e.jsxs("button",{onClick:()=>f({...s,marketItem:v}),className:"px-2.5 py-1.5 text-xs font-medium rounded-lg bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border border-indigo-200/60 transition-colors flex items-center gap-1 cursor-pointer",children:[e.jsx(bt,{size:12}),e.jsx("span",{children:C==="zh"?"新特性":"Notes"})]})]}):null,e.jsx("button",{onClick:()=>w(s.id),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-colors ${s.status==="active"?"bg-amber-50 text-amber-600 hover:bg-amber-100":"bg-green-50 text-green-600 hover:bg-green-100"}`,children:s.status==="active"?C==="zh"?"禁用":"Disable":C==="zh"?"启用":"Enable"}),e.jsxs("button",{onClick:()=>{const E=!y;Ve.getState().setDashboardVisibility(s.id,E)},title:y?C==="zh"?"在系统总览中隐藏":"Hide from Dashboard":C==="zh"?"在系统总览中显示":"Show in Dashboard",className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5 ${y?"bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border border-indigo-200/60":"bg-gray-50 text-gray-500 hover:bg-gray-100 border border-gray-200/60"}`,children:[e.jsx("span",{children:C==="zh"?"总览":"Dash"}),e.jsx("span",{className:`w-7 h-3.5 rounded-full transition-colors flex items-center p-0.5 shrink-0 ${y?"bg-indigo-600":"bg-gray-300"}`,children:e.jsx("span",{className:`w-2.5 h-2.5 rounded-full bg-white shadow-sm transition-transform ${y?"translate-x-3.5":"translate-x-0"}`})})]}),d.hasConfig&&e.jsxs("button",{onClick:()=>p({id:s.id,name:s.name,manifest:s.manifest}),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-indigo-50 text-indigo-600 hover:bg-indigo-100 transition-colors flex items-center gap-1",children:[e.jsx(Ue,{size:12}),C==="zh"?"设置":"Settings"]}),!g&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{k(s.id),b.current?.click()},className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-sky-50 text-sky-700 hover:bg-sky-100 transition-colors",children:C==="zh"?"更新":"Update"}),e.jsx("button",{onClick:()=>i(s.id),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-red-50 text-red-600 hover:bg-red-100 transition-colors",children:C==="zh"?"删除":"Delete"})]}),s.execution_mode==="legacy"&&e.jsx("button",{onClick:()=>document.getElementById("zip-plugin-uploader")?.click(),className:"px-3 py-1.5 text-xs font-medium rounded-lg bg-amber-600 text-white hover:bg-amber-700 transition-colors",title:C==="zh"?"上传新格式 ZIP 包以完成迁移":"Upload new-format ZIP package to migrate",children:C==="zh"?"迁移":"Migrate"})]})]})]},s.id)})})})}const Wt="/api/plugins/community",Ht="/api/plugins/install-from-url",Gt="/api/plugins/upload-zip-raw";function Vt(R){try{const C=new URL(R).pathname.split("/").filter(Boolean).pop();return C?decodeURIComponent(C):"plugin.zip"}catch{return"plugin.zip"}}function qt(R){if(!R)return null;try{return new URL(R).host}catch{return null}}function Qe(R,C){return R===null?null:R>=1e4?C==="zh"?`${(R/1e4).toFixed(1)} 万`:`${(R/1e3).toFixed(1)}k`:R>=1e3?C==="zh"?`${R}`:`${(R/1e3).toFixed(1)}k`:String(R)}function Jt({plugin:R}){const[C,a]=K.useState(!1),N=R.icon?.trim(),c=!!N&&(N.startsWith("http://")||N.startsWith("https://"));return c&&!C?e.jsx("img",{src:N,alt:"",className:"w-11 h-11 rounded-lg object-cover border border-gray-100 shrink-0",onError:()=>a(!0)}):N&&!c?e.jsx("div",{className:"w-11 h-11 rounded-lg bg-indigo-50 border border-indigo-100 flex items-center justify-center text-xl shrink-0",children:e.jsx("span",{"aria-hidden":!0,children:N})}):e.jsx("div",{className:"w-11 h-11 rounded-lg bg-indigo-50 text-indigo-600 border border-indigo-100 flex items-center justify-center font-bold shrink-0",children:R.name.slice(0,1).toUpperCase()})}function Kt(){return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-5 shadow-sm flex flex-col gap-3 animate-pulse",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg bg-gray-100 shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-100 rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-1/3"})]})]}),e.jsx("div",{className:"h-3 bg-gray-100 rounded"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-5/6"}),e.jsx("div",{className:"h-8 bg-gray-100 rounded-lg mt-2"})]})}function Yt({installedPlugins:R,lang:C,onInstalled:a,fetcher:N}){const c=C==="zh",o=K.useMemo(()=>N??((O,I)=>fetch(O,I)),[N]),[h,n]=K.useState("loading"),[f,p]=K.useState(null),[k,b]=K.useState(null),[w,i]=K.useState(""),[x,s]=K.useState(null),[d,l]=K.useState("recommended"),[g,y]=K.useState(!1),[v,j]=K.useState({}),[P,E]=K.useState(null),[M,T]=K.useState(!1),[G,te]=K.useState({}),_=K.useCallback(async O=>{n("loading"),b(null);try{const I=await o(`${Wt}${O?"?refresh=1":""}`),z=await I.json();if(!I.ok||!z?.success)throw new Error(z?.error||(c?"服务端拒绝请求":"Request rejected by the server"));p(z),z.error?(b(z.error),n("error")):n("ready")}catch(I){b(I instanceof Error?I.message:String(I)),n("error")}},[o,c]);K.useEffect(()=>{_(!1)},[_]);const B=K.useMemo(()=>{const O=new Set;for(const I of R)try{const z=JSON.parse(I.manifest);typeof z?.id=="string"&&z.id&&O.add(z.id)}catch{O.add(I.id)}return O},[R]),r=K.useCallback(O=>!!G[O.id]||B.has(O.id)||O.installedVersion!==null,[B,G]),L=K.useMemo(()=>{const O=new Map;for(const I of f?.plugins??[])for(const z of I.tags)O.set(z,(O.get(z)??0)+1);return Array.from(O.entries()).sort((I,z)=>z[1]-I[1]||I[0].localeCompare(z[0])).slice(0,12).map(([I])=>I)},[f]),ee=K.useMemo(()=>{const O=w.trim().toLowerCase();let I=(f?.plugins??[]).filter(z=>g&&r(z)||x&&!z.tags.includes(x)?!1:O?[z.name,z.id,z.description,z.author,z.tags.join(" ")].join(" ").toLowerCase().includes(O):!0);return d==="downloads"?I=[...I].sort((z,Q)=>(Q.downloads??-1)-(z.downloads??-1)):d==="name"&&(I=[...I].sort((z,Q)=>z.name.localeCompare(Q.name))),I},[x,f,g,r,w,d]),W=K.useCallback((O,I)=>{j(z=>{const Q={...z};return I?Q[O]=I:delete Q[O],Q})},[]),ne=K.useCallback(async(O,I)=>{W(O.id,{phase:"installing",message:c?"服务端下载不可用,改为浏览器直传…":"Server download unavailable, transferring from browser…"});const z=await o(O.downloadUrl);if(!z.ok)throw new Error(`${c?"浏览器下载失败":"Browser download failed"}: HTTP ${z.status}`);const Q=await z.blob();if(Q.size===0)throw new Error(c?"插件包为空":"The package is empty");const Y=Vt(O.downloadUrl),q=await o(Gt,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-filename":encodeURIComponent(Y),"x-community-install":"true","x-acknowledge-risk":"true",...O.integrity?{"x-integrity":O.integrity}:{},...O.signature?{"x-signature":O.signature}:{},...I?{"x-approve-public-routes":"true"}:{}},body:Q}),ue=await q.json().catch(()=>null);if(!q.ok||!ue?.success)throw new Error(ue?.error||(c?"浏览器直传失败":"Browser upload failed"))},[o,W,c]),H=K.useCallback(async(O,I)=>{W(O.id,{phase:"installing",message:c?"正在由服务端下载插件包…":"Server is downloading the package…"});try{const z=await o(Ht,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({downloadUrl:O.downloadUrl,expectedId:O.id,acknowledgeRisk:!0,approvePublicRoutes:I,...O.integrity?{integrity:O.integrity}:{},...O.signature?{signature:O.signature}:{}})}),Q=await z.json().catch(()=>null);if(!z.ok||!Q?.success)if(Q?.fallbackToClient)await ne(O,I);else throw z.status===403?new Error(c?"仅管理员可安装社区插件,请联系管理员。":"Only administrators can install plugins."):new Error(Q?.error||(c?"安装失败":"Installation failed"));te(Y=>({...Y,[O.id]:!0})),W(O.id,{phase:"success",message:c?"安装完成,请在「发现」页启用":"Installed — enable it on the Discover tab"}),a?.()}catch(z){W(O.id,{phase:"error",message:z instanceof Error?z.message:String(z)})}},[o,a,W,ne,c]);return h==="ready"&&f&&!f.configured?e.jsx("div",{className:"flex-1 overflow-y-auto p-6 bg-gray-50/30",children:e.jsxs("div",{className:"max-w-2xl mx-auto mt-10 bg-white border border-gray-200 rounded-2xl p-8 text-center shadow-sm",children:[e.jsx(Be,{size:44,className:"mx-auto text-indigo-300 mb-4"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:c?"尚未配置社区插件源":"No community registry configured"}),e.jsx("p",{className:"text-sm text-gray-500 mt-2 leading-relaxed",children:c?"社区市场会从一个远端 JSON 注册表读取可安装插件。请在服务端环境变量中配置地址后重启服务:":"The community market reads an installable-plugin list from a remote JSON registry. Set the environment variable on the server and restart:"}),e.jsxs("code",{className:"inline-block mt-4 px-3 py-1.5 rounded-lg bg-gray-900 text-gray-50 text-xs font-mono",children:[f.envVar||"PLUGIN_COMMUNITY_REGISTRY_URL","=","<https://example.com/community-plugins.json>"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-4",children:c?"地址仅允许公网 HTTP(S),回环与内网地址会被安全拦截。":"Only public HTTP(S) endpoints are allowed; loopback and private addresses are blocked."})]})}):e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 bg-gray-50/30",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(yt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:w,onChange:O=>i(O.target.value),placeholder:c?"搜索插件名称、作者或标签…":"Search by name, author or tag…","aria-label":c?"搜索社区插件":"Search community plugins",className:"w-full pl-9 pr-8 py-2 text-sm bg-white border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500/30 focus:border-indigo-300"}),w&&e.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":c?"清空搜索":"Clear search",className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 cursor-pointer",children:e.jsx(ze,{size:14})})]}),e.jsxs("select",{value:d,onChange:O=>l(O.target.value),"aria-label":c?"排序方式":"Sort order",className:"px-3 py-2 text-sm bg-white border border-gray-200 rounded-lg text-gray-600 cursor-pointer focus:outline-none focus:ring-2 focus:ring-indigo-500/30",children:[e.jsx("option",{value:"recommended",children:c?"推荐排序":"Recommended"}),e.jsx("option",{value:"downloads",children:c?"下载最多":"Most downloaded"}),e.jsx("option",{value:"name",children:c?"按名称":"By name"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-xs font-semibold text-gray-500 hover:text-gray-900 select-none transition-colors border border-gray-200 rounded-lg px-3 py-2 bg-white shadow-sm",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:O=>y(O.target.checked),className:"w-3.5 h-3.5 rounded text-indigo-600 border-gray-300 focus:ring-indigo-500 cursor-pointer"}),e.jsx("span",{children:c?"隐藏已安装":"Hide installed"})]}),e.jsxs("button",{type:"button",onClick:()=>void _(!0),disabled:h==="loading",className:"flex items-center gap-1.5 text-xs font-semibold border border-gray-200 rounded-lg px-3 py-2 bg-white shadow-sm text-gray-600 hover:text-gray-900 hover:border-gray-300 transition-colors disabled:opacity-50 cursor-pointer",children:[h==="loading"?e.jsx(ye,{size:14,className:"animate-spin"}):e.jsx(Ne,{size:14}),e.jsx("span",{children:c?"刷新":"Refresh"})]})]}),f?.source&&h==="ready"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4 text-xs text-gray-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Be,{size:11}),e.jsx("span",{className:"font-mono",children:qt(f.source)})]}),e.jsx("span",{children:c?`${ee.length} / ${f.plugins.length} 个插件`:`${ee.length} of ${f.plugins.length} plugins`}),f.fetchedAt&&e.jsxs("span",{className:"font-mono",children:[c?"更新于 ":"Fetched ",new Date(f.fetchedAt).toLocaleTimeString(c?"zh-CN":"en-US",{hour:"2-digit",minute:"2-digit"})]}),f.skipped>0&&e.jsxs("span",{title:c?"注册表中存在格式非法或地址不安全的条目":"Registry entries with invalid format or unsafe URLs",children:["⚠️ ",c?`${f.skipped} 条记录被忽略`:`${f.skipped} entries ignored`]})]}),L.length>0&&h==="ready"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-4","data-testid":"community-tag-filters",children:[e.jsx("button",{type:"button",onClick:()=>s(null),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors cursor-pointer ${x===null?"bg-indigo-600 border-indigo-600 text-white":"bg-white border-gray-200 text-gray-500 hover:border-indigo-300 hover:text-indigo-600"}`,children:c?"全部":"All"}),L.map(O=>e.jsx("button",{type:"button",onClick:()=>s(x===O?null:O),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors cursor-pointer ${x===O?"bg-indigo-600 border-indigo-600 text-white":"bg-white border-gray-200 text-gray-500 hover:border-indigo-300 hover:text-indigo-600"}`,children:O},O))]}),h==="error"&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-5 flex items-start gap-3",role:"alert",children:[e.jsx(_e,{size:18,className:"text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-800",children:c?"社区插件市场加载失败":"Failed to load the community market"}),e.jsx("p",{className:"text-xs text-amber-700 mt-1 break-all",children:k}),e.jsx("button",{type:"button",onClick:()=>void _(!0),className:"mt-3 px-3 py-1.5 text-xs font-semibold rounded-lg bg-amber-600 text-white hover:bg-amber-700 transition-colors cursor-pointer",children:c?"重试":"Retry"})]})]}),h==="loading"&&e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4",children:Array.from({length:6},(O,I)=>e.jsx(Kt,{},I))}),h==="ready"&&ee.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx(vt,{size:44,className:"mx-auto text-gray-300 mb-3"}),e.jsx("p",{className:"text-sm font-medium text-gray-500",children:f?.plugins.length?c?"没有符合当前筛选条件的插件":"No plugins match the current filters":c?"社区注册表暂时没有可用插件":"The community registry has no plugins yet"}),f?.plugins.length?e.jsx("button",{type:"button",onClick:()=>{i(""),s(null),y(!1)},className:"mt-3 text-xs font-semibold text-indigo-600 hover:text-indigo-800 cursor-pointer",children:c?"清除筛选条件":"Clear filters"}):null]}),h==="ready"&&ee.length>0&&e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4",children:ee.map(O=>{const I=v[O.id],z=r(O),Q=z?O.hasUpdate?c?`更新至 v${O.version}`:`Update to v${O.version}`:c?"已安装":"Installed":c?"安装":"Install";return e.jsxs("article",{"data-testid":`community-card-${O.id}`,className:"bg-white rounded-xl border border-gray-200 p-5 shadow-sm hover:shadow-md transition-all flex flex-col gap-3 relative overflow-hidden",children:[e.jsxs("div",{className:"absolute top-0 right-0 p-3 flex items-center gap-1.5 flex-wrap justify-end",children:[O.featured&&e.jsxs("span",{className:"text-xs font-bold px-2 py-0.5 rounded-full bg-gradient-to-r from-amber-500 to-orange-500 text-white flex items-center gap-1 shadow-sm",children:[e.jsx(Le,{size:9}),c?"精选":"FEATURED"]}),O.verified&&e.jsxs("span",{title:c?"平台公钥验签通过":"Signed with the platform public key",className:"text-xs font-bold bg-emerald-50 text-emerald-700 border border-emerald-200 px-1.5 py-0.5 rounded-full flex items-center gap-0.5",children:[e.jsx(wt,{size:11}),c?"已认证":"VERIFIED"]})]}),e.jsxs("div",{className:"flex items-start gap-3 pr-20",children:[e.jsx(Jt,{plugin:O}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-bold text-gray-900 truncate",title:O.name,children:O.name}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-gray-400 min-w-0",children:[e.jsx("span",{className:"truncate",children:O.author}),O.version&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300",children:"·"}),e.jsxs("span",{className:"font-mono shrink-0",children:["v",O.version]})]})]})]})]}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed line-clamp-3 min-h-[3.6rem]",children:O.description||(c?"该插件未提供描述。":"No description provided.")}),(O.tags.length>0||O.capabilities.length>0)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[O.tags.slice(0,4).map(Y=>e.jsx("span",{className:"text-xs font-medium bg-slate-50 text-slate-600 border border-slate-200 px-2 py-0.5 rounded-full",children:Y},Y)),O.capabilities.length>0&&e.jsxs("span",{title:O.capabilities.join(`
14
+ `),className:"inline-flex items-center gap-1 text-xs font-medium bg-rose-50 text-rose-600 border border-rose-100 px-2 py-0.5 rounded-full",children:[e.jsx($e,{size:9}),c?`${O.capabilities.length} 项权限`:`${O.capabilities.length} permission${O.capabilities.length>1?"s":""}`]}),z&&O.installedVersion&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium bg-indigo-50 text-indigo-700 border border-indigo-100 px-2 py-0.5 rounded-full",children:[c?"已装":"Installed"," v",O.installedVersion]})]}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 border-t border-gray-100 pt-2 gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[O.downloads!==null&&e.jsxs("span",{className:"inline-flex items-center gap-1",title:c?"下载量":"Downloads",children:[e.jsx(Oe,{size:10}),Qe(O.downloads,C)]}),O.stars!==null&&e.jsxs("span",{className:"inline-flex items-center gap-1",title:c?"收藏数":"Stars",children:[e.jsx(jt,{size:10}),Qe(O.stars,C)]}),O.license&&e.jsx("span",{className:"font-mono",children:O.license})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[je(O.repository)&&e.jsxs("a",{href:je(O.repository),target:"_blank",rel:"noopener noreferrer",title:c?"查看源码仓库":"View source repository",className:"inline-flex items-center gap-1 text-xs font-mono text-indigo-600 hover:text-indigo-800 bg-indigo-50 hover:bg-indigo-100 px-1.5 py-0.5 rounded border border-indigo-200/60 transition-colors",children:[e.jsx(Me,{size:10}),e.jsx("span",{children:c?"源码":"Code"})]}),je(O.homepage)&&e.jsx("a",{href:je(O.homepage),target:"_blank",rel:"noopener noreferrer",title:c?"打开主页":"Open homepage",className:"inline-flex items-center gap-1 text-xs text-gray-500 hover:text-gray-800 bg-gray-50 hover:bg-gray-100 px-1.5 py-0.5 rounded border border-gray-200 transition-colors",children:e.jsx(et,{size:10})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{T(!1),E(O)},disabled:I?.phase==="installing"||z&&!O.hasUpdate,className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all flex items-center gap-1.5 disabled:cursor-default ${z&&!O.hasUpdate?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-gradient-to-r from-indigo-600 to-violet-600 text-white hover:from-indigo-700 hover:to-violet-700 shadow-sm disabled:opacity-60 cursor-pointer"}`,children:[I?.phase==="installing"?e.jsx(ye,{size:12,className:"animate-spin"}):z&&!O.hasUpdate?e.jsx(Ce,{size:12}):e.jsx(Oe,{size:12}),e.jsx("span",{children:Q})]}),I&&e.jsx("span",{className:`text-xs truncate ${I.phase==="error"?"text-rose-600":I.phase==="success"?"text-emerald-600":"text-gray-400"}`,title:I.message,role:I.phase==="error"?"alert":void 0,children:I.message})]})]})]},O.id)})}),P&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"community-risk-title","data-testid":"community-install-risk-dialog",className:"w-full max-w-lg rounded-2xl bg-white shadow-xl border border-amber-200 p-6",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_e,{className:"text-amber-600 shrink-0 mt-0.5",size:20}),e.jsxs("div",{children:[e.jsx("h3",{id:"community-risk-title",className:"text-base font-bold text-slate-900",children:c?`安装「${P.name}」前请确认风险`:`Confirm the risk before installing “${P.name}”`}),e.jsx("p",{className:"mt-2 text-sm text-slate-600 leading-relaxed",children:c?"社区插件是第三方代码,安装后会在本机执行。未受信任的插件默认进入独立子进程,不继承宿主的密钥类环境变量,但仍具备该系统用户被权限模型允许的能力(含出站网络)。只有清单 id 以 @openlearn/ 开头,或写在 OPENLEARN_TRUSTED_INLINE_PLUGINS 里的插件,才会在宿主进程内运行。":"A community plugin is third-party code that runs on this machine. Untrusted plugins start in a child process and do not inherit host secret environment variables, but they still have the OS user permissions the process model allows, including outbound network. Only plugins whose manifest id starts with @openlearn/, or ids listed in OPENLEARN_TRUSTED_INLINE_PLUGINS, run inside the host process."}),e.jsx("p",{className:"mt-2 text-sm text-slate-600 leading-relaxed",children:c?"插件自己写 auth: false 不会让接口变成公开。下面的选项默认关闭;勾选后才会批准清单里声明为公开的路由。":"auth: false in the manifest does not publish a route. The option below stays off unless you approve those routes."})]})]}),e.jsxs("label",{className:"mt-4 flex items-start gap-2 text-sm text-slate-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:M,onChange:O=>T(O.target.checked)}),e.jsx("span",{children:c?"同时批准清单中声明为公开的路由(auth: false)":"Also approve routes the manifest marks public (auth: false)"})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>E(null),className:"px-3 py-1.5 text-sm font-medium rounded-lg border border-slate-200 text-slate-600 hover:bg-slate-50",children:c?"取消":"Cancel"}),e.jsx("button",{type:"button",onClick:()=>{const O=P,I=M;E(null),H(O,I)},className:"px-3 py-1.5 text-sm font-semibold rounded-lg bg-amber-600 text-white hover:bg-amber-700",children:c?"确认风险并安装":"I understand the risk — install"})]})]})})]})}function Xt(R){if(!R||typeof R!="string")return null;const C=Ct(R);return C.manifest?{manifest:C.manifest}:null}const Qt=`exports.default = {
15
+ manifest: {
16
+ id: "ext-ai-quiz-gen",
17
+ name: "AI Course Quiz Generator (智能测验生成器)",
18
+ version: "1.0.0",
19
+ description: "自动根据教案主题或特定文本,一键生成结构化的单选/多选随堂测验,并直接分发至指定班级的学生学习终端。",
20
+ author: "Openlearn Next AI Team",
21
+ capabilitiesProposed: ["lesson:read", "whiteboard:write"]
22
+ },
23
+ activate: async (ctx) => {
24
+ ctx.actionRegistry.register({
25
+ id: 'ext-quiz-create',
26
+ commandType: 'quiz.create',
27
+ description: '为指定课时快速创建一份包含指定题目的随堂测验卷,可直接投射至白板或学生端',
28
+ capabilityRequired: 'lesson:read',
29
+ inputSchema: {
30
+ type: 'OBJECT',
31
+ properties: {
32
+ lessonId: { type: 'STRING', description: '关联的课时 ID' },
33
+ title: { type: 'STRING', description: '测验标题' },
34
+ questionsCount: { type: 'INTEGER', description: '自动生成的题目数量 (1-10)' }
35
+ },
36
+ required: ['lessonId', 'title']
37
+ }
38
+ });
39
+
40
+ ctx.commandBus.registerHandler('quiz.create', {
41
+ execute: async (command) => {
42
+ const payload = command.payload;
43
+ const count = payload.questionsCount || 3;
44
+
45
+ const mockQuestions = Array.from({ length: count }).map((_, i) => ({
46
+ id: 'q_' + (i + 1),
47
+ question: \`关于\${payload.title}的第 \${i + 1} 道随堂思考题?\`,
48
+ options: ["选项 A: 基础概念描述", "选项 B: 核心定理应用", "选项 C: 边界条件推导", "选项 D: 实验验证方法"],
49
+ answerIndex: i % 4
50
+ }));
51
+
52
+ const quizData = {
53
+ quizId: 'qz_' + Math.random().toString(36).slice(2, 9),
54
+ lessonId: payload.lessonId,
55
+ title: payload.title,
56
+ questions: mockQuestions,
57
+ createdTime: new Date().toISOString()
58
+ };
59
+
60
+ await ctx.eventBus.publish({
61
+ id: 'evt_' + Math.random().toString(36).slice(2),
62
+ type: 'quiz.created',
63
+ source: 'plugin.ext-ai-quiz-gen',
64
+ payload: quizData,
65
+ timestamp: Date.now()
66
+ });
67
+
68
+ return {
69
+ success: true,
70
+ quiz: quizData,
71
+ message: \`已为课时 \${payload.lessonId} 成功生成包含 \${count} 道题目的测验包!\`
72
+ };
73
+ }
74
+ });
75
+ }
76
+ };`;function es({lang:R,pluginCode:C,setPluginCode:a,plugins:N,installingPlugin:c,onInstall:o,onToggle:h,onDelete:n,setUpdateTargetPluginId:f,updateFileInputRef:p,setStoreTab:k,zipError:b,setZipError:w,zipPreview:i,setZipPreview:x,zipProcessing:s,hasLegacyPlugins:d,dismissMigration:l,MigrationPromptBanner:g}){return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden bg-gray-950",children:[e.jsxs("div",{className:"p-4 bg-gray-900 border-b border-gray-800 flex justify-between items-center shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te,{size:16,className:"text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-200",children:R==="zh"?"开发者工具: 插件旁路加载与实时 Manifest 校验":"Developer Tools: Plugin Sideloading & Real-time Manifest Validation"}),e.jsx("p",{className:"text-xs text-gray-505",children:R==="zh"?"在安装前系统将进行解析、安全授权与注册接口预览机制":"Parse metadata, proposed permissions, and registered triggers before installation"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs uppercase font-bold rounded-lg cursor-pointer transition-all ${b?"border border-red-500/30 bg-red-500/10 text-red-400 hover:bg-red-500/20":i?"border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20":s?"border border-indigo-500/30 bg-indigo-500/10 text-indigo-400":"border border-gray-600 text-gray-400 hover:text-white hover:border-indigo-400 hover:bg-indigo-500/10"}`,onClick:()=>{w(null),x(null),document.getElementById("zip-plugin-uploader")?.click()},children:s?e.jsxs(e.Fragment,{children:[e.jsx(ye,{size:11,className:"animate-spin"}),e.jsx("span",{children:R==="zh"?"分析中...":"Analyzing..."})]}):i?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:11}),e.jsx("span",{className:"max-w-[100px] truncate",children:i.name})]}):b?e.jsxs(e.Fragment,{children:[e.jsx(Te,{size:11}),e.jsx("span",{children:R==="zh"?"重试":"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:11}),e.jsx("span",{children:R==="zh"?"从 ZIP 安装":"Install from ZIP"})]})}),e.jsxs("button",{onClick:()=>a(Qt),className:"px-2.5 py-1 text-xs uppercase font-bold text-gray-400 hover:text-white bg-gray-800 hover:bg-gray-700 rounded-lg transition-all flex items-center gap-1 cursor-pointer",title:"Reset to default example",children:[e.jsx(_t,{size:11,className:"text-indigo-450"}),R==="zh"?"示例:智能测验生成器":"Quiz Sample"]})]})]}),d&&!l&&e.jsx("div",{className:"px-4 pt-4 bg-gray-950",children:e.jsx(g,{})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 bg-gray-950",children:[e.jsxs("div",{className:"w-7/12 flex flex-col border-r border-gray-800 h-full p-4 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1 text-xs uppercase font-bold text-gray-400 select-none shrink-0",children:[e.jsx("span",{children:R==="zh"?"⚙️ 插件主程序 JS 源代码":"⚙️ Plugin Source Code (JavaScript)"}),e.jsx("span",{className:"font-mono text-xs text-gray-500",children:"Node Sandbox Ready"})]}),e.jsx("textarea",{value:C,onChange:y=>a(y.target.value),className:"w-full flex-1 font-mono text-xs p-4 bg-gray-900 border border-gray-800 text-indigo-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:outline-none resize-none leading-relaxed overflow-y-auto"})]}),e.jsxs("div",{className:"w-5/12 flex flex-col bg-gray-900/40 p-4 h-full overflow-y-auto min-h-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-xs uppercase font-bold text-gray-400 select-none mb-1.5 flex justify-between items-center",children:[e.jsx("span",{children:R==="zh"?"🔍 MANIFEST 实时解析与权限审计":"🔍 Manifest Extraction & Audit"}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-indigo-950 text-indigo-400 border border-indigo-900 font-mono",children:"Live Static"})]}),(()=>{const y=Xt(C),v=y&&y.manifest&&y.manifest.id&&y.manifest.name;return e.jsxs("div",{className:"space-y-3.5",children:[e.jsx("div",{className:`p-3 rounded-lg border flex items-start gap-2 ${v?"bg-emerald-950/45 border-emerald-800/60 text-emerald-300":"bg-amber-955/40 border-amber-800/60 text-amber-300"}`,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:16,className:"text-emerald-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-bold font-sans",children:R==="zh"?"✓ Manifest 静态合法性验证通过":"✓ Manifest Validation Passed"}),e.jsx("p",{className:"text-xs text-emerald-400/80 mt-0.5 leading-tight",children:R==="zh"?"检测到完整的插件标识。可在安全白名单和命令总线中顺利完成挂载。":"Completed identifier extraction. Secure initialization is ready to deploy."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{size:16,className:"text-amber-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-bold font-sans",children:R==="zh"?"⚠️ 未匹配到有效 Manifest 描述符":"⚠️ Searching for valid Metadata"}),e.jsx("p",{className:"text-xs text-amber-400/80 mt-0.5 leading-tight",children:R==="zh"?"请在代码段中指定完整的 manifest 包含 id、name 属性,系统才能自动进行预览与权限挂载。":"Please provide manifest object inside exports.default with unique id/name properties to active automatic registration."})]})]})}),v&&y&&y.manifest&&e.jsxs("div",{className:"bg-gray-900 border border-gray-800 rounded-xl p-3.5 space-y-2.5",children:[e.jsxs("div",{className:"border-b border-gray-800 pb-2 flex justify-between items-center",children:[e.jsx("h6",{className:"text-xs font-bold text-gray-300 uppercase tracking-wider",children:R==="zh"?"基本描述元数据":"Metadata Details"}),e.jsxs("span",{className:"text-xs text-indigo-400 font-mono px-1 bg-indigo-950 rounded",children:["v",y.manifest.version||"1.0.0"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs font-mono",children:[e.jsx("div",{className:"text-gray-500",children:R==="zh"?"名称:":"Name:"}),e.jsx("div",{className:"col-span-2 text-gray-200 font-sans font-semibold",children:y.manifest.name}),e.jsx("div",{className:"text-gray-500",children:R==="zh"?"唯一标识:":"UUID/ID:"}),e.jsx("div",{className:"col-span-2 text-gray-305",children:y.manifest.id}),e.jsx("div",{className:"text-gray-500",children:R==="zh"?"开发者:":"Author:"}),e.jsx("div",{className:"col-span-2 text-indigo-305",children:y.manifest.author||"Community"})]})]})]})})()]}),e.jsxs("div",{className:"mt-5 bg-gray-900 border border-gray-800 rounded-xl p-3.5 space-y-3 shrink-0",children:[e.jsxs("h6",{className:"text-xs font-bold text-indigo-300 uppercase tracking-wider pb-1.5 border-b border-gray-800 flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(st,{size:11,className:"text-indigo-400 animate-pulse"}),e.jsx("span",{children:R==="zh"?`已加载插件管理 (${N.length})`:`Active Plugins (${N.length})`})]}),e.jsx("button",{onClick:()=>k("store"),className:"text-xs text-gray-500 hover:text-indigo-400 transition-colors uppercase tracking-wider font-semibold",children:R==="zh"?"管理大图 ➔":"View Grid ➔"})]}),e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1",children:N.length===0?e.jsx("div",{className:"text-xs text-gray-550 italic py-2 text-center",children:R==="zh"?"暂无安装的插件":"No plugins sideloaded."}):N.map(y=>e.jsxs("div",{className:"p-2.5 bg-gray-950 border border-gray-900 rounded-lg flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-bold text-gray-200 truncate",children:y.name}),e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${y.status==="active"?"bg-emerald-500 animate-pulse":"bg-slate-500"}`})]}),e.jsx("span",{className:"text-xs text-gray-500 font-mono block truncate select-all",children:y.id})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("button",{onClick:()=>h(y.id),className:`px-2.5 py-1 text-xs font-bold rounded transition-colors ${y.status==="active"?"bg-amber-950/60 border border-amber-900/50 text-amber-400 hover:bg-amber-900/80":"bg-emerald-950/60 border border-emerald-900/50 text-emerald-400 hover:bg-emerald-900/80"}`,children:y.status==="active"?R==="zh"?"禁用":"Disable":R==="zh"?"启用":"Enable"}),!y.id.startsWith("@openlearn/")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{f(y.id),p.current?.click()},className:"px-2 py-1 text-xs font-bold bg-sky-950/60 border border-sky-900/50 text-sky-300 hover:bg-sky-900/80 rounded transition-colors",children:R==="zh"?"更新":"Update"}),e.jsx("button",{onClick:()=>n(y.id),className:"px-2 py-1 text-xs font-bold bg-red-950/60 border border-red-900/50 text-red-400 hover:bg-red-900/80 rounded transition-colors",children:R==="zh"?"删除":"Delete"})]})]})]},y.id))})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-800 bg-gray-950 flex justify-between items-center shrink-0 select-none",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono",children:"Secure Sideload Mode • Sandbox Integrity Check"}),e.jsx("div",{className:"flex justify-end gap-3",children:e.jsx("button",{onClick:o,disabled:c||!C.trim(),className:"px-4 py-2 text-xs bg-indigo-600 font-bold hover:bg-indigo-700 text-white rounded-lg transition-all flex items-center gap-2 disabled:opacity-50 hover:shadow-lg active:scale-97 cursor-pointer",children:c?e.jsxs(e.Fragment,{children:[e.jsx(ye,{size:13,className:"animate-spin"}),e.jsx("span",{children:R==="zh"?"集成挂载中...":"Registering..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:R==="zh"?"部署并安装到课堂内核":"Deploy & Install Plugin"})]})})})]})]})}function ts({lang:R}){const[C,a]=ve.useState([]),[N,c]=ve.useState(!1),[o,h]=ve.useState(!0),[n,f]=ve.useState(""),[p,k]=ve.useState(""),[b,w]=ve.useState(""),i=async()=>{c(!0);try{let l="/api/admin/logs?limit=300";p&&(l+=`&level=${p}`),b&&(l+=`&component=${b}`);const y=await(await fetch(l)).json();y.success&&a(y.logs||[])}catch(l){console.error("Error fetching logs:",l)}finally{c(!1)}};ve.useEffect(()=>{i()},[p,b]),ve.useEffect(()=>{if(!o)return;const l=setInterval(()=>{let g="/api/admin/logs?limit=300";p&&(g+=`&level=${p}`),b&&(g+=`&component=${b}`),fetch(g).then(y=>y.json()).then(y=>{y.success&&a(y.logs||[])}).catch(y=>console.error(y))},3e3);return()=>clearInterval(l)},[o,p,b]);const x=ve.useMemo(()=>{const l=new Set;return C.forEach(g=>{g.component&&l.add(g.component)}),Array.from(l)},[C]),s=ve.useMemo(()=>{if(!n)return C;const l=n.toLowerCase();return C.filter(g=>{const y=(g.msg||"").toLowerCase(),v=(g.component||"").toLowerCase();return y.includes(l)||v.includes(l)})},[C,n]),d=l=>{switch(l){case"error":return"text-rose-500 font-semibold";case"warn":return"text-amber-500 font-semibold";case"debug":return"text-blue-400";default:return"text-emerald-400"}};return e.jsxs("div",{className:"flex-1 flex flex-col p-6 bg-slate-900 text-slate-100 font-mono text-sm overflow-hidden h-full min-h-[500px]",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between border-b border-slate-800 pb-4 shrink-0 font-sans",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsx("input",{type:"text",placeholder:R==="zh"?"搜索日志内容...":"Search logs...",value:n,onChange:l=>f(l.target.value),className:"bg-slate-800 border border-slate-700 text-slate-200 px-3 py-1.5 rounded-lg focus:outline-none focus:border-indigo-500 placeholder-slate-500 text-xs w-48"}),e.jsxs("select",{value:p,onChange:l=>k(l.target.value),className:"bg-slate-800 border border-slate-700 text-slate-200 px-3 py-1.5 rounded-lg focus:outline-none focus:border-indigo-500 text-xs",children:[e.jsx("option",{value:"",children:R==="zh"?"所有级别":"All Levels"}),e.jsx("option",{value:"info",children:"INFO"}),e.jsx("option",{value:"warn",children:"WARN"}),e.jsx("option",{value:"error",children:"ERROR"}),e.jsx("option",{value:"debug",children:"DEBUG"})]}),e.jsxs("select",{value:b,onChange:l=>w(l.target.value),className:"bg-slate-800 border border-slate-700 text-slate-200 px-3 py-1.5 rounded-lg focus:outline-none focus:border-indigo-500 text-xs max-w-48",children:[e.jsx("option",{value:"",children:R==="zh"?"所有组件":"All Components"}),x.map(l=>e.jsx("option",{value:l,children:l},l))]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-400 select-none cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:l=>h(l.target.checked),className:"rounded bg-slate-800 border-slate-700 text-indigo-500 focus:ring-0 focus:ring-offset-0"}),R==="zh"?"自动刷新 (3s)":"Auto-refresh (3s)"]}),e.jsxs("button",{onClick:i,disabled:N,className:"bg-slate-800 hover:bg-slate-700 active:bg-slate-750 text-slate-200 border border-slate-700 px-3 py-1.5 rounded-lg text-xs flex items-center gap-1.5 transition-colors disabled:opacity-50 cursor-pointer",children:[N?e.jsx(ye,{size:12,className:"animate-spin"}):null,R==="zh"?"刷新":"Refresh"]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-4 p-4 bg-slate-950 border border-slate-800 rounded-xl flex flex-col gap-1.5 min-h-0 select-text",children:s.length===0?e.jsx("div",{className:"text-center py-12 text-slate-500 text-xs",children:R==="zh"?"暂无匹配的运行日志数据":"No logs found."}):s.map((l,g)=>e.jsxs("div",{className:"flex gap-3 text-xs leading-relaxed hover:bg-slate-900/60 p-1 rounded transition-colors",children:[e.jsx("span",{className:"text-slate-500 shrink-0 select-none",children:new Date(l.timestamp||Date.now()).toLocaleTimeString()}),e.jsx("span",{className:`uppercase font-bold w-12 shrink-0 ${d(l.level)}`,children:l.level||"info"}),e.jsxs("span",{className:"text-indigo-400 shrink-0 font-semibold w-24 truncate",title:l.component,children:["[",l.component||"system","]"]}),e.jsxs("span",{className:"text-slate-200 flex-1 break-all whitespace-pre-wrap",children:[l.msg,l.meta&&Object.keys(l.meta).length>0&&e.jsx("span",{className:"text-slate-500 ml-2 font-mono text-xs",children:JSON.stringify(l.meta)})]})]},g))})]})}function ss(R){if(!R)return"-";try{return new Date(R).toLocaleString()}catch{return"-"}}function rs({lang:R,items:C,loading:a,onRefresh:N,onExport:c,onPurge:o,onDownloadArchive:h}){const n=R==="zh",[f,p]=K.useState(null),[k,b]=K.useState(null);K.useEffect(()=>{N()},[]);const w=async(i,x)=>{b(i);try{await x()}finally{b(null)}};return e.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50/30 p-6",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-bold text-gray-900",children:[e.jsx(Ze,{size:16,className:"text-indigo-600"}),n?"插件数据(卸载后保留)":"Plugin Data (kept after uninstall)"]}),e.jsx("p",{className:"mt-1 max-w-2xl text-xs text-gray-500",children:n?"卸载插件默认保留其数据表与配置,重新安装同一插件会自动接回。清除前服务端会先导出 SQL 归档,此操作不可恢复。":"Uninstalling keeps plugin tables and config by default; reinstalling the same plugin re-attaches them. Purging exports a SQL archive first and cannot be undone."})]}),e.jsxs("button",{type:"button",onClick:()=>void N(),className:"flex shrink-0 items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-xs font-semibold text-gray-600 shadow-sm transition-colors hover:border-indigo-300 hover:text-indigo-600",children:[e.jsx(Ne,{size:13,className:a?"animate-spin":""}),n?"刷新":"Refresh"]})]}),C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-gray-200 bg-white/60 py-16 text-center",children:[e.jsx(kt,{size:28,className:"mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm font-medium text-gray-500",children:n?"暂无保留的插件数据":"No retained plugin data"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:n?"卸载插件时若选择「保留数据」,会在这里出现。":'Data appears here when a plugin is uninstalled with "keep data".'})]}):e.jsx("div",{className:"space-y-3",children:C.map(i=>{const x=`${i.manifestId}:${i.pluginId}`,s=k===i.pluginId,d=f===i.pluginId;return e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-bold text-gray-900",children:i.pluginName||i.manifestId}),i.pluginVersion&&e.jsxs("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[10px] font-semibold text-gray-500",children:["v",i.pluginVersion]})]}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-gray-400",children:i.manifestId}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-gray-500",children:[e.jsxs("span",{children:[n?"数据表":"Tables",": ",e.jsx("strong",{className:"text-gray-700",children:i.tableCount})]}),e.jsxs("span",{children:[n?"数据行":"Rows",": ",e.jsx("strong",{className:"text-gray-700",children:i.rowCount})]}),e.jsxs("span",{children:[n?"配置键":"Storage keys",": ",e.jsx("strong",{className:"text-gray-700",children:i.storageKeys})]}),e.jsxs("span",{children:[n?"迁移版本":"Migration",":"," ",e.jsx("strong",{className:"text-gray-700",children:i.migrationVersion??"-"})]}),e.jsxs("span",{children:[n?"卸载时间":"Uninstalled",":"," ",e.jsx("strong",{className:"text-gray-700",children:ss(i.uninstalledAt)})]})]}),i.lastExportPath&&e.jsxs("div",{className:"mt-1 truncate font-mono text-[11px] text-emerald-600",children:[n?"最近归档":"Latest archive",": ",i.lastExportPath]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>void w(i.pluginId,()=>c(i)),className:"flex items-center gap-1 rounded-lg bg-sky-50 px-3 py-1.5 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-100 disabled:opacity-50",children:[s?e.jsx(ye,{size:12,className:"animate-spin"}):e.jsx(Oe,{size:12}),n?"导出归档":"Export"]}),h&&i.lastExportPath&&e.jsxs("button",{type:"button",onClick:()=>h(i),className:"flex items-center gap-1 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100",children:[e.jsx(Oe,{size:12}),n?"下载":"Download"]}),e.jsxs("button",{type:"button",disabled:s,onClick:()=>p(d?null:i.pluginId),className:"flex items-center gap-1 rounded-lg bg-red-50 px-3 py-1.5 text-xs font-medium text-red-600 transition-colors hover:bg-red-100 disabled:opacity-50",children:[e.jsx(Pe,{size:12}),n?"清除数据":"Purge"]})]})]}),d&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2",children:[e.jsxs("div",{className:"flex items-start gap-2 text-xs text-red-700",children:[e.jsx(_e,{size:14,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:n?`将清除 ${i.tableCount} 张表、${i.rowCount} 行数据与 ${i.storageKeys} 个配置键。服务端会先导出 SQL 归档,但清除后无法直接恢复。`:`This clears ${i.tableCount} tables, ${i.rowCount} rows and ${i.storageKeys} storage keys. A SQL archive is exported first, but the data cannot be restored in place.`})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>p(null),className:"rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50",children:n?"取消":"Cancel"}),e.jsxs("button",{type:"button",disabled:s,onClick:()=>void w(i.pluginId,async()=>{await o(i),p(null)}),className:"flex items-center gap-1 rounded-lg bg-red-600 px-3 py-1.5 text-xs font-semibold text-white transition-colors hover:bg-red-700 disabled:bg-red-300",children:[s?e.jsx(ye,{size:12,className:"animate-spin"}):e.jsx(Pe,{size:12}),n?"确认清除":"Confirm purge"]})]})]})]},x)})})]})}function ns({pluginName:R,manifestId:C,lang:a,onCancel:N,onConfirm:c}){const[o,h]=K.useState(!1),[n,f]=K.useState(!1),p=a==="zh",k=()=>{if(o){if(!n)return;c("purge");return}c("keep")};return e.jsx("div",{className:"fixed inset-0 z-[120] flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl bg-white shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{size:18,className:"text-red-500"}),e.jsx("h3",{className:"text-base font-bold text-gray-900",children:p?`卸载「${R}」`:`Uninstall "${R}"`})]}),e.jsx("button",{type:"button",onClick:N,className:"rounded-lg p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700","aria-label":p?"关闭":"Close",children:e.jsx(ze,{size:18})})]}),e.jsxs("div",{className:"space-y-3 px-6 py-5",children:[e.jsx("p",{className:"text-sm text-gray-600",children:p?"卸载后插件功能立即停用。请选择如何处理该插件保存的数据(学生作业、考勤、成绩等)。":"The plugin stops working immediately. Choose what happens to the data it stored (submissions, attendance, scores…)."}),e.jsxs("label",{className:`flex cursor-pointer items-start gap-3 rounded-xl border p-4 transition-colors ${o?"border-gray-200 bg-gray-50/40":"border-indigo-300 bg-indigo-50/40"}`,children:[e.jsx("input",{type:"radio",name:"uninstall-data-policy",checked:!o,onChange:()=>h(!1),className:"mt-1"}),e.jsxs("span",{className:"space-y-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-gray-900",children:[e.jsx(Ze,{size:14,className:"text-indigo-600"}),p?"保留插件数据(推荐)":"Keep plugin data (recommended)"]}),e.jsx("span",{className:"block text-xs text-gray-500",children:p?"插件表、迁移版本与配置原样留库。重新安装同一插件时会自动接回旧数据,也可以在「插件数据」页随时导出或清除。":"Tables, migration version and config stay in the database. Reinstalling the same plugin re-attaches them; you can export or clear them later under Plugin Data."})]})]}),e.jsxs("label",{className:`flex cursor-pointer items-start gap-3 rounded-xl border p-4 transition-colors ${o?"border-red-300 bg-red-50/50":"border-gray-200 bg-gray-50/40"}`,children:[e.jsx("input",{type:"radio",name:"uninstall-data-policy",checked:o,onChange:()=>h(!0),className:"mt-1"}),e.jsxs("span",{className:"space-y-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-semibold text-red-700",children:[e.jsx(_e,{size:14}),p?"卸载并清除插件数据(不可恢复)":"Uninstall and purge plugin data (irreversible)"]}),e.jsx("span",{className:"block text-xs text-gray-500",children:p?"服务端会先把插件表导出为 SQL 归档(保存在数据目录 plugin-data-exports/),确认归档成功后再删除数据,并写入审计日志。":"The server exports the plugin tables to a SQL archive (data dir plugin-data-exports/) before deleting anything, then writes an audit record."})]})]}),o&&e.jsxs("label",{className:"flex items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:b=>f(b.target.checked),className:"mt-0.5"}),e.jsx("span",{children:p?`我已知晓:清除「${C}」的数据不可恢复(请以归档文件为准)。`:`I understand that purging data for "${C}" is irreversible (rely on the archive).`})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-gray-100 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:N,className:"rounded-lg border border-gray-200 px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50",children:p?"取消":"Cancel"}),e.jsx("button",{type:"button",onClick:k,disabled:o&&!n,className:`rounded-lg px-4 py-2 text-sm font-semibold text-white transition-colors ${o?n?"bg-red-600 hover:bg-red-700":"cursor-not-allowed bg-red-300":"bg-indigo-600 hover:bg-indigo-700"}`,children:o?p?"卸载并清除数据":"Uninstall & purge":p?"卸载并保留数据":"Uninstall & keep data"})]})]})})}function as({plugins:R,lang:C,storeTab:a,setStoreTab:N,pluginCode:c,setPluginCode:o,installingPlugin:h,onInstall:n,onZipUpload:f,onToggle:p,onDelete:k,orphanData:b=[],orphanDataLoading:w=!1,fetchOrphanData:i,handleExportOrphanData:x,handlePurgeOrphanData:s,handleDownloadOrphanArchive:d}){const[l,g]=K.useState(!1),[y,v]=K.useState(!1),[j,P]=K.useState(null),[E,M]=K.useState(null),T=K.useRef(null),[G,te]=K.useState(null),_=m=>{const u=R.find(F=>F.id===m);let S=m;try{S=JSON.parse(u?.manifest??"{}")?.id??m}catch{S=m}te({id:m,name:u?.name??S,manifestId:S})},[B,r]=K.useState(null),[L,ee]=K.useState(null),[W,ne]=K.useState(!1),[H,O]=K.useState(null),[I,z]=K.useState(new Map),[Q,Y]=K.useState(null),[q,ue]=K.useState(null),[he,ae]=K.useState(null),[de,ce]=K.useState(null);K.useEffect(()=>{let m=!0;return fetch("/api/plugins/market").then(u=>u.json()).then(u=>{if(u?.success&&Array.isArray(u.market)&&m){const S=new Map;for(const F of u.market)S.set(F.manifestId,F);z(S)}}).catch(()=>{}),()=>{m=!1}},[]);const ie=()=>{ce(C==="zh"?"🎉 社区插件已安装,正在刷新插件列表…":"🎉 Community plugin installed, reloading the plugin list…"),setTimeout(()=>window.location.reload(),1200)},ge=async(m,u)=>{ue(m);try{const S=await fetch(`/api/plugins/${encodeURIComponent(m)}/check-update`,{method:"POST"}).then(F=>F.json());S?.success&&z(F=>{const U=new Map(F);return U.set(u,{...S,manifestId:u}),U})}catch{}finally{ue(null)}},xe=async(m,u)=>{Y(m),ce(C==="zh"?"正在连接市场执行一键无缝热更新...":"Connecting to market for one-click hot update...");try{const S=u?.downloadUrl?JSON.stringify({downloadUrl:u.downloadUrl,acknowledgeRisk:!0,...u.integrity?{integrity:u.integrity}:{},...u.signature?{signature:u.signature}:{}}):JSON.stringify({acknowledgeRisk:!0}),F=await fetch(`/api/plugins/${encodeURIComponent(m)}/one-click-update`,{method:"POST",headers:S?{"Content-Type":"application/json"}:void 0,body:S}).then(U=>U.json());if(F?.success)ce(C==="zh"?`🎉 插件已成功热更新至 v${F.newVersion||"1.2.0"}!`:`🎉 Hot updated to v${F.newVersion||"1.2.0"}!`),setTimeout(()=>window.location.reload(),1200);else if(F?.fallbackToClient&&u?.downloadUrl){ce(C==="zh"?"服务端下载超时,切换至浏览器直传...":"Server download timed out, switching to browser transfer...");try{const A=await(await fetch(u.downloadUrl)).blob(),V=new FormData;V.append("file",A,"update.zip");const X=await fetch(`/api/plugins/${encodeURIComponent(m)}/update-zip-raw`,{method:"POST",headers:{"x-install-mode":"update","x-acknowledge-risk":"true","x-community-install":"true",...u.integrity?{"x-integrity":u.integrity}:{},...u.signature?{"x-signature":u.signature}:{}},body:V}).then(J=>J.json());X?.success?(ce(C==="zh"?"🎉 插件已成功热更新!":"🎉 Hot updated!"),setTimeout(()=>window.location.reload(),1200)):(ce(`❌ 更新失败: ${X?.error||"客户端上传失败"}`),setTimeout(()=>ce(null),4e3))}catch(U){ce(`❌ 客户端下载失败: ${U.message}`),setTimeout(()=>ce(null),4e3)}}else ce(`❌ 更新失败: ${F?.error||"受热更新包限制"}`),setTimeout(()=>ce(null),4e3)}catch(S){ce(`❌ 一键热更新失败: ${S.message}`),setTimeout(()=>ce(null),4e3)}finally{Y(null)}},t=m=>{const u=m.target.files?.[0];u&&P(u)},$=R.some(m=>m.execution_mode==="legacy");function D(){return e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_e,{size:20,className:"text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-amber-800",children:C==="zh"?"发现可迁移的旧格式插件":"Legacy Plugin Detected"}),e.jsx("p",{className:"text-xs text-amber-700 mt-1",children:C==="zh"?"该插件使用旧格式运行。上传新格式 ZIP 包以完成迁移,迁移后旧版本可安全卸载。":"This plugin runs in legacy mode. Upload a new-format ZIP package to migrate. The old version can be safely uninstalled afterwards."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>document.getElementById("zip-plugin-uploader")?.click(),className:"bg-amber-600 text-white hover:bg-amber-700 rounded-lg text-sm font-medium px-4 py-2 transition-colors cursor-pointer",children:C==="zh"?"迁移到新格式":"Migrate to New Format"}),e.jsx("button",{onClick:()=>v(!0),className:"text-amber-500 hover:text-amber-700 p-1 cursor-pointer",children:e.jsx(ze,{size:16})})]})]})}return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 flex flex-col h-full overflow-y-auto",children:e.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow flex flex-col overflow-hidden h-full",children:[e.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-gray-100 bg-gray-50/50 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("h2",{className:"font-bold text-gray-900 flex items-center gap-2 text-lg",children:[e.jsx(st,{size:20,className:"text-indigo-600"}),C==="zh"?"Openlearn Next 插件中心":"Openlearn Next App Store"]}),e.jsxs("div",{className:"flex bg-gray-200/50 p-1 rounded-lg",children:[e.jsx("button",{onClick:()=>N("store"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors cursor-pointer ${a==="store"?"bg-white shadow text-indigo-600 font-bold":"text-gray-600 hover:text-gray-900"}`,children:C==="zh"?"发现":"Discover"}),e.jsxs("button",{onClick:()=>N("community"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-1 cursor-pointer ${a==="community"?"bg-white shadow text-indigo-600 font-bold":"text-gray-600 hover:text-gray-900"}`,children:[e.jsx(Be,{size:14})," ",C==="zh"?"社区":"Community"]}),e.jsxs("button",{onClick:()=>N("dev"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-1 cursor-pointer ${a==="dev"?"bg-white shadow text-indigo-600 font-bold":"text-gray-600 hover:text-gray-900"}`,children:[e.jsx(Nt,{size:14})," ",C==="zh"?"开发者":"Developer"]}),e.jsxs("button",{onClick:()=>N("logs"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-1 cursor-pointer ${a==="logs"?"bg-white shadow text-indigo-600 font-bold":"text-gray-600 hover:text-gray-900"}`,children:[e.jsx(zt,{size:14})," ",C==="zh"?"系统日志":"Logs"]}),e.jsxs("button",{onClick:()=>N("data"),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-1 cursor-pointer ${a==="data"?"bg-white shadow text-indigo-600 font-bold":"text-gray-600 hover:text-gray-900"}`,children:[e.jsx(Ze,{size:14})," ",C==="zh"?"插件数据":"Data"]})]})]}),a==="store"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-xs font-semibold text-gray-500 hover:text-gray-900 select-none transition-colors border border-gray-200 rounded-lg px-3 py-1.5 bg-gray-50/50 shadow-sm",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:m=>g(m.target.checked),className:"w-3.5 h-3.5 rounded text-indigo-600 border-gray-300 focus:ring-indigo-500 cursor-pointer"}),e.jsx("span",{children:C==="zh"?"显示系统核心插件":"Show System Core Plugins"})]}),e.jsx("button",{type:"button",className:`flex items-center gap-1.5 cursor-pointer text-xs font-semibold select-none transition-colors border rounded-lg px-3 py-1.5 shadow-sm ${j?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-teal-200 bg-teal-50/50 text-teal-700 hover:border-teal-400 hover:bg-teal-50"}`,onClick:()=>{document.getElementById("zip-plugin-uploader")?.click()},children:j?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:14,className:"text-emerald-500"}),e.jsx("span",{className:"max-w-[120px] truncate",children:j.name})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{size:14}),e.jsx("span",{children:C==="zh"?"从 ZIP 安装":"Install from ZIP"})]})})]})]}),e.jsx("input",{type:"file",accept:".zip",id:"zip-plugin-uploader",className:"hidden",onChange:m=>{M(null),t(m)}}),e.jsx("input",{ref:T,type:"file",accept:".zip",className:"hidden",onChange:m=>{const u=m.target.files?.[0];u&&P(u),m.target.value=""}}),a==="store"?e.jsx(Zt,{plugins:R,lang:C,showSystemPlugins:l,marketMap:I,checkingUpdateId:q,oneClickUpdatingId:Q,handleCheckUpdate:ge,handleOneClickUpdate:xe,setChangelogModalPlugin:ae,setSettingsPlugin:O,setUpdateTargetPluginId:M,updateFileInputRef:T,onToggle:p,onDelete:_}):a==="community"?e.jsx(Yt,{installedPlugins:R,lang:C,onInstalled:ie}):a==="logs"?e.jsx(ts,{lang:C}):a==="data"?e.jsx(rs,{lang:C,items:b,loading:w,onRefresh:()=>void i?.(),onExport:m=>void x?.(m),onPurge:m=>void s?.(m),onDownloadArchive:d}):e.jsx(es,{lang:C,pluginCode:c,setPluginCode:o,plugins:R,installingPlugin:h,onInstall:n,onToggle:p,onDelete:_,setUpdateTargetPluginId:M,updateFileInputRef:T,setStoreTab:N,zipError:B,setZipError:r,zipPreview:L,setZipPreview:ee,zipProcessing:W,hasLegacyPlugins:$,dismissMigration:y,MigrationPromptBanner:D})]})}),H&&e.jsx(Et,{pluginId:H.id,pluginName:H.name,manifestStr:H.manifest,lang:C,onClose:()=>O(null)}),e.jsx(Lt,{isOpen:!!j,onClose:()=>{P(null),M(null)},lang:C,file:j,lockedTargetPluginId:E,installedPlugins:R,onConfirmInstall:f}),he&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-2xl max-w-lg w-full p-6 shadow-2xl border border-gray-100 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"text-indigo-600",size:20}),e.jsxs("h3",{className:"text-base font-bold text-gray-900",children:[he.name," ",C==="zh"?"版本更新说明":"Release Notes"]})]}),e.jsx("button",{onClick:()=>ae(null),className:"text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100 transition-colors",children:e.jsx(ze,{size:18})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-indigo-50/70 border border-indigo-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono font-bold bg-white text-gray-600 px-2 py-0.5 rounded border border-gray-200",children:["v",he.version||"1.1.0"]}),e.jsx("span",{className:"text-indigo-400 font-bold",children:"➔"}),e.jsxs("span",{className:"text-xs font-mono font-bold bg-indigo-600 text-white px-2 py-0.5 rounded shadow-sm",children:["v",he.marketItem?.latestVersion||"1.2.0"]})]}),je(he.marketItem?.repository)&&e.jsxs("a",{href:je(he.marketItem?.repository),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs font-mono text-indigo-600 hover:text-indigo-800 font-medium",children:[e.jsx(Me,{size:12}),e.jsx("span",{children:"Git Repo"}),e.jsx(et,{size:10})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h4",{className:"text-xs font-bold text-gray-700 uppercase tracking-wider",children:C==="zh"?"新特性与优化变更清单 (Changelog)":"What's New"}),e.jsx("div",{className:"bg-slate-50 border border-slate-200/80 rounded-xl p-3.5 text-xs text-slate-700 leading-relaxed font-mono whitespace-pre-wrap max-h-48 overflow-y-auto",children:he.marketItem?.changelog||(C==="zh"?`1. 阶段式任务逻辑与自动化测试增强
77
+ 2. 前端轻量化与高可用平滑升级`:"1. General enhancements and bug fixes")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2 border-t border-gray-100",children:[e.jsx("button",{onClick:()=>ae(null),className:"px-4 py-2 text-xs font-medium rounded-lg text-gray-600 hover:bg-gray-100 transition-colors cursor-pointer",children:C==="zh"?"稍后再说":"Later"}),he.marketItem?.downloadUrl?e.jsx("button",{onClick:()=>{const m=he.id,u=he.marketItem;ae(null),xe(m,u)},className:"px-4 py-2 text-xs font-bold rounded-lg bg-gradient-to-r from-blue-600 to-indigo-600 text-white hover:from-blue-700 hover:to-indigo-700 shadow-md transition-all flex items-center gap-1.5 cursor-pointer",children:e.jsxs("span",{children:["🚀 ",C==="zh"?"立即一键热更新":"Update Now"]})}):e.jsx("span",{className:"px-3 py-2 text-xs text-amber-700 bg-amber-50 border border-amber-200 rounded-lg",children:C==="zh"?"本地源更新:请重新构建 ZIP 后在「开发」页上传更新":"Local source update: rebuild the ZIP and upload it in the Dev tab"})]})]})}),de&&e.jsxs("div",{className:"fixed bottom-6 right-6 z-50 bg-gray-900/90 backdrop-blur text-white text-xs font-medium px-4 py-3 rounded-xl shadow-2xl border border-gray-700/80 flex items-center gap-2",children:[e.jsx(Ne,{size:14,className:"text-indigo-400 animate-spin"}),e.jsx("span",{children:de})]}),G&&e.jsx(ns,{pluginName:G.name,manifestId:G.manifestId,lang:C,onCancel:()=>te(null),onConfirm:m=>{const u=G;te(null),k(u.id,m)}})]})}function ps(R={}){const C=St(),a=R.plugins??C?.plugins??[],N=R.lang??C?.lang??"zh",c=R.storeTab??C?.storeTab??"store",o=R.setStoreTab??C?.setStoreTab??(()=>{}),h=R.pluginCode??C?.pluginCode??"",n=R.setPluginCode??C?.setPluginCode??(()=>{}),f=R.installingPlugin??C?.installingPlugin??!1,p=R.onInstall??C?.handleInstallPlugin??(()=>{}),k=R.onZipUpload??C?.handleZipPluginUpload??(async()=>{}),b=R.onToggle??C?.handleTogglePlugin??(async()=>{}),w=R.onDelete??C?.handleDeletePlugin??(async()=>{});return e.jsx(as,{plugins:a,lang:N,storeTab:c,setStoreTab:i=>o(i),pluginCode:h,setPluginCode:n,installingPlugin:f,onInstall:()=>{p(h)},onZipUpload:k,onToggle:b,onDelete:w,orphanData:C?.orphanData,orphanDataLoading:C?.orphanDataLoading,fetchOrphanData:C?.fetchOrphanData,handleExportOrphanData:C?.handleExportOrphanData,handlePurgeOrphanData:C?.handlePurgeOrphanData,handleDownloadOrphanArchive:C?.handleDownloadOrphanArchive})}export{ps as PluginView};