
    ɢiT.                         d dl Z d dlZd dlmZmZ  ej
                  e      Z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ZdZ	d Z
d"dededefdZ	 	 d#dededededed edefd!Zy)$    N)call_llmcall_llm_textzCost EstimatorzRInteractive calculator that helps visitors estimate costs for products or services
calculator)labeldescriptioniconzSelf-Assessment QuizzFInteractive quiz that evaluates visitor needs and recommends solutionszclipboard-checkzProduct Comparatorz3Side-by-side comparison tool for evaluating optionscolumnszROI Calculatorz:Return on investment calculator showing financial benefitsztrending-upzProduct ConfiguratorzMBuild-your-own tool that lets visitors customize a product or service packagesliderszInteractive Checklistz=Step-by-step guided checklist for planning or decision-makingzcheck-square)	estimator
assessment
comparisonroi_calculatorconfigurator	checklistu  You are an expert interactive widget designer and developer. You create high-value, niche-specific interactive tools that engage visitors, capture leads, and demonstrate expertise. Your widgets are professional, visually polished, and provide genuine value to the user.

You generate complete, self-contained HTML widgets with embedded CSS and JavaScript. The widgets must:
1. Be fully self-contained (no external dependencies except Font Awesome CDN for icons)
2. Use modern, professional design with smooth animations and dimensional depth (layered shadows, inner highlights, subtle gradients)
3. Be responsive and work on all screen sizes
4. Include tooltips on interactive elements
5. Calculate real, useful results based on actual industry data
6. Use EXACTLY the brand colors provided — match the site's color palette precisely (primary, secondary, accent). Use a LIGHT background theme (#ffffff / #f8fafc / #f1f5f9) with brand-colored accents, NOT a dark theme, unless dark theme is explicitly requested. Cards should have layered box-shadows with inset highlights for 3D depth.
7. Include proper form validation and user feedback
8. Have a polished results display with breakdowns and visualizations
9. Use CSS variables for colors: --widget-primary, --widget-secondary, --widget-accent set to the exact hex values provided
10. Buttons should use gradient backgrounds from primary to secondary color with inner highlight shadows for a dimensional feelc                      t         S N)AUGMENT_TYPES     3/sites/domain-asset-master/app/services/augments.pyget_augment_typesr   7   s    r   niche
niche_datareturnc                    d}|rNd|j                  d|        d|j                  dd       d|j                  dd       d|j                  d	d       }d
|  d| dt        j                  t        t        j                                      d}	 t        |t              }t        j                  |      }t        |t              r|S t        |t              rYdD ]!  }||v st        ||   t              s||   c S  t        |j                               }|rt        |d   t              r|d   S g S # t        j                  t        f$ r#}t        j                  d|        Y d }~g S d }~ww xY w)N z
Niche details:
- Name: namez
- Description: r   
- Monetization: monetization_model
- Target Audience: target_audiencezFor a business in the "zj" niche, suggest 3-5 high-value interactive widgets that would engage visitors and demonstrate expertise.
zA

For each widget, provide ALL of these fields:
- "type": one of aG  
- "title": specific, compelling title for this widget (e.g., "Luxury Pool Cost Estimator" not just "Cost Estimator")
- "description": 2-3 sentences explaining what it does and why it's valuable for visitors
- "value_proposition": one sentence on how this widget converts visitors into leads/customers
- "target_audience": who specifically benefits from this widget (e.g., "Homeowners planning a kitchen remodel", "Small business owners evaluating CRM options")
- "benefit_level": rate 1-5 how beneficial this is to the business (5 = highest conversion impact)
- "benefit_reason": one sentence explaining WHY this is beneficial and to whom (e.g., "Highest conversion tool because price-conscious buyers need cost clarity before committing")
- "category": one of ["lead_capture", "trust_builder", "decision_aid", "engagement", "education"]

Return JSON array sorted by benefit_level descending (most beneficial first):
[
  {"type": "...", "title": "...", "description": "...", "value_proposition": "...", "target_audience": "...", "benefit_level": 5, "benefit_reason": "...", "category": "..."}
])suggestionswidgetsitemsresultsaugmentsr   zAugment suggestion failed: )getjsondumpslistr   keysr   SYSTEM_PROMPTloads
isinstancedictvaluesJSONDecodeError	Exceptionloggererror)	r   r   
niche_descpromptresponseparsedkeyvalses	            r   suggest_augmentsr<   ;   s~   J			&' (}b12 3 4b9: ;NN#4b9:>
 ) 0  **T-"4"4"6789 :	F$8FM2H%fd#Mfd#Q '&=ZsT%B!#;&' (D
47D1Aw I   ), 821#677I8s0   6D0 D0 D0 3D0 :3D0 0E,	E''E,augment_typetitle
brand_datacustom_instructionsc                    d}d}|rd}|j                  dg       }|j                  dd      }	|r#|	t        |      k  r||	   j                  dd      }d|j                  dd	       d
|j                  dd       d|j                  dd       d| }d}
|r;d|j                  dd       d|j                  dd       d|j                  dd       }
t        j                  | i       }|j                  d|       }|r|j                  dd	      nd	}|r|j                  dd      nd}|r|j                  dd      nd}dj                  g d| d| d| d| d|
 d|rd| nd d| d| d | d!| d"| d#| d$| d%| d&|j	                          d'| d(k(  rd)nd d| d*k(  rd+nd d| d,k(  rd-nd d| d.k(  rd/nd d| d0k(  rd1nd d| d2k(  rd3nd d4      }d}d }t        d5      D ]0  }	 t        |t        d67      }|j                         }|j                  d8      r|t        d8      d  j                         }|j                  d9      r|d5d  j                         }|j                  d9      r|d d: j                         }|j                  d;      sB|j                  d<      s1|j                  d;      }|d=k(  r|j                  d<      }|dk\  r||d  }|rt        |      d>k\  r|} n1d?t        |       d@}t        j                  dA|dBz    dC| dD       3 |rt        |      d>k  rt!        dF|       | |||||r|j                  dd	      nd	|r|j                  dd      nd|r|j                  dd      nddGdH}|||| dI| | dJS # t        $ r5}t        |      }t        j                  dA|dBz    dE| dD       Y d }~d }~ww xY w)KNr   Businessoptionsrecommendedr   r   z
Brand Colors:
- Primary: color_primaryz#6366f1z
- Secondary: color_secondaryz#8b5cf6z
- Accent: color_accentz#22d3eez
Brand Name: z
Niche details:
- Description: r   r    r!   r   r   r   z3Create a complete, self-contained HTML widget for "z" - a z
 for the "z	" niche.

zAdditional instructions: uq   

CRITICAL COLOR REQUIREMENTS — the widget will be embedded in a site that uses these EXACT colors:
- Primary: z@  (use for headings, primary buttons, key accents)
- Secondary: zH  (use for secondary elements, gradients paired with primary)
- Accent: a}    (use for highlights, links, call-outs)
- Background: #ffffff (main) / #f8fafc (sections) / #f1f5f9 (alternating)
- Text: #111827 (headings) / #374151 (body) / #6b7280 (muted)
- Cards: white background with layered box-shadows (e.g. box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px -2px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.8))
- Buttons: background gradient from z to u  , white text, with box-shadow including inset highlight
DO NOT use a dark/black background. This is a LIGHT-themed widget.

REQUIREMENTS:
1. Generate a COMPLETE standalone HTML document with embedded <style> and <script> tags
2. Use the EXACT brand colors above — light background, brand-colored accents
3. Include Font Awesome CDN for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
4. Make it fully responsive
5. Include realistic industry-accurate data, pricing, and calculations
6. Add smooth animations and transitions with dimensional depth (layered shadows, inner glows)
7. Include tooltips on key elements using title attributes
8. The widget should provide REAL VALUE - actual useful calculations/results
9. Include a results section that shows detailed breakdowns
10. Add a subtle branded footer with the brand name
11. Set CSS variables: --widget-primary: z; --widget-secondary: z; --widget-accent: z;
12. Maximum width of 800px, centered on page
13. Alternating table/list rows should use #f8fafc vs #ffffff for clear visual separation

WIDGET TYPE SPECIFICS FOR z:
r   zE- Multiple form sections with dropdowns, checkboxes, and range inputsr   zT- Multiple form sections with select dropdowns, checkbox groups for features/add-onsr   z;- Series of multiple-choice questions with weighted scoringr   z3- Side-by-side cards with feature comparison matrixr   zB- Input fields for costs, revenue, timeframe with visual ROI chartr   z;- Expandable sections with checkboxes and progress trackingaK  
- Show a detailed results section when the user submits/completes the widget
- Results should include specific numbers, recommendations, and next steps
- Include a call-to-action in the results section

Return ONLY the complete HTML document, nothing else. No markdown code fences. Start with <!DOCTYPE html> and end with </html>.   i @  )
max_tokensz```htmlz```z	<!DOCTYPEz<htmld   z#AI returned insufficient HTML (got z chars)zAugment generate attempt    z/3: z, retrying...z
/3 error: zMAI returned empty or insufficient HTML content after 3 attempts. Last error: )primary	secondaryaccent)type
type_labelr>   r   
brand_namebrand_colorsz for )html_contentconfigr>   r   r=   )r'   lenr   joinupperranger   r,   strip
startswithendswithfindr3   warningr2   str
ValueError)r=   r>   r   r?   r   r@   rU   rT   optsrecr5   	type_inforS   primary_hexsecondary_hex
accent_hexr6   rV   
last_errorattemptr7   	candidate	doc_startr;   rW   s                            r   generate_augment_htmlrm   h   s3    LJ
~~i,nn]A.C#d)Ocvz:JNN?I67 8nn.	:; <>>.)4
5 6L J}b12 3NN#4b9: ; 4b9:	>
 !!,3Iw5J@J*..)<PYKDNJNN#4i@T]M>H	:iJ)C )CD )CUG )C6 )CR\Q] )C]g )Chmgn )C o )C)C)C)C)C 7J012r R)CS)C =)C)C _)C)C ,)C%)C &1M)C 26)C 7D_)CE*)C4 +65)C4 7M5)C4 N[O5)C4 \o5)C4 pznz5)C4{5)C< &++-.=)C</=)C> MY\gLgHmo p?)C>q?)C@ \hky[yW  @B  CA)C@CA)CB COR^B^>df gC)CBhC)CD ;G,:V6\^ _E)CD`E)CF JVYiIiEoq rG)CFsG)CH COR]B]>ce fI)CHg@I)CFV LJ8 g	g$V]uMH (I##I.%c)no6<<>	##E*%abM//1	!!%(%crN002	''4Y=Q=QRY=Z%NN;7	? )w 7I> ))* 5IS^s2(B3y>BRRYZ
!:719+T*Ubcd/g8 3|,s2hishtuvv   EOz~~oyAU^IS(99EYbCMjnn^Y?S\
F %$U5'2$ )  	gQJNN6wqykJ<Wdeff	gs   C<N+.N++	O)4*O$$O)r   )NNr   )r(   loggingapp.services.llmr   r   	getLogger__name__r3   r   r,   r   ra   r/   r*   r<   rm   r   r   r   <module>rr      s      4			8	$ "k (_! &L "S (f )V5BC*C *T *T *\ GK57@ @C @ @&*@?C@/2@<@@r   