
    +j                        S SK r S SKJr  S SKJrJrJr  S SKJrJ	r	J
r
JrJrJrJrJrJrJrJrJr  S SKJrJrJrJrJrJrJrJrJrJr  SrS\ S\ 4S	 jr!S
\"S\"S\"S\ 4S jr# " S S\RH                  5      r% " S S\RH                  5      r& " S S\RH                  5      r' " S S\RH                  5      r( " S S\RH                  5      r) " S S\5      r*S\*4S jr+g)    N)override)IOComfyExtensionInput)#ImageRelightAdvancedSettingsRequestImageRelightRequest ImageSkinEnhancerCreativeRequest ImageSkinEnhancerFaithfulRequest ImageSkinEnhancerFlexibleRequestImageStyleTransferRequestImageUpscalerCreativeRequestImageUpscalerPrecisionV2RequestInputAdvancedSettingsInputPortraitModeInputSkinEnhancerModeTaskResponse)
ApiEndpointdownload_url_to_image_tensordownscale_image_tensorget_image_dimensionsget_number_of_imagespoll_opsync_opupload_images_to_comfyapivalidate_image_aspect_ratiovalidate_image_dimensionsg
ףp=
?
megapixelsreturnc                 .    U S::  a  gU S::  a  gU S::  a  gg)zLPrice in EUR for a single Magnific upscaling step based on input megapixels.g?gM?g      @gM?g@g~jt?g~jt? )r   s    >/home/wildlama/comfy/ComfyUI/comfy_api_nodes/nodes_magnific.py_tier_price_eurr"   $   s&    SSS    widthheightscalec                     [        [        R                  " U5      5      nSnX-  n[        U5       H  nU[	        US-  5      -  nUS-  nM     [        U[        -  S5      $ )zZCalculate total Magnific upscale price in USD for given input dimensions and scale factor.g        i@B       )intmathlog2ranger"   round_EUR_TO_USD)r$   r%   r&   	num_steps	total_eurpixels_s          r!   %_calculate_magnific_upscale_price_usdr4   /   sa    DIIe$%II^F9_Vi%788	!  [(!,,r#   c                       \ rS rSr\S 5       r\S\R                  S\S\S\S\	S\	S	\	S
\	S\S\
S\R                  4S j5       rSrg)!MagnificImageUpscalerCreativeNode:   c                    [         R                  " SSSS[         R                  R                  S5      [         R                  R                  SSSS	9[         R
                  R                  S
/ SQS9[         R
                  R                  S/ SQS9[         R                  R                  SSSS[         R                  R                  S9[         R                  R                  SSSSS[         R                  R                  S9[         R                  R                  SSSSS[         R                  R                  S9[         R                  R                  SSSSS[         R                  R                  S9[         R
                  R                  S/ SQSS9[         R                  R                  SSS SS!9/
[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                  /S[         R                  " [         R                   " S
S/S"9S#S$9S%9	$ )&Nr6   z!Magnific Image Upscale (Creative)partner/image/Magnificuf   Prompt‑guided enhancement, stylization, and 2x/4x/8x/16x upscaling. Maximum output: 25.3 megapixels.imagepromptT 	multilinedefaultscale_factor2x4x8x16xoptionsoptimized_for)	standardsoft_portraitshard_portraitsart_n_illustrationvideogame_assetsnature_n_landscapesfilms_n_photography
3d_rendersscience_fiction_n_horror
creativityi
   r   )minmaxr?   display_modehdrz#The level of definition and detail.rT   rU   r?   tooltiprV   resemblancez/The level of resemblance to the original image.
fractalityz:The strength of the prompt and intricacy per square pixel.engine)	automaticmagnific_illusiomagnific_sharpymagnific_sparkle)rG   advancedauto_downscaleFzOAutomatically downscale input image if output would exceed maximum pixel limit.r?   rY   ra   widgetsa  
                (
                  $ad := widgets.auto_downscale;
                  $mins := $ad
                    ? {"2x": 0.172, "4x": 0.343, "8x": 0.515, "16x": 0.515}
                    : {"2x": 0.172, "4x": 0.343, "8x": 0.515, "16x": 0.844};
                  $maxs := {"2x": 0.515, "4x": 0.844, "8x": 1.015, "16x": 1.187};
                  {
                    "type": "range_usd",
                    "min_usd": $lookup($mins, widgets.scale_factor),
                    "max_usd": $lookup($maxs, widgets.scale_factor),
                    "format": { "approximate": true }
                  }
                )
                
depends_onexpr	node_iddisplay_namecategorydescriptioninputsoutputshiddenis_api_nodeprice_badge)r   SchemaImager   StringComboIntNumberDisplaysliderBooleanOutputHiddenauth_token_comfy_orgapi_key_comfy_org	unique_id
PriceBadgePriceBadgeDependsclss    r!   define_schema/MagnificImageUpscalerCreativeNode.define_schema;   s   yy7<-/ w'		D"E~7PQ#
   \sATVTdTdTkTklA!#!1!1!8!8   !M!#!1!1!8!8    X!#!1!1!8!8   d!  
 

  $!m!	 ! a6p ! 		..		++		##
 //IY8Z[MX
 X	
r#   r:   r;   r@   rH   rR   rW   rZ   r[   r\   rb   r   c                   ^#    [        U5      S:w  a  [        S5      e[        USSSS9  [        USSS9  S	n[	        U5      u  p[        UR                  S
5      5      nX-  U-  U-  nX:  a  U
(       an  X-  nSnUS-  nS HJ  nUU:  a  M  UU-  U-  nUU::  a  UnS n  O/[        R                  " UU-  5      nUS::  d  M@  UnUUU-  -  n  O   Ub
  [        UUS9nU S
3nO[        SX-   S
X-   SUS SUS S3	5      e[	        U5      u  nn[        UR                  S
5      5      n[        UUU5      m[        U [        SSS9[        [        [        XSS S9I S h  vN S   UUUUUUU	U(       a  UOS S9	S9I S h  vN n[!        U [        SUR"                   3S9[        S U4S jS S!9I S h  vN n[$        R&                  " [)        UR*                  S   5      I S h  vN 5      $  N Nm N< N7f)"N   $Exactly one input image is required.r      r   r   Fstrict   
min_height	min_widthi xr)   r(         r(   r)          @total_pixelszOutput size (z = ,z) pixels) exceeds maximum allowed size of 9 pixels. Use a smaller input image or lower scale factor.z#/proxy/freepik/v1/ai/image-upscalerPOSTpathmethod
max_imagesr   r   )	r:   r@   rH   rR   rW   rZ   r[   r\   r;   response_modeldataz$/proxy/freepik/v1/ai/image-upscaler/r   c                     U R                   $ Nstatusr   s    r!   <lambda>;MagnificImageUpscalerCreativeNode.execute.<locals>.<lambda>       qxxr#   c                    > T$ r   r    r3   	price_usds    r!   r   r          ir#         $@r   status_extractorprice_extractorpoll_interval)r   
ValueErrorr   r   r   r*   rstripr+   sqrtr   r4   r   r   r   r   r   r   task_idr   
NodeOutputr   	generated)r   r:   r;   r@   rH   rR   rW   rZ   r[   r\   rb   max_output_pixelsr%   r$   requested_scaleoutput_pixelsinput_pixelsr&   max_input_pixels	candidatescale_output_pixelsdownscale_ratiofinal_heightfinal_widthactual_scaleinitial_resfinal_responser   s                              @r!   execute)MagnificImageUpscalerCreativeNode.execute   sq      &!+CDD#E66%H!%C3G&,U3l11#678?J,  %~#4#9 !.I ?2 *6*BY*N'*.?? )+/(&*ii0CFW0W&XO&#- )+<YAV+W( "/ $/25GWXE"'{ #E$;#<Af>V=WWZ[hijZk l77H6K LGH  %9$?!k<..s349+|Uab	#B6R'-6sa^bccefg)+%'%!'vT
	
 
   'CKDWDWCXYZ'// 
 
 }}#?@X@XYZ@[#\\]]' d
 
 ]sO   B:G0BG0G(G0<G*=2G0/G,0/G0G. 	G0*G0,G0.G0r    N__name__
__module____qualname____firstlineno__classmethodr   r   rt   strr*   boolr   r   r   __static_attributes__r    r#   r!   r6   r6   :   s    Y
 Y
v R^{{R^ R^ 	R^
 R^ R^ R^ R^ R^ R^ R^ 
R^ R^r#   r6   c                       \ rS rSr\S 5       r\S\R                  S\S\S\	S\	S\	S	\
S
\R                  4S j5       rSrg)"MagnificImageUpscalerPreciseV2Node   c                    [         R                  " SSSS[         R                  R                  S5      [         R                  R                  S/ SQS9[         R                  R                  S	/ S
QSS9[         R
                  R                  SSSSS[         R                  R                  S9[         R
                  R                  SSSSS[         R                  R                  S9[         R
                  R                  SSSSS[         R                  R                  S9[         R                  R                  SSSSS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                  /S[         R                  " [         R                  " S/S9SS9S 9	$ )!Nr   z#Magnific Image Upscale (Precise V2)r9   uq   High-fidelity upscaling with fine control over sharpness, grain, and detail. Maximum output: 10060×10060 pixels.r:   r@   rA   rF   flavor)sublimephotophoto_denoiserzbProcessing style: sublime for general use, photo for photographs, photo_denoiser for noisy photos.rG   rY   sharpenr   d      zNImage sharpness intensity. Higher values increase edge definition and clarity.rX   smart_grainzaIntelligent grain/texture enhancement to prevent the image from looking too smooth or artificial.ultra_detail   zIControls fine detail, textures, and micro-details added during upscaling.rb   FzNAutomatically downscale input image if output would exceed maximum resolution.Trc   rd   a  
                (
                  $mins := {"2x": 0.172, "4x": 0.343, "8x": 0.515, "16x": 0.844};
                  $maxs := {"2x": 2.045, "4x": 2.545, "8x": 2.889, "16x": 3.06};
                  {
                    "type": "range_usd",
                    "min_usd": $lookup($mins, widgets.scale_factor),
                    "max_usd": $lookup($maxs, widgets.scale_factor),
                    "format": { "approximate": true }
                  }
                )
                rf   ri   )r   rs   rt   r   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   s    r!   r   0MagnificImageUpscalerPreciseV2Node.define_schema   s   yy8>-3 w'~7PQBg   l!#!1!1!8!8   !8!#!1!1!8!8   "g!#!1!1!8!8   

  $!l!	 ! E(T ! 		..		++		##
 //8HIqG
 G	
r#   r:   r@   r   r   r   r   rb   r   c                   ^#    [        U5      S:w  a  [        S5      e[        USSSS9  [        USSS9  S	n[	        U5      u  p[        UR                  S
5      5      nX-  nX-  nX:  d  X:  a  U(       a  [        X5      nSnUS-  nUU-  n[        X-  U-  U-  5      nS HH  nUU:  a  M  UU-  nUU::  a  UnS n  O0UU-  nUS::  d  M)  UnUU-  nUU-  n[        X-  U-  U-  5      n  O   Ub
  [        UUS9nUnO[        SU S
U SU S
U S3	5      e[	        U5      u  nn[        UUU5      m[        U [        SSS9[        [        [        XSS S9I S h  vN S   UUUUUS9S9I S h  vN n[        U [        SUR                    3S9[        S U4S jSS9I S h  vN n["        R$                  " ['        UR(                  S   5      I S h  vN 5      $  N Nm N< N7f)Nr   r   r   r   Fr   r   r   iL'  r   r)   r   r   r   zOutput dimensions (z') exceed maximum allowed resolution of r   z0/proxy/freepik/v1/ai/image-upscaler-precision-v2r   r   r   r   )r:   r@   r   r   r   r   r   z1/proxy/freepik/v1/ai/image-upscaler-precision-v2/r   c                     U R                   $ r   r   r   s    r!   r   <MagnificImageUpscalerPreciseV2Node.execute.<locals>.<lambda>  r   r#   c                    > T$ r   r    r   s    r!   r   r     r   r#   r   r   )r   r   r   r   r   r*   striprU   r   r4   r   r   r   r   r   r   r   r   r   r   r   )r   r:   r@   r   r   r   r   rb   max_output_dimensionr%   r$   r   output_widthoutput_heightmax_dimr&   max_input_dimscale_ratior   r   
output_dimr   r   r   r   r   r   s                             @r!   r   *MagnificImageUpscalerPreciseV2Node.execute9  so      &!+CDD#E66%H!%C3G$,U3l0056.0.-2V e, 4 9+g5#&u~'Ck'Q#R !.I ?2 !(9!4J!%99 )+/(&03G&GO&#- )(<	(I&3g&=+.u~/Kk/Y+Z( "/  $/25GWXE"' ),q H%%9$:!<P;Q RGH  %9$?!k9+|Ude	#OX^_'06sa^bccefg,')	
 
  'PQ\QdQdPefg'// 
 
 }}#?@X@XYZ@[#\\]]! d

 ]sO   CG!BG!GG!-G.2G! G!/G!G	G!G!G!G!r    Nr   r    r#   r!   r   r      s    H
 H
T P^{{P^ P^ 	P^
 P^ P^ P^ P^ 
P^ P^r#   r   c                       \ rS rSr\S 5       r\S\R                  S\R                  S\S\	S\	S\S	\S
\
S\S\R                  4S j5       rSrg)MagnificImageStyleTransferNodei  c                    [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  SS	S9[         R                  R                  S
SSS9[         R
                  R                  SSSSS[         R                  R                  S9[         R
                  R                  SSSSS[         R                  R                  S9[         R                  R                  S/ SQSS9[         R                  R                  S/ SQSSS9[         R                  R                  S[         R                  R                  S/ 5      [         R                  R                  S [         R                  R                  S!/ S"QS#S9[         R                  R                  S$/ S%QS&S9/5      /S'S9[         R                  R                  S(SS)SS*9/	[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                   /S[         R"                  " S+S,9S-9	$ ).Nr   zMagnific Image Style Transferr9   z>Transfer the style from a reference image to your input image.r:   z%The image to apply style transfer to.rY   reference_imagez*The reference image to extract style from.r;   Tr<   r=   style_strengthr   r   zPercentage of style strength.rX   structure_strength2   z.Maintains the structure of the original image.r   )faithfulgen_zpsychedeliadetailyclear
donotstyledonotstyle_sharpzStyle transfer flavor.r   r\   )	balanceddefinioillusio
3d_cartooncolorful_anime
caricaturereal
super_realsoftyProcessing engine selection.)rG   rY   ra   portrait_modedisabledenabledportrait_style)rI   pop	super_popz(Visual style applied to portrait images.portrait_beautifier)nonebeautify_facebeautify_face_maxz-Facial beautification intensity on portraits.z-Enable portrait mode for facial enhancements.fixed_generationzlWhen disabled, expect each generation to introduce a degree of randomness, leading to more diverse outcomes.rc   {"type":"usd","usd":0.11}rh   ri   )r   rs   rt   r   ru   rw   rx   ry   rv   DynamicComboOptionrz   r{   r|   r}   r~   r   r   r   s    r!   r   ,MagnificImageStyleTransferNode.define_schema  s+   yy48-Xw0WX0:fg		D"E$;!#!1!1!8!8   (L!#!1!1!8!8   v4  
 
 ;!    %%#..z2>..% "$4,L,V !/ !"
 !#$9,Z,[ !/ !"$ L) & , 

  & 8! ! FP ! 		..		++		##
 4kX
 X	
r#   r:   r   r;   r   r   r   r\   r
  r  r   c
                   #    [        U5      S:w  a  [        S5      e[        U5      S:w  a  [        S5      e[        USSSS9  [        USSSS9  [        USSS	9  [        USSS	9  US
   S:H  n
UR	                  SS5      nUR	                  SS5      n[        XU/SS9I S h  vN n[        U [        SSS9[        [        US   US   U(       a  UOS UUU
U
(       a  UOS U
(       a  US:w  a  UOS UUU	S9S9I S h  vN n[        U [        SUR                   3S9[        S SS9I S h  vN n[        R                  " [        UR                  S   5      I S h  vN 5      $  N Nh N< N7f)Nr   r   (Exactly one reference image is required.r   r   Fr   r   r   r
  r  r  rI   r  r  r)   r   z)/proxy/freepik/v1/ai/image-style-transferr   r   r   )r:   r   r;   r   r   is_portraitr  r  r   r\   r  r   z*/proxy/freepik/v1/ai/image-style-transfer/r   c                     U R                   $ r   r   r   s    r!   r   8MagnificImageStyleTransferNode.execute.<locals>.<lambda>  r   r#   r   r   r   r   )r   r   r   r   getr   r   r   r   r   r   r   r   r   r   r   )r   r:   r   r;   r   r   r   r\   r
  r  r  r  r  uploaded_urlsr   r   s                   r!   r   &MagnificImageStyleTransferNode.execute  s      &!+CDD0A5GHH#E66%H#OVVER!%C3G!/cSQ#O4	A&**+;ZH+//0EvN7_=Ubcdd#HQWX'*#A& -a 0!'vT-#5'1<~$;FK^bhKh$7nr!1	
 
$  'I+J]J]I^_`'/ 
 
 }}#?@X@XYZ@[#\\]]7 e
$
 ]sI   BE' E!AE'8E!9-E'&E#'/E'E%	E'!E'#E'%E'r    N)r   r   r   r   r   r   r   rt   r   r*   r   r   r   r   r   r   r    r#   r!   r   r     s    Y
 Y
v 4^{{4^ 4^ 	4^
 4^  4^ 4^ 4^ )4^ 4^ 
4^ 4^r#   r   c                       \ rS rSr\S 5       r\ SS\R                  S\S\	S\S\
S	\
S
\
S\S\R                  S-  S\R                  4S jj5       rSrg)MagnificImageRelightNodei"  c           "      <   [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  SS	S
SS9[         R
                  R                  SSSSS[         R                  R                  S9[         R                  R                  S/ SQSS9[         R                  R                  SSSS	S9[         R                  R                  SS	SS	S9[         R                  R                  SS	SS	S9[         R                  R                  S[         R                  R                  S/ 5      [         R                  R                  S [         R
                  R                  S!SSS"S#[         R                  R                  S9[         R
                  R                  S$SSS"S%[         R                  R                  S9[         R
                  R                  S&SSS"S'[         R                  R                  S9[         R
                  R                  S(SSS"S)[         R                  R                  S9[         R
                  R                  S*SSS"S+[         R                  R                  S9[         R                  R                  S,/ S-QS.S9[         R                  R                  S// S0QS1S9[         R                  R                  S2/ S3QS4S9[         R                  R                  S5S	S6S79/	5      /S8S9[         R                  R                  S9S	S:S;9/	[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                   /S	[         R"                  " S<S=9S>9	$ )?Nr%  zMagnific Image Relightr9   zWRelight an image with lighting adjustments and optional reference-based light transfer.r:   zThe image to relight.r   r;   Tr<   zFDescriptive guidance for lighting. Supports emphasis notation (1-1.4).)r>   r?   rY   light_transfer_strengthr   r   z(Intensity of light transfer application.rX   style)rI   darker_but_realisticcleansmoothbrightercontrasted_n_hdrjust_compositionzStylistic output preference.r   interpolate_from_originalFz<Restricts generation freedom to match original more closely.rc   change_backgroundz.Modifies background based on prompt/reference.preserve_detailsz1Maintains texture and fine details from original.advanced_settingsr  r  whitesr   z)Adjusts the brightest tones in the image.blacksz'Adjusts the darkest tones in the image.
brightnesszOverall brightness adjustment.contrastzContrast adjustment.
saturationzColor saturation adjustment.r\   )	r]   r   coolr  r  fairyr  hard_transformr  r	  transfer_light_a)r]   lowmediumnormalhighhigh_on_facesz The intensity of light transfer.transfer_light_b)r]   compositionstraight	smooth_in
smooth_outsmooth_bothreverse_bothsoft_insoft_outsoft_midstyle_shiftstrong_shiftzeAlso modifies light transfer intensity. Can be combined with the previous control for varied effects.r  z1Ensures consistent output with the same settings.)r?   rY   z2Fine-tuning options for advanced lighting control.r   z3Optional reference image to transfer lighting from.)optionalrY   r  r  ri   )r   rs   rt   r   ru   rw   rx   ry   rv   rz   r  r  r{   r|   r}   r~   r   r   r   s    r!   r   &MagnificImageRelightNode.define_schema#  s   yy.1-qw0GH		"d	    -F!#!1!1!8!8    ;   

  /!Z!	 !  

  ' L!	 !  

  & O!	 !  %%'..z2>..% "$,()(+,.,W131A1A1H1H !- !" !#$,()(+,.,U131A1A1H1H !- !" !#$0()(+,.,L131A1A1H1H !- !" !#$.()(+,.,B131A1A1H1H !- !" !#$0()(+,.,J131A1A1H1H !- !" !#$,
-& -K !/ !" !#$6,m,N !/ !"
 !#$6-&-d# !/ !"( !#

 0 0$6,0,_ !1 !"cVY\z Q & `B %!Q  aUn ! 		..		++		##
 4Ig
 g	
r#   Nr:   r;   r'  r(  r/  r0  r1  r2  r   r   c
                   #    [        U5      S:w  a  [        S5      eU	b  [        U	5      S:w  a  [        S5      e[        USSSS9  [        USSS	9  U	b  [        U	SSSS9  [        U	SSS	9  [	        XSS
9I S h  vN S   n
S nU	b  [	        X	SS
9I S h  vN S   nS nUS   S:X  a,  [        US   US   US   US   US   US   US   US   US   S9	n[        U [        SSS9[        [        U
U(       a  UOS UUUUUUUS9	S9I S h  vN n[        U [        SUR                   3S9[        S S S!9I S h  vN n[        R                  " [        UR                  S   5      I S h  vN 5      $  N N Nj N> N7f)"Nr   r   r  r   r   Fr   r   r   r  r   r2  r  r3  r4  r5  r6  r7  r\   r;  rA  r  )	r3  r4  r5  r6  r7  r\   r;  rA  r  z"/proxy/freepik/v1/ai/image-relightr   r   )	r:   r;   #transfer_light_from_reference_imager'  r/  r0  r(  r1  r2  r   z#/proxy/freepik/v1/ai/image-relight/r   c                     U R                   $ r   r   r   s    r!   r   2MagnificImageRelightNode.execute.<locals>.<lambda>  r   r#   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r:   r;   r'  r(  r/  r0  r1  r2  r   	image_urlreference_urladv_settingsr   r   s                  r!   r    MagnificImageRelightNode.execute  s      &!+CDD&+?+PTU+UGHH#E66%H!%C3G&'PUV%o#QTU4SANNPQR	&#<S^_#``bcdM01Y>>(2(2,\:*:6,\:(2!23E!F!23E!F!23E!F
L $A&Q'$!'vT4A(?*C"3!1".
	
 
   'B;CVCVBWXY'/ 
 
 }}#?@X@XYZ@[#\\]]U O a 
 
 ]s[   A6E58E+9E5E-A1E5E/-E52E13/E5"E3#	E5-E5/E51E53E5r    r   )r   r   r   r   r   r   r   rt   r   r*   r   r   r   r   r   r   r    r#   r!   r%  r%  "  s    h
 h
T  /3@^{{@^ @^ "%	@^
 @^ $(@^  @^ @^ 1@^ t+@^ 
@^ @^r#   r%  c                   t    \ rS rSr\S 5       r\S\R                  S\S\S\	S\
R                  4
S j5       rS	rg
)MagnificImageSkinEnhancerNodei  c                    [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  SS	S
S	S[         R
                  R                  S9[         R                  R                  SS	S
SS[         R
                  R                  S9[         R                  R                  S[         R                  R                  S/ 5      [         R                  R                  S[         R                  R                  SS	S
SS[         R
                  R                  S9/5      [         R                  R                  S[         R                  R                  S/ SQSS9/5      /SS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                  /S[         R                  " [         R                   " S/S9SS9S 9	$ )!NrX  zMagnific Image Skin Enhancerr9   z>Skin enhancement for portraits with multiple processing modes.r:   zThe portrait image to enhance.r   r   r   r   zSharpening intensity level.rX   r   r)   zSmart grain intensity level.modecreativer   skin_detailP   zSkin detail enhancement level.flexiblerH   )enhance_skinimprove_lightingenhance_everythingtransform_to_real
no_make_upz Enhancement optimization target.r   zProcessing mode: creative for artistic enhancement, faithful for preserving original appearance, flexible for targeted optimization.Trd   z
                (
                  $rates := {"creative": 0.29, "faithful": 0.37, "flexible": 0.45};
                  {"type":"usd","usd": $lookup($rates, widgets.mode)}
                )
                rf   ri   )r   rs   rt   r   rw   rx   ry   r  r  rv   r{   r|   r}   r~   r   r   r   r   s    r!   r   +MagnificImageSkinEnhancerNode.define_schema  s   yy37-Xw0PQ9!#!1!1!8!8   !:!#!1!1!8!8   %%..z2>..& "$1()(+,.,L131A1A1H1H !- !"	 ..& "$3-& -O !/ 
!"@:E & %%8t ! 		..		++		##
 //AOP
 P	
r#   r:   r   r   rZ  r   c                 6  #    [        U5      S:w  a  [        S5      e[        USSSS9  [        USSS9  [	        XSS	S
9I S h  vN S   nUS   nUS:X  a  Sn[        UUUS9nO)US:X  a  Sn[        UUUUS   S9nOSn[        UUUUS   S9n[        U [        SU 3SS9[        US9I S h  vN n	[        U [        SU	R                   3S9[        S SS9I S h  vN n
[        R                  " [        U
R                   S   5      I S h  vN 5      $  N Nh N< N7f)Nr   r   r   r   Fr   r   r   i   r   r   rZ  r[  )r:   r   r   r   r\  )r:   r   r   r\  r^  rH   )r:   r   r   rH   z#/proxy/freepik/v1/ai/skin-enhancer/r   r   r   r   c                     U R                   $ r   r   r   s    r!   r   7MagnificImageSkinEnhancerNode.execute.<locals>.<lambda>  r   r#   r   r   )r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   )r   r:   r   r   rZ  rS  selected_modeendpointr   r   r   s              r!   r   %MagnificImageSkinEnhancerNode.executeg  se      &!+CDD#E66%H!%C3G4SA\ghhjkl	VJ&!H3'D
 j(!H3' /	D "H3'"?3	D $B8*MV\]'	
 
  'B;CVCVBWXY'/ 
 
 }}#?@X@XYZ@[#\\]]Q i6

 ]sI   A DDA'D*D+-DD/DD		DDDDr    N)r   r   r   r   r   r   r   rt   r*   r   r   r   r   r   r    r#   r!   rX  rX    sj    Q
 Q
f 4^{{4^ 4^ 	4^
 $4^ 
4^ 4^r#   rX  c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)MagnificExtensioni  r   c                 @   #    [         [        [        [        [        /$ 7fr   )r6   r   r   r%  rX  )selfs    r!   get_node_listMagnificExtension.get_node_list  s       ..*$)
 	
s   r    N)r   r   r   r   r   listtyper   	ComfyNodero  r   r    r#   r!   rl  rl    s)    
T$r||*<%= 
 
r#   rl  c                     #    [        5       $ 7fr   )rl  r    r#   r!   comfy_entrypointru    s     s   ),r+   typing_extensionsr   comfy_api.latestr   r   r   comfy_api_nodes.apis.magnificr   r   r	   r
   r   r   r   r   r   r   r   r   comfy_api_nodes.utilr   r   r   r   r   r   r   r   r   r   r/   floatr"   r*   r4   rs  r6   r   r   r%  rX  rl  ru  r    r#   r!   <module>r{     s     & 6 6       % - -c -# -RW -p^ p^f]^ ]^@R^R\\ R^jm^r|| m^`J^BLL J^Z	
 	
 1 r#   