@mlightcad/dxf-json-converter 1.10.3 → 1.10.5
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/dxf-json-converter.umd.cjs +2 -1
- package/dist/dxf-parser-worker.js +1093 -877
- package/lib/AcDbDxfConverter.d.ts +2 -0
- package/lib/AcDbDxfConverter.d.ts.map +1 -1
- package/lib/AcDbDxfConverter.js +19 -9
- package/lib/AcDbDxfConverter.js.map +1 -1
- package/lib/AcDbEntitiyConverter.d.ts +24 -5
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +74 -7
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/lib/Acsh3dSolidResolver.d.ts +12 -0
- package/lib/Acsh3dSolidResolver.d.ts.map +1 -0
- package/lib/Acsh3dSolidResolver.js +253 -0
- package/lib/Acsh3dSolidResolver.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1,2 @@
|
|
|
1
|
-
(function(oe,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@mlightcad/data-model")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model"],i):(oe=typeof globalThis<"u"?globalThis:oe||self,i(oe["dxf-json-converter"]={},oe.dataModel))})(this,function(oe,i){"use strict";var S,Ce,T,h,Pe,v,ie,G,b,H,k,re,ae,le,x,W,be,me,se,ce,Ne,xe,Oe,O,Y,D,de,Re,u,m,ye,N,we,z,A,X,Me,ue,B,_e,Ge,Fe,j,$,Ve,ve,K,Ae,fe,ke,De,Z,Ie,C,q,R,Te,y,J,P,Q,w,pe,Be,ge,M,ee,_,te,He,he,F;(S={})[S.None=0]="None",S[S.Anonymous=1]="Anonymous",S[S.NonConstant=2]="NonConstant",S[S.Xref=4]="Xref",S[S.XrefOverlay=8]="XrefOverlay",S[S.ExternallyDependent=16]="ExternallyDependent",S[S.ResolvedOrDependent=32]="ResolvedOrDependent",S[S.ReferencedXref=64]="ReferencedXref",(Ce={})[Ce.BYBLOCK=0]="BYBLOCK",Ce[Ce.BYLAYER=256]="BYLAYER",(T={})[T.Rotated=0]="Rotated",T[T.Aligned=1]="Aligned",T[T.Angular=2]="Angular",T[T.Diameter=3]="Diameter",T[T.Radius=4]="Radius",T[T.Angular3Point=5]="Angular3Point",T[T.Ordinate=6]="Ordinate",T[T.ReferenceIsExclusive=32]="ReferenceIsExclusive",T[T.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",T[T.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(h={})[h.TopLeft=1]="TopLeft",h[h.TopCenter=2]="TopCenter",h[h.TopRight=3]="TopRight",h[h.MiddleLeft=4]="MiddleLeft",h[h.MiddleCenter=5]="MiddleCenter",h[h.MiddleRight=6]="MiddleRight",h[h.BottomLeft=7]="BottomLeft",h[h.BottomCenter=8]="BottomCenter",h[h.BottomRight=9]="BottomRight",(Pe={})[Pe.AtLeast=1]="AtLeast",Pe[Pe.Exact=2]="Exact";var We=((v={})[v.Center=0]="Center",v[v.Above=1]="Above",v[v.Outside=2]="Outside",v[v.JIS=3]="JIS",v[v.Below=4]="Below",v);(ie={})[ie.WithDimension=0]="WithDimension",ie[ie.AddLeader=1]="AddLeader",ie[ie.Independent=2]="Independent",(G={})[G.BothOutside=0]="BothOutside",G[G.ArrowFirst=1]="ArrowFirst",G[G.TextFirst=2]="TextFirst",G[G.Auto=3]="Auto";var Le=((b={})[b.Feet=0]="Feet",b[b.None=1]="None",b[b.Inch=2]="Inch",b[b.FeetAndInch=3]="FeetAndInch",b[b.Leading=4]="Leading",b[b.Trailing=8]="Trailing",b[b.LeadingAndTrailing=12]="LeadingAndTrailing",b),$e=((H={})[H.None=0]="None",H[H.Leading=1]="Leading",H[H.Trailing=2]="Trailing",H[H.LeadingAndTrailing=3]="LeadingAndTrailing",H),Ke=((k={})[k.Center=0]="Center",k[k.First=1]="First",k[k.Second=2]="Second",k[k.OverFirst=3]="OverFirst",k[k.OverSecond=4]="OverSecond",k),Ze=((re={})[re.Bottom=0]="Bottom",re[re.Center=1]="Center",re[re.Top=2]="Top",re);(ae={})[ae.None=0]="None",ae[ae.UseDrawingBackground=1]="UseDrawingBackground",ae[ae.Custom=2]="Custom",(le={})[le.Horizontal=0]="Horizontal",le[le.Diagonal=1]="Diagonal",le[le.NotStacked=2]="NotStacked",(x={})[x.Scientific=1]="Scientific",x[x.Decimal=2]="Decimal",x[x.Engineering=3]="Engineering",x[x.Architectural=4]="Architectural",x[x.Fractional=5]="Fractional",x[x.WindowDesktop=6]="WindowDesktop",(W={})[W.Decimal=0]="Decimal",W[W.DegreesMinutesSecond=1]="DegreesMinutesSecond",W[W.Gradian=2]="Gradian",W[W.Radian=3]="Radian";var qe=((be={})[be.PatternFill=0]="PatternFill",be[be.SolidFill=1]="SolidFill",be);(me={})[me.NonAssociative=0]="NonAssociative",me[me.Associative=1]="Associative",(se={})[se.Normal=0]="Normal",se[se.Outer=1]="Outer",se[se.Ignore=2]="Ignore",(ce={})[ce.UserDefined=0]="UserDefined",ce[ce.Predefined=1]="Predefined",ce[ce.Custom=2]="Custom",(Ne={})[Ne.NotAnnotated=0]="NotAnnotated",Ne[Ne.Annotated=1]="Annotated",(xe={})[xe.Solid=0]="Solid",xe[xe.Gradient=1]="Gradient",(Oe={})[Oe.TwoColor=0]="TwoColor",Oe[Oe.OneColor=1]="OneColor",(O={})[O.Default=0]="Default",O[O.External=1]="External",O[O.Polyline=2]="Polyline",O[O.Derived=4]="Derived",O[O.Textbox=8]="Textbox",O[O.Outermost=16]="Outermost",(Y={})[Y.Line=1]="Line",Y[Y.Circular=2]="Circular",Y[Y.Elliptic=3]="Elliptic",Y[Y.Spline=4]="Spline";var Je=((D={})[D.Off=0]="Off",D[D.Solid=1]="Solid",D[D.Dashed=2]="Dashed",D[D.Dotted=3]="Dotted",D[D.ShotDash=4]="ShotDash",D[D.MediumDash=5]="MediumDash",D[D.LongDash=6]="LongDash",D[D.DoubleShortDash=7]="DoubleShortDash",D[D.DoubleMediumDash=8]="DoubleMediumDash",D[D.DoubleLongDash=9]="DoubleLongDash",D[D.DoubleMediumLongDash=10]="DoubleMediumLongDash",D[D.SparseDot=11]="SparseDot",D);Je.Off,(de={})[de.Standard=-3]="Standard",de[de.ByLayer=-2]="ByLayer",de[de.ByBlock=-1]="ByBlock",(Re={})[Re.English=0]="English",Re[Re.Metric=1]="Metric",(u={})[u.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",u[u.FRONT_CLIPPING=2]="FRONT_CLIPPING",u[u.BACK_CLIPPING=4]="BACK_CLIPPING",u[u.UCS_FOLLOW=8]="UCS_FOLLOW",u[u.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",u[u.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",u[u.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",u[u.FAST_ZOOM=128]="FAST_ZOOM",u[u.SNAP_MODE=256]="SNAP_MODE",u[u.GRID_MODE=512]="GRID_MODE",u[u.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",u[u.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",u[u.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",u[u.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",u[u.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",u[u.UNUSED=32768]="UNUSED",u[u.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",u[u.VIEWPORT_OFF=131072]="VIEWPORT_OFF",u[u.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",u[u.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",u[u.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",u[u.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(m={})[m.OPTIMIZED_2D=0]="OPTIMIZED_2D",m[m.WIREFRAME=1]="WIREFRAME",m[m.HIDDEN_LINE=2]="HIDDEN_LINE",m[m.FLAT_SHADED=3]="FLAT_SHADED",m[m.GOURAUD_SHADED=4]="GOURAUD_SHADED",m[m.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",m[m.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(ye={})[ye.UCS_UNCHANGED=0]="UCS_UNCHANGED",ye[ye.HAS_OWN_UCS=1]="HAS_OWN_UCS",(N={})[N.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",N[N.TOP=1]="TOP",N[N.BOTTOM=2]="BOTTOM",N[N.FRONT=3]="FRONT",N[N.BACK=4]="BACK",N[N.LEFT=5]="LEFT",N[N.RIGHT=6]="RIGHT",(we={})[we.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",we[we.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",(z={})[z.ByLayer=0]="ByLayer",z[z.ByBlock=1]="ByBlock",z[z.ByDictionaryDefault=2]="ByDictionaryDefault",z[z.ByObject=3]="ByObject",(A={})[A.NotAllowed=0]="NotAllowed",A[A.AllowErase=1]="AllowErase",A[A.AllowTransform=2]="AllowTransform",A[A.AllowChangeColor=4]="AllowChangeColor",A[A.AllowChangeLayer=8]="AllowChangeLayer",A[A.AllowChangeLinetype=16]="AllowChangeLinetype",A[A.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",A[A.AllowChangeVisibility=64]="AllowChangeVisibility",A[A.AllowClone=128]="AllowClone",A[A.AllowChangeLineweight=256]="AllowChangeLineweight",A[A.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",A[A.AllowAllExceptClone=895]="AllowAllExceptClone",A[A.AllowAll=1023]="AllowAll",A[A.DisableProxyWarning=1024]="DisableProxyWarning",A[A.R13FormatProxy=32768]="R13FormatProxy",(X={})[X.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",X[X.CAST=1]="CAST",X[X.RECEIVE=2]="RECEIVE",X[X.IGNORE=3]="IGNORE",(Me={})[Me.RayTrace=0]="RayTrace",Me[Me.ShadowMap=1]="ShadowMap",(ue={})[ue.BeforeText=0]="BeforeText",ue[ue.AboveText=1]="AboveText",ue[ue.None=2]="None",(B={})[B.NONE=0]="NONE",B[B.INVISIBLE=1]="INVISIBLE",B[B.CONSTANT=2]="CONSTANT",B[B.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",B[B.PRESET=8]="PRESET",(_e={})[_e.MULTILINE=2]="MULTILINE",_e[_e.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Ge={})[Ge.ProxyEntity=498]="ProxyEntity",(Fe={})[Fe.Dwg=0]="Dwg",Fe[Fe.Dxf=1]="Dxf",(j={})[j.First=1]="First",j[j.Second=2]="Second",j[j.Third=4]="Third",j[j.Fourth=8]="Fourth",($={})[$.ShowImage=1]="ShowImage",$[$.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",$[$.UseClippingBoundary=4]="UseClippingBoundary",$[$.TransparencyIsOn=8]="TransparencyIsOn",(Ve={})[Ve.Rectangular=1]="Rectangular",Ve[Ve.Polygonal=2]="Polygonal",(ve={})[ve.Outside=0]="Outside",ve[ve.Inside=1]="Inside",(K={})[K.TextAnnotation=0]="TextAnnotation",K[K.ToleranceAnnotation=1]="ToleranceAnnotation",K[K.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",K[K.NoAnnotation=3]="NoAnnotation",(Ae={})[Ae.Distant=1]="Distant",Ae[Ae.Point=2]="Point",Ae[Ae.Spot=3]="Spot",(fe={})[fe.None=0]="None",fe[fe.InverseLinear=1]="InverseLinear",fe[fe.InverseSquare=2]="InverseSquare",(ke={})[ke.IS_CLOSED=1]="IS_CLOSED",ke[ke.PLINE_GEN=128]="PLINE_GEN",(De={})[De.Top=0]="Top",De[De.Zero=1]="Zero",De[De.Bottom=2]="Bottom",(Z={})[Z.HasVertex=1]="HasVertex",Z[Z.Closed=2]="Closed",Z[Z.SuppressStartCaps=4]="SuppressStartCaps",Z[Z.SuppressEndCaps=8]="SuppressEndCaps",(Ie={})[Ie.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ie[Ie.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ie[Ie.BY_STYLE=5]="BY_STYLE",(C={})[C.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",C[C.CURVE_FIT=2]="CURVE_FIT",C[C.SPLINE_FIT=4]="SPLINE_FIT",C[C.POLYLINE_3D=8]="POLYLINE_3D",C[C.POLYGON_3D=16]="POLYGON_3D",C[C.CLOSED_POLYGON=32]="CLOSED_POLYGON",C[C.POLYFACE=64]="POLYFACE",C[C.CONTINUOUS=128]="CONTINUOUS";var Ue=((q={})[q.NONE=0]="NONE",q[q.QUADRATIC=5]="QUADRATIC",q[q.CUBIC=6]="CUBIC",q[q.BEZIER=8]="BEZIER",q);(R={})[R.NONE=0]="NONE",R[R.CLOSED=1]="CLOSED",R[R.PERIODIC=2]="PERIODIC",R[R.RATIONAL=4]="RATIONAL",R[R.PLANAR=8]="PLANAR",R[R.LINEAR=16]="LINEAR",(Te={})[Te.NONE=0]="NONE",Te[Te.MIRRORED_X=2]="MIRRORED_X",Te[Te.MIRRORED_Y=4]="MIRRORED_Y",(y={})[y.LEFT=0]="LEFT",y[y.CENTER=1]="CENTER",y[y.RIGHT=2]="RIGHT",y[y.ALIGNED=3]="ALIGNED",y[y.MIDDLE=4]="MIDDLE",y[y.FIT=5]="FIT",(J={})[J.BASELINE=0]="BASELINE",J[J.BOTTOM=1]="BOTTOM",J[J.MIDDLE=2]="MIDDLE",J[J.TOP=3]="TOP";var Qe=((P={})[P.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",P[P.TANGENT_DEFINED=2]="TANGENT_DEFINED",P[P.NOT_USED=4]="NOT_USED",P[P.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",P[P.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",P[P.FOR_POLYLINE=32]="FOR_POLYLINE",P[P.FOR_POLYGON=64]="FOR_POLYGON",P[P.POLYFACE=128]="POLYFACE",P);(Q={})[Q.ShowImage=1]="ShowImage",Q[Q.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Q[Q.UseClippingBoundary=4]="UseClippingBoundary",Q[Q.Transparency=8]="Transparency",(w={})[w.NOT_APPLICABLE=0]="NOT_APPLICABLE",w[w.KEEP_EXISTING=1]="KEEP_EXISTING",w[w.USE_CLONE=2]="USE_CLONE",w[w.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",w[w.VALUE_NAME=4]="VALUE_NAME",w[w.UNMANGLE_NAME=5]="UNMANGLE_NAME",(pe={})[pe.NOUNIT=0]="NOUNIT",pe[pe.CENTIMETERS=2]="CENTIMETERS",pe[pe.INCH=5]="INCH",(Be={})[Be.PSLTSCALE=1]="PSLTSCALE",Be[Be.LIMCHECK=2]="LIMCHECK",(ge={})[ge.INCHES=0]="INCHES",ge[ge.MILLIMETERS=1]="MILLIMETERS",ge[ge.PIXELS=2]="PIXELS",(M={})[M.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",M[M.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",M[M.DRAWING_LIMITS=2]="DRAWING_LIMITS",M[M.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",M[M.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",M[M.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION",(ee={})[ee.AS_DISPLAYED=0]="AS_DISPLAYED",ee[ee.WIREFRAME=1]="WIREFRAME",ee[ee.HIDDEN=2]="HIDDEN",ee[ee.RENDERED=3]="RENDERED",(_={})[_.DRAFT=0]="DRAFT",_[_.PREVIEW=1]="PREVIEW",_[_.NORMAL=2]="NORMAL",_[_.PRESENTATION=3]="PRESENTATION",_[_.MAXIMUM=4]="MAXIMUM",_[_.CUSTOM=5]="CUSTOM",We.Above,We.Center,Le.Trailing,Le.Feet,$e.None,Ke.Center,Ze.Center,Le.Trailing,Le.Feet,Le.Trailing,Le.Trailing,(te={})[te.NONE=0]="NONE",te[te.AbsoluteRotation=1]="AbsoluteRotation",te[te.TextEmbedded=2]="TextEmbedded",te[te.ShapeEmbedded=4]="ShapeEmbedded",(He={})[He.PaperSpace=1]="PaperSpace",(he={})[he.XrefDependent=16]="XrefDependent",he[he.XrefResolved=32]="XrefResolved",he[he.Referenced=64]="Referenced",(F={})[F.Off=0]="Off",F[F.Perspective=1]="Perspective",F[F.ClipFront=2]="ClipFront",F[F.ClipBack=4]="ClipBack",F[F.UcsFollow=8]="UcsFollow",F[F.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class Ye{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="MLINE"?this.convertMLine(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="TOLERANCE"?this.convertTolerance(e):e.type=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="3DSOLID"?this.convert3dSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):null}convertProxyEntity(e){const t=new i.AcDbProxyEntity;if(t.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(t.originalDxfName=e.originalDxfName),e.objectDrawingFormat!=null&&(t.graphicsMetafileType=e.objectDrawingFormat),e.applicationEntityClassId!=null&&(t.originalClassName=String(e.applicationEntityClassId)),e.graphicsData){const n=i.hexStringsToBytes([e.graphicsData]),r=e.graphicsDataSize??n.length;t.setProxyGraphic(n.subarray(0,r))}return t}convertFace(e){const t=new i.AcDbFace;return e.vertices.forEach((n,r)=>t.setVertexAt(r,n)),t}convertArc(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbArc(i.transformOcsPointToWcs(e.center,t),e.radius,i.AcGeMathUtil.degToRad(e.startAngle),i.AcGeMathUtil.degToRad(e.endAngle),t)}convertAttributeCommon(e,t){t.textString=e.text,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.alignmentPoint,r=!n||n.x===0&&n.y===0&&(n.z??0)===0;n&&!r?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.tag=e.tag,t.fieldLength=0,t.isInvisible=(e.attributeFlag&i.AcDbAttributeFlags.Invisible)!==0,t.isConst=(e.attributeFlag&i.AcDbAttributeFlags.Const)!==0,t.isVerifiable=(e.attributeFlag&i.AcDbAttributeFlags.Verifiable)!==0,t.isPreset=(e.attributeFlag&i.AcDbAttributeFlags.Preset)!==0,t.isReallyLocked=!!e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.ConstMultiLine)!==0}convertAttribute(e){const t=new i.AcDbAttribute;return this.convertAttributeCommon(e,t),t.styleName=e.textStyle,t.horizontalMode=e.horizontalJustification,t.verticalMode=e.verticalJustification,t.widthFactor=e.scale??1,t.lockPositionInBlock=e.lockPositionFlag,t}convertAttributeDefinition(e){const t=new i.AcDbAttributeDefinition;return this.convertAttributeCommon(e,t),t.styleName=e.styleName,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t.prompt=e.prompt,t}convertCirle(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbCircle(i.transformOcsPointToWcs(e.center,t),e.radius,t)}convertEllipse(e){const t=new i.AcGeVector3d(e.majorAxisEndPoint),n=t.length();return new i.AcDbEllipse(e.center,e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t,n,n*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,n=e.endPoint;return new i.AcDbLine(new i.AcGePoint3d(t.x,t.y,t.z||0),new i.AcGePoint3d(n.x,n.y,n.z||0))}convertSpline(e){return i.AcDbSpline.fromDwgSpline(e)}convertPoint(e){const t=new i.AcDbPoint;return t.position=e.position,t}convertShape(e){const t=new i.AcDbShape;return t.position.copy(e.insertionPoint),t.size=e.size,t.name=e.shapeName,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.widthFactor=e.xScale??1,t.oblique=i.AcGeMathUtil.degToRad(e.obliqueAngle||0),t.thickness=e.thickness??0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}convertSolid(e){const t=new i.AcDbTrace;return e.points.forEach((n,r)=>t.setPointAt(r,n)),t.thickness=e.thickness,t}convert3dSolid(e){return new i.AcDb3dSolid(e.data??"",e.version)}convertPolyline(e){var c;const t=!!(e.flag&1),n=!!(e.flag&8),r=!!(e.flag&16),a=!!(e.flag&64),o=!!(e.flag&32),l=[],d=[],f=[];if((c=e.vertices)==null||c.map(s=>{s.flag&Qe.SPLINE_CONTROL_POINT||(a&&s.flag&128?s.flag&64?(l.push({x:s.x,y:s.y,z:s.z}),d.push(s.bulge??0)):s.faces&&s.faces.length>=3&&f.push([...s.faces]):(l.push({x:s.x,y:s.y,z:s.z}),d.push(s.bulge??0)))}),r){const s=e.meshMVertexCount,p=e.meshNVertexCount;return new i.AcDbPolygonMesh(s,p,l,t,o)}else{if(a)return new i.AcDbPolyFaceMesh(l,f);if(n){let s=i.AcDbPoly3dType.SimplePoly;return e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly3dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly3dType.QuadSplinePoly)),new i.AcDb3dPolyline(s,l,t)}else{let s=i.AcDbPoly2dType.SimplePoly;return e.flag&2?s=i.AcDbPoly2dType.FitCurvePoly:e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly2dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly2dType.QuadSplinePoly)),new i.AcDb2dPolyline(s,l,0,t,e.startWidth,e.endWidth,d)}}}convertLWPolyline(e){var r;const t=new i.AcDbPolyline;t.closed=!!(e.flag&1);const n=e.constantWidth??-1;return(r=e.vertices)==null||r.forEach((a,o)=>{t.addVertexAt(o,new i.AcGePoint2d(a.x,a.y),a.bulge,a.startWidth??n,a.endWidth??n)}),t}convertHatch(e){var r;const t=new i.AcDbHatch;if((r=e.definitionLines)==null||r.forEach(a=>{t.definitionLines.push({angle:i.AcGeMathUtil.degToRad(a.angle||0),base:a.base,offset:a.offset,dashLengths:a.numberOfDashLengths>0?a.dashLengths:[]})}),t.isSolidFill=e.solidFill==qe.SolidFill,t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:i.AcGeMathUtil.degToRad(e.patternAngle),t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(a=>{if(a.boundaryPathTypeFlag&2){const l=a,d=new i.AcGePolyline2d;d.closed=l.isClosed,l.vertices.forEach((f,c)=>{d.addVertexAt(c,{x:f.x,y:f.y,bulge:f.bulge})}),t.add(d)}else{const l=a,d=[];l.edges.forEach(c=>{if(c.type==1){const s=c;d.push(new i.AcGeLine2d(s.start,s.end))}else if(c.type==2){const s=c;d.push(new i.AcGeCircArc2d(s.center,s.radius,i.AcGeMathUtil.degToRad(s.startAngle||0),i.AcGeMathUtil.degToRad(s.endAngle||0),!s.isCCW))}else if(c.type==3){const s=c;new i.AcGeVector2d().subVectors(s.end,s.center);const E=Math.sqrt(Math.pow(s.end.x,2)+Math.pow(s.end.y,2)),I=E*s.lengthOfMinorAxis;let L=i.AcGeMathUtil.degToRad(s.startAngle||0),V=i.AcGeMathUtil.degToRad(s.endAngle||0);const ne=Math.atan2(s.end.y,s.end.x);s.isCCW||(L=Math.PI*2-L,V=Math.PI*2-V),d.push(new i.AcGeEllipseArc2d({...s.center,z:0},E,I,L,V,!s.isCCW,ne))}else if(c.type==4){const s=i.AcGeSpline3d.fromDwgSplineEdge(c);s&&d.push(s)}});const f=i.AcGeLoop2d.buildFromEdges(d);f.length==0&&d.length>0?t.add(new i.AcGeLoop2d(d)):f.forEach(c=>t.add(c))}}),e.gradientFlag){const a=e;if(t.hatchObjectType=i.AcDbHatchObjectType.GradientObject,t.gradientName=a.gradientName,t.gradientAngle=a.gradientRotation??0,t.gradientShift=a.gradientDefinition??0,t.gradientOneColorMode=a.gradientColorFlag==1,t.shadeTintValue=a.colorTint??0,a.gradientColors){const o=a.gradientColors.length;o>1?(t.gradientStartColor=a.gradientColors[0].rgb,t.gradientEndColor=a.gradientColors[1].rgb):o>0&&(t.gradientStartColor=a.gradientColors[0].rgb)}}return t}convertTable(e){const t=new i.AcDbTable(e.name,e.rowCount,e.columnCount);return t.tableDataVersion=e.version,t.tableStyleId=e.tableStyleId,t.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(t.horizontalDirection=new i.AcGeVector3d(e.directionVector)),t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),t.tableValueFlag=e.tableValue,t.tableOverrideFlag=e.overrideFlag,t.borderColorOverrideFlag=e.borderColorOverrideFlag,t.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,t.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach((n,r)=>t.setColumnWidth(r,n)),e.rowHeightArr.forEach((n,r)=>t.setRowHeight(r,n)),e.cells.forEach((n,r)=>{t.setCell(r,n)}),t}convertText(e){const t=new i.AcDbText;t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.endPoint,r=!n||n.x===0&&n.y===0&&(n.z??0)===0;return n&&!r?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertTolerance(e){const t=new i.AcDbFcf;return t.location.copy(e.position),t.text=e.text,t.dimensionStyle=e.styleName??"",e.extrusionDirection&&t.normal.copy(e.extrusionDirection),e.xAxisDirection&&t.direction.copy(e.xAxisDirection),t}convertMText(e){const t=new i.AcDbMText;t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new i.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection;const n=this.readMTextExtentsWidth(e);return n!=null&&n>0&&(t.extentsWidth=n),t}readMTextExtentsWidth(e){const t=e;return t.extentsWidth??t.actualWidth}convertLeader(e){var n;const t=new i.AcDbLeader;return(n=e.vertices)==null||n.forEach(r=>{t.appendVertex(r)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isHookLineSameDirection=e.isHooklineSameDirection,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName??"",t.annoType=e.leaderCreationFlag,t.textHeight=e.textHeight??0,t.textWidth=e.textWidth??0,t.byBlockColor=e.byBlockColor,t.associatedAnnotation=e.associatedAnnotation??"",e.normal&&(t.normal=e.normal),e.horizontalDirection&&(t.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(t.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(t.offsetFromAnnotation=e.offsetFromAnnotation),t}convertMLine(e){const t=new i.AcDbMLine;return t.styleName=e.name||"STANDARD",t.styleObjectHandle=e.styleObjectHandle,t.scale=e.scale,t.justification=e.justification,t.flags=e.flags,t.styleCount=e.styleCount,t.startPosition=e.startPosition,t.normal=e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t.segments=(e.segments??[]).map(n=>{var r;return{position:n.position,direction:n.direction,miterDirection:n.miterDirection,elements:((r=n.elements)==null?void 0:r.map(a=>({parameterCount:a.parameterCount,parameters:a.parameters??[],fillCount:a.fillCount,fillParameters:a.fillParameters??[]})))??[]}}),t}convertMLeader(e){var Ee,Se;const t=new i.AcDbMLeader,n=e;t.version=e.version,t.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(t.mleaderStyleId=e.leaderStyleId),t.propertyOverrideFlag=e.propertyOverrideFlag,t.leaderLineType=e.leaderLineType??i.AcDbMLeaderLineType.StraightLeader,e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,t.leaderLineWeight=e.leaderLineWeight,t.landingEnabled=e.landingEnabled,t.doglegEnabled=e.doglegEnabled??!1,t.doglegLength=e.doglegLength??0,t.arrowheadId=e.arrowheadId,t.arrowheadSize=e.arrowheadSize,t.textStyleId=e.textStyleId,t.textLeftAttachmentType=e.textLeftAttachmentType,t.textRightAttachmentType=e.textRightAttachmentType,t.textAngleType=e.textAngleType,t.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),t.textFrameEnabled=e.textFrameEnabled,t.landingGap=e.landingGap,t.textAttachment=e.textAttachment,t.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(t.blockContentId=e.blockContentId),e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),t.blockContentRotation=e.blockContentRotation,t.blockContentConnectionType=e.blockContentConnectionType,t.annotativeScaleEnabled=e.annotativeScaleEnabled,t.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(g=>({...g})):[],t.blockAttributes=e.blockAttributes?e.blockAttributes.map(g=>({...g})):[],t.textDirectionNegative=e.textDirectionNegative,t.textAlignInIPE=e.textAlignInIPE,t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,t.topTextAttachmentDirection=e.topTextAttachmentDirection,t.contentScale=e.contentScale,t.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(t.textBackgroundColor=i.decodeMLeaderStyleRawColor(e.textBackgroundColor)),t.textBackgroundScaleFactor=e.textBackgroundScaleFactor,t.textBackgroundTransparency=e.textBackgroundTransparency,t.textBackgroundColorOn=e.textBackgroundColorOn,t.textFillOn=e.textFillOn,t.textColumnType=e.textColumnType,t.textUseAutoHeight=e.textUseAutoHeight,t.textColumnWidth=e.textColumnWidth,t.textColumnGutterWidth=e.textColumnGutterWidth,t.textColumnFlowReversed=e.textColumnFlowReversed,t.textColumnHeight=e.textColumnHeight,t.textUseWordBreak=e.textUseWordBreak,t.hasMText=e.hasMText,t.hasBlock=e.hasBlock,t.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(t.blockContentScale=new i.AcGeVector3d(e.blockContentScale)),e.contentBasePosition&&(t.contentBasePosition=new i.AcGePoint3d().copy(e.contentBasePosition)),e.textAnchor&&(t.textAnchor=new i.AcGePoint3d().copy(e.textAnchor)),e.planeOrigin&&(t.planeOrigin=new i.AcGePoint3d().copy(e.planeOrigin)),e.planeXAxisDirection&&(t.planeXAxisDirection=new i.AcGeVector3d(e.planeXAxisDirection)),e.planeYAxisDirection&&(t.planeYAxisDirection=new i.AcGeVector3d(e.planeYAxisDirection));const r=n.textContent,a=r&&typeof r=="object"?r:void 0,o=typeof r=="string"&&r.length>0||this.readString(a??{},["text","contents"])!=null||this.readString(n,["text","contents","mtext"])!=null,l=e.contentType??(o?i.AcDbMLeaderContentType.MTextContent:e.blockContent?i.AcDbMLeaderContentType.BlockContent:i.AcDbMLeaderContentType.NoneContent);t.contentType=l;const d=this.readPoint(n,["normal","extrusionDirection"]);d&&(t.normal=d);const f=this.readString(a??{},["styleName","textStyleName","textStyle"])??this.readString(n,["textStyleName","textStyle","styleName"]);f&&(t.textStyleName=f);const c=this.readPositiveNumber(a??{},["textHeight","height"])??this.readPositiveNumber(n,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(n,["arrowheadSize","contentScale"]);c!=null&&(t.textHeight=c);const s=this.readPositiveNumber(a??{},["textWidth","width"])??this.readPositiveNumber(n,["textWidth","mtextWidth","textContentWidth"]);s!=null&&(t.textWidth=s),t.textLineSpacingFactor=this.readNumber(a??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(n,["textLineSpacingFactor"])??t.textLineSpacingFactor;const p=this.readNumber(a??{},["textRotation","rotation"])??this.readNumber(n,["textRotation","mtextRotation","textContentRotation"]);p!=null&&(t.textRotation=i.AcGeMathUtil.degToRad(p));const E=this.readPoint(n,["textDirection","mtextDirection","textDirectionVector"]);E&&(t.textDirection=E);const I=this.readNumber(n,["textAttachmentPoint","attachmentPoint"]);I!=null&&I!==0&&(t.textAttachmentPoint=I);const L=e.textAttachmentDirection;L!=null&&(t.textAttachmentDirection=L);const V=this.readNumber(n,["textDrawingDirection","drawingDirection"]);V!=null&&(t.textDrawingDirection=V);const ne=typeof r=="string"?r:this.readString(a??{},["text","contents"])??this.readString(n,["text","contents","mtext"]),U=this.readPoint(a??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(n,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(ne!=null&&U&&(t.mtextContent={text:ne,anchorPoint:U}),e.blockContent){const g=e.blockContent,Xe=e.blockContent.blockContentId;if(this.isValidHandleId(Xe)){const je=this.readNumber(g,["color"]);t.blockContent={blockContentId:Xe,normal:this.readPoint(g,["normal"]),position:e.blockContent.position,scale:this.readPoint(g,["scale"]),rotation:this.readNumber(g,["rotation"]),color:je!=null?i.decodeMLeaderStyleRawColor(je):void 0,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(t.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:t.blockContentColor,transformationMatrix:[]});return(Ee=this.readMLeaderLeaders(n))==null||Ee.forEach(g=>{t.addLeader({lastLeaderLinePoint:g.lastLeaderLinePoint,lastLeaderLinePointSet:g.lastLeaderLinePointSet,doglegVector:g.doglegVector,doglegVectorSet:g.doglegVectorSet,doglegLength:g.doglegLength??e.doglegLength,breaks:g.breaks,leaderBranchIndex:g.leaderBranchIndex,leaderLines:g.leaderLines})}),t.numberOfLeaders===0&&((Se=this.readLeaderLineArray(n))==null||Se.forEach(g=>{t.addLeader({doglegLength:e.doglegLength}),t.addLeaderLine(t.numberOfLeaders-1,g)})),t.numberOfLeaders===0&&e.contentBasePosition&&t.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"){const t=e,n=new i.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRotatedDimension"){const t=e,n=new i.AcDbRotatedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,n=new i.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb2LineAngularDimension"){const t=e,n=t.centerPoint??t.subDefinitionPoint2??t.definitionPoint,r=t.definitionPoint??t.subDefinitionPoint2;if(!n||!t.subDefinitionPoint1||!t.subDefinitionPoint2||!r)return null;const a=new i.AcDb3PointAngularDimension(n,t.subDefinitionPoint1,t.subDefinitionPoint2,r);return this.processDimensionCommonAttrs(e,a),a}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,n=new i.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,n=new i.AcDbRadialDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,n=new i.AcDbDiametricDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new i.AcDbRasterImage;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new i.AcDbWipeout;return this.processWipeout(e,t),t}convertViewport(e){const t=new i.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new i.AcDbRay;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new i.AcDbXline;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new i.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?i.AcGeMathUtil.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(e,t){if(t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle.toString()),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){const n=new i.AcCmColor;e.color!=null&&n.setRGBValue(e.color),e.colorIndex!=null&&(n.colorIndex=e.colorIndex),e.colorName&&(n.colorName=e.colorName),t.color=n}e.isVisible!=null&&(t.visibility=!e.isVisible),e.transparency!=null&&(t.transparency=i.AcCmTransparency.deserialize(e.transparency))}isValidHandleId(e){return e!=null&&e!==""&&e!=="0"}readNumber(e,t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}}readPositiveNumber(e,t){const n=this.readNumber(e,t);return n!=null&&n>0?n:void 0}readString(e,t){for(const n of t){const r=e[n];if(typeof r=="string")return r}}readBoolean(e,t){for(const n of t){const r=e[n];if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0}}readPoint(e,t){for(const n of t){const r=e[n];if(this.isPointLike(r))return r;if(Array.isArray(r)&&typeof r[0]=="number"&&typeof r[1]=="number")return{x:r[0],y:r[1],z:r[2]??0}}}readLeaderLineArray(e){const t=e.leaderLines;if(Array.isArray(t))return t.map(r=>{if(!r||typeof r!="object")return;const a=r.vertices;return Array.isArray(a)?a.filter(o=>this.isPointLike(o)):void 0}).filter(r=>!!r&&r.length>0);const n=e.vertices;if(Array.isArray(n)){const r=n.filter(a=>this.isPointLike(a));return r.length>0?[r]:void 0}}readMLeaderLeaders(e){const t=e.leaderSections;if(!Array.isArray(t))return;const n=[];return t.forEach(r=>{if(!r||typeof r!="object")return;const a=r,o=a.leaderLines,l=Array.isArray(o)?o.reduce((I,L)=>{const V=this.readMLeaderLine(L);return V&&I.push(V),I},[]):void 0,d={},f=this.readPoint(a,["lastLeaderLinePoint"]),c=this.readPoint(a,["doglegVector"]),s=this.readNumber(a,["doglegLength"]),p=this.readMLeaderBreaks(a.breaks),E=this.readNumber(a,["leaderBranchIndex"]);f&&(d.lastLeaderLinePoint=f),a.lastLeaderLinePointSet!=null&&(d.lastLeaderLinePointSet=this.readBoolean(a,["lastLeaderLinePointSet"])),c&&(d.doglegVector=c),a.doglegVectorSet!=null&&(d.doglegVectorSet=this.readBoolean(a,["doglegVectorSet"])),s!=null&&(d.doglegLength=s),p&&(d.breaks=p),E!=null&&(d.leaderBranchIndex=E),l&&(d.leaderLines=l),n.push(d)}),n}readMLeaderLine(e){if(!e||typeof e!="object")return;const t=e,n=t.vertices,r=Array.isArray(n)?n.filter(d=>this.isPointLike(d)):[],a=this.readMLeaderBreaks(t.breaks),o=Array.isArray(t.breakPointIndexes)?t.breakPointIndexes.filter(d=>typeof d=="number"):void 0,l=this.readNumber(t,["leaderLineIndex"]);return r.length>0||a&&a.length>0?{vertices:r,breakPointIndexes:o,leaderLineIndex:l,breaks:a}:void 0}readMLeaderBreaks(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!n||typeof n!="object")return;const r=n,a=this.readPoint(r,["start"]),o=this.readPoint(r,["end"]),l=this.readNumber(r,["index"]);if(!a||!o)return;const d={start:a,end:o};return l!=null&&(d.index=l),d}).filter(n=>!!n);return t.length>0?t:void 0}isPointLike(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"}}class et{convertLayout(e,t){var a,o;const n=new i.AcDbLayout;n.layoutName=e.layoutName,n.tabOrder=e.tabOrder,n.plotSettingsName=e.pageSetupName,n.plotCfgName=e.configName,n.canonicalMediaName=e.paperSize,n.plotViewName=e.plotViewName,n.currentStyleSheet=e.currentStyleSheet,n.plotPaperMargins={left:e.marginLeft,right:e.marginRight,top:e.marginTop,bottom:e.marginBottom},n.plotPaperSize.copy({x:e.paperWidth,y:e.paperHeight}),n.plotOrigin.copy({x:e.plotOriginX,y:e.plotOriginY}),n.plotWindowArea.min.copy({x:e.windowAreaXMin,y:e.windowAreaYMin}),n.plotWindowArea.max.copy({x:e.windowAreaXMax,y:e.windowAreaYMax}),n.customPrintScale={numerator:e.printScaleNumerator,denominator:e.printScaleDenominator},n.plotPaperUnits=e.plotPaperUnit,n.plotRotation=e.plotRotation,n.plotType=e.plotType,n.stdScaleType=e.standardScaleType,n.shadePlot=(()=>{switch(e.shadePlotMode){case 1:return i.AcDbPlotShadePlotType.kWireframe;case 2:return i.AcDbPlotShadePlotType.kHidden;case 3:return i.AcDbPlotShadePlotType.kRendered;default:return i.AcDbPlotShadePlotType.kAsDisplayed}})(),n.shadePlotResLevel=(()=>{switch(e.shadePlotResolution){case 1:return i.AcDbPlotShadePlotResLevel.kPreview;case 2:return i.AcDbPlotShadePlotResLevel.kNormal;case 3:return i.AcDbPlotShadePlotResLevel.kPresentation;case 4:return i.AcDbPlotShadePlotResLevel.kMaximum;case 5:return i.AcDbPlotShadePlotResLevel.kCustom;default:return i.AcDbPlotShadePlotResLevel.kDraft}})(),e.shadePlotCustomDPI!=null&&(n.shadePlotCustomDPI=e.shadePlotCustomDPI),e.shadePlotId&&(n.shadePlotId=e.shadePlotId);const r=e.layoutFlag??0;if(n.plotViewportBorders=(r&1)!==0,n.showPlotStyles=(r&2)!==0,n.plotCentered=(r&4)!==0,n.plotHidden=(r&8)!==0,n.useStandardScale=(r&16)!==0,n.plotPlotStyles=(r&32)!==0,n.scaleLineweights=(r&64)!==0,n.printLineweights=(r&128)!==0,n.drawViewportsFirst=(r&512)!==0,n.modelType=(r&1024)!==0,e.viewportId&&n.viewportArray.push(e.viewportId),e.layoutName==="Model"){const l=i.AcDbBlockTableRecord.MODEL_SPACE_NAME.toUpperCase();(a=t.tables.BLOCK_RECORD)==null||a.entries.some(d=>d.name.toUpperCase()===l?(n.blockTableRecordId=d.handle,!0):!1)}else(o=t.tables.BLOCK_RECORD)==null||o.entries.some(l=>l.layoutObjects===e.handle?(n.blockTableRecordId=l.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=e.paperSpaceTableId);return e.minLimit&&n.limits.min.copy(e.minLimit),e.maxLimit&&n.limits.max.copy(e.maxLimit),e.minExtent&&n.extents.min.copy(e.minExtent),e.maxExtent&&n.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,n),n}convertImageDef(e){const t=new i.AcDbRasterImageDef;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}convertMLeaderStyle(e){const t=new i.AcDbMLeaderStyle;return t.unknown1=e.unknown1,e.contentType!=null&&(t.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(t.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(t.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(t.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(t.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(t.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(t.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(t.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(t.landingEnabled=e.landingEnabled),e.landingGap!=null&&(t.landingGap=e.landingGap),e.doglegEnabled!=null&&(t.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(t.doglegLength=e.doglegLength),e.description!=null&&(t.description=e.description),t.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(t.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(t.defaultMTextContents=e.defaultMTextContents),t.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(t.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(t.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(t.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(t.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),e.textHeight!=null&&(t.textHeight=e.textHeight),e.textFrameEnabled!=null&&(t.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(t.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(t.alignSpace=e.alignSpace),t.blockContentId=e.blockContentId,e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),e.blockContentScale&&(t.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:e.blockContentScale.z??1}),e.blockContentScaleEnabled!=null&&(t.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(t.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(t.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(t.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(t.scale=e.scale),e.overwritePropertyValue!=null&&(t.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(t.annotative=e.annotative),e.breakGapSize!=null&&(t.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(t.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(t.topTextAttachmentDirection=e.topTextAttachmentDirection),t.unknown2=e.unknown2,this.processCommonAttrs(e,t),t}convertMLineStyle(e){var r;const t=new i.AcDbMlineStyle;if(e.styleName!=null&&(t.styleName=e.styleName),e.flags!=null&&(t.flags=e.flags),e.description!=null&&(t.description=e.description),e.fillColor!=null)t.fillColor=new i.AcCmColor().setRGBValue(e.fillColor);else if(e.fillColorIndex!=null){const a=new i.AcCmColor;a.colorIndex=e.fillColorIndex,t.fillColor=a}e.startAngle!=null&&(t.startAngle=e.startAngle),e.endAngle!=null&&(t.endAngle=e.endAngle);const n=Math.max(e.elementCount??0,((r=e.elements)==null?void 0:r.length)??0);return n>0&&(t.elements=Array.from({length:n},(a,o)=>{var l,d,f,c;return{offset:((d=(l=e.elements)==null?void 0:l[o])==null?void 0:d.offset)??0,color:(()=>{var p,E,I,L;const s=new i.AcCmColor;return((E=(p=e.elements)==null?void 0:p[o])==null?void 0:E.color)!=null?s.setRGBValue(e.elements[o].color):s.colorIndex=((L=(I=e.elements)==null?void 0:I[o])==null?void 0:L.colorIndex)??256,s})(),lineType:((c=(f=e.elements)==null?void 0:f[o])==null?void 0:c.lineType)??"BYLAYER"}})),this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}}class tt extends i.AcDbDatabaseConverter{constructor(e={}){super(e),this.config.parserWorkerUrl||(this.config.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e,t){const n=this.config,r=this.getParserWorkerTimeout(e,t);if(n.useWorker&&n.parserWorkerUrl){const a=i.createWorkerApi({workerUrl:n.parserWorkerUrl,timeout:r,maxConcurrentWorkers:1}),o=await a.execute(e);return a.destroy(),i.AcDbOpenDatabaseError.throwOnWorkerParseFailure(o),{model:o.data,data:{unknownEntityCount:0}}}else throw new Error("dxf converter can run in web worker only!")}getFonts(e){var a,o,l,d,f;const t=e.blocks??{},n=new Map;for(const c of((o=(a=e.tables)==null?void 0:a.DIMSTYLE)==null?void 0:o.entries)??[])n.set(c.name,c.DIMTXSTY||i.DEFAULT_TEXT_STYLE);const r=[...e.entities??[]];for(const c of Object.values(t))(l=c.entities)!=null&&l.length&&r.push(...c.entities);return new i.AcDbFontNameCollector({styles:((d=e.tables.STYLE)==null?void 0:d.entries)??[],textStyleVar:((f=e.header)==null?void 0:f.$TEXTSTYLE)||i.DEFAULT_TEXT_STYLE}).collect(r,{getEntityFontInfo:c=>{if(c.type=="MTEXT"){const s=c;return{styleName:s.styleName,formattedText:s.text,resolveStyle:!0}}if(c.type=="TEXT"||c.type=="ATTRIB"||c.type=="ATTDEF")return{styleName:c.styleName,resolveStyle:!0};if(c.type=="MULTILEADER"||c.type=="MLEADER"){const s=c,p=typeof s.textContent=="string"?s.textContent:"";return{styleName:typeof s.textStyleName=="string"?s.textStyleName:typeof s.styleName=="string"?s.styleName:void 0,formattedText:p,resolveStyle:!0}}if(c.type=="TOLERANCE"){const s=c;return{styleName:this.resolveDimStyleTextStyle(n,s.styleName),formattedText:s.text,resolveStyle:!0}}if(c.type=="INSERT")return{blockName:c.name};if(c.type=="DIMENSION"){const s=c;return s.name?{blockName:s.name}:null}return null},getBlockEntities:c=>{var s;return(s=t[c])==null?void 0:s.entities}})}resolveDimStyleTextStyle(e,t){const n=t==null?void 0:t.trim();if(!n)return;const r=e.get(n);if(r)return r;const a=n.toUpperCase();for(const[o,l]of e)if(o.toUpperCase()===a)return l}async processEntities(e,t,n,r,a){const o=new Ye;let l=e.entities;const d=l.length,f=new i.AcDbBatchProcessing(d,100-r.value,n);this.config.convertByEntityType&&(l=this.groupAndFlattenByType(l));const c=new Map;for(let p=0;p<d;p++){const E=l[p];if(E.type==="ATTRIB"){const I=o.convert(E);if(I&&I.ownerId&&I.ownerId!=="0"){let L=c.get(I==null?void 0:I.ownerId);L==null&&(L=[],c.set(I.ownerId,L)),L.push(I)}}}const s=t.tables.blockTable.modelSpace;await f.processChunk(async(p,E)=>{let I=[],L=p<E?l[p].type:"";for(let ne=p;ne<E;ne++){const U=l[ne];if(!(U.ownerBlockRecordSoftId&&U.ownerBlockRecordSoftId!==s.objectId)&&U.type!=="ATTRIB"){const Ee=o.convert(U);if(Ee){if(this.config.convertByEntityType&&U.type!==L&&(s.appendEntity(I),I=[],L=U.type),U.type==="INSERT"){const Se=c.get(Ee.objectId);Se&&Se.length>0&&Se.forEach(g=>{Ee.appendAttributes(g)})}I.push(Ee)}}}s.appendEntity(I);let V=r.value+E/d*(100-r.value);V>100&&(V=100),a&&await a(V,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(e,t,n=!1){const r=new Ye,a=e.length,o=[],l=t.objectId,d=[];for(let f=0;f<a;f++){const c=e[f],s=r.convert(c);s&&(c.type==="ATTRIB"?d.push(s):(!n||c.ownerBlockRecordSoftId===l)&&o.push(s))}t.appendEntity(o),d.forEach(f=>{const c=t.getIdAt(f.ownerId);c&&c.appendAttributes(f)})}processBlocks(e,t){const n=e.blocks;for(const[r,a]of Object.entries(n)){let o=t.tables.blockTable.getAt(a.name);o||(o=new i.AcDbBlockTableRecord,a.handle!=null&&(o.objectId=String(a.handle)),o.name=r,t.tables.blockTable.add(o)),o.origin.copy(a.position),a.entities?this.processEntitiesInBlock(a.entities,o):o.isPaperSapce&&this.processEntitiesInBlock(e.entities,o,!0)}}processHeader(e,t){const n=e.header;n.$ACADVER&&(t.version=n.$ACADVER),t.cecolor.colorIndex=n.$CECOLOR||256,t.angbase=n.$ANGBASE||0,t.angdir=n.$ANGDIR||0,n.$AUNITS!=null&&(t.aunits=n.$AUNITS),n.$AUPREC!=null&&(t.auprec=n.$AUPREC),n.$LUNITS!=null&&(t.lunits=n.$LUNITS),n.$LUPREC!=null&&(t.luprec=n.$LUPREC),n.$UNITMODE!=null&&(t.unitmode=n.$UNITMODE),n.$MEASUREMENT!=null&&(t.measurement=n.$MEASUREMENT),t.celtype=n.$CELTYPE||i.ByLayer,i.AcDbSysVarManager.instance().setVar(i.AcDbSystemVariables.CETRANSPARENCY,n.$CETRANSPARENCY||"ByLayer",t),t.celtscale=n.$CELTSCALE||1;const r=this.normalizeHeaderStringValue(n.$CMLSTYLE)||this.normalizeHeaderStringValue(n.CMLSTYLE)||i.DEFAULT_MLINE_STYLE;t.cmlstyle=r;const a=n.$CMLSCALE??n.CMLSCALE;typeof a=="number"&&Number.isFinite(a)&&(t.cmlscale=a);const o=this.normalizeHeaderStringValue(n.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(n.CMLEADERSTYLE)||i.DEFAULT_MLEADER_STYLE;t.cmleaderstyle=o,t.hplayer=this.normalizeHeaderStringValue(n.$HPLAYER)||this.normalizeHeaderStringValue(n.HPLAYER)||".",t.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(t.extmax=n.$EXTMAX),n.$EXTMIN&&(t.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(t.insunits=n.$INSUNITS),t.osmode=n.$OSMODE||0,t.orthomode=n.$ORTHOMODE||0,t.pdmode=n.$PDMODE||0,t.pdsize=n.$PDSIZE||0,t.textstyle=n.$TEXTSTYLE||i.DEFAULT_TEXT_STYLE,n.$HANDSEED!=null&&t.initializeHandleSeed(String(n.$HANDSEED))}processBlockTables(e,t){var r;const n=(r=e.tables.BLOCK_RECORD)==null?void 0:r.entries;n&&n.length>0&&(t.tables.blockTable.removeAll(),n.forEach(a=>{const o=new i.AcDbBlockTableRecord;o.objectId=a.handle,o.name=a.name,o.layoutId=a.layoutObjects,o.blockInsertUnits=a.insertionUnits,o.explodability=a.explodability,o.blockScaling=a.scalability,a.bmpPreview&&(o.bmpPreview=a.bmpPreview),t.tables.blockTable.add(o)}))}processObjects(e,t){const n=e.objects.byName,r=new et;if("LAYOUT"in n){const a=t.objects.layout;n.LAYOUT.forEach(o=>{const l=r.convertLayout(o,e);a.setAt(l.layoutName,l)})}if("IMAGEDEF"in n){const a=t.objects.imageDefinition;n.IMAGEDEF.forEach(o=>{const l=r.convertImageDef(o);a.setAt(l.objectId,l)})}if("MLEADERSTYLE"in n){const a=t.objects.mleaderStyle;n.MLEADERSTYLE.forEach(o=>{const l=r.convertMLeaderStyle(o);a.setAt(l.objectId,l)})}if("MLINESTYLE"in n){const a=t.objects.mlineStyle;n.MLINESTYLE.forEach(o=>{const l=r.convertMLineStyle(o);a.setAt(l.styleName||l.objectId,l)})}}processViewports(e,t){var r;const n=(r=e.tables)==null?void 0:r.VPORT;if(n){this.processCommonTableAttrs(n,t.tables.viewportTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const l=new i.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(o,l),o.circleSides&&(l.circleSides=o.circleSides),l.standardFlag=o.standardFlag,l.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.lowerLeftCorner.copy(o.lowerLeftCorner??i.VPORT_FALLBACK_LLC),l.upperRightCorner.copy(o.upperRightCorner??i.VPORT_FALLBACK_URC),o.snapBasePoint&&l.snapBase.copy(o.snapBasePoint),o.snapRotationAngle&&(l.snapAngle=o.snapRotationAngle),o.snapSpacing&&l.snapIncrements.copy(o.snapSpacing),o.majorGridLines&&(l.gridMajor=o.majorGridLines),o.gridSpacing&&l.gridIncrements.copy(o.gridSpacing),o.backgroundObjectId&&(l.backgroundObjectId=o.backgroundObjectId),l.gsView.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget??i.VPORT_FALLBACK_VIEW_DIR),l.gsView.viewTarget.copy(o.viewTarget??i.VPORT_FALLBACK_VIEW_TARGET),o.lensLength&&(l.gsView.lensLength=o.lensLength),o.frontClippingPlane&&(l.gsView.frontClippingPlane=o.frontClippingPlane),o.backClippingPlane&&(l.gsView.backClippingPlane=o.backClippingPlane),o.viewHeight&&(l.gsView.viewHeight=o.viewHeight),o.aspectRatio!=null&&Number.isFinite(o.aspectRatio)&&o.aspectRatio>0&&(l.gsView.aspectRatio=o.aspectRatio),o.viewTwistAngle&&(l.gsView.viewTwistAngle=o.viewTwistAngle),o.frozenLayers&&(l.gsView.frozenLayers=o.frozenLayers),o.styleSheet&&(l.gsView.styleSheet=o.styleSheet),o.renderMode&&(l.gsView.renderMode=o.renderMode),o.viewMode&&(l.gsView.viewMode=o.viewMode),o.ucsIconSetting&&(l.gsView.ucsIconSetting=o.ucsIconSetting),o.ucsOrigin&&l.gsView.ucsOrigin.copy(o.ucsOrigin),o.ucsXAxis&&l.gsView.ucsXAxis.copy(o.ucsXAxis),o.ucsYAxis&&l.gsView.ucsYAxis.copy(o.ucsYAxis),o.orthographicType&&(l.gsView.orthographicType=o.orthographicType),o.shadePlotSetting&&(l.gsView.shadePlotSetting=o.shadePlotSetting),o.shadePlotObjectId&&(l.gsView.shadePlotObjectId=o.shadePlotObjectId),o.visualStyleObjectId&&(l.gsView.visualStyleObjectId=o.visualStyleObjectId),o.isDefaultLightingOn&&(l.gsView.isDefaultLightingOn=o.isDefaultLightingOn),o.defaultLightingType&&(l.gsView.defaultLightingType=o.defaultLightingType),o.brightness&&(l.gsView.brightness=o.brightness),o.contrast&&(l.gsView.contrast=o.contrast),o.ambientColor&&(l.gsView.ambientColor=o.ambientColor),t.tables.viewportTable.add(l)})}}processLayers(e,t){var r;const n=(r=e.tables)==null?void 0:r.LAYER;if(n){this.processCommonTableAttrs(n,t.tables.layerTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const l=new i.AcCmColor;l.colorIndex=o.colorIndex;const d=new i.AcDbLayerTableRecord({name:o.name,standardFlags:o.standardFlag,linetype:o.lineType,lineWeight:o.lineweight,isOff:o.colorIndex<0,color:l,isPlottable:o.isPlotting});this.processCommonTableEntryAttrs(o,d),t.tables.layerTable.add(d)})}t.ensureTextStyleDefaults()}processLineTypes(e,t){var r;const n=(r=e.tables)==null?void 0:r.LTYPE;if(n){this.processCommonTableAttrs(n,t.tables.linetypeTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const l=new i.AcDbLinetypeTableRecord({name:o.name,standardFlag:o.standardFlag,description:o.description,totalPatternLength:o.totalPatternLength,pattern:o.pattern});this.processCommonTableEntryAttrs(o,l),t.tables.linetypeTable.add(l)})}}processTextStyles(e,t){var r;const n=(r=e.tables)==null?void 0:r.STYLE;if(n){this.processCommonTableAttrs(n,t.tables.textStyleTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const l=new i.AcDbTextStyleTableRecord({name:o.name,standardFlag:o.standardFlag,fixedTextHeight:o.fixedTextHeight,widthFactor:o.widthFactor,obliqueAngle:o.obliqueAngle,textGenerationFlag:o.textGenerationFlag,lastHeight:o.lastHeight,font:o.font,bigFont:o.bigFont,extendedFont:o.extendedFont});this.processCommonTableEntryAttrs(o,l),t.tables.textStyleTable.add(l)})}}processDimStyles(e,t){var r;const n=(r=e.tables)==null?void 0:r.DIMSTYLE;if(n){this.processCommonTableAttrs(n,t.tables.dimStyleTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const l={name:o.name,ownerId:o.ownerObjectId,dimpost:o.DIMPOST||"",dimapost:o.DIMAPOST||"",dimscale:o.DIMSCALE,dimasz:o.DIMASZ,dimexo:o.DIMEXO,dimdli:o.DIMDLI,dimexe:o.DIMEXE,dimrnd:o.DIMRND,dimdle:o.DIMDLE,dimtp:o.DIMTP,dimtm:o.DIMTM,dimtxt:o.DIMTXT,dimcen:o.DIMCEN,dimtsz:o.DIMTSZ,dimaltf:o.DIMALTF,dimlfac:o.DIMLFAC,dimtvp:o.DIMTVP,dimtfac:o.DIMTFAC,dimgap:o.DIMGAP,dimaltrnd:o.DIMALTRND,dimtol:o.DIMTOL==null||o.DIMTOL==0?0:1,dimlim:o.DIMLIM==null||o.DIMLIM==0?0:1,dimtih:o.DIMTIH==null||o.DIMTIH==0?0:1,dimtoh:o.DIMTOH==null||o.DIMTOH==0?0:1,dimse1:o.DIMSE1==null||o.DIMSE1==0?0:1,dimse2:o.DIMSE2==null||o.DIMSE2==0?0:1,dimtad:o.DIMTAD,dimzin:o.DIMZIN,dimazin:o.DIMAZIN,dimalt:o.DIMALT,dimaltd:o.DIMALTD,dimtofl:o.DIMTOFL,dimsah:o.DIMSAH,dimtix:o.DIMTIX,dimsoxd:o.DIMSOXD,dimclrd:o.DIMCLRD,dimclre:o.DIMCLRE,dimclrt:o.DIMCLRT,dimadec:o.DIMADEC||0,dimunit:o.DIMUNIT||2,dimdec:o.DIMDEC,dimtdec:o.DIMTDEC,dimaltu:o.DIMALTU,dimalttd:o.DIMALTTD,dimaunit:o.DIMAUNIT,dimfrac:o.DIMFRAC,dimlunit:o.DIMLUNIT,dimdsep:o.DIMDSEP?o.DIMDSEP.toString():".",dimtmove:o.DIMTMOVE||0,dimjust:o.DIMJUST,dimsd1:o.DIMSD1,dimsd2:o.DIMSD2,dimtolj:o.DIMTOLJ,dimtzin:o.DIMTZIN,dimaltz:o.DIMALTZ,dimalttz:o.DIMALTTZ,dimfit:o.DIMFIT||0,dimupt:o.DIMUPT,dimatfit:o.DIMATFIT,dimtxsty:o.DIMTXSTY||i.DEFAULT_TEXT_STYLE,dimldrblk:o.DIMLDRBLK||"",dimblk:o.DIMBLK||"",dimblk1:o.DIMBLK1||"",dimblk2:o.DIMBLK2||"",dimlwd:o.DIMLWD,dimlwe:o.DIMLWE},d=new i.AcDbDimStyleTableRecord(l);this.processCommonTableEntryAttrs(o,d),t.tables.dimStyleTable.add(d)})}}processCommonTableAttrs(e,t,n){e.handle!=null&&n.adoptExternalHandle(t,e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}processCommonTableEntryAttrs(e,t){t.name="name"in e?e.name:"",e.handle!=null&&(t.objectId=e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}groupAndFlattenByType(e){const t={},n=[];for(const r of e)t[r.type]||(t[r.type]=[],n.push(r.type)),t[r.type].push(r);return n.flatMap(r=>t[r])}normalizeHeaderStringValue(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}}oe.AcDbDxfConverter=tt,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(ie,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@mlightcad/data-model")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model"],r):(ie=typeof globalThis<"u"?globalThis:ie||self,r(ie["dxf-json-converter"]={},ie.dataModel))})(this,function(ie,r){"use strict";var C,be,E,S,Pe,B,re,G,N,W,k,ae,se,le,R,Y,me,Ne,ce,de,Oe,ye,Re,x,j,I,ue,xe,f,O,we,y,_e,z,D,X,Me,fe,U,Fe,Ye,Ve,$,K,ve,Be,Z,Ae,De,ke,Ie,q,pe,b,J,w,Te,_,Q,P,ee,M,he,Ue,ge,F,te,V,ne,je,Ee,v;(C={})[C.None=0]="None",C[C.Anonymous=1]="Anonymous",C[C.NonConstant=2]="NonConstant",C[C.Xref=4]="Xref",C[C.XrefOverlay=8]="XrefOverlay",C[C.ExternallyDependent=16]="ExternallyDependent",C[C.ResolvedOrDependent=32]="ResolvedOrDependent",C[C.ReferencedXref=64]="ReferencedXref",(be={})[be.BYBLOCK=0]="BYBLOCK",be[be.BYLAYER=256]="BYLAYER",(E={})[E.Rotated=0]="Rotated",E[E.Aligned=1]="Aligned",E[E.Angular=2]="Angular",E[E.Diameter=3]="Diameter",E[E.Radius=4]="Radius",E[E.Angular3Point=5]="Angular3Point",E[E.Ordinate=6]="Ordinate",E[E.ReferenceIsExclusive=32]="ReferenceIsExclusive",E[E.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",E[E.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(S={})[S.TopLeft=1]="TopLeft",S[S.TopCenter=2]="TopCenter",S[S.TopRight=3]="TopRight",S[S.MiddleLeft=4]="MiddleLeft",S[S.MiddleCenter=5]="MiddleCenter",S[S.MiddleRight=6]="MiddleRight",S[S.BottomLeft=7]="BottomLeft",S[S.BottomCenter=8]="BottomCenter",S[S.BottomRight=9]="BottomRight",(Pe={})[Pe.AtLeast=1]="AtLeast",Pe[Pe.Exact=2]="Exact";var Xe=((B={})[B.Center=0]="Center",B[B.Above=1]="Above",B[B.Outside=2]="Outside",B[B.JIS=3]="JIS",B[B.Below=4]="Below",B);(re={})[re.WithDimension=0]="WithDimension",re[re.AddLeader=1]="AddLeader",re[re.Independent=2]="Independent",(G={})[G.BothOutside=0]="BothOutside",G[G.ArrowFirst=1]="ArrowFirst",G[G.TextFirst=2]="TextFirst",G[G.Auto=3]="Auto";var Le=((N={})[N.Feet=0]="Feet",N[N.None=1]="None",N[N.Inch=2]="Inch",N[N.FeetAndInch=3]="FeetAndInch",N[N.Leading=4]="Leading",N[N.Trailing=8]="Trailing",N[N.LeadingAndTrailing=12]="LeadingAndTrailing",N),qe=((W={})[W.None=0]="None",W[W.Leading=1]="Leading",W[W.Trailing=2]="Trailing",W[W.LeadingAndTrailing=3]="LeadingAndTrailing",W),Je=((k={})[k.Center=0]="Center",k[k.First=1]="First",k[k.Second=2]="Second",k[k.OverFirst=3]="OverFirst",k[k.OverSecond=4]="OverSecond",k),Qe=((ae={})[ae.Bottom=0]="Bottom",ae[ae.Center=1]="Center",ae[ae.Top=2]="Top",ae);(se={})[se.None=0]="None",se[se.UseDrawingBackground=1]="UseDrawingBackground",se[se.Custom=2]="Custom",(le={})[le.Horizontal=0]="Horizontal",le[le.Diagonal=1]="Diagonal",le[le.NotStacked=2]="NotStacked",(R={})[R.Scientific=1]="Scientific",R[R.Decimal=2]="Decimal",R[R.Engineering=3]="Engineering",R[R.Architectural=4]="Architectural",R[R.Fractional=5]="Fractional",R[R.WindowDesktop=6]="WindowDesktop",(Y={})[Y.Decimal=0]="Decimal",Y[Y.DegreesMinutesSecond=1]="DegreesMinutesSecond",Y[Y.Gradian=2]="Gradian",Y[Y.Radian=3]="Radian";var et=((me={})[me.PatternFill=0]="PatternFill",me[me.SolidFill=1]="SolidFill",me);(Ne={})[Ne.NonAssociative=0]="NonAssociative",Ne[Ne.Associative=1]="Associative",(ce={})[ce.Normal=0]="Normal",ce[ce.Outer=1]="Outer",ce[ce.Ignore=2]="Ignore",(de={})[de.UserDefined=0]="UserDefined",de[de.Predefined=1]="Predefined",de[de.Custom=2]="Custom",(Oe={})[Oe.NotAnnotated=0]="NotAnnotated",Oe[Oe.Annotated=1]="Annotated",(ye={})[ye.Solid=0]="Solid",ye[ye.Gradient=1]="Gradient",(Re={})[Re.TwoColor=0]="TwoColor",Re[Re.OneColor=1]="OneColor",(x={})[x.Default=0]="Default",x[x.External=1]="External",x[x.Polyline=2]="Polyline",x[x.Derived=4]="Derived",x[x.Textbox=8]="Textbox",x[x.Outermost=16]="Outermost",(j={})[j.Line=1]="Line",j[j.Circular=2]="Circular",j[j.Elliptic=3]="Elliptic",j[j.Spline=4]="Spline";var tt=((I={})[I.Off=0]="Off",I[I.Solid=1]="Solid",I[I.Dashed=2]="Dashed",I[I.Dotted=3]="Dotted",I[I.ShotDash=4]="ShotDash",I[I.MediumDash=5]="MediumDash",I[I.LongDash=6]="LongDash",I[I.DoubleShortDash=7]="DoubleShortDash",I[I.DoubleMediumDash=8]="DoubleMediumDash",I[I.DoubleLongDash=9]="DoubleLongDash",I[I.DoubleMediumLongDash=10]="DoubleMediumLongDash",I[I.SparseDot=11]="SparseDot",I);tt.Off,(ue={})[ue.Standard=-3]="Standard",ue[ue.ByLayer=-2]="ByLayer",ue[ue.ByBlock=-1]="ByBlock",(xe={})[xe.English=0]="English",xe[xe.Metric=1]="Metric",(f={})[f.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",f[f.FRONT_CLIPPING=2]="FRONT_CLIPPING",f[f.BACK_CLIPPING=4]="BACK_CLIPPING",f[f.UCS_FOLLOW=8]="UCS_FOLLOW",f[f.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",f[f.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",f[f.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",f[f.FAST_ZOOM=128]="FAST_ZOOM",f[f.SNAP_MODE=256]="SNAP_MODE",f[f.GRID_MODE=512]="GRID_MODE",f[f.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",f[f.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",f[f.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",f[f.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",f[f.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",f[f.UNUSED=32768]="UNUSED",f[f.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",f[f.VIEWPORT_OFF=131072]="VIEWPORT_OFF",f[f.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",f[f.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",f[f.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",f[f.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(O={})[O.OPTIMIZED_2D=0]="OPTIMIZED_2D",O[O.WIREFRAME=1]="WIREFRAME",O[O.HIDDEN_LINE=2]="HIDDEN_LINE",O[O.FLAT_SHADED=3]="FLAT_SHADED",O[O.GOURAUD_SHADED=4]="GOURAUD_SHADED",O[O.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",O[O.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(we={})[we.UCS_UNCHANGED=0]="UCS_UNCHANGED",we[we.HAS_OWN_UCS=1]="HAS_OWN_UCS",(y={})[y.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",y[y.TOP=1]="TOP",y[y.BOTTOM=2]="BOTTOM",y[y.FRONT=3]="FRONT",y[y.BACK=4]="BACK",y[y.LEFT=5]="LEFT",y[y.RIGHT=6]="RIGHT",(_e={})[_e.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",_e[_e.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",(z={})[z.ByLayer=0]="ByLayer",z[z.ByBlock=1]="ByBlock",z[z.ByDictionaryDefault=2]="ByDictionaryDefault",z[z.ByObject=3]="ByObject",(D={})[D.NotAllowed=0]="NotAllowed",D[D.AllowErase=1]="AllowErase",D[D.AllowTransform=2]="AllowTransform",D[D.AllowChangeColor=4]="AllowChangeColor",D[D.AllowChangeLayer=8]="AllowChangeLayer",D[D.AllowChangeLinetype=16]="AllowChangeLinetype",D[D.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",D[D.AllowChangeVisibility=64]="AllowChangeVisibility",D[D.AllowClone=128]="AllowClone",D[D.AllowChangeLineweight=256]="AllowChangeLineweight",D[D.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",D[D.AllowAllExceptClone=895]="AllowAllExceptClone",D[D.AllowAll=1023]="AllowAll",D[D.DisableProxyWarning=1024]="DisableProxyWarning",D[D.R13FormatProxy=32768]="R13FormatProxy",(X={})[X.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",X[X.CAST=1]="CAST",X[X.RECEIVE=2]="RECEIVE",X[X.IGNORE=3]="IGNORE",(Me={})[Me.RayTrace=0]="RayTrace",Me[Me.ShadowMap=1]="ShadowMap",(fe={})[fe.BeforeText=0]="BeforeText",fe[fe.AboveText=1]="AboveText",fe[fe.None=2]="None",(U={})[U.NONE=0]="NONE",U[U.INVISIBLE=1]="INVISIBLE",U[U.CONSTANT=2]="CONSTANT",U[U.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",U[U.PRESET=8]="PRESET",(Fe={})[Fe.MULTILINE=2]="MULTILINE",Fe[Fe.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Ye={})[Ye.ProxyEntity=498]="ProxyEntity",(Ve={})[Ve.Dwg=0]="Dwg",Ve[Ve.Dxf=1]="Dxf",($={})[$.First=1]="First",$[$.Second=2]="Second",$[$.Third=4]="Third",$[$.Fourth=8]="Fourth",(K={})[K.ShowImage=1]="ShowImage",K[K.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",K[K.UseClippingBoundary=4]="UseClippingBoundary",K[K.TransparencyIsOn=8]="TransparencyIsOn",(ve={})[ve.Rectangular=1]="Rectangular",ve[ve.Polygonal=2]="Polygonal",(Be={})[Be.Outside=0]="Outside",Be[Be.Inside=1]="Inside",(Z={})[Z.TextAnnotation=0]="TextAnnotation",Z[Z.ToleranceAnnotation=1]="ToleranceAnnotation",Z[Z.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",Z[Z.NoAnnotation=3]="NoAnnotation",(Ae={})[Ae.Distant=1]="Distant",Ae[Ae.Point=2]="Point",Ae[Ae.Spot=3]="Spot",(De={})[De.None=0]="None",De[De.InverseLinear=1]="InverseLinear",De[De.InverseSquare=2]="InverseSquare",(ke={})[ke.IS_CLOSED=1]="IS_CLOSED",ke[ke.PLINE_GEN=128]="PLINE_GEN",(Ie={})[Ie.Top=0]="Top",Ie[Ie.Zero=1]="Zero",Ie[Ie.Bottom=2]="Bottom",(q={})[q.HasVertex=1]="HasVertex",q[q.Closed=2]="Closed",q[q.SuppressStartCaps=4]="SuppressStartCaps",q[q.SuppressEndCaps=8]="SuppressEndCaps",(pe={})[pe.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",pe[pe.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",pe[pe.BY_STYLE=5]="BY_STYLE",(b={})[b.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",b[b.CURVE_FIT=2]="CURVE_FIT",b[b.SPLINE_FIT=4]="SPLINE_FIT",b[b.POLYLINE_3D=8]="POLYLINE_3D",b[b.POLYGON_3D=16]="POLYGON_3D",b[b.CLOSED_POLYGON=32]="CLOSED_POLYGON",b[b.POLYFACE=64]="POLYFACE",b[b.CONTINUOUS=128]="CONTINUOUS";var He=((J={})[J.NONE=0]="NONE",J[J.QUADRATIC=5]="QUADRATIC",J[J.CUBIC=6]="CUBIC",J[J.BEZIER=8]="BEZIER",J);(w={})[w.NONE=0]="NONE",w[w.CLOSED=1]="CLOSED",w[w.PERIODIC=2]="PERIODIC",w[w.RATIONAL=4]="RATIONAL",w[w.PLANAR=8]="PLANAR",w[w.LINEAR=16]="LINEAR",(Te={})[Te.NONE=0]="NONE",Te[Te.MIRRORED_X=2]="MIRRORED_X",Te[Te.MIRRORED_Y=4]="MIRRORED_Y",(_={})[_.LEFT=0]="LEFT",_[_.CENTER=1]="CENTER",_[_.RIGHT=2]="RIGHT",_[_.ALIGNED=3]="ALIGNED",_[_.MIDDLE=4]="MIDDLE",_[_.FIT=5]="FIT",(Q={})[Q.BASELINE=0]="BASELINE",Q[Q.BOTTOM=1]="BOTTOM",Q[Q.MIDDLE=2]="MIDDLE",Q[Q.TOP=3]="TOP";var nt=((P={})[P.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",P[P.TANGENT_DEFINED=2]="TANGENT_DEFINED",P[P.NOT_USED=4]="NOT_USED",P[P.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",P[P.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",P[P.FOR_POLYLINE=32]="FOR_POLYLINE",P[P.FOR_POLYGON=64]="FOR_POLYGON",P[P.POLYFACE=128]="POLYFACE",P);(ee={})[ee.ShowImage=1]="ShowImage",ee[ee.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",ee[ee.UseClippingBoundary=4]="UseClippingBoundary",ee[ee.Transparency=8]="Transparency",(M={})[M.NOT_APPLICABLE=0]="NOT_APPLICABLE",M[M.KEEP_EXISTING=1]="KEEP_EXISTING",M[M.USE_CLONE=2]="USE_CLONE",M[M.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",M[M.VALUE_NAME=4]="VALUE_NAME",M[M.UNMANGLE_NAME=5]="UNMANGLE_NAME",(he={})[he.NOUNIT=0]="NOUNIT",he[he.CENTIMETERS=2]="CENTIMETERS",he[he.INCH=5]="INCH",(Ue={})[Ue.PSLTSCALE=1]="PSLTSCALE",Ue[Ue.LIMCHECK=2]="LIMCHECK",(ge={})[ge.INCHES=0]="INCHES",ge[ge.MILLIMETERS=1]="MILLIMETERS",ge[ge.PIXELS=2]="PIXELS",(F={})[F.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",F[F.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",F[F.DRAWING_LIMITS=2]="DRAWING_LIMITS",F[F.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",F[F.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",F[F.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION",(te={})[te.AS_DISPLAYED=0]="AS_DISPLAYED",te[te.WIREFRAME=1]="WIREFRAME",te[te.HIDDEN=2]="HIDDEN",te[te.RENDERED=3]="RENDERED",(V={})[V.DRAFT=0]="DRAFT",V[V.PREVIEW=1]="PREVIEW",V[V.NORMAL=2]="NORMAL",V[V.PRESENTATION=3]="PRESENTATION",V[V.MAXIMUM=4]="MAXIMUM",V[V.CUSTOM=5]="CUSTOM",Xe.Above,Xe.Center,Le.Trailing,Le.Feet,qe.None,Je.Center,Qe.Center,Le.Trailing,Le.Feet,Le.Trailing,Le.Trailing,(ne={})[ne.NONE=0]="NONE",ne[ne.AbsoluteRotation=1]="AbsoluteRotation",ne[ne.TextEmbedded=2]="TextEmbedded",ne[ne.ShapeEmbedded=4]="ShapeEmbedded",(je={})[je.PaperSpace=1]="PaperSpace",(Ee={})[Ee.XrefDependent=16]="XrefDependent",Ee[Ee.XrefResolved=32]="XrefResolved",Ee[Ee.Referenced=64]="Referenced",(v={})[v.Off=0]="Off",v[v.Perspective=1]="Perspective",v[v.ClipFront=2]="ClipFront",v[v.ClipBack=4]="ClipBack",v[v.UcsFollow=8]="UcsFollow",v[v.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";const ot=new Set(["ACSH_SWEEP_CLASS","ACSH_BREP_CLASS","ACSH_EXTRUSION_CLASS","ACSH_REVOLVE_CLASS","ACSH_LOFT_CLASS"]);function it(u,e){if(!u||!e)return"";const t=e[Ge(u)];if(!t||t.name!=="ACSH_HISTORY_CLASS")return"";const n=t.evalGraphHardId;if(!n)return"";const i=e[Ge(n)];if(!i||i.name!=="ACAD_EVALUATION_GRAPH")return"";const a=i.nodeObjectHardIds??[];let o="";for(const d of a){const A=e[Ge(d)];if(!A)continue;const c=rt(A);c&&(o=c)}if(o)return o;const s=[];for(const d of a){const A=e[Ge(d)];A&&s.push(...at(A))}return s.length===0?"":lt(s)}function rt(u){return ot.has(u.name)?u.acisData??"":""}function at(u){switch(u.name){case"ACSH_BOX_CLASS":return $e(u);case"ACSH_CYLINDER_CLASS":return ze(u,e=>{const t=Math.max(e.minorRadius??0,e.majorRadius??0,e.topMajorRadius??0),n=e.height??e.topMajorRadius??0;return{length:t*2,width:t*2,height:n}});case"ACSH_CONE_CLASS":return ze(u,e=>{const t=Math.max(e.baseRadius??0,e.minorRadius??0,e.topRadius??0,e.majorRadius??0),n=e.height??e.topMajorRadius??0;return{length:t*2,width:t*2,height:n}});case"ACSH_WEDGE_CLASS":return ze(u,e=>({length:e.length??0,width:e.width??0,height:e.height??0}));default:return[]}}function ze(u,e){const{length:t,width:n,height:i}=e(u);return t<=0||n<=0||i<=0?[]:$e({name:"ACSH_BOX_CLASS",handle:"",ownerObjectId:"0",length:t,width:n,height:i,transform:u.transform})}function Ge(u){return String(u).trim().toUpperCase()}function $e(u){const e=u.length??0,t=u.width??0,n=u.height??0;if(e<=0||t<=0||n<=0)return[];const i=e/2,a=t/2,o=n/2,s=[{x:-i,y:-a,z:-o},{x:i,y:-a,z:-o},{x:i,y:a,z:-o},{x:-i,y:a,z:-o},{x:-i,y:-a,z:o},{x:i,y:-a,z:o},{x:i,y:a,z:o},{x:-i,y:a,z:o}],d=u.transform;return!d||d.length!==16?s:s.map(A=>st(d,A))}function st(u,e){const t=e.x,n=e.y,i=e.z,a=u[12]*t+u[13]*n+u[14]*i+u[15],o=a!==0&&a!==1?1/a:1;return{x:(u[0]*t+u[1]*n+u[2]*i+u[3])*o,y:(u[4]*t+u[5]*n+u[6]*i+u[7])*o,z:(u[8]*t+u[9]*n+u[10]*i+u[11])*o}}function lt(u){const e=u.map(t=>`point $-1 ${t.x} ${t.y} ${t.z} #`);return e.push("End-of-ACIS-data"),e.join(`
|
|
2
|
+
`)}function ct(u){if(u){if(u instanceof Uint8Array)return u;if(Array.isArray(u))return Uint8Array.from(u);if(typeof u=="object"){const e=u,t=Object.keys(e).filter(n=>/^\d+$/.test(n));if(t.length>0)return Uint8Array.from(t.sort((n,i)=>Number(n)-Number(i)).map(n=>e[n]))}}}class Ke{constructor(){this.objectByHandle={},this.acdsDataByHandle={}}setObjectByHandle(e){this.objectByHandle=e}setAcdsDataByHandle(e={}){this.acdsDataByHandle=e}convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="MLINE"?this.convertMLine(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="TOLERANCE"?this.convertTolerance(e):e.type=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="3DSOLID"?this.convert3dSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):null}convertProxyEntity(e){const t=new r.AcDbProxyEntity;if(t.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(t.originalDxfName=e.originalDxfName),e.objectDrawingFormat!=null&&(t.graphicsMetafileType=e.objectDrawingFormat),e.applicationEntityClassId!=null&&(t.originalClassName=String(e.applicationEntityClassId)),e.graphicsData){const n=r.hexStringsToBytes([e.graphicsData]),i=e.graphicsDataSize??n.length;t.setProxyGraphic(n.subarray(0,i))}return t}convertFace(e){const t=new r.AcDbFace;return e.vertices.forEach((n,i)=>t.setVertexAt(i,n)),t}convertArc(e){const t=e.extrusionDirection??r.AcGeVector3d.Z_AXIS;return new r.AcDbArc(r.transformOcsPointToWcs(e.center,t),e.radius,r.AcGeMathUtil.degToRad(e.startAngle),r.AcGeMathUtil.degToRad(e.endAngle),t)}convertAttributeCommon(e,t){t.textString=e.text,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.alignmentPoint,i=!n||n.x===0&&n.y===0&&(n.z??0)===0;n&&!i?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.tag=e.tag,t.fieldLength=0,t.isInvisible=(e.attributeFlag&r.AcDbAttributeFlags.Invisible)!==0,t.isConst=(e.attributeFlag&r.AcDbAttributeFlags.Const)!==0,t.isVerifiable=(e.attributeFlag&r.AcDbAttributeFlags.Verifiable)!==0,t.isPreset=(e.attributeFlag&r.AcDbAttributeFlags.Preset)!==0,t.isReallyLocked=!!e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&r.AcDbAttributeMTextFlag.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&r.AcDbAttributeMTextFlag.ConstMultiLine)!==0}convertAttribute(e){const t=new r.AcDbAttribute;return this.convertAttributeCommon(e,t),t.styleName=e.textStyle,t.horizontalMode=e.horizontalJustification,t.verticalMode=e.verticalJustification,t.widthFactor=e.scale??1,t.lockPositionInBlock=e.lockPositionFlag,t}convertAttributeDefinition(e){const t=new r.AcDbAttributeDefinition;return this.convertAttributeCommon(e,t),t.styleName=e.styleName,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t.prompt=e.prompt,t}convertCirle(e){const t=e.extrusionDirection??r.AcGeVector3d.Z_AXIS;return new r.AcDbCircle(r.transformOcsPointToWcs(e.center,t),e.radius,t)}convertEllipse(e){const t=new r.AcGeVector3d(e.majorAxisEndPoint),n=t.length();return new r.AcDbEllipse(e.center,e.extrusionDirection??r.AcGeVector3d.Z_AXIS,t,n,n*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,n=e.endPoint;return new r.AcDbLine(new r.AcGePoint3d(t.x,t.y,t.z||0),new r.AcGePoint3d(n.x,n.y,n.z||0))}convertSpline(e){return r.AcDbSpline.fromDwgSpline(e)}convertPoint(e){const t=new r.AcDbPoint;return t.position=e.position,t}convertShape(e){const t=new r.AcDbShape;return t.position.copy(e.insertionPoint),t.size=e.size,t.name=e.shapeName,t.rotation=r.AcGeMathUtil.degToRad(e.rotation||0),t.widthFactor=e.xScale??1,t.oblique=r.AcGeMathUtil.degToRad(e.obliqueAngle||0),t.thickness=e.thickness??0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}convertSolid(e){const t=new r.AcDbTrace;return e.points.forEach((n,i)=>t.setPointAt(i,n)),t.thickness=e.thickness,t}convert3dSolid(e){const t=e.handle?String(e.handle).trim().toUpperCase():"",n=t?ct(this.acdsDataByHandle[t]):void 0;let i=typeof e.data=="string"?e.data:"";return!n&&!i&&e.historyObjectSoftId&&(i=it(e.historyObjectSoftId,this.objectByHandle)),new r.AcDb3dSolid({sabBytes:n,satText:i,version:e.version})}convertPolyline(e){var c;const t=!!(e.flag&1),n=!!(e.flag&8),i=!!(e.flag&16),a=!!(e.flag&64),o=!!(e.flag&32),s=[],d=[],A=[];if((c=e.vertices)==null||c.map(l=>{l.flag&nt.SPLINE_CONTROL_POINT||(a&&l.flag&128?l.flag&64?(s.push({x:l.x,y:l.y,z:l.z}),d.push(l.bulge??0)):l.faces&&l.faces.length>=3&&A.push([...l.faces]):(s.push({x:l.x,y:l.y,z:l.z}),d.push(l.bulge??0)))}),i){const l=e.meshMVertexCount,h=e.meshNVertexCount;return new r.AcDbPolygonMesh(l,h,s,t,o)}else{if(a)return new r.AcDbPolyFaceMesh(s,A);if(n){let l=r.AcDbPoly3dType.SimplePoly;return e.flag&4&&(e.smoothType==He.CUBIC?l=r.AcDbPoly3dType.CubicSplinePoly:e.smoothType==He.QUADRATIC&&(l=r.AcDbPoly3dType.QuadSplinePoly)),new r.AcDb3dPolyline(l,s,t)}else{let l=r.AcDbPoly2dType.SimplePoly;return e.flag&2?l=r.AcDbPoly2dType.FitCurvePoly:e.flag&4&&(e.smoothType==He.CUBIC?l=r.AcDbPoly2dType.CubicSplinePoly:e.smoothType==He.QUADRATIC&&(l=r.AcDbPoly2dType.QuadSplinePoly)),new r.AcDb2dPolyline(l,s,0,t,e.startWidth,e.endWidth,d)}}}convertLWPolyline(e){var i;const t=new r.AcDbPolyline;t.closed=!!(e.flag&1);const n=e.constantWidth??-1;return(i=e.vertices)==null||i.forEach((a,o)=>{t.addVertexAt(o,new r.AcGePoint2d(a.x,a.y),a.bulge,a.startWidth??n,a.endWidth??n)}),t}convertHatch(e){var i;const t=new r.AcDbHatch;if((i=e.definitionLines)==null||i.forEach(a=>{t.definitionLines.push({angle:r.AcGeMathUtil.degToRad(a.angle||0),base:a.base,offset:a.offset,dashLengths:a.numberOfDashLengths>0?a.dashLengths:[]})}),t.isSolidFill=e.solidFill==et.SolidFill,t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:r.AcGeMathUtil.degToRad(e.patternAngle),t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(a=>{if(a.boundaryPathTypeFlag&2){const s=a,d=new r.AcGePolyline2d;d.closed=s.isClosed,s.vertices.forEach((A,c)=>{d.addVertexAt(c,{x:A.x,y:A.y,bulge:A.bulge})}),t.add(d)}else{const s=a,d=[];s.edges.forEach(c=>{if(c.type==1){const l=c;d.push(new r.AcGeLine2d(l.start,l.end))}else if(c.type==2){const l=c;d.push(new r.AcGeCircArc2d(l.center,l.radius,r.AcGeMathUtil.degToRad(l.startAngle||0),r.AcGeMathUtil.degToRad(l.endAngle||0),!l.isCCW))}else if(c.type==3){const l=c;new r.AcGeVector2d().subVectors(l.end,l.center);const T=Math.sqrt(Math.pow(l.end.x,2)+Math.pow(l.end.y,2)),L=T*l.lengthOfMinorAxis;let p=r.AcGeMathUtil.degToRad(l.startAngle||0),m=r.AcGeMathUtil.degToRad(l.endAngle||0);const oe=Math.atan2(l.end.y,l.end.x);l.isCCW||(p=Math.PI*2-p,m=Math.PI*2-m),d.push(new r.AcGeEllipseArc2d({...l.center,z:0},T,L,p,m,!l.isCCW,oe))}else if(c.type==4){const l=r.AcGeSpline3d.fromDwgSplineEdge(c);l&&d.push(l)}});const A=r.AcGeLoop2d.buildFromEdges(d);A.length==0&&d.length>0?t.add(new r.AcGeLoop2d(d)):A.forEach(c=>t.add(c))}}),e.gradientFlag){const a=e;if(t.hatchObjectType=r.AcDbHatchObjectType.GradientObject,t.gradientName=a.gradientName,t.gradientAngle=a.gradientRotation??0,t.gradientShift=a.gradientDefinition??0,t.gradientOneColorMode=a.gradientColorFlag==1,t.shadeTintValue=a.colorTint??0,a.gradientColors){const o=a.gradientColors.length;o>1?(t.gradientStartColor=a.gradientColors[0].rgb,t.gradientEndColor=a.gradientColors[1].rgb):o>0&&(t.gradientStartColor=a.gradientColors[0].rgb)}}return t}convertTable(e){const t=new r.AcDbTable(e.name,e.rowCount,e.columnCount);return t.tableDataVersion=e.version,t.tableStyleId=e.tableStyleId,t.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(t.horizontalDirection=new r.AcGeVector3d(e.directionVector)),t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),t.tableValueFlag=e.tableValue,t.tableOverrideFlag=e.overrideFlag,t.borderColorOverrideFlag=e.borderColorOverrideFlag,t.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,t.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach((n,i)=>t.setColumnWidth(i,n)),e.rowHeightArr.forEach((n,i)=>t.setRowHeight(i,n)),e.cells.forEach((n,i)=>{t.setCell(i,n)}),t}convertText(e){const t=new r.AcDbText;t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.endPoint,i=!n||n.x===0&&n.y===0&&(n.z??0)===0;return n&&!i?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=r.AcGeMathUtil.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertTolerance(e){const t=new r.AcDbFcf;return t.location.copy(e.position),t.text=e.text,t.dimensionStyle=e.styleName??"",e.extrusionDirection&&t.normal.copy(e.extrusionDirection),e.xAxisDirection&&t.direction.copy(e.xAxisDirection),t}convertMText(e){const t=new r.AcDbMText;t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=r.AcGeMathUtil.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new r.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection;const n=this.readMTextExtentsWidth(e);return n!=null&&n>0&&(t.extentsWidth=n),t}readMTextExtentsWidth(e){const t=e;return t.extentsWidth??t.actualWidth}convertLeader(e){var n;const t=new r.AcDbLeader;return(n=e.vertices)==null||n.forEach(i=>{t.appendVertex(i)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isHookLineSameDirection=e.isHooklineSameDirection,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName??"",t.annoType=e.leaderCreationFlag,t.textHeight=e.textHeight??0,t.textWidth=e.textWidth??0,t.byBlockColor=e.byBlockColor,t.associatedAnnotation=e.associatedAnnotation??"",e.normal&&(t.normal=e.normal),e.horizontalDirection&&(t.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(t.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(t.offsetFromAnnotation=e.offsetFromAnnotation),t}convertMLine(e){const t=new r.AcDbMLine;return t.styleName=e.name||"STANDARD",t.styleObjectHandle=e.styleObjectHandle,t.scale=e.scale,t.justification=e.justification,t.flags=e.flags,t.styleCount=e.styleCount,t.startPosition=e.startPosition,t.normal=e.extrusionDirection??r.AcGeVector3d.Z_AXIS,t.segments=(e.segments??[]).map(n=>{var i;return{position:n.position,direction:n.direction,miterDirection:n.miterDirection,elements:((i=n.elements)==null?void 0:i.map(a=>({parameterCount:a.parameterCount,parameters:a.parameters??[],fillCount:a.fillCount,fillParameters:a.fillParameters??[]})))??[]}}),t}convertMLeader(e){var H,Se;const t=new r.AcDbMLeader,n=e;t.version=e.version,t.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(t.mleaderStyleId=e.leaderStyleId),t.propertyOverrideFlag=e.propertyOverrideFlag,t.leaderLineType=e.leaderLineType??r.AcDbMLeaderLineType.StraightLeader,e.leaderLineColor!=null&&(t.leaderLineColor=r.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,t.leaderLineWeight=e.leaderLineWeight,t.landingEnabled=e.landingEnabled,t.doglegEnabled=e.doglegEnabled??!1,t.doglegLength=e.doglegLength??0,t.arrowheadId=e.arrowheadId,t.arrowheadSize=e.arrowheadSize,t.textStyleId=e.textStyleId,t.textLeftAttachmentType=e.textLeftAttachmentType,t.textRightAttachmentType=e.textRightAttachmentType,t.textAngleType=e.textAngleType,t.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(t.textColor=r.decodeMLeaderStyleRawColor(e.textColor)),t.textFrameEnabled=e.textFrameEnabled,t.landingGap=e.landingGap,t.textAttachment=e.textAttachment,t.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(t.blockContentId=e.blockContentId),e.blockContentColor!=null&&(t.blockContentColor=r.decodeMLeaderStyleRawColor(e.blockContentColor)),t.blockContentRotation=e.blockContentRotation,t.blockContentConnectionType=e.blockContentConnectionType,t.annotativeScaleEnabled=e.annotativeScaleEnabled,t.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(g=>({...g})):[],t.blockAttributes=e.blockAttributes?e.blockAttributes.map(g=>({...g})):[],t.textDirectionNegative=e.textDirectionNegative,t.textAlignInIPE=e.textAlignInIPE,t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,t.topTextAttachmentDirection=e.topTextAttachmentDirection,t.contentScale=e.contentScale,t.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(t.textBackgroundColor=r.decodeMLeaderStyleRawColor(e.textBackgroundColor)),t.textBackgroundScaleFactor=e.textBackgroundScaleFactor,t.textBackgroundTransparency=e.textBackgroundTransparency,t.textBackgroundColorOn=e.textBackgroundColorOn,t.textFillOn=e.textFillOn,t.textColumnType=e.textColumnType,t.textUseAutoHeight=e.textUseAutoHeight,t.textColumnWidth=e.textColumnWidth,t.textColumnGutterWidth=e.textColumnGutterWidth,t.textColumnFlowReversed=e.textColumnFlowReversed,t.textColumnHeight=e.textColumnHeight,t.textUseWordBreak=e.textUseWordBreak,t.hasMText=e.hasMText,t.hasBlock=e.hasBlock,t.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(t.blockContentScale=new r.AcGeVector3d(e.blockContentScale)),e.contentBasePosition&&(t.contentBasePosition=new r.AcGePoint3d().copy(e.contentBasePosition)),e.textAnchor&&(t.textAnchor=new r.AcGePoint3d().copy(e.textAnchor)),e.planeOrigin&&(t.planeOrigin=new r.AcGePoint3d().copy(e.planeOrigin)),e.planeXAxisDirection&&(t.planeXAxisDirection=new r.AcGeVector3d(e.planeXAxisDirection)),e.planeYAxisDirection&&(t.planeYAxisDirection=new r.AcGeVector3d(e.planeYAxisDirection));const i=n.textContent,a=i&&typeof i=="object"?i:void 0,o=typeof i=="string"&&i.length>0||this.readString(a??{},["text","contents"])!=null||this.readString(n,["text","contents","mtext"])!=null,s=e.contentType??(o?r.AcDbMLeaderContentType.MTextContent:e.blockContent?r.AcDbMLeaderContentType.BlockContent:r.AcDbMLeaderContentType.NoneContent);t.contentType=s;const d=this.readPoint(n,["normal","extrusionDirection"]);d&&(t.normal=d);const A=this.readString(a??{},["styleName","textStyleName","textStyle"])??this.readString(n,["textStyleName","textStyle","styleName"]);A&&(t.textStyleName=A);const c=this.readPositiveNumber(a??{},["textHeight","height"])??this.readPositiveNumber(n,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(n,["arrowheadSize","contentScale"]);c!=null&&(t.textHeight=c);const l=this.readPositiveNumber(a??{},["textWidth","width"])??this.readPositiveNumber(n,["textWidth","mtextWidth","textContentWidth"]);l!=null&&(t.textWidth=l),t.textLineSpacingFactor=this.readNumber(a??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(n,["textLineSpacingFactor"])??t.textLineSpacingFactor;const h=this.readNumber(a??{},["textRotation","rotation"])??this.readNumber(n,["textRotation","mtextRotation","textContentRotation"]);h!=null&&(t.textRotation=r.AcGeMathUtil.degToRad(h));const T=this.readPoint(n,["textDirection","mtextDirection","textDirectionVector"]);T&&(t.textDirection=T);const L=this.readNumber(n,["textAttachmentPoint","attachmentPoint"]);L!=null&&L!==0&&(t.textAttachmentPoint=L);const p=e.textAttachmentDirection;p!=null&&(t.textAttachmentDirection=p);const m=this.readNumber(n,["textDrawingDirection","drawingDirection"]);m!=null&&(t.textDrawingDirection=m);const oe=typeof i=="string"?i:this.readString(a??{},["text","contents"])??this.readString(n,["text","contents","mtext"]),Ce=this.readPoint(a??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(n,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(oe!=null&&Ce&&(t.mtextContent={text:oe,anchorPoint:Ce}),e.blockContent){const g=e.blockContent,We=e.blockContent.blockContentId;if(this.isValidHandleId(We)){const Ze=this.readNumber(g,["color"]);t.blockContent={blockContentId:We,normal:this.readPoint(g,["normal"]),position:e.blockContent.position,scale:this.readPoint(g,["scale"]),rotation:this.readNumber(g,["rotation"]),color:Ze!=null?r.decodeMLeaderStyleRawColor(Ze):void 0,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(t.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:t.blockContentColor,transformationMatrix:[]});return(H=this.readMLeaderLeaders(n))==null||H.forEach(g=>{t.addLeader({lastLeaderLinePoint:g.lastLeaderLinePoint,lastLeaderLinePointSet:g.lastLeaderLinePointSet,doglegVector:g.doglegVector,doglegVectorSet:g.doglegVectorSet,doglegLength:g.doglegLength??e.doglegLength,breaks:g.breaks,leaderBranchIndex:g.leaderBranchIndex,leaderLines:g.leaderLines})}),t.numberOfLeaders===0&&((Se=this.readLeaderLineArray(n))==null||Se.forEach(g=>{t.addLeader({doglegLength:e.doglegLength}),t.addLeaderLine(t.numberOfLeaders-1,g)})),t.numberOfLeaders===0&&e.contentBasePosition&&t.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"){const t=e,n=new r.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=r.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRotatedDimension"){const t=e,n=new r.AcDbRotatedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=r.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,n=new r.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb2LineAngularDimension"){const t=e,n=t.centerPoint??t.subDefinitionPoint2??t.definitionPoint,i=t.definitionPoint??t.subDefinitionPoint2;if(!n||!t.subDefinitionPoint1||!t.subDefinitionPoint2||!i)return null;const a=new r.AcDb3PointAngularDimension(n,t.subDefinitionPoint1,t.subDefinitionPoint2,i);return this.processDimensionCommonAttrs(e,a),a}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,n=new r.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,n=new r.AcDbRadialDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,n=new r.AcDbDiametricDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(n=>{t.clipBoundary.push(new r.AcGePoint2d(n))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new r.AcDbRasterImage;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(n=>{t.clipBoundary.push(new r.AcGePoint2d(n))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new r.AcDbWipeout;return this.processWipeout(e,t),t}convertViewport(e){const t=new r.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new r.AcDbRay;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new r.AcDbXline;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new r.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?r.AcGeMathUtil.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(e,t){if(t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle.toString()),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){const n=new r.AcCmColor;e.color!=null&&n.setRGBValue(e.color),e.colorIndex!=null&&(n.colorIndex=e.colorIndex),e.colorName&&(n.colorName=e.colorName),t.color=n}e.isVisible!=null&&(t.visibility=!e.isVisible),e.transparency!=null&&(t.transparency=r.AcCmTransparency.deserialize(e.transparency))}isValidHandleId(e){return e!=null&&e!==""&&e!=="0"}readNumber(e,t){for(const n of t){const i=e[n];if(typeof i=="number"&&Number.isFinite(i))return i}}readPositiveNumber(e,t){const n=this.readNumber(e,t);return n!=null&&n>0?n:void 0}readString(e,t){for(const n of t){const i=e[n];if(typeof i=="string")return i}}readBoolean(e,t){for(const n of t){const i=e[n];if(typeof i=="boolean")return i;if(typeof i=="number")return i!==0}}readPoint(e,t){for(const n of t){const i=e[n];if(this.isPointLike(i))return i;if(Array.isArray(i)&&typeof i[0]=="number"&&typeof i[1]=="number")return{x:i[0],y:i[1],z:i[2]??0}}}readLeaderLineArray(e){const t=e.leaderLines;if(Array.isArray(t))return t.map(i=>{if(!i||typeof i!="object")return;const a=i.vertices;return Array.isArray(a)?a.filter(o=>this.isPointLike(o)):void 0}).filter(i=>!!i&&i.length>0);const n=e.vertices;if(Array.isArray(n)){const i=n.filter(a=>this.isPointLike(a));return i.length>0?[i]:void 0}}readMLeaderLeaders(e){const t=e.leaderSections;if(!Array.isArray(t))return;const n=[];return t.forEach(i=>{if(!i||typeof i!="object")return;const a=i,o=a.leaderLines,s=Array.isArray(o)?o.reduce((L,p)=>{const m=this.readMLeaderLine(p);return m&&L.push(m),L},[]):void 0,d={},A=this.readPoint(a,["lastLeaderLinePoint"]),c=this.readPoint(a,["doglegVector"]),l=this.readNumber(a,["doglegLength"]),h=this.readMLeaderBreaks(a.breaks),T=this.readNumber(a,["leaderBranchIndex"]);A&&(d.lastLeaderLinePoint=A),a.lastLeaderLinePointSet!=null&&(d.lastLeaderLinePointSet=this.readBoolean(a,["lastLeaderLinePointSet"])),c&&(d.doglegVector=c),a.doglegVectorSet!=null&&(d.doglegVectorSet=this.readBoolean(a,["doglegVectorSet"])),l!=null&&(d.doglegLength=l),h&&(d.breaks=h),T!=null&&(d.leaderBranchIndex=T),s&&(d.leaderLines=s),n.push(d)}),n}readMLeaderLine(e){if(!e||typeof e!="object")return;const t=e,n=t.vertices,i=Array.isArray(n)?n.filter(d=>this.isPointLike(d)):[],a=this.readMLeaderBreaks(t.breaks),o=Array.isArray(t.breakPointIndexes)?t.breakPointIndexes.filter(d=>typeof d=="number"):void 0,s=this.readNumber(t,["leaderLineIndex"]);return i.length>0||a&&a.length>0?{vertices:i,breakPointIndexes:o,leaderLineIndex:s,breaks:a}:void 0}readMLeaderBreaks(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!n||typeof n!="object")return;const i=n,a=this.readPoint(i,["start"]),o=this.readPoint(i,["end"]),s=this.readNumber(i,["index"]);if(!a||!o)return;const d={start:a,end:o};return s!=null&&(d.index=s),d}).filter(n=>!!n);return t.length>0?t:void 0}isPointLike(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"}}class dt{convertLayout(e,t){var a,o;const n=new r.AcDbLayout;n.layoutName=e.layoutName,n.tabOrder=e.tabOrder,n.plotSettingsName=e.pageSetupName,n.plotCfgName=e.configName,n.canonicalMediaName=e.paperSize,n.plotViewName=e.plotViewName,n.currentStyleSheet=e.currentStyleSheet,n.plotPaperMargins={left:e.marginLeft,right:e.marginRight,top:e.marginTop,bottom:e.marginBottom},n.plotPaperSize.copy({x:e.paperWidth,y:e.paperHeight}),n.plotOrigin.copy({x:e.plotOriginX,y:e.plotOriginY}),n.plotWindowArea.min.copy({x:e.windowAreaXMin,y:e.windowAreaYMin}),n.plotWindowArea.max.copy({x:e.windowAreaXMax,y:e.windowAreaYMax}),n.customPrintScale={numerator:e.printScaleNumerator,denominator:e.printScaleDenominator},n.plotPaperUnits=e.plotPaperUnit,n.plotRotation=e.plotRotation,n.plotType=e.plotType,n.stdScaleType=e.standardScaleType,n.shadePlot=(()=>{switch(e.shadePlotMode){case 1:return r.AcDbPlotShadePlotType.kWireframe;case 2:return r.AcDbPlotShadePlotType.kHidden;case 3:return r.AcDbPlotShadePlotType.kRendered;default:return r.AcDbPlotShadePlotType.kAsDisplayed}})(),n.shadePlotResLevel=(()=>{switch(e.shadePlotResolution){case 1:return r.AcDbPlotShadePlotResLevel.kPreview;case 2:return r.AcDbPlotShadePlotResLevel.kNormal;case 3:return r.AcDbPlotShadePlotResLevel.kPresentation;case 4:return r.AcDbPlotShadePlotResLevel.kMaximum;case 5:return r.AcDbPlotShadePlotResLevel.kCustom;default:return r.AcDbPlotShadePlotResLevel.kDraft}})(),e.shadePlotCustomDPI!=null&&(n.shadePlotCustomDPI=e.shadePlotCustomDPI),e.shadePlotId&&(n.shadePlotId=e.shadePlotId);const i=e.layoutFlag??0;if(n.plotViewportBorders=(i&1)!==0,n.showPlotStyles=(i&2)!==0,n.plotCentered=(i&4)!==0,n.plotHidden=(i&8)!==0,n.useStandardScale=(i&16)!==0,n.plotPlotStyles=(i&32)!==0,n.scaleLineweights=(i&64)!==0,n.printLineweights=(i&128)!==0,n.drawViewportsFirst=(i&512)!==0,n.modelType=(i&1024)!==0,e.viewportId&&n.viewportArray.push(e.viewportId),e.layoutName==="Model"){const s=r.AcDbBlockTableRecord.MODEL_SPACE_NAME.toUpperCase();(a=t.tables.BLOCK_RECORD)==null||a.entries.some(d=>d.name.toUpperCase()===s?(n.blockTableRecordId=d.handle,!0):!1)}else(o=t.tables.BLOCK_RECORD)==null||o.entries.some(s=>s.layoutObjects===e.handle?(n.blockTableRecordId=s.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=e.paperSpaceTableId);return e.minLimit&&n.limits.min.copy(e.minLimit),e.maxLimit&&n.limits.max.copy(e.maxLimit),e.minExtent&&n.extents.min.copy(e.minExtent),e.maxExtent&&n.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,n),n}convertImageDef(e){const t=new r.AcDbRasterImageDef;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}convertMLeaderStyle(e){const t=new r.AcDbMLeaderStyle;return t.unknown1=e.unknown1,e.contentType!=null&&(t.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(t.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(t.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(t.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(t.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(t.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(t.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(t.leaderLineColor=r.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(t.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(t.landingEnabled=e.landingEnabled),e.landingGap!=null&&(t.landingGap=e.landingGap),e.doglegEnabled!=null&&(t.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(t.doglegLength=e.doglegLength),e.description!=null&&(t.description=e.description),t.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(t.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(t.defaultMTextContents=e.defaultMTextContents),t.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(t.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(t.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(t.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(t.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(t.textColor=r.decodeMLeaderStyleRawColor(e.textColor)),e.textHeight!=null&&(t.textHeight=e.textHeight),e.textFrameEnabled!=null&&(t.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(t.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(t.alignSpace=e.alignSpace),t.blockContentId=e.blockContentId,e.blockContentColor!=null&&(t.blockContentColor=r.decodeMLeaderStyleRawColor(e.blockContentColor)),e.blockContentScale&&(t.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:e.blockContentScale.z??1}),e.blockContentScaleEnabled!=null&&(t.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(t.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(t.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(t.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(t.scale=e.scale),e.overwritePropertyValue!=null&&(t.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(t.annotative=e.annotative),e.breakGapSize!=null&&(t.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(t.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(t.topTextAttachmentDirection=e.topTextAttachmentDirection),t.unknown2=e.unknown2,this.processCommonAttrs(e,t),t}convertMLineStyle(e){var i;const t=new r.AcDbMlineStyle;if(e.styleName!=null&&(t.styleName=e.styleName),e.flags!=null&&(t.flags=e.flags),e.description!=null&&(t.description=e.description),e.fillColor!=null)t.fillColor=new r.AcCmColor().setRGBValue(e.fillColor);else if(e.fillColorIndex!=null){const a=new r.AcCmColor;a.colorIndex=e.fillColorIndex,t.fillColor=a}e.startAngle!=null&&(t.startAngle=e.startAngle),e.endAngle!=null&&(t.endAngle=e.endAngle);const n=Math.max(e.elementCount??0,((i=e.elements)==null?void 0:i.length)??0);return n>0&&(t.elements=Array.from({length:n},(a,o)=>{var s,d,A,c;return{offset:((d=(s=e.elements)==null?void 0:s[o])==null?void 0:d.offset)??0,color:(()=>{var h,T,L,p;const l=new r.AcCmColor;return((T=(h=e.elements)==null?void 0:h[o])==null?void 0:T.color)!=null?l.setRGBValue(e.elements[o].color):l.colorIndex=((p=(L=e.elements)==null?void 0:L[o])==null?void 0:p.colorIndex)??256,l})(),lineType:((c=(A=e.elements)==null?void 0:A[o])==null?void 0:c.lineType)??"BYLAYER"}})),this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}}class ut extends r.AcDbDatabaseConverter{constructor(e={}){super(e),this.config.parserWorkerUrl||(this.config.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e,t){const n=this.config,i=this.getParserWorkerTimeout(e,t);if(n.useWorker&&n.parserWorkerUrl){const a=r.createWorkerApi({workerUrl:n.parserWorkerUrl,timeout:i,maxConcurrentWorkers:1}),o=await a.execute(e);return a.destroy(),r.AcDbOpenDatabaseError.throwOnWorkerParseFailure(o),{model:o.data,data:{unknownEntityCount:0}}}else throw new Error("dxf converter can run in web worker only!")}getFonts(e){var a,o,s,d,A;const t=e.blocks??{},n=new Map;for(const c of((o=(a=e.tables)==null?void 0:a.DIMSTYLE)==null?void 0:o.entries)??[])n.set(c.name,c.DIMTXSTY||r.DEFAULT_TEXT_STYLE);const i=[...e.entities??[]];for(const c of Object.values(t))(s=c.entities)!=null&&s.length&&i.push(...c.entities);return new r.AcDbFontNameCollector({styles:((d=e.tables.STYLE)==null?void 0:d.entries)??[],textStyleVar:((A=e.header)==null?void 0:A.$TEXTSTYLE)||r.DEFAULT_TEXT_STYLE}).collect(i,{getEntityFontInfo:c=>{if(c.type=="MTEXT"){const l=c;return{styleName:l.styleName,formattedText:l.text,resolveStyle:!0}}if(c.type=="TEXT"||c.type=="ATTRIB"||c.type=="ATTDEF")return{styleName:c.styleName,resolveStyle:!0};if(c.type=="MULTILEADER"||c.type=="MLEADER"){const l=c,h=typeof l.textContent=="string"?l.textContent:"";return{styleName:typeof l.textStyleName=="string"?l.textStyleName:typeof l.styleName=="string"?l.styleName:void 0,formattedText:h,resolveStyle:!0}}if(c.type=="TOLERANCE"){const l=c;return{styleName:this.resolveDimStyleTextStyle(n,l.styleName),formattedText:l.text,resolveStyle:!0}}if(c.type=="INSERT")return{blockName:c.name};if(c.type=="DIMENSION"){const l=c;return l.name?{blockName:l.name}:null}return null},getBlockEntities:c=>{var l;return(l=t[c])==null?void 0:l.entities}})}resolveDimStyleTextStyle(e,t){const n=t==null?void 0:t.trim();if(!n)return;const i=e.get(n);if(i)return i;const a=n.toUpperCase();for(const[o,s]of e)if(o.toUpperCase()===a)return s}async processEntities(e,t,n,i,a){var h;const o=new Ke;o.setObjectByHandle(e.objects.byHandle??{}),o.setAcdsDataByHandle(((h=e.acdsData)==null?void 0:h.byOwnerHandle)??{});let s=e.entities;const d=s.length,A=new r.AcDbBatchProcessing(d,100-i.value,n);this.config.convertByEntityType&&(s=this.groupAndFlattenByType(s));const c=new Map;for(let T=0;T<d;T++){const L=s[T];if(L.type==="ATTRIB"){const p=o.convert(L);if(p&&p.ownerId&&p.ownerId!=="0"){let m=c.get(p==null?void 0:p.ownerId);m==null&&(m=[],c.set(p.ownerId,m)),m.push(p)}}}const l=t.tables.blockTable.modelSpace;await A.processChunk(async(T,L)=>{let p=[],m=T<L?s[T].type:"";for(let Ce=T;Ce<L;Ce++){const H=s[Ce];if(!(H.ownerBlockRecordSoftId&&H.ownerBlockRecordSoftId!==l.objectId)&&H.type!=="ATTRIB"){const Se=o.convert(H);if(Se){if(this.config.convertByEntityType&&H.type!==m&&(l.appendEntity(p),p=[],m=H.type),H.type==="INSERT"){const g=c.get(Se.objectId);g&&g.length>0&&g.forEach(We=>{Se.appendAttributes(We)})}p.push(Se)}}}l.appendEntity(p);let oe=i.value+L/d*(100-i.value);oe>100&&(oe=100),a&&await a(oe,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(e,t,n=!1,i={},a={}){const o=new Ke;o.setObjectByHandle(i),o.setAcdsDataByHandle(a);const s=e.length,d=[],A=t.objectId,c=[];for(let l=0;l<s;l++){const h=e[l],T=o.convert(h);T&&(h.type==="ATTRIB"?c.push(T):(!n||h.ownerBlockRecordSoftId===A)&&d.push(T))}t.appendEntity(d),c.forEach(l=>{const h=t.getIdAt(l.ownerId);h&&h.appendAttributes(l)})}processBlocks(e,t){var i,a,o,s;const n=e.blocks;for(const[d,A]of Object.entries(n)){let c=t.tables.blockTable.getAt(A.name);c||(c=new r.AcDbBlockTableRecord,A.handle!=null&&(c.objectId=String(A.handle)),c.name=d,t.tables.blockTable.add(c)),c.origin.copy(A.position),A.entities?this.processEntitiesInBlock(A.entities,c,!1,((i=e.objects)==null?void 0:i.byHandle)??{},((a=e.acdsData)==null?void 0:a.byOwnerHandle)??{}):c.isPaperSapce&&this.processEntitiesInBlock(e.entities,c,!0,((o=e.objects)==null?void 0:o.byHandle)??{},((s=e.acdsData)==null?void 0:s.byOwnerHandle)??{})}}processHeader(e,t){const n=e.header;n.$ACADVER&&(t.version=n.$ACADVER),t.cecolor.colorIndex=n.$CECOLOR||256,t.angbase=n.$ANGBASE||0,t.angdir=n.$ANGDIR||0,n.$AUNITS!=null&&(t.aunits=n.$AUNITS),n.$AUPREC!=null&&(t.auprec=n.$AUPREC),n.$LUNITS!=null&&(t.lunits=n.$LUNITS),n.$LUPREC!=null&&(t.luprec=n.$LUPREC),n.$UNITMODE!=null&&(t.unitmode=n.$UNITMODE),n.$MEASUREMENT!=null&&(t.measurement=n.$MEASUREMENT),t.celtype=n.$CELTYPE||r.ByLayer,r.AcDbSysVarManager.instance().setVar(r.AcDbSystemVariables.CETRANSPARENCY,n.$CETRANSPARENCY||"ByLayer",t),t.celtscale=n.$CELTSCALE||1;const i=this.normalizeHeaderStringValue(n.$CMLSTYLE)||this.normalizeHeaderStringValue(n.CMLSTYLE)||r.DEFAULT_MLINE_STYLE;t.cmlstyle=i;const a=n.$CMLSCALE??n.CMLSCALE;typeof a=="number"&&Number.isFinite(a)&&(t.cmlscale=a);const o=this.normalizeHeaderStringValue(n.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(n.CMLEADERSTYLE)||r.DEFAULT_MLEADER_STYLE;t.cmleaderstyle=o,t.hplayer=this.normalizeHeaderStringValue(n.$HPLAYER)||this.normalizeHeaderStringValue(n.HPLAYER)||".",t.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(t.extmax=n.$EXTMAX),n.$EXTMIN&&(t.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(t.insunits=n.$INSUNITS),t.osmode=n.$OSMODE||0,t.orthomode=n.$ORTHOMODE||0,t.pdmode=n.$PDMODE||0,t.pdsize=n.$PDSIZE||0,t.textstyle=n.$TEXTSTYLE||r.DEFAULT_TEXT_STYLE,n.$HANDSEED!=null&&t.initializeHandleSeed(String(n.$HANDSEED))}processBlockTables(e,t){var i;const n=(i=e.tables.BLOCK_RECORD)==null?void 0:i.entries;n&&n.length>0&&(t.tables.blockTable.removeAll(),n.forEach(a=>{const o=new r.AcDbBlockTableRecord;o.objectId=a.handle,o.name=a.name,o.layoutId=a.layoutObjects,o.blockInsertUnits=a.insertionUnits,o.explodability=a.explodability,o.blockScaling=a.scalability,a.bmpPreview&&(o.bmpPreview=a.bmpPreview),t.tables.blockTable.add(o)}))}processObjects(e,t){const n=e.objects.byName,i=new dt;if("LAYOUT"in n){const a=t.objects.layout;n.LAYOUT.forEach(o=>{const s=i.convertLayout(o,e);a.setAt(s.layoutName,s)})}if("IMAGEDEF"in n){const a=t.objects.imageDefinition;n.IMAGEDEF.forEach(o=>{const s=i.convertImageDef(o);a.setAt(s.objectId,s)})}if("MLEADERSTYLE"in n){const a=t.objects.mleaderStyle;n.MLEADERSTYLE.forEach(o=>{const s=i.convertMLeaderStyle(o);a.setAt(s.objectId,s)})}if("MLINESTYLE"in n){const a=t.objects.mlineStyle;n.MLINESTYLE.forEach(o=>{const s=i.convertMLineStyle(o);a.setAt(s.styleName||s.objectId,s)})}}processViewports(e,t){var i;const n=(i=e.tables)==null?void 0:i.VPORT;if(n){this.processCommonTableAttrs(n,t.tables.viewportTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const s=new r.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(o,s),o.circleSides&&(s.circleSides=o.circleSides),s.standardFlag=o.standardFlag,s.center.copy(o.center??r.VPORT_FALLBACK_CENTER_2D),s.lowerLeftCorner.copy(o.lowerLeftCorner??r.VPORT_FALLBACK_LLC),s.upperRightCorner.copy(o.upperRightCorner??r.VPORT_FALLBACK_URC),o.snapBasePoint&&s.snapBase.copy(o.snapBasePoint),o.snapRotationAngle&&(s.snapAngle=o.snapRotationAngle),o.snapSpacing&&s.snapIncrements.copy(o.snapSpacing),o.majorGridLines&&(s.gridMajor=o.majorGridLines),o.gridSpacing&&s.gridIncrements.copy(o.gridSpacing),o.backgroundObjectId&&(s.backgroundObjectId=o.backgroundObjectId),s.gsView.center.copy(o.center??r.VPORT_FALLBACK_CENTER_2D),s.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget??r.VPORT_FALLBACK_VIEW_DIR),s.gsView.viewTarget.copy(o.viewTarget??r.VPORT_FALLBACK_VIEW_TARGET),o.lensLength&&(s.gsView.lensLength=o.lensLength),o.frontClippingPlane&&(s.gsView.frontClippingPlane=o.frontClippingPlane),o.backClippingPlane&&(s.gsView.backClippingPlane=o.backClippingPlane),o.viewHeight&&(s.gsView.viewHeight=o.viewHeight),o.aspectRatio!=null&&Number.isFinite(o.aspectRatio)&&o.aspectRatio>0&&(s.gsView.aspectRatio=o.aspectRatio),o.viewTwistAngle&&(s.gsView.viewTwistAngle=o.viewTwistAngle),o.frozenLayers&&(s.gsView.frozenLayers=o.frozenLayers),o.styleSheet&&(s.gsView.styleSheet=o.styleSheet),o.renderMode&&(s.gsView.renderMode=o.renderMode),o.viewMode&&(s.gsView.viewMode=o.viewMode),o.ucsIconSetting&&(s.gsView.ucsIconSetting=o.ucsIconSetting),o.ucsOrigin&&s.gsView.ucsOrigin.copy(o.ucsOrigin),o.ucsXAxis&&s.gsView.ucsXAxis.copy(o.ucsXAxis),o.ucsYAxis&&s.gsView.ucsYAxis.copy(o.ucsYAxis),o.orthographicType&&(s.gsView.orthographicType=o.orthographicType),o.shadePlotSetting&&(s.gsView.shadePlotSetting=o.shadePlotSetting),o.shadePlotObjectId&&(s.gsView.shadePlotObjectId=o.shadePlotObjectId),o.visualStyleObjectId&&(s.gsView.visualStyleObjectId=o.visualStyleObjectId),o.isDefaultLightingOn&&(s.gsView.isDefaultLightingOn=o.isDefaultLightingOn),o.defaultLightingType&&(s.gsView.defaultLightingType=o.defaultLightingType),o.brightness&&(s.gsView.brightness=o.brightness),o.contrast&&(s.gsView.contrast=o.contrast),o.ambientColor&&(s.gsView.ambientColor=o.ambientColor),t.tables.viewportTable.add(s)})}}processLayers(e,t){var i;const n=(i=e.tables)==null?void 0:i.LAYER;if(n){this.processCommonTableAttrs(n,t.tables.layerTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const s=new r.AcCmColor;s.colorIndex=o.colorIndex;const d=new r.AcDbLayerTableRecord({name:o.name,standardFlags:o.standardFlag,linetype:o.lineType,lineWeight:o.lineweight,isOff:o.colorIndex<0,color:s,isPlottable:o.isPlotting});this.processCommonTableEntryAttrs(o,d),t.tables.layerTable.add(d)})}t.ensureTextStyleDefaults()}processLineTypes(e,t){var i;const n=(i=e.tables)==null?void 0:i.LTYPE;if(n){this.processCommonTableAttrs(n,t.tables.linetypeTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const s=new r.AcDbLinetypeTableRecord({name:o.name,standardFlag:o.standardFlag,description:o.description,totalPatternLength:o.totalPatternLength,pattern:o.pattern});this.processCommonTableEntryAttrs(o,s),t.tables.linetypeTable.add(s)})}}processTextStyles(e,t){var i;const n=(i=e.tables)==null?void 0:i.STYLE;if(n){this.processCommonTableAttrs(n,t.tables.textStyleTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const s=new r.AcDbTextStyleTableRecord({name:o.name,standardFlag:o.standardFlag,fixedTextHeight:o.fixedTextHeight,widthFactor:o.widthFactor,obliqueAngle:o.obliqueAngle,textGenerationFlag:o.textGenerationFlag,lastHeight:o.lastHeight,font:o.font,bigFont:o.bigFont,extendedFont:o.extendedFont});this.processCommonTableEntryAttrs(o,s),t.tables.textStyleTable.add(s)})}}processDimStyles(e,t){var i;const n=(i=e.tables)==null?void 0:i.DIMSTYLE;if(n){this.processCommonTableAttrs(n,t.tables.dimStyleTable,t);const a=n.entries;a&&a.length>0&&a.forEach(o=>{const s={name:o.name,ownerId:o.ownerObjectId,dimpost:o.DIMPOST||"",dimapost:o.DIMAPOST||"",dimscale:o.DIMSCALE,dimasz:o.DIMASZ,dimexo:o.DIMEXO,dimdli:o.DIMDLI,dimexe:o.DIMEXE,dimrnd:o.DIMRND,dimdle:o.DIMDLE,dimtp:o.DIMTP,dimtm:o.DIMTM,dimtxt:o.DIMTXT,dimcen:o.DIMCEN,dimtsz:o.DIMTSZ,dimaltf:o.DIMALTF,dimlfac:o.DIMLFAC,dimtvp:o.DIMTVP,dimtfac:o.DIMTFAC,dimgap:o.DIMGAP,dimaltrnd:o.DIMALTRND,dimtol:o.DIMTOL==null||o.DIMTOL==0?0:1,dimlim:o.DIMLIM==null||o.DIMLIM==0?0:1,dimtih:o.DIMTIH==null||o.DIMTIH==0?0:1,dimtoh:o.DIMTOH==null||o.DIMTOH==0?0:1,dimse1:o.DIMSE1==null||o.DIMSE1==0?0:1,dimse2:o.DIMSE2==null||o.DIMSE2==0?0:1,dimtad:o.DIMTAD,dimzin:o.DIMZIN,dimazin:o.DIMAZIN,dimalt:o.DIMALT,dimaltd:o.DIMALTD,dimtofl:o.DIMTOFL,dimsah:o.DIMSAH,dimtix:o.DIMTIX,dimsoxd:o.DIMSOXD,dimclrd:o.DIMCLRD,dimclre:o.DIMCLRE,dimclrt:o.DIMCLRT,dimadec:o.DIMADEC||0,dimunit:o.DIMUNIT||2,dimdec:o.DIMDEC,dimtdec:o.DIMTDEC,dimaltu:o.DIMALTU,dimalttd:o.DIMALTTD,dimaunit:o.DIMAUNIT,dimfrac:o.DIMFRAC,dimlunit:o.DIMLUNIT,dimdsep:o.DIMDSEP?o.DIMDSEP.toString():".",dimtmove:o.DIMTMOVE||0,dimjust:o.DIMJUST,dimsd1:o.DIMSD1,dimsd2:o.DIMSD2,dimtolj:o.DIMTOLJ,dimtzin:o.DIMTZIN,dimaltz:o.DIMALTZ,dimalttz:o.DIMALTTZ,dimfit:o.DIMFIT||0,dimupt:o.DIMUPT,dimatfit:o.DIMATFIT,dimtxsty:o.DIMTXSTY||r.DEFAULT_TEXT_STYLE,dimldrblk:o.DIMLDRBLK||"",dimblk:o.DIMBLK||"",dimblk1:o.DIMBLK1||"",dimblk2:o.DIMBLK2||"",dimlwd:o.DIMLWD,dimlwe:o.DIMLWE},d=new r.AcDbDimStyleTableRecord(s);this.processCommonTableEntryAttrs(o,d),t.tables.dimStyleTable.add(d)})}}processCommonTableAttrs(e,t,n){e.handle!=null&&n.adoptExternalHandle(t,e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}processCommonTableEntryAttrs(e,t){t.name="name"in e?e.name:"",e.handle!=null&&(t.objectId=e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}groupAndFlattenByType(e){const t={},n=[];for(const i of e)t[i.type]||(t[i.type]=[],n.push(i.type)),t[i.type].push(i);return n.flatMap(i=>t[i])}normalizeHeaderStringValue(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}}ie.AcDbDxfConverter=ut,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})});
|