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 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
import React, { useState } from 'react';
import { motion } from 'framer-motion';
import { 
  Save,
  Send,
  Eye,
  Calendar,
  Clock,
  Image,
  Layers,
  FileText,
  Video,
  Sparkles,
  ChevronDown,
  Plus,
  X,
  GripVertical,
  RefreshCw,
  ThumbsUp,
  MessageCircle,
  Share2,
  MoreHorizontal,
  Globe,
  Link2,
  Hash,
  AtSign,
  Bold,
  Italic,
  List,
  Smile,
  ImagePlus,
  Trash2,
  ArrowLeft,
  Linkedin
} from 'lucide-react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { Badge } from '@/components/ui/badge';
import { Label } from '@/components/ui/label';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Separator } from '@/components/ui/separator';
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/select';
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from '@/components/ui/popover';
import { Calendar as CalendarComponent } from '@/components/ui/calendar';
import { format } from 'date-fns';
import { Link } from 'react-router-dom';
import { createPageUrl } from '@/utils';

const postTypes = [
  { id: 'carousel', name: 'Carousel', icon: Layers },
  { id: 'cover_content', name: 'Cover Image + Content', icon: Image },
  { id: 'content_only', name: 'Content Only', icon: FileText },
  { id: 'webinar', name: 'Webinar Invite', icon: Video },
];

const products = [
  { id: 'ocr', name: 'Document Parsing (OCR)', shortName: 'OCR' },
  { id: 'p2p', name: 'Purchase To Pay', shortName: 'P2P' },
  { id: 'o2c', name: 'Order to Cash', shortName: 'O2C' },
];

export default function PostEditor() {
  const [postType, setPostType] = useState('carousel');
  const [product, setProduct] = useState('ocr');
  const [content, setContent] = useState(`🚀 Transform Your Document Processing with AI-Powered OCR

Are you still manually processing invoices and documents? 

Here's how our Intelligent Document Parsing solution can revolutionize your workflow:

✅ 99.5% accuracy in data extraction
✅ Process 1000+ documents per hour
✅ Seamless integration with existing systems
✅ Reduce manual errors by 95%

The future of document automation is here. Ready to transform your business?

#DocumentAutomation #OCR #AITechnology #DigitalTransformation #BusinessEfficiency`);
  const [scheduledDate, setScheduledDate] = useState(new Date());
  const [scheduledTime, setScheduledTime] = useState('10:00');
  const [carouselSlides, setCarouselSlides] = useState([
    { id: 1, title: 'Slide 1', hasImage: true },
    { id: 2, title: 'Slide 2', hasImage: true },
    { id: 3, title: 'Slide 3', hasImage: true },
  ]);
  const [selectedAssets, setSelectedAssets] = useState([
    { id: 1, name: 'OCR_Demo.png', type: 'image' },
    { id: 2, name: 'Workflow_Diagram.png', type: 'image' },
  ]);

  const addSlide = () => {
    setCarouselSlides([...carouselSlides, { id: Date.now(), title: `Slide ${carouselSlides.length + 1}`, hasImage: false }]);
  };

  const removeSlide = (id) => {
    setCarouselSlides(carouselSlides.filter(slide => slide.id !== id));
  };

  return (
    <div className="min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50/30">
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        {/* Header */}
        <motion.div 
          initial={{ opacity: 0, y: -20 }}
          animate={{ opacity: 1, y: 0 }}
          className="mb-8"
        >
          <div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
            <div className="flex items-center gap-4">
              <Link to={createPageUrl('Scheduler')}>
                <Button variant="ghost" size="icon" className="h-10 w-10">
                  <ArrowLeft className="w-5 h-5" />
                </Button>
              </Link>
              <div>
                <h1 className="text-2xl font-bold text-slate-900 tracking-tight">
                  Create Post
                </h1>
                <p className="text-slate-500 text-sm mt-0.5">
                  Compose and schedule your LinkedIn content
                </p>
              </div>
            </div>
            <div className="flex gap-3">
              <Button variant="outline" className="gap-2 border-slate-200">
                <Save className="w-4 h-4" />
                Save Draft
              </Button>
              <Button variant="outline" className="gap-2 border-slate-200">
                <Eye className="w-4 h-4" />
                Preview
              </Button>
              <Button className="gap-2 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 shadow-lg shadow-blue-500/25">
                <Send className="w-4 h-4" />
                Schedule Post
              </Button>
            </div>
          </div>
        </motion.div>

        <div className="grid lg:grid-cols-5 gap-6">
          {/* Editor Panel */}
          <motion.div
            initial={{ opacity: 0, x: -20 }}
            animate={{ opacity: 1, x: 0 }}
            className="lg:col-span-3 space-y-6"
          >
            {/* Post Type Selection */}
            <Card className="border-0 shadow-lg shadow-slate-200/50">
              <CardHeader className="pb-4">
                <CardTitle className="text-base font-semibold">Post Type</CardTitle>
              </CardHeader>
              <CardContent>
                <div className="grid grid-cols-2 md:grid-cols-4 gap-3">
                  {postTypes.map(type => (
                    <button
                      key={type.id}
                      onClick={() => setPostType(type.id)}
                      className={`p-4 rounded-xl border-2 transition-all ${
                        postType === type.id
                          ? 'border-blue-500 bg-blue-50'
                          : 'border-slate-200 hover:border-slate-300 bg-white'
                      }`}
                    >
                      <type.icon className={`w-6 h-6 mx-auto mb-2 ${
                        postType === type.id ? 'text-blue-600' : 'text-slate-400'
                      }`} />
                      <p className={`text-sm font-medium ${
                        postType === type.id ? 'text-blue-700' : 'text-slate-600'
                      }`}>
                        {type.name}
                      </p>
                    </button>
                  ))}
                </div>
              </CardContent>
            </Card>

            {/* Content Editor */}
            <Card className="border-0 shadow-lg shadow-slate-200/50">
              <CardHeader className="pb-4">
                <div className="flex items-center justify-between">
                  <CardTitle className="text-base font-semibold">Content</CardTitle>
                  <Button variant="outline" size="sm" className="gap-2 text-violet-600 border-violet-200 hover:bg-violet-50">
                    <Sparkles className="w-4 h-4" />
                    AI Generate
                  </Button>
                </div>
              </CardHeader>
              <CardContent className="space-y-4">
                {/* Formatting Toolbar */}
                <div className="flex items-center gap-1 p-2 bg-slate-50 rounded-lg">
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <Bold className="w-4 h-4" />
                  </Button>
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <Italic className="w-4 h-4" />
                  </Button>
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <List className="w-4 h-4" />
                  </Button>
                  <Separator orientation="vertical" className="h-6 mx-1" />
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <Hash className="w-4 h-4" />
                  </Button>
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <AtSign className="w-4 h-4" />
                  </Button>
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <Link2 className="w-4 h-4" />
                  </Button>
                  <Button variant="ghost" size="icon" className="h-8 w-8">
                    <Smile className="w-4 h-4" />
                  </Button>
                </div>

                <Textarea
                  value={content}
                  onChange={(e) => setContent(e.target.value)}
                  className="min-h-[250px] text-sm leading-relaxed border-slate-200 focus:border-blue-300"
                  placeholder="Write your post content here..."
                />

                <div className="flex items-center justify-between text-sm text-slate-500">
                  <span>{content.length} / 3000 characters</span>
                  <Button variant="ghost" size="sm" className="gap-1 text-blue-600">
                    <RefreshCw className="w-3 h-3" />
                    Regenerate
                  </Button>
                </div>
              </CardContent>
            </Card>

            {/* Carousel Slides (if carousel type) */}
            {postType === 'carousel' && (
              <Card className="border-0 shadow-lg shadow-slate-200/50">
                <CardHeader className="pb-4">
                  <div className="flex items-center justify-between">
                    <CardTitle className="text-base font-semibold">Carousel Slides</CardTitle>
                    <Button onClick={addSlide} variant="outline" size="sm" className="gap-1">
                      <Plus className="w-4 h-4" />
                      Add Slide
                    </Button>
                  </div>
                </CardHeader>
                <CardContent>
                  <div className="space-y-3">
                    {carouselSlides.map((slide, index) => (
                      <motion.div
                        key={slide.id}
                        initial={{ opacity: 0, y: 10 }}
                        animate={{ opacity: 1, y: 0 }}
                        className="flex items-center gap-3 p-3 rounded-xl border border-slate-200 bg-white hover:border-slate-300 transition-colors"
                      >
                        <GripVertical className="w-4 h-4 text-slate-400 cursor-grab" />
                        <div className="w-16 h-16 rounded-lg bg-gradient-to-br from-slate-100 to-slate-50 flex items-center justify-center border border-slate-200">
                          {slide.hasImage ? (
                            <Image className="w-6 h-6 text-slate-400" />
                          ) : (
                            <ImagePlus className="w-6 h-6 text-slate-300" />
                          )}
                        </div>
                        <div className="flex-1">
                          <Input 
                            value={slide.title}
                            className="h-8 text-sm border-0 bg-transparent p-0 font-medium"
                            placeholder="Slide title"
                          />
                          <p className="text-xs text-slate-500 mt-0.5">
                            {slide.hasImage ? 'Image attached' : 'No image'}
                          </p>
                        </div>
                        <Button variant="ghost" size="sm" className="gap-1 text-blue-600">
                          <ImagePlus className="w-4 h-4" />
                          {slide.hasImage ? 'Change' : 'Add'} Image
                        </Button>
                        <Button 
                          variant="ghost" 
                          size="icon" 
                          onClick={() => removeSlide(slide.id)}
                          className="h-8 w-8 text-slate-400 hover:text-red-500"
                        >
                          <Trash2 className="w-4 h-4" />
                        </Button>
                      </motion.div>
                    ))}
                  </div>
                </CardContent>
              </Card>
            )}

            {/* Media Attachments */}
            <Card className="border-0 shadow-lg shadow-slate-200/50">
              <CardHeader className="pb-4">
                <div className="flex items-center justify-between">
                  <CardTitle className="text-base font-semibold">Media from Repository</CardTitle>
                  <Link to={createPageUrl('Repository')}>
                    <Button variant="outline" size="sm" className="gap-1">
                      <Plus className="w-4 h-4" />
                      Browse Assets
                    </Button>
                  </Link>
                </div>
              </CardHeader>
              <CardContent>
                <div className="flex flex-wrap gap-3">
                  {selectedAssets.map(asset => (
                    <div 
                      key={asset.id}
                      className="flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-50 border border-slate-200"
                    >
                      <Image className="w-4 h-4 text-blue-500" />
                      <span className="text-sm text-slate-700">{asset.name}</span>
                      <Button variant="ghost" size="icon" className="h-5 w-5 text-slate-400 hover:text-red-500">
                        <X className="w-3 h-3" />
                      </Button>
                    </div>
                  ))}
                  <button className="flex items-center gap-2 px-3 py-2 rounded-lg border-2 border-dashed border-slate-200 text-slate-500 hover:border-blue-300 hover:text-blue-600 transition-colors">
                    <Plus className="w-4 h-4" />
                    <span className="text-sm">Add from Canva</span>
                  </button>
                </div>
              </CardContent>
            </Card>
          </motion.div>

          {/* Preview & Settings Panel */}
          <motion.div
            initial={{ opacity: 0, x: 20 }}
            animate={{ opacity: 1, x: 0 }}
            className="lg:col-span-2 space-y-6"
          >
            {/* Schedule Settings */}
            <Card className="border-0 shadow-lg shadow-slate-200/50">
              <CardHeader className="pb-4">
                <CardTitle className="text-base font-semibold flex items-center gap-2">
                  <Calendar className="w-4 h-4 text-blue-600" />
                  Schedule
                </CardTitle>
              </CardHeader>
              <CardContent className="space-y-4">
                <div>
                  <Label className="text-sm text-slate-600">Product Category</Label>
                  <Select value={product} onValueChange={setProduct}>
                    <SelectTrigger className="mt-1.5">
                      <SelectValue />
                    </SelectTrigger>
                    <SelectContent>
                      {products.map(p => (
                        <SelectItem key={p.id} value={p.id}>{p.name}</SelectItem>
                      ))}
                    </SelectContent>
                  </Select>
                </div>

                <div className="grid grid-cols-2 gap-3">
                  <div>
                    <Label className="text-sm text-slate-600">Date</Label>
                    <Popover>
                      <PopoverTrigger asChild>
                        <Button variant="outline" className="w-full justify-start mt-1.5 text-left font-normal">
                          <Calendar className="w-4 h-4 mr-2" />
                          {format(scheduledDate, 'MMM d, yyyy')}
                        </Button>
                      </PopoverTrigger>
                      <PopoverContent className="w-auto p-0" align="start">
                        <CalendarComponent
                          mode="single"
                          selected={scheduledDate}
                          onSelect={setScheduledDate}
                        />
                      </PopoverContent>
                    </Popover>
                  </div>
                  <div>
                    <Label className="text-sm text-slate-600">Time</Label>
                    <Select value={scheduledTime} onValueChange={setScheduledTime}>
                      <SelectTrigger className="mt-1.5">
                        <Clock className="w-4 h-4 mr-2" />
                        <SelectValue />
                      </SelectTrigger>
                      <SelectContent>
                        {['09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00'].map(time => (
                          <SelectItem key={time} value={time}>{time}</SelectItem>
                        ))}
                      </SelectContent>
                    </Select>
                  </div>
                </div>
              </CardContent>
            </Card>

            {/* LinkedIn Preview */}
            <Card className="border-0 shadow-lg shadow-slate-200/50 overflow-hidden">
              <CardHeader className="pb-3 bg-gradient-to-r from-[#0A66C2] to-[#004182]">
                <CardTitle className="text-base font-semibold text-white flex items-center gap-2">
                  <Linkedin className="w-4 h-4" />
                  LinkedIn Preview
                </CardTitle>
              </CardHeader>
              <CardContent className="p-0">
                <div className="p-4 bg-white">
                  {/* Post Header */}
                  <div className="flex items-start gap-3">
                    <Avatar className="h-12 w-12">
                      <AvatarImage src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=100&h=100&fit=crop" />
                      <AvatarFallback>AB</AvatarFallback>
                    </Avatar>
                    <div className="flex-1">
                      <p className="font-semibold text-sm text-slate-900">Alex Business</p>
                      <p className="text-xs text-slate-500">Marketing Director at TechCorp</p>
                      <p className="text-xs text-slate-400 flex items-center gap-1 mt-0.5">
                        {format(scheduledDate, 'MMM d')} • <Globe className="w-3 h-3" />
                      </p>
                    </div>
                    <Button variant="ghost" size="icon" className="h-8 w-8">
                      <MoreHorizontal className="w-4 h-4" />
                    </Button>
                  </div>

                  {/* Post Content */}
                  <div className="mt-3 text-sm text-slate-800 whitespace-pre-line leading-relaxed">
                    {content.length > 300 ? content.slice(0, 300) + '...' : content}
                    {content.length > 300 && (
                      <button className="text-blue-600 hover:underline ml-1">see more</button>
                    )}
                  </div>

                  {/* Post Image Preview */}
                  {postType !== 'content_only' && (
                    <div className="mt-3 -mx-4">
                      <div className="aspect-video bg-gradient-to-br from-blue-100 to-indigo-100 flex items-center justify-center">
                        {postType === 'carousel' ? (
                          <div className="text-center">
                            <Layers className="w-12 h-12 text-blue-400 mx-auto mb-2" />
                            <p className="text-sm text-blue-600">{carouselSlides.length} slides</p>
                          </div>
                        ) : (
                          <Image className="w-12 h-12 text-blue-400" />
                        )}
                      </div>
                    </div>
                  )}

                  {/* Engagement Stats */}
                  <div className="flex items-center justify-between mt-3 pt-3 border-t border-slate-100">
                    <div className="flex items-center gap-1 text-xs text-slate-500">
                      <div className="flex -space-x-1">
                        <div className="w-4 h-4 rounded-full bg-blue-500 flex items-center justify-center">
                          <ThumbsUp className="w-2 h-2 text-white" />
                        </div>
                        <div className="w-4 h-4 rounded-full bg-red-500 flex items-center justify-center">
                          <span className="text-[8px]">❤️</span>
                        </div>
                      </div>
                      <span>Preview mode</span>
                    </div>
                    <span className="text-xs text-slate-500">0 comments</span>
                  </div>

                  {/* Action Buttons */}
                  <div className="flex items-center justify-between mt-3 pt-3 border-t border-slate-100">
                    {[
                      { icon: ThumbsUp, label: 'Like' },
                      { icon: MessageCircle, label: 'Comment' },
                      { icon: Share2, label: 'Share' },
                      { icon: Send, label: 'Send' },
                    ].map((action, idx) => (
                      <button 
                        key={idx}
                        className="flex items-center gap-1.5 px-3 py-2 text-slate-600 hover:bg-slate-50 rounded-lg transition-colors"
                      >
                        <action.icon className="w-4 h-4" />
                        <span className="text-xs font-medium">{action.label}</span>
                      </button>
                    ))}
                  </div>
                </div>
              </CardContent>
            </Card>

            {/* Action Buttons */}
            <div className="space-y-3">
              <Button className="w-full gap-2 h-12 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 shadow-lg shadow-blue-500/25">
                <Send className="w-5 h-5" />
                Schedule for {format(scheduledDate, 'MMM d')} at {scheduledTime}
              </Button>
              <Button variant="outline" className="w-full gap-2 h-12 border-slate-200">
                <Eye className="w-5 h-5" />
                Post Immediately
              </Button>
            </div>
          </motion.div>
        </div>
      </div>
    </div>
  );
}