efficient-shell 7.10.0 → 7.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-FTJ2G343.js";import{ImageAnnotator_default as r}from"./chunk-JQRIAZDP.js";import{AboutApp as s}from"./chunk-UZJ6RYMF.js";import{peekPdfPreviewStage as i,claimPdfPreviewStage as a,PDF_PREVIEW_UPDATE_EVENT as o}from"./chunk-ESL5TDNA.js";import{WindowTitle as l,getActiveModalId as c}from"./chunk-THM35LAN.js";import"./chunk-DSSLOQDW.js";import"./chunk-SCJT2XXU.js";import{toast_default as d}from"./chunk-RUHUTZN4.js";import"./chunk-ZRU5F2XT.js";import"./chunk-5A7MWTXX.js";import"./chunk-YMWCZKUN.js";import"./chunk-KSLOSQKN.js";import"./chunk-ICN533ML.js";import"./chunk-UVBK6YSR.js";import"./chunk-NGUH7T5V.js";import"./chunk-7IQ3B77H.js";import{registerModalEscapeInterceptor as u}from"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-B4XGJA3N.js";import"./chunk-KNUR2UEG.js";import{useShellStrings as p,splitAround as m}from"./chunk-QRCDQPJA.js";import"./chunk-C3QOHMR6.js";import{Icon as h}from"./chunk-ZGUQLVY4.js";import{useRef as y,useState as x,useEffect as f}from"react";import{jsxs as g,jsx as b,Fragment as w}from"react/jsx-runtime";var v=!1;function k(e,t){return e?.url&&e.url!==t.url&&e.url.startsWith("blob:")&&URL.revokeObjectURL(e.url),t}function N(){const n=y(void 0);void 0===n.current&&(n.current=i());const[r,u]=x(n.current?.data??null);f(()=>{const e=n.current;null!=e&&(a(e),u(t=>t===e.data?t:k(t,e.data)))},[]),f(()=>{const e=n.current?.token;if(null==e)return;const t=t=>{const n=t.detail;n&&n.token===e&&u(e=>k(e,n.data))};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const v=y(void 0);f(()=>{v.current=r?.url},[r?.url]);const N=y(null);f(()=>(null!==N.current&&(clearTimeout(N.current),N.current=null),()=>{const e=v.current;e?.startsWith("blob:")&&(N.current=setTimeout(()=>URL.revokeObjectURL(e),0))}),[]);const A=p().preview,E=r?.filename?(M=r.filename).length>24?`${M.slice(0,23)}…`:M:A.untitled;var M;const S=y(null),z=y(null),[T,R]=x(null),[F,H]=x(!1),I=y(0),P=()=>S.current?.click(),O=()=>{I.current=0,H(!1)},W=e=>{const t=e.closest("[data-modal-id]");return!t||c()===t.dataset.modalId};f(()=>{const e=()=>O(),t=()=>O(),n=e=>{"Escape"===e.key&&O()};return window.addEventListener("dragend",e),window.addEventListener("drop",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",t),window.removeEventListener("keydown",n)}},[]);const B=e=>{const t=(e.name.split(".").pop()||"").toLowerCase(),n="pdf"===t?"pdf":"dxf"===t?"dxf":["jpg","jpeg","png","gif","webp","svg","avif","bmp"].includes(t)?"image":["stp","step","stl","obj","gltf","glb","3mf","iges","igs","ply","fbx"].includes(t)?"3d":void 0;if(!n)return void("dwg"===t?d.error(A.dwgUnsupported):d.error(A.unsupportedType(t)));const r=URL.createObjectURL(e);u(t=>(t?.url?.startsWith("blob:")&&t.url!==r&&URL.revokeObjectURL(t.url),{url:r,filename:e.name,kind:n}))},U=/* @__PURE__ */g("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
2
- /* @__PURE__ */b("input",{ref:S,type:"file",accept:".pdf,.dxf,.jpg,.jpeg,.png,.gif,.webp,.svg,.avif,.bmp,.stp,.step,.stl,.obj,.gltf,.glb,.3mf,.iges,.igs,.ply,.fbx",onChange:e=>{const t=e.target.files?.[0];t&&B(t),S.current&&(S.current.value="")},className:"hidden"}),
1
+ import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-FTJ2G343.js";import{ImageAnnotator_default as r}from"./chunk-JQRIAZDP.js";import{AboutApp as s}from"./chunk-KPFDT626.js";import{peekPdfPreviewStage as i,claimPdfPreviewStage as a,PDF_PREVIEW_UPDATE_EVENT as o}from"./chunk-ESL5TDNA.js";import{WindowTitle as l,getActiveModalId as c}from"./chunk-THM35LAN.js";import"./chunk-DSSLOQDW.js";import"./chunk-SCJT2XXU.js";import{toast_default as d}from"./chunk-RUHUTZN4.js";import"./chunk-ZRU5F2XT.js";import"./chunk-5A7MWTXX.js";import"./chunk-YMWCZKUN.js";import"./chunk-KSLOSQKN.js";import"./chunk-ICN533ML.js";import"./chunk-UVBK6YSR.js";import"./chunk-NGUH7T5V.js";import"./chunk-7IQ3B77H.js";import{registerModalEscapeInterceptor as u}from"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-GIRABDNU.js";import"./chunk-KNUR2UEG.js";import{useShellStrings as p,splitAround as m}from"./chunk-QRCDQPJA.js";import"./chunk-C3QOHMR6.js";import{Icon as h}from"./chunk-ZGUQLVY4.js";import{useRef as y,useState as x,useEffect as f}from"react";import{jsxs as g,jsx as b,Fragment as w}from"react/jsx-runtime";var v=!1;function k(e,t){return e?.url&&e.url!==t.url&&e.url.startsWith("blob:")&&URL.revokeObjectURL(e.url),t}function N(){const n=y(void 0);void 0===n.current&&(n.current=i());const[r,u]=x(n.current?.data??null);f(()=>{const e=n.current;null!=e&&(a(e),u(t=>t===e.data?t:k(t,e.data)))},[]),f(()=>{const e=n.current?.token;if(null==e)return;const t=t=>{const n=t.detail;n&&n.token===e&&u(e=>k(e,n.data))};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const v=y(void 0);f(()=>{v.current=r?.url},[r?.url]);const N=y(null);f(()=>(null!==N.current&&(clearTimeout(N.current),N.current=null),()=>{const e=v.current;e?.startsWith("blob:")&&(N.current=setTimeout(()=>URL.revokeObjectURL(e),0))}),[]);const A=p().preview,E=r?.filename?(S=r.filename).length>24?`${S.slice(0,23)}…`:S:A.untitled;var S;const M=y(null),z=y(null),[T,R]=x(null),[F,H]=x(!1),I=y(0),P=()=>M.current?.click(),O=()=>{I.current=0,H(!1)},W=e=>{const t=e.closest("[data-modal-id]");return!t||c()===t.dataset.modalId};f(()=>{const e=()=>O(),t=()=>O(),n=e=>{"Escape"===e.key&&O()};return window.addEventListener("dragend",e),window.addEventListener("drop",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",t),window.removeEventListener("keydown",n)}},[]);const B=e=>{const t=(e.name.split(".").pop()||"").toLowerCase(),n="pdf"===t?"pdf":"dxf"===t?"dxf":["jpg","jpeg","png","gif","webp","svg","avif","bmp"].includes(t)?"image":["stp","step","stl","obj","gltf","glb","3mf","iges","igs","ply","fbx"].includes(t)?"3d":void 0;if(!n)return void("dwg"===t?d.error(A.dwgUnsupported):d.error(A.unsupportedType(t)));const r=URL.createObjectURL(e);u(t=>(t?.url?.startsWith("blob:")&&t.url!==r&&URL.revokeObjectURL(t.url),{url:r,filename:e.name,kind:n}))},U=/* @__PURE__ */g("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
2
+ /* @__PURE__ */b("input",{ref:M,type:"file",accept:".pdf,.dxf,.jpg,.jpeg,.png,.gif,.webp,.svg,.avif,.bmp,.stp,.step,.stl,.obj,.gltf,.glb,.3mf,.iges,.igs,.ply,.fbx",onChange:e=>{const t=e.target.files?.[0];t&&B(t),M.current&&(M.current.value="")},className:"hidden"}),
3
3
  /* @__PURE__ */g("button",{onClick:P,className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
4
4
  /* @__PURE__ */b(h,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),A.open]}),
5
5
  /* @__PURE__ */b("span",{className:"text-2xs text-gray-400 ml-1",children:A.formats}),r?.filename&&/* @__PURE__ */g(w,{children:[
@@ -35,12 +35,12 @@ return g("div",{className:"flex flex-col items-center justify-center h-full bg-g
35
35
  /* @__PURE__ */b("div",{className:"text-base font-semibold tracking-wide text-gray-700 uppercase",children:t||n.converting}),
36
36
  /* @__PURE__ */b("div",{className:"text-xs text-gray-400 truncate max-w-md",children:e})]}),
37
37
  /* @__PURE__ */b("div",{className:"w-72 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */b("div",{className:"h-full w-1/3 bg-blue-500 rounded-full animate-pulse",style:{animation:"preview-bar 1.4s ease-in-out infinite"}})}),
38
- /* @__PURE__ */b("style",{children:"@keyframes preview-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }"})]})}var A=["https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/Roboto-LightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NotoSansDisplay-SemiCondensedLightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NanumGothic-Regular.ttf"],E={l:"LINE",line:"LINE",pl:"PLINE",pline:"PLINE",ex:"EXTEND",extend:"EXTEND",tr:"TRIM",trim:"TRIM",e:"ERASE",erase:"ERASE",m:"MOVE",move:"MOVE",co:"COPY",cp:"COPY",copy:"COPY",o:"OFFSET",offset:"OFFSET",f:"FILLET",fillet:"FILLET",cha:"CHAMFER",chamfer:"CHAMFER",x:"EXPLODE",explode:"EXPLODE",mi:"MIRROR",mirror:"MIRROR",ro:"ROTATE",rotate:"ROTATE",sc:"SCALE",scale:"SCALE",s:"STRETCH",stretch:"STRETCH",ar:"ARRAY",array:"ARRAY",rec:"RECTANG",rectang:"RECTANG",rectangle:"RECTANG",c:"CIRCLE",circle:"CIRCLE",a:"ARC",arc:"ARC",el:"ELLIPSE",ellipse:"ELLIPSE",t:"MTEXT",mt:"MTEXT",mtext:"MTEXT",text:"TEXT",b:"BLOCK",block:"BLOCK",i:"INSERT",insert:"INSERT",ha:"HATCH",hatch:"HATCH"};function L({url:e,filename:t,onDownload:r,onEmail:s}){const i=y(null),a=y(null),[o,l]=x(!0),[d,v]=x(null),[k,N]=x([]),[C,L]=x(!1),[M,S]=x(!0),z=p(),T=z.drawing,j=z.preview,D=y(T);D.current=T;const[F,H]=x(!1),[I,P]=x("auto"),[O,W]=x(null),[B,U]=x(null),[X,G]=x(null),[_,V]=x(""),Y=y(I),$=y(X);f(()=>{Y.current=I},[I]),f(()=>{$.current=X},[X]);const Z=y(null),q=y(null),K=y(null),[Q,J]=x(""),[ee,te]=x(null),ne=y(""),re=y(null),se=y(null),ie=y(null);f(()=>{let t=!1,n=null;return l(!0),v(null),N([]),(async()=>{let r;try{r=(await(import("dxf-viewer"))).DxfViewer}catch(e){return void(t||(v(D.current.notInstalled),l(!1)))}if(!t&&i.current)try{if(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),t||!i.current)return;const s={autoResize:!0},o=r.DefaultOptions?.clearColor;"function"==typeof o?.clone&&(s.clearColor=o.clone().setHex(16777215)),n=new r(i.current,s),a.current=n;const c="undefined"!=typeof window&&window.__REACT_OS_SHELL_DXF_FONTS__||A;if(await n.Load({url:e,fonts:c,workerFactory:null}),t)return;try{const e=n.GetLayers?.()??[];Array.isArray(e)&&N(e.map(e=>({name:e.name,displayName:e.displayName??e.name,color:"number"==typeof e.color?e.color:void 0,visible:!0})))}catch{}const d=()=>{try{const e=i.current?.getBoundingClientRect();e&&e.width>0&&e.height>0&&n.SetSize?.(Math.round(e.width),Math.round(e.height));const t=n.GetBounds?.(),r=n.GetOrigin?.();t&&r&&n.FitView(t.minX-r.x,t.maxX-r.x,t.minY-r.y,t.maxY-r.y),n.Render?.()}catch(e){console.warn("[Preview] DXF refit failed",e)}};d(),requestAnimationFrame(d),l(!1)}catch(e){t||(v(e?.message||D.current.renderFailed),l(!1))}})(),()=>{t=!0;try{n?.Destroy?.()}catch{}a.current=null}},[e]),f(()=>{if(!M||o)return;const e=setTimeout(()=>S(!1),5e3);return()=>clearTimeout(e)},[M,o]);const ae=k.map(e=>e.visible?"1":"0").join("");f(()=>{const e=a.current;if(o||d||!e)return;const t=e.GetScene?.(),n=e.GetCamera?.(),r=e.GetCanvas?.();if(!(t&&n&&r&&i.current))return;const s=()=>{const e=ie.current;e&&(e.overlay&&e.overlay.parentElement&&e.overlay.parentElement.removeChild(e.overlay),ie.current=null)};if(!F)return s(),W(null),void U(null);const l=document.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:5;",i.current.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;pointer-events:none;");const u=document.createElementNS("http://www.w3.org/2000/svg","defs"),p=document.createElementNS("http://www.w3.org/2000/svg","marker");p.setAttribute("id","dxf-measure-arrow"),p.setAttribute("viewBox","0 0 10 10"),p.setAttribute("refX","9"),p.setAttribute("refY","5"),p.setAttribute("markerWidth","6"),p.setAttribute("markerHeight","6"),p.setAttribute("orient","auto-start-reverse");const m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),m.setAttribute("fill","#ff8800"),p.appendChild(m),u.appendChild(p),c.appendChild(u),l.appendChild(c);const h=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","line");return e.setAttribute("stroke","#ff8800"),e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","6,4"),e.setAttribute("opacity","0.55"),e.style.display="none",c.appendChild(e),e},y=h(),x=h(),f=document.createElementNS("http://www.w3.org/2000/svg","line");f.setAttribute("stroke","#ff8800"),f.setAttribute("stroke-width","1"),f.setAttribute("opacity","0.85"),f.style.display="none",c.appendChild(f);const g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("stroke","#ff8800"),g.setAttribute("stroke-width","1"),g.setAttribute("opacity","0.85"),g.style.display="none",c.appendChild(g);const b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("stroke","#ff8800"),b.setAttribute("stroke-width","1.5"),b.setAttribute("stroke-linecap","round"),b.style.display="none",c.appendChild(b);const w=document.createElementNS("http://www.w3.org/2000/svg","line");w.setAttribute("stroke","#ff8800"),w.setAttribute("stroke-width","1.5"),w.setAttribute("stroke-linecap","round"),w.style.display="none",c.appendChild(w);const v=document.createElement("div");v.style.cssText="position:absolute;transform:translate(-50%,-50%);pointer-events:none;display:none;";const k="http://www.w3.org/2000/svg",N=document.createElementNS(k,"svg");N.setAttribute("width","22"),N.setAttribute("height","22"),N.setAttribute("viewBox","0 0 22 22"),N.setAttribute("style","overflow:visible;display:block"),v.appendChild(N);const C=e=>{const t=document.createElementNS(k,"g");return e(t),t.style.display="none",N.appendChild(t),t},A=C(e=>{const t=document.createElementNS(k,"rect");t.setAttribute("x","4"),t.setAttribute("y","4"),t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t)}),E=C(e=>{const t=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","2.2"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(t(4,4,18,18)),e.appendChild(t(18,4,4,18))}),L=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","4,4 18,4 4,18 18,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),M=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","11,3 19,18 3,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),S=C(e=>{const t=document.createElementNS(k,"circle");t.setAttribute("cx","11"),t.setAttribute("cy","11"),t.setAttribute("r","7"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t);const n=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","1.6"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(n(6.5,6.5,15.5,15.5)),e.appendChild(n(15.5,6.5,6.5,15.5))});l.appendChild(v),ie.current={picks:[],rawSecondClick:null,overlay:l,svg:c,line:b,fixedLine:w,fixedLabel:null,refLine:y,refLineV:x,extLineA:f,extLineB:g,markers:[],label:null,snap:v,segs:null,nodes:null};const z=n?.position?.constructor??t?.position?.constructor??null;let T=!1;const j=(e,t)=>{if(!z)return{x:0,y:0};const s=new z(e,t,0).project(n),i=r.clientWidth,a=r.clientHeight;return{x:(s.x+1)/2*i,y:(1-s.y)/2*a}};(()=>{try{const e=ie.current;if(!e)return;const n=[],r=[];let s=!1;const i=e=>{const t=e?.attributes?.instanceTransform0,n=e?.attributes?.instanceTransform1;if(t&&n){const e=[],r=Math.min(t.count,n.count);for(let s=0;s<r;s++)e.push([t.getX(s),t.getY(s),t.getZ(s),n.getX(s),n.getY(s),n.getZ(s)]);return e}const r=e?.attributes?.instanceTransform;if(r){const e=[];for(let t=0;t<r.count;t++)e.push([1,0,r.getX(t),0,1,r.getY(t)]);return e}return[[1,0,0,0,1,0]]},a=e=>{const t=!!e?.isLineSegments;if(!t&&!!!e?.isPoints)return;const a=e.geometry,o=a?.attributes?.position;if(!o)return;const l=i(a);if(t){const e=a.index,t=Math.floor((e?e.count:o.count)/2);for(let r=0;r<t;r++){const t=e?e.getX(2*r):2*r,i=e?e.getX(2*r+1):2*r+1,a=o.getX(t),c=o.getY(t),d=o.getX(i),u=o.getY(i);if(Number.isFinite(a+c+d+u))for(const e of l){if(n.length>=16e5)return void(s=!0);const t=e[0]*a+e[1]*c+e[2],r=e[3]*a+e[4]*c+e[5],i=e[0]*d+e[1]*u+e[2],o=e[3]*d+e[4]*u+e[5];t===i&&r===o||n.push(t,r,i,o)}}}else for(let e=0;e<o.count;e++){const t=o.getX(e),n=o.getY(e);if(Number.isFinite(t+n))for(const e of l)r.push(e[0]*t+e[1]*n+e[2],e[3]*t+e[4]*n+e[5])}};"function"==typeof t.traverseVisible?t.traverseVisible(a):t.traverse(a),e.segs=new Float64Array(n),e.nodes=new Float64Array(r),s&&console.warn("[Preview] DXF snap cache truncated at 400000 segments — snapping may miss some geometry."),T=!0}catch{}})();const I=(e,t,n,r,s,i,a,o)=>{const l=(n-e)*(o-i)-(r-t)*(a-s);if(Math.abs(l)<1e-9)return null;const c=((s-e)*(o-i)-(i-t)*(a-s))/l,d=((s-e)*(r-t)-(i-t)*(n-e))/l,u=1e-4;return c<-u||c>1+u||d<-u||d>1+u?null:{px:e+c*(n-e),py:t+c*(r-t),t:c}},P=()=>{const e=document.createElement("div");return e.style.cssText="position:absolute;width:10px;height:10px;border-radius:50%;background:#ff8800;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,0.25);transform:translate(-50%,-50%);pointer-events:none;",l.appendChild(e),e},O=(e,t,n)=>{const r=j(t,n);e.style.left=`${r.x}px`,e.style.top=`${r.y}px`},B=()=>{const e=ie.current;if(!e||!e.rawSecondClick||e.picks.length<2)return;const t=e.picks[0],n=e.rawSecondClick,r=$.current,s=Y.current;if(null===r||!Number.isFinite(r)||"horizontal"!==s&&"vertical"!==s)e.picks[1]={x:n.x,y:n.y};else if("horizontal"===s){const s=n.x>=t.x?1:-1;e.picks[1]={x:t.x+s*Math.abs(r),y:n.y}}else{const s=n.y>=t.y?1:-1;e.picks[1]={x:n.x,y:t.y+s*Math.abs(r)}}},X=(e,t)=>{const n=Y.current;return"auto"!==n?n:e&&t?Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?"horizontal":"vertical":"horizontal"},G=()=>{const e=ie.current;if(!e)return;B();const t=Y.current,n=$.current,s=null!==n&&Number.isFinite(n)&&("horizontal"===t||"vertical"===t);e.markers[0]&&O(e.markers[0],e.picks[0].x,e.picks[0].y),e.markers[1]&&O(e.markers[1],e.picks[1].x,e.picks[1].y);const i=(t,n,s)=>{if(!t)return;if(!s||e.picks.length<1)return void(t.style.display="none");const i=e.picks[0],a=r.clientWidth,o=r.clientHeight,l=4*Math.hypot(a,o),c=j(i.x,i.y),d=j(i.x+n.dx,i.y+n.dy),u=l/(Math.hypot(d.x-c.x,d.y-c.y)||1),p=j(i.x-n.dx*u,i.y-n.dy*u),m=j(i.x+n.dx*u,i.y+n.dy*u);t.setAttribute("x1",String(p.x)),t.setAttribute("y1",String(p.y)),t.setAttribute("x2",String(m.x)),t.setAttribute("y2",String(m.y)),t.style.display=""};let a="horizontal"===t,o="vertical"===t;if("auto"===t)if(e.picks.length>=2){const t=X(e.picks[0],e.picks[1]);a="horizontal"===t,o="vertical"===t}else a=!0,o=!0;if(i(e.refLine,{dx:1,dy:0},a),i(e.refLineV,{dx:0,dy:1},o),2===e.picks.length){const t=e.picks[0],i=e.picks[1],a=X(t,i),o=(()=>{const e=ie.current,t=e.picks[0],n=e.picks[1],r=X(t,n),s=Y.current,i=$.current;return null!==i&&Number.isFinite(i)&&"horizontal"===s?{from:{x:n.x,y:t.y},to:{x:n.x,y:n.y}}:null!==i&&Number.isFinite(i)&&"vertical"===s?{from:{x:t.x,y:n.y},to:{x:n.x,y:n.y}}:"horizontal"===r?{from:t,to:{x:n.x,y:t.y}}:"vertical"===r?{from:t,to:{x:t.x,y:n.y}}:{from:t,to:n}})(),l=j(o.from.x,o.from.y),c=j(o.to.x,o.to.y);e.line.setAttribute("x1",String(l.x)),e.line.setAttribute("y1",String(l.y)),e.line.setAttribute("x2",String(c.x)),e.line.setAttribute("y2",String(c.y)),e.line.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.line.setAttribute("marker-end","url(#dxf-measure-arrow)");const d=Math.hypot(c.x-l.x,c.y-l.y);if(e.line.style.display=d>.5?"":"none",s&&e.fixedLine){const s="horizontal"===a?{x:i.x,y:t.y}:{x:t.x,y:i.y},o=j(t.x,t.y),l=j(s.x,s.y);e.fixedLine.setAttribute("x1",String(o.x)),e.fixedLine.setAttribute("y1",String(o.y)),e.fixedLine.setAttribute("x2",String(l.x)),e.fixedLine.setAttribute("y2",String(l.y)),e.fixedLine.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.fixedLine.setAttribute("marker-end","url(#dxf-measure-arrow)"),e.fixedLine.style.display="";const c=_();c.textContent=R(Math.abs(n));const d=(o.x+l.x)/2,u=(o.y+l.y)/2;c.style.left=`${d}px`,c.style.top=`${u}px`;const p=r.clientWidth,m=r.clientHeight;c.style.display=d<0||u<0||d>p||u>m?"none":""}else e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none");const u=e.extLineA,p=e.extLineB;if(!s&&"horizontal"===a&&Math.abs(i.y-t.y)>1e-9){const e=j(i.x,t.y),n=j(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else if(!s&&"vertical"===a&&Math.abs(i.x-t.x)>1e-9){const e=j(t.x,i.y),n=j(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else u.style.display="none",p.style.display="none";if(e.label){const t=(l.x+c.x)/2,n=(l.y+c.y)/2;e.label.style.left=`${t}px`,e.label.style.top=`${n}px`;const s=r.clientWidth,i=r.clientHeight;e.label.style.display=t<0||n<0||t>s||n>i?"none":"",d<=.5&&(e.label.style.display="none")}}else e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none")},_=()=>{const e=ie.current;if(e.fixedLabel)return e.fixedLabel;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.75);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.fixedLabel=t,t};let V=0,Q=0,J=0,ee=!1,ne=!1,re=null;const se=e=>{const t=e?.detail;t&&0===t.domEvent?.button&&(V=t.canvasCoord.x,Q=t.canvasCoord.y,J=performance.now(),ne=!1,ee=!0)},ae=e=>{const t=r.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;ee&&(n-V)**2+(s-Q)**2>16&&(ne=!0);const i=ie.current;var a;if(i&&i.snap)if(ee&&ne)i.snap.style.display="none";else if(re=((e,t)=>{const n=ie.current;if(!n||!T||!n.segs)return null;const r=j(0,0),s=j(1,0),i=j(0,1),a=s.x-r.x,o=s.y-r.y,l=i.x-r.x,c=i.y-r.y,d=a*c-l*o;if(!d)return null;const u=((e-r.x)*c-(t-r.y)*l)/d,p=((t-r.y)*a-(e-r.x)*o)/d,m=18/(Math.hypot(a,o)||1),h=18/(Math.hypot(l,c)||1),y=u-m,x=u+m,f=p-h,g=p+h,b=324;let w=null,v=b,k=null,N=b,C=null,A=b,E=null,L=b;const M=[],S=n.segs;for(let n=0;n<S.length;n+=4){const s=S[n],i=S[n+1],d=S[n+2],u=S[n+3];if(s<y&&d<y||s>x&&d>x||i<f&&u<f||i>g&&u>g)continue;const p=r.x+a*s+l*i,m=r.y+o*s+c*i,h=r.x+a*d+l*u,E=r.y+o*d+c*u;let L=!1,z=e-p,T=t-m,R=z*z+T*T;R<b&&(L=!0,R<v&&(v=R,w={sx:s,sy:i,type:"endpoint"})),z=e-h,T=t-E,R=z*z+T*T,R<b&&(L=!0,R<v&&(v=R,w={sx:d,sy:u,type:"endpoint"})),z=e-(p+h)/2,T=t-(m+E)/2,R=z*z+T*T,R<b&&(L=!0,R<N&&(N=R,k={sx:(s+d)/2,sy:(i+u)/2,type:"midpoint"}));const j=h-p,D=E-m,F=j*j+D*D;if(F>0){const n=((e-p)*j+(t-m)*D)/F;n>0&&n<1&&(z=e-(p+n*j),T=t-(m+n*D),R=z*z+T*T,R<b&&(L=!0,R<A&&(A=R,C={sx:s+n*(d-s),sy:i+n*(u-i),type:"line"})))}L&&M.push({ax:s,ay:i,bx:d,by:u,apx:p,apy:m,bpx:h,bpy:E})}const z=n.nodes;if(z)for(let n=0;n<z.length;n+=2){const s=z[n],i=z[n+1];if(s<y||s>x||i<f||i>g)continue;const d=e-(r.x+a*s+l*i),u=t-(r.y+o*s+c*i),p=d*d+u*u;p<v&&(v=p,w={sx:s,sy:i,type:"node"})}for(let n=0;n<M.length;n++){const r=M[n];for(let s=n+1;s<M.length;s++){const n=M[s],i=I(r.apx,r.apy,r.bpx,r.bpy,n.apx,n.apy,n.bpx,n.bpy);if(!i)continue;const a=e-i.px,o=t-i.py,l=a*a+o*o;l>=b||l>=L||(L=l,E={sx:r.ax+i.t*(r.bx-r.ax),sy:r.ay+i.t*(r.by-r.ay),type:"intersection"})}}return(E&&w?L<v-1?E:w:E??w)??k??C})(n,s),re){const e=j(re.sx,re.sy);i.snap.style.left=`${e.x}px`,i.snap.style.top=`${e.y}px`,i.snap.style.display="",a=re.type,A.style.display="endpoint"===a?"":"none",E.style.display="intersection"===a?"":"none",L.style.display="line"===a?"":"none",M.style.display="midpoint"===a?"":"none",S.style.display="node"===a?"":"none"}else i.snap.style.display="none"},oe=e=>{if(!ee)return;ee=!1;const t=performance.now()-J;if(ne||t>350)return;const n=e?.detail?.position;if(!n)return;const r=re?{x:re.sx,y:re.sy}:{x:n.x,y:n.y};ue(r)},le=()=>{const e=ie.current;if(!e||2!==e.picks.length)return;B();const t=e.picks[0],n=e.picks[1],r=Y.current,s=X(t,n),i=$.current,a=null!==i&&Number.isFinite(i)&&("horizontal"===r||"vertical"===r);let o,c,d="",u=s;const p=Math.abs(n.x-t.x),m=Math.abs(n.y-t.y);if(a&&"horizontal"===r?(o=m,d=" ↕",u="vertical",c=D.current.echoLocked("ΔY",R(m),"ΔX",R(Math.abs(i)))):a&&"vertical"===r?(o=p,d=" ↔",u="horizontal",c=D.current.echoLocked("ΔX",R(p),"ΔY",R(Math.abs(i)))):"horizontal"===s?(o=p,d=" ↔",c=D.current.echoLinear(R(p),"ΔX")):"vertical"===s?(o=m,d=" ↕",c=D.current.echoLinear(R(m),"ΔY")):(o=Math.hypot(n.x-t.x,n.y-t.y),c=D.current.echoDistance(R(o),R(p),R(m))),!Number.isFinite(o))return W(null),U(null),void(e.label&&(e.label.style.opacity="0"));W(o),U(u),te(c);const h=(()=>{const e=ie.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.95);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.label=t,t})();h.style.opacity="1",h.textContent=`${R(o)}${d}`};Z.current=()=>{le(),G()};const ce=e=>{e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none"),e.label&&(e.label.style.opacity="0"),W(null),U(null)},de=()=>{const e=ie.current;if(e){for(const t of e.markers)t.parentElement?.removeChild(t);e.markers=[],e.picks=[],e.rawSecondClick=null,e.refLine&&(e.refLine.style.display="none"),e.refLineV&&(e.refLineV.style.display="none"),ce(e)}};q.current=de,K.current=()=>{const e=ie.current;if(!e||0===e.picks.length)return;e.picks.pop();const t=e.markers.pop();t?.parentElement?.removeChild(t),e.rawSecondClick=null,ce(e),G()};const ue=e=>{const t=ie.current;t&&(2===t.picks.length&&de(),0===t.picks.length?(t.picks.push({x:e.x,y:e.y}),t.markers.push(P())):(t.rawSecondClick={x:e.x,y:e.y},t.picks.push({x:e.x,y:e.y}),t.markers.push(P()),le()),G())},pe=e=>{"Escape"===e.key&&H(!1)};r.style.cursor="crosshair";try{e.Subscribe?.("pointerdown",se)}catch{}try{e.Subscribe?.("pointerup",oe)}catch{}try{e.Subscribe?.("viewChanged",G)}catch{}return r.addEventListener("pointermove",ae),window.addEventListener("keydown",pe),()=>{r.style.cursor="";try{e.Unsubscribe?.("pointerdown",se)}catch{}try{e.Unsubscribe?.("pointerup",oe)}catch{}try{e.Unsubscribe?.("viewChanged",G)}catch{}r.removeEventListener("pointermove",ae),window.removeEventListener("keydown",pe),Z.current=null,q.current=null,K.current=null,s(),W(null),U(null)}},[F,o,d,ae]),f(()=>{Z.current?.()},[I,X]);const oe=e=>{N(t=>t.map(t=>{if(t.visible===e)return t;try{a.current?.ShowLayer?.(t.name,e)}catch{}return{...t,visible:e}}))},le=()=>{try{const e=a.current,t=e?.GetBounds?.(),n=e?.GetOrigin?.();t&&n?e.FitView(t.minX-n.x,t.maxX-n.x,t.minY-n.y,t.maxY-n.y):e?.FitView?.(),e?.Render?.()}catch{}};f(()=>{const e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;if(1!==e.key.length||" "===e.key)return;const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=se.current;if(!n)return;const r=n.closest("[data-modal-id]");r&&c()!==r.dataset.modalId||re.current?.focus()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);const ce=y(Q),de=y(F);f(()=>{ce.current=Q},[Q]),f(()=>{de.current=F},[F]),f(()=>u(()=>{const e=se.current;if(!e)return!1;const t=e.closest("[data-modal-id]");return!(!t||c()!==t.dataset.modalId)&&(ce.current?(J(""),te(D.current.cancelled),!0):!!de.current&&(H(!1),te(D.current.measureOff),!0))}),[]);const ue="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1",[pe,me]=m(T.typeToMeasure);/* @__PURE__ */
38
+ /* @__PURE__ */b("style",{children:"@keyframes preview-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }"})]})}var A=["https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/Roboto-LightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NotoSansDisplay-SemiCondensedLightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NanumGothic-Regular.ttf"],E={l:"LINE",line:"LINE",pl:"PLINE",pline:"PLINE",ex:"EXTEND",extend:"EXTEND",tr:"TRIM",trim:"TRIM",e:"ERASE",erase:"ERASE",m:"MOVE",move:"MOVE",co:"COPY",cp:"COPY",copy:"COPY",o:"OFFSET",offset:"OFFSET",f:"FILLET",fillet:"FILLET",cha:"CHAMFER",chamfer:"CHAMFER",x:"EXPLODE",explode:"EXPLODE",mi:"MIRROR",mirror:"MIRROR",ro:"ROTATE",rotate:"ROTATE",sc:"SCALE",scale:"SCALE",s:"STRETCH",stretch:"STRETCH",ar:"ARRAY",array:"ARRAY",rec:"RECTANG",rectang:"RECTANG",rectangle:"RECTANG",c:"CIRCLE",circle:"CIRCLE",a:"ARC",arc:"ARC",el:"ELLIPSE",ellipse:"ELLIPSE",t:"MTEXT",mt:"MTEXT",mtext:"MTEXT",text:"TEXT",b:"BLOCK",block:"BLOCK",i:"INSERT",insert:"INSERT",ha:"HATCH",hatch:"HATCH"};function L({url:e,filename:t,onDownload:r,onEmail:s}){const i=y(null),a=y(null),[o,l]=x(!0),[d,v]=x(null),[k,N]=x([]),[C,L]=x(!1),[S,M]=x(!0),z=p(),T=z.drawing,j=z.preview,D=y(T);D.current=T;const[F,H]=x(!1),[I,P]=x("auto"),[O,W]=x(null),[B,U]=x(null),[X,G]=x(null),[_,V]=x(""),Y=y(I),$=y(X);f(()=>{Y.current=I},[I]),f(()=>{$.current=X},[X]);const Z=y(null),q=y(null),K=y(null),[Q,J]=x(""),[ee,te]=x(null),ne=y(""),re=y(null),se=y(null),ie=y(null);f(()=>{let t=!1,n=null;return l(!0),v(null),N([]),(async()=>{let r;try{r=(await(import("dxf-viewer"))).DxfViewer}catch(e){return void(t||(v(D.current.notInstalled),l(!1)))}if(!t&&i.current)try{if(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),t||!i.current)return;const s={autoResize:!0},o=r.DefaultOptions?.clearColor;"function"==typeof o?.clone&&(s.clearColor=o.clone().setHex(16777215)),n=new r(i.current,s),a.current=n;const c="undefined"!=typeof window&&window.__REACT_OS_SHELL_DXF_FONTS__||A;if(await n.Load({url:e,fonts:c,workerFactory:null}),t)return;try{const e=n.GetLayers?.()??[];Array.isArray(e)&&N(e.map(e=>({name:e.name,displayName:e.displayName??e.name,color:"number"==typeof e.color?e.color:void 0,visible:!0})))}catch{}const d=()=>{try{const e=i.current?.getBoundingClientRect();e&&e.width>0&&e.height>0&&n.SetSize?.(Math.round(e.width),Math.round(e.height));const t=n.GetBounds?.(),r=n.GetOrigin?.();t&&r&&n.FitView(t.minX-r.x,t.maxX-r.x,t.minY-r.y,t.maxY-r.y),n.Render?.()}catch(e){console.warn("[Preview] DXF refit failed",e)}};d(),requestAnimationFrame(d),l(!1)}catch(e){t||(v(e?.message||D.current.renderFailed),l(!1))}})(),()=>{t=!0;try{n?.Destroy?.()}catch{}a.current=null}},[e]),f(()=>{if(!S||o)return;const e=setTimeout(()=>M(!1),5e3);return()=>clearTimeout(e)},[S,o]);const ae=k.map(e=>e.visible?"1":"0").join("");f(()=>{const e=a.current;if(o||d||!e)return;const t=e.GetScene?.(),n=e.GetCamera?.(),r=e.GetCanvas?.();if(!(t&&n&&r&&i.current))return;const s=()=>{const e=ie.current;e&&(e.overlay&&e.overlay.parentElement&&e.overlay.parentElement.removeChild(e.overlay),ie.current=null)};if(!F)return s(),W(null),void U(null);const l=document.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:5;",i.current.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;pointer-events:none;");const u=document.createElementNS("http://www.w3.org/2000/svg","defs"),p=document.createElementNS("http://www.w3.org/2000/svg","marker");p.setAttribute("id","dxf-measure-arrow"),p.setAttribute("viewBox","0 0 10 10"),p.setAttribute("refX","9"),p.setAttribute("refY","5"),p.setAttribute("markerWidth","6"),p.setAttribute("markerHeight","6"),p.setAttribute("orient","auto-start-reverse");const m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),m.setAttribute("fill","#ff8800"),p.appendChild(m),u.appendChild(p),c.appendChild(u),l.appendChild(c);const h=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","line");return e.setAttribute("stroke","#ff8800"),e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","6,4"),e.setAttribute("opacity","0.55"),e.style.display="none",c.appendChild(e),e},y=h(),x=h(),f=document.createElementNS("http://www.w3.org/2000/svg","line");f.setAttribute("stroke","#ff8800"),f.setAttribute("stroke-width","1"),f.setAttribute("opacity","0.85"),f.style.display="none",c.appendChild(f);const g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("stroke","#ff8800"),g.setAttribute("stroke-width","1"),g.setAttribute("opacity","0.85"),g.style.display="none",c.appendChild(g);const b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("stroke","#ff8800"),b.setAttribute("stroke-width","1.5"),b.setAttribute("stroke-linecap","round"),b.style.display="none",c.appendChild(b);const w=document.createElementNS("http://www.w3.org/2000/svg","line");w.setAttribute("stroke","#ff8800"),w.setAttribute("stroke-width","1.5"),w.setAttribute("stroke-linecap","round"),w.style.display="none",c.appendChild(w);const v=document.createElement("div");v.style.cssText="position:absolute;transform:translate(-50%,-50%);pointer-events:none;display:none;";const k="http://www.w3.org/2000/svg",N=document.createElementNS(k,"svg");N.setAttribute("width","22"),N.setAttribute("height","22"),N.setAttribute("viewBox","0 0 22 22"),N.setAttribute("style","overflow:visible;display:block"),v.appendChild(N);const C=e=>{const t=document.createElementNS(k,"g");return e(t),t.style.display="none",N.appendChild(t),t},A=C(e=>{const t=document.createElementNS(k,"rect");t.setAttribute("x","4"),t.setAttribute("y","4"),t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t)}),E=C(e=>{const t=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","2.2"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(t(4,4,18,18)),e.appendChild(t(18,4,4,18))}),L=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","4,4 18,4 4,18 18,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),S=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","11,3 19,18 3,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),M=C(e=>{const t=document.createElementNS(k,"circle");t.setAttribute("cx","11"),t.setAttribute("cy","11"),t.setAttribute("r","7"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t);const n=(e,t,n,r)=>{const s=document.createElementNS(k,"line");return s.setAttribute("x1",String(e)),s.setAttribute("y1",String(t)),s.setAttribute("x2",String(n)),s.setAttribute("y2",String(r)),s.setAttribute("stroke","#ff8800"),s.setAttribute("stroke-width","1.6"),s.setAttribute("stroke-linecap","round"),s};e.appendChild(n(6.5,6.5,15.5,15.5)),e.appendChild(n(15.5,6.5,6.5,15.5))});l.appendChild(v),ie.current={picks:[],rawSecondClick:null,overlay:l,svg:c,line:b,fixedLine:w,fixedLabel:null,refLine:y,refLineV:x,extLineA:f,extLineB:g,markers:[],label:null,snap:v,segs:null,nodes:null};const z=n?.position?.constructor??t?.position?.constructor??null;let T=!1;const j=(e,t)=>{if(!z)return{x:0,y:0};const s=new z(e,t,0).project(n),i=r.clientWidth,a=r.clientHeight;return{x:(s.x+1)/2*i,y:(1-s.y)/2*a}};(()=>{try{const e=ie.current;if(!e)return;const n=[],r=[];let s=!1;const i=e=>{const t=e?.attributes?.instanceTransform0,n=e?.attributes?.instanceTransform1;if(t&&n){const e=[],r=Math.min(t.count,n.count);for(let s=0;s<r;s++)e.push([t.getX(s),t.getY(s),t.getZ(s),n.getX(s),n.getY(s),n.getZ(s)]);return e}const r=e?.attributes?.instanceTransform;if(r){const e=[];for(let t=0;t<r.count;t++)e.push([1,0,r.getX(t),0,1,r.getY(t)]);return e}return[[1,0,0,0,1,0]]},a=e=>{const t=!!e?.isLineSegments;if(!t&&!!!e?.isPoints)return;const a=e.geometry,o=a?.attributes?.position;if(!o)return;const l=i(a);if(t){const e=a.index,t=Math.floor((e?e.count:o.count)/2);for(let r=0;r<t;r++){const t=e?e.getX(2*r):2*r,i=e?e.getX(2*r+1):2*r+1,a=o.getX(t),c=o.getY(t),d=o.getX(i),u=o.getY(i);if(Number.isFinite(a+c+d+u))for(const e of l){if(n.length>=16e5)return void(s=!0);const t=e[0]*a+e[1]*c+e[2],r=e[3]*a+e[4]*c+e[5],i=e[0]*d+e[1]*u+e[2],o=e[3]*d+e[4]*u+e[5];t===i&&r===o||n.push(t,r,i,o)}}}else for(let e=0;e<o.count;e++){const t=o.getX(e),n=o.getY(e);if(Number.isFinite(t+n))for(const e of l)r.push(e[0]*t+e[1]*n+e[2],e[3]*t+e[4]*n+e[5])}};"function"==typeof t.traverseVisible?t.traverseVisible(a):t.traverse(a),e.segs=new Float64Array(n),e.nodes=new Float64Array(r),s&&console.warn("[Preview] DXF snap cache truncated at 400000 segments — snapping may miss some geometry."),T=!0}catch{}})();const I=(e,t,n,r,s,i,a,o)=>{const l=(n-e)*(o-i)-(r-t)*(a-s);if(Math.abs(l)<1e-9)return null;const c=((s-e)*(o-i)-(i-t)*(a-s))/l,d=((s-e)*(r-t)-(i-t)*(n-e))/l,u=1e-4;return c<-u||c>1+u||d<-u||d>1+u?null:{px:e+c*(n-e),py:t+c*(r-t),t:c}},P=()=>{const e=document.createElement("div");return e.style.cssText="position:absolute;width:10px;height:10px;border-radius:50%;background:#ff8800;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,0.25);transform:translate(-50%,-50%);pointer-events:none;",l.appendChild(e),e},O=(e,t,n)=>{const r=j(t,n);e.style.left=`${r.x}px`,e.style.top=`${r.y}px`},B=()=>{const e=ie.current;if(!e||!e.rawSecondClick||e.picks.length<2)return;const t=e.picks[0],n=e.rawSecondClick,r=$.current,s=Y.current;if(null===r||!Number.isFinite(r)||"horizontal"!==s&&"vertical"!==s)e.picks[1]={x:n.x,y:n.y};else if("horizontal"===s){const s=n.x>=t.x?1:-1;e.picks[1]={x:t.x+s*Math.abs(r),y:n.y}}else{const s=n.y>=t.y?1:-1;e.picks[1]={x:n.x,y:t.y+s*Math.abs(r)}}},X=(e,t)=>{const n=Y.current;return"auto"!==n?n:e&&t?Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?"horizontal":"vertical":"horizontal"},G=()=>{const e=ie.current;if(!e)return;B();const t=Y.current,n=$.current,s=null!==n&&Number.isFinite(n)&&("horizontal"===t||"vertical"===t);e.markers[0]&&O(e.markers[0],e.picks[0].x,e.picks[0].y),e.markers[1]&&O(e.markers[1],e.picks[1].x,e.picks[1].y);const i=(t,n,s)=>{if(!t)return;if(!s||e.picks.length<1)return void(t.style.display="none");const i=e.picks[0],a=r.clientWidth,o=r.clientHeight,l=4*Math.hypot(a,o),c=j(i.x,i.y),d=j(i.x+n.dx,i.y+n.dy),u=l/(Math.hypot(d.x-c.x,d.y-c.y)||1),p=j(i.x-n.dx*u,i.y-n.dy*u),m=j(i.x+n.dx*u,i.y+n.dy*u);t.setAttribute("x1",String(p.x)),t.setAttribute("y1",String(p.y)),t.setAttribute("x2",String(m.x)),t.setAttribute("y2",String(m.y)),t.style.display=""};let a="horizontal"===t,o="vertical"===t;if("auto"===t)if(e.picks.length>=2){const t=X(e.picks[0],e.picks[1]);a="horizontal"===t,o="vertical"===t}else a=!0,o=!0;if(i(e.refLine,{dx:1,dy:0},a),i(e.refLineV,{dx:0,dy:1},o),2===e.picks.length){const t=e.picks[0],i=e.picks[1],a=X(t,i),o=(()=>{const e=ie.current,t=e.picks[0],n=e.picks[1],r=X(t,n),s=Y.current,i=$.current;return null!==i&&Number.isFinite(i)&&"horizontal"===s?{from:{x:n.x,y:t.y},to:{x:n.x,y:n.y}}:null!==i&&Number.isFinite(i)&&"vertical"===s?{from:{x:t.x,y:n.y},to:{x:n.x,y:n.y}}:"horizontal"===r?{from:t,to:{x:n.x,y:t.y}}:"vertical"===r?{from:t,to:{x:t.x,y:n.y}}:{from:t,to:n}})(),l=j(o.from.x,o.from.y),c=j(o.to.x,o.to.y);e.line.setAttribute("x1",String(l.x)),e.line.setAttribute("y1",String(l.y)),e.line.setAttribute("x2",String(c.x)),e.line.setAttribute("y2",String(c.y)),e.line.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.line.setAttribute("marker-end","url(#dxf-measure-arrow)");const d=Math.hypot(c.x-l.x,c.y-l.y);if(e.line.style.display=d>.5?"":"none",s&&e.fixedLine){const s="horizontal"===a?{x:i.x,y:t.y}:{x:t.x,y:i.y},o=j(t.x,t.y),l=j(s.x,s.y);e.fixedLine.setAttribute("x1",String(o.x)),e.fixedLine.setAttribute("y1",String(o.y)),e.fixedLine.setAttribute("x2",String(l.x)),e.fixedLine.setAttribute("y2",String(l.y)),e.fixedLine.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.fixedLine.setAttribute("marker-end","url(#dxf-measure-arrow)"),e.fixedLine.style.display="";const c=_();c.textContent=R(Math.abs(n));const d=(o.x+l.x)/2,u=(o.y+l.y)/2;c.style.left=`${d}px`,c.style.top=`${u}px`;const p=r.clientWidth,m=r.clientHeight;c.style.display=d<0||u<0||d>p||u>m?"none":""}else e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none");const u=e.extLineA,p=e.extLineB;if(!s&&"horizontal"===a&&Math.abs(i.y-t.y)>1e-9){const e=j(i.x,t.y),n=j(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else if(!s&&"vertical"===a&&Math.abs(i.x-t.x)>1e-9){const e=j(t.x,i.y),n=j(i.x,i.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else u.style.display="none",p.style.display="none";if(e.label){const t=(l.x+c.x)/2,n=(l.y+c.y)/2;e.label.style.left=`${t}px`,e.label.style.top=`${n}px`;const s=r.clientWidth,i=r.clientHeight;e.label.style.display=t<0||n<0||t>s||n>i?"none":"",d<=.5&&(e.label.style.display="none")}}else e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none")},_=()=>{const e=ie.current;if(e.fixedLabel)return e.fixedLabel;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.75);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.fixedLabel=t,t};let V=0,Q=0,J=0,ee=!1,ne=!1,re=null;const se=e=>{const t=e?.detail;t&&0===t.domEvent?.button&&(V=t.canvasCoord.x,Q=t.canvasCoord.y,J=performance.now(),ne=!1,ee=!0)},ae=e=>{const t=r.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;ee&&(n-V)**2+(s-Q)**2>16&&(ne=!0);const i=ie.current;var a;if(i&&i.snap)if(ee&&ne)i.snap.style.display="none";else if(re=((e,t)=>{const n=ie.current;if(!n||!T||!n.segs)return null;const r=j(0,0),s=j(1,0),i=j(0,1),a=s.x-r.x,o=s.y-r.y,l=i.x-r.x,c=i.y-r.y,d=a*c-l*o;if(!d)return null;const u=((e-r.x)*c-(t-r.y)*l)/d,p=((t-r.y)*a-(e-r.x)*o)/d,m=18/(Math.hypot(a,o)||1),h=18/(Math.hypot(l,c)||1),y=u-m,x=u+m,f=p-h,g=p+h,b=324;let w=null,v=b,k=null,N=b,C=null,A=b,E=null,L=b;const S=[],M=n.segs;for(let n=0;n<M.length;n+=4){const s=M[n],i=M[n+1],d=M[n+2],u=M[n+3];if(s<y&&d<y||s>x&&d>x||i<f&&u<f||i>g&&u>g)continue;const p=r.x+a*s+l*i,m=r.y+o*s+c*i,h=r.x+a*d+l*u,E=r.y+o*d+c*u;let L=!1,z=e-p,T=t-m,R=z*z+T*T;R<b&&(L=!0,R<v&&(v=R,w={sx:s,sy:i,type:"endpoint"})),z=e-h,T=t-E,R=z*z+T*T,R<b&&(L=!0,R<v&&(v=R,w={sx:d,sy:u,type:"endpoint"})),z=e-(p+h)/2,T=t-(m+E)/2,R=z*z+T*T,R<b&&(L=!0,R<N&&(N=R,k={sx:(s+d)/2,sy:(i+u)/2,type:"midpoint"}));const j=h-p,D=E-m,F=j*j+D*D;if(F>0){const n=((e-p)*j+(t-m)*D)/F;n>0&&n<1&&(z=e-(p+n*j),T=t-(m+n*D),R=z*z+T*T,R<b&&(L=!0,R<A&&(A=R,C={sx:s+n*(d-s),sy:i+n*(u-i),type:"line"})))}L&&S.push({ax:s,ay:i,bx:d,by:u,apx:p,apy:m,bpx:h,bpy:E})}const z=n.nodes;if(z)for(let n=0;n<z.length;n+=2){const s=z[n],i=z[n+1];if(s<y||s>x||i<f||i>g)continue;const d=e-(r.x+a*s+l*i),u=t-(r.y+o*s+c*i),p=d*d+u*u;p<v&&(v=p,w={sx:s,sy:i,type:"node"})}for(let n=0;n<S.length;n++){const r=S[n];for(let s=n+1;s<S.length;s++){const n=S[s],i=I(r.apx,r.apy,r.bpx,r.bpy,n.apx,n.apy,n.bpx,n.bpy);if(!i)continue;const a=e-i.px,o=t-i.py,l=a*a+o*o;l>=b||l>=L||(L=l,E={sx:r.ax+i.t*(r.bx-r.ax),sy:r.ay+i.t*(r.by-r.ay),type:"intersection"})}}return(E&&w?L<v-1?E:w:E??w)??k??C})(n,s),re){const e=j(re.sx,re.sy);i.snap.style.left=`${e.x}px`,i.snap.style.top=`${e.y}px`,i.snap.style.display="",a=re.type,A.style.display="endpoint"===a?"":"none",E.style.display="intersection"===a?"":"none",L.style.display="line"===a?"":"none",S.style.display="midpoint"===a?"":"none",M.style.display="node"===a?"":"none"}else i.snap.style.display="none"},oe=e=>{if(!ee)return;ee=!1;const t=performance.now()-J;if(ne||t>350)return;const n=e?.detail?.position;if(!n)return;const r=re?{x:re.sx,y:re.sy}:{x:n.x,y:n.y};ue(r)},le=()=>{const e=ie.current;if(!e||2!==e.picks.length)return;B();const t=e.picks[0],n=e.picks[1],r=Y.current,s=X(t,n),i=$.current,a=null!==i&&Number.isFinite(i)&&("horizontal"===r||"vertical"===r);let o,c,d="",u=s;const p=Math.abs(n.x-t.x),m=Math.abs(n.y-t.y);if(a&&"horizontal"===r?(o=m,d=" ↕",u="vertical",c=D.current.echoLocked("ΔY",R(m),"ΔX",R(Math.abs(i)))):a&&"vertical"===r?(o=p,d=" ↔",u="horizontal",c=D.current.echoLocked("ΔX",R(p),"ΔY",R(Math.abs(i)))):"horizontal"===s?(o=p,d=" ↔",c=D.current.echoLinear(R(p),"ΔX")):"vertical"===s?(o=m,d=" ↕",c=D.current.echoLinear(R(m),"ΔY")):(o=Math.hypot(n.x-t.x,n.y-t.y),c=D.current.echoDistance(R(o),R(p),R(m))),!Number.isFinite(o))return W(null),U(null),void(e.label&&(e.label.style.opacity="0"));W(o),U(u),te(c);const h=(()=>{const e=ie.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:var(--text-2xs);font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.95);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.label=t,t})();h.style.opacity="1",h.textContent=`${R(o)}${d}`};Z.current=()=>{le(),G()};const ce=e=>{e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none"),e.label&&(e.label.style.opacity="0"),W(null),U(null)},de=()=>{const e=ie.current;if(e){for(const t of e.markers)t.parentElement?.removeChild(t);e.markers=[],e.picks=[],e.rawSecondClick=null,e.refLine&&(e.refLine.style.display="none"),e.refLineV&&(e.refLineV.style.display="none"),ce(e)}};q.current=de,K.current=()=>{const e=ie.current;if(!e||0===e.picks.length)return;e.picks.pop();const t=e.markers.pop();t?.parentElement?.removeChild(t),e.rawSecondClick=null,ce(e),G()};const ue=e=>{const t=ie.current;t&&(2===t.picks.length&&de(),0===t.picks.length?(t.picks.push({x:e.x,y:e.y}),t.markers.push(P())):(t.rawSecondClick={x:e.x,y:e.y},t.picks.push({x:e.x,y:e.y}),t.markers.push(P()),le()),G())},pe=e=>{"Escape"===e.key&&H(!1)};r.style.cursor="crosshair";try{e.Subscribe?.("pointerdown",se)}catch{}try{e.Subscribe?.("pointerup",oe)}catch{}try{e.Subscribe?.("viewChanged",G)}catch{}return r.addEventListener("pointermove",ae),window.addEventListener("keydown",pe),()=>{r.style.cursor="";try{e.Unsubscribe?.("pointerdown",se)}catch{}try{e.Unsubscribe?.("pointerup",oe)}catch{}try{e.Unsubscribe?.("viewChanged",G)}catch{}r.removeEventListener("pointermove",ae),window.removeEventListener("keydown",pe),Z.current=null,q.current=null,K.current=null,s(),W(null),U(null)}},[F,o,d,ae]),f(()=>{Z.current?.()},[I,X]);const oe=e=>{N(t=>t.map(t=>{if(t.visible===e)return t;try{a.current?.ShowLayer?.(t.name,e)}catch{}return{...t,visible:e}}))},le=()=>{try{const e=a.current,t=e?.GetBounds?.(),n=e?.GetOrigin?.();t&&n?e.FitView(t.minX-n.x,t.maxX-n.x,t.minY-n.y,t.maxY-n.y):e?.FitView?.(),e?.Render?.()}catch{}};f(()=>{const e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;if(1!==e.key.length||" "===e.key)return;const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=se.current;if(!n)return;const r=n.closest("[data-modal-id]");r&&c()!==r.dataset.modalId||re.current?.focus()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);const ce=y(Q),de=y(F);f(()=>{ce.current=Q},[Q]),f(()=>{de.current=F},[F]),f(()=>u(()=>{const e=se.current;if(!e)return!1;const t=e.closest("[data-modal-id]");return!(!t||c()!==t.dataset.modalId)&&(ce.current?(J(""),te(D.current.cancelled),!0):!!de.current&&(H(!1),te(D.current.measureOff),!0))}),[]);const ue="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1",[pe,me]=m(T.typeToMeasure);/* @__PURE__ */
39
39
  return g("div",{ref:se,className:"flex flex-col h-full",children:[
40
40
  /* @__PURE__ */g(n,{children:[
41
41
  /* @__PURE__ */g("button",{onClick:()=>L(e=>!e),className:ue+(C?" bg-gray-200":""),title:T.layersHint,disabled:0===k.length,children:[
42
42
  /* @__PURE__ */b(h,{name:"layers",className:"h-3.5 w-3.5",strokeWidth:1.5}),T.layers," ",k.length>0&&/* @__PURE__ */g("span",{className:"text-gray-400",children:["(",k.filter(e=>e.visible).length,"/",k.length,")"]})]}),
43
- /* @__PURE__ */b("button",{onClick:()=>S(e=>!e),className:ue,title:j.howToNavigate,children:/* @__PURE__ */b(h,{name:"help",className:"h-3.5 w-3.5",strokeWidth:1.5})}),
43
+ /* @__PURE__ */b("button",{onClick:()=>M(e=>!e),className:ue,title:j.howToNavigate,children:/* @__PURE__ */b(h,{name:"help",className:"h-3.5 w-3.5",strokeWidth:1.5})}),
44
44
  /* @__PURE__ */g("button",{onClick:()=>H(e=>!e),className:ue+(F?" bg-gray-200":""),title:F?j.stopMeasuring:T.measureHint,children:[
45
45
  /* @__PURE__ */g("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[
46
46
  /* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 14.25l6-6 6 6 4.5-4.5M9.75 8.25v3M12.75 11.25v3M15.75 14.25v3"}),
@@ -66,7 +66,7 @@ return g("div",{ref:se,className:"flex flex-col h-full",children:[
66
66
  /* @__PURE__ */b("div",{className:"overflow-y-auto py-1",children:k.map(e=>{/* @__PURE__ */return g("label",{className:"flex items-center gap-2 px-2 py-1 hover:bg-gray-100 cursor-pointer",children:[
67
67
  /* @__PURE__ */b("input",{type:"checkbox",checked:e.visible,onChange:()=>{return t=e.name,void N(e=>e.map(e=>{if(e.name!==t)return e;const n=!e.visible;try{a.current?.ShowLayer?.(t,n)}catch{}return{...e,visible:n}}));var t},className:"h-3.5 w-3.5"}),
68
68
  /* @__PURE__ */b("span",{className:"inline-block h-3 w-3 rounded-sm border border-gray-300 shrink-0",style:{background:(t=e.color,"number"!=typeof t?"#999":"#"+t.toString(16).padStart(6,"0"))}}),
69
- /* @__PURE__ */b("span",{className:"truncate text-gray-700",title:e.displayName,children:e.displayName||e.name})]},e.name);var t})})]}),M&&!o&&!d&&/* @__PURE__ */g("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 bg-gray-900/85 text-white text-2xs px-3 min-h-8 py-1 rounded-full shadow-lg flex items-center gap-3 z-10 pointer-events-none",children:[
69
+ /* @__PURE__ */b("span",{className:"truncate text-gray-700",title:e.displayName,children:e.displayName||e.name})]},e.name);var t})})]}),S&&!o&&!d&&/* @__PURE__ */g("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 bg-gray-900/85 text-white text-2xs px-3 min-h-8 py-1 rounded-full shadow-lg flex items-center gap-3 z-10 pointer-events-none",children:[
70
70
  /* @__PURE__ */g("span",{className:"flex items-center gap-1",children:[
71
71
  /* @__PURE__ */b("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})}),T.dragToPan]}),
72
72
  /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
@@ -81,7 +81,7 @@ return g("div",{ref:se,className:"flex flex-col h-full",children:[
81
81
  /* @__PURE__ */g("div",{className:"shrink-0 border-t border-gray-200 bg-gray-50",children:[ee&&/* @__PURE__ */b("div",{className:"px-3 pt-1 text-2xs font-mono text-gray-500 truncate",title:ee,children:ee}),
82
82
  /* @__PURE__ */g("div",{className:"flex items-center gap-2 px-3 h-7",children:[
83
83
  /* @__PURE__ */b("span",{className:"text-2xs font-mono font-semibold text-gray-400 select-none",children:">"}),
84
- /* @__PURE__ */b("input",{ref:re,value:Q,onChange:e=>J(e.target.value),onKeyDown:e=>{"Enter"===e.key||" "===e.key?(e.preventDefault(),(e=>{const t=e.trim()||ne.current;if(J(""),!t)return;const n=t.toLowerCase().split(/\s+/)[0],r=()=>{ne.current=t},s=(e,t)=>{H(!0),P(e),q.current?.(),te(t),r()};if(/^-?(\d+\.?\d*|\.\d+)$/.test(n))if(!F||"horizontal"!==I&&"vertical"!==I)te(T.fixedNeedsAxis);else{const e=parseFloat(n);e?(V(n),G(e),te(T.axisLocked("horizontal"===I?"ΔX":"ΔY",R(Math.abs(e))))):(V(""),G(null),te(T.fixedCleared))}else switch(n){case"di":case"dist":case"mea":case"measuregeom":s("point",T.echoDist);break;case"dim":case"dli":case"dimlin":case"dimlinear":s("auto",T.echoDimLinear);break;case"h":case"hor":case"horizontal":H(!0),P("horizontal"),te(T.echoHorizontal),r();break;case"v":case"ver":case"vertical":H(!0),P("vertical"),te(T.echoVertical),r();break;case"au":case"auto":H(!0),P("auto"),te(T.echoAuto),r();break;case"measure":H(!F),te(F?T.measureOff:T.measureOn),r();break;case"u":case"undo":K.current?.(),te(T.pickRemoved),r();break;case"z":case"ze":case"zoom":case"fit":case"zoomextents":le(),te(T.zoomExtents),r();break;case"la":case"layer":case"layers":L(e=>!e),te(T.layersToggled),r();break;case"off":case"clear":G(null),V(""),q.current?.(),te(T.measurementCleared),r();break;case"?":case"help":te(T.commandHelp);break;default:{const e=E[n];te(e?T.readOnly(e):T.unknownCommand(n.toUpperCase()))}}})(Q)):"Escape"===e.key&&(Q?(e.stopPropagation(),J(""),te(T.cancelled)):e.target.blur())},placeholder:T.commandPlaceholder,spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-2xs font-mono text-gray-700 focus:outline-none placeholder:text-gray-300"})]})]})]})}var M="https://cdn.jsdelivr.net/npm/online-3d-viewer@0.18.0/libs/";function S(e,t,n=0){return{id:e.GetId?.()??0,name:e.GetName?.()||(0===n?t.root:t.node),isMeshNode:!!e.IsMeshNode?.(),meshIndices:e.GetMeshIndices?.()??[],children:(e.GetChildNodes?.()??[]).map(e=>S(e,t,n+1))}}function z(e,t){t.add(e.id);for(const n of e.children)z(n,t)}function T(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(t),r=n?parseInt(n[1],16):0;return new e.RGBColor(r>>16&255,r>>8&255,255&r)}function R(e){return e>=1e3?`${(e/1e3).toFixed(3)} m`:`${e.toFixed(2)} mm`}function j({url:e,filename:t,onDownload:r,onEmail:s}){const i=y(null),a=y(null),o=y(null),[l,c]=x(!0),[d,u]=x(null),[m,w]=x(!0),k=p(),N=k.model,C=k.preview,A=y(N);A.current=N;const[E,L]=x(null),[j,D]=x({}),[F,H]=x(/* @__PURE__ */new Set),[I,P]=x("#f5f6f8"),[O,W]=x(!0),[B,U]=x("#000000"),[X,G]=x(1),[_,V]=x(!1),[Y,$]=x(!1),[Z,q]=x(!1),[K,Q]=x(!1),[J,ee]=x("x"),[te,ne]=x(!1),[re,se]=x(.5),[ie,ae]=x(0),[oe,le]=x(!1),[ce,de]=x("point"),[ue,pe]=x(null),me=y(null),he=y(null);f(()=>{let n=!1,r=null,s=null;return c(!0),u(null),L(null),D({}),H(/* @__PURE__ */new Set),(async()=>{let l;try{l=await(import("online-3d-viewer"))}catch{return void(n||(u(A.current.notInstalled),c(!1)))}if(o.current=l,!n&&i.current&&(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),!n&&i.current))try{const o="undefined"!=typeof window&&window.__REACT_OS_SHELL_O3DV_LIBS__||M;l.SetExternalLibLocation?.(o),function(){if(v)return;if("undefined"==typeof HTMLCanvasElement)return;v=!0;const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,n){return"webgl"!==t&&"webgl2"!==t&&"experimental-webgl"!==t||(n={...n||{},stencil:!0}),e.call(this,t,n)},console.info("[Preview] section: canvas getContext patched (force stencil=true)")}(),r=new l.EmbeddedViewer(i.current,{backgroundColor:new l.RGBAColor(245,246,248,255),defaultColor:new l.RGBColor(180,188,200),edgeSettings:new l.EdgeSettings(!0,new l.RGBColor(0,0,0),1),onModelLoaded:()=>{if(!n){try{const e=r.GetModel?.(),t=e?.GetRootNode?.();if(t){const e=S(t,{root:A.current.rootNode,node:A.current.node});L(e);const n={[e.id]:!0};for(const t of e.children)n[t.id]=!0;D(n)}}catch(e){console.warn("[Preview] mesh tree extraction failed",e)}c(!1)}},onModelLoadFailed:()=>{n||(u(A.current.loadFailed),c(!1))}}),a.current=r;const d=new l.InputFile(t,l.FileSource.Url,e);r.LoadModelFromInputFiles([d]),i.current&&"undefined"!=typeof ResizeObserver&&(s=new ResizeObserver(()=>{try{const e=a.current;e?.Resize?e.Resize():e?.viewer?.Resize&&e.viewer.Resize(),e?.viewer?.Render?.()}catch{}}),s.observe(i.current))}catch(e){n||(u(e?.message||A.current.loadFailed),c(!1))}})(),()=>{n=!0;try{s?.disconnect()}catch{}try{r?.Destroy?.()}catch{}a.current=null}},[e,t]),f(()=>{const e=a.current;if(e?.viewer)try{const t=e=>{if(e.userData?.__sectionHelper)return;const t=e.userData?.originalMeshInstance??e.userData,n=t?.id?.nodeId??t?.nodeId;"number"==typeof n&&(e.visible=!F.has(n))};e.viewer.mainModel?.EnumerateMeshesAndLines?.(t),e.viewer.mainModel?.EnumerateEdges?.(t),e.viewer.Render?.()}catch(e){console.warn("[Preview] visibility update failed",e)}},[F,E]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{t.viewer.SetEdgeSettings(new e.EdgeSettings(O,T(e,B),X));const n=he.current;if(n){const e=[];t.viewer.mainModel?.EnumerateEdges?.(t=>{t.userData?.__sectionHelper&&e.push(t)});for(const t of e)t.parent?.remove(t),t.geometry?.dispose?.(),t.material?.dispose?.();const r=n.plane,s=e=>{e&&!n.materialState.has(e)&&(n.materialState.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[r],e.clipShadows=!0,e.needsUpdate=!0)};t.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)s(e);else s(t)})}t.viewer.Render?.()}catch{}},[O,B,X]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{const n=T(e,I);t.viewer.SetBackgroundColor(new e.RGBAColor(n.r,n.g,n.b,255)),t.viewer.Render?.()}catch{}},[I]),f(()=>{const e=a.current;if(!e?.viewer||l)return;const t=e.viewer.renderer,n=e.viewer.scene;if(!t||!n)return;if(he.current){const e=he.current;for(const[t,n]of e.materialState.entries())t.clippingPlanes=n.clippingPlanes,t.clipShadows=n.clipShadows,t.needsUpdate=!0;for(const t of e.helpers)t.parent?.remove(t),t.material?.dispose?.();e.capMesh&&(n.remove(e.capMesh),e.capMesh.geometry?.dispose?.(),e.capMesh.material?.dispose?.()),he.current=null}if(!K)return t.localClippingEnabled=!1,void e.viewer.Render?.();const r=e.viewer.GetBoundingBox?.(()=>!0);if(!r)return;const s=[];if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{e.userData?.__sectionHelper||s.push(e)}),!s.length)return t.localClippingEnabled=!1,void e.viewer.Render?.();const i=s[0],o=i.constructor,c=i.material?.constructor,d=i.geometry?.constructor,u=i.geometry?.attributes?.position?.constructor;o&&c&&d&&u||console.warn("[Preview] section: missing THREE constructors, falling back to no cap");const p=7681;let m=!0;try{const e=t.getContext?.(),n=e?.getContextAttributes?.();m=!1!==n?.stencil,t.autoClearStencil=!0,console.info("[Preview] section: stencil buffer =",m,"targets =",s.length)}catch{}t.localClippingEnabled=!0;const h={normal:{x:0,y:0,z:-1},constant:0,clone:function e(){const t={normal:{x:this.normal.x,y:this.normal.y,z:this.normal.z},constant:this.constant};return t.clone=e,t}},y=[],x=/* @__PURE__ */new Map,f=e=>{e&&!x.has(e)&&(x.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[h],e.clipShadows=!0,e.needsUpdate=!0)};for(const e of s){const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t);const n=Array.isArray(t)?t[0]:t;if(o&&m&&n?.clone){const t=(t,r)=>{const s=n.clone();s.depthWrite=!1,s.depthTest=!1,s.colorWrite=!1,s.stencilWrite=!0,s.stencilFunc=519,s.stencilFail=r,s.stencilZFail=r,s.stencilZPass=r,s.side=t,s.transparent=!1,s.clippingPlanes=[h],s.clipShadows=!0,s.needsUpdate=!0;const i=new o(e.geometry,s);i.matrixAutoUpdate=!1,i.renderOrder=1,i.userData.__sectionHelper=!0,e.add(i),y.push(i)};t(1,7682),t(0,7683)}}e.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t)});let g=null;const b=s[0]?.material&&(Array.isArray(s[0].material)?s[0].material[0]:s[0].material);if(m&&o&&d&&u&&b?.clone){const e=r.max.x-r.min.x,t=r.max.y-r.min.y,s=r.max.z-r.min.z,i=2*Math.max(e,t,s,1)/2,a=new d,l=new Float32Array([-i,-i,0,i,-i,0,i,i,0,-i,i,0]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]);a.setAttribute("position",new u(l,3)),a.setAttribute("normal",new u(c,3)),a.setIndex([0,1,2,0,2,3]);const m=b.clone(),h=b.color?.getHex?.()??11844808;m.emissive?.setHex?.(h),"emissiveIntensity"in m&&(m.emissiveIntensity=.25),m.side=2,m.transparent=!1,m.opacity=1,m.stencilWrite=!0,m.stencilRef=0,m.stencilFunc=517,m.stencilFail=p,m.stencilZFail=p,m.stencilZPass=p,m.clippingPlanes=[],m.polygonOffset=!0,m.polygonOffsetFactor=-1,m.polygonOffsetUnits=-1,m.needsUpdate=!0,g=new o(a,m),g.renderOrder=2,g.userData.__sectionHelper=!0,n.add(g)}he.current={plane:h,capMesh:g,helpers:y,materialState:x,bbox:r},console.info("[Preview] section: helpers =",y.length,"cap =",!!g),e.viewer.Render?.()},[K,l,E]),f(()=>{const e=a.current,t=he.current;if(e?.viewer&&t&&K)try{const n=t.bbox,r="x"===J?0:"y"===J?1:2,s=[n.min.x,n.min.y,n.min.z][r],i=s+([n.max.x,n.max.y,n.max.z][r]-s)*re,a=ie*Math.PI/180,o=Math.cos(a),l=Math.sin(a),c=te?-1:1;let d=0,u=0,p=0;"x"===J?(d=c*o,p=c*l):"y"===J?(u=c*o,d=c*l):(p=c*o,u=c*l);const m={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},h="x"===J?i:m.x,y="y"===J?i:m.y,x="z"===J?i:m.z;if(t.plane.normal.x=d,t.plane.normal.y=u,t.plane.normal.z=p,t.plane.constant=-(d*h+u*y+p*x),t.capMesh){const e=m.x,n=m.y,r=m.z,s=d*e+u*n+p*r+t.plane.constant,i=e-d*s,a=n-u*s,o=r-p*s;t.capMesh.position.set(i,a,o),t.capMesh.lookAt?.(i+d,a+u,o+p)}e.viewer.Render?.()}catch(e){console.warn("[Preview] section update failed",e)}},[K,J,te,re,ie]),f(()=>{const e=a.current;if(!e?.viewer||l||!i.current)return;const t=e.viewer.renderer,n=e.viewer.scene,r=t?.domElement;if(!t||!n||!r)return;let s=null;if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{s||e.userData?.__sectionHelper||e.userData?.__measureHelper||(s=e)}),!s)return;const c=s.position.constructor,d=s.constructor,u=(Array.isArray(s.material)?s.material[0]:s.material)?.constructor,p=s.geometry.constructor,m=s.geometry.attributes?.position?.constructor;if(!(c&&d&&u&&p&&m))return;let h=null,y=null;n.traverse(e=>{if(h&&y)return;if(!e?.isLineSegments)return;h=e.constructor;const t=Array.isArray(e.material)?e.material[0]:e.material;t?.constructor&&(y=t.constructor)});const x=()=>{const t=me.current;if(t){null!==t.rafId&&cancelAnimationFrame(t.rafId);for(const e of t.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();t.line&&(n.remove(t.line),t.line.geometry?.dispose?.(),t.line.material?.dispose?.()),t.label&&t.label.parentElement&&t.label.parentElement.removeChild(t.label),me.current=null,e.viewer.Render?.()}};if(!oe)return x(),void pe(null);me.current={points:[],normals:[],markers:[],line:null,label:null,rafId:null};const f=o.current,g=f?.IntersectionMode?.MeshOnly??1,b=e.viewer.GetBoundingBox?.(()=>!0),w=b?Math.sqrt((b.max.x-b.min.x)**2+(b.max.y-b.min.y)**2+(b.max.z-b.min.z)**2):100,v=Math.max(.005*w,.2),k=e=>{const t=[],r=[];for(let e=0;e<=12;e++){const n=e/12*Math.PI;for(let e=0;e<=16;e++){const r=e/16*Math.PI*2;t.push(v*Math.sin(n)*Math.cos(r),v*Math.cos(n),v*Math.sin(n)*Math.sin(r))}}for(let e=0;e<12;e++)for(let t=0;t<16;t++){const n=17*e+t,s=n+16+1;r.push(n,s,n+1,s,s+1,n+1)}const s=new p;s.setAttribute("position",new m(new Float32Array(t),3)),s.setIndex(r),s.computeVertexNormals?.();const i=new u;i.color?.setHex?.(16746496),i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=.95;const a=new d(s,i);return a.position.copy(e),a.renderOrder=9999,a.userData.__measureHelper=!0,n.add(a),a},N=()=>{const t=me.current;t&&((()=>{const t=me.current;if(!t||t.points.length<2||!t.label)return;const n=e.viewer.camera;if(!n)return;const s=t.points[0],i=t.points[1],a=new c((s.x+i.x)/2,(s.y+i.y)/2,(s.z+i.z)/2).clone();a.project?.(n);const o=r.getBoundingClientRect(),l=(a.x+1)/2*o.width,d=(1-a.y)/2*o.height;t.label.style.left=`${l}px`,t.label.style.top=`${d}px`;const u=l<0||d<0||l>o.width||d>o.height;t.label.style.opacity=a.z>1||u?"0":"1"})(),t.rafId=requestAnimationFrame(N))};me.current.rafId=requestAnimationFrame(N);let C=0,A=0,E=0,L=!1,M=!1;const S=t=>{if(!e.viewer.camera)return;const s=r.getBoundingClientRect(),a={x:t.clientX-s.left,y:t.clientY-s.top},o=e.viewer.GetMeshIntersectionUnderMouse?.(g,a);if(!o)return;const l=me.current,x=new c(o.point.x,o.point.y,o.point.z),f=(e=>{const t=e?.face?.normal,n=e?.object;if(!t||!n)return null;try{const e=new c(t.x,t.y,t.z);return e.transformDirection?.(n.matrixWorld),{x:e.x,y:e.y,z:e.z}}catch{return{x:t.x,y:t.y,z:t.z}}})(o);if(2===l.points.length){for(const e of l.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();l.line&&(n.remove(l.line),l.line.geometry?.dispose?.(),l.line.material?.dispose?.()),l.label&&(l.label.style.opacity="0"),l.points=[],l.markers=[],l.line=null,l.normals=[],pe(null)}if(l.points.push(x),l.normals.push(f),"perp"===ce){const e=((e,t)=>{const r=e?.geometry,s=r?.attributes?.position;if(!r||!s||!t?.face?.normal)return null;const i=s.array,a=r.index?r.index.array:null,o=new c(t.point.x,t.point.y,t.point.z);e.worldToLocal?.(o);const l=t.face.normal,h=-(l.x*o.x+l.y*o.y+l.z*o.z);r.computeBoundingBox?.();const y=r.boundingBox,x=y?Math.sqrt((y.max.x-y.min.x)**2+(y.max.y-y.min.y)**2+(y.max.z-y.min.z)**2):100,f=Math.max(.001*x,.005),g=a?a.length/3:s.count/3,b=[],w=new c;for(let t=0;t<g;t++){const n=a?a[3*t]:3*t,r=a?a[3*t+1]:3*t+1,s=a?a[3*t+2]:3*t+2,o=i[3*n],c=i[3*n+1],d=i[3*n+2],u=i[3*r],p=i[3*r+1],m=i[3*r+2],y=i[3*s],x=i[3*s+1],g=i[3*s+2],v=u-o,k=p-c,N=m-d,C=y-o,A=x-c,E=g-d;let L=k*E-N*A,M=N*C-v*E,S=v*A-k*C;const z=Math.sqrt(L*L+M*M+S*S);if(0===z)continue;if(L/=z,M/=z,S/=z,L*l.x+M*l.y+S*l.z<.9995)continue;const T=(o+u+y)/3,R=(c+p+x)/3,j=(d+m+g)/3;if(!(Math.abs(l.x*T+l.y*R+l.z*j+h)>f))for(const[t,n,r]of[[o,c,d],[u,p,m],[y,x,g]])w.set?.(t,n,r),e.localToWorld?.(w),b.push(w.x,w.y,w.z)}if(0===b.length)return null;const v=new p;v.setAttribute("position",new m(new Float32Array(b),3)),v.computeVertexNormals?.();const k=new u;k.color?.setHex?.(16746496),k.transparent=!0,k.opacity=.45,k.depthWrite=!1,k.polygonOffset=!0,k.polygonOffsetFactor=-2,k.polygonOffsetUnits=-2;const N=new d(v,k);return N.renderOrder=9998,N.userData.__measureHelper=!0,n.add(N),N})(o.object,o);l.markers.push(e??k(x))}else l.markers.push(k(x));if(2===l.points.length){const e=l.points[0];let t,r=l.points[1],s="";if("perp"===ce){const n=l.normals[0]??l.normals[1];if(n){const i=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)||1,a=n.x/i,o=n.y/i,d=n.z/i,u=(r.x-e.x)*a+(r.y-e.y)*o+(r.z-e.z)*d,p=new c(e.x+a*u,e.y+o*u,e.z+d*u);l.points[1]=p,r=p,t=Math.abs(u),s=" ⊥"}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}l.line=((e,t)=>{const r=new p;r.setAttribute("position",new m(new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),3));const s=new(h??d)(r,new(y??u)({color:16746496,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95}));return s.renderOrder=9998,s.userData.__measureHelper=!0,n.add(s),s})(e,r),pe(t);const a=(()=>{const e=me.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.transform="translate(-50%, -50%)",t.style.padding="2px 6px",t.style.fontSize="11px",t.style.fontWeight="600",t.style.fontFamily="system-ui, -apple-system, sans-serif",t.style.background="rgba(255, 136, 0, 0.95)",t.style.color="#fff",t.style.borderRadius="4px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.boxShadow="0 1px 4px rgba(0,0,0,0.25)",t.style.zIndex="5",i.current.appendChild(t),e.label=t,t})();a.textContent=`${R(t)}${s}`}e.viewer.Render?.()},z=e=>{0===e.button&&(C=e.clientX,A=e.clientY,E=performance.now(),L=!1,M=!0)},T=e=>{if(!M)return;const t=e.clientX-C,n=e.clientY-A;t*t+n*n>16&&(L=!0)},j=e=>{if(0!==e.button||!M)return;const t=performance.now()-E;M=!1,!L&&t<350&&S(e)},D=e=>{"Escape"===e.key&&le(!1)};return r.style.cursor="crosshair",r.addEventListener("pointerdown",z),r.addEventListener("pointermove",T),r.addEventListener("pointerup",j),r.addEventListener("pointercancel",j),window.addEventListener("keydown",D),()=>{r.style.cursor="",r.removeEventListener("pointerdown",z),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",j),r.removeEventListener("pointercancel",j),window.removeEventListener("keydown",D),x(),pe(null)}},[oe,ce,l,E]),f(()=>{if(!m||l)return;const e=setTimeout(()=>w(!1),5e3);return()=>clearTimeout(e)},[m,l]);const ye=e=>{const t=/* @__PURE__ */new Set;z(e,t),H(e=>{const n=new Set(e),r=[...t].some(e=>!n.has(e));for(const e of t)r?n.add(e):n.delete(e);return n})},xe=()=>{try{const e=a.current,t=e?.viewer?.GetBoundingSphere?.(()=>!0);t&&e.viewer.FitSphereToWindow(t,!0),e?.viewer?.Render?.()}catch{}};f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer&&!l)try{t.viewer.SetProjectionMode(Z?e.ProjectionMode.Perspective:e.ProjectionMode.Orthographic)}catch{}},[Z,l]);const fe=e=>{const t=o.current,n=a.current;if(t&&n?.viewer)try{const r=n.viewer.GetBoundingSphere?.(()=>!0);if(!r)return;const s=r.center,i=3*(r.radius||1),a=s.x??0,o=s.y??0,l=s.z??0;let c,d;switch(e){case"top":c=new t.Coord3D(a,o,l+i),d=new t.Coord3D(0,1,0);break;case"front":c=new t.Coord3D(a,o-i,l),d=new t.Coord3D(0,0,1);break;case"side":c=new t.Coord3D(a+i,o,l),d=new t.Coord3D(0,0,1);break;default:{const e=i/Math.sqrt(3);c=new t.Coord3D(a+e,o-e,l+e),d=new t.Coord3D(0,0,1);break}}const u=new t.Coord3D(a,o,l),p=new t.Camera(c,u,d,45);n.viewer.SetCamera(p),n.viewer.AdjustClippingPlanesToSphere?.(r),n.viewer.Render?.()}catch{}},ge=(t.split(".").pop()||"").toUpperCase(),be=(e,t=0)=>{const n=e.children.length>0,r=!1!==j[e.id],s=!F.has(e.id);/* @__PURE__ */
84
+ /* @__PURE__ */b("input",{ref:re,value:Q,onChange:e=>J(e.target.value),onKeyDown:e=>{"Enter"===e.key||" "===e.key?(e.preventDefault(),(e=>{const t=e.trim()||ne.current;if(J(""),!t)return;const n=t.toLowerCase().split(/\s+/)[0],r=()=>{ne.current=t},s=(e,t)=>{H(!0),P(e),q.current?.(),te(t),r()};if(/^-?(\d+\.?\d*|\.\d+)$/.test(n))if(!F||"horizontal"!==I&&"vertical"!==I)te(T.fixedNeedsAxis);else{const e=parseFloat(n);e?(V(n),G(e),te(T.axisLocked("horizontal"===I?"ΔX":"ΔY",R(Math.abs(e))))):(V(""),G(null),te(T.fixedCleared))}else switch(n){case"di":case"dist":case"mea":case"measuregeom":s("point",T.echoDist);break;case"dim":case"dli":case"dimlin":case"dimlinear":s("auto",T.echoDimLinear);break;case"h":case"hor":case"horizontal":H(!0),P("horizontal"),te(T.echoHorizontal),r();break;case"v":case"ver":case"vertical":H(!0),P("vertical"),te(T.echoVertical),r();break;case"au":case"auto":H(!0),P("auto"),te(T.echoAuto),r();break;case"measure":H(!F),te(F?T.measureOff:T.measureOn),r();break;case"u":case"undo":K.current?.(),te(T.pickRemoved),r();break;case"z":case"ze":case"zoom":case"fit":case"zoomextents":le(),te(T.zoomExtents),r();break;case"la":case"layer":case"layers":L(e=>!e),te(T.layersToggled),r();break;case"off":case"clear":G(null),V(""),q.current?.(),te(T.measurementCleared),r();break;case"?":case"help":te(T.commandHelp);break;default:{const e=E[n];te(e?T.readOnly(e):T.unknownCommand(n.toUpperCase()))}}})(Q)):"Escape"===e.key&&(Q?(e.stopPropagation(),J(""),te(T.cancelled)):e.target.blur())},placeholder:T.commandPlaceholder,spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-2xs font-mono text-gray-700 focus:outline-none placeholder:text-gray-300"})]})]})]})}var S="https://cdn.jsdelivr.net/npm/online-3d-viewer@0.18.0/libs/";function M(e,t,n=0){return{id:e.GetId?.()??0,name:e.GetName?.()||(0===n?t.root:t.node),isMeshNode:!!e.IsMeshNode?.(),meshIndices:e.GetMeshIndices?.()??[],children:(e.GetChildNodes?.()??[]).map(e=>M(e,t,n+1))}}function z(e,t){t.add(e.id);for(const n of e.children)z(n,t)}function T(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(t),r=n?parseInt(n[1],16):0;return new e.RGBColor(r>>16&255,r>>8&255,255&r)}function R(e){return e>=1e3?`${(e/1e3).toFixed(3)} m`:`${e.toFixed(2)} mm`}function j({url:e,filename:t,onDownload:r,onEmail:s}){const i=y(null),a=y(null),o=y(null),[l,c]=x(!0),[d,u]=x(null),[m,w]=x(!0),k=p(),N=k.model,C=k.preview,A=y(N);A.current=N;const[E,L]=x(null),[j,D]=x({}),[F,H]=x(/* @__PURE__ */new Set),[I,P]=x("#f5f6f8"),[O,W]=x(!0),[B,U]=x("#000000"),[X,G]=x(1),[_,V]=x(!1),[Y,$]=x(!1),[Z,q]=x(!1),[K,Q]=x(!1),[J,ee]=x("x"),[te,ne]=x(!1),[re,se]=x(.5),[ie,ae]=x(0),[oe,le]=x(!1),[ce,de]=x("point"),[ue,pe]=x(null),me=y(null),he=y(null);f(()=>{let n=!1,r=null,s=null;return c(!0),u(null),L(null),D({}),H(/* @__PURE__ */new Set),(async()=>{let l;try{l=await(import("online-3d-viewer"))}catch{return void(n||(u(A.current.notInstalled),c(!1)))}if(o.current=l,!n&&i.current&&(await new Promise(e=>{const t=()=>{const n=i.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),!n&&i.current))try{const o="undefined"!=typeof window&&window.__REACT_OS_SHELL_O3DV_LIBS__||S;l.SetExternalLibLocation?.(o),function(){if(v)return;if("undefined"==typeof HTMLCanvasElement)return;v=!0;const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,n){return"webgl"!==t&&"webgl2"!==t&&"experimental-webgl"!==t||(n={...n||{},stencil:!0}),e.call(this,t,n)},console.info("[Preview] section: canvas getContext patched (force stencil=true)")}(),r=new l.EmbeddedViewer(i.current,{backgroundColor:new l.RGBAColor(245,246,248,255),defaultColor:new l.RGBColor(180,188,200),edgeSettings:new l.EdgeSettings(!0,new l.RGBColor(0,0,0),1),onModelLoaded:()=>{if(!n){try{const e=r.GetModel?.(),t=e?.GetRootNode?.();if(t){const e=M(t,{root:A.current.rootNode,node:A.current.node});L(e);const n={[e.id]:!0};for(const t of e.children)n[t.id]=!0;D(n)}}catch(e){console.warn("[Preview] mesh tree extraction failed",e)}c(!1)}},onModelLoadFailed:()=>{n||(u(A.current.loadFailed),c(!1))}}),a.current=r;const d=new l.InputFile(t,l.FileSource.Url,e);r.LoadModelFromInputFiles([d]),i.current&&"undefined"!=typeof ResizeObserver&&(s=new ResizeObserver(()=>{try{const e=a.current;e?.Resize?e.Resize():e?.viewer?.Resize&&e.viewer.Resize(),e?.viewer?.Render?.()}catch{}}),s.observe(i.current))}catch(e){n||(u(e?.message||A.current.loadFailed),c(!1))}})(),()=>{n=!0;try{s?.disconnect()}catch{}try{r?.Destroy?.()}catch{}a.current=null}},[e,t]),f(()=>{const e=a.current;if(e?.viewer)try{const t=e=>{if(e.userData?.__sectionHelper)return;const t=e.userData?.originalMeshInstance??e.userData,n=t?.id?.nodeId??t?.nodeId;"number"==typeof n&&(e.visible=!F.has(n))};e.viewer.mainModel?.EnumerateMeshesAndLines?.(t),e.viewer.mainModel?.EnumerateEdges?.(t),e.viewer.Render?.()}catch(e){console.warn("[Preview] visibility update failed",e)}},[F,E]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{t.viewer.SetEdgeSettings(new e.EdgeSettings(O,T(e,B),X));const n=he.current;if(n){const e=[];t.viewer.mainModel?.EnumerateEdges?.(t=>{t.userData?.__sectionHelper&&e.push(t)});for(const t of e)t.parent?.remove(t),t.geometry?.dispose?.(),t.material?.dispose?.();const r=n.plane,s=e=>{e&&!n.materialState.has(e)&&(n.materialState.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[r],e.clipShadows=!0,e.needsUpdate=!0)};t.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)s(e);else s(t)})}t.viewer.Render?.()}catch{}},[O,B,X]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{const n=T(e,I);t.viewer.SetBackgroundColor(new e.RGBAColor(n.r,n.g,n.b,255)),t.viewer.Render?.()}catch{}},[I]),f(()=>{const e=a.current;if(!e?.viewer||l)return;const t=e.viewer.renderer,n=e.viewer.scene;if(!t||!n)return;if(he.current){const e=he.current;for(const[t,n]of e.materialState.entries())t.clippingPlanes=n.clippingPlanes,t.clipShadows=n.clipShadows,t.needsUpdate=!0;for(const t of e.helpers)t.parent?.remove(t),t.material?.dispose?.();e.capMesh&&(n.remove(e.capMesh),e.capMesh.geometry?.dispose?.(),e.capMesh.material?.dispose?.()),he.current=null}if(!K)return t.localClippingEnabled=!1,void e.viewer.Render?.();const r=e.viewer.GetBoundingBox?.(()=>!0);if(!r)return;const s=[];if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{e.userData?.__sectionHelper||s.push(e)}),!s.length)return t.localClippingEnabled=!1,void e.viewer.Render?.();const i=s[0],o=i.constructor,c=i.material?.constructor,d=i.geometry?.constructor,u=i.geometry?.attributes?.position?.constructor;o&&c&&d&&u||console.warn("[Preview] section: missing THREE constructors, falling back to no cap");const p=7681;let m=!0;try{const e=t.getContext?.(),n=e?.getContextAttributes?.();m=!1!==n?.stencil,t.autoClearStencil=!0,console.info("[Preview] section: stencil buffer =",m,"targets =",s.length)}catch{}t.localClippingEnabled=!0;const h={normal:{x:0,y:0,z:-1},constant:0,clone:function e(){const t={normal:{x:this.normal.x,y:this.normal.y,z:this.normal.z},constant:this.constant};return t.clone=e,t}},y=[],x=/* @__PURE__ */new Map,f=e=>{e&&!x.has(e)&&(x.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[h],e.clipShadows=!0,e.needsUpdate=!0)};for(const e of s){const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t);const n=Array.isArray(t)?t[0]:t;if(o&&m&&n?.clone){const t=(t,r)=>{const s=n.clone();s.depthWrite=!1,s.depthTest=!1,s.colorWrite=!1,s.stencilWrite=!0,s.stencilFunc=519,s.stencilFail=r,s.stencilZFail=r,s.stencilZPass=r,s.side=t,s.transparent=!1,s.clippingPlanes=[h],s.clipShadows=!0,s.needsUpdate=!0;const i=new o(e.geometry,s);i.matrixAutoUpdate=!1,i.renderOrder=1,i.userData.__sectionHelper=!0,e.add(i),y.push(i)};t(1,7682),t(0,7683)}}e.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t)});let g=null;const b=s[0]?.material&&(Array.isArray(s[0].material)?s[0].material[0]:s[0].material);if(m&&o&&d&&u&&b?.clone){const e=r.max.x-r.min.x,t=r.max.y-r.min.y,s=r.max.z-r.min.z,i=2*Math.max(e,t,s,1)/2,a=new d,l=new Float32Array([-i,-i,0,i,-i,0,i,i,0,-i,i,0]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]);a.setAttribute("position",new u(l,3)),a.setAttribute("normal",new u(c,3)),a.setIndex([0,1,2,0,2,3]);const m=b.clone(),h=b.color?.getHex?.()??11844808;m.emissive?.setHex?.(h),"emissiveIntensity"in m&&(m.emissiveIntensity=.25),m.side=2,m.transparent=!1,m.opacity=1,m.stencilWrite=!0,m.stencilRef=0,m.stencilFunc=517,m.stencilFail=p,m.stencilZFail=p,m.stencilZPass=p,m.clippingPlanes=[],m.polygonOffset=!0,m.polygonOffsetFactor=-1,m.polygonOffsetUnits=-1,m.needsUpdate=!0,g=new o(a,m),g.renderOrder=2,g.userData.__sectionHelper=!0,n.add(g)}he.current={plane:h,capMesh:g,helpers:y,materialState:x,bbox:r},console.info("[Preview] section: helpers =",y.length,"cap =",!!g),e.viewer.Render?.()},[K,l,E]),f(()=>{const e=a.current,t=he.current;if(e?.viewer&&t&&K)try{const n=t.bbox,r="x"===J?0:"y"===J?1:2,s=[n.min.x,n.min.y,n.min.z][r],i=s+([n.max.x,n.max.y,n.max.z][r]-s)*re,a=ie*Math.PI/180,o=Math.cos(a),l=Math.sin(a),c=te?-1:1;let d=0,u=0,p=0;"x"===J?(d=c*o,p=c*l):"y"===J?(u=c*o,d=c*l):(p=c*o,u=c*l);const m={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},h="x"===J?i:m.x,y="y"===J?i:m.y,x="z"===J?i:m.z;if(t.plane.normal.x=d,t.plane.normal.y=u,t.plane.normal.z=p,t.plane.constant=-(d*h+u*y+p*x),t.capMesh){const e=m.x,n=m.y,r=m.z,s=d*e+u*n+p*r+t.plane.constant,i=e-d*s,a=n-u*s,o=r-p*s;t.capMesh.position.set(i,a,o),t.capMesh.lookAt?.(i+d,a+u,o+p)}e.viewer.Render?.()}catch(e){console.warn("[Preview] section update failed",e)}},[K,J,te,re,ie]),f(()=>{const e=a.current;if(!e?.viewer||l||!i.current)return;const t=e.viewer.renderer,n=e.viewer.scene,r=t?.domElement;if(!t||!n||!r)return;let s=null;if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{s||e.userData?.__sectionHelper||e.userData?.__measureHelper||(s=e)}),!s)return;const c=s.position.constructor,d=s.constructor,u=(Array.isArray(s.material)?s.material[0]:s.material)?.constructor,p=s.geometry.constructor,m=s.geometry.attributes?.position?.constructor;if(!(c&&d&&u&&p&&m))return;let h=null,y=null;n.traverse(e=>{if(h&&y)return;if(!e?.isLineSegments)return;h=e.constructor;const t=Array.isArray(e.material)?e.material[0]:e.material;t?.constructor&&(y=t.constructor)});const x=()=>{const t=me.current;if(t){null!==t.rafId&&cancelAnimationFrame(t.rafId);for(const e of t.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();t.line&&(n.remove(t.line),t.line.geometry?.dispose?.(),t.line.material?.dispose?.()),t.label&&t.label.parentElement&&t.label.parentElement.removeChild(t.label),me.current=null,e.viewer.Render?.()}};if(!oe)return x(),void pe(null);me.current={points:[],normals:[],markers:[],line:null,label:null,rafId:null};const f=o.current,g=f?.IntersectionMode?.MeshOnly??1,b=e.viewer.GetBoundingBox?.(()=>!0),w=b?Math.sqrt((b.max.x-b.min.x)**2+(b.max.y-b.min.y)**2+(b.max.z-b.min.z)**2):100,v=Math.max(.005*w,.2),k=e=>{const t=[],r=[];for(let e=0;e<=12;e++){const n=e/12*Math.PI;for(let e=0;e<=16;e++){const r=e/16*Math.PI*2;t.push(v*Math.sin(n)*Math.cos(r),v*Math.cos(n),v*Math.sin(n)*Math.sin(r))}}for(let e=0;e<12;e++)for(let t=0;t<16;t++){const n=17*e+t,s=n+16+1;r.push(n,s,n+1,s,s+1,n+1)}const s=new p;s.setAttribute("position",new m(new Float32Array(t),3)),s.setIndex(r),s.computeVertexNormals?.();const i=new u;i.color?.setHex?.(16746496),i.depthTest=!1,i.depthWrite=!1,i.transparent=!0,i.opacity=.95;const a=new d(s,i);return a.position.copy(e),a.renderOrder=9999,a.userData.__measureHelper=!0,n.add(a),a},N=()=>{const t=me.current;t&&((()=>{const t=me.current;if(!t||t.points.length<2||!t.label)return;const n=e.viewer.camera;if(!n)return;const s=t.points[0],i=t.points[1],a=new c((s.x+i.x)/2,(s.y+i.y)/2,(s.z+i.z)/2).clone();a.project?.(n);const o=r.getBoundingClientRect(),l=(a.x+1)/2*o.width,d=(1-a.y)/2*o.height;t.label.style.left=`${l}px`,t.label.style.top=`${d}px`;const u=l<0||d<0||l>o.width||d>o.height;t.label.style.opacity=a.z>1||u?"0":"1"})(),t.rafId=requestAnimationFrame(N))};me.current.rafId=requestAnimationFrame(N);let C=0,A=0,E=0,L=!1,S=!1;const M=t=>{if(!e.viewer.camera)return;const s=r.getBoundingClientRect(),a={x:t.clientX-s.left,y:t.clientY-s.top},o=e.viewer.GetMeshIntersectionUnderMouse?.(g,a);if(!o)return;const l=me.current,x=new c(o.point.x,o.point.y,o.point.z),f=(e=>{const t=e?.face?.normal,n=e?.object;if(!t||!n)return null;try{const e=new c(t.x,t.y,t.z);return e.transformDirection?.(n.matrixWorld),{x:e.x,y:e.y,z:e.z}}catch{return{x:t.x,y:t.y,z:t.z}}})(o);if(2===l.points.length){for(const e of l.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();l.line&&(n.remove(l.line),l.line.geometry?.dispose?.(),l.line.material?.dispose?.()),l.label&&(l.label.style.opacity="0"),l.points=[],l.markers=[],l.line=null,l.normals=[],pe(null)}if(l.points.push(x),l.normals.push(f),"perp"===ce){const e=((e,t)=>{const r=e?.geometry,s=r?.attributes?.position;if(!r||!s||!t?.face?.normal)return null;const i=s.array,a=r.index?r.index.array:null,o=new c(t.point.x,t.point.y,t.point.z);e.worldToLocal?.(o);const l=t.face.normal,h=-(l.x*o.x+l.y*o.y+l.z*o.z);r.computeBoundingBox?.();const y=r.boundingBox,x=y?Math.sqrt((y.max.x-y.min.x)**2+(y.max.y-y.min.y)**2+(y.max.z-y.min.z)**2):100,f=Math.max(.001*x,.005),g=a?a.length/3:s.count/3,b=[],w=new c;for(let t=0;t<g;t++){const n=a?a[3*t]:3*t,r=a?a[3*t+1]:3*t+1,s=a?a[3*t+2]:3*t+2,o=i[3*n],c=i[3*n+1],d=i[3*n+2],u=i[3*r],p=i[3*r+1],m=i[3*r+2],y=i[3*s],x=i[3*s+1],g=i[3*s+2],v=u-o,k=p-c,N=m-d,C=y-o,A=x-c,E=g-d;let L=k*E-N*A,S=N*C-v*E,M=v*A-k*C;const z=Math.sqrt(L*L+S*S+M*M);if(0===z)continue;if(L/=z,S/=z,M/=z,L*l.x+S*l.y+M*l.z<.9995)continue;const T=(o+u+y)/3,R=(c+p+x)/3,j=(d+m+g)/3;if(!(Math.abs(l.x*T+l.y*R+l.z*j+h)>f))for(const[t,n,r]of[[o,c,d],[u,p,m],[y,x,g]])w.set?.(t,n,r),e.localToWorld?.(w),b.push(w.x,w.y,w.z)}if(0===b.length)return null;const v=new p;v.setAttribute("position",new m(new Float32Array(b),3)),v.computeVertexNormals?.();const k=new u;k.color?.setHex?.(16746496),k.transparent=!0,k.opacity=.45,k.depthWrite=!1,k.polygonOffset=!0,k.polygonOffsetFactor=-2,k.polygonOffsetUnits=-2;const N=new d(v,k);return N.renderOrder=9998,N.userData.__measureHelper=!0,n.add(N),N})(o.object,o);l.markers.push(e??k(x))}else l.markers.push(k(x));if(2===l.points.length){const e=l.points[0];let t,r=l.points[1],s="";if("perp"===ce){const n=l.normals[0]??l.normals[1];if(n){const i=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)||1,a=n.x/i,o=n.y/i,d=n.z/i,u=(r.x-e.x)*a+(r.y-e.y)*o+(r.z-e.z)*d,p=new c(e.x+a*u,e.y+o*u,e.z+d*u);l.points[1]=p,r=p,t=Math.abs(u),s=" ⊥"}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}}else{const n=r.x-e.x,s=r.y-e.y,i=r.z-e.z;t=Math.sqrt(n*n+s*s+i*i)}l.line=((e,t)=>{const r=new p;r.setAttribute("position",new m(new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),3));const s=new(h??d)(r,new(y??u)({color:16746496,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95}));return s.renderOrder=9998,s.userData.__measureHelper=!0,n.add(s),s})(e,r),pe(t);const a=(()=>{const e=me.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.transform="translate(-50%, -50%)",t.style.padding="2px 6px",t.style.fontSize="11px",t.style.fontWeight="600",t.style.fontFamily="system-ui, -apple-system, sans-serif",t.style.background="rgba(255, 136, 0, 0.95)",t.style.color="#fff",t.style.borderRadius="4px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.boxShadow="0 1px 4px rgba(0,0,0,0.25)",t.style.zIndex="5",i.current.appendChild(t),e.label=t,t})();a.textContent=`${R(t)}${s}`}e.viewer.Render?.()},z=e=>{0===e.button&&(C=e.clientX,A=e.clientY,E=performance.now(),L=!1,S=!0)},T=e=>{if(!S)return;const t=e.clientX-C,n=e.clientY-A;t*t+n*n>16&&(L=!0)},j=e=>{if(0!==e.button||!S)return;const t=performance.now()-E;S=!1,!L&&t<350&&M(e)},D=e=>{"Escape"===e.key&&le(!1)};return r.style.cursor="crosshair",r.addEventListener("pointerdown",z),r.addEventListener("pointermove",T),r.addEventListener("pointerup",j),r.addEventListener("pointercancel",j),window.addEventListener("keydown",D),()=>{r.style.cursor="",r.removeEventListener("pointerdown",z),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",j),r.removeEventListener("pointercancel",j),window.removeEventListener("keydown",D),x(),pe(null)}},[oe,ce,l,E]),f(()=>{if(!m||l)return;const e=setTimeout(()=>w(!1),5e3);return()=>clearTimeout(e)},[m,l]);const ye=e=>{const t=/* @__PURE__ */new Set;z(e,t),H(e=>{const n=new Set(e),r=[...t].some(e=>!n.has(e));for(const e of t)r?n.add(e):n.delete(e);return n})},xe=()=>{try{const e=a.current,t=e?.viewer?.GetBoundingSphere?.(()=>!0);t&&e.viewer.FitSphereToWindow(t,!0),e?.viewer?.Render?.()}catch{}};f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer&&!l)try{t.viewer.SetProjectionMode(Z?e.ProjectionMode.Perspective:e.ProjectionMode.Orthographic)}catch{}},[Z,l]);const fe=e=>{const t=o.current,n=a.current;if(t&&n?.viewer)try{const r=n.viewer.GetBoundingSphere?.(()=>!0);if(!r)return;const s=r.center,i=3*(r.radius||1),a=s.x??0,o=s.y??0,l=s.z??0;let c,d;switch(e){case"top":c=new t.Coord3D(a,o,l+i),d=new t.Coord3D(0,1,0);break;case"front":c=new t.Coord3D(a,o-i,l),d=new t.Coord3D(0,0,1);break;case"side":c=new t.Coord3D(a+i,o,l),d=new t.Coord3D(0,0,1);break;default:{const e=i/Math.sqrt(3);c=new t.Coord3D(a+e,o-e,l+e),d=new t.Coord3D(0,0,1);break}}const u=new t.Coord3D(a,o,l),p=new t.Camera(c,u,d,45);n.viewer.SetCamera(p),n.viewer.AdjustClippingPlanesToSphere?.(r),n.viewer.Render?.()}catch{}},ge=(t.split(".").pop()||"").toUpperCase(),be=(e,t=0)=>{const n=e.children.length>0,r=!1!==j[e.id],s=!F.has(e.id);/* @__PURE__ */
85
85
  return g("div",{children:[
86
86
  /* @__PURE__ */g("div",{className:"group flex items-center gap-1 px-2 py-1 hover:bg-gray-100 cursor-default text-xs text-gray-700",style:{paddingLeft:12*t+6+"px"},children:[n?/* @__PURE__ */b("button",{onClick:()=>{return t=e.id,void D(e=>({...e,[t]:!e[t]}));var t},className:"h-4 w-4 shrink-0 flex items-center justify-center text-gray-500 hover:text-gray-900",title:r?N.collapse:N.expand,children:/* @__PURE__ */b(h,r?{name:"chevron-down",className:"h-3 w-3",strokeWidth:2}:{name:"chevron-right",className:"h-3 w-3",strokeWidth:2})}):/* @__PURE__ */b("span",{className:"h-4 w-4 shrink-0 flex items-center justify-center",children:/* @__PURE__ */b("span",{className:"h-1 w-1 rounded-full bg-gray-400"})}),
87
87
  /* @__PURE__ */b("span",{className:"flex-1 truncate "+(s?"":"opacity-40"),title:e.name,children:e.name}),
@@ -1,19 +1,19 @@
1
- import{EditableGrid as e}from"./chunk-7BX3JQBP.js";import"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-UZJ6RYMF.js";import{peekSpreadsheetPreviewStage as r,claimSpreadsheetPreviewStage as n,SPREADSHEET_PREVIEW_UPDATE_EVENT as o}from"./chunk-VTVSMRFX.js";import{WindowTitle as a}from"./chunk-THM35LAN.js";import"./chunk-DSSLOQDW.js";import"./chunk-SCJT2XXU.js";import"./chunk-ZRU5F2XT.js";import"./chunk-5A7MWTXX.js";import"./chunk-YMWCZKUN.js";import"./chunk-KSLOSQKN.js";import"./chunk-ICN533ML.js";import"./chunk-UVBK6YSR.js";import"./chunk-NGUH7T5V.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-B4XGJA3N.js";import"./chunk-KNUR2UEG.js";import"./chunk-QRCDQPJA.js";import"./chunk-C3QOHMR6.js";import"./chunk-ZGUQLVY4.js";import{useRef as l,useState as s,useEffect as c,useCallback as i}from"react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m="ABCDEFGHIJKLMNOPQRSTUVWXYZ",p=10,x=30;function g(e){return e<26?m[e]:m[Math.floor(e/26)-1]+m[e%26]}function y(e){return Array.from({length:e},(e,t)=>({key:`col_${t}`,title:g(t),width:100}))}function b(e,t){return Array.from({length:e},()=>Array(t).fill(""))}function f(e){return{id:crypto.randomUUID(),name:e,columns:y(p),data:b(x,p),cellStyles:{}}}function v(e){return e.split("\n").map(e=>{if(e.includes("\t"))return e.split("\t").map(e=>e.trim());const t=[];let r="",n=!1;for(const o of e)'"'!==o?","!==o||n?r+=o:(t.push(r.trim()),r=""):n=!n;return t.push(r.trim()),t}).filter(e=>e.some(e=>e.trim()))}function k(e,t){const r=v(e);if(0===r.length)return null;const n=Math.max(p,r.reduce((e,t)=>Math.max(e,t.length),0)),o=r.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));return{id:crypto.randomUUID(),name:t,columns:y(n),data:o,cellStyles:{}}}function w(){const m=l(null),g=l(void 0);void 0===g.current&&(g.current=r());const w=l(g.current?.data??null),N=(()=>{const e=g.current;if(!e)return null;const t=k(e.data.csv,"Sheet 1");if(!t)return null;return{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}})(),[C,S]=s(N?[N.sheet]:[f("Sheet 1")]),[j,U]=s(0),M=l([]),$=l(C),A=l(!1);c(()=>{A.current?A.current=!1:$.current!==C&&(M.current.push($.current),M.current.length>50&&M.current.shift()),$.current=C},[C]);const E=i(()=>{const e=M.current.pop();e&&(A.current=!0,S(e))},[]);c(()=>{const e=e=>{if(!m.current?.contains(document.activeElement)&&!m.current?.matches(":focus-within"))return;(e.ctrlKey||e.metaKey)&&!e.shiftKey&&("z"===e.key||"Z"===e.key)&&(e.preventDefault(),E())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E]);const[L,D]=s(N?.title??"Untitled"),[R,B]=s(()=>g.current?.data.onEmail),F=i(e=>{const t=k(e.csv,"Sheet 1");t&&(S([t]),U(0),D(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),B(()=>e.onEmail))},[]);c(()=>{const e=g.current;null!=e&&(n(e),e.data!==w.current&&F(e.data))},[]),c(()=>{const e=g.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&F(r.data)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const[K,X]=s(!1),[I,Q]=s(null),[T,H]=s(""),J=l(null),[O,V]=s("1"),[G,Z]=s("10"),Y=C[j]||C[0],z=Y.data,P=Y.columns,W=Y.cellStyles??{},[_,q]=s(null),[ee,te]=s(null),re=i(()=>{if(ee){const e=Math.min(ee.anchor.row,ee.end.row),t=Math.max(ee.anchor.row,ee.end.row),r=Math.min(ee.anchor.col,ee.end.col),n=Math.max(ee.anchor.col,ee.end.col),o=[];for(let a=e;a<=t;a++)for(let e=r;e<=n;e++)o.push({row:a,col:e});return o}return _?[_]:[]},[ee,_]),ne=i((e,t)=>{const r=re();0!==r.length&&S(n=>n.map((n,o)=>{if(o!==j)return n;const a={...n.cellStyles??{}},l=`${r[0].row}:${r[0].col}`,s=void 0!==t?t:!(a[l]??{})[e];for(const{row:t,col:n}of r){const r=`${t}:${n}`;a[r]={...a[r]??{},[e]:s}}return{...n,cellStyles:a}}))},[re,j]),oe=ee?{row:ee.anchor.row,col:ee.anchor.col}:_,ae=oe?W[`${oe.row}:${oe.col}`]??{}:{},le=!!oe,se=i(e=>{S(t=>t.map((t,r)=>r===j?{...t,...e}:t))},[j]),ce=i(e=>{const t=e.reduce((e,t)=>Math.max(e,t.length),0);t!==P.length?se({data:e,columns:y(t)}):se({data:e})},[se,P.length]),ie=(e,t)=>{S(r=>r.map((r,n)=>n===e?{...r,name:t}:r)),Q(null)},ue=()=>z.filter(e=>e.some(e=>e.trim())).map(e=>e.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?`"${e.replace(/"/g,'""')}"`:e).join(",")).join("\n"),de=[];z.forEach(e=>e.forEach(e=>{const t=parseFloat(e);!isNaN(t)&&e.trim()&&de.push(t)}));const he=z.reduce((e,t)=>e+t.filter(e=>e.trim()).length,0);/* @__PURE__ */
1
+ import{EditableGrid as e}from"./chunk-7BX3JQBP.js";import"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-KPFDT626.js";import{peekSpreadsheetPreviewStage as r,claimSpreadsheetPreviewStage as n,SPREADSHEET_PREVIEW_UPDATE_EVENT as o}from"./chunk-VTVSMRFX.js";import{WindowTitle as a}from"./chunk-THM35LAN.js";import"./chunk-DSSLOQDW.js";import"./chunk-SCJT2XXU.js";import"./chunk-ZRU5F2XT.js";import"./chunk-5A7MWTXX.js";import"./chunk-YMWCZKUN.js";import"./chunk-KSLOSQKN.js";import"./chunk-ICN533ML.js";import"./chunk-UVBK6YSR.js";import"./chunk-NGUH7T5V.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-GIRABDNU.js";import"./chunk-KNUR2UEG.js";import"./chunk-QRCDQPJA.js";import"./chunk-C3QOHMR6.js";import"./chunk-ZGUQLVY4.js";import{useRef as l,useState as s,useEffect as c,useCallback as i}from"react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m="ABCDEFGHIJKLMNOPQRSTUVWXYZ",p=10,x=30;function g(e){return e<26?m[e]:m[Math.floor(e/26)-1]+m[e%26]}function y(e){return Array.from({length:e},(e,t)=>({key:`col_${t}`,title:g(t),width:100}))}function b(e,t){return Array.from({length:e},()=>Array(t).fill(""))}function f(e){return{id:crypto.randomUUID(),name:e,columns:y(p),data:b(x,p),cellStyles:{}}}function v(e){return e.split("\n").map(e=>{if(e.includes("\t"))return e.split("\t").map(e=>e.trim());const t=[];let r="",n=!1;for(const o of e)'"'!==o?","!==o||n?r+=o:(t.push(r.trim()),r=""):n=!n;return t.push(r.trim()),t}).filter(e=>e.some(e=>e.trim()))}function k(e,t){const r=v(e);if(0===r.length)return null;const n=Math.max(p,r.reduce((e,t)=>Math.max(e,t.length),0)),o=r.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));return{id:crypto.randomUUID(),name:t,columns:y(n),data:o,cellStyles:{}}}function w(){const m=l(null),g=l(void 0);void 0===g.current&&(g.current=r());const w=l(g.current?.data??null),N=(()=>{const e=g.current;if(!e)return null;const t=k(e.data.csv,"Sheet 1");if(!t)return null;return{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}})(),[C,S]=s(N?[N.sheet]:[f("Sheet 1")]),[j,U]=s(0),M=l([]),$=l(C),A=l(!1);c(()=>{A.current?A.current=!1:$.current!==C&&(M.current.push($.current),M.current.length>50&&M.current.shift()),$.current=C},[C]);const E=i(()=>{const e=M.current.pop();e&&(A.current=!0,S(e))},[]);c(()=>{const e=e=>{if(!m.current?.contains(document.activeElement)&&!m.current?.matches(":focus-within"))return;(e.ctrlKey||e.metaKey)&&!e.shiftKey&&("z"===e.key||"Z"===e.key)&&(e.preventDefault(),E())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E]);const[D,L]=s(N?.title??"Untitled"),[R,B]=s(()=>g.current?.data.onEmail),K=i(e=>{const t=k(e.csv,"Sheet 1");t&&(S([t]),U(0),L(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),B(()=>e.onEmail))},[]);c(()=>{const e=g.current;null!=e&&(n(e),e.data!==w.current&&K(e.data))},[]),c(()=>{const e=g.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&K(r.data)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const[F,I]=s(!1),[X,Q]=s(null),[T,H]=s(""),O=l(null),[V,G]=s("1"),[J,P]=s("10"),Z=C[j]||C[0],z=Z.data,W=Z.columns,Y=Z.cellStyles??{},[_,q]=s(null),[ee,te]=s(null),re=i(()=>{if(ee){const e=Math.min(ee.anchor.row,ee.end.row),t=Math.max(ee.anchor.row,ee.end.row),r=Math.min(ee.anchor.col,ee.end.col),n=Math.max(ee.anchor.col,ee.end.col),o=[];for(let a=e;a<=t;a++)for(let e=r;e<=n;e++)o.push({row:a,col:e});return o}return _?[_]:[]},[ee,_]),ne=i((e,t)=>{const r=re();0!==r.length&&S(n=>n.map((n,o)=>{if(o!==j)return n;const a={...n.cellStyles??{}},l=`${r[0].row}:${r[0].col}`,s=void 0!==t?t:!(a[l]??{})[e];for(const{row:t,col:n}of r){const r=`${t}:${n}`;a[r]={...a[r]??{},[e]:s}}return{...n,cellStyles:a}}))},[re,j]),oe=ee?{row:ee.anchor.row,col:ee.anchor.col}:_,ae=oe?Y[`${oe.row}:${oe.col}`]??{}:{},le=!!oe,se=i(e=>{S(t=>t.map((t,r)=>r===j?{...t,...e}:t))},[j]),ce=i(e=>{const t=e.reduce((e,t)=>Math.max(e,t.length),0);t!==W.length?se({data:e,columns:y(t)}):se({data:e})},[se,W.length]),ie=(e,t)=>{S(r=>r.map((r,n)=>n===e?{...r,name:t}:r)),Q(null)},ue=()=>z.filter(e=>e.some(e=>e.trim())).map(e=>e.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?`"${e.replace(/"/g,'""')}"`:e).join(",")).join("\n"),de=[];z.forEach(e=>e.forEach(e=>{const t=parseFloat(e);!isNaN(t)&&e.trim()&&de.push(t)}));const he=z.reduce((e,t)=>e+t.filter(e=>e.trim()).length,0);/* @__PURE__ */
2
2
  return u("div",{ref:m,className:"flex flex-col h-full",children:[
3
- /* @__PURE__ */d(a,{title:`${me=L||"Untitled",me.length>24?`${me.slice(0,23)}…`:me} - Spreadsheets`}),
3
+ /* @__PURE__ */d(a,{title:`${me=D||"Untitled",me.length>24?`${me.slice(0,23)}…`:me} - Spreadsheets`}),
4
4
  /* @__PURE__ */d(t,{app:"spreadsheet"}),
5
- /* @__PURE__ */u("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[K?/* @__PURE__ */d("input",{type:"text",value:L,onChange:e=>D(e.target.value),onBlur:()=>X(!1),onKeyDown:e=>{"Enter"===e.key&&X(!1)},autoFocus:!0,className:"text-sm font-medium text-gray-900 border border-gray-300 rounded px-2 py-0.5 w-40 focus:border-blue-500 focus:ring-blue-500"}):/* @__PURE__ */d("button",{onClick:()=>X(!0),className:"text-sm font-medium text-gray-900 hover:text-blue-600 truncate max-w-[200px]",title:"Click to rename",children:L||"Untitled"}),
5
+ /* @__PURE__ */u("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[F?/* @__PURE__ */d("input",{type:"text",value:D,onChange:e=>L(e.target.value),onBlur:()=>I(!1),onKeyDown:e=>{"Enter"===e.key&&I(!1)},autoFocus:!0,className:"text-sm font-medium text-gray-900 border border-gray-300 rounded px-2 py-0.5 w-40 focus:border-blue-500 focus:ring-blue-500"}):/* @__PURE__ */d("button",{onClick:()=>I(!0),className:"text-sm font-medium text-gray-900 hover:text-blue-600 truncate max-w-[200px]",title:"Click to rename",children:D||"Untitled"}),
6
6
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
7
- /* @__PURE__ */d("input",{ref:J,type:"file",accept:".csv,.tsv,.txt,.xlsx,.xls,.ods",onChange:async e=>{const t=e.target.files?.[0];if(!t)return;const r=t.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");if(/\.(xlsx|xls|ods)$/i.test(t.name)){const e=new Uint8Array(await t.arrayBuffer()),n=await(import("xlsx")),o=n.read(e,{type:"array"}),a=o.SheetNames.map(e=>{const t=n.utils.sheet_to_json(o.Sheets[e],{header:1,defval:""}),r=Math.max(p,t.reduce((e,t)=>Math.max(e,t.length),0)),a=t.map(e=>{const t=e.map(e=>String(e??""));for(;t.length<r;)t.push("");return t});for(;a.length<x;)a.push(Array(r).fill(""));return{id:crypto.randomUUID(),name:e,columns:y(r),data:a}});S(a),U(0),D(r)}else{const e=v(await t.text());if(0===e.length)return;const n=Math.max(p,e.reduce((e,t)=>Math.max(e,t.length),0)),o=e.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));se({columns:y(n),data:o}),D(r)}J.current&&(J.current.value="")},className:"hidden"}),
8
- /* @__PURE__ */d("button",{onClick:()=>J.current?.click(),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Open"}),
9
- /* @__PURE__ */d("button",{onClick:()=>{const e=new Blob([ue()],{type:"text/csv"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${L||"spreadsheet"}.csv`,r.click(),URL.revokeObjectURL(t)},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save CSV"}),R&&/* @__PURE__ */d("button",{onClick:()=>R(ue(),`${L||"spreadsheet"}.csv`),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Email"}),
7
+ /* @__PURE__ */d("input",{ref:O,type:"file",accept:".csv,.tsv,.txt,.xlsx,.xls,.ods",onChange:async e=>{const t=e.target.files?.[0];if(!t)return;const r=t.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");if(/\.(xlsx|xls|ods)$/i.test(t.name)){const e=new Uint8Array(await t.arrayBuffer()),n=await(import("xlsx")),o=n.read(e,{type:"array"}),a=o.SheetNames.map(e=>{const t=n.utils.sheet_to_json(o.Sheets[e],{header:1,defval:""}),r=Math.max(p,t.reduce((e,t)=>Math.max(e,t.length),0)),a=t.map(e=>{const t=e.map(e=>String(e??""));for(;t.length<r;)t.push("");return t});for(;a.length<x;)a.push(Array(r).fill(""));return{id:crypto.randomUUID(),name:e,columns:y(r),data:a}});S(a),U(0),L(r)}else{const e=v(await t.text());if(0===e.length)return;const n=Math.max(p,e.reduce((e,t)=>Math.max(e,t.length),0)),o=e.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));se({columns:y(n),data:o}),L(r)}O.current&&(O.current.value="")},className:"hidden"}),
8
+ /* @__PURE__ */d("button",{onClick:()=>O.current?.click(),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Open"}),
9
+ /* @__PURE__ */d("button",{onClick:()=>{const e=new Blob([ue()],{type:"text/csv"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${D||"spreadsheet"}.csv`,r.click(),URL.revokeObjectURL(t)},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save CSV"}),R&&/* @__PURE__ */d("button",{onClick:()=>R(ue(),`${D||"spreadsheet"}.csv`),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Email"}),
10
10
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
11
11
  /* @__PURE__ */u("div",{className:"flex items-center gap-1",children:[
12
- /* @__PURE__ */d("input",{type:"number",min:"1",max:"50",value:O,onChange:e=>V(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
13
- /* @__PURE__ */d("button",{onClick:()=>(e=>{const t=P.length+e;se({columns:y(t),data:z.map(t=>[...t,...Array(e).fill("")])})})(parseInt(O)||1),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Col"})]}),
12
+ /* @__PURE__ */d("input",{type:"number",min:"1",max:"50",value:V,onChange:e=>G(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
13
+ /* @__PURE__ */d("button",{onClick:()=>(e=>{const t=W.length+e;se({columns:y(t),data:z.map(t=>[...t,...Array(e).fill("")])})})(parseInt(V)||1),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Col"})]}),
14
14
  /* @__PURE__ */u("div",{className:"flex items-center gap-1",children:[
15
- /* @__PURE__ */d("input",{type:"number",min:"1",max:"500",value:G,onChange:e=>Z(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
16
- /* @__PURE__ */d("button",{onClick:()=>{return e=parseInt(G)||10,void se({data:[...z,...Array.from({length:e},()=>Array(P.length).fill(""))]});var e},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Row"})]}),
15
+ /* @__PURE__ */d("input",{type:"number",min:"1",max:"500",value:J,onChange:e=>P(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
16
+ /* @__PURE__ */d("button",{onClick:()=>{return e=parseInt(J)||10,void se({data:[...z,...Array.from({length:e},()=>Array(W.length).fill(""))]});var e},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Row"})]}),
17
17
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
18
18
  /* @__PURE__ */d("button",{onClick:()=>{se({columns:y(p),data:b(x,p)})},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Clear"}),
19
19
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
@@ -26,12 +26,12 @@ return u("div",{ref:m,className:"flex flex-col h-full",children:[
26
26
  /* @__PURE__ */d("option",{value:"base",children:"S"}),
27
27
  /* @__PURE__ */d("option",{value:"lg",children:"M"}),
28
28
  /* @__PURE__ */d("option",{value:"xl",children:"L"})]})]})]}),
29
- /* @__PURE__ */d("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */d(e,{columns:P,data:z,onChange:ce,onColumnsChange:e=>se({columns:e}),cellStyles:W,onFocusChange:q,onSelectionChange:te,minRows:x,maxHeight:"100%"})}),
29
+ /* @__PURE__ */d("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */d(e,{columns:W,data:z,onChange:ce,onColumnsChange:e=>se({columns:e}),cellStyles:Y,onFocusChange:q,onSelectionChange:te,minRows:x,maxHeight:"100%"})}),
30
30
  /* @__PURE__ */u("div",{className:"flex items-center border-t border-gray-200 bg-gray-50 shrink-0",children:[
31
- /* @__PURE__ */u("div",{className:"flex items-center gap-0.5 px-1 py-1 overflow-x-auto flex-1 min-w-0",children:[C.map((e,t)=>/* @__PURE__ */d("button",{onClick:()=>U(t),onDoubleClick:()=>{Q(t),H(e.name)},onContextMenu:e=>{e.preventDefault(),C.length>1&&(e=>{C.length<=1||(S(t=>t.filter((t,r)=>r!==e)),j>=e&&j>0&&U(j-1))})(t)},className:"px-3 py-1 text-xs font-medium rounded-b whitespace-nowrap transition-colors "+(t===j?"bg-white text-blue-700 border border-t-0 border-gray-300 -mt-px relative z-10":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:I===t?/* @__PURE__ */d("input",{type:"text",value:T,onChange:e=>H(e.target.value),onBlur:()=>ie(t,T||e.name),onKeyDown:r=>{"Enter"===r.key&&ie(t,T||e.name),"Escape"===r.key&&Q(null)},onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-20 text-xs border border-blue-400 rounded px-1 py-0 focus:ring-0 focus:outline-none"}):e.name},e.id)),
31
+ /* @__PURE__ */u("div",{className:"flex items-center gap-0.5 px-1 py-1 overflow-x-auto flex-1 min-w-0",children:[C.map((e,t)=>/* @__PURE__ */d("button",{onClick:()=>U(t),onDoubleClick:()=>{Q(t),H(e.name)},onContextMenu:e=>{e.preventDefault(),C.length>1&&(e=>{C.length<=1||(S(t=>t.filter((t,r)=>r!==e)),j>=e&&j>0&&U(j-1))})(t)},className:"px-3 py-1 text-xs font-medium rounded-b whitespace-nowrap transition-colors "+(t===j?"bg-white text-blue-700 border border-t-0 border-gray-300 -mt-px relative z-10":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:X===t?/* @__PURE__ */d("input",{type:"text",value:T,onChange:e=>H(e.target.value),onBlur:()=>ie(t,T||e.name),onKeyDown:r=>{"Enter"===r.key&&ie(t,T||e.name),"Escape"===r.key&&Q(null)},onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-20 text-xs border border-blue-400 rounded px-1 py-0 focus:ring-0 focus:outline-none"}):e.name},e.id)),
32
32
  /* @__PURE__ */d("button",{onClick:()=>{const e=`Sheet ${C.length+1}`;S(t=>[...t,f(e)]),U(C.length)},className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded",title:"Add sheet",children:"+"})]}),
33
33
  /* @__PURE__ */u("div",{className:"flex items-center gap-4 px-3 py-1 text-xs text-gray-500 shrink-0 border-l border-gray-200",children:[
34
34
  /* @__PURE__ */u("span",{children:[he," cells"]}),de.length>0&&/* @__PURE__ */u(h,{children:[
35
35
  /* @__PURE__ */u("span",{children:["Sum: ",de.reduce((e,t)=>e+t,0).toLocaleString(void 0,{maximumFractionDigits:2})]}),
36
36
  /* @__PURE__ */u("span",{children:["Avg: ",(de.reduce((e,t)=>e+t,0)/de.length).toLocaleString(void 0,{maximumFractionDigits:2})]})]}),
37
- /* @__PURE__ */u("span",{children:[z.length," × ",P.length]})]})]})]});var me}export{w as default};
37
+ /* @__PURE__ */u("span",{children:[z.length," × ",W.length]})]})]})]});var me}export{w as default};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-7HLTPMQV.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-UZJ6RYMF.js";import"../chunk-XN7CAWSZ.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-THM35LAN.js";import"../chunk-DSSLOQDW.js";import"../chunk-SCJT2XXU.js";import{toast_default as o}from"../chunk-RUHUTZN4.js";import"../chunk-ZRU5F2XT.js";import"../chunk-5A7MWTXX.js";import"../chunk-YMWCZKUN.js";import"../chunk-KSLOSQKN.js";import"../chunk-ICN533ML.js";import"../chunk-UVBK6YSR.js";import"../chunk-NGUH7T5V.js";import"../chunk-7IQ3B77H.js";import"../chunk-FIEA5CGB.js";import"../chunk-D65T4H6J.js";import"../chunk-B4XGJA3N.js";import"../chunk-KNUR2UEG.js";import{currentShellStrings as r}from"../chunk-QRCDQPJA.js";import"../chunk-C3QOHMR6.js";import"../chunk-ZGUQLVY4.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),l=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),a=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function m(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":l.has(t)?"image":a.has(t)?"3d":null}function p(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function d(n,s,l={}){const a=r().attachment,d=n?.url||"",f=n?.filename||a.fallbackName;if(!d&&!l.fetchBlob)return void o.error(a.noLink);const j=m(f)??m(d);if("csv"===j){try{t({csv:await u(d,l,n),filename:f}),s("/spreadsheet")}catch{o.error(a.spreadsheetFailed),d&&p(d)}return}if(c.has(i(f)||i(d)))return o.error(a.workbookUnavailable),void(d&&p(d));if(!j)return d?(o.info(a.noViewer),void p(d)):void o.error(a.noLink);if(!l.fetchBlob)return e({url:d,filename:f,kind:j}),void s("/preview");const k=e({filename:f,kind:j,converting:!0,convertingMessage:l.loadingMessage||a.loading});s("/preview");try{const e=await l.fetchBlob(n);k.update({url:URL.createObjectURL(e),filename:f,kind:j})}catch(e){k.update({filename:f,kind:j,converting:!1,convertingMessage:h(e,a.loadFailed)})}}var f=n(()=>import("../Calculator-HFF54RNH.js")),j=n(()=>import("../Spreadsheet-F5BXANOO.js")),k=n(()=>import("../Weather-62FA6T6O.js")),w=n(()=>import("../CurrencyConverter-SAIDT4WN.js")),g=n(()=>import("../PomodoroTimer-AV3YE2WJ.js")),v=n(()=>import("../Notepad-NNYMEU7M.js")),S=n(()=>import("../WorldClock-C3A6PZYM.js")),b=n(()=>import("../Stock-EP2SB76N.js")),N=n(()=>import("../Preview-PWFREL75.js")),T=n(()=>import("../PdfViewer-PHABUM7K.js")),x=n(()=>import("../Documents-OWPQE6D6.js")),C=n(()=>import("../Files-UCNAQWGM.js")),y=n(()=>import("../Browser-VCRHLL3W.js")),L={"/calculator":{component:f,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:j,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:v,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:k,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:S,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:b,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},P={"/preview":{component:N,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:x,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:C,label:"Files",size:"xl",appStyle:!0}},U={"/browser":{component:y,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},M={...L,...P,...U};export{y as Browser,f as Calculator,w as CurrencyConverter,x as Documents,C as Files,v as Notepad,T as PdfViewer,g as PomodoroTimer,N as Preview,j as Spreadsheet,b as Stock,k as Weather,S as WorldClock,m as attachmentKind,M as bundledApps,P as documentApps,d as openAttachment,L as utilityApps,U as webApps};
2
+ export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-7HLTPMQV.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-KPFDT626.js";import"../chunk-XN7CAWSZ.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-THM35LAN.js";import"../chunk-DSSLOQDW.js";import"../chunk-SCJT2XXU.js";import{toast_default as o}from"../chunk-RUHUTZN4.js";import"../chunk-ZRU5F2XT.js";import"../chunk-5A7MWTXX.js";import"../chunk-YMWCZKUN.js";import"../chunk-KSLOSQKN.js";import"../chunk-ICN533ML.js";import"../chunk-UVBK6YSR.js";import"../chunk-NGUH7T5V.js";import"../chunk-7IQ3B77H.js";import"../chunk-FIEA5CGB.js";import"../chunk-D65T4H6J.js";import"../chunk-GIRABDNU.js";import"../chunk-KNUR2UEG.js";import{currentShellStrings as r}from"../chunk-QRCDQPJA.js";import"../chunk-C3QOHMR6.js";import"../chunk-ZGUQLVY4.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),l=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),a=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function m(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":l.has(t)?"image":a.has(t)?"3d":null}function p(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function d(n,s,l={}){const a=r().attachment,d=n?.url||"",f=n?.filename||a.fallbackName;if(!d&&!l.fetchBlob)return void o.error(a.noLink);const j=m(f)??m(d);if("csv"===j){try{t({csv:await u(d,l,n),filename:f}),s("/spreadsheet")}catch{o.error(a.spreadsheetFailed),d&&p(d)}return}if(c.has(i(f)||i(d)))return o.error(a.workbookUnavailable),void(d&&p(d));if(!j)return d?(o.info(a.noViewer),void p(d)):void o.error(a.noLink);if(!l.fetchBlob)return e({url:d,filename:f,kind:j}),void s("/preview");const k=e({filename:f,kind:j,converting:!0,convertingMessage:l.loadingMessage||a.loading});s("/preview");try{const e=await l.fetchBlob(n);k.update({url:URL.createObjectURL(e),filename:f,kind:j})}catch(e){k.update({filename:f,kind:j,converting:!1,convertingMessage:h(e,a.loadFailed)})}}var f=n(()=>import("../Calculator-HFF54RNH.js")),j=n(()=>import("../Spreadsheet-2BFHRSTA.js")),k=n(()=>import("../Weather-62FA6T6O.js")),w=n(()=>import("../CurrencyConverter-SAIDT4WN.js")),g=n(()=>import("../PomodoroTimer-AV3YE2WJ.js")),S=n(()=>import("../Notepad-U5PUVVNQ.js")),v=n(()=>import("../WorldClock-C3A6PZYM.js")),b=n(()=>import("../Stock-EP2SB76N.js")),T=n(()=>import("../Preview-GB65GSM3.js")),N=n(()=>import("../PdfViewer-PHABUM7K.js")),x=n(()=>import("../Documents-YFYTJGI3.js")),U=n(()=>import("../Files-FUOFGLH4.js")),y=n(()=>import("../Browser-HQSYADOK.js")),F={"/calculator":{component:f,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:j,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:S,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:k,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:v,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:b,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},P={"/preview":{component:T,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:x,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:U,label:"Files",size:"xl",appStyle:!0}},B={"/browser":{component:y,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},C={...F,...P,...B};export{y as Browser,f as Calculator,w as CurrencyConverter,x as Documents,U as Files,S as Notepad,N as PdfViewer,g as PomodoroTimer,T as Preview,j as Spreadsheet,b as Stock,k as Weather,v as WorldClock,m as attachmentKind,C as bundledApps,P as documentApps,d as openAttachment,F as utilityApps,B as webApps};