filens-preview 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +4 -4
  2. package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +583 -0
  3. package/dist/all-in-one/filens.js +305 -305
  4. package/dist/index.d.ts +1 -1
  5. package/dist/split/THIRD-PARTY-NOTICES.txt +583 -0
  6. package/dist/split/chunks/{archive-haip2eOP.js → archive-BT6evXzB.js} +1 -1
  7. package/dist/split/chunks/{browser-video-session-C_14e_mG.js → browser-video-session-BX-bBV8b.js} +1 -1
  8. package/dist/split/chunks/{cad-5oTkbaDV.js → cad-D4xpsKTK.js} +1 -1
  9. package/dist/split/chunks/{core-EjELrtsP.js → core-DMIUha7u.js} +10 -10
  10. package/dist/split/chunks/{diagram-BRcdlitF.js → diagram-DEaht2P0.js} +1 -1
  11. package/dist/split/chunks/{docx-I39iDYpR.js → docx-CDkeTBtm.js} +1 -1
  12. package/dist/split/chunks/{ebook-BRfadCGl.js → ebook-Hm8yI-Uy.js} +1 -1
  13. package/dist/split/chunks/index-JSBoG8MK.js +1 -0
  14. package/dist/split/chunks/{index-DkF8PBGR.js → index-cyA_1amh.js} +1 -1
  15. package/dist/split/chunks/{iwork-DXq9Adf7.js → iwork-Drn02EYr.js} +1 -1
  16. package/dist/split/chunks/{media-runtime-B6322raw.js → media-runtime-C31OgCrW.js} +1 -1
  17. package/dist/split/chunks/{mindmap-CyR3TRfx.js → mindmap-CZvf6m9O.js} +1 -1
  18. package/dist/split/chunks/{model3d-BEt6INTt.js → model3d-DXfxzjT8.js} +1 -1
  19. package/dist/split/chunks/{panorama-ChsqnvWC.js → panorama-COXaZ8XC.js} +10 -10
  20. package/dist/split/chunks/vendor-C8SyXchM.js +4115 -0
  21. package/dist/split/chunks/{xlsx-CITQo0Od.js → xlsx-bMXHZBbO.js} +1 -1
  22. package/dist/split/converter-core.wasm +0 -0
  23. package/dist/split/converter-office.wasm +0 -0
  24. package/dist/split/converter-postscript.wasm +0 -0
  25. package/dist/split/filens.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/split/chunks/index-C4jdVbDq.js +0 -1
  28. package/dist/split/chunks/vendor-C1aIdQ-w.js +0 -4115
@@ -1 +1 @@
1
- var U=Object.defineProperty;var j=(e,t,n)=>t in e?U(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var d=(e,t,n)=>j(e,typeof t!="symbol"?t+"":t,n);import{c as G,b as R}from"./core-EjELrtsP.js";import{J as O}from"./vendor-C1aIdQ-w.js";const _=[{extensions:["mm","opml","xmind","mmap"],family:"mindmap",driverId:"mindmap",targetFormat:"mindmap",contentTypes:["text/x-opml","application/x-freemind","application/x-xmind","application/vnd.xmind.workbook","application/x-mindmanager","application/vnd.mindjet.mindmanager"]}],D=new Set(["mm","opml","xmind","mmap"]),y="http://www.w3.org/2000/svg",b=34,J=110,I=260,W=90,H=20,E=36;class V{constructor(t,n={}){d(this,"listeners",{loading:new Set,rendered:new Set,error:new Set,statechange:new Set,warnings:new Set});d(this,"root");d(this,"scale");d(this,"fitMode");d(this,"canvasSize");d(this,"resizeObserver");d(this,"document",null);d(this,"loadGeneration",0);d(this,"loadController");d(this,"removeAbortListener");d(this,"selectedNodeId");d(this,"state");this.host=t,this.scale=n.initialScale??1,this.fitMode=n.fit??"contain",this.root=document.createElement("div"),this.root.className="mindmapv-preview",this.host.replaceChildren(this.root),this.state={loading:false,error:null,family:"mindmap",warnings:[],capabilities:{zoom:true,fit:true,pan:true,outline:true,search:true,fullscreen:true,metadata:true,download:true},scale:this.scale},typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{if(this.fitMode==="none")return;const r=this.scale;this.applyScale(),this.scale!==r&&this.emit("statechange",this.state)}))}async load(t,n){var a,c,f;const r=++this.loadGeneration;(a=this.loadController)==null||a.abort(),(c=this.removeAbortListener)==null||c.call(this),this.releaseDocument();const i=new AbortController;this.loadController=i;const o=n.signal,s=()=>{i.abort(),r===this.loadGeneration&&(this.releaseDocument(),this.state.loading=false,this.emit("statechange",this.state))};o==null||o.addEventListener("abort",s,{once:true}),this.removeAbortListener=()=>o==null?void 0:o.removeEventListener("abort",s),this.state={...this.state,loading:true,error:null,title:n.descriptor.name,warnings:[],selectedNodeId:void 0},this.emit("loading",this.state),this.emit("statechange",this.state);try{o!=null&&o.aborted&&i.abort(),l(i.signal);const p=$(((f=n.route)==null?void 0:f.sourceFormat)??n.descriptor.extension);if(!D.has(p))throw new Error(`Mind-map preview currently supports FreeMind MM, OPML, XMind, and MindManager MMAP files, got ${p||"unknown"}.`);const w={...n,signal:i.signal};let N;if(p==="xmind"||p==="mmap"){const x=await ft(t,w);l(i.signal),N=await(p==="xmind"?Y(x,w):Z(x,w))}else{const x=await ut(t,w);l(i.signal),N=q(x,p)}if(r!==this.loadGeneration)return;l(i.signal),this.document=N,this.selectedNodeId=this.document.root.id,this.state={...this.state,loading:false,error:null,title:this.document.title??n.descriptor.name,selectedNodeId:this.selectedNodeId,scale:this.scale},this.render(),R(this.root,{getScale:()=>this.state.scale,setScale:x=>this.setScale(x),signal:i.signal}),this.emit("rendered",this.state),this.emit("statechange",this.state)}catch(p){if(r!==this.loadGeneration)return;this.releaseDocument(),this.state.loading=false,l(i.signal);const w=p instanceof Error?p:new Error(String(p));throw this.state.error=w.message,this.emit("error",w),this.emit("statechange",this.state),w}}destroy(){var t,n;this.loadGeneration++,(t=this.loadController)==null||t.abort(),(n=this.removeAbortListener)==null||n.call(this),this.releaseDocument(),this.state.loading=false,this.root.parentElement===this.host&&this.host.replaceChildren();for(const r of Object.values(this.listeners))r.clear()}getState(){return{...this.state,warnings:[...this.state.warnings],selectedNodeId:this.selectedNodeId}}on(t,n){return this.listeners[t].add(n),()=>{this.listeners[t].delete(n)}}setScale(t){Number.isFinite(t)&&(this.scale=Math.max(.25,Math.min(t,3)),this.fitMode="none",this.state.scale=this.scale,this.applyScale(),this.emit("statechange",this.state))}fit(t="contain"){this.fitMode=t,t==="none"&&(this.scale=1),this.applyScale(),this.state.scale=this.scale,this.root.scrollLeft=0,this.root.scrollTop=0,this.emit("statechange",this.state)}pan(t,n){this.root.scrollLeft+=t,this.root.scrollTop+=n}async fullscreen(){var t,n;await((n=(t=this.root).requestFullscreen)==null?void 0:n.call(t))}render(){var s,a,c;if(!this.document){this.root.replaceChildren();return}const t=at(this.document.root),n=ct(t);this.canvasSize=n;const r=document.createElement("div");r.className="mindmapv-canvas-wrap",r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;const i=document.createElementNS(y,"svg");i.classList.add("mindmapv-canvas"),i.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),i.setAttribute("role","img"),i.setAttribute("aria-label",this.document.title??"Mind map preview"),i.appendChild(lt(t)),i.appendChild(dt(t,this.selectedNodeId,f=>this.selectNode(f))),r.appendChild(i);const o=document.createElement("div");o.className="mindmapv-summary",o.textContent=`${this.document.nodeCount} node${this.document.nodeCount===1?"":"s"}`,(s=this.resizeObserver)==null||s.disconnect(),this.root.replaceChildren(o,r),this.applyScale(),(a=this.resizeObserver)==null||a.observe(this.root),(c=this.resizeObserver)==null||c.observe(o)}selectNode(t){if(!t){this.selectedNodeId=void 0,this.state.selectedNodeId=void 0,this.root.querySelectorAll(".mindmapv-node").forEach(n=>{n.classList.remove("is-selected")}),this.emit("statechange",this.state);return}this.selectedNodeId=t,this.state.selectedNodeId=t,this.root.querySelectorAll(".mindmapv-node").forEach(n=>{n.classList.toggle("is-selected",n.getAttribute("data-node-id")===t)}),this.emit("statechange",this.state)}applyScale(){const t=this.root.querySelector(".mindmapv-canvas-wrap");if(!(!t||!this.canvasSize)){if(this.fitMode!=="none"){const n=this.root.clientWidth,r=this.root.clientHeight-this.root.firstElementChild.offsetHeight;if(n>0&&r>0){const i=n/this.canvasSize.width,o=r/this.canvasSize.height;this.scale=this.fitMode==="width"?i:this.fitMode==="height"?o:Math.min(i,o)}}this.state.scale=this.scale,t.style.width=`${this.canvasSize.width*this.scale}px`,t.style.height=`${this.canvasSize.height*this.scale}px`}}releaseDocument(){var t;(t=this.resizeObserver)==null||t.disconnect(),this.canvasSize=void 0,this.document=null,this.selectedNodeId=void 0,this.state.selectedNodeId=void 0,this.root.replaceChildren()}emit(t,n){for(const r of this.listeners[t])r(n)}}function At(){return{id:"mindmap",family:"mindmap",supports:e=>D.has($(e)),createSession:(e,t)=>new V(e,t)}}function vt(e=G()){return[..._,...e.filter(t=>!t.extensions.some(n=>D.has(n)))]}function q(e,t){const n=new DOMParser().parseFromString(e,"application/xml");if(n.getElementsByTagName("parsererror")[0])throw new Error("Mind-map XML is invalid.");const i=$(t)==="opml"||m(n.documentElement)==="opml"?it(n):nt(n);return{title:i.text,root:i,nodeCount:A(i)}}async function Y(e,t={}){l(t.signal);const n=await O.loadAsync(e);l(t.signal);const r=n.file("content.json");if(r){const o=await r.async("text");return l(t.signal),rt(o)}const i=n.file("content.xml");if(i){const o=await i.async("text");return l(t.signal),st(o)}throw new Error("XMind package is missing content.json or content.xml.")}async function Z(e,t={}){l(t.signal);const n=await O.loadAsync(e);l(t.signal);const r=n.file("Document.xml")??n.file("document.xml")??n.file(/(^|\/)document\.xml$/i)[0];if(!r)throw new Error("MindManager package is missing Document.xml.");const i=await r.async("text");return l(t.signal),K(i)}function K(e){const t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror")[0])throw new Error("MindManager Document.xml is invalid.");const n=Array.from(t.getElementsByTagName("*")).filter(o=>m(o)==="topic");if(!n.length)throw new Error("MindManager Document.xml does not contain topic nodes.");const r=n.find(o=>!Q(o))??n[0],i=B(r,"mmap-root");return{title:i.text,root:i,nodeCount:A(i)}}function Q(e){let t=e.parentElement;for(;t;){if(m(t)==="topic")return true;t=t.parentElement}return false}function B(e,t){var o;const n=L(e,"id")||t,r=v(L(e,"text")||((o=u(e,"text")[0])==null?void 0:o.textContent)||e.textContent||"Untitled"),i=tt(e).map((s,a)=>B(s,`${n}-${a+1}`));return{id:n,text:r,children:i}}function tt(e){const t=[],n=r=>{for(const i of Array.from(r.children)){if(m(i)==="topic"){t.push(i);continue}et(i)&&n(i)}};return n(e),t}function et(e){return Array.from(e.getElementsByTagName("*")).some(t=>m(t)==="topic")}function L(e,t){const n=t.toLowerCase();for(const r of Array.from(e.attributes))if(r.name.toLowerCase()===n)return r.value}function nt(e){const t=Array.from(e.getElementsByTagName("*")).find(n=>m(n)==="node");if(!t)throw new Error("FreeMind MM file does not contain a root node.");return z(t,"mm",t.parentElement?mt(t):"")}function z(e,t,n){const r=e.getAttribute("ID")||`${t}-${n||"1"}`,i=v(e.getAttribute("TEXT")||e.getAttribute("text")||"Untitled"),o=u(e,"node").map((s,a)=>z(s,`${r}-${a+1}`,n?`${n}-${a+1}`:String(a+1)));return{id:r,text:i,children:o}}function it(e){var i,o;const t=Array.from(e.getElementsByTagName("*")).find(s=>m(s)==="body"),n=(o=(i=Array.from(e.getElementsByTagName("*")).find(s=>m(s)==="title"))==null?void 0:i.textContent)==null?void 0:o.trim(),r=t?u(t,"outline"):[];if(!r.length)throw new Error("OPML file does not contain outline nodes.");if(r.length===1){const s=C(r[0],"opml-1");return n&&s.text==="Untitled"?{...s,text:n}:s}return{id:"opml-root",text:n||"OPML",children:r.map((s,a)=>C(s,`opml-${a+1}`))}}function C(e,t){const n=v(e.getAttribute("text")||e.getAttribute("title")||"Untitled");return{id:t,text:n,children:u(e,"outline").map((r,i)=>C(r,`${t}-${i+1}`))}}function rt(e){let t;try{t=JSON.parse(e)}catch{throw new Error("XMind content.json is invalid.")}const r=(Array.isArray(t)?t:[t]).find(s=>s&&typeof s=="object");if(!r)throw new Error("XMind content.json does not contain a sheet.");const i=h(r.rootTopic)??h(r.centralTopic)??h(r.topic);if(!i)throw new Error("XMind content.json does not contain a root topic.");const o=F(i,"xmind-json-1");return{title:g(r.title)||o.text,root:o,nodeCount:A(o)}}function F(e,t){const n=g(e.id)||g(e.uuid)||t,r=v(g(e.title)||g(e.text)||wt(e)||"Untitled"),i=ot(e).map((o,s)=>F(o,`${n}-${s+1}`));return{id:n,text:r,children:i}}function ot(e){var s;const t=[],n=e.children;Array.isArray(n)&&t.push(...n.map(h).filter(M));const r=h(n);if(r)for(const a of["attached","detached","floating","summary"]){const c=r[a],f=Array.isArray(c)?c:(s=h(c))==null?void 0:s.topics;Array.isArray(f)&&t.push(...f.map(h).filter(M))}const i=e.subTopics??e.subtopics;Array.isArray(i)&&t.push(...i.map(h).filter(M));const o=h(i);if(o)for(const a of Object.values(o))Array.isArray(a)&&t.push(...a.map(h).filter(M));return t}function st(e){var s,a;const t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror")[0])throw new Error("XMind content.xml is invalid.");const n=Array.from(t.getElementsByTagName("*")).find(c=>m(c)==="sheet")??t.documentElement,r=u(n,"topic")[0]??Array.from(t.getElementsByTagName("*")).find(c=>m(c)==="topic");if(!r)throw new Error("XMind content.xml does not contain a root topic.");const i=X(r,"xmind-xml-1");return{title:((a=(s=u(n,"title")[0])==null?void 0:s.textContent)==null?void 0:a.trim())||i.text,root:i,nodeCount:A(i)}}function X(e,t){var o;const n=e.getAttribute("id")||t,r=((o=u(e,"title")[0])==null?void 0:o.textContent)??e.getAttribute("title")??e.getAttribute("text")??"Untitled",i=u(e,"children").flatMap(s=>u(s,"topics")).flatMap(s=>u(s,"topic")).map((s,a)=>X(s,`${n}-${a+1}`));return{id:n,text:v(r),children:i}}function at(e){const t=P(e,0);let n=E;const r=i=>{if(i.x=E+i.depth*(I+W),i.width=k(i.text),i.height=b,!i.children.length){i.y=n,n+=b+H;return}for(const o of i.children)r(o);i.y=(i.children[0].y+i.children[i.children.length-1].y)/2};return r(t),t}function P(e,t){return{...e,x:0,y:0,width:k(e.text),height:b,depth:t,children:e.children.map(n=>P(n,t+1))}}function ct(e){let t=0,n=0;return S(e,r=>{t=Math.max(t,r.x+r.width+E),n=Math.max(n,r.y+r.height+E)}),{width:Math.max(360,t),height:Math.max(260,n)}}function lt(e){const t=document.createElementNS(y,"g");return t.classList.add("mindmapv-links"),S(e,n=>{for(const r of n.children){const i=document.createElementNS(y,"path"),o=n.x+n.width,s=n.y+b/2,a=r.x,c=r.y+b/2,f=o+(a-o)*.5;i.setAttribute("d",`M ${o} ${s} C ${f} ${s}, ${f} ${c}, ${a} ${c}`),t.appendChild(i)}}),t}function dt(e,t,n){const r=document.createElementNS(y,"g");return r.classList.add("mindmapv-nodes"),S(e,i=>{const o=document.createElementNS(y,"g");o.classList.add("mindmapv-node"),i.id===t&&o.classList.add("is-selected"),o.setAttribute("data-node-id",i.id),o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.setAttribute("aria-label",i.text),o.addEventListener("click",()=>n(i.id)),o.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(i.id))});const s=document.createElementNS(y,"rect");s.setAttribute("x",String(i.x)),s.setAttribute("y",String(i.y)),s.setAttribute("width",String(i.width)),s.setAttribute("height",String(b)),s.setAttribute("rx","6");const a=document.createElementNS(y,"text");a.setAttribute("x",String(i.x+14)),a.setAttribute("y",String(i.y+22)),a.textContent=ht(i.text),o.append(s,a),r.appendChild(o)}),r}function S(e,t){t(e);for(const n of e.children)S(n,t)}function k(e){return Math.max(J,Math.min(I,e.length*8+34))}function ht(e){return e.length>34?`${e.slice(0,31)}...`:e}function A(e){return 1+e.children.reduce((t,n)=>t+A(n),0)}function u(e,t){return Array.from(e.children).filter(n=>m(n)===t)}function m(e){return e.localName.toLowerCase()}function v(e){return e.replace(/\s+/g," ").trim()||"Untitled"}function mt(e){const t=[];let n=e;for(;n!=null&&n.parentElement;){const r=u(n.parentElement,m(n));t.unshift(r.indexOf(n)+1),n=n.parentElement}return t.join("-")||"1"}async function ut(e,t){if(l(t.signal),typeof e=="string"){if(e.trimStart().toLowerCase().startsWith("data:"))return pt(e);const n=await fetch(e,{signal:t.signal});if(l(t.signal),!n.ok)throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());return n.text()}return e instanceof Blob?e.text():ArrayBuffer.isView(e)?new TextDecoder().decode(e):e instanceof ArrayBuffer?new TextDecoder().decode(e):String(e)}async function ft(e,t){if(l(t.signal),typeof e=="string"){if(e.trimStart().toLowerCase().startsWith("data:"))return T(gt(e));const n=await fetch(e,{signal:t.signal});if(l(t.signal),!n.ok)throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());return n.arrayBuffer()}if(e instanceof Blob)return e.arrayBuffer();if(ArrayBuffer.isView(e)){const n=new Uint8Array(e.byteLength);return n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),T(n)}return e instanceof ArrayBuffer?e:T(new TextEncoder().encode(String(e)))}function l(e){if(e!=null&&e.aborted)throw new DOMException("Mind-map preview aborted.","AbortError")}function pt(e){const t=e.indexOf(",");if(t<0)return e;const n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.endsWith(";base64")?new TextDecoder().decode(Uint8Array.from(atob(r),i=>i.charCodeAt(0))):decodeURIComponent(r)}function gt(e){const t=e.indexOf(",");if(t<0)return new TextEncoder().encode(e);const n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.endsWith(";base64")?Uint8Array.from(atob(r),i=>i.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(r))}function T(e){const t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function $(e){return String(e??"").trim().replace(/^\./,"").toLowerCase()}function h(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function M(e){return e!==void 0}function g(e){return typeof e=="string"?e.trim():""}function wt(e){const t=h(e.title),n=h(e.text);return g(t==null?void 0:t.plain)||g(t==null?void 0:t.content)||g(n==null?void 0:n.plain)||g(n==null?void 0:n.content)}export{vt as a,At as c};
1
+ var U=Object.defineProperty;var j=(e,t,n)=>t in e?U(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var d=(e,t,n)=>j(e,typeof t!="symbol"?t+"":t,n);import{c as G,b as R}from"./core-DMIUha7u.js";import{J as O}from"./vendor-C8SyXchM.js";const _=[{extensions:["mm","opml","xmind","mmap"],family:"mindmap",driverId:"mindmap",targetFormat:"mindmap",contentTypes:["text/x-opml","application/x-freemind","application/x-xmind","application/vnd.xmind.workbook","application/x-mindmanager","application/vnd.mindjet.mindmanager"]}],D=new Set(["mm","opml","xmind","mmap"]),y="http://www.w3.org/2000/svg",b=34,J=110,I=260,W=90,H=20,E=36;class V{constructor(t,n={}){d(this,"listeners",{loading:new Set,rendered:new Set,error:new Set,statechange:new Set,warnings:new Set});d(this,"root");d(this,"scale");d(this,"fitMode");d(this,"canvasSize");d(this,"resizeObserver");d(this,"document",null);d(this,"loadGeneration",0);d(this,"loadController");d(this,"removeAbortListener");d(this,"selectedNodeId");d(this,"state");this.host=t,this.scale=n.initialScale??1,this.fitMode=n.fit??"contain",this.root=document.createElement("div"),this.root.className="mindmapv-preview",this.host.replaceChildren(this.root),this.state={loading:false,error:null,family:"mindmap",warnings:[],capabilities:{zoom:true,fit:true,pan:true,outline:true,search:true,fullscreen:true,metadata:true,download:true},scale:this.scale},typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{if(this.fitMode==="none")return;const r=this.scale;this.applyScale(),this.scale!==r&&this.emit("statechange",this.state)}))}async load(t,n){var a,c,f;const r=++this.loadGeneration;(a=this.loadController)==null||a.abort(),(c=this.removeAbortListener)==null||c.call(this),this.releaseDocument();const i=new AbortController;this.loadController=i;const o=n.signal,s=()=>{i.abort(),r===this.loadGeneration&&(this.releaseDocument(),this.state.loading=false,this.emit("statechange",this.state))};o==null||o.addEventListener("abort",s,{once:true}),this.removeAbortListener=()=>o==null?void 0:o.removeEventListener("abort",s),this.state={...this.state,loading:true,error:null,title:n.descriptor.name,warnings:[],selectedNodeId:void 0},this.emit("loading",this.state),this.emit("statechange",this.state);try{o!=null&&o.aborted&&i.abort(),l(i.signal);const p=$(((f=n.route)==null?void 0:f.sourceFormat)??n.descriptor.extension);if(!D.has(p))throw new Error(`Mind-map preview currently supports FreeMind MM, OPML, XMind, and MindManager MMAP files, got ${p||"unknown"}.`);const w={...n,signal:i.signal};let N;if(p==="xmind"||p==="mmap"){const x=await ft(t,w);l(i.signal),N=await(p==="xmind"?Y(x,w):Z(x,w))}else{const x=await ut(t,w);l(i.signal),N=q(x,p)}if(r!==this.loadGeneration)return;l(i.signal),this.document=N,this.selectedNodeId=this.document.root.id,this.state={...this.state,loading:false,error:null,title:this.document.title??n.descriptor.name,selectedNodeId:this.selectedNodeId,scale:this.scale},this.render(),R(this.root,{getScale:()=>this.state.scale,setScale:x=>this.setScale(x),signal:i.signal}),this.emit("rendered",this.state),this.emit("statechange",this.state)}catch(p){if(r!==this.loadGeneration)return;this.releaseDocument(),this.state.loading=false,l(i.signal);const w=p instanceof Error?p:new Error(String(p));throw this.state.error=w.message,this.emit("error",w),this.emit("statechange",this.state),w}}destroy(){var t,n;this.loadGeneration++,(t=this.loadController)==null||t.abort(),(n=this.removeAbortListener)==null||n.call(this),this.releaseDocument(),this.state.loading=false,this.root.parentElement===this.host&&this.host.replaceChildren();for(const r of Object.values(this.listeners))r.clear()}getState(){return{...this.state,warnings:[...this.state.warnings],selectedNodeId:this.selectedNodeId}}on(t,n){return this.listeners[t].add(n),()=>{this.listeners[t].delete(n)}}setScale(t){Number.isFinite(t)&&(this.scale=Math.max(.25,Math.min(t,3)),this.fitMode="none",this.state.scale=this.scale,this.applyScale(),this.emit("statechange",this.state))}fit(t="contain"){this.fitMode=t,t==="none"&&(this.scale=1),this.applyScale(),this.state.scale=this.scale,this.root.scrollLeft=0,this.root.scrollTop=0,this.emit("statechange",this.state)}pan(t,n){this.root.scrollLeft+=t,this.root.scrollTop+=n}async fullscreen(){var t,n;await((n=(t=this.root).requestFullscreen)==null?void 0:n.call(t))}render(){var s,a,c;if(!this.document){this.root.replaceChildren();return}const t=at(this.document.root),n=ct(t);this.canvasSize=n;const r=document.createElement("div");r.className="mindmapv-canvas-wrap",r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;const i=document.createElementNS(y,"svg");i.classList.add("mindmapv-canvas"),i.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),i.setAttribute("role","img"),i.setAttribute("aria-label",this.document.title??"Mind map preview"),i.appendChild(lt(t)),i.appendChild(dt(t,this.selectedNodeId,f=>this.selectNode(f))),r.appendChild(i);const o=document.createElement("div");o.className="mindmapv-summary",o.textContent=`${this.document.nodeCount} node${this.document.nodeCount===1?"":"s"}`,(s=this.resizeObserver)==null||s.disconnect(),this.root.replaceChildren(o,r),this.applyScale(),(a=this.resizeObserver)==null||a.observe(this.root),(c=this.resizeObserver)==null||c.observe(o)}selectNode(t){if(!t){this.selectedNodeId=void 0,this.state.selectedNodeId=void 0,this.root.querySelectorAll(".mindmapv-node").forEach(n=>{n.classList.remove("is-selected")}),this.emit("statechange",this.state);return}this.selectedNodeId=t,this.state.selectedNodeId=t,this.root.querySelectorAll(".mindmapv-node").forEach(n=>{n.classList.toggle("is-selected",n.getAttribute("data-node-id")===t)}),this.emit("statechange",this.state)}applyScale(){const t=this.root.querySelector(".mindmapv-canvas-wrap");if(!(!t||!this.canvasSize)){if(this.fitMode!=="none"){const n=this.root.clientWidth,r=this.root.clientHeight-this.root.firstElementChild.offsetHeight;if(n>0&&r>0){const i=n/this.canvasSize.width,o=r/this.canvasSize.height;this.scale=this.fitMode==="width"?i:this.fitMode==="height"?o:Math.min(i,o)}}this.state.scale=this.scale,t.style.width=`${this.canvasSize.width*this.scale}px`,t.style.height=`${this.canvasSize.height*this.scale}px`}}releaseDocument(){var t;(t=this.resizeObserver)==null||t.disconnect(),this.canvasSize=void 0,this.document=null,this.selectedNodeId=void 0,this.state.selectedNodeId=void 0,this.root.replaceChildren()}emit(t,n){for(const r of this.listeners[t])r(n)}}function At(){return{id:"mindmap",family:"mindmap",supports:e=>D.has($(e)),createSession:(e,t)=>new V(e,t)}}function vt(e=G()){return[..._,...e.filter(t=>!t.extensions.some(n=>D.has(n)))]}function q(e,t){const n=new DOMParser().parseFromString(e,"application/xml");if(n.getElementsByTagName("parsererror")[0])throw new Error("Mind-map XML is invalid.");const i=$(t)==="opml"||m(n.documentElement)==="opml"?it(n):nt(n);return{title:i.text,root:i,nodeCount:A(i)}}async function Y(e,t={}){l(t.signal);const n=await O.loadAsync(e);l(t.signal);const r=n.file("content.json");if(r){const o=await r.async("text");return l(t.signal),rt(o)}const i=n.file("content.xml");if(i){const o=await i.async("text");return l(t.signal),st(o)}throw new Error("XMind package is missing content.json or content.xml.")}async function Z(e,t={}){l(t.signal);const n=await O.loadAsync(e);l(t.signal);const r=n.file("Document.xml")??n.file("document.xml")??n.file(/(^|\/)document\.xml$/i)[0];if(!r)throw new Error("MindManager package is missing Document.xml.");const i=await r.async("text");return l(t.signal),K(i)}function K(e){const t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror")[0])throw new Error("MindManager Document.xml is invalid.");const n=Array.from(t.getElementsByTagName("*")).filter(o=>m(o)==="topic");if(!n.length)throw new Error("MindManager Document.xml does not contain topic nodes.");const r=n.find(o=>!Q(o))??n[0],i=B(r,"mmap-root");return{title:i.text,root:i,nodeCount:A(i)}}function Q(e){let t=e.parentElement;for(;t;){if(m(t)==="topic")return true;t=t.parentElement}return false}function B(e,t){var o;const n=L(e,"id")||t,r=v(L(e,"text")||((o=u(e,"text")[0])==null?void 0:o.textContent)||e.textContent||"Untitled"),i=tt(e).map((s,a)=>B(s,`${n}-${a+1}`));return{id:n,text:r,children:i}}function tt(e){const t=[],n=r=>{for(const i of Array.from(r.children)){if(m(i)==="topic"){t.push(i);continue}et(i)&&n(i)}};return n(e),t}function et(e){return Array.from(e.getElementsByTagName("*")).some(t=>m(t)==="topic")}function L(e,t){const n=t.toLowerCase();for(const r of Array.from(e.attributes))if(r.name.toLowerCase()===n)return r.value}function nt(e){const t=Array.from(e.getElementsByTagName("*")).find(n=>m(n)==="node");if(!t)throw new Error("FreeMind MM file does not contain a root node.");return z(t,"mm",t.parentElement?mt(t):"")}function z(e,t,n){const r=e.getAttribute("ID")||`${t}-${n||"1"}`,i=v(e.getAttribute("TEXT")||e.getAttribute("text")||"Untitled"),o=u(e,"node").map((s,a)=>z(s,`${r}-${a+1}`,n?`${n}-${a+1}`:String(a+1)));return{id:r,text:i,children:o}}function it(e){var i,o;const t=Array.from(e.getElementsByTagName("*")).find(s=>m(s)==="body"),n=(o=(i=Array.from(e.getElementsByTagName("*")).find(s=>m(s)==="title"))==null?void 0:i.textContent)==null?void 0:o.trim(),r=t?u(t,"outline"):[];if(!r.length)throw new Error("OPML file does not contain outline nodes.");if(r.length===1){const s=C(r[0],"opml-1");return n&&s.text==="Untitled"?{...s,text:n}:s}return{id:"opml-root",text:n||"OPML",children:r.map((s,a)=>C(s,`opml-${a+1}`))}}function C(e,t){const n=v(e.getAttribute("text")||e.getAttribute("title")||"Untitled");return{id:t,text:n,children:u(e,"outline").map((r,i)=>C(r,`${t}-${i+1}`))}}function rt(e){let t;try{t=JSON.parse(e)}catch{throw new Error("XMind content.json is invalid.")}const r=(Array.isArray(t)?t:[t]).find(s=>s&&typeof s=="object");if(!r)throw new Error("XMind content.json does not contain a sheet.");const i=h(r.rootTopic)??h(r.centralTopic)??h(r.topic);if(!i)throw new Error("XMind content.json does not contain a root topic.");const o=F(i,"xmind-json-1");return{title:g(r.title)||o.text,root:o,nodeCount:A(o)}}function F(e,t){const n=g(e.id)||g(e.uuid)||t,r=v(g(e.title)||g(e.text)||wt(e)||"Untitled"),i=ot(e).map((o,s)=>F(o,`${n}-${s+1}`));return{id:n,text:r,children:i}}function ot(e){var s;const t=[],n=e.children;Array.isArray(n)&&t.push(...n.map(h).filter(M));const r=h(n);if(r)for(const a of["attached","detached","floating","summary"]){const c=r[a],f=Array.isArray(c)?c:(s=h(c))==null?void 0:s.topics;Array.isArray(f)&&t.push(...f.map(h).filter(M))}const i=e.subTopics??e.subtopics;Array.isArray(i)&&t.push(...i.map(h).filter(M));const o=h(i);if(o)for(const a of Object.values(o))Array.isArray(a)&&t.push(...a.map(h).filter(M));return t}function st(e){var s,a;const t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror")[0])throw new Error("XMind content.xml is invalid.");const n=Array.from(t.getElementsByTagName("*")).find(c=>m(c)==="sheet")??t.documentElement,r=u(n,"topic")[0]??Array.from(t.getElementsByTagName("*")).find(c=>m(c)==="topic");if(!r)throw new Error("XMind content.xml does not contain a root topic.");const i=X(r,"xmind-xml-1");return{title:((a=(s=u(n,"title")[0])==null?void 0:s.textContent)==null?void 0:a.trim())||i.text,root:i,nodeCount:A(i)}}function X(e,t){var o;const n=e.getAttribute("id")||t,r=((o=u(e,"title")[0])==null?void 0:o.textContent)??e.getAttribute("title")??e.getAttribute("text")??"Untitled",i=u(e,"children").flatMap(s=>u(s,"topics")).flatMap(s=>u(s,"topic")).map((s,a)=>X(s,`${n}-${a+1}`));return{id:n,text:v(r),children:i}}function at(e){const t=P(e,0);let n=E;const r=i=>{if(i.x=E+i.depth*(I+W),i.width=k(i.text),i.height=b,!i.children.length){i.y=n,n+=b+H;return}for(const o of i.children)r(o);i.y=(i.children[0].y+i.children[i.children.length-1].y)/2};return r(t),t}function P(e,t){return{...e,x:0,y:0,width:k(e.text),height:b,depth:t,children:e.children.map(n=>P(n,t+1))}}function ct(e){let t=0,n=0;return S(e,r=>{t=Math.max(t,r.x+r.width+E),n=Math.max(n,r.y+r.height+E)}),{width:Math.max(360,t),height:Math.max(260,n)}}function lt(e){const t=document.createElementNS(y,"g");return t.classList.add("mindmapv-links"),S(e,n=>{for(const r of n.children){const i=document.createElementNS(y,"path"),o=n.x+n.width,s=n.y+b/2,a=r.x,c=r.y+b/2,f=o+(a-o)*.5;i.setAttribute("d",`M ${o} ${s} C ${f} ${s}, ${f} ${c}, ${a} ${c}`),t.appendChild(i)}}),t}function dt(e,t,n){const r=document.createElementNS(y,"g");return r.classList.add("mindmapv-nodes"),S(e,i=>{const o=document.createElementNS(y,"g");o.classList.add("mindmapv-node"),i.id===t&&o.classList.add("is-selected"),o.setAttribute("data-node-id",i.id),o.setAttribute("tabindex","0"),o.setAttribute("role","button"),o.setAttribute("aria-label",i.text),o.addEventListener("click",()=>n(i.id)),o.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(i.id))});const s=document.createElementNS(y,"rect");s.setAttribute("x",String(i.x)),s.setAttribute("y",String(i.y)),s.setAttribute("width",String(i.width)),s.setAttribute("height",String(b)),s.setAttribute("rx","6");const a=document.createElementNS(y,"text");a.setAttribute("x",String(i.x+14)),a.setAttribute("y",String(i.y+22)),a.textContent=ht(i.text),o.append(s,a),r.appendChild(o)}),r}function S(e,t){t(e);for(const n of e.children)S(n,t)}function k(e){return Math.max(J,Math.min(I,e.length*8+34))}function ht(e){return e.length>34?`${e.slice(0,31)}...`:e}function A(e){return 1+e.children.reduce((t,n)=>t+A(n),0)}function u(e,t){return Array.from(e.children).filter(n=>m(n)===t)}function m(e){return e.localName.toLowerCase()}function v(e){return e.replace(/\s+/g," ").trim()||"Untitled"}function mt(e){const t=[];let n=e;for(;n!=null&&n.parentElement;){const r=u(n.parentElement,m(n));t.unshift(r.indexOf(n)+1),n=n.parentElement}return t.join("-")||"1"}async function ut(e,t){if(l(t.signal),typeof e=="string"){if(e.trimStart().toLowerCase().startsWith("data:"))return pt(e);const n=await fetch(e,{signal:t.signal});if(l(t.signal),!n.ok)throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());return n.text()}return e instanceof Blob?e.text():ArrayBuffer.isView(e)?new TextDecoder().decode(e):e instanceof ArrayBuffer?new TextDecoder().decode(e):String(e)}async function ft(e,t){if(l(t.signal),typeof e=="string"){if(e.trimStart().toLowerCase().startsWith("data:"))return T(gt(e));const n=await fetch(e,{signal:t.signal});if(l(t.signal),!n.ok)throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());return n.arrayBuffer()}if(e instanceof Blob)return e.arrayBuffer();if(ArrayBuffer.isView(e)){const n=new Uint8Array(e.byteLength);return n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),T(n)}return e instanceof ArrayBuffer?e:T(new TextEncoder().encode(String(e)))}function l(e){if(e!=null&&e.aborted)throw new DOMException("Mind-map preview aborted.","AbortError")}function pt(e){const t=e.indexOf(",");if(t<0)return e;const n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.endsWith(";base64")?new TextDecoder().decode(Uint8Array.from(atob(r),i=>i.charCodeAt(0))):decodeURIComponent(r)}function gt(e){const t=e.indexOf(",");if(t<0)return new TextEncoder().encode(e);const n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.endsWith(";base64")?Uint8Array.from(atob(r),i=>i.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(r))}function T(e){const t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function $(e){return String(e??"").trim().replace(/^\./,"").toLowerCase()}function h(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function M(e){return e!==void 0}function g(e){return typeof e=="string"?e.trim():""}function wt(e){const t=h(e.title),n=h(e.text);return g(t==null?void 0:t.plain)||g(t==null?void 0:t.content)||g(n==null?void 0:n.plain)||g(n==null?void 0:n.content)}export{vt as a,At as c};
@@ -1,4 +1,4 @@
1
- var Gn=Object.defineProperty;var Un=(n,e,t)=>e in n?Gn(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var M=(n,e,t)=>Un(n,typeof e!="symbol"?e+"":e,t);import{c as _n,o as Vn}from"./core-EjELrtsP.js";import{L as Ne,M as V,b as ne,F as nt,S as $n,C as de,V as E,d as ee,e as en,R as tn,B as Y,g as ie,h as Q,j as $,k as Wn,l as lt,P as we,m as xt,E as Mt,A as St,D as Oe,n as te,o as Ve,O as Kn,p as Z,q as _e,r as Pe,t as me,v as Yn,w as $e,x as Te,y as Ee,z as Ct,H as fe,I as Xn,K as Zn,N as nn,Q as qn,T as Jn,W as Qn,X as es,Y as ts,Z as ns,_ as ss,$ as rs,a0 as is,a1 as as,a2 as os,a3 as ls,a4 as cs,a5 as us,a6 as ds,a7 as hs,a8 as ms,J as fs,a9 as ps,aa as gs,ab as ws}from"./vendor-C1aIdQ-w.js";import{c as bs}from"./panorama-ChsqnvWC.js";const Pt=0,Lt=1,Et=2,Ft=3,At=4,Dt=5,We=0,ys=1,vs=2,xs=3,Ms=4,Ss=5,Nt=6,ae="16",ve="24",ke=$n,He=new E,je=new E;class Cs extends Q{constructor(e,t){super(e,t),this.isConditionalLine=true}}function Ps(n){for(let e=0,t=n.length;e<t;e++){const s=n[e],r=s.vertices,i=r[0],a=r[1],o=r[2];He.subVectors(a,i),je.subVectors(o,a),s.faceNormal=new E().crossVectors(He,je).normalize()}}const Ot=new tn;function Ls(n,e,t=false){const s=100.00000001000001;function r(f){const m=~~(f.x*s),g=~~(f.y*s),w=~~(f.z*s);return`${m},${g},${w}`}function i(f,m){return`${r(f)}_${r(m)}`}function a(f,m,g){g.direction.subVectors(m,f).normalize();const w=f.dot(g.direction);return g.origin.copy(f).addScaledVector(g.direction,-w),g}function o(f){return i(f.origin,f.direction)}const u=new Set,l=new Map,c=new Map,d=[];for(let f=0,m=e.length;f<m;f++){const w=e[f].vertices,p=w[0],b=w[1];if(u.add(i(p,b)),u.add(i(b,p)),t){const y=a(p,b,new tn),C=o(y);if(!l.has(C)){a(b,p,y);const k=o(y),D={ray:y,distances:[]};l.set(C,D),l.set(k,D)}const P=l.get(C);let S=P.ray.direction.dot(p),L=P.ray.direction.dot(b);S>L&&([S,L]=[L,S]),P.distances.push(S,L)}}for(let f=0,m=n.length;f<m;f++){const g=n[f],w=g.vertices,p=w.length;for(let b=0;b<p;b++){const y=b,C=(b+1)%p,P=w[y],S=w[C],L=i(P,S);if(u.has(L))continue;if(t){a(P,S,Ot);const D=o(Ot);if(l.has(D)){const N=l.get(D),{ray:v,distances:O}=N;let A=v.direction.dot(P),x=v.direction.dot(S);A>x&&([A,x]=[x,A]);let z=false;for(let H=0,U=O.length;H<U;H+=2)if(A>=O[H]&&x<=O[H+1]){z=true;break}if(z)continue}}const k={index:y,tri:g};c.set(L,k)}}const h=c.values();for(;;){const f=h.next().value;if(f===void 0)break;const m=[f];for(;m.length>0;){const g=m.pop().tri,w=g.vertices,p=g.normals,b=g.faceNormal,y=w.length;for(let C=0;C<y;C++){const P=C,S=(C+1)%y,L=w[P],k=w[S],D=i(L,k);c.delete(D);const N=i(k,L),v=c.get(N);if(v){const O=v.tri,A=v.index,x=O.normals,z=x.length,H=O.faceNormal;if(Math.abs(O.faceNormal.dot(g.faceNormal))<.25)continue;c.has(N)&&(m.push(v),c.delete(N));const U=(A+1)%z;p[P]&&x[U]&&p[P]!==x[U]&&(x[U].norm.add(p[P].norm),p[P].norm=x[U].norm);let I=p[P]||x[U];I===null&&(I={norm:new E},d.push(I.norm)),p[P]===null&&(p[P]=I,I.norm.add(b)),x[U]===null&&(x[U]=I,I.norm.add(H)),p[S]&&x[A]&&p[S]!==x[A]&&(x[A].norm.add(p[S].norm),p[S].norm=x[A].norm);let B=p[S]||x[A];B===null&&(B={norm:new E},d.push(B.norm)),p[S]===null&&(p[S]=B,B.norm.add(b)),x[A]===null&&(x[A]=B,B.norm.add(H))}}}}for(let f=0,m=d.length;f<m;f++)d[f].normalize()}function kt(n){return n==="Part"||n==="Unofficial_Part"}function Es(n){return/primitive/i.test(n)||n==="Subpart"}class Se{constructor(e,t){this.line=e,this.lineLength=e.length,this.currentCharIndex=0,this.currentChar=" ",this.lineNumber=t}seekNonSpace(){for(;this.currentCharIndex<this.lineLength;){if(this.currentChar=this.line.charAt(this.currentCharIndex),this.currentChar!==" "&&this.currentChar!==" ")return;this.currentCharIndex++}}getToken(){const e=this.currentCharIndex++;for(;this.currentCharIndex<this.lineLength&&(this.currentChar=this.line.charAt(this.currentCharIndex),!(this.currentChar===" "||this.currentChar===" "));)this.currentCharIndex++;const t=this.currentCharIndex;return this.seekNonSpace(),this.line.substring(e,t)}getVector(){return new E(parseFloat(this.getToken()),parseFloat(this.getToken()),parseFloat(this.getToken()))}getRemainingString(){return this.line.substring(this.currentCharIndex,this.lineLength)}isAtTheEnd(){return this.currentCharIndex>=this.lineLength}setToEnd(){this.currentCharIndex=this.lineLength}getLineNumberString(){return this.lineNumber>=0?" at line "+this.lineNumber:""}}class Fs{constructor(e){this.loader=e,this._cache={}}cloneResult(e){const t={};return t.faces=e.faces.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone()),normals:s.normals.map(()=>null),faceNormal:null})),t.conditionalSegments=e.conditionalSegments.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone()),controlPoints:s.controlPoints.map(r=>r.clone())})),t.lineSegments=e.lineSegments.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone())})),t.type=e.type,t.category=e.category,t.keywords=e.keywords,t.author=e.author,t.subobjects=e.subobjects,t.fileName=e.fileName,t.totalFaces=e.totalFaces,t.startingBuildingStep=e.startingBuildingStep,t.materials=e.materials,t.group=null,t}async fetchData(e){let t=false,s=We;for(;s!==Nt;){let r=e;switch(s){case xs:s=s+1;break;case We:r="parts/"+r,s=s+1;break;case ys:r="p/"+r,s=s+1;break;case vs:r="models/"+r,s=s+1;break;case Ms:r=e.substring(0,e.lastIndexOf("/")+1)+r,s=s+1;break;case Ss:t?s=Nt:(e=e.toLowerCase(),r=e,t=true,s=We);break}const i=this.loader,a=new nt(i.manager);a.setPath(i.partsLibraryPath),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials);try{return await a.loadAsync(r)}catch{continue}}throw new Error('LDrawLoader: Subobject "'+e+'" could not be loaded.')}parse(e,t=null){const s=this.loader,r=[],i=[],a=[],o=[],u={},l=D=>u[D]||null;let c="Model",d=null,h=null,f=null,m=0;e.indexOf(`\r
1
+ var Gn=Object.defineProperty;var Un=(n,e,t)=>e in n?Gn(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var M=(n,e,t)=>Un(n,typeof e!="symbol"?e+"":e,t);import{c as _n,o as Vn}from"./core-DMIUha7u.js";import{L as Ne,M as V,b as ne,F as nt,S as $n,C as de,V as E,d as ee,e as en,R as tn,B as Y,g as ie,h as Q,j as $,k as Wn,l as lt,P as we,m as xt,E as Mt,A as St,D as Oe,n as te,o as Ve,O as Kn,p as Z,q as _e,r as Pe,t as me,v as Yn,w as $e,x as Te,y as Ee,z as Ct,H as fe,I as Xn,K as Zn,N as nn,Q as qn,T as Jn,W as Qn,X as es,Y as ts,Z as ns,_ as ss,$ as rs,a0 as is,a1 as as,a2 as os,a3 as ls,a4 as cs,a5 as us,a6 as ds,a7 as hs,a8 as ms,J as fs,a9 as ps,aa as gs,ab as ws}from"./vendor-C8SyXchM.js";import{c as bs}from"./panorama-COXaZ8XC.js";const Pt=0,Lt=1,Et=2,Ft=3,At=4,Dt=5,We=0,ys=1,vs=2,xs=3,Ms=4,Ss=5,Nt=6,ae="16",ve="24",ke=$n,He=new E,je=new E;class Cs extends Q{constructor(e,t){super(e,t),this.isConditionalLine=true}}function Ps(n){for(let e=0,t=n.length;e<t;e++){const s=n[e],r=s.vertices,i=r[0],a=r[1],o=r[2];He.subVectors(a,i),je.subVectors(o,a),s.faceNormal=new E().crossVectors(He,je).normalize()}}const Ot=new tn;function Ls(n,e,t=false){const s=100.00000001000001;function r(f){const m=~~(f.x*s),g=~~(f.y*s),w=~~(f.z*s);return`${m},${g},${w}`}function i(f,m){return`${r(f)}_${r(m)}`}function a(f,m,g){g.direction.subVectors(m,f).normalize();const w=f.dot(g.direction);return g.origin.copy(f).addScaledVector(g.direction,-w),g}function o(f){return i(f.origin,f.direction)}const u=new Set,l=new Map,c=new Map,d=[];for(let f=0,m=e.length;f<m;f++){const w=e[f].vertices,p=w[0],b=w[1];if(u.add(i(p,b)),u.add(i(b,p)),t){const y=a(p,b,new tn),C=o(y);if(!l.has(C)){a(b,p,y);const k=o(y),D={ray:y,distances:[]};l.set(C,D),l.set(k,D)}const P=l.get(C);let S=P.ray.direction.dot(p),L=P.ray.direction.dot(b);S>L&&([S,L]=[L,S]),P.distances.push(S,L)}}for(let f=0,m=n.length;f<m;f++){const g=n[f],w=g.vertices,p=w.length;for(let b=0;b<p;b++){const y=b,C=(b+1)%p,P=w[y],S=w[C],L=i(P,S);if(u.has(L))continue;if(t){a(P,S,Ot);const D=o(Ot);if(l.has(D)){const N=l.get(D),{ray:v,distances:O}=N;let A=v.direction.dot(P),x=v.direction.dot(S);A>x&&([A,x]=[x,A]);let z=false;for(let H=0,U=O.length;H<U;H+=2)if(A>=O[H]&&x<=O[H+1]){z=true;break}if(z)continue}}const k={index:y,tri:g};c.set(L,k)}}const h=c.values();for(;;){const f=h.next().value;if(f===void 0)break;const m=[f];for(;m.length>0;){const g=m.pop().tri,w=g.vertices,p=g.normals,b=g.faceNormal,y=w.length;for(let C=0;C<y;C++){const P=C,S=(C+1)%y,L=w[P],k=w[S],D=i(L,k);c.delete(D);const N=i(k,L),v=c.get(N);if(v){const O=v.tri,A=v.index,x=O.normals,z=x.length,H=O.faceNormal;if(Math.abs(O.faceNormal.dot(g.faceNormal))<.25)continue;c.has(N)&&(m.push(v),c.delete(N));const U=(A+1)%z;p[P]&&x[U]&&p[P]!==x[U]&&(x[U].norm.add(p[P].norm),p[P].norm=x[U].norm);let I=p[P]||x[U];I===null&&(I={norm:new E},d.push(I.norm)),p[P]===null&&(p[P]=I,I.norm.add(b)),x[U]===null&&(x[U]=I,I.norm.add(H)),p[S]&&x[A]&&p[S]!==x[A]&&(x[A].norm.add(p[S].norm),p[S].norm=x[A].norm);let B=p[S]||x[A];B===null&&(B={norm:new E},d.push(B.norm)),p[S]===null&&(p[S]=B,B.norm.add(b)),x[A]===null&&(x[A]=B,B.norm.add(H))}}}}for(let f=0,m=d.length;f<m;f++)d[f].normalize()}function kt(n){return n==="Part"||n==="Unofficial_Part"}function Es(n){return/primitive/i.test(n)||n==="Subpart"}class Se{constructor(e,t){this.line=e,this.lineLength=e.length,this.currentCharIndex=0,this.currentChar=" ",this.lineNumber=t}seekNonSpace(){for(;this.currentCharIndex<this.lineLength;){if(this.currentChar=this.line.charAt(this.currentCharIndex),this.currentChar!==" "&&this.currentChar!==" ")return;this.currentCharIndex++}}getToken(){const e=this.currentCharIndex++;for(;this.currentCharIndex<this.lineLength&&(this.currentChar=this.line.charAt(this.currentCharIndex),!(this.currentChar===" "||this.currentChar===" "));)this.currentCharIndex++;const t=this.currentCharIndex;return this.seekNonSpace(),this.line.substring(e,t)}getVector(){return new E(parseFloat(this.getToken()),parseFloat(this.getToken()),parseFloat(this.getToken()))}getRemainingString(){return this.line.substring(this.currentCharIndex,this.lineLength)}isAtTheEnd(){return this.currentCharIndex>=this.lineLength}setToEnd(){this.currentCharIndex=this.lineLength}getLineNumberString(){return this.lineNumber>=0?" at line "+this.lineNumber:""}}class Fs{constructor(e){this.loader=e,this._cache={}}cloneResult(e){const t={};return t.faces=e.faces.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone()),normals:s.normals.map(()=>null),faceNormal:null})),t.conditionalSegments=e.conditionalSegments.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone()),controlPoints:s.controlPoints.map(r=>r.clone())})),t.lineSegments=e.lineSegments.map(s=>({colorCode:s.colorCode,material:s.material,vertices:s.vertices.map(r=>r.clone())})),t.type=e.type,t.category=e.category,t.keywords=e.keywords,t.author=e.author,t.subobjects=e.subobjects,t.fileName=e.fileName,t.totalFaces=e.totalFaces,t.startingBuildingStep=e.startingBuildingStep,t.materials=e.materials,t.group=null,t}async fetchData(e){let t=false,s=We;for(;s!==Nt;){let r=e;switch(s){case xs:s=s+1;break;case We:r="parts/"+r,s=s+1;break;case ys:r="p/"+r,s=s+1;break;case vs:r="models/"+r,s=s+1;break;case Ms:r=e.substring(0,e.lastIndexOf("/")+1)+r,s=s+1;break;case Ss:t?s=Nt:(e=e.toLowerCase(),r=e,t=true,s=We);break}const i=this.loader,a=new nt(i.manager);a.setPath(i.partsLibraryPath),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials);try{return await a.loadAsync(r)}catch{continue}}throw new Error('LDrawLoader: Subobject "'+e+'" could not be loaded.')}parse(e,t=null){const s=this.loader,r=[],i=[],a=[],o=[],u={},l=D=>u[D]||null;let c="Model",d=null,h=null,f=null,m=0;e.indexOf(`\r
2
2
  `)!==-1&&(e=e.replace(/\r\n/g,`
3
3
  `));const g=e.split(`
4
4
  `),w=g.length;let p=false,b=null,y=null,C=false,P=true,S=false,L=true,k=false;for(let D=0;D<w;D++){const N=g[D];if(N.length===0)continue;if(p){N.startsWith("0 FILE ")?(this.setData(b,y),b=N.substring(7),y=""):y+=N+`