Ezmary commited on
Commit
46caae7
·
verified ·
1 Parent(s): f6a570d

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +399 -0
templates/index.html ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- templates/index.html -->
2
+ <!DOCTYPE html>
3
+ <html lang="fa" dir="rtl">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>AI Video Studio</title>
8
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
9
+ <style>
10
+ /* تمام کدهای CSS شما بدون تغییر در اینجا قرار می‌گیرد */
11
+ :root {
12
+ --app-font: 'Vazirmatn', sans-serif;
13
+ --app-bg: #F8F9FC;
14
+ --panel-bg: #FFFFFF;
15
+ --panel-border: #EAEFF7;
16
+ --input-bg: #F6F8FB;
17
+ --input-border: #E1E7EF;
18
+ --text-primary: #1A202C;
19
+ --text-secondary: #626F86;
20
+ --text-tertiary: #8A94A6;
21
+ --accent-primary: #4A6CFA;
22
+ --accent-primary-hover: #3553D6;
23
+ --accent-primary-glow: rgba(74, 108, 250, 0.25);
24
+ --accent-secondary: #0FD4A8;
25
+ --success-color: #38A169;
26
+ --danger-color: #e53e3e;
27
+ --danger-color-hover: #c53030;
28
+ --shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
29
+ --shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
30
+ --shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05);
31
+ --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
32
+ --radius-card: 24px;
33
+ --radius-btn: 14px;
34
+ --radius-input: 12px;
35
+ --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
36
+ --igadlm-alpha-color-primary: #5A67D8;
37
+ --igadlm-alpha-color-secondary: #805AD5;
38
+ --igadlm-alpha-color-primary-darker: #4C51BF;
39
+ --igadlm-alpha-color-secondary-darker: #6B46C1;
40
+ --igadlm-alpha-color-text-light: #4A5568;
41
+ --igadlm-alpha-color-warning-bg: #FFFBEB;
42
+ --igadlm-alpha-color-warning-border: #FBBF24;
43
+ --igadlm-alpha-color-warning-text: #B45309;
44
+ --igadlm-alpha-border-radius-md: 8px;
45
+ --igadlm-alpha-border-radius-lg: 12px;
46
+ }
47
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
48
+ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
49
+ @keyframes core-pulse { 0%, 100% { transform: scale(0.95); box-shadow: 0 0 25px var(--accent-primary-glow); } 50% { transform: scale(1.05); box-shadow: 0 0 50px rgba(74, 108, 250, 0.5); } }
50
+ @keyframes ring-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
51
+ @keyframes background-pan { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
52
+ @keyframes igadlmAlphaV2fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
53
+ @keyframes fill-progress { from { width: 0%; } to { width: 100%; } }
54
+ body { font-family: var(--app-font); background-color: var(--app-bg); color: var(--text-primary); margin: 0; padding: 2.5rem 1rem; display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; }
55
+ .container { max-width: 820px; width: 100%; }
56
+ header { position: relative; text-align: center; margin-bottom: 2.5rem; padding: 2rem 0; animation: fadeIn 0.8s 0.1s ease-out backwards; overflow: hidden; }
57
+ #neural-network-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
58
+ .header-content { position: relative; z-index: 2; }
59
+ .ai-orb-container { width: 150px; height: 150px; margin: 0 auto 1rem; position: relative; display: flex; align-items: center; justify-content: center; }
60
+ .orb-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(ellipse at center, rgba(74, 108, 250, 0.15) 0%, transparent 70%), linear-gradient(45deg, rgba(15, 212, 168, 0.05), rgba(74, 108, 250, 0.05)); border-radius: 50%; animation: background-pan 12s ease-in-out infinite; background-size: 200% 200%; }
61
+ .orb-core { width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle, #394A7A 0%, #1A202C 70%); box-shadow: 0 0 25px var(--accent-primary-glow); display: flex; align-items: center; justify-content: center; position: relative; z-index: 2; animation: core-pulse 4s ease-in-out infinite; border: 1px solid rgba(74, 108, 250, 0.3); }
62
+ .play-icon { width: 24px; height: 24px; color: var(--accent-secondary); filter: drop-shadow(0 0 8px rgba(15, 212, 168, 0.7)); transition: var(--transition-smooth); }
63
+ .orb-core:hover .play-icon { transform: scale(1.1); color: #fff; filter: drop-shadow(0 0 12px rgba(15, 212, 168, 1)); }
64
+ .orb-ring { position: absolute; top: 50%; left: 50%; border-style: solid; border-color: transparent; border-radius: 50%; z-index: 1; mix-blend-mode: screen; }
65
+ .orb-ring.one { width: 100px; height: 100px; margin-top: -50px; margin-left: -50px; border-width: 2px; border-top-color: var(--accent-primary); border-right-color: var(--accent-primary); animation: ring-rotate 8s linear infinite; filter: blur(1px); }
66
+ .orb-ring.two { width: 120px; height: 120px; margin-top: -60px; margin-left: -60px; border-width: 1px; border-bottom-color: var(--accent-secondary); animation: ring-rotate 10s linear infinite reverse; }
67
+ .orb-ring.three { width: 140px; height: 140px; margin-top: -70px; margin-left: -70px; border-width: 2px; border-left-color: rgba(255, 255, 255, 0.5); border-right-color: rgba(255, 255, 255, 0.5); animation: ring-rotate 12s linear infinite; filter: blur(1px); opacity: 0.5; }
68
+ h1 { font-size: 2.8rem; font-weight: 800; margin: 0; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; }
69
+ .subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.5rem; }
70
+ .instruction { font-size: 0.95rem; color: var(--text-tertiary); margin-top: 0.75rem; font-weight: 500; }
71
+ main { padding: 3rem; background-color: var(--panel-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); border: 1px solid var(--panel-border); animation: fadeIn 0.8s 0.3s ease-out backwards; }
72
+ .form-group { margin-bottom: 2.5rem; }
73
+ .form-group:last-child { margin-bottom: 0; }
74
+ .form-label { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; color: var(--text-primary); font-size: 1.2em; margin-bottom: 1.2rem; }
75
+ .form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
76
+ #image-drop-zone { position: relative; border: 2px dashed var(--input-border); border-radius: var(--radius-input); padding: 2.5rem; text-align: center; cursor: pointer; transition: var(--transition-smooth); background-color: var(--input-bg); min-height: 200px; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; }
77
+ #image-drop-zone.drag-over, #image-drop-zone:hover:not(.has-image) { border-color: var(--accent-primary); background-color: #fff; box-shadow: 0 0 15px var(--accent-primary-glow); }
78
+ #image-drop-zone.has-image { border-style: solid; border-color: var(--success-color); padding: 0; cursor: default; }
79
+ .upload-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
80
+ .upload-icon svg { width: 48px; height: 48px; color: var(--accent-primary); stroke-width: 1.5; opacity: 0.8; }
81
+ #image-drop-zone p { margin: 0; color: var(--text-secondary); font-weight: 500; }
82
+ #imagePreview { display: none; width: 100%; height: 100%; object-fit: contain; position: absolute; top: 0; left: 0; }
83
+ #image-drop-zone.has-image .upload-content { display: none; }
84
+ #image-drop-zone.has-image #imagePreview { display: block; }
85
+ textarea { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); min-height: 120px; resize: vertical; }
86
+ textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); }
87
+ #generateButton { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.1rem; font-size: 1.2rem; font-weight: 700; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px rgba(15, 212, 168, 0.25); margin-top: 1.5rem; }
88
+ #generateButton svg { width: 24px; height: 24px; margin-left: 4px; filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
89
+ #generateButton:hover:not(:disabled) { transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(15, 212, 168, 0.3); }
90
+ #generateButton:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
91
+ #result-container { min-height: 350px; position: relative; padding: 1rem; background-color: var(--input-bg); border-radius: var(--radius-card); border: 2px dashed var(--input-border); box-shadow: var(--shadow-sm) inset; transition: var(--transition-smooth); display: flex; flex-direction: column; align-items: center; justify-content: center; }
92
+ #result-container.active { border-style: solid; border-color: var(--panel-border); }
93
+ #statusSection, #outputSection, #criticalErrorSection { display: none; width: 100%; }
94
+ #statusSection.active, #outputSection.active, #criticalErrorSection.active { display: block; animation: fadeIn 0.5s; }
95
+ #statusMessages { max-height: 150px; overflow-y: auto; width: 100%; padding: 0.5rem; margin-bottom: 1rem; }
96
+ .status-message { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; margin-bottom: 0.5rem; border-radius: var(--radius-input); font-size: 0.9rem; background: var(--panel-bg); border: 1px solid var(--panel-border); color: var(--text-secondary); }
97
+ .status-message.success { border-left: 4px solid var(--success-color); color: var(--success-color); }
98
+ .status-message.error { border-left: 4px solid var(--danger-color); color: var(--danger-color); }
99
+ .status-icon { width: 18px; height: 18px; }
100
+ #aiLoader { display: none; align-items: center; justify-content: center; }
101
+ .generator-container { position: relative; width: 400px; max-width: 100%; height: 300px; border: 2px solid #38bdf8; border-radius: 20px; overflow: hidden; box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); animation: pulse-loader 5s infinite cubic-bezier(0.4, 0, 0.6, 1); background-color: #161b22; color: #f0f6fc; }
102
+ @keyframes pulse-loader { 0% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); } 50% { box-shadow: 0 0 60px rgba(56, 189, 248, 0.7); } 100% { box-shadow: 0 0 40px rgba(56, 189, 248, 0.3); } }
103
+ .noise-layer, .sketch-layer, .building-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
104
+ .noise-layer { background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="none"/><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.6"/></svg>') repeat; opacity: 1; animation: fade-noise 7s infinite ease-in-out; }
105
+ @keyframes fade-noise { 0% { opacity: 1; filter: blur(5px); } 30% { opacity: 0.8; filter: blur(2px); } 100% { opacity: 0; filter: blur(0px); } }
106
+ .sketch-layer { filter: grayscale(1) contrast(1.5) blur(3px); opacity: 0; animation: reveal-sketch 7s infinite ease-in-out; }
107
+ @keyframes reveal-sketch { 0% { opacity: 0; } 20% { opacity: 1; } 60% { opacity: 0.5; } 100% { opacity: 0; } }
108
+ .building-layer { filter: blur(15px); opacity: 0; animation: denoise-color 7s infinite ease-in-out; }
109
+ @keyframes denoise-color { 0% { opacity: 0; } 40% { opacity: 0.6; filter: blur(5px); } 100% { opacity: 1; filter: blur(0px); } }
110
+ .pixel-grid { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: repeating-linear-gradient(0deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px), repeating-linear-gradient(90deg, transparent 0 1px, rgba(255,255,255,0.1) 1px 2px); opacity: 1; animation: dissolve-grid 7s infinite ease-in-out; }
111
+ @keyframes dissolve-grid { 0% { opacity: 1; } 70% { opacity: 0.5; } 100% { opacity: 0; } }
112
+ .particles { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle, rgba(56, 189, 248, 0.2) 0%, transparent 50%); animation: flow-particles 7s infinite cubic-bezier(0.4, 0, 0.6, 1); }
113
+ @keyframes flow-particles { 0% { transform: translate(0, 0) scale(1); opacity: 0.5; } 50% { transform: translate(10px, -15px) scale(1.05); opacity: 0.8; } 100% { transform: translate(0, 0) scale(1); opacity: 0.5; } }
114
+ .text-overlay { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); font-size: 24px; font-weight: 700; text-shadow: 0 0 20px rgba(56, 189, 248, 0.8); animation: glow-text 7s infinite ease-in-out; font-family: var(--app-font); width: 90%; text-align: center;}
115
+ @keyframes glow-text { 0% { opacity: 0.7; } 50% { opacity: 1; } 100% { opacity: 0.7; } }
116
+ .progress-bar { position: absolute; bottom: 0; left: 0; width: 0%; height: 6px; background: linear-gradient(to right, #38bdf8, #bb86fc, #facc15); }
117
+ .progress-bar.animate-progress { animation: fill-progress 60s linear forwards; }
118
+ #outputVideo { width: 100%; max-width: 500px; border-radius: var(--radius-input); margin: 1rem auto; display: block; background-color: #000; box-shadow: var(--shadow-md); }
119
+ #finalSeed { text-align: center; color: var(--text-tertiary); font-size: 0.85rem; margin-top: 1rem; }
120
+ .video-controls { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
121
+ .video-button { padding: 0.7rem 1.5rem; border-radius: var(--radius-btn); border: none; cursor: pointer; font-family: var(--app-font); font-weight: 600; font-size: 1rem; transition: var(--transition-smooth); display: flex; align-items: center; gap: 0.5rem; }
122
+ .video-button.primary { background-color: var(--accent-primary); color: white; }
123
+ .video-button.primary:hover { background-color: var(--accent-primary-hover); transform: translateY(-2px); }
124
+ .video-button:not(.primary) { background-color: var(--input-bg); color: var(--text-secondary); border: 1px solid var(--input-border); }
125
+ .video-button:not(.primary):hover { background-color: var(--panel-border); color: var(--text-primary); }
126
+ .gpu-error-message-container { text-align: right; background-color: var(--igadlm-alpha-color-warning-bg); padding: 25px; border-radius: var(--igadlm-alpha-border-radius-lg); box-shadow: var(--shadow-lg); border: 2px solid var(--igadlm-alpha-color-warning-border); animation: igadlmAlphaV2fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both; }
127
+ .gpu-error-message-container h2 { font-size: 1.2em; color: var(--igadlm-alpha-color-warning-text); margin-bottom: 15px; font-weight: 700; display: flex; align-items: center; border-bottom: 1px solid var(--igadlm-alpha-color-warning-border); padding-bottom: 12px; }
128
+ .gpu-error-message-container h2 .icon { margin-left: 10px; font-size: 1.3em; }
129
+ .gpu-error-message-container .error-content { font-size: 0.9rem; color: var(--igadlm-alpha-color-text-light); line-height: 1.7; word-break: break-word; white-space: pre-line; }
130
+ .gpu-error-message-container .error-content strong.error-message-title { font-weight: 600; color: var(--igadlm-alpha-color-warning-text); display: block; margin-bottom: 8px;}
131
+ .gpu-error-message-container .error-content ul { list-style-type: "▫️ "; padding-right: 20px; margin-top: 10px; }
132
+ .gpu-error-message-container .error-content li { margin-bottom: 6px; }
133
+ .gpu-error-actions { display: flex; gap: 15px; margin-top: 25px; }
134
+ .gpu-error-actions .action-button { padding: 12px 20px; border: none; border-radius: var(--igadlm-alpha-border-radius-md); font-size: 0.95em; font-weight: 600; cursor: pointer; font-family: inherit; width: 100%; box-shadow: var(--shadow-md); transition: var(--transition-smooth); text-transform: none; letter-spacing: normal; }
135
+ .gpu-error-actions .action-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
136
+ .gpu-error-actions .action-button.back-button { background-color: var(--panel-bg); color: var(--text-tertiary); border: 1px solid var(--panel-border); flex-grow: 0.45; }
137
+ .gpu-error-actions .action-button.back-button:hover:not(:disabled) { background-color: var(--input-bg); }
138
+ .gpu-error-actions .action-button.retry-button { background: linear-gradient(60deg, var(--igadlm-alpha-color-primary) 0%, var(--igadlm-alpha-color-secondary) 100%); color: white; flex-grow: 1; }
139
+ .gpu-error-actions .action-button.retry-button:hover:not(:disabled) { background: linear-gradient(60deg, var(--igadlm-alpha-color-primary-darker) 0%, var(--igadlm-alpha-color-secondary-darker) 100%); }
140
+ /* استایل‌های جدید برای بخش اعتبار */
141
+ #credit-info-section {
142
+ margin-top: 1rem;
143
+ padding: 1rem;
144
+ background-color: var(--input-bg);
145
+ border-radius: var(--radius-input);
146
+ text-align: center;
147
+ font-size: 0.95rem;
148
+ font-weight: 500;
149
+ color: var(--text-secondary);
150
+ border: 1px solid var(--input-border);
151
+ display: none; /* در ابتدا مخفی */
152
+ }
153
+ #upgrade-button {
154
+ margin-top: 1rem;
155
+ width: 100%;
156
+ padding: 1rem;
157
+ font-size: 1.1rem;
158
+ font-weight: 700;
159
+ background: linear-gradient(95deg, #FFD54F, #FFC107 100%);
160
+ color: #212529;
161
+ border: none;
162
+ border-radius: var(--radius-btn);
163
+ cursor: pointer;
164
+ box-shadow: 0 8px 20px -5px rgba(255, 193, 7, 0.3);
165
+ display: none; /* در ابتدا مخفی */
166
+ }
167
+ @media (max-width: 768px) { main { padding: 1.5rem; } h1 { font-size: 2.2rem; } .generator-container { height: 250px; } .text-overlay { font-size: 18px; } }
168
+ </style>
169
+ </head>
170
+ <body>
171
+ <div class="container">
172
+ <header>
173
+ <canvas id="neural-network-canvas"></canvas>
174
+ <div class="header-content">
175
+ <!-- ... محتوای هدر بدون تغییر ... -->
176
+ </div>
177
+ </header>
178
+
179
+ <main>
180
+ <!-- ... محتوای فرم بدون تغییر ... -->
181
+ <div class="form-group">
182
+ <label for="prompt" class="form-label">
183
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
184
+ ۲. دستور ساخت ویدیو را بنویسید
185
+ </label>
186
+ <textarea id="prompt" rows="4" placeholder="مثال: زوم آهسته به بیرون در حالی که برگ‌ها در باد می‌رقصند و نور خورشید از بین درختان می‌تابد"></textarea>
187
+
188
+ <!-- بخش جدید برای نمایش اعتبار و دکمه ارتقا -->
189
+ <div id="credit-info-section"></div>
190
+ <button id="upgrade-button">⭐️ ارتقا به نسخه کامل و نامحدود</button>
191
+
192
+ <button id="generateButton">
193
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/></svg>
194
+ <span>ساخت ویدیو جادویی</span>
195
+ </button>
196
+ </div>
197
+ <!-- ... بقیه محتوای فرم ... -->
198
+ </main>
199
+ </div>
200
+
201
+ <script type="module">
202
+ import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
203
+
204
+ (function() {
205
+ // === START: بخش جدید: ارتباط با Iframe و مدیریت اعتبار ===
206
+ let userSubscriptionStatus = 'free'; // 'free' or 'paid'
207
+ let userFingerprint = null;
208
+ let countdownInterval = null;
209
+ const PREMIUM_PAGE_ID = '1149636';
210
+
211
+ // تابع برای تولید اثر انگشت مرورگر
212
+ async function getBrowserFingerprint() {
213
+ const components = [navigator.userAgent, navigator.language, screen.width + 'x' + screen.height, new Date().getTimezoneOffset()];
214
+ try {
215
+ const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d');
216
+ ctx.fillText("a1b2c3d4e5f6g7h8i9j0", 2, 15);
217
+ components.push(canvas.toDataURL());
218
+ } catch (e) { components.push("canvas-error"); }
219
+ const fingerprintString = components.join('---');
220
+ let hash = 0;
221
+ for (let i = 0; i < fingerprintString.length; i++) {
222
+ hash = ((hash << 5) - hash) + fingerprintString.charCodeAt(i);
223
+ hash |= 0;
224
+ }
225
+ return 'fp_' + Math.abs(hash).toString(16);
226
+ }
227
+
228
+ // بررسی پولی بودن کاربر بر اساس آبجکت دریافتی
229
+ function isUserPaid(userObject) {
230
+ return userObject && userObject.isLogin && userObject.accessible_pages &&
231
+ (userObject.accessible_pages.includes(PREMIUM_PAGE_ID) || userObject.accessible_pages.includes(parseInt(PREMIUM_PAGE_ID)));
232
+ }
233
+
234
+ // بروزرسانی UI بر اساس وضعیت اشتراک
235
+ function updateUIForSubscriptionStatus(status) {
236
+ userSubscriptionStatus = status;
237
+ const creditInfoDiv = document.getElementById('credit-info-section');
238
+ const upgradeBtn = document.getElementById('upgrade-button');
239
+ const genBtn = document.getElementById('generateButton');
240
+
241
+ if (status === 'paid') {
242
+ creditInfoDiv.style.display = 'none';
243
+ upgradeBtn.style.display = 'none';
244
+ genBtn.disabled = false;
245
+ } else {
246
+ // برای کاربر رایگان، از بک‌اند وضعیت اعتبار را می‌پرسیم
247
+ checkFreeUserCredit();
248
+ }
249
+ }
250
+
251
+ // چک کردن اعتبار کاربر رایگان از بک‌اند
252
+ async function checkFreeUserCredit() {
253
+ if (!userFingerprint) return;
254
+ const creditInfoDiv = document.getElementById('credit-info-section');
255
+ const upgradeBtn = document.getElementById('upgrade-button');
256
+ const genBtn = document.getElementById('generateButton');
257
+
258
+ try {
259
+ const response = await fetch('/api/check-credit', {
260
+ method: 'POST',
261
+ headers: {'Content-Type': 'application/json'},
262
+ body: JSON.stringify({ fingerprint: userFingerprint })
263
+ });
264
+ const result = await response.json();
265
+
266
+ creditInfoDiv.style.display = 'block';
267
+ if (result.limit_reached) {
268
+ genBtn.disabled = true;
269
+ upgradeBtn.style.display = 'block';
270
+ startCountdown(result.reset_timestamp);
271
+ } else {
272
+ genBtn.disabled = false;
273
+ upgradeBtn.style.display = 'none';
274
+ if(countdownInterval) clearInterval(countdownInterval);
275
+ creditInfoDiv.textContent = `شما ${result.credits_remaining} اعتبار ساخت ویدیوی رایگان در این هفته دارید.`;
276
+ }
277
+ } catch (error) {
278
+ creditInfoDiv.textContent = "خطا در بررسی اعتبار.";
279
+ genBtn.disabled = true;
280
+ }
281
+ }
282
+
283
+ function startCountdown(resetTimestamp) {
284
+ if (countdownInterval) clearInterval(countdownInterval);
285
+ const creditInfoDiv = document.getElementById('credit-info-section');
286
+ const updateTimer = () => {
287
+ const timeLeft = Math.max(0, resetTimestamp - (Date.now() / 1000));
288
+ if (timeLeft === 0) {
289
+ clearInterval(countdownInterval);
290
+ checkFreeUserCredit();
291
+ return;
292
+ }
293
+ const d = Math.floor(timeLeft / 86400), h = Math.floor((timeLeft % 86400) / 3600), m = Math.floor((timeLeft % 3600) / 60), s = Math.floor(timeLeft % 60);
294
+ creditInfoDiv.textContent = `اعتبار شما تمام شده است. زمان باقی‌مانده تا دریافت اعتبار جدید: ${d} روز و ${h} ساعت و ${m} دقیقه`;
295
+ };
296
+ updateTimer();
297
+ countdownInterval = setInterval(updateTimer, 60000); // آپدیت هر دقیقه
298
+ }
299
+
300
+ // گوش دادن به پیام از والد (لودر Iframe)
301
+ window.addEventListener('message', (event) => {
302
+ if (event.data && event.data.type === 'USER_DATA_RESPONSE') {
303
+ if (event.data.error || !event.data.payload) {
304
+ updateUIForSubscriptionStatus('free');
305
+ return;
306
+ }
307
+ try {
308
+ const userObject = JSON.parse(event.data.payload);
309
+ const status = isUserPaid(userObject) ? 'paid' : 'free';
310
+ updateUIForSubscriptionStatus(status);
311
+ } catch (e) {
312
+ updateUIForSubscriptionStatus('free');
313
+ }
314
+ }
315
+ });
316
+
317
+ // درخواست اطلاعات کاربر هنگام بارگذاری صفحه
318
+ window.addEventListener('load', async () => {
319
+ userFingerprint = await getBrowserFingerprint();
320
+ parent.postMessage({ type: 'REQUEST_USER_DATA' }, '*');
321
+ });
322
+
323
+ // رویداد کلیک دکمه ارتقا
324
+ document.getElementById('upgrade-button').addEventListener('click', () => {
325
+ parent.postMessage({ type: 'NAVIGATE_TO_PREMIUM' }, '*');
326
+ });
327
+
328
+ // === END: بخش جدید ===
329
+
330
+
331
+ // ... تمام کدهای جاوااسکریپت قبلی شما برای منطق ساخت ویدیو ...
332
+ // من فقط بخش‌هایی که نیاز به تغییر داشتند را اصلاح می‌کنم
333
+
334
+ const btnDownloadVideo = document.getElementById('btnDownloadVideo');
335
+
336
+ function handleSuccessfulVideoGeneration(result) {
337
+ // ... (کد قبلی شما)
338
+ const videoUrl = result.data[0].video.url;
339
+ // ...
340
+ // این تابع دیگر لینک مستقیم نمی‌سازد، بلکه درخواست را به والد ارسال می‌کند
341
+ prepareCustomDownloadLink(videoUrl);
342
+ }
343
+
344
+ function prepareCustomDownloadLink(videoUrl) {
345
+ btnDownloadVideo.style.display = 'flex';
346
+ btnDownloadVideo.onclick = () => {
347
+ // ارسال پیام به والد (Iframe Loader) برای شروع فرآیند دانلود
348
+ parent.postMessage({
349
+ type: 'DOWNLOAD_REQUEST',
350
+ url: videoUrl
351
+ }, '*');
352
+ };
353
+ }
354
+
355
+ // بازنویسی تابع generateButton.addEventListener('click', ...)
356
+ document.getElementById('generateButton').addEventListener('click', async () => {
357
+ if (document.getElementById('generateButton').disabled) return;
358
+
359
+ const proceedWithGeneration = async () => {
360
+ // این تابع حاوی منطق اصلی ساخت ویدیو شماست
361
+ // ... (تمام کدهای داخل event listener قبلی شما اینجا قرار می‌گیرد)
362
+ };
363
+
364
+ if (userSubscriptionStatus === 'paid') {
365
+ await proceedWithGeneration();
366
+ } else {
367
+ try {
368
+ const response = await fetch('/api/use-credit', {
369
+ method: 'POST',
370
+ headers: {'Content-Type': 'application/json'},
371
+ body: JSON.stringify({ fingerprint: userFingerprint })
372
+ });
373
+
374
+ if (!response.ok) {
375
+ if (response.status === 429) { // Limit reached
376
+ checkFreeUserCredit(); // UI را با پیام اتمام اعتبار آپدیت می‌کند
377
+ } else {
378
+ throw new Error('خطای سرور در بررسی اعتبار.');
379
+ }
380
+ return;
381
+ }
382
+
383
+ await response.json(); // دریافت پاسخ موفق
384
+ await proceedWithGeneration(); // ادامه فرآیند ساخت ویدیو
385
+ checkFreeUserCredit(); // آپدیت تعداد اعتبار باقی‌مانده
386
+
387
+ } catch (err) {
388
+ console.error("Failed to use credit:", err);
389
+ showCriticalError(`خطا در سیستم اعتبار: ${err.message}`);
390
+ }
391
+ }
392
+ });
393
+
394
+ })();
395
+ </script>
396
+
397
+ <!-- ... اسکریپت انیمیشن هدر بدون تغییر ... -->
398
+ </body>
399
+ </html>