@mlightcad/cad-simple-viewer 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3093,6 +3093,7 @@ class w {
3093
3093
  v.emit("open-file-progress", {
3094
3094
  percentage: o.percentage,
3095
3095
  stage: o.stage,
3096
+ subStage: o.subStage,
3096
3097
  stageStatus: o.stageStatus
3097
3098
  });
3098
3099
  });
@@ -6,4 +6,4 @@
6
6
  <line x1="${n+e}" y1="${t+e}" x2="${n+e}" y2="${t+2*e}" stroke="${i}" />
7
7
  <line x1="0" y1="${n+e}" x2="${e}" y2="${n+e}" stroke="${i}" />
8
8
  </svg>
9
- `;return this.encodeSvgToCursor(r,n+e,n+e)}}class P{constructor(t){this.active=!1,this.isResolvedOrRejected=!1,this.onKeyDown=e=>{e.code==="Escape"&&this.reject("Canceled by user!")},this.view=t}get isActive(){return this.active}activate(){this.isActive&&console.warn("Something wrong here!"),this.active=!0,this.view.canvas.addEventListener("keydown",this.onKeyDown)}deactivate(){this.active=!1,this.view.canvas.removeEventListener("keydown",this.onKeyDown)}resolve(t){this.deactivate(),this._resolve&&!this.isResolvedOrRejected&&(this._resolve(t),this.isResolvedOrRejected=!0)}reject(t){this.deactivate(),this._reject&&!this.isResolvedOrRejected&&(this._reject(t),this.isResolvedOrRejected=!0)}async start(){return this.isResolvedOrRejected=!1,new Promise((t,e)=>{this._resolve=t,this._reject=e,this.activate()})}}class mt extends P{constructor(t){super(t),this.events={update:new c.AcCmEventManager},this.onMouseMove=e=>{this.curPos.set(e.clientX,e.clientY),this.events.update.dispatch()},this.curPos=new c.AcGePoint2d}activate(){super.activate(),this.view.canvas.addEventListener("mousemove",this.onMouseMove)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("mousemove",this.onMouseMove)}}class X{constructor(t){this.onUpdate=()=>{this.update()},this._view=t,this._jigLoop=new mt(t),this._jigLoop.events.update.addEventListener(this.onUpdate)}get view(){return this._view}resolve(t){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.resolve(t)}reject(t){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.reject(t)}async drag(){const t=this._jigLoop.start(),e=this.sampler();await Promise.allSettled([t,e])}async sampler(){}update(){}}const _t=16777215,wt="1px";class ft extends P{constructor(t){super(t),this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.mousedown=e=>{if(e.button===0){this.mouseDown=!0;const i=new c.AcGePoint2d(e.x,e.y);this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y}},this.mousemove=e=>{if(!this.mouseDown)return;const i=new c.AcGePoint2d(e.x,e.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(i.x-this.mouseDownPositionX)>=5||Math.abs(i.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;const o=new c.AcGePoint2d(Math.min(this.mouseDownPositionX,i.x),Math.min(this.mouseDownPositionY,i.y)),r=new c.AcGePoint2d(Math.max(this.mouseDownPositionX,i.x),Math.max(this.mouseDownPositionY,i.y));this.drawRect(o,r)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){const i=new c.AcGePoint2d(e.x,e.y),n=new c.AcGePoint2d(Math.min(this.mouseDownPositionX,i.x),Math.min(this.mouseDownPositionY,i.y)),o=new c.AcGePoint2d(Math.max(this.mouseDownPositionX,i.x),Math.max(this.mouseDownPositionY,i.y)),r=new c.AcGeBox2d(n,o);this.resolve(this.toWcs(r))}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.container=t.canvas,this.color=_t}activate(){super.activate(),this.active=!0,this.container.addEventListener("pointerdown",this.mousedown),this.container.addEventListener("pointermove",this.mousemove),this.container.addEventListener("pointerup",this.mouseup)}deactivate(){super.deactivate(),this.container.removeEventListener("pointerdown",this.mousedown),this.container.removeEventListener("pointermove",this.mousemove),this.container.removeEventListener("pointerup",this.mouseup),this.setRectDomVisible(!1)}reject(t){var e;super.reject(t),(e=this.boxDom)==null||e.remove(),this.boxDom=void 0}drawRect(t,e){if(!this.boxDom){const o=new c.AcCmColor;o.color=this.color,this.boxDom=document.createElement("div"),this.boxDom.style.cssText=`position: absolute;border: ${wt} solid ${o.cssColor};`,document.body.appendChild(this.boxDom)}this.setRectDomVisible(!0),t.x<=0&&(t.x=0),t.y<=0&&(t.y=0),e.x>=this.container.clientWidth-2&&(e.x=this.container.clientWidth-2),e.y>=this.container.clientHeight-2&&(e.y=this.container.clientHeight-2),this.boxDom.style.left=`${t.x}px`,this.boxDom.style.top=`${t.y}px`;const i=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y);this.boxDom.style.width=`${i}px`,this.boxDom.style.height=`${n}px`}setRectDomVisible(t){this.boxDom&&(this.boxDom.style.display=t?"inline-block":"none")}toWcs(t){const e=new c.AcGeBox2d,i=new c.AcGePoint2d(t.min.x,t.min.y),n=new c.AcGePoint2d(t.max.x,t.max.y);return e.expandByPoint(this.view.cwcs2Wcs(i)),e.expandByPoint(this.view.cwcs2Wcs(n)),e}}class vt extends P{constructor(t){super(t),this.onClick=e=>{this.resolve(this.view.cwcs2Wcs({x:e.clientX,y:e.clientY}))}}activate(){super.activate(),this.view.canvas.addEventListener("click",this.onClick)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("click",this.onClick)}}class F{constructor(t){this._view=t,this._cursorManager=new Y}get currentCursor(){return this._currentCursor}restoreCursor(){this._previousCursor!=null&&this.setCursor(this._previousCursor)}setCursor(t){this._cursorManager.setCursor(t,this._view.canvas),this._previousCursor=this._currentCursor,this._currentCursor=t}async getPoint(){return await new vt(this._view).start()}async getSelection(){return await new ft(this._view).start()}}class U{constructor(t=[]){this.events={selectionAdded:new c.AcCmEventManager,selectionRemoved:new c.AcCmEventManager},this._ids=new Set(t)}get ids(){return Array.from(this._ids)}get count(){return this._ids.size}add(t){Array.isArray(t)?(t.forEach(e=>this._ids.add(e)),this.events.selectionAdded.dispatch({ids:t})):(this._ids.add(t),this.events.selectionAdded.dispatch({ids:[t]}))}delete(t){Array.isArray(t)?(t.forEach(e=>this._ids.delete(e)),this.events.selectionRemoved.dispatch({ids:t})):(this._ids.delete(t),this.events.selectionRemoved.dispatch({ids:[t]}))}has(t){return this._ids.has(t)}clear(){if(this._ids.size>0){const t=Array.from(this._ids);this._ids.clear(),this.events.selectionRemoved.dispatch({ids:t})}}}var p=(s=>(s[s.SELECTION=0]="SELECTION",s[s.PAN=1]="PAN",s))(p||{});class k{constructor(t){this.events={mouseMove:new c.AcCmEventManager,viewResize:new c.AcCmEventManager,hover:new c.AcCmEventManager,unhover:new c.AcCmEventManager},this._canvas=t;const e=t.getBoundingClientRect();this._bbox=new c.AcGeBox3d,this._width=e.width,this._height=e.height,this._curPos=new c.AcGePoint2d,this._curScreenPos=new c.AcGePoint2d,this._selectionSet=new U,this._editor=new F(this),this._canvas.addEventListener("mousemove",i=>this.onMouseMove(i)),this._canvas.addEventListener("mousedown",i=>{i.button===1&&this._editor.setCursor(b.Grab)}),this._canvas.addEventListener("mouseup",i=>{i.button===1&&this._editor.restoreCursor()}),window.addEventListener("resize",this.onWindowResize.bind(this)),this._selectionBoxSize=4,this._hoverTimer=null,this._pauseTimer=null,this._hoveredObjectId=null}get editor(){return this._editor}get selectionBoxSize(){return this._selectionBoxSize}set selectionBoxSize(t){this._selectionBoxSize=t}setCursor(t){this._editor.setCursor(t)}setCalculateSizeCallback(t){this._calculateSizeCallback=t}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}get bbox(){return this._bbox}get canvas(){return this._canvas}get aspect(){return this._width/this._height}get curPos(){return this._curPos}get curScreenPos(){return this._curScreenPos}get selectionSet(){return this._selectionSet}onWindowResize(){if(this._calculateSizeCallback){const{width:t,height:e}=this._calculateSizeCallback();this._width=t,this._height=e}else this._width=this._canvas.clientWidth,this._height=this._canvas.clientHeight;this.events.viewResize.dispatch({width:this._width,height:this._height})}onMouseMove(t){this._curScreenPos=new c.AcGePoint2d(t.clientX,t.clientY);const e=this.cwcs2Wcs(this._curScreenPos);this._curPos.copy(e),this.events.mouseMove.dispatch({x:e.x,y:e.y}),this.mode==0&&this.startHoverTimer(e.x,e.y)}setHoveredObjectId(t){this._hoveredObjectId&&(this.events.unhover.dispatch({id:this._hoveredObjectId,x:this.curScreenPos.x,y:this.curScreenPos.y}),this.onUnhover(this._hoveredObjectId)),this._hoveredObjectId=t,t&&(this.startPauseTimer(t),this.onHover(t))}hoverAt(t,e){const i=this.pick({x:t,y:e});i.length>0?this.setHoveredObjectId(i[0]):(this.setHoveredObjectId(null),this.clearPauseTimer())}clearHoverTimer(){this._hoverTimer&&clearTimeout(this._hoverTimer)}clearPauseTimer(){this._pauseTimer&&clearTimeout(this._pauseTimer)}startHoverTimer(t,e){this.clearHoverTimer(),this._hoverTimer=setTimeout(()=>{this.hoverAt(t,e)},50)}startPauseTimer(t){this._pauseTimer=setTimeout(()=>{this.events.hover.dispatch({id:t,x:this.curScreenPos.x,y:this.curScreenPos.y})},500)}}class ${constructor(){this._fileName="",this._docTitle="",this._isReadOnly=!0,this._database=new c.AcDbDatabase,this.docTitle="Untitled"}async openUri(t,e){this._uri=t,this._isReadOnly=e&&e.readOnly||!1,this._fileName=this.getFileNameFromUri(t);let i=!0;try{await this._database.openUri(t,e),this.docTitle=this._fileName}catch{i=!1,y.emit("failed-to-open-file",{fileName:t})}return i}async openDocument(t,e,i){var o;let n=!0;this._fileName=t;try{const r=(o=t.split(".").pop())==null?void 0:o.toLocaleLowerCase();await this._database.read(e,i,r=="dwg"?c.AcDbFileType.DWG:c.AcDbFileType.DXF),this.docTitle=this._fileName}catch(r){n=!1,y.emit("failed-to-open-file",{fileName:t}),console.error(r)}return n}get uri(){return this._uri}get database(){return this._database}get docTitle(){return this._docTitle}set docTitle(t){this._docTitle=t,typeof document<"u"&&(document.title=t)}get isReadOnly(){return this._isReadOnly}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}class yt{convert(){const t=w.instance.curDocument.database.tables.blockTable.modelSpace.newIterator(),e=new rt.AcSvgRenderer;for(const i of t)i.draw(e);this.createFileAndDownloadIt(e.export())}createFileAndDownloadIt(t){const e=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download="example.svg",document.body.appendChild(n),n.click()}}class W extends g{execute(t){new yt().convert()}}class H extends g{execute(t){y.emit("open-file",{})}}class q extends g{execute(t){w.instance.openUrl("https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/templates/"+"acadiso.dxf")}}class J extends g{execute(t){t.view.mode=p.SELECTION,t.view.setCursor(b.Crosshair)}}class Z extends g{execute(t){t.view.zoomToFit()}}class K extends X{constructor(t){super(t)}async sampler(){await w.instance.editor.getSelection().then(t=>this.view.zoomTo(t,1))}}class Q extends g{async execute(t){await new K(t.view).drag()}}class tt extends g{execute(t){t.view.mode=p.PAN,t.view.setCursor(b.Grab)}}const pt={threeBo2dToGeBox2d:s=>new c.AcGeBox2d(s.min,s.max),goBox2dToThreeBox2d:s=>new f.Box2(s.min,s.max),threeBox3dToGeBox3d:s=>new c.AcGeBox3d(s.min,s.max),goBox3dToThreeBox3d:s=>new f.Box3(s.min,s.max),threeBox3dToGeBox2d:s=>new c.AcGeBox2d(s.min,s.max),goBox2dToThreeBox3d:s=>{const t=new f.Box3;return t.min.set(s.min.x,s.min.y,0),t.max.set(s.max.x,s.max.y,0),t}};class gt extends D.AcTrBaseView{constructor(t,e,i,n){super(t,i,n),this._layoutBtrId=e,this._mode=p.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(t){t==p.SELECTION?this._cameraControls.mouseButtons={MIDDLE:f.MOUSE.PAN}:t==p.PAN&&(this._cameraControls.mouseButtons={LEFT:f.MOUSE.PAN}),this._cameraControls.update(),this._mode=t}get viewportCount(){return this._viewportViews.size}addViewport(t){this._viewportViews.set(t.viewport.id,t)}removeViewport(t){this._viewportViews.delete(t)}resize(t,e){this._height=e,this._width=t,this.updateCameraFrustum(),this._viewportViews.forEach(i=>{i.update()})}render(t){var i;this._renderer.clear(),this._renderer.render(t.internalScene,this._camera);const e=t.modelSpaceLayout;e&&this.drawViewports(e.internalObject),(i=this._axesGizmo)==null||i.update()}createAxesGizmo(){return new V.AxesGizmo(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:V.ObjectPosition.LEFT_BOTTOM})}drawViewports(t){if(this._viewportViews.size>0){const e=this._renderer.autoClear;this._renderer.autoClear=!1;const i=new f.Vector4;this._renderer.getViewport(i),this._renderer.clearDepth();const n=t.visible;t.visible=!0,this._viewportViews.forEach(o=>{o.render(t)}),t.visible=n,this._renderer.setViewport(i.x,i.y,i.z,i.w),this._renderer.autoClear=e}}}class xt{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(t){this._activeLayoutBtrId=t,this._layoutViews.forEach(e=>{e.enabled=e.layoutBtrId==t})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(t){return this._layoutViews.has(t)}getAt(t){return this._layoutViews.get(t)}resize(t,e){this._layoutViews.forEach(i=>{i.resize(t,e)})}add(t){this._layoutViews.set(t.layoutBtrId,t)}render(t){var e;(e=this.activeLayoutView)==null||e.render(t)}}function et(s,t,e=0,i=s.length-1,n=bt){for(;i>e;){if(i-e>600){const h=i-e+1,d=t-e+1,l=Math.log(h),m=.5*Math.exp(2*l/3),x=.5*Math.sqrt(l*m*(h-m)/h)*(d-h/2<0?-1:1),j=Math.max(e,Math.floor(t-d*m/h+x)),Pt=Math.min(i,Math.floor(t+(h-d)*m/h+x));et(s,t,j,Pt,n)}const o=s[t];let r=e,a=i;for(L(s,e,t),n(s[i],o)>0&&L(s,e,i);r<a;){for(L(s,r,a),r++,a--;n(s[r],o)<0;)r++;for(;n(s[a],o)>0;)a--}n(s[e],o)===0?L(s,e,a):(a++,L(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function L(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function bt(s,t){return s<t?-1:s>t?1:0}class St{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!M(t,e))return i;const n=this.toBBox,o=[];for(;e;){for(let r=0;r<e.children.length;r++){const a=e.children[r],h=e.leaf?n(a):a;M(t,h)&&(e.leaf?i.push(a):G(t,h)?this._all(a,i):o.push(a))}e=o.pop()}return i}collides(t){let e=this.data;if(!M(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const o=e.children[n],r=e.leaf?this.toBBox(o):o;if(M(t,r)){if(e.leaf||G(t,r))return!0;i.push(o)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=B([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),o=[],r=[];let a,h,d;for(;i||o.length;){if(i||(i=o.pop(),h=o[o.length-1],a=r.pop(),d=!0),i.leaf){const l=Bt(t,i.children,e);if(l!==-1)return i.children.splice(l,1),o.push(i),this._condense(o),this}!d&&!i.leaf&&G(i,n)?(o.push(i),r.push(a),a=0,h=i,i=i.children[0]):h?(a++,i=h.children[a],d=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const o=i-e+1;let r=this._maxEntries,a;if(o<=r)return a=B(t.slice(e,i+1)),S(a,this.toBBox),a;n||(n=Math.ceil(Math.log(o)/Math.log(r)),r=Math.ceil(o/Math.pow(r,n-1))),a=B([]),a.leaf=!1,a.height=n;const h=Math.ceil(o/r),d=h*Math.ceil(Math.sqrt(r));it(t,e,i,d,this.compareMinX);for(let l=e;l<=i;l+=d){const m=Math.min(l+d-1,i);it(t,l,m,h,this.compareMinY);for(let x=l;x<=m;x+=h){const j=Math.min(x+h-1,m);a.children.push(this._build(t,x,j,n-1))}}return S(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let o=1/0,r=1/0,a;for(let h=0;h<e.children.length;h++){const d=e.children[h],l=N(d),m=Lt(t,d)-l;m<r?(r=m,o=l<o?l:o,a=d):m===r&&l<o&&(o=l,a=d)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),o=[],r=this._chooseSubtree(n,this.data,e,o);for(r.children.push(t),T(r,n);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(n,o,e)}_split(t,e){const i=t[e],n=i.children.length,o=this._minEntries;this._chooseSplitAxis(i,o,n);const r=this._chooseSplitIndex(i,o,n),a=B(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,S(i,this.toBBox),S(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=B([t,e]),this.data.height=t.height+1,this.data.leaf=!1,S(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,o=1/0,r=1/0;for(let a=e;a<=i-e;a++){const h=C(t,0,a,this.toBBox),d=C(t,a,i,this.toBBox),l=Ct(h,d),m=N(h)+N(d);l<o?(o=l,n=a,r=m<r?m:r):l===o&&m<r&&(r=m,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:At,o=t.leaf?this.compareMinY:Et,r=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,o);r<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const o=this.toBBox,r=C(t,0,e,o),a=C(t,i-e,i,o);let h=I(r)+I(a);for(let d=e;d<i-e;d++){const l=t.children[d];T(r,t.leaf?o(l):l),h+=I(r)}for(let d=i-e-1;d>=e;d--){const l=t.children[d];T(a,t.leaf?o(l):l),h+=I(a)}return h}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)T(e[n],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():S(t[e],this.toBBox)}}function Bt(s,t,e){if(!e)return t.indexOf(s);for(let i=0;i<t.length;i++)if(e(s,t[i]))return i;return-1}function S(s,t){C(s,0,s.children.length,t,s)}function C(s,t,e,i,n){n||(n=B(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let o=t;o<e;o++){const r=s.children[o];T(n,s.leaf?i(r):r)}return n}function T(s,t){return s.minX=Math.min(s.minX,t.minX),s.minY=Math.min(s.minY,t.minY),s.maxX=Math.max(s.maxX,t.maxX),s.maxY=Math.max(s.maxY,t.maxY),s}function At(s,t){return s.minX-t.minX}function Et(s,t){return s.minY-t.minY}function N(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function I(s){return s.maxX-s.minX+(s.maxY-s.minY)}function Lt(s,t){return(Math.max(t.maxX,s.maxX)-Math.min(t.minX,s.minX))*(Math.max(t.maxY,s.maxY)-Math.min(t.minY,s.minY))}function Ct(s,t){const e=Math.max(s.minX,t.minX),i=Math.max(s.minY,t.minY),n=Math.min(s.maxX,t.maxX),o=Math.min(s.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,o-i)}function G(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function M(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function B(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function it(s,t,e,i,n){const o=[t,e];for(;o.length;){if(e=o.pop(),t=o.pop(),e-t<=i)continue;const r=t+Math.ceil((e-t)/i/2)*i;et(s,r,t,e,n),o.push(t,r,r,e)}}class Tt{constructor(t){this._group=new D.AcTrBatchedGroup,this._name=t}get name(){return this._name}set name(t){this._name=t}get visible(){return this._group.visible}set visible(t){this._group.visible=t}get internalObject(){return this._group}get stats(){const t=this._group.stats;return{name:this._name,...t}}get entityCount(){return this._group.entityCount}rerenderPoints(t){this._group.rerenderPoints(t)}hasEntity(t){return this._group.hasEntity(t)}addEntity(t){this._group.addEntity(t)}isIntersectWith(t,e){return this._group.isIntersectWith(t,e)}remove(t){throw new Error("Not implemented yet!")}update(t){return this._group.add(t),!0}hover(t){t.forEach(e=>{this._group.hover(e)})}unhover(t){t.forEach(e=>{this._group.unhover(e)})}select(t){t.forEach(e=>{this._group.select(e)})}unselect(t){t.forEach(e=>{this._group.unselect(e)})}}class Dt{constructor(){this._group=new f.Group,this._indexTree=new St,this._box=new f.Box3,this._layers=new Map}get internalObject(){return this._group}get layers(){return this._layers}get box(){return this._box}get visible(){return this._group.visible}set visible(t){this._group.visible=t}get entityCount(){let t=0;return this._layers.forEach(e=>t+=e.entityCount),t}get stats(){const t=[];let e=0,i=0,n=0,o=0,r=0;return this._layers.forEach(a=>{const h=a.stats;t.push(h),n+=h.line.indexed.geometrySize+h.line.nonIndexed.geometrySize,o+=h.mesh.indexed.geometrySize+h.mesh.nonIndexed.geometrySize,r+=h.point.indexed.geometrySize+h.point.nonIndexed.geometrySize,e+=h.summary.totalGeometrySize,i+=h.summary.totalMappingSize}),{layers:t,summary:{entityCount:this.entityCount,totalSize:{line:n,mesh:o,point:r,geometry:e,mapping:i}}}}clear(){return this._layers.forEach(t=>{this._group.remove(t.internalObject)}),this._layers.clear(),this._box.makeEmpty(),this._indexTree.clear(),this}rerenderPoints(t){this._layers.forEach(e=>{e.rerenderPoints(t)})}isIntersectWith(t,e){const i=this.getLayerByObjectId(t);return i&&i.isIntersectWith(t,e)}addEntity(t,e=!0){if(!t.objectId)throw new Error("[AcTrEntity] Object id is required to add one entity!");if(!t.layerName)throw new Error("[AcTrEntity] Layer name is required to add one entity!");const i=this.getLayer(t.layerName,!0);if(i){i.addEntity(t);const n=t.box;e&&this._box.union(n),this._indexTree.insert({minX:n.min.x,minY:n.min.y,maxX:n.max.x,maxY:n.max.y,id:t.objectId})}return this}remove(t){for(const[e,i]of this._layers)if(i.remove(t))return!0;return!1}update(t){for(const[e,i]of this._layers)if(i.update(t))return!0;return!1}hover(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.hover([e])})}unhover(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.unhover([e])})}select(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.select([e])})}unselect(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.unselect([e])})}setSnapObject(t){this._snapPointsObject&&this._group.remove(this._snapPointsObject),this._snapPointsObject=t,this._group.add(t)}search(t){return this._indexTree.search({minX:t.min.x,minY:t.min.y,maxX:t.max.x,maxY:t.max.y})}getLayerByObjectId(t){for(const[e,i]of this._layers)if(i.hasEntity(t))return i}getLayer(t,e=!0){let i=this._layers.get(t);return i===void 0&&e&&(i=new Tt(t),this._layers.set(t,i),this._group.add(i.internalObject)),i}}class It{constructor(){this._scene=new f.Scene,this._layouts=new Map,this._activeLayoutBtrId="",this._modelSpaceBtrId=""}get layouts(){return this._layouts}get box(){var t;return(t=this.activeLayout)==null?void 0:t.box}get internalScene(){return this._scene}get modelSpaceBtrId(){return this._modelSpaceBtrId}set modelSpaceBtrId(t){if(this._modelSpaceBtrId=t,!this._layouts.has(t))throw new Error(`[AcTrScene] No layout assiciated with the specified block table record id '${t}'!`)}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(t){this._activeLayoutBtrId=t,this._layouts.forEach((e,i)=>{e.visible=t==i})}get activeLayout(){if(this._activeLayoutBtrId&&this._layouts.has(this._activeLayoutBtrId))return this._layouts.get(this._activeLayoutBtrId)}get modelSpaceLayout(){if(this._modelSpaceBtrId&&this._layouts.has(this._modelSpaceBtrId))return this._layouts.get(this._modelSpaceBtrId)}get stats(){const t=[];return this._layouts.forEach(e=>t.push(e.stats)),{layouts:t}}addEmptyLayout(t){const e=new Dt;return this._layouts.set(t,e),this._scene.add(e.internalObject),e.visible=t==this._activeLayoutBtrId,e}clear(){return this._layouts.forEach(t=>{this._scene.remove(t.internalObject),t.clear()}),this._layouts.clear(),this._scene.clear(),this}setLayerVisibility(t,e){var n;let i=!1;return(n=this.activeLayout)==null||n.layers.forEach(o=>{o.name===t&&(o.visible=e,i=!0)}),i}hover(t){return this.activeLayout?(this.activeLayout.hover(t),!0):!1}unhover(t){return this.activeLayout?(this.activeLayout.unhover(t),!0):!1}select(t){return this.activeLayout?(this.activeLayout.select(t),!0):!1}unselect(t){return this.activeLayout?(this.activeLayout.unselect(t),!0):!1}search(t){const e=this.activeLayout;return e?e==null?void 0:e.search(t):[]}addEntity(t,e=!0){const i=t.ownerId;if(i){let n=this._layouts.get(i);n||(n=this.addEmptyLayout(i)),n.addEntity(t,e)}else console.warn("[AcTrSecene] The owner id of one entity cannot be empty!");return this}remove(t){for(const[e,i]of this._layouts)if(i.remove(t))return!0;return!1}update(t){for(const[e,i]of this._layouts)if(i.update(t))return!0;return!1}setSnapObject(t){return this._layouts.forEach(e=>{e.setSnapObject(t)}),this}}const R={background:0};class st extends k{constructor(t=R){const e={...R,...t},i=new f.WebGLRenderer({antialias:!0,alpha:!0,canvas:t.canvas});e.canvas==null&&(e.canvas=i.domElement),super(e.canvas),t.calculateSizeCallback&&this.setCalculateSizeCallback(t.calculateSizeCallback),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.setSize(this.width,this.height),i.setClearColor(e.background||0),this._renderer=new D.AcTrRenderer(i);const n=E.instance.fontMapping;this._renderer.setFontMapping(n),this._renderer.events.fontNotFound.addEventListener(o=>{y.emit("font-not-found",{fontName:o.fontName,count:o.count??0})}),this._scene=this.createScene(),this._stats=this.createStats(E.instance.isShowStats),E.instance.events.modified.addEventListener(o=>{o.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,o.value)}),this.canvas.addEventListener("click",()=>{this.mode==p.SELECTION&&this.select()}),document.addEventListener("keydown",o=>{o.code==="Escape"&&this.selectionSet.clear()}),c.acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(o=>{this.activeLayoutBtrId=o.newLayout.blockTableRecordId}),this._missedImages=new Map,this._layoutViewManager=new xt,this.initialize(),this.onWindowResize(),this.animate(),this._isDirty=!0}initialize(){this.setCursor(b.Crosshair)}get mode(){const t=this.activeLayoutView;return t?t.mode:p.SELECTION}set mode(t){this.activeLayoutView.mode=t,this.editor.getPoint()}get renderer(){return this._renderer}get isDirty(){return this._isDirty}set isDirty(t){this._isDirty=t}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages}}get center(){return this.activeLayoutView.center}set center(t){this.activeLayoutView.center=t}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(t){this._scene.modelSpaceBtrId=t}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(t){this._layoutViewManager.activeLayoutBtrId=t,this._scene.activeLayoutBtrId=t,this._isDirty=!0}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}animate(){var t;requestAnimationFrame(this.animate.bind(this)),this._isDirty&&(this._layoutViewManager.render(this._scene),(t=this._stats)==null||t.update(),this._isDirty=!1)}cwcs2Wcs(t){const e=this.activeLayoutView;return e?e.cwcs2Wcs(t):new c.AcGePoint2d(t)}wcs2Cwcs(t){const e=this.activeLayoutView;return e?e.wcs2Cwcs(t):new c.AcGePoint2d(t)}zoomTo(t,e=1.1){this.activeLayoutView.zoomTo(t,e),this._isDirty=!0}rerenderPoints(t){const e=this._scene.activeLayout;e&&(e.rerenderPoints(t),this._isDirty=!0)}zoomToFit(){if(this._scene.box){const t=pt.threeBox3dToGeBox2d(this._scene.box);this.zoomTo(t),this._isDirty=!0}}pick(t){t==null&&(t=this.curPos);const e=[],i=this._scene.activeLayout;if(i){const n=this.activeLayoutView,o=n.pointToBox(t,this.selectionBoxSize),r=this._scene.search(o),a=Math.max(o.size.width/2,o.size.height/2),h=n.resetRaycaster(t,a);r.forEach(d=>{const l=d.id;i.isIntersectWith(l,h)&&e.push(l)})}return e}search(t){return this._scene.search(t)}select(t){const e=[];this.pick(t).forEach(n=>e.push(n)),e.length>0&&this.selectionSet.add(e)}selectByBox(t){const e=[];this._scene.search(t).forEach(n=>e.push(n.id)),this.selectionSet.add(e)}addEntity(t){const e=this.createLayoutViewIfNeeded(t.ownerId);let i=t.draw(this._renderer);if(i){i.objectId=t.objectId,i.ownerId=t.ownerId,i.layerName=t.layer,i.visible=t.visibility;const n=!(t instanceof c.AcDbRay||t instanceof c.AcDbXline);this._scene.addEntity(i,n),this._isDirty=!0,i.dispose(),i=null}if(t instanceof c.AcDbViewport){if(t.number>1){const n=new D.AcTrViewportView(e,t.toGiViewport(),this._renderer);e.addViewport(n)}}else if(t instanceof c.AcDbRasterImage){const n=t.imageFileName;n&&this._missedImages.set(t.objectId,n)}}removeEntity(t){this._scene.remove(t)}updateEntity(t){const e=t.draw(this._renderer);return e&&(e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility,this._scene.update(e),this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)),e}clear(){this._scene.clear(),this._isDirty=!0,this._missedImages.clear(),this._renderer.clearMissedFonts()}highlight(t){this._isDirty=this._scene.select(t)}unhighlight(t){this._isDirty=this._scene.unselect(t)}setLayerVisibility(t,e){this._isDirty=this._scene.setLayerVisibility(t,e)}onHover(t){this._isDirty=this._scene.hover([t])}onUnhover(t){this._isDirty=this._scene.unhover([t])}createScene(){const t=new It;return t.layouts.forEach(e=>{e.setSnapObject(this.renderer.createObject())}),t}createStats(t){const e=new ct;document.body.appendChild(e.dom);const i=e.dom;return i.style.position="fixed",i.style.inset="unset",i.style.bottom="30px",i.style.right="0px",this.toggleStatsVisibility(e,t),e}onWindowResize(){super.onWindowResize(),this._renderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0}createLayoutViewIfNeeded(t){let e=this._layoutViewManager.getAt(t);return e==null&&(e=new gt(this._renderer,t,this.width,this.height),e.events.viewChanged.addEventListener(()=>{this._isDirty=!0}),this._layoutViewManager.add(e)),e}toggleStatsVisibility(t,e){e?t.dom.style.display="block":t.dom.style.display="none"}}const nt="simsun";class A{static get instance(){return A._instance||(A._instance=new A),A._instance}createExampleDoc1(t){for(let n=0;n<2;++n)for(let o=0;o<2;++o){const r=new c.AcDbHatch,a=new c.AcGePolyline2d;a.addVertexAt(0,{x:o*100,y:n*100,bulge:1}),a.addVertexAt(1,{x:o*100+100,y:n*100,bulge:1}),a.closed=!0,r.add(a),t.tables.blockTable.modelSpace.appendEntity(r)}}createExampleDoc2(t){const e=t.tables.blockTable.modelSpace;e.appendEntity(this.createArc()),this.createLines().forEach(n=>{t.tables.blockTable.modelSpace.appendEntity(new c.AcDbLine(n.startPoint,n.endPoint))}),e.appendEntity(this.createHatch()),t.tables.textStyleTable.add(this.createTextStyle()),e.appendEntity(this.createMText())}createTextStyle(){const t={bigFont:"",color:16777215,extendedFont:nt,fixedTextHeight:0,font:nt,lastHeight:.2,name:"Standard",obliqueAngle:0,standardFlag:0,textGenerationFlag:0,widthFactor:.667};return new c.AcDbTextStyleTableRecord(t)}createMText(){const t=new c.AcDbMText;return t.attachmentPoint=c.AcGiMTextAttachmentPoint.MiddleLeft,t.color=new c.AcCmColor().setColorName("red"),t.layer="0",t.location=new c.AcGePoint3d(9850,86773,0),t.contents="{\\W0.667;\\T1.1;智慧8081}",t.height=200,t.width=1e3,t.styleName="Standard",t}createHatch(){const t=this.createLines(),e=new c.AcDbHatch,i=new c.AcGeLoop2d;return i.add(new c.AcGeCircArc2d({x:20241.23355899991,y:174118.6312674369},89258.30757455899,c.AcGeMathUtil.degToRad(262.2471115358437),c.AcGeMathUtil.degToRad(264.444541053754),!1)),t.forEach(n=>{i.add(new c.AcGeLine2d(n.startPoint,n.endPoint))}),e.add(i),e}createArc(){return new c.AcDbArc({x:20241.23355899991,y:174118.6312674369,z:0},89258.30757455899,c.AcGeMathUtil.degToRad(262.2471115358437),c.AcGeMathUtil.degToRad(264.444541053754))}createLines(){const t=[];return t.push(new c.AcGeLine3d({x:11600.20888122753,y:85279.57362051727,z:0},{x:11600.20890652924,y:86546.03982284805,z:0})),t.push(new c.AcGeLine3d({x:11600.20890652924,y:86546.03982284805,z:0},{x:10850.20885583921,y:86546.03980174381,z:0})),t.push(new c.AcGeLine3d({x:10850.2088602169,y:86546.03967292747,z:0},{x:9050.208860216895,y:86546.039672927,z:0})),t.push(new c.AcGeLine3d({x:9050.208855839213,y:86546.0397510943,z:0},{x:8200.209067034302,y:86546.039727177,z:0})),t.push(new c.AcGeLine3d({x:8200.209067034302,y:86546.039727177,z:0},{x:8200.209067033837,y:85676.22514764359,z:0})),t}}class Mt{constructor(t){this._cadRenderer=t,this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const t="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",e=t+"fonts.json";try{const i=await fetch(e);this._avaiableFonts=await i.json()}catch{y.emit("failed-to-get-avaiable-fonts",{url:e})}this._avaiableFonts.forEach(i=>{i.url=t+i.file})}return this._avaiableFonts}async load(t){await this.getAvaiableFonts();const e=[];t.forEach(n=>{const o=n.toLowerCase(),r=O.find(this._avaiableFonts,a=>O.findIndex(a.name,h=>h.toLowerCase()==o)>=0);r&&e.push(r.url)}),(await this._cadRenderer.loadFonts(e)).forEach(n=>{n.status||y.emit("font-not-loaded",{fontName:n.fontName,url:n.url})})}}class w{constructor(t){this.events={documentCreated:new c.AcCmEventManager,documentActivated:new c.AcCmEventManager};const e=new $;e.database.events.openProgress.addEventListener(o=>{y.emit("open-file-progress",{percentage:o.percentage,stage:o.stage,stageStatus:o.stageStatus})});const i=()=>({width:window.innerWidth,height:window.innerHeight-30}),n=new st({canvas:t,calculateSizeCallback:i});this._context=new z(n,e),this._fontLoader=new Mt(n.renderer),c.acdbHostApplicationServices().workingDatabase=e.database,this.registerCommands()}static createInstance(t){return w._instance==null&&(w._instance=new w(t)),this._instance}static get instance(){return w._instance||(w._instance=new w),w._instance}get context(){return this._context}get curDocument(){return this._context.doc}get mdiActiveDocument(){return this._context.doc}get curView(){return this._context.view}get editor(){return this._context.view.editor}get avaiableFonts(){return this._fontLoader.avaiableFonts}async loadFonts(t){await this._fontLoader.load(t)}async loadDefaultFonts(t){t==null?await this._fontLoader.load(["simkai"]):await this._fontLoader.load(t)}createExampleDoc(){setTimeout(async()=>{await this.loadDefaultFonts(),A.instance.createExampleDoc2(this.curDocument.database),this.setLayoutInfo(),this.curView.zoomToFit()})}async openUrl(t,e){this.onBeforeOpenDocument(),e=this.setOptions(e);const i=await this.context.doc.openUri(t,e);return this.onAfterOpenDocument(i),i}async openDocument(t,e,i){this.onBeforeOpenDocument(),i=this.setOptions(i);const n=await this.context.doc.openDocument(t,e,i);return this.onAfterOpenDocument(n),n}registerCommands(){const t=_.instance;t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"pan","pan",new tt),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"select","select",new J),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"zoom","zoom",new Z),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"zoomw","zoomw",new Q),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"csvg","csvg",new W),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"qnew","qnew",new q),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"open","open",new H)}sendStringToExecute(t){const i=_.instance.lookupGlobalCmd(t);i==null||i.execute(this.context)}onBeforeOpenDocument(){this.curView.clear()}onAfterOpenDocument(t){t&&(this.events.documentActivated.dispatch({doc:this.context.doc}),this.setLayoutInfo(),this.curView.zoomToFit())}setOptions(t){return t==null?t={fontLoader:this._fontLoader}:t.fontLoader==null&&(t.fontLoader=this._fontLoader),t}setLayoutInfo(){const t=this.curView;t.activeLayoutBtrId=this.curDocument.database.currentSpaceId,t.modelSpaceBtrId=this.curDocument.database.currentSpaceId}}const Ot={isDebug:!1,isShowCommandLine:!0,isShowCoordinate:!0,isShowToolbar:!0,isShowStats:!1,fontMapping:{}},ot="settings";class E{constructor(){this.events={modified:new c.AcCmEventManager}}static get instance(){return this._instance||(this._instance=new E),this._instance}set(t,e){const i=this.settings;i[t]=e,localStorage.setItem(ot,JSON.stringify(i)),this.events.modified.dispatch({key:t,value:e})}get(t){return this.settings[t]}toggle(t){const e=this.get(t);this.set(t,!e)}get isDebug(){return this.get("isDebug")}set isDebug(t){this.set("isDebug",t)}get isShowCommandLine(){return this.get("isShowCommandLine")}set isShowCommandLine(t){this.set("isShowCommandLine",t)}get isShowCoordinate(){return this.get("isShowCoordinate")}set isShowCoordinate(t){this.set("isShowCoordinate",t)}get isShowToolbar(){return this.get("isShowToolbar")}set isShowToolbar(t){this.set("isShowToolbar",t)}get isShowStats(){return this.get("isShowStats")}set isShowStats(t){this.set("isShowStats",t)}get fontMapping(){return this.get("fontMapping")}set fontMapping(t){this.set("fontMapping",t)}setFontMapping(t,e){const i=this.get("fontMapping");i[t]=e,this.set("fontMapping",i)}get settings(){const t=localStorage.getItem(ot),e=t==null?{}:JSON.parse(t);return O.defaults(e,Ot)}}u.AcApContext=z,u.AcApConvertToSvgCmd=W,u.AcApDocManager=w,u.AcApDocument=$,u.AcApOpenCmd=H,u.AcApPanCmd=tt,u.AcApQNewCmd=q,u.AcApSelectCmd=J,u.AcApSettingManager=E,u.AcApZoomCmd=Z,u.AcApZoomToBoxCmd=Q,u.AcApZoomToBoxJig=K,u.AcEdBaseView=k,u.AcEdCommand=g,u.AcEdCommandStack=_,u.AcEdCorsorType=b,u.AcEdCursorManager=Y,u.AcEdJig=X,u.AcEdSelectionSet=U,u.AcEdViewMode=p,u.AcEditor=F,u.AcTrView2d=st,u.DEFAULT_VIEW_2D_OPTIONS=R,u.acedAlert=dt,u.eventBus=y,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
9
+ `;return this.encodeSvgToCursor(r,n+e,n+e)}}class P{constructor(t){this.active=!1,this.isResolvedOrRejected=!1,this.onKeyDown=e=>{e.code==="Escape"&&this.reject("Canceled by user!")},this.view=t}get isActive(){return this.active}activate(){this.isActive&&console.warn("Something wrong here!"),this.active=!0,this.view.canvas.addEventListener("keydown",this.onKeyDown)}deactivate(){this.active=!1,this.view.canvas.removeEventListener("keydown",this.onKeyDown)}resolve(t){this.deactivate(),this._resolve&&!this.isResolvedOrRejected&&(this._resolve(t),this.isResolvedOrRejected=!0)}reject(t){this.deactivate(),this._reject&&!this.isResolvedOrRejected&&(this._reject(t),this.isResolvedOrRejected=!0)}async start(){return this.isResolvedOrRejected=!1,new Promise((t,e)=>{this._resolve=t,this._reject=e,this.activate()})}}class mt extends P{constructor(t){super(t),this.events={update:new c.AcCmEventManager},this.onMouseMove=e=>{this.curPos.set(e.clientX,e.clientY),this.events.update.dispatch()},this.curPos=new c.AcGePoint2d}activate(){super.activate(),this.view.canvas.addEventListener("mousemove",this.onMouseMove)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("mousemove",this.onMouseMove)}}class X{constructor(t){this.onUpdate=()=>{this.update()},this._view=t,this._jigLoop=new mt(t),this._jigLoop.events.update.addEventListener(this.onUpdate)}get view(){return this._view}resolve(t){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.resolve(t)}reject(t){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.reject(t)}async drag(){const t=this._jigLoop.start(),e=this.sampler();await Promise.allSettled([t,e])}async sampler(){}update(){}}const _t=16777215,wt="1px";class ft extends P{constructor(t){super(t),this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.mousedown=e=>{if(e.button===0){this.mouseDown=!0;const i=new c.AcGePoint2d(e.x,e.y);this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y}},this.mousemove=e=>{if(!this.mouseDown)return;const i=new c.AcGePoint2d(e.x,e.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(i.x-this.mouseDownPositionX)>=5||Math.abs(i.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;const o=new c.AcGePoint2d(Math.min(this.mouseDownPositionX,i.x),Math.min(this.mouseDownPositionY,i.y)),r=new c.AcGePoint2d(Math.max(this.mouseDownPositionX,i.x),Math.max(this.mouseDownPositionY,i.y));this.drawRect(o,r)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){const i=new c.AcGePoint2d(e.x,e.y),n=new c.AcGePoint2d(Math.min(this.mouseDownPositionX,i.x),Math.min(this.mouseDownPositionY,i.y)),o=new c.AcGePoint2d(Math.max(this.mouseDownPositionX,i.x),Math.max(this.mouseDownPositionY,i.y)),r=new c.AcGeBox2d(n,o);this.resolve(this.toWcs(r))}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.container=t.canvas,this.color=_t}activate(){super.activate(),this.active=!0,this.container.addEventListener("pointerdown",this.mousedown),this.container.addEventListener("pointermove",this.mousemove),this.container.addEventListener("pointerup",this.mouseup)}deactivate(){super.deactivate(),this.container.removeEventListener("pointerdown",this.mousedown),this.container.removeEventListener("pointermove",this.mousemove),this.container.removeEventListener("pointerup",this.mouseup),this.setRectDomVisible(!1)}reject(t){var e;super.reject(t),(e=this.boxDom)==null||e.remove(),this.boxDom=void 0}drawRect(t,e){if(!this.boxDom){const o=new c.AcCmColor;o.color=this.color,this.boxDom=document.createElement("div"),this.boxDom.style.cssText=`position: absolute;border: ${wt} solid ${o.cssColor};`,document.body.appendChild(this.boxDom)}this.setRectDomVisible(!0),t.x<=0&&(t.x=0),t.y<=0&&(t.y=0),e.x>=this.container.clientWidth-2&&(e.x=this.container.clientWidth-2),e.y>=this.container.clientHeight-2&&(e.y=this.container.clientHeight-2),this.boxDom.style.left=`${t.x}px`,this.boxDom.style.top=`${t.y}px`;const i=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y);this.boxDom.style.width=`${i}px`,this.boxDom.style.height=`${n}px`}setRectDomVisible(t){this.boxDom&&(this.boxDom.style.display=t?"inline-block":"none")}toWcs(t){const e=new c.AcGeBox2d,i=new c.AcGePoint2d(t.min.x,t.min.y),n=new c.AcGePoint2d(t.max.x,t.max.y);return e.expandByPoint(this.view.cwcs2Wcs(i)),e.expandByPoint(this.view.cwcs2Wcs(n)),e}}class vt extends P{constructor(t){super(t),this.onClick=e=>{this.resolve(this.view.cwcs2Wcs({x:e.clientX,y:e.clientY}))}}activate(){super.activate(),this.view.canvas.addEventListener("click",this.onClick)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("click",this.onClick)}}class F{constructor(t){this._view=t,this._cursorManager=new Y}get currentCursor(){return this._currentCursor}restoreCursor(){this._previousCursor!=null&&this.setCursor(this._previousCursor)}setCursor(t){this._cursorManager.setCursor(t,this._view.canvas),this._previousCursor=this._currentCursor,this._currentCursor=t}async getPoint(){return await new vt(this._view).start()}async getSelection(){return await new ft(this._view).start()}}class U{constructor(t=[]){this.events={selectionAdded:new c.AcCmEventManager,selectionRemoved:new c.AcCmEventManager},this._ids=new Set(t)}get ids(){return Array.from(this._ids)}get count(){return this._ids.size}add(t){Array.isArray(t)?(t.forEach(e=>this._ids.add(e)),this.events.selectionAdded.dispatch({ids:t})):(this._ids.add(t),this.events.selectionAdded.dispatch({ids:[t]}))}delete(t){Array.isArray(t)?(t.forEach(e=>this._ids.delete(e)),this.events.selectionRemoved.dispatch({ids:t})):(this._ids.delete(t),this.events.selectionRemoved.dispatch({ids:[t]}))}has(t){return this._ids.has(t)}clear(){if(this._ids.size>0){const t=Array.from(this._ids);this._ids.clear(),this.events.selectionRemoved.dispatch({ids:t})}}}var p=(s=>(s[s.SELECTION=0]="SELECTION",s[s.PAN=1]="PAN",s))(p||{});class k{constructor(t){this.events={mouseMove:new c.AcCmEventManager,viewResize:new c.AcCmEventManager,hover:new c.AcCmEventManager,unhover:new c.AcCmEventManager},this._canvas=t;const e=t.getBoundingClientRect();this._bbox=new c.AcGeBox3d,this._width=e.width,this._height=e.height,this._curPos=new c.AcGePoint2d,this._curScreenPos=new c.AcGePoint2d,this._selectionSet=new U,this._editor=new F(this),this._canvas.addEventListener("mousemove",i=>this.onMouseMove(i)),this._canvas.addEventListener("mousedown",i=>{i.button===1&&this._editor.setCursor(b.Grab)}),this._canvas.addEventListener("mouseup",i=>{i.button===1&&this._editor.restoreCursor()}),window.addEventListener("resize",this.onWindowResize.bind(this)),this._selectionBoxSize=4,this._hoverTimer=null,this._pauseTimer=null,this._hoveredObjectId=null}get editor(){return this._editor}get selectionBoxSize(){return this._selectionBoxSize}set selectionBoxSize(t){this._selectionBoxSize=t}setCursor(t){this._editor.setCursor(t)}setCalculateSizeCallback(t){this._calculateSizeCallback=t}get width(){return this._width}set width(t){this._width=t}get height(){return this._height}set height(t){this._height=t}get bbox(){return this._bbox}get canvas(){return this._canvas}get aspect(){return this._width/this._height}get curPos(){return this._curPos}get curScreenPos(){return this._curScreenPos}get selectionSet(){return this._selectionSet}onWindowResize(){if(this._calculateSizeCallback){const{width:t,height:e}=this._calculateSizeCallback();this._width=t,this._height=e}else this._width=this._canvas.clientWidth,this._height=this._canvas.clientHeight;this.events.viewResize.dispatch({width:this._width,height:this._height})}onMouseMove(t){this._curScreenPos=new c.AcGePoint2d(t.clientX,t.clientY);const e=this.cwcs2Wcs(this._curScreenPos);this._curPos.copy(e),this.events.mouseMove.dispatch({x:e.x,y:e.y}),this.mode==0&&this.startHoverTimer(e.x,e.y)}setHoveredObjectId(t){this._hoveredObjectId&&(this.events.unhover.dispatch({id:this._hoveredObjectId,x:this.curScreenPos.x,y:this.curScreenPos.y}),this.onUnhover(this._hoveredObjectId)),this._hoveredObjectId=t,t&&(this.startPauseTimer(t),this.onHover(t))}hoverAt(t,e){const i=this.pick({x:t,y:e});i.length>0?this.setHoveredObjectId(i[0]):(this.setHoveredObjectId(null),this.clearPauseTimer())}clearHoverTimer(){this._hoverTimer&&clearTimeout(this._hoverTimer)}clearPauseTimer(){this._pauseTimer&&clearTimeout(this._pauseTimer)}startHoverTimer(t,e){this.clearHoverTimer(),this._hoverTimer=setTimeout(()=>{this.hoverAt(t,e)},50)}startPauseTimer(t){this._pauseTimer=setTimeout(()=>{this.events.hover.dispatch({id:t,x:this.curScreenPos.x,y:this.curScreenPos.y})},500)}}class ${constructor(){this._fileName="",this._docTitle="",this._isReadOnly=!0,this._database=new c.AcDbDatabase,this.docTitle="Untitled"}async openUri(t,e){this._uri=t,this._isReadOnly=e&&e.readOnly||!1,this._fileName=this.getFileNameFromUri(t);let i=!0;try{await this._database.openUri(t,e),this.docTitle=this._fileName}catch{i=!1,y.emit("failed-to-open-file",{fileName:t})}return i}async openDocument(t,e,i){var o;let n=!0;this._fileName=t;try{const r=(o=t.split(".").pop())==null?void 0:o.toLocaleLowerCase();await this._database.read(e,i,r=="dwg"?c.AcDbFileType.DWG:c.AcDbFileType.DXF),this.docTitle=this._fileName}catch(r){n=!1,y.emit("failed-to-open-file",{fileName:t}),console.error(r)}return n}get uri(){return this._uri}get database(){return this._database}get docTitle(){return this._docTitle}set docTitle(t){this._docTitle=t,typeof document<"u"&&(document.title=t)}get isReadOnly(){return this._isReadOnly}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch(e){return console.error("Invalid URI:",e),""}}}class yt{convert(){const t=w.instance.curDocument.database.tables.blockTable.modelSpace.newIterator(),e=new rt.AcSvgRenderer;for(const i of t)i.draw(e);this.createFileAndDownloadIt(e.export())}createFileAndDownloadIt(t){const e=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download="example.svg",document.body.appendChild(n),n.click()}}class W extends g{execute(t){new yt().convert()}}class H extends g{execute(t){y.emit("open-file",{})}}class q extends g{execute(t){w.instance.openUrl("https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/templates/"+"acadiso.dxf")}}class J extends g{execute(t){t.view.mode=p.SELECTION,t.view.setCursor(b.Crosshair)}}class Z extends g{execute(t){t.view.zoomToFit()}}class K extends X{constructor(t){super(t)}async sampler(){await w.instance.editor.getSelection().then(t=>this.view.zoomTo(t,1))}}class Q extends g{async execute(t){await new K(t.view).drag()}}class tt extends g{execute(t){t.view.mode=p.PAN,t.view.setCursor(b.Grab)}}const pt={threeBo2dToGeBox2d:s=>new c.AcGeBox2d(s.min,s.max),goBox2dToThreeBox2d:s=>new f.Box2(s.min,s.max),threeBox3dToGeBox3d:s=>new c.AcGeBox3d(s.min,s.max),goBox3dToThreeBox3d:s=>new f.Box3(s.min,s.max),threeBox3dToGeBox2d:s=>new c.AcGeBox2d(s.min,s.max),goBox2dToThreeBox3d:s=>{const t=new f.Box3;return t.min.set(s.min.x,s.min.y,0),t.max.set(s.max.x,s.max.y,0),t}};class gt extends D.AcTrBaseView{constructor(t,e,i,n){super(t,i,n),this._layoutBtrId=e,this._mode=p.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(t){t==p.SELECTION?this._cameraControls.mouseButtons={MIDDLE:f.MOUSE.PAN}:t==p.PAN&&(this._cameraControls.mouseButtons={LEFT:f.MOUSE.PAN}),this._cameraControls.update(),this._mode=t}get viewportCount(){return this._viewportViews.size}addViewport(t){this._viewportViews.set(t.viewport.id,t)}removeViewport(t){this._viewportViews.delete(t)}resize(t,e){this._height=e,this._width=t,this.updateCameraFrustum(),this._viewportViews.forEach(i=>{i.update()})}render(t){var i;this._renderer.clear(),this._renderer.render(t.internalScene,this._camera);const e=t.modelSpaceLayout;e&&this.drawViewports(e.internalObject),(i=this._axesGizmo)==null||i.update()}createAxesGizmo(){return new V.AxesGizmo(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:V.ObjectPosition.LEFT_BOTTOM})}drawViewports(t){if(this._viewportViews.size>0){const e=this._renderer.autoClear;this._renderer.autoClear=!1;const i=new f.Vector4;this._renderer.getViewport(i),this._renderer.clearDepth();const n=t.visible;t.visible=!0,this._viewportViews.forEach(o=>{o.render(t)}),t.visible=n,this._renderer.setViewport(i.x,i.y,i.z,i.w),this._renderer.autoClear=e}}}class xt{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(t){this._activeLayoutBtrId=t,this._layoutViews.forEach(e=>{e.enabled=e.layoutBtrId==t})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(t){return this._layoutViews.has(t)}getAt(t){return this._layoutViews.get(t)}resize(t,e){this._layoutViews.forEach(i=>{i.resize(t,e)})}add(t){this._layoutViews.set(t.layoutBtrId,t)}render(t){var e;(e=this.activeLayoutView)==null||e.render(t)}}function et(s,t,e=0,i=s.length-1,n=bt){for(;i>e;){if(i-e>600){const h=i-e+1,d=t-e+1,l=Math.log(h),m=.5*Math.exp(2*l/3),x=.5*Math.sqrt(l*m*(h-m)/h)*(d-h/2<0?-1:1),j=Math.max(e,Math.floor(t-d*m/h+x)),Pt=Math.min(i,Math.floor(t+(h-d)*m/h+x));et(s,t,j,Pt,n)}const o=s[t];let r=e,a=i;for(L(s,e,t),n(s[i],o)>0&&L(s,e,i);r<a;){for(L(s,r,a),r++,a--;n(s[r],o)<0;)r++;for(;n(s[a],o)>0;)a--}n(s[e],o)===0?L(s,e,a):(a++,L(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function L(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function bt(s,t){return s<t?-1:s>t?1:0}class St{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!M(t,e))return i;const n=this.toBBox,o=[];for(;e;){for(let r=0;r<e.children.length;r++){const a=e.children[r],h=e.leaf?n(a):a;M(t,h)&&(e.leaf?i.push(a):G(t,h)?this._all(a,i):o.push(a))}e=o.pop()}return i}collides(t){let e=this.data;if(!M(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const o=e.children[n],r=e.leaf?this.toBBox(o):o;if(M(t,r)){if(e.leaf||G(t,r))return!0;i.push(o)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=B([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),o=[],r=[];let a,h,d;for(;i||o.length;){if(i||(i=o.pop(),h=o[o.length-1],a=r.pop(),d=!0),i.leaf){const l=Bt(t,i.children,e);if(l!==-1)return i.children.splice(l,1),o.push(i),this._condense(o),this}!d&&!i.leaf&&G(i,n)?(o.push(i),r.push(a),a=0,h=i,i=i.children[0]):h?(a++,i=h.children[a],d=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const o=i-e+1;let r=this._maxEntries,a;if(o<=r)return a=B(t.slice(e,i+1)),S(a,this.toBBox),a;n||(n=Math.ceil(Math.log(o)/Math.log(r)),r=Math.ceil(o/Math.pow(r,n-1))),a=B([]),a.leaf=!1,a.height=n;const h=Math.ceil(o/r),d=h*Math.ceil(Math.sqrt(r));it(t,e,i,d,this.compareMinX);for(let l=e;l<=i;l+=d){const m=Math.min(l+d-1,i);it(t,l,m,h,this.compareMinY);for(let x=l;x<=m;x+=h){const j=Math.min(x+h-1,m);a.children.push(this._build(t,x,j,n-1))}}return S(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let o=1/0,r=1/0,a;for(let h=0;h<e.children.length;h++){const d=e.children[h],l=N(d),m=Lt(t,d)-l;m<r?(r=m,o=l<o?l:o,a=d):m===r&&l<o&&(o=l,a=d)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),o=[],r=this._chooseSubtree(n,this.data,e,o);for(r.children.push(t),T(r,n);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(n,o,e)}_split(t,e){const i=t[e],n=i.children.length,o=this._minEntries;this._chooseSplitAxis(i,o,n);const r=this._chooseSplitIndex(i,o,n),a=B(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,S(i,this.toBBox),S(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=B([t,e]),this.data.height=t.height+1,this.data.leaf=!1,S(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,o=1/0,r=1/0;for(let a=e;a<=i-e;a++){const h=C(t,0,a,this.toBBox),d=C(t,a,i,this.toBBox),l=Ct(h,d),m=N(h)+N(d);l<o?(o=l,n=a,r=m<r?m:r):l===o&&m<r&&(r=m,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:At,o=t.leaf?this.compareMinY:Et,r=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,o);r<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const o=this.toBBox,r=C(t,0,e,o),a=C(t,i-e,i,o);let h=I(r)+I(a);for(let d=e;d<i-e;d++){const l=t.children[d];T(r,t.leaf?o(l):l),h+=I(r)}for(let d=i-e-1;d>=e;d--){const l=t.children[d];T(a,t.leaf?o(l):l),h+=I(a)}return h}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)T(e[n],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():S(t[e],this.toBBox)}}function Bt(s,t,e){if(!e)return t.indexOf(s);for(let i=0;i<t.length;i++)if(e(s,t[i]))return i;return-1}function S(s,t){C(s,0,s.children.length,t,s)}function C(s,t,e,i,n){n||(n=B(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let o=t;o<e;o++){const r=s.children[o];T(n,s.leaf?i(r):r)}return n}function T(s,t){return s.minX=Math.min(s.minX,t.minX),s.minY=Math.min(s.minY,t.minY),s.maxX=Math.max(s.maxX,t.maxX),s.maxY=Math.max(s.maxY,t.maxY),s}function At(s,t){return s.minX-t.minX}function Et(s,t){return s.minY-t.minY}function N(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function I(s){return s.maxX-s.minX+(s.maxY-s.minY)}function Lt(s,t){return(Math.max(t.maxX,s.maxX)-Math.min(t.minX,s.minX))*(Math.max(t.maxY,s.maxY)-Math.min(t.minY,s.minY))}function Ct(s,t){const e=Math.max(s.minX,t.minX),i=Math.max(s.minY,t.minY),n=Math.min(s.maxX,t.maxX),o=Math.min(s.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,o-i)}function G(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function M(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function B(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function it(s,t,e,i,n){const o=[t,e];for(;o.length;){if(e=o.pop(),t=o.pop(),e-t<=i)continue;const r=t+Math.ceil((e-t)/i/2)*i;et(s,r,t,e,n),o.push(t,r,r,e)}}class Tt{constructor(t){this._group=new D.AcTrBatchedGroup,this._name=t}get name(){return this._name}set name(t){this._name=t}get visible(){return this._group.visible}set visible(t){this._group.visible=t}get internalObject(){return this._group}get stats(){const t=this._group.stats;return{name:this._name,...t}}get entityCount(){return this._group.entityCount}rerenderPoints(t){this._group.rerenderPoints(t)}hasEntity(t){return this._group.hasEntity(t)}addEntity(t){this._group.addEntity(t)}isIntersectWith(t,e){return this._group.isIntersectWith(t,e)}remove(t){throw new Error("Not implemented yet!")}update(t){return this._group.add(t),!0}hover(t){t.forEach(e=>{this._group.hover(e)})}unhover(t){t.forEach(e=>{this._group.unhover(e)})}select(t){t.forEach(e=>{this._group.select(e)})}unselect(t){t.forEach(e=>{this._group.unselect(e)})}}class Dt{constructor(){this._group=new f.Group,this._indexTree=new St,this._box=new f.Box3,this._layers=new Map}get internalObject(){return this._group}get layers(){return this._layers}get box(){return this._box}get visible(){return this._group.visible}set visible(t){this._group.visible=t}get entityCount(){let t=0;return this._layers.forEach(e=>t+=e.entityCount),t}get stats(){const t=[];let e=0,i=0,n=0,o=0,r=0;return this._layers.forEach(a=>{const h=a.stats;t.push(h),n+=h.line.indexed.geometrySize+h.line.nonIndexed.geometrySize,o+=h.mesh.indexed.geometrySize+h.mesh.nonIndexed.geometrySize,r+=h.point.indexed.geometrySize+h.point.nonIndexed.geometrySize,e+=h.summary.totalGeometrySize,i+=h.summary.totalMappingSize}),{layers:t,summary:{entityCount:this.entityCount,totalSize:{line:n,mesh:o,point:r,geometry:e,mapping:i}}}}clear(){return this._layers.forEach(t=>{this._group.remove(t.internalObject)}),this._layers.clear(),this._box.makeEmpty(),this._indexTree.clear(),this}rerenderPoints(t){this._layers.forEach(e=>{e.rerenderPoints(t)})}isIntersectWith(t,e){const i=this.getLayerByObjectId(t);return i&&i.isIntersectWith(t,e)}addEntity(t,e=!0){if(!t.objectId)throw new Error("[AcTrEntity] Object id is required to add one entity!");if(!t.layerName)throw new Error("[AcTrEntity] Layer name is required to add one entity!");const i=this.getLayer(t.layerName,!0);if(i){i.addEntity(t);const n=t.box;e&&this._box.union(n),this._indexTree.insert({minX:n.min.x,minY:n.min.y,maxX:n.max.x,maxY:n.max.y,id:t.objectId})}return this}remove(t){for(const[e,i]of this._layers)if(i.remove(t))return!0;return!1}update(t){for(const[e,i]of this._layers)if(i.update(t))return!0;return!1}hover(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.hover([e])})}unhover(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.unhover([e])})}select(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.select([e])})}unselect(t){t.forEach(e=>{const i=this.getLayerByObjectId(e);i&&i.unselect([e])})}setSnapObject(t){this._snapPointsObject&&this._group.remove(this._snapPointsObject),this._snapPointsObject=t,this._group.add(t)}search(t){return this._indexTree.search({minX:t.min.x,minY:t.min.y,maxX:t.max.x,maxY:t.max.y})}getLayerByObjectId(t){for(const[e,i]of this._layers)if(i.hasEntity(t))return i}getLayer(t,e=!0){let i=this._layers.get(t);return i===void 0&&e&&(i=new Tt(t),this._layers.set(t,i),this._group.add(i.internalObject)),i}}class It{constructor(){this._scene=new f.Scene,this._layouts=new Map,this._activeLayoutBtrId="",this._modelSpaceBtrId=""}get layouts(){return this._layouts}get box(){var t;return(t=this.activeLayout)==null?void 0:t.box}get internalScene(){return this._scene}get modelSpaceBtrId(){return this._modelSpaceBtrId}set modelSpaceBtrId(t){if(this._modelSpaceBtrId=t,!this._layouts.has(t))throw new Error(`[AcTrScene] No layout assiciated with the specified block table record id '${t}'!`)}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(t){this._activeLayoutBtrId=t,this._layouts.forEach((e,i)=>{e.visible=t==i})}get activeLayout(){if(this._activeLayoutBtrId&&this._layouts.has(this._activeLayoutBtrId))return this._layouts.get(this._activeLayoutBtrId)}get modelSpaceLayout(){if(this._modelSpaceBtrId&&this._layouts.has(this._modelSpaceBtrId))return this._layouts.get(this._modelSpaceBtrId)}get stats(){const t=[];return this._layouts.forEach(e=>t.push(e.stats)),{layouts:t}}addEmptyLayout(t){const e=new Dt;return this._layouts.set(t,e),this._scene.add(e.internalObject),e.visible=t==this._activeLayoutBtrId,e}clear(){return this._layouts.forEach(t=>{this._scene.remove(t.internalObject),t.clear()}),this._layouts.clear(),this._scene.clear(),this}setLayerVisibility(t,e){var n;let i=!1;return(n=this.activeLayout)==null||n.layers.forEach(o=>{o.name===t&&(o.visible=e,i=!0)}),i}hover(t){return this.activeLayout?(this.activeLayout.hover(t),!0):!1}unhover(t){return this.activeLayout?(this.activeLayout.unhover(t),!0):!1}select(t){return this.activeLayout?(this.activeLayout.select(t),!0):!1}unselect(t){return this.activeLayout?(this.activeLayout.unselect(t),!0):!1}search(t){const e=this.activeLayout;return e?e==null?void 0:e.search(t):[]}addEntity(t,e=!0){const i=t.ownerId;if(i){let n=this._layouts.get(i);n||(n=this.addEmptyLayout(i)),n.addEntity(t,e)}else console.warn("[AcTrSecene] The owner id of one entity cannot be empty!");return this}remove(t){for(const[e,i]of this._layouts)if(i.remove(t))return!0;return!1}update(t){for(const[e,i]of this._layouts)if(i.update(t))return!0;return!1}setSnapObject(t){return this._layouts.forEach(e=>{e.setSnapObject(t)}),this}}const R={background:0};class st extends k{constructor(t=R){const e={...R,...t},i=new f.WebGLRenderer({antialias:!0,alpha:!0,canvas:t.canvas});e.canvas==null&&(e.canvas=i.domElement),super(e.canvas),t.calculateSizeCallback&&this.setCalculateSizeCallback(t.calculateSizeCallback),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.setSize(this.width,this.height),i.setClearColor(e.background||0),this._renderer=new D.AcTrRenderer(i);const n=E.instance.fontMapping;this._renderer.setFontMapping(n),this._renderer.events.fontNotFound.addEventListener(o=>{y.emit("font-not-found",{fontName:o.fontName,count:o.count??0})}),this._scene=this.createScene(),this._stats=this.createStats(E.instance.isShowStats),E.instance.events.modified.addEventListener(o=>{o.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,o.value)}),this.canvas.addEventListener("click",()=>{this.mode==p.SELECTION&&this.select()}),document.addEventListener("keydown",o=>{o.code==="Escape"&&this.selectionSet.clear()}),c.acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(o=>{this.activeLayoutBtrId=o.newLayout.blockTableRecordId}),this._missedImages=new Map,this._layoutViewManager=new xt,this.initialize(),this.onWindowResize(),this.animate(),this._isDirty=!0}initialize(){this.setCursor(b.Crosshair)}get mode(){const t=this.activeLayoutView;return t?t.mode:p.SELECTION}set mode(t){this.activeLayoutView.mode=t,this.editor.getPoint()}get renderer(){return this._renderer}get isDirty(){return this._isDirty}set isDirty(t){this._isDirty=t}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages}}get center(){return this.activeLayoutView.center}set center(t){this.activeLayoutView.center=t}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(t){this._scene.modelSpaceBtrId=t}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(t){this._layoutViewManager.activeLayoutBtrId=t,this._scene.activeLayoutBtrId=t,this._isDirty=!0}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}animate(){var t;requestAnimationFrame(this.animate.bind(this)),this._isDirty&&(this._layoutViewManager.render(this._scene),(t=this._stats)==null||t.update(),this._isDirty=!1)}cwcs2Wcs(t){const e=this.activeLayoutView;return e?e.cwcs2Wcs(t):new c.AcGePoint2d(t)}wcs2Cwcs(t){const e=this.activeLayoutView;return e?e.wcs2Cwcs(t):new c.AcGePoint2d(t)}zoomTo(t,e=1.1){this.activeLayoutView.zoomTo(t,e),this._isDirty=!0}rerenderPoints(t){const e=this._scene.activeLayout;e&&(e.rerenderPoints(t),this._isDirty=!0)}zoomToFit(){if(this._scene.box){const t=pt.threeBox3dToGeBox2d(this._scene.box);this.zoomTo(t),this._isDirty=!0}}pick(t){t==null&&(t=this.curPos);const e=[],i=this._scene.activeLayout;if(i){const n=this.activeLayoutView,o=n.pointToBox(t,this.selectionBoxSize),r=this._scene.search(o),a=Math.max(o.size.width/2,o.size.height/2),h=n.resetRaycaster(t,a);r.forEach(d=>{const l=d.id;i.isIntersectWith(l,h)&&e.push(l)})}return e}search(t){return this._scene.search(t)}select(t){const e=[];this.pick(t).forEach(n=>e.push(n)),e.length>0&&this.selectionSet.add(e)}selectByBox(t){const e=[];this._scene.search(t).forEach(n=>e.push(n.id)),this.selectionSet.add(e)}addEntity(t){const e=this.createLayoutViewIfNeeded(t.ownerId);let i=t.draw(this._renderer);if(i){i.objectId=t.objectId,i.ownerId=t.ownerId,i.layerName=t.layer,i.visible=t.visibility;const n=!(t instanceof c.AcDbRay||t instanceof c.AcDbXline);this._scene.addEntity(i,n),this._isDirty=!0,i.dispose(),i=null}if(t instanceof c.AcDbViewport){if(t.number>1){const n=new D.AcTrViewportView(e,t.toGiViewport(),this._renderer);e.addViewport(n)}}else if(t instanceof c.AcDbRasterImage){const n=t.imageFileName;n&&this._missedImages.set(t.objectId,n)}}removeEntity(t){this._scene.remove(t)}updateEntity(t){const e=t.draw(this._renderer);return e&&(e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility,this._scene.update(e),this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)),e}clear(){this._scene.clear(),this._isDirty=!0,this._missedImages.clear(),this._renderer.clearMissedFonts()}highlight(t){this._isDirty=this._scene.select(t)}unhighlight(t){this._isDirty=this._scene.unselect(t)}setLayerVisibility(t,e){this._isDirty=this._scene.setLayerVisibility(t,e)}onHover(t){this._isDirty=this._scene.hover([t])}onUnhover(t){this._isDirty=this._scene.unhover([t])}createScene(){const t=new It;return t.layouts.forEach(e=>{e.setSnapObject(this.renderer.createObject())}),t}createStats(t){const e=new ct;document.body.appendChild(e.dom);const i=e.dom;return i.style.position="fixed",i.style.inset="unset",i.style.bottom="30px",i.style.right="0px",this.toggleStatsVisibility(e,t),e}onWindowResize(){super.onWindowResize(),this._renderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0}createLayoutViewIfNeeded(t){let e=this._layoutViewManager.getAt(t);return e==null&&(e=new gt(this._renderer,t,this.width,this.height),e.events.viewChanged.addEventListener(()=>{this._isDirty=!0}),this._layoutViewManager.add(e)),e}toggleStatsVisibility(t,e){e?t.dom.style.display="block":t.dom.style.display="none"}}const nt="simsun";class A{static get instance(){return A._instance||(A._instance=new A),A._instance}createExampleDoc1(t){for(let n=0;n<2;++n)for(let o=0;o<2;++o){const r=new c.AcDbHatch,a=new c.AcGePolyline2d;a.addVertexAt(0,{x:o*100,y:n*100,bulge:1}),a.addVertexAt(1,{x:o*100+100,y:n*100,bulge:1}),a.closed=!0,r.add(a),t.tables.blockTable.modelSpace.appendEntity(r)}}createExampleDoc2(t){const e=t.tables.blockTable.modelSpace;e.appendEntity(this.createArc()),this.createLines().forEach(n=>{t.tables.blockTable.modelSpace.appendEntity(new c.AcDbLine(n.startPoint,n.endPoint))}),e.appendEntity(this.createHatch()),t.tables.textStyleTable.add(this.createTextStyle()),e.appendEntity(this.createMText())}createTextStyle(){const t={bigFont:"",color:16777215,extendedFont:nt,fixedTextHeight:0,font:nt,lastHeight:.2,name:"Standard",obliqueAngle:0,standardFlag:0,textGenerationFlag:0,widthFactor:.667};return new c.AcDbTextStyleTableRecord(t)}createMText(){const t=new c.AcDbMText;return t.attachmentPoint=c.AcGiMTextAttachmentPoint.MiddleLeft,t.color=new c.AcCmColor().setColorName("red"),t.layer="0",t.location=new c.AcGePoint3d(9850,86773,0),t.contents="{\\W0.667;\\T1.1;智慧8081}",t.height=200,t.width=1e3,t.styleName="Standard",t}createHatch(){const t=this.createLines(),e=new c.AcDbHatch,i=new c.AcGeLoop2d;return i.add(new c.AcGeCircArc2d({x:20241.23355899991,y:174118.6312674369},89258.30757455899,c.AcGeMathUtil.degToRad(262.2471115358437),c.AcGeMathUtil.degToRad(264.444541053754),!1)),t.forEach(n=>{i.add(new c.AcGeLine2d(n.startPoint,n.endPoint))}),e.add(i),e}createArc(){return new c.AcDbArc({x:20241.23355899991,y:174118.6312674369,z:0},89258.30757455899,c.AcGeMathUtil.degToRad(262.2471115358437),c.AcGeMathUtil.degToRad(264.444541053754))}createLines(){const t=[];return t.push(new c.AcGeLine3d({x:11600.20888122753,y:85279.57362051727,z:0},{x:11600.20890652924,y:86546.03982284805,z:0})),t.push(new c.AcGeLine3d({x:11600.20890652924,y:86546.03982284805,z:0},{x:10850.20885583921,y:86546.03980174381,z:0})),t.push(new c.AcGeLine3d({x:10850.2088602169,y:86546.03967292747,z:0},{x:9050.208860216895,y:86546.039672927,z:0})),t.push(new c.AcGeLine3d({x:9050.208855839213,y:86546.0397510943,z:0},{x:8200.209067034302,y:86546.039727177,z:0})),t.push(new c.AcGeLine3d({x:8200.209067034302,y:86546.039727177,z:0},{x:8200.209067033837,y:85676.22514764359,z:0})),t}}class Mt{constructor(t){this._cadRenderer=t,this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const t="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",e=t+"fonts.json";try{const i=await fetch(e);this._avaiableFonts=await i.json()}catch{y.emit("failed-to-get-avaiable-fonts",{url:e})}this._avaiableFonts.forEach(i=>{i.url=t+i.file})}return this._avaiableFonts}async load(t){await this.getAvaiableFonts();const e=[];t.forEach(n=>{const o=n.toLowerCase(),r=O.find(this._avaiableFonts,a=>O.findIndex(a.name,h=>h.toLowerCase()==o)>=0);r&&e.push(r.url)}),(await this._cadRenderer.loadFonts(e)).forEach(n=>{n.status||y.emit("font-not-loaded",{fontName:n.fontName,url:n.url})})}}class w{constructor(t){this.events={documentCreated:new c.AcCmEventManager,documentActivated:new c.AcCmEventManager};const e=new $;e.database.events.openProgress.addEventListener(o=>{y.emit("open-file-progress",{percentage:o.percentage,stage:o.stage,subStage:o.subStage,stageStatus:o.stageStatus})});const i=()=>({width:window.innerWidth,height:window.innerHeight-30}),n=new st({canvas:t,calculateSizeCallback:i});this._context=new z(n,e),this._fontLoader=new Mt(n.renderer),c.acdbHostApplicationServices().workingDatabase=e.database,this.registerCommands()}static createInstance(t){return w._instance==null&&(w._instance=new w(t)),this._instance}static get instance(){return w._instance||(w._instance=new w),w._instance}get context(){return this._context}get curDocument(){return this._context.doc}get mdiActiveDocument(){return this._context.doc}get curView(){return this._context.view}get editor(){return this._context.view.editor}get avaiableFonts(){return this._fontLoader.avaiableFonts}async loadFonts(t){await this._fontLoader.load(t)}async loadDefaultFonts(t){t==null?await this._fontLoader.load(["simkai"]):await this._fontLoader.load(t)}createExampleDoc(){setTimeout(async()=>{await this.loadDefaultFonts(),A.instance.createExampleDoc2(this.curDocument.database),this.setLayoutInfo(),this.curView.zoomToFit()})}async openUrl(t,e){this.onBeforeOpenDocument(),e=this.setOptions(e);const i=await this.context.doc.openUri(t,e);return this.onAfterOpenDocument(i),i}async openDocument(t,e,i){this.onBeforeOpenDocument(),i=this.setOptions(i);const n=await this.context.doc.openDocument(t,e,i);return this.onAfterOpenDocument(n),n}registerCommands(){const t=_.instance;t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"pan","pan",new tt),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"select","select",new J),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"zoom","zoom",new Z),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"zoomw","zoomw",new Q),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"csvg","csvg",new W),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"qnew","qnew",new q),t.addCommand(_.SYSTEMT_COMMAND_GROUP_NAME,"open","open",new H)}sendStringToExecute(t){const i=_.instance.lookupGlobalCmd(t);i==null||i.execute(this.context)}onBeforeOpenDocument(){this.curView.clear()}onAfterOpenDocument(t){t&&(this.events.documentActivated.dispatch({doc:this.context.doc}),this.setLayoutInfo(),this.curView.zoomToFit())}setOptions(t){return t==null?t={fontLoader:this._fontLoader}:t.fontLoader==null&&(t.fontLoader=this._fontLoader),t}setLayoutInfo(){const t=this.curView;t.activeLayoutBtrId=this.curDocument.database.currentSpaceId,t.modelSpaceBtrId=this.curDocument.database.currentSpaceId}}const Ot={isDebug:!1,isShowCommandLine:!0,isShowCoordinate:!0,isShowToolbar:!0,isShowStats:!1,fontMapping:{}},ot="settings";class E{constructor(){this.events={modified:new c.AcCmEventManager}}static get instance(){return this._instance||(this._instance=new E),this._instance}set(t,e){const i=this.settings;i[t]=e,localStorage.setItem(ot,JSON.stringify(i)),this.events.modified.dispatch({key:t,value:e})}get(t){return this.settings[t]}toggle(t){const e=this.get(t);this.set(t,!e)}get isDebug(){return this.get("isDebug")}set isDebug(t){this.set("isDebug",t)}get isShowCommandLine(){return this.get("isShowCommandLine")}set isShowCommandLine(t){this.set("isShowCommandLine",t)}get isShowCoordinate(){return this.get("isShowCoordinate")}set isShowCoordinate(t){this.set("isShowCoordinate",t)}get isShowToolbar(){return this.get("isShowToolbar")}set isShowToolbar(t){this.set("isShowToolbar",t)}get isShowStats(){return this.get("isShowStats")}set isShowStats(t){this.set("isShowStats",t)}get fontMapping(){return this.get("fontMapping")}set fontMapping(t){this.set("fontMapping",t)}setFontMapping(t,e){const i=this.get("fontMapping");i[t]=e,this.set("fontMapping",i)}get settings(){const t=localStorage.getItem(ot),e=t==null?{}:JSON.parse(t);return O.defaults(e,Ot)}}u.AcApContext=z,u.AcApConvertToSvgCmd=W,u.AcApDocManager=w,u.AcApDocument=$,u.AcApOpenCmd=H,u.AcApPanCmd=tt,u.AcApQNewCmd=q,u.AcApSelectCmd=J,u.AcApSettingManager=E,u.AcApZoomCmd=Z,u.AcApZoomToBoxCmd=Q,u.AcApZoomToBoxJig=K,u.AcEdBaseView=k,u.AcEdCommand=g,u.AcEdCommandStack=_,u.AcEdCorsorType=b,u.AcEdCursorManager=Y,u.AcEdJig=X,u.AcEdSelectionSet=U,u.AcEdViewMode=p,u.AcEditor=F,u.AcTrView2d=st,u.DEFAULT_VIEW_2D_OPTIONS=R,u.acedAlert=dt,u.eventBus=y,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- {"version":3,"file":"AcApDocManager.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAa9B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,GAAG,EAAE,YAAY,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACzB,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAa;IAC7B,8CAA8C;IAC9C,OAAO,CAAC,WAAW,CAAgB;IACnC,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAgB;IAEzC,6CAA6C;IAC7C,SAAgB,MAAM;QACpB,2CAA2C;;QAE3C,2CAA2C;;MAE5C;IAED;;;;;;;;OAQG;IACH,OAAO;IAuBP;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB;IAOhD;;;;;;OAMG;IACH,MAAM,KAAK,QAAQ,mBAKlB;IAED;;;;;;OAM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W,EAC7B,OAAO,EAAE,uBAAuB;IAclC;;;;;;;;;;;;;OAaG;IACH,gBAAgB;IA8ChB;;;;;;;;;;;;;OAaG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM;IAMlC;;;;;;;OAOG;IACH,SAAS,CAAC,oBAAoB;IAI9B;;;;;;;;;OASG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO;IAUhD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;CAKtB"}
@@ -78,6 +78,7 @@ var AcApDocManager = /** @class */ (function () {
78
78
  eventBus.emit('open-file-progress', {
79
79
  percentage: args.percentage,
80
80
  stage: args.stage,
81
+ subStage: args.subStage,
81
82
  stageStatus: args.stageStatus
82
83
  });
83
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"AcApDocManager.js","sourceRoot":"","sources":["../../src/app/AcApDocManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAE5B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAA6B,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAUjD;;;;;;;;;;;GAWG;AACH;IAgBE;;;;;;;;OAQG;IACH,wBAAoB,MAA0B;QAjB9C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AO,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,CAAA;QAC5C,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YACtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;;;OAOG;IACK,sCAAa,GAArB;QACE,IAAM,WAAW,GAAG,IAAI,CAAC,OAAqB,CAAA;QAC9C,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAA;QACxE,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAA;IACxE,CAAC;IACH,qBAAC;AAAD,CAAC,AAraD,IAqaC"}
@@ -1,4 +1,4 @@
1
- import { AcDbConversionStage, AcDbConversionStageStatus } from '@mlightcad/data-model';
1
+ import { AcDbProgressdEventArgs } from '@mlightcad/data-model';
2
2
  import { type Emitter } from 'mitt';
3
3
  /**
4
4
  * Message severity type for user notifications.
@@ -6,6 +6,13 @@ import { type Emitter } from 'mitt';
6
6
  * Used to categorize messages shown to users with appropriate visual styling.
7
7
  */
8
8
  export type AcEdMessageType = 'success' | 'warning' | 'info' | 'error';
9
+ /**
10
+ * Progress event arguments for database operations.
11
+ *
12
+ * This type represents the progress information for database operations
13
+ * like opening files, excluding the database reference.
14
+ */
15
+ export type AcEdOpenFileProgressEventArgs = Omit<AcDbProgressdEventArgs, 'database'>;
9
16
  /**
10
17
  * Type definition for all events that can be emitted through the global event bus.
11
18
  *
@@ -21,14 +28,7 @@ export type AcEdEvents = {
21
28
  /** Emitted to request opening a file dialog */
22
29
  'open-file': {};
23
30
  /** Emitted during file opening to report progress */
24
- 'open-file-progress': {
25
- /** Progress percentage (0-100) */
26
- percentage: number;
27
- /** Current conversion stage */
28
- stage: AcDbConversionStage;
29
- /** Status of the current stage */
30
- stageStatus: AcDbConversionStageStatus;
31
- };
31
+ 'open-file-progress': AcEdOpenFileProgressEventArgs;
32
32
  /** Emitted to display a message to the user */
33
33
  message: {
34
34
  /** The message text to display */
@@ -87,7 +87,8 @@ export type AcEdEvents = {
87
87
  * // Emit a progress update
88
88
  * eventBus.emit('open-file-progress', {
89
89
  * percentage: 50,
90
- * stage: AcDbConversionStage.Parsing,
90
+ * stage: 'CONVERSION'
91
+ * subStage: AcDbConversionStage.Parsing,
91
92
  * stageStatus: AcDbConversionStageStatus.InProgress
92
93
  * });
93
94
  *
@@ -1 +1 @@
1
- {"version":3,"file":"eventBus.d.ts","sourceRoot":"","sources":["../../../src/editor/global/eventBus.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAa,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAA;AAEtE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,+CAA+C;IAC/C,WAAW,EAAE,EAAE,CAAA;IACf,qDAAqD;IACrD,oBAAoB,EAAE;QACpB,kCAAkC;QAClC,UAAU,EAAE,MAAM,CAAA;QAClB,+BAA+B;QAC/B,KAAK,EAAE,mBAAmB,CAAA;QAC1B,kCAAkC;QAClC,WAAW,EAAE,yBAAyB,CAAA;KACvC,CAAA;IACD,+CAA+C;IAC/C,OAAO,EAAE;QACP,kCAAkC;QAClC,OAAO,EAAE,MAAM,CAAA;QACf,uCAAuC;QACvC,IAAI,EAAE,eAAe,CAAA;KACtB,CAAA;IACD,wCAAwC;IACxC,iBAAiB,EAAE;QACjB,2CAA2C;QAC3C,QAAQ,EAAE,MAAM,CAAA;QAChB,yDAAyD;QACzD,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,gEAAgE;IAChE,8BAA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ChE,8BAA8B,EAAE;QAC9B,kEAAkE;QAClE,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,wCAAwC;IACxC,qBAAqB,EAAE;QACrB,gDAAgD;QAChD,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,gDAAgD;IAChD,gBAAgB,EAAE;QAChB,+BAA+B;QAC/B,QAAQ,EAAE,MAAM,CAAA;QAChB,gDAAgD;QAChD,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAsB,CAAA"}
@@ -25,7 +25,8 @@ import mitt from 'mitt';
25
25
  * // Emit a progress update
26
26
  * eventBus.emit('open-file-progress', {
27
27
  * percentage: 50,
28
- * stage: AcDbConversionStage.Parsing,
28
+ * stage: 'CONVERSION'
29
+ * subStage: AcDbConversionStage.Parsing,
29
30
  * stageStatus: AcDbConversionStageStatus.InProgress
30
31
  * });
31
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"eventBus.js","sourceRoot":"","sources":["../../../src/editor/global/eventBus.ts"],"names":[],"mappings":"AAIA,OAAO,IAAsB,MAAM,MAAM,CAAA;AAiEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAwB,IAAI,EAAc,CAAA"}
1
+ {"version":3,"file":"eventBus.js","sourceRoot":"","sources":["../../../src/editor/global/eventBus.ts"],"names":[],"mappings":"AACA,OAAO,IAAsB,MAAM,MAAM,CAAA;AAkEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAwB,IAAI,EAAc,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mlightcad/cad-simple-viewer",
3
3
  "private": false,
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
@@ -43,12 +43,12 @@
43
43
  "rbush": "^4.0.1"
44
44
  },
45
45
  "peerDependencies": {
46
- "@mlightcad/data-model": "1.1.3",
46
+ "@mlightcad/data-model": "1.1.4",
47
47
  "@mlightcad/three-viewcube": "0.0.9",
48
48
  "three": "^0.172.0",
49
49
  "lodash-es": "4.17.21",
50
- "@mlightcad/svg-renderer": "0.0.2",
51
- "@mlightcad/three-renderer": "1.0.1"
50
+ "@mlightcad/svg-renderer": "0.0.3",
51
+ "@mlightcad/three-renderer": "1.0.2"
52
52
  },
53
53
  "scripts": {
54
54
  "clean": "rimraf dist lib tsconfig.tsbuildinfo",