@mlightcad/data-model 1.15.24 → 1.15.25
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/data-model.cjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
`).replace(wx,"").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").trim()}function Sx(i,t,e=1){const n=i.trim();if(!n||t<=0)return 0;const r=Ax(n),s=xx.test(n);return r?Math.max(t,En(r,t,e)):s?t:0}function En(i,t,e=1){if(!i||t<=0)return 0;const n=Jl(i),r=Math.max(...n.split(/\r\n|\r|\n/g).map(s=>s.length),0);return r===0?0:Math.max(t,r*t*_x*e)}function Px(i){const t=Jl(i);return Math.max(t.split(/\r\n|\r|\n/g).length,1)}function kx(i,t,e,n=1){if(t<=0||i<=0)return 0;if(i===1)return t;const r=Math.max(e,0)*(5/3),s=n===2?r:Math.max(r,1);return t+(i-1)*t*s}function th(i,t,e){switch(e){case exports.AcGiMTextAttachmentPoint.TopCenter:return{minX:-i/2,minY:-t,maxX:i/2,maxY:0};case exports.AcGiMTextAttachmentPoint.TopRight:return{minX:-i,minY:-t,maxX:0,maxY:0};case exports.AcGiMTextAttachmentPoint.MiddleLeft:return{minX:0,minY:-t/2,maxX:i,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleCenter:return{minX:-i/2,minY:-t/2,maxX:i/2,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleRight:return{minX:-i,minY:-t/2,maxX:0,maxY:t/2};case exports.AcGiMTextAttachmentPoint.BottomLeft:case exports.AcGiMTextAttachmentPoint.BaselineLeft:return{minX:0,minY:0,maxX:i,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomCenter:case exports.AcGiMTextAttachmentPoint.BaselineCenter:return{minX:-i/2,minY:0,maxX:i/2,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomRight:case exports.AcGiMTextAttachmentPoint.BaselineRight:return{minX:-i,minY:0,maxX:0,maxY:t};case exports.AcGiMTextAttachmentPoint.TopLeft:default:return{minX:0,minY:-t,maxX:i,maxY:0}}}function eh(i,t){let e;t&&t.lengthSq()>0?e=t.clone().normalize():e=new A(Math.cos(i),Math.sin(i),0);const n=new A(-e.y,e.x,e.z);return n.lengthSq()===0?n.set(0,1,0):n.normalize(),{xAxis:e,yAxis:n}}function Ix(i,t,e,n,r,s=0,a){if(e<=0&&n<=0)return i.expandByPoint(t),i;const o=th(e,n,r),{xAxis:c,yAxis:l}=eh(s,void 0),h=[[o.minX,o.minY],[o.maxX,o.minY],[o.maxX,o.maxY],[o.minX,o.maxY]];for(const[u,d]of h)i.expandByPoint(new x(t.x+c.x*u+l.x*d,t.y+c.y*u+l.y*d,t.z+c.z*u+l.z*d));return i}function jc(i){const t=i.extentsWidth>0?i.extentsWidth:i.width>0?i.width:En(i.contents,i.height),e=kx(Px(i.contents),i.height,i.lineSpacingFactor,i.lineSpacingStyle??1);return{width:t,height:e,attachment:i.attachmentPoint,rotation:i.rotation,direction:i.direction.lengthSq()>0?i.direction.clone():void 0,location:new x(i.location.x,i.location.y,i.location.z??0)}}function Ex(i,t){const{xAxis:e,yAxis:n}=eh(t.rotation,t.direction),r=i.x-t.location.x,s=i.y-t.location.y,a=(i.z??0)-t.location.z;return{x:r*e.x+s*e.y+a*e.z,y:r*n.x+s*n.y+a*n.z}}function Vc(i,t=0){const e=th(i.width,i.height,i.attachment),n=Math.max(0,t),r=e.minX-n,s=e.minY-n,a=e.maxX+n,o=e.maxY+n,{xAxis:c,yAxis:l}=eh(i.rotation,i.direction);return[[r,s],[a,s],[a,o],[r,o]].map(([u,d])=>new x(i.location.x+c.x*u+l.x*d,i.location.y+c.y*u+l.y*d,i.location.z+c.z*u+l.z*d))}function td(i,t){return!(t>0)||!(i>1)?0:(i-1)*t}function Tx(i,t,e){const n=th(t.width,t.height,t.attachment),{x:r,y:s}=Ex(i,t),a=n.minX-e.padX,o=n.maxX+e.padX,c=n.minY-e.padYBelow,l=n.maxY+e.padYAbove;if(r<a||r>o||s<c||s>l)return null;const h=r<n.minX?n.minX-r:r>n.maxX?n.maxX-r:0,u=s<n.minY?n.minY-s:s>n.maxY?s-n.maxY:0;return h+u}var gi=(i=>(i[i.Fit=1]="Fit",i[i.Left=2]="Left",i[i.Right=3]="Right",i[i.Center=4]="Center",i))(gi||{}),up=(i=>(i[i.OutwardFromCenter=1]="OutwardFromCenter",i[i.InwardToTheCenter=2]="InwardToTheCenter",i))(up||{}),dp=(i=>(i[i.OnConvexSide=1]="OnConvexSide",i[i.OnConcaveSide=2]="OnConcaveSide",i))(dp||{});const Jo=Math.PI*2;function Lx(i,t){const e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:t}const Lh=class Lh extends et{constructor(){super(...arguments),this._textString="",this._textSize=0,this._xScale=1,this._characterSpacing=0,this._styleName="",this._fontName="",this._bigFontName="",this._offsetFromArc=0,this._rightOffset=0,this._leftOffset=0,this._center=new x,this._radius=0,this._startAngle=0,this._endAngle=0,this._normal=new A(0,0,1),this._characterSet=0,this._pitchAndFamily=0,this._isShx=!1,this._isBold=!1,this._isItalic=!1,this._isUnderlined=!1,this._alignment=1,this._isReverse=!1,this._wizardFlag=0,this._textPosition=1,this._textDirection=1,this._arcId=""}get dxfTypeName(){return"ARCALIGNEDTEXT"}get textString(){return this._textString}set textString(t){this._textString=t??""}get textSize(){return this._textSize}set textSize(t){this._textSize=t}get xScale(){return this._xScale}set xScale(t){this._xScale=t}get characterSpacing(){return this._characterSpacing}set characterSpacing(t){this._characterSpacing=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t??""}get fontName(){return this._fontName}set fontName(t){this._fontName=t??""}get bigFontName(){return this._bigFontName}set bigFontName(t){this._bigFontName=t??""}get offsetFromArc(){return this._offsetFromArc}set offsetFromArc(t){this._offsetFromArc=t}get rightOffset(){return this._rightOffset}set rightOffset(t){this._rightOffset=t}get leftOffset(){return this._leftOffset}set leftOffset(t){this._leftOffset=t}get center(){return this._center}set center(t){this._center.copy(t)}get radius(){return this._radius}set radius(t){this._radius=t}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get characterSet(){return this._characterSet}set characterSet(t){this._characterSet=t}get pitchAndFamily(){return this._pitchAndFamily}set pitchAndFamily(t){this._pitchAndFamily=t}get isShx(){return this._isShx}set isShx(t){this._isShx=t}get isBold(){return this._isBold}set isBold(t){this._isBold=t}get isItalic(){return this._isItalic}set isItalic(t){this._isItalic=t}get isUnderlined(){return this._isUnderlined}set isUnderlined(t){this._isUnderlined=t}get alignment(){return this._alignment}set alignment(t){this._alignment=t}get isReverse(){return this._isReverse}set isReverse(t){this._isReverse=t}get wizardFlag(){return this._wizardFlag}set wizardFlag(t){this._wizardFlag=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition=t}get textDirection(){return this._textDirection}set textDirection(t){this._textDirection=t}get arcId(){return this._arcId}set arcId(t){this._arcId=t??""}applyRawTextColor(t){if(!Number.isFinite(t))return;const e=new X,n=t>>>24&255;if(t===0||n===193)e.setByBlock();else if(t===256||n===192||n===200)e.setByLayer();else if(t>0&&t<256)e.colorIndex=t;else if(n===194||n===195||n===197)e.setRGBValue(t&16777215);else return;this._rawTextColor=t,this.color=e}rawTextColor(){if(this._rawTextColor!=null&&Number.isFinite(this._rawTextColor))return this._rawTextColor;if(this.color.isByBlock)return 0;if(this.color.isByLayer)return 256;const t=this.color.colorIndex;if(t!=null&&t>0&&t<256)return t;const e=this.color.RGB;return e!=null?(194<<24|e&16777215)>>0:256}glyphPlacements(){const t=Array.from(this._textString).filter(w=>w!=="\r");if(this._isReverse&&t.reverse(),t.length===0)return[];const e=this._textSize>0?this._textSize:1,n=this._xScale>0?this._xScale:1,r=t.map(w=>w===" "||w===`
|
|
10
10
|
`?e*.5*n:En(w,e,n)),s=r.reduce((w,k)=>w+k,0),a=this._textPosition!==2,o=this._textDirection===1,c=Math.abs(this._radius)+(a?1:-1)*this._offsetFromArc,l=a===o?0:a?e:-e,h=Math.max(1e-6,c+l);let u=this._endAngle-this._startAngle;for(;u<=1e-9;)u+=Jo;for(;u>Jo;)u-=Jo;const d=u*h,g=Math.max(0,d-this._leftOffset-this._rightOffset),f=Math.max(0,t.length-1);let p=this._characterSpacing;this._alignment===1&&f>0&&(p=(g-s)/f);const m=s+p*f;let y=this._leftOffset;this._alignment===3?y=d-this._rightOffset-m:(this._alignment===4||this._alignment===0)&&(y=this._leftOffset+(g-m)/2);const b=this.extrusionMatrix(),_=[];for(let w=0;w<t.length;w++){const k=r[w]??0,P=t[w]??"";if(P===`
|
|
11
11
|
`)continue;const v=y+k/2,S=this._startAngle+v/h,I=new x(this._center.x+h*Math.cos(S),this._center.y+h*Math.sin(S),this._center.z);let M=S+Math.PI/2;this._textDirection===1&&(M+=Math.PI),_.push({text:P,position:I.applyMatrix4(b),rotation:this.rotationInWcs(M,b)}),y+=k+p}return _}get geometricExtents(){const t=new H,e=this.glyphPlacements();if(e.length===0)return t.expandByPoint(this._center),t;const n=this._textSize>0?this._textSize:1;for(const r of e){const s=En(r.text,n,this._xScale>0?this._xScale:1),a=Math.max(s,n)/2;t.expandByPoint(new x(r.position.x-a,r.position.y-a,r.position.z)),t.expandByPoint(new x(r.position.x+a,r.position.y+a,r.position.z))}return t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textSize,set:t=>{this.textSize=t}}},{name:"xScale",type:"float",editable:!0,accessor:{get:()=>this.xScale,set:t=>{this.xScale=t}}},{name:"characterSpacing",type:"float",editable:!0,accessor:{get:()=>this.characterSpacing,set:t=>{this.characterSpacing=t}}},{name:"offsetFromArc",type:"float",editable:!0,accessor:{get:()=>this.offsetFromArc,set:t=>{this.offsetFromArc=t}}},{name:"alignment",type:"enum",editable:!0,options:[{label:gi[1],value:1},{label:gi[2],value:2},{label:gi[3],value:3},{label:gi[4],value:4}],accessor:{get:()=>this.alignment,set:t=>{this.alignment=t}}},{name:"isBold",type:"boolean",editable:!0,accessor:{get:()=>this.isBold,set:t=>{this.isBold=t}}},{name:"isItalic",type:"boolean",editable:!0,accessor:{get:()=>this.isItalic,set:t=>{this.isItalic=t}}},{name:"isUnderlined",type:"boolean",editable:!0,accessor:{get:()=>this.isUnderlined,set:t=>{this.isUnderlined=t}}},{name:"isReverse",type:"boolean",editable:!0,accessor:{get:()=>this.isReverse,set:t=>{this.isReverse=t}}},{name:"fontName",type:"string",editable:!0,accessor:{get:()=>this.fontName,set:t=>{this.fontName=t}}},{name:"bigFontName",type:"string",editable:!0,accessor:{get:()=>this.bigFontName,set:t=>{this.bigFontName=t}}}]},{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"leftOffset",type:"float",editable:!0,accessor:{get:()=>this.leftOffset,set:t=>{this.leftOffset=t}}},{name:"rightOffset",type:"float",editable:!0,accessor:{get:()=>this.rightOffset,set:t=>{this.rightOffset=t}}}]}]}}subWorldDraw(t,e){const n=this.glyphPlacements();if(n.length===0)return;const r=this.getTextStyle(),s=this._textSize>0?this._textSize:1,a=[];for(const o of n){const l={text:this._isUnderlined?`\\L${o.text}`:o.text,height:s,width:1/0,widthFactor:this._xScale>0?this._xScale:1,position:o.position,rotation:o.rotation,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineCenter};a.push(t.mtext(l,r,e))}return a.length===1?a[0]:t.group(a)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArcAlignedText"),t.writeString(1,this._textString),t.writeString(2,this._fontName),t.writeString(3,this._bigFontName),t.writeString(7,this._styleName),t.writePoint3d(10,this._center),t.writeDouble(40,this._radius),t.writeDouble(41,this._xScale),t.writeDouble(42,this._textSize),t.writeDouble(43,this._characterSpacing),t.writeDouble(44,this._offsetFromArc),t.writeDouble(45,this._rightOffset),t.writeDouble(46,this._leftOffset),t.writeAngle(50,this._startAngle),t.writeAngle(51,this._endAngle),t.writeInt16(70,this._isReverse?1:0),t.writeInt16(71,this._textDirection),t.writeInt16(72,this._alignment),t.writeInt16(73,this._textPosition),t.writeInt16(74,this._isBold?1:0),t.writeInt16(75,this._isItalic?1:0),t.writeInt16(76,this._isUnderlined?1:0),t.writeInt16(77,this._characterSet),t.writeInt16(78,this._pitchAndFamily),t.writeInt16(79,this._isShx?1:0),t.writeInt32(90,this.rawTextColor()),t.writeVector3d(210,this._normal),t.writeInt16(280,this._wizardFlag),this._arcId&&t.writeHandle(330,this._arcId),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbArcAlignedText");let e=this._center.x,n=this._center.y,r=this._center.z,s=this._normal.x,a=this._normal.y,o=this._normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value),u=c.value==null?"":String(c.value);switch(l){case 1:this._textString=u;break;case 2:this._fontName=u;break;case 3:this._bigFontName=u;break;case 7:this._styleName=u;break;case 10:e=h;break;case 20:n=h;break;case 30:r=h;break;case 40:this._radius=h;break;case 41:this._xScale=h;break;case 42:this._textSize=h;break;case 43:this._characterSpacing=h;break;case 44:this._offsetFromArc=h;break;case 45:this._rightOffset=h;break;case 46:this._leftOffset=h;break;case 50:this._startAngle=h;break;case 51:this._endAngle=h;break;case 70:this._isReverse=h!==0;break;case 71:this._textDirection=h;break;case 72:this._alignment=h;break;case 73:this._textPosition=h;break;case 74:this._isBold=h!==0;break;case 75:this._isItalic=h!==0;break;case 76:this._isUnderlined=h!==0;break;case 77:this._characterSet=h;break;case 78:this._pitchAndFamily=h;break;case 79:this._isShx=h!==0;break;case 90:this.applyRawTextColor(h);break;case 210:s=h;break;case 220:a=h;break;case 230:o=h;break;case 280:this._wizardFlag=h;break;case 330:this._arcId=u;break}}return this._center.set(e,n,r),this._normal.set(s,a,o),this}getTextStyle(){var r,s;const t=(s=(r=this.database)==null?void 0:r.tables)==null?void 0:s.textStyleTable,e=(t==null?void 0:t.resolveAt(this._styleName))??(t==null?void 0:t.resolveAt(gt)),n=e?{...e.textStyle}:{name:this._styleName||gt,standardFlag:0,fixedTextHeight:0,widthFactor:this._xScale>0?this._xScale:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:this._textSize,font:this._fontName||"txt",bigFont:this._bigFontName};return this._fontName&&(n.font=this._fontName),this._bigFontName&&(n.bigFont=this._bigFontName),this._xScale>0&&(n.widthFactor=this._xScale),n}isPlanarInWcs(){return Math.abs(this._normal.x)<1e-10&&Math.abs(this._normal.y)<1e-10&&this._normal.z>0}extrusionMatrix(){return this.isPlanarInWcs()?new z:new z().setFromExtrusionDirection(this._normal)}rotationInWcs(t,e){if(this.isPlanarInWcs())return t;const n=new A(Math.cos(t),Math.sin(t),0);return n.transformDirection(e),Math.atan2(n.y,n.x)}};Lh.typeName="ArcAlignedText";let ua=Lh;function Mx(i,t=0){return Lx(i,t)}var gp=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(gp||{}),fp=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(fp||{});const Mh=class Mh extends et{constructor(){super(),this._hasAlignmentPoint=!1,this._generationFlag=0,this._normal=new A(0,0,1),this._textString="",this._height=0,this._thickness=0,this._position=new x,this._alignmentPoint=new x,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=0,this._styleName="",this._widthFactor=1}get dxfTypeName(){return"TEXT"}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}get annotative(){return Se(this)}set annotative(t){me(this,t)}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get alignmentPoint(){return this._alignmentPoint}set alignmentPoint(t){this._alignmentPoint.copy(t),this._hasAlignmentPoint=!0}get hasAlignmentPoint(){return this._hasAlignmentPoint}set hasAlignmentPoint(t){this._hasAlignmentPoint=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get generationFlag(){return this._generationFlag}set generationFlag(t){this._generationFlag=t}get isBackward(){return(this._generationFlag&2)!==0}set isBackward(t){this._generationFlag=t?this._generationFlag|2:this._generationFlag&-3}get isUpsideDown(){return(this._generationFlag&4)!==0}set isUpsideDown(t){this._generationFlag=t?this._generationFlag|4:this._generationFlag&-5}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get geometricExtents(){const t=new H,{anchor:e,attachmentPoint:n}=this.resolveTextAnchor(),r=this.extrusionDrawingAdjust(),s=En(this.textString,this.height,Math.abs(r.widthFactor));return Ix(t,e,s,this.height,n,r.rotation)}subGetGripPoints(){return[this.resolveTextAnchor().anchor]}subMoveGripPointsAt(t,e){const n=Zt(e,this._normal);return he(t,n,this._position),this._alignmentPoint.add(n),this}subGetOsnapPoints(t,e,n,r){T.Insertion===t&&r.push(this.resolveTextAnchor().anchor)}transformBy(t){const e=this._position.clone(),n=this._position.clone().add(new A(Math.cos(this._rotation),Math.sin(this._rotation),0)),r=this._position.clone().add(new A(-Math.sin(this._rotation),Math.cos(this._rotation),0)),s=this._position.clone().add(new A(0,0,1));e.applyMatrix4(t),n.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new A(n).sub(e),o=new A(r).sub(e),c=new A(s).sub(e),l=o.length(),h=a.length(),u=c.length();this._position.copy(e),h>0&&(this._rotation=Math.atan2(a.y,a.x)),l>0&&(this._height*=l,h>0&&(this._widthFactor*=h/l)),u>0&&(this._thickness*=u);const d=this._alignmentPoint.clone();return d.applyMatrix4(t),this._alignmentPoint.copy(d),this}get properties(){return this.getTextProperties()}getTextProperties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"horizontalMode",type:"int",editable:!0,accessor:{get:()=>this.horizontalMode,set:t=>{this.horizontalMode=t}}},{name:"verticalMode",type:"int",editable:!0,accessor:{get:()=>this.verticalMode,set:t=>{this.verticalMode=t}}},{name:"isBackward",type:"boolean",editable:!0,accessor:{get:()=>this.isBackward,set:t=>{this.isBackward=t}}},{name:"isUpsideDown",type:"boolean",editable:!0,accessor:{get:()=>this.isUpsideDown,set:t=>{this.isUpsideDown=t}}},{name:"hasAlignmentPoint",type:"boolean",editable:!1,accessor:{get:()=>this.hasAlignmentPoint}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"alignmentPointX",type:"float",editable:!0,accessor:{get:()=>this.alignmentPoint.x,set:t=>{this.alignmentPoint.x=t}}},{name:"alignmentPointY",type:"float",editable:!0,accessor:{get:()=>this.alignmentPoint.y,set:t=>{this.alignmentPoint.y=t}}},{name:"alignmentPointZ",type:"float",editable:!0,accessor:{get:()=>this.alignmentPoint.z,set:t=>{this.alignmentPoint.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}resolveAnnotativePresentation(){var u;const{anchor:t,attachmentPoint:e}=this.resolveTextAnchor(),n=this.extrusionDrawingAdjust(),r=Wt(this),s=r.length>0||pe(this);let a=this.height,o=t,c=n.rotation,l,h;if(s&&r.length>0){const d=Re(this.height,r);l=He(r,(u=this.database)==null?void 0:u.cannoscale)??r.find(f=>f.isDefault)??r[0],a=Be(d,l.scale.scaleFactor);const g=l.contextData;if(g instanceof tr){const p=g.horizontalMode!==0||g.alignmentPoint.x!==0||g.alignmentPoint.y!==0||g.alignmentPoint.z!==0?g.alignmentPoint:g.position;o=this.pointToWcs(p),c=g.rotation}h=Ge(r,l)}return{height:a,position:o,attachmentPoint:e,rotation:c,preferred:l,annotationScale:h}}subWorldDraw(t,e){const{height:n,position:r,attachmentPoint:s,rotation:a,annotationScale:o}=this.resolveAnnotativePresentation(),c=this.extrusionDrawingAdjust(),l={text:this.textString,height:n,width:1/0,widthFactor:c.widthFactor,position:r,rotation:a,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:s},h=t.mtext(l,this.getTextStyle(),e);if(h&&o){const u=h.userData;u.annotationScale=o}return h}pointToWcs(t){return ce(t,this._normal)}extrusionDrawingAdjust(){if(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)return{rotation:this._rotation,widthFactor:this._widthFactor};if(this._normal.x===0&&this._normal.y===0&&this._normal.z<0)return{rotation:-this._rotation,widthFactor:-this._widthFactor};const t=new A(Math.cos(this._rotation),Math.sin(this._rotation),0);return t.transformDirection(new z().setFromExtrusionDirection(this._normal)),{rotation:Math.atan2(t.y,t.x),widthFactor:this._widthFactor}}resolveTextAnchor(){const t=this.resolveAttachmentPoint();if(t===exports.AcGiMTextAttachmentPoint.BaselineLeft)return{anchor:this.pointToWcs(this._position),attachmentPoint:t};const e=this._alignmentPoint;return!this._hasAlignmentPoint||e.x===0&&e.y===0&&e.z===0?{anchor:this.pointToWcs(this._position),attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft}:{anchor:this.pointToWcs(e),attachmentPoint:t}}resolveAttachmentPoint(){const t=this._horizontalMode,e=this._verticalModel;if(t===4)return exports.AcGiMTextAttachmentPoint.MiddleCenter;if(t===3||t===5)return exports.AcGiMTextAttachmentPoint.BaselineLeft;switch(e){case 3:return t===1?exports.AcGiMTextAttachmentPoint.TopCenter:t===2?exports.AcGiMTextAttachmentPoint.TopRight:exports.AcGiMTextAttachmentPoint.TopLeft;case 2:return t===1?exports.AcGiMTextAttachmentPoint.MiddleCenter:t===2?exports.AcGiMTextAttachmentPoint.MiddleRight:exports.AcGiMTextAttachmentPoint.MiddleLeft;case 1:return t===1?exports.AcGiMTextAttachmentPoint.BottomCenter:t===2?exports.AcGiMTextAttachmentPoint.BottomRight:exports.AcGiMTextAttachmentPoint.BottomLeft;case 0:default:return t===1?exports.AcGiMTextAttachmentPoint.BaselineCenter:t===2?exports.AcGiMTextAttachmentPoint.BaselineRight:exports.AcGiMTextAttachmentPoint.BaselineLeft}}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbText"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,this.position),t.writeDouble(40,this.height),t.writeString(1,this.textString),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeString(7,this.styleName||"Standard"),this.generationFlag!==0&&t.writeInt16(71,this.generationFlag),t.writeInt16(72,this.horizontalMode);const e=this.horizontalMode!==0||this.verticalMode!==0,n=this.hasAlignmentPoint?this.alignmentPoint:e?this.position:this.alignmentPoint;return t.writePoint3d(11,n),t.writeVector3d(210,this.normal),t.writeSubclassMarker("AcDbText"),t.writeInt16(73,this.verticalMode),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbText");let e=this.position.x,n=this.position.y,r=this.position.z,s=this.alignmentPoint.x,a=this.alignmentPoint.y,o=this.alignmentPoint.z,c=!1,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),f=Number(d.value);switch(g){case 10:e=f;break;case 20:n=f;break;case 30:r=f;break;case 11:s=f,c=!0;break;case 21:a=f,c=!0;break;case 31:o=f,c=!0;break;case 1:this.textString=String(d.value);break;case 7:this.styleName=String(d.value);break;case 39:this.thickness=f;break;case 40:this.height=f;break;case 41:this.widthFactor=f;break;case 50:this.rotation=D.degToRad(f);break;case 51:this.oblique=D.degToRad(f);break;case 71:this.generationFlag=f;break;case 72:this.horizontalMode=f;break;case 73:this.verticalMode=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break;case 100:{if(String(d.value)==="AcDbText")break;return t.pushBackItem(d),this.finishTextDxfIn(e,n,r,s,a,o,c,l,h,u),this}}}return this.finishTextDxfIn(e,n,r,s,a,o,c,l,h,u),this}finishTextDxfIn(t,e,n,r,s,a,o,c,l,h){this.position=new x(t,e,n),o&&!(r===0&&s===0&&a===0)?(this.alignmentPoint=new x(r,s,a),this._hasAlignmentPoint=!0):(this.alignmentPoint=new x(t,e,n),this._hasAlignmentPoint=!1);const u=new A(c,l,h);u.lengthSq()>0&&this.normal.copy(u.normalize())}};Mh.typeName="Text";let ji=Mh;var Tt=(i=>(i[i.Invisible=1]="Invisible",i[i.Const=2]="Const",i[i.Verifiable=4]="Verifiable",i[i.Preset=8]="Preset",i))(Tt||{}),Ee=(i=>(i[i.MultiLine=2]="MultiLine",i[i.ConstMultiLine=4]="ConstMultiLine",i))(Ee||{});const Ch=class Ch extends ji{get dxfTypeName(){return"ATTDEF"}constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}isLooseInDrawingSpace(){const t=this.database;if(!t)return!1;const e=this.getAttrWithoutException("ownerId");if(!e)return!1;const n=t.tables.blockTable.getIdAt(e);return n?n.isModelSapce||n.isPaperSapce:!1}resolveDisplayText(){if(!this.isInvisible){if(this.isLooseInDrawingSpace())return this.tag||this.textString;if(this.isConst||this.isConstMTextAttribute)return this.textString}}resolveMTextAnnotativePresentation(t){var y;const e=this.mtext,n=(e==null?void 0:e.height)??this.height,r=(e==null?void 0:e.width)??0,s=e!=null&&e.location?new x(e.location):this.position.clone(),a=e!=null&&e.direction?new A(e.direction):new A(1,0,0),o=(e==null?void 0:e.attachmentPoint)??exports.AcGiMTextAttachmentPoint.TopLeft,c=Wt(this),l=c.length>0||pe(this);let h=n,u=r,d=s,g=a,f=o,p,m;if(l&&c.length>0){p=He(c,(y=this.database)==null?void 0:y.cannoscale)??c.find(_=>_.isDefault)??c[0],h=Be(Re(n,c),p.scale.scaleFactor);const b=p.contextData;b instanceof Ue&&(d=b.insertionPoint.clone(),g=b.direction.clone(),f=b.attachmentPoint,b.definedWidth>0&&(u=b.definedWidth)),m=Ge(c,p)}return{contents:t,height:h,width:u,position:d,direction:g,attachmentPoint:f,preferred:p,annotationScale:m}}subWorldDraw(t,e){const n=this.resolveDisplayText();if(n===void 0)return;if(this.isMTextAttribute&&this.mtext){const s=this.resolveMTextAnnotativePresentation(n),a={text:s.contents,height:s.height,width:s.width,position:s.position,rotation:this.mtext.rotation,directionVector:s.direction,attachmentPoint:s.attachmentPoint,drawingDirection:this.mtext.drawingDirection,lineSpaceFactor:this.mtext.lineSpacingFactor,lineSpaceStyle:this.mtext.lineSpacingStyle},o=t.mtext(a,this.getTextStyle(),e);if(o&&s.annotationScale){const c=o.userData??(o.userData={});c.annotationScale=s.annotationScale}return o}if(n===this.textString)return super.subWorldDraw(t,e);const r=this.textString;this.textString=n;try{return super.subWorldDraw(t,e)}finally{this.textString=r}}get properties(){const t=this.getTextProperties();return{type:this.type,groups:[...t.groups,{groupName:"attribute",properties:[{name:"tag",type:"string",editable:!0,accessor:{get:()=>this.tag,set:e=>{this.tag=e}}},{name:"prompt",type:"string",editable:!0,accessor:{get:()=>this.prompt,set:e=>{this.prompt=e}}},{name:"isInvisible",type:"boolean",editable:!0,accessor:{get:()=>this.isInvisible,set:e=>{this.isInvisible=e}}},{name:"isConst",type:"boolean",editable:!0,accessor:{get:()=>this.isConst,set:e=>{this.isConst=e}}},{name:"isVerifiable",type:"boolean",editable:!0,accessor:{get:()=>this.isVerifiable,set:e=>{this.isVerifiable=e}}},{name:"isPreset",type:"boolean",editable:!0,accessor:{get:()=>this.isPreset,set:e=>{this.isPreset=e}}},{name:"isMTextAttribute",type:"boolean",editable:!0,accessor:{get:()=>this.isMTextAttribute,set:e=>{this.isMTextAttribute=e}}},{name:"fieldLength",type:"int",editable:!0,accessor:{get:()=>this.fieldLength,set:e=>{this.fieldLength=e}}},{name:"lockPositionInBlock",type:"boolean",editable:!0,accessor:{get:()=>this.lockPositionInBlock,set:e=>{this.lockPositionInBlock=e}}},{name:"isReallyLocked",type:"boolean",editable:!0,accessor:{get:()=>this.isReallyLocked,set:e=>{this.isReallyLocked=e}}},{name:"isConstMTextAttribute",type:"boolean",editable:!0,accessor:{get:()=>this.isConstMTextAttribute,set:e=>{this.isConstMTextAttribute=e}}}]}]}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this._flags),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.lockPositionInBlock?1:0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttributeDefinition");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){if(String(e.value)==="AcDbAttributeDefinition")continue;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData&&t.readItem(););break}const r=Number(e.value);switch(n){case 2:this.tag=String(e.value);break;case 3:this.prompt=String(e.value);break;case 70:this.isInvisible=(r&1)!==0,this.isConst=(r&2)!==0,this.isVerifiable=(r&4)!==0,this.isPreset=(r&8)!==0;break;case 71:this.isMTextAttribute=(r&2)!==0,this.isConstMTextAttribute=(r&4)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};Ch.typeName="AttDef";let da=Ch;function Cx(i){return i!=null&&typeof i=="object"&&"blockTableRecord"in i}const Oh=class Oh extends ji{get dxfTypeName(){return"ATTRIB"}get resolvedColor(){var t;if(this.color.isByBlock){const e=(t=this.database)==null?void 0:t.tables.blockTable.getEntityById(this.ownerId);if(Cx(e))return e.resolvedColor}return this.resolveStandardColor()}constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&Tt.Invisible)!==0}set isInvisible(t){t?this._flags|=Tt.Invisible:this._flags&=~Tt.Invisible}get isConst(){return(this._flags&Tt.Const)!==0}set isConst(t){t?this._flags|=Tt.Const:this._flags&=~Tt.Const}get isVerifiable(){return(this._flags&Tt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=Tt.Verifiable:this._flags&=~Tt.Verifiable}get isPreset(){return(this._flags&Tt.Preset)!==0}set isPreset(t){t?this._flags|=Tt.Preset:this._flags&=~Tt.Preset}get isMTextAttribute(){return(this._mtextFlag&Ee.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=Ee.MultiLine:this._mtextFlag&=~Ee.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Ee.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=Ee.ConstMultiLine:this._mtextFlag&=~Ee.ConstMultiLine}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}resolveMTextAnnotativePresentation(t){var y;const e=this.mtext,n=(e==null?void 0:e.height)??this.height,r=(e==null?void 0:e.width)??0,s=e!=null&&e.location?new x(e.location):this.position.clone(),a=e!=null&&e.direction?new A(e.direction):new A(1,0,0),o=(e==null?void 0:e.attachmentPoint)??exports.AcGiMTextAttachmentPoint.TopLeft,c=Wt(this),l=c.length>0||pe(this);let h=n,u=r,d=s,g=a,f=o,p,m;if(l&&c.length>0){p=He(c,(y=this.database)==null?void 0:y.cannoscale)??c.find(_=>_.isDefault)??c[0],h=Be(Re(n,c),p.scale.scaleFactor);const b=p.contextData;b instanceof Ue&&(d=b.insertionPoint.clone(),g=b.direction.clone(),f=b.attachmentPoint,b.definedWidth>0&&(u=b.definedWidth)),m=Ge(c,p)}return{contents:t,height:h,width:u,position:d,direction:g,attachmentPoint:f,preferred:p,annotationScale:m}}subWorldDraw(t,e){if(!this.isInvisible){if(this.isMTextAttribute&&this.mtext){const n=this.resolveMTextAnnotativePresentation(this.mtext.contents||this.textString),r={text:n.contents,height:n.height,width:n.width,position:n.position,rotation:this.mtext.rotation,directionVector:n.direction,attachmentPoint:n.attachmentPoint,drawingDirection:this.mtext.drawingDirection,lineSpaceFactor:this.mtext.lineSpacingFactor,lineSpaceStyle:this.mtext.lineSpacingStyle},s=t.mtext(r,this.getTextStyle(),e);if(s&&n.annotationScale){const a=s.userData??(s.userData={});a.annotationScale=n.annotationScale}return s}return super.subWorldDraw(t,e)}}get properties(){const t=this.getTextProperties();return{type:this.type,groups:[...t.groups,{groupName:"attribute",properties:[{name:"tag",type:"string",editable:!0,accessor:{get:()=>this.tag,set:e=>{this.tag=e}}},{name:"isInvisible",type:"boolean",editable:!0,accessor:{get:()=>this.isInvisible,set:e=>{this.isInvisible=e}}},{name:"isConst",type:"boolean",editable:!0,accessor:{get:()=>this.isConst,set:e=>{this.isConst=e}}},{name:"isVerifiable",type:"boolean",editable:!0,accessor:{get:()=>this.isVerifiable,set:e=>{this.isVerifiable=e}}},{name:"isPreset",type:"boolean",editable:!0,accessor:{get:()=>this.isPreset,set:e=>{this.isPreset=e}}},{name:"isMTextAttribute",type:"boolean",editable:!0,accessor:{get:()=>this.isMTextAttribute,set:e=>{this.isMTextAttribute=e}}},{name:"fieldLength",type:"int",editable:!0,accessor:{get:()=>this.fieldLength,set:e=>{this.fieldLength=e}}},{name:"lockPositionInBlock",type:"boolean",editable:!0,accessor:{get:()=>this.lockPositionInBlock,set:e=>{this.lockPositionInBlock=e}}},{name:"isReallyLocked",type:"boolean",editable:!0,accessor:{get:()=>this.isReallyLocked,set:e=>{this.isReallyLocked=e}}},{name:"isConstMTextAttribute",type:"boolean",editable:!0,accessor:{get:()=>this.isConstMTextAttribute,set:e=>{this.isConstMTextAttribute=e}}}]}]}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttribute"),t.writeInt16(70,this.isInvisible?1:0),t.writeInt16(73,this.fieldLength),t.writeString(2,this.tag),t.writeInt16(74,this.isReallyLocked?1:0),this.mtext&&t.writeInt16(71,this.isMTextAttribute?1:0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttribute");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){if(String(e.value)==="AcDbAttribute")continue;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData&&t.readItem(););break}const r=Number(e.value);switch(n){case 2:this.tag=String(e.value);break;case 70:this.isInvisible=(r&Tt.Invisible)!==0,this.isConst=(r&Tt.Const)!==0,this.isVerifiable=(r&Tt.Verifiable)!==0,this.isPreset=(r&Tt.Preset)!==0;break;case 71:this.isMTextAttribute=(r&Ee.MultiLine)!==0,this.isConstMTextAttribute=(r&Ee.ConstMultiLine)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};Oh.typeName="Attrib";let Vr=Oh;const Ox=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}),ed=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:Ox(),blockMisses:[]}),ut=class ut{constructor(){this._lruTotalBytes=0,this._retiredCompactedTemplates=[],this._blocks=new Map,this._lruBytes=new Map}static get profileStats(){return this._profileStats}static resetProfile(){this._profileStats=ed(),this._drawDepth=0}static get instance(){return this._instance||(this._instance=new ut),this._instance}createKey(t,e){let n=e.toString();return!n&&e.isByColor&&(n=`RGB:${e.red},${e.green},${e.blue}`),`${t}_${n}`}createCacheKey(t,e,n){return n?this.createKey(t,e):t}set(t,e){if(this._blocks.set(t,e),ut.lruEnabled){const n=this._lruBytes.get(t)??0,r=this.estimateTemplateBytes(e);this._lruBytes.set(t,r),this._lruTotalBytes+=r-n,this.enforceLruBudget()}return e}enforceLruBudget(){const t=ut.lruMaxEntries;for(;t>0&&this._blocks.size>t;)this.evictOldest();const e=ut.lruMaxEstimatedBytes;for(;e>0&&this._lruTotalBytes>e&&this._blocks.size>1;)this.evictOldest()}evictOldest(){var r;const t=this._blocks.keys().next();if(t.done||t.value===void 0)return;const e=t.value,n=this._blocks.get(e);this._blocks.delete(e),this._lruTotalBytes-=this._lruBytes.get(e)??0,this._lruBytes.delete(e),n&&(nd(n)?this._retiredCompactedTemplates.push(n):(r=n.dispose)==null||r.call(n))}estimateTemplateBytes(t){var r,s;let e=0;const n=[t];for(;n.length>0;){const a=n.pop();if(a==null)continue;if(a.geometry){const c=a.geometry.attributes;if(c)for(const h in c){const u=(r=c[h])==null?void 0:r.array;u&&(e+=u.byteLength)}const l=(s=a.geometry.index)==null?void 0:s.array;l&&(e+=l.byteLength)}const o=a.children;if(o)for(let c=0;c<o.length;c++)n.push(o[c])}return e}peek(t){return this._blocks.get(t)}get(t){const e=this._blocks.get(t);if(!e)return;if(ut.lruEnabled&&(this._blocks.delete(t),this._blocks.set(t,e)),ut.profiling){const r=performance.now();if(this.maybeCompactTemplate(e,!0)){const l=performance.now()-r;ut._profileStats.missCompactMs+=l,ut._drawDepth===1&&(ut._profileStats.topLevel.missCompactMs+=l)}const a=performance.now(),o=e.fastDeepClone(),c=performance.now()-a;return ut._profileStats.cloneMs+=c,ut._drawDepth===1&&(ut._profileStats.topLevel.cloneMs+=c),ec(o,t),o}this.maybeCompactTemplate(e,!0);const n=e.fastDeepClone();return ec(n,t),n}has(t){return this._blocks.has(t)}clear(){var t;this._blocks.forEach(e=>{var n;(n=e.dispose)==null||n.call(e)}),this._blocks.clear(),this._lruBytes.clear(),this._lruTotalBytes=0,this._retiredCompactedTemplates.forEach(e=>{var n;(n=e.dispose)==null||n.call(e)}),this._retiredCompactedTemplates.length=0,(t=ut.onCleared)==null||t.call(ut)}async prebuildAll(t,e,n){const r=[];for(const l of e)!l||!l.name||this.shouldSkipPrebuild(l)||r.push(l);const s=r.length;let a=0;const o=new X().setForeground(),c=new ho;for(const l of r){const h=this.createCacheKey(l.name,o,!1);this.has(h)||this.draw(t,l,o,[],!0),a++,n&&await n(a,s,l.name),await c.maybeYield(Zi)}}draw(t,e,n,r=[],s=!0,a,o){const c=ut.profiling;c&&ut._drawDepth++;const l=c&&ut._drawDepth===1,h=ut._profileStats,u=[];try{if(e!=null){const d=n.RGB??0,g=e.name;let f;if(g&&this.has(g))f=g;else if(g){const y=this.createKey(g,n);this.has(y)&&(f=y)}let p;if(f!==void 0){const y=c?performance.now():0;if(p=this.get(f),c){const b=performance.now()-y;h.hits++,h.hitMs+=b,l&&(h.topLevel.hits++,h.topLevel.hitMs+=b)}}else{const y=c?performance.now():0;let b=!1;const _=e.newIterator();for(const S of _)if(S.visibility)if(S.color.isByBlock){b=!0;const I=Xx(S.color);try{n.isForeground?S.color.setForeground():S.color.setRGBValue(d),this.addEntity(S,u,t)}finally{S.color.copy(I),Yx(I)}}else this.addEntity(S,u,t);p=t.group(u);let w=0;c&&(w=performance.now()-y,h.missBuildMs+=w,l&&(h.topLevel.missBuildMs+=w));let k=0;const P=!!s&&!!g&&!g.startsWith("*U");if(p&&P){const S=c?performance.now():0,I=this.maybeCompactTemplate(p,!1);c&&I&&(k=performance.now()-S,h.missCompactMs+=k,l&&(h.topLevel.missCompactMs+=k))}f=this.createCacheKey(g,n,b);const v=c?h.setCloneMs:0;if(p&&P){if(zx(p),this.set(f,p),c){const S=performance.now();p=p.fastDeepClone();const I=performance.now()-S;h.setCloneMs+=I,l&&(h.topLevel.setCloneMs+=I)}else p=p.fastDeepClone();ec(p,f)}c&&(h.misses++,l&&h.topLevel.misses++,h.blockMisses.push({blockName:g||"(unnamed)",buildMs:w,compactMs:k,setCloneMs:h.setCloneMs-v}))}const m=c?performance.now():0;if(p&&a&&(ks.copy(a),p.applyMatrix(ks),o&&(o.x!=0||o.y!=0||o.z!=1)&&(tc.setFromExtrusionDirection(o),p.applyMatrix(tc),ks.premultiply(tc))),p&&r&&r.length>0){const y=a!=null?Dx.copy(ks).invert():void 0;r.forEach(b=>{y&&b.applyMatrix(y),p.addChild(b)})}if(c){const y=performance.now()-m;h.applyMs+=y,l&&(h.topLevel.applyMs+=y)}return p}else return t.group(u)}finally{c&&ut._drawDepth--}}shouldSkipPrebuild(t){const e=t.name;if(lt.isModelSapceName(e)||lt.isPaperSapceName(e)||e.startsWith("*U")||this.blockHasByBlockColor(t))return!0;for(const n of t.newIterator())if(n.visibility)return!1;return!0}blockHasByBlockColor(t){for(const e of t.newIterator())if(e.visibility&&e.color.isByBlock)return!0;return!1}addEntity(t,e,n){if(!t.visibility)return;const r=t.worldDraw(n);r&&(this.attachEntityInfo(r,t),e.push(r))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}maybeCompactTemplate(t,e){return!t.compactForInstancing||nd(t)||!Fx(t,e)?!1:(t.compactForInstancing(),!0)}};ut.profiling=!1,ut.lruEnabled=!0,ut.lruMaxEntries=512,ut.lruMaxEstimatedBytes=64*1024*1024,ut._profileStats=ed(),ut._drawDepth=0;let Tn=ut;const ks=new z,tc=new z,Dx=new z,Nx=8,Rx=32,pp=[];function Bx(i){const t=i.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function nd(i){return i.isCompacted===!0}function Fx(i,t){const e=Bx(i);return e<Nx?!1:e>=Rx?!0:t}function zx(i){const t=i.prepareCacheTemplate;typeof t=="function"&&t.call(i)}function ec(i,t){const e=i.userData;e.blockCacheKey=t}function Xx(i){const t=pp.pop()??new X;return t.copy(i),t}function Yx(i){pp.push(i)}const br="AcDbBlockRepresentation",nh="AcDbRepData",Vi="ACAD_ENHANCEDBLOCK",ih="AcDbBlockRepBTag",jx="AcDbBlockRepETag",Vx="AcDbDynamicBlockTrueName",Ux="AcDbDynamicBlockGUID";function ga(i){return i?i.trim().toUpperCase().startsWith("*U"):!1}class Uc extends pt{constructor(){super(...arguments),this._blockId=""}get blockId(){return this._blockId}set blockId(t){this._blockId=t??""}dxfOutFields(t){return super.dxfOutFields(t),t.writeObjectId(340,this._blockId),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbBlockRepresentationData");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}n===340&&(this._blockId=String(e.value??""))}return this}}class Ui{constructor(t){typeof t=="string"?(this._blockRefId=t,this._blockRef=void 0):(this._blockRef=t,this._blockRefId=t.objectId)}static isDynamicBlock(t,e){return new Ui(t).isDynamicBlock(e)}static drawableBlockTableRecord(t){const e=new Ui(t);if(e.isDynamicBlock()){const n=e.anonymousBlockTableRecord();if(n&&t.database){const r=t.database.tables.blockTable.getIdAt(n);if(r)return r;const s=t.database.getObjectById(n);if(s instanceof lt)return s}}return t.blockTableRecord}blockId(){return this._blockRefId}isDynamicBlock(t){const e=this.resolveBlockRef(t);if(!e)return!1;if(this.getRepresentationData(e)||this.hasRepresentationDictionary(e))return!0;const n=e.blockTableRecord;return n?!!(this.getDynamicDefinitionIdFromBTag(n)||this.blockTableRecordIsEnhanced(n)):!1}anonymousBlockTableRecord(t){const e=this.resolveBlockRef(t);if(!e||!this.isDynamicBlock(t))return;const n=e.blockTableRecord;if(n&&(ga(n.name)||this.getDynamicDefinitionIdFromBTag(n)!=null))return n.objectId}dynamicBlockTableRecord(t){var a;const e=this.resolveBlockRef(t);if(!e)return;const n=(a=this.getRepresentationData(e))==null?void 0:a.blockId;if(n)return n;const r=e.blockTableRecord;if(!r)return;const s=this.getDynamicDefinitionIdFromBTag(r);if(s)return s;if(this.blockTableRecordIsEnhanced(r))return r.objectId}resolveBlockRef(t){if(this._blockRef)return this._blockRef;const e=t??this.guessDatabase();if(!e)return;const n=e.getObjectById(this._blockRefId);return n instanceof Qt?n:void 0}guessDatabase(){var t;return(t=this._blockRef)==null?void 0:t.database}getExtensionDictionary(t){const e=t.extensionDictionary;if(!e||!t.database)return;const n=t.database.getObjectById(e);return n instanceof G?n:void 0}hasRepresentationDictionary(t){const e=this.getExtensionDictionary(t);return e?e.getAt(br)!=null||e.has(br):!1}getRepresentationData(t){const e=this.getExtensionDictionary(t);if(!e)return;const n=e.getAt(br),r=n instanceof G?n:this.asDictionary(n);if(!r)return;const s=r.getAt(nh);if(s instanceof Uc)return s}asDictionary(t){if(!t)return;if(t instanceof G)return t;if(!t.database)return;const e=t.database.getObjectById(t.objectId);return e instanceof G?e:void 0}getDynamicDefinitionIdFromBTag(t){const e=t.getXData(ih);if(e){for(const n of e)if(Number(n.code)===Z.ExtendedDataHandle){const r=String(n.value??"").trim();if(r)return r.toUpperCase()}}}blockTableRecordIsEnhanced(t){const e=this.getExtensionDictionary(t);return e?e.getAt(Vi)!=null||e.has(Vi):!1}}const Hx=1e-10;function ee(i,t,e){const n=t?i.length:i.length-1;if(n<1||i.length<2)return[];const r=[];for(let s=0;s<n;s++){const a=i[s],o=i[(s+1)%i.length];if(Io(a,o))continue;const c=!t&&(s===0||s===n-1);r.push({kind:"line",line:new Bt(a,o),extent:"bounded",extendable:e??c})}return r}function rh(i,t,e,n){const r=t?i.length:i.length-1;if(r<1||i.length<2)return[];const s=[];for(let a=0;a<r;a++){const o=i[a],c=i[(a+1)%i.length],h=!t&&(a===0||a===r-1),u=o.bulge??0;if(Math.abs(u)>Hx){const f=yp(new tt(o,c,u),e,n,h);f&&s.push(f);continue}const d=nn(o.x,o.y,e,n),g=nn(c.x,c.y,e,n);Io(d,g)||s.push({kind:"line",line:new Bt(d,g),extent:"bounded",extendable:h})}return s}function Gx(i,t,e){const n=[];for(const r of i){if(r instanceof ot){n.push(...rh(r.vertices,r.closed,t,e));continue}if(r instanceof _n)for(const s of r.curves){const a=Wx(s,t,e);a&&n.push(...a)}}return n}function mp(i,t){return i.map(e=>Kb(e,t))}function Wx(i,t,e){if(i instanceof yt){const n=nn(i.startPoint.x,i.startPoint.y,t,e),r=nn(i.endPoint.x,i.endPoint.y,t,e);return Io(n,r)?[]:[{kind:"line",line:new Bt(n,r),extent:"bounded",extendable:!1}]}if(i instanceof tt){const n=yp(i,t,e,!1);return n?[n]:[]}if(i instanceof qe){const n=$x(i,t,e,!1);return n?[n]:[]}if(i instanceof Xt){const n=i.clone(),r=qx(t,e);return r&&n.transform(r),[{kind:"spline",spline:n,extendable:!1}]}return[]}function yp(i,t,e,n){if(i.closed||Math.abs(i.deltaAngle-Y)<1e-10){const c=nn(i.center.x,i.center.y,t,e);return{kind:"circArc",arc:new _t(c,i.radius,0,Y,e,Mi(e)),extendable:!1}}const r=nn(i.startPoint.x,i.startPoint.y,t,e),s=nn(i.endPoint.x,i.endPoint.y,t,e),a=nn(i.midPoint.x,i.midPoint.y,t,e),o=_t.tryCreateByThreePoints(r,s,a);return o?{kind:"circArc",arc:o,extendable:n&&!o.closed}:Io(r,s)?null:{kind:"line",line:new Bt(r,s),extent:"bounded",extendable:n}}function $x(i,t,e,n){const r=nn(i.center.x,i.center.y,t,e),s=new z().setFromExtrusionDirection(new A(e.x,e.y,e.z)),a=new A(Math.cos(i.rotation),Math.sin(i.rotation),0).transformDirection(s);if(a.lengthSq()===0)return null;const o=i.clockwise?i.endAngle:i.startAngle,c=i.clockwise?i.startAngle:i.endAngle,l=new we(r,e,a,i.majorAxisRadius,i.minorAxisRadius,o,c);return{kind:"ellipseArc",arc:l,extendable:n&&!l.closed&&Math.abs(l.deltaAngle-Y)>1e-10}}function nn(i,t,e,n){return ce({x:i,y:t,z:e},n)}function qx(i,t){if(Math.abs(t.x)<1e-10&&Math.abs(t.y)<1e-10&&Math.abs(t.z-1)<1e-10&&Math.abs(i)<1e-10)return null;const n=new z().setFromExtrusionDirection(new A(t.x,t.y,t.z));return Math.abs(i)<1e-10?n:n.multiply(new z().makeTranslation(0,0,i))}function Io(i,t){const e=i.x-t.x,n=i.y-t.y,r=(i.z??0)-(t.z??0);return e*e+n*n+r*r<1e-20}const bi=class bi extends et{constructor(t){super(),this._columnCount=1,this._rowCount=1,this._columnSpacing=0,this._rowSpacing=0,this._blockName=t??"",this._position=new x,this._rotation=0,this._normal=new A(0,0,1),this._scaleFactors=new x(1,1,1),this._attribs=new Map}get dxfTypeName(){return"INSERT"}get annotative(){if(Se(this))return!0;const t=this.blockTableRecord;return!!(t!=null&&t.annotative)}set annotative(t){me(this,t)}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockName(){return this._blockName}set blockName(t){this._blockName=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=Math.max(1,Math.floor(t)||1)}get rowCount(){return this._rowCount}set rowCount(t){this._rowCount=Math.max(1,Math.floor(t)||1)}get columnSpacing(){return this._columnSpacing}set columnSpacing(t){this._columnSpacing=t}get rowSpacing(){return this._rowSpacing}set rowSpacing(t){this._rowSpacing=t}get blockTableRecord(){if(this._blockName)return this.database.tables.blockTable.getAt(this._blockName)}get drawableBlockTableRecord(){return Ui.drawableBlockTableRecord(this)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId,this.syncAttributeDatabases()}syncAttributeDatabases(){try{const t=this.database,e=new Map;this._attribs.forEach(n=>{n.database=t,t.commitObjectHandle(n),n.ownerId=this.objectId,e.set(n.objectId,n)}),this._attribs=e}catch{}}attributeIterator(){return new Hn(this._attribs)}get blockTransform(){var u,d,g;const t=this.drawableBlockTableRecord,e=(t==null?void 0:t.origin)??x.ORIGIN,n=((u=this._drawPresentation)==null?void 0:u.position)??this._position,r=((d=this._drawPresentation)==null?void 0:d.rotation)??this._rotation,s=((g=this._drawPresentation)==null?void 0:g.scaleFactors)??this._scaleFactors,a=new z().makeTranslation(-e.x,-e.y,-e.z),o=new z().makeScale(s.x,s.y,s.z),c=new Li().setFromAxisAngle(A.Z_AXIS,r),l=new z().makeRotationFromQuaternion(c),h=new z().makeTranslation(n.x,n.y,0);return new z().multiplyMatrices(h,l).multiply(o).multiply(a)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return he(t,e,this._position),this}subGetOsnapPoints(t,e,n,r,s,a){const o=a??new z;T.Insertion===t?r.push(this.getInsertionPoint(o)):s?this.subEntityGetOsnapPoints(t,e,n,r,s,o):this.collectBlockOsnapPoints(t,e,n,r,o)}transformBy(t){const e=new z().setFromExtrusionDirection(this._normal),n=new z().makeRotationZ(this._rotation),r=new z().multiplyMatrices(e,n),s=this._position.clone(),a=new x(this._scaleFactors.x,0,0).applyMatrix4(r).add(s),o=new x(0,this._scaleFactors.y,0).applyMatrix4(r).add(s),c=new x(0,0,this._scaleFactors.z).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new A(a).sub(s),h=new A(o).sub(s),u=new A(c).sub(s);let d=new A().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const f=new z().setFromExtrusionDirection(d).clone().invert(),p=l.clone().applyMatrix4(f);return this._position.copy(s),this._normal.copy(d),this._rotation=Math.atan2(p.y,p.x),this._scaleFactors.set(l.length(),h.length(),u.length()),this._attribs.forEach(m=>m.transformBy(t)),this}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:e=>{this.annotative=e}}},{name:"blockName",type:"string",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}},{name:"columnCount",type:"int",editable:!0,accessor:{get:()=>this.columnCount,set:e=>{this.columnCount=e}}},{name:"rowCount",type:"int",editable:!0,accessor:{get:()=>this.rowCount,set:e=>{this.rowCount=e}}},{name:"columnSpacing",type:"float",editable:!0,accessor:{get:()=>this.columnSpacing,set:e=>{this.columnSpacing=e}}},{name:"rowSpacing",type:"float",editable:!0,accessor:{get:()=>this.rowSpacing,set:e=>{this.rowSpacing=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(n=>{e.properties.push({name:n.tag,type:"string",editable:!n.isConst,skipTranslation:!0,accessor:{get:()=>n.textString,set:r=>{n.textString=r}}})})}return t}get geometricExtents(){const t=new H,e=this.drawableBlockTableRecord;if(e!=null){const r=e.newIterator();for(const s of r)t.union(s.geometricExtents)}const n=this.getFullInsertionTransform();return t.applyMatrix4(n),t}subGetIntersectCurves(){const t=this.drawableBlockTableRecord;if(t==null)return[];const e=[],n=Math.max(1,this.columnCount),r=Math.max(1,this.rowCount);for(let s=0;s<r;s++)for(let a=0;a<n;a++){const o=new z().makeTranslation(a*this.columnSpacing,s*this.rowSpacing,0),c=new z().multiplyMatrices(this.getFullInsertionTransform(),o);for(const l of t.newIterator())e.push(...mp(l.subGetIntersectCurves(),c))}return e}resolveAnnotativePresentation(){var c,l;const t=Wt(this),e=t.length>0||pe(this)||!!((c=this.blockTableRecord)!=null&&c.annotative);let n=this._position.clone(),r=this._rotation,s=this._scaleFactors.clone(),a,o;if(e&&t.length>0){a=He(t,(l=this.database)==null?void 0:l.cannoscale)??t.find(u=>u.isDefault)??t[0],o=Ge(t,a);const h=a.contextData;h instanceof Bi&&(n=h.position.clone(),r=h.rotation,s=new x(h.scaleX,h.scaleY,h.scaleZ))}else e&&(o=Gn(this).annotationScale);return{position:n,rotation:r,scaleFactors:s,preferred:a,annotationScale:o}}attachAnnotationScaleDrawInfo(t,e){if(!t||!this.annotative)return t;let n=e;n||(n=Gn(this).annotationScale),n||(n={drawnScaleFactor:1,supportedScaleFactors:[1],supportedScaleNames:[]});const r=t.userData??(t.userData={});return r.annotationScale=n,t}subWorldDraw(t){const e=this.resolveAnnotativePresentation();this._drawPresentation=e;try{return this.subWorldDrawWithPresentation(t,e)}finally{this._drawPresentation=void 0}}subWorldDrawWithPresentation(t,e){const n=this.drawableBlockTableRecord;if(n!=null){const r=[];this._attribs.forEach(c=>{if(!c.isInvisible){const l=c.worldDraw(t);l&&r.push(l)}});const s=Math.max(1,this.columnCount),a=Math.max(1,this.rowCount);if(s===1&&a===1)return this.attachAnnotationScaleDrawInfo(Tn.instance.draw(t,n,this.resolvedColor,r,!0,this.blockTransform,this._normal),e.annotationScale);const o=[];for(let c=0;c<a;c++)for(let l=0;l<s;l++){const h=new z().makeTranslation(l*this.columnSpacing,c*this.rowSpacing,0),u=new z().multiplyMatrices(this.blockTransform,h),d=Tn.instance.draw(t,n,this.resolvedColor,l===0&&c===0?r:[],!0,u,this._normal);d&&o.push(d)}return this.attachAnnotationScaleDrawInfo(t.group(o),e.annotationScale)}else return t.group([])}dxfOut(t,e=!1){super.dxfOut(t,e);let n=!1;for(const r of this.attributeIterator())n=!0,t.writeStart("ATTRIB"),r.dxfOut(t,e);return n&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}collectBlockOsnapPoints(t,e,n,r,s){const a=this.drawableBlockTableRecord;if(!a)return;const o=new z().multiplyMatrices(s,this.getFullInsertionTransform()),c=o.clone().invert(),l=new x(e).applyMatrix4(c),h=new x(n).applyMatrix4(c),u=[];for(const d of a.newIterator()){const g=[];if(d instanceof bi){d.subGetOsnapPoints(t,e,n,g,void 0,o);for(let f=0;f<g.length;f++)u.push(g[f]);continue}d.subGetOsnapPoints(t,l,h,g,void 0,o),g.forEach(f=>u.push(new x(f).applyMatrix4(o)))}if(u.length!==0)if(t===T.Nearest||t===T.Perpendicular||t===T.Tangent){const d=ye(e,u);d&&r.push(d)}else for(let d=0;d<u.length;d++)r.push(u[d])}subEntityGetOsnapPoints(t,e,n,r,s,a,o=new Set,c){const l=bx(s),h=l.objectId;let u=c===void 0?l.occurrence:c;if(h===this.objectId||o.has(this.objectId))return u;o.add(this.objectId);try{const d=this.drawableBlockTableRecord;if(d==null)return u;const g=new z().multiplyMatrices(a,this.getFullInsertionTransform()),f=g.clone().invert(),p=new x(e).applyMatrix4(f),m=new x(n).applyMatrix4(f);for(const y of d.newIterator()){if(y.objectId===h){if(u>0){u-=1;continue}const b=[];return y.subGetOsnapPoints(t,p,m,b,h,g),y instanceof bi?b.forEach(_=>{r.push(_.clone())}):b.forEach(_=>{r.push(new x(_).applyMatrix4(g))}),-1}if(y instanceof bi){const b=y.subEntityGetOsnapPoints(t,e,n,r,s,g,o,u);if(b<0)return-1;u=b}}return u}finally{o.delete(this.objectId)}}getInsertionPoint(t){var r;const e=((r=this.drawableBlockTableRecord)==null?void 0:r.origin)??x.ORIGIN,n=new z().multiplyMatrices(t,this.getFullInsertionTransform());return new x(e).applyMatrix4(n)}getFullInsertionTransform(){const t=new z().setFromExtrusionDirection(this._normal);return new z().multiplyMatrices(t,this.blockTransform)}dxfOutFields(t){super.dxfOutFields(t);const e=this.dxfTypeName==="INSERT"&&(this.columnCount>1||this.rowCount>1);return t.writeSubclassMarker(e?"AcDbMInsertBlock":"AcDbBlockReference"),this._attribs.size>0&&t.writeInt16(66,1),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),this.columnCount>1&&t.writeInt16(70,this.columnCount),this.rowCount>1&&t.writeInt16(71,this.rowCount),this.columnSpacing!==0&&t.writeDouble(44,this.columnSpacing),this.rowSpacing!==0&&t.writeDouble(45,this.rowSpacing),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbBlockReference")||t.atSubclassData("AcDbMInsertBlock");let e=this.position.x,n=this.position.y,r=this.position.z,s=this.scaleFactors.x,a=this.scaleFactors.y,o=this.scaleFactors.z,c=D.radToDeg(this.rotation),l=this.normal.x,h=this.normal.y,u=this.normal.z,d=this.columnCount,g=this.rowCount,f=this.columnSpacing,p=this.rowSpacing;const m=()=>{this.position=new x(e,n,r),this.scaleFactors=new x(s,a,o),this.rotation=D.degToRad(c),this.normal.copy(new A(l,h,u)),this.columnCount=d>0?d:1,this.rowCount=g>0?g:1,this.columnSpacing=f,this.rowSpacing=p};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const b=Number(y.code),_=Number(y.value);switch(b){case 10:e=_;break;case 20:n=_;break;case 30:r=_;break;case 2:this.blockName=String(y.value);break;case 41:s=_;break;case 42:a=_;break;case 43:o=_;break;case 44:f=_;break;case 45:p=_;break;case 50:c=_;break;case 66:break;case 70:d=_;break;case 71:g=_;break;case 210:l=_;break;case 220:h=_;break;case 230:u=_;break;case 100:return t.pushBackItem(y),m(),this}}return m(),this}};bi.typeName="BlockReference";let Qt=bi;const ni=new A,id=new A,rd=new x,sd=[0,Math.PI/2,Math.PI,Math.PI/2*3],no=class no extends Ot{constructor(t,e,n=A.Z_AXIS){if(super(),this._geoData=null,this._thickness=0,t!==void 0&&e!==void 0){const r=Mi(n);this._geo=new _t(t,e,0,Y,n,r)}}get dxfTypeName(){return"CIRCLE"}get _geo(){return this._geoData==null&&(this._geoData=new _t(new x,1,0,Y,A.Z_AXIS,A.X_AXIS)),this._geoData}set _geo(t){this._geoData=t}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"circArc",arc:this._geo.clone(),extendable:!1}]}get closed(){return this._geo.closed}get area(){return this._geo.area}subGetOsnapPoints(t,e,n,r){switch(t){case T.Center:case T.Centroid:r.push(this._geo.center);break;case T.Quadrant:r.push(this._geo.getPointAtAngle(0)),r.push(this._geo.getPointAtAngle(Math.PI/2)),r.push(this._geo.getPointAtAngle(Math.PI)),r.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case T.Nearest:{const s=this._geo.nearestPoint(e);r.push(s)}break;case T.Tangent:{const s=this._geo.tangentPoints(e);r.push(...s);break}case T.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=ye(e,s);a&&r.push(a);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}}]}]}}subGetGripPoints(){const t=new Array;t.push(this.center);for(const e of sd)t.push(this._geo.getPointAtAngle(e));return t}subMoveGripPointsAt(t,e){return Et(t,n=>{this.moveGripAt(n,e)}),this}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=Zt(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,e),t.writeDouble(40,this.radius),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbCircle");let e=0,n=0,r=0,s=this.radius,a=this.normal.x,o=this.normal.y,c=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code),u=Number(l.value);switch(h){case 10:e=u;break;case 20:n=u;break;case 30:r=u;break;case 40:s=u;break;case 39:this.thickness=u;break;case 210:a=u;break;case 220:o=u;break;case 230:c=u;break}}return this.applyDxfInGeometry(e,n,r,s,a,o,c),this}applyDxfInGeometry(t,e,n,r,s,a,o){ni.set(s,a,o),ni.lengthSq()>0&&ni.normalize(),Ws(id,ni),Ml(rd,{x:t,y:e,z:n},ni),this._geo=new _t(rd,r,0,Y,ni,id)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,n=this.radius;return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)>=n?1:-1}createOffsetCurve(t){const e=this._geo.offset(t);return e?new no(e.center,e.radius,e.normal):null}moveGripAt(t,e){switch(t){case 0:this.transformBy(z.makeTranslation(e));break;case 1:case 2:case 3:case 4:{const n=sd[t-1],r=this._geo.getPointAtAngle(n),a=new x(r.x+e.x,r.y+e.y,(r.z??0)+(e.z??0)).distanceTo(this.center);a>0&&(this.radius=a);break}}}};no.typeName="Circle";let fa=no;const or=[0,Math.PI/2,Math.PI,Math.PI/2*3],io=class io extends Ot{constructor(t,e,n,r,s,a,o){super(),this._geoData=null,t!==void 0&&e!==void 0&&n!==void 0&&r!==void 0&&s!==void 0&&a!==void 0&&o!==void 0&&(this._geo=new we(t,e,n,r,s,a,o))}get dxfTypeName(){return"ELLIPSE"}get _geo(){return this._geoData==null&&(this._geoData=new we(new x,A.Z_AXIS,A.X_AXIS,1,1,0,Math.PI*2)),this._geoData}set _geo(t){this._geoData=t}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxis(){return this._geo.majorAxis}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"ellipseArc",arc:this._geo.clone(),extendable:!this.closed}]}get closed(){return this._geo.closed||Math.abs(this._geo.deltaAngle-Y)<1e-10}get area(){return this._geo.area}subGetGripPoints(){const t=new Array;if(t.push(this._geo.center),this.closed)for(const e of or)t.push(this._geo.getPointAtAngle(e));else t.push(this._geo.startPoint),t.push(this._geo.endPoint);return t}subMoveGripPointsAt(t,e){return Et(t,n=>{this.moveGripAt(n,e)}),this}subGetOsnapPoints(t,e,n,r){switch(t){case T.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case T.MidPoint:this.closed||r.push(this._geo.midPoint);break;case T.Center:case T.Centroid:r.push(this._geo.center);break;case T.Quadrant:if(this.closed)for(const s of or)r.push(this._geo.getPointAtAngle(s));break;case T.Nearest:r.push(this._geo.nearestPoint(e));break;case T.Tangent:r.push(...this._geo.tangentPoints(e));break;case T.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=ye(e,s);a&&r.push(a);break}}}transformBy(t){return this._geo.transform(t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}}]}]}}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.ellipticalArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbEllipse"),t.writePoint3d(10,this.center);const e=this._geo.majorAxis,n=this.majorAxisRadius;return t.writePoint3d(11,{x:e.x*n,y:e.y*n,z:e.z*n}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbEllipse");let e=this.center.x,n=this.center.y,r=this.center.z,s=this.majorAxis.x*this.majorAxisRadius,a=this.majorAxis.y*this.majorAxisRadius,o=this.majorAxis.z*this.majorAxisRadius,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=this.majorAxisRadius>0?this.minorAxisRadius/this.majorAxisRadius:1,d=this.startAngle,g=this.endAngle;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const f=t.readItem();if(!f)break;const p=Number(f.code),m=Number(f.value);switch(p){case 10:e=m;break;case 20:n=m;break;case 30:r=m;break;case 11:s=m;break;case 21:a=m;break;case 31:o=m;break;case 210:c=m;break;case 220:l=m;break;case 230:h=m;break;case 40:u=m;break;case 41:d=m;break;case 42:g=m;break}}return this.applyDxfInGeometry(e,n,r,s,a,o,c,l,h,u,d,g),this}applyDxfInGeometry(t,e,n,r,s,a,o,c,l,h,u,d){const g=Math.hypot(r,s,a)||1;this._geo=new we({x:t,y:e,z:n},{x:o,y:c,z:l},{x:r,y:s,z:a},g,g*h,u,d)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,n=t.x-e.x,r=t.y-e.y,s=this.majorAxis,a=Math.hypot(s.x,s.y)||1,o=this.minorAxisRadius/this.majorAxisRadius*a||1,c=s.x/a,l=s.y/a,h=-l,u=c,d=n*c+r*l,g=n*h+r*u;return(d/a)**2+(g/o)**2>=1?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(z.makeTranslation(e));break;case 1:if(this.closed)this.moveQuadrantGripAt(or[0],e);else{const n=this._geo.startPoint;this._geo.startAngle=Ze(this._geo.center,{x:n.x+e.x,y:n.y+e.y,z:(n.z??0)+(e.z??0)},this._geo.normal)}break;case 2:if(this.closed)this.moveQuadrantGripAt(or[1],e);else{const n=this._geo.endPoint;this._geo.endAngle=Ze(this._geo.center,{x:n.x+e.x,y:n.y+e.y,z:(n.z??0)+(e.z??0)},this._geo.normal)}break;case 3:case 4:this.closed&&this.moveQuadrantGripAt(or[t-1],e);break}}moveQuadrantGripAt(t,e){const n=this._geo.getPointAtAngle(t),r=new x(n.x+e.x,n.y+e.y,(n.z??0)+(e.z??0)),s=this._geo.center,a=r.x-s.x,o=r.y-s.y,c=(r.z??0)-(s.z??0),l=t===0||t===Math.PI?this._geo.majorAxis:this._geo.minorAxis,h=a*l.x+o*l.y+c*l.z,u=Math.abs(h);u<=0||(t===0||t===Math.PI?this.majorAxisRadius=u:this.minorAxisRadius=u)}createOffsetCurve(t){const e=this._geo.offset(t);return e?new io(e.center,e.normal,e.majorAxis,e.majorAxisRadius,e.minorAxisRadius,e.startAngle,e.endAngle):null}};io.typeName="Ellipse";let pa=io;const Dh=class Dh extends et{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new x,new x,new x],this._edgeInvisibilities=0}getVertexAt(t){return t<0?this._vertices[0]:t>=this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[t]}setVertexAt(t,e){if(t<0&&this._vertices[0].copy(e),t>=3)return this._vertices.length===3&&this._vertices.push(new x),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}setEdgeVisibleAt(t,e){let n=0;for(let r=0;r<4;r++)this.isEdgeVisibleAt(r)||(n|=1<<r);e?n&=~(1<<t):n|=1<<t,this.setEdgeInvisibilities(n)}get properties(){const t=(e,n)=>({name:n,type:"boolean",editable:!0,accessor:{get:()=>this.isEdgeVisibleAt(e),set:r=>{this.setEdgeVisibleAt(e,r)}}});return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!1},{name:"y",type:"float",editable:!1},{name:"z",type:"float",editable:!1}]},accessor:{get:()=>{const e=this._vertices.length,n=[];for(let r=0;r<e;r++)n.push(this.getVertexAt(r));return n}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}}]},{groupName:"others",properties:[t(0,"edge0Visible"),t(1,"edge1Visible"),t(2,"edge2Visible"),t(3,"edge3Visible")]}]}}get geometricExtents(){return new H().setFromPoints(this._vertices)}subGetIntersectCurves(){return ee(this._vertices,!0)}get area(){const t=[this.getVertexAt(0),this.getVertexAt(1),this.getVertexAt(2)],e=this.getVertexAt(3);return(e.x!==t[2].x||e.y!==t[2].y||e.z!==t[2].z)&&t.push(e),Ag(t)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return er(t,e,this._vertices),this}subGetOsnapPoints(t,e,n,r){ko(this._vertices,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}get directBatchPrimitive(){return"lineSegments"}subWorldDraw(t){const e=this._vertices.length,n=new Float32Array(e*3),r=new Uint16Array(e*2);for(let s=0;s<e;s++)n[s*3]=this._vertices[s].x,n[s*3+1]=this._vertices[s].y,n[s*3+2]=this._vertices[s].z,this.isEdgeVisibleAt(s)&&(r[s*2]=s,r[s*2+1]=(s+1)%4);return t.lineSegments(n,3,r)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),n=this.getVertexAt(1),r=this.getVertexAt(2),s=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,n),t.writePoint3d(12,r),t.writePoint3d(13,s);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return t.writeInt16(70,a),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFace");const e=[0,1,2,3].map(r=>{const s=this._vertices[r];return s?{x:s.x,y:s.y,z:s.z}:{x:0,y:0,z:0}});let n=this._edgeInvisibilities;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 10:case 11:case 12:case 13:e[s-10].x=a;break;case 20:case 21:case 22:case 23:e[s-20].y=a;break;case 30:case 31:case 32:case 33:e[s-30].z=a;break;case 70:n=a;break}}return e.forEach((r,s)=>this.setVertexAt(s,r)),this._edgeInvisibilities=n,this}};Dh.typeName="Face";let ma=Dh;var Ht=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(Ht||{}),xt=(i=>(i[i.Scientific=1]="Scientific",i[i.Decimal=2]="Decimal",i[i.Engineering=3]="Engineering",i[i.Architectural=4]="Architectural",i[i.Fractional=5]="Fractional",i[i.WindowsDesktop=6]="WindowsDesktop",i))(xt||{}),mt=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(mt||{});function Kx(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function Zx(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}const E={ACADVER:"ACADVER",ANNOALLVISIBLE:"ANNOALLVISIBLE",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",AUPREC:"AUPREC",CANNOSCALE:"CANNOSCALE",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELTYPE:"CELTYPE",CELWEIGHT:"CELWEIGHT",CETRANSPARENCY:"CETRANSPARENCY",CLAYER:"CLAYER",CMLEADERSTYLE:"CMLEADERSTYLE",CMLSCALE:"CMLSCALE",CMLSTYLE:"CMLSTYLE",COLORTHEME:"COLORTHEME",COMPAREHATCH:"COMPAREHATCH",COMPAREPROPS:"COMPAREPROPS",COMPARERCMARGIN:"COMPARERCMARGIN",COMPARETEXT:"COMPARETEXT",COMPARETOLERANCE:"COMPARETOLERANCE",DYNMODE:"DYNMODE",DYNPROMPT:"DYNPROMPT",DWGNAME:"DWGNAME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",GRIPCOLOR:"GRIPCOLOR",GRIPHOT:"GRIPHOT",GRIPOBJLIMIT:"GRIPOBJLIMIT",GRIPS:"GRIPS",GRIPSIZE:"GRIPSIZE",HPANG:"HPANG",HPASSOC:"HPASSOC",HPBACKGROUNDCOLOR:"HPBACKGROUNDCOLOR",HPCOLOR:"HPCOLOR",HPDOUBLE:"HPDOUBLE",HPISLANDDETECTION:"HPISLANDDETECTION",HPLAYER:"HPLAYER",HPNAME:"HPNAME",HPSCALE:"HPSCALE",HPSEPARATE:"HPSEPARATE",HPTRANSPARENCY:"HPTRANSPARENCY",INSUNITS:"INSUNITS",LOGINNAME:"LOGINNAME",LTSCALE:"LTSCALE",LUNITS:"LUNITS",LUPREC:"LUPREC",LWDISPLAY:"LWDISPLAY",MEASUREMENT:"MEASUREMENT",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",MODELBKCOLOR:"MODELBKCOLOR",OSMODE:"OSMODE",ORTHOMODE:"ORTHOMODE",OPENPROF:"OPENPROF",PAPERBKCOLOR:"PAPERBKCOLOR",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",PICKSTYLE:"PICKSTYLE",GROUPDISPLAYMODE:"GROUPDISPLAYMODE",POLARADDANG:"POLARADDANG",POLARMODE:"POLARMODE",POLARANG:"POLARANG",SHORTCUTMENU:"SHORTCUTMENU",TEXTSTYLE:"TEXTSTYLE",TILEMODE:"TILEMODE",DIMSTYLE:"DIMSTYLE",UNITMODE:"UNITMODE"},Qx=Object.freeze(Object.values(E));function Jx(){try{const i=typeof process<"u"&&process.env?process.env:void 0;if(!i)return"";const t=i.USERNAME||i.USER||i.LOGNAME||"";return typeof t=="string"?t.trim():""}catch{return""}}const ro=class ro{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new vt},this.registerVar({name:E.ANNOALLVISIBLE,type:"boolean",isDbVar:!0,defaultValue:!0}),this.registerVar({name:E.ANGBASE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.ANGDIR,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.AUNITS,type:"number",isDbVar:!0,defaultValue:Ht.DecimalDegrees}),this.registerVar({name:E.AUPREC,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.CANNOSCALE,type:"string",isDbVar:!0,defaultValue:"1:1"}),this.registerVar({name:E.CECOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:E.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:E.CELTYPE,type:"string",isDbVar:!0,defaultValue:kt}),this.registerVar({name:E.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:exports.AcGiLineWeight.ByLayer}),this.registerVar({name:E.CETRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new St}),this.registerVar({name:E.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:E.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:en}),this.registerVar({name:E.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:E.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:tn}),this.registerVar({name:E.COLORTHEME,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.COMPAREHATCH,type:"number",isDbVar:!0,defaultValue:ra}),this.registerVar({name:E.COMPAREPROPS,type:"number",isDbVar:!1,defaultValue:Of}),this.registerVar({name:E.COMPARERCMARGIN,type:"number",isDbVar:!0,defaultValue:sa}),this.registerVar({name:E.COMPARETEXT,type:"number",isDbVar:!0,defaultValue:aa}),this.registerVar({name:E.COMPARETOLERANCE,type:"number",isDbVar:!0,defaultValue:oa}),this.registerVar({name:E.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:E.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:E.DWGNAME,type:"string",isDbVar:!0,readOnly:!0,defaultValue:"Drawing1.dwg"}),this.registerVar({name:E.GRIPCOLOR,type:"number",isDbVar:!1,defaultValue:Af}),this.registerVar({name:E.GRIPHOT,type:"number",isDbVar:!1,defaultValue:Sf}),this.registerVar({name:E.GRIPOBJLIMIT,type:"number",isDbVar:!1,defaultValue:100}),this.registerVar({name:E.GRIPS,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:E.GROUPDISPLAYMODE,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:E.GRIPSIZE,type:"number",isDbVar:!1,defaultValue:Pf}),this.registerVar({name:E.HPANG,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPASSOC,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPBACKGROUNDCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.None)}),this.registerVar({name:E.HPCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:E.HPDOUBLE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPISLANDDETECTION,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPLAYER,type:"string",isDbVar:!0,defaultValue:"."}),this.registerVar({name:E.HPNAME,type:"string",isDbVar:!1,defaultValue:xf}),this.registerVar({name:E.HPSCALE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPSEPARATE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPTRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new St}),this.registerVar({name:E.INSUNITS,type:"number",isDbVar:!0,defaultValue:mt.Millimeters}),this.registerVar({name:E.LOGINNAME,type:"string",isDbVar:!1,readOnly:!0,defaultValue:Jx()}),this.registerVar({name:E.LUNITS,type:"number",isDbVar:!0,defaultValue:xt.Decimal}),this.registerVar({name:E.LUPREC,type:"number",isDbVar:!0,defaultValue:4}),this.registerVar({name:E.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:E.MEASUREMENT,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:E.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:E.MODELBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(0,0,0),t})()}),this.registerVar({name:E.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.ORTHOMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.OPENPROF,type:"boolean",isDbVar:!1,defaultValue:!1}),this.registerVar({name:E.PAPERBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(255,255,255),t})()}),this.registerVar({name:E.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:E.PICKSTYLE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.POLARADDANG,type:"string",isDbVar:!1,defaultValue:""}),this.registerVar({name:E.POLARMODE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.POLARANG,type:"number",isDbVar:!1,defaultValue:90}),this.registerVar({name:E.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:gt}),this.registerVar({name:E.TILEMODE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:E.UNITMODE,type:"number",isDbVar:!0,defaultValue:0})}static instance(){return this._instance||(this._instance=new ro),this._instance}registerVar(t){const e=this.normalizeName(t.name);this.registry.set(e,{...t,name:e}),t.isDbVar||this.cache.set(e,t.defaultValue)}registerMany(t){t.forEach(e=>this.registerVar(e))}setLoginName(t){const e=this.normalizeName(E.LOGINNAME);this.cache.set(e,t.trim())}getVar(t,e){t=this.normalizeName(t);const n=this.getDescriptor(t);if(!n)throw new Error(`System variable ${t} not found!`);if(n.isDbVar)return e[t.toLowerCase()];if(this.cache.has(t))return this.cache.get(t)}getDefaultValue(t){t=this.normalizeName(t);const e=this.getDescriptor(t);if(!e)throw new Error(`System variable ${t} not found!`);return e.defaultValue}applyVarMutation(t,e,n,r,s){const a=this.normalizeName(t);if(this.hasValueChanged(e,n)){if(r.transactionManager.isRecording())r.transactionManager.recordSysvar(a,e);else if(r.transactionManager.strictMode&&!r.transactionManager.isApplyingUndoRedo())throw new Error(`Cannot change system variable ${a} outside an active transaction.`);s(),!r.transactionManager.isApplyingUndoRedo()&&!r.transactionManager.isRecording()&&this.events.sysVarChanged.dispatch({database:r,name:a,newVal:n,oldVal:e})}}setVar(t,e,n){t=this.normalizeName(t);const r=this.getDescriptor(t);if(r){if(r.readOnly)throw new Error(`System variable ${t} is read-only!`);const s=this.getVar(t,n);if(r.type==="transparency"){const a=this.parseTransparency(e);if(a==null||a.isInvalid)throw new Error("Invalid transparency value!");e=a}else if(r.type!=="string"&&(typeof e=="string"||e instanceof String)){if(r.type==="number"){const a=Number(e);if(Number.isNaN(a))throw new Error("Invalid number input!");e=a}else if(r.type==="boolean")e=this.parseBoolean(e);else if(r.type==="color"){const a=this.parseColorSysVar(t,e,n);if(a==null)throw new Error("Invalid color value!");e=a}}else r.type==="boolean"&&(e=!!e);if(t===E.GRIPCOLOR.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<Rc||a>Bc)throw new Error(`Invalid GRIPCOLOR value! Valid range is ${Rc} to ${Bc}.`);e=a}if(t===E.GRIPHOT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<Fc||a>zc)throw new Error(`Invalid GRIPHOT value! Valid range is ${Fc} to ${zc}.`);e=a}if(t===E.GRIPOBJLIMIT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>32767)throw new Error("Invalid GRIPOBJLIMIT value! Valid range is 0 to 32767.");e=a}if(t===E.GRIPS.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>2)throw new Error("Invalid GRIPS value! Valid range is 0 to 2.");e=a}if(t===E.GROUPDISPLAYMODE.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>2)throw new Error("Invalid GROUPDISPLAYMODE value! Valid range is 0 to 2.");e=a}if(t===E.PICKSTYLE.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>3)throw new Error("Invalid PICKSTYLE value! Valid range is 0 to 3.");e=a}if(t===E.GRIPSIZE.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<Xc||a>Yc)throw new Error(`Invalid GRIPSIZE value! Valid range is ${Xc} to ${Yc}.`);e=a}t===E.COMPAREHATCH.toLowerCase()&&(e=Oe("COMPAREHATCH",e,po,mo)),t===E.COMPAREPROPS.toLowerCase()&&(e=Oe("COMPAREPROPS",e,Df,Nf)),t===E.COMPARERCMARGIN.toLowerCase()&&(e=Oe("COMPARERCMARGIN",e,yo,bo)),t===E.COMPARETEXT.toLowerCase()&&(e=Oe("COMPARETEXT",e,_o,xo)),t===E.COMPARETOLERANCE.toLowerCase()&&(e=Oe("COMPARETOLERANCE",e,wo,vo)),r.isDbVar?this.applyVarMutation(t,s,e,n,()=>{n[t.toLowerCase()]=e}):this.applyVarMutation(t,s,e,n,()=>{this.cache.set(t,e)})}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(this.normalizeName(t))}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),n=new Set(["true","t","1","yes","y"]),r=new Set(["false","f","0","no","n"]);return n.has(e)?!0:(r.has(e),!1)}parseColorSysVar(t,e,n){const r=e.trim().toLowerCase();return t===E.HPCOLOR.toLowerCase()&&(r==="."||r==="use current")?n.cecolor.clone():t===E.HPBACKGROUNDCOLOR.toLowerCase()&&(r===""||r==="."||r==="none")?new X(exports.AcCmColorMethod.None):X.fromString(e)}parseTransparency(t){if(t instanceof St)return t;if(typeof t=="number")return St.deserialize(t);if(!(typeof t!="string"&&!(t instanceof String)))return St.fromString(String(t))}hasValueChanged(t,e){return t instanceof X&&e instanceof X||t instanceof St&&e instanceof St?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};ro._instance=null;let wt=ro;const bp="Load Database",ad=3e4,tw=12e4,ew=1024*1024;class qt extends Qd{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Al.getInstance().getEntry(bp),n=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",r?r.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-n),r}}class sh{constructor(t={}){this.config={useWorker:t.useWorker??!0,...t}}async read(t,e,n={}){const{minimumChunkSize:r=10,progress:s,timeout:a,sysVars:o}=n,c={name:bp,data:{total:0},format(){let d="";return Object.keys(this.data).forEach(g=>{g!=="total"&&(d+=`- ${g}: ${this.data[g]} ms
|
|
12
|
-
`)}),d+=`- total: ${this.data.total} ms`,d}};Al.getInstance().collect(c),this.progress=s;const l={value:0},h=new Jd;h.setCompleteCallback(()=>this.onFinished()),h.setErrorCallback(d=>this.onError(d)),h.addTask(new qt({stage:"START",step:1,progress:l,task:async d=>d},s)),h.addTask(new qt({stage:"PARSE",step:5,progress:l,task:async d=>await this.parse(d,a)},s)),h.addTask(new qt({stage:"LTYPE",step:1,progress:l,task:async d=>(this.processLineTypes(d.model,e),d)},s)),h.addTask(new qt({stage:"STYLE",step:1,progress:l,task:async d=>(this.processTextStyles(d.model,e),d)},s)),h.addTask(new qt({stage:"DIMSTYLE",step:1,progress:l,task:async d=>(this.processDimStyles(d.model,e),d)},s)),h.addTask(new qt({stage:"LAYER",step:1,progress:l,task:async d=>(this.processLayers(d.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),d)},s)),h.addTask(new qt({stage:"VPORT",step:1,progress:l,task:async d=>(this.processViewports(d.model,e),d)},s)),h.addTask(new qt({stage:"HEADER",step:1,progress:l,task:async d=>{if(this.processClasses(d.model,e),this.processHeader(d.model,e),o){const g=wt.instance();for(const[f,p]of Object.entries(o))g.setVar(f,p,e)}return d}},s)),h.addTask(new qt({stage:"BLOCK_RECORD",step:5,progress:l,task:async d=>(this.processBlockTables(d.model,e),d)},s)),h.addTask(new qt({stage:"OBJECT",step:5,progress:l,task:async d=>(this.processObjects(d.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),d)},s)),h.addTask(new qt({stage:"BLOCK",step:5,progress:l,task:async d=>(await this.processBlocks(d.model,e),d)},s)),h.addTask(new qt({stage:"ENTITY",step:100,progress:l,task:async d=>(await this.processEntities(d.model,e,r,l,s),d)},s)),h.addTask(new qt({stage:"END",step:0,progress:l,task:async d=>d},s));const u=Date.now();await h.run(t),c.data.total=Date.now()-u}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&this.progress(100,"END","END")}getParserWorkerTimeout(t,e){const n=e??this.config.timeout;if(n!=null)return n;const r=Math.ceil(t.byteLength/ew),s=ad+r*1e3;return Math.min(tw,Math.max(ad,s))}async parse(t,e){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processClasses(t,e){}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,n,r,s){throw new Error("Not impelemented yet!")}}class _p{constructor(t,e,n){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=n,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}async scheduleTask(t){await Zi(),await t()}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let n=0;const r=async()=>{const s=n,a=Math.min(n+this._chunkSize,this._count);await t(s,a),n=a,n<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class xp extends sh{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}async processEntities(t,e,n,r,s){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,c=new _p(o,100-r.value,n);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?a[h].type:"";for(let f=h;f<u;f++){const p=a[f];this.config.convertByEntityType&&p.type!==g&&(this.triggerEvents(l,d),d=[],g=p.type),d.push(p)}if(this.triggerEvents(l,d),s){let f=r.value+u/o*(100-r.value);f>100&&(f=100),await s(f,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const n=e.newIterator().toArray();this.triggerEvents(e,n)}}processHeader(){}processClasses(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const a of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const a of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const n=this._database.objects.mleaderStyle.newIterator();for(const a of n)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const r=this._database.objects.layerFilter.newIterator();for(const a of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const s=this._database.objects.layerIndex.newIterator();for(const a of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},n=[];for(const r of t)e[r.type]||(e[r.type]=[],n.push(r.type)),e[r.type].push(r);return n.flatMap(r=>e[r])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var wp=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(wp||{}),Fn=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(Fn||{}),ya=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(ya||{}),fi=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(fi||{}),vp=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(vp||{});const so=class so extends on{constructor(t,e){t=t||{},fe(t,so.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get annotative(){return Se(this)}set annotative(t){me(this,t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimtfill(){return this.getAttr("dimtfill")}set dimtfill(t){this.setAttr("dimtfill",t)}get dimtfillclr(){return this.getAttr("dimtfillclr")}set dimtfillclr(t){this.setAttr("dimtfillclr",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimtxtdirection(){return this.getAttr("dimtxtdirection")}set dimtxtdirection(t){this.setAttr("dimtxtdirection",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}dxfOut(...t){const[e,n=!1]=t;return e.writeHandle(105,this.objectId),this.dxfOutExtensionDictionary(e),e.writeObjectId(330,this.ownerId),this.dxfOutFields(e),n&&this.dxfOutXData(e),this}dxfOutFields(t){super.dxfOutFields(t);const e=this.database.tables.textStyleTable.getAt(this.dimtxsty),n=this.database.tables.blockTable.getAt(this.dimldrblk),r=this.database.tables.blockTable.getAt(this.dimblk),s=this.database.tables.blockTable.getAt(this.dimblk1),a=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(69,this.dimtfill),t.writeInt16(70,this.dimtfillclr),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeInt16(295,this.dimtxtdirection),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,n==null?void 0:n.objectId),t.writeObjectId(342,r==null?void 0:r.objectId),t.writeObjectId(343,s==null?void 0:s.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbDimStyleTableRecord");const e=s=>s===0?0:1;let n=-1,r=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code);if(a===100){t.pushBackItem(s);break}const o=Number(s.value);switch(a){case 2:this.name=String(s.value);break;case 70:r||n===69?this.dimtfillclr=o:r=!0;break;case 69:this.dimtfill=o===1||o===2?o:0;break;case 3:this.dimpost=String(s.value);break;case 4:this.dimapost=String(s.value);break;case 5:this.dimblk=String(s.value);break;case 6:this.dimblk1=String(s.value);break;case 7:this.dimblk2=String(s.value);break;case 40:this.dimscale=o;break;case 41:this.dimasz=o;break;case 42:this.dimexo=o;break;case 43:this.dimdli=o;break;case 44:this.dimexe=o;break;case 45:this.dimrnd=o;break;case 46:this.dimdle=o;break;case 47:this.dimtp=o;break;case 48:this.dimtm=o;break;case 140:this.dimtxt=o;break;case 141:this.dimcen=o;break;case 142:this.dimtsz=o;break;case 143:this.dimaltf=o;break;case 144:this.dimlfac=o;break;case 145:this.dimtvp=o;break;case 146:this.dimtfac=o;break;case 147:this.dimgap=o;break;case 148:this.dimaltrnd=o;break;case 71:this.dimtol=e(o);break;case 72:this.dimlim=e(o);break;case 73:this.dimtih=e(o);break;case 74:this.dimtoh=e(o);break;case 75:this.dimse1=e(o);break;case 76:this.dimse2=e(o);break;case 77:this.dimtad=o;break;case 78:this.dimzin=o;break;case 79:this.dimazin=o;break;case 170:this.dimalt=e(o);break;case 171:this.dimaltd=o;break;case 172:this.dimtofl=e(o);break;case 173:this.dimsah=e(o);break;case 174:this.dimtix=e(o);break;case 175:this.dimsoxd=e(o);break;case 176:this.dimclrd=o;break;case 177:this.dimclre=o;break;case 178:this.dimclrt=o;break;case 179:this.dimadec=o;break;case 270:this.dimunit=o;break;case 271:this.dimdec=o;break;case 272:this.dimtdec=o;break;case 273:this.dimaltu=o;break;case 274:this.dimalttd=o;break;case 275:this.dimaunit=o;break;case 276:this.dimfrac=o;break;case 277:this.dimlunit=o;break;case 278:this.dimdsep=typeof s.value=="string"?s.value:String.fromCharCode(o||46);break;case 279:this.dimtmove=o;break;case 280:this.dimjust=o;break;case 281:this.dimsd1=e(o);break;case 282:this.dimsd2=e(o);break;case 283:this.dimtolj=o;break;case 284:this.dimtzin=o;break;case 285:this.dimaltz=o;break;case 286:this.dimalttz=o;break;case 287:this.dimfit=o;break;case 288:this.dimupt=e(o);break;case 289:this.dimatfit=o;break;case 294:case 295:this.dimtxtdirection=e(o);break;case 340:this.dimtxsty=String(s.value);break;case 341:this.dimldrblk=String(s.value);break;case 342:this.dimblk=String(s.value);break;case 343:this.dimblk1=String(s.value);break;case 344:this.dimblk2=String(s.value);break;case 371:this.dimlwd=o;break;case 372:this.dimlwe=o;break}n=a}return this}};so.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimtfill:0,dimtfillclr:0,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimtxtdirection:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:gt,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Vt=so;function Ap(){return{color:new X,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new St,linetype:"Continuous",lineWeight:1,materialId:-1}}const nw=["name",...Object.keys(Ap())];class ls extends on{constructor(t,e){t=t||{},fe(t,Ap()),super(t,e)}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeCmColor(this.color),t.writeString(6,this.linetype||"Continuous"),t.writeInt16(290,this.isPlottable?1:0),t.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLayerTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=Number(e.value);break;case 62:{const r=Number(e.value);this.isOff=r<0,this.color.colorIndex=Math.abs(r);break}case 420:this.color.setRGBValue(Number(e.value));break;case 6:this.linetype=String(e.value);break;case 290:this.isPlottable=Number(e.value)!==0;break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=St.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}const iw=1,nc=2,rw=4;class vn extends on{constructor(t,e){t=t||{},fe(t,{standardFlag:0,description:"",totalPatternLength:0}),super(t,e)}get numDashes(){const t=this.getAttrWithoutException("pattern");return t?t.length:0}get patternLength(){return this.getAttr("totalPatternLength")}get comments(){return this.getAttr("description")}get linetype(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),description:this.getAttr("description"),totalPatternLength:this.getAttr("totalPatternLength"),pattern:this.getAttrWithoutException("pattern")}}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this.getAttr("pattern")[t].elementLength}toPreviewSvgString(t){const e=Math.max((t==null?void 0:t.width)??220,1),n=Math.max((t==null?void 0:t.height)??36,1),r=Math.min(Math.max((t==null?void 0:t.padding)??8,0),Math.floor(e/2)),s=Math.max((t==null?void 0:t.strokeWidth)??2,.5),a=(t==null?void 0:t.stroke)??"currentColor",o=this.escapeSvgAttribute(a),c=this.escapeSvgAttribute((t==null?void 0:t.textFill)??a),l=this.escapeSvgAttribute((t==null?void 0:t.fontFamily)??"sans-serif"),h=n/2,u=r,d=Math.max(e-r,u+1),g=d-u,f=this.getAttrWithoutException("pattern")??[];if(f.length===0||this.patternLength<=0||!f.some(F=>F.elementLength!==0))return this.buildSvgString({width:e,height:n,stroke:o,strokeWidth:s,textFill:c,fontFamily:l,lineSegments:[[u,d]],dots:[],texts:[],y:h});const p=f.some(F=>this.isComplexPatternElement(F)&&(F.elementTypeFlag&nc)!==0),m=Math.max((t==null?void 0:t.repeats)??(p?2:4),1),y=p?Math.min(Math.max(n*.55,Math.min(8,n*.85)),n*.8):0,b=Math.max(s*2,4),_=this.buildPreviewSegments(f,y,b),w=g/(this.patternLength*m),k=.5,P=Math.max(s*2,2),v=_.map(F=>F.kind==="dot"?P:F.kind==="text"?Math.max(F.units*w,F.minPx):Math.max(F.units*w,F.kind==="dash"?k:0)),S=v.reduce((F,q)=>F+q,0),I=S>0?g/(S*m):1,M=v.map(F=>F*I),O=[],N=[],nt=[];let W=u;for(;W<d-1e-6;){for(let F=0;F<_.length&&!(W>=d);F++){const q=_[F],L=M[F],$=Math.min(W+L,d);if(q.kind==="dash"&&$>W)O.push([W,$]);else if(q.kind==="dot")N.push(W);else if(q.kind==="text"&&q.label.trim().length>0){const ct=(W+$)*.5;nt.push({x:ct,y:h,text:q.label,fontSize:Math.min(q.fontSize*I,n*.8),rotationDeg:q.rotationDeg})}W=$}if(S<=0)break}return this.buildSvgString({width:e,height:n,stroke:o,strokeWidth:s,textFill:c,fontFamily:l,lineSegments:O,dots:N,texts:nt,y:h})}buildPreviewSegments(t,e,n){const r=[],s=new Set;for(let a=0;a<t.length;a++){if(s.has(a))continue;const o=t[a];if(this.isComplexPatternElement(o)){let c=0;for(;r.length>0&&r[r.length-1].kind==="gap";){const d=r.pop();c+=d.units}let l=c+Math.abs(o.elementLength);for(let d=a+1;d<t.length;d++){const g=t[d];if(this.isComplexPatternElement(g)||g.elementLength>=0)break;l+=Math.abs(g.elementLength),s.add(d)}const h=(o.elementTypeFlag&nc)!==0,u=h?this.resolveEmbeddedText(o.text):"";if(h&&u.trim().length>0){const d=this.estimateTextWidthPx(u,e)+n;r.push({kind:"text",units:Math.max(l,1e-6),minPx:d,label:u,fontSize:e,rotationDeg:this.previewTextRotationDeg(o)})}else l>0&&r.push({kind:"gap",units:l});continue}o.elementLength===0?r.push({kind:"dot"}):o.elementLength>0?r.push({kind:"dash",units:o.elementLength}):r.push({kind:"gap",units:Math.abs(o.elementLength)})}return r}estimateTextWidthPx(t,e){let n=0;for(const r of t)r===" "?n+=.33:/[iIlj1.'|]/.test(r)?n+=.35:/[mwMW@%]/.test(r)?n+=.85:n+=.62;return Math.max(n*e,e*.5)}isComplexPatternElement(t){const e=t.elementTypeFlag??0;return(e&nc)!==0?(t.text??"").length>0:(e&rw)!==0?t.shapeNumber!=null&&t.shapeNumber!==0:!1}resolveEmbeddedText(t){var o,c;const e=t??"";if(e.trim().length>0)return this.decodeAutoCadTextEscapes(e);const n=(this.comments??"").trim();if(!n)return this.decodeAutoCadTextEscapes(e);const r=(o=n.split(/\s+-\s+/)[0])==null?void 0:o.trim();if(r&&r!==n)return this.decodeAutoCadTextEscapes(r);const s=n.match(/-{2,}\s*([^-]+?)\s*-{2,}/);if((c=s==null?void 0:s[1])!=null&&c.trim())return this.decodeAutoCadTextEscapes(s[1].trim());const a=(this.name??"").trim();return a&&n.length>a.length+2?this.decodeAutoCadTextEscapes(a):this.decodeAutoCadTextEscapes(r||e)}decodeAutoCadTextEscapes(t){return t.replace(/%%(\d{1,3}|[cCdDpP%])/g,(e,n)=>{if(n==="%")return"%";if(n==="c"||n==="C")return"Ø";if(n==="d"||n==="D")return"°";if(n==="p"||n==="P")return"±";const r=Number.parseInt(n,10);return Number.isFinite(r)&&r>=0&&r<=255?String.fromCharCode(r):`%%${n}`})}previewTextRotationDeg(t){const e=t.rotation??0;return(((t.elementTypeFlag??0)&iw)!==0?e:this.uprightLinetypeAngle(e))*180/Math.PI}uprightLinetypeAngle(t){const e=Math.PI*2;let n=((t+Math.PI)%e+e)%e-Math.PI;return(n>Math.PI/2||n<-Math.PI/2)&&(n+=Math.PI,n>Math.PI&&(n-=e)),n}buildSvgString(t){const{width:e,height:n,stroke:r,strokeWidth:s,textFill:a,fontFamily:o,lineSegments:c,dots:l,texts:h,y:u}=t,d=c.map(([p,m])=>`<line x1="${p.toFixed(2)}" y1="${u.toFixed(2)}" x2="${m.toFixed(2)}" y2="${u.toFixed(2)}" stroke="${r}" stroke-width="${s.toFixed(2)}" stroke-linecap="round" />`).join(""),g=l.map(p=>`<circle cx="${p.toFixed(2)}" cy="${u.toFixed(2)}" r="${(s/2).toFixed(2)}" fill="${r}" />`).join(""),f=h.map(p=>{const m=Math.abs(p.rotationDeg)>1e-6?` transform="rotate(${p.rotationDeg.toFixed(2)} ${p.x.toFixed(2)} ${p.y.toFixed(2)})"`:"";return`<text x="${p.x.toFixed(2)}" y="${p.y.toFixed(2)}" fill="${a}" font-family="${o}" font-size="${p.fontSize.toFixed(2)}" text-anchor="middle" dominant-baseline="middle"${m}>${this.escapeSvgText(p.text)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${n}" viewBox="0 0 ${e} ${n}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${d}${g}${f}</svg>`}escapeSvgAttribute(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}escapeSvgText(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeString(3,this.comments),t.writeInt16(72,65),t.writeInt16(73,this.numDashes),t.writeDouble(40,this.patternLength);for(const e of this.getAttrWithoutException("pattern")??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag),e.elementTypeFlag!==0&&(e.shapeNumber!=null&&t.writeInt16(75,e.shapeNumber),e.styleObjectId&&t.writeObjectId(340,e.styleObjectId),e.scale!=null&&t.writeDouble(46,e.scale),e.rotation!=null&&t.writeDouble(50,e.rotation),e.offsetX!=null&&t.writeDouble(44,e.offsetX),e.offsetY!=null&&t.writeDouble(45,e.offsetY),e.text&&t.writeString(9,e.text));return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLinetypeTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const n=t.readItem();if(!n)break;const r=Number(n.code);if(r===100){t.pushBackItem(n);break}switch(r){case 2:this.name=String(n.value);break;case 70:this.setAttr("standardFlag",Number(n.value));break;case 3:this.setAttr("description",String(n.value));break;case 72:break;case 73:break;case 40:this.setAttr("totalPatternLength",Number(n.value));break;case 49:e.push({elementLength:Number(n.value),elementTypeFlag:0});break;case 74:e.length>0&&(e[e.length-1].elementTypeFlag=Number(n.value));break;case 75:e.length>0&&(e[e.length-1].shapeNumber=Number(n.value));break;case 340:e.length>0&&(e[e.length-1].styleObjectId=String(n.value));break;case 46:e.length>0&&(e[e.length-1].scale=Number(n.value));break;case 50:e.length>0&&(e[e.length-1].rotation=Number(n.value));break;case 44:e.length>0&&(e[e.length-1].offsetX=Number(n.value));break;case 45:e.length>0&&(e[e.length-1].offsetY=Number(n.value));break;case 9:e.length>0&&(e[e.length-1].text=String(n.value));break}}return this.setAttr("pattern",e),this}}class _r extends on{constructor(t){typeof t=="string"&&(t={name:t}),super(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbRegAppTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break}}return this}}class Eo extends on{constructor(t,e){t=t||{},fe(t,{standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:0,font:"",bigFont:""}),super(t,e),this.setAttr("font",this.getFileNameWithoutExtension(this.getAttr("font")||this.getAttrWithoutException("extendedFont")||this.name))}get obliquingAngle(){return this.getAttr("obliqueAngle")}set obliquingAngle(t){this.setAttr("obliqueAngle",t)}get annotative(){return Se(this)}set annotative(t){me(this,t)}get priorSize(){return this.getAttr("lastHeight")}set priorSize(t){this.setAttr("lastHeight",t)}get textSize(){return this.getAttr("fixedTextHeight")}set textSize(t){this.setAttr("fixedTextHeight",t)}get xScale(){return this.getAttr("widthFactor")}set xScale(t){this.setAttr("widthFactor",t)}get isVertical(){return(this.getAttr("standardFlag")&4)===4}set isVertical(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|4:e&-5)}get isShapeFile(){return(this.getAttr("standardFlag")&1)===1}set isShapeFile(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|1:e&-2)}get fileName(){return this.getAttr("font")}set fileName(t){this.setAttr("font",t)}get bigFontFileName(){return this.getAttr("bigFont")}set bigFontFileName(t){this.setAttr("bigFont",t)}get textStyle(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),fixedTextHeight:this.getAttr("fixedTextHeight"),widthFactor:this.getAttr("widthFactor"),obliqueAngle:this.getAttr("obliqueAngle"),textGenerationFlag:this.getAttr("textGenerationFlag"),lastHeight:this.getAttr("lastHeight"),font:this.getAttr("font"),bigFont:this.getAttr("bigFont"),extendedFont:this.getAttrWithoutException("extendedFont")}}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t}get dxfFontFileName(){var e;const t=((e=this.fileName)==null?void 0:e.trim())??"";return!t||!this.isShapeFile||/\.[^./\\]+$/i.test(t)?t:`${t}.shx`}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.getAttr("textGenerationFlag")),t.writeDouble(42,this.priorSize),t.writeString(3,this.dxfFontFileName),t.writeString(4,this.bigFontFileName),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbTextStyleTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break;case 70:this.setAttr("standardFlag",Number(e.value));break;case 40:this.textSize=Number(e.value);break;case 41:this.xScale=Number(e.value);break;case 50:this.obliquingAngle=Number(e.value);break;case 71:this.setAttr("textGenerationFlag",Number(e.value));break;case 42:this.priorSize=Number(e.value);break;case 3:this.fileName=this.getFileNameWithoutExtension(String(e.value));break;case 4:this.bigFontFileName=String(e.value);break}}return this}dxfInXData(t){super.dxfInXData(t),this.applyExtendedFontFromXData()}applyExtendedFontFromXData(){const t=this.getXData("ACAD");if(t){for(const n of t)if(Number(n.code)===1e3&&n.value!=null){const r=String(n.value).trim();if(r){this.setAttr("extendedFont",r);break}}}if(!(this.getAttr("font")??"").trim()){const n=this.getAttrWithoutException("extendedFont")||this.name||"";n&&(this.fileName=this.getFileNameWithoutExtension(n))}}}class Sp extends on{constructor(t,e){t=t||{},fe(t,{standardFlags:0,origin:new x(0,0,0),xAxis:new x(1,0,0),yAxis:new x(0,1,0),isOrthographic:!1,elevation:0}),super(t,e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get origin(){return this.getAttr("origin")}set origin(t){this.setAttr("origin",t.clone())}get xAxis(){return this.getAttr("xAxis")}set xAxis(t){this.setAttr("xAxis",t.clone())}get yAxis(){return this.getAttr("yAxis")}set yAxis(t){this.setAttr("yAxis",t.clone())}get isOrthographic(){return this.getAttr("isOrthographic")}set isOrthographic(t){this.setAttr("isOrthographic",t)}get elevation(){return this.getAttr("elevation")}set elevation(t){this.setAttr("elevation",t)}get baseUcsId(){return this.getAttrWithoutException("baseUcsId")}set baseUcsId(t){this.setAttr("baseUcsId",t)}get orthographicType(){return this.getAttrWithoutException("orthographicType")}set orthographicType(t){this.setAttr("orthographicType",t)}get orthographicOrigin(){return this.getAttrWithoutException("orthographicOrigin")}set orthographicOrigin(t){this.setAttr("orthographicOrigin",t==null?void 0:t.clone())}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbUCSTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writePoint3d(10,this.origin),t.writePoint3d(11,this.xAxis),t.writePoint3d(12,this.yAxis),t.writeDouble(146,this.elevation),t.writeInt16(79,this.isOrthographic?1:0),this.isOrthographic&&t.writeObjectId(346,this.baseUcsId),this.orthographicType!=null&&this.orthographicOrigin&&(t.writeInt16(71,this.orthographicType),t.writePoint3d(13,this.orthographicOrigin)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbUCSTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}const r=Number(e.value);switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 10:this.origin.x=r;break;case 20:this.origin.y=r;break;case 30:this.origin.z=r;break;case 11:this.xAxis.x=r;break;case 21:this.xAxis.y=r;break;case 31:this.xAxis.z=r;break;case 12:this.yAxis.x=r;break;case 22:this.yAxis.y=r;break;case 32:this.yAxis.z=r;break;case 79:this.isOrthographic=r!==0;break;case 146:this.elevation=r;break;case 346:this.baseUcsId=String(e.value);break;case 71:this.orthographicType=r;break;case 13:this.orthographicOrigin=this.orthographicOrigin??new x,this.orthographicOrigin.x=r;break;case 23:this.orthographicOrigin&&(this.orthographicOrigin.y=r);break;case 33:this.orthographicOrigin&&(this.orthographicOrigin.z=r);break}}return this}}const sw=()=>({center:new C,viewDirectionFromTarget:new x(0,0,1),viewTarget:new x(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:exports.AcGiRenderMode.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new x(0,0,0),ucsXAxis:new x(1,0,0),ucsYAxis:new x(0,1,0),orthographicType:exports.AcGiOrthographicType.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:exports.AcGiDefaultLightingType.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0,aspectRatio:void 0});class ah extends on{constructor(t,e){t=t||{},fe(t,{gsView:sw()}),super(t,e)}get gsView(){return this.getAttr("gsView")}get centerPoint(){return this.gsView.center}set centerPoint(t){this.gsView.center.copy(t)}get viewDirectionFromTarget(){return this.gsView.viewDirectionFromTarget}set viewDirectionFromTarget(t){this.gsView.viewDirectionFromTarget.copy(t)}get viewTarget(){return this.gsView.viewTarget}set viewTarget(t){this.gsView.viewTarget.copy(t)}get viewHeight(){return this.gsView.viewHeight}set viewHeight(t){this.gsView.viewHeight=t}get viewTwistAngle(){return this.gsView.viewTwistAngle}set viewTwistAngle(t){this.gsView.viewTwistAngle=t}get lensLength(){return this.gsView.lensLength}set lensLength(t){this.gsView.lensLength=t}get frontClippingPlane(){return this.gsView.frontClippingPlane}set frontClippingPlane(t){this.gsView.frontClippingPlane=t}get backClippingPlane(){return this.gsView.backClippingPlane}set backClippingPlane(t){this.gsView.backClippingPlane=t}get renderMode(){return this.gsView.renderMode}set renderMode(t){this.gsView.renderMode=t}get viewMode(){return this.gsView.viewMode}set viewMode(t){this.gsView.viewMode=t}get ucsIconSetting(){return this.gsView.ucsIconSetting}set ucsIconSetting(t){this.gsView.ucsIconSetting=t}get ucsOrigin(){return this.gsView.ucsOrigin}set ucsOrigin(t){this.gsView.ucsOrigin.copy(t)}get ucsXAxis(){return this.gsView.ucsXAxis}set ucsXAxis(t){this.gsView.ucsXAxis.copy(t)}get ucsYAxis(){return this.gsView.ucsYAxis}set ucsYAxis(t){this.gsView.ucsYAxis.copy(t)}get orthographicType(){return this.gsView.orthographicType}set orthographicType(t){this.gsView.orthographicType=t}get shadePlotSetting(){return this.gsView.shadePlotSetting}set shadePlotSetting(t){this.gsView.shadePlotSetting=t}get shadePlotObjectId(){return this.gsView.shadePlotObjectId}set shadePlotObjectId(t){this.gsView.shadePlotObjectId=t}get visualStyleObjectId(){return this.gsView.visualStyleObjectId}set visualStyleObjectId(t){this.gsView.visualStyleObjectId=t}get isDefaultLightingOn(){return this.gsView.isDefaultLightingOn}set isDefaultLightingOn(t){this.gsView.isDefaultLightingOn=t}get defaultLightingType(){return this.gsView.defaultLightingType}set defaultLightingType(t){this.gsView.defaultLightingType=t}get brightness(){return this.gsView.brightness}set brightness(t){this.gsView.brightness=t}get contrast(){return this.gsView.contrast}set contrast(t){this.gsView.contrast=t}get ambientColor(){return this.gsView.ambientColor}set ambientColor(t){this.gsView.ambientColor=t}get aspectRatio(){return this.gsView.aspectRatio}set aspectRatio(t){this.gsView.aspectRatio=t}}const od=2,aw=.45,ow=1e5;function cw(i){var n;const t=i,e=t.aspectRatio??((n=t.gsView)==null?void 0:n.aspectRatio);return Number.isFinite(e)?e:void 0}function lw(i,t){if(Number.isFinite(t)&&t>0)return t;const e=cw(i);return e!=null&&e>0?e:1}function hw(i,t){const e=Math.max(i.min.x,t.min.x),n=Math.max(i.min.y,t.min.y),r=Math.min(i.max.x,t.max.x),s=Math.min(i.max.y,t.max.y);return e>=r||n>=s?0:(r-e)*(s-n)}function cd(i){return{x:(i.min.x+i.max.x)/2,y:(i.min.y+i.max.y)/2}}function uw(i){if(!i||i.isEmpty())return!1;const t=i.max.x-i.min.x,e=i.max.y-i.min.y;return t>0&&e>0}class An extends ah{static isActiveVportName(t){return t.toLowerCase()===Ri.toLowerCase()}constructor(t,e){t=t||{},fe(t,{circleSides:100,lowerLeftCorner:new C(0,0),upperRightCorner:new C(1,1),snapBase:new C(0,0),snapAngle:0,snapSpacing:new C(0,0),standardFlag:0,gridSpacing:new C,gridMajor:10,ucsElevation:0}),super(t,e)}get circleSides(){return this.getAttr("circleSides")}set circleSides(t){this.setAttr("circleSides",t)}get center(){return this.centerPoint}set center(t){this.centerPoint=t}get lowerLeftCorner(){return this.getAttr("lowerLeftCorner")}set lowerLeftCorner(t){this.getAttr("lowerLeftCorner").copy(t)}get upperRightCorner(){return this.getAttr("upperRightCorner")}set upperRightCorner(t){this.getAttr("upperRightCorner").copy(t)}get snapBase(){return this.getAttr("snapBase")}set snapBase(t){this.getAttr("snapBase").copy(t)}get snapAngle(){return this.getAttr("snapAngle")}set snapAngle(t){this.setAttr("snapAngle",t)}get snapIncrements(){return this.getAttr("snapSpacing")}set snapIncrements(t){this.getAttr("snapSpacing").copy(t)}get gridMajor(){return this.getAttr("gridMajor")}set gridMajor(t){this.setAttr("gridMajor",t)}get gridIncrements(){return this.getAttr("gridSpacing")}set gridIncrements(t){this.getAttr("gridSpacing").copy(t)}get standardFlag(){return this.getAttr("standardFlag")}set standardFlag(t){this.setAttr("standardFlag",t)}get snapEnabled(){return!!(this.standardFlag&256)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}modelViewBox(t){const e=this.centerPoint,n=this.viewHeight;if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(n)||n<=0)return;const r=this.viewTwistAngle;let s=e.x,a=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,a=e.x*g+e.y*d}const o=this.viewTarget;o&&Number.isFinite(o.x)&&Number.isFinite(o.y)&&(s+=o.x,a+=o.y);const c=lw(this,t),l=n*c,h=n/2,u=l/2;return new Ct().expandByPoint({x:s-u,y:a-h}).expandByPoint({x:s+u,y:a+h})}static isModelViewBoxUsable(t,e){if(t.isEmpty()||e.isEmpty())return!1;const n=t.max.x-t.min.x,r=t.max.y-t.min.y,s=e.max.x-e.min.x,a=e.max.y-e.min.y;if(n<=0||r<=0||s<=0||a<=0||n>s*od||r>a*od)return!1;const o=Math.max(s,a)*aw,c=cd(t),l=cd(e);if(Math.hypot(c.x-l.x,c.y-l.y)>o)return!1;const u=n*r,d=hw(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const n=this.modelViewBox(t);if(!(!n||!An.isModelViewBoxStructurallyValid(n))){if(uw(e)){if(!An.isModelViewBoxUsable(n,e))return}else if(!An.isModelViewBoxPlausibleWithoutExtents(n))return;return n}}static isModelViewBoxStructurallyValid(t){if(t.isEmpty())return!1;const e=t.max.x-t.min.x,n=t.max.y-t.min.y;return Number.isFinite(e)&&Number.isFinite(n)&&e>0&&n>0}static isModelViewBoxPlausibleWithoutExtents(t){const e=t.max.x-t.min.x,n=t.max.y-t.min.y;return Math.max(e,n)<=ow}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(40,this.gsView.viewHeight),this.gsView.aspectRatio!=null&&Number.isFinite(this.gsView.aspectRatio)&&t.writeDouble(41,this.gsView.aspectRatio),t.writePoint2d(10,this.lowerLeftCorner),t.writePoint2d(11,this.upperRightCorner),t.writePoint2d(12,this.center),t.writePoint2d(13,this.snapBase),t.writePoint2d(14,this.snapIncrements),t.writePoint2d(15,this.gridIncrements),t.writeInt16(70,this.standardFlag),t.writeInt16(71,this.circleSides),t.writeDouble(42,this.gsView.lensLength),t.writePoint3d(16,this.gsView.viewDirectionFromTarget),t.writePoint3d(17,this.gsView.viewTarget),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.gsView.viewTwistAngle),t.capabilities.supportsVportExtendedFields&&(t.writeInt16(61,this.gridMajor),t.writeDouble(146,this.ucsElevation),t.writeInt16(170,this.shadePlotSetting),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLightingOn?1:0),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(333,this.shadePlotObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewportTableRecord");const e=[...this.gsView.frozenLayers??[]];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const n=t.readItem();if(!n)break;const r=Number(n.code);if(r===100){t.pushBackItem(n);break}const s=Number(n.value);switch(r){case 2:this.name=String(n.value);break;case 1:this.gsView.styleSheet=String(n.value);break;case 10:this.lowerLeftCorner.x=s;break;case 20:this.lowerLeftCorner.y=s;break;case 11:this.upperRightCorner.x=s;break;case 21:this.upperRightCorner.y=s;break;case 12:this.center.x=s,this.gsView.center.x=s;break;case 22:this.center.y=s,this.gsView.center.y=s;break;case 13:this.snapBase.x=s;break;case 23:this.snapBase.y=s;break;case 14:this.snapIncrements.x=s;break;case 24:this.snapIncrements.y=s;break;case 15:this.gridIncrements.x=s;break;case 25:this.gridIncrements.y=s;break;case 16:this.gsView.viewDirectionFromTarget.x=s;break;case 26:this.gsView.viewDirectionFromTarget.y=s;break;case 36:this.gsView.viewDirectionFromTarget.z=s;break;case 17:this.gsView.viewTarget.x=s;break;case 27:this.gsView.viewTarget.y=s;break;case 37:this.gsView.viewTarget.z=s;break;case 40:case 45:this.gsView.viewHeight=s;break;case 41:Number.isFinite(s)&&s>0&&(this.gsView.aspectRatio=s);break;case 42:this.gsView.lensLength=s;break;case 43:this.gsView.frontClippingPlane=s;break;case 44:this.gsView.backClippingPlane=s;break;case 50:this.snapAngle=s;break;case 51:this.gsView.viewTwistAngle=s;break;case 61:this.gridMajor=s;break;case 70:this.standardFlag=s;break;case 71:s>=1&&s<=2e4&&(this.circleSides=s),this.gsView.viewMode=s;break;case 72:this.circleSides=s;break;case 74:this.gsView.ucsIconSetting=s;break;case 110:this.gsView.ucsOrigin.x=s;break;case 120:this.gsView.ucsOrigin.y=s;break;case 130:this.gsView.ucsOrigin.z=s;break;case 111:this.gsView.ucsXAxis.x=s;break;case 121:this.gsView.ucsXAxis.y=s;break;case 131:this.gsView.ucsXAxis.z=s;break;case 112:this.gsView.ucsYAxis.x=s;break;case 122:this.gsView.ucsYAxis.y=s;break;case 132:this.gsView.ucsYAxis.z=s;break;case 79:this.gsView.orthographicType=s;break;case 281:this.gsView.renderMode=s;break;case 331:case 441:e.push(String(n.value));break;case 332:this.backgroundObjectId=String(n.value);break;case 146:this.ucsElevation=s;break;case 170:this.shadePlotSetting=s;break;case 282:this.defaultLightingType=s;break;case 292:this.isDefaultLightingOn=s!==0;break;case 333:this.shadePlotObjectId=String(n.value);break;case 348:this.gsView.visualStyleObjectId=String(n.value);break}}return this.gsView.frozenLayers=e,this}}class Pp extends ah{constructor(t,e){t=t||{};const n=t.viewWidth!==void 0;fe(t,{standardFlags:0,ucsAssociated:!1,cameraPlottable:!1,ucsElevation:0}),super(t,e),n||(this.viewWidth=this.viewHeight)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get viewWidth(){return this.getAttr("viewWidth")}set viewWidth(t){this.setAttr("viewWidth",t)}get ucsAssociated(){return this.getAttr("ucsAssociated")}set ucsAssociated(t){this.setAttr("ucsAssociated",t)}get cameraPlottable(){return this.getAttr("cameraPlottable")}set cameraPlottable(t){this.setAttr("cameraPlottable",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}get ucsObjectId(){return this.getAttrWithoutException("ucsObjectId")}set ucsObjectId(t){this.setAttr("ucsObjectId",t)}get ucsBaseObjectId(){return this.getAttrWithoutException("ucsBaseObjectId")}set ucsBaseObjectId(t){this.setAttr("ucsBaseObjectId",t)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get liveSectionObjectId(){return this.getAttrWithoutException("liveSectionObjectId")}set liveSectionObjectId(t){this.setAttr("liveSectionObjectId",t)}get sunObjectId(){return this.getAttrWithoutException("sunObjectId")}set sunObjectId(t){this.setAttr("sunObjectId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeDouble(40,this.gsView.viewHeight),t.writePoint2d(10,this.centerPoint),t.writeDouble(41,this.viewWidth),t.writePoint3d(11,this.gsView.viewDirectionFromTarget),t.writePoint3d(12,this.gsView.viewTarget),t.writeDouble(42,this.gsView.lensLength),t.writeDouble(43,this.gsView.frontClippingPlane),t.writeDouble(44,this.gsView.backClippingPlane),t.writeAngle(50,this.gsView.viewTwistAngle),t.writeInt16(71,this.gsView.viewMode),t.writeInt16(281,this.gsView.renderMode),t.writeInt16(72,this.ucsAssociated?1:0),t.writeInt16(73,this.cameraPlottable?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(334,this.liveSectionObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId),t.writeObjectId(361,this.sunObjectId),this.ucsAssociated&&(t.writePoint3d(110,this.gsView.ucsOrigin),t.writePoint3d(111,this.gsView.ucsXAxis),t.writePoint3d(112,this.gsView.ucsYAxis),t.writeInt16(79,this.gsView.orthographicType),t.writeDouble(146,this.ucsElevation),t.writeObjectId(345,this.ucsObjectId),t.writeObjectId(346,this.ucsBaseObjectId)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}const r=Number(e.value);switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 40:this.gsView.viewHeight=r;break;case 10:this.centerPoint.x=r;break;case 20:this.centerPoint.y=r;break;case 41:this.viewWidth=r;break;case 11:this.gsView.viewDirectionFromTarget.x=r;break;case 21:this.gsView.viewDirectionFromTarget.y=r;break;case 31:this.gsView.viewDirectionFromTarget.z=r;break;case 12:this.gsView.viewTarget.x=r;break;case 22:this.gsView.viewTarget.y=r;break;case 32:this.gsView.viewTarget.z=r;break;case 42:this.gsView.lensLength=r;break;case 43:this.gsView.frontClippingPlane=r;break;case 44:this.gsView.backClippingPlane=r;break;case 50:this.gsView.viewTwistAngle=r*Math.PI/180;break;case 71:this.gsView.viewMode=r;break;case 281:this.gsView.renderMode=r;break;case 72:this.ucsAssociated=r!==0;break;case 73:this.cameraPlottable=r!==0;break;case 332:this.backgroundObjectId=String(e.value);break;case 334:this.liveSectionObjectId=String(e.value);break;case 348:this.gsView.visualStyleObjectId=String(e.value);break;case 361:this.sunObjectId=String(e.value);break;case 110:this.gsView.ucsOrigin.x=r;break;case 120:this.gsView.ucsOrigin.y=r;break;case 130:this.gsView.ucsOrigin.z=r;break;case 111:this.gsView.ucsXAxis.x=r;break;case 121:this.gsView.ucsXAxis.y=r;break;case 131:this.gsView.ucsXAxis.z=r;break;case 112:this.gsView.ucsYAxis.x=r;break;case 122:this.gsView.ucsYAxis.y=r;break;case 132:this.gsView.ucsYAxis.z=r;break;case 79:this.gsView.orthographicType=r;break;case 146:this.ucsElevation=r;break;case 345:this.ucsObjectId=String(e.value);break;case 346:this.ucsBaseObjectId=String(e.value);break}}return this}}const Hi=192,Gi=193,ir=194,hs=195,oh=200;function ic(i){if(i.isByBlock)return Gi<<24>>0;if(i.isByLayer)return Hi<<24>>0;const t=i.colorIndex;if(t!=null&&t>0&&t<256)return(hs<<24|t&255)>>0;const e=i.RGB;return e!=null?(ir<<24|e&16777215)>>0:Gi<<24>>0}function Yt(i){const t=new X(exports.AcCmColorMethod.ByBlock);if(!Number.isFinite(i))return t;switch(i>>>24&255){case Hi:t.setByLayer();break;case Gi:case oh:t.setByBlock();break;case hs:t.colorIndex=i&255;break;case ir:t.setRGBValue(i&16777215);break;default:i===256?t.setByLayer():i===0?t.setByBlock():i>0&&i<256&&(t.colorIndex=i);break}return t}function Ur(i){if(i==null)return new X(exports.AcCmColorMethod.ByBlock);if(typeof i=="number")return Yt(i);if(typeof i=="object"){const t=i,e=t.method!=null&&t.method!==0?t.method&255:typeof t.rgb=="number"?t.rgb>>>24&255:0;if(typeof t.rgb=="number"&&Number.isFinite(t.rgb)&&e>=Hi&&e<=oh&&(t.rgb>>>24&255)===e)return Yt(t.rgb>>0);if(e===Hi||t.index===256){const n=new X;return n.setByLayer(),n}if(e===Gi||t.index===0)return new X(exports.AcCmColorMethod.ByBlock);if(e===ir&&typeof t.rgb=="number"){const n=new X;return n.setRGBValue(t.rgb&16777215),n}if(e===hs){const n=typeof t.rgb=="number"?t.rgb&255:(t.index??0)&255;return Yt(n)}if(typeof t.index=="number"&&t.index>=0&&t.index<=256)return Yt(t.index);if(typeof t.rgb=="number"&&Number.isFinite(t.rgb))return Yt(t.rgb>>0)}return new X(exports.AcCmColorMethod.ByBlock)}function dw(i){const t=Ur(i);if(t.isByBlock)return 0;if(t.isByLayer)return 256;const e=t.colorIndex;if(e!=null&&e>0&&e<256)return e;const n=t.RGB;return typeof n=="number"?(ir<<24|n&16777215)>>0:0}const gw=127;var kp=(i=>(i[i.Extents=1]="Extents",i[i.Circle=2]="Circle",i[i.Circle3P=3]="Circle3P",i[i.CircularArc=4]="CircularArc",i[i.CircularArc3P=5]="CircularArc3P",i[i.Polyline=6]="Polyline",i[i.Polygon=7]="Polygon",i[i.Mesh=8]="Mesh",i[i.Shell=9]="Shell",i[i.Text=10]="Text",i[i.Text2=11]="Text2",i[i.Xline=12]="Xline",i[i.Ray=13]="Ray",i[i.AttributeColor=14]="AttributeColor",i[i.AttributeLayer=16]="AttributeLayer",i[i.AttributeLinetype=18]="AttributeLinetype",i[i.AttributeMarker=19]="AttributeMarker",i[i.AttributeFill=20]="AttributeFill",i[i.AttributeTrueColor=22]="AttributeTrueColor",i[i.AttributeLineweight=23]="AttributeLineweight",i[i.AttributeLtscale=24]="AttributeLtscale",i[i.AttributeThickness=25]="AttributeThickness",i[i.PushMatrix=29]="PushMatrix",i[i.PopMatrix=31]="PopMatrix",i[i.PolylineWithNormals=32]="PolylineWithNormals",i[i.LwPolyline=33]="LwPolyline",i[i.UnicodeText=36]="UnicodeText",i[i.UnicodeText2=38]="UnicodeText2",i[i.EllipticArc=44]="EllipticArc",i))(kp||{});const Mn=A.Z_AXIS,fw=529;function pw(i){const t=i>>24&255;return t===ir?{rgb:i&16777215}:t===Hi?{colorIndex:256}:t===Gi?{colorIndex:0}:t===hs?{colorIndex:i&255}:{colorIndex:i&255}}function rc(i){return new A(i.x,i.y,i.z??0)}function sc(i){return new x(i.x,i.y,i.z??0)}function ld(i){return{x:i[0],y:i[1],z:i[2]}}class Hc{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=kt,this._lineweight=exports.AcGiLineWeight.ByLineWeightDefault,this._ltscale=1,this._thickness=0,this._fill=!1,this._layers=[],this._linetypes=[],this._matrices=[],this._buffer=t,this._database=e.database,this._dxfversion=e.dxfversion??"AC1015",this._encoding=e.encoding??(this._dxfversion<"AC1024"?"windows-1252":"utf-8"),this._layer=e.defaultLayer??"0",this._database&&(this._database.tables.layerTable.newIterator().toArray().forEach(n=>this._layers.push(n.name)),this._database.tables.linetypeTable.newIterator().toArray().forEach(n=>this._linetypes.push(n.name)))}get extents(){return this._extents}scanExtents(){var n;const t=this._buffer;let e=this._index;for(;e<t.length;){const r=new DataView(t.buffer,t.byteOffset+e,8),s=r.getUint32(0,!0),a=r.getUint32(4,!0);if(s<8)break;if(a===1){const o=t.subarray(e+8,e+s);return this.readExtents(o),((n=this._extents)==null?void 0:n.length)===2?[this._extents[0],this._extents[1]]:void 0}e+=s}}worldDraw(t){const e=[],n=t.subEntityTraits,r={color:n.color.clone(),lineType:n.lineType,lineTypeScale:n.lineTypeScale,lineWeight:n.lineWeight,layer:n.layer,thickness:n.thickness},s=this._buffer;let a=this._index;for(;a<s.length;){const o=new DataView(s.buffer,s.byteOffset+a,8),c=o.getUint32(0,!0),l=o.getUint32(4,!0);if(c<8)break;const h=s.subarray(a+8,a+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),a+=c}if(n.color=r.color,n.lineType=r.lineType,n.lineTypeScale=r.lineTypeScale,n.lineWeight=r.lineWeight,n.layer=r.layer,n.thickness=r.thickness,e.length!==0)return t.group(e)}dispatchChunk(t,e,n,r){switch(n){case 1:this.readExtents(r);break;case 2:this.drawCircle(t,e,r);break;case 3:this.drawCircle3P(t,e,r);break;case 4:this.drawCircularArc(t,e,r);break;case 5:this.drawCircularArc3P(t,e,r);break;case 44:this.drawEllipticArc(t,e,r);break;case 6:this.drawPolyline(t,e,r,!1);break;case 32:this.drawPolyline(t,e,r,!0);break;case 7:this.drawPolygon(t,e,r);break;case 33:this.drawLwPolyline(t,e,r);break;case 9:this.drawShell(t,e,r);break;case 10:this.drawText(t,e,r,!1);break;case 36:this.drawText(t,e,r,!0);break;case 11:this.drawText2(t,e,r,!1);break;case 38:this.drawText2(t,e,r,!0);break;case 12:this.drawXline(t,e,r,!1);break;case 13:this.drawXline(t,e,r,!0);break;case 14:this.readAttributeColor(r);break;case 16:this.readAttributeLayer(r);break;case 18:this.readAttributeLinetype(r);break;case 20:this.readAttributeFill(r);break;case 22:this.readAttributeTrueColor(r);break;case 23:this.readAttributeLineweight(r);break;case 24:this.readAttributeLtscale(r);break;case 25:this.readAttributeThickness(r);break;case 29:this.pushMatrix(r);break;case 31:this.popMatrix();break}}applyTraits(t){const e=t.subEntityTraits;e.layer=this._layer,e.lineTypeScale=this._ltscale,e.thickness=this._thickness,e.lineWeight=this._lineweight,this._rgbColor!=null?e.color=new X(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new X(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new X(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new X(exports.AcCmColorMethod.ByACI,7):e.color=new X(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===kt?"ByLayer":this._linetype===Ne?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?ld(t):t,n=sc(e);return this._matrices.length>0&&n.applyMatrix4(this._matrices[this._matrices.length-1]),n}transformVector(t){const e=Array.isArray(t)?ld(t):t,n=rc(e);return this._matrices.length>0&&n.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(n.lengthSq())||n.lengthSq()<1e-24?Mn.clone():n.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new re(t),n=e.readVertex(),r=e.readVertex();this._extents=[new x(n[0],n[1],n[2]),new x(r[0],r[1],r[2])]}readAttributeColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);this._rgbColor=void 0,this._colorIndex=e>256||e<0?256:e}readAttributeLayer(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e<this._layers.length&&(this._layer=this._layers[e])}readAttributeLinetype(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e+2<this._linetypes.length?this._linetype=this._linetypes[e+2]:e===32766?this._linetype=Ne:this._linetype=kt}readAttributeFill(t){this._fill=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0)!==0}readAttributeTrueColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0),n=pw(e);this._rgbColor=n.rgb,n.colorIndex!=null&&(this._colorIndex=n.colorIndex)}readAttributeLineweight(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e>fw?this._lineweight=e-4294967296:this._lineweight=e}readAttributeLtscale(t){this._ltscale=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}readAttributeThickness(t){this._thickness=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}pushMatrix(t){const e=new Float64Array(t.buffer,t.byteOffset,16),n=new z().fromArray(Array.from(e));n.transpose(),this._matrices.push(n)}popMatrix(){this._matrices.length>0&&this._matrices.pop()}loadVertices(t,e){const n=new re(t);let r=n.readLong();e&&(r+=1);const s=[];for(;r>0;){const[o,c,l]=n.readVertex();s.push(this.transformPoint({x:o,y:c,z:l})),r-=1}let a=Mn;return e&&s.length>0&&(a=rc(s.pop())),{vertices:s,normal:a}}drawCircle(t,e,n){const r=new re(n),s=r.readVertex(),a=r.readFloat(),o=this.transformVector(r.readVertex());let c=sc({x:s[0],y:s[1],z:s[2]});o.equals(Mn)||(c=Zt(c,o)),c=this.transformPoint(c);const l=Mi(o),h=new _t(ce(c,o),a,0,Y,o,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=_t.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=new _t(c,l,0,Y,Mn);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,n){const r=new re(n),s=r.readVertex(),a=r.readFloat(),o=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(o),u=sc({x:s[0],y:s[1],z:s[2]}),d=rc({x:c[0],y:c[1],z:c[2]});this._matrices.length>0&&d.transformDirection(this._matrices[this._matrices.length-1]);const g=Number.isFinite(d.lengthSq())&&d.lengthSq()>=1e-24?d.normalize():Mi(h),f=0,p=l,m=new _t(this.transformPoint(u),a,f,p,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=_t.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=Ze(c,s,Mn),u=Ze(c,o,Mn),d=new _t(c,l,h,u,Mn);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformVector(r.readVertex()),o=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=ce({x:Math.cos(u)*o,y:Math.sin(u)*o,z:0},a),g=new we(s,a,d,o,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,n,r){var a,o;const{vertices:s}=this.loadVertices(n,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((a=this._database)==null?void 0:a.pdmode)??0,l=((o=this._database)==null?void 0:o.pdsize)??0;this.pushEntity(e,t.point(s[0],{displayMode:c,displaySize:l}));return}this.applyTraits(t),this.pushEntity(e,t.lines(s))}}drawPolygon(t,e,n){const{vertices:r}=this.loadVertices(n,!1);if(r.length<2)return;if(this._fill){const a=new ot(r.map(l=>({x:l.x,y:l.y})),!0),o=new de;o.add(a);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(o));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,n){const r=new Hf(n,this._dxfversion,this._encoding);let s=0,a=!1;r.readUnsignedLong();const o=r.readBitShort();o&8&&(s=r.readBitDouble()),o&512&&(a=!0);const c=r.readBitLong();if(c<=0)return;const l=o&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(o&1024&&r.readBitLong(),o&32&&r.readBitLong());const h=r.readRawDouble(2),u=[this.transformPoint({x:h[0],y:h[1],z:s})];let d=h;for(let g=1;g<c;g++){const f=r.readBitDoubleDefault(1,d[0]),p=r.readBitDoubleDefault(1,d[1]);d=[f,p],u.push(this.transformPoint({x:f,y:p,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();a&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,n){const r=new re(n),s=r.readLong(),a=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();a.push(this.transformPoint({x:u,y:d,z:g}))}const o=r.readLong(),c=[];let l=0;for(;l<o;){const h=Math.abs(r.readSignedLong());l+=1+h;const u=[];for(let g=0;g<h;g++)u.push(r.readLong());const d=u.map(g=>a[g]).filter(Boolean);if(d.length>=3)for(let g=0;g<d.length;g++)c.push(d[g]),c.push(d[(g+1)%d.length])}c.length!==0&&(this.applyTraits(t),this.pushEntity(e,t.lines(c)))}drawText(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),[l,h,u]=s.readStruct([8,8,8]),d=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),l=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);s.readSignedLong(),s.readSignedLong();const[h,u,d]=s.readStruct([8,8,8]);s.readFloat(),this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:l,height:h,widthFactor:u,obliqueAngle:d})}drawTextPrimitive(t,e,n){const r=Math.atan2(n.textDirection.y,n.textDirection.x),s={text:n.text,height:n.height,width:1/0,widthFactor:n.widthFactor,position:n.insert,rotation:r*180/Math.PI,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft},a={name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:n.widthFactor,obliqueAngle:n.obliqueAngle*180/Math.PI,textGenerationFlag:0,lastHeight:n.height,font:"txt",bigFont:""};this.applyTraits(t),this.pushEntity(e,t.mtext(s,a))}drawXline(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformPoint(s.readVertex()),c=new A().subVectors(o,a);if(c.lengthSq()===0)return;const l=1e6,h=r?a.clone().add(c.normalize().multiplyScalar(l)):a.clone().sub(c.normalize().multiplyScalar(l)),u=o.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function mw(i,t){if(!(t!=null&&t.length))return;const e=cs(t);return i!=null&&i>0&&e.length>=i?e.subarray(0,i):e}const Nh=class Nh extends et{constructor(){super(...arguments),this._originalDxfName="",this._originalClassName="",this._applicationName="",this._proxyEntityClassId=498,this._applicationEntityClassId=0,this._objectDrawingFormat=0,this._originalDataFormat=0,this._entityOrigins=[],this._worldTransform=new z}get dxfTypeName(){return"ACAD_PROXY_ENTITY"}get originalDxfName(){return this._originalDxfName}set originalDxfName(t){this._originalDxfName=t}get originalClassName(){return this._originalClassName}set originalClassName(t){this._originalClassName=t}get applicationName(){return this._applicationName}set applicationName(t){this._applicationName=t}get proxyEntityClassId(){return this._proxyEntityClassId}set proxyEntityClassId(t){this._proxyEntityClassId=t}get applicationEntityClassId(){return this._applicationEntityClassId}set applicationEntityClassId(t){this._applicationEntityClassId=t}get objectDrawingFormat(){return this._objectDrawingFormat}set objectDrawingFormat(t){this._objectDrawingFormat=t}get graphicsMetafileType(){return this._objectDrawingFormat}set graphicsMetafileType(t){this._objectDrawingFormat=t}get originalDataFormat(){return this._originalDataFormat}set originalDataFormat(t){this._originalDataFormat=t}get proxyGraphic(){return this._proxyGraphic}setProxyGraphic(t){this._proxyGraphic=t?new Uint8Array(t):void 0}get entityOrigins(){return this._entityOrigins}setEntityOrigins(t){this._entityOrigins=t.map(e=>new x(e.x,e.y,e.z))}get geometricExtents(){const t=this._proxyGraphic;if(!(t!=null&&t.length))return new H;const n=new Hc(t,{database:this.database,defaultLayer:this.layer}).scanExtents();if(n){const r=new H().setFromPoints(n);return this._worldTransform.equals(new z)||r.applyMatrix4(this._worldTransform),r}return new H}subGetGripPoints(){if(this._entityOrigins.length>0)return[...this._entityOrigins];const t=this.geometricExtents;return t.isEmpty()?[]:[new x(t.min.x,t.min.y,t.min.z),new x(t.max.x,t.max.y,t.max.z)]}subMoveGripPointsAt(t,e){return this._entityOrigins.length>0?(er(t,e,this._entityOrigins),this):this.geometricExtents.isEmpty()?this:(Et(t,r=>{r===0&&this.transformBy(z.makeTranslation(e))}),this)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"proxy",properties:[{name:"originalDxfName",type:"string",editable:!1,accessor:{get:()=>this.originalDxfName}},{name:"originalClassName",type:"string",editable:!1,accessor:{get:()=>this.originalClassName}},{name:"applicationName",type:"string",editable:!1,accessor:{get:()=>this.applicationName}},{name:"proxyEntityClassId",type:"int",editable:!1,accessor:{get:()=>this.proxyEntityClassId}},{name:"applicationEntityClassId",type:"int",editable:!1,accessor:{get:()=>this.applicationEntityClassId}},{name:"objectDrawingFormat",type:"int",editable:!1,accessor:{get:()=>this.objectDrawingFormat}},{name:"originalDataFormat",type:"int",editable:!1,accessor:{get:()=>this.originalDataFormat}}]}]}}transformBy(t){return this._entityOrigins.forEach(e=>e.applyMatrix4(t)),this._worldTransform.premultiply(t),this}subWorldDraw(t){const e=this._proxyGraphic;if(!(e!=null&&e.length))return;const r=new Hc(e,{database:this.database,defaultLayer:this.layer}).worldDraw(t);return r&&!this._worldTransform.equals(new z)&&r.applyMatrix(this._worldTransform),r}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbProxyEntity"),this._originalDxfName&&t.writeString(1,this._originalDxfName),this._originalClassName&&t.writeString(3,this._originalClassName),t.writeInt32(90,this._proxyEntityClassId||498),this._applicationEntityClassId&&t.writeInt32(91,this._applicationEntityClassId),this._objectDrawingFormat&&t.writeInt32(95,this._objectDrawingFormat),t.writeInt16(70,this._originalDataFormat),(e=this._proxyGraphic)!=null&&e.length){t.writeInt32(160,this._proxyGraphic.length);let n=0;for(;n<this._proxyGraphic.length;){const r=this._proxyGraphic.subarray(n,n+127);t.writeString(310,Po(r)),n+=127}}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbProxyEntity");const e=[];let n;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 1:this.originalDxfName=String(r.value);break;case 3:this.originalClassName=String(r.value);break;case 70:this.originalDataFormat=a;break;case 90:this.proxyEntityClassId=a;break;case 91:this.applicationEntityClassId=a;break;case 95:this.objectDrawingFormat=a;break;case 160:n=a;break;case 310:r.value instanceof Uint8Array?e.push(r.value):e.push(String(r.value));break}}return e.length>0&&this.loadProxyGraphicFromDxf(n,e),this}loadProxyGraphicFromDxf(t,e){const n=mw(t,e);n&&this.setProxyGraphic(n)}};Nh.typeName="ProxyEntity";let Hr=Nh;const Rh=class Rh extends Hr{constructor(t=""){super(),this._rawTags={header:[],body:[]},this._dxfTypeName=t.toUpperCase(),this.originalDxfName=this._dxfTypeName}get dxfTypeName(){return this._dxfTypeName}get rawTags(){return this._rawTags}dxfIn(t){const{tags:e,handle:n,ownerId:r,extensionDictionary:s}=Rf(t);this._rawTags=e,n&&(this.objectId=n),r&&(this.ownerId=r),s&&(this.extensionDictionary=s);const a=ve.forReading(new Ao(e.body.map(as)),{database:t.database});return this.dxfInFields(a),this.loadEmbeddedProxyGraphic(),t.atExtendedData&&this.dxfInXData(t),this}dxfInFields(t){return et.prototype.dxfInFields.call(this,t),this}dxfOut(...t){const[e,n=!1]=t;return Gl(e,this.patchedTags(),this),n&&this.dxfOutXData(e),this}patchedTags(){const t=[...this._rawTags.body],e=t.findIndex(a=>Number(a.code)===100&&a.value==="AcDbEntity");if(e<0)return this._rawTags;let n=t.findIndex((a,o)=>o>e&&Number(a.code)===100);n<0&&(n=t.length);const r={code:8,value:this.layer},s=t.findIndex((a,o)=>o>e&&o<n&&Number(a.code)===8);return s>=0?t[s]=r:t.splice(e+1,0,r),{header:this._rawTags.header,body:t}}get hasSubclassData(){return this._rawTags.body.some(t=>Number(t.code)===100)}transformBy(t){return this}subGetGripPoints(){return[]}loadEmbeddedProxyGraphic(){let t;const e=[];let n=!1;for(const r of this._rawTags.body){const s=Number(r.code);if(s===100){n=r.value==="AcDbEntity";continue}n&&(s===92||s===160?t=Number(r.value):s===310&&e.push(r.value instanceof Uint8Array?r.value:String(r.value)))}e.length>0&&this.loadProxyGraphicFromDxf(t,e)}};Rh.typeName="UnknownEntity";let Gr=Rh;const yw="ASM_Data";function Gc(i){return String(i).trim().toUpperCase()}function bw(i){let t,e;const n={};for(;!i.atEndOfObject&&!i.atEof;){const r=i.readItem();if(!r)break;switch(Number(r.code)){case 320:t=Gc(String(r.value));break;case 2:e=String(r.value),n[e]??(n[e]=[]);break;case 310:e&&(r.value instanceof Uint8Array?n[e].push(r.value):n[e].push(String(r.value)));break}}return{ownerHandle:t,hexChunks:n[yw]??[]}}function _w(i){const t={};for(;!i.atEof;){const e=i.peekItem();if(!e)break;if(Number(e.code)!==0){i.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"||n==="EOF"){i.readItem();break}if(i.readItem(),n==="ACDSRECORD"){const r=bw(i);if(r.ownerHandle&&r.hexChunks.length>0){const s=cs(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else i.skipToEndOfObject()}return{byOwnerHandle:t}}function Ip(i,t){for(t.clearDxfHeaderExtras();!i.atEof;){const e=i.peekItem();if(!e)break;if(Number(e.code)===0){if(String(e.value).toUpperCase()==="ENDSEC"){i.readItem();break}break}if(i.readItem(),Number(e.code)!==9)continue;const n=String(e.value).toUpperCase();xw(i,t,n)}}function xw(i,t,e){switch(e){case"$ACADVER":{const n=ke(i);n&&(t.version=n);break}case"$DWGCODEPAGE":{const n=ke(i);n&&(t.dwgCodePage=n);break}case"$CECOLOR":{const n=ac(i);n?t.cecolor=n:t.cecolor.colorIndex=256;break}case"$HPCOLOR":{const n=ac(i);n&&(t.hpcolor=n);break}case"$HPBACKGROUNDCOLOR":{const n=ac(i);n&&(t.hpbackgroundcolor=n);break}case"$ANGBASE":t.angbase=ft(i)??0;break;case"$ANGDIR":t.angdir=ft(i)??0;break;case"$AUNITS":{const n=ft(i);n!=null&&(t.aunits=n);break}case"$AUPREC":{const n=ft(i);n!=null&&(t.auprec=n);break}case"$LUNITS":{const n=ft(i);n!=null&&(t.lunits=n);break}case"$LUPREC":{const n=ft(i);n!=null&&(t.luprec=n);break}case"$UNITMODE":{const n=ft(i);n!=null&&(t.unitmode=n);break}case"$MEASUREMENT":{const n=ft(i);n!=null&&(t.measurement=n);break}case"$CELTYPE":t.celtype=ke(i)||kt;break;case"$CETRANSPARENCY":{hd(i,t,E.CETRANSPARENCY);break}case"$CELTSCALE":t.celtscale=ft(i)??1;break;case"$CELWEIGHT":{const n=ft(i);n!=null&&(t.celweight=n);break}case"$LWDISPLAY":t.lwdisplay=(ft(i)??0)!==0;break;case"$TILEMODE":t.tilemode=ft(i)??1;break;case"$PSLTSCALE":t.psltscale=(ft(i)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=ke(i)||tn;break;case"$CMLSCALE":case"CMLSCALE":{const n=ft(i);n!=null&&Number.isFinite(n)&&(t.cmlscale=n);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=ke(i)||en;break;case"$HPLAYER":case"HPLAYER":t.hplayer=ke(i)||".";break;case"$HPTRANSPARENCY":{hd(i,t,E.HPTRANSPARENCY);break}case"$LTSCALE":t.ltscale=ft(i)??1;break;case"$EXTMAX":{const n=ud(i);n&&(t.extmax=n);break}case"$EXTMIN":{const n=ud(i);n&&(t.extmin=n);break}case"$INSUNITS":{const n=ft(i);n!=null&&(t.insunits=n);break}case"$OSMODE":t.osmode=ft(i)??0;break;case"$ORTHOMODE":t.orthomode=ft(i)??0;break;case"$COMPAREHATCH":{const n=ur(ft(i),po,mo);n!=null&&(t.comparehatch=n);break}case"$COMPARERCMARGIN":{const n=ur(ft(i),yo,bo);n!=null&&(t.comparercmargin=n);break}case"$COMPARETEXT":{const n=ur(ft(i),_o,xo);n!=null&&(t.comparetext=n);break}case"$COMPARETOLERANCE":{const n=ur(ft(i),wo,vo);n!=null&&(t.comparetolerance=n);break}case"$PDMODE":t.pdmode=ft(i)??0;break;case"$PDSIZE":t.pdsize=ft(i)??0;break;case"$TEXTSTYLE":t.textstyle=ke(i)||gt;break;case"$DIMSTYLE":t.dimstyle=ke(i)||gt;break;case"$CLAYER":t.clayer=ke(i)||"0";break;case"$HANDSEED":{const n=ke(i);n&&t.initializeHandleSeed(n);break}default:{const n=Ep(i);n.length>0&&t.addDxfHeaderExtra(e,n);break}}}function ac(i){let t;for(const e of Ep(i)){const n=Number(e.code),r=Number(e.value);Number.isFinite(r)&&(n===62||n===70?(t??(t=new X),t.colorIndex=r):n===420&&(t??(t=new X),t.setRGBValue(r)))}return t}function ke(i){const t=i.readItem();if(t){if(Number(t.code)===9||Number(t.code)===0){i.pushBackItem(t);return}return String(t.value)}}function ft(i){const t=i.readItem();if(!t)return;if(Number(t.code)===9||Number(t.code)===0){i.pushBackItem(t);return}const e=Number(t.value);return Number.isFinite(e)?e:void 0}function hd(i,t,e){const n=i.readItem();if(!n||Number(n.code)===9||Number(n.code)===0){n&&i.pushBackItem(n),wt.instance().setVar(e,"ByLayer",t);return}const r=Number(n.code),s=String(n.value).trim();if(s===""){wt.instance().setVar(e,"ByLayer",t);return}if(r===440){const a=Number(s);wt.instance().setVar(e,Number.isFinite(a)?a:"ByLayer",t);return}wt.instance().setVar(e,s,t)}function ud(i){let t=0,e=0,n=0,r=!1;for(;!i.atEof;){const s=i.peekItem();if(!s)break;const a=Number(s.code);if(a===9||a===0)break;i.readItem();const o=Number(s.value);a===10?(t=o,r=!0):a===20?(e=o,r=!0):a===30&&(n=o,r=!0)}return r?new x(t,e,n):void 0}function Ep(i){const t=[];for(;!i.atEof;){const e=i.peekItem();if(!e)break;const n=Number(e.code);if(n===9||n===0)break;i.readItem(),t.push(e)}return t}class Tp{constructor(t){this._expression=t}get expression(){return this._expression}}var Lp=(i=>(i[i.Cancel=0]="Cancel",i[i.Ok=1]="Ok",i))(Lp||{});class To{constructor(){this._name="",this._filterExpression="",this._nestedFilters=[],this._parent=null,this._allowDelete=!0,this._allowRename=!0,this._dynamicallyGenerated=!1,this._isProxy=!1}get name(){return this._name}setName(t){return!this.allowRename()&&this._name.length>0?!1:(this._name=t,!0)}set name(t){this.setName(t)}get filterExpression(){return this._filterExpression}setFilterExpression(t){return this.isIdFilter()?!1:(this._filterExpression=t??"",!0)}set filterExpression(t){this.setFilterExpression(t)}filterExpressionTree(){return this.isIdFilter()||!this._filterExpression?null:new Tp(this._filterExpression)}getNestedFilters(){return this._nestedFilters}get nestedFilters(){return this._nestedFilters}parent(){return this._parent}isIdFilter(){return!1}allowNested(){return!0}allowDelete(){return this._allowDelete}setAllowDelete(t){this._allowDelete=t}allowRename(){return this._allowRename}setAllowRename(t){this._allowRename=t}dynamicallyGenerated(){return this._dynamicallyGenerated}setDynamicallyGenerated(t){this._dynamicallyGenerated=t}isProxy(){return this._isProxy}setIsProxy(t){this._isProxy=t}addNested(t){return!t||t===this||!this.allowNested()||!(this._parent==null)&&!this.isIdFilter()&&t.isIdFilter()||this._nestedFilters.includes(t)?!1:(t._parent&&t._parent.removeNested(t),t._parent=this,this._nestedFilters.push(t),!0)}removeNested(t){const e=this._nestedFilters.indexOf(t);return e<0?!1:(this._nestedFilters.splice(e,1),t._parent===this&&(t._parent=null),!0)}generateNested(){return!1}compareTo(t){return t?this.isIdFilter()===t.isIdFilter()&&this._name===t._name&&this._filterExpression===t._filterExpression:!1}filter(t){return t?this._filterExpression?ww(this._filterExpression,t):!0:!1}showEditor(){return 0}}function ww(i,t){const e=i.trim();return e?dd(e,"OR").some(r=>dd(r,"AND").every(a=>vw(a,t))):!0}function dd(i,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return i.split(e).map(n=>n.trim()).filter(n=>n.length>0)}function vw(i,t){var a;const e=i.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const n=e[1].toUpperCase(),r=e[3],s=Sw(r);switch(n){case"NAME":return Aw(t.name,r);case"LOCKED":return s!=null?t.isLocked===s:!1;case"FROZEN":return s!=null?t.isFrozen===s:!1;case"OFF":return s!=null?t.isOff===s:!1;case"PLOT":return s!=null?t.isPlottable===s:!1;case"COLOR":{const o=(a=t.color)==null?void 0:a.colorIndex;return o!=null&&String(o)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function Aw(i,t){return/[*?]/.test(t)?new RegExp(`^${t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`,"i").test(i):i.localeCompare(t,void 0,{sensitivity:"accent"})===0}function Sw(i){const t=i.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class rn{constructor(t,e){this._root=t??rn.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new To;return t.setName("All"),t.setAllowDelete(!1),t.setAllowRename(!1),t.setFilterExpression(""),t}get root(){return this._root}get current(){return this._current}set current(t){this._current=t}clone(){return new rn(this._root,this._current)}}class Mp extends To{constructor(){super(),this._layerIds=[]}isIdFilter(){return!0}layerIds(){return this._layerIds}get layerIdList(){return this._layerIds}addLayerId(t){return!t||this._layerIds.includes(t)?!1:(this._layerIds.push(t),!0)}removeLayerId(t){const e=this._layerIds.indexOf(t);return e<0?!1:(this._layerIds.splice(e,1),!0)}filter(t){return t?this._layerIds.includes(t.objectId):!1}setFilterExpression(t){return!1}}const Wr="ACAD_LAYERFILTERS",zn="ACLYDICTIONARY";function Cp(i){const t=rn.createDefaultRoot(),e=new rn(t,t),n=gd(i,zn),r=gd(i,Wr);if(n){for(const[s,a]of Object.entries(n.entries)){const o=Wc(i,a,s);o&&t.addNested(o)}return e}if(r)for(const[s,a]of Object.entries(r.entries)){const o=Wc(i,a,s);o&&t.addNested(o)}return e}function Op(i){const t=[];for(const e of i.root.getNestedFilters())t.push(Rp(e));return{nodes:t}}function Dp(i){const t=new Xe;for(const e of i)t.add({code:e.code,value:e.value});return t}function Pw(i){return i?i.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function gd(i,t){let e;for(const n of i.dictionaries.values()){const r=n.entries[t];if(!r)continue;const s=i.dictionaries.get(Ke(r));if(!s)continue;if(!(n.ownerObjectId?i.xrecords.has(Ke(n.ownerObjectId)):!1))return s;e=s}return e}function Wc(i,t,e){const n=i.xrecords.get(Ke(t));if(!n)return;const r=Np(n.data,e),s=r.isIdFilter?new Mp:new To;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const a=s;for(const o of r.layerIds)a.addLayerId(o)}for(const a of kw(i,n)){const o=Wc(i,a.handle,a.key);o&&s.addNested(o)}return s}function kw(i,t){const e=[],n=new Set,r=Ke(t.handle),s=t.extensionDictionaryId?Ke(t.extensionDictionaryId):void 0,a=(o,c)=>{const l=Ke(c);n.has(l)||(n.add(l),e.push({key:o,handle:c}))};for(const o of i.dictionaries.values()){const c=o.ownerObjectId?Ke(o.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=o.entries[zn];if(h){const u=i.dictionaries.get(Ke(h));if(u){for(const[d,g]of Object.entries(u.entries))a(d,g);continue}}for(const[u,d]of Object.entries(o.entries))u===zn||u===Wr||a(u,d)}return e}function Np(i,t=""){const e=[],n=[];let r=0,s,a,o;for(const f of i){const p=Number(f.code),m=f.value;p===1&&typeof m=="string"?e.push(m):p===300&&typeof m=="string"?a=m:p===301&&typeof m=="string"?o=m:p===70||p===90?r=Number(m)||0:p===290||p===280?s=Number(m)===1:(p===330||p===340||p===350||p===360)&&m!=null&&String(m).length>0&&n.push(Ke(String(m)))}const c=e[0],h=a||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=o??u;!o&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=o!=null&&o.length>0?!1:s===!0&&n.length>0?!0:n.length>0&&(d.length===0||d==="*");return{name:h,filterExpression:g?"":d,flags:r,layerIds:n,isIdFilter:g}}function Rp(i){const t=i.isIdFilter(),e=Bp(i),n=i.getNestedFilters().map(s=>Rp(s));return{key:i.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:n}}function Bp(i){const t=[];if(t.push({code:1,value:i.name}),i.isIdFilter()){t.push({code:1,value:""}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:1});const e=i;for(const n of e.layerIds())t.push({code:330,value:n})}else t.push({code:1,value:i.filterExpression||"*"}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:0});return t}function Ke(i){return i.trim().toUpperCase()}class xr extends pt{constructor(){super(...arguments),this._schema=0,this._value=""}get schema(){return this._schema}set schema(t){this._schema=t}get value(){return this._value}set value(t){this._value=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("DictionaryVariables"),t.writeInt16(280,this._schema),t.writeString(1,this._value),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("DictionaryVariables")||t.atSubclassData("AcDbDictionaryVar");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 280:this._schema=Number(e.value);break;case 1:this._value=String(e.value);break}}return this}}class Pi extends pt{constructor(t="",e=!0){super(),this._name="",this._description="",this._anonymous=!1,this._selectable=!0,this._entityIds=[],this.description=t,this.selectable=e}get name(){return this._name}set name(t){this._name=t}get description(){return this._description}set description(t){this._description=String(t??"")}get unnamed(){return this._anonymous}set unnamed(t){this._anonymous=t}get anonymous(){return this._anonymous}set anonymous(t){this._anonymous=t}get selectable(){return this._selectable}set selectable(t){this._selectable=t}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this.append(t)}isAnonymous(){return this._anonymous}setAnonymous(){this._anonymous=!0}isNotAccessible(){return!1}setName(t){var a;const e=String(t??""),n=(a=this.database)==null?void 0:a.objects.group;if(!n){this._name=e;return}let r;if(this._name&&n.getAt(this._name)===this)r=this._name;else for(const[o,c]of n.entries())if(c===this){r=o;break}if(r===e){this._name=e;return}const s=e?n.getAt(e):void 0;s&&s!==this||(r!=null&&r!==e&&(n.remove(r),e&&n.setAt(e,this)),this._name=e)}numEntities(){return this._entityIds.length}allEntityIds(t){return t&&(t.length=0,t.push(...this._entityIds)),this._entityIds.length}has(t){const e=typeof t=="string"?t:t.objectId??"";return e?this._entityIds.includes(e):!1}getIndex(t){return this._entityIds.indexOf(t)}newIterator(){return new Hn(this._entityIds)}append(t){const e=Array.isArray(t)?t:[t];for(const n of e)!n||this._entityIds.includes(n)||this._entityIds.push(n)}prepend(t){const e=Array.isArray(t)?t:[t];for(let n=e.length-1;n>=0;n--){const r=e[n];!r||this._entityIds.includes(r)||this._entityIds.unshift(r)}}insertAt(t,e){const n=(Array.isArray(e)?e:[e]).filter(s=>!!s&&!this._entityIds.includes(s));if(n.length===0)return;const r=Math.max(0,Math.min(this._entityIds.length,Math.trunc(t)));this._entityIds.splice(r,0,...n)}remove(t){const e=new Set((Array.isArray(t)?t:[t]).filter(Boolean));e.size!==0&&(this._entityIds=this._entityIds.filter(n=>!e.has(n)))}removeAt(t,e){const n=Math.trunc(t);if(!(n<0||n>=this._entityIds.length)){if(e&&e.length>0){const r=new Set(e.filter(Boolean));this._entityIds=this._entityIds.filter((s,a)=>a<n?!0:!r.has(s));return}this._entityIds.splice(n,1)}}replace(t,e){if(!t||!e||t===e)return;const n=this._entityIds.indexOf(t);if(!(n<0)){if(this._entityIds.includes(e)){this._entityIds.splice(n,1);return}this._entityIds[n]=e}}transfer(t,e,n){const r=Math.trunc(t),s=Math.trunc(e),a=Math.trunc(n);if(a<=0||r<0||r>=this._entityIds.length)return;const o=this._entityIds.splice(r,a);let c=s;s>r&&(c=Math.max(0,s-o.length)),c=Math.max(0,Math.min(this._entityIds.length,c)),this._entityIds.splice(c,0,...o)}reverse(){this._entityIds.reverse()}clear(){this._entityIds=[]}setColor(t){for(const e of this.memberEntities())e.color=t.clone()}setColorIndex(t){const e=new X;e.colorIndex=t,this.setColor(e)}setLayer(t){const e=this.resolveLayerName(t);if(e)for(const n of this.memberEntities())n.layer=e}setLinetype(t){const e=this.resolveLinetypeName(t);if(e)for(const n of this.memberEntities())n.lineType=e}setLinetypeScale(t){for(const e of this.memberEntities())e.linetypeScale=t}setMaterial(t){}setVisibility(t){for(const e of this.memberEntities())e.visibility=t}setHighlight(t){}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbGroup"),this._description&&t.writeString(300,this._description),t.writeInt16(70,this._anonymous?1:0),t.writeInt16(71,this._selectable?1:0);for(const e of this._entityIds)t.writeObjectId(340,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbGroup"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 300:this.description=e.value;break;case 70:this.anonymous=Number(e.value)!==0;break;case 71:this.selectable=Number(e.value)!==0;break;case 340:this._entityIds.push(String(e.value));break}}return this}memberEntities(){const t=this.database;if(!t)return[];const e=[];for(const n of this._entityIds){const r=t.getObjectById(n);r instanceof et&&e.push(r)}return e}resolveLayerName(t){const e=this.database;if(!e)return String(t??"");const n=e.getObjectById(t);return n&&"name"in n&&typeof n.name=="string"?n.name:String(t??"")}resolveLinetypeName(t){const e=this.database;if(!e)return String(t??"");const n=e.getObjectById(t);return n&&"name"in n&&typeof n.name=="string"?n.name:String(t??"")}}class Fp extends pt{constructor(){super(),this._boundaryVertices=[],this._clipBoundaryDisplayEnabled=!1,this._frontClippingEnabled=!1,this._backClippingEnabled=!1}get boundaryVertices(){return this._boundaryVertices}set boundaryVertices(t){this._boundaryVertices=t.map(e=>e.clone())}get clipBoundaryNormal(){return this._clipBoundaryNormal}set clipBoundaryNormal(t){this._clipBoundaryNormal=t==null?void 0:t.clone()}get clipBoundaryOrigin(){return this._clipBoundaryOrigin}set clipBoundaryOrigin(t){this._clipBoundaryOrigin=t==null?void 0:t.clone()}get clipBoundaryDisplayEnabled(){return this._clipBoundaryDisplayEnabled}set clipBoundaryDisplayEnabled(t){this._clipBoundaryDisplayEnabled=t}get frontClippingEnabled(){return this._frontClippingEnabled}set frontClippingEnabled(t){this._frontClippingEnabled=t}get frontClippingDistance(){return this._frontClippingDistance}set frontClippingDistance(t){this._frontClippingDistance=t}get backClippingEnabled(){return this._backClippingEnabled}set backClippingEnabled(t){this._backClippingEnabled=t}get backClippingDistance(){return this._backClippingDistance}set backClippingDistance(t){this._backClippingDistance=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFilter"),this._boundaryVertices.length>0&&(t.writeInt16(70,this._boundaryVertices.length),this._boundaryVertices.forEach(e=>t.writePoint2d(10,e)),t.writeVector3d(210,this._clipBoundaryNormal),t.writePoint3d(11,this._clipBoundaryOrigin),t.writeInt16(71,this._clipBoundaryDisplayEnabled?1:0),t.writeInt16(72,this._frontClippingEnabled?1:0),this._frontClippingEnabled&&this._frontClippingDistance!=null&&t.writeDouble(40,this._frontClippingDistance),t.writeInt16(73,this._backClippingEnabled?1:0),this._backClippingEnabled&&this._backClippingDistance!=null&&t.writeDouble(41,this._backClippingDistance)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFilter");let e=null,n=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===100){t.pushBackItem(r);break}const a=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new C(e.x,e.y)),e={x:a,y:0};break;case 20:e&&(e.y=a);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new x,this._clipBoundaryNormal.x=a;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=a);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=a);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new x,this._clipBoundaryOrigin.x=a;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=a);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=a);break;case 71:this._clipBoundaryDisplayEnabled=a!==0;break;case 72:this._frontClippingEnabled=a!==0;break;case 73:this._backClippingEnabled=a!==0;break;case 40:n||(this._frontClippingDistance=a,n=!0);break;case 41:this._backClippingDistance=a;break}}return e&&this._boundaryVertices.push(new C(e.x,e.y)),this}}class ch extends Fp{constructor(){super(),this._layerNames=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}add(t){const e=t==null?void 0:t.trim();return!e||this._layerNames.includes(e)?!1:(this._layerNames.push(e),!0)}getAt(t){if(t<0||t>=this._layerNames.length)throw new Error("The layer index is out of range!");return this._layerNames[t]}remove(t){const e=this._layerNames.indexOf(t);return e<0?!1:(this._layerNames.splice(e,1),!0)}layerCount(){return this._layerNames.length}indexClass(){return"AcDbLayerIndex"}isValid(){return this._layerNames.some(t=>t.length>0)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerFilter");for(const e of this._layerNames)t.writeString(8,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayerFilter");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 8:this.add(String(e.value));break;case 100:return t.pushBackItem(e),this}}return this}}class zp extends pt{constructor(){super(),this._lastUpdatedAt=0,this._lastUpdatedAtU=0,this._isUptoDate=!1,this._objectBeingIndexedId=""}get lastUpdatedAt(){return this._lastUpdatedAt}set lastUpdatedAt(t){this._lastUpdatedAt=t}get lastUpdatedAtU(){return this._lastUpdatedAtU}set lastUpdatedAtU(t){this._lastUpdatedAtU=t}get isUptoDate(){return this._isUptoDate}set isUptoDate(t){this._isUptoDate=t}objectBeingIndexedId(){return this._objectBeingIndexedId}setObjectBeingIndexedId(t){this._objectBeingIndexedId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbIndex"),t.writeDouble(40,this.lastUpdatedAt),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbIndex");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 40:this.lastUpdatedAt=Number(e.value),this.lastUpdatedAtU=this.lastUpdatedAt;break;case 100:return t.pushBackItem(e),this}}return this}}class lh extends zp{constructor(){super(),this._layerNames=[],this._idBufferIds=[],this._idBufferEntryCounts=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}get idBufferIds(){return this._idBufferIds}set idBufferIds(t){this._idBufferIds=[...t]}get idBufferEntryCounts(){return this._idBufferEntryCounts}set idBufferEntryCounts(t){this._idBufferEntryCounts=[...t]}get entries(){const t=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length),e=[];for(let n=0;n<t;n++)e.push({layerName:this._layerNames[n]??"",idBufferId:this._idBufferIds[n]??"",idBufferEntryCount:this._idBufferEntryCounts[n]??0});return e}set entries(t){this._layerNames=t.map(e=>e.layerName),this._idBufferIds=t.map(e=>e.idBufferId),this._idBufferEntryCounts=t.map(e=>e.idBufferEntryCount)}compute(t,e){if(e&&this.setObjectBeingIndexedId(e.objectId),t){this._layerNames=[];for(const n of t.newIterator())this._layerNames.push(n.name)}return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}newIterator(t){return null}rebuildFull(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}rebuildModified(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerIndex");const e=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length);for(let n=0;n<e;n++)this._layerNames[n]!=null&&t.writeString(8,this._layerNames[n]),this._idBufferIds[n]&&t.writeHandle(360,this._idBufferIds[n]),this._idBufferEntryCounts[n]!=null&&t.writeInt32(90,this._idBufferEntryCounts[n]);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLayerIndex");const e=[],n=[],r=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;switch(Number(s.code)){case 8:e.push(String(s.value));break;case 360:n.push(String(s.value));break;case 90:r.push(Number(s.value));break;case 100:return t.pushBackItem(s),this.layerNames=e,this.idBufferIds=n,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}return this.layerNames=e,this.idBufferIds=n,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}class us extends pt{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new X(exports.AcCmColorMethod.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new X(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new X(exports.AcCmColorMethod.ByBlock),this._blockScale=new A(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(t){this._unknown1=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(t){this._drawMLeaderOrderType=t}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(t){this._drawLeaderOrderType=t}get bitFlags(){return this._bitFlags}set bitFlags(t){this._bitFlags=t}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(t){this._maxLeaderSegmentsPoints=t}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(t){this.maxLeaderSegmentsPoints=t}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(t){this._firstSegmentAngleConstraint=t}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(t){this._secondSegmentAngleConstraint=t}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor.copy(t)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get enableLanding(){return this._enableLanding}set enableLanding(t){this._enableLanding=t}get landingEnabled(){return this.enableLanding}set landingEnabled(t){this.enableLanding=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get enableDogleg(){return this._enableDogleg}set enableDogleg(t){this._enableDogleg=t}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(t){this.enableDogleg=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get description(){return this._description}set description(t){this._description=t}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(t){this._arrowSymbolId=t}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(t){this.arrowSymbolId=t}get arrowSize(){return this._arrowSize}set arrowSize(t){this._arrowSize=t}get arrowheadSize(){return this.arrowSize}set arrowheadSize(t){this.arrowSize=t}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(t){this._defaultMTextContents=t}get defaultMText(){return this.defaultMTextContents}set defaultMText(t){this.defaultMTextContents=t}get textString(){return this.defaultMTextContents}set textString(t){this.defaultMTextContents=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textStyle(){return this.textStyleId}set textStyle(t){this.textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor.copy(t)}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get enableFrameText(){return this._enableFrameText}set enableFrameText(t){this._enableFrameText=t}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(t){this.enableFrameText=t}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(t){this._textAlignAlwaysLeft=t}get alignSpace(){return this._alignSpace}set alignSpace(t){this._alignSpace=t}get blockId(){return this._blockId}set blockId(t){this._blockId=t}get blockContentId(){return this.blockId}set blockContentId(t){this.blockId=t}get blockColor(){return this._blockColor}set blockColor(t){this._blockColor.copy(t)}get blockContentColor(){return this.blockColor}set blockContentColor(t){this.blockColor=t}get blockScale(){return this._blockScale.clone()}set blockScale(t){this._blockScale.copy(t)}get blockContentScale(){return this.blockScale}set blockContentScale(t){this.blockScale=t}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(t){this._enableBlockScale=t}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(t){this.enableBlockScale=t}get blockRotation(){return this._blockRotation}set blockRotation(t){this._blockRotation=t}get blockContentRotation(){return this.blockRotation}set blockContentRotation(t){this.blockRotation=t}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(t){this._enableBlockRotation=t}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(t){this.enableBlockRotation=t}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(t){this._blockConnectionType=t}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(t){this.blockConnectionType=t}get scale(){return this._scale}set scale(t){this._scale=t}get scaleFactor(){return this.scale}set scaleFactor(t){this.scale=t}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(t){this._overwritePropChanged=t}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(t){this.overwritePropChanged=t}get annotative(){return this._annotative}set annotative(t){this._annotative=t}get breakSize(){return this._breakSize}set breakSize(t){this._breakSize=t}get breakGapSize(){return this.breakSize}set breakGapSize(t){this.breakSize=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(t){this._bottomTextAttachmentType=t}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(t){this.bottomTextAttachmentType=t}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(t){this._topTextAttachmentType=t}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(t){this.topTextAttachmentType=t}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(t){this._extendLeaderToText=t}get unknown2(){return this._unknown2}set unknown2(t){this._unknown2=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeaderStyle"),t.writeInt16(179,this.unknown1),t.writeInt16(170,this.contentType),t.writeInt16(171,this.drawMLeaderOrderType),t.writeInt16(172,this.drawLeaderOrderType),t.writeInt32(90,this.maxLeaderSegmentsPoints),t.writeDouble(40,this.firstSegmentAngleConstraint),t.writeDouble(41,this.secondSegmentAngleConstraint),t.writeInt16(173,this.leaderLineType),t.writeInt32(91,ic(this.leaderLineColor)),t.writeHandle(340,this.leaderLineTypeId),t.writeInt32(92,this.leaderLineWeight),t.writeBoolean(290,this.enableLanding),t.writeDouble(42,this.landingGap),t.writeBoolean(291,this.enableDogleg),t.writeDouble(43,this.doglegLength),t.writeString(3,this.description),t.writeHandle(341,this.arrowSymbolId),t.writeDouble(44,this.arrowSize),t.writeString(300,this.defaultMTextContents),t.writeHandle(342,this.textStyleId),t.writeInt16(174,this.textLeftAttachmentType),t.writeInt16(175,this.textAngleType),t.writeInt16(176,this.textAlignmentType),t.writeInt16(178,this.textRightAttachmentType),t.writeInt32(93,ic(this.textColor)),t.writeDouble(45,this.textHeight),t.writeBoolean(292,this.enableFrameText),t.writeBoolean(297,this.textAlignAlwaysLeft),t.writeDouble(46,this.alignSpace),t.writeHandle(343,this.blockId),t.writeInt32(94,ic(this.blockColor)),t.writeDouble(47,this._blockScale.x),t.writeDouble(49,this._blockScale.y),t.writeDouble(140,this._blockScale.z),t.writeBoolean(293,this.enableBlockScale),t.writeDouble(141,this.blockRotation),t.writeBoolean(294,this.enableBlockRotation),t.writeInt16(177,this.blockConnectionType),t.writeDouble(142,this.scale),t.writeBoolean(295,this.overwritePropChanged),t.writeBoolean(296,this.annotative),t.writeDouble(143,this.breakSize),t.writeInt16(271,this.textAttachmentDirection),t.writeInt16(272,this.bottomTextAttachmentType),t.writeInt16(273,this.topTextAttachmentType),t.writeBoolean(298,this.unknown2),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbMLeaderStyle");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code),r=Number(e.value);switch(n){case 179:this.unknown1=r;break;case 170:this.contentType=r;break;case 171:this.drawMLeaderOrderType=r;break;case 172:this.drawLeaderOrderType=r;break;case 90:this.maxLeaderSegmentsPoints=r;break;case 40:this.firstSegmentAngleConstraint=r;break;case 41:this.secondSegmentAngleConstraint=r;break;case 173:this.leaderLineType=r;break;case 91:this.leaderLineColor=Yt(r);break;case 340:this.leaderLineTypeId=String(e.value);break;case 92:this.leaderLineWeight=r;break;case 290:this.enableLanding=r!==0;break;case 42:this.landingGap=r;break;case 291:this.enableDogleg=r!==0;break;case 43:this.doglegLength=r;break;case 3:this.description=String(e.value);break;case 341:this.arrowSymbolId=String(e.value);break;case 44:this.arrowSize=r;break;case 300:this.defaultMTextContents=String(e.value);break;case 342:this.textStyleId=String(e.value);break;case 174:this.textLeftAttachmentType=r;break;case 175:this.textAngleType=r;break;case 176:this.textAlignmentType=r;break;case 178:this.textRightAttachmentType=r;break;case 93:this.textColor=Yt(r);break;case 45:this.textHeight=r;break;case 292:this.enableFrameText=r!==0;break;case 297:this.textAlignAlwaysLeft=r!==0;break;case 46:this.alignSpace=r;break;case 343:this.blockId=String(e.value);break;case 94:this.blockColor=Yt(r);break;case 47:this._blockScale.x=r;break;case 49:this._blockScale.y=r;break;case 140:this._blockScale.z=r;break;case 293:this.enableBlockScale=r!==0;break;case 141:this.blockRotation=r;break;case 294:this.enableBlockRotation=r!==0;break;case 177:this.blockConnectionType=r;break;case 142:this.scale=r;break;case 295:this.overwritePropChanged=r!==0;break;case 296:this.annotative=r!==0;break;case 143:this.breakSize=r;break;case 271:this.textAttachmentDirection=r;break;case 272:this.bottomTextAttachmentType=r;break;case 273:this.topTextAttachmentType=r;break;case 298:this.unknown2=r!==0;break;case 100:return t.pushBackItem(e),this}}return this}}class Lo extends pt{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new X,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get flags(){return this._flags}set flags(t){this._flags=t}get description(){return this._description}set description(t){this._description=t}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor.copy(t)}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get elementCount(){return this._elements.length}get elements(){return this._elements.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}set elements(t){this._elements=t.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}addElement(t){this._elements.push({offset:t.offset,color:t.color.clone(),lineType:t.lineType})}removeElementAt(t){if(t<0||t>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(t,1)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMlineStyle"),t.writeString(2,this.styleName),t.writeInt16(70,this.flags),t.writeString(3,this.description),t.writeCmColor(this.fillColor),t.writeDouble(51,this.startAngle),t.writeDouble(52,this.endAngle),t.writeInt16(71,this.elementCount),this._elements.forEach(e=>{t.writeDouble(49,e.offset),t.writeCmColor(e.color),t.writeString(6,e.lineType)}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMlineStyle");const e=[];let n,r=0;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 2:this.styleName=String(s.value);break;case 70:this.flags=o;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=o;break;case 52:this.endAngle=o;break;case 71:r=o;break;case 49:{n={offset:o,color:new X,lineType:"BYLAYER"},n.color.colorIndex=256,e.push(n);break}case 62:n?n.color.colorIndex=o:this.fillColor.colorIndex=o;break;case 420:n?n.color.setRGBValue(o):this.fillColor.setRGBValue(o);break;case 6:n&&(n.lineType=String(s.value));break;case 100:return t.pushBackItem(s),this.finishMlineElements(e,r),this}}return this.finishMlineElements(e,r),this}finishMlineElements(t,e){const n=Math.max(e,t.length);if(n<=0){this.elements=[];return}this.elements=Array.from({length:n},(r,s)=>{const a=t[s];if(a)return a;const o=new X;return o.colorIndex=256,{offset:0,color:o,lineType:"BYLAYER"}})}}class hh extends pt{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new C,this._pixelSize=new C(1,1)}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}get classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize.copy(t)}get isLoaded(){return this._isLoaded}set isLoaded(t){this._isLoaded=t}get resolutionUnits(){return this._resolutionUnits}set resolutionUnits(t){this._resolutionUnits=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeInt32(90,this.classVersion),t.writeString(1,this.sourceFileName),t.writePoint2d(10,this.imageSize),t.writeDouble(11,this.pixelSize.x),t.writeDouble(12,this.pixelSize.y),t.writeInt16(280,this.isLoaded?1:0),t.writeInt16(281,this.resolutionUnits),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbRasterImageDef");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code),r=Number(e.value);switch(n){case 1:this.sourceFileName=String(e.value);break;case 90:this.classVersion=r;break;case 10:this.imageSize.x=r;break;case 20:this.imageSize.y=r;break;case 11:this.pixelSize.x=r;break;case 12:this.pixelSize.y=r;break;case 280:this.isLoaded=r!==0;break;case 281:this.resolutionUnits=r;break;case 100:return t.pushBackItem(e),this}}return this}}class uh extends pt{constructor(){super(...arguments),this._entityIds=[]}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbSortentsTable");for(const e of this._entityIds)t.writeObjectId(331,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSortentsTable"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 331:this._entityIds.push(String(e.value));break}}return this}}class Xp extends pt{constructor(t=""){super(),this._rawTags={header:[],body:[]},this._dxfTypeName=t.toUpperCase()}get dxfTypeName(){return this._dxfTypeName}get rawTags(){return this._rawTags}dxfIn(t){const{tags:e,handle:n,ownerId:r,extensionDictionary:s}=Rf(t);return this._rawTags=e,n&&(this.objectId=n),r&&(this.ownerId=r),s&&(this.extensionDictionary=s),t.atExtendedData&&this.dxfInXData(t),this}dxfOut(...t){const[e,n=!1]=t;return Gl(e,this._rawTags,this),n&&this.dxfOutXData(e),this}}const at=i=>i?i.trim().toUpperCase():"";class Yp{constructor(t){this._db=t,this._dictionaries=new Map,this._xrecords=new Map,this._unknownObjectCount=0,this._unknownObjects=[]}get unknownObjectCount(){return this._unknownObjectCount}read(t){for(this._unknownObjectCount=0,this._unknownObjects.length=0;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"){t.readItem();break}t.readItem(),this.readObject(t,n)}this.finishNamedObjectDictionaries(),this.materializeBufferedDictionaries(),this.finishCannoscale(),this.finishAnnoallvisible(),this.finishLayerFilterTree(),this.linkLayoutsToBlockTableRecords(),this._db.objects.layout.numEntries===0&&this._db.createDefaultData({layout:!0})}readObject(t,e){switch(e){case"LAYOUT":{const n=new In;n.dxfIn(t),n.layoutName&&this._db.objects.layout.setAt(n.layoutName,n);break}case"IMAGEDEF":{const n=new hh;n.dxfIn(t),this._db.objects.imageDefinition.setAt(n.objectId,n);break}case"LAYER_FILTER":{const n=new ch;n.dxfIn(t),this._db.objects.layerFilter.setAt(n.objectId,n);break}case"LAYER_INDEX":{const n=new lh;n.dxfIn(t),this._db.objects.layerIndex.setAt(n.objectId,n);break}case"MLEADERSTYLE":{const n=new us;n.dxfIn(t),this._db.objects.mleaderStyle.setAt(n.objectId,n);break}case"MLINESTYLE":{const n=new Lo;n.dxfIn(t),this._db.objects.mlineStyle.setAt(n.styleName||n.objectId,n);break}case"GROUP":{const n=new Pi;n.dxfIn(t);const r=n.objectId||n.description;this._db.objects.group.setAt(r,n);break}case"SORTENTSTABLE":{const n=new uh;n.dxfIn(t),this._db.objects.sortentsTable.setAt(n.objectId,n);break}case"DICTIONARY":case"ACDBDICTIONARYWDFLT":{const n=this.readPersistDictionary(t,e);n.handle&&this._dictionaries.set(at(n.handle),n);break}case"SCALE":{const n=new Pn;n.dxfIn(t);const r=n.scaleName||at(n.objectId);r&&this._db.objects.scale.setAt(r,n);break}case"DICTIONARYVAR":{const n=new xr;n.dxfIn(t);const r=at(n.objectId);r&&this._db.objects.dictionaryVar.setAt(r,n);break}case"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Ue,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_TEXTOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new tr,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_ALDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ANGDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ARCDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_DMDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ORDDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADDIMLGCOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Br,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_HATCHSCALECONTEXTDATA_CLASS":{const n=this.readContextData(t,new Fi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_BLKREFOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Bi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_LEADEROBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new So,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_MLEADEROBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new zi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Fr,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"XRECORD":{const n=new os;n.dxfIn(t);const r=at(n.objectId);if(r){this._db.objects.xrecord.setAt(r,n);const s={handle:r,ownerObjectId:at(n.ownerId),data:n.data?n.data.toArray().map(a=>({code:Number(a.code),value:a.value})):[]};n.extensionDictionary&&(s.extensionDictionaryId=at(n.extensionDictionary)),this._xrecords.set(r,s)}break}default:{this._unknownObjectCount+=1;const n=new Xp(e);n.dxfIn(t),n.objectId&&(n.database=this._db,this._db.registerObjectHandle(n),this._db.addDxfUnknownObject(n),this._unknownObjects.push(n));break}}}readContextData(t,e,n){const r=Hl(t);for(;!t.atEndOfObject&&!t.atEof;){const a=t.readItem();if(!a)break;r.push(as(a))}const s=ve.forReading(new Ao(r),{database:t.database});return e.dxfIn(s),e.dxfRecordName=n,e.setDxfRawTags(Bf(r).tags),e}finishNamedObjectDictionaries(){if(this._dictionaries.size===0)return;let t;for(const s of this._dictionaries.values())if(!s.ownerObjectId||s.ownerObjectId==="0"){t=s;break}if(!(t!=null&&t.handle))return;const e=this._db.objects.dictionary;this.adoptDxfHandle(e,t.handle),e.ownerId="0";const n={ACAD_LAYOUT:this._db.objects.layout,ACAD_GROUP:this._db.objects.group,ACAD_SORTENTS:this._db.objects.sortentsTable,ACAD_MLEADERSTYLE:this._db.objects.mleaderStyle,ACAD_MLINESTYLE:this._db.objects.mlineStyle,ACAD_SCALELIST:this._db.objects.scale,ISM_RASTER_IMAGE_DICT:this._db.objects.imageDefinition,MLIGHT_XRECORD:this._db.objects.xrecord},r=this.collectLoadedObjectsByHandle();for(const[s,a]of Object.entries(t.entries)){const o=n[s.toUpperCase()];if(!o)continue;this.adoptDxfHandle(o,a),o.ownerId=t.handle,e.setAt(s,o);const c=this._dictionaries.get(at(a));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(at(h));if(!u)continue;const d=at(u.objectId);let g;for(const[f,p]of o.entries())if(at(p.objectId)===d){g=f;break}if(o===this._db.objects.mleaderStyle&&g!=null&&g!==l&&at(g)===d&&!o.getAt(l)){o.remove(g),o.setAt(l,u);continue}if(o===this._db.objects.group&&u instanceof Pi&&g!=null&&g!==l&&!o.getAt(l)){o.remove(g),o.setAt(l,u),u.name=l;continue}if(o===this._db.objects.group&&u instanceof Pi&&g==null){o.setAt(l,u),u.name=l;continue}!o.getAt(l)&&g==null&&o.setAt(l,u)}}}adoptDxfHandle(t,e){if(at(t.objectId)===at(e))return;const n=this._db.getObjectById(e);if(n&&n!==t){const s=this._db.generateUniqueHandle();if(this._db.releaseObjectHandle(n),n.objectId=s,this._db.registerObjectHandle(n),n instanceof G)for(const[,a]of n.entries())a.ownerId===e&&(a.ownerId=s)}const r=t.objectId;this._db.releaseObjectHandle(t),t.objectId=e,this._db.registerObjectHandle(t);for(const[,s]of t.entries())s.ownerId===r&&(s.ownerId=e)}collectLoadedObjectsByHandle(){const t=new Map,e=n=>{const r=at(n.objectId);r&&t.set(r,n)};for(const[,n]of this._db.objects.layout.entries())e(n);for(const[,n]of this._db.objects.group.entries())e(n);for(const[,n]of this._db.objects.sortentsTable.entries())e(n);for(const[,n]of this._db.objects.imageDefinition.entries())e(n);for(const[,n]of this._db.objects.mleaderStyle.entries())e(n);for(const[,n]of this._db.objects.mlineStyle.entries())e(n);for(const[,n]of this._db.objects.layerFilter.entries())e(n);for(const[,n]of this._db.objects.layerIndex.entries())e(n);for(const[,n]of this._db.objects.xrecord.entries())e(n);for(const[,n]of this._db.objects.scale.entries())e(n);for(const[,n]of this._db.objects.dictionaryVar.entries())e(n);for(const[,n]of this._db.objects.objectContextData.entries())e(n);for(const n of this._unknownObjects)e(n);return t}materializeBufferedDictionaries(){if(this._dictionaries.size===0)return;const t=new Map;for(const a of this._db.getRootDictionaries()){const o=at(a.objectId);o&&(t.set(o,a),this._db.registerObjectHandle(a))}const e=new Map;for(const[a,o]of this._dictionaries){const c=this._db.getObjectById(a)??t.get(a);if(c instanceof G){e.set(a,c);continue}const l=new G(this._db);this._db.releaseObjectHandle(l),l.objectId=a,l.ownerId=o.ownerObjectId||"0",o.defaultId&&(l.defaultId=o.defaultId),o.extensionDictionaryId&&(l.extensionDictionary=o.extensionDictionaryId),this._db.registerObjectHandle(l),e.set(a,l)}const n=this.collectLoadedObjectsByHandle();for(const[a,o]of e)n.set(a,o);for(const[a,o]of this._dictionaries){const c=e.get(a);if(c)for(const[l,h]of Object.entries(o.entries)){const u=n.get(at(h));if(!u||c.getAt(l))continue;const d=at(u.objectId);let g=!1;for(const[,f]of c.entries())if(at(f.objectId)===d){g=!0;break}if(!g)try{c.setAt(l,u)}catch{}}}let r;for(const a of this._dictionaries.values())if(!a.ownerObjectId||a.ownerObjectId==="0"){r=a;break}if(!(r!=null&&r.handle))return;const s=this._db.objects.dictionary;for(const[a,o]of Object.entries(r.entries)){if(s.getAt(a))continue;const c=n.get(at(o));if(c instanceof G)try{s.setAt(a,c)}catch{}}}finishCannoscale(){const e=this._db.objects.dictionary.getAt("AcDbVariableDictionary");if(!(e instanceof G))return;const n=e.getAt("CANNOSCALE");n instanceof xr&&n.value&&(this._db.cannoscale=n.value)}finishAnnoallvisible(){const e=this._db.objects.dictionary.getAt("AcDbVariableDictionary");if(!(e instanceof G))return;const n=e.getAt("ANNOALLVISIBLE");if(!(n instanceof xr)||n.value==null)return;const r=String(n.value).trim();this._db.annoallvisible=r!=="0"&&r.toLowerCase()!=="false"}readPersistDictionary(t,e){const n={handle:"",ownerObjectId:"",entries:{}};let r,s=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const a=t.readItem();if(!a)break;const o=Number(a.code);switch(o){case 5:n.handle=String(a.value);break;case 330:n.ownerObjectId=String(a.value);break;case 100:s=String(a.value)==="AcDbDictionaryWithDefault";break;case 280:case 281:break;case 3:r=String(a.value);break;case 350:case 340:case 360:{const c=at(String(a.value));o===340&&(s||e==="ACDBDICTIONARYWDFLT")&&!r?n.defaultId=c:r?(n.entries[r]=c,r=void 0):o===360&&!n.extensionDictionaryId&&(n.extensionDictionaryId=c);break}}}return n.handle=at(n.handle),n.ownerObjectId=at(n.ownerObjectId),n.extensionDictionaryId&&(n.extensionDictionaryId=at(n.extensionDictionaryId)),n}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=Cp({dictionaries:this._dictionaries,xrecords:this._xrecords});t.root.getNestedFilters().length>0&&(this._db.layerFilters=t),this._dictionaries.clear(),this._xrecords.clear()}linkLayoutsToBlockTableRecords(){const t=this._db.tables.blockTable,e=lt.MODEL_SPACE_NAME.toUpperCase();for(const[,n]of this._db.objects.layout.entries()){if(n.layoutName==="Model"){const a=t.modelSpace;n.blockTableRecordId=a.objectId,a.layoutId=n.objectId;continue}const r=at(n.objectId);let s=!1;for(const a of t.newIterator())if(at(a.layoutId)===r){n.blockTableRecordId=a.objectId,s=!0;break}if(!s&&n.blockTableRecordId){const a=t.getIdAt(n.blockTableRecordId);a&&(a.layoutId=n.objectId)}else if(!s){for(const a of t.newIterator())if(a.isPaperSapce&&a.name.toUpperCase()!==e&&!a.layoutId){n.blockTableRecordId=a.objectId,a.layoutId=n.objectId;break}}}}}class Mo{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap=new Map,this._yieldGate=new ho(this._options.yieldBudgetMs??Cr)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap.clear(),this._openInsert=void 0,t.database=this._db;!t.atEof;){const e=t.readItem();if(!e)break;if(Number(e.code)!==0)continue;const n=String(e.value).toUpperCase();if(n==="EOF")break;if(n==="SECTION"){const r=this.readSectionName(t);await this.readSection(t,r);continue}}return this.flushRemainingAttributes(),{unknownEntityCount:this._unknownEntityCount,unknownObjectCount:this._unknownObjectCount}}readSectionName(t){const e=t.readItem();return e&&Number(e.code)===2?String(e.value).toUpperCase():(e&&t.pushBackItem(e),"")}async readSection(t,e){switch(e){case"HEADER":Ip(t,this._db),await this.reportParseProgress(t);break;case"CLASSES":this.readClassesSection(t),await this.reportParseProgress(t);break;case"TABLES":this.readTablesSection(t),await this.reportParseProgress(t);break;case"BLOCKS":await this.readBlocksSection(t),await this.reportParseProgress(t);break;case"ENTITIES":await this.readEntitiesSection(t),await this.reportParseProgress(t);break;case"OBJECTS":{const n=new Yp(this._db);n.read(t),this._unknownObjectCount+=n.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(_w(t)),await this.reportParseProgress(t);break;case"THUMBNAILIMAGE":this.readThumbnailImageSection(t),await this.reportParseProgress(t);break;default:this.skipUntilEndSec(t),await this.reportParseProgress(t);break}}applyAcdsDataToSolids(t){const e=Object.keys(t.byOwnerHandle);if(e.length===0)return;const n=new Map;for(const r of this._db.tables.blockTable.newIterator())for(const s of r.newIterator())s instanceof Xr&&n.set(Gc(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const a=n.get(Gc(r));a&&a.setSabBytes(s)}}readThumbnailImageSection(t){let e=0;const n=[];for(;!t.atEof;){const s=t.readItem();if(!s)break;if(Number(s.code)===0){if(String(s.value).toUpperCase()==="ENDSEC")break;t.pushBackItem(s);break}Number(s.code)===90?e=Number(s.value)||0:Number(s.code)===310&&(s.value instanceof Uint8Array?n.push(s.value):n.push(String(s.value)))}if(n.length===0)return;const r=cs(n);!r||r.length===0||(this._db.thumbnailImage=e>0&&r.length>e?r.subarray(0,e):r)}readClassesSection(t){const e=[];for(;!t.atEof;){const n=t.peekItem();if(!n)break;if(Number(n.code)!==0){t.readItem();continue}const r=String(n.value).toUpperCase();if(r==="ENDSEC"){t.readItem();break}if(r==="CLASS"){t.readItem();const s=this.readClassRecord(t);(s.name||s.cppClassName)&&e.push(s);continue}t.readItem(),t.skipToEndOfObject()}e.length>0&&(this._db.classes=e)}readClassRecord(t){const e={name:"",cppClassName:"",appName:"",proxyFlag:0,instanceCount:0,wasProxy:!1,isEntity:!1};for(;!t.atEndOfObject&&!t.atEof;){const n=t.readItem();if(!n)break;switch(Number(n.code)){case 1:e.name=String(n.value);break;case 2:e.cppClassName=String(n.value);break;case 3:e.appName=String(n.value);break;case 90:e.proxyFlag=Number(n.value);break;case 91:e.instanceCount=Number(n.value);break;case 280:e.wasProxy=Number(n.value)!==0;break;case 281:e.isEntity=Number(n.value)!==0;break}}return e}readTablesSection(t){for(;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"){t.readItem();break}if(n==="TABLE"){t.readItem();const r=this.readTableName(t);this.readTable(t,r);continue}t.readItem(),t.skipToEndOfObject()}this.resolveDimStyleHandles(),this._db.ensureTextStyleDefaults()}resolveDimStyleHandles(){const{textStyleTable:t,blockTable:e,dimStyleTable:n}=this._db.tables,r=(s,a)=>{if(!s||a.getAt(s))return;const o=a.getIdAt(s);return o?o.name:/^[0-9A-F]+$/i.test(s)?"":void 0};for(const s of n.newIterator()){const a=r(s.dimtxsty,t);a!=null&&(s.dimtxsty=a||Vt.DEFAULT_DIM_VALUES.dimtxsty||"");const o=r(s.dimldrblk,e);o!=null&&(s.dimldrblk=o);const c=r(s.dimblk,e);c!=null&&(s.dimblk=c);const l=r(s.dimblk1,e);l!=null&&(s.dimblk1=l);const h=r(s.dimblk2,e);h!=null&&(s.dimblk2=h)}}readTableName(t){for(;!t.atEof;){const e=t.peekItem();if(!e)return"";const n=Number(e.code);if(n===0)return"";if(t.readItem(),n===2)return String(e.value).toUpperCase()}return""}readTable(t,e){switch(e){case"LAYER":this.readNamedTable(t,"LAYER",()=>new ls,n=>{n.name&&this._db.tables.layerTable.add(n)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new vn,n=>{n.name&&this._db.tables.linetypeTable.add(n)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new Eo,n=>{this._db.tables.textStyleTable.add(n)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Vt,n=>{n.name&&this._db.tables.dimStyleTable.add(n)});break;case"VPORT":this.readNamedTable(t,"VPORT",()=>new An,n=>{n.name&&this._db.tables.viewportTable.add(n)});break;case"APPID":this.readNamedTable(t,"APPID",()=>new _r,n=>{n.name&&this._db.tables.appIdTable.add(n)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new Pp,n=>{n.name&&this._db.tables.viewTable.add(n)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new Sp,n=>{n.name&&this._db.tables.ucsTable.add(n)});break;case"BLOCK_RECORD":this.readBlockRecordTable(t);break;default:this.skipUntilEndTab(t);break}}readNamedTable(t,e,n,r){for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDTAB"){t.readItem();break}if(a==="ENDSEC")break;if(a===e){t.readItem();const o=n();o.dxfIn(t),r(o);continue}t.readItem(),t.skipToEndOfObject()}}readBlockRecordTable(t){let e=!1;for(;!t.atEof;){const n=t.peekItem();if(!n)break;if(Number(n.code)!==0){t.readItem();continue}const r=String(n.value).toUpperCase();if(r==="ENDTAB"){t.readItem();break}if(r==="ENDSEC")break;if(r==="BLOCK_RECORD"){t.readItem(),e||(this._db.tables.blockTable.removeAll(),e=!0);const s=new lt;s.dxfIn(t),s.name&&this._db.tables.blockTable.add(s);continue}t.readItem(),t.skipToEndOfObject()}}skipUntilEndTab(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDTAB")break}}async readBlocksSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let n=0;for(;!t.atEof;){const r=t.peekItem();if(!r)break;if(Number(r.code)!==0){t.readItem();continue}const s=String(r.value).toUpperCase();if(s==="ENDSEC"){t.readItem();break}if(s==="BLOCK"){t.readItem(),n=await this.readBlockDefinition(t,e,n);continue}t.readItem(),t.skipToEndOfObject()}}async readBlockDefinition(t,e,n){const r=this.readBlockBeginFields(t),s=this.ensureBlockTableRecord(r);for(this._openInsert=void 0;!t.atEof;){const a=t.peekItem();if(!a)break;if(Number(a.code)!==0){t.readItem();continue}const o=String(a.value).toUpperCase();if(o==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(o==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,o)){this._openInsert=void 0,n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t));continue}const c=xl(t,o);c?(this.countUnknownEntity(c),this.shouldAcceptBlockEntity(s)?this.acceptEntity(c,s):this._openInsert=void 0):(this._openInsert=void 0,t.skipToEndOfObject()),n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t))}return n}shouldAcceptBlockEntity(t){return!(t.isModelSapce||Mo.isActivePaperSpaceName(t.name))}static isActivePaperSpaceName(t){return t.toLowerCase()===lt.PAPER_SPACE_NAME_PREFIX.toLowerCase()}consumeSeqend(t,e){return e!=="SEQEND"?!1:(t.skipToEndOfObject(),!0)}readBlockBeginFields(t){const e=new x;let n="",r=0,s="",a="",o,c;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code);if(h===100)continue;const u=Number(l.value);switch(h){case 5:o=String(l.value);break;case 330:c=String(l.value);break;case 2:case 3:n||(n=String(l.value));break;case 70:r=u;break;case 10:e.x=u;break;case 20:e.y=u;break;case 30:e.z=u;break;case 1:s=String(l.value);break;case 4:a=String(l.value);break}}return{name:n,flags:r,origin:e,pathName:s,comments:a,objectId:o,ownerId:c}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new lt,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin),t.comments&&(e.comments=t.comments);let n=lt.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(n&(pr.Xref|pr.XrefOverlay))===0&&(n=n|pr.Xref)),e.flags=n,e}async readEntitiesSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let n=0;const r=this._db.tables.blockTable.modelSpace;for(this._openInsert=void 0;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,a)){this._openInsert=void 0,n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t));continue}const o=xl(t,a);o?(this.countUnknownEntity(o),this.acceptEntity(o,this.resolveEntityOwner(o,r))):(this._openInsert=void 0,t.skipToEndOfObject()),n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t))}}resolveEntityOwner(t,e){const n=t.getAttrWithoutException("ownerId");if(n){const r=this._db.tables.blockTable.getIdAt(n);if(r&&(r.isModelSapce||r.isPaperSapce))return r}if(t.dxfPaperSpace){const r=this._db.tables.blockTable.getAt(lt.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Vr){const n=this._openInsert;if(n){n.appendAttributes(t);return}this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),this._openInsert=t instanceof Qt?t:void 0,t instanceof Qt){const n=this._attributeMap.get(t.objectId);if(n&&n.length>0){for(const r of n)t.appendAttributes(r);this._attributeMap.delete(t.objectId)}}}countUnknownEntity(t){t instanceof Gr&&(this._unknownEntityCount+=1)}linkOrDeferAttribute(t,e){const n=t.getAttrWithoutException("ownerId");if(!n||n==="0")return;const r=e.getIdAt(n)??this._db.tables.blockTable.getEntityById(n);if(r instanceof Qt){r.appendAttributes(t);return}let s=this._attributeMap.get(n);s||(s=[],this._attributeMap.set(n,s)),s.push(t)}flushRemainingAttributes(){for(const[t,e]of this._attributeMap){const n=this._db.tables.blockTable.getEntityById(t);if(n instanceof Qt)for(const r of e)n.appendAttributes(r)}this._attributeMap.clear()}skipUntilEndSec(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDSEC")break}}async reportParseProgress(t){const{onProgress:e,totalBytes:n}=this._options;if(!e||!n||n<=0)return;const r=Math.min(1,Math.max(0,t.position().byteOffset/n));await e(r)}async yieldAndReportProgress(t){await this.reportParseProgress(t),await this._yieldGate.maybeYield(Zi)}}const Is=1,oc=18,Es=20,Ts=98;class jp extends sh{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,n={}){const{minimumChunkSize:r=10,progress:s,encoding:a}=n;this.progress=s;const o=async(l,h,u,d)=>{s&&await s(l,h,u,d)};await o(0,"START","START"),await o(Is,"PARSE","START"),await Zd(),e.beginEventBatch();let c=!0;try{const l=ve.fromBuffer(t,{database:e,encoding:a}),h=t.byteLength;let u=Is;const g=await new Mo(e,{entityBatchSize:Math.max(1,r||200),yieldBudgetMs:Cr,totalBytes:h,onProgress:async y=>{const b=Math.min(oc-1,Is+Math.floor(y*(oc-Is)));b<=u||(u=b,await o(b,"PARSE","IN-PROGRESS"))}}).read(l);await o(oc,"PARSE","END",{unknownEntityCount:g.unknownEntityCount}),await o(Es,"ENTITY","START");const f=Math.max(1,r||200);let p=Es;const m=new ho(Cr);await e.endEventBatchChunked(f,async(y,b)=>{const _=b<=0?Ts:Math.min(Ts,Es+Math.floor(y/b*(Ts-Es)));_>p&&(p=_,await o(_,"ENTITY","IN-PROGRESS")),await m.maybeYield()}),c=!1,await o(Ts,"ENTITY","END"),await o(100,"END","END")}catch(l){throw c&&e.endEventBatch(),l}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}}var wr=(i=>(i.DXF="dxf",i.DWG="dwg",i))(wr||{});class Ce{constructor(){this.events={registered:new vt,unregistered:new vt},this._converters=new Map,this.register("dxf",new jp)}static createInstance(){return Ce._instance==null&&(Ce._instance=new Ce),this._instance}static get instance(){return Ce._instance||(Ce._instance=new Ce),Ce._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}const $c=50,Iw=tt.DEFAULT_CIRCLE_SIDES,Ew=1e3;function ds(i){var e;const t=Vp((e=i==null?void 0:i.context)==null?void 0:e.database);return{circleSides:t,maxSegments:t}}function Vp(i){if(i!=null&&typeof i=="object"){const t=i.drawCircleSides;if(typeof t=="number"&&Number.isFinite(t))return tt.resolveCircleSides(t)}return tt.DEFAULT_CIRCLE_SIDES}function Tw(i){var n,r,s;if(i==null||typeof i!="object")return tt.DEFAULT_CIRCLE_SIDES;const t=i.tables,e=(s=(r=(n=t==null?void 0:t.viewportTable)==null?void 0:n.getActiveVport)==null?void 0:r.call(n))==null?void 0:s.circleSides;return typeof e!="number"||!Number.isFinite(e)?tt.DEFAULT_CIRCLE_SIDES:tt.resolveCircleSides(e)}const cc=new C,_i=class _i extends Ot{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._elevation=0,this._geo=new ot}get dxfTypeName(){return"LWPOLYLINE"}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}addVertexAt(t,e,n=0,r=-1,s=-1){const a=r<0?void 0:r,o=s<0?void 0:s,c={x:e.x,y:e.y,bulge:n,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}removeVertexAt(t){this._geo.removeVertexAt(t)}reset(t,e){this._geo.reset(t,e)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return this.ocsPointToWcs(e.x,e.y)}get geometricExtents(){const t=this._geo.box;return t.isEmpty()?new H:new H().setFromPoints([this.ocsPointToWcs(t.min.x,t.min.y),this.ocsPointToWcs(t.max.x,t.min.y),this.ocsPointToWcs(t.max.x,t.max.y),this.ocsPointToWcs(t.min.x,t.max.y)])}ocsPointToWcs(t,e){return ce({x:t,y:e,z:this._elevation},this._normal)}subGetIntersectCurves(){return rh(this._geo.vertices,this.closed,this._elevation,this._normal)}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return this.shouldIncludeSegmentMidpointGrips()&&this.appendSegmentMidpointGrips(t),t}subMoveGripPointsAt(t,e){const n=this.numberOfVertices,r=this.shouldIncludeSegmentMidpointGrips(),s=r?this.getSegmentCount():0,a=Zt(e,this._normal);return Et(t,o=>{if(o<n){yr(this._geo.vertices,o,a);return}if(!r||o>=n+s)return;const c=o-n;yr(this._geo.vertices,c,a),yr(this._geo.vertices,(c+1)%n,a)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=wt.instance().getVar(E.GRIPS,this.database);return typeof t=="number"?t:2}catch{return 2}}getSegmentCount(){const t=this.numberOfVertices;return t<2?0:this.closed?t:t-1}appendSegmentMidpointGrips(t){var a;const e=this._geo,n=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let o=0;o<r;o++){const c=[];Yr(e.getPointAt(o),e.getPointAt((o+1)%s),(a=e.vertices[o])==null?void 0:a.bulge,n,T.MidPoint,{x:0,y:0,z:0},c);for(const l of c)t.push(this.ocsPointToWcs(l.x,l.y))}}subGetOsnapPoints(t,e,n,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case T.EndPoint:for(let l=0;l<o;l++)r.push(this.getPoint3dAt(l));break;case T.MidPoint:case T.Nearest:case T.Perpendicular:case T.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Yr(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d);for(const g of d)h.push(this.ocsPointToWcs(g.x,g.y))}if(t===T.MidPoint)r.push(...h);else{const u=ye(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let n=this._elevation;return this._geo.vertices.forEach(r=>{const s=new x(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,n=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=n,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]},{groupName:"others",properties:[{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}get directBatchPrimitive(){return this.hasRenderableWidth()?null:"lineStrip"}subWorldDraw(t){const e=ds(t),n=this._geo.tessellate(e),r=this.createWidthProfile(e);if(r!=null){if(this.closed||Up(gh(r,!1))){const c=Lw(r);if(c!=null){const l=t.subEntityTraits;return l.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.offsetRing(c.outer.map(h=>this.ocsPointToWcs(h.x,h.y)),c.inner.map(h=>this.ocsPointToWcs(h.x,h.y)))}}const o=Mw(r,this.closed);if(o!=null){const c=t.subEntityTraits,l=c.fillType;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const h=o.map(d=>(this.mapAreaLoopsToWcs(d),t.area(d)));c.fillType=l;const u=r.map(d=>this.ocsPointToWcs(d.x,d.y));return this.closed&&u.length>=2&&u.push(u[0]),u.length>=2&&h.push(t.lines(u)),h.length===1?h[0]:t.group(h)}}const s=[];return n.forEach(a=>s.push(this.ocsPointToWcs(a.x,a.y))),t.lines(s)}mapAreaLoopsToWcs(t){if(!(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)){for(const e of t.loops)if("vertices"in e)for(const n of e.vertices){const r=this.ocsPointToWcs(n.x,n.y);n.x=r.x,n.y=r.y}}}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0);const e=this.resolveConstantWidth();e!=null&&t.writeDouble(43,e),t.writeDouble(38,this.elevation),this.thickness!==0&&t.writeDouble(39,this.thickness);const n=this._geo.vertices;for(let r=0;r<n.length;++r){const s=n[r];t.writePoint2d(10,this.getPoint2dAt(r)),e==null&&(s.startWidth!=null&&t.writeDouble(40,s.startWidth),s.endWidth!=null&&t.writeDouble(41,s.endWidth));const a=s.bulge??0;a!==0&&t.writeDouble(42,a),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,a;t.writeHandle(5,this.objectId),this.dxfOutExtensionDictionary(t),t.writeObjectId(330,this.ownerId),t.writeSubclassMarker("AcDbEntity"),t.writeString(8,this.layer),t.writeString(6,this.lineType),t.writeDouble(48,this.linetypeScale),t.writeInt16(60,this.visibility?0:1),t.writeCmColor(this.color),t.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency);const n=(r=this.database)==null?void 0:r.tables.blockTable.getIdAt(this.ownerId);n!=null&&n.isPaperSapce&&t.writeInt16(67,1),t.writeSubclassMarker("AcDb2dPolyline"),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,this.closed?1:0),t.writeDouble(10,0),t.writeDouble(20,0),t.writeDouble(30,this.elevation),e&&this.dxfOutXData(t);for(let o=0;o<this.numberOfVertices;++o){const c=this._geo.vertices[o];t.writeStart("VERTEX"),t.writeHandle(5,(s=this.database)==null?void 0:s.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:this.getPoint2dAt(o).x,y:this.getPoint2dAt(o).y,z:this.elevation});const l=(c==null?void 0:c.bulge)??0;l!==0&&t.writeDouble(42,l),t.writeInt16(70,0)}return t.writeStart("SEQEND"),t.writeHandle(5,(a=this.database)==null?void 0:a.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPolyline"),this.reset(!1);let e=!1,n=this.elevation,r=this.thickness,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,f=-1,p,m=0;const y=()=>{if(!u)return;const b=g<0?c:g,_=f<0?c:f;if(cc.x=l,cc.y=h,this.addVertexAt(m++,cc,d,b,_),p!=null){const w=this._geo.vertices[m-1];w&&(w.identifier=p)}u=!1,d=0,g=-1,f=-1,p=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),w=Number(b.value);switch(_){case 90:break;case 70:e=(w&1)!==0;break;case 43:c=w;break;case 38:n=w;break;case 39:r=w;break;case 10:y(),l=w,h=0,u=!0;break;case 20:h=w;break;case 40:g=w;break;case 41:f=w;break;case 42:d=w;break;case 91:p=w;break;case 210:s=w;break;case 220:a=w;break;case 230:o=w;break}}return y(),this.closed=e,this.elevation=n,this.thickness=r,s*s+a*a+o*o>0&&this.normal.set(s,a,o).normalize(),this}resolveConstantWidth(){const t=this._geo.vertices;if(t.length===0)return;let e;for(const n of t){const r=n.startWidth,s=n.endWidth;if(r==null&&s==null){if(e!=null&&e!==0)return;e=e??0;continue}const a=r??0;if(a!==(s??0))return;if(e==null)e=a;else if(e!==a)return}return e!=null&&e!==0?e:void 0}hasRenderableWidth(){const t=this._geo.vertices;for(let e=0;e<t.length;e++){const n=Math.max(0,t[e].startWidth??0),r=Math.max(0,t[e].endWidth??0);if(n>It||r>It)return!0}return!1}createWidthProfile(t){const e=this._geo.vertices,n=e.length;if(n<2)return null;const r=this.closed?n:n-1,s=[];let a=!1;for(let o=0;o<r;o++){const c=e[o],l=e[(o+1)%n],h=Math.max(0,c.startWidth??0),u=Math.max(0,c.endWidth??0);(h>It||u>It)&&(a=!0);const d=this.sampleSegment(c,l,t),g=d.length-1;for(let f=0;f<=g;f++){if(f===0&&s.length>0||this.closed&&o===r-1&&f===g)continue;const p=g>0?f/g:0;s.push({x:d[f].x,y:d[f].y,width:Fw(h,u,p)})}}return a&&s.length>=2?s:null}sampleSegment(t,e,n){if(t.bulge&&Math.abs(t.bulge)>It){const s=new tt(t,e,t.bulge).tessellate(n);if(s.length>1)return s.map(a=>new C(a.x,a.y))}return[new C(t.x,t.y),new C(e.x,e.y)]}static from2dPoints(t,e){const n=new _i;return t.forEach((r,s)=>n.addVertexAt(s,r)),n.closed=e,n}static fromGePolyline(t){const e=new _i;return t.vertices.forEach((n,r)=>{e.addVertexAt(r,new C(n.x,n.y),n.bulge??0)}),e.closed=t.closed,e}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.numberOfVertices;let n=1/0,r=1;const s=this.closed?e:e-1;for(let a=0;a<s;a++){const o=this.getPoint2dAt(a),c=this.getPoint2dAt((a+1)%e),l=c.x-o.x,h=c.y-o.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*h)/u)),g=(t.x-o.x-d*l)**2+(t.y-o.y-d*h)**2;g<n&&(n=g,r=l*(t.y-o.y)-h*(t.x-o.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:_i.fromGePolyline(e[0])}};_i.typeName="Polyline";let Ut=_i;function Co(i,t,e){const n=_b(i,t,e);return n?Ut.fromGePolyline(n):null}const It=1e-6,fd=4;function Lw(i){const t=gh(i,!0);if(t.length<2)return null;const{left:e,right:n}=dh(t,!0),r=Wi(e),s=Wi(n);if(!$n(r)||!$n(s)||r.length!==s.length)return null;const a=Math.abs(Wn(r)),o=Math.abs(Wn(s)),[c,l]=a>=o?[r,s]:[s,r];return{outer:c,inner:l}}function Mw(i,t){if(i.length<2)return null;if(t){const r=pd(i,!0);return r?[r]:null}const e=Cw(i),n=[];for(const r of e){const s=pd(r,!1);s!=null&&n.push(s)}return n.length>0?n:null}function pd(i,t){const e=gh(i,t);if(e.length<2)return null;const{left:n,right:r}=dh(e,t);if(yd(n)<2||yd(r)<2)return null;const s=new de;if(t){const a=Wi(n),o=Wi(r),c=$n(a),l=$n(o);if(!c&&!l)return null;if(!c||!l)return s.add(new ot(c?a:o,!0)),s;const h=Math.abs(Wn(a)),u=Math.abs(Wn(o)),[d,g]=h>=u?[a,o]:[o,a];return s.add(new ot(d,!0)),s.add(new ot(g,!0)),s}return Up(e)&&Dw(s,e)||Rw(s,n,r)?s:null}function Cw(i){if(i.length<2)return[i];const t=[];let e=0;const n=new Map;for(let s=0;s<i.length;s++){const a=md(i[s]),o=n.get(a);if(o!=null&&s-o>1){const c=i.slice(e,s+1);if(c.length>=2&&t.push(c),o===e&&s===i.length-1)return t.length>0?t:[i];e=o,n.clear();for(let l=e;l<=s;l++)n.set(md(i[l]),l);continue}n.set(a,s)}const r=i.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[i]}function md(i){return`${i.x.toFixed(4)}:${i.y.toFixed(4)}`}function Ow(i,t){const e=Math.max(i,t),n=Math.min(i,t);return e<=It?!1:e-n>It}function Up(i){if(i.length<3)return!1;const t=i[0],e=i[i.length-1],n=Math.hypot(e.x-t.x,e.y-t.y);if(n<=It)return!0;const r=Math.max(...i.map(s=>s.width));return r<=It?!1:n<=r*4}function Dw(i,t){const{left:e,right:n}=dh(t,!0),r=Wi(e),s=Wi(n);if(!$n(r)||!$n(s))return!1;const a=Math.abs(Wn(r)),o=Math.abs(Wn(s));if(!Ow(a,o))return!1;const[c,l]=a>=o?[r,s]:[s,r];return i.add(new ot(c,!0)),i.add(new ot(l,!0)),!0}function dh(i,t){const e=new Array(i.length),n=new Array(i.length);for(let r=0;r<i.length;r++){const s=i[r],a=Math.max(0,s.width)/2;if(a<=It){e[r]={x:s.x,y:s.y},n[r]={x:s.x,y:s.y};continue}const o=Bw(i,r,t);if(o==null){e[r]=null,n[r]=null;continue}e[r]={x:s.x+o.x*a,y:s.y+o.y*a},n[r]={x:s.x-o.x*a,y:s.y-o.y*a}}return{left:e,right:n}}function Nw(i,t,e,n,r){const s=[t,e,n,r];return $n(s)?(i.add(new ot(s,!0)),!0):!1}function Rw(i,t,e){let n=!1;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=e[r],c=e[r+1];s==null||a==null||o==null||c==null||Nw(i,s,a,c,o)&&(n=!0)}return n}function yd(i){return i.reduce((t,e)=>e==null?t:t+1,0)}function Wi(i){return i.filter(t=>t!=null)}function gh(i,t){const e=[];if(i.forEach(n=>{const r=e[e.length-1];(!r||Math.abs(r.x-n.x)>It||Math.abs(r.y-n.y)>It||Math.abs(r.width-n.width)>It)&&e.push(n)}),t&&e.length>1){const n=e[0],r=e[e.length-1];Math.abs(n.x-r.x)<=It&&Math.abs(n.y-r.y)<=It&&e.pop()}return e}function Bw(i,t,e){const n=i.length,r=i[t],s=i[(t-1+n)%n],a=i[(t+1)%n];let o=bd(r.x-s.x,r.y-s.y),c=bd(a.x-r.x,a.y-r.y);if(e||(t===0&&(o=c),t===n-1&&(c=o)),o==null&&c==null)return null;if(o==null)return Ls(c);if(c==null)return Ls(o);const l=Ls(o),h=Ls(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=It)return h;const f={x:u/g,y:d/g},p=Math.abs(f.x*h.x+f.y*h.y),m=p<=It?fd:Math.min(1/p,fd);return{x:f.x*m,y:f.y*m}}function bd(i,t){const e=Math.hypot(i,t);return e<=It?null:{x:i/e,y:t/e}}function Ls(i){return{x:-i.y,y:i.x}}function Wn(i){let t=0;const e=i.length;for(let n=0;n<e;n++){const r=i[n],s=i[(n+1)%e];t+=r.x*s.y-s.x*r.y}return t/2}function $n(i){return i.length>=3&&Math.abs(Wn(i))>It}function Fw(i,t,e){return i+(t-i)*e}const zw={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:23},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:24}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:26}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:28},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:29}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:31},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:32}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:34},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:35},{angle:45,originX:.353553391,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:36},{angle:45,originX:.530330086,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:37}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:39},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.3125,-.0625,0,-.0625],sourceLine:40}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:.21875,deltaY:.125,dashes:[.3125,-.0625,0,-.0625],sourceLine:42}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:45}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:47},{angle:135,originX:0,originY:0,deltaX:.25,deltaY:.125,dashes:[.3125,-.1875],sourceLine:48}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:54},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[8,-8],sourceLine:55}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:57},{angle:0,originX:-8,originY:.375,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:58},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:59},{angle:90,originX:-.375,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:60}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:62},{angle:90,originX:0,originY:0,deltaX:8,deltaY:4,dashes:[8,-8],sourceLine:63}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:65},{angle:0,originX:0,originY:2.25,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:66},{angle:0,originX:2,originY:2.667,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:67},{angle:0,originX:2,originY:4.917,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:68},{angle:90,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:69},{angle:90,originX:-.375,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:70},{angle:90,originX:2,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:71},{angle:90,originX:1.625,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:72}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:2.667,dashes:[],sourceLine:74},{angle:90,originX:0,originY:0,deltaX:2.667,deltaY:4,dashes:[2.667,-2.667],sourceLine:75}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:77},{angle:355,originX:0,originY:0,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:78},{angle:100.45144446,originX:.59771681,originY:-.05229344,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.63740192,-7.01142112],sourceLine:79},{angle:46.1842,originX:0,originY:2,deltaX:6.19462554,deltaY:-8.84684596,dashes:[1.125,-12.375],sourceLine:80},{angle:96.63563549,originX:.88936745,originY:1.86206693,deltaX:8.59588239,deltaY:-10.40964966,dashes:[.95610342,-10.5171376],sourceLine:81},{angle:351.18416399,originX:0,originY:2,deltaX:7.74327494,deltaY:11.05855746,dashes:[.9,-9.90000001],sourceLine:82},{angle:21,originX:1,originY:1.5,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:83},{angle:326,originX:1,originY:1.5,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:84},{angle:71.45144474,originX:1.49742254,originY:1.16448426,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.6374019,-7.01142112],sourceLine:85},{angle:37.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-6.52,0,-6.7,0,-6.625],sourceLine:86},{angle:7.5,originX:0,originY:0,deltaX:3.123,deltaY:3.567,dashes:[0,-3.82,0,-6.37,0,-2.525],sourceLine:87},{angle:-32.5,originX:-2.23,originY:0,deltaX:4.6234,deltaY:2.678,dashes:[0,-2.5,0,-7.8,0,-10.35],sourceLine:88},{angle:-42.5,originX:-3.23,originY:0,deltaX:3.6234,deltaY:4.678,dashes:[0,-3.25,0,-5.18,0,-7.35],sourceLine:89}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:4,deltaY:4,dashes:[12,-4],sourceLine:91},{angle:135,originX:2.828427125,originY:2.828427125,deltaX:4,deltaY:-4,dashes:[12,-4],sourceLine:92}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:94},{angle:90,originX:2,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:95},{angle:90,originX:4,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:96},{angle:90,originX:6,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:97},{angle:90,originX:8,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:98},{angle:90,originX:10,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:99},{angle:90,originX:12,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:100},{angle:0,originX:0,originY:12,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:101},{angle:0,originX:0,originY:14,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:102},{angle:0,originX:0,originY:16,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:103},{angle:0,originX:0,originY:18,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:104},{angle:0,originX:0,originY:20,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:105},{angle:0,originX:0,originY:22,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:106},{angle:0,originX:0,originY:24,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:107}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:2.2,deltaY:1,dashes:[15,-2,5,-1],sourceLine:109},{angle:0,originX:1.33,originY:.5,deltaX:-1,deltaY:1.33,dashes:[3,-.33,6,-.75],sourceLine:110},{angle:0,originX:.5,originY:.85,deltaX:5.2,deltaY:.67,dashes:[8,-1.4,4,-1],sourceLine:111}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:25.5,deltaY:12,dashes:[6,-5,7,-3,9,-4],sourceLine:113},{angle:0,originX:6,originY:.5,deltaX:25.5,deltaY:12,dashes:[5,-19,4,-6],sourceLine:114},{angle:0,originX:18,originY:-.75,deltaX:25.5,deltaY:12,dashes:[3,-31],sourceLine:115},{angle:90,originX:0,originY:0,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:116},{angle:90,originX:6,originY:0,deltaX:12,deltaY:8.5,dashes:[11.25,-36.75],sourceLine:117},{angle:90,originX:11,originY:0,deltaX:12,deltaY:8.5,dashes:[10.5,-37.5],sourceLine:118},{angle:90,originX:18,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:119},{angle:90,originX:21,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:120},{angle:90,originX:30,originY:0,deltaX:12,deltaY:8.5,dashes:[11,-37],sourceLine:121}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:1.123,deltaY:1.567,dashes:[0,-1.52,0,-1.7,0,-1.625],sourceLine:123},{angle:7.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-.82,0,-1.37,0,-.525],sourceLine:124},{angle:-32.5,originX:-1.23,originY:0,deltaX:2.6234,deltaY:1.678,dashes:[0,-.5,0,-1.8,0,-2.35],sourceLine:125},{angle:-42.5,originX:-1.23,originY:0,deltaX:1.6234,deltaY:2.678,dashes:[0,-.25,0,-1.18,0,-1.35],sourceLine:126}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:128},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:129},{angle:0,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:130},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:131},{angle:0,originX:0,originY:.5,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:132},{angle:0,originX:0,originY:.75,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:133},{angle:90,originX:.5,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:134},{angle:90,originX:.75,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:135}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:137},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:138}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:140},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.5,dashes:[.25,-.25],sourceLine:141},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:.5,dashes:[-.25,.25],sourceLine:142}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.33,dashes:[],sourceLine:144},{angle:90,originX:.9,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:145},{angle:90,originX:.8,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:146},{angle:0,originX:.9,originY:.055,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:147},{angle:0,originX:.9,originY:.11,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:148},{angle:0,originX:.9,originY:.165,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:149},{angle:0,originX:.9,originY:.22,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:150},{angle:0,originX:.9,originY:.275,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:151}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.1875,dashes:[],sourceLine:153},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.1875,dashes:[],sourceLine:154},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.1875,dashes:[],sourceLine:155},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.1875,dashes:[.1875,-.125],sourceLine:156}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:158},{angle:135,originX:.0625,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:159},{angle:135,originX:.09375,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:160},{angle:135,originX:.125,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:161}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:163},{angle:90,originX:.0625,originY:-.0625,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:164}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:166}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:168},{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[.3535533905932738,-.7071067811865476],sourceLine:169}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.03125,deltaY:.0625,dashes:[0,-.0625],sourceLine:171}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:173},{angle:0,originX:0,originY:.09375,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:174},{angle:0,originX:0,originY:.1875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:175},{angle:90,originX:.03125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:176},{angle:90,originX:.125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:177},{angle:90,originX:.21875,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:178}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:180},{angle:180,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:181},{angle:300,originX:0,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:182},{angle:60,originX:.1,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:183},{angle:300,originX:.1,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:184},{angle:60,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:185},{angle:180,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:186},{angle:300,originX:-.05,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:187},{angle:180,originX:-.05,originY:-.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:188},{angle:60,originX:-.4,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:189},{angle:300,originX:-.4,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:190},{angle:60,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:191},{angle:180,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:192},{angle:300,originX:.2,originY:.346410161,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:193},{angle:180,originX:.2,originY:.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:194},{angle:0,originX:.2,originY:.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:195},{angle:0,originX:.2,originY:-.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:196},{angle:120,originX:.05,originY:.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:197},{angle:120,originX:-.25,originY:.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:198},{angle:240,originX:-.25,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:199},{angle:240,originX:.05,originY:-.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:200}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[.25,-.25],sourceLine:202},{angle:45,originX:.25,originY:0,deltaX:.176776695296,deltaY:.176776695296,dashes:[.0625,-.2285533906,.0625,-.353553390593],sourceLine:203}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:205},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:206},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:207}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:209},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:210},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:211}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:213},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:214},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:215}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:.707106781,deltaY:.707106781,dashes:[.1875,-1.226713563],sourceLine:217},{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:218},{angle:135,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:219}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.03125,dashes:[],sourceLine:221},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:222}]},{name:"GRAVEL",description:"",lines:[{angle:228.012787504,originX:.72,originY:1,deltaX:12.0413651692039,deltaY:.0743294146632,dashes:[.134536,-13.3190880470737],sourceLine:224},{angle:184.969740728,originX:.63,originY:.9,deltaX:-12.0415166747131,deltaY:.0433148081592,dashes:[.230868,-22.85592476123],sourceLine:225},{angle:132.510447078,originX:.4,originY:.88,deltaX:-14.8659418273816,deltaY:.061429511683,dashes:[.162788,-16.1160325960997],sourceLine:226},{angle:267.273689006,originX:.01,originY:.63,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:227},{angle:292.833654178,originX:0,originY:.42,deltaX:-12.9999095019474,deltaY:.048507125026,dashes:[.206155,-20.4093731280883],sourceLine:228},{angle:357.273689006,originX:.08,originY:.23,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:229},{angle:37.6942404667,originX:.29,originY:.22,deltaX:-16.4011800288558,deltaY:.0359675000664,dashes:[.278029,-27.524848548916],sourceLine:230},{angle:72.2553283749,originX:.51,originY:.39,deltaX:23.0867613281116,deltaY:.0380969659053,dashes:[.262488,-25.9863214968134],sourceLine:231},{angle:121.429565615,originX:.59,originY:.64,deltaX:15.2642639131074,deltaY:.047404546271,dashes:[.21095,-20.884073109729],sourceLine:232},{angle:175.236358309,originX:.48,originY:.82,deltaX:-11.0450488205478,deltaY:.083045479801,dashes:[.240832,-11.8007625787923],sourceLine:233},{angle:222.397437798,originX:.24,originY:.84,deltaX:16.2787889313724,deltaY:.0321080648114,dashes:[.311448,-30.8333750047949],sourceLine:234},{angle:138.814074834,originX:1,originY:.62,deltaX:9.2190645101588,deltaY:.0940720868851,dashes:[.106301,-10.5238448127347],sourceLine:235},{angle:171.46923439,originX:.92,originY:.69,deltaX:-13.1528534931484,deltaY:.0494468176315,dashes:[.202237,-20.021511416157],sourceLine:236},{angle:225,originX:.72,originY:.72,deltaX:.7071067811865,deltaY:.7071067811865,dashes:[.141421,-1.2727925623731],sourceLine:237},{angle:203.198590514,originX:.65,originY:.84,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.076158,-7.5396151058639],sourceLine:238},{angle:291.801409486,originX:.58,originY:.81,deltaX:-3.156820749011,deltaY:.185695338158,dashes:[.107703,-5.2774618071345],sourceLine:239},{angle:30.9637565321,originX:.62,originY:.71,deltaX:3.6014702879928,deltaY:.1714985851408,dashes:[.174929,-5.6560228948453],sourceLine:240},{angle:161.565051177,originX:.77,originY:.8,deltaX:-2.2135943621183,deltaY:.3162277660138,dashes:[.126491,-3.0357866601684],sourceLine:241},{angle:16.389540334,originX:0,originY:.81,deltaX:10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.5428451466694],sourceLine:242},{angle:70.3461759419,originX:.17,originY:.86,deltaX:-11.7045066155395,deltaY:.0672672793901,dashes:[.148661,-14.717407747319],sourceLine:243},{angle:293.198590514,originX:.77,originY:1,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.152315,-7.4634581058639],sourceLine:244},{angle:343.610459666,originX:.83,originY:.86,deltaX:-10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.542845146669],sourceLine:245},{angle:339.44395478,originX:0,originY:.19,deltaX:-5.3838927710229,deltaY:.117041147157,dashes:[.17088,-8.3731237453175],sourceLine:246},{angle:294.775140569,originX:.16,originY:.13,deltaX:-12.0828441168135,deltaY:.0698430296124,dashes:[.143178,-14.174643063276],sourceLine:247},{angle:66.8014094864,originX:.78,originY:0,deltaX:5.3835637472487,deltaY:.1313064328552,dashes:[.152315,-7.4634581058639],sourceLine:248},{angle:17.3540246363,originX:.84,originY:.14,deltaX:-13.6013396869991,deltaY:.0596549986364,dashes:[.167631,-16.59542361424],sourceLine:249},{angle:69.4439547804,originX:.29,originY:0,deltaX:-5.383892771022,deltaY:.1170411471946,dashes:[.08544,-8.4585637453175],sourceLine:250},{angle:101.309932474,originX:.72,originY:0,deltaX:4.1184388379018,deltaY:.1961161351396,dashes:[.05099,-5.0480295135928],sourceLine:251},{angle:165.963756532,originX:.71,originY:.05,deltaX:-3.1529631254726,deltaY:.2425356250323,dashes:[.206155,-3.9169506256177],sourceLine:252},{angle:186.009005957,originX:.51,originY:.1,deltaX:-10.0497393137326,deltaY:.0523423921723,dashes:[.19105,-18.9139231745428],sourceLine:253},{angle:303.690067526,originX:.62,originY:.62,deltaX:-2.2188007849008,deltaY:.2773500981134,dashes:[.144222,-3.461329275464],sourceLine:254},{angle:353.157226587,originX:.7,originY:.5,deltaX:17.1171966955143,deltaY:.0397150736497,dashes:[.251794,-24.9275626240283],sourceLine:255},{angle:60.9453959009,originX:.95,originY:.47,deltaX:-8.0616726575653,deltaY:.0971285862325,dashes:[.102956,-10.192674140987],sourceLine:256},{angle:90,originX:1,originY:.56,deltaX:1,deltaY:1,dashes:[.06,-.94],sourceLine:257},{angle:120.256437164,originX:.49,originY:.13,deltaX:-8.0619364083848,deltaY:.0719815751411,dashes:[.138924,-13.7535199894498],sourceLine:258},{angle:48.0127875042,originX:.42,originY:.25,deltaX:12.0413651692041,deltaY:.0743294146212,dashes:[.269072,-13.1845520470737],sourceLine:259},{angle:0,originX:.6,originY:.45,deltaX:1,deltaY:1,dashes:[.26,-.74],sourceLine:260},{angle:325.304846469,originX:.86,originY:.45,deltaX:12.2063917682497,deltaY:-.063245553253,dashes:[.158114,-15.653274300842],sourceLine:261},{angle:254.054604099,originX:.99,originY:.36,deltaX:4.1208169184605,deltaY:.1373605639542,dashes:[.145602,-7.1345078892805],sourceLine:262},{angle:207.645975364,originX:.95,originY:.22,deltaX:21.4708691170287,deltaY:.0421824539631,dashes:[.237065,-23.4694741822594],sourceLine:263},{angle:175.42607874,originX:.74,originY:.11,deltaX:13.0383438432524,deltaY:.039872611164,dashes:[.250799,-24.8290734079689],sourceLine:264}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:266},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:267},{angle:60,originX:.125,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:268}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:270},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:271},{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[-.25,.125],sourceLine:272}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.0625,dashes:[1,-.5],sourceLine:274},{angle:90,originX:0,originY:0,deltaX:-.25,deltaY:.0625,dashes:[1,-.5],sourceLine:275}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:277},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:278},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:279}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:292}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:294}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:296}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:298}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:300},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:301}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:303}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:305}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:307}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:309}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:311}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:313}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:315},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:316}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:318},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:319}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:321},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:322}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:327}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.25,dashes:[.25,-.25,0,-.25,0,-.25],sourceLine:329}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:331},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:332}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:334},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:335},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:336}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:338},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:339},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:340}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:342},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:343},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:344},{angle:0,originX:0,originY:.15625,deltaX:0,deltaY:.25,dashes:[],sourceLine:345}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.09375,dashes:[],sourceLine:347},{angle:45,originX:.066291261,originY:0,deltaX:0,deltaY:.09375,dashes:[0,-.09375],sourceLine:348}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:350},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:351}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:353},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:354},{angle:120,originX:.0625,originY:.108253176,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:355}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:357},{angle:45,originX:0,originY:.0625,deltaX:0,deltaY:.125,dashes:[],sourceLine:358}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.125,-.875],sourceLine:360},{angle:90,originX:.0625,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.0625,-1.669550806],sourceLine:361},{angle:90,originX:.078125,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:362},{angle:90,originX:.046875,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:363},{angle:60,originX:.09375,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:364},{angle:120,originX:.03125,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:365}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:367},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.125],sourceLine:368}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:370},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:371},{angle:0,originX:-.09375,originY:.162379763,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:372}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:374},{angle:90,originX:.125,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:375}]}],issues:[]},Hp={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:20},{angle:90,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:21}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:23}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:25},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:26}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:28},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:29}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:31},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:32},{angle:45,originX:8.98026,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:33},{angle:45,originX:13.4704,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:34}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:36},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:37}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:5.55625,deltaY:3.175,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:39}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:41},{angle:135,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:42}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:6.35,deltaY:3.175,dashes:[7.9375,-4.7625],sourceLine:45}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:47},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[203.2,-203.2],sourceLine:48}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:50},{angle:0,originX:-203.2,originY:9.525,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:51},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:52},{angle:90,originX:-9.525,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:53}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:55},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:101.6,dashes:[203.2,-203.2],sourceLine:56}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:58},{angle:0,originX:0,originY:57.15,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:59},{angle:0,originX:50.8,originY:67.7418,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:60},{angle:0,originX:50.8,originY:124.892,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:61},{angle:90,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:62},{angle:90,originX:-9.525,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:63},{angle:90,originX:50.8,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:64},{angle:90,originX:41.275,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:65}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:67.7418,dashes:[],sourceLine:67},{angle:90,originX:0,originY:0,deltaX:67.7418,deltaY:101.6,dashes:[67.7418,-67.7418],sourceLine:68}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:104.896,deltaY:-149.807,dashes:[19.05,-209.55],sourceLine:70},{angle:355,originX:0,originY:0,deltaX:-51.76101082,deltaY:187.25814969,dashes:[15.24,-167.64058417],sourceLine:71},{angle:100.4514447,originX:15.182007,originY:-1.3282535,deltaX:145.5569059,deltaY:-176.270089,dashes:[16.1900088,-178.0902446],sourceLine:72},{angle:46.1842,originX:0,originY:50.8,deltaX:157.343,deltaY:-224.71,dashes:[28.575,-314.325],sourceLine:73},{angle:96.63555761,originX:22.5899,originY:47.2965,deltaX:218.33577212,deltaY:-264.40480444,dashes:[24.28502314,-267.13560816],sourceLine:74},{angle:351.18415117,originX:0,originY:50.8,deltaX:196.67912063,deltaY:280.88740361,dashes:[22.85996707,-251.45973192],sourceLine:75},{angle:21,originX:25.4,originY:38.1,deltaX:104.89565868,deltaY:-149.80652586,dashes:[19.05,-209.55],sourceLine:76},{angle:326,originX:25.4,originY:38.1,deltaX:-51.7604,deltaY:187.258,dashes:[15.24,-167.64],sourceLine:77},{angle:71.451445,originX:38.0345326,originY:29.5779001,deltaX:145.5567546,deltaY:-176.2700748,dashes:[16.1900088,-178.0899376],sourceLine:78},{angle:37.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-165.608,0,-170.18,0,-168.275],sourceLine:79},{angle:7.5,originX:0,originY:0,deltaX:79.3242,deltaY:90.6018,dashes:[0,-97.028,0,-161.798,0,-64.135],sourceLine:80},{angle:-32.5,originX:-56.642,originY:0,deltaX:117.434,deltaY:68.0212,dashes:[0,-63.5,0,-198.12,0,-262.89],sourceLine:81},{angle:-42.5,originX:-82.042,originY:0,deltaX:92.0344,deltaY:118.821,dashes:[0,-82.55,0,-131.572,0,-186.69],sourceLine:82}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:101.6,deltaY:101.6,dashes:[304.8,-101.6],sourceLine:84},{angle:135,originX:71.842,originY:71.842,deltaX:101.6,deltaY:-101.6,dashes:[304.8,-101.6],sourceLine:85}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:87},{angle:90,originX:50.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:88},{angle:90,originX:101.6,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:89},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:90},{angle:90,originX:203.2,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:91},{angle:90,originX:254,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:92},{angle:90,originX:304.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:93},{angle:0,originX:0,originY:304.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:94},{angle:0,originX:0,originY:355.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:95},{angle:0,originX:0,originY:406.4,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:96},{angle:0,originX:0,originY:457.2,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:97},{angle:0,originX:0,originY:508,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:98},{angle:0,originX:0,originY:558.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:99},{angle:0,originX:0,originY:609.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:100}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:55.88,deltaY:25.4,dashes:[381,-50.8,127,-25.4],sourceLine:102},{angle:0,originX:33.782,originY:12.7,deltaX:-25.4,deltaY:33.782,dashes:[76.2,-8.382,152.4,-19.05],sourceLine:103},{angle:0,originX:12.7,originY:21.59,deltaX:132.08,deltaY:17.018,dashes:[203.2,-35.56,101.6,-25.4],sourceLine:104}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:647.7,deltaY:304.8,dashes:[152.4,-127,177.8,-76.2,228.6,-101.6],sourceLine:106},{angle:0,originX:152.4,originY:12.7,deltaX:647.7,deltaY:304.8,dashes:[127,-482.6,101.6,-152.4],sourceLine:107},{angle:0,originX:457.2,originY:-19.05,deltaX:647.7,deltaY:304.8,dashes:[76.2,-787.4],sourceLine:108},{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:109},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[285.75,-933.45],sourceLine:110},{angle:90,originX:279.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[266.7,-952.5],sourceLine:111},{angle:90,originX:457.2,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:112},{angle:90,originX:533.4,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:113},{angle:90,originX:762,originY:0,deltaX:304.8,deltaY:215.9,dashes:[279.4,-939.8],sourceLine:114}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:28.5242,deltaY:39.8018,dashes:[0,-38.608,0,-43.18,0,-41.275],sourceLine:116},{angle:7.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-20.828,0,-34.798,0,-13.335],sourceLine:117},{angle:-32.5,originX:-31.242,originY:0,deltaX:66.6344,deltaY:42.6212,dashes:[0,-12.7,0,-45.72,0,-59.69],sourceLine:118},{angle:-42.5,originX:-31.242,originY:0,deltaX:41.2344,deltaY:68.0212,dashes:[0,-6.35,0,-29.972,0,-34.29],sourceLine:119}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:121},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:122},{angle:0,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:123},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:124},{angle:0,originX:0,originY:12.7,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:125},{angle:0,originX:0,originY:19.05,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:126},{angle:90,originX:12.7,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:127},{angle:90,originX:19.05,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:128}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:130},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:131}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:133},{angle:90,originX:0,originY:0,deltaX:0,deltaY:12.7,dashes:[6.35,-6.35],sourceLine:134},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:12.7,dashes:[-6.35,6.35],sourceLine:135}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8.382,dashes:[],sourceLine:137},{angle:90,originX:22.86,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:138},{angle:90,originX:20.32,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:139},{angle:0,originX:22.86,originY:1.397,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:140},{angle:0,originX:22.86,originY:2.794,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:141},{angle:0,originX:22.86,originY:4.191,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:142},{angle:0,originX:22.86,originY:5.588,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:143},{angle:0,originX:22.86,originY:6.985,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:144}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:146},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:147},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:148},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:4.7625,dashes:[4.7625,-3.175],sourceLine:149}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:151},{angle:135,originX:1.5875,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:152},{angle:135,originX:2.38125,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:153},{angle:135,originX:3.175,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:154}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:156},{angle:90,originX:1.5875,originY:-1.5875,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:157}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:159}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:161},{angle:45,originX:0,originY:0,deltaX:0,deltaY:17.9605,dashes:[8.980256121069154,-17.960512242138307],sourceLine:162}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.79375,deltaY:1.5875,dashes:[0,-1.5875],sourceLine:164}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:166},{angle:0,originX:0,originY:2.38125,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:167},{angle:0,originX:0,originY:4.7625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:168},{angle:90,originX:.79375,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:169},{angle:90,originX:3.175,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:170},{angle:90,originX:5.55625,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:171}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:173},{angle:180,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:174},{angle:300,originX:0,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:175},{angle:60,originX:2.54,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:176},{angle:300,originX:2.54,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:177},{angle:60,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:178},{angle:180,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:179},{angle:300,originX:-1.27,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:180},{angle:180,originX:-1.27,originY:-2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:181},{angle:60,originX:-10.16,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:182},{angle:300,originX:-10.16,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:183},{angle:60,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:184},{angle:180,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:185},{angle:300,originX:5.08,originY:8.7988180894,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:186},{angle:180,originX:5.08,originY:8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:187},{angle:0,originX:5.08,originY:4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:188},{angle:0,originX:5.08,originY:-4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:189},{angle:120,originX:1.27,originY:6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:190},{angle:120,originX:-6.35,originY:2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:191},{angle:240,originX:-6.35,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:192},{angle:240,originX:1.27,originY:-6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:193}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:195},{angle:45,originX:6.35,originY:0,deltaX:4.490128053,deltaY:4.490128053,dashes:[1.5875,-5.8052561314,1.5875,-8.9802561314],sourceLine:196}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:198},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:199},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:200}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:202},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:203},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:204}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:206},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:207},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:208}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:17.96051224,deltaY:17.96051224,dashes:[4.7625,-31.15852448],sourceLine:210},{angle:45,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:211},{angle:135,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:212}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.79375,dashes:[],sourceLine:214},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:215}]},{name:"GRAVEL",description:"",lines:[{angle:228.0127875,originX:18.288,originY:25.4,deltaX:305.85067529778,deltaY:1.88796713245,dashes:[3.4172144,-338.30483639565],sourceLine:217},{angle:184.969741,originX:16.002,originY:22.86,deltaX:-305.8545235377,deltaY:1.10019612724,dashes:[5.8640472,-580.54048893524],sourceLine:218},{angle:132.5104471,originX:10.16,originY:22.352,deltaX:-377.59492241548,deltaY:1.56030959675,dashes:[4.1348152,-409.347227941],sourceLine:219},{angle:267.273689,originX:.254,originY:16.002,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:220},{angle:292.83365418,originX:0,originY:10.668,deltaX:-330.19770134945,deltaY:1.23208097566,dashes:[5.236337,-518.39807745344],sourceLine:221},{angle:357.273689,originX:2.032,originY:5.842,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:222},{angle:37.69424047,originX:7.366,originY:5.588,deltaX:-416.58997273292,deltaY:.91357450169,dashes:[7.0619366,-699.13115314247],sourceLine:223},{angle:72.25532837,originX:12.954,originY:9.906,deltaX:586.40373773403,deltaY:.96766293399,dashes:[6.6671952,-660.05256601905],sourceLine:224},{angle:121.42956562,originX:14.986,originY:16.256,deltaX:387.71230339293,deltaY:1.2040754753,dashes:[5.35813,-530.45545698712],sourceLine:225},{angle:175.2363583,originX:12.192,originY:20.828,deltaX:-280.5442400419,deltaY:2.10935518695,dashes:[6.1171328,-299.7393695],sourceLine:226},{angle:222.3974378,originX:6.096,originY:21.336,deltaX:413.48123885686,deltaY:.81554484621,dashes:[7.9107792,-783.16772512177],sourceLine:227},{angle:138.81407483,originX:25.4,originY:15.748,deltaX:234.164238558,deltaY:2.38943100688,dashes:[2.7000454,-267.30565824344],sourceLine:228},{angle:171.4692344,originX:23.368,originY:17.526,deltaX:-334.082478726,deltaY:1.25594916784,dashes:[5.1368198,-508.5463899704],sourceLine:229},{angle:225,originX:18.288,originY:18.288,deltaX:17.96051224214,deltaY:17.96051224214,dashes:[3.5920934,-32.32893108428],sourceLine:230},{angle:203.19859051,originX:16.51,originY:21.336,deltaX:-136.74251918,deltaY:3.33518339548,dashes:[1.9344132,-191.50622368894],sourceLine:231},{angle:291.80140949,originX:14.732,originY:20.574,deltaX:-80.18324702488,deltaY:4.71666158921,dashes:[2.7356562,-134.0475299],sourceLine:232},{angle:30.96375653,originX:15.748,originY:18.034,deltaX:91.47734531502,deltaY:4.35606406258,dashes:[4.4431966,-143.6629815291],sourceLine:233},{angle:161.56505118,originX:19.558,originY:20.32,deltaX:-56.2252967978,deltaY:8.03218525675,dashes:[3.2128714,-77.10898116828],sourceLine:234},{angle:16.389540334,originX:0,originY:20.574,deltaX:265.17991128726,deltaY:1.43340492604,dashes:[4.50088,-445.58826672539],sourceLine:235},{angle:70.34617594,originX:4.318,originY:21.844,deltaX:-297.29446803469,deltaY:1.70858889651,dashes:[3.7759894,-373.822156782],sourceLine:236},{angle:293.19859051,originX:19.558,originY:25.4,deltaX:-136.7425191801,deltaY:3.33518339548,dashes:[3.868801,-189.57183588894],sourceLine:237},{angle:343.61045967,originX:21.082,originY:21.844,deltaX:-265.17991128725,deltaY:1.433404926,dashes:[4.50088,-445.5882667254],sourceLine:238},{angle:339.44395478,originX:0,originY:4.826,deltaX:-136.75087638398,deltaY:2.97284513779,dashes:[4.340352,-212.67734313106],sourceLine:239},{angle:294.7751406,originX:4.064,originY:3.302,deltaX:-306.90424056705,deltaY:1.77401295215,dashes:[3.6367212,-360.0359338072],sourceLine:240},{angle:66.80140949,originX:19.812,originY:0,deltaX:136.74251918012,deltaY:3.33518339452,dashes:[3.868801,-189.57183588894],sourceLine:241},{angle:17.35402464,originX:21.336,originY:3.556,deltaX:-345.47402804977,deltaY:1.51523696536,dashes:[4.2578274,-421.523759802],sourceLine:242},{angle:69.44395478,originX:7.366,originY:0,deltaX:-136.75087638396,deltaY:2.97284513874,dashes:[2.170176,-214.84751913106],sourceLine:243},{angle:101.309932474,originX:18.288,originY:0,deltaX:104.60834648271,deltaY:4.98134983255,dashes:[1.295146,-128.21994964526],sourceLine:244},{angle:165.963756532,originX:18.034,originY:1.27,deltaX:-80.085263387,deltaY:6.16040487582,dashes:[5.236337,-99.49054589069],sourceLine:245},{angle:186.00900596,originX:12.954,originY:2.54,deltaX:-255.26337856879,deltaY:1.32949676118,dashes:[4.85267,-480.41364863337],sourceLine:246},{angle:303.69006753,originX:15.748,originY:15.748,deltaX:-56.35753993648,deltaY:7.0446924921,dashes:[3.6632388,-87.9177635968],sourceLine:247},{angle:353.15722659,originX:17.78,originY:12.7,deltaX:434.77679606606,deltaY:1.0087628707,dashes:[6.3955676,-633.16009065031],sourceLine:248},{angle:60.9453959,originX:24.13,originY:11.938,deltaX:-204.76648550216,deltaY:2.46706609031,dashes:[2.6150824,-258.8939231811],sourceLine:249},{angle:90,originX:25.4,originY:14.224,deltaX:25.4,deltaY:25.4,dashes:[1.524,-23.876],sourceLine:250},{angle:120.25643716,originX:12.446,originY:3.302,deltaX:-204.77318477297,deltaY:1.8283320086,dashes:[3.5286696,-349.339407732],sourceLine:251},{angle:48.0127875,originX:10.668,originY:6.35,deltaX:305.85067529778,deltaY:1.88796713138,dashes:[6.8344288,-334.88762199565],sourceLine:252},{angle:0,originX:15.24,originY:11.43,deltaX:25.4,deltaY:25.4,dashes:[6.604,-18.796],sourceLine:253},{angle:325.3048465,originX:21.844,originY:11.43,deltaX:310.04235091354,deltaY:-1.6064370526,dashes:[4.0160956,-397.5931672414],sourceLine:254},{angle:254.0546041,originX:25.146,originY:9.144,deltaX:104.6687497289,deltaY:3.48895832444,dashes:[3.6982908,-181.21650038772],sourceLine:255},{angle:207.64597536,originX:24.13,originY:5.588,deltaX:545.36007557253,deltaY:1.07143433066,dashes:[6.021451,-596.12464422938],sourceLine:256},{angle:175.42607874,originX:18.796,originY:2.794,deltaX:331.1739336186,deltaY:1.01276432357,dashes:[6.3702946,-630.6584645624],sourceLine:257}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:259},{angle:120,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:260},{angle:60,originX:3.175,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:261}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:263},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:264},{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[-6.35,3.175],sourceLine:265}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:267},{angle:90,originX:0,originY:0,deltaX:-6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:268}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:270},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:271},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:272}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:285}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:287}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:289}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:291}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:293},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:294}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:296}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:298}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:300}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:302}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:304}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:306}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:308},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:309}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:311},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:312}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:314},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:315}]},{name:"JIS_LC_20",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:322},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:323}]},{name:"JIS_LC_20A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:325},{angle:45,originX:1,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:326}]},{name:"JIS_LC_8",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:328},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:329}]},{name:"JIS_LC_8A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:331},{angle:45,originX:1,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:332}]},{name:"JIS_RC_10",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:334},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:335},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:336}]},{name:"JIS_RC_15",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:338},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:339},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:340}]},{name:"JIS_RC_18",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:342},{angle:45,originX:1,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:343},{angle:45,originX:2,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:344}]},{name:"JIS_RC_30",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:346},{angle:45,originX:1,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:347},{angle:45,originX:2,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:348}]},{name:"JIS_STN_1E",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:350},{angle:45,originX:.705,originY:0,deltaX:0,deltaY:1,dashes:[1,-.5],sourceLine:351}]},{name:"JIS_STN_2.5",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.5,dashes:[],sourceLine:353},{angle:45,originX:1.765,originY:0,deltaX:0,deltaY:2.5,dashes:[1.2,-.5],sourceLine:354}]},{name:"JIS_WOOD",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[],sourceLine:356}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:359}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:6.35,dashes:[6.35,-6.35,0,-6.35,0,-6.35],sourceLine:361}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:363},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:364}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:366},{angle:60,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:367},{angle:120,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:368}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:370},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:371},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:372}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:374},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:375},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:376},{angle:0,originX:0,originY:3.96875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:377}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.38125,dashes:[],sourceLine:379},{angle:45,originX:1.6838,originY:0,deltaX:0,deltaY:2.38125,dashes:[0,-2.38125],sourceLine:380}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:382},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:383}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:385},{angle:60,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:386},{angle:120,originX:1.5875,originY:2.7496306704,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:387}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:389},{angle:45,originX:0,originY:1.5875,deltaX:0,deltaY:3.175,dashes:[],sourceLine:390}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[3.175,-22.225],sourceLine:392},{angle:90,originX:1.5875,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.5875,-42.4065904724],sourceLine:393},{angle:90,originX:1.984375,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:394},{angle:90,originX:1.190625,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:395},{angle:60,originX:2.38125,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:396},{angle:120,originX:.79375,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:397}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:399},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-3.175],sourceLine:400}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:402},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:403},{angle:0,originX:-2.38125,originY:4.1244459802,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:404}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:406},{angle:90,originX:3.175,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:407}]}],issues:[]};var vr=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(vr||{}),Ar=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(Ar||{}),ba=(i=>(i[i.HatchObject=0]="HatchObject",i[i.GradientObject=1]="GradientObject",i))(ba||{}),_a=(i=>(i[i.PreDefinedGradient=0]="PreDefinedGradient",i[i.UserDefinedGradient=1]="UserDefinedGradient",i))(_a||{});const Bh=class Bh extends et{constructor(){super(),this._areasFromLoopsCache=null,this._normal=new A(0,0,1),this._gradientAngle=0,this._elevation=0,this._geo=new de,this._isSolidFill=!1,this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1,this._patternName="",this._patternNameSet=!1,this._patternType=1,this._patternAngle=0,this._patternAngleSet=!1,this._patternScale=1,this._patternScaleSet=!1,this._associative=!1,this._associativeSet=!1,this._backgroundColor=void 0,this._backgroundColorSet=!1,this._patternDouble=!1,this._patternDoubleSet=!1,this._hatchStyle=0,this._hatchStyleSet=!1,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._pixelSize=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||fr(this.getEffectivePatternName())}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=wt.instance().getVar(E.HPCOLOR,t);return e instanceof X&&e.colorMethod!==exports.AcCmColorMethod.None?e.clone():t.cecolor.clone()}set color(t){this.setEntityColor(t)}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t??"",this._isSolidFill=fr(this._patternName),this._patternNameSet=!0,this.updatePredefinedPatternDefinitionLines()}get patternType(){return this._patternType}set patternType(t){this._patternType=t,t!==1&&this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1),this.updatePredefinedPatternDefinitionLines()}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t,this._patternAngleSet=!0}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}get annotative(){return Se(this)}set annotative(t){me(this,t)}get associative(){return this._associative}set associative(t){this._associative=!!t,this._associativeSet=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t==null?void 0:t.clone(),this._backgroundColorSet=!0}get patternDouble(){return this._patternDouble}set patternDouble(t){this._patternDouble=!!t,this._patternDoubleSet=!0}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t,this._hatchStyleSet=!0}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(t){this._hatchObjectType=t}get gradientAngle(){return this._gradientAngle}set gradientAngle(t){this._gradientAngle=t}get gradientShift(){return this._gradientShift}set gradientShift(t){this._gradientShift=t}get gradientType(){return this._gradientType}set gradientType(t){this._gradientType=t}get gradientName(){return this.isGradient&&this._gradientName.trim()===""?vf:this._gradientName}set gradientName(t){this._gradientName=t??""}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(t){this._gradientOneColorMode=t}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(t){this._shadeTintValue=t}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(t){this._gradientStartColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(t){this._gradientEndColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize=t}applyPatternDefaultsFromSysVars(t){const e=wt.instance();if(!this.hasExplicitLayer()){const n=e.getVar(E.HPLAYER,t);this.shouldUseSysVarOverride(n)&&(this.layer=n)}if(!this.hasExplicitTransparency()){const n=this.parseHpTransparency(e.getVar(E.HPTRANSPARENCY,t));n&&(this.transparency=n)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(E.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const n=e.getVar(E.HPNAME,t);this._patternName=typeof n=="string"?n:"",this._patternNameSet=!0}if(!this._patternAngleSet){const n=e.getVar(E.HPANG,t);this._patternAngle=typeof n=="number"&&Number.isFinite(n)?n:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(E.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const n=e.getVar(E.HPASSOC,t);this._associative=typeof n=="number"?n!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(E.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const n=e.getVar(E.HPDOUBLE,t);this._patternDouble=typeof n=="number"?n!==0:!1,this._patternDoubleSet=!0}this.updatePredefinedPatternDefinitionLines()}getEffectivePatternName(){if(this._patternNameSet)return this._patternName;const t=this.database,e=wt.instance().getVar(E.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=wt.instance().getVar(E.HPANG,t);return typeof e=="number"&&Number.isFinite(e)?e:this._patternAngle}getRenderablePatternAngle(){return!this._definitionLinesAutoGenerated&&this._definitionLines.length>0?0:this.getEffectivePatternAngle()}getEffectivePatternScale(){if(this._patternScaleSet)return this._patternScale;const t=this.database;return this.normalizePatternScale(wt.instance().getVar(E.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=wt.instance().getVar(E.HPASSOC,t);return typeof e=="number"?e!==0:this._associative}normalizePatternScale(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}normalizeHatchStyle(t){return typeof t!="number"||!Number.isFinite(t)?1:t===0?0:t===2?2:1}shouldUseSysVarOverride(t){if(typeof t!="string")return!1;const e=t.trim().toLowerCase();return e!==""&&e!=="."&&e!=="use current"}parseHpBackgroundColor(t){if(t instanceof X)return t.colorMethod===exports.AcCmColorMethod.None?void 0:t.clone();if(typeof t!="string")return;const e=t.trim().toLowerCase();if(!(!e||e==="."||e==="none"))return X.fromString(t)}parseHpTransparency(t){if(t instanceof St)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return St.fromString(e);const n=Number(e);if(Number.isInteger(n)&&n>=0&&n<=90){const r=new St;return r.percentage=n,r}}updatePredefinedPatternDefinitionLines(t=this.getEffectivePatternName(),e=this.getEffectivePatternScale()){if(this.patternType!==1||!(this._definitionLinesAutoGenerated||this._definitionLines.length===0))return;const r=t.trim().toUpperCase();if(!r||fr(r)){this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1;return}const s=this.normalizePatternScale(e);if(this._definitionLinesAutoGenerated&&this._definitionLinesPatternName===r&&this._definitionLinesPatternScale===s)return;const a=Hp.patterns.find(o=>o.name.trim().toUpperCase()===r);if(!a){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=a.lines.map(o=>({angle:o.angle*Math.PI/180,base:{x:o.originX*s,y:o.originY*s},offset:{x:o.deltaX*s,y:o.deltaY*s},dashLengths:o.dashes.map(c=>c*s)})),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}add(t){this._geo.add(t),this.invalidateAreasFromLoopsCache()}invalidateAreasFromLoopsCache(){this._areasFromLoopsCache=null}buildAreasFromLoops(){if(this._areasFromLoopsCache!=null)return this._areasFromLoopsCache;const t=this._geo.loops;if(t.length===0)return this._areasFromLoopsCache=[],this._areasFromLoopsCache;if(t.length===1)return this._areasFromLoopsCache=[this._geo],this._areasFromLoopsCache;const e=this._geo.buildHierarchy(),n=[],r=(s,a)=>{if(s.index>=0&&a%2===0){const o=new de;o.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&o.add(t[c.index])}),n.push(o)}s.children.forEach(o=>r(o,a+1))};return e.children.forEach(s=>r(s,0)),this._areasFromLoopsCache=n.length>0?n:[this._geo],this._areasFromLoopsCache}getCalculatedAreaValue(){const t=this.buildAreasFromLoops();return t.length===0?0:t.reduce((e,n)=>e+n.area,0)}get area(){return this.getCalculatedAreaValue()}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new H;const e=new H;return t.forEach(n=>{const r=n.box;e.union(new H().setFromPoints([ce({x:r.min.x,y:r.min.y,z:this._elevation},this._normal),ce({x:r.max.x,y:r.min.y,z:this._elevation},this._normal),ce({x:r.max.x,y:r.max.y,z:this._elevation},this._normal),ce({x:r.min.x,y:r.max.y,z:this._elevation},this._normal)]))}),e}subGetIntersectCurves(){return Gx(this._geo.loops,this._elevation,this._normal)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:vr[0],value:0},{label:vr[1],value:1},{label:vr[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}},{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"associative",type:"boolean",editable:!0,accessor:{get:()=>this.associative,set:t=>{this.associative=t}}},{name:"backgroundColor",type:"color",editable:!0,accessor:{get:()=>this.backgroundColor,set:t=>{this.backgroundColor=t}}},{name:"patternDouble",type:"boolean",editable:!0,accessor:{get:()=>this.patternDouble,set:t=>{this.patternDouble=t}}},{name:"isGradient",type:"boolean",editable:!1,accessor:{get:()=>this.isGradient}},{name:"isSolidFill",type:"boolean",editable:!0,accessor:{get:()=>this.isSolidFill,set:t=>{this.isSolidFill=t}}},{name:"hatchStyle",type:"enum",editable:!0,options:[{label:Ar[0],value:0},{label:Ar[1],value:1},{label:Ar[2],value:2}],accessor:{get:()=>this.hatchStyle,set:t=>{this.hatchStyle=t}}},{name:"gradientAngle",type:"float",editable:!0,accessor:{get:()=>this.gradientAngle,set:t=>{this.gradientAngle=t}}},{name:"gradientName",type:"string",editable:!0,accessor:{get:()=>this.gradientName,set:t=>{this.gradientName=t}}},{name:"gradientType",type:"enum",editable:!0,options:[{label:_a[0],value:0},{label:_a[1],value:1}],accessor:{get:()=>this.gradientType,set:t=>{this.gradientType=t}}},{name:"gradientShift",type:"float",editable:!0,accessor:{get:()=>this.gradientShift,set:t=>{this.gradientShift=t}}},{name:"gradientOneColorMode",type:"boolean",editable:!0,accessor:{get:()=>this.gradientOneColorMode,set:t=>{this.gradientOneColorMode=t}}},{name:"shadeTintValue",type:"float",editable:!0,accessor:{get:()=>this.shadeTintValue,set:t=>{this.shadeTintValue=t}}},{name:"gradientStartColor",type:"int",editable:!0,accessor:{get:()=>this.gradientStartColor??0,set:t=>{this.gradientStartColor=t}}},{name:"gradientEndColor",type:"int",editable:!0,accessor:{get:()=>this.gradientEndColor??0,set:t=>{this.gradientEndColor=t}}},{name:"hatchObjectType",type:"enum",editable:!0,options:[{label:ba[0],value:0},{label:ba[1],value:1}],accessor:{get:()=>this.hatchObjectType,set:t=>{this.hatchObjectType=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subGetGripPoints(){return this.associative?[]:this.collectBoundaryGripPoints()}subMoveGripPointsAt(t,e){return this.associative?this:(Et(t,n=>{this.moveBoundaryGripPointAt(n,e)}),this.invalidateAreasFromLoopsCache(),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,n=new Set,r=s=>{const a=`${s.x},${s.y},${s.z??0}`;n.has(a)||(n.add(a),t.push(new x(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof ot){const a=s.numberOfVertices;for(let o=0;o<a;o++){const c=s.getPointAt(o);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(a=>{if(a instanceof yt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});else if(a instanceof tt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e}),r({x:a.midPoint.x,y:a.midPoint.y,z:e});else if(a instanceof qe){r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});const o=a.getPoint(.5);r({x:o.x,y:o.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let n=0;const r=this._elevation,s=new Set,a=(o,c)=>{const l=`${o.x},${o.y},${o.z??0}`;s.has(l)||(s.add(l),n===t&&c(),n++)};this._geo.loops.forEach(o=>{if(o instanceof ot){const c=o.numberOfVertices;for(let l=0;l<c;l++){const h=o.vertices[l];h&&a({x:h.x,y:h.y,z:r},()=>{yr(o.vertices,l,e)})}return}o.curves.forEach(c=>{if(c instanceof yt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof tt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),a({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof qe){a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);a({x:l.x,y:l.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"mid",e))}})})}moveCircArc2dGripPoint(t,e,n){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"mid":{const s=t.midPoint,a=new tt(t.startPoint,{x:s.x+n.x,y:s.y+n.y},t.endPoint);t.center=a.center,t.radius=a.radius,t.startAngle=a.startAngle,t.endAngle=a.endAngle,t.clockwise=a.clockwise;break}}}moveEllipseArc2dGripPoint(t,e,n){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"mid":{const s=t.getPoint(.5),a=s.x+n.x-t.center.x,o=s.y+n.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(a,o);if(c>0&&l>0){const h=l/c;t.majorAxisRadius*=h,t.minorAxisRadius*=h}break}}}subGetOsnapPoints(t,e,n,r){const s=this._elevation,a=[];if(this._geo.loops.forEach(o=>{var c;if(o instanceof ot){const l=o,h=l.numberOfVertices;if(h===0)return;switch(t){case T.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new x(d.x,d.y,s))}break;case T.MidPoint:case T.Nearest:case T.Perpendicular:case T.Tangent:{const u=o.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Yr(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===T.MidPoint?r.push(...g):a.push(...g)}break}}return}o.curves.forEach(l=>{if(l instanceof yt){const h=[];Yr(l.startPoint,l.endPoint,void 0,s,t,e,h),t===T.MidPoint?r.push(...h):t===T.Nearest||t===T.Perpendicular||t===T.Tangent?a.push(...h):r.push(...h)}else if(l instanceof tt)switch(t){case T.EndPoint:r.push(new x(l.startPoint.x,l.startPoint.y,s),new x(l.endPoint.x,l.endPoint.y,s));break;case T.MidPoint:r.push(new x(l.midPoint.x,l.midPoint.y,s));break;case T.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new x(h.x,h.y,s));break}case T.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}case T.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}}else if(l instanceof qe)switch(t){case T.EndPoint:r.push(new x(l.startPoint.x,l.startPoint.y,s),new x(l.endPoint.x,l.endPoint.y,s));break;case T.MidPoint:{const h=l.getPoint(.5);r.push(new x(h.x,h.y,s));break}case T.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new x(h.x,h.y,s));break}case T.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}case T.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}}})}),(t===T.Nearest||t===T.Perpendicular||t===T.Tangent)&&a.length>0){const o=ye(e,a);r.length=0,o&&r.push(o)}}get directBatchPrimitive(){return!this.isSolidFill||this.isGradient||this.buildAreasFromLoops().length>1?null:"area"}resolveAnnotativePresentation(){var o;const t=this.getEffectivePatternScale(),e=Wt(this),n=e.length>0||pe(this);let r=t,s,a;if(n&&e.length>0){s=He(e,(o=this.database)==null?void 0:o.cannoscale)??e.find(l=>l.isDefault)??e[0],a=Ge(e,s);const c=s.contextData;c instanceof Fi&&c.patternScale>0?r=c.patternScale:r=Be(Re(t,e),s.scale.scaleFactor)}else n&&(a=Gn(this).annotationScale);return{patternScale:r,preferred:s,annotationScale:a}}subWorldDraw(t){var s;const e=this.resolveAnnotativePresentation(),n=this._patternScale,r=this._patternScaleSet;this._patternScale=e.patternScale,this._patternScaleSet=!0;try{this.updatePredefinedPatternDefinitionLines();const a=t.subEntityTraits;a.fillType={solidFill:this.isSolidFill,patternAngle:this.getRenderablePatternAngle(),definitionLines:this.definitionLines,backgroundColor:(s=this.backgroundColor)==null?void 0:s.clone(),gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},a.drawOrder=-1;const o=this.buildAreasFromLoops();let c;if(o.length===0)c=t.area(this._geo);else if(o.length===1)c=t.area(o[0]);else{const l=o.map(h=>t.area(h));c=t.group(l)}if(c&&this.annotative){let l=e.annotationScale;l||(l={drawnScaleFactor:1,supportedScaleFactors:[1],supportedScaleNames:[]});const h=c.userData??(c.userData={});h.annotationScale=l}return c}finally{this._patternScale=n,this._patternScaleSet=r,this.updatePredefinedPatternDefinitionLines()}}transformBy(t){const e=t.elements,n=new is(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(n),this.invalidateAreasFromLoopsCache(),this._elevation=new x(0,0,this._elevation).applyMatrix4(t).z,this._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize();const r=new x(1,0,0).applyMatrix4(t),s=new x().applyMatrix4(t),a=new x(r).sub(s);if(a.length()>0){const o=Math.atan2(a.y,a.x);this._patternAngle=this.getEffectivePatternAngle()+o,this._gradientAngle+=o,this._patternScale=this.getEffectivePatternScale()*a.length(),this._patternAngleSet=!0,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}return this}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops,n=this.getEffectivePatternName(),r=this.getEffectivePatternAngle(),s=this.getEffectivePatternScale();if(this.updatePredefinedPatternDefinitionLines(n,s),t.writeSubclassMarker("AcDbHatch"),t.writePoint3d(10,{x:0,y:0,z:this.elevation}),t.writeVector3d(210,this.normal),t.writeString(2,n||(this.isSolidFill?Si:wf)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((a,o)=>{const c=o===0;if(a instanceof ot){const l=a.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,a.closed?1:0),t.writeInt16(93,l.length);for(const d of l)t.writePoint2d(10,d),h&&t.writeDouble(42,d.bulge??0);t.writeInt16(97,0);return}if(a instanceof _n){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,a.numberOfEdges);for(const h of a.curves){if(h instanceof yt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof tt){t.writeInt16(72,2),t.writePoint2d(10,h.center),t.writeDouble(40,h.radius),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.closed?h.startAngle+Math.PI*2:h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof qe){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new C(h.majorAxisRadius*Math.cos(h.rotation),h.majorAxisRadius*Math.sin(h.rotation));t.writePoint2d(11,u);const d=h.majorAxisRadius===0?0:h.minorAxisRadius/h.majorAxisRadius;t.writeDouble(40,d),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.closed?h.startAngle+Math.PI*2:h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof Xt){const u=h.knots,d=h.controlPoints,g=h.weights,f=h.fitPoints,p=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,p?1:0),t.writeInt16(74,h.closed?1:0),t.writeInt16(95,u.length),t.writeInt16(96,d.length),u.forEach(m=>t.writeDouble(40,m)),d.forEach((m,y)=>{t.writePoint2d(10,m),p&&t.writeDouble(42,g[y]??1)}),t.writeInt16(97,(f==null?void 0:f.length)??0),f==null||f.forEach(m=>t.writePoint2d(11,m))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,r),t.writeDouble(41,s),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(a=>{t.writeAngle(53,a.angle),t.writeDouble(43,a.base.x),t.writeDouble(44,a.base.y),t.writeDouble(45,a.offset.x),t.writeDouble(46,a.offset.y),t.writeInt16(79,a.dashLengths.length),a.dashLengths.forEach(o=>t.writeDouble(49,o))}),this._pixelSize!=null&&t.writeDouble(47,this._pixelSize),this.isGradient){t.writeInt16(450,this._hatchObjectType),t.writeInt16(451,0),t.writeDouble(460,this._gradientAngle),t.writeDouble(461,this._gradientShift),t.writeInt16(452,this._gradientOneColorMode?1:0),t.writeDouble(462,this._shadeTintValue);const a=this._gradientStartColor,o=this._gradientEndColor,c=a!=null&&o!=null?2:a!=null||o!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=Le.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};a!=null&&l(0,a),o!=null&&l(1,o),t.writeString(470,this.gradientName)}return t.writeInt16(98,0),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbHatch"),this.definitionLines.length=0;let e=this.elevation,n=this.normal.x,r=this.normal.y,s=this.normal.z,a=this.patternAngle*180/Math.PI,o=0,c=!1,l=!1,h=!1,u=[],d=null,g=[],f=null,p="type",m=0,y=!1,b=null,_=!1,w=0,k;const P=F=>{w===0?this.gradientStartColor=F:this.gradientEndColor=F,w++,k=void 0},v=()=>{if(k==null)return;const F=Le.getColorByIndex(k);F!=null?P(F):k=void 0},S=()=>{d&&(u.push(d),d=null)},I=()=>{if(S(),u.length===0)return;const F=new ot;F.closed=h,u.forEach((q,L)=>{F.addVertexAt(L,{x:q.x,y:q.y,bulge:q.bulge??0})}),this.add(F),u=[]},M=()=>{if(g.length===0)return;const F=[];for(const L of g)if(L.kind==="line")F.push(new yt({x:L.sx,y:L.sy},{x:L.ex,y:L.ey}));else if(L.kind==="arc")F.push(new tt({x:L.cx,y:L.cy},L.radius,L.startDeg*Math.PI/180,L.endDeg*Math.PI/180,!L.isCcw));else if(L.kind==="ellipse"){const $=Math.hypot(L.mx,L.my),ct=$*L.ratio;let B=L.startDeg*Math.PI/180,Ft=L.endDeg*Math.PI/180;const ne=Math.atan2(L.my,L.mx);L.isCcw||(B=Math.PI*2-B,Ft=Math.PI*2-Ft),F.push(new qe({x:L.cx,y:L.cy,z:0},$,ct,B,Ft,!L.isCcw,ne))}else{const $=Xt.fromDwgSplineEdge({degree:L.degree,numberOfControlPoints:L.controlPoints.length,numberOfKnots:L.knots.length,numberOfFitData:L.fitPoints.length,knots:L.knots,controlPoints:L.controlPoints.map(ct=>({x:ct.x,y:ct.y,z:0,weight:L.rational?ct.weight??1:void 0})),fitDatum:L.fitPoints.map(ct=>({x:ct.x,y:ct.y,z:0})),startTangent:null,endTangent:null});$&&F.push($)}const q=_n.buildFromEdges(F);q.length===1?this.add(q[0]):F.length>0&&this.add(new _n(F)),g=[],f=null},O=()=>{c?I():M()},N=()=>{f&&(g.push(f),f=null)},nt=()=>{N(),O(),m=Math.max(0,m-1),m===0&&(_=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const F=t.readItem();if(!F)break;const q=Number(F.code),L=Number(F.value);if(y||_){switch(q){case 75:this.hatchStyle=L,_=!0;break;case 76:this.patternType=L;break;case 52:a=L;break;case 41:this.patternScale=L;break;case 77:break;case 78:y=!0;break;case 53:b&&this.definitionLines.push(b),b={angle:L*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:b&&(b.base.x=L);break;case 44:b&&(b.base.y=L);break;case 45:b&&(b.offset.x=L);break;case 46:b&&(b.offset.y=L);break;case 79:break;case 49:b&&b.dashLengths.push(L);break;case 47:this.pixelSize=L;break;case 99:break;case 450:this.hatchObjectType=L,this.gradientStartColor=void 0,this.gradientEndColor=void 0,w=0,k=void 0;break;case 451:break;case 452:this.gradientOneColorMode=L!==0;break;case 453:break;case 460:this.gradientAngle=L;break;case 461:this.gradientShift=L;break;case 462:this.shadeTintValue=L;break;case 463:v();break;case 63:k=L;break;case 421:P(L);break;case 470:v(),this.gradientName=String(F.value);break}continue}switch(q){case 10:c||f&&f.kind!=="line"&&f.kind!=="arc"&&f.kind!=="ellipse"&&f.kind,m>0&&c?(S(),d={x:L,y:0}):(f==null?void 0:f.kind)==="line"&&p==="type"?f.sx=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cx=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.push({x:L,y:0});break;case 20:m>0&&c&&d?d.y=L:(f==null?void 0:f.kind)==="line"&&p==="type"?f.sy=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cy=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].y=L);break;case 30:m<=0&&!_&&(e=L);break;case 2:this.patternName=String(F.value);break;case 70:this.isSolidFill=L!==0;break;case 71:this.associative=L!==0;break;case 91:m=L;break;case 92:m>0&&(u.length>0||g.length>0||f)&&(N(),O()),o=L,c=(o&2)!==0,l=!1,h=!1,u=[],g=[],f=null,p="type";break;case 72:c?l=L!==0:(N(),L===1?(f={kind:"line",sx:0,sy:0,ex:0,ey:0},p="type"):L===2?f={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:L===3?f={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:L===4?f={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:f=null);break;case 73:c?h=L!==0:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.isCcw=L!==0:(f==null?void 0:f.kind)==="spline"&&(f.rational=L!==0);break;case 74:(f==null?void 0:f.kind)==="spline"&&(f.closed=L!==0);break;case 93:break;case 42:c&&l&&d?d.bulge=L:(f==null?void 0:f.kind)==="spline"&&f.rational&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].weight=L);break;case 11:(f==null?void 0:f.kind)==="line"?(f.ex=L,p="line-end"):(f==null?void 0:f.kind)==="ellipse"?f.mx=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.push({x:L,y:0});break;case 21:(f==null?void 0:f.kind)==="line"?f.ey=L:(f==null?void 0:f.kind)==="ellipse"?f.my=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.length>0&&(f.fitPoints[f.fitPoints.length-1].y=L);break;case 40:(f==null?void 0:f.kind)==="arc"?f.radius=L:(f==null?void 0:f.kind)==="ellipse"?f.ratio=L:(f==null?void 0:f.kind)==="spline"&&f.knots.push(L);break;case 50:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.startDeg=L);break;case 51:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.endDeg=L);break;case 94:(f==null?void 0:f.kind)==="spline"&&(f.degree=L);break;case 95:(f==null?void 0:f.kind)==="spline"&&(f.expectedKnots=L);break;case 96:(f==null?void 0:f.kind)==="spline"&&(f.expectedControls=L);break;case 97:if((f==null?void 0:f.kind)==="spline"&&!f.fitCountSeen&&(f.controlPoints.length>0||f.knots.length>0)){f.expectedFits=L,f.fitCountSeen=!0;break}nt();break;case 75:N(),O(),m=0,_=!0,this.hatchStyle=L;break;case 210:n=L;break;case 220:r=L;break;case 230:s=L;break}}f&&(g.push(f),f=null),O(),b&&this.definitionLines.push(b),v(),this.elevation=e;const W=new A(n,r,s);return W.lengthSq()>0&&(this.normal=W),this.patternAngle=a*Math.PI/180,this}};Bh.typeName="Hatch";let Xn=Bh;const _d=new x,xd=new x,ao=class ao extends Ot{constructor(t,e){super(),this._geoData=null,this._normal=null,this._thickness=0,t!==void 0&&e!==void 0&&(this._geo=new Bt(t,e))}get dxfTypeName(){return"LINE"}get _geo(){return this._geoData==null&&(this._geoData=new Bt(new x,new x)),this._geoData}set _geo(t){this._geoData=t}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){let t=this._normal;return t==null&&(t=new A(0,0,1),this._normal=t),t}set normal(t){this.normal.copy(t).normalize()}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"line",line:this._geo.clone(),extent:"bounded"}]}get closed(){return!1}get area(){return 0}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subMoveGripPointsAt(t,e){return Et(t,n=>{switch(n){case 0:this.transformBy(z.makeTranslation(e));break;case 1:this.startPoint.add(e);break;case 2:this.endPoint.add(e);break}}),this}subGetOsnapPoints(t,e,n,r){const s=this.startPoint,a=this.endPoint;switch(t){case T.EndPoint:r.push(s),r.push(a);break;case T.MidPoint:r.push(this.midPoint);break;case T.Nearest:{const o=this._geo.project(e);r.push(o)}break;case T.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case T.Tangent:break}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this.startPoint,n=this.endPoint,r=[new x(e.x,e.y,0),new x(n.x,n.y,0)];return t.lines(r)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLine");let e=0,n=0,r=0,s=0,a=0,o=0,c=this.thickness,l=0,h=0,u=1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),f=Number(d.value);switch(g){case 10:e=f;break;case 20:n=f;break;case 30:r=f;break;case 11:s=f;break;case 21:a=f;break;case 31:o=f;break;case 39:c=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break}}return(l!==0||h!==0||u!==1)&&l*l+h*h+u*u>0&&this.normal.set(l,h,u).normalize(),this.thickness=c,_d.set(e,n,r),xd.set(s,a,o),this._geo=new Bt(_d,xd),this}getOffsetCurves(t){const e=this._geo.offset(t);return[new ao(e.startPoint,e.endPoint)]}getOffsetSideAtPoint(t){const e=this.startPoint,n=this.endPoint;return(n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x)>=0?1:-1}};ao.typeName="Line";let $i=ao;class fh{constructor(t){this.db=t}createDefaultLayer(){const t=new X;return t.colorIndex=7,this.db.tables.layerTable.add(new ls({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new vn({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new vn({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new vn({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Eo({name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Vt({name:gt,dimtxsty:gt}))}createDefaultLayout(){const t=this.db.tables.blockTable.modelSpace,e=new In;if(e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=t.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.objects.layout.setAt(e.layoutName,e),t.layoutId=e.objectId,!this.db.tables.blockTable.getAt(lt.PAPER_SPACE_NAME_PREFIX)){const n=new lt;n.name=lt.PAPER_SPACE_NAME_PREFIX,this.db.tables.blockTable.add(n);const r=new In;r.layoutName="Layout1",r.tabOrder=1,r.blockTableRecordId=n.objectId,r.limits.min.copy({x:0,y:0}),r.limits.max.copy({x:12,y:9}),r.extents.min.copy({x:0,y:0,z:0}),r.extents.max.copy({x:12,y:9,z:0}),this.db.objects.layout.setAt(r.layoutName,r),n.layoutId=r.objectId}}createArrowBlock(){this.ensureArrowBlock("_CAXARROW"),this.ensureArrowBlock("_CLOSEDFILLED")}ensureArrowBlock(t){if(!t||this.db.tables.blockTable.getAt(t))return;const e=t.toUpperCase(),n=new lt;n.name=t;const r=(o=.125)=>{const c=new Xn;c.patternName=Si;const l=new _n;l.add(new yt({x:0,y:0},{x:-1,y:o})),l.add(new yt({x:-1,y:o},{x:-1,y:-o})),l.add(new yt({x:-1,y:-o},{x:0,y:0})),c.add(l),this.appendArrowEntity(n,c)},s=(o=.125)=>{this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-1,y:o,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-1,y:-o,z:0}))},a=(o,c)=>{if(c){const l=new Xn;l.patternName=Si;const h=new _n,u=o;h.add(new yt({x:u,y:0},{x:0,y:u})),h.add(new yt({x:0,y:u},{x:-u,y:0})),h.add(new yt({x:-u,y:0},{x:0,y:-u})),h.add(new yt({x:0,y:-u},{x:u,y:0})),l.add(h),this.appendArrowEntity(n,l)}else this.appendArrowEntity(n,this.lineEntity({x:-o,y:0,z:0},{x:o,y:0,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:-o,z:0},{x:0,y:o,z:0}))};switch(e){case"_CAXARROW":case"_CLOSEDFILLED":case"":r();break;case"_CLOSED":s(),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.125,z:0},{x:-1,y:-.125,z:0}));break;case"_CLOSEDBLANK":s(),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.125,z:0},{x:-1,y:-.125,z:0}));break;case"_OPEN":s(.1667);break;case"_OPEN30":s(.2679);break;case"_OPEN90":this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-.5,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-.5,y:-.5,z:0}));break;case"_OBLIQUE":case"_ARCHTICK":this.appendArrowEntity(n,this.lineEntity({x:-.5,y:-.5,z:0},{x:.5,y:.5,z:0}));break;case"_DOT":a(.25,!0);break;case"_DOTSMALL":case"_SMALL":a(.125,!0);break;case"_DOTBLANK":a(.25,!1);break;case"_BOXFILLED":{const o=new Xn;o.patternName=Si;const c=new _n;c.add(new yt({x:-1,y:-.5},{x:0,y:-.5})),c.add(new yt({x:0,y:-.5},{x:0,y:.5})),c.add(new yt({x:0,y:.5},{x:-1,y:.5})),c.add(new yt({x:-1,y:.5},{x:-1,y:-.5})),o.add(c),this.appendArrowEntity(n,o)}break;case"_BOXBLANK":this.appendArrowEntity(n,this.lineEntity({x:-1,y:-.5,z:0},{x:0,y:-.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:-.5,z:0},{x:0,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:.5,z:0},{x:-1,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.5,z:0},{x:-1,y:-.5,z:0}));break;case"_DATUMFILLED":r(.5);break;case"_DATUMBLANK":s(.5),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.5,z:0},{x:-1,y:-.5,z:0}));break;case"_ORIGIN":case"_ORIGIN2":a(.5,!1),a(.125,!0);break;case"_INTEGRAL":this.appendArrowEntity(n,this.lineEntity({x:0,y:-.5,z:0},{x:0,y:.5,z:0}));break;case"_NONE":break;default:r();break}this.db.tables.blockTable.add(n)}appendArrowEntity(t,e){e.color=new X().setByBlock(),t.appendEntity(e)}lineEntity(t,e){return new $i(t,e)}}const qc=Math.PI/200;class Gp{constructor(t){this.database=t}formatLength(t,e){const n=this.createContext(e);return ii(t,n)}formatPoint2d(t,e){const n=this.createContext(e);return`${ii(t.x,n)}, ${ii(t.y,n)}`}formatPoint3d(t,e){const n=this.createContext(e);return`${ii(t.x,n)}, ${ii(t.y,n)}, ${ii(t.z,n)}`}formatAngle(t,e){const n=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?Yw(t,this.database.angbase,this.database.angdir):D.normalizeAngle(t);return Xw(s,n)}createContext(t){return{lunits:this.database.lunits,luprec:$r(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:$r(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function ii(i,t){let e;switch(t.lunits){case xt.Scientific:e=lc(Kw(i,t.luprec),t);break;case xt.Engineering:e=Zw(i,t);break;case xt.Architectural:e=Qw(i,t);break;case xt.Fractional:e=lc(Jw(i,t),t);break;case xt.WindowsDesktop:case xt.Decimal:default:e=lc(sr(i,t.luprec),t)}return Wp(e,jw(i,t),t)}function Xw(i,t){let e;switch(t.aunits){case Ht.DegreesMinutesSeconds:e=Kp(i,t);break;case Ht.Gradians:e=nv(i,t);break;case Ht.Radians:e=ev(i,t);break;case Ht.SurveyorsUnits:e=iv(i,t);break;case Ht.DecimalDegrees:default:e=tv(i,t)}return Wp(e,Vw(i,t),t)}function Yw(i,t,e){let n=i-t;return e===1&&(n=-n),D.normalizeAngle(n)}function ph(i){const t=i.showUnits?'"':"";return i.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function $r(i,t=0,e=8){return Number.isFinite(i)?Math.max(t,Math.min(e,Math.round(i))):t}function rr(i){return Object.is(i,-0)?0:i}function Wp(i,t,e){return!e.showApproximate||!t?i:`~ ${i}`}function jw(i,t){if(!Number.isFinite(i))return!1;const e=Hw(i,t);return mh(i,e)}function Vw(i,t){if(!Number.isFinite(i))return!1;if(t.aunits===Ht.SurveyorsUnits)return Uw(i,t.auprec);const e=Gw(i,t);return mh(i,e)}function Uw(i,t){const n=((90-D.radToDeg(i))%360+360)%360,r=Zp(n),s=Math.min(Math.abs(n-r.base),Math.abs(r.base+90-n)),a=D.degToRad(s),o=$p(a,t);return mh(a,o)}function Hw(i,t){const e=rr(i);switch(t.lunits){case xt.Scientific:return Ww(e,t.luprec);case xt.Engineering:case xt.Architectural:case xt.Fractional:return $w(e,t);case xt.WindowsDesktop:case xt.Decimal:default:return ki(e,t.luprec)}}function Gw(i,t){const e=rr(i);switch(t.aunits){case Ht.DegreesMinutesSeconds:return $p(e,t.auprec);case Ht.Gradians:return ki(e/qc,t.auprec)*qc;case Ht.Radians:return ki(e,t.auprec);case Ht.DecimalDegrees:default:return D.degToRad(ki(D.radToDeg(e),t.auprec))}}function ki(i,t){if(!Number.isFinite(i))return 0;const e=10**t;return Math.round(rr(i)*e)/e}function Ww(i,t){if(!Number.isFinite(i))return 0;const e=rr(i);if(e===0)return 0;const n=e.toExponential(t);return Number(n)}function $w(i,t){if(!Number.isFinite(i))return 0;const e=i<0?-1:1,n=Math.abs(i),r=Math.floor(n/12),s=n-r*12;if(t.lunits===xt.Architectural||t.lunits===xt.Fractional){const a=1<<$r(t.luprec,0,8),o=qw(s,a);return e*(r*12+o)}return e*(r*12+ki(s,t.luprec))}function qw(i,t){const e=Math.floor(i),n=i-e,r=Math.round(n*t);return r>=t?e+1:e+r/t}function $p(i,t){const e=D.radToDeg(i),n=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=ki((a-o)*60,t),l=s+o/60+c/3600;return D.degToRad(n*l)}function mh(i,t){if(i===t)return!1;const e=Math.max(Math.abs(i),Math.abs(t),1);return Math.abs(i-t)>e*Number.EPSILON*8}function sr(i,t){if(!Number.isFinite(i))return"0";const e=rr(i);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function Kw(i,t){if(!Number.isFinite(i))return"0";const e=rr(i);if(e===0)return"0";const n=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!n)return"0";const[,r,s,a]=n,o=a.length<2?a.padStart(2,"0"):a;return`${r}E${s}${o}`.toUpperCase()}function Zw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=Math.floor(r/12),a=r-s*12,o=sr(a,t.luprec);return s===0?`${n}${o}${e.inchSuffix}`:`${n}${s}'${e.feetInchSeparator}${o}${e.inchSuffix}`}function Qw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=Math.floor(r/12),a=r-s*12,o=1<<$r(t.luprec,0,8),c=qp(a,o,e.fractionSeparator);return s===0?`${n}${c}${e.inchSuffix}`:`${n}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function Jw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=1<<$r(t.luprec,0,8);return`${n}${qp(r,s,e.fractionSeparator)}`}function qp(i,t,e){const n=Math.floor(i),r=i-n;let s=Math.round(r*t);if(s>=t)return String(n+1);if(s===0)return String(n);const a=ov(s,t);s/=a;const o=t/a,c=`${s}/${o}`;return n===0?c:`${n}${e}${c}`}function tv(i,t){const e=D.radToDeg(i);return`${sr(e,t.auprec)}${t.showUnits?"°":""}`}function ev(i,t){return`${sr(i,t.auprec)}${t.showUnits?" rad":""}`}function nv(i,t){const e=i/qc;return`${sr(e,t.auprec)}${t.showUnits?"g":""}`}function Kp(i,t){const e=D.radToDeg(i),n=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=(a-o)*60,l=sr(c,t.auprec),h=t.showUnits?'"':"";return`${n}${s}d${o}'${l}${h}`}function iv(i,t){const n=((90-D.radToDeg(i))%360+360)%360,r=Zp(n),s=Math.min(Math.abs(n-r.base),Math.abs(r.base+90-n)),o=Kp(D.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${o} ${r.suffix}`.trim()}function Zp(i){return i<90?{prefix:"N",suffix:"E",base:0}:i<180?{prefix:"S",suffix:"E",base:90}:i<270?{prefix:"S",suffix:"W",base:180}:{prefix:"N",suffix:"W",base:270}}function lc(i,t){if(!t.showUnits||t.lunits===xt.Engineering||t.lunits===xt.Architectural)return i;const e=rv(t.insunits,t.measurement);return e?`${i}${e}`:i}function rv(i,t){return i===mt.Undefined?t===0?'"':" mm":Kx(i)?sv(i):Zx(i)?av(i):""}function sv(i){switch(i){case mt.Millimeters:return" mm";case mt.Centimeters:return" cm";case mt.Meters:return" m";case mt.Kilometers:return" km";case mt.Decimeters:return" dm";case mt.Microns:return" µm";case mt.Nanometers:return" nm";default:return""}}function av(i){switch(i){case mt.Inches:case mt.Microinches:case mt.Mils:case mt.USSurveyInch:return'"';case mt.Feet:case mt.USSurveyFeet:return"'";case mt.Miles:case mt.USSurveyMile:return" mi";case mt.Yards:case mt.USSurveyYard:return" yd";default:return""}}function ov(i,t){let e=Math.abs(i),n=Math.abs(t);for(;n!==0;){const r=n;n=e%n,e=r}return e||1}class Pe extends pt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this.ownerId=t.objectId,this._recordsByName=new Map,this._unnamedRecords=[]}get numEntries(){return this._recordsByName.size}get totalRecordCount(){return this._recordsByName.size+this._unnamedRecords.length}add(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot add symbol table records outside an active transaction.");const n=e.resolveSymbolTableName(this);t.database=this.database,this.database.commitObjectHandle(t,s=>this.hasId(s)),t.ownerId=this.objectId;const r=this.normalizeName(t.name);r?this._recordsByName.set(r,t):this._unnamedRecords.push(t),e.isRecording()&&e.recordAppend({type:"symbolTable",tableName:n},t)}remove(t){const e=this.normalizeName(t),n=this._recordsByName.get(e);return n?(this.removeRecord(n),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this.removeRecord(e),!0):!1}removeRecord(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove symbol table records outside an active transaction.");if(e.isRecording()){const n=e.resolveSymbolTableName(this);e.recordRemove({type:"symbolTable",tableName:n},t)}this.removeFromMembership(t),this.database.releaseObjectHandle(t)}removeAll(){for(const t of this._recordsByName.values())this.database.releaseObjectHandle(t);for(const t of this._unnamedRecords)this.database.releaseObjectHandle(t);this._recordsByName.clear(),this._unnamedRecords.length=0}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}getOwnerIdAt(t){return this.getIdAt(t)}newIterator(t=!1){return t?new Hn([...this._recordsByName.values(),...this._unnamedRecords]):new Hn(this._recordsByName)}normalizeName(t){return(t??"").trim().toUpperCase()}get dxfEntryCount(){return this.numEntries}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.dxfEntryCount),this}removeFromMembership(t){const e=this.normalizeName(t.name);if(e){this._recordsByName.delete(e);return}const n=this._unnamedRecords.indexOf(t);n>=0&&this._unnamedRecords.splice(n,1)}}class Qp extends Pe{constructor(t){super(t)}get modelSpace(){let t=this.getAt(lt.MODEL_SPACE_NAME);return t||(t=new lt,t.name=lt.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof et)return e}removeEntity(t){let e=!1;for(const n of this.database.tables.blockTable.newIterator())if(n.removeEntity(t)){e=!0;break}return e}getXrefs(){const t=[];for(const e of this.newIterator())e.isXref&&t.push(e);return t}getUnresolvedXrefs(){return this.getXrefs().filter(t=>t.isUnresolvedXref)}normalizeName(t){const e=(t??"").trim();if(!e)return"";if(lt.isModelSapceName(e))return lt.MODEL_SPACE_NAME;if(lt.isPaperSapceName(e)){const n=lt.PAPER_SPACE_NAME_PREFIX,r=e.substring(n.length);return n+r}return super.normalizeName(e)}}const Jp="DwgConverterLicenseError",cv=["evaluation of @mlightcad/dwg-converter has expired"],lv=["invalid @mlightcad/dwg-converter license key"];function tm(i){return i==="license_expired"||i==="license_invalid"}function yh(i){const t=i.toLowerCase();if(cv.some(e=>t.includes(e)))return"license_expired";if(lv.some(e=>t.includes(e)))return"license_invalid"}function em(i){return yh(i)??"license_invalid"}const hv=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];function nm(i){const t=i.toLowerCase();return hv.some(e=>t.includes(e))}function hc(){const i=globalThis;if(typeof i.postMessage!="function")throw new Error("Worker messaging is not available in this runtime");return i}class uv{constructor(){this.setupMessageHandler()}setupMessageHandler(){hc().onmessage=async t=>{const e=t,{id:n,input:r}=e.data;try{const s=await this.executeTask(r);this.sendResponse(n,!0,s)}catch(s){const a=s instanceof Error?s.message:String(s);this.sendResponse(n,!1,void 0,a,this.classifyTaskError(s,a))}}}sendResponse(t,e,n,r,s){const a={id:t,success:e,data:n,error:r,errorCode:s};try{hc().postMessage(a)}catch(o){const c=o instanceof Error?o.message:String(o);hc().postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyTaskError(t,e){if(t instanceof Error){const r=t.code;if(tm(r))return r;if(t.name===Jp)return em(e)}const n=yh(e);return n||this.classifyPostMessageError(e)}classifyPostMessageError(t){return nm(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"}}class zt extends Error{constructor(t,e,n){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=n==null?void 0:n.stage,this.cause=n==null?void 0:n.cause}static isLicenseErrorCode(t){return tm(t)}static isWorkerOutOfMemoryMessage(t){return nm(t)}static classifyThrownError(t){if(t instanceof Error){const n=zt.readStructuredCode(t);if(n)return n;if(t.name===Jp)return em(t.message)}const e=t instanceof Error?t.message:String(t);return zt.classifyWorkerErrorMessage(e)}static classifyWorkerErrorMessage(t){const e=yh(t);return e||(zt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error")}static from(t,e){if(t instanceof zt)return t;const n=t instanceof Error?t.message:String(t),r=zt.classifyThrownError(t);return new zt(n,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return zt.from(t.error,e)}static throwOnWorkerParseFailure(t,e="PARSE"){if(t.success)return;const n=t.error!=null?`Failed to parse drawing due to error: '${t.error}'`:"Failed to parse drawing due to an unknown worker error",r=zt.mapWorkerResultCode(t.errorCode,t.error);throw new zt(n,r,{stage:e})}static mapWorkerResultCode(t,e){switch(t){case"worker_oom":return"worker_oom";case"worker_timeout":return"worker_timeout";case"worker_error":return"worker_error";case"license_expired":return"license_expired";case"license_invalid":return"license_invalid";default:return zt.classifyWorkerErrorMessage(e??"")}}static readStructuredCode(t){const e=t.code;if(typeof e=="string")switch(e){case"license_expired":case"license_invalid":case"worker_oom":case"worker_timeout":case"worker_error":case"parse_failed":case"font_load_failed":case"fetch_failed":case"unknown":return e;default:return}}}class im extends Pe{constructor(t){super(t)}}class rm extends Pe{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class sm extends Pe{constructor(t){super(t)}}class qr extends Pe{constructor(t){super(t)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}get dxfEntryCount(){return this.totalRecordCount}resolveAt(t){this.database.ensureTextStyleDefaults();const e=[],n=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};n(t),n(this.database.textstyle),n(gt),n("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const a=r.toUpperCase();for(const o of this.newIterator())if(o.name.toUpperCase()===a)return o}return this.newIterator().next().value??void 0}get shapeFiles(){return this.newIterator(!0).toArray().filter(t=>t.isShapeFile)}get fonts(){const t=new Set;for(const e of this.newIterator()){const n=qr.normalizeFontFileName(e.fileName);n&&t.add(n);const r=qr.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class am extends Pe{constructor(t){super(t)}}class om extends Pe{constructor(t){super(t)}}class cm extends Pe{constructor(t){super(t)}normalizeName(t){const e=(t??"").trim();return e?An.isActiveVportName(e)?Ri:super.normalizeName(e):""}getActiveVport(){return this.getAt(Ri)}getActiveVportBox(t,e){const n=this.getActiveVport();return n==null?void 0:n.resolveModelViewBox(t,e)}}class lm extends Pe{constructor(t){super(t)}}class hm extends G{getBtrIdAt(t){for(const[e,n]of this._recordsByName)if(n.blockTableRecordId==t)return n}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class um{constructor(t){this.database=t}applyForward(t){for(const e of t)this.applyChange(e,!0)}applyInverse(t){for(let e=t.length-1;e>=0;e--)this.applyChange(t[e],!1)}applyChange(t,e){switch(t.kind){case"modify":this.applyModify(t,e);break;case"append":e?this.applyAppend(t.container,t.object):this.applyRemove(t.container,t.object);break;case"remove":e?this.applyRemove(t.container,t.object):this.applyAppend(t.container,t.object);break;case"sysvar":this.applySysvar(t,e);break}}applyModify(t,e){const n=this.database.getObjectById(t.objectId);if(!n)return;const r=e?t.after:t.before;r&&n.restoreFrom(r)}applySysvar(t,e){const n=e?t.after:t.before;n!==void 0&&wt.instance().setVar(t.name,n,this.database)}applyAppend(t,e){switch(t.type){case"blockTableRecord":{const n=this.database.tables.blockTable.getIdAt(t.ownerId);n&&n.appendEntity(e);break}case"symbolTable":{const n=this.getSymbolTable(t.tableName);n&&n.add(e);break}case"dictionary":{const n=this.database.getObjectById(t.dictionaryId);n&&n.setAt(t.key,e);break}}}applyRemove(t,e){switch(t.type){case"blockTableRecord":{const n=this.database.tables.blockTable.getIdAt(t.ownerId);n&&n.removeEntity(e.objectId);break}case"symbolTable":{const n=this.getSymbolTable(t.tableName);n&&n.removeId(e.objectId);break}case"dictionary":{const n=this.database.getObjectById(t.dictionaryId);n&&n.removeId(e.objectId);break}}}getSymbolTable(t){const e=this.database.tables;switch(t){case"appIdTable":return e.appIdTable;case"blockTable":return e.blockTable;case"dimStyleTable":return e.dimStyleTable;case"linetypeTable":return e.linetypeTable;case"textStyleTable":return e.textStyleTable;case"viewTable":return e.viewTable;case"layerTable":return e.layerTable;case"viewportTable":return e.viewportTable;default:return}}}function Kc(i,t){const e=[],n=[],r=[];for(const s of t)if(s.kind==="modify"){const a=i.getObjectById(s.objectId);a instanceof et&&e.push(a)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const a=i.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof et?s.object:void 0);a&&n.push(a)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof et&&r.push(s.object);return{modified:e,appended:n,erased:r}}function wd(i,t){const e=[],n=[];for(const r of t){if(r.kind!=="append"&&r.kind!=="remove"||r.container.type!=="dictionary")continue;const s=r.container.key;if(r.kind==="append"){const a=i.getObjectById(r.object.objectId)??r.object;e.push({object:a,key:s})}else r.kind==="remove"&&n.push({object:r.object,key:s})}return{set:e,erased:n}}function vd(i,t){const e={};for(const n of nw){const r=i.getAttrWithoutException(n),s=t.getAttrWithoutException(n);pn(r,s)||(e[n]=s)}return e}function Ad(i,t,e=!1){const n=[];for(const r of t){if(r.kind!=="modify")continue;const s=i.getObjectById(r.objectId);if(!(s instanceof ls))continue;const a=r.before,o=r.after;if(!a||!o)continue;const c=e?vd(o,a):vd(a,o);Object.keys(c).length!==0&&n.push({database:i,layer:s,changes:c})}return n}function dv(i,t){if(i.type!==t.type)return!1;switch(i.type){case"blockTableRecord":return t.type==="blockTableRecord"&&i.ownerId===t.ownerId;case"symbolTable":return t.type==="symbolTable"&&i.tableName===t.tableName;case"dictionary":return t.type==="dictionary"&&i.dictionaryId===t.dictionaryId&&i.key===t.key}}class dm{constructor(){this.changes=[]}getChanges(){return this.changes}clear(){this.changes.length=0}mergeFrom(t){for(const e of t.getChanges())this.mergeChange(e)}recordModify(t){const e=t.objectId;this.changes.find(r=>r.kind==="modify"&&r.objectId===e)||this.changes.push({kind:"modify",objectId:e,before:t.clonePreservingIdentity()})}hasModify(t){return this.changes.some(e=>e.kind==="modify"&&e.objectId===t)}recordAppend(t,e){this.recordStructuralChange({kind:"append",container:t,object:e.clonePreservingIdentity()})}recordRemove(t,e){this.recordStructuralChange({kind:"remove",container:t,object:e.clonePreservingIdentity()})}recordSysvar(t,e){const n=t.toLowerCase();this.changes.find(s=>s.kind==="sysvar"&&s.name===n)||this.changes.push({kind:"sysvar",name:n,before:e})}finalize(t){for(const e of this.changes)if(e.kind==="modify"){const n=t.getObjectById(e.objectId);n&&(e.after=n.clonePreservingIdentity())}else e.kind==="sysvar"&&(e.after=this.getSysvarValue(t,e.name))}recordStructuralChange(t){const e=t.kind==="append"?"remove":"append",n=this.findStructuralChangeIndex(e,t.container,t.object.objectId);if(n>=0){this.changes.splice(n,1);return}this.changes.push(t)}mergeChange(t){if(t.kind==="modify"){this.changes.find(n=>n.kind==="modify"&&n.objectId===t.objectId)||this.changes.push(t);return}if(t.kind==="sysvar"){this.changes.find(n=>n.kind==="sysvar"&&n.name===t.name)||this.changes.push(t);return}this.recordStructuralChange(t)}findStructuralChangeIndex(t,e,n){return this.changes.findIndex(r=>r.kind===t&&r.object.objectId===n&&dv(r.container,e))}getSysvarValue(t,e){return wt.instance().getVar(e,t)}}class bh{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new dm}getObject(t,e,n=!1){const r=this.openedObjects.get(t);if(r){if(e===Yi.kForWrite&&!this.originalStates.has(t)){const a=r.clonePreservingIdentity();this.originalStates.set(t,a),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,n);if(this.openedObjects.set(t,s),e===Yi.kForWrite){const a=s.clonePreservingIdentity();this.originalStates.set(s.objectId,a),this.recorder.recordModify(s)}return s}commit(){this.originalStates.clear(),this.openedObjects.clear()}abort(){for(const[t,e]of this.originalStates){const n=this.openedObjects.get(t);n&&n.restoreFrom(e)}this.originalStates.clear(),this.openedObjects.clear(),this.recorder.clear()}lookupObject(t,e){throw new Error(`lookupObject(${t}) not implemented`)}}class gm extends bh{constructor(t){super(),this.database=t}lookupObject(t,e){const n=this.database.getObjectById(t,e);if(!n)throw new Error(`lookupObject(${t}) not found`);return n}}class fm{constructor(){this.undoRecords=[],this.redoRecords=[],this.maxDepth=100}push(t){this.undoRecords.push(t),this.redoRecords.length=0,this.trimUndoRecords()}pushUndo(t){this.undoRecords.push(t),this.trimUndoRecords()}trimUndoRecords(){this.undoRecords.length>this.maxDepth&&this.undoRecords.shift()}popUndo(){return this.undoRecords.pop()}pushRedo(t){this.redoRecords.push(t)}popRedo(){return this.redoRecords.pop()}canUndo(){return this.undoRecords.length>0}canRedo(){return this.redoRecords.length>0}clear(){this.undoRecords.length=0,this.redoRecords.length=0}}class pm{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new fm,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new um(t)}startTransaction(){const t=new gm(this.database);return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}hasTransaction(){return this.transactionStack.length>0}isRecording(){return this.hasTransaction()&&!this._applyingUndoRedo}isApplyingUndoRedo(){return this._applyingUndoRedo}isOpenedForWriteInTransaction(t){for(const e of this.transactionStack)if(e.recorder.hasModify(t))return!0;return!1}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");if(this.transactionStack.length>0){this.transactionStack[this.transactionStack.length-1].recorder.mergeFrom(t.recorder),t.commit();return}t.recorder.finalize(this.database);const e=t.recorder.getChanges();t.commit(),e.length>0&&(this.dispatchCommitEvents(e),this.enqueueUndoChanges(e))}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");const e=[...t.recorder.getChanges()];this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{t.abort(),e.length>0&&this.changeApplier.applyInverse(e)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}}startUndoMark(t){this.undoMarkStack.push({label:t,pendingChanges:[]})}endUndoMark(){const t=this.undoMarkStack.pop();if(!t)throw new Error("No active undo mark to end.");t.pendingChanges.length!==0&&this.undoStack.push({label:t.label,changes:t.pendingChanges})}cancelUndoMark(){this.undoMarkStack.length>0&&this.undoMarkStack.pop()}undo(){const t=this.undoStack.popUndo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyInverse(t.changes),this.dispatchUndoRedoEvents(t.changes,!0)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushRedo(t),!0}redo(){const t=this.undoStack.popRedo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyForward(t.changes),this.dispatchUndoRedoEvents(t.changes,!1)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushUndo(t),!0}canUndo(){return this.undoStack.canUndo()}canRedo(){return this.undoStack.canRedo()}clearUndoStack(){this.undoStack.clear()}recordAppend(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordAppend(t,e))}recordRemove(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordRemove(t,e))}recordSysvar(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordSysvar(t,e))}resolveSymbolTableName(t){const e=this.database.tables;return t===e.appIdTable?"appIdTable":t===e.blockTable?"blockTable":t===e.dimStyleTable?"dimStyleTable":t===e.linetypeTable?"linetypeTable":t===e.textStyleTable?"textStyleTable":t===e.viewTable?"viewTable":t===e.layerTable?"layerTable":t===e.viewportTable?"viewportTable":t.objectId}runUndoable(t,e){this.startUndoMark(t),this.startTransaction();try{const n=e(this.currentTransaction());return this.commitTransaction(),this.endUndoMark(),n}catch(n){throw this.hasTransaction()&&this.abortTransaction(),this.cancelUndoMark(),n}}enqueueUndoChanges(t){const e=this.undoMarkStack[this.undoMarkStack.length-1];if(e)for(const n of t)e.pendingChanges.push(n)}dispatchCommitEvents(t){const{modified:e,appended:n,erased:r}=Kc(this.database,t);for(const o of e)this.dispatchEntityModified(o);n.length>0&&this.database.notifyEntityAppended(n),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:a}=wd(this.database,t);for(const{object:o,key:c}of s)this.database.notifyDictObjectSet(o,c);for(const{object:o,key:c}of a)this.database.notifyDictObjectErased(o,c);for(const o of t)o.kind==="sysvar"&&o.after!==void 0&&wt.instance().events.sysVarChanged.dispatch({database:this.database,name:o.name,oldVal:o.before,newVal:o.after});for(const o of Ad(this.database,t))this.dispatchLayerModified(o)}dispatchUndoRedoEvents(t,e){const{modified:n,appended:r,erased:s}=Kc(this.database,t),{set:a,erased:o}=wd(this.database,t);if(e){for(const c of n)this.dispatchEntityModified(c);s.length>0&&this.database.notifyEntityAppended(s),r.length>0&&this.database.notifyEntityErased(r);for(const{object:c,key:l}of o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)this.database.notifyDictObjectErased(c,l)}else{for(const c of n)this.dispatchEntityModified(c);r.length>0&&this.database.notifyEntityAppended(r),s.length>0&&this.database.notifyEntityErased(s);for(const{object:c,key:l}of a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)this.database.notifyDictObjectErased(c,l)}for(const c of t)if(c.kind==="sysvar"){const l=e?c.after:c.before,h=e?c.before:c.after;h!==void 0&&wt.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of Ad(this.database,t,e))this.dispatchLayerModified(c)}dispatchLayerModified(t){if(this.database.isEventBatched()){const e=this._pendingLayerModified.get(t.layer.objectId);if(e){e.changes={...e.changes,...t.changes};return}this._pendingLayerModified.set(t.layer.objectId,{database:t.database,layer:t.layer,changes:{...t.changes}});return}this.database.events.layerModified.dispatch(t)}dispatchEntityModified(t){if(this.database.isEventBatched()){this._pendingEntityModified.add(t);return}this.database.events.entityModified.dispatch({database:this.database,entity:t})}flushPendingLayerModifiedEvents(){if(this._pendingLayerModified.size===0)return;const t=[...this._pendingLayerModified.values()];this._pendingLayerModified.clear();for(const e of t)this.database.events.layerModified.dispatch(e)}flushPendingEntityModifiedEvents(){if(this._pendingEntityModified.size===0)return;const t=[...this._pendingEntityModified];this._pendingEntityModified.clear();for(const e of t)this.database.events.entityModified.dispatch({database:this.database,entity:e})}}function gv(i,t){if(i instanceof Xp||i instanceof G)return i.dxfTypeName;if(i instanceof In)return"LAYOUT";if(i instanceof Pi)return"GROUP";if(i instanceof os)return"XRECORD";if(i instanceof uh)return"SORTENTSTABLE";if(i instanceof hh)return"IMAGEDEF";if(i instanceof ch)return"LAYER_FILTER";if(i instanceof lh)return"LAYER_INDEX";if(i instanceof us)return"MLEADERSTYLE";if(i instanceof Lo)return"MLINESTYLE";if(i instanceof Pn)return"SCALE";if(i instanceof xr)return"DICTIONARYVAR";if(i instanceof Wl){const e=i.dxfRecordName??fv(i);return e&&(i.hasDxfRawTags||t.has(e.toUpperCase()))?e:void 0}}function fv(i){if(i instanceof Fr)return"ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS";if(i instanceof Ue)return"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS";if(i instanceof tr)return"ACDB_TEXTOBJECTCONTEXTDATA_CLASS";if(i instanceof Fi)return"ACDB_HATCHSCALECONTEXTDATA_CLASS";if(i instanceof Bi)return"ACDB_BLKREFOBJECTCONTEXTDATA_CLASS";if(i instanceof zi)return"ACDB_MLEADEROBJECTCONTEXTDATA_CLASS";if(i instanceof So)return"ACDB_LEADEROBJECTCONTEXTDATA_CLASS"}const pv=new Set(["$ACADVER","$HANDSEED","$DWGCODEPAGE","$INSUNITS","$LUNITS","$LUPREC","$UNITMODE","$MEASUREMENT","$LTSCALE","$LWDISPLAY","$CELTSCALE","$CELWEIGHT","$CECOLOR","$TILEMODE","$PSLTSCALE","$CLAYER","$CELTYPE","$CETRANSPARENCY","$CMLSTYLE","$CMLSCALE","$CMLEADERSTYLE","$HPCOLOR","$HPBACKGROUNDCOLOR","$HPLAYER","$HPTRANSPARENCY","$TEXTSTYLE","$DIMSTYLE","$ANGBASE","$ANGDIR","$AUNITS","$AUPREC","$EXTMIN","$EXTMAX","$PDMODE","$PDSIZE","$OSMODE","$ORTHOMODE"]),Mr=class Mr extends pt{constructor(){super({objectId:"0"}),this._classes=[],this._dimStyleAnnotationScales=new Map,this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._drawCircleSides=$c,this._dxfHeaderExtras=[],this._dxfHeaderExtrasVersion=0,this._dxfUnknownObjects=[],this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new vt,dictObjectErased:new vt,entityAppended:new vt,entityModified:new vt,entityErased:new vt,layerAppended:new vt,layerModified:new vt,layerErased:new vt,openProgress:new vt,openFailed:new vt},Mr._unsavedDrawingSequence+=1,this._dwgname=`Drawing${Mr._unsavedDrawingSequence}.dwg`,this._version=new Lt("AC1014"),this._dwgCodePage=void 0,this._angbase=0,this._angdir=0,this._aunits=Ht.DecimalDegrees,this._auprec=0,this._lunits=xt.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new X,this._celtype=kt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new St,this._clayer="0",this._cmlstyle=tn,this._cmlscale=1,this._cmleaderstyle=en,this._hpbackgroundcolor=new X(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new St,this._textstyle=gt,this._dimstyle=gt,this._extents=new H,this._insunits=mt.Millimeters,this._unitmode=0,this._measurement=1,this._ltscale=1,this._lwdisplay=!1,this._tilemode=1,this._psltscale=!0,this._cannoscale="1:1",this._dimStyleAnnotationScales=new Map,this._annoallvisible=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._orthomode=0,this._comparehatch=ra,this._comparercmargin=sa,this._comparetext=aa,this._comparetolerance=oa,this._maxHandle=0,this._tables={appIdTable:new lm(this),blockTable:new Qp(this),dimStyleTable:new im(this),linetypeTable:new sm(this),textStyleTable:new qr(this),ucsTable:new am(this),viewTable:new om(this),layerTable:new rm(this),viewportTable:new cm(this)},this._objects={dictionary:new G(this),dictionaryVar:new G(this),group:new G(this),imageDefinition:new G(this),layerFilter:new G(this),layerIndex:new G(this),layout:new hm(this),mleaderStyle:new G(this),mlineStyle:new G(this),objectContextData:new G(this),scale:new G(this),sortentsTable:new G(this),xrecord:new G(this)},this._layerFilters=new rn,this.transactionManager=new pm(this),this.registerBootstrapHandles()}get tables(){return this._tables}get classes(){return this._classes}set classes(t){this._classes=t.map(e=>({...e}))}get objects(){return this._objects}get layerFilters(){return this._layerFilters}set layerFilters(t){this._layerFilters=t??new rn}getObjectById(t,e=!1){return t===this.objectId?this:this._handleRegistry.get(t)}createExtensionDictionaryFor(t){const e=t.extensionDictionary;if(e)return e;const n=new G(this);return n.database=this,n.ownerId=t.objectId,this.commitObjectHandle(n),t.extensionDictionary=n.objectId,n.objectId}isUndoRecording(){return this.transactionManager.isRecording()}openObject(t,e){const n=this.transactionManager.currentTransaction();if(n){const r=n.getObject(t,e);if(r)return r}return this.getObjectById(t)}openObjectForRead(t){return this.openObject(t,Yi.kForRead)}openObjectForWrite(t){return this.openObject(t,Yi.kForWrite)}openEntityForRead(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForRead(e)}openEntityForWrite(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForWrite(e)}runDatabaseEdit(t,e){if(this.isUndoRecording()){e();return}this.transactionManager.runUndoable(t,e)}getRootDictionaries(){return[this.objects.dictionary,this.objects.dictionaryVar,this.objects.group,this.objects.imageDefinition,this.objects.layerFilter,this.objects.layerIndex,this.objects.layout,this.objects.mleaderStyle,this.objects.mlineStyle,this.objects.objectContextData,this.objects.scale,this.objects.sortentsTable,this.objects.xrecord]}beginEventBatch(){this._eventBatchDepth++}endEventBatch(){this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth===0&&(this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents(),this.flushEventBatch()))}async endEventBatchChunked(t,e){if(this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth!==0))return;this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents();const n=this._pendingEntityAppended;this._pendingEntityAppended=[];const r=n.length,s=Math.max(1,t);if(r===0){this.flushEventBatchRemainder();return}let a=0;try{for(let o=0;o<r;o+=s){const c=Math.min(o+s,r),l=n.slice(o,c);this.events.entityAppended.dispatch({database:this,entity:l}),a=c,e&&await e(c,r)}}finally{a<r&&this.events.entityAppended.dispatch({database:this,entity:n.slice(a)}),this.flushEventBatchRemainder()}}isEventBatched(){return this._eventBatchDepth>0}notifyEntityAppended(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityAppended.push(...e);return}this.events.entityAppended.dispatch({database:this,entity:t})}notifyEntityErased(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityErased.push(...e);return}this.events.entityErased.dispatch({database:this,entity:t})}notifyDictObjectSet(t,e){if(this.isEventBatched()){this._pendingDictObjectSet.push({object:t,key:e});return}this.events.dictObjetSet.dispatch({database:this,object:t,key:e})}notifyDictObjectErased(t,e){if(this.isEventBatched()){this._pendingDictObjectErased.push({object:t,key:e});return}this.events.dictObjectErased.dispatch({database:this,object:t,key:e})}flushEventBatch(){if(this._pendingEntityAppended.length>0){const t=this._pendingEntityAppended;this._pendingEntityAppended=[],this.events.entityAppended.dispatch({database:this,entity:t})}this.flushEventBatchRemainder()}flushEventBatchRemainder(){if(this._pendingEntityErased.length>0){const t=this._pendingEntityErased;this._pendingEntityErased=[],this.events.entityErased.dispatch({database:this,entity:t})}if(this._pendingDictObjectSet.length>0){const t=this._pendingDictObjectSet;this._pendingDictObjectSet=[];for(const{object:e,key:n}of t)this.events.dictObjetSet.dispatch({database:this,object:e,key:n})}if(this._pendingDictObjectErased.length>0){const t=this._pendingDictObjectErased;this._pendingDictObjectErased=[];for(const{object:e,key:n}of t)this.events.dictObjectErased.dispatch({database:this,object:e,key:n})}}get formatter(){return this._formatter??(this._formatter=new Gp(this))}generateHandle(){return this._maxHandleBig!=null?(this._maxHandleBig+=BigInt(1),this._maxHandleBig.toString(16).toUpperCase()):this._maxHandle>=Number.MAX_SAFE_INTEGER?(this._maxHandleBig=BigInt(this._maxHandle),this.generateHandle()):(this._maxHandle++,this._maxHandle.toString(16).toUpperCase())}generateUniqueHandle(){let t=this.generateHandle();for(;this.isHandleTaken(t);)t=this.generateHandle();return t}initializeHandleSeed(t){const e=BigInt("0x"+t);if(e<=BigInt(0))return;const n=e-BigInt(1);if(n<=BigInt(Number.MAX_SAFE_INTEGER)){if(this._maxHandleBig==null){const r=Number(n);r>this._maxHandle&&(this._maxHandle=r)}return}(this._maxHandleBig==null||n>this._maxHandleBig)&&(this._maxHandleBig=n)}adoptExternalHandle(t,e){return this.releaseObjectHandle(t),e&&!e.startsWith(mn)&&!this.isHandleTaken(e)?(t.objectId=e,this.registerObjectHandle(t),this.updateMaxHandle(e),e):this.assignGeneratedHandle(t)}registerObjectHandle(t){const e=t.objectId;!e||e.startsWith(mn)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(mn)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(mn))return!1;const n=this._handleRegistry.get(t);return n!==void 0&&n!==e}registerBootstrapHandles(){this._handleRegistry.clear(),this.registerObjectHandle(this);for(const t of[this._tables.blockTable,this._tables.dimStyleTable,this._tables.layerTable,this._tables.linetypeTable,this._tables.appIdTable,this._tables.textStyleTable,this._tables.ucsTable,this._tables.viewTable,this._tables.viewportTable])this.registerObjectHandle(t);for(const t of[this._objects.dictionary,this._objects.dictionaryVar,this._objects.group,this._objects.imageDefinition,this._objects.layerFilter,this._objects.layerIndex,this._objects.layout,this._objects.mleaderStyle,this._objects.mlineStyle,this._objects.objectContextData,this._objects.scale,this._objects.sortentsTable,this._objects.xrecord])this.registerObjectHandle(t)}assignGeneratedHandle(t){const e=t.objectId;this.releaseObjectHandle(t);const n=this.generateUniqueHandle();if(t.objectId=n,this.registerObjectHandle(t),e&&e!==n){if(this.updateMaxHandle(n),t instanceof lt)for(const r of t.newIterator())r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n);if(t instanceof Pe)for(const r of t.newIterator(!0))r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n);if(t instanceof G)for(const r of t.newIterator())r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n)}return n}updateMaxHandle(t){this.trackMaxHandle(t)}trackMaxHandle(t){if(this._maxHandleBig!=null){if(t.length>=14){const n=BigInt("0x"+t);n>this._maxHandleBig&&(this._maxHandleBig=n)}return}const e=parseInt(t,16);if(!isNaN(e)){if(e>Number.MAX_SAFE_INTEGER){this._maxHandleBig=BigInt("0x"+t);return}e>this._maxHandle&&(this._maxHandle=e)}}commitObjectHandle(t,e){const n=t.getAttrWithoutException("objectId"),r=e!=null&&n!=null&&e(n);if(!n||t.isTemp||r){this.assignGeneratedHandle(t);return}const a=this._handleRegistry.get(n);if(a&&a!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(a);else{this.assignGeneratedHandle(t);return}this.registerObjectHandle(t),this.updateMaxHandle(n)}shouldPreserveIncomingHandle(t){return!t.isTemp}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this.updateSysVar(E.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(E.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(E.LUNITS,this._lunits,t??xt.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(E.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(E.ACADVER,this._version,new Lt(t),e=>{this._version=e})}get dwgCodePage(){return this._dwgCodePage}set dwgCodePage(t){this._dwgCodePage=t!=null&&t.trim()?t.trim():void 0}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(E.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(E.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(E.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(E.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get cannoscale(){return this._cannoscale}set cannoscale(t){this.updateSysVar(E.CANNOSCALE,this._cannoscale,t||"1:1",e=>{this._cannoscale=e})}getDimStyleAnnotationScale(t){if(t)return this._dimStyleAnnotationScales.get(t.trim().toUpperCase())}setDimStyleAnnotationScale(t,e){!t||!(e>0)||this._dimStyleAnnotationScales.set(t.trim().toUpperCase(),e)}get annoallvisible(){return this._annoallvisible}set annoallvisible(t){const e=!!t;this.updateSysVar(E.ANNOALLVISIBLE,this._annoallvisible,e,n=>{this._annoallvisible=n})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get drawCircleSides(){return this._drawCircleSides}set drawCircleSides(t){this._drawCircleSides=tt.resolveCircleSides(t)}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(E.DWGNAME,this._dwgname,e,n=>{this._dwgname=n})}get dxfHeaderExtras(){return this._dxfHeaderExtras}addDxfHeaderExtra(t,e){const n=this._dxfHeaderExtras.findIndex(r=>r.name===t);n>=0?this._dxfHeaderExtras[n]={name:t,pairs:e}:this._dxfHeaderExtras.push({name:t,pairs:e}),this._dxfHeaderExtrasVersion=this._version.value}get dxfUnknownObjects(){return this._dxfUnknownObjects}addDxfUnknownObject(t){this._dxfUnknownObjects.push(t)}clearDxfHeaderExtras(){this._dxfHeaderExtras=[],this._dxfHeaderExtrasVersion=0}get thumbnailImage(){return this._thumbnailImage}set thumbnailImage(t){if(!t||t.length===0){this._thumbnailImage=void 0;return}this._thumbnailImage=t}isLayerDrawable(t){if(this._drawNoPlotLayers)return!0;const e=this.tables.layerTable.getAt(t);return e==null||e.isPlottable}set lwdisplay(t){this.updateSysVar(E.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get tilemode(){return this._tilemode}set tilemode(t){this.updateSysVar(E.TILEMODE,this._tilemode,t??1,e=>{this._tilemode=e})}get psltscale(){return this._psltscale}set psltscale(t){this._psltscale=t}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(E.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(E.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??kt);this.updateSysVar(E.CELTYPE,this._celtype,e,n=>{this._celtype=n})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(E.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(E.CETRANSPARENCY,this._cetransparency,t??new St,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(E.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(E.CMLSTYLE,this._cmlstyle,t??tn,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(E.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(E.CMLEADERSTYLE,this._cmleaderstyle,t??en,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(E.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new X(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(E.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(E.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(E.HPTRANSPARENCY,this._hptransparency,t??new St,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(E.TEXTSTYLE,this._textstyle,t??gt,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(E.DIMSTYLE,this._dimstyle,t??gt,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(E.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(E.ANGDIR,this._angdir,t??0,e=>{this._angdir=e})}get extmax(){return this._extents.max}set extmax(t){if(t){const e=this._extents.max.clone();this._extents.expandByPoint(t),this._extents.max.equals(e)||this.triggerSysVarChangedEvent(E.EXTMAX,e,this._extents.max)}}get extmin(){return this._extents.min}set extmin(t){if(t){const e=this._extents.min.clone();this._extents.expandByPoint(t),this._extents.min.equals(e)||this.triggerSysVarChangedEvent(E.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(E.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(E.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(E.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(E.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get comparehatch(){return this._comparehatch}set comparehatch(t){const e=Oe("COMPAREHATCH",t??ra,po,mo);this.updateSysVar(E.COMPAREHATCH,this._comparehatch,e,n=>{this._comparehatch=n})}get comparercmargin(){return this._comparercmargin}set comparercmargin(t){const e=Oe("COMPARERCMARGIN",t??sa,yo,bo);this.updateSysVar(E.COMPARERCMARGIN,this._comparercmargin,e,n=>{this._comparercmargin=n})}get comparetext(){return this._comparetext}set comparetext(t){const e=Oe("COMPARETEXT",t??aa,_o,xo);this.updateSysVar(E.COMPARETEXT,this._comparetext,e,n=>{this._comparetext=n})}get comparetolerance(){return this._comparetolerance}set comparetolerance(t){const e=Oe("COMPARETOLERANCE",t??oa,wo,vo);this.updateSysVar(E.COMPARETOLERANCE,this._comparetolerance,e,n=>{this._comparetolerance=n})}get lastOpenError(){return this._lastOpenError}async read(t,e,n=wr.DXF){const r=Ce.instance.get(n);if(r==null)throw new Error(`Database converter for file type '${n}' isn't registered and can can't read this file!`);let s;if(typeof t=="string"){const a=new TextEncoder().encode(t);s=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}else if(t instanceof ArrayBuffer)s=t;else if(ArrayBuffer.isView(t))s=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);else{const a=new zt("AcDbDatabase.read expects a string, ArrayBuffer, or ArrayBufferView","unknown");throw this._lastOpenError=a,this.events.openFailed.dispatch({database:this,error:a}),a}this.clear(),this._lastOpenError=null,this._drawNoPlotLayers=(e==null?void 0:e.drawNoPlotLayers)??!0,this.drawCircleSides=(e==null?void 0:e.circleSides)??$c,e!=null&&e.fileName&&this.setDwgName(e.fileName),pf(this);try{await r.read(s,this,{minimumChunkSize:e&&e.minimumChunkSize||10,progress:this.createConversionProgressHandler(),timeout:e==null?void 0:e.timeout,encoding:e==null?void 0:e.encoding,sysVars:e==null?void 0:e.sysVars})}catch(a){const o=zt.from(a);throw this._lastOpenError=o,this.events.openFailed.dispatch({database:this,error:o}),o}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(){return async(t,e,n,r,s)=>{let a=r;if(n==="ERROR"&&s){const o=zt.fromTask(s);this._lastOpenError=o,a={code:o.code,message:o.message,stage:o.stage??e}}this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:e,subStageStatus:n,data:a})}}async openUri(t,e){var g;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const n=await fetch(t);if(!n.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${n.status}'!`);const r=n.headers.get("content-length"),s=r?parseInt(r,10):null;let a=0;const o=(g=n.body)==null?void 0:g.getReader();if(!o)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:f,value:p}=await o.read();if(f)break;if(c.push(p),a+=p.length,s!==null){const m=Math.round(a/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(a);let h=0;for(const f of c)l.set(f,h),h+=f.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,wr.DWG):d==="dxf"?await this.read(l.buffer,e,wr.DXF):await this.read(l.buffer,e,d),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,n=this.version.name,r=!1){this.ensureDatabaseDefaults(),this._layerFilters.root.getNestedFilters().length>0&&!this.tables.layerTable.extensionDictionary&&(this.tables.layerTable.extensionDictionary=this.generateHandle());const s=typeof r=="boolean"?{saveThumbnailImage:r,format:"ascii"}:{saveThumbnailImage:r.saveThumbnailImage??!1,format:r.format??"ascii"},a=n instanceof Lt?n:new Lt(n),o=new ve({database:this,precision:e,version:a,outputFormat:s.format}),c=o.capabilities.supportsObjectsSection?this.planDxfObjectsSection(o):void 0;return o.writtenObjectIds=(c==null?void 0:c.writtenObjectIds)??new Set,this.ensureXDataAppIds(c),this.writeDxfHeaderSection(o),this.writeDxfClassesSection(o),this.writeDxfTablesSection(o,a),this.writeDxfBlocksSection(o),this.writeDxfEntitiesSection(o),this.writeDxfObjectsSection(o,c),this.writeDxfThumbnailImageSection(o,s.saveThumbnailImage),o.writeStart("EOF"),o.finalizeHandseed(),s.format==="binary"?o.toBinary():o.toString()}async regen(){await new xp(this).read(null,this,{minimumChunkSize:500,progress:this.createConversionProgressHandler()})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new fh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureEntityStyleDefaults(t){var e;if(t.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||tn);return}if(t.dxfTypeName==="MULTILEADER"){this.ensureMLeaderStyle(this._cmleaderstyle||en);return}if(t.dxfTypeName==="HATCH"){const n=t;(e=n.applyPatternDefaultsFromSysVars)==null||e.call(n,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new Eo({name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[gt,"STANDARD"];for(const e of t)if(this.tables.textStyleTable.has(e))return!0;for(const e of this.tables.textStyleTable.newIterator())if(e.name.toUpperCase()===gt.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new X;e.colorIndex=7,this.tables.layerTable.add(new ls({name:"0",standardFlags:0,linetype:wn,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(Ne)||this.tables.linetypeTable.add(new vn({name:Ne,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(kt)||this.tables.linetypeTable.add(new vn({name:kt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(wn)||this.tables.linetypeTable.add(new vn({name:wn,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(gt)||this.tables.dimStyleTable.add(new Vt({name:gt,dimtxsty:gt})),!this.tables.viewportTable.has(Ri)){const e=new An;e.name=Ri,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||tn),this.ensureMLeaderStyle(this._cmleaderstyle||en);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new In;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=t.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.objects.layout.setAt(e.layoutName,e),t.layoutId=e.objectId}this.ensureDefaultPaperSpaceLayout(),this.tables.appIdTable.has(Nc)||this.tables.appIdTable.add(new _r(Nc)),this.tables.appIdTable.has(Dc)||this.tables.appIdTable.add(new _r(Dc))}ensureDefaultPaperSpaceLayout(){for(const r of this.tables.blockTable.newIterator())if(r.isPaperSapce)return;const t=new lt;t.name=lt.PAPER_SPACE_NAME_PREFIX,this.tables.blockTable.add(t);const e=this.objects.layout.getAt("Layout1")?`Layout${this.objects.layout.maxTabOrder+1}`:"Layout1",n=new In;n.layoutName=e,n.tabOrder=Math.max(1,this.objects.layout.maxTabOrder+1),n.blockTableRecordId=t.objectId,n.limits.min.copy({x:0,y:0}),n.limits.max.copy({x:12,y:9}),n.extents.min.copy({x:0,y:0,z:0}),n.extents.max.copy({x:12,y:9,z:0}),this.objects.layout.setAt(n.layoutName,n),t.layoutId=n.objectId}ensureMLineStyle(t){var s;const e=this.objects.mlineStyle,n=t.trim();if(!n||e.getAt(n))return;for(const[a,o]of e.entries())if((a==null?void 0:a.toUpperCase())===n.toUpperCase()||((s=o.styleName)==null?void 0:s.toUpperCase())===n.toUpperCase())return;const r=new Lo;r.styleName=n,r.elements=[{offset:.5,color:new X().setByLayer(),lineType:kt},{offset:-.5,color:new X().setByLayer(),lineType:kt}],e.setAt(n,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,n=t.trim();if(!n||e.getAt(n))return;for(const[o]of e.entries())if((o==null?void 0:o.toUpperCase())===n.toUpperCase())return;const r=new us;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new X().setByBlock(),r.textColor=new X().setByBlock(),r.blockColor=new X().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(Ne);r.leaderLineTypeId=s==null?void 0:s.objectId;const a=this.tables.textStyleTable.getAt(gt);r.textStyleId=a==null?void 0:a.objectId,e.setAt(n,r)}writeDxfHeaderSection(t){var e;if(t.startSection("HEADER"),t.writeString(9,"$ACADVER"),t.writeString(1,((e=t.version)==null?void 0:e.name)??this.version.name),t.writeHandseedPlaceholder(),t.writeString(9,"$DWGCODEPAGE"),t.capabilities.supportsUtf8CodePage)t.writeString(3,"UTF-8");else{const n=this._dwgCodePage,r=n&&!/^utf-?8$/i.test(n)?n:"ANSI_1252";t.writeString(3,r)}t.writeString(9,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LUNITS"),t.writeInt16(70,this.lunits),t.writeString(9,"$LUPREC"),t.writeInt16(70,this.luprec),t.writeString(9,"$UNITMODE"),t.writeInt16(70,this.unitmode),t.writeString(9,"$MEASUREMENT"),t.writeInt16(70,this.measurement),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$LWDISPLAY"),t.writeBoolean(290,this.lwdisplay)),t.writeString(9,"$CELTSCALE"),t.writeDouble(40,this.celtscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$CELWEIGHT"),t.writeLineWeight(370,this.celweight)),t.writeString(9,"$CECOLOR"),t.writeCmColor(this.cecolor),t.writeString(9,"$TILEMODE"),t.writeInt16(70,this.tilemode),t.writeString(9,"$PSLTSCALE"),t.writeInt16(70,this.psltscale?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$CELTYPE"),t.writeString(6,this.celtype),t.capabilities.supportsTransparency&&!this.cetransparency.isInvalid&&(t.writeString(9,"$CETRANSPARENCY"),t.writeTransparency(this.cetransparency)),t.writeString(9,"$CMLSTYLE"),t.writeString(2,this.cmlstyle),t.writeString(9,"$CMLSCALE"),t.writeDouble(40,this.cmlscale),t.capabilities.supportsMLeader&&(t.writeString(9,"$CMLEADERSTYLE"),t.writeString(2,this.cmleaderstyle)),t.capabilities.supportsHatchHeaderVars&&(this.hpcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPCOLOR"),t.writeCmColor(this.hpcolor)),this.hpbackgroundcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPBACKGROUNDCOLOR"),t.writeCmColor(this.hpbackgroundcolor)),this.hplayer&&this.hplayer!=="."&&(t.writeString(9,"$HPLAYER"),t.writeString(8,this.hplayer)),t.capabilities.supportsTransparency&&!this.hptransparency.isInvalid&&(t.writeString(9,"$HPTRANSPARENCY"),t.writeTransparency(this.hptransparency))),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$DIMSTYLE"),t.writeString(2,this.dimstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angbase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angdir),t.writeString(9,"$AUNITS"),t.writeInt16(70,this.aunits),t.writeString(9,"$AUPREC"),t.writeInt16(70,this.auprec),this.writeDxfExtentsHeader(t),t.writeString(9,"$PDMODE"),t.writeInt32(70,this.pdmode),t.writeString(9,"$PDSIZE"),t.writeDouble(40,this.pdsize),t.writeString(9,"$OSMODE"),t.writeInt32(70,this.osmode),t.writeString(9,"$ORTHOMODE"),t.writeInt16(70,this.orthomode),this.writeDxfHeaderExtras(t),t.endSection()}writeDxfHeaderExtras(t){var n;if(!((((n=t.version)==null?void 0:n.value)??this.version.value)<this._dxfHeaderExtrasVersion))for(const{name:r,pairs:s}of this._dxfHeaderExtras)pv.has(r)||(t.writeString(9,r),t.writeRawPairs(s))}writeDxfExtentsHeader(t){if(this._extents.isEmpty()&&this.refreshExtentsFromModelSpace(),this._extents.isEmpty()){t.writeString(9,"$EXTMIN"),t.writePoint3d(10,{x:1e20,y:1e20,z:1e20}),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,{x:-1e20,y:-1e20,z:-1e20});return}t.writeString(9,"$EXTMIN"),t.writePoint3d(10,this.extmin),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,this.extmax)}refreshExtentsFromModelSpace(){for(const t of this.tables.blockTable.modelSpace.newIterator())try{const e=t.geometricExtents;e&&!e.isEmpty()&&this._extents.union(e)}catch{}}writeDxfClassesSection(t){if(!(!t.capabilities.supportsClassesSection||this._classes.length===0)){t.startSection("CLASSES");for(const e of this._classes)t.writeStart("CLASS"),t.writeString(1,e.name),t.writeString(2,e.cppClassName),t.writeString(3,e.appName),t.writeInt32(90,e.proxyFlag),t.writeInt32(91,e.instanceCount),t.writeInt8(280,e.wasProxy?1:0),t.writeInt8(281,e.isEntity?1:0);t.endSection()}}writeDxfTablesSection(t,e){t.startSection("TABLES"),this.writeDxfTable(t,"VPORT",this.tables.viewportTable,this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(t,"VIEW",this.tables.viewTable,this.tables.viewTable.newIterator(),"VIEW"),this.writeDxfTable(t,"UCS",this.tables.ucsTable,this.tables.ucsTable.newIterator(),"UCS"),this.writeDxfTable(t,"LTYPE",this.tables.linetypeTable,this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(t,"LAYER",this.tables.layerTable,this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(t,"STYLE",this.tables.textStyleTable,this.tables.textStyleTable.newIterator(!0),"STYLE"),this.writeDxfTable(t,"APPID",this.tables.appIdTable,this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(t,"DIMSTYLE",this.tables.dimStyleTable,this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),e.capabilities.supportsBlockRecordTable&&this.writeDxfTable(t,"BLOCK_RECORD",this.tables.blockTable,this.tables.blockTable.newIterator(),"BLOCK_RECORD"),t.endSection()}writeDxfBlocksSection(t){t.startSection("BLOCKS");for(const e of this.tables.blockTable.newIterator()){if(e.dxfOutBlockBegin(t),!e.isModelSapce&&!e.isPaperSapce)for(const n of e.newIterator())this.writeDxfEntity(t,n);e.dxfOutBlockEnd(t)}t.endSection()}writeDxfEntitiesSection(t){t.startSection("ENTITIES");for(const e of this.tables.blockTable.newIterator())if(!(!e.isModelSapce&&!e.isPaperSapce))for(const n of e.newIterator())this.writeDxfEntity(t,n);t.endSection()}planDxfObjectsSection(t){var v;const e=this.objects.dictionary;e.ownerId="0";const n=(S,I)=>{e.getAt(S)!==I&&e.setAt(S,I)},r=S=>{e.getAt(S)&&e.remove(S)};n("ACAD_LAYOUT",this.objects.layout),n("ACAD_GROUP",this.objects.group),this.objects.sortentsTable.numEntries>0?n("ACAD_SORTENTS",this.objects.sortentsTable):r("ACAD_SORTENTS");const s=this.objects.mleaderStyle.numEntries>0,a=t.capabilities.supportsMLeader&&s,o=!a&&e.getAt("ACAD_MLEADERSTYLE")===this.objects.mleaderStyle;a?n("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):r("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?n("ACAD_MLINESTYLE",this.objects.mlineStyle):r("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?n("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):r("ISM_RASTER_IMAGE_DICT");const c=S=>(S??"").trim().toUpperCase(),l=new Set(this._classes.map(S=>(S.name??"").toUpperCase())),h=new Map,u=new Set,d=this.objects.xrecord,g=[],f=S=>{if(!S||S===d)return;const I=c(S.objectId);if(!I||h.has(I)||u.has(I))return;const M=gv(S,l);M&&(h.set(I,{object:S,type:M}),g.push(S))},p=S=>{const I=S.extensionDictionary;I&&f(this.getObjectById(I))};let m=0;const y=()=>{for(;m<g.length;){const S=g[m++];if(p(S),S instanceof G){for(const[,I]of S.entries())f(I);S.defaultId&&f(this.getObjectById(S.defaultId))}}},b=S=>{if(!S)return;const I=c(S.objectId);if(!(!I||u.has(I))&&(u.add(I),S.extensionDictionary&&b(this.getObjectById(S.extensionDictionary)),S instanceof G))for(const[,M]of S.entries())b(M)};f(e),y();const _=this.tables.layerTable,w=this._layerFilters.root.getNestedFilters().length>0;if(w&&_.extensionDictionary){const S=_.extensionDictionary,I=this.getObjectById(S);if(u.add(c(S)),I instanceof G)for(const[M,O]of I.entries())M===zn||M===Wr?b(O):f(O)}for(const S of Object.values(this.tables)){p(S);for(const I of S.newIterator())p(I)}for(const S of this.tables.blockTable.newIterator())for(const I of S.newIterator()){p(I);const M=(v=I.attributeIterator)==null?void 0:v.call(I);if(M)for(const O of M)p(O)}y();for(const[,S]of this.objects.layerFilter.entries())f(S);for(const[,S]of this.objects.layerIndex.entries())f(S);for(const S of this._dxfUnknownObjects){const I=this.getObjectById(S.ownerId);(I instanceof et||I&&!(I instanceof G)&&h.has(c(I.objectId)))&&f(S)}y();const k=[];for(const[,S]of d.entries()){const I=c(S.objectId);!I||h.has(I)||u.has(I)||k.push(S)}k.length>0?n("MLIGHT_XRECORD",d):r("MLIGHT_XRECORD");const P=new Set(h.keys());if(k.length>0){P.add(c(d.objectId));for(const S of k)P.add(c(S.objectId))}return w&&_.extensionDictionary&&P.add(c(_.extensionDictionary)),{records:[...h.values()],looseXrecords:k,writtenObjectIds:P,restoreMLeaderRoot:o}}ensureXDataAppIds(t){var r;const e=this.tables.appIdTable,n=s=>{for(const a of s.xDataAppIds())a&&!e.has(a)&&e.add(new _r(a))};for(const s of Object.values(this.tables))for(const a of s.newIterator())n(a);for(const s of this.tables.blockTable.newIterator())for(const a of s.newIterator()){n(a);const o=(r=a.attributeIterator)==null?void 0:r.call(a);if(o)for(const c of o)n(c)}if(t){for(const{object:s}of t.records)n(s);for(const s of t.looseXrecords)n(s)}}writeDxfObjectsSection(t,e){if(!e)return;t.startSection("OBJECTS");const n=r=>e.writtenObjectIds.has((r.objectId??"").trim().toUpperCase());for(const{object:r,type:s}of e.records){if(r instanceof G){t.writeStart(s),r.dxfOutFiltered(t,n);continue}if(r instanceof Pi&&!r.name)for(const[a,o]of this.objects.group.entries())o===r&&(r.name=a);t.writeStart(s),r.dxfOut(t,!0)}if(e.looseXrecords.length>0){const r=this.objects.xrecord;r.ownerId=this.objects.dictionary.objectId,t.writeStart("DICTIONARY"),r.dxfOutFiltered(t,n);for(const s of e.looseXrecords)s.ownerId=r.objectId,t.writeStart("XRECORD"),s.dxfOut(t,!0)}this.writeAcLyLayerFilterObjects(t),t.endSection(),e.restoreMLeaderRoot&&this.objects.dictionary.setAt("ACAD_MLEADERSTYLE",this.objects.mleaderStyle)}writeAcLyLayerFilterObjects(t){const e=Op(this._layerFilters);if(e.nodes.length===0)return;const n=[],r=[],s=this.tables.layerTable,a=s.extensionDictionary??this.generateHandle();s.extensionDictionary=a;const o=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(f,p,m)=>{const y=this.generateHandle();let b;if(f.children.length>0){const _=this.generateHandle(),w=this.generateHandle(),k=[];for(const P of f.children)k.push({name:P.key,id:u(P,w,!1)});n.push({handle:_,ownerId:y,entries:[{name:zn,id:w}]}),n.push({handle:w,ownerId:_,entries:k}),b=_}return r.push({handle:y,ownerId:p,extensionDictionaryId:b,data:f.data}),m&&h.push({name:f.key,id:y}),y};for(const f of e.nodes)l.push({name:f.key,id:u(f,o,!0)});const d=new Map,g=this.getObjectById(a);if(g instanceof G)for(const[f,p]of g.entries())d.set(f,p.objectId);d.set(zn,o),d.set(Wr,c),n.unshift({handle:a,ownerId:s.objectId,entries:Array.from(d,([f,p])=>({name:f,id:p}))},{handle:o,ownerId:a,entries:l},{handle:c,ownerId:a,entries:h});for(const f of n)t.markObjectIdWritten(f.handle);for(const f of r)t.markObjectIdWritten(f.handle);for(const f of n){t.writeStart("DICTIONARY"),t.writeHandle(5,f.handle),t.writeObjectId(330,f.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const p of f.entries)t.writeString(3,p.name),t.writeObjectId(350,p.id)}for(const f of r){const p=new os;p.objectId=f.handle,p.ownerId=f.ownerId,f.extensionDictionaryId&&(p.extensionDictionary=f.extensionDictionaryId),p.data=Dp(f.data),t.writeStart("XRECORD"),p.dxfOut(t)}}writeDxfTable(t,e,n,r,s){const a=[...r];t.startTable(e),n.dxfOut(t);for(const o of a){if(s==="BLOCK_RECORD"&&o instanceof lt){o.dxfOutBlockRecord(t);continue}t.writeStart(s),o.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(!(e instanceof Gr&&e.hasSubclassData!==t.capabilities.supportsSubclassMarkers)){if(e instanceof Ut&&!t.capabilities.supportsLwPolyline){t.writeStart("POLYLINE"),e.dxfOutAs2dPolyline(t,!0);return}t.writeStart(e.dxfTypeName),e.dxfOut(t,!0)}}writeDxfThumbnailImageSection(t,e=!1){const n=this._thumbnailImage;if(!e||!n||n.length===0||!t.capabilities.supportsObjectsSection)return;const r=127;t.startSection("THUMBNAILIMAGE"),t.writeInt32(90,n.length);for(let s=0;s<n.length;s+=r){const a=n.subarray(s,s+r);t.writeString(310,Po(a))}t.endSection()}clear(){this.transactionManager.clearUndoStack(),this._classes=[],this.clearDxfHeaderExtras(),this._dxfUnknownObjects=[],this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.ucsTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._tables.appIdTable.removeAll(),this._objects.layout.removeAll(),this._objects.group.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.layerFilter.removeAll(),this._objects.layerIndex.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.objectContextData.removeAll(),this._objects.scale.removeAll(),this._objects.dictionaryVar.removeAll(),this._objects.sortentsTable.removeAll(),this._objects.xrecord.removeAll(),this._cannoscale="1:1",this._dimStyleAnnotationScales.clear(),this._annoallvisible=!0,this._layerFilters=new rn,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,n,r){wt.instance().applyVarMutation(t,e,n,this,()=>r(n))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?kt:e.toUpperCase()==="BYBLOCK"?Ne:e}triggerSysVarChangedEvent(t,e,n){const r=wt.instance(),s=t.toLowerCase();r.getDescriptor(s)!=null&&r.events.sysVarChanged.dispatch({database:this,name:s,oldVal:e,newVal:n})}getFileNameFromUri(t){try{const n=new URL(t).pathname.split("/");return n[n.length-1]||""}catch{return""}}};Mr._unsavedDrawingSequence=0;let Zc=Mr;class mv{constructor(){this.transactionStack=[]}startTransaction(){const t=new bh;return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");t.commit()}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");t.abort()}hasTransaction(){return this.transactionStack.length>0}}const qn="ACAD",Oo="DSTYLE",mm={3:"dimpost",4:"dimapost",40:"dimscale",41:"dimasz",42:"dimexo",43:"dimdli",44:"dimexe",45:"dimrnd",46:"dimdle",47:"dimtp",48:"dimtm",140:"dimtxt",141:"dimcen",142:"dimtsz",143:"dimaltf",144:"dimlfac",145:"dimtvp",146:"dimtfac",147:"dimgap",148:"dimaltrnd",70:"dimtfillclr",69:"dimtfill",71:"dimtol",72:"dimlim",73:"dimtih",74:"dimtoh",75:"dimse1",76:"dimse2",77:"dimtad",78:"dimzin",79:"dimazin",170:"dimalt",171:"dimaltd",172:"dimtofl",173:"dimsah",174:"dimtix",175:"dimsoxd",176:"dimclrd",177:"dimclre",178:"dimclrt",179:"dimadec",270:"dimunit",271:"dimdec",272:"dimtdec",273:"dimaltu",274:"dimalttd",275:"dimaunit",276:"dimfrac",277:"dimlunit",278:"dimdsep",279:"dimtmove",280:"dimjust",281:"dimsd1",282:"dimsd2",283:"dimtolj",284:"dimtzin",285:"dimaltz",286:"dimalttz",287:"dimfit",288:"dimupt",289:"dimatfit",294:"dimtxtdirection",295:"dimtxtdirection",340:"dimtxsty",341:"dimldrblk",342:"dimblk",343:"dimblk1",344:"dimblk2",371:"dimlwd",372:"dimlwe"},ym=new Set([340,341,342,343,344]);function yv(i){return mm[i]}function bm(i){const t=Array.from(i.iterateXData(qn)),e=t.findIndex(a=>Number(a.code)===Z.ExtendedDataAsciiString&&String(a.value)===Oo);if(e<0)return[];const n=[];let r=!1,s;for(let a=e+1;a<t.length;a++){const o=t[a],c=Number(o.code);if(c===Z.ExtendedDataControlString){if(String(o.value)==="{"){if(r)break;r=!0;continue}break}if(!r)continue;if(s===void 0){c===Z.ExtendedDataInteger16&&(s=Number(o.value));continue}const l=bv(c,o.value);l!==void 0&&n.push({code:s,value:l}),s=void 0}return n}function bv(i,t){switch(i){case Z.ExtendedDataReal:case Z.ExtendedDataDist:case Z.ExtendedDataScale:case Z.ExtendedDataInteger16:case Z.ExtendedDataInteger32:return Number(t);case Z.ExtendedDataAsciiString:return String(t);case Z.ExtendedDataHandle:return String(t);default:return}}const _v=new Set([341,342,343,344]),xv=new Set(["dimpost","dimapost","dimdsep","dimtxsty","dimldrblk","dimblk","dimblk1","dimblk2"]);function wv(i,t){if(xv.has(i))return typeof t=="string"?t:Number.isFinite(t)?String.fromCharCode(Math.trunc(t)):".";if(typeof t=="string"){const e=Number(t);return Number.isFinite(e)?e:t}return t}function _m(i,t){const e=[];for(const n of i){if(!ym.has(n.code)){e.push(n);continue}const r=String(n.value).trim().toUpperCase(),s=!r||r==="0";if(n.code===340){if(s||!t)continue;const c=t.getObjectById(r),l=c==null?void 0:c.name;l&&e.push({code:n.code,value:l});continue}if(s||!t){_v.has(n.code)&&e.push({code:n.code,value:""});continue}const a=t.getObjectById(r),o=a==null?void 0:a.name;e.push({code:n.code,value:o??""})}return e}function xm(i,t){const e=(i==null?void 0:i.clonePreservingIdentity())??new Vt;e.objectId="";for(const n of t){const r=mm[n.code];r&&r in e&&e.attrs.set(r,wv(r,n.value))}return e}function Do(i,t,e){const n=bm(i);if(n.length===0)return t;const r=_m(n,e);return r.length===0?t:xm(t,r)}function vv(i,t){const e=Array.from(i.iterateXData(qn)).filter(s=>Number(s.code)!==Z.ExtendedDataRegAppName),n=Av(e),r=[{code:Z.ExtendedDataRegAppName,value:qn},...n.map(s=>({code:s.code,value:s.value}))];if(t.length>0){r.push({code:Z.ExtendedDataAsciiString,value:Oo}),r.push({code:Z.ExtendedDataControlString,value:"{"});for(const s of t)r.push({code:Z.ExtendedDataInteger16,value:s.code}),r.push(Sv(s));r.push({code:Z.ExtendedDataControlString,value:"}"})}i.setXData(new Xe(r))}function Av(i){const t=i.findIndex(s=>Number(s.code)===Z.ExtendedDataAsciiString&&String(s.value)===Oo);if(t<0)return i.slice();let e=0,n=!1,r=t+1;for(;r<i.length;r++){const s=i[r];if(Number(s.code)===Z.ExtendedDataControlString){if(String(s.value)==="{")n=!0,e++;else if(n&&--e<=0){r++;break}}}return[...i.slice(0,t),...i.slice(r)]}function Sv(i){if(ym.has(i.code)){const t=String(i.value);return{code:Z.ExtendedDataHandle,value:t||"0"}}return typeof i.value=="string"?{code:Z.ExtendedDataAsciiString,value:i.value}:wm(i.code)?{code:Z.ExtendedDataInteger16,value:Math.trunc(i.value)}:{code:Z.ExtendedDataReal,value:i.value}}const Pv=new Set([69,70,71,72,73,74,75,76,77,78,79,170,171,172,173,174,175,176,177,178,179,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,294,295,371,372]);function wm(i){return Pv.has(i)}const kv=Vt.DEFAULT_DIM_VALUES,uc=6,Fh=class Fh extends et{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new x,this._text="",this._dimensionStyle="",this._normal=new A(0,0,1),this._direction=new A(1,0,0)}get location(){return this._location}set location(t){this._location.set(t.x,t.y,t.z??0)}get text(){return this._text}set text(t){this._text=t}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t,this._dimStyle=void 0,this._dimStyleName=void 0}get normal(){return this._normal}set normal(t){this._normal.set(t.x,t.y,t.z??0),this._normal.lengthSq()>0&&this._normal.normalize()}get direction(){return this._direction}set direction(t){this._direction.set(t.x,t.y,t.z??0),this._direction.lengthSq()>0&&this._direction.normalize()}setOrientation(t,e){return this.normal=t,this.direction=e,this}getBoundingPoints(){return this.getBoundingPolyline().slice(0,4)}getBoundingPolyline(){const{width:t,rowHeight:e,rowCount:n}=this.resolveFrameLayout(),r=e/2,s=r-e*n;return[new x(0,r,0),new x(t,r,0),new x(t,s,0),new x(0,s,0),new x(0,r,0)].map(o=>this.toFrameWcs(o.x,o.y))}get geometricExtents(){const t=new H;for(const e of this.getBoundingPoints())t.expandByPoint(e);return t.isEmpty()&&t.expandByPoint(this._location),t}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return he(t,e,this._location),this}subGetOsnapPoints(t,e,n,r){t===T.Insertion&&r.push(this._location)}transformBy(t){const e=this.resolveLocalBasis(),n=this._location.clone(),r=n.clone().add(e.xAxis),s=n.clone().add(e.yAxis);n.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new A(r).sub(n),o=new A(s).sub(n);let c=new A().crossVectors(a,o);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=a.clone();return l.lengthSq()===0?l=this._direction.clone().transformDirection(t):l.normalize(),this._location.copy(n),this._normal.copy(c),this._direction.copy(l),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"tolerance",properties:[{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"text",type:"string",editable:!0,accessor:{get:()=>this.text,set:t=>{this.text=t}}},{name:"dimensionStyle",type:"string",editable:!0,accessor:{get:()=>this.dimensionStyle,set:t=>{this.dimensionStyle=t}}},{name:"textHeight",type:"float",editable:!1,accessor:{get:()=>this.textHeight}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]}]}}get annotative(){return Se(this)}set annotative(t){me(this,t)}subWorldDraw(t,e){const r=this.collectFrameLineSegments().map(([o,c])=>t.lines([o,c])),s=this.drawToleranceText(t,e);let a;if(r.length>0&&s?a=t.group([...r,s]):r.length===1?a=r[0]:r.length>1?a=t.group(r):a=s,a&&this.annotative){const o=Gn(this);if(o.annotationScale){const c=a.userData??(a.userData={});c.annotationScale=o.annotationScale}}return a}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFcf"),this._dimensionStyle&&t.writeString(3,this._dimensionStyle),t.writePoint3d(10,this._location),t.writeString(1,this._text),this._normal.equals(A.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(A.X_AXIS)||t.writeVector3d(11,this._direction),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFcf");let e=this.location.x,n=this.location.y,r=this.location.z,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=this.direction.x,l=this.direction.y,h=this.direction.z,u=!1,d=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const f=Number(g.code),p=Number(g.value);switch(f){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=p;break;case 20:n=p;break;case 30:r=p;break;case 11:c=p,d=!0;break;case 21:l=p,d=!0;break;case 31:h=p,d=!0;break;case 210:s=p,u=!0;break;case 220:a=p,u=!0;break;case 230:o=p,u=!0;break}}return this.location={x:e,y:n,z:r},u&&(this.normal={x:s,y:a,z:o}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Vt.DEFAULT_DIM_VALUES.dimtxt,n=(t==null?void 0:t.dimscale)??Vt.DEFAULT_DIM_VALUES.dimscale;return e*n}drawToleranceText(t,e){const n=this.parseToleranceFrame(this._text);if(n.length===0)return;const r=this.resolveFrameLayout(n),s=this.getTextStyle(),a=[];for(let o=0;o<n.length;o++){const c=n[o];let l=r.cellPadding;const h=-r.rowHeight*o;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const f=this.toFrameWcs(l+g/2,h),p={text:d,height:this.textHeight,width:1/0,position:f,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};a.push(t.mtext(p,s,e))}l+=g+r.columnGap}}if(a.length!==0)return a.length===1?a[0]:t.group(a)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:n,rowHeight:r,rowCount:s,columnDivisions:a}=e;if(n<=0||r<=0||s<=0)return[];const o=r/2,c=o-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,o),this.toFrameWcs(n,o)),h(this.toFrameWcs(n,o),this.toFrameWcs(n,c)),h(this.toFrameWcs(n,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,o));for(const u of a)h(this.toFrameWcs(u,o),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=o-r*u;h(this.toFrameWcs(0,d),this.toFrameWcs(n,d))}return l}toFrameWcs(t,e){const n=this.resolveLocalBasis();return this._location.clone().addScaledVector(n.xAxis,t).addScaledVector(n.yAxis,e)}resolveFrameLayout(t){const e=t??this.parseToleranceFrame(this._text),n=this.textHeight,r=n*2,s=n/2,a=n;if(n<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const o=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<o;d++){let g=n;for(const f of e){const p=f.cells[d]??"";if(!p.trim())continue;const m=Sx(p,n);g=Math.max(g,m)}c.push(g)}const l=[0];let h=s;for(let d=0;d<c.length;d++)h+=c[d],h+=a,l.push(h-s);return{width:l[l.length-1]??0,totalHeight:r*e.length,rowHeight:r,columnWidths:c,columnDivisions:l,rowCount:e.length,cellPadding:s,columnGap:a}}parseToleranceFrame(t){if(!t)return[];const e=this.splitToleranceRows(t);if(e.length===0)return[];if(!t.includes("%%v"))return e.map(s=>({cells:this.parsePipeSeparatedCells(s)}));const n=e.map(s=>{const o=this.splitToleranceTokens(s,"%%v").slice(0,uc);for(;o.length<uc;)o.push("");return o}),r=[0,1];n.some(s=>{var a;return(a=s[2])==null?void 0:a.trim()})&&r.push(2);for(let s=3;s<uc;s++)n.some(a=>{var o;return(o=a[s])==null?void 0:o.trim()})&&r.push(s);return n.map(s=>({cells:r.map(a=>s[a]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
|
|
12
|
+
`)}),d+=`- total: ${this.data.total} ms`,d}};Al.getInstance().collect(c),this.progress=s;const l={value:0},h=new Jd;h.setCompleteCallback(()=>this.onFinished()),h.setErrorCallback(d=>this.onError(d)),h.addTask(new qt({stage:"START",step:1,progress:l,task:async d=>d},s)),h.addTask(new qt({stage:"PARSE",step:5,progress:l,task:async d=>await this.parse(d,a)},s)),h.addTask(new qt({stage:"LTYPE",step:1,progress:l,task:async d=>(this.processLineTypes(d.model,e),d)},s)),h.addTask(new qt({stage:"STYLE",step:1,progress:l,task:async d=>(this.processTextStyles(d.model,e),d)},s)),h.addTask(new qt({stage:"DIMSTYLE",step:1,progress:l,task:async d=>(this.processDimStyles(d.model,e),d)},s)),h.addTask(new qt({stage:"LAYER",step:1,progress:l,task:async d=>(this.processLayers(d.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),d)},s)),h.addTask(new qt({stage:"VPORT",step:1,progress:l,task:async d=>(this.processViewports(d.model,e),d)},s)),h.addTask(new qt({stage:"HEADER",step:1,progress:l,task:async d=>{if(this.processClasses(d.model,e),this.processHeader(d.model,e),o){const g=wt.instance();for(const[f,p]of Object.entries(o))g.setVar(f,p,e)}return d}},s)),h.addTask(new qt({stage:"BLOCK_RECORD",step:5,progress:l,task:async d=>(this.processBlockTables(d.model,e),d)},s)),h.addTask(new qt({stage:"OBJECT",step:5,progress:l,task:async d=>(this.processObjects(d.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),d)},s)),h.addTask(new qt({stage:"BLOCK",step:5,progress:l,task:async d=>(await this.processBlocks(d.model,e),d)},s)),h.addTask(new qt({stage:"ENTITY",step:100,progress:l,task:async d=>(await this.processEntities(d.model,e,r,l,s),d)},s)),h.addTask(new qt({stage:"END",step:0,progress:l,task:async d=>d},s));const u=Date.now();await h.run(t),c.data.total=Date.now()-u}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&this.progress(100,"END","END")}getParserWorkerTimeout(t,e){const n=e??this.config.timeout;if(n!=null)return n;const r=Math.ceil(t.byteLength/ew),s=ad+r*1e3;return Math.min(tw,Math.max(ad,s))}async parse(t,e){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processClasses(t,e){}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,n,r,s){throw new Error("Not impelemented yet!")}}class _p{constructor(t,e,n){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=n,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}async scheduleTask(t){await Zi(),await t()}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let n=0;const r=async()=>{const s=n,a=Math.min(n+this._chunkSize,this._count);await t(s,a),n=a,n<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class xp extends sh{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}async processEntities(t,e,n,r,s){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,c=new _p(o,100-r.value,n);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?a[h].type:"";for(let f=h;f<u;f++){const p=a[f];this.config.convertByEntityType&&p.type!==g&&(this.triggerEvents(l,d),d=[],g=p.type),d.push(p)}if(this.triggerEvents(l,d),s){let f=r.value+u/o*(100-r.value);f>100&&(f=100),await s(f,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const n=e.newIterator().toArray();this.triggerEvents(e,n)}}processHeader(){}processClasses(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const a of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const a of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const n=this._database.objects.mleaderStyle.newIterator();for(const a of n)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const r=this._database.objects.layerFilter.newIterator();for(const a of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const s=this._database.objects.layerIndex.newIterator();for(const a of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},n=[];for(const r of t)e[r.type]||(e[r.type]=[],n.push(r.type)),e[r.type].push(r);return n.flatMap(r=>e[r])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}var wp=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(wp||{}),Fn=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(Fn||{}),ya=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(ya||{}),fi=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(fi||{}),vp=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(vp||{});const so=class so extends on{constructor(t,e){t=t||{},fe(t,so.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get annotative(){return Se(this)}set annotative(t){me(this,t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimtfill(){return this.getAttr("dimtfill")}set dimtfill(t){this.setAttr("dimtfill",t)}get dimtfillclr(){return this.getAttr("dimtfillclr")}set dimtfillclr(t){this.setAttr("dimtfillclr",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimtxtdirection(){return this.getAttr("dimtxtdirection")}set dimtxtdirection(t){this.setAttr("dimtxtdirection",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}dxfOut(...t){const[e,n=!1]=t;return e.writeHandle(105,this.objectId),this.dxfOutExtensionDictionary(e),e.writeObjectId(330,this.ownerId),this.dxfOutFields(e),n&&this.dxfOutXData(e),this}dxfOutFields(t){super.dxfOutFields(t);const e=this.database.tables.textStyleTable.getAt(this.dimtxsty),n=this.database.tables.blockTable.getAt(this.dimldrblk),r=this.database.tables.blockTable.getAt(this.dimblk),s=this.database.tables.blockTable.getAt(this.dimblk1),a=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(69,this.dimtfill),t.writeInt16(70,this.dimtfillclr),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeInt16(295,this.dimtxtdirection),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,n==null?void 0:n.objectId),t.writeObjectId(342,r==null?void 0:r.objectId),t.writeObjectId(343,s==null?void 0:s.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbDimStyleTableRecord");const e=s=>s===0?0:1;let n=-1,r=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code);if(a===100){t.pushBackItem(s);break}const o=Number(s.value);switch(a){case 2:this.name=String(s.value);break;case 70:r||n===69?this.dimtfillclr=o:r=!0;break;case 69:this.dimtfill=o===1||o===2?o:0;break;case 3:this.dimpost=String(s.value);break;case 4:this.dimapost=String(s.value);break;case 5:this.dimblk=String(s.value);break;case 6:this.dimblk1=String(s.value);break;case 7:this.dimblk2=String(s.value);break;case 40:this.dimscale=o;break;case 41:this.dimasz=o;break;case 42:this.dimexo=o;break;case 43:this.dimdli=o;break;case 44:this.dimexe=o;break;case 45:this.dimrnd=o;break;case 46:this.dimdle=o;break;case 47:this.dimtp=o;break;case 48:this.dimtm=o;break;case 140:this.dimtxt=o;break;case 141:this.dimcen=o;break;case 142:this.dimtsz=o;break;case 143:this.dimaltf=o;break;case 144:this.dimlfac=o;break;case 145:this.dimtvp=o;break;case 146:this.dimtfac=o;break;case 147:this.dimgap=o;break;case 148:this.dimaltrnd=o;break;case 71:this.dimtol=e(o);break;case 72:this.dimlim=e(o);break;case 73:this.dimtih=e(o);break;case 74:this.dimtoh=e(o);break;case 75:this.dimse1=e(o);break;case 76:this.dimse2=e(o);break;case 77:this.dimtad=o;break;case 78:this.dimzin=o;break;case 79:this.dimazin=o;break;case 170:this.dimalt=e(o);break;case 171:this.dimaltd=o;break;case 172:this.dimtofl=e(o);break;case 173:this.dimsah=e(o);break;case 174:this.dimtix=e(o);break;case 175:this.dimsoxd=e(o);break;case 176:this.dimclrd=o;break;case 177:this.dimclre=o;break;case 178:this.dimclrt=o;break;case 179:this.dimadec=o;break;case 270:this.dimunit=o;break;case 271:this.dimdec=o;break;case 272:this.dimtdec=o;break;case 273:this.dimaltu=o;break;case 274:this.dimalttd=o;break;case 275:this.dimaunit=o;break;case 276:this.dimfrac=o;break;case 277:this.dimlunit=o;break;case 278:this.dimdsep=typeof s.value=="string"?s.value:String.fromCharCode(o||46);break;case 279:this.dimtmove=o;break;case 280:this.dimjust=o;break;case 281:this.dimsd1=e(o);break;case 282:this.dimsd2=e(o);break;case 283:this.dimtolj=o;break;case 284:this.dimtzin=o;break;case 285:this.dimaltz=o;break;case 286:this.dimalttz=o;break;case 287:this.dimfit=o;break;case 288:this.dimupt=e(o);break;case 289:this.dimatfit=o;break;case 294:case 295:this.dimtxtdirection=e(o);break;case 340:this.dimtxsty=String(s.value);break;case 341:this.dimldrblk=String(s.value);break;case 342:this.dimblk=String(s.value);break;case 343:this.dimblk1=String(s.value);break;case 344:this.dimblk2=String(s.value);break;case 371:this.dimlwd=o;break;case 372:this.dimlwe=o;break}n=a}return this}};so.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimtfill:0,dimtfillclr:0,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimtxtdirection:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:gt,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Vt=so;function Ap(){return{color:new X,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new St,linetype:"Continuous",lineWeight:1,materialId:-1}}const nw=["name",...Object.keys(Ap())];class ls extends on{constructor(t,e){t=t||{},fe(t,Ap()),super(t,e)}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeCmColor(this.color),t.writeString(6,this.linetype||"Continuous"),t.writeInt16(290,this.isPlottable?1:0),t.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLayerTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=Number(e.value);break;case 62:{const r=Number(e.value);this.isOff=r<0,this.color.colorIndex=Math.abs(r);break}case 420:this.color.setRGBValue(Number(e.value));break;case 6:this.linetype=String(e.value);break;case 290:this.isPlottable=Number(e.value)!==0;break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=St.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}const iw=1,nc=2,rw=4;class vn extends on{constructor(t,e){t=t||{},fe(t,{standardFlag:0,description:"",totalPatternLength:0}),super(t,e)}get numDashes(){const t=this.getAttrWithoutException("pattern");return t?t.length:0}get patternLength(){return this.getAttr("totalPatternLength")}get comments(){return this.getAttr("description")}get linetype(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),description:this.getAttr("description"),totalPatternLength:this.getAttr("totalPatternLength"),pattern:this.getAttrWithoutException("pattern")}}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this.getAttr("pattern")[t].elementLength}toPreviewSvgString(t){const e=Math.max((t==null?void 0:t.width)??220,1),n=Math.max((t==null?void 0:t.height)??36,1),r=Math.min(Math.max((t==null?void 0:t.padding)??8,0),Math.floor(e/2)),s=Math.max((t==null?void 0:t.strokeWidth)??2,.5),a=(t==null?void 0:t.stroke)??"currentColor",o=this.escapeSvgAttribute(a),c=this.escapeSvgAttribute((t==null?void 0:t.textFill)??a),l=this.escapeSvgAttribute((t==null?void 0:t.fontFamily)??"sans-serif"),h=n/2,u=r,d=Math.max(e-r,u+1),g=d-u,f=this.getAttrWithoutException("pattern")??[];if(f.length===0||this.patternLength<=0||!f.some(F=>F.elementLength!==0))return this.buildSvgString({width:e,height:n,stroke:o,strokeWidth:s,textFill:c,fontFamily:l,lineSegments:[[u,d]],dots:[],texts:[],y:h});const p=f.some(F=>this.isComplexPatternElement(F)&&(F.elementTypeFlag&nc)!==0),m=Math.max((t==null?void 0:t.repeats)??(p?2:4),1),y=p?Math.min(Math.max(n*.55,Math.min(8,n*.85)),n*.8):0,b=Math.max(s*2,4),_=this.buildPreviewSegments(f,y,b),w=g/(this.patternLength*m),k=.5,P=Math.max(s*2,2),v=_.map(F=>F.kind==="dot"?P:F.kind==="text"?Math.max(F.units*w,F.minPx):Math.max(F.units*w,F.kind==="dash"?k:0)),S=v.reduce((F,q)=>F+q,0),I=S>0?g/(S*m):1,M=v.map(F=>F*I),O=[],N=[],nt=[];let W=u;for(;W<d-1e-6;){for(let F=0;F<_.length&&!(W>=d);F++){const q=_[F],L=M[F],$=Math.min(W+L,d);if(q.kind==="dash"&&$>W)O.push([W,$]);else if(q.kind==="dot")N.push(W);else if(q.kind==="text"&&q.label.trim().length>0){const ct=(W+$)*.5;nt.push({x:ct,y:h,text:q.label,fontSize:Math.min(q.fontSize*I,n*.8),rotationDeg:q.rotationDeg})}W=$}if(S<=0)break}return this.buildSvgString({width:e,height:n,stroke:o,strokeWidth:s,textFill:c,fontFamily:l,lineSegments:O,dots:N,texts:nt,y:h})}buildPreviewSegments(t,e,n){const r=[],s=new Set;for(let a=0;a<t.length;a++){if(s.has(a))continue;const o=t[a];if(this.isComplexPatternElement(o)){let c=0;for(;r.length>0&&r[r.length-1].kind==="gap";){const d=r.pop();c+=d.units}let l=c+Math.abs(o.elementLength);for(let d=a+1;d<t.length;d++){const g=t[d];if(this.isComplexPatternElement(g)||g.elementLength>=0)break;l+=Math.abs(g.elementLength),s.add(d)}const h=(o.elementTypeFlag&nc)!==0,u=h?this.resolveEmbeddedText(o.text):"";if(h&&u.trim().length>0){const d=this.estimateTextWidthPx(u,e)+n;r.push({kind:"text",units:Math.max(l,1e-6),minPx:d,label:u,fontSize:e,rotationDeg:this.previewTextRotationDeg(o)})}else l>0&&r.push({kind:"gap",units:l});continue}o.elementLength===0?r.push({kind:"dot"}):o.elementLength>0?r.push({kind:"dash",units:o.elementLength}):r.push({kind:"gap",units:Math.abs(o.elementLength)})}return r}estimateTextWidthPx(t,e){let n=0;for(const r of t)r===" "?n+=.33:/[iIlj1.'|]/.test(r)?n+=.35:/[mwMW@%]/.test(r)?n+=.85:n+=.62;return Math.max(n*e,e*.5)}isComplexPatternElement(t){const e=t.elementTypeFlag??0;return(e&nc)!==0?(t.text??"").length>0:(e&rw)!==0?t.shapeNumber!=null&&t.shapeNumber!==0:!1}resolveEmbeddedText(t){var o,c;const e=t??"";if(e.trim().length>0)return this.decodeAutoCadTextEscapes(e);const n=(this.comments??"").trim();if(!n)return this.decodeAutoCadTextEscapes(e);const r=(o=n.split(/\s+-\s+/)[0])==null?void 0:o.trim();if(r&&r!==n)return this.decodeAutoCadTextEscapes(r);const s=n.match(/-{2,}\s*([^-]+?)\s*-{2,}/);if((c=s==null?void 0:s[1])!=null&&c.trim())return this.decodeAutoCadTextEscapes(s[1].trim());const a=(this.name??"").trim();return a&&n.length>a.length+2?this.decodeAutoCadTextEscapes(a):this.decodeAutoCadTextEscapes(r||e)}decodeAutoCadTextEscapes(t){return t.replace(/%%(\d{1,3}|[cCdDpP%])/g,(e,n)=>{if(n==="%")return"%";if(n==="c"||n==="C")return"Ø";if(n==="d"||n==="D")return"°";if(n==="p"||n==="P")return"±";const r=Number.parseInt(n,10);return Number.isFinite(r)&&r>=0&&r<=255?String.fromCharCode(r):`%%${n}`})}previewTextRotationDeg(t){const e=t.rotation??0;return(((t.elementTypeFlag??0)&iw)!==0?e:this.uprightLinetypeAngle(e))*180/Math.PI}uprightLinetypeAngle(t){const e=Math.PI*2;let n=((t+Math.PI)%e+e)%e-Math.PI;return(n>Math.PI/2||n<-Math.PI/2)&&(n+=Math.PI,n>Math.PI&&(n-=e)),n}buildSvgString(t){const{width:e,height:n,stroke:r,strokeWidth:s,textFill:a,fontFamily:o,lineSegments:c,dots:l,texts:h,y:u}=t,d=c.map(([p,m])=>`<line x1="${p.toFixed(2)}" y1="${u.toFixed(2)}" x2="${m.toFixed(2)}" y2="${u.toFixed(2)}" stroke="${r}" stroke-width="${s.toFixed(2)}" stroke-linecap="round" />`).join(""),g=l.map(p=>`<circle cx="${p.toFixed(2)}" cy="${u.toFixed(2)}" r="${(s/2).toFixed(2)}" fill="${r}" />`).join(""),f=h.map(p=>{const m=Math.abs(p.rotationDeg)>1e-6?` transform="rotate(${p.rotationDeg.toFixed(2)} ${p.x.toFixed(2)} ${p.y.toFixed(2)})"`:"";return`<text x="${p.x.toFixed(2)}" y="${p.y.toFixed(2)}" fill="${a}" font-family="${o}" font-size="${p.fontSize.toFixed(2)}" text-anchor="middle" dominant-baseline="middle"${m}>${this.escapeSvgText(p.text)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${n}" viewBox="0 0 ${e} ${n}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${d}${g}${f}</svg>`}escapeSvgAttribute(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'")}escapeSvgText(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeString(3,this.comments),t.writeInt16(72,65),t.writeInt16(73,this.numDashes),t.writeDouble(40,this.patternLength);for(const e of this.getAttrWithoutException("pattern")??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag),e.elementTypeFlag!==0&&(e.shapeNumber!=null&&t.writeInt16(75,e.shapeNumber),e.styleObjectId&&t.writeObjectId(340,e.styleObjectId),e.scale!=null&&t.writeDouble(46,e.scale),e.rotation!=null&&t.writeDouble(50,e.rotation),e.offsetX!=null&&t.writeDouble(44,e.offsetX),e.offsetY!=null&&t.writeDouble(45,e.offsetY),e.text&&t.writeString(9,e.text));return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLinetypeTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const n=t.readItem();if(!n)break;const r=Number(n.code);if(r===100){t.pushBackItem(n);break}switch(r){case 2:this.name=String(n.value);break;case 70:this.setAttr("standardFlag",Number(n.value));break;case 3:this.setAttr("description",String(n.value));break;case 72:break;case 73:break;case 40:this.setAttr("totalPatternLength",Number(n.value));break;case 49:e.push({elementLength:Number(n.value),elementTypeFlag:0});break;case 74:e.length>0&&(e[e.length-1].elementTypeFlag=Number(n.value));break;case 75:e.length>0&&(e[e.length-1].shapeNumber=Number(n.value));break;case 340:e.length>0&&(e[e.length-1].styleObjectId=String(n.value));break;case 46:e.length>0&&(e[e.length-1].scale=Number(n.value));break;case 50:e.length>0&&(e[e.length-1].rotation=Number(n.value));break;case 44:e.length>0&&(e[e.length-1].offsetX=Number(n.value));break;case 45:e.length>0&&(e[e.length-1].offsetY=Number(n.value));break;case 9:e.length>0&&(e[e.length-1].text=String(n.value));break}}return this.setAttr("pattern",e),this}}class _r extends on{constructor(t){typeof t=="string"&&(t={name:t}),super(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbRegAppTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break}}return this}}class Eo extends on{constructor(t,e){t=t||{},fe(t,{standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:0,font:"",bigFont:""}),super(t,e),this.setAttr("font",this.getFileNameWithoutExtension(this.getAttr("font")||this.getAttrWithoutException("extendedFont")||this.name))}get obliquingAngle(){return this.getAttr("obliqueAngle")}set obliquingAngle(t){this.setAttr("obliqueAngle",t)}get annotative(){return Se(this)}set annotative(t){me(this,t)}get priorSize(){return this.getAttr("lastHeight")}set priorSize(t){this.setAttr("lastHeight",t)}get textSize(){return this.getAttr("fixedTextHeight")}set textSize(t){this.setAttr("fixedTextHeight",t)}get xScale(){return this.getAttr("widthFactor")}set xScale(t){this.setAttr("widthFactor",t)}get isVertical(){return(this.getAttr("standardFlag")&4)===4}set isVertical(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|4:e&-5)}get isShapeFile(){return(this.getAttr("standardFlag")&1)===1}set isShapeFile(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|1:e&-2)}get fileName(){return this.getAttr("font")}set fileName(t){this.setAttr("font",t)}get bigFontFileName(){return this.getAttr("bigFont")}set bigFontFileName(t){this.setAttr("bigFont",t)}get textStyle(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),fixedTextHeight:this.getAttr("fixedTextHeight"),widthFactor:this.getAttr("widthFactor"),obliqueAngle:this.getAttr("obliqueAngle"),textGenerationFlag:this.getAttr("textGenerationFlag"),lastHeight:this.getAttr("lastHeight"),font:this.getAttr("font"),bigFont:this.getAttr("bigFont"),extendedFont:this.getAttrWithoutException("extendedFont")}}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const n=e.lastIndexOf(".");return n===-1?e:e.substring(0,n)}return t}get dxfFontFileName(){var e;const t=((e=this.fileName)==null?void 0:e.trim())??"";return!t||!this.isShapeFile||/\.[^./\\]+$/i.test(t)?t:`${t}.shx`}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.getAttr("textGenerationFlag")),t.writeDouble(42,this.priorSize),t.writeString(3,this.dxfFontFileName),t.writeString(4,this.bigFontFileName),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbTextStyleTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 2:this.name=String(e.value);break;case 70:this.setAttr("standardFlag",Number(e.value));break;case 40:this.textSize=Number(e.value);break;case 41:this.xScale=Number(e.value);break;case 50:this.obliquingAngle=Number(e.value);break;case 71:this.setAttr("textGenerationFlag",Number(e.value));break;case 42:this.priorSize=Number(e.value);break;case 3:this.fileName=this.getFileNameWithoutExtension(String(e.value));break;case 4:this.bigFontFileName=String(e.value);break}}return this}dxfInXData(t){super.dxfInXData(t),this.applyExtendedFontFromXData()}applyExtendedFontFromXData(){const t=this.getXData("ACAD");if(t){for(const n of t)if(Number(n.code)===1e3&&n.value!=null){const r=String(n.value).trim();if(r){this.setAttr("extendedFont",r);break}}}if(!(this.getAttr("font")??"").trim()){const n=this.getAttrWithoutException("extendedFont")||this.name||"";n&&(this.fileName=this.getFileNameWithoutExtension(n))}}}class Sp extends on{constructor(t,e){t=t||{},fe(t,{standardFlags:0,origin:new x(0,0,0),xAxis:new x(1,0,0),yAxis:new x(0,1,0),isOrthographic:!1,elevation:0}),super(t,e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get origin(){return this.getAttr("origin")}set origin(t){this.setAttr("origin",t.clone())}get xAxis(){return this.getAttr("xAxis")}set xAxis(t){this.setAttr("xAxis",t.clone())}get yAxis(){return this.getAttr("yAxis")}set yAxis(t){this.setAttr("yAxis",t.clone())}get isOrthographic(){return this.getAttr("isOrthographic")}set isOrthographic(t){this.setAttr("isOrthographic",t)}get elevation(){return this.getAttr("elevation")}set elevation(t){this.setAttr("elevation",t)}get baseUcsId(){return this.getAttrWithoutException("baseUcsId")}set baseUcsId(t){this.setAttr("baseUcsId",t)}get orthographicType(){return this.getAttrWithoutException("orthographicType")}set orthographicType(t){this.setAttr("orthographicType",t)}get orthographicOrigin(){return this.getAttrWithoutException("orthographicOrigin")}set orthographicOrigin(t){this.setAttr("orthographicOrigin",t==null?void 0:t.clone())}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbUCSTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writePoint3d(10,this.origin),t.writePoint3d(11,this.xAxis),t.writePoint3d(12,this.yAxis),t.writeDouble(146,this.elevation),t.writeInt16(79,this.isOrthographic?1:0),this.isOrthographic&&t.writeObjectId(346,this.baseUcsId),this.orthographicType!=null&&this.orthographicOrigin&&(t.writeInt16(71,this.orthographicType),t.writePoint3d(13,this.orthographicOrigin)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbUCSTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}const r=Number(e.value);switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 10:this.origin.x=r;break;case 20:this.origin.y=r;break;case 30:this.origin.z=r;break;case 11:this.xAxis.x=r;break;case 21:this.xAxis.y=r;break;case 31:this.xAxis.z=r;break;case 12:this.yAxis.x=r;break;case 22:this.yAxis.y=r;break;case 32:this.yAxis.z=r;break;case 79:this.isOrthographic=r!==0;break;case 146:this.elevation=r;break;case 346:this.baseUcsId=String(e.value);break;case 71:this.orthographicType=r;break;case 13:this.orthographicOrigin=this.orthographicOrigin??new x,this.orthographicOrigin.x=r;break;case 23:this.orthographicOrigin&&(this.orthographicOrigin.y=r);break;case 33:this.orthographicOrigin&&(this.orthographicOrigin.z=r);break}}return this}}const sw=()=>({center:new C,viewDirectionFromTarget:new x(0,0,1),viewTarget:new x(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:exports.AcGiRenderMode.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new x(0,0,0),ucsXAxis:new x(1,0,0),ucsYAxis:new x(0,1,0),orthographicType:exports.AcGiOrthographicType.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:exports.AcGiDefaultLightingType.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0,aspectRatio:void 0});class ah extends on{constructor(t,e){t=t||{},fe(t,{gsView:sw()}),super(t,e)}get gsView(){return this.getAttr("gsView")}get centerPoint(){return this.gsView.center}set centerPoint(t){this.gsView.center.copy(t)}get viewDirectionFromTarget(){return this.gsView.viewDirectionFromTarget}set viewDirectionFromTarget(t){this.gsView.viewDirectionFromTarget.copy(t)}get viewTarget(){return this.gsView.viewTarget}set viewTarget(t){this.gsView.viewTarget.copy(t)}get viewHeight(){return this.gsView.viewHeight}set viewHeight(t){this.gsView.viewHeight=t}get viewTwistAngle(){return this.gsView.viewTwistAngle}set viewTwistAngle(t){this.gsView.viewTwistAngle=t}get lensLength(){return this.gsView.lensLength}set lensLength(t){this.gsView.lensLength=t}get frontClippingPlane(){return this.gsView.frontClippingPlane}set frontClippingPlane(t){this.gsView.frontClippingPlane=t}get backClippingPlane(){return this.gsView.backClippingPlane}set backClippingPlane(t){this.gsView.backClippingPlane=t}get renderMode(){return this.gsView.renderMode}set renderMode(t){this.gsView.renderMode=t}get viewMode(){return this.gsView.viewMode}set viewMode(t){this.gsView.viewMode=t}get ucsIconSetting(){return this.gsView.ucsIconSetting}set ucsIconSetting(t){this.gsView.ucsIconSetting=t}get ucsOrigin(){return this.gsView.ucsOrigin}set ucsOrigin(t){this.gsView.ucsOrigin.copy(t)}get ucsXAxis(){return this.gsView.ucsXAxis}set ucsXAxis(t){this.gsView.ucsXAxis.copy(t)}get ucsYAxis(){return this.gsView.ucsYAxis}set ucsYAxis(t){this.gsView.ucsYAxis.copy(t)}get orthographicType(){return this.gsView.orthographicType}set orthographicType(t){this.gsView.orthographicType=t}get shadePlotSetting(){return this.gsView.shadePlotSetting}set shadePlotSetting(t){this.gsView.shadePlotSetting=t}get shadePlotObjectId(){return this.gsView.shadePlotObjectId}set shadePlotObjectId(t){this.gsView.shadePlotObjectId=t}get visualStyleObjectId(){return this.gsView.visualStyleObjectId}set visualStyleObjectId(t){this.gsView.visualStyleObjectId=t}get isDefaultLightingOn(){return this.gsView.isDefaultLightingOn}set isDefaultLightingOn(t){this.gsView.isDefaultLightingOn=t}get defaultLightingType(){return this.gsView.defaultLightingType}set defaultLightingType(t){this.gsView.defaultLightingType=t}get brightness(){return this.gsView.brightness}set brightness(t){this.gsView.brightness=t}get contrast(){return this.gsView.contrast}set contrast(t){this.gsView.contrast=t}get ambientColor(){return this.gsView.ambientColor}set ambientColor(t){this.gsView.ambientColor=t}get aspectRatio(){return this.gsView.aspectRatio}set aspectRatio(t){this.gsView.aspectRatio=t}}const od=2,aw=.45,ow=1e5;function cw(i){var n;const t=i,e=t.aspectRatio??((n=t.gsView)==null?void 0:n.aspectRatio);return Number.isFinite(e)?e:void 0}function lw(i,t){if(Number.isFinite(t)&&t>0)return t;const e=cw(i);return e!=null&&e>0?e:1}function hw(i,t){const e=Math.max(i.min.x,t.min.x),n=Math.max(i.min.y,t.min.y),r=Math.min(i.max.x,t.max.x),s=Math.min(i.max.y,t.max.y);return e>=r||n>=s?0:(r-e)*(s-n)}function cd(i){return{x:(i.min.x+i.max.x)/2,y:(i.min.y+i.max.y)/2}}function uw(i){if(!i||i.isEmpty())return!1;const t=i.max.x-i.min.x,e=i.max.y-i.min.y;return t>0&&e>0}class An extends ah{static isActiveVportName(t){return t.toLowerCase()===Ri.toLowerCase()}constructor(t,e){t=t||{},fe(t,{circleSides:100,lowerLeftCorner:new C(0,0),upperRightCorner:new C(1,1),snapBase:new C(0,0),snapAngle:0,snapSpacing:new C(0,0),standardFlag:0,gridSpacing:new C,gridMajor:10,ucsElevation:0}),super(t,e)}get circleSides(){return this.getAttr("circleSides")}set circleSides(t){this.setAttr("circleSides",t)}get center(){return this.centerPoint}set center(t){this.centerPoint=t}get lowerLeftCorner(){return this.getAttr("lowerLeftCorner")}set lowerLeftCorner(t){this.getAttr("lowerLeftCorner").copy(t)}get upperRightCorner(){return this.getAttr("upperRightCorner")}set upperRightCorner(t){this.getAttr("upperRightCorner").copy(t)}get snapBase(){return this.getAttr("snapBase")}set snapBase(t){this.getAttr("snapBase").copy(t)}get snapAngle(){return this.getAttr("snapAngle")}set snapAngle(t){this.setAttr("snapAngle",t)}get snapIncrements(){return this.getAttr("snapSpacing")}set snapIncrements(t){this.getAttr("snapSpacing").copy(t)}get gridMajor(){return this.getAttr("gridMajor")}set gridMajor(t){this.setAttr("gridMajor",t)}get gridIncrements(){return this.getAttr("gridSpacing")}set gridIncrements(t){this.getAttr("gridSpacing").copy(t)}get standardFlag(){return this.getAttr("standardFlag")}set standardFlag(t){this.setAttr("standardFlag",t)}get snapEnabled(){return!!(this.standardFlag&256)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}modelViewBox(t){const e=this.centerPoint,n=this.viewHeight;if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(n)||n<=0)return;const r=this.viewTwistAngle;let s=e.x,a=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,a=e.x*g+e.y*d}const o=this.viewTarget;o&&Number.isFinite(o.x)&&Number.isFinite(o.y)&&(s+=o.x,a+=o.y);const c=lw(this,t),l=n*c,h=n/2,u=l/2;return new Ct().expandByPoint({x:s-u,y:a-h}).expandByPoint({x:s+u,y:a+h})}static isModelViewBoxUsable(t,e){if(t.isEmpty()||e.isEmpty())return!1;const n=t.max.x-t.min.x,r=t.max.y-t.min.y,s=e.max.x-e.min.x,a=e.max.y-e.min.y;if(n<=0||r<=0||s<=0||a<=0||n>s*od||r>a*od)return!1;const o=Math.max(s,a)*aw,c=cd(t),l=cd(e);if(Math.hypot(c.x-l.x,c.y-l.y)>o)return!1;const u=n*r,d=hw(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const n=this.modelViewBox(t);if(!(!n||!An.isModelViewBoxStructurallyValid(n))){if(uw(e)){if(!An.isModelViewBoxUsable(n,e))return}else if(!An.isModelViewBoxPlausibleWithoutExtents(n))return;return n}}static isModelViewBoxStructurallyValid(t){if(t.isEmpty())return!1;const e=t.max.x-t.min.x,n=t.max.y-t.min.y;return Number.isFinite(e)&&Number.isFinite(n)&&e>0&&n>0}static isModelViewBoxPlausibleWithoutExtents(t){const e=t.max.x-t.min.x,n=t.max.y-t.min.y;return Math.max(e,n)<=ow}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(40,this.gsView.viewHeight),this.gsView.aspectRatio!=null&&Number.isFinite(this.gsView.aspectRatio)&&t.writeDouble(41,this.gsView.aspectRatio),t.writePoint2d(10,this.lowerLeftCorner),t.writePoint2d(11,this.upperRightCorner),t.writePoint2d(12,this.center),t.writePoint2d(13,this.snapBase),t.writePoint2d(14,this.snapIncrements),t.writePoint2d(15,this.gridIncrements),t.writeInt16(70,this.standardFlag),t.writeInt16(71,this.circleSides),t.writeDouble(42,this.gsView.lensLength),t.writePoint3d(16,this.gsView.viewDirectionFromTarget),t.writePoint3d(17,this.gsView.viewTarget),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.gsView.viewTwistAngle),t.capabilities.supportsVportExtendedFields&&(t.writeInt16(61,this.gridMajor),t.writeDouble(146,this.ucsElevation),t.writeInt16(170,this.shadePlotSetting),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLightingOn?1:0),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(333,this.shadePlotObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewportTableRecord");const e=[...this.gsView.frozenLayers??[]];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const n=t.readItem();if(!n)break;const r=Number(n.code);if(r===100){t.pushBackItem(n);break}const s=Number(n.value);switch(r){case 2:this.name=String(n.value);break;case 1:this.gsView.styleSheet=String(n.value);break;case 10:this.lowerLeftCorner.x=s;break;case 20:this.lowerLeftCorner.y=s;break;case 11:this.upperRightCorner.x=s;break;case 21:this.upperRightCorner.y=s;break;case 12:this.center.x=s,this.gsView.center.x=s;break;case 22:this.center.y=s,this.gsView.center.y=s;break;case 13:this.snapBase.x=s;break;case 23:this.snapBase.y=s;break;case 14:this.snapIncrements.x=s;break;case 24:this.snapIncrements.y=s;break;case 15:this.gridIncrements.x=s;break;case 25:this.gridIncrements.y=s;break;case 16:this.gsView.viewDirectionFromTarget.x=s;break;case 26:this.gsView.viewDirectionFromTarget.y=s;break;case 36:this.gsView.viewDirectionFromTarget.z=s;break;case 17:this.gsView.viewTarget.x=s;break;case 27:this.gsView.viewTarget.y=s;break;case 37:this.gsView.viewTarget.z=s;break;case 40:case 45:this.gsView.viewHeight=s;break;case 41:Number.isFinite(s)&&s>0&&(this.gsView.aspectRatio=s);break;case 42:this.gsView.lensLength=s;break;case 43:this.gsView.frontClippingPlane=s;break;case 44:this.gsView.backClippingPlane=s;break;case 50:this.snapAngle=s;break;case 51:this.gsView.viewTwistAngle=s;break;case 61:this.gridMajor=s;break;case 70:this.standardFlag=s;break;case 71:s>=1&&s<=2e4&&(this.circleSides=s),this.gsView.viewMode=s;break;case 72:this.circleSides=s;break;case 74:this.gsView.ucsIconSetting=s;break;case 110:this.gsView.ucsOrigin.x=s;break;case 120:this.gsView.ucsOrigin.y=s;break;case 130:this.gsView.ucsOrigin.z=s;break;case 111:this.gsView.ucsXAxis.x=s;break;case 121:this.gsView.ucsXAxis.y=s;break;case 131:this.gsView.ucsXAxis.z=s;break;case 112:this.gsView.ucsYAxis.x=s;break;case 122:this.gsView.ucsYAxis.y=s;break;case 132:this.gsView.ucsYAxis.z=s;break;case 79:this.gsView.orthographicType=s;break;case 281:this.gsView.renderMode=s;break;case 331:case 441:e.push(String(n.value));break;case 332:this.backgroundObjectId=String(n.value);break;case 146:this.ucsElevation=s;break;case 170:this.shadePlotSetting=s;break;case 282:this.defaultLightingType=s;break;case 292:this.isDefaultLightingOn=s!==0;break;case 333:this.shadePlotObjectId=String(n.value);break;case 348:this.gsView.visualStyleObjectId=String(n.value);break}}return this.gsView.frozenLayers=e,this}}class Pp extends ah{constructor(t,e){t=t||{};const n=t.viewWidth!==void 0;fe(t,{standardFlags:0,ucsAssociated:!1,cameraPlottable:!1,ucsElevation:0}),super(t,e),n||(this.viewWidth=this.viewHeight)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get viewWidth(){return this.getAttr("viewWidth")}set viewWidth(t){this.setAttr("viewWidth",t)}get ucsAssociated(){return this.getAttr("ucsAssociated")}set ucsAssociated(t){this.setAttr("ucsAssociated",t)}get cameraPlottable(){return this.getAttr("cameraPlottable")}set cameraPlottable(t){this.setAttr("cameraPlottable",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}get ucsObjectId(){return this.getAttrWithoutException("ucsObjectId")}set ucsObjectId(t){this.setAttr("ucsObjectId",t)}get ucsBaseObjectId(){return this.getAttrWithoutException("ucsBaseObjectId")}set ucsBaseObjectId(t){this.setAttr("ucsBaseObjectId",t)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get liveSectionObjectId(){return this.getAttrWithoutException("liveSectionObjectId")}set liveSectionObjectId(t){this.setAttr("liveSectionObjectId",t)}get sunObjectId(){return this.getAttrWithoutException("sunObjectId")}set sunObjectId(t){this.setAttr("sunObjectId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeDouble(40,this.gsView.viewHeight),t.writePoint2d(10,this.centerPoint),t.writeDouble(41,this.viewWidth),t.writePoint3d(11,this.gsView.viewDirectionFromTarget),t.writePoint3d(12,this.gsView.viewTarget),t.writeDouble(42,this.gsView.lensLength),t.writeDouble(43,this.gsView.frontClippingPlane),t.writeDouble(44,this.gsView.backClippingPlane),t.writeAngle(50,this.gsView.viewTwistAngle),t.writeInt16(71,this.gsView.viewMode),t.writeInt16(281,this.gsView.renderMode),t.writeInt16(72,this.ucsAssociated?1:0),t.writeInt16(73,this.cameraPlottable?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(334,this.liveSectionObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId),t.writeObjectId(361,this.sunObjectId),this.ucsAssociated&&(t.writePoint3d(110,this.gsView.ucsOrigin),t.writePoint3d(111,this.gsView.ucsXAxis),t.writePoint3d(112,this.gsView.ucsYAxis),t.writeInt16(79,this.gsView.orthographicType),t.writeDouble(146,this.ucsElevation),t.writeObjectId(345,this.ucsObjectId),t.writeObjectId(346,this.ucsBaseObjectId)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}const r=Number(e.value);switch(n){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 40:this.gsView.viewHeight=r;break;case 10:this.centerPoint.x=r;break;case 20:this.centerPoint.y=r;break;case 41:this.viewWidth=r;break;case 11:this.gsView.viewDirectionFromTarget.x=r;break;case 21:this.gsView.viewDirectionFromTarget.y=r;break;case 31:this.gsView.viewDirectionFromTarget.z=r;break;case 12:this.gsView.viewTarget.x=r;break;case 22:this.gsView.viewTarget.y=r;break;case 32:this.gsView.viewTarget.z=r;break;case 42:this.gsView.lensLength=r;break;case 43:this.gsView.frontClippingPlane=r;break;case 44:this.gsView.backClippingPlane=r;break;case 50:this.gsView.viewTwistAngle=r*Math.PI/180;break;case 71:this.gsView.viewMode=r;break;case 281:this.gsView.renderMode=r;break;case 72:this.ucsAssociated=r!==0;break;case 73:this.cameraPlottable=r!==0;break;case 332:this.backgroundObjectId=String(e.value);break;case 334:this.liveSectionObjectId=String(e.value);break;case 348:this.gsView.visualStyleObjectId=String(e.value);break;case 361:this.sunObjectId=String(e.value);break;case 110:this.gsView.ucsOrigin.x=r;break;case 120:this.gsView.ucsOrigin.y=r;break;case 130:this.gsView.ucsOrigin.z=r;break;case 111:this.gsView.ucsXAxis.x=r;break;case 121:this.gsView.ucsXAxis.y=r;break;case 131:this.gsView.ucsXAxis.z=r;break;case 112:this.gsView.ucsYAxis.x=r;break;case 122:this.gsView.ucsYAxis.y=r;break;case 132:this.gsView.ucsYAxis.z=r;break;case 79:this.gsView.orthographicType=r;break;case 146:this.ucsElevation=r;break;case 345:this.ucsObjectId=String(e.value);break;case 346:this.ucsBaseObjectId=String(e.value);break}}return this}}const Hi=192,Gi=193,ir=194,hs=195,oh=200;function ic(i){if(i.isByBlock)return Gi<<24>>0;if(i.isByLayer)return Hi<<24>>0;const t=i.colorIndex;if(t!=null&&t>0&&t<256)return(hs<<24|t&255)>>0;const e=i.RGB;return e!=null?(ir<<24|e&16777215)>>0:Gi<<24>>0}function Yt(i){const t=new X(exports.AcCmColorMethod.ByBlock);if(!Number.isFinite(i))return t;switch(i>>>24&255){case Hi:t.setByLayer();break;case Gi:case oh:t.setByBlock();break;case hs:t.colorIndex=i&255;break;case ir:t.setRGBValue(i&16777215);break;default:i===256?t.setByLayer():i===0?t.setByBlock():i>0&&i<256&&(t.colorIndex=i);break}return t}function Ur(i){if(i==null)return new X(exports.AcCmColorMethod.ByBlock);if(typeof i=="number")return Yt(i);if(typeof i=="object"){const t=i,e=t.method!=null&&t.method!==0?t.method&255:typeof t.rgb=="number"?t.rgb>>>24&255:0;if(typeof t.rgb=="number"&&Number.isFinite(t.rgb)&&e>=Hi&&e<=oh&&(t.rgb>>>24&255)===e)return Yt(t.rgb>>0);if(e===Hi||t.index===256){const n=new X;return n.setByLayer(),n}if(e===Gi||t.index===0)return new X(exports.AcCmColorMethod.ByBlock);if(e===ir&&typeof t.rgb=="number"){const n=new X;return n.setRGBValue(t.rgb&16777215),n}if(e===hs){const n=typeof t.rgb=="number"?t.rgb&255:(t.index??0)&255;return Yt(n)}if(typeof t.index=="number"&&t.index>=0&&t.index<=256)return Yt(t.index);if(typeof t.rgb=="number"&&Number.isFinite(t.rgb))return Yt(t.rgb>>0)}return new X(exports.AcCmColorMethod.ByBlock)}function dw(i){const t=Ur(i);if(t.isByBlock)return 0;if(t.isByLayer)return 256;const e=t.colorIndex;if(e!=null&&e>0&&e<256)return e;const n=t.RGB;return typeof n=="number"?(ir<<24|n&16777215)>>0:0}const gw=127;var kp=(i=>(i[i.Extents=1]="Extents",i[i.Circle=2]="Circle",i[i.Circle3P=3]="Circle3P",i[i.CircularArc=4]="CircularArc",i[i.CircularArc3P=5]="CircularArc3P",i[i.Polyline=6]="Polyline",i[i.Polygon=7]="Polygon",i[i.Mesh=8]="Mesh",i[i.Shell=9]="Shell",i[i.Text=10]="Text",i[i.Text2=11]="Text2",i[i.Xline=12]="Xline",i[i.Ray=13]="Ray",i[i.AttributeColor=14]="AttributeColor",i[i.AttributeLayer=16]="AttributeLayer",i[i.AttributeLinetype=18]="AttributeLinetype",i[i.AttributeMarker=19]="AttributeMarker",i[i.AttributeFill=20]="AttributeFill",i[i.AttributeTrueColor=22]="AttributeTrueColor",i[i.AttributeLineweight=23]="AttributeLineweight",i[i.AttributeLtscale=24]="AttributeLtscale",i[i.AttributeThickness=25]="AttributeThickness",i[i.PushMatrix=29]="PushMatrix",i[i.PopMatrix=31]="PopMatrix",i[i.PolylineWithNormals=32]="PolylineWithNormals",i[i.LwPolyline=33]="LwPolyline",i[i.UnicodeText=36]="UnicodeText",i[i.UnicodeText2=38]="UnicodeText2",i[i.EllipticArc=44]="EllipticArc",i))(kp||{});const Mn=A.Z_AXIS,fw=529;function pw(i){const t=i>>24&255;return t===ir?{rgb:i&16777215}:t===Hi?{colorIndex:256}:t===Gi?{colorIndex:0}:t===hs?{colorIndex:i&255}:{colorIndex:i&255}}function rc(i){return new A(i.x,i.y,i.z??0)}function sc(i){return new x(i.x,i.y,i.z??0)}function ld(i){return{x:i[0],y:i[1],z:i[2]}}class Hc{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=kt,this._lineweight=exports.AcGiLineWeight.ByLineWeightDefault,this._ltscale=1,this._thickness=0,this._fill=!1,this._layers=[],this._linetypes=[],this._matrices=[],this._buffer=t,this._database=e.database,this._dxfversion=e.dxfversion??"AC1015",this._encoding=e.encoding??(this._dxfversion<"AC1024"?"windows-1252":"utf-8"),this._layer=e.defaultLayer??"0",this._database&&(this._database.tables.layerTable.newIterator().toArray().forEach(n=>this._layers.push(n.name)),this._database.tables.linetypeTable.newIterator().toArray().forEach(n=>this._linetypes.push(n.name)))}get extents(){return this._extents}scanExtents(){var n;const t=this._buffer;let e=this._index;for(;e<t.length;){const r=new DataView(t.buffer,t.byteOffset+e,8),s=r.getUint32(0,!0),a=r.getUint32(4,!0);if(s<8)break;if(a===1){const o=t.subarray(e+8,e+s);return this.readExtents(o),((n=this._extents)==null?void 0:n.length)===2?[this._extents[0],this._extents[1]]:void 0}e+=s}}worldDraw(t){const e=[],n=t.subEntityTraits,r={color:n.color.clone(),lineType:n.lineType,lineTypeScale:n.lineTypeScale,lineWeight:n.lineWeight,layer:n.layer,thickness:n.thickness},s=this._buffer;let a=this._index;for(;a<s.length;){const o=new DataView(s.buffer,s.byteOffset+a,8),c=o.getUint32(0,!0),l=o.getUint32(4,!0);if(c<8)break;const h=s.subarray(a+8,a+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),a+=c}if(n.color=r.color,n.lineType=r.lineType,n.lineTypeScale=r.lineTypeScale,n.lineWeight=r.lineWeight,n.layer=r.layer,n.thickness=r.thickness,e.length!==0)return t.group(e)}dispatchChunk(t,e,n,r){switch(n){case 1:this.readExtents(r);break;case 2:this.drawCircle(t,e,r);break;case 3:this.drawCircle3P(t,e,r);break;case 4:this.drawCircularArc(t,e,r);break;case 5:this.drawCircularArc3P(t,e,r);break;case 44:this.drawEllipticArc(t,e,r);break;case 6:this.drawPolyline(t,e,r,!1);break;case 32:this.drawPolyline(t,e,r,!0);break;case 7:this.drawPolygon(t,e,r);break;case 33:this.drawLwPolyline(t,e,r);break;case 9:this.drawShell(t,e,r);break;case 10:this.drawText(t,e,r,!1);break;case 36:this.drawText(t,e,r,!0);break;case 11:this.drawText2(t,e,r,!1);break;case 38:this.drawText2(t,e,r,!0);break;case 12:this.drawXline(t,e,r,!1);break;case 13:this.drawXline(t,e,r,!0);break;case 14:this.readAttributeColor(r);break;case 16:this.readAttributeLayer(r);break;case 18:this.readAttributeLinetype(r);break;case 20:this.readAttributeFill(r);break;case 22:this.readAttributeTrueColor(r);break;case 23:this.readAttributeLineweight(r);break;case 24:this.readAttributeLtscale(r);break;case 25:this.readAttributeThickness(r);break;case 29:this.pushMatrix(r);break;case 31:this.popMatrix();break}}applyTraits(t){const e=t.subEntityTraits;e.layer=this._layer,e.lineTypeScale=this._ltscale,e.thickness=this._thickness,e.lineWeight=this._lineweight,this._rgbColor!=null?e.color=new X(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new X(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new X(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new X(exports.AcCmColorMethod.ByACI,7):e.color=new X(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===kt?"ByLayer":this._linetype===Ne?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?ld(t):t,n=sc(e);return this._matrices.length>0&&n.applyMatrix4(this._matrices[this._matrices.length-1]),n}transformVector(t){const e=Array.isArray(t)?ld(t):t,n=rc(e);return this._matrices.length>0&&n.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(n.lengthSq())||n.lengthSq()<1e-24?Mn.clone():n.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new re(t),n=e.readVertex(),r=e.readVertex();this._extents=[new x(n[0],n[1],n[2]),new x(r[0],r[1],r[2])]}readAttributeColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);this._rgbColor=void 0,this._colorIndex=e>256||e<0?256:e}readAttributeLayer(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e<this._layers.length&&(this._layer=this._layers[e])}readAttributeLinetype(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e+2<this._linetypes.length?this._linetype=this._linetypes[e+2]:e===32766?this._linetype=Ne:this._linetype=kt}readAttributeFill(t){this._fill=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0)!==0}readAttributeTrueColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0),n=pw(e);this._rgbColor=n.rgb,n.colorIndex!=null&&(this._colorIndex=n.colorIndex)}readAttributeLineweight(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e>fw?this._lineweight=e-4294967296:this._lineweight=e}readAttributeLtscale(t){this._ltscale=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}readAttributeThickness(t){this._thickness=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}pushMatrix(t){const e=new Float64Array(t.buffer,t.byteOffset,16),n=new z().fromArray(Array.from(e));n.transpose(),this._matrices.push(n)}popMatrix(){this._matrices.length>0&&this._matrices.pop()}loadVertices(t,e){const n=new re(t);let r=n.readLong();e&&(r+=1);const s=[];for(;r>0;){const[o,c,l]=n.readVertex();s.push(this.transformPoint({x:o,y:c,z:l})),r-=1}let a=Mn;return e&&s.length>0&&(a=rc(s.pop())),{vertices:s,normal:a}}drawCircle(t,e,n){const r=new re(n),s=r.readVertex(),a=r.readFloat(),o=this.transformVector(r.readVertex());let c=sc({x:s[0],y:s[1],z:s[2]});o.equals(Mn)||(c=Zt(c,o)),c=this.transformPoint(c);const l=Mi(o),h=new _t(ce(c,o),a,0,Y,o,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=_t.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=new _t(c,l,0,Y,Mn);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,n){const r=new re(n),s=r.readVertex(),a=r.readFloat(),o=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(o),u=sc({x:s[0],y:s[1],z:s[2]}),d=rc({x:c[0],y:c[1],z:c[2]});this._matrices.length>0&&d.transformDirection(this._matrices[this._matrices.length-1]);const g=Number.isFinite(d.lengthSq())&&d.lengthSq()>=1e-24?d.normalize():Mi(h),f=0,p=l,m=new _t(this.transformPoint(u),a,f,p,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=_t.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=Ze(c,s,Mn),u=Ze(c,o,Mn),d=new _t(c,l,h,u,Mn);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,n){const r=new re(n),s=this.transformPoint(r.readVertex()),a=this.transformVector(r.readVertex()),o=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=ce({x:Math.cos(u)*o,y:Math.sin(u)*o,z:0},a),g=new we(s,a,d,o,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,n,r){var a,o;const{vertices:s}=this.loadVertices(n,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((a=this._database)==null?void 0:a.pdmode)??0,l=((o=this._database)==null?void 0:o.pdsize)??0;this.pushEntity(e,t.point(s[0],{displayMode:c,displaySize:l}));return}this.applyTraits(t),this.pushEntity(e,t.lines(s))}}drawPolygon(t,e,n){const{vertices:r}=this.loadVertices(n,!1);if(r.length<2)return;if(this._fill){const a=new ot(r.map(l=>({x:l.x,y:l.y})),!0),o=new de;o.add(a);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(o));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,n){const r=new Hf(n,this._dxfversion,this._encoding);let s=0,a=!1;r.readUnsignedLong();const o=r.readBitShort();o&8&&(s=r.readBitDouble()),o&512&&(a=!0);const c=r.readBitLong();if(c<=0)return;const l=o&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(o&1024&&r.readBitLong(),o&32&&r.readBitLong());const h=r.readRawDouble(2),u=[this.transformPoint({x:h[0],y:h[1],z:s})];let d=h;for(let g=1;g<c;g++){const f=r.readBitDoubleDefault(1,d[0]),p=r.readBitDoubleDefault(1,d[1]);d=[f,p],u.push(this.transformPoint({x:f,y:p,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();a&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,n){const r=new re(n),s=r.readLong(),a=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();a.push(this.transformPoint({x:u,y:d,z:g}))}const o=r.readLong(),c=[];let l=0;for(;l<o;){const h=Math.abs(r.readSignedLong());l+=1+h;const u=[];for(let g=0;g<h;g++)u.push(r.readLong());const d=u.map(g=>a[g]).filter(Boolean);if(d.length>=3)for(let g=0;g<d.length;g++)c.push(d[g]),c.push(d[(g+1)%d.length])}c.length!==0&&(this.applyTraits(t),this.pushEntity(e,t.lines(c)))}drawText(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),[l,h,u]=s.readStruct([8,8,8]),d=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),l=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);s.readSignedLong(),s.readSignedLong();const[h,u,d]=s.readStruct([8,8,8]);s.readFloat(),this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:l,height:h,widthFactor:u,obliqueAngle:d})}drawTextPrimitive(t,e,n){const r=Math.atan2(n.textDirection.y,n.textDirection.x),s={text:n.text,height:n.height,width:1/0,widthFactor:n.widthFactor,position:n.insert,rotation:r*180/Math.PI,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft},a={name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:n.widthFactor,obliqueAngle:n.obliqueAngle*180/Math.PI,textGenerationFlag:0,lastHeight:n.height,font:"txt",bigFont:""};this.applyTraits(t),this.pushEntity(e,t.mtext(s,a))}drawXline(t,e,n,r){const s=new re(n),a=this.transformPoint(s.readVertex()),o=this.transformPoint(s.readVertex()),c=new A().subVectors(o,a);if(c.lengthSq()===0)return;const l=1e6,h=r?a.clone().add(c.normalize().multiplyScalar(l)):a.clone().sub(c.normalize().multiplyScalar(l)),u=o.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function mw(i,t){if(!(t!=null&&t.length))return;const e=cs(t);return i!=null&&i>0&&e.length>=i?e.subarray(0,i):e}const Nh=class Nh extends et{constructor(){super(...arguments),this._originalDxfName="",this._originalClassName="",this._applicationName="",this._proxyEntityClassId=498,this._applicationEntityClassId=0,this._objectDrawingFormat=0,this._originalDataFormat=0,this._entityOrigins=[],this._worldTransform=new z}get dxfTypeName(){return"ACAD_PROXY_ENTITY"}get originalDxfName(){return this._originalDxfName}set originalDxfName(t){this._originalDxfName=t}get originalClassName(){return this._originalClassName}set originalClassName(t){this._originalClassName=t}get applicationName(){return this._applicationName}set applicationName(t){this._applicationName=t}get proxyEntityClassId(){return this._proxyEntityClassId}set proxyEntityClassId(t){this._proxyEntityClassId=t}get applicationEntityClassId(){return this._applicationEntityClassId}set applicationEntityClassId(t){this._applicationEntityClassId=t}get objectDrawingFormat(){return this._objectDrawingFormat}set objectDrawingFormat(t){this._objectDrawingFormat=t}get graphicsMetafileType(){return this._objectDrawingFormat}set graphicsMetafileType(t){this._objectDrawingFormat=t}get originalDataFormat(){return this._originalDataFormat}set originalDataFormat(t){this._originalDataFormat=t}get proxyGraphic(){return this._proxyGraphic}setProxyGraphic(t){this._proxyGraphic=t?new Uint8Array(t):void 0}get entityOrigins(){return this._entityOrigins}setEntityOrigins(t){this._entityOrigins=t.map(e=>new x(e.x,e.y,e.z))}get geometricExtents(){const t=this._proxyGraphic;if(!(t!=null&&t.length))return new H;const n=new Hc(t,{database:this.database,defaultLayer:this.layer}).scanExtents();if(n){const r=new H().setFromPoints(n);return this._worldTransform.equals(new z)||r.applyMatrix4(this._worldTransform),r}return new H}subGetGripPoints(){if(this._entityOrigins.length>0)return[...this._entityOrigins];const t=this.geometricExtents;return t.isEmpty()?[]:[new x(t.min.x,t.min.y,t.min.z),new x(t.max.x,t.max.y,t.max.z)]}subMoveGripPointsAt(t,e){return this._entityOrigins.length>0?(er(t,e,this._entityOrigins),this):this.geometricExtents.isEmpty()?this:(Et(t,r=>{r===0&&this.transformBy(z.makeTranslation(e))}),this)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"proxy",properties:[{name:"originalDxfName",type:"string",editable:!1,accessor:{get:()=>this.originalDxfName}},{name:"originalClassName",type:"string",editable:!1,accessor:{get:()=>this.originalClassName}},{name:"applicationName",type:"string",editable:!1,accessor:{get:()=>this.applicationName}},{name:"proxyEntityClassId",type:"int",editable:!1,accessor:{get:()=>this.proxyEntityClassId}},{name:"applicationEntityClassId",type:"int",editable:!1,accessor:{get:()=>this.applicationEntityClassId}},{name:"objectDrawingFormat",type:"int",editable:!1,accessor:{get:()=>this.objectDrawingFormat}},{name:"originalDataFormat",type:"int",editable:!1,accessor:{get:()=>this.originalDataFormat}}]}]}}transformBy(t){return this._entityOrigins.forEach(e=>e.applyMatrix4(t)),this._worldTransform.premultiply(t),this}subWorldDraw(t){const e=this._proxyGraphic;if(!(e!=null&&e.length))return;const r=new Hc(e,{database:this.database,defaultLayer:this.layer}).worldDraw(t);return r&&!this._worldTransform.equals(new z)&&r.applyMatrix(this._worldTransform),r}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbProxyEntity"),this._originalDxfName&&t.writeString(1,this._originalDxfName),this._originalClassName&&t.writeString(3,this._originalClassName),t.writeInt32(90,this._proxyEntityClassId||498),this._applicationEntityClassId&&t.writeInt32(91,this._applicationEntityClassId),this._objectDrawingFormat&&t.writeInt32(95,this._objectDrawingFormat),t.writeInt16(70,this._originalDataFormat),(e=this._proxyGraphic)!=null&&e.length){t.writeInt32(160,this._proxyGraphic.length);let n=0;for(;n<this._proxyGraphic.length;){const r=this._proxyGraphic.subarray(n,n+127);t.writeString(310,Po(r)),n+=127}}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbProxyEntity");const e=[];let n;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 1:this.originalDxfName=String(r.value);break;case 3:this.originalClassName=String(r.value);break;case 70:this.originalDataFormat=a;break;case 90:this.proxyEntityClassId=a;break;case 91:this.applicationEntityClassId=a;break;case 95:this.objectDrawingFormat=a;break;case 160:n=a;break;case 310:r.value instanceof Uint8Array?e.push(r.value):e.push(String(r.value));break}}return e.length>0&&this.loadProxyGraphicFromDxf(n,e),this}loadProxyGraphicFromDxf(t,e){const n=mw(t,e);n&&this.setProxyGraphic(n)}};Nh.typeName="ProxyEntity";let Hr=Nh;const Rh=class Rh extends Hr{constructor(t=""){super(),this._rawTags={header:[],body:[]},this._dxfTypeName=t.toUpperCase(),this.originalDxfName=this._dxfTypeName}get dxfTypeName(){return this._dxfTypeName}get rawTags(){return this._rawTags}dxfIn(t){const{tags:e,handle:n,ownerId:r,extensionDictionary:s}=Rf(t);this._rawTags=e,n&&(this.objectId=n),r&&(this.ownerId=r),s&&(this.extensionDictionary=s);const a=ve.forReading(new Ao(e.body.map(as)),{database:t.database});return this.dxfInFields(a),this.loadEmbeddedProxyGraphic(),t.atExtendedData&&this.dxfInXData(t),this}dxfInFields(t){return et.prototype.dxfInFields.call(this,t),this}dxfOut(...t){const[e,n=!1]=t;return Gl(e,this.patchedTags(),this),n&&this.dxfOutXData(e),this}patchedTags(){const t=[...this._rawTags.body],e=t.findIndex(a=>Number(a.code)===100&&a.value==="AcDbEntity");if(e<0)return this._rawTags;let n=t.findIndex((a,o)=>o>e&&Number(a.code)===100);n<0&&(n=t.length);const r={code:8,value:this.layer},s=t.findIndex((a,o)=>o>e&&o<n&&Number(a.code)===8);return s>=0?t[s]=r:t.splice(e+1,0,r),{header:this._rawTags.header,body:t}}get hasSubclassData(){return this._rawTags.body.some(t=>Number(t.code)===100)}transformBy(t){return this}subGetGripPoints(){return[]}loadEmbeddedProxyGraphic(){let t;const e=[];let n=!1;for(const r of this._rawTags.body){const s=Number(r.code);if(s===100){n=r.value==="AcDbEntity";continue}n&&(s===92||s===160?t=Number(r.value):s===310&&e.push(r.value instanceof Uint8Array?r.value:String(r.value)))}e.length>0&&this.loadProxyGraphicFromDxf(t,e)}};Rh.typeName="UnknownEntity";let Gr=Rh;const yw="ASM_Data";function Gc(i){return String(i).trim().toUpperCase()}function bw(i){let t,e;const n={};for(;!i.atEndOfObject&&!i.atEof;){const r=i.readItem();if(!r)break;switch(Number(r.code)){case 320:t=Gc(String(r.value));break;case 2:e=String(r.value),n[e]??(n[e]=[]);break;case 310:e&&(r.value instanceof Uint8Array?n[e].push(r.value):n[e].push(String(r.value)));break}}return{ownerHandle:t,hexChunks:n[yw]??[]}}function _w(i){const t={};for(;!i.atEof;){const e=i.peekItem();if(!e)break;if(Number(e.code)!==0){i.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"||n==="EOF"){i.readItem();break}if(i.readItem(),n==="ACDSRECORD"){const r=bw(i);if(r.ownerHandle&&r.hexChunks.length>0){const s=cs(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else i.skipToEndOfObject()}return{byOwnerHandle:t}}function Ip(i,t){for(t.clearDxfHeaderExtras();!i.atEof;){const e=i.peekItem();if(!e)break;if(Number(e.code)===0){if(String(e.value).toUpperCase()==="ENDSEC"){i.readItem();break}break}if(i.readItem(),Number(e.code)!==9)continue;const n=String(e.value).toUpperCase();xw(i,t,n)}}function xw(i,t,e){switch(e){case"$ACADVER":{const n=ke(i);n&&(t.version=n);break}case"$DWGCODEPAGE":{const n=ke(i);n&&(t.dwgCodePage=n);break}case"$CECOLOR":{const n=ac(i);n?t.cecolor=n:t.cecolor.colorIndex=256;break}case"$HPCOLOR":{const n=ac(i);n&&(t.hpcolor=n);break}case"$HPBACKGROUNDCOLOR":{const n=ac(i);n&&(t.hpbackgroundcolor=n);break}case"$ANGBASE":t.angbase=ft(i)??0;break;case"$ANGDIR":t.angdir=ft(i)??0;break;case"$AUNITS":{const n=ft(i);n!=null&&(t.aunits=n);break}case"$AUPREC":{const n=ft(i);n!=null&&(t.auprec=n);break}case"$LUNITS":{const n=ft(i);n!=null&&(t.lunits=n);break}case"$LUPREC":{const n=ft(i);n!=null&&(t.luprec=n);break}case"$UNITMODE":{const n=ft(i);n!=null&&(t.unitmode=n);break}case"$MEASUREMENT":{const n=ft(i);n!=null&&(t.measurement=n);break}case"$CELTYPE":t.celtype=ke(i)||kt;break;case"$CETRANSPARENCY":{hd(i,t,E.CETRANSPARENCY);break}case"$CELTSCALE":t.celtscale=ft(i)??1;break;case"$CELWEIGHT":{const n=ft(i);n!=null&&(t.celweight=n);break}case"$LWDISPLAY":t.lwdisplay=(ft(i)??0)!==0;break;case"$TILEMODE":t.tilemode=ft(i)??1;break;case"$PSLTSCALE":t.psltscale=(ft(i)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=ke(i)||tn;break;case"$CMLSCALE":case"CMLSCALE":{const n=ft(i);n!=null&&Number.isFinite(n)&&(t.cmlscale=n);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=ke(i)||en;break;case"$HPLAYER":case"HPLAYER":t.hplayer=ke(i)||".";break;case"$HPTRANSPARENCY":{hd(i,t,E.HPTRANSPARENCY);break}case"$LTSCALE":t.ltscale=ft(i)??1;break;case"$EXTMAX":{const n=ud(i);n&&(t.extmax=n);break}case"$EXTMIN":{const n=ud(i);n&&(t.extmin=n);break}case"$INSUNITS":{const n=ft(i);n!=null&&(t.insunits=n);break}case"$OSMODE":t.osmode=ft(i)??0;break;case"$ORTHOMODE":t.orthomode=ft(i)??0;break;case"$COMPAREHATCH":{const n=ur(ft(i),po,mo);n!=null&&(t.comparehatch=n);break}case"$COMPARERCMARGIN":{const n=ur(ft(i),yo,bo);n!=null&&(t.comparercmargin=n);break}case"$COMPARETEXT":{const n=ur(ft(i),_o,xo);n!=null&&(t.comparetext=n);break}case"$COMPARETOLERANCE":{const n=ur(ft(i),wo,vo);n!=null&&(t.comparetolerance=n);break}case"$PDMODE":t.pdmode=ft(i)??0;break;case"$PDSIZE":t.pdsize=ft(i)??0;break;case"$TEXTSTYLE":t.textstyle=ke(i)||gt;break;case"$DIMSTYLE":t.dimstyle=ke(i)||gt;break;case"$CLAYER":t.clayer=ke(i)||"0";break;case"$HANDSEED":{const n=ke(i);n&&t.initializeHandleSeed(n);break}default:{const n=Ep(i);n.length>0&&t.addDxfHeaderExtra(e,n);break}}}function ac(i){let t;for(const e of Ep(i)){const n=Number(e.code),r=Number(e.value);Number.isFinite(r)&&(n===62||n===70?(t??(t=new X),t.colorIndex=r):n===420&&(t??(t=new X),t.setRGBValue(r)))}return t}function ke(i){const t=i.readItem();if(t){if(Number(t.code)===9||Number(t.code)===0){i.pushBackItem(t);return}return String(t.value)}}function ft(i){const t=i.readItem();if(!t)return;if(Number(t.code)===9||Number(t.code)===0){i.pushBackItem(t);return}const e=Number(t.value);return Number.isFinite(e)?e:void 0}function hd(i,t,e){const n=i.readItem();if(!n||Number(n.code)===9||Number(n.code)===0){n&&i.pushBackItem(n),wt.instance().setVar(e,"ByLayer",t);return}const r=Number(n.code),s=String(n.value).trim();if(s===""){wt.instance().setVar(e,"ByLayer",t);return}if(r===440){const a=Number(s);wt.instance().setVar(e,Number.isFinite(a)?a:"ByLayer",t);return}wt.instance().setVar(e,s,t)}function ud(i){let t=0,e=0,n=0,r=!1;for(;!i.atEof;){const s=i.peekItem();if(!s)break;const a=Number(s.code);if(a===9||a===0)break;i.readItem();const o=Number(s.value);a===10?(t=o,r=!0):a===20?(e=o,r=!0):a===30&&(n=o,r=!0)}return r?new x(t,e,n):void 0}function Ep(i){const t=[];for(;!i.atEof;){const e=i.peekItem();if(!e)break;const n=Number(e.code);if(n===9||n===0)break;i.readItem(),t.push(e)}return t}class Tp{constructor(t){this._expression=t}get expression(){return this._expression}}var Lp=(i=>(i[i.Cancel=0]="Cancel",i[i.Ok=1]="Ok",i))(Lp||{});class To{constructor(){this._name="",this._filterExpression="",this._nestedFilters=[],this._parent=null,this._allowDelete=!0,this._allowRename=!0,this._dynamicallyGenerated=!1,this._isProxy=!1}get name(){return this._name}setName(t){return!this.allowRename()&&this._name.length>0?!1:(this._name=t,!0)}set name(t){this.setName(t)}get filterExpression(){return this._filterExpression}setFilterExpression(t){return this.isIdFilter()?!1:(this._filterExpression=t??"",!0)}set filterExpression(t){this.setFilterExpression(t)}filterExpressionTree(){return this.isIdFilter()||!this._filterExpression?null:new Tp(this._filterExpression)}getNestedFilters(){return this._nestedFilters}get nestedFilters(){return this._nestedFilters}parent(){return this._parent}isIdFilter(){return!1}allowNested(){return!0}allowDelete(){return this._allowDelete}setAllowDelete(t){this._allowDelete=t}allowRename(){return this._allowRename}setAllowRename(t){this._allowRename=t}dynamicallyGenerated(){return this._dynamicallyGenerated}setDynamicallyGenerated(t){this._dynamicallyGenerated=t}isProxy(){return this._isProxy}setIsProxy(t){this._isProxy=t}addNested(t){return!t||t===this||!this.allowNested()||!(this._parent==null)&&!this.isIdFilter()&&t.isIdFilter()||this._nestedFilters.includes(t)?!1:(t._parent&&t._parent.removeNested(t),t._parent=this,this._nestedFilters.push(t),!0)}removeNested(t){const e=this._nestedFilters.indexOf(t);return e<0?!1:(this._nestedFilters.splice(e,1),t._parent===this&&(t._parent=null),!0)}generateNested(){return!1}compareTo(t){return t?this.isIdFilter()===t.isIdFilter()&&this._name===t._name&&this._filterExpression===t._filterExpression:!1}filter(t){return t?this._filterExpression?ww(this._filterExpression,t):!0:!1}showEditor(){return 0}}function ww(i,t){const e=i.trim();return e?dd(e,"OR").some(r=>dd(r,"AND").every(a=>vw(a,t))):!0}function dd(i,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return i.split(e).map(n=>n.trim()).filter(n=>n.length>0)}function vw(i,t){var a;const e=i.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const n=e[1].toUpperCase(),r=e[3],s=Sw(r);switch(n){case"NAME":return Aw(t.name,r);case"LOCKED":return s!=null?t.isLocked===s:!1;case"FROZEN":return s!=null?t.isFrozen===s:!1;case"OFF":return s!=null?t.isOff===s:!1;case"PLOT":return s!=null?t.isPlottable===s:!1;case"COLOR":{const o=(a=t.color)==null?void 0:a.colorIndex;return o!=null&&String(o)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function Aw(i,t){return/[*?]/.test(t)?new RegExp(`^${t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`,"i").test(i):i.localeCompare(t,void 0,{sensitivity:"accent"})===0}function Sw(i){const t=i.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class rn{constructor(t,e){this._root=t??rn.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new To;return t.setName("All"),t.setAllowDelete(!1),t.setAllowRename(!1),t.setFilterExpression(""),t}get root(){return this._root}get current(){return this._current}set current(t){this._current=t}clone(){return new rn(this._root,this._current)}}class Mp extends To{constructor(){super(),this._layerIds=[]}isIdFilter(){return!0}layerIds(){return this._layerIds}get layerIdList(){return this._layerIds}addLayerId(t){return!t||this._layerIds.includes(t)?!1:(this._layerIds.push(t),!0)}removeLayerId(t){const e=this._layerIds.indexOf(t);return e<0?!1:(this._layerIds.splice(e,1),!0)}filter(t){return t?this._layerIds.includes(t.objectId):!1}setFilterExpression(t){return!1}}const Wr="ACAD_LAYERFILTERS",zn="ACLYDICTIONARY";function Cp(i){const t=rn.createDefaultRoot(),e=new rn(t,t),n=gd(i,zn),r=gd(i,Wr);if(n){for(const[s,a]of Object.entries(n.entries)){const o=Wc(i,a,s);o&&t.addNested(o)}return e}if(r)for(const[s,a]of Object.entries(r.entries)){const o=Wc(i,a,s);o&&t.addNested(o)}return e}function Op(i){const t=[];for(const e of i.root.getNestedFilters())t.push(Rp(e));return{nodes:t}}function Dp(i){const t=new Xe;for(const e of i)t.add({code:e.code,value:e.value});return t}function Pw(i){return i?i.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function gd(i,t){let e;for(const n of i.dictionaries.values()){const r=n.entries[t];if(!r)continue;const s=i.dictionaries.get(Ke(r));if(!s)continue;if(!(n.ownerObjectId?i.xrecords.has(Ke(n.ownerObjectId)):!1))return s;e=s}return e}function Wc(i,t,e){const n=i.xrecords.get(Ke(t));if(!n)return;const r=Np(n.data,e),s=r.isIdFilter?new Mp:new To;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const a=s;for(const o of r.layerIds)a.addLayerId(o)}for(const a of kw(i,n)){const o=Wc(i,a.handle,a.key);o&&s.addNested(o)}return s}function kw(i,t){const e=[],n=new Set,r=Ke(t.handle),s=t.extensionDictionaryId?Ke(t.extensionDictionaryId):void 0,a=(o,c)=>{const l=Ke(c);n.has(l)||(n.add(l),e.push({key:o,handle:c}))};for(const o of i.dictionaries.values()){const c=o.ownerObjectId?Ke(o.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=o.entries[zn];if(h){const u=i.dictionaries.get(Ke(h));if(u){for(const[d,g]of Object.entries(u.entries))a(d,g);continue}}for(const[u,d]of Object.entries(o.entries))u===zn||u===Wr||a(u,d)}return e}function Np(i,t=""){const e=[],n=[];let r=0,s,a,o;for(const f of i){const p=Number(f.code),m=f.value;p===1&&typeof m=="string"?e.push(m):p===300&&typeof m=="string"?a=m:p===301&&typeof m=="string"?o=m:p===70||p===90?r=Number(m)||0:p===290||p===280?s=Number(m)===1:(p===330||p===340||p===350||p===360)&&m!=null&&String(m).length>0&&n.push(Ke(String(m)))}const c=e[0],h=a||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=o??u;!o&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=o!=null&&o.length>0?!1:s===!0&&n.length>0?!0:n.length>0&&(d.length===0||d==="*");return{name:h,filterExpression:g?"":d,flags:r,layerIds:n,isIdFilter:g}}function Rp(i){const t=i.isIdFilter(),e=Bp(i),n=i.getNestedFilters().map(s=>Rp(s));return{key:i.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:n}}function Bp(i){const t=[];if(t.push({code:1,value:i.name}),i.isIdFilter()){t.push({code:1,value:""}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:1});const e=i;for(const n of e.layerIds())t.push({code:330,value:n})}else t.push({code:1,value:i.filterExpression||"*"}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:0});return t}function Ke(i){return i.trim().toUpperCase()}class xr extends pt{constructor(){super(...arguments),this._schema=0,this._value=""}get schema(){return this._schema}set schema(t){this._schema=t}get value(){return this._value}set value(t){this._value=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("DictionaryVariables"),t.writeInt16(280,this._schema),t.writeString(1,this._value),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("DictionaryVariables")||t.atSubclassData("AcDbDictionaryVar");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 280:this._schema=Number(e.value);break;case 1:this._value=String(e.value);break}}return this}}class Pi extends pt{constructor(t="",e=!0){super(),this._name="",this._description="",this._anonymous=!1,this._selectable=!0,this._entityIds=[],this.description=t,this.selectable=e}get name(){return this._name}set name(t){this._name=t}get description(){return this._description}set description(t){this._description=String(t??"")}get unnamed(){return this._anonymous}set unnamed(t){this._anonymous=t}get anonymous(){return this._anonymous}set anonymous(t){this._anonymous=t}get selectable(){return this._selectable}set selectable(t){this._selectable=t}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this.append(t)}isAnonymous(){return this._anonymous}setAnonymous(){this._anonymous=!0}isNotAccessible(){return!1}setName(t){var a;const e=String(t??""),n=(a=this.database)==null?void 0:a.objects.group;if(!n){this._name=e;return}let r;if(this._name&&n.getAt(this._name)===this)r=this._name;else for(const[o,c]of n.entries())if(c===this){r=o;break}if(r===e){this._name=e;return}const s=e?n.getAt(e):void 0;s&&s!==this||(r!=null&&r!==e&&(n.remove(r),e&&n.setAt(e,this)),this._name=e)}numEntities(){return this._entityIds.length}allEntityIds(t){return t&&(t.length=0,t.push(...this._entityIds)),this._entityIds.length}has(t){const e=typeof t=="string"?t:t.objectId??"";return e?this._entityIds.includes(e):!1}getIndex(t){return this._entityIds.indexOf(t)}newIterator(){return new Hn(this._entityIds)}append(t){const e=Array.isArray(t)?t:[t];for(const n of e)!n||this._entityIds.includes(n)||this._entityIds.push(n)}prepend(t){const e=Array.isArray(t)?t:[t];for(let n=e.length-1;n>=0;n--){const r=e[n];!r||this._entityIds.includes(r)||this._entityIds.unshift(r)}}insertAt(t,e){const n=(Array.isArray(e)?e:[e]).filter(s=>!!s&&!this._entityIds.includes(s));if(n.length===0)return;const r=Math.max(0,Math.min(this._entityIds.length,Math.trunc(t)));this._entityIds.splice(r,0,...n)}remove(t){const e=new Set((Array.isArray(t)?t:[t]).filter(Boolean));e.size!==0&&(this._entityIds=this._entityIds.filter(n=>!e.has(n)))}removeAt(t,e){const n=Math.trunc(t);if(!(n<0||n>=this._entityIds.length)){if(e&&e.length>0){const r=new Set(e.filter(Boolean));this._entityIds=this._entityIds.filter((s,a)=>a<n?!0:!r.has(s));return}this._entityIds.splice(n,1)}}replace(t,e){if(!t||!e||t===e)return;const n=this._entityIds.indexOf(t);if(!(n<0)){if(this._entityIds.includes(e)){this._entityIds.splice(n,1);return}this._entityIds[n]=e}}transfer(t,e,n){const r=Math.trunc(t),s=Math.trunc(e),a=Math.trunc(n);if(a<=0||r<0||r>=this._entityIds.length)return;const o=this._entityIds.splice(r,a);let c=s;s>r&&(c=Math.max(0,s-o.length)),c=Math.max(0,Math.min(this._entityIds.length,c)),this._entityIds.splice(c,0,...o)}reverse(){this._entityIds.reverse()}clear(){this._entityIds=[]}setColor(t){for(const e of this.memberEntities())e.color=t.clone()}setColorIndex(t){const e=new X;e.colorIndex=t,this.setColor(e)}setLayer(t){const e=this.resolveLayerName(t);if(e)for(const n of this.memberEntities())n.layer=e}setLinetype(t){const e=this.resolveLinetypeName(t);if(e)for(const n of this.memberEntities())n.lineType=e}setLinetypeScale(t){for(const e of this.memberEntities())e.linetypeScale=t}setMaterial(t){}setVisibility(t){for(const e of this.memberEntities())e.visibility=t}setHighlight(t){}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbGroup"),this._description&&t.writeString(300,this._description),t.writeInt16(70,this._anonymous?1:0),t.writeInt16(71,this._selectable?1:0);for(const e of this._entityIds)t.writeObjectId(340,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbGroup"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 300:this.description=e.value;break;case 70:this.anonymous=Number(e.value)!==0;break;case 71:this.selectable=Number(e.value)!==0;break;case 340:this._entityIds.push(String(e.value));break}}return this}memberEntities(){const t=this.database;if(!t)return[];const e=[];for(const n of this._entityIds){const r=t.getObjectById(n);r instanceof et&&e.push(r)}return e}resolveLayerName(t){const e=this.database;if(!e)return String(t??"");const n=e.getObjectById(t);return n&&"name"in n&&typeof n.name=="string"?n.name:String(t??"")}resolveLinetypeName(t){const e=this.database;if(!e)return String(t??"");const n=e.getObjectById(t);return n&&"name"in n&&typeof n.name=="string"?n.name:String(t??"")}}class Fp extends pt{constructor(){super(),this._boundaryVertices=[],this._clipBoundaryDisplayEnabled=!1,this._frontClippingEnabled=!1,this._backClippingEnabled=!1}get boundaryVertices(){return this._boundaryVertices}set boundaryVertices(t){this._boundaryVertices=t.map(e=>e.clone())}get clipBoundaryNormal(){return this._clipBoundaryNormal}set clipBoundaryNormal(t){this._clipBoundaryNormal=t==null?void 0:t.clone()}get clipBoundaryOrigin(){return this._clipBoundaryOrigin}set clipBoundaryOrigin(t){this._clipBoundaryOrigin=t==null?void 0:t.clone()}get clipBoundaryDisplayEnabled(){return this._clipBoundaryDisplayEnabled}set clipBoundaryDisplayEnabled(t){this._clipBoundaryDisplayEnabled=t}get frontClippingEnabled(){return this._frontClippingEnabled}set frontClippingEnabled(t){this._frontClippingEnabled=t}get frontClippingDistance(){return this._frontClippingDistance}set frontClippingDistance(t){this._frontClippingDistance=t}get backClippingEnabled(){return this._backClippingEnabled}set backClippingEnabled(t){this._backClippingEnabled=t}get backClippingDistance(){return this._backClippingDistance}set backClippingDistance(t){this._backClippingDistance=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFilter"),this._boundaryVertices.length>0&&(t.writeInt16(70,this._boundaryVertices.length),this._boundaryVertices.forEach(e=>t.writePoint2d(10,e)),t.writeVector3d(210,this._clipBoundaryNormal),t.writePoint3d(11,this._clipBoundaryOrigin),t.writeInt16(71,this._clipBoundaryDisplayEnabled?1:0),t.writeInt16(72,this._frontClippingEnabled?1:0),this._frontClippingEnabled&&this._frontClippingDistance!=null&&t.writeDouble(40,this._frontClippingDistance),t.writeInt16(73,this._backClippingEnabled?1:0),this._backClippingEnabled&&this._backClippingDistance!=null&&t.writeDouble(41,this._backClippingDistance)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFilter");let e=null,n=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===100){t.pushBackItem(r);break}const a=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new C(e.x,e.y)),e={x:a,y:0};break;case 20:e&&(e.y=a);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new x,this._clipBoundaryNormal.x=a;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=a);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=a);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new x,this._clipBoundaryOrigin.x=a;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=a);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=a);break;case 71:this._clipBoundaryDisplayEnabled=a!==0;break;case 72:this._frontClippingEnabled=a!==0;break;case 73:this._backClippingEnabled=a!==0;break;case 40:n||(this._frontClippingDistance=a,n=!0);break;case 41:this._backClippingDistance=a;break}}return e&&this._boundaryVertices.push(new C(e.x,e.y)),this}}class ch extends Fp{constructor(){super(),this._layerNames=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}add(t){const e=t==null?void 0:t.trim();return!e||this._layerNames.includes(e)?!1:(this._layerNames.push(e),!0)}getAt(t){if(t<0||t>=this._layerNames.length)throw new Error("The layer index is out of range!");return this._layerNames[t]}remove(t){const e=this._layerNames.indexOf(t);return e<0?!1:(this._layerNames.splice(e,1),!0)}layerCount(){return this._layerNames.length}indexClass(){return"AcDbLayerIndex"}isValid(){return this._layerNames.some(t=>t.length>0)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerFilter");for(const e of this._layerNames)t.writeString(8,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayerFilter");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 8:this.add(String(e.value));break;case 100:return t.pushBackItem(e),this}}return this}}class zp extends pt{constructor(){super(),this._lastUpdatedAt=0,this._lastUpdatedAtU=0,this._isUptoDate=!1,this._objectBeingIndexedId=""}get lastUpdatedAt(){return this._lastUpdatedAt}set lastUpdatedAt(t){this._lastUpdatedAt=t}get lastUpdatedAtU(){return this._lastUpdatedAtU}set lastUpdatedAtU(t){this._lastUpdatedAtU=t}get isUptoDate(){return this._isUptoDate}set isUptoDate(t){this._isUptoDate=t}objectBeingIndexedId(){return this._objectBeingIndexedId}setObjectBeingIndexedId(t){this._objectBeingIndexedId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbIndex"),t.writeDouble(40,this.lastUpdatedAt),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbIndex");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 40:this.lastUpdatedAt=Number(e.value),this.lastUpdatedAtU=this.lastUpdatedAt;break;case 100:return t.pushBackItem(e),this}}return this}}class lh extends zp{constructor(){super(),this._layerNames=[],this._idBufferIds=[],this._idBufferEntryCounts=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}get idBufferIds(){return this._idBufferIds}set idBufferIds(t){this._idBufferIds=[...t]}get idBufferEntryCounts(){return this._idBufferEntryCounts}set idBufferEntryCounts(t){this._idBufferEntryCounts=[...t]}get entries(){const t=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length),e=[];for(let n=0;n<t;n++)e.push({layerName:this._layerNames[n]??"",idBufferId:this._idBufferIds[n]??"",idBufferEntryCount:this._idBufferEntryCounts[n]??0});return e}set entries(t){this._layerNames=t.map(e=>e.layerName),this._idBufferIds=t.map(e=>e.idBufferId),this._idBufferEntryCounts=t.map(e=>e.idBufferEntryCount)}compute(t,e){if(e&&this.setObjectBeingIndexedId(e.objectId),t){this._layerNames=[];for(const n of t.newIterator())this._layerNames.push(n.name)}return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}newIterator(t){return null}rebuildFull(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}rebuildModified(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerIndex");const e=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length);for(let n=0;n<e;n++)this._layerNames[n]!=null&&t.writeString(8,this._layerNames[n]),this._idBufferIds[n]&&t.writeHandle(360,this._idBufferIds[n]),this._idBufferEntryCounts[n]!=null&&t.writeInt32(90,this._idBufferEntryCounts[n]);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLayerIndex");const e=[],n=[],r=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;switch(Number(s.code)){case 8:e.push(String(s.value));break;case 360:n.push(String(s.value));break;case 90:r.push(Number(s.value));break;case 100:return t.pushBackItem(s),this.layerNames=e,this.idBufferIds=n,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}return this.layerNames=e,this.idBufferIds=n,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}class us extends pt{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new X(exports.AcCmColorMethod.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new X(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new X(exports.AcCmColorMethod.ByBlock),this._blockScale=new A(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(t){this._unknown1=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(t){this._drawMLeaderOrderType=t}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(t){this._drawLeaderOrderType=t}get bitFlags(){return this._bitFlags}set bitFlags(t){this._bitFlags=t}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(t){this._maxLeaderSegmentsPoints=t}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(t){this.maxLeaderSegmentsPoints=t}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(t){this._firstSegmentAngleConstraint=t}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(t){this._secondSegmentAngleConstraint=t}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor.copy(t)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get enableLanding(){return this._enableLanding}set enableLanding(t){this._enableLanding=t}get landingEnabled(){return this.enableLanding}set landingEnabled(t){this.enableLanding=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get enableDogleg(){return this._enableDogleg}set enableDogleg(t){this._enableDogleg=t}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(t){this.enableDogleg=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get description(){return this._description}set description(t){this._description=t}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(t){this._arrowSymbolId=t}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(t){this.arrowSymbolId=t}get arrowSize(){return this._arrowSize}set arrowSize(t){this._arrowSize=t}get arrowheadSize(){return this.arrowSize}set arrowheadSize(t){this.arrowSize=t}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(t){this._defaultMTextContents=t}get defaultMText(){return this.defaultMTextContents}set defaultMText(t){this.defaultMTextContents=t}get textString(){return this.defaultMTextContents}set textString(t){this.defaultMTextContents=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textStyle(){return this.textStyleId}set textStyle(t){this.textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor.copy(t)}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get enableFrameText(){return this._enableFrameText}set enableFrameText(t){this._enableFrameText=t}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(t){this.enableFrameText=t}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(t){this._textAlignAlwaysLeft=t}get alignSpace(){return this._alignSpace}set alignSpace(t){this._alignSpace=t}get blockId(){return this._blockId}set blockId(t){this._blockId=t}get blockContentId(){return this.blockId}set blockContentId(t){this.blockId=t}get blockColor(){return this._blockColor}set blockColor(t){this._blockColor.copy(t)}get blockContentColor(){return this.blockColor}set blockContentColor(t){this.blockColor=t}get blockScale(){return this._blockScale.clone()}set blockScale(t){this._blockScale.copy(t)}get blockContentScale(){return this.blockScale}set blockContentScale(t){this.blockScale=t}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(t){this._enableBlockScale=t}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(t){this.enableBlockScale=t}get blockRotation(){return this._blockRotation}set blockRotation(t){this._blockRotation=t}get blockContentRotation(){return this.blockRotation}set blockContentRotation(t){this.blockRotation=t}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(t){this._enableBlockRotation=t}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(t){this.enableBlockRotation=t}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(t){this._blockConnectionType=t}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(t){this.blockConnectionType=t}get scale(){return this._scale}set scale(t){this._scale=t}get scaleFactor(){return this.scale}set scaleFactor(t){this.scale=t}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(t){this._overwritePropChanged=t}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(t){this.overwritePropChanged=t}get annotative(){return this._annotative}set annotative(t){this._annotative=t}get breakSize(){return this._breakSize}set breakSize(t){this._breakSize=t}get breakGapSize(){return this.breakSize}set breakGapSize(t){this.breakSize=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(t){this._bottomTextAttachmentType=t}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(t){this.bottomTextAttachmentType=t}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(t){this._topTextAttachmentType=t}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(t){this.topTextAttachmentType=t}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(t){this._extendLeaderToText=t}get unknown2(){return this._unknown2}set unknown2(t){this._unknown2=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeaderStyle"),t.writeInt16(179,this.unknown1),t.writeInt16(170,this.contentType),t.writeInt16(171,this.drawMLeaderOrderType),t.writeInt16(172,this.drawLeaderOrderType),t.writeInt32(90,this.maxLeaderSegmentsPoints),t.writeDouble(40,this.firstSegmentAngleConstraint),t.writeDouble(41,this.secondSegmentAngleConstraint),t.writeInt16(173,this.leaderLineType),t.writeInt32(91,ic(this.leaderLineColor)),t.writeHandle(340,this.leaderLineTypeId),t.writeInt32(92,this.leaderLineWeight),t.writeBoolean(290,this.enableLanding),t.writeDouble(42,this.landingGap),t.writeBoolean(291,this.enableDogleg),t.writeDouble(43,this.doglegLength),t.writeString(3,this.description),t.writeHandle(341,this.arrowSymbolId),t.writeDouble(44,this.arrowSize),t.writeString(300,this.defaultMTextContents),t.writeHandle(342,this.textStyleId),t.writeInt16(174,this.textLeftAttachmentType),t.writeInt16(175,this.textAngleType),t.writeInt16(176,this.textAlignmentType),t.writeInt16(178,this.textRightAttachmentType),t.writeInt32(93,ic(this.textColor)),t.writeDouble(45,this.textHeight),t.writeBoolean(292,this.enableFrameText),t.writeBoolean(297,this.textAlignAlwaysLeft),t.writeDouble(46,this.alignSpace),t.writeHandle(343,this.blockId),t.writeInt32(94,ic(this.blockColor)),t.writeDouble(47,this._blockScale.x),t.writeDouble(49,this._blockScale.y),t.writeDouble(140,this._blockScale.z),t.writeBoolean(293,this.enableBlockScale),t.writeDouble(141,this.blockRotation),t.writeBoolean(294,this.enableBlockRotation),t.writeInt16(177,this.blockConnectionType),t.writeDouble(142,this.scale),t.writeBoolean(295,this.overwritePropChanged),t.writeBoolean(296,this.annotative),t.writeDouble(143,this.breakSize),t.writeInt16(271,this.textAttachmentDirection),t.writeInt16(272,this.bottomTextAttachmentType),t.writeInt16(273,this.topTextAttachmentType),t.writeBoolean(298,this.unknown2),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbMLeaderStyle");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code),r=Number(e.value);switch(n){case 179:this.unknown1=r;break;case 170:this.contentType=r;break;case 171:this.drawMLeaderOrderType=r;break;case 172:this.drawLeaderOrderType=r;break;case 90:this.maxLeaderSegmentsPoints=r;break;case 40:this.firstSegmentAngleConstraint=r;break;case 41:this.secondSegmentAngleConstraint=r;break;case 173:this.leaderLineType=r;break;case 91:this.leaderLineColor=Yt(r);break;case 340:this.leaderLineTypeId=String(e.value);break;case 92:this.leaderLineWeight=r;break;case 290:this.enableLanding=r!==0;break;case 42:this.landingGap=r;break;case 291:this.enableDogleg=r!==0;break;case 43:this.doglegLength=r;break;case 3:this.description=String(e.value);break;case 341:this.arrowSymbolId=String(e.value);break;case 44:this.arrowSize=r;break;case 300:this.defaultMTextContents=String(e.value);break;case 342:this.textStyleId=String(e.value);break;case 174:this.textLeftAttachmentType=r;break;case 175:this.textAngleType=r;break;case 176:this.textAlignmentType=r;break;case 178:this.textRightAttachmentType=r;break;case 93:this.textColor=Yt(r);break;case 45:this.textHeight=r;break;case 292:this.enableFrameText=r!==0;break;case 297:this.textAlignAlwaysLeft=r!==0;break;case 46:this.alignSpace=r;break;case 343:this.blockId=String(e.value);break;case 94:this.blockColor=Yt(r);break;case 47:this._blockScale.x=r;break;case 49:this._blockScale.y=r;break;case 140:this._blockScale.z=r;break;case 293:this.enableBlockScale=r!==0;break;case 141:this.blockRotation=r;break;case 294:this.enableBlockRotation=r!==0;break;case 177:this.blockConnectionType=r;break;case 142:this.scale=r;break;case 295:this.overwritePropChanged=r!==0;break;case 296:this.annotative=r!==0;break;case 143:this.breakSize=r;break;case 271:this.textAttachmentDirection=r;break;case 272:this.bottomTextAttachmentType=r;break;case 273:this.topTextAttachmentType=r;break;case 298:this.unknown2=r!==0;break;case 100:return t.pushBackItem(e),this}}return this}}class Lo extends pt{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new X,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get flags(){return this._flags}set flags(t){this._flags=t}get description(){return this._description}set description(t){this._description=t}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor.copy(t)}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get elementCount(){return this._elements.length}get elements(){return this._elements.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}set elements(t){this._elements=t.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}addElement(t){this._elements.push({offset:t.offset,color:t.color.clone(),lineType:t.lineType})}removeElementAt(t){if(t<0||t>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(t,1)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMlineStyle"),t.writeString(2,this.styleName),t.writeInt16(70,this.flags),t.writeString(3,this.description),t.writeCmColor(this.fillColor),t.writeDouble(51,this.startAngle),t.writeDouble(52,this.endAngle),t.writeInt16(71,this.elementCount),this._elements.forEach(e=>{t.writeDouble(49,e.offset),t.writeCmColor(e.color),t.writeString(6,e.lineType)}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMlineStyle");const e=[];let n,r=0;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 2:this.styleName=String(s.value);break;case 70:this.flags=o;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=o;break;case 52:this.endAngle=o;break;case 71:r=o;break;case 49:{n={offset:o,color:new X,lineType:"BYLAYER"},n.color.colorIndex=256,e.push(n);break}case 62:n?n.color.colorIndex=o:this.fillColor.colorIndex=o;break;case 420:n?n.color.setRGBValue(o):this.fillColor.setRGBValue(o);break;case 6:n&&(n.lineType=String(s.value));break;case 100:return t.pushBackItem(s),this.finishMlineElements(e,r),this}}return this.finishMlineElements(e,r),this}finishMlineElements(t,e){const n=Math.max(e,t.length);if(n<=0){this.elements=[];return}this.elements=Array.from({length:n},(r,s)=>{const a=t[s];if(a)return a;const o=new X;return o.colorIndex=256,{offset:0,color:o,lineType:"BYLAYER"}})}}class hh extends pt{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new C,this._pixelSize=new C(1,1)}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}get classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize.copy(t)}get isLoaded(){return this._isLoaded}set isLoaded(t){this._isLoaded=t}get resolutionUnits(){return this._resolutionUnits}set resolutionUnits(t){this._resolutionUnits=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeInt32(90,this.classVersion),t.writeString(1,this.sourceFileName),t.writePoint2d(10,this.imageSize),t.writeDouble(11,this.pixelSize.x),t.writeDouble(12,this.pixelSize.y),t.writeInt16(280,this.isLoaded?1:0),t.writeInt16(281,this.resolutionUnits),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbRasterImageDef");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code),r=Number(e.value);switch(n){case 1:this.sourceFileName=String(e.value);break;case 90:this.classVersion=r;break;case 10:this.imageSize.x=r;break;case 20:this.imageSize.y=r;break;case 11:this.pixelSize.x=r;break;case 12:this.pixelSize.y=r;break;case 280:this.isLoaded=r!==0;break;case 281:this.resolutionUnits=r;break;case 100:return t.pushBackItem(e),this}}return this}}class uh extends pt{constructor(){super(...arguments),this._entityIds=[]}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbSortentsTable");for(const e of this._entityIds)t.writeObjectId(331,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSortentsTable"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const n=Number(e.code);if(n===100){t.pushBackItem(e);break}switch(n){case 331:this._entityIds.push(String(e.value));break}}return this}}class Xp extends pt{constructor(t=""){super(),this._rawTags={header:[],body:[]},this._dxfTypeName=t.toUpperCase()}get dxfTypeName(){return this._dxfTypeName}get rawTags(){return this._rawTags}dxfIn(t){const{tags:e,handle:n,ownerId:r,extensionDictionary:s}=Rf(t);return this._rawTags=e,n&&(this.objectId=n),r&&(this.ownerId=r),s&&(this.extensionDictionary=s),t.atExtendedData&&this.dxfInXData(t),this}dxfOut(...t){const[e,n=!1]=t;return Gl(e,this._rawTags,this),n&&this.dxfOutXData(e),this}}const at=i=>i?i.trim().toUpperCase():"";class Yp{constructor(t){this._db=t,this._dictionaries=new Map,this._xrecords=new Map,this._unknownObjectCount=0,this._unknownObjects=[]}get unknownObjectCount(){return this._unknownObjectCount}read(t){for(this._unknownObjectCount=0,this._unknownObjects.length=0;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"){t.readItem();break}t.readItem(),this.readObject(t,n)}this.finishNamedObjectDictionaries(),this.materializeBufferedDictionaries(),this.finishCannoscale(),this.finishAnnoallvisible(),this.finishLayerFilterTree(),this.linkLayoutsToBlockTableRecords(),this._db.objects.layout.numEntries===0&&this._db.createDefaultData({layout:!0})}readObject(t,e){switch(e){case"LAYOUT":{const n=new In;n.dxfIn(t),n.layoutName&&this._db.objects.layout.setAt(n.layoutName,n);break}case"IMAGEDEF":{const n=new hh;n.dxfIn(t),this._db.objects.imageDefinition.setAt(n.objectId,n);break}case"LAYER_FILTER":{const n=new ch;n.dxfIn(t),this._db.objects.layerFilter.setAt(n.objectId,n);break}case"LAYER_INDEX":{const n=new lh;n.dxfIn(t),this._db.objects.layerIndex.setAt(n.objectId,n);break}case"MLEADERSTYLE":{const n=new us;n.dxfIn(t),this._db.objects.mleaderStyle.setAt(n.objectId,n);break}case"MLINESTYLE":{const n=new Lo;n.dxfIn(t),this._db.objects.mlineStyle.setAt(n.styleName||n.objectId,n);break}case"GROUP":{const n=new Pi;n.dxfIn(t);const r=n.objectId||n.description;this._db.objects.group.setAt(r,n);break}case"SORTENTSTABLE":{const n=new uh;n.dxfIn(t),this._db.objects.sortentsTable.setAt(n.objectId,n);break}case"DICTIONARY":case"ACDBDICTIONARYWDFLT":{const n=this.readPersistDictionary(t,e);n.handle&&this._dictionaries.set(at(n.handle),n);break}case"SCALE":{const n=new Pn;n.dxfIn(t);const r=n.scaleName||at(n.objectId);r&&this._db.objects.scale.setAt(r,n);break}case"DICTIONARYVAR":{const n=new xr;n.dxfIn(t);const r=at(n.objectId);r&&this._db.objects.dictionaryVar.setAt(r,n);break}case"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Ue,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_TEXTOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new tr,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_ALDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ANGDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ARCDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_DMDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_ORDDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADDIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADIMOBJECTCONTEXTDATA_CLASS":case"ACDB_RADDIMLGCOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Br,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_HATCHSCALECONTEXTDATA_CLASS":{const n=this.readContextData(t,new Fi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_BLKREFOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Bi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_LEADEROBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new So,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_MLEADEROBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new zi,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS":{const n=this.readContextData(t,new Fr,e),r=at(n.objectId);r&&this._db.objects.objectContextData.setAt(r,n);break}case"XRECORD":{const n=new os;n.dxfIn(t);const r=at(n.objectId);if(r){this._db.objects.xrecord.setAt(r,n);const s={handle:r,ownerObjectId:at(n.ownerId),data:n.data?n.data.toArray().map(a=>({code:Number(a.code),value:a.value})):[]};n.extensionDictionary&&(s.extensionDictionaryId=at(n.extensionDictionary)),this._xrecords.set(r,s)}break}default:{this._unknownObjectCount+=1;const n=new Xp(e);n.dxfIn(t),n.objectId&&(n.database=this._db,this._db.registerObjectHandle(n),this._db.addDxfUnknownObject(n),this._unknownObjects.push(n));break}}}readContextData(t,e,n){const r=Hl(t);for(;!t.atEndOfObject&&!t.atEof;){const a=t.readItem();if(!a)break;r.push(as(a))}const s=ve.forReading(new Ao(r),{database:t.database});return e.dxfIn(s),e.dxfRecordName=n,e.setDxfRawTags(Bf(r).tags),e}finishNamedObjectDictionaries(){if(this._dictionaries.size===0)return;let t;for(const s of this._dictionaries.values())if(!s.ownerObjectId||s.ownerObjectId==="0"){t=s;break}if(!(t!=null&&t.handle))return;const e=this._db.objects.dictionary;this.adoptDxfHandle(e,t.handle),e.ownerId="0";const n={ACAD_LAYOUT:this._db.objects.layout,ACAD_GROUP:this._db.objects.group,ACAD_SORTENTS:this._db.objects.sortentsTable,ACAD_MLEADERSTYLE:this._db.objects.mleaderStyle,ACAD_MLINESTYLE:this._db.objects.mlineStyle,ACAD_SCALELIST:this._db.objects.scale,ISM_RASTER_IMAGE_DICT:this._db.objects.imageDefinition,MLIGHT_XRECORD:this._db.objects.xrecord},r=this.collectLoadedObjectsByHandle();for(const[s,a]of Object.entries(t.entries)){const o=n[s.toUpperCase()];if(!o)continue;this.adoptDxfHandle(o,a),o.ownerId=t.handle,e.setAt(s,o);const c=this._dictionaries.get(at(a));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(at(h));if(!u)continue;const d=at(u.objectId);let g;for(const[f,p]of o.entries())if(at(p.objectId)===d){g=f;break}if(o===this._db.objects.mleaderStyle&&g!=null&&g!==l&&at(g)===d&&!o.getAt(l)){o.remove(g),o.setAt(l,u);continue}if(o===this._db.objects.group&&u instanceof Pi&&g!=null&&g!==l&&!o.getAt(l)){o.remove(g),o.setAt(l,u),u.name=l;continue}if(o===this._db.objects.group&&u instanceof Pi&&g==null){o.setAt(l,u),u.name=l;continue}!o.getAt(l)&&g==null&&o.setAt(l,u)}}}adoptDxfHandle(t,e){if(at(t.objectId)===at(e))return;const n=this._db.getObjectById(e);if(n&&n!==t){const s=this._db.generateUniqueHandle();if(this._db.releaseObjectHandle(n),n.objectId=s,this._db.registerObjectHandle(n),n instanceof G)for(const[,a]of n.entries())a.ownerId===e&&(a.ownerId=s)}const r=t.objectId;this._db.releaseObjectHandle(t),t.objectId=e,this._db.registerObjectHandle(t);for(const[,s]of t.entries())s.ownerId===r&&(s.ownerId=e)}collectLoadedObjectsByHandle(){const t=new Map,e=n=>{const r=at(n.objectId);r&&t.set(r,n)};for(const[,n]of this._db.objects.layout.entries())e(n);for(const[,n]of this._db.objects.group.entries())e(n);for(const[,n]of this._db.objects.sortentsTable.entries())e(n);for(const[,n]of this._db.objects.imageDefinition.entries())e(n);for(const[,n]of this._db.objects.mleaderStyle.entries())e(n);for(const[,n]of this._db.objects.mlineStyle.entries())e(n);for(const[,n]of this._db.objects.layerFilter.entries())e(n);for(const[,n]of this._db.objects.layerIndex.entries())e(n);for(const[,n]of this._db.objects.xrecord.entries())e(n);for(const[,n]of this._db.objects.scale.entries())e(n);for(const[,n]of this._db.objects.dictionaryVar.entries())e(n);for(const[,n]of this._db.objects.objectContextData.entries())e(n);for(const n of this._unknownObjects)e(n);return t}materializeBufferedDictionaries(){if(this._dictionaries.size===0)return;const t=new Map;for(const a of this._db.getRootDictionaries()){const o=at(a.objectId);o&&(t.set(o,a),this._db.registerObjectHandle(a))}const e=new Map;for(const[a,o]of this._dictionaries){const c=this._db.getObjectById(a)??t.get(a);if(c instanceof G){e.set(a,c);continue}const l=new G(this._db);this._db.releaseObjectHandle(l),l.objectId=a,l.ownerId=o.ownerObjectId||"0",o.defaultId&&(l.defaultId=o.defaultId),o.extensionDictionaryId&&(l.extensionDictionary=o.extensionDictionaryId),this._db.registerObjectHandle(l),e.set(a,l)}const n=this.collectLoadedObjectsByHandle();for(const[a,o]of e)n.set(a,o);for(const[a,o]of this._dictionaries){const c=e.get(a);if(c)for(const[l,h]of Object.entries(o.entries)){const u=n.get(at(h));if(!u||c.getAt(l))continue;const d=at(u.objectId);let g=!1;for(const[,f]of c.entries())if(at(f.objectId)===d){g=!0;break}if(!g)try{c.setAt(l,u)}catch{}}}let r;for(const a of this._dictionaries.values())if(!a.ownerObjectId||a.ownerObjectId==="0"){r=a;break}if(!(r!=null&&r.handle))return;const s=this._db.objects.dictionary;for(const[a,o]of Object.entries(r.entries)){if(s.getAt(a))continue;const c=n.get(at(o));if(c instanceof G)try{s.setAt(a,c)}catch{}}}finishCannoscale(){const e=this._db.objects.dictionary.getAt("AcDbVariableDictionary");if(!(e instanceof G))return;const n=e.getAt("CANNOSCALE");n instanceof xr&&n.value&&(this._db.cannoscale=n.value)}finishAnnoallvisible(){const e=this._db.objects.dictionary.getAt("AcDbVariableDictionary");if(!(e instanceof G))return;const n=e.getAt("ANNOALLVISIBLE");if(!(n instanceof xr)||n.value==null)return;const r=String(n.value).trim();this._db.annoallvisible=r!=="0"&&r.toLowerCase()!=="false"}readPersistDictionary(t,e){const n={handle:"",ownerObjectId:"",entries:{}};let r,s=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const a=t.readItem();if(!a)break;const o=Number(a.code);switch(o){case 5:n.handle=String(a.value);break;case 330:n.ownerObjectId=String(a.value);break;case 100:s=String(a.value)==="AcDbDictionaryWithDefault";break;case 280:case 281:break;case 3:r=String(a.value);break;case 350:case 340:case 360:{const c=at(String(a.value));o===340&&(s||e==="ACDBDICTIONARYWDFLT")&&!r?n.defaultId=c:r?(n.entries[r]=c,r=void 0):o===360&&!n.extensionDictionaryId&&(n.extensionDictionaryId=c);break}}}return n.handle=at(n.handle),n.ownerObjectId=at(n.ownerObjectId),n.extensionDictionaryId&&(n.extensionDictionaryId=at(n.extensionDictionaryId)),n}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=Cp({dictionaries:this._dictionaries,xrecords:this._xrecords});t.root.getNestedFilters().length>0&&(this._db.layerFilters=t),this._dictionaries.clear(),this._xrecords.clear()}linkLayoutsToBlockTableRecords(){const t=this._db.tables.blockTable,e=lt.MODEL_SPACE_NAME.toUpperCase();for(const[,n]of this._db.objects.layout.entries()){if(n.layoutName==="Model"){const a=t.modelSpace;n.blockTableRecordId=a.objectId,a.layoutId=n.objectId;continue}const r=at(n.objectId);let s=!1;for(const a of t.newIterator())if(at(a.layoutId)===r){n.blockTableRecordId=a.objectId,s=!0;break}if(!s&&n.blockTableRecordId){const a=t.getIdAt(n.blockTableRecordId);a&&(a.layoutId=n.objectId)}else if(!s){for(const a of t.newIterator())if(a.isPaperSapce&&a.name.toUpperCase()!==e&&!a.layoutId){n.blockTableRecordId=a.objectId,a.layoutId=n.objectId;break}}}}}class Mo{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap=new Map,this._yieldGate=new ho(this._options.yieldBudgetMs??Cr)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap.clear(),this._openInsert=void 0,t.database=this._db;!t.atEof;){const e=t.readItem();if(!e)break;if(Number(e.code)!==0)continue;const n=String(e.value).toUpperCase();if(n==="EOF")break;if(n==="SECTION"){const r=this.readSectionName(t);await this.readSection(t,r);continue}}return this.flushRemainingAttributes(),{unknownEntityCount:this._unknownEntityCount,unknownObjectCount:this._unknownObjectCount}}readSectionName(t){const e=t.readItem();return e&&Number(e.code)===2?String(e.value).toUpperCase():(e&&t.pushBackItem(e),"")}async readSection(t,e){switch(e){case"HEADER":Ip(t,this._db),await this.reportParseProgress(t);break;case"CLASSES":this.readClassesSection(t),await this.reportParseProgress(t);break;case"TABLES":this.readTablesSection(t),await this.reportParseProgress(t);break;case"BLOCKS":await this.readBlocksSection(t),await this.reportParseProgress(t);break;case"ENTITIES":await this.readEntitiesSection(t),await this.reportParseProgress(t);break;case"OBJECTS":{const n=new Yp(this._db);n.read(t),this._unknownObjectCount+=n.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(_w(t)),await this.reportParseProgress(t);break;case"THUMBNAILIMAGE":this.readThumbnailImageSection(t),await this.reportParseProgress(t);break;default:this.skipUntilEndSec(t),await this.reportParseProgress(t);break}}applyAcdsDataToSolids(t){const e=Object.keys(t.byOwnerHandle);if(e.length===0)return;const n=new Map;for(const r of this._db.tables.blockTable.newIterator())for(const s of r.newIterator())s instanceof Xr&&n.set(Gc(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const a=n.get(Gc(r));a&&a.setSabBytes(s)}}readThumbnailImageSection(t){let e=0;const n=[];for(;!t.atEof;){const s=t.readItem();if(!s)break;if(Number(s.code)===0){if(String(s.value).toUpperCase()==="ENDSEC")break;t.pushBackItem(s);break}Number(s.code)===90?e=Number(s.value)||0:Number(s.code)===310&&(s.value instanceof Uint8Array?n.push(s.value):n.push(String(s.value)))}if(n.length===0)return;const r=cs(n);!r||r.length===0||(this._db.thumbnailImage=e>0&&r.length>e?r.subarray(0,e):r)}readClassesSection(t){const e=[];for(;!t.atEof;){const n=t.peekItem();if(!n)break;if(Number(n.code)!==0){t.readItem();continue}const r=String(n.value).toUpperCase();if(r==="ENDSEC"){t.readItem();break}if(r==="CLASS"){t.readItem();const s=this.readClassRecord(t);(s.name||s.cppClassName)&&e.push(s);continue}t.readItem(),t.skipToEndOfObject()}e.length>0&&(this._db.classes=e)}readClassRecord(t){const e={name:"",cppClassName:"",appName:"",proxyFlag:0,instanceCount:0,wasProxy:!1,isEntity:!1};for(;!t.atEndOfObject&&!t.atEof;){const n=t.readItem();if(!n)break;switch(Number(n.code)){case 1:e.name=String(n.value);break;case 2:e.cppClassName=String(n.value);break;case 3:e.appName=String(n.value);break;case 90:e.proxyFlag=Number(n.value);break;case 91:e.instanceCount=Number(n.value);break;case 280:e.wasProxy=Number(n.value)!==0;break;case 281:e.isEntity=Number(n.value)!==0;break}}return e}readTablesSection(t){for(;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const n=String(e.value).toUpperCase();if(n==="ENDSEC"){t.readItem();break}if(n==="TABLE"){t.readItem();const r=this.readTableName(t);this.readTable(t,r);continue}t.readItem(),t.skipToEndOfObject()}this.resolveDimStyleHandles(),this._db.ensureTextStyleDefaults()}resolveDimStyleHandles(){const{textStyleTable:t,blockTable:e,dimStyleTable:n}=this._db.tables,r=(s,a)=>{if(!s||a.getAt(s))return;const o=a.getIdAt(s);return o?o.name:/^[0-9A-F]+$/i.test(s)?"":void 0};for(const s of n.newIterator()){const a=r(s.dimtxsty,t);a!=null&&(s.dimtxsty=a||Vt.DEFAULT_DIM_VALUES.dimtxsty||"");const o=r(s.dimldrblk,e);o!=null&&(s.dimldrblk=o);const c=r(s.dimblk,e);c!=null&&(s.dimblk=c);const l=r(s.dimblk1,e);l!=null&&(s.dimblk1=l);const h=r(s.dimblk2,e);h!=null&&(s.dimblk2=h)}}readTableName(t){for(;!t.atEof;){const e=t.peekItem();if(!e)return"";const n=Number(e.code);if(n===0)return"";if(t.readItem(),n===2)return String(e.value).toUpperCase()}return""}readTable(t,e){switch(e){case"LAYER":this.readNamedTable(t,"LAYER",()=>new ls,n=>{n.name&&this._db.tables.layerTable.add(n)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new vn,n=>{n.name&&this._db.tables.linetypeTable.add(n)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new Eo,n=>{this._db.tables.textStyleTable.add(n)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Vt,n=>{n.name&&this._db.tables.dimStyleTable.add(n)});break;case"VPORT":this.readNamedTable(t,"VPORT",()=>new An,n=>{n.name&&this._db.tables.viewportTable.add(n)});break;case"APPID":this.readNamedTable(t,"APPID",()=>new _r,n=>{n.name&&this._db.tables.appIdTable.add(n)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new Pp,n=>{n.name&&this._db.tables.viewTable.add(n)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new Sp,n=>{n.name&&this._db.tables.ucsTable.add(n)});break;case"BLOCK_RECORD":this.readBlockRecordTable(t);break;default:this.skipUntilEndTab(t);break}}readNamedTable(t,e,n,r){for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDTAB"){t.readItem();break}if(a==="ENDSEC")break;if(a===e){t.readItem();const o=n();o.dxfIn(t),r(o);continue}t.readItem(),t.skipToEndOfObject()}}readBlockRecordTable(t){let e=!1;for(;!t.atEof;){const n=t.peekItem();if(!n)break;if(Number(n.code)!==0){t.readItem();continue}const r=String(n.value).toUpperCase();if(r==="ENDTAB"){t.readItem();break}if(r==="ENDSEC")break;if(r==="BLOCK_RECORD"){t.readItem(),e||(this._db.tables.blockTable.removeAll(),e=!0);const s=new lt;s.dxfIn(t),s.name&&this._db.tables.blockTable.add(s);continue}t.readItem(),t.skipToEndOfObject()}}skipUntilEndTab(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDTAB")break}}async readBlocksSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let n=0;for(;!t.atEof;){const r=t.peekItem();if(!r)break;if(Number(r.code)!==0){t.readItem();continue}const s=String(r.value).toUpperCase();if(s==="ENDSEC"){t.readItem();break}if(s==="BLOCK"){t.readItem(),n=await this.readBlockDefinition(t,e,n);continue}t.readItem(),t.skipToEndOfObject()}}async readBlockDefinition(t,e,n){const r=this.readBlockBeginFields(t),s=this.ensureBlockTableRecord(r);for(this._openInsert=void 0;!t.atEof;){const a=t.peekItem();if(!a)break;if(Number(a.code)!==0){t.readItem();continue}const o=String(a.value).toUpperCase();if(o==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(o==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,o)){this._openInsert=void 0,n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t));continue}const c=xl(t,o);c?(this.countUnknownEntity(c),this.shouldAcceptBlockEntity(s)?this.acceptEntity(c,s):this._openInsert=void 0):(this._openInsert=void 0,t.skipToEndOfObject()),n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t))}return n}shouldAcceptBlockEntity(t){return!(t.isModelSapce||Mo.isActivePaperSpaceName(t.name))}static isActivePaperSpaceName(t){return t.toLowerCase()===lt.PAPER_SPACE_NAME_PREFIX.toLowerCase()}consumeSeqend(t,e){return e!=="SEQEND"?!1:(t.skipToEndOfObject(),!0)}readBlockBeginFields(t){const e=new x;let n="",r=0,s="",a="",o,c;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code);if(h===100)continue;const u=Number(l.value);switch(h){case 5:o=String(l.value);break;case 330:c=String(l.value);break;case 2:case 3:n||(n=String(l.value));break;case 70:r=u;break;case 10:e.x=u;break;case 20:e.y=u;break;case 30:e.z=u;break;case 1:s=String(l.value);break;case 4:a=String(l.value);break}}return{name:n,flags:r,origin:e,pathName:s,comments:a,objectId:o,ownerId:c}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new lt,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin),t.comments&&(e.comments=t.comments);let n=lt.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(n&(pr.Xref|pr.XrefOverlay))===0&&(n=n|pr.Xref)),e.flags=n,e}async readEntitiesSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let n=0;const r=this._db.tables.blockTable.modelSpace;for(this._openInsert=void 0;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,a)){this._openInsert=void 0,n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t));continue}const o=xl(t,a);o?(this.countUnknownEntity(o),this.acceptEntity(o,this.resolveEntityOwner(o,r))):(this._openInsert=void 0,t.skipToEndOfObject()),n+=1,n>=e&&(n=0,await this.yieldAndReportProgress(t))}}resolveEntityOwner(t,e){const n=t.getAttrWithoutException("ownerId");if(n){const r=this._db.tables.blockTable.getIdAt(n);if(r&&(r.isModelSapce||r.isPaperSapce))return r}if(t.dxfPaperSpace){const r=this._db.tables.blockTable.getAt(lt.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Vr){const n=this._openInsert;if(n){n.appendAttributes(t);return}this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),this._openInsert=t instanceof Qt?t:void 0,t instanceof Qt){const n=this._attributeMap.get(t.objectId);if(n&&n.length>0){for(const r of n)t.appendAttributes(r);this._attributeMap.delete(t.objectId)}}}countUnknownEntity(t){t instanceof Gr&&(this._unknownEntityCount+=1)}linkOrDeferAttribute(t,e){const n=t.getAttrWithoutException("ownerId");if(!n||n==="0")return;const r=e.getIdAt(n)??this._db.tables.blockTable.getEntityById(n);if(r instanceof Qt){r.appendAttributes(t);return}let s=this._attributeMap.get(n);s||(s=[],this._attributeMap.set(n,s)),s.push(t)}flushRemainingAttributes(){for(const[t,e]of this._attributeMap){const n=this._db.tables.blockTable.getEntityById(t);if(n instanceof Qt)for(const r of e)n.appendAttributes(r)}this._attributeMap.clear()}skipUntilEndSec(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDSEC")break}}async reportParseProgress(t){const{onProgress:e,totalBytes:n}=this._options;if(!e||!n||n<=0)return;const r=Math.min(1,Math.max(0,t.position().byteOffset/n));await e(r)}async yieldAndReportProgress(t){await this.reportParseProgress(t),await this._yieldGate.maybeYield(Zi)}}const Is=1,oc=18,Es=20,Ts=98;class jp extends sh{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,n={}){const{minimumChunkSize:r=10,progress:s,encoding:a}=n;this.progress=s;const o=async(l,h,u,d)=>{s&&await s(l,h,u,d)};await o(0,"START","START"),await o(Is,"PARSE","START"),await Zd(),e.beginEventBatch();let c=!0;try{const l=ve.fromBuffer(t,{database:e,encoding:a}),h=t.byteLength;let u=Is;const g=await new Mo(e,{entityBatchSize:Math.max(1,r||200),yieldBudgetMs:Cr,totalBytes:h,onProgress:async y=>{const b=Math.min(oc-1,Is+Math.floor(y*(oc-Is)));b<=u||(u=b,await o(b,"PARSE","IN-PROGRESS"))}}).read(l);await o(oc,"PARSE","END",{unknownEntityCount:g.unknownEntityCount}),await o(Es,"ENTITY","START");const f=Math.max(1,r||200);let p=Es;const m=new ho(Cr);await e.endEventBatchChunked(f,async(y,b)=>{const _=b<=0?Ts:Math.min(Ts,Es+Math.floor(y/b*(Ts-Es)));_>p&&(p=_,await o(_,"ENTITY","IN-PROGRESS")),await m.maybeYield()}),c=!1,await o(Ts,"ENTITY","END"),await o(100,"END","END")}catch(l){throw c&&e.endEventBatch(),l}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}}var wr=(i=>(i.DXF="dxf",i.DWG="dwg",i))(wr||{});class Ce{constructor(){this.events={registered:new vt,unregistered:new vt},this._converters=new Map,this.register("dxf",new jp)}static createInstance(){return Ce._instance==null&&(Ce._instance=new Ce),this._instance}static get instance(){return Ce._instance||(Ce._instance=new Ce),Ce._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}const $c=50,Iw=tt.DEFAULT_CIRCLE_SIDES,Ew=1e3;function ds(i){var e;const t=Vp((e=i==null?void 0:i.context)==null?void 0:e.database);return{circleSides:t,maxSegments:t}}function Vp(i){if(i!=null&&typeof i=="object"){const t=i.drawCircleSides;if(typeof t=="number"&&Number.isFinite(t))return tt.resolveCircleSides(t)}return tt.DEFAULT_CIRCLE_SIDES}function Tw(i){var n,r,s;if(i==null||typeof i!="object")return tt.DEFAULT_CIRCLE_SIDES;const t=i.tables,e=(s=(r=(n=t==null?void 0:t.viewportTable)==null?void 0:n.getActiveVport)==null?void 0:r.call(n))==null?void 0:s.circleSides;return typeof e!="number"||!Number.isFinite(e)?tt.DEFAULT_CIRCLE_SIDES:tt.resolveCircleSides(e)}const cc=new C,_i=class _i extends Ot{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._elevation=0,this._geo=new ot}get dxfTypeName(){return"LWPOLYLINE"}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}addVertexAt(t,e,n=0,r=-1,s=-1){const a=r<0?void 0:r,o=s<0?void 0:s,c={x:e.x,y:e.y,bulge:n,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}removeVertexAt(t){this._geo.removeVertexAt(t)}reset(t,e){this._geo.reset(t,e)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return this.ocsPointToWcs(e.x,e.y)}get geometricExtents(){const t=this._geo.box;return t.isEmpty()?new H:new H().setFromPoints([this.ocsPointToWcs(t.min.x,t.min.y),this.ocsPointToWcs(t.max.x,t.min.y),this.ocsPointToWcs(t.max.x,t.max.y),this.ocsPointToWcs(t.min.x,t.max.y)])}ocsPointToWcs(t,e){return ce({x:t,y:e,z:this._elevation},this._normal)}subGetIntersectCurves(){return rh(this._geo.vertices,this.closed,this._elevation,this._normal)}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return this.shouldIncludeSegmentMidpointGrips()&&this.appendSegmentMidpointGrips(t),t}subMoveGripPointsAt(t,e){const n=this.numberOfVertices,r=this.shouldIncludeSegmentMidpointGrips(),s=r?this.getSegmentCount():0,a=Zt(e,this._normal);return Et(t,o=>{if(o<n){yr(this._geo.vertices,o,a);return}if(!r||o>=n+s)return;const c=o-n;yr(this._geo.vertices,c,a),yr(this._geo.vertices,(c+1)%n,a)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=wt.instance().getVar(E.GRIPS,this.database);return typeof t=="number"?t:2}catch{return 2}}getSegmentCount(){const t=this.numberOfVertices;return t<2?0:this.closed?t:t-1}appendSegmentMidpointGrips(t){var a;const e=this._geo,n=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let o=0;o<r;o++){const c=[];Yr(e.getPointAt(o),e.getPointAt((o+1)%s),(a=e.vertices[o])==null?void 0:a.bulge,n,T.MidPoint,{x:0,y:0,z:0},c);for(const l of c)t.push(this.ocsPointToWcs(l.x,l.y))}}subGetOsnapPoints(t,e,n,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case T.EndPoint:for(let l=0;l<o;l++)r.push(this.getPoint3dAt(l));break;case T.MidPoint:case T.Nearest:case T.Perpendicular:case T.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Yr(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d);for(const g of d)h.push(this.ocsPointToWcs(g.x,g.y))}if(t===T.MidPoint)r.push(...h);else{const u=ye(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let n=this._elevation;return this._geo.vertices.forEach(r=>{const s=new x(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,n=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=n,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]},{groupName:"others",properties:[{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}get directBatchPrimitive(){return this.hasRenderableWidth()?null:"lineStrip"}subWorldDraw(t){const e=ds(t),n=this._geo.tessellate(e),r=this.createWidthProfile(e);if(r!=null){if(this.closed||Up(gh(r,!1))){const c=Lw(r);if(c!=null){const l=t.subEntityTraits;return l.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.offsetRing(c.outer.map(h=>this.ocsPointToWcs(h.x,h.y)),c.inner.map(h=>this.ocsPointToWcs(h.x,h.y)))}}const o=Mw(r,this.closed);if(o!=null){const c=t.subEntityTraits,l=c.fillType;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const h=o.map(d=>(this.mapAreaLoopsToWcs(d),t.area(d)));c.fillType=l;const u=r.map(d=>this.ocsPointToWcs(d.x,d.y));return this.closed&&u.length>=2&&u.push(u[0]),u.length>=2&&h.push(t.lines(u)),h.length===1?h[0]:t.group(h)}}const s=[];return n.forEach(a=>s.push(this.ocsPointToWcs(a.x,a.y))),t.lines(s)}mapAreaLoopsToWcs(t){if(!(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)){for(const e of t.loops)if("vertices"in e)for(const n of e.vertices){const r=this.ocsPointToWcs(n.x,n.y);n.x=r.x,n.y=r.y}}}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0);const e=this.resolveConstantWidth();e!=null&&t.writeDouble(43,e),t.writeDouble(38,this.elevation),this.thickness!==0&&t.writeDouble(39,this.thickness);const n=this._geo.vertices;for(let r=0;r<n.length;++r){const s=n[r];t.writePoint2d(10,this.getPoint2dAt(r)),e==null&&(s.startWidth!=null&&t.writeDouble(40,s.startWidth),s.endWidth!=null&&t.writeDouble(41,s.endWidth));const a=s.bulge??0;a!==0&&t.writeDouble(42,a),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,a;t.writeHandle(5,this.objectId),this.dxfOutExtensionDictionary(t),t.writeObjectId(330,this.ownerId),t.writeSubclassMarker("AcDbEntity"),t.writeString(8,this.layer),t.writeString(6,this.lineType),t.writeDouble(48,this.linetypeScale),t.writeInt16(60,this.visibility?0:1),t.writeCmColor(this.color),t.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency);const n=(r=this.database)==null?void 0:r.tables.blockTable.getIdAt(this.ownerId);n!=null&&n.isPaperSapce&&t.writeInt16(67,1),t.writeSubclassMarker("AcDb2dPolyline"),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,this.closed?1:0),t.writeDouble(10,0),t.writeDouble(20,0),t.writeDouble(30,this.elevation),e&&this.dxfOutXData(t);for(let o=0;o<this.numberOfVertices;++o){const c=this._geo.vertices[o];t.writeStart("VERTEX"),t.writeHandle(5,(s=this.database)==null?void 0:s.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:this.getPoint2dAt(o).x,y:this.getPoint2dAt(o).y,z:this.elevation});const l=(c==null?void 0:c.bulge)??0;l!==0&&t.writeDouble(42,l),t.writeInt16(70,0)}return t.writeStart("SEQEND"),t.writeHandle(5,(a=this.database)==null?void 0:a.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPolyline"),this.reset(!1);let e=!1,n=this.elevation,r=this.thickness,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,f=-1,p,m=0;const y=()=>{if(!u)return;const b=g<0?c:g,_=f<0?c:f;if(cc.x=l,cc.y=h,this.addVertexAt(m++,cc,d,b,_),p!=null){const w=this._geo.vertices[m-1];w&&(w.identifier=p)}u=!1,d=0,g=-1,f=-1,p=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),w=Number(b.value);switch(_){case 90:break;case 70:e=(w&1)!==0;break;case 43:c=w;break;case 38:n=w;break;case 39:r=w;break;case 10:y(),l=w,h=0,u=!0;break;case 20:h=w;break;case 40:g=w;break;case 41:f=w;break;case 42:d=w;break;case 91:p=w;break;case 210:s=w;break;case 220:a=w;break;case 230:o=w;break}}return y(),this.closed=e,this.elevation=n,this.thickness=r,s*s+a*a+o*o>0&&this.normal.set(s,a,o).normalize(),this}resolveConstantWidth(){const t=this._geo.vertices;if(t.length===0)return;let e;for(const n of t){const r=n.startWidth,s=n.endWidth;if(r==null&&s==null){if(e!=null&&e!==0)return;e=e??0;continue}const a=r??0;if(a!==(s??0))return;if(e==null)e=a;else if(e!==a)return}return e!=null&&e!==0?e:void 0}hasRenderableWidth(){const t=this._geo.vertices;for(let e=0;e<t.length;e++){const n=Math.max(0,t[e].startWidth??0),r=Math.max(0,t[e].endWidth??0);if(n>It||r>It)return!0}return!1}createWidthProfile(t){const e=this._geo.vertices,n=e.length;if(n<2)return null;const r=this.closed?n:n-1,s=[];let a=!1;for(let o=0;o<r;o++){const c=e[o],l=e[(o+1)%n],h=Math.max(0,c.startWidth??0),u=Math.max(0,c.endWidth??0);(h>It||u>It)&&(a=!0);const d=this.sampleSegment(c,l,t),g=d.length-1;for(let f=0;f<=g;f++){if(f===0&&s.length>0||this.closed&&o===r-1&&f===g)continue;const p=g>0?f/g:0;s.push({x:d[f].x,y:d[f].y,width:Fw(h,u,p)})}}return a&&s.length>=2?s:null}sampleSegment(t,e,n){if(t.bulge&&Math.abs(t.bulge)>It){const s=new tt(t,e,t.bulge).tessellate(n);if(s.length>1)return s.map(a=>new C(a.x,a.y))}return[new C(t.x,t.y),new C(e.x,e.y)]}static from2dPoints(t,e){const n=new _i;return t.forEach((r,s)=>n.addVertexAt(s,r)),n.closed=e,n}static fromGePolyline(t){const e=new _i;return t.vertices.forEach((n,r)=>{e.addVertexAt(r,new C(n.x,n.y),n.bulge??0)}),e.closed=t.closed,e}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.numberOfVertices;let n=1/0,r=1;const s=this.closed?e:e-1;for(let a=0;a<s;a++){const o=this.getPoint2dAt(a),c=this.getPoint2dAt((a+1)%e),l=c.x-o.x,h=c.y-o.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*h)/u)),g=(t.x-o.x-d*l)**2+(t.y-o.y-d*h)**2;g<n&&(n=g,r=l*(t.y-o.y)-h*(t.x-o.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:_i.fromGePolyline(e[0])}};_i.typeName="Polyline";let Ut=_i;function Co(i,t,e){const n=_b(i,t,e);return n?Ut.fromGePolyline(n):null}const It=1e-6,fd=4;function Lw(i){const t=gh(i,!0);if(t.length<2)return null;const{left:e,right:n}=dh(t,!0),r=Wi(e),s=Wi(n);if(!$n(r)||!$n(s)||r.length!==s.length)return null;const a=Math.abs(Wn(r)),o=Math.abs(Wn(s)),[c,l]=a>=o?[r,s]:[s,r];return{outer:c,inner:l}}function Mw(i,t){if(i.length<2)return null;if(t){const r=pd(i,!0);return r?[r]:null}const e=Cw(i),n=[];for(const r of e){const s=pd(r,!1);s!=null&&n.push(s)}return n.length>0?n:null}function pd(i,t){const e=gh(i,t);if(e.length<2)return null;const{left:n,right:r}=dh(e,t);if(yd(n)<2||yd(r)<2)return null;const s=new de;if(t){const a=Wi(n),o=Wi(r),c=$n(a),l=$n(o);if(!c&&!l)return null;if(!c||!l)return s.add(new ot(c?a:o,!0)),s;const h=Math.abs(Wn(a)),u=Math.abs(Wn(o)),[d,g]=h>=u?[a,o]:[o,a];return s.add(new ot(d,!0)),s.add(new ot(g,!0)),s}return Up(e)&&Dw(s,e)||Rw(s,n,r)?s:null}function Cw(i){if(i.length<2)return[i];const t=[];let e=0;const n=new Map;for(let s=0;s<i.length;s++){const a=md(i[s]),o=n.get(a);if(o!=null&&s-o>1){const c=i.slice(e,s+1);if(c.length>=2&&t.push(c),o===e&&s===i.length-1)return t.length>0?t:[i];e=o,n.clear();for(let l=e;l<=s;l++)n.set(md(i[l]),l);continue}n.set(a,s)}const r=i.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[i]}function md(i){return`${i.x.toFixed(4)}:${i.y.toFixed(4)}`}function Ow(i,t){const e=Math.max(i,t),n=Math.min(i,t);return e<=It?!1:e-n>It}function Up(i){if(i.length<3)return!1;const t=i[0],e=i[i.length-1],n=Math.hypot(e.x-t.x,e.y-t.y);if(n<=It)return!0;const r=Math.max(...i.map(s=>s.width));return r<=It?!1:n<=r*4}function Dw(i,t){const{left:e,right:n}=dh(t,!0),r=Wi(e),s=Wi(n);if(!$n(r)||!$n(s))return!1;const a=Math.abs(Wn(r)),o=Math.abs(Wn(s));if(!Ow(a,o))return!1;const[c,l]=a>=o?[r,s]:[s,r];return i.add(new ot(c,!0)),i.add(new ot(l,!0)),!0}function dh(i,t){const e=new Array(i.length),n=new Array(i.length);for(let r=0;r<i.length;r++){const s=i[r],a=Math.max(0,s.width)/2;if(a<=It){e[r]={x:s.x,y:s.y},n[r]={x:s.x,y:s.y};continue}const o=Bw(i,r,t);if(o==null){e[r]=null,n[r]=null;continue}e[r]={x:s.x+o.x*a,y:s.y+o.y*a},n[r]={x:s.x-o.x*a,y:s.y-o.y*a}}return{left:e,right:n}}function Nw(i,t,e,n,r){const s=[t,e,n,r];return $n(s)?(i.add(new ot(s,!0)),!0):!1}function Rw(i,t,e){let n=!1;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=e[r],c=e[r+1];s==null||a==null||o==null||c==null||Nw(i,s,a,c,o)&&(n=!0)}return n}function yd(i){return i.reduce((t,e)=>e==null?t:t+1,0)}function Wi(i){return i.filter(t=>t!=null)}function gh(i,t){const e=[];if(i.forEach(n=>{const r=e[e.length-1];(!r||Math.abs(r.x-n.x)>It||Math.abs(r.y-n.y)>It||Math.abs(r.width-n.width)>It)&&e.push(n)}),t&&e.length>1){const n=e[0],r=e[e.length-1];Math.abs(n.x-r.x)<=It&&Math.abs(n.y-r.y)<=It&&e.pop()}return e}function Bw(i,t,e){const n=i.length,r=i[t],s=i[(t-1+n)%n],a=i[(t+1)%n];let o=bd(r.x-s.x,r.y-s.y),c=bd(a.x-r.x,a.y-r.y);if(e||(t===0&&(o=c),t===n-1&&(c=o)),o==null&&c==null)return null;if(o==null)return Ls(c);if(c==null)return Ls(o);const l=Ls(o),h=Ls(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=It)return h;const f={x:u/g,y:d/g},p=Math.abs(f.x*h.x+f.y*h.y),m=p<=It?fd:Math.min(1/p,fd);return{x:f.x*m,y:f.y*m}}function bd(i,t){const e=Math.hypot(i,t);return e<=It?null:{x:i/e,y:t/e}}function Ls(i){return{x:-i.y,y:i.x}}function Wn(i){let t=0;const e=i.length;for(let n=0;n<e;n++){const r=i[n],s=i[(n+1)%e];t+=r.x*s.y-s.x*r.y}return t/2}function $n(i){return i.length>=3&&Math.abs(Wn(i))>It}function Fw(i,t,e){return i+(t-i)*e}const zw={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:23},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:24}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:26}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:28},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:29}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:31},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:32}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:34},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:35},{angle:45,originX:.353553391,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:36},{angle:45,originX:.530330086,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:37}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:39},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.3125,-.0625,0,-.0625],sourceLine:40}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:.21875,deltaY:.125,dashes:[.3125,-.0625,0,-.0625],sourceLine:42}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:45}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:47},{angle:135,originX:0,originY:0,deltaX:.25,deltaY:.125,dashes:[.3125,-.1875],sourceLine:48}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:54},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[8,-8],sourceLine:55}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:57},{angle:0,originX:-8,originY:.375,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:58},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:59},{angle:90,originX:-.375,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:60}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:62},{angle:90,originX:0,originY:0,deltaX:8,deltaY:4,dashes:[8,-8],sourceLine:63}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:65},{angle:0,originX:0,originY:2.25,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:66},{angle:0,originX:2,originY:2.667,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:67},{angle:0,originX:2,originY:4.917,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:68},{angle:90,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:69},{angle:90,originX:-.375,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:70},{angle:90,originX:2,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:71},{angle:90,originX:1.625,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:72}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:2.667,dashes:[],sourceLine:74},{angle:90,originX:0,originY:0,deltaX:2.667,deltaY:4,dashes:[2.667,-2.667],sourceLine:75}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:77},{angle:355,originX:0,originY:0,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:78},{angle:100.45144446,originX:.59771681,originY:-.05229344,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.63740192,-7.01142112],sourceLine:79},{angle:46.1842,originX:0,originY:2,deltaX:6.19462554,deltaY:-8.84684596,dashes:[1.125,-12.375],sourceLine:80},{angle:96.63563549,originX:.88936745,originY:1.86206693,deltaX:8.59588239,deltaY:-10.40964966,dashes:[.95610342,-10.5171376],sourceLine:81},{angle:351.18416399,originX:0,originY:2,deltaX:7.74327494,deltaY:11.05855746,dashes:[.9,-9.90000001],sourceLine:82},{angle:21,originX:1,originY:1.5,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:83},{angle:326,originX:1,originY:1.5,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:84},{angle:71.45144474,originX:1.49742254,originY:1.16448426,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.6374019,-7.01142112],sourceLine:85},{angle:37.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-6.52,0,-6.7,0,-6.625],sourceLine:86},{angle:7.5,originX:0,originY:0,deltaX:3.123,deltaY:3.567,dashes:[0,-3.82,0,-6.37,0,-2.525],sourceLine:87},{angle:-32.5,originX:-2.23,originY:0,deltaX:4.6234,deltaY:2.678,dashes:[0,-2.5,0,-7.8,0,-10.35],sourceLine:88},{angle:-42.5,originX:-3.23,originY:0,deltaX:3.6234,deltaY:4.678,dashes:[0,-3.25,0,-5.18,0,-7.35],sourceLine:89}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:4,deltaY:4,dashes:[12,-4],sourceLine:91},{angle:135,originX:2.828427125,originY:2.828427125,deltaX:4,deltaY:-4,dashes:[12,-4],sourceLine:92}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:94},{angle:90,originX:2,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:95},{angle:90,originX:4,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:96},{angle:90,originX:6,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:97},{angle:90,originX:8,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:98},{angle:90,originX:10,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:99},{angle:90,originX:12,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:100},{angle:0,originX:0,originY:12,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:101},{angle:0,originX:0,originY:14,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:102},{angle:0,originX:0,originY:16,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:103},{angle:0,originX:0,originY:18,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:104},{angle:0,originX:0,originY:20,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:105},{angle:0,originX:0,originY:22,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:106},{angle:0,originX:0,originY:24,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:107}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:2.2,deltaY:1,dashes:[15,-2,5,-1],sourceLine:109},{angle:0,originX:1.33,originY:.5,deltaX:-1,deltaY:1.33,dashes:[3,-.33,6,-.75],sourceLine:110},{angle:0,originX:.5,originY:.85,deltaX:5.2,deltaY:.67,dashes:[8,-1.4,4,-1],sourceLine:111}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:25.5,deltaY:12,dashes:[6,-5,7,-3,9,-4],sourceLine:113},{angle:0,originX:6,originY:.5,deltaX:25.5,deltaY:12,dashes:[5,-19,4,-6],sourceLine:114},{angle:0,originX:18,originY:-.75,deltaX:25.5,deltaY:12,dashes:[3,-31],sourceLine:115},{angle:90,originX:0,originY:0,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:116},{angle:90,originX:6,originY:0,deltaX:12,deltaY:8.5,dashes:[11.25,-36.75],sourceLine:117},{angle:90,originX:11,originY:0,deltaX:12,deltaY:8.5,dashes:[10.5,-37.5],sourceLine:118},{angle:90,originX:18,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:119},{angle:90,originX:21,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:120},{angle:90,originX:30,originY:0,deltaX:12,deltaY:8.5,dashes:[11,-37],sourceLine:121}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:1.123,deltaY:1.567,dashes:[0,-1.52,0,-1.7,0,-1.625],sourceLine:123},{angle:7.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-.82,0,-1.37,0,-.525],sourceLine:124},{angle:-32.5,originX:-1.23,originY:0,deltaX:2.6234,deltaY:1.678,dashes:[0,-.5,0,-1.8,0,-2.35],sourceLine:125},{angle:-42.5,originX:-1.23,originY:0,deltaX:1.6234,deltaY:2.678,dashes:[0,-.25,0,-1.18,0,-1.35],sourceLine:126}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:128},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:129},{angle:0,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:130},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:131},{angle:0,originX:0,originY:.5,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:132},{angle:0,originX:0,originY:.75,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:133},{angle:90,originX:.5,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:134},{angle:90,originX:.75,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:135}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:137},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:138}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:140},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.5,dashes:[.25,-.25],sourceLine:141},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:.5,dashes:[-.25,.25],sourceLine:142}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.33,dashes:[],sourceLine:144},{angle:90,originX:.9,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:145},{angle:90,originX:.8,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:146},{angle:0,originX:.9,originY:.055,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:147},{angle:0,originX:.9,originY:.11,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:148},{angle:0,originX:.9,originY:.165,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:149},{angle:0,originX:.9,originY:.22,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:150},{angle:0,originX:.9,originY:.275,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:151}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.1875,dashes:[],sourceLine:153},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.1875,dashes:[],sourceLine:154},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.1875,dashes:[],sourceLine:155},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.1875,dashes:[.1875,-.125],sourceLine:156}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:158},{angle:135,originX:.0625,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:159},{angle:135,originX:.09375,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:160},{angle:135,originX:.125,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:161}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:163},{angle:90,originX:.0625,originY:-.0625,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:164}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:166}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:168},{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[.3535533905932738,-.7071067811865476],sourceLine:169}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.03125,deltaY:.0625,dashes:[0,-.0625],sourceLine:171}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:173},{angle:0,originX:0,originY:.09375,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:174},{angle:0,originX:0,originY:.1875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:175},{angle:90,originX:.03125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:176},{angle:90,originX:.125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:177},{angle:90,originX:.21875,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:178}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:180},{angle:180,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:181},{angle:300,originX:0,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:182},{angle:60,originX:.1,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:183},{angle:300,originX:.1,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:184},{angle:60,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:185},{angle:180,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:186},{angle:300,originX:-.05,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:187},{angle:180,originX:-.05,originY:-.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:188},{angle:60,originX:-.4,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:189},{angle:300,originX:-.4,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:190},{angle:60,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:191},{angle:180,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:192},{angle:300,originX:.2,originY:.346410161,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:193},{angle:180,originX:.2,originY:.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:194},{angle:0,originX:.2,originY:.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:195},{angle:0,originX:.2,originY:-.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:196},{angle:120,originX:.05,originY:.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:197},{angle:120,originX:-.25,originY:.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:198},{angle:240,originX:-.25,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:199},{angle:240,originX:.05,originY:-.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:200}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[.25,-.25],sourceLine:202},{angle:45,originX:.25,originY:0,deltaX:.176776695296,deltaY:.176776695296,dashes:[.0625,-.2285533906,.0625,-.353553390593],sourceLine:203}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:205},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:206},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:207}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:209},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:210},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:211}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:213},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:214},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:215}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:.707106781,deltaY:.707106781,dashes:[.1875,-1.226713563],sourceLine:217},{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:218},{angle:135,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:219}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.03125,dashes:[],sourceLine:221},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:222}]},{name:"GRAVEL",description:"",lines:[{angle:228.012787504,originX:.72,originY:1,deltaX:12.0413651692039,deltaY:.0743294146632,dashes:[.134536,-13.3190880470737],sourceLine:224},{angle:184.969740728,originX:.63,originY:.9,deltaX:-12.0415166747131,deltaY:.0433148081592,dashes:[.230868,-22.85592476123],sourceLine:225},{angle:132.510447078,originX:.4,originY:.88,deltaX:-14.8659418273816,deltaY:.061429511683,dashes:[.162788,-16.1160325960997],sourceLine:226},{angle:267.273689006,originX:.01,originY:.63,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:227},{angle:292.833654178,originX:0,originY:.42,deltaX:-12.9999095019474,deltaY:.048507125026,dashes:[.206155,-20.4093731280883],sourceLine:228},{angle:357.273689006,originX:.08,originY:.23,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:229},{angle:37.6942404667,originX:.29,originY:.22,deltaX:-16.4011800288558,deltaY:.0359675000664,dashes:[.278029,-27.524848548916],sourceLine:230},{angle:72.2553283749,originX:.51,originY:.39,deltaX:23.0867613281116,deltaY:.0380969659053,dashes:[.262488,-25.9863214968134],sourceLine:231},{angle:121.429565615,originX:.59,originY:.64,deltaX:15.2642639131074,deltaY:.047404546271,dashes:[.21095,-20.884073109729],sourceLine:232},{angle:175.236358309,originX:.48,originY:.82,deltaX:-11.0450488205478,deltaY:.083045479801,dashes:[.240832,-11.8007625787923],sourceLine:233},{angle:222.397437798,originX:.24,originY:.84,deltaX:16.2787889313724,deltaY:.0321080648114,dashes:[.311448,-30.8333750047949],sourceLine:234},{angle:138.814074834,originX:1,originY:.62,deltaX:9.2190645101588,deltaY:.0940720868851,dashes:[.106301,-10.5238448127347],sourceLine:235},{angle:171.46923439,originX:.92,originY:.69,deltaX:-13.1528534931484,deltaY:.0494468176315,dashes:[.202237,-20.021511416157],sourceLine:236},{angle:225,originX:.72,originY:.72,deltaX:.7071067811865,deltaY:.7071067811865,dashes:[.141421,-1.2727925623731],sourceLine:237},{angle:203.198590514,originX:.65,originY:.84,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.076158,-7.5396151058639],sourceLine:238},{angle:291.801409486,originX:.58,originY:.81,deltaX:-3.156820749011,deltaY:.185695338158,dashes:[.107703,-5.2774618071345],sourceLine:239},{angle:30.9637565321,originX:.62,originY:.71,deltaX:3.6014702879928,deltaY:.1714985851408,dashes:[.174929,-5.6560228948453],sourceLine:240},{angle:161.565051177,originX:.77,originY:.8,deltaX:-2.2135943621183,deltaY:.3162277660138,dashes:[.126491,-3.0357866601684],sourceLine:241},{angle:16.389540334,originX:0,originY:.81,deltaX:10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.5428451466694],sourceLine:242},{angle:70.3461759419,originX:.17,originY:.86,deltaX:-11.7045066155395,deltaY:.0672672793901,dashes:[.148661,-14.717407747319],sourceLine:243},{angle:293.198590514,originX:.77,originY:1,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.152315,-7.4634581058639],sourceLine:244},{angle:343.610459666,originX:.83,originY:.86,deltaX:-10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.542845146669],sourceLine:245},{angle:339.44395478,originX:0,originY:.19,deltaX:-5.3838927710229,deltaY:.117041147157,dashes:[.17088,-8.3731237453175],sourceLine:246},{angle:294.775140569,originX:.16,originY:.13,deltaX:-12.0828441168135,deltaY:.0698430296124,dashes:[.143178,-14.174643063276],sourceLine:247},{angle:66.8014094864,originX:.78,originY:0,deltaX:5.3835637472487,deltaY:.1313064328552,dashes:[.152315,-7.4634581058639],sourceLine:248},{angle:17.3540246363,originX:.84,originY:.14,deltaX:-13.6013396869991,deltaY:.0596549986364,dashes:[.167631,-16.59542361424],sourceLine:249},{angle:69.4439547804,originX:.29,originY:0,deltaX:-5.383892771022,deltaY:.1170411471946,dashes:[.08544,-8.4585637453175],sourceLine:250},{angle:101.309932474,originX:.72,originY:0,deltaX:4.1184388379018,deltaY:.1961161351396,dashes:[.05099,-5.0480295135928],sourceLine:251},{angle:165.963756532,originX:.71,originY:.05,deltaX:-3.1529631254726,deltaY:.2425356250323,dashes:[.206155,-3.9169506256177],sourceLine:252},{angle:186.009005957,originX:.51,originY:.1,deltaX:-10.0497393137326,deltaY:.0523423921723,dashes:[.19105,-18.9139231745428],sourceLine:253},{angle:303.690067526,originX:.62,originY:.62,deltaX:-2.2188007849008,deltaY:.2773500981134,dashes:[.144222,-3.461329275464],sourceLine:254},{angle:353.157226587,originX:.7,originY:.5,deltaX:17.1171966955143,deltaY:.0397150736497,dashes:[.251794,-24.9275626240283],sourceLine:255},{angle:60.9453959009,originX:.95,originY:.47,deltaX:-8.0616726575653,deltaY:.0971285862325,dashes:[.102956,-10.192674140987],sourceLine:256},{angle:90,originX:1,originY:.56,deltaX:1,deltaY:1,dashes:[.06,-.94],sourceLine:257},{angle:120.256437164,originX:.49,originY:.13,deltaX:-8.0619364083848,deltaY:.0719815751411,dashes:[.138924,-13.7535199894498],sourceLine:258},{angle:48.0127875042,originX:.42,originY:.25,deltaX:12.0413651692041,deltaY:.0743294146212,dashes:[.269072,-13.1845520470737],sourceLine:259},{angle:0,originX:.6,originY:.45,deltaX:1,deltaY:1,dashes:[.26,-.74],sourceLine:260},{angle:325.304846469,originX:.86,originY:.45,deltaX:12.2063917682497,deltaY:-.063245553253,dashes:[.158114,-15.653274300842],sourceLine:261},{angle:254.054604099,originX:.99,originY:.36,deltaX:4.1208169184605,deltaY:.1373605639542,dashes:[.145602,-7.1345078892805],sourceLine:262},{angle:207.645975364,originX:.95,originY:.22,deltaX:21.4708691170287,deltaY:.0421824539631,dashes:[.237065,-23.4694741822594],sourceLine:263},{angle:175.42607874,originX:.74,originY:.11,deltaX:13.0383438432524,deltaY:.039872611164,dashes:[.250799,-24.8290734079689],sourceLine:264}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:266},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:267},{angle:60,originX:.125,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:268}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:270},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:271},{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[-.25,.125],sourceLine:272}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.0625,dashes:[1,-.5],sourceLine:274},{angle:90,originX:0,originY:0,deltaX:-.25,deltaY:.0625,dashes:[1,-.5],sourceLine:275}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:277},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:278},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:279}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:292}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:294}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:296}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:298}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:300},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:301}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:303}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:305}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:307}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:309}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:311}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:313}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:315},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:316}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:318},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:319}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:321},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:322}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:327}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.25,dashes:[.25,-.25,0,-.25,0,-.25],sourceLine:329}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:331},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:332}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:334},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:335},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:336}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:338},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:339},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:340}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:342},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:343},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:344},{angle:0,originX:0,originY:.15625,deltaX:0,deltaY:.25,dashes:[],sourceLine:345}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.09375,dashes:[],sourceLine:347},{angle:45,originX:.066291261,originY:0,deltaX:0,deltaY:.09375,dashes:[0,-.09375],sourceLine:348}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:350},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:351}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:353},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:354},{angle:120,originX:.0625,originY:.108253176,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:355}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:357},{angle:45,originX:0,originY:.0625,deltaX:0,deltaY:.125,dashes:[],sourceLine:358}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.125,-.875],sourceLine:360},{angle:90,originX:.0625,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.0625,-1.669550806],sourceLine:361},{angle:90,originX:.078125,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:362},{angle:90,originX:.046875,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:363},{angle:60,originX:.09375,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:364},{angle:120,originX:.03125,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:365}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:367},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.125],sourceLine:368}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:370},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:371},{angle:0,originX:-.09375,originY:.162379763,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:372}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:374},{angle:90,originX:.125,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:375}]}],issues:[]},Hp={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:20},{angle:90,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:21}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:23}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:25},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:26}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:28},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:29}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:31},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:32},{angle:45,originX:8.98026,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:33},{angle:45,originX:13.4704,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:34}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:36},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:37}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:5.55625,deltaY:3.175,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:39}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:41},{angle:135,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:42}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:6.35,deltaY:3.175,dashes:[7.9375,-4.7625],sourceLine:45}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:47},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[203.2,-203.2],sourceLine:48}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:50},{angle:0,originX:-203.2,originY:9.525,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:51},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:52},{angle:90,originX:-9.525,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:53}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:55},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:101.6,dashes:[203.2,-203.2],sourceLine:56}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:58},{angle:0,originX:0,originY:57.15,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:59},{angle:0,originX:50.8,originY:67.7418,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:60},{angle:0,originX:50.8,originY:124.892,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:61},{angle:90,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:62},{angle:90,originX:-9.525,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:63},{angle:90,originX:50.8,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:64},{angle:90,originX:41.275,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:65}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:67.7418,dashes:[],sourceLine:67},{angle:90,originX:0,originY:0,deltaX:67.7418,deltaY:101.6,dashes:[67.7418,-67.7418],sourceLine:68}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:104.896,deltaY:-149.807,dashes:[19.05,-209.55],sourceLine:70},{angle:355,originX:0,originY:0,deltaX:-51.76101082,deltaY:187.25814969,dashes:[15.24,-167.64058417],sourceLine:71},{angle:100.4514447,originX:15.182007,originY:-1.3282535,deltaX:145.5569059,deltaY:-176.270089,dashes:[16.1900088,-178.0902446],sourceLine:72},{angle:46.1842,originX:0,originY:50.8,deltaX:157.343,deltaY:-224.71,dashes:[28.575,-314.325],sourceLine:73},{angle:96.63555761,originX:22.5899,originY:47.2965,deltaX:218.33577212,deltaY:-264.40480444,dashes:[24.28502314,-267.13560816],sourceLine:74},{angle:351.18415117,originX:0,originY:50.8,deltaX:196.67912063,deltaY:280.88740361,dashes:[22.85996707,-251.45973192],sourceLine:75},{angle:21,originX:25.4,originY:38.1,deltaX:104.89565868,deltaY:-149.80652586,dashes:[19.05,-209.55],sourceLine:76},{angle:326,originX:25.4,originY:38.1,deltaX:-51.7604,deltaY:187.258,dashes:[15.24,-167.64],sourceLine:77},{angle:71.451445,originX:38.0345326,originY:29.5779001,deltaX:145.5567546,deltaY:-176.2700748,dashes:[16.1900088,-178.0899376],sourceLine:78},{angle:37.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-165.608,0,-170.18,0,-168.275],sourceLine:79},{angle:7.5,originX:0,originY:0,deltaX:79.3242,deltaY:90.6018,dashes:[0,-97.028,0,-161.798,0,-64.135],sourceLine:80},{angle:-32.5,originX:-56.642,originY:0,deltaX:117.434,deltaY:68.0212,dashes:[0,-63.5,0,-198.12,0,-262.89],sourceLine:81},{angle:-42.5,originX:-82.042,originY:0,deltaX:92.0344,deltaY:118.821,dashes:[0,-82.55,0,-131.572,0,-186.69],sourceLine:82}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:101.6,deltaY:101.6,dashes:[304.8,-101.6],sourceLine:84},{angle:135,originX:71.842,originY:71.842,deltaX:101.6,deltaY:-101.6,dashes:[304.8,-101.6],sourceLine:85}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:87},{angle:90,originX:50.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:88},{angle:90,originX:101.6,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:89},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:90},{angle:90,originX:203.2,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:91},{angle:90,originX:254,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:92},{angle:90,originX:304.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:93},{angle:0,originX:0,originY:304.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:94},{angle:0,originX:0,originY:355.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:95},{angle:0,originX:0,originY:406.4,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:96},{angle:0,originX:0,originY:457.2,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:97},{angle:0,originX:0,originY:508,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:98},{angle:0,originX:0,originY:558.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:99},{angle:0,originX:0,originY:609.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:100}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:55.88,deltaY:25.4,dashes:[381,-50.8,127,-25.4],sourceLine:102},{angle:0,originX:33.782,originY:12.7,deltaX:-25.4,deltaY:33.782,dashes:[76.2,-8.382,152.4,-19.05],sourceLine:103},{angle:0,originX:12.7,originY:21.59,deltaX:132.08,deltaY:17.018,dashes:[203.2,-35.56,101.6,-25.4],sourceLine:104}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:647.7,deltaY:304.8,dashes:[152.4,-127,177.8,-76.2,228.6,-101.6],sourceLine:106},{angle:0,originX:152.4,originY:12.7,deltaX:647.7,deltaY:304.8,dashes:[127,-482.6,101.6,-152.4],sourceLine:107},{angle:0,originX:457.2,originY:-19.05,deltaX:647.7,deltaY:304.8,dashes:[76.2,-787.4],sourceLine:108},{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:109},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[285.75,-933.45],sourceLine:110},{angle:90,originX:279.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[266.7,-952.5],sourceLine:111},{angle:90,originX:457.2,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:112},{angle:90,originX:533.4,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:113},{angle:90,originX:762,originY:0,deltaX:304.8,deltaY:215.9,dashes:[279.4,-939.8],sourceLine:114}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:28.5242,deltaY:39.8018,dashes:[0,-38.608,0,-43.18,0,-41.275],sourceLine:116},{angle:7.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-20.828,0,-34.798,0,-13.335],sourceLine:117},{angle:-32.5,originX:-31.242,originY:0,deltaX:66.6344,deltaY:42.6212,dashes:[0,-12.7,0,-45.72,0,-59.69],sourceLine:118},{angle:-42.5,originX:-31.242,originY:0,deltaX:41.2344,deltaY:68.0212,dashes:[0,-6.35,0,-29.972,0,-34.29],sourceLine:119}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:121},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:122},{angle:0,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:123},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:124},{angle:0,originX:0,originY:12.7,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:125},{angle:0,originX:0,originY:19.05,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:126},{angle:90,originX:12.7,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:127},{angle:90,originX:19.05,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:128}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:130},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:131}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:133},{angle:90,originX:0,originY:0,deltaX:0,deltaY:12.7,dashes:[6.35,-6.35],sourceLine:134},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:12.7,dashes:[-6.35,6.35],sourceLine:135}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8.382,dashes:[],sourceLine:137},{angle:90,originX:22.86,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:138},{angle:90,originX:20.32,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:139},{angle:0,originX:22.86,originY:1.397,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:140},{angle:0,originX:22.86,originY:2.794,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:141},{angle:0,originX:22.86,originY:4.191,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:142},{angle:0,originX:22.86,originY:5.588,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:143},{angle:0,originX:22.86,originY:6.985,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:144}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:146},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:147},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:148},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:4.7625,dashes:[4.7625,-3.175],sourceLine:149}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:151},{angle:135,originX:1.5875,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:152},{angle:135,originX:2.38125,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:153},{angle:135,originX:3.175,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:154}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:156},{angle:90,originX:1.5875,originY:-1.5875,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:157}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:159}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:161},{angle:45,originX:0,originY:0,deltaX:0,deltaY:17.9605,dashes:[8.980256121069154,-17.960512242138307],sourceLine:162}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.79375,deltaY:1.5875,dashes:[0,-1.5875],sourceLine:164}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:166},{angle:0,originX:0,originY:2.38125,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:167},{angle:0,originX:0,originY:4.7625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:168},{angle:90,originX:.79375,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:169},{angle:90,originX:3.175,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:170},{angle:90,originX:5.55625,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:171}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:173},{angle:180,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:174},{angle:300,originX:0,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:175},{angle:60,originX:2.54,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:176},{angle:300,originX:2.54,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:177},{angle:60,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:178},{angle:180,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:179},{angle:300,originX:-1.27,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:180},{angle:180,originX:-1.27,originY:-2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:181},{angle:60,originX:-10.16,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:182},{angle:300,originX:-10.16,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:183},{angle:60,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:184},{angle:180,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:185},{angle:300,originX:5.08,originY:8.7988180894,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:186},{angle:180,originX:5.08,originY:8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:187},{angle:0,originX:5.08,originY:4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:188},{angle:0,originX:5.08,originY:-4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:189},{angle:120,originX:1.27,originY:6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:190},{angle:120,originX:-6.35,originY:2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:191},{angle:240,originX:-6.35,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:192},{angle:240,originX:1.27,originY:-6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:193}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:195},{angle:45,originX:6.35,originY:0,deltaX:4.490128053,deltaY:4.490128053,dashes:[1.5875,-5.8052561314,1.5875,-8.9802561314],sourceLine:196}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:198},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:199},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:200}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:202},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:203},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:204}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:206},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:207},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:208}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:17.96051224,deltaY:17.96051224,dashes:[4.7625,-31.15852448],sourceLine:210},{angle:45,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:211},{angle:135,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:212}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.79375,dashes:[],sourceLine:214},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:215}]},{name:"GRAVEL",description:"",lines:[{angle:228.0127875,originX:18.288,originY:25.4,deltaX:305.85067529778,deltaY:1.88796713245,dashes:[3.4172144,-338.30483639565],sourceLine:217},{angle:184.969741,originX:16.002,originY:22.86,deltaX:-305.8545235377,deltaY:1.10019612724,dashes:[5.8640472,-580.54048893524],sourceLine:218},{angle:132.5104471,originX:10.16,originY:22.352,deltaX:-377.59492241548,deltaY:1.56030959675,dashes:[4.1348152,-409.347227941],sourceLine:219},{angle:267.273689,originX:.254,originY:16.002,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:220},{angle:292.83365418,originX:0,originY:10.668,deltaX:-330.19770134945,deltaY:1.23208097566,dashes:[5.236337,-518.39807745344],sourceLine:221},{angle:357.273689,originX:2.032,originY:5.842,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:222},{angle:37.69424047,originX:7.366,originY:5.588,deltaX:-416.58997273292,deltaY:.91357450169,dashes:[7.0619366,-699.13115314247],sourceLine:223},{angle:72.25532837,originX:12.954,originY:9.906,deltaX:586.40373773403,deltaY:.96766293399,dashes:[6.6671952,-660.05256601905],sourceLine:224},{angle:121.42956562,originX:14.986,originY:16.256,deltaX:387.71230339293,deltaY:1.2040754753,dashes:[5.35813,-530.45545698712],sourceLine:225},{angle:175.2363583,originX:12.192,originY:20.828,deltaX:-280.5442400419,deltaY:2.10935518695,dashes:[6.1171328,-299.7393695],sourceLine:226},{angle:222.3974378,originX:6.096,originY:21.336,deltaX:413.48123885686,deltaY:.81554484621,dashes:[7.9107792,-783.16772512177],sourceLine:227},{angle:138.81407483,originX:25.4,originY:15.748,deltaX:234.164238558,deltaY:2.38943100688,dashes:[2.7000454,-267.30565824344],sourceLine:228},{angle:171.4692344,originX:23.368,originY:17.526,deltaX:-334.082478726,deltaY:1.25594916784,dashes:[5.1368198,-508.5463899704],sourceLine:229},{angle:225,originX:18.288,originY:18.288,deltaX:17.96051224214,deltaY:17.96051224214,dashes:[3.5920934,-32.32893108428],sourceLine:230},{angle:203.19859051,originX:16.51,originY:21.336,deltaX:-136.74251918,deltaY:3.33518339548,dashes:[1.9344132,-191.50622368894],sourceLine:231},{angle:291.80140949,originX:14.732,originY:20.574,deltaX:-80.18324702488,deltaY:4.71666158921,dashes:[2.7356562,-134.0475299],sourceLine:232},{angle:30.96375653,originX:15.748,originY:18.034,deltaX:91.47734531502,deltaY:4.35606406258,dashes:[4.4431966,-143.6629815291],sourceLine:233},{angle:161.56505118,originX:19.558,originY:20.32,deltaX:-56.2252967978,deltaY:8.03218525675,dashes:[3.2128714,-77.10898116828],sourceLine:234},{angle:16.389540334,originX:0,originY:20.574,deltaX:265.17991128726,deltaY:1.43340492604,dashes:[4.50088,-445.58826672539],sourceLine:235},{angle:70.34617594,originX:4.318,originY:21.844,deltaX:-297.29446803469,deltaY:1.70858889651,dashes:[3.7759894,-373.822156782],sourceLine:236},{angle:293.19859051,originX:19.558,originY:25.4,deltaX:-136.7425191801,deltaY:3.33518339548,dashes:[3.868801,-189.57183588894],sourceLine:237},{angle:343.61045967,originX:21.082,originY:21.844,deltaX:-265.17991128725,deltaY:1.433404926,dashes:[4.50088,-445.5882667254],sourceLine:238},{angle:339.44395478,originX:0,originY:4.826,deltaX:-136.75087638398,deltaY:2.97284513779,dashes:[4.340352,-212.67734313106],sourceLine:239},{angle:294.7751406,originX:4.064,originY:3.302,deltaX:-306.90424056705,deltaY:1.77401295215,dashes:[3.6367212,-360.0359338072],sourceLine:240},{angle:66.80140949,originX:19.812,originY:0,deltaX:136.74251918012,deltaY:3.33518339452,dashes:[3.868801,-189.57183588894],sourceLine:241},{angle:17.35402464,originX:21.336,originY:3.556,deltaX:-345.47402804977,deltaY:1.51523696536,dashes:[4.2578274,-421.523759802],sourceLine:242},{angle:69.44395478,originX:7.366,originY:0,deltaX:-136.75087638396,deltaY:2.97284513874,dashes:[2.170176,-214.84751913106],sourceLine:243},{angle:101.309932474,originX:18.288,originY:0,deltaX:104.60834648271,deltaY:4.98134983255,dashes:[1.295146,-128.21994964526],sourceLine:244},{angle:165.963756532,originX:18.034,originY:1.27,deltaX:-80.085263387,deltaY:6.16040487582,dashes:[5.236337,-99.49054589069],sourceLine:245},{angle:186.00900596,originX:12.954,originY:2.54,deltaX:-255.26337856879,deltaY:1.32949676118,dashes:[4.85267,-480.41364863337],sourceLine:246},{angle:303.69006753,originX:15.748,originY:15.748,deltaX:-56.35753993648,deltaY:7.0446924921,dashes:[3.6632388,-87.9177635968],sourceLine:247},{angle:353.15722659,originX:17.78,originY:12.7,deltaX:434.77679606606,deltaY:1.0087628707,dashes:[6.3955676,-633.16009065031],sourceLine:248},{angle:60.9453959,originX:24.13,originY:11.938,deltaX:-204.76648550216,deltaY:2.46706609031,dashes:[2.6150824,-258.8939231811],sourceLine:249},{angle:90,originX:25.4,originY:14.224,deltaX:25.4,deltaY:25.4,dashes:[1.524,-23.876],sourceLine:250},{angle:120.25643716,originX:12.446,originY:3.302,deltaX:-204.77318477297,deltaY:1.8283320086,dashes:[3.5286696,-349.339407732],sourceLine:251},{angle:48.0127875,originX:10.668,originY:6.35,deltaX:305.85067529778,deltaY:1.88796713138,dashes:[6.8344288,-334.88762199565],sourceLine:252},{angle:0,originX:15.24,originY:11.43,deltaX:25.4,deltaY:25.4,dashes:[6.604,-18.796],sourceLine:253},{angle:325.3048465,originX:21.844,originY:11.43,deltaX:310.04235091354,deltaY:-1.6064370526,dashes:[4.0160956,-397.5931672414],sourceLine:254},{angle:254.0546041,originX:25.146,originY:9.144,deltaX:104.6687497289,deltaY:3.48895832444,dashes:[3.6982908,-181.21650038772],sourceLine:255},{angle:207.64597536,originX:24.13,originY:5.588,deltaX:545.36007557253,deltaY:1.07143433066,dashes:[6.021451,-596.12464422938],sourceLine:256},{angle:175.42607874,originX:18.796,originY:2.794,deltaX:331.1739336186,deltaY:1.01276432357,dashes:[6.3702946,-630.6584645624],sourceLine:257}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:259},{angle:120,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:260},{angle:60,originX:3.175,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:261}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:263},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:264},{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[-6.35,3.175],sourceLine:265}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:267},{angle:90,originX:0,originY:0,deltaX:-6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:268}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:270},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:271},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:272}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:285}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:287}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:289}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:291}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:293},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:294}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:296}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:298}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:300}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:302}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:304}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:306}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:308},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:309}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:311},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:312}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:314},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:315}]},{name:"JIS_LC_20",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:322},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:323}]},{name:"JIS_LC_20A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:325},{angle:45,originX:1,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:326}]},{name:"JIS_LC_8",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:328},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:329}]},{name:"JIS_LC_8A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:331},{angle:45,originX:1,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:332}]},{name:"JIS_RC_10",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:334},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:335},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:336}]},{name:"JIS_RC_15",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:338},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:339},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:340}]},{name:"JIS_RC_18",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:342},{angle:45,originX:1,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:343},{angle:45,originX:2,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:344}]},{name:"JIS_RC_30",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:346},{angle:45,originX:1,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:347},{angle:45,originX:2,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:348}]},{name:"JIS_STN_1E",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:350},{angle:45,originX:.705,originY:0,deltaX:0,deltaY:1,dashes:[1,-.5],sourceLine:351}]},{name:"JIS_STN_2.5",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.5,dashes:[],sourceLine:353},{angle:45,originX:1.765,originY:0,deltaX:0,deltaY:2.5,dashes:[1.2,-.5],sourceLine:354}]},{name:"JIS_WOOD",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[],sourceLine:356}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:359}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:6.35,dashes:[6.35,-6.35,0,-6.35,0,-6.35],sourceLine:361}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:363},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:364}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:366},{angle:60,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:367},{angle:120,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:368}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:370},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:371},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:372}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:374},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:375},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:376},{angle:0,originX:0,originY:3.96875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:377}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.38125,dashes:[],sourceLine:379},{angle:45,originX:1.6838,originY:0,deltaX:0,deltaY:2.38125,dashes:[0,-2.38125],sourceLine:380}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:382},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:383}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:385},{angle:60,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:386},{angle:120,originX:1.5875,originY:2.7496306704,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:387}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:389},{angle:45,originX:0,originY:1.5875,deltaX:0,deltaY:3.175,dashes:[],sourceLine:390}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[3.175,-22.225],sourceLine:392},{angle:90,originX:1.5875,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.5875,-42.4065904724],sourceLine:393},{angle:90,originX:1.984375,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:394},{angle:90,originX:1.190625,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:395},{angle:60,originX:2.38125,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:396},{angle:120,originX:.79375,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:397}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:399},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-3.175],sourceLine:400}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:402},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:403},{angle:0,originX:-2.38125,originY:4.1244459802,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:404}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:406},{angle:90,originX:3.175,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:407}]}],issues:[]};var vr=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(vr||{}),Ar=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(Ar||{}),ba=(i=>(i[i.HatchObject=0]="HatchObject",i[i.GradientObject=1]="GradientObject",i))(ba||{}),_a=(i=>(i[i.PreDefinedGradient=0]="PreDefinedGradient",i[i.UserDefinedGradient=1]="UserDefinedGradient",i))(_a||{});const Bh=class Bh extends et{constructor(){super(),this._areasFromLoopsCache=null,this._normal=new A(0,0,1),this._gradientAngle=0,this._elevation=0,this._geo=new de,this._isSolidFill=!1,this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1,this._patternName="",this._patternNameSet=!1,this._patternType=1,this._patternAngle=0,this._patternAngleSet=!1,this._patternScale=1,this._patternScaleSet=!1,this._associative=!1,this._associativeSet=!1,this._backgroundColor=void 0,this._backgroundColorSet=!1,this._patternDouble=!1,this._patternDoubleSet=!1,this._hatchStyle=0,this._hatchStyleSet=!1,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._pixelSize=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||fr(this.getEffectivePatternName())}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=wt.instance().getVar(E.HPCOLOR,t);return e instanceof X&&e.colorMethod!==exports.AcCmColorMethod.None?e.clone():t.cecolor.clone()}set color(t){this.setEntityColor(t)}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t??"",this._isSolidFill=fr(this._patternName),this._patternNameSet=!0,this.updatePredefinedPatternDefinitionLines()}get patternType(){return this._patternType}set patternType(t){this._patternType=t,t!==1&&this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1),this.updatePredefinedPatternDefinitionLines()}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t,this._patternAngleSet=!0}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}get annotative(){return Se(this)}set annotative(t){me(this,t)}get associative(){return this._associative}set associative(t){this._associative=!!t,this._associativeSet=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t==null?void 0:t.clone(),this._backgroundColorSet=!0}get patternDouble(){return this._patternDouble}set patternDouble(t){this._patternDouble=!!t,this._patternDoubleSet=!0}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t,this._hatchStyleSet=!0}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(t){this._hatchObjectType=t}get gradientAngle(){return this._gradientAngle}set gradientAngle(t){this._gradientAngle=t}get gradientShift(){return this._gradientShift}set gradientShift(t){this._gradientShift=t}get gradientType(){return this._gradientType}set gradientType(t){this._gradientType=t}get gradientName(){return this.isGradient&&this._gradientName.trim()===""?vf:this._gradientName}set gradientName(t){this._gradientName=t??""}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(t){this._gradientOneColorMode=t}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(t){this._shadeTintValue=t}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(t){this._gradientStartColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(t){this._gradientEndColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize=t}applyPatternDefaultsFromSysVars(t){const e=wt.instance();if(!this.hasExplicitLayer()){const n=e.getVar(E.HPLAYER,t);this.shouldUseSysVarOverride(n)&&(this.layer=n)}if(!this.hasExplicitTransparency()){const n=this.parseHpTransparency(e.getVar(E.HPTRANSPARENCY,t));n&&(this.transparency=n)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(E.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const n=e.getVar(E.HPNAME,t);this._patternName=typeof n=="string"?n:"",this._patternNameSet=!0}if(!this._patternAngleSet){const n=e.getVar(E.HPANG,t);this._patternAngle=typeof n=="number"&&Number.isFinite(n)?n:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(E.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const n=e.getVar(E.HPASSOC,t);this._associative=typeof n=="number"?n!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(E.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const n=e.getVar(E.HPDOUBLE,t);this._patternDouble=typeof n=="number"?n!==0:!1,this._patternDoubleSet=!0}this.updatePredefinedPatternDefinitionLines()}getEffectivePatternName(){if(this._patternNameSet)return this._patternName;const t=this.database,e=wt.instance().getVar(E.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=wt.instance().getVar(E.HPANG,t);return typeof e=="number"&&Number.isFinite(e)?e:this._patternAngle}getRenderablePatternAngle(){return!this._definitionLinesAutoGenerated&&this._definitionLines.length>0?0:this.getEffectivePatternAngle()}getEffectivePatternScale(){if(this._patternScaleSet)return this._patternScale;const t=this.database;return this.normalizePatternScale(wt.instance().getVar(E.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=wt.instance().getVar(E.HPASSOC,t);return typeof e=="number"?e!==0:this._associative}normalizePatternScale(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}normalizeHatchStyle(t){return typeof t!="number"||!Number.isFinite(t)?1:t===0?0:t===2?2:1}shouldUseSysVarOverride(t){if(typeof t!="string")return!1;const e=t.trim().toLowerCase();return e!==""&&e!=="."&&e!=="use current"}parseHpBackgroundColor(t){if(t instanceof X)return t.colorMethod===exports.AcCmColorMethod.None?void 0:t.clone();if(typeof t!="string")return;const e=t.trim().toLowerCase();if(!(!e||e==="."||e==="none"))return X.fromString(t)}parseHpTransparency(t){if(t instanceof St)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return St.fromString(e);const n=Number(e);if(Number.isInteger(n)&&n>=0&&n<=90){const r=new St;return r.percentage=n,r}}getDxfDefinitionLines(t){if(!this._definitionLinesAutoGenerated||t===0)return this._definitionLines;const e=Math.cos(t),n=Math.sin(t),r=s=>({x:s.x*e-s.y*n,y:s.x*n+s.y*e});return this._definitionLines.map(s=>({angle:s.angle+t,base:r(s.base),offset:r(s.offset),dashLengths:s.dashLengths}))}updatePredefinedPatternDefinitionLines(t=this.getEffectivePatternName(),e=this.getEffectivePatternScale()){if(this.patternType!==1||!(this._definitionLinesAutoGenerated||this._definitionLines.length===0))return;const r=t.trim().toUpperCase();if(!r||fr(r)){this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1;return}const s=this.normalizePatternScale(e);if(this._definitionLinesAutoGenerated&&this._definitionLinesPatternName===r&&this._definitionLinesPatternScale===s)return;const a=Hp.patterns.find(o=>o.name.trim().toUpperCase()===r);if(!a){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=a.lines.map(o=>{const c=o.angle*Math.PI/180,l=Math.cos(c),h=Math.sin(c);return{angle:c,base:{x:o.originX*s,y:o.originY*s},offset:{x:(o.deltaX*l-o.deltaY*h)*s,y:(o.deltaX*h+o.deltaY*l)*s},dashLengths:o.dashes.map(u=>u*s)}}),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}add(t){this._geo.add(t),this.invalidateAreasFromLoopsCache()}invalidateAreasFromLoopsCache(){this._areasFromLoopsCache=null}buildAreasFromLoops(){if(this._areasFromLoopsCache!=null)return this._areasFromLoopsCache;const t=this._geo.loops;if(t.length===0)return this._areasFromLoopsCache=[],this._areasFromLoopsCache;if(t.length===1)return this._areasFromLoopsCache=[this._geo],this._areasFromLoopsCache;const e=this._geo.buildHierarchy(),n=[],r=(s,a)=>{if(s.index>=0&&a%2===0){const o=new de;o.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&o.add(t[c.index])}),n.push(o)}s.children.forEach(o=>r(o,a+1))};return e.children.forEach(s=>r(s,0)),this._areasFromLoopsCache=n.length>0?n:[this._geo],this._areasFromLoopsCache}getCalculatedAreaValue(){const t=this.buildAreasFromLoops();return t.length===0?0:t.reduce((e,n)=>e+n.area,0)}get area(){return this.getCalculatedAreaValue()}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new H;const e=new H;return t.forEach(n=>{const r=n.box;e.union(new H().setFromPoints([ce({x:r.min.x,y:r.min.y,z:this._elevation},this._normal),ce({x:r.max.x,y:r.min.y,z:this._elevation},this._normal),ce({x:r.max.x,y:r.max.y,z:this._elevation},this._normal),ce({x:r.min.x,y:r.max.y,z:this._elevation},this._normal)]))}),e}subGetIntersectCurves(){return Gx(this._geo.loops,this._elevation,this._normal)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:vr[0],value:0},{label:vr[1],value:1},{label:vr[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}},{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"associative",type:"boolean",editable:!0,accessor:{get:()=>this.associative,set:t=>{this.associative=t}}},{name:"backgroundColor",type:"color",editable:!0,accessor:{get:()=>this.backgroundColor,set:t=>{this.backgroundColor=t}}},{name:"patternDouble",type:"boolean",editable:!0,accessor:{get:()=>this.patternDouble,set:t=>{this.patternDouble=t}}},{name:"isGradient",type:"boolean",editable:!1,accessor:{get:()=>this.isGradient}},{name:"isSolidFill",type:"boolean",editable:!0,accessor:{get:()=>this.isSolidFill,set:t=>{this.isSolidFill=t}}},{name:"hatchStyle",type:"enum",editable:!0,options:[{label:Ar[0],value:0},{label:Ar[1],value:1},{label:Ar[2],value:2}],accessor:{get:()=>this.hatchStyle,set:t=>{this.hatchStyle=t}}},{name:"gradientAngle",type:"float",editable:!0,accessor:{get:()=>this.gradientAngle,set:t=>{this.gradientAngle=t}}},{name:"gradientName",type:"string",editable:!0,accessor:{get:()=>this.gradientName,set:t=>{this.gradientName=t}}},{name:"gradientType",type:"enum",editable:!0,options:[{label:_a[0],value:0},{label:_a[1],value:1}],accessor:{get:()=>this.gradientType,set:t=>{this.gradientType=t}}},{name:"gradientShift",type:"float",editable:!0,accessor:{get:()=>this.gradientShift,set:t=>{this.gradientShift=t}}},{name:"gradientOneColorMode",type:"boolean",editable:!0,accessor:{get:()=>this.gradientOneColorMode,set:t=>{this.gradientOneColorMode=t}}},{name:"shadeTintValue",type:"float",editable:!0,accessor:{get:()=>this.shadeTintValue,set:t=>{this.shadeTintValue=t}}},{name:"gradientStartColor",type:"int",editable:!0,accessor:{get:()=>this.gradientStartColor??0,set:t=>{this.gradientStartColor=t}}},{name:"gradientEndColor",type:"int",editable:!0,accessor:{get:()=>this.gradientEndColor??0,set:t=>{this.gradientEndColor=t}}},{name:"hatchObjectType",type:"enum",editable:!0,options:[{label:ba[0],value:0},{label:ba[1],value:1}],accessor:{get:()=>this.hatchObjectType,set:t=>{this.hatchObjectType=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subGetGripPoints(){return this.associative?[]:this.collectBoundaryGripPoints()}subMoveGripPointsAt(t,e){return this.associative?this:(Et(t,n=>{this.moveBoundaryGripPointAt(n,e)}),this.invalidateAreasFromLoopsCache(),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,n=new Set,r=s=>{const a=`${s.x},${s.y},${s.z??0}`;n.has(a)||(n.add(a),t.push(new x(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof ot){const a=s.numberOfVertices;for(let o=0;o<a;o++){const c=s.getPointAt(o);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(a=>{if(a instanceof yt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});else if(a instanceof tt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e}),r({x:a.midPoint.x,y:a.midPoint.y,z:e});else if(a instanceof qe){r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});const o=a.getPoint(.5);r({x:o.x,y:o.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let n=0;const r=this._elevation,s=new Set,a=(o,c)=>{const l=`${o.x},${o.y},${o.z??0}`;s.has(l)||(s.add(l),n===t&&c(),n++)};this._geo.loops.forEach(o=>{if(o instanceof ot){const c=o.numberOfVertices;for(let l=0;l<c;l++){const h=o.vertices[l];h&&a({x:h.x,y:h.y,z:r},()=>{yr(o.vertices,l,e)})}return}o.curves.forEach(c=>{if(c instanceof yt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof tt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),a({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof qe){a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);a({x:l.x,y:l.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"mid",e))}})})}moveCircArc2dGripPoint(t,e,n){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"mid":{const s=t.midPoint,a=new tt(t.startPoint,{x:s.x+n.x,y:s.y+n.y},t.endPoint);t.center=a.center,t.radius=a.radius,t.startAngle=a.startAngle,t.endAngle=a.endAngle,t.clockwise=a.clockwise;break}}}moveEllipseArc2dGripPoint(t,e,n){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+n.y-r.y,s.x+n.x-r.x);break}case"mid":{const s=t.getPoint(.5),a=s.x+n.x-t.center.x,o=s.y+n.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(a,o);if(c>0&&l>0){const h=l/c;t.majorAxisRadius*=h,t.minorAxisRadius*=h}break}}}subGetOsnapPoints(t,e,n,r){const s=this._elevation,a=[];if(this._geo.loops.forEach(o=>{var c;if(o instanceof ot){const l=o,h=l.numberOfVertices;if(h===0)return;switch(t){case T.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new x(d.x,d.y,s))}break;case T.MidPoint:case T.Nearest:case T.Perpendicular:case T.Tangent:{const u=o.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Yr(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===T.MidPoint?r.push(...g):a.push(...g)}break}}return}o.curves.forEach(l=>{if(l instanceof yt){const h=[];Yr(l.startPoint,l.endPoint,void 0,s,t,e,h),t===T.MidPoint?r.push(...h):t===T.Nearest||t===T.Perpendicular||t===T.Tangent?a.push(...h):r.push(...h)}else if(l instanceof tt)switch(t){case T.EndPoint:r.push(new x(l.startPoint.x,l.startPoint.y,s),new x(l.endPoint.x,l.endPoint.y,s));break;case T.MidPoint:r.push(new x(l.midPoint.x,l.midPoint.y,s));break;case T.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new x(h.x,h.y,s));break}case T.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}case T.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}}else if(l instanceof qe)switch(t){case T.EndPoint:r.push(new x(l.startPoint.x,l.startPoint.y,s),new x(l.endPoint.x,l.endPoint.y,s));break;case T.MidPoint:{const h=l.getPoint(.5);r.push(new x(h.x,h.y,s));break}case T.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new x(h.x,h.y,s));break}case T.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}case T.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new x(u.x,u.y,s)));break}}})}),(t===T.Nearest||t===T.Perpendicular||t===T.Tangent)&&a.length>0){const o=ye(e,a);r.length=0,o&&r.push(o)}}get directBatchPrimitive(){return!this.isSolidFill||this.isGradient||this.buildAreasFromLoops().length>1?null:"area"}resolveAnnotativePresentation(){var o;const t=this.getEffectivePatternScale(),e=Wt(this),n=e.length>0||pe(this);let r=t,s,a;if(n&&e.length>0){s=He(e,(o=this.database)==null?void 0:o.cannoscale)??e.find(l=>l.isDefault)??e[0],a=Ge(e,s);const c=s.contextData;c instanceof Fi&&c.patternScale>0?r=c.patternScale:r=Be(Re(t,e),s.scale.scaleFactor)}else n&&(a=Gn(this).annotationScale);return{patternScale:r,preferred:s,annotationScale:a}}subWorldDraw(t){var s;const e=this.resolveAnnotativePresentation(),n=this._patternScale,r=this._patternScaleSet;this._patternScale=e.patternScale,this._patternScaleSet=!0;try{this.updatePredefinedPatternDefinitionLines();const a=t.subEntityTraits;a.fillType={solidFill:this.isSolidFill,patternAngle:this.getRenderablePatternAngle(),definitionLines:this.definitionLines,backgroundColor:(s=this.backgroundColor)==null?void 0:s.clone(),gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},a.drawOrder=-1;const o=this.buildAreasFromLoops();let c;if(o.length===0)c=t.area(this._geo);else if(o.length===1)c=t.area(o[0]);else{const l=o.map(h=>t.area(h));c=t.group(l)}if(c&&this.annotative){let l=e.annotationScale;l||(l={drawnScaleFactor:1,supportedScaleFactors:[1],supportedScaleNames:[]});const h=c.userData??(c.userData={});h.annotationScale=l}return c}finally{this._patternScale=n,this._patternScaleSet=r,this.updatePredefinedPatternDefinitionLines()}}transformBy(t){const e=t.elements,n=new is(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(n),this.invalidateAreasFromLoopsCache(),this._elevation=new x(0,0,this._elevation).applyMatrix4(t).z,this._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize();const r=new x(1,0,0).applyMatrix4(t),s=new x().applyMatrix4(t),a=new x(r).sub(s);if(a.length()>0){const o=Math.atan2(a.y,a.x);this._patternAngle=this.getEffectivePatternAngle()+o,this._gradientAngle+=o,this._patternScale=this.getEffectivePatternScale()*a.length(),this._patternAngleSet=!0,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}return this}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops,n=this.getEffectivePatternName(),r=this.getEffectivePatternAngle(),s=this.getEffectivePatternScale();if(this.updatePredefinedPatternDefinitionLines(n,s),t.writeSubclassMarker("AcDbHatch"),t.writePoint3d(10,{x:0,y:0,z:this.elevation}),t.writeVector3d(210,this.normal),t.writeString(2,n||(this.isSolidFill?Si:wf)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((a,o)=>{const c=o===0;if(a instanceof ot){const l=a.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,a.closed?1:0),t.writeInt16(93,l.length);for(const d of l)t.writePoint2d(10,d),h&&t.writeDouble(42,d.bulge??0);t.writeInt16(97,0);return}if(a instanceof _n){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,a.numberOfEdges);for(const h of a.curves){if(h instanceof yt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof tt){t.writeInt16(72,2),t.writePoint2d(10,h.center),t.writeDouble(40,h.radius),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.closed?h.startAngle+Math.PI*2:h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof qe){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new C(h.majorAxisRadius*Math.cos(h.rotation),h.majorAxisRadius*Math.sin(h.rotation));t.writePoint2d(11,u);const d=h.majorAxisRadius===0?0:h.minorAxisRadius/h.majorAxisRadius;t.writeDouble(40,d),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.closed?h.startAngle+Math.PI*2:h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof Xt){const u=h.knots,d=h.controlPoints,g=h.weights,f=h.fitPoints,p=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,p?1:0),t.writeInt16(74,h.closed?1:0),t.writeInt16(95,u.length),t.writeInt16(96,d.length),u.forEach(m=>t.writeDouble(40,m)),d.forEach((m,y)=>{t.writePoint2d(10,m),p&&t.writeDouble(42,g[y]??1)}),t.writeInt16(97,(f==null?void 0:f.length)??0),f==null||f.forEach(m=>t.writePoint2d(11,m))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,r),t.writeDouble(41,s),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.getDxfDefinitionLines(r).forEach(a=>{t.writeAngle(53,a.angle),t.writeDouble(43,a.base.x),t.writeDouble(44,a.base.y),t.writeDouble(45,a.offset.x),t.writeDouble(46,a.offset.y),t.writeInt16(79,a.dashLengths.length),a.dashLengths.forEach(o=>t.writeDouble(49,o))}),this._pixelSize!=null&&t.writeDouble(47,this._pixelSize),this.isGradient){t.writeInt16(450,this._hatchObjectType),t.writeInt16(451,0),t.writeDouble(460,this._gradientAngle),t.writeDouble(461,this._gradientShift),t.writeInt16(452,this._gradientOneColorMode?1:0),t.writeDouble(462,this._shadeTintValue);const a=this._gradientStartColor,o=this._gradientEndColor,c=a!=null&&o!=null?2:a!=null||o!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=Le.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};a!=null&&l(0,a),o!=null&&l(1,o),t.writeString(470,this.gradientName)}return t.writeInt16(98,0),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbHatch"),this.definitionLines.length=0;let e=this.elevation,n=this.normal.x,r=this.normal.y,s=this.normal.z,a=this.patternAngle*180/Math.PI,o=0,c=!1,l=!1,h=!1,u=[],d=null,g=[],f=null,p="type",m=0,y=!1,b=null,_=!1,w=0,k;const P=F=>{w===0?this.gradientStartColor=F:this.gradientEndColor=F,w++,k=void 0},v=()=>{if(k==null)return;const F=Le.getColorByIndex(k);F!=null?P(F):k=void 0},S=()=>{d&&(u.push(d),d=null)},I=()=>{if(S(),u.length===0)return;const F=new ot;F.closed=h,u.forEach((q,L)=>{F.addVertexAt(L,{x:q.x,y:q.y,bulge:q.bulge??0})}),this.add(F),u=[]},M=()=>{if(g.length===0)return;const F=[];for(const L of g)if(L.kind==="line")F.push(new yt({x:L.sx,y:L.sy},{x:L.ex,y:L.ey}));else if(L.kind==="arc")F.push(new tt({x:L.cx,y:L.cy},L.radius,L.startDeg*Math.PI/180,L.endDeg*Math.PI/180,!L.isCcw));else if(L.kind==="ellipse"){const $=Math.hypot(L.mx,L.my),ct=$*L.ratio;let B=L.startDeg*Math.PI/180,Ft=L.endDeg*Math.PI/180;const ne=Math.atan2(L.my,L.mx);L.isCcw||(B=Math.PI*2-B,Ft=Math.PI*2-Ft),F.push(new qe({x:L.cx,y:L.cy,z:0},$,ct,B,Ft,!L.isCcw,ne))}else{const $=Xt.fromDwgSplineEdge({degree:L.degree,numberOfControlPoints:L.controlPoints.length,numberOfKnots:L.knots.length,numberOfFitData:L.fitPoints.length,knots:L.knots,controlPoints:L.controlPoints.map(ct=>({x:ct.x,y:ct.y,z:0,weight:L.rational?ct.weight??1:void 0})),fitDatum:L.fitPoints.map(ct=>({x:ct.x,y:ct.y,z:0})),startTangent:null,endTangent:null});$&&F.push($)}const q=_n.buildFromEdges(F);q.length===1?this.add(q[0]):F.length>0&&this.add(new _n(F)),g=[],f=null},O=()=>{c?I():M()},N=()=>{f&&(g.push(f),f=null)},nt=()=>{N(),O(),m=Math.max(0,m-1),m===0&&(_=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const F=t.readItem();if(!F)break;const q=Number(F.code),L=Number(F.value);if(y||_){switch(q){case 75:this.hatchStyle=L,_=!0;break;case 76:this.patternType=L;break;case 52:a=L;break;case 41:this.patternScale=L;break;case 77:break;case 78:y=!0;break;case 53:b?this.definitionLines.push(b):this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1),b={angle:L*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:b&&(b.base.x=L);break;case 44:b&&(b.base.y=L);break;case 45:b&&(b.offset.x=L);break;case 46:b&&(b.offset.y=L);break;case 79:break;case 49:b&&b.dashLengths.push(L);break;case 47:this.pixelSize=L;break;case 99:break;case 450:this.hatchObjectType=L,this.gradientStartColor=void 0,this.gradientEndColor=void 0,w=0,k=void 0;break;case 451:break;case 452:this.gradientOneColorMode=L!==0;break;case 453:break;case 460:this.gradientAngle=L;break;case 461:this.gradientShift=L;break;case 462:this.shadeTintValue=L;break;case 463:v();break;case 63:k=L;break;case 421:P(L);break;case 470:v(),this.gradientName=String(F.value);break}continue}switch(q){case 10:c||f&&f.kind!=="line"&&f.kind!=="arc"&&f.kind!=="ellipse"&&f.kind,m>0&&c?(S(),d={x:L,y:0}):(f==null?void 0:f.kind)==="line"&&p==="type"?f.sx=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cx=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.push({x:L,y:0});break;case 20:m>0&&c&&d?d.y=L:(f==null?void 0:f.kind)==="line"&&p==="type"?f.sy=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cy=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].y=L);break;case 30:m<=0&&!_&&(e=L);break;case 2:this.patternName=String(F.value);break;case 70:this.isSolidFill=L!==0;break;case 71:this.associative=L!==0;break;case 91:m=L;break;case 92:m>0&&(u.length>0||g.length>0||f)&&(N(),O()),o=L,c=(o&2)!==0,l=!1,h=!1,u=[],g=[],f=null,p="type";break;case 72:c?l=L!==0:(N(),L===1?(f={kind:"line",sx:0,sy:0,ex:0,ey:0},p="type"):L===2?f={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:L===3?f={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:L===4?f={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:f=null);break;case 73:c?h=L!==0:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.isCcw=L!==0:(f==null?void 0:f.kind)==="spline"&&(f.rational=L!==0);break;case 74:(f==null?void 0:f.kind)==="spline"&&(f.closed=L!==0);break;case 93:break;case 42:c&&l&&d?d.bulge=L:(f==null?void 0:f.kind)==="spline"&&f.rational&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].weight=L);break;case 11:(f==null?void 0:f.kind)==="line"?(f.ex=L,p="line-end"):(f==null?void 0:f.kind)==="ellipse"?f.mx=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.push({x:L,y:0});break;case 21:(f==null?void 0:f.kind)==="line"?f.ey=L:(f==null?void 0:f.kind)==="ellipse"?f.my=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.length>0&&(f.fitPoints[f.fitPoints.length-1].y=L);break;case 40:(f==null?void 0:f.kind)==="arc"?f.radius=L:(f==null?void 0:f.kind)==="ellipse"?f.ratio=L:(f==null?void 0:f.kind)==="spline"&&f.knots.push(L);break;case 50:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.startDeg=L);break;case 51:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.endDeg=L);break;case 94:(f==null?void 0:f.kind)==="spline"&&(f.degree=L);break;case 95:(f==null?void 0:f.kind)==="spline"&&(f.expectedKnots=L);break;case 96:(f==null?void 0:f.kind)==="spline"&&(f.expectedControls=L);break;case 97:if((f==null?void 0:f.kind)==="spline"&&!f.fitCountSeen&&(f.controlPoints.length>0||f.knots.length>0)){f.expectedFits=L,f.fitCountSeen=!0;break}nt();break;case 75:N(),O(),m=0,_=!0,this.hatchStyle=L;break;case 210:n=L;break;case 220:r=L;break;case 230:s=L;break}}f&&(g.push(f),f=null),O(),b&&this.definitionLines.push(b),v(),this.elevation=e;const W=new A(n,r,s);return W.lengthSq()>0&&(this.normal=W),this.patternAngle=a*Math.PI/180,this}};Bh.typeName="Hatch";let Xn=Bh;const _d=new x,xd=new x,ao=class ao extends Ot{constructor(t,e){super(),this._geoData=null,this._normal=null,this._thickness=0,t!==void 0&&e!==void 0&&(this._geo=new Bt(t,e))}get dxfTypeName(){return"LINE"}get _geo(){return this._geoData==null&&(this._geoData=new Bt(new x,new x)),this._geoData}set _geo(t){this._geoData=t}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){let t=this._normal;return t==null&&(t=new A(0,0,1),this._normal=t),t}set normal(t){this.normal.copy(t).normalize()}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"line",line:this._geo.clone(),extent:"bounded"}]}get closed(){return!1}get area(){return 0}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subMoveGripPointsAt(t,e){return Et(t,n=>{switch(n){case 0:this.transformBy(z.makeTranslation(e));break;case 1:this.startPoint.add(e);break;case 2:this.endPoint.add(e);break}}),this}subGetOsnapPoints(t,e,n,r){const s=this.startPoint,a=this.endPoint;switch(t){case T.EndPoint:r.push(s),r.push(a);break;case T.MidPoint:r.push(this.midPoint);break;case T.Nearest:{const o=this._geo.project(e);r.push(o)}break;case T.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case T.Tangent:break}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this.startPoint,n=this.endPoint,r=[new x(e.x,e.y,0),new x(n.x,n.y,0)];return t.lines(r)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLine");let e=0,n=0,r=0,s=0,a=0,o=0,c=this.thickness,l=0,h=0,u=1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),f=Number(d.value);switch(g){case 10:e=f;break;case 20:n=f;break;case 30:r=f;break;case 11:s=f;break;case 21:a=f;break;case 31:o=f;break;case 39:c=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break}}return(l!==0||h!==0||u!==1)&&l*l+h*h+u*u>0&&this.normal.set(l,h,u).normalize(),this.thickness=c,_d.set(e,n,r),xd.set(s,a,o),this._geo=new Bt(_d,xd),this}getOffsetCurves(t){const e=this._geo.offset(t);return[new ao(e.startPoint,e.endPoint)]}getOffsetSideAtPoint(t){const e=this.startPoint,n=this.endPoint;return(n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x)>=0?1:-1}};ao.typeName="Line";let $i=ao;class fh{constructor(t){this.db=t}createDefaultLayer(){const t=new X;return t.colorIndex=7,this.db.tables.layerTable.add(new ls({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new vn({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new vn({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new vn({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Eo({name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Vt({name:gt,dimtxsty:gt}))}createDefaultLayout(){const t=this.db.tables.blockTable.modelSpace,e=new In;if(e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=t.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.objects.layout.setAt(e.layoutName,e),t.layoutId=e.objectId,!this.db.tables.blockTable.getAt(lt.PAPER_SPACE_NAME_PREFIX)){const n=new lt;n.name=lt.PAPER_SPACE_NAME_PREFIX,this.db.tables.blockTable.add(n);const r=new In;r.layoutName="Layout1",r.tabOrder=1,r.blockTableRecordId=n.objectId,r.limits.min.copy({x:0,y:0}),r.limits.max.copy({x:12,y:9}),r.extents.min.copy({x:0,y:0,z:0}),r.extents.max.copy({x:12,y:9,z:0}),this.db.objects.layout.setAt(r.layoutName,r),n.layoutId=r.objectId}}createArrowBlock(){this.ensureArrowBlock("_CAXARROW"),this.ensureArrowBlock("_CLOSEDFILLED")}ensureArrowBlock(t){if(!t||this.db.tables.blockTable.getAt(t))return;const e=t.toUpperCase(),n=new lt;n.name=t;const r=(o=.125)=>{const c=new Xn;c.patternName=Si;const l=new _n;l.add(new yt({x:0,y:0},{x:-1,y:o})),l.add(new yt({x:-1,y:o},{x:-1,y:-o})),l.add(new yt({x:-1,y:-o},{x:0,y:0})),c.add(l),this.appendArrowEntity(n,c)},s=(o=.125)=>{this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-1,y:o,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-1,y:-o,z:0}))},a=(o,c)=>{if(c){const l=new Xn;l.patternName=Si;const h=new _n,u=o;h.add(new yt({x:u,y:0},{x:0,y:u})),h.add(new yt({x:0,y:u},{x:-u,y:0})),h.add(new yt({x:-u,y:0},{x:0,y:-u})),h.add(new yt({x:0,y:-u},{x:u,y:0})),l.add(h),this.appendArrowEntity(n,l)}else this.appendArrowEntity(n,this.lineEntity({x:-o,y:0,z:0},{x:o,y:0,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:-o,z:0},{x:0,y:o,z:0}))};switch(e){case"_CAXARROW":case"_CLOSEDFILLED":case"":r();break;case"_CLOSED":s(),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.125,z:0},{x:-1,y:-.125,z:0}));break;case"_CLOSEDBLANK":s(),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.125,z:0},{x:-1,y:-.125,z:0}));break;case"_OPEN":s(.1667);break;case"_OPEN30":s(.2679);break;case"_OPEN90":this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-.5,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:0,z:0},{x:-.5,y:-.5,z:0}));break;case"_OBLIQUE":case"_ARCHTICK":this.appendArrowEntity(n,this.lineEntity({x:-.5,y:-.5,z:0},{x:.5,y:.5,z:0}));break;case"_DOT":a(.25,!0);break;case"_DOTSMALL":case"_SMALL":a(.125,!0);break;case"_DOTBLANK":a(.25,!1);break;case"_BOXFILLED":{const o=new Xn;o.patternName=Si;const c=new _n;c.add(new yt({x:-1,y:-.5},{x:0,y:-.5})),c.add(new yt({x:0,y:-.5},{x:0,y:.5})),c.add(new yt({x:0,y:.5},{x:-1,y:.5})),c.add(new yt({x:-1,y:.5},{x:-1,y:-.5})),o.add(c),this.appendArrowEntity(n,o)}break;case"_BOXBLANK":this.appendArrowEntity(n,this.lineEntity({x:-1,y:-.5,z:0},{x:0,y:-.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:-.5,z:0},{x:0,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:0,y:.5,z:0},{x:-1,y:.5,z:0})),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.5,z:0},{x:-1,y:-.5,z:0}));break;case"_DATUMFILLED":r(.5);break;case"_DATUMBLANK":s(.5),this.appendArrowEntity(n,this.lineEntity({x:-1,y:.5,z:0},{x:-1,y:-.5,z:0}));break;case"_ORIGIN":case"_ORIGIN2":a(.5,!1),a(.125,!0);break;case"_INTEGRAL":this.appendArrowEntity(n,this.lineEntity({x:0,y:-.5,z:0},{x:0,y:.5,z:0}));break;case"_NONE":break;default:r();break}this.db.tables.blockTable.add(n)}appendArrowEntity(t,e){e.color=new X().setByBlock(),t.appendEntity(e)}lineEntity(t,e){return new $i(t,e)}}const qc=Math.PI/200;class Gp{constructor(t){this.database=t}formatLength(t,e){const n=this.createContext(e);return ii(t,n)}formatPoint2d(t,e){const n=this.createContext(e);return`${ii(t.x,n)}, ${ii(t.y,n)}`}formatPoint3d(t,e){const n=this.createContext(e);return`${ii(t.x,n)}, ${ii(t.y,n)}, ${ii(t.z,n)}`}formatAngle(t,e){const n=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?Yw(t,this.database.angbase,this.database.angdir):D.normalizeAngle(t);return Xw(s,n)}createContext(t){return{lunits:this.database.lunits,luprec:$r(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:$r(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function ii(i,t){let e;switch(t.lunits){case xt.Scientific:e=lc(Kw(i,t.luprec),t);break;case xt.Engineering:e=Zw(i,t);break;case xt.Architectural:e=Qw(i,t);break;case xt.Fractional:e=lc(Jw(i,t),t);break;case xt.WindowsDesktop:case xt.Decimal:default:e=lc(sr(i,t.luprec),t)}return Wp(e,jw(i,t),t)}function Xw(i,t){let e;switch(t.aunits){case Ht.DegreesMinutesSeconds:e=Kp(i,t);break;case Ht.Gradians:e=nv(i,t);break;case Ht.Radians:e=ev(i,t);break;case Ht.SurveyorsUnits:e=iv(i,t);break;case Ht.DecimalDegrees:default:e=tv(i,t)}return Wp(e,Vw(i,t),t)}function Yw(i,t,e){let n=i-t;return e===1&&(n=-n),D.normalizeAngle(n)}function ph(i){const t=i.showUnits?'"':"";return i.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function $r(i,t=0,e=8){return Number.isFinite(i)?Math.max(t,Math.min(e,Math.round(i))):t}function rr(i){return Object.is(i,-0)?0:i}function Wp(i,t,e){return!e.showApproximate||!t?i:`~ ${i}`}function jw(i,t){if(!Number.isFinite(i))return!1;const e=Hw(i,t);return mh(i,e)}function Vw(i,t){if(!Number.isFinite(i))return!1;if(t.aunits===Ht.SurveyorsUnits)return Uw(i,t.auprec);const e=Gw(i,t);return mh(i,e)}function Uw(i,t){const n=((90-D.radToDeg(i))%360+360)%360,r=Zp(n),s=Math.min(Math.abs(n-r.base),Math.abs(r.base+90-n)),a=D.degToRad(s),o=$p(a,t);return mh(a,o)}function Hw(i,t){const e=rr(i);switch(t.lunits){case xt.Scientific:return Ww(e,t.luprec);case xt.Engineering:case xt.Architectural:case xt.Fractional:return $w(e,t);case xt.WindowsDesktop:case xt.Decimal:default:return ki(e,t.luprec)}}function Gw(i,t){const e=rr(i);switch(t.aunits){case Ht.DegreesMinutesSeconds:return $p(e,t.auprec);case Ht.Gradians:return ki(e/qc,t.auprec)*qc;case Ht.Radians:return ki(e,t.auprec);case Ht.DecimalDegrees:default:return D.degToRad(ki(D.radToDeg(e),t.auprec))}}function ki(i,t){if(!Number.isFinite(i))return 0;const e=10**t;return Math.round(rr(i)*e)/e}function Ww(i,t){if(!Number.isFinite(i))return 0;const e=rr(i);if(e===0)return 0;const n=e.toExponential(t);return Number(n)}function $w(i,t){if(!Number.isFinite(i))return 0;const e=i<0?-1:1,n=Math.abs(i),r=Math.floor(n/12),s=n-r*12;if(t.lunits===xt.Architectural||t.lunits===xt.Fractional){const a=1<<$r(t.luprec,0,8),o=qw(s,a);return e*(r*12+o)}return e*(r*12+ki(s,t.luprec))}function qw(i,t){const e=Math.floor(i),n=i-e,r=Math.round(n*t);return r>=t?e+1:e+r/t}function $p(i,t){const e=D.radToDeg(i),n=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=ki((a-o)*60,t),l=s+o/60+c/3600;return D.degToRad(n*l)}function mh(i,t){if(i===t)return!1;const e=Math.max(Math.abs(i),Math.abs(t),1);return Math.abs(i-t)>e*Number.EPSILON*8}function sr(i,t){if(!Number.isFinite(i))return"0";const e=rr(i);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function Kw(i,t){if(!Number.isFinite(i))return"0";const e=rr(i);if(e===0)return"0";const n=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!n)return"0";const[,r,s,a]=n,o=a.length<2?a.padStart(2,"0"):a;return`${r}E${s}${o}`.toUpperCase()}function Zw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=Math.floor(r/12),a=r-s*12,o=sr(a,t.luprec);return s===0?`${n}${o}${e.inchSuffix}`:`${n}${s}'${e.feetInchSeparator}${o}${e.inchSuffix}`}function Qw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=Math.floor(r/12),a=r-s*12,o=1<<$r(t.luprec,0,8),c=qp(a,o,e.fractionSeparator);return s===0?`${n}${c}${e.inchSuffix}`:`${n}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function Jw(i,t){if(!Number.isFinite(i))return"0";const e=ph(t),n=i<0?"-":"",r=Math.abs(i),s=1<<$r(t.luprec,0,8);return`${n}${qp(r,s,e.fractionSeparator)}`}function qp(i,t,e){const n=Math.floor(i),r=i-n;let s=Math.round(r*t);if(s>=t)return String(n+1);if(s===0)return String(n);const a=ov(s,t);s/=a;const o=t/a,c=`${s}/${o}`;return n===0?c:`${n}${e}${c}`}function tv(i,t){const e=D.radToDeg(i);return`${sr(e,t.auprec)}${t.showUnits?"°":""}`}function ev(i,t){return`${sr(i,t.auprec)}${t.showUnits?" rad":""}`}function nv(i,t){const e=i/qc;return`${sr(e,t.auprec)}${t.showUnits?"g":""}`}function Kp(i,t){const e=D.radToDeg(i),n=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=(a-o)*60,l=sr(c,t.auprec),h=t.showUnits?'"':"";return`${n}${s}d${o}'${l}${h}`}function iv(i,t){const n=((90-D.radToDeg(i))%360+360)%360,r=Zp(n),s=Math.min(Math.abs(n-r.base),Math.abs(r.base+90-n)),o=Kp(D.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${o} ${r.suffix}`.trim()}function Zp(i){return i<90?{prefix:"N",suffix:"E",base:0}:i<180?{prefix:"S",suffix:"E",base:90}:i<270?{prefix:"S",suffix:"W",base:180}:{prefix:"N",suffix:"W",base:270}}function lc(i,t){if(!t.showUnits||t.lunits===xt.Engineering||t.lunits===xt.Architectural)return i;const e=rv(t.insunits,t.measurement);return e?`${i}${e}`:i}function rv(i,t){return i===mt.Undefined?t===0?'"':" mm":Kx(i)?sv(i):Zx(i)?av(i):""}function sv(i){switch(i){case mt.Millimeters:return" mm";case mt.Centimeters:return" cm";case mt.Meters:return" m";case mt.Kilometers:return" km";case mt.Decimeters:return" dm";case mt.Microns:return" µm";case mt.Nanometers:return" nm";default:return""}}function av(i){switch(i){case mt.Inches:case mt.Microinches:case mt.Mils:case mt.USSurveyInch:return'"';case mt.Feet:case mt.USSurveyFeet:return"'";case mt.Miles:case mt.USSurveyMile:return" mi";case mt.Yards:case mt.USSurveyYard:return" yd";default:return""}}function ov(i,t){let e=Math.abs(i),n=Math.abs(t);for(;n!==0;){const r=n;n=e%n,e=r}return e||1}class Pe extends pt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this.ownerId=t.objectId,this._recordsByName=new Map,this._unnamedRecords=[]}get numEntries(){return this._recordsByName.size}get totalRecordCount(){return this._recordsByName.size+this._unnamedRecords.length}add(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot add symbol table records outside an active transaction.");const n=e.resolveSymbolTableName(this);t.database=this.database,this.database.commitObjectHandle(t,s=>this.hasId(s)),t.ownerId=this.objectId;const r=this.normalizeName(t.name);r?this._recordsByName.set(r,t):this._unnamedRecords.push(t),e.isRecording()&&e.recordAppend({type:"symbolTable",tableName:n},t)}remove(t){const e=this.normalizeName(t),n=this._recordsByName.get(e);return n?(this.removeRecord(n),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this.removeRecord(e),!0):!1}removeRecord(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove symbol table records outside an active transaction.");if(e.isRecording()){const n=e.resolveSymbolTableName(this);e.recordRemove({type:"symbolTable",tableName:n},t)}this.removeFromMembership(t),this.database.releaseObjectHandle(t)}removeAll(){for(const t of this._recordsByName.values())this.database.releaseObjectHandle(t);for(const t of this._unnamedRecords)this.database.releaseObjectHandle(t);this._recordsByName.clear(),this._unnamedRecords.length=0}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}getOwnerIdAt(t){return this.getIdAt(t)}newIterator(t=!1){return t?new Hn([...this._recordsByName.values(),...this._unnamedRecords]):new Hn(this._recordsByName)}normalizeName(t){return(t??"").trim().toUpperCase()}get dxfEntryCount(){return this.numEntries}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.dxfEntryCount),this}removeFromMembership(t){const e=this.normalizeName(t.name);if(e){this._recordsByName.delete(e);return}const n=this._unnamedRecords.indexOf(t);n>=0&&this._unnamedRecords.splice(n,1)}}class Qp extends Pe{constructor(t){super(t)}get modelSpace(){let t=this.getAt(lt.MODEL_SPACE_NAME);return t||(t=new lt,t.name=lt.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof et)return e}removeEntity(t){let e=!1;for(const n of this.database.tables.blockTable.newIterator())if(n.removeEntity(t)){e=!0;break}return e}getXrefs(){const t=[];for(const e of this.newIterator())e.isXref&&t.push(e);return t}getUnresolvedXrefs(){return this.getXrefs().filter(t=>t.isUnresolvedXref)}normalizeName(t){const e=(t??"").trim();if(!e)return"";if(lt.isModelSapceName(e))return lt.MODEL_SPACE_NAME;if(lt.isPaperSapceName(e)){const n=lt.PAPER_SPACE_NAME_PREFIX,r=e.substring(n.length);return n+r}return super.normalizeName(e)}}const Jp="DwgConverterLicenseError",cv=["evaluation of @mlightcad/dwg-converter has expired"],lv=["invalid @mlightcad/dwg-converter license key"];function tm(i){return i==="license_expired"||i==="license_invalid"}function yh(i){const t=i.toLowerCase();if(cv.some(e=>t.includes(e)))return"license_expired";if(lv.some(e=>t.includes(e)))return"license_invalid"}function em(i){return yh(i)??"license_invalid"}const hv=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];function nm(i){const t=i.toLowerCase();return hv.some(e=>t.includes(e))}function hc(){const i=globalThis;if(typeof i.postMessage!="function")throw new Error("Worker messaging is not available in this runtime");return i}class uv{constructor(){this.setupMessageHandler()}setupMessageHandler(){hc().onmessage=async t=>{const e=t,{id:n,input:r}=e.data;try{const s=await this.executeTask(r);this.sendResponse(n,!0,s)}catch(s){const a=s instanceof Error?s.message:String(s);this.sendResponse(n,!1,void 0,a,this.classifyTaskError(s,a))}}}sendResponse(t,e,n,r,s){const a={id:t,success:e,data:n,error:r,errorCode:s};try{hc().postMessage(a)}catch(o){const c=o instanceof Error?o.message:String(o);hc().postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyTaskError(t,e){if(t instanceof Error){const r=t.code;if(tm(r))return r;if(t.name===Jp)return em(e)}const n=yh(e);return n||this.classifyPostMessageError(e)}classifyPostMessageError(t){return nm(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"}}class zt extends Error{constructor(t,e,n){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=n==null?void 0:n.stage,this.cause=n==null?void 0:n.cause}static isLicenseErrorCode(t){return tm(t)}static isWorkerOutOfMemoryMessage(t){return nm(t)}static classifyThrownError(t){if(t instanceof Error){const n=zt.readStructuredCode(t);if(n)return n;if(t.name===Jp)return em(t.message)}const e=t instanceof Error?t.message:String(t);return zt.classifyWorkerErrorMessage(e)}static classifyWorkerErrorMessage(t){const e=yh(t);return e||(zt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error")}static from(t,e){if(t instanceof zt)return t;const n=t instanceof Error?t.message:String(t),r=zt.classifyThrownError(t);return new zt(n,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return zt.from(t.error,e)}static throwOnWorkerParseFailure(t,e="PARSE"){if(t.success)return;const n=t.error!=null?`Failed to parse drawing due to error: '${t.error}'`:"Failed to parse drawing due to an unknown worker error",r=zt.mapWorkerResultCode(t.errorCode,t.error);throw new zt(n,r,{stage:e})}static mapWorkerResultCode(t,e){switch(t){case"worker_oom":return"worker_oom";case"worker_timeout":return"worker_timeout";case"worker_error":return"worker_error";case"license_expired":return"license_expired";case"license_invalid":return"license_invalid";default:return zt.classifyWorkerErrorMessage(e??"")}}static readStructuredCode(t){const e=t.code;if(typeof e=="string")switch(e){case"license_expired":case"license_invalid":case"worker_oom":case"worker_timeout":case"worker_error":case"parse_failed":case"font_load_failed":case"fetch_failed":case"unknown":return e;default:return}}}class im extends Pe{constructor(t){super(t)}}class rm extends Pe{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class sm extends Pe{constructor(t){super(t)}}class qr extends Pe{constructor(t){super(t)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}get dxfEntryCount(){return this.totalRecordCount}resolveAt(t){this.database.ensureTextStyleDefaults();const e=[],n=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};n(t),n(this.database.textstyle),n(gt),n("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const a=r.toUpperCase();for(const o of this.newIterator())if(o.name.toUpperCase()===a)return o}return this.newIterator().next().value??void 0}get shapeFiles(){return this.newIterator(!0).toArray().filter(t=>t.isShapeFile)}get fonts(){const t=new Set;for(const e of this.newIterator()){const n=qr.normalizeFontFileName(e.fileName);n&&t.add(n);const r=qr.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class am extends Pe{constructor(t){super(t)}}class om extends Pe{constructor(t){super(t)}}class cm extends Pe{constructor(t){super(t)}normalizeName(t){const e=(t??"").trim();return e?An.isActiveVportName(e)?Ri:super.normalizeName(e):""}getActiveVport(){return this.getAt(Ri)}getActiveVportBox(t,e){const n=this.getActiveVport();return n==null?void 0:n.resolveModelViewBox(t,e)}}class lm extends Pe{constructor(t){super(t)}}class hm extends G{getBtrIdAt(t){for(const[e,n]of this._recordsByName)if(n.blockTableRecordId==t)return n}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class um{constructor(t){this.database=t}applyForward(t){for(const e of t)this.applyChange(e,!0)}applyInverse(t){for(let e=t.length-1;e>=0;e--)this.applyChange(t[e],!1)}applyChange(t,e){switch(t.kind){case"modify":this.applyModify(t,e);break;case"append":e?this.applyAppend(t.container,t.object):this.applyRemove(t.container,t.object);break;case"remove":e?this.applyRemove(t.container,t.object):this.applyAppend(t.container,t.object);break;case"sysvar":this.applySysvar(t,e);break}}applyModify(t,e){const n=this.database.getObjectById(t.objectId);if(!n)return;const r=e?t.after:t.before;r&&n.restoreFrom(r)}applySysvar(t,e){const n=e?t.after:t.before;n!==void 0&&wt.instance().setVar(t.name,n,this.database)}applyAppend(t,e){switch(t.type){case"blockTableRecord":{const n=this.database.tables.blockTable.getIdAt(t.ownerId);n&&n.appendEntity(e);break}case"symbolTable":{const n=this.getSymbolTable(t.tableName);n&&n.add(e);break}case"dictionary":{const n=this.database.getObjectById(t.dictionaryId);n&&n.setAt(t.key,e);break}}}applyRemove(t,e){switch(t.type){case"blockTableRecord":{const n=this.database.tables.blockTable.getIdAt(t.ownerId);n&&n.removeEntity(e.objectId);break}case"symbolTable":{const n=this.getSymbolTable(t.tableName);n&&n.removeId(e.objectId);break}case"dictionary":{const n=this.database.getObjectById(t.dictionaryId);n&&n.removeId(e.objectId);break}}}getSymbolTable(t){const e=this.database.tables;switch(t){case"appIdTable":return e.appIdTable;case"blockTable":return e.blockTable;case"dimStyleTable":return e.dimStyleTable;case"linetypeTable":return e.linetypeTable;case"textStyleTable":return e.textStyleTable;case"viewTable":return e.viewTable;case"layerTable":return e.layerTable;case"viewportTable":return e.viewportTable;default:return}}}function Kc(i,t){const e=[],n=[],r=[];for(const s of t)if(s.kind==="modify"){const a=i.getObjectById(s.objectId);a instanceof et&&e.push(a)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const a=i.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof et?s.object:void 0);a&&n.push(a)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof et&&r.push(s.object);return{modified:e,appended:n,erased:r}}function wd(i,t){const e=[],n=[];for(const r of t){if(r.kind!=="append"&&r.kind!=="remove"||r.container.type!=="dictionary")continue;const s=r.container.key;if(r.kind==="append"){const a=i.getObjectById(r.object.objectId)??r.object;e.push({object:a,key:s})}else r.kind==="remove"&&n.push({object:r.object,key:s})}return{set:e,erased:n}}function vd(i,t){const e={};for(const n of nw){const r=i.getAttrWithoutException(n),s=t.getAttrWithoutException(n);pn(r,s)||(e[n]=s)}return e}function Ad(i,t,e=!1){const n=[];for(const r of t){if(r.kind!=="modify")continue;const s=i.getObjectById(r.objectId);if(!(s instanceof ls))continue;const a=r.before,o=r.after;if(!a||!o)continue;const c=e?vd(o,a):vd(a,o);Object.keys(c).length!==0&&n.push({database:i,layer:s,changes:c})}return n}function dv(i,t){if(i.type!==t.type)return!1;switch(i.type){case"blockTableRecord":return t.type==="blockTableRecord"&&i.ownerId===t.ownerId;case"symbolTable":return t.type==="symbolTable"&&i.tableName===t.tableName;case"dictionary":return t.type==="dictionary"&&i.dictionaryId===t.dictionaryId&&i.key===t.key}}class dm{constructor(){this.changes=[]}getChanges(){return this.changes}clear(){this.changes.length=0}mergeFrom(t){for(const e of t.getChanges())this.mergeChange(e)}recordModify(t){const e=t.objectId;this.changes.find(r=>r.kind==="modify"&&r.objectId===e)||this.changes.push({kind:"modify",objectId:e,before:t.clonePreservingIdentity()})}hasModify(t){return this.changes.some(e=>e.kind==="modify"&&e.objectId===t)}recordAppend(t,e){this.recordStructuralChange({kind:"append",container:t,object:e.clonePreservingIdentity()})}recordRemove(t,e){this.recordStructuralChange({kind:"remove",container:t,object:e.clonePreservingIdentity()})}recordSysvar(t,e){const n=t.toLowerCase();this.changes.find(s=>s.kind==="sysvar"&&s.name===n)||this.changes.push({kind:"sysvar",name:n,before:e})}finalize(t){for(const e of this.changes)if(e.kind==="modify"){const n=t.getObjectById(e.objectId);n&&(e.after=n.clonePreservingIdentity())}else e.kind==="sysvar"&&(e.after=this.getSysvarValue(t,e.name))}recordStructuralChange(t){const e=t.kind==="append"?"remove":"append",n=this.findStructuralChangeIndex(e,t.container,t.object.objectId);if(n>=0){this.changes.splice(n,1);return}this.changes.push(t)}mergeChange(t){if(t.kind==="modify"){this.changes.find(n=>n.kind==="modify"&&n.objectId===t.objectId)||this.changes.push(t);return}if(t.kind==="sysvar"){this.changes.find(n=>n.kind==="sysvar"&&n.name===t.name)||this.changes.push(t);return}this.recordStructuralChange(t)}findStructuralChangeIndex(t,e,n){return this.changes.findIndex(r=>r.kind===t&&r.object.objectId===n&&dv(r.container,e))}getSysvarValue(t,e){return wt.instance().getVar(e,t)}}class bh{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new dm}getObject(t,e,n=!1){const r=this.openedObjects.get(t);if(r){if(e===Yi.kForWrite&&!this.originalStates.has(t)){const a=r.clonePreservingIdentity();this.originalStates.set(t,a),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,n);if(this.openedObjects.set(t,s),e===Yi.kForWrite){const a=s.clonePreservingIdentity();this.originalStates.set(s.objectId,a),this.recorder.recordModify(s)}return s}commit(){this.originalStates.clear(),this.openedObjects.clear()}abort(){for(const[t,e]of this.originalStates){const n=this.openedObjects.get(t);n&&n.restoreFrom(e)}this.originalStates.clear(),this.openedObjects.clear(),this.recorder.clear()}lookupObject(t,e){throw new Error(`lookupObject(${t}) not implemented`)}}class gm extends bh{constructor(t){super(),this.database=t}lookupObject(t,e){const n=this.database.getObjectById(t,e);if(!n)throw new Error(`lookupObject(${t}) not found`);return n}}class fm{constructor(){this.undoRecords=[],this.redoRecords=[],this.maxDepth=100}push(t){this.undoRecords.push(t),this.redoRecords.length=0,this.trimUndoRecords()}pushUndo(t){this.undoRecords.push(t),this.trimUndoRecords()}trimUndoRecords(){this.undoRecords.length>this.maxDepth&&this.undoRecords.shift()}popUndo(){return this.undoRecords.pop()}pushRedo(t){this.redoRecords.push(t)}popRedo(){return this.redoRecords.pop()}canUndo(){return this.undoRecords.length>0}canRedo(){return this.redoRecords.length>0}clear(){this.undoRecords.length=0,this.redoRecords.length=0}}class pm{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new fm,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new um(t)}startTransaction(){const t=new gm(this.database);return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}hasTransaction(){return this.transactionStack.length>0}isRecording(){return this.hasTransaction()&&!this._applyingUndoRedo}isApplyingUndoRedo(){return this._applyingUndoRedo}isOpenedForWriteInTransaction(t){for(const e of this.transactionStack)if(e.recorder.hasModify(t))return!0;return!1}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");if(this.transactionStack.length>0){this.transactionStack[this.transactionStack.length-1].recorder.mergeFrom(t.recorder),t.commit();return}t.recorder.finalize(this.database);const e=t.recorder.getChanges();t.commit(),e.length>0&&(this.dispatchCommitEvents(e),this.enqueueUndoChanges(e))}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");const e=[...t.recorder.getChanges()];this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{t.abort(),e.length>0&&this.changeApplier.applyInverse(e)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}}startUndoMark(t){this.undoMarkStack.push({label:t,pendingChanges:[]})}endUndoMark(){const t=this.undoMarkStack.pop();if(!t)throw new Error("No active undo mark to end.");t.pendingChanges.length!==0&&this.undoStack.push({label:t.label,changes:t.pendingChanges})}cancelUndoMark(){this.undoMarkStack.length>0&&this.undoMarkStack.pop()}undo(){const t=this.undoStack.popUndo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyInverse(t.changes),this.dispatchUndoRedoEvents(t.changes,!0)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushRedo(t),!0}redo(){const t=this.undoStack.popRedo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyForward(t.changes),this.dispatchUndoRedoEvents(t.changes,!1)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushUndo(t),!0}canUndo(){return this.undoStack.canUndo()}canRedo(){return this.undoStack.canRedo()}clearUndoStack(){this.undoStack.clear()}recordAppend(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordAppend(t,e))}recordRemove(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordRemove(t,e))}recordSysvar(t,e){var n;this.isRecording()&&((n=this.currentTransaction())==null||n.recorder.recordSysvar(t,e))}resolveSymbolTableName(t){const e=this.database.tables;return t===e.appIdTable?"appIdTable":t===e.blockTable?"blockTable":t===e.dimStyleTable?"dimStyleTable":t===e.linetypeTable?"linetypeTable":t===e.textStyleTable?"textStyleTable":t===e.viewTable?"viewTable":t===e.layerTable?"layerTable":t===e.viewportTable?"viewportTable":t.objectId}runUndoable(t,e){this.startUndoMark(t),this.startTransaction();try{const n=e(this.currentTransaction());return this.commitTransaction(),this.endUndoMark(),n}catch(n){throw this.hasTransaction()&&this.abortTransaction(),this.cancelUndoMark(),n}}enqueueUndoChanges(t){const e=this.undoMarkStack[this.undoMarkStack.length-1];if(e)for(const n of t)e.pendingChanges.push(n)}dispatchCommitEvents(t){const{modified:e,appended:n,erased:r}=Kc(this.database,t);for(const o of e)this.dispatchEntityModified(o);n.length>0&&this.database.notifyEntityAppended(n),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:a}=wd(this.database,t);for(const{object:o,key:c}of s)this.database.notifyDictObjectSet(o,c);for(const{object:o,key:c}of a)this.database.notifyDictObjectErased(o,c);for(const o of t)o.kind==="sysvar"&&o.after!==void 0&&wt.instance().events.sysVarChanged.dispatch({database:this.database,name:o.name,oldVal:o.before,newVal:o.after});for(const o of Ad(this.database,t))this.dispatchLayerModified(o)}dispatchUndoRedoEvents(t,e){const{modified:n,appended:r,erased:s}=Kc(this.database,t),{set:a,erased:o}=wd(this.database,t);if(e){for(const c of n)this.dispatchEntityModified(c);s.length>0&&this.database.notifyEntityAppended(s),r.length>0&&this.database.notifyEntityErased(r);for(const{object:c,key:l}of o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)this.database.notifyDictObjectErased(c,l)}else{for(const c of n)this.dispatchEntityModified(c);r.length>0&&this.database.notifyEntityAppended(r),s.length>0&&this.database.notifyEntityErased(s);for(const{object:c,key:l}of a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)this.database.notifyDictObjectErased(c,l)}for(const c of t)if(c.kind==="sysvar"){const l=e?c.after:c.before,h=e?c.before:c.after;h!==void 0&&wt.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of Ad(this.database,t,e))this.dispatchLayerModified(c)}dispatchLayerModified(t){if(this.database.isEventBatched()){const e=this._pendingLayerModified.get(t.layer.objectId);if(e){e.changes={...e.changes,...t.changes};return}this._pendingLayerModified.set(t.layer.objectId,{database:t.database,layer:t.layer,changes:{...t.changes}});return}this.database.events.layerModified.dispatch(t)}dispatchEntityModified(t){if(this.database.isEventBatched()){this._pendingEntityModified.add(t);return}this.database.events.entityModified.dispatch({database:this.database,entity:t})}flushPendingLayerModifiedEvents(){if(this._pendingLayerModified.size===0)return;const t=[...this._pendingLayerModified.values()];this._pendingLayerModified.clear();for(const e of t)this.database.events.layerModified.dispatch(e)}flushPendingEntityModifiedEvents(){if(this._pendingEntityModified.size===0)return;const t=[...this._pendingEntityModified];this._pendingEntityModified.clear();for(const e of t)this.database.events.entityModified.dispatch({database:this.database,entity:e})}}function gv(i,t){if(i instanceof Xp||i instanceof G)return i.dxfTypeName;if(i instanceof In)return"LAYOUT";if(i instanceof Pi)return"GROUP";if(i instanceof os)return"XRECORD";if(i instanceof uh)return"SORTENTSTABLE";if(i instanceof hh)return"IMAGEDEF";if(i instanceof ch)return"LAYER_FILTER";if(i instanceof lh)return"LAYER_INDEX";if(i instanceof us)return"MLEADERSTYLE";if(i instanceof Lo)return"MLINESTYLE";if(i instanceof Pn)return"SCALE";if(i instanceof xr)return"DICTIONARYVAR";if(i instanceof Wl){const e=i.dxfRecordName??fv(i);return e&&(i.hasDxfRawTags||t.has(e.toUpperCase()))?e:void 0}}function fv(i){if(i instanceof Fr)return"ACDB_MTEXTATTRIBUTEOBJECTCONTEXTDATA_CLASS";if(i instanceof Ue)return"ACDB_MTEXTOBJECTCONTEXTDATA_CLASS";if(i instanceof tr)return"ACDB_TEXTOBJECTCONTEXTDATA_CLASS";if(i instanceof Fi)return"ACDB_HATCHSCALECONTEXTDATA_CLASS";if(i instanceof Bi)return"ACDB_BLKREFOBJECTCONTEXTDATA_CLASS";if(i instanceof zi)return"ACDB_MLEADEROBJECTCONTEXTDATA_CLASS";if(i instanceof So)return"ACDB_LEADEROBJECTCONTEXTDATA_CLASS"}const pv=new Set(["$ACADVER","$HANDSEED","$DWGCODEPAGE","$INSUNITS","$LUNITS","$LUPREC","$UNITMODE","$MEASUREMENT","$LTSCALE","$LWDISPLAY","$CELTSCALE","$CELWEIGHT","$CECOLOR","$TILEMODE","$PSLTSCALE","$CLAYER","$CELTYPE","$CETRANSPARENCY","$CMLSTYLE","$CMLSCALE","$CMLEADERSTYLE","$HPCOLOR","$HPBACKGROUNDCOLOR","$HPLAYER","$HPTRANSPARENCY","$TEXTSTYLE","$DIMSTYLE","$ANGBASE","$ANGDIR","$AUNITS","$AUPREC","$EXTMIN","$EXTMAX","$PDMODE","$PDSIZE","$OSMODE","$ORTHOMODE"]),Mr=class Mr extends pt{constructor(){super({objectId:"0"}),this._classes=[],this._dimStyleAnnotationScales=new Map,this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._drawCircleSides=$c,this._dxfHeaderExtras=[],this._dxfHeaderExtrasVersion=0,this._dxfUnknownObjects=[],this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new vt,dictObjectErased:new vt,entityAppended:new vt,entityModified:new vt,entityErased:new vt,layerAppended:new vt,layerModified:new vt,layerErased:new vt,openProgress:new vt,openFailed:new vt},Mr._unsavedDrawingSequence+=1,this._dwgname=`Drawing${Mr._unsavedDrawingSequence}.dwg`,this._version=new Lt("AC1014"),this._dwgCodePage=void 0,this._angbase=0,this._angdir=0,this._aunits=Ht.DecimalDegrees,this._auprec=0,this._lunits=xt.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new X,this._celtype=kt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new St,this._clayer="0",this._cmlstyle=tn,this._cmlscale=1,this._cmleaderstyle=en,this._hpbackgroundcolor=new X(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new St,this._textstyle=gt,this._dimstyle=gt,this._extents=new H,this._insunits=mt.Millimeters,this._unitmode=0,this._measurement=1,this._ltscale=1,this._lwdisplay=!1,this._tilemode=1,this._psltscale=!0,this._cannoscale="1:1",this._dimStyleAnnotationScales=new Map,this._annoallvisible=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._orthomode=0,this._comparehatch=ra,this._comparercmargin=sa,this._comparetext=aa,this._comparetolerance=oa,this._maxHandle=0,this._tables={appIdTable:new lm(this),blockTable:new Qp(this),dimStyleTable:new im(this),linetypeTable:new sm(this),textStyleTable:new qr(this),ucsTable:new am(this),viewTable:new om(this),layerTable:new rm(this),viewportTable:new cm(this)},this._objects={dictionary:new G(this),dictionaryVar:new G(this),group:new G(this),imageDefinition:new G(this),layerFilter:new G(this),layerIndex:new G(this),layout:new hm(this),mleaderStyle:new G(this),mlineStyle:new G(this),objectContextData:new G(this),scale:new G(this),sortentsTable:new G(this),xrecord:new G(this)},this._layerFilters=new rn,this.transactionManager=new pm(this),this.registerBootstrapHandles()}get tables(){return this._tables}get classes(){return this._classes}set classes(t){this._classes=t.map(e=>({...e}))}get objects(){return this._objects}get layerFilters(){return this._layerFilters}set layerFilters(t){this._layerFilters=t??new rn}getObjectById(t,e=!1){return t===this.objectId?this:this._handleRegistry.get(t)}createExtensionDictionaryFor(t){const e=t.extensionDictionary;if(e)return e;const n=new G(this);return n.database=this,n.ownerId=t.objectId,this.commitObjectHandle(n),t.extensionDictionary=n.objectId,n.objectId}isUndoRecording(){return this.transactionManager.isRecording()}openObject(t,e){const n=this.transactionManager.currentTransaction();if(n){const r=n.getObject(t,e);if(r)return r}return this.getObjectById(t)}openObjectForRead(t){return this.openObject(t,Yi.kForRead)}openObjectForWrite(t){return this.openObject(t,Yi.kForWrite)}openEntityForRead(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForRead(e)}openEntityForWrite(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForWrite(e)}runDatabaseEdit(t,e){if(this.isUndoRecording()){e();return}this.transactionManager.runUndoable(t,e)}getRootDictionaries(){return[this.objects.dictionary,this.objects.dictionaryVar,this.objects.group,this.objects.imageDefinition,this.objects.layerFilter,this.objects.layerIndex,this.objects.layout,this.objects.mleaderStyle,this.objects.mlineStyle,this.objects.objectContextData,this.objects.scale,this.objects.sortentsTable,this.objects.xrecord]}beginEventBatch(){this._eventBatchDepth++}endEventBatch(){this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth===0&&(this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents(),this.flushEventBatch()))}async endEventBatchChunked(t,e){if(this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth!==0))return;this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents();const n=this._pendingEntityAppended;this._pendingEntityAppended=[];const r=n.length,s=Math.max(1,t);if(r===0){this.flushEventBatchRemainder();return}let a=0;try{for(let o=0;o<r;o+=s){const c=Math.min(o+s,r),l=n.slice(o,c);this.events.entityAppended.dispatch({database:this,entity:l}),a=c,e&&await e(c,r)}}finally{a<r&&this.events.entityAppended.dispatch({database:this,entity:n.slice(a)}),this.flushEventBatchRemainder()}}isEventBatched(){return this._eventBatchDepth>0}notifyEntityAppended(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityAppended.push(...e);return}this.events.entityAppended.dispatch({database:this,entity:t})}notifyEntityErased(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityErased.push(...e);return}this.events.entityErased.dispatch({database:this,entity:t})}notifyDictObjectSet(t,e){if(this.isEventBatched()){this._pendingDictObjectSet.push({object:t,key:e});return}this.events.dictObjetSet.dispatch({database:this,object:t,key:e})}notifyDictObjectErased(t,e){if(this.isEventBatched()){this._pendingDictObjectErased.push({object:t,key:e});return}this.events.dictObjectErased.dispatch({database:this,object:t,key:e})}flushEventBatch(){if(this._pendingEntityAppended.length>0){const t=this._pendingEntityAppended;this._pendingEntityAppended=[],this.events.entityAppended.dispatch({database:this,entity:t})}this.flushEventBatchRemainder()}flushEventBatchRemainder(){if(this._pendingEntityErased.length>0){const t=this._pendingEntityErased;this._pendingEntityErased=[],this.events.entityErased.dispatch({database:this,entity:t})}if(this._pendingDictObjectSet.length>0){const t=this._pendingDictObjectSet;this._pendingDictObjectSet=[];for(const{object:e,key:n}of t)this.events.dictObjetSet.dispatch({database:this,object:e,key:n})}if(this._pendingDictObjectErased.length>0){const t=this._pendingDictObjectErased;this._pendingDictObjectErased=[];for(const{object:e,key:n}of t)this.events.dictObjectErased.dispatch({database:this,object:e,key:n})}}get formatter(){return this._formatter??(this._formatter=new Gp(this))}generateHandle(){return this._maxHandleBig!=null?(this._maxHandleBig+=BigInt(1),this._maxHandleBig.toString(16).toUpperCase()):this._maxHandle>=Number.MAX_SAFE_INTEGER?(this._maxHandleBig=BigInt(this._maxHandle),this.generateHandle()):(this._maxHandle++,this._maxHandle.toString(16).toUpperCase())}generateUniqueHandle(){let t=this.generateHandle();for(;this.isHandleTaken(t);)t=this.generateHandle();return t}initializeHandleSeed(t){const e=BigInt("0x"+t);if(e<=BigInt(0))return;const n=e-BigInt(1);if(n<=BigInt(Number.MAX_SAFE_INTEGER)){if(this._maxHandleBig==null){const r=Number(n);r>this._maxHandle&&(this._maxHandle=r)}return}(this._maxHandleBig==null||n>this._maxHandleBig)&&(this._maxHandleBig=n)}adoptExternalHandle(t,e){return this.releaseObjectHandle(t),e&&!e.startsWith(mn)&&!this.isHandleTaken(e)?(t.objectId=e,this.registerObjectHandle(t),this.updateMaxHandle(e),e):this.assignGeneratedHandle(t)}registerObjectHandle(t){const e=t.objectId;!e||e.startsWith(mn)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(mn)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(mn))return!1;const n=this._handleRegistry.get(t);return n!==void 0&&n!==e}registerBootstrapHandles(){this._handleRegistry.clear(),this.registerObjectHandle(this);for(const t of[this._tables.blockTable,this._tables.dimStyleTable,this._tables.layerTable,this._tables.linetypeTable,this._tables.appIdTable,this._tables.textStyleTable,this._tables.ucsTable,this._tables.viewTable,this._tables.viewportTable])this.registerObjectHandle(t);for(const t of[this._objects.dictionary,this._objects.dictionaryVar,this._objects.group,this._objects.imageDefinition,this._objects.layerFilter,this._objects.layerIndex,this._objects.layout,this._objects.mleaderStyle,this._objects.mlineStyle,this._objects.objectContextData,this._objects.scale,this._objects.sortentsTable,this._objects.xrecord])this.registerObjectHandle(t)}assignGeneratedHandle(t){const e=t.objectId;this.releaseObjectHandle(t);const n=this.generateUniqueHandle();if(t.objectId=n,this.registerObjectHandle(t),e&&e!==n){if(this.updateMaxHandle(n),t instanceof lt)for(const r of t.newIterator())r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n);if(t instanceof Pe)for(const r of t.newIterator(!0))r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n);if(t instanceof G)for(const r of t.newIterator())r.getAttrWithoutException("ownerId")===e&&(r.ownerId=n)}return n}updateMaxHandle(t){this.trackMaxHandle(t)}trackMaxHandle(t){if(this._maxHandleBig!=null){if(t.length>=14){const n=BigInt("0x"+t);n>this._maxHandleBig&&(this._maxHandleBig=n)}return}const e=parseInt(t,16);if(!isNaN(e)){if(e>Number.MAX_SAFE_INTEGER){this._maxHandleBig=BigInt("0x"+t);return}e>this._maxHandle&&(this._maxHandle=e)}}commitObjectHandle(t,e){const n=t.getAttrWithoutException("objectId"),r=e!=null&&n!=null&&e(n);if(!n||t.isTemp||r){this.assignGeneratedHandle(t);return}const a=this._handleRegistry.get(n);if(a&&a!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(a);else{this.assignGeneratedHandle(t);return}this.registerObjectHandle(t),this.updateMaxHandle(n)}shouldPreserveIncomingHandle(t){return!t.isTemp}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this.updateSysVar(E.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(E.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(E.LUNITS,this._lunits,t??xt.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(E.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(E.ACADVER,this._version,new Lt(t),e=>{this._version=e})}get dwgCodePage(){return this._dwgCodePage}set dwgCodePage(t){this._dwgCodePage=t!=null&&t.trim()?t.trim():void 0}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(E.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(E.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(E.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(E.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get cannoscale(){return this._cannoscale}set cannoscale(t){this.updateSysVar(E.CANNOSCALE,this._cannoscale,t||"1:1",e=>{this._cannoscale=e})}getDimStyleAnnotationScale(t){if(t)return this._dimStyleAnnotationScales.get(t.trim().toUpperCase())}setDimStyleAnnotationScale(t,e){!t||!(e>0)||this._dimStyleAnnotationScales.set(t.trim().toUpperCase(),e)}get annoallvisible(){return this._annoallvisible}set annoallvisible(t){const e=!!t;this.updateSysVar(E.ANNOALLVISIBLE,this._annoallvisible,e,n=>{this._annoallvisible=n})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get drawCircleSides(){return this._drawCircleSides}set drawCircleSides(t){this._drawCircleSides=tt.resolveCircleSides(t)}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(E.DWGNAME,this._dwgname,e,n=>{this._dwgname=n})}get dxfHeaderExtras(){return this._dxfHeaderExtras}addDxfHeaderExtra(t,e){const n=this._dxfHeaderExtras.findIndex(r=>r.name===t);n>=0?this._dxfHeaderExtras[n]={name:t,pairs:e}:this._dxfHeaderExtras.push({name:t,pairs:e}),this._dxfHeaderExtrasVersion=this._version.value}get dxfUnknownObjects(){return this._dxfUnknownObjects}addDxfUnknownObject(t){this._dxfUnknownObjects.push(t)}clearDxfHeaderExtras(){this._dxfHeaderExtras=[],this._dxfHeaderExtrasVersion=0}get thumbnailImage(){return this._thumbnailImage}set thumbnailImage(t){if(!t||t.length===0){this._thumbnailImage=void 0;return}this._thumbnailImage=t}isLayerDrawable(t){if(this._drawNoPlotLayers)return!0;const e=this.tables.layerTable.getAt(t);return e==null||e.isPlottable}set lwdisplay(t){this.updateSysVar(E.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get tilemode(){return this._tilemode}set tilemode(t){this.updateSysVar(E.TILEMODE,this._tilemode,t??1,e=>{this._tilemode=e})}get psltscale(){return this._psltscale}set psltscale(t){this._psltscale=t}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(E.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(E.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??kt);this.updateSysVar(E.CELTYPE,this._celtype,e,n=>{this._celtype=n})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(E.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(E.CETRANSPARENCY,this._cetransparency,t??new St,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(E.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(E.CMLSTYLE,this._cmlstyle,t??tn,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(E.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(E.CMLEADERSTYLE,this._cmleaderstyle,t??en,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(E.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new X(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(E.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(E.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(E.HPTRANSPARENCY,this._hptransparency,t??new St,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(E.TEXTSTYLE,this._textstyle,t??gt,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(E.DIMSTYLE,this._dimstyle,t??gt,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(E.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(E.ANGDIR,this._angdir,t??0,e=>{this._angdir=e})}get extmax(){return this._extents.max}set extmax(t){if(t){const e=this._extents.max.clone();this._extents.expandByPoint(t),this._extents.max.equals(e)||this.triggerSysVarChangedEvent(E.EXTMAX,e,this._extents.max)}}get extmin(){return this._extents.min}set extmin(t){if(t){const e=this._extents.min.clone();this._extents.expandByPoint(t),this._extents.min.equals(e)||this.triggerSysVarChangedEvent(E.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(E.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(E.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(E.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(E.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get comparehatch(){return this._comparehatch}set comparehatch(t){const e=Oe("COMPAREHATCH",t??ra,po,mo);this.updateSysVar(E.COMPAREHATCH,this._comparehatch,e,n=>{this._comparehatch=n})}get comparercmargin(){return this._comparercmargin}set comparercmargin(t){const e=Oe("COMPARERCMARGIN",t??sa,yo,bo);this.updateSysVar(E.COMPARERCMARGIN,this._comparercmargin,e,n=>{this._comparercmargin=n})}get comparetext(){return this._comparetext}set comparetext(t){const e=Oe("COMPARETEXT",t??aa,_o,xo);this.updateSysVar(E.COMPARETEXT,this._comparetext,e,n=>{this._comparetext=n})}get comparetolerance(){return this._comparetolerance}set comparetolerance(t){const e=Oe("COMPARETOLERANCE",t??oa,wo,vo);this.updateSysVar(E.COMPARETOLERANCE,this._comparetolerance,e,n=>{this._comparetolerance=n})}get lastOpenError(){return this._lastOpenError}async read(t,e,n=wr.DXF){const r=Ce.instance.get(n);if(r==null)throw new Error(`Database converter for file type '${n}' isn't registered and can can't read this file!`);let s;if(typeof t=="string"){const a=new TextEncoder().encode(t);s=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}else if(t instanceof ArrayBuffer)s=t;else if(ArrayBuffer.isView(t))s=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);else{const a=new zt("AcDbDatabase.read expects a string, ArrayBuffer, or ArrayBufferView","unknown");throw this._lastOpenError=a,this.events.openFailed.dispatch({database:this,error:a}),a}this.clear(),this._lastOpenError=null,this._drawNoPlotLayers=(e==null?void 0:e.drawNoPlotLayers)??!0,this.drawCircleSides=(e==null?void 0:e.circleSides)??$c,e!=null&&e.fileName&&this.setDwgName(e.fileName),pf(this);try{await r.read(s,this,{minimumChunkSize:e&&e.minimumChunkSize||10,progress:this.createConversionProgressHandler(),timeout:e==null?void 0:e.timeout,encoding:e==null?void 0:e.encoding,sysVars:e==null?void 0:e.sysVars})}catch(a){const o=zt.from(a);throw this._lastOpenError=o,this.events.openFailed.dispatch({database:this,error:o}),o}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(){return async(t,e,n,r,s)=>{let a=r;if(n==="ERROR"&&s){const o=zt.fromTask(s);this._lastOpenError=o,a={code:o.code,message:o.message,stage:o.stage??e}}this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:e,subStageStatus:n,data:a})}}async openUri(t,e){var g;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const n=await fetch(t);if(!n.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${n.status}'!`);const r=n.headers.get("content-length"),s=r?parseInt(r,10):null;let a=0;const o=(g=n.body)==null?void 0:g.getReader();if(!o)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:f,value:p}=await o.read();if(f)break;if(c.push(p),a+=p.length,s!==null){const m=Math.round(a/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(a);let h=0;for(const f of c)l.set(f,h),h+=f.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,wr.DWG):d==="dxf"?await this.read(l.buffer,e,wr.DXF):await this.read(l.buffer,e,d),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,n=this.version.name,r=!1){this.ensureDatabaseDefaults(),this._layerFilters.root.getNestedFilters().length>0&&!this.tables.layerTable.extensionDictionary&&(this.tables.layerTable.extensionDictionary=this.generateHandle());const s=typeof r=="boolean"?{saveThumbnailImage:r,format:"ascii"}:{saveThumbnailImage:r.saveThumbnailImage??!1,format:r.format??"ascii"},a=n instanceof Lt?n:new Lt(n),o=new ve({database:this,precision:e,version:a,outputFormat:s.format}),c=o.capabilities.supportsObjectsSection?this.planDxfObjectsSection(o):void 0;return o.writtenObjectIds=(c==null?void 0:c.writtenObjectIds)??new Set,this.ensureXDataAppIds(c),this.writeDxfHeaderSection(o),this.writeDxfClassesSection(o),this.writeDxfTablesSection(o,a),this.writeDxfBlocksSection(o),this.writeDxfEntitiesSection(o),this.writeDxfObjectsSection(o,c),this.writeDxfThumbnailImageSection(o,s.saveThumbnailImage),o.writeStart("EOF"),o.finalizeHandseed(),s.format==="binary"?o.toBinary():o.toString()}async regen(){await new xp(this).read(null,this,{minimumChunkSize:500,progress:this.createConversionProgressHandler()})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new fh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureEntityStyleDefaults(t){var e;if(t.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||tn);return}if(t.dxfTypeName==="MULTILEADER"){this.ensureMLeaderStyle(this._cmleaderstyle||en);return}if(t.dxfTypeName==="HATCH"){const n=t;(e=n.applyPatternDefaultsFromSysVars)==null||e.call(n,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new Eo({name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[gt,"STANDARD"];for(const e of t)if(this.tables.textStyleTable.has(e))return!0;for(const e of this.tables.textStyleTable.newIterator())if(e.name.toUpperCase()===gt.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new X;e.colorIndex=7,this.tables.layerTable.add(new ls({name:"0",standardFlags:0,linetype:wn,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(Ne)||this.tables.linetypeTable.add(new vn({name:Ne,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(kt)||this.tables.linetypeTable.add(new vn({name:kt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(wn)||this.tables.linetypeTable.add(new vn({name:wn,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(gt)||this.tables.dimStyleTable.add(new Vt({name:gt,dimtxsty:gt})),!this.tables.viewportTable.has(Ri)){const e=new An;e.name=Ri,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||tn),this.ensureMLeaderStyle(this._cmleaderstyle||en);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new In;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=t.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.objects.layout.setAt(e.layoutName,e),t.layoutId=e.objectId}this.ensureDefaultPaperSpaceLayout(),this.tables.appIdTable.has(Nc)||this.tables.appIdTable.add(new _r(Nc)),this.tables.appIdTable.has(Dc)||this.tables.appIdTable.add(new _r(Dc))}ensureDefaultPaperSpaceLayout(){for(const r of this.tables.blockTable.newIterator())if(r.isPaperSapce)return;const t=new lt;t.name=lt.PAPER_SPACE_NAME_PREFIX,this.tables.blockTable.add(t);const e=this.objects.layout.getAt("Layout1")?`Layout${this.objects.layout.maxTabOrder+1}`:"Layout1",n=new In;n.layoutName=e,n.tabOrder=Math.max(1,this.objects.layout.maxTabOrder+1),n.blockTableRecordId=t.objectId,n.limits.min.copy({x:0,y:0}),n.limits.max.copy({x:12,y:9}),n.extents.min.copy({x:0,y:0,z:0}),n.extents.max.copy({x:12,y:9,z:0}),this.objects.layout.setAt(n.layoutName,n),t.layoutId=n.objectId}ensureMLineStyle(t){var s;const e=this.objects.mlineStyle,n=t.trim();if(!n||e.getAt(n))return;for(const[a,o]of e.entries())if((a==null?void 0:a.toUpperCase())===n.toUpperCase()||((s=o.styleName)==null?void 0:s.toUpperCase())===n.toUpperCase())return;const r=new Lo;r.styleName=n,r.elements=[{offset:.5,color:new X().setByLayer(),lineType:kt},{offset:-.5,color:new X().setByLayer(),lineType:kt}],e.setAt(n,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,n=t.trim();if(!n||e.getAt(n))return;for(const[o]of e.entries())if((o==null?void 0:o.toUpperCase())===n.toUpperCase())return;const r=new us;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new X().setByBlock(),r.textColor=new X().setByBlock(),r.blockColor=new X().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(Ne);r.leaderLineTypeId=s==null?void 0:s.objectId;const a=this.tables.textStyleTable.getAt(gt);r.textStyleId=a==null?void 0:a.objectId,e.setAt(n,r)}writeDxfHeaderSection(t){var e;if(t.startSection("HEADER"),t.writeString(9,"$ACADVER"),t.writeString(1,((e=t.version)==null?void 0:e.name)??this.version.name),t.writeHandseedPlaceholder(),t.writeString(9,"$DWGCODEPAGE"),t.capabilities.supportsUtf8CodePage)t.writeString(3,"UTF-8");else{const n=this._dwgCodePage,r=n&&!/^utf-?8$/i.test(n)?n:"ANSI_1252";t.writeString(3,r)}t.writeString(9,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LUNITS"),t.writeInt16(70,this.lunits),t.writeString(9,"$LUPREC"),t.writeInt16(70,this.luprec),t.writeString(9,"$UNITMODE"),t.writeInt16(70,this.unitmode),t.writeString(9,"$MEASUREMENT"),t.writeInt16(70,this.measurement),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$LWDISPLAY"),t.writeBoolean(290,this.lwdisplay)),t.writeString(9,"$CELTSCALE"),t.writeDouble(40,this.celtscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$CELWEIGHT"),t.writeLineWeight(370,this.celweight)),t.writeString(9,"$CECOLOR"),t.writeCmColor(this.cecolor),t.writeString(9,"$TILEMODE"),t.writeInt16(70,this.tilemode),t.writeString(9,"$PSLTSCALE"),t.writeInt16(70,this.psltscale?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$CELTYPE"),t.writeString(6,this.celtype),t.capabilities.supportsTransparency&&!this.cetransparency.isInvalid&&(t.writeString(9,"$CETRANSPARENCY"),t.writeTransparency(this.cetransparency)),t.writeString(9,"$CMLSTYLE"),t.writeString(2,this.cmlstyle),t.writeString(9,"$CMLSCALE"),t.writeDouble(40,this.cmlscale),t.capabilities.supportsMLeader&&(t.writeString(9,"$CMLEADERSTYLE"),t.writeString(2,this.cmleaderstyle)),t.capabilities.supportsHatchHeaderVars&&(this.hpcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPCOLOR"),t.writeCmColor(this.hpcolor)),this.hpbackgroundcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPBACKGROUNDCOLOR"),t.writeCmColor(this.hpbackgroundcolor)),this.hplayer&&this.hplayer!=="."&&(t.writeString(9,"$HPLAYER"),t.writeString(8,this.hplayer)),t.capabilities.supportsTransparency&&!this.hptransparency.isInvalid&&(t.writeString(9,"$HPTRANSPARENCY"),t.writeTransparency(this.hptransparency))),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$DIMSTYLE"),t.writeString(2,this.dimstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angbase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angdir),t.writeString(9,"$AUNITS"),t.writeInt16(70,this.aunits),t.writeString(9,"$AUPREC"),t.writeInt16(70,this.auprec),this.writeDxfExtentsHeader(t),t.writeString(9,"$PDMODE"),t.writeInt32(70,this.pdmode),t.writeString(9,"$PDSIZE"),t.writeDouble(40,this.pdsize),t.writeString(9,"$OSMODE"),t.writeInt32(70,this.osmode),t.writeString(9,"$ORTHOMODE"),t.writeInt16(70,this.orthomode),this.writeDxfHeaderExtras(t),t.endSection()}writeDxfHeaderExtras(t){var n;if(!((((n=t.version)==null?void 0:n.value)??this.version.value)<this._dxfHeaderExtrasVersion))for(const{name:r,pairs:s}of this._dxfHeaderExtras)pv.has(r)||(t.writeString(9,r),t.writeRawPairs(s))}writeDxfExtentsHeader(t){if(this._extents.isEmpty()&&this.refreshExtentsFromModelSpace(),this._extents.isEmpty()){t.writeString(9,"$EXTMIN"),t.writePoint3d(10,{x:1e20,y:1e20,z:1e20}),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,{x:-1e20,y:-1e20,z:-1e20});return}t.writeString(9,"$EXTMIN"),t.writePoint3d(10,this.extmin),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,this.extmax)}refreshExtentsFromModelSpace(){for(const t of this.tables.blockTable.modelSpace.newIterator())try{const e=t.geometricExtents;e&&!e.isEmpty()&&this._extents.union(e)}catch{}}writeDxfClassesSection(t){if(!(!t.capabilities.supportsClassesSection||this._classes.length===0)){t.startSection("CLASSES");for(const e of this._classes)t.writeStart("CLASS"),t.writeString(1,e.name),t.writeString(2,e.cppClassName),t.writeString(3,e.appName),t.writeInt32(90,e.proxyFlag),t.writeInt32(91,e.instanceCount),t.writeInt8(280,e.wasProxy?1:0),t.writeInt8(281,e.isEntity?1:0);t.endSection()}}writeDxfTablesSection(t,e){t.startSection("TABLES"),this.writeDxfTable(t,"VPORT",this.tables.viewportTable,this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(t,"VIEW",this.tables.viewTable,this.tables.viewTable.newIterator(),"VIEW"),this.writeDxfTable(t,"UCS",this.tables.ucsTable,this.tables.ucsTable.newIterator(),"UCS"),this.writeDxfTable(t,"LTYPE",this.tables.linetypeTable,this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(t,"LAYER",this.tables.layerTable,this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(t,"STYLE",this.tables.textStyleTable,this.tables.textStyleTable.newIterator(!0),"STYLE"),this.writeDxfTable(t,"APPID",this.tables.appIdTable,this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(t,"DIMSTYLE",this.tables.dimStyleTable,this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),e.capabilities.supportsBlockRecordTable&&this.writeDxfTable(t,"BLOCK_RECORD",this.tables.blockTable,this.tables.blockTable.newIterator(),"BLOCK_RECORD"),t.endSection()}writeDxfBlocksSection(t){t.startSection("BLOCKS");for(const e of this.tables.blockTable.newIterator()){if(e.dxfOutBlockBegin(t),!e.isModelSapce&&!e.isPaperSapce)for(const n of e.newIterator())this.writeDxfEntity(t,n);e.dxfOutBlockEnd(t)}t.endSection()}writeDxfEntitiesSection(t){t.startSection("ENTITIES");for(const e of this.tables.blockTable.newIterator())if(!(!e.isModelSapce&&!e.isPaperSapce))for(const n of e.newIterator())this.writeDxfEntity(t,n);t.endSection()}planDxfObjectsSection(t){var v;const e=this.objects.dictionary;e.ownerId="0";const n=(S,I)=>{e.getAt(S)!==I&&e.setAt(S,I)},r=S=>{e.getAt(S)&&e.remove(S)};n("ACAD_LAYOUT",this.objects.layout),n("ACAD_GROUP",this.objects.group),this.objects.sortentsTable.numEntries>0?n("ACAD_SORTENTS",this.objects.sortentsTable):r("ACAD_SORTENTS");const s=this.objects.mleaderStyle.numEntries>0,a=t.capabilities.supportsMLeader&&s,o=!a&&e.getAt("ACAD_MLEADERSTYLE")===this.objects.mleaderStyle;a?n("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):r("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?n("ACAD_MLINESTYLE",this.objects.mlineStyle):r("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?n("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):r("ISM_RASTER_IMAGE_DICT");const c=S=>(S??"").trim().toUpperCase(),l=new Set(this._classes.map(S=>(S.name??"").toUpperCase())),h=new Map,u=new Set,d=this.objects.xrecord,g=[],f=S=>{if(!S||S===d)return;const I=c(S.objectId);if(!I||h.has(I)||u.has(I))return;const M=gv(S,l);M&&(h.set(I,{object:S,type:M}),g.push(S))},p=S=>{const I=S.extensionDictionary;I&&f(this.getObjectById(I))};let m=0;const y=()=>{for(;m<g.length;){const S=g[m++];if(p(S),S instanceof G){for(const[,I]of S.entries())f(I);S.defaultId&&f(this.getObjectById(S.defaultId))}}},b=S=>{if(!S)return;const I=c(S.objectId);if(!(!I||u.has(I))&&(u.add(I),S.extensionDictionary&&b(this.getObjectById(S.extensionDictionary)),S instanceof G))for(const[,M]of S.entries())b(M)};f(e),y();const _=this.tables.layerTable,w=this._layerFilters.root.getNestedFilters().length>0;if(w&&_.extensionDictionary){const S=_.extensionDictionary,I=this.getObjectById(S);if(u.add(c(S)),I instanceof G)for(const[M,O]of I.entries())M===zn||M===Wr?b(O):f(O)}for(const S of Object.values(this.tables)){p(S);for(const I of S.newIterator())p(I)}for(const S of this.tables.blockTable.newIterator())for(const I of S.newIterator()){p(I);const M=(v=I.attributeIterator)==null?void 0:v.call(I);if(M)for(const O of M)p(O)}y();for(const[,S]of this.objects.layerFilter.entries())f(S);for(const[,S]of this.objects.layerIndex.entries())f(S);for(const S of this._dxfUnknownObjects){const I=this.getObjectById(S.ownerId);(I instanceof et||I&&!(I instanceof G)&&h.has(c(I.objectId)))&&f(S)}y();const k=[];for(const[,S]of d.entries()){const I=c(S.objectId);!I||h.has(I)||u.has(I)||k.push(S)}k.length>0?n("MLIGHT_XRECORD",d):r("MLIGHT_XRECORD");const P=new Set(h.keys());if(k.length>0){P.add(c(d.objectId));for(const S of k)P.add(c(S.objectId))}return w&&_.extensionDictionary&&P.add(c(_.extensionDictionary)),{records:[...h.values()],looseXrecords:k,writtenObjectIds:P,restoreMLeaderRoot:o}}ensureXDataAppIds(t){var r;const e=this.tables.appIdTable,n=s=>{for(const a of s.xDataAppIds())a&&!e.has(a)&&e.add(new _r(a))};for(const s of Object.values(this.tables))for(const a of s.newIterator())n(a);for(const s of this.tables.blockTable.newIterator())for(const a of s.newIterator()){n(a);const o=(r=a.attributeIterator)==null?void 0:r.call(a);if(o)for(const c of o)n(c)}if(t){for(const{object:s}of t.records)n(s);for(const s of t.looseXrecords)n(s)}}writeDxfObjectsSection(t,e){if(!e)return;t.startSection("OBJECTS");const n=r=>e.writtenObjectIds.has((r.objectId??"").trim().toUpperCase());for(const{object:r,type:s}of e.records){if(r instanceof G){t.writeStart(s),r.dxfOutFiltered(t,n);continue}if(r instanceof Pi&&!r.name)for(const[a,o]of this.objects.group.entries())o===r&&(r.name=a);t.writeStart(s),r.dxfOut(t,!0)}if(e.looseXrecords.length>0){const r=this.objects.xrecord;r.ownerId=this.objects.dictionary.objectId,t.writeStart("DICTIONARY"),r.dxfOutFiltered(t,n);for(const s of e.looseXrecords)s.ownerId=r.objectId,t.writeStart("XRECORD"),s.dxfOut(t,!0)}this.writeAcLyLayerFilterObjects(t),t.endSection(),e.restoreMLeaderRoot&&this.objects.dictionary.setAt("ACAD_MLEADERSTYLE",this.objects.mleaderStyle)}writeAcLyLayerFilterObjects(t){const e=Op(this._layerFilters);if(e.nodes.length===0)return;const n=[],r=[],s=this.tables.layerTable,a=s.extensionDictionary??this.generateHandle();s.extensionDictionary=a;const o=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(f,p,m)=>{const y=this.generateHandle();let b;if(f.children.length>0){const _=this.generateHandle(),w=this.generateHandle(),k=[];for(const P of f.children)k.push({name:P.key,id:u(P,w,!1)});n.push({handle:_,ownerId:y,entries:[{name:zn,id:w}]}),n.push({handle:w,ownerId:_,entries:k}),b=_}return r.push({handle:y,ownerId:p,extensionDictionaryId:b,data:f.data}),m&&h.push({name:f.key,id:y}),y};for(const f of e.nodes)l.push({name:f.key,id:u(f,o,!0)});const d=new Map,g=this.getObjectById(a);if(g instanceof G)for(const[f,p]of g.entries())d.set(f,p.objectId);d.set(zn,o),d.set(Wr,c),n.unshift({handle:a,ownerId:s.objectId,entries:Array.from(d,([f,p])=>({name:f,id:p}))},{handle:o,ownerId:a,entries:l},{handle:c,ownerId:a,entries:h});for(const f of n)t.markObjectIdWritten(f.handle);for(const f of r)t.markObjectIdWritten(f.handle);for(const f of n){t.writeStart("DICTIONARY"),t.writeHandle(5,f.handle),t.writeObjectId(330,f.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const p of f.entries)t.writeString(3,p.name),t.writeObjectId(350,p.id)}for(const f of r){const p=new os;p.objectId=f.handle,p.ownerId=f.ownerId,f.extensionDictionaryId&&(p.extensionDictionary=f.extensionDictionaryId),p.data=Dp(f.data),t.writeStart("XRECORD"),p.dxfOut(t)}}writeDxfTable(t,e,n,r,s){const a=[...r];t.startTable(e),n.dxfOut(t);for(const o of a){if(s==="BLOCK_RECORD"&&o instanceof lt){o.dxfOutBlockRecord(t);continue}t.writeStart(s),o.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(!(e instanceof Gr&&e.hasSubclassData!==t.capabilities.supportsSubclassMarkers)){if(e instanceof Ut&&!t.capabilities.supportsLwPolyline){t.writeStart("POLYLINE"),e.dxfOutAs2dPolyline(t,!0);return}t.writeStart(e.dxfTypeName),e.dxfOut(t,!0)}}writeDxfThumbnailImageSection(t,e=!1){const n=this._thumbnailImage;if(!e||!n||n.length===0||!t.capabilities.supportsObjectsSection)return;const r=127;t.startSection("THUMBNAILIMAGE"),t.writeInt32(90,n.length);for(let s=0;s<n.length;s+=r){const a=n.subarray(s,s+r);t.writeString(310,Po(a))}t.endSection()}clear(){this.transactionManager.clearUndoStack(),this._classes=[],this.clearDxfHeaderExtras(),this._dxfUnknownObjects=[],this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.ucsTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._tables.appIdTable.removeAll(),this._objects.layout.removeAll(),this._objects.group.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.layerFilter.removeAll(),this._objects.layerIndex.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.objectContextData.removeAll(),this._objects.scale.removeAll(),this._objects.dictionaryVar.removeAll(),this._objects.sortentsTable.removeAll(),this._objects.xrecord.removeAll(),this._cannoscale="1:1",this._dimStyleAnnotationScales.clear(),this._annoallvisible=!0,this._layerFilters=new rn,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,n,r){wt.instance().applyVarMutation(t,e,n,this,()=>r(n))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?kt:e.toUpperCase()==="BYBLOCK"?Ne:e}triggerSysVarChangedEvent(t,e,n){const r=wt.instance(),s=t.toLowerCase();r.getDescriptor(s)!=null&&r.events.sysVarChanged.dispatch({database:this,name:s,oldVal:e,newVal:n})}getFileNameFromUri(t){try{const n=new URL(t).pathname.split("/");return n[n.length-1]||""}catch{return""}}};Mr._unsavedDrawingSequence=0;let Zc=Mr;class mv{constructor(){this.transactionStack=[]}startTransaction(){const t=new bh;return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");t.commit()}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");t.abort()}hasTransaction(){return this.transactionStack.length>0}}const qn="ACAD",Oo="DSTYLE",mm={3:"dimpost",4:"dimapost",40:"dimscale",41:"dimasz",42:"dimexo",43:"dimdli",44:"dimexe",45:"dimrnd",46:"dimdle",47:"dimtp",48:"dimtm",140:"dimtxt",141:"dimcen",142:"dimtsz",143:"dimaltf",144:"dimlfac",145:"dimtvp",146:"dimtfac",147:"dimgap",148:"dimaltrnd",70:"dimtfillclr",69:"dimtfill",71:"dimtol",72:"dimlim",73:"dimtih",74:"dimtoh",75:"dimse1",76:"dimse2",77:"dimtad",78:"dimzin",79:"dimazin",170:"dimalt",171:"dimaltd",172:"dimtofl",173:"dimsah",174:"dimtix",175:"dimsoxd",176:"dimclrd",177:"dimclre",178:"dimclrt",179:"dimadec",270:"dimunit",271:"dimdec",272:"dimtdec",273:"dimaltu",274:"dimalttd",275:"dimaunit",276:"dimfrac",277:"dimlunit",278:"dimdsep",279:"dimtmove",280:"dimjust",281:"dimsd1",282:"dimsd2",283:"dimtolj",284:"dimtzin",285:"dimaltz",286:"dimalttz",287:"dimfit",288:"dimupt",289:"dimatfit",294:"dimtxtdirection",295:"dimtxtdirection",340:"dimtxsty",341:"dimldrblk",342:"dimblk",343:"dimblk1",344:"dimblk2",371:"dimlwd",372:"dimlwe"},ym=new Set([340,341,342,343,344]);function yv(i){return mm[i]}function bm(i){const t=Array.from(i.iterateXData(qn)),e=t.findIndex(a=>Number(a.code)===Z.ExtendedDataAsciiString&&String(a.value)===Oo);if(e<0)return[];const n=[];let r=!1,s;for(let a=e+1;a<t.length;a++){const o=t[a],c=Number(o.code);if(c===Z.ExtendedDataControlString){if(String(o.value)==="{"){if(r)break;r=!0;continue}break}if(!r)continue;if(s===void 0){c===Z.ExtendedDataInteger16&&(s=Number(o.value));continue}const l=bv(c,o.value);l!==void 0&&n.push({code:s,value:l}),s=void 0}return n}function bv(i,t){switch(i){case Z.ExtendedDataReal:case Z.ExtendedDataDist:case Z.ExtendedDataScale:case Z.ExtendedDataInteger16:case Z.ExtendedDataInteger32:return Number(t);case Z.ExtendedDataAsciiString:return String(t);case Z.ExtendedDataHandle:return String(t);default:return}}const _v=new Set([341,342,343,344]),xv=new Set(["dimpost","dimapost","dimdsep","dimtxsty","dimldrblk","dimblk","dimblk1","dimblk2"]);function wv(i,t){if(xv.has(i))return typeof t=="string"?t:Number.isFinite(t)?String.fromCharCode(Math.trunc(t)):".";if(typeof t=="string"){const e=Number(t);return Number.isFinite(e)?e:t}return t}function _m(i,t){const e=[];for(const n of i){if(!ym.has(n.code)){e.push(n);continue}const r=String(n.value).trim().toUpperCase(),s=!r||r==="0";if(n.code===340){if(s||!t)continue;const c=t.getObjectById(r),l=c==null?void 0:c.name;l&&e.push({code:n.code,value:l});continue}if(s||!t){_v.has(n.code)&&e.push({code:n.code,value:""});continue}const a=t.getObjectById(r),o=a==null?void 0:a.name;e.push({code:n.code,value:o??""})}return e}function xm(i,t){const e=(i==null?void 0:i.clonePreservingIdentity())??new Vt;e.objectId="";for(const n of t){const r=mm[n.code];r&&r in e&&e.attrs.set(r,wv(r,n.value))}return e}function Do(i,t,e){const n=bm(i);if(n.length===0)return t;const r=_m(n,e);return r.length===0?t:xm(t,r)}function vv(i,t){const e=Array.from(i.iterateXData(qn)).filter(s=>Number(s.code)!==Z.ExtendedDataRegAppName),n=Av(e),r=[{code:Z.ExtendedDataRegAppName,value:qn},...n.map(s=>({code:s.code,value:s.value}))];if(t.length>0){r.push({code:Z.ExtendedDataAsciiString,value:Oo}),r.push({code:Z.ExtendedDataControlString,value:"{"});for(const s of t)r.push({code:Z.ExtendedDataInteger16,value:s.code}),r.push(Sv(s));r.push({code:Z.ExtendedDataControlString,value:"}"})}i.setXData(new Xe(r))}function Av(i){const t=i.findIndex(s=>Number(s.code)===Z.ExtendedDataAsciiString&&String(s.value)===Oo);if(t<0)return i.slice();let e=0,n=!1,r=t+1;for(;r<i.length;r++){const s=i[r];if(Number(s.code)===Z.ExtendedDataControlString){if(String(s.value)==="{")n=!0,e++;else if(n&&--e<=0){r++;break}}}return[...i.slice(0,t),...i.slice(r)]}function Sv(i){if(ym.has(i.code)){const t=String(i.value);return{code:Z.ExtendedDataHandle,value:t||"0"}}return typeof i.value=="string"?{code:Z.ExtendedDataAsciiString,value:i.value}:wm(i.code)?{code:Z.ExtendedDataInteger16,value:Math.trunc(i.value)}:{code:Z.ExtendedDataReal,value:i.value}}const Pv=new Set([69,70,71,72,73,74,75,76,77,78,79,170,171,172,173,174,175,176,177,178,179,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,294,295,371,372]);function wm(i){return Pv.has(i)}const kv=Vt.DEFAULT_DIM_VALUES,uc=6,Fh=class Fh extends et{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new x,this._text="",this._dimensionStyle="",this._normal=new A(0,0,1),this._direction=new A(1,0,0)}get location(){return this._location}set location(t){this._location.set(t.x,t.y,t.z??0)}get text(){return this._text}set text(t){this._text=t}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t,this._dimStyle=void 0,this._dimStyleName=void 0}get normal(){return this._normal}set normal(t){this._normal.set(t.x,t.y,t.z??0),this._normal.lengthSq()>0&&this._normal.normalize()}get direction(){return this._direction}set direction(t){this._direction.set(t.x,t.y,t.z??0),this._direction.lengthSq()>0&&this._direction.normalize()}setOrientation(t,e){return this.normal=t,this.direction=e,this}getBoundingPoints(){return this.getBoundingPolyline().slice(0,4)}getBoundingPolyline(){const{width:t,rowHeight:e,rowCount:n}=this.resolveFrameLayout(),r=e/2,s=r-e*n;return[new x(0,r,0),new x(t,r,0),new x(t,s,0),new x(0,s,0),new x(0,r,0)].map(o=>this.toFrameWcs(o.x,o.y))}get geometricExtents(){const t=new H;for(const e of this.getBoundingPoints())t.expandByPoint(e);return t.isEmpty()&&t.expandByPoint(this._location),t}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return he(t,e,this._location),this}subGetOsnapPoints(t,e,n,r){t===T.Insertion&&r.push(this._location)}transformBy(t){const e=this.resolveLocalBasis(),n=this._location.clone(),r=n.clone().add(e.xAxis),s=n.clone().add(e.yAxis);n.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new A(r).sub(n),o=new A(s).sub(n);let c=new A().crossVectors(a,o);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=a.clone();return l.lengthSq()===0?l=this._direction.clone().transformDirection(t):l.normalize(),this._location.copy(n),this._normal.copy(c),this._direction.copy(l),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"tolerance",properties:[{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"text",type:"string",editable:!0,accessor:{get:()=>this.text,set:t=>{this.text=t}}},{name:"dimensionStyle",type:"string",editable:!0,accessor:{get:()=>this.dimensionStyle,set:t=>{this.dimensionStyle=t}}},{name:"textHeight",type:"float",editable:!1,accessor:{get:()=>this.textHeight}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]}]}}get annotative(){return Se(this)}set annotative(t){me(this,t)}subWorldDraw(t,e){const r=this.collectFrameLineSegments().map(([o,c])=>t.lines([o,c])),s=this.drawToleranceText(t,e);let a;if(r.length>0&&s?a=t.group([...r,s]):r.length===1?a=r[0]:r.length>1?a=t.group(r):a=s,a&&this.annotative){const o=Gn(this);if(o.annotationScale){const c=a.userData??(a.userData={});c.annotationScale=o.annotationScale}}return a}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFcf"),this._dimensionStyle&&t.writeString(3,this._dimensionStyle),t.writePoint3d(10,this._location),t.writeString(1,this._text),this._normal.equals(A.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(A.X_AXIS)||t.writeVector3d(11,this._direction),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFcf");let e=this.location.x,n=this.location.y,r=this.location.z,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=this.direction.x,l=this.direction.y,h=this.direction.z,u=!1,d=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const f=Number(g.code),p=Number(g.value);switch(f){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=p;break;case 20:n=p;break;case 30:r=p;break;case 11:c=p,d=!0;break;case 21:l=p,d=!0;break;case 31:h=p,d=!0;break;case 210:s=p,u=!0;break;case 220:a=p,u=!0;break;case 230:o=p,u=!0;break}}return this.location={x:e,y:n,z:r},u&&(this.normal={x:s,y:a,z:o}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Vt.DEFAULT_DIM_VALUES.dimtxt,n=(t==null?void 0:t.dimscale)??Vt.DEFAULT_DIM_VALUES.dimscale;return e*n}drawToleranceText(t,e){const n=this.parseToleranceFrame(this._text);if(n.length===0)return;const r=this.resolveFrameLayout(n),s=this.getTextStyle(),a=[];for(let o=0;o<n.length;o++){const c=n[o];let l=r.cellPadding;const h=-r.rowHeight*o;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const f=this.toFrameWcs(l+g/2,h),p={text:d,height:this.textHeight,width:1/0,position:f,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};a.push(t.mtext(p,s,e))}l+=g+r.columnGap}}if(a.length!==0)return a.length===1?a[0]:t.group(a)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:n,rowHeight:r,rowCount:s,columnDivisions:a}=e;if(n<=0||r<=0||s<=0)return[];const o=r/2,c=o-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,o),this.toFrameWcs(n,o)),h(this.toFrameWcs(n,o),this.toFrameWcs(n,c)),h(this.toFrameWcs(n,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,o));for(const u of a)h(this.toFrameWcs(u,o),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=o-r*u;h(this.toFrameWcs(0,d),this.toFrameWcs(n,d))}return l}toFrameWcs(t,e){const n=this.resolveLocalBasis();return this._location.clone().addScaledVector(n.xAxis,t).addScaledVector(n.yAxis,e)}resolveFrameLayout(t){const e=t??this.parseToleranceFrame(this._text),n=this.textHeight,r=n*2,s=n/2,a=n;if(n<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const o=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<o;d++){let g=n;for(const f of e){const p=f.cells[d]??"";if(!p.trim())continue;const m=Sx(p,n);g=Math.max(g,m)}c.push(g)}const l=[0];let h=s;for(let d=0;d<c.length;d++)h+=c[d],h+=a,l.push(h-s);return{width:l[l.length-1]??0,totalHeight:r*e.length,rowHeight:r,columnWidths:c,columnDivisions:l,rowCount:e.length,cellPadding:s,columnGap:a}}parseToleranceFrame(t){if(!t)return[];const e=this.splitToleranceRows(t);if(e.length===0)return[];if(!t.includes("%%v"))return e.map(s=>({cells:this.parsePipeSeparatedCells(s)}));const n=e.map(s=>{const o=this.splitToleranceTokens(s,"%%v").slice(0,uc);for(;o.length<uc;)o.push("");return o}),r=[0,1];n.some(s=>{var a;return(a=s[2])==null?void 0:a.trim()})&&r.push(2);for(let s=3;s<uc;s++)n.some(a=>{var o;return(o=a[s])==null?void 0:o.trim()})&&r.push(s);return n.map(s=>({cells:r.map(a=>s[a]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
|
|
13
13
|
`).split(/\r\n|\r|\n|\\P/i).map(n=>n.trim()).filter(n=>n.length>0)}splitToleranceTokens(t,e){if(!t)return[];const n=[];let r="",s=0;for(let a=0;a<t.length;){if(t.startsWith(e,a)&&s===0){n.push(r),r="",a+=e.length;continue}const o=t[a];o==="{"?s++:o==="}"&&(s=Math.max(0,s-1)),r+=o,a++}return n.push(r),n}parsePipeSeparatedCells(t){return t?this.splitToleranceTokens(t,"|").filter(n=>n.length>0):[]}resolveLocalBasis(){const t=this._normal.clone();t.lengthSq()===0?t.set(0,0,1):t.normalize();let e=this._direction.clone();e.lengthSq()===0?e.set(1,0,0):e.normalize();let n=new A().crossVectors(t,e);return n.lengthSq()===0&&(e=A.X_AXIS.clone(),n=new A().crossVectors(t,e)),n.normalize(),e=new A().crossVectors(n,t).normalize(),{xAxis:e,yAxis:n,zAxis:t}}resolveDimensionStyle(){const t=this._dimensionStyle.trim(),e=this.tryGetDatabase();if(!t||!e)return;if(this._dimStyle&&this._dimStyleName===t)return this._dimStyle;const n=e.tables.dimStyleTable.getAt(t),r=Do(this,n,e);return this._dimStyle=r,this._dimStyleName=t,r}onXDataChanged(t){t===qn&&(this._dimStyle=void 0,this._dimStyleName=void 0)}onDatabaseChanged(){this._dimStyle=void 0,this._dimStyleName=void 0}tryGetDatabase(){try{return this.database}catch{return}}getTextStyle(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxsty)??Vt.DEFAULT_DIM_VALUES.dimtxsty??"Standard",n=this.database.tables.textStyleTable.resolveAt(e);if(!n)throw new Error("No valid text style found in text style table.");return n.textStyle}};Fh.typeName="Fcf";let xa=Fh;const zh=class zh extends et{constructor(){super(),this._normal=new A(0,0,1),this._annotationHeight=0,this._columnType=0,this._columnCount=0,this._columnFlowReversed=!1,this._columnAutoHeight=!1,this._columnWidth=0,this._columnGutter=0,this._contents="",this._height=0,this._width=0,this._extentsWidth=0,this._lineSpacingFactor=1,this._lineSpacingStyle=0,this._backgroundFill=!1,this._useBackgroundColor=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new x,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.TopLeft,this._direction=new A(1,0,0),this._drawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT}get dxfTypeName(){return"MTEXT"}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get annotative(){return Se(this)}set annotative(t){me(this,t)}get width(){return this._width}set width(t){this._width=t}get extentsWidth(){return this._extentsWidth}set extentsWidth(t){this._extentsWidth=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,t||(this._useBackgroundColor=!1)}get useBackgroundColor(){return this._useBackgroundColor}set useBackgroundColor(t){this._useBackgroundColor=t,t&&(this._backgroundFill=!0)}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get annotationHeight(){return this._annotationHeight}set annotationHeight(t){this._annotationHeight=t}get columnType(){return this._columnType}set columnType(t){this._columnType=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=t}get columnFlowReversed(){return this._columnFlowReversed}set columnFlowReversed(t){this._columnFlowReversed=t}get columnAutoHeight(){return this._columnAutoHeight}set columnAutoHeight(t){this._columnAutoHeight=t}get columnWidth(){return this._columnWidth}set columnWidth(t){this._columnWidth=t}get columnGutter(){return this._columnGutter}set columnGutter(t){this._columnGutter=t}resolveAnnotativePresentation(){var u;const t=Wt(this),e=t.length>0||pe(this);let n=this.height,r=this._location,s=this.direction,a=this.attachmentPoint,o=this.width,c=this.extentsWidth,l,h;if(e&&t.length>0){const d=Re(this.height,t);l=He(t,(u=this.database)==null?void 0:u.cannoscale)??t.find(f=>f.isDefault)??t[0],n=Be(d,l.scale.scaleFactor);const g=l.contextData;g instanceof Ue&&(r=g.insertionPoint,s=g.direction,a=g.attachmentPoint,g.definedWidth>0&&(o=g.definedWidth),g.extentsWidth>0&&(c=g.extentsWidth)),h=Ge(t,l)}return{height:n,width:o,extentsWidth:c,position:r,direction:s,attachmentPoint:a,preferred:l,annotationScale:h}}get geometricExtents(){const t=new H,e=this.resolveAnnotativePresentation(),n=jc({contents:this.contents,height:e.height,width:e.width,extentsWidth:e.extentsWidth,lineSpacingFactor:this.lineSpacingFactor,lineSpacingStyle:this.lineSpacingStyle,attachmentPoint:e.attachmentPoint,rotation:this.rotation,direction:e.direction,location:e.position}),r=this.backgroundFill?td(this.backgroundScaleFactor,e.height):0;for(const s of Vc(n,r))t.expandByPoint(s);return t.isEmpty()&&t.expandByPoint(e.position),t}subGetGripPoints(){return[this.resolveAnnotativePresentation().position]}subMoveGripPointsAt(t,e){const{preferred:n}=this.resolveAnnotativePresentation(),r=n==null?void 0:n.contextData;return r instanceof Ue?(he(t,e,r.insertionPoint),n!=null&&n.isDefault&&he(t,e,this._location),this):(he(t,e,this._location),this)}subGetOsnapPoints(t,e,n,r){T.Insertion===t&&r.push(this.resolveAnnotativePresentation().position)}transformBy(t){const e=this._location.clone(),n=this._direction.lengthSq()>0?this._direction.clone().normalize():new A(Math.cos(this._rotation),Math.sin(this._rotation),0),r=new A(-n.y,n.x,n.z);r.lengthSq()===0&&r.set(0,1,0),r.normalize();const s=e.clone().add(n),a=e.clone().add(r);e.applyMatrix4(t),s.applyMatrix4(t),a.applyMatrix4(t);const o=new A(s).sub(e),c=new A(a).sub(e),l=o.length(),h=c.length();return this._location.copy(e),l>0&&(this._direction.copy(o).normalize(),this._rotation=Math.atan2(this._direction.y,this._direction.x),this._width*=l,this._extentsWidth>0&&(this._extentsWidth*=l)),h>0&&(this._height*=h),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:exports.AcGiMTextAttachmentPoint[1],value:1},{label:exports.AcGiMTextAttachmentPoint[2],value:2},{label:exports.AcGiMTextAttachmentPoint[3],value:3},{label:exports.AcGiMTextAttachmentPoint[4],value:4},{label:exports.AcGiMTextAttachmentPoint[5],value:5},{label:exports.AcGiMTextAttachmentPoint[6],value:6},{label:exports.AcGiMTextAttachmentPoint[7],value:7},{label:exports.AcGiMTextAttachmentPoint[8],value:8},{label:exports.AcGiMTextAttachmentPoint[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:exports.AcGiMTextFlowDirection[1],value:1},{label:exports.AcGiMTextFlowDirection[2],value:2},{label:exports.AcGiMTextFlowDirection[3],value:3},{label:exports.AcGiMTextFlowDirection[4],value:4},{label:exports.AcGiMTextFlowDirection[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}},{name:"lineSpacingStyle",type:"int",editable:!0,accessor:{get:()=>this.lineSpacingStyle,set:t=>{this.lineSpacingStyle=t}}},{name:"backgroundFill",type:"boolean",editable:!0,accessor:{get:()=>this.backgroundFill,set:t=>{this.backgroundFill=t}}},{name:"useBackgroundColor",type:"boolean",editable:!0,accessor:{get:()=>this.useBackgroundColor,set:t=>{this.useBackgroundColor=t}}},{name:"backgroundFillColor",type:"int",editable:!0,accessor:{get:()=>this.backgroundFillColor,set:t=>{this.backgroundFillColor=t}}},{name:"backgroundScaleFactor",type:"float",editable:!0,accessor:{get:()=>this.backgroundScaleFactor,set:t=>{this.backgroundScaleFactor=t}}},{name:"annotationHeight",type:"float",editable:!0,accessor:{get:()=>this.annotationHeight,set:t=>{this.annotationHeight=t}}},{name:"columnType",type:"int",editable:!0,accessor:{get:()=>this.columnType,set:t=>{this.columnType=t}}},{name:"columnCount",type:"int",editable:!0,accessor:{get:()=>this.columnCount,set:t=>{this.columnCount=t}}},{name:"columnWidth",type:"float",editable:!0,accessor:{get:()=>this.columnWidth,set:t=>{this.columnWidth=t}}},{name:"columnGutter",type:"float",editable:!0,accessor:{get:()=>this.columnGutter,set:t=>{this.columnGutter=t}}},{name:"columnAutoHeight",type:"boolean",editable:!0,accessor:{get:()=>this.columnAutoHeight,set:t=>{this.columnAutoHeight=t}}},{name:"columnFlowReversed",type:"boolean",editable:!0,accessor:{get:()=>this.columnFlowReversed,set:t=>{this.columnFlowReversed=t}}},{name:"backgroundFillTransparency",type:"float",editable:!0,accessor:{get:()=>this.backgroundFillTransparency,set:t=>{this.backgroundFillTransparency=t}}},{name:"extentsWidth",type:"float",editable:!1,accessor:{get:()=>this.extentsWidth}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}subWorldDraw(t,e){const{height:n,width:r,extentsWidth:s,position:a,direction:o,attachmentPoint:c,annotationScale:l}=this.resolveAnnotativePresentation(),h=[],u=this.drawBackgroundMask(t,n,r,s,a,o,c);u&&h.push(u);const d={text:this.contents,height:n,width:r,position:a,rotation:this.rotation,directionVector:o,attachmentPoint:c,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor,lineSpaceStyle:this.lineSpacingStyle},g=t.mtext(d,this.getTextStyle(),e);g&&h.push(g);const f=h.length===0?void 0:h.length===1?h[0]:t.group(h);if(f&&l){const p=f.userData;p.annotationScale=l}if(f&&u&&g){const p={skipMeshGlyphInstancing:!0};Object.assign(f.userData,p),Object.assign(g.userData,p)}return f}drawBackgroundMask(t,e,n,r,s,a,o){if(!this.backgroundFill)return;const c=jc({contents:this.contents,height:e,width:n,extentsWidth:r,lineSpacingFactor:this.lineSpacingFactor,lineSpacingStyle:this.lineSpacingStyle,attachmentPoint:o,rotation:this.rotation,direction:a,location:s});if(c.width<=0&&c.height<=0)return;const l=td(this.backgroundScaleFactor,e),h=Vc(c,l);if(h.length<3)return;const u=t.subEntityTraits,d=u.color,g=u.isColorByLayer,f=u.fillType,p=u.isBackgroundFill,m=u.drawOrder;if(u.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},u.drawOrder=0,this.useBackgroundColor)u.isBackgroundFill=!0,u.isColorByLayer=!1;else{u.isBackgroundFill=!1;const _=this.resolveBackgroundFillColor();u.color=_,u.isColorByLayer=!1}const y=new de;y.add(new ot(h,!0));const b=t.area(y);return u.color=d,u.isColorByLayer=g,u.fillType=f,u.isBackgroundFill=p,u.drawOrder=m,b}resolveBackgroundFillColor(){const t=this.backgroundFillColor,e=new X;return t>0&&t<=255?(e.colorIndex=t,e):(e.setRGBValue(t>>>0),e)}encodeMTextContentsForDxf(t){return(t??"").replace(/\r\n|\r|\n/g,"\\P")}dxfOutFields(t){if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbMText"),t.writePoint3d(10,this.location),t.writeDouble(40,this.height),t.writeDouble(41,this.width),this.extentsWidth>0&&t.writeDouble(42,this.extentsWidth),t.writeMTextContents(this.encodeMTextContentsForDxf(this.contents??"")),t.writeString(7,this.styleName),t.writeAngle(50,this.rotation),t.writeVector3d(11,this.direction),t.writeInt16(71,this.attachmentPoint),t.writeInt16(72,this.drawingDirection),t.writeInt16(73,this.lineSpacingStyle),t.writeDouble(44,this.lineSpacingFactor),this.backgroundFill){if(t.writeInt16(90,this.useBackgroundColor?3:1),!this.useBackgroundColor){const e=this.backgroundFillColor>>>0;e>0&&e<=255?t.writeInt16(63,e):t.writeInt32(421,e)}t.writeInt32(441,this.backgroundFillTransparency),t.writeDouble(45,this.backgroundScaleFactor)}return this.annotationHeight!==0&&t.writeDouble(46,this.annotationHeight),this.columnType!==0&&(t.writeInt16(75,this.columnType),t.writeInt16(76,this.columnCount),t.writeInt16(78,this.columnFlowReversed?1:0),t.writeInt16(79,this.columnAutoHeight?1:0),t.writeDouble(48,this.columnWidth),t.writeDouble(49,this.columnGutter)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMText");let e=this.location.x,n=this.location.y,r=this.location.z,s=this.direction.x,a=this.direction.y,o=this.direction.z,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=!1;const d=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const f=Number(g.code),p=Number(g.value);switch(f){case 10:e=p;break;case 20:n=p;break;case 30:r=p;break;case 11:s=p,u=!0;break;case 21:a=p,u=!0;break;case 31:o=p,u=!0;break;case 1:case 3:d.push(String(g.value));break;case 7:this.styleName=String(g.value);break;case 40:this.height=p;break;case 41:this.width=p;break;case 42:p>0&&(this.extentsWidth=p);break;case 43:break;case 44:this.lineSpacingFactor=p;break;case 45:this.backgroundScaleFactor=p;break;case 46:this.annotationHeight=p;break;case 48:this.columnWidth=p;break;case 49:this.columnGutter=p;break;case 50:this.rotation=D.degToRad(p);break;case 71:this.attachmentPoint=p;break;case 72:this.drawingDirection=p;break;case 73:this.lineSpacingStyle=p;break;case 75:this.columnType=p;break;case 76:this.columnCount=p;break;case 78:this.columnFlowReversed=p!==0;break;case 79:this.columnAutoHeight=p!==0;break;case 90:{const m=p|0;this._backgroundFill=m!==0,this._useBackgroundColor=(m&2)!==0;break}case 63:this.backgroundFillColor=p;break;case 421:this.backgroundFillColor=p>>>0;break;case 441:this.backgroundFillTransparency=p;break;case 101:for(;!t.atEndOfObject&&!t.atEof&&t.readItem(););break;case 210:c=p;break;case 220:l=p;break;case 230:h=p;break;case 100:return t.pushBackItem(g),this.finishMTextDxfIn(d,e,n,r,s,a,o,u,c,l,h),this}}return this.finishMTextDxfIn(d,e,n,r,s,a,o,u,c,l,h),this}finishMTextDxfIn(t,e,n,r,s,a,o,c,l,h,u){t.length>0&&(this.contents=t.join("")),this.location={x:e,y:n,z:r},c&&(this.direction={x:s,y:a,z:o});const d=new A(l,h,u);d.lengthSq()>0&&this.normal.copy(d.normalize())}};zh.typeName="MText";let Kn=zh;function Mt(i,t){var e;if(t){const n=Gn(t);if(n.preferred&&n.preferred.scale.scaleFactor>0)return n.preferred.scale.scaleFactor}try{const n=(e=i.database)==null?void 0:e.getDimStyleAnnotationScale(i.name);if(n!=null&&n>0)return n}catch{}return i.dimscale>0?i.dimscale:1}function Iv(i,t){let e=i*t.dimlfac;t.dimrnd>0&&(e=Math.round(e/t.dimrnd)*t.dimrnd);let n;switch(t.dimlunit){case 1:n=e.toExponential(Math.max(0,t.dimdec));break;case 4:case 5:n=Lv(e,t.dimdec);break;case 3:n=Mv(e,t.dimdec);break;case 2:default:n=Sr(e,t.dimdec,t.dimdsep,t.dimzin);break}return n=Cv(n,t.dimzin),_h(n,t.dimpost)}function Ev(i,t){const e=Math.abs(i);let n;switch(t.dimaunit){case 1:{const r=e*180/Math.PI,s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=(a-o)*60,l=t.dimadec>0?c.toFixed(t.dimadec):String(Math.round(c));n=`${s}d${String(o).padStart(2,"0")}'${l}"`;break}case 2:n=Sr(e*200/Math.PI,t.dimadec,t.dimdsep,t.dimazin),n=`${n}g`;break;case 3:n=Sr(e,t.dimadec,t.dimdsep,t.dimazin),n=`${n}r`;break;case 0:default:{const r=e*180/Math.PI;n=Sr(r,t.dimadec,t.dimdsep,t.dimazin),n=`${n}%%d`;break}}return n=Ov(n,t.dimazin),_h(n,t.dimpost)}function Tv(i,t,e,n="linear"){if(t===".")return"";let r=n==="angular"?Ev(i,e):Iv(i,e);if(n==="radial"&&!r.startsWith("R")?r=`R${r}`:n==="diametric"&&!r.includes("%%c")&&(r=`%%c${r}`),e.dimtol===1&&n!=="angular"){const s=e.dimtp.toFixed(Math.max(0,e.dimtdec)),a=e.dimtm.toFixed(Math.max(0,e.dimtdec));r=`${r}{\\H0.7x;\\S+${s}^-${a};}`}if(e.dimalt===1&&n!=="angular"){const s=i*e.dimlfac*(e.dimaltf||25.4),a=e.dimaltd,o=Sr(s,a,e.dimdsep,e.dimaltz),c=_h(o,e.dimapost||"");r=`${r} [${c}]`}return t==null||t===""?r:t.includes("<>")?t.split("<>").join(r):t}function Sr(i,t,e=".",n=0){const r=i.toFixed(Math.max(0,t));return e&&e!=="."?r.replace(".",e):r}function Lv(i,t){const e=Math.trunc(i),n=Math.abs(i-e),r=Math.max(1,Math.pow(2,Math.min(6,Math.max(0,t)))),s=Math.round(n*r);if(s===0)return String(e);if(s===r)return String(e+(i<0?-1:1));const a=Dv(s,r),o=s/a,c=r/a;return e===0?`${i<0?"-":""}${o}/${c}`:`${e} ${o}/${c}`}function Mv(i,t){const e=Math.trunc(i/12),n=i-e*12;return`${e}'-${n.toFixed(Math.max(0,t))}"`}function _h(i,t){return t?t.includes("<>")?t.split("<>").join(i):`${i}${t}`:i}function Cv(i,t){return(t&ya.Leading)!==0&&i.startsWith("0.")&&(i=i.slice(1)),(t&ya.Trailing)!==0&&i.includes(".")&&(i=i.replace(/\.?0+$/,"")),i}function Ov(i,t){return(t===fi.Leading||t===fi.LeadingAndTrailing)&&i.startsWith("0.")&&(i=i.slice(1)),(t===fi.Trailing||t===fi.LeadingAndTrailing)&&i.includes(".")&&(i=i.replace(/(\.\d*?)0+(%%d|g|r|"|')?$/,"$1$2").replace(/\.(%%d|g|r)/,"$1")),i}function Dv(i,t){let e=Math.abs(i),n=Math.abs(t);for(;n;){const r=n;n=e%n,e=r}return e||1}const vm="_CLOSEDFILLED";function Gt(i){return i==null||i===""||i===exports.AcGiArrowType.ClosedFilled?vm:i===exports.AcGiArrowType.None||i.toUpperCase()==="_NONE"?"":i}function Jn(i,t){const e=new fh(i),n=new Set;t.dimsah===0?n.add(Gt(t.dimblk)):(n.add(Gt(t.dimblk1)),n.add(Gt(t.dimblk2))),n.add(Gt(t.dimldrblk));for(const r of n)r&&e.ensureArrowBlock(r)}function xh(i){return Ur(i)}function Pt(i,t,e,n="dimension"){const r=new $i(i,t);return r.layer="0",r.color=xh(n==="dimension"?e.dimclrd:e.dimclre),r}function xe(i,t,e,n){if(!n)return null;const r=new Qt(n);return r.position=i,r.rotation=t,r.scaleFactors={x:e,y:e,z:e},r.layer="0",r.color=new X(exports.AcCmColorMethod.ByBlock),r}function gs(i,t){const e=Mt(i,t);return i.dimtsz>0?i.dimtsz*e:i.dimasz*e}function No(i,t){return i.dimtxt*Mt(i,t)}function Zn(i){if(!i.contents)return null;const t=new Kn;return t.layer="0",t.color=xh(i.style.dimclrt),t.location=i.position,t.contents=i.contents,t.height=No(i.style,i.entity),t.direction={x:Math.cos(i.rotation),y:Math.sin(i.rotation),z:0},t.styleName=i.style.dimtxsty,t.attachmentPoint=i.attachmentPoint??Nv(i.style.dimtad),t}function Nv(i){switch(i){case Fn.Above:return exports.AcGiMTextAttachmentPoint.BottomCenter;case Fn.Below:return exports.AcGiMTextAttachmentPoint.TopCenter;default:return exports.AcGiMTextAttachmentPoint.MiddleCenter}}function wa(i,t,e,n){const r=(e.dimgap>=0?e.dimgap:0)*Mt(e,n),s=No(e,n);let a=0;e.dimtad===Fn.Above?a=r+s*.5:e.dimtad===Fn.Below?a=-(r+s*.5):e.dimtad===Fn.Outside&&(a=r+s*.5);const o=-Math.sin(t),c=Math.cos(t);return new x(i.x+o*a,i.y+c*a,i.z??0)}function Rv(i,t,e,n){const r=e.dimcen*Mt(e,n);if(r===0)return;const s=Math.abs(r),a=new x().copy(t);if(i.appendEntity(Pt({x:a.x-s,y:a.y,z:a.z},{x:a.x+s,y:a.y,z:a.z},e,"extension")),i.appendEntity(Pt({x:a.x,y:a.y-s,z:a.z},{x:a.x,y:a.y+s,z:a.z},e,"extension")),r<0){const o=s*2;i.appendEntity(Pt({x:a.x-o,y:a.y,z:a.z},{x:a.x+o,y:a.y,z:a.z},e,"extension")),i.appendEntity(Pt({x:a.x,y:a.y-o,z:a.z},{x:a.x,y:a.y+o,z:a.z},e,"extension"))}}function ar(i){const t=new lt;return t.name=i,t}function Qn(i,t,e,n){return Tv(i,t,e,n)}function Ii(i,t,e,n,r){const s=new jr(i,t,e,n);return s.layer="0",s.color=xh(r.dimclrd),s}function sn(i,t){return Math.atan2(t.y-i.y,t.x-i.x)}function dc(i){let t=i;for(;t<0;)t+=Math.PI*2;for(;t>=Math.PI*2;)t-=Math.PI*2;return t}function Bv(i,t,e){return i<=t?e>=i&&e<=t:e>=i||e<=t}function va(i){const t=sn(i.center,i.xLine1),e=sn(i.center,i.xLine2),n=sn(i.center,i.arcPoint);let r=t,s=e;const a=dc(r),o=dc(s),c=dc(n);Bv(a,o,c)||(r=e,s=t);let l=s-r;for(;l<0;)l+=Math.PI*2;for(;l>Math.PI*2;)l-=Math.PI*2;return{start:r,end:s,sweep:l}}function Kt(i,t,e){return new x(i.x+Math.cos(t)*e,i.y+Math.sin(t)*e,i.z??0)}function Qc(i,t){return new x((i.x+t.x)/2,(i.y+t.y)/2,((i.z??0)+(t.z??0))/2)}function Fv(i,t,e){const n=t.dimdle*Mt(t,e);n!==0&&(i.extend(n),i.extend(n,!0))}var pi=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(pi||{});const Xh=class Xh extends Ot{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._isHookLineSameDirection=!1,this._annoType=3,this._textHeight=0,this._textWidth=0,this._associatedAnnotation="",this._normal=new A(0,0,1),this._horizontalDirection=new A(1,0,0)}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get isHookLineSameDirection(){return this._isHookLineSameDirection}set isHookLineSameDirection(t){this._isHookLineSameDirection=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t,this._dimStyle=void 0,this._dimStyleName=void 0}get annoType(){return this._annoType}set annoType(t){this._annoType=t}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get byBlockColor(){return this._byBlockColor}set byBlockColor(t){this._byBlockColor=t}get associatedAnnotation(){return this._associatedAnnotation}set associatedAnnotation(t){this._associatedAnnotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get horizontalDirection(){return this._horizontalDirection}set horizontalDirection(t){this._horizontalDirection.copy(t)}get offsetFromBlock(){var t;return(t=this._offsetFromBlock)==null?void 0:t.clone()}set offsetFromBlock(t){this._offsetFromBlock=t?new A(t):void 0}get offsetFromAnnotation(){var t;return(t=this._offsetFromAnnotation)==null?void 0:t.clone()}set offsetFromAnnotation(t){this._offsetFromAnnotation=t?new A(t):void 0}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[this.createProperty("dimensionStyleName","string",()=>this.dimensionStyle,t=>{this.dimensionStyle=t}),this.createProperty("annoType","enum",()=>this.annoType,t=>{this.annoType=t},[{label:pi[0],value:0},{label:pi[1],value:1},{label:pi[2],value:2},{label:pi[3],value:3}]),this.createProperty("hasArrowHead","boolean",()=>this.hasArrowHead,t=>{this.hasArrowHead=t}),this.createProperty("hasHookLine","boolean",()=>this.hasHookLine,t=>{this.hasHookLine=t}),this.createProperty("isHookLineSameDirection","boolean",()=>this.isHookLineSameDirection,t=>{this.isHookLineSameDirection=t}),this.createProperty("isSplined","boolean",()=>this.isSplined,t=>{this.isSplined=t}),this.createProperty("associatedAnnotation","string",()=>this._associatedAnnotation),this.createProperty("byBlockColor","int",()=>this._byBlockColor)]},{groupName:"text",properties:[this.createProperty("textHeight","float",()=>this.textHeight,t=>{this.textHeight=t}),this.createProperty("textWidth","float",()=>this.textWidth,t=>{this.textWidth=t})]},{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!1},{name:"y",type:"float",editable:!1},{name:"z",type:"float",editable:!1}]},accessor:{get:()=>this.vertices.map(t=>({x:t.x,y:t.y,z:t.z}))}},...this.createPoint3dProperties("normal",()=>this._normal),...this.createPoint3dProperties("horizontalDirection",()=>this._horizontalDirection),...this.createOptionalPoint3dProperties("offsetFromBlock",()=>this.offsetFromBlock,t=>{this.offsetFromBlock=t}),...this.createOptionalPoint3dProperties("offsetFromAnnotation",()=>this.offsetFromAnnotation,t=>{this.offsetFromAnnotation=t})]}]}}createProperty(t,e,n,r,s){return{name:t,type:e,editable:r!=null,options:s,accessor:r?{get:n,set:r}:{get:n}}}createPoint3dProperties(t,e){return[this.createProperty(`${t}X`,"float",()=>e().x,n=>{e().x=n}),this.createProperty(`${t}Y`,"float",()=>e().y,n=>{e().y=n}),this.createProperty(`${t}Z`,"float",()=>e().z,n=>{e().z=n})]}createOptionalPoint3dProperties(t,e,n){const r=s=>this.createProperty(`${t}${s.toUpperCase()}`,"float",()=>{var a;return(a=e())==null?void 0:a[s]},a=>{if(a==null)return;const o=e();n({x:s==="x"?a:(o==null?void 0:o.x)??0,y:s==="y"?a:(o==null?void 0:o.y)??0,z:s==="z"?a:(o==null?void 0:o.z)??0})});return[r("x"),r("y"),r("z")]}appendVertex(t){this._vertices.push(new x().copy(t)),this._updated=!0}setVertexAt(t,e){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].copy(e),this._updated=!0,this}vertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].clone()}subGetGripPoints(){return this._vertices.map(t=>t.clone())}subMoveGripPointsAt(t,e){return er(t,e,this._vertices),this}subGetOsnapPoints(t,e,n,r){if(this.numVertices===0)return;if(this.isSplined&&this.splineGeo){switch(t){case T.EndPoint:r.push(this._vertices[0]),r.push(this._vertices[this.numVertices-1]);break;case T.Nearest:r.push(this.splineGeo.nearestPoint(e));break}return}const s=this._vertices;switch(t){case T.EndPoint:r.push(...s);break;case T.MidPoint:case T.Nearest:case T.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];nr(s[o],s[o+1],t,e,c),a.push(...c)}if(t===T.MidPoint)r.push(...a);else{const o=ye(e,a);o&&r.push(o)}break}}}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new H().setFromPoints(this.collectDrawPoints())}subGetIntersectCurves(){return this.isSplined&&this.splineGeo?[{kind:"spline",spline:this.splineGeo.clone(),extendable:!1}]:ee(this._vertices,!1)}get closed(){return!1}set closed(t){}get area(){return 0}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this.transformVector(this._normal,t),this.transformVector(this._horizontalDirection,t),this._offsetFromBlock&&this.transformVector(this._offsetFromBlock,t),this._offsetFromAnnotation&&this.transformVector(this._offsetFromAnnotation,t),this._splineGeo?(this._splineGeo.transform(t),this._updated=!1):this._updated=!0,this}get directBatchPrimitive(){return this._hasArrowHead&&this._vertices.length>=2||this.leaderLineColorDiffersFromEntity()?null:"lineStrip"}subWorldDraw(t){const e=[],n=this.collectDrawPoints(t),r=this.resolveLeaderLineColor(),s=t.subEntityTraits,a=()=>{n.length>0&&e.push(t.lines(n));const o=this.drawArrowHead(t,n,r);o&&e.push(o)};if(r&&s){const o=this.applyTraitsColor(s,r,this.leaderLineColorFollowsLayer());try{a()}finally{o()}}else a();return e.length===0?t.lines([]):e.length===1?e[0]:t.group(e)}get hasRenderableArrowHead(){return!this._hasArrowHead||this.numVertices<2||this.resolveArrowHeadBlockName()===""?!1:this.resolveArrowHeadSize()>0}resolveLeaderLineColor(){const t=this.resolveDimensionStyle();if(!t)return;const e=Ur(t.dimclrd);return e.isByBlock?this.resolveByBlockLeaderColor():e.isByLayer?this.resolveLayerLeaderColor():e}leaderLineColorDiffersFromEntity(){const t=this.resolveLeaderLineColor();if(!t)return!1;try{return!t.equals(this.resolvedColor)||this.leaderLineColorFollowsLayer()!==this.color.isByLayer}catch{return!0}}leaderLineColorFollowsLayer(){const t=this.resolveDimensionStyle();if(!t)return!1;const e=Ur(t.dimclrd);return e.isByLayer?!0:e.isByBlock&&this._byBlockColor===256}resolveByBlockLeaderColor(){const t=this._byBlockColor;if(!(t==null||t===0)){if(t===256)return this.resolveLayerLeaderColor();if(t>0&&t<256){const e=new X;return e.colorIndex=t,e}}}resolveLayerLeaderColor(){var t;try{return(t=this.getLayerColor())==null?void 0:t.clone()}catch{return}}drawArrowHead(t,e,n){if(!this.hasRenderableArrowHead||e.length<2)return;const r=e[0],s=e.find(w=>!w.equals(r));if(!s)return;const a=new A().subVectors(s,r);if(a.lengthSq()===0)return;a.normalize();const o=this.resolveArrowHeadSize(),c=Math.atan2(-a.y,-a.x),l=this.resolveArrowHeadBlockName(),h=this.resolveArrowHeadBlock(l);if(h){const w=h.origin??x.ORIGIN,k=new z().makeTranslation(-w.x,-w.y,-w.z),P=new z().makeScale(o,o,o),v=new z().makeRotationZ(c),S=new z().makeTranslation(r.x,r.y,r.z),I=new z().multiplyMatrices(S,v).multiply(P).multiply(k);return Tn.instance.draw(t,h,n??this.resolvedColor,[],!0,I,new A(this.normal))}if(l!==vm)return;const u=r.clone().addScaledVector(a,o),d=o/6,g=new A(-a.y,a.x,a.z),f=u.clone().addScaledVector(g,d),p=u.clone().addScaledVector(g,-d),m=new de;m.add(new ot([r,f,p,r],!0));const y=t.subEntityTraits,b=y.fillType;y.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const _=t.area(m);return y.fillType=b,_}resolveArrowHeadSize(){const t=this.resolveDimensionStyle();if(!t)return Vt.DEFAULT_DIM_VALUES.dimasz;const e=Mt(t,this),n=(t.dimasz??0)*(e>0?e:1);return n>0?n:0}resolveArrowHeadBlockName(){const t=this.resolveDimensionStyle();return Gt(t==null?void 0:t.dimldrblk)}resolveArrowHeadBlock(t){if(!t)return;const e=this.tryGetDatabase();if(!e)return;const n=e.tables.blockTable.getAt(t);if(n)return n;const r=this.resolveDimensionStyle();return r&&Jn(e,r),e.tables.blockTable.getAt(t)}collectDrawPoints(t){if(this.isSplined&&this.splineGeo)return this.splineGeo.tessellate(ds(t));const e=this._vertices.map(n=>n.clone());if(e.length>0&&!this._isSplined){const n=e[e.length-1];if(this.shouldDrawHookLine(n)){const r=this.computeHookLineEndPoint(n);r&&e.push(r)}}return e}shouldDrawHookLine(t){return this._hasHookLine?this.resolveHookLineLength(t)>0:!1}computeHookLineEndPoint(t){const e=this.resolveHookLineLength(t);if(e<=0)return null;const n=this.resolveHookAxis();return t.clone().addScaledVector(n,e)}resolveHookLineLength(t){const e=this.resolveDimensionStyle(),n=((e==null?void 0:e.dimgap)??Vt.DEFAULT_DIM_VALUES.dimgap)*(e?Mt(e,this):1),r=Math.abs(this._textWidth);let s=r>0?r+n:0;const a=this.resolveAssociatedMText();if(a){const o=this.resolveHookSpanFromMText(a,t);if(o>s)s=o;else{const c=this.resolveAnnotationWidth(a);c>s&&(s=c)}}return s}resolveHookAxis(){const t=this._horizontalDirection.clone();t.lengthSq()===0?t.set(1,0,0):t.normalize();let e=this._isHookLineSameDirection?1:-1;return this._textWidth<0&&(e=-e),t.multiplyScalar(e),t}resolveHookSpanFromMText(t,e){const n=this.resolveHookAxis(),r=this.resolveMTextLayoutMetrics(t);let s=0;for(const a of Vc(r)){const o=(a.x-e.x)*n.x+(a.y-e.y)*n.y+(a.z-e.z)*n.z;o>s&&(s=o)}return s}resolveAnnotationWidth(t){if(t.extentsWidth>0)return t.extentsWidth;const e=Jl(t.contents).split(`
|
|
14
14
|
`);return Math.max(...e.map(n=>En(n.trim(),t.height)),0)}resolveMTextLayoutMetrics(t){return jc({contents:t.contents,height:t.height,width:t.width,extentsWidth:t.extentsWidth,lineSpacingFactor:t.lineSpacingFactor,lineSpacingStyle:t.lineSpacingStyle,attachmentPoint:t.attachmentPoint,rotation:t.rotation,direction:t.direction,location:t.location})}scoreMTextAssociation(t,e){const n=this.resolveMTextLayoutMetrics(t),r=Math.max(t.height*2,1),s=Math.max(t.height,1),a=Math.max(n.height,t.height*4,10);return Tx(e,n,{padX:r,padYAbove:s,padYBelow:a})}resolveDimensionStyle(){var s;const t=(s=this._dimensionStyle)==null?void 0:s.trim(),e=this.tryGetDatabase();if(!t||!e)return;if(this._dimStyle&&this._dimStyleName===t)return this._dimStyle;const n=e.tables.dimStyleTable.getAt(t),r=Do(this,n,e);return this._dimStyle=r,this._dimStyleName=t,r}onXDataChanged(t){t===qn&&(this._dimStyle=void 0,this._dimStyleName=void 0)}onDatabaseChanged(){this._dimStyle=void 0,this._dimStyleName=void 0}resolveAssociatedMText(){const t=this.tryGetDatabase();if(!t)return;if(this._associatedAnnotation){const o=t.getObjectById(this._associatedAnnotation);return o instanceof Kn?o:void 0}if(this._annoType!==0||this._vertices.length===0)return;const e=this.getAttrWithoutException("ownerId");if(!e)return;const n=t.getObjectById(e);if(!(n instanceof lt))return;const r=this._vertices[this._vertices.length-1];let s,a=Number.POSITIVE_INFINITY;for(const o of n.newIterator()){if(!(o instanceof Kn))continue;const c=this.scoreMTextAssociation(o,r);c==null||c>=a||(a=c,s=o)}return s}tryGetDatabase(){try{return this.database}catch{return}}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Xt(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.isSplined?1:0),t.writeInt16(73,this.annoType),t.writeInt16(74,this.isHookLineSameDirection?1:0),t.writeInt16(75,this.hasHookLine?1:0),t.writeInt16(76,this.numVertices),this.textHeight!==0&&t.writeDouble(40,this.textHeight),this.textWidth!==0&&t.writeDouble(41,this.textWidth),this.byBlockColor!=null&&t.writeInt16(77,this.byBlockColor),this.associatedAnnotation&&t.writeHandle(340,this.associatedAnnotation);for(const e of this.vertices)t.writePoint3d(10,e);return t.writeVector3d(210,this.normal),t.writeVector3d(211,this.horizontalDirection),this._offsetFromBlock&&t.writeVector3d(212,this._offsetFromBlock),this._offsetFromAnnotation&&t.writeVector3d(213,this._offsetFromAnnotation),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLeader"),this._vertices.length=0;let e=null,n=this.normal.x,r=this.normal.y,s=this.normal.z,a=this.horizontalDirection.x,o=this.horizontalDirection.y,c=this.horizontalDirection.z,l=0,h=0,u=0,d=0,g=0,f=0,p=!1,m=!1;const y=()=>{e&&(this.appendVertex(e),e=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),w=Number(b.value);switch(_){case 3:this.dimensionStyle=String(b.value);break;case 10:y(),e={x:w,y:0,z:0};break;case 20:e&&(e.y=w);break;case 30:e&&(e.z=w);break;case 40:this.textHeight=w;break;case 41:this.textWidth=w;break;case 71:this.hasArrowHead=w!==0;break;case 72:this.isSplined=w!==0;break;case 73:this.annoType=w;break;case 74:this.isHookLineSameDirection=w!==0;break;case 75:this.hasHookLine=w!==0;break;case 76:break;case 77:this.byBlockColor=w;break;case 210:n=w;break;case 220:r=w;break;case 230:s=w;break;case 211:a=w;break;case 221:o=w;break;case 231:c=w;break;case 212:l=w,p=!0;break;case 222:h=w,p=!0;break;case 232:u=w,p=!0;break;case 213:d=w,m=!0;break;case 223:g=w,m=!0;break;case 233:f=w,m=!0;break;case 340:this.associatedAnnotation=String(b.value);break}}return y(),this.normal={x:n,y:r,z:s},this.horizontalDirection={x:a,y:o,z:c},p&&(this.offsetFromBlock={x:l,y:h,z:u}),m&&(this.offsetFromAnnotation={x:d,y:g,z:f}),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:Ut.from2dPoints(e,!1).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Co(this.collectPath2d(),!1,t)}collectPath2d(){return this.isSplined&&this.splineGeo?this.splineGeo.getPoints(64).map(t=>new C(t.x,t.y)):this._vertices.map(t=>new C(t.x,t.y))}transformVector(t,e){const n=new x,r=new x(t.x,t.y,t.z);n.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-n.x,r.y-n.y,r.z-n.z)}};Xh.typeName="Leader";let Aa=Xh;var Pr=(i=>(i[i.InvisibleLeader=0]="InvisibleLeader",i[i.StraightLeader=1]="StraightLeader",i[i.SplineLeader=2]="SplineLeader",i))(Pr||{}),mi=(i=>(i[i.NoneContent=0]="NoneContent",i[i.BlockContent=1]="BlockContent",i[i.MTextContent=2]="MTextContent",i[i.ToleranceContent=3]="ToleranceContent",i))(mi||{}),Am=(i=>(i[i.Horizontal=0]="Horizontal",i[i.Vertical=1]="Vertical",i))(Am||{}),Sm=(i=>(i[i.Unknown=0]="Unknown",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Top=3]="Top",i[i.Bottom=4]="Bottom",i))(Sm||{});const zv=1,Xv=2,Yv=4,jv=8,Vv=64,Uv=128,Hv=32768,Yh=class Yh extends et{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new A(1,0,0),this._normal=new A(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new A(1,0,0),this._textStyleName="",this._textAttachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleLeft,this._textDrawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT,this._textLineSpacingFactor=1,this._textAttachmentDirection=0,this._arrowheadOverrides=[],this._blockAttributes=[]}get leaders(){return this._leaders.map(t=>this.cloneLeader(t))}get numberOfLeaders(){return this._leaders.length}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get doglegEnabled(){return this._doglegEnabled}set doglegEnabled(t){this._doglegEnabled=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get doglegVector(){return this._doglegVector}set doglegVector(t){this._doglegVector.copy(t)}get landingPoint(){return this._landingPoint}set landingPoint(t){this._landingPoint=t?this.createPoint(t):void 0}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get mleaderStyleId(){return this._mleaderStyleId}set mleaderStyleId(t){this._mleaderStyleId=t}get version(){return this._version}set version(t){this._version=t}get leaderStyleId(){return this._leaderStyleId}set leaderStyleId(t){this._leaderStyleId=t}get propertyOverrideFlag(){return this._propertyOverrideFlag}set propertyOverrideFlag(t){this._propertyOverrideFlag=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor=t==null?void 0:t.clone()}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get landingEnabled(){return this._landingEnabled}set landingEnabled(t){this._landingEnabled=t}get arrowheadId(){return this._arrowheadId}set arrowheadId(t){this._arrowheadId=t}get arrowheadSize(){return this._arrowheadSize}set arrowheadSize(t){this._arrowheadSize=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor=t==null?void 0:t.clone()}get textFrameEnabled(){return this._textFrameEnabled}set textFrameEnabled(t){this._textFrameEnabled=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get textAttachment(){return this._textAttachment}set textAttachment(t){this._textAttachment=t}get textFlowDirection(){return this._textFlowDirection}set textFlowDirection(t){this._textFlowDirection=t}get blockContentId(){return this._blockContentId}set blockContentId(t){this._blockContentId=t}get blockContentColor(){return this._blockContentColor}set blockContentColor(t){this._blockContentColor=t==null?void 0:t.clone()}get blockContentScale(){return this._blockContentScale}set blockContentScale(t){this._blockContentScale=t}get blockContentRotation(){return this._blockContentRotation}set blockContentRotation(t){this._blockContentRotation=t}get blockContentConnectionType(){return this._blockContentConnectionType}set blockContentConnectionType(t){this._blockContentConnectionType=t}get annotativeScaleEnabled(){return this._annotativeScaleEnabled}set annotativeScaleEnabled(t){this._annotativeScaleEnabled=t}get annotative(){return this._annotativeScaleEnabled===!0||Se(this)}set annotative(t){this._annotativeScaleEnabled=t,me(this,t)}get arrowheadOverrides(){return this._arrowheadOverrides}set arrowheadOverrides(t){this._arrowheadOverrides=t}get blockAttributes(){return this._blockAttributes}set blockAttributes(t){this._blockAttributes=t}get textDirectionNegative(){return this._textDirectionNegative}set textDirectionNegative(t){this._textDirectionNegative=t}get textAlignInIPE(){return this._textAlignInIPE}set textAlignInIPE(t){this._textAlignInIPE=t}get bottomTextAttachmentDirection(){return this._bottomTextAttachmentDirection}set bottomTextAttachmentDirection(t){this._bottomTextAttachmentDirection=t}get topTextAttachmentDirection(){return this._topTextAttachmentDirection}set topTextAttachmentDirection(t){this._topTextAttachmentDirection=t}get contentScale(){return this._contentScale}set contentScale(t){this._contentScale=t}get contentBasePosition(){return this._contentBasePosition}set contentBasePosition(t){this._contentBasePosition=t}get textAnchor(){return this._textAnchor}set textAnchor(t){this._textAnchor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textBackgroundColor(){return this._textBackgroundColor}set textBackgroundColor(t){this._textBackgroundColor=t==null?void 0:t.clone()}get textBackgroundScaleFactor(){return this._textBackgroundScaleFactor}set textBackgroundScaleFactor(t){this._textBackgroundScaleFactor=t}get textBackgroundTransparency(){return this._textBackgroundTransparency}set textBackgroundTransparency(t){this._textBackgroundTransparency=t}get textBackgroundColorOn(){return this._textBackgroundColorOn}set textBackgroundColorOn(t){this._textBackgroundColorOn=t}get textFillOn(){return this._textFillOn}set textFillOn(t){this._textFillOn=t}get textColumnType(){return this._textColumnType}set textColumnType(t){this._textColumnType=t}get textUseAutoHeight(){return this._textUseAutoHeight}set textUseAutoHeight(t){this._textUseAutoHeight=t}get textColumnWidth(){return this._textColumnWidth}set textColumnWidth(t){this._textColumnWidth=t}get textColumnGutterWidth(){return this._textColumnGutterWidth}set textColumnGutterWidth(t){this._textColumnGutterWidth=t}get textColumnFlowReversed(){return this._textColumnFlowReversed}set textColumnFlowReversed(t){this._textColumnFlowReversed=t}get textColumnHeight(){return this._textColumnHeight}set textColumnHeight(t){this._textColumnHeight=t}get textUseWordBreak(){return this._textUseWordBreak}set textUseWordBreak(t){this._textUseWordBreak=t}get hasMText(){return this._hasMText}set hasMText(t){this._hasMText=t}get hasBlock(){return this._hasBlock}set hasBlock(t){this._hasBlock=t}get planeOrigin(){return this._planeOrigin}set planeOrigin(t){this._planeOrigin=t}get planeXAxisDirection(){return this._planeXAxisDirection}set planeXAxisDirection(t){this._planeXAxisDirection=t}get planeYAxisDirection(){return this._planeYAxisDirection}set planeYAxisDirection(t){this._planeYAxisDirection=t}get planeNormalReversed(){return this._planeNormalReversed}set planeNormalReversed(t){this._planeNormalReversed=t}get leaderSections(){return this.leaders}get blockContentData(){return this.blockContent}get mtextContent(){return this._mtextContent?{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint.clone()}:void 0}set mtextContent(t){if(!t){this._mtextContent=void 0,this._contentType===2&&(this._contentType=0);return}this._mtextContent={text:t.text,anchorPoint:this.createPoint(t.anchorPoint)},this._contentType=2}get contents(){var t;return((t=this._mtextContent)==null?void 0:t.text)??""}set contents(t){this._mtextContent?this._mtextContent.text=t:this._mtextContent={text:t,anchorPoint:new x},this._contentType=2}get textLocation(){var t;return(t=this._mtextContent)==null?void 0:t.anchorPoint}set textLocation(t){if(!t){this._mtextContent=void 0;return}this._mtextContent?this._mtextContent.anchorPoint.copy(t):this._mtextContent={text:"",anchorPoint:this.createPoint(t)},this._contentType=2}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get textDirection(){return this._textDirection}set textDirection(t){this._textDirection.copy(t)}get textStyleName(){return this._textStyleName}set textStyleName(t){this._textStyleName=t}get textAttachmentPoint(){return this._textAttachmentPoint}set textAttachmentPoint(t){this._textAttachmentPoint=t}get textDrawingDirection(){return this._textDrawingDirection}set textDrawingDirection(t){this._textDrawingDirection=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get blockContent(){var t,e,n;return this._blockContent?{blockContentId:this._blockContent.blockContentId,blockHandle:this._blockContent.blockHandle,normal:(t=this._blockContent.normal)==null?void 0:t.clone(),position:(e=this._blockContent.position)==null?void 0:e.clone(),scale:this._blockContent.scale.clone(),rotation:this._blockContent.rotation,color:(n=this._blockContent.color)==null?void 0:n.clone(),transformationMatrix:[...this._blockContent.transformationMatrix]}:void 0}set blockContent(t){var e;if(!t){this._blockContent=void 0,this._contentType===1&&(this._contentType=0);return}this._blockContent={blockContentId:t.blockContentId??t.blockHandle,blockHandle:t.blockHandle,normal:t.normal?new A(t.normal):void 0,position:t.position?this.createPoint(t.position):void 0,scale:new A(t.scale??{x:1,y:1,z:1}),rotation:t.rotation??0,color:(e=t.color)==null?void 0:e.clone(),transformationMatrix:t.transformationMatrix?[...t.transformationMatrix]:[]},this.blockContentId=this._blockContent.blockContentId,this._contentType=1}addLeader(t={}){var n,r;const e={lastLeaderLinePoint:t.lastLeaderLinePoint?this.createPoint(t.lastLeaderLinePoint):void 0,lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:t.landingPoint?this.createPoint(t.landingPoint):void 0,doglegVector:t.doglegVector?new A(t.doglegVector):void 0,doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:((n=t.breaks)==null?void 0:n.map(s=>({index:s.index,start:this.createPoint(s.start),end:this.createPoint(s.end)})))??[],leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:[]};return(r=t.leaderLines)==null||r.forEach(s=>{e.leaderLines.push(this.createLeaderLine(s))}),this._leaders.push(e),this._leaders.length-1}removeLeader(t){return this.checkLeaderIndex(t),this._leaders.splice(t,1),this}addLeaderLine(t,e=[]){return this.checkLeaderIndex(t),this._leaders[t].leaderLines.push(this.createLeaderLine({vertices:e})),this._leaders[t].leaderLines.length-1}appendVertex(t,e,n){return this.getMutableLeaderLine(t,e).vertices.push(this.createPoint(n)),this}setLeaderLineVertices(t,e,n){return this.getMutableLeaderLine(t,e).vertices=n.map(r=>this.createPoint(r)),this}getLeaderLineVertices(t,e){return this.getMutableLeaderLine(t,e).vertices.map(n=>n.clone())}addBreak(t,e,n,r){return this.getMutableLeaderLine(t,e).breaks.push({start:this.createPoint(n),end:this.createPoint(r)}),this}setLandingPoint(t,e){return this.checkLeaderIndex(t),this._leaders[t].landingPoint=e?this.createPoint(e):void 0,this}setDoglegDirection(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegVector=new A(e),this}setDoglegLength(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegLength=e,this}get geometricExtents(){const t=this.collectGeometryPoints();return t.length>0?new H().setFromPoints(t):new H}subGetIntersectCurves(){const t=[];return this._leaders.forEach(e=>{e.leaderLines.forEach(n=>{t.push(...ee(n.vertices,!1))})}),t}subGetGripPoints(){return this.collectGeometryPoints().map(t=>t.clone())}subMoveGripPointsAt(t,e){return Et(t,n=>{this.moveGeometryGripPointAt(n,e)}),this}subGetOsnapPoints(t,e,n,r){var s;if(t===T.Insertion){this.contentBasePosition?r.push(this.contentBasePosition):this._mtextContent?r.push(this._mtextContent.anchorPoint):(s=this._blockContent)!=null&&s.position&&r.push(this._blockContent.position);return}this._leaders.forEach(a=>{a.leaderLines.forEach(o=>{const c=this.getLeaderLineDrawPoints(a,o);if(c.length!==0)switch(t){case T.EndPoint:r.push(...c);break;case T.MidPoint:case T.Nearest:case T.Perpendicular:{const l=[];for(let h=0;h<c.length-1;h++){const u=[];nr(c[h],c[h+1],t,e,u),l.push(...u)}if(t===T.MidPoint)r.push(...l);else{const h=ye(e,l);h&&r.push(h)}break}}})})}transformBy(t){var e,n,r,s,a,o,c,l;return this._leaders.forEach(h=>{var u,d;(u=h.lastLeaderLinePoint)==null||u.applyMatrix4(t),(d=h.landingPoint)==null||d.applyMatrix4(t),h.doglegVector&&this.transformVector(h.doglegVector,t),h.breaks.forEach(g=>{g.start.applyMatrix4(t),g.end.applyMatrix4(t)}),h.leaderLines.forEach(g=>{g.vertices.forEach(f=>f.applyMatrix4(t)),g.breaks.forEach(f=>{f.start.applyMatrix4(t),f.end.applyMatrix4(t)})})}),(e=this._landingPoint)==null||e.applyMatrix4(t),(n=this.contentBasePosition)==null||n.applyMatrix4(t),this.transformVector(this._doglegVector,t),this.transformVector(this._normal,t),(r=this.textAnchor)==null||r.applyMatrix4(t),(s=this._mtextContent)==null||s.anchorPoint.applyMatrix4(t),this.transformVector(this._textDirection,t),(o=(a=this._blockContent)==null?void 0:a.position)==null||o.applyMatrix4(t),(c=this._blockContent)!=null&&c.normal&&this.transformVector(this._blockContent.normal,t),this.blockContentScale&&this.transformVector(this.blockContentScale,t),(l=this.planeOrigin)==null||l.applyMatrix4(t),this.planeXAxisDirection&&this.transformVector(this.planeXAxisDirection,t),this.planeYAxisDirection&&this.transformVector(this.planeYAxisDirection,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[{name:"annotative",type:"boolean",editable:!0,accessor:{get:()=>this.annotative,set:t=>{this.annotative=t}}},{name:"contentType",type:"enum",editable:!0,options:[{label:mi[0],value:0},{label:mi[1],value:1},{label:mi[2],value:2},{label:mi[3],value:3}],accessor:{get:()=>this.contentType,set:t=>{this.contentType=t}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:Pr[0],value:0},{label:Pr[1],value:1},{label:Pr[2],value:2}],accessor:{get:()=>this.leaderLineType,set:t=>{this.leaderLineType=t}}},{name:"doglegEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.doglegEnabled,set:t=>{this.doglegEnabled=t}}},{name:"doglegLength",type:"float",editable:!0,accessor:{get:()=>this.doglegLength,set:t=>{this.doglegLength=t}}},{name:"leaderCount",type:"int",editable:!1,accessor:{get:()=>this.numberOfLeaders}},{name:"mleaderStyleId",type:"string",editable:!0,accessor:{get:()=>this.mleaderStyleId,set:t=>{this.mleaderStyleId=t}}},{name:"landingGap",type:"float",editable:!0,accessor:{get:()=>this.landingGap??0,set:t=>{this.landingGap=t}}},{name:"blockContentId",type:"string",editable:!0,accessor:{get:()=>this.blockContentId??"",set:t=>{this.blockContentId=t}}},{name:"landingEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.landingEnabled??!1,set:t=>{this.landingEnabled=t}}},{name:"arrowheadSize",type:"float",editable:!0,accessor:{get:()=>this.arrowheadSize??0,set:t=>{this.arrowheadSize=t}}}]},{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textHeight,set:t=>{this.textHeight=t}}},{name:"textWidth",type:"float",editable:!0,accessor:{get:()=>this.textWidth,set:t=>{this.textWidth=t}}},{name:"textStyleName",type:"string",editable:!0,accessor:{get:()=>this.textStyleName,set:t=>{this.textStyleName=t}}},{name:"textRotation",type:"float",editable:!0,accessor:{get:()=>this.textRotation,set:t=>{this.textRotation=t}}},{name:"textAttachmentPoint",type:"enum",editable:!0,options:[{label:exports.AcGiMTextAttachmentPoint[1],value:1},{label:exports.AcGiMTextAttachmentPoint[2],value:2},{label:exports.AcGiMTextAttachmentPoint[3],value:3},{label:exports.AcGiMTextAttachmentPoint[4],value:4},{label:exports.AcGiMTextAttachmentPoint[5],value:5},{label:exports.AcGiMTextAttachmentPoint[6],value:6},{label:exports.AcGiMTextAttachmentPoint[7],value:7},{label:exports.AcGiMTextAttachmentPoint[8],value:8},{label:exports.AcGiMTextAttachmentPoint[9],value:9}],accessor:{get:()=>this.textAttachmentPoint,set:t=>{this.textAttachmentPoint=t}}},{name:"textDrawingDirection",type:"enum",editable:!0,options:[{label:exports.AcGiMTextFlowDirection[1],value:1},{label:exports.AcGiMTextFlowDirection[2],value:2},{label:exports.AcGiMTextFlowDirection[3],value:3},{label:exports.AcGiMTextFlowDirection[4],value:4},{label:exports.AcGiMTextFlowDirection[5],value:5}],accessor:{get:()=>this.textDrawingDirection,set:t=>{this.textDrawingDirection=t}}},{name:"textLineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.textLineSpacingFactor,set:t=>{this.textLineSpacingFactor=t}}}]},{groupName:"geometry",properties:[{name:"landingPointX",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.landingPoint)==null?void 0:t.x)??0},set:t=>{const e=this.landingPoint;e?(e.x=t,this.landingPoint=e):this.landingPoint={x:t,y:0,z:0}}}},{name:"landingPointY",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.landingPoint)==null?void 0:t.y)??0},set:t=>{const e=this.landingPoint;e?(e.y=t,this.landingPoint=e):this.landingPoint={x:0,y:t,z:0}}}},{name:"landingPointZ",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.landingPoint)==null?void 0:t.z)??0},set:t=>{const e=this.landingPoint;e?(e.z=t,this.landingPoint=e):this.landingPoint={x:0,y:0,z:t}}}},{name:"doglegVectorX",type:"float",editable:!0,accessor:{get:()=>this.doglegVector.x,set:t=>{this.doglegVector={x:t,y:this.doglegVector.y,z:this.doglegVector.z}}}},{name:"doglegVectorY",type:"float",editable:!0,accessor:{get:()=>this.doglegVector.y,set:t=>{this.doglegVector={x:this.doglegVector.x,y:t,z:this.doglegVector.z}}}},{name:"doglegVectorZ",type:"float",editable:!0,accessor:{get:()=>this.doglegVector.z,set:t=>{this.doglegVector={x:this.doglegVector.x,y:this.doglegVector.y,z:t}}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal={x:t,y:this.normal.y,z:this.normal.z}}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal={x:this.normal.x,y:t,z:this.normal.z}}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal={x:this.normal.x,y:this.normal.y,z:t}}}},{name:"textLocationX",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.textLocation)==null?void 0:t.x)??0},set:t=>{const e=this.textLocation;e?(e.x=t,this.textLocation=e):this.textLocation={x:t,y:0,z:0}}}},{name:"textLocationY",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.textLocation)==null?void 0:t.y)??0},set:t=>{const e=this.textLocation;e?(e.y=t,this.textLocation=e):this.textLocation={x:0,y:t,z:0}}}},{name:"textLocationZ",type:"float",editable:!0,accessor:{get:()=>{var t;return((t=this.textLocation)==null?void 0:t.z)??0},set:t=>{const e=this.textLocation;e?(e.z=t,this.textLocation=e):this.textLocation={x:0,y:0,z:t}}}}]}]}}resolveEffectiveProperties(){if(super.resolveEffectiveProperties(),this._mleaderStyleId)return;const t=this.getDefaultMLeaderStyle();t&&(this._mleaderStyleId=t.objectId)}resolveAnnotativePresentation(){var h;const t=this.getBaseTextHeight(),e=this.getBaseArrowheadSize(),n=Wt(this),r=n.length>0||this._annotativeScaleEnabled===!0||pe(this);let s=t,a=e,o,c,l;if(r&&n.length>0){c=He(n,(h=this.database)==null?void 0:h.cannoscale)??n.find(d=>d.isDefault)??n[0],l=Ge(n,c);const u=c.contextData;u instanceof zi?(u.textHeight>0?s=u.textHeight:s=Be(Re(t,n),c.scale.scaleFactor),u.arrowheadSize>0?a=u.arrowheadSize:a=Be(Re(e,n),c.scale.scaleFactor),u.hasTextAnchor&&(o=u.textAnchor.clone())):(s=Be(Re(t,n),c.scale.scaleFactor),a=Be(Re(e,n),c.scale.scaleFactor))}return{textHeight:s,arrowheadSize:a,textAnchor:o,preferred:c,annotationScale:l}}subWorldDraw(t,e){const n=this.resolveAnnotativePresentation();this._drawPresentation=n;const r=[],s=t.subEntityTraits,a=s.color,o=s.isColorByLayer,c=s.lineType,l=s.lineWeight,h=this.getResolvedLeaderLineColor(),u=this.getResolvedLeaderLineStyle(),d=this.getResolvedLeaderLineWeight(),g=this.getResolvedTextColor();this.getResolvedLeaderLineType()!==0&&(this.applyColorTraits(s,h,a,o),this.applyLineTraits(s,u,d),this._leaders.forEach(y=>{y.leaderLines.forEach(_=>{const w=this.getLeaderLineDrawPoints(y,_);if(w.length>0){const k=this.drawLeaderLine(t,w);k&&r.push(k)}});const b=this.getDoglegPoints(y);b&&r.push(t.lines(b))}));const f=this.getRenderableMTextContent();if(!!f&&(this.contentType===2||this.contentType===0||this.hasMText===!0)&&f){this.applyColorTraits(s,g,a,o);const y=n.textHeight,b={text:f.text,height:y,width:this.getMTextRenderWidth(f.text,y),position:n.textAnchor??f.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor,lineSpaceStyle:this.textLineSpacingStyle};r.push(t.mtext(b,this.getTextStyle(),e))}if(s.color=a,s.isColorByLayer=o,s.lineType=c,s.lineWeight=l,this._drawPresentation=void 0,r.length===0)return;const m=r.length===1?r[0]:t.group(r);if(m&&this.annotative){let y=n.annotationScale;y||(y={drawnScaleFactor:1,supportedScaleFactors:[1],supportedScaleNames:[]});const b=m.userData??(m.userData={});b.annotationScale=y}return m}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeader"),t.writeInt16(170,this.leaderLineType),t.writeBoolean(290,this.doglegEnabled),t.writeDouble(41,this.doglegLength),t.writeInt16(172,this.contentType),t.writeVector3d(210,this.normal),t.writeHandle(340,this.mleaderStyleId),this._landingPoint&&t.writePoint3d(10,this._landingPoint),t.writeVector3d(11,this.doglegVector),this._mtextContent&&(t.writeString(1,this._mtextContent.text),t.writePoint3d(12,this._mtextContent.anchorPoint),t.writeDouble(40,this.textHeight),t.writeDouble(42,this.textWidth),t.writeAngle(50,this.textRotation),t.writeString(7,this.textStyleName)),this._blockContent&&(t.writeHandle(341,this._blockContent.blockContentId??""),this._blockContent.position&&t.writePoint3d(15,this._blockContent.position),t.writeVector3d(16,this._blockContent.scale),t.writeAngle(52,this._blockContent.rotation)),this._leaders.forEach(e=>{e.landingPoint&&t.writePoint3d(110,e.landingPoint),e.doglegVector&&t.writeVector3d(111,e.doglegVector),t.writeDouble(140,e.doglegLength),t.writeInt16(171,e.leaderLines.length),e.leaderLines.forEach(n=>{t.writeInt16(90,n.vertices.length),n.vertices.forEach(r=>t.writePoint3d(10,r))})}),this}dxfInFields(t){var S,I,M,O,N,nt,W,F,q,L,$,ct,B,Ft,ne;super.dxfInFields(t),t.atSubclassData("AcDbMLeader"),this._leaders.length=0;let e=(S=this._mtextContent)==null?void 0:S.text,n=(M=(I=this._mtextContent)==null?void 0:I.anchorPoint)==null?void 0:M.clone(),r=!!this._mtextContent,s=(O=this._blockContent)==null?void 0:O.blockContentId,a=(nt=(N=this._blockContent)==null?void 0:N.position)==null?void 0:nt.clone(),o=(F=(W=this._blockContent)==null?void 0:W.scale)==null?void 0:F.clone(),c=(q=this._blockContent)==null?void 0:q.rotation,l=($=(L=this._blockContent)==null?void 0:L.normal)==null?void 0:$.clone(),h=(B=(ct=this._blockContent)==null?void 0:ct.color)==null?void 0:B.clone(),u=(Ft=this._blockContent)!=null&&Ft.transformationMatrix?[...this._blockContent.transformationMatrix]:[],d=!!this._blockContent,g=!1,f=!1,p=!1,m=(ne=this._landingPoint)==null?void 0:ne.clone(),y=this._doglegVector.clone(),b=null,_=null,w=!1,k;const P=()=>{_&&b&&b.leaderLines.push(_),_=null},v=()=>{P(),b&&this.addLeader(b),b=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const dt=t.readItem();if(!dt)break;const cn=Number(dt.code),K=Number(dt.value),ht=String(dt.value??"");switch(cn){case 100:return t.pushBackItem(dt),v(),this.finishMLeaderDxfIn(e,n,r,s,a,o,c,l,h,u,d,g,m,y,k),this;case 300:if(ht==="CONTEXT_DATA{"){f=!0;const R=this.dxfInContextData(t);R.hasArrowheadSize&&(p=!0),R.textContent!=null&&(e=R.textContent,r=!0),R.textAnchor&&(n=R.textAnchor,r=!0),R.hasMText!=null&&(this.hasMText=R.hasMText),R.hasBlock!=null&&(this.hasBlock=R.hasBlock),R.blockContentId&&(s=R.blockContentId,d=this.isValidMLeaderHandle(R.blockContentId)),R.blockPosition&&(a=R.blockPosition,d=!0),R.blockScale&&(o=R.blockScale,d=!0),R.blockRotation!=null&&(c=R.blockRotation,d=!0),R.blockNormal&&(l=R.blockNormal,d=!0),R.blockColor&&(h=R.blockColor,d=!0),R.blockMatrix.length>0&&(u=R.blockMatrix,d=!0),r&&!g&&(this.contentType=2,g=!0)}break;case 270:f=!0,this.version=K;break;case 340:this.leaderStyleId=ht,this.mleaderStyleId=ht;break;case 90:w?(P(),_={vertices:[],breakPointIndexes:[],breaks:[]}):this.propertyOverrideFlag=K;break;case 170:this.leaderLineType=K;break;case 91:this.leaderLineColor=Yt(K);break;case 341:f?this.leaderLineTypeId=ht:this.isValidMLeaderHandle(ht)?(s=ht,d=!0):this.leaderLineTypeId=ht;break;case 171:w||(this.leaderLineWeight=K);break;case 290:f?this.landingEnabled=this.readDxfBoolean(dt):this.doglegEnabled=this.readDxfBoolean(dt);break;case 291:this.doglegEnabled=this.readDxfBoolean(dt);break;case 40:f?this.doglegLength=K:this.textHeight=K;break;case 41:this.doglegLength=K;break;case 342:this.arrowheadId=ht;break;case 42:f?p||(this.arrowheadSize=K*(this.contentScale??1)):this.textWidth=K;break;case 172:this.contentType=K,g=!0;break;case 343:this.textStyleId=ht;break;case 173:this.textLeftAttachmentType=K;break;case 95:this.textRightAttachmentType=K;break;case 174:this.textAngleType=K;break;case 175:this.textAlignmentType=K;break;case 92:this.textColor=Yt(K);break;case 292:this.textFrameEnabled=this.readDxfBoolean(dt);break;case 344:this.isValidMLeaderHandle(ht)&&(s=ht,this.blockContentId=ht,d=!0);break;case 93:this.blockContentColor=Yt(K);break;case 10:if(w){t.pushBackItem(dt);const R=t.readPoint3d(10);R&&_&&_.vertices.push(R)}else{t.pushBackItem(dt);const R=t.readPoint3d(10);if(!R)break;f?(this.blockContentScale=new A(R),o=new A(R),d=!0):m=R}break;case 43:this.blockContentRotation=K,c=K,d=!0;break;case 176:this.blockContentConnectionType=K;break;case 293:this.annotativeScaleEnabled=this.readDxfBoolean(dt);break;case 94:{this.arrowheadOverrides.push({index:K});break}case 345:{const R=this.arrowheadOverrides[this.arrowheadOverrides.length-1];R?R.handle=ht:this.arrowheadOverrides.push({index:0,handle:ht});break}case 330:this.blockAttributes.push({id:ht});break;case 177:{const R=this.blockAttributes[this.blockAttributes.length-1];R&&(R.index=K);break}case 44:{const R=this.blockAttributes[this.blockAttributes.length-1];R&&(R.width=K);break}case 302:{const R=this.blockAttributes[this.blockAttributes.length-1];R&&(R.text=ht);break}case 294:this.textDirectionNegative=this.readDxfBoolean(dt);break;case 178:this.textAlignInIPE=K;break;case 179:K!==0&&(this.textAttachmentPoint=K);break;case 271:this.textAttachmentDirection=K;break;case 272:this.bottomTextAttachmentDirection=K;break;case 273:this.topTextAttachmentDirection=K;break;case 210:t.pushBackItem(dt);{const R=t.readVector3d(210);R&&(this.normal=R)}break;case 110:v(),w=!0,t.pushBackItem(dt),b={landingPoint:t.readPoint3d(110),doglegVector:new A(1,0,0),doglegLength:0,breaks:[],leaderLines:[]};break;case 111:if(b){t.pushBackItem(dt);const R=t.readVector3d(111);R&&(b.doglegVector=R)}break;case 140:b?b.doglegLength=K:this.arrowheadSize=K;break;case 1:e=ht,r=!0;break;case 12:t.pushBackItem(dt);{const R=t.readPoint3d(12);R&&(n=R,r=!0)}break;case 7:this.textStyleName=ht;break;case 50:k=K;break;case 15:t.pushBackItem(dt);{const R=t.readPoint3d(15);R&&(a=R,d=!0)}break;case 16:t.pushBackItem(dt);{const R=t.readVector3d(16);R&&(o=R,d=!0)}break;case 52:c=K*Math.PI/180,d=!0;break;case 11:if(!w&&!f){t.pushBackItem(dt);const R=t.readVector3d(11);R&&(y=R)}break}}return v(),this.finishMLeaderDxfIn(e,n,r,s,a,o,c,l,h,u,d,g,m,y,k),this}finishMLeaderDxfIn(t,e,n,r,s,a,o,c,l,h,u,d,g,f,p){if(g&&(this.landingPoint=g),this.doglegVector=f,p!=null&&(this.textRotation=p*Math.PI/180),!this.textStyleName&&this.textStyleId){const y=this.database.tables.textStyleTable.getIdAt(this.textStyleId);y!=null&&y.name&&(this.textStyleName=y.name)}const m=e??this.textAnchor??this.contentBasePosition??g;(n||this.hasMText)&&t!=null&&m?(this.mtextContent={text:t,anchorPoint:m.clone()},this.textAnchor||(this.textAnchor=m.clone()),d||(this.contentType=2)):(n||this.hasMText)&&t!=null&&!m&&(d||(this.contentType=2)),u&&this.isValidMLeaderHandle(r)&&this.contentType!==2&&!this.mtextContent&&(this.blockContent={blockContentId:r,position:s,scale:a??new A(1,1,1),rotation:o??0,normal:c,color:l,transformationMatrix:h},!d&&this.contentType===0&&(this.contentType=1))}dxfInContextData(t){const e={blockMatrix:[]};for(;!t.atEof;){const n=t.readItem();if(!n)break;const r=Number(n.code),s=Number(n.value),a=String(n.value??"");if(r===301)break;if(r===0){t.pushBackItem(n);break}switch(r){case 10:t.pushBackItem(n),this.contentBasePosition=t.readPoint3d(10);break;case 11:t.pushBackItem(n);{const o=t.readVector3d(11);o&&(this.normal=o)}break;case 12:t.pushBackItem(n);{const o=t.readPoint3d(12);o&&(e.textAnchor=o,this.textAnchor=o.clone())}break;case 13:t.pushBackItem(n);{const o=t.readVector3d(13);o&&(this.textDirection=o)}break;case 14:t.pushBackItem(n),e.blockNormal=t.readVector3d(14);break;case 15:t.pushBackItem(n),e.blockPosition=t.readPoint3d(15);break;case 16:t.pushBackItem(n),e.blockScale=t.readVector3d(16);break;case 40:this.contentScale=s;break;case 41:s>0&&(this.textHeight=s);break;case 42:this.textRotation=s;break;case 43:s>0&&(this.textWidth=s);break;case 44:s>0&&(this.textHeight=s);break;case 45:this.textLineSpacingFactor=s;break;case 46:e.blockRotation=s;break;case 47:e.blockMatrix.push(s);break;case 90:this.textColor=Yt(s);break;case 91:this.textBackgroundColor=Yt(s);break;case 92:this.textBackgroundTransparency=s;break;case 93:e.blockColor=Yt(s);break;case 110:t.pushBackItem(n),this.planeOrigin=t.readPoint3d(110);break;case 111:t.pushBackItem(n),this.planeXAxisDirection=t.readVector3d(111);break;case 112:t.pushBackItem(n),this.planeYAxisDirection=t.readVector3d(112);break;case 140:this.arrowheadSize=s,e.hasArrowheadSize=!0;break;case 141:this.textBackgroundScaleFactor=s;break;case 142:this.textColumnWidth=s;break;case 143:this.textColumnGutterWidth=s;break;case 144:this.textColumnHeight=s;break;case 145:this.landingGap=s;break;case 170:this.textLineSpacingStyle=s;break;case 171:this.textAttachment=s;break;case 172:this.textFlowDirection=s;break;case 173:this.textColumnType=s;break;case 290:e.hasMText=this.readDxfBoolean(n),this.hasMText=e.hasMText;break;case 291:this.textBackgroundColorOn=this.readDxfBoolean(n);break;case 292:this.textFillOn=this.readDxfBoolean(n);break;case 293:this.textUseAutoHeight=this.readDxfBoolean(n);break;case 294:this.textColumnFlowReversed=this.readDxfBoolean(n);break;case 295:this.textUseWordBreak=this.readDxfBoolean(n);break;case 296:e.hasBlock=this.readDxfBoolean(n),this.hasBlock=e.hasBlock;break;case 297:this.planeNormalReversed=this.readDxfBoolean(n);break;case 302:if(a==="LEADER{"){const o=this.dxfInLeaderSection(t);this.addLeader(o)}break;case 304:a!=="LEADER_LINE{"&&(e.textContent=a,this.hasMText=!0);break;case 340:this.textStyleId=a;break;case 341:e.blockContentId=a,this.isValidMLeaderHandle(a)&&(this.blockContentId=a);break}}return e}dxfInLeaderSection(t){const e={breaks:[],leaderLines:[]};let n;const r=()=>{n&&(e.breaks.push(n),n=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value),c=String(s.value??"");if(a===303){r();break}if(a===0||a===301){t.pushBackItem(s),r();break}switch(a){case 290:e.lastLeaderLinePointSet=this.readDxfBoolean(s);break;case 291:e.doglegVectorSet=this.readDxfBoolean(s);break;case 10:t.pushBackItem(s),e.lastLeaderLinePoint=t.readPoint3d(10);break;case 11:t.pushBackItem(s),e.doglegVector=t.readVector3d(11);break;case 12:t.pushBackItem(s);{const l=t.readPoint3d(12);l&&(n={start:l,end:l.clone()})}break;case 13:t.pushBackItem(s);{const l=t.readPoint3d(13);n&&l&&(n.end=l,r())}break;case 90:e.leaderBranchIndex=o;break;case 40:e.doglegLength=o;break;case 304:c==="LEADER_LINE{"&&e.leaderLines.push(this.dxfInLeaderLine(t));break}}return e}dxfInLeaderLine(t){const e={vertices:[],breakPointIndexes:[],breaks:[]};let n;const r=()=>{n&&(e.breaks.push(n),n=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);if(a===305){r();break}if(a===0||a===303||a===301){t.pushBackItem(s),r();break}switch(a){case 10:t.pushBackItem(s);{const c=t.readPoint3d(10);c&&e.vertices.push(c)}break;case 11:t.pushBackItem(s);{const c=t.readPoint3d(11);c&&(n={index:n==null?void 0:n.index,start:c,end:c.clone()})}break;case 12:t.pushBackItem(s);{const c=t.readPoint3d(12);n&&c&&(n.end=c,r())}break;case 90:e.breakPointIndexes.push(o),n={index:o,start:(n==null?void 0:n.start)??new x,end:(n==null?void 0:n.end)??new x};break;case 91:e.leaderLineIndex=o;break}}return e}readDxfBoolean(t){if(typeof t.value=="boolean")return t.value;const e=Number(t.value);if(Number.isFinite(e))return e!==0;const n=String(t.value??"");return n!==""&&n!=="0"}isValidMLeaderHandle(t){return t!=null&&t!==""&&t!=="0"}createPoint(t){return new x().copy(t)}createLeaderLine(t){var e,n;return{vertices:((e=t.vertices)==null?void 0:e.map(r=>this.createPoint(r)))??[],breakPointIndexes:t.breakPointIndexes?[...t.breakPointIndexes]:[],leaderLineIndex:t.leaderLineIndex,breaks:((n=t.breaks)==null?void 0:n.map(r=>({index:r.index,start:this.createPoint(r.start),end:this.createPoint(r.end)})))??[]}}cloneLeader(t){var e,n,r;return{lastLeaderLinePoint:(e=t.lastLeaderLinePoint)==null?void 0:e.clone(),lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:(n=t.landingPoint)==null?void 0:n.clone(),doglegVector:(r=t.doglegVector)==null?void 0:r.clone(),doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:t.breaks.map(s=>({index:s.index,start:s.start.clone(),end:s.end.clone()})),leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:t.leaderLines.map(s=>({vertices:s.vertices.map(a=>a.clone()),breakPointIndexes:[...s.breakPointIndexes],leaderLineIndex:s.leaderLineIndex,breaks:s.breaks.map(a=>({index:a.index,start:a.start.clone(),end:a.end.clone()}))}))}}checkLeaderIndex(t){if(t<0||t>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(t,e){this.checkLeaderIndex(t);const n=this._leaders[t].leaderLines[e];if(!n)throw new Error("The leader line index is out of range!");return n}collectGeometryPoints(){var e;const t=[];return this._leaders.forEach(n=>{n.lastLeaderLinePoint&&t.push(n.lastLeaderLinePoint),n.landingPoint&&t.push(n.landingPoint),n.breaks.forEach(s=>t.push(s.start,s.end)),n.leaderLines.forEach(s=>{t.push(...s.vertices),s.breaks.forEach(a=>t.push(a.start,a.end))});const r=this.getDoglegPoints(n);r&&t.push(...r),n.leaderLines.forEach(s=>{const a=this.getArrowheadPoints(this.getLeaderLineDrawPoints(n,s));a&&t.push(...a)})}),this._landingPoint&&t.push(this._landingPoint),this.contentBasePosition&&t.push(this.contentBasePosition),this.textAnchor&&t.push(this.textAnchor),this._mtextContent&&t.push(this._mtextContent.anchorPoint),(e=this._blockContent)!=null&&e.position&&t.push(this._blockContent.position),this.planeOrigin&&t.push(this.planeOrigin),t}moveGeometryGripPointAt(t,e){var s;let n=0;const r=(a,o)=>{if(a){n===t&&a.add(e),n++;return}o&&(n===t&&o(),n++)};this._leaders.forEach(a=>{r(a.lastLeaderLinePoint),r(a.landingPoint),a.breaks.forEach(c=>{r(c.start),r(c.end)}),a.leaderLines.forEach(c=>{c.vertices.forEach(l=>r(l)),c.breaks.forEach(l=>{r(l.start),r(l.end)})});const o=this.getDoglegPoints(a);o&&(r(o[0]),r(void 0,()=>{const c=o[0],l=o[1];if(!c||!l)return;const h=c.distanceTo({x:l.x+e.x,y:l.y+e.y,z:(l.z??0)+(e.z??0)});a.doglegLength!=null||a.doglegVectorSet?a.doglegLength=h:this._doglegLength=h})),a.leaderLines.forEach(c=>{const l=this.getLeaderLineDrawPoints(a,c),h=this.getArrowheadPoints(l);h&&h.forEach((u,d)=>{d===0||d===h.length-1?r(l[0]):r(void 0)})})}),r(this._landingPoint),r(this.contentBasePosition),r(this.textAnchor),this._mtextContent&&r(this._mtextContent.anchorPoint),(s=this._blockContent)!=null&&s.position&&r(this._blockContent.position),r(this.planeOrigin)}getLeaderLineDrawPoints(t,e){if(e.vertices.length>=2)return e.vertices;if(e.vertices.length===0)return[];const n=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint??this.contentBasePosition;return!n||e.vertices[0].equals(n)?e.vertices:[e.vertices[0],n]}getDoglegPoints(t){if(!this.getResolvedDoglegEnabled())return;const e=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint;if(!e)return;const n=this.contentBasePosition;if(n&&!n.equals(e))return[e,n.clone()];const r=t.doglegVector??this._doglegVector,s=t.doglegLength??this.getResolvedDoglegLength();if(s==null||s===0||r.lengthSq()===0)return;const a=e.clone().add(r.clone().normalize().multiplyScalar(s));return[e,a]}getArrowheadPoints(t){if(!this.isArrowheadVisible()||t.length<2)return;const e=this.getArrowheadFrame(t);if(!e)return;const n=this.getResolvedArrowheadSize(),{tip:r,unit:s}=e,a=r.clone().add(s.clone().multiplyScalar(n)),o=n/6,c=new A(-s.y,s.x,0),l=a.clone().add(c.clone().multiplyScalar(o)),h=a.clone().add(c.clone().multiplyScalar(-o));return[r,l,h,r]}isArrowheadVisible(){const t=this.getResolvedArrowheadId();return(t==null?void 0:t.toUpperCase())==="_NONE"?!1:this.getResolvedArrowheadSize()>0}drawLeaderLine(t,e){const n=[],r=this.getLeaderLinePointsForDraw(e);r.length>=2&&n.push(t.lines(r));const s=this.drawArrowhead(t,e);if(s&&n.push(s),n.length!==0)return n.length===1?n[0]:t.group(n)}getLeaderLinePointsForDraw(t){const e=this.getArrowheadLeaderLineTrimDistance();return e<=0?t:this.trimPolylineStart(t,e)}getArrowheadLeaderLineTrimDistance(){if(!this.isArrowheadVisible())return 0;const t=this.getResolvedArrowheadBlockTableRecord();if(!t)return 0;const e=this.getResolvedArrowheadSize();if(e<=0)return 0;const n=t.origin??x.ORIGIN;let r=n.x;for(const s of t.newIterator()){const a=s.geometricExtents;a.isEmpty()||a.max.x>r&&(r=a.max.x)}return Math.max(0,(r-n.x)*e)}trimPolylineStart(t,e){if(t.length<2||e<=0)return t;let n=e;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=a.distanceTo(s);if(!(o<=0)){if(n<o){const c=new A().subVectors(a,s);return[s.clone().add(c.multiplyScalar(n/o)),...t.slice(r+1)]}n-=o}}return[t[t.length-1]]}drawArrowhead(t,e){if(!this.isArrowheadVisible())return;const n=this.drawArrowheadBlock(t,e);if(n)return n;const r=this.getArrowheadPoints(e);if(!r)return;const s=new de;s.add(new ot(r,!0));const a=t.subEntityTraits,o=a.fillType;a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const c=t.area(s);return a.fillType=o,c}drawArrowheadBlock(t,e){const n=this.getResolvedArrowheadBlockTableRecord();if(!n)return;const r=this.getArrowheadFrame(e);if(!r)return;const{tip:s,unit:a}=r,o=this.getResolvedArrowheadSize(),c=Math.atan2(a.y,a.x),l=n.origin??x.ORIGIN,h=new z().makeTranslation(-l.x,-l.y,-l.z),u=new z().makeScale(o,o,o),d=new z().makeRotationZ(c),g=new z().makeTranslation(s.x,s.y,s.z),f=new z().multiplyMatrices(g,d).multiply(u).multiply(h);return Tn.instance.draw(t,n,this.resolvedColor,[],!0,f,new A(this.normal))}getArrowheadFrame(t){if(t.length<2)return;const e=t[0],n=t.find(s=>!s.equals(e));if(!n)return;const r=new A().subVectors(n,e);if(r.lengthSq()!==0)return{tip:e,unit:r.normalize()}}getResolvedArrowheadId(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.arrowSymbolId;return this.arrowheadId??t}getResolvedArrowheadBlockTableRecord(){const t=this.getResolvedArrowheadId();if(t)return this.database.tables.blockTable.getIdAt(t)}getBaseArrowheadSize(){const t=this.getMLeaderStyle(),e=(t==null?void 0:t.arrowSize)??(t==null?void 0:t.scale);return this.arrowheadSize??this.contentScale??e??this.getBaseTextHeight()}getResolvedArrowheadSize(){return this._drawPresentation?this._drawPresentation.arrowheadSize:this.getBaseArrowheadSize()}getBaseTextHeight(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.textHeight;return this.textHeight>0?this.textHeight:t!=null&&t>0?t:2.5}getRenderableMTextContent(){var n;if(this._mtextContent)return{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint};const t=(n=this.getMLeaderStyle())==null?void 0:n.defaultMTextContents,e=this.textAnchor??this.contentBasePosition??this._landingPoint;if(!(!t||!e))return{text:t,anchorPoint:e}}getMTextRenderWidth(t,e){return this._textWidth>0?this._textWidth:0}transformVector(t,e){const n=new x,r=new x(t.x,t.y,t.z);n.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-n.x,r.y-n.y,r.z-n.z)}getMLeaderStyle(){var n,r;const t=this.database.objects.mleaderStyle,e=(n=this.mleaderStyleId||this.leaderStyleId)==null?void 0:n.trim();if(e){const s=t.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[,c]of t.entries())if(((r=c.objectId)==null?void 0:r.toUpperCase())===a)return c;const o=this.database.getObjectById(e);if(o instanceof us)return o}return this.getDefaultMLeaderStyle()}getDefaultMLeaderStyle(){const t=this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());return t||this.database.objects.mleaderStyle.newIterator().toArray()[0]}resolveMLeaderStyleByName(t){const e=t==null?void 0:t.trim();if(!e)return;const n=this.database.objects.mleaderStyle,r=n.getAt(e);if(r)return r;const s=n.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[o,c]of n.entries())if(o.toUpperCase()===a)return c}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||en}catch{return en}}getResolvedTextStyleName(){var s,a,o;const t=this.database.tables.textStyleTable,e=(s=this.getMLeaderStyle())==null?void 0:s.textStyleId,n=e?(a=t.getIdAt(e))==null?void 0:a.name:void 0,r=this.textStyleId?(o=t.getIdAt(this.textStyleId))==null?void 0:o.name:void 0;if(this.textStyleName){const c=t.getAt(this.textStyleName);if(c!=null&&c.name)return c.name;const l=t.getIdAt(this.textStyleName);if(l!=null&&l.name)return l.name}return r||n}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.getResolvedTextStyleName());if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}getResolvedLeaderLineColor(){var t;return this.getResolvedComponentColor(this.leaderLineColor,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineColor,Xv)}getResolvedLeaderLineType(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,t,zv)}getResolvedLeaderLineTypeId(){var t;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineTypeId,Yv)}getResolvedLeaderLineStyle(){const t=this.getResolvedLeaderLineTypeId();if(!t)return;const e=this.database.tables.linetypeTable.getIdAt(t);if(e)return{type:"UserSpecified",...e.linetype}}getResolvedLeaderLineWeight(){var n;const t=(n=this.getMLeaderStyle())==null?void 0:n.leaderLineWeight,e=this.getResolvedStyleDrivenValue(this.leaderLineWeight,t,jv);if(e!=null)return e}getResolvedDoglegEnabled(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,t,Vv)}getResolvedDoglegLength(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,t,Uv)}getResolvedTextColor(){var t;return this.getResolvedComponentColor(this.textColor,(t=this.getMLeaderStyle())==null?void 0:t.textColor,Hv)}getResolvedComponentColor(t,e,n){if(!t)return e;if(!t.isByBlock&&!t.isByLayer)return t;const r=this.isPropertyOverrideEnabled(n);return r===!0?t:e??t}getResolvedStyleDrivenValue(t,e,n){const r=this.isPropertyOverrideEnabled(n);return r===!0?t??e:e??t}isPropertyOverrideEnabled(t){if(this.propertyOverrideFlag!=null)return(this.propertyOverrideFlag&t)!==0}applyColorTraits(t,e,n,r){var s;if(t.color=n,t.isColorByLayer=r,!!e){if(e.isByLayer){const a=(s=this.getLayerColor())==null?void 0:s.clone();a&&this.applyTraitsColor(t,a,!0);return}e.isByBlock||this.applyTraitsColor(t,e)}}applyLineTraits(t,e,n){e&&(t.lineType=e),n!=null&&(t.lineWeight=n)}};Yh.typeName="MLeader";let Sa=Yh;var kr=(i=>(i[i.Top=0]="Top",i[i.Zero=1]="Zero",i[i.Bottom=2]="Bottom",i))(kr||{}),Pm=(i=>(i[i.HasVertex=1]="HasVertex",i[i.Closed=2]="Closed",i[i.SuppressStartCaps=4]="SuppressStartCaps",i[i.SuppressEndCaps=8]="SuppressEndCaps",i))(Pm||{});const jh=class jh extends et{get dxfTypeName(){return"MLINE"}constructor(){super(),this._styleName="",this._styleObjectHandle="",this._scale=1,this._justification=1,this._flags=0,this._styleCount=0,this._startPosition=new x,this._normal=new A(0,0,1),this._segments=[]}get styleName(){return this._styleName||this.getDefaultStyleName()}set styleName(t){this._styleName=t}get styleObjectHandle(){return this._styleObjectHandle}set styleObjectHandle(t){this._styleObjectHandle=t}get scale(){return this._scale}set scale(t){this._scale=t}get justification(){return this._justification}set justification(t){this._justification=t}get flags(){return this._flags}set flags(t){this._flags=t}get styleCount(){return this._styleCount}set styleCount(t){this._styleCount=Math.max(0,t)}get startPosition(){return this._startPosition}set startPosition(t){this._startPosition.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get segments(){return this._segments.map(t=>this.cloneSegment(t))}set segments(t){this._segments=t.map(e=>this.createSegment(e)),this.updateHasVertexFlag()}get vertexCount(){return this._segments.length}get closed(){return(this._flags&2)!==0}set closed(t){this.setFlag(2,t)}get suppressStartCaps(){return(this._flags&4)!==0}set suppressStartCaps(t){this.setFlag(4,t)}get suppressEndCaps(){return(this._flags&8)!==0}set suppressEndCaps(t){this.setFlag(8,t)}appendSegment(t){this._segments.push(this.createSegment(t)),this.updateHasVertexFlag()}clearSegments(){this._segments=[],this.updateHasVertexFlag()}get geometricExtents(){const t=this.collectGeometryPoints();return new H().setFromPoints(t)}subGetIntersectCurves(){const t=[],e=this.getMLineStyle(),n=this.getRenderableElementCount(e);if(n<=0)return ee(this.getReferencePath(),this.closed);for(let r=0;r<n;r++)t.push(...ee(this.getElementPath(r,e),this.closed));return t}transformBy(t){return this._startPosition.applyMatrix4(t),this._segments.forEach(e=>{e.position.applyMatrix4(t),this.transformVector(e.direction,t),this.transformVector(e.miterDirection,t)}),this.transformVector(this._normal,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"mline",properties:[{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"scale",type:"float",editable:!0,accessor:{get:()=>this.scale,set:t=>{this.scale=t}}},{name:"justification",type:"enum",editable:!0,options:[{label:kr[0],value:0},{label:kr[1],value:1},{label:kr[2],value:2}],accessor:{get:()=>this.justification,set:t=>{this.justification=t}}},{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}},{name:"vertexCount",type:"int",editable:!1,accessor:{get:()=>this.vertexCount}},{name:"styleObjectHandle",type:"string",editable:!0,accessor:{get:()=>this.styleObjectHandle,set:t=>{this.styleObjectHandle=t}}},{name:"suppressStartCaps",type:"boolean",editable:!0,accessor:{get:()=>this.suppressStartCaps,set:t=>{this.suppressStartCaps=t}}},{name:"suppressEndCaps",type:"boolean",editable:!0,accessor:{get:()=>this.suppressEndCaps,set:t=>{this.suppressEndCaps=t}}}]},{groupName:"geometry",properties:[{name:"startPositionX",type:"float",editable:!0,accessor:{get:()=>this.startPosition.x,set:t=>{this.startPosition.x=t}}},{name:"startPositionY",type:"float",editable:!0,accessor:{get:()=>this.startPosition.y,set:t=>{this.startPosition.y=t}}},{name:"startPositionZ",type:"float",editable:!0,accessor:{get:()=>this.startPosition.z,set:t=>{this.startPosition.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this._startPosition.clone()),this._segments.forEach(e=>t.push(e.position.clone())),t}subMoveGripPointsAt(t,e){const n=[this._startPosition,...this._segments.map(r=>r.position)];return er(t,e,n),Et(t,r=>{this.updateReferencePathDirectionsAfterGripMove(r)}),this}subGetOsnapPoints(t,e,n,r){const s=[this._startPosition,...this._segments.map(a=>a.position)];if(s.length!==0)switch(t){case T.EndPoint:r.push(...s);break;case T.MidPoint:case T.Nearest:case T.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];nr(s[o],s[o+1],t,e,c),a.push(...c)}if(t===T.MidPoint)r.push(...a);else{const o=ye(e,a);o&&r.push(o)}break}}}subWorldDraw(t){if(this._segments.length===0)return;const e=[],n=this.getMLineStyle(),r=this.getRenderableElementCount(n),s=t.subEntityTraits,a=s.color;this._drawIsColorByLayer=s.isColorByLayer;const o=s.lineType,c=s.fillType,l=s.drawOrder,h=this.createFillArea(n,r);if(h&&(this.resetTraitsColor(s,a),this.applyFillTraits(n,s),s.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},s.drawOrder=-1,e.push(t.area(h)),s.fillType=c,s.drawOrder=l),r<=0){const u=this.getReferencePath();u.length>=2&&e.push(t.lines(u))}else{for(let u=0;u<r;u++){this.resetTraitsColor(s,a),s.lineType=o,this.applyStyleElementTraits(n,u,s);const d=this.getElementPath(u,n);d.length>=2&&e.push(t.lines(d))}this.appendStyleDrivenJointAndCapEntities(t,e,n,r,a,o)}if(this.resetTraitsColor(s,a),s.lineType=o,s.fillType=c,s.drawOrder=l,e.length!==0)return e.length===1?e[0]:t.group(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMline"),t.writeString(2,this.styleName),t.writeHandle(340,this._styleObjectHandle),t.writeDouble(40,this._scale),t.writeInt16(70,this._justification),t.writeInt16(71,this._flags),t.writeInt16(72,this.vertexCount),t.writeInt16(73,this._styleCount),t.writePoint3d(10,this._startPosition),t.writeVector3d(210,this._normal),this._segments.forEach(e=>{t.writePoint3d(11,e.position),t.writeVector3d(12,e.direction),t.writeVector3d(13,e.miterDirection),e.elements.forEach(n=>{t.writeInt16(74,n.parameterCount),n.parameters.forEach(r=>t.writeDouble(41,r)),t.writeInt16(75,n.fillCount),n.fillParameters.forEach(r=>t.writeDouble(42,r))})}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMline");let e=this._startPosition.x,n=this._startPosition.y,r=this._startPosition.z,s=this._normal.x,a=this._normal.y,o=this._normal.z;const c=[];let l=null,h=null,u=!1,d=!1,g=0,f=0;const p=()=>{h&&l&&l.elements.push(h),h=null,u=!1,d=!1,g=0,f=0},m=()=>{p(),l&&c.push(l),l=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const b=Number(y.code),_=Number(y.value);switch(b){case 2:this.styleName=String(y.value);break;case 340:this.styleObjectHandle=String(y.value);break;case 40:this.scale=_;break;case 70:this.justification=_;break;case 71:this.flags=_;break;case 72:break;case 73:this.styleCount=_;break;case 10:e=_;break;case 20:n=_;break;case 30:r=_;break;case 210:s=_;break;case 220:a=_;break;case 230:o=_;break;case 11:m(),l={position:new x(_,0,0),direction:new A(1,0,0),miterDirection:new A(0,1,0),elements:[]};break;case 21:l&&(l.position.y=_);break;case 31:l&&(l.position.z=_);break;case 12:l&&(l.direction.x=_);break;case 22:l&&(l.direction.y=_);break;case 32:l&&(l.direction.z=_);break;case 13:l&&(l.miterDirection.x=_);break;case 23:l&&(l.miterDirection.y=_);break;case 33:l&&(l.miterDirection.z=_);break;case 74:p(),g=_,u=!0,d=!1,h={parameterCount:_,parameters:[],fillCount:0,fillParameters:[]};break;case 41:h&&u&&(h.parameters.push(_),g>0&&h.parameters.length>=g&&(u=!1));break;case 75:h&&(f=_,h.fillCount=_,d=!0,u=!1);break;case 42:h&&d&&(h.fillParameters.push(_),f>0&&h.fillParameters.length>=f&&(d=!1));break}}return m(),this.startPosition=new x(e,n,r),this.normal=new A(s,a,o),this.segments=c,this}setFlag(t,e){e?this._flags|=t:this._flags&=~t}updateHasVertexFlag(){this.setFlag(1,this._segments.length>0)}updateReferencePathDirectionsAfterGripMove(t){const e=r=>{const s=this._segments[r];if(!s)return;const a=r===0?this._startPosition:this._segments[r-1].position,o=new A().subVectors(s.position,a);o.lengthSq()>0&&s.direction.copy(o.normalize())};if(t===0){this._segments.length>0&&e(0);return}const n=t-1;n<0||n>=this._segments.length||(e(n),n+1<this._segments.length&&e(n+1))}createSegment(t){var e;return{position:new x().copy(t.position),direction:new A().copy(t.direction),miterDirection:new A().copy(t.miterDirection),elements:((e=t.elements)==null?void 0:e.map(n=>this.createElement(n)))??[]}}createElement(t){const e=t.parameters?[...t.parameters]:[],n=t.fillParameters?[...t.fillParameters]:[];return{parameterCount:t.parameterCount??e.length,parameters:e,fillCount:t.fillCount??n.length,fillParameters:n}}cloneSegment(t){return{position:t.position.clone(),direction:t.direction.clone(),miterDirection:t.miterDirection.clone(),elements:t.elements.map(e=>({parameterCount:e.parameterCount,parameters:[...e.parameters],fillCount:e.fillCount,fillParameters:[...e.fillParameters]}))}}collectGeometryPoints(){const t=[this._startPosition];if(this._segments.length===0)return t;const e=this.getMLineStyle(),n=this.getRenderableElementCount(e);if(n<=0)return this._segments.forEach(r=>t.push(r.position)),t;for(let r=0;r<n;r++)t.push(...this.getElementPath(r,e));return t}getRenderableElementCount(t){const e=(t==null?void 0:t.elementCount)??0;return Math.max(this._styleCount,e,...this._segments.map(n=>n.elements.length),0)}getReferencePath(){const t=[this._startPosition.clone(),...this._segments.map(e=>e.position.clone())];return this.closePathIfNeeded(t)}getElementPath(t,e){const n=[],r=this._segments[0];return n.push(this.getElementBoundaryPoint("start",r,t,e)),this._segments.forEach(s=>{n.push(this.offsetPoint(s.position,s.miterDirection,this.getElementMiterOffset(s,t,e)))}),n[n.length-1]=this.getElementBoundaryPoint("end",this._segments[this._segments.length-1],t,e),this.closePathIfNeeded(n)}getElementMiterOffset(t,e,n){var s;const r=t.elements[e];return(s=r==null?void 0:r.parameters)!=null&&s.length?r.parameters[0]:this.getStyleElementOffset(e,n)}getElementBoundaryPoint(t,e,n,r){const s=this.getElementMiterOffset(e,n,r),a=t==="start"?this._startPosition:e.position,o=this.offsetPoint(a,e.miterDirection,s);if(!this.shouldApplyCapCutAtSide(t,r))return o;const c=t==="start"?r==null?void 0:r.startAngle:r==null?void 0:r.endAngle,l=this.computeCapCutDistance(s,c,t);if(l===0)return o;const h=t==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return h.lengthSq()===0?o:o.add(h.multiplyScalar(l))}shouldApplyCapCutAtSide(t,e){return!e||this.closed?!1:t==="start"?this.suppressStartCaps?!1:(e.flags&112)!==0:this.suppressEndCaps?!1:(e.flags&1792)!==0}computeCapCutDistance(t,e,n){const r=this.normalizeCapAngle(e),s=Math.tan(r);if(Math.abs(s)<1e-6)return 0;const a=t/s;return a}normalizeCapAngle(t){if(t==null||!Number.isFinite(t))return Math.PI/2;let e=t%180;return e<0&&(e+=180),(e<1||e>179)&&(e=90),e*Math.PI/180}getStartSegmentDirection(){const t=this._segments[0],e=new A;return t&&(e.subVectors(t.position,this._startPosition),e.lengthSq()===0&&e.copy(t.direction)),e.lengthSq()>0&&e.normalize(),e}getEndSegmentDirection(){const t=this._segments[this._segments.length-1];if(!t)return new A;const e=new A,n=this._segments.length>1?this._segments[this._segments.length-2].position:this._startPosition;return e.subVectors(t.position,n),e.lengthSq()===0&&e.copy(t.direction),e.lengthSq()>0&&e.normalize(),e}createFillArea(t,e){if(!t||(t.flags&1)===0||e<2)return;const n=this.getFillBoundaryElementIndices(e,t);if(!n)return;const r=this.getElementPath(n.outerIndex,t),s=this.getElementPath(n.innerIndex,t),a=this.stripClosingPoint(r),o=this.stripClosingPoint(s);if(a.length<2||o.length<2)return;const c=new de;if(this.closed){if(a.length<3||o.length<3)return;c.add(new ot(a.map(l=>({x:l.x,y:l.y})),!0)),c.add(new ot(o.map(l=>({x:l.x,y:l.y})),!0))}else{const l=[...a,...o.slice().reverse()].map(h=>({x:h.x,y:h.y}));if(l.length<3)return;c.add(new ot(l,!0))}return c}getFillBoundaryElementIndices(t,e){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=-1,a=-1;for(let o=0;o<t;o++){const c=this.getElementReferenceOffset(o,e);c<n&&(n=c,s=o),c>r&&(r=c,a=o)}if(!(s<0||a<0||s===a))return{outerIndex:a,innerIndex:s}}getElementReferenceOffset(t,e){var r;const n=this._segments[0];if(n){const s=n.elements[t];if((r=s==null?void 0:s.parameters)!=null&&r.length)return s.parameters[0]}return this.getStyleElementOffset(t,e)}getStyleElementOffset(t,e){const n=e==null?void 0:e.elements[t];if(!n)return 0;const r=this.getStyleJustificationShift(e);return(n.offset+r)*this._scale}getStyleJustificationShift(t){const e=(t==null?void 0:t.elements)??[];if(e.length<=0)return 0;let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of e){const a=s.offset;a<n&&(n=a),a>r&&(r=a)}return this._justification===0?-r:this._justification===2?-n:0}stripClosingPoint(t){if(t.length<2)return t;const e=t[0],n=t[t.length-1],r=1e-9;return Math.abs(e.x-n.x)<=r&&Math.abs(e.y-n.y)<=r&&Math.abs(e.z-n.z)<=r?t.slice(0,-1):t}offsetPoint(t,e,n){if(n===0||e.lengthSq()===0)return t.clone();const r=e.clone().normalize().multiplyScalar(n);return t.clone().add(r)}closePathIfNeeded(t){if(!this.closed||t.length<2)return t;const e=t[0],n=t[t.length-1],r=1e-9;return Math.abs(e.x-n.x)<=r&&Math.abs(e.y-n.y)<=r&&Math.abs(e.z-n.z)<=r||t.push(e.clone()),t}appendStyleDrivenJointAndCapEntities(t,e,n,r,s,a){!n||r<2||(e.push(...this.drawMiterJointEntities(t,n,r,s,a)),e.push(...this.drawCapEntities(t,n,r,s,a)))}drawMiterJointEntities(t,e,n,r,s){if(this.closed||this._segments.length<2||(e.flags&2)===0)return[];const a=[],o=t.subEntityTraits;for(let c=0;c<this._segments.length-1;c++){const l=this._segments[c],h=Array.from({length:n},(u,d)=>{const g=this.getElementMiterOffset(l,d,e);return{elementIndex:d,offset:g,point:this.offsetPoint(l.position,l.miterDirection,g)}}).sort((u,d)=>d.offset-u.offset);for(let u=0;u<h.length-1;u++)this.applyElementDrawTraits(o,r,s,e,h[u].elementIndex),a.push(t.lines([h[u].point,h[u+1].point]))}return a}drawCapEntities(t,e,n,r,s){if(this.closed||this._segments.length<=0)return[];const a=[];return a.push(...this.drawCapEntitiesForSide(t,"start",e,n,r,s)),a.push(...this.drawCapEntitiesForSide(t,"end",e,n,r,s)),a}drawCapEntitiesForSide(t,e,n,r,s,a){if(e==="start"&&this.suppressStartCaps)return[];if(e==="end"&&this.suppressEndCaps)return[];const o=n.flags,c=e==="start",l=c?(o&16)!==0:(o&256)!==0,h=c?(o&64)!==0:(o&1024)!==0,u=c?(o&32)!==0:(o&512)!==0;if(!l&&!h&&!u)return[];const d=this.getCapElementPoints(e,r,n);if(d.length<2)return[];const g=[],f=t.subEntityTraits;if(l)for(let m=0;m<d.length-1;m++)this.applyElementDrawTraits(f,s,a,n,d[m].elementIndex),g.push(t.lines([d[m].point,d[m+1].point]));const p=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(h){const m=this.drawCapArcBetweenElements(t,e,d[0],d[d.length-1],p,f,s,a,n);m&&g.push(m)}if(u)for(let m=1;m<Math.floor(d.length/2);m++){const y=d[m],b=d[d.length-1-m];if(!y||!b||y===b)continue;const _=this.drawCapArcBetweenElements(t,e,y,b,p,f,s,a,n);_&&g.push(_)}return g}getCapElementPoints(t,e,n){const r=t==="start"?this._segments[0]:this._segments[this._segments.length-1];return r?Array.from({length:e},(s,a)=>({elementIndex:a,offset:this.getElementMiterOffset(r,a,n),point:this.getElementBoundaryPoint(t,r,a,n)})).sort((s,a)=>a.offset-s.offset):[]}drawCapArcBetweenElements(t,e,n,r,s,a,o,c,l){const h=e==="end"?r.point:n.point,u=e==="end"?n.point:r.point,d=h.distanceTo(u);if(d<=1e-9||s.lengthSq()===0)return;const f=h.clone().add(new A().subVectors(u,h).multiplyScalar(.5)).add(s.clone().normalize().multiplyScalar(d/2)),p=_t.createByThreePoints(h,u,f);if(p)return this.applyElementDrawTraits(a,o,c,l,e==="end"?r.elementIndex:n.elementIndex),t.circularArc(p)}applyElementDrawTraits(t,e,n,r,s){this.resetTraitsColor(t,e),t.lineType=n,this.applyStyleElementTraits(r,s,t)}transformVector(t,e){const n=new x,r=new x(t.x,t.y,t.z);n.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-n.x,r.y-n.y,r.z-n.z)}getMLineStyle(){var s;const t=this.database.objects.mlineStyle,e=this.styleObjectHandle?t.getIdAt(this.styleObjectHandle):void 0;if(e)return e;const n=this.styleName?t.getAt(this.styleName):void 0;if(n)return n;const r=(s=this.styleName)==null?void 0:s.toUpperCase();if(r)for(const[a,o]of t.entries()){const c=(o.styleName||a).toUpperCase();if(a.toUpperCase()===r||c===r)return o}}applyStyleElementTraits(t,e,n){const r=t==null?void 0:t.elements[e];if(!r)return;const s=this.resolveStyleElementLineType(r.lineType);s&&(n.lineType=s),!(r.color.isByBlock||r.color.isByLayer)&&this.applyTraitsColor(n,r.color.clone())}applyFillTraits(t,e){const n=t==null?void 0:t.fillColor;!n||n.isByBlock||n.isByLayer||this.applyTraitsColor(e,n.clone())}resetTraitsColor(t,e){t.color=e,t.isColorByLayer=this._drawIsColorByLayer}resolveStyleElementLineType(t){var l;const e=t==null?void 0:t.trim();if(!e)return;const n=e.toUpperCase(),r=kt.toUpperCase(),s=Ne.toUpperCase();let a="UserSpecified",o=e;if(n===r){a="ByLayer";const h=(l=this.database.tables.layerTable.getAt(this.layer))==null?void 0:l.linetype;o=h&&h.toUpperCase()!==r&&h.toUpperCase()!==s?h:wn}else n===s&&(a="ByBlock",o=wn);const c=this.database.tables.linetypeTable.getAt(o);return c?{type:a,...c.linetype}:{type:a,name:o,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||tn}catch{return tn}}};jh.typeName="MLine";let Pa=jh;function km(i,t){if(t.length<3)return;const e=i.subEntityTraits,n=e.fillType,r=e.transparency;e.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},e.transparency=new St(0);const s=new de;s.add(new ot(t,!0));const a=i.area(s);e.fillType=n,e.transparency=r;const o=i.lines(t);return a?o?i.group([a,o]):a:o}const Sd=[208,207,17,224,161,177,26,225],Jc=128,tl=8,gc=3*tl,Ms=2;function Im(i){if(!i||i.length<Jc)return;for(let l=0;l<Sd.length;l++)if(i[Jc+l]!==Sd[l])return;const t=new DataView(i.buffer,i.byteOffset,i.byteLength),e=l=>{const h=t.getFloat64(l,!0),u=t.getFloat64(l+tl,!0),d=t.getFloat64(l+2*tl,!0);if([h,u,d].every(Number.isFinite))return{x:h,y:u,z:d}},n=e(Ms),r=e(Ms+gc),s=e(Ms+2*gc),a=e(Ms+3*gc);if(!n||!r||!s||!a)return;const o=Math.abs(s.x-n.x),c=Math.abs(n.y-s.y);if(!(o<=0||c<=0))return{upperLeft:n,upperRight:r,lowerRight:s,lowerLeft:a}}const Kr="image/wmf",Ei="image/emf",Em=2596720087;function wh(i){return i===Kr||i===Ei}function Ye(i){if(i.length<18)return!1;const t=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.length>=40&&t.getUint32(0,!0)===Em?Pd(i.subarray(22)):Pd(i)}function ka(i){return Lm(i)>=0}const Gv=1574,Wv=15,$v=1128680791;function Tm(i){if(!Ye(i))return;const t=new DataView(i.buffer,i.byteOffset,i.byteLength);let e=0;if(t.getUint32(0,!0)===Em&&(e=22),e+18>i.length)return;const n=t.getUint16(e+2,!0);if(n<9)return;e+=n*2;const r=[];let s=0;for(;e+6<=i.length;){const c=t.getUint32(e,!0),l=c*2,h=t.getUint16(e+4,!0);if(c<3||l<6||e+l>i.length)break;if(h===Gv&&e+44<=e+l&&t.getUint16(e+6,!0)===Wv){const d=t.getUint32(e+10,!0),g=t.getUint32(e+32,!0),f=t.getUint32(e+40,!0),p=g>0&&g===f||g>0?g:f,m=e+44;d===$v&&p>0&&m+p<=e+l&&(r.push(i.subarray(m,m+p)),s+=p)}if(h===0)break;e+=l}if(r.length===0||s<88)return;const a=new Uint8Array(s);let o=0;for(const c of r)a.set(c,o),o+=c.length;if(Ro(a,0))return a}function Lm(i){const t=Math.min(i.length-44,4096);for(let e=0;e<=t;e++)if(Ro(i,e))return e;return-1}function Ro(i,t){if(t+88>i.length)return!1;const e=new DataView(i.buffer,i.byteOffset+t,i.length-t);if(e.getUint32(0,!0)!==1)return!1;const n=e.getUint32(4,!0);if(n<88||t+n>i.length||i[t+40]!==32||i[t+41]!==69||i[t+42]!==77||i[t+43]!==70)return!1;const r=e.getUint32(48,!0),s=e.getUint32(52,!0);return!(r<n||t+r>i.length||s<2||s>1e7)}function Pd(i){if(i.length<18)return!1;const t=new DataView(i.buffer,i.byteOffset,i.byteLength),e=t.getUint16(0,!0),n=t.getUint16(2,!0),r=t.getUint16(4,!0),s=t.getUint32(6,!0);return!(e!==1&&e!==2||n<9||n>100||r!==256&&r!==768||(s<n||s*2>i.length+16)&&s<n)}const el=[208,207,17,224,161,177,26,225],qv=2,nl=3,Kv=8,kd=14,fc=128,Zv=64*1024*1024;function Mm(i){if(!(i!=null&&i.length))return;const t=Qv(i);return t||rl(i)}function Qv(i){const t=Zr(i,el);if(t<0)return;const e=i.subarray(t);let n;try{n=cA(e)}catch{return}for(const s of n.entries()){if(s.type!=="stream"||!Id(s.name))continue;const a=n.readStream(s.name);if(!(a!=null&&a.length))continue;const o=Ed(a,{allowMetafile:!1});if(o)return o}const r=["CONTENTS","Ole10Native","Ole10Native","Package"];for(const s of r){const a=n.readStream(s);if(!(a!=null&&a.length))continue;const o=Ia(a);if(o)return o}for(const s of n.entries()){if(s.type!=="stream"||!Id(s.name))continue;const a=n.readStream(s.name);if(!(a!=null&&a.length))continue;const o=Ed(a,{allowMetafile:!0});if(o)return o;const c=rl(a);if(c)return c}for(const s of n.entries()){if(s.type!=="stream")continue;const a=n.readStream(s.name);if(!(a!=null&&a.length))continue;const o=rl(a);if(o)return o}}function Id(i){return/olepres/i.test(i)||i.includes("OlePres")}function Ed(i,t={}){if(i.length<28)return;const e=t.allowMetafile!==!1,n=new DataView(i.buffer,i.byteOffset,i.byteLength);let r=0;const s=n.getUint32(r,!0);r+=4;let a=0;if(s===4294967295)a=n.getUint32(r,!0),r+=4;else if(s===4294967294){if(r+4>i.length)return;const h=n.getUint32(r,!0);r+=4+h}else if(s>0&&s<65535)r+=s;else return;if(r+4>i.length)return;const o=n.getUint32(r,!0);if(r+=4,o>4&&(r+=o-4),r+=24,r+4>i.length)return;const c=n.getUint32(r,!0);if(r+=4,c<=0||r+c>i.length)return;const l=i.subarray(r,r+c);return Jv(l,a,{allowMetafile:e})}function Jv(i,t,e={}){const n=e.allowMetafile!==!1;if(!((t===kd||t===nl)&&!n)){if(t===Kv){const s=Om(i);if(s)return s}if(t===qv){const s=Ia(i);if(s)return s}if(n&&(t===kd||t===nl)){const s=il(i,t);if(s)return s}if(n){const s=il(i);if(s)return s}return Ia(i)}}function il(i,t){let e=i;if(t===nl&&i.length>30){const r=i.subarray(12);Ye(r)&&(e=r)}if(Ye(e)){const r=Tm(e);if(r)return new Blob([cr(r)],{type:Ei})}const n=Lm(i);if(n>=0&&Ro(i,n)){const r=tA(i,n);if(r)return new Blob([cr(r)],{type:Ei});const a=new DataView(i.buffer,i.byteOffset+n,i.length-n).getUint32(48,!0);if(a>88&&n+a<=i.length)return new Blob([cr(i.subarray(n,n+a))],{type:Ei})}if(Ye(e)){const r=eA(e);return r?new Blob([cr(r)],{type:Kr}):new Blob([cr(e)],{type:Kr})}}function cr(i){const t=new Uint8Array(i.length);return t.set(i),t}function tA(i,t){if(!Ro(i,t))return;const e=new DataView(i.buffer,i.byteOffset+t,i.length-t),n=e.getUint32(48,!0),r=e.getUint32(52,!0);let s=0;for(let a=0;a<r;a++){if(s+8>n)return;const o=e.getUint32(s,!0),c=e.getUint32(s+4,!0);if(c<8||s+c>n)return;if(s+=c,o===14)return i.subarray(t,t+s)}}function eA(i){let t=0;const e=new DataView(i.buffer,i.byteOffset,i.byteLength);if(i.length>=40&&e.getUint32(0,!0)===2596720087&&(t=22),!Ye(i.subarray(t)))return;const n=new DataView(i.buffer,i.byteOffset+t,i.length-t),r=n.getUint16(2,!0),s=n.getUint32(6,!0),a=t+s*2;if(a>i.length)return;let o=t+r*2;const c=a;let l=0;for(;o+6<=c&&l<5e5;){const h=e.getUint32(o,!0),u=e.getUint16(o+4,!0);if(h<3||o+h*2>c)return;if(o+=h*2,l++,u===0)return i.subarray(0,o)}}function rl(i){const t=Ia(i);if(t)return t;if(ka(i)||Ye(i))return il(i)}function Ia(i){const t=nA(i);if(t)return t;const e=iA(i);if(e)return e;const n=rA(i);if(n)return n;const r=sA(i);if(r)return r;const s=aA(i);if(s)return s}function nA(i){for(let t=0;t<i.length-14;t++){if(i[t]!==66||i[t+1]!==77)continue;const e=new DataView(i.buffer,i.byteOffset+t,i.length-t),n=e.getUint32(2,!0);if(n<14||n>i.length-t)continue;const r=e.getUint32(10,!0);if(!(r<14||r>=n))return new Blob([i.subarray(t,t+n)],{type:"image/bmp"})}}function iA(i){const e=Zr(i,[137,80,78,71,13,10,26,10]);if(!(e<0)){for(let n=e+8;n+12<=i.length;n++)if(i[n+4]===73&&i[n+5]===69&&i[n+6]===78&&i[n+7]===68){const r=n+12;return new Blob([i.subarray(e,r)],{type:"image/png"})}return new Blob([i.subarray(e)],{type:"image/png"})}}function rA(i){const t=Zr(i,[255,216,255]);if(!(t<0)){for(let e=t+3;e+1<i.length;e++)if(i[e]===255&&i[e+1]===217)return new Blob([i.subarray(t,e+2)],{type:"image/jpeg"})}}function sA(i){const t=Zr(i,[71,73,70,56,55,97]),e=Zr(i,[71,73,70,56,57,97]),n=t>=0?t:e;if(!(n<0)){for(let r=n+6;r<i.length;r++)if(i[r]===59)return new Blob([i.subarray(n,r+1)],{type:"image/gif"});return new Blob([i.subarray(n)],{type:"image/gif"})}}function aA(i){for(let t=0;t+40<=i.length;t++){const e=new DataView(i.buffer,i.byteOffset+t,i.length-t),n=e.getUint32(0,!0);if(n!==40)continue;const r=e.getInt32(4,!0),s=e.getInt32(8,!0),a=e.getUint16(12,!0),o=e.getUint16(14,!0),c=e.getUint32(16,!0),l=e.getUint32(20,!0),h=e.getUint32(32,!0);if(r<=0||r>65536||s===0||Math.abs(s)>65536||a!==1||![1,4,8,16,24,32].includes(o)||c!==0&&c!==3)continue;const u=Cm(n,o,c,h),d=Math.abs(s),g=r*o+31>>5<<2,f=l>0?l:g*d,p=u+f;if(!(p<=40||t+p>i.length))return Om(i.subarray(t,t+p))}}function Cm(i,t,e,n){let r=0;return t>8&&e===3&&(r+=12),n>0?r+=n*4:t<=8&&(r+=(1<<t)*4),i+r}function Om(i){if(i.length<40)return;const e=new DataView(i.buffer,i.byteOffset,i.byteLength).getUint32(0,!0);if(e!==40&&e!==12)return;const n=14+i.length,r=new Uint8Array(14),s=new DataView(r.buffer);r[0]=66,r[1]=77,s.setUint32(2,n,!0),s.setUint32(10,14+oA(i),!0);const a=new Uint8Array(n);return a.set(r,0),a.set(i,14),new Blob([a],{type:"image/bmp"})}function oA(i){const t=new DataView(i.buffer,i.byteOffset,i.byteLength),e=t.getUint32(0,!0);if(e===12){const a=t.getUint16(10,!0),o=a<=8?1<<a:0;return e+o*3}const n=t.getUint16(14,!0),r=t.getUint32(16,!0),s=t.getUint32(32,!0);return Cm(e,n,r,s)}function Zr(i,t){t:for(let e=0;e<=i.length-t.length;e++){for(let n=0;n<t.length;n++)if(i[e+n]!==t[n])continue t;return e}return-1}function cA(i){if(i.length<512)throw new Error("CFB too small");for(let P=0;P<el.length;P++)if(i[P]!==el[P])throw new Error("Not a CFB document");const t=new DataView(i.buffer,i.byteOffset,i.byteLength),n=1<<t.getUint16(30,!0);if(n!==512&&n!==4096)throw new Error("Unsupported CFB sector size");const r=t.getUint32(44,!0),s=t.getUint32(48,!0),a=t.getUint32(56,!0),o=t.getUint32(60,!0),c=t.getUint32(64,!0),l=t.getUint32(68,!0),h=t.getUint32(72,!0),u=[];for(let P=0;P<109;P++){const v=t.getUint32(76+P*4,!0);v<=4294967290&&u.push(v)}let d=l;for(let P=0;P<h&&d<=4294967290;P++){const v=(d+1)*n;if(v+n>i.length)break;const S=n/4-1;for(let I=0;I<S;I++){const M=t.getUint32(v+I*4,!0);M<=4294967290&&u.push(M)}d=t.getUint32(v+S*4,!0)}const g=[];for(let P=0;P<Math.min(r,u.length);P++){const S=(u[P]+1)*n;if(S+n>i.length)break;const I=n/4;for(let M=0;M<I;M++)g.push(t.getUint32(S+M*4,!0))}const f=Cs(g,s,4096),p=Os(i,f,n),m=[],y=Math.floor(p.length/fc);for(let P=0;P<y;P++){const v=P*fc,S=new DataView(p.buffer,p.byteOffset+v,fc),I=S.getUint16(64,!0);if(I<2||I>64)continue;const M=Math.floor((I-2)/2);let O="";for(let $=0;$<M;$++)O+=String.fromCharCode(S.getUint16($*2,!0));const N=S.getUint8(66),nt=S.getUint32(116,!0),W=S.getUint32(120,!0),F=S.getUint32(124,!0),q=F===0?W:W+F*4294967296;let L="unknown";N===5?L="root":N===1?L="storage":N===2&&(L="stream"),m.push({name:O,type:L,size:q,startSector:nt})}const b=m.find(P=>P.type==="root"),_=[];if(c>0&&o<=4294967290){const P=Cs(g,o,c),v=Os(i,P,n),S=new DataView(v.buffer,v.byteOffset,v.byteLength);for(let I=0;I+4<=v.length;I+=4)_.push(S.getUint32(I,!0))}let w;if(b&&b.size>0){const P=Cs(g,b.startSector,65536);w=Os(i,P,n).subarray(0,b.size)}return{entries:()=>m,readStream:P=>{const v=m.find(I=>I.type==="stream"&&(I.name===P||I.name.toLowerCase()===P.toLowerCase()));if(!v||v.size<=0||v.size>Zv)return;if(v.size<a&&w&&_.length>0){const M=Dm(_,v.startSector,65536),O=new Uint8Array(v.size);let N=0;for(const nt of M){if(N>=v.size)break;const W=nt*64,F=Math.min(W+64,w.length);if(W>=w.length)break;const q=w.subarray(W,F);O.set(q.subarray(0,Math.min(q.length,v.size-N)),N),N+=q.length}return O.subarray(0,Math.min(N,v.size))}const S=Cs(g,v.startSector,65536);return Os(i,S,n).subarray(0,v.size)}}}function Cs(i,t,e){return Dm(i,t,e)}function Dm(i,t,e){const n=[];let r=t;const s=new Set;for(;r<=4294967290&&n.length<e&&!(s.has(r)||(s.add(r),n.push(r),r>=i.length));)r=i[r];return n}function Os(i,t,e){const n=new Uint8Array(t.length*e);let r=0;for(const s of t){const a=(s+1)*e,o=Math.min(a+e,i.length);if(a>=i.length)break;n.set(i.subarray(a,o),r),r+=e}return n}const Vh=class Vh extends et{};Vh.typeName="Frame";let Ea=Vh;const Uh=class Uh extends Ea{constructor(){super(),this._oleVersion=0}get dxfTypeName(){return"OLEFRAME"}get oleVersion(){return this._oleVersion}set oleVersion(t){this._oleVersion=t}getOleObject(){return this._oleObject?new Uint8Array(this._oleObject):void 0}setOleObject(t){t==null?this._oleObject=void 0:this._oleObject=t instanceof ArrayBuffer?new Uint8Array(t.slice(0)):new Uint8Array(t),this.onOleObjectChanged()}loadOleObjectFromDxf(t,e){e!=null&&e.length?t!=null&&t>0&&t<e.length?this._oleObject=e.subarray(0,t):this._oleObject=new Uint8Array(e):this._oleObject=void 0,this.onOleObjectChanged()}get oleObjectData(){return this._oleObject}onOleObjectChanged(){}getOleProperties(){return{groupName:"ole",properties:[{name:"oleVersion",type:"int",editable:!0,accessor:{get:()=>this.oleVersion,set:t=>{this.oleVersion=t}}}]}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),this.getOleProperties()]}}get geometricExtents(){return new H}subWorldDraw(t){}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbOleFrame"),t.writeInt16(70,this._oleVersion),(e=this._oleObject)!=null&&e.length){t.writeInt32(90,this._oleObject.length);let n=0;for(;n<this._oleObject.length;){const r=this._oleObject.subarray(n,n+127);t.writeString(310,Po(r)),n+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbOleFrame");const e=[];let n;const r=()=>{e.length>0&&this.loadOleObjectFromDxf(n,cs(e))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 1:break;case 70:this.oleVersion=o;break;case 90:n=o;break;case 310:s.value instanceof Uint8Array?e.push(s.value):e.push(String(s.value));break}}return r(),this}};Uh.typeName="OleFrame";let Qr=Uh;var Ir=(i=>(i[i.Link=1]="Link",i[i.Embedded=2]="Embedded",i[i.Static=3]="Static",i))(Ir||{}),Ta=(i=>(i[i.ModelSpace=0]="ModelSpace",i[i.PaperSpace=1]="PaperSpace",i))(Ta||{});const Hh=class Hh extends Qr{constructor(){super(),this._upperLeft=new x,this._lowerRight=new x,this._rotation=0,this._scaleWidth=1,this._scaleHeight=1,this._lockAspect=!1,this._outputQuality=0,this._autoOutputQuality=0,this._oleObjectType=2,this._tileMode=0,this._userType="",this._linkName="",this._linkPath="",this._oleClientItem=null,this._imageResolved=!1}get dxfTypeName(){return"OLE2FRAME"}get upperLeftCorner(){return this._upperLeft}set upperLeftCorner(t){this._upperLeft.copy(t)}get lowerRightCorner(){return this._lowerRight}set lowerRightCorner(t){this._lowerRight.copy(t)}getLocation(t){return t?t.copy(this._upperLeft):this._upperLeft.clone()}setLocation(t){const e=t.x-this._upperLeft.x,n=t.y-this._upperLeft.y,r=(t.z??0)-this._upperLeft.z;this._upperLeft.copy(t),this._lowerRight.x+=e,this._lowerRight.y+=n,this._lowerRight.z+=r}position(){return{upperLeft:this._upperLeft.clone(),upperRight:this.cornerUpperRight(),lowerLeft:this.cornerLowerLeft(),lowerRight:this._lowerRight.clone()}}setPosition(t){this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight)}wcsWidth(){return Math.abs(this._lowerRight.x-this._upperLeft.x)}setWcsWidth(t){const e=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+e*Math.abs(t),this._lockAspect&&this.syncHeightFromAspect()}wcsHeight(){return Math.abs(this._upperLeft.y-this._lowerRight.y)}setWcsHeight(t){const e=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-e*Math.abs(t),this._lockAspect&&this.syncWidthFromAspect()}scaleWidth(){return this._scaleWidth}setScaleWidth(t){this._scaleWidth=t}scaleHeight(){return this._scaleHeight}setScaleHeight(t){this._scaleHeight=t}rotation(){return this._rotation}setRotation(t){this._rotation=t}lockAspect(){return this._lockAspect}setLockAspect(t){this._lockAspect=!!t}outputQuality(){return this._outputQuality}setOutputQuality(t){this._outputQuality=t&255}autoOutputQuality(){return this._autoOutputQuality}setAutoOutputQuality(t){this._autoOutputQuality=t&255}getType(){return this._oleObjectType}setType(t){this._oleObjectType=t}get oleObjectType(){return this._oleObjectType}set oleObjectType(t){this._oleObjectType=t}get tileMode(){return this._tileMode}set tileMode(t){this._tileMode=t}getUserType(){return this._userType}setUserType(t){this._userType=t}get userType(){return this._userType}set userType(t){this._userType=t}getLinkName(){return this._linkName}setLinkName(t){this._linkName=t}getLinkPath(){return this._linkPath}setLinkPath(t){this._linkPath=t}getOleClientItem(){return this._oleClientItem}setOleClientItem(t){this._oleClientItem=t??null}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.upperLeftCorner.x,set:t=>{this.setLocation({x:t,y:this.upperLeftCorner.y,z:this.upperLeftCorner.z})}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.upperLeftCorner.y,set:t=>{this.setLocation({x:this.upperLeftCorner.x,y:t,z:this.upperLeftCorner.z})}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.upperLeftCorner.z,set:t=>{this.setLocation({x:this.upperLeftCorner.x,y:this.upperLeftCorner.y,z:t})}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation(),set:t=>{this.setRotation(t)}}},{name:"width",type:"float",editable:!0,accessor:{get:()=>this.wcsWidth(),set:t=>{this.setWcsWidth(t)}}},{name:"height",type:"float",editable:!0,accessor:{get:()=>this.wcsHeight(),set:t=>{this.setWcsHeight(t)}}},{name:"scaleWidth",type:"float",editable:!0,accessor:{get:()=>this.scaleWidth(),set:t=>{this.setScaleWidth(t)}}},{name:"scaleHeight",type:"float",editable:!0,accessor:{get:()=>this.scaleHeight(),set:t=>{this.setScaleHeight(t)}}},{name:"lockAspect",type:"boolean",editable:!0,accessor:{get:()=>this.lockAspect(),set:t=>{this.setLockAspect(t)}}}]},{groupName:"ole",properties:[...this.getOleProperties().properties,{name:"userType",type:"string",editable:!0,accessor:{get:()=>this.userType,set:t=>{this.userType=t}}},{name:"oleObjectType",type:"enum",editable:!0,options:[{label:Ir[1],value:1},{label:Ir[2],value:2},{label:Ir[3],value:3}],accessor:{get:()=>this.oleObjectType,set:t=>{this.oleObjectType=t}}},{name:"tileMode",type:"enum",editable:!0,options:[{label:Ta[0],value:0},{label:Ta[1],value:1}],accessor:{get:()=>this.tileMode,set:t=>{this.tileMode=t}}},{name:"linkName",type:"string",editable:!0,accessor:{get:()=>this.getLinkName(),set:t=>{this.setLinkName(t)}}},{name:"linkPath",type:"string",editable:!0,accessor:{get:()=>this.getLinkPath(),set:t=>{this.setLinkPath(t)}}},{name:"outputQuality",type:"int",editable:!0,accessor:{get:()=>this.outputQuality(),set:t=>{this.setOutputQuality(t)}}},{name:"autoOutputQuality",type:"int",editable:!0,accessor:{get:()=>this.autoOutputQuality(),set:t=>{this.setAutoOutputQuality(t)}}}]}]}}get geometricExtents(){return new H().setFromPoints(this.boundaryPath())}subGetIntersectCurves(){return ee(this.boundaryPath().slice(0,4),!0)}subGetGripPoints(){return this.boundaryPath().slice(0,4)}subMoveGripPointsAt(t,e){const n=this.boundaryPath().slice(0,4);return er(t,e,n),Et(t,r=>{r===0?this._upperLeft.copy(n[0]):r===2?this._lowerRight.copy(n[2]):r===1?(this._upperLeft.y=n[1].y,this._lowerRight.x=n[1].x,this._upperLeft.z=n[1].z,this._lowerRight.z=n[1].z):r===3&&(this._upperLeft.x=n[3].x,this._lowerRight.y=n[3].y,this._upperLeft.z=n[3].z,this._lowerRight.z=n[3].z)}),this}subGetOsnapPoints(t,e,n,r){if(t===T.Insertion){r.push(this._upperLeft.clone());return}const s=this.boundaryPath().slice(0,4);if(t===T.EndPoint){r.push(...s);return}ko(s,!0,t,e,r)}transformBy(t){const e=this._lowerRight.x-this._upperLeft.x,n=this._upperLeft.y-this._lowerRight.y,r=Math.cos(this._rotation),s=Math.sin(this._rotation),a=this._upperLeft.clone(),o=a.clone().add(new A(e*r,e*s,0)),c=a.clone().add(new A(n*s,-n*r,0));a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new A().subVectors(o,a),h=new A().subVectors(c,a);return this._upperLeft.copy(a),this._rotation=Math.atan2(l.y,l.x),this._lowerRight.set(a.x+l.length(),a.y-h.length(),a.z),this}get image(){return this.resolveImage()}subWorldDraw(t){const e=this.resolveImage(),n=this.imageBoundaryPath();return e?t.image(e,{boundary:n,roation:this._rotation}):km(t,this.boundaryPath())}onOleObjectChanged(){this._image=void 0,this._imageResolved=!1,this.applyGeometryFromOleObjectData()}applyGeometryFromOleObjectData(){const t=Im(this.oleObjectData);t&&(this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight))}resolveImage(){return this._imageResolved?this._image:(this._imageResolved=!0,this._image=Mm(this.oleObjectData),this._image)}imageBoundaryPath(){const t=this.boundaryPath(),e=[t[3],t[2],t[1],t[0]];return e.push(e[0].clone()),e}dxfOutFields(t){et.prototype.dxfOutFields.call(this,t),t.writeSubclassMarker("AcDbOle2Frame"),t.writeInt16(70,this.oleVersion),this._userType&&t.writeString(3,this._userType),t.writePoint3d(10,this._upperLeft),t.writePoint3d(11,this._lowerRight),t.writeInt16(71,this._oleObjectType),t.writeInt16(72,this._tileMode),this._outputQuality&&t.writeInt16(73,this._outputQuality);const e=this.getOleObject();if(e!=null&&e.length){t.writeInt32(90,e.length);let n=0;for(;n<e.length;){const r=e.subarray(n,n+127);t.writeString(310,Po(r)),n+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){et.prototype.dxfInFields.call(this,t),t.atSubclassData("AcDbOle2Frame");let e=this._upperLeft.x,n=this._upperLeft.y,r=this._upperLeft.z,s=this._lowerRight.x,a=this._lowerRight.y,o=this._lowerRight.z;const c=[];let l;const h=()=>{this.upperLeftCorner=new x(e,n,r),this.lowerRightCorner=new x(s,a,o),c.length>0&&this.loadOleObjectFromDxf(l,cs(c))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 1:break;case 3:this.userType=String(u.value);break;case 10:e=g;break;case 20:n=g;break;case 30:r=g;break;case 11:s=g;break;case 21:a=g;break;case 31:o=g;break;case 70:this.oleVersion=g;break;case 71:this.oleObjectType=g;break;case 72:this.tileMode=g;break;case 73:this.setOutputQuality(g);break;case 90:l=g;break;case 310:u.value instanceof Uint8Array?c.push(u.value):c.push(String(u.value));break}}return h(),this}cornerUpperRight(){return new x(this._lowerRight.x,this._upperLeft.y,this._upperLeft.z)}cornerLowerLeft(){return new x(this._upperLeft.x,this._lowerRight.y,this._lowerRight.z)}boundaryPath(){const t=[this._upperLeft.clone(),this.cornerUpperRight(),this._lowerRight.clone(),this.cornerLowerLeft()];if(this._rotation!==0){const e=this._upperLeft;for(let n=1;n<t.length;n++)t[n].sub(e).applyMatrix4(new z().makeRotationZ(this._rotation)),t[n].add(e)}return t.push(t[0].clone()),t}syncHeightFromAspect(){const t=this.wcsWidth();if(t===0||this._scaleWidth===0)return;const e=this._scaleHeight/this._scaleWidth,n=t*e,r=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-r*Math.abs(n)}syncWidthFromAspect(){const t=this.wcsHeight();if(t===0||this._scaleHeight===0)return;const e=this._scaleWidth/this._scaleHeight,n=t*e,r=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+r*Math.abs(n)}};Hh.typeName="Ole2Frame";let La=Hh;const Gh=class Gh extends et{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._ecsRotation=0,this._geo=new x}get dxfTypeName(){return"POINT"}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get ecsRotation(){return this._ecsRotation}set ecsRotation(t){this._ecsRotation=t}get geometricExtents(){return new H().expandByPoint(this._geo)}subGetGripPoints(){return[this._geo]}subMoveGripPointsAt(t,e){return he(t,e,this._geo),this}subGetOsnapPoints(t,e,n,r){t===T.Node&&r.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"ecsRotation",type:"float",editable:!0,accessor:{get:()=>this.ecsRotation,set:t=>{this.ecsRotation=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}get directBatchPrimitive(){var e;return(((e=this.database)==null?void 0:e.pdmode)??0)===0?"point":null}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbPoint"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,this.position),this.ecsRotation!==0&&t.writeAngle(50,this.ecsRotation),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPoint");let e=this.position.x,n=this.position.y,r=this.position.z,s=this.thickness,a=this.ecsRotation*180/Math.PI,o=this.normal.x,c=this.normal.y,l=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 10:e=g;break;case 20:n=g;break;case 30:r=g;break;case 39:s=g;break;case 50:a=g;break;case 210:o=g;break;case 220:c=g;break;case 230:l=g;break}}const h=new A(o,c,l);return h.lengthSq()>0&&this.normal.copy(h.normalize()),this.thickness=s,this.ecsRotation=a*Math.PI/180,this.position=new x(e,n,r),this}};Gh.typeName="Point";let Ma=Gh;var Er=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(Er||{}),Nm=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(Nm||{});const Wh=class Wh extends et{constructor(){super(),this._classVersion=0,this._clipMode=0,this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new x,this._scale=new bt(1,1),this._rotation=0,this._imageSize=new C,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get dxfTypeName(){return"IMAGE"}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get clipMode(){return this._clipMode}set clipMode(t){this._clipMode=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.objects.imageDefinition,e=t.getIdAt(this._imageDefId)??t.getAt(this._imageDefId);if(e)return e.sourceFileName}return""}get imageDisplayName(){const t=this.imageFileName.trim();if(!t)return"";const e=t.replace(/\\/g,"/").split("/");return e[e.length-1]||t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"name",type:"string",editable:!1,accessor:{get:()=>this.imageFileName||this.imageDisplayName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"width",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"height",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"scaleX",type:"float",editable:!0,accessor:{get:()=>this.scale.x,set:t=>{this.scale.x=t}}},{name:"scaleY",type:"float",editable:!0,accessor:{get:()=>this.scale.y,set:t=>{this.scale.y=t}}}]},{groupName:"image",properties:[{name:"brightness",type:"int",editable:!0,accessor:{get:()=>this.brightness,set:t=>{this.brightness=t}}},{name:"contrast",type:"int",editable:!0,accessor:{get:()=>this.contrast,set:t=>{this.contrast=t}}},{name:"fade",type:"int",editable:!0,accessor:{get:()=>this.fade,set:t=>{this.fade=t}}},{name:"isImageShown",type:"boolean",editable:!0,accessor:{get:()=>this.isImageShown,set:t=>{this.isImageShown=t}}},{name:"isImageTransparent",type:"boolean",editable:!0,accessor:{get:()=>this.isImageTransparent,set:t=>{this.isImageTransparent=t}}},{name:"isClipped",type:"boolean",editable:!0,accessor:{get:()=>this.isClipped,set:t=>{this.isClipped=t}}},{name:"isShownClipped",type:"boolean",editable:!0,accessor:{get:()=>this.isShownClipped,set:t=>{this.isShownClipped=t}}},{name:"imageSizeX",type:"float",editable:!0,accessor:{get:()=>this.imageSize.x,set:t=>{this.imageSize.x=t}}},{name:"imageSizeY",type:"float",editable:!0,accessor:{get:()=>this.imageSize.y,set:t=>{this.imageSize.y=t}}},{name:"clipBoundaryType",type:"enum",editable:!0,options:[{label:Er[0],value:0},{label:Er[1],value:1},{label:Er[2],value:2}],accessor:{get:()=>this.clipBoundaryType,set:t=>{this.clipBoundaryType=t}}},{name:"clipMode",type:"int",editable:!0,accessor:{get:()=>this.clipMode,set:t=>{this.clipMode=t}}},{name:"classVersion",type:"int",editable:!0,accessor:{get:()=>this.classVersion,set:t=>{this.classVersion=t}}},{name:"imageDefId",type:"string",editable:!1,accessor:{get:()=>this.imageDefId}}]}]}}get geometricExtents(){const t=new H;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetIntersectCurves(){return ee(this.boundaryPath(),!0)}subGetGripPoints(){return this.boundaryPath()}subMoveGripPointsAt(t,e){return Et(t,n=>{this.isClipped&&this._clipBoundary.length>3?this.moveClippedBoundaryGripAt(n,e):this.moveUnclippedGripAt(n,e)}),this}subGetOsnapPoints(t,e,n,r){if(t===T.Insertion){r.push(this._position);return}const s=this.boundaryPath();if(s.length===0)return;let a=s;if(s.length>1){const o=s[0],c=s[s.length-1];o.x===c.x&&o.y===c.y&&(o.z||0)===(c.z||0)&&(a=s.slice(0,-1))}if(t===T.EndPoint){r.push(...a);return}ko(a,!0,t,e,r)}subWorldDraw(t){const e=this.boundaryPath();if(this._image&&this.isImageShown)return t.image(this._image,{boundary:e,roation:this._rotation});const n=km(t,e),r=this.drawMissingImageLabel(t,e);return r?n?t.group([n,r]):r:n}drawMissingImageLabel(t,e){if(this._image||e.length<3)return;let n="";try{n=this.imageFileName.trim()}catch{return}if(!n)return;const r=this.boundaryCenter(e),{width:s,height:a,rotation:o}=this.boundaryLocalSize(e);if(s<=0||a<=0)return;const c=n.replace(/\\/g,"/"),l=this.fitLabelTextHeight(c,s,a);if(l<=0)return;const h=vx(n),u=En(c,l),d={text:h,height:l,width:Math.max(u,l),position:r,rotation:o,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter};try{return t.mtext(d,this.resolveLabelTextStyle())}catch{return}}resolveLabelTextStyle(){const t=this.database.tables.textStyleTable,e=t.resolveAt(gt)??t.resolveAt("STANDARD");return e?e.textStyle:{name:gt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:0,font:"txt",bigFont:""}}fitLabelTextHeight(t,e,n){const r=e*.85,s=n*.85;if(r<=0||s<=0||!t)return 0;let a=0,o=s;for(let c=0;c<24;c++){const l=(a+o)/2;En(t,l)<=r&&l<=s?a=l:o=l}return a}boundaryCenter(t){let e=t.length;e>1&&t[0].x===t[e-1].x&&t[0].y===t[e-1].y&&(e-=1);let n=0,r=0,s=0;for(let a=0;a<e;a++)n+=t[a].x,r+=t[a].y,s+=t[a].z;return new x(n/e,r/e,s/e)}boundaryLocalSize(t){let e=t.length;if(e>1&&t[0].x===t[e-1].x&&t[0].y===t[e-1].y&&(e-=1),e<2)return{width:this._width,height:this._height,rotation:this._rotation};const n=t[0],r=t[1],s=r.x-n.x,a=r.y-n.y,o=Math.hypot(s,a),c=Math.atan2(a,s);if(o<=0)return{width:this._width,height:this._height,rotation:this._rotation};const l=s/o,h=a/o;let u=0,d=0;for(let f=0;f<e;f++){const p=t[f].x-n.x,m=t[f].y-n.y,y=p*-h+m*l;u=Math.min(u,y),d=Math.max(d,y)}const g=Math.max(d-u,0);return{width:o>0?o:this._width,height:g>0?g:this._height,rotation:c}}transformBy(t){const e=this._width*this._scale.x,n=this._height*this._scale.y,r=new A(e*Math.cos(this._rotation),e*Math.sin(this._rotation),0),s=new A(-n*Math.sin(this._rotation),n*Math.cos(this._rotation),0),a=this._position.clone(),o=this._position.clone().add(r),c=this._position.clone().add(s);a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new A(o).sub(a),h=new A(c).sub(a);return this._position.copy(a),this._rotation=Math.atan2(l.y,l.x),this._width=l.length(),this._height=h.length(),this._scale.set(1,1),this}moveUnclippedGripAt(t,e){const n=this._position.x,r=this._position.y,s=this._width,a=this._height;switch(t){case 0:this._position.add(e);break;case 1:{const o=n,c=r+a,l=n+s+e.x,h=r+e.y;this._position.x=o,this._position.y=h,this._width=l-o,this._height=c-h;break}case 2:{const o=n+s+e.x,c=r+a+e.y;this._width=o-n,this._height=c-r;break}case 3:{const o=n+s,c=r,l=n+e.x,h=r+a+e.y;this._position.x=l,this._position.y=c,this._width=o-l,this._height=h-c;break}}}moveClippedBoundaryGripAt(t,e){if(t<0||t>=this._clipBoundary.length)return;const n=this._width,r=this._height,s=new Ct;s.setFromPoints(this._clipBoundary);const a=new C;a.setX(this._position.x-s.min.x*n),a.setY(this._position.y-s.min.y*r);const o=this._clipBoundary[t],c=o.x*n+a.x+e.x,l=o.y*r+a.y+e.y;o.x=(c-a.x)/n,o.y=(l-a.y)/r}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,n=this._height,r=new Ct;r.setFromPoints(this._clipBoundary);const s=new C;s.setX(this._position.x-r.min.x*e),s.setY(this._position.y-r.min.y*n),this._clipBoundary.forEach(a=>{const o=a.x*e+s.x,c=a.y*n+s.y;t.push(new x(o,c,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Td.copy(t[1]);for(let e=1;e<4;e++)Ds.copy(t[e]),Ds.rotateAround(Td,this._rotation),t[e].setX(Ds.x),t[e].setY(Ds.y)}t.push(t[0])}return t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writeInt32(90,this.classVersion),t.writePoint3d(10,this.position);const e=this.width*this.scale.x,n=this.height*this.scale.y,r=this._imageSize.x>0&&this._imageSize.y>0?this._imageSize:{x:e,y:n},s=r.x>0?e/r.x:e,a=r.y>0?n/r.y:n,o=Math.cos(this._rotation),c=Math.sin(this._rotation);t.writePoint3d(11,{x:s*o,y:s*c,z:0}),t.writePoint3d(12,{x:-a*c,y:a*o,z:0}),t.writePoint2d(13,r),t.writeObjectId(340,this.imageDefId);const l=(this.isImageShown?1:0)|(this.isShownClipped?4:0)|(this.isImageTransparent?8:0);if(t.writeInt16(70,l),t.writeInt16(280,this.isClipped?1:0),t.writeInt16(281,this.brightness),t.writeInt16(282,this.contrast),t.writeInt16(283,this.fade),t.writeInt16(71,this.clipBoundaryType),this.isClipped){t.writeInt16(91,this.clipBoundary.length);for(const h of this.clipBoundary)t.writePoint2d(14,h)}return t.writeInt16(290,this.clipMode),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRasterImage");let e=this.position.x,n=this.position.y,r=this.position.z,s=1,a=0,o=0,c=0,l=1,h=0,u=this.imageSize.x,d=this.imageSize.y;const g=[];let f=null;const p=()=>{f&&(g.push(new C(f.x,f.y)),f=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const m=t.readItem();if(!m)break;const y=Number(m.code),b=Number(m.value);switch(y){case 10:e=b;break;case 20:n=b;break;case 30:r=b;break;case 11:s=b;break;case 21:a=b;break;case 31:o=b;break;case 12:c=b;break;case 22:l=b;break;case 32:h=b;break;case 13:u=b;break;case 23:d=b;break;case 14:p(),f={x:b,y:0};break;case 24:f&&(f.y=b);break;case 70:{this.isImageShown=(b&3)!==0,this.isShownClipped=(b&4)!==0,this.isImageTransparent=(b&8)!==0;break}case 71:this.clipBoundaryType=b;break;case 90:this.classVersion=b;break;case 91:break;case 280:this.isClipped=b!==0;break;case 281:this.brightness=b;break;case 282:this.contrast=b;break;case 283:this.fade=b;break;case 290:this.clipMode=b;break;case 340:this.imageDefId=String(m.value);break}}return p(),this.applyRasterImageDxfIn(e,n,r,s,a,o,c,l,h,u,d,g),this}applyRasterImageDxfIn(t,e,n,r,s,a,o,c,l,h,u,d){this.position.copy({x:t,y:e,z:n}),this.imageSize.copy({x:h,y:u});const g=Math.hypot(r,s,a),f=Math.hypot(o,c,l);this.width=g*(h||1),this.height=f*(u||1),this.rotation=Math.atan2(s,r),d.length>0&&(this.clipBoundary=d)}};Wh.typeName="RasterImage";let Jr=Wh;const Td=new C,Ds=new C,oo=class oo extends Ot{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new x,this._unitDir=new A}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get area(){return 0}get geometricExtents(){const t=new H;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetIntersectCurves(){const t=this._basePoint.clone().add(this._unitDir);return[{kind:"line",line:new Bt(this._basePoint,t),extent:"ray"}]}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subMoveGripPointsAt(t,e){return he(t,e,this.basePoint),this}subGetOsnapPoints(t,e,n,r){const s=this.basePoint;if(t===T.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new Bt(s,s.clone().add(a));switch(t){case T.Nearest:{const c=o.project(e),h=new A(c).sub(s).dot(a);r.push(h<0?s:c);break}case T.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRay");let e=this.basePoint.x,n=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:n=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new x(e,n,r),this.unitDir=new A(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,n=this.unitDir,r=Math.hypot(n.x,n.y);return r<=1e-9||(n.x*(t.y-e.y)-n.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Xg(this.basePoint,this.unitDir,t);if(!e)return null;const n=new oo;return n.basePoint=e,n.unitDir=this.unitDir.clone(),n}};oo.typeName="Ray";let Ca=oo;const $h=class $h extends et{get dxfTypeName(){return"SHAPE"}constructor(){super(),this._position=new x,this._size=1,this._name="",this._rotation=0,this._widthFactor=1,this._oblique=0,this._thickness=0,this._normal=new A(0,0,1),this._shapeNumber=0,this._styleName=""}get position(){return this._position}set position(t){this._position.copy(t)}get size(){return this._size}set size(t){this._size=t}get name(){return this._name}set name(t){this._name=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get shapeNumber(){return this._shapeNumber}set shapeNumber(t){this._shapeNumber=t}get styleId(){var e,n,r;const t=(r=(n=(e=this.database)==null?void 0:e.tables)==null?void 0:n.textStyleTable)==null?void 0:r.resolveAt(this._styleName);return(t==null?void 0:t.objectId)??""}set styleId(t){var n,r,s;const e=(s=(r=(n=this.database)==null?void 0:n.tables)==null?void 0:r.textStyleTable)==null?void 0:s.getIdAt(t);e&&(this._styleName=e.name)}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get isPlanar(){return!0}get geometricExtents(){const t=Math.abs(this._size)/2,e=new H;return e.expandByPoint(this._position),t>0&&(e.expandByPoint(new x(this._position.x-t,this._position.y-t,this._position.z)),e.expandByPoint(new x(this._position.x+t,this._position.y+t,this._position.z))),e}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return he(t,e,this._position),this}subGetOsnapPoints(t,e,n,r){t===T.Insertion&&r.push(this._position)}transformBy(t){const e=new z().setFromExtrusionDirection(this._normal),n=new z().makeRotationZ(this._rotation),r=new z().multiplyMatrices(e,n),s=this._position.clone(),a=new x(this._widthFactor,0,0).applyMatrix4(r).add(s),o=new x(0,1,0).applyMatrix4(r).add(s),c=new x(0,0,1).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new A(a).sub(s),h=new A(o).sub(s),u=new A(c).sub(s);let d=new A().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const f=new z().setFromExtrusionDirection(d).clone().invert(),p=l.clone().applyMatrix4(f),m=h.length(),y=l.length();this._position.copy(s),this._normal.copy(d),y>0&&(this._rotation=Math.atan2(p.y,p.x)),m>0&&(this._size*=m,y>0&&(this._widthFactor*=y/m));const b=u.length();return b>0&&(this._thickness*=b),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"shape",properties:[{name:"name",type:"string",editable:!0,accessor:{get:()=>this.name,set:t=>{this.name=t}}},{name:"size",type:"float",editable:!0,accessor:{get:()=>this.size,set:t=>{this.size=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}},{name:"shapeNumber",type:"int",editable:!0,accessor:{get:()=>this.shapeNumber,set:t=>{this.shapeNumber=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"isPlanar",type:"boolean",editable:!1,accessor:{get:()=>this.isPlanar}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}subWorldDraw(t,e){const n=this.getTextStyle(),r=n?{...n,widthFactor:this.widthFactor,obliqueAngle:this.oblique*180/Math.PI}:void 0,s={...this.renderGlyphIdentity(),size:this.size,position:this._position,rotation:this._rotation,directionVector:this._normal,widthFactor:this.widthFactor};return t.shape(s,r,e)}renderGlyphIdentity(){const t=this._name.trim(),e=Number(t);return t!==""&&Number.isInteger(e)&&e!==0&&String(e)===t?{shapeNumber:e}:{name:t||void 0,shapeNumber:this._shapeNumber!==0?this._shapeNumber:void 0}}getTextStyle(){const t=this.styleName.trim();if(!t)return;const e=this.database.tables.textStyleTable.resolveAt(t);return e==null?void 0:e.textStyle}get dxfShapeIdentity(){const t=this._name.trim();return t||(this._shapeNumber!==0?String(this._shapeNumber):"")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbShape"),t.writePoint3d(10,this.position),t.writeDouble(40,this.size);const e=this.dxfShapeIdentity;return e&&t.writeString(2,e),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeDouble(39,this.thickness),this._styleName&&t.writeString(3,this._styleName),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbShape");let e=this.position.x,n=this.position.y,r=this.position.z,s=this.normal.x,a=this.normal.y,o=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:n=h;break;case 30:r=h;break;case 2:{const u=String(c.value).trim(),d=Number(u);u!==""&&Number.isInteger(d)&&d!==0&&String(d)===u?(this.shapeNumber=d,this.name=""):this.name=u;break}case 3:this.styleName=String(c.value);break;case 39:this.thickness=h;break;case 40:this.size=h;break;case 41:this.widthFactor=h;break;case 50:this.rotation=D.degToRad(h);break;case 51:this.oblique=D.degToRad(h);break;case 210:s=h;break;case 220:a=h;break;case 230:o=h;break}}return this.position={x:e,y:n,z:r},this.normal={x:s,y:a,z:o},this}};$h.typeName="Shape";let Oa=$h;const xi=class xi extends Ot{constructor(){super(),this._normal=new A(0,0,1),this._elevation=0,this._thickness=0,this._vertices=[new x,new x,new x,new x]}get dxfTypeName(){return"TRACE"}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get area(){return new ot(xi.boundaryPointsFromVertices(this._vertices),!0).area}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new H().setFromPoints(this._vertices)}subGetIntersectCurves(){const t=this._vertices[0],e=this._vertices[1],n=this._vertices[2],r=this._vertices[3];return ee([t,e,r,n],!0)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return er(t,e,this._vertices),this}subGetOsnapPoints(t,e,n,r){const s=[this._vertices[0],this._vertices[1],this._vertices[3],this._vertices[2]];ko(s,!0,t,e,r)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!1},{name:"y",type:"float",editable:!1},{name:"z",type:"float",editable:!1}]},accessor:{get:()=>[this.getPointAt(0),this.getPointAt(1),this.getPointAt(2),this.getPointAt(3)]}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"thickness",type:"float",editable:!0,accessor:{get:()=>this.thickness,set:t=>{this.thickness=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]}}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this._elevation=this._vertices[0].z,this}get directBatchPrimitive(){return"area"}subWorldDraw(t){const e=new ot(xi.boundaryPointsFromVertices(this._vertices),!0),n=new de;n.add(e);const r=t.subEntityTraits;return r.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(n)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTrace"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,Zt(this.getPointAt(0),this.normal)),t.writePoint3d(11,Zt(this.getPointAt(1),this.normal)),t.writePoint3d(12,Zt(this.getPointAt(2),this.normal)),t.writePoint3d(13,Zt(this.getPointAt(3),this.normal)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbTrace");const e=[{x:this.getPointAt(0).x,y:this.getPointAt(0).y,z:this.getPointAt(0).z},{x:this.getPointAt(1).x,y:this.getPointAt(1).y,z:this.getPointAt(1).z},{x:this.getPointAt(2).x,y:this.getPointAt(2).y,z:this.getPointAt(2).z},{x:this.getPointAt(3).x,y:this.getPointAt(3).y,z:this.getPointAt(3).z}];let n=this.normal.x,r=this.normal.y,s=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const o=t.readItem();if(!o)break;const c=Number(o.code),l=Number(o.value);switch(c){case 10:case 11:case 12:case 13:e[c-10].x=l;break;case 20:case 21:case 22:case 23:e[c-20].y=l;break;case 30:case 31:case 32:case 33:e[c-30].z=l;break;case 39:this.thickness=l;break;case 210:n=l;break;case 220:r=l;break;case 230:s=l;break}}const a=new A(n,r,s);return a.lengthSq()>0&&this.normal.copy(a.normalize()),e.forEach((o,c)=>this.setPointAt(c,ce(o,this.normal))),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:Ut.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Co(this.collectBoundary2d(),!0,t)}collectBoundary2d(){return xi.boundaryPointsFromVertices(this._vertices)}static boundaryPointsFromVertices(t){const e=t[0],n=t[1],r=t[2],s=t[3];return[new C(e.x,e.y),new C(n.x,n.y),new C(s.x,s.y),new C(r.x,r.y)]}};xi.typeName="Trace";let ts=xi;const qh=class qh extends ts{get dxfTypeName(){return"SOLID"}};qh.typeName="Solid";let Da=qh;function lA(i){return i&2048?"SqrtChord":i&1024?"Chord":"Uniform"}function Ld(i,t){try{return new es(i.controlPoints,i.knots,hA(i.weights,i.controlPoints.length),i.degree,t)}catch{return null}}function hA(i,t){if(!(!i||i.length!==t))return i}const wi=class wi extends Ot{constructor(t,e,n,r,s){super(),this._geoData=null,this._knotTolerance=1e-6,this._controlTolerance=1e-6,this._fitTolerance=1e-9,this._normal=new A(0,0,1),t!==void 0&&this.rebuild(t,e,n,r,s)}get dxfTypeName(){return"SPLINE"}static fromControlPoints(t,e,n,r,s){const a=Xt.fromControlPoints(t,e,n,r,s);return a?Ld(a,s):null}static fromFitPoints(t,e,n,r,s,a){const o=Xt.fromFitPoints(t,e,n,r,s,a);return o?Ld(o,r):null}static fromDwgSpline(t){var o,c,l;const e=!!(t.flag&1),n=lA(t.flag),r=t.numberOfControlPoints||((o=t.controlPoints)==null?void 0:o.length)||0,s=t.numberOfKnots||((c=t.knots)==null?void 0:c.length)||0,a=t.numberOfFitPoints||((l=t.fitPoints)==null?void 0:l.length)||0;if(r>0&&s>0){const h=wi.fromControlPoints(t.controlPoints,t.knots,t.weights,t.degree,e);if(h)return h}return a>0?wi.fromFitPoints(t.fitPoints,n,t.degree,e,t.startTangent,t.endTangent):null}get _geo(){if(this._geoData==null){const t=[{x:0,y:0,z:0},{x:1,y:0,z:0},{x:2,y:0,z:0},{x:3,y:0,z:0}],e=[0,0,0,0,1,1,1,1];this._geoData=Xt.fromControlPoints(t,e,void 0,3,!1)??new Xt(t,e,void 0,3,!1)}return this._geoData}set _geo(t){this._geoData=t}rebuild(t,e,n,r,s){const a=+(t!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(r!==void 0)+ +(s!==void 0);if(a<2||a>5)throw jt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Xt(t,e,n,r):this._geo=new Xt(t,e,n,r,s)}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"spline",spline:this._geo.clone(),extendable:!1}]}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}get knotTolerance(){return this._knotTolerance}set knotTolerance(t){this._knotTolerance=t}get controlTolerance(){return this._controlTolerance}set controlTolerance(t){this._controlTolerance=t}get fitTolerance(){return this._fitTolerance}set fitTolerance(t){this._fitTolerance=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"controlPoints",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!1},{name:"y",type:"float",editable:!1},{name:"z",type:"float",editable:!1}]},accessor:{get:()=>this._geo.controlPoints}},{name:"fitPoints",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!1},{name:"y",type:"float",editable:!1},{name:"z",type:"float",editable:!1}]},accessor:{get:()=>this._geo.fitPoints??[]}},{name:"degree",type:"int",editable:!1,accessor:{get:()=>this._geo.degree}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]},{groupName:"others",properties:[{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}},{name:"knotTolerance",type:"float",editable:!0,accessor:{get:()=>this.knotTolerance,set:t=>{this.knotTolerance=t}}},{name:"controlTolerance",type:"float",editable:!0,accessor:{get:()=>this.controlTolerance,set:t=>{this.controlTolerance=t}}},{name:"fitTolerance",type:"float",editable:!0,accessor:{get:()=>this.fitTolerance,set:t=>{this.fitTolerance=t}}}]}]}}subGetGripPoints(){return this._geo.getGripPoints()}subMoveGripPointsAt(t,e){return this._geo.moveGripPointsAt(t,e),this}subGetOsnapPoints(t,e,n,r){switch(t){case T.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break;case T.Node:{const s=new Set;for(const a of this._geo.knots)s.has(a)||(s.add(a),r.push(this._geo.evaluateAt(a)));break}case T.Nearest:r.push(this._geo.nearestPoint(e));break}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this._geo.tessellate(ds(t));return t.lines(e)}dxfOutFields(t){var n;const e=this._geo;super.dxfOutFields(t),t.writeSubclassMarker("AcDbSpline"),t.writeInt16(70,this.closed?1:0),t.writeInt16(71,e.degree),t.writeInt16(72,e.knots.length),t.writeInt16(73,e.controlPoints.length),t.writeInt16(74,((n=e.fitPoints)==null?void 0:n.length)??0),t.writeDouble(42,this.knotTolerance),t.writeDouble(43,this.controlTolerance),t.writeDouble(44,this.fitTolerance);for(const r of e.knots)t.writeDouble(40,r);for(const r of e.weights)t.writeDouble(41,r);for(const r of e.controlPoints)t.writePoint3d(10,r);for(const r of e.fitPoints??[])t.writePoint3d(11,r);return t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSpline");let e=this.closed?1:0,n=3,r=0,s=0,a=0;const o=[],c=[],l=[],h=[];let u=null,d=null,g=this.knotTolerance,f=this.controlTolerance,p=this.fitTolerance,m=this.normal.x,y=this.normal.y,b=this.normal.z,_=null,w=null,k=null,P=null;const v=()=>{_&&(l.push(_),_=null)},S=()=>{w&&(h.push(w),w=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const M=t.readItem();if(!M)break;const O=Number(M.code),N=Number(M.value);switch(O){case 70:e=N;break;case 71:n=N;break;case 72:r=N;break;case 73:s=N;break;case 74:a=N;break;case 42:g=N;break;case 43:f=N;break;case 44:p=N;break;case 40:o.push(N);break;case 41:c.push(N);break;case 10:v(),_={x:N,y:0,z:0};break;case 20:_&&(_.y=N);break;case 30:_&&(_.z=N);break;case 11:S(),w={x:N,y:0,z:0};break;case 21:w&&(w.y=N);break;case 31:w&&(w.z=N);break;case 12:k={x:N,y:0,z:0};break;case 22:k&&(k.y=N);break;case 32:k&&(k.z=N,u=k,k=null);break;case 13:P={x:N,y:0,z:0};break;case 23:P&&(P.y=N);break;case 33:P&&(P.z=N,d=P,P=null);break;case 210:m=N;break;case 220:y=N;break;case 230:b=N;break}}v(),S(),this.knotTolerance=g,this.controlTolerance=f,this.fitTolerance=p;const I=new A(m,y,b);return I.lengthSq()>0&&this.normal.copy(I.normalize()),this.applyDxfInSpline({flag:e,degree:n,numberOfControlPoints:s||l.length,numberOfKnots:r||o.length,numberOfFitPoints:a||h.length,controlPoints:l,knots:o,weights:c.length>0?c:void 0,fitPoints:h,startTangent:u,endTangent:d}),this}applyDxfInSpline(t){const e=wi.fromDwgSpline(t);e&&(this._geo=e._geo,this.closed=e.closed)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d(1);return e.length<2?1:Ut.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const{points:e,tangents:n}=this._geo.getOffsetSamplePath2d(t),r=xb(e,this.closed,t,n);return r?Ut.fromGePolyline(r):null}collectPath2d(t){return this._geo.getOffsetSamplePath2d(t).points}};wi.typeName="Spline";let es=wi;function uA(i){return i==null?Lt.latest.capabilities:typeof i=="object"&&"supportsHandles"in i?i:i instanceof Lt?i.capabilities:new Lt(i).capabilities}const dA=new A,Kh=class Kh extends Qt{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,n){super(t??""),this._attachmentPoint=exports.AcGiMTextAttachmentPoint.TopLeft,this._numColumns=n,this._numRows=e,this._columnWidth=new Array(n),this._rowHeight=new Array(e),this._cells=new Array(e*n)}get blockTableRecord(){const t=this.blockName;if(t){const n=this.database.tables.blockTable.getAt(t);if(n)return n}const e=this.owningBlockRecordId;if(e)return this.database.tables.blockTable.getIdAt(e)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}resizeGrid(t,e){const n=Math.max(0,t),r=Math.max(0,e);this._numRows=n,this._numColumns=r,this._rowHeight=new Array(n).fill(0),this._columnWidth=new Array(r).fill(0),this._cells=new Array(n*r)}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,n){var s;const r=t*this._numColumns+e;return(s=this._cells[r])==null?void 0:s.text}setTextString(t,e,n){const r=t*this._numColumns+e;if(!this._cells[r]){this._cells[r]={text:n,attachmentPoint:this._attachmentPoint,cellType:1,textHeight:0};return}this._cells[r].text=n}isEmpty(t,e){var r;const n=t*this._numColumns+e;return!((r=this._cells[n])!=null&&r.text)}get geometricExtents(){let t;try{t=this.blockTableRecord}catch{t=void 0}if(t&&t.newIterator().count>0){const o=new H;for(const c of t.newIterator())o.union(c.geometricExtents);return o.applyMatrix4(this.blockTransform),o}const e=this._columnWidth.reduce((o,c)=>o+c,0),n=this._rowHeight.reduce((o,c)=>o+c,0),r=new H;if(e===0&&n===0)return r.expandByPoint(this.position),r;const s=new Li;s.setFromAxisAngle(A.Z_AXIS,this.rotation),ri.compose(this.position,s,this.scaleFactors);const a=[new x(0,0,0),new x(e,0,0),new x(e,-n,0),new x(0,-n,0)];for(const o of a)r.expandByPoint(o.applyMatrix4(ri));return r}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"int",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"int",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:exports.AcGiMTextAttachmentPoint[1],value:1},{label:exports.AcGiMTextAttachmentPoint[2],value:2},{label:exports.AcGiMTextAttachmentPoint[3],value:3},{label:exports.AcGiMTextAttachmentPoint[4],value:4},{label:exports.AcGiMTextAttachmentPoint[5],value:5},{label:exports.AcGiMTextAttachmentPoint[6],value:6},{label:exports.AcGiMTextAttachmentPoint[7],value:7},{label:exports.AcGiMTextAttachmentPoint[8],value:8},{label:exports.AcGiMTextAttachmentPoint[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){const e=this.blockTableRecord;if(e&&e.newIterator().count>0){const g=this.drawAnonymousTableBlock(t,e);if(g)return g}let n=0,r=0;const s=new Uint16Array(this.numColumns*this.numRows*8),a=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let o=0;for(let g=0;g<=this.numRows;g++){n-=g>0?this.rowHeight(g-1):0,r=0;for(let f=0;f<=this.numColumns;f++)r+=f>0?this.columnWidth(f-1):0,a[o++]=r,a[o++]=n,a[o++]=0}const c=[],l=new Array(this.numRows*this.numColumns).fill(!1);r=0,o=0;let h=0;for(let g=0;g<this.numColumns;g++){r+=g>0?this.columnWidth(g-1):0,n=0;for(let f=0;f<this.numRows;f++){n+=f>0?this.rowHeight(f-1):0;const p=this.cell(f*this.numColumns+g);if(h=f*this.numColumns+g,p&&!l[h]){const m=p.borderWidth??1,y=p.borderHeight??1;this.fillVisited(l,h,this.numColumns,m,y),s[o++]=g+f*(this.numColumns+1),s[o++]=g+f*(this.numColumns+1)+m;const b=a[s[o-1]*3]-r,_=g+(f+y)*(this.numColumns+1)+m;g+m==this.numColumns&&(s[o++]=g+f*(this.numColumns+1)+m,s[o++]=_);const w=-a[_*3+1]-n;if(f+y==this.numRows&&(s[o++]=g+(f+y)*(this.numColumns+1)+y,s[o++]=g+(f+y)*(this.numColumns+1)),s[o++]=g+(f+y)*(this.numColumns+1),s[o++]=g+f*(this.numColumns+1),p.text){const k=p.attachmentPoint||this.attachmentPoint||exports.AcGiMTextAttachmentPoint.MiddleCenter,P=this.getTableTextOffset(k,b,w),v={text:p.text,height:this.getCellTextHeight(p,w),width:b,position:dA.set(r,-n,0).clone().add(P),rotation:this.rotation,attachmentPoint:k},S=this.getTextStyle(p);c.push(t.mtext(v,S))}}}}c.push(t.lineSegments(a,3,s));const u=t.group(c),d=new Li;return d.setFromAxisAngle(A.Z_AXIS,this.rotation),ri.compose(this.position,d,this.scaleFactors),u.applyMatrix(ri),u}drawAnonymousTableBlock(t,e){const n=[],r=e.newIterator();for(const o of r){let c;if(o.color.isByBlock){Md.copy(o.color);const l=this.resolvedColor;l.isForeground?o.color.setForeground():l.RGB!=null&&o.color.setRGBValue(l.RGB),c=o.worldDraw(t),o.color.copy(Md)}else c=o.worldDraw(t);c&&(c.objectId=this.objectId,c.ownerId=this.ownerId,c.layerName=this.layer,c.visible=this.visibility&&o.visibility,n.push(c))}const s=t.group(n);s.applyMatrix(this.blockTransform);const a=this.normal;return a&&(a.x!==0||a.y!==0||a.z!==1)&&(ri.setFromExtrusionDirection(a),s.applyMatrix(ri)),s}fillVisited(t,e,n,r,s){if(s==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<s;++o)t[e+a+o*n]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable.resolveAt(t.textStyle);if(!e)throw new Error("No valid text style found in text style table.");return e.textStyle}getTableTextOffset(t,e,n){const r=new A;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-n/2);break;case 5:r.set(e/2,-n/2,0);break;case 6:r.set(e,-n/2,0);break;case 7:r.setY(-n);break;case 8:r.set(e/2,-n,0);break;case 9:r.set(e,-n,0);break}return r}getCellTextHeight(t,e){return t.textHeight&&t.textHeight>0?t.textHeight:Math.max(e/2,1)}dxfOutFields(t){var s,a,o,c,l,h,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((s=t.database)==null?void 0:s.version)??((a=this.database)==null?void 0:a.version),n=uA(e).supportsUtf8CodePage;t.writeInt16(280,this.tableDataVersion),t.writeObjectId(342,this.tableStyleId),t.writeObjectId(343,this.owningBlockRecordId),t.writeVector3d(11,this.horizontalDirection),t.writeUInt32(90,this.tableValueFlag),t.writeUInt32(93,this.tableOverrideFlag),t.writeUInt32(94,this.borderColorOverrideFlag),t.writeUInt32(95,this.borderLineweightOverrideFlag),t.writeUInt32(96,this.borderVisibilityOverrideFlag),t.writeInt16(71,this.attachmentPoint),t.writeInt32(91,this.numRows),t.writeInt32(92,this.numColumns);for(let d=0;d<this.numRows;++d)t.writeDouble(141,this.rowHeight(d));for(let d=0;d<this.numColumns;++d)t.writeDouble(142,this.columnWidth(d));const r=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let d=0;d<r;d++){const g=this._cells[d],f=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(t.writeInt16(171,f),t.writeInt16(172,(g==null?void 0:g.flagValue)??0),t.writeInt16(173,(g==null?void 0:g.mergedValue)??0),t.writeBoolean(174,g==null?void 0:g.autoFit),t.writeInt16(175,g==null?void 0:g.borderWidth),t.writeInt16(176,g==null?void 0:g.borderHeight),(g==null?void 0:g.overrideFlag)!=null&&(n?t.writeInt32(91,g.overrideFlag):t.writeInt16(177,g.overrideFlag)),t.writeInt16(178,g==null?void 0:g.virtualEdgeFlag),t.writeAngle(145,g==null?void 0:g.rotation),n&&t.writeInt16(92,g==null?void 0:g.extendedCellFlags),f===1)g!=null&&g.fieldObjetId?t.writeObjectId(344,g.fieldObjetId):this.writeCellText(t,(g==null?void 0:g.text)??"",n,g==null?void 0:g.cellValueBlockBegin);else if(f===2){if(t.writeObjectId(340,g==null?void 0:g.blockTableRecordId),t.writeDouble(144,g==null?void 0:g.blockScale),t.writeInt16(179,g==null?void 0:g.blockAttrNum),(o=g==null?void 0:g.attrDefineId)!=null&&o.length)for(const p of g.attrDefineId)t.writeObjectId(331,p);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const p of g.attrText)t.writeString(300,p);else t.writeString(300,g.attrText)}g!=null&&g.textStyle&&t.writeString(7,g.textStyle),(g==null?void 0:g.textHeight)!=null&&t.writeDouble(140,g.textHeight),(g==null?void 0:g.attachmentPoint)!=null&&t.writeInt16(170,g.attachmentPoint),(g==null?void 0:g.topBorderVisibility)!=null&&t.writeInt16(289,g.topBorderVisibility?1:0),(g==null?void 0:g.rightBorderVisibility)!=null&&t.writeInt16(285,g.rightBorderVisibility?1:0),(g==null?void 0:g.bottomBorderVisibility)!=null&&t.writeInt16(286,g.bottomBorderVisibility?1:0),(g==null?void 0:g.leftBorderVisibility)!=null&&t.writeInt16(288,g.leftBorderVisibility?1:0)}if(t.writeInt16(70,this.flowDirection),t.writeDouble(40,this.horizontalCellMargin),t.writeDouble(41,this.verticalCellMargin),this.suppressTitle!=null&&t.writeInt16(280,this.suppressTitle?1:0),this.suppressHeader!=null&&t.writeInt16(281,this.suppressHeader?1:0),(c=this.cellTypeOverrides)!=null&&c.length)for(const d of this.cellTypeOverrides){t.writeString(7,d.textStyle),t.writeDouble(140,d.textHeight),t.writeInt16(170,d.alignment),t.writeInt16(63,d.backgroundColor),t.writeInt16(64,d.contentColor),d.backgroundColorEnabled!=null&&t.writeInt16(283,d.backgroundColorEnabled?1:0);const g=d.borderLineweights;g&&(t.writeInt16(274,g.top),t.writeInt16(275,g.right),t.writeInt16(276,g.bottom),t.writeInt16(277,g.left),t.writeInt16(278,g.insideHorizontal),t.writeInt16(279,g.insideVertical));const f=d.borderVisibility;f&&(t.writeInt16(284,f.top?1:0),t.writeInt16(285,f.right?1:0),t.writeInt16(286,f.bottom?1:0),t.writeInt16(287,f.left?1:0),t.writeInt16(288,f.insideHorizontal?1:0),t.writeInt16(289,f.insideVertical?1:0))}if(this.tableBorderColors&&(t.writeInt16(63,this.tableBorderColors.left),t.writeInt16(64,this.tableBorderColors.top),t.writeInt16(65,this.tableBorderColors.insideHorizontal),t.writeInt16(66,this.tableBorderColors.bottom),t.writeInt16(68,this.tableBorderColors.insideVertical),t.writeInt16(69,this.tableBorderColors.right)),(l=this.rowDataTypes)!=null&&l.length)for(const d of this.rowDataTypes)t.writeInt16(97,d);if((h=this.rowUnitTypes)!=null&&h.length)for(const d of this.rowUnitTypes)t.writeInt16(98,d);if((u=this.rowFormats)!=null&&u.length)for(const d of this.rowFormats)t.writeString(4,d);return this}dxfInFields(t){var p,m,y;super.dxfInFields(t),t.atSubclassData("AcDbTable");let e=this._numRows,n=this._numColumns,r=!1;const s=[],a=[];let o=0,c=null,l=[],h=((p=this.horizontalDirection)==null?void 0:p.x)??1,u=((m=this.horizontalDirection)==null?void 0:m.y)??0,d=((y=this.horizontalDirection)==null?void 0:y.z)??0;const g=()=>{e>0&&n>0&&(!r||this._numRows!==e||this._numColumns!==n)&&(this.resizeGrid(e,n),r=!0)},f=()=>{c&&(l.length>0&&(c.text=l.join(""),l=[]),g(),o<this._cells.length&&this.setCell(o,c),o+=1,c=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),w=Number(b.value);switch(_){case 280:c||(this.tableDataVersion=w);break;case 342:this.tableStyleId=String(b.value);break;case 343:this.owningBlockRecordId=String(b.value);break;case 11:h=w;break;case 21:u=w;break;case 31:d=w;break;case 90:c||(this.tableValueFlag=w);break;case 93:c||(this.tableOverrideFlag=w);break;case 94:c||(this.borderColorOverrideFlag=w);break;case 95:c||(this.borderLineweightOverrideFlag=w);break;case 96:c||(this.borderVisibilityOverrideFlag=w);break;case 71:this.attachmentPoint=w;break;case 170:c?c.attachmentPoint=w:this.attachmentPoint=w;break;case 91:c?c&&(c.overrideFlag=w):(e=w,g());break;case 92:c?c&&(c.extendedCellFlags=w):(n=w,g());break;case 141:s.push(w);break;case 142:a.push(w);break;case 171:f(),c={text:"",attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,cellType:w,textHeight:0};break;case 172:c&&(c.flagValue=w);break;case 173:c&&(c.mergedValue=w);break;case 174:c&&(c.autoFit=!!b.value||w!==0);break;case 175:c&&(c.borderWidth=w);break;case 176:c&&(c.borderHeight=w);break;case 177:c&&(c.overrideFlag=w);break;case 178:c&&(c.virtualEdgeFlag=w);break;case 145:c&&(c.rotation=w*Math.PI/180);break;case 1:case 2:case 302:case 303:l.push(String(b.value));break;case 300:if(c){const k=c.attrText;Array.isArray(k)?k.push(String(b.value)):k!=null&&k!==""?c.attrText=[String(k),String(b.value)]:c.attrText=String(b.value)}break;case 301:c&&(c.cellValueBlockBegin=String(b.value));break;case 304:break;case 7:c&&(c.textStyle=String(b.value));break;case 140:c&&(c.textHeight=w);break;case 340:c&&(c.blockTableRecordId=String(b.value));break;case 344:case 345:c&&(c.fieldObjetId=String(b.value));break;case 144:case 146:c&&(c.blockScale=w);break;case 179:c&&(c.blockAttrNum=w);break;case 70:this.flowDirection=w;break;case 40:this.horizontalCellMargin=w;break;case 41:this.verticalCellMargin=w;break;case 281:this.suppressHeader=w!==0;break}}return f(),this.horizontalDirection=new A(h,u,d),s.forEach((b,_)=>this.setRowHeight(_,b)),a.forEach((b,_)=>this.setColumnWidth(_,b)),this}writeCellText(t,e,n,r){if(!n){if(e.length<=250){t.writeString(1,e);return}const o=Math.ceil(e.length/250);for(let c=0;c<o;c++){const l=c*250,h=l+250,u=e.slice(l,h);c===o-1?t.writeString(1,u):t.writeString(2,u)}return}if(t.writeString(301,r??"CELL_VALUE"),e.length<=250){t.writeString(302,e),t.writeString(304,"ACVALUE_END");return}const a=Math.ceil(e.length/250);for(let o=0;o<a;o++){const c=o*250,l=c+250,h=e.slice(c,l);o===a-1?t.writeString(302,h):t.writeString(303,h)}t.writeString(304,"ACVALUE_END")}};Kh.typeName="Table";let Na=Kh;const ri=new z,Md=new X,Zh=class Zh extends et{constructor(){super(),this._snapBase=new x,this._snapSpacing=new x(1,1,0),this._gridSpacing=new x(1,1,0),this._perspectiveLensLength=50,this._frontClipZ=0,this._backClipZ=0,this._snapAngle=0,this._status=0,this._ucsPerViewport=0,this._circleZoomPercent=1e3,this._statusBitFlags=0,this._ucsOrigin=new x,this._ucsXAxis=new A(1,0,0),this._ucsYAxis=new A(0,1,0),this._elevation=0,this._frozenLayerIds=[],this._sheetName="",this._iconFlag=0,this._orthographicType=0,this._majorGridFrequency=0,this._ambientLightColorIndex=0,this._brightness=0,this._contrast=0,this._shadePlotMode=0,this._renderMode=0,this._defaultLightingType=0,this._isDefaultLighting=!1,this._clippingBoundaryId="",this._backgroundId="",this._shadePlotId="",this._ucsId="",this._ucsBaseId="",this._visualStyleId="",this._sunId="",this._ambientLightColorInstance=0,this._ambientLightColorName="",this._softPointers=[],this._centerPoint=new x,this._height=0,this._width=0,this._viewCenter=new x,this._viewTarget=new x,this._viewDirection=new A(0,0,1),this._viewTwistAngle=0,this._viewHeight=0,this._number=-1}get dxfTypeName(){return"VIEWPORT"}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewTarget(){return this._viewTarget}set viewTarget(t){this._viewTarget=t}get viewDirection(){return this._viewDirection}set viewDirection(t){this._viewDirection.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapSpacing(){return this._snapSpacing}set snapSpacing(t){this._snapSpacing.copy(t)}get gridSpacing(){return this._gridSpacing}set gridSpacing(t){this._gridSpacing.copy(t)}get perspectiveLensLength(){return this._perspectiveLensLength}set perspectiveLensLength(t){this._perspectiveLensLength=t}get frontClipZ(){return this._frontClipZ}set frontClipZ(t){this._frontClipZ=t}get backClipZ(){return this._backClipZ}set backClipZ(t){this._backClipZ=t}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get status(){return this._status}set status(t){this._status=t}get ucsPerViewport(){return this._ucsPerViewport}set ucsPerViewport(t){this._ucsPerViewport=t}get circleZoomPercent(){return this._circleZoomPercent}set circleZoomPercent(t){this._circleZoomPercent=t}get statusBitFlags(){return this._statusBitFlags}set statusBitFlags(t){this._statusBitFlags=t}get ucsOrigin(){return this._ucsOrigin}set ucsOrigin(t){this._ucsOrigin.copy(t)}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get frozenLayerIds(){return this._frozenLayerIds}set frozenLayerIds(t){this._frozenLayerIds=[...t]}get ucsXAxis(){return this._ucsXAxis}set ucsXAxis(t){this._ucsXAxis.copy(t)}get ucsYAxis(){return this._ucsYAxis}set ucsYAxis(t){this._ucsYAxis.copy(t)}get sheetName(){return this._sheetName}set sheetName(t){this._sheetName=t}get iconFlag(){return this._iconFlag}set iconFlag(t){this._iconFlag=t}get orthographicType(){return this._orthographicType}set orthographicType(t){this._orthographicType=t}get majorGridFrequency(){return this._majorGridFrequency}set majorGridFrequency(t){this._majorGridFrequency=t}get ambientLightColorIndex(){return this._ambientLightColorIndex}set ambientLightColorIndex(t){this._ambientLightColorIndex=t}get viewportBrightness(){return this._brightness}set viewportBrightness(t){this._brightness=t}get viewportContrast(){return this._contrast}set viewportContrast(t){this._contrast=t}get shadePlotMode(){return this._shadePlotMode}set shadePlotMode(t){this._shadePlotMode=t}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode=t}get defaultLightingType(){return this._defaultLightingType}set defaultLightingType(t){this._defaultLightingType=t}get isDefaultLighting(){return this._isDefaultLighting}set isDefaultLighting(t){this._isDefaultLighting=t}get clippingBoundaryId(){return this._clippingBoundaryId}set clippingBoundaryId(t){this._clippingBoundaryId=t}get backgroundId(){return this._backgroundId}set backgroundId(t){this._backgroundId=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get ucsId(){return this._ucsId}set ucsId(t){this._ucsId=t}get ucsBaseId(){return this._ucsBaseId}set ucsBaseId(t){this._ucsBaseId=t}get visualStyleId(){return this._visualStyleId}set visualStyleId(t){this._visualStyleId=t}get sunId(){return this._sunId}set sunId(t){this._sunId=t}get ambientLightColorInstance(){return this._ambientLightColorInstance}set ambientLightColorInstance(t){this._ambientLightColorInstance=t}get ambientLightColorName(){return this._ambientLightColorName}set ambientLightColorName(t){this._ambientLightColorName=t}get softPointers(){return this._softPointers}set softPointers(t){this._softPointers=[...t]}get viewTwistAngle(){return this._viewTwistAngle}set viewTwistAngle(t){this._viewTwistAngle=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"viewport",properties:[{name:"number",type:"int",editable:!0,accessor:{get:()=>this.number,set:t=>{this.number=t}}},{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.centerPoint.x,set:t=>{this.centerPoint.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.centerPoint.y,set:t=>{this.centerPoint.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.centerPoint.z,set:t=>{this.centerPoint.z=t}}},{name:"width",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"height",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"viewCenterX",type:"float",editable:!0,accessor:{get:()=>this.viewCenter.x,set:t=>{this.viewCenter.x=t}}},{name:"viewCenterY",type:"float",editable:!0,accessor:{get:()=>this.viewCenter.y,set:t=>{this.viewCenter.y=t}}},{name:"viewCenterZ",type:"float",editable:!0,accessor:{get:()=>this.viewCenter.z,set:t=>{this.viewCenter.z=t}}},{name:"viewHeight",type:"float",editable:!0,accessor:{get:()=>this.viewHeight,set:t=>{this.viewHeight=t}}},{name:"viewTwistAngle",type:"float",editable:!0,accessor:{get:()=>this.viewTwistAngle,set:t=>{this.viewTwistAngle=t}}},{name:"viewTargetX",type:"float",editable:!0,accessor:{get:()=>this.viewTarget.x,set:t=>{this.viewTarget.x=t}}},{name:"viewTargetY",type:"float",editable:!0,accessor:{get:()=>this.viewTarget.y,set:t=>{this.viewTarget.y=t}}},{name:"viewTargetZ",type:"float",editable:!0,accessor:{get:()=>this.viewTarget.z,set:t=>{this.viewTarget.z=t}}},{name:"viewDirectionX",type:"float",editable:!0,accessor:{get:()=>this.viewDirection.x,set:t=>{this.viewDirection.x=t}}},{name:"viewDirectionY",type:"float",editable:!0,accessor:{get:()=>this.viewDirection.y,set:t=>{this.viewDirection.y=t}}},{name:"viewDirectionZ",type:"float",editable:!0,accessor:{get:()=>this.viewDirection.z,set:t=>{this.viewDirection.z=t}}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"snapAngle",type:"float",editable:!0,accessor:{get:()=>this.snapAngle,set:t=>{this.snapAngle=t}}},{name:"snapSpacingX",type:"float",editable:!0,accessor:{get:()=>this.snapSpacing.x,set:t=>{this.snapSpacing.x=t}}},{name:"snapSpacingY",type:"float",editable:!0,accessor:{get:()=>this.snapSpacing.y,set:t=>{this.snapSpacing.y=t}}},{name:"gridSpacingX",type:"float",editable:!0,accessor:{get:()=>this.gridSpacing.x,set:t=>{this.gridSpacing.x=t}}},{name:"gridSpacingY",type:"float",editable:!0,accessor:{get:()=>this.gridSpacing.y,set:t=>{this.gridSpacing.y=t}}},{name:"frontClipZ",type:"float",editable:!0,accessor:{get:()=>this.frontClipZ,set:t=>{this.frontClipZ=t}}},{name:"backClipZ",type:"float",editable:!0,accessor:{get:()=>this.backClipZ,set:t=>{this.backClipZ=t}}},{name:"renderMode",type:"int",editable:!0,accessor:{get:()=>this.renderMode,set:t=>{this.renderMode=t}}}]}]}}get geometricExtents(){const t=this._width/2,e=this._height/2,n=new H;return n.expandByPoint(new x(this._centerPoint.x-t,this._centerPoint.y-e,this._centerPoint.z)),n.expandByPoint(new x(this._centerPoint.x+t,this._centerPoint.y+e,this._centerPoint.z)),n}subGetIntersectCurves(){const t=this._width/2,e=this._height/2,n=this._centerPoint.z,r=[new x(this._centerPoint.x-t,this._centerPoint.y-e,n),new x(this._centerPoint.x+t,this._centerPoint.y-e,n),new x(this._centerPoint.x+t,this._centerPoint.y+e,n),new x(this._centerPoint.x-t,this._centerPoint.y+e,n)];return ee(r,!0)}subGetGripPoints(){const t=new Array,e=this._width/2,n=this._height/2,r=this._centerPoint.z;return t.push(this._centerPoint),(e>0||n>0)&&t.push(new x(this._centerPoint.x-e,this._centerPoint.y-n,r),new x(this._centerPoint.x+e,this._centerPoint.y-n,r),new x(this._centerPoint.x+e,this._centerPoint.y+n,r),new x(this._centerPoint.x-e,this._centerPoint.y+n,r)),t}subMoveGripPointsAt(t,e){return Et(t,n=>{this.moveGripAt(n,e)}),this}transformBy(t){const e=this._centerPoint.clone(),n=this._centerPoint.clone().add(new A(this._width,0,0)),r=this._centerPoint.clone().add(new A(0,this._height,0));e.applyMatrix4(t),n.applyMatrix4(t),r.applyMatrix4(t);const s=new A(n).sub(e),a=new A(r).sub(e),o=this._height!==0?a.length()/this._height:1;return this._centerPoint.copy(e),this._width=s.length(),this._height=a.length(),this._viewHeight*=o,this}subWorldDraw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){var s;const t=new _f;t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t.viewTarget=this.viewTarget,t.viewTwistAngle=this.viewTwistAngle,t.frozenLayerIds=this.frozenLayerIds;const e=[],n=(s=this.database)==null?void 0:s.tables.layerTable;if(n)for(const a of this.frozenLayerIds){const o=n.getIdAt(a);o&&e.push(o.name)}t.frozenLayers=e;const r=Xf(this);return r&&(t.annotationScaleName=r.scaleName,t.annotationScaleFactor=r.scaleFactor),t}createViewportRect(t,e){const n=[];return n.push(e.lines([new x(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new x(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),n.push(e.lines([new x(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new x(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new x(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new x(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),n.push(e.lines([new x(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new x(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),n}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewport"),t.writePoint3d(10,this.centerPoint),t.writeDouble(40,this.width),t.writeDouble(41,this.height),t.writePoint3d(12,this.viewCenter),t.writePoint3d(13,this.snapBase),t.writePoint3d(14,this.snapSpacing),t.writePoint3d(15,this.gridSpacing),t.writeVector3d(16,this.viewDirection),t.writePoint3d(17,this.viewTarget),t.writeDouble(42,this.perspectiveLensLength),t.writeDouble(43,this.frontClipZ),t.writeDouble(44,this.backClipZ),t.writeDouble(45,this.viewHeight),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.viewTwistAngle),t.writeInt16(68,this.status),t.writeInt32(69,this.number),t.writeInt16(71,this.ucsPerViewport),t.writeInt16(72,this.circleZoomPercent),t.writeInt32(90,this.statusBitFlags);for(const e of this.frozenLayerIds)t.writeObjectId(331,e);t.writePoint3d(110,this.ucsOrigin),t.writeVector3d(111,this.ucsXAxis),t.writeVector3d(112,this.ucsYAxis),t.writeDouble(146,this.elevation),this.sheetName&&t.writeString(1,this.sheetName),t.writeInt16(61,this.majorGridFrequency),t.writeInt16(63,this.ambientLightColorIndex),t.writeInt16(74,this.iconFlag),t.writeInt16(79,this.orthographicType);for(const e of this.softPointers)t.writeObjectId(91,e);return t.writeDouble(141,this.viewportBrightness),t.writeDouble(142,this.viewportContrast),t.writeInt16(170,this.shadePlotMode),t.writeInt16(281,this.renderMode),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLighting?1:0),this.clippingBoundaryId&&t.writeObjectId(340,this.clippingBoundaryId),this.backgroundId&&t.writeObjectId(332,this.backgroundId),this.shadePlotId&&t.writeObjectId(333,this.shadePlotId),this.ucsId&&t.writeObjectId(345,this.ucsId),this.ucsBaseId&&t.writeObjectId(346,this.ucsBaseId),this.visualStyleId&&t.writeObjectId(348,this.visualStyleId),this.sunId&&t.writeObjectId(361,this.sunId),this.ambientLightColorInstance&&t.writeInt32(421,this.ambientLightColorInstance),this.ambientLightColorName&&t.writeString(431,this.ambientLightColorName),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbViewport");let e=this.centerPoint.x,n=this.centerPoint.y,r=this.centerPoint.z,s=this.viewCenter.x,a=this.viewCenter.y,o=this.viewCenter.z,c=this.viewTarget.x,l=this.viewTarget.y,h=this.viewTarget.z,u=this.viewDirection.x,d=this.viewDirection.y,g=this.viewDirection.z,f=this.snapBase.x,p=this.snapBase.y,m=this.snapBase.z,y=this.snapSpacing.x,b=this.snapSpacing.y,_=this.snapSpacing.z,w=this.gridSpacing.x,k=this.gridSpacing.y,P=this.gridSpacing.z,v=this.ucsOrigin.x,S=this.ucsOrigin.y,I=this.ucsOrigin.z,M=this.ucsXAxis.x,O=this.ucsXAxis.y,N=this.ucsXAxis.z,nt=this.ucsYAxis.x,W=this.ucsYAxis.y,F=this.ucsYAxis.z;const q=[],L=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const $=t.readItem();if(!$)break;const ct=Number($.code),B=Number($.value);switch(ct){case 1:this.sheetName=String($.value);break;case 10:e=B;break;case 20:n=B;break;case 30:r=B;break;case 12:s=B;break;case 22:a=B;break;case 32:o=B;break;case 13:f=B;break;case 23:p=B;break;case 33:m=B;break;case 14:y=B;break;case 24:b=B;break;case 34:_=B;break;case 15:w=B;break;case 25:k=B;break;case 35:P=B;break;case 16:u=B;break;case 26:d=B;break;case 36:g=B;break;case 17:c=B;break;case 27:l=B;break;case 37:h=B;break;case 40:this.width=B;break;case 41:this.height=B;break;case 42:this.perspectiveLensLength=B;break;case 43:this.frontClipZ=B;break;case 44:this.backClipZ=B;break;case 45:this.viewHeight=B;break;case 50:this.snapAngle=D.degToRad(B);break;case 51:this.viewTwistAngle=D.degToRad(B);break;case 61:this.majorGridFrequency=B;break;case 63:this.ambientLightColorIndex=B;break;case 68:this.status=B;break;case 69:this.number=B;break;case 71:this.ucsPerViewport=B;break;case 72:this.circleZoomPercent=B;break;case 74:this.iconFlag=B;break;case 79:this.orthographicType=B;break;case 90:this.statusBitFlags=B;break;case 91:case 335:case 343:case 344:L.push(String($.value));break;case 110:v=B;break;case 120:S=B;break;case 130:I=B;break;case 111:M=B;break;case 121:O=B;break;case 131:N=B;break;case 112:nt=B;break;case 122:W=B;break;case 132:F=B;break;case 141:this.viewportBrightness=B;break;case 142:this.viewportContrast=B;break;case 146:this.elevation=B;break;case 170:this.shadePlotMode=B;break;case 281:this.renderMode=B;break;case 282:this.defaultLightingType=B;break;case 292:this.isDefaultLighting=B!==0;break;case 331:q.push(String($.value));break;case 332:this.backgroundId=String($.value);break;case 333:this.shadePlotId=String($.value);break;case 340:this.clippingBoundaryId=String($.value);break;case 345:this.ucsId=String($.value);break;case 346:this.ucsBaseId=String($.value);break;case 348:this.visualStyleId=String($.value);break;case 361:this.sunId=String($.value);break;case 421:this.ambientLightColorInstance=B;break;case 431:this.ambientLightColorName=String($.value);break}}return this.applyViewportDxfIn(e,n,r,s,a,o,c,l,h),this._viewDirection.copy({x:u,y:d,z:g}),this._snapBase.copy({x:f,y:p,z:m}),this._snapSpacing.copy({x:y,y:b,z:_}),this._gridSpacing.copy({x:w,y:k,z:P}),this._ucsOrigin.copy({x:v,y:S,z:I}),this._ucsXAxis.copy({x:M,y:O,z:N}),this._ucsYAxis.copy({x:nt,y:W,z:F}),this.frozenLayerIds=q,this.softPointers=L,this}applyViewportDxfIn(t,e,n,r,s,a,o,c,l){this.centerPoint.copy({x:t,y:e,z:n}),this.viewCenter.copy({x:r,y:s,z:a}),this.viewTarget.copy({x:o,y:c,z:l});const h=1e-6,u=Math.abs(t)<h&&Math.abs(e)<h,d=Math.abs(o)<h&&Math.abs(c)<h,g=Number.isFinite(this.height)&&Number.isFinite(this.viewHeight)&&Math.abs(this.viewHeight-this.height)<h;u&&d&&g&&this.centerPoint.copy(this.viewCenter)}moveGripAt(t,e){switch(t){case 0:this._centerPoint.add(e);break;case 1:case 2:case 3:case 4:{const n=this.width/2,r=this.height/2,s=this._centerPoint.x,a=this._centerPoint.y,o={1:{x:s-n,y:a-r},2:{x:s+n,y:a-r},3:{x:s+n,y:a+r},4:{x:s-n,y:a+r}},c=t===1?3:t===2?4:t===3?1:2,l=o[t],h=o[c];l.x+=e.x,l.y+=e.y,this._centerPoint.x=(l.x+h.x)/2,this._centerPoint.y=(l.y+h.y)/2,this._centerPoint.z=(this._centerPoint.z??0)+(e.z??0),this.width=Math.abs(h.x-l.x),this.height=Math.abs(h.y-l.y);break}}}};Zh.typeName="Viewport";let Ra=Zh;const Qh=class Qh extends Jr{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=t.subEntityTraits;e.isBackgroundFill=!0,e.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const n=this.boundaryPath(),r=new de;return r.add(new ot(n)),t.area(r)}dxfOutFields(t){return super.dxfOutFields(t),this}};Qh.typeName="Wipeout";let Ba=Qh;const co=class co extends Ot{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new x,this._unitDir=new A}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get area(){return 0}get geometricExtents(){const t=new H;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetIntersectCurves(){const t=this._basePoint.clone().add(this._unitDir);return[{kind:"line",line:new Bt(this._basePoint,t),extent:"unbounded"}]}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subMoveGripPointsAt(t,e){return he(t,e,this.basePoint),this}subGetOsnapPoints(t,e,n,r){const s=this.basePoint;if(t===T.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new Bt(s,s.clone().add(a));switch(t){case T.Nearest:r.push(o.project(e));break;case T.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbXline");let e=this.basePoint.x,n=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:n=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new x(e,n,r),this.unitDir=new A(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,n=this.unitDir,r=Math.hypot(n.x,n.y);return r<=1e-9||(n.x*(t.y-e.y)-n.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Xg(this.basePoint,this.unitDir,t);if(!e)return null;const n=new co;return n.basePoint=e,n.unitDir=this.unitDir.clone(),n}};co.typeName="Xline";let Fa=co;var Rm=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(Rm||{});const si=48,Cd=8,gA=48,Bm=80,Fm=32,pc=80,mc=24,sl=40,fA=8,pA=4,Od=64,mA=64,yA=new Set(["_version","_angbase","_angdir","_aunits","_auprec","_lunits","_luprec","_celtscale","_cecolor","_celtype","_celweight","_cetransparency","_clayer","_cmlstyle","_cmlscale","_cmleaderstyle","_hpbackgroundcolor","_hpcolor","_hplayer","_hptransparency","_textstyle","_dimstyle","_dimstyle","_dimstyle","_extents","_insunits","_unitmode","_measurement","_ltscale","_lwdisplay","_pdmode","_pdsize","_osmode","_orthomode","_maxHandle","_drawNoPlotLayers","_drawCircleSides","_dwgname","_currentSpace","_formatter","_eventBatchDepth","_pendingEntityAppended","_pendingEntityErased","_pendingDictObjectSet","_pendingDictObjectErased","_lastOpenError"]),zm=new Set(["constructor","prototype","__proto__","caller","callee","arguments"]);function Ie(i,t){let e=i.get(t);return e||(e={bytes:0,count:0},i.set(t,e)),e}function se(i,t,e,n=0){if(e<=0&&n===0)return;const r=Ie(i.byCategory,t);r.bytes+=e,r.count+=n}function bA(i){const t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function _A(i){return ArrayBuffer.isView(i)}function xA(i){return typeof i.addEventListener=="function"&&typeof i.dispatch=="function"&&"listeners"in i}function wA(i,t,e){return zm.has(t)?!0:!i.includeEventManagers&&(t==="events"||e==="events")?t==="events":!i.includeTransactionManager&&(t==="transactionManager"||e==="transaction")?t==="transactionManager":!1}function Dd(i,t,e){return t==="_xDataMap"||t==="_importedXData"||i==="xdata"?"xdata":t==="_tables"||i==="tables"?e instanceof et?"entities":"tables":t==="_entities"||i==="entities"?"entities":t==="_objects"||i==="objects"?"objects":t==="_handleRegistry"||i==="handleRegistry"?"handleRegistry":t==="transactionManager"||i==="transaction"?"transaction":t==="events"||i==="events"?"events":i==="sysvars"||yA.has(t)?"sysvars":e instanceof et?"entities":i==="other"?"other":i}function vA(i){const t=new Set;let e=i;for(;e&&e!==Object.prototype;){for(const n of Object.getOwnPropertyNames(e)){if(zm.has(n))continue;const r=Object.getOwnPropertyDescriptor(e,n);r&&typeof r.value=="function"||r&&(r.get||r.set)&&r.value===void 0||t.add(n)}if(e=Object.getPrototypeOf(e),e===Object.prototype||e===null||e===Array.prototype||e===Map.prototype||e===Set.prototype)break}return[...t]}function Xm(i){if(i==null)return 0;switch(typeof i){case"number":return fA;case"boolean":return pA;case"string":return sl+i.length*2;case"bigint":return 16;case"symbol":return sl+String(i.description??"").length*2;default:return 0}}function AA(i,t){if(i.visited.has(t))return 0;i.visited.add(t),i.objectCount+=1;let e=Bm+t.size*Fm;for(const n of t.keys())e+=Xm(n);return se(i,"handleRegistry",e,1),e}function li(i,t,e,n){if(t==null)return 0;const r=typeof t;if(r==="function")return 0;if(r!=="object"){const h=Xm(t);if(se(i,e,h),n){const u=Ie(i.byEntityType,n);u.bytes+=h}return h}const s=t;if(typeof s.nodeType=="number"||i.visited.has(s))return 0;if(i.visited.add(s),i.objectCount+=1,!i.includeEventManagers&&xA(s))return se(i,e,si,1),si;let a=n,o=e;if(s instanceof et){o="entities",a=s.type,i.entityCount+=1;const h=Ie(i.byEntityType,a);h.count+=1}if(typeof s.then=="function")return se(i,o,si,1),si;if(s instanceof ArrayBuffer){const h=Od+s.byteLength;return se(i,o,h,1),a&&(Ie(i.byEntityType,a).bytes+=h),h}if(_A(s)){const h=Od+s.byteLength;return s.buffer&&!i.visited.has(s.buffer)&&i.visited.add(s.buffer),se(i,o,h,1),a&&(Ie(i.byEntityType,a).bytes+=h),h}if(typeof Blob<"u"&&s instanceof Blob){const h=mA+s.size;return se(i,o,h,1),a&&(Ie(i.byEntityType,a).bytes+=h),h}if(s instanceof Date){const h=si+8;return se(i,o,h,1),h}if(s instanceof Map){const h=o==="handleRegistry",u=Bm+s.size*Fm;let d=u;se(i,o,u,1),a&&(Ie(i.byEntityType,a).bytes+=u);for(const[g,f]of s)d+=li(i,g,o,a),h||(d+=li(i,f,o,a));return d}if(s instanceof Set){let h=pc+s.size*mc;for(const u of s)h+=li(i,u,o,a);return se(i,o,pc+s.size*mc,1),a&&(Ie(i.byEntityType,a).bytes+=pc+s.size*mc),h}if(Array.isArray(s)){let h=gA+s.length*Cd;se(i,o,h,1),a&&(Ie(i.byEntityType,a).bytes+=h);for(let u=0;u<s.length;u++){const d=s[u],g=Dd(o,String(u),d);h+=li(i,d,g,a)}return h}let c=si;const l=bA(s)?Object.getOwnPropertyNames(s):vA(s);for(const h of l)c+=Cd,c+=Math.min(sl+h.length*2,64);se(i,o,c,1),a&&(Ie(i.byEntityType,a).bytes+=c);for(const h of l){if(wA(i,h,o)||h==="_database"||h==="database")continue;let u;try{u=s[h]}catch{continue}if(typeof u=="function")continue;if(h==="_handleRegistry"&&u instanceof Map){c+=AA(i,u);continue}const d=Dd(o,h,u);!i.includeTransactionManager&&d==="transaction"||!i.includeEventManagers&&d==="events"||(c+=li(i,u,d,a))}return c}function SA(i,t){const e={visited:new WeakSet,objectCount:0,entityCount:0,byCategory:new Map,byEntityType:new Map,includeTransactionManager:(t==null?void 0:t.includeTransactionManager)===!0,includeEventManagers:(t==null?void 0:t.includeEventManagers)===!0};li(e,i,"sysvars",null);let n=0;const r={};for(const[a,o]of e.byCategory)r[a]={bytes:o.bytes,count:o.count},n+=o.bytes;const s={};for(const[a,o]of e.byEntityType)s[a]={bytes:o.bytes,count:o.count};return{totalBytes:n,objectCount:e.objectCount,entityCount:e.entityCount,byCategory:r,byEntityType:s}}function yc(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(2)} KiB`:`${(i/(1024*1024)).toFixed(2)} MiB`}function PA(i){const t=[`AcDbDatabase memory estimate: ${yc(i.totalBytes)} (${i.totalBytes} bytes)`,`Objects: ${i.objectCount}, Entities: ${i.entityCount}`,"By category:"],e=Object.entries(i.byCategory).sort((r,s)=>s[1].bytes-r[1].bytes);for(const[r,s]of e)t.push(` ${r}: ${yc(s.bytes)} (${s.bytes} bytes), count=${s.count}`);const n=Object.entries(i.byEntityType).sort((r,s)=>s[1].bytes-r[1].bytes);if(n.length>0){t.push("By entity type:");for(const[r,s]of n)t.push(` ${r}: ${yc(s.bytes)} (${s.bytes} bytes), count=${s.count}`)}return t.join(`
|
|
15
15
|
`)}function kA(i,t,e){const n=r=>r.toString(16).padStart(2,"0");return`#${n(i&255)}${n(t&255)}${n(e&255)}`}function ze(i,t){const e=i.getUint8(t),n=i.getUint8(t+1),r=i.getUint8(t+2);return kA(e,n,r)}function oe(i){const t=(i>>>24&255)/255,e=i>>>16&255,n=i>>>8&255,r=i&255;return`rgba(${e},${n},${r},${t.toFixed(3)})`}function Ym(i,t,e){const n=Math.min(1,Math.max(0,e)),r=(u,d)=>Math.round(u+(d-u)*n),s=i>>>24&255,a=t>>>24&255,o=r(i>>>16&255,t>>>16&255),c=r(i>>>8&255,t>>>8&255),l=r(i&255,t&255),h=r(s,a)/255;return`rgba(${o},${c},${l},${h.toFixed(3)})`}function IA(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(t)return`#${(16777215^parseInt(t[1],16)).toString(16).padStart(6,"0")}`;const e=/^#([0-9a-f]{3})$/i.exec(i);if(e){const[r,s,a]=e[1].split("").map(c=>parseInt(c+c,16)),o=c=>(255-c).toString(16).padStart(2,"0");return`#${o(r)}${o(s)}${o(a)}`}const n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(i);if(n){const r=255-Math.min(255,parseInt(n[1],10)),s=255-Math.min(255,parseInt(n[2],10)),a=255-Math.min(255,parseInt(n[3],10));return n[4]!==void 0?`rgba(${r},${s},${a},${n[4]})`:`rgb(${r},${s},${a})`}return i}var jm=1,Vm=2,Um=3,EA=4,al=5,Hm=6,TA=7,LA=8,MA=9,CA=10,OA=11,DA=12,NA=13,RA=14,BA=15,FA=17,zA=18,XA=19,YA=20,jA=21,VA=1,UA=2,HA=3,GA=4,WA=5,$A=6,qA=7,KA=8,ZA=9,QA=10,JA=11,t2=12,e2=14,n2=15,i2=16,ol=8192,Gm=2e5,Wm=5e5,Nd=22,r2=24,s2=25,a2=26,o2=27,c2=28,l2=29,h2=30,u2=31,d2=32,g2=33,f2=34,p2=35,m2=36,y2=37,b2=38,_2=39,x2=40,w2=42,v2=43,A2=44,S2=45,cl=46,Hs=47,P2=54,$m=55,k2=58,I2=59,E2=60,T2=61,L2=62,M2=63,C2=64,O2=67,D2=70,N2=75,R2=76,B2=81,F2=82,z2=84,qm=85,Km=86,X2=87,ll=88,Zm=89,Y2=91,j2=95,V2=98,U2=115,Rd=2147483648,H2=726027589,G2=1128875079,W2=16385,$2=16386,q2=16388,K2=16392,Z2=16394,Q2=16395,J2=16396,tS=16397,eS=16398,nS=16399,bc=16400,iS=16401,rS=16402,sS=16404,aS=16405,oS=16410,cS=16411,lS=16412,hS=16414,uS=16415,dS=16417,gS=16418,fS=16420,pS=16421,mS=16422,yS=16424,bS=16425,_S=16426,xS=16427,wS=16428,vS=16429,AS=16430,SS=16431,PS=16432,kS=16433,IS=16434,ES=16435,TS=16436,LS=16438,MS=16437,CS=1,OS=2,DS=3,NS=4,RS=5,BS=6,FS=7,zS=8,XS=0,YS=1,jS=3,VS=4,US=0,HS=513,GS=258,WS=260,$S=262,qS=521,KS=302,ZS=523,QS=524,JS=532,tP=531,eP=1051,nP=1564,iP=1048,rP=2071,Ns=2074,_c=2096,sP=804,aP=805,oP=301,cP=496,lP=762,hP=764,uP=763,dP=1313,gP=2610,fP=30,pP=295,mP=1336,V=(...i)=>{},je=(...i)=>{},vh=1;function Qm(i,t,e,n,r=vh,s=ol){const a=Math.max(1,Math.min(r,4));let o=Math.round(i*a),c=Math.round(t*a),l=a,h=a;if(e&&o>e){const f=e/o;o=e,c=Math.round(c*f),l*=f,h*=f}if(n&&c>n){const f=n/c;o=Math.round(o*f),c=n,l*=f,h*=f}const u=Math.max(1,Math.floor(s)),d=Math.max(1,Math.min(o,u)),g=Math.max(1,Math.min(c,u));o=d,c=g;try{if(typeof OffscreenCanvas<"u"){V(`createCanvas: using OffscreenCanvas ${o}×${c}, scale=(${l.toFixed(3)},${h.toFixed(3)})`);const m=new OffscreenCanvas(o,c),y=m.getContext("2d");return y?{canvas:m,ctx:y,scaleX:l,scaleY:h}:(je('createCanvas: OffscreenCanvas.getContext("2d") returned null'),null)}if(typeof document>"u")return je("createCanvas: no OffscreenCanvas and no document — cannot create canvas"),null;V(`createCanvas: using HTMLCanvasElement ${o}×${c}, scale=(${l.toFixed(3)},${h.toFixed(3)})`);const f=document.createElement("canvas");f.width=o,f.height=c;const p=f.getContext("2d");return p?{canvas:f,ctx:p,scaleX:l,scaleY:h}:(je('createCanvas: HTMLCanvasElement.getContext("2d") returned null'),null)}catch{return null}}function Jm(i,t){if(i<=0||t<=0)return null;if(i=Math.max(1,Math.min(Math.floor(i),ol)),t=Math.max(1,Math.min(Math.floor(t),ol)),typeof OffscreenCanvas<"u"){const e=new OffscreenCanvas(i,t),n=e.getContext("2d");return n?{canvas:e,ctx:n}:null}if(typeof document<"u"){const e=document.createElement("canvas");e.width=i,e.height=t;const n=e.getContext("2d");return n?{canvas:e,ctx:n}:null}return null}function t0(i){switch(i){case VA:return{gco:"source-over",colorTransform:"black",exact:!0};case i2:return{gco:"source-over",colorTransform:"white",exact:!0};case JA:return{gco:"source-over",colorTransform:"skip",exact:!0};case GA:return{gco:"source-over",colorTransform:"invert",exact:!0};case $A:return{gco:"difference",colorTransform:"white",exact:!0};case qA:case WA:return{gco:"difference",colorTransform:"none",exact:!1};case QA:return{gco:"difference",colorTransform:"invert",exact:!1};case ZA:return{gco:"darken",colorTransform:"none",exact:!1};case HA:case UA:return{gco:"darken",colorTransform:"invert",exact:!1};case n2:case e2:return{gco:"lighten",colorTransform:"none",exact:!1};case t2:case KA:return{gco:"lighten",colorTransform:"invert",exact:!1};default:return{gco:"source-over",colorTransform:"none",exact:!0}}}function e0(i,t){switch(t){case"invert":return IA(i);case"black":return"#000000";case"white":return"#ffffff";case"skip":return"rgba(0,0,0,0)";default:return i}}function At(i,t){const e=t0(t.rop2);if(i.globalCompositeOperation=e.gco,t.penStyle===5){i.strokeStyle="rgba(0,0,0,0)",i.lineWidth=0;return}switch(i.strokeStyle=e0(t.penColor,e.colorTransform),i.lineWidth=Math.max(t.penWidth,1),t.penStyle){case 1:i.setLineDash([8,4]);break;case 2:i.setLineDash([2,2]);break;case 3:i.setLineDash([8,4,2,4]);break;case 4:i.setLineDash([8,4,2,4,2,4]);break;default:i.setLineDash([]);break}}function Rt(i,t){const e=t0(t.rop2);if(i.globalCompositeOperation=e.gco,t.brushStyle===1){i.fillStyle="rgba(0,0,0,0)";return}i.fillStyle=e0(t.brushColor,e.colorTransform)}function yP(i){if(!i||i===400)return"";const t=Math.round(i/100)*100;return t===700?"bold":t>=100&&t<=900?String(t):i>=700?"bold":""}function hl(i,t){const e=(t==null?void 0:t[i.toLowerCase().trim()])??i;return/[\s,]/.test(e)&&!/^["']/.test(e)?`"${e}"`:e}function Ah(i,t=1){return Math.max(Math.abs(i.fontHeight)*Math.abs(t||1),8)}function ul(i,t,e=1){const n=t.fontItalic?"italic ":"",r=yP(t.fontWeight),s=r?`${r} `:"",a=Ah(t,e),o=hl(t.fontFamily,t.fontFamilyMap);i.font=`${n}${s}${a}px ${o}`}function bP(i,t,e,n,r,s=1){if(!t.fontUnderline&&!t.fontStrikeOut)return;const a=Ah(t,s),o=Math.max(1,Math.round(a/14)),c=i.fillStyle;i.fillStyle=t.textColor,t.fontUnderline&&i.fillRect(e,n+Math.round(a*.12),r,o),t.fontStrikeOut&&i.fillRect(e,n-Math.round(a*.3),r,o),i.fillStyle=c}function ns(i,t,e){if(e<=0)return"";const n=i.byteLength-t;if(n<=0)return"";const r=Math.min(e,Math.floor(n/2));if(r<=0)return"";let s;try{const o=new Uint8Array(i.buffer,i.byteOffset+t,r*2);s=new TextDecoder("utf-16le").decode(o)}catch{const o=[];for(let c=0;c<r;c++){const l=i.getUint16(t+c*2,!0);if(l===0)return o.join("");o.push(String.fromCharCode(l))}return o.join("")}const a=s.indexOf("\0");return a===-1?s:s.slice(0,a)}function _P(i){switch(i){case 0:return{kind:"brush",style:0,color:"#ffffff"};case 1:return{kind:"brush",style:0,color:"#c0c0c0"};case 2:return{kind:"brush",style:0,color:"#808080"};case 3:return{kind:"brush",style:0,color:"#404040"};case 4:return{kind:"brush",style:0,color:"#000000"};case 5:return{kind:"brush",style:1,color:"#000000"};case 6:return{kind:"pen",style:0,widthX:1,color:"#ffffff"};case 7:return{kind:"pen",style:0,widthX:1,color:"#000000"};case 8:return{kind:"pen",style:5,widthX:0,color:"#000000"};case 10:case 11:return{kind:"font",height:12,weight:400,italic:!1,underline:!1,strikeOut:!1,family:"monospace"};case 12:case 13:case 14:case 17:return{kind:"font",height:12,weight:400,italic:!1,underline:!1,strikeOut:!1,family:"sans-serif"};default:return null}}async function xP(i){const t=new Uint8Array(await i.arrayBuffer());let e="";const n=32768;for(let s=0;s<t.length;s+=n)e+=String.fromCharCode(...t.subarray(s,s+n));return`data:${i.type||"application/octet-stream"};base64,${btoa(e)}`}async function n0(i){if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas){V(`exportCanvasToPngDataUrl: using OffscreenCanvas.convertToBlob (${i.width}×${i.height})`);const t=await i.convertToBlob({type:"image/png"});return V(`exportCanvasToPngDataUrl: blob size=${t.size} bytes, type=${t.type}`),xP(t)}return typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement?(V(`exportCanvasToPngDataUrl: using HTMLCanvasElement.toDataURL (${i.width}×${i.height})`),i.toDataURL("image/png")):null}function wP(i){if(V("parseEmfHeader: byteLength =",i.byteLength),i.byteLength<88||i.getUint32(0,!0)!==jm)return null;const e=i.getInt32(8,!0),n=i.getInt32(12,!0),r=i.getInt32(16,!0),s=i.getInt32(20,!0),a=i.getInt32(24,!0),o=i.getInt32(28,!0),c=i.getInt32(32,!0),l=i.getInt32(36,!0),h=c-a,u=l-o;return{bounds:{left:e,top:n,right:r,bottom:s},frameW:h,frameH:u}}function vP(i){const t=i.bounds.right-i.bounds.left,e=i.bounds.bottom-i.bounds.top;return t>0&&e>0?i.bounds:i.frameW>0&&i.frameH>0?(V(`getRenderableEmfBounds: bounds invalid (${t}×${e}), falling back to frame ${i.frameW}×${i.frameH}`),{left:0,top:0,right:i.frameW,bottom:i.frameH}):null}function AP(i){if(i.byteLength<22)return null;const t=i.getUint32(0,!0);let e=0,n=0,r=0,s=800,a=600,o=96;if(t===2596720087&&(n=i.getInt16(6,!0),r=i.getInt16(8,!0),s=i.getInt16(10,!0),a=i.getInt16(12,!0),o=i.getUint16(14,!0)||96,e=22),e+18>i.byteLength)return null;const c=i.getUint16(e,!0);if(c!==1&&c!==2)return null;const l=i.getUint16(e+2,!0)*2,h=i.getUint32(e+8,!0)*2;return{headerSize:e+l,maxRecordSize:h,boundsLeft:n,boundsTop:r,boundsRight:s,boundsBottom:a,unitsPerInch:o}}function rt(i,t){const e=i.state.worldTransform,n=e[0]*t+e[4];return i.useMappingMode?(n-i.windowOrg.x)/(i.windowExt.cx||1)*(i.viewportExt.cx||1)+i.viewportOrg.x:(n-i.bounds.left)*i.sx}function st(i,t){const e=i.state.worldTransform,n=e[3]*t+e[5];return i.useMappingMode?(n-i.windowOrg.y)/(i.windowExt.cy||1)*(i.viewportExt.cy||1)+i.viewportOrg.y:(n-i.bounds.top)*i.sy}function ue(i,t){const e=i.state.worldTransform[0]*t;return i.useMappingMode?e/(i.windowExt.cx||1)*(i.viewportExt.cx||1):e*i.sx}function te(i,t){const e=i.state.worldTransform[3]*t;return i.useMappingMode?e/(i.windowExt.cy||1)*(i.viewportExt.cy||1):e*i.sy}function Cn(i){i.useMappingMode=!0}function SP(i,t,e){const{ctx:n,view:r}=i;if(e>=20){const s=r.getInt32(t,!0),a=r.getInt32(t+4,!0),o=ze(r,t+8);n.fillStyle=o,n.fillRect(rt(i,s),st(i,a),1,1)}return!0}function PP(i,t,e){const{ctx:n,view:r,state:s,inPath:a}=i;return e>=16&&(s.curX=r.getInt32(t,!0),s.curY=r.getInt32(t+4,!0),a&&n.moveTo(rt(i,s.curX),st(i,s.curY))),!0}function kP(i,t,e){const{ctx:n,view:r,state:s,inPath:a}=i;if(e>=16){const o=r.getInt32(t,!0),c=r.getInt32(t+4,!0);a?n.lineTo(rt(i,o),st(i,c)):(At(n,s),n.beginPath(),n.moveTo(rt(i,s.curX),st(i,s.curY)),n.lineTo(rt(i,o),st(i,c)),n.stroke()),s.curX=o,s.curY=c}return!0}function IP(i,t,e){const{ctx:n,view:r,state:s,inPath:a}=i;if(e>=24){const o=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0);a?n.rect(rt(i,o),st(i,c),ue(i,l-o),te(i,h-c)):(Rt(n,s),n.fillRect(rt(i,o),st(i,c),ue(i,l-o),te(i,h-c)),At(n,s),n.strokeRect(rt(i,o),st(i,c),ue(i,l-o),te(i,h-c)))}return!0}function EP(i,t,e){const{ctx:n,view:r,state:s,inPath:a}=i;if(e>=32){const o=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0),u=Math.abs(ue(i,r.getInt32(t+16,!0)))/2,d=Math.abs(te(i,r.getInt32(t+20,!0)))/2,g=rt(i,o),f=st(i,c),p=ue(i,l-o),m=te(i,h-c),y=()=>{const b=Math.min(u,d,p/2,m/2);n.moveTo(g+b,f),n.lineTo(g+p-b,f),n.arcTo(g+p,f,g+p,f+b,b),n.lineTo(g+p,f+m-b),n.arcTo(g+p,f+m,g+p-b,f+m,b),n.lineTo(g+b,f+m),n.arcTo(g,f+m,g,f+m-b,b),n.lineTo(g,f+b),n.arcTo(g,f,g+b,f,b),n.closePath()};a?y():(n.beginPath(),y(),Rt(n,s),n.fill(),At(n,s),n.stroke())}return!0}function TP(i,t,e){const{ctx:n,view:r,state:s,inPath:a}=i;if(e>=24){const o=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0),u=rt(i,(o+l)/2),d=st(i,(c+h)/2),g=Math.abs(ue(i,l-o))/2,f=Math.abs(te(i,h-c))/2;a?n.ellipse(u,d,g,f,0,0,Math.PI*2):(n.beginPath(),n.ellipse(u,d,g,f,0,0,Math.PI*2),Rt(n,s),n.fill(),At(n,s),n.stroke())}return!0}function LP(i,t,e,n){const{ctx:r,view:s,state:a,inPath:o}=i;if(n>=40){const c=s.getInt32(e,!0),l=s.getInt32(e+4,!0),h=s.getInt32(e+8,!0),u=s.getInt32(e+12,!0),d=s.getInt32(e+16,!0),g=s.getInt32(e+20,!0),f=s.getInt32(e+24,!0),p=s.getInt32(e+28,!0),m=(c+h)/2,y=(l+u)/2,b=Math.abs(h-c)/2,_=Math.abs(u-l)/2,w=Math.atan2((g-y)/(_||1),(d-m)/(b||1)),k=Math.atan2((p-y)/(_||1),(f-m)/(b||1)),P=rt(i,m),v=st(i,y),S=Math.abs(ue(i,b)),I=Math.abs(te(i,_)),M=t===$m,O=t===Hs||t===cl;o||r.beginPath(),t===Hs&&r.moveTo(P,v),M&&r.lineTo(P+S*Math.cos(w),v+I*Math.sin(w)),r.ellipse(P,v,S,I,0,w,k,!1),(t===Hs||t===cl)&&r.closePath(),o||(O&&(Rt(r,a),r.fill()),At(r,a),r.stroke()),M&&(a.curX=f,a.curY=p)}return!0}function MP(i,t,e,n){switch(t){case BA:return SP(i,e,n);case o2:return PP(i,e,n);case P2:return kP(i,e,n);case v2:return IP(i,e,n);case A2:return EP(i,e,n);case w2:return TP(i,e,n);case S2:case $m:case cl:case Hs:return LP(i,t,e,n);default:return!1}}var Rs=1<<24;function CP(i,t,e,n){return{cmds:[{op:"rect",x:i,y:t,w:e,h:n}],fillRule:"nonzero",simple:!0}}function OP(i){return{cmds:i.map(t=>({op:"rect",x:t.x,y:t.y,w:t.w,h:t.h})),fillRule:"nonzero",simple:!0}}function Ti(){return{cmds:[{op:"rect",x:0,y:0,w:0,h:0}],fillRule:"nonzero",simple:!0}}function DP(i,t,e){return{...i,cmds:i.cmds.map(n=>{switch(n.op){case"rect":return{...n,x:n.x+t,y:n.y+e};case"moveTo":case"lineTo":return{...n,x:n.x+t,y:n.y+e};case"bezierCurveTo":return{...n,cp1x:n.cp1x+t,cp1y:n.cp1y+e,cp2x:n.cp2x+t,cp2y:n.cp2y+e,x:n.x+t,y:n.y+e};case"closePath":return n}})}}function i0(i,t,e){return i?i.map(n=>DP(n,t,e)):null}function hn(i){return i.simple&&i.fillRule==="nonzero"}function Bs(i){return{cmds:[{op:"rect",x:-Rs,y:-Rs,w:2*Rs,h:2*Rs},...i.cmds],fillRule:"evenodd",simple:!1}}function Tr(i,t,e){switch(e){case"replace":return{region:[t],exact:!0};case"intersect":return{region:i?[...i,t]:[t],exact:!0};case"exclude":{if(!hn(t))return{region:i?[...i,t]:[t],exact:!1};const n=Bs(t);return{region:i?[...i,n]:[n],exact:!0}}case"union":return i?i.length===1&&hn(i[0])&&hn(t)?{region:[{cmds:[...i[0].cmds,...t.cmds],fillRule:"nonzero",simple:!1}],exact:!1}:{region:i,exact:!1}:{region:null,exact:!0};case"xor":return i?i.length===1&&hn(i[0])&&hn(t)?{region:[{cmds:[...i[0].cmds,...t.cmds],fillRule:"evenodd",simple:!1}],exact:!0}:hn(t)?{region:[...i,Bs(t)],exact:!1}:{region:[...i,t],exact:!1}:hn(t)?{region:[Bs(t)],exact:!0}:{region:[t],exact:!1};case"complement":return i?i.length===1&&hn(i[0])?{region:[t,Bs(i[0])],exact:!0}:{region:[t],exact:!1}:{region:[Ti()],exact:!0}}}function r0(i,t,e){if(e==="replace")return{region:t,exact:!0};if(t&&t.length===1)return Tr(i,t[0],e);if(!t)switch(e){case"intersect":return{region:i,exact:!0};case"union":return{region:null,exact:!0};case"exclude":return{region:[Ti()],exact:!0};case"xor":case"complement":return i?i.length===1?Tr(null,i[0],"exclude"):{region:i,exact:!1}:{region:[Ti()],exact:!0}}switch(e){case"intersect":return{region:i?[...i,...t]:t,exact:!0};case"union":return{region:i,exact:!1};case"xor":return{region:i??t,exact:!1};case"exclude":return{region:i,exact:!1};case"complement":return i?i.length===1?Tr(t,i[0],"exclude"):{region:t,exact:!1}:{region:[Ti()],exact:!0}}}function NP(i,t){for(const e of t)switch(e.op){case"rect":i.rect(e.x,e.y,e.w,e.h);break;case"moveTo":i.moveTo(e.x,e.y);break;case"lineTo":i.lineTo(e.x,e.y);break;case"bezierCurveTo":i.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y);break;case"closePath":i.closePath();break}}function dl(i,t){for(const e of t){i.beginPath(),NP(i,e.cmds);try{i.clip(e.fillRule)}catch{}}}function qi(i,t,e=!1){const{ctx:n}=i;for(;i.clipSaveDepth>0;)n.restore(),i.clipSaveDepth--;t&&(n.save(),i.clipSaveDepth=1,e&&n.setTransform(1,0,0,1,0,0),dl(n,t))}function s0(i,t,e){const n=globalThis.ImageData;return typeof n=="function"?new n(i,t,e):{data:i,width:t,height:e,colorSpace:"srgb"}}function RP(i,t,e,n,r,s,a,o,c,l){let h=0,u=r-1,d=t;const g=t+e;for(;d+1<g&&u>=0;){const f=i.getUint8(d),p=i.getUint8(d+1);if(d+=2,f===0)if(p===0)h=0,u--;else{if(p===1)break;if(p===2){if(d+1>=g)break;h+=i.getUint8(d),u-=i.getUint8(d+1),d+=2}else{const m=p;if(a){const y=Math.ceil(m/2);let b=0;for(let _=0;_<y&&d<g;_++){const w=i.getUint8(d++);for(let k=0;k<2&&b<m;k++){const P=k===0?w>>4&15:w&15;P<o.length&&h<n&&l(h,r-1-u,o[P][0],o[P][1],o[P][2],255),h++,b++}}y&1&&d++}else{for(let y=0;y<m&&d<g&&h<n;y++){const b=i.getUint8(d++);b<o.length&&l(h,r-1-u,o[b][0],o[b][1],o[b][2],255),h++}m&1&&d++}}}else if(a){const m=p>>4&15,y=p&15;for(let b=0;b<f&&h<n;b++){const _=(b&1)===0?m:y;_<o.length&&l(h,r-1-u,o[_][0],o[_][1],o[_][2],255),h++}}else{const m=p,y=m<o.length?o[m]:[0,0,0];for(let b=0;b<f&&h<n;b++)l(h,r-1-u,y[0],y[1],y[2],255),h++}}return s0(new Uint8ClampedArray(c.buffer,c.byteOffset,c.byteLength),n,r)}function xc(i){if(i===0)return 0;let t=0,e=i;for(;(e&1)===0;)e>>>=1,t++;return t}var BP=3;function FP(i,t,e,n,r){let s=0,a=0,o=0,c=0,l=0,h=0,u=1,d=1,g=1;if(n===BP){const f=t+e;if(f+12>i.byteLength)return null;s=i.getUint32(f,!0),a=i.getUint32(f+4,!0),o=i.getUint32(f+8,!0),c=xc(s),l=xc(a),h=xc(o),u=s>>>c||1,d=a>>>l||1,g=o>>>h||1}else r===16&&(s=31744,a=992,o=31,c=10,l=5,h=0,u=31,d=31,g=31);return{rMask:s,gMask:a,bMask:o,rShift:c,gShift:l,bShift:h,rMax:u,gMax:d,bMax:g}}function zP(i,t,e,n,r,s,a,o,c){const l=Math.floor((s*e+31)/32)*4,{rMask:h,gMask:u,bMask:d,rShift:g,gShift:f,bShift:p,rMax:m,gMax:y,bMax:b}=o;for(let _=0;_<n;_++){const w=r?_:n-1-_,k=t+w*l;if(!(k+l>i.byteLength))for(let P=0;P<e;P++){const v=(_*e+P)*4;if(s===1){const S=k+(P>>3),I=i.getUint8(S)>>7-(P&7)&1;I<a.length&&(c[v]=a[I][0],c[v+1]=a[I][1],c[v+2]=a[I][2]),c[v+3]=255}else if(s===4){const S=k+(P>>1),I=(P&1)===0?i.getUint8(S)>>4&15:i.getUint8(S)&15;I<a.length&&(c[v]=a[I][0],c[v+1]=a[I][1],c[v+2]=a[I][2]),c[v+3]=255}else if(s===8){const S=i.getUint8(k+P);S<a.length&&(c[v]=a[S][0],c[v+1]=a[S][1],c[v+2]=a[S][2]),c[v+3]=255}else if(s===16){const S=i.getUint16(k+P*2,!0);c[v]=Math.round(((S&h)>>>g)*255/m),c[v+1]=Math.round(((S&u)>>>f)*255/y),c[v+2]=Math.round(((S&d)>>>p)*255/b),c[v+3]=255}else if(s===24){const S=k+P*3;c[v]=i.getUint8(S+2),c[v+1]=i.getUint8(S+1),c[v+2]=i.getUint8(S),c[v+3]=255}else{const S=k+P*4,I=i.getUint8(S),M=i.getUint8(S+1),O=i.getUint8(S+2),N=i.getUint8(S+3);c[v]=O,c[v+1]=M,c[v+2]=I,c[v+3]=N===0?255:N}}}}function a0(i,t,e,n){if(t<0||e<0||t+40>i.byteLength||e+n>i.byteLength)return null;const r=i.getUint32(t,!0);if(r<40||t+r>i.byteLength)return null;const s=i.getInt32(t+4,!0),a=i.getInt32(t+8,!0),o=i.getUint16(t+12,!0),c=i.getUint16(t+14,!0),l=i.getUint32(t+16,!0);if(o!==1||s<=0||a===0||s>8192||Math.abs(a)>8192)return null;const h=0,u=1,d=2,g=3;if(c!==1&&c!==4&&c!==8&&c!==16&&c!==24&&c!==32||l===u&&c!==8||l===d&&c!==4||l===g&&c!==16&&c!==32||l!==h&&l!==u&&l!==d&&l!==g)return null;const f=Math.abs(a),p=a<0,m=[];if(c<=8){const _=1<<c,w=i.getUint32(t+32,!0)||_,k=Math.min(w,_),P=t+r;if(P+k*4>i.byteLength)return null;for(let v=0;v<k;v++){const S=i.getUint8(P+v*4),I=i.getUint8(P+v*4+1),M=i.getUint8(P+v*4+2);m.push([M,I,S])}}const y=FP(i,t,r,l,c);if(!y)return null;const b=new Uint8ClampedArray(s*f*4);return l===u||l===d?RP(i,e,n,s,f,p,l===d,m,b,(w,k,P,v,S,I)=>{const M=(k*s+w)*4;b[M]=P,b[M+1]=v,b[M+2]=S,b[M+3]=I}):(zP(i,e,s,f,p,c,m,y,b),s0(b,s,f))}function XP(i,t,e,n){const{ctx:r,view:s,state:a}=i;if(n>=76){const o=s.getInt32(e+28,!0),c=s.getInt32(e+32,!0),l=s.getUint32(e+36,!0),h=s.getUint32(e+40,!0),u=s.byteLength;if(l>0&&h>0&&t+h+l*2<=u){const d=ns(s,t+h,l);if(d.length>0){const g=Math.abs(te(i,1));ul(r,a,g),r.fillStyle=a.textColor;const f=a.textAlign&24,p=f===24?"alphabetic":f===8?"bottom":"top";let m="left";if(a.textAlign&6&&(m="center"),a.textAlign&2&&(m="right"),r.textBaseline=p,r.textAlign=m,a.bkMode===2){const y=r.measureText(d),b=Ah(a,g);r.fillStyle=a.bkColor,r.fillRect(rt(i,o),st(i,c)-b,y.width,b),r.fillStyle=a.textColor}if(r.fillText(d,rt(i,o),st(i,c)),a.fontUnderline||a.fontStrikeOut){const y=r.measureText(d).width,b=rt(i,o),_=m==="center"?b-y/2:m==="right"?b-y:b;bP(r,a,_,st(i,c),y,g)}}}}return!0}var YP=15728673,jP=1;function VP(i,t,e,n){const{ctx:r,view:s,state:a}=i;if(n>=96){const o=s.getInt32(e+16,!0),c=s.getInt32(e+20,!0),l=s.getInt32(e+24,!0),h=s.getInt32(e+28,!0),u=s.getUint32(e+32,!0),d=s.getUint32(e+76,!0),g=s.getUint32(e+80,!0),f=s.getUint32(e+84,!0),p=s.getUint32(e+88,!0);if(d===0&&u===YP){const m=r.fillStyle;return a.brushStyle!==jP&&(r.fillStyle=a.brushColor,r.fillRect(rt(i,o),st(i,c),ue(i,l),te(i,h))),r.fillStyle=m,!0}if(d>0&&g>0&&f>0&&p>0){const m=a0(s,t+d,t+f,p);if(m){const y=Jm(m.width,m.height);y&&(y.ctx.putImageData(m,0,0),r.drawImage(y.canvas,rt(i,o),st(i,c),ue(i,l),te(i,h)))}}}return!0}function UP(i,t,e,n){const{ctx:r,view:s}=i;if(n>=80){const a=s.getInt32(e+16,!0),o=s.getInt32(e+20,!0),c=s.getInt32(e+64,!0),l=s.getInt32(e+68,!0),h=s.getUint32(e+40,!0),u=s.getUint32(e+44,!0),d=s.getUint32(e+48,!0),g=s.getUint32(e+52,!0);if(h>0&&u>0&&d>0&&g>0){const f=a0(s,t+h,t+d,g);if(f){const p=Jm(f.width,f.height);p&&(p.ctx.putImageData(f,0,0),r.drawImage(p.canvas,rt(i,a),st(i,o),ue(i,c),te(i,l)))}}}return!0}function Sh(i,t,e){const{ctx:n}=i;if(i.clipUntracked&&e!=="replace")switch(e){case"intersect":case"complement":{n.save(),i.clipSaveDepth++,dl(n,[t]);return}case"exclude":case"xor":{const s=Tr(null,t,"exclude");n.save(),i.clipSaveDepth++,dl(n,s.region??[t]);return}case"union":return}const r=Tr(e==="replace"?null:i.clipRegion??null,t,e);r.exact,i.clipRegion=r.region,i.clipUntracked=!1,qi(i,r.region)}function o0(i,t){const{view:e}=i,n=e.getInt32(t,!0),r=e.getInt32(t+4,!0),s=e.getInt32(t+8,!0),a=e.getInt32(t+12,!0);return CP(rt(i,n),st(i,r),ue(i,s-n),te(i,a-r))}function HP(i,t,e){return e>=24&&Sh(i,o0(i,t),"intersect"),!0}function GP(i,t,e){return e>=24&&Sh(i,o0(i,t),"exclude"),!0}var WP={1:"intersect",2:"union",3:"xor",4:"exclude",5:"replace"};function $P(i,t,e){const{view:n}=i;if(e<16)return!0;const r=n.getUint32(t,!0),s=n.getUint32(t+4,!0),a=WP[s];if(!a)return!0;if(r===0)return a==="replace"&&(i.clipRegion=null,i.clipUntracked=!1,qi(i,null)),!0;const o=t+8;if(r<32)return!0;const c=n.getUint32(o+8,!0);if(c===0)return!0;const l=[],h=o+32;for(let u=0;u<c;u++){const d=h+u*16;if(d+16>t+8+r)break;const g=n.getInt32(d,!0),f=n.getInt32(d+4,!0),p=n.getInt32(d+8,!0),m=n.getInt32(d+12,!0);l.push({x:(g-i.bounds.left)*i.sx,y:(f-i.bounds.top)*i.sy,w:(p-g)*i.sx,h:(m-f)*i.sy})}return l.length===0||Sh(i,OP(l),a),!0}function qP(i,t,e){if(e>=16){const n=i.view.getInt32(t,!0),r=i.view.getInt32(t+4,!0);if(i.clipUntracked)return!0;i.clipRegion&&(i.clipRegion=i0(i.clipRegion,ue(i,n),te(i,r)),qi(i,i.clipRegion))}return!0}function KP(i,t,e,n,r){switch(t){case z2:return XP(i,e,n,r);case R2:return VP(i,e,n,r);case B2:return UP(i,e,n,r);case h2:return HP(i,n,r);case N2:return $P(i,n,r);case l2:return GP(i,n,r);case a2:return qP(i,n,r);default:return!1}}function ZP(i,t,e,n,r){return MP(i,t,n,r)||KP(i,t,e,n,r)}function QP(i,t,e,n){const{ctx:r,view:s,state:a,inPath:o}=i,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*8>t+n)return;o||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt32(u+d*8,!0),y=s.getInt32(u+d*8+4,!0);p===0?r.moveTo(rt(i,m),st(i,y)):r.lineTo(rt(i,m),st(i,y)),d++}r.closePath()}o||(Rt(r,a),r.fill(a.polyFillMode===2?"nonzero":"evenodd"),At(r,a),r.stroke())}function JP(i,t,e,n){const{ctx:r,view:s,state:a,inPath:o}=i,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*8>t+n)return;o||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt32(u+d*8,!0),y=s.getInt32(u+d*8+4,!0);p===0?r.moveTo(rt(i,m),st(i,y)):r.lineTo(rt(i,m),st(i,y)),d++}}o||(At(r,a),r.stroke())}function tk(i,t,e,n){const{ctx:r,view:s,state:a,inPath:o}=i,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*4>t+n)return;o||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt16(u+d*4,!0),y=s.getInt16(u+d*4+2,!0);p===0?r.moveTo(rt(i,m),st(i,y)):r.lineTo(rt(i,m),st(i,y)),d++}r.closePath()}o||(Rt(r,a),r.fill(a.polyFillMode===2?"nonzero":"evenodd"),At(r,a),r.stroke())}function ek(i,t,e,n,r){const{ctx:s,view:a,state:o,inPath:c}=i;if(r<28)return!0;const l=a.getUint32(n+16,!0),h=n+20;if(l===0||h+l*8>e+r)return!0;const u=t===Um,d=t===Vm||t===al,g=t===al||t===Hm;c||s.beginPath(),g||s.moveTo(rt(i,a.getInt32(h,!0)),st(i,a.getInt32(h+4,!0)));let f=g?0:1;if(d)for(;f+2<l;)s.bezierCurveTo(rt(i,a.getInt32(h+f*8,!0)),st(i,a.getInt32(h+f*8+4,!0)),rt(i,a.getInt32(h+(f+1)*8,!0)),st(i,a.getInt32(h+(f+1)*8+4,!0)),rt(i,a.getInt32(h+(f+2)*8,!0)),st(i,a.getInt32(h+(f+2)*8+4,!0))),f+=3;else for(;f<l;f++)s.lineTo(rt(i,a.getInt32(h+f*8,!0)),st(i,a.getInt32(h+f*8+4,!0)));if(u&&s.closePath(),c||(u&&(Rt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd")),At(s,o),s.stroke()),l>0){const p=l-1;o.curX=a.getInt32(h+p*8,!0),o.curY=a.getInt32(h+p*8+4,!0)}return!0}function nk(i,t,e,n,r){const{ctx:s,view:a,state:o,inPath:c}=i;if(r<28)return!0;const l=a.getUint32(n+16,!0),h=n+20;if(l===0||h+l*4>e+r)return!0;const u=t===Km,d=t===qm||t===ll,g=t===ll||t===Zm;c||s.beginPath(),g||s.moveTo(rt(i,a.getInt16(h,!0)),st(i,a.getInt16(h+2,!0)));let f=g?0:1;if(d)for(;f+2<l;)s.bezierCurveTo(rt(i,a.getInt16(h+f*4,!0)),st(i,a.getInt16(h+f*4+2,!0)),rt(i,a.getInt16(h+(f+1)*4,!0)),st(i,a.getInt16(h+(f+1)*4+2,!0)),rt(i,a.getInt16(h+(f+2)*4,!0)),st(i,a.getInt16(h+(f+2)*4+2,!0))),f+=3;else for(;f<l;f++)s.lineTo(rt(i,a.getInt16(h+f*4,!0)),st(i,a.getInt16(h+f*4+2,!0)));if(u&&s.closePath(),c||(u&&(Rt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd")),At(s,o),s.stroke()),l>0){const p=l-1;o.curX=a.getInt16(h+p*4,!0),o.curY=a.getInt16(h+p*4+2,!0)}return!0}function ik(i,t,e,n,r){const{ctx:s,state:a}=i;switch(t){case EA:case Um:case Vm:case al:case Hm:return ek(i,t,e,n,r);case X2:case Km:case qm:case ll:case Zm:return nk(i,t,e,n,r);case TA:return r>=28&&JP(i,e,n,r),!0;case LA:return r>=28&&QP(i,e,n,r),!0;case Y2:return r>=28&&tk(i,e,n,r),!0;case I2:return i.inPath=!0,s.beginPath(),!0;case E2:return i.inPath=!1,!0;case T2:return s.closePath(),!0;case L2:return Rt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd"),!0;case M2:return Rt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd"),At(s,a),s.stroke(),!0;case C2:return At(s,a),s.stroke(),!0;case O2:{const o=r>=12?i.view.getUint32(n,!0):5;try{if(o===5)for(;i.clipSaveDepth>0;)s.restore(),i.clipSaveDepth--;s.save(),i.clipSaveDepth++,s.clip(a.polyFillMode===2?"nonzero":"evenodd"),i.clipRegion=null,i.clipUntracked=!0}catch{}return!0}default:return!1}}function rk(i,t,e,n){const{view:r,state:s}=i;switch(t){case b2:{if(n>=28){const a=r.getUint32(e,!0),o=r.getUint32(e+4,!0),c=r.getInt32(e+8,!0),l=ze(r,e+16);i.objectTable.set(a,{kind:"pen",style:o&255,widthX:c,color:l})}return!0}case j2:{if(n>=52){const a=r.getUint32(e,!0),o=r.getUint32(e+12,!0),c=r.getInt32(e+16,!0),l=ze(r,e+24);i.objectTable.set(a,{kind:"pen",style:o&255,widthX:c,color:l})}return!0}case _2:{if(n>=24){const a=r.getUint32(e,!0),o=r.getUint32(e+4,!0),c=ze(r,e+8);i.objectTable.set(a,{kind:"brush",style:o,color:c})}return!0}case F2:{if(n>=332){const a=r.getUint32(e,!0),o=r.getInt32(e+4,!0),c=r.getInt32(e+20,!0),l=r.getUint8(e+24),h=r.getUint8(e+25),u=r.getUint8(e+26),d=ns(r,e+32,32)||"sans-serif";i.objectTable.set(a,{kind:"font",height:Math.abs(o),weight:c,italic:l!==0,underline:h!==0,strikeOut:u!==0,family:d})}return!0}case y2:{if(n>=12){const a=r.getUint32(e,!0),o=a>=Rd?_P(a-Rd):i.objectTable.get(a)??null;if(o)switch(o.kind){case"pen":s.penStyle=o.style,s.penWidth=o.widthX,s.penColor=o.color;break;case"brush":s.brushStyle=o.style,s.brushColor=o.color;break;case"font":s.fontHeight=o.height,s.fontWeight=o.weight,s.fontItalic=o.italic,s.fontUnderline=o.underline,s.fontStrikeOut=o.strikeOut,s.fontFamily=o.family;break}}return!0}case x2:return n>=12&&i.objectTable.delete(r.getUint32(e,!0)),!0;default:return!1}}function sk(i,t,e,n){const{view:r}=i;switch(t){case MA:return n>=16&&(i.windowExt.cx=r.getInt32(e,!0),i.windowExt.cy=r.getInt32(e+4,!0),Cn(i)),!0;case CA:return n>=16&&(i.windowOrg.x=r.getInt32(e,!0),i.windowOrg.y=r.getInt32(e+4,!0),Cn(i)),!0;case OA:return n>=16&&(i.viewportExt.cx=r.getInt32(e,!0),i.viewportExt.cy=r.getInt32(e+4,!0),Cn(i)),!0;case DA:return n>=16&&(i.viewportOrg.x=r.getInt32(e,!0),i.viewportOrg.y=r.getInt32(e+4,!0),Cn(i)),!0;case FA:{if(n>=12){const s=r.getUint32(e,!0);(s===8||s===7)&&Cn(i)}return!0}case u2:{if(n>=24){const s=r.getInt32(e,!0),a=r.getInt32(e+4,!0),o=r.getInt32(e+8,!0),c=r.getInt32(e+12,!0);a!==0&&(i.viewportExt.cx=Math.round(i.viewportExt.cx*s/a)),c!==0&&(i.viewportExt.cy=Math.round(i.viewportExt.cy*o/c)),Cn(i)}return!0}case d2:{if(n>=24){const s=r.getInt32(e,!0),a=r.getInt32(e+4,!0),o=r.getInt32(e+8,!0),c=r.getInt32(e+12,!0);a!==0&&(i.windowExt.cx=Math.round(i.windowExt.cx*s/a)),c!==0&&(i.windowExt.cy=Math.round(i.windowExt.cy*o/c)),Cn(i)}return!0}default:return!1}}function ak(i,t,e,n){const{view:r,state:s}=i;switch(t){case p2:return n>=32&&(s.worldTransform=[r.getFloat32(e,!0),r.getFloat32(e+4,!0),r.getFloat32(e+8,!0),r.getFloat32(e+12,!0),r.getFloat32(e+16,!0),r.getFloat32(e+20,!0)]),!0;case m2:{if(n>=36){const a=r.getUint32(e+24,!0);if(a===1)s.worldTransform=[1,0,0,1,0,0];else if(a===2||a===3){const o=[r.getFloat32(e,!0),r.getFloat32(e+4,!0),r.getFloat32(e+8,!0),r.getFloat32(e+12,!0),r.getFloat32(e+16,!0),r.getFloat32(e+20,!0)],[c,l,h,u,d,g]=s.worldTransform;a===2?s.worldTransform=[o[0]*c+o[1]*h,o[0]*l+o[1]*u,o[2]*c+o[3]*h,o[2]*l+o[3]*u,o[4]*c+o[5]*h+d,o[4]*l+o[5]*u+g]:s.worldTransform=[c*o[0]+l*o[2],c*o[1]+l*o[3],h*o[0]+u*o[2],h*o[1]+u*o[3],d*o[0]+g*o[2]+o[4],d*o[1]+g*o[3]+o[5]]}}return!0}default:return!1}}function ok(i,t,e,n){return sk(i,t,e,n)||ak(i,t,e,n)}function c0(){return{penColor:"#000000",penWidth:1,penStyle:0,brushColor:"#ffffff",brushStyle:0,textColor:"#000000",bkColor:"#ffffff",bkMode:1,fontHeight:12,fontWeight:400,fontItalic:!1,fontFamily:"sans-serif",fontUnderline:!1,fontStrikeOut:!1,rop2:13,curX:0,curY:0,polyFillMode:1,textAlign:0,worldTransform:[1,0,0,1,0,0]}}function l0(i){return{...i,worldTransform:[...i.worldTransform]}}function h0(){return{objectTable:new Map,worldTransform:[1,0,0,1,0,0],saveStack:[],saveIdMap:new Map,clipRegion:null,clipSaveDepth:0}}function ck(i,t,e,n,r){var c,l;if(ok(i,t,n,r)||rk(i,t,n,r))return!0;const{ctx:s,view:a,state:o}=i;switch(t){case g2:{for(;i.clipSaveDepth>0;)s.restore(),i.clipSaveDepth--;return i.clipStack??(i.clipStack=[]),i.clipStack.push({region:i.clipRegion??null,untracked:i.clipUntracked??!1}),i.stateStack.push(l0(o)),s.save(),i.clipUntracked?(i.clipUntracked=!1,i.clipRegion=null):i.clipRegion&&qi(i,i.clipRegion),!0}case f2:{if(r>=12){for(;i.clipSaveDepth>0;)s.restore(),i.clipSaveDepth--;let h=a.getInt32(n,!0);for(h<0&&(h=i.stateStack.length+h+1);i.stateStack.length>h&&i.stateStack.length>0;)i.stateStack.pop(),(c=i.clipStack)==null||c.pop(),s.restore();const u=i.stateStack.pop();if(u){const d=(l=i.clipStack)==null?void 0:l.pop();Object.assign(o,u),s.restore(),i.clipRegion=(d==null?void 0:d.region)??null,i.clipUntracked=!1,i.clipRegion&&qi(i,i.clipRegion)}}return!0}case r2:return r>=12&&(o.textColor=ze(a,n)),!0;case s2:return r>=12&&(o.bkColor=ze(a,n)),!0;case zA:return r>=12&&(o.bkMode=a.getUint32(n,!0)),!0;case XA:return r>=12&&(o.polyFillMode=a.getUint32(n,!0)),!0;case YA:return r>=12&&(o.rop2=a.getUint32(n,!0)),!0;case jA:case k2:case Nd:return t===Nd&&r>=12&&(o.textAlign=a.getUint32(n,!0)),!0;default:return!1}}function Bd(i,t,e){return e?{x:i.getInt16(t,!0),y:i.getInt16(t+2,!0),w:i.getInt16(t+4,!0),h:i.getInt16(t+6,!0)}:{x:i.getFloat32(t,!0),y:i.getFloat32(t+4,!0),w:i.getFloat32(t+8,!0),h:i.getFloat32(t+12,!0)}}function Fd(i,t,e){return e?{x:i.getInt16(t,!0),y:i.getInt16(t+2,!0)}:{x:i.getFloat32(t,!0),y:i.getFloat32(t+4,!0)}}function Ph(i,t,e){if(e<12)return null;i.getUint32(t,!0);const n=i.getUint32(t+4,!0),r=i.getUint32(t+8,!0);if(n===0||n>1e5)return null;const s=(r&16384)!==0;if(12+(n*(s?4:8)+n)>e)return null;const h=[];let u=t+12;for(let f=0;f<n;f++)s?(h.push({x:i.getInt16(u,!0),y:i.getInt16(u+2,!0)}),u+=4):(h.push({x:i.getFloat32(u,!0),y:i.getFloat32(u+4,!0)}),u+=8);const d=u+3&-4,g=new Uint8Array(i.buffer,i.byteOffset+d,n);return{kind:"plus-path",points:h,types:new Uint8Array(g)}}function u0(i,t){const e=(c,l)=>t[0]*c+t[2]*l+t[4],n=(c,l)=>t[1]*c+t[3]*l+t[5],r=[],s=i.points,a=i.types;let o=0;for(;o<s.length;){const c=a[o]&15,l=(a[o]&128)!==0;if(c===0)r.push({op:"moveTo",x:e(s[o].x,s[o].y),y:n(s[o].x,s[o].y)}),o++;else if(c===3){if(o+2<s.length){r.push({op:"bezierCurveTo",cp1x:e(s[o].x,s[o].y),cp1y:n(s[o].x,s[o].y),cp2x:e(s[o+1].x,s[o+1].y),cp2y:n(s[o+1].x,s[o+1].y),x:e(s[o+2].x,s[o+2].y),y:n(s[o+2].x,s[o+2].y)}),(a[o+2]&128)!==0&&r.push({op:"closePath"}),o+=3;continue}break}else r.push({op:"lineTo",x:e(s[o].x,s[o].y),y:n(s[o].x,s[o].y)}),o++;l&&r.push({op:"closePath"})}return r}function zd(i,t){i.beginPath();const e=t.points,n=t.types;let r=0;for(;r<e.length;){const s=n[r]&15,a=(n[r]&128)!==0;if(s===0)i.moveTo(e[r].x,e[r].y),r++;else if(s===1)i.lineTo(e[r].x,e[r].y),r++;else if(s===3)if(r+2<e.length){i.bezierCurveTo(e[r].x,e[r].y,e[r+1].x,e[r+1].y,e[r+2].x,e[r+2].y),(n[r+2]&128)!==0&&i.closePath(),r+=3;continue}else break;else i.lineTo(e[r].x,e[r].y),r++;a&&i.closePath()}}function un(i,t){return[i[0]*t[0]+i[1]*t[2],i[0]*t[1]+i[1]*t[3],i[2]*t[0]+i[3]*t[2],i[2]*t[1]+i[3]*t[3],i[4]*t[0]+i[5]*t[2]+t[4],i[4]*t[1]+i[5]*t[3]+t[5]]}function lk(i,t){const e=i.ctx;try{let n=null;if(t.type==="linear"&&typeof e.createLinearGradient=="function"){if(t.x1===t.x2&&t.y1===t.y2)return null;n=e.createLinearGradient(t.x1,t.y1,t.x2,t.y2)}else if(t.type==="radial"&&typeof e.createRadialGradient=="function"){if(!(t.r>0))return null;n=e.createRadialGradient(t.cx,t.cy,0,t.cx,t.cy,t.r)}if(!n)return null;for(const r of t.stops)n.addColorStop(r.offset,r.color);return n}catch{return null}}function Rn(i,t,e){if(t&32768)return oe(e);const n=i.objectTable.get(e&255);if(n&&n.kind==="plus-brush"){if(n.gradient){const r=lk(i,n.gradient);if(r)return r}return n.color}return"rgba(0,0,0,1)"}function za(i,t){let n;switch(i){case 3:n=96/72;break;case 4:n=96;break;case 5:n=96/300;break;case 6:n=96/25.4;break;default:n=1;break}return n*t}function _e(i){const t=i.worldTransform,e=za(i.pageUnit,i.pageScale),n=i.dpiScale;i.ctx.setTransform(t[0]*e*n,t[1]*e*n,t[2]*e*n,t[3]*e*n,t[4]*e*n,t[5]*e*n)}function Xd(i,t){i.saveStack.push({transform:[...i.worldTransform]}),i.saveIdMap.set(t,i.saveStack.length-1)}function Yd(i,t){const e=i.saveIdMap.get(t);if(e!==void 0&&e<i.saveStack.length){i.worldTransform=[...i.saveStack[e].transform],i.saveStack.length=e;const n=new Map;for(const[r,s]of i.saveIdMap)s<e&&n.set(r,s);i.saveIdMap=n}}function Fs(i){const t=i.worldTransform,e=za(i.pageUnit,i.pageScale)*i.dpiScale;return[t[0]*e,t[1]*e,t[2]*e,t[3]*e,t[4]*e,t[5]*e]}function d0(i,t,e,n,r){const s=(c,l)=>r[0]*c+r[2]*l+r[4],a=(c,l)=>r[1]*c+r[3]*l+r[5];return{cmds:[{op:"moveTo",x:s(i,t),y:a(i,t)},{op:"lineTo",x:s(i+e,t),y:a(i+e,t)},{op:"lineTo",x:s(i+e,t+n),y:a(i+e,t+n)},{op:"lineTo",x:s(i,t+n),y:a(i,t+n)},{op:"closePath"}],fillRule:"nonzero",simple:!0}}function hk(i,t){return{cmds:u0(i.path,t),fillRule:"nonzero",simple:!0}}var uk={0:"intersect",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"},dk=64;function gl(i,t,e=0){if(e>dk)return{region:[Ti()],exact:!1};switch(i.type){case"rect":return{region:[d0(i.x,i.y,i.width,i.height,t)],exact:!0};case"path":return{region:[hk(i,t)],exact:!0};case"infinite":return{region:null,exact:!0};case"empty":return{region:[Ti()],exact:!0};case"combine":{const n=gl(i.left,t,e+1),r=gl(i.right,t,e+1),s=uk[i.combineMode]??"intersect",a=r0(n.region,r.region,s);return{region:a.region,exact:a.exact&&n.exact&&r.exact}}}}var gk={0:"replace",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"};function fl(i){qi(i,i.clipRegion??null,!0)}function g0(i,t,e,n){const r=gk[e],s=r0(i.clipRegion??null,t,r??"intersect");s.exact,i.clipRegion=s.region,fl(i)}function jd(i,t,e,n){g0(i,[t],e)}function fk(i,t,e,n,r){const{view:s}=i;switch(t){case _S:return r>=24&&(i.worldTransform=[s.getFloat32(n,!0),s.getFloat32(n+4,!0),s.getFloat32(n+8,!0),s.getFloat32(n+12,!0),s.getFloat32(n+16,!0),s.getFloat32(n+20,!0)]),!0;case xS:return i.worldTransform=[1,0,0,1,0,0],!0;case wS:{if(r>=24){const a=[s.getFloat32(n,!0),s.getFloat32(n+4,!0),s.getFloat32(n+8,!0),s.getFloat32(n+12,!0),s.getFloat32(n+16,!0),s.getFloat32(n+20,!0)];e&8192?i.worldTransform=un(i.worldTransform,a):i.worldTransform=un(a,i.worldTransform)}return!0}case vS:{if(r>=8){const a=s.getFloat32(n,!0),o=s.getFloat32(n+4,!0),c=[1,0,0,1,a,o];e&8192?i.worldTransform=un(i.worldTransform,c):i.worldTransform=un(c,i.worldTransform)}return!0}case AS:{if(r>=8){const a=s.getFloat32(n,!0),o=s.getFloat32(n+4,!0),c=[a,0,0,o,0,0];e&8192?i.worldTransform=un(i.worldTransform,c):i.worldTransform=un(c,i.worldTransform)}return!0}case SS:{if(r>=4){const a=s.getFloat32(n,!0)*Math.PI/180,o=Math.cos(a),c=Math.sin(a),l=[o,c,-c,o,0,0];e&8192?i.worldTransform=un(i.worldTransform,l):i.worldTransform=un(l,i.worldTransform)}return!0}case pS:return r>=4&&Xd(i,s.getUint32(n,!0)),!0;case mS:return r>=4&&Yd(i,s.getUint32(n,!0)),!0;case IS:{if(r>=16){const a=e>>8&15,o=s.getFloat32(n,!0),c=s.getFloat32(n+4,!0),l=s.getFloat32(n+8,!0),h=s.getFloat32(n+12,!0),u=d0(o,c,l,h,Fs(i));jd(i,u,a)}return!0}case kS:return i.clipRegion=null,fl(i),!0;case TS:{const a=e&255,o=e>>8&15,c=i.objectTable.get(a);if(c&&c.kind==="plus-region"&&c.nodes.length>0){const l=gl(c.nodes[0],Fs(i));l.exact,g0(i,l.region,o)}return!0}case ES:{const a=e&255,o=e>>8&15,c=i.objectTable.get(a);if(c&&c.kind==="plus-path"){const l={cmds:u0(c,Fs(i)),fillRule:"nonzero",simple:!0};jd(i,l,o)}return!0}case MS:{if(r>=8){const a=s.getFloat32(n,!0),o=s.getFloat32(n+4,!0);if(i.clipRegion){const c=Fs(i),l=c[0]*a+c[2]*o,h=c[1]*a+c[3]*o;i.clipRegion=i0(i.clipRegion,l,h),fl(i)}}return!0}case yS:return r>=4&&Xd(i,s.getUint32(n,!0)),!0;case bS:return r>=4&&Yd(i,s.getUint32(n,!0)),!0;case PS:{const a=e&255,o=r>=4?s.getFloat32(n,!0):1;return i.pageUnit=a,i.pageScale=o,!0}case hS:case uS:case dS:case gS:case fS:return!0;default:return!1}}function zs(i,t){i.strokeStyle=t.color,i.lineWidth=t.width;const e=t.width||1;switch(t.dashStyle){case 1:i.setLineDash([e*3,Number(e)]);break;case 2:i.setLineDash([Number(e),Number(e)]);break;case 3:i.setLineDash([e*3,Number(e),Number(e),Number(e)]);break;case 4:i.setLineDash([e*3,Number(e),Number(e),Number(e),Number(e),Number(e)]);break;default:i.setLineDash([]);break}}function pk(i,t,e,n,r){const{ctx:s,view:a,objectTable:o}=i;switch(t){case Z2:{if(r>=8){const c=a.getUint32(n,!0),l=a.getUint32(n+4,!0),h=(e&16384)!==0,u=h?8:16;s.fillStyle=Rn(i,e,c),_e(i);let d=n+8;for(let g=0;g<l&&d+u<=n+r;g++){const{x:f,y:p,w:m,h:y}=Bd(a,d,h);s.fillRect(f,p,m,y),d+=u}}return!0}case Q2:{if(r>=4){const c=e&255,l=o.get(c),h=a.getUint32(n,!0),u=(e&16384)!==0,d=u?8:16;l&&l.kind==="plus-pen"&&zs(s,l),_e(i);let g=n+4;for(let f=0;f<h&&g+d<=n+r;f++){const{x:p,y:m,w:y,h:b}=Bd(a,g,u);s.strokeRect(p,m,y,b),g+=d}}return!0}case eS:{if(r>=12){const c=a.getUint32(n,!0),l=(e&16384)!==0;let h,u,d,g;if(l)h=a.getInt16(n+4,!0),u=a.getInt16(n+6,!0),d=a.getInt16(n+8,!0),g=a.getInt16(n+10,!0);else{if(r<20)return!0;h=a.getFloat32(n+4,!0),u=a.getFloat32(n+8,!0),d=a.getFloat32(n+12,!0),g=a.getFloat32(n+16,!0)}s.fillStyle=Rn(i,e,c),_e(i),s.beginPath(),s.ellipse(h+d/2,u+g/2,Math.abs(d)/2,Math.abs(g)/2,0,0,Math.PI*2),s.fill()}return!0}case nS:{const c=e&255,l=o.get(c),h=(e&16384)!==0;let u,d,g,f;if(h&&r>=8)u=a.getInt16(n,!0),d=a.getInt16(n+2,!0),g=a.getInt16(n+4,!0),f=a.getInt16(n+6,!0);else if(!h&&r>=16)u=a.getFloat32(n,!0),d=a.getFloat32(n+4,!0),g=a.getFloat32(n+8,!0),f=a.getFloat32(n+12,!0);else return!0;return l&&l.kind==="plus-pen"&&zs(s,l),_e(i),s.beginPath(),s.ellipse(u+g/2,d+f/2,Math.abs(g)/2,Math.abs(f)/2,0,0,Math.PI*2),s.stroke(),!0}case bc:case iS:case rS:{const c=t===bc;if(r<(c?12:8))return!0;let h=n;if(c){const P=a.getUint32(h,!0);s.fillStyle=Rn(i,e,P),h+=4}const u=a.getFloat32(h,!0)*Math.PI/180,d=a.getFloat32(h+4,!0)*Math.PI/180;h+=8;const g=(e&16384)!==0;let f,p,m,y;if(g&&h+8<=n+r)f=a.getInt16(h,!0),p=a.getInt16(h+2,!0),m=a.getInt16(h+4,!0),y=a.getInt16(h+6,!0);else if(!g&&h+16<=n+r)f=a.getFloat32(h,!0),p=a.getFloat32(h+4,!0),m=a.getFloat32(h+8,!0),y=a.getFloat32(h+12,!0);else return!0;if(t!==bc){const P=e&255,v=o.get(P);v&&v.kind==="plus-pen"&&zs(s,v)}_e(i),s.beginPath();const b=f+m/2,_=p+y/2,w=Math.abs(m)/2,k=Math.abs(y)/2;return c&&s.moveTo(b,_),s.ellipse(b,_,w,k,0,u,u+d,d<0),c?(s.closePath(),s.fill()):s.stroke(),!0}case tS:{if(r>=4){const c=e&255,l=o.get(c),h=a.getUint32(n,!0),u=(e&16384)!==0,d=u?4:8;l&&l.kind==="plus-pen"&&zs(s,l),_e(i),s.beginPath();let g=n+4;for(let f=0;f<h&&g+d<=n+r;f++){const p=Fd(a,g,u);f===0?s.moveTo(p.x,p.y):s.lineTo(p.x,p.y),g+=d}e&8192&&s.closePath(),s.stroke()}return!0}case J2:{if(r>=8){const c=a.getUint32(n,!0),l=a.getUint32(n+4,!0),h=(e&16384)!==0,u=h?4:8;s.fillStyle=Rn(i,e,c),_e(i),s.beginPath();let d=n+8;for(let g=0;g<l&&d+u<=n+r;g++){const f=Fd(a,d,h);g===0?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),d+=u}s.closePath(),s.fill()}return!0}default:return!1}}var mk=1,f0=2,p0=4,m0=8,Xa=4096;function y0(i){return i>>>12===900097}function b0(i,t){return[i.getFloat32(t,!0),i.getFloat32(t+4,!0),i.getFloat32(t+8,!0),i.getFloat32(t+12,!0),i.getFloat32(t+16,!0),i.getFloat32(t+20,!0)]}function Ya(i,t,e){return{x:i[0]*t+i[2]*e+i[4],y:i[1]*t+i[3]*e+i[5]}}function yk(i){return Number.isFinite(i)?Math.min(1,Math.max(0,i)):0}function _0(i){return i.map(t=>({offset:yk(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset)}function x0(i,t,e){if(t+4>e)return null;const n=i.getUint32(t,!0);if(n===0||n>Xa)return null;const r=t+4,s=r+n*4,a=s+n*4;if(a>e)return null;const o=[];for(let c=0;c<n;c++)o.push({offset:i.getFloat32(r+c*4,!0),color:oe(i.getUint32(s+c*4,!0))});return{stops:o,next:a}}function w0(i,t,e){if(t+4>e)return null;const n=i.getUint32(t,!0);if(n===0||n>Xa)return null;const r=t+4,s=r+n*4,a=s+n*4;if(a>e)return null;const o=[];for(let c=0;c<n;c++)o.push({pos:i.getFloat32(r+c*4,!0),factor:i.getFloat32(s+c*4,!0)});return{entries:o,next:a}}function bk(i,t,e){if(t+40>e)return null;const n=i.getUint32(t,!0),r=i.getFloat32(t+8,!0),s=i.getFloat32(t+12,!0),a=i.getFloat32(t+16,!0),o=i.getFloat32(t+20,!0),c=i.getUint32(t+24,!0),l=i.getUint32(t+28,!0);let h=t+40,u=null;n&f0&&h+24<=e&&(u=b0(i,h),h+=24);let d=[{offset:0,color:oe(c)},{offset:1,color:oe(l)}];if(n&p0){const p=x0(i,h,e);p&&(d=p.stops)}else if(n&m0){const p=w0(i,h,e);p&&(d=p.entries.map(m=>({offset:m.pos,color:Ym(c,l,m.factor)})))}let g={x:r,y:s+o/2},f={x:r+a,y:s+o/2};return u&&(g=Ya(u,g.x,g.y),f=Ya(u,f.x,f.y)),V(`parseEmfPlusBrushObject: linear gradient (${g.x.toFixed(1)},${g.y.toFixed(1)})→(${f.x.toFixed(1)},${f.y.toFixed(1)}), ${d.length} stop(s)`),{kind:"plus-brush",color:oe(c),gradient:{type:"linear",x1:g.x,y1:g.y,x2:f.x,y2:f.y,stops:_0(d)}}}function _k(i,t,e){if(t+24>e)return null;const n=i.getUint32(t,!0),r=i.getUint32(t+8,!0);let s=i.getFloat32(t+12,!0),a=i.getFloat32(t+16,!0);const o=i.getUint32(t+20,!0);if(o>Xa)return{kind:"plus-brush",color:oe(r)};const c=[];let l=t+24;for(let p=0;p<o&&l+4<=e;p++)c.push(i.getUint32(l,!0)),l+=4;let h=[];if(n&mk){if(l+4<=e){const p=i.getInt32(l,!0);if(l+=4,p>0&&l+p<=e){const m=Ph(i,l,p);m&&(h=m.points),l+=p}}}else if(l+4<=e){const p=i.getUint32(l,!0);if(l+=4,p>0&&p<=Xa&&l+p*8<=e){for(let m=0;m<p;m++)h.push({x:i.getFloat32(l+m*8,!0),y:i.getFloat32(l+m*8+4,!0)});l+=p*8}}let u=null;n&f0&&l+24<=e&&(u=b0(i,l),l+=24),u&&({x:s,y:a}=Ya(u,s,a),h=h.map(p=>Ya(u,p.x,p.y)));const d=c.length>0?c[0]:r;let g=[{offset:0,color:oe(r)},{offset:1,color:oe(d)}];if(n&p0){const p=x0(i,l,e);p&&(g=p.stops.map(m=>({offset:1-m.offset,color:m.color})))}else if(n&m0){const p=w0(i,l,e);p&&(g=p.entries.map(m=>({offset:1-m.pos,color:Ym(d,r,m.factor)})))}let f=0;for(const p of h){const m=Math.hypot(p.x-s,p.y-a);m>f&&(f=m)}return f>0?(V(`parseEmfPlusBrushObject: path gradient centre=(${s.toFixed(1)},${a.toFixed(1)}), r=${f.toFixed(1)}, ${g.length} stop(s)`),{kind:"plus-brush",color:oe(r),gradient:{type:"radial",cx:s,cy:a,r:f,stops:_0(g)}}):{kind:"plus-brush",color:oe(r)}}function v0(i,t,e){if(e<8)return null;const n=t+e,r=y0(i.getUint32(t,!0)),s=t+(r?4:0);if(s+8>n)return null;const a=i.getUint32(s,!0),o=s+4;switch(a){case XS:return{kind:"plus-brush",color:oe(i.getUint32(o,!0))};case YS:return o+8<=n?{kind:"plus-brush",color:oe(i.getUint32(o+4,!0))}:{kind:"plus-brush",color:"rgba(0,0,0,1)"};case VS:return bk(i,o,n)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};case jS:return _k(i,o,n)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};default:return{kind:"plus-brush",color:"rgba(0,0,0,1)"}}}var xk=137224,wk=139273,vk=2498570,Vd=925707;function Ak(i,t,e,n,r,s){const a=Math.abs(r),o=r>0,l=e*4+3&-4,h=l*n,u=new Uint8Array(h);for(let b=0;b<n;b++){const _=o?b:n-1-b,w=t+_*a,k=(n-1-b)*l;switch(s){case vk:case Vd:{for(let P=0;P<e;P++){const v=w+P*4;if(v+3>=i.byteLength)break;let S=i.getUint8(v),I=i.getUint8(v+1),M=i.getUint8(v+2);const O=i.getUint8(v+3);s===Vd&&O>0&&O<255&&(M=Math.min(255,Math.round(M*255/O)),I=Math.min(255,Math.round(I*255/O)),S=Math.min(255,Math.round(S*255/O)));const N=k+P*4;u[N]=S,u[N+1]=I,u[N+2]=M,u[N+3]=O}break}case wk:{for(let P=0;P<e;P++){const v=w+P*4;if(v+3>=i.byteLength)break;const S=k+P*4;u[S]=i.getUint8(v),u[S+1]=i.getUint8(v+1),u[S+2]=i.getUint8(v+2),u[S+3]=255}break}case xk:{for(let P=0;P<e;P++){const v=w+P*3;if(v+2>=i.byteLength)break;const S=k+P*4;u[S]=i.getUint8(v),u[S+1]=i.getUint8(v+1),u[S+2]=i.getUint8(v+2),u[S+3]=255}break}default:return null}}const d=14,g=108,f=d+g+h,p=new ArrayBuffer(f),m=new DataView(p),y=new Uint8Array(p);return m.setUint8(0,66),m.setUint8(1,77),m.setUint32(2,f,!0),m.setUint32(6,0,!0),m.setUint32(10,d+g,!0),m.setUint32(14,g,!0),m.setInt32(18,e,!0),m.setInt32(22,n,!0),m.setUint16(26,1,!0),m.setUint16(28,32,!0),m.setUint32(30,3,!0),m.setUint32(34,h,!0),m.setInt32(38,2835,!0),m.setInt32(42,2835,!0),m.setUint32(46,0,!0),m.setUint32(50,0,!0),m.setUint32(54,16711680,!0),m.setUint32(58,65280,!0),m.setUint32(62,255,!0),m.setUint32(66,4278190080,!0),m.setUint32(70,1934772034,!0),y.set(u,d+g),p}function Sk(i,t,e){if(e<20)return null;const n=y0(i.getUint32(t,!0)),r=i.getUint32(t+(n?8:4),!0),s=i.getFloat32(t+16,!0);let a=t+20;const o=[[1,4],[2,4],[4,4],[8,4],[16,4],[32,4],[64,4],[128,4]];let c=0;for(const[h,u]of o)r&h&&(h===1?a+=24:(h===32&&a+4<=t+e&&(c=i.getUint32(a,!0)),a+=u));if(r&256&&a+4<=t+e){const h=i.getUint32(a,!0);a+=4+h*4}if(r&512&&a+4<=t+e){const h=i.getUint32(a,!0);a+=4+h*4}if(r&1024&&a+4<=t+e){const h=i.getUint32(a,!0);a+=4+h}if(r&2048&&a+4<=t+e){const h=i.getUint32(a,!0);a+=4+h}let l="rgba(0,0,0,1)";if(a+8<=t+e){const h=v0(i,a,t+e-a);h&&(l=h.color)}return{kind:"plus-pen",color:l,width:s||1,dashStyle:c}}function Pk(i,t,e,n){let r=null;const s=i.getUint32(t+4,!0);if(s===1&&e>=28){const a=i.getUint32(t+24,!0);if(a===1){const o=i.getInt32(t+8,!0),c=i.getInt32(t+12,!0),l=i.getInt32(t+16,!0),h=i.getUint32(t+20,!0);V(` Bitmap(Pixel): ${o}×${c}, stride=${l}, pixelFormat=0x${h.toString(16).padStart(8,"0")}`);const u=t+28,d=Math.abs(l);if(o>0&&c>0&&o<=8192&&c<=8192&&u+d*c<=i.byteLength){const g=Ak(i,u,o,c,l,h);g&&(V(` Bitmap(Pixel): decoded successfully, size=${g.byteLength} bytes`),r=g)}}else if(a===2){const o=t+28,c=e-28;if(V(` Bitmap(Compressed): imgLen=${c}, imgStart=0x${o.toString(16)}`),c>0&&o+c<=i.byteLength&&(r=i.buffer.slice(i.byteOffset+o,i.byteOffset+o+c),r.byteLength>=4)){const l=new Uint8Array(r,0,4);V(` Bitmap(Compressed): first 4 bytes = [${Array.from(l).map(h=>h.toString(16).padStart(2,"0")).join(" ")}]`)}}}else if(s===2&&e>=12){i.getUint32(t+8,!0);const a=i.getUint32(t+12,!0),o=t+16;a>0&&o+a<=i.byteLength?(r=i.buffer.slice(i.byteOffset+o,i.byteOffset+o+a),r.byteLength>=4&&new DataView(r).getUint32(0,!0)):je(` Metafile: out of bounds or empty (mfStart=0x${o.toString(16)}, mfDataSize=${a}, viewLen=${i.byteLength})`)}return{data:r,type:s}}function kk(i,t,e){if(e<28)return null;const n=i.getFloat32(t+4,!0),r=i.getInt32(t+12,!0),s=i.getUint32(t+20,!0);let a="sans-serif";return s>0&&t+24+s*2<=t+e&&(a=ns(i,t+24,s)||"sans-serif"),{kind:"plus-font",emSize:n||12,flags:r,family:a}}function Ud(i,t,e,n){const{view:r,objectTable:s}=i,a=t&255;switch(t>>8&127){case CS:{const c=v0(r,e,n);c&&s.set(a,c);break}case OS:{const c=Sk(r,e,n);c&&s.set(a,c);break}case DS:{const c=Ph(r,e,n);c&&s.set(a,c);break}case BS:{const c=kk(r,e,n);c&&s.set(a,c);break}case FS:{if(n>=16){const c=r.getUint32(e+4,!0),l=r.getUint32(e+12,!0),h=r.getUint32(e+16,!0);s.set(a,{kind:"plus-stringformat",flags:c,alignment:l??0,lineAlignment:h??0})}break}case RS:{if(n<8)break;const c=Pk(r,e,n);s.set(a,{kind:"plus-image",data:c.data,type:c.type}),i.totalImageObjects++;break}case NS:{s.set(a,{kind:"plus-imageattributes"});break}case zS:{const c=Ek(r,e,n);c&&s.set(a,c);break}}}var Ik=64;function pl(i,t,e,n=0){if(t+4>e||n>Ik)return null;const r=i.getUint32(t,!0);let s=t+4;if(r<=5){const a=pl(i,s,e,n+1);if(!a)return null;s+=a.bytesRead;const o=pl(i,s,e,n+1);return o?(s+=o.bytesRead,{node:{type:"combine",combineMode:r,left:a.node,right:o.node},bytesRead:s-t}):null}if(r===268435456){if(s+16>e)return null;const a=i.getFloat32(s,!0),o=i.getFloat32(s+4,!0),c=i.getFloat32(s+8,!0),l=i.getFloat32(s+12,!0);return{node:{type:"rect",x:a,y:o,width:c,height:l},bytesRead:s+16-t}}if(r===268435457){if(s+4>e)return null;const a=i.getInt32(s,!0);if(s+=4,a<=0||s+a>e)return null;const o=Ph(i,s,a);return{node:o?{type:"path",path:o}:{type:"empty"},bytesRead:s+a-t}}return r===268435458?{node:{type:"empty"},bytesRead:4}:r===268435459?{node:{type:"infinite"},bytesRead:4}:(je(`parseRegionNode: unknown node type 0x${r.toString(16)}`),{node:{type:"empty"},bytesRead:4})}function Ek(i,t,e){if(e<8)return null;i.getUint32(t,!0);const n=i.getUint32(t+4,!0);if(n===0||n>1e5)return null;const r=t+e,s=pl(i,t+8,r);return s?{kind:"plus-region",nodes:[s.node]}:null}function Tk(i,t,e,n,r){const{ctx:s,view:a,objectTable:o}=i;switch(t){case sS:{if(r>=4){const c=a.getUint32(n,!0),l=e&255,h=o.get(l);h&&h.kind==="plus-path"&&(s.fillStyle=Rn(i,e,c),_e(i),zd(s,h),s.fill())}return!0}case aS:{if(r>=4){const c=a.getUint32(n,!0),l=e&255,h=o.get(l),u=o.get(c&255);h&&h.kind==="plus-path"&&(u&&u.kind==="plus-pen"&&(s.strokeStyle=u.color,s.lineWidth=u.width),_e(i),zd(s,h),s.stroke())}return!0}case lS:{if(r>=28){const c=a.getUint32(n,!0),l=a.getUint32(n+4,!0),h=a.getUint32(n+8,!0),u=a.getFloat32(n+12,!0),d=a.getFloat32(n+16,!0);a.getFloat32(n+20,!0),a.getFloat32(n+24,!0);const g=e&255,f=o.get(g);if(h>0&&n+28+h*2<=n+r){const p=ns(a,n+28,h);if(p.length>0&&f&&f.kind==="plus-font"){const m=f.flags&1?"bold ":"",y=f.flags&2?"italic ":"",b=hl(f.family,i.fontFamilyMap);s.font=`${y}${m}${f.emSize}px ${b}`,s.fillStyle=Rn(i,e,c),s.textBaseline="top";const _=o.get(l);if(_&&_.kind==="plus-stringformat")switch(_.alignment){case 1:s.textAlign="center";break;case 2:s.textAlign="right";break;default:s.textAlign="left"}else s.textAlign="left";_e(i),s.fillText(p,u,d)}}}return!0}case LS:{if(r>=16){const c=a.getUint32(n,!0),l=a.getUint32(n+12,!0),h=e&255,u=o.get(h),d=n+16,f=d+l*2+3&-4;if(l>0&&l<1e5&&f+l*8<=n+r&&u&&u.kind==="plus-font"){const p=ns(a,d,l);if(p.length>0){const m=u.flags&1?"bold ":"",y=u.flags&2?"italic ":"",b=hl(u.family,i.fontFamilyMap);s.font=`${y}${m}${u.emSize}px ${b}`,s.fillStyle=Rn(i,e,c),s.textBaseline="alphabetic",s.textAlign="left",_e(i);const _=a.getFloat32(f,!0),w=a.getFloat32(f+4,!0);s.fillText(p,_,w)}}}return!0}case oS:{if(r>=24){const c=e&255,l=o.get(c),h=(e&16384)!==0,u=n+24;let d,g,f,p;if(h&&u+8<=n+r)d=a.getInt16(u,!0),g=a.getInt16(u+2,!0),f=a.getInt16(u+4,!0),p=a.getInt16(u+6,!0);else if(!h&&u+16<=n+r)d=a.getFloat32(u,!0),g=a.getFloat32(u+4,!0),f=a.getFloat32(u+8,!0),p=a.getFloat32(u+12,!0);else return!0;i.totalDrawImageCalls++;const m=l&&l.kind==="plus-image"&&l.data;if(V(`DrawImage: imgId=${c}, dest=(${d},${g},${f},${p}), compressed=${h}, hasObj=${!!l}, objKind=${l==null?void 0:l.kind}, hasData=${!!m}, dataLen=${m?l.data.byteLength:0}, isMetafile=${(l==null?void 0:l.kind)==="plus-image"?l.type===2:"N/A"}`),V(`DrawImage: worldTransform=[${i.worldTransform.map(y=>y.toFixed(3)).join(", ")}]`),l&&l.kind==="plus-image"&&l.data){const y=i.worldTransform,b=za(i.pageUnit,i.pageScale)*i.dpiScale;i.deferredImages.push({imageData:l.data,dx:d,dy:g,dw:f,dh:p,transform:[y[0]*b,y[1]*b,y[2]*b,y[3]*b,y[4]*b,y[5]*b],isMetafile:l.type===2}),V(`DrawImage: queued deferred image (total=${i.deferredImages.length})`)}}return!0}case cS:{if(r>=28){const c=e&255,l=o.get(c),h=a.getUint32(n+24,!0),u=(e&16384)!==0,d=n+28;if(h>=3&&l&&l.kind==="plus-image"&&l.data){let g,f,p,m,y,b;if(u&&d+12<=n+r)g=a.getInt16(d,!0),f=a.getInt16(d+2,!0),p=a.getInt16(d+4,!0),m=a.getInt16(d+6,!0),y=a.getInt16(d+8,!0),b=a.getInt16(d+10,!0);else if(!u&&d+24<=n+r)g=a.getFloat32(d,!0),f=a.getFloat32(d+4,!0),p=a.getFloat32(d+8,!0),m=a.getFloat32(d+12,!0),y=a.getFloat32(d+16,!0),b=a.getFloat32(d+20,!0);else return!0;const _=g,w=f,k=Math.sqrt((p-g)**2+(m-f)**2),P=Math.sqrt((y-g)**2+(b-f)**2);i.totalDrawImageCalls++,V(`DrawImagePoints: imgId=${c}, points=[(${g},${f}),(${p},${m}),(${y},${b})], dest=(${_.toFixed(1)},${w.toFixed(1)},${k.toFixed(1)},${P.toFixed(1)})`),V(`DrawImagePoints: worldTransform=[${i.worldTransform.map(I=>I.toFixed(3)).join(", ")}]`);const v=i.worldTransform,S=za(i.pageUnit,i.pageScale)*i.dpiScale;i.deferredImages.push({imageData:l.data,dx:_,dy:w,dw:k,dh:P,transform:[v[0]*S,v[1]*S,v[2]*S,v[3]*S,v[4]*S,v[5]*S],isMetafile:l.type===2}),V(`DrawImagePoints: queued deferred image (total=${i.deferredImages.length})`)}else l&&l.kind==="plus-image"&&l.data}return!0}default:return!1}}var Lk={16385:"Header",16386:"EndOfFile",16388:"GetDC",16392:"Object",16394:"FillRects",16395:"DrawRects",16396:"FillPolygon",16397:"DrawLines",16398:"FillEllipse",16399:"DrawEllipse",16404:"FillPath",16405:"DrawPath",16410:"DrawImage",16411:"DrawImagePoints",16412:"DrawString",16438:"DrawDriverString",16414:"SetAntiAliasMode",16426:"SetWorldTransform",16427:"ResetWorldTransform",16428:"MultiplyWorldTransform",16432:"SetPageTransform",16433:"ResetClip",16434:"SetClipRect",16435:"SetClipPath",16436:"SetClipRegion",16437:"OffsetClip",16421:"Save",16422:"Restore",16424:"BeginContainerNoParams",16425:"EndContainer"};function Mk(i,t,e,n,r,s,a,o=1,c=Wm,l){const h=a??h0(),u={ctx:n,view:i,objectTable:h.objectTable,worldTransform:h.worldTransform,deferredImages:[],saveStack:h.saveStack,saveIdMap:h.saveIdMap,totalImageObjects:0,totalDrawImageCalls:0,clipSaveDepth:h.clipSaveDepth,clipRegion:h.clipRegion,pageUnit:2,pageScale:1,continuationBuffer:null,continuationObjectId:-1,continuationObjectType:0,continuationTotalSize:0,continuationOffset:0,dpiScale:o,fontFamilyMap:l},d=t+e;let g=0;const f=new Map;for(V(`replayEmfPlusRecords: offset=0x${t.toString(16)}, length=${e}`);t+12<=d&&g<c;){const m=i.getUint16(t,!0),y=i.getUint16(t+2,!0),b=i.getUint32(t+4,!0),_=i.getUint32(t+8,!0);if(b<12||t+b>d)break;g++,f.set(m,(f.get(m)??0)+1);const w=t+12;switch(m){case W2:{_>=16&&(i.getFloat32(w+8,!0),i.getFloat32(w+12,!0));break}case $2:t=d;continue;case q2:break;case K2:{const k=(y&32768)!==0,P=y&255;if(k)if(u.continuationBuffer===null){if(_>=4){const v=i.getUint32(w,!0),S=y>>8&127,I=64*1024*1024,M=i.byteLength-w;if(!(!Number.isFinite(v)||v<=0||v>I||v>M||_-4<0)){u.continuationTotalSize=v,u.continuationObjectId=P,u.continuationObjectType=S,u.continuationBuffer=new Uint8Array(v);const O=_-4,N=new Uint8Array(i.buffer,i.byteOffset+w+4,Math.min(O,v));u.continuationBuffer.set(N,0),u.continuationOffset=N.length}}}else{const v=u.continuationTotalSize-u.continuationOffset,S=new Uint8Array(i.buffer,i.byteOffset+w,Math.min(_,v));u.continuationBuffer.set(S,u.continuationOffset),u.continuationOffset+=S.length}else if(u.continuationBuffer!==null&&P===u.continuationObjectId){const v=u.continuationTotalSize-u.continuationOffset,S=new Uint8Array(i.buffer,i.byteOffset+w,Math.min(_,v));u.continuationBuffer.set(S,u.continuationOffset);const I=new DataView(u.continuationBuffer.buffer,u.continuationBuffer.byteOffset,u.continuationBuffer.byteLength),M=u.continuationObjectType<<8|P;Ud({...u,view:I},M,0,u.continuationTotalSize),u.continuationBuffer=null,u.continuationObjectId=-1,u.continuationObjectType=0,u.continuationTotalSize=0,u.continuationOffset=0}else Ud(u,y,w,_);break}default:{const k=pk(u,m,y,w,_)||Tk(u,m,y,w,_)||fk(u,m,y,w,_);break}}t+=b}g>=c;const p=[];for(const[m,y]of f)p.push(`${Lk[m]??`0x${m.toString(16)}`}:${y}`);return V(`replayEmfPlusRecords: totalImageObjects=${u.totalImageObjects}, totalDrawImageCalls=${u.totalDrawImageCalls}, deferredImages=${u.deferredImages.length}`),V(`replayEmfPlusRecords: object table has ${u.objectTable.size} entries: [${Array.from(u.objectTable.entries()).map(([m,y])=>`${m}:${y.kind}`).join(", ")}]`),a&&(a.worldTransform=u.worldTransform,a.saveIdMap=u.saveIdMap,a.clipRegion=u.clipRegion??null,a.clipSaveDepth=u.clipSaveDepth),n.setTransform(1,0,0,1,0,0),u.deferredImages}var Ck={1:"EMR_HEADER",2:"EMR_POLYBEZIER",3:"EMR_POLYGON",4:"EMR_POLYLINE",5:"EMR_POLYBEZIERTO",6:"EMR_POLYLINETO",14:"EMR_EOF",27:"EMR_MOVETOEX",37:"EMR_SELECTOBJECT",38:"EMR_CREATEPEN",39:"EMR_CREATEBRUSHINDIRECT",40:"EMR_DELETEOBJECT",42:"EMR_ELLIPSE",43:"EMR_RECTANGLE",54:"EMR_LINETO",59:"EMR_BEGINPATH",60:"EMR_ENDPATH",62:"EMR_FILLPATH",63:"EMR_STROKEANDFILLPATH",64:"EMR_STROKEPATH",70:"EMR_COMMENT",76:"EMR_BITBLT",81:"EMR_STRETCHDIBITS",84:"EMR_EXTTEXTOUTW",85:"EMR_POLYBEZIER16",86:"EMR_POLYGON16",87:"EMR_POLYLINE16",88:"EMR_POLYBEZIERTO16",91:"EMR_POLYPOLYGON16"};function Ok(i,t,e,n,r,s=1,a={}){V(`replayEmfRecords: bounds=(${e.left},${e.top})→(${e.right},${e.bottom}), canvas=${n}×${r}`);const o=[],c=h0(),l=a.maxRecords??Gm,h=a.maxRecordsEmfPlus??Wm,u=e.right-e.left||1,d=e.bottom-e.top||1,g=n/u,f=r/d;V(`replayEmfRecords: logical=${u}×${d}, scale=(${g.toFixed(4)},${f.toFixed(4)})`);const p={ctx:t,view:i,objectTable:new Map,state:{...c0(),fontFamilyMap:a.fontFamilyMap},stateStack:[],inPath:!1,windowOrg:{x:e.left,y:e.top},windowExt:{cx:u,cy:d},viewportOrg:{x:0,y:0},viewportExt:{cx:n,cy:r},useMappingMode:!1,clipSaveDepth:0,bounds:e,canvasW:n,canvasH:r,sx:g,sy:f};let m=0;const y=i.byteLength;let b=0,_=0;const w=new Map;for(;m+8<=y&&b<l;){const k=i.getUint32(m,!0),P=i.getUint32(m+4,!0);if(P<8||m+P>y)break;b++;const v=m+8;if(w.set(k,(w.get(k)??0)+1),k===D2){if(P>=16){const I=i.getUint32(v,!0),M=i.getUint32(v+4,!0);if(M===H2&&I>4){_++,V(`replayEmfRecords: EMF+ comment #${_} at offset 0x${m.toString(16)}, dataSize=${I}`);const O=Mk(i,v+8,I-4,t,n,r,c,s,h,a.fontFamilyMap);V(`replayEmfRecords: EMF+ comment #${_} returned ${O.length} deferred images`),o.push(...O)}else V(M===G2?`replayEmfRecords: EMR_COMMENT_PUBLIC at offset 0x${m.toString(16)}, size=${I}`:`replayEmfRecords: EMR_COMMENT (sig=0x${M.toString(16).padStart(8,"0")}) at offset 0x${m.toString(16)}, size=${I}`)}m+=P;continue}if(k===RA){const I=[];for(const[M,O]of w)I.push(`${Ck[M]??`0x${M.toString(16)}`}:${O}`);V(`replayEmfRecords: total deferred images = ${o.length}, EMF+ object table size = ${c.objectTable.size}`);break}if(k===NA||k===c2||k===V2||k===U2||k===jm){m+=P;continue}const S=ck(p,k,m,v,P)||ZP(p,k,m,v,P)||ik(p,k,m,v,P);m+=P}return b>=l,o}function Dk(i,t,e,n,r){const{ctx:s,view:a,state:o,coord:c}=i,{mx:l,my:h,mw:u,mh:d}=c;switch(t){case JS:return r>=10&&(o.curY=a.getInt16(n,!0),o.curX=a.getInt16(n+2,!0)),!0;case tP:if(r>=10){const g=a.getInt16(n,!0),f=a.getInt16(n+2,!0);At(s,o),s.beginPath(),s.moveTo(l(o.curX),h(o.curY)),s.lineTo(l(f),h(g)),s.stroke(),o.curX=f,o.curY=g}return!0;case eP:if(r>=14){const g=a.getInt16(n,!0),f=a.getInt16(n+2,!0),p=a.getInt16(n+4,!0),m=a.getInt16(n+6,!0);Rt(s,o),s.fillRect(l(m),h(p),u(f-m),d(g-p)),At(s,o),s.strokeRect(l(m),h(p),u(f-m),d(g-p))}return!0;case nP:if(r>=18){const g=Math.abs(d(a.getInt16(n,!0)))/2,f=Math.abs(u(a.getInt16(n+2,!0)))/2,p=a.getInt16(n+4,!0),m=a.getInt16(n+6,!0),y=a.getInt16(n+8,!0),b=a.getInt16(n+10,!0),_=l(b),w=h(y),k=u(m-b),P=d(p-y),v=Math.min(f,g,k/2,P/2);s.beginPath(),s.moveTo(_+v,w),s.lineTo(_+k-v,w),s.arcTo(_+k,w,_+k,w+v,v),s.lineTo(_+k,w+P-v),s.arcTo(_+k,w+P,_+k-v,w+P,v),s.lineTo(_+v,w+P),s.arcTo(_,w+P,_,w+P-v,v),s.lineTo(_,w+v),s.arcTo(_,w,_+v,w,v),s.closePath(),Rt(s,o),s.fill(),At(s,o),s.stroke()}return!0;case iP:if(r>=14){const g=a.getInt16(n,!0),f=a.getInt16(n+2,!0),p=a.getInt16(n+4,!0),m=a.getInt16(n+6,!0);s.beginPath(),s.ellipse(l((m+f)/2),h((p+g)/2),Math.abs(u(f-m))/2,Math.abs(d(g-p))/2,0,0,Math.PI*2),Rt(s,o),s.fill(),At(s,o),s.stroke()}return!0;case rP:case Ns:case _c:if(r>=22){const g=a.getInt16(n,!0),f=a.getInt16(n+2,!0),p=a.getInt16(n+4,!0),m=a.getInt16(n+6,!0),y=a.getInt16(n+8,!0),b=a.getInt16(n+10,!0),_=a.getInt16(n+12,!0),w=a.getInt16(n+14,!0),k=(w+b)/2,P=(_+y)/2,v=Math.abs(b-w)/2,S=Math.abs(y-_)/2,I=Math.atan2((p-P)/(S||1),(m-k)/(v||1)),M=Math.atan2((g-P)/(S||1),(f-k)/(v||1));s.beginPath(),t===Ns&&s.moveTo(l(k),h(P)),s.ellipse(l(k),h(P),Math.abs(u(v)),Math.abs(d(S)),0,I,M,!1),(t===Ns||t===_c)&&s.closePath(),(t===Ns||t===_c)&&(Rt(s,o),s.fill()),At(s,o),s.stroke()}return!0;case sP:if(r>=10){const g=a.getInt16(n,!0);if(g>0&&n+2+g*4<=e+r){s.beginPath();for(let f=0;f<g;f++){const p=a.getInt16(n+2+f*4,!0),m=a.getInt16(n+4+f*4,!0);f===0?s.moveTo(l(p),h(m)):s.lineTo(l(p),h(m))}s.closePath(),Rt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd"),At(s,o),s.stroke()}}return!0;case aP:if(r>=10){const g=a.getInt16(n,!0);if(g>0&&n+2+g*4<=e+r){s.beginPath();for(let f=0;f<g;f++){const p=a.getInt16(n+2+f*4,!0),m=a.getInt16(n+4+f*4,!0);f===0?s.moveTo(l(p),h(m)):s.lineTo(l(p),h(m))}At(s,o),s.stroke()}}return!0;case mP:if(r>=10){const g=a.getUint16(n,!0);let f=n+2;const p=[];for(let m=0;m<g&&f+2<=e+r;m++)p.push(a.getInt16(f,!0)),f+=2;s.beginPath();for(const m of p)if(m>0&&f+m*4<=e+r){for(let y=0;y<m;y++){const b=a.getInt16(f+y*4,!0),_=a.getInt16(f+y*4+2,!0);y===0?s.moveTo(l(b),h(_)):s.lineTo(l(b),h(_))}s.closePath(),f+=m*4}Rt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd"),At(s,o),s.stroke()}return!0;case dP:if(r>=12){const g=a.getInt16(n,!0);if(g>0&&n+2+g<=e+r){let f="";for(let y=0;y<g;y++){const b=a.getUint8(n+2+y);if(b===0)break;f+=String.fromCharCode(b)}const p=g+g%2,m=n+2+p;if(m+4<=e+r){const y=a.getInt16(m,!0),b=a.getInt16(m+2,!0);ul(s,o,Math.abs(d(1))),s.fillStyle=o.textColor,s.fillText(f,l(b),h(y))}}}return!0;case gP:if(r>=14){const g=a.getInt16(n,!0),f=a.getInt16(n+2,!0),p=a.getInt16(n+4,!0),m=(a.getUint16(n+6,!0)&4)!==0,y=n+8+(m?8:0);if(p>0&&y+p<=e+r){let b="";for(let _=0;_<p;_++){const w=a.getUint8(y+_);if(w===0)break;b+=String.fromCharCode(w)}ul(s,o,Math.abs(d(1))),s.fillStyle=o.textColor,s.fillText(b,l(f),h(g))}}return!0;default:return!1}}function Nk(i,t,e,n){return{mx:r=>(r-i.x)/(t.cx||1)*e,my:r=>(r-i.y)/(t.cy||1)*n,mw:r=>r/(t.cx||1)*e,mh:r=>r/(t.cy||1)*n}}function Rk(i,t,e,n,r,s={}){const a=e.boundsRight-e.boundsLeft||1,o=e.boundsBottom-e.boundsTop||1,c={x:e.boundsLeft,y:e.boundsTop},l={cx:a,cy:o},h=Nk(c,l,n,r),u=new Map,d=()=>{let w=0;for(;u.has(w);)w++;return w},g={...c0(),fontFamilyMap:s.fontFamilyMap},f=[],p={view:i,ctx:t,state:g,coord:h};let m=e.headerSize;const y=i.byteLength,b=s.maxRecords??Gm;let _=0;for(;m+6<=y&&_<b;){const w=i.getUint32(m,!0),k=i.getUint16(m+4,!0),P=w*2;if(P<6||m+P>y||k===US)break;_++;const v=m+6;if(Dk(p,k,m,v,P)){m+=P;continue}switch(k){case ZS:P>=10&&(c.y=i.getInt16(v,!0),c.x=i.getInt16(v+2,!0));break;case QS:P>=10&&(l.cy=i.getInt16(v,!0),l.cx=i.getInt16(v+2,!0));break;case fP:f.push(l0(g));break;case pP:{const S=f.pop();S&&Object.assign(g,S);break}case qS:P>=10&&(g.textColor=ze(i,v));break;case HS:P>=10&&(g.bkColor=ze(i,v));break;case GS:P>=8&&(g.bkMode=i.getUint16(v,!0));break;case WS:P>=8&&(g.rop2=i.getUint16(v,!0));break;case $S:P>=8&&(g.polyFillMode=i.getUint16(v,!0));break;case KS:P>=8&&(g.textAlign=i.getUint16(v,!0));break;case lP:if(P>=16){const S=d();u.set(S,{kind:"pen",style:i.getUint16(v,!0)&255,widthX:i.getInt16(v+2,!0),color:ze(i,v+6)})}break;case hP:if(P>=14){const S=d();u.set(S,{kind:"brush",style:i.getUint16(v,!0),color:ze(i,v+2)})}break;case uP:if(P>=24){let S="";for(let M=0;M<32&&v+14+M<m+P;M++){const O=i.getUint8(v+14+M);if(O===0)break;S+=String.fromCharCode(O)}const I=d();u.set(I,{kind:"font",height:Math.abs(i.getInt16(v,!0)),weight:i.getInt16(v+8,!0),italic:i.getUint8(v+10)!==0,underline:i.getUint8(v+11)!==0,strikeOut:i.getUint8(v+12)!==0,family:S||"sans-serif"})}break;case oP:if(P>=8){const S=u.get(i.getUint16(v,!0));if(S)switch(S.kind){case"pen":g.penStyle=S.style,g.penWidth=S.widthX,g.penColor=S.color;break;case"brush":g.brushStyle=S.style,g.brushColor=S.color;break;case"font":g.fontHeight=S.height,g.fontWeight=S.weight,g.fontItalic=S.italic,g.fontUnderline=S.underline,g.fontStrikeOut=S.strikeOut,g.fontFamily=S.family;break}}break;case cP:P>=8&&u.delete(i.getUint16(v,!0));break}m+=P}_>=b}var ja=3;async function Hd(i){const t=globalThis.createImageBitmap;if(typeof t!="function")throw new Error("createImageBitmap is not available in this runtime");return t(i)}async function Bk(i,t,e=0){V(`processDeferredImages: processing ${t.length} deferred images (recursionDepth=${e})...`);for(let n=0;n<t.length;n++){const r=t[n];V(` Deferred image [${n}]: isMetafile=${r.isMetafile}, dataLen=${r.imageData.byteLength}, dest=(${r.dx.toFixed(1)},${r.dy.toFixed(1)},${r.dw.toFixed(1)},${r.dh.toFixed(1)}), transform=[${r.transform.map(s=>s.toFixed(3)).join(",")}]`);try{const s=new ArrayBuffer(r.imageData.byteLength);if(new Uint8Array(s).set(new Uint8Array(r.imageData)),i.setTransform(r.transform[0],r.transform[1],r.transform[2],r.transform[3],r.transform[4],r.transform[5]),r.isMetafile){if(e>=ja){je(` Deferred image [${n}]: skipping embedded metafile — recursion depth ${e} >= ${ja}`);continue}V(` Deferred image [${n}]: recursively converting embedded metafile...`);const o=await ml(s,void 0,e+1)??await yl(s,void 0,e+1);if(o){V(` Deferred image [${n}]: metafile converted, dataUrl length=${o.length}`);const c=atob(o.split(",")[1]),l=o.match(/data:([^;]+)/),h=l?l[1]:"image/png",u=new ArrayBuffer(c.length),d=new Uint8Array(u);for(let p=0;p<c.length;p++)d[p]=c.charCodeAt(p);const g=new Blob([u],{type:h});V(` Deferred image [${n}]: creating ImageBitmap from ${g.size} byte blob (${h})...`);const f=await Hd(g);V(` Deferred image [${n}]: ImageBitmap created ${f.width}×${f.height}`),i.drawImage(f,r.dx,r.dy,r.dw,r.dh),f.close()}else je(` Deferred image [${n}]: metafile conversion returned null`)}else{V(` Deferred image [${n}]: creating ImageBitmap from ${s.byteLength} byte blob...`);const o=new Blob([s]),c=await Hd(o);V(` Deferred image [${n}]: ImageBitmap created ${c.width}×${c.height}`),i.drawImage(c,r.dx,r.dy,r.dw,r.dh),c.close()}}catch(s){s instanceof Error?s.message:String(s)}}i.setTransform(1,0,0,1,0,0)}async function ml(i,t,e=0){if(e>ja)return null;const n=t??{},r=n.dpiScale??vh,s=n.maxWidth,a=n.maxHeight,o={maxRecords:n.maxRecords,maxRecordsEmfPlus:n.maxRecords,fontFamilyMap:n.fontFamilyMap};try{if(V("=== convertEmfToDataUrl START ==="),V(`Input buffer: ${i.byteLength} bytes, maxWidth=${s}, maxHeight=${a}, dpiScale=${r}`),i.byteLength>=16){const b=new Uint8Array(i,0,16);V(`First 16 bytes: [${Array.from(b).map(_=>_.toString(16).padStart(2,"0")).join(" ")}]`)}const c=new DataView(i),l=wP(c);if(!l)return V("convertEmfToDataUrl: parseEmfHeader returned null — returning null"),null;const h=vP(l);if(!h)return V("convertEmfToDataUrl: getRenderableEmfBounds returned null — returning null"),null;const u=h.right-h.left,d=h.bottom-h.top;V(`convertEmfToDataUrl: logicalSize=${u}×${d}`);const g=Qm(u,d,s,a,r,n.maxCanvasDimension);if(!g)return V("convertEmfToDataUrl: createCanvas returned null — returning null"),null;const{canvas:f,ctx:p}=g;V(`convertEmfToDataUrl: canvas created ${f.width}×${f.height} (dpiScale=${r})`),p.save(),V("convertEmfToDataUrl: starting replayEmfRecords...");const m=Ok(c,p,h,f.width,f.height,r,o);V(`convertEmfToDataUrl: replayEmfRecords returned ${m.length} deferred images`),p.restore(),await Bk(p,m),V("convertEmfToDataUrl: exporting canvas to PNG data URL...");const y=await n0(f);return y?V(`convertEmfToDataUrl: SUCCESS — data URL length=${y.length}`):je("convertEmfToDataUrl: exportCanvasToPngDataUrl returned null"),V("=== convertEmfToDataUrl END ==="),y}catch(c){return je("convertEmfToDataUrl: EXCEPTION:",c instanceof Error?c.message:c),null}}async function yl(i,t,e=0){if(e>ja)return null;const n=t??{},r=n.dpiScale??vh,s=n.maxWidth,a=n.maxHeight,o={maxRecords:n.maxRecords,fontFamilyMap:n.fontFamilyMap};try{V("=== convertWmfToDataUrl START ===",`buffer=${i.byteLength} bytes, dpiScale=${r}`);const c=new DataView(i),l=AP(c);if(!l)return V("convertWmfToDataUrl: parseWmfHeader returned null"),null;const h=l.boundsRight-l.boundsLeft,u=l.boundsBottom-l.boundsTop;if(V(`convertWmfToDataUrl: logicalSize=${h}×${u}`),h<=0||u<=0)return V("convertWmfToDataUrl: invalid dimensions — returning null"),null;const d=Qm(h,u,s,a,r,n.maxCanvasDimension);if(!d)return null;const{canvas:g,ctx:f}=d;f.save(),Rk(c,f,l,g.width,g.height,o),f.restore();const p=await n0(g);return V(`convertWmfToDataUrl: result=${p?`dataUrl len=${p.length}`:"null"}`),V("=== convertWmfToDataUrl END ==="),p}catch(c){return je("convertWmfToDataUrl: EXCEPTION:",c instanceof Error?c.message:c),null}}const Fk={宋体:'"SimSun", "NSimSun", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif',simsun:'"SimSun", "NSimSun", "Microsoft YaHei", "Noto Sans SC", sans-serif',nsimsun:'"NSimSun", "SimSun", "Microsoft YaHei", sans-serif',黑体:'"SimHei", "Microsoft YaHei", "Noto Sans SC", sans-serif',simhei:'"SimHei", "Microsoft YaHei", sans-serif',微软雅黑:'"Microsoft YaHei", "Noto Sans SC", sans-serif',"microsoft yahei":'"Microsoft YaHei", "Noto Sans SC", sans-serif'};async function zk(i,t={}){const e=i instanceof Uint8Array?i:new Uint8Array(await i.arrayBuffer());if(!e.length)return;const n=i instanceof Blob&&wh(i.type)?i.type:void 0,r={maxWidth:t.maxWidth,maxHeight:t.maxHeight,dpiScale:t.dpiScale??1,maxCanvasDimension:t.maxCanvasDimension,fontFamilyMap:{...Fk,...t.fontFamilyMap}},s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),a=n===Ei||n==null&&ka(e)&&!Ye(e);let o=null;if(a?(o=await ml(s,r),!o&&Ye(e)&&(o=await yl(s,r))):((n===Kr||Ye(e))&&(o=await yl(s,r)),!o&&ka(e)&&(o=await ml(s,r))),!!o)return Yk(o)}function Xk(i){return wh(i.type)}function Xs(i){const t=i.indexOf(",");if(!i.startsWith("data:")||t<0)return;const e=i.slice(5,t),n=i.slice(t+1),r=e.split(";"),s=r[0]||"image/png";if(r.includes("base64")){const c=atob(n),l=new Uint8Array(c.length);for(let h=0;h<c.length;h++)l[h]=c.charCodeAt(h);return new Blob([l],{type:s})}const o=decodeURIComponent(n);return new Blob([o],{type:s})}async function Yk(i){const t=jk();if(!t)return Xs(i);try{const e=await t.decodeImage(i),n=Math.max(1,e.width),r=Math.max(1,e.height),s=t.createCanvas(n,r),a=s.getContext("2d");if(!a)return Xs(i);a.fillStyle="#ffffff",a.fillRect(0,0,n,r),a.drawImage(e,0,0);const o=globalThis.OffscreenCanvas;if(typeof o=="function"&&s instanceof o)return await s.convertToBlob({type:"image/png"});const c=s;if(typeof c.toBlob=="function")return await new Promise(l=>{c.toBlob(h=>l(h||void 0),"image/png")});if(typeof c.toDataURL=="function")return Xs(c.toDataURL("image/png"))}catch{}return Xs(i)}function jk(){if(typeof OffscreenCanvas<"u")return{createCanvas:(i,t)=>new OffscreenCanvas(i,t),decodeImage:async i=>{const e=await(await fetch(i)).blob(),n=globalThis.createImageBitmap;if(typeof n!="function")throw new Error("createImageBitmap is not available in this runtime");return n(e)}};if(typeof document<"u"&&document.createElement)return{createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},decodeImage:i=>new Promise((t,e)=>{const n=globalThis.Image;if(typeof n!="function"){e(new Error("Image is not available in this runtime"));return}const r=new n;r.onload=()=>t(r),r.onerror=()=>e(new Error("Failed to decode PNG")),r.src=i})}}class kh{parse(t){const n=this.normalizeLineEndings(t).split(`
|