anyfile-cli 0.2.0 → 0.2.1

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 (111) hide show
  1. package/README.md +1 -2
  2. package/chunks/{chunk-5OI4NQH7.mjs → chunk-HI7TURZM.mjs} +27 -3
  3. package/chunks/{chunk-UUN2DVDC.mjs → chunk-IGEGIF35.mjs} +178 -37
  4. package/cli-main.mjs +24 -5
  5. package/index.mjs +2 -2
  6. package/package.json +2 -2
  7. package/renderer-host/assets/{amf-CLBaywBr.js → amf-BkE--DNX.js} +1 -1
  8. package/renderer-host/assets/{animation-DnPo99To.js → animation-Dt0WW2cB.js} +1 -1
  9. package/renderer-host/assets/{archive-client-CyhEmSF7.js → archive-client-CL5yOgwH.js} +1 -1
  10. package/renderer-host/assets/{book-worker-DrtzCzPo.js → book-worker-DUt14LJO.js} +1 -1
  11. package/renderer-host/assets/{client-Dp-p4unY.js → client-CU2ERPtk.js} +1 -1
  12. package/renderer-host/assets/container-inspection-ekEPWWcy.js +1 -0
  13. package/renderer-host/assets/decode-hBroL8C1.js +1 -0
  14. package/renderer-host/assets/{decode-tiff-BuYdKp6p.js → decode-tiff-CP1xdrF_.js} +3 -3
  15. package/renderer-host/assets/{dual-track-playback-lNQyU1GR.js → dual-track-playback-CxjGms-W.js} +1 -1
  16. package/renderer-host/assets/{ffmpeg-playback-QcT_NwlK.js → ffmpeg-playback-DzCJz9Ny.js} +1 -1
  17. package/renderer-host/assets/{gltf-Cqq-xStc.js → gltf-PozNLKNg.js} +1 -1
  18. package/renderer-host/assets/{image-load-B1fNI3iO.js → image-load-SK3ULGWm.js} +1 -1
  19. package/renderer-host/assets/index-DtiyOy_J.js +2 -0
  20. package/renderer-host/assets/{lerc-CRhfhhOS.js → lerc-Cuor-Zm2.js} +1 -1
  21. package/renderer-host/assets/{mediabunny-viewer-BnJM6Yo0.js → mediabunny-viewer-BniHVEWJ.js} +1 -1
  22. package/renderer-host/assets/{model-D2YSoRt5.js → model-Drd3vqcF.js} +1 -1
  23. package/renderer-host/assets/{obj-DbUZkDna.js → obj-B3p81LL2.js} +1 -1
  24. package/renderer-host/assets/{off-CzR_R_Tf.js → off-QQbiKPTX.js} +1 -1
  25. package/renderer-host/assets/{ogg-viewer-CT31JEhG.js → ogg-viewer-Dc8K-tas.js} +1 -1
  26. package/renderer-host/assets/{paged-CX-N_Pzy.js → paged-C8AQD7sX.js} +1 -1
  27. package/renderer-host/assets/{ply-C-xrhUaO.js → ply-C3_RRA7n.js} +1 -1
  28. package/renderer-host/assets/{probe-asf-CvcaYQaR.js → probe-asf-C_UpCBly.js} +1 -1
  29. package/renderer-host/assets/{range-reader-9PeAh1Hv.js → range-reader-BMfLhWcp.js} +1 -1
  30. package/renderer-host/assets/{resources-WcZvn3-C.js → resources-6AmS6O5e.js} +1 -1
  31. package/renderer-host/assets/{safe-content-B61Ktgzp.js → safe-content-CWHf8jex.js} +1 -1
  32. package/renderer-host/assets/{scene-adapter-CmaaVwsM.js → scene-adapter-CaCLr1am.js} +1 -1
  33. package/renderer-host/assets/{skp-adapter-ByI1iX8S.js → skp-adapter-jl6q24fW.js} +1 -1
  34. package/renderer-host/assets/{src-DZE9IoBl.js → src-1Won7FxU.js} +1 -1
  35. package/renderer-host/assets/{src-CXRrmfb0.js → src-3RoHqOkA.js} +1 -1
  36. package/renderer-host/assets/{src-vPHMg1Fp.js → src-4zBOL6Jt.js} +1 -1
  37. package/renderer-host/assets/{src-CGx0nUS5.js → src-6v8-hoR3.js} +1 -1
  38. package/renderer-host/assets/{src-D3OyeoQs.js → src-8Jx9gbII.js} +1 -1
  39. package/renderer-host/assets/{src-Bu1cTJNz.js → src-B1WA0dRu.js} +1 -1
  40. package/renderer-host/assets/{src-j_mEQ9Os.js → src-B5ijbemo.js} +2 -2
  41. package/renderer-host/assets/{src-efHN2oAJ.js → src-B8DH2GJe.js} +3 -3
  42. package/renderer-host/assets/{src-B_o7QilB.js → src-B9t_iEO3.js} +1 -1
  43. package/renderer-host/assets/{src-CIDWSV97.js → src-BCC58C0X.js} +1 -1
  44. package/renderer-host/assets/{src-lYIAi6Hw.js → src-BCwENs26.js} +1 -1
  45. package/renderer-host/assets/{src-ClIHDiJ4.js → src-BEirBh4c.js} +1 -1
  46. package/renderer-host/assets/{src-CeGmxOTi.js → src-BHR6n7Fj.js} +1 -1
  47. package/renderer-host/assets/{src-BMrLVJyB.js → src-BIlLq0QT.js} +3 -3
  48. package/renderer-host/assets/{src-C5k8Ydia.js → src-BKlK1jcN.js} +1 -1
  49. package/renderer-host/assets/{src-C_1M1IDo.js → src-BN0FUJhs.js} +1 -1
  50. package/renderer-host/assets/{src-BEn15PBT.js → src-BWElAdlq.js} +1 -1
  51. package/renderer-host/assets/{src-QXdjrTaw.js → src-BXg11IjY.js} +1 -1
  52. package/renderer-host/assets/{src-BwZAUudm.js → src-BbBdnTjJ.js} +2 -2
  53. package/renderer-host/assets/{src-Bw-O8ujJ.js → src-BbFZbZsL.js} +2 -2
  54. package/renderer-host/assets/{src-DPm7_lsi.js → src-BdPbFRd-.js} +1 -1
  55. package/renderer-host/assets/{src-C2LKqLBA.js → src-BpbGaBrT.js} +1 -1
  56. package/renderer-host/assets/{src-DmzigsPg.js → src-BwIl76_H.js} +1 -1
  57. package/renderer-host/assets/{src-CHNgoDf9.js → src-C2e6QJIj.js} +1 -1
  58. package/renderer-host/assets/{src-Cyw_3X-L.js → src-C2gNidHF.js} +1 -1
  59. package/renderer-host/assets/{src-CBE5sqjl.js → src-CBUhG6W5.js} +1 -1
  60. package/renderer-host/assets/{src-Cvb3aCDG.js → src-CQDGi3Qa.js} +1 -1
  61. package/renderer-host/assets/{src-CBo2yHRk.js → src-CRLCRg0N.js} +1 -1
  62. package/renderer-host/assets/{src-Q-oKL3Dw.js → src-CS5rqxBy.js} +1 -1
  63. package/renderer-host/assets/{src-DrYYfoQO.js → src-CWZdSJQw.js} +1 -1
  64. package/renderer-host/assets/{src-B0zJlB0C.js → src-CXnpsVpU.js} +1 -1
  65. package/renderer-host/assets/{src-C4t_UvT8.js → src-CnhXvqQY.js} +1 -1
  66. package/renderer-host/assets/{src-CPUYqpHZ.js → src-CpExg0ZA.js} +1 -1
  67. package/renderer-host/assets/{src-C_HAB_bn.js → src-CrLmL3wU.js} +1 -1
  68. package/renderer-host/assets/{src-2X3Gt6Lk.js → src-CrYEJ5uz.js} +2 -2
  69. package/renderer-host/assets/{src-CifsQr3m.js → src-D-iIkSqZ.js} +1 -1
  70. package/renderer-host/assets/{src-p14e1hma.js → src-D6sH9uTT.js} +1 -1
  71. package/renderer-host/assets/{src-BPG8SYXq.js → src-D8zHDJh_.js} +1 -1
  72. package/renderer-host/assets/{src-D4cv_-u0.js → src-D9OFaPNV.js} +1 -1
  73. package/renderer-host/assets/{src-9k3CCYnZ.js → src-DCI_ff7c.js} +1 -1
  74. package/renderer-host/assets/{src-BB6xj1UK.js → src-DCrbiTpH.js} +1 -1
  75. package/renderer-host/assets/{src-TbSq3WSr.js → src-DK8DvtMd.js} +1 -1
  76. package/renderer-host/assets/{src-eVKtGm4Q.js → src-DWGlOVjt.js} +1 -1
  77. package/renderer-host/assets/{src-DpEmkhrn.js → src-DbvEX_Ct.js} +1 -1
  78. package/renderer-host/assets/{src-Ck1ekdEN.js → src-Dezc2dj1.js} +1 -1
  79. package/renderer-host/assets/{src-TuTvYAR6.js → src-Dh5VD1lL.js} +1 -1
  80. package/renderer-host/assets/{src-BydeR01n.js → src-DlwABqw5.js} +1 -1
  81. package/renderer-host/assets/{src-0QHjkpy0.js → src-DlxETlTh.js} +1 -1
  82. package/renderer-host/assets/{src-R4bKlaNn.js → src-Dmd6BvBh.js} +1 -1
  83. package/renderer-host/assets/{src-BuN3y1yE.js → src-DpgvaJNJ.js} +1 -1
  84. package/renderer-host/assets/{src-C6w9FGSB.js → src-DpjRB2sv.js} +1 -1
  85. package/renderer-host/assets/{src-Blx9jp9x.js → src-Dvn41FR7.js} +1 -1
  86. package/renderer-host/assets/{src-CVc67mQv.js → src-DwcPYp7X.js} +1 -1
  87. package/renderer-host/assets/{src-BZrNtUNO.js → src-HUxhcDlO.js} +1 -1
  88. package/renderer-host/assets/{src-ORHZWeVF.js → src-Jhqg3J8L.js} +2 -2
  89. package/renderer-host/assets/{src-DsVDi0pr.js → src-MO5bLsLj.js} +1 -1
  90. package/renderer-host/assets/{src-n2gsf381.js → src-N8XBQaK4.js} +1 -1
  91. package/renderer-host/assets/{src-BgUXah8O.js → src-XZ_0U972.js} +1 -1
  92. package/renderer-host/assets/{src-5ZJshveh.js → src-Y6mXl4vh.js} +3 -3
  93. package/renderer-host/assets/{src-B4jorJ2U.js → src-b9aXVJde.js} +1 -1
  94. package/renderer-host/assets/{src-CAdKRH5C.js → src-d2U6neq8.js} +1 -1
  95. package/renderer-host/assets/{src-Bl5Lv4-d.js → src-jUGjKzOV.js} +1 -1
  96. package/renderer-host/assets/{src-BgM1jpe4.js → src-vOBd-1zk.js} +1 -1
  97. package/renderer-host/assets/{src-0DTp6SF8.js → src-yCrAObB-.js} +1 -1
  98. package/renderer-host/assets/{src-BLndk63N.js → src-zrBiCtay.js} +1 -1
  99. package/renderer-host/assets/{stl-adapter-D1eozFH9.js → stl-adapter-CLkWHoOn.js} +1 -1
  100. package/renderer-host/assets/{three-mf-CbcWWdM8.js → three-mf-BSrcsdQD.js} +1 -1
  101. package/renderer-host/assets/{webm-_wYh_V7u.js → webm-14HHwfWy.js} +1 -1
  102. package/renderer-host/assets/{zip-core-base-CDv8KjIR.js → zip-core-base-DD8akpjq.js} +1 -1
  103. package/renderer-host/assets/zip-core-custom-CfPFs1lw.js +1 -0
  104. package/renderer-host/assets/{zip-source-C5dFTDt7.js → zip-source-CLF3Hfcg.js} +1 -1
  105. package/renderer-host/index.html +1 -1
  106. package/worker.mjs +3 -2
  107. package/renderer-host/assets/container-inspection-DZoaDYQR.js +0 -1
  108. package/renderer-host/assets/decode-D5vB6JN8.js +0 -1
  109. package/renderer-host/assets/index-BCxD9rBl.js +0 -2
  110. package/renderer-host/assets/src-2tfD0huT.js +0 -16
  111. package/renderer-host/assets/zip-core-custom-D3VVVj-J.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,s as n}from"./index-BCxD9rBl.js";import{n as r,r as i}from"./src-CBo2yHRk.js";import{t as a}from"./xml.browser-CC8-XAyN.js";import{t as o}from"./safe-content-B61Ktgzp.js";new Set(`head script style noscript template svg math img image object embed applet iframe frame frameset form input select textarea button audio video canvas map`.split(` `)),new Set(`html body p div section article aside header footer main nav address center figure figcaption caption table thead tbody tfoot dl dt dd ol ul blockquote`.split(` `));function s(e){return a(e,`text/html`)}var c={1028:`big5`,3076:`big5`,5124:`big5`,2052:`gbk`,4100:`gbk`,1041:`shift_jis`,1042:`euc-kr`,1049:`windows-1251`,1058:`windows-1251`,1059:`windows-1251`,1029:`windows-1250`,1038:`windows-1250`,1045:`windows-1250`,1048:`windows-1250`,1050:`windows-1250`,1051:`windows-1250`,1060:`windows-1250`,1032:`windows-1253`,1055:`windows-1254`,1037:`windows-1255`,1025:`windows-1256`,2049:`windows-1256`,1065:`windows-1256`,1061:`windows-1257`,1062:`windows-1257`,1063:`windows-1257`,1066:`windows-1258`,1054:`windows-874`},l=new TextDecoder(`utf-8`,{fatal:!0}),u=new TextDecoder(`windows-1252`);function d(e){return c[e&65535]??`windows-1252`}function f(e,t){try{return new TextDecoder(t,{fatal:!0}).decode(e)}catch{try{return new TextDecoder(t).decode(e)}catch{return null}}}function p(e){let t=u.decode(e.subarray(0,Math.min(e.byteLength,2048))),n=/<meta\b[^>]*\bcharset\s*=\s*["']?\s*([a-z0-9._-]+)/i.exec(t);if(n)return n[1].toLowerCase();let r=/<meta\b[^>]*\bhttp-equiv\s*=\s*["']?content-type["']?[^>]*\bcontent\s*=\s*["'][^"']*charset\s*=\s*([a-z0-9._-]+)/i.exec(t);return r?r[1].toLowerCase():null}function m(e,t,n=!1){if(e.byteLength===0)return``;if(e.byteLength>=3&&e[0]===239&&e[1]===187&&e[2]===191)return new TextDecoder(`utf-8`).decode(e.subarray(3));if(e.byteLength>=2&&e[0]===255&&e[1]===254)return new TextDecoder(`utf-16le`).decode(e.subarray(2));if(e.byteLength>=2&&e[0]===254&&e[1]===255)return new TextDecoder(`utf-16be`).decode(e.subarray(2));if(n){let t=p(e);if(t&&t!==`utf-8`&&t!==`utf8`){let n=f(e,t);if(n!==null)return n}}try{return l.decode(e)}catch{let n=f(e,t);return n===null?u.decode(e):n}}var h={maxFileBytes:134217728,maxHeaderBytes:512,maxDirChunks:4096,maxEntries:2e4,maxSectionBytes:134217728,maxSystemBytes:4194304,maxTopicBytes:2097152,maxTopics:2e3,maxTocItems:1e4,maxResetEntries:65536,maxResetIntervalBytes:16777216,maxCachedIntervals:8};function g(e){let t=e.trim().replace(/\\/g,`/`);try{t=decodeURIComponent(t)}catch{}t=t.replace(/^\/+/,``);let n=[];for(let e of t.split(`/`))!e||e===`.`||(e===`..`?n.length>0&&n.pop():n.push(e));return`/`+n.join(`/`)}function _(e,t,n,r){let i=n.trim();if(!i||/^(?:javascript|vbscript|data|mailto|tel|https?|ftp):/i.test(i))return null;let a=i,o=/^(?:ms-its|its|mk:@MSITStore):([^:]*)::(.*)$/i.exec(a);if(o){let e=o[1].trim().replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase()??``;if(e&&(!r||!r.has(e)))return null;let t=o[2].trim();if(!t.startsWith(`/`))return null;a=t}else if(/^[a-z][\w+.-]*:/i.test(a))return null;let[s,c=``]=a.split(`#`,2),l=c;try{l=decodeURIComponent(c)}catch{}if(!s){let n=e.byExactPath.get(t)??e.byLowerPath.get(t.toLowerCase());return n?{entry:n,fragment:l}:null}let u=[];if(s.startsWith(`/`))u.push(g(s));else{let e=t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)+1):`/`;u.push(g(e+s)),u.push(g(`/`+s))}for(let t of u){let n=e.byExactPath.get(t)??e.byLowerPath.get(t.toLowerCase());if(n)return{entry:n,fragment:l}}return null}function v(e,t){let n=e.indexOf(0);return n<0&&(n=e.length),m(e.subarray(0,n),t).trim()}function y(e,t){let n=t,r=``,i=``,a=``,o=``,s=``;if(e.byteLength<4)return{title:r,compiledName:i,defaultTopic:a,hhcPath:o,hhkPath:s,encoding:n};let c=new DataView(e.buffer,e.byteOffset,e.byteLength),l=[],u=4;for(;u+4<=e.byteLength;){let t=c.getUint16(u,!0),r=c.getUint16(u+2,!0);if(u+=4,u+r>e.byteLength)break;let i=e.subarray(u,u+r);if(u+=r,t===4&&i.byteLength>=4){let e=new DataView(i.buffer,i.byteOffset,i.byteLength).getUint32(0,!0);e>0&&(n=d(e))}l.push({code:t,payload:i})}for(let{code:e,payload:t}of l)e===0&&!o?o=v(t,n):e===1&&!s?s=v(t,n):e===2&&!a?a=v(t,n):e===3&&!r?r=v(t,n):e===6&&!i&&(i=v(t,n));return{title:r,compiledName:i,defaultTopic:a,hhcPath:o,hhkPath:s,encoding:n}}function b(e,t,n){if(t<=0||t>=e.byteLength)return``;let r=t;for(;r<e.byteLength&&e[r]!==0;)r+=1;return m(e.subarray(t,r),n).trim()}function x(e,t,n){if(t<0||t+8>=e.byteLength)return``;let r=t+8;for(;r<e.byteLength&&e[r]!==0;)r+=1;return m(e.subarray(t+8,r),n).trim()}function S(e,t,n){let r=s(e),i=0;function a(e){let r=Array.from(e.children).find(e=>e.localName===`object`);if(!r||(r.getAttribute(`type`)??``).toLowerCase()!==`text/sitemap`)return null;let i=``,a=``;for(let e of Array.from(r.querySelectorAll(`param`))){let t=(e.getAttribute(`name`)??``).toLowerCase(),n=(e.getAttribute(`value`)??``).trim();t===`name`&&!i?i=n:(t===`local`||t===`url`)&&!a&&(a=n)}if(!i&&!a)return null;if(!a)return{label:i||`Section`,path:``,fragment:``};let o=_(t,n,a);return o?{label:i||o.entry.path.split(`/`).pop()||o.entry.path,path:o.entry.path,fragment:o.fragment}:{label:i||a,path:``,fragment:``}}function o(e,t){if(t>32||i>=h.maxTocItems)return[];let n=[];for(let r of Array.from(e.children)){if(i>=h.maxTocItems)break;if(r.localName===`li`){let e=a(r),s=Array.from(r.children).filter(e=>e.localName===`ul`).flatMap(e=>o(e,t+1));e?(i+=1,n.push({label:e.label,path:e.path,fragment:e.fragment,children:s})):s.length>0&&n.push(...s)}else if(r.localName===`ul`){let e=n[n.length-1],i=o(r,t+1);e&&i.length>0?n[n.length-1]={...e,children:[...e.children,...i]}:n.push(...i)}}return n}return{tree:Array.from(r.querySelectorAll(`ul`)).filter(e=>!e.parentElement||e.parentElement.localName!==`li`).filter(e=>{let t=e.parentElement;for(;t;){if(t.localName===`ul`)return!1;t=t.parentElement}return!0}).flatMap(e=>o(e,0)),flatCount:i}}function C(e,t=[]){for(let n of e){if(t.length>=h.maxTocItems)break;n.path&&t.push({label:n.label,path:n.path,fragment:n.fragment}),n.children.length>0&&C(n.children,t)}return t}async function w(e,t,n){let r=d(e.lcid),i={title:``,compiledName:``,defaultTopic:``,hhcPath:``,hhkPath:``,encoding:r},a=e.byLowerPath.get(`/#system`);a&&(i=y(await t.readEntry(a,h.maxSystemBytes,n),r));let o=i.encoding,s=(i.hhcPath?_(e,`/`,i.hhcPath)?.entry:null)??e.entries.find(e=>!e.path.startsWith(`::`)&&e.lowerPath.endsWith(`.hhc`))??null,c=(i.hhkPath?_(e,`/`,i.hhkPath)?.entry:null)??e.entries.find(e=>!e.path.startsWith(`::`)&&e.lowerPath.endsWith(`.hhk`))??null,l=[];s&&s.length>0&&(l=S(m(await t.readEntry(s,h.maxTopicBytes,n),o,!0),e,s.path).tree);let u=[];c&&c.length>0&&(u=C(S(m(await t.readEntry(c,h.maxTopicBytes,n),o,!0),e,c.path).tree));let f=[],p=e.byLowerPath.get(`/#topics`),g=e.byLowerPath.get(`/#strings`),v=e.byLowerPath.get(`/#urltbl`),w=e.byLowerPath.get(`/#urlstr`);if(p&&v&&w){let[r,i,a,s]=await Promise.all([t.readEntry(p,h.maxSystemBytes,n),g?t.readEntry(g,h.maxSystemBytes,n):Promise.resolve(new Uint8Array),t.readEntry(v,h.maxSystemBytes,n),t.readEntry(w,h.maxSystemBytes,n)]),c=new DataView(r.buffer,r.byteOffset,r.byteLength),l=new DataView(a.buffer,a.byteOffset,a.byteLength),u=Math.min(Math.floor(r.byteLength/16),h.maxTopics);for(let t=0;t<u;t+=1){let n=t*16,r=c.getInt32(n+4,!0),u=c.getUint32(n+8,!0);if(u+12>a.byteLength)continue;let d=x(s,l.getUint32(u+8,!0),o);if(!d)continue;let p=_(e,`/`,d);if(!p)continue;let m=r>=0?b(i,r,o):``;f.push({title:m,url:p.entry.path})}}let T=``;if(i.defaultTopic){let t=_(e,`/`,i.defaultTopic);t&&(T=t.entry.path)}return{title:i.title,compiledName:i.compiledName,encoding:o,defaultTopic:T,hhcPath:s?.path??``,hhkPath:c?.path??``,tocTree:l,indexEntries:u,systemTopics:f}}var T=new TextDecoder(`utf-8`,{fatal:!0});function E(e,n){let r=e.getUint32(n,!0),i=e.getUint32(n+4,!0);if(i>2097151)throw new t(`invalid-file`,`CHM 64-bit offset exceeds safe bounds.`);return i*2**32+r}function D(e,n,r){let i=0,a=0;for(;n.pos<r;){let r=e[n.pos++];if(a+=1,a>8)throw new t(`invalid-file`,`CHM encint exceeds 64-bit limit.`);if(i>4398046511103)throw new t(`invalid-file`,`CHM encint overflows safe integer.`);if(i=i*128+(r&127),!(r&128))return i}throw new t(`invalid-file`,`Truncated CHM encint.`)}async function O(e,n,r,i){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n<0||r<n||r>e.size)throw new t(`invalid-file`,`CHM slice offset out of range.`);let a=await e.slice(n,r).arrayBuffer();if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);return new Uint8Array(a)}function k(e,t,n){let r=``;for(let i=0;i<n;i+=1)r+=String.fromCharCode(e[t+i]);return r}function A(e,n,r,i){if(k(e,0,4)!==`PMGL`)throw new t(`invalid-file`,`Expected PMGL directory chunk.`);let a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=a.getUint32(4,!0),s=a.getInt32(16,!0);if(o<2||o>e.byteLength-20)throw new t(`invalid-file`,`Invalid PMGL free space.`);let c=e.byteLength-o,l={pos:20};for(;l.pos<c;){let a=D(e,l,c);if(a===0||l.pos+a>c)throw new t(`invalid-file`,`Invalid CHM entry name length.`);let o=e.subarray(l.pos,l.pos+a);l.pos+=a;let s;try{s=T.decode(o)}catch{throw new t(`invalid-file`,`Invalid UTF-8 in CHM entry path.`)}if(!s||s.includes(`\0`))throw new t(`invalid-file`,`Invalid CHM entry path.`);let u=D(e,l,c);if(u!==0&&u!==1)throw new t(`invalid-file`,`Unsupported CHM section number.`);let d=D(e,l,c),f=D(e,l,c);if(n.length>=h.maxEntries)throw new t(`resource-limit`,`CHM entry count limit exceeded.`);let p={path:s,lowerPath:s.toLowerCase(),section:u,offset:d,length:f};n.push(p),r.has(p.path)||r.set(p.path,p),i.has(p.lowerPath)||i.set(p.lowerPath,p)}return s}async function j(e,n){if(e.size>h.maxFileBytes)throw new t(`resource-limit`,`CHM file exceeds 128 MiB limit.`);if(e.size<172)throw new t(`invalid-file`,`File is too small to be a CHM archive.`);let r=await O(e,0,Math.min(e.size,96),n);if(k(r,0,4)!==`ITSF`)throw new t(`invalid-file`,`Missing ITSF signature.`);let i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=i.getUint32(4,!0),o=i.getUint32(8,!0);if(a===2){if(o<88||o>h.maxHeaderBytes)throw new t(`invalid-file`,`Invalid ITSF v2 header length.`)}else if(a===3){if(o<96||o>h.maxHeaderBytes||r.byteLength<96)throw new t(`invalid-file`,`Invalid ITSF v3 header length.`)}else throw new t(`invalid-file`,`Unsupported ITSF version.`);let s=i.getUint32(20,!0);E(i,56),E(i,64);let c=E(i,72),l=E(i,80);if(c<o||l<84||c+l>e.size)throw new t(`invalid-file`,`CHM directory bounds out of range.`);let u=a>=3?E(i,88):c+l;if(u<c+l||u>e.size)throw new t(`invalid-file`,`Invalid CHM content offset.`);let d=await O(e,c,c+84,n);if(k(d,0,4)!==`ITSP`)throw new t(`invalid-file`,`Missing ITSP directory header.`);let f=new DataView(d.buffer,d.byteOffset,d.byteLength),p=f.getUint32(4,!0),m=f.getUint32(8,!0),g=f.getUint32(16,!0),_=f.getInt32(32,!0),v=f.getInt32(36,!0),y=f.getUint32(44,!0),b=f.getUint32(48,!0);if(p!==1||m<84||m>h.maxHeaderBytes)throw new t(`invalid-file`,`Invalid ITSP header.`);if(g<64||g>65536)throw new t(`invalid-file`,`Unsupported CHM directory chunk size.`);if(y>h.maxDirChunks)throw new t(`resource-limit`,`CHM directory chunk count exceeds limit.`);let x=c+m;if(x+y*g>c+l)throw new t(`invalid-file`,`CHM directory chunks exceed directory bounds.`);let S=[],C=new Map,w=new Map;if(y>0&&_>=0){if(_>=y||v>=0&&v>=y)throw new t(`invalid-file`,`CHM PMGL chunk index out of range.`);let r=new Set,i=_;for(;i>=0;){if(i>=y||r.has(i))throw new t(`invalid-file`,`CHM directory chunk loop or invalid link.`);r.add(i);let a=x+i*g,o=A(await O(e,a,a+g,n),S,C,w);if(i===v){if(o>=0)throw new t(`invalid-file`,`CHM directory chunk loop or trailing link.`);break}i=o}}return{version:a,lcid:b||s,contentOffset:u,entries:S,byExactPath:C,byLowerPath:w}}var M=32768,N=16,P=12,F=20,I=249,L=8,R=[30,32,34,36,38,42,50],z=new Uint8Array(51),B=new Uint32Array(51);(()=>{let e=0;for(let t=0;t<51;t+=1){let n=t<4?0:t<36?(t>>1)-1:17;z[t]=n,B[t]=e,e+=1<<n}})();var V=class{constructor(e){this.data=e,this.pos=0,this.bitBuf=0,this.bitsLeft=0,this.eofPadded=!1}ensure(e){for(;this.bitsLeft<e;){if(this.pos>=this.data.length){if(this.eofPadded)throw new t(`invalid-file`,`Unexpected end of LZX compressed stream.`);this.eofPadded=!0,this.bitsLeft+=16;return}let e=this.data[this.pos++]|(this.pos<this.data.length?this.data[this.pos++]:0)<<8;this.bitBuf=(this.bitBuf|e<<16-this.bitsLeft)>>>0,this.bitsLeft+=16}}peek(e){return e===0?0:(this.ensure(e),this.bitBuf>>>32-e)}skip(e){if(this.eofPadded&&e>this.bitsLeft-16)throw new t(`invalid-file`,`Unexpected end of LZX compressed stream.`);this.bitBuf=e>=32?0:this.bitBuf<<e>>>0,this.bitsLeft-=e}readBits(e){if(e===0)return 0;if(e<=16){let t=this.peek(e);return this.skip(e),t}let t=this.readBits(16),n=this.readBits(e-16);return(t<<e-16|n)>>>0}alignForUncompressed(){return this.bitsLeft===0&&this.ensure(16),this.bitsLeft=0,this.bitBuf=0,{r0:this.readRawUint32(),r1:this.readRawUint32(),r2:this.readRawUint32()}}readRawBytes(e,n,r){if(this.pos+r>this.data.length)throw new t(`invalid-file`,`Truncated LZX uncompressed block.`);e.set(this.data.subarray(this.pos,this.pos+r),n),this.pos+=r}skipPadByte(){this.pos<this.data.length&&(this.pos+=1)}readRawUint32(){if(this.pos+4>this.data.length)throw new t(`invalid-file`,`Truncated LZX uncompressed block header.`);let e=(this.data[this.pos]|this.data[this.pos+1]<<8|this.data[this.pos+2]<<16|this.data[this.pos+3]<<24)>>>0;return this.pos+=4,e}};function H(e,n){let r=e.length,i=new Int32Array(4096).fill(-1),a=new Int32Array(r*2+16).fill(-1),o=new Int32Array(r*2+16).fill(-1),s=0,c=0;for(let n=0;n<r;n+=1){let r=e[n];if(r>N)throw new t(`invalid-file`,`Invalid LZX Huffman code length.`);r>0&&(s+=1,r>c&&(c=r))}if(s===0){if(!n)throw new t(`invalid-file`,`Empty LZX Huffman table.`);return{empty:!0,maxBits:0,table:i,left:a,right:o}}let l=0,u=r;for(let n=1;n<=c;n+=1){for(let s=0;s<r;s+=1)if(e[s]===n){if(l>=1<<n)throw new t(`invalid-file`,`Oversubscribed LZX Huffman table.`);if(n<=P){let e=P-n,t=l<<e,r=l+1<<e;i.fill(s,t,r)}else{let e=l>>>n-P,t=i[e];t===-1&&(t=u++,i[e]=t);let r=n-P;for(let e=r-1;e>=0;--e){let n=l>>>e&1;if(e===0)n?o[t]=s:a[t]=s;else{let e=n?o[t]:a[t];e===-1&&(e=u++,n?o[t]=e:a[t]=e),t=e}}}l+=1}l<<=1}return{empty:!1,maxBits:c,table:i,left:a,right:o}}function U(e,n,r,i){if(n.empty)throw new t(`invalid-file`,`Attempted decode from empty LZX Huffman table.`);let a=e.peek(P),o=n.table[a];if(o<0)throw new t(`invalid-file`,`Invalid LZX Huffman prefix.`);if(o<i)return e.skip(r[o]),o;e.skip(P);let s=o;for(let r=0;r<5;r+=1){if(s=e.readBits(1)?n.right[s]:n.left[s],s<0)throw new t(`invalid-file`,`Invalid LZX Huffman tree path.`);if(s<i)return s}throw new t(`invalid-file`,`LZX Huffman code exceeded max length.`)}function W(e,t,n,r){let i=new Uint8Array(F);for(let t=0;t<F;t+=1)i[t]=e.readBits(4);let a=H(i,!1),o=n;for(;o<r;){let n=U(e,a,i,F);if(n===17){let n=e.readBits(4)+4,i=Math.min(r,o+n);for(;o<i;)t[o++]=0}else if(n===18){let n=e.readBits(5)+20,i=Math.min(r,o+n);for(;o<i;)t[o++]=0}else if(n===19){let n=e.readBits(1)+4,s=U(e,a,i,F),c=(t[o]-s+17)%17,l=Math.min(r,o+n);for(;o<l;)t[o++]=c}else t[o]=(t[o]-n+17)%17,o+=1}}function G(e,n,r,i){if(r>h.maxResetIntervalBytes&&r>h.maxSectionBytes)throw new t(`resource-limit`,`LZX decompression request exceeds budget.`);if(r===0)return new Uint8Array;let a=new V(e),o=new Uint8Array(n.windowSize),s=n.windowSize-1,c=Math.ceil(r/M)*M,l=new Uint8Array(c),u=256+(R[n.windowBits-15]<<3),d=new Uint8Array(u),f=new Uint8Array(I),p=new Uint8Array(L),m=null,g=null,_=null,v=1,y=1,b=1,x=!1,S=0,C=!1,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=()=>{v=1,y=1,b=1,x=!1,E=0,w=0,d.fill(0),f.fill(0),m=null,g=null,_=null};for(;A<r;){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);n.resetFrames>0&&k>0&&k%n.resetFrames===0&&j(),x||=(S=a.readBits(1)?a.readBits(16)<<16|a.readBits(16):0,!0);let e=M,c=e;for(;c>0;){if(E===0){if(A+(e-c)>=r){let t=e-c;return t>0&&l.set(o.subarray(O,O+t),A),l.subarray(0,r)}if(w===3&&T&1&&a.skipPadByte(),w=a.readBits(3),T=a.readBits(16)<<8|a.readBits(8),E=T,w===2){for(let e=0;e<8;e+=1)p[e]=a.readBits(3);_=H(p,!1)}if(w===1||w===2)W(a,d,0,256),W(a,d,256,u),m=H(d,!1),d[232]!==0&&(C=!0),W(a,f,0,I),g=H(f,!0);else if(w===3){C=!0;let e=a.alignForUncompressed();v=e.r0,y=e.r1,b=e.r2}else throw new t(`invalid-file`,`Invalid LZX block type.`)}let i=Math.min(E,c);if(i<=0)throw new t(`invalid-file`,`Zero-length LZX block.`);if(w===3)a.readRawBytes(o,D,i),D+=i,E-=i,c-=i;else{let e=i;for(;e>0;){let r=U(a,m,d,u);if(r<256)o[D++]=r,--e,--E,--c;else{let i=r-256,l=i&7;l===7&&(l+=U(a,g,f,I)),l+=2;let u=i>>3,d;if(u===0)d=v;else if(u===1)d=y,y=v,v=d;else if(u===2)d=b,b=v,v=d;else{let e=z[u],t=B[u]-2;if(w===2&&e>=3){let n=a.readBits(e-3)<<3,r=U(a,_,p,L);d=t+n+r}else d=t+a.readBits(e);b=y,y=v,v=d}if(d<=0||d>n.windowSize)throw new t(`invalid-file`,`LZX match offset out of window.`);if(l>e)throw new t(`invalid-file`,`LZX match crosses block or frame boundary.`);let m=D-d&s;for(let e=0;e<l;e+=1)o[D++]=o[m],m=m+1&s;e-=l,E-=l,c-=l}}}}let h=o.subarray(O,O+e);if(l.set(h,A),C&&S>0&&k<32768){let t=A,n=A+e-10,r=A;for(;r<n;){if(l[r++]!==232){t+=1;continue}let e=l[r]|l[r+1]<<8|l[r+2]<<16|l[r+3]<<24;if(e>=-t&&e<S){let n=e>=0?e-t:e+S;l[r]=n&255,l[r+1]=n>>>8&255,l[r+2]=n>>>16&255,l[r+3]=n>>>24&255}r+=4,t+=5}}A+=e,O+=e,k+=1,D===n.windowSize&&(D=0),O===n.windowSize&&(O=0)}return l.subarray(0,r)}function K(e,n){let r=e.getUint32(n,!0),i=e.getUint32(n+4,!0);if(i>2097151)throw new t(`invalid-file`,`CHM ResetTable 64-bit integer out of range.`);return i*2**32+r}function q(e){if(e.byteLength<28)throw new t(`invalid-file`,`CHM ControlData is truncated.`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e[4]!==76||e[5]!==90||e[6]!==88||e[7]!==67)throw new t(`invalid-file`,`Invalid CHM LZXC signature.`);let r=n.getUint32(8,!0),i=n.getUint32(12,!0),a=n.getUint32(16,!0);if(r===2)i*=M,a*=M;else if(r!==1)throw new t(`invalid-file`,`Unsupported LZXC ControlData version.`);let o=0;for(let e=15;e<=21;e+=1)if(a===1<<e){o=e;break}if(!o)throw new t(`invalid-file`,`Unsupported LZX window size.`);if(i===0||i%32768!=0)throw new t(`invalid-file`,`Invalid LZX reset interval.`);if(i>h.maxResetIntervalBytes)throw new t(`resource-limit`,`LZX reset interval exceeds budget.`);return{windowBits:o,windowSize:a,resetInterval:i,resetFrames:i/M}}function ee(e,n){if(e.byteLength<40)throw new t(`invalid-file`,`CHM ResetTable is truncated.`);let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=r.getUint32(0,!0),a=r.getUint32(4,!0),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=K(r,16),l=K(r,24),u=K(r,32);if(i!==2||o!==4&&o!==8||s<40)throw new t(`invalid-file`,`Invalid CHM ResetTable header.`);if(a>h.maxResetEntries)throw new t(`resource-limit`,`CHM ResetTable entry count exceeds budget.`);if(c>h.maxSectionBytes)throw new t(`resource-limit`,`CHM uncompressed section exceeds 128 MiB limit.`);if(l>n)throw new t(`invalid-file`,`CHM ResetTable compressed length exceeds content stream.`);if(s+a*o>e.byteLength)throw new t(`invalid-file`,`CHM ResetTable entries exceed table bounds.`);let d=[],f=0;for(let e=0;e<a;e+=1){let i=s+e*o,a=o===8?K(r,i):r.getUint32(i,!0);if(a<f||a>n)throw new t(`invalid-file`,`Invalid CHM ResetTable entry offset.`);d.push(a),f=a}return{uncompressedLength:c,compressedLength:l,frameLength:u||32768,offsets:d}}async function J(e,n,r,i){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n<0||r<n||r>e.size)throw new t(`invalid-file`,`CHM file slice out of bounds.`);let a=await e.slice(n,r).arrayBuffer();if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);return new Uint8Array(a)}function te(e,n){let r=null,i=new Map;async function a(r,i,a){if(r.length>i)throw new t(`resource-limit`,`CHM entry exceeds read budget.`);if(r.length===0)return new Uint8Array;let o=n.contentOffset+r.offset;return J(e,o,o+r.length,a)}async function o(e){if(r)return r;r=(async()=>{let r=n.byLowerPath.get(`::dataspace/storage/mscompressed/content`),i=n.byLowerPath.get(`::dataspace/storage/mscompressed/controldata`);if(!r||!i||r.section!==0||i.section!==0)throw new t(`invalid-file`,`Missing CHM MSCompressed stream metadata.`);let o=q(await a(i,1024,e)),s=n.byLowerPath.get(`::dataspace/storage/mscompressed/transform/{7fc28940-9d31-11d0-9b27-00a0c91e9c7c}/instancedata/resettable`),c=null,l=0;if(s&&s.section===0)c=ee(await a(s,2097152,e),r.length),l=c.uncompressedLength;else{let r=n.byLowerPath.get(`::dataspace/storage/mscompressed/spaninfo`);if(!r||r.section!==0||r.length<8)throw new t(`invalid-file`,`Missing CHM ResetTable and SpanInfo.`);let i=await a(r,64,e);l=K(new DataView(i.buffer,i.byteOffset,i.byteLength),0)}if(l>h.maxSectionBytes)throw new t(`resource-limit`,`CHM compressed section exceeds 128 MiB limit.`);return{contentEntry:r,control:o,resetTable:c,totalUncompressed:l}})();try{return await r}catch(e){throw r=null,e}}async function s(r,a){let s=i.get(r);if(s)return i.delete(r),i.set(r,s),s;let{contentEntry:c,control:l,resetTable:u,totalUncompressed:d}=await o(a),f=n.contentOffset+c.offset,p;if(u&&u.offsets.length>0){let n=r*l.resetFrames;if(n>=u.offsets.length)throw new t(`invalid-file`,`CHM ResetTable frame index out of range.`);let i=u.offsets[n],o=n+l.resetFrames,s=o<u.offsets.length?u.offsets[o]:u.compressedLength||c.length,m=n*M,h=Math.min(l.resetInterval,d-m);if(h<=0)throw new t(`invalid-file`,`CHM ResetTable interval is empty.`);p=G(await J(e,f+i,f+s,a),l,h,a)}else{if(r!==0)throw new t(`invalid-file`,`CHM missing ResetTable for seek.`);if(d>h.maxResetIntervalBytes)throw new t(`resource-limit`,`CHM unseekable compressed stream exceeds budget.`);p=G(await J(e,f,f+c.length,a),l,d,a)}if(i.size>=h.maxCachedIntervals){let e=i.keys().next().value;e!==void 0&&i.delete(e)}return i.set(r,p),p}return{async readEntry(e,n,r){if(e.length>n)throw new t(`resource-limit`,`CHM entry exceeds read budget.`);if(e.length===0)return new Uint8Array;if(e.section===0)return a(e,n,r);let i=await o(r);if(e.offset+e.length>i.totalUncompressed)throw new t(`invalid-file`,`CHM entry offset exceeds uncompressed section.`);let c=i.resetTable?i.control.resetInterval:i.totalUncompressed,l=Math.floor(e.offset/c),u=Math.floor((e.offset+e.length-1)/c);if(l===u){let t=await s(l,r),n=e.offset-l*c;return t.slice(n,n+e.length)}let d=new Uint8Array(e.length),f=0;for(let t=l;t<=u;t+=1){let n=await s(t,r),i=t*c,a=Math.max(0,e.offset-i),o=Math.min(n.length,e.offset+e.length-i);d.set(n.subarray(a,o),f),f+=o-a}return d},dispose(){i.clear()}}}var ne={protocolVersion:2,id:`chm-reader`,name:{en:`CHM help reader`,"zh-CN":`CHM 帮助文档阅读器`},formats:[{name:{en:`Compiled HTML Help`,"zh-CN":`CHM 编译 HTML 帮助文档`},extensions:[`.chm`],mimeTypes:[`application/vnd.ms-htmlhelp`]}],workspaceAccess:`none`};function Y(t){return{...i(t),...e(t,{en:{invalid:`The CHM help file is damaged or uses an unsupported layout.`,limit:`This CHM help file exceeds the safe reading resource limits.`,noTopics:`No readable HTML topics were found in this CHM archive.`,unsupportedObject:`Unsupported embedded object`},"zh-CN":{invalid:`CHM 帮助文件已损坏或使用了不支持的格式结构。`,limit:`此 CHM 帮助文件超过安全阅读资源上限。`,noTopics:`在此 CHM 归档中未找到可阅读的 HTML 主题。`,unsupportedObject:`不支持的嵌入对象`}})}}var re={".html":`text/html`,".htm":`text/html`,".xhtml":`text/html`,".css":`text/css`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".svg":`image/svg+xml`,".bmp":`image/bmp`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`,".ttf":`font/ttf`,".otf":`font/otf`};function X(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:re[e.slice(t)]??`application/octet-stream`}function Z(e){return e.path.startsWith(`::`)||e.path.startsWith(`/#`)||e.path.startsWith(`/$`)?!1:e.lowerPath.endsWith(`.html`)||e.lowerPath.endsWith(`.htm`)||e.lowerPath.endsWith(`.xhtml`)}function Q(e){return e.replace(/^\/+/,``)}function $(e,t){let n=e.split(`/`).slice(0,-1),r=t.split(`/`),i=0;for(;i<n.length&&i<r.length-1&&n[i]===r[i];)i+=1;let a=Array.from({length:n.length-i},()=>`..`),o=r.slice(i);return[...a,...o].map(e=>e===`..`?e:encodeURIComponent(e)).join(`/`)}function ie(e,t,n,r,i,a){let o=document.createElement(`template`);o.innerHTML=e;let s=Q(t);for(let e of Array.from(o.content.querySelectorAll(`object, embed, applet`))){let t=o.content.ownerDocument.createElement(`span`);t.textContent=`[${i}]`,e.replaceWith(t)}for(let e of Array.from(o.content.querySelectorAll(`a[href]`))){let i=_(n,t,e.getAttribute(`href`)??``,r);if(i&&Z(i.entry)){let t=$(s,Q(i.entry.path)),n=i.fragment?`#${encodeURIComponent(i.fragment)}`:``;e.setAttribute(`href`,`${t}${n}`)}else e.removeAttribute(`href`)}for(let e of Array.from(o.content.querySelectorAll(`img[src]`))){let i=e.getAttribute(`src`)??``;if(/^(?:https?:|ftp:|javascript:|vbscript:)/i.test(i.trim())){e.removeAttribute(`src`);continue}let o=_(n,t,i,r);if(o)e.setAttribute(`src`,$(s,Q(o.entry.path)));else{let n=i.trim();if(n&&!/^[a-z][\w+.-]*:/i.test(n)){let r=t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)+1):`/`,i=Q(g(n.startsWith(`/`)?n:r+n)),o=X(i.toLowerCase());o.startsWith(`image/`)&&!a.has(i)&&a.set(i,{id:i,path:i,type:o,properties:[]}),e.setAttribute(`src`,$(s,i))}else e.removeAttribute(`src`)}}for(let e of Array.from(o.content.querySelectorAll(`link[href]`))){if((e.getAttribute(`rel`)??``).toLowerCase()!==`stylesheet`){e.removeAttribute(`href`);continue}let i=_(n,t,e.getAttribute(`href`)??``,r);i?e.setAttribute(`href`,$(s,Q(i.entry.path))):e.removeAttribute(`href`)}return new TextEncoder().encode(o.innerHTML)}function ae(e,n,r,i,a){let s=Y(a),c=new Set,l=e.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase();if(l&&c.add(l),r.compiledName){let e=r.compiledName.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase();e&&(c.add(e),e.endsWith(`.chm`)||c.add(`${e}.chm`))}let u=new Map,d=new Map,f=new Map;for(let e of n.entries){if(e.path.startsWith(`::`)||e.path.endsWith(`/`))continue;let t=Q(e.path);!t||u.has(t)||(u.set(t,e),d.set(t,{filename:t,directory:!1,uncompressedSize:e.length}),f.set(t,{id:t,path:t,type:X(e.lowerPath),properties:[]}))}let p=[],g=new Set,_=e=>{if(!e||p.length>=h.maxTopics)return;let t=Q(e),n=u.get(t);!n||!Z(n)||g.has(t)||(g.add(t),p.push(t))};r.defaultTopic&&_(r.defaultTopic);let v=e=>{for(let t of e)t.path&&_(t.path),t.children.length>0&&v(t.children)};v(r.tocTree);for(let e of r.indexEntries)_(e.path);for(let e of r.systemTopics)_(e.url);for(let e of n.entries)Z(e)&&_(e.path);if(p.length===0)throw new t(`invalid-file`,s.noTopics);let y=p.map(e=>f.get(e)),b=[],x=(e,t)=>{for(let n of e){let e=n.path?Q(n.path):``;if(e&&g.has(e)){let r=t>0?`${`— `.repeat(Math.min(t,4))}`:``;b.push({label:`${r}${n.label}`,path:e,fragment:n.fragment})}n.children.length>0&&x(n.children,t+1)}};if(x(r.tocTree,0),b.length===0){let e=new Map;for(let t of r.systemTopics)t.title&&e.set(Q(t.url),t.title);for(let t of p)b.push({label:e.get(t)||t.split(`/`).pop()||t,path:t,fragment:``})}let S=e=>e.map(e=>{let t=e.path?Q(e.path):``,n=t&&g.has(t)?t:``,r=S(e.children);return!n&&r.length===0?null:{label:e.label,path:n,fragment:e.fragment,children:r}}).filter(e=>e!==null),C=S(r.tocTree),w=r.indexEntries.map(e=>({label:e.label,path:Q(e.path),fragment:e.fragment})).filter(e=>g.has(e.path)),T={entries:d,async read(e,a,o=new AbortController().signal){let l=u.get(e);if(!l)throw new t(`missing-related-file`,s.missing);let d=await i.readEntry(l,a,o),p=X(l.lowerPath);if(p===`text/html`)return ie(m(d,r.encoding,!0),l.path,n,c,s.unsupportedObject,f);if(p===`text/css`){let e=m(d,r.encoding,!1);return new TextEncoder().encode(e)}return d},async dispose(){i.dispose()}},E={title:r.title||e,author:``,direction:`ltr`,items:f,spine:y,toc:b};return{title:E.title,author:E.author,spine:y,toc:b,tocTree:C.length>0?C:void 0,index:w.length>0?w:void 0,loadSection:(e,t)=>o(T,E,e,t)}}var oe={manifest:ne,async open(e){let i=Y(e.locale),a=document.createElement(`div`);a.className=`anyfile-chm-reader`;let o=new AbortController,s,c,l=!1,u=()=>{l||(l=!0,o.abort(),e.signal.removeEventListener(`abort`,u),c?.dispose(),s?.dispose(),a.remove())};try{if(e.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(typeof ResizeObserver>`u`||typeof DOMParser>`u`||typeof CSSStyleSheet>`u`)throw new t(`unsupported-environment`,i.environment);e.signal.addEventListener(`abort`,u,{once:!0}),e.reportProgress({stage:`parsing`,message:i.loading});let n=await j(e.file,o.signal);s=te(e.file,n);let l=await w(n,s,o.signal),d=ae(e.file.name,n,l,s,e.locale);if(o.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);return e.container.append(a),c=r(a,d,e.locale,i),{dispose:u}}catch(e){if(u(),n(e))throw e;let r=e instanceof t?e.code:`invalid-file`;throw new t(r,r===`resource-limit`?i.limit:r===`missing-related-file`?i.missing:r===`unsupported-environment`?i.environment:i.invalid,{cause:e})}}};export{oe as chmViewer};
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,s as n}from"./index-DtiyOy_J.js";import{n as r,r as i}from"./src-CRLCRg0N.js";import{t as a}from"./xml.browser-CC8-XAyN.js";import{t as o}from"./safe-content-CWHf8jex.js";new Set(`head script style noscript template svg math img image object embed applet iframe frame frameset form input select textarea button audio video canvas map`.split(` `)),new Set(`html body p div section article aside header footer main nav address center figure figcaption caption table thead tbody tfoot dl dt dd ol ul blockquote`.split(` `));function s(e){return a(e,`text/html`)}var c={1028:`big5`,3076:`big5`,5124:`big5`,2052:`gbk`,4100:`gbk`,1041:`shift_jis`,1042:`euc-kr`,1049:`windows-1251`,1058:`windows-1251`,1059:`windows-1251`,1029:`windows-1250`,1038:`windows-1250`,1045:`windows-1250`,1048:`windows-1250`,1050:`windows-1250`,1051:`windows-1250`,1060:`windows-1250`,1032:`windows-1253`,1055:`windows-1254`,1037:`windows-1255`,1025:`windows-1256`,2049:`windows-1256`,1065:`windows-1256`,1061:`windows-1257`,1062:`windows-1257`,1063:`windows-1257`,1066:`windows-1258`,1054:`windows-874`},l=new TextDecoder(`utf-8`,{fatal:!0}),u=new TextDecoder(`windows-1252`);function d(e){return c[e&65535]??`windows-1252`}function f(e,t){try{return new TextDecoder(t,{fatal:!0}).decode(e)}catch{try{return new TextDecoder(t).decode(e)}catch{return null}}}function p(e){let t=u.decode(e.subarray(0,Math.min(e.byteLength,2048))),n=/<meta\b[^>]*\bcharset\s*=\s*["']?\s*([a-z0-9._-]+)/i.exec(t);if(n)return n[1].toLowerCase();let r=/<meta\b[^>]*\bhttp-equiv\s*=\s*["']?content-type["']?[^>]*\bcontent\s*=\s*["'][^"']*charset\s*=\s*([a-z0-9._-]+)/i.exec(t);return r?r[1].toLowerCase():null}function m(e,t,n=!1){if(e.byteLength===0)return``;if(e.byteLength>=3&&e[0]===239&&e[1]===187&&e[2]===191)return new TextDecoder(`utf-8`).decode(e.subarray(3));if(e.byteLength>=2&&e[0]===255&&e[1]===254)return new TextDecoder(`utf-16le`).decode(e.subarray(2));if(e.byteLength>=2&&e[0]===254&&e[1]===255)return new TextDecoder(`utf-16be`).decode(e.subarray(2));if(n){let t=p(e);if(t&&t!==`utf-8`&&t!==`utf8`){let n=f(e,t);if(n!==null)return n}}try{return l.decode(e)}catch{let n=f(e,t);return n===null?u.decode(e):n}}var h={maxFileBytes:134217728,maxHeaderBytes:512,maxDirChunks:4096,maxEntries:2e4,maxSectionBytes:134217728,maxSystemBytes:4194304,maxTopicBytes:2097152,maxTopics:2e3,maxTocItems:1e4,maxResetEntries:65536,maxResetIntervalBytes:16777216,maxCachedIntervals:8};function g(e){let t=e.trim().replace(/\\/g,`/`);try{t=decodeURIComponent(t)}catch{}t=t.replace(/^\/+/,``);let n=[];for(let e of t.split(`/`))!e||e===`.`||(e===`..`?n.length>0&&n.pop():n.push(e));return`/`+n.join(`/`)}function _(e,t,n,r){let i=n.trim();if(!i||/^(?:javascript|vbscript|data|mailto|tel|https?|ftp):/i.test(i))return null;let a=i,o=/^(?:ms-its|its|mk:@MSITStore):([^:]*)::(.*)$/i.exec(a);if(o){let e=o[1].trim().replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase()??``;if(e&&(!r||!r.has(e)))return null;let t=o[2].trim();if(!t.startsWith(`/`))return null;a=t}else if(/^[a-z][\w+.-]*:/i.test(a))return null;let[s,c=``]=a.split(`#`,2),l=c;try{l=decodeURIComponent(c)}catch{}if(!s){let n=e.byExactPath.get(t)??e.byLowerPath.get(t.toLowerCase());return n?{entry:n,fragment:l}:null}let u=[];if(s.startsWith(`/`))u.push(g(s));else{let e=t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)+1):`/`;u.push(g(e+s)),u.push(g(`/`+s))}for(let t of u){let n=e.byExactPath.get(t)??e.byLowerPath.get(t.toLowerCase());if(n)return{entry:n,fragment:l}}return null}function v(e,t){let n=e.indexOf(0);return n<0&&(n=e.length),m(e.subarray(0,n),t).trim()}function y(e,t){let n=t,r=``,i=``,a=``,o=``,s=``;if(e.byteLength<4)return{title:r,compiledName:i,defaultTopic:a,hhcPath:o,hhkPath:s,encoding:n};let c=new DataView(e.buffer,e.byteOffset,e.byteLength),l=[],u=4;for(;u+4<=e.byteLength;){let t=c.getUint16(u,!0),r=c.getUint16(u+2,!0);if(u+=4,u+r>e.byteLength)break;let i=e.subarray(u,u+r);if(u+=r,t===4&&i.byteLength>=4){let e=new DataView(i.buffer,i.byteOffset,i.byteLength).getUint32(0,!0);e>0&&(n=d(e))}l.push({code:t,payload:i})}for(let{code:e,payload:t}of l)e===0&&!o?o=v(t,n):e===1&&!s?s=v(t,n):e===2&&!a?a=v(t,n):e===3&&!r?r=v(t,n):e===6&&!i&&(i=v(t,n));return{title:r,compiledName:i,defaultTopic:a,hhcPath:o,hhkPath:s,encoding:n}}function b(e,t,n){if(t<=0||t>=e.byteLength)return``;let r=t;for(;r<e.byteLength&&e[r]!==0;)r+=1;return m(e.subarray(t,r),n).trim()}function x(e,t,n){if(t<0||t+8>=e.byteLength)return``;let r=t+8;for(;r<e.byteLength&&e[r]!==0;)r+=1;return m(e.subarray(t+8,r),n).trim()}function S(e,t,n){let r=s(e),i=0;function a(e){let r=Array.from(e.children).find(e=>e.localName===`object`);if(!r||(r.getAttribute(`type`)??``).toLowerCase()!==`text/sitemap`)return null;let i=``,a=``;for(let e of Array.from(r.querySelectorAll(`param`))){let t=(e.getAttribute(`name`)??``).toLowerCase(),n=(e.getAttribute(`value`)??``).trim();t===`name`&&!i?i=n:(t===`local`||t===`url`)&&!a&&(a=n)}if(!i&&!a)return null;if(!a)return{label:i||`Section`,path:``,fragment:``};let o=_(t,n,a);return o?{label:i||o.entry.path.split(`/`).pop()||o.entry.path,path:o.entry.path,fragment:o.fragment}:{label:i||a,path:``,fragment:``}}function o(e,t){if(t>32||i>=h.maxTocItems)return[];let n=[];for(let r of Array.from(e.children)){if(i>=h.maxTocItems)break;if(r.localName===`li`){let e=a(r),s=Array.from(r.children).filter(e=>e.localName===`ul`).flatMap(e=>o(e,t+1));e?(i+=1,n.push({label:e.label,path:e.path,fragment:e.fragment,children:s})):s.length>0&&n.push(...s)}else if(r.localName===`ul`){let e=n[n.length-1],i=o(r,t+1);e&&i.length>0?n[n.length-1]={...e,children:[...e.children,...i]}:n.push(...i)}}return n}return{tree:Array.from(r.querySelectorAll(`ul`)).filter(e=>!e.parentElement||e.parentElement.localName!==`li`).filter(e=>{let t=e.parentElement;for(;t;){if(t.localName===`ul`)return!1;t=t.parentElement}return!0}).flatMap(e=>o(e,0)),flatCount:i}}function C(e,t=[]){for(let n of e){if(t.length>=h.maxTocItems)break;n.path&&t.push({label:n.label,path:n.path,fragment:n.fragment}),n.children.length>0&&C(n.children,t)}return t}async function w(e,t,n){let r=d(e.lcid),i={title:``,compiledName:``,defaultTopic:``,hhcPath:``,hhkPath:``,encoding:r},a=e.byLowerPath.get(`/#system`);a&&(i=y(await t.readEntry(a,h.maxSystemBytes,n),r));let o=i.encoding,s=(i.hhcPath?_(e,`/`,i.hhcPath)?.entry:null)??e.entries.find(e=>!e.path.startsWith(`::`)&&e.lowerPath.endsWith(`.hhc`))??null,c=(i.hhkPath?_(e,`/`,i.hhkPath)?.entry:null)??e.entries.find(e=>!e.path.startsWith(`::`)&&e.lowerPath.endsWith(`.hhk`))??null,l=[];s&&s.length>0&&(l=S(m(await t.readEntry(s,h.maxTopicBytes,n),o,!0),e,s.path).tree);let u=[];c&&c.length>0&&(u=C(S(m(await t.readEntry(c,h.maxTopicBytes,n),o,!0),e,c.path).tree));let f=[],p=e.byLowerPath.get(`/#topics`),g=e.byLowerPath.get(`/#strings`),v=e.byLowerPath.get(`/#urltbl`),w=e.byLowerPath.get(`/#urlstr`);if(p&&v&&w){let[r,i,a,s]=await Promise.all([t.readEntry(p,h.maxSystemBytes,n),g?t.readEntry(g,h.maxSystemBytes,n):Promise.resolve(new Uint8Array),t.readEntry(v,h.maxSystemBytes,n),t.readEntry(w,h.maxSystemBytes,n)]),c=new DataView(r.buffer,r.byteOffset,r.byteLength),l=new DataView(a.buffer,a.byteOffset,a.byteLength),u=Math.min(Math.floor(r.byteLength/16),h.maxTopics);for(let t=0;t<u;t+=1){let n=t*16,r=c.getInt32(n+4,!0),u=c.getUint32(n+8,!0);if(u+12>a.byteLength)continue;let d=x(s,l.getUint32(u+8,!0),o);if(!d)continue;let p=_(e,`/`,d);if(!p)continue;let m=r>=0?b(i,r,o):``;f.push({title:m,url:p.entry.path})}}let T=``;if(i.defaultTopic){let t=_(e,`/`,i.defaultTopic);t&&(T=t.entry.path)}return{title:i.title,compiledName:i.compiledName,encoding:o,defaultTopic:T,hhcPath:s?.path??``,hhkPath:c?.path??``,tocTree:l,indexEntries:u,systemTopics:f}}var T=new TextDecoder(`utf-8`,{fatal:!0});function E(e,n){let r=e.getUint32(n,!0),i=e.getUint32(n+4,!0);if(i>2097151)throw new t(`invalid-file`,`CHM 64-bit offset exceeds safe bounds.`);return i*2**32+r}function D(e,n,r){let i=0,a=0;for(;n.pos<r;){let r=e[n.pos++];if(a+=1,a>8)throw new t(`invalid-file`,`CHM encint exceeds 64-bit limit.`);if(i>4398046511103)throw new t(`invalid-file`,`CHM encint overflows safe integer.`);if(i=i*128+(r&127),!(r&128))return i}throw new t(`invalid-file`,`Truncated CHM encint.`)}async function O(e,n,r,i){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n<0||r<n||r>e.size)throw new t(`invalid-file`,`CHM slice offset out of range.`);let a=await e.slice(n,r).arrayBuffer();if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);return new Uint8Array(a)}function k(e,t,n){let r=``;for(let i=0;i<n;i+=1)r+=String.fromCharCode(e[t+i]);return r}function A(e,n,r,i){if(k(e,0,4)!==`PMGL`)throw new t(`invalid-file`,`Expected PMGL directory chunk.`);let a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=a.getUint32(4,!0),s=a.getInt32(16,!0);if(o<2||o>e.byteLength-20)throw new t(`invalid-file`,`Invalid PMGL free space.`);let c=e.byteLength-o,l={pos:20};for(;l.pos<c;){let a=D(e,l,c);if(a===0||l.pos+a>c)throw new t(`invalid-file`,`Invalid CHM entry name length.`);let o=e.subarray(l.pos,l.pos+a);l.pos+=a;let s;try{s=T.decode(o)}catch{throw new t(`invalid-file`,`Invalid UTF-8 in CHM entry path.`)}if(!s||s.includes(`\0`))throw new t(`invalid-file`,`Invalid CHM entry path.`);let u=D(e,l,c);if(u!==0&&u!==1)throw new t(`invalid-file`,`Unsupported CHM section number.`);let d=D(e,l,c),f=D(e,l,c);if(n.length>=h.maxEntries)throw new t(`resource-limit`,`CHM entry count limit exceeded.`);let p={path:s,lowerPath:s.toLowerCase(),section:u,offset:d,length:f};n.push(p),r.has(p.path)||r.set(p.path,p),i.has(p.lowerPath)||i.set(p.lowerPath,p)}return s}async function j(e,n){if(e.size>h.maxFileBytes)throw new t(`resource-limit`,`CHM file exceeds 128 MiB limit.`);if(e.size<172)throw new t(`invalid-file`,`File is too small to be a CHM archive.`);let r=await O(e,0,Math.min(e.size,96),n);if(k(r,0,4)!==`ITSF`)throw new t(`invalid-file`,`Missing ITSF signature.`);let i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=i.getUint32(4,!0),o=i.getUint32(8,!0);if(a===2){if(o<88||o>h.maxHeaderBytes)throw new t(`invalid-file`,`Invalid ITSF v2 header length.`)}else if(a===3){if(o<96||o>h.maxHeaderBytes||r.byteLength<96)throw new t(`invalid-file`,`Invalid ITSF v3 header length.`)}else throw new t(`invalid-file`,`Unsupported ITSF version.`);let s=i.getUint32(20,!0);E(i,56),E(i,64);let c=E(i,72),l=E(i,80);if(c<o||l<84||c+l>e.size)throw new t(`invalid-file`,`CHM directory bounds out of range.`);let u=a>=3?E(i,88):c+l;if(u<c+l||u>e.size)throw new t(`invalid-file`,`Invalid CHM content offset.`);let d=await O(e,c,c+84,n);if(k(d,0,4)!==`ITSP`)throw new t(`invalid-file`,`Missing ITSP directory header.`);let f=new DataView(d.buffer,d.byteOffset,d.byteLength),p=f.getUint32(4,!0),m=f.getUint32(8,!0),g=f.getUint32(16,!0),_=f.getInt32(32,!0),v=f.getInt32(36,!0),y=f.getUint32(44,!0),b=f.getUint32(48,!0);if(p!==1||m<84||m>h.maxHeaderBytes)throw new t(`invalid-file`,`Invalid ITSP header.`);if(g<64||g>65536)throw new t(`invalid-file`,`Unsupported CHM directory chunk size.`);if(y>h.maxDirChunks)throw new t(`resource-limit`,`CHM directory chunk count exceeds limit.`);let x=c+m;if(x+y*g>c+l)throw new t(`invalid-file`,`CHM directory chunks exceed directory bounds.`);let S=[],C=new Map,w=new Map;if(y>0&&_>=0){if(_>=y||v>=0&&v>=y)throw new t(`invalid-file`,`CHM PMGL chunk index out of range.`);let r=new Set,i=_;for(;i>=0;){if(i>=y||r.has(i))throw new t(`invalid-file`,`CHM directory chunk loop or invalid link.`);r.add(i);let a=x+i*g,o=A(await O(e,a,a+g,n),S,C,w);if(i===v){if(o>=0)throw new t(`invalid-file`,`CHM directory chunk loop or trailing link.`);break}i=o}}return{version:a,lcid:b||s,contentOffset:u,entries:S,byExactPath:C,byLowerPath:w}}var M=32768,N=16,P=12,F=20,I=249,L=8,R=[30,32,34,36,38,42,50],z=new Uint8Array(51),B=new Uint32Array(51);(()=>{let e=0;for(let t=0;t<51;t+=1){let n=t<4?0:t<36?(t>>1)-1:17;z[t]=n,B[t]=e,e+=1<<n}})();var V=class{constructor(e){this.data=e,this.pos=0,this.bitBuf=0,this.bitsLeft=0,this.eofPadded=!1}ensure(e){for(;this.bitsLeft<e;){if(this.pos>=this.data.length){if(this.eofPadded)throw new t(`invalid-file`,`Unexpected end of LZX compressed stream.`);this.eofPadded=!0,this.bitsLeft+=16;return}let e=this.data[this.pos++]|(this.pos<this.data.length?this.data[this.pos++]:0)<<8;this.bitBuf=(this.bitBuf|e<<16-this.bitsLeft)>>>0,this.bitsLeft+=16}}peek(e){return e===0?0:(this.ensure(e),this.bitBuf>>>32-e)}skip(e){if(this.eofPadded&&e>this.bitsLeft-16)throw new t(`invalid-file`,`Unexpected end of LZX compressed stream.`);this.bitBuf=e>=32?0:this.bitBuf<<e>>>0,this.bitsLeft-=e}readBits(e){if(e===0)return 0;if(e<=16){let t=this.peek(e);return this.skip(e),t}let t=this.readBits(16),n=this.readBits(e-16);return(t<<e-16|n)>>>0}alignForUncompressed(){return this.bitsLeft===0&&this.ensure(16),this.bitsLeft=0,this.bitBuf=0,{r0:this.readRawUint32(),r1:this.readRawUint32(),r2:this.readRawUint32()}}readRawBytes(e,n,r){if(this.pos+r>this.data.length)throw new t(`invalid-file`,`Truncated LZX uncompressed block.`);e.set(this.data.subarray(this.pos,this.pos+r),n),this.pos+=r}skipPadByte(){this.pos<this.data.length&&(this.pos+=1)}readRawUint32(){if(this.pos+4>this.data.length)throw new t(`invalid-file`,`Truncated LZX uncompressed block header.`);let e=(this.data[this.pos]|this.data[this.pos+1]<<8|this.data[this.pos+2]<<16|this.data[this.pos+3]<<24)>>>0;return this.pos+=4,e}};function H(e,n){let r=e.length,i=new Int32Array(4096).fill(-1),a=new Int32Array(r*2+16).fill(-1),o=new Int32Array(r*2+16).fill(-1),s=0,c=0;for(let n=0;n<r;n+=1){let r=e[n];if(r>N)throw new t(`invalid-file`,`Invalid LZX Huffman code length.`);r>0&&(s+=1,r>c&&(c=r))}if(s===0){if(!n)throw new t(`invalid-file`,`Empty LZX Huffman table.`);return{empty:!0,maxBits:0,table:i,left:a,right:o}}let l=0,u=r;for(let n=1;n<=c;n+=1){for(let s=0;s<r;s+=1)if(e[s]===n){if(l>=1<<n)throw new t(`invalid-file`,`Oversubscribed LZX Huffman table.`);if(n<=P){let e=P-n,t=l<<e,r=l+1<<e;i.fill(s,t,r)}else{let e=l>>>n-P,t=i[e];t===-1&&(t=u++,i[e]=t);let r=n-P;for(let e=r-1;e>=0;--e){let n=l>>>e&1;if(e===0)n?o[t]=s:a[t]=s;else{let e=n?o[t]:a[t];e===-1&&(e=u++,n?o[t]=e:a[t]=e),t=e}}}l+=1}l<<=1}return{empty:!1,maxBits:c,table:i,left:a,right:o}}function U(e,n,r,i){if(n.empty)throw new t(`invalid-file`,`Attempted decode from empty LZX Huffman table.`);let a=e.peek(P),o=n.table[a];if(o<0)throw new t(`invalid-file`,`Invalid LZX Huffman prefix.`);if(o<i)return e.skip(r[o]),o;e.skip(P);let s=o;for(let r=0;r<5;r+=1){if(s=e.readBits(1)?n.right[s]:n.left[s],s<0)throw new t(`invalid-file`,`Invalid LZX Huffman tree path.`);if(s<i)return s}throw new t(`invalid-file`,`LZX Huffman code exceeded max length.`)}function W(e,t,n,r){let i=new Uint8Array(F);for(let t=0;t<F;t+=1)i[t]=e.readBits(4);let a=H(i,!1),o=n;for(;o<r;){let n=U(e,a,i,F);if(n===17){let n=e.readBits(4)+4,i=Math.min(r,o+n);for(;o<i;)t[o++]=0}else if(n===18){let n=e.readBits(5)+20,i=Math.min(r,o+n);for(;o<i;)t[o++]=0}else if(n===19){let n=e.readBits(1)+4,s=U(e,a,i,F),c=(t[o]-s+17)%17,l=Math.min(r,o+n);for(;o<l;)t[o++]=c}else t[o]=(t[o]-n+17)%17,o+=1}}function G(e,n,r,i){if(r>h.maxResetIntervalBytes&&r>h.maxSectionBytes)throw new t(`resource-limit`,`LZX decompression request exceeds budget.`);if(r===0)return new Uint8Array;let a=new V(e),o=new Uint8Array(n.windowSize),s=n.windowSize-1,c=Math.ceil(r/M)*M,l=new Uint8Array(c),u=256+(R[n.windowBits-15]<<3),d=new Uint8Array(u),f=new Uint8Array(I),p=new Uint8Array(L),m=null,g=null,_=null,v=1,y=1,b=1,x=!1,S=0,C=!1,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=()=>{v=1,y=1,b=1,x=!1,E=0,w=0,d.fill(0),f.fill(0),m=null,g=null,_=null};for(;A<r;){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);n.resetFrames>0&&k>0&&k%n.resetFrames===0&&j(),x||=(S=a.readBits(1)?a.readBits(16)<<16|a.readBits(16):0,!0);let e=M,c=e;for(;c>0;){if(E===0){if(A+(e-c)>=r){let t=e-c;return t>0&&l.set(o.subarray(O,O+t),A),l.subarray(0,r)}if(w===3&&T&1&&a.skipPadByte(),w=a.readBits(3),T=a.readBits(16)<<8|a.readBits(8),E=T,w===2){for(let e=0;e<8;e+=1)p[e]=a.readBits(3);_=H(p,!1)}if(w===1||w===2)W(a,d,0,256),W(a,d,256,u),m=H(d,!1),d[232]!==0&&(C=!0),W(a,f,0,I),g=H(f,!0);else if(w===3){C=!0;let e=a.alignForUncompressed();v=e.r0,y=e.r1,b=e.r2}else throw new t(`invalid-file`,`Invalid LZX block type.`)}let i=Math.min(E,c);if(i<=0)throw new t(`invalid-file`,`Zero-length LZX block.`);if(w===3)a.readRawBytes(o,D,i),D+=i,E-=i,c-=i;else{let e=i;for(;e>0;){let r=U(a,m,d,u);if(r<256)o[D++]=r,--e,--E,--c;else{let i=r-256,l=i&7;l===7&&(l+=U(a,g,f,I)),l+=2;let u=i>>3,d;if(u===0)d=v;else if(u===1)d=y,y=v,v=d;else if(u===2)d=b,b=v,v=d;else{let e=z[u],t=B[u]-2;if(w===2&&e>=3){let n=a.readBits(e-3)<<3,r=U(a,_,p,L);d=t+n+r}else d=t+a.readBits(e);b=y,y=v,v=d}if(d<=0||d>n.windowSize)throw new t(`invalid-file`,`LZX match offset out of window.`);if(l>e)throw new t(`invalid-file`,`LZX match crosses block or frame boundary.`);let m=D-d&s;for(let e=0;e<l;e+=1)o[D++]=o[m],m=m+1&s;e-=l,E-=l,c-=l}}}}let h=o.subarray(O,O+e);if(l.set(h,A),C&&S>0&&k<32768){let t=A,n=A+e-10,r=A;for(;r<n;){if(l[r++]!==232){t+=1;continue}let e=l[r]|l[r+1]<<8|l[r+2]<<16|l[r+3]<<24;if(e>=-t&&e<S){let n=e>=0?e-t:e+S;l[r]=n&255,l[r+1]=n>>>8&255,l[r+2]=n>>>16&255,l[r+3]=n>>>24&255}r+=4,t+=5}}A+=e,O+=e,k+=1,D===n.windowSize&&(D=0),O===n.windowSize&&(O=0)}return l.subarray(0,r)}function K(e,n){let r=e.getUint32(n,!0),i=e.getUint32(n+4,!0);if(i>2097151)throw new t(`invalid-file`,`CHM ResetTable 64-bit integer out of range.`);return i*2**32+r}function q(e){if(e.byteLength<28)throw new t(`invalid-file`,`CHM ControlData is truncated.`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e[4]!==76||e[5]!==90||e[6]!==88||e[7]!==67)throw new t(`invalid-file`,`Invalid CHM LZXC signature.`);let r=n.getUint32(8,!0),i=n.getUint32(12,!0),a=n.getUint32(16,!0);if(r===2)i*=M,a*=M;else if(r!==1)throw new t(`invalid-file`,`Unsupported LZXC ControlData version.`);let o=0;for(let e=15;e<=21;e+=1)if(a===1<<e){o=e;break}if(!o)throw new t(`invalid-file`,`Unsupported LZX window size.`);if(i===0||i%32768!=0)throw new t(`invalid-file`,`Invalid LZX reset interval.`);if(i>h.maxResetIntervalBytes)throw new t(`resource-limit`,`LZX reset interval exceeds budget.`);return{windowBits:o,windowSize:a,resetInterval:i,resetFrames:i/M}}function ee(e,n){if(e.byteLength<40)throw new t(`invalid-file`,`CHM ResetTable is truncated.`);let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=r.getUint32(0,!0),a=r.getUint32(4,!0),o=r.getUint32(8,!0),s=r.getUint32(12,!0),c=K(r,16),l=K(r,24),u=K(r,32);if(i!==2||o!==4&&o!==8||s<40)throw new t(`invalid-file`,`Invalid CHM ResetTable header.`);if(a>h.maxResetEntries)throw new t(`resource-limit`,`CHM ResetTable entry count exceeds budget.`);if(c>h.maxSectionBytes)throw new t(`resource-limit`,`CHM uncompressed section exceeds 128 MiB limit.`);if(l>n)throw new t(`invalid-file`,`CHM ResetTable compressed length exceeds content stream.`);if(s+a*o>e.byteLength)throw new t(`invalid-file`,`CHM ResetTable entries exceed table bounds.`);let d=[],f=0;for(let e=0;e<a;e+=1){let i=s+e*o,a=o===8?K(r,i):r.getUint32(i,!0);if(a<f||a>n)throw new t(`invalid-file`,`Invalid CHM ResetTable entry offset.`);d.push(a),f=a}return{uncompressedLength:c,compressedLength:l,frameLength:u||32768,offsets:d}}async function J(e,n,r,i){if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n<0||r<n||r>e.size)throw new t(`invalid-file`,`CHM file slice out of bounds.`);let a=await e.slice(n,r).arrayBuffer();if(i.aborted)throw new DOMException(`Aborted`,`AbortError`);return new Uint8Array(a)}function te(e,n){let r=null,i=new Map;async function a(r,i,a){if(r.length>i)throw new t(`resource-limit`,`CHM entry exceeds read budget.`);if(r.length===0)return new Uint8Array;let o=n.contentOffset+r.offset;return J(e,o,o+r.length,a)}async function o(e){if(r)return r;r=(async()=>{let r=n.byLowerPath.get(`::dataspace/storage/mscompressed/content`),i=n.byLowerPath.get(`::dataspace/storage/mscompressed/controldata`);if(!r||!i||r.section!==0||i.section!==0)throw new t(`invalid-file`,`Missing CHM MSCompressed stream metadata.`);let o=q(await a(i,1024,e)),s=n.byLowerPath.get(`::dataspace/storage/mscompressed/transform/{7fc28940-9d31-11d0-9b27-00a0c91e9c7c}/instancedata/resettable`),c=null,l=0;if(s&&s.section===0)c=ee(await a(s,2097152,e),r.length),l=c.uncompressedLength;else{let r=n.byLowerPath.get(`::dataspace/storage/mscompressed/spaninfo`);if(!r||r.section!==0||r.length<8)throw new t(`invalid-file`,`Missing CHM ResetTable and SpanInfo.`);let i=await a(r,64,e);l=K(new DataView(i.buffer,i.byteOffset,i.byteLength),0)}if(l>h.maxSectionBytes)throw new t(`resource-limit`,`CHM compressed section exceeds 128 MiB limit.`);return{contentEntry:r,control:o,resetTable:c,totalUncompressed:l}})();try{return await r}catch(e){throw r=null,e}}async function s(r,a){let s=i.get(r);if(s)return i.delete(r),i.set(r,s),s;let{contentEntry:c,control:l,resetTable:u,totalUncompressed:d}=await o(a),f=n.contentOffset+c.offset,p;if(u&&u.offsets.length>0){let n=r*l.resetFrames;if(n>=u.offsets.length)throw new t(`invalid-file`,`CHM ResetTable frame index out of range.`);let i=u.offsets[n],o=n+l.resetFrames,s=o<u.offsets.length?u.offsets[o]:u.compressedLength||c.length,m=n*M,h=Math.min(l.resetInterval,d-m);if(h<=0)throw new t(`invalid-file`,`CHM ResetTable interval is empty.`);p=G(await J(e,f+i,f+s,a),l,h,a)}else{if(r!==0)throw new t(`invalid-file`,`CHM missing ResetTable for seek.`);if(d>h.maxResetIntervalBytes)throw new t(`resource-limit`,`CHM unseekable compressed stream exceeds budget.`);p=G(await J(e,f,f+c.length,a),l,d,a)}if(i.size>=h.maxCachedIntervals){let e=i.keys().next().value;e!==void 0&&i.delete(e)}return i.set(r,p),p}return{async readEntry(e,n,r){if(e.length>n)throw new t(`resource-limit`,`CHM entry exceeds read budget.`);if(e.length===0)return new Uint8Array;if(e.section===0)return a(e,n,r);let i=await o(r);if(e.offset+e.length>i.totalUncompressed)throw new t(`invalid-file`,`CHM entry offset exceeds uncompressed section.`);let c=i.resetTable?i.control.resetInterval:i.totalUncompressed,l=Math.floor(e.offset/c),u=Math.floor((e.offset+e.length-1)/c);if(l===u){let t=await s(l,r),n=e.offset-l*c;return t.slice(n,n+e.length)}let d=new Uint8Array(e.length),f=0;for(let t=l;t<=u;t+=1){let n=await s(t,r),i=t*c,a=Math.max(0,e.offset-i),o=Math.min(n.length,e.offset+e.length-i);d.set(n.subarray(a,o),f),f+=o-a}return d},dispose(){i.clear()}}}var ne={protocolVersion:2,id:`chm-reader`,name:{en:`CHM help reader`,"zh-CN":`CHM 帮助文档阅读器`},formats:[{name:{en:`Compiled HTML Help`,"zh-CN":`CHM 编译 HTML 帮助文档`},extensions:[`.chm`],mimeTypes:[`application/vnd.ms-htmlhelp`]}],workspaceAccess:`none`};function Y(t){return{...i(t),...e(t,{en:{invalid:`The CHM help file is damaged or uses an unsupported layout.`,limit:`This CHM help file exceeds the safe reading resource limits.`,noTopics:`No readable HTML topics were found in this CHM archive.`,unsupportedObject:`Unsupported embedded object`},"zh-CN":{invalid:`CHM 帮助文件已损坏或使用了不支持的格式结构。`,limit:`此 CHM 帮助文件超过安全阅读资源上限。`,noTopics:`在此 CHM 归档中未找到可阅读的 HTML 主题。`,unsupportedObject:`不支持的嵌入对象`}})}}var re={".html":`text/html`,".htm":`text/html`,".xhtml":`text/html`,".css":`text/css`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".svg":`image/svg+xml`,".bmp":`image/bmp`,".ico":`image/x-icon`,".woff":`font/woff`,".woff2":`font/woff2`,".ttf":`font/ttf`,".otf":`font/otf`};function X(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:re[e.slice(t)]??`application/octet-stream`}function Z(e){return e.path.startsWith(`::`)||e.path.startsWith(`/#`)||e.path.startsWith(`/$`)?!1:e.lowerPath.endsWith(`.html`)||e.lowerPath.endsWith(`.htm`)||e.lowerPath.endsWith(`.xhtml`)}function Q(e){return e.replace(/^\/+/,``)}function $(e,t){let n=e.split(`/`).slice(0,-1),r=t.split(`/`),i=0;for(;i<n.length&&i<r.length-1&&n[i]===r[i];)i+=1;let a=Array.from({length:n.length-i},()=>`..`),o=r.slice(i);return[...a,...o].map(e=>e===`..`?e:encodeURIComponent(e)).join(`/`)}function ie(e,t,n,r,i,a){let o=document.createElement(`template`);o.innerHTML=e;let s=Q(t);for(let e of Array.from(o.content.querySelectorAll(`object, embed, applet`))){let t=o.content.ownerDocument.createElement(`span`);t.textContent=`[${i}]`,e.replaceWith(t)}for(let e of Array.from(o.content.querySelectorAll(`a[href]`))){let i=_(n,t,e.getAttribute(`href`)??``,r);if(i&&Z(i.entry)){let t=$(s,Q(i.entry.path)),n=i.fragment?`#${encodeURIComponent(i.fragment)}`:``;e.setAttribute(`href`,`${t}${n}`)}else e.removeAttribute(`href`)}for(let e of Array.from(o.content.querySelectorAll(`img[src]`))){let i=e.getAttribute(`src`)??``;if(/^(?:https?:|ftp:|javascript:|vbscript:)/i.test(i.trim())){e.removeAttribute(`src`);continue}let o=_(n,t,i,r);if(o)e.setAttribute(`src`,$(s,Q(o.entry.path)));else{let n=i.trim();if(n&&!/^[a-z][\w+.-]*:/i.test(n)){let r=t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)+1):`/`,i=Q(g(n.startsWith(`/`)?n:r+n)),o=X(i.toLowerCase());o.startsWith(`image/`)&&!a.has(i)&&a.set(i,{id:i,path:i,type:o,properties:[]}),e.setAttribute(`src`,$(s,i))}else e.removeAttribute(`src`)}}for(let e of Array.from(o.content.querySelectorAll(`link[href]`))){if((e.getAttribute(`rel`)??``).toLowerCase()!==`stylesheet`){e.removeAttribute(`href`);continue}let i=_(n,t,e.getAttribute(`href`)??``,r);i?e.setAttribute(`href`,$(s,Q(i.entry.path))):e.removeAttribute(`href`)}return new TextEncoder().encode(o.innerHTML)}function ae(e,n,r,i,a){let s=Y(a),c=new Set,l=e.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase();if(l&&c.add(l),r.compiledName){let e=r.compiledName.replace(/\\/g,`/`).split(`/`).pop()?.toLowerCase();e&&(c.add(e),e.endsWith(`.chm`)||c.add(`${e}.chm`))}let u=new Map,d=new Map,f=new Map;for(let e of n.entries){if(e.path.startsWith(`::`)||e.path.endsWith(`/`))continue;let t=Q(e.path);!t||u.has(t)||(u.set(t,e),d.set(t,{filename:t,directory:!1,uncompressedSize:e.length}),f.set(t,{id:t,path:t,type:X(e.lowerPath),properties:[]}))}let p=[],g=new Set,_=e=>{if(!e||p.length>=h.maxTopics)return;let t=Q(e),n=u.get(t);!n||!Z(n)||g.has(t)||(g.add(t),p.push(t))};r.defaultTopic&&_(r.defaultTopic);let v=e=>{for(let t of e)t.path&&_(t.path),t.children.length>0&&v(t.children)};v(r.tocTree);for(let e of r.indexEntries)_(e.path);for(let e of r.systemTopics)_(e.url);for(let e of n.entries)Z(e)&&_(e.path);if(p.length===0)throw new t(`invalid-file`,s.noTopics);let y=p.map(e=>f.get(e)),b=[],x=(e,t)=>{for(let n of e){let e=n.path?Q(n.path):``;if(e&&g.has(e)){let r=t>0?`${`— `.repeat(Math.min(t,4))}`:``;b.push({label:`${r}${n.label}`,path:e,fragment:n.fragment})}n.children.length>0&&x(n.children,t+1)}};if(x(r.tocTree,0),b.length===0){let e=new Map;for(let t of r.systemTopics)t.title&&e.set(Q(t.url),t.title);for(let t of p)b.push({label:e.get(t)||t.split(`/`).pop()||t,path:t,fragment:``})}let S=e=>e.map(e=>{let t=e.path?Q(e.path):``,n=t&&g.has(t)?t:``,r=S(e.children);return!n&&r.length===0?null:{label:e.label,path:n,fragment:e.fragment,children:r}}).filter(e=>e!==null),C=S(r.tocTree),w=r.indexEntries.map(e=>({label:e.label,path:Q(e.path),fragment:e.fragment})).filter(e=>g.has(e.path)),T={entries:d,async read(e,a,o=new AbortController().signal){let l=u.get(e);if(!l)throw new t(`missing-related-file`,s.missing);let d=await i.readEntry(l,a,o),p=X(l.lowerPath);if(p===`text/html`)return ie(m(d,r.encoding,!0),l.path,n,c,s.unsupportedObject,f);if(p===`text/css`){let e=m(d,r.encoding,!1);return new TextEncoder().encode(e)}return d},async dispose(){i.dispose()}},E={title:r.title||e,author:``,direction:`ltr`,items:f,spine:y,toc:b};return{title:E.title,author:E.author,spine:y,toc:b,tocTree:C.length>0?C:void 0,index:w.length>0?w:void 0,loadSection:(e,t)=>o(T,E,e,t)}}var oe={manifest:ne,async open(e){let i=Y(e.locale),a=document.createElement(`div`);a.className=`anyfile-chm-reader`;let o=new AbortController,s,c,l=!1,u=()=>{l||(l=!0,o.abort(),e.signal.removeEventListener(`abort`,u),c?.dispose(),s?.dispose(),a.remove())};try{if(e.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(typeof ResizeObserver>`u`||typeof DOMParser>`u`||typeof CSSStyleSheet>`u`)throw new t(`unsupported-environment`,i.environment);e.signal.addEventListener(`abort`,u,{once:!0}),e.reportProgress({stage:`parsing`,message:i.loading});let n=await j(e.file,o.signal);s=te(e.file,n);let l=await w(n,s,o.signal),d=ae(e.file.name,n,l,s,e.locale);if(o.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);return e.container.append(a),c=r(a,d,e.locale,i),{dispose:u}}catch(e){if(u(),n(e))throw e;let r=e instanceof t?e.code:`invalid-file`;throw new t(r,r===`resource-limit`?i.limit:r===`missing-related-file`?i.missing:r===`unsupported-environment`?i.environment:i.invalid,{cause:e})}}};export{oe as chmViewer};
@@ -1 +1 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t}from"./index-BCxD9rBl.js";import{i as n,n as r,r as i,t as a}from"./probe-asf-CvcaYQaR.js";var o=new Set([`FMP4`,`XVID`,`DIVX`,`DX50`,`MP4V`]);async function s({file:e,signal:t}){try{let n=new r(e,t),a=await n.read(0,12);if(i(a)!==`RIFF`||i(a,8)!==`AVI `||a.getUint32(4,!0)+8!==e.size)return null;let s,c,l,u=0,d=!1,f=!1;async function p(e,t,r){let a,m;for(let o=e;o<t;){let e=await n.read(o,8),c=i(e),l=e.getUint32(4,!0),u=o+8+l;if(u+(l&1)>t)throw Error(`RIFF bounds`);if(c===`LIST`){if(l<4)throw Error(`LIST bounds`);let e=i(await n.read(o+8,4));if(e===`hdrl`&&r===`root`)await p(o+12,u,`hdrl`);else if(e===`strl`&&r===`hdrl`)await p(o+12,u,`strl`);else if(e===`movi`&&r===`root`){if(d||l<12)throw Error(`movi`);d=!0}}else if(c===`avih`&&r===`hdrl`){if(s||l<56)throw Error(`avih`);s=await n.read(o+8,56)}else if(c===`strh`&&r===`strl`){if(a||l<56)throw Error(`strh`);a=await n.read(o+8,56)}else if(c===`strf`&&r===`strl`){if(m||l<16)throw Error(`strf`);m=await n.read(o+8,Math.min(l,40))}else if(c===`idx1`&&r===`root`){if(f||l<16||l%16)throw Error(`idx1`);let e=await n.read(o+8,16),t=await n.read(u-16,16);if(!e.getUint32(12,!0)||!t.getUint32(12,!0))throw Error(`Empty index`);f=!0}o=u+(l&1)}if(r===`strl`){if(!a||!m||!a.getUint32(20,!0)||!a.getUint32(24,!0)||!a.getUint32(32,!0)||a.getUint32(28,!0))throw Error(`Stream timing`);if(u++,i(a)===`vids`){if(c||!o.has(i(a,4).toUpperCase())||m.byteLength<40||!o.has(i(m,16).toUpperCase()))throw Error(`Video codec`);c=m}else if(i(a)===`auds`){if(l||m.getUint16(0,!0)!==85)throw Error(`Audio codec`);l=m}else throw Error(`Unsupported stream`)}}if(await p(12,e.size,`root`),!s||!c||!d||!f||!(s.getUint32(12,!0)&16)||s.getUint32(24,!0)!==u)return null;let m=c.getInt32(4,!0),h=c.getInt32(8,!0),g=l?.getUint16(2,!0)??0,_=l?.getUint32(4,!0)??0;return m<=0||h<=0||m*h>2073600||c.getUint16(12,!0)!==1||l&&(![1,2].includes(g)||_<8e3||_>96e3)?null:{width:m,height:h,audio:!!l,channels:g,sampleRate:_}}catch(e){if(t.throwIfAborted(),e instanceof DOMException&&e.name===`AbortError`)throw e;return null}}var c=131072,l=4096,u=[44100,48e3,32e3],d=[48e3,44100,32e3],f=new Set([187,188,190,191]);function p(e,t,n){for(let r=t;r+4<=n&&r<t+l;r++){if(e[r]!==255||(e[r+1]&254)!=252)continue;let t=e[r+2]>>2&3;if(e[r+2]>>4!=15&&t!==3)return{audioCodec:`mp2`,channels:e[r+3]>>6==3?1:2,sampleRate:u[t]}}return null}function m(e,t,n){for(let r=t;r+8<=n&&r<t+l;r++){if(e[r]!==11||e[r+1]!==119)continue;let t=e[r+4]>>6,n=e[r+6]>>5;if(!(t===3||(e[r+4]&63)>37||e[r+5]>>3>10||n>2))return{audioCodec:`ac3`,channels:n===1?1:2,sampleRate:d[t]}}return null}function h(e,t,n){let r=Math.min(n,t+l);for(let n=t;n+8<=r;n++){if(e[n]||e[n+1]||e[n+2]!==1||e[n+3]!==179)continue;let t=e[n+4]<<4|e[n+5]>>4,i=(e[n+5]&15)<<8|e[n+6];if(!t||!i||t*i>2073600)return null;for(let a=n+8;a+5<=r&&a<n+260;a++)if(!(e[a]||e[a+1]||e[a+2]!==1)){if(e[a+3]===181&&(e[a+4]&240)==16)return{width:t,height:i};if(e[a+3]===0)break}return null}return null}async function g({file:e,signal:t}){try{let n=Math.min(e.size,c);if(n<64)return null;let i=await new r(e,t).read(0,n),a=new Uint8Array(i.buffer,i.byteOffset,n),o=e=>e+4<=n&&!a[e]&&!a[e+1]&&a[e+2]===1;if(!o(0)||a[3]!==186)return null;let s=null,l=null,u=-1,d=-1;for(let e=0,t=0;e+4<=n;t++){if(t>=256||!o(e))return null;let r=a[e+3];if(r===185)break;if(r===186){if((a[e+4]&192)==64)e+=14;else if((a[e+4]&240)==32)for(e+=12;e<n&&a[e]===255;)e++;else return null;continue}let c=i.getUint16(e+4);if(f.has(r)){if(e+6+c>n)return null;e+=6+c;continue}if(!c)return null;let g=e+6,_=Math.min(g+c,n);if(r>=224&&r<=239){if(u>=0&&u!==r)return null;u=r,s??=h(a,g,_)}else if(r>=192&&r<=223){if(d>=0&&d!==r)return null;d=r,l??=p(a,g,_)}else if(r===189){let e=m(a,g,_);if(e){if(d>=0&&d!==r)return null;d=r,l??=e}}else return null;if(g+c>n)break;e=g+c}return s?{...s,audioCodec:l?.audioCodec??null,channels:l?.channels??0,sampleRate:l?.sampleRate??0}:null}catch(e){if(t.throwIfAborted(),e instanceof DOMException&&e.name===`AbortError`)throw e;return null}}async function _(e){let t=await s(e);if(t)return{container:`avi`,videoCodec:`mpeg4`,audioCodec:t.audio?`mp3`:``,...t};let n=await a(e);if(n?.video&&(!n.audio||n.audio.codec===`wmav2`))return{container:`asf`,videoCodec:n.video.codec,width:n.video.width,height:n.video.height,audio:!!n.audio,audioCodec:n.audio?`wmav2`:``,channels:n.audio?.channels??0,sampleRate:n.audio?.sampleRate??0};let r=await g(e);return r?{container:`mpeg-ps`,videoCodec:`mpeg2video`,width:r.width,height:r.height,audio:!!r.audioCodec,audioCodec:r.audioCodec??``,channels:r.channels,sampleRate:r.sampleRate}:null}var v={manifest:{protocolVersion:2,id:`ffmpeg-video`,name:{en:`FFmpeg video viewer`,"zh-CN":`FFmpeg 视频查看器`},formats:[{name:{en:`AVI MPEG-4 video`,"zh-CN":`AVI MPEG-4 视频`},extensions:[`.avi`]},{name:{en:`ASF / Windows Media video`,"zh-CN":`ASF / Windows Media 视频`},extensions:[`.wmv`,`.asf`],mimeTypes:[`video/x-ms-wmv`,`video/x-ms-asf`]},{name:{en:`MPEG program stream video`,"zh-CN":`MPEG 节目流视频`},extensions:[`.mpg`,`.mpeg`,`.vob`],mimeTypes:[`video/mpeg`]}],workspaceAccess:`none`},async open(r){let i=await _(r);if(!i)throw new t(`invalid-file`,e(r.locale,{en:`Unsupported video.`,"zh-CN":`不支持此视频。`}));return n(r,!0,e=>e.video&&e.videoCodec===i.videoCodec&&e.width===i.width&&e.height===i.height&&e.audio===i.audio&&(!e.audio||e.audioCodec===i.audioCodec&&e.channels===i.channels&&e.sampleRate===i.sampleRate))}};export{v as ffmpegVideoViewer};
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t}from"./index-DtiyOy_J.js";import{i as n,n as r,r as i,t as a}from"./probe-asf-C_UpCBly.js";var o=new Set([`FMP4`,`XVID`,`DIVX`,`DX50`,`MP4V`]);async function s({file:e,signal:t}){try{let n=new r(e,t),a=await n.read(0,12);if(i(a)!==`RIFF`||i(a,8)!==`AVI `||a.getUint32(4,!0)+8!==e.size)return null;let s,c,l,u=0,d=!1,f=!1;async function p(e,t,r){let a,m;for(let o=e;o<t;){let e=await n.read(o,8),c=i(e),l=e.getUint32(4,!0),u=o+8+l;if(u+(l&1)>t)throw Error(`RIFF bounds`);if(c===`LIST`){if(l<4)throw Error(`LIST bounds`);let e=i(await n.read(o+8,4));if(e===`hdrl`&&r===`root`)await p(o+12,u,`hdrl`);else if(e===`strl`&&r===`hdrl`)await p(o+12,u,`strl`);else if(e===`movi`&&r===`root`){if(d||l<12)throw Error(`movi`);d=!0}}else if(c===`avih`&&r===`hdrl`){if(s||l<56)throw Error(`avih`);s=await n.read(o+8,56)}else if(c===`strh`&&r===`strl`){if(a||l<56)throw Error(`strh`);a=await n.read(o+8,56)}else if(c===`strf`&&r===`strl`){if(m||l<16)throw Error(`strf`);m=await n.read(o+8,Math.min(l,40))}else if(c===`idx1`&&r===`root`){if(f||l<16||l%16)throw Error(`idx1`);let e=await n.read(o+8,16),t=await n.read(u-16,16);if(!e.getUint32(12,!0)||!t.getUint32(12,!0))throw Error(`Empty index`);f=!0}o=u+(l&1)}if(r===`strl`){if(!a||!m||!a.getUint32(20,!0)||!a.getUint32(24,!0)||!a.getUint32(32,!0)||a.getUint32(28,!0))throw Error(`Stream timing`);if(u++,i(a)===`vids`){if(c||!o.has(i(a,4).toUpperCase())||m.byteLength<40||!o.has(i(m,16).toUpperCase()))throw Error(`Video codec`);c=m}else if(i(a)===`auds`){if(l||m.getUint16(0,!0)!==85)throw Error(`Audio codec`);l=m}else throw Error(`Unsupported stream`)}}if(await p(12,e.size,`root`),!s||!c||!d||!f||!(s.getUint32(12,!0)&16)||s.getUint32(24,!0)!==u)return null;let m=c.getInt32(4,!0),h=c.getInt32(8,!0),g=l?.getUint16(2,!0)??0,_=l?.getUint32(4,!0)??0;return m<=0||h<=0||m*h>2073600||c.getUint16(12,!0)!==1||l&&(![1,2].includes(g)||_<8e3||_>96e3)?null:{width:m,height:h,audio:!!l,channels:g,sampleRate:_}}catch(e){if(t.throwIfAborted(),e instanceof DOMException&&e.name===`AbortError`)throw e;return null}}var c=131072,l=4096,u=[44100,48e3,32e3],d=[48e3,44100,32e3],f=new Set([187,188,190,191]);function p(e,t,n){for(let r=t;r+4<=n&&r<t+l;r++){if(e[r]!==255||(e[r+1]&254)!=252)continue;let t=e[r+2]>>2&3;if(e[r+2]>>4!=15&&t!==3)return{audioCodec:`mp2`,channels:e[r+3]>>6==3?1:2,sampleRate:u[t]}}return null}function m(e,t,n){for(let r=t;r+8<=n&&r<t+l;r++){if(e[r]!==11||e[r+1]!==119)continue;let t=e[r+4]>>6,n=e[r+6]>>5;if(!(t===3||(e[r+4]&63)>37||e[r+5]>>3>10||n>2))return{audioCodec:`ac3`,channels:n===1?1:2,sampleRate:d[t]}}return null}function h(e,t,n){let r=Math.min(n,t+l);for(let n=t;n+8<=r;n++){if(e[n]||e[n+1]||e[n+2]!==1||e[n+3]!==179)continue;let t=e[n+4]<<4|e[n+5]>>4,i=(e[n+5]&15)<<8|e[n+6];if(!t||!i||t*i>2073600)return null;for(let a=n+8;a+5<=r&&a<n+260;a++)if(!(e[a]||e[a+1]||e[a+2]!==1)){if(e[a+3]===181&&(e[a+4]&240)==16)return{width:t,height:i};if(e[a+3]===0)break}return null}return null}async function g({file:e,signal:t}){try{let n=Math.min(e.size,c);if(n<64)return null;let i=await new r(e,t).read(0,n),a=new Uint8Array(i.buffer,i.byteOffset,n),o=e=>e+4<=n&&!a[e]&&!a[e+1]&&a[e+2]===1;if(!o(0)||a[3]!==186)return null;let s=null,l=null,u=-1,d=-1;for(let e=0,t=0;e+4<=n;t++){if(t>=256||!o(e))return null;let r=a[e+3];if(r===185)break;if(r===186){if((a[e+4]&192)==64)e+=14;else if((a[e+4]&240)==32)for(e+=12;e<n&&a[e]===255;)e++;else return null;continue}let c=i.getUint16(e+4);if(f.has(r)){if(e+6+c>n)return null;e+=6+c;continue}if(!c)return null;let g=e+6,_=Math.min(g+c,n);if(r>=224&&r<=239){if(u>=0&&u!==r)return null;u=r,s??=h(a,g,_)}else if(r>=192&&r<=223){if(d>=0&&d!==r)return null;d=r,l??=p(a,g,_)}else if(r===189){let e=m(a,g,_);if(e){if(d>=0&&d!==r)return null;d=r,l??=e}}else return null;if(g+c>n)break;e=g+c}return s?{...s,audioCodec:l?.audioCodec??null,channels:l?.channels??0,sampleRate:l?.sampleRate??0}:null}catch(e){if(t.throwIfAborted(),e instanceof DOMException&&e.name===`AbortError`)throw e;return null}}async function _(e){let t=await s(e);if(t)return{container:`avi`,videoCodec:`mpeg4`,audioCodec:t.audio?`mp3`:``,...t};let n=await a(e);if(n?.video&&(!n.audio||n.audio.codec===`wmav2`))return{container:`asf`,videoCodec:n.video.codec,width:n.video.width,height:n.video.height,audio:!!n.audio,audioCodec:n.audio?`wmav2`:``,channels:n.audio?.channels??0,sampleRate:n.audio?.sampleRate??0};let r=await g(e);return r?{container:`mpeg-ps`,videoCodec:`mpeg2video`,width:r.width,height:r.height,audio:!!r.audioCodec,audioCodec:r.audioCodec??``,channels:r.channels,sampleRate:r.sampleRate}:null}var v={manifest:{protocolVersion:2,id:`ffmpeg-video`,name:{en:`FFmpeg video viewer`,"zh-CN":`FFmpeg 视频查看器`},formats:[{name:{en:`AVI MPEG-4 video`,"zh-CN":`AVI MPEG-4 视频`},extensions:[`.avi`]},{name:{en:`ASF / Windows Media video`,"zh-CN":`ASF / Windows Media 视频`},extensions:[`.wmv`,`.asf`],mimeTypes:[`video/x-ms-wmv`,`video/x-ms-asf`]},{name:{en:`MPEG program stream video`,"zh-CN":`MPEG 节目流视频`},extensions:[`.mpg`,`.mpeg`,`.vob`],mimeTypes:[`video/mpeg`]}],workspaceAccess:`none`},async open(r){let i=await _(r);if(!i)throw new t(`invalid-file`,e(r.locale,{en:`Unsupported video.`,"zh-CN":`不支持此视频。`}));return n(r,!0,e=>e.video&&e.videoCodec===i.videoCodec&&e.width===i.width&&e.height===i.height&&e.audio===i.audio&&(!e.audio||e.audioCodec===i.audioCodec&&e.channels===i.channels&&e.sampleRate===i.sampleRate))}};export{v as ffmpegVideoViewer};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t}from"./index-BCxD9rBl.js";import{n,r,t as i}from"./src-hCrza_Lf.js";var a={protocolVersion:2,id:`dicom`,name:{en:`DICOM medical image viewer`,"zh-CN":`DICOM 医学影像查看器`},formats:[{name:{en:`DICOM medical image`,"zh-CN":`DICOM 医学影像`},extensions:[`.dcm`,`.dicom`],mimeTypes:[`application/dicom`]}],workspaceAccess:`none`},o={en:{reading:`Reading DICOM image…`,invalid:`The DICOM file is invalid or truncated.`,limit:`The DICOM header exceeds 8 MiB or the frame exceeds 16 Mi pixels.`,environment:`This viewer requires Web Workers and Canvas 2D.`,failed:`The DICOM image could not be displayed.`,syntax:`Metadata only: this transfer syntax is not supported for image display.`,pixels:`Metadata only: this pixel format is not supported for image display.`,transform:`Metadata only: this image uses unsupported LUT or per-frame transformations.`,noImage:`Metadata only: no supported image pixel data was found.`,frame:`Frame`,center:`Window center`,width:`Window width`,apply:`Apply window`,auto:`Reset window`,fit:`Fit`,actual:`Actual size`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,left:`Rotate left`,right:`Rotate right`,image:`DICOM image; use arrow keys to pan, + and − to zoom`,metadata:`Image metadata`,modality:`Modality`,date:`Study date`,syntaxLabel:`Transfer syntax`,sopClass:`SOP class`,dimensions:`Dimensions`,frames:`Frames`,bits:`Bits allocated`,photometric:`Photometric interpretation`,loading:`Loading frame…`,frameError:`Could not load this frame. The previous image remains displayed.`,displayed:`Displayed frame`,windowError:`Enter a finite window center and a window width of at least 1.`},"zh-CN":{reading:`正在读取 DICOM 影像…`,invalid:`DICOM 文件无效或不完整。`,limit:`DICOM 文件头超过 8 MiB,或单帧超过约 1677 万像素。`,environment:`此查看器需要 Web Worker 和 Canvas 2D 支持。`,failed:`无法显示 DICOM 影像。`,syntax:`仅显示元数据:暂不支持此传输语法的影像解码。`,pixels:`仅显示元数据:暂不支持此像素格式的影像显示。`,transform:`仅显示元数据:此影像使用了暂不支持的 LUT 或逐帧变换。`,noImage:`仅显示元数据:未找到受支持的影像像素数据。`,frame:`帧`,center:`窗位`,width:`窗宽`,apply:`应用窗宽/窗位`,auto:`重置窗宽/窗位`,fit:`适应窗口`,actual:`原始大小`,zoomIn:`放大`,zoomOut:`缩小`,left:`向左旋转`,right:`向右旋转`,image:`DICOM 影像;方向键平移,加减键缩放`,metadata:`影像元数据`,modality:`检查类型`,date:`检查日期`,syntaxLabel:`传输语法`,sopClass:`SOP 类`,dimensions:`尺寸`,frames:`帧数`,bits:`像素分配位数`,photometric:`光度解释`,loading:`正在加载帧…`,frameError:`无法加载此帧,仍显示上一帧影像。`,displayed:`当前显示帧`,windowError:`请输入有效窗位,窗宽须大于或等于 1。`}};function s(e,t){let n=document.createElement(`div`);n.className=`anyfile-dicom`;let r=document.createElement(`style`);r.textContent=`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t}from"./index-DtiyOy_J.js";import{n,r,t as i}from"./src-hCrza_Lf.js";var a={protocolVersion:2,id:`dicom`,name:{en:`DICOM medical image viewer`,"zh-CN":`DICOM 医学影像查看器`},formats:[{name:{en:`DICOM medical image`,"zh-CN":`DICOM 医学影像`},extensions:[`.dcm`,`.dicom`],mimeTypes:[`application/dicom`]}],workspaceAccess:`none`},o={en:{reading:`Reading DICOM image…`,invalid:`The DICOM file is invalid or truncated.`,limit:`The DICOM header exceeds 8 MiB or the frame exceeds 16 Mi pixels.`,environment:`This viewer requires Web Workers and Canvas 2D.`,failed:`The DICOM image could not be displayed.`,syntax:`Metadata only: this transfer syntax is not supported for image display.`,pixels:`Metadata only: this pixel format is not supported for image display.`,transform:`Metadata only: this image uses unsupported LUT or per-frame transformations.`,noImage:`Metadata only: no supported image pixel data was found.`,frame:`Frame`,center:`Window center`,width:`Window width`,apply:`Apply window`,auto:`Reset window`,fit:`Fit`,actual:`Actual size`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,left:`Rotate left`,right:`Rotate right`,image:`DICOM image; use arrow keys to pan, + and − to zoom`,metadata:`Image metadata`,modality:`Modality`,date:`Study date`,syntaxLabel:`Transfer syntax`,sopClass:`SOP class`,dimensions:`Dimensions`,frames:`Frames`,bits:`Bits allocated`,photometric:`Photometric interpretation`,loading:`Loading frame…`,frameError:`Could not load this frame. The previous image remains displayed.`,displayed:`Displayed frame`,windowError:`Enter a finite window center and a window width of at least 1.`},"zh-CN":{reading:`正在读取 DICOM 影像…`,invalid:`DICOM 文件无效或不完整。`,limit:`DICOM 文件头超过 8 MiB,或单帧超过约 1677 万像素。`,environment:`此查看器需要 Web Worker 和 Canvas 2D 支持。`,failed:`无法显示 DICOM 影像。`,syntax:`仅显示元数据:暂不支持此传输语法的影像解码。`,pixels:`仅显示元数据:暂不支持此像素格式的影像显示。`,transform:`仅显示元数据:此影像使用了暂不支持的 LUT 或逐帧变换。`,noImage:`仅显示元数据:未找到受支持的影像像素数据。`,frame:`帧`,center:`窗位`,width:`窗宽`,apply:`应用窗宽/窗位`,auto:`重置窗宽/窗位`,fit:`适应窗口`,actual:`原始大小`,zoomIn:`放大`,zoomOut:`缩小`,left:`向左旋转`,right:`向右旋转`,image:`DICOM 影像;方向键平移,加减键缩放`,metadata:`影像元数据`,modality:`检查类型`,date:`检查日期`,syntaxLabel:`传输语法`,sopClass:`SOP 类`,dimensions:`尺寸`,frames:`帧数`,bits:`像素分配位数`,photometric:`光度解释`,loading:`正在加载帧…`,frameError:`无法加载此帧,仍显示上一帧影像。`,displayed:`当前显示帧`,windowError:`请输入有效窗位,窗宽须大于或等于 1。`}};function s(e,t){let n=document.createElement(`div`);n.className=`anyfile-dicom`;let r=document.createElement(`style`);r.textContent=`
2
2
  .anyfile-dicom { display:flex; flex-direction:column; height:100%; min-height:0; width:100%; overflow:hidden; color:var(--viewer-foreground,#222); background:var(--viewer-background,#fff); font-family:var(--viewer-font-family,sans-serif); }
3
3
  .anyfile-dicom .dicom-toolbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:8px; flex:none; max-height:40%; overflow:auto; border-bottom:1px solid var(--viewer-border,#ccc); }
4
4
  .anyfile-dicom button,.anyfile-dicom input { font:inherit; color:inherit; background:var(--viewer-background,#fff); border:1px solid var(--viewer-border,#ccc); border-radius:4px; padding:4px 8px; }
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,l as n,o as r}from"./index-BCxD9rBl.js";import{r as i}from"./src-hCrza_Lf.js";import{n as a}from"./webm-_wYh_V7u.js";import"./container-inspection-DZoaDYQR.js";import{a as o,l as s,n as c,r as l,t as u}from"./id3-uzaDmDwy.js";function d(e,t){if(t.aborted)return Promise.reject(r());let n=e();return new Promise((e,i)=>{let a=!1,o=()=>{a||(a=!0,t.removeEventListener(`abort`,o),i(r()),n.then(e=>e.close(),()=>void 0))};t.addEventListener(`abort`,o,{once:!0}),n.then(n=>{a||(a=!0,t.removeEventListener(`abort`,o),e(n))},e=>{a||(a=!0,t.removeEventListener(`abort`,o),i(e))})})}async function f(e,n,i,a){if(typeof createImageBitmap!=`function`)throw new t(`unsupported-environment`,a);let o;try{o=await d(()=>createImageBitmap(e.slice(0,e.size,`image/jpeg`)),n)}catch(e){throw n.aborted?r():new t(`invalid-file`,i,{cause:e})}if(n.aborted)throw o.close(),r();if(o.width!==5760||o.height!==2880)throw o.close(),new t(`invalid-file`,i);return o}var p=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function m(e,t,n){let r=``,i=Math.min(e.length,t+n);for(let n=t;n<i&&e[n]!==0;n+=1)r+=String.fromCharCode(e[n]);return r.trim()}function h(e,t,n){if(n-t<14||m(e,t,6)!==`Exif`)return;let r=t+6,i=m(e,r,2),a=i===`II`;if(!a&&i!==`MM`)return;let o=new DataView(e.buffer,e.byteOffset,e.byteLength),s=e=>e+2<=n?o.getUint16(e,a):void 0,c=e=>e+4<=n?o.getUint32(e,a):void 0;if(s(r+2)!==42)return;let l=c(r+4);if(l===void 0)return;let u=r+l,d=s(u);if(d===void 0||d>512||u+2+d*12>n)return;let f,p;for(let t=0;t<d;t+=1){let i=u+2+t*12,a=s(i),o=s(i+2),l=c(i+4);if(a!==271&&a!==272||o!==2||!l||l>256)continue;let d=l<=4?i+8:r+(c(i+8)??2**53-1);d<r||d+l>n||(a===271?f=m(e,d,l):p=m(e,d,l))}return{make:f,model:p}}function g(e){if(e.length<4||e[0]!==255||e[1]!==216)return;let t=2,n,r,i,a,o=!1;for(;t+4<=e.length;){if(e[t]!==255)return;for(;t<e.length&&e[t]===255;)t+=1;let s=e[t++];if(s===218||s===217)break;if(s===1||s>=208&&s<=215)continue;if(t+2>e.length)return;let c=e[t]*256+e[t+1];if(c<2||t+c>e.length)return;let l=t+2,u=t+c;if(p.has(s)&&l+5<=u)r=e[l+1]*256+e[l+2],n=e[l+3]*256+e[l+4];else if(s===225){let t=h(e,l,u);i??=t?.make,a??=t?.model;let n=new TextDecoder(`latin1`).decode(e.subarray(l,u));o||=n.includes(`<GPano:ProjectionType>equirectangular</GPano:ProjectionType>`)&&n.includes(`<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>`)}t=u}return n===5760&&r===2880&&i===`GoPro`&&a===`GoPro Max`&&o?{kind:`photo`,device:`MAX`,width:n,height:r}:void 0}var _=65536,v=16,y=2097152;function b(e,t,n=4){return String.fromCharCode(...e.subarray(t,t+n))}function x(e,t){if(t+8>e.length)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(t);if(r===0)return;if(r!==1)return r>=8?r:void 0;if(t+16>e.length)return;let i=n.getBigUint64(t+8);return i>=BigInt(16)&&i<=BigInt(2**53-1)?Number(i):void 0}function S(e,t){let n=0;for(;n+8<=e.length;){let r=x(e,n);if(!r||n+r>t)return;let i=b(e,n+4);if(i===`moov`)return n;if(i===`mdat`)return n+r;if(n+r>e.length)return;n+=r}}function C(e){if(e.container!==`MP4`||e.videoTracks.length!==2)return;let[t,n]=e.videoTracks;if(t.codec===`HEVC/H.265`&&n.codec===`HEVC/H.265`&&t.width===n.width&&t.height===n.height&&e.audioTracks.some(e=>e.codec===`AAC-LC`&&e.channels===2&&e.sampleRate===48e3)){if(t.width===4096&&t.height===1344)return{device:`MAX`,width:4096,height:1344};if(t.width===5952&&t.height===1920)return{device:`MAX2`,width:5952,height:1920}}}async function w(e,t){if(e.size<24)return;let r=await n(e.slice(0,Math.min(e.size,_)),t);if(b(r,4)!==`ftyp`)return;let i=S(r,e.size);if(i===void 0||i+8>e.size)return;let o=await n(e.slice(i,Math.min(e.size,i+v)),t);if(o.length<8||b(o,4)!==`moov`)return;let s=x(o,0);if(!s||s>y||i+s>e.size)return;let c=await n(e.slice(i,i+s),t);if(!new TextDecoder(`latin1`).decode(c).includes(`GoPro H.265`))return;let l=a({head:r,tail:c,tailOffset:i}),u=l&&C(l);return l&&u?{kind:`video`,media:l,...u}:void 0}var T=262144;async function E(e){let t=e.file.name.slice(e.file.name.lastIndexOf(`.`)).toLowerCase();if(t===`.360`)return w(e.file,e.signal);if(t===`.jpg`||t===`.jpeg`)return g(await n(e.file.slice(0,Math.min(e.file.size,T)),e.signal))}var D={protocolVersion:2,id:`gopro-max`,name:{en:`GoPro MAX panorama viewer`,"zh-CN":`GoPro MAX 全景查看器`},formats:[{name:{en:`GoPro MAX panorama photo`,"zh-CN":`GoPro MAX 全景照片`},extensions:[`.jpg`,`.jpeg`],mimeTypes:[`image/jpeg`]},{name:{en:`GoPro MAX 360 video`,"zh-CN":`GoPro MAX 全景视频`},extensions:[`.360`],mimeTypes:[`video/mp4`]}],workspaceAccess:`none`},O=`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,l as n,o as r}from"./index-DtiyOy_J.js";import{r as i}from"./src-hCrza_Lf.js";import{n as a}from"./webm-14HHwfWy.js";import"./container-inspection-ekEPWWcy.js";import{a as o,l as s,n as c,r as l,t as u}from"./id3-uzaDmDwy.js";function d(e,t){if(t.aborted)return Promise.reject(r());let n=e();return new Promise((e,i)=>{let a=!1,o=()=>{a||(a=!0,t.removeEventListener(`abort`,o),i(r()),n.then(e=>e.close(),()=>void 0))};t.addEventListener(`abort`,o,{once:!0}),n.then(n=>{a||(a=!0,t.removeEventListener(`abort`,o),e(n))},e=>{a||(a=!0,t.removeEventListener(`abort`,o),i(e))})})}async function f(e,n,i,a){if(typeof createImageBitmap!=`function`)throw new t(`unsupported-environment`,a);let o;try{o=await d(()=>createImageBitmap(e.slice(0,e.size,`image/jpeg`)),n)}catch(e){throw n.aborted?r():new t(`invalid-file`,i,{cause:e})}if(n.aborted)throw o.close(),r();if(o.width!==5760||o.height!==2880)throw o.close(),new t(`invalid-file`,i);return o}var p=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function m(e,t,n){let r=``,i=Math.min(e.length,t+n);for(let n=t;n<i&&e[n]!==0;n+=1)r+=String.fromCharCode(e[n]);return r.trim()}function h(e,t,n){if(n-t<14||m(e,t,6)!==`Exif`)return;let r=t+6,i=m(e,r,2),a=i===`II`;if(!a&&i!==`MM`)return;let o=new DataView(e.buffer,e.byteOffset,e.byteLength),s=e=>e+2<=n?o.getUint16(e,a):void 0,c=e=>e+4<=n?o.getUint32(e,a):void 0;if(s(r+2)!==42)return;let l=c(r+4);if(l===void 0)return;let u=r+l,d=s(u);if(d===void 0||d>512||u+2+d*12>n)return;let f,p;for(let t=0;t<d;t+=1){let i=u+2+t*12,a=s(i),o=s(i+2),l=c(i+4);if(a!==271&&a!==272||o!==2||!l||l>256)continue;let d=l<=4?i+8:r+(c(i+8)??2**53-1);d<r||d+l>n||(a===271?f=m(e,d,l):p=m(e,d,l))}return{make:f,model:p}}function g(e){if(e.length<4||e[0]!==255||e[1]!==216)return;let t=2,n,r,i,a,o=!1;for(;t+4<=e.length;){if(e[t]!==255)return;for(;t<e.length&&e[t]===255;)t+=1;let s=e[t++];if(s===218||s===217)break;if(s===1||s>=208&&s<=215)continue;if(t+2>e.length)return;let c=e[t]*256+e[t+1];if(c<2||t+c>e.length)return;let l=t+2,u=t+c;if(p.has(s)&&l+5<=u)r=e[l+1]*256+e[l+2],n=e[l+3]*256+e[l+4];else if(s===225){let t=h(e,l,u);i??=t?.make,a??=t?.model;let n=new TextDecoder(`latin1`).decode(e.subarray(l,u));o||=n.includes(`<GPano:ProjectionType>equirectangular</GPano:ProjectionType>`)&&n.includes(`<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>`)}t=u}return n===5760&&r===2880&&i===`GoPro`&&a===`GoPro Max`&&o?{kind:`photo`,device:`MAX`,width:n,height:r}:void 0}var _=65536,v=16,y=2097152;function b(e,t,n=4){return String.fromCharCode(...e.subarray(t,t+n))}function x(e,t){if(t+8>e.length)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(t);if(r===0)return;if(r!==1)return r>=8?r:void 0;if(t+16>e.length)return;let i=n.getBigUint64(t+8);return i>=BigInt(16)&&i<=BigInt(2**53-1)?Number(i):void 0}function S(e,t){let n=0;for(;n+8<=e.length;){let r=x(e,n);if(!r||n+r>t)return;let i=b(e,n+4);if(i===`moov`)return n;if(i===`mdat`)return n+r;if(n+r>e.length)return;n+=r}}function C(e){if(e.container!==`MP4`||e.videoTracks.length!==2)return;let[t,n]=e.videoTracks;if(t.codec===`HEVC/H.265`&&n.codec===`HEVC/H.265`&&t.width===n.width&&t.height===n.height&&e.audioTracks.some(e=>e.codec===`AAC-LC`&&e.channels===2&&e.sampleRate===48e3)){if(t.width===4096&&t.height===1344)return{device:`MAX`,width:4096,height:1344};if(t.width===5952&&t.height===1920)return{device:`MAX2`,width:5952,height:1920}}}async function w(e,t){if(e.size<24)return;let r=await n(e.slice(0,Math.min(e.size,_)),t);if(b(r,4)!==`ftyp`)return;let i=S(r,e.size);if(i===void 0||i+8>e.size)return;let o=await n(e.slice(i,Math.min(e.size,i+v)),t);if(o.length<8||b(o,4)!==`moov`)return;let s=x(o,0);if(!s||s>y||i+s>e.size)return;let c=await n(e.slice(i,i+s),t);if(!new TextDecoder(`latin1`).decode(c).includes(`GoPro H.265`))return;let l=a({head:r,tail:c,tailOffset:i}),u=l&&C(l);return l&&u?{kind:`video`,media:l,...u}:void 0}var T=262144;async function E(e){let t=e.file.name.slice(e.file.name.lastIndexOf(`.`)).toLowerCase();if(t===`.360`)return w(e.file,e.signal);if(t===`.jpg`||t===`.jpeg`)return g(await n(e.file.slice(0,Math.min(e.file.size,T)),e.signal))}var D={protocolVersion:2,id:`gopro-max`,name:{en:`GoPro MAX panorama viewer`,"zh-CN":`GoPro MAX 全景查看器`},formats:[{name:{en:`GoPro MAX panorama photo`,"zh-CN":`GoPro MAX 全景照片`},extensions:[`.jpg`,`.jpeg`],mimeTypes:[`image/jpeg`]},{name:{en:`GoPro MAX 360 video`,"zh-CN":`GoPro MAX 全景视频`},extensions:[`.360`],mimeTypes:[`video/mp4`]}],workspaceAccess:`none`},O=`
2
2
  attribute vec2 aPosition;
3
3
  varying vec2 vPosition;
4
4
  void main() {
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-BCxD9rBl.js";import{a as r,i,r as a,s as o}from"./zip-core-base-CDv8KjIR.js";import"./zip-core-custom-D3VVVj-J.js";import{c as s,f as c,n as l,o as u,u as d}from"./src-C9Uz3C-q.js";import{t as f}from"./xml.browser-CC8-XAyN.js";var p=class extends Error{},m=class extends Error{};function h(e){throw new p(e)}function g(e,t){let n=0,r=1;for(let i=0;i<10;i+=1){t.offset>=e.length&&h(`Truncated varint.`);let i=e[t.offset++];if(n+=(i&127)*r,i<128)return n;r*=128}return h(`Varint is too long.`)}function _(e,t){let n={offset:0},r=g(e,n);if(r>t)throw new m(`Snappy block exceeds the output limit.`);let i=new Uint8Array(r),a=0,o=n.offset;for(;o<e.length;){let t=e[o++],n=t&3;if(n===0){let n=t>>>2;if(n>=60){let t=n-59;o+t>e.length&&h(`Truncated Snappy literal.`),n=0;for(let r=0;r<t;r+=1)n+=e[o+r]*2**(8*r);o+=t}n+=1,(o+n>e.length||a+n>r)&&h(`Invalid Snappy literal.`),i.set(e.subarray(o,o+n),a),o+=n,a+=n;continue}let s,c;if(n===1)o>=e.length&&h(`Truncated Snappy copy.`),s=(t>>>2&7)+4,c=t>>>5<<8|e[o++];else{let r=n===2?2:4;o+r>e.length&&h(`Truncated Snappy copy.`),s=(t>>>2)+1,c=0;for(let t=0;t<r;t+=1)c+=e[o+t]*2**(8*t);o+=r}(c===0||c>a||a+s>r)&&h(`Invalid Snappy copy.`);for(let e=0;e<s;e+=1,a+=1)i[a]=i[a-c]}return a!==r&&h(`Snappy block length mismatch.`),i}function v(e,t){let n=[],r=0,i=0;for(;i<e.length;){(i+4>e.length||e[i]!==0)&&h(`Invalid IWA chunk header.`);let a=e[i+1]|e[i+2]<<8|e[i+3]<<16;i+=4,i+a>e.length&&h(`Truncated IWA chunk.`);let o=_(e.subarray(i,i+a),t-r);n.push(o),r+=o.length,i+=a}if(n.length===1)return n[0];let a=new Uint8Array(r),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}function y(e){let t=new Map,n={offset:0};for(;n.offset<e.length;){let r=g(e,n),i=Math.floor(r/8),a=r%8;i===0&&h(`Invalid protobuf field.`);let o;if(a===0)o=g(e,n);else if(a===2){let t=g(e,n);n.offset+t>e.length&&h(`Truncated protobuf field.`),o=e.subarray(n.offset,n.offset+t),n.offset+=t}else a===1||a===5?(n.offset+=a===1?8:4,n.offset>e.length&&h(`Truncated protobuf field.`)):h(`Unsupported protobuf wire type.`);if(o===void 0)continue;let s=t.get(i);s?s.push(o):t.set(i,[o])}return t}function b(e,t){let n=e.get(t)?.[0];return typeof n==`number`?n:void 0}function x(e,t){return(e.get(t)??[]).filter(e=>e instanceof Uint8Array)}function ee(e){let t=[],n={offset:0};for(;n.offset<e.length;){let r=g(e,n);n.offset+r>e.length&&h(`Truncated IWA archive info.`);let i=y(e.subarray(n.offset,n.offset+r));n.offset+=r;let a=b(i,1);a===void 0&&h(`IWA archive has no identifier.`);let o=[];for(let t of x(i,2)){let r=y(t),i=b(r,1)??0,a=b(r,3)??0;n.offset+a>e.length&&h(`Truncated IWA message.`),o.push({type:i,data:e.subarray(n.offset,n.offset+a)}),n.offset+=a}t.push({id:a,messages:o})}return t}var te=[`preview.jpg`,`QuickLook/Thumbnail.jpg`,`preview-web.jpg`,`QuickLook/Thumbnail.png`];function ne(e){let t=e.toLowerCase();if(t.endsWith(`.pages`))return`pages`;if(t.endsWith(`.key`))return`keynote`}function S(e,t){if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return n===``||/^[^/]+\/$/.test(n)?n:void 0}function C(e,t){let n=t===`pages`?`index.xml`:`index.apxl`,r;for(let t of e){if(t.endsWith(`.iwpv2`))return{kind:`encrypted`};if(r)continue;let e=S(t,`Index/Document.iwa`);e===void 0?(e=S(t,`Index.zip`))===void 0?(e=S(t,n))===void 0?(e=S(t,`${n}.gz`))!==void 0&&(r={kind:`xml`,prefix:e,index:t}):r={kind:`xml`,prefix:e,index:t}:r={kind:`iwa-zip`,prefix:e}:r={kind:`iwa`,prefix:e}}return r}function w(e,t){return te.map(e=>t+e).find(t=>e.has(t))}var T=2001,E=0,D=4,O=1e4,re=1,ie=2,ae=4,k=5,oe=11006,se=32,A=new TextDecoder;function j(e){return e.replace(/\uFFFC/g,``).split(/[\n\r\u2029\u000c\u000e\u0004\u0005]/).map(e=>e.replace(/\u2028/g,`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-DtiyOy_J.js";import{a as r,i,r as a,s as o}from"./zip-core-base-DD8akpjq.js";import"./zip-core-custom-CfPFs1lw.js";import{c as s,f as c,n as l,o as u,u as d}from"./src-C9Uz3C-q.js";import{t as f}from"./xml.browser-CC8-XAyN.js";var p=class extends Error{},m=class extends Error{};function h(e){throw new p(e)}function g(e,t){let n=0,r=1;for(let i=0;i<10;i+=1){t.offset>=e.length&&h(`Truncated varint.`);let i=e[t.offset++];if(n+=(i&127)*r,i<128)return n;r*=128}return h(`Varint is too long.`)}function _(e,t){let n={offset:0},r=g(e,n);if(r>t)throw new m(`Snappy block exceeds the output limit.`);let i=new Uint8Array(r),a=0,o=n.offset;for(;o<e.length;){let t=e[o++],n=t&3;if(n===0){let n=t>>>2;if(n>=60){let t=n-59;o+t>e.length&&h(`Truncated Snappy literal.`),n=0;for(let r=0;r<t;r+=1)n+=e[o+r]*2**(8*r);o+=t}n+=1,(o+n>e.length||a+n>r)&&h(`Invalid Snappy literal.`),i.set(e.subarray(o,o+n),a),o+=n,a+=n;continue}let s,c;if(n===1)o>=e.length&&h(`Truncated Snappy copy.`),s=(t>>>2&7)+4,c=t>>>5<<8|e[o++];else{let r=n===2?2:4;o+r>e.length&&h(`Truncated Snappy copy.`),s=(t>>>2)+1,c=0;for(let t=0;t<r;t+=1)c+=e[o+t]*2**(8*t);o+=r}(c===0||c>a||a+s>r)&&h(`Invalid Snappy copy.`);for(let e=0;e<s;e+=1,a+=1)i[a]=i[a-c]}return a!==r&&h(`Snappy block length mismatch.`),i}function v(e,t){let n=[],r=0,i=0;for(;i<e.length;){(i+4>e.length||e[i]!==0)&&h(`Invalid IWA chunk header.`);let a=e[i+1]|e[i+2]<<8|e[i+3]<<16;i+=4,i+a>e.length&&h(`Truncated IWA chunk.`);let o=_(e.subarray(i,i+a),t-r);n.push(o),r+=o.length,i+=a}if(n.length===1)return n[0];let a=new Uint8Array(r),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}function y(e){let t=new Map,n={offset:0};for(;n.offset<e.length;){let r=g(e,n),i=Math.floor(r/8),a=r%8;i===0&&h(`Invalid protobuf field.`);let o;if(a===0)o=g(e,n);else if(a===2){let t=g(e,n);n.offset+t>e.length&&h(`Truncated protobuf field.`),o=e.subarray(n.offset,n.offset+t),n.offset+=t}else a===1||a===5?(n.offset+=a===1?8:4,n.offset>e.length&&h(`Truncated protobuf field.`)):h(`Unsupported protobuf wire type.`);if(o===void 0)continue;let s=t.get(i);s?s.push(o):t.set(i,[o])}return t}function b(e,t){let n=e.get(t)?.[0];return typeof n==`number`?n:void 0}function x(e,t){return(e.get(t)??[]).filter(e=>e instanceof Uint8Array)}function ee(e){let t=[],n={offset:0};for(;n.offset<e.length;){let r=g(e,n);n.offset+r>e.length&&h(`Truncated IWA archive info.`);let i=y(e.subarray(n.offset,n.offset+r));n.offset+=r;let a=b(i,1);a===void 0&&h(`IWA archive has no identifier.`);let o=[];for(let t of x(i,2)){let r=y(t),i=b(r,1)??0,a=b(r,3)??0;n.offset+a>e.length&&h(`Truncated IWA message.`),o.push({type:i,data:e.subarray(n.offset,n.offset+a)}),n.offset+=a}t.push({id:a,messages:o})}return t}var te=[`preview.jpg`,`QuickLook/Thumbnail.jpg`,`preview-web.jpg`,`QuickLook/Thumbnail.png`];function ne(e){let t=e.toLowerCase();if(t.endsWith(`.pages`))return`pages`;if(t.endsWith(`.key`))return`keynote`}function S(e,t){if(!e.endsWith(t))return;let n=e.slice(0,e.length-t.length);return n===``||/^[^/]+\/$/.test(n)?n:void 0}function C(e,t){let n=t===`pages`?`index.xml`:`index.apxl`,r;for(let t of e){if(t.endsWith(`.iwpv2`))return{kind:`encrypted`};if(r)continue;let e=S(t,`Index/Document.iwa`);e===void 0?(e=S(t,`Index.zip`))===void 0?(e=S(t,n))===void 0?(e=S(t,`${n}.gz`))!==void 0&&(r={kind:`xml`,prefix:e,index:t}):r={kind:`xml`,prefix:e,index:t}:r={kind:`iwa-zip`,prefix:e}:r={kind:`iwa`,prefix:e}}return r}function w(e,t){return te.map(e=>t+e).find(t=>e.has(t))}var T=2001,E=0,D=4,O=1e4,re=1,ie=2,ae=4,k=5,oe=11006,se=32,A=new TextDecoder;function j(e){return e.replace(/\uFFFC/g,``).split(/[\n\r\u2029\u000c\u000e\u0004\u0005]/).map(e=>e.replace(/\u2028/g,`
2
2
  `).replace(/[\u0000-\u0009\u000b\u000f-\u001f]/g,``).trim()).filter(Boolean)}function M(e){let t=new Map;for(let[n,r]of e)for(let e of r){let r=e.messages[0];!r||t.has(e.id)||t.set(e.id,{file:n,type:r.type,get fields(){return y(r.data)}})}return t}function N(e,t){let n=x(e,t)[0];return n?b(y(n),1):void 0}function P(e){return x(e,3).map(e=>A.decode(e)).join(``)}function F(e){let t=[];for(let n of e)for(let e of n.messages){if(e.type!==T)continue;let r=y(e.data);t.push({id:n.id,kind:b(r,1),text:P(r)})}return t}function I(e){let t=e.get(`Document.iwa`),n=t?.find(e=>e.id===1)?.messages[0];if(!t||n?.type!==O)throw new p(`Missing Pages document archive.`);let r=N(y(n.data),4),i=F(t),a=i.find(e=>e.id===r&&e.kind===E),o=[],s=a?j(a.text):[];s.length&&o.push({role:`body`,paragraphs:s,notes:[]});let c=i.filter(e=>e!==a&&(e.kind===void 0||e.kind===3)).flatMap(e=>j(e.text));return c.length&&o.push({role:`text-boxes`,paragraphs:c,notes:[]}),{app:`pages`,generation:`iwa`,sections:o}}function L(e){let t=new Map;for(let n of e.get(`Metadata.iwa`)??[])for(let e of n.messages)if(e.type===oe)for(let n of x(y(e.data),4)){let e=y(n),r=b(e,1),i=x(e,4)[0]??x(e,3)[0];r!==void 0&&i&&t.set(r,A.decode(i))}return t}function R(e,t,n){let r=new Map,i=[5,6,7].flatMap(e=>x(t,e).map(e=>b(y(e),1)));for(let t of i){let n=e.get(t??-1),i=n&&x(n.fields,1)[0],a=i?N(y(i),2):void 0;a!==void 0&&!r.has(a)&&r.set(a,r.size)}return n.map((e,t)=>({text:e,order:r.get(e.id)??r.size+t})).sort((e,t)=>e.order-t.order).map(({text:e})=>e)}function z(e,t){let n=M(e),r=n.get(1);if(r?.type!==re)throw new p(`Missing Keynote document archive.`);let i=n.get(N(r.fields,2)??-1);if(i?.type!==ie)throw new p(`Missing Keynote show archive.`);let a=x(i.fields,3)[0],o=a?y(a):new Map,s=L(e),c=[],l=new Set,u=(r,i)=>{if(i>se||l.has(r))return;l.add(r);let a=n.get(r);if(a?.type!==ae)return;let o=n.get(N(a.fields,2)??-1);if(o?.type===k){let r=e.get(o.file)??[],i=r.filter(e=>e.messages[0]?.type===k).length===1?R(n,o.fields,F(r)):[],l=x(a.fields,16)[0],u=l?b(y(l),1):void 0;c.push({role:`slide`,paragraphs:i.filter(e=>e.kind!==D).flatMap(e=>j(e.text)),notes:i.filter(e=>e.kind===D).flatMap(e=>j(e.text)),image:u===void 0?void 0:t(u,s.get(u))})}for(let e of x(a.fields,1)){let t=b(y(e),1);t!==void 0&&u(t,i+1)}};for(let e of x(o,2)){let t=b(y(e),1);t!==void 0&&u(t,0)}return{app:`keynote`,generation:`iwa`,sections:c}}function B(e,t,n){return e===`pages`?I(t):z(t,n)}var V=`http://developer.apple.com/namespaces/sf`,H=`http://developer.apple.com/namespaces/keynote2`,U=class extends Error{};function W(e,t,n){return Array.from(e.getElementsByTagName(`*`)).filter(e=>e.namespaceURI===t&&e.localName===n)}function G(e,t){return e?.getAttribute(`sf:${t}`)??void 0}function K(e){let t=``,n=e=>{for(let r of Array.from(e.childNodes))if(r.nodeType===3)t+=r.nodeValue??``;else if(r.nodeType===1){let e=r;if(e.namespaceURI===V&&e.localName===`ghost-text`)continue;e.namespaceURI===V&&(e.localName===`br`||e.localName===`lnbr`)?t+=`
3
3
  `:e.namespaceURI===V&&e.localName===`tab`?t+=` `:n(e)}};return n(e),t}function q(e,t){return W(e,V,`p`).filter(e=>!t?.(e)).flatMap(e=>j(K(e)))}function ce(e,t){for(let n=e.parentElement;n&&n!==t;n=n.parentElement)if(n.namespaceURI===H&&n.localName===`notes`)return!0;return!1}function le(e){let t=f(e,`application/xml`);if(t.getElementsByTagName(`parsererror`).length)throw new U(`Malformed iWork XML.`);return t}function ue(e){if(e.documentElement.localName!==`document`)throw new U(`Not a Pages document.`);let t=Array.from(e.documentElement.children).find(e=>e.namespaceURI===V&&e.localName===`text-storage`&&G(e,`kind`)===`body`),n=t&&W(t,V,`text-body`)[0],r=n?q(n):[];return{app:`pages`,generation:`xml`,sections:r.length?[{role:`body`,paragraphs:r,notes:[]}]:[]}}function de(e){if(e.documentElement.namespaceURI!==H||e.documentElement.localName!==`presentation`)throw new U(`Not a Keynote presentation.`);let t=W(e,H,`slide-list`)[0];return{app:`keynote`,generation:`xml`,sections:(t?W(t,H,`slide`):[]).map(e=>{let t=W(e,H,`thumbnails`)[0],n=G(t&&W(t,V,`data`)[0],`path`),r=W(e,H,`notes`)[0];return{role:`slide`,paragraphs:q(e,t=>ce(t,e)),notes:r?q(r):[],image:n||void 0}})}}function fe(e,t){let n=le(t);return e===`pages`?ue(n):de(n)}var J={entries:2e4,entryBytes:134217728,expandedBytes:268435456,imageBytes:67108864,slides:5e3},Y=class extends Error{},X=class extends Error{},pe=new Set([0,8]),me=class e{constructor(e){this.signal=e,this.readers=[],this.entries=new Map}static async open(t,n){let r=new e(n);try{return await r.mount(t,``),r}catch(e){throw await r.close(),e}}get names(){return new Set(this.entries.keys())}async mountNested(e,t){await this.mount(await this.blob(e,J.entryBytes),t)}async bytes(e,t){return this.entry(e,t).getData(new o,{signal:this.signal})}async blob(e,t,n=`application/octet-stream`){return this.entry(e,t).getData(new r(n),{signal:this.signal})}size(e){return this.entries.get(e)?.uncompressedSize}async close(){await Promise.all(this.readers.splice(0).map(e=>e.close().catch(()=>void 0)))}entry(e,t){let n=this.entries.get(e);if(!n)throw Error(`Missing package entry ${e}.`);if(n.encrypted||!pe.has(n.compressionMethod))throw new X(`Encrypted entry.`);if(n.uncompressedSize>t)throw new Y(`Package entry exceeds the limit.`);return n}async mount(e,t){let n=new a(new i(e),{useWebWorkers:!1,useCompressionStream:!0});this.readers.push(n);for await(let e of n.getEntriesGenerator()){if(this.signal.aborted)throw new DOMException(`Viewer operation aborted.`,`AbortError`);if(this.entries.size>=J.entries)throw new Y(`Too many package entries.`);he(e)&&this.entries.set((t+e.filename).normalize(`NFC`),e)}}};function he(e){return!e.directory}async function ge(e,t,r,i){let a=`${t}Index/`,o=[...e.names].filter(e=>{if(!e.startsWith(a))return!1;let t=e.slice(a.length);return t===`Document.iwa`||t===`Metadata.iwa`||r===`keynote`&&/^Slide(-[^/]*)?\.iwa$/.test(t)});if(r===`keynote`&&o.length>J.slides+2)throw new Y(`Too many slides.`);let s=new Map,c=J.expandedBytes;for(let t of o){if(i.aborted)throw n();let r=v(await e.bytes(t,J.entryBytes),c);c-=r.length,s.set(t.slice(a.length),ee(r))}return s}async function _e(e,t){let n=await e.blob(t,J.entryBytes);if(!t.endsWith(`.gz`))return n.text();let r=[],i=0,a=n.stream().pipeThrough(new DecompressionStream(`gzip`)).getReader();try{for(let e=await a.read();!e.done;e=await a.read()){if(i+=e.value.length,i>J.expandedBytes)throw new Y(`Expanded XML exceeds the limit.`);r.push(e.value)}}finally{await a.cancel().catch(()=>void 0)}return new Blob(r).text()}function ve(e,t){let n=`${t}Data/`,r=[...e].filter(e=>e.startsWith(n));return(t,i)=>{let a=i?`${n}${i.normalize(`NFC`)}`:void 0;if(a&&e.has(a))return a;let o=`-${t}.`;return r.find(e=>e.slice(n.length).includes(o))}}async function ye(e,t,n,r){if(t.kind===`xml`){let r=fe(n,await _e(e,t.index)),i=r.sections.map(e=>({...e,image:e.image?t.prefix+e.image:void 0}));return{...r,sections:i}}return t.kind===`iwa-zip`&&await e.mountNested(`${t.prefix}Index.zip`,t.prefix),B(n,await ge(e,t.prefix,n,r),ve(e.names,t.prefix))}var Z={protocolVersion:2,id:`iwork`,name:{en:`Apple Pages & Keynote viewer`,"zh-CN":`Apple Pages 与 Keynote 查看器`},formats:[{name:{en:`Apple Pages document`,"zh-CN":`Apple Pages 文稿`},extensions:[`.pages`],mimeTypes:[`application/vnd.apple.pages`]},{name:{en:`Apple Keynote presentation`,"zh-CN":`Apple Keynote 演示文稿`},extensions:[`.key`],mimeTypes:[`application/vnd.apple.keynote`]}],workspaceAccess:`none`},be=`
4
4
  .anyfile-iwork__page { max-width: 880px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-BCxD9rBl.js";import{c as r,d as i,f as a,l as o,n as s,r as c,u as l}from"./src-C9Uz3C-q.js";import{t as u}from"./data-table-OJQe3aN5.js";var d=4096,f=3,p=class extends Error{};function m(){return{nodes:d}}function h(e,t,n,r){if(t<0||t+2>n)throw new p(`Truncated DER element.`);if(r&&(--r.nodes,r.nodes<0))throw new p(`Too many DER elements.`);let i=e[t];if((i&31)==31)throw new p(`Unsupported high-tag-number DER element.`);let a=e[t+1],o=a,s=2;if(a===128)throw new p(`Indefinite DER length is not allowed.`);if(a>128){let r=a&127;if(r===0||r>f||t+2+r>n)throw new p(`Unsupported DER length.`);o=0;for(let n=0;n<r;n+=1)o=o*256+e[t+2+n];s+=r}return{tag:i,constructed:!!(i&32),start:t,contentStart:t+s,length:o,end:t+s+o}}function g(e,t,n,r){let i=h(e,t,n,r);if(i.end>n)throw new p(`DER element exceeds its container.`);return i}function _(e,t,n=m()){if(!t.constructed)return[];let r=[],i=t.contentStart;for(;i<t.end;){let a=g(e,i,t.end,n);r.push(a),i=a.end}return r}function v(e,t,n,r){let i=t.contentStart,a=0,o=t.end;for(;i<o;){let t=g(e,i,o,r);if(a===n)return t;a+=1,i=t.end}}function y(e,t){return e.subarray(t.contentStart,t.end)}function b(e,t){let n=y(e,t);if(n.length===0||n.length>64)throw new p(`Invalid OBJECT IDENTIFIER.`);let r=n[0],i=[Math.floor(r/40),r%40],a=0,o=!1;for(let e=1;e<n.length;e+=1){let t=n[e];a=a*128+(t&127),o=!!(t&128),o||(i.push(a),a=0)}if(o)throw new p(`Truncated OBJECT IDENTIFIER.`);return i.join(`.`)}function x(e,t){let n=y(e,t),r=0;for(;r<n.length-1&&n[r]===0;)r+=1;return n.subarray(r)}function S(e,t){let n=y(e,t);return n.length>0&&n[0]!==0}function C(e,t){let n=y(e,t);if(n.length===0)throw new p(`Empty BIT STRING.`);let r=n[0];if(r>7||n.length===1&&r!==0)throw new p(`Invalid BIT STRING padding.`);return n.subarray(1)}function w(e,t){let n=y(e,t);if(t.tag===30){let e=``;for(let t=0;t+1<n.length;t+=2)e+=String.fromCharCode(n[t]<<8|n[t+1]);return e}if(t.tag===28){let e=``;for(let t=0;t+3<n.length;t+=4)e+=String.fromCodePoint(n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]);return e}try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return Array.from(n,e=>String.fromCharCode(e)).join(``)}}function T(e,t=`:`){return Array.from(e,e=>e.toString(16).padStart(2,`0`).toUpperCase()).join(t)}function E(e,t,n){let r=e.slice(t,t+n);if(!(r.length!==n||!/^\d+$/.test(r)))return Number(r)}function D(e,t){let n=Array.from(y(e,t),e=>String.fromCharCode(e)).join(``),r=t.tag===24,i=r?4:2;if(n.length<i+10)return;let a=E(n,0,i),o=E(n,i,2),s=E(n,i+2,2),c=E(n,i+4,2),l=E(n,i+6,2),u=E(n,i+8,2);if(a===void 0||o===void 0||s===void 0||c===void 0||l===void 0||u===void 0)return;r||(a+=a>=50?1900:2e3);let d=Date.UTC(a,o-1,s,c,l,u);if(!Number.isFinite(d))return;let f=new Date(d);return Number.isNaN(f.getTime())?void 0:f}var O=40,k={"2.5.4.3":`CN`,"2.5.4.4":`SN`,"2.5.4.5":`serialNumber`,"2.5.4.6":`C`,"2.5.4.7":`L`,"2.5.4.8":`ST`,"2.5.4.9":`street`,"2.5.4.10":`O`,"2.5.4.11":`OU`,"2.5.4.12":`title`,"2.5.4.17":`postalCode`,"2.5.4.42":`givenName`,"2.5.4.43":`initials`,"2.5.4.65":`pseudonym`,"2.5.4.97":`organizationIdentifier`,"0.9.2342.19200300.100.1.1":`UID`,"0.9.2342.19200300.100.1.25":`DC`,"1.2.840.113549.1.9.1":`emailAddress`,"1.3.6.1.4.1.311.60.2.1.3":`jurisdictionC`},A={"1.2.840.113549.1.1.2":`MD2 with RSA`,"1.2.840.113549.1.1.4":`MD5 with RSA`,"1.2.840.113549.1.1.5":`SHA-1 with RSA`,"1.2.840.113549.1.1.11":`SHA-256 with RSA`,"1.2.840.113549.1.1.12":`SHA-384 with RSA`,"1.2.840.113549.1.1.13":`SHA-512 with RSA`,"1.2.840.113549.1.1.10":`RSASSA-PSS`,"1.2.840.10045.4.1":`ECDSA with SHA-1`,"1.2.840.10045.4.3.2":`ECDSA with SHA-256`,"1.2.840.10045.4.3.3":`ECDSA with SHA-384`,"1.2.840.10045.4.3.4":`ECDSA with SHA-512`,"1.3.101.112":`Ed25519`,"1.3.101.113":`Ed448`,"1.3.101.114":`Ed448`,"2.16.840.1.101.3.4.3.2":`DSA with SHA-256`},j={"1.2.840.113549.1.1.1":`RSA`,"1.2.840.113549.1.1.10":`RSASSA-PSS`,"1.2.840.10045.2.1":`EC`,"1.2.840.10040.4.1":`DSA`,"1.3.101.112":`Ed25519`,"1.3.101.113":`Ed448`},M={"1.2.840.10045.3.1.7":`P-256`,"1.3.132.0.34":`P-384`,"1.3.132.0.35":`P-521`,"1.3.132.0.10":`secp256k1`,"1.3.132.0.33":`P-224`},N={"2.5.29.14":`Subject Key Identifier`,"2.5.29.15":`Key Usage`,"2.5.29.16":`Private Key Usage Period`,"2.5.29.17":`Subject Alternative Name`,"2.5.29.18":`Issuer Alternative Name`,"2.5.29.19":`Basic Constraints`,"2.5.29.30":`Name Constraints`,"2.5.29.31":`CRL Distribution Points`,"2.5.29.32":`Certificate Policies`,"2.5.29.35":`Authority Key Identifier`,"2.5.29.36":`Policy Constraints`,"2.5.29.37":`Extended Key Usage`,"2.5.29.46":`Freshest CRL`,"2.5.29.54":`Inhibit Any Policy`,"1.3.6.1.5.5.7.1.1":`Authority Information Access`,"1.3.6.1.5.5.7.1.11":`Subject Information Access`,"1.3.6.1.4.1.11129.2.4.2":`Signed Certificate Timestamp List`},P={"1.3.6.1.5.5.7.3.1":`TLS server authentication`,"1.3.6.1.5.5.7.3.2":`TLS client authentication`,"1.3.6.1.5.5.7.3.3":`Code signing`,"1.3.6.1.5.5.7.3.4":`Email protection`,"1.3.6.1.5.5.7.3.8":`Time stamping`,"1.3.6.1.5.5.7.3.9":`OCSP signing`,"2.5.29.37.0":`Any extended key usage`},F=[`digitalSignature`,`nonRepudiation`,`keyEncipherment`,`dataEncipherment`,`keyAgreement`,`keyCertSign`,`cRLSign`,`encipherOnly`,`decipherOnly`],I={160:`otherName`,129:`email`,130:`DNS`,163:`x400Address`,164:`directoryName`,165:`ediPartyName`,134:`URI`,135:`IP`,136:`registeredID`},L={"1.3.6.1.5.5.7.48.1":`ocsp`,"1.3.6.1.5.5.7.48.2":`caIssuers`};function R(e){let t=[];for(let n of e.matchAll(/-----BEGIN ([A-Z0-9 ]+)-----([\s\S]*?)-----END \1-----/g)){if(t.length>=O)break;let e=n[2].replace(/[^A-Za-z0-9+/=]/g,``),r;try{r=atob(e)}catch{continue}let i=Uint8Array.from(r,e=>e.charCodeAt(0));i.byteLength>0&&t.push({label:n[1],der:i})}return t}function z(e,t){return t[e]??e}function B(e,t,n){let r=t?v(e,t,0,n):void 0;return{oid:r?b(e,r):``,params:t?v(e,t,1,n):void 0}}function V(e,t,n){let r=[];for(let i of _(e,t,n))for(let t of _(e,i,n)){let i=v(e,t,0,n),a=v(e,t,1,n);if(!i||!a)continue;let o=b(e,i);if(r.push({oid:o,label:k[o]??o,value:w(e,a).trim()}),r.length>64)return{display:``,attributes:r}}return{display:r.map(({label:e,value:t})=>`${e}=${t}`).join(`, `),attributes:r}}function H(e){if(e.byteLength===4)return Array.from(e).join(`.`);if(e.byteLength===16){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return t.join(`:`)}return T(e)}function U(e,t,n){let r=[];for(let i of _(e,t,n)){let t=I[i.tag]??`[${i.tag&31}]`;if(i.tag===135)r.push({type:t,value:H(y(e,i))});else if(i.constructed){let a=_(e,i,n).map(t=>w(e,t)).join(`, `);r.push({type:t,value:a||T(y(e,i))})}else r.push({type:t,value:w(e,i)});if(r.length>128)break}return r}function W(e,t){let n=C(e,t),r=[];return F.forEach((e,t)=>{t<n.length*8&&n[Math.floor(t/8)]&128>>t%8&&r.push(e)}),r}function G(e,t,n,r){if(!(r.length>=16)){if(t.tag===134){r.push(w(e,t));return}if(t.constructed)for(let i of _(e,t,n))G(e,i,n,r)}}function K(e,t,n,r){if(t.byteLength===0)return{summary:``,items:[]};let i=g(t,0,t.byteLength,r);if(n===`2.5.29.19`){let e=!1,n=[];for(let a of _(t,i,r))a.tag===1?e=S(t,a):a.tag===2&&n.push(`pathLenConstraint=${Number.parseInt(T(x(t,a)),16)}`);return{summary:e?`CA certificate`:`End-entity certificate`,items:n}}if(n===`2.5.29.15`)return{summary:``,items:W(t,i)};if(n===`2.5.29.37`)return{summary:``,items:_(t,i,r).map(e=>z(b(t,e),P)).slice(0,64)};if(n===`2.5.29.17`)return{summary:``,items:U(t,i,r).map(({type:e,value:t})=>`${e}: ${t}`)};if(n===`2.5.29.14`)return{summary:T(y(t,i)),items:[]};if(n===`2.5.29.35`){let e=_(t,i,r).find(e=>e.tag===128);return{summary:e?T(y(t,e)):``,items:[]}}if(n===`2.5.29.31`||n===`2.5.29.46`){let e=[];return G(t,i,r,e),{summary:``,items:e}}return n===`1.3.6.1.5.5.7.1.1`?{summary:``,items:_(t,i,r).flatMap(e=>{let n=v(t,e,0,r),i=v(t,e,1,r);if(!n||!i)return[];let a=L[b(t,n)];return a&&i.tag===134?[`${a}: ${w(t,i)}`]:[]})}:n===`2.5.29.32`?{summary:``,items:_(t,i,r).flatMap(e=>{let n=v(t,e,0,r);return n?[b(t,n)]:[]})}:{summary:`${t.byteLength} bytes`,items:[]}}function q(e,t,n){if(!t)return{algorithm:``};let r=v(e,t,0,n),i=v(e,t,1,n),{oid:a,params:o}=B(e,r,n),s=z(a,j),c=o&&o.tag===6?M[b(e,o)]:void 0;if(!i)return{algorithm:s,curve:c};let l=C(e,i);if(a===`1.2.840.113549.1.1.1`&&l.byteLength>0)try{let e=v(l,g(l,0,l.byteLength,n),0,n);if(e){let t=x(l,e),n=t[0].toString(2).length;return{algorithm:s,bits:t.byteLength*8-(8-n)}}}catch(e){if(!(e instanceof p))throw e}return{algorithm:s,curve:c,bits:c?void 0:l.byteLength*8}}function J(e,t,n){let r=v(e,t,0,n);if(!r)return[];let i=[];for(let t of _(e,r,n)){let r=v(e,t,0,n);if(!r)continue;let a=b(e,r),o=!1,s=v(e,t,1,n);if(s?.tag===1&&(o=S(e,s),s=v(e,t,2,n)),!s)continue;let c=y(e,s),l={summary:``,items:[]};try{l=K(e,c,a,n)}catch(e){if(!(e instanceof p))throw e}if(i.push({oid:a,name:N[a]??`Unknown extension`,critical:o,...l}),i.length>=64)break}return i}function Y(e){let t=m(),n=g(e,0,e.byteLength,t);if(n.tag!==48||n.end!==e.byteLength)throw new p(`Certificate is not a single DER SEQUENCE.`);let r=v(e,n,0,t),i=v(e,n,1,t),a=v(e,n,2,t);if(!r||r.tag!==48||!i||a?.tag!==3)throw new p(`Not a signed X.509 certificate.`);let o=0,s=0,c=v(e,r,o,t);if(c?.tag===160){let n=v(e,c,0,t);n?.tag===2&&(s=Number.parseInt(T(x(e,n),``),16)),o+=1}let l=v(e,r,o++,t),u=v(e,r,o++,t),d=v(e,r,o++,t),f=v(e,r,o++,t),h=v(e,r,o++,t),y=v(e,r,o++,t);if(!l||!d||!f||!h)throw new p(`TBSCertificate is missing required fields.`);let b=_(e,f,t),S=B(e,u,t),C=B(e,i,t),w=S.oid||C.oid,E=q(e,y,t),O;for(let n=o;n<o+3;n+=1){let i=v(e,r,n,t);i?.tag===163&&(O=i)}let k=O?J(e,O,t):[],j=k.find(({oid:e})=>e===`2.5.29.19`),M=k.find(({oid:e})=>e===`2.5.29.15`)?.items??[],N=k.find(({oid:e})=>e===`2.5.29.37`)?.items??[],P=k.find(({oid:e})=>e===`2.5.29.17`)?.items??[],F=k.find(({oid:e})=>e===`2.5.29.32`)?.items??[],I=k.find(({oid:e})=>e===`1.3.6.1.5.5.7.1.1`)?.items??[],L=j?.items.find(e=>e.startsWith(`pathLenConstraint=`));return{version:s+1,serial:T(x(e,l)),subject:V(e,h,t),issuer:V(e,d,t),notBefore:b[0]?D(e,b[0]):void 0,notAfter:b[1]?D(e,b[1]):void 0,signatureAlgorithm:z(w,A),publicKeyAlgorithm:E.algorithm,publicKeyBits:E.bits,publicKeyCurve:E.curve,isCa:j?.summary===`CA certificate`,pathLength:L?Number(L.split(`=`)[1]):void 0,keyUsage:M,extendedKeyUsage:N,subjectAltNames:P.map(e=>{let t=e.indexOf(`: `);return t<0?{type:`name`,value:e}:{type:e.slice(0,t),value:e.slice(t+2)}}),subjectKeyId:k.find(({oid:e})=>e===`2.5.29.14`)?.summary||void 0,authorityKeyId:k.find(({oid:e})=>e===`2.5.29.35`)?.summary||void 0,policies:F,crlDistributionPoints:k.find(({oid:e})=>e===`2.5.29.31`)?.items??[],ocspUrls:I.filter(e=>e.startsWith(`ocsp: `)).map(e=>e.slice(6)),caIssuerUrls:I.filter(e=>e.startsWith(`caIssuers: `)).map(e=>e.slice(11)),extensions:k,der:e}}function ee(e){let t=[];if(e[0]===48)t.push(Y(e));else{let n=new TextDecoder(`utf-8`).decode(e);for(let e of R(n).filter(({label:e})=>e.endsWith(`CERTIFICATE`)))try{t.push(Y(e.der))}catch(e){if(!(e instanceof p))throw e}}if(t.length===0)throw new p(`No readable X.509 certificate in the file.`);return t}async function te(e,t){let n=globalThis.crypto?.subtle;if(!n)return{sha256:``,sha1:``};if(t.aborted)throw new DOMException(`Viewer operation aborted.`,`AbortError`);let r=new Uint8Array(e),[i,a]=await Promise.all([n.digest(`SHA-256`,r),n.digest(`SHA-1`,r)]);return{sha256:T(new Uint8Array(i)),sha1:T(new Uint8Array(a))}}var X={protocolVersion:2,id:`x509-certificate`,name:{en:`X.509 certificate viewer`,"zh-CN":`X.509 证书查看器`},formats:[{name:{en:`X.509 certificate`,"zh-CN":`X.509 证书`},extensions:[`.pem`,`.crt`,`.cer`,`.der`],mimeTypes:[`application/x-pem-file`,`application/pkix-cert`,`application/x-x509-ca-cert`]}],workspaceAccess:`none`},ne=16384,re=8388608,Z=/-----BEGIN (?:TRUSTED |X509 )?CERTIFICATE-----/,ie=/-----BEGIN ([A-Z0-9 ]+)-----/;function ae(e){return Array.from(e,e=>String.fromCharCode(e)).join(``)}async function oe({file:e,signal:t}){if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);if(e.size<64||e.size>re)return 0;let n;try{n=new Uint8Array(await e.slice(0,Math.min(e.size,ne)).arrayBuffer())}catch{if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);return 0}if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);let r=ae(n);if(r.includes(`-----BEGIN `)){if(!Z.test(r))return 0;let e=ie.exec(r);return e&&Z.test(`-----BEGIN ${e[1]}-----`)?4:0}if(n[0]!==48)return 0;try{let t=h(n,0,n.byteLength);if(t.end!==e.size)return 0;let r=h(n,t.contentStart,n.byteLength);if(r.tag!==48||r.end>t.end)return 0;let i=h(n,r.end,n.byteLength);return i.tag===48&&i.end<=t.end?4:0}catch(e){if(!(e instanceof p))throw e;return 0}}function se(t){return e(t,{en:{summary:`Certificate summary`,subject:`Subject`,issuer:`Issuer`,serialNumber:`Serial number`,notBefore:`Valid from`,notAfter:`Valid to`,version:`Version`,signatureAlgorithm:`Signature algorithm`,publicKey:`Public key`,keyUsage:`Key usage`,extendedKeyUsage:`Extended key usage`,fingerprintSha256:`SHA-256 fingerprint`,fingerprintSha1:`SHA-1 fingerprint`,subjectAltNames:`Subject alternative names`,extensions:`Extensions`,registration:`Revocation and policies`,crl:`CRL distribution points`,ocsp:`OCSP responders`,caIssuers:`CA issuers`,policies:`Certificate policies`,subjectKeyId:`Subject key identifier`,authorityKeyId:`Authority key identifier`,expired:`Expired`,notYetValid:`Not yet valid`,valid:`Currently valid`,caBadge:`CA certificate`,leafBadge:`End entity`,critical:`critical`,none:`None`,certificates:`Certificates`,fileSize:`File size`,pathLength:`Path length constraint`},"zh-CN":{summary:`证书摘要`,subject:`使用者`,issuer:`颁发者`,serialNumber:`序列号`,notBefore:`生效时间`,notAfter:`到期时间`,version:`版本`,signatureAlgorithm:`签名算法`,publicKey:`公钥`,keyUsage:`密钥用途`,extendedKeyUsage:`扩展密钥用途`,fingerprintSha256:`SHA-256 指纹`,fingerprintSha1:`SHA-1 指纹`,subjectAltNames:`使用者可选名称`,extensions:`扩展`,registration:`吊销与策略`,crl:`CRL 分发点`,ocsp:`OCSP 响应地址`,caIssuers:`CA 证书地址`,policies:`证书策略`,subjectKeyId:`使用者密钥标识`,authorityKeyId:`颁发者密钥标识`,expired:`已过期`,notYetValid:`尚未生效`,valid:`当前有效`,caBadge:`CA 证书`,leafBadge:`终端实体`,critical:`关键`,none:`无`,certificates:`证书`,fileSize:`文件大小`,pathLength:`路径长度限制`}})}var ce=`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-DtiyOy_J.js";import{c as r,d as i,f as a,l as o,n as s,r as c,u as l}from"./src-C9Uz3C-q.js";import{t as u}from"./data-table-OJQe3aN5.js";var d=4096,f=3,p=class extends Error{};function m(){return{nodes:d}}function h(e,t,n,r){if(t<0||t+2>n)throw new p(`Truncated DER element.`);if(r&&(--r.nodes,r.nodes<0))throw new p(`Too many DER elements.`);let i=e[t];if((i&31)==31)throw new p(`Unsupported high-tag-number DER element.`);let a=e[t+1],o=a,s=2;if(a===128)throw new p(`Indefinite DER length is not allowed.`);if(a>128){let r=a&127;if(r===0||r>f||t+2+r>n)throw new p(`Unsupported DER length.`);o=0;for(let n=0;n<r;n+=1)o=o*256+e[t+2+n];s+=r}return{tag:i,constructed:!!(i&32),start:t,contentStart:t+s,length:o,end:t+s+o}}function g(e,t,n,r){let i=h(e,t,n,r);if(i.end>n)throw new p(`DER element exceeds its container.`);return i}function _(e,t,n=m()){if(!t.constructed)return[];let r=[],i=t.contentStart;for(;i<t.end;){let a=g(e,i,t.end,n);r.push(a),i=a.end}return r}function v(e,t,n,r){let i=t.contentStart,a=0,o=t.end;for(;i<o;){let t=g(e,i,o,r);if(a===n)return t;a+=1,i=t.end}}function y(e,t){return e.subarray(t.contentStart,t.end)}function b(e,t){let n=y(e,t);if(n.length===0||n.length>64)throw new p(`Invalid OBJECT IDENTIFIER.`);let r=n[0],i=[Math.floor(r/40),r%40],a=0,o=!1;for(let e=1;e<n.length;e+=1){let t=n[e];a=a*128+(t&127),o=!!(t&128),o||(i.push(a),a=0)}if(o)throw new p(`Truncated OBJECT IDENTIFIER.`);return i.join(`.`)}function x(e,t){let n=y(e,t),r=0;for(;r<n.length-1&&n[r]===0;)r+=1;return n.subarray(r)}function S(e,t){let n=y(e,t);return n.length>0&&n[0]!==0}function C(e,t){let n=y(e,t);if(n.length===0)throw new p(`Empty BIT STRING.`);let r=n[0];if(r>7||n.length===1&&r!==0)throw new p(`Invalid BIT STRING padding.`);return n.subarray(1)}function w(e,t){let n=y(e,t);if(t.tag===30){let e=``;for(let t=0;t+1<n.length;t+=2)e+=String.fromCharCode(n[t]<<8|n[t+1]);return e}if(t.tag===28){let e=``;for(let t=0;t+3<n.length;t+=4)e+=String.fromCodePoint(n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]);return e}try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return Array.from(n,e=>String.fromCharCode(e)).join(``)}}function T(e,t=`:`){return Array.from(e,e=>e.toString(16).padStart(2,`0`).toUpperCase()).join(t)}function E(e,t,n){let r=e.slice(t,t+n);if(!(r.length!==n||!/^\d+$/.test(r)))return Number(r)}function D(e,t){let n=Array.from(y(e,t),e=>String.fromCharCode(e)).join(``),r=t.tag===24,i=r?4:2;if(n.length<i+10)return;let a=E(n,0,i),o=E(n,i,2),s=E(n,i+2,2),c=E(n,i+4,2),l=E(n,i+6,2),u=E(n,i+8,2);if(a===void 0||o===void 0||s===void 0||c===void 0||l===void 0||u===void 0)return;r||(a+=a>=50?1900:2e3);let d=Date.UTC(a,o-1,s,c,l,u);if(!Number.isFinite(d))return;let f=new Date(d);return Number.isNaN(f.getTime())?void 0:f}var O=40,k={"2.5.4.3":`CN`,"2.5.4.4":`SN`,"2.5.4.5":`serialNumber`,"2.5.4.6":`C`,"2.5.4.7":`L`,"2.5.4.8":`ST`,"2.5.4.9":`street`,"2.5.4.10":`O`,"2.5.4.11":`OU`,"2.5.4.12":`title`,"2.5.4.17":`postalCode`,"2.5.4.42":`givenName`,"2.5.4.43":`initials`,"2.5.4.65":`pseudonym`,"2.5.4.97":`organizationIdentifier`,"0.9.2342.19200300.100.1.1":`UID`,"0.9.2342.19200300.100.1.25":`DC`,"1.2.840.113549.1.9.1":`emailAddress`,"1.3.6.1.4.1.311.60.2.1.3":`jurisdictionC`},A={"1.2.840.113549.1.1.2":`MD2 with RSA`,"1.2.840.113549.1.1.4":`MD5 with RSA`,"1.2.840.113549.1.1.5":`SHA-1 with RSA`,"1.2.840.113549.1.1.11":`SHA-256 with RSA`,"1.2.840.113549.1.1.12":`SHA-384 with RSA`,"1.2.840.113549.1.1.13":`SHA-512 with RSA`,"1.2.840.113549.1.1.10":`RSASSA-PSS`,"1.2.840.10045.4.1":`ECDSA with SHA-1`,"1.2.840.10045.4.3.2":`ECDSA with SHA-256`,"1.2.840.10045.4.3.3":`ECDSA with SHA-384`,"1.2.840.10045.4.3.4":`ECDSA with SHA-512`,"1.3.101.112":`Ed25519`,"1.3.101.113":`Ed448`,"1.3.101.114":`Ed448`,"2.16.840.1.101.3.4.3.2":`DSA with SHA-256`},j={"1.2.840.113549.1.1.1":`RSA`,"1.2.840.113549.1.1.10":`RSASSA-PSS`,"1.2.840.10045.2.1":`EC`,"1.2.840.10040.4.1":`DSA`,"1.3.101.112":`Ed25519`,"1.3.101.113":`Ed448`},M={"1.2.840.10045.3.1.7":`P-256`,"1.3.132.0.34":`P-384`,"1.3.132.0.35":`P-521`,"1.3.132.0.10":`secp256k1`,"1.3.132.0.33":`P-224`},N={"2.5.29.14":`Subject Key Identifier`,"2.5.29.15":`Key Usage`,"2.5.29.16":`Private Key Usage Period`,"2.5.29.17":`Subject Alternative Name`,"2.5.29.18":`Issuer Alternative Name`,"2.5.29.19":`Basic Constraints`,"2.5.29.30":`Name Constraints`,"2.5.29.31":`CRL Distribution Points`,"2.5.29.32":`Certificate Policies`,"2.5.29.35":`Authority Key Identifier`,"2.5.29.36":`Policy Constraints`,"2.5.29.37":`Extended Key Usage`,"2.5.29.46":`Freshest CRL`,"2.5.29.54":`Inhibit Any Policy`,"1.3.6.1.5.5.7.1.1":`Authority Information Access`,"1.3.6.1.5.5.7.1.11":`Subject Information Access`,"1.3.6.1.4.1.11129.2.4.2":`Signed Certificate Timestamp List`},P={"1.3.6.1.5.5.7.3.1":`TLS server authentication`,"1.3.6.1.5.5.7.3.2":`TLS client authentication`,"1.3.6.1.5.5.7.3.3":`Code signing`,"1.3.6.1.5.5.7.3.4":`Email protection`,"1.3.6.1.5.5.7.3.8":`Time stamping`,"1.3.6.1.5.5.7.3.9":`OCSP signing`,"2.5.29.37.0":`Any extended key usage`},F=[`digitalSignature`,`nonRepudiation`,`keyEncipherment`,`dataEncipherment`,`keyAgreement`,`keyCertSign`,`cRLSign`,`encipherOnly`,`decipherOnly`],I={160:`otherName`,129:`email`,130:`DNS`,163:`x400Address`,164:`directoryName`,165:`ediPartyName`,134:`URI`,135:`IP`,136:`registeredID`},L={"1.3.6.1.5.5.7.48.1":`ocsp`,"1.3.6.1.5.5.7.48.2":`caIssuers`};function R(e){let t=[];for(let n of e.matchAll(/-----BEGIN ([A-Z0-9 ]+)-----([\s\S]*?)-----END \1-----/g)){if(t.length>=O)break;let e=n[2].replace(/[^A-Za-z0-9+/=]/g,``),r;try{r=atob(e)}catch{continue}let i=Uint8Array.from(r,e=>e.charCodeAt(0));i.byteLength>0&&t.push({label:n[1],der:i})}return t}function z(e,t){return t[e]??e}function B(e,t,n){let r=t?v(e,t,0,n):void 0;return{oid:r?b(e,r):``,params:t?v(e,t,1,n):void 0}}function V(e,t,n){let r=[];for(let i of _(e,t,n))for(let t of _(e,i,n)){let i=v(e,t,0,n),a=v(e,t,1,n);if(!i||!a)continue;let o=b(e,i);if(r.push({oid:o,label:k[o]??o,value:w(e,a).trim()}),r.length>64)return{display:``,attributes:r}}return{display:r.map(({label:e,value:t})=>`${e}=${t}`).join(`, `),attributes:r}}function H(e){if(e.byteLength===4)return Array.from(e).join(`.`);if(e.byteLength===16){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return t.join(`:`)}return T(e)}function U(e,t,n){let r=[];for(let i of _(e,t,n)){let t=I[i.tag]??`[${i.tag&31}]`;if(i.tag===135)r.push({type:t,value:H(y(e,i))});else if(i.constructed){let a=_(e,i,n).map(t=>w(e,t)).join(`, `);r.push({type:t,value:a||T(y(e,i))})}else r.push({type:t,value:w(e,i)});if(r.length>128)break}return r}function W(e,t){let n=C(e,t),r=[];return F.forEach((e,t)=>{t<n.length*8&&n[Math.floor(t/8)]&128>>t%8&&r.push(e)}),r}function G(e,t,n,r){if(!(r.length>=16)){if(t.tag===134){r.push(w(e,t));return}if(t.constructed)for(let i of _(e,t,n))G(e,i,n,r)}}function K(e,t,n,r){if(t.byteLength===0)return{summary:``,items:[]};let i=g(t,0,t.byteLength,r);if(n===`2.5.29.19`){let e=!1,n=[];for(let a of _(t,i,r))a.tag===1?e=S(t,a):a.tag===2&&n.push(`pathLenConstraint=${Number.parseInt(T(x(t,a)),16)}`);return{summary:e?`CA certificate`:`End-entity certificate`,items:n}}if(n===`2.5.29.15`)return{summary:``,items:W(t,i)};if(n===`2.5.29.37`)return{summary:``,items:_(t,i,r).map(e=>z(b(t,e),P)).slice(0,64)};if(n===`2.5.29.17`)return{summary:``,items:U(t,i,r).map(({type:e,value:t})=>`${e}: ${t}`)};if(n===`2.5.29.14`)return{summary:T(y(t,i)),items:[]};if(n===`2.5.29.35`){let e=_(t,i,r).find(e=>e.tag===128);return{summary:e?T(y(t,e)):``,items:[]}}if(n===`2.5.29.31`||n===`2.5.29.46`){let e=[];return G(t,i,r,e),{summary:``,items:e}}return n===`1.3.6.1.5.5.7.1.1`?{summary:``,items:_(t,i,r).flatMap(e=>{let n=v(t,e,0,r),i=v(t,e,1,r);if(!n||!i)return[];let a=L[b(t,n)];return a&&i.tag===134?[`${a}: ${w(t,i)}`]:[]})}:n===`2.5.29.32`?{summary:``,items:_(t,i,r).flatMap(e=>{let n=v(t,e,0,r);return n?[b(t,n)]:[]})}:{summary:`${t.byteLength} bytes`,items:[]}}function q(e,t,n){if(!t)return{algorithm:``};let r=v(e,t,0,n),i=v(e,t,1,n),{oid:a,params:o}=B(e,r,n),s=z(a,j),c=o&&o.tag===6?M[b(e,o)]:void 0;if(!i)return{algorithm:s,curve:c};let l=C(e,i);if(a===`1.2.840.113549.1.1.1`&&l.byteLength>0)try{let e=v(l,g(l,0,l.byteLength,n),0,n);if(e){let t=x(l,e),n=t[0].toString(2).length;return{algorithm:s,bits:t.byteLength*8-(8-n)}}}catch(e){if(!(e instanceof p))throw e}return{algorithm:s,curve:c,bits:c?void 0:l.byteLength*8}}function J(e,t,n){let r=v(e,t,0,n);if(!r)return[];let i=[];for(let t of _(e,r,n)){let r=v(e,t,0,n);if(!r)continue;let a=b(e,r),o=!1,s=v(e,t,1,n);if(s?.tag===1&&(o=S(e,s),s=v(e,t,2,n)),!s)continue;let c=y(e,s),l={summary:``,items:[]};try{l=K(e,c,a,n)}catch(e){if(!(e instanceof p))throw e}if(i.push({oid:a,name:N[a]??`Unknown extension`,critical:o,...l}),i.length>=64)break}return i}function Y(e){let t=m(),n=g(e,0,e.byteLength,t);if(n.tag!==48||n.end!==e.byteLength)throw new p(`Certificate is not a single DER SEQUENCE.`);let r=v(e,n,0,t),i=v(e,n,1,t),a=v(e,n,2,t);if(!r||r.tag!==48||!i||a?.tag!==3)throw new p(`Not a signed X.509 certificate.`);let o=0,s=0,c=v(e,r,o,t);if(c?.tag===160){let n=v(e,c,0,t);n?.tag===2&&(s=Number.parseInt(T(x(e,n),``),16)),o+=1}let l=v(e,r,o++,t),u=v(e,r,o++,t),d=v(e,r,o++,t),f=v(e,r,o++,t),h=v(e,r,o++,t),y=v(e,r,o++,t);if(!l||!d||!f||!h)throw new p(`TBSCertificate is missing required fields.`);let b=_(e,f,t),S=B(e,u,t),C=B(e,i,t),w=S.oid||C.oid,E=q(e,y,t),O;for(let n=o;n<o+3;n+=1){let i=v(e,r,n,t);i?.tag===163&&(O=i)}let k=O?J(e,O,t):[],j=k.find(({oid:e})=>e===`2.5.29.19`),M=k.find(({oid:e})=>e===`2.5.29.15`)?.items??[],N=k.find(({oid:e})=>e===`2.5.29.37`)?.items??[],P=k.find(({oid:e})=>e===`2.5.29.17`)?.items??[],F=k.find(({oid:e})=>e===`2.5.29.32`)?.items??[],I=k.find(({oid:e})=>e===`1.3.6.1.5.5.7.1.1`)?.items??[],L=j?.items.find(e=>e.startsWith(`pathLenConstraint=`));return{version:s+1,serial:T(x(e,l)),subject:V(e,h,t),issuer:V(e,d,t),notBefore:b[0]?D(e,b[0]):void 0,notAfter:b[1]?D(e,b[1]):void 0,signatureAlgorithm:z(w,A),publicKeyAlgorithm:E.algorithm,publicKeyBits:E.bits,publicKeyCurve:E.curve,isCa:j?.summary===`CA certificate`,pathLength:L?Number(L.split(`=`)[1]):void 0,keyUsage:M,extendedKeyUsage:N,subjectAltNames:P.map(e=>{let t=e.indexOf(`: `);return t<0?{type:`name`,value:e}:{type:e.slice(0,t),value:e.slice(t+2)}}),subjectKeyId:k.find(({oid:e})=>e===`2.5.29.14`)?.summary||void 0,authorityKeyId:k.find(({oid:e})=>e===`2.5.29.35`)?.summary||void 0,policies:F,crlDistributionPoints:k.find(({oid:e})=>e===`2.5.29.31`)?.items??[],ocspUrls:I.filter(e=>e.startsWith(`ocsp: `)).map(e=>e.slice(6)),caIssuerUrls:I.filter(e=>e.startsWith(`caIssuers: `)).map(e=>e.slice(11)),extensions:k,der:e}}function ee(e){let t=[];if(e[0]===48)t.push(Y(e));else{let n=new TextDecoder(`utf-8`).decode(e);for(let e of R(n).filter(({label:e})=>e.endsWith(`CERTIFICATE`)))try{t.push(Y(e.der))}catch(e){if(!(e instanceof p))throw e}}if(t.length===0)throw new p(`No readable X.509 certificate in the file.`);return t}async function te(e,t){let n=globalThis.crypto?.subtle;if(!n)return{sha256:``,sha1:``};if(t.aborted)throw new DOMException(`Viewer operation aborted.`,`AbortError`);let r=new Uint8Array(e),[i,a]=await Promise.all([n.digest(`SHA-256`,r),n.digest(`SHA-1`,r)]);return{sha256:T(new Uint8Array(i)),sha1:T(new Uint8Array(a))}}var X={protocolVersion:2,id:`x509-certificate`,name:{en:`X.509 certificate viewer`,"zh-CN":`X.509 证书查看器`},formats:[{name:{en:`X.509 certificate`,"zh-CN":`X.509 证书`},extensions:[`.pem`,`.crt`,`.cer`,`.der`],mimeTypes:[`application/x-pem-file`,`application/pkix-cert`,`application/x-x509-ca-cert`]}],workspaceAccess:`none`},ne=16384,re=8388608,Z=/-----BEGIN (?:TRUSTED |X509 )?CERTIFICATE-----/,ie=/-----BEGIN ([A-Z0-9 ]+)-----/;function ae(e){return Array.from(e,e=>String.fromCharCode(e)).join(``)}async function oe({file:e,signal:t}){if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);if(e.size<64||e.size>re)return 0;let n;try{n=new Uint8Array(await e.slice(0,Math.min(e.size,ne)).arrayBuffer())}catch{if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);return 0}if(t.aborted)throw new DOMException(`__anyfile_certificate_probe_v1__: aborted`,`AbortError`);let r=ae(n);if(r.includes(`-----BEGIN `)){if(!Z.test(r))return 0;let e=ie.exec(r);return e&&Z.test(`-----BEGIN ${e[1]}-----`)?4:0}if(n[0]!==48)return 0;try{let t=h(n,0,n.byteLength);if(t.end!==e.size)return 0;let r=h(n,t.contentStart,n.byteLength);if(r.tag!==48||r.end>t.end)return 0;let i=h(n,r.end,n.byteLength);return i.tag===48&&i.end<=t.end?4:0}catch(e){if(!(e instanceof p))throw e;return 0}}function se(t){return e(t,{en:{summary:`Certificate summary`,subject:`Subject`,issuer:`Issuer`,serialNumber:`Serial number`,notBefore:`Valid from`,notAfter:`Valid to`,version:`Version`,signatureAlgorithm:`Signature algorithm`,publicKey:`Public key`,keyUsage:`Key usage`,extendedKeyUsage:`Extended key usage`,fingerprintSha256:`SHA-256 fingerprint`,fingerprintSha1:`SHA-1 fingerprint`,subjectAltNames:`Subject alternative names`,extensions:`Extensions`,registration:`Revocation and policies`,crl:`CRL distribution points`,ocsp:`OCSP responders`,caIssuers:`CA issuers`,policies:`Certificate policies`,subjectKeyId:`Subject key identifier`,authorityKeyId:`Authority key identifier`,expired:`Expired`,notYetValid:`Not yet valid`,valid:`Currently valid`,caBadge:`CA certificate`,leafBadge:`End entity`,critical:`critical`,none:`None`,certificates:`Certificates`,fileSize:`File size`,pathLength:`Path length constraint`},"zh-CN":{summary:`证书摘要`,subject:`使用者`,issuer:`颁发者`,serialNumber:`序列号`,notBefore:`生效时间`,notAfter:`到期时间`,version:`版本`,signatureAlgorithm:`签名算法`,publicKey:`公钥`,keyUsage:`密钥用途`,extendedKeyUsage:`扩展密钥用途`,fingerprintSha256:`SHA-256 指纹`,fingerprintSha1:`SHA-1 指纹`,subjectAltNames:`使用者可选名称`,extensions:`扩展`,registration:`吊销与策略`,crl:`CRL 分发点`,ocsp:`OCSP 响应地址`,caIssuers:`CA 证书地址`,policies:`证书策略`,subjectKeyId:`使用者密钥标识`,authorityKeyId:`颁发者密钥标识`,expired:`已过期`,notYetValid:`尚未生效`,valid:`当前有效`,caBadge:`CA 证书`,leafBadge:`终端实体`,critical:`关键`,none:`无`,certificates:`证书`,fileSize:`文件大小`,pathLength:`路径长度限制`}})}var ce=`
2
2
  .anyfile-certificate-viewer .anyfile-inspector__section { max-width:1100px; margin-inline:auto; }
3
3
  .anyfile-certificate-viewer__list { margin:0; padding-inline-start:18px; font-size:13px; }
4
4
  .anyfile-certificate-viewer__list li { overflow-wrap:anywhere; }
@@ -1 +1 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,n,o as r}from"./index-BCxD9rBl.js";import{H as i,K as a,g as o,j as s,k as c,n as l,o as u,s as d,t as f}from"./src-DsVDi0pr.js";var p={protocolVersion:2,id:`cad-exchange`,name:{en:`CAD exchange viewer`,"zh-CN":`CAD 交换格式查看器`},formats:[{name:{en:`STEP, IGES and BREP`,"zh-CN":`STEP、IGES 与 BREP`},extensions:[`.step`,`.stp`,`.iges`,`.igs`,`.brep`]}],workspaceAccess:`none`};function m(e,t){let n=new o;try{let r=e.meshes.map(e=>{let t=new o;t.name=e.name;let r=new d;if(r.setAttribute(`position`,new u(e.positions,3)),r.setAttribute(`color`,new u(e.colors,3)),r.setIndex(new u(e.indices,1)),e.normals?r.setAttribute(`normal`,new u(e.normals,3)):r.computeVertexNormals(),t.add(new i(r,new a({vertexColors:!0,side:2,roughness:.8,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}))),e.edges.length){let n=new d;n.setAttribute(`position`,new u(e.edges,3)),t.add(new s(n,new c({color:5265250})))}return n.add(t),t}),l=new o,f=(e,t,n)=>{if(n>64)throw RangeError();let i=new o;i.name=e.name,t.add(i);for(let t of e.meshes){if(!r[t])throw Error(`Invalid assembly mesh`);i.add(r[t].clone(!0))}for(let t of e.children)f(t,i,n+1)};f(e.root,l,0);let p=l;for(;p.children.length===1&&p.children[0]instanceof o&&p.children[0].children.every(e=>e instanceof o);)p=p.children[0];return n.clear(),n.add(...p.children),n.userData.origin=e.origin,n.userData.kernelHeapBytes=e.heapBytes,{root:n,up:`z`,units:t?void 0:`mm`}}catch(e){throw l(n),e}}var h=`0.0.23-anyfile.1`,g=[{name:`R2`,value:`https://assets.anyfile.top/vendor/occt-import-js/${h}/occt-import-js.js`},{name:`local`,value:`/vendor/occt-import-js/${h}/occt-import-js.js`}],_=class{constructor(e,t){this.signal=e,this.copy=t,this.worker=new Worker(new URL(`/renderer-host/assets/kernel.worker-D88TbQnz.js`,``+import.meta.url),{type:`module`}),this.disposed=!1,this.dispose=()=>{this.disposed||(this.disposed=!0,this.signal.removeEventListener(`abort`,this.dispose),this.cancel?.(),this.worker.terminate())},e.addEventListener(`abort`,this.dispose,{once:!0})}async initialize(e){if((await this.request({type:`init`,runtimeUrl:new URL(e,location.origin).href})).type!==`ready`)throw new t(`unsupported-environment`,this.copy.unsupported)}async open(e,n){let r=await this.request({type:`open`,bytes:e,format:n},[e]);if(r.type!==`opened`)throw new t(`open-failed`,this.copy.invalid);return r.result}request(e,n=[]){return this.disposed||this.signal.aborted?Promise.reject(r()):new Promise((i,a)=>{let o=()=>{clearTimeout(c),this.worker.onmessage=null,this.worker.onerror=null,this.cancel=void 0},s=e=>{o(),a(e)},c=e.type===`init`?setTimeout(()=>{s(new t(`unsupported-environment`,this.copy.unsupported))},2e4):void 0;this.cancel=()=>s(r()),this.worker.onerror=()=>s(new t(`open-failed`,this.copy.invalid)),this.worker.onmessage=({data:e})=>{o(),e.type===`error`?a(new t(e.code,e.code===`resource-limit`?this.copy.limit:e.code===`unsupported-environment`?this.copy.unsupported:this.copy.invalid)):i(e)};try{this.worker.postMessage(e,n)}catch(e){o(),a(e)}})}};async function v(e,i){try{return await n({signal:e,sources:g,errorMessage:i.unsupported,async createAttempt(t){let n=new _(e,i);return{async initialize(){return await n.initialize(t.value),n},dispose(){n.dispose()}}}})}catch(n){throw e.aborted||n instanceof DOMException&&n.name===`AbortError`?r():new t(`runtime-unavailable`,i.unsupported,{cause:n})}}var y={manifest:p,async open({file:n,signal:r,locale:i,container:a,reportProgress:o,reportPreview:s}){let c=e(i,{en:{loading:`Tessellating CAD geometry locally…`,invalid:`The CAD file could not be tessellated.`,limit:`CAD input or tessellation exceeds its resource budget (128 MiB input, 256 MiB kernel heap).`,unsupported:`The CAD WebAssembly runtime is unavailable.`},"zh-CN":{loading:`正在本地离散化 CAD 几何…`,invalid:`无法将 CAD 文件离散化为可见几何。`,limit:`CAD 输入或离散化结果超限(输入 128 MiB,内核堆 256 MiB)。`,unsupported:`CAD WebAssembly 运行环境不可用。`}});if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n.size>134217728)throw new t(`resource-limit`,c.limit);o({stage:`tessellation`,message:c.loading});let l=await n.arrayBuffer();if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);let u=n.name.split(`.`).pop()?.toLowerCase(),d=u===`brep`?`brep`:u===`igs`||u===`iges`?`iges`:`step`,p=await v(r,c),h;try{h=await p.open(l,d)}finally{p.dispose()}if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);let g=!1,_=f(a,m(h,d===`brep`),i,n.name,()=>{!g&&!r.aborted&&s?.({outcome:`success`,kind:`static`})}),y=()=>{g||(g=!0,r.removeEventListener(`abort`,y),_.dispose())};return r.addEventListener(`abort`,y,{once:!0}),{dispose:y,captureImage:_.captureImage}}};export{y as cadExchangeViewer};
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,n,o as r}from"./index-DtiyOy_J.js";import{H as i,K as a,g as o,j as s,k as c,n as l,o as u,s as d,t as f}from"./src-MO5bLsLj.js";var p={protocolVersion:2,id:`cad-exchange`,name:{en:`CAD exchange viewer`,"zh-CN":`CAD 交换格式查看器`},formats:[{name:{en:`STEP, IGES and BREP`,"zh-CN":`STEP、IGES 与 BREP`},extensions:[`.step`,`.stp`,`.iges`,`.igs`,`.brep`]}],workspaceAccess:`none`};function m(e,t){let n=new o;try{let r=e.meshes.map(e=>{let t=new o;t.name=e.name;let r=new d;if(r.setAttribute(`position`,new u(e.positions,3)),r.setAttribute(`color`,new u(e.colors,3)),r.setIndex(new u(e.indices,1)),e.normals?r.setAttribute(`normal`,new u(e.normals,3)):r.computeVertexNormals(),t.add(new i(r,new a({vertexColors:!0,side:2,roughness:.8,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}))),e.edges.length){let n=new d;n.setAttribute(`position`,new u(e.edges,3)),t.add(new s(n,new c({color:5265250})))}return n.add(t),t}),l=new o,f=(e,t,n)=>{if(n>64)throw RangeError();let i=new o;i.name=e.name,t.add(i);for(let t of e.meshes){if(!r[t])throw Error(`Invalid assembly mesh`);i.add(r[t].clone(!0))}for(let t of e.children)f(t,i,n+1)};f(e.root,l,0);let p=l;for(;p.children.length===1&&p.children[0]instanceof o&&p.children[0].children.every(e=>e instanceof o);)p=p.children[0];return n.clear(),n.add(...p.children),n.userData.origin=e.origin,n.userData.kernelHeapBytes=e.heapBytes,{root:n,up:`z`,units:t?void 0:`mm`}}catch(e){throw l(n),e}}var h=`0.0.23-anyfile.1`,g=[{name:`R2`,value:`https://assets.anyfile.top/vendor/occt-import-js/${h}/occt-import-js.js`},{name:`local`,value:`/vendor/occt-import-js/${h}/occt-import-js.js`}],_=class{constructor(e,t){this.signal=e,this.copy=t,this.worker=new Worker(new URL(`/renderer-host/assets/kernel.worker-D88TbQnz.js`,``+import.meta.url),{type:`module`}),this.disposed=!1,this.dispose=()=>{this.disposed||(this.disposed=!0,this.signal.removeEventListener(`abort`,this.dispose),this.cancel?.(),this.worker.terminate())},e.addEventListener(`abort`,this.dispose,{once:!0})}async initialize(e){if((await this.request({type:`init`,runtimeUrl:new URL(e,location.origin).href})).type!==`ready`)throw new t(`unsupported-environment`,this.copy.unsupported)}async open(e,n){let r=await this.request({type:`open`,bytes:e,format:n},[e]);if(r.type!==`opened`)throw new t(`open-failed`,this.copy.invalid);return r.result}request(e,n=[]){return this.disposed||this.signal.aborted?Promise.reject(r()):new Promise((i,a)=>{let o=()=>{clearTimeout(c),this.worker.onmessage=null,this.worker.onerror=null,this.cancel=void 0},s=e=>{o(),a(e)},c=e.type===`init`?setTimeout(()=>{s(new t(`unsupported-environment`,this.copy.unsupported))},2e4):void 0;this.cancel=()=>s(r()),this.worker.onerror=()=>s(new t(`open-failed`,this.copy.invalid)),this.worker.onmessage=({data:e})=>{o(),e.type===`error`?a(new t(e.code,e.code===`resource-limit`?this.copy.limit:e.code===`unsupported-environment`?this.copy.unsupported:this.copy.invalid)):i(e)};try{this.worker.postMessage(e,n)}catch(e){o(),a(e)}})}};async function v(e,i){try{return await n({signal:e,sources:g,errorMessage:i.unsupported,async createAttempt(t){let n=new _(e,i);return{async initialize(){return await n.initialize(t.value),n},dispose(){n.dispose()}}}})}catch(n){throw e.aborted||n instanceof DOMException&&n.name===`AbortError`?r():new t(`runtime-unavailable`,i.unsupported,{cause:n})}}var y={manifest:p,async open({file:n,signal:r,locale:i,container:a,reportProgress:o,reportPreview:s}){let c=e(i,{en:{loading:`Tessellating CAD geometry locally…`,invalid:`The CAD file could not be tessellated.`,limit:`CAD input or tessellation exceeds its resource budget (128 MiB input, 256 MiB kernel heap).`,unsupported:`The CAD WebAssembly runtime is unavailable.`},"zh-CN":{loading:`正在本地离散化 CAD 几何…`,invalid:`无法将 CAD 文件离散化为可见几何。`,limit:`CAD 输入或离散化结果超限(输入 128 MiB,内核堆 256 MiB)。`,unsupported:`CAD WebAssembly 运行环境不可用。`}});if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);if(n.size>134217728)throw new t(`resource-limit`,c.limit);o({stage:`tessellation`,message:c.loading});let l=await n.arrayBuffer();if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);let u=n.name.split(`.`).pop()?.toLowerCase(),d=u===`brep`?`brep`:u===`igs`||u===`iges`?`iges`:`step`,p=await v(r,c),h;try{h=await p.open(l,d)}finally{p.dispose()}if(r.aborted)throw new DOMException(`Aborted`,`AbortError`);let g=!1,_=f(a,m(h,d===`brep`),i,n.name,()=>{!g&&!r.aborted&&s?.({outcome:`success`,kind:`static`})}),y=()=>{g||(g=!0,r.removeEventListener(`abort`,y),_.dispose())};return r.addEventListener(`abort`,y,{once:!0}),{dispose:y,captureImage:_.captureImage}}};export{y as cadExchangeViewer};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-BCxD9rBl.js";import{a as r,c as i,d as a,f as o,n as s,r as c,u as l}from"./src-C9Uz3C-q.js";var u={protocolVersion:2,id:`apple-plist`,name:{en:`Apple property list viewer`,"zh-CN":`Apple 属性列表查看器`},formats:[{name:{en:`Apple property list`,"zh-CN":`Apple 属性列表`},extensions:[`.plist`],mimeTypes:[`application/x-plist`,`application/xml`]}],workspaceAccess:`none`},d=class extends Error{constructor(e,t,n){super(t,n),this.code=e,this.name=`PlistError`}},f={maxNodes:5e5,maxDepth:2048,maxDataBytes:67108864},p=Date.UTC(2001,0,1);function m(e,t,n){let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return r}function h(e,t){let n=BigInt(0);for(let r=0;r<8;r+=1)n=n<<BigInt(8)|BigInt(e[t+r]);return n}function g(e,t,n){let r=[];for(let i=0;i+1<n;i+=2)r.push(e[t+i]<<8|e[t+i+1]);let i=``;for(let e=0;e<r.length;e+=8192)i+=String.fromCharCode(...r.slice(e,e+8192));return i}var _=class{constructor(e){this.bytes=e,this.nodeCount=0,this.cache=new Map;let t=e.byteLength;if(t<40)throw new d(`invalid-file`,`Binary plist is too short.`);let n=t-32;this.offsetSize=e[n+6],this.objectRefSize=e[n+7],this.objectCount=m(e,n+8,8),this.topObject=m(e,n+16,8);let r=m(e,n+24,8);if(this.offsetSize<1||this.offsetSize>8||this.objectRefSize<1||this.objectRefSize>8)throw new d(`invalid-file`,`Binary plist has an invalid offset or reference size.`);if(this.objectCount<1||this.objectCount>f.maxNodes)throw new d(this.objectCount>f.maxNodes?`resource-limit`:`invalid-file`,`Binary plist has an invalid object count.`);if(r<8||r+this.objectCount*this.offsetSize>n)throw new d(`invalid-file`,`Binary plist offset table is out of range.`);if(this.topObject>=this.objectCount)throw new d(`invalid-file`,`Binary plist top object is out of range.`);this.offsets=Array(this.objectCount);for(let t=0;t<this.objectCount;t+=1){let n=m(e,r+t*this.offsetSize,this.offsetSize);if(n<8||n>=r)throw new d(`invalid-file`,`Binary plist object offset is out of range.`);this.offsets[t]=n}}read(){return this.readObject(this.topObject,0)}readObject(e,t){let n=this.cache.get(e);if(n)return n;if(t>f.maxDepth)throw new d(`resource-limit`,`Binary plist nesting is too deep.`);if(e<0||e>=this.objectCount)throw new d(`invalid-file`,`Binary plist references an out-of-range object.`);if(++this.nodeCount>f.maxNodes)throw new d(`resource-limit`,`Binary plist has too many objects.`);let r=this.offsets[e],i=this.bytes[r],a=i>>4,o=i&15,s=this.decode(r,a,o,t);return this.cache.set(e,s),s}decode(e,t,n,r){let i=this.bytes;switch(t){case 0:if(n===0)return{kind:`null`};if(n===8)return{kind:`boolean`,value:!1};if(n===9)return{kind:`boolean`,value:!0};throw new d(`invalid-file`,`Unsupported binary plist marker 0x${t.toString(16)}${n.toString(16)}.`);case 1:{let t=1<<n;if(e+1+t>i.length)throw new d(`invalid-file`,`Binary plist integer is out of range.`);if(t===8)return{kind:`integer`,value:BigInt.asIntN(64,h(i,e+1))};let r=BigInt(0);for(let n=0;n<t;n+=1)r=r<<BigInt(8)|BigInt(i[e+1+n]);return{kind:`integer`,value:BigInt.asIntN(t*8,r)}}case 2:if(n===2){if(e+1+4>i.length)throw new d(`invalid-file`,`Binary plist real is out of range.`);return{kind:`real`,value:new DataView(i.buffer,i.byteOffset+e+1,4).getFloat32(0,!1)}}if(n===3){if(e+1+8>i.length)throw new d(`invalid-file`,`Binary plist real is out of range.`);return{kind:`real`,value:new DataView(i.buffer,i.byteOffset+e+1,8).getFloat64(0,!1)}}throw new d(`invalid-file`,`Binary plist has an invalid real marker.`);case 3:{if(e+1+8>i.length)throw new d(`invalid-file`,`Binary plist date is out of range.`);let t=new DataView(i.buffer,i.byteOffset+e+1,8).getFloat64(0,!1);return{kind:`date`,value:new Date(p+t*1e3)}}case 4:{let{length:t,start:r}=this.readLengthAndPayload(e,n);if(t>f.maxDataBytes)throw new d(`resource-limit`,`Binary plist data object is too large.`);return{kind:`data`,value:i.subarray(r,r+t)}}case 5:{let{length:t,start:r}=this.readLengthAndPayload(e,n),a=Math.min(r+t,i.length);return{kind:`string`,value:new TextDecoder(`ascii`,{fatal:!1}).decode(i.subarray(r,a))}}case 6:{let{length:t,start:r}=this.readLengthAndPayload(e,n);return{kind:`string`,value:g(i,r,Math.min(r+t*2,i.length)-r)}}case 8:{let t=n+1;if(e+1+t>i.length)throw new d(`invalid-file`,`Binary plist UID is out of range.`);let r=BigInt(0);for(let n=t-1;n>=0;--n)r=r<<BigInt(8)|BigInt(i[e+1+n]);return{kind:`uid`,value:r}}case 10:case 11:case 12:{let{length:t,start:a}=this.readLengthAndPayload(e,n),o=[];for(let e=0;e<t;e+=1){let t=m(i,a+e*this.objectRefSize,this.objectRefSize);o.push(this.readObject(t,r+1))}return{kind:`array`,items:o}}case 13:{let{length:t,start:a}=this.readLengthAndPayload(e,n),o=[];for(let e=0;e<t;e+=1){let n=m(i,a+e*this.objectRefSize,this.objectRefSize),s=m(i,a+(t+e)*this.objectRefSize,this.objectRefSize),c=this.readObject(n,r+1);if(c.kind!==`string`)throw new d(`invalid-file`,`Binary plist dictionary key is not a string.`);o.push({key:c.value,value:this.readObject(s,r+1)})}return{kind:`dict`,entries:o}}default:throw new d(`invalid-file`,`Unsupported binary plist object marker 0x${t.toString(16)}${n.toString(16)}.`)}}readLengthAndPayload(e,t){if(t!==15)return{length:t,start:e+1};let n=e+1,r=this.bytes[n];if(r===void 0||r>>4!=1)throw new d(`invalid-file`,`Binary plist encoded length is invalid.`);let i=1<<(r&15);if(n+1+i>this.bytes.length)throw new d(`invalid-file`,`Binary plist encoded length is out of range.`);return{length:m(this.bytes,n+1,i),start:n+1+i}}};function v(e){if(new TextDecoder(`ascii`).decode(e.subarray(0,8))!==`bplist00`)throw new d(`invalid-file`,`Not a binary property list.`);return new _(e).read()}var y={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function b(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`||t[1]===`X`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return y[t]??e})}var x=new Set([`string`,`integer`,`real`,`date`,`data`,`true`,`false`]);function S(e){if(e.length>f.maxDataBytes*4)throw new d(`resource-limit`,`XML plist is too large.`);if(!e.includes(`<plist`))throw new d(`invalid-file`,`Not an XML property list.`);let t=[],n,r=e,i=0,a=e=>{let r=t[t.length-1];if(!r){if(n!==void 0)throw new d(`invalid-file`,`XML plist has more than one root value.`);n=e;return}if(r.kind===`array`){if(r.items.push(e),r.items.length>f.maxNodes)throw new d(`resource-limit`,`XML plist array is too large.`)}else{if(r.pendingKey===void 0)throw new d(`invalid-file`,`XML plist dictionary value has no key.`);r.entries.push({key:r.pendingKey,value:e}),r.pendingKey=void 0}};for(;i<r.length;){let e=r.indexOf(`<`,i);if(e===-1)break;if(e>i&&(i=e),r.startsWith(`<!--`,e)){let t=r.indexOf(`-->`,e+4);if(t===-1)throw new d(`invalid-file`,`Unterminated XML comment.`);i=t+3;continue}if(r.startsWith(`<?`,e)||r.startsWith(`<!`,e)){let t=r.indexOf(`>`,e+2);if(t===-1)throw new d(`invalid-file`,`Unterminated XML declaration.`);i=t+1;continue}let n=C(r,e+1),o=r.slice(e+1,n);if(i=n+1,o.startsWith(`/`)){let e=o.slice(1).trim();if(e===`dict`||e===`array`){let e=t.pop();if(!e)throw new d(`invalid-file`,`XML plist has an unbalanced closing tag.`);if(e.kind===`dict`){if(e.pendingKey!==void 0)throw new d(`invalid-file`,`XML plist dictionary key has no value.`);a({kind:`dict`,entries:e.entries})}else a({kind:`array`,items:e.items})}continue}let s=o.endsWith(`/`),c=(s?o.slice(0,-1):o).trim().split(/\s+/)[0];if(c===`dict`||c===`array`){if(t.length>=f.maxDepth)throw new d(`resource-limit`,`XML plist nesting is too deep.`);let e=c===`dict`?{kind:`dict`,entries:[]}:{kind:`array`,items:[]};s?a(c===`dict`?{kind:`dict`,entries:[]}:{kind:`array`,items:[]}):t.push(e);continue}if(c===`key`){let{content:e,next:n}=w(r,i);i=n;let a=t[t.length-1];if(!a||a.kind!==`dict`)throw new d(`invalid-file`,`XML plist <key> is outside a dictionary.`);a.pendingKey=b(e);continue}if(c===`true`||c===`false`){if(!s){let{next:e}=w(r,i);i=e}a({kind:`boolean`,value:c===`true`});continue}if(x.has(c)){let{content:e,next:t}=w(r,i);i=t,a(T(c,b(e)));continue}}if(n===void 0)throw new d(`invalid-file`,`XML plist has no value.`);return n}function C(e,t){let n=e.indexOf(`>`,t);if(n===-1)throw new d(`invalid-file`,`Unterminated XML tag.`);return n}function w(e,t){let n=e.indexOf(`</`,t);if(n===-1)throw new d(`invalid-file`,`Unterminated XML element.`);let r=e.slice(t,n),i=e.indexOf(`>`,n);if(i===-1)throw new d(`invalid-file`,`Unterminated XML closing tag.`);return{content:r,next:i+1}}function T(e,t){let n=t.trim();switch(e){case`string`:return{kind:`string`,value:t};case`integer`:if(!/^[+-]?\d+$/.test(n))throw new d(`invalid-file`,`XML plist integer is malformed.`);return{kind:`integer`,value:BigInt(n)};case`real`:{let e=Number(n);if(!Number.isFinite(e))throw new d(`invalid-file`,`XML plist real is malformed.`);return{kind:`real`,value:e}}case`date`:{let e=new Date(n);if(Number.isNaN(e.getTime()))throw new d(`invalid-file`,`XML plist date is malformed.`);return{kind:`date`,value:e}}case`data`:{let e=E(n.replace(/\s+/g,``));if(e.length>f.maxDataBytes)throw new d(`resource-limit`,`XML plist data is too large.`);return{kind:`data`,value:e}}default:throw new d(`invalid-file`,`Unsupported XML plist tag <${e}>.`)}}function E(e){if(e.length===0)return new Uint8Array;let t=e,n=globalThis.atob;if(n)try{let e=n(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{}t=t.replace(/[^A-Za-z0-9+/]/g,``);let r=Math.floor(t.length*3/4),i=new Uint8Array(r),a=0,o=0,s=0;for(let e of t)a=a<<6|`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e),o+=6,o>=8&&(o-=8,i[s++]=a>>o&255);return i.subarray(0,s)}var D=67108864,O=`bplist00`,k=65536;function A(e){if(e.length<8)return!1;for(let t=0;t<8;t+=1)if(e[t]!==O.charCodeAt(t))return!1;return!0}function j(e){if(A(e))return!0;let t=new TextDecoder(`utf-8`,{fatal:!1}).decode(e).trimStart();return t.startsWith(`<plist`)?!0:/^<\?xml/.test(t)||/^<!DOCTYPE\s+plist/.test(t)}async function M(e,t){if(t.aborted)throw N();try{let n=new Uint8Array(await e.slice(0,Math.min(e.size,k)).arrayBuffer());if(t.aborted)throw N();return n}catch(e){throw t.aborted||e?.name===`AbortError`?N():e}}function N(){return new DOMException(`Viewer operation aborted.`,`AbortError`)}async function P(e,t){if(e.size>67108864)throw new d(`resource-limit`,`Property lists above ${D/1048576} MiB are not supported.`);if(t.aborted)throw N();let n=await M(e,t);if(n.length===0)throw new d(`invalid-file`,`The file is empty.`);if(A(n)){let n=new Uint8Array(await e.arrayBuffer());if(t.aborted)throw N();return v(n)}if(!j(n))throw new d(`invalid-file`,`The file is not a property list.`);let r=new TextDecoder(`utf-8`,{fatal:!1}).decode(await e.arrayBuffer());if(t.aborted)throw N();try{return S(r)}catch(e){throw e instanceof d?e:new d(`invalid-file`,`The XML property list is malformed.`,{cause:e})}}function F(t){return e(t,{"zh-CN":{summary:`概览`,root:`根节点`,type:`根类型`,entries:`条目`,filter:`筛选键与值`,empty:`没有匹配的条目`,expand:`展开全部`,collapse:`收起全部`,noValue:`(空)`,dict:`字典`,array:`数组`,string:`字符串`,integer:`整数`,real:`实数`,boolean:`布尔`,date:`日期`,data:`数据`,uid:`UID`,null:`空值`,key:`键`,value:`值`,kind:`类型`,bytes:`字节`,true:`真`,false:`假`},en:{summary:`Overview`,root:`Root`,type:`Root type`,entries:`Entries`,filter:`Filter keys and values`,empty:`No matching entries`,expand:`Expand all`,collapse:`Collapse all`,noValue:`(empty)`,dict:`Dictionary`,array:`Array`,string:`String`,integer:`Integer`,real:`Real`,boolean:`Boolean`,date:`Date`,data:`Data`,uid:`UID`,null:`Null`,key:`Key`,value:`Value`,kind:`Type`,bytes:`bytes`,true:`true`,false:`false`}})}var I=`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-DtiyOy_J.js";import{a as r,c as i,d as a,f as o,n as s,r as c,u as l}from"./src-C9Uz3C-q.js";var u={protocolVersion:2,id:`apple-plist`,name:{en:`Apple property list viewer`,"zh-CN":`Apple 属性列表查看器`},formats:[{name:{en:`Apple property list`,"zh-CN":`Apple 属性列表`},extensions:[`.plist`],mimeTypes:[`application/x-plist`,`application/xml`]}],workspaceAccess:`none`},d=class extends Error{constructor(e,t,n){super(t,n),this.code=e,this.name=`PlistError`}},f={maxNodes:5e5,maxDepth:2048,maxDataBytes:67108864},p=Date.UTC(2001,0,1);function m(e,t,n){let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return r}function h(e,t){let n=BigInt(0);for(let r=0;r<8;r+=1)n=n<<BigInt(8)|BigInt(e[t+r]);return n}function g(e,t,n){let r=[];for(let i=0;i+1<n;i+=2)r.push(e[t+i]<<8|e[t+i+1]);let i=``;for(let e=0;e<r.length;e+=8192)i+=String.fromCharCode(...r.slice(e,e+8192));return i}var _=class{constructor(e){this.bytes=e,this.nodeCount=0,this.cache=new Map;let t=e.byteLength;if(t<40)throw new d(`invalid-file`,`Binary plist is too short.`);let n=t-32;this.offsetSize=e[n+6],this.objectRefSize=e[n+7],this.objectCount=m(e,n+8,8),this.topObject=m(e,n+16,8);let r=m(e,n+24,8);if(this.offsetSize<1||this.offsetSize>8||this.objectRefSize<1||this.objectRefSize>8)throw new d(`invalid-file`,`Binary plist has an invalid offset or reference size.`);if(this.objectCount<1||this.objectCount>f.maxNodes)throw new d(this.objectCount>f.maxNodes?`resource-limit`:`invalid-file`,`Binary plist has an invalid object count.`);if(r<8||r+this.objectCount*this.offsetSize>n)throw new d(`invalid-file`,`Binary plist offset table is out of range.`);if(this.topObject>=this.objectCount)throw new d(`invalid-file`,`Binary plist top object is out of range.`);this.offsets=Array(this.objectCount);for(let t=0;t<this.objectCount;t+=1){let n=m(e,r+t*this.offsetSize,this.offsetSize);if(n<8||n>=r)throw new d(`invalid-file`,`Binary plist object offset is out of range.`);this.offsets[t]=n}}read(){return this.readObject(this.topObject,0)}readObject(e,t){let n=this.cache.get(e);if(n)return n;if(t>f.maxDepth)throw new d(`resource-limit`,`Binary plist nesting is too deep.`);if(e<0||e>=this.objectCount)throw new d(`invalid-file`,`Binary plist references an out-of-range object.`);if(++this.nodeCount>f.maxNodes)throw new d(`resource-limit`,`Binary plist has too many objects.`);let r=this.offsets[e],i=this.bytes[r],a=i>>4,o=i&15,s=this.decode(r,a,o,t);return this.cache.set(e,s),s}decode(e,t,n,r){let i=this.bytes;switch(t){case 0:if(n===0)return{kind:`null`};if(n===8)return{kind:`boolean`,value:!1};if(n===9)return{kind:`boolean`,value:!0};throw new d(`invalid-file`,`Unsupported binary plist marker 0x${t.toString(16)}${n.toString(16)}.`);case 1:{let t=1<<n;if(e+1+t>i.length)throw new d(`invalid-file`,`Binary plist integer is out of range.`);if(t===8)return{kind:`integer`,value:BigInt.asIntN(64,h(i,e+1))};let r=BigInt(0);for(let n=0;n<t;n+=1)r=r<<BigInt(8)|BigInt(i[e+1+n]);return{kind:`integer`,value:BigInt.asIntN(t*8,r)}}case 2:if(n===2){if(e+1+4>i.length)throw new d(`invalid-file`,`Binary plist real is out of range.`);return{kind:`real`,value:new DataView(i.buffer,i.byteOffset+e+1,4).getFloat32(0,!1)}}if(n===3){if(e+1+8>i.length)throw new d(`invalid-file`,`Binary plist real is out of range.`);return{kind:`real`,value:new DataView(i.buffer,i.byteOffset+e+1,8).getFloat64(0,!1)}}throw new d(`invalid-file`,`Binary plist has an invalid real marker.`);case 3:{if(e+1+8>i.length)throw new d(`invalid-file`,`Binary plist date is out of range.`);let t=new DataView(i.buffer,i.byteOffset+e+1,8).getFloat64(0,!1);return{kind:`date`,value:new Date(p+t*1e3)}}case 4:{let{length:t,start:r}=this.readLengthAndPayload(e,n);if(t>f.maxDataBytes)throw new d(`resource-limit`,`Binary plist data object is too large.`);return{kind:`data`,value:i.subarray(r,r+t)}}case 5:{let{length:t,start:r}=this.readLengthAndPayload(e,n),a=Math.min(r+t,i.length);return{kind:`string`,value:new TextDecoder(`ascii`,{fatal:!1}).decode(i.subarray(r,a))}}case 6:{let{length:t,start:r}=this.readLengthAndPayload(e,n);return{kind:`string`,value:g(i,r,Math.min(r+t*2,i.length)-r)}}case 8:{let t=n+1;if(e+1+t>i.length)throw new d(`invalid-file`,`Binary plist UID is out of range.`);let r=BigInt(0);for(let n=t-1;n>=0;--n)r=r<<BigInt(8)|BigInt(i[e+1+n]);return{kind:`uid`,value:r}}case 10:case 11:case 12:{let{length:t,start:a}=this.readLengthAndPayload(e,n),o=[];for(let e=0;e<t;e+=1){let t=m(i,a+e*this.objectRefSize,this.objectRefSize);o.push(this.readObject(t,r+1))}return{kind:`array`,items:o}}case 13:{let{length:t,start:a}=this.readLengthAndPayload(e,n),o=[];for(let e=0;e<t;e+=1){let n=m(i,a+e*this.objectRefSize,this.objectRefSize),s=m(i,a+(t+e)*this.objectRefSize,this.objectRefSize),c=this.readObject(n,r+1);if(c.kind!==`string`)throw new d(`invalid-file`,`Binary plist dictionary key is not a string.`);o.push({key:c.value,value:this.readObject(s,r+1)})}return{kind:`dict`,entries:o}}default:throw new d(`invalid-file`,`Unsupported binary plist object marker 0x${t.toString(16)}${n.toString(16)}.`)}}readLengthAndPayload(e,t){if(t!==15)return{length:t,start:e+1};let n=e+1,r=this.bytes[n];if(r===void 0||r>>4!=1)throw new d(`invalid-file`,`Binary plist encoded length is invalid.`);let i=1<<(r&15);if(n+1+i>this.bytes.length)throw new d(`invalid-file`,`Binary plist encoded length is out of range.`);return{length:m(this.bytes,n+1,i),start:n+1+i}}};function v(e){if(new TextDecoder(`ascii`).decode(e.subarray(0,8))!==`bplist00`)throw new d(`invalid-file`,`Not a binary property list.`);return new _(e).read()}var y={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function b(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g,(e,t)=>{if(t[0]===`#`){let n=t[1]===`x`||t[1]===`X`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return y[t]??e})}var x=new Set([`string`,`integer`,`real`,`date`,`data`,`true`,`false`]);function S(e){if(e.length>f.maxDataBytes*4)throw new d(`resource-limit`,`XML plist is too large.`);if(!e.includes(`<plist`))throw new d(`invalid-file`,`Not an XML property list.`);let t=[],n,r=e,i=0,a=e=>{let r=t[t.length-1];if(!r){if(n!==void 0)throw new d(`invalid-file`,`XML plist has more than one root value.`);n=e;return}if(r.kind===`array`){if(r.items.push(e),r.items.length>f.maxNodes)throw new d(`resource-limit`,`XML plist array is too large.`)}else{if(r.pendingKey===void 0)throw new d(`invalid-file`,`XML plist dictionary value has no key.`);r.entries.push({key:r.pendingKey,value:e}),r.pendingKey=void 0}};for(;i<r.length;){let e=r.indexOf(`<`,i);if(e===-1)break;if(e>i&&(i=e),r.startsWith(`<!--`,e)){let t=r.indexOf(`-->`,e+4);if(t===-1)throw new d(`invalid-file`,`Unterminated XML comment.`);i=t+3;continue}if(r.startsWith(`<?`,e)||r.startsWith(`<!`,e)){let t=r.indexOf(`>`,e+2);if(t===-1)throw new d(`invalid-file`,`Unterminated XML declaration.`);i=t+1;continue}let n=C(r,e+1),o=r.slice(e+1,n);if(i=n+1,o.startsWith(`/`)){let e=o.slice(1).trim();if(e===`dict`||e===`array`){let e=t.pop();if(!e)throw new d(`invalid-file`,`XML plist has an unbalanced closing tag.`);if(e.kind===`dict`){if(e.pendingKey!==void 0)throw new d(`invalid-file`,`XML plist dictionary key has no value.`);a({kind:`dict`,entries:e.entries})}else a({kind:`array`,items:e.items})}continue}let s=o.endsWith(`/`),c=(s?o.slice(0,-1):o).trim().split(/\s+/)[0];if(c===`dict`||c===`array`){if(t.length>=f.maxDepth)throw new d(`resource-limit`,`XML plist nesting is too deep.`);let e=c===`dict`?{kind:`dict`,entries:[]}:{kind:`array`,items:[]};s?a(c===`dict`?{kind:`dict`,entries:[]}:{kind:`array`,items:[]}):t.push(e);continue}if(c===`key`){let{content:e,next:n}=w(r,i);i=n;let a=t[t.length-1];if(!a||a.kind!==`dict`)throw new d(`invalid-file`,`XML plist <key> is outside a dictionary.`);a.pendingKey=b(e);continue}if(c===`true`||c===`false`){if(!s){let{next:e}=w(r,i);i=e}a({kind:`boolean`,value:c===`true`});continue}if(x.has(c)){let{content:e,next:t}=w(r,i);i=t,a(T(c,b(e)));continue}}if(n===void 0)throw new d(`invalid-file`,`XML plist has no value.`);return n}function C(e,t){let n=e.indexOf(`>`,t);if(n===-1)throw new d(`invalid-file`,`Unterminated XML tag.`);return n}function w(e,t){let n=e.indexOf(`</`,t);if(n===-1)throw new d(`invalid-file`,`Unterminated XML element.`);let r=e.slice(t,n),i=e.indexOf(`>`,n);if(i===-1)throw new d(`invalid-file`,`Unterminated XML closing tag.`);return{content:r,next:i+1}}function T(e,t){let n=t.trim();switch(e){case`string`:return{kind:`string`,value:t};case`integer`:if(!/^[+-]?\d+$/.test(n))throw new d(`invalid-file`,`XML plist integer is malformed.`);return{kind:`integer`,value:BigInt(n)};case`real`:{let e=Number(n);if(!Number.isFinite(e))throw new d(`invalid-file`,`XML plist real is malformed.`);return{kind:`real`,value:e}}case`date`:{let e=new Date(n);if(Number.isNaN(e.getTime()))throw new d(`invalid-file`,`XML plist date is malformed.`);return{kind:`date`,value:e}}case`data`:{let e=E(n.replace(/\s+/g,``));if(e.length>f.maxDataBytes)throw new d(`resource-limit`,`XML plist data is too large.`);return{kind:`data`,value:e}}default:throw new d(`invalid-file`,`Unsupported XML plist tag <${e}>.`)}}function E(e){if(e.length===0)return new Uint8Array;let t=e,n=globalThis.atob;if(n)try{let e=n(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)r[t]=e.charCodeAt(t);return r}catch{}t=t.replace(/[^A-Za-z0-9+/]/g,``);let r=Math.floor(t.length*3/4),i=new Uint8Array(r),a=0,o=0,s=0;for(let e of t)a=a<<6|`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e),o+=6,o>=8&&(o-=8,i[s++]=a>>o&255);return i.subarray(0,s)}var D=67108864,O=`bplist00`,k=65536;function A(e){if(e.length<8)return!1;for(let t=0;t<8;t+=1)if(e[t]!==O.charCodeAt(t))return!1;return!0}function j(e){if(A(e))return!0;let t=new TextDecoder(`utf-8`,{fatal:!1}).decode(e).trimStart();return t.startsWith(`<plist`)?!0:/^<\?xml/.test(t)||/^<!DOCTYPE\s+plist/.test(t)}async function M(e,t){if(t.aborted)throw N();try{let n=new Uint8Array(await e.slice(0,Math.min(e.size,k)).arrayBuffer());if(t.aborted)throw N();return n}catch(e){throw t.aborted||e?.name===`AbortError`?N():e}}function N(){return new DOMException(`Viewer operation aborted.`,`AbortError`)}async function P(e,t){if(e.size>67108864)throw new d(`resource-limit`,`Property lists above ${D/1048576} MiB are not supported.`);if(t.aborted)throw N();let n=await M(e,t);if(n.length===0)throw new d(`invalid-file`,`The file is empty.`);if(A(n)){let n=new Uint8Array(await e.arrayBuffer());if(t.aborted)throw N();return v(n)}if(!j(n))throw new d(`invalid-file`,`The file is not a property list.`);let r=new TextDecoder(`utf-8`,{fatal:!1}).decode(await e.arrayBuffer());if(t.aborted)throw N();try{return S(r)}catch(e){throw e instanceof d?e:new d(`invalid-file`,`The XML property list is malformed.`,{cause:e})}}function F(t){return e(t,{"zh-CN":{summary:`概览`,root:`根节点`,type:`根类型`,entries:`条目`,filter:`筛选键与值`,empty:`没有匹配的条目`,expand:`展开全部`,collapse:`收起全部`,noValue:`(空)`,dict:`字典`,array:`数组`,string:`字符串`,integer:`整数`,real:`实数`,boolean:`布尔`,date:`日期`,data:`数据`,uid:`UID`,null:`空值`,key:`键`,value:`值`,kind:`类型`,bytes:`字节`,true:`真`,false:`假`},en:{summary:`Overview`,root:`Root`,type:`Root type`,entries:`Entries`,filter:`Filter keys and values`,empty:`No matching entries`,expand:`Expand all`,collapse:`Collapse all`,noValue:`(empty)`,dict:`Dictionary`,array:`Array`,string:`String`,integer:`Integer`,real:`Real`,boolean:`Boolean`,date:`Date`,data:`Data`,uid:`UID`,null:`Null`,key:`Key`,value:`Value`,kind:`Type`,bytes:`bytes`,true:`true`,false:`false`}})}var I=`
2
2
  .anyfile-plist-viewer__tree { font-family: ${o.fontMono}; font-size: 12.5px; padding: 4px 0 24px; }
3
3
  .anyfile-plist-viewer__node { padding-inline-start: 16px; }
4
4
  .anyfile-plist-viewer__row { display:flex; align-items:baseline; gap:6px; padding:2px 4px; border-radius:4px; }
@@ -1 +1 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,s as n}from"./index-BCxD9rBl.js";import{n as r,r as i}from"./src-CBo2yHRk.js";import{n as a,t as o}from"./book-source-28BQcBKR.js";import{a as s,i as c,n as l,r as u,t as d}from"./safe-content-B61Ktgzp.js";import{t as f}from"./zip-source-C5dFTDt7.js";var p={protocolVersion:2,id:`epub-reader`,name:{en:`EPUB reader`,"zh-CN":`EPUB 阅读器`},formats:[{name:{en:`EPUB`,"zh-CN":`EPUB`},extensions:[`.epub`],mimeTypes:[`application/epub+zip`]}],workspaceAccess:`none`},m=`http://purl.org/dc/elements/1.1/`;function h(e){let t={},n=(e,n)=>{let r=n?.replace(/\s+/g,` `).trim();e&&r&&(t[e]??=[]).push(r)},r=u(e,`metadata`)[0];for(let e of r?Array.from(r.querySelectorAll(`*`)):[])e.namespaceURI===m?n(e.localName,e.textContent):e.localName===`meta`&&e.getAttribute(`property`)?n(e.getAttribute(`property`),e.textContent):e.localName===`meta`&&e.getAttribute(`name`)&&n(e.getAttribute(`name`),e.getAttribute(`content`));return t}async function g(e,n){if(new TextDecoder().decode(await e.read(`mimetype`,64,n))!==`application/epub+zip`)throw new t(`invalid-file`,`Invalid EPUB media type.`);if(e.entries.has(`META-INF/encryption.xml`)||e.entries.has(`META-INF/rights.xml`))throw new o(`Protected or obfuscated EPUB`);let r=s(await e.read(`META-INF/container.xml`,l.xml,n)),i=u(r,`rootfile`);if(i.length!==1)throw new t(`invalid-file`,`EPUB requires one package document.`);let a=i[0].getAttribute(`full-path`)??``,d=c(``,a);if(!d?.path)throw new t(`invalid-file`,`Invalid package path.`);let f=s(await e.read(d.path,l.xml,n));if(f.documentElement.localName!==`package`||!/^[23](?:\.|$)/.test(f.documentElement.getAttribute(`version`)??``))throw new t(`invalid-file`,`Unsupported EPUB package.`);if(u(f,`meta`).some(e=>e.getAttribute(`property`)===`rendition:layout`&&e.textContent?.trim()===`pre-paginated`))throw new o(`Fixed-layout EPUB is not supported`);let p=new Map,m=new Map;for(let e of u(f,`item`)){let n=c(d.path,e.getAttribute(`href`)??``);if(!n)continue;let r={id:e.getAttribute(`id`)??``,path:n.path,type:e.getAttribute(`media-type`)??``,properties:(e.getAttribute(`properties`)??``).split(/\s+/)};if(!r.id||m.has(r.id)||p.has(r.path))throw new t(`invalid-file`,`Duplicate EPUB manifest item.`);m.set(r.id,r),p.set(r.path,r)}let g=u(f,`spine`)[0];if(!g)throw new t(`invalid-file`,`Missing EPUB spine.`);let _=u(g,`itemref`).filter(e=>e.getAttribute(`linear`)!==`no`).map(n=>{let r=m.get(n.getAttribute(`idref`)??``);if(!r||!e.entries.has(r.path))throw new t(`missing-related-file`,`Missing EPUB chapter.`);if(r.type!==`application/xhtml+xml`)throw new t(`invalid-file`,`Unsupported EPUB spine content.`);return r});if(!_.length)throw new t(`invalid-file`,`Empty EPUB spine.`);if(_.length>l.chapters)throw new t(`resource-limit`,`EPUB chapter limit exceeded.`);let v=[...p.values()].find(e=>e.properties.includes(`nav`)),y=m.get(g.getAttribute(`toc`)??``),b=[];if(v||y){let t=v??y,r=s(await e.read(t.path,l.xml,n));if(v){let e=u(r,`nav`).find(e=>(e.getAttribute(`epub:type`)??e.getAttributeNS(`http://www.idpf.org/2007/ops`,`type`)??``).split(/\s+/).includes(`toc`));for(let n of e?u(e,`a`):[]){let e=c(t.path,n.getAttribute(`href`)??``);e&&_.some(t=>t.path===e.path)&&b.push({...e,label:n.textContent?.trim()||e.path})}}else for(let e of u(r,`navPoint`)){let n=c(t.path,u(e,`content`)[0]?.getAttribute(`src`)??``);n&&_.some(e=>e.path===n.path)&&b.push({...n,label:u(e,`text`)[0]?.textContent?.trim()||n.path})}}return b.length||b.push(..._.map(e=>({label:e.id,path:e.path,fragment:``}))),{title:u(f,`title`)[0]?.textContent??``,author:u(f,`creator`)[0]?.textContent??``,direction:g.getAttribute(`page-progression-direction`)===`rtl`?`rtl`:`ltr`,items:p,spine:_,toc:b,metadata:h(f)}}function _(t){return{...i(t),...e(t,{en:{invalid:`The EPUB is damaged or uses unsupported content.`,protected:`Protected, obfuscated or fixed-layout EPUB content is not supported. No decryption is attempted.`},"zh-CN":{invalid:`EPUB 已损坏或包含不支持的内容。`,protected:`不支持受保护、字体混淆或固定版式 EPUB;不会尝试解密。`}})}}var v={manifest:p,async open(e){let i=_(e.locale),s=document.createElement(`div`);s.className=`anyfile-epub-reader`;let c=new AbortController,l,u,p=!1,m=()=>{p||(p=!0,c.abort(),e.signal.removeEventListener(`abort`,m),u?.dispose(),s.remove(),l?.dispose())};try{if(a(e.signal),typeof ResizeObserver>`u`||typeof DOMParser>`u`||typeof CSSStyleSheet>`u`)throw new t(`unsupported-environment`,i.environment);e.signal.addEventListener(`abort`,m,{once:!0}),e.reportProgress({stage:`parsing`,message:i.loading}),l=await f(e.file,c.signal);let n=await g(l,c.signal);return a(c.signal),e.container.append(s),u=r(s,{...n,loadSection:(e,t)=>d(l,n,e,t)},e.locale,i),{dispose:m}}catch(r){if(r instanceof o&&!c.signal.aborted)return s.textContent=i.protected,s.setAttribute(`role`,`status`),e.container.append(s),{dispose:m};if(m(),await l?.dispose(),n(r))throw r;let a=r instanceof t?r.code:`invalid-file`;throw new t(a,a===`resource-limit`?i.limit:a===`missing-related-file`?i.missing:a===`unsupported-environment`?i.environment:i.invalid,{cause:r})}}};export{v as epubViewer};
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,s as n}from"./index-DtiyOy_J.js";import{n as r,r as i}from"./src-CRLCRg0N.js";import{n as a,t as o}from"./book-source-28BQcBKR.js";import{a as s,i as c,n as l,r as u,t as d}from"./safe-content-CWHf8jex.js";import{t as f}from"./zip-source-CLF3Hfcg.js";var p={protocolVersion:2,id:`epub-reader`,name:{en:`EPUB reader`,"zh-CN":`EPUB 阅读器`},formats:[{name:{en:`EPUB`,"zh-CN":`EPUB`},extensions:[`.epub`],mimeTypes:[`application/epub+zip`]}],workspaceAccess:`none`},m=`http://purl.org/dc/elements/1.1/`;function h(e){let t={},n=(e,n)=>{let r=n?.replace(/\s+/g,` `).trim();e&&r&&(t[e]??=[]).push(r)},r=u(e,`metadata`)[0];for(let e of r?Array.from(r.querySelectorAll(`*`)):[])e.namespaceURI===m?n(e.localName,e.textContent):e.localName===`meta`&&e.getAttribute(`property`)?n(e.getAttribute(`property`),e.textContent):e.localName===`meta`&&e.getAttribute(`name`)&&n(e.getAttribute(`name`),e.getAttribute(`content`));return t}async function g(e,n){if(new TextDecoder().decode(await e.read(`mimetype`,64,n))!==`application/epub+zip`)throw new t(`invalid-file`,`Invalid EPUB media type.`);if(e.entries.has(`META-INF/encryption.xml`)||e.entries.has(`META-INF/rights.xml`))throw new o(`Protected or obfuscated EPUB`);let r=s(await e.read(`META-INF/container.xml`,l.xml,n)),i=u(r,`rootfile`);if(i.length!==1)throw new t(`invalid-file`,`EPUB requires one package document.`);let a=i[0].getAttribute(`full-path`)??``,d=c(``,a);if(!d?.path)throw new t(`invalid-file`,`Invalid package path.`);let f=s(await e.read(d.path,l.xml,n));if(f.documentElement.localName!==`package`||!/^[23](?:\.|$)/.test(f.documentElement.getAttribute(`version`)??``))throw new t(`invalid-file`,`Unsupported EPUB package.`);if(u(f,`meta`).some(e=>e.getAttribute(`property`)===`rendition:layout`&&e.textContent?.trim()===`pre-paginated`))throw new o(`Fixed-layout EPUB is not supported`);let p=new Map,m=new Map;for(let e of u(f,`item`)){let n=c(d.path,e.getAttribute(`href`)??``);if(!n)continue;let r={id:e.getAttribute(`id`)??``,path:n.path,type:e.getAttribute(`media-type`)??``,properties:(e.getAttribute(`properties`)??``).split(/\s+/)};if(!r.id||m.has(r.id)||p.has(r.path))throw new t(`invalid-file`,`Duplicate EPUB manifest item.`);m.set(r.id,r),p.set(r.path,r)}let g=u(f,`spine`)[0];if(!g)throw new t(`invalid-file`,`Missing EPUB spine.`);let _=u(g,`itemref`).filter(e=>e.getAttribute(`linear`)!==`no`).map(n=>{let r=m.get(n.getAttribute(`idref`)??``);if(!r||!e.entries.has(r.path))throw new t(`missing-related-file`,`Missing EPUB chapter.`);if(r.type!==`application/xhtml+xml`)throw new t(`invalid-file`,`Unsupported EPUB spine content.`);return r});if(!_.length)throw new t(`invalid-file`,`Empty EPUB spine.`);if(_.length>l.chapters)throw new t(`resource-limit`,`EPUB chapter limit exceeded.`);let v=[...p.values()].find(e=>e.properties.includes(`nav`)),y=m.get(g.getAttribute(`toc`)??``),b=[];if(v||y){let t=v??y,r=s(await e.read(t.path,l.xml,n));if(v){let e=u(r,`nav`).find(e=>(e.getAttribute(`epub:type`)??e.getAttributeNS(`http://www.idpf.org/2007/ops`,`type`)??``).split(/\s+/).includes(`toc`));for(let n of e?u(e,`a`):[]){let e=c(t.path,n.getAttribute(`href`)??``);e&&_.some(t=>t.path===e.path)&&b.push({...e,label:n.textContent?.trim()||e.path})}}else for(let e of u(r,`navPoint`)){let n=c(t.path,u(e,`content`)[0]?.getAttribute(`src`)??``);n&&_.some(e=>e.path===n.path)&&b.push({...n,label:u(e,`text`)[0]?.textContent?.trim()||n.path})}}return b.length||b.push(..._.map(e=>({label:e.id,path:e.path,fragment:``}))),{title:u(f,`title`)[0]?.textContent??``,author:u(f,`creator`)[0]?.textContent??``,direction:g.getAttribute(`page-progression-direction`)===`rtl`?`rtl`:`ltr`,items:p,spine:_,toc:b,metadata:h(f)}}function _(t){return{...i(t),...e(t,{en:{invalid:`The EPUB is damaged or uses unsupported content.`,protected:`Protected, obfuscated or fixed-layout EPUB content is not supported. No decryption is attempted.`},"zh-CN":{invalid:`EPUB 已损坏或包含不支持的内容。`,protected:`不支持受保护、字体混淆或固定版式 EPUB;不会尝试解密。`}})}}var v={manifest:p,async open(e){let i=_(e.locale),s=document.createElement(`div`);s.className=`anyfile-epub-reader`;let c=new AbortController,l,u,p=!1,m=()=>{p||(p=!0,c.abort(),e.signal.removeEventListener(`abort`,m),u?.dispose(),s.remove(),l?.dispose())};try{if(a(e.signal),typeof ResizeObserver>`u`||typeof DOMParser>`u`||typeof CSSStyleSheet>`u`)throw new t(`unsupported-environment`,i.environment);e.signal.addEventListener(`abort`,m,{once:!0}),e.reportProgress({stage:`parsing`,message:i.loading}),l=await f(e.file,c.signal);let n=await g(l,c.signal);return a(c.signal),e.container.append(s),u=r(s,{...n,loadSection:(e,t)=>d(l,n,e,t)},e.locale,i),{dispose:m}}catch(r){if(r instanceof o&&!c.signal.aborted)return s.textContent=i.protected,s.setAttribute(`role`,`status`),e.container.append(s),{dispose:m};if(m(),await l?.dispose(),n(r))throw r;let a=r instanceof t?r.code:`invalid-file`;throw new t(a,a===`resource-limit`?i.limit:a===`missing-related-file`?i.missing:a===`unsupported-environment`?i.environment:i.invalid,{cause:r})}}};export{v as epubViewer};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-BCxD9rBl.js";function r(t){return e(t,{en:{calendar:`Calendar`,contacts:`Contacts`,events:`events`,tasks:`Tasks`,search:`Search`,noTitle:`Untitled event`,searchCalendar:`Filter by title, place, description or category`,searchContacts:`Filter by name, organization, email or phone`,noMatch:`Nothing matches this filter.`,noEvents:`This calendar has no events.`,noContacts:`This file has no contacts.`,unscheduled:`No start time`,allDay:`All day`,organizer:`Organizer`,attendees:`Attendees`,details:`Details`,description:`Description`,recurrence:`Repeats`,alarms:`Reminders`,status:`Status`,categories:`Categories`,link:`Link`,due:`Due`,timezone:`Time zone`,version:`Version`,product:`Produced by`,fileSize:`File size`,contents:`Contents`,phone:`Phone`,email:`Email`,address:`Address`,website:`Website`,note:`Note`,birthday:`Birthday`,nickname:`Nickname`,organization:`Organization`,title:`Job title`,photo:`This card contains a photo, which is not displayed.`,unnamed:`Unnamed contact`},"zh-CN":{calendar:`日历`,contacts:`联系人`,events:`个日程`,tasks:`任务`,search:`搜索`,noTitle:`无标题日程`,searchCalendar:`按标题、地点、描述或分类筛选`,searchContacts:`按姓名、组织、邮箱或电话筛选`,noMatch:`没有匹配的内容。`,noEvents:`该日历没有日程。`,noContacts:`该文件没有联系人。`,unscheduled:`没有开始时间`,allDay:`全天`,organizer:`组织者`,attendees:`参与者`,details:`详情`,description:`描述`,recurrence:`重复规则`,alarms:`提醒`,status:`状态`,categories:`分类`,link:`链接`,due:`截止`,timezone:`时区`,version:`版本`,product:`生成程序`,fileSize:`文件大小`,contents:`内容`,phone:`电话`,email:`邮箱`,address:`地址`,website:`网址`,note:`备注`,birthday:`生日`,nickname:`昵称`,organization:`组织`,title:`职位`,photo:`该名片包含照片,未在此显示。`,unnamed:`未命名联系人`}})}function i(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r}function a(){let e=i(`style`);return e.textContent=`
1
+ import{t as e}from"./src-rJN_jaC5.js";import{a as t,o as n}from"./index-DtiyOy_J.js";function r(t){return e(t,{en:{calendar:`Calendar`,contacts:`Contacts`,events:`events`,tasks:`Tasks`,search:`Search`,noTitle:`Untitled event`,searchCalendar:`Filter by title, place, description or category`,searchContacts:`Filter by name, organization, email or phone`,noMatch:`Nothing matches this filter.`,noEvents:`This calendar has no events.`,noContacts:`This file has no contacts.`,unscheduled:`No start time`,allDay:`All day`,organizer:`Organizer`,attendees:`Attendees`,details:`Details`,description:`Description`,recurrence:`Repeats`,alarms:`Reminders`,status:`Status`,categories:`Categories`,link:`Link`,due:`Due`,timezone:`Time zone`,version:`Version`,product:`Produced by`,fileSize:`File size`,contents:`Contents`,phone:`Phone`,email:`Email`,address:`Address`,website:`Website`,note:`Note`,birthday:`Birthday`,nickname:`Nickname`,organization:`Organization`,title:`Job title`,photo:`This card contains a photo, which is not displayed.`,unnamed:`Unnamed contact`},"zh-CN":{calendar:`日历`,contacts:`联系人`,events:`个日程`,tasks:`任务`,search:`搜索`,noTitle:`无标题日程`,searchCalendar:`按标题、地点、描述或分类筛选`,searchContacts:`按姓名、组织、邮箱或电话筛选`,noMatch:`没有匹配的内容。`,noEvents:`该日历没有日程。`,noContacts:`该文件没有联系人。`,unscheduled:`没有开始时间`,allDay:`全天`,organizer:`组织者`,attendees:`参与者`,details:`详情`,description:`描述`,recurrence:`重复规则`,alarms:`提醒`,status:`状态`,categories:`分类`,link:`链接`,due:`截止`,timezone:`时区`,version:`版本`,product:`生成程序`,fileSize:`文件大小`,contents:`内容`,phone:`电话`,email:`邮箱`,address:`地址`,website:`网址`,note:`备注`,birthday:`生日`,nickname:`昵称`,organization:`组织`,title:`职位`,photo:`该名片包含照片,未在此显示。`,unnamed:`未命名联系人`}})}function i(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r}function a(){let e=i(`style`);return e.textContent=`
2
2
  .anyfile-calendar-contacts { box-sizing:border-box; display:flex; height:100%; min-height:0; width:100%; flex-direction:column; overflow:hidden; background:var(--viewer-background,#fff); color:var(--viewer-foreground,#111); font-family:var(--viewer-font-family,system-ui); }
3
3
  .anyfile-calendar-contacts * { box-sizing:border-box; }
4
4
  .anyfile-calendar-contacts__header { flex:none; padding:14px 18px 10px; border-bottom:1px solid var(--viewer-border,#ddd); }