+
    Kio                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H	t	H
t
 ^ RIHtHt ^ RIHt ^ RIHtHtHt ]! ]4      P+                  4       P,                  t]R,          R,          t]R	,          t]R
,          t]R,          t]R,          R,          t]R,          t]R,          R,          R,          t]R,          t ]R,          t!]R,          t"]PF                  ! R]PH                  4      t%]PF                  ! R4      t&RRRRRRRRRRRRRRRRRR/	t'R  t(R! R" lt)R# R$ lt*R% R& lt+R' R( lt,R) R* lt-R+ R, lt.]PF                  ! R-4      t/RKR. R/ llt0R0 R1 lt1R2 R3 lt2R4 R5 lt3R6 R7 lt4R8 R9 lt5]5! 4       t6R: R; lt7R< R= lt8R> R? lt9R@ RA lt:RB RC lt;RD RE lt< ! RF RG]4      t=RH RI lt>]?RJ8X  d
   ]>! 4        R# R# )L    )annotationsN)datetime	timedelta)SimpleHTTPRequestHandlerThreadingHTTPServer)Path)parse_qsunquoteurlparsescriptszbuild_data.pyPulled_Infoconfigzvouchers.sqliteVouchers
All_Scaned	InventoryBoot_FeaturesRW_ScraperszRW_Site_Scrape.mdzInventory_Search_Presets.jsonzInventory_Search_Users.jsonzsite_state.jsonz(\d{8})_On_Hand_Footwearz:^(?P<style>\d+)(?P<width>[A-Z]\d?|[A-Z]+)?(?P<size>\d{3})$A2ABCDEE2E3Hc                    R p V \         P                  9   d   \         P                  V ,          # \        P                  P	                  V \
        4      pVe   VP                  f   \        R\
         24      h\        P                  P                  V4      pV\         P                  V &   VP                  P                  V4       V# )_rw_site_build_dataz&Could not load build_data module from )
sysmodules	importlibutilspec_from_file_locationBUILD_DATA_PATHloaderImportErrormodule_from_specexec_module)module_namespecmodules      .\server.pyload_build_data_moduler-   )   s    'Kckk!{{;''>>11+OD|t{{*B?BSTUU^^,,T2F%CKKKKF#M    c                    V ^8  d   QhRRRR/# )   presetdict | Nonereturndict )formats   "r,   __annotate__r7   6   s      [ T r.   c                j   T ;'       g    / p V P                  R . 4      p\        V\        4      '       g   . pV Uu. uF  p\        V4      NK  	  ppV P                  R4      pVR9   d   RpR TR\	        V P                  RR4      4      R\        V P                  RR4      ;'       g    R4      R\	        V P                  RR4      4      R\        V4      R\	        V P                  RR4      4      R	\        V P                  R	R4      ;'       g    R4      R
\	        V P                  R
R4      4      /# u upi )features	width_key size_filter_enabledF
size_value      $@size_exact_enabledwidth_and_widersearch_textshow_zero_qty)Nr;   )get
isinstanceliststrboolfloat)r1   r9   itemr:   s   &   r,   normalize_preset_payloadrJ   6   s   \\rFzz*b)Hh%%&./hdD	hH/

;'IJ	HtFJJ/De$LMeFJJ|T:BBdCd6::.BE#JKS^4

+<e DEs6::mR8>>B?fjj%@A	 		 0s   D0c                    V ^8  d   QhRRRR/# )r0   
appearancer2   r3   r4   r5   )r6   s   "r,   r7   r7   K   s      [ T r.   c                   T ;'       g    / p R \        V P                  R R4      ;'       g    R4      R\        V P                  RR4      ;'       g    R4      R\        V P                  R^
4      ;'       g    ^
4      R\        V P                  RR4      ;'       g    R4      R\        V P                  RR4      ;'       g    R4      /# )
theme_nameLightfont_familyzSegoe UI	font_sizeprimary_hexr;   secondary_hex)rF   rC   int)rL   s   &r,   normalize_appearance_payloadrU   K   s    !!rJc*..w?JJ7Ks:>>-DRR
SSR8>>B?s:>>-<BBCZ^^OR@FFBG r.   c                   V ^8  d   QhRR/# r0   r3   r4   r5   )r6   s   "r,   r7   r7   V   s     !H !Hd !Hr.   c                 J   R p R R/ R\        / 4      //p \        P                  4       '       d   \        P                  ! \        P                  RR7      4      p\        VP                  R4      ;'       g    T 4      p VP                  R/ 4      p\        V\        4      '       d   VP                  4        UUu/ uF^  w  rE\        V\        4      '       g   K  \        V\        4      '       g   K5  \        V4      R/ R\        VP                  R/ 4      4      /bK`  	  upp;'       g    Tp \        P                  4       '       Ed   \        P                  ! \        P                  RR7      4      p\        T\        4      '       d   TP                  RT4      M/ p\        T\        4      '       g   / pTP                  T R/ /4       Y,          P                  R\        / 4      4       TP                  4        UUu/ uFJ  w  rH\        T\        4      '       g   K  \        T\        4      '       g   K5  \        T4      \        T4      bKL  	  uppY,          R&   Y9  d   R/ R\        / 4      /Y&   R^RT RT/# u uppi   \         d     EL`i ; iu uppi   \         d     LJi ; i)DefaultpresetsrL   utf-8encodingcurrent_userusersversion)rU   DESKTOP_USERS_PATHis_filejsonloads	read_textrF   rC   rD   r4   items	ExceptionDESKTOP_PRESETS_PATH
setdefaultrJ   )	r^   r_   desktop_users	raw_usersnamepayloadraw
preset_mapr1   s	            r,   bootstrap_site_staterp   V   s\   L')RGcdfGg)hiE%%'' JJ'9'C'CW'C'UVM}00@PPLQL%))'26I)T** *3):):!$, z1;GT1J zCI	2|=YZaZeZefrtvZw=xyy):   	 ''))**1;;W;MNC4>sD4I4IC0rJj$//
\Ir?;**<9UVX9YZ %/$4$4$6.$6LDdC( <-7-E <D	3F;;$6.E	*  ("l<XY[<\]q.,GG1
  .
  st   A I< 6AI< 8I6I6/-I6
I< 'I< +J B4J :JJ1J
J 6I< <J
JJ J"!J"c                   V ^8  d   QhRR/# rW   r5   )r6   s   "r,   r7   r7   z   s     'L 'L 'Lr.   c                 (   \        4       p \        P                  4       '       g   T p\        V4       V#  \        P
                  ! \        P                  R R7      4      pTP                  R/ 4      p\        T\        4      '       d	   T'       g   T p\        T4       T# \        T P                  R/ 4      4      pTP                  4        F  w  rV\        T\        4      '       d   \        T\        4      '       g   K3  TP                  R/ 4      p\        T\        4      '       g   / pR\        TP                  R/ 4      4      RTP                  4        UU	u/ uFJ  w  r\        T\        4      '       g   K  \        T	\        4      '       g   K5  \        T4      \        T	4      bKL  	  up	p/YE&   K  	  T'       g   RR/ R\        / 4      //p\        TP                  R4      ;'       g    T P                  R4      ;'       g    R4      p
Y9  d%   \        T P                  R4      ;'       g    R4      p
Y9  d1   \        TP!                  4       \        P"                  R7      ^ ,          p
R	^RT
RT/#   \         d    T p\        T4       Tu # i ; iu up	pi )
r[   r\   r_   rZ   rL   rY   r^   r;   keyr`   )rp   SITE_STATE_PATHrb   save_site_staterc   rd   re   rg   rC   rD   r4   rf   rF   rU   rJ   sortedkeyslower)basestatern   r_   	out_usersrl   rm   rZ   preset_namepreset_payloadr^   s              r,   load_site_stater   z   s    !D""$$jj22G2DE
 GGGR EeT""%
!%dhhw&;!<I$$$Jw,E,E++i,'4((G6w{{<QS7TU3:==?3B/Kk3/ K4>~t4T KK ":>"JJ3B
	 ' B>Z[]>^ _`	sww~.PP$((>2JPPbQL$488N399r:$inn.CII>qAq.,KK?  
$s#   *I. J4JJ.J
Jc                    V ^8  d   QhRRRR/# )r0   r{   r4   r3   Noner5   )r6   s   "r,   r7   r7      s     ^ ^4 ^D ^r.   c                b    \         P                  \        P                  ! V ^RR7      RR7       R# )r0   T)indent	sort_keysr[   r\   N)ru   
write_textrc   dumps)r{   s   &r,   rv   rv      s#    tzz%TJU\]r.   c                    V ^8  d   QhRRRR/# )r0   stylerF   r3   r5   )r6   s   "r,   r7   r7      s      3 3 r.   c                    \        T ;'       g    R 4      P                  4       pV'       d)   V^ ,          P                  4       '       g   VR,          pK0  VP                  R4      # )r;      NN0)rF   stripisdigitlstrip)r   texts   & r,   normalize_styler      sF    u{{!!#D
tAw((Bx;;sr.   z\b\d{4,5}\bc               $    V ^8  d   QhRRRRRR/# )r0   rel_pathrF   	max_linesrT   r3   	list[str]r5   )r6   s   "r,   r7   r7      s!     ) ) ) )i )r.   c                ^   V '       g   . # \         V ,          P                  4       p VP                  \         P                  4       4       TP	                  4       '       g   . #  TP                  R RR7      pTP                  4       RT #   \         d    . u # i ; i  \         d    . u # i ; i)r[   ignore)r]   errorsN)VOUCHER_SOURCE_DIRresolverelative_torg   rb   re   
splitlines)r   r   pathr   s   &&  r,   read_voucher_source_linesr      s    	)224D+3356 <<>>	~~wx~@ ??Zi((  	  	s#   #B	 #B 	BBB,+B,c                    V ^8  d   QhRRRR/# )r0   linesr   r3   r5   )r6   s   "r,   r7   r7      s     	 	i 	I 	r.   c                    \        4       p. pV  Fh  p\        P                  T;'       g    R 4       FB  p\        V4      pV'       g   K  WQ9  g   K   VP	                  V4       VP                  V4       KD  	  Kj  	  V# )r;   )setSTYLE_CODE_REfindallr   addappend)r   seenoutline	raw_stylenorms   &     r,   extract_voucher_style_hitsr      se    UDC&..tzzr:I"9-Dt(

4 	 ;  Jr.   c                    V ^8  d   QhRRRR/# )r0   	width_rawrF   r3   z
str | Noner5   )r6   s   "r,   r7   r7      s      s z r.   c                    \        T ;'       g    R 4      P                  4       P                  4       pV'       g   R# VR8X  d   R# VR
9   d   R# VR9   d   R# VR9   d   R# VR9   d   R# VR9   d   V# VR	8X  d   R# R# )r;   NAAr   r   r   r   r   r   E1>   2Er   EEW2>   3Er   EEE>   r   4EE4EEEE>   r   M>   r   r   r   r   )rF   r   upper)r   values   & r,   normalize_widthr      s~    	R &&(..0E}((##))
$$}r.   c                    V ^8  d   QhRRRR/# )r0   style_wd_sizerF   r3   z+tuple[str | None, float | None, str | None]r5   )r6   s   "r,   r7   r7      s     D Ds D/Z Dr.   c                   \         P                  ! R R\        T ;'       g    R4      P                  4       P	                  4       4      pV'       g   R	# \        V4      ^8  d   VR,          P                  4       '       df   VR
R P                  4       '       dM   VR,          pV^R
 p\        V4      \        VR
R 4      R,          \        V4      ;'       g    T;'       g    R3# \        P                  V4      pV'       g   R	# VP                  R4      ;'       g    Rp\        VP                  R4      4      \        VP                  R4      4      R,          \        V4      ;'       g    T;'       g    R3# )z\s+r;   N:N   Nr>   r   widthr   size)NNN)resubrF   r   r   lenr   r   rT   r   STYLE_WD_SIZE_REmatchgroup)r   r   style_digitsr   r   s   &    r,   parse_style_wd_sizer      sJ   FF62s=#6#6B7==?EEGHE
5zQ59,,..5:3E3E3G3GRy!BK	|,c%*o.DoV_F`FvFveneueuruvv""5)EG$**I5;;w/0#ekk&6I2JT2QSbclSm  TD  TDr{  sC  sC  @C  D  Dr.   c                    V ^8  d   QhRRRR/# )r0   r   rF   r3   r   r5   )r6   s   "r,   r7   r7      s     * *S *Y *r.   c                   \        \        P                  ! V .R R7      4      pV'       d   V^ ,          R8X  d
   VR,          pV'       d   VR,          R8X  d   VRR pV Uu. uF  q"P                  4       NK  	  up# u upi )|)	delimiterr;   r   N)nextcsvreaderr   )r   rowcells   &  r,   split_markdown_rowr      sc    
szz4&C0
1C
s1v|"g
s2w"}#2h%()STJJLS)))s   !A<c                   V ^8  d   QhRR/# )r0   r3   zdict[str, dict[str, str]]r5   )r6   s   "r,   r7   r7      s      6 r.   c                    \         P                  R R7      P                  4       p V  Uu. uF+  qP                  4       P	                  R4      '       g   K)  VNK-  	  pp\        V^ ,          4      pVR,           Uu. uF  p\        V4      NK  	  pp/ pV F  p\        V4      \        V4      8w  g<   V'       d4   V^ ,          '       d%   V^ ,          ^ ,          P                  4       '       g   KY  \        \        W64      4      p\        VP                  RR4      4      pV'       g   K  RVP                  RR4      P                  4       RVP                  R	R4      P                  4       /WX&   K  	  V# u upi u upi )
r[   r\   r   :r0   NNzStyle #r;   rl   NamebrandBrand)FEATURES_PATHre   r   r   
startswithr   r   r   r4   zipr   rC   )	r   r   table_linesheadersrowslookupr   recordr   s	            r,   load_feature_lookupr      s&   ##W#5@@BE$)JEDZZ\-D-DS-I44EKJ Q0G1<RAt$DA(*Fs8s7|#3c!ffCF1IDUDUDWDWc''(vzz)R894"FJJvr$:$@$@$BGVZZX_acMdMjMjMlmFL  M KAs   &E/E/9E4c                   V ^8  d   QhRR/# )r0   r3   zlist[tuple[datetime, Path]]r5   )r6   s   "r,   r7   r7     s      $? r.   c                 *   . p \         P                  R 4       Fc  p\        P                  VP                  4      pV'       g   K,  V P                  \        P                  ! VP                  ^4      R4      V34       Ke  	  V P                  R RR7       V # )z*On_Hand_Footwear*.csvz%Y%m%dc                    V ^ ,          # )r   r5   )rI   s   &r,   <lambda>,inventory_files_with_dates.<locals>.<lambda>  s    d1gr.   Trt   reverse)
INVENTORY_DIRglobDATE_REsearchrl   r   r   strptimer   sort)r   r   r   s      r,   inventory_files_with_datesr     ss    ')C""#;<tyy)

H%%ekk!nh?FG	 =
 HH%tH4Jr.   c                    V ^8  d   QhRRRR/# )r0   csv_pathr   r3   zdict[str, float]r5   )r6   s   "r,   r7   r7     s     
 
D 
-= 
r.   c           
        / pV P                  R RRR7      ;_uu_ 4       p\        P                  ! V4      pV F  p\        VP	                  RR4      4      P                  4       pV'       d   V^ ,          P                  4       '       g   KS  \        V4      pVP	                  VR4      \        VP	                  R^ 4      ;'       g    ^ 4      ,           W&   K  	  RRR4       V#   + '       g   i     T# ; i)r	utf-8-sigr;   r]   newlineStyle        QtyN)	openr   
DictReaderrF   rC   r   r   r   rH   )r   totalshandler   r   r   r   s   &      r,   load_inventory_totalsr    s    !F	s["	=	='CCGGGR01779IIaL$8$8$:$:"9-D!::dC059J9O9Oa3PPFL  
> M 
>	= Ms   A)C"	;C"C""C3	c                    V ^8  d   QhRRRR/# )r0   r   r   r3   z(dict[str, dict[float, dict[str, float]]]r5   )r6   s   "r,   r7   r7   '  s      4 ,T r.   c           	        / pV P                  R RRR7      ;_uu_ 4       p\        P                  ! V4      pV EF  p\        VP	                  RR4      4      P                  4       pV'       d   V^ ,          P                  4       '       g   KT  \        V4      pRpRpVP	                  R4      '       d$   \        VR,          4      w  rpV	'       d   T	pT
pTpVe   Vf   K  \        VP	                  R^ 4      ;'       g    ^ 4      pVP                  V/ 4      pVP                  \        V4      / 4      pVP	                  VR4      V,           W&   EK  	  RRR4       V#   + '       g   i     T# ; i)	r   r   r;   r   r   NStyleWdSizer   r   )r   r   r   rF   rC   r   r   r   r   rH   ri   )r   r   r  r   r   r   r   r   r:   parsed_styleparsed_sizeparsed_widthqty	style_map	width_maps   &              r,   load_inventory_sizesr  '  s:   46C	s["	=	='CCGGGR01779IIaL$8$8$:$:"9-DDIww}%%:McR_N`:a7<'D&D ,I|y0q)..Q/CtR0I!,,U4["=I#,==C#@3#FI %  
>* J+ 
>	=* Js   A*E
A2E=AEE,	c               (    V ^8  d   QhRRRRRRRR/# )r0   	curr_filerF   	prev_file	days_backrT   r3   z3tuple[tuple[datetime, Path], tuple[datetime, Path]]r5   )r6   s   "r,   r7   r7   A  s/     Y Y# Y# Y# YJ} Yr.   c                6  a
 \        4       p\        V4      ^8  d   \        R4      hV UUu/ uF  w  rEVP                  WE3bK  	  pppV '       d   VP	                  V 4      MV^ ,          o
S
f
   V^ ,          o
V'       d(   VP	                  V4      pVf   \        RV 24      hS
V3# S
^ ,          \        \        ^V4      R7      ,
          pV F.  p	V	^,          S
^,          8X  d   K  V	^ ,          V8:  g   K*  S
V	3u # 	  S
\        V
3R lV 4       4      3# u uppi )r0   z&Not enough dated inventory CSVs found.z#Previous inventory file not found: )daysc              3  T   <"   T F  q^,          S^,          8w  g   K  Vx  K  	  R# 5i)r   Nr5   ).0	candidatecurrents   & r,   	<genexpr>%resolve_diff_paths.<locals>.<genexpr>T  s!     XEyq\WUVZ=WEs   (
()r   r   FileNotFoundErrorrl   rC   r   maxr   )r  r  r  filesdtr   by_nameprevious	target_dtr  r  s   &&&       @r,   resolve_diff_pathsr   A  s   &(E
5zA~ HII5:;Utyy2*$UG;(1gkk)$uQxG(;;y)#&I)$UVV  
YC9,=>>I	Q<71:%Q<9$I%%	 
 DXEXXXX <s   Dc               $    V ^8  d   QhRRRRRR/# )r0   	curr_pathr   	prev_pathr3   z
list[dict]r5   )r6   s   "r,   r7   r7   W  s!     + +t + + +r.   c                0   \        V 4      p\        V4      p\        V 4      p\        V4      p. p\        \        V4      \        V4      ,          R  R7       EF'  p\	        VP                  VR4      4      p\	        VP                  VR4      4      p	W,
          p
\        V
4      R8  d   KT  . p. pVP                  V/ 4      pVP                  V/ 4      p\        \        V4      \        V4      ,          4       EF+  pVP                  V/ 4      pVP                  V/ 4      p\        \        V4      \        V4      ,          4       F  p\	        VP                  VR4      4      \	        VP                  VR4      4      ,
          p\        V4      R8  d   KP  \        V\        V4      ,
          4      R8  d   \        V4       MVR pV R\        P                  VV4       2pV^ 8  d   VP                  V RVR 24       K  VP                  V R\        V4      R 24       K  	  EK.  	  \        P                  V/ 4      pVP                  RVRVP                  RR	4      R
VP                  R
R4      RV
RVRV	RVRV/4       EK*  	  VP                  R RR7       V# )c                H    V P                  4       '       d   \        V 4      # T # N)r   rT   )r   s   &r,   r   !build_diff_rows.<locals>.<lambda>]  s#    didqdqdsdsVYZ_V`V~y~V~r.   rs   r   g&.>g :r   rl   Heritager   HERITAGEsoldQtyprevQtycurrQty	soldSizesincomingSizesc                J    \        \        V R ,          4      4      V R,          3# )r-  r   )absrH   )r   s   &r,   r   r'    s    s5Y#893w<Hr.   Tr   )r  r  rw   r   rH   rC   r3  rT   WIDTH_DISPLAYr   FEATURE_LOOKUPr   )r"  r#  current_totalsprevious_totalscurrent_sizesprevious_sizesr   r   prev_qtycurr_qtysold_qty
sold_sizesincoming_sizesprev_size_mapcurr_size_mapr   prev_widthscurr_widthsr   deltasize_txtlabelfeatures   &&                     r,   build_diff_rowsrG  W  so   *95N+I6O(3M))4NDs>*S-AAG  A  A,,T378++D#67&x=4 "
$&&**44%))$33}-M0BBCD'++D"5K'++D"5KK 03{3C CDkooeS9:U;??SXZ]C^=__u:$-0D	1A-BT-Ic$i[RVWXQY#*Am&7&7u&E%FG19%%qq	&:;"))UG1SZN*CD E D !$$T2.FJ7Wj9888Z		
1 AH 	IIHRVIWKr.   c                   V ^8  d   QhRR/# )r0   r3   zsqlite3.Connectionr5   )r6   s   "r,   r7   r7     s      $ r.   c                 d    \         P                  ! \        4      p \         P                  V n        V # r&  )sqlite3connectDB_PATHRowrow_factory)conns    r,   get_connrP    s!    ??7#D{{DKr.   c                     a  ] tR tRtV 3R ltR V 3R lltR R ltRR R lltR	 R
 ltR R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltRtV ;t# )Handleri  c                	F   < \         SV `  ! VR \        \        4      /VB  R# )	directoryN)super__init__rF   ROOT)selfargskwargs	__class__s   &*,r,   rV  Handler.__init__  s    $>#d)>v>r.   c                   V ^8  d   QhRR/# r0   r3   r   r5   )r6   s   "r,   r7   Handler.__annotate__  s       r.   c                	  < \        V P                  4      pVP                  R 8X  d   V P                  VP                  4       R# VP                  R8X  d   V P	                  VP                  4       R# VP                  R8X  d   V P                  VP                  4       R# VP                  R8X  d   V P                  4        R# VP                  R8X  d   V P                  4        R# VP                  R8X  d   V P                  VP                  4       R# VP                  R8X  d   V P                  4        R# \        SV `-  4        R# )z/api/voucher-searchNz/api/voucher-detailz/api/voucher-folder-filesz/api/inventory-dataz/api/inventory-filesz/api/inventory-diff/api/site-state)r   r   _handle_voucher_searchquery_handle_voucher_detail_handle_voucher_folder_files_handle_inventory_data_handle_inventory_files_handle_inventory_diff_handle_site_state_getrU  do_GET)rX  parsedr[  s   & r,   rj  Handler.do_GET  s    $))$;;//''5;;//''5;;55--fll;;;//'');;00((*;;//''5;;++'')r.   c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r_    s     * * *r.   c                	    \        V P                  4      pVP                  R 8X  d   V P                  4        R# V P                  RR4       R# )ra  N  z	Not found)r   r   _handle_site_state_post
send_error)rX  rk  s   & r,   do_POSTHandler.do_POST  s:    $))$;;++((*[)r.   c               $    V ^8  d   QhRRRRRR/# )r0   rm   r4   statusrT   r3   r   r5   )r6   s   "r,   r7   r_    s!      4  t r.   c                	4   \         P                  ! V4      P                  R 4      pV P                  V4       V P	                  RR4       V P	                  R\        \        V4      4      4       V P                  4        V P                  P                  V4       R# )r[   zContent-Typezapplication/json; charset=utf-8Content-LengthN)
rc   r   encodesend_responsesend_headerrF   r   end_headerswfilewrite)rX  rm   ru  datas   &&& r,   _write_jsonHandler._write_json  sq    zz'"))'26")JK)3s4y>:

r.   c                   V ^8  d   QhRR/# rW   r5   )r6   s   "r,   r7   r_    s     / / /r.   c                	    \        V P                  P                  R R4      ;'       g    R4      pV^ 8  d   V P                  P	                  V4      MRp\
        P                  ! VP                  R4      4      # )rw  r   s   {}r[   )rT   r   rC   rfilereadrc   rd   decode)rX  lengthrn   s   &  r,   _read_json_bodyHandler._read_json_body  sX    T\\%%&6<CCD)/!djjoof%zz#**W-..r.   c                    V ^8  d   QhRRRR/# r0   rc  rF   r3   r   r5   )r6   s   "r,   r7   r_    s     T
 T
C T
D T
r.   c                	0   \        V4      pVP                  R R.4      ^ ,          ;'       g    RP                  4       p\        \	        \        VP                  RR.4      ^ ,          ;'       g    R4      ^4      ^4      pRVP                  4        R2p\        4       ;_uu_ 4       pV'       g#   VP                  RV34      P                  4       pM$VP                  RWUWUWUV34      P                  4       pRRR4       T P                  RTR	X Uu. uFb  pR
VR,          RVR,          RVR,          R\        VR,          ;'       g    ^ 4      '       d   RMRR\        VR,          ;'       g    ^ 4      /NKd  	  up/4       R#   + '       g   i     L; iu upi )qr;   limit80%a  
                    select
                        folder as rel_path,
                        folder as name,
                        folder,
                        count(*) as voucher_count,
                        1 as is_dir
                    from voucher_items
                    where is_dir = 0
                      and folder is not null
                      and trim(folder) <> ''
                    group by folder
                    order by lower(folder)
                    limit ?
                    a#  
                    select *
                    from (
                        select
                            folder as rel_path,
                            folder as name,
                            folder,
                            count(*) as voucher_count,
                            1 as is_dir,
                            0 as sort_rank
                        from voucher_items
                        where is_dir = 0
                          and folder is not null
                          and trim(folder) <> ''
                          and (
                                lower(folder) like ?
                                or lower(name) like ?
                           )
                        group by folder
                        union all
                        select
                            rel_path,
                            name,
                            folder,
                            1 as voucher_count,
                            0 as is_dir,
                            1 as sort_rank
                        from voucher_items
                        where is_dir = 0
                          and (
                                lower(rel_path) like ?
                                or lower(name) like ?
                                or lower(folder) like ?
                                or lower(numbers_json) like ?
                           )
                    )
                    order by sort_rank asc, lower(folder) asc, lower(name) asc
                    limit ?
                    Nrc  resultsrelPathr   rl   foldertypeis_dirfilevoucherCountvoucher_count)r	   rC   r   minr  rT   ry   rP  executefetchallr  )	rX  rc  paramsrn   r  likerO  r   r   s	   &&       r,   rb  Handler._handle_voucher_search  s   %zz#t$Q'--2446CVZZ$8;CCtEqI3O399;-q!ZZ4|| H!" (*# & ||&N T?Q)R (*S + @ 	  $	  $ "3z?F #h-CH0B0B,C,C&C,@,E,EA(F  $		
A ZF	s%   %AF 5FFF*F F	c                    V ^8  d   QhRRRR/# r  r5   )r6   s   "r,   r7   r_    s      
  
#  
$  
r.   c                	"   \        V4      p\        VP                  R R.4      ^ ,          ;'       g    R4      P                  4       pV'       g   V P	                  RR/RR7       R# \        4       ;_uu_ 4       pVP                  RV34      P                  4       pRRR4       T P	                  R TRX Uu. uF5  pR	VR
,          RVR,          R VR ,          RVR,          ;'       g    RRR/NK7  	  up/4       R#   + '       g   i     Lg; iu upi )r  r;   errorzMissing folder  ru  Nz
                select rel_path, name, folder, numbers_json
                from voucher_items
                where folder = ? and is_dir = 0
                order by lower(name), lower(rel_path)
                r  r  r   rl   numbersJsonnumbers_jsonz[]r  r  )r	   r
   rC   r   r  rP  r  r  )rX  rc  r  r  rO  r   r   s   &&     r,   re  $Handler._handle_voucher_folder_files  s	   %&**Xt4Q7==2?EEGg'78EZZ4<< 	 hj   	&  $	  $ "3z?F #h-%s>':'B'Bd  $		
 Z	s   8"C940D%
D9D		c                    V ^8  d   QhRRRR/# r  r5   )r6   s   "r,   r7   r_  4  s     8
 8
C 8
D 8
r.   c                	   \        V4      p\        VP                  R R.4      ^ ,          ;'       g    R4      P                  4       pV'       g   V P	                  RR/RR7       R# \        4       ;_uu_ 4       pVP                  RV34      P                  4       pVf!   V P	                  RR/R	R7        RRR4       R# VP                  R
V34      P                  4       pRRR4       \        V4      p\        \        V4      4      pV'       d   RP                  V4      MXR,          ;'       g    Rp	V'       d+   X U
u. uF  p
\        V
R,          4      V9   g   K  V
NK   	  pp
T P	                  RRXR ,          RVR,          RVR,          RVR,          RV	/RX U
u. uF)  p
RV
R,          RV
R,          RV
R,          RV
R,          /NK+  	  up
/4       R#   + '       g   i     L; iu up
i u up
i )r   r;   r  zMissing rel_pathr  r  Nz
                select rel_path, name, folder, numbers_json, preview_text
                from voucher_items
                where rel_path = ? and is_dir = 0
                zVoucher not foundro  a  
                select style_code, normal_price, discount_pct, discounted_price
                from voucher_style_prices
                where rel_path = ?
                order by discounted_price asc, style_code asc
                limit 500
                
preview_text
style_coderI   r  rl   r  r  r  previewTextstyles	styleCodenormalPricenormal_pricediscountPctdiscount_pctdiscountedPricediscounted_price)r	   r
   rC   r   r  rP  r  fetchoner  r   r   r   joinr   )rX  rc  r  r   rO  rI   r  source_linesmatched_norm_stylesr  r   s   &&         r,   rd  Handler._handle_voucher_detail4  s   %FJJzB48;AArCIIKg'9:3GZZ4<<
  hj  |  '+>!? L Z \\ 	 hj  0 1:!"<\"JK2>tyy.T.EYE_E_]_%+iVcs<?P/QUh/hccVFitJ/DLd8n!4#7!<   &  & $S%6%s>':%s>':)3/A+B	  &	
= Z8 js$   8<G>!G>G(G(/G-G%	c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r_  n  s     " " "r.   c                	\    \        4       pVP                  4       pV P                  V4       R # r&  )r-   build_payloadr  )rX  
build_datarm   s   &  r,   rf  Handler._handle_inventory_datan  s&    +-
**,!r.   c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r_  s  s     	
 	
 	
r.   c                	    \        4       pT P                  R V UUu. uF1  w  r#RVP                  4       P                  4       RVP                  /NK3  	  upp/4       R# u uppi )r  dater  N)r   r  r  	isoformatrl   )rX  r  r  r   s   &   r,   rg  Handler._handle_inventory_filess  s^    *,$)$) RWWY002FDIIF$)	
s   7Ac                    V ^8  d   QhRRRR/# r  r5   )r6   s   "r,   r7   r_  ~  s     
 
C 
D 
r.   c                	   \        V4      pVP                  R R.4      ^ ,          ;'       g    RP                  4       pVP                  RR.4      ^ ,          ;'       g    RP                  4       p\        VP                  RR.4      ^ ,          ;'       g    R4      p\	        W4V4      w  rg\        V^,          V^,          4      pV P                  RV^,          P                  RV^ ,          P                  4       P                  4       RV^,          P                  RV^ ,          P                  4       P                  4       R	V/4       R
# )r  r;   r  r  7currentFilecurrentDatepreviousFilepreviousDater   N)
r	   rC   r   rT   r   rG  r  rl   r  r  )	rX  rc  r  r  r  r  r  r  r   s	   &&       r,   rh  Handler._handle_inventory_diff~  s
   %ZZbT215;;BBD	ZZbT215;;BBD	K#7:AAcC	.yYOwqz8A;7wqzwqz0::< 0 0 0 0 2 < < >	
r.   c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r_    s     , , ,r.   c                	8    V P                  \        4       4       R # r&  )r  r   )rX  s   &r,   ri  Handler._handle_site_state_get  s    *+r.   c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r_    s     D  D  D r.   c                	   V P                  4       p\        VP                  R 4      ;'       g    R4      P                  4       p\	        4       pVR,          pVR,          pVR8X  dV   \        VP                  R4      ;'       g    R4      P                  4       pWd9  d   V P                  RR/RR	7       R
# WcR&   EMVR8X  d   \        VP                  R4      ;'       g    R4      P                  4       pV'       g   V P                  RR/RR	7       R
# Wd9   d   V P                  RR/RR	7       R
# WE,          P                  R/ 4      pR/ R\        V4      /WF&   WcR&   EMVR8X  d   \        VP                  R4      ;'       g    R4      P                  4       pWd9  d   V P                  RR/RR	7       R
# \        V4      ^8:  d   V P                  RR/RR	7       R
# WF VR,          V8X  d4   \        VP                  4       \        P                  R7      ^ ,          VR&   EM(VR8X  d   \        VP                  R4      ;'       g    R4      P                  4       pVP                  R4      pV'       d   \        V\        4      '       g   V P                  RR/RR	7       R
# \        V4      WE,          R,          V&   EMVR8X  d   \        VP                  R4      ;'       g    R4      P                  4       p	\        VP                  R4      ;'       g    R4      P                  4       p
WE,          R,          pW9  g	   V
'       g   V P                  RR/RR	7       R
# VP                  V	4      W&   MVR8X  db   \        VP                  R4      ;'       g    R4      P                  4       pWE,          R,          pWk9  d   V P                  RR/RR	7       R
# W MqVR8X  dT   VP                  R4      p\        V\        4      '       g   V P                  RR/RR	7       R
# \        V4      WE,          R&   MV P                  RR/RR	7       R
# \        V4       V P                  V4       R
# )actionr;   r_   r^   set_current_userrl   r  zUnknown userr  r  Nadd_userzUser name cannot be blankzUser already existsrL   rZ   delete_userzAt least one user must remainrs   save_presetr1   zInvalid preset payloadrename_presetold_namenew_namezInvalid rename requestdelete_presetzUnknown presetset_appearancezInvalid appearance payloadzUnknown action)r  rF   rC   r   r   r  rU   r   rw   rx   ry   rD   r4   rJ   poprv   )rX  rm   r  r{   r_   r^   rl   source_appearancer1   r  r  rZ   rL   s   &            r,   rp  Handler._handle_site_state_post  s   &&(W[[*00b1779!g^,''w{{6*00b1779D   '>!:3 G$(.!z!w{{6*00b1779D  '+F!GPS T}  '+@!A# N % 3 7 7b I$b,8TUf8ghEK$(.!}$w{{6*00b1779D   '>!:3 G5zQ  '+J!KTW X^$,(.uzz|(KA(Nn%}$w{{6*00b1779D[[*Fz&$77  '+C!DS Q3KF3SE	*40&7;;z288b9??AH7;;z288b9??AH))4G&h  '+C!DS Q 'H 5G&w{{6*00b1779D))4G"  '+;!<S I'' \2Jj$//  '+G!HQT U0LZ0XE-g'78Er.   r5   )   )__name__
__module____qualname____firstlineno__rV  rj  rr  r  r  rb  re  rd  rf  rg  rh  ri  rp  __static_attributes____classcell__)r[  s   @r,   rR  rR    sT    ? 2*/
T
l 
D8
t"
	

",D  D r.   rR  c                   V ^8  d   QhRR/# r^  r5   )r6   s   "r,   r7   r7     s      d r.   c                     R p Rp\        W3\        4      p\        R\         RV  RV 24       \        R\         24       \        R\
         24       VP                  4        R# )z	127.0.0.1i@  zServing z at http://r*  zVoucher SQLite source: zInventory source: N)r   rR  printrW  rL  r   serve_forever)hostportservers      r,   mainr    sa    DD $w7F	HTF+dV1TF
34	#G9
-.	}o
./
r.   __main__)i  )@
__future__r   rc   r   importlib.utilr!   r   rJ  r   r   r   http.serverr   r   pathlibr   urllib.parser	   r
   r   __file__r   parentrW  r$   PULLED_INFO_ROOT
CONFIG_DIRrL  PULLED_INFO_DIRr   r   r   rh   ra   ru   compile
IGNORECASEr   r   r4  r-   rJ   rU   rp   r   rv   r   r   r   r   r   r   r   r   r5  r   r  r  r   rG  rP  rR  r  r  r5   r.   r,   <module>r     s   "  
  	  
 ( E  4 4H~&&"_4-' H_

(
($z1L@  ;. ?2]BEXX!$CC "?? **
**0"--
@::[\ $$$

*!HH'LT^ 

>*)"	*D*  %&
4Y,+\K & K \
 zF r.   