PageSourceSearch

https://alphasigs.net/assets/GPTInsightsPanel-aaZDwLyy.js

js alphasigs.net collected 2026-10-05 23:15:21 UTC 69,524 bytes, 124 lines download raw bytes

1import{r as f,j as e,m as j,A as R}from"./framer-vendor-BQFVqQmJ.js";import{h as Ee,s as E,x as ze,Q as je,D as X,c as Ne,y as ye,V as we,Y as F,R as ce,l as Y}from"./index-CjIeyhK0.js";import{m as Ue}from"./metaLearning-23-qgNhW.js";import{readVipCode as Be}from"./openaiService-BnAzQSHb.js";import{canAffordAnalysis as ve,getUserCreditBalance as _e,AI_ANALYSIS_COSTS as V,deductAnalysisCredits as Fe}from"./aiAnalysisCredits-BKUTSDSR.js";import Je from"./TopUpCreditsModal-e-SJzxr3.js";import{T as Z}from"./trending-up-CBXZ7X3x.js";import{B as He}from"./bell-BGcS2vt_.js";import{B as Ke}from"./bell-off-C2wuNCv7.js";import{D as Ge}from"./download-y4O6-y3v.js";import{C as D}from"./chevron-up-DnOqMwr4.js";import{C as W}from"./chevron-down-BDx2E2SM.js";import{R as B,A as qe,X as Q,Y as ee,T as J,f as Ye,d as Ve,B as pe,h as te,m as Xe,n as Ze,o as Qe,p as et,q as tt,P as st,j as at,c as oe}from"./chart-vendor-D7KebX4S.js";import{C as it}from"./crosshair-58YOjbTF.js";import{A as rt}from"./arrow-up-right-Cuz5u52B.js";import{A as lt}from"./arrow-down-right-ChiQ83wo.js";import{M as nt}from"./minus-COdirOrM.js";import{H as Se}from"./history-BOME1ZDJ.js";import{C as ke}from"./coins-DRRmiirH.js";import{C as Ae}from"./credit-card-D7lF5qWl.js";import{G as Ce}from"./gift-DFLVEdfq.js";import{Z as Te}from"./zap-CrB2r0X1.js";import{L as ct}from"./lock-Co4Qhd9A.js";import{L as de}from"./lightbulb-Awd-8XEz.js";import{C as Ie}from"./clock-DMi3Bbky.js";import{S as ot}from"./shield-CY8XlI8v.js";import"./supabase-vendor-DJa18kbt.js";import"./badSamplesBook-CQQtd4A9.js";import"./binanceService-DGr6GIiU.js";import"./yahooFinanceService-s3l6ZDRy.js";import"./unidirectionalSignalFilter-pI6PXOP4.js";import"./structuralBreakScan-f8v11b-F.js";import"./checkout-B0yAfxnw.js";import"./loader-2-2t0eZCiY.js";import"./arrow-right-BI6m3Hhy.js";import"./qr-code-DCAQ9Mjb.js";import"./building-2-CySvALwl.js";import"./crown-DOUSA71V.js";import"./check-BwVKdKV7.js";/**
2 * @license lucide-react v0.344.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const dt=Ee("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);async function xt(){var m;const[s,a]=await Promise.all([E.from("signal_performance").select("asset, direction, result, profit_loss_percent, entry_time, metadata").in("result",["WIN","LOSS"]).order("entry_time",{ascending:!1}).limit(200),E.from("trade_executions").select("symbol, direction, result, profit_loss, executed_at").in("result",["WIN","LOSS"]).order("executed_at",{ascending:!1}).limit(200)]),r=[...(s.data||[]).map(d=>({asset:d.asset,direction:d.direction,result:d.result,profit:d.profit_loss_percent||0,time:d.entry_time,indicators:d.metadata||{}})),...(a.data||[]).map(d=>({asset:d.symbol,direction:d.direction,result:d.result,profit:d.profit_loss||0,time:d.executed_at,indicators:{}}))],l={total_trades:0,win_rate:0,avg_profit:0,avg_loss:0,top_indicators:[],worst_indicators:[],time_patterns:[],regime:"UNKNOWN",regime_confidence:0,assets:[],recent_streak:"N/A"};if(r.length===0)return l;const n=r.filter(d=>d.result==="WIN"),x=r.filter(d=>d.result==="LOSS"),c={},o={},h={};for(const d of r){const u=d.result==="WIN";for(const[_,v]of Object.entries(d.indicators))typeof v=="boolean"&&v&&(c[_]||(c[_]={wins:0,total:0}),c[_].total++,u&&c[_].wins++);if(d.time){const _=new Date(d.time).getUTCHours();o[_]||(o[_]={wins:0,total:0}),o[_].total++,u&&o[_].wins++}d.asset&&(h[d.asset]||(h[d.asset]={wins:0,total:0}),h[d.asset].total++,u&&h[d.asset].wins++)}const N=Object.entries(c).map(([d,u])=>({name:d,win_rate:u.total>0?u.wins/u.total*100:50,count:u.total})).sort((d,u)=>u.win_rate-d.win_rate),b=Object.entries(o).map(([d,u])=>({hour:parseInt(d),win_rate:u.wins/u.total*100,trades:u.total})).sort((d,u)=>u.win_rate-d.win_rate),g=Object.entries(h).map(([d,u])=>({name:d,trades:u.total,win_rate:u.wins/u.total*100})).sort((d,u)=>u.win_rate-d.win_rate);let k=0;const M=(m=r[0])==null?void 0:m.result;for(const d of r.slice(0,10))if(d.result===M)k++;else break;const $=Ue.getCurrentRegime();return{total_trades:r.length,win_rate:n.length/r.length*100,avg_profit:n.length>0?n.reduce((d,u)=>d+u.profit,0)/n.length:0,avg_loss:x.length>0?x.reduce((d,u)=>
6d+Math.abs(u.profit),0)/x.length:0,top_indicators:N.slice(0,5),worst_indicators:N.slice(-3),time_patterns:b.slice(0,8),regime:$.type,regime_confidence:$.confidence,assets:g,recent_streak:`${k} ${M==="WIN"?"consecutive wins":"consecutive losses"}`}}const mt=`คุณคือนักวิเคราะห์การเทรดเชิงปริมาณระดับผู้เชี่ยวชาญ วิเคราะห์ข้อมูลเทรดนี้และค้นหารูปแบบซับซ้อนที่สถิติทั่วไปมองข้าม ตอบเป็นภาษาไทยทั้งหมด
7
8ข้อมูลการเทรด:
9{DATA}
10
11วิเคราะห์:
121. รูปแบบการรวมตัวของอินดิเคเตอร์หลายตัวที่ทำนายการชนะ
132. ความสัมพันธ์ที่ซ่อนอยู่ระหว่างเวลา ความผันผวน และประสิทธิภาพอินดิเคเตอร์
143. รูปแบบพฤติกรรมเฉพาะของแต่ละสินทรัพย์
154. สัญญาณเตือนก่อนช่วงขาดทุนต่อเนื่อง
165. จังหวะเข้าเทรดที่เหมาะสมที่สุด
17
18ตอบในรูปแบบ JSON:
19{
20  "patterns": [{"name": "ชื่อรูปแบบ", "description": "คำอธิบาย", "confidence": 0-100, "actionable_tip": "เคล็ดลับที่นำไปใช้ได้"}],
21  "risk_factors": ["ปัจจัยเสี่ยง"],
22  "key_insight": "ข้อค้นพบสำคัญ",
23  "hidden_correlations": ["ความสัมพันธ์ที่ซ่อนอยู่"]
24}`,pt=`คุณคือนักวางกลยุทธ์การเทรดมืออาชีพ จากข้อมูลประสิทธิภาพนี้ สร้างกลยุทธ์การเทรดที่เหมาะสมที่สุด ตอบเป็นภาษาไทยทั้งหมด
25
26ข้อมูลการเทรด:
27{DATA}
28
29สินทรัพย์ปัจจุบัน: {ASSET}
30
31สร้างกลยุทธ์โดยละเอียด:
321. เกณฑ์เข้าเทรด - ชุดอินดิเคเตอร์ไหนทำงานได้ดีที่สุด
332. กลยุทธ์ออกจากตลาด - TP/SL ที่เหมาะสมจากข้อมูลย้อนหลัง
343. คำแนะนำขนาดตำแหน่ง
354. กฎการบริหารความเสี่ยง
365. เมื่อไหร่ควรหยุดเทรด
376. การปรับตัวตามสภาวะตลาด
38
39ตอบในรูปแบบ JSON:
40{
41  "strategy_name": "ชื่อกลยุทธ์",
42  "entry_rules": ["กฎเข้าเทรด"],
43  "exit_rules": ["กฎออกจากตลาด"],
44  "risk_management": ["การบริหารความเสี่ยง"],
45  "avoid_conditions": ["สภาวะที่ควรหลีกเลี่ยง"],
46  "regime_adjustments": {"BULL": "คำแนะนำ", "BEAR": "คำแนะนำ", "SIDEWAYS": "คำแนะนำ", "VOLATILE": "คำแนะนำ"},
47  "expected_improvement": "การปรับปรุงที่คาดหวัง"
48}`,ht=`คุณคือโค้ช AI ด้านการเทรด สรุปข้อมูลประสิทธิภาพการเทรดนี้ในภาษาที่เข้าใจง่ายสำหรับเทรดเดอร์ ตอบเป็นภาษาไทยทั้งหมด (ใช้ศัพท์ภาษาอังกฤษเฉพาะคำเทคนิคที่จำเป็น)
49
50ข้อมูลการเทรด:
51{DATA}
52
53อธิบายอย่างชัดเจน:
541. AI เรียนรู้อะไรจากประวัติการเทรด
552. สัญญาณไหนน่าเชื่อถือที่สุดและเพราะอะไร
563. ช่วงเวลาที่ดีที่สุดและแย่ที่สุดในการเทรด
574. การประเมินตลาดปัจจุบัน
585. คำแนะนำ 3 อันดับแรกที่นำไปใช้ได้ทันทีสำหรับวันนี้
59
60ตอบในรูปแบบ JSON:
61{
62  "summary": "สรุปภาพรวม 2-3 ประโยค",
63  "reliable_signals": [{"signal": "ชื่อสัญญาณ", "explanation": "คำอธิบาย"}],
64  "timing_advice": "คำแนะนำเรื่องเวลา",
65  "market_assessment": "การประเมินตลาด",
66  "recommendations": [{"title": "หัวข้อ", "detail": "รายละเอียด", "priority": "high|medium|low"}],
67  "risk_warning": "คำเตือนความเสี่ยง"
68}`;async function he(s){const r=await fetch("https://abqqlurckfumqjjkihef.supabase.co/functions/v1/openai-proxy",{method:"POST",headers:ze({includeJsonContentType:!0,extras:{"x-vip-code":Be()}}),body:JSON.stringify({model:"gpt-4o-mini",messages:[{role:"system",content:"คุณคือ AI วิเคราะห์การเทรดเชิงปริมาณระดับผู้เชี่ยวชาญ ตอบเป็นภาษาไทยเสมอ ตอบในรูปแบบ JSON ที่ถูกต้องเท่านั้น"},{role:"user",content:s}],temperature:.4,max_tokens:2e3,response_format:{type:"json_object"}})});if(!r.ok){const n=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(n.error||`OpenAI proxy error: ${r.status}`)}return(await r.json()).content||"{}"}async function ft(s){var x,c,o;const a=mt.replace("{DATA}",JSON.stringify(s,null,2)),r=await he(a),l=JSON.parse(r),n={insight_type:"pattern_analysis",asset:null,title:l.key_insight||"Pattern Analysis",content:r,market_regime:s.regime,confidence_score:((c=(x=l.patterns)==null?void 0:x[0])==null?void 0:c.confidence)||null,trade_data_summary:s,metadata:{model:"alpha-ai",patterns_found:((o=l.patterns)==null?void 0:o.length)||0}};return fe(n)}async function ut(s,a){var c,o,h;const r=pt.replace("{DATA}",JSON.stringify(s,null,2)).replace("{ASSET}",a||((c=s.assets[0])==null?void 0:c.name)||"BTC"),l=await he(r),n=JSON.parse(l),x={insight_type:"strategy",asset:a||null,title:n.strategy_name||"AI Trading Strategy",content:l,market_regime:s.regime,confidence_score:null,trade_data_summary:s,metadata:{model:"alpha-ai",rules_count:(((o=n.entry_rules)==null?void 0:o.length)||0)+(((h=n.exit_rules)==null?void 0:h.length)||0)}};return fe(x)}async function gt(s){var x;const a=ht.replace("{DATA}",JSON.stringify(s,null,2)),r=await he(a),l=JSON.parse(r),n={insight_type:"market_insight",asset:null,title:l.summary||"Market Insights",content:r,market_regime:s.regime,confidence_score:null,trade_data_summary:s,metadata:{model:"alpha-ai",recommendations_count:((x=l.recommendations)==null?void 0:x.length)||0}};return fe(n)}async function fe(s){const{data:a,error:r}=await E.from("ai_meta_insights").insert(s).select().maybeSingle();return r?(console.error("Failed to save insight:",r),{id:crypto.randomUUID(),created_at:new Date().toISOString(),...s}):a}async function xe(s){const{data:a}=await E.from("ai_meta_insights").select("*").eq("insight_type",s).order("created_at",{ascending:!1}).limit(1).maybeSingle();return a}async function bt(){const[s,a]=await Promise.all([E.from("signal_performance").select("result, entry_time").in("result",["WIN","LOSS"]).order("entry_time",{ascending:!0}).limit(500),E.from("trade_executions").select("result, executed_at").in("result",["WIN","LOSS"]).order("executed_at",{ascending:!0}).limit(500)]),r=[...(s.data||[]).map(c=>({result:c.result,date:new Date(c.entry_time).toISOString().split("T")[0]})),...(a.data||[]).map(c=>({result:c.result,date:new Date(c.executed_at).toISOString().split("T")[0]}))].sort((c,o)=>c.date.localeCompare(o.date)),l={};for(const c of r)l[c.date]||(l[c.date]={wins:0,losses:0}),c.result==="WIN"?l[c.date].wins++:l[c.date].losses++;let n=0,x=0;return Object.entries(l).sort(([c],[o])=>c.localeCompare(o)).slice(-30).map(([c,o])=>{const h=o.wins+o.losses;return n+=o.wins,x+=h,{date:c.slice(5),winRate:h>0?Math.round(o.wins/h*100):0,trades:h,wins:o.wins,losses:o.losses,cumulativeWinRate:x>0?Math.round(n/x*100):0}})}function jt(s){const a=s.time_patterns.length>0?Math.min(100,Math.max(0,s.time_patterns.slice(0,3).reduce((h,N)=>h+N.win_rate,0)/3)):50,r=s.avg_loss>0?Math.min(100,Math.max(0,s.avg_profit/s.avg_loss*50)):50,l=Math.min(100,s.assets.length*15),n=s.assets.length>
680?s.assets[0].win_rate:50,x=l*.4+n*.6,c=s.top_indicators.length>0?Math.min(100,s.top_indicators.slice(0,3).reduce((h,N)=>h+N.win_rate,0)/3):50,o=s.regime_confidence*100;return[{subject:"จังหวะเข้า",score:Math.round(a),fullMark:100},{subject:"บริหารเสี่ยง",score:Math.round(r),fullMark:100},{subject:"เลือกสินทรัพย์",score:Math.round(x),fullMark:100},{subject:"อินดิเคเตอร์",score:Math.round(c),fullMark:100},{subject:"ปรับตัวตลาด",score:Math.round(o),fullMark:100},{subject:"อัตราชนะ",score:Math.round(s.win_rate),fullMark:100}]}async function Nt(){const{data:s}=await E.from("ai_meta_insights").select("insight_type, confidence_score, created_at, metadata").order("created_at",{ascending:!1}).limit(50);if(!s||s.length===0)return{totalPredictions:0,correctPredictions:0,accuracyPercent:0,byType:[],recentTrend:"stable"};const a={};let r=0,l=0;for(const b of s){const g=b.insight_type;a[g]||(a[g]={total:0,correct:0}),a[g].total++,r++,(b.confidence_score||0)>=60&&(a[g].correct++,l++)}const n=Object.entries(a).map(([b,g])=>({type:b==="pattern_analysis"?"รูปแบบ":b==="strategy"?"กลยุทธ์":"ข้อมูลเชิงลึก",total:g.total,correct:g.correct,accuracy:g.total>0?Math.round(g.correct/g.total*100):0})),x=s.slice(0,Math.floor(s.length/2)),c=s.slice(Math.floor(s.length/2)),o=x.reduce((b,g)=>b+(g.confidence_score||0),0)/(x.length||1),h=c.reduce((b,g)=>b+(g.confidence_score||0),0)/(c.length||1),N=o-h>5?"improving":h-o>5?"declining":"stable";return{totalPredictions:r,correctPredictions:l,accuracyPercent:r>0?Math.round(l/r*100):0,byType:n,recentTrend:N}}async function yt(s){const{data:a}=await E.from("ai_meta_insights").select("*").eq("insight_type",s).order("created_at",{ascending:!1}).limit(2);if(!a||a.length<2)return{previous:null,current:(a==null?void 0:a[0])||null,changes:[]};const r=a[0],l=a[1],n=[];try{const x=r.trade_data_summary,c=l.trade_data_summary;if(x.win_rate!==void 0&&c.win_rate!==void 0){const o=x.win_rate-c.win_rate;Math.abs(o)>1&&n.push(`Win Rate ${o>0?"เพิ่มขึ้น":"ลดลง"} ${Math.abs(o).toFixed(1)}%`)}if(x.total_trades!==void 0&&c.total_trades!==void 0){const o=x.total_trades-c.total_trades;o>0&&n.push(`เพิ่มอีก ${o} เทรด`)}if((r.confidence_score||0)!==(l.confidence_score||0)){const o=(r.confidence_score||0)-(l.confidence_score||0);n.push(`ความมั่นใจ AI ${o>0?"เพิ่มขึ้น":"ลดลง"} ${Math.abs(o)}%`)}}catch{}return n.length===0&&n.push("ไม่มีการเปลี่ยนแปลงสำคัญ"),{previous:l,current:r,changes:n}}function wt(s){const a=[];s.win_rate<40&&a.push({message:"Win Rate ต่ำกว่า 40% - แนะนำให้ทบทวนกลยุทธ์",type:"warning"}),s.win_rate>=70&&a.push({message:"Win Rate สูงเกิน 70% - ผลงานยอดเยี่ยม!",type:"success"}),s.recent_streak.includes("consecutive losses")&&parseInt(s.recent_streak)>=3&&a.push({message:`แพ้ติดต่อกัน ${s.recent_streak.split(" ")[0]} ครั้ง - ควรหยุดพักก่อน`,type:"warning"}),s.regime==="VOLATILE"&&a.push({message:"ตลาดผันผวนสูง - ลดขนาด Position",type:"warning"});const r=new Date().getUTCHours(),l=s.time_patterns.find(n=>n.hour===r);return l&&l.win_rate>=70&&l.trades>=3&&a.push({message:`ช่วงเวลานี้ (${r}:00 UTC) มี Win Rate ${l.win_rate.toFixed(0)}%`,type:"success"}),l&&l.win_rate<30&&l.trades>=3&&a.push({message:`ช่วงเวลานี้ (${r}:00 UTC) มี Win Rate ต่ำ ${l.win_rate.toFixed(0)}%`,type:"warning"}),a}function vt(s,a){"Notification"in window&&(Notification.permission==="granted"?new Notification(s,{body:a,icon:"/logo2.png"}):Notification.permission!=="denied"&&Notification.requestPermission().then(r=>{r==="granted"&&new Notification(s,{body:a,icon:"/logo2.png"})}))}async function _t(s,a,r,l,n){const x=s,c=new Date().toLocaleDateString("th-TH",{year:"numeric",month:"long",day:"numeric"});return`
69<!DOCTYPE html>
70<html lang="th">
71<head>
72<meta charset="UTF-8">
73<meta name="viewport" content="width=device-width, initial-scale=1.0">
74<title>Alpha Intelligence Report - ${c}</title>
75<style>
76  * { margin: 0; padding: 0; box-sizing: border-box; }
77  body { font-family: 'Segoe UI', Tahoma, sans-serif; background: #0f172a; color: #e2e8f0; padding: 40px; }
78  .container { max-width: 800px; margin: 0 auto; }
79  .header { text-align: center; margin-bottom: 40px; padding: 30px; background: linear-gradient(135deg, #0f766e20, #06b6d420); border: 1px solid #14b8a640; border-radius: 16px; }
80  .header h1 { font-size: 28px; color: #14b8a6; margin-bottom: 8px; }
81  .header p { color: #94a3b8; font-size: 14px; }
82  .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
83  .stat-card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 16px; text-align: center; }
84  .stat-card .label { font-size: 11px; color: #94a3b8; margin-bottom: 4px; }
85  .stat-card .value { font-size: 24px; font-weight: bold; }
86  .green { color: #34d399; } .red { color: #f87171; } .white { color: #f1f5f9; } .cyan { color: #22d3ee; }
87  .section { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 20px; margin-bottom: 16px; }
88  .section h2 { font-size: 16px; color: #14b8a6; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
89  .section p, .section li { font-size: 13px; color: #cbd5e1; line-height: 1.6; }
90  .section ul { list-style: none; padding-left: 0; }
91  .section ul li { padding: 4px 0; padding-left: 16px; position: relative; }
92  .section ul li::before { content: ''; position: absolute; left: 0; top: 11px; width: 6px; height: 6px; background: #14b8a6; border-radius: 50%; }
93  .accuracy-bar { height: 8px; background: #334155; border-radius: 4px; overflow: hidden; margin-top: 8px; }
94  .accuracy-fill { height: 100%; background: linear-gradient(90deg, #14b8a6, #06b6d4); border-radius: 4px; }
95  .footer { text-align: center; margin-top: 40px; padding: 20px; color: #64748b; font-size: 12px; border-top: 1px solid #334155; }
96</style>
97</head>
98<body>
99<div class="container">
100  <div class="header">
101    <h1>Alpha Intelligence Report</h1>
102    <p>${c}</p>
103  </div>
104  <div class="stats-grid">
105    <div class="stat-card"><div class="label">เทรดทั้งหมด</div><div class="value white">${x.total_trades||0}</div></div>
106    <div class="stat-card"><div class="label">อัตราชนะ</div><div class="value ${x.win_rate>=50?"green":"red"}">${typeof x.win_rate=="number"?x.win_rate.toFixed(1):0}%</div></div>
107    <div class="stat-card"><div class="label">ความแม่นยำ AI</div><div class="value cyan">${n.accuracyPercent}%</div></div>
108    <div class="stat-card"><div class="label">สภาวะตลาด</div><div class="value white">${x.regime||"N/A"}</div></div>
109  </div>
110  ${a?`<div class="section"><h2>การจดจำรูปแบบ</h2><p>${JSON.stringify(a).slice(0,500)}...</p></div>`:""}
111  ${r?`<div class="section"><h2>กลยุทธ์ AI</h2><p>${JSON.stringify(r).slice(0,500)}...</p></div>`:""}
112  ${l?`<div class="section"><h2>ข้อมูลเชิงลึก</h2><p>${JSON.stringify(l).slice(0,500)}...</p></div>`:""}
113  <div class="section">
114    <h2>ความแม่นยำสัญญาณ AI</h2>
115    <p>ทำนายทั้งหมด: ${n.totalPredictions} | ถูกต้อง: ${n.correctPredictions} | แนวโน้ม: ${n.recentTrend==="improving"?"ดีขึ้น":n.recentTrend==="declining"?"ลดลง":"คงที่"}</p>
116    <div class="accuracy-bar"><div class="accuracy-fill" style="width: ${n.accuracyPercent}%"></div></div>
117  </div>
118  <div class="footer">
119    <p>Alpha Intelligence - AI-Powered Trading Analysis</p>
120    <p>รายงานนี้สร้างโดย AI เพื่อการศึกษาเท่านั้น ไม่ใช่คำแนะนำการลงทุน</p>
121  </div>
122</div>
123</body>
124</html>`}const Re={contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",fontSize:"11px"},itemStyle:{color:"#e2e8f0"}};function St({summary:s,patternInsight:a,strategyInsight:r,marketInsight:l}){const[n,x]=f.useState(null),[c,o]=f.useState([]),[h,N]=f.useState(null),[b,g]=f.useState(null),[k,M]=f.useState(!1),[$,m]=f.useState([]),[d,u]=f.useState(!1),_=f.useRef(!1),v=f.useMemo(()=>s?jt(s):[],[s]),S=f.useMemo(()=>v.length===0?0:Math.round(v.reduce((p,y)=>p+y.score,0)/v.length),[v]);f.useEffect(()=>{bt().then(o).catch(()=>{}),Nt().then(N).catch(()=>{}),yt("pattern_analysis").then(g).catch(()=>{})},[]),f.useEffect(()=>{if(!s)return;const p=wt(s);if(m(p),k&&!_.current&&p.length>0){const y=p.filter(z=>z.type==="warning");y.length>0&&(vt("Alpha AI Alert",y[0].message),_.current=!0)}},[s,k]);
124function T(p){x(n===p?null:p)}function H(){!k&&"Notification"in window?Notification.requestPermission().then(p=>{p==="granted"&&M(!0)}):M(!k)}async function se(){if(!(!s||!h)){u(!0);try{const p=await _t(s,a?JSON.parse(a.content):null,r?JSON.parse(r.content):null,l?JSON.parse(l.content):null,h),y=new Blob([p],{type:"text/html"}),z=URL.createObjectURL(y),U=document.createElement("a");U.href=z,U.download=`alpha-intelligence-report-${new Date().toISOString().split("T")[0]}.html`,U.click(),URL.revokeObjectURL(z)}catch(p){console.warn("Export failed:",p)}finally{u(!1)}}}return s?e.jsxs("div",{className:"space-y-3",children:[$.length>0&&e.jsx(j.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"space-y-1.5",children:$.map((p,y)=>e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs border ${p.type==="warning"?"bg-amber-500/10 border-amber-500/30 text-amber-300":p.type==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":"bg-blue-500/10 border-blue-500/30 text-blue-300"}`,children:[p.type==="warning"?e.jsx(je,{className:"w-3.5 h-3.5 flex-shrink-0"}):p.type==="success"?e.jsx(Z,{className:"w-3.5 h-3.5 flex-shrink-0"}):e.jsx(je,{className:"w-3.5 h-3.5 flex-shrink-0"}),p.message]},y))}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsxs("button",{onClick:H,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border transition-all ${k?"bg-teal-500/20 border-teal-500/30 text-teal-300":"bg-slate-700/50 border-slate-600/50 text-slate-400 hover:text-white"}`,children:[k?e.jsx(He,{className:"w-3.5 h-3.5"}):e.jsx(Ke,{className:"w-3.5 h-3.5"}),k?"แจ้งเตือน ON":"แจ้งเตือน"]}),e.jsxs("button",{onClick:se,disabled:d||!h,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-slate-700/50 hover:bg-slate-700 border border-slate-600/50 text-slate-300 rounded-lg transition-all disabled:opacity-50",children:[e.jsx(Ge,{className:"w-3.5 h-3.5"}),d?"กำลังส่งออก...":"ส่งออกรายงาน"]})]}),c.length>0&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>T("trend"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"w-5 h-5 text-emerald-400"}),e.jsx("span",{className:"font-medium text-white",children:"แนวโน้มผลงาน"}),e.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-300 text-xs rounded-full",children:[c.length," วัน"]})]}),n==="trend"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]}),e.jsx(R,{children:n==="trend"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-2 text-center",children:"Win Rate รายวัน + แนวโน้มสะสม"}),e.jsx(B,{width:"100%",height:200,children:e.jsxs(qe,{data:c,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"winRateGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#14b8a6",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#14b8a6",stopOpacity:0})]})}),e.jsx(Q,{dataKey:"date",tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1}),e.jsx(ee,{tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1,domain:[0,100]}),e.jsx(J,{...Re,formatter:(p,y)=>[`${p}%`,y==="winRate"?"Win Rate วันนี้":"Win Rate สะสม"]}),e.jsx(Ye,{type:"monotone",dataKey:"winRate",stroke:"#14b8a6",fill:"url(#winRateGradient)",strokeWidth:2,dot:{r:2,fill:"#14b8a6"}}),e.jsx(Ve,{type:"monotone",dataKey:"cumulativeWinRate",stroke:"#f59e0b",strokeWidth:1.5,strokeDasharray:"5 5",dot:!1})]})}),e.jsxs("div",{className:"flex justify-center gap-6 mt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("div",{className:"w-3 h-0.5 bg-teal-400 rounded"}),e.jsx("span",{className:"text-slate-400",children:"Win Rate รายวัน"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("div",{className:"w-3 h-0.5 bg-amber-400 rounded border-dashed"}),e.jsx("span",{className:"text-slate-400",children:"Win Rate สะสม"})]})]})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-2 text-center",children:"à¸
124ˆà¸³à¸™à¸§à¸™à¹€à¸—รดรายวัน"}),e.jsx(B,{width:"100%",height:120,children:e.jsxs(pe,{data:c,children:[e.jsx(Q,{dataKey:"date",tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1}),e.jsx(ee,{tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1}),e.jsx(J,{...Re}),e.jsx(te,{dataKey:"wins",stackId:"a",fill:"#14b8a6",radius:[0,0,0,0],name:"ชนะ"}),e.jsx(te,{dataKey:"losses",stackId:"a",fill:"#ef4444",radius:[3,3,0,0],name:"แพ้"})]})})]})]})})]}),v.length>0&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>T("radar"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(it,{className:"w-5 h-5 text-cyan-400"}),e.jsx("span",{className:"font-medium text-white",children:"ทักษะการเทรด"}),e.jsxs("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-300 text-xs rounded-full",children:[S," คะแนน"]})]}),n==="radar"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]}),e.jsx(R,{children:n==="radar"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"bg-slate-900/60 rounded-lg p-3",children:e.jsx(B,{width:"100%",height:250,children:e.jsxs(Xe,{data:v,children:[e.jsx(Ze,{stroke:"#334155"}),e.jsx(Qe,{dataKey:"subject",tick:{fill:"#e2e8f0",fontSize:11}}),e.jsx(et,{angle:30,domain:[0,100],tick:{fill:"#64748b",fontSize:9}}),e.jsx(tt,{name:"คะแนน",dataKey:"score",stroke:"#14b8a6",fill:"#14b8a6",fillOpacity:.25,strokeWidth:2})]})})}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:v.map((p,y)=>e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-0.5",children:p.subject}),e.jsx("p",{className:`text-sm font-bold ${p.score>=70?"text-emerald-400":p.score>=40?"text-amber-400":"text-red-400"}`,children:p.score})]},y))}),e.jsxs("div",{className:`rounded-lg p-3 border text-center ${S>=70?"bg-emerald-500/10 border-emerald-500/20":S>=40?"bg-amber-500/10 border-amber-500/20":"bg-red-500/10 border-red-500/20"}`,children:[e.jsx("p",{className:"text-xs text-slate-400 mb-0.5",children:"ระดับทักษะรวม"}),e.jsxs("p",{className:`text-lg font-bold ${S>=70?"text-emerald-400":S>=40?"text-amber-400":"text-red-400"}`,children:[S>=80?"ระดับผู้เชี่ยวชาญ":S>=60?"ระดับก้าวหน้า":S>=40?"ระดับกลาง":"ระดับเริ่มต้น"," (",S,"/100)"]})]})]})})]}),h&&h.totalPredictions>0&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>T("accuracy"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-5 h-5 text-amber-400"}),e.jsx("span",{className:"font-medium text-white",children:"ความแม่นยำ AI"}),e.jsxs("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-300 text-xs rounded-full",children:[h.accuracyPercent,"%"]})]}),n==="accuracy"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]}),e.jsx(R,{children:n==="accuracy"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-0.5",children:"ทำนายทั้งหมด"}),e.jsx("p",{className:"text-lg font-bold text-white",children:h.totalPredictions})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-0.5",children:"ถูกต้อง"}),e.jsx("p",{className:"text-lg font-bold text-emerald-400",children:h.correctPredictions})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-0.5",children:"แนวโน้ม"}),e.jsx("div",{className:"flex items-center justify-center gap-1",children:h.recentTrend==="improving"?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{className:"text-sm font-bold text-emerald-400",children:"ดีขึ้น"})]}):h.recentTrend==="declining"?e.jsxs(e.Fragment,{children:[e.jsx(lt,{className:"w-4 h-4 text-red-400"}),e.jsx("span",{className:"text-sm font-bold text-red-400",children:"ลดลง"})]}):e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"w-4 h-4 text-slate-400"}),e.jsx("span",{className:"text-sm font-bold text-slate-300",children:"คงที่"})]})})]})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:"ความแม่นยำ"}),e.jsxs("div",{className:"relative h-4 bg-slate-700 rounded-full overflow-hidden",children:[e.jsx(j.div,{initial:{width:0},animate:{width:`${h.accuracyPercent}%`},transition:{duration:1,ease:"easeOut"},className:`absolute h-full rounded-full ${h.accuracyPercent>=70?"bg-gradient-to-r from-emerald-500 to-teal-400":h.accuracyPercent>=50?"bg-gradient-to-r from-amber-500 to-yellow-400":"bg-gradient-to-r from-red-500 to-orange-400"}`}),e.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] font-bold text-white drop-shadow",children:[h.accuracyPercent,"%"]})]})]}),h.byType.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"แยกตามประเภท"}),h.byType.map((p,y)=>e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-2.5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-300",children:p.type}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-[10px] text-slate-500",children:[p.correct,"/",p.total]}),e.jsxs("span",{className:`text-xs font-bold ${p.accuracy>=70?"text-emerald-400":p.accuracy>=50?"text-amber-400":"text-red-400"}`,children:[p.accuracy,"%"]})]})]},y))]})]})})]}),b&&b.previous&&b.current&&e.jsxs(j.div,{initial:{opacity:0,y:10}
124,animate:{opacity:1,y:0},transition:{delay:.15},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>T("comparison"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(dt,{className:"w-5 h-5 text-blue-400"}),e.jsx("span",{className:"font-medium text-white",children:"เปรียบเทียบการวิเคราะห์"})]}),n==="comparison"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]}),e.jsx(R,{children:n==="comparison"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1",children:"ครั้งก่อน"}),e.jsx("p",{className:"text-xs text-slate-300 line-clamp-3",children:b.previous.title}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:new Date(b.previous.created_at).toLocaleDateString("th-TH")}),b.previous.confidence_score&&e.jsxs("p",{className:"text-[10px] text-amber-400 mt-0.5",children:["ความมั่นใจ: ",b.previous.confidence_score,"%"]})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 border border-teal-500/20",children:[e.jsx("p",{className:"text-[10px] text-teal-400 mb-1",children:"ล่าสุด"}),e.jsx("p",{className:"text-xs text-slate-300 line-clamp-3",children:b.current.title}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:new Date(b.current.created_at).toLocaleDateString("th-TH")}),b.current.confidence_score&&e.jsxs("p",{className:"text-[10px] text-teal-400 mt-0.5",children:["ความมั่นใจ: ",b.current.confidence_score,"%"]})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-blue-500/10 to-cyan-500/10 border border-blue-500/20 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-blue-300 mb-2",children:"การเปลี่ยนแปลง"}),e.jsx("ul",{className:"space-y-1",children:b.changes.map((p,y)=>e.jsxs("li",{className:"text-xs text-slate-300 flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-400 flex-shrink-0"}),p]},y))})]})]})})]})]}):null}function me(s,a){try{return JSON.parse(s)}catch{return a}}function xs({currentAsset:s}){const[a,r]=f.useState(!1),[l,n]=f.useState(null),[x,c]=f.useState(null),[o,h]=f.useState(null),[N,b]=f.useState(null),[g,k]=f.useState("patterns"),[M,$]=f.useState(null),[m,d]=f.useState(null),[u,_]=f.useState(!1),[v,S]=f.useState(0),[T,H]=f.useState(!1),[se,p]=f.useState(!1),[y,z]=f.useState(0),[U,K]=f.useState(null),[$e,ae]=f.useState(!1),[Le,Oe]=f.useState(""),[Pe,ue]=f.useState(""),[Me,De]=f.useState(""),ge=["#14b8a6","#f59e0b","#ef4444","#3b82f6","#8b5cf6","#ec4899"],ie=f.useMemo(()=>m!=null&&m.assets?m.assets.slice(0,8).map(t=>({name:t.name,"Win Rate":Math.round(t.win_rate),trades:t.trades})):[],[m]),re=f.useMemo(()=>{if(!m)return[];const t=Math.round(m.total_trades*m.win_rate/100),i=m.total_trades-t;return[{name:"ชนะ",value:t,color:"#14b8a6"},{name:"แพ้",value:i,color:"#ef4444"}]},[m]),le=f.useMemo(()=>m!=null&&m.time_patterns?m.time_patterns.slice(0,8).map(t=>({name:`${t.hour}:00`,"Win Rate":Math.round(t.win_rate),trades:t.trades})):[],[m]);f.useEffect(()=>{We(),be()},[]);async function be(){try{const t=await ve("full");H(t.isFreeTrial);const i=await _e();S(i.purchasedBalance),i.vipCodeId&&Oe(i.vipCodeId);let w=Ne.getItem("vip_code");if(w||(w=Ne.getItem("vip_session")),w)try{const L=JSON.parse(w);ue(L.code||w),De(L.customer_email||"")}catch{ue(w)}}catch(t){console.warn("Could not load credit info:",t),S(0)}}async function We(){try{const[t,i,w]=await Promise.all([xe("pattern_analysis"),xe("strategy"),xe("market_insight")]);t&&c(t),i&&h(i),w&&b(w)}catch(t){console.warn("Could not load cached insights:",t)}}async function ne(t){$(null),p(!1),K(null);const i=t==="all"?"full":"single",w=await ve(i);if(!w.canAfford){p(!0),z(w.cost),S(w.balance);return}const L=await Fe(i);if(!L.success){$(L.error||"Failed to process credits");return}if(L.freeTrialUsed)K("Free trial used! First analysis is on us."),H(!1);else{const O=V[i];K(`${O} credits deducted`);const{purchasedBalance:P}=await _e();S(P)}r(!0),n(t);try{const O=await xt();if(d(O),O.total_trades<3){$("Need at least 3 completed trades (WIN/LOSS) for AI analysis.");return}if(t==="all"||t==="pattern_analysis"){const P=await ft(O);c(P)}if(t==="all"||t==="strategy"){const P=await ut(O,s);h(P)}if(t==="all"||t==="market_insight"){const P=await gt(O);b(P)}}catch(O){const P=O instanceof Error?O.message:"Analysis failed";$(P)}finally{r(!1),n(null)}}function G(t){k(g===t?null:t)}function q(t){if(!t)return"";const i=Date.now()-new Date(t).getTime(),w=Math.floor(i/6e4);if(w<60)return`${w}m ago`;const L=Math.floor(w/60);return L<24?`${L}h ago`:`${Math.floor(L/24)}d ago`}const I=x?me(x.content,{patterns:[],risk_factors:[],key_insight:"",hidden_correlations:[]}):null,A=o?me(o.content,{strategy_name:"",entry_rules:[],exit_rules:[],risk_management:[],avoid_conditions:[],regime_adjustments:{},expected_improvement:""}):null,C=N?me(N.content,{summary:"",reliable_signals:[],timing_advice:"",market_assessment:"",recommendations:[],risk_warning:""}):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-teal-500/20 bg-gradient-to-br from-slate-800/80 via-slate-800/40 to-slate-900/70 p-4",children:[e.jsx("div",{className:"pointer-events-none absolute -top-16 -right-10 h-40 w-40 rounded-full bg-teal-500/10 blur-3xl"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-20 -left-12 h-44 w-44 rounded-full bg-cyan-500/10 blur-3xl"}),e.jsxs("div",{className:"relative flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-teal-500 to-cyan-600 shadow-lg shadow-teal-500/30",children:[e.jsx(ye,{className:"h-5 w-5 text-white"}),e.jsxs("span",{className:"absolute -top-1 -right-1 flex h-3 w-3",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-teal-300 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-3 w-3 rounded-full bg-teal-400"})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold leading-tight text-white",children:"Alpha Intelligence"}),e.jsx("span",{className:"rounded-full border border-teal-500/30 bg-teal-500/15 px-2 py-0.5 text-[10px] font-medium text-teal-300",children:"AI-Powered"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-slate-400",children:"AI อ่านพอร์ตเทรดจริงของคุณ แล้วสรุป รูปแบบ · กลยุทธ์ · จุดเสี่ยง"})]})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:e.jsx("button",{onClick:()=>_(!u),className:"rounded-lg p-1.5 text-slate-400 transition-colors hover:bg-slate-700/60 hover:text-white",title:"ประวัติการวิเคราะห์",children:e.jsx(Se,{className:"h-4 w-4"})})})]}),e.jsxs("div",{className:"relative mt-3 flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-xl border border-yellow-500/25 bg-gradient-to-r from-yellow-500/10 to-amber-500/10 px-3 py-2",children:[e.jsx(ke,{className:"h-4 w-4 flex-shrink-0 text-yellow-400"}),e.jsxs("div",{className:"flex flex-col leading-none",children:[e.jsx("span",{className:"text-[9px] text-yellow-400/70",children:"เครดิตคงเหลือ"}),e.jsx("span",{className:"text-sm font-bold text-yellow-300",children:v.toLocaleStr
124ing()})]})]}),e.jsxs("button",{onClick:()=>ae(!0),className:"flex items-center gap-1.5 rounded-xl border border-emerald-500/30 bg-gradient-to-r from-emerald-500/15 to-teal-500/15 px-3 py-2 text-xs font-medium text-emerald-300 transition-all hover:from-emerald-500/25 hover:to-teal-500/25",title:"เติมเครดิต",children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"เติมเครดิต"})]})]})]}),(m||T)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-700/60 bg-slate-800/40 px-2.5 py-1 text-xs text-slate-300",children:[e.jsx(we,{className:"h-3.5 w-3.5 text-cyan-400"}),m.total_trades.toLocaleString()," เทรด"]}),e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs ${m.win_rate>=50?"border-emerald-500/30 bg-emerald-500/10 text-emerald-300":"border-red-500/30 bg-red-500/10 text-red-300"}`,children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),m.win_rate.toFixed(0),"% ชนะ"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-teal-500/30 bg-teal-500/10 px-2.5 py-1 text-xs text-teal-300",children:[e.jsx(F,{className:"h-3.5 w-3.5"}),m.regime]})]}),T&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-lg border border-emerald-500/30 bg-emerald-500/15 px-2.5 py-1 text-xs text-emerald-300",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"ทดลองฟรี 1 ครั้ง"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>ne("all"),disabled:a,className:"group relative w-full overflow-hidden rounded-2xl bg-gradient-to-r from-teal-500 via-cyan-500 to-teal-500 px-4 py-3.5 text-left text-white shadow-lg shadow-teal-500/25 transition-all hover:shadow-teal-500/40 disabled:cursor-not-allowed disabled:opacity-60",children:[!a&&e.jsx(j.span,{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-1/3 bg-gradient-to-r from-transparent via-white/25 to-transparent",animate:{x:["-160%","460%"]},transition:{duration:2.6,repeat:1/0,ease:"linear",repeatDelay:1.2}}),e.jsxs("div",{className:"relative flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-white/20",children:a&&l==="all"?e.jsx(ce,{className:"h-5 w-5 animate-spin"}):e.jsx(Te,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold",children:a&&l==="all"?"Alpha AI กำลังวิเคราะห์…":"วิเคราะห์ทั้งหมด"}),!(a&&l==="all")&&e.jsx("span",{className:"rounded-full bg-white/20 px-2 py-0.5 text-[10px] font-semibold",children:T?"ฟรี":`${V.full} เครดิต`})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-white/80",children:"รูปแบบ · กลยุทธ์ · เชิงลึก — 3 รายงานในคลิกเดียว"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>ne("pattern_analysis"),disabled:a,className:"group flex items-center gap-2.5 rounded-xl border border-slate-700/60 bg-slate-800/40 p-3 text-left transition-all hover:border-teal-500/40 hover:bg-slate-800/70 disabled:opacity-50",children:[e.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-teal-500/15 text-teal-300 transition-colors group-hover:bg-teal-500/25",children:a&&l==="pattern_analysis"?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("span",{className:"truncate text-xs font-semibold text-white",children:"รูปแบบการเทรด"}),e.jsx("span",{className:"flex-shrink-0 rounded-full bg-slate-700/60 px-1.5 py-0.5 text-[9px] text-slate-300",children:T?"ฟรี":`${V.single}c`})]}),e.jsx("p",{className:"truncate text-[10px] text-slate-500",children:"à¸
124ˆà¸¸à¸”แข็ง–จุดอ่อน + ความเสี่ยง"})]})]}),e.jsxs("button",{onClick:()=>ne("strategy"),disabled:a,className:"group flex items-center gap-2.5 rounded-xl border border-slate-700/60 bg-slate-800/40 p-3 text-left transition-all hover:border-emerald-500/40 hover:bg-slate-800/70 disabled:opacity-50",children:[e.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-emerald-500/15 text-emerald-300 transition-colors group-hover:bg-emerald-500/25",children:a&&l==="strategy"?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("span",{className:"truncate text-xs font-semibold text-white",children:"กลยุทธ์เฉพาะตัว"}),e.jsx("span",{className:"flex-shrink-0 rounded-full bg-slate-700/60 px-1.5 py-0.5 text-[9px] text-slate-300",children:T?"ฟรี":`${V.single}c`})]}),e.jsx("p",{className:"truncate text-[10px] text-slate-500",children:"กฎเข้า–ออก + จัดการเสี่ยง"})]})]})]})]}),e.jsx(R,{children:se&&e.jsx(j.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"bg-gradient-to-r from-amber-500/10 to-orange-500/10 border border-amber-500/30 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-amber-500/20 rounded-lg flex-shrink-0",children:e.jsx(ct,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-amber-300",children:"เครดิตไม่เพียงพอ"}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["การวิเคราะห์นี้ต้องใช้ ",e.jsxs("span",{className:"text-white font-medium",children:[y.toLocaleString()," เครดิต"]}),"คุณมี ",e.jsxs("span",{className:"text-amber-300 font-medium",children:[v.toLocaleString()," เครดิต"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsxs("button",{onClick:()=>{p(!1),ae(!0)},className:"flex items-center gap-1.5 px-4 py-2 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-400 hover:to-orange-400 text-white text-xs font-medium rounded-lg transition-all shadow-lg shadow-amber-500/20",children:[e.jsx(Ae,{className:"w-3.5 h-3.5"}),"เติมเครดิต"]}),e.jsx("button",{onClick:()=>p(!1),className:"px-3 py-2 text-slate-400 hover:text-white text-xs rounded-lg transition-colors",children:"ยกเลิก"})]}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-2",children:["ต้องการอีก ",(y-v).toLocaleString()," เครดิต"]})]})]})})}),e.jsx(R,{children:U&&e.jsxs(j.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg p-2.5 flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs text-emerald-300 flex items-center gap-1.5",children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),U]}),e.jsx("button",{onClick:()=>K(null),className:"text-slate-500 hover:text-white text-xs",children:"OK"})]})}),e.jsx(R,{children:M&&e.jsx(j.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-red-300 flex items-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4 flex-shrink-0"}),M]})})}),a&&e.jsxs(j.div,{initial:{opacity:0}
124,animate:{opacity:1},className:"bg-gradient-to-r from-teal-500/10 to-cyan-500/10 border border-teal-500/30 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(F,{className:"w-6 h-6 text-teal-400 animate-pulse"}),e.jsx("div",{className:"absolute inset-0 w-6 h-6 bg-teal-400/20 rounded-full animate-ping"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-teal-300",children:"Alpha AI กำลังวิเคราะห์ข้อมูลเทรดของคุณ..."}),e.jsx("p",{className:"text-xs text-slate-400",children:"ระบุรูปแบบ สร้างกลยุทธ์ เตรียมข้อมูลเชิงลึก"})]})]}),e.jsx("div",{className:"space-y-2",children:["กำลังรวบรวมประวัติเทรด","วิเคราะห์ความสัมพันธ์ของอินดิเคเตอร์","สร้างข้อมูลเชิงลึก"].map((t,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${i===0?"bg-teal-400":i===1?"bg-teal-400 animate-pulse":"bg-slate-600"}`}),e.jsx("span",{className:i<=1?"text-teal-300":"text-slate-500",children:t})]},i))})]}),m&&m.total_trades>0&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>G("stats"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(we,{className:"w-5 h-5 text-cyan-400"}),e.jsx("span",{className:"font-medium text-white",children:"สถิติการเทรด"}),e.jsxs("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-300 text-xs rounded-full",children:[m.total_trades," เทรด"]})]}),g==="stats"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]}),e.jsx(R,{children:g==="stats"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{label:"เทรดทั้งหมด",value:m.total_trades,color:"text-white"},{label:"อัตราชนะ",value:`${m.win_rate.toFixed(1)}%`,color:m.win_rate>=50?"text-emerald-400":"text-red-400"},{label:"กำไรเฉลี่ย",value:`${m.avg_profit.toFixed(2)}%`,color:"text-emerald-400"},{label:"ขาดทุนเฉลี่ย",value:`${m.avg_loss.toFixed(2)}%`,color:"text-red-400"}].map((t,i)=>e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-2.5 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-0.5",children:t.label}),e.jsx("p",{className:`text-sm font-bold ${t.color}`,children:t.value})]},i))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-2 text-center",children:"สัดส่วนชนะ/แพ้"}),e.jsx(B,{width:"100%",height:140,children:e.jsxs(st,{children:[e.jsx(at,{data:re,cx:"50%",cy:"50%",innerRadius:35,outerRadius:55,paddingAngle:4,dataKey:"value",children:re.map((t,i)=>e.jsx(oe,{fill:t.color},i))}),e.jsx(J,{contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",fontSize:"11px"},itemStyle:{color:"#e2e8f0"}})]})}),e.jsx("div",{className:"flex justify-center gap-4 mt-1",children:re.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.color}}),e.jsxs("span",{className:"text-slate-400",children:[t.name,": ",t.value]})]},i))})]}),le.length>0&&e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-2 text-center",children:"Win Rate ตามช่วงเวลา"}),e.jsx(B,{width:"100%",height:140,children:e.jsxs(pe,{data:le,children:[e.jsx(Q,{dataKey:"name",tick:{fill:"#94a3b8",fontSize:9}
124,axisLine:!1,tickLine:!1}),e.jsx(ee,{tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1,domain:[0,100]}),e.jsx(J,{contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",fontSize:"11px"},itemStyle:{color:"#e2e8f0"},formatter:t=>[t===void 0?"-":`${t}%`,"Win Rate"]}),e.jsx(te,{dataKey:"Win Rate",radius:[3,3,0,0],children:le.map((t,i)=>e.jsx(oe,{fill:ge[i%ge.length]},i))})]})})]})]}),ie.length>0&&e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-2 text-center",children:"Win Rate ตามสินทรัพย์"}),e.jsx(B,{width:"100%",height:180,children:e.jsxs(pe,{data:ie,layout:"vertical",children:[e.jsx(Q,{type:"number",tick:{fill:"#94a3b8",fontSize:9},axisLine:!1,tickLine:!1,domain:[0,100]}),e.jsx(ee,{dataKey:"name",type:"category",tick:{fill:"#e2e8f0",fontSize:10},axisLine:!1,tickLine:!1,width:55}),e.jsx(J,{contentStyle:{background:"#1e293b",border:"1px solid #334155",borderRadius:"8px",fontSize:"11px"},itemStyle:{color:"#e2e8f0"},formatter:t=>[t===void 0?"-":`${t}%`,"Win Rate"]}),e.jsx(te,{dataKey:"Win Rate",radius:[0,4,4,0],children:ie.map((t,i)=>e.jsx(oe,{fill:t["Win Rate"]>=60?"#14b8a6":t["Win Rate"]>=40?"#f59e0b":"#ef4444"},i))})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1",children:"สถิติต่อเนื่อง"}),e.jsx("p",{className:"text-sm font-bold text-teal-300",children:m.recent_streak})]}),e.jsxs("div",{className:"bg-slate-900/60 rounded-lg p-3 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1",children:"สภาวะตลาด"}),e.jsx("p",{className:`text-sm font-bold ${m.regime==="BULL"?"text-emerald-400":m.regime==="BEAR"?"text-red-400":m.regime==="VOLATILE"?"text-amber-400":"text-slate-300"}`,children:m.regime}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:["ความมั่นใจ ",(m.regime_confidence*100).toFixed(0),"%"]})]})]})]})})]}),I&&I.patterns.length>0&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>G("patterns"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{className:"w-5 h-5 text-teal-400"}),e.jsx("span",{className:"font-medium text-white",children:"การจดจำรูปแบบ"}),e.jsxs("span",{className:"px-2 py-0.5 bg-teal-500/20 text-teal-300 text-xs rounded-full",children:["พบ ",I.patterns.length," รูปแบบ"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(x==null?void 0:x.created_at)&&e.jsx("span",{className:"text-xs text-slate-500",children:q(x.created_at)}),g==="patterns"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]})]}),e.jsx(R,{children:g==="patterns"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[I.key_insight&&e.jsx("div",{className:"bg-teal-500/10 border border-teal-500/30 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-teal-200 flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 flex-shrink-0 text-teal-400"}),I.key_insight]})}),I.patterns.map((t,i)=>e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3 border border-slate-700/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:t.name}),e.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full ${t.confidence>=70?"bg-green-500/20 text-green-300":t.confidence>=50?"bg-yellow-500/20 text-yellow-300":"bg-red-500/20 text-red-300"}`,children:[t.confidence,"%"]})]}),e.jsx("p",{className:"text-xs text-slate-400 mb-2",children:t.description}),t.actionable_tip&&e.jsxs("p",{className:"text-xs text-teal-300 bg-teal-500/10 rounded px-2 py-1",children:["เคล็ดลับ: ",t.actionable_tip]})]},i)),I.risk_factors.length>0&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-red-300 mb-1.5 flex items-center gap-1",children:[e.jsx(Y,{className:"w-3.5 h-3.5"})," ปัจจัยเสี่ยง"]}),e.jsx("ul",{className:"space-y-1",children:I.risk_factors.map((t,i)=>e.jsx("li",{className:"text-xs text-red-200/80 pl-3 relative before:absolute before:left-0 before:top-1.5 before:w-1 before:h-1 before:bg-red-400 before:rounded-full",children:t},i))})]}),I.hidden_correlations&&I.hidden_correlations.length>0&&e.jsxs("div",{className:"bg-cyan-500/10 border border-cyan-500/20 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-cyan-300 mb-1.5",children:"ความสัมพันธ์ที่ซ่อนอยู่"}),e.jsx("ul",{className:"space-y-1",children:I.hidden_correlations.map((t,i)=>e.jsx("li",{className:"text-xs text-cyan-200/80 pl-3 relative before:absolute before:left-0 before:top-1.5 before:w-1 before:h-1 before:bg-cyan-400 before:rounded-full",children:t},i))})]})]})})]}),A&&A.strategy_name&&e.jsxs(j.div,{initial:{opacity:0,y:10}
124,animate:{opacity:1,y:0},transition:{delay:.1},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>G("strategy"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-5 h-5 text-emerald-400"}),e.jsx("span",{className:"font-medium text-white",children:A.strategy_name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(o==null?void 0:o.created_at)&&e.jsx("span",{className:"text-xs text-slate-500",children:q(o.created_at)}),g==="strategy"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]})]}),e.jsx(R,{children:g==="strategy"&&e.jsxs(j.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[A.entry_rules.length>0&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-emerald-300 mb-2 flex items-center gap-1.5",children:[e.jsx(Z,{className:"w-3.5 h-3.5"})," กฎเข้าเทรด"]}),e.jsx("ul",{className:"space-y-1.5",children:A.entry_rules.map((t,i)=>e.jsxs("li",{className:"text-xs text-slate-300 flex items-start gap-2",children:[e.jsxs("span",{className:"text-emerald-400 font-mono mt-0.5",children:[i+1,"."]})," ",t]},i))})]}),A.exit_rules.length>0&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-amber-300 mb-2 flex items-center gap-1.5",children:[e.jsx(Ie,{className:"w-3.5 h-3.5"})," กฎออกเทรด"]}),e.jsx("ul",{className:"space-y-1.5",children:A.exit_rules.map((t,i)=>e.jsxs("li",{className:"text-xs text-slate-300 flex items-start gap-2",children:[e.jsxs("span",{className:"text-amber-400 font-mono mt-0.5",children:[i+1,"."]})," ",t]},i))})]}),A.risk_management.length>0&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-blue-300 mb-2 flex items-center gap-1.5",children:[e.jsx(ot,{className:"w-3.5 h-3.5"})," การจัดการความเสี่ยง"]}),e.jsx("ul",{className:"space-y-1.5",children:A.risk_management.map((t,i)=>e.jsxs("li",{className:"text-xs text-slate-300 flex items-start gap-2",children:[e.jsxs("span",{className:"text-blue-400 font-mono mt-0.5",children:[i+1,"."]})," ",t]},i))})]}),A.avoid_conditions.length>0&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-red-300 mb-2 flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-3.5 h-3.5"})," หลีกเลี่ยงเทรดเมื่อ"]}),e.jsx("ul",{className:"space-y-1",children:A.avoid_conditions.map((t,i)=>e.jsx("li",{className:"text-xs text-red-200/80 pl-3 relative before:absolute before:left-0 before:top-1.5 before:w-1 before:h-1 before:bg-red-400 before:rounded-full",children:t},i))})]}),A.expected_improvement&&e.jsx("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-lg p-2.5 text-center",children:e.jsx("p",{className:"text-xs text-emerald-300",children:A.expected_improvement})})]})})]}),C&&C.summary&&e.jsxs(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:"bg-slate-800/50 rounded-xl border border-slate-700 overflow-hidden",children:[e.jsxs("button",{onClick:()=>G("insights"),className:"w-full p-4 flex items-center justify-between hover:bg-slate-700/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-5 h-5 text-amber-400"}),e.jsx("span",{className:"font-medium text-white",children:"ข้อมูลเชิงลึก"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[(N==null?void 0:N.created_at)&&e.jsx("span",{className:"text-xs text-slate-500",children:q(N.created_at)}),g==="insights"?e.jsx(D,{className:"w-4 h-4 text-slate-400"}):e.jsx(W,{className:"w-4 h-4 text-slate-400"})]})]}),e.jsx(R,{children:g==="insights"&&e.jsxs(j.div,{initial:{height:0,opacity:0}
124,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-500/10 to-cyan-500/10 border border-teal-500/20 rounded-lg p-3",children:e.jsx("p",{className:"text-sm text-teal-200",children:C.summary})}),C.market_assessment&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-300 mb-1",children:"การประเมินตลาด"}),e.jsx("p",{className:"text-xs text-slate-400",children:C.market_assessment})]}),C.reliable_signals.length>0&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-medium text-emerald-300 mb-2",children:"สัญญาณที่น่าเชื่อถือ"}),e.jsx("div",{className:"space-y-2",children:C.reliable_signals.map((t,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Te,{className:"w-3 h-3 text-emerald-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-white font-medium",children:t.signal}),e.jsx("p",{className:"text-xs text-slate-400",children:t.explanation})]})]},i))})]}),C.timing_advice&&e.jsxs("div",{className:"bg-slate-900/50 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-cyan-300 mb-1 flex items-center gap-1",children:[e.jsx(Ie,{className:"w-3 h-3"})," คำแนะนำเรื่องเวลา"]}),e.jsx("p",{className:"text-xs text-slate-400",children:C.timing_advice})]}),C.recommendations.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-amber-300",children:"คำแนะนำ"}),C.recommendations.map((t,i)=>e.jsxs("div",{className:`rounded-lg p-3 border ${t.priority==="high"?"bg-amber-500/10 border-amber-500/20":t.priority==="medium"?"bg-blue-500/10 border-blue-500/20":"bg-slate-900/50 border-slate-700/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t.priority==="high"?"bg-amber-400":t.priority==="medium"?"bg-blue-400":"bg-slate-400"}`}),e.jsx("span",{className:"text-xs font-medium text-white",children:t.title})]}),e.jsx("p",{className:"text-xs text-slate-400 pl-3.5",children:t.detail})]},i))]}),C.risk_warning&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-2.5",children:e.jsxs("p",{className:"text-xs text-red-300 flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-3.5 h-3.5 flex-shrink-0"}),C.risk_warning]})})]})})]}),e.jsx(St,{summary:m,patternInsight:x,strategyInsight:o,marketInsight:N}),!x&&!o&&!N&&!a&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-800/30 p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-2xl bg-gradient-to-br from-teal-500/20 to-cyan-500/20",children:e.jsx(ye,{className:"h-6 w-6 text-teal-400"})}),e.jsx("p",{className:"text-sm font-semibold text-white",children:"พร้อมวิเคราะห์พอร์ตของคุณ"}),e.jsx("p",{className:"mx-auto mt-1 max-w-xs text-xs text-slate-500",children:"กด “วิเคราะห์ทั้งหมด” แล้ว Alpha AI จะสรุปผลงานจริงของคุณให้ 3 ด้าน"}),e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:[{icon:F,color:"text-teal-300",bg:"border-teal-500/20 bg-teal-500/10",title:"รูปแบบ",desc:"จุดแข็ง-อ่อน"},{icon:X,color:"text-emerald-300",bg:"border-emerald-500/20 bg-emerald-500/10",title:"กลยุทธ์",desc:"กฎเข้า-ออก"},{icon:de,color:"text-amber-300",bg:"border-amber-500/20 bg-amber-500/10",title:"เชิงลึก",desc:"คำแนะนำ"}].map((t,i)=>{const w=t.icon;return e.jsxs("div",{className:`rounded-xl border p-3 ${t.bg}`,children:[e.jsx(w,{className:`mx-auto mb-1.5 h-5 w-5 ${t.color}`}),e.jsx("p",{className:"text-[11px] font-medium text-white",children:t.title}),e.jsx("p",{className:"text-[9px] text-slate-500",children:t.desc})]},i)})}),T&&e.jsxs("p",{className:"mt-3 inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/15 px-3 py-1 text-xs text-emerald-300",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"วิเคราะห์ครั้งแรกฟรี!"]})]}),u&&(x||o||N)&&e.jsxs(j.div,{initial:{opacity:0,height:0}
124,animate:{opacity:1,height:"auto"},className:"bg-slate-800/30 rounded-lg border border-slate-700/50 p-3",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-400 mb-2 flex items-center gap-1.5",children:[e.jsx(Se,{className:"w-3.5 h-3.5"})," ประวัติการวิเคราะห์"]}),e.jsx("div",{className:"space-y-1.5",children:[x,o,N].filter(Boolean).map((t,i)=>e.jsxs("div",{className:"flex items-center justify-between text-xs bg-slate-900/50 rounded px-2.5 py-1.5",children:[e.jsx("span",{className:"text-slate-300",children:t.insight_type==="pattern_analysis"?"รูปแบบ":t.insight_type==="strategy"?"กลยุทธ์":"ข้อมูลเชิงลึก"}),e.jsx("span",{className:"text-slate-500",children:q(t.created_at)})]},i))})]}),e.jsx(Je,{isOpen:$e,onClose:()=>{ae(!1),be()},userId:Pe,currentCredits:v,userEmail:Me,vipCodeId:Le})]})}export{xs as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.