
    ɢi.                        d Z dZd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	Z	ddl
mZ ddlmZmZ ddlmZmZmZmZ ddlmZ dd	lmZ  ej0                  e      Zd
ededz  fdZdadefdZdefdZd Z de!de"fdZ# ed      Z$ddddddddddddddddd d!d"dd#Z%d$d%d&dd'd(d)dd*d+d,dd-d.d/dd0d1d2dd3d4d5dd6Z&d7Z'd8d9d:d;d<d=d>d?d@d<dAdBdCdDd<dEZ(dFdGdHdIdJdKdLdMdNdOdPdKdQdRdSdTdPdKdUdVdWdXdYdKdZd[d\d]d^dKd_d`dadbdcdKddZ)dee*dfe*ddfdgZ+dhe*diedjede*fdkZ,dledefdmZ-dne.doedefdpZ/dqe.defdrZ0 e eds       edtdudvw       ee#      dxy      ddzed{ede.fd|       Z1dd}ed~edefdZ2	 	 	 	 	 	 	 ddhe*diedjeded{edledede3d}ed~ede*fdZ4	 	 	 	 	 	 	 ddhe*diedjedededed{edledede3d}ed~ede*fdZ5	 	 	 	 	 	 	 ddhe*diedjeded{edledede3d}ed~ede*fdZ6	 	 	 	 	 	 ddedhe*diedjed{edledede3d}ed~ede*fdZ7	 	 	 	 	 ddhe*diedjede*dlededed{ede*de*fdZ8	 	 ddedhe*diedjedled{ede*de*fdZ9de*de*fdZ:de*de;fdZ<de*dede*fdZ=y)a  
Aura Graphics Pack Engine v2.0.0
================================
AI-powered brand graphics generation using Google Gemini (Nano Banana).

Generates cohesive visual identity packs:
  - Logos (5 styles: wordmark, emblem, abstract_mark, icon_text, monogram)
  - Section icons (per content section)
  - Site Essentials (favicon, nav_logo, footer_logo, og_image, cta_accent, email_header)
  - Decorative separators (6 styles)

Every asset and pack carries unique identifiers and version tracking:
  - Pack: pack_id (GP-xxxx), pack_version (auto-increments on regeneration)
  - Assets: asset_id (GPA-xxxx), revision number, lineage tracking

HISTORY: Every regenerated asset is preserved in history[]. Nothing is ever lost.
z2.0.0       N)Path)ThreadPoolExecutoras_completed)retrystop_after_attemptwait_exponentialretry_if_exception)genai)typeskeysreturnc                  \    | D ]'  }t         j                  j                  |      }|s%|c S  y N)osenvironget)r   keyvals      3/sites/domain-asset-master/app/services/graphics.py_resolve_envr   &   s0     jjnnS!J     c                  f    dt        j                         j                  d d j                          S )NzGP-   uuiduuid4hexupper r   r   _generate_pack_idr!   1   s,    !!"1%++-.//r   c                  f    dt        j                         j                  d d j                          S )NzGPA-r   r   r    r   r   _generate_asset_idr#   5   s,    $**,""2A&,,./00r   c                      t         :t        ddd      } t        d      }ddi}|r||d<   t        j                  | |      a t         S )	NAI_INTEGRATIONS_GEMINI_API_KEYGEMINI_API_KEYGOOGLE_API_KEYAI_INTEGRATIONS_GEMINI_BASE_URLapi_version base_url)api_keyhttp_options)gemini_clientr   r   Client)r,   r+   	http_optss      r   _get_gemini_clientr1   9   sW    ?AQScd AB"B'	$,Ij!"
 r   	exceptionc                     t        |       }t        | dd       xs t        | dd       }d|v xs3 d|v xs- d|j                         v xs d|j                         v xs |dk(  S )Nstatusstatus_code429RATELIMIT_EXCEEDEDquotaz
rate limiti  )strgetattrlower)r2   	error_msgr5   s      r   is_rate_limit_errorr=   H   s{    II)Xt4_	=Z^8_K 	9,	ioo''	 9??,,	 #r   zstatic/graphicszLS-01Wordmarku  A premium typographic wordmark logo — the brand name rendered in bespoke lettering with the precision of hand-engraved watch dials. Each letterform should feel individually crafted: deliberate weight variation, tasteful kerning, and subtle typographic details like tapered terminals, ink traps, or hairline serifs that reward close inspection. Think Rolls-Royce badge lettering or Breguet watch numerals — quiet authority through typographic mastery. No icon, pure lettering excellence.)idnamedescriptionzLS-02Emblemu  A prestige emblem/crest logo with the craftsmanship of a Bentley hood ornament or Swiss watch case-back engraving. The brand name sits within an architecturally structured frame — shield, medallion, or crest — with ornamental details that feel hand-tooled: fine line filigree, symmetrical scrollwork, and layered depth through precise line-weight hierarchy. Every decorative element should serve a purpose, nothing arbitrary. The kind of emblem you'd stamp into leather or emboss on heavy card stock.zLS-03zAbstract Marku  A modern abstract geometric mark with the engineered precision of a supercar air intake or turbine blade — every curve exists for a reason. The symbol should feel like it was CNC-machined from a single concept: clean geometric relationships, golden-ratio proportions, and the kind of satisfying visual tension between positive and negative space that makes designers stare. Think Pininfarina design language — minimal but loaded with intent. No text, pure form.zLS-04zIcon + Textu
  A combination mark where icon and typography are married with the fit-and-finish of a Pagani dashboard — each element distinctly excellent, yet together forming something greater. The icon should be a distilled symbol of the brand concept: bold, geometric, memorable in silhouette. The text sits alongside with deliberate spacing and weight-matched to the icon's visual density. The two elements should feel like they share a DNA — same design vocabulary, same level of refinement, unified by invisible grid alignment.zLS-05Monogramu  An elegant monogram using the brand's initials with the intricacy of Damascus steel pattern-welding — letters interlocked, interwoven, or nested with geometric precision. Each letterform should have deliberate overlap or nesting points that feel engineered, not accidental. The kind of monogram you'd hot-stamp into bridle leather or etch into sapphire crystal. Balanced weight distribution, optical centering, and the quiet confidence of old-money craftsmanship.)wordmarkemblemabstract_mark	icon_textmonogramzSS-01Flowinguy  organic flowing lines with the fluidity of hand-blown Murano glass — continuous, sinuous curves that breathe like silk in wind. Each line should have deliberate thickness variation as if drawn by a master calligrapher's brush: swelling at the curves, tapering to hairline at the extremities. Not random waviness — controlled elegance with the grace of Art Nouveau ironwork.zSS-02	Geometricu  precision geometric patterns with the engineered exactness of carbon fiber weave or guilloche watch dial engraving. Sharp angles, perfect symmetry, and mathematically derived spacing. Every intersection point is deliberate. Think aerospace engineering meets decorative art — the kind of pattern you'd find laser-etched into titanium or machined into a supercar's billet aluminum controls.zSS-03	Botanicalu  delicate botanical filigree with the refined intricacy of Victorian botanical illustration or pressed-flower herbarium art. Individual leaves should show vein structure, stems should taper naturally, and tendrils should curl with organic Fibonacci spirals. Not clip-art flowers — this is botanical craftsmanship, the kind of detail you'd find hand-engraved on a silver tea service or embossed on fine Italian stationery.zSS-04Abstractu  abstract artistic expression with the controlled energy of sumi-e brush mastery — each stroke placed with deliberate intention, not random splatter. Varying ink density from saturated core to feathered edge. The kind of abstract mark that looks effortless but reveals deep technical skill on close inspection. Think Franz Kline's structural boldness meets Japanese wabi-sabi restraint.zSS-05
Ornamentalu  symmetrical ornamental scrollwork with the precision of hand-chased silver repoussé or carved Baroque architectural molding. Balanced volutes, acanthus-inspired curves, and hierarchical detail levels — primary scrolls framing secondary flourishes framing tertiary finials. Every element mirrors perfectly. The craftsmanship of a master silversmith: no lazy symmetry, every curve hand-refined.zSS-06Minimalu  ultra-minimal with the restraint of a single piano note in a concert hall — one thin, perfectly weighted horizontal line with a small, exquisitely detailed centered accent element. The line should have a subtle warmth: not ruler-straight but hand-ruled with barely perceptible character. The center accent is tiny but precious — like a single diamond set into platinum. Maximum impact from minimum elements.)flowing	geometric	botanicalabstract
ornamentalminimalgemini-2.5-flash-imagezMDL-01zNano Banana (Fast)standardz$0.04)r?   r@   tiercost_per_imagezMDL-03zFlash Exp (Experimental)experimentalz~$0.04zMDL-02zNano Banana Pro (Legendary)	legendaryz$0.13)rU   zgemini-2.0-flash-expzgemini-3-pro-image-previewzSE-01FaviconzlA tiny square icon (32x32) that appears in browser tabs. Must be instantly recognizable at very small sizes.u  Create a premium favicon icon for a brand called "{brand_name}" in the {niche} niche.

CRAFTSMANSHIP STANDARD: This is the brand's smallest ambassador — like a signet ring or cufflink monogram. Every pixel matters at this scale. IMPORTANT: This is a FLAT 2D graphic icon — no photorealistic textures, no 3D materials, no surface rendering.

CRITICAL SIZE CONSTRAINT: Must read clearly at 32x32 pixels. Ultra-simple. If it has more than one element, it's too complex.

DESIGN:
- Single, bold, iconic shape or letterform that distills the entire brand into one symbol
- Use {primary} as the dominant color — pure, saturated, no muddy tones
- The shape must have PERFECT geometric balance — optically centered, not mathematically centered
- Designed with the precision mindset of fine engraving — but rendered as clean flat vector art
- Ultra-simple silhouette that reads instantly at 32x32 pixels — if it doesn't read at thumbnail size, it fails
- Clean edges with pixel-perfect crispness — no anti-aliasing haze, no fuzzy borders
- Transparent or solid background (no gradients at this scale)
- NO text, NO fine details, NO complexity — this is reductive design mastery
- The icon should feel like it was carved from a single piece of precious material32x32)r?   r@   rA   prompt_template	size_hintzSE-02zNavigation LogozpA compact horizontal logo variant optimized for website navigation bars. Smaller and simpler than the main logo.u  Create a compact horizontal navigation bar logo for "{brand_name}" ({niche}).

CRAFTSMANSHIP STANDARD: This logo lives in the navigation bar — the brand's constant presence on every page. Like a dashboard badge: always visible, never distracting, unmistakably premium. IMPORTANT: Flat 2D vector graphic — no photorealistic textures or 3D rendering.

CRITICAL SIZE CONSTRAINT: Must be perfectly legible at 40px height. Every element must read at this small scale.

DESIGN:
- Horizontal aspect ratio optimized for 40px height
- Clean, refined brand name in a carefully chosen typeface — weight-matched to the accompanying icon
- Small icon/symbol to the left of the text, proportionally balanced (not oversized)
- Use {primary} as dominant color, {secondary} for icon accent
- The spacing between icon and text should feel like hand-kerned typography — deliberate, not default
- Transparent background — must sit cleanly on any header color
- Think of the precision of a Leica camera top-plate engraving: compact, authoritative, quietly luxurious
- NO gradients, NO shadows, NO effects — pure form and color
- Must remain crisp and legible, not blurry or crowded at navigation scale
wide_smallzSE-03zFooter LogozqA monochrome or muted version of the logo for website footers. Typically white/light for dark footer backgrounds.u-  Create a footer logo variant for "{brand_name}" ({niche}).

CRAFTSMANSHIP STANDARD: The footer logo is the brand's closing signature — like a hallmark stamped on fine silverware. Understated, elegant, permanent. IMPORTANT: Flat 2D vector graphic — no photorealistic textures or 3D rendering.

DESIGN:
- Monochrome white or light gray design — must look stunning on a dark background
- Horizontal layout, clean and spacious
- Slightly more restrained than the main logo — less visual weight, more breathing room
- Transparent background (this will sit on dark footer sections)
- The white rendering should feel like platinum foil stamping on dark leather — luminous and precise
- Typography should be thinner/lighter weight than the main logo — whispered, not spoken
- NO colored elements — purely monochrome white with possible gray tonal variation for depth
- NO shadows, NO glows — the contrast against the dark background provides all the presence needed
- Think of a luxury brand's embossed packaging: the logo is there, unmistakable, but never loudzSE-04zSocial Share ImagezoThe image that appears when your site is shared on social media (Facebook, Twitter, LinkedIn). 1200x630 pixels.u  Create a social media share card image for "{brand_name}" — a {niche} brand with tagline "{tagline}".

CRAFTSMANSHIP STANDARD: This is the brand's first impression on social media — a digital business card that must command attention in a feed of mediocrity. Like the cover of a Taschen art book: bold, confident, impossible to scroll past.

DESIGN:
- 1200x630 landscape aspect ratio — MUST have a solid or gradient background (NOT transparent)
- Background: rich, deep gradient using {primary} and {secondary} — bold, saturated color depth. Optionally add an ultra-subtle flat geometric pattern overlay (not a texture render — a clean vector pattern at low opacity)
- Brand name "{brand_name}" in LARGE, bold, beautifully typeset text as the dominant focal point — centered or slightly above center
- Tagline "{tagline}" in smaller, lighter text below the brand name — refined spacing, not cramped
- Use {accent} sparingly for a small highlight element: an underline, a dot, a subtle decorative accent
- Typography must have generous letter-spacing and feel hand-placed, not template-generated
- Ensure EXTREME contrast between text and background — this must read clearly at tiny social thumbnail sizes
- NO photographs, NO complex illustrations, NO photorealistic textures or material rendering — pure flat typographic and color design
- The overall impression should be: "this brand knows exactly what it is" 1200x630zSE-05zCTA Accent GraphiczUA small decorative accent graphic used near call-to-action buttons to draw attention.u+  Create a small decorative accent graphic for call-to-action areas on a {niche} website.

CRAFTSMANSHIP STANDARD: This is visual energy in concentrated form — small, vibrant, irresistible. Every detail at this tiny scale must be perfect. IMPORTANT: Flat 2D vector graphic — no photorealistic textures or 3D rendering.

DESIGN:
- Abstract decorative element: an energy burst, a directional swoosh, converging arrows, or radiating sparks
- Use {accent} as the dominant color — vivid, saturated, electric
- Transparent background — this floats near CTA buttons as a visual attractor
- The element should feel kinetic — like captured motion, frozen energy, a visual "go" signal
- Must work beautifully at 80-120px — small but potent
- Clean vector-style rendering: crisp edges, no blur, no soft gradients
- Think of the glow around a supercar's start/stop button or the light streak of a F1 car's brake light
- NOT busy — this is one elegant gesture, not a firework display
- NO text, NO photorealistic elements, NO 3D materials — pure flat abstract energysmall_accentzSE-06zEmail HeaderzFA branded header graphic for marketing emails. Horizontal, 600px wide.u>  Create an email header banner for "{brand_name}" ({niche}).

CRAFTSMANSHIP STANDARD: This banner opens every marketing email — it sets the tone before a single word is read. Like the masthead of a luxury magazine: authoritative, beautiful, and instantly establishing quality expectations.

DESIGN:
- Horizontal banner, 600px wide × 150px tall proportions
- MUST have a solid or gradient background (NOT transparent) — rich, confident color using {primary} and {secondary}
- Brand name "{brand_name}" in clean, bold typography — centered or left-aligned with intentional asymmetry
- The background should feel layered and rich: a deep gradient with optional ultra-subtle flat geometric pattern overlay at very low opacity (NOT a material texture — a clean vector pattern)
- Typography should feel hand-set: generous letter-spacing, perfect vertical centering, weight that commands without shouting
- Use {accent} only for a tiny highlight detail — a thin accent line, a small decorative element
- Must render reliably across ALL email clients — no transparency tricks, no complex layering
- NO photographs, NO illustrations, NO photorealistic textures or material rendering — pure flat typographic and color design
- The banner should feel like opening a luxury product's packaging: the first visual says "you're in good hands" email_banner)faviconnav_logofooter_logoog_image
cta_accentemail_headerpack
asset_datac                     |r|j                  d      sy d| vrg | d<   t        |      }t        j                  j                         j	                         |d<   | d   j                  |       y )Nasset_idhistoryreplaced_at)r   dictdatetimeutcnow	isoformatappend)ri   rj   archiveds      r   _archive_asset_to_historyru   *  sb    Z^^J7YJH&//668BBDH]O8$r   
brand_datanichemoodc                 l   | j                  dd      }| j                  dd      }| j                  dd      }| j                  dd      }| j                  d	d      }| j                  d
d      }| j                  di       j                  dd      }	||||||||d|	d| d| d| d| d| d| d| d|	 dS )Ncolor_primaryz#4F46E5color_secondaryz#7C3AEDcolor_accentz#06B6D4r@   r*   taglinetoneprofessionalpaletterA   )primary	secondaryaccentzDesign for a  z brand called 'z '. The visual style should feel z. Use colors z (primary), z (secondary), z (accent). )
brand_namer}   rw   rx   r~   colorspalette_descriptionstyle_direction)r   )
rv   rw   rx   r   r   r   r   r}   r~   palette_descs
             r   _build_style_seedr   4  s$   nn_i8G0)<I^^NI6F+JnnY+G>>&.1D>>)R044]BGL !"

  ,*4&%
|Sstxsy  zG  HO  GP  P\  ]f  \g  gu  v|  u}  }H  IU  HV  W r   domainc                     | j                  dd      j                  dd      }t        |z  }|j                  dd       |S )N/_\T)parentsexist_ok)replaceGRAPHICS_DIRmkdir)r   safe_domain
domain_dirs      r   _ensure_domain_dirr   M  sB    ..c*224=K+JTD1r   image_bytesfilepathc                 .    |j                  |        d| S )Nr   )write_bytes)r   r   s     r   _save_image_bytesr   T  s    %xj>r   datac                 N    t        j                  |       j                         d d S )N   )hashlibsha256	hexdigest)r   s    r   _compute_content_hashr   Y  s!    >>$))+CR00r               )
multiplierminmaxT)stopwaitr   reraisepromptmodelc                 v   |xs t         }t               }d|v rddg}ndg}|j                  j                  || t	        j
                  |            }|j                  st        d| d      |j                  d	   }|j                  r|j                  j                  st        d
| d      |j                  j                  D ]e  }t        |d      s|j                  s|j                  j                  }t        |t              rt        j                   |      c S t#        |      c S  t        d| d      )Nz	2.0-flashTextImageIMAGE)response_modalities)r   contentsconfigz(No candidates in Gemini response (model=)r   z+No content parts in Gemini response (model=inline_dataz.No image data found in Gemini response (model=)DEFAULT_MODELr1   modelsgenerate_contentr   GenerateContentConfig
candidates
ValueErrorcontentpartshasattrr   r   
isinstancer9   base64	b64decodebytes)r   r   client
modalitiesresponse	candidatepart
image_datas           r   _generate_image_geminir   ]  s6    "]E!Feg&
Y
}}--** *
 . H CE7!LMM##A&II$5$5$;$;FugQOPP!!'' %4'D,<,<))..J*c*''
33$$% EeWAN
OOr   influence_urlreference_promptc                     g }| r|j                  d|  d       |r|j                  d| d       dj                  |      S )Nzk
STYLE INFLUENCE (BRAND KIT REFERENCE):
The client has provided a reference image from their brand kit at: u?  
Study the visual language, color distribution, line weight, and overall aesthetic of that reference.
Incorporate its stylistic DNA — color temperature, geometric vs organic quality, level of detail — into this new asset.
Do NOT copy it literally; instead let it guide the visual vocabulary and craftsmanship level.z%
CREATIVE DIRECTION (USER-PROVIDED):
zh
Incorporate these specific creative directions while maintaining brand coherence and quality standards.
)rs   join)r   r   r   s      r   _build_influence_suffixr     si    E DDQ? S^a 	b    hk 	l 99Ur   styleprevious_asset_idrevisionc
                    |xs t         }t        | ||      }
t        j                  |t        d         }|d   }|
d   }|
d   d   }|
d   d   }|
d   d   }d| d	| d
| d| d| d|
d    d|
d    d| d| d| d}|t	        ||	      z  }t
        j                  d| d| d|        t        ||      }t        |      }t        |      }|j                  dd      j                  dd      j                  dd      d d j                         }d| d| d}||z  }t        ||      }t               }t        j                  |d |d!d"      }i d#|d$d%d&d%d'd(|d)    d*d+|d,   d-|d.|d)   d/|d0|d1|d2|d3|d4|d,   d5|d6|d)   d7t        j                   |j#                               j%                         d d8 d9t&        j&                  j)                         j+                         d:t,        iS );NrG   rA   r   r   r   r   r   z"Design an ultra-premium logo for "u   " — a z brand.

Think step by step about what makes this brand unique, then create a logo that a Fortune 500 company would pay $50,000 for.

STYLE DIRECTIVE: z

BRAND DNA:
- Niche: z	 | Mood: z	 | Tone: r~   z
- Tagline: "r}   uI   "

EXACT COLORS (mandatory — use these precise hex values):
- Primary: uF    — dominant structural color, at least 60% of the mark
- Secondary: uA    — supporting elements, typographic contrast, 25-30%
- Accent: u   — ONE surgical highlight, a single jewel-like detail, max 10%

COMPOSITION RULES (non-negotiable):
1. TRANSPARENT BACKGROUND — no rectangles, no circles behind, no background fill whatsoever
2. The logo floats on transparency with generous padding on all sides
3. Optically centered (not mathematically — adjust for visual weight distribution)
4. Total element count: maximum 3 distinct visual components (icon + text + accent detail)
5. If text is present: each letter must be individually considered — custom kerning, optical spacing, deliberate weight
6. The silhouette alone must be recognizable — it should read clearly as a solid black shape

RENDERING STANDARD:
- FLAT 2D vector illustration style — razor-crisp edges like laser-cut stainless steel
- Line weights: deliberate hierarchy — primary strokes 3-4x thicker than detail strokes
- Geometric precision: all angles are intentional (45°, 30°, 60° relationships), all curves follow consistent radius logic
- Color application: solid fills only, no gradients, no transparency, no blending
- NO photorealism, NO 3D rendering, NO shadows, NO glows, NO textures, NO bevels
- NO busy ornamentation — every element must justify its existence
- The overall impression: engineered luxury, quiet authority, timeless sophisticationGenerating z
 logo for  with r   -r   r*   r   (   zbrand-logo-.pngMDL-00unknownr?   r@   rW   rl   typelogoclassificationdisplay_namezBrand Logo (r@   r   style_idr?   r   
style_namer   replacesurlfilenamecontent_hashmodel_idr   
model_nameprompt_fingerprintr   generated_atengine_version)r   r   LOGO_STYLESr   r   loggerinfor   r   r   r   r;   r   r#   MODELSr   md5encoder   rp   rq   rr   ENGINE_VERSION)rv   rw   rx   r   r   r   r   r   r   r   
style_seed
style_meta
style_descr   r   r   r   r   r   r   r   
safe_brandr   r   r   rl   
model_metas                              r   generate_logor     s    "]E":ud;JK(@AJM*JL)J"9-G8$[1I!(+F3J<xw O  
 	$yF);(< =	"# $ 9 [ ( VYF@ %m5EFFF
KK+eWJvhfUGDE(7K(5L#F+J##C-55c2>FFtRPQTRTU[[]JUG1ZL5HH$H
K
2C!#HE(E9#UVJH 	& 	,z&'9&:!<	
 	Jt$ 	 	j( 	H 	% 	s 	H 	 	Jt$ 	 	j(  	gkk&--/:DDFrJ!" 	))002<<>#$ 	.% r   section_typesection_title	icon_hintc                    |xs t         }t        | ||      }|d   d   }|d   d   }|rd| dnd| d}dddd	d
ddddddddddd}|j                  |d      }d| d| d| d| d| d| d| d| d| d | d!}|t        |
|      z  }t        j                  d"| d#| d$       t        ||      }t        |      }t        |      }|j                  d%d&      j                  d'd(      j                  d)d(      d d* j                         }d+| d&| d,}||z  }t        ||      }t               }t        j                  |d-|d.d/      }i d0|d1d2d3d4d5d6| d7|d8|d9|	d:|d;|d<|d=|d>|d?   d@|dA|dB   dCt        j                  |j!                               j#                         d dD dEt$        j$                  j'                         j)                         dFt*        S )GNr   r   r   zrepresenting the concept of ''uv   key capabilities or benefits — a precision-cut gemstone, a master-tooled gear, or a radiating star with crisp facetsu   a process or workflow — interlocking gears with visible teeth precision, a stepped pathway with clean angles, or a circuit-trace flowpathu   a challenge or pain point — a fractured geometric shape showing clean break lines, a maze with visible walls, or a precision warning diamondu   a resolution or answer — a key with detailed ward cuts, a lightbulb with filament structure, or a checkmark with confident stroke weightu   identity or story — a refined silhouette with considered proportions, an architectural building with structural detail, or a heart with geometric construction linesu   data or metrics — a chart with precisely weighted bars, an upward trend arrow with engineered curves, or a gauge dial with tick marksu   social proof or trust — speech bubbles with crisp corners and deliberate overlap, a constellation of stars with geometric placement, or quotation marks with typographic weightu{   value or plans — a price tag with a clean fold detail, a diamond with facet lines, or tiered blocks with precise stackingu   evaluation or choice — a balance scale with mechanical pivot detail, parallel columns with equal weight, or a versus symbol with architectural symmetryu   visual showcase — an aperture with blade-like segments, a picture frame with mitered corner detail, or a grid with golden-ratio proportionsu   people or collaboration — group silhouettes with deliberate overlap hierarchy, interlocking hands with finger detail, or connected nodes with precise link linesu   tools or knowledge — a book with visible spine and page edges, a toolbox with latch detail, or a download arrow with technical precisionu   questions and answers — a question mark with considered typographic weight and terminal detail, a chat bubble with crisp geometry, or a help circle with precise stroke widthu   communication or reach — an envelope with fold lines and seal detail, a phone with refined proportions, or a location pin with inner circle precisionu   action or engagement — a rocket with exhaust detail and aerodynamic lines, a forward arrow with speed-streak taper, or a lightning bolt with angular facets)featureshow_it_worksproblemsolutionaboutstatstestimonialspricing
comparisongalleryteam	resourcesfaqcontactctazIa relevant symbolic representation with considered geometric constructionzDesign a single premium icon z for a z8 website.

Think about what ONE symbol best represents "uY   " — then render it with the precision of Swiss graphic design.

PURPOSE: Icon for the "z" section titled "z"
VISUAL METAPHOR: z 

EXACT COLORS:
- Primary fill: u<    — the main shape, bold and confident
- Secondary detail: ux   — one internal detail or accent element for visual depth

COMPOSITION (strict rules):
1. ONE single unified symbol — not multiple objects, not a scene, ONE iconic shape
2. TRANSPARENT BACKGROUND — no circle behind it, no badge, no square, nothing. Just the icon floating
3. The icon occupies roughly 70% of the canvas, centered with breathing room
4. Maximum 2 colors (z and u  ) — no other colors
5. The silhouette alone must communicate the concept (squint test: does it read as a solid shape?)

RENDERING:
- FLAT 2D vector illustration — crisp edges, solid fills, no gradients
- Bold geometric construction — clean angles, consistent curves, mathematical relationships between elements
- Line weight hierarchy if using strokes: thick for primary structure (4px+), thin for inner detail (1-2px)
- Every edge laser-sharp — no soft edges, no blur, no feathering
- NO text, NO labels, NO words
- NO 3D, NO shadows, NO gradients, NO glow, NO photorealism
- The quality standard: Apple's SF Symbols or Google Material Icons — simple but unmistakably premiumzGenerating icon for section 'z' (r   r   r   r   r*   r      zsection-icon-r   r   r   r   rl   r   iconr   icon_graphicr   u   Section Icon — sectionr   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   r#   r   r   r   r   r   rp   rq   rr   r   )rv   rw   rx   r   r   r   r   r   r   r   r   r   r   r   r   icon_contextsection_type_hints	type_hintr   r   r   r   
safe_titler   r   r   rl   r   s                               r   generate_section_iconr    sB    "]E":ud;J"9-G8$[1ICL29+Q?Tqr  rA  AB  SCL M f d a z [ L Q r c u b A m o" #&&|  6A  BI.|nGE7 K..;_ =$~%7 G  	 K   YeI; 
/hkF6 %m5EFFF
KK/~SJK(7K(5L#F+J&&sC088bAII$PRSTWUWX^^`J|nAj\>HH$H
K
2C!#HE(E9#UVJH 	. 	+M?;	
 	< 	 	H 	% 	s 	H 	 	Jt$ 	 	j( 	gkk&--/:DDFrJ  	))002<<>!" 	.# r   separator_stylec
                 r   |xs t         }t        | ||      }
|
d   d   }|
d   d   }|
d   d   }|}|dk(  rddddd	d
}|j                  |d      }t        j                  |t        d         }|d   }d| d| d| d| d| d}|t	        ||	      z  }t
        j                  d| d|        t        ||      }t        |      }t        |      }d| d}||z  }t        ||      }t               }t        j                  |d|dd      }i d|dddddd |d!    d"d#|d$   d%|d&|d!   d'|d(|d)|d*|d+|d,|d-|d$   d.|d/|d!   d0t        j                  |j                               j!                         d d1 t"        j"                  j%                         j'                         t(        d2S )3Nr   r   r   r   autorP   rR   rT   rQ   )r   creativerT   boldwarmrO   rA   zADesign a wide horizontal decorative separator line for a premium z website.

SEPARATOR STYLE: z

COLORS:
- Primary: u*    — main decorative element
- Secondary: u!    — supporting detail
- Accent: u   — optional single tiny highlight

COMPOSITION (strict):
1. EXTREME wide aspect ratio — approximately 1200px wide × 40px tall (a thin horizontal ribbon)
2. TRANSPARENT BACKGROUND — the decorative element floats, no filled rectangle behind it
3. Perfectly symmetrical — mirrored left-to-right from a center axis
4. The center may have a small focal motif (a diamond, a knot, a flourish) with decorative lines extending outward to both edges
5. Lines taper and fade toward the edges — the endpoints dissolve gracefully, not hard-stop
6. Total visual weight: LIGHT — this whispers, it does not shout

RENDERING:
- FLAT 2D vector illustration — crisp clean lines, no texture, no grain
- Line weight: thin and refined (1-3px equivalent), deliberate variation for visual rhythm
- Solid color fills only — no gradients, no transparency effects
- NO text, NO 3D, NO shadows, NO photorealism
- The quality of a hand-engraved certificate border — precise, elegant, restrainedr   z separator for zsection-separator-z-divider.pngr   r   r   rl   r   	separatorr   section_separatorr   zSection Separator (r@   r   r   r?   r   r   requested_styler   r   r   r   r   r   r   r   r   r   )r   r   )r   r   r   SEPARATOR_STYLESr   r   r   r   r   r   r   r#   r   r   r   r   r   rp   rq   rr   r   )rv   rw   rx   r  r   r   r   r   r   r   r   r   r   r   resolved_stylemood_separator_mapr   r   r   r   r   r   r   r   r   rl   r   s                              r   generate_separatorr$  U  s    "]E":ud;J"9-G8$[1I!(+F$N& '" 
 ,//i@!%%n6Fy6QRJM*JRSXRY Z  9 [ ( UXF0 %m5EFFF
KK+n-_VHEF(7K(5L#F+J#N#3<@HH$H
K
2C!#HE(E9#UVJH 	- 	-j.@-AC	
 	Jt$ 	 	j( 	? 	H 	% 	s 	H 	 	Jt$ 	  	j(!" 	gkk&--/:DDFrJ#$ !))002<<>(' r   essential_typec
           	         |xs t         }| t        vrt        d|        t        |    }
t        |||      }|d   d   }|d   d   }|d   d   }|d   }|d   }|
d   j	                  |||||||	      }|t        ||	      z  }t        j                  d
|  d| d|        t        ||      }t        |      }t        |      }|j                  dd      j                  dd      j                  dd      d d j                         }d|  d| d}||z  }t        ||      }t               }t        j!                  |d|dd      }i d|ddd| ddd|
d   d|
d    d!|
d!   d"|d#|d$|d%|d&|d'|d    d(|d)|d   d*t#        j$                  |j'                               j)                         d d+ d,t*        j*                  j-                         j/                         d-t0        iS ).NzUnknown essential type: r   r   r   r   r   r}   r]   )r   rw   rx   r   r   r   r}   zGenerating essential 'z' for r   r   r   r   r*   r   r   z
essential-r   r   r   r   rl   r   	essentialr%  r   r   r@   essential_idr?   r^   r   r   r   r   r   r   r   r   r   r   r   r   )r   SITE_ESSENTIALSr   r   formatr   r   r   r   r   r   r   r;   r   r#   r   r   r   r   r   r   rp   rq   rr   r   )r%  rv   rw   rx   r   r   r   r   r   r   metar   r   r   r   r   r}   r   r   r   r   r   r   r   r   rl   r   s                              r   generate_essentialr,    s    "]E_,3N3CDEE>*D":ud;J"9-G8$[1I!(+FL)J#G#$++U9VW , F %m5EFFF
KK((8vhfUGTU(7K(5L#F+J##C-55c2>FFtRPQTRTU[[]JN+1ZL=HH$H
K
2C!#HE(E9#UVJH 	. 	+	
 	V 	T
 	T+& 	H 	% 	s 	H 	 	Jt$ 	 	j(  	gkk&--/:DDFrJ!" 	))002<<>#$ 	.% r   	site_copy
logo_styleexisting_packc
                 b   012 xs t         t               }
d}|	r2t        |	t              r"|	j	                  d|	j	                  dd            }|dz   }|	r|	j	                  d      nd }g }|	rt        |	t              rt        |	j	                  dg             }|	j	                  d      rt        d|i|	d          |	j	                  d      xs i j                         D ]  \  }}|s	t        d|i|        |	j	                  d	      rt        d|i|	d	          |	j	                  d
      xs i j                         D ]  \  }}|s	t        d|i|        i dt               d|dt        dt        d|d|
dt        j	                  i       j	                  dd      ddt        j	                  i       j	                  d      ddt        j                  j                         j                         dd di d	d d
i di d|dg d}dt        t               z   2h d}|j	                  dg       }g }|r@t        |t
              r0|D ]*  }|j	                  dd      }||v s|j#                  |       , nh|D ]c  }||v s|j%                  dd       j'                         }||   }t        |t              r|j	                  d!|      }|j#                  ||dd"       e 2t        |      z  2d002fd#}d }d}|	r:|	j	                  d      r)|	d   j	                  d$      }|	d   j	                  d%d      }	 t)         |||dz   &      }||d<   d|d'|d   |d$   <    |d(| d)|d$    d*       |	r|	j	                  di       ni 1 1fd1} t5        d2      5 }!|D ci c]  }|!j7                  | |      | }"}t9        |"      D ]t  }#|#j;                         \  }}$d3|$v r3|d-   j#                  d4| |$d3   t3               d.        |d5| d6       M|$|d   |<   d7|d8|d   |$d$   <    |d5| d9|$d$    d*       v 	 d d d        d }%d}&|	r:|	j	                  d	      r)|	d	   j	                  d$      }%|	d	   j	                  d%d      }&	 t=         ||%|&dz   &      }'|'|d	<   d	|'d:   d'|d   |'d$   <    |d;|'d:    d)|'d$    d*       |	r|	j	                  d
i       ni }(t         j                         D ]  \  })}*|(j	                  |)      }+|+r|+j	                  d$      nd },|+r|+j	                  d%d      nd}-	 t?        |) |,|-dz   &      }.|.|d
   |)<   d>|)d?|d   |.d$   <    |d@|*d    d9|.d$    d*        |d-   sdDndE|dF<   t        j                  j                         j                         |dG<   t        |d
         }/|d   d ut        |d         t        |      |d	   d u|/t        t               |d   rdndt        |d         z   |d	   rdndz   |/z   t        |d-         dH|dI<   |S # t*        $ rf}t,        j/                  d+ d,|        |d-   j#                  dt1        |      t3               d.        |d/t1        |      d d0         Y d }~(d }~ww xY wc c}w # 1 sw Y   gxY w# t*        $ rf}t,        j/                  d< d,|        |d-   j#                  d	t1        |      t3               d.        |d=t1        |      d d0         Y d }~Rd }~ww xY w# t*        $ rr}t,        j/                  d@|) dA d,|        |d-   j#                  dB|) t1        |      t3               d.        |d@|*d    dCt1        |      d d0         Y d }~d }~ww xY w)JNr   pack_versionversionr   pack_idrm   r   iconsr  
essentialsschema_versionr   replaces_pack_idr   r   r?   r   r   r   r@   r   r   asset_index
generating)r4   errorsr   >   r  r  r
  r  r  r  r	  r  r  r   r  r  r  r  r  sectionsr   r*   r   r   title)r   r<  r  c                 J    dz  t        z  dz        }r
 ||        y y )Nr   d   )int)msgpctcurrent_stepprogress_callbacktotal_stepss     r   _reportz,generate_full_graphics_pack.<locals>._report@  s3    <+-45c3' r   rl   r   r   r   )r   r   zLogo generated (z	 style) []zLogo generation failed for z: r:  )asseterrorerror_idzLogo generation failed: r>  c                    | j                  dd      }| j                  d|      }| j                  dd      }
j                  |i       }|j                  d      }|j                  dd      }	 |t        |||	||dz   	
      fS # t        $ r7}t        j	                  d
| d	 d|        |dt        |      ifcY d }~S d }~ww xY w)Nr   r*   r<  r  rl   r   r   r   rF  zIcon generation failed for z (z): rI  )r   r  	Exceptionr   rI  r9   )secsec_type	sec_titler   	prev_iconprev_idprev_reverv   r   existing_iconsr   rx   rw   s           r   	_gen_iconz.generate_full_graphics_pack.<locals>._gen_iconZ  s    7762&GGGX.	GGFB'	"&&x4	--
+==Q/	/2E49iPV")HqL    	/LL6xj6(#aSQRgs1v...	/s   .B 	C,C=CC)max_workersrI  icon_z
Icon for 'z' failedr  )r   r  z' generated [r   zSeparator generated (z Separator generation failed for zSeparator generation failed: r'  )r   r%  zEssential 'z' generation failed for 
essential_z
' failed: completepartialr4   completed_at)logo_generatedicons_generatedicons_totalseparator_generatedessentials_generatedessentials_totaltotal_assetsr:  r  ) r   r   r   ro   r   listru   itemsr!   SCHEMA_VERSIONr   r   rp   rq   rr   lenr)  rs   r   r<  r   rL  r   rI  r9   r#   r   submitr   resultr$  r,  )3rv   rw   rx   r-  r   r.  r  r   rC  r/  r   prev_versionr1  prev_pack_idrm   rN  	icon_dataess_typeess_datari   ICON_ELIGIBLEr;  icon_sectionsrM  r   r<  r   rE  prev_logo_idprev_logo_revr   rS  rU  executorfuturesfuturerh  prev_sep_idprev_sep_revr  existing_essentialsess_keyess_metaprev_essprev_ess_idprev_ess_rev
ess_resultr`  rB  rT  rD  s3   ``` `  ``                                       @@@r   generate_full_graphics_packr~    s"	    "]E":ud;JLM48$((9J9J9VW9XY!#L3@=$$Y/dLGM48}((B78V$%y'&:M&<QR$1$5$5g$>$D"#K#K#M 	KHi)9g*>	J	K [)%y'&:M+<VW#0#4#4\#B#Hb"O"O"Q 	JHh)9g*>I	J$& 	. 	.	
 	L 	j 	FJJub)--dH= 	 	fjj+//> 	& 	))002<<> 	 	 	T 	b  	r!" 	7#$ 'D, #o..KCM }}Z,HMJx. 	*Cwwvr*H=($$S)	*
  	PCm#C-335#C.gt,#KK7E$$cE2%NO	P 3}%%KL( LM**62$V,00<%f-11*a@	;Zj%/;mVWFWYV9?*0U]D,-":,iZ8H7IKL 8E]&&w3"N/ /  
	* 
ShCPQC8??9c2C7QQ"7+ 	SF%}}Hf& X%%%z0BVT[_j|j~&  A*XJh78*0Wh'CIV^:_]#F:$67*XJmF:<N;OqQR	S
S KL**;7#K044Z@$[155j!D	@&z5$QVX^9D|^_O_a	%[>IT]^eTf5g]Ij12'	'(:';9YzEZD[[\]^ BO-++L"=TV,224 N&**732:hll:.6>x||J2A	N+UD%"-q8HJ +5Dw'CNbi:jD
: 67k(6"2!3=JAW@XXYZ[N" (,H~Z9DN#,,335??ADtL12v,d2tG}-=)#K0< 40"6lSg5GGPTU`Pa1ghi  mA  Ad8n%	DM Ki  ;26("QC@AXQM_Mabc*3q6$3<.9::;0 R
S 
S0  @7xr!EFXc!fRdRfgh/At~>??@$  	NLL;wi/GxrRSQTUVN!!j	,BSQRVasau"vwk(6"2!3:c!fTcl^LMM	Nsl   ;X= +Z40Z/
BZ4A[ A\3=	Z,AZ''Z,/Z44Z>	\0
A\++\03	^.<A'^))^.
asset_typec                    d }d }	d}
|r| dk(  r|j                  d      }n| dk(  r2|j                  di       j                  |j                  dd            }nM| dk(  r|j                  d      }n6| dk(  r1|j                  d	i       j                  |j                  d
d            }|r#|j                  d      }	|j                  dd      }
|j                  dd      }|j                  dd      }| dk(  r*|j                  dd      }t        |||||||	|
dz   ||
      S | dk(  rP|j                  dd      }|j                  d|      }|j                  dd      }t        |||||||||	|
dz   ||      S | dk(  r*|j                  dd      }t        |||||||	|
dz   ||
      S | dk(  r*|j                  d
d      }t	        |||||||	|
dz   ||
      S t        d|        )Nr   r   r  r4  r   r*   r  r'  r5  r%  rl   r   r   r   r   rG   r   )r   r   r   r   r   r   r   r  r  rc   zUnknown asset type: )r   r   r  r$  r,  r   )r  rv   rw   rx   r   r   r/  kwargs
prev_assetrQ  rR  r   r   r   r   r   r   r  r%  s                      r   regenerate_assetr    s=    JGH&**62J6!&**7B7;;FJJ~WY<Z[J;&&**;7J;&&**<<@@L\^`AabJ nnZ0G!~~j!4HJJ3Mzz"4b9V

7K0ZeUF/6A+8K[] 	] 
v	zz.*=

?LAJJ{B/	$ZlM[dfkms7>TU3@Sce 	e 
{	" **%6?!*eT?ESY4;hQRl0=P`b 	b 
{	"$4i@!.*eT5RX4;hQRl0=P`b 	b /
|<==r   graphics_packc                    | sddiS | j                  d      }| j                  d      }| j                  di       }| j                  dg       }i ddd| j                  dd	      d
| j                  d
| j                  dd            d| j                  dd      d| j                  dd	      d| j                  dd      d| j                  dd	      d| j                  dd	      d| j                  dd	      d| j                  dd	      d|d ud|r|j                  dd	      nd	d|r|j                  dd	      nd	d|r|j                  dd	      nd	d|r|j                  dd      ndd|r|j                  d d	      nd	d!t        | j                  d"i             i d#t        | j                  d"i       j                               d$| j                  d"i       j	                         D ci c]  \  }}||j                  dd	       c}}d%|d ud&|r|j                  dd	      nd	d'|r|j                  dd	      nd	d(|r|j                  dd	      nd	d)|r|j                  dd      ndd*|r|j                  d d	      nd	d|j	                         D ci c]M  \  }}||j                  d+|      |j                  dd	      |j                  dd      |j                  d d	      d,O c}}d-t        |      d.t        t
              d/t        |      d0| j                  d1i       j                  d0d      d2| j                  d2i       d3| j                  d3g       d1| j                  d1i       S c c}}w c c}}w )4Nhas_packFr   r  r5  rm   Tr3  r*   r1  r2  r   r6  r   r4   r   r   r   r   r   has_logologo_asset_idrl   r.  r   logo_style_idr   logo_revisionr   r   logo_urlr   
icon_countr4  ro  icon_asset_idshas_separatorseparator_asset_idr  separator_style_idseparator_revisionseparator_urlr   )r@   rl   r   r   essentials_countra  history_countrb  r  r8  r:  )r   rf  rc  r   rd  r)  )r  r   sepr5  rm   kvs          r   get_graphics_pack_summaryr    sq   E""V$D


K
(C""<4J	2.G"D"=$$Y3" 	)).-:K:KIWX:YZ" 	-++,<a@	"
 	-++,<bA" 	-##Hi8" 	))."=" 	M%%j"5" 	""7B/" 	m''b9" 	D$" 	T*b1r" 	tdhhw+" 	T*b1r" 	D*a0a"  	4DHHUB'R!"" 	c-++GR89#"$ 	m//<AACD%"& 	@Q@QRY[]@^@d@d@fg11aeeJ33g'"( 	D)"* 	cggj"5"+", 	33777B/B-". 	cggj"5"/"0 	cggj!41"2 	s+3"4 	  hr  hx  hx  hz  {  `d  `a  cdq155#;z[]I^lmlqlqr|~  mA  JK  JO  JO  PU  WY  JZ  [  [  {5"6 	C
O7"8 	C09": 	W;"< 	))'26::>1M="> 	}((;?"@ 	-##Hb1A"B 	""7B/C" "& h {s   /M8AM>c                 *   g }| s|S | j                  d      }|r"|j                  d      r|j                  |       | j                  d      xs i j                         D ]+  \  }}|s	|j                  d      s|j                  |       - | j                  d      }|r"|j                  d      r|j                  |       | j                  d      xs i j                         D ]+  \  }}|s	|j                  d      s|j                  |       - |S )Nr   r   r4  r  r5  )r   rs   rd  )r  assetsr   rN  rk  r  rl  rm  s           r   flatten_pack_assetsr    s    FV$Dd - 1 1' : @bGGI %)u-MM)$% 

K
(C
swwu~c,00>D"KKM $(U+MM(#$ Mr   rl   c                 (   | r|sy | j                  di       j                  d      |k(  r| d   S | j                  d      xs i j                         D ]   \  }}|s	|j                  d      |k(  s|c S  | j                  di       j                  d      |k(  r| d   S | j                  d      xs i j                         D ]   \  }}|s	|j                  d      |k(  s|c S  | j                  dg       D ]  }|j                  d      |k(  s|c S  y )Nr   rl   r4  r  r5  rm   )r   rd  )r  rl   rN  rk  rl  rm  	hist_items          r   resolve_asset_by_idr  $  s'   $((4@V$$ - 1 1' : @bGGI )z2h> b)--j9XE[)),00>D"KKM (Z0H<O #&&y"5 	==$0 r   r   )r*   r*   )rG   Nr*   Nr   r*   r*   )r*   Nr*   Nr   r*   r*   )r  Nr*   Nr   r*   r*   )Nr*   Nr   r*   r*   )rG   r  NNN)rU   N)>__doc__r   re  r   r   r   jsonloggingr   rp   pathlibr   concurrent.futuresr   r   tenacityr   r   r	   r
   googler   google.genair   	getLogger__name__r   r9   r   r.   r!   r#   r1   BaseExceptionboolr=   r   r   r!  r   r   r)  ro   ru   r   r   r   r   r   r   r   r?  r   r  r$  r,  r~  r  r  rc  r  r  r    r   r   <module>r     s  $  	        ? T T  			8	$ d
  03 01C 1	= 	T 	 %&  D  R  k  d  k+<  S  `  @  ]  e  u5 B ) $!	 *"	 -!	#
.  FV  ). ! JN  ").  Kc "%* $ IN  %* $nX $%* _u $%S}@%D %d %t %$ s # $ 2s t 5 D S 
1 1# 1 	A		QA3	7
0
1	P3 Ps Pe PPD3 s TW * !VVV V 	V
 V V V V V V 
V~ !ccc c 	c
 c c c c c c c c 
cT "!YYY Y 	Y
 Y Y Y Y Y Y 
YB !=== = 	=
 = = = = = = 
=L "!vvv v 	v
 v v v v v 
v~ *6>6>6> 6> 	6>
 6> 6> 6> 
6>r+T +d +\t  &t s t r   