§
   C‡S•é–¯ã                   ó¾   — d Z ddlZddlZddlmZ ddlmZmZm	Z	m
Z
  eefi ej        ej        i¤ŽZdZdZdZdZd	Zd
ZdZd„ Zd„ Z G d„ de¦  «        Zd„ Zd„ Zd„ ZdS )uH  Which row the hero of a cinematic Home section reads (docs/plan/skin-milionar/190-cinema.md, 220-hero-buttons.md).

The hero always shows the selected item of the current row: a card that is no title (a genre, a row action) has a hero
of its own (hero.tile), so the hero never shows something the cursor is not on. Only before any row was current, or when
the current row emptied, it shows the first row with a title. The skin used to work this out in generated conditions that compared every slot with every other one (2 MB of XML for 7 slots, 3 MB for 14). Now one
Window(Home) property names the row: milionar.hero.<sec> = its list id, and per slot the skin tests only that.

  * A row sets it itself when it gets the focus (gen_cinema ROW, no delay).
  * This watcher does the rest a few times a second: the first row with a title when nothing (or an emptied row) is
    named, and the borrowed buttons of an emptied current row: milionar.hero.<sec>.lent = true and .lent.<b1â€¦> copied
    from the hero item's milionar.hero.s<slot>.* (written by hero_buttons.lent when the rows are built).
é    N)Úcontract)ÚBASESÚSECTIONSÚlist_idÚ
slot_countzmilionar.hero.{}zmilionar.hero.{}.lent)	Úb1Úb2Úb3Úb4Úb1lÚb2lÚb3lÚb4lÚb1ig      ð?g       @é
   z4Window.IsActive(home) + !System.HasActiveModalDialogc                 ó`   — |D ]\  }}}|| k    r|r|c S Œt          d„ |D ¦   «         d¦  «        S )zäThe list id the hero reads. `current`: the current row's list id (''); `rows`: [(list id, has items, the selected
    item has a title)] in slot order. The current row when it has items, else the first row with a title, else ''.c              3   ó*   K  — | ]\  }}}|¯|¯
|V — Œd S )N© )Ú.0ÚlidÚitemsÚtitleds       úb/Users/chudy/Library/Application Support/Kodi/addons/plugin.video.milionar/wcs/skin/hero_source.pyú	<genexpr>zchoose.<locals>.<genexpr>)   s3   è è € ÐHÐHÑ+˜˜e V°uÐHÀÐH�ÐHÐHÐHÐHÐHÐHó    Ú )Únext)ÚcurrentÚrowsr   r   Ú_titleds        r   Úchooser!   #   sP   € ð  $ð ð ÑˆˆU�GØ�'Š>ˆ>˜eˆ>ØˆJˆJˆJøÝÐHÐH¨tÐHÑHÔHÈ"ÑMÔMÐMr   c                 ó2   — | r|r| |k    r| |v r||          S dS )z�The slot whose button layout applies to the hero item: the current row when it is not the source (it emptied),
    else None. `rows_by_lid`: {list id: slot}.Nr   )r   ÚsourceÚrows_by_lids      r   Ú	lent_slotr%   ,   s7   € ð ð $�6ð $˜g¨Ò/Ð/°G¸{Ð4JÐ4JØ˜7Ô#Ð#Øˆ4r   c                   ó,   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚWatcherc                 óF   — t          j        d¦  «        | _        i | _        d S )Ni'  )ÚxbmcguiÚWindowÚhomeÚlent_key)Úselfs    r   Ú__init__zWatcher.__init__5   s   € Ý”N 5Ñ)Ô)ˆŒ	ØˆŒˆˆr   c           
      ó*  — g }t          dt          |¦  «        dz   ¦  «        D ]o}t          j        d                     ||¦  «        ¦  «        }|rC|dk    r=|                     |t          t          t          |         |¦  «        ¦  «        f¦  «         Œp|S )Né   zSkin.String(mil.{}.{}.type)Úoff)	Úranger   ÚxbmcÚgetInfoLabelÚformatÚappendÚstrr   ÚSOURCES)r-   Úsecr   ÚnÚrows        r   Ú_rowszWatcher._rows9   s’   € ØˆÝ�q�* S™/œ/¨AÑ-Ñ.Ô.ð 	@ð 	@ˆAÝÔ#Ð$A×$HÒ$HÈÈaÑ$PÔ$PÑQÔQˆCØð @�s˜e’|�|Ø—’˜Q¥¥G­G°C¬L¸!Ñ$<Ô$<Ñ =Ô =Ð>Ñ?Ô?Ð?øØˆr   c                 óÀ   — t          j        d                     |¦  «        ¦  «        }||o3t          t          j        d                     |¦  «        ¦  «        ¦  «        fS )Nz+Integer.IsGreater(Container({}).NumItems,0)z4Container({}).ListItem.Property(milionar.hero.title))r3   ÚgetCondVisibilityr5   Úboolr4   )r-   r   r   s      r   Ú_statezWatcher._stateA   sU   € ÝÔ&Ð'T×'[Ò'[Ð\_Ñ'`Ô'`ÑaÔaˆØ�eÐ{¥¥TÔ%6Ð7m×7tÒ7tÐuxÑ7yÔ7yÑ%zÔ%zÑ {Ô {Ð{Ð{r   c           	      óÄ  ‡ — ‰ j                              d|z   ¦  «        }‰ j                              t                               |¦  «        ¦  «        }|r:||k    r4‰                      |¦  «        d         r‰                      |d |¦  «         d S ‰                      |¦  «        }|sd S t          |ˆ fd„|D ¦   «         ¦  «        }||k    rh|r4‰ j                              t                               |¦  «        |¦  «         n2‰ j          	                    t                               |¦  «        ¦  «         ‰                      |t          ||d„ |D ¦   «         ¦  «        |¦  «         d S )Nzmilionar.row.r   c                 ób   •— g | ]+\  }}|ft          ‰                     |¦  «        ¦  «        z   ‘Œ,S r   )Útupler@   )r   Ú_nr   r-   s      €r   ú
<listcomp>z Watcher.tick.<locals>.<listcomp>N   s8   ø€ Ð!XÐ!XÐ!XÁwÀrÈ3 3 &­5°·²¸SÑ1AÔ1AÑ+BÔ+BÑ"BÐ!XÐ!XÐ!Xr   c                 ó   — i | ]\  }}||“Œ	S r   r   )r   r:   r   s      r   ú
<dictcomp>z Watcher.tick.<locals>.<dictcomp>T   s   € Ð3OÐ3OÐ3O¹v¸qÀ#°C¸Ð3OÐ3OÐ3Or   )r+   ÚgetPropertyÚSOURCEr5   r@   Ú_lendr<   r!   ÚsetPropertyÚclearPropertyr%   )r-   r9   r   r#   ÚslotsÚchosens   `     r   ÚtickzWatcher.tickE   sV  ø€ Ø”)×'Ò'¨¸#Ñ(=Ñ>Ô>ˆØ”×&Ò&¥v§}¢}°SÑ'9Ô'9Ñ:Ô:ˆØð 	�w &Ò(Ð(¨T¯[ª[¸Ñ-AÔ-AÀ!Ô-DÐ(Ø�JŠJ�s˜D &Ñ)Ô)Ð)ØˆFØ—
’
˜3‘”ˆØð 	ØˆFÝ˜Ð!XÐ!XÐ!XÐ!XÐRWÐ!XÑ!XÔ!XÑYÔYˆØ�VÒÐØð <Ø”	×%Ò%¥f§m¢m°CÑ&8Ô&8¸&ÑAÔAÐAÐAà”	×'Ò'­¯ª°cÑ(:Ô(:Ñ;Ô;Ð;Ø�
Š
�3�	 '¨6Ð3OÐ3OÈÐ3OÑ3OÔ3OÑPÔPÐRXÑYÔYÐYÐYÐYr   c                 óV  — |||r't          j        d                     |¦  «        ¦  «        ndf}| j                             |¦  «        |k    rdS || j        |<   dj        }|rÅt          j         |||d¦  «        ¦  «        r¦t
          D ]i}| j                             d                     t                               |¦  «        |¦  «        t          j         |||d|z   ¦  «        ¦  «        ¦  «         Œj| j                             t                               |¦  «        d¦  «         dS | j         	                    t                               |¦  «        ¦  «         t
          D ]H}| j         	                    d                     t                               |¦  «        |¦  «        ¦  «         ŒIdS )z_Copy the borrowed buttons of row `slot` from the hero item (or clear them when no row borrows).zContainer({}).CurrentItemr   Nz4Container({}).ListItem.Property(milionar.hero.s{}{})z{}.{}ú.Útrue)
r3   r4   r5   r,   ÚgetÚLENT_FIELDSr+   rK   ÚLENTrL   )r-   r9   Úslotr#   ÚkeyÚitemÚfields          r   rJ   zWatcher._lendV   sµ  € à�VÐ^bÐj�TÔ.Ð/J×/QÒ/QÐRXÑ/YÔ/YÑZÔZÐZÐhjÐkˆØŒ=×Ò˜SÑ!Ô! SÒ(Ð(ØˆFØ ˆŒ�cÑØEÔLˆØð 	Q•DÔ% d d¨6°4¸Ñ&<Ô&<Ñ=Ô=ð 	QÝ$ð Cð C�Ø”	×%Ò% g§n¢nµT·[²[ÀÑ5EÔ5EÀuÑ&MÔ&MÍtÔO`ÐaeÐaeÐflÐnrÐtwÐzÑtñ  bAô  bAñ  PBô  PBñ  Cô  Cð  Cð  CØŒI×!Ò!¥$§+¢+¨cÑ"2Ô"2°FÑ;Ô;Ð;Ð;Ð;àŒI×#Ò#¥D§K¢K°Ñ$4Ô$4Ñ5Ô5Ð5Ý$ð Qð Q�Ø”	×'Ò'¨¯ªµt·{²{À3Ñ7GÔ7GÈÑ(OÔ(OÑPÔPÐPÐPðQð Qr   N)Ú__name__Ú
__module__Ú__qualname__r.   r<   r@   rO   rJ   r   r   r   r'   r'   4   sj   € € € € € ðð ð ðð ð ð|ð |ð |ðZð Zð Zð"Qð Qð Qð Qð Qr   r'   c                  ó  — ddl m} m} |                      d¦  «        rdS |                      t          j        ¦  «        rt          j        S |j                             |  	                    ¦   «         ¦  «        }|t          v r|ndS )zfThe hero on screen: the genre page when it is open in the section the menu shows, else that section's.r   )ÚpagesÚwarmzmilionar.detail.N)Úwcs.skinr^   r_   ÚhereÚgenreÚPREFIXÚSECÚBY_MENUrS   Ú	menu_itemr   )r^   r_   r9   s      r   Ú
_on_screenrg   g   sƒ   € à$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ø‡z‚zÐ$Ñ%Ô%ð ØˆtØ‡z‚z•%”,ÑÔð ÝŒyÐØ
Œ,×
Ò
˜5Ÿ?š?Ñ,Ô,Ñ
-Ô
-€CØ��/�/ˆ3ˆ3 tÐ+r   c           
      ó˜  — ddl m}m} t          ¦   «         }d}|                      ¦   «         �s|                     ¦   «         �rÒt          j        t          ¦  «        �r¸|dz  }t          ¦   «         }|€x	 ddl m
} |                     ¦   «          n\# t          $ rO}t          j        d                     t          |¦  «        j        |¦  «        t          j        ¦  «         Y d }~nd }~ww xY w|rt	 |                     |¦  «         n]# t          $ rP}t          j        d                     |t          |¦  «        j        |¦  «        t          j        ¦  «         Y d }~nd }~ww xY wt$                               |r|fnd|t(          z  dk    rt*          ndz   ¦  «        D ]u}	 |                     |¦  «         Œ# t          $ rP}t          j        d                     |t          |¦  «        j        |¦  «        t          j        ¦  «         Y d }~Œnd }~ww xY wt,          }	nt.          }	|                      |	¦  «        rd S |                      ¦   «         �¯d S d S )	Nr   )ÚfamilyÚpagingr0   )Údetailu%   [MilionÃ¡Å™ Skin] pinned hero: {}: {}u'   [MilionÃ¡Å™ Skin] row paging {}: {}: {}r   u(   [MilionÃ¡Å™ Skin] hero source {}: {}: {})r`   ri   rj   r'   ÚabortRequestedÚactiver3   r>   ÚSCREENrg   rk   rO   Ú	ExceptionÚlogr5   ÚtyperZ   Ú
LOGWARNINGÚdictÚfromkeysÚ	ALL_EVERYr   ÚPOLLÚIDLEÚwaitForAbort)
Úmonitorri   rj   ÚwatcherrO   Úfocusedrk   Úexcr9   Úwaits
             r   Úrunr~   r   sÂ  € Ø'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ý‰iŒi€GØ€DØ×$Ò$Ñ&Ô&ñ Ø�=Š=‰?Œ?ñ 	�tÔ5µfÑ=Ô=ñ 	Ø�A‰IˆDÝ ‘l”lˆGØˆðwØ/Ð/Ð/Ð/Ð/Ð/Ø—K’K‘M”M�M�MøÝ ð wð wð wÝ”HÐD×KÒKÍDÐQTÉIÌIÔL^Ð`cÑdÔdÕfjÔfuÑvÔvÐvÐvÐvÐvÐvÐvøøøøðwøøøàð BðBØ—K’K Ñ(Ô(Ð(Ð(øÝ ð Bð Bð BÝ”HÐF×MÒMÈgÕW[Ð\_ÑW`ÔW`ÔWiÐknÑoÔoÕquô  rAñ  Bô  Bð  Bð  Bð  Bð  Bð  Bð  BøøøøðBøøøå—}’}°GÐ&C w j jÀÐTXÕ[dÑTdÐhiÒTiÐTiÍÈÐoqÑ%rÑsÔsð ð �ðØ—L’L Ñ%Ô%Ð%Ð%øÝ ð ð ð Ý”HÐG×NÒNÈsÕTXÐY\ÑT]ÔT]ÔTfÐhkÑlÔlÕnrÔn}Ñ~Ô~Ð~Ð~Ð~Ð~Ð~Ð~øøøøðøøøåˆDˆDåˆDØ×Ò Ñ%Ô%ð 	ØˆFð1 ×$Ò$Ñ&Ô&ñ ð ð ð ð sK   Á3B Â
C'ÂAC"Ã"C'Ã-D Ä
EÄAEÅEÆF0Æ0
H
Æ:AHÈH
c                 óp   — dd l }|                     t          | fdd¬¦  «                             ¦   «          d S )Nr   zmilionar-hero-sourceT)ÚtargetÚargsÚnameÚdaemon)Ú	threadingÚThreadr~   Ústart)ry   r„   s     r   r†   r†   ‘   sA   € ØÐÐÐØ×Ò�C w jÐ7MÐVZÐÑ[Ô[×aÒaÑcÔcÐcÐcÐcr   )Ú__doc__r3   r)   Ú
wcs.genresr   rb   Úwcs.skin.hero_contractr   r   r   r   rs   rd   ÚBASEr8   rI   rU   rT   rv   rw   ru   rn   r!   r%   Úobjectr'   rg   r~   r†   r   r   r   ú<module>rŒ      s1  ððð ð €€€Ø €€€à (Ð (Ð (Ð (Ð (Ð (Ø GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ Gð ˆ$ˆuÐ
0Ð
0˜œ E¤JÐ/Ð
0Ð
0€à	€Ø€ØI€Ø
€Ø
€Ø€	ð 
@€ðNð Nð Nðð ð ð0Qð 0Qð 0Qð 0Qð 0Qˆfñ 0Qô 0Qð 0Qðf,ð ,ð ,ðð ð ð>dð dð dð dð dr   