
    ic                     X    d Z ddlmZmZmZ ddlZddlmZ ddlmZ  G d d          Z	dS )z
Browser Tools Mixin - High-level operations

Provides complex workflows like cookie banner handling, archive operations, search.
Used as a mixin for BrowserNavigator to keep code organized.
    )OptionalDictAnyN)datetime)SearchObjectc            	       D    e Zd ZdZddedee         deeef         fdZdS )ToolsExecutorz~
    Mixin providing high-level tool operations.
    
    Requires parent to have:
    - _get_page_to_use(page_id) method
    Ndescriptionpage_idreturnc                   K   t          j                    }|                     |           d{V }	 |                    d|            d{V  t	                      }|                    ||           d{V }t          j                    }||z
                                  }||d<   t          d           ||                                 d{V  S # t          $ rp}	t          d|	            |
                    t          |	                     d{V  dt          |	          dcY d}	~	|                                 d{V  S d}	~	ww xY w# |                                 d{V  w xY w)ai  
        Search for an object on the page based on description using vision AI.

        Args:
            description (str): Description of the object to search for
            page_id (str, optional): Specific page ID to use, or None for any available page

        Returns:
            Dict containing search result with bounding box and coordinates
        Nzsearching for object: duration_secondsu   ✅ Object search completedu   ❌ Object search failed: F)successerror)r   now_get_page_to_useset_busyr   searchtotal_secondsprintset_idle	Exception	set_errorstr)
selfr
   r   
start_timemanaged_pagesearcherresultend_timedurationes
             6/home/byschii/byschiidev/penelope/lib/browser_tools.pydo_search_objectzToolsExecutor.do_search_object   s      \^^
!227;;;;;;;;	*''(N(N(NOOOOOOOOO $~~H#??<EEEEEEEEF|~~H :-<<>>H)1F%&0111 ''))))))))))  	7 	7 	72q22333((Q000000000$s1vv6666666 ''))))))))))	7 ''))))))))))s1   BC 
EAE	)E*E 	EE E-)N)	__name__
__module____qualname____doc__r   r   r   r   r$        r#   r	   r	      s]         "* "*# "* "*Y]^acf^fYg "* "* "* "* "* "*r*   r	   )
r(   typingr   r   r   	tracebackr   lib.highlevel.search_objectr   r	   r)   r*   r#   <module>r.      s     ' & & & & & & & & &           4 4 4 4 4 4** ** ** ** ** ** ** ** ** **r*   