Ë
    JÿiæÂ  ã                  óR  — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZ ddlmZmZmZ ddlmZmZmZmZmZ ddlmZmZ dd	lmZ dd
lmZmZm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7  ejp                  d«      js                   ejt                  «       «        ejp                  d«      Z;dZ<dZ=de=z  Z>de=z  Z?de=z  Z@de@z  ZAe@dz  ZBe!j€                  e?e@z  e!j‚                  e?eAz  e!jx                  e?e<z  e!jz                  e?e=z  e!j|                  e?e>z  e!j~                  diZCdZDdeDz  ZEdeDz  ZFd„ ZG edeeHe   «      ZIdBd„ZJi dg d¢“dg d¢“dg d¢“ddg“dg d¢“dd g“d!dg“d"dg“d#d g“d$d g“d%g d¢“d&g d¢“d'g d¢“d(dg“d)dg“d*g d¢“d+dg“g d¢dd gdgd,œ¥ZK ed-d.¬/«      ZL	  G d0„ d.e
«      ZM	 dC	 	 	 dDd1„ZN G d2„ d3«      ZO G d4„ d5eO«      ZP G d6„ d7eO«      ZQ G d8„ d9eO«      ZR G d:„ d;eO«      ZS G d<„ d=«      ZT ed>«      ZU	 	 	 	 dEd?„ZV eVeMj®                  «      ZW eVeMj°                  «      ZX eVeMj²                  «      ZY eVeMj´                  «      ZZ eVeMj¶                  «      Z[ eVeMj¸                  «      Z\ eVeMjº                  «      Z] eVeMj¼                  «      Z^ eVeMj¾                  «      Z_ eVeMjÀ                  «      Z`dFd@„Zae;jÅ                  dA«        eae&jÆ                  «      e&_c         eae&jÈ                  «      e&_d        y)Ga   
build123d Common

name: build_common.py
by:   Gumyr
date: July 12th 2022

desc:
    This is a Python code defining a class hierarchy for building CAD
    models. The code defines an abstract base class Builder with three
    concrete subclasses BuildLine, BuildPart, and BuildSketch in separate
    modules.

    The Builder class has several methods for adding and retrieving
    geometric shapes such as vertices, edges, faces, and solids. It also
    has a method _add_to_pending for adding shapes to a pending list that
    will be integrated into the final model later. The class has a
    _get_context method for retrieving the current Builder instance and a
    validate_inputs method for validating input shapes.

    The code also defines a validate_inputs function that takes a Builder
    instance and validates the input shapes.

license:

    Copyright 2022 Gumyr

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

é    )ÚannotationsN)ÚABCÚabstractmethod)Úproduct)ÚsqrtÚcosÚpi)ÚAnyÚcastÚoverloadÚTypeÚTypeVar)ÚCallableÚIterable)ÚSelf)ÚAlignÚModeÚSelectÚUnit)ÚAxisÚLocationÚPlaneÚVectorÚ
VectorLikeÚto_align_offset)ÚCompoundÚCurveÚEdgeÚFaceÚJointÚPartÚShapeÚ	ShapeListÚSketchÚSolidÚVertexÚWireÚtuplifyÚ	new_edgesÚ	build123dgü©ñÒMbP?é   é
   iè  gffffff9@é   g÷XzY|@c                óJ   — t        | t        «      xr t        d„ | D «       «      S )z$Identify points as tuples of numbersc              3  óH   K  — | ]  }t        |t        t        f«      –— Œ y ­w©N)Ú
isinstanceÚintÚfloat)Ú.0Úitems     úg/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/build123d/build_common.pyÚ	<genexpr>z_is_point.<locals>.<genexpr>ƒ   s   è ø€ ð *Ù36¨4Œ
�4œ#œu˜×&±3ùs   ‚ ")r1   ÚtupleÚall)Úobjs    r6   Ú	_is_pointr;   �   s*   € ä�cœ5Ó!ò ¤cñ *Ù36ó*ó 'ð ó    ÚTc                 óÐ   — t        «       }| D ]V  }t        |t        t        t        t
        f«      r#t        |«      s|j                  t        |Ž «       ŒF|j                  |«       ŒX |S )zNConvert a sequence of object potentially containing iterables into a flat list)
r#   r1   Úlistr8   ÚfilterÚsetr;   ÚextendÚflatten_sequenceÚappend)r:   Ú	flat_listr5   s      r6   rC   rC   ‹   sZ   € ô !*£€IÛˆô �dœT¤5¬&´#Ð6Ô7Ä	È$ÄØ×ÑÔ-¨tÐ4Õ5à×Ñ˜TÕ"ð ð Ðr<   Úadd)Ú	BuildPartÚBuildSketchÚ	BuildLineÚbounding_boxÚchamferÚextruderG   ÚfilletÚ
full_roundrH   ÚloftÚmake_brake_formedÚ	make_faceÚ	make_hullÚmirrorÚoffsetÚprojectÚproject_workplaneÚrevolveÚscaleÚsection)ÚsplitÚsweepÚthickenÚBÚBuilder)Úboundc                  óè  — e Zd ZU dZ ej
                  d«      Zded<   d ZdZ	e
j                  dœ	 	 	 d'd„Zeed(d„«       «       Zej                   ed)d	„«       «       Zed*d
„«       Zed+d„«       Zd„ Zd„ Zd„ Zeddœd,d„«       Ze	 	 d-	 	 	 	 	 	 	 d.d„«       Zdde
j                  dœ	 	 	 	 	 	 	 d/d„Zej6                  fd0d„Zej6                  fd1d„Zej6                  fd2d„Zej6                  fd3d„Zej6                  fd4d„Z ej6                  fd5d„Z!ej6                  fd6d„Z"ej6                  fd7d„Z#ej6                  fd8d„Z$ej6                  fd9d„Z%	 d:	 	 	 d;d „Z&	 d:	 d<d!„Z'd"„ Z(d=d#„Z)d=d$„Z*d=d%„Z+d&„ Z,y)>r^   a™  Builder

    Base class for the build123d Builders.

    Args:
        workplanes: sequence of Union[Face, Plane, Location]: set plane(s) to work on
        mode (Mode, optional): combination mode. Defaults to Mode.ADD.

    Attributes:
        mode (Mode): builder's combination mode
        workplanes (list[Plane]): active workplanes
        builder_parent (Builder): build to pass objects to on exit

    zBuilder._currentzcontextvars.ContextVar[Builder]Ú_currentÚNone©Úmodec               ó’  — || _         t        j                  |«      }|r|nt        j                  g| _        d | _        t        j                  «       }|€J ‚|j                  €J ‚|j                  j                  | _
        d | _        d | _        t        g t        g t        g t         g i| _        d | _        g | _        d | _        g | _        y r0   )rd   ÚWorkplaneListÚ_convert_to_planesr   ÚXYÚ
workplanesÚ
_reset_tokÚinspectÚcurrentframeÚf_backÚ_python_frameÚparent_frameÚbuilder_parentr&   r   r   r%   ÚlastsÚworkplanes_contextÚexit_workplanesÚ
obj_beforeÚ
to_combine)Úselfrd   ri   ÚplanesÚcurrent_frames        r6   Ú__init__zBuilder.__init__Ò   s¹   € ð
 ˆŒ	Ü×1Ñ1°*Ó=ˆÙ$*™&´·±°
ˆŒØˆŒÜ×,Ñ,Ó.ˆØÐ(Ð(Ð(Ø×#Ñ#Ð/Ð/Ð/Ø*×1Ñ1×8Ñ8ˆÔØ ˆÔØ"ˆÔÜ" B¬¨b´$¸¼EÀ2ÐFˆŒ
Ø"&ˆÔØ,.ˆÔØ(,ˆŒØ')ˆ�r<   c                ó   — t         ‚)zObject to pass to parent©ÚNotImplementedError©rv   s    r6   Ú_objzBuilder._objç   s
   € ô "Ð!r<   c                ó   — t         ‚r0   r{   )rv   Úvalues     r6   r~   zBuilder._objí   s
   € ô "Ð!r<   c                óf   — | j                   r$| j                   j                  «       j                  S dS )z(Maximum size of object in all directionsç        )r~   rJ   Údiagonalr}   s    r6   Úmax_dimensionzBuilder.max_dimensionò   s(   € ð 59·I²Iˆt�y‰y×%Ñ%Ó'×0Ñ0ÐFÀ3ÐFr<   c                ó|   — | j                   €g n| j                   g}t        || j                  z   d| j                  iŽS )z(Edges that changed during last operationÚcombined)rt   r)   ru   r~   )rv   Úbefore_lists     r6   r)   zBuilder.new_edges÷   s8   € ð !ŸO™OÐ3‘b¸$¿/¹/Ð9JˆÜ˜;¨¯©Ñ8ÐNÀDÇIÁIÑNÐNr<   c                ób  — t         j                  «       r=t         j                  «       j                  t        j                  «       j
                  k(  nd}|rt         j                  «       | _        nd| _        | j                  j                  | «      | _	        t        j                  dt        | «      j                  | j                  |rdnd«       | j                  r't!        | j                  Ž j#                  «       | _        | S t!        t&        j(                  «      j#                  «       | _        | S )zBUpon entering record the parent and a token to restore contextvarsFNz7Entering %s with mode=%s which is in %s scope as parentÚsameÚ	different)r^   Ú_get_contextrn   rk   rl   rm   rp   ra   rA   rj   ÚloggerÚinfoÚtypeÚ__name__rd   ri   rf   Ú	__enter__rr   r   rh   )rv   Ú
same_scopes     r6   r�   zBuilder.__enter__ý   sé   € ô ×#Ñ#Ô%ô × Ñ Ó"×0Ñ0´G×4HÑ4HÓ4J×4QÑ4QÒQàð 	ñ Ü")×"6Ñ"6Ó"8ˆDÕà"&ˆDÔàŸ-™-×+Ñ+¨DÓ1ˆŒä�‰ØEÜ�‹J×ÑØ�I‰IÙ ‰F kô		
ð �?Š?Ü&3°T·_±_Ð&E×&OÑ&OÓ&QˆDÔ#ð ˆô '4´E·H±HÓ&=×&GÑ&GÓ&IˆDÔ#àˆr<   c                 ó   — y)z!Any builder specific exit actionsN© r}   s    r6   Ú_exit_extraszBuilder._exit_extras   s   � r<   c                ó  — | j                   j                  | j                  «       | j                  «        | j                  �Õ| j
                  t        j                  k7  r¸t        j                  dt        | j                  «      j                  «       | j                  €Ht        j                  «       d   s1t        j                   | j"                  › d| j$                  › d�d¬«       | j                  j'                  | j                  | j
                  ¬«       t(        j+                  «       j,                  | _        | j,                  r| j0                  j3                  ddd«       t        j5                  d	t        | «      j                  «       y)
z6Upon exiting restore context and send object to parentNzTransferring object(s) to %sr+   z is None - z didn't create anythingé   ©Ú
stacklevelrc   z
Exiting %s)ra   Úresetrj   r”   rp   rd   r   ÚPRIVATErŒ   ÚdebugrŽ   r�   r~   ÚsysÚexc_infoÚwarningsÚwarnÚ	_obj_nameÚ_tagÚ_add_to_contextrf   r‹   ri   rs   rr   Ú__exit__r�   ©rv   Úexception_typeÚexception_valueÚ	tracebacks       r6   r£   zBuilder.__exit__#  s  € à�‰×Ñ˜DŸO™OÔ,à×ÑÔà×ÑÐ*¨t¯y©y¼D¿L¹LÒ/HÜ�L‰LØ.´°T×5HÑ5HÓ0I×0RÑ0Rôð �y‰yÐ ¬¯©«¸Ò):Ü—‘Ø—~‘~Ð& k°$·)±)°Ð<SÐTØ õð ×Ñ×/Ñ/°·	±	ÀÇ	Á	Ð/ÔJä,×9Ñ9Ó;×FÑFˆÔð �?Š?Ø×#Ñ#×,Ñ,¨T°4¸Ô>ä�‰�L¤$ t£*×"5Ñ"5Õ6r<   N)Ú
face_planec               ó   — t         S )z<Integrate a sequence of objects into existing builder objectr{   )rv   r¨   Úobjectss      r6   Ú_add_to_pendingzBuilder._add_to_pending=  s
   € ô #Ð"r<   Tc                óT  — | j                   j                  d«      }|€dnt        |«      j                  }|rct	        |t
        t        t        t        f«      r|j                  j                  }nt	        |t        «      r|}nd}t        j                  d||«       t        t        |«      S )z*Return the instance of the current builderNrb   z%s context requested by %s)ra   ÚgetrŽ   r�   r1   r!   r$   r   r'   Ú	__class__ÚstrrŒ   r�   r   r]   )ÚclsÚcallerÚlogÚresultÚcontext_nameÚcaller_names         r6   r‹   zBuilder._get_contextB  s…   € ð —‘×!Ñ! $Ó'ˆØ!' ‘v´T¸&³\×5JÑ5JˆáÜ˜&¤4¬´¼Ð"=Ô>Ø$×.Ñ.×7Ñ7‘Ü˜F¤CÔ(Ø$‘à$�Ü�K‰KÐ4°lÀKÔPä”A�v‹Ðr<   )Úfaces_to_pendingÚcleanrd   c          	     ó  — | j                   | _        t        |«      | _        |t        j
                  k7  �rt        |«      dkD  �rt        t        t        t        t        fD �ci c]  }|g “Œ c}}t        t        t        t        t        fD ]"  }|D �cg c]  }t        ||«      sŒ|‘Œ c}||<   Œ$ t        d„ |j                  «       D «       «      }t        |«      |k7  rjt        j                   «       d   sSt#        |«      |j                  «       D �	�
ch c]  }	|	D ]  }
|
’Œ Œ c}
}	z
  }|dhk7  rt%        | j&                  › d|› �«      ‚|t           D ]@  }t        t        t        t        fD ]%  }||   j)                  |j+                  |«      «       Œ' ŒB | j&                  dk(  rÝg }|t           D ]Æ  }|j-                  t.        j0                  «      sd	 t/        dd|j3                  «       ¬	«      }|j7                  |«      }|j9                  t;        dd|j=                  «       j>                   f«      «       |j3                  «       j>                  dkD  r|jA                  |«       Œµ|jA                  | «       ŒÈ ||t        <   |t           D ](  }|t           j)                  |jC                  «       «       Œ* |s(|t           j)                  |t           «       g |t        <   i }tD        t        t        t        fD ]5  }| j                   €
t#        «       nt#        | jG                  |«      «      ||<   Œ7 || jH                     �rWtJ        jM                  dt        || jH                     «      |«       |t        jN                  k(  r›| j                   €ht        || jH                     «      dk(  r|| jH                     d   }�n< || jH                     jQ                  «       jR                  || jH                     Ž }�n | j                   jR                  || jH                     Ž }nÜ|t        jT                  k(  r>| j                   €tW        d«      ‚ | j                   jX                  || jH                     Ž }n‹|t        jZ                  k(  r>| j                   €tW        d«      ‚ | j                   j\                  || jH                     Ž }n:|t        j^                  k(  r'| ja                  t        || jH                     «      «      }€| ja                  «       | _         n.t        |t        «      r| ja                  |«      | _         n|| _         | j                   �!|r| j                   jc                  «       | _         tJ        je                  dt        || jH                     «      |«       tD        t        t        t        fD ]m  }| j                   €
t#        «       nt#        | jG                  |«      «      }| jH                  |k(  rtg        ||   «      ntg        |||   z
  «      | jh                  |<   Œo | j                   �|t        | j                   t        «      r+| ja                  | j                   jj                  «      | _         n7| ja                  t        | jG                  «       «      jj                  «      | _         | j&                  dk(  rq | jl                  |t           Ž  tn        jq                  «       jr                  D ]9  }|t           D �cg c]  }|ju                  |«      ‘Œ }} | jl                  |d|iŽ Œ; y| j&                  dk(  r | jl                  |t           Ž  yyyyc c}w c c}w c c}
}	w # t4        $ r t/        d|j3                  «       ¬
«      }Y �Œ–w xY wc c}w )a  Add objects to Builder instance

        Core method to interface with Builder instance. Input sequence of objects is
        parsed into lists of edges, faces, and solids. Edges and faces are added to pending
        lists. Solids are combined with current part.

        Each operation generates a list of vertices, edges, faces, and solids that have
        changed during this operation. These lists are only guaranteed to be valid up until
        the next operation as subsequent operations can eliminate these objects.

        Args:
            objects (Union[Edge, Wire, Face, Solid, Compound]): sequence of objects to add
            faces_to_pending (bool, optional): add faces to pending_faces. Default to True.
            clean (bool, optional): Remove extraneous internal structure. Defaults to True.
            mode (Mode, optional): combination mode. Defaults to Mode.ADD.

        Raises:
            ValueError: Invalid input
            ValueError: Nothing to intersect with
            ValueError: Nothing to intersect with
        r   c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr0   )Úlen)r4   Úts     r6   r7   z*Builder._add_to_context.<locals>.<genexpr>ƒ  s   è ø€ Ð<©^¨œS ŸV©^ùs   ‚r+   Nú doesn't accept rH   )r   r   r   )r+   r   r   )ÚoriginÚx_dirÚz_dir)r½   r¿   z;Attempting to integrate %d object(s) into part with Mode=%szNothing to subtract fromzNothing to intersect withz9Completed integrating %d object(s) into part with Mode=%srG   r¨   );r~   rt   r?   ru   r   rš   rº   r   r'   r   r%   r   r1   ÚsumÚvaluesrœ   r�   rA   Ú
ValueErrorr¡   rB   Úget_typeÚis_coplanarr   rh   Ú	normal_atÚ	ExceptionÚto_local_coordsÚmover   ÚcenterÚZrD   Úedgesr&   Ú_shapesÚ_shaperŒ   r›   ÚADDÚpopÚfuseÚSUBTRACTÚRuntimeErrorÚcutÚ	INTERSECTÚ	intersectÚREPLACEÚ
_sub_classr·   r�   r#   rq   Úwrappedr«   rf   r‹   ri   Úfrom_local_coords)rv   r¶   r·   rd   rª   r°   Útypedr:   Ú
num_storedÚlÚvÚunsupportedÚcompoundÚ	obj_typesÚalignedÚnew_faceÚplaneÚnew_wireÚprer†   ÚpostÚfÚglobal_facess                          r6   r¢   zBuilder._add_to_contextW  s:  € ð@ Ÿ)™)ˆŒÜ˜w›-ˆŒØ”4—<‘<Ó¤C¨£L°1Ó$4ô
 &*¬4´´u¼hÑ$GÓHÑ$G˜S��b‘Ð$GÑHð ô œd¤D¬%´Ó:�Ù-4ÓM©W c¼
À3ÈÕ8Lšc¨WÑM��c’
ð ;ô Ñ<¨U¯\©\¬^Ó<Ó<ˆJä�7‹|˜zÒ)´#·,±,³.ÀÒ2CÜ! '›l¸¿¹¼Ô-S¹°AÓQRÈAªaÐQR¨a¸Ò-SÑS�Ø 4 &Ò(Ü$¨¯	©	 {Ð2BÀ;À-Ð%PÓQÐQð "¤(œO�Ü"&¬¬d´EÓ!:�IØ˜)Ñ$×+Ñ+¨H×,=Ñ,=¸iÓ,HÕIñ ";ð ,ð
 �y‰y˜MÒ)Ø�à %¤d¤�HØ#×/Ñ/´·±Ô9ðXÜ$)Ø'0Ø&/Ø&.×&8Ñ&8Ó&:ô%˜Eð $)×#8Ñ#8¸Ó#B˜Ø Ÿ™¤h°°1°x·±Ó7H×7JÑ7JÐ6JÐ/KÓ&LÔMØ×)Ñ)Ó+×-Ñ-°Ò1ØŸ™ xÕ0àŸ™¨ yÕ1ð# !,ð$ &�”d‘ð "¤$œK�Ø”d‘×"Ñ" 8§>¡>Ó#3Õ4ð (ñ $Ø”e‘×#Ñ# E¬$¡KÔ0Ø �”d‘ð ˆCÜ¤¤d¬EÓ2�Ø$(§I¡IÐ$5œ3œ5¼3¸t¿|¹|ÈCÓ?PÓ;Q��C’ð 3ð �T—[‘[Ó!Ü—‘ØQÜ˜˜dŸk™kÑ*Ó+Øôð œ4Ÿ8™8Ò#Ø—y‘yÐ(Ü˜u T§[¡[Ñ1Ó2°aÒ7Ø',¨T¯[©[Ñ'9¸!Ñ'<šHð !>  d§k¡kÑ 2× 6Ñ 6Ó 8× =Ñ =¸uÀTÇ[Á[Ñ?QÐ Rò %ð $2 4§9¡9§>¡>°5¸¿¹Ñ3EÐ#F™ØœTŸ]™]Ò*Ø—y‘yÐ(Ü*Ð+EÓFÐFØ,˜tŸy™yŸ}™}¨e°D·K±KÑ.@ÐA‘HØœTŸ^™^Ò+Ø—y‘yÐ(Ü*Ð+FÓGÐGØ2˜tŸy™y×2Ñ2°E¸$¿+¹+Ñ4FÐG‘HØœTŸ\™\Ò)Ø#Ÿ™¬t°E¸$¿+¹+Ñ4FÓ/GÓH�HàÐ#Ø $§¡Ó 1�D•IÜØœdôð !%§¡°Ó 9�D•Ià (�D”Ið —9‘9Ð(©UØ $§	¡	§¡Ó 1�D”Iä—‘ØOÜ˜˜dŸk™kÑ*Ó+Øôô ¤¤d¬EÓ2�Ø $§	¡	Ð 1”s”u´s¸4¿<¹<ÈÓ;LÓ7M�ð —{‘{ cÒ)ô ˜e C™jÔ)ä" 4¨#¨c©(¡?Ó3ð —
‘
˜3’ð 3ð �y‰yÐ$Ü˜dŸi™i¬Ô2Ø $§¡°·	±	×0AÑ0AÓ B�D•Ià $§¡´¸¿¹»Ó0H×0PÑ0PÓ Q�D”Ið �y‰y˜KÒ'Ø$�×$Ñ$ e¬D¡kÑ2Ü*×7Ñ7Ó9×DÔD�EØHMÌdÊÓ#TÉÀ1 E×$;Ñ$;¸AÕ$>È�LÐ#TØ(�D×(Ñ(¨,ÐIÀ5ÓIñ Eð —‘˜mÒ+Ø$�×$Ñ$ e¬D¡kÒ2ð ,ð] %5Ðùò
 IùâMùó .Tøô.  )ò XÜ$)°À(×BTÑBTÓBVÔ$W›EðXüòP $Us0   Á"
]Â]Â#]Ä]Ç]Û3^Ý$^Þ^c                ó”  — g }|t         j                  k(  r?| j                  j                  «       D ]!  }|j	                  |j                  «       «       Œ# na|t         j                  k(  r| j                  t           }n:|t         j                  k(  rt        d«      ‚t        dt         j                  › �«      ‚t        t        |«      «      S )a	  Return Vertices

        Return either all or the vertices created during the last operation.

        Args:
            select (Select, optional): Vertex selector. Defaults to Select.ALL.

        Returns:
            ShapeList[Vertex]: Vertices extracted
        úSelect.NEW only valid for edgesú%Invalid input, must be one of Select.)r   ÚALLr~   rË   rB   ÚverticesÚLASTrq   r&   ÚNEWrÂ   Ú_member_names_r#   rA   )rv   ÚselectÚvertex_listÚobj_edges       r6   rí   zBuilder.vertices  s£   € ð %'ˆØ”V—Z‘ZÒØ ŸI™IŸO™OÖ-�Ø×"Ñ" 8×#4Ñ#4Ó#6Õ7ñ .à”v—{‘{Ò"ØŸ*™*¤VÑ,‰KØ”v—z‘zÒ!ÜÐ>Ó?Ð?äØ7¼×8MÑ8MÐ7NÐOóð ô œ˜[Ó)Ó*Ð*r<   c                ó„   — | j                  |«      }t        |«      }|dk7  rt        j                  d|› d�d¬«       |d   S )zÆReturn Vertex

        Return a vertex.

        Args:
            select (Select, optional): Vertex selector. Defaults to Select.ALL.

        Returns:
            Vertex: Vertex extracted
        r+   úFound z vertices, returning firstr–   r—   r   )rí   rº   rž   rŸ   )rv   rñ   Úall_verticesÚvertex_counts       r6   ÚvertexzBuilder.vertex%  sL   € ð —}‘} VÓ,ˆÜ˜<Ó(ˆØ˜1ÒÜ�M‰MØ˜˜Ð&@ÐAØõð ˜A‰Ðr<   c                ó`  — |t         j                  k(  r%| j                  j                  «       }t        |«      S |t         j                  k(  r| j
                  t           }t        |«      S |t         j                  k(  r| j                  }t        |«      S t        dt         j                  › �«      ‚)züReturn Edges

        Return either all or the edges created during the last operation.

        Args:
            select (Select, optional): Edge selector. Defaults to Select.ALL.

        Returns:
            ShapeList[Edge]: Edges extracted
        rë   )r   rì   r~   rË   rî   rq   r   rï   r)   rÂ   rð   r#   )rv   rñ   Ú	edge_lists      r6   rË   zBuilder.edges9  sš   € ð ”V—Z‘ZÒØŸ	™	Ÿ™Ó)ˆIô ˜Ó#Ð#ð ”v—{‘{Ò"ØŸ
™
¤4Ñ(ˆIô ˜Ó#Ð#ð ”v—z‘zÒ!ØŸ™ˆIô
 ˜Ó#Ð#ô Ø7¼×8MÑ8MÐ7NÐOóð r<   c                ó„   — | j                  |«      }t        |«      }|dk7  rt        j                  d|› d�d¬«       |d   S )z½Return Edge

        Return an edge.

        Args:
            select (Select, optional): Edge selector. Defaults to Select.ALL.

        Returns:
            Edge: Edge extracted
        r+   rõ   z edges, returning firstr–   r—   r   )rË   rº   rž   rŸ   )rv   rñ   Ú	all_edgesÚ
edge_counts       r6   ÚedgezBuilder.edgeP  óJ   € ð —J‘J˜vÓ&ˆ	Ü˜“^ˆ
Ø˜Š?Ü�M‰MØ˜˜Ð$;Ð<Øõð ˜‰|Ðr<   c                ón  — |t         j                  k(  r%| j                  j                  «       }t        |«      S |t         j                  k(  r1t        j                  | j                  t           «      }t        |«      S |t         j                  k(  rt        d«      ‚t        dt         j                  › �«      ‚)züReturn Wires

        Return either all or the wires created during the last operation.

        Args:
            select (Select, optional): Wire selector. Defaults to Select.ALL.

        Returns:
            ShapeList[Wire]: Wires extracted
        rê   rë   )r   rì   r~   Úwiresrî   r'   Úcombinerq   r   rï   rÂ   rð   r#   )rv   rñ   Ú	wire_lists      r6   r  zBuilder.wiresd  s—   € ð ”V—Z‘ZÒØŸ	™	Ÿ™Ó)ˆIô ˜Ó#Ð#ð ”v—{‘{Ò"ÜŸ™ T§Z¡Z´Ñ%5Ó6ˆIô ˜Ó#Ð#ð ”v—z‘zÒ!ÜÐ>Ó?Ð?äØ7¼×8MÑ8MÐ7NÐOóð r<   c                ó„   — | j                  |«      }t        |«      }|dk7  rt        j                  d|› d�d¬«       |d   S )z¼Return Wire

        Return a wire.

        Args:
            select (Select, optional): Wire selector. Defaults to Select.ALL.

        Returns:
            Wire: Wire extracted
        r+   rõ   z wires, returning firstr–   r—   r   )r  rº   rž   rŸ   )rv   rñ   Ú	all_wiresÚ
wire_counts       r6   ÚwirezBuilder.wire{  rÿ   r<   c                óH  — |t         j                  k(  r%| j                  j                  «       }t        |«      S |t         j                  k(  r| j
                  t           }t        |«      S |t         j                  k(  rt        d«      ‚t        dt         j                  › �«      ‚)züReturn Faces

        Return either all or the faces created during the last operation.

        Args:
            select (Select, optional): Face selector. Defaults to Select.ALL.

        Returns:
            ShapeList[Face]: Faces extracted
        rê   rë   )r   rì   r~   Úfacesrî   rq   r   rï   rÂ   rð   r#   )rv   rñ   Ú	face_lists      r6   r	  zBuilder.faces�  sŽ   € ð ”V—Z‘ZÒØŸ	™	Ÿ™Ó)ˆIô ˜Ó#Ð#ð ”v—{‘{Ò"ØŸ
™
¤4Ñ(ˆIô ˜Ó#Ð#ð ”v—z‘zÒ!ÜÐ>Ó?Ð?äØ7¼×8MÑ8MÐ7NÐOóð r<   c                ó„   — | j                  |«      }t        |«      }|dk7  rt        j                  d|› d�d¬«       |d   S )z¼Return Face

        Return a face.

        Args:
            select (Select, optional): Face selector. Defaults to Select.ALL.

        Returns:
            Face: Face extracted
        r+   rõ   z faces, returning firstr–   r—   r   )r	  rº   rž   rŸ   )rv   rñ   Ú	all_facesÚ
face_counts       r6   ÚfacezBuilder.face¦  rÿ   r<   c                óH  — |t         j                  k(  r%| j                  j                  «       }t        |«      S |t         j                  k(  r| j
                  t           }t        |«      S |t         j                  k(  rt        d«      ‚t        dt         j                  › �«      ‚)a  Return Solids

        Return either all or the solids created during the last operation.

        Args:
            select (Select, optional): Solid selector. Defaults to Select.ALL.

        Returns:
            ShapeList[Solid]: Solids extracted
        rê   rë   )r   rì   r~   Úsolidsrî   rq   r%   rï   rÂ   rð   r#   )rv   rñ   Ú
solid_lists      r6   r  zBuilder.solidsº  s�   € ð ”V—Z‘ZÒØŸ™×)Ñ)Ó+ˆJô ˜Ó$Ð$ð ”v—{‘{Ò"ØŸ™¤EÑ*ˆJô ˜Ó$Ð$ð ”v—z‘zÒ!ÜÐ>Ó?Ð?äØ7¼×8MÑ8MÐ7NÐOóð r<   c                ó„   — | j                  |«      }t        |«      }|dk7  rt        j                  d|› d�d¬«       |d   S )zÁReturn Solid

        Return a solid.

        Args:
            select (Select, optional): Solid selector. Defaults to Select.ALL.

        Returns:
            Solid: Solid extracted
        r+   rõ   z solids, returning firstr–   r—   r   )r  rº   rž   rŸ   )rv   rñ   Ú
all_solidsÚsolid_counts       r6   ÚsolidzBuilder.solidÑ  sK   € ð —[‘[ Ó(ˆ
Ü˜*“oˆØ˜!ÒÜ�M‰MØ˜˜Ð%=Ð>Øõð ˜!‰}Ðr<   c                óR  — |€| j                   n|}|t        k(  r| j                  j                  «       }|S |t        k(  r| j                  j                  «       }|S |t        k(  r| j                  j                  «       }|S |t        k(  r| j                  j                  «       }|S d}|S )zExtract ShapesN)
rÍ   r&   r~   rí   r   rË   r   r	  r%   r  )rv   Úobj_typer³   s      r6   rÌ   zBuilder._shapeså  s¦   € ð
 #+Ð"2�4—;’;¸ˆØ”vÒØ—Y‘Y×'Ñ'Ó)ˆFð ˆð œÒØ—Y‘Y—_‘_Ó&ˆFð ˆð œÒØ—Y‘Y—_‘_Ó&ˆFð
 ˆð	 œÒØ—Y‘Y×%Ñ%Ó'ˆFð ˆð ˆFØˆr<   c           
     óÀ  — |sg }nt        |t        «      s|g}t        |t        t        t        t
        f«      ru| j                  |j                  vr]t        | j                  j                  › d|j                  j                  › d|j                  j                  › d|j                  › d�«      ‚t        |t        «      r8| j                  j                  t        |   vrt        d|› dt        |   › d�«      ‚|D ]d  }t        |t        «      r|n|j                  j                  }|€Œ.t        |t        «      rŒ?t        |› dt        |«      j                  › d	|› d
�«      ‚ y)z5Validate that objects/operations and parameters applyz doesn't have a z object or operation (z applies to Ú)Ú(z doesn't apply to Nr¼   z, did you intend <keyword>=Ú?)r1   r   r!   r$   r   r'   r¡   Ú_applies_torÒ   r®   r�   r¯   Úoperations_apply_tor"   rŽ   )rv   Úvalidating_classrª   r:   Ú	operations        r6   Úvalidate_inputszBuilder.validate_inputs÷  ss  € ñ
 Ø‰GÜ˜G¤XÔ.Ø�iˆGô Ð'¬$´¼¼tÐ)DÔEØ—	‘	Ð!1×!=Ñ!=Ñ=äØ—>‘>×*Ñ*Ð+Ð+;Ø#×-Ñ-×6Ñ6Ð7ð 8Ø$×.Ñ.×7Ñ7Ð8¸ÐEU×EaÑEaÐDbÐbcðeóð ô Ð'¬Ô-Ø—‘×'Ñ'Ô/BÐCSÑ/TÑTäØÐ$Ð%Ð%7Ô8KÐL\Ñ8]Ð7^Ð^_Ð`óð ó ˆCô Ð.´Ô4ñ !à%×/Ñ/×8Ñ8ð ð
 ˆ{ØÜ ¤UÕ+Ü"Ø �kÐ!1´$°s³)×2DÑ2DÐ1Eð F1Ø14°°Qð8óð ñ r<   c                ó`   — t        | j                  j                  › d| j                  › d�«      ‚)z5Raise an error for invalid boolean combine operationszc is a builder of Shapes and can't be combined. The object being constructed is accessible via the 'z' attribute.)rÒ   r®   r�   r    r}   s    r6   Ú_invalid_combinezBuilder._invalid_combine   s5   € äØ�~‰~×&Ñ&Ð'ð (à—‘Ð˜|ð-ó
ð 	
r<   c                ó"   — | j                  «       S )zInvalid add©r"  ©rv   Ú_others     r6   Ú__add__zBuilder.__add__(  ó   € à×$Ñ$Ó&Ð&r<   c                ó"   — | j                  «       S )zInvalid subr$  r%  s     r6   Ú__sub__zBuilder.__sub__,  r(  r<   c                ó"   — | j                  «       S )zInvalid andr$  r%  s     r6   Ú__and__zBuilder.__and__0  r(  r<   c                óœ   — t        d| j                  j                  › d|› d| j                  j                  › d| j                  › d|› d�«      ‚)z;The user is likely trying to reference the builder's objectÚ'z' has no attribute 'z'. Did you intend '<z>.Ú.z'?)ÚAttributeErrorr®   r�   r    )rv   Únames     r6   Ú__getattr__zBuilder.__getattr__4  sX   € äØ�—‘×'Ñ'Ð(Ð(<¸T¸Fð C Ø $§¡× 7Ñ 7Ð8¸¸4¿>¹>Ð:JÈ!ÈDÈ6ÐQSðUó
ð 	
r<   )ri   úFace | Plane | Locationrd   r   )Úreturnr"   )r€   r!   r4  rb   )r4  r3   )r4  úShapeList[Edge])rª   zEdge | Facer¨   zPlane | None)NT)r°   zType[B]r±   z$Builder | Shape | Joint | str | Noner²   Úboolr4  zB | None)rª   z%Edge | Wire | Face | Solid | Compoundr¶   r6  r·   r6  rd   r   )rñ   r   r4  zShapeList[Vertex])rñ   r   r4  r&   )rñ   r   r4  r5  )rñ   r   r4  r   )rñ   r   r4  zShapeList[Wire])rñ   r   r4  r'   )rñ   r   r4  zShapeList[Face])rñ   r   r4  r   )rñ   r   r4  zShapeList[Solid])rñ   r   r4  r%   r0   )r  z;Type[Vertex] | Type[Edge] | Type[Face] | Type[Solid] | Noner4  r#   )rª   zShape | Iterable[Shape] | None)r4  r   )-r�   Ú
__module__Ú__qualname__Ú__doc__ÚcontextvarsÚ
ContextVarra   Ú__annotations__r¡   r    r   rÎ   ry   Úpropertyr   r~   Úsetterr„   r)   r�   r”   r£   r«   Úclassmethodr‹   r¢   r   rì   rí   rø   rË   rþ   r  r  r	  r  r  r  rÌ   r   r"  r'  r*  r,  r2  r“   r<   r6   r^   r^   µ   s:  … ñð$ 1G°×0FÑ0FØó1€HÐ-ó ð
 €DØ€Ið —X‘Xñ*à,ð*ð ó*ð* Øò"ó ó ð"ð 
‡[�[Øò"ó ó ð"ð òGó ðGð òOó ðOò
!òF0ò7ð4 ØPTô #ó ð#ð ð 8<ØðØðà4ðð ðð 
ò	ó ðð. "&ØØ—X‘Xñq3à7ðq3ð ðq3ð ð	q3ð
 óq3ðj )/¯
©
ô +ð2 '-§j¡jô ð( &,§Z¡Zô $ð. %+§J¡Jô ð( &,§Z¡Zô $ð. %+§J¡Jô ð( &,§Z¡Zô $ð. %+§J¡Jô ð( '-§j¡jô %ð. &,§Z¡Zô ð, QUðàMðð 
óð& KOð'Ø)Gó'òR
ó'ó'ó'ó
r<   c                ó.   — | €y| j                  ||«       y)zDA function to wrap the method when used outside of a Builder contextN)r   )Úcontextr  rª   s      r6   r   r   <  s   € ð €Øà×ÑÐ 0°'Õ:r<   c                  óŠ   — e Zd ZU dZ ej
                  d«      Zded<   edd„«       Z	dd„Z
d„ Zd„ Zd	„ Zd
„ Zdd„Zed„ «       Zy)ÚLocationLista`  Location Context

    A stateful context of active locations. At least one must be active
    at all time. Note that local locations are stored and global locations
    are returned as a property of the local locations and the currently
    active workplanes.

    Args:
        locations (list[Location]): list of locations to add to the context

    zContextList._currentz$contextvars.ContextVar[LocationList]ra   c                óÖ   — t         j                  «       }|r|j                  nt        j                  g}|D ��cg c]"  }| j
                  D ]  }|j                  |z  ‘Œ Œ$ }}}|S c c}}w )z:Current local locations globalized with current workplanes)rf   r‹   ri   r   rh   Úlocal_locationsÚlocation)rv   rA  ri   rã   Úlocal_locationÚglobal_locationss         r6   Ú	locationszLocationList.locationsX  sr   € ô  ×,Ñ,Ó.ˆÙ+2�W×'Ò'¼¿¹¸
ˆ
ñ $ô
á#�Ø"&×"6Ô"6�ð �N‰N˜^Ó+à"6ð ,Ø#ð 	ñ 
ð
  Ðùó
s   ¹'A%c                óJ   — d | _         || _        d| _        d| _        d | _        y ©Nr   )rj   rE  Úlocation_indexÚplane_indexÚiter_loc)rv   rI  s     r6   ry   zLocationList.__init__d  s(   € ØˆŒØ(ˆÔØˆÔØˆÔØˆ�r<   c                óÖ   — | j                   j                  | «      | _        t        j	                  dt        | «      j                  t        | j                  «      | j                  «       | S )ú3Upon entering create a token to restore contextvarsz%s is pushing %d points: %s)	ra   rA   rj   rŒ   r�   rŽ   r�   rº   rE  r}   s    r6   r�   zLocationList.__enter__k  sR   € àŸ-™-×+Ñ+¨DÓ1ˆŒä�‰Ø)Ü�‹J×ÑÜ�×$Ñ$Ó%Ø× Ñ ô		
ð ˆr<   c                óÈ   — | j                   j                  | j                  «       t        j	                  dt        | «      j                  t        | j                  «      «       y)úUpon exiting restore contextz%s is popping %d pointsN)	ra   r™   rj   rŒ   r�   rŽ   r�   rº   rE  r¤   s       r6   r£   zLocationList.__exit__w  s@   € à�‰×Ñ˜DŸO™OÔ,Ü�‰Ø%¤t¨D£z×':Ñ':¼CÀ×@TÑ@TÓ<Uõ	
r<   c                ó6   — d| _         | j                  | _        | S ©zInitialize to beginningr   )rL  rI  rN  r}   s    r6   Ú__iter__zLocationList.__iter__~  s   € àˆÔØŸ™ˆŒØˆr<   c                ó²   — | j                   t        | j                  «      k\  rt        ‚| j                  | j                      }| xj                   dz  c_         |S )z8While not through all the locations, return the next oner+   )rL  rº   rN  ÚStopIteration©rv   r³   s     r6   Ú__next__zLocationList.__next__„  sI   € à×Ñ¤# d§m¡mÓ"4Ò4ÜÐØ—‘˜t×2Ñ2Ñ3ˆØ×Ò˜qÑ ÕØˆr<   c                ó|   — t        |t        «      st        d«      ‚| j                  D �cg c]  }||z  ‘Œ	 c}S c c}w )z.Vectorized application of locations to a shapez0Location list can only be multiplied with shapes)r1   r"   rÂ   rI  )rv   ÚshapeÚlocs      r6   Ú__mul__zLocationList.__mul__Œ  s8   € ä˜%¤Ô'ÜÐOÓPÐPØ'+§~¢~Ó6¡~ ��e“ ~Ñ6Ð6ùÒ6s   ª9c                ó8   — | j                   j                  d«      S )z/Return the instance of the current LocationListN©ra   r­   ©r°   s    r6   r‹   zLocationList._get_context’  ó   € ð �|‰|×Ñ Ó%Ð%r<   N)r4  úlist[Location])rI  rb  )r[  r"   r4  zlist[Shape])r�   r7  r8  r9  r:  r;  ra   r<  r=  rI  ry   r�   r£   rU  rY  r]  r?  r‹   r“   r<   r6   rC  rC  F  sm   … ñ
ð 6L°[×5KÑ5KØó6€HÐ2ó ð ò	 ó ð	 óò
ò
òòó7ð ñ&ó ñ&r<   rC  c                  óh   ‡ — e Zd ZdZdej
                  ej
                  ff	 	 	 	 	 	 	 	 	 dˆ fd„Zˆ xZS )ÚHexLocationsau  Location Context: Hex Array

    Creates a context of hexagon array of locations for Part or Sketch. When creating
    hex locations for an array of circles, set `radius` to the radius of the circle
    plus one half the spacing between the circles.

    Args:
        radius (float): distance from origin to vertices (major), or
            optionally from the origin to side (minor or apothem)
            with major_radius = False
        x_count (int): number of points ( > 0 )
        y_count (int): number of points ( > 0 )
        major_radius (bool): If True the radius is the major radius, else the
            radius is the minor radius (also known as inscribed radius).
            Defaults to False.
        align (Union[Align, tuple[Align, Align]], optional): align min, center, or max of object.
            Defaults to (Align.CENTER, Align.CENTER).

    Attributes:
        radius (float): distance from origin to vertices (major), or
            optionally from the origin to side (minor or apothem)
            with major_radius = False
        apothem (float): radius of the inscribed circle, also known as minor radius
        x_count (int): number of points ( > 0 )
        y_count (int): number of points ( > 0 )
        major_radius (bool): If True the radius is the major radius, else the
            radius is the minor radius (also known as inscribed radius).
        align (Union[Align, tuple[Align, Align]]): align min, center, or max of object.
        diagonal (float): major radius
        local_locations (list{Location}): locations relative to workplane

    Raises:
        ValueError: Spacing and count must be > 0
    Fc           
     ó  •— |rd|z  }|t        t        dz  «      z  }nd|z  t        d«      z  }|}d|z  dz  }|t        d«      z  dz  }	|dk  s|	dk  s
|dk  s|dk  rt        d«      ‚|| _        || _        || _        || _        || _        || _	        t        |d«      | _        t        t           «       }
t        d|d«      D ]9  }t        |«      D ])  }|
j                  t        ||z  |	|z  |	dz  z   «      «       Œ+ Œ; t        d|d«      D ]6  }t        |«      D ]&  }|
j                  t        ||z  |	|z  |	z   «      «       Œ( Œ8 |
j!                  t"        j$                  «      |
j!                  t"        j&                  «      g}|d   d   j$                  |d   d   j$                  z
  |d   d   j&                  |d   d   j&                  z
  g}t        |d   d   j$                  |d   d   j&                  «      }t)        d	||«      }t        |
D �cg c]  }|t        |Ž z   |z
  ‘Œ c}«      }
|
D �cg c]  }t+        |«      ‘Œ }}t,        j/                  |«      | _        t2        ‰| �i  | j0                  «       y c c}w c c}w )
Nr–   é   é   é   r   r+   zSpacing and count must be > 0 éÿÿÿÿ©r   r   )r   r	   r   rÂ   ÚradiusÚapothemrƒ   Úx_countÚy_countÚmajor_radiusr(   Úalignr#   r   ÚrangerD   Úsort_byr   ÚXÚYr   r   Ú	LocationsÚ_move_to_existingrE  Úsuperry   )rv   rk  rm  rn  ro  rp  rƒ   rl  Ú	x_spacingÚ	y_spacingÚpointsÚx_valÚy_valÚsorted_pointsÚsizeÚ
min_cornerÚalign_offsetÚpointrE  r®   s                      €r6   ry   zHexLocations.__init__¼  s’  ø€ ñ Ø˜6‘zˆHØœs¤2¨¡6›{Ñ*‰Gà˜6‘z¤D¨£GÑ+ˆHØˆGà˜‘L 1Ñ$ˆ	Øœt A›wÑ&¨Ñ*ˆ	Ø˜Š>˜Y¨!š^¨w¸ª{¸gÈºkÜÐ=Ó>Ð>àˆŒØˆŒØ ˆŒØˆŒØˆŒØ(ˆÔÜ˜U AÓ&ˆŒ
ô œ6Ñ"Ó$ˆÜ˜1˜g qÖ)ˆEÜ˜wž�Ø—‘Ü˜9 uÑ,¨i¸%Ñ.?À)ÈaÁ-Ñ.OÓPõñ (ð *ô
 ˜1˜g qÖ)ˆEÜ˜wž�Ø—‘œf Y°Ñ%6¸	ÀEÑ8IÈIÑ8UÓVÕWñ (ð *ð
  Ÿ™¬¯©Ó/°·±ÄÇÁÓ1GÐHˆð ˜!Ñ˜RÑ ×"Ñ" ]°1Ñ%5°aÑ%8×%:Ñ%:Ñ:Ø˜!Ñ˜RÑ ×"Ñ" ]°1Ñ%5°aÑ%8×%:Ñ%:Ñ:ð
ˆô ˜M¨!Ñ,¨QÑ/×1Ñ1°=ÀÑ3CÀAÑ3F×3HÑ3HÓIˆ
ô ' v¨t°UÓ;ˆô ÙEKÓLÁV¸EˆU”V˜\Ð*Ñ*¨ZÓ7ÀVÑLó
ˆñ
 9?Ó?¹¨uœ8 E�?¸ˆÐ?ä(×:Ñ:Øó 
ˆÔô 	‰Ñ˜×-Ñ-Õ.ùò Mùò @s   ÈI7È/I<)
rk  r3   rm  r2   rn  r2   ro  r6  rp  úAlign | tuple[Align, Align]©r�   r7  r8  r9  r   ÚCENTERry   Ú__classcell__©r®   s   @r6   rd  rd  ˜  s_   ø„ ñ!ðP #Ø.3¯l©l¸E¿L¹LÐ-IðB/àðB/ð ðB/ð ð	B/ð
 ðB/ð +÷B/ñ B/r<   rd  c                  óD   ‡ — e Zd ZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Zˆ xZS )ÚPolarLocationsa  Location Context: Polar Array

    Creates a context of polar array of locations for Part or Sketch

    Args:
        radius (float): array radius
        count (int): Number of points to push
        start_angle (float, optional): angle to first point from +ve X axis. Defaults to 0.0.
        angular_range (float, optional): magnitude of array from start angle. Defaults to 360.0.
        rotate (bool, optional): Align locations with arc tangents. Defaults to True.
        endpoint (bool, optional): If True, `start_angle` + `angular_range` is the last sample.
            Otherwise, it is not included. Defaults to False.

    Attributes:
        local_locations (list{Location}): locations relative to workplane

    Raises:
        ValueError: Count must be greater than or equal to 1
    c                ó¤  •— |dk  rt        d|› �«      ‚|dk(  rd}n||t        |«      z
  z  }g }t        |«      D ]`  }	|j                  t	        t        |d«      j                  t        j                  |||	z  z   «      t        ddd«      |||	z  |z   z  «      «       Œb t        j                  |«      | _        t        ‰
| �5  | j                  «       y )Nr+   ú(At least 1 elements required, requested r‚   r   )rÂ   r2   rq  rD   r   r   Úrotater   rÊ   ru  rv  rE  rw  ry   )rv   rk  ÚcountÚstart_angleÚangular_ranger‹  ÚendpointÚ
angle_steprE  Úir®   s             €r6   ry   zPolarLocations.__init__  s×   ø€ ð �1Š9ÜÐGÈÀwÐOÓPÐPØ�AŠ:Ø‰Jà&¨%´#°h³-Ñ*?Ñ@ˆJð ˆÜ�u–ˆAØ×"Ñ"ÜÜ˜6 1Ó%×,Ñ,¬T¯V©V°[À:ÐPQÁ>Ñ5QÓRÜ˜1˜a “OØ˜j¨1™n¨{Ñ:Ñ;óõð ô  )×:Ñ:Øó 
ˆÔô 	‰Ñ˜×-Ñ-Õ.r<   )r‚   g     €v@TF)rk  r3   rŒ  r2   r�  r3   rŽ  r3   r‹  r6  r�  r6  )r�   r7  r8  r9  ry   r…  r†  s   @r6   rˆ  rˆ    sZ   ø„ ñð0 !Ø$ØØð/àð/ð ð/ð ð	/ð
 ð/ð ð/ð ÷/ñ /r<   rˆ  c                  ó:   ‡ — e Zd ZdZ	 	 dˆ fd„Zedd„«       Zˆ xZS )ru  aA  Location Context: Push Points

    Creates a context of locations for Part or Sketch

    Args:
        pts (Union[VectorLike, Vertex, Location, Face, Plane, Axis] or iterable of same):
            sequence of points to push

    Attributes:
        local_locations (list{Location}): locations relative to workplane

    c           	     óX  •— g }t        |Ž D �]h  }t        |t        «      r|j                  |«       Œ&t        |t        «      r|j                  t        |«      «       ŒQt        |t
        «      r2|j                  t        t	        |j                  «       «      «      «       Œ“t        |t        «      r$|j                  t        t	        |«      «      «       ŒÇt        |t        «      r|j                  t        |«      «       Œòt        |t        «      r|j                  |j                  «       �Œt        |t        «      r%|j                  t        t        |«      «      «       �ŒTt        dt        |«      › �«      ‚ t        j                  |«      | _        t"        ‰| �I  | j                   «       y )NzLocations doesn't accept type )rC   r1   r   rD   r   r&   Úto_tupler8   r   r   rF  r   rÂ   rŽ   ru  rv  rE  rw  ry   )rv   ÚptsrE  r�  r®   s       €r6   ry   zLocations.__init__F  s4  ø€ ð ˆÜ% sÔ+ˆEÜ˜%¤Ô*Ø×&Ñ& uÕ-Ü˜E¤6Ô*Ø×&Ñ&¤x°£Õ7Ü˜E¤6Ô*Ø×&Ñ&¤x´°u·~±~Ó7GÓ0HÓ'IÕJÜ˜E¤5Ô)Ø×&Ñ&¤x´°u³Ó'>Õ?Ü˜E¤5Ô)Ø×&Ñ&¤x°£Õ7Ü˜E¤4Ô(Ø×&Ñ& u§~¡~Ö6Ü˜E¤4Ô(Ø×&Ñ&¤x´°e³Ó'=Ö>ä Ð#AÄ$ÀuÃ+ÀÐ!OÓPÐPð! ,ô$  )×:Ñ:Øó 
ˆÔô 	‰Ñ˜×-Ñ-Õ.r<   c                óÎ   — g }t         j                  «       �Gt         j                  «       j                  D ]$  }|j                  | D �cg c]  }||z  ‘Œ	 c}«       Œ& |S | }|S c c}w )a�  _move_to_existing

        Move as a group the local locations to any existing locations  Note that existing
        polar locations may be rotated so this rotates the group not the individuals.

        Args:
            local_locations (list[Location]): location group to move to existing locations

        Returns:
            list[Location]: group of locations moved to existing locations as a group
        )rC  r‹   rE  rB   )rE  Úlocation_groupÚgroup_centerrÜ   s       r6   rv  zLocations._move_to_existingj  so   € ð ˆÜ×$Ñ$Ó&Ð2Ü ,× 9Ñ 9Ó ;× KÔ K�Ø×%Ñ%ÁÓ&QÁ¸A |°aÓ'7ÀÑ&QÕRð !Lð Ðð -ˆNØÐùò 'Rs   ÁA"
)r•  zuVectorLike | Vertex | Location | Face | Plane | Axis | Iterable[VectorLike | Vertex | Location | Face | Plane | Axis])rE  rb  r4  rb  )r�   r7  r8  r9  ry   Ústaticmethodrv  r…  r†  s   @r6   ru  ru  8  s-   ø„ ñð"/ðMõ"/ðH òó ôr<   ru  c                  óf   ‡ — e Zd ZdZej
                  ej
                  ff	 	 	 	 	 	 	 	 	 dˆ fd„Zˆ xZS )ÚGridLocationsa¢  Location Context: Rectangular Array

    Creates a context of rectangular array of locations for Part or Sketch

    Args:
        x_spacing (float): horizontal spacing
        y_spacing (float): vertical spacing
        x_count (int): number of horizontal points
        y_count (int): number of vertical points
        align (Union[Align, tuple[Align, Align]], optional): align min, center, or max of object.
            Defaults to (Align.CENTER, Align.CENTER).


    Attributes:
        x_spacing (float): horizontal spacing
        y_spacing (float): vertical spacing
        x_count (int): number of horizontal points
        y_count (int): number of vertical points
        align (Union[Align, tuple[Align, Align]]): align min, center, or max of object.
        local_locations (list{Location}): locations relative to workplane

    Raises:
        ValueError: Either x or y count must be greater than or equal to one.
    c                óL  •— |dk  s|dk  rt        d|› d|› �«      ‚|| _        || _        || _        || _        t        |d«      | _        ||dz
  z  ||dz
  z  g}t        |Ž | _        t        d||«      }|| _
        | j                  | j                  z   | _        t        t        |«      t        |«      «      D ��	cg c]#  \  }}	t        |t        ||z  |	|z  «      z   «      ‘Œ% }
}}	t        j!                  |
«      | _        g | _        t&        ‰| �Q  | j"                  «       y c c}	}w )Nr+   rŠ  z, r–   rj  )rÂ   rx  ry  rm  rn  r(   rp  r   r~  r   ÚminÚmaxr   rq  r   ru  rv  rE  rw   rw  ry   )rv   rx  ry  rm  rn  rp  r~  r€  r‘  ÚjrE  r®   s              €r6   ry   zGridLocations.__init__œ  sB  ø€ ð �QŠ;˜' Aš+ÜØ:¸7¸)À2ÀgÀYÐOóð ð #ˆŒØ"ˆŒØˆŒØˆŒÜ˜U AÓ&ˆŒ
à˜W q™[Ñ)¨9¸À!¹Ñ+DÐEˆÜ˜D�MˆŒ	ä& v¨t°UÓ;ˆàˆŒØ—8‘8˜dŸi™iÑ'ˆŒô  ¤ g£´°g³Ô?ô	
ñ @‘��1ô ØÜØ˜	‘MØ˜	‘Móñõð @ð 	ñ 	
ô  )×:Ñ:Øó 
ˆÔð $&ˆŒÜ‰Ñ˜×-Ñ-Õ.ùó	
s   Â:(D )
rx  r3   ry  r3   rm  r2   rn  r2   rp  r‚  rƒ  r†  s   @r6   r›  r›  €  sU   ø„ ñðB /4¯l©l¸E¿L¹LÐ-Ið*/àð*/ð ð*/ð ð	*/ð
 ð*/ð +÷*/ñ */r<   r›  c                  óÌ   — e Zd ZU dZ ej
                  d«      Zded<   dd„Ze	dd„«       Z
d„ Zd„ Zd	„ Zd
„ Zed„ «       Zeedd„«       «       Zeedd„«       «       Zedd„«       Zy)rf   a  Workplane Context

    A stateful context of active workplanes. At least one must be active
    at all time.

    Args:
        workplanes (sequence of Union[Face, Plane, Location]): objects to become planes

    Attributes:
        workplanes (list[Plane]): list of workplanes

    zWorkplaneList._currentz%contextvars.ContextVar[WorkplaneList]ra   c                ób   — d | _         t        j                  |«      | _        d | _        d| _        y rK  )rj   rf   rg   ri   Úlocations_contextrM  )rv   ri   s     r6   ry   zWorkplaneList.__init__Ü  s+   € ØˆŒÜ'×:Ñ:¸:ÓFˆŒØ!%ˆÔØˆÕr<   c                óú   — t        | Ž } g }| D ]k  }t        |t        «      r|j                  |«       Œ%t        |t        t
        f«      r|j                  t        |«      «       ŒVt        dt        |«      › �«      ‚ |S )zTranslate objects to planeszWorkplaneList does not accept )rC   r1   r   rD   r   r   rÂ   rŽ   )Úobjsrw   r:   s      r6   rg   z WorkplaneList._convert_to_planesâ  sp   € ô   Ð&ˆØˆÛˆCÜ˜#œuÔ%Ø—‘˜cÕ"Ü˜C¤(¬DÐ!1Ô2Ø—‘œe C›jÕ)ä Ð#AÄ$ÀsÃ)ÀÐ!MÓNÐNð ð ˆr<   c                ó6  — | j                   j                  | «      | _        t        j	                  dt        | «      j                  t        | j                  «      | j                  «       t        t        t        «       «      g«      j                  «       | _        | S )rP  z%s is pushing %d workplanes: %s)ra   rA   rj   rŒ   r�   rŽ   r�   rº   ri   rC  r   r   r�   r¢  r}   s    r6   r�   zWorkplaneList.__enter__ð  sn   € àŸ-™-×+Ñ+¨DÓ1ˆŒÜ�‰Ø-Ü�‹J×ÑÜ�—‘Ó Ø�O‰Oô		
ô ".¬x¼»Ó/AÐ.BÓ!C×!MÑ!MÓ!OˆÔØˆr<   c                ó  — | j                   j                  | j                  «       | j                  j	                  ddd«       t
        j                  dt        | «      j                  t        | j                  «      «       y)rR  Nz%s is popping %d workplanes)ra   r™   rj   r¢  r£   rŒ   r�   rŽ   r�   rº   ri   r¤   s       r6   r£   zWorkplaneList.__exit__ü  sV   € à�‰×Ñ˜DŸO™OÔ,Ø×Ñ×'Ñ'¨¨d°DÔ9Ü�‰Ø)¬4°«:×+>Ñ+>ÄÀDÇOÁOÓ@Tõ	
r<   c                ó   — d| _         | S rT  )rM  r}   s    r6   rU  zWorkplaneList.__iter__  s   € àˆÔØˆr<   c                ó²   — | j                   t        | j                  «      k\  rt        ‚| j                  | j                      }| xj                   dz  c_         |S )z9While not through all the workplanes, return the next oner+   )rM  rº   ri   rW  rX  s     r6   rY  zWorkplaneList.__next__	  sI   € à×Ñœs 4§?¡?Ó3Ò3ÜÐØ—‘ ×!1Ñ!1Ñ2ˆØ×Ò˜AÑÕØˆr<   c                ó8   — | j                   j                  d«      S )z.Return the instance of the current ContextListNr_  r`  s    r6   r‹   zWorkplaneList._get_context  ra  r<   c                 ó   — y r0   r“   ©r°   rz  s     r6   ÚlocalizezWorkplaneList.localize  s   € à58r<   c                 ó   — y r0   r“   r«  s     r6   r¬  zWorkplaneList.localize  s   € à<?r<   c                óè  — t         j                  «       €|D �cg c]  }t        |«      ‘Œ }}n§g }t         j                  «       j                  d   }|D �cg c]E  }t	        |t
        «      r(t        t        |j                  t        |«      «      «      n
t        |«      ‘ŒG }}t        |«      dk(  r|j                  |d   «       n|j                  |«       t        |«      dk(  r|d   S |S c c}w c c}w )zòLocalize a sequence of points to the active workplane
        (only used by BuildLine where there is only one active workplane)

        The return value is conditional:
        - 1 point -> Vector
        - >1 points -> list[Vector]
        r   r+   )rf   r‹   r   ri   r1   r8   r   rÙ   rº   rD   rB   )r°   rz  ÚpÚpoints_per_workplaneÚ	workplaneÚptÚlocalized_ptss          r6   r¬  zWorkplaneList.localize  sø   € ô ×%Ñ%Ó'Ð/Ù7=Ó#>±v°!¤F¨1¥I°vÐ Ñ#>à#%Ð Ü%×2Ñ2Ó4×?Ñ?ÀÑBˆIñ !óñ !�Bô " "¤eÔ,ô œ ×!<Ñ!<¼VÀB»ZÓ!HÔIä ›ñ$ð !ð ð ô �=Ó! QÒ&Ø$×+Ñ+¨M¸!Ñ,<Õ=à$×+Ñ+¨MÔ:äÐ#Ó$¨Ò)Ø'¨Ñ*Ð*Ø#Ð#ùò' $?ùòs   ™C*ÁA
C/N)ri   r3  )r¤  z!Iterable[Face | Plane | Location]r4  zlist[Plane])rz  r   r4  r   )rz  r   r4  zlist[Vector])rz  r   )r�   r7  r8  r9  r:  r;  ra   r<  ry   r™  rg   r�   r£   rU  rY  r?  r‹   r   r¬  r“   r<   r6   rf   rf   É  s¨   … ñð 7M°k×6LÑ6LØ ó7€HÐ3ó óð òó ðò
ò
òò
ð ñ&ó ð&ð ØÚ8ó ó à8àØÚ?ó ó à?àò$ó ñ$r<   rf   ÚT2c                ód   ‡ — t        j                  ‰ «      t        j                  fdˆ fd„«       }|S )ay  
    Wraps a Builder method to automatically provide the Builder context.

    This function creates a wrapper around the provided Builder method (`func`) that
    automatically retrieves the current Builder context and passes it as the first
    argument to the method. This allows the method to be called without explicitly
    providing the Builder context.

    Args:
        func (Callable[[Builder, Select], T2]): The Builder method to be wrapped.
            - The method must take a `Builder` instance as its first argument and
              a `Select` instance as its second argument.

    Returns:
        Callable[[Select], T2]: A callable that takes only a `Select` argument and
        internally retrieves the Builder context to call the original method.

    Raises:
        RuntimeError: If no Builder context is available when the returned function
        is called.
    c                óˆ   •— t         j                  ‰j                  «      }|st        ‰j                  › d�«      ‚ ‰|| «      S )Nz,() requires a Builder context to be in scope)r^   r‹   r�   rÒ   )rñ   rA  Úfuncs     €r6   Úgetterz.__gen_context_component_getter.<locals>.getter[  sG   ø€ ô ×&Ñ& t§}¡}Ó5ˆÙÜØ—=‘=�/Ð!MÐNóð ñ �G˜VÓ$Ð$r<   )rñ   r   r4  r´  )Ú	functoolsÚwrapsr   rì   )r·  r¸  s   ` r6   Ú__gen_context_component_getterr»  B  s.   ø€ ô2 ‡_�_�TÓÜ &§
¡
õ %ó ð%ð €Mr<   c                ó   ‡ — dˆ fd„}|S )Nc                óÜ   •— t        |t        «      rD	 t        j                  «       j                  d   j
                  }t        j                  |«      |z
  } ‰| |«      S # t        $ r Y Œw xY wrK  )r1   r8   rf   r‹   ri   r½   r¬  r0  )rv   Úvecr½   Úoriginal_ops      €r6   Úwrapperz(_vector_add_sub_wrapper.<locals>.wrapper|  si   ø€ Ü�cœ5Ô!ðä&×3Ñ3Ó5×@Ñ@ÀÑC×JÑJ�Ü#×,Ñ,¨SÓ1°FÑ:�ñ ˜4 Ó%Ð%øô "ò áðús   “AA Á	A+Á*A+)rv   r   r¾  r   r“   )r¿  rÀ  s   ` r6   Ú_vector_add_sub_wrapperrÁ  {  s   ø€ õ	&ð €Nr<   z-monkey-patching `Vector.add` and `Vector.sub`)r:   r=   r4  zShapeList[Any]r0   )rA  zBuilder | Nonerª   zIterable[Shape] | None)r·  zCallable[[Builder, Select], T2]r4  zCallable[[Select], T2])r¿  z&Callable[[Vector, VectorLike], Vector])er9  Ú
__future__r   r:  rk   Úloggingrœ   rž   r¹  Úabcr   r   Ú	itertoolsr   Úmathr   r   r	   Útypingr
   r   r   r   r   Úcollections.abcr   r   Útyping_extensionsr   Úbuild123d.build_enumsr   r   r   r   Úbuild123d.geometryr   r   r   r   r   r   Úbuild123d.topologyr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   Ú	getLoggerÚ
addHandlerÚNullHandlerrŒ   ÚMCÚMMÚCMÚMÚINÚFTÚTHOUÚUNITS_PER_METERÚGÚKGÚLBr;   r?   r=   rC   r  r]   r^   r   rC  rd  rˆ  ru  r›  rf   r´  r»  rí   rË   r  r	  r  rø   rþ   r  r  r  rÁ  r›   rF   Úsubr“   r<   r6   Ú<module>rÜ     sÒ  ðñ'õR #ã Û Û Û 
Û Û ß #Ý ß Ñ ß 5Õ 5ç .Ý "ç ;Ó ;÷÷ ÷÷ ÷ ÷ ð* €× Ñ �+Ó × )Ñ )Ð*=¨'×*=Ñ*=Ó*?Ô @Ø	ˆ×	Ñ	˜;Ó	'€ð  €Ø€Øˆ"�W€Øˆ2�I€Ø	ˆB�Y€Øˆ"�W€Ø	ˆD�y€ð 	‡G�GˆQ�‰VØ‡G�GˆQ�‰VØ‡G�GˆQ�‰VØ‡G�GˆQ�‰VØ‡G�GˆQ�‰VØ‡F�FˆAð€ð €Ø	ˆA�X€Ø��]€òñ ˆC��d˜3‘iÓ €óðØ	Ò4ðàÒ=ðð Ò8ðð �ˆ}ð	ð
 Ò7ðð �=�/ðð ˆ[ˆMðð ˜+˜ðð �-�ðð �-�ðð Ò7ðð Ò7ðð Ò8ðð ˜+˜ðð �ˆ}ðð  Ò6ð!ð" �ˆ}ð#ò$ 7Ø˜=Ð)Øˆ}ò)Ð ñ. ˆC�yÔ!€Ø ôD

ˆcô D

ðP RVð;Øð;Ø8Nó;÷O&ñ O&ôdf/�<ô f/ôR4/�\ô 4/ônE�ô EôPF/�Lô F/÷Rr$ñ r$ñl ˆTƒ]€ð$Ø
)ð$àó$ñP *¨'×*:Ñ*:Ó;€Ù& w§}¡}Ó5€Ù& w§}¡}Ó5€Ù& w§}¡}Ó5€Ù	'¨¯©Ó	7€á	'¨¯©Ó	7€Ù% g§l¡lÓ3€Ù% g§l¡lÓ3€Ù% g§l¡lÓ3€Ù& w§}¡}Ó5€óð ‡�Ð<Ô =Ù$ V§Z¡ZÓ0€„
Ù$ V§Z¡ZÓ0€…
r<   