@file-viewer/web-full 2.1.3 → 2.1.4
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.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/flyfish-file-viewer-web-full.iife.js +10 -11643
- package/dist/flyfish-viewer-manifest.json +1 -1
- package/dist/global.d.ts +4 -2
- package/dist/global.js +4 -2
- package/dist/iife.d.ts +40 -0
- package/dist/iife.js +325 -0
- package/dist/renderers/archive.iife.js +358 -0
- package/dist/renderers/cad.iife.js +198 -0
- package/dist/renderers/data.iife.js +154 -0
- package/dist/renderers/drawing.iife.js +3389 -0
- package/dist/renderers/ebook.iife.js +95 -0
- package/dist/renderers/eda.iife.js +146 -0
- package/dist/renderers/email.iife.js +95 -0
- package/dist/renderers/geo.iife.js +30 -0
- package/dist/renderers/image.iife.js +88 -0
- package/dist/renderers/media.iife.js +89 -0
- package/dist/renderers/mindmap.iife.js +57 -0
- package/dist/renderers/model.iife.js +4288 -0
- package/dist/renderers/ofd.iife.js +31 -0
- package/dist/renderers/pdf.iife.js +2097 -0
- package/dist/renderers/presentation.iife.js +108 -0
- package/dist/renderers/spreadsheet.iife.js +121 -0
- package/dist/renderers/text.iife.js +284 -0
- package/dist/renderers/typst.iife.js +109 -0
- package/dist/renderers/word.iife.js +458 -0
- package/package.json +23 -3
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
(function(){var Wl=Object.create,St=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,zl=Object.getOwnPropertyNames,Ul=Object.getPrototypeOf,$l=Object.prototype.hasOwnProperty,E=(e,t)=>()=>(e&&(t=e(e=0)),t),Hl=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),xi=(e,t)=>{let i={};for(var r in e)St(i,r,{get:e[r],enumerable:!0});return t||St(i,Symbol.toStringTag,{value:"Module"}),i},Vl=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var s=zl(t),n=0,a=s.length,o;n<a;n++)o=s[n],!$l.call(e,o)&&o!==i&&St(e,o,{get:(l=>t[l]).bind(null,o),enumerable:!(r=Ol(t,o))||r.enumerable});return e},Xl=(e,t,i)=>(i=e!=null?Wl(Ul(e)):{},Vl(t||!e||!e.__esModule?St(i,"default",{value:e,enumerable:!0}):i,e)),tn,rn,nn,sn,Ct,ki,Gl=E((()=>{tn="wasm/cad/",rn="wasm/cad/dwg-worker.js",nn="wasm/cad/dwfv-render.wasm",sn="http://localhost/",Ct=(e,t,i={})=>{const r=e?String(e):t,s=i.documentBaseUrl||sn,n=i.baseUrl?i.baseUrl.endsWith("/")?i.baseUrl:`${i.baseUrl}/`:s,a=i.baseUrl?new URL(n,s).href:n,o=new URL(r,a).href;return i.trimTrailingSlash?o.replace(/\/+$/,""):o},ki=(e,t)=>({wasmPath:Ct(e?.wasmPath,tn,{documentBaseUrl:t,trimTrailingSlash:!0}),workerUrl:Ct(e?.workerUrl,rn,{documentBaseUrl:t}),dwfWasmUrl:Ct(e?.dwfWasmUrl,nn,{documentBaseUrl:t})})})),an=E((()=>{Gl()})),Ei,Pi,Si,Ci,be,Yl,Le=E((()=>{Ei=["zip","zipx","7z","rar","tar","gz","gzip","tgz","bz2","bzip2","tbz","tbz2","xz","txz","lzma","zst","tzst","cab","ar","cpio","iso","xar","lha","lzh","jar","war","ear","apk","cbz","cbr"],Pi=["glb","gltf","obj","stl","ply","fbx","dae","3ds","3mf","amf","usd","usda","usdc","usdz","kmz","step","stp","iges","igs","ifc","3dm","brep","pcd","wrl","vrml","xyz","vtk","vtp"],Si=["txt","json","js","mjs","cjs","css","java","py","html","htm","jsx","ts","tsx","xml","log","vue","yaml","yml","ini","sh","bash","sql","go","rs","php","c","cpp","cc","h","hpp","cs","diff","patch","bundle","bdl","jsonc","json5","ipynb","toml","proto","hcl","tex","gv","http","react","rb","swift","kt"],Ci=["gif","jpg","jpeg","bmp","tiff","tif","png","svg","webp","avif","ico","heic","heif","jxl"],be=[{id:"office-word-openxml",label:"Word OpenXML",category:"office",extensions:["docx","docm","dotx","dotm"],async:!0,capabilities:{download:!0,print:"adapter",exportHtml:"adapter",zoom:"provider",search:!0}},{id:"office-word-binary",label:"Word Binary",category:"office",extensions:["doc","dot"],async:!0,capabilities:{download:!0,print:"adapter",exportHtml:"adapter",zoom:"provider",search:!0}},{id:"office-presentation",label:"PowerPoint",category:"office",extensions:["pptx","pptm","potx","potm","ppsx","ppsm"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"open-document",label:"Open Document",category:"office",extensions:["rtf","odt","odp"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"spreadsheet-openxml",label:"Spreadsheet",category:"office",extensions:["xlsx","xltx","xlsm","xlsb","xls","xlt","xltm","csv","ods","fods","numbers"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!1,zoom:"provider",search:!0}},{id:"pdf",label:"PDF",category:"document",extensions:["pdf"],async:!0,capabilities:{download:!0,print:"adapter",exportHtml:"adapter",zoom:"provider",search:"provider"}},{id:"ofd",label:"OFD",category:"document",extensions:["ofd"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"typst",label:"Typst",category:"document",extensions:["typ","typst"],async:!0,capabilities:{download:!0,print:"adapter",exportHtml:"adapter",zoom:"provider",search:!0}},{id:"archive",label:"Archive",category:"archive",extensions:Ei,async:!0,capabilities:{download:!0,print:!1,exportHtml:!1,zoom:!1,search:!0}},{id:"email",label:"Email",category:"email",extensions:["eml","msg","mbox"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!0,zoom:!1,search:!0}},{id:"eda",label:"EDA",category:"eda",extensions:["olb","dra","gds","oas","oasis"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:!1,search:!0}},{id:"cad",label:"CAD",category:"cad",extensions:["dxf","dwg","dwf","dwfx","xps"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!1}},{id:"model",label:"3D Model",category:"model",extensions:Pi,async:!0,capabilities:{download:!0,print:!1,exportHtml:!1,zoom:"provider",search:!1}},{id:"geo",label:"Geospatial",category:"geo",extensions:["geojson","kml","gpx","shp"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"drawing",label:"Drawing",category:"drawing",extensions:["excalidraw","drawio","dio","mermaid","mmd","plantuml","puml"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"mindmap",label:"Mind Map",category:"mindmap",extensions:["xmind"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"epub",label:"EPUB",category:"ebook",extensions:["epub"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!0,zoom:!1,search:"provider"}},{id:"umd",label:"UMD",category:"ebook",extensions:["umd"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!0}},{id:"image",label:"Image",category:"image",extensions:Ci,async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:"provider",search:!1}},{id:"markdown",label:"Markdown",category:"markdown",extensions:["md","markdown"],async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:!1,search:!0}},{id:"code",label:"Code and Text",category:"code",extensions:Si,async:!0,capabilities:{download:!0,print:!0,exportHtml:!0,zoom:!1,search:!0}},{id:"video",label:"Video",category:"media",extensions:["mp4","webm","m3u8"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!1,zoom:!1,search:!1}},{id:"audio",label:"Audio",category:"media",extensions:["mp3","mpeg","wav","ogg","oga","opus","m4a","aac","flac","weba","midi","mid"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!1,zoom:!1,search:!1}},{id:"data-asset",label:"Data Asset",category:"asset",extensions:["ttf","otf","woff","woff2","psd","ai","eps","sqlite","wasm","parquet","avro","webarchive"],async:!0,capabilities:{download:!0,print:!1,exportHtml:!0,zoom:!1,search:!0}}],Yl=Object.freeze(Array.from(new Set(be.flatMap(e=>e.extensions))).sort())})),jl,ql,Zl=E((()=>{jl=["[data-viewer-anchor-id]",".pdfViewer .page",".docx-wrapper section",".docx p",".docx li",".docx table",".markdown-body h1",".markdown-body h2",".markdown-body h3",".markdown-body h4",".markdown-body h5",".markdown-body h6",".markdown-body p",".markdown-body li",".markdown-body pre",".markdown-body table","article h1","article h2","article h3","article h4","article h5","article h6","article p","article li","article pre","article table","pre code","p","li","tr","h1","h2","h3","h4","h5","h6","pre","table"].join(","),ql=[".viewer-actions",".viewer-watermark",".state-panel",".pdf-toolbar",".pdf-nav-pane",".flyfish-search-match"].join(",")})),Mi,Ai,Ti,Kl=E((()=>{Mi=new WeakMap,Ai=(e,t)=>{Mi.set(e,t),e.dataset.viewerZoomProvider=e.dataset.viewerZoomProvider||"custom",e.__flyfishViewerZoomProvider=t},Ti=e=>{e&&(Mi.delete(e),delete e.dataset.viewerZoomProvider,delete e.__flyfishViewerZoomProvider)}})),dt=E((()=>{Zl(),Kl()})),Ql,on=E((()=>{dt(),Ql=["script","style","textarea","input","select","button",".viewer-actions",".viewer-watermark",".state-panel",".pdf-toolbar",".pdf-nav-pane",".flyfish-search-match",".textLayer",".annotationLayer",".xfaLayer","svg","canvas","iframe","video","audio"].join(",")})),ln=E((()=>{dt(),on()})),Fi,Ni=E((()=>{dt(),Fi=()=>{const e=new Set;return{emit(){e.forEach(t=>t())},subscribe(t){return e.add(t),()=>{e.delete(t)}}}}})),se,Mt=E((()=>{se=e=>e.trim().replace(/^\./,"").toLowerCase()})),Jl,cn,dn,Ii,hn,un,fn,At,pn,Se,mn,Ve=E((()=>{Jl="zh-CN",cn={"toolbar.zoomGroup":"缩放控制","toolbar.zoomOut":"缩小预览","toolbar.zoomIn":"放大预览","toolbar.zoomReset":"还原比例","toolbar.download":"下载","toolbar.downloadTitle":"下载原始文件","toolbar.print":"打印","toolbar.printTitle":"打印完整渲染内容","toolbar.exportHtml":"HTML","toolbar.exportHtmlTitle":"导出当前渲染后的 HTML","state.ready.title":"预览完成","state.ready.message":"文件内容已完成渲染。","state.empty.title":"暂无文件","state.empty.message":"请选择文件或提供可访问的文件地址后开始预览。","state.unsupported.install.title":"需要装配预览能力","state.unsupported.install.message":"{extension} 格式已在支持矩阵中,但当前项目尚未装配 {rendererLabel} renderer。","state.unsupported.install.description":"推荐安装 {presetPackage},通过 options.preset / options.renderers 注入对应能力{rendererTip};Vite 项目也可以使用 @file-viewer/vite-plugin 自动发现已安装 preset。","state.unsupported.title":"暂不支持在线预览","state.unsupported.message":"不支持{extension}格式的在线预览,请下载后预览或转换为支持的格式。","state.unsupported.description":"支持 Office、PDF、OFD、Typst、压缩包、邮件、OLB/DRA、CAD、地理数据、3D 模型、Excalidraw、draw.io、EPUB、UMD、Markdown、代码/文本、图片、音视频、字体和数据资产的在线预览","state.error.title":"预览失败","preview.downloading":"正在下载文件资源...","preview.streamingPdf":"正在建立 PDF 流式预览...","preview.reading":"正在解析文件内容...","error.download":"下载失败","error.print":"打印失败","error.exportHtml":"导出 HTML 失败","error.noDownloadSource":"当前没有可下载的源文件","error.noExportContent":"当前没有可导出的预览内容","error.printUnavailable":"当前文件类型不支持完整打印,请下载原文件后在本地应用中打印","error.printWindowBlocked":"浏览器拦截了打印窗口","error.remoteDownload":"文件下载失败","error.localRead":"读取文件异常","error.load":"加载文件异常","error.stream":"加载 PDF 流式预览异常","error.beforeOperation":"操作前置校验失败","operation.download":"下载原始文件","operation.print":"打印完整渲染内容","operation.exportHtml":"导出渲染 HTML","operation.zoomIn":"放大预览","operation.zoomOut":"缩小预览","operation.zoomReset":"还原预览比例","pdf.toolbar.toggleNavigation":"切换导航窗格","pdf.toolbar.previousPage":"上一页","pdf.toolbar.nextPage":"下一页","pdf.toolbar.fitWidth":"适合宽度","pdf.toolbar.zoomOut":"缩小","pdf.toolbar.zoomIn":"放大","pdf.toolbar.rotateLeft":"向左旋转","pdf.toolbar.rotateRight":"向右旋转","pdf.nav.typeLabel":"PDF 导航类型","pdf.nav.pagesTab":"页面","pdf.nav.outlineTab":"目录","pdf.nav.pagesTitle":"页面导航","pdf.nav.outlineTitle":"目录导航","pdf.nav.pageCount":"{count} 页","pdf.nav.itemCount":"{count} 项","pdf.nav.pageLabel":"第 {page} 页","pdf.nav.outlineEmpty":"当前 PDF 没有可用目录","pdf.nav.outlineFallbackTitle":"目录 {index}","pdf.thumbnail.alt":"第 {page} 页缩略图","pdf.state.loading":"正在加载 PDF...","pdf.error.browserWindow":"PDF 预览需要浏览器窗口","pdf.error.missingSource":"PDF 缺少可读取的数据源","pdf.error.loadFailed":"PDF 加载失败","pdf.error.notLoaded":"PDF 尚未加载完成,请稍后再试","pdf.error.unloaded":"PDF 已卸载,无法继续打印","pdf.error.canvasUnavailable":"当前浏览器无法创建 PDF 打印画布","pdf.export.pageTitle":"{title} - 第 {page} 页","spreadsheet.loading.kicker":"Excel 表格","spreadsheet.loading.title":"正在解析 Excel 工作簿","spreadsheet.loading.hint":"正在准备工作表、样式和大数据视口,请稍候。","spreadsheet.loading.streaming":"正在平滑补充可视区数据","spreadsheet.tabs.ariaLabel":"工作表列表","spreadsheet.state.parsingWorkbook":"正在解析 Excel 工作簿,请耐心等待...","spreadsheet.state.preparingSheet":"正在准备工作表内容...","spreadsheet.state.preparingSheetNamed":"正在准备「{name}」...","spreadsheet.state.cachedRows":"已缓存 {cached} / {total} 行","spreadsheet.state.rows":"共 {rows} 行,按视口预取平滑加载","spreadsheet.state.rowsAndColumns":"共 {rows} 行,{cols} 列,按视口预取平滑加载","spreadsheet.error.parseFailed":"Excel 解析失败","spreadsheet.error.workerFailed":"Excel Worker 运行失败","archive.error.nestedUnsupported":"不支持 .{type} 格式的在线预览,请下载后预览或转换为支持的格式","archive.loading.readingDirectory":"正在读取压缩包目录...","archive.loading.readingDirectoryHint":"大文件会在 Worker 中解析,避免阻塞主线程。","archive.search.placeholder":"筛选压缩包内文件","archive.preview.title":"压缩包内预览","archive.preview.chooseFile":"请选择一个文件","archive.preview.downloadFile":"下载文件","archive.error.title":"压缩包预览提示","archive.stats.summary":"{count} 个文件 · {size} · {previewable} 个可直接预览","archive.warning.encrypted":"检测到加密内容,当前在线预览不接收密码,建议下载后本地解压。","archive.empty.title":"选择左侧文件即可预览","archive.empty.message":"压缩包只读取目录;文件内容会在点击后按需解压,并在体积允许时缓存到 IndexedDB。","archive.loading.initializingCandidate":"正在初始化 {label}...","archive.loading.initializingCandidateHint":"如果当前服务器没有正确发布 Worker/WASM,会自动切换兼容模式。","archive.error.candidateInitTimeout":"{label} 初始化超时","archive.error.encryptedCheckTimeout":"{label} 加密检测超时","archive.loading.directoryReadyHint":"目录读取完成后,点击内部文件才会按需解压。","archive.error.candidateReadTimeout":"{label} 读取目录超时","archive.loading.workerFallback":"Worker 不可用,正在切换 ZIP/TAR 兼容模式...","archive.loading.workerFallbackHint":"兼容模式无需额外静态 Worker,适合手机 WebView 或本地临时服务器。","archive.notice.workerFallback":"当前环境的 libarchive Worker 未能启动,已自动切换到 ZIP/TAR/GZIP 兼容模式。RAR、7z 等格式仍建议发布 vendor/libarchive/worker-bundle.js 与 libarchive.wasm。","archive.error.tooLarge":"压缩包体积 {size} 超过安全上限 {limit},请下载后在本地解压。","archive.loading.initializingWorker":"正在初始化压缩包解析 Worker...","archive.loading.initializingWorkerHint":"大文件会在 Worker 中解析,避免阻塞主线程。","archive.error.workerInitFailed":"压缩包 Worker 初始化失败","archive.error.entryTooLarge":"压缩包内文件 {name} 体积 {size} 超过预览上限 {limit}。","archive.loading.extracting":"正在按需解压 {name}...","archive.loading.rendering":"正在渲染 {name}...","archive.loading.exporting":"正在导出 {name}...","media.audio.title":"音频预览","media.audio.description":"使用浏览器原生播放器打开,兼容性取决于当前浏览器支持的音频编码。","media.audio.unsupported":"当前浏览器不支持音频播放。","media.video.title":"视频预览","media.video.unsupported":"当前浏览器不支持该视频格式。","media.video.hlsHint":"HLS 会优先使用原始 URL 加载分片;如果传入的是本地单文件清单,请确保分片地址可被浏览器访问。","media.midi.title":"MIDI 文件","media.midi.loading":"正在解析 MIDI 轨道...","media.midi.trackHeader":"轨道","media.midi.instrumentHeader":"乐器","media.midi.channelHeader":"通道","media.midi.noteCountHeader":"音符数","media.midi.durationHeader":"时长","media.midi.durationStat":"时长","media.midi.trackStat":"轨道","media.midi.noteStat":"音符","media.midi.parseFailed":"MIDI 解析失败","email.mbox.subject":"{filename} · 第 1 封","email.mbox.summary":"MBOX 共识别 {count} 封邮件,当前展示第 1 封。","email.error.title":"邮件预览提示","email.meta.from":"发件人","email.meta.to":"收件人","email.meta.cc":"抄送","email.meta.date":"时间","email.tabs.text":"正文","email.tabs.headers":"头信息","email.attachments.title":"附件","email.attachments.empty":"暂无附件","email.attachments.download":"下载附件","email.attachments.opening":"正在打开附件 {name}...","email.attachments.nestedUnavailable":"当前运行环境未提供附件嵌套预览入口,请下载 {name} 后查看。","email.loading.parsing":"正在解析邮件...","data.font.sample":"Flyfish Viewer 轻量预览 AaBbCc 1234567890","data.error.fontFaceUnsupported":"当前浏览器不支持 FontFace API","data.title.font":"字体文件预览","data.title.sqlite":"SQLite 数据库预览","data.title.parquet":"Parquet 列式数据预览","data.title.avro":"Avro 对象容器预览","data.title.wasm":"WebAssembly 模块预览","data.title.eps":"EPS 矢量文件摘要","data.title.ai":"Illustrator 文件摘要","data.title.webarchive":"WebArchive 摘要预览","data.title.summary":"数据资产摘要","data.label.format":"格式","data.label.size":"大小","data.label.rendering":"渲染方式","data.label.objects":"对象数","data.label.sampleTable":"示例表","data.label.rows":"行数","data.label.columns":"列数","data.label.sampleRows":"示例行","data.label.imports":"导入","data.label.exports":"导出","data.label.magic":"Magic","data.label.note":"说明","data.label.container":"容器","data.value.schemaRead":"已读取","data.value.schemaUnread":"未读取","data.note.aiSummary":"非 PDF-compatible AI 按摘要展示","data.note.postscriptSummary":"PostScript 摘要展示","data.note.webarchive":"安全提取可读片段,不执行网页脚本","data.image.alt":"资产预览","psd.title":"PSD 图层预览","psd.action.fit":"适合","psd.action.showAll":"全显","psd.action.hideAll":"全隐","psd.layers.title":"图层","psd.layers.redrawable":"{count} 可重绘","psd.layers.empty":"未发现可展示图层,使用合成图预览。","psd.layers.hidden":"隐藏","drawing.error.viewerLoadFailed":"diagrams.net viewer 加载失败","drawing.error.excalidrawEmpty":"Excalidraw 文件中没有可预览图元","drawing.error.excalidrawTimeout":"Excalidraw 官方导出超时,自动切换 rough.js 兼容渲染","drawing.error.drawioParseFailed":"Draw.io XML 解析失败:{message}","drawing.error.drawioNoModel":"当前 Draw.io 文件没有可直接渲染的 mxGraphModel。","drawing.error.drawioNoElements":"当前 Draw.io 文件没有可预览图元。","drawing.error.viewerInitFailed":"diagrams.net viewer 未正确初始化","drawing.error.drawioTimeout":"diagrams.net 官方 Viewer 加载超时,自动切换本地 SVG 预览","drawing.error.svgParseFailed":"SVG 解析失败","drawing.error.plantumlRenderFailed":"PlantUML SVG 渲染失败:{status}","drawing.title.excalidraw":"Excalidraw 官方 SVG 预览","drawing.title.mermaid":"Mermaid SVG 预览","drawing.title.plantuml":"PlantUML SVG 预览","drawing.title.drawio":"Draw.io 离线 SVG 预览","drawing.toolbar.zoomOut":"缩小","drawing.toolbar.zoomIn":"放大","drawing.toolbar.fit":"适合","drawing.toolbar.fitWidth":"适合宽度","drawing.state.loading":"正在加载绘图预览...","text.code.loadingHighlight":"正在加载高亮...","ebook.toc":"目录","ebook.reading":"阅读中","ebook.itemCount":"{count} 项","epub.title":"EPUB 电子书","epub.previousPage":"上一页","epub.nextPage":"下一页","epub.loading":"正在解析 EPUB...","epub.chapterFallback":"章节 {index}","epub.renderIncomplete":"EPUB 正文渲染未完成,请刷新后重试","umd.title":"UMD 电子书","umd.previousChapter":"上一章","umd.nextChapter":"下一章","umd.loading":"正在解析 UMD...","umd.emptyContent":"未解析到正文内容","umd.chapterFallback":"章节 {index}","umd.galleryFallback":"图集 {index}","umd.warningBodyTooShort":"UMD 正文长度小于声明长度,文件可能不完整","umd.error.unexpectedEnd":"UMD 文件结构不完整,读取时遇到意外结尾","umd.error.invalidFile":"不是有效的 UMD 电子书文件","typst.summaryRenderer":"Typst WASM 渲染器","typst.pageSummary.empty":"0 页","typst.pageSummary.ready":"{count} 页 / {width} x {height} pt","typst.status.compiling":"正在编译","typst.status.failed":"编译失败","typst.status.rendered":"已渲染","typst.loading.title":"正在解析 Typst","typst.loading.hint":"加载编译器并生成页面预览...","typst.error.title":"Typst 渲染失败","typst.error.timeout":"Typst WASM / 字体加载或编译超过 {seconds} 秒","typst.error.timeoutHint":"请检查 Typst compiler WASM、renderer WASM、字体目录的下载速度和缓存策略;弱网或跨境部署可通过 options.typst.renderTimeoutMs 调大浏览器端加载/编译超时。","typst.error.assetHint":"Typst 需要本地 compiler / renderer WASM 和字体目录。请运行 file-viewer-copy-assets,或配置 options.typst.compilerWasmUrl / options.typst.rendererWasmUrl / options.typst.fontAssetsUrl,并确认服务器以 application/wasm 返回 WASM。","typst.error.svgParseFailed":"Typst SVG 解析失败","typst.error.wasmLoadFailed":"Typst WASM 加载失败","xmind.toolbar.zoomOut":"缩小","xmind.toolbar.zoomIn":"放大","xmind.toolbar.fit":"适合","xmind.toolbar.fitTitle":"适配画布","xmind.state.loading":"正在解析 XMind 脑图...","xmind.stats.nodes":"节点","xmind.stats.depth":"层级","xmind.stats.theme":"主题","xmind.stats.template":"模板","xmind.badge.paused":"暂停","xmind.badge.collapsed":"折叠","xmind.badge.floating":"浮动","xmind.badge.summary":"概要","xmind.badge.callout":"标注","xmind.imageResource":"图片资源: {name}","xmind.error.unrecognized":"无法识别 XMind 文件: ZIP 中未找到 content.json 或 content.xml","xmind.error.noCanvas":"XMind 文件中没有可预览的画布","cad.toolbar.fit":"适配","cad.toolbar.zoomOut":"缩小","cad.toolbar.zoomIn":"放大","cad.layers.title":"图层","cad.layers.count":"{count} 项","cad.inspector.title":"结构","cad.inspector.entities":"实体","cad.inspector.blocks":"块","cad.inspector.pages":"页面","cad.inspector.drawn":"绘制","cad.state.loadingViewer":"正在加载 CAD 预览器...","cad.state.parsing":"正在解析 CAD...","cad.error.parseFailed":"CAD 文件解析失败","image.alt":"图片","image.lightbox.alt":"图片预览","image.lightbox.close":"关闭图片预览","gitBundle.error.invalid":"当前文件不是标准 Git bundle。","gitBundle.error.missingPack":"Git bundle header 后未找到 PACK 数据。","gitBundle.notice.delta":"当前 bundle 包含 delta 压缩对象。预览器已在浏览器端解析常规 OFS_DELTA / REF_DELTA;若仍有缺失文件,通常是包体过大、对象过多或依赖外部 prerequisite。","gitBundle.title.history":"历史记录","gitBundle.title.fileTree":"文件树","gitBundle.file.choose":"选择文件查看内容","gitBundle.file.noTree":"当前 bundle 的 tree/blob 可能被 delta 压缩,暂未解析到可展开文件。","gitBundle.file.none":"未解析到文件","gitBundle.history.empty":"当前 bundle 未解析到 commit 对象,仅展示 refs 和 pack 摘要。","gitBundle.toolbar.summary":"{commits} commits · {files} files","gitBundle.meta.bundle":"Bundle","gitBundle.meta.refs":"Refs","gitBundle.meta.commits":"Commits","gitBundle.meta.objects":"Objects","gitBundle.meta.deltas":"Deltas","gitBundle.meta.objectFormat":"Object format","gitBundle.meta.objectTypes":"Object types","geo.error.unrecognized":"无法识别的 GeoJSON 数据","geo.error.xmlParseFailed":"XML 解析失败","geo.error.unsupported":"不支持 .{type} 地理格式","geo.title":"地理数据预览","geo.featureCount":"要素数","geo.bounds":"范围","geo.geometryTypes":"几何类型","geo.aria":"地理数据 SVG 预览","geo.loading":"正在解析地理数据...","model.toolbar.fit":"适配","model.toolbar.rotate":"旋转","model.toolbar.wireframe":"线框","model.toolbar.grid":"网格","model.toolbar.axes":"坐标","model.state.loadingSummary":"正在加载模型","model.state.loading":"正在解析 3D 模型...","model.state.loaded":"模型已加载","model.state.parseFailed":"模型解析失败","model.summary.meshes":"{count} 个网格","model.summary.points":"{count} 个点云","model.error.daeEmpty":"DAE 模型未解析出有效场景","model.error.unsupported":"暂不支持 .{type} 模型格式","model.error.parseFailed":"{type} 模型解析失败","model.notice.signature":"检测到文件签名: {signature}。","loading.generic.label":"文件内容","loading.generic.hint":"正在整理内容结构并生成预览。","loading.word.label":"Word 文档","loading.word.hint":"正在准备分页、文本样式和文档结构。","loading.wordWorker.hint":"正在通过 Worker 准备文档结构、文本样式和分页结果。","loading.sheet.label":"Excel 表格","loading.sheet.hint":"正在准备工作表、样式和可视区数据。","loading.csv.label":"表格数据","loading.csv.hint":"正在准备行列数据和基础样式。","loading.presentation.label":"PPT 演示文稿","loading.presentation.hint":"正在构建幻灯片布局和媒体内容。","loading.pdf.label":"PDF 文档","loading.pdf.hint":"正在载入页面位图、文本层和缩放视图。","loading.ofd.label":"OFD 版式文件","loading.ofd.hint":"正在解析国产版式文档和页面对象。","loading.archive.label":"压缩包","loading.archive.hint":"正在启动 Worker 并读取压缩包目录。","loading.email.label":"邮件文件","loading.email.hint":"正在解析邮件头、正文和附件。","loading.msg.hint":"正在解析 Outlook 邮件和附件。","loading.eda.label":"EDA 文件","loading.eda.hint":"正在读取 EDA 容器结构和可读属性。","loading.cad.label":"CAD 图纸","loading.cad.hint":"正在准备 CAD 图层、几何对象和画布视图。","loading.dwg.hint":"正在通过 Worker 加载 DWG 几何和 LibreDWG WASM。","loading.dwf.hint":"正在加载 DWF native renderer 与 W2D/W3D 图形。","loading.dwfx.hint":"正在加载 DWFx/XPS native renderer 与页面图形。","loading.xps.hint":"正在加载 XPS native renderer 与嵌入字体。","loading.drawio.label":"draw.io 图纸","loading.drawio.hint":"正在解析图元、连线和 SVG 预览。","loading.excalidraw.label":"Excalidraw 图纸","loading.excalidraw.hint":"正在解析手绘图元并生成安全 SVG。","loading.epub.label":"EPUB 电子书","loading.epub.hint":"正在解析目录、章节资源和阅读分页。","loading.umd.label":"UMD 电子书","loading.umd.hint":"正在解析移动电子书结构、目录和压缩正文。","loading.image.label":"图片文件","loading.image.hint":"正在解码像素数据并生成预览。","loading.video.label":"视频文件","loading.video.hint":"正在准备媒体资源和播放组件。","loading.audio.label":"音频文件","loading.audio.hint":"正在准备音频资源和播放控件。"},dn={"toolbar.zoomGroup":"Zoom controls","toolbar.zoomOut":"Zoom out","toolbar.zoomIn":"Zoom in","toolbar.zoomReset":"Reset zoom","toolbar.download":"Download","toolbar.downloadTitle":"Download the original file","toolbar.print":"Print","toolbar.printTitle":"Print the complete rendered document","toolbar.exportHtml":"HTML","toolbar.exportHtmlTitle":"Export the rendered HTML","state.ready.title":"Preview ready","state.ready.message":"The file has been rendered.","state.empty.title":"No file selected","state.empty.message":"Choose a file or provide an accessible URL to start previewing.","state.unsupported.install.title":"Preview capability required","state.unsupported.install.message":"{extension} is in the supported matrix, but {rendererLabel} renderer is not assembled in this project.","state.unsupported.install.description":"Install {presetPackage} and pass the capability through options.preset / options.renderers{rendererTip}. Vite projects can also use @file-viewer/vite-plugin to auto-discover installed presets.","state.unsupported.title":"Online preview is not supported yet","state.unsupported.message":"{extension} cannot be previewed online. Download it or convert it to a supported format.","state.unsupported.description":"Supports online preview for Office, PDF, OFD, Typst, archives, email, OLB/DRA, CAD, geospatial data, 3D models, Excalidraw, draw.io, EPUB, UMD, Markdown, code/text, images, audio/video, fonts, and structured data assets.","state.error.title":"Preview failed","preview.downloading":"Downloading file resources...","preview.streamingPdf":"Preparing streaming PDF preview...","preview.reading":"Parsing file content...","error.download":"Download failed","error.print":"Print failed","error.exportHtml":"HTML export failed","error.noDownloadSource":"There is no original file source to download.","error.noExportContent":"There is no rendered preview content to export.","error.printUnavailable":"This file type does not support full-document printing. Download the original file and print it locally.","error.printWindowBlocked":"The browser blocked the print window.","error.remoteDownload":"File download failed","error.localRead":"Failed to read local file","error.load":"Failed to load file","error.stream":"Failed to load streaming PDF preview","error.beforeOperation":"Before-operation check failed","operation.download":"Download original file","operation.print":"Print complete rendered content","operation.exportHtml":"Export rendered HTML","operation.zoomIn":"Zoom in","operation.zoomOut":"Zoom out","operation.zoomReset":"Reset preview zoom","pdf.toolbar.toggleNavigation":"Toggle navigation pane","pdf.toolbar.previousPage":"Previous page","pdf.toolbar.nextPage":"Next page","pdf.toolbar.fitWidth":"Fit to width","pdf.toolbar.zoomOut":"Zoom out","pdf.toolbar.zoomIn":"Zoom in","pdf.toolbar.rotateLeft":"Rotate left","pdf.toolbar.rotateRight":"Rotate right","pdf.nav.typeLabel":"PDF navigation type","pdf.nav.pagesTab":"Pages","pdf.nav.outlineTab":"Outline","pdf.nav.pagesTitle":"Page navigation","pdf.nav.outlineTitle":"Outline navigation","pdf.nav.pageCount":"{count} pages","pdf.nav.itemCount":"{count} items","pdf.nav.pageLabel":"Page {page}","pdf.nav.outlineEmpty":"This PDF has no available outline.","pdf.nav.outlineFallbackTitle":"Outline {index}","pdf.thumbnail.alt":"Page {page} thumbnail","pdf.state.loading":"Loading PDF...","pdf.error.browserWindow":"PDF preview requires a browser window","pdf.error.missingSource":"PDF has no readable data source","pdf.error.loadFailed":"Failed to load PDF","pdf.error.notLoaded":"The PDF is not loaded yet. Please try again later.","pdf.error.unloaded":"The PDF has been unloaded and cannot continue printing.","pdf.error.canvasUnavailable":"This browser cannot create a PDF print canvas.","pdf.export.pageTitle":"{title} - Page {page}","spreadsheet.loading.kicker":"Excel workbook","spreadsheet.loading.title":"Parsing Excel workbook","spreadsheet.loading.hint":"Preparing worksheets, styles, and virtualized viewport data.","spreadsheet.loading.streaming":"Loading visible worksheet data","spreadsheet.tabs.ariaLabel":"Worksheet list","spreadsheet.state.parsingWorkbook":"Parsing the Excel workbook. Please wait...","spreadsheet.state.preparingSheet":"Preparing worksheet content...","spreadsheet.state.preparingSheetNamed":"Preparing “{name}”...","spreadsheet.state.cachedRows":"Cached {cached} / {total} rows","spreadsheet.state.rows":"{rows} rows, loading smoothly by viewport","spreadsheet.state.rowsAndColumns":"{rows} rows, {cols} columns, loading smoothly by viewport","spreadsheet.error.parseFailed":"Failed to parse Excel","spreadsheet.error.workerFailed":"Excel Worker failed","archive.error.nestedUnsupported":".{type} cannot be previewed online. Download it or convert it to a supported format.","archive.loading.readingDirectory":"Reading archive directory...","archive.loading.readingDirectoryHint":"Large files are parsed in a Worker to keep the main thread responsive.","archive.search.placeholder":"Filter files inside the archive","archive.preview.title":"Archive entry preview","archive.preview.chooseFile":"Choose a file","archive.preview.downloadFile":"Download file","archive.error.title":"Archive preview notice","archive.stats.summary":"{count} files · {size} · {previewable} directly previewable","archive.warning.encrypted":"Encrypted content was detected. Online preview does not accept passwords; download and extract it locally.","archive.empty.title":"Choose a file from the left to preview","archive.empty.message":"The archive directory is read first. File contents are extracted on demand and cached in IndexedDB when size allows.","archive.loading.initializingCandidate":"Initializing {label}...","archive.loading.initializingCandidateHint":"If the server does not publish Worker/WASM assets correctly, the viewer falls back automatically.","archive.error.candidateInitTimeout":"{label} initialization timed out","archive.error.encryptedCheckTimeout":"{label} encryption check timed out","archive.loading.directoryReadyHint":"After the directory is ready, click an entry to extract it on demand.","archive.error.candidateReadTimeout":"{label} directory read timed out","archive.loading.workerFallback":"Worker unavailable. Switching to ZIP/TAR compatibility mode...","archive.loading.workerFallbackHint":"Compatibility mode needs no static Worker and works well in mobile WebViews or temporary local servers.","archive.notice.workerFallback":"The libarchive Worker could not start in this environment, so ZIP/TAR/GZIP compatibility mode is active. RAR, 7z, and similar formats should still publish vendor/libarchive/worker-bundle.js and libarchive.wasm.","archive.error.tooLarge":"Archive size {size} exceeds the safety limit {limit}. Download and extract it locally.","archive.loading.initializingWorker":"Initializing archive parsing Worker...","archive.loading.initializingWorkerHint":"Large files are parsed in a Worker to keep the main thread responsive.","archive.error.workerInitFailed":"Archive Worker initialization failed","archive.error.entryTooLarge":"Entry {name} is {size}, exceeding the preview limit {limit}.","archive.loading.extracting":"Extracting {name} on demand...","archive.loading.rendering":"Rendering {name}...","archive.loading.exporting":"Exporting {name}...","media.audio.title":"Audio preview","media.audio.description":"Opened with the browser-native audio player. Codec support depends on the current browser.","media.audio.unsupported":"This browser does not support audio playback.","media.video.title":"Video preview","media.video.unsupported":"This browser does not support this video format.","media.video.hlsHint":"HLS prefers the original URL for segment loading. If the input is a local single-file playlist, make sure segment URLs are reachable by the browser.","media.midi.title":"MIDI file","media.midi.loading":"Parsing MIDI tracks...","media.midi.trackHeader":"Track","media.midi.instrumentHeader":"Instrument","media.midi.channelHeader":"Channel","media.midi.noteCountHeader":"Notes","media.midi.durationHeader":"Duration","media.midi.durationStat":"Duration","media.midi.trackStat":"Tracks","media.midi.noteStat":"Notes","media.midi.parseFailed":"Failed to parse MIDI","email.mbox.subject":"{filename} · message 1","email.mbox.summary":"Detected {count} messages in the MBOX archive. Showing message 1.","email.error.title":"Email preview notice","email.meta.from":"From","email.meta.to":"To","email.meta.cc":"Cc","email.meta.date":"Date","email.tabs.text":"Body","email.tabs.headers":"Headers","email.attachments.title":"Attachments","email.attachments.empty":"No attachments","email.attachments.download":"Download attachment","email.attachments.opening":"Opening attachment {name}...","email.attachments.nestedUnavailable":"Nested attachment preview is not available in this environment. Download {name} to inspect it.","email.loading.parsing":"Parsing email...","data.font.sample":"Flyfish Viewer preview AaBbCc 1234567890","data.error.fontFaceUnsupported":"This browser does not support the FontFace API","data.title.font":"Font file preview","data.title.sqlite":"SQLite database preview","data.title.parquet":"Parquet columnar data preview","data.title.avro":"Avro object container preview","data.title.wasm":"WebAssembly module preview","data.title.eps":"EPS vector file summary","data.title.ai":"Illustrator file summary","data.title.webarchive":"WebArchive summary preview","data.title.summary":"Data asset summary","data.label.format":"Format","data.label.size":"Size","data.label.rendering":"Renderer","data.label.objects":"Objects","data.label.sampleTable":"Sample table","data.label.rows":"Rows","data.label.columns":"Columns","data.label.sampleRows":"Sample rows","data.label.imports":"Imports","data.label.exports":"Exports","data.label.magic":"Magic","data.label.note":"Note","data.label.container":"Container","data.value.schemaRead":"Read","data.value.schemaUnread":"Not read","data.note.aiSummary":"Non PDF-compatible AI is shown as a safe summary.","data.note.postscriptSummary":"PostScript summary preview","data.note.webarchive":"Readable fragments are extracted safely. Web scripts are not executed.","data.image.alt":"Asset preview","psd.title":"PSD layer preview","psd.action.fit":"Fit","psd.action.showAll":"Show all","psd.action.hideAll":"Hide all","psd.layers.title":"Layers","psd.layers.redrawable":"{count} redrawable","psd.layers.empty":"No displayable layers were found. Showing the composite image.","psd.layers.hidden":"hidden","drawing.error.viewerLoadFailed":"Failed to load the diagrams.net viewer","drawing.error.excalidrawEmpty":"This Excalidraw file has no previewable elements","drawing.error.excalidrawTimeout":"Official Excalidraw export timed out. Falling back to the rough.js renderer.","drawing.error.drawioParseFailed":"Failed to parse Draw.io XML: {message}","drawing.error.drawioNoModel":"This Draw.io file has no directly renderable mxGraphModel.","drawing.error.drawioNoElements":"This Draw.io file has no previewable elements.","drawing.error.viewerInitFailed":"The diagrams.net viewer was not initialized correctly","drawing.error.drawioTimeout":"Official diagrams.net Viewer timed out. Falling back to the local SVG preview.","drawing.error.svgParseFailed":"Failed to parse SVG","drawing.error.plantumlRenderFailed":"Failed to render PlantUML SVG: {status}","drawing.title.excalidraw":"Official Excalidraw SVG preview","drawing.title.mermaid":"Mermaid SVG preview","drawing.title.plantuml":"PlantUML SVG preview","drawing.title.drawio":"Draw.io offline SVG preview","drawing.toolbar.zoomOut":"Zoom out","drawing.toolbar.zoomIn":"Zoom in","drawing.toolbar.fit":"Fit","drawing.toolbar.fitWidth":"Fit width","drawing.state.loading":"Loading drawing preview...","text.code.loadingHighlight":"Loading syntax highlighting...","ebook.toc":"Table of contents","ebook.reading":"Reading","ebook.itemCount":"{count} items","epub.title":"EPUB ebook","epub.previousPage":"Previous","epub.nextPage":"Next","epub.loading":"Parsing EPUB...","epub.chapterFallback":"Chapter {index}","epub.renderIncomplete":"EPUB content did not finish rendering. Refresh and try again.","umd.title":"UMD ebook","umd.previousChapter":"Previous chapter","umd.nextChapter":"Next chapter","umd.loading":"Parsing UMD...","umd.emptyContent":"No readable body content was parsed.","umd.chapterFallback":"Chapter {index}","umd.galleryFallback":"Gallery {index}","umd.warningBodyTooShort":"The UMD body is shorter than declared and may be incomplete.","umd.error.unexpectedEnd":"The UMD structure is incomplete and ended unexpectedly.","umd.error.invalidFile":"This is not a valid UMD ebook file.","typst.summaryRenderer":"Typst WASM renderer","typst.pageSummary.empty":"0 pages","typst.pageSummary.ready":"{count} pages / {width} x {height} pt","typst.status.compiling":"Compiling","typst.status.failed":"Compilation failed","typst.status.rendered":"Rendered","typst.loading.title":"Parsing Typst","typst.loading.hint":"Loading the compiler and generating page previews...","typst.error.title":"Typst render failed","typst.error.timeout":"Typst WASM / font loading or compilation exceeded {seconds} seconds","typst.error.timeoutHint":"Check the download speed and cache strategy for the Typst compiler WASM, renderer WASM, and font directory. On weak networks or cross-region deployments, increase options.typst.renderTimeoutMs.","typst.error.assetHint":"Typst requires local compiler / renderer WASM files and a font directory. Run file-viewer-copy-assets, or configure options.typst.compilerWasmUrl / options.typst.rendererWasmUrl / options.typst.fontAssetsUrl, and make sure the server returns WASM with application/wasm.","typst.error.svgParseFailed":"Failed to parse Typst SVG","typst.error.wasmLoadFailed":"Failed to load Typst WASM","xmind.toolbar.zoomOut":"Zoom out","xmind.toolbar.zoomIn":"Zoom in","xmind.toolbar.fit":"Fit","xmind.toolbar.fitTitle":"Fit canvas","xmind.state.loading":"Parsing XMind mind map...","xmind.stats.nodes":"Nodes","xmind.stats.depth":"Depth","xmind.stats.theme":"Theme","xmind.stats.template":"Template","xmind.badge.paused":"Paused","xmind.badge.collapsed":"Collapsed","xmind.badge.floating":"Floating","xmind.badge.summary":"Summary","xmind.badge.callout":"Callout","xmind.imageResource":"Image resource: {name}","xmind.error.unrecognized":"Unrecognized XMind file: content.json or content.xml was not found in the ZIP package.","xmind.error.noCanvas":"This XMind file has no previewable canvas.","cad.toolbar.fit":"Fit","cad.toolbar.zoomOut":"Zoom out","cad.toolbar.zoomIn":"Zoom in","cad.layers.title":"Layers","cad.layers.count":"{count} items","cad.inspector.title":"Structure","cad.inspector.entities":"Entities","cad.inspector.blocks":"Blocks","cad.inspector.pages":"Pages","cad.inspector.drawn":"Drawn","cad.state.loadingViewer":"Loading CAD viewer...","cad.state.parsing":"Parsing CAD...","cad.error.parseFailed":"Failed to parse CAD file","image.alt":"Image","image.lightbox.alt":"Image preview","image.lightbox.close":"Close image preview","gitBundle.error.invalid":"This file is not a valid Git bundle.","gitBundle.error.missingPack":"No PACK data was found after the Git bundle header.","gitBundle.notice.delta":"This bundle contains delta-compressed objects. The viewer resolves common OFS_DELTA / REF_DELTA objects in the browser. Missing files usually indicate a very large bundle, too many objects, or an external prerequisite.","gitBundle.title.history":"History","gitBundle.title.fileTree":"File tree","gitBundle.file.choose":"Select a file to inspect","gitBundle.file.noTree":"The tree/blob objects in this bundle may be delta-compressed, and no expandable files were parsed.","gitBundle.file.none":"No files parsed","gitBundle.history.empty":"No commit objects were parsed. Showing refs and pack summary only.","gitBundle.toolbar.summary":"{commits} commits · {files} files","gitBundle.meta.bundle":"Bundle","gitBundle.meta.refs":"Refs","gitBundle.meta.commits":"Commits","gitBundle.meta.objects":"Objects","gitBundle.meta.deltas":"Deltas","gitBundle.meta.objectFormat":"Object format","gitBundle.meta.objectTypes":"Object types","geo.error.unrecognized":"Unrecognized GeoJSON data","geo.error.xmlParseFailed":"Failed to parse XML","geo.error.unsupported":".{type} geospatial format is not supported","geo.title":"Geospatial preview","geo.featureCount":"Features","geo.bounds":"Bounds","geo.geometryTypes":"Geometry types","geo.aria":"Geospatial SVG preview","geo.loading":"Parsing geospatial data...","model.toolbar.fit":"Fit","model.toolbar.rotate":"Rotate","model.toolbar.wireframe":"Wireframe","model.toolbar.grid":"Grid","model.toolbar.axes":"Axes","model.state.loadingSummary":"Loading model","model.state.loading":"Parsing 3D model...","model.state.loaded":"Model loaded","model.state.parseFailed":"Failed to parse model","model.summary.meshes":"{count} meshes","model.summary.points":"{count} point clouds","model.error.daeEmpty":"The DAE model did not contain a valid scene.","model.error.unsupported":".{type} model format is not supported yet","model.error.parseFailed":"Failed to parse {type} model","model.notice.signature":"Detected file signature: {signature}.","loading.generic.label":"File content","loading.generic.hint":"Preparing content structure and preview.","loading.word.label":"Word document","loading.word.hint":"Preparing document structure, text styles, and layout.","loading.wordWorker.hint":"Preparing document structure, text styles, and layout in a Worker.","loading.sheet.label":"Excel workbook","loading.sheet.hint":"Preparing worksheets, styles, and viewport data.","loading.csv.label":"Tabular data","loading.csv.hint":"Preparing rows, columns, and basic styling.","loading.presentation.label":"PowerPoint deck","loading.presentation.hint":"Building slide layout and media content.","loading.pdf.label":"PDF document","loading.pdf.hint":"Loading page bitmaps, text layers, and zoom view.","loading.ofd.label":"OFD layout document","loading.ofd.hint":"Parsing OFD pages and layout objects.","loading.archive.label":"Archive","loading.archive.hint":"Starting Worker and reading archive entries.","loading.email.label":"Email file","loading.email.hint":"Parsing message headers, body, and attachments.","loading.msg.hint":"Parsing Outlook message and attachments.","loading.eda.label":"EDA file","loading.eda.hint":"Reading EDA container structure and properties.","loading.cad.label":"CAD drawing","loading.cad.hint":"Preparing CAD layers, geometry, and canvas view.","loading.dwg.hint":"Loading DWG geometry and LibreDWG WASM in a Worker.","loading.dwf.hint":"Loading native DWF renderer and W2D/W3D graphics.","loading.dwfx.hint":"Loading native DWFx/XPS renderer and page graphics.","loading.xps.hint":"Loading native XPS renderer and embedded fonts.","loading.drawio.label":"draw.io diagram","loading.drawio.hint":"Parsing shapes, connectors, and SVG preview.","loading.excalidraw.label":"Excalidraw scene","loading.excalidraw.hint":"Parsing hand-drawn elements and generating safe SVG.","loading.epub.label":"EPUB ebook","loading.epub.hint":"Parsing table of contents, chapter resources, and reading pages.","loading.umd.label":"UMD ebook","loading.umd.hint":"Parsing mobile ebook metadata, table of contents, and compressed chapters.","loading.image.label":"Image file","loading.image.hint":"Decoding pixels and generating preview.","loading.video.label":"Video file","loading.video.hint":"Preparing media resource and player.","loading.audio.label":"Audio file","loading.audio.hint":"Preparing audio resource and playback controls."},Ii=Object.freeze({"zh-CN":cn,"en-US":dn}),hn=()=>{var e;if(!(typeof navigator>"u"))return((e=navigator.languages)===null||e===void 0?void 0:e[0])||navigator.language},un=e=>{const t=!e||e==="auto"?hn():e;return String(t||"zh-CN").toLowerCase().startsWith("zh")?"zh-CN":"en-US"},fn=e=>{var t;return((t=e?.i18n)===null||t===void 0?void 0:t.messages)||e?.messages},At=e=>{var t;return un(((t=e?.i18n)===null||t===void 0?void 0:t.locale)||e?.locale)},pn=(e,t={})=>e.replace(/\{([a-zA-Z0-9_.-]+)\}/g,(i,r)=>{const s=t[r];return s==null?"":String(s)}),Se=(e,t,i={})=>{const r=At(e),s=fn(e);return pn((typeof s=="function"?s(t,i,r):s?.[t])||Ii[r][t]||Ii["zh-CN"][t],i)},mn=e=>(t,i)=>Se(e,t,i)})),_i=E((()=>{Ve()})),gn,Tt,Ft=E((()=>{Le(),Mt(),gn=e=>({...e,extensions:e.extensions.map(se)}),Tt=(e=be)=>{const t=new Map,i=new Map,r=s=>{const n=gn(s),a=t.get(n.id);a&&a.extensions.forEach(o=>{var l;((l=i.get(o))===null||l===void 0?void 0:l.id)===a.id&&i.delete(o)}),t.set(n.id,n),n.extensions.forEach(o=>{const l=i.get(o);if(l&&l.id!==n.id)throw new Error(`File extension "${o}" is already registered by renderer "${l.id}".`);i.set(o,n)})};return e.forEach(r),{register:r,unregister(s){const n=t.get(s);return n?(n.extensions.forEach(a=>{var o;((o=i.get(a))===null||o===void 0?void 0:o.id)===s&&i.delete(a)}),t.delete(s),!0):!1},getById(s){return t.get(s)},getByExtension(s){return i.get(se(s))},hasExtension(s){return i.has(se(s))},list(){return Array.from(t.values())},listExtensions(){return Array.from(i.keys()).sort()}}}})),Li,Di=E((()=>{Le(),Ft(),Mt(),Li=({registry:e=Tt(be),handlers:t,fallbackHandler:i,fallbackKey:r="error"})=>{const s=Array.from(t).reduce((l,c)=>(l.set(c.rendererId,c.handler),l),new Map),n=new Map,a=[];e.list().forEach(l=>{const c=s.get(l.id);if(!c){a.push(l.id);return}l.extensions.forEach(d=>{n.set(se(d),c)})}),i&&r&&n.set(se(r),i);const o=l=>n.get(se(l));return{handlersByRendererId:s,handlersByExtension:n,missingRendererIds:a,get:o,resolve(l){return o(l)||(r?o(r):void 0)},has(l){return n.has(se(l))},listExtensions(){return Array.from(n.keys()).sort()}}}})),ec,tc,ic,Ri=E((()=>{Le(),ec=Object.freeze({download:!1,print:!1,exportHtml:!1,zoom:!1,zoomIn:!1,zoomOut:!1,zoomReset:!1}),tc=["pptx","pptm","potx","potm","ppsx","ppsm","ofd","dxf","dwg","dwf","dwfx","xps","excalidraw","drawio","dio","mermaid","mmd","plantuml","puml","umd","md","markdown","olb","dra",...Si,...Ci],ic=["xlsx","xltx","xlsm","xlsb","xls","xlt","xltm","csv","ods","fods","numbers",...Ei,"eml","msg","epub","mp4","mp3","mpeg","wav","ogg","oga","opus","m4a","aac","flac","weba",...Pi]})),ht=E((()=>{Ri(),Ve(),_i()})),rc,Bi,bn,wn,vn,yn,xn,kn,En,Wi,Pn,Nt=E((()=>{Mt(),Le(),Ve(),rc=Object.freeze({downloading:"正在下载文件资源...",streamingPdf:"正在建立 PDF 流式预览...",reading:"正在解析文件内容..."}),Bi=Object.freeze({accent:"#5f6f82",soft:"rgba(95, 111, 130, 0.12)",badge:"DOC",label:"文件内容",hint:"正在整理内容结构并生成预览。"}),bn=e=>{const t=se(e);return t?`.${t}`:"当前"},wn={"office-word-openxml":"@file-viewer/renderer-word","office-word-binary":"@file-viewer/renderer-word","office-presentation":"@file-viewer/renderer-presentation","open-document":"@file-viewer/renderer-word","spreadsheet-openxml":"@file-viewer/renderer-spreadsheet",pdf:"@file-viewer/renderer-pdf",ofd:"@file-viewer/renderer-ofd",typst:"@file-viewer/renderer-typst",archive:"@file-viewer/renderer-archive",email:"@file-viewer/renderer-email",eda:"@file-viewer/renderer-eda",cad:"@file-viewer/renderer-cad",model:"@file-viewer/renderer-3d",geo:"@file-viewer/renderer-geo",drawing:"@file-viewer/renderer-drawing",mindmap:"@file-viewer/renderer-mindmap",epub:"@file-viewer/renderer-epub",umd:"@file-viewer/renderer-epub",image:"@file-viewer/renderer-image",markdown:"@file-viewer/renderer-text",code:"@file-viewer/renderer-text",video:"@file-viewer/renderer-media",audio:"@file-viewer/renderer-media","data-asset":"@file-viewer/renderer-data"},vn=new Set(["office-word-openxml","office-word-binary","office-presentation","open-document","spreadsheet-openxml","pdf","ofd"]),yn=new Set(["image","markdown","code","video","audio"]),xn=new Set(["typst","archive","eda","cad","model","geo","drawing","mindmap","data-asset"]),kn=e=>vn.has(e.id)?{packageName:"@file-viewer/preset-office",vitePreset:"office",label:"Office preset"}:xn.has(e.id)?{packageName:"@file-viewer/preset-engineering",vitePreset:"engineering",label:"Engineering preset"}:yn.has(e.id)?{packageName:"@file-viewer/preset-lite",vitePreset:"lite",label:"Lite preset"}:{packageName:"@file-viewer/preset-all",vitePreset:"all",label:"Full preset"},En=(e="")=>{const t=se(e),i=be.find(s=>s.extensions.map(se).includes(t));if(!i)return null;const r=kn(i);return{extension:t,rendererId:i.id,rendererLabel:i.label,rendererCategory:i.category,rendererPackage:wn[i.id],presetPackage:r.packageName,vitePreset:r.vitePreset,presetLabel:r.label}},Wi=({state:e,extension:t="",title:i,message:r,description:s,theme:n=Bi,recoverable:a})=>({state:e,extension:se(t),title:i,message:r,description:s,theme:n,recoverable:a}),Pn=(e="",t=Bi,i)=>{const r=bn(e),s=En(e);if(s){const n=At(i),a=s.rendererPackage?n==="zh-CN"?`;如果需要极致裁剪,也可以只安装 ${s.rendererPackage}`:`; for a strict custom cut, install only ${s.rendererPackage}`:"";return Wi({state:"unsupported",extension:e,title:Se(i,"state.unsupported.install.title"),message:Se(i,"state.unsupported.install.message",{extension:r,rendererLabel:s.rendererLabel}),description:Se(i,"state.unsupported.install.description",{extension:r,rendererLabel:s.rendererLabel,presetPackage:s.presetPackage,vitePreset:s.vitePreset,rendererTip:a}),theme:t,recoverable:!0})}return Wi({state:"unsupported",extension:e,title:Se(i,"state.unsupported.title"),message:Se(i,"state.unsupported.message",{extension:r}),description:Se(i,"state.unsupported.description"),theme:t,recoverable:!0})}})),It=E((()=>{ht(),Nt(),Ve()})),Sn,Oi,Cn,Mn,An,zi=E((()=>{Le(),Di(),Ft(),It(),Sn=(e,t)=>({rendered:e,destroy:()=>t?t():Oi(e)}),Oi=e=>{if(!e||typeof e!="object")return;const t=e;if(typeof t.unmount=="function")return t.unmount();if(typeof t.$destroy=="function")return t.$destroy();if(typeof t.destroy=="function")return t.destroy()},Cn=({source:e,options:t,registerExportAdapter:i,renderContext:r})=>({filename:e.filename,url:e.url,streamUrl:e.url,options:t,registerExportAdapter:i,...r}),Mn=({handler:e,getTarget:t=s=>s.surface.container,createContext:i=Cn,destroy:r})=>async s=>{const{source:n}=s;if(!n.buffer)throw new Error("FileRenderHandler renderer requires an ArrayBuffer source.");const a=t(s),o=await e(n.buffer,a,n.extension,i(s));return Sn(o,()=>r?r(o,s):Oi(o))},An=({definitions:e=be,handlers:t,getTarget:i,createContext:r,destroy:s})=>{const n=Tt(e),a=Li({registry:n,handlers:t});return{registry:Tt(n.list().map(o=>{const l=a.handlersByRendererId.get(o.id);return l?{...o,load:Mn({handler:l,getTarget:i,createContext:r,destroy:s})}:o})),dispatcher:a,missingRendererIds:a.missingRendererIds}}})),nc=xi({default:()=>sc});async function sc(e,t,i){const r=await Ln(e,i);let s=1,n=0;const a=Fi(),o=document.createElement("div");o.className="image-viewer",o.dataset.viewerZoomProvider="image";const l=document.createElement("div");l.className="image-stage";const c=document.createElement("img");c.alt="图片",c.src=r,l.append(c),o.append(l);const d=Rn(r),h=()=>d.open();c.addEventListener("click",h),document.body.append(d.element);const u=()=>{n=o.clientHeight||0,Ui(c,n,s),a.emit()},f=new ResizeObserver(u);f.observe(o);const p=()=>({scale:s,label:`${Math.round(s*100)}%`,canZoomIn:s<5,canZoomOut:s>.1,canReset:s!==1,minScale:.1,maxScale:5}),w=m=>(s=Dn(m),Ui(c,n,s),a.emit(),p());return Ai(o,{zoomIn:()=>w(s+.15),zoomOut:()=>w(s-.15),resetZoom:()=>w(1),setZoom:w,getState:p,subscribe:a.subscribe}),t.replaceChildren(Nn(),o),u(),{$el:t,unmount(){Ti(o),f.disconnect(),c.removeEventListener("click",h),d.destroy(),t.replaceChildren()}}}var Tn,Fn,Nn,In,_n,Ln,Dn,Ui,Rn,ac=E((()=>{dt(),Ni(),Tn={avif:"image/avif",bmp:"image/bmp",gif:"image/gif",heic:"image/heic",heif:"image/heif",ico:"image/x-icon",jxl:"image/jxl",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp"},Fn=`
|
|
2
|
+
.image-viewer{position:relative;width:100%;height:100%;overflow:auto;background:#eef1f4;box-sizing:border-box}
|
|
3
|
+
.image-stage{min-width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px;box-sizing:border-box}
|
|
4
|
+
.image-stage img{display:block;width:auto;max-width:none;margin:0 auto;border:0;box-shadow:0 18px 48px rgba(15,23,42,.16);background:#fff;cursor:zoom-in}
|
|
5
|
+
.image-lightbox{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:40px;background:rgba(15,23,42,.88);box-sizing:border-box}
|
|
6
|
+
.image-lightbox[hidden]{display:none}
|
|
7
|
+
.image-lightbox img{display:block;max-width:100%;max-height:100%;object-fit:contain;background:#fff;box-shadow:0 30px 80px rgba(0,0,0,.4);cursor:zoom-out}
|
|
8
|
+
.image-lightbox button{position:absolute;top:20px;right:20px;width:40px;height:40px;border:0;border-radius:999px;background:rgba(255,255,255,.92);color:#172033;font-size:24px;line-height:40px;cursor:pointer;box-shadow:0 12px 28px rgba(0,0,0,.18)}
|
|
9
|
+
.file-viewer[data-viewer-theme='dark'] .image-viewer{background:#101820}
|
|
10
|
+
@media (prefers-color-scheme:dark){.file-viewer[data-viewer-theme='system'] .image-viewer{background:#101820}}
|
|
11
|
+
@media (max-width:767px){.image-stage{padding:12px}.image-lightbox{padding:16px}.image-lightbox button{top:12px;right:12px}}
|
|
12
|
+
`,Nn=()=>{const e=document.createElement("style");return e.textContent=Fn,e},In=e=>Tn[(e||"").trim().toLowerCase()]||"image/*",_n=async e=>await new Promise((t,i)=>{const r=new FileReader;r.onload=s=>{var n;const a=(n=s.target)===null||n===void 0?void 0:n.result;if(typeof a=="string"){t(a);return}i(new Error("Unable to read image data URL."))},r.onerror=()=>i(r.error||new Error("Unable to read image data URL.")),r.readAsDataURL(e)}),Ln=async(e,t)=>{const i=(t||"").trim().toLowerCase();if(i==="heic"||i==="heif")throw new Error("HEIC/HEIF image conversion has moved out of @file-viewer/core. Install and pass @file-viewer/renderer-image, or use @file-viewer/preset-all.");return _n(new Blob([e],{type:In(i)}))},Dn=e=>Math.min(5,Math.max(.1,Number(e.toFixed(2)))),Ui=(e,t,i)=>{if(t>0){e.style.height=`${Math.max(1,Math.round(t*i))}px`;return}e.style.height=`${i*100}%`},Rn=e=>{const t=document.createElement("div");t.className="image-lightbox",t.hidden=!0,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true");const i=document.createElement("img");i.alt="Preview image",i.src=e;const r=document.createElement("button");r.type="button",r.setAttribute("aria-label","Close image preview"),r.textContent="x";const s=()=>{t.hidden=!0};return r.addEventListener("click",s),i.addEventListener("click",s),t.addEventListener("click",n=>{n.target===t&&s()}),t.append(i,r),{element:t,open(){t.hidden=!1},destroy(){r.removeEventListener("click",s),i.removeEventListener("click",s),t.remove()}}}})),Bn,_t,$i,Wn,On,zn,Un,$n,Hn,Lt,oc,lc,cc,Vn=E((()=>{Le(),zi(),Di(),Nt(),Bn=e=>({$el:e,unmount(){}}),_t=[{rendererId:"image",handler:async(e,t,i)=>{const{default:r}=await Promise.resolve().then(()=>(ac(),nc));return r(e,t,i)}}],$i=["image"],Wn=_t.filter(e=>$i.includes(e.rendererId)),On=be.filter(e=>$i.includes(e.id)),zn=e=>e==="none"?[]:e==="lite"?On:be,Un=e=>e==="none"?[]:e==="lite"?Wn:_t,$n=async(e,t,i)=>{const r=Pn(i),s=document.createElement("div");s.style.textAlign="center",s.style.marginTop="80px";const n=document.createElement("div");if(n.textContent=r.message,s.appendChild(n),r.description){const a=document.createElement("div");a.textContent=r.description,s.appendChild(a)}return t.replaceChildren(s),Bn(t)},Hn=(e={})=>{const t=e.builtinRenderers||"all",i=An({definitions:zn(t),handlers:Un(t)});return{...i,dispatcher:Li({registry:i.registry,handlers:_t,fallbackHandler:$n})}},Lt=Hn(),oc=Lt.registry,lc=Lt.dispatcher,cc=Lt.missingRendererIds})),dc=E((()=>{Ve()})),hc=E((()=>{ht(),It()})),uc=E((()=>{ht()})),fc=E((()=>{ln(),Ni(),_i(),Ri(),ht(),Ft(),zi(),Vn(),It(),Nt()})),Xn=E((()=>{an(),Le(),on(),ln(),Ni(),dt(),_i(),Ve(),Ft(),Vn(),Ri(),ht(),dc(),hc(),uc(),Di(),zi(),Mt(),Nt(),It(),fc()}));function M(e,t,i,r){return r===void 0?{level:e,code:t,message:i}:{level:e,code:t,message:i,source:r}}function Dt(e){return(e??[]).filter(t=>t.level!=="info")}var te=E((()=>{}));function pc(){return globalThis.DecompressionStream}async function Gn(e,t,i){const r=new Blob([e]).stream().pipeThrough(new i(t)),s=await new Response(r).arrayBuffer();return new Uint8Array(s)}var Hi,Vi=E((()=>{Hi=class{async inflateRaw(e){const t=pc();if(!t)throw new Error("This browser does not expose DecompressionStream. Provide a custom InflateProvider, or pre-bundle a WASM/JS inflater.");try{return await Gn(e,"deflate-raw",t)}catch(i){try{return await Gn(e,"deflate",t)}catch{throw i instanceof Error?i:new Error(String(i))}}}}}));function ae(e){return Kn.decode(e)}function U(e){const t=[],i=e.replace(/\\/g,"/");for(const r of i.split("/"))!r||r==="."||(r===".."?t.pop():t.push(r));return t.join("/")}function mc(e){const t=U(e),i=t.lastIndexOf("/");return i<0?"":t.slice(0,i)}function Xe(e,t){if(!t)return U(e);if(t.startsWith("/"))return U(t.slice(1));const i=mc(e);return U((i?i+"/":"")+t)}function Rt(e){const t=e.indexOf(":");return t>=0?e.slice(t+1):e}function A(e){return Rt(e.localName||e.nodeName)}function S(e,t){return e.getAttribute(t)??e.getAttributeNS(null,t)??void 0}function Y(e){return Array.from(e.childNodes).filter(t=>t.nodeType===1)}function Q(e,t="document.xml"){const i=Yn(e);if(i)return i;const r=gc(e);if(r!==e){const s=Yn(r);if(s)return s}try{return bc(r)}catch(s){throw new Error(`XML parse error in ${t}: ${String(s)}`)}}function Yn(e){if(!(typeof DOMParser>"u"))try{const t=new DOMParser().parseFromString(e,"application/xml");return t.getElementsByTagName("parsererror")[0]?void 0:t}catch{return}}function gc(e){let t=e;return t=t.replace(/\s+xmlns:(?:schemaLocation|noNamespaceSchemaLocation)\s*=\s*("[^"]*"|'[^']*')/g,""),/\s+xsi:schemaLocation\s*=/.test(t)&&!/\s+xmlns:xsi\s*=/.test(t)&&(t=t.replace(/<([A-Za-z_][\w.:-]*)(?=\s|>|\/)/,'<$1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"')),t}function bc(e){const t=new Jn,i=[t];let r=0;for(;r<e.length;){const s=e.indexOf("<",r);if(s<0){Xi(i[i.length-1],e.slice(r));break}if(s>r&&Xi(i[i.length-1],e.slice(r,s)),e.startsWith("<!--",s)){const h=e.indexOf("-->",s+4);if(h<0)throw new Error("Unclosed XML comment.");r=h+3;continue}if(e.startsWith("<![CDATA[",s)){const h=e.indexOf("]]>",s+9);if(h<0)throw new Error("Unclosed XML CDATA section.");Xi(i[i.length-1],e.slice(s+9,h)),r=h+3;continue}if(e.startsWith("<?",s)){const h=e.indexOf("?>",s+2);if(h<0)throw new Error("Unclosed XML processing instruction.");r=h+2;continue}if(e.startsWith("<!",s)){const h=e.indexOf(">",s+2);if(h<0)throw new Error("Unclosed XML declaration.");r=h+1;continue}const n=wc(e,s+1);if(n<0)throw new Error("Unclosed XML tag.");let a=e.slice(s+1,n).trim();if(r=n+1,!a)continue;if(a[0]==="/"){const h=a.slice(1).trim().split(/\s+/)[0]??"";let u=i.pop();for(;u&&u instanceof Ge&&u.nodeName!==h&&u.localName!==Rt(h)&&i.length>0;)u=i.pop();i.length===0&&i.push(t);continue}const o=a.endsWith("/");o&&(a=a.slice(0,-1).trim());const l=a.search(/\s/),c=new Ge(l<0?a:a.slice(0,l),vc(l<0?"":a.slice(l+1))),d=i[i.length-1];c.parentNode=d,d.childNodes.push(c),o||i.push(c)}return t}function Xi(e,t){if(!t)return;const i=jn(t);i.trim().length!==0&&e.childNodes.push(new Qn(i))}function wc(e,t){let i="";for(let r=t;r<e.length;r++){const s=e[r];if(i)s===i&&(i="");else if(s==='"'||s==="'")i=s;else if(s===">")return r}return-1}function vc(e){const t=[],i=/([^\s=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;let r;for(;r=i.exec(e);){const s=r[1],n=jn(r[2]??r[3]??"");t.push({name:s,nodeName:s,localName:Rt(s),value:n})}return t}function jn(e){return e.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g,(t,i)=>i==="amp"?"&":i==="lt"?"<":i==="gt"?">":i==="quot"?'"':i==="apos"?"'":i.startsWith("#x")?String.fromCodePoint(Number.parseInt(i.slice(2),16)):i.startsWith("#")?String.fromCodePoint(Number.parseInt(i.slice(1),10)):t)}function qn(e,t=2048){const i=Math.min(t,e.length);if(i===0)return!0;let r=0,s=0;for(let n=0;n<i;n++){const a=e[n];if(a===0)return!1;a===9||a===10||a===13||a>=32&&a<=126||a>=160?r++:s++}return r/i>.85&&s<20}function Zn(e){const t=e.split(/[?#]/)[0]??e,i=t.lastIndexOf("/"),r=t.lastIndexOf(".");return r>i?t.slice(r+1).toLowerCase():""}function De(e){switch(Zn(e)){case"png":return"image/png";case"jpg":case"jpeg":return"image/jpeg";case"gif":return"image/gif";case"bmp":return"image/bmp";case"tif":case"tiff":return"image/tiff";case"w2d":return"application/x-dwf-w2d";case"hsf":return"model/vnd.hsf";case"fpage":return"application/vnd.ms-package.xps-fixeddocumentsequence+xml";case"fdseq":return"application/vnd.ms-package.xps-fixeddocumentsequence+xml";case"fdoc":return"application/vnd.ms-package.xps-fixeddocument+xml";default:return}}async function Gi(e,t){const i=new Blob([e],{type:t});return"createImageBitmap"in globalThis?await createImageBitmap(i):await new Promise((r,s)=>{const n=URL.createObjectURL(i),a=new Image;a.onload=()=>{URL.revokeObjectURL(n),r(a)},a.onerror=()=>{URL.revokeObjectURL(n),s(new Error("Failed to decode image"))},a.src=n})}function Z(e){const t=e.match(/[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?/g);return t?t.map(Number).filter(Number.isFinite):[]}var Kn,yc,Ge,Qn,Jn,ue=E((()=>{Kn=new TextDecoder("utf-8"),yc=new TextDecoder("ascii"),Ge=class yi{constructor(t,i){this.nodeType=1,this.childNodes=[],this.nodeName=t,this.localName=Rt(t),this.attributes=i}get textContent(){return this.childNodes.map(t=>t.textContent??"").join("")}get children(){return this.childNodes.filter(t=>t instanceof yi)}getAttribute(t){return this.attributes.find(i=>i.name===t||i.nodeName===t)?.value??null}getAttributeNS(t,i){return this.attributes.find(r=>r.localName===i)?.value??null}getElementsByTagName(t){const i=[],r=s=>{(t==="*"||s.nodeName===t||s.localName===t)&&i.push(s);for(const n of s.childNodes)n instanceof yi&&r(n)};for(const s of this.childNodes)s instanceof yi&&r(s);return i}},Qn=class{constructor(e){this.textContent=e,this.nodeType=3}},Jn=class{constructor(){this.nodeType=9,this.childNodes=[]}get textContent(){return this.childNodes.map(e=>e.textContent??"").join("")}get children(){return this.childNodes.filter(e=>e instanceof Ge)}get documentElement(){return this.children[0]}getElementsByTagName(e){const t=[],i=r=>{(e==="*"||r.nodeName===e||r.localName===e)&&t.push(r);for(const s of r.childNodes)s instanceof Ge&&i(s)};for(const r of this.childNodes)r instanceof Ge&&i(r);return t}}}));function xc(e){if(e.byteLength<22)return!1;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return le(t,0)===Yi?!0:es(t)>=0}function es(e){const t=Math.max(0,e.byteLength-65535-22);for(let i=e.byteLength-22;i>=t;i--)if(le(e,i)===is)return i;return-1}function ts(e,t){return(t&2048)!==0?ae(e):Array.from(e,i=>String.fromCharCode(i)).join("")}function oe(e,t){return e.getUint16(t,!0)}function le(e,t){return e.getUint32(t,!0)}var is,Bt,Yi,rs,ns=E((()=>{Vi(),ue(),is=101010256,Bt=33639248,Yi=67324752,rs=class Bl{constructor(t,i,r,s){this.entryMap=new Map,this.cache=new Map,this.bytes=t,this.entries=i,this.archiveBase=r,this.inflater=s??new Hi;for(const n of i)this.entryMap.set(U(n.name),n)}static open(t,i){const r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=es(r);if(s<0)throw new Error("ZIP end-of-central-directory record was not found. This is not a DWF 6+/DWFx ZIP package.");const n=oe(r,s+4),a=oe(r,s+6);if(n!==0||a!==0)throw new Error("Multi-disk ZIP archives are not supported.");const o=oe(r,s+10),l=le(r,s+12),c=le(r,s+16);let d=0,h=c;if(le(r,h)!==Bt){const p=Math.max(0,s-l-1048576);let w=-1;for(let m=s-l;m>=p;m--)if(m>=0&&le(r,m)===Bt){w=m;break}if(w<0)throw new Error("ZIP central directory could not be located.");h=w,d=h-c}const u=[];let f=h;for(let p=0;p<o;p++){if(le(r,f)!==Bt)throw new Error(`Bad central directory signature at ${f}.`);const w=oe(r,f+8),m=oe(r,f+10),v=oe(r,f+12),g=oe(r,f+14),x=le(r,f+16),y=le(r,f+20),b=le(r,f+24),k=oe(r,f+28),T=oe(r,f+30),N=oe(r,f+32),$=le(r,f+42),he=t.subarray(f+46,f+46+k),fe=t.subarray(f+46+k+T,f+46+k+T+N),L=U(ts(he,w)),z=ts(fe,w);L.endsWith("/")||u.push({name:L,compressedSize:y,uncompressedSize:b,compressionMethod:m,crc32:x,localHeaderOffset:$,centralHeaderOffset:f-d,flags:w,lastModTime:v,lastModDate:g,comment:z}),f+=46+k+T+N}return new Bl(t,u,d,i)}has(t){return this.entryMap.has(U(t))}get(t){return this.entryMap.get(U(t))}find(t){return this.entries.find(t)}findAll(t){return this.entries.filter(t)}async read(t){const i=typeof t=="string"?this.get(t):t;if(!i)throw new Error(`ZIP entry not found: ${t}`);const r=this.cache.get(i.name);if(r)return r;const s=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),n=this.archiveBase+i.localHeaderOffset;if(le(s,n)!==Yi)throw new Error(`Bad local header signature for ${i.name}.`);const a=oe(s,n+26),o=oe(s,n+28),l=n+30+a+o,c=this.bytes.subarray(l,l+i.compressedSize);let d;if(i.compressionMethod===0)d=c.slice();else if(i.compressionMethod===8)d=await this.inflater.inflateRaw(c);else throw new Error(`Unsupported ZIP compression method ${i.compressionMethod} for ${i.name}.`);if(i.uncompressedSize!==0&&d.byteLength!==i.uncompressedSize&&i.uncompressedSize<4294967295)throw new Error(`ZIP entry size mismatch for ${i.name}: expected ${i.uncompressedSize}, got ${d.byteLength}.`);return this.cache.set(i.name,d),d}}}));async function kc(e){const t=new Map,i=new Map,r=[];if(e.has("[Content_Types].xml")){const n=Q(ae(await e.read("[Content_Types].xml")),"[Content_Types].xml");for(const a of Array.from(n.documentElement.children)){const o=A(a);if(o==="Default"){const l=a.getAttribute("Extension")?.toLowerCase(),c=a.getAttribute("ContentType");l&&c&&i.set(l,c)}else if(o==="Override"){const l=U((a.getAttribute("PartName")??"").replace(/^\//,"")),c=a.getAttribute("ContentType");l&&c&&(t.set(l,c),r.push({partName:l,contentType:c}))}}}const s=new Map;return{zip:e,contentTypes:t,defaults:i,overrides:r,relationships:s,resources:e.entries.map(n=>({path:n.name,mediaType:ss(t,i,n.name),size:n.uncompressedSize})),readText:async n=>ae(await e.read(U(n))),readBytes:async n=>e.read(U(n)),getContentType:n=>ss(t,i,n),getRelationships:async(n="")=>{const a=U(n),o=s.get(a);if(o)return o;const l=Ec(a);if(!e.has(l))return s.set(a,[]),[];const c=Q(ae(await e.read(l)),l),d=[];for(const h of Array.from(c.documentElement.children)){if(A(h)!=="Relationship")continue;const u=h.getAttribute("Id")??"",f=h.getAttribute("Type")??"",p=h.getAttribute("Target")??"",w=h.getAttribute("TargetMode")??void 0;!u||!p||d.push({id:u,type:f,target:p,targetMode:w,source:a,resolvedTarget:w==="External"?p:Xe(a,p)})}return s.set(a,d),d}}}function Ec(e){const t=U(e);if(!t)return"_rels/.rels";const i=t.lastIndexOf("/");return i<0?`_rels/${t}.rels`:`${t.slice(0,i)}/_rels/${t.slice(i+1)}.rels`}function ss(e,t,i){const r=U(i),s=e.get(r);if(s)return s;const n=r.lastIndexOf(".");if(n>=0)return t.get(r.slice(n+1).toLowerCase())}var Pc=E((()=>{ue()}));function Wt(e,t,i,r){return{...e,pages:t.map(s=>({id:s.id,name:s.name,kind:s.kind,width:s.width,height:s.height,sourcePath:s.sourcePath,diagnostics:s.diagnostics})),pageData:t,zip:i,opc:r}}var ji=E((()=>{}));async function Sc(e,t={}){const i=[],r=await Cc(e,i,t.sourcePath),s=[],n=new Set,a=t.maxMeshes??1e4,o=t.maxTriangles??1e7;let l=0,c=0,d=0;for(let u=0;u<r.length&&s.length<a&&d<o;u++)if(r[u]===83)try{const f=Ac(r,u,s.length+1);if(!f)continue;const p=`${f.sourceStart}:${f.sourceEnd}`;if(n.has(p))continue;n.add(p),s.push(f),d+=f.triangleCount,u=Math.max(u,f.sourceEnd-1)}catch(f){const p=String(f);/edgebreaker/i.test(p)?l++:c++}l>0&&i.push(M("warning","W3D_EDGEBREAKER_PARTIAL",`${l} connectivity-compressed shell candidate(s) were skipped.`,t.sourcePath)),s.length===0&&i.push(M("error","W3D_NO_MESHES","No renderable W3D shell meshes were decoded.",t.sourcePath));const h=zc(s);return{kind:"w3d-model",title:t.title??"3D Model",meshes:s,bounds:h,diagnostics:i,sourcePath:t.sourcePath,stats:{meshCount:s.length,vertexCount:s.reduce((u,f)=>u+f.vertexCount,0),triangleCount:s.reduce((u,f)=>u+f.triangleCount,0),decodedBytes:r.byteLength,edgeCount:s.reduce((u,f)=>u+Math.floor((f.edgeIndices?.length??0)/2),0),materialCount:0,textureCount:0,pmiCount:0,nodeCount:0}}}async function Cc(e,t,i){const r=new Hi;for(let s=0;s+6<e.length;s++){if(e[s]!==120)continue;const n=e[s+1];if(n!==1&&n!==94&&n!==156&&n!==218)continue;const a=e.subarray(s),o=Mc(a),l=[];o.length>6&&l.push({label:"raw-deflate-body",data:o.subarray(2,o.length-4)}),a.length>2&&l.push({label:"raw-deflate-body-with-trailer",data:a.subarray(2)}),l.push({label:"zlib-trimmed",data:o}),o.length!==a.length&&l.push({label:"zlib-with-padding",data:a});for(const c of l)try{return await r.inflateRaw(c.data)}catch{}}return e}function Mc(e){let t=e.length;for(;t>0&&e[t-1]===0;)t--;return t===e.length?e:e.subarray(0,t)}function Ac(e,t,i){const r=cs(e,t+1),s=ut(r);let n=0;if((s&ps)!==0&&(n=Hc(r)),(s&fs)!==0||((s&us)===0&&V(r),ut(r),(n&3)!==0))return;const a=(s&65)!==0?ut(r):ir;let o,l,c;if(a===ws){const f=V(r);if(f<=0||r.pos+f>e.length||f>1e8)throw new Error("Bad edgebreaker block length.");r.pos;const p=e.subarray(r.pos,r.pos+f);r.pos+=f;const w=Tc(p);if((s&hs)===0){const m=w.pointCount*3;if(r.pos+m*4>e.length)throw new Error("Edgebreaker shell has no following full-resolution vertex array.");o=os(e,r.pos,m),r.pos+=m*4}else throw new Error("edgebreaker quantized-point reconstruction is not enabled for this shell.");if(l=Ot(w.faces,w.pointCount),c=`edgebreaker-v${p[0]??0}`,l.length<3)throw new Error("Empty edgebreaker face list.")}else if(a===ir){const f=V(r);if(f<=0||f>1e7)throw new Error("Bad uncompressed shell point count.");o=os(e,r.pos,f*3),r.pos+=f*3*4,l=Ot(as(r,f,(s&tr)!==0,!1).indices,f),c="uncompressed"}else if(a===bs){const f=V(r);if(f<=0||f>1e7)throw new Error("Bad compressed shell point count.");const p=(n&gs)===0?ls(r,6):[0,0,0,1,1,1],w=ut(r),m=V(r);if(m<=0||r.pos+m>e.length)throw new Error("Bad compressed shell point payload length.");o=Rc(e.subarray(r.pos,r.pos+m),f,w,p),r.pos+=m,l=Ot(as(r,f,(s&tr)!==0,(n&ms)!==0).indices,f),c=`quantized-${w}`}else throw new Error(`Unsupported W3D shell compression scheme ${a}.`);if(l.length<3||o.length<9)return;const d=Bc(o,l),h=Wc(o,l),u=Uc(o);return{id:`w3d-mesh-${i}`,name:`Mesh ${i}`,positions:o,normals:d,indices:l,edgeIndices:h,vertexCount:Math.floor(o.length/3),triangleCount:Math.floor(l.length/3),bounds:u,color:$c(i),sourceStart:t,sourceEnd:r.pos,decodeKind:c}}function Tc(e){if(e.byteLength<24)throw new Error("Edgebreaker block is too short.");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=e[0],r=e[1],s=e[2],n=e[3],a=t.getInt32(4,!0),o=t.getInt32(8,!0);t.getInt32(12,!0);const l=t.getInt32(16,!0);if(t.getInt32(20,!0),i<0||i>2||r!==0||s<0||s>3||n<0||n>3)throw new Error("Unsupported edgebreaker header.");if(a<=0||o<0||l<=0)throw new Error("Invalid edgebreaker sizes.");let c=i>=1?24:20;const d=e.subarray(c,c+a);if(c+=a+ds(c+a),c+o>e.length)throw new Error("Invalid edgebreaker MTable offset.");const h=Fc(e.subarray(c,c+o));c+=o+ds(c+o);const u=Nc(d,h),f=_c(u.opcodePointCount,h,u.faces),p=[];for(const v of f)p.push(v[1],v[2],v[3]);const w=p.reduce((v,g)=>Math.max(v,g),-1),m=p.reduce((v,g)=>Math.min(v,g),l);if(m<0||w>=l)throw new Error(`Edgebreaker face index range ${m}..${w} is outside point count ${l}.`);return{pointCount:l,faces:p,triangleCount:p.length/3,diagnostics:[]}}function Fc(e){const t=cs(e,0),i=V(t),r=(i&vs)!==0?V(t):0,s=(i&ys)!==0?V(t):0,n=(i&xs)!==0?s:0,a=(i&ks)!==0?V(t):0,o=(i&Es)!==0?V(t):0,l=er(t,r),c=er(t,s),d=er(t,n),h=[];let u=0;for(let w=0;w<a;w++)u+=V(t),h.push(u);const f=[],p=new Map;u=0;for(let w=0;w<o;w+=2){const m=V(t)+u;u=m;const v=V(t);f.push(m,v),p.set(m,v)}return{flags:i,mlengths:l,m2stackoffsets:c,m2gateoffsets:d,dummies:h,patches:f,patchMap:p,bounding:(i&Ps)!==0?ls(t,6):void 0,quantization:(i&Ss)!==0?[V(t),V(t),V(t)]:[11,11,11],normalQuantization:(i&Cs)!==0?[V(t),V(t),V(t)]:[11,11,11]}}function Nc(e,t){const i=Array.from(e),r=[];let s=0,n=0;for(;n<i.length;){const{ecount:a,offsets:o}=Ic(i,n,t);if(a<=0)throw new Error(`Invalid edgebreaker boundary loop length ${a}.`);const l=[],c=[],d=[],h=[],u=[];for(let g=0;g<a;g++)c[g]=g-1,l[g]=g+1,d[g]=s++,h[g]=j;c[0]=a-1,l[a-1]=0;let f=0,p=0,w=a;const m=[],v=[];for(;;){for(v.length===0&&v.push(w++);w+2>=l.length;)l.push(0),c.push(0),d.push(0),h.push(j);const g=u.length;u.push({start:0,twin:j},{start:0,twin:j},{start:0,twin:j});const x=[3,d[f],d[l[f]],-1];h[f]!==j&&h[f]>=0&&h[f]<u.length&&(u[h[f]].twin=g),u[g].twin=h[f],u[g].start=d[f],u[g+1].start=d[l[f]];const y=i[n++];if(y===rr){x[3]=s,u[g+1].twin=j,u[g+2].twin=j,u[g+2].start=s;const b=v.pop();l[c[f]]=b,c[b]=c[f],l[b]=f,c[f]=b,d[b]=d[f],d[f]=s,h[f]=g+1,h[b]=g+2,s++}else if(y===nr)x[3]=d[c[f]],u[g+1].twin=j,u[g+2].twin=h[c[f]],h[c[f]]!==j&&h[c[f]]>=0&&h[c[f]]<u.length&&(u[h[c[f]]].twin=g+2),u[g+2].start=d[c[f]],d[f]=d[c[f]],v.push(c[f]),c[f]=c[c[f]],l[c[f]]=f,h[f]=g+1;else if(y===zt)if(x[3]=d[c[f]],u[g+1].twin=h[l[f]],h[l[f]]!==j&&h[l[f]]>=0&&h[l[f]]<u.length&&(u[h[l[f]]].twin=g+1),u[g+2].twin=h[c[f]],h[c[f]]!==j&&h[c[f]]>=0&&h[c[f]]<u.length&&(u[h[c[f]]].twin=g+2),u[g+2].start=d[c[f]],v.push(f,c[f],l[f]),Ki(x)&&r.push(x),m.length>0)f=m.pop();else break;else if(y===sr)x[3]=d[l[l[f]]],u[g+1].twin=h[l[f]],h[l[f]]!==j&&h[l[f]]>=0&&h[l[f]]<u.length&&(u[h[l[f]]].twin=g+1),u[g+2].twin=j,u[g+2].start=d[l[l[f]]],v.push(l[f]),l[f]=l[l[f]],c[l[f]]=f,h[f]=g+2;else if(y===ar){let b=f;const k=(o[p]??0)+1;for(let N=0;N<k;N++)b=l[b];x[3]=d[l[b]],u[g+1].twin=j,u[g+2].twin=j,u[g+2].start=d[l[b]],p++;const T=v.pop();m.push(T),l[c[f]]=T,c[T]=c[f],l[T]=l[b],c[l[b]]=T,h[T]=g+2,d[T]=d[f],d[f]=d[l[b]],h[f]=g+1,c[f]=b,l[b]=f}else throw new Error(`Unsupported edgebreaker opcode ${y}.`);if(y!==zt)if(Ki(x))r.push(x);else throw new Error("Invalid edgebreaker triangle.");if(n>=i.length)break}}return{faces:r,opcodePointCount:s}}function Ic(e,t,i){let r=0,s=0,n=0,a=0;const o=[],l=[],c=[];for(let d=t;d<e.length;d++){const h=e[d];if(h===rr)r-=1;else if(h===nr)r+=1;else if(h===zt)if(r+=3,o.length>0){const u=l.pop();c[u]=r-2-o.pop()}else break;else if(h===sr)r+=1;else if(h===ar)r-=1,l.push(s),o.push(r),c[s]=0,s++;else if(h===Ms){const u=i.mlengths[n++]??0;r-=u+1}else if(h===As)i.mlengths[a],r-=1,a++;else throw new Error(`Bad edgebreaker opcode ${h}.`)}return{ecount:r,offsets:c}}function _c(e,t,i){const r=new Int32Array(e);for(const a of t.dummies)a>=0&&a<e&&(r[a]=Ut);for(let a=0;a+1<t.patches.length;a+=2){const o=t.patches[a];o>=0&&o<e&&r[o]!==Ut&&(r[o]=or)}let s=0;for(let a=0;a<e;a++)r[a]<0?s++:r[a]=s;const n=[];for(const a of i){const o=a[1],l=a[2],c=a[3];if(Zi(o,r)||Zi(l,r)||Zi(c,r))continue;const d=[3,qi(o,r,t),qi(l,r,t),qi(c,r,t)];Ki(d)&&n.push(d)}return n}function qi(e,t,i){return t[e]===or?i.patchMap.get(e)??e:e-t[e]}function Zi(e,t){return e<0||e>=t.length||t[e]===Ut}function Ki(e){return e[1]!==e[2]&&e[2]!==e[3]&&e[3]!==e[1]&&e[1]>=0&&e[2]>=0&&e[3]>=0}function as(e,t,i,r){ut(e);const s=V(e);if(s<=0||e.pos+s>e.bytes.length)throw new Error("Bad compressed face-list payload length.");const n=e.bytes.subarray(e.pos,e.pos+s);e.pos+=s;const a=Lc(n,r);return{indices:Dc(a,t,i),values:a}}function Lc(e,t){if(e.length<2)throw new Error("Face payload is too short.");const i=e[0],r=i/8;if(r!==1&&r!==2&&r!==4)throw new Error(`Unsupported face-list sample width ${i}.`);const s=[],n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=1;a+r<=e.length;a+=r)r===1?s.push(t?n.getInt8(a):n.getUint8(a)):r===2?s.push(t?n.getInt16(a,!0):n.getUint16(a,!0)):s.push(t?n.getInt32(a,!0):n.getUint32(a,!0));return s}function Dc(e,t,i){const r=[];let s=0;for(;s<e.length;){const n=e[s++],a=Math.abs(n);if(a<3||s+a>e.length)throw new Error("Invalid face list run.");const o=e.slice(s,s+a);if(s+=a,o.some(l=>l<0||l>=t))throw new Error("Face index out of range.");if(i)if(n>0)for(let l=2;l<o.length;l++)(l&1)===0?r.push(o[l-2],o[l-1],o[l]):r.push(o[l-1],o[l-2],o[l]);else for(let l=2;l<o.length;l++)r.push(o[0],o[l-1],o[l]);else if(n>0)for(let l=2;l<o.length;l++)r.push(o[0],o[l-1],o[l])}return r}function Rc(e,t,i,r){if(i===8){if(e.length<t*3)throw new Error("Short 8-bit quantized point payload.");const o=new Float32Array(t*3);for(let l=0;l<t;l++)for(let c=0;c<3;c++){const d=e[l*3+c],h=r[c],u=r[c+3];o[l*3+c]=d===255?u:h+(u-h)*(d/255)}return o}const s=new Float32Array(t*3);let n=0;const a=(1<<i)-1;for(let o=0;o<t*3;o++){let l=0;for(let u=0;u<i;u++){const f=e[n>>3]??0;l=l<<1|f>>7-(n&7)&1,n++}const c=o%3,d=r[c],h=r[c+3];s[o]=l===a?h:d+(h-d)*(l/a)}return s}function Ot(e,t){return t<=65535?new Uint16Array(e):new Uint32Array(e)}function Bc(e,t){const i=new Float32Array(e.length);for(let r=0;r+2<t.length;r+=3){const s=t[r]*3,n=t[r+1]*3,a=t[r+2]*3,o=e[s],l=e[s+1],c=e[s+2],d=e[n],h=e[n+1],u=e[n+2],f=e[a],p=e[a+1],w=e[a+2],m=d-o,v=h-l,g=u-c,x=f-o,y=p-l,b=w-c,k=v*b-g*y,T=g*x-m*b,N=m*y-v*x;i[s]=(i[s]??0)+k,i[s+1]=(i[s+1]??0)+T,i[s+2]=(i[s+2]??0)+N,i[n]=(i[n]??0)+k,i[n+1]=(i[n+1]??0)+T,i[n+2]=(i[n+2]??0)+N,i[a]=(i[a]??0)+k,i[a+1]=(i[a+1]??0)+T,i[a+2]=(i[a+2]??0)+N}for(let r=0;r<i.length;r+=3){const s=i[r],n=i[r+1],a=i[r+2],o=Math.hypot(s,n,a)||1;i[r]=s/o,i[r+1]=n/o,i[r+2]=a/o}return i}function Wc(e,t,i=Math.PI/5){if(t.length<3)return;const r=[],s=new Map;for(let o=0,l=0;o+2<t.length;o+=3,l++){const c=t[o],d=t[o+1],h=t[o+2],u=Oc(e,c,d,h);r.push(u),Qi(s,c,d,l),Qi(s,d,h,l),Qi(s,h,c,l)}const n=Math.cos(i),a=[];for(const o of s.values())if(o.tris.length===1)a.push(o.a,o.b);else if(o.tris.length>=2){let l=!1;for(let c=0;c<o.tris.length&&!l;c++)for(let d=c+1;d<o.tris.length;d++){const h=r[o.tris[c]],u=r[o.tris[d]];if(h[0]*u[0]+h[1]*u[1]+h[2]*u[2]<n){l=!0;break}}l&&a.push(o.a,o.b)}if(a.length!==0)return Ot(a,Math.floor(e.length/3))}function Oc(e,t,i,r){const s=t*3,n=i*3,a=r*3,o=e[s],l=e[s+1],c=e[s+2],d=e[n],h=e[n+1],u=e[n+2],f=e[a],p=e[a+1],w=e[a+2],m=d-o,v=h-l,g=u-c,x=f-o,y=p-l,b=w-c;let k=v*b-g*y,T=g*x-m*b,N=m*y-v*x;const $=Math.hypot(k,T,N)||1;return k/=$,T/=$,N/=$,[k,T,N]}function Qi(e,t,i,r){const s=Math.min(t,i),n=Math.max(t,i),a=`${s}:${n}`;let o=e.get(a);o||(o={a:s,b:n,tris:[]},e.set(a,o)),o.tris.push(r)}function zc(e){if(e.length===0)return{min:[0,0,0],max:[1,1,1],center:[.5,.5,.5],radius:1};const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const s of e)for(let n=0;n<3;n++)t[n]=Math.min(t[n],s.bounds.min[n]),i[n]=Math.max(i[n],s.bounds.max[n]);const r=[(t[0]+i[0])/2,(t[1]+i[1])/2,(t[2]+i[2])/2];return{min:t,max:i,center:r,radius:Math.max(1e-6,Math.hypot(i[0]-r[0],i[1]-r[1],i[2]-r[2]))}}function Uc(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let r=0;r<e.length;r+=3){const s=e[r],n=e[r+1],a=e[r+2];s<t[0]&&(t[0]=s),n<t[1]&&(t[1]=n),a<t[2]&&(t[2]=a),s>i[0]&&(i[0]=s),n>i[1]&&(i[1]=n),a>i[2]&&(i[2]=a)}return{min:t,max:i}}function $c(e){const t=e*.61803398875%1,i=.34,r=.62,s=.96-r*i,n=2*r-s;return[Ji(n,s,t+1/3),Ji(n,s,t),Ji(n,s,t-1/3)]}function Ji(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*(2/3-i)*6:e}function os(e,t,i){if(t+i*4>e.length)throw new Error("Float array exceeds W3D stream length.");const r=new Float32Array(i),s=new DataView(e.buffer,e.byteOffset+t,i*4);for(let n=0;n<i;n++)r[n]=s.getFloat32(n*4,!0);return r}function ls(e,t){const i=[];for(let r=0;r<t;r++)i.push(Vc(e));return i}function er(e,t){const i=[];for(let r=0;r<t;r++)i.push(V(e));return i}function cs(e,t=0){return{bytes:e,pos:t,view:new DataView(e.buffer,e.byteOffset,e.byteLength)}}function ut(e){if(e.pos>=e.bytes.length)throw new Error("Unexpected end of W3D stream.");return e.bytes[e.pos++]}function Hc(e){const t=e.view.getUint16(e.pos,!0);return e.pos+=2,t}function V(e){const t=e.view.getInt32(e.pos,!0);return e.pos+=4,t}function Vc(e){const t=e.view.getFloat32(e.pos,!0);return e.pos+=4,t}function ds(e){return 3-(e-1)%4}var hs,tr,us,fs,ps,ms,gs,bs,ir,ws,vs,ys,xs,ks,Es,Ps,Ss,Cs,rr,nr,zt,sr,ar,Ms,As,j,Ut,or,Xc=E((()=>{Vi(),te(),hs=1,tr=4,us=16,fs=32,ps=128,ms=4,gs=8,bs=1,ir=4,ws=5,vs=1,ys=2,xs=4,ks=8,Es=16,Ps=32,Ss=64,Cs=128,rr=0,nr=1,zt=2,sr=3,ar=4,Ms=5,As=6,j=-2139062144,Ut=-2139062145,or=-2139062146}));async function Gc(e,t,i){const r=e.diagnostics;e.metadata??(e.metadata={}),e.materials??(e.materials=[]),e.textures??(e.textures=[]),e.sceneTree??(e.sceneTree=[]),e.pmi??(e.pmi=[]),e.views??(e.views=[]),e.animations??(e.animations=[]),await Yc(e,t,i,r);const s=t.find(h=>/descriptor/i.test(h.role??"")||/descriptor\.xml$/i.test(h.path));if(s&&i.zip.has(s.path))try{jc(e,ae(await i.readBytes(s.path)),s.path)}catch(h){r.push(M("warning","EMODEL_DESCRIPTOR_PARSE_FAILED",`Failed to parse eModel descriptor: ${String(h)}`,s.path))}const n=t.find(h=>/content\s+definition/i.test(h.role??"")),a=n&&i.zip.has(n.path)?Zc(e,ae(await i.readBytes(n.path)),n.path,r):[],o=t.find(h=>/content\s+presentation/i.test(h.role??"")),l=new Map;let c=new Map;if(o&&i.zip.has(o.path))try{const{nodes:h,pmi:u,views:f,animations:p,materials:w}=Kc(ae(await i.readBytes(o.path)),o.path,l);c=w,e.sceneTree=h,e.pmi=u,e.views=Is(e.views??[],f),e.animations=p;const m=new Map((e.materials??[]).map(v=>[v.id,v]));for(const v of w.values())m.set(v.id,Jc(v,e.textures??[]));e.materials=Array.from(m.values())}catch(h){r.push(M("warning","EMODEL_PRESENTATION_PARSE_FAILED",`Failed to parse eModel presentation: ${String(h)}`,o.path))}ed(e,a,l,c);const d=Ls(e.sceneTree??[]);(e.views?.length??0)>0&&!e.initialView&&(e.initialView=e.views[0]),e.stats.materialCount=e.materials?.length??0,e.stats.textureCount=e.textures?.length??0,e.stats.pmiCount=e.pmi?.length??0,e.stats.nodeCount=d}async function Yc(e,t,i,r){const s=[];for(const n of t.filter(a=>/texture/i.test(a.role??"")||/texture/i.test(a.title??""))){if(!i.zip.has(n.path))continue;let a,o;try{const l=sd(await i.readBytes(n.path));a=l?.width,o=l?.height}catch(l){r.push(M("warning","EMODEL_TEXTURE_SIZE_FAILED",`Failed to read texture size: ${String(l)}`,n.path))}s.push({id:n.path,name:Ds(n.title)??nd(n.path),path:n.path,mediaType:n.mediaType,width:a,height:o,role:n.role})}if(e.textures=s,s.length>0){const n=s.find(a=>/thread/i.test(a.name??""))??s.find(a=>!/environment/i.test(a.name??""))??s[0];n&&(e.materials=[{id:"dwfx-default-textured",name:"DWFx default material",color:[.72,.74,.78],textureId:n.id,roughness:.6,metalness:.03,doubleSided:!0,source:n.path}])}}function jc(e,t,i){const r=Q(t,i),s=r.documentElement;if(s){const a=Array.from(s.getElementsByTagName("*")).find(l=>A(l)==="Units")?.getAttribute("type");a&&(e.metadata.units=a);const o=s.getAttribute("name");o&&(e.metadata.spaceName=o)}for(const a of Array.from(r.getElementsByTagName("*")).filter(o=>A(o)==="Property")){const o=a.getAttribute("name"),l=a.getAttribute("value");o&&l&&(e.metadata[o]=l)}const n=qc(e.metadata);n&&(e.views=Is(e.views??[],[n]),e.initialView=n)}function qc(e){const t=Ht(e._ViewCubeHomeCameraPosition),i=Ht(e._ViewCubeHomeCameraTarget),r=Ht(e._ViewCubeHomeCameraUpVector),s=Ht(e._ViewCubeHomeCameraField);if(!(!t&&!i&&!r))return{id:"descriptor-home-view",label:"Home",camera:{position:t,target:i,up:r,field:s,projection:e._ViewCubeHomeCameraProjection==="1"?"perspective":"orthographic"}}}function Zc(e,t,i,r){try{const s=Q(t,i),n=[];for(const a of Array.from(s.getElementsByTagName("*")).filter(o=>A(o)==="Instance")){const o=a.getAttribute("id")??"";o&&n.push({id:o,renderableRef:a.getAttribute("renderableRef")??void 0,node:a.getAttribute("node")??void 0,geometricVariation:a.getAttribute("geometricVariation")??void 0})}return e.metadata.contentInstanceCount=String(n.length),n}catch(s){return r.push(M("warning","EMODEL_CONTENTDEF_PARSE_FAILED",`Failed to parse eModel content definition: ${String(s)}`,i)),[]}}function Kc(e,t,i){const r=Q(e,t),s=Array.from(r.getElementsByTagName("*")).filter(d=>A(d)==="View"),n=[];for(const d of s){const h=Ts(d);for(const u of h)n.push(cr(u,i))}if(n.length===0)for(const d of Array.from(r.getElementsByTagName("*")).filter(h=>A(h)==="ReferenceNode"&&!id(h)))n.push(cr(d,i));const a=[];for(const d of Array.from(r.getElementsByTagName("*")).filter(h=>/ModelViewNode|View/i.test(A(h)))){const h=d.getAttribute("id")??`view-${a.length+1}`,u=d.getAttribute("label")??d.getAttribute("name")??h,f=Vt(d).find(w=>A(w)==="Camera")??Array.from(d.getElementsByTagName("*")).find(w=>A(w)==="Camera"),p=f?td(f):void 0;(p||/ModelViewNode/i.test(A(d)))&&a.push({id:h,label:u,camera:p})}const o=[];for(const d of Array.from(r.getElementsByTagName("*"))){const h=A(d);/PMI|Markup|Dimension|Annotation|Callout|Leader|Note/i.test(h)&&o.push({id:d.getAttribute("id")??`pmi-${o.length+1}`,type:/Leader/i.test(h)?"leader":/Text|Note|Dimension/i.test(h)?"text":"markup",label:d.getAttribute("label")??d.getAttribute("name")??h,text:d.getAttribute("text")??d.textContent?.trim()??void 0,targetRef:d.getAttribute("contentElementRefs")??d.getAttribute("target")??void 0,properties:Ns(d)})}const l=[];for(const d of Array.from(r.getElementsByTagName("*")).filter(h=>/Animation|Sequence|Timeline/i.test(A(h))))l.push({id:d.getAttribute("id")??`animation-${l.length+1}`,name:d.getAttribute("label")??d.getAttribute("name")??A(d),targetRef:d.getAttribute("target")??void 0});const c=Qc(r);return{nodes:n,pmi:o,views:_s(a),animations:l,materials:c}}function Qc(e){const t=new Map;for(const i of Array.from(e.getElementsByTagName("*")).filter(r=>A(r)==="InstanceAttributes")){const r=i.getAttribute("id");if(!r)continue;const s=Vt(i).find(u=>A(u)==="Color")??Array.from(i.getElementsByTagName("*")).find(u=>A(u)==="Color");if(!s)continue;const n=Array.from(s.getElementsByTagName("*")).find(u=>A(u)==="Channel"&&/diffuse/i.test(u.getAttribute("type")??"")),a=Array.from(s.getElementsByTagName("*")).find(u=>A(u)==="Channel"&&/environment/i.test(u.getAttribute("type")??"")),o=Number(n?.getAttribute("red")),l=Number(n?.getAttribute("green")),c=Number(n?.getAttribute("blue"));if(![o,l,c].every(Number.isFinite))continue;const d=Number(s.getAttribute("gloss")),h=Ds(a?.getAttribute("name")??void 0);t.set(r,{id:`material-${r}`,name:`Material ${r}`,color:[o,l,c],opacity:1,roughness:Number.isFinite(d)?Math.max(.12,Math.min(.92,1-d/128)):.58,metalness:.03,textureName:h,doubleSided:!0,source:"content-presentation"})}return t}function Jc(e,t){if(e.textureId||!e.textureName)return e;const i=lr(e.textureName),r=t.find(s=>lr(s.name??"").includes(i)||i.includes(lr(s.name??"")));return r?{...e,textureId:r.id}:e}function lr(e){return e.replace(/"/g,"").replace(/["{}]/g,"").toLowerCase()}function cr(e,t){const i=rd(e.getAttribute("contentElementRefs")??e.getAttribute("contentRefs")??""),r={id:e.getAttribute("id")??`node-${Math.random().toString(36).slice(2)}`,label:e.getAttribute("label")??e.getAttribute("name")??A(e),contentRefs:i,meshIds:[],children:[],properties:Ns(e)};for(const s of i)t.set(s,r);for(const s of Ts(e))r.children.push(cr(s,t));return r}function ed(e,t,i,r){const s=new Map(i),n=t.length===e.meshes.length;t.forEach((a,o)=>{const l=e.meshes[o];if(!l)return;const c=[a.renderableRef,a.id].filter(Boolean);l.selectionRefs=c,l.nodeId=a.node;const d=r.get(a.id)??(a.renderableRef?r.get(a.renderableRef):void 0);d&&n&&(l.materialId=d.id,l.color=d.color);for(const h of c){const u=s.get(h);if(u){l.name=u.label||l.name,u.meshIds.push(l.id);break}}})}function td(e){return{position:$t(e,"positionX","positionY","positionZ"),target:$t(e,"targetX","targetY","targetZ"),up:$t(e,"upVectorX","upVectorY","upVectorZ"),field:$t(e,"fieldWidth","fieldHeight","fieldDepth"),projection:e.getAttribute("projectionType")??void 0}}function $t(e,t,i,r){const s=[Number(e.getAttribute(t)),Number(e.getAttribute(i)),Number(e.getAttribute(r))];return s.every(Number.isFinite)?s:void 0}function Ht(e){if(!e)return;const t=e.trim().split(/[\s,]+/).map(Number).filter(Number.isFinite);return t.length>=3?[t[0],t[1],t[2]]:void 0}function Vt(e){return Array.from(e.children)}function Ts(e){const t=[];for(const i of Vt(e)){const r=A(i);if(r.endsWith("Node"))t.push(i);else if(r==="Nodes"||r==="Views")for(const s of Vt(i))A(s).endsWith("Node")&&t.push(s)}return t}function id(e){let t=Fs(e);for(;t;){if(A(t)==="ReferenceNode")return!0;t=Fs(t)}return!1}function Fs(e){return(e.parentElement??e.parentNode)||void 0}function Ns(e){const t={};for(const i of Array.from(e.attributes))t[i.localName||i.name]=i.value;return t}function rd(e){return e.trim().split(/[\s,]+/).filter(Boolean)}function Is(e,t){return _s([...e,...t])}function _s(e){const t=new Set,i=[];for(const r of e){const s=r.id||r.label;t.has(s)||(t.add(s),i.push(r))}return i}function Ls(e){let t=0;for(const i of e)t+=1+Ls(i.children);return t}function nd(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Ds(e){if(e)return e.replace(/^"|"$/g,"").replace(/"/g,'"')}function sd(e){if(e.length>=24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return{width:Rs(e,16),height:Rs(e,20)};if(e.length>=4&&e[0]===255&&e[1]===216){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}const i=e[t+1];for(t+=2;e[t]===255;)t++;if(i===217||i===218||t+2>e.length)break;const r=e[t]<<8|e[t+1];if(r<2||t+r>e.length)break;if(i>=192&&i<=195||i>=197&&i<=199||i>=201&&i<=203||i>=205&&i<=207)return{width:e[t+5]<<8|e[t+6],height:e[t+3]<<8|e[t+4]};t+=r}}}function Rs(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var ad=E((()=>{ue(),te()}));async function Bs(e){const t=await kc(e),i=[],r=[],s=await ld(t,r,i);if(r.length===0){const n=await dd(t,i);for(const a of n)try{const o=Q(await t.readText(a),a),l=Array.from(o.getElementsByTagName("*")).filter(c=>A(c)==="DocumentReference");l.length===0&&i.push(M("warning","DWFX_NO_DOCREF",`No DocumentReference elements found in ${a}.`,a));for(const c of l){const d=c.getAttribute("Source");d&&await hd(t,Xe(a,d),r,i)}}catch(o){i.push(M("warning","DWFX_FDSEQ_READ_FAILED",`Failed to read fixed document sequence: ${String(o)}`,a))}}if(r.length===0){const n=e.entries.filter(a=>/\.fpage$/i.test(a.name));for(const[a,o]of n.entries()){const l=await dr(t,o.name,i);r.push({id:`page-${a+1}`,name:o.name.split("/").pop()??`Page ${a+1}`,kind:"xps-fixed-page",sourcePath:o.name,width:l.width,height:l.height,diagnostics:[]})}}if(r.length===0){const n=e.entries.some(a=>/\.(w3d|hsf)$/i.test(a.name))||s.some(a=>/emodel/i.test(a.type));r.push({id:"unsupported-1",name:n?"Unsupported 3D DWFx package":"Unsupported DWFx package",kind:"unsupported",width:1e3,height:1e3,reason:n?"This DWFx package contains 3D eModel/W3D content but no supported 2D FixedPage or preview image resource was found.":"No XPS FixedPage parts or supported DWF manifest preview resources were found.",diagnostics:[M("error","DWFX_NO_PAGES","No supported renderable page was found in this DWFx package.")]})}return Wt({kind:"dwfx",pages:[],resources:t.resources,diagnostics:i,packageEntries:e.entries.map(n=>n.name)},r,e,t)}function od(e){return e.has("[Content_Types].xml")&&(e.has("_rels/.rels")||e.entries.some(t=>/\.(fpage|dwfseq)$/i.test(t.name)))}async function ld(e,t,i){const r=await cd(e,i),s=[];for(const n of r)try{const a=ud(await e.readText(n),n);s.push(...a),i.push(M("info","DWFX_DWF_MANIFEST_FOUND",`Found DWFx DWF manifest with ${a.length} section(s).`,n))}catch(a){i.push(M("warning","DWFX_DWF_MANIFEST_PARSE_FAILED",`Failed to parse DWFx DWF manifest: ${String(a)}`,n))}for(const n of s.filter(a=>fd(a))){const a=Os(n,/2d\s+streaming\s+graphics/i)??n.resources.find(c=>/\.fpage$/i.test(c.path));if(!a||!/\.fpage$/i.test(Me(a.path)))continue;const o=Me(a.path);if(!e.zip.has(o))continue;const l=await dr(e,o,i);t.push({id:`page-${t.length+1}`,name:n.title||a.title||Xt(o),kind:"xps-fixed-page",sourcePath:o,width:Number.isFinite(l.width)&&l.width>0?l.width:1e3,height:Number.isFinite(l.height)&&l.height>0?l.height:1e3,diagnostics:[]})}if(t.length>0)return s;for(const n of s.filter(a=>pd(a))){const a=md(n,e.zip),o=Os(n,/3d\s+streaming\s+graphics/i)??n.resources.find(l=>/\.(w3d|hsf)$/i.test(l.path));if(o&&e.zip.has(o.path))try{const l=await Sc(await e.zip.read(o.path),{title:n.title||o.title||Xt(o.path),sourcePath:o.path});if(await Gc(l,n.resources,e),l.meshes.length>0){t.push({id:`w3d-${t.length+1}`,name:n.title||o.title||Xt(o.path),kind:"w3d-model",sourcePath:o.path,width:1e3,height:1e3,model:l,diagnostics:l.diagnostics});continue}t.push({id:`unsupported-3d-${t.length+1}`,name:n.title||"Unsupported 3D eModel",kind:"unsupported",width:1e3,height:1e3,sourcePath:o.path,reason:"A W3D/HSF 3D stream exists, but no renderable shell geometry was decoded. The package is intentionally not shown as a thumbnail so this failure is visible during production validation.",diagnostics:[...l.diagnostics,M("warning","DWFX_3D_W3D_UNSUPPORTED","Detected a 3D W3D resource, but no renderable shell geometry was decoded.",o.path)]});continue}catch(l){t.push({id:`unsupported-3d-${t.length+1}`,name:n.title||"Unsupported 3D eModel",kind:"unsupported",width:1e3,height:1e3,sourcePath:o.path,reason:`A W3D/HSF 3D stream exists, but geometry parsing failed: ${String(l)}`,diagnostics:[M("warning","DWFX_W3D_PARSE_FAILED",`Failed to parse W3D geometry: ${String(l)}`,o.path)]});continue}if(a&&e.zip.has(a.path)){const l=bd(await e.zip.read(a.path))??{width:1e3,height:1e3};t.push({id:`image-${t.length+1}`,name:n.title||a.title||Xt(a.path),kind:"image",sourcePath:a.path,mediaType:a.mediaType??De(a.path)??"image/png",width:l.width,height:l.height,diagnostics:[M("info","DWFX_3D_PREVIEW_ONLY","No W3D/HSF geometry stream was declared; showing the embedded section preview image.",a.path)]})}}return s}async function cd(e,t){const i=new Set,r=n=>{n&&i.add(U(Me(n)))},s=new Set;try{const n=await e.getRelationships("");for(const a of n)(/documentsequence/i.test(a.type)||/\.dwfseq$/i.test(a.resolvedTarget))&&s.add(U(a.resolvedTarget)),/document$/i.test(a.type)&&/manifest\.xml$/i.test(a.resolvedTarget)&&r(a.resolvedTarget)}catch(n){t.push(M("warning","DWFX_DWFSEQ_RELS_FAILED",`Failed to inspect DWFx package relationships: ${String(n)}`))}for(const n of e.zip.entries)/\.dwfseq$/i.test(n.name)&&s.add(n.name);for(const n of s)if(e.zip.has(n))try{const a=Q(await e.readText(n),n),o=Array.from(a.getElementsByTagName("*")).filter(c=>A(c)==="ManifestReference");for(const c of o)r(c.getAttribute("Source")??c.getAttribute("source")??void 0);const l=await e.getRelationships(n).catch(()=>[]);for(const c of l)(/document/i.test(c.type)||/manifest\.xml$/i.test(c.resolvedTarget))&&r(c.resolvedTarget)}catch(a){t.push(M("warning","DWFX_DWFSEQ_READ_FAILED",`Failed to read DWFDocumentSequence ${n}: ${String(a)}`,n))}for(const n of e.zip.entries)/^dwf\/documents\/.*\/manifest\.xml$/i.test(n.name)&&r(n.name);return Array.from(i).filter(n=>e.zip.has(n))}async function dd(e,t){const i=new Set;try{const r=await e.getRelationships("");for(const s of r)(Us.has(s.type)||/fixedrepresentation/i.test(s.type)||/\.fdseq$/i.test(s.resolvedTarget))&&i.add(U(s.resolvedTarget))}catch(r){t.push(M("warning","DWFX_ROOT_RELS_FAILED",`Failed to read package relationships: ${String(r)}`))}for(const r of e.overrides)(/fixeddocumentsequence/i.test(r.contentType)||/\.fdseq$/i.test(r.partName))&&i.add(r.partName);for(const r of e.zip.entries)/\.fdseq$/i.test(r.name)&&i.add(r.name);return Array.from(i)}async function hd(e,t,i,r){let s;try{s=await e.readText(t)}catch(o){r.push(M("warning","DWFX_FDOC_READ_FAILED",`Failed to read fixed document ${t}: ${String(o)}`,t));return}const n=Q(s,t),a=Array.from(n.getElementsByTagName("*")).filter(o=>A(o)==="PageContent");for(const o of a){const l=o.getAttribute("Source");if(!l)continue;let c=Xe(t,Me(l));const d=l.startsWith("#")?l.slice(1):void 0;if(d){const w=(await e.getRelationships(t)).find(m=>m.id===d);w&&(c=w.resolvedTarget)}c=Me(c);const h=o.getAttribute("Width"),u=o.getAttribute("Height"),f=h&&u?{width:Number(h),height:Number(u)}:await dr(e,c,r),p=i.length+1;i.push({id:`page-${p}`,name:`Page ${p}`,kind:"xps-fixed-page",sourcePath:c,width:Number.isFinite(f.width)&&f.width>0?f.width:1e3,height:Number.isFinite(f.height)&&f.height>0?f.height:1e3,diagnostics:[]})}}async function dr(e,t,i){try{const r=Me(t),s=Q(ae(await e.readBytes(r)),r),n=s.documentElement??Array.from(s.getElementsByTagName("*"))[0];return{width:Number(n?.getAttribute("Width")??1e3),height:Number(n?.getAttribute("Height")??1e3)}}catch(r){return i.push(M("warning","DWFX_PAGE_SIZE_FAILED",`Failed to read FixedPage size: ${String(r)}`,t)),{width:1e3,height:1e3}}}function ud(e,t){const i=Q(e,t);return Array.from(i.getElementsByTagName("*")).filter(r=>A(r)==="Section").map((r,s)=>{const n=Ce(r,"name")??`section-${s+1}`,a=Ce(r,"title")??n;return{type:Ce(r,"type")??"",name:n,title:a,resources:Array.from(r.getElementsByTagName("*")).filter(o=>A(o).endsWith("Resource")||A(o)==="Resource").map(o=>({path:U(Me(Ce(o,"href")??"")),role:Ce(o,"role"),mediaType:Ce(o,"mime"),title:Ce(o,"title"),size:gd(o,"size")})).filter(o=>o.path.length>0)}}).filter(r=>r.resources.length>0||r.type.length>0)}function fd(e){return/(^|\.)ePlot$/i.test(e.type)||/com\.autodesk\.dwf\.ePlot$/i.test(e.type)}function pd(e){return/(^|\.)eModel$/i.test(e.type)||/com\.autodesk\.dwf\.eModel$/i.test(e.type)}function md(e,t){const i=e.resources.filter(n=>/^(image\/|application\/octet-stream)/i.test(n.mediaType??"")||/\.(png|jpe?g|gif|bmp)$/i.test(n.path)),r=i.filter(n=>/thumbnail|preview/i.test(n.role??"")||/thumbnail|preview/i.test(n.title??"")),s=r.length>0?r:i.filter(n=>!/texture/i.test(n.role??""));return(s.length>0?s:i).filter(n=>t.has(n.path)).sort((n,a)=>Ws(a)-Ws(n))[0]}function Ws(e){let t=e.size??0;return/thumbnail/i.test(e.role??"")&&(t+=5e6),/preview/i.test(e.role??"")&&(t+=4e6),/icon/i.test(e.role??"")&&(t-=2e6),/texture/i.test(e.role??"")&&(t-=3e6),t}function Ce(e,t){return e.getAttribute(t)??e.getAttribute(`dwf:${t}`)??e.getAttribute(`ePlot:${t}`)??e.getAttribute(`eModel:${t}`)??Array.from(e.attributes).find(i=>i.localName===t)?.value??void 0}function gd(e,t){const i=Ce(e,t);if(i===void 0)return;const r=Number(i);return Number.isFinite(r)?r:void 0}function Os(e,t){return e.resources.find(i=>t.test(i.role??""))}function Me(e){return U((e.split(/[?#]/)[0]??e).replace(/^\//,""))}function Xt(e){const t=Me(e),i=t.lastIndexOf("/");return i>=0?t.slice(i+1):t}function bd(e){if(e.length>=24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return{width:zs(e,16),height:zs(e,20)};if(e.length>=4&&e[0]===255&&e[1]===216){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}const i=e[t+1];for(t+=2;e[t]===255;)t++;if(i===217||i===218||t+2>e.length)break;const r=e[t]<<8|e[t+1];if(r<2||t+r>e.length)break;if(i>=192&&i<=195||i>=197&&i<=199||i>=201&&i<=203||i>=205&&i<=207)return{width:e[t+5]<<8|e[t+6],height:e[t+3]<<8|e[t+4]};t+=r}}}function zs(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Us,wd=E((()=>{te(),Pc(),ue(),ji(),Xc(),ad(),Us=new Set(["http://schemas.microsoft.com/xps/2005/06/fixedrepresentation","http://schemas.openxps.org/oxps/v1.0/fixedrepresentation"])}));function Ae(e){const t=vd(e),i=[];let r=0,s="",n=0,a=0,o=0,l=0,c,d;const h=()=>r<t.length&&t[r]?.kind==="num",u=()=>{const p=t[r++];if(!p||p.kind!=="num")throw new Error(`Expected number in path data near token ${r}.`);return p.value},f=()=>u()!==0;for(;r<t.length;){const p=t[r];if(!p)break;if(p.kind==="cmd"){if(s=p.value,r++,s==="F"||s==="f"){h()&&u();continue}}else if(!s){r++;continue}const w=s===s.toLowerCase(),m=s.toUpperCase(),v=x=>w?n+x:x,g=x=>w?a+x:x;if(m==="M"){if(!h())continue;const x=v(u()),y=g(u());for(i.push({type:"M",x,y}),n=o=x,a=l=y,c=d=void 0;h();){const b=v(u()),k=g(u());i.push({type:"L",x:b,y:k}),n=b,a=k}}else if(m==="L")for(;h();){const x=v(u()),y=g(u());i.push({type:"L",x,y}),n=x,a=y,c=d=void 0}else if(m==="H")for(;h();){const x=v(u());i.push({type:"L",x,y:a}),n=x,c=d=void 0}else if(m==="V")for(;h();){const x=g(u());i.push({type:"L",x:n,y:x}),a=x,c=d=void 0}else if(m==="C")for(;h();){const x=v(u()),y=g(u()),b=v(u()),k=g(u()),T=v(u()),N=g(u());i.push({type:"C",x1:x,y1:y,x2:b,y2:k,x:T,y:N}),n=T,a=N,c={x:b,y:k},d=void 0}else if(m==="S")for(;h();){const x=c?{x:2*n-c.x,y:2*a-c.y}:{x:n,y:a},y=v(u()),b=g(u()),k=v(u()),T=g(u());i.push({type:"C",x1:x.x,y1:x.y,x2:y,y2:b,x:k,y:T}),n=k,a=T,c={x:y,y:b},d=void 0}else if(m==="Q")for(;h();){const x=v(u()),y=g(u()),b=v(u()),k=g(u());i.push({type:"Q",x1:x,y1:y,x:b,y:k}),n=b,a=k,d={x,y},c=void 0}else if(m==="T")for(;h();){const x=d?{x:2*n-d.x,y:2*a-d.y}:{x:n,y:a},y=v(u()),b=g(u());i.push({type:"Q",x1:x.x,y1:x.y,x:y,y:b}),n=y,a=b,d=x,c=void 0}else if(m==="A")for(;h();){const x=Math.abs(u()),y=Math.abs(u()),b=u(),k=f(),T=f(),N=v(u()),$=g(u());i.push({type:"A",rx:x,ry:y,rotation:b,largeArc:k,sweep:T,x:N,y:$}),n=N,a=$,c=d=void 0}else m==="Z"?(i.push({type:"Z"}),n=o,a=l,c=d=void 0):r++}return i}function Gt(e,t){let i=0,r=0,s=0,n=0;for(const a of t)switch(a.type){case"M":e.moveTo(a.x,a.y),i=s=a.x,r=n=a.y;break;case"L":e.lineTo(a.x,a.y),i=a.x,r=a.y;break;case"C":e.bezierCurveTo(a.x1,a.y1,a.x2,a.y2,a.x,a.y),i=a.x,r=a.y;break;case"Q":e.quadraticCurveTo(a.x1,a.y1,a.x,a.y),i=a.x,r=a.y;break;case"A":{const o=Xs(i,r,a.rx,a.ry,a.rotation,a.largeArc,a.sweep,a.x,a.y,32);for(const[l,c]of o)e.lineTo(l,c);i=a.x,r=a.y;break}case"Z":e.closePath(),i=s,r=n;break}}function Yt(e,t=.75){const i=[];let r,s=0,n=0,a=0,o=0;const l=()=>(r||(r={points:[],closed:!1},i.push(r)),r),c=(d,h)=>{const u=l(),f=u.points.length;f>=2&&Math.abs(u.points[f-2]-d)<1e-9&&Math.abs(u.points[f-1]-h)<1e-9||u.points.push(d,h)};for(const d of e)switch(d.type){case"M":r={points:[d.x,d.y],closed:!1},i.push(r),s=a=d.x,n=o=d.y;break;case"L":c(d.x,d.y),s=d.x,n=d.y;break;case"C":{const h=$s(s,n,d.x,d.y,t);for(let u=1;u<=h;u++){const f=u/h;c(Hs(s,d.x1,d.x2,d.x,f),Hs(n,d.y1,d.y2,d.y,f))}s=d.x,n=d.y;break}case"Q":{const h=$s(s,n,d.x,d.y,t);for(let u=1;u<=h;u++){const f=u/h;c(Vs(s,d.x1,d.x,f),Vs(n,d.y1,d.y,f))}s=d.x,n=d.y;break}case"A":{const h=Xs(s,n,d.rx,d.ry,d.rotation,d.largeArc,d.sweep,d.x,d.y,Math.max(8,Math.ceil(24/Math.max(t,.1))));for(const[u,f]of h)c(u,f);s=d.x,n=d.y;break}case"Z":r&&(c(a,o),r.closed=!0),s=a,n=o;break}return i.filter(d=>d.points.length>=2)}function vd(e){const t=[],i=/([MmLlHhVvCcSsQqTtAaZzFf])|([-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?)/g;let r;for(;(r=i.exec(e))!==null;)r[1]?t.push({kind:"cmd",value:r[1]}):r[2]&&t.push({kind:"num",value:Number(r[2])});return t}function $s(e,t,i,r,s){const n=Math.hypot(i-e,r-t);return Math.max(4,Math.min(96,Math.ceil(n/Math.max(1.5,s*6))))}function Hs(e,t,i,r,s){const n=1-s;return n*n*n*e+3*n*n*s*t+3*n*s*s*i+s*s*s*r}function Vs(e,t,i,r){const s=1-r;return s*s*e+2*s*r*t+r*r*i}function Xs(e,t,i,r,s,n,a,o,l,c){if(i===0||r===0||Math.abs(e-o)<1e-9&&Math.abs(t-l)<1e-9)return[[o,l]];const d=s*Math.PI/180,h=Math.cos(d),u=Math.sin(d),f=(e-o)/2,p=(t-l)/2;let w=h*f+u*p,m=-u*f+h*p;i=Math.abs(i),r=Math.abs(r);const v=w*w/(i*i)+m*m/(r*r);if(v>1){const ke=Math.sqrt(v);i*=ke,r*=ke}const g=i*i,x=r*r,y=w*w,b=m*m;let k=(g*x-g*b-x*y)/(g*b+x*y);k=Math.max(0,k);const T=(n===a?-1:1)*Math.sqrt(k),N=T*(i*m/r),$=T*(-r*w/i),he=h*N-u*$+(e+o)/2,fe=u*N+h*$+(t+l)/2,L=(w-N)/i,z=(m-$)/r,ge=(-w-N)/i,ye=(-m-$)/r;let Ne=Math.atan2(z,L),xe=Math.atan2(L*ye-z*ge,L*ge+z*ye);!a&&xe>0&&(xe-=2*Math.PI),a&&xe<0&&(xe+=2*Math.PI);const Et=Math.max(2,Math.min(c,Math.ceil(Math.abs(xe)/(Math.PI/16)))),Pt=[];for(let ke=1;ke<=Et;ke++){const Ee=Ne+xe*ke/Et,bi=h*i*Math.cos(Ee)-u*r*Math.sin(Ee)+he,$e=u*i*Math.cos(Ee)+h*r*Math.sin(Ee)+fe;Pt.push([bi,$e])}return Pt}var ft=E((()=>{}));function Gs(e,t){const i=ae(e),r=[],s=[];let n="#000000",a,o=1,l=0;if(/<svg[\s>]/i.test(i)){const h=i.matchAll(/<path\b[^>]*\bd=["']([^"']+)["'][^>]*>/gi);for(const f of h){const p=f[0],w=f[1];s.push({type:"path",commands:Ae(w),stroke:Ye(p,"stroke")??n,fill:Ye(p,"fill")??void 0,lineWidth:Number(Ye(p,"stroke-width")??o)}),l++}const u=i.matchAll(/<(polyline|polygon)\b[^>]*\bpoints=["']([^"']+)["'][^>]*>/gi);for(const f of u){const p=f[0],w=Z(f[2]);w.length>=4&&s.push({type:f[1].toLowerCase()==="polygon"?"polygon":"polyline",points:w,stroke:Ye(p,"stroke")??n,fill:Ye(p,"fill")??void 0,lineWidth:Number(Ye(p,"stroke-width")??o)}),l++}}const c=i.split(/\r?\n/);for(const h of c){const u=h.trim();if(!u||u.startsWith("#")||u.startsWith("//"))continue;const f=u.toLowerCase(),p=Z(u);if(/^(color|stroke|pen|wt_color)\b/i.test(u)){n=js(u)??n,l++;continue}if(/^(fill|brush|wt_fill)\b/i.test(u)){a=js(u)??a??"#000000",l++;continue}if(/^(nofill|fillnone)\b/i.test(u)){a=void 0,l++;continue}if(/^(linewidth|lineweight|weight|wt_line_weight)\b/i.test(u)&&p.length>=1){o=Math.max(.2,p[0]),l++;continue}if((/^path\b/i.test(u)||/\bPath\s*Data\b/.test(u))&&/[MmLlCcQqAaZz]/.test(u)){const w=u.replace(/^path\b[:=]?/i,"").replace(/^.*?Data\s*=\s*/i,"").replace(/^['"]|['"]$/g,"");s.push({type:"path",commands:Ae(w),stroke:n,fill:a,lineWidth:o}),l++;continue}if(/^(line|wt_line)\b/i.test(u)&&p.length>=4){s.push({type:"polyline",points:p.slice(0,4),stroke:n,lineWidth:o}),l++;continue}if((/^(polyline|wt_polyline|pline)\b/i.test(u)||/\bPolyline\b/i.test(u))&&p.length>=4){s.push({type:"polyline",points:Ys(p),stroke:n,lineWidth:o}),l++;continue}if((/^(polygon|wt_polygon)\b/i.test(u)||/\bPolygon\b/i.test(u))&&p.length>=6){s.push({type:"polygon",points:Ys(p),stroke:n,fill:a??"#000000",lineWidth:o}),l++;continue}if(/^(rect|rectangle|wt_rectangle)\b/i.test(u)&&p.length>=4){s.push({type:"rect",x:p[0],y:p[1],width:p[2],height:p[3],stroke:n,fill:a,lineWidth:o}),l++;continue}if(/^(circle|ellipse)\b/i.test(u)&&p.length>=3){const[w,m,v]=p,g=72,x=[];for(let y=0;y<=g;y++){const b=Math.PI*2*y/g;x.push(w+Math.cos(b)*v,m+Math.sin(b)*v)}s.push({type:"polygon",points:x,stroke:n,fill:a,lineWidth:o}),l++;continue}if(/^(text|wt_text)\b/i.test(u)&&p.length>=2){const w=p[0],m=p[1],v=p.length>=3?p[2]:12,g=u.match(/["']([^"']+)["']/)?.[1]??u.replace(/^(text|wt_text)\b/i,"").replace(/[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?/g,"").trim();s.push({type:"text",x:w,y:m,size:v,text:g||"Text",fill:n}),l++;continue}(f.includes("wt_")||f.includes("whip")||f.includes("dwf"))&&l++}const d=yd(s);return s.length===0?r.push(M("warning","W2D_TEXT_NO_GEOMETRY",`Textual W2D parser did not find supported geometry commands in ${t}.`,t)):r.push(M("info","W2D_TEXT_PARSED",`Parsed ${s.length} supported vector primitives from ${t}.`,t)),l===0&&r.push(M("warning","W2D_TEXT_UNKNOWN_DIALECT","The file is textual, but does not look like the supported WHIP/W2D textual subset.",t)),{primitives:s,diagnostics:r,bounds:d}}function Ys(e){return e.length>=5&&Number.isInteger(e[0])&&e.length-1===e[0]*2?e.slice(1):e}function Ye(e,t){return e.match(new RegExp(`${t}=["']([^"']+)["']`,"i"))?.[1]}function js(e){const t=e.match(/#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i)?.[0];if(t)return t;const i=Z(e);return i.length>=3?`rgb(${Math.max(0,Math.min(255,i[0]))}, ${Math.max(0,Math.min(255,i[1]))}, ${Math.max(0,Math.min(255,i[2]))})`:e.match(/\b(black|white|red|green|blue|yellow|cyan|magenta|gray|grey)\b/i)?.[1]}function yd(e){let t=1/0,i=1/0,r=-1/0,s=-1/0;const n=(a,o)=>{t=Math.min(t,a),i=Math.min(i,o),r=Math.max(r,a),s=Math.max(s,o)};for(const a of e)if("points"in a)for(let o=0;o+1<a.points.length;o+=2)n(a.points[o],a.points[o+1]);else if(a.type==="rect")n(a.x,a.y),n(a.x+a.width,a.y+a.height);else if(a.type==="text")n(a.x,a.y),n(a.x+a.text.length*(a.size??12)*.6,a.y+(a.size??12));else if(a.type==="path")for(const o of a.commands)"x"in o&&"y"in o&&n(o.x,o.y),"x1"in o&&"y1"in o&&n(o.x1,o.y1),"x2"in o&&"y2"in o&&n(o.x2,o.y2);return Number.isFinite(t)?{minX:t,minY:i,maxX:r,maxY:s}:void 0}var qs=E((()=>{te(),ue(),ft()}));function xd(e,t){return new ha(e,t).parse()}function Zs(e){const t=[];for(const i of e)t.push(i.x,i.y);return t}function kd(e,t,i,r,s,n){let a=r,o=s;a===0&&o===0?o=65536:o<=a&&(o+=65536);const l=o-a,c=Math.max(16,Math.min(144,Math.ceil(Math.abs(l)/65536*96))),d=n*Math.PI*2/65536,h=Math.cos(d),u=Math.sin(d),f=[];for(let p=0;p<=c;p++){const w=(a+l*p/c)*Math.PI*2/65536,m=Math.cos(w)*t,v=Math.sin(w)*i;f.push({x:e.x+m*h-v*u,y:e.y+m*u+v*h})}return f}function Ks(e){return e.replace(/\\P/gi,`
|
|
13
|
+
`).replace(/\\L|\\l/g,"").replace(/\\O|\\o/g,"").replace(/\\H[-+]?\d*\.?\d+x;/gi,"").replace(/\\S([^;]+);/gi,"$1").replace(/\\[A-Za-z][^;]*;/g,"").replace(/\\~/g," ").replace(/\\\\/g,"\\").trim()}function Ed(e){let t=1/0,i=1/0,r=-1/0,s=-1/0;const n=(a,o)=>{t=Math.min(t,a),i=Math.min(i,o),r=Math.max(r,a),s=Math.max(s,o)};for(const a of e)if("points"in a)for(let o=0;o+1<a.points.length;o+=2)n(a.points[o],a.points[o+1]);else if(a.type==="rect")n(a.x,a.y),n(a.x+a.width,a.y+a.height);else if(a.type==="text"){const o=a.size??12;n(a.x,a.y),n(a.x,a.y+o)}else if(a.type==="path")for(const o of a.commands)"x"in o&&"y"in o&&n(o.x,o.y),"x1"in o&&"y1"in o&&n(o.x1,o.y1),"x2"in o&&"y2"in o&&n(o.x2,o.y2);return Number.isFinite(t)?{minX:t,minY:i,maxX:r,maxY:s}:void 0}function Pd(e){return e>=48&&e<=57}function jt(e){return Array.from(e,t=>String.fromCharCode(t)).join("")}function Sd(e,t,i){return`rgb(${je(e)}, ${je(t)}, ${je(i)})`}function Cd(e,t,i,r){return`rgba(${je(e)}, ${je(t)}, ${je(i)}, ${Math.max(0,Math.min(1,r/255))})`}function je(e){return Math.max(0,Math.min(255,Math.round(e)))}function Qs(e){return(e.match(/[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?/g)??[]).map(Number).filter(Number.isFinite)}function Js(e){return["#000000","#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#000000","#808080","#c0c0c0"][e]??"#000000"}var ea,ta,ia,ra,na,sa,aa,oa,la,ca,da,ha,Md=E((()=>{te(),ea=1,ta=2,ia=4,ra=8,na=16,sa=32,aa=64,oa=128,la=256,ca=512,da=1024,ha=class{constructor(e,t){this.bytes=e,this.sourcePath=t,this.pos=0,this.current={x:0,y:0},this.primitives=[],this.diagnostics=[],this.unsupportedOpcodes=[],this.opcodes=0,this.decimalRevision=600,this.state={stroke:"#000000",fill:void 0,fillOn:!1,visible:!0,lineWidth:1,fontHeight:120,fontRotation:0,fontName:"sans-serif"},this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}parse(){for(;this.pos<this.bytes.length&&(this.eatWhitespace(),!(this.pos>=this.bytes.length));){const e=this.pos,t=this.u8();this.opcodes++;try{if(t===40){this.pos=e,this.parseExtendedAscii(e);continue}if(t===123){if(!this.parseExtendedBinary(e))break;continue}if(this.parseSingleByteOpcode(t))continue;this.unsupportedOpcodes.push({offset:e,opcode:t,message:`Unsupported/unknown W2D single-byte opcode 0x${t.toString(16).padStart(2,"0")}.`});break}catch(i){this.unsupportedOpcodes.push({offset:e,opcode:t,message:`Failed while decoding W2D opcode 0x${t.toString(16)}: ${String(i)}`});break}}if(this.primitives.length>0?this.diagnostics.push(M("info","W2D_BINARY_PARSED",`Parsed ${this.primitives.length} vector primitives from binary WHIP!/W2D stream (${this.opcodes} opcodes).`,this.sourcePath)):this.diagnostics.push(M("warning","W2D_BINARY_NO_GEOMETRY","Binary WHIP!/W2D parser did not emit supported geometry.",this.sourcePath)),this.unsupportedOpcodes.length>0){const e=this.unsupportedOpcodes[0];this.diagnostics.push(M("warning","W2D_BINARY_PARTIAL",`${this.unsupportedOpcodes.length} unsupported opcode(s); first at byte ${e.offset}: ${e.message}`,this.sourcePath))}return{primitives:this.primitives,diagnostics:this.diagnostics,bounds:Ed(this.primitives),opcodes:this.opcodes,unsupportedOpcodes:this.unsupportedOpcodes}}parseSingleByteOpcode(e){switch(e){case 0:return!0;case 3:{const t=this.u8(),i=this.u8(),r=this.u8(),s=this.u8();return this.state.stroke=Cd(t,i,r,s),this.state.fillOn&&(this.state.fill=this.state.stroke),!0}case 6:return this.readBinaryFont(),!0;case 12:{const t=[this.point16Relative(),this.point16Relative()];return this.polyline(t),!0}case 16:{const t=this.pointSet16Relative();return this.pointSetPrimitive(t),!0}case 18:{const t=this.point16Relative(),i=this.u16();return this.ellipsePrimitive(t,i,i,0,0,0),!0}case 20:return this.polytriangles(this.pointSet16Relative()),!0;case 23:return this.state.lineWidth=Math.max(.2,Math.abs(this.i32())),!0;case 24:{const t=this.point32Relative(),i=Ks(this.readWhipString());return this.text(t,i),this.skipComplexTextOptions(),!0}case 146:{const t=this.point32Relative(),i=this.u32(),r=this.u16(),s=this.u16();return this.ellipsePrimitive(t,i,i,r,s,0,!1),!0}case 172:return this.readCount(),!0;case 204:return this.readCount(),!0;case 228:return this.readCount(),!0}switch(String.fromCharCode(e)){case"B":return this.polyline(this.pointSet32Relative()),!0;case"C":return this.state.stroke=Js(this.readAsciiInteger()),this.state.fillOn&&(this.state.fill=this.state.stroke),!0;case"c":return this.state.stroke=Js(this.u8()),this.state.fillOn&&(this.state.fill=this.state.stroke),!0;case"E":{const t=this.readAsciiPoint(),i=this.readAsciiPoint();return this.ellipsePrimitive(t,i.x,i.y,0,0,0),!0}case"e":{const t=this.point32Relative(),i=this.u32(),r=this.u32(),s=this.u16(),n=this.u16(),a=this.u16();return this.ellipsePrimitive(t,i,r,s,n,a),!0}case"F":return this.state.fillOn=!0,this.state.fill=this.state.stroke,!0;case"f":return this.state.fillOn=!1,this.state.fill=void 0,!0;case"L":{const t=[this.readAsciiPoint(),this.readAsciiPoint()];return this.polyline(t),!0}case"l":{const t=[this.point32Relative(),this.point32Relative()];return this.polyline(t),!0}case"N":return this.i32(),!0;case"n":return this.u16(),!0;case"O":return this.current={x:this.i32(),y:this.i32()},!0;case"P":return this.pointSetPrimitive(this.pointSetAscii()),!0;case"p":return this.pointSetPrimitive(this.pointSet32Relative()),!0;case"R":{const t=this.readAsciiPoint(),i=this.readAsciiInteger();return this.ellipsePrimitive(t,i,i,0,0,0),!0}case"r":{const t=this.point32Relative(),i=this.u32();return this.ellipsePrimitive(t,i,i,0,0,0),!0}case"T":return this.polytriangles(this.pointSetAscii()),!0;case"t":return this.polytriangles(this.pointSet32Relative()),!0;case"V":return this.state.visible=!0,!0;case"v":return this.state.visible=!1,!0;case"x":{const t=this.point32Relative(),i=Ks(this.readWhipString());return this.text(t,i),!0}}return!1}parseExtendedAscii(e){const{token:t,expr:i}=this.readBalancedExpression(e);switch(t){case"(W2D":{const r=i.match(/V(\d+)\.(\d+)/i);r&&(this.decimalRevision=Number(r[1])*100+Number(r[2]));break}case"(Color":{const r=Qs(i);r.length>=3&&(this.state.stroke=Sd(r[0],r[1],r[2]));break}case"(LineWeight":{const r=Qs(i);r.length>=1&&(this.state.lineWidth=Math.max(.2,Math.abs(r[0])));break}case"(Font":{const r=i.match(/\(Height\s+(-?\d+)/i)?.[1],s=i.match(/\(Rotation\s+(-?\d+)/i)?.[1],n=i.match(/\(Name\s+(['"])(.*?)\1/i)?.[2];r&&(this.state.fontHeight=Math.max(1,Math.abs(Number(r)))),s&&(this.state.fontRotation=Number(s)||0),n&&(this.state.fontName=n);break}case"(EndOfDWF":this.pos=this.bytes.length;break;default:break}}parseExtendedBinary(e){if(this.remaining()<6)return!1;const t=this.u32(),i=this.u16();return i===17||i===16||i===291?(this.unsupportedOpcodes.push({offset:e,opcode:`{${i.toString(16)}}`,message:"Embedded compressed WHIP block detected. This build renders uncompressed binary W2D streams and manifest markup XML; compressed nested blocks are skipped."}),this.pos=t>0&&this.pos+t<=this.bytes.length?this.pos+t:this.bytes.length,!0):t>0&&this.pos+t<=this.bytes.length?(this.pos+=t,!0):(this.unsupportedOpcodes.push({offset:e,opcode:`{${i.toString(16)}}`,message:"Unsupported extended binary WHIP object with unknown payload size."}),!1)}readBinaryFont(){const e=this.u16();e&ea&&(this.state.fontName=this.readWhipString()||this.state.fontName),e&ta&&this.u8(),e&ia&&this.u8(),e&ra&&this.u8(),e&na&&this.u8(),e&sa&&(this.state.fontHeight=Math.max(1,Math.abs(this.i32()))),e&aa&&(this.state.fontRotation=this.u16()),e&oa&&this.u16(),e&la&&this.u16(),e&ca&&this.u16(),e&da&&this.i32()}skipComplexTextOptions(){this.skipScoringOption(),this.skipScoringOption();for(let e=0;e<4;e++)this.i32(),this.i32();if(this.decimalRevision>=600&&this.pos<this.bytes.length){const e=Math.max(0,this.readCount()-1);for(let t=0;t<e;t++)this.readCount()}}skipScoringOption(){const e=Math.max(0,this.readCount()-1);for(let t=0;t<e;t++)this.readCount()}pointSetPrimitive(e){this.state.fillOn?this.polygon(e,this.state.fill??this.state.stroke,this.state.stroke):this.polyline(e)}polytriangles(e){if(!(!this.state.visible||e.length<3))for(let t=0;t+2<e.length;t++)this.polygon([e[t],e[t+1],e[t+2]],this.state.stroke,void 0)}polyline(e){!this.state.visible||e.length<2||this.primitives.push({type:"polyline",points:Zs(e),stroke:this.state.stroke,lineWidth:this.state.lineWidth})}polygon(e,t,i){!this.state.visible||e.length<3||this.primitives.push({type:"polygon",points:Zs(e),fill:t,stroke:i,lineWidth:this.state.lineWidth})}ellipsePrimitive(e,t,i,r,s,n,a=this.state.fillOn){const o=kd(e,t,i,r,s,n);a?this.polygon(o,this.state.fill??this.state.stroke,this.state.stroke):this.polyline(o)}text(e,t){!this.state.visible||!t.trim()||this.primitives.push({type:"text",x:e.x,y:e.y,text:t,size:Math.max(10,Math.abs(this.state.fontHeight)),fill:this.state.stroke})}pointSet32Relative(){const e=this.readCount(),t=[];for(let i=0;i<e;i++)t.push(this.point32Relative());return t}pointSet16Relative(){const e=this.readCount(),t=[];for(let i=0;i<e;i++)t.push(this.point16Relative());return t}pointSetAscii(){const e=this.readAsciiInteger(),t=[];for(let i=0;i<e;i++)t.push(this.readAsciiPoint());return t}point32Relative(){const e=this.i32(),t=this.i32();return this.current={x:this.current.x+e,y:this.current.y+t},{...this.current}}point16Relative(){const e=this.i16(),t=this.i16();return this.current={x:this.current.x+e,y:this.current.y+t},{...this.current}}readAsciiPoint(){const e=this.readAsciiInteger();return this.peek()===44&&this.pos++,{x:e,y:this.readAsciiInteger()}}readAsciiInteger(){this.eatWhitespace();const e=this.pos;for((this.peek()===43||this.peek()===45)&&this.pos++;this.pos<this.bytes.length&&Pd(this.bytes[this.pos]);)this.pos++;const t=jt(this.bytes.subarray(e,this.pos)),i=Number.parseInt(t,10);return Number.isFinite(i)?i:0}readWhipString(){this.eatWhitespace();const e=this.peek();if(e===123){this.pos++;const i=this.i32(),r=Math.max(0,i*2);if(this.pos+r>this.bytes.length)throw new Error("Truncated binary WHIP string.");const s=new TextDecoder("utf-16le").decode(this.bytes.subarray(this.pos,this.pos+r));return this.pos+=r,this.peek()===125&&this.pos++,s}if(e===34||e===39){const i=this.u8(),r=[];let s=!1;for(;this.pos<this.bytes.length;){const n=this.u8();if(s)r.push(n),s=!1;else if(n===92)r.push(n),s=!0;else{if(n===i)break;r.push(n)}}return jt(new Uint8Array(r))}const t=this.pos;for(;this.pos<this.bytes.length;){const i=this.bytes[this.pos];if(i===32||i===9||i===10||i===13||i===41)break;this.pos++}return jt(this.bytes.subarray(t,this.pos))}readBalancedExpression(e){this.pos=e;let t=0,i=0,r=!1;for(;this.pos<this.bytes.length;){const n=this.u8();if(i)r?r=!1:n===92?r=!0:n===i&&(i=0);else if(n===34||n===39)i=n;else if(n===40)t++;else if(n===41&&(t--,t<=0))break}const s=jt(this.bytes.subarray(e,this.pos));return{token:s.match(/^\([^\s()]+/)?.[0]??"(",expr:s}}readCount(){const e=this.u8();return e!==0?e:256+this.u16()}eatWhitespace(){for(;this.pos<this.bytes.length;){const e=this.bytes[this.pos];if(e===32||e===9||e===10||e===13)this.pos++;else break}}remaining(){return this.bytes.length-this.pos}peek(){return this.pos<this.bytes.length?this.bytes[this.pos]:void 0}u8(){if(this.remaining()<1)throw new Error("Unexpected EOF");return this.view.getUint8(this.pos++)}i16(){if(this.remaining()<2)throw new Error("Unexpected EOF");const e=this.view.getInt16(this.pos,!0);return this.pos+=2,e}u16(){if(this.remaining()<2)throw new Error("Unexpected EOF");const e=this.view.getUint16(this.pos,!0);return this.pos+=2,e}i32(){if(this.remaining()<4)throw new Error("Unexpected EOF");const e=this.view.getInt32(this.pos,!0);return this.pos+=4,e}u32(){if(this.remaining()<4)throw new Error("Unexpected EOF");const e=this.view.getUint32(this.pos,!0);return this.pos+=4,e}}}));function Ad(e){return e.entries.some(t=>/\.w2d$/i.test(t.name)||/manifest\.xml$/i.test(t.name)||/descriptor\.xml$/i.test(t.name)||/\.hsf$/i.test(t.name))}async function ua(e){const t=[],i=[],r=e.entries.map(o=>({path:o.name,mediaType:De(o.name),size:o.uncompressedSize})),s=e.entries.find(o=>/(^|\/)manifest\.xml$/i.test(o.name));let n=[];if(s)try{n=Fd(ae(await e.read(s)),s.name),t.push(M("info","DWF_MANIFEST_FOUND",`Found DWF manifest with ${n.length} section(s).`,s.name))}catch(o){t.push(M("warning","DWF_MANIFEST_PARSE_FAILED",`Failed to parse DWF manifest: ${String(o)}`,s.name))}else t.push(M("info","DWF_NO_MANIFEST","No manifest.xml was found; falling back to resource discovery."));if(n.length>0)for(const o of n){const l=fr(o,/2d\s+streaming\s+graphics/i)??o.resources.find(f=>/\.w2d$/i.test(f.path));if(!l)continue;const c=fr(o,/^descriptor$/i)??{path:U(o.name+"/descriptor.xml")};let d={};if(c&&e.has(c.path))try{d=Nd(ae(await e.read(c.path)),l.path)}catch(f){t.push(M("warning","DWF_DESCRIPTOR_PARSE_FAILED",`Failed to parse descriptor for ${o.title}: ${String(f)}`,c.path))}const h=[],u=[];try{const f=await fa(e,l.path);u.push(...f.primitives),h.push(...f.diagnostics)}catch(f){h.push(M("warning","DWF_W2D_READ_FAILED",`Failed to read or parse ${l.path}: ${String(f)}`,l.path))}for(const f of o.resources.filter(p=>/markup\s+private/i.test(p.role??"")&&/\.xml$/i.test(p.path)))if(e.has(f.path))try{const p=Id(ae(await e.read(f.path)),f.path,d.w2dTransform);u.push(...p.primitives),h.push(...p.diagnostics)}catch(p){h.push(M("warning","DWF_MARKUP_XML_PARSE_FAILED",`Failed to parse markup private XML: ${String(p)}`,f.path))}if(u.length>0){const f=_d(u),p=f?Math.max(1,f.maxX-f.minX):d.paperWidth??1e3,w=f?Math.max(1,f.maxY-f.minY):d.paperHeight??1e3;i.push({id:`page-${i.length+1}`,name:o.title||l.title||qt(l.path),kind:"w2d-text",sourcePath:l.path,width:p,height:w,primitives:u,bounds:f,diagnostics:h})}else{const f=fr(o,/thumbnail|preview/i)??o.resources.find(p=>/\.(png|jpe?g|gif|bmp)$/i.test(p.path));f&&e.has(f.path)&&i.push({id:`image-${i.length+1}`,name:o.title||qt(f.path),kind:"image",sourcePath:f.path,mediaType:f.mediaType??De(f.path)??"image/png",width:1e3,height:1e3,diagnostics:[...h,M("warning","DWF_IMAGE_FALLBACK","Vector stream did not produce geometry; using section thumbnail as fallback.",f.path)]})}}i.length===0&&await Td(e,i,t);const a=e.entries.filter(o=>/\.hsf$/i.test(o.name));if(a.length>0&&(t.push(M("warning","DWF_3D_HSF_DETECTED",`Detected ${a.length} HSF/3D resource(s). This frontend build reports them but does not render 3D HSF.`,a[0]?.name)),i.length===0&&i.push({id:"unsupported-3d",name:"Unsupported 3D DWF",kind:"unsupported",width:1e3,height:1e3,sourcePath:a[0]?.name,reason:"3D HSF resource detected; not implemented in this pure frontend native renderer build.",diagnostics:[M("warning","DWF_3D_HSF_UNSUPPORTED","3D HSF rendering is not implemented in this build.",a[0]?.name)]})),i.length===0){const o=Ld(e);o&&i.push({id:"image-1",name:qt(o.name),kind:"image",sourcePath:o.name,mediaType:De(o.name)??"image/png",width:1e3,height:1e3,diagnostics:[M("info","DWF_IMAGE_FALLBACK","No supported vector page was found; using an embedded preview/image resource.",o.name)]})}return i.length===0&&i.push({id:"unsupported-1",name:"Unsupported DWF package",kind:"unsupported",width:1e3,height:1e3,reason:"No supported W2D, XPS FixedPage, or preview image resource was found.",diagnostics:[M("error","DWF_NO_SUPPORTED_PAGE","No supported renderable DWF resource was found.")]}),Wt({kind:"dwf",pages:[],resources:r,diagnostics:t,packageEntries:e.entries.map(o=>o.name)},i,e,void 0)}async function Td(e,t,i){const r=e.entries.filter(s=>/\.w2d$/i.test(s.name));for(const s of r)try{const n=await fa(e,s.name),a=n.bounds,o=a?Math.max(1,a.maxX-a.minX):1e3,l=a?Math.max(1,a.maxY-a.minY):1e3;n.primitives.length>0&&t.push({id:`page-${t.length+1}`,name:qt(s.name),kind:"w2d-text",sourcePath:s.name,width:o,height:l,primitives:n.primitives,bounds:a,diagnostics:n.diagnostics})}catch(n){i.push(M("warning","DWF_W2D_READ_FAILED",`Failed to read ${s.name}: ${String(n)}`,s.name))}}async function fa(e,t){const i=await e.read(t);return qn(i)?Gs(i,t):xd(i,t)}function Fd(e,t){const i=Q(e,t);return Array.from(i.getElementsByTagName("*")).filter(r=>we(r)==="Section").map((r,s)=>{const n=H(r,"name")??`section-${s+1}`;return{name:n,title:H(r,"title")??n,resources:Array.from(r.getElementsByTagName("*")).filter(a=>we(a).endsWith("Resource")||we(a)==="Resource").map(a=>({path:U(H(a,"href")??""),role:H(a,"role"),mediaType:H(a,"mime"),title:H(a,"title")})).filter(a=>a.path.length>0)}}).filter(r=>r.resources.length>0)}function Nd(e,t){const i=Q(e,"descriptor.xml"),r=Array.from(i.getElementsByTagName("*")).find(l=>we(l)==="Paper"),s={};if(r){s.paperWidth=pe(r,"width"),s.paperHeight=pe(r,"height");const l=H(r,"clip");l&&(s.clip=Z(l))}const n=Array.from(i.getElementsByTagName("*")).filter(l=>/GraphicResource$/i.test(we(l))||we(l)==="GraphicResource"),a=n.find(l=>U(H(l,"href")??"")===U(t))??n.find(l=>/2d\s+streaming\s+graphics/i.test(H(l,"role")??"")),o=a?Z(H(a,"transform")??""):[];return o.length>=14&&(s.w2dTransform={sx:o[0]||1,sy:o[5]||o[0]||1,tx:o[12]||0,ty:o[13]||0}),s}function Id(e,t,i){const r=Q(e,t),s=[],n=(l,c)=>i?{x:(l-i.tx)/i.sx,y:(c-i.ty)/i.sy}:{x:l,y:c},a=l=>Z(H(l,"Points")??H(l,"points")??"");for(const l of Array.from(r.getElementsByTagName("*"))){const c=we(l);if(c==="Polyline2D"||c==="Leader"){const d=a(l);if(d.length>=4){const h=[];for(let f=0;f+1<d.length;f+=2){const p=n(d[f],d[f+1]);h.push(p.x,p.y)}const u=hr(l);s.push({type:"polyline",points:h,stroke:u.stroke,lineWidth:u.lineWidth})}}else if(c==="Tag"||c==="Target"){const d=pe(l,"CenterX"),h=pe(l,"CenterY"),u=pe(l,"Width"),f=pe(l,"Height");if([d,h,u,f].every(p=>p!==void 0)){const p=n(d-u/2,h-f/2),w=n(d+u/2,h-f/2),m=n(d+u/2,h+f/2),v=n(d-u/2,h+f/2),g=hr(l);s.push({type:"polygon",points:[p.x,p.y,w.x,w.y,m.x,m.y,v.x,v.y],stroke:g.stroke,fill:g.fill,lineWidth:g.lineWidth})}}else if(c==="Text"){const d=pe(l,"X"),h=pe(l,"Y");if(d!==void 0&&h!==void 0){const u=Array.from(l.getElementsByTagName("*")).filter(p=>we(p)==="TextPhrase"),f=u.map(p=>H(p,"String")??"").filter(Boolean).join(`
|
|
14
|
+
`);if(f){const p=n(d,h),w=pe(l,"Height"),m=u.length?pe(u[0],"FontHeight"):void 0,v=i&&w?Math.max(10,Math.abs(w/i.sy)):m??12,g=u.length?H(u[0],"Color"):void 0;s.push({type:"text",x:p.x,y:p.y,text:f,size:v,fill:g?ur(g):hr(l).stroke})}}}}const o=[];return s.length>0&&o.push(M("info","DWF_MARKUP_XML_PARSED",`Parsed ${s.length} markup primitive(s) from markup private XML.`,t)),{primitives:s,diagnostics:o}}function hr(e){let t="#0000ff",i,r=1;const s=Array.from(e.getElementsByTagName("*")).filter(n=>we(n)==="FormatProperty");for(const n of s){const a=(H(n,"Name")??"").toUpperCase(),o=(H(n,"Enabled")??"true").toLowerCase()!=="false",l=H(n,"ModifierUIntVal")??H(n,"UIntValue")??H(n,"DblValue")??H(n,"IntValue");!o||l===void 0||(a==="LINECOLOR"&&(t=ur(l)),a==="FILLCOLOR"&&(i=ur(l)),a==="LINEWEIGHT"&&(r=Math.max(1,Number(l)||r)),a==="NOFILL"&&/true/i.test(H(n,"BoolValue")??"")&&(i=void 0))}return{stroke:t,fill:i,lineWidth:r}}function ur(e){const t=Number(e);if(!Number.isFinite(t))return"#000000";const i=t>>>0;return`rgb(${i>>>16&255}, ${i>>>8&255}, ${i&255})`}function _d(e){let t=1/0,i=1/0,r=-1/0,s=-1/0;const n=(a,o)=>{t=Math.min(t,a),i=Math.min(i,o),r=Math.max(r,a),s=Math.max(s,o)};for(const a of e)if("points"in a)for(let o=0;o+1<a.points.length;o+=2)n(a.points[o],a.points[o+1]);else if(a.type==="rect")n(a.x,a.y),n(a.x+a.width,a.y+a.height);else if(a.type==="text"){const o=a.size??12;n(a.x,a.y),n(a.x,a.y+o)}else if(a.type==="path")for(const o of a.commands)"x"in o&&"y"in o&&n(o.x,o.y),"x1"in o&&"y1"in o&&n(o.x1,o.y1),"x2"in o&&"y2"in o&&n(o.x2,o.y2);return Number.isFinite(t)?{minX:t,minY:i,maxX:r,maxY:s}:void 0}function fr(e,t){return e.resources.find(i=>t.test(i.role??""))}function H(e,t){return e.getAttribute(t)??e.getAttribute(`dwf:${t}`)??e.getAttribute(`ePlot:${t}`)??Array.from(e.attributes).find(i=>i.localName===t)?.value??void 0}function we(e){const t=e.localName||e.nodeName,i=t.indexOf(":");return i>=0?t.slice(i+1):t}function pe(e,t){const i=H(e,t);if(i===void 0)return;const r=Number(i);return Number.isFinite(r)?r:void 0}function qt(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Ld(e){const t=e.entries.filter(i=>/\.(png|jpe?g|gif|bmp)$/i.test(i.name));if(t.length!==0)return t.sort((i,r)=>pa(r.name,r.uncompressedSize)-pa(i.name,i.uncompressedSize))[0]}function pa(e,t){let i=Math.min(t,1e7)/1e3;return/thumbnail|preview/i.test(e)&&(i+=5e3),Zn(e)==="png"&&(i+=100),i}var Dd=E((()=>{te(),ue(),ji(),qs(),Md()}));async function ma(e,t={}){const i=await Rd(e),r=t.fileName??(e instanceof File?e.name:void 0)??"document.dwf";if(xc(i)){const n=rs.open(i,t.inflater);return od(n)?await Bs(n):Ad(n)?await ua(n):n.entries.some(a=>/\.fpage$/i.test(a.name))?await Bs(n):await ua(n)}if(qn(i)){const n=Gs(i,r),a=[{id:"page-1",name:r,kind:"w2d-text",width:n.bounds?Math.max(1,n.bounds.maxX-n.bounds.minX):1e3,height:n.bounds?Math.max(1,n.bounds.maxY-n.bounds.minY):1e3,sourcePath:r,primitives:n.primitives,bounds:n.bounds,diagnostics:n.diagnostics}];return Wt({kind:"unknown",pages:[],resources:[{path:r,mediaType:"text/plain",size:i.byteLength}],diagnostics:[M("warning","RAW_TEXT_W2D_MODE","Input is not a DWF ZIP package; opened it as a textual W2D-like vector stream.",r)],packageEntries:[r]},a)}const s={id:"unsupported-raw",name:r,kind:"unsupported",width:1e3,height:1e3,sourcePath:r,reason:"Input is neither a ZIP-based DWF/DWFx package nor a supported textual W2D stream.",diagnostics:[M("error","UNSUPPORTED_RAW_FORMAT","Unsupported raw DWF input. DWF 6+/DWFx ZIP packages are required for this build.",r)]};return Wt({kind:"unknown",pages:[],resources:[{path:r,size:i.byteLength}],diagnostics:s.diagnostics,packageEntries:[r]},[s])}async function Rd(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(await e.arrayBuffer())}var ga=E((()=>{te(),ns(),wd(),Dd(),ue(),qs(),ji()}));function ce(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}}function Re(e,t,i){return[e.a*t+e.c*i+e.e,e.b*t+e.d*i+e.f]}function Zt(e){if(!e)return{...mr};const t=Z(e);return t.length>=6?{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}:{...mr}}function ie(e,t=1){if(!e||e==="Transparent"||e==="{x:Null}")return;let i=e.trim();if(i.startsWith("{")||i.includes("Brush"))return;const r=ba(i);if(r&&(i=r),i.startsWith("sc#")){const s=Z(i);if(s.length>=3){const n=s.length>=4?1:0,a=s.length>=4?s[0]:1;return Kt(Math.round((s[n]??0)*255),Math.round((s[n+1]??0)*255),Math.round((s[n+2]??0)*255),a*t)}}if(i.startsWith("#")){const s=i.slice(1);if(s.length===3)return Kt(parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16),t);if(s.length===6)return Kt(parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),t);if(s.length===8){const n=parseInt(s.slice(0,2),16)/255;return Kt(parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),parseInt(s.slice(6,8),16),n*t)}}return/^rgba?\(/i.test(i),i}function qe(e,t=4278190080){if(!e)return t;const i=e.trim(),r=i.match(/^rgba?\(([^)]+)\)/i);if(r){const n=r[1].split(",").map(d=>d.trim()),a=Number(n[0]??0),o=Number(n[1]??0),l=Number(n[2]??0),c=n[3]===void 0?1:Number(n[3]);return pr(a,o,l,Math.round(c*255))}if(i.startsWith("#")){const n=i.slice(1);if(n.length===6)return pr(parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),255);if(n.length===8)return pr(parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),parseInt(n.slice(6,8),16),parseInt(n.slice(0,2),16))}const s=ba(i);return s?qe(s,t):t}function pr(e,t,i,r){return e=Be(e),t=Be(t),i=Be(i),r=Be(r),e&255|(t&255)<<8|(i&255)<<16|(r&255)<<24}function Kt(e,t,i,r){return`rgba(${Be(e)}, ${Be(t)}, ${Be(i)}, ${Math.max(0,Math.min(1,r))})`}function Be(e){return Math.max(0,Math.min(255,Math.round(e)))}function ba(e){switch(e.toLowerCase()){case"black":return"#000000";case"white":return"#ffffff";case"red":return"#ff0000";case"green":return"#008000";case"blue":return"#0000ff";case"yellow":return"#ffff00";case"cyan":return"#00ffff";case"magenta":return"#ff00ff";case"gray":case"grey":return"#808080";case"transparent":return"#00000000";default:return}}var mr,Ze=E((()=>{ue(),mr={a:1,b:0,c:0,d:1,e:0,f:0}}));function Qt(e){const t=e.margin??24,i=Math.max(1,e.canvasWidth-t*2),r=Math.max(1,e.canvasHeight-t*2),s=Math.min(i/Math.max(1,e.pageWidth),r/Math.max(1,e.pageHeight))*(e.zoom??1);return{a:s,b:0,c:0,d:s,e:(e.canvasWidth-e.pageWidth*s)/2+(e.panX??0)-(e.sourceMinX??0)*s,f:(e.canvasHeight-e.pageHeight*s)/2+(e.panY??0)-(e.sourceMinY??0)*s}}function gr(e,t,i,r=1,s=0,n=0){const a=e.bounds,o=a?.minX??0;a?.minY;const l=a?.maxY??e.height,c=a?Math.max(1,a.maxX-a.minX):e.width,d=a?Math.max(1,a.maxY-a.minY):e.height,h=24,u=Math.max(1,t-h*2),f=Math.max(1,i-h*2),p=Math.min(u/Math.max(1,c),f/Math.max(1,d))*r,w=(t-c*p)/2+s,m=(i-d*p)/2+n;return{a:p,b:0,c:0,d:-p,e:w-o*p,f:m+l*p}}var pt=E((()=>{}));function Ke(e){const t=Math.hypot(e.a,e.b),i=Math.hypot(e.c,e.d);return Math.max(1e-12,(t+i)*.5)}function Jt(e){const t=e.getBoundingClientRect?.(),i=t&&t.width>0?t.width:Number(e.style.width?.replace("px",""))||e.width;return Math.max(1,e.width/Math.max(1,i))}function Qe(e,t,i={},r){const s=Ke(t),n=Math.max(0,Math.abs(e||0)*s),a=i.lineWeightMode??"adaptive";if(a==="physical")return Math.max(1e-6,Math.abs(e||1));const o=Math.max(1,r.dpr||1),l=Math.max(.25,(i.minStrokeCssPx??.55)*o);if(a==="hairline")return l/s;const c=Math.max(.05,r.zoom??1),d=i.maxOverviewStrokeCssPx??1.15,h=c<=1?d:Math.min(24,d*(1+Math.log2(c)*1.6)),u=Math.max(l,h*o);return Math.max(l,Math.min(n,u))/s}function wa(e,t,i={},r){if((i.lineWeightMode??"adaptive")==="physical")return!0;const s=Math.max(1,r.dpr||1),n=i.minTextCssPx??3.5;return Math.abs(e*Ke(t))>=n*s}function va(e,t,i={},r){if(!e||(i.lineWeightMode??"adaptive")==="physical")return!0;const s=Math.max(1,r.dpr||1),n=Math.max(0,i.minFilledAreaCssPx??.12)*s*s;if(n<=0)return!0;const a=ei(t,e.minX,e.minY),o=ei(t,e.maxX,e.minY),l=ei(t,e.maxX,e.maxY),c=ei(t,e.minX,e.maxY),d=[a[0],o[0],l[0],c[0]],h=[a[1],o[1],l[1],c[1]];return(Math.max(...d)-Math.min(...d))*(Math.max(...h)-Math.min(...h))>=n}function ei(e,t,i){return[e.a*t+e.c*i+e.e,e.b*t+e.d*i+e.f]}var ti=E((()=>{})),br,wr=E((()=>{Ze(),br=class{constructor(e={}){this.fbPtr=0,this.fbBytes=0,this.width=0,this.height=0,this.wasmUrl=e.wasmUrl??"./public/dwfv-render.wasm"}async init(){if(this.exports)return;const e=await fetch(this.wasmUrl);if(!e.ok)throw new Error(`Failed to load WASM raster backend: ${e.status} ${e.statusText}`);const t=await e.arrayBuffer(),i=await WebAssembly.instantiate(t,{});this.exports=i.instance.exports}begin(e,t,i="#ffffff"){const r=this.requireExports();this.width=Math.max(1,Math.floor(e)),this.height=Math.max(1,Math.floor(t)),this.fbBytes=this.width*this.height*4,r.dwfv_reset_heap(),this.fbPtr=r.dwfv_alloc(this.fbBytes),this.ensureMemory(this.fbPtr+this.fbBytes),r.dwfv_clear(this.fbPtr,this.width,this.height,qe(i,4294967295))}drawPolyline(e,t,i,r=1){const s=this.requireExports();if(e.length<4||!i)return;const n=Math.floor(e.length/2),a=this.allocF32(n*2),o=new Float32Array(s.memory.buffer,a,n*2);for(let l=0;l<n;l++){const[c,d]=Re(t,e[l*2],e[l*2+1]);o[l*2]=c,o[l*2+1]=d}s.dwfv_draw_polyline(this.fbPtr,this.width,this.height,a,n,qe(i,4278190080),Math.max(1,r))}drawPolygon(e,t,i){const r=this.requireExports();if(e.length<6||!i)return;const s=Math.floor(e.length/2),n=this.allocF32(s*2),a=new Float32Array(r.memory.buffer,n,s*2);for(let o=0;o<s;o++){const[l,c]=Re(t,e[o*2],e[o*2+1]);a[o*2]=l,a[o*2+1]=c}r.dwfv_draw_polygon(this.fbPtr,this.width,this.height,n,s,qe(i,4278190080))}toImageData(){const e=this.requireExports(),t=new Uint8ClampedArray(e.memory.buffer,this.fbPtr,this.fbBytes);return new ImageData(new Uint8ClampedArray(t),this.width,this.height)}allocF32(e){const t=this.requireExports(),i=e*4,r=t.dwfv_alloc(i);return this.ensureMemory(r+i),r}ensureMemory(e){const t=this.requireExports(),i=65536,r=t.memory.buffer.byteLength;e>r&&t.memory.grow(Math.ceil((e-r)/i))}requireExports(){if(!this.exports)throw new Error("WASM backend is not initialized. Call init() first.");return this.exports}}}));function Bd(e){const t=[];return ya(e,Ta,1,t),t}function ya(e,t,i,r){const s=A(e),n=ce(t,Vd(e)),a=i*Sa(S(e,"Opacity"));if(s==="Path"){const o=Xd(e);if(o.length>0){const l=Pa(e,"Fill",a),c=Pa(e,"Stroke",a),d=Number(S(e,"StrokeThickness")??1);(l||c&&d>0)&&r.push({commands:o,matrix:n,opacity:a,fill:l,stroke:c,thickness:Number.isFinite(d)?d:1,lineStyle:jd(e),fillRule:Yd(e),bounds:qd(o)})}}for(const o of Y(e))A(o).includes(".")||ya(o,n,a,r)}function Wd(e,t,i,r,s){const n=ce(i,t.matrix),a=Ke(t.matrix),o=Math.max(1e-6,t.thickness||1),l=Math.max(.01,Qe(o,n,r,s)*a),c=Yt(t.commands,.5),d=t.fill?vr(t.fill):void 0,h=t.stroke?vr(t.stroke):void 0;if(d&&va(t.bounds,n,r,s))for(const u of c)(u.closed||u.points.length>=6)&&Od(e,Ea(u.points,t.matrix),d);if(h&&t.thickness>0)for(const u of c){const f=Ea(u.points,t.matrix),p=u.closed?Ud(f):f;t.lineStyle.dash.length>0?zd(e,p,l,t.lineStyle,h):xa(e,p,l,h)}}function Od(e,t,i){if(t.length<3)return;const r=t[0];for(let s=1;s+1<t.length;s++){const n=t[s],a=t[s+1];$d(r,n,a)<1e-6||(e.push(r.x,r.y,i),e.push(n.x,n.y,i),e.push(a.x,a.y,i))}}function xa(e,t,i,r){if(t.length<2)return;const s=Math.max(.05,i*.5);for(let n=0;n+1<t.length;n++)ka(e,t[n],t[n+1],s,r)}function zd(e,t,i,r,s){if(t.length<2||r.dash.length===0)return;const n=r.dash.map(h=>Math.max(.01,h*i)),a=n.reduce((h,u)=>h+u,0);if(a<=.01){xa(e,t,i,s);return}let o=0,l=n[0],c=!0,d=(r.dashOffset*i%a+a)%a;for(;d>l;)d-=l,o=(o+1)%n.length,l=n[o],c=!c;l-=d;for(let h=0;h+1<t.length;h++){const u=t[h],f=t[h+1],p=f.x-u.x,w=f.y-u.y,m=Math.hypot(p,w);if(m<=1e-9)continue;let v=0;for(;v<m-1e-9;){const g=Math.min(l,m-v);if(c&&g>1e-9){const x=v/m,y=(v+g)/m;ka(e,{x:u.x+p*x,y:u.y+w*x},{x:u.x+p*y,y:u.y+w*y},Math.max(.05,i*.5),s)}v+=g,l-=g,l<=1e-9&&(o=(o+1)%n.length,l=n[o],c=!c)}}}function ka(e,t,i,r,s){const n=i.x-t.x,a=i.y-t.y,o=Math.hypot(n,a);if(o<=1e-9)return;const l=-a/o*r,c=n/o*r,d=t.x+l,h=t.y+c,u=t.x-l,f=t.y-c,p=i.x-l,w=i.y-c,m=i.x+l,v=i.y+c;e.push(d,h,s),e.push(u,f,s),e.push(p,w,s),e.push(d,h,s),e.push(p,w,s),e.push(m,v,s)}function Ea(e,t){const i=[];for(let r=0;r+1<e.length;r+=2){const[s,n]=Re(t,e[r]??0,e[r+1]??0);i.push({x:s,y:n})}return i}function Ud(e){if(e.length<2)return e;const t=e[0],i=e[e.length-1];return t.x===i.x&&t.y===i.y?e:[...e,{x:t.x,y:t.y}]}function $d(e,t,i){return Math.abs((t.x-e.x)*(i.y-e.y)-(t.y-e.y)*(i.x-e.x))}function Hd(e,t,i){const r=i.lineWeightMode??"adaptive",s=r==="physical"?"physical":String(Math.round(Math.log2(Math.max(1e-12,Ke(t)))*8));return`${e.id}|${e.sourcePath}|${e.width}x${e.height}|lw:${r}:${s}`}function Vd(e){let t=Zt(S(e,"RenderTransform")??S(e,"Transform"));for(const s of Y(e)){const n=A(s);if(n.endsWith(".RenderTransform")||n.endsWith(".Transform")){const a=Y(s).find(o=>A(o)==="MatrixTransform");a&&(t=ce(t,Zt(S(a,"Matrix"))))}}const i=Number(S(e,"Canvas.Left")??0),r=Number(S(e,"Canvas.Top")??0);return(i||r)&&(t=ce({a:1,b:0,c:0,d:1,e:i,f:r},t)),t}function Xd(e){const t=S(e,"Data");if(t)return Ae(t);for(const i of Y(e))if(A(i)==="Path.Data")for(const r of Y(i)){const s=S(r,"Figures");if(s)return Ae(s)}return[]}function Pa(e,t,i){const r=S(e,t);if(r)return ie(r,i);const s=Gd(e,t,"SolidColorBrush");if(s)return ie(S(s,"Color"),i*Sa(S(s,"Opacity")))}function Gd(e,t,i){const r=`${A(e)}.${t}`;for(const s of Y(e))if(A(s)===r)return Y(s).find(n=>A(n)===i)}function Sa(e){if(!e)return 1;const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):1}function Yd(e){const t=S(e,"Data")??"";return/F0/.test(t)?"nonzero":"evenodd"}function jd(e){const t=(S(e,"StrokeStartLineCap")??"").toLowerCase(),i=(S(e,"StrokeEndLineCap")??"").toLowerCase(),r=(S(e,"StrokeDashCap")??"").toLowerCase(),s=t==="round"||i==="round"||r==="round"?"round":t==="square"||i==="square"||r==="square"?"square":"butt",n=(S(e,"StrokeLineJoin")??"").toLowerCase(),a=n==="round"?"round":n==="bevel"?"bevel":"miter",o=Number(S(e,"StrokeMiterLimit")??10);return{cap:s,join:a,miterLimit:Number.isFinite(o)&&o>0?o:10,dash:Z(S(e,"StrokeDashArray")??"").filter(l=>Number.isFinite(l)&&l>0),dashOffset:Number(S(e,"StrokeDashOffset")??0)||0}}function qd(e){let t=1/0,i=1/0,r=-1/0,s=-1/0;const n=(a,o)=>{!Number.isFinite(a)||!Number.isFinite(o)||(t=Math.min(t,a),i=Math.min(i,o),r=Math.max(r,a),s=Math.max(s,o))};for(const a of e)a.type==="M"||a.type==="L"?n(a.x,a.y):a.type==="C"?(n(a.x1,a.y1),n(a.x2,a.y2),n(a.x,a.y)):a.type==="Q"?(n(a.x1,a.y1),n(a.x,a.y)):a.type==="A"&&(n(a.x-a.rx,a.y-a.ry),n(a.x+a.rx,a.y+a.ry));return Number.isFinite(t)?{minX:t,minY:i,maxX:r,maxY:s}:void 0}function vr(e){const t=qe(e,4278190080);return{r:t&255,g:t>>>8&255,b:t>>>16&255,a:t>>>24&255}}function Zd(e){const t=vr(e);return[t.r/255,t.g/255,t.b/255,t.a/255]}function Ca(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/1024/1024).toFixed(1)} MiB`}function Kd(e,t,i){const r=Ma(e,e.VERTEX_SHADER,t),s=Ma(e,e.FRAGMENT_SHADER,i),n=e.createProgram();if(!n)throw new Error("Failed to create WebGLProgram.");if(e.attachShader(n,r),e.attachShader(n,s),e.linkProgram(n),e.deleteShader(r),e.deleteShader(s),!e.getProgramParameter(n,e.LINK_STATUS)){const a=e.getProgramInfoLog(n)??"unknown link error";throw e.deleteProgram(n),new Error(`WebGL program link failed: ${a}`)}return n}function Ma(e,t,i){const r=e.createShader(t);if(!r)throw new Error("Failed to create WebGLShader.");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){const s=e.getShaderInfoLog(r)??"unknown shader compile error";throw e.deleteShader(r),new Error(`WebGL shader compile failed: ${s}`)}return r}var mt,yr,Aa,Ta,Fa,Na,Ia,_a,La=E((()=>{te(),ue(),ft(),Ze(),ti(),pt(),mt=12,yr=128*1024*1024,Aa=4,Ta={a:1,b:0,c:0,d:1,e:0,f:0},Fa=class{constructor(e){this.scenes=new Map,this.gpuBytes=0,this.tick=0,this.canvas=e??document.createElement("canvas");const t=this.canvas.getContext("webgl",{alpha:!1,antialias:!0,depth:!1,stencil:!1,preserveDrawingBuffer:!0,powerPreference:"high-performance"});if(!t)throw new Error("WebGLRenderingContext is not available.");this.gl=t,this.program=Kd(t,Ia,_a),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aColor=t.getAttribLocation(this.program,"a_color");const i=t.getUniformLocation(this.program,"u_matrix"),r=t.getUniformLocation(this.program,"u_viewport");if(this.aPos<0||this.aColor<0||!i||!r)throw new Error("Failed to resolve WebGL shader locations.");this.uMatrix=i,this.uViewport=r}render(e,t,i,r={}){const s=[];if(i.width<=0||i.height<=0)return{commands:0,warnings:s,gpuBytes:this.gpuBytes,vertexCount:0,pathCount:0,cacheHit:!0};this.resize(i.width,i.height);const n=Qt({canvasWidth:this.canvas.width,canvasHeight:this.canvas.height,pageWidth:e.width,pageHeight:e.height,zoom:r.zoom,panX:r.panX,panY:r.panY}),a={dpr:Jt(i),zoom:r.zoom??1},o=Hd(e,n,r);let l=this.scenes.get(o);const c=!!l;if(!l){const u=Bd(t);l=this.compileScene(e,o,u,n,r,a),this.scenes.set(o,l),this.gpuBytes+=l.gpuBytes,this.evictIfNeeded(r),l=this.scenes.get(o)??l}l.lastUsed=++this.tick;const d=this.gl,h=Zd(r.background??"#ffffff");if(d.viewport(0,0,this.canvas.width,this.canvas.height),d.disable(d.DEPTH_TEST),d.disable(d.CULL_FACE),d.enable(d.BLEND),d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA),d.clearColor(h[0],h[1],h[2],h[3]),d.clear(d.COLOR_BUFFER_BIT),d.useProgram(this.program),d.bindBuffer(d.ARRAY_BUFFER,l.buffer),d.enableVertexAttribArray(this.aPos),d.vertexAttribPointer(this.aPos,2,d.FLOAT,!1,mt,0),d.enableVertexAttribArray(this.aColor),d.vertexAttribPointer(this.aColor,4,d.UNSIGNED_BYTE,!0,mt,8),d.uniform4f(this.uMatrix,n.a,n.b,n.c,n.d),d.uniform4f(this.uViewport,n.e,n.f,this.canvas.width,this.canvas.height),d.drawArrays(d.TRIANGLES,0,l.vertexCount),r.compositeToTarget??!0){const u=i.getContext("2d");if(!u)throw new Error("CanvasRenderingContext2D is not available for WebGL compositing.");u.save(),u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,i.width,i.height),u.drawImage(this.canvas,0,0),u.restore()}return l.vertexCount===0&&s.push(M("warning","WEBGL_XPS_EMPTY_SCENE","WebGL XPS scene contained no drawable vector geometry; Canvas/WASM fallback may be required.",e.sourcePath)),{commands:l.pathCount,warnings:s,gpuBytes:this.gpuBytes,vertexCount:l.vertexCount,pathCount:l.pathCount,cacheHit:c}}dispose(){for(const e of this.scenes.values())this.gl.deleteBuffer(e.buffer);this.scenes.clear(),this.gpuBytes=0}resize(e,t){(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t)}compileScene(e,t,i,r,s,n){const a=new Na;let o=0;for(const f of i)o++,Wd(a,f,r,s,n);const l=a.byteLength,c=s.maxGpuCacheBytes??yr;if(l>c)throw new Error(`WebGL XPS scene buffer would require ${Ca(l)}, exceeding maxGpuCacheBytes=${Ca(c)}.`);const d=this.gl,h=d.createBuffer();if(!h)throw new Error("Failed to allocate WebGLBuffer.");d.bindBuffer(d.ARRAY_BUFFER,h),d.bufferData(d.ARRAY_BUFFER,a.toArrayBuffer(),d.STATIC_DRAW);const u=d.getError();if(u!==d.NO_ERROR)throw d.deleteBuffer(h),new Error(`WebGL XPS buffer upload failed: 0x${u.toString(16)} for ${e.sourcePath}.`);return{key:t,buffer:h,vertexCount:a.vertexCount,gpuBytes:l,pathCount:o,lastUsed:++this.tick}}evictIfNeeded(e){const t=e.maxGpuCacheBytes??yr,i=e.maxCachedScenes??Aa;for(;this.scenes.size>Math.max(1,i)||this.gpuBytes>t;){let r;for(const s of this.scenes.values())(!r||s.lastUsed<r.lastUsed)&&(r=s);if(!r)break;this.scenes.delete(r.key),this.gl.deleteBuffer(r.buffer),this.gpuBytes-=r.gpuBytes}}},Na=class{constructor(){this.buffer=new ArrayBuffer(64*1024),this.view=new DataView(this.buffer),this.vertexCount=0}get byteLength(){return this.vertexCount*mt}push(e,t,i){if(!Number.isFinite(e)||!Number.isFinite(t))return;const r=this.byteLength;this.ensure(mt),this.view.setFloat32(r,e,!0),this.view.setFloat32(r+4,t,!0),this.view.setUint8(r+8,i.r),this.view.setUint8(r+9,i.g),this.view.setUint8(r+10,i.b),this.view.setUint8(r+11,i.a),this.vertexCount++}toArrayBuffer(){return this.buffer.slice(0,this.byteLength)}ensure(e){const t=this.byteLength+e;if(t<=this.buffer.byteLength)return;let i=this.buffer.byteLength;for(;i<t;)i*=2;const r=new ArrayBuffer(i);new Uint8Array(r).set(new Uint8Array(this.buffer,0,this.byteLength)),this.buffer=r,this.view=new DataView(this.buffer)}},Ia=`
|
|
15
|
+
attribute vec2 a_pos;
|
|
16
|
+
attribute vec4 a_color;
|
|
17
|
+
uniform vec4 u_matrix;
|
|
18
|
+
uniform vec4 u_viewport;
|
|
19
|
+
varying vec4 v_color;
|
|
20
|
+
void main() {
|
|
21
|
+
float x = u_matrix.x * a_pos.x + u_matrix.z * a_pos.y + u_viewport.x;
|
|
22
|
+
float y = u_matrix.y * a_pos.x + u_matrix.w * a_pos.y + u_viewport.y;
|
|
23
|
+
vec2 clip = vec2((x / u_viewport.z) * 2.0 - 1.0, 1.0 - (y / u_viewport.w) * 2.0);
|
|
24
|
+
gl_Position = vec4(clip, 0.0, 1.0);
|
|
25
|
+
v_color = a_color;
|
|
26
|
+
}
|
|
27
|
+
`,_a=`
|
|
28
|
+
precision mediump float;
|
|
29
|
+
varying vec4 v_color;
|
|
30
|
+
void main() {
|
|
31
|
+
gl_FragColor = v_color;
|
|
32
|
+
}
|
|
33
|
+
`}));function Qd(e,t,i){const r=(S(t,"StrokeStartLineCap")??"").toLowerCase(),s=(S(t,"StrokeEndLineCap")??"").toLowerCase(),n=(S(t,"StrokeDashCap")??"").toLowerCase();r==="round"||s==="round"||n==="round"?e.lineCap="round":r==="square"||s==="square"||n==="square"?e.lineCap="square":e.lineCap="butt";const a=(S(t,"StrokeLineJoin")??"").toLowerCase();e.lineJoin=a==="round"?"round":a==="bevel"?"bevel":"miter";const o=Number(S(t,"StrokeMiterLimit")??10);Number.isFinite(o)&&o>0&&(e.miterLimit=o);const l=Z(S(t,"StrokeDashArray")??"");if(l.length>0){const c=Number(S(t,"StrokeDashOffset")??0);e.setLineDash(l.map(d=>Math.max(0,d*i))),e.lineDashOffset=Number.isFinite(c)?c*i:0}else e.setLineDash([]),e.lineDashOffset=0}function Jd(e){let t=1/0,i=1/0,r=-1/0,s=-1/0;const n=(a,o)=>{!Number.isFinite(a)||!Number.isFinite(o)||(t=Math.min(t,a),i=Math.min(i,o),r=Math.max(r,a),s=Math.max(s,o))};for(const a of e)a.type==="M"||a.type==="L"?n(a.x,a.y):a.type==="C"?(n(a.x1,a.y1),n(a.x2,a.y2),n(a.x,a.y)):a.type==="Q"?(n(a.x1,a.y1),n(a.x,a.y)):a.type==="A"&&(n(a.x-a.rx,a.y-a.ry),n(a.x+a.rx,a.y+a.ry));return Number.isFinite(t)?{minX:t,minY:i,maxX:r,maxY:s}:void 0}function eh(e,t,i,r,s,n){const a=i.split(";");let o=r,l=0;for(const c of a){const d=c.trim();if(!d)continue;const h=d.split(","),u=Number(h[1]??""),f=Number(h[3]??0),p=Number(h[4]??0),w=t[l++]??"";w&&e.fillText(w,o+(Number.isFinite(f)?f:0),s+(Number.isFinite(p)?p:0)),Number.isFinite(u)&&u>0?o+=u*n/100:o+=e.measureText(w||" ").width}l<t.length&&e.fillText(t.slice(l),o,s)}function th(e,t){const i=(e.split("/").pop()??"").replace(/\.odttf$/i,"").replace(/[^0-9a-fA-F]/g,"");if(i.length!==32||t.length<32)return t;const r=new Uint8Array(16);for(let n=0;n<16;n++)r[n]=parseInt(i.slice(n*2,n*2+2),16);const s=new Uint8Array(t);for(let n=0;n<Math.min(32,s.length);n++)s[n]=(s[n]??0)^r[15-n%16];if(!Da(s)){const n=ih(i),a=new Uint8Array(t);for(let o=0;o<Math.min(32,a.length);o++)a[o]=(a[o]??0)^n[15-o%16];if(Da(a))return a}return s}function ih(e){const t=new Uint8Array(16),i=new Uint8Array(16);for(let r=0;r<16;r++)i[r]=parseInt(e.slice(r*2,r*2+2),16);t[0]=i[3],t[1]=i[2],t[2]=i[1],t[3]=i[0],t[4]=i[5],t[5]=i[4],t[6]=i[7],t[7]=i[6];for(let r=8;r<16;r++)t[r]=i[r];return t}function Da(e){if(e.length<4)return!1;const t=String.fromCharCode(e[0],e[1],e[2],e[3]);return t==="OTTO"||t==="true"||t==="typ1"||t==="ttcf"||e[0]===0&&e[1]===1&&e[2]===0&&e[3]===0}function rh(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Ra(e){let t=Zt(S(e,"RenderTransform")??S(e,"Transform"));for(const s of Y(e)){const n=A(s);if(n.endsWith(".RenderTransform")||n.endsWith(".Transform")){const a=Y(s).find(o=>A(o)==="MatrixTransform");a&&(t=ce(t,Zt(S(a,"Matrix"))))}}const i=Number(S(e,"Canvas.Left")??0),r=Number(S(e,"Canvas.Top")??0);return(i||r)&&(t=ce({a:1,b:0,c:0,d:1,e:i,f:r},t)),t}function xr(e){const t=S(e,"Data");if(t)return Ae(t);for(const i of Y(e))if(A(i)==="Path.Data")for(const r of Y(i)){const s=S(r,"Figures");if(s)return Ae(s);if(A(r)==="PathGeometry"){const n=nh(r);if(n)return Ae(n)}}return[]}function nh(e){const t=[];for(const i of Y(e).filter(r=>A(r)==="PathFigure")){const r=Z(S(i,"StartPoint")??"");r.length>=2&&t.push(`M ${r[0]} ${r[1]}`);for(const s of Y(i)){const n=A(s);if(n==="LineSegment"){const a=Z(S(s,"Point")??"");a.length>=2&&t.push(`L ${a[0]} ${a[1]}`)}else if(n==="PolyLineSegment"){const a=Z(S(s,"Points")??"");for(let o=0;o+1<a.length;o+=2)t.push(`L ${a[o]} ${a[o+1]}`)}else if(n==="BezierSegment"){const a=Z(S(s,"Point1")+" "+S(s,"Point2")+" "+S(s,"Point3"));a.length>=6&&t.push(`C ${a.slice(0,6).join(" ")}`)}else if(n==="PolyBezierSegment"){const a=Z(S(s,"Points")??"");for(let o=0;o+5<a.length;o+=6)t.push(`C ${a.slice(o,o+6).join(" ")}`)}}S(i,"IsClosed")==="true"&&t.push("Z")}return t.length?t.join(" "):void 0}function gt(e,t,i){const r=S(e,t);if(r)return ie(r,i);const s=Ba(e,t,"SolidColorBrush");if(s)return ie(S(s,"Color"),i*kr(S(s,"Opacity")))}function Ba(e,t,i){const r=`${A(e)}.${t}`;for(const s of Y(e))if(A(s)===r)return Y(s).find(n=>A(n)===i)}function kr(e){if(!e)return 1;const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):1}function sh(e){const t=S(e,"Data")??"";return/F0/.test(t)?"nonzero":"evenodd"}function Wa(e){if(!e)return;const t=Z(e);if(t.length>=4)return[t[0],t[1],t[2],t[3]]}var Oa,ah=E((()=>{te(),ue(),ft(),Ze(),ti(),pt(),wr(),La(),Oa=class{constructor(e){this.document=e,this.fontCache=new Map,this.xmlCache=new Map}async render(e,t,i={}){if(!this.document.opc)throw new Error("XPS page requires an OPC package view.");const r=Dt(e.diagnostics),s=(await this.getXmlDocument(e.sourcePath)).documentElement,n=t.getContext("2d");if(!n)throw new Error("CanvasRenderingContext2D is not available.");const a=i.background??"#ffffff",o={dpr:Jt(t),zoom:i.zoom??1},l=Qt({canvasWidth:t.width,canvasHeight:t.height,pageWidth:e.width,pageHeight:e.height,zoom:i.zoom,panX:i.panX,panY:i.panY});let c=0;if(i.preferWebgl??!0)try{const d=this.getWebGlBackend(i.webglCanvas);i.webglCanvas&&(i.webglCanvas.style.visibility="visible");const h=d.render(e,s,t,{...i,compositeToTarget:!i.webglCanvas});return n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,t.width,t.height),n.restore(),c+=h.commands,c+=await this.renderElementToCanvas(s,n,e.sourcePath,l,1,r,{vectors:!1,overlays:!0},i,o),r.push(...h.warnings),{backend:"webgl-xps",commands:c,warnings:r}}catch(d){i.webglCanvas&&(i.webglCanvas.style.visibility="hidden"),r.push(M("warning","WEBGL_XPS_BACKEND_FALLBACK",`WebGL XPS vector path failed, falling back to ${i.preferWasm?"WASM raster":"Canvas2D"}: ${String(d)}`,e.sourcePath))}if(i.webglCanvas&&(i.webglCanvas.style.visibility="hidden"),i.preferWasm)try{return this.wasm??(this.wasm=new br({wasmUrl:i.wasmUrl})),await this.wasm.init(),this.wasm.begin(t.width,t.height,a),c+=this.renderElementToWasm(s,l,1,r,i,o),n.setTransform(1,0,0,1,0,0),n.putImageData(this.wasm.toImageData(),0,0),c+=await this.renderElementToCanvas(s,n,e.sourcePath,l,1,r,{vectors:!1,overlays:!0},i,o),{backend:"wasm-raster",commands:c,warnings:r}}catch(d){r.push(M("warning","WASM_BACKEND_FALLBACK",`WASM raster path failed, falling back to Canvas2D: ${String(d)}`))}return n.save(),n.setTransform(1,0,0,1,0,0),n.fillStyle=a,n.fillRect(0,0,t.width,t.height),n.restore(),c+=await this.renderElementToCanvas(s,n,e.sourcePath,l,1,r,{vectors:!0,overlays:!0},i,o),{backend:"canvas2d",commands:c,warnings:r}}getWebGlBackend(e){return(!this.webgl||this.webglCanvas!==e)&&(this.webgl?.dispose(),this.webgl=new Fa(e),this.webglCanvas=e),this.webgl}getXmlDocument(e){let t=this.xmlCache.get(e);return t||(t=this.document.opc.readText(e).then(i=>Q(i,e)),this.xmlCache.set(e,t)),t}dispose(){this.webgl?.dispose(),this.webgl=void 0,this.webglCanvas=void 0,this.xmlCache.clear(),this.fontCache.clear()}async renderElementToCanvas(e,t,i,r,s,n,a,o,l){const c=A(e),d=ce(r,Ra(e)),h=s*kr(S(e,"Opacity"));let u=0;if(c==="Path"&&a.vectors){const f=xr(e);if(f.length>0){t.save(),t.setTransform(d.a,d.b,d.c,d.d,d.e,d.f),t.globalAlpha=h;const p=S(e,"Clip");p&&(t.beginPath(),Gt(t,Ae(p)),t.clip()),t.beginPath(),Gt(t,f);const w=gt(e,"Fill",h),m=gt(e,"Stroke",h),v=Number(S(e,"StrokeThickness")??1),g=Jd(f);w&&va(g,d,o,l)&&(t.fillStyle=w,t.fill(sh(e))),m&&v>0&&(t.strokeStyle=m,t.lineWidth=Qe(v,d,o,l),Qd(t,e,t.lineWidth),t.stroke()),t.restore(),u++}}else if(c==="Glyphs"&&a.overlays)u+=await this.drawGlyphs(t,i,e,d,h,n,o,l);else if(c==="Image"&&a.overlays){const f=S(e,"Source")??S(e,"ImageSource");if(f)try{await this.drawImageResource(t,i,f,d,h,e),u++}catch(p){n.push(M("warning","XPS_IMAGE_DRAW_FAILED",`Failed to draw image ${f}: ${String(p)}`,i))}}else c==="Canvas"||c==="FixedPage"||c.endsWith(".RenderTransform")||c.endsWith(".Resources");if(c==="Path"&&a.overlays){const f=Ba(e,"Fill","ImageBrush"),p=f?S(f,"ImageSource"):void 0;if(f&&p)try{await this.drawImageBrush(t,i,p,d,h,e,f),u++}catch(w){n.push(M("warning","XPS_IMAGEBRUSH_FAILED",`Failed to draw ImageBrush ${p}: ${String(w)}`,i))}}for(const f of Y(e))A(f).includes(".")||(u+=await this.renderElementToCanvas(f,t,i,d,h,n,a,o,l));return u}renderElementToWasm(e,t,i,r,s,n){if(!this.wasm)return 0;const a=A(e),o=ce(t,Ra(e)),l=i*kr(S(e,"Opacity"));let c=0;if(a==="Path"){const d=xr(e);if(d.length>0){const h=gt(e,"Fill",l),u=gt(e,"Stroke",l),f=Number(S(e,"StrokeThickness")??1),p=Qe(f,o,s,n)*Math.max(1e-12,Math.hypot(o.a,o.b)),w=Yt(d,.5);if(h)for(const m of w)(m.closed||m.points.length>=6)&&this.wasm.drawPolygon(m.points,o,h);if(u&&f>0)for(const m of w)this.wasm.drawPolyline(m.points,o,u,p);c++}}for(const d of Y(e))A(d).includes(".")||(c+=this.renderElementToWasm(d,o,l,r,s,n));return c}async drawGlyphs(e,t,i,r,s,n,a,o){const l=S(i,"UnicodeString")??"";if(!l)return 0;const c=Number(S(i,"OriginX")??0),d=Number(S(i,"OriginY")??0),h=Number(S(i,"FontRenderingEmSize")??12);if(!wa(h,r,a,o))return 0;const u=gt(i,"Fill",s)??"#000000",f=await this.fontFamilyForGlyphs(t,i,n)??"sans-serif";e.save(),e.setTransform(r.a,r.b,r.c,r.d,r.e,r.f),e.globalAlpha=s,e.fillStyle=u,e.font=`${h}px "${f}"`,e.textBaseline="alphabetic";const p=S(i,"Indices");return p?eh(e,l,p,c,d,h):e.fillText(l,c,d),e.restore(),1}async fontFamilyForGlyphs(e,t,i){const r=S(t,"FontUri");if(!r)return;const s=Xe(e,r.replace(/^\//,""));let n=this.fontCache.get(s);return n||(n=this.loadFontFace(s).catch(a=>{i.push(M("warning","XPS_FONT_LOAD_FAILED",`Failed to load embedded XPS font ${s}: ${String(a)}`,e))}),this.fontCache.set(s,n)),n}async loadFontFace(e){const t=globalThis.FontFace,i=document.fonts;if(!t||!i)return;let r=await this.document.opc.readBytes(e),s=De(e)??"font/ttf";/\.odttf$/i.test(e)&&(r=th(e,r),s="font/ttf");const n=`dwfv_xps_${rh(e)}`,a=new Blob([r],{type:s}),o=URL.createObjectURL(a),l=new t(n,`url("${o}")`);try{return await l.load(),i.add(l),URL.revokeObjectURL(o),n}catch(c){throw URL.revokeObjectURL(o),c}}async drawImageResource(e,t,i,r,s,n){const a=this.document.opc,o=Xe(t,i.replace(/^\//,"")),l=await Gi(await a.readBytes(o),a.getContentType(o)??De(o)??"image/png"),c=Number(S(n,"Width")??("width"in l?l.width:0)),d=Number(S(n,"Height")??("height"in l?l.height:0)),h=Number(S(n,"Canvas.Left")??S(n,"X")??0),u=Number(S(n,"Canvas.Top")??S(n,"Y")??0);e.save(),e.setTransform(r.a,r.b,r.c,r.d,r.e,r.f),e.globalAlpha=s,e.drawImage(l,h,u,c||l.width,d||l.height),e.restore()}async drawImageBrush(e,t,i,r,s,n,a){const o=this.document.opc,l=Xe(t,i.replace(/^\//,"")),c=await Gi(await o.readBytes(l),o.getContentType(l)??De(l)??"image/png"),d=Wa(S(a,"Viewport"))??Wa(S(a,"Viewbox"))??[0,0,Number(c.width??1),Number(c.height??1)],h=xr(n);e.save(),e.setTransform(r.a,r.b,r.c,r.d,r.e,r.f),e.globalAlpha=s,h.length>0&&(e.beginPath(),Gt(e,h),e.clip()),e.drawImage(c,d[0],d[1],d[2],d[3]),e.restore()}}}));function oh(e,t,i){const r=i.lineWeightMode??"adaptive",s=r==="physical"?"physical":String(Math.round(Math.log2(Math.max(1e-12,Ke(t)))*8));return`${e.id}|${e.sourcePath}|${e.primitives.length}|lw:${r}:${s}`}function lh(e,t,i,r,s){const n=t.matrix??Sr,a=Ua(n),o=ce(i,n),l=Math.max(.01,Qe(t.lineWidth??1,o,r,s)*a);if(t.type==="polyline"){const c=Te(t.stroke??"#000000");ri(e,ii(t.points,n),l,c)}else if(t.type==="polygon"){const c=ii(t.points,n);t.fill&&Er(e,c,Te(t.fill)),t.stroke&&ri(e,za(c),l,Te(t.stroke))}else if(t.type==="rect"){const c=ii([t.x,t.y,t.x+t.width,t.y,t.x+t.width,t.y+t.height,t.x,t.y+t.height],n);t.fill&&Er(e,c,Te(t.fill)),t.stroke&&ri(e,za(c),l,Te(t.stroke))}else if(t.type==="path"){const c=Yt(t.commands,.5),d=t.fill?Te(t.fill):void 0,h=t.stroke?Te(t.stroke):void 0;for(const u of c){const f=ii(u.points,n);d&&(u.closed||f.length>=6)&&Er(e,f,d),h&&ri(e,f,l,h)}}}function ii(e,t){const i=[];for(let r=0;r+1<e.length;r+=2){const[s,n]=Re(t,e[r]??0,e[r+1]??0);i.push({x:s,y:n})}return i}function Er(e,t,i){if(t.length<3)return;const r=t[0];for(let s=1;s+1<t.length;s++){const n=t[s],a=t[s+1];dh(r,n,a)<1e-6||(e.push(r.x,r.y,i),e.push(n.x,n.y,i),e.push(a.x,a.y,i))}}function ri(e,t,i,r){if(t.length<2)return;const s=Math.max(.05,i*.5);for(let n=0;n+1<t.length;n++)ch(e,t[n],t[n+1],s,r)}function ch(e,t,i,r,s){const n=i.x-t.x,a=i.y-t.y,o=Math.hypot(n,a);if(o<=1e-9)return;const l=-a/o*r,c=n/o*r,d=t.x+l,h=t.y+c,u=t.x-l,f=t.y-c,p=i.x-l,w=i.y-c,m=i.x+l,v=i.y+c;e.push(d,h,s),e.push(u,f,s),e.push(p,w,s),e.push(d,h,s),e.push(p,w,s),e.push(m,v,s)}function za(e){if(e.length<2)return e;const t=e[0],i=e[e.length-1];return t.x===i.x&&t.y===i.y?e:[...e,{x:t.x,y:t.y}]}function dh(e,t,i){return Math.abs((t.x-e.x)*(i.y-e.y)-(t.y-e.y)*(i.x-e.x))}function Ua(e){const t=Math.hypot(e.a,e.b),i=Math.hypot(e.c,e.d);return Math.max(1e-9,(t+i)*.5)}function Te(e){const t=qe(e,4278190080);return{r:t&255,g:t>>>8&255,b:t>>>16&255,a:t>>>24&255}}function hh(e){const t=Te(e);return[t.r/255,t.g/255,t.b/255,t.a/255]}function $a(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/1024/1024).toFixed(1)} MiB`}function uh(e,t,i){const r=Ha(e,e.VERTEX_SHADER,t),s=Ha(e,e.FRAGMENT_SHADER,i),n=e.createProgram();if(!n)throw new Error("Failed to create WebGLProgram.");if(e.attachShader(n,r),e.attachShader(n,s),e.linkProgram(n),e.deleteShader(r),e.deleteShader(s),!e.getProgramParameter(n,e.LINK_STATUS)){const a=e.getProgramInfoLog(n)??"unknown link error";throw e.deleteProgram(n),new Error(`WebGL program link failed: ${a}`)}return n}function Ha(e,t,i){const r=e.createShader(t);if(!r)throw new Error("Failed to create WebGLShader.");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){const s=e.getShaderInfoLog(r)??"unknown shader compile error";throw e.deleteShader(r),new Error(`WebGL shader compile failed: ${s}`)}return r}var bt,Pr,Va,Xa,Sr,Ga,Ya,ja,qa=E((()=>{te(),ft(),Ze(),ti(),pt(),bt=12,Pr=96*1024*1024,Va=3,Xa=class{constructor(e){this.scenes=new Map,this.gpuBytes=0,this.tick=0,this.canvas=e??document.createElement("canvas");const t=this.canvas.getContext("webgl",{alpha:!1,antialias:!0,depth:!1,stencil:!1,preserveDrawingBuffer:!0,powerPreference:"high-performance"});if(!t)throw new Error("WebGLRenderingContext is not available.");this.gl=t,this.program=uh(t,Ya,ja),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aColor=t.getAttribLocation(this.program,"a_color");const i=t.getUniformLocation(this.program,"u_matrix"),r=t.getUniformLocation(this.program,"u_viewport");if(this.aPos<0||this.aColor<0||!i||!r)throw new Error("Failed to resolve WebGL shader locations.");this.uMatrix=i,this.uViewport=r}render(e,t,i={}){const r=[];if(t.width<=0||t.height<=0)return{commands:0,warnings:r,gpuBytes:this.gpuBytes,vertexCount:0,textCount:0,cacheHit:!0};this.resize(t.width,t.height);const s=gr(e,this.canvas.width,this.canvas.height,i.zoom,i.panX,i.panY),n={dpr:Jt(t),zoom:i.zoom??1},a=oh(e,s,i);let o=this.scenes.get(a);const l=!!o;o||(o=this.compileScene(e,a,i,s,n),this.scenes.set(a,o),this.gpuBytes+=o.gpuBytes,this.evictIfNeeded(i),o=this.scenes.get(a)??o),o.lastUsed=++this.tick;const c=this.gl,d=hh(i.background??"#ffffff");c.viewport(0,0,this.canvas.width,this.canvas.height),c.disable(c.DEPTH_TEST),c.disable(c.CULL_FACE),c.enable(c.BLEND),c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA),c.clearColor(d[0],d[1],d[2],d[3]),c.clear(c.COLOR_BUFFER_BIT),c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,o.buffer),c.enableVertexAttribArray(this.aPos),c.vertexAttribPointer(this.aPos,2,c.FLOAT,!1,bt,0),c.enableVertexAttribArray(this.aColor),c.vertexAttribPointer(this.aColor,4,c.UNSIGNED_BYTE,!0,bt,8),c.uniform4f(this.uMatrix,s.a,s.b,s.c,s.d),c.uniform4f(this.uViewport,s.e,s.f,this.canvas.width,this.canvas.height),c.drawArrays(c.TRIANGLES,0,o.vertexCount);const h=t.getContext("2d");if(!h)throw new Error("CanvasRenderingContext2D is not available for WebGL text overlay.");return h.save(),h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,t.width,t.height),(i.compositeToTarget??!0)&&h.drawImage(this.canvas,0,0),this.drawTextOverlay(h,e,s),h.restore(),o.vertexCount===0&&e.primitives.some(u=>u.type!=="text")&&r.push(M("warning","WEBGL_EMPTY_SCENE","WebGL scene contained no drawable geometry; Canvas/WASM fallback may be required.",e.sourcePath)),{commands:o.primitiveCount,warnings:r,gpuBytes:this.gpuBytes,vertexCount:o.vertexCount,textCount:o.textCount,cacheHit:l}}dispose(){for(const e of this.scenes.values())this.gl.deleteBuffer(e.buffer);this.scenes.clear(),this.gpuBytes=0}resize(e,t){(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t)}compileScene(e,t,i,r,s){const n=new Ga;let a=0,o=0;for(const f of e.primitives){if(f.type==="text"){o++;continue}a++,lh(n,f,r,i,s)}const l=n.byteLength,c=i.maxGpuCacheBytes??Pr;if(l>c)throw new Error(`WebGL scene buffer would require ${$a(l)}, exceeding maxGpuCacheBytes=${$a(c)}.`);const d=this.gl,h=d.createBuffer();if(!h)throw new Error("Failed to allocate WebGLBuffer.");d.bindBuffer(d.ARRAY_BUFFER,h),d.bufferData(d.ARRAY_BUFFER,n.toArrayBuffer(),d.STATIC_DRAW);const u=d.getError();if(u!==d.NO_ERROR)throw d.deleteBuffer(h),new Error(`WebGL buffer upload failed: 0x${u.toString(16)}.`);return{key:t,buffer:h,vertexCount:n.vertexCount,gpuBytes:l,primitiveCount:a,textCount:o,lastUsed:++this.tick}}evictIfNeeded(e){const t=e.maxGpuCacheBytes??Pr,i=e.maxCachedScenes??Va;for(;this.scenes.size>Math.max(1,i)||this.gpuBytes>t;){let r;for(const s of this.scenes.values())(!r||s.lastUsed<r.lastUsed)&&(r=s);if(!r)break;this.scenes.delete(r.key),this.gl.deleteBuffer(r.buffer),this.gpuBytes-=r.gpuBytes}}drawTextOverlay(e,t,i){const r=this.canvas.width,s=this.canvas.height;for(const n of t.primitives){if(n.type!=="text")continue;const a=ce(i,n.matrix??Sr),[o,l]=Re(a,n.x,n.y),c=Ua(a),d=Math.max(2,Math.min(768,Math.abs((n.size??12)*c)));if(d<2.5)continue;const h=n.text.split(/\n/),u=h.reduce((w,m)=>Math.max(w,m.length),0),f=Math.max(24,u*d*.65),p=Math.max(d,h.length*d*1.15);if(!(o+f<-64||o>r+64||l+p<-64||l-p>s+64)){e.save(),e.setTransform(1,0,0,1,0,0),e.fillStyle=n.fill??n.stroke??"#000000",e.font=`${d}px sans-serif`,e.textBaseline="alphabetic";for(let w=0;w<h.length;w++)e.fillText(h[w]??"",o,l+w*d*1.15);e.restore()}}}},Sr={a:1,b:0,c:0,d:1,e:0,f:0},Ga=class{constructor(){this.buffer=new ArrayBuffer(64*1024),this.view=new DataView(this.buffer),this.vertexCount=0}get byteLength(){return this.vertexCount*bt}push(e,t,i){if(!Number.isFinite(e)||!Number.isFinite(t))return;const r=this.byteLength;this.ensure(bt),this.view.setFloat32(r,e,!0),this.view.setFloat32(r+4,t,!0),this.view.setUint8(r+8,i.r),this.view.setUint8(r+9,i.g),this.view.setUint8(r+10,i.b),this.view.setUint8(r+11,i.a),this.vertexCount++}toArrayBuffer(){return this.buffer.slice(0,this.byteLength)}ensure(e){const t=this.byteLength+e;if(t<=this.buffer.byteLength)return;let i=this.buffer.byteLength;for(;i<t;)i*=2;const r=new ArrayBuffer(i);new Uint8Array(r).set(new Uint8Array(this.buffer,0,this.byteLength)),this.buffer=r,this.view=new DataView(this.buffer)}},Ya=`
|
|
34
|
+
attribute vec2 a_pos;
|
|
35
|
+
attribute vec4 a_color;
|
|
36
|
+
uniform vec4 u_matrix;
|
|
37
|
+
uniform vec4 u_viewport;
|
|
38
|
+
varying vec4 v_color;
|
|
39
|
+
void main() {
|
|
40
|
+
float x = u_matrix.x * a_pos.x + u_matrix.z * a_pos.y + u_viewport.x;
|
|
41
|
+
float y = u_matrix.y * a_pos.x + u_matrix.w * a_pos.y + u_viewport.y;
|
|
42
|
+
vec2 clip = vec2((x / u_viewport.z) * 2.0 - 1.0, 1.0 - (y / u_viewport.w) * 2.0);
|
|
43
|
+
gl_Position = vec4(clip, 0.0, 1.0);
|
|
44
|
+
v_color = a_color;
|
|
45
|
+
}
|
|
46
|
+
`,ja=`
|
|
47
|
+
precision mediump float;
|
|
48
|
+
varying vec4 v_color;
|
|
49
|
+
void main() {
|
|
50
|
+
gl_FragColor = v_color;
|
|
51
|
+
}
|
|
52
|
+
`}));function fh(e){if(e.length<4)return e;const t=e[0],i=e[1],r=e[e.length-2],s=e[e.length-1];return t===r&&i===s?e:[...e,t,i]}function ph(e){return Math.max(1e-9,(Math.hypot(e.a,e.b)+Math.hypot(e.c,e.d))*.5)}function mh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/1024/1024).toFixed(1)} MiB`}var Za,gh=E((()=>{te(),ft(),Ze(),ti(),pt(),wr(),qa(),Za=class{async render(e,t,i={}){const r=Dt(e.diagnostics),s=i.background??"#ffffff";if(i.preferWebgl??!0)try{const c=this.getWebGlBackend(i.webglCanvas);i.webglCanvas&&(i.webglCanvas.style.visibility="visible");const d=c.render(e,t,{...i,compositeToTarget:!i.webglCanvas}),h=mh(d.gpuBytes),u=d.cacheHit?"cache hit":"cache upload";return r.push(M("info","WEBGL_W2D_RENDERED",`WebGL rendered ${d.vertexCount} vertices, ${d.textCount} text item(s), GPU cache ${h}, ${u}.`,e.sourcePath)),r.push(...d.warnings),{backend:"webgl",commands:d.commands,warnings:r}}catch(c){r.push(M("warning","WEBGL_BACKEND_FALLBACK",`WebGL vector path failed, falling back to ${i.preferWasm?"WASM raster":"Canvas2D"}: ${String(c)}`,e.sourcePath))}i.webglCanvas&&(i.webglCanvas.style.visibility="hidden");const n=t.getContext("2d");if(!n)throw new Error("CanvasRenderingContext2D is not available.");const a=gr(e,t.width,t.height,i.zoom,i.panX,i.panY),o={dpr:Jt(t),zoom:i.zoom??1};let l=0;if(i.preferWasm)try{this.wasm??(this.wasm=new br({wasmUrl:i.wasmUrl})),await this.wasm.init(),this.wasm.begin(t.width,t.height,s);for(const c of e.primitives)l+=this.drawPrimitiveWasm(c,a,i,o);n.setTransform(1,0,0,1,0,0),n.putImageData(this.wasm.toImageData(),0,0);for(const c of e.primitives.filter(d=>d.type==="text"))l+=this.drawPrimitiveCanvas(n,c,a,i,o);return{backend:"wasm-raster",commands:l,warnings:r}}catch(c){r.push(M("warning","WASM_BACKEND_FALLBACK",`WASM raster path failed, falling back to Canvas2D: ${String(c)}`,e.sourcePath))}n.save(),n.setTransform(1,0,0,1,0,0),n.fillStyle=s,n.fillRect(0,0,t.width,t.height),n.restore();for(const c of e.primitives)l+=this.drawPrimitiveCanvas(n,c,a,i,o);return{backend:"canvas2d",commands:l,warnings:r}}dispose(){this.webgl?.dispose(),this.webgl=void 0,this.webglCanvas=void 0}getWebGlBackend(e){return(!this.webgl||this.webglCanvas!==e)&&(this.webgl?.dispose(),this.webgl=new Xa(e),this.webglCanvas=e),this.webgl}drawPrimitiveCanvas(e,t,i,r,s){const n=ce(i,t.matrix??{a:1,b:0,c:0,d:1,e:0,f:0}),a=ie(t.stroke??"#000000")??"#000000",o=ie(t.fill);if(t.type==="text"){const[l,c]=Re(n,t.x,t.y),d=Math.max(1,Math.abs((t.size??12)*ph(n)));if(!wa(t.size??12,n,r,s)||l>e.canvas.width+64||c>e.canvas.height+64||l<-e.canvas.width||c<-e.canvas.height)return 0;e.save(),e.setTransform(1,0,0,1,0,0),e.fillStyle=o??a,e.font=`${Math.min(768,d)}px sans-serif`,e.textBaseline="alphabetic";for(const[h,u]of t.text.split(/\n/).entries())e.fillText(u,l,c+h*d*1.15);return e.restore(),1}if(e.save(),e.setTransform(n.a,n.b,n.c,n.d,n.e,n.f),e.lineWidth=Qe(t.lineWidth??1,n,r,s),t.type==="polyline"){if(t.points.length>=4){e.beginPath(),e.moveTo(t.points[0],t.points[1]);for(let l=2;l+1<t.points.length;l+=2)e.lineTo(t.points[l],t.points[l+1]);e.strokeStyle=a,e.stroke()}}else if(t.type==="polygon"){if(t.points.length>=6){e.beginPath(),e.moveTo(t.points[0],t.points[1]);for(let l=2;l+1<t.points.length;l+=2)e.lineTo(t.points[l],t.points[l+1]);e.closePath(),o&&(e.fillStyle=o,e.fill()),t.stroke&&(e.strokeStyle=a,e.stroke())}}else t.type==="rect"?(o&&(e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height)),t.stroke&&(e.strokeStyle=a,e.strokeRect(t.x,t.y,t.width,t.height))):t.type==="path"&&(e.beginPath(),Gt(e,t.commands),o&&(e.fillStyle=o,e.fill()),t.stroke&&(e.strokeStyle=a,e.stroke()));return e.restore(),1}drawPrimitiveWasm(e,t,i,r){if(!this.wasm||e.type==="text")return 0;const s=ce(t,e.matrix??{a:1,b:0,c:0,d:1,e:0,f:0}),n=Ke(s),a=o=>Qe(o??1,s,i,r)*n;if(e.type==="polyline")this.wasm.drawPolyline(e.points,s,ie(e.stroke??"#000000"),a(e.lineWidth));else if(e.type==="polygon")this.wasm.drawPolygon(e.points,s,ie(e.fill)),e.stroke&&this.wasm.drawPolyline(fh(e.points),s,ie(e.stroke),a(e.lineWidth));else if(e.type==="rect"){const o=[e.x,e.y,e.x+e.width,e.y,e.x+e.width,e.y+e.height,e.x,e.y+e.height,e.x,e.y];e.fill&&this.wasm.drawPolygon(o,s,ie(e.fill)),e.stroke&&this.wasm.drawPolyline(o,s,ie(e.stroke),a(e.lineWidth))}else if(e.type==="path"){const o=Yt(e.commands,.5),l=ie(e.fill),c=ie(e.stroke);if(l)for(const d of o)(d.closed||d.points.length>=6)&&this.wasm.drawPolygon(d.points,s,l);if(c)for(const d of o)this.wasm.drawPolyline(d.points,s,c,a(e.lineWidth))}return 1}}}));function Cr(e,t){for(const i of t.meshes)e.deleteBuffer(i.pos),e.deleteBuffer(i.normal),e.deleteBuffer(i.index),i.edgeIndex&&e.deleteBuffer(i.edgeIndex),i.vao&&Mr(e)&&e.deleteVertexArray(i.vao)}function ni(e,t,i){const r=e.createBuffer();if(!r)throw new Error("Failed to create WebGL buffer.");return e.bindBuffer(t,r),e.bufferData(t,i,e.STATIC_DRAW),r}function Ka(e,t,i){e.bindBuffer(e.ARRAY_BUFFER,i.pos),e.enableVertexAttribArray(t.aPosition),e.vertexAttribPointer(t.aPosition,3,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,i.normal),e.enableVertexAttribArray(t.aNormal),e.vertexAttribPointer(t.aNormal,3,e.FLOAT,!1,0,0)}function bh(e){const t=e.getContext("2d");t&&(t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height))}function si(e,t,i){const r=e.createShader(t);if(!r)throw new Error("Failed to create WebGL shader.");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){const s=e.getShaderInfoLog(r)??"unknown shader error";throw e.deleteShader(r),new Error(s)}return r}function Qa(e,t,i){const r=e.createProgram();if(!r)throw new Error("Failed to create WebGL program.");if(e.attachShader(r,t),e.attachShader(r,i),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS)){const s=e.getProgramInfoLog(r)??"unknown program link error";throw e.deleteProgram(r),new Error(s)}return r}function Fe(e,t,i){const r=e.getUniformLocation(t,i);if(!r)throw new Error(`Missing shader uniform ${i}.`);return r}function wh(e,t,i){const r=e.model.bounds,s=Math.max(1e-6,t.width/Math.max(1,t.height)),n=i.yaw??-.78,a=Eh(i.pitch??.55,-1.45,1.45),o=Math.max(.05,Math.min(100,i.zoom??1)),l=Math.max(1e-4,r.radius),c=l*2.55/o,d=Math.cos(a),h=[Math.sin(n)*d,Math.sin(a),Math.cos(n)*d],u=r.center,f=[Math.cos(n),0,-Math.sin(n)],p=[f[1]*h[2]-f[2]*h[1],f[2]*h[0]-f[0]*h[2],f[0]*h[1]-f[1]*h[0]],w=l*2/Math.max(1,Math.min(t.width,t.height))/Math.max(.1,o),m=(i.panX??0)*w,v=(i.panY??0)*w,g=[u[0]-f[0]*m+p[0]*v,u[1]-f[1]*m+p[1]*v,u[2]-f[2]*m+p[2]*v],x=xh([g[0]+h[0]*c,g[1]+h[1]*c,g[2]+h[2]*c],g,[0,1,0]);return{mvp:kh(yh(Math.PI/4,s,Math.max(.001,c-l*2.2),c+l*3.2),x)}}function vh(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function yh(e,t,i,r){const s=1/Math.tan(e/2),n=1/(i-r);return new Float32Array([s/t,0,0,0,0,s,0,0,0,0,(r+i)*n,-1,0,0,2*r*i*n,0])}function xh(e,t,i){let r=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],a=Math.hypot(r,s,n)||1;r/=a,s/=a,n/=a;let o=i[1]*n-i[2]*s,l=i[2]*r-i[0]*n,c=i[0]*s-i[1]*r;a=Math.hypot(o,l,c)||1,o/=a,l/=a,c/=a;const d=s*c-n*l,h=n*o-r*c,u=r*l-s*o;return new Float32Array([o,d,r,0,l,h,s,0,c,u,n,0,-(o*e[0]+l*e[1]+c*e[2]),-(d*e[0]+h*e[1]+u*e[2]),-(r*e[0]+s*e[1]+n*e[2]),1])}function kh(e,t){const i=new Float32Array(16);for(let r=0;r<4;r++)for(let s=0;s<4;s++)i[r*4+s]=e[0+s]*t[r*4+0]+e[4+s]*t[r*4+1]+e[8+s]*t[r*4+2]+e[12+s]*t[r*4+3];return i}function Eh(e,t,i){return Math.max(t,Math.min(i,e))}function Mr(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext}var Ja,eo=E((()=>{te(),Ja=class{constructor(){this.cache=new Map}async render(e,t,i={}){const r=i.webglCanvas??t;i.webglCanvas&&(i.webglCanvas.style.visibility="visible"),bh(t);const s=this.ensureContext(r),n=this.ensureProgram(s),a=this.ensureEdgeProgram(s),o=this.ensureScene(s,e);this.evictScenes(s,i.maxCachedScenes??2,i.maxGpuCacheBytes??160*1024*1024),s.viewport(0,0,r.width,r.height),s.enable(s.DEPTH_TEST),s.disable(s.CULL_FACE),s.clearColor(.97,.98,1,1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.useProgram(n.program);const l=wh(e,r,i);s.uniformMatrix4fv(n.uMvp,!1,l.mvp),s.uniformMatrix4fv(n.uModel,!1,vh()),s.uniform3f(n.uLight0,.35,.65,.68),s.uniform3f(n.uLight1,-.75,.4,-.5),s.uniform1f(n.uAmbient,.28);let c=0;s.enable(s.POLYGON_OFFSET_FILL),s.polygonOffset(1,1);for(const d of o.meshes){const h=d.mesh.color??[.72,.74,.78];s.uniform3f(n.uColor,h[0],h[1],h[2]),d.vao&&"bindVertexArray"in s?s.bindVertexArray(d.vao):Ka(s,n,d),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,d.index),s.drawElements(s.TRIANGLES,d.indexCount,d.indexType,0),c++}s.disable(s.POLYGON_OFFSET_FILL),Mr(s)&&s.bindVertexArray(null),s.useProgram(a.program),s.uniformMatrix4fv(a.uMvp,!1,l.mvp),s.uniform3f(a.uColor,.035,.04,.045),s.enable(s.DEPTH_TEST);for(const d of o.meshes)!d.edgeIndex||!d.edgeIndexCount||(s.bindBuffer(s.ARRAY_BUFFER,d.pos),s.enableVertexAttribArray(a.aPosition),s.vertexAttribPointer(a.aPosition,3,s.FLOAT,!1,0,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,d.edgeIndex),s.drawElements(s.LINES,d.edgeIndexCount,d.edgeIndexType??d.indexType,0),c++);return{backend:"threejs-webgl",commands:c,warnings:Dt(e.diagnostics)}}dispose(){if(this.gl)for(const e of this.cache.values())Cr(this.gl,e);this.cache.clear(),this.program=void 0,this.edgeProgram=void 0}ensureContext(e){if(this.gl&&this.currentCanvas===e)return this.gl;const t=e.getContext("webgl2",{antialias:!0,alpha:!1})??e.getContext("webgl",{antialias:!0,alpha:!1});if(!t)throw new Error("WebGL is not available for 3D W3D rendering.");if(this.gl&&this.currentCanvas!==e){for(const i of this.cache.values())Cr(this.gl,i);this.cache.clear()}return this.gl=t,this.currentCanvas=e,this.program=void 0,this.edgeProgram=void 0,t}ensureProgram(e){if(this.program)return this.program;const t=Qa(e,si(e,e.VERTEX_SHADER,`
|
|
53
|
+
attribute vec3 a_position;
|
|
54
|
+
attribute vec3 a_normal;
|
|
55
|
+
uniform mat4 u_mvp;
|
|
56
|
+
uniform mat4 u_model;
|
|
57
|
+
varying vec3 v_normal;
|
|
58
|
+
void main() {
|
|
59
|
+
v_normal = normalize((u_model * vec4(a_normal, 0.0)).xyz);
|
|
60
|
+
gl_Position = u_mvp * vec4(a_position, 1.0);
|
|
61
|
+
}
|
|
62
|
+
`),si(e,e.FRAGMENT_SHADER,`
|
|
63
|
+
precision mediump float;
|
|
64
|
+
varying vec3 v_normal;
|
|
65
|
+
uniform vec3 u_color;
|
|
66
|
+
uniform vec3 u_light0;
|
|
67
|
+
uniform vec3 u_light1;
|
|
68
|
+
uniform float u_ambient;
|
|
69
|
+
void main() {
|
|
70
|
+
vec3 n = normalize(v_normal);
|
|
71
|
+
float d0 = max(dot(n, normalize(u_light0)), 0.0);
|
|
72
|
+
float d1 = max(dot(n, normalize(u_light1)), 0.0) * 0.45;
|
|
73
|
+
vec3 color = u_color * (u_ambient + d0 * 0.78 + d1);
|
|
74
|
+
gl_FragColor = vec4(color, 1.0);
|
|
75
|
+
}
|
|
76
|
+
`)),i={program:t,aPosition:e.getAttribLocation(t,"a_position"),aNormal:e.getAttribLocation(t,"a_normal"),uMvp:Fe(e,t,"u_mvp"),uModel:Fe(e,t,"u_model"),uColor:Fe(e,t,"u_color"),uLight0:Fe(e,t,"u_light0"),uLight1:Fe(e,t,"u_light1"),uAmbient:Fe(e,t,"u_ambient")};return this.program=i,i}ensureEdgeProgram(e){if(this.edgeProgram)return this.edgeProgram;const t=Qa(e,si(e,e.VERTEX_SHADER,`
|
|
77
|
+
attribute vec3 a_position;
|
|
78
|
+
uniform mat4 u_mvp;
|
|
79
|
+
void main() {
|
|
80
|
+
gl_Position = u_mvp * vec4(a_position, 1.0);
|
|
81
|
+
}
|
|
82
|
+
`),si(e,e.FRAGMENT_SHADER,`
|
|
83
|
+
precision mediump float;
|
|
84
|
+
uniform vec3 u_color;
|
|
85
|
+
void main() {
|
|
86
|
+
gl_FragColor = vec4(u_color, 0.9);
|
|
87
|
+
}
|
|
88
|
+
`));return this.edgeProgram={program:t,aPosition:e.getAttribLocation(t,"a_position"),uMvp:Fe(e,t,"u_mvp"),uColor:Fe(e,t,"u_color")},this.edgeProgram}evictScenes(e,t,i){let r=Array.from(this.cache.values()).reduce((s,n)=>s+n.bytes,0);for(;this.cache.size>Math.max(1,t)||r>i;){const s=this.cache.entries().next().value;if(!s)break;this.cache.delete(s[0]),Cr(e,s[1]),r-=s[1].bytes}}ensureScene(e,t){const i=this.cache.get(t);if(i)return i;const r=[];let s=0;const n=this.ensureProgram(e),a=typeof e.createVertexArray=="function";for(const l of t.model.meshes){const c=ni(e,e.ARRAY_BUFFER,l.positions),d=l.normals??new Float32Array(l.positions.length),h={mesh:l,pos:c,normal:ni(e,e.ARRAY_BUFFER,d),index:ni(e,e.ELEMENT_ARRAY_BUFFER,l.indices),edgeIndex:l.edgeIndices?ni(e,e.ELEMENT_ARRAY_BUFFER,l.edgeIndices):void 0,indexType:l.indices instanceof Uint32Array?e.UNSIGNED_INT:e.UNSIGNED_SHORT,edgeIndexType:l.edgeIndices instanceof Uint32Array?e.UNSIGNED_INT:e.UNSIGNED_SHORT,indexCount:l.indices.length,edgeIndexCount:l.edgeIndices?.length,bytes:l.positions.byteLength+d.byteLength+l.indices.byteLength+(l.edgeIndices?.byteLength??0)};if((l.indices instanceof Uint32Array||l.edgeIndices instanceof Uint32Array)&&!Mr(e)&&!e.getExtension("OES_element_index_uint"))throw new Error("This WebGL implementation does not support 32-bit element indices.");if(a){const u=e,f=u.createVertexArray();u.bindVertexArray(f),Ka(e,n,h),u.bindVertexArray(null),h.vao=f}r.push(h),s+=h.bytes}const o={page:t,meshes:r,bytes:s};return this.cache.set(t,o),o}}}));function to(e,t,i,r,s,n){const a=t.split(/\s+/);let o="";for(const l of a){const c=o?`${o} ${l}`:l;e.measureText(c).width>s&&o?(e.fillText(o,i,r),o=l,r+=n):o=c}o&&e.fillText(o,i,r)}var io,ro=E((()=>{te(),ue(),ah(),gh(),eo(),io=class{constructor(e){this.document=e}async render(e,t,i={}){const r=this.document.pageData[e];if(!r)throw new Error(`Page index out of range: ${e}`);return r.kind!=="w2d-text"&&r.kind!=="w3d-model"&&i.webglCanvas&&(i.webglCanvas.style.visibility="hidden"),r.kind==="xps-fixed-page"?(this.xps??(this.xps=new Oa(this.document)),await this.xps.render(r,t,i)):r.kind==="w2d-text"?(this.w2d??(this.w2d=new Za),await this.w2d.render(r,t,i)):r.kind==="w3d-model"?(this.w3d??(this.w3d=new Ja),await this.w3d.render(r,t,i)):r.kind==="image"?await this.renderImage(r,t,i):this.renderUnsupported(r,t,i)}dispose(){this.xps?.dispose(),this.w2d?.dispose(),this.w3d?.dispose()}async renderImage(e,t,i){const r=this.document.zip;if(!r)throw new Error("Image page requires a ZIP package.");const s=t.getContext("2d");if(!s)throw new Error("CanvasRenderingContext2D is not available.");s.save(),s.setTransform(1,0,0,1,0,0),s.fillStyle=i.background??"#ffffff",s.fillRect(0,0,t.width,t.height),s.restore();const n=await Gi(await r.read(e.sourcePath),e.mediaType),a="width"in n?n.width:n.naturalWidth,o="height"in n?n.height:n.naturalHeight,l=Math.min(t.width/Math.max(1,a),t.height/Math.max(1,o))*(i.zoom??1),c=a*l,d=o*l,h=(t.width-c)/2+(i.panX??0),u=(t.height-d)/2+(i.panY??0);return s.drawImage(n,h,u,c,d),{backend:"image",commands:1,warnings:Dt(e.diagnostics)}}renderUnsupported(e,t,i){const r=t.getContext("2d");if(!r)throw new Error("CanvasRenderingContext2D is not available.");return r.save(),r.setTransform(1,0,0,1,0,0),r.fillStyle=i.background??"#ffffff",r.fillRect(0,0,t.width,t.height),r.fillStyle="#111827",r.font="16px sans-serif",to(r,e.name,32,48,t.width-64,24),r.font="13px sans-serif",r.fillStyle="#92400e",to(r,e.reason,32,88,t.width-64,20),r.restore(),{backend:"unsupported",commands:0,warnings:[...e.diagnostics,M("warning","PAGE_UNSUPPORTED",e.reason,e.sourcePath)]}}}}));function Ar(e){const t=document.createElement("button");return t.type="button",t.textContent=e,t}function no(e){const t=document.createElement("details");t.open=e.children.length>0&&e.children.length<20;const i=document.createElement("summary");if(i.textContent=e.label||e.id,e.meshIds.length>0&&(i.title=`${e.meshIds.length} mesh(es)`),t.append(i),e.contentRefs.length>0){const r=document.createElement("div");r.className="dwfv-tree-meta",r.textContent=e.contentRefs.slice(0,3).join(", "),t.append(r)}for(const r of e.children)t.append(no(r));return t}var so,Ph=E((()=>{ga(),Ze(),pt(),ro(),so=class{constructor(e,t={}){this.pageIndex=0,this.zoom=1,this.panX=0,this.panY=0,this.yaw=-.78,this.pitch=.55,this.rendering=!1,this.renderAgain=!1,this.renderRaf=0,this.renderSeq=0,this.currentDpr=1,this.preferWebgl=t.preferWebgl??!0,this.preferWasm=t.preferWasm??!0,this.wasmUrl=t.wasmUrl,this.background=t.background??"#ffffff",this.maxDevicePixelRatio=t.maxDevicePixelRatio??2,this.maxCanvasPixels=t.maxCanvasPixels??16777216,this.maxGpuCacheBytes=t.maxGpuCacheBytes,this.maxCachedScenes=t.maxCachedScenes,this.lineWeightMode=t.lineWeightMode??"adaptive",this.minStrokeCssPx=t.minStrokeCssPx,this.maxOverviewStrokeCssPx=t.maxOverviewStrokeCssPx,this.minTextCssPx=t.minTextCssPx,this.minFilledAreaCssPx=t.minFilledAreaCssPx,this.root=document.createElement("div"),this.root.className="dwfv-root";const i=document.createElement("div");i.className="dwfv-toolbar",this.pageSelect=document.createElement("select"),this.zoomOutButton=Ar("−"),this.zoomInButton=Ar("+"),this.resetButton=Ar("适应"),this.status=document.createElement("span"),this.status.className="dwfv-status",i.append("页: ",this.pageSelect,this.zoomOutButton,this.zoomInButton,this.resetButton,this.status);const r=document.createElement("div");r.className="dwfv-workspace",this.treePanel=document.createElement("div"),this.treePanel.className="dwfv-tree",this.treePanel.style.display="none";const s=document.createElement("div");s.className="dwfv-stage",this.webglCanvas=document.createElement("canvas"),this.webglCanvas.className="dwfv-canvas dwfv-webgl-canvas",this.webglCanvas.style.visibility="hidden",this.canvas=document.createElement("canvas"),this.canvas.className="dwfv-canvas dwfv-overlay-canvas",this.canvas.style.touchAction="none",s.append(this.webglCanvas,this.canvas),r.append(this.treePanel,s),this.root.append(i,r),e.replaceChildren(this.root),this.pageSelect.addEventListener("change",()=>{this.pageIndex=this.pageSelect.selectedIndex,this.resetView(),this.populateModelTree(),this.requestRender()}),this.zoomOutButton.addEventListener("click",()=>{this.zoomAtCenter(.8),this.requestRender()}),this.zoomInButton.addEventListener("click",()=>{this.zoomAtCenter(1.25),this.requestRender()}),this.resetButton.addEventListener("click",()=>{this.resetView(),this.requestRender()}),this.canvas.addEventListener("wheel",n=>this.onWheel(n),{passive:!1}),this.canvas.addEventListener("pointerdown",n=>this.onPointerDown(n)),window.addEventListener("pointermove",n=>this.onPointerMove(n)),window.addEventListener("pointerup",()=>{this.drag=void 0}),this.canvas.addEventListener("contextmenu",n=>n.preventDefault()),new ResizeObserver(()=>this.requestRender()).observe(s),this.setStatus("选择 .dwf/.dwfx 文件")}setPreferWebgl(e){this.preferWebgl=e,this.requestRender()}setPreferWasm(e){this.preferWasm=e,this.requestRender()}setLineWeightMode(e){this.lineWeightMode=e,this.renderer?.dispose(),this.requestRender()}async load(e,t={}){this.setStatus("解析文件中…"),this.renderer?.dispose(),this.doc=await ma(e,{fileName:t.fileName}),this.renderer=new io(this.doc),this.pageIndex=t.pageIndex??0,this.zoom=1,this.panX=this.panY=0,this.yaw=-.78,this.pitch=.55,this.preferWebgl=t.preferWebgl??this.preferWebgl,this.preferWasm=t.preferWasm??this.preferWasm,this.wasmUrl=t.wasmUrl??this.wasmUrl,this.background=t.background??this.background,this.maxGpuCacheBytes=t.maxGpuCacheBytes??this.maxGpuCacheBytes,this.maxCachedScenes=t.maxCachedScenes??this.maxCachedScenes,this.lineWeightMode=t.lineWeightMode??this.lineWeightMode,this.minStrokeCssPx=t.minStrokeCssPx??this.minStrokeCssPx,this.maxOverviewStrokeCssPx=t.maxOverviewStrokeCssPx??this.maxOverviewStrokeCssPx,this.minTextCssPx=t.minTextCssPx??this.minTextCssPx,this.minFilledAreaCssPx=t.minFilledAreaCssPx??this.minFilledAreaCssPx,this.populatePages(),this.populateModelTree(),await this.render()}async render(){if(!(!this.renderer||!this.doc)){if(this.rendering)return this.renderAgain=!0,this.pendingRender;this.rendering=!0;try{this.resizeCanvasToDisplaySize();const e=this.doc.pageData[this.pageIndex];if(!e)return;const t=++this.renderSeq,i=this.renderer.render(this.pageIndex,this.canvas,{zoom:this.zoom,panX:this.panX,panY:this.panY,preferWebgl:this.preferWebgl,preferWasm:this.preferWasm,wasmUrl:this.wasmUrl,background:this.background,maxGpuCacheBytes:this.maxGpuCacheBytes,maxCachedScenes:this.maxCachedScenes,webglCanvas:this.webglCanvas,yaw:this.yaw,pitch:this.pitch,lineWeightMode:this.lineWeightMode,minStrokeCssPx:this.minStrokeCssPx,maxOverviewStrokeCssPx:this.maxOverviewStrokeCssPx,minTextCssPx:this.minTextCssPx,minFilledAreaCssPx:this.minFilledAreaCssPx});this.pendingRender=i;try{const r=await i;if(this.pendingRender===i&&t===this.renderSeq){const s=r.warnings.filter(a=>a.level!=="info").length,n=this.currentDpr>1?` · DPR ${this.currentDpr.toFixed(2)}`:"";this.setStatus(`${this.doc.kind.toUpperCase()} · ${e.kind} · ${r.backend} · ${r.commands} ops${n}${s?` · ${s} 警告`:""}`,s>0)}return r}catch(r){throw t===this.renderSeq&&this.setStatus(`渲染失败:${String(r)}`,!0),r}}finally{this.rendering=!1,this.renderAgain&&(this.renderAgain=!1,this.requestRender())}}}getDocument(){return this.doc}fit(){this.resetView(),this.requestRender()}dispose(){this.renderRaf&&cancelAnimationFrame(this.renderRaf),this.renderRaf=0,this.renderer?.dispose(),this.renderer=void 0,this.doc=void 0,this.root.replaceChildren()}requestRender(){this.renderRaf||(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=0,this.render()}))}populatePages(){this.pageSelect.replaceChildren();const e=this.doc?.pageData??[];for(const[t,i]of e.entries()){const r=document.createElement("option");r.value=String(t),r.textContent=`${t+1}. ${i.name} (${i.kind})`,this.pageSelect.append(r)}this.pageSelect.selectedIndex=Math.max(0,Math.min(this.pageIndex,e.length-1))}populateModelTree(){const e=this.doc?.pageData[this.pageIndex];if(!e||e.kind!=="w3d-model"||!e.model.sceneTree?.length){this.treePanel.style.display="none",this.treePanel.replaceChildren();return}this.treePanel.style.display="";const t=document.createElement("div");t.className="dwfv-tree-header",t.textContent=`模型结构 · ${e.model.stats.nodeCount??0} 节点`;const i=document.createElement("div");i.className="dwfv-tree-stats",i.textContent=`${e.model.stats.meshCount} meshes · ${e.model.stats.triangleCount} triangles · ${e.model.stats.textureCount??0} textures`;const r=document.createElement("div");r.className="dwfv-tree-content";for(const s of e.model.sceneTree)r.append(no(s));this.treePanel.replaceChildren(t,i,r)}resizeCanvasToDisplaySize(){const e=this.canvas.getBoundingClientRect(),t=Math.max(1,e.width),i=Math.max(1,e.height);let r=Math.max(1,Math.min(this.maxDevicePixelRatio,window.devicePixelRatio||1));const s=t*i*r*r;s>this.maxCanvasPixels&&(r*=Math.sqrt(this.maxCanvasPixels/s)),this.currentDpr=r;const n=Math.max(1,Math.floor(t*r)),a=Math.max(1,Math.floor(i*r));(this.canvas.width!==n||this.canvas.height!==a)&&(this.canvas.width=n,this.canvas.height=a),(this.webglCanvas.width!==n||this.webglCanvas.height!==a)&&(this.webglCanvas.width=n,this.webglCanvas.height=a)}resetView(){this.zoom=1,this.panX=0,this.panY=0,this.yaw=-.78,this.pitch=.55;const e=this.doc?.pageData[this.pageIndex];if(e?.kind==="w3d-model"){const t=e.model.initialView?.camera,i=t?.position,r=t?.target;if(i&&r){const s=i[0]-r[0],n=i[1]-r[1],a=i[2]-r[2],o=Math.hypot(s,n,a);if(o>1e-6){this.pitch=Math.max(-1.45,Math.min(1.45,Math.asin(n/o))),this.yaw=Math.atan2(s,a);const l=Math.max(1e-6,e.model.bounds.radius);this.zoom=Math.max(.05,Math.min(100,l*2.55/o))}}}}zoomAtCenter(e){if(this.resizeCanvasToDisplaySize(),this.is3dPage()){this.zoom=Math.max(.05,Math.min(100,this.zoom*e));return}const t=this.canvas.width/2,i=this.canvas.height/2;this.zoomAroundPoint(e,t,i)}zoomAroundPoint(e,t,i){const r=this.zoom,s=Math.max(.05,Math.min(64,r*e));if(s===r)return;const n=this.pagePointAtCanvasPoint(t,i,r,this.panX,this.panY);if(n){const o=this.pageMatrixAt(s,0,0);if(o){const[l,c]=Re(o,n.x,n.y);this.panX=t-l,this.panY=i-c,this.zoom=s;return}}const a=s/r;this.panX=t-(t-this.panX)*a,this.panY=i-(i-this.panY)*a,this.zoom=s}onWheel(e){if(!this.doc)return;e.preventDefault(),this.resizeCanvasToDisplaySize();const t=this.canvas.getBoundingClientRect(),i=(e.clientX-t.left)*this.currentDpr,r=(e.clientY-t.top)*this.currentDpr,s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*Math.max(1,t.height):e.deltaY,n=Math.exp(-s*.0015);this.is3dPage()?this.zoom=Math.max(.05,Math.min(100,this.zoom*n)):this.zoomAroundPoint(n,i,r),this.requestRender()}onPointerDown(e){this.canvas.setPointerCapture?.(e.pointerId),this.is3dPage()&&e.preventDefault();const t=this.is3dPage()?e.button===2||e.shiftKey?"pan3d":"rotate3d":"pan2d";this.drag={x:e.clientX,y:e.clientY,panX:this.panX,panY:this.panY,yaw:this.yaw,pitch:this.pitch,mode:t}}onPointerMove(e){if(!this.drag)return;const t=e.clientX-this.drag.x,i=e.clientY-this.drag.y;this.drag.mode==="rotate3d"?(this.yaw=this.drag.yaw+t*.008,this.pitch=Math.max(-1.45,Math.min(1.45,this.drag.pitch+i*.008))):(this.panX=this.drag.panX+t*this.currentDpr,this.panY=this.drag.panY+i*this.currentDpr),this.requestRender()}is3dPage(){return this.doc?.pageData[this.pageIndex]?.kind==="w3d-model"}pagePointAtCanvasPoint(e,t,i,r,s){const n=this.pageMatrixAt(i,r,s);if(!n)return;const a=n.a*n.d-n.b*n.c;if(!Number.isFinite(a)||Math.abs(a)<1e-12)return;const o=e-n.e,l=t-n.f;return{x:(n.d*o-n.c*l)/a,y:(-n.b*o+n.a*l)/a}}pageMatrixAt(e,t,i){const r=this.doc?.pageData[this.pageIndex];if(!r)return;const s=Math.max(1,this.canvas.width),n=Math.max(1,this.canvas.height);if(r.kind==="w2d-text")return gr(r,s,n,e,t,i);if(r.kind==="xps-fixed-page")return Qt({canvasWidth:s,canvasHeight:n,pageWidth:Math.max(1,r.width),pageHeight:Math.max(1,r.height),zoom:e,panX:t,panY:i});if(r.kind==="image")return Qt({canvasWidth:s,canvasHeight:n,pageWidth:Math.max(1,r.width),pageHeight:Math.max(1,r.height),zoom:e,panX:t,panY:i,margin:0})}setStatus(e,t=!1){this.status.textContent=e,this.status.classList.toggle("dwfv-warn",t)}}})),Sh=E((()=>{ga(),ns(),Vi(),Ph(),ro(),wr(),qa(),La(),eo()}));function ao(e,t){return e<=9?t:e>=10&&e<=59?parseFloat(t):e>=60&&e<=99?parseInt(t):e>=100&&e<=109?t:e>=110&&e<=149?parseFloat(t):e>=160&&e<=179?parseInt(t):e>=210&&e<=239?parseFloat(t):e>=270&&e<=289?parseInt(t):e>=290&&e<=299?Ch(t):e>=300&&e<=369?t:e>=370&&e<=389?parseInt(t):e>=390&&e<=399?t:e>=400&&e<=409?parseInt(t):e>=410&&e<=419?t:e>=420&&e<=429?parseInt(t):e>=430&&e<=439?t:e>=440&&e<=459?parseInt(t):e>=460&&e<=469?parseFloat(t):e>=470&&e<=481||e===999||e>=1e3&&e<=1009?t:e>=1010&&e<=1059?parseFloat(t):e>=1060&&e<=1071?parseInt(t):(console.log("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function Ch(e){if(e==="0")return!1;if(e==="1")return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var oo,Mh=E((()=>{oo=class{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=ao(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=ao(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}})),Tr,lo=E((()=>{Tr=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215]}));function Ah(e){return Tr[e]}function _(e){const t={};e.rewind();let i=e.next(),r=i.code;if(t.x=i.value,r+=10,i=e.next(),i.code!=r)throw new Error("Expected code for point value to be "+r+" but got "+i.code+".");return t.y=i.value,r+=10,i=e.next(),i.code!=r?(e.rewind(),t):(t.z=i.value,t)}function q(e,t,i){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 6:e.lineType=t.value;break;case 8:e.layer=t.value;break;case 48:e.lineTypeScale=t.value;break;case 60:e.visible=t.value===0;break;case 62:e.colorIndex=t.value,e.color=Ah(Math.abs(t.value));break;case 67:e.inPaperSpace=t.value!==0;break;case 100:break;case 101:for(;t.code!=0;)t=i.next();i.rewind();break;case 330:e.ownerHandle=t.value;break;case 347:e.materialObjectHandle=t.value;break;case 370:e.lineweight=t.value;break;case 420:e.color=t.value;break;case 1e3:e.extendedData=e.extendedData||{},e.extendedData.customStrings=e.extendedData.customStrings||[],e.extendedData.customStrings.push(t.value);break;case 1001:e.extendedData=e.extendedData||{},e.extendedData.applicationName=t.value;break;default:return!1}return!0}var K=E((()=>{lo()}));function Th(e,t){var i=[],r=!1,s=!1,n=4;for(let o=0;o<=n;o++){for(var a={};!e.isEOF()&&!(t.code===0||s);){switch(t.code){case 10:case 11:case 12:case 13:if(r){s=!0;continue}a.x=t.value,r=!0;break;case 20:case 21:case 22:case 23:a.y=t.value;break;case 30:case 31:case 32:case 33:a.z=t.value;break;default:return i}t=e.next()}i.push(a),r=!1,s=!1}return e.rewind(),i}var co,Fh=E((()=>{K(),co=class{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=Th(e,t),t=e.lastReadGroup;break;default:q(i,t,e);break}t=e.next()}return i}}})),ho,Nh=E((()=>{K(),ho=class{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=_(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),uo,Ih=E((()=>{K(),uo=class{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=_(e);break;case 11:i.endPoint=_(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),fo,_h=E((()=>{K(),fo=class{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=_(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const r=Math.PI/180*t.value;r<i.startAngle?i.angleLength=r+2*Math.PI-i.startAngle:i.angleLength=r-i.startAngle,i.endAngle=r;break;default:q(i,t,e);break}t=e.next()}return i}}})),po,Lh=E((()=>{K(),po=class{constructor(){this.ForEntityName="DIMENSION"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 2:i.block=t.value;break;case 10:i.anchorPoint=_(e);break;case 11:i.middleOfText=_(e);break;case 12:i.insertionPoint=_(e);break;case 13:i.linearOrAngularPoint1=_(e);break;case 14:i.linearOrAngularPoint2=_(e);break;case 15:i.diameterOrRadiusPoint=_(e);break;case 16:i.arcPoint=_(e);break;case 70:i.dimensionType=t.value;break;case 71:i.attachmentPoint=t.value;break;case 42:i.actualMeasurement=t.value;break;case 1:i.text=t.value;break;case 50:i.angle=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),mo,Dh=E((()=>{K(),mo=class{constructor(){this.ForEntityName="ELLIPSE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=_(e);break;case 11:i.majorAxisEndPoint=_(e);break;case 40:i.axisRatio=t.value;break;case 41:i.startAngle=t.value;break;case 42:i.endAngle=t.value;break;case 2:i.name=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),go,Rh=E((()=>{K(),go=class{constructor(){this.ForEntityName="INSERT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 2:i.name=t.value;break;case 41:i.xScale=t.value;break;case 42:i.yScale=t.value;break;case 43:i.zScale=t.value;break;case 10:i.position=_(e);break;case 50:i.rotation=t.value;break;case 70:i.columnCount=t.value;break;case 71:i.rowCount=t.value;break;case 44:i.columnSpacing=t.value;break;case 45:i.rowSpacing=t.value;break;case 210:i.extrusionDirection=_(e);break;default:q(i,t,e);break}t=e.next()}return i}}})),bo,Bh=E((()=>{K(),bo=class{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.vertices.unshift(_(e));break;case 11:i.vertices.push(_(e));break;case 210:i.extrusionDirection=_(e);break;case 100:break;default:q(i,t,e);break}t=e.next()}return i}}}));function Wh(e,t){if(!e||e<=0)throw Error("n must be greater than 0 verticies");const i=[];let r=!1,s=!1,n=t.lastReadGroup;for(let a=0;a<e;a++){const o={};for(;!t.isEOF()&&!(n.code===0||s);){switch(n.code){case 10:if(r){s=!0;continue}o.x=n.value,r=!0;break;case 20:o.y=n.value;break;case 30:o.z=n.value;break;case 40:o.startWidth=n.value;break;case 41:o.endWidth=n.value;break;case 42:n.value!=0&&(o.bulge=n.value);break;default:return t.rewind(),r&&i.push(o),t.rewind(),i}n=t.next()}i.push(o),r=!1,s=!1}return t.rewind(),i}var wo,Oh=E((()=>{K(),wo=class{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){const i={type:t.value,vertices:[]};let r=0;for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 38:i.elevation=t.value;break;case 39:i.depth=t.value;break;case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 90:r=t.value;break;case 10:i.vertices=Wh(r,e);break;case 43:t.value!==0&&(i.width=t.value);break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),vo,zh=E((()=>{K(),vo=class{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 3:i.text?i.text+=t.value:i.text=t.value;break;case 1:i.text?i.text+=t.value:i.text=t.value;break;case 10:i.position=_(e);break;case 11:i.directionVector=_(e);break;case 40:i.height=t.value;break;case 41:i.width=t.value;break;case 50:i.rotation=t.value;break;case 71:i.attachmentPoint=t.value;break;case 72:i.drawingDirection=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),yo,Uh=E((()=>{K(),yo=class{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.position=_(e);break;case 39:i.thickness=t.value;break;case 210:i.extrusionDirection=_(e);break;case 100:break;default:q(i,t,e);break}t=e.next()}return i}}})),xo,$h=E((()=>{K(),xo=class{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.x=t.value;break;case 20:i.y=t.value;break;case 30:i.z=t.value;break;case 40:break;case 41:break;case 42:t.value!=0&&(i.bulge=t.value);break;case 70:i.curveFittingVertex=(t.value&1)!==0,i.curveFitTangent=(t.value&2)!==0,i.splineVertex=(t.value&8)!==0,i.splineControlPoint=(t.value&16)!==0,i.threeDPolylineVertex=(t.value&32)!==0,i.threeDPolylineMesh=(t.value&64)!==0,i.polyfaceMeshVertex=(t.value&128)!==0;break;case 50:break;case 71:i.faceA=t.value;break;case 72:i.faceB=t.value;break;case 73:i.faceC=t.value;break;case 74:i.faceD=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}}));function Hh(e,t){const i=new xo,r=[];for(;!e.isEOF();)if(t.code===0){if(t.value==="VERTEX")r.push(i.parseEntity(e,t)),t=e.lastReadGroup;else if(t.value==="SEQEND"){Vh(e,t);break}}return r}function Vh(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!=0;)q(i,t,e),t=e.next();return i}var ko,Xh=E((()=>{K(),$h(),ko=class{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:break;case 20:break;case 30:break;case 39:i.thickness=t.value;break;case 40:break;case 41:break;case 70:i.shape=(t.value&1)!==0,i.includesCurveFitVertices=(t.value&2)!==0,i.includesSplineFitVertices=(t.value&4)!==0,i.is3dPolyline=(t.value&8)!==0,i.is3dPolygonMesh=(t.value&16)!==0,i.is3dPolygonMeshClosed=(t.value&32)!==0,i.isPolyfaceMesh=(t.value&64)!==0,i.hasContinuousLinetypePattern=(t.value&128)!==0;break;case 71:break;case 72:break;case 73:break;case 74:break;case 75:break;case 210:i.extrusionDirection=_(e);break;default:q(i,t,e);break}t=e.next()}return i.vertices=Hh(e,t),i}}})),Eo,Gh=E((()=>{K(),Eo=class{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){const i={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.points[0]=_(e);break;case 11:i.points[1]=_(e);break;case 12:i.points[2]=_(e);break;case 13:i.points[3]=_(e);break;case 210:i.extrusionDirection=_(e);break;default:q(i,t,e);break}t=e.next()}return i}}})),Po,Yh=E((()=>{K(),Po=class{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.controlPoints||(i.controlPoints=[]),i.controlPoints.push(_(e));break;case 11:i.fitPoints||(i.fitPoints=[]),i.fitPoints.push(_(e));break;case 12:i.startTangent=_(e);break;case 13:i.endTangent=_(e);break;case 40:i.knotValues||(i.knotValues=[]),i.knotValues.push(t.value);break;case 70:(t.value&1)!=0&&(i.closed=!0),(t.value&2)!=0&&(i.periodic=!0),(t.value&4)!=0&&(i.rational=!0),(t.value&8)!=0&&(i.planar=!0),(t.value&16)!=0&&(i.planar=!0,i.linear=!0);break;case 71:i.degreeOfSplineCurve=t.value;break;case 72:i.numberOfKnots=t.value;break;case 73:i.numberOfControlPoints=t.value;break;case 74:i.numberOfFitPoints=t.value;break;case 210:i.normalVector=_(e);break;default:q(i,t,e);break}t=e.next()}return i}}})),So,jh=E((()=>{K(),So=class{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.startPoint=_(e);break;case 11:i.endPoint=_(e);break;case 40:i.textHeight=t.value;break;case 41:i.xScale=t.value;break;case 50:i.rotation=t.value;break;case 1:i.text=t.value;break;case 72:i.halign=t.value;break;case 73:i.valign=t.value;break;default:q(i,t,e);break}t=e.next()}return i}}})),qh=Hl(((e,t)=>{(function(i,r){"use strict";typeof define=="function"&&define.amd?define(r):typeof t=="object"&&t.exports?t.exports=r():i.log=r()})(e,function(){"use strict";var i=function(){},r="undefined",s=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],a={},o=null;function l(m,v){var g=m[v];if(typeof g.bind=="function")return g.bind(m);try{return Function.prototype.bind.call(g,m)}catch{return function(){return Function.prototype.apply.apply(g,[m,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function d(m){return m==="debug"&&(m="log"),typeof console===r?!1:m==="trace"&&s?c:console[m]!==void 0?l(console,m):console.log!==void 0?l(console,"log"):i}function h(){for(var m=this.getLevel(),v=0;v<n.length;v++){var g=n[v];this[g]=v<m?i:this.methodFactory(g,m,this.name)}if(this.log=this.debug,typeof console===r&&m<this.levels.SILENT)return"No console available for logging"}function u(m){return function(){typeof console!==r&&(h.call(this),this[m].apply(this,arguments))}}function f(m,v,g){return d(m)||u.apply(this,arguments)}function p(m,v){var g=this,x,y,b,k="loglevel";typeof m=="string"?k+=":"+m:typeof m=="symbol"&&(k=void 0);function T(L){var z=(n[L]||"silent").toUpperCase();if(!(typeof window===r||!k)){try{window.localStorage[k]=z;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+z+";"}catch{}}}function N(){var L;if(!(typeof window===r||!k)){try{L=window.localStorage[k]}catch{}if(typeof L===r)try{var z=window.document.cookie,ge=encodeURIComponent(k),ye=z.indexOf(ge+"=");ye!==-1&&(L=/^([^;]+)/.exec(z.slice(ye+ge.length+1))[1])}catch{}return g.levels[L]===void 0&&(L=void 0),L}}function $(){if(!(typeof window===r||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function he(L){var z=L;if(typeof z=="string"&&g.levels[z.toUpperCase()]!==void 0&&(z=g.levels[z.toUpperCase()]),typeof z=="number"&&z>=0&&z<=g.levels.SILENT)return z;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=m,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=v||f,g.getLevel=function(){return b??y??x},g.setLevel=function(L,z){return b=he(L),z!==!1&&T(b),h.call(g)},g.setDefaultLevel=function(L){y=he(L),N()||g.setLevel(L,!1)},g.resetLevel=function(){b=null,$(),h.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(o!==g&&(x=he(o.getLevel())),h.call(g),o===g)for(var L in a)a[L].rebuild()},x=he(o?o.getLevel():"WARN");var fe=N();fe!=null&&(b=he(fe)),h.call(g)}o=new p,o.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var g=a[v];return g||(g=a[v]=new p(v,o.methodFactory)),g};var w=typeof window!==r?window.log:void 0;return o.noConflict=function(){return typeof window!==r&&window.log===o&&(window.log=w),o},o.getLoggers=function(){return a},o.default=o,o})}));function Zh(e){e.registerEntityHandler(co),e.registerEntityHandler(ho),e.registerEntityHandler(uo),e.registerEntityHandler(fo),e.registerEntityHandler(po),e.registerEntityHandler(mo),e.registerEntityHandler(go),e.registerEntityHandler(bo),e.registerEntityHandler(wo),e.registerEntityHandler(vo),e.registerEntityHandler(yo),e.registerEntityHandler(ko),e.registerEntityHandler(Eo),e.registerEntityHandler(Po),e.registerEntityHandler(So)}function me(e,t,i){return e.code===t&&e.value===i}function We(e){I.default.debug("unhandled group "+Co(e))}function Co(e){return e.code+":"+e.value}function Kh(e){return Tr[e]}var I,Fr,Qh=E((()=>{Mh(),lo(),Fh(),Nh(),Ih(),_h(),Lh(),Dh(),Rh(),Bh(),Oh(),zh(),Uh(),Xh(),Gh(),Yh(),jh(),I=Xl(qh()),I.default.setLevel("error"),Fr=class{constructor(){this._entityHandlers={},Zh(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((r,s)=>{e.on("data",n=>{t+=n}),e.on("end",()=>{try{r(i._parse(t))}catch(n){s(n)}}),e.on("error",n=>{s(n)})})}_parse(e){const t={};let i=0;const r=new oo(e.split(/\r\n|\r|\n/g));if(!r.hasNext())throw Error("Empty file");const s=this;let n;function a(){for(n=r.next();!r.isEOF();)if(n.code===0&&n.value==="SECTION"){if(n=r.next(),n.code!==2){console.error("Unexpected code %s after 0:SECTION",Co(n)),n=r.next();continue}n.value==="HEADER"?(I.default.debug("> HEADER"),t.header=o(),I.default.debug("<")):n.value==="BLOCKS"?(I.default.debug("> BLOCKS"),t.blocks=l(),I.default.debug("<")):n.value==="ENTITIES"?(I.default.debug("> ENTITIES"),t.entities=v(!1),I.default.debug("<")):n.value==="TABLES"?(I.default.debug("> TABLES"),t.tables=d(),I.default.debug("<")):n.value==="EOF"?I.default.debug("EOF"):I.default.warn("Skipping section '%s'",n.value)}else n=r.next()}function o(){let y=null,b=null;const k={};for(n=r.next();;){if(me(n,0,"ENDSEC")){y&&(k[y]=b);break}else n.code===9?(y&&(k[y]=b),y=n.value):n.code===10?b={x:n.value}:n.code===20?b.y=n.value:n.code===30?b.z=n.value:b=n.value;n=r.next()}return n=r.next(),k}function l(){const y={};for(n=r.next();n.value!=="EOF"&&!me(n,0,"ENDSEC");)if(me(n,0,"BLOCK")){I.default.debug("block {");const b=c();I.default.debug("}"),x(b),b.name?y[b.name]=b:I.default.error('block with handle "'+b.handle+'" is missing a name.')}else We(n),n=r.next();return y}function c(){const y={};for(n=r.next();n.value!=="EOF";){switch(n.code){case 1:y.xrefPath=n.value,n=r.next();break;case 2:y.name=n.value,n=r.next();break;case 3:y.name2=n.value,n=r.next();break;case 5:y.handle=n.value,n=r.next();break;case 8:y.layer=n.value,n=r.next();break;case 10:y.position=g(n),n=r.next();break;case 67:y.paperSpace=!!(n.value&&n.value==1),n=r.next();break;case 70:n.value!=0&&(y.type=n.value),n=r.next();break;case 100:n=r.next();break;case 330:y.ownerHandle=n.value,n=r.next();break;case 0:if(n.value=="ENDBLK")break;y.entities=v(!0);break;default:We(n),n=r.next()}if(me(n,0,"ENDBLK")){n=r.next();break}}return y}function d(){const y={};for(n=r.next();n.value!=="EOF"&&!me(n,0,"ENDSEC");)me(n,0,"TABLE")?(n=r.next(),m[n.value]?(I.default.debug(n.value+" Table {"),y[m[n.value].tableName]=u(n),I.default.debug("}")):I.default.debug("Unhandled Table "+n.value)):n=r.next();return n=r.next(),y}const h="ENDTAB";function u(y){const b=m[y.value],k={};let T=0;for(n=r.next();!me(n,0,h);)switch(n.code){case 5:k.handle=n.value,n=r.next();break;case 330:k.ownerHandle=n.value,n=r.next();break;case 100:n.value==="AcDbSymbolTable"||We(n),n=r.next();break;case 70:T=n.value,n=r.next();break;case 0:n.value===b.dxfSymbolName?k[b.tableRecordsProperty]=b.parseTableRecords():(We(n),n=r.next());break;default:We(n),n=r.next()}const N=k[b.tableRecordsProperty];if(N){let $=(()=>{if(N.constructor===Array)return N.length;if(typeof N=="object")return Object.keys(N).length})();T!==$&&I.default.warn("Parsed "+$+" "+b.dxfSymbolName+"'s but expected "+T)}return n=r.next(),k}function f(){const y=[];let b={};for(I.default.debug("ViewPort {"),n=r.next();!me(n,0,h);)switch(n.code){case 2:b.name=n.value,n=r.next();break;case 10:b.lowerLeftCorner=g(n),n=r.next();break;case 11:b.upperRightCorner=g(n),n=r.next();break;case 12:b.center=g(n),n=r.next();break;case 13:b.snapBasePoint=g(n),n=r.next();break;case 14:b.snapSpacing=g(n),n=r.next();break;case 15:b.gridSpacing=g(n),n=r.next();break;case 16:b.viewDirectionFromTarget=g(n),n=r.next();break;case 17:b.viewTarget=g(n),n=r.next();break;case 42:b.lensLength=n.value,n=r.next();break;case 43:b.frontClippingPlane=n.value,n=r.next();break;case 44:b.backClippingPlane=n.value,n=r.next();break;case 45:b.viewHeight=n.value,n=r.next();break;case 50:b.snapRotationAngle=n.value,n=r.next();break;case 51:b.viewTwistAngle=n.value,n=r.next();break;case 79:b.orthographicType=n.value,n=r.next();break;case 110:b.ucsOrigin=g(n),n=r.next();break;case 111:b.ucsXAxis=g(n),n=r.next();break;case 112:b.ucsYAxis=g(n),n=r.next();break;case 110:b.ucsOrigin=g(n),n=r.next();break;case 281:b.renderMode=n.value,n=r.next();break;case 281:b.defaultLightingType=n.value,n=r.next();break;case 292:b.defaultLightingOn=n.value,n=r.next();break;case 330:b.ownerHandle=n.value,n=r.next();break;case 63:case 421:case 431:b.ambientColor=n.value,n=r.next();break;case 0:n.value==="VPORT"&&(I.default.debug("}"),y.push(b),I.default.debug("ViewPort {"),b={},n=r.next());break;default:We(n),n=r.next();break}return I.default.debug("}"),y.push(b),y}function p(){const y={};let b={},k=0,T;for(I.default.debug("LType {"),n=r.next();!me(n,0,"ENDTAB");)switch(n.code){case 2:b.name=n.value,T=n.value,n=r.next();break;case 3:b.description=n.value,n=r.next();break;case 73:k=n.value,k>0&&(b.pattern=[]),n=r.next();break;case 40:b.patternLength=n.value,n=r.next();break;case 49:b.pattern.push(n.value),n=r.next();break;case 0:I.default.debug("}"),k>0&&k!==b.pattern.length&&I.default.warn("lengths do not match on LTYPE pattern"),y[T]=b,b={},I.default.debug("LType {"),n=r.next();break;default:n=r.next()}return I.default.debug("}"),y[T]=b,y}function w(){const y={};let b={},k;for(I.default.debug("Layer {"),n=r.next();!me(n,0,"ENDTAB");)switch(n.code){case 2:b.name=n.value,k=n.value,n=r.next();break;case 62:b.visible=n.value>=0,b.colorIndex=Math.abs(n.value),b.color=Kh(b.colorIndex),n=r.next();break;case 70:b.frozen=(n.value&1)!=0||(n.value&2)!=0,n=r.next();break;case 0:n.value==="LAYER"&&(I.default.debug("}"),y[k]=b,I.default.debug("Layer {"),b={},k=void 0,n=r.next());break;default:We(n),n=r.next();break}return I.default.debug("}"),y[k]=b,y}const m={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:f},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:p},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:w}};function v(y){const b=[],k=y?"ENDBLK":"ENDSEC";for(y||(n=r.next());;)if(n.code===0){if(n.value===k)break;const T=s._entityHandlers[n.value];if(T!=null){I.default.debug(n.value+" {");const N=T.parseEntity(r,n);n=r.lastReadGroup,I.default.debug("}"),x(N),b.push(N)}else{I.default.warn("Unhandled entity "+n.value),n=r.next();continue}}else n=r.next();return k=="ENDSEC"&&(n=r.next()),b}function g(y){const b={};let k=y.code;if(b.x=y.value,k+=10,y=r.next(),y.code!=k)throw new Error("Expected code for point value to be "+k+" but got "+y.code+".");return b.y=y.value,k+=10,y=r.next(),y.code!=k?(r.rewind(),b):(b.z=y.value,b)}function x(y){if(!y)throw new TypeError("entity cannot be undefined or null");y.handle||(y.handle=i++)}return a(),t}}})),Jh=xi({DxfParser:()=>Fr,default:()=>Mo}),Mo,eu=E((()=>{Qh(),Mo=Fr}));async function wt(e){if(e.buffer instanceof Uint8Array)return e.buffer;if(e.buffer instanceof ArrayBuffer)return new Uint8Array(e.buffer);if(e.file)return new Uint8Array(await e.file.arrayBuffer());throw new Error("CadLoadInput requires a File, ArrayBuffer, or Uint8Array.")}function tu(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}function Je(e){var t;const i=e.fileName??((t=e.file)==null?void 0:t.name)??"",r=i.lastIndexOf(".");return r>=0?i.slice(r+1).toLowerCase():""}function et(e,t){const i=Je(e);if(i==="dwg")return"dwg";if(i==="dxf")return"dxf";if(i==="dwfx")return"dwfx";if(i==="xps")return"xps";if(i==="dwf")return"dwf";if(t&&t.byteLength>=6){const r=Ao(t.slice(0,6));if(/^AC10/.test(r))return"dwg";if(t[0]===80&&t[1]===75)return"dwfx";const s=Ao(t.slice(0,Math.min(t.byteLength,2048))).toUpperCase();if(s.includes("SECTION")&&s.includes("ENTITIES"))return"dxf";if(s.includes("DWF"))return"dwf"}return"unknown"}function Ao(e){return Array.from(e,t=>t>=32&&t<=126?String.fromCharCode(t):" ").join("")}function Nr(){return typeof Worker<"u"&&typeof URL<"u"}function iu(e){return e.workerFactory?e.workerFactory():new Worker(su(e.workerUrl),{type:"module",name:"lightweight-cad-dwg-loader"})}function To(e){return{wasmPath:nu(e.wasmPath),includePaperSpace:e.includePaperSpace,maxInsertDepth:e.maxInsertDepth,keepRaw:!!e.keepRaw}}function ru(e,t,i){return t.file||i.transferInputBuffer===!0?tu(e):e.slice().buffer}function ai(e){e.timer&&clearTimeout(e.timer),e.signal&&e.abortHandler&&e.signal.removeEventListener("abort",e.abortHandler)}function oi(){if(typeof DOMException<"u")return new DOMException("DWG loading was aborted.","AbortError");const e=new Error("DWG loading was aborted.");return e.name="AbortError",e}function nu(e){const t=(e?.trim()||"/wasm").replace(/\/+$/,"");return t===""?Fo():No(t)?t:t.startsWith("/")?`${Fo()}${t}`:new URL(t,Ir()).href.replace(/\/+$/,"")}function su(e){if(e instanceof URL)return e;const t=e?.trim()||ll;return No(t)?t:new URL(t,Ir()).href}function Ir(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:"http://localhost/"}function Fo(){return typeof location<"u"&&location.origin?location.origin:new URL(Ir()).origin}function No(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}function au(e){return e instanceof Error&&e.name==="AbortError"}function ou(e){const t=e instanceof Error?e.message:String(e);return new Error(`${t} If the worker asset cannot be resolved by your bundler/CDN, pass workerUrl or workerFactory to CadViewer.`)}function Io(e){return{format:e.format,sourceName:e.sourceName,units:e.units,header:e.header??{},layers:e.layers??{},blocks:e.blocks??{},entities:e.entities??[],pages:e.pages,metadata:e.metadata??{},warnings:e.warnings??[],raw:e.raw}}function tt(e){switch(String(e??"").toUpperCase()){case"LINE":return"line";case"CIRCLE":return"circle";case"ARC":return"arc";case"LWPOLYLINE":case"POLYLINE":case"POLYLINE_2D":case"POLYLINE2D":case"POLYLINE_3D":case"POLYLINE3D":case"LEADER":case"MULTILEADER":return"polyline";case"ELLIPSE":return"ellipse";case"TEXT":case"MTEXT":case"ATTRIB":case"ATTDEF":case"DIMENSION":return"text";case"POINT":return"point";case"INSERT":return"insert";case"SOLID":case"TRACE":case"3DFACE":return"solid";case"HATCH":return"hatch";case"SPLINE":return"spline";case"PATH":case"XPS_PATH":case"DWF_PATH":return"path";case"IMAGE":case"RASTER_IMAGE":case"DWF_IMAGE":return"image";case"VIEWPORT":return"viewport";default:return"unsupported"}}function lu(e,t,i={}){const r=t??String(e.type??e.entityType??e.objectName??"UNKNOWN").toUpperCase(),s=i.includeUnknownProperties===!1?{type:r,kind:tt(r)}:{...e,type:r,kind:tt(r)};i.keepRaw&&(s.raw=e),s.handle=ne(e.handle??e.id),s.layer=ne(e.layer??e.layerName),s.lineType=ne(e.lineType??e.linetype);const n=i.numericColorMode??"auto",a=O(e.color);s.colorIndex=O(e.colorIndex??e.colorNumber??e.aci??e.aciColor??e.color_index)??(n!=="rgb"&&a!==void 0&&Math.abs(a)<=257?a:void 0),s.trueColor=e.trueColor??e.true_color??e.truecolor??e.colorRGB??e.colorRgb??e.rgbColor??e.rgb??(a!==void 0&&a>=0&&a<=16777215&&(n==="rgb"||n==="auto"&&Math.abs(a)>257)?a:void 0),(typeof e.color=="string"||typeof e.color=="number")&&(s.color=e.color),s.colorNumber=O(e.colorNumber)??s.colorNumber,s.colorName=ne(e.colorName??e.color_name)??s.colorName,s.fillColor=e.fillColor??e.fill_color,s.fillColorIndex=O(e.fillColorIndex??e.fill_color_index??e.fillColorNumber)??s.fillColorIndex,s.opacity=O(e.opacity??e.alpha)??s.opacity,s.lineweight=O(e.lineweight??e.lineWeight),s.isVisible=!(e.isVisible===!1||e.visible===!1),s.startPoint=re(e.startPoint??e.start??e.p0??e.from)??s.startPoint,s.endPoint=re(e.endPoint??e.end??e.p1??e.to)??s.endPoint,s.center=re(e.center??e.centerPoint)??s.center,s.insertionPoint=re(e.insertionPoint??e.position??e.location??e.point??e.basePoint)??s.insertionPoint,s.radius=O(e.radius)??s.radius,s.startAngle=O(e.startAngle??e.start_angle)??s.startAngle,s.endAngle=O(e.endAngle??e.end_angle)??s.endAngle,s.majorAxisEndPoint=re(e.majorAxisEndPoint??e.majorAxis??e.major)??s.majorAxisEndPoint,s.axisRatio=O(e.axisRatio??e.ratio)??s.axisRatio,s.height=O(e.height??e.textHeight)??s.height,s.textHeight=O(e.textHeight??e.height)??s.textHeight,s.rotation=O(e.rotation??e.angle)??s.rotation,s.text=ne(e.text??e.value??e.string??e.contents)??s.text,s.name=ne(e.name??e.blockName)??s.name,s.blockName=ne(e.blockName??e.name)??s.blockName;const o=_r(e.vertices??e.points);o.length>0&&(s.vertices=o);const l=_r(e.controlPoints??e.control_points);l.length>0&&(s.controlPoints=l);const c=_r(e.fitPoints??e.fit_points);return c.length>0&&(s.fitPoints=c),s}function re(e){if(!e||typeof e!="object")return;const t=e,i=Number(t.x??t.X??t[0]),r=Number(t.y??t.Y??t[1]),s=t.z??t.Z??t[2],n=s===void 0?void 0:Number(s);if(!(!Number.isFinite(i)||!Number.isFinite(r)))return Number.isFinite(n)?{x:i,y:r,z:n}:{x:i,y:r}}function _r(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){const r=re(i);if(!r)continue;const s=i,n=r,a=O(s.bulge);a!==void 0&&(n.bulge=a);const o=O(s.startWidth??s.start_width);o!==void 0&&(n.startWidth=o);const l=O(s.endWidth??s.end_width);l!==void 0&&(n.endWidth=l),t.push(n)}return t}function li(e){var t;const i={};for(const r of e.entities){const s=String(r.type??"UNKNOWN").toUpperCase();i[s]=(i[s]??0)+1}return{format:e.format,sourceName:e.sourceName,entityCount:e.entities.length,layerCount:Object.keys(e.layers).length,blockCount:Object.keys(e.blocks).length,pageCount:((t=e.pages)==null?void 0:t.length)??0,byType:i,warnings:[...e.warnings]}}function _o(e,t){t.name&&(e[t.name]=t,e[t.name.toLowerCase()]=t)}function cu(e,t){t.name&&(e[t.name]=t,e[t.name.toLowerCase()]=t)}function du(e){return e!=null&&e.length?e.flatMap(t=>t.entities.map(i=>({...i,pageIndex:t.index}))):[]}function O(e){const t=Number(e);return Number.isFinite(t)?t:void 0}function ne(e){if(typeof e!="string"&&typeof e!="number")return;const t=String(e);return t.length>0?t:void 0}function ve(){return{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function it(e){return Number.isFinite(e.minX)&&Number.isFinite(e.minY)&&Number.isFinite(e.maxX)&&Number.isFinite(e.maxY)&&e.maxX>=e.minX&&e.maxY>=e.minY}function W(e,t){C(t)&&(e.minX=Math.min(e.minX,t.x),e.minY=Math.min(e.minY,t.y),e.maxX=Math.max(e.maxX,t.x),e.maxY=Math.max(e.maxY,t.y))}function Lo(e,t,i){if(!C(t)||!Number.isFinite(i))return;const r=Math.abs(i);W(e,{x:t.x-r,y:t.y-r}),W(e,{x:t.x+r,y:t.y+r})}function Do(e,t=.02,i=1e-6){if(!it(e))return{minX:-10,minY:-10,maxX:10,maxY:10};const r=Math.max((e.maxX-e.minX)*t,i),s=Math.max((e.maxY-e.minY)*t,i);return{minX:e.minX-r,minY:e.minY-s,maxX:e.maxX+r,maxY:e.maxY+s}}function C(e){return!!e&&typeof e=="object"&&Number.isFinite(e.x)&&Number.isFinite(e.y)}function X(e){return{x:e.x,y:e.y}}function Oe(e){return e*Math.PI/180}function ci(e,t,i,r,s=!0,n=64){if(!C(e)||!Number.isFinite(t))return[];let a=i,o=r;if(!Number.isFinite(a)||!Number.isFinite(o))return[];(Math.abs(a)>Math.PI*2+1e-6||Math.abs(o)>Math.PI*2+1e-6)&&(a=Oe(a),o=Oe(o)),s&&o<a&&(o+=Math.PI*2),!s&&a<o&&(a+=Math.PI*2);const l=o-a,c=Math.max(8,Math.min(256,Math.ceil(Math.abs(l)/(Math.PI*2)*n))),d=[];for(let h=0;h<=c;h++){const u=a+l*(h/c);d.push({x:e.x+Math.cos(u)*t,y:e.y+Math.sin(u)*t})}return d}function di(e,t,i=1,r=0,s=Math.PI*2,n=96){if(!C(e)||!C(t))return[];const a=Math.hypot(t.x,t.y);if(!Number.isFinite(a)||a<=0)return[];const o=a*(Number.isFinite(i)&&i>0?i:1),l=Math.atan2(t.y,t.x);let c=Number.isFinite(r)?r:0,d=Number.isFinite(s)?s:Math.PI*2;(Math.abs(c)>Math.PI*2+1e-6||Math.abs(d)>Math.PI*2+1e-6)&&(c=Oe(c),d=Oe(d)),d<c&&(d+=Math.PI*2);const h=Math.max(12,Math.min(256,Math.ceil(Math.abs(d-c)/(Math.PI*2)*n))),u=[],f=Math.cos(l),p=Math.sin(l);for(let w=0;w<=h;w++){const m=c+(d-c)*(w/h),v=Math.cos(m)*a,g=Math.sin(m)*o;u.push({x:e.x+v*f-g*p,y:e.y+v*p+g*f})}return u}function Ro(e,t,i=0,r=16){if(!Number.isFinite(i)||Math.abs(i)<1e-12)return[X(e),X(t)];const s=Math.hypot(t.x-e.x,t.y-e.y);if(s<=1e-12)return[X(e),X(t)];const n=4*Math.atan(i),a=Math.abs(s/(2*Math.sin(n/2))),o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},l=(t.x-e.x)/s,c=(t.y-e.y)/s,d=i>=0?1:-1,h=Math.sqrt(Math.max(a*a-(s/2)**2,0)),u={x:o.x-d*c*h,y:o.y+d*l*h};return ci(u,a,Math.atan2(e.y-u.y,e.x-u.x),Math.atan2(t.y-u.y,t.x-u.x),i>=0,r)}function Bo(e){return e.replace(/\\P/g,`
|
|
89
|
+
`).replace(/\\~|\\ /g," ").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").replace(/\\[A-Za-z]/g,"").trim()}function rt(e,t,i){return Math.min(i,Math.max(t,e))}async function hu(e){const t=await Promise.resolve().then(()=>(eu(),Jh)),i=t.default??t.DxfParser;if(!i)throw new Error("dxf-parser did not expose a parser constructor.");return new i().parseSync(e)}function uu(e,t,i=[]){const r=e&&typeof e=="object"?e:{},s=fu(r),n=pu(r),a=(Array.isArray(r.entities)?r.entities:[]).filter(l=>!!l&&typeof l=="object").map(l=>Lr(l)),o=Io({format:"dxf",sourceName:t,header:r.header&&typeof r.header=="object"?r.header:{},layers:s,blocks:n,entities:a,metadata:{parser:"dxf-parser + cad-viewer normalizer"},warnings:i,raw:e});return a.length===0&&o.warnings.push("DXF file did not expose any ENTITIES."),o}function Lr(e){const t=String(e.type??e.entityType??"UNKNOWN").toUpperCase(),i=lu(e,t),r=O(e.colorIndex??e.colorNumber??e.aci),s=O(e.color);if(i.colorIndex=r??(s!==void 0&&Math.abs(s)<=257?s:void 0),i.trueColor=e.trueColor??e.true_color??e.colorRGB??e.trueColorValue??(s!==void 0&&Math.abs(s)>257?s:void 0),i.layer=ne(e.layer??e.layerName)??"0",i.isClosed=!!(e.shape??e.closed??e.isClosed)||(Number(e.flag??e.flags??0)&1)===1,t==="LINE"&&(i.startPoint=re(e.startPoint??{x:e.x1??e.x,y:e.y1??e.y,z:e.z1??e.z})??i.startPoint,i.endPoint=re(e.endPoint??{x:e.x2,y:e.y2,z:e.z2})??i.endPoint),(t==="TEXT"||t==="MTEXT"||t==="ATTRIB"||t==="ATTDEF")&&(i.insertionPoint=re(e.startPoint??e.position??e.insertionPoint)??i.insertionPoint,i.text=Eu(e.text??e.string??e.value)??i.text,i.textHeight=O(e.textHeight??e.height)??i.textHeight,i.rotation=Oo(e.rotation??e.angle)),(t==="ARC"||t==="ELLIPSE")&&(i.startAngle=zo(e.startAngle??e.start_angle),i.endAngle=zo(e.endAngle??e.end_angle)),t==="INSERT"){i.blockName=ne(e.name??e.blockName)??i.blockName,i.insertionPoint=re(e.position??e.insertionPoint??e.point)??i.insertionPoint;const n=O(e.xScale??e.scaleX??e.xscale),a=O(e.yScale??e.scaleY??e.yscale),o=O(e.zScale??e.scaleZ??e.zscale);(n!==void 0||a!==void 0||o!==void 0)&&(i.scale={x:n??1,y:a??n??1,z:o??1}),i.rotation=Oo(e.rotation??e.angle)}if(t==="SPLINE"){const n=hi(e.controlPoints??e.control_points??e.points);n.length&&(i.controlPoints=n);const a=hi(e.fitPoints??e.fit_points);a.length&&(i.fitPoints=a)}return t==="HATCH"&&(i.loops=bu(e),i.fillColorIndex=i.colorIndex),(t==="SOLID"||t==="TRACE"||t==="3DFACE")&&(i.vertices=gu(e),i.fillColorIndex=i.colorIndex),i}function fu(e){const t={},i=e.tables,r=mu(e.layers??i?.layer??i?.LAYER??i?.layers);for(const s of r){const n=s,a=ne(n.name??n.layerName);a&&_o(t,{name:a,color:n.color??n.colorNumber??n.colorIndex,colorIndex:O(n.colorNumber??n.colorIndex??n.color),lineType:ne(n.lineType??n.linetype),isVisible:Number(n.colorNumber??n.colorIndex??n.color??1)>=0,isFrozen:!!n.frozen,isLocked:!!n.locked,raw:n})}return t[0]||_o(t,{name:"0",colorIndex:7,isVisible:!0}),t}function pu(e){const t={},i=e.blocks;if(!i||typeof i!="object")return t;if(Array.isArray(i))for(const r of i)Wo(t,r);else for(const[r,s]of Object.entries(i))Wo(t,s,r);return t}function Wo(e,t,i){if(!t||typeof t!="object")return;const r=t,s=ne(r.name??r.blockName??i);if(!s)return;const n=(Array.isArray(r.entities)?r.entities:[]).filter(a=>!!a&&typeof a=="object").map(a=>Lr(a));cu(e,{name:s,basePoint:re(r.basePoint??r.position)??{x:0,y:0},entities:n,raw:r})}function mu(e){if(!e)return[];if(Array.isArray(e))return e;if(typeof e!="object")return[];const t=e;return Array.isArray(t.entries)?t.entries:Array.isArray(t.records)?t.records:Array.isArray(t.layers)?t.layers:Object.values(t).filter(i=>i&&typeof i=="object")}function hi(e){return Array.isArray(e)?e.map(re).filter(t=>!!t):[]}function gu(e){const t=hi(e.vertices??e.points);if(t.length)return t;const i=[];for(let r=0;r<4;r++){const s=re({x:e[`x${r}`]??e[`x${r+1}`],y:e[`y${r}`]??e[`y${r+1}`],z:e[`z${r}`]??e[`z${r+1}`]});s&&i.push(s)}return i}function bu(e){const t=e.boundaryLoops??e.loops??e.paths;if(Array.isArray(t))return t.map(i=>{const r=i;return{vertices:hi(r.vertices??r.points),isClosed:!0}}).filter(i=>i.vertices&&i.vertices.length>0)}function Oo(e){const t=O(e);if(t!==void 0)return Math.abs(t)>Math.PI*2+1e-6?Oe(t):t}function zo(e){const t=O(e);if(t!==void 0)return Math.abs(t)>Math.PI*2+1e-6?Oe(t):t}function wu(e,t){const i=Dr(t);if(i)return ze(e,i);const r=vu(e);if(r)return ze(e,r);const s=Dr(yu(e));if(s)return ze(e,s);const n=ze(e,"utf-8");return n.includes("�")?xu(e):n}function vu(e){if(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191)return"utf-8";if(e.length>=2&&e[0]===255&&e[1]===254)return"utf-16le";if(e.length>=2&&e[0]===254&&e[1]===255)return"utf-16be"}function yu(e){var t,i,r,s;const n=ze(e.subarray(0,Math.min(e.byteLength,131072)),"iso-8859-1").replace(/\r\n/g,`
|
|
90
|
+
`).replace(/\r/g,`
|
|
91
|
+
`).split(`
|
|
92
|
+
`);for(let a=0;a<n.length-3;a++)if(!(((t=n[a])==null?void 0:t.trim())!=="9"||((i=n[a+1])==null?void 0:i.trim().toUpperCase())!=="$DWGCODEPAGE"))for(let o=a+2;o<Math.min(a+10,n.length-1);o+=2){const l=(r=n[o])==null?void 0:r.trim(),c=(s=n[o+1])==null?void 0:s.trim();if(l==="3"&&c)return c}}function Dr(e){const t=e?.trim();if(!t)return;const i=t.replace(/[-\s]+/g,"_").toUpperCase();if(qr[i])return qr[i];const r=/^ANSI_(\d{3,4})$/.exec(i);if(r)return Dr(`cp${r[1]}`);const s=/^CP(\d{3,4})$/.exec(i);return s?s[1]==="936"?"gb18030":s[1]==="950"?"big5":s[1]==="932"?"shift_jis":s[1]==="949"?"euc-kr":`windows-${s[1]}`:t}function ze(e,t){try{return new TextDecoder(t,{fatal:!1}).decode(e)}catch{return new TextDecoder("utf-8",{fatal:!1}).decode(e)}}function xu(e){const t=["windows-1252","gb18030","big5","shift_jis","euc-kr","iso-8859-1"];let i="",r=Number.POSITIVE_INFINITY;for(const s of t){const n=ze(e,s),a=ku(n,s);a<r&&(r=a,i=n)}return i||ze(e,"utf-8")}function ku(e,t){const i=Rr(e,/\uFFFD/g),r=Rr(e,/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g),s=Rr(e,/[\u3400-\u9FFF\uF900-\uFAFF]/g),n=e.includes("SECTION")&&(e.includes("ENTITIES")||e.includes("HEADER"));let a=i*1e4+r*1e3;return n&&(a-=500),t==="windows-1252"&&(a-=2),t==="gb18030"&&s>=2&&(a-=50+Math.min(s,200)*2),a}function Rr(e,t){var i;return((i=e.match(t))==null?void 0:i.length)??0}function Eu(e){const t=ne(e);if(t!==void 0)return t.replace(/\\U\+([0-9a-fA-F]{4,6})/g,(i,r)=>{const s=Number.parseInt(r,16);return Number.isFinite(s)&&s>=0&&s<=1114111?String.fromCodePoint(s):i}).replace(/%%[cC]/g,"∅").replace(/%%[dD]/g,"°").replace(/%%[pP]/g,"±").replace(/\\P/g,`
|
|
93
|
+
`)}function Pu(e){var t,i;const r=e.replace(/\r\n/g,`
|
|
94
|
+
`).replace(/\r/g,`
|
|
95
|
+
`).split(`
|
|
96
|
+
`),s=[];for(let h=0;h<r.length-1;h+=2){const u=Number((t=r[h])==null?void 0:t.trim()),f=r[h+1]??"";Number.isFinite(u)&&s.push({code:u,value:f.trimEnd()})}const n=[],a={};let o="",l=[],c;for(let h=0;h<s.length;h++){const u=s[h];if(u.code===0&&u.value==="SECTION"){o=((i=s[h+1])==null?void 0:i.code)===2?s[h+1].value.toUpperCase():"",h++;continue}if(u.code===0&&u.value==="ENDSEC"){d(),o="";continue}o==="ENTITIES"&&(u.code===0?(d(),l=[u]):l.push(u))}return d(),{header:{},tables:{},entities:n,blocks:a};function d(){var h;if(!l.length)return;const u=(h=l[0])==null?void 0:h.value.toUpperCase();if(u==="VERTEX"&&c){const p=J(l,10,20,30);p&&(c.vertices??(c.vertices=[])).push({...p,bulge:B(l,42)}),l=[];return}if(u==="SEQEND"){c&&n.push(c),c=void 0,l=[];return}if(c&&(n.push(c),c=void 0),!u||u==="EOF"){l=[];return}const f=Su(u,l);u==="POLYLINE"?c=f:n.push(f),l=[]}}function Su(e,t){const i={type:e,handle:vt(t,5),layer:vt(t,8)??"0",colorIndex:B(t,62),trueColor:B(t,420),lineType:vt(t,6),lineweight:B(t,370)};switch(e){case"LINE":Object.assign(i,{startPoint:J(t,10,20,30),endPoint:J(t,11,21,31)});break;case"CIRCLE":Object.assign(i,{center:J(t,10,20,30),radius:B(t,40)});break;case"ARC":Object.assign(i,{center:J(t,10,20,30),radius:B(t,40),startAngle:ui(B(t,50)),endAngle:ui(B(t,51))});break;case"POINT":Object.assign(i,{point:J(t,10,20,30)});break;case"TEXT":case"MTEXT":Object.assign(i,{insertionPoint:J(t,10,20,30),text:Au(t),textHeight:B(t,40),rotation:ui(B(t,50))});break;case"LWPOLYLINE":Object.assign(i,{vertices:Mu(t),flag:B(t,70),isClosed:(Number(B(t,70)??0)&1)===1});break;case"POLYLINE":Object.assign(i,{vertices:[],flag:B(t,70),isClosed:(Number(B(t,70)??0)&1)===1});break;case"ELLIPSE":Object.assign(i,{center:J(t,10,20,30),majorAxisEndPoint:J(t,11,21,31),axisRatio:B(t,40),startAngle:B(t,41),endAngle:B(t,42)});break;case"SPLINE":Object.assign(i,{controlPoints:Cu(t,10,20,30),degree:B(t,71),isClosed:(Number(B(t,70)??0)&1)===1});break;case"INSERT":Object.assign(i,{name:vt(t,2),blockName:vt(t,2),insertionPoint:J(t,10,20,30),rotation:ui(B(t,50)),scale:{x:B(t,41)??1,y:B(t,42)??B(t,41)??1,z:B(t,43)??1}});break;case"SOLID":case"TRACE":case"3DFACE":Object.assign(i,{vertices:[J(t,10,20,30),J(t,11,21,31),J(t,12,22,32),J(t,13,23,33)].filter(Boolean)});break}return Lr(i)}function B(e,t){var i;const r=(i=e.find(n=>n.code===t))==null?void 0:i.value,s=Number(r);return Number.isFinite(s)?s:void 0}function vt(e,t){var i;const r=(i=e.find(s=>s.code===t))==null?void 0:i.value;return r&&r.length>0?r:void 0}function J(e,t,i,r){const s=B(e,t),n=B(e,i),a=B(e,r);if(!(s===void 0||n===void 0))return a===void 0?{x:s,y:n}:{x:s,y:n,z:a}}function Cu(e,t,i,r){const s=[];for(let n=0;n<e.length;n++){if(e[n].code!==t)continue;const a=Number(e[n].value),o=e.slice(n+1).find(h=>h.code===i),l=e.slice(n+1).find(h=>h.code===r),c=Number(o?.value),d=Number(l?.value);Number.isFinite(a)&&Number.isFinite(c)&&s.push(Number.isFinite(d)?{x:a,y:c,z:d}:{x:a,y:c})}return s}function Mu(e){const t=[];for(let i=0;i<e.length;i++){if(e[i].code!==10)continue;const r=Number(e[i].value);let s,n;for(let a=i+1;a<e.length&&e[a].code!==10;a++)e[a].code===20&&(s=Number(e[a].value)),e[a].code===42&&(n=Number(e[a].value));Number.isFinite(r)&&Number.isFinite(s)&&t.push({x:r,y:s,bulge:Number.isFinite(n)?n:void 0})}return t}function Au(e){const t=e.filter(i=>i.code===1||i.code===3).map(i=>i.value);return t.length?t.join(""):void 0}function ui(e){return typeof e=="number"&&Number.isFinite(e)?Oe(e):void 0}function Uo(e,t,i,r){var s,n;const a=$o(e?.diagnostics??[]),o=(e?.pageData??[]).map((c,d)=>Tu(c,d));for(const c of e?.pageData??[])a.push(...$o(c.diagnostics));const l={parser:"dwf-viewer",nativeRenderer:"dwf-viewer",dwfKind:e?.kind,packageEntries:((s=e?.packageEntries)==null?void 0:s.length)??0,resources:((n=e?.resources)==null?void 0:n.length)??0,pageKinds:Bu((e?.pageData??[]).map(c=>c.kind)),pageNames:(e?.pages??[]).map(c=>c.name)};return Io({format:i,sourceName:t,layers:{},blocks:{},pages:o,entities:du(o),metadata:l,warnings:Wu(a),raw:r?e:void 0})}function Tu(e,t){const i=Fu(e,t);return{index:t,name:e.name||e.sourcePath||`${t+1}`,width:e.width||1e3,height:e.height||1e3,entities:i}}function Fu(e,t){return e.kind==="w2d-text"?e.primitives.flatMap((i,r)=>Nu(i,t,r)):e.kind==="image"?[{type:"DWF_IMAGE_PAGE",kind:"image",pageIndex:t,width:e.width,height:e.height,imageSource:e.sourcePath}]:e.kind==="w3d-model"?e.model.meshes.map((i,r)=>({id:i.id,type:"W3D_MESH",kind:"solid",pageIndex:t,color:i.color?Ru(i.color):void 0,name:i.name||`mesh-${r+1}`,raw:{vertexCount:i.vertexCount,triangleCount:i.triangleCount,materialId:i.materialId}})):e.kind==="xps-fixed-page"?[{type:"XPS_FIXED_PAGE",kind:"viewport",pageIndex:t,width:e.width,height:e.height,raw:{sourcePath:e.sourcePath}}]:[{type:"DWF_PAGE",kind:"viewport",pageIndex:t,width:e.width,height:e.height,raw:{sourcePath:e.sourcePath}}]}function Nu(e,t,i){const r={id:`dwf-${t}-${i}`,pageIndex:t,color:e.stroke,fillColor:e.fill,lineweight:e.lineWidth,raw:{matrix:e.matrix}};if(e.type==="polyline"||e.type==="polygon")return[{...r,type:e.type==="polygon"?"DWF_POLYGON":"DWF_POLYLINE",kind:"polyline",vertices:Iu(e.points),isClosed:e.type==="polygon"}];if(e.type==="path")return[{...r,type:"DWF_PATH",kind:"path",commands:e.commands}];if(e.type==="text")return[{...r,type:"DWF_TEXT",kind:"text",insertionPoint:{x:e.x,y:e.y,z:0},text:e.text,textHeight:e.size}];if(e.type==="rect"){const s=e.x,n=e.y,a=e.width,o=e.height;return[{...r,type:"DWF_RECT",kind:"polyline",isClosed:!0,vertices:[{x:s,y:n,z:0},{x:s+a,y:n,z:0},{x:s+a,y:n+o,z:0},{x:s,y:n+o,z:0}]}]}return[]}function Iu(e){const t=[];for(let i=0;i+1<e.length;i+=2)t.push({x:e[i],y:e[i+1],z:0});return t}function $o(e){return e.filter(t=>t.level!=="info").map(t=>`${t.code}: ${t.message}${t.source?` (${t.source})`:""}`)}function Ho(e,t){return t==="dwf"||t==="dwfx"||t==="xps"?t:e==="dwf"||e==="dwfx"||e==="xps"?e:"dwf"}function _u(e){if(e.dwfWasmUrl)return e.dwfWasmUrl;if(typeof document>"u")return;const t=e.wasmPath?new URL(Du(e.wasmPath),document.baseURI).href:new URL("wasm/",document.baseURI).href;return new URL("dwfv-render.wasm",t).href}function Vo(e){if(e.dwfBackground)return e.dwfBackground;const t=e.canvasOptions;return t?.background??"#05070d"}function Lu(e,t,i){return{...Xo(e,t,i),maxDevicePixelRatio:e.dwfMaxDevicePixelRatio??2,maxCanvasPixels:e.dwfMaxCanvasPixels??16777216}}function Xo(e,t,i){return{wasmUrl:t,preferWebgl:e.dwfPreferWebgl??!0,preferWasm:e.dwfPreferWasm??!0,background:i,maxGpuCacheBytes:e.dwfMaxGpuCacheBytes??160*1024*1024,maxCachedScenes:e.dwfMaxCachedScenes??2,lineWeightMode:e.dwfLineWeightMode??"adaptive",minStrokeCssPx:e.dwfMinStrokeCssPx,maxOverviewStrokeCssPx:e.dwfMaxOverviewStrokeCssPx,minTextCssPx:e.dwfMinTextCssPx,minFilledAreaCssPx:e.dwfMinFilledAreaCssPx}}function fi(e,t,i){typeof i=="number"&&Number.isFinite(i)&&(e[t]=i)}function Du(e){return e.endsWith("/")?e:`${e}/`}function Ru(e){const[t,i,r]=e.map(s=>Math.max(0,Math.min(255,Math.round(s*255))));return`#${Br(t)}${Br(i)}${Br(r)}`}function Br(e){return e.toString(16).padStart(2,"0")}function Bu(e){const t={};for(const i of e)t[i]=(t[i]??0)+1;return t}function Wu(e){return Array.from(new Set(e))}function Ou(e={}){return new ol([new dl(e),new hl(e),new ul(e)])}function zu(e){const t=e;return t.nativeRenderer===!0&&typeof t.mount=="function"}function Ue(e,t="#ffffff",i=t){if(typeof e!="number"||Number.isNaN(e))return t;const r=Math.abs(Math.trunc(e));return r===0||r===256||r===257?t:r===7?i:fl[r]??t}function yt(e,t="rgb"){const i=Math.max(0,Math.trunc(e))&16777215,r=i>>16&255,s=i>>8&255,n=i&255;return`rgb(${t==="rgb"?r:n}, ${s}, ${t==="rgb"?n:r})`}function nt(e){if(typeof e=="string"){const t=e.trim();return t?/^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t)?Uu(t)??t:{red:"#ff0000",yellow:"#ffff00",green:"#00ff00",cyan:"#00ffff",blue:"#0000ff",magenta:"#ff00ff",white:"#ffffff",black:"#000000",grey:"#808080",gray:"#808080"}[t.toLowerCase()]:void 0}if(e&&typeof e=="object"){const t=e,i=Number(t.r??t.red),r=Number(t.g??t.green),s=Number(t.b??t.blue),n=Number(t.a??t.alpha??1);if([i,r,s].every(Number.isFinite))return Number.isFinite(n)&&n>=0&&n<1?`rgba(${i}, ${r}, ${s}, ${n})`:`rgb(${i}, ${r}, ${s})`}}function Uu(e){if(!e)return;const t=e.trim();if(/^#[0-9a-f]{8}$/i.test(t)){const i=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16),s=parseInt(t.slice(5,7),16),n=parseInt(t.slice(7,9),16);return i>=.999?`rgb(${r}, ${s}, ${n})`:`rgba(${r}, ${s}, ${n}, ${$r(i)})`}if(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t))return t;if(/^sc#/i.test(t)){const i=t.slice(3).split(",").map(o=>Number(o.trim())),[r,s,n,a]=i.length===4?i:[1,...i];if([r,s,n,a].every(Number.isFinite))return`rgba(${Math.round(s*255)}, ${Math.round(n*255)}, ${Math.round(a*255)}, ${$r(r)})`}}function st(e,t,i={}){const r=i.foreground??"#ffffff",s=r;let n;const a=nt(e.trueColor)??nt(e.color)??nt(e.colorName);if(a&&(n=a),!n){const o=Yu(e,["trueColor","true_color","truecolor","colorRGB","colorRgb","rgbColor","rgb"]);typeof o=="number"&&o>=0&&o<=16777215&&(n=yt(o,i.trueColorByteOrder??"rgb"))}if(!n){const o=qo(e.colorIndex,e.colorNumber,e.aci);typeof o=="number"&&Math.abs(o)<=257&&o!==256&&o!==0&&o!==257&&(n=Ue(o,s,r))}if(!n&&typeof e.color=="number"){const o=Number(e.color);Math.abs(o)<=257?o!==0&&o!==256&&o!==257&&(n=Ue(o,s,r)):n=yt(o,i.trueColorByteOrder??"rgb")}return n||(n=Hu(Gu(t,e.layer),i)),Go(n??s,i)}function Wr(e,t,i={}){let r;const s=nt(e.fillColor);if(s&&(r=s),!r&&typeof e.fillColor=="number"){const n=e.fillColor;r=Math.abs(n)<=257?Ue(n,i.foreground??"#ffffff",i.foreground??"#ffffff"):yt(n,i.trueColorByteOrder??"rgb")}return!r&&typeof e.fillColorIndex=="number"&&(r=Ue(e.fillColorIndex,i.foreground??"#ffffff",i.foreground??"#ffffff")),r?Go(r,i):void 0}function Go(e,t={}){return t.contrastMode!=="adaptive"?e:$u(e,t.background??"#0b1020",t.foreground??"#ffffff",t.minColorContrast??2.4)}function $u(e,t,i,r=2.4){const s=Or(i)??{r:255,g:255,b:255,a:1},n=Or(t)??{r:11,g:16,b:32,a:1},a=Or(e);if(!a||Ur(Zo(a,n),n)>=r)return e;const o=zr(n),l=o<.5?{r:255,g:255,b:255,a:a.a}:{r:0,g:0,b:0,a:a.a};for(const c of[.25,.4,.55,.7,.85,1]){const d=ju(a,l,c);if(Ur(Zo(d,n),n)>=r)return Ko(d)}return Ur(s,n)>=r?Ko(s):o<.5?"#ffffff":"#000000"}function Yo(e){return e?e.isVisible!==!1&&e.isFrozen!==!0:!0}function Hu(e,t){if(!e)return;const i=t.foreground??"#ffffff",r=nt(e.trueColor);if(r)return r;if(typeof e.trueColor=="number"&&e.trueColor>=0&&e.trueColor<=16777215)return yt(e.trueColor,t.trueColorByteOrder??"rgb");const s=nt(e.color);if(s)return s;if(Xu(e.colorIndex))return Ue(e.colorIndex,i,i);if(typeof e.color=="number"){const n=Number(e.color);return Math.abs(n)<=257?Ue(n,i,i):yt(n,t.trueColorByteOrder??"rgb")}if(typeof e.colorIndex=="number")return Ue(e.colorIndex,i,i)}function Vu(e){return qo(e.colorIndex,e.colorNumber,e.aci)===0?!0:e.trueColor===void 0&&e.color===0}function jo(e,t,i,r={}){if(!Vu(e))return e;const s=st(t,i,r);return{...e,color:s,trueColor:void 0,colorIndex:void 0,colorNumber:void 0}}function Xu(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(Math.trunc(e))>=1&&Math.abs(Math.trunc(e))<=255}function Gu(e,t){if(!(!e||!t))return e.layers[t]??e.layers[t.toLowerCase()]??Object.values(e.layers).find(i=>i.name.toLowerCase()===t.toLowerCase())}function qo(...e){for(const t of e)if(typeof t=="number"&&Number.isFinite(t))return t}function Yu(e,t){const i=e;for(const r of t){const s=i[r];if(typeof s=="number"&&Number.isFinite(s))return s}}function Or(e){const t=e.trim().toLowerCase();if(/^#[0-9a-f]{3}$/i.test(t))return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1};if(/^#[0-9a-f]{6}$/i.test(t))return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1};const i=t.match(/^rgba?\(([^)]+)\)$/i);if(i){const r=i[1].split(/[,\s/]+/).filter(Boolean).map(s=>Number(s.replace("%","")));if(r.length>=3&&r.slice(0,3).every(Number.isFinite)){const s=/%/.test(i[1]);return{r:at(s?r[0]*2.55:r[0]),g:at(s?r[1]*2.55:r[1]),b:at(s?r[2]*2.55:r[2]),a:Number.isFinite(r[3])?Math.max(0,Math.min(1,r[3])):1}}}}function Zo(e,t){const i=e.a+t.a*(1-e.a);return i<=0?{r:0,g:0,b:0,a:0}:{r:(e.r*e.a+t.r*t.a*(1-e.a))/i,g:(e.g*e.a+t.g*t.a*(1-e.a))/i,b:(e.b*e.a+t.b*t.a*(1-e.a))/i,a:i}}function ju(e,t,i){const r=Math.max(0,Math.min(1,i));return{r:e.r+(t.r-e.r)*r,g:e.g+(t.g-e.g)*r,b:e.b+(t.b-e.b)*r,a:e.a}}function zr(e){const t=[e.r,e.g,e.b].map(i=>{const r=i/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4});return .2126*t[0]+.7152*t[1]+.0722*t[2]}function Ur(e,t){const i=zr(e),r=zr(t),s=Math.max(i,r),n=Math.min(i,r);return(s+.05)/(n+.05)}function Ko(e){const t=at(e.r),i=at(e.g),r=at(e.b);return e.a<.999?`rgba(${t}, ${i}, ${r}, ${$r(e.a)})`:`rgb(${t}, ${i}, ${r})`}function at(e){return Math.max(0,Math.min(255,Math.round(e)))}function $r(e){return Math.round(e*1e3)/1e3}function Hr(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}}function Qo(e,t){return{a:1,b:0,c:0,d:1,e,f:t}}function qu(e){const t=Math.cos(e),i=Math.sin(e);return{a:t,b:i,c:-i,d:t,e:0,f:0}}function Zu(e,t=e){return{a:e,b:0,c:0,d:t,e:0,f:0}}function de(e,t){return{x:e.x*t.a+e.y*t.c+t.e,y:e.x*t.b+e.y*t.d+t.f,z:"z"in e?e.z:void 0}}function Jo(e,t){if(e)return e.map(i=>({cmd:i.cmd,points:i.points.map(r=>de(r,t))}))}function pi(e,t={x:0,y:0}){const i=e.insertionPoint??{x:0,y:0},r=e.scale,s=Number(typeof r=="object"&&r?r.x??1:e.scaleX??1),n=Number(typeof r=="object"&&r?r.y??s:e.scaleY??s),a=Number(e.rotation??0);let o=Qo(i.x,i.y);return o=Hr(o,qu(Number.isFinite(a)?a:0)),o=Hr(o,Zu(Number.isFinite(s)?s:1,Number.isFinite(n)?n:1)),o=Hr(o,Qo(-t.x,-t.y)),o}function mi(e,t){const i={...e,raw:e.raw??e};if(e.startPoint&&(i.startPoint=de(e.startPoint,t)),e.endPoint&&(i.endPoint=de(e.endPoint,t)),e.center&&(i.center=de(e.center,t)),e.insertionPoint&&(i.insertionPoint=de(e.insertionPoint,t)),e.majorAxisEndPoint){const s=de({x:0,y:0},t),n=de(e.majorAxisEndPoint,t);i.majorAxisEndPoint={x:n.x-s.x,y:n.y-s.y,z:n.z}}e.vertices&&(i.vertices=e.vertices.map(s=>({...de(s,t),bulge:s.bulge,startWidth:s.startWidth,endWidth:s.endWidth}))),e.points&&(i.points=e.points.map(s=>de(s,t))),e.controlPoints&&(i.controlPoints=e.controlPoints.map(s=>de(s,t))),e.fitPoints&&(i.fitPoints=e.fitPoints.map(s=>de(s,t))),e.commands&&(i.commands=Jo(e.commands,t)),e.loops&&(i.loops=e.loops.map(s=>{var n;return{...s,vertices:(n=s.vertices)==null?void 0:n.map(a=>de(a,t)),commands:Jo(s.commands,t)}}));const r=Math.sqrt(Math.abs(t.a*t.d-t.b*t.c));return typeof e.radius=="number"&&Number.isFinite(r)&&(i.radius=e.radius*r),i}function Ku(e){return{total:e.total,drawn:e.drawn,skipped:e.skipped,byType:{...e.byType},unsupported:{...e.unsupported},renderElapsedMs:e.renderElapsedMs,backend:e.backend,primitiveCount:e.primitiveCount,visiblePrimitiveCount:e.visiblePrimitiveCount,culledPrimitiveCount:e.culledPrimitiveCount,gpuMemoryBytes:e.gpuMemoryBytes,buildElapsedMs:e.buildElapsedMs}}function el(){if(typeof document>"u")return!1;const e=document.createElement("canvas");return!!(e.getContext("webgl2")??e.getContext("webgl")??e.getContext("experimental-webgl"))}function Qu(e,t){const i={alpha:!1,antialias:t.antialias??!0,depth:!1,stencil:!1,preserveDrawingBuffer:t.preserveDrawingBuffer??!1,powerPreference:t.powerPreference??"high-performance"};return e.getContext("webgl2",i)??e.getContext("webgl",i)??e.getContext("experimental-webgl",i)??void 0}function Ju(e){const t=`
|
|
97
|
+
attribute vec2 a_position;
|
|
98
|
+
attribute vec4 a_color;
|
|
99
|
+
uniform vec2 u_viewCenter;
|
|
100
|
+
uniform float u_scale;
|
|
101
|
+
uniform vec2 u_viewport;
|
|
102
|
+
uniform float u_pointSize;
|
|
103
|
+
varying vec4 v_color;
|
|
104
|
+
void main() {
|
|
105
|
+
vec2 screen = vec2(
|
|
106
|
+
u_viewport.x * 0.5 + (a_position.x - u_viewCenter.x) * u_scale,
|
|
107
|
+
u_viewport.y * 0.5 - (a_position.y - u_viewCenter.y) * u_scale
|
|
108
|
+
);
|
|
109
|
+
vec2 clip = vec2(screen.x / u_viewport.x * 2.0 - 1.0, 1.0 - screen.y / u_viewport.y * 2.0);
|
|
110
|
+
gl_Position = vec4(clip, 0.0, 1.0);
|
|
111
|
+
gl_PointSize = u_pointSize;
|
|
112
|
+
v_color = a_color;
|
|
113
|
+
}
|
|
114
|
+
`,i=`
|
|
115
|
+
precision mediump float;
|
|
116
|
+
varying vec4 v_color;
|
|
117
|
+
void main() {
|
|
118
|
+
gl_FragColor = v_color;
|
|
119
|
+
}
|
|
120
|
+
`,r=tl(e,e.VERTEX_SHADER,t),s=tl(e,e.FRAGMENT_SHADER,i),n=e.createProgram();if(!n)throw new Error("Failed to create WebGL program.");if(e.attachShader(n,r),e.attachShader(n,s),e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS)){const d=e.getProgramInfoLog(n)??"Unknown WebGL program link error.";throw e.deleteProgram(n),new Error(d)}e.deleteShader(r),e.deleteShader(s);const a=e.getUniformLocation(n,"u_viewCenter"),o=e.getUniformLocation(n,"u_scale"),l=e.getUniformLocation(n,"u_viewport"),c=e.getUniformLocation(n,"u_pointSize");if(!a||!o||!l||!c)throw new Error("Failed to resolve WebGL shader uniforms.");return{program:n,aPosition:e.getAttribLocation(n,"a_position"),aColor:e.getAttribLocation(n,"a_color"),uViewCenter:a,uScale:o,uViewport:l,uPointSize:c}}function tl(e,t,i){const r=e.createShader(t);if(!r)throw new Error("Failed to create WebGL shader.");if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){const s=e.getShaderInfoLog(r)??"Unknown WebGL shader compile error.";throw e.deleteShader(r),new Error(s)}return r}function ef(e,t){let i=0;const r=o=>o.map(l=>{const c=il(e,l.positions),d=il(e,l.colors),h=l.positions.byteLength+l.colors.byteLength;return i+=h,{positionBuffer:c,colorBuffer:d,vertexCount:l.positions.length/2,primitiveCount:l.primitiveCount,bounds:l.bounds,gpuBytes:h}}),s=r(t.lineBatches),n=r(t.triangleBatches),a=r(t.pointBatches);return{origin:t.origin,lineBatches:s,triangleBatches:n,pointBatches:a,textItems:t.textItems,imageItems:t.imageItems,stats:t.stats,primitiveCount:t.primitiveCount,gpuMemoryBytes:i,buildElapsedMs:t.buildElapsedMs}}function il(e,t){const i=e.createBuffer();if(!i)throw new Error("Failed to create WebGL buffer.");return e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),i}function tf(e,t,i){const r=performance.now(),s=new gl(e,t,i,it(i)?{x:(i.minX+i.maxX)/2,y:(i.minY+i.maxY)/2}:{x:0,y:0});for(const a of e.entities)s.addEntityTracked(a,0);const n=s.finalize();return n.buildElapsedMs=performance.now()-r,n}function rf(){return{positions:[],colors:[],bounds:ve(),primitiveCount:0}}function ot(e,t,i,r){e.positions.push(t.x-r.x,t.y-r.y),e.colors.push(i[0],i[1],i[2],i[3])}function Vr(e,t){const i=[];for(const r of e.values()){const s=r.positions.length/2;if(s<=0||!it(r.bounds))continue;if(s<=t){i.push({positions:new Float32Array(r.positions),colors:new Uint8Array(r.colors),bounds:{...r.bounds},primitiveCount:r.primitiveCount});continue}const n=nf(r),a=Math.max(n,Math.floor(t/n)*n);for(let o=0;o<s;o+=a){const l=Math.min(s,o+a),c=r.positions.slice(o*2,l*2),d=r.colors.slice(o*4,l*4),h=ve();for(let u=0;u<c.length;u+=2)W(h,{x:c[u],y:c[u+1]});i.push({positions:new Float32Array(c),colors:new Uint8Array(d),bounds:{...r.bounds},primitiveCount:Math.floor((l-o)/n)})}}return i}function nf(e){const t=e.positions.length/2;return t===e.primitiveCount?1:t===e.primitiveCount*3?3:2}function sf(e,t){var i;const r=ve();if((i=e.pages)!=null&&i.length)for(const a of e.pages)W(r,{x:0,y:0}),W(r,{x:a.width,y:a.height});const s=a=>{if(a)return e.blocks[a]??e.blocks[a.toLowerCase()]??Object.values(e.blocks).find(o=>o.name.toLowerCase()===a.toLowerCase())},n=(a,o)=>{const l=String(a.type??"").toUpperCase(),c=a.kind??tt(l);if(c==="insert"){const d=s(a.blockName??a.name);if(d&&o<t.maxInsertDepth){const h=pi(a,d.basePoint??{x:0,y:0});for(const u of d.entities)n(mi(u,h),o+1);return}}if(c==="line")C(a.startPoint)&&W(r,a.startPoint),C(a.endPoint)&&W(r,a.endPoint);else if(c==="circle"||c==="arc")C(a.center)&&Number.isFinite(a.radius)&&Lo(r,a.center,Number(a.radius));else if(c==="polyline"||c==="solid"||c==="spline")for(const d of[...a.vertices??[],...a.points??[],...a.controlPoints??[],...a.fitPoints??[]])C(d)&&W(r,d);else if(c==="ellipse")C(a.center)&&C(a.majorAxisEndPoint)&&di(a.center,a.majorAxisEndPoint,Number(a.axisRatio??1),Number(a.startAngle??0),Number(a.endAngle??Math.PI*2),t.maxCurveSegments).forEach(d=>W(r,d));else if(c==="path")for(const d of a.commands??[])for(const h of d.points)W(r,h);else if(c==="hatch")for(const d of a.loops??[]){for(const h of d.vertices??[])W(r,h);for(const h of d.commands??[])for(const u of h.points)W(r,u)}else{const d=nl(a);d&&W(r,d)}};for(const a of e.entities)n(a,0);return Do(r)}function rl(e,t){const i=[];let r,s;const n=a=>{(!i.length||Math.hypot(i[i.length-1].x-a.x,i[i.length-1].y-a.y)>1e-12)&&i.push(X(a)),r=X(a)};for(const a of e)if(a.cmd==="M")r=X(a.points[0]),s=r,n(r);else if(a.cmd==="L")n(a.points[0]);else if(a.cmd==="Q"&&r&&a.points.length>=2){const o=r,[l,c]=a.points,d=Math.max(4,Math.min(t,24));for(let h=1;h<=d;h++){const u=h/d,f=1-u;n({x:f*f*o.x+2*f*u*l.x+u*u*c.x,y:f*f*o.y+2*f*u*l.y+u*u*c.y})}}else if(a.cmd==="C"&&r&&a.points.length>=3){const o=r,[l,c,d]=a.points,h=Math.max(6,Math.min(t,32));for(let u=1;u<=h;u++){const f=u/h,p=1-f;n({x:p**3*o.x+3*p*p*f*l.x+3*p*f*f*c.x+f**3*d.x,y:p**3*o.y+3*p*p*f*l.y+3*p*f*f*c.y+f**3*d.y})}}else a.cmd==="Z"&&s&&n(s);return i}function nl(e){for(const t of["startPoint","insertionPoint","center","point","location"]){const i=e[t];if(C(i))return X(i)}if(Array.isArray(e.vertices)&&C(e.vertices[0]))return X(e.vertices[0]);if(Array.isArray(e.commands)&&e.commands.length){const t=e.commands.find(i=>i.points.length>0);if(t)return X(t.points[0])}}function Xr(e){const t=ve();for(const i of e)W(t,i);return t}function af(e){return{minX:e.x,minY:e.y,maxX:e.x,maxY:e.y}}function Gr(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function of(e,t){return t.trueColorByteOrder!==void 0&&t.trueColorByteOrder!==e.trueColorByteOrder||t.contrastMode!==void 0&&t.contrastMode!==e.contrastMode||t.minColorContrast!==void 0&&t.minColorContrast!==e.minColorContrast||t.foreground!==void 0&&t.foreground!==e.foreground||t.background!==void 0&&t.background!==e.background||t.maxInsertDepth!==void 0&&t.maxInsertDepth!==e.maxInsertDepth||t.maxCurveSegments!==void 0&&t.maxCurveSegments!==e.maxCurveSegments||t.spatialIndexCellCount!==void 0&&t.spatialIndexCellCount!==e.spatialIndexCellCount||t.maxVerticesPerBatch!==void 0&&t.maxVerticesPerBatch!==e.maxVerticesPerBatch||t.enableSpatialIndex!==void 0&&t.enableSpatialIndex!==e.enableSpatialIndex}function lf(e,t){return{...e.stats,renderElapsedMs:t,backend:"webgl",primitiveCount:e.primitiveCount,visiblePrimitiveCount:0,culledPrimitiveCount:0,gpuMemoryBytes:e.gpuMemoryBytes,buildElapsedMs:e.buildElapsedMs}}function cf(e){return{total:e.total,drawn:e.drawn,skipped:e.skipped,byType:{...e.byType},unsupported:{...e.unsupported},renderElapsedMs:e.renderElapsedMs,backend:e.backend,primitiveCount:e.primitiveCount,visiblePrimitiveCount:e.visiblePrimitiveCount,culledPrimitiveCount:e.culledPrimitiveCount,gpuMemoryBytes:e.gpuMemoryBytes,buildElapsedMs:e.buildElapsedMs}}function Yr(e,t,i=1){const r=e.trim().toLowerCase();let s;if(/^#[0-9a-f]{3}$/i.test(r))s=[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16),255];else if(/^#[0-9a-f]{6}$/i.test(r))s=[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16),255];else{const a=r.match(/^rgba?\(([^)]+)\)$/i);if(a){const o=a[1].split(/[\s,\/]+/).filter(Boolean),l=o.slice(0,3).some(d=>d.includes("%")),c=o.map(d=>Number(d.replace("%","")));c.length>=3&&c.slice(0,3).every(Number.isFinite)&&(s=[xt(l?c[0]*2.55:c[0]),xt(l?c[1]*2.55:c[1]),xt(l?c[2]*2.55:c[2]),xt((Number.isFinite(c[3])?c[3]:1)*255)])}}const n=s??t;return[n[0],n[1],n[2],xt(n[3]*i)]}function xt(e){return Math.max(0,Math.min(255,Math.round(e)))}function df(e){return e instanceof Error?e:new Error(String(e))}function jr(e){if(e!=null&&e.aborted)throw new DOMException("Loading cancelled.","AbortError")}function hf(e,t,i={}){if(e==="canvas2d")return new Zr(t,i);if(e==="webgl")return new Kr(t,i);if(el())try{return new Kr(t,i)}catch{}return new Zr(t,i)}var sl,al,P,ol,ll,cl,dl,hl,qr,ul,fl,pl,Zr,ml,Kr,gl,bl,uf=E((()=>{Sh(),sl=Object.defineProperty,al=(e,t,i)=>t in e?sl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t,i)=>al(e,typeof t!="symbol"?t+"":t,i),ol=class{constructor(e=[]){P(this,"loaders",[]);for(const t of e)this.register(t)}register(e){const t=this.loaders.findIndex(i=>i.id===e.id);return t>=0?this.loaders.splice(t,1,e):this.loaders.push(e),this}unregister(e){const t=this.loaders.findIndex(i=>i.id===e);return t>=0&&this.loaders.splice(t,1),this}list(){return[...this.loaders]}async detect(e){const t=await wt(e),i=et(e,t),r=this.loaders.find(n=>n.formats.includes(i)&&n.accepts(e,t));if(r)return{loader:r,bytes:t,format:i};const s=this.loaders.find(n=>n.accepts(e,t));if(s)return{loader:s,bytes:t,format:i};throw new Error(`No CAD loader registered for ${i==="unknown"?"this file":i.toUpperCase()}.`)}async load(e,t={}){const{loader:i,bytes:r}=await this.detect(e);return i.load({...e,buffer:r},t)}},ll="wasm/dwg-worker.js",cl=class{constructor(){P(this,"worker"),P(this,"sequence",0),P(this,"pending",new Map)}load(e,t,i={}){var r,s;if(!Nr())throw new Error("Web Worker is not available in this runtime.");const n=this.ensureWorker(i),a=++this.sequence,o=Math.max(0,Number(i.workerTimeoutMs??0)),l=i.fileName??t.fileName??((r=t.file)==null?void 0:r.name),c=ru(e,t,i);return(s=i.onProgress)==null||s.call(i,{phase:"worker-start",format:"dwg",message:"Dispatching DWG parse to worker…",total:e.byteLength}),new Promise((d,h)=>{var u;if((u=i.signal)!=null&&u.aborted){h(oi());return}const f={resolve:d,reject:h,onProgress:i.onProgress,signal:i.signal};o>0&&(f.timer=setTimeout(()=>{this.pending.delete(a),this.resetWorker(),h(new Error(`DWG worker timed out after ${o} ms.`))},o)),i.signal&&(f.abortHandler=()=>{this.pending.delete(a),this.resetWorker(),h(oi())},i.signal.addEventListener("abort",f.abortHandler,{once:!0})),this.pending.set(a,f);try{n.postMessage({type:"load",requestId:a,bytes:c,fileName:l,options:To(i)},[c])}catch(p){this.pending.delete(a),ai(f),h(p instanceof Error?p:new Error(String(p)))}})}preload(e={}){var t;if(!Nr())return Promise.reject(new Error("Web Worker is not available in this runtime."));const i=this.ensureWorker(e),r=++this.sequence,s=Math.max(0,Number(e.workerTimeoutMs??0));return(t=e.onProgress)==null||t.call(e,{phase:"worker-start",format:"dwg",message:"Starting DWG worker warmup…"}),new Promise((n,a)=>{var o;if((o=e.signal)!=null&&o.aborted){a(oi());return}const l={resolve:()=>n(),reject:a,onProgress:e.onProgress,signal:e.signal};s>0&&(l.timer=setTimeout(()=>{this.pending.delete(r),this.resetWorker(),a(new Error(`DWG worker warmup timed out after ${s} ms.`))},s)),e.signal&&(l.abortHandler=()=>{this.pending.delete(r),this.resetWorker(),a(oi())},e.signal.addEventListener("abort",l.abortHandler,{once:!0})),this.pending.set(r,l);try{i.postMessage({type:"warmup",requestId:r,options:To(e)})}catch(c){this.pending.delete(r),ai(l),a(c instanceof Error?c:new Error(String(c)))}})}terminate(){this.resetWorker()}ensureWorker(e){return this.worker||(this.worker=iu(e),this.worker.onmessage=t=>this.handleMessage(t.data),this.worker.onerror=t=>{const i=t.message||"DWG worker failed.";this.rejectAll(new Error(i)),this.resetWorker(!1)},this.worker.onmessageerror=()=>{this.rejectAll(new Error("DWG worker returned a message that could not be cloned.")),this.resetWorker(!1)}),this.worker}handleMessage(e){var t,i;if(e.type==="ready")return;const r=this.pending.get(e.requestId);if(!r)return;if(e.type==="progress"){(t=r.onProgress)==null||t.call(r,e.progress);return}if(this.pending.delete(e.requestId),ai(r),e.type==="result"){r.resolve(e.result);return}if(e.type==="warmup-result"){(i=r.onProgress)==null||i.call(r,{phase:"worker-ready",format:"dwg",message:"DWG worker warmup complete.",percent:100,elapsedMs:e.elapsedMs}),r.resolve(void 0);return}const s=new Error(e.error.message);s.name=e.error.name||"DwgWorkerError",e.error.stack&&(s.stack=e.error.stack),r.reject(s)}rejectAll(e){for(const[,t]of this.pending)ai(t),t.reject(e);this.pending.clear()}resetWorker(e=!0){var t;e&&this.rejectAll(new Error("DWG worker was terminated.")),(t=this.worker)==null||t.terminate(),this.worker=void 0}},dl=class{constructor(e={}){P(this,"id","dwg"),P(this,"label","DWG / LibreDWG WebAssembly"),P(this,"formats",["dwg"]),P(this,"defaults"),P(this,"workerClient",new cl),this.defaults={useWorker:!0,...e}}accepts(e,t){return Je(e)==="dwg"?!0:et(e,t)==="dwg"}async load(e,t={}){var i,r;const s={...this.defaults,...t};(i=s.onProgress)==null||i.call(s,{phase:"read",format:"dwg",message:"Reading DWG bytes…"});const n=await wt(e),a=e.fileName??((r=e.file)==null?void 0:r.name);if(s.useWorker===!1)throw new Error("DWG main-thread parsing is intentionally not bundled by the default viewer. Keep useWorker enabled, or register a custom DWG loader for non-browser runtimes.");if(!Nr())throw new Error("DWG loading requires Web Worker support in this build. Provide a custom loader for this runtime.");try{return await this.workerClient.load(n,e,{...s,fileName:a})}catch(o){throw au(o)?o:ou(o)}}terminateWorker(){this.workerClient.terminate()}preload(e={}){const t={...this.defaults,...e};return t.useWorker===!1?Promise.reject(new Error("DWG preload requires worker mode in the default viewer.")):this.workerClient.preload(t)}},hl=class{constructor(e={}){P(this,"id","dxf"),P(this,"label","DXF / JavaScript parser"),P(this,"formats",["dxf"]),P(this,"defaults"),this.defaults=e}accepts(e,t){return Je(e)==="dxf"||et(e,t)==="dxf"}async load(e,t={}){var i;const r={...this.defaults,...t},s=performance.now(),n=await wt(e),a=wu(n,r.dxfEncoding),o=[];let l;try{l=await hu(a)}catch(h){o.push(`dxf-parser failed, using built-in fallback parser: ${h instanceof Error?h.message:String(h)}`),l=Pu(a)}const c=uu(l,e.fileName??((i=e.file)==null?void 0:i.name),o),d=performance.now()-s;return{document:c,raw:l,bytes:n.byteLength,elapsedMs:d,format:"dxf",warnings:c.warnings}}},qr={ANSI_874:"windows-874",ANSI_932:"shift_jis",ANSI_936:"gb18030",ANSI_949:"euc-kr",ANSI_950:"big5",ANSI_1250:"windows-1250",ANSI_1251:"windows-1251",ANSI_1252:"windows-1252",ANSI_1253:"windows-1253",ANSI_1254:"windows-1254",ANSI_1255:"windows-1255",ANSI_1256:"windows-1256",ANSI_1257:"windows-1257",ANSI_1258:"windows-1258",BIG5:"big5",CP874:"windows-874",CP932:"shift_jis",CP936:"gb18030",CP949:"euc-kr",CP950:"big5",CP1250:"windows-1250",CP1251:"windows-1251",CP1252:"windows-1252",CP1253:"windows-1253",CP1254:"windows-1254",CP1255:"windows-1255",CP1256:"windows-1256",CP1257:"windows-1257",CP1258:"windows-1258",GB18030:"gb18030",GB2312:"gb18030",GBK:"gb18030",SHIFT_JIS:"shift_jis",SHIFTJIS:"shift_jis",SJIS:"shift_jis",UTF8:"utf-8",UTF_8:"utf-8",UTF16:"utf-16le",UTF_16:"utf-16le",UTF16LE:"utf-16le",UTF_16LE:"utf-16le",UTF16BE:"utf-16be",UTF_16BE:"utf-16be"},ul=class{constructor(e={}){P(this,"id","dwf"),P(this,"label","DWF/DWFx native viewer powered by dwf-viewer"),P(this,"formats",["dwf","dwfx","xps"]),P(this,"nativeRenderer",!0),P(this,"defaults"),P(this,"native"),P(this,"host"),P(this,"lastStats"),this.defaults=e}accepts(e,t){const i=Je(e);if(i==="dwf"||i==="dwfx"||i==="xps")return!0;const r=et(e,t);return r==="dwf"||r==="dwfx"||r==="xps"}async load(e,t={}){var i,r,s,n;const a={...this.defaults,...t},o=performance.now(),l=e.fileName??((i=e.file)==null?void 0:i.name),c=await wt(e),d=Ho(et(e,c),Je(e));(r=a.onProgress)==null||r.call(a,{phase:"parse",format:d,message:"Opening DWF/DWFx with dwf-viewer…",percent:48});const h=await ma(c,{fileName:l});(s=a.onProgress)==null||s.call(a,{phase:"normalize",format:d,message:"Reading DWF pages, sheets and model metadata…",percent:76});const u=Uo(h,l,d,a.keepRaw===!0),f=performance.now()-o;return(n=a.onProgress)==null||n.call(a,{phase:"done",format:u.format,message:"DWF/DWFx document ready.",percent:100,elapsedMs:f}),{document:u,raw:a.keepRaw?h:void 0,bytes:c.byteLength,elapsedMs:f,format:u.format,warnings:u.warnings}}async mount(e,t,i={}){var r,s,n,a,o;const l={...this.defaults,...i},c=performance.now(),d=e.fileName??((r=e.file)==null?void 0:r.name),h=await wt(e),u=Ho(et(e,h),Je(e)),f=_u(l),p=Vo(l),w=Lu(l,f,p),m=Xo(l,f,p);(s=l.onProgress)==null||s.call(l,{phase:"native-render",format:u,message:"Mounting native DWF renderer…",percent:28}),this.unmount(),this.host=t,t.replaceChildren(),this.native=new so(t,w),(n=l.onProgress)==null||n.call(l,{phase:"parse",format:u,message:"Parsing DWF package and page streams…",percent:58}),await this.native.load(h,{fileName:d,...m}),(a=l.onProgress)==null||a.call(l,{phase:"render",format:u,message:"Rendering DWF/DWFx with dwf-viewer…",percent:88}),this.lastStats=await this.native.render();const v=this.native.getDocument(),g=Uo(v,d,u,l.keepRaw===!0);g.metadata.loaderMode="Native DWF",g.metadata.nativeRenderer="dwf-viewer",g.metadata.nativeRenderStats=this.lastStats?{...this.lastStats,warnings:this.lastStats.warnings.length}:void 0;const x=performance.now()-c;return(o=l.onProgress)==null||o.call(l,{phase:"done",format:g.format,message:"DWF/DWFx rendered.",percent:100,elapsedMs:x}),{document:g,raw:l.keepRaw?v:void 0,bytes:h.byteLength,elapsedMs:x,format:g.format,warnings:g.warnings}}unmount(){var e;(e=this.native)==null||e.dispose(),this.native=void 0,this.lastStats=void 0,this.host&&this.host.replaceChildren()}fit(){var e;(e=this.native)==null||e.fit()}zoomIn(){var e;((e=this.native)==null?void 0:e.zoomInButton)?.click()}zoomOut(){var e;((e=this.native)==null?void 0:e.zoomOutButton)?.click()}resize(){var e;(e=this.native)==null||e.render()}setNativeOptions(e){var t,i,r,s;const n=this.native;if(n){if(typeof e.dwfBackground=="string")n.background=e.dwfBackground;else{const a=Vo(e);a&&(n.background=a)}typeof e.dwfPreferWebgl=="boolean"&&((t=n.setPreferWebgl)==null||t.call(n,e.dwfPreferWebgl)),typeof e.dwfPreferWasm=="boolean"&&((i=n.setPreferWasm)==null||i.call(n,e.dwfPreferWasm)),e.dwfLineWeightMode&&((r=n.setLineWeightMode)==null||r.call(n,e.dwfLineWeightMode)),fi(n,"minStrokeCssPx",e.dwfMinStrokeCssPx),fi(n,"maxOverviewStrokeCssPx",e.dwfMaxOverviewStrokeCssPx),fi(n,"minTextCssPx",e.dwfMinTextCssPx),fi(n,"minFilledAreaCssPx",e.dwfMinFilledAreaCssPx),(s=n.render)==null||s.call(n)}}getLastNativeStats(){return this.lastStats}},fl={1:"#ff0000",2:"#ffff00",3:"#00ff00",4:"#00ffff",5:"#0000ff",6:"#ff00ff",8:"#808080",9:"#c0c0c0",10:"#ff0000",11:"#ff7f7f",12:"#a50000",13:"#a55252",14:"#7f0000",15:"#7f3f3f",16:"#4c0000",17:"#4c2626",18:"#260000",19:"#261313",20:"#ff3f00",21:"#ff9f7f",22:"#a52900",23:"#a56752",24:"#7f1f00",25:"#7f4f3f",26:"#4c1300",27:"#4c2f26",28:"#260900",29:"#261713",30:"#ff7f00",31:"#ffbf7f",32:"#a55200",33:"#a57c52",34:"#7f3f00",35:"#7f5f3f",36:"#4c2600",37:"#4c3926",38:"#261300",39:"#261c13",40:"#ffbf00",41:"#ffdf7f",42:"#a57c00",43:"#a59152",44:"#7f5f00",45:"#7f6f3f",46:"#4c3900",47:"#4c4226",48:"#261c00",49:"#262113",50:"#ffff00",51:"#ffff7f",52:"#a5a500",53:"#a5a552",54:"#7f7f00",55:"#7f7f3f",56:"#4c4c00",57:"#4c4c26",58:"#262600",59:"#262613",60:"#bfff00",61:"#dfff7f",62:"#7ca500",63:"#91a552",64:"#5f7f00",65:"#6f7f3f",66:"#394c00",67:"#424c26",68:"#1c2600",69:"#212613",70:"#7fff00",71:"#bfff7f",72:"#52a500",73:"#7ca552",74:"#3f7f00",75:"#5f7f3f",76:"#264c00",77:"#394c26",78:"#132600",79:"#1c2613",80:"#3fff00",81:"#9fff7f",82:"#29a500",83:"#67a552",84:"#1f7f00",85:"#4f7f3f",86:"#134c00",87:"#2f4c26",88:"#092600",89:"#172613",90:"#00ff00",91:"#7fff7f",92:"#00a500",93:"#52a552",94:"#007f00",95:"#3f7f3f",96:"#004c00",97:"#264c26",98:"#002600",99:"#132613",100:"#00ff3f",101:"#7fff9f",102:"#00a529",103:"#52a567",104:"#007f1f",105:"#3f7f4f",106:"#004c13",107:"#264c2f",108:"#002609",109:"#132617",110:"#00ff7f",111:"#7fffbf",112:"#00a552",113:"#52a57c",114:"#007f3f",115:"#3f7f5f",116:"#004c26",117:"#264c39",118:"#002613",119:"#13261c",120:"#00ffbf",121:"#7fffdf",122:"#00a57c",123:"#52a591",124:"#007f5f",125:"#3f7f6f",126:"#004c39",127:"#264c42",128:"#00261c",129:"#132621",130:"#00ffff",131:"#7fffff",132:"#00a5a5",133:"#52a5a5",134:"#007f7f",135:"#3f7f7f",136:"#004c4c",137:"#264c4c",138:"#002626",139:"#132626",140:"#00bfff",141:"#7fdfff",142:"#007ca5",143:"#5291a5",144:"#005f7f",145:"#3f6f7f",146:"#00394c",147:"#26424c",148:"#001c26",149:"#132126",150:"#007fff",151:"#7fbfff",152:"#0052a5",153:"#527ca5",154:"#003f7f",155:"#3f5f7f",156:"#00264c",157:"#26394c",158:"#001326",159:"#131c26",160:"#003fff",161:"#7f9fff",162:"#0029a5",163:"#5267a5",164:"#001f7f",165:"#3f4f7f",166:"#00134c",167:"#262f4c",168:"#000926",169:"#131726",170:"#0000ff",171:"#7f7fff",172:"#0000a5",173:"#5252a5",174:"#00007f",175:"#3f3f7f",176:"#00004c",177:"#26264c",178:"#000026",179:"#131326",180:"#3f00ff",181:"#9f7fff",182:"#2900a5",183:"#6752a5",184:"#1f007f",185:"#4f3f7f",186:"#13004c",187:"#2f264c",188:"#090026",189:"#171326",190:"#7f00ff",191:"#bf7fff",192:"#5200a5",193:"#7c52a5",194:"#3f007f",195:"#5f3f7f",196:"#26004c",197:"#39264c",198:"#130026",199:"#1c1326",200:"#bf00ff",201:"#df7fff",202:"#7c00a5",203:"#9152a5",204:"#5f007f",205:"#6f3f7f",206:"#39004c",207:"#42264c",208:"#1c0026",209:"#211326",210:"#ff00ff",211:"#ff7fff",212:"#a500a5",213:"#a552a5",214:"#7f007f",215:"#7f3f7f",216:"#4c004c",217:"#4c264c",218:"#260026",219:"#261326",220:"#ff00bf",221:"#ff7fdf",222:"#a5007c",223:"#a55291",224:"#7f005f",225:"#7f3f6f",226:"#4c0039",227:"#4c2642",228:"#26001c",229:"#261321",230:"#ff007f",231:"#ff7fbf",232:"#a50052",233:"#a5527c",234:"#7f003f",235:"#7f3f5f",236:"#4c0026",237:"#4c2639",238:"#260013",239:"#26131c",240:"#ff003f",241:"#ff7f9f",242:"#a50029",243:"#a55267",244:"#7f001f",245:"#7f3f4f",246:"#4c0013",247:"#4c262f",248:"#260009",249:"#261317",250:"#333333",251:"#505050",252:"#696969",253:"#828282",254:"#bebebe",255:"#ffffff"},pl={background:"#0b1020",foreground:"#ffffff",showUnsupportedMarkers:!1,showImagePlaceholders:!0,showPageBounds:!0,minScale:1e-9,maxScale:1e9,wheelZoomFactor:1.14,trueColorByteOrder:"rgb",maxInsertDepth:16,contrastMode:"adaptive",minColorContrast:2.4,maxCurveSegments:96,spatialIndexCellCount:72,maxVerticesPerBatch:65536,textMinPixelHeight:4,maxVisibleTextLabels:2500,powerPreference:"high-performance",antialias:!0,preserveDrawingBuffer:!1,enableSpatialIndex:!0},Zr=class{constructor(e,t={}){P(this,"canvas"),P(this,"ctx"),P(this,"opts"),P(this,"document"),P(this,"bounds",ve()),P(this,"view",{centerX:0,centerY:0,scale:1}),P(this,"fitScale",1),P(this,"dpr",1),P(this,"isDragging",!1),P(this,"lastPointer"),P(this,"resizeObserver"),P(this,"imageCache",new Map),P(this,"stats",{total:0,drawn:0,skipped:0,byType:{},unsupported:{},renderElapsedMs:0,backend:"canvas2d"}),P(this,"onStats"),P(this,"onViewChange");const i=e.getContext("2d");if(!i)throw new Error("Canvas 2D context is not available.");this.canvas=e,this.ctx=i,this.opts={...pl,...t},this.canvas.classList.add("cad-viewer-canvas"),this.bindEvents(),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(e)),this.resize()}destroy(){var e;(e=this.resizeObserver)==null||e.disconnect()}clear(){this.document=void 0,this.bounds=ve(),this.view={centerX:0,centerY:0,scale:1},this.fitScale=1,this.render(),this.emitViewChange()}setDocument(e){this.document=e,this.bounds=this.computeBounds(e),this.fitToView()}getDocument(){return this.document}setOptions(e){Object.assign(this.opts,e),this.render(),this.emitViewChange()}getOptions(){return{...this.opts}}fitToView(e=.92){if(!it(this.bounds)){this.view={centerX:0,centerY:0,scale:1},this.fitScale=1,this.render(),this.emitViewChange();return}const t=Math.max(1,this.cssWidth),i=Math.max(1,this.cssHeight),r=Math.max(this.bounds.maxX-this.bounds.minX,1e-9),s=Math.max(this.bounds.maxY-this.bounds.minY,1e-9),n=this.clampScale(Math.min(t/r,i/s)*e);this.fitScale=n,this.view={centerX:(this.bounds.minX+this.bounds.maxX)/2,centerY:(this.bounds.minY+this.bounds.maxY)/2,scale:n},this.render(),this.emitViewChange()}resize(){this.dpr=Math.max(1,window.devicePixelRatio||1);const e=Math.max(1,Math.floor(this.cssWidth*this.dpr)),t=Math.max(1,Math.floor(this.cssHeight*this.dpr));(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.render(),this.emitViewChange()}zoom(e,t){if(!Number.isFinite(e)||e<=0)return;const i=t??{x:this.cssWidth/2,y:this.cssHeight/2},r=this.screenToWorld(i);this.view.scale=this.clampScale(this.view.scale*e);const s=this.screenToWorld(i);this.view.centerX+=r.x-s.x,this.view.centerY+=r.y-s.y,this.render(),this.emitViewChange()}zoomIn(){this.zoom(this.opts.wheelZoomFactor)}zoomOut(){this.zoom(1/this.opts.wheelZoomFactor)}panByScreenDelta(e,t){!Number.isFinite(e)||!Number.isFinite(t)||(this.view.centerX-=e/this.view.scale,this.view.centerY+=t/this.view.scale,this.render(),this.emitViewChange())}setViewState(e){if(![e.centerX,e.centerY,e.scale].every(Number.isFinite))throw new Error("Invalid view state.");this.view={...e,scale:this.clampScale(e.scale)},this.render(),this.emitViewChange()}getViewState(){return{...this.view}}getBounds(){return{...this.bounds}}getStats(){return Ku(this.stats)}getZoomRatio(){return Math.abs(this.fitScale)<1e-12?1:this.view.scale/this.fitScale}getZoomPercent(){return this.getZoomRatio()*100}worldToScreen(e){return{x:this.cssWidth/2+(e.x-this.view.centerX)*this.view.scale,y:this.cssHeight/2-(e.y-this.view.centerY)*this.view.scale}}screenToWorld(e){return{x:this.view.centerX+(e.x-this.cssWidth/2)/this.view.scale,y:this.view.centerY-(e.y-this.cssHeight/2)/this.view.scale}}render(){var e,t;const i=performance.now();if(this.stats={total:0,drawn:0,skipped:0,byType:{},unsupported:{},renderElapsedMs:0,backend:"canvas2d"},this.clearCanvas(),this.document){this.opts.showPageBounds&&(e=this.document.pages)!=null&&e.length&&this.drawPageBounds(this.document);for(const r of this.document.entities)this.drawEntityTracked(r,0)}return this.stats.renderElapsedMs=performance.now()-i,(t=this.onStats)==null||t.call(this,this.getStats()),this.getStats()}get cssWidth(){return this.canvas.clientWidth||1}get cssHeight(){return this.canvas.clientHeight||1}bindEvents(){this.canvas.addEventListener("wheel",t=>{t.preventDefault();const i=t.deltaY<0?this.opts.wheelZoomFactor:1/this.opts.wheelZoomFactor;this.zoom(i,{x:t.offsetX,y:t.offsetY})},{passive:!1}),this.canvas.addEventListener("pointerdown",t=>{this.canvas.setPointerCapture(t.pointerId),this.isDragging=!0,this.lastPointer={x:t.clientX,y:t.clientY},this.canvas.classList.add("is-dragging")}),this.canvas.addEventListener("pointermove",t=>{!this.isDragging||!this.lastPointer||(this.panByScreenDelta(t.clientX-this.lastPointer.x,t.clientY-this.lastPointer.y),this.lastPointer={x:t.clientX,y:t.clientY})});const e=t=>{t&&this.canvas.hasPointerCapture(t.pointerId)&&this.canvas.releasePointerCapture(t.pointerId),this.isDragging=!1,this.lastPointer=void 0,this.canvas.classList.remove("is-dragging")};this.canvas.addEventListener("pointerup",e),this.canvas.addEventListener("pointercancel",()=>e())}clearCanvas(){const e=this.ctx;e.save(),e.setTransform(this.dpr,0,0,this.dpr,0,0),e.clearRect(0,0,this.cssWidth,this.cssHeight),e.fillStyle=this.opts.background,e.fillRect(0,0,this.cssWidth,this.cssHeight),e.restore()}drawPageBounds(e){const t=this.ctx;t.save(),t.setTransform(this.dpr,0,0,this.dpr,0,0),t.strokeStyle="rgba(148, 163, 184, 0.35)",t.lineWidth=1,t.setLineDash([8,6]);for(const i of e.pages??[]){const r=this.worldToScreen({x:0,y:0}),s=this.worldToScreen({x:i.width,y:i.height});t.strokeRect(Math.min(r.x,s.x),Math.min(r.y,s.y),Math.abs(s.x-r.x),Math.abs(s.y-r.y))}t.restore()}drawEntityTracked(e,t){this.stats.total++;const i=String(e.type??"UNKNOWN").toUpperCase();this.stats.byType[i]=(this.stats.byType[i]??0)+1;const r=this.lookupLayer(e.layer);if(e.isVisible===!1||!Yo(r)){this.stats.skipped++;return}this.drawEntity(e,i,t)}drawEntity(e,t,i){switch(e.kind??tt(t)){case"line":return this.drawLine(e);case"circle":return this.drawCircle(e);case"arc":return this.drawArc(e);case"polyline":return this.drawPolyline(e);case"ellipse":return this.drawEllipse(e);case"text":return this.drawText(e);case"point":return this.drawPoint(e);case"insert":return this.drawInsert(e,i);case"solid":return this.drawSolid(e);case"hatch":return this.drawHatch(e);case"spline":return this.drawSpline(e);case"path":return this.drawPath(e);case"image":return this.drawImage(e);case"viewport":return this.markSkipped(t);default:this.stats.unsupported[t]=(this.stats.unsupported[t]??0)+1,this.stats.skipped++,this.opts.showUnsupportedMarkers&&this.drawUnsupportedMarker(e)}}beginStyledPath(e,t=!1){const i=this.ctx;i.save(),i.setTransform(this.dpr,0,0,this.dpr,0,0);const r=st(e,this.document,{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast}),s=Wr(e,this.document,{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast})??r;i.strokeStyle=r,i.fillStyle=t?s:r,i.globalAlpha=rt(Number(e.opacity??1),0,1),i.lineCap="round",i.lineJoin="round";const n=typeof e.lineweight=="number"&&e.lineweight>0?e.lineweight:0;i.lineWidth=Math.max(1,Math.min(12,n>0?n/30:1)),i.beginPath()}finishStroke(){this.ctx.stroke(),this.ctx.restore(),this.stats.drawn++}finishFillStroke(e=!1){e&&this.ctx.fill(),this.ctx.stroke(),this.ctx.restore(),this.stats.drawn++}drawLine(e){const t=e.startPoint,i=e.endPoint;if(!C(t)||!C(i))return this.markSkipped("LINE");const r=this.worldToScreen(t),s=this.worldToScreen(i);this.beginStyledPath(e),this.ctx.moveTo(r.x,r.y),this.ctx.lineTo(s.x,s.y),this.finishStroke()}drawCircle(e){const t=e.center,i=Number(e.radius);if(!C(t)||!Number.isFinite(i))return this.markSkipped("CIRCLE");const r=this.worldToScreen(t);this.beginStyledPath(e),this.ctx.arc(r.x,r.y,Math.abs(i)*this.view.scale,0,Math.PI*2),this.finishStroke()}drawArc(e){const t=e.center,i=Number(e.radius),r=Number(e.startAngle),s=Number(e.endAngle);if(!C(t)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return this.markSkipped("ARC");this.strokeWorldPolyline(e,ci(X(t),i,r,s,!0),!1)}drawPolyline(e){const t=e.vertices??e.points;if(!Array.isArray(t)||t.length<2)return this.markSkipped(String(e.type));const i=!!e.isClosed||(Number(e.flag)&1)===1,r=[],s=i?t.length:t.length-1;for(let n=0;n<s;n++){const a=t[n],o=t[(n+1)%t.length];if(!C(a)||!C(o))continue;const l=Ro(a,o,Number(a.bulge??0));r.length>0&&l.shift(),r.push(...l)}this.strokeWorldPolyline(e,r,i)}drawEllipse(e){const t=e.center,i=e.majorAxisEndPoint,r=Number(e.axisRatio??1);if(!C(t)||!C(i))return this.markSkipped("ELLIPSE");const s=di(t,i,r,Number(e.startAngle??0),Number(e.endAngle??Math.PI*2)),n=Math.abs(Number(e.endAngle??Math.PI*2)-Number(e.startAngle??0))>=Math.PI*2-1e-6;this.strokeWorldPolyline(e,s,n)}drawPoint(e){const t=e.point??e.location??e.center??e.insertionPoint;if(!C(t))return this.markSkipped("POINT");const i=this.worldToScreen(t);this.beginStyledPath(e),this.ctx.moveTo(i.x-3,i.y),this.ctx.lineTo(i.x+3,i.y),this.ctx.moveTo(i.x,i.y-3),this.ctx.lineTo(i.x,i.y+3),this.finishStroke()}drawText(e){const t=e.insertionPoint??e.startPoint??e.center,i=Bo(String(e.text??e.value??"")),r=Number(e.textHeight??e.height??1);if(!C(t)||!i)return this.markSkipped(String(e.type));this.drawTextAt(e,t,i,r,Number(e.rotation??0))}drawInsert(e,t){const i=this.lookupBlock(e.blockName??e.name);if(i&&t<this.opts.maxInsertDepth){const a=pi(e,i.basePoint??{x:0,y:0});for(const o of i.entities){const l=jo(o,e,this.document,{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast});this.drawEntityTracked(mi(l,a),t+1)}return}const r=e.insertionPoint;if(!C(r))return this.markSkipped("INSERT");const s=this.worldToScreen(r);this.beginStyledPath(e);const n=5;if(this.ctx.rect(s.x-n,s.y-n,n*2,n*2),this.finishStroke(),Array.isArray(e.attribs))for(const a of e.attribs)this.drawText(a)}drawSolid(e){const t=e.vertices??e.points;if(!Array.isArray(t)||t.length<3)return this.markSkipped(String(e.type));this.beginStyledPath(e,!0);const i=this.worldToScreen(t[0]);this.ctx.moveTo(i.x,i.y);for(const r of t.slice(1)){if(!C(r))continue;const s=this.worldToScreen(r);this.ctx.lineTo(s.x,s.y)}this.ctx.closePath(),this.finishFillStroke(!0)}drawHatch(e){var t,i;const r=e.loops;if(!Array.isArray(r)||r.length===0)return this.markSkipped("HATCH");this.beginStyledPath(e,!0);for(const s of r)if((t=s.commands)!=null&&t.length)this.addPathCommands(s.commands);else if((i=s.vertices)!=null&&i.length){const n=this.worldToScreen(s.vertices[0]);this.ctx.moveTo(n.x,n.y);for(const a of s.vertices.slice(1)){const o=this.worldToScreen(a);this.ctx.lineTo(o.x,o.y)}this.ctx.closePath()}this.finishFillStroke(!!Wr(e,this.document,{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast}))}drawSpline(e){var t;const i=(t=e.fitPoints)!=null&&t.length?e.fitPoints:e.controlPoints;if(!i||i.length<2)return this.markSkipped("SPLINE");this.strokeWorldPolyline(e,i,!!e.isClosed)}drawPath(e){var t;if(!((t=e.commands)!=null&&t.length))return this.markSkipped(String(e.type));this.beginStyledPath(e,!!e.fillColor),this.addPathCommands(e.commands),this.finishFillStroke(!!e.fillColor)}addPathCommands(e){for(const t of e)if(t.cmd==="M"){const i=this.worldToScreen(t.points[0]);this.ctx.moveTo(i.x,i.y)}else if(t.cmd==="L"){const i=this.worldToScreen(t.points[0]);this.ctx.lineTo(i.x,i.y)}else if(t.cmd==="C"){const[i,r,s]=t.points.map(n=>this.worldToScreen(n));this.ctx.bezierCurveTo(i.x,i.y,r.x,r.y,s.x,s.y)}else if(t.cmd==="Q"){const[i,r]=t.points.map(s=>this.worldToScreen(s));this.ctx.quadraticCurveTo(i.x,i.y,r.x,r.y)}else t.cmd==="Z"&&this.ctx.closePath()}drawImage(e){const t=e.insertionPoint;if(!C(t))return this.markSkipped(String(e.type));const i=Number(e.width??32),r=Number(e.height??32),s=this.worldToScreen(t),n=this.worldToScreen({x:t.x+i,y:t.y-r}),a=Math.min(s.x,n.x),o=Math.min(s.y,n.y),l=Math.abs(n.x-s.x),c=Math.abs(n.y-s.y),d=e.imageDataUrl;if(d){const h=this.getImage(d);if(h.complete&&h.naturalWidth>0){this.ctx.save(),this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0),this.ctx.drawImage(h,a,o,l,c),this.ctx.restore(),this.stats.drawn++;return}h.onload=()=>this.render()}if(!this.opts.showImagePlaceholders)return this.markSkipped(String(e.type));this.beginStyledPath(e),this.ctx.rect(a,o,l,c),this.ctx.moveTo(a,o),this.ctx.lineTo(a+l,o+c),this.ctx.moveTo(a+l,o),this.ctx.lineTo(a,o+c),this.finishStroke()}getImage(e){let t=this.imageCache.get(e);return t||(t=new Image,t.src=e,this.imageCache.set(e,t)),t}drawUnsupportedMarker(e){const t=this.entityAnchor(e);if(!t)return;const i=this.worldToScreen(t);this.beginStyledPath(e),this.ctx.moveTo(i.x-4,i.y-4),this.ctx.lineTo(i.x+4,i.y+4),this.ctx.moveTo(i.x+4,i.y-4),this.ctx.lineTo(i.x-4,i.y+4),this.finishStroke()}drawTextAt(e,t,i,r,s){const n=this.ctx,a=this.worldToScreen(t);n.save(),n.setTransform(this.dpr,0,0,this.dpr,0,0),n.translate(a.x,a.y),n.rotate(-s);const o=Math.max(4,Math.min(256,Math.abs(r)*this.view.scale));n.font=`${o}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,n.fillStyle=st(e,this.document,{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast}),n.globalAlpha=rt(Number(e.opacity??1),0,1),n.textBaseline="alphabetic";for(const[l,c]of i.split(/\r?\n/g).entries())n.fillText(c,0,l*o*1.22);n.restore(),this.stats.drawn++}strokeWorldPolyline(e,t,i){const r=t.filter(C);if(r.length<2)return this.markSkipped(String(e.type));this.beginStyledPath(e);const s=this.worldToScreen(r[0]);this.ctx.moveTo(s.x,s.y);for(const n of r.slice(1)){const a=this.worldToScreen(n);this.ctx.lineTo(a.x,a.y)}i&&this.ctx.closePath(),this.finishStroke()}markSkipped(e){this.stats.skipped++,this.stats.unsupported[e]=this.stats.unsupported[e]??0}entityAnchor(e){for(const t of["startPoint","insertionPoint","center","point","location"]){const i=e[t];if(C(i))return X(i)}if(Array.isArray(e.vertices)&&C(e.vertices[0]))return X(e.vertices[0]);if(Array.isArray(e.commands)&&e.commands.length){const t=e.commands.find(i=>i.points.length>0);if(t)return X(t.points[0])}}computeBounds(e){var t;const i=ve();if((t=e.pages)!=null&&t.length)for(const r of e.pages)W(i,{x:0,y:0}),W(i,{x:r.width,y:r.height});for(const r of e.entities)this.includeEntityBounds(i,r,0);return Do(i)}includeEntityBounds(e,t,i){const r=String(t.type??"").toUpperCase(),s=t.kind??tt(r);if(s==="insert"){const n=this.lookupBlock(t.blockName??t.name);if(n&&i<this.opts.maxInsertDepth){const a=pi(t,n.basePoint??{x:0,y:0});for(const o of n.entities)this.includeEntityBounds(e,mi(o,a),i+1);return}}if(s==="line")C(t.startPoint)&&W(e,t.startPoint),C(t.endPoint)&&W(e,t.endPoint);else if(s==="circle"||s==="arc")C(t.center)&&Number.isFinite(t.radius)&&Lo(e,t.center,Number(t.radius));else if(s==="polyline"||s==="solid"||s==="spline")for(const n of[...t.vertices??[],...t.points??[],...t.controlPoints??[],...t.fitPoints??[]])C(n)&&W(e,n);else if(s==="ellipse")C(t.center)&&C(t.majorAxisEndPoint)&&di(t.center,t.majorAxisEndPoint,Number(t.axisRatio??1),Number(t.startAngle??0),Number(t.endAngle??Math.PI*2)).forEach(n=>W(e,n));else if(s==="path")for(const n of t.commands??[])for(const a of n.points)W(e,a);else if(s==="hatch")for(const n of t.loops??[]){for(const a of n.vertices??[])W(e,a);for(const a of n.commands??[])for(const o of a.points)W(e,o)}else{const n=this.entityAnchor(t);n&&W(e,n)}}lookupLayer(e){if(!(!this.document||!e))return this.document.layers[e]??this.document.layers[e.toLowerCase()]??Object.values(this.document.layers).find(t=>t.name.toLowerCase()===e.toLowerCase())}lookupBlock(e){if(!(!this.document||!e))return this.document.blocks[e]??this.document.blocks[e.toLowerCase()]??Object.values(this.document.blocks).find(t=>t.name.toLowerCase()===e.toLowerCase())}clampScale(e){return Math.min(this.opts.maxScale,Math.max(this.opts.minScale,e))}emitViewChange(){var e;(e=this.onViewChange)==null||e.call(this,{view:this.getViewState(),fitScale:this.fitScale,zoomRatio:this.getZoomRatio(),zoomPercent:this.getZoomPercent(),bounds:this.getBounds()})}},ml={background:"#0b1020",foreground:"#ffffff",showUnsupportedMarkers:!1,showImagePlaceholders:!0,showPageBounds:!0,minScale:1e-9,maxScale:1e9,wheelZoomFactor:1.14,trueColorByteOrder:"rgb",maxInsertDepth:16,contrastMode:"adaptive",minColorContrast:2.4,maxCurveSegments:96,spatialIndexCellCount:72,maxVerticesPerBatch:65536,textMinPixelHeight:4,maxVisibleTextLabels:2500,powerPreference:"high-performance",antialias:!0,preserveDrawingBuffer:!1,enableSpatialIndex:!0},Kr=class{constructor(e,t={}){P(this,"canvas"),P(this,"backend","webgl"),P(this,"gl"),P(this,"program"),P(this,"eventController",new AbortController),P(this,"imageCache",new Map),P(this,"opts"),P(this,"document"),P(this,"bounds",ve()),P(this,"view",{centerX:0,centerY:0,scale:1}),P(this,"fitScale",1),P(this,"dpr",1),P(this,"isDragging",!1),P(this,"lastPointer"),P(this,"resizeObserver"),P(this,"overlayCanvas"),P(this,"overlayCtx"),P(this,"scene"),P(this,"stats",{total:0,drawn:0,skipped:0,byType:{},unsupported:{},renderElapsedMs:0,backend:"webgl",primitiveCount:0,visiblePrimitiveCount:0,culledPrimitiveCount:0,gpuMemoryBytes:0,buildElapsedMs:0}),P(this,"rafHandle",0),P(this,"onStats"),P(this,"onViewChange");const i=Qu(e,t);if(!i)throw new Error('WebGL is not available. Use renderer: "canvas2d" to force the Canvas2D fallback.');this.canvas=e,this.gl=i,this.program=Ju(i),this.opts={...ml,...t},this.canvas.classList.add("cad-viewer-canvas","cad-viewer-webgl-canvas"),this.createOverlayCanvas(),this.bindEvents(),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(e)),this.resize()}static isSupported(){return el()}destroy(){var e,t;this.eventController.abort(),(e=this.resizeObserver)==null||e.disconnect(),this.cancelScheduledRender(),this.disposeScene(),(t=this.overlayCanvas)==null||t.remove()}clear(){this.document=void 0,this.bounds=ve(),this.view={centerX:0,centerY:0,scale:1},this.fitScale=1,this.disposeScene(),this.render(),this.emitViewChange()}setDocument(e){this.document=e,this.bounds=sf(e,this.opts),this.disposeScene();const t=tf(e,this.opts,this.bounds);this.scene=ef(this.gl,t),this.stats=lf(this.scene,0),this.fitToView()}getDocument(){return this.document}setOptions(e){const t=of(this.opts,e);if(this.opts={...this.opts,...e},t&&this.document){this.setDocument(this.document);return}this.render(),this.emitViewChange()}getOptions(){return{...this.opts}}fitToView(e=.92){if(!it(this.bounds)){this.view={centerX:0,centerY:0,scale:1},this.fitScale=1,this.render(),this.emitViewChange();return}const t=Math.max(1,this.cssWidth),i=Math.max(1,this.cssHeight),r=Math.max(this.bounds.maxX-this.bounds.minX,1e-9),s=Math.max(this.bounds.maxY-this.bounds.minY,1e-9),n=this.clampScale(Math.min(t/r,i/s)*e);this.fitScale=n,this.view={centerX:(this.bounds.minX+this.bounds.maxX)/2,centerY:(this.bounds.minY+this.bounds.maxY)/2,scale:n},this.render(),this.emitViewChange()}resize(){this.dpr=Math.max(1,window.devicePixelRatio||1);const e=Math.max(1,Math.floor(this.cssWidth*this.dpr)),t=Math.max(1,Math.floor(this.cssHeight*this.dpr));(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.resizeOverlay(e,t),this.render(),this.emitViewChange()}zoom(e,t){if(!Number.isFinite(e)||e<=0)return;const i=t??{x:this.cssWidth/2,y:this.cssHeight/2},r=this.screenToWorld(i);this.view.scale=this.clampScale(this.view.scale*e);const s=this.screenToWorld(i);this.view.centerX+=r.x-s.x,this.view.centerY+=r.y-s.y,this.scheduleRender(),this.emitViewChange()}zoomIn(){this.zoom(this.opts.wheelZoomFactor)}zoomOut(){this.zoom(1/this.opts.wheelZoomFactor)}panByScreenDelta(e,t){!Number.isFinite(e)||!Number.isFinite(t)||(this.view.centerX-=e/this.view.scale,this.view.centerY+=t/this.view.scale,this.scheduleRender(),this.emitViewChange())}setViewState(e){if(![e.centerX,e.centerY,e.scale].every(Number.isFinite))throw new Error("Invalid view state.");this.view={...e,scale:this.clampScale(e.scale)},this.render(),this.emitViewChange()}getViewState(){return{...this.view}}getBounds(){return{...this.bounds}}getStats(){return cf(this.stats)}getZoomRatio(){return Math.abs(this.fitScale)<1e-12?1:this.view.scale/this.fitScale}getZoomPercent(){return this.getZoomRatio()*100}worldToScreen(e){return{x:this.cssWidth/2+(e.x-this.view.centerX)*this.view.scale,y:this.cssHeight/2-(e.y-this.view.centerY)*this.view.scale}}screenToWorld(e){return{x:this.view.centerX+(e.x-this.cssWidth/2)/this.view.scale,y:this.view.centerY-(e.y-this.cssHeight/2)/this.view.scale}}render(){return this.cancelScheduledRender(),this.renderNow()}renderNow(){var e;const t=performance.now(),i=this.gl;i.viewport(0,0,this.canvas.width,this.canvas.height);const r=Yr(this.opts.background,[11,16,32,255]);i.clearColor(r[0]/255,r[1]/255,r[2]/255,r[3]/255),i.clear(i.COLOR_BUFFER_BIT),i.disable(i.DEPTH_TEST),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA);let s=0,n=0;const a=this.scene,o=this.visibleWorldBounds();if(a){i.useProgram(this.program.program),i.uniform2f(this.program.uViewCenter,this.view.centerX-a.origin.x,this.view.centerY-a.origin.y),i.uniform1f(this.program.uScale,this.view.scale*this.dpr),i.uniform2f(this.program.uViewport,this.canvas.width,this.canvas.height),i.uniform1f(this.program.uPointSize,Math.max(2,Math.min(12,4*this.dpr)));const c=this.drawBatches(a.lineBatches,i.LINES,o);s+=c.visible,n+=c.culled;const d=this.drawBatches(a.triangleBatches,i.TRIANGLES,o);s+=d.visible,n+=d.culled;const h=this.drawBatches(a.pointBatches,i.POINTS,o);s+=h.visible,n+=h.culled}this.renderOverlay(o);const l=performance.now()-t;return this.stats=a?{...a.stats,renderElapsedMs:l,backend:"webgl",primitiveCount:a.primitiveCount,visiblePrimitiveCount:s,culledPrimitiveCount:n,gpuMemoryBytes:a.gpuMemoryBytes,buildElapsedMs:a.buildElapsedMs}:{total:0,drawn:0,skipped:0,byType:{},unsupported:{},renderElapsedMs:l,backend:"webgl",primitiveCount:0,visiblePrimitiveCount:0,culledPrimitiveCount:0,gpuMemoryBytes:0,buildElapsedMs:0},(e=this.onStats)==null||e.call(this,this.getStats()),this.getStats()}drawBatches(e,t,i){const r=this.gl;let s=0,n=0;for(const a of e){if(!Gr(a.bounds,i)){n+=a.primitiveCount;continue}r.bindBuffer(r.ARRAY_BUFFER,a.positionBuffer),r.enableVertexAttribArray(this.program.aPosition),r.vertexAttribPointer(this.program.aPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,a.colorBuffer),r.enableVertexAttribArray(this.program.aColor),r.vertexAttribPointer(this.program.aColor,4,r.UNSIGNED_BYTE,!0,0,0),r.drawArrays(t,0,a.vertexCount),s+=a.primitiveCount}return{visible:s,culled:n}}scheduleRender(){this.rafHandle||(this.rafHandle=window.requestAnimationFrame(()=>{this.rafHandle=0,this.renderNow()}))}cancelScheduledRender(){this.rafHandle&&(window.cancelAnimationFrame(this.rafHandle),this.rafHandle=0)}renderOverlay(e){var t,i;const r=this.overlayCtx,s=this.overlayCanvas;!r||!s||(r.save(),r.setTransform(this.dpr,0,0,this.dpr,0,0),r.clearRect(0,0,this.cssWidth,this.cssHeight),this.opts.showPageBounds&&(i=(t=this.document)==null?void 0:t.pages)!=null&&i.length&&this.drawPageBoundsOverlay(r),this.scene&&(this.drawImagesOverlay(r,this.scene.imageItems,e),this.drawTextOverlay(r,this.scene.textItems,e)),r.restore())}drawPageBoundsOverlay(e){var t,i;if((i=(t=this.document)==null?void 0:t.pages)!=null&&i.length){e.save(),e.strokeStyle="rgba(148, 163, 184, 0.34)",e.lineWidth=1,e.setLineDash([8,6]);for(const r of this.document.pages){const s=this.worldToScreen({x:0,y:0}),n=this.worldToScreen({x:r.width,y:r.height});e.strokeRect(Math.min(s.x,n.x),Math.min(s.y,n.y),Math.abs(n.x-s.x),Math.abs(n.y-s.y))}e.restore()}}drawTextOverlay(e,t,i){const r=this.opts.maxVisibleTextLabels;let s=0;for(const n of t){if(s>=r)break;if(!Gr(n.bounds,i))continue;const a=Math.abs(n.height)*this.view.scale;if(a<this.opts.textMinPixelHeight)continue;const o=this.worldToScreen(n.point);if(o.x<-512||o.y<-512||o.x>this.cssWidth+512||o.y>this.cssHeight+512)continue;e.save(),e.translate(o.x,o.y),e.rotate(-n.rotation);const l=Math.max(4,Math.min(256,a));e.font=`${l}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,e.fillStyle=n.color,e.globalAlpha=n.opacity,e.textBaseline="alphabetic";for(const[c,d]of n.text.split(/\r?\n/g).entries())e.fillText(d,0,c*l*1.22);e.restore(),s++}}drawImagesOverlay(e,t,i){for(const r of t){if(!Gr(r.bounds,i))continue;const s=this.worldToScreen(r.point),n=this.worldToScreen({x:r.point.x+r.width,y:r.point.y-r.height}),a=Math.min(s.x,n.x),o=Math.min(s.y,n.y),l=Math.abs(n.x-s.x),c=Math.abs(n.y-s.y);if(!(l<1||c<1)){if(r.source){const d=this.getImage(r.source);if(d.complete&&d.naturalWidth>0){e.save(),e.globalAlpha=r.opacity,e.drawImage(d,a,o,l,c),e.restore();continue}d.onload=()=>this.scheduleRender()}this.opts.showImagePlaceholders&&(e.save(),e.strokeStyle=r.color,e.globalAlpha=r.opacity,e.lineWidth=1,e.strokeRect(a,o,l,c),e.beginPath(),e.moveTo(a,o),e.lineTo(a+l,o+c),e.moveTo(a+l,o),e.lineTo(a,o+c),e.stroke(),e.restore())}}}getImage(e){let t=this.imageCache.get(e);return t||(t=new Image,t.src=e,this.imageCache.set(e,t)),t}createOverlayCanvas(){const e=this.canvas.parentElement;if(!e||typeof document>"u")return;window.getComputedStyle(e).position==="static"&&(e.style.position="relative");const t=document.createElement("canvas");t.className="cad-viewer-text-overlay",t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.inset="0",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none",t.style.zIndex="1";const i=t.getContext("2d");i&&(e.appendChild(t),this.overlayCanvas=t,this.overlayCtx=i)}resizeOverlay(e,t){this.overlayCanvas&&(this.overlayCanvas.width!==e||this.overlayCanvas.height!==t)&&(this.overlayCanvas.width=e,this.overlayCanvas.height=t)}bindEvents(){const e=this.eventController.signal;this.canvas.addEventListener("wheel",i=>{i.preventDefault();const r=i.deltaY<0?this.opts.wheelZoomFactor:1/this.opts.wheelZoomFactor;this.zoom(r,{x:i.offsetX,y:i.offsetY})},{passive:!1,signal:e}),this.canvas.addEventListener("pointerdown",i=>{this.canvas.setPointerCapture(i.pointerId),this.isDragging=!0,this.lastPointer={x:i.clientX,y:i.clientY},this.canvas.classList.add("is-dragging")},{signal:e}),this.canvas.addEventListener("pointermove",i=>{!this.isDragging||!this.lastPointer||(this.panByScreenDelta(i.clientX-this.lastPointer.x,i.clientY-this.lastPointer.y),this.lastPointer={x:i.clientX,y:i.clientY})},{signal:e});const t=i=>{i&&this.canvas.hasPointerCapture(i.pointerId)&&this.canvas.releasePointerCapture(i.pointerId),this.isDragging=!1,this.lastPointer=void 0,this.canvas.classList.remove("is-dragging")};this.canvas.addEventListener("pointerup",t,{signal:e}),this.canvas.addEventListener("pointercancel",()=>t(),{signal:e}),this.canvas.addEventListener("webglcontextlost",i=>{i.preventDefault(),this.cancelScheduledRender()},{signal:e})}visibleWorldBounds(){const e=this.cssWidth/Math.max(this.view.scale,1e-12)/2,t=this.cssHeight/Math.max(this.view.scale,1e-12)/2;return{minX:this.view.centerX-e,maxX:this.view.centerX+e,minY:this.view.centerY-t,maxY:this.view.centerY+t}}get cssWidth(){return this.canvas.clientWidth||1}get cssHeight(){return this.canvas.clientHeight||1}clampScale(e){return Math.min(this.opts.maxScale,Math.max(this.opts.minScale,e))}disposeScene(){if(!this.scene)return;const e=this.gl;for(const t of[...this.scene.lineBatches,...this.scene.triangleBatches,...this.scene.pointBatches])e.deleteBuffer(t.positionBuffer),e.deleteBuffer(t.colorBuffer);this.scene=void 0}emitViewChange(){var e;(e=this.onViewChange)==null||e.call(this,{view:this.getViewState(),fitScale:this.fitScale,zoomRatio:this.getZoomRatio(),zoomPercent:this.getZoomPercent(),bounds:this.getBounds()})}},gl=class{constructor(e,t,i,r){P(this,"lineBuckets",new Map),P(this,"triangleBuckets",new Map),P(this,"pointBuckets",new Map),P(this,"textItems",[]),P(this,"imageItems",[]),P(this,"stats",{total:0,drawn:0,skipped:0,byType:{},unsupported:{},backend:"webgl",primitiveCount:0,visiblePrimitiveCount:0,culledPrimitiveCount:0,gpuMemoryBytes:0,buildElapsedMs:0}),P(this,"tileSize"),P(this,"maxVerticesPerBatch"),P(this,"primitiveCount",0),this.document=e,this.opts=t,this.bounds=i,this.origin=r;const s=it(i)?Math.max(i.maxX-i.minX,i.maxY-i.minY,1e-9):1;this.tileSize=t.enableSpatialIndex?s/Math.max(8,t.spatialIndexCellCount):Number.POSITIVE_INFINITY,this.maxVerticesPerBatch=Math.max(4096,Math.floor(t.maxVerticesPerBatch))}addEntityTracked(e,t){this.stats.total++;const i=String(e.type??"UNKNOWN").toUpperCase();this.stats.byType[i]=(this.stats.byType[i]??0)+1;const r=this.lookupLayer(e.layer);if(e.isVisible===!1||!Yo(r)){this.stats.skipped++;return}this.addEntity(e,i,t)}finalize(){const e=Vr(this.lineBuckets,this.maxVerticesPerBatch),t=Vr(this.triangleBuckets,this.maxVerticesPerBatch),i=Vr(this.pointBuckets,this.maxVerticesPerBatch);return this.stats.primitiveCount=this.primitiveCount,{origin:this.origin,lineBatches:e,triangleBatches:t,pointBatches:i,textItems:this.textItems,imageItems:this.imageItems,stats:this.stats,primitiveCount:this.primitiveCount,buildElapsedMs:0}}addEntity(e,t,i){switch(e.kind??tt(t)){case"line":return this.addLineEntity(e);case"circle":return this.addCircleEntity(e);case"arc":return this.addArcEntity(e);case"polyline":return this.addPolylineEntity(e);case"ellipse":return this.addEllipseEntity(e);case"text":return this.addTextEntity(e);case"point":return this.addPointEntity(e);case"insert":return this.addInsertEntity(e,i);case"solid":return this.addSolidEntity(e);case"hatch":return this.addHatchEntity(e);case"spline":return this.addSplineEntity(e);case"path":return this.addPathEntity(e);case"image":return this.addImageEntity(e);case"viewport":return this.markSkipped(t);default:this.stats.unsupported[t]=(this.stats.unsupported[t]??0)+1,this.stats.skipped++,this.opts.showUnsupportedMarkers&&this.addUnsupportedMarker(e)}}addLineEntity(e){if(!C(e.startPoint)||!C(e.endPoint))return this.markSkipped("LINE");this.addSegment(e.startPoint,e.endPoint,this.strokeBytes(e)),this.stats.drawn++}addCircleEntity(e){const t=e.center,i=Number(e.radius);if(!C(t)||!Number.isFinite(i))return this.markSkipped("CIRCLE");const r=Math.max(16,Math.min(this.opts.maxCurveSegments,Math.ceil(Math.sqrt(Math.abs(i))*12))),s=ci(t,i,0,Math.PI*2,!0,r);this.addPolyline(s,!0,this.strokeBytes(e)),this.stats.drawn++}addArcEntity(e){const t=e.center,i=Number(e.radius),r=Number(e.startAngle),s=Number(e.endAngle);if(!C(t)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return this.markSkipped("ARC");this.addPolyline(ci(t,i,r,s,!0,this.opts.maxCurveSegments),!1,this.strokeBytes(e)),this.stats.drawn++}addPolylineEntity(e){const t=e.vertices??e.points;if(!Array.isArray(t)||t.length<2)return this.markSkipped(String(e.type));const i=!!e.isClosed||(Number(e.flag)&1)===1,r=[],s=i?t.length:t.length-1;for(let n=0;n<s;n++){const a=t[n],o=t[(n+1)%t.length];if(!C(a)||!C(o))continue;const l=Ro(a,o,Number(a.bulge??0),Math.max(4,Math.min(24,this.opts.maxCurveSegments/4)));r.length>0&&l.shift(),r.push(...l)}if(r.length<2)return this.markSkipped(String(e.type));this.addPolyline(r,i,this.strokeBytes(e)),this.stats.drawn++}addEllipseEntity(e){if(!C(e.center)||!C(e.majorAxisEndPoint))return this.markSkipped("ELLIPSE");const t=di(e.center,e.majorAxisEndPoint,Number(e.axisRatio??1),Number(e.startAngle??0),Number(e.endAngle??Math.PI*2),this.opts.maxCurveSegments),i=Math.abs(Number(e.endAngle??Math.PI*2)-Number(e.startAngle??0))>=Math.PI*2-1e-6;this.addPolyline(t,i,this.strokeBytes(e)),this.stats.drawn++}addTextEntity(e){const t=e.insertionPoint??e.startPoint??e.center,i=Bo(String(e.text??e.value??"")),r=Number(e.textHeight??e.height??1);if(!C(t)||!i||!Number.isFinite(r))return this.markSkipped(String(e.type));const s=X(t),n=Math.max(1,i.split(/\r?\n/g).reduce((o,l)=>Math.max(o,l.length),0))*Math.abs(r)*.62,a=Math.max(1,i.split(/\r?\n/g).length)*Math.abs(r)*1.22;this.textItems.push({point:s,text:i,height:r,rotation:Number(e.rotation??0),color:st(e,this.document,this.colorOptions()),opacity:rt(Number(e.opacity??1),0,1),bounds:{minX:s.x-n*.1,minY:s.y-a,maxX:s.x+n,maxY:s.y+a}}),this.stats.drawn++}addPointEntity(e){const t=e.point??e.location??e.center??e.insertionPoint;if(!C(t))return this.markSkipped("POINT");this.addPoint(t,this.strokeBytes(e)),this.stats.drawn++}addInsertEntity(e,t){const i=this.lookupBlock(e.blockName??e.name);if(i&&t<this.opts.maxInsertDepth){const s=pi(e,i.basePoint??{x:0,y:0});for(const n of i.entities){const a=jo(n,e,this.document,this.colorOptions());this.addEntityTracked(mi(a,s),t+1)}return}const r=e.insertionPoint;if(!C(r))return this.markSkipped("INSERT");if(this.addPoint(r,this.strokeBytes(e)),Array.isArray(e.attribs))for(const s of e.attribs)this.addTextEntity(s);this.stats.drawn++}addSolidEntity(e){const t=e.vertices??e.points;if(!Array.isArray(t)||t.length<3)return this.markSkipped(String(e.type));const i=t.filter(C).map(X);if(i.length<3)return this.markSkipped(String(e.type));const r=this.fillBytes(e)??this.strokeBytes(e);this.addTriangleFan(i,r),this.addPolyline(i,!0,this.strokeBytes(e)),this.stats.drawn++}addHatchEntity(e){var t;const i=e.loops;if(!Array.isArray(i)||i.length===0)return this.markSkipped("HATCH");const r=this.strokeBytes(e),s=this.fillBytes(e);let n=!1;for(const a of i){const o=(t=a.commands)!=null&&t.length?rl(a.commands,this.opts.maxCurveSegments):(a.vertices??[]).filter(C).map(X);o.length<2||(this.addPolyline(o,!0,r),s&&o.length>=3&&this.addTriangleFan(o,s),n=!0)}if(!n)return this.markSkipped("HATCH");this.stats.drawn++}addSplineEntity(e){var t;const i=(t=e.fitPoints)!=null&&t.length?e.fitPoints:e.controlPoints;if(!i||i.length<2)return this.markSkipped("SPLINE");this.addPolyline(i.filter(C).map(X),!!e.isClosed,this.strokeBytes(e)),this.stats.drawn++}addPathEntity(e){var t;if(!((t=e.commands)!=null&&t.length))return this.markSkipped(String(e.type));const i=rl(e.commands,this.opts.maxCurveSegments);if(i.length<2)return this.markSkipped(String(e.type));this.addPolyline(i,!1,this.strokeBytes(e));const r=this.fillBytes(e);r&&i.length>=3&&this.addTriangleFan(i,r),this.stats.drawn++}addImageEntity(e){const t=e.insertionPoint;if(!C(t))return this.markSkipped(String(e.type));const i=Number(e.width??32),r=Number(e.height??32);if(!Number.isFinite(i)||!Number.isFinite(r))return this.markSkipped(String(e.type));const s=X(t),n=Xr([s,{x:s.x+i,y:s.y-r}]);this.imageItems.push({point:s,width:i,height:r,source:e.imageDataUrl??e.imageSource,color:st(e,this.document,this.colorOptions()),opacity:rt(Number(e.opacity??1),0,1),bounds:n}),this.stats.drawn++}addUnsupportedMarker(e){const t=nl(e);t&&this.addPoint(t,this.strokeBytes(e))}addPolyline(e,t,i){const r=e.filter(C).map(X);if(!(r.length<2)){for(let s=0;s<r.length-1;s++)this.addSegment(r[s],r[s+1],i);t&&this.addSegment(r[r.length-1],r[0],i)}}addSegment(e,t,i){if(!C(e)||!C(t)||Math.hypot(e.x-t.x,e.y-t.y)<=1e-14)return;const r=this.batchFor(this.lineBuckets,Xr([e,t]));ot(r,e,i,this.origin),ot(r,t,i,this.origin),r.primitiveCount++,this.primitiveCount++}addPoint(e,t){const i=this.batchFor(this.pointBuckets,af(e));ot(i,e,t,this.origin),i.primitiveCount++,this.primitiveCount++}addTriangleFan(e,t){const i=e.filter(C).map(X);if(i.length<3)return;const r=Xr(i),s=this.batchFor(this.triangleBuckets,r);for(let n=1;n<i.length-1;n++)ot(s,i[0],t,this.origin),ot(s,i[n],t,this.origin),ot(s,i[n+1],t,this.origin),s.primitiveCount++,this.primitiveCount++}batchFor(e,t){const i=this.bucketKey(t);let r=e.get(i);return r||(r=rf(),e.set(i,r)),W(r.bounds,{x:t.minX,y:t.minY}),W(r.bounds,{x:t.maxX,y:t.maxY}),r}bucketKey(e){if(!Number.isFinite(this.tileSize))return"all";const t=(e.minX+e.maxX)/2,i=(e.minY+e.maxY)/2;return`${Math.floor((t-this.bounds.minX)/this.tileSize)}:${Math.floor((i-this.bounds.minY)/this.tileSize)}`}strokeBytes(e){return Yr(st(e,this.document,this.colorOptions()),[255,255,255,255],rt(Number(e.opacity??1),0,1))}fillBytes(e){const t=Wr(e,this.document,this.colorOptions());return t?Yr(t,[255,255,255,255],rt(Number(e.opacity??1),0,1)):void 0}colorOptions(){return{foreground:this.opts.foreground,background:this.opts.background,trueColorByteOrder:this.opts.trueColorByteOrder,contrastMode:this.opts.contrastMode,minColorContrast:this.opts.minColorContrast}}markSkipped(e){this.stats.skipped++,this.stats.unsupported[e]=this.stats.unsupported[e]??0}lookupLayer(e){if(e)return this.document.layers[e]??this.document.layers[e.toLowerCase()]??Object.values(this.document.layers).find(t=>t.name.toLowerCase()===e.toLowerCase())}lookupBlock(e){if(e)return this.document.blocks[e]??this.document.blocks[e.toLowerCase()]??Object.values(this.document.blocks).find(t=>t.name.toLowerCase()===e.toLowerCase())}},bl=class{constructor(e={}){P(this,"canvas"),P(this,"renderer"),P(this,"registry"),P(this,"nativeHost"),P(this,"options"),P(this,"lastResult"),P(this,"activeNativeLoader");var t;if(this.options={autoFit:!0,...e},this.registry=e.registry??Ou(e),e.loaders)for(const i of e.loaders)this.registry.register(i);if(this.canvas=e.canvas??document.createElement("canvas"),this.canvas.classList.add("cad-viewer-canvas"),e.container)e.container.classList.add("cad-viewer-container"),e.canvas||(this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",e.container.appendChild(this.canvas)),this.nativeHost=e.nativeHost??document.createElement("div"),this.nativeHost.classList.add("cad-viewer-native-host"),e.nativeHost||e.container.appendChild(this.nativeHost);else if(e.nativeHost)this.nativeHost=e.nativeHost,this.nativeHost.classList.add("cad-viewer-native-host");else if((t=e.canvas)!=null&&t.parentElement){e.canvas.parentElement.classList.add("cad-viewer-container");const i=document.createElement("div");i.classList.add("cad-viewer-native-host"),e.canvas.parentElement.appendChild(i),this.nativeHost=i}this.renderer=hf(e.renderer??"auto",this.canvas,e.canvasOptions),this.renderer.onStats=i=>{var r,s;return(s=(r=this.options).onRenderStats)==null?void 0:s.call(r,i)},this.renderer.onViewChange=i=>{var r,s;return(s=(r=this.options).onViewChange)==null?void 0:s.call(r,i)}}registerLoader(e){return this.registry.register(e),this}async loadFile(e,t={}){var i,r;return(r=(i=this.options).onLoadStart)==null||r.call(i,e),this.loadThroughRegistry({file:e,fileName:e.name},t,e.name)}async loadBuffer(e,t,i={}){var r,s;return(s=(r=this.options).onLoadStart)==null||s.call(r,e),this.loadThroughRegistry({buffer:e,fileName:t},i,t)}async load(e,t={}){var i,r,s;return(r=(i=this.options).onLoadStart)==null||r.call(i,e),this.loadThroughRegistry(e,t,e.fileName??((s=e.file)==null?void 0:s.name))}setDocument(e,t){var i,r;this.deactivateNativeRenderer();const s={document:e,raw:e.raw,bytes:0,elapsedMs:0,format:e.format,warnings:e.warnings,summary:li(e),fileName:t};return this.renderer.setDocument(e),this.options.autoFit||this.renderer.render(),this.lastResult=s,(r=(i=this.options).onLoad)==null||r.call(i,s),s}fit(){var e,t;this.activeNativeLoader?(t=(e=this.activeNativeLoader).fit)==null||t.call(e):this.renderer.fitToView()}zoomIn(){var e,t;this.activeNativeLoader?(t=(e=this.activeNativeLoader).zoomIn)==null||t.call(e):this.renderer.zoomIn()}zoomOut(){var e,t;this.activeNativeLoader?(t=(e=this.activeNativeLoader).zoomOut)==null||t.call(e):this.renderer.zoomOut()}resize(){var e,t;this.activeNativeLoader?(t=(e=this.activeNativeLoader).resize)==null||t.call(e):this.renderer.resize()}setCanvasOptions(e){var t,i;this.options.canvasOptions={...this.options.canvasOptions??{},...e},this.renderer.setOptions(e),this.activeNativeLoader&&((i=(t=this.activeNativeLoader).setNativeOptions)==null||i.call(t,{...this.mergeLoadOptions({}),dwfBackground:e.background??this.options.dwfBackground}))}async preloadDwg(e={}){const t=this.registry.list().find(i=>i.id==="dwg");if(!(t!=null&&t.preload))throw new Error("The registered DWG loader does not support preload().");return t.preload(this.mergeLoadOptions(e))}clear(){this.lastResult=void 0,this.deactivateNativeRenderer(),this.renderer.clear()}destroy(){var e,t,i;this.deactivateNativeRenderer();for(const r of this.registry.list()){const s=r;(e=s.terminateWorker)==null||e.call(s),(t=s.unmount)==null||t.call(s),(i=s.destroy)==null||i.call(s)}this.renderer.destroy()}getLoadResult(){return this.lastResult}getDocument(){var e;return this.activeNativeLoader?(e=this.lastResult)==null?void 0:e.document:this.renderer.getDocument()}getZoomPercent(){return this.activeNativeLoader?100:this.renderer.getZoomPercent()}isNativeRendererActive(){return!!this.activeNativeLoader}async loadThroughRegistry(e,t,i){var r,s;try{const n=this.mergeLoadOptions(t);jr(n.signal);const a=await this.registry.detect(e),o={...e,buffer:a.bytes};if(zu(a.loader))return await this.applyNativeLoadResult(a.loader,o,n,i);const l=await a.loader.load(o,n);return this.applyLoadResult(l,i)}catch(n){const a=df(n);throw(s=(r=this.options).onError)==null||s.call(r,a),a}}applyLoadResult(e,t){var i,r,s,n;this.deactivateNativeRenderer(),(r=(i=this.options).onLoadProgress)==null||r.call(i,{phase:"render",format:e.format,message:"Rendering normalized CAD scene…",percent:96}),this.renderer.setDocument(e.document),this.options.autoFit||this.renderer.render();const a={...e,fileName:t,summary:li(e.document)};return this.lastResult=a,(n=(s=this.options).onLoad)==null||n.call(s,a),a}async applyNativeLoadResult(e,t,i,r){var s,n,a;if(!this.nativeHost)throw new Error("Native DWF rendering requires CadViewerOptions.container, nativeHost, or a canvas parent element.");jr(i.signal),this.renderer.clear(),(s=this.activeNativeLoader)==null||s.unmount(),this.activeNativeLoader=e,this.canvas.style.display="none",this.nativeHost.classList.add("is-active");try{const o=await e.mount(t,this.nativeHost,i);jr(i.signal);const l={...o,fileName:r,summary:li(o.document)};return this.lastResult=l,this.emitNativeRenderStats(o),(a=(n=this.options).onLoad)==null||a.call(n,l),l}catch(o){throw this.deactivateNativeRenderer(),o}}deactivateNativeRenderer(){var e,t;if(!this.activeNativeLoader&&!((e=this.nativeHost)!=null&&e.classList.contains("is-active"))){this.canvas.style.display="";return}(t=this.activeNativeLoader)==null||t.unmount(),this.activeNativeLoader=void 0,this.nativeHost&&(this.nativeHost.classList.remove("is-active"),this.nativeHost.replaceChildren()),this.canvas.style.display=""}emitNativeRenderStats(e){var t,i,r,s;const n=e.document.metadata,a=Number(((t=n.nativeRenderStats)==null?void 0:t.commands)??e.document.entities.length??0),o=String(((i=n.nativeRenderStats)==null?void 0:i.backend)??"webgl").includes("webgl")?"webgl":"canvas2d";(s=(r=this.options).onRenderStats)==null||s.call(r,{total:a,drawn:a,skipped:0,byType:li(e.document).byType,unsupported:{},renderElapsedMs:e.elapsedMs,backend:o,primitiveCount:a,visiblePrimitiveCount:a,culledPrimitiveCount:0,gpuMemoryBytes:void 0,buildElapsedMs:e.elapsedMs})}mergeLoadOptions(e){const t=this.options.onProgress,i=e.onProgress;return{...this.options,...e,onProgress:r=>{var s,n;(n=(s=this.options).onLoadProgress)==null||n.call(s,r),t?.(r),i&&i!==t&&i(r)}}}}})),ff=xi({default:()=>pf});async function pf(e,t,i="dxf",r){var s;const n=xl(i),a=((s=r?.options)===null||s===void 0?void 0:s.cad)||{},o=mn(r?.options),l=At(r?.options);let c="loading",d=o("cad.state.loadingViewer"),h="",u=null,f=null,p=null,w=[],m=null,v=null,g=null,x=!1;const y=yl(),b=D("div","cad-shell");b.dataset.viewerZoomProvider="cad";const k=D("div","cad-toolbar"),T=D("div","cad-tools"),N=D("button",void 0,o("cad.toolbar.fit")),$=D("button",void 0,"-"),he=D("span","cad-zoom","100%"),fe=D("button",void 0,"+"),L=D("div","cad-meta"),z=D("span",void 0,n.toUpperCase()),ge=D("span",void 0,"AUTO");[N,$,fe].forEach(F=>{F.type="button"}),N.title=o("cad.toolbar.fit"),$.title=o("cad.toolbar.zoomOut"),fe.title=o("cad.toolbar.zoomIn"),T.append(N,$,he,fe),L.append(z,ge),k.append(T,L);const ye=D("div","cad-body without-layers"),Ne=D("aside","cad-layers");Ne.hidden=!0;const xe=D("div","cad-layers-head"),Et=D("span",void 0,o("cad.layers.count",{count:0}));xe.append(D("strong",void 0,o("cad.layers.title")),Et);const Pt=D("div","cad-layers-list");Ne.append(xe,Pt);const ke=D("div","cad-canvas-wrap"),Ee=D("div","cad-stage"),bi=D("div","cad-native-stage");Ee.append(bi);const $e=D("div","cad-state",d);ke.append(Ee,$e);const Cl=D("aside","cad-inspector"),bf=D("strong",void 0,o("cad.inspector.title")),Ml=D("dl"),wi=D("p","cad-warning");wi.hidden=!0,Cl.append(bf,Ml,wi),ye.append(Ne,ke,Cl),b.append(k,ye),t.replaceChildren(y,b);const Al=()=>r?.filename||`drawing.${n}`,wf=()=>u?.warnings||u?.document.warnings||[],Tl=()=>{var F,R,G;const ee=(G=(F=p?.zoomPercent)!==null&&F!==void 0?F:(R=m?.getZoomPercent)===null||R===void 0?void 0:R.call(m))!==null&&G!==void 0?G:100;return Number.isFinite(ee)?Math.round(ee):100},vi=()=>{const F=c==="ready"&&!!m,R=Tl();return{scale:R/100,label:`${R}%`,canZoomIn:F,canZoomOut:F,canReset:F,minScale:.05,maxScale:16}},He=Fi(),Fl=()=>{const F=u?.summary,R=[[o("cad.inspector.entities"),kt(F?.entityCount,l)],[o("cad.inspector.blocks"),kt(F?.blockCount,l)],[o("cad.inspector.pages"),kt(F?.pageCount,l)],[o("cad.inspector.drawn"),kt(f?.drawn,l)]];Ml.replaceChildren(...R.map(([ee,Ie])=>{const ct=D("div");return ct.append(D("dt",void 0,ee),D("dd",void 0,Ie)),ct}));const G=wf()[0];wi.textContent=G||"",wi.hidden=!G},vf=()=>{Et.textContent=o("cad.layers.count",{count:w.length}),Ne.hidden=w.length===0,ye.classList.toggle("without-layers",w.length===0),Pt.replaceChildren(...w.map(F=>{const R=D("button");R.type="button",R.classList.toggle("muted",F.isVisible===!1||!!F.isFrozen);const G=D("span","cad-layer-color");return typeof F.color=="string"&&(G.style.background=F.color),R.append(G,D("span",void 0,F.name)),R.addEventListener("click",()=>{const ee=m?.getDocument();if(!ee?.layers[F.name])return;const Ie=ee.layers[F.name];Ie.isVisible=Ie.isVisible===!1,u=m?.setDocument(ee,Al())||null,w=gi(u),lt(),queueMicrotask(()=>{m?.fit(),He.emit()})}),R}))},Pe=()=>{he.textContent=`${Tl()}%`,ge.textContent=(f?.backend||"auto").toUpperCase(),$e.hidden=c==="ready",$e.classList.toggle("error",c==="error"),c==="loading"?$e.textContent=d:c==="error"&&($e.textContent=h)},lt=()=>{Pe(),vf(),Fl()},yf=F=>{const R=F.format?`${F.format.toUpperCase()} `:"",G=Number.isFinite(F.percent)?` ${Math.round(F.percent||0)}%`:"";d=`${R}${F.message}${G}`,Pe()},Nl=()=>{m?.fit(),He.emit(),Pe()},Il=()=>{m?.zoomIn(),He.emit(),Pe()},_l=()=>{m?.zoomOut(),He.emit(),Pe()};Ai(b,{zoomIn:()=>(Il(),vi()),zoomOut:()=>(_l(),vi()),resetZoom:()=>(Nl(),vi()),getState:vi,subscribe:He.subscribe}),N.addEventListener("click",Nl),fe.addEventListener("click",Il),$.addEventListener("click",_l);const xf=()=>{var F,R,G,ee,Ie,ct,en;const{wasmPath:Ll,workerUrl:Dl,dwfWasmUrl:Ef}=ki(a,Qr(t)),Pf={background:"#f8fafc",foreground:"#0f172a",contrastMode:"adaptive",minColorContrast:2.4,showPageBounds:!0,showUnsupportedMarkers:!0,enableSpatialIndex:!0,maxVisibleTextLabels:2400,...a.canvasOptions||{}},Rl=new bl({container:Ee,nativeHost:bi,renderer:a.renderer||"auto",wasmPath:Ll,workerUrl:Dl,dwfWasmUrl:Ef,dxfEncoding:a.dxfEncoding,useWorker:(F=a.useWorker)!==null&&F!==void 0?F:!0,workerTimeoutMs:(R=a.workerTimeoutMs)!==null&&R!==void 0?R:wl,preferDwgWasm:(G=a.preferDwgWasm)!==null&&G!==void 0?G:!0,includePaperSpace:(ee=a.includePaperSpace)!==null&&ee!==void 0?ee:!0,maxInsertDepth:a.maxInsertDepth,keepRaw:(Ie=a.keepRaw)!==null&&Ie!==void 0?Ie:!1,dwfPreferWebgl:(ct=a.dwfPreferWebgl)!==null&&ct!==void 0?ct:!0,dwfPreferWasm:(en=a.dwfPreferWasm)!==null&&en!==void 0?en:!0,dwfBackground:a.dwfBackground||"#f8fafc",dwfMaxDevicePixelRatio:a.dwfMaxDevicePixelRatio,dwfMaxCanvasPixels:a.dwfMaxCanvasPixels,dwfMaxGpuCacheBytes:a.dwfMaxGpuCacheBytes,dwfMaxCachedScenes:a.dwfMaxCachedScenes,dwfLineWeightMode:a.dwfLineWeightMode,dwfMinStrokeCssPx:a.dwfMinStrokeCssPx,dwfMaxOverviewStrokeCssPx:a.dwfMaxOverviewStrokeCssPx,dwfMinTextCssPx:a.dwfMinTextCssPx,dwfMinFilledAreaCssPx:a.dwfMinFilledAreaCssPx,autoFit:!0,canvasOptions:Pf,onLoadProgress:yf,onRenderStats:_e=>{f=_e,Pe(),Fl()},onViewChange:_e=>{p=_e,He.emit(),Pe()},onLoad:_e=>{u=_e,w=gi(_e),lt()},onError:_e=>{h=_e.message||o("cad.error.parseFailed"),Pe()}});return a.preloadDwg!==!1&&n==="dwg"&&Rl.preloadDwg({wasmPath:Ll,workerUrl:Dl}).catch(()=>{}),Rl},kf=async()=>{c="loading",d=o("cad.state.parsing"),h="",u=null,f=null,p=null,w=[],lt(),g?.abort();const F=new AbortController;g=F;try{m?.destroy(),m=xf();const R=ki(a,Qr(t)),G=await m.loadBuffer(e.slice(0),Al(),{signal:F.signal,transferInputBuffer:!1,dxfEncoding:a.dxfEncoding,wasmPath:R.wasmPath,workerUrl:R.workerUrl,dwfWasmUrl:R.dwfWasmUrl});if(x||F.signal.aborted)return;u=G,w=gi(G),c="ready",lt(),queueMicrotask(()=>{m?.fit(),He.emit(),Pe()})}catch(R){if(x||F.signal.aborted)return;console.error(R),c="error",h=R instanceof Error?R.message:o("cad.error.parseFailed"),lt()}};return typeof ResizeObserver<"u"&&(v=new ResizeObserver(()=>{m?.resize()}),v.observe(Ee)),lt(),kf(),{$el:b,unmount(){x=!0,Ti(b),g?.abort(),g=null,v?.disconnect(),v=null,m?.destroy(),m=null,t.replaceChildren()}}}var wl,vl,yl,D,xl,gi,kt,Qr,mf=E((()=>{uf(),an(),Xn(),wl=12e4,vl=`
|
|
121
|
+
.cad-shell{display:flex;height:100%;min-height:100%;flex-direction:column;background:#f5f7fb;color:#142335}
|
|
122
|
+
.cad-shell *{box-sizing:border-box}
|
|
123
|
+
.cad-toolbar{display:flex;min-height:48px;align-items:center;justify-content:space-between;gap:16px;padding:0 14px;border-bottom:1px solid rgba(15,23,42,.08);background:#fff}
|
|
124
|
+
.cad-tools,.cad-meta{display:flex;align-items:center;gap:8px}
|
|
125
|
+
.cad-tools button{min-width:34px;min-height:30px;border:0;border-radius:8px;background:rgba(15,23,42,.06);color:#25344c;cursor:pointer;font-weight:800;letter-spacing:0;transition:background-color .18s ease,color .18s ease}
|
|
126
|
+
.cad-tools button:hover{background:rgba(31,150,110,.14);color:#0f8f62}
|
|
127
|
+
.cad-zoom,.cad-meta span{color:#64748b;font-size:12px;font-weight:800;letter-spacing:0}
|
|
128
|
+
.cad-meta span{border-radius:999px;padding:5px 9px;background:rgba(15,23,42,.06)}
|
|
129
|
+
.cad-body{display:grid;min-height:0;flex:1;grid-template-columns:minmax(168px,220px) minmax(0,1fr) minmax(150px,190px);background:#eef2f7}
|
|
130
|
+
.cad-body.without-layers{grid-template-columns:minmax(0,1fr) minmax(150px,190px)}
|
|
131
|
+
.cad-layers,.cad-inspector{min-height:0;overflow:auto;border-right:1px solid rgba(15,23,42,.08);background:#fff}
|
|
132
|
+
.cad-layers[hidden]{display:none}
|
|
133
|
+
.cad-inspector{border-right:0;border-left:1px solid rgba(15,23,42,.08);padding:14px}
|
|
134
|
+
.cad-layers-head{position:sticky;top:0;display:flex;align-items:center;justify-content:space-between;padding:12px 12px 8px;background:#fff;color:#1f2a3d;font-size:13px;z-index:1}
|
|
135
|
+
.cad-layers-head span{color:#7b8ca5;font-size:12px;font-weight:700}
|
|
136
|
+
.cad-layers-list{display:flex;flex-direction:column;padding:0 0 8px}
|
|
137
|
+
.cad-layers button{display:flex;width:calc(100% - 16px);min-height:34px;align-items:center;gap:8px;margin:0 8px 6px;border:1px solid rgba(148,163,184,.22);border-radius:8px;background:#f8fafc;color:#25344c;cursor:pointer;font-size:12px;font-weight:700;text-align:left}
|
|
138
|
+
.cad-layers button.muted{opacity:.48}
|
|
139
|
+
.cad-layer-color{width:10px;height:10px;flex:0 0 auto;border-radius:50%;background:#1f966e;box-shadow:inset 0 0 0 1px rgba(15,23,42,.14)}
|
|
140
|
+
.cad-canvas-wrap{position:relative;min-width:0;min-height:0;overflow:hidden;background:linear-gradient(90deg,rgba(15,23,42,.04) 1px,transparent 1px),linear-gradient(180deg,rgba(15,23,42,.04) 1px,transparent 1px),#f8fafc;background-size:28px 28px}
|
|
141
|
+
.cad-stage{position:relative;width:100%;height:100%;min-height:420px;overflow:hidden}
|
|
142
|
+
.cad-stage canvas{position:absolute;inset:0;display:block;width:100%!important;height:100%!important}
|
|
143
|
+
.cad-native-stage{position:absolute;inset:0;z-index:2;display:none;overflow:hidden}
|
|
144
|
+
.cad-native-stage:not(:empty),.cad-native-stage.is-active{display:block}
|
|
145
|
+
.cad-native-stage *{box-sizing:border-box}
|
|
146
|
+
.dwfv-root{height:100%;min-height:0;display:grid;grid-template-rows:auto 1fr;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;color:#111827}
|
|
147
|
+
.dwfv-toolbar{display:flex;gap:8px;align-items:center;padding:8px 12px;background:#fff;border-bottom:1px solid #e5e7eb}
|
|
148
|
+
.dwfv-toolbar button,.dwfv-toolbar select{font:inherit}
|
|
149
|
+
.dwfv-workspace{min-height:0;display:grid;grid-template-columns:minmax(220px,300px) 1fr}
|
|
150
|
+
.dwfv-tree{overflow:auto;border-right:1px solid #d6d8dd;background:#fff;font-size:12px;padding:8px}
|
|
151
|
+
.dwfv-tree[style*="display: none"]+.dwfv-stage{grid-column:1/-1}
|
|
152
|
+
.dwfv-tree-header{font-weight:700;margin-bottom:4px}
|
|
153
|
+
.dwfv-tree-stats{color:#6b7280;margin-bottom:8px}
|
|
154
|
+
.dwfv-tree details{margin-left:8px}
|
|
155
|
+
.dwfv-tree summary{cursor:pointer;padding:2px 0}
|
|
156
|
+
.dwfv-tree-meta{color:#6b7280;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;padding-left:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
157
|
+
.dwfv-stage{position:relative;overflow:hidden;background:#e5e7eb}
|
|
158
|
+
.dwfv-canvas{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}
|
|
159
|
+
.dwfv-webgl-canvas{pointer-events:none}
|
|
160
|
+
.dwfv-overlay-canvas{pointer-events:auto;touch-action:none;cursor:grab}
|
|
161
|
+
.dwfv-overlay-canvas:active{cursor:grabbing}
|
|
162
|
+
.dwfv-status{margin-left:auto;font-size:12px;color:#4b5563}
|
|
163
|
+
.dwfv-warn{color:#92400e}
|
|
164
|
+
.cad-viewer-container{position:relative;overflow:hidden;min-width:0;min-height:0}
|
|
165
|
+
.cad-viewer-canvas{display:block;width:100%;height:100%;cursor:grab;touch-action:none;-webkit-user-select:none;user-select:none}
|
|
166
|
+
.cad-viewer-canvas.is-dragging{cursor:grabbing}
|
|
167
|
+
.cad-viewer-webgl-canvas{position:relative;z-index:0}
|
|
168
|
+
.cad-viewer-text-overlay{display:block;contain:strict;-webkit-user-select:none;user-select:none}
|
|
169
|
+
.cad-viewer-native-host{position:absolute;top:0;right:0;bottom:0;left:0;display:none;z-index:2;min-width:0;min-height:0;background:#05070d}
|
|
170
|
+
.cad-viewer-native-host.is-active{display:block}
|
|
171
|
+
.cad-viewer-native-host .dwfv-root{height:100%;min-height:0;color:#dbeafe;background:#05070d}
|
|
172
|
+
.cad-viewer-native-host .dwfv-toolbar{min-height:34px;padding:5px 8px;gap:6px;border-bottom:1px solid rgba(71,85,105,.65);background:#0f172af5;color:#e5e7eb}
|
|
173
|
+
.cad-viewer-native-host .dwfv-toolbar button,.cad-viewer-native-host .dwfv-toolbar select{height:24px;border:1px solid rgba(100,116,139,.75);border-radius:6px;background:#111827;color:#e5e7eb;font-size:12px}
|
|
174
|
+
.cad-viewer-native-host .dwfv-toolbar button{padding:0 8px;cursor:pointer}
|
|
175
|
+
.cad-viewer-native-host .dwfv-toolbar button:hover,.cad-viewer-native-host .dwfv-toolbar select:hover{border-color:#60a5fa;color:#bfdbfe}
|
|
176
|
+
.cad-viewer-native-host .dwfv-status{color:#93c5fd;font-size:12px}
|
|
177
|
+
.cad-viewer-native-host .dwfv-workspace{min-height:0;background:#05070d}
|
|
178
|
+
.cad-viewer-native-host .dwfv-stage{background:#05070d}
|
|
179
|
+
.cad-viewer-native-host .dwfv-tree{border-right:1px solid rgba(71,85,105,.7);background:#0f172a;color:#dbeafe}
|
|
180
|
+
.cad-viewer-native-host .dwfv-tree-stats,.cad-viewer-native-host .dwfv-tree-meta{color:#94a3b8}
|
|
181
|
+
.cad-viewer-native-host .dwfv-warn{color:#fbbf24}
|
|
182
|
+
.cad-native-stage .dwfv-root,.cad-native-stage .dwfv-workspace,.cad-native-stage .dwfv-stage{width:100%;min-width:0;min-height:0}
|
|
183
|
+
.cad-native-stage .dwfv-root{height:100%}
|
|
184
|
+
.cad-state{position:absolute;inset:50% auto auto 50%;max-width:min(520px,calc(100% - 48px));transform:translate(-50%,-50%);border-radius:12px;padding:14px 18px;background:rgba(255,255,255,.92);box-shadow:0 14px 38px rgba(15,23,42,.12);color:#53637a;font-size:13px;font-weight:800;text-align:center}
|
|
185
|
+
.cad-state[hidden]{display:none!important}
|
|
186
|
+
.cad-state.error{color:#b42318}
|
|
187
|
+
.cad-inspector strong{display:block;margin-bottom:12px;color:#1f2a3d;font-size:13px}
|
|
188
|
+
.cad-inspector dl{display:grid;gap:8px;margin:0}
|
|
189
|
+
.cad-inspector dl div{display:flex;align-items:center;justify-content:space-between;gap:12px;border-radius:8px;padding:8px 10px;background:#f8fafc}
|
|
190
|
+
.cad-inspector dt,.cad-inspector dd{margin:0;font-size:12px}
|
|
191
|
+
.cad-inspector dt{color:#7b8ca5;font-weight:700}
|
|
192
|
+
.cad-inspector dd{color:#20304a;font-weight:900}
|
|
193
|
+
.cad-warning{margin:12px 0 0;border-radius:8px;padding:10px;background:rgba(245,158,11,.13);color:#92400e;font-size:12px;line-height:1.55}
|
|
194
|
+
.file-viewer[data-viewer-theme='dark'] .cad-shell{background:#111827;color:#e5edf6}
|
|
195
|
+
.file-viewer[data-viewer-theme='dark'] .cad-toolbar,.file-viewer[data-viewer-theme='dark'] .cad-layers,.file-viewer[data-viewer-theme='dark'] .cad-inspector{background:#fff;color:#142335}
|
|
196
|
+
@media (prefers-color-scheme:dark){.file-viewer[data-viewer-theme='system'] .cad-shell{background:#111827;color:#e5edf6}.file-viewer[data-viewer-theme='system'] .cad-toolbar,.file-viewer[data-viewer-theme='system'] .cad-layers,.file-viewer[data-viewer-theme='system'] .cad-inspector{background:#fff;color:#142335}}
|
|
197
|
+
@media (max-width:860px){.cad-body,.cad-body.without-layers{grid-template-columns:minmax(0,1fr)}.cad-layers,.cad-inspector{display:none}}
|
|
198
|
+
`,yl=()=>{const e=document.createElement("style");return e.textContent=vl,e},D=(e,t,i)=>{const r=document.createElement(e);return t&&(r.className=t),i!==void 0&&(r.textContent=i),r},xl=e=>(e||"dxf").toLowerCase(),gi=e=>e?Object.entries(e.document.layers).map(([t,i])=>({...i,name:t})).sort((t,i)=>t.name.localeCompare(i.name)):[],kt=(e,t="zh-CN")=>Number.isFinite(e)?new Intl.NumberFormat(t).format(Math.round(e||0)):"0",Qr=e=>{var t;return((t=e.ownerDocument)===null||t===void 0?void 0:t.baseURI)||"http://localhost/"}}));Xn();var kl=be.find(e=>e.id==="cad");if(!kl)throw new Error("@file-viewer/renderer-cad could not locate the shared CAD format definition.");var El=kl,gf=(e,t,i,r)=>Promise.resolve().then(()=>(mf(),ff)).then(({default:s})=>s(e,t,i,r)),Jr={id:"file-viewer-renderer-cad",label:"Flyfish File Viewer CAD renderer",definitions:[El],handlers:[{rendererId:El.id,handler:gf}]},Pl=globalThis,Sl=Pl.FlyfishFileViewerWebFullRenderers||(Pl.FlyfishFileViewerWebFullRenderers={});Sl.cad=Jr,Sl[Jr.id]=Jr})();
|