slidecanvas 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -238,14 +238,81 @@ async function extractCaptions(fileBuffer: ArrayBuffer) {
238
238
  ## API Reference
239
239
 
240
240
  ### `<PptEditor />`
241
+ ### Properties
241
242
 
242
- | Prop | Type | Default | Description |
243
+ | Property | Type | Default | Description |
243
244
  | :--- | :--- | :--- | :--- |
244
- | `initialPresentation` | `Presentation` | `undefined` | Load an existing presentation state object. |
245
- | `url` | `string` | `undefined` | Automatically fetch and parse a presentation from a remote URL. |
246
- | `appName` | `string` | `"SlideCanvas"` | Customize the branding in the toolbar. |
247
- | `geminiApiKey` | `string` | `undefined` | Your Google Gemini API key to enable assistant features. |
248
- | `onChange` | `(state: Presentation) => void` | `undefined` | Callback triggered on any slide or element change. |
245
+ | `width` | `number \| string` | **Required** | The width of the editor container. |
246
+ | `height` | `number \| string` | **Required** | The height of the editor container. |
247
+ | `initialPresentation` | `Presentation` | `undefined` | Initial presentation data to load. |
248
+ | `url` | `string` | `undefined` | URL of a public .pptx file to load on mount. |
249
+ | `initialSource` | `'scratch' \| 'uploaded' \| 'url'` | `undefined` | Sets the initial UI source state and badge. |
250
+ | `appName` | `string` | `"SlideCanvas"` | Brand name shown in the ribbon. |
251
+ | `appBgColor` | `string` | `"#B7472A"` | Primary brand color for the UI. |
252
+ | `geminiApiKey` | `string` | `undefined` | API key for built-in AI text actions. |
253
+ | `showHomeOnEmpty` | `boolean` | `false` | Shows a "New / Upload" splash if no data provided. |
254
+ | `onChange` | `(pres: Presentation) => void` | `undefined` | Fired on any change to the deck. |
255
+ | `onSourceChange` | `(src, url?) => void` | `undefined` | Fired when the deck origin changes (useful for routing). |
256
+
257
+ ### Usage Examples
258
+
259
+ #### 1. Branded Full-Screen Editor
260
+ Perfect for a standalone presentation app.
261
+ ```tsx
262
+ import { PptEditor } from 'slidecanvas';
263
+
264
+ export default function MyEditor() {
265
+ return (
266
+ <div style={{ width: '100vw', height: '100vh' }}>
267
+ <PptEditor
268
+ width="100%"
269
+ height="100%"
270
+ appName="SkyDeck"
271
+ appBgColor="#0f172a" // Custom dark theme
272
+ showHomeOnEmpty={true} // Show the splash screen if no PPT loaded
273
+ />
274
+ </div>
275
+ );
276
+ }
277
+ ```
278
+
279
+ #### 2. AI-Powered Assistant
280
+ Enable Gemini-driven text refinements and slide generation.
281
+ ```tsx
282
+ <PptEditor
283
+ width={1200}
284
+ height={800}
285
+ geminiApiKey={process.env.NEXT_PUBLIC_GEMINI_API_KEY}
286
+ appName="AI Slides"
287
+ />
288
+ ```
289
+
290
+ #### 3. Deep-Linking & URL Sync (Next.js)
291
+ Synchronize the editor's source (Scratch, Uploaded, or Remote) with your browser's address bar.
292
+ ```tsx
293
+ const router = useRouter();
294
+ const searchParams = useSearchParams();
295
+
296
+ <PptEditor
297
+ width="100vw"
298
+ height="100vh"
299
+ url={searchParams.get('url')}
300
+ initialSource={searchParams.get('source')} // 'scratch' | 'uploaded' | 'url'
301
+ onSourceChange={(source, url) => {
302
+ // Dynamically update URL as user switches between 'Create New' and 'Upload'
303
+ const query = url ? `?url=${url}` : `?source=${source}`;
304
+ router.push(`/editor${query}`);
305
+ }}
306
+ />
307
+ ```
308
+
309
+ ### Advanced Features
310
+
311
+ #### 🏗️ Visual Shape Selection
312
+ The editor includes a rich selection of 30+ SVG shapes out of the box. The shapes are fully responsive and scale accurately with the editor's dimensions.
313
+
314
+ #### 🔗 Intelligent Routing
315
+ Use the `onSourceChange` callback to synchronize the editor state with your application's routing. This allows for deep-linking to specific presentations or maintaining "Upload" vs "New" states in the address bar.
249
316
 
250
317
  ### `PptxParser` & `PptxExporter`
251
318
 
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import React from 'react';
2
2
 
3
3
  type ElementType = 'text' | 'image' | 'shape';
4
4
  type ShapeType = 'rect' | 'ellipse' | 'triangle' | 'line';
5
+ type PresentationSource = 'scratch' | 'uploaded' | 'url';
5
6
  interface BaseElement {
6
7
  id: string;
7
8
  type: ElementType;
@@ -53,6 +54,12 @@ interface PptEditorProps {
53
54
  appName?: string;
54
55
  onChange?: (presentation: Presentation) => void;
55
56
  geminiApiKey?: string;
57
+ width: number | string;
58
+ height: number | string;
59
+ appBgColor?: string;
60
+ showHomeOnEmpty?: boolean;
61
+ initialSource?: PresentationSource;
62
+ onSourceChange?: (source: PresentationSource, url?: string) => void;
56
63
  }
57
64
  declare const PptEditor: React.FC<PptEditorProps>;
58
65
 
@@ -76,4 +83,4 @@ declare class PptxExporter {
76
83
  export(presentation: Presentation): Promise<void>;
77
84
  }
78
85
 
79
- export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
86
+ export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import React from 'react';
2
2
 
3
3
  type ElementType = 'text' | 'image' | 'shape';
4
4
  type ShapeType = 'rect' | 'ellipse' | 'triangle' | 'line';
5
+ type PresentationSource = 'scratch' | 'uploaded' | 'url';
5
6
  interface BaseElement {
6
7
  id: string;
7
8
  type: ElementType;
@@ -53,6 +54,12 @@ interface PptEditorProps {
53
54
  appName?: string;
54
55
  onChange?: (presentation: Presentation) => void;
55
56
  geminiApiKey?: string;
57
+ width: number | string;
58
+ height: number | string;
59
+ appBgColor?: string;
60
+ showHomeOnEmpty?: boolean;
61
+ initialSource?: PresentationSource;
62
+ onSourceChange?: (source: PresentationSource, url?: string) => void;
56
63
  }
57
64
  declare const PptEditor: React.FC<PptEditorProps>;
58
65
 
@@ -76,4 +83,4 @@ declare class PptxExporter {
76
83
  export(presentation: Presentation): Promise<void>;
77
84
  }
78
85
 
79
- export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
86
+ export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- "use strict";var Oe=Object.create;var ne=Object.defineProperty,He=Object.defineProperties,je=Object.getOwnPropertyDescriptor,Xe=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertyNames,ge=Object.getOwnPropertySymbols,Ge=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var be=(m,o,l)=>o in m?ne(m,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):m[o]=l,w=(m,o)=>{for(var l in o||(o={}))ye.call(o,l)&&be(m,l,o[l]);if(ge)for(var l of ge(o))Ye.call(o,l)&&be(m,l,o[l]);return m},I=(m,o)=>He(m,Xe(o));var _e=(m,o)=>{for(var l in o)ne(m,l,{get:o[l],enumerable:!0})},ve=(m,o,l,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let g of We(o))!ye.call(m,g)&&g!==l&&ne(m,g,{get:()=>o[g],enumerable:!(c=je(o,g))||c.enumerable});return m};var pe=(m,o,l)=>(l=m!=null?Oe(Ge(m)):{},ve(o||!m||!m.__esModule?ne(l,"default",{value:m,enumerable:!0}):l,m)),Ke=m=>ve(ne({},"__esModule",{value:!0}),m);var tt={};_e(tt,{PptEditor:()=>et,PptxExporter:()=>oe,PptxParser:()=>le});module.exports=Ke(tt);var z=require("react");var M=pe(require("react")),x=require("lucide-react");var we=require("clsx"),Ne=require("tailwind-merge");function E(...m){return(0,Ne.twMerge)((0,we.clsx)(m))}var e=require("react/jsx-runtime"),Ve=["Inter","Lato","Open Sans","Poppins","Roboto","Roboto Slab","Georgia","Playfair Display","Merriweather","Nunito Sans","Montserrat","Oswald","Raleway","Ubuntu","Lora","PT Sans","PT Serif","Play","Arvo","Kanit","Times New Roman","Arial"],qe=[12,14,16,18,20,24,28,32,36,48,64,72,96],Je=[{name:"Basic Shapes",shapes:["rect","circle","triangle","rightTriangle","rhombus","parallelogram","trapezoid","pentagon","hexagon","heptagon","octagon","heart","smiley","sun","moon"]},{name:"Arrows",shapes:["arrowRight","arrowLeft","arrowUp","arrowDown","arrowLeftRight","arrowUpDown"]},{name:"Stars & Symbols",shapes:["star4","star5","star6","star8","cloud","lightning"]},{name:"Equation Shapes",shapes:["plus","minus","multiply","divide","equal"]}],Ze=({onAddShape:m})=>{let[o,l]=(0,M.useState)(!1);return M.default.useEffect(()=>(window._toggleShapesMenu=()=>l(!o),()=>{window._toggleShapesMenu=void 0}),[o]),o?(0,e.jsx)("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-2xl shadow-2xl p-4 w-[320px] max-h-[480px] overflow-y-auto z-[100] animate-in fade-in zoom-in-95 duration-200",children:(0,e.jsx)("div",{className:"flex flex-col gap-6",children:Je.map(c=>(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)("span",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 px-1",children:c.name}),(0,e.jsx)("div",{className:"grid grid-cols-5 gap-1",children:c.shapes.map(g=>(0,e.jsx)("button",{onClick:()=>{m(g),l(!1)},className:"aspect-square hover:bg-slate-50 rounded-lg flex items-center justify-center border border-transparent hover:border-slate-100 transition-all group",title:g,children:(0,e.jsx)("div",{className:"w-6 h-6 bg-slate-100 rounded-sm group-hover:bg-blue-100 group-hover:scale-110 transition-all flex items-center justify-center overflow-hidden",children:(0,e.jsx)("div",{className:"text-[8px] font-bold text-slate-400 group-hover:text-blue-600 uppercase text-center scale-[0.8] leading-tight",children:g.slice(0,3)})})},g))})]},c.name))})}):null},Se=({onAddText:m,onAddImage:o,onAddShape:l,onAddSlide:c,onExport:g,onFormatText:p,onDeleteElement:N,onApplyLayout:v,onPlay:f,selectedElement:i,appName:y,onAiAction:a,onAiResponseAction:b,aiResponse:s,isAiLoading:t,onNewPresentation:n,onLoadPresentation:u})=>{let S=M.default.useRef(null),[L,U]=(0,M.useState)("Home"),[O,X]=(0,M.useState)(!1),[W,G]=(0,M.useState)(!1),[Y,P]=(0,M.useState)(!1),[ie,F]=(0,M.useState)(!1),[_,K]=(0,M.useState)("file"),[B,q]=(0,M.useState)(""),T=(i==null?void 0:i.type)==="text",re=(i==null?void 0:i.type)==="shape",ue="#B7472A";return(0,e.jsxs)("div",{className:"flex flex-col border-b border-slate-200 bg-white z-50 select-none",children:[(0,e.jsxs)("div",{className:"flex items-center bg-[#F3F2F1] border-b border-slate-200 h-10",children:[(0,e.jsx)("div",{className:"flex items-center h-full px-4 border-r border-slate-200 mr-2 bg-[#B7472A] text-white",children:(0,e.jsx)("span",{className:"font-black text-xs tracking-tighter capitalize",children:y})}),(0,e.jsxs)("div",{className:"flex h-full relative",children:[(0,e.jsx)("button",{onClick:()=>P(!Y),className:E("px-4 h-10 transition-all flex items-center text-xs font-semibold relative",Y?"text-white bg-[#B7472A]":"text-slate-600 hover:bg-slate-200/50"),children:"File"}),Y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-[140]",onClick:()=>P(!1)}),(0,e.jsxs)("div",{className:"absolute top-10 left-0 w-48 bg-white border border-slate-200 shadow-xl rounded-b-xl z-[150] py-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[(0,e.jsxs)("button",{onClick:()=>{n(),P(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(x.Plus,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Create New"})]}),(0,e.jsxs)("button",{onClick:()=>{F(!0),P(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(x.Download,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Upload"})]}),(0,e.jsx)("div",{className:"h-[1px] bg-slate-100 my-1 mx-2"}),(0,e.jsxs)("button",{onClick:()=>{g(),P(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(x.Share2,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Export PPTX"})]})]})]})]}),(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsxs)("div",{className:"flex items-center gap-4 px-4 text-slate-400",children:[(0,e.jsx)("div",{className:"h-4 w-[1px] bg-slate-200"}),(0,e.jsx)(x.Play,{size:16,className:"cursor-pointer hover:text-[#B7472A] transition-colors",onClick:f})]})]}),(0,e.jsxs)("div",{className:"bg-white h-[96px] flex items-center px-6 gap-8 justify-start",children:[(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 pr-8 py-1 min-w-[140px]",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,e.jsxs)("button",{onClick:c,className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",children:[(0,e.jsx)("div",{className:"bg-orange-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(x.Plus,{size:22,className:"text-[#B7472A]"})}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"New Slide"})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{onClick:()=>X(!O),className:E("p-2 hover:bg-slate-50 rounded-xl transition-all flex flex-col items-center",O&&"bg-slate-100"),children:[(0,e.jsx)(x.Layout,{size:20,className:"text-slate-500"}),(0,e.jsx)("span",{className:"text-[10px] font-medium text-slate-500 mt-1",children:"Layout"})]}),O&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-xl shadow-2xl p-2 w-56 flex flex-col gap-1 z-[100] animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("button",{onClick:()=>{v("title"),X(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.FileText,{size:16,className:"text-blue-500"})," Title Slide"]}),(0,e.jsxs)("button",{onClick:()=>{v("content"),X(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.List,{size:16,className:"text-emerald-500"})," Title & Content"]}),(0,e.jsxs)("button",{onClick:()=>{v("split"),X(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.Columns,{size:16,className:"text-purple-500"})," Two Columns"]})]})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Slides"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2 min-w-[220px]",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("select",{disabled:!T,value:(i==null?void 0:i.fontFamily)||"Arial",onChange:A=>p({fontFamily:A.target.value}),className:"h-8 px-3 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-36 disabled:opacity-50 transition-colors appearance-none cursor-pointer",children:Ve.map(A=>(0,e.jsx)("option",{value:A,children:A},A))}),(0,e.jsx)("select",{disabled:!T,value:(i==null?void 0:i.fontSize)||24,onChange:A=>p({fontSize:parseInt(A.target.value)}),className:"h-8 px-2 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-16 disabled:opacity-50 transition-colors appearance-none cursor-pointer text-center",children:qe.map(A=>(0,e.jsx)("option",{value:A,children:A},A))})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{disabled:!T,onClick:()=>p({isBold:!i.isBold}),className:E("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isBold?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:(0,e.jsx)(x.Bold,{size:16,strokeWidth:3})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>p({isItalic:!i.isItalic}),className:E("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isItalic?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:(0,e.jsx)(x.Italic,{size:16})}),(0,e.jsx)("div",{className:"h-4 w-[1px] bg-slate-200 mx-2"}),(0,e.jsxs)("div",{className:"relative group p-1 hover:bg-slate-50 rounded-lg transition-colors cursor-pointer",children:[(0,e.jsx)("input",{type:"color",disabled:!i,value:T?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6",onChange:A=>p(T?{color:A.target.value}:{fill:A.target.value}),className:"w-8 h-6 p-0 border-0 bg-transparent cursor-pointer disabled:opacity-30",title:"Format Color"}),(0,e.jsx)("div",{className:"absolute bottom-1.5 left-2 right-2 h-1 rounded-full",style:{backgroundColor:T?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6"}})]})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto pt-1",children:"Font"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-1 bg-slate-50 rounded-xl border border-slate-100",children:[(0,e.jsx)("button",{disabled:!T,onClick:()=>p({textAlign:"left"}),className:E("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="left"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:(0,e.jsx)(x.AlignLeft,{size:16})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>p({textAlign:"center"}),className:E("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="center"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:(0,e.jsx)(x.AlignCenter,{size:16})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>p({textAlign:"right"}),className:E("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="right"?"bg-white shadow-sm text-[#B7472A] scale-110":"text-slate-400"),children:(0,e.jsx)(x.AlignRight,{size:16})})]}),(0,e.jsx)("button",{disabled:!T,onClick:()=>p({isBulleted:!i.isBulleted}),className:E("p-2 rounded-lg self-start transition-all disabled:opacity-30",i!=null&&i.isBulleted?"bg-slate-100 text-[#B7472A]":"text-slate-500 hover:bg-slate-50"),children:(0,e.jsx)(x.List,{size:18})})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Paragraph"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(0,e.jsxs)("div",{className:"relative group/shapes",children:[(0,e.jsxs)("button",{className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",onClick:()=>{var A;return(A=window._toggleShapesMenu)==null?void 0:A.call(window)},children:[(0,e.jsx)("div",{className:"bg-blue-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(x.Square,{size:22,className:"text-blue-600"})}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"Shapes"})]}),(0,e.jsx)(Ze,{onAddShape:A=>{l(A)}})]}),(0,e.jsx)("div",{className:"h-10 w-[1px] bg-slate-100 mx-2"}),(0,e.jsx)("button",{onClick:m,className:"p-2.5 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Text Box",children:(0,e.jsx)(x.Type,{size:18})}),(0,e.jsxs)("button",{onClick:()=>{var A;return(A=S.current)==null?void 0:A.click()},className:"p-2.5 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Image",children:[(0,e.jsx)(x.Image,{size:18}),(0,e.jsx)("input",{type:"file",ref:S,className:"hidden",accept:"image/*",onChange:A=>{var Q;return((Q=A.target.files)==null?void 0:Q[0])&&o(A.target.files[0])}})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Drawing"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-8 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>a(i.id,"shorten"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.Sparkles,{size:16,className:"text-purple-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold",children:"Shorten"})]}),(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>a(i.id,"reframe"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.Sparkles,{size:16,className:"text-blue-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold",children:"Reframe"})]}),(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>a(i.id,"lengthen"),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(x.Sparkles,{size:16,className:"text-emerald-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold",children:"Lengthen"})]})]}),t&&(0,e.jsx)("div",{className:"absolute inset-0 bg-white/80 flex items-center justify-center rounded-lg z-10 backdrop-blur-[1px]",children:(0,e.jsx)(x.RefreshCw,{size:18,className:"text-blue-600 animate-spin"})}),s&&(0,e.jsxs)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] bg-white border border-slate-200 rounded-2xl shadow-2xl p-6 z-[200] animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(x.Sparkles,{size:20,className:"text-purple-600"}),(0,e.jsx)("h3",{className:"text-sm font-black text-slate-800 uppercase tracking-widest",children:"AI Generated Response"})]}),(0,e.jsxs)("div",{className:"bg-slate-50 p-4 rounded-xl mb-6 max-h-[200px] overflow-y-auto border border-slate-100 italic text-slate-700 text-sm leading-relaxed",children:['"',s,'"']}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,e.jsx)("button",{onClick:()=>b("replace"),className:"px-4 py-2.5 bg-[#B7472A] text-white text-[11px] font-bold rounded-lg hover:bg-[#a33f25] transition-colors shadow-sm",children:"REPLACE CURRENT"}),(0,e.jsx)("button",{onClick:()=>b("addBelow"),className:"px-4 py-2.5 bg-slate-800 text-white text-[11px] font-bold rounded-lg hover:bg-slate-900 transition-colors shadow-sm",children:"ADD BELOW"})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("button",{onClick:()=>b("regenerate"),className:"flex-1 px-4 py-2.5 border border-slate-200 text-slate-600 text-[11px] font-bold rounded-lg hover:bg-slate-50 transition-colors flex items-center justify-center gap-2",children:[(0,e.jsx)(x.RefreshCw,{size:14})," REGENERATE"]}),(0,e.jsx)("button",{className:"px-4 py-2.5 text-slate-400 text-[11px] font-bold hover:text-slate-600 transition-colors",onClick:()=>{b("replace")},children:"CLOSE"})]})]})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"AI Text"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center px-8 py-1",children:[(0,e.jsxs)("div",{className:"flex gap-3",children:[(0,e.jsx)("button",{onClick:g,className:"flex flex-col items-center justify-center p-2.5 hover:bg-emerald-50 rounded-xl group transition-all",title:"Download Presentation",children:(0,e.jsx)("div",{className:"bg-emerald-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(x.Download,{size:22,className:"text-emerald-700"})})}),i&&(0,e.jsx)("button",{onClick:N,className:"flex flex-col items-center justify-center p-2.5 hover:bg-red-50 rounded-xl group transition-all",title:"Delete Element",children:(0,e.jsx)("div",{className:"bg-red-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(x.Trash2,{size:22,className:"text-red-600"})})})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Actions"})]}),(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsxs)("div",{className:"pr-12 flex flex-col items-end gap-1 group",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] font-black text-slate-300 group-hover:text-[#B7472A] transition-colors",children:[(0,e.jsx)(x.History,{size:12}),(0,e.jsx)("span",{children:"SAVED AUTOMATICALLY"})]}),(0,e.jsx)("div",{className:"h-1 w-24 bg-slate-100 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full w-full bg-emerald-500/20"})})]})]}),ie&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-[2000]",onClick:()=>F(!1)}),(0,e.jsxs)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] bg-white rounded-3xl shadow-2xl z-[2001] border border-slate-200 p-8 animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,e.jsxs)("h3",{className:"text-lg font-black text-slate-800 tracking-tight flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-xl",children:(0,e.jsx)(x.Download,{size:20})}),"Upload Presentation"]}),(0,e.jsx)("button",{onClick:()=>F(!1),className:"text-slate-400 hover:text-slate-600 transition-colors",children:(0,e.jsx)(x.RefreshCw,{size:20,className:"rotate-45"})})]}),(0,e.jsxs)("div",{className:"flex gap-2 p-1 bg-slate-50 rounded-2xl mb-8",children:[(0,e.jsx)("button",{onClick:()=>K("file"),className:E("flex-1 py-3 text-xs font-black rounded-xl transition-all",_==="file"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"FILE UPLOAD"}),(0,e.jsx)("button",{onClick:()=>K("link"),className:E("flex-1 py-3 text-xs font-black rounded-xl transition-all",_==="link"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"LINK UPLOAD"})]}),_==="file"?(0,e.jsxs)("label",{className:"flex flex-col items-center justify-center gap-4 py-12 border-2 border-dashed border-slate-200 rounded-3xl hover:border-blue-400 hover:bg-blue-50/50 transition-all cursor-pointer group",children:[(0,e.jsx)("div",{className:"p-4 bg-white rounded-2xl shadow-sm border border-slate-100 group-hover:scale-110 transition-transform",children:(0,e.jsx)(x.Plus,{size:24,className:"text-blue-500"})}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-slate-700",children:"Choose a PPTX file"}),(0,e.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Maximum file size: 50MB"})]}),(0,e.jsx)("input",{type:"file",accept:".pptx",className:"hidden",onChange:A=>{var de;let Q=(de=A.target.files)==null?void 0:de[0];Q&&(u(Q),F(!1))}})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"relative",children:(0,e.jsx)("input",{type:"text",placeholder:"Paste S3 or public URL",value:B,onChange:A=>q(A.target.value),className:"w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 focus:outline-none focus:ring-4 focus:ring-blue-500/10 focus:border-blue-500 text-sm placeholder:text-slate-400 text-black"})}),(0,e.jsx)("button",{onClick:()=>{B.trim()&&(u(B.trim()),F(!1))},disabled:!B.trim(),className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 text-white font-black py-4 rounded-2xl transition-all shadow-lg shadow-blue-500/20",children:"LOAD PRESENTATION"}),(0,e.jsx)("p",{className:"text-[10px] text-slate-400 text-center uppercase tracking-widest font-black",children:"Supports S3, Dropbox, and public URLS"})]})]})]})]})};var ee=require("lucide-react"),$=require("@dnd-kit/core"),Z=require("@dnd-kit/sortable"),Ae=require("@dnd-kit/utilities");var C=require("react/jsx-runtime"),Qe=({slide:m,index:o,isActive:l,onSelect:c,onDelete:g,onDuplicate:p,showDelete:N})=>{let{attributes:v,listeners:f,setNodeRef:i,transform:y,transition:a,isDragging:b}=(0,Z.useSortable)({id:m.id}),s={transform:Ae.CSS.Transform.toString(y),transition:a,zIndex:b?2:1,opacity:b?.5:1};return(0,C.jsxs)("div",{ref:i,style:s,onClick:c,className:E("cursor-pointer border-[1.5px] rounded-2xl p-2 transition-all duration-300 group relative select-none",l?"border-[#B7472A] bg-white":"border-transparent hover:border-slate-200 bg-white/50 hover:bg-white"),children:[(0,C.jsxs)("div",{className:"text-[10px] font-bold text-slate-400 mb-1 flex items-center justify-between",children:[(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)("div",I(w(w({},v),f),{className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-slate-100 rounded text-slate-300 hover:text-slate-500",children:(0,C.jsx)(ee.GripVertical,{size:10})})),(0,C.jsxs)("span",{children:["SLIDE ",o+1]})]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[l&&(0,C.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-[#B7472A]"}),(0,C.jsxs)("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,C.jsx)("button",{onClick:t=>{t.stopPropagation(),p()},className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-500 rounded transition-all",title:"Duplicate Slide",children:(0,C.jsx)(ee.Copy,{size:12})}),N&&(0,C.jsx)("button",{onClick:t=>{t.stopPropagation(),g()},className:"p-1 hover:bg-red-50 text-red-400 hover:text-red-500 rounded transition-all",title:"Delete Slide",children:(0,C.jsx)(ee.Trash2,{size:12})})]})]})]}),(0,C.jsx)("div",{className:"aspect-video bg-white rounded-xl flex items-center justify-center border border-slate-200 overflow-hidden relative group-hover:shadow-sm transition-shadow",children:(0,C.jsx)("div",{className:"absolute inset-0 origin-top-left pointer-events-none select-none",style:{width:"1200px",height:"675px",transform:"scale(0.165)",backgroundColor:"#ffffff"},children:m.elements.sort((t,n)=>(t.zIndex||0)-(n.zIndex||0)).map(t=>{var u;let n={position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,opacity:(u=t.opacity)!=null?u:1};return t.type==="text"?(0,C.jsx)("div",{style:I(w({},n),{fontSize:t.fontSize,fontFamily:t.fontFamily,color:t.color,textAlign:t.textAlign||"left",fontWeight:t.isBold?"bold":"normal",fontStyle:t.isItalic?"italic":"normal",lineHeight:1.2,overflow:"hidden",wordBreak:"break-word",whiteSpace:"pre-wrap"}),children:t.content},t.id):t.type==="shape"?(0,C.jsx)("div",{style:I(w({},n),{backgroundColor:t.fill,borderRadius:t.shapeType==="ellipse"?"50%":"0"})},t.id):t.type==="image"?(0,C.jsx)("img",{src:t.src,alt:"",style:I(w({},n),{objectFit:"contain"})},t.id):null})})})]})},ke=({slides:m,currentSlideIndex:o,onSelectSlide:l,onDeleteSlide:c,onDuplicateSlide:g,onReorderSlides:p})=>{let N=(0,$.useSensors)((0,$.useSensor)($.PointerSensor,{activationConstraint:{distance:5}}),(0,$.useSensor)($.KeyboardSensor,{coordinateGetter:Z.sortableKeyboardCoordinates}));return(0,C.jsx)("div",{className:"w-64 bg-white border-r border-slate-100 overflow-y-auto p-4 flex flex-col gap-4",children:(0,C.jsx)($.DndContext,{sensors:N,collisionDetection:$.closestCenter,onDragEnd:f=>{let{active:i,over:y}=f;if(i.id!==(y==null?void 0:y.id)){let a=m.findIndex(s=>s.id===i.id),b=m.findIndex(s=>s.id===(y==null?void 0:y.id));p(a,b)}},children:(0,C.jsx)(Z.SortableContext,{items:m.map(f=>f.id),strategy:Z.verticalListSortingStrategy,children:m.map((f,i)=>(0,C.jsx)(Qe,{slide:f,index:i,isActive:i===o,onSelect:()=>l(i),onDelete:()=>c(i),onDuplicate:()=>g(i),showDelete:m.length>1},f.id))})})})};var H=require("react"),j=pe(require("fabric"));var me=require("react/jsx-runtime"),fe=({slide:m,onElementUpdate:o,onSelect:l})=>{let c=(0,H.useRef)(null),g=(0,H.useRef)(null),p=(0,H.useRef)(!1),N=(0,H.useRef)(o),v=(0,H.useRef)(l);return(0,H.useEffect)(()=>{N.current=o,v.current=l},[o,l]),(0,H.useEffect)(()=>{if(c.current&&!g.current){g.current=new j.Canvas(c.current,{width:1200,height:675,backgroundColor:"#ffffff"});let f=g.current,i=s=>{s.left<0&&s.set("left",0),s.top<0&&s.set("top",0);let t=s.getBoundingRect();t.left+t.width>(f.width||1200)&&s.set("left",(f.width||1200)-t.width),t.top+t.height>(f.height||675)&&s.set("top",(f.height||675)-t.height)};f.on("object:moving",s=>i(s.target)),f.on("object:scaling",s=>i(s.target));let y=s=>{var u;if(p.current)return;let t=s.target,n=(u=t.get("data"))==null?void 0:u.id;t&&n&&N.current(n,w({x:t.left,y:t.top,width:t.getScaledWidth(),height:t.getScaledHeight()},t.isType("textbox")?{content:t.text,textAlign:t.textAlign,fontSize:t.fontSize,fontFamily:t.fontFamily,color:t.fill}:{fill:t.fill}))};f.on("object:modified",y),f.on("text:changed",y);let a=s=>{var n,u;let t=((n=s.selected)==null?void 0:n[0])||s.target;if(t){let S=(u=t.get("data"))==null?void 0:u.id;v.current(S)}};f.on("selection:created",a),f.on("selection:updated",a),f.on("selection:cleared",()=>v.current(null));let b=s=>{let t=f.getActiveObject();if(!t||t.isType("textbox")&&t.isEditing)return;let n=s.shiftKey?10:1,u=!1;switch(s.key){case"ArrowLeft":t.set("left",t.left-n),u=!0;break;case"ArrowRight":t.set("left",t.left+n),u=!0;break;case"ArrowUp":t.set("top",t.top-n),u=!0;break;case"ArrowDown":t.set("top",t.top+n),u=!0;break}u&&(i(t),f.requestRenderAll(),y({target:t}))};window.addEventListener("keydown",b),f._keyboardListener=b}return()=>{if(g.current){let f=g.current._keyboardListener;f&&window.removeEventListener("keydown",f),g.current.dispose(),g.current=null}}},[]),(0,H.useEffect)(()=>{if(!g.current)return;let f=g.current;(async()=>{p.current=!0;let y=f.getObjects(),a=new Set(m.elements.map(s=>s.id));y.forEach(s=>{var n;let t=(n=s.get("data"))==null?void 0:n.id;t&&!a.has(t)&&f.remove(s)});let b=[...m.elements].sort((s,t)=>(s.zIndex||0)-(t.zIndex||0));for(let s of b){let t=y.find(n=>{var u;return((u=n.get("data"))==null?void 0:u.id)===s.id});if(t){if(t===f.getActiveObject()&&t.isType("textbox")&&t.isEditing)continue;let n={left:s.x,top:s.y,opacity:s.opacity!==void 0?s.opacity:1,zIndex:s.zIndex};s.type==="text"&&t.isType("textbox")?(n.text=s.content||" ",n.fontSize=s.fontSize||22,n.fill=s.color||"#000000",n.textAlign=s.textAlign||"left",n.fontWeight=s.isBold?"bold":"normal",n.fontStyle=s.isItalic?"italic":"normal",n.fontFamily=s.fontFamily||"Arial",n.width=Math.max(s.width||50,10)):s.type==="shape"?(n.fill=s.fill||"#cccccc",n.scaleX=(s.width||50)/(t.width||1),n.scaleY=(s.height||50)/(t.height||1)):s.type==="image"&&(n.scaleX=(s.width||100)/(t.width||1),n.scaleY=(s.height||100)/(t.height||1)),t.set(n)}else{let n=null,u={left:s.x,top:s.y,data:{id:s.id},originX:"left",originY:"top",opacity:s.opacity!==void 0?s.opacity:1};if(s.type==="text")n=new j.Textbox(s.content||" ",I(w({},u),{width:Math.max(s.width||200,10),fontSize:s.fontSize||22,fill:s.color||"#000000",fontFamily:s.fontFamily||"Inter, Arial, sans-serif",textAlign:s.textAlign||"left",fontWeight:s.isBold?"bold":"normal",fontStyle:s.isItalic?"italic":"normal",splitByGrapheme:!1}));else if(s.type==="shape"){let S=s.fill||"#3b82f6";s.shapeType==="ellipse"?n=new j.Circle(I(w({},u),{radius:(s.width||100)/2,scaleY:(s.height||100)/(s.width||100),fill:S})):n=new j.Rect(I(w({},u),{width:s.width||100,height:s.height||100,fill:S}))}else if(s.type==="image")try{let S=await j.FabricImage.fromURL(s.src);S.set(I(w({},u),{scaleX:(s.width||100)/(S.width||1),scaleY:(s.height||100)/(S.height||1)})),n=S}catch(S){console.error(S)}n&&f.add(n)}}f.renderAll(),p.current=!1})()},[m]),(0,me.jsx)("div",{className:"border border-slate-200 rounded-xl overflow-hidden bg-white",children:(0,me.jsx)("canvas",{ref:c})})};var Ie=pe(require("pptxgenjs"));var oe=class{async export(o){var i,y;let l=new Ie.default,c=((i=o.layout)==null?void 0:i.width)||12192e3,g=((y=o.layout)==null?void 0:y.height)||6858e3,p=1200,N=675,v=a=>a/p*(c/914400),f=a=>a/N*(g/914400);o.slides.forEach(a=>{let b=l.addSlide();[...a.elements].sort((t,n)=>t.zIndex-n.zIndex).forEach(t=>{var S,L;let n=t.opacity!==void 0?(1-t.opacity)*100:0,u={x:v(t.x),y:f(t.y),w:v(t.width),h:f(t.height)};if(t.type==="text")b.addText(t.content,I(w({},u),{fontSize:(t.fontSize||18)/2,color:((S=t.color)==null?void 0:S.replace("#",""))||"000000",fontFace:t.fontFamily||"Arial"}));else if(t.type==="image")b.addImage(I(w({},u),{path:t.src,transparency:n}));else if(t.type==="shape"){let U=t.shapeType==="ellipse"?l.ShapeType.ellipse:l.ShapeType.rect;b.addShape(U,I(w({},u),{fill:{color:((L=t.fill)==null?void 0:L.replace("#",""))||"CCCCCC",transparency:n>0?Math.min(n+10,100):0}}))}})}),await l.writeFile({fileName:"presentation.pptx"})}};var Ce=pe(require("jszip")),le=class{constructor(){this.slideWidth=12192e3;this.slideHeight=6858e3;this.CANVAS_WIDTH=1200;this.CANVAS_HEIGHT=675}async parse(o){var y,a;let l=o;if(typeof o=="string"){let b=await fetch(o);if(!b.ok){let s=b.status,t=b.statusText,n="";try{let u=await b.json();n=u.details||u.error||""}catch(u){}throw new Error(`Failed to fetch PPTX from ${o}: ${s} ${t} ${n?`(${n})`:""}`)}l=await b.arrayBuffer()}let c=await Ce.default.loadAsync(l),g=await((y=c.file("ppt/presentation.xml"))==null?void 0:y.async("string"));if(!g)throw new Error("Invalid PPTX");let N=new DOMParser().parseFromString(g,"text/xml"),v=this.findFirstByLocalName(N,"sldSz");v&&(this.slideWidth=parseInt(this.getAttr(v,"cx")||"12192000"),this.slideHeight=parseInt(this.getAttr(v,"cy")||"6858000"));let f=Array.from(N.getElementsByTagNameNS("*","sldId")),i=[];for(let b=0;b<f.length;b++){let s=b+1,t=`ppt/slides/slide${s}.xml`,n=await((a=c.file(t))==null?void 0:a.async("string"));if(n){let u=await this.parseSlide(n,s,c);i.push(u)}}return{slides:i,layout:{width:this.slideWidth,height:this.slideHeight}}}getAttr(o,l){return o.getAttribute(l)||o.getAttribute(`a:${l}`)||o.getAttribute(`p:${l}`)||o.getAttribute(`r:${l}`)}findFirstByLocalName(o,l){let c=o.getElementsByTagNameNS("*",l);return c.length>0?c[0]:null}findAllByLocalName(o,l){return Array.from(o.getElementsByTagNameNS("*",l))}scaleX(o){return o/this.slideWidth*this.CANVAS_WIDTH}scaleY(o){return o/this.slideHeight*this.CANVAS_HEIGHT}parseColor(o){let l=this.findFirstByLocalName(o,"srgbClr");if(l){let g=`#${this.getAttr(l,"val")}`,p=this.findFirstByLocalName(l,"alpha"),N=p?parseInt(this.getAttr(p,"val")||"100000")/1e5:1;return{color:g,opacity:N}}let c=this.findFirstByLocalName(o,"schemeClr");if(c){let g=this.findFirstByLocalName(c,"alpha");return{color:"#000000",opacity:g?parseInt(this.getAttr(g,"val")||"100000")/1e5:1}}return{color:"#000000",opacity:1}}async resolveImage(o,l,c){var i,y;let g=await((i=c.file(`ppt/slides/_rels/slide${l}.xml.rels`))==null?void 0:i.async("string"));if(!g)return null;let N=new DOMParser().parseFromString(g,"text/xml"),v=Array.from(N.getElementsByTagName("Relationship")).find(a=>a.getAttribute("Id")===o),f=v==null?void 0:v.getAttribute("Target");if(f){let a=(f.startsWith("../")?`ppt/${f.substring(3)}`:`ppt/slides/${f}`).replace("ppt/slides/../","ppt/");return await((y=c.file(a))==null?void 0:y.async("blob"))||null}return null}async parseSlide(o,l,c){let p=new DOMParser().parseFromString(o,"text/xml"),N=[],v=0,f=this.findFirstByLocalName(p,"bg");if(f){let a=this.findFirstByLocalName(f,"blip"),b=(a==null?void 0:a.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(a==null?void 0:a.getAttribute("r:embed"));if(b){let s=await this.resolveImage(b,l,c);s&&N.push({id:`bg-${l}`,type:"image",src:URL.createObjectURL(s),x:0,y:0,width:this.CANVAS_WIDTH,height:this.CANVAS_HEIGHT,zIndex:v++,opacity:1})}}let i=this.findFirstByLocalName(p,"spTree");if(!i)return{id:`slide-${l}`,elements:N};let y=Array.from(i.children);for(let a of y){let b=a.localName;if(b==="sp"){let s=this.findFirstByLocalName(a,"txBody"),t=this.findFirstByLocalName(a,"xfrm"),n=t?this.findFirstByLocalName(t,"off"):null,u=t?this.findFirstByLocalName(t,"ext"):null;if(s&&n&&u){let L=this.findAllByLocalName(s,"p"),U="",O=18,X="#000000",W=1,G=!1;for(let Y of L){let P=this.findFirstByLocalName(Y,"pPr"),ie=P?this.findFirstByLocalName(P,"buNone"):null;P&&!ie&&(this.findFirstByLocalName(P,"buChar")||this.findFirstByLocalName(P,"buAutoNum"))&&(G=!0,U+="\u2022 ");let F=this.findAllByLocalName(Y,"r");for(let _ of F){let K=this.findFirstByLocalName(_,"t");K&&(U+=K.textContent);let B=this.findFirstByLocalName(_,"rPr");if(B){let q=this.getAttr(B,"sz");q&&(O=parseInt(q)/100*2);let T=this.parseColor(B);X=T.color,W=T.opacity}}U+=`
3
- `}if(U.trim()){N.push({id:`el-${l}-${Date.now()}-${v}`,type:"text",content:U.trim(),x:this.scaleX(parseInt(this.getAttr(n,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(n,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(u,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(u,"cy")||"0")),fontSize:O,color:X,fontFamily:"Arial",zIndex:v++,isBulleted:G,opacity:W});continue}}let S=this.findFirstByLocalName(a,"prstGeom");if(S&&n&&u){let L=this.getAttr(S,"prst"),U=this.findFirstByLocalName(a,"spPr"),O=U?this.parseColor(U):{color:"#cccccc",opacity:1};N.push({id:`el-${l}-${Date.now()}-${v}`,type:"shape",shapeType:L==="ellipse"||L==="circle"?"ellipse":"rect",fill:O.color,opacity:O.opacity,x:this.scaleX(parseInt(this.getAttr(n,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(n,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(u,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(u,"cy")||"0")),zIndex:v++})}}if(b==="pic"){let s=this.findFirstByLocalName(a,"blip"),t=(s==null?void 0:s.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(s==null?void 0:s.getAttribute("r:embed")),n=this.findFirstByLocalName(a,"xfrm"),u=n?this.findFirstByLocalName(n,"off"):null,S=n?this.findFirstByLocalName(n,"ext"):null;if(t&&u&&S){let L=await this.resolveImage(t,l,c);L&&N.push({id:`el-${l}-${Date.now()}-${v}`,type:"image",src:URL.createObjectURL(L),x:this.scaleX(parseInt(this.getAttr(u,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(u,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(S,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(S,"cy")||"0")),zIndex:v++,opacity:1})}}}return{id:`slide-${l}`,elements:N}}};var te=require("react"),se=require("lucide-react");var D=require("react/jsx-runtime"),Pe=({presentation:m,initialSlideIndex:o,onClose:l})=>{let[c,g]=(0,te.useState)(o),p=m.slides[c],N=()=>{c>0&&g(c-1)},v=()=>{c<m.slides.length-1&&g(c+1)};(0,te.useEffect)(()=>{let y=a=>{a.key==="ArrowRight"||a.key===" "||a.key==="PageDown"?v():a.key==="ArrowLeft"||a.key==="Backspace"||a.key==="PageUp"?N():a.key==="Escape"&&l()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]);let[f,i]=(0,te.useState)(1);return(0,te.useEffect)(()=>{let y=()=>{let b=window.innerWidth-40,s=window.innerHeight-40,t=1200,n=675,u=b/t,S=s/n,L=Math.min(u,S);i(L)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[]),(0,D.jsxs)("div",{className:"fixed inset-0 z-[99999] bg-[#0A0A0A] flex flex-col items-center justify-center overflow-hidden",children:[(0,D.jsxs)("div",{className:"absolute top-0 left-0 right-0 p-6 flex justify-between items-center opacity-0 hover:opacity-100 transition-opacity bg-gradient-to-b from-black/60 to-transparent z-[100] pointer-events-none",children:[(0,D.jsxs)("div",{className:"text-white/80 font-bold ml-4 pointer-events-auto",children:["Slide ",c+1," of ",m.slides.length]}),(0,D.jsx)("button",{onClick:l,className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-full transition-all pointer-events-auto",children:(0,D.jsx)(se.X,{size:24})})]}),(0,D.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,D.jsx)("div",{className:"relative shadow-2xl shadow-black/80 bg-white",style:{width:"1200px",height:"675px",transform:`scale(${f})`,transformOrigin:"center center"},children:(0,D.jsx)(fe,{slide:p,onElementUpdate:()=>{},onSelect:()=>{}})})}),(0,D.jsxs)("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 flex items-center gap-6 opacity-0 hover:opacity-100 transition-opacity bg-black/40 backdrop-blur-md px-6 py-3 rounded-full border border-white/10 pointer-events-auto",children:[(0,D.jsx)("button",{disabled:c===0,onClick:N,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:(0,D.jsx)(se.ChevronLeft,{size:32})}),(0,D.jsx)("div",{className:"h-6 w-[1px] bg-white/10"}),(0,D.jsx)("button",{disabled:c===m.slides.length-1,onClick:v,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:(0,D.jsx)(se.ChevronRight,{size:32})})]})]})};var ze=require("@google/generative-ai");var V=require("react/jsx-runtime"),et=({initialPresentation:m,url:o,appName:l="SlideCanvas",onChange:c,geminiApiKey:g})=>{let[p,N]=(0,z.useState)(m||{slides:[{id:"slide-1",elements:[]}],layout:{width:12192e3,height:6858e3}}),[v,f]=(0,z.useState)([]),[i,y]=(0,z.useState)([]),[a,b]=(0,z.useState)(0),[s,t]=(0,z.useState)(null),[n,u]=(0,z.useState)(!1),[S,L]=(0,z.useState)(null),[U,O]=(0,z.useState)(!1);(0,z.useEffect)(()=>{o&&xe(o)},[o]);let[X,W]=(0,z.useState)(!1),[G,Y]=(0,z.useState)(null),P=p.slides[a],ie=(0,z.useMemo)(()=>P.elements.find(r=>r.id===s)||null,[P,s]),F=(0,z.useCallback)(r=>{f(d=>[...d.slice(-19),p]),y([]),N(r),c==null||c(r)},[c,p]),_=()=>{if(v.length===0)return;let r=v[v.length-1];y(d=>[...d,p]),f(d=>d.slice(0,-1)),N(r)},K=()=>{if(i.length===0)return;let r=i[i.length-1];f(d=>[...d,p]),y(d=>d.slice(0,-1)),N(r)},B=(0,z.useCallback)(r=>{N(d=>{let h=[...d.slides];h[a]=w(w({},h[a]),r);let k=I(w({},d),{slides:h});return f(R=>[...R.slice(-19),d]),y([]),c==null||c(k),k})},[a,c]),q=(0,z.useCallback)((r,d)=>{N(h=>{let k=h.slides[a],R=k.elements.map(ae=>ae.id===r?w(w({},ae),d):ae),J=[...h.slides];J[a]=I(w({},k),{elements:R});let ce=I(w({},h),{slides:J});return c==null||c(ce),ce})},[a,c]),T=r=>{if(!s)return;if(P.elements.find(h=>h.id===s)){q(s,r);let h=p.slides[a],k=h.elements.map(J=>J.id===s?w(w({},J),r):J),R=[...p.slides];R[a]=I(w({},h),{elements:k}),F(I(w({},p),{slides:R}))}},re=(0,z.useCallback)(()=>{if(!s)return;let d=p.slides[a].elements.filter(h=>h.id!==s);B({elements:d}),t(null)},[s,a,p,B]),ue=()=>{let r={id:`text-${Date.now()}`,type:"text",content:"New Text",x:100,y:100,width:400,height:100,fontSize:48,fontFamily:"Arial",color:"#000000",zIndex:P.elements.length};B({elements:[...P.elements,r]})},A=r=>{let d=URL.createObjectURL(r),h=`img-${Date.now()}`,k={id:h,type:"image",src:d,x:100,y:100,width:400,height:250,zIndex:P.elements.length};B({elements:[...P.elements,k]}),t(h)},Q=r=>{let d={id:`shape-${Date.now()}`,type:"shape",shapeType:r,fill:"#3b82f6",x:200,y:200,width:200,height:200,zIndex:P.elements.length};B({elements:[...P.elements,d]})},de=()=>{let r={id:`slide-${Date.now()}`,elements:[]};F(I(w({},p),{slides:[...p.slides,r]})),b(p.slides.length)},Le=r=>{if(p.slides.length<=1)return;let d=p.slides.filter((h,k)=>k!==r);F(I(w({},p),{slides:d})),r<=a&&b(Math.max(0,a-1))},Te=r=>{let d=p.slides[r],h=I(w({},d),{id:`slide-${Date.now()}`,elements:d.elements.map(R=>I(w({},R),{id:`${R.type}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}))}),k=[...p.slides];k.splice(r+1,0,h),F(I(w({},p),{slides:k})),b(r+1)},Be=(r,d)=>{if(r===d)return;let h=[...p.slides],[k]=h.splice(r,1);h.splice(d,0,k),F(I(w({},p),{slides:h})),a===r?b(d):a>r&&a<=d?b(a-1):a<r&&a>=d&&b(a+1)},De=r=>{let d=[],h=Date.now();r==="title"?d=[{id:`text-title-${h}`,type:"text",content:"Presentation Title",x:100,y:200,width:1e3,height:150,fontSize:80,fontFamily:"Inter",color:"#000000",textAlign:"center",isBold:!0,zIndex:0},{id:`text-sub-${h}`,type:"text",content:"Subtitle goes here",x:200,y:380,width:800,height:80,fontSize:36,fontFamily:"Inter",color:"#64748b",textAlign:"center",zIndex:1}]:r==="content"?d=[{id:`text-title-${h}`,type:"text",content:"Slide Title",x:60,y:40,width:800,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,zIndex:0},{id:`text-body-${h}`,type:"text",content:`\u2022 Add your points here
2
+ "use strict";var et=Object.create;var pe=Object.defineProperty,tt=Object.defineProperties,st=Object.getOwnPropertyDescriptor,at=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertyNames,Le=Object.getOwnPropertySymbols,ot=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var ze=(p,a,l)=>a in p?pe(p,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):p[a]=l,N=(p,a)=>{for(var l in a||(a={}))Ie.call(a,l)&&ze(p,l,a[l]);if(Le)for(var l of Le(a))rt.call(a,l)&&ze(p,l,a[l]);return p},L=(p,a)=>tt(p,at(a));var nt=(p,a)=>{for(var l in a)pe(p,l,{get:a[l],enumerable:!0})},Pe=(p,a,l,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let b of it(a))!Ie.call(p,b)&&b!==l&&pe(p,b,{get:()=>a[b],enumerable:!(f=st(a,b))||f.enumerable});return p};var xe=(p,a,l)=>(l=p!=null?et(ot(p)):{},Pe(a||!p||!p.__esModule?pe(l,"default",{value:p,enumerable:!0}):l,p)),lt=p=>Pe(pe({},"__esModule",{value:!0}),p);var xt={};nt(xt,{PptEditor:()=>ht,PptxExporter:()=>ue,PptxParser:()=>fe});module.exports=lt(xt);var I=require("react");var O=xe(require("react")),m=require("lucide-react");var Be=require("clsx"),Te=require("tailwind-merge");function D(...p){return(0,Te.twMerge)((0,Be.clsx)(p))}var e=require("react/jsx-runtime"),ct=["Inter","Lato","Open Sans","Poppins","Roboto","Roboto Slab","Georgia","Playfair Display","Merriweather","Nunito Sans","Montserrat","Oswald","Raleway","Ubuntu","Lora","PT Sans","PT Serif","Play","Arvo","Kanit","Times New Roman","Arial"],dt=[12,14,16,18,20,24,28,32,36,48,64,72,96],pt=[{name:"Basic Shapes",shapes:["rect","circle","triangle","rightTriangle","rhombus","parallelogram","trapezoid","pentagon","hexagon","heptagon","octagon","heart","smiley","sun","moon"]},{name:"Arrows",shapes:["arrowRight","arrowLeft","arrowUp","arrowDown","arrowLeftRight","arrowUpDown"]},{name:"Stars & Symbols",shapes:["star4","star5","star6","star8","cloud","lightning"]},{name:"Equation Shapes",shapes:["plus","minus","multiply","divide","equal"]}],ut=({type:p,className:a})=>{switch(p){case"rect":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:"currentColor"})});case"circle":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:"currentColor"})});case"triangle":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 4L20 18H4L12 4Z",fill:"currentColor"})});case"rightTriangle":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M4 4V20H20L4 4Z",fill:"currentColor"})});case"rhombus":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 4L20 12L12 20L4 12L12 4Z",fill:"currentColor"})});case"parallelogram":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M7 4H21L17 20H3L7 4Z",fill:"currentColor"})});case"trapezoid":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M6 4H18L21 20H3L6 4Z",fill:"currentColor"})});case"pentagon":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 3L21 9V19H3V9L12 3Z",fill:"currentColor"})});case"hexagon":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5L12 3Z",fill:"currentColor"})});case"heptagon":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 3L18.5 6L21 13L16 20H8L3 13L5.5 6L12 3Z",fill:"currentColor"})});case"octagon":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M8.5 3H15.5L21 8.5V15.5L15.5 21H8.5L3 15.5V8.5L8.5 3Z",fill:"currentColor"})});case"heart":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",fill:"currentColor"})});case"smiley":return(0,e.jsxs)("svg",{viewBox:"0 0 24 24",className:a,children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:"currentColor",fillOpacity:"0.2",stroke:"currentColor",strokeWidth:"2"}),(0,e.jsx)("circle",{cx:"9",cy:"9",r:"1.5",fill:"currentColor"}),(0,e.jsx)("circle",{cx:"15",cy:"9",r:"1.5",fill:"currentColor"}),(0,e.jsx)("path",{d:"M8 15C8 15 9.5 17 12 17C14.5 17 16 15 16 15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"sun":return(0,e.jsxs)("svg",{viewBox:"0 0 24 24",className:a,children:[(0,e.jsx)("circle",{cx:"12",cy:"12",r:"5",fill:"currentColor"}),(0,e.jsx)("path",{d:"M12 2V4M12 20V22M4 12H2M22 12H20M19.07 4.93L17.66 6.34M6.34 17.66L4.93 19.07M4.93 4.93L6.34 6.34M17.66 17.66L19.07 19.07",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"moon":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 3a9 9 0 1 0 9 9 7 7 0 0 1-9-9",fill:"currentColor"})});case"arrowRight":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M4 11h11.5l-3.5-3.5 1.5-1.5 6 6-6 6-1.5-1.5 3.5-3.5H4z",fill:"currentColor"})});case"arrowLeft":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M20 11H8.5l3.5-3.5L10.5 6l-6 6 6 6 1.5-1.5-3.5-3.5H20z",fill:"currentColor"})});case"arrowUp":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M13 20V8.5l3.5 3.5 1.5-1.5-6-6-6 6 1.5 1.5 3.5-3.5V20z",fill:"currentColor"})});case"arrowDown":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M11 4v11.5l-3.5-3.5-1.5 1.5 6 6 6-6-1.5-1.5-3.5 3.5V4z",fill:"currentColor"})});case"arrowLeftRight":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M4 12l4-4v3h8V8l4 4-4 4v-3H8v3l-4-4z",fill:"currentColor"})});case"arrowUpDown":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 4l-4 4h3v8H8l4 4 4-4h-3V8h3l-4-4z",fill:"currentColor"})});case"star4":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 2l2 8 8 2-8 2-2 8-2-8-8-2 8-2 2-8z",fill:"currentColor"})});case"star5":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 2l2.5 7.5H22l-6 4.5 2.5 7.5-6.5-4.5-6.5 4.5 2.5-7.5-6-4.5h7.5L12 2z",fill:"currentColor"})});case"star6":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 2l3 5 6-1-4 4.5 2 6.5-7-3-7 3 2-6.5-4-4.5 6 1 3-5z",fill:"currentColor"})});case"star8":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M12 2l2 4 4-2-2 4 4 2-4 2 2 4-4-2-2 4-2-4-4 2 2-4-4-2 4-2-2-4 4 2 2-4z",fill:"currentColor"})});case"cloud":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M17.5 19c-3 0-5.5-2.5-5.5-5.5 0-.2 0-.4.1-.6-2-.8-3.6-2.5-4.1-4.7C6.5 7.4 5 6 3 6c-1.7 0-3 1.3-3 3s1.3 3 3 3c.4 0 .8-.1 1.2-.2C4.1 13 5 14.5 6.5 15.5c.3 1.8 1.4 3.4 3 4.3.4.2.8.3 1.2.4 1.2.4 2.5.6 3.8.6 4.4 0 8-3.6 8-8s-3.6-8-8-8c-.4 0-.8 0-1.2.1-1.2.2-2.3.7-3.2 1.5C11 4.2 12.4 3.5 14 3.5c4.1 0 7.5 3.4 7.5 7.5s-1.8 7.5-4 8z",fill:"currentColor",transform:"scale(0.8) translate(3,3)"})});case"lightning":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M13 2L3 14h9v8l10-12h-9l3-8z",fill:"currentColor"})});case"plus":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",fill:"currentColor"})});case"minus":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M19 13H5v-2h14v2z",fill:"currentColor"})});case"multiply":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z",fill:"currentColor"})});case"divide":return(0,e.jsxs)("svg",{viewBox:"0 0 24 24",className:a,children:[(0,e.jsx)("circle",{cx:"12",cy:"7",r:"2",fill:"currentColor"}),(0,e.jsx)("circle",{cx:"12",cy:"17",r:"2",fill:"currentColor"}),(0,e.jsx)("rect",{x:"5",y:"11",width:"14",height:"2",fill:"currentColor"})]});case"equal":return(0,e.jsx)("svg",{viewBox:"0 0 24 24",className:a,children:(0,e.jsx)("path",{d:"M19 10H5V8h14v2zm0 6H5v-2h14v2z",fill:"currentColor"})});default:return(0,e.jsx)("div",{className:"w-6 h-6 bg-slate-200 rounded-sm"})}},ft=({onAddShape:p,uiScale:a})=>{let[l,f]=(0,O.useState)(!1);return O.default.useEffect(()=>(window._toggleShapesMenu=()=>f(!l),()=>{window._toggleShapesMenu=void 0}),[l]),l?(0,e.jsx)("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-2xl shadow-2xl p-4 overflow-y-auto z-[100] animate-in fade-in zoom-in-95 duration-200",style:{width:`${320*a}px`,maxHeight:`${480*a}px`},children:(0,e.jsx)("div",{className:"flex flex-col gap-6",children:pt.map(b=>(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)("span",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 px-1",style:{fontSize:`${10*a}px`},children:b.name}),(0,e.jsx)("div",{className:"grid grid-cols-5 gap-1",children:b.shapes.map(h=>(0,e.jsx)("button",{onClick:()=>{p(h),f(!1)},className:"aspect-square hover:bg-slate-50 rounded-lg flex items-center justify-center border border-transparent hover:border-slate-100 transition-all group p-1",title:h,children:(0,e.jsx)("div",{className:"w-full h-full bg-slate-100 rounded-sm group-hover:bg-blue-100 group-hover:scale-110 transition-all flex items-center justify-center overflow-hidden p-1.5",children:(0,e.jsx)(ut,{type:h,className:"w-full h-full text-slate-400 group-hover:text-blue-600 transition-colors"})})},h))})]},b.name))})}):null},De=({onAddText:p,onAddImage:a,onAddShape:l,onAddSlide:f,onExport:b,onFormatText:h,onDeleteElement:k,onApplyLayout:C,onPlay:z,selectedElement:i,appName:y,onAiAction:o,onAiResponseAction:g,aiResponse:w,isAiLoading:t,onNewPresentation:s,onLoadPresentation:r,appBgColor:c="#B7472A",uiScale:x,source:P})=>{let M=O.default.useRef(null),[re,q]=(0,O.useState)("Home"),[E,$]=(0,O.useState)(!1),[G,ne]=(0,O.useState)(!1),[Y,V]=(0,O.useState)(!1),[te,H]=(0,O.useState)(!1),[j,J]=(0,O.useState)("file"),[se,le]=(0,O.useState)(""),T=(i==null?void 0:i.type)==="text",be=(i==null?void 0:i.type)==="shape",ce="#B7472A";return(0,e.jsxs)("div",{className:"flex flex-col border-b border-slate-200 bg-white z-50 select-none pb-1",style:{fontSize:`${12*x}px`},children:[(0,e.jsxs)("div",{className:"flex items-center bg-[#F3F2F1] border-b border-slate-200",style:{height:`${40*x}px`},children:[(0,e.jsx)("div",{className:"flex items-center h-full px-4 border-r border-slate-200 mr-2 text-white",style:{backgroundColor:c},children:(0,e.jsx)("span",{className:"font-black text-xs tracking-tighter capitalize",children:y})}),(0,e.jsxs)("div",{className:"flex h-full relative",children:[(0,e.jsx)("button",{onClick:()=>V(!Y),className:D("px-4 h-10 transition-all flex items-center text-xs font-semibold relative",Y?"text-white":"text-slate-600 hover:bg-slate-200/50"),style:{backgroundColor:Y?c:"transparent"},children:"File"}),Y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 z-[140]",onClick:()=>V(!1)}),(0,e.jsxs)("div",{className:"absolute top-10 left-0 w-48 bg-white border border-slate-200 shadow-xl rounded-b-xl z-[200] py-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[(0,e.jsxs)("button",{onClick:()=>{s(),V(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(m.Plus,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Create New"})]}),(0,e.jsxs)("button",{onClick:()=>{H(!0),V(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(m.Download,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Upload"})]}),(0,e.jsx)("div",{className:"h-[1px] bg-slate-100 my-1 mx-2"}),(0,e.jsxs)("button",{onClick:()=>{b(),V(!1)},className:"w-full text-left px-4 py-2 text-xs text-slate-700 hover:bg-slate-50 flex items-center gap-3 transition-colors",children:[(0,e.jsx)(m.Share2,{size:14,className:"text-slate-400"}),(0,e.jsx)("span",{children:"Export PPTX"})]})]})]})]}),(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 h-full",children:[P&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 bg-white/50 rounded-full border border-slate-200/50 shadow-sm animate-in fade-in slide-in-from-right-2 duration-300",children:[P==="scratch"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.Sparkles,{size:10,className:"text-amber-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Scratch"})]}),P==="uploaded"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.Layout,{size:10,className:"text-blue-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Uploaded"})]}),P==="url"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m.Share2,{size:10,className:"text-emerald-500"}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-tighter",children:"Linked"})]})]}),(0,e.jsx)("div",{className:"h-4 w-[1px] bg-slate-200 mx-1"}),(0,e.jsx)(m.Play,{size:16,className:"text-slate-400 cursor-pointer hover:text-[#B7472A] transition-colors",onClick:z})]})]}),(0,e.jsxs)("div",{className:"bg-white flex items-center px-4 gap-4 justify-start",style:{height:`${96*x}px`},children:[(0,e.jsxs)("div",{className:D("flex flex-col items-center border-r border-slate-100 py-1",x<.84?"px-1.5 min-w-0":"px-3 min-w-[110px]"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 mb-1",children:[(0,e.jsxs)("button",{onClick:f,className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",children:[(0,e.jsx)("div",{className:"bg-orange-50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(m.Plus,{size:22,style:{color:c}})}),(0,e.jsx)("span",{className:"text-[10px] font-bold text-slate-700 mt-1",children:"New Slide"})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{onClick:()=>$(!E),className:D("p-1.5 hover:bg-slate-50 rounded-xl transition-all flex flex-col items-center",E&&"bg-slate-100"),children:[(0,e.jsx)(m.Layout,{size:20,className:"text-slate-500"}),(0,e.jsx)("span",{className:"text-[10px] font-medium text-slate-500 mt-1",children:"Layout"})]}),E&&(0,e.jsxs)("div",{className:"absolute top-full left-0 mt-2 bg-white border border-slate-200 rounded-xl shadow-2xl p-2 w-56 flex flex-col gap-1 z-[100] animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("button",{onClick:()=>{C("title"),$(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.FileText,{size:16,className:"text-blue-500"})," Title Slide"]}),(0,e.jsxs)("button",{onClick:()=>{C("content"),$(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.List,{size:16,className:"text-emerald-500"})," Title & Content"]}),(0,e.jsxs)("button",{onClick:()=>{C("split"),$(!1)},className:"flex items-center gap-3 px-4 py-2.5 hover:bg-slate-50 rounded-lg text-xs font-semibold text-slate-700 transition-colors border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.Columns,{size:16,className:"text-purple-500"})," Two Columns"]})]})]})]}),x>=.85&&(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Slides"})]}),(0,e.jsxs)("div",{className:D("flex flex-col items-center border-r border-slate-100 py-1 pt-1",x<.85?"px-1.5":"px-3"),children:[(0,e.jsxs)("div",{className:D("flex flex-col gap-2",x<.85?"min-w-0":"min-w-[220px]"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("select",{disabled:!T,value:(i==null?void 0:i.fontFamily)||"Arial",onChange:v=>h({fontFamily:v.target.value}),className:D("h-7 px-2 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none disabled:opacity-50 transition-colors appearance-none cursor-pointer",x<.85?"w-24":"w-32"),children:ct.map(v=>(0,e.jsx)("option",{value:v,children:v},v))}),(0,e.jsx)("select",{disabled:!T,value:(i==null?void 0:i.fontSize)||24,onChange:v=>h({fontSize:parseInt(v.target.value)}),className:"h-7 px-1.5 text-xs text-slate-900 border border-slate-200 rounded-lg font-semibold bg-white hover:border-slate-300 outline-none w-14 disabled:opacity-50 transition-colors appearance-none cursor-pointer text-center",children:dt.map(v=>(0,e.jsx)("option",{value:v,children:v},v))})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)("button",{disabled:!T,onClick:()=>h({isBold:!i.isBold}),className:D("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isBold?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:(0,e.jsx)(m.Bold,{size:16,strokeWidth:3})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>h({isItalic:!i.isItalic}),className:D("p-2 rounded-lg transition-all disabled:opacity-30",i!=null&&i.isItalic?"bg-slate-100 text-slate-900":"text-slate-500 hover:bg-slate-50"),children:(0,e.jsx)(m.Italic,{size:16})}),(0,e.jsx)("div",{className:"h-4 w-[1px] bg-slate-200 mx-2"}),(0,e.jsxs)("div",{className:"relative group p-1 hover:bg-slate-50 rounded-lg transition-colors cursor-pointer",children:[(0,e.jsx)("input",{type:"color",disabled:!i,value:T?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6",onChange:v=>h(T?{color:v.target.value}:{fill:v.target.value}),className:"w-8 h-6 p-0 border-0 bg-transparent cursor-pointer disabled:opacity-30",title:"Format Color"}),(0,e.jsx)("div",{className:"absolute bottom-1.5 left-2 right-2 h-1 rounded-full",style:{backgroundColor:T?i.color||"#000000":(i==null?void 0:i.fill)||"#3b82f6"}})]})]})]}),x>=.85&&(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto pt-1",children:"Font"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-4 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-1 bg-slate-50 rounded-xl border border-slate-100",children:[(0,e.jsx)("button",{disabled:!T,onClick:()=>h({textAlign:"left"}),className:D("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="left"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(i==null?void 0:i.textAlign)==="left"?c:void 0},children:(0,e.jsx)(m.AlignLeft,{size:16})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>h({textAlign:"center"}),className:D("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="center"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(i==null?void 0:i.textAlign)==="center"?c:void 0},children:(0,e.jsx)(m.AlignCenter,{size:16})}),(0,e.jsx)("button",{disabled:!T,onClick:()=>h({textAlign:"right"}),className:D("p-1.5 rounded-lg transition-all disabled:opacity-30",(i==null?void 0:i.textAlign)==="right"?"bg-white shadow-sm scale-110":"text-slate-400"),style:{color:(i==null?void 0:i.textAlign)==="right"?c:void 0},children:(0,e.jsx)(m.AlignRight,{size:16})})]}),(0,e.jsx)("button",{disabled:!T,onClick:()=>h({isBulleted:!i.isBulleted}),className:D("p-2 rounded-lg self-start transition-all disabled:opacity-30",i!=null&&i.isBulleted?"bg-slate-100":"text-slate-500 hover:bg-slate-50"),style:{color:i!=null&&i.isBulleted?c:void 0},children:(0,e.jsx)(m.List,{size:18})})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Paragraph"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-3 py-1 shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mb-0.5",children:[(0,e.jsxs)("div",{className:"relative group/shapes",children:[(0,e.jsxs)("button",{className:"flex flex-col items-center justify-center p-2 hover:bg-slate-50 rounded-xl group transition-all",onClick:()=>{var v;return(v=window._toggleShapesMenu)==null?void 0:v.call(window)},children:[(0,e.jsx)("div",{className:"bg-blue-50 p-1.5 rounded-lg group-hover:scale-105 transition-transform",children:(0,e.jsx)(m.Square,{size:20,className:"text-blue-600"})}),(0,e.jsx)("span",{className:"text-[9px] font-bold text-slate-700 mt-1",children:"Shapes"})]}),(0,e.jsx)(ft,{onAddShape:v=>{l(v)},uiScale:x})]}),(0,e.jsx)("div",{className:"h-10 w-[1px] bg-slate-100 mx-2"}),(0,e.jsx)("button",{onClick:p,className:"p-2 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Text Box",children:(0,e.jsx)(m.Type,{size:18})}),(0,e.jsxs)("button",{onClick:()=>{var v;return(v=M.current)==null?void 0:v.click()},className:"p-2 hover:bg-slate-50 rounded-xl text-slate-600 transition-colors",title:"Image",children:[(0,e.jsx)(m.Image,{size:18}),(0,e.jsx)("input",{type:"file",ref:M,className:"hidden",accept:"image/*",onChange:v=>{var Q;return((Q=v.target.files)==null?void 0:Q[0])&&a(v.target.files[0])}})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Drawing"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center border-r border-slate-100 px-4 py-1",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2 relative",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>o(i.id,"shorten"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.Sparkles,{size:14,className:"text-purple-500"}),(0,e.jsx)("span",{className:"text-[9px] font-bold",children:"Shorten"})]}),(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>o(i.id,"reframe"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.Sparkles,{size:14,className:"text-blue-500"}),(0,e.jsx)("span",{className:"text-[9px] font-bold",children:"Reframe"})]}),(0,e.jsxs)("button",{disabled:!T||t,onClick:()=>o(i.id,"lengthen"),className:"flex items-center gap-1.5 px-2 py-1.5 hover:bg-slate-50 rounded-lg text-slate-600 disabled:opacity-20 transition-all group border border-transparent hover:border-slate-100",children:[(0,e.jsx)(m.Sparkles,{size:14,className:"text-emerald-500"}),(0,e.jsx)("span",{className:D("text-[9px] font-bold",x<.85&&"hidden"),children:"Lengthen"})]})]}),t&&(0,e.jsx)("div",{className:"absolute inset-0 bg-white/80 flex items-center justify-center rounded-lg z-10 backdrop-blur-[1px]",children:(0,e.jsx)(m.RefreshCw,{size:18,className:"text-blue-600 animate-spin"})}),w&&(0,e.jsxs)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] bg-white border border-slate-200 rounded-2xl shadow-2xl p-6 z-[200] animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(m.Sparkles,{size:20,className:"text-purple-600"}),(0,e.jsx)("h3",{className:"text-sm font-black text-slate-800 uppercase tracking-widest",children:"AI Generated Response"})]}),(0,e.jsxs)("div",{className:"bg-slate-50 p-4 rounded-xl mb-6 max-h-[200px] overflow-y-auto border border-slate-100 italic text-slate-700 text-sm leading-relaxed",children:['"',w,'"']}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,e.jsx)("button",{onClick:()=>g("replace"),className:"px-4 py-2.5 text-white text-[11px] font-bold rounded-lg transition-colors shadow-sm",style:{backgroundColor:c},children:"REPLACE CURRENT"}),(0,e.jsx)("button",{onClick:()=>g("addBelow"),className:"px-4 py-2.5 bg-slate-800 text-white text-[11px] font-bold rounded-lg hover:bg-slate-900 transition-colors shadow-sm",children:"ADD BELOW"})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)("button",{onClick:()=>g("regenerate"),className:"flex-1 px-4 py-2.5 border border-slate-200 text-slate-600 text-[11px] font-bold rounded-lg hover:bg-slate-50 transition-colors flex items-center justify-center gap-2",children:[(0,e.jsx)(m.RefreshCw,{size:14})," REGENERATE"]}),(0,e.jsx)("button",{className:"px-4 py-2.5 text-slate-400 text-[11px] font-bold hover:text-slate-600 transition-colors",onClick:()=>{g("replace")},children:"CLOSE"})]})]})]})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"AI Text"})]}),(0,e.jsxs)("div",{className:"flex flex-col items-center px-3 py-1",children:[(0,e.jsxs)("div",{className:"flex gap-3",children:[(0,e.jsx)("button",{onClick:b,className:"flex flex-col items-center justify-center p-2.5 hover:bg-emerald-50 rounded-xl group transition-all",title:"Download Presentation",children:(0,e.jsx)("div",{className:"bg-emerald-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(m.Download,{size:22,className:"text-emerald-700"})})}),i&&(0,e.jsx)("button",{onClick:k,className:"flex flex-col items-center justify-center p-2.5 hover:bg-red-50 rounded-xl group transition-all",title:"Delete Element",children:(0,e.jsx)("div",{className:"bg-red-100/50 p-2 rounded-lg group-hover:scale-110 transition-transform",children:(0,e.jsx)(m.Trash2,{size:22,className:"text-red-600"})})})]}),(0,e.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] font-black text-slate-300 mt-auto",children:"Actions"})]}),(0,e.jsx)("div",{className:"flex-1"}),(0,e.jsxs)("div",{className:"pr-12 flex flex-col items-end gap-1 group",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] font-black text-slate-300 transition-colors",style:{color:c},children:[(0,e.jsx)(m.History,{size:12}),(0,e.jsx)("span",{children:"SAVED AUTOMATICALLY"})]}),(0,e.jsx)("div",{className:"h-1 w-24 bg-slate-100 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full w-full bg-emerald-500/20"})})]})]}),te&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"fixed inset-0 bg-slate-900/40 backdrop-blur-sm z-[2000]",onClick:()=>H(!1)}),(0,e.jsxs)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[480px] bg-white rounded-3xl shadow-2xl z-[2001] border border-slate-200 p-8 animate-in fade-in zoom-in-95 duration-200",children:[(0,e.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,e.jsxs)("h3",{className:"text-lg font-black text-slate-800 tracking-tight flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-xl",children:(0,e.jsx)(m.Download,{size:20})}),"Upload Presentation"]}),(0,e.jsx)("button",{onClick:()=>H(!1),className:"text-slate-400 hover:text-slate-600 transition-colors",children:(0,e.jsx)(m.RefreshCw,{size:20,className:"rotate-45"})})]}),(0,e.jsxs)("div",{className:"flex gap-2 p-1 bg-slate-50 rounded-2xl mb-8",children:[(0,e.jsx)("button",{onClick:()=>J("file"),className:D("flex-1 py-3 text-xs font-black rounded-xl transition-all",j==="file"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"FILE UPLOAD"}),(0,e.jsx)("button",{onClick:()=>J("link"),className:D("flex-1 py-3 text-xs font-black rounded-xl transition-all",j==="link"?"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-700"),children:"LINK UPLOAD"})]}),j==="file"?(0,e.jsxs)("label",{className:"flex flex-col items-center justify-center gap-4 py-12 border-2 border-dashed border-slate-200 rounded-3xl hover:border-blue-400 hover:bg-blue-50/50 transition-all cursor-pointer group",children:[(0,e.jsx)("div",{className:"p-4 bg-white rounded-2xl shadow-sm border border-slate-100 group-hover:scale-110 transition-transform",children:(0,e.jsx)(m.Plus,{size:24,className:"text-blue-500"})}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-slate-700",children:"Choose a PPTX file"}),(0,e.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Maximum file size: 50MB"})]}),(0,e.jsx)("input",{type:"file",accept:".pptx",className:"hidden",onChange:v=>{var _;let Q=(_=v.target.files)==null?void 0:_[0];Q&&(r(Q),H(!1))}})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"relative",children:(0,e.jsx)("input",{type:"text",placeholder:"Paste S3 or public URL",value:se,onChange:v=>le(v.target.value),className:"w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 focus:outline-none focus:ring-4 focus:ring-blue-500/10 focus:border-blue-500 text-sm placeholder:text-slate-400 text-black"})}),(0,e.jsx)("button",{onClick:()=>{se.trim()&&(r(se.trim()),H(!1))},disabled:!se.trim(),className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-slate-300 text-white font-black py-4 rounded-2xl transition-all shadow-lg shadow-blue-500/20",children:"LOAD PRESENTATION"}),(0,e.jsx)("p",{className:"text-[10px] text-slate-400 text-center uppercase tracking-widest font-black",children:"Supports S3, Dropbox, and public URLS"})]})]})]})]})};var ae=require("lucide-react"),U=require("@dnd-kit/core"),Z=require("@dnd-kit/sortable"),Fe=require("@dnd-kit/utilities");var B=require("react/jsx-runtime"),mt=({slide:p,index:a,isActive:l,onSelect:f,onDelete:b,onDuplicate:h,showDelete:k,uiScale:C})=>{let{attributes:z,listeners:i,setNodeRef:y,transform:o,transition:g,isDragging:w}=(0,Z.useSortable)({id:p.id}),t={transform:Fe.CSS.Transform.toString(o),transition:g,zIndex:w?2:1,opacity:w?.5:1};return(0,B.jsxs)("div",{ref:y,style:t,onClick:f,className:D("cursor-pointer border-[1.5px] rounded-2xl p-2 transition-all duration-300 group relative select-none",l?"border-[#B7472A] bg-white":"border-transparent hover:border-slate-200 bg-white/50 hover:bg-white"),children:[(0,B.jsxs)("div",{className:"text-[10px] font-bold text-slate-400 mb-1 flex items-center justify-between",children:[(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[(0,B.jsx)("div",L(N(N({},z),i),{className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-slate-100 rounded text-slate-300 hover:text-slate-500",children:(0,B.jsx)(ae.GripVertical,{size:10})})),(0,B.jsxs)("span",{children:["SLIDE ",a+1]})]}),(0,B.jsxs)("div",{className:"flex items-center gap-1",children:[l&&(0,B.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-[#B7472A]"}),(0,B.jsxs)("div",{className:"flex items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,B.jsx)("button",{onClick:s=>{s.stopPropagation(),h()},className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-500 rounded transition-all",title:"Duplicate Slide",children:(0,B.jsx)(ae.Copy,{size:12})}),k&&(0,B.jsx)("button",{onClick:s=>{s.stopPropagation(),b()},className:"p-1 hover:bg-red-50 text-red-400 hover:text-red-500 rounded transition-all",title:"Delete Slide",children:(0,B.jsx)(ae.Trash2,{size:12})})]})]})]}),(0,B.jsx)("div",{className:"aspect-video bg-white rounded-xl flex items-center justify-center border border-slate-200 overflow-hidden relative group-hover:shadow-sm transition-shadow",children:(0,B.jsx)("div",{className:"origin-center pointer-events-none select-none shrink-0",style:{width:"1200px",height:"675px",transform:`scale(${180*C/1200})`,backgroundColor:"#ffffff"},children:p.elements.sort((s,r)=>(s.zIndex||0)-(r.zIndex||0)).map(s=>{var c;let r={position:"absolute",left:s.x,top:s.y,width:s.width,height:s.height,opacity:(c=s.opacity)!=null?c:1};return s.type==="text"?(0,B.jsx)("div",{style:L(N({},r),{fontSize:s.fontSize,fontFamily:s.fontFamily,color:s.color,textAlign:s.textAlign||"left",fontWeight:s.isBold?"bold":"normal",fontStyle:s.isItalic?"italic":"normal",lineHeight:1.2,overflow:"hidden",wordBreak:"break-word",whiteSpace:"pre-wrap"}),children:s.content},s.id):s.type==="shape"?(0,B.jsx)("div",{style:L(N({},r),{backgroundColor:s.fill,borderRadius:s.shapeType==="ellipse"?"50%":"0"})},s.id):s.type==="image"?(0,B.jsx)("img",{src:s.src,alt:"",style:L(N({},r),{objectFit:"contain"})},s.id):null})})})]})},Me=({slides:p,currentSlideIndex:a,onSelectSlide:l,onDeleteSlide:f,onDuplicateSlide:b,onReorderSlides:h,uiScale:k})=>{let C=(0,U.useSensors)((0,U.useSensor)(U.PointerSensor,{activationConstraint:{distance:5}}),(0,U.useSensor)(U.KeyboardSensor,{coordinateGetter:Z.sortableKeyboardCoordinates})),z=i=>{let{active:y,over:o}=i;if(y.id!==(o==null?void 0:o.id)){let g=p.findIndex(t=>t.id===y.id),w=p.findIndex(t=>t.id===(o==null?void 0:o.id));h(g,w)}};return(0,B.jsx)("div",{className:"bg-white border-r border-slate-100 overflow-y-auto p-4 flex flex-col gap-4",style:{width:`${256*k}px`},children:(0,B.jsx)(U.DndContext,{sensors:C,collisionDetection:U.closestCenter,onDragEnd:z,children:(0,B.jsx)(Z.SortableContext,{items:p.map(i=>i.id),strategy:Z.verticalListSortingStrategy,children:p.map((i,y)=>(0,B.jsx)(mt,{slide:i,index:y,isActive:y===a,onSelect:()=>l(y),onDelete:()=>f(y),onDuplicate:()=>b(y),showDelete:p.length>1,uiScale:k},i.id))})})})};var W=require("react"),X=xe(require("fabric"));var Se=require("react/jsx-runtime"),ge=({slide:p,onElementUpdate:a,onSelect:l,uiScale:f})=>{let b=(0,W.useRef)(null),h=(0,W.useRef)(null),k=(0,W.useRef)(!1),C=(0,W.useRef)(a),z=(0,W.useRef)(l);return(0,W.useEffect)(()=>{C.current=a,z.current=l},[a,l]),(0,W.useEffect)(()=>{if(b.current&&!h.current){h.current=new X.Canvas(b.current,{width:1200,height:675,backgroundColor:"#ffffff"});let i=h.current,y=t=>{t.left<0&&t.set("left",0),t.top<0&&t.set("top",0);let s=t.getBoundingRect();s.left+s.width>(i.width||1200)&&t.set("left",(i.width||1200)-s.width),s.top+s.height>(i.height||675)&&t.set("top",(i.height||675)-s.height)};i.on("object:moving",t=>y(t.target)),i.on("object:scaling",t=>y(t.target));let o=t=>{var c;if(k.current)return;let s=t.target,r=(c=s.get("data"))==null?void 0:c.id;s&&r&&C.current(r,N({x:s.left,y:s.top,width:s.getScaledWidth(),height:s.getScaledHeight()},s.isType("textbox")?{content:s.text,textAlign:s.textAlign,fontSize:s.fontSize,fontFamily:s.fontFamily,color:s.fill}:{fill:s.fill}))};i.on("object:modified",o),i.on("text:changed",o);let g=t=>{var r,c;let s=((r=t.selected)==null?void 0:r[0])||t.target;if(s){let x=(c=s.get("data"))==null?void 0:c.id;z.current(x)}};i.on("selection:created",g),i.on("selection:updated",g),i.on("selection:cleared",()=>z.current(null));let w=t=>{let s=i.getActiveObject();if(!s||s.isType("textbox")&&s.isEditing)return;let r=t.shiftKey?10:1,c=!1;switch(t.key){case"ArrowLeft":s.set("left",s.left-r),c=!0;break;case"ArrowRight":s.set("left",s.left+r),c=!0;break;case"ArrowUp":s.set("top",s.top-r),c=!0;break;case"ArrowDown":s.set("top",s.top+r),c=!0;break}c&&(y(s),i.requestRenderAll(),o({target:s}))};window.addEventListener("keydown",w),i._keyboardListener=w}return()=>{if(h.current){let i=h.current._keyboardListener;i&&window.removeEventListener("keydown",i),h.current.dispose(),h.current=null}}},[]),(0,W.useEffect)(()=>{if(!h.current)return;let i=h.current;(async()=>{k.current=!0;let o=i.getObjects(),g=new Set(p.elements.map(t=>t.id));o.forEach(t=>{var r;let s=(r=t.get("data"))==null?void 0:r.id;s&&!g.has(s)&&i.remove(t)});let w=[...p.elements].sort((t,s)=>(t.zIndex||0)-(s.zIndex||0));for(let t of w){let s=o.find(r=>{var c;return((c=r.get("data"))==null?void 0:c.id)===t.id});if(s){if(s===i.getActiveObject()&&s.isType("textbox")&&s.isEditing)continue;let r={left:t.x,top:t.y,opacity:t.opacity!==void 0?t.opacity:1,zIndex:t.zIndex};t.type==="text"&&s.isType("textbox")?(r.text=t.content||" ",r.fontSize=t.fontSize||22,r.fill=t.color||"#000000",r.textAlign=t.textAlign||"left",r.fontWeight=t.isBold?"bold":"normal",r.fontStyle=t.isItalic?"italic":"normal",r.fontFamily=t.fontFamily||"Arial",r.width=Math.max(t.width||50,10)):t.type==="shape"?(r.fill=t.fill||"#cccccc",r.scaleX=(t.width||50)/(s.width||1),r.scaleY=(t.height||50)/(s.height||1)):t.type==="image"&&(r.scaleX=(t.width||100)/(s.width||1),r.scaleY=(t.height||100)/(s.height||1)),s.set(r)}else{let r=null,c={left:t.x,top:t.y,data:{id:t.id},originX:"left",originY:"top",opacity:t.opacity!==void 0?t.opacity:1};if(t.type==="text")r=new X.Textbox(t.content||" ",L(N({},c),{width:Math.max(t.width||200,10),fontSize:t.fontSize||22,fill:t.color||"#000000",fontFamily:t.fontFamily||"Inter, Arial, sans-serif",textAlign:t.textAlign||"left",fontWeight:t.isBold?"bold":"normal",fontStyle:t.isItalic?"italic":"normal",splitByGrapheme:!1}));else if(t.type==="shape"){let x=t.fill||"#3b82f6";t.shapeType==="ellipse"?r=new X.Circle(L(N({},c),{radius:(t.width||100)/2,scaleY:(t.height||100)/(t.width||100),fill:x})):r=new X.Rect(L(N({},c),{width:t.width||100,height:t.height||100,fill:x}))}else if(t.type==="image")try{let x=await X.FabricImage.fromURL(t.src);x.set(L(N({},c),{scaleX:(t.width||100)/(x.width||1),scaleY:(t.height||100)/(x.height||1)})),r=x}catch(x){console.error(x)}r&&i.add(r)}}i.renderAll(),k.current=!1})()},[p]),(0,Se.jsx)("div",{className:"border border-slate-200 overflow-hidden bg-white shadow-lg transition-transform duration-300",style:{transform:`scale(${f*.8})`,transformOrigin:"center center"},children:(0,Se.jsx)("canvas",{ref:b})})};var Re=xe(require("pptxgenjs"));var ue=class{async export(a){var i,y;let l=new Re.default,f=((i=a.layout)==null?void 0:i.width)||12192e3,b=((y=a.layout)==null?void 0:y.height)||6858e3,h=1200,k=675,C=o=>o/h*(f/914400),z=o=>o/k*(b/914400);a.slides.forEach(o=>{let g=l.addSlide();[...o.elements].sort((t,s)=>t.zIndex-s.zIndex).forEach(t=>{var c,x;let s=t.opacity!==void 0?(1-t.opacity)*100:0,r={x:C(t.x),y:z(t.y),w:C(t.width),h:z(t.height)};if(t.type==="text")g.addText(t.content,L(N({},r),{fontSize:(t.fontSize||18)/2,color:((c=t.color)==null?void 0:c.replace("#",""))||"000000",fontFace:t.fontFamily||"Arial"}));else if(t.type==="image")g.addImage(L(N({},r),{path:t.src,transparency:s}));else if(t.type==="shape"){let P=t.shapeType==="ellipse"?l.ShapeType.ellipse:l.ShapeType.rect;g.addShape(P,L(N({},r),{fill:{color:((x=t.fill)==null?void 0:x.replace("#",""))||"CCCCCC",transparency:s>0?Math.min(s+10,100):0}}))}})}),await l.writeFile({fileName:"presentation.pptx"})}};var $e=xe(require("jszip")),fe=class{constructor(){this.slideWidth=12192e3;this.slideHeight=6858e3;this.CANVAS_WIDTH=1200;this.CANVAS_HEIGHT=675}async parse(a){var y,o;let l=a;if(typeof a=="string"){let g=await fetch(a);if(!g.ok){let w=g.status,t=g.statusText,s="";try{let r=await g.json();s=r.details||r.error||""}catch(r){}throw new Error(`Failed to fetch PPTX from ${a}: ${w} ${t} ${s?`(${s})`:""}`)}l=await g.arrayBuffer()}let f=await $e.default.loadAsync(l),b=await((y=f.file("ppt/presentation.xml"))==null?void 0:y.async("string"));if(!b)throw new Error("Invalid PPTX");let k=new DOMParser().parseFromString(b,"text/xml"),C=this.findFirstByLocalName(k,"sldSz");C&&(this.slideWidth=parseInt(this.getAttr(C,"cx")||"12192000"),this.slideHeight=parseInt(this.getAttr(C,"cy")||"6858000"));let z=Array.from(k.getElementsByTagNameNS("*","sldId")),i=[];for(let g=0;g<z.length;g++){let w=g+1,t=`ppt/slides/slide${w}.xml`,s=await((o=f.file(t))==null?void 0:o.async("string"));if(s){let r=await this.parseSlide(s,w,f);i.push(r)}}return{slides:i,layout:{width:this.slideWidth,height:this.slideHeight}}}getAttr(a,l){return a.getAttribute(l)||a.getAttribute(`a:${l}`)||a.getAttribute(`p:${l}`)||a.getAttribute(`r:${l}`)}findFirstByLocalName(a,l){let f=a.getElementsByTagNameNS("*",l);return f.length>0?f[0]:null}findAllByLocalName(a,l){return Array.from(a.getElementsByTagNameNS("*",l))}scaleX(a){return a/this.slideWidth*this.CANVAS_WIDTH}scaleY(a){return a/this.slideHeight*this.CANVAS_HEIGHT}parseColor(a){let l=this.findFirstByLocalName(a,"srgbClr");if(l){let b=`#${this.getAttr(l,"val")}`,h=this.findFirstByLocalName(l,"alpha"),k=h?parseInt(this.getAttr(h,"val")||"100000")/1e5:1;return{color:b,opacity:k}}let f=this.findFirstByLocalName(a,"schemeClr");if(f){let b=this.findFirstByLocalName(f,"alpha");return{color:"#000000",opacity:b?parseInt(this.getAttr(b,"val")||"100000")/1e5:1}}return{color:"#000000",opacity:1}}async resolveImage(a,l,f){var i,y;let b=await((i=f.file(`ppt/slides/_rels/slide${l}.xml.rels`))==null?void 0:i.async("string"));if(!b)return null;let k=new DOMParser().parseFromString(b,"text/xml"),C=Array.from(k.getElementsByTagName("Relationship")).find(o=>o.getAttribute("Id")===a),z=C==null?void 0:C.getAttribute("Target");if(z){let o=(z.startsWith("../")?`ppt/${z.substring(3)}`:`ppt/slides/${z}`).replace("ppt/slides/../","ppt/");return await((y=f.file(o))==null?void 0:y.async("blob"))||null}return null}async parseSlide(a,l,f){let h=new DOMParser().parseFromString(a,"text/xml"),k=[],C=0,z=this.findFirstByLocalName(h,"bg");if(z){let o=this.findFirstByLocalName(z,"blip"),g=(o==null?void 0:o.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(o==null?void 0:o.getAttribute("r:embed"));if(g){let w=await this.resolveImage(g,l,f);w&&k.push({id:`bg-${l}`,type:"image",src:URL.createObjectURL(w),x:0,y:0,width:this.CANVAS_WIDTH,height:this.CANVAS_HEIGHT,zIndex:C++,opacity:1})}}let i=this.findFirstByLocalName(h,"spTree");if(!i)return{id:`slide-${l}`,elements:k};let y=Array.from(i.children);for(let o of y){let g=o.localName;if(g==="sp"){let w=this.findFirstByLocalName(o,"txBody"),t=this.findFirstByLocalName(o,"xfrm"),s=t?this.findFirstByLocalName(t,"off"):null,r=t?this.findFirstByLocalName(t,"ext"):null;if(w&&s&&r){let x=this.findAllByLocalName(w,"p"),P="",M=18,re="#000000",q=1,E=!1;for(let $ of x){let G=this.findFirstByLocalName($,"pPr"),ne=G?this.findFirstByLocalName(G,"buNone"):null;G&&!ne&&(this.findFirstByLocalName(G,"buChar")||this.findFirstByLocalName(G,"buAutoNum"))&&(E=!0,P+="\u2022 ");let Y=this.findAllByLocalName($,"r");for(let V of Y){let te=this.findFirstByLocalName(V,"t");te&&(P+=te.textContent);let H=this.findFirstByLocalName(V,"rPr");if(H){let j=this.getAttr(H,"sz");j&&(M=parseInt(j)/100*2);let J=this.parseColor(H);re=J.color,q=J.opacity}}P+=`
3
+ `}if(P.trim()){k.push({id:`el-${l}-${Date.now()}-${C}`,type:"text",content:P.trim(),x:this.scaleX(parseInt(this.getAttr(s,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(s,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(r,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(r,"cy")||"0")),fontSize:M,color:re,fontFamily:"Arial",zIndex:C++,isBulleted:E,opacity:q});continue}}let c=this.findFirstByLocalName(o,"prstGeom");if(c&&s&&r){let x=this.getAttr(c,"prst"),P=this.findFirstByLocalName(o,"spPr"),M=P?this.parseColor(P):{color:"#cccccc",opacity:1};k.push({id:`el-${l}-${Date.now()}-${C}`,type:"shape",shapeType:x==="ellipse"||x==="circle"?"ellipse":"rect",fill:M.color,opacity:M.opacity,x:this.scaleX(parseInt(this.getAttr(s,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(s,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(r,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(r,"cy")||"0")),zIndex:C++})}}if(g==="pic"){let w=this.findFirstByLocalName(o,"blip"),t=(w==null?void 0:w.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed"))||(w==null?void 0:w.getAttribute("r:embed")),s=this.findFirstByLocalName(o,"xfrm"),r=s?this.findFirstByLocalName(s,"off"):null,c=s?this.findFirstByLocalName(s,"ext"):null;if(t&&r&&c){let x=await this.resolveImage(t,l,f);x&&k.push({id:`el-${l}-${Date.now()}-${C}`,type:"image",src:URL.createObjectURL(x),x:this.scaleX(parseInt(this.getAttr(r,"x")||"0")),y:this.scaleY(parseInt(this.getAttr(r,"y")||"0")),width:this.scaleX(parseInt(this.getAttr(c,"cx")||"0")),height:this.scaleY(parseInt(this.getAttr(c,"cy")||"0")),zIndex:C++,opacity:1})}}}return{id:`slide-${l}`,elements:k}}};var ie=require("react"),oe=require("lucide-react");var F=require("react/jsx-runtime"),He=({presentation:p,initialSlideIndex:a,onClose:l})=>{let[f,b]=(0,ie.useState)(a),h=p.slides[f],k=()=>{f>0&&b(f-1)},C=()=>{f<p.slides.length-1&&b(f+1)};(0,ie.useEffect)(()=>{let y=o=>{o.key==="ArrowRight"||o.key===" "||o.key==="PageDown"?C():o.key==="ArrowLeft"||o.key==="Backspace"||o.key==="PageUp"?k():o.key==="Escape"&&l()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[f]);let[z,i]=(0,ie.useState)(1);return(0,ie.useEffect)(()=>{let y=()=>{let g=window.innerWidth-40,w=window.innerHeight-40,t=1200,s=675,r=g/t,c=w/s,x=Math.min(r,c);i(x)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[]),(0,F.jsxs)("div",{className:"fixed inset-0 z-[99999] bg-[#0A0A0A] flex flex-col items-center justify-center overflow-hidden",children:[(0,F.jsxs)("div",{className:"absolute top-0 left-0 right-0 p-6 flex justify-between items-center opacity-0 hover:opacity-100 transition-opacity bg-gradient-to-b from-black/60 to-transparent z-[100] pointer-events-none",children:[(0,F.jsxs)("div",{className:"text-white/80 font-bold ml-4 pointer-events-auto",children:["Slide ",f+1," of ",p.slides.length]}),(0,F.jsx)("button",{onClick:l,className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-full transition-all pointer-events-auto",children:(0,F.jsx)(oe.X,{size:24})})]}),(0,F.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,F.jsx)("div",{className:"relative shadow-2xl shadow-black/80 bg-white",style:{width:"1200px",height:"675px",transform:`scale(${z})`,transformOrigin:"center center"},children:(0,F.jsx)(ge,{slide:h,onElementUpdate:()=>{},onSelect:()=>{},uiScale:.75})})}),(0,F.jsxs)("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 flex items-center gap-6 opacity-0 hover:opacity-100 transition-opacity bg-black/40 backdrop-blur-md px-6 py-3 rounded-full border border-white/10 pointer-events-auto",children:[(0,F.jsx)("button",{disabled:f===0,onClick:k,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:(0,F.jsx)(oe.ChevronLeft,{size:32})}),(0,F.jsx)("div",{className:"h-6 w-[1px] bg-white/10"}),(0,F.jsx)("button",{disabled:f===p.slides.length-1,onClick:C,className:"p-2 text-white/50 hover:text-white disabled:opacity-20 transition-colors",children:(0,F.jsx)(oe.ChevronRight,{size:32})})]})]})};var Ue=require("@google/generative-ai");var S=require("react/jsx-runtime"),ht=({initialPresentation:p,url:a,appName:l="SlideCanvas",onChange:f,geminiApiKey:b,width:h,height:k,appBgColor:C="#B7472A",showHomeOnEmpty:z=!1,initialSource:i,onSourceChange:y})=>{let[o,g]=(0,I.useState)(p||{slides:[{id:"slide-1",elements:[]}],layout:{width:12192e3,height:6858e3}}),[w,t]=(0,I.useState)([]),[s,r]=(0,I.useState)([]),[c,x]=(0,I.useState)(0),[P,M]=(0,I.useState)(null),[re,q]=(0,I.useState)(!1),[E,$]=(0,I.useState)(null),[G,ne]=(0,I.useState)(!1),[Y,V]=(0,I.useState)(i||(a?"url":null)),[te,H]=(0,I.useState)(z&&!p&&!a&&!i),[j,J]=(0,I.useState)("");(0,I.useEffect)(()=>{a&&me(a)},[a]);let[se,le]=(0,I.useState)(!1),[T,be]=(0,I.useState)(null),ce=(0,I.useMemo)(()=>{let n=typeof h=="number"?h:parseInt(String(h));return isNaN(n)?1:Math.min(Math.max(n/1600,.7),1)},[h]),v=o.slides[c],Q=(0,I.useMemo)(()=>v.elements.find(n=>n.id===P)||null,[v,P]),_=(0,I.useCallback)(n=>{t(d=>[...d.slice(-19),o]),r([]),g(n),f==null||f(n)},[f,o]),ke=()=>{if(w.length===0)return;let n=w[w.length-1];r(d=>[...d,o]),t(d=>d.slice(0,-1)),g(n)},ve=()=>{if(s.length===0)return;let n=s[s.length-1];t(d=>[...d,o]),r(d=>d.slice(0,-1)),g(n)},ee=(0,I.useCallback)(n=>{g(d=>{let u=[...d.slides];u[c]=N(N({},u[c]),n);let A=L(N({},d),{slides:u});return t(R=>[...R.slice(-19),d]),r([]),f==null||f(A),A})},[c,f]),ye=(0,I.useCallback)((n,d)=>{g(u=>{let A=u.slides[c],R=A.elements.map(de=>de.id===n?N(N({},de),d):de),K=[...u.slides];K[c]=L(N({},A),{elements:R});let he=L(N({},u),{slides:K});return f==null||f(he),he})},[c,f]),Oe=n=>{if(!P)return;if(v.elements.find(u=>u.id===P)){ye(P,n);let u=o.slides[c],A=u.elements.map(K=>K.id===P?N(N({},K),n):K),R=[...o.slides];R[c]=L(N({},u),{elements:A}),_(L(N({},o),{slides:R}))}},we=(0,I.useCallback)(()=>{if(!P)return;let d=o.slides[c].elements.filter(u=>u.id!==P);ee({elements:d}),M(null)},[P,c,o,ee]),Ee=()=>{let n={id:`text-${Date.now()}`,type:"text",content:"New Text",x:100,y:100,width:400,height:100,fontSize:48,fontFamily:"Arial",color:"#000000",zIndex:v.elements.length};ee({elements:[...v.elements,n]})},je=n=>{let d=URL.createObjectURL(n),u=`img-${Date.now()}`,A={id:u,type:"image",src:d,x:100,y:100,width:400,height:250,zIndex:v.elements.length};ee({elements:[...v.elements,A]}),M(u)},Ve=n=>{let d={id:`shape-${Date.now()}`,type:"shape",shapeType:n,fill:"#3b82f6",x:200,y:200,width:200,height:200,zIndex:v.elements.length};ee({elements:[...v.elements,d]})},We=()=>{let n={id:`slide-${Date.now()}`,elements:[]};_(L(N({},o),{slides:[...o.slides,n]})),x(o.slides.length)},Xe=n=>{if(o.slides.length<=1)return;let d=o.slides.filter((u,A)=>A!==n);_(L(N({},o),{slides:d})),n<=c&&x(Math.max(0,c-1))},Ge=n=>{let d=o.slides[n],u=L(N({},d),{id:`slide-${Date.now()}`,elements:d.elements.map(R=>L(N({},R),{id:`${R.type}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}))}),A=[...o.slides];A.splice(n+1,0,u),_(L(N({},o),{slides:A})),x(n+1)},Ye=(n,d)=>{if(n===d)return;let u=[...o.slides],[A]=u.splice(n,1);u.splice(d,0,A),_(L(N({},o),{slides:u})),c===n?x(d):c>n&&c<=d?x(c-1):c<n&&c>=d&&x(c+1)},_e=n=>{let d=[],u=Date.now();n==="title"?d=[{id:`text-title-${u}`,type:"text",content:"Presentation Title",x:100,y:200,width:1e3,height:150,fontSize:80,fontFamily:"Inter",color:"#000000",textAlign:"center",isBold:!0,zIndex:0},{id:`text-sub-${u}`,type:"text",content:"Subtitle goes here",x:200,y:380,width:800,height:80,fontSize:36,fontFamily:"Inter",color:"#64748b",textAlign:"center",zIndex:1}]:n==="content"?d=[{id:`text-title-${u}`,type:"text",content:"Slide Title",x:60,y:40,width:800,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,zIndex:0},{id:`text-body-${u}`,type:"text",content:`\u2022 Add your points here
4
4
  \u2022 Press Enter for new line
5
- \u2022 Use the toolbar to format`,x:60,y:150,width:1080,height:480,fontSize:28,fontFamily:"Inter",color:"#334155",zIndex:1,isBulleted:!0}]:r==="split"&&(d=[{id:`text-title-${h}`,type:"text",content:"Comparison Layout",x:60,y:40,width:1080,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,textAlign:"center",zIndex:0},{id:`text-left-${h}`,type:"text",content:"Left column content goes here.",x:60,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:1},{id:`text-right-${h}`,type:"text",content:"Right column content goes here.",x:620,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:2}]),B({elements:d})},he=async(r,d)=>{let k=p.slides[a].elements.find(R=>R.id===r);if(!(!k||k.type!=="text")){W(!0),L(null),Y({id:r,action:d});try{if(!g){L("Gemini API key is missing. Please provide it via the 'geminiApiKey' prop."),W(!1);return}let J=new ze.GoogleGenerativeAI(g).getGenerativeModel({model:"gemini-flash-latest",systemInstruction:`You are a professional presentation assistant. Your task is to transform slide text according to specific user requests (shorten, reframe, or lengthen).
5
+ \u2022 Use the toolbar to format`,x:60,y:150,width:1080,height:480,fontSize:28,fontFamily:"Inter",color:"#334155",zIndex:1,isBulleted:!0}]:n==="split"&&(d=[{id:`text-title-${u}`,type:"text",content:"Comparison Layout",x:60,y:40,width:1080,height:80,fontSize:48,fontFamily:"Inter",color:"#000000",isBold:!0,textAlign:"center",zIndex:0},{id:`text-left-${u}`,type:"text",content:"Left column content goes here.",x:60,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:1},{id:`text-right-${u}`,type:"text",content:"Right column content goes here.",x:620,y:180,width:520,height:400,fontSize:24,fontFamily:"Inter",color:"#334155",zIndex:2}]),ee({elements:d})},Ce=async(n,d)=>{let A=o.slides[c].elements.find(R=>R.id===n);if(!(!A||A.type!=="text")){le(!0),$(null),be({id:n,action:d});try{if(!b){$("Gemini API key is missing. Please provide it via the 'geminiApiKey' prop."),le(!1);return}let K=new Ue.GoogleGenerativeAI(b).getGenerativeModel({model:"gemini-flash-latest",systemInstruction:`You are a professional presentation assistant. Your task is to transform slide text according to specific user requests (shorten, reframe, or lengthen).
6
6
 
7
7
  CRITICAL RULES:
8
8
  1. Return ONLY the transformed text.
@@ -10,9 +10,9 @@ CRITICAL RULES:
10
10
  3. Do NOT use markdown formatting (like bolding or headers) unless specifically needed for bullet points.
11
11
  4. If the input text is a title/headline, the output should be a professional title/headline.
12
12
  5. If the input text is a bulleted list, the output MUST be a bulleted list using the same bullet style (e.g., '\u2022').
13
- 6. Maintain the professional tone of the original presentation.`}),ce=k.fontSize>32?"Title/Headline":"Body Text/List",ae=`Action: ${d.toUpperCase()}
14
- Text Role: ${ce}
15
- Original Text: "${k.content}"
13
+ 6. Maintain the professional tone of the original presentation.`}),he=A.fontSize>32?"Title/Headline":"Body Text/List",de=`Action: ${d.toUpperCase()}
14
+ Text Role: ${he}
15
+ Original Text: "${A.content}"
16
16
 
17
- Transformed Text:`,Me=await(await J.generateContent(ae)).response;L(Me.text().trim())}catch(R){console.error("Gemini AI Error:",R),L("Error generating response. Please check your API key or connection.")}finally{W(!1)}}},Fe=r=>{if(!S||!G)return;if(r==="regenerate"){he(G.id,G.action);return}let d=p.slides[a],h=d.elements.find(k=>k.id===G.id);if(!(!h||h.type!=="text")){if(r==="replace")q(G.id,{content:S});else if(r==="addBelow"){let k=I(w({},h),{id:`text-ai-${Date.now()}`,content:S,y:h.y+h.height+20,zIndex:d.elements.length});B({elements:[...d.elements,k]})}L(null),Y(null)}},Re=async()=>{await new oe().export(p)},Ee=()=>{u(!0);let r=document.documentElement;r.requestFullscreen&&r.requestFullscreen()},$e=()=>{u(!1),document.fullscreenElement&&document.exitFullscreen()};(0,z.useEffect)(()=>{let r=()=>{document.fullscreenElement||u(!1)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[]),(0,z.useEffect)(()=>{let r=d=>{if(d.key==="Delete"||d.key==="Backspace"){let h=document.activeElement;if((h==null?void 0:h.tagName)==="INPUT"||(h==null?void 0:h.tagName)==="TEXTAREA"||h!=null&&h.isContentEditable)return;re()}(d.ctrlKey||d.metaKey)&&(d.key==="z"&&(d.preventDefault(),d.shiftKey?K():_()),d.key==="y"&&(d.preventDefault(),K()))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[re,_,K]);let Ue=()=>{F({slides:[{id:`slide-${Date.now()}`,elements:[]}],layout:{width:12192e3,height:6858e3}}),b(0),t(null)},xe=async r=>{W(!0);try{let d=new le,h=r;typeof r=="string"&&(h=`/api/proxy?url=${encodeURIComponent(r.trim())}`);let k=await d.parse(h);N(k),f([]),y([]),b(0),t(null)}catch(d){console.error("Failed to load PPTX",d),alert("Failed to load presentation. Please ensure it is a valid .pptx.")}finally{W(!1)}};return(0,V.jsxs)("div",{className:"flex flex-col h-screen bg-white overflow-hidden",children:[n&&(0,V.jsx)(Pe,{presentation:p,initialSlideIndex:a,onClose:$e}),(0,V.jsx)(Se,{onAddText:ue,onAddImage:A,onAddShape:Q,onAddSlide:de,onExport:Re,onFormatText:T,onDeleteElement:re,onApplyLayout:De,onPlay:Ee,onAiAction:he,onAiResponseAction:Fe,onNewPresentation:Ue,onLoadPresentation:xe,aiResponse:S,isAiLoading:X,selectedElement:ie,appName:l}),(0,V.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,V.jsx)(ke,{slides:p.slides,currentSlideIndex:a,onSelectSlide:b,onDeleteSlide:Le,onDuplicateSlide:Te,onReorderSlides:Be}),(0,V.jsx)("div",{className:"flex-1 flex items-center justify-center p-12 overflow-auto bg-white",children:(0,V.jsx)(fe,{slide:P,onElementUpdate:q,onSelect:t})})]})]})};0&&(module.exports={PptEditor,PptxExporter,PptxParser});
17
+ Transformed Text:`,Qe=await(await K.generateContent(de)).response;$(Qe.text().trim())}catch(R){console.error("Gemini AI Error:",R),$("Error generating response. Please check your API key or connection.")}finally{le(!1)}}},Ke=n=>{if(!E||!T)return;if(n==="regenerate"){Ce(T.id,T.action);return}let d=o.slides[c],u=d.elements.find(A=>A.id===T.id);if(!(!u||u.type!=="text")){if(n==="replace")ye(T.id,{content:E});else if(n==="addBelow"){let A=L(N({},u),{id:`text-ai-${Date.now()}`,content:E,y:u.y+u.height+20,zIndex:d.elements.length});ee({elements:[...d.elements,A]})}$(null),be(null)}},Ze=async()=>{await new ue().export(o)},qe=()=>{q(!0);let n=document.documentElement;n.requestFullscreen&&n.requestFullscreen()},Je=()=>{q(!1),document.fullscreenElement&&document.exitFullscreen()};(0,I.useEffect)(()=>{let n=()=>{document.fullscreenElement||q(!1)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),(0,I.useEffect)(()=>{let n=d=>{if(d.key==="Delete"||d.key==="Backspace"){let u=document.activeElement;if((u==null?void 0:u.tagName)==="INPUT"||(u==null?void 0:u.tagName)==="TEXTAREA"||u!=null&&u.isContentEditable)return;we()}(d.ctrlKey||d.metaKey)&&(d.key==="z"&&(d.preventDefault(),d.shiftKey?ve():ke()),d.key==="y"&&(d.preventDefault(),ve()))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[we,ke,ve]);let Ne=(n,d)=>{V(n),y==null||y(n,d)},Ae=()=>{g({slides:[{id:`slide-${Date.now()}`,elements:[]}],layout:{width:12192e3,height:6858e3}}),x(0),M(null),Ne("scratch")},me=async n=>{ne(!0);try{let d=new fe,u=n;typeof n=="string"?(u=`/api/proxy?url=${encodeURIComponent(n.trim())}`,Ne("url",n.trim())):Ne("uploaded");let A=await d.parse(u);g(A),t([]),r([]),x(0),M(null)}catch(d){console.error("Failed to load PPTX",d),alert("Failed to load presentation. Please ensure it is a valid .pptx.")}finally{ne(!1)}};return!h||!k?(0,S.jsx)("div",{className:"flex items-center justify-center bg-red-50 text-red-600 p-8 rounded-xl border-2 border-red-200 font-bold",children:"Error: width and height props are compulsory for PptEditor."}):(0,S.jsxs)("div",{className:"flex flex-col bg-white overflow-hidden relative",style:{width:typeof h=="number"?`${h}px`:h,height:typeof k=="number"?`${k}px`:k,fontSize:`${16*ce}px`},children:[te&&(0,S.jsx)("div",{className:"absolute inset-0 z-[2000] bg-white flex items-center justify-center p-12",children:(0,S.jsxs)("div",{className:"max-w-xl w-full text-center space-y-8 animate-in fade-in zoom-in-95 duration-500",children:[(0,S.jsxs)("div",{className:"space-y-2",children:[(0,S.jsx)("h2",{className:"text-4xl font-black tracking-tight text-slate-800",children:l}),(0,S.jsx)("p",{className:"text-slate-500 font-medium",children:"Create stunning presentations in seconds."})]}),(0,S.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,S.jsxs)("button",{onClick:()=>{Ae(),H(!1)},className:"flex flex-col items-center justify-center gap-3 p-8 border-2 border-slate-100 rounded-3xl hover:border-slate-300 hover:bg-slate-50 transition-all group",children:[(0,S.jsx)("div",{className:"p-3 bg-slate-100 rounded-xl group-hover:bg-blue-50 transition-colors",children:(0,S.jsx)("svg",{className:"w-6 h-6 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,S.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),(0,S.jsx)("span",{className:"text-xs font-black uppercase tracking-widest text-slate-600",children:"Start New Deck"})]}),(0,S.jsxs)("label",{className:"flex flex-col items-center justify-center gap-3 p-8 border-2 border-slate-100 rounded-3xl hover:border-slate-300 hover:bg-slate-50 transition-all group cursor-pointer",children:[(0,S.jsx)("div",{className:"p-3 bg-slate-100 rounded-xl group-hover:bg-emerald-50 transition-colors",children:(0,S.jsx)("svg",{className:"w-6 h-6 text-emerald-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,S.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}),(0,S.jsx)("span",{className:"text-xs font-black uppercase tracking-widest text-slate-600",children:"Upload PPTX"}),(0,S.jsx)("input",{type:"file",accept:".pptx",className:"hidden",onChange:n=>{var u;let d=(u=n.target.files)==null?void 0:u[0];d&&(me(d),H(!1))}})]})]}),(0,S.jsxs)("div",{className:"space-y-4 pt-4 border-t border-slate-100",children:[(0,S.jsxs)("div",{className:"flex gap-2",children:[(0,S.jsxs)("div",{className:"flex-1 relative",children:[(0,S.jsx)("svg",{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,S.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9h18"})}),(0,S.jsx)("input",{type:"text",placeholder:"Paste presentation URL...",value:j,onChange:n=>J(n.target.value),className:"text-black w-full bg-slate-50 border border-slate-200 rounded-2xl pl-11 pr-5 py-4 focus:outline-none focus:border-slate-400 focus:ring-4 focus:ring-slate-400/5 text-sm transition-all"})]}),(0,S.jsx)("button",{onClick:()=>{j.trim()&&(me(j.trim()),H(!1))},disabled:!j.trim()||G,style:{cursor:"pointer"},className:"bg-slate-900 hover:bg-black disabled:bg-slate-200 disabled:text-slate-400 text-white font-bold px-8 rounded-2xl transition-all shadow-sm text-sm",children:"Load"})]}),(0,S.jsx)("p",{className:"text-[10px] text-slate-400 font-bold uppercase tracking-widest",children:"Supports S3, public links, and versioned assets"})]})]})}),re&&(0,S.jsx)(He,{presentation:o,initialSlideIndex:c,onClose:Je}),(0,S.jsx)(De,{onAddText:Ee,onAddImage:je,onAddShape:Ve,onAddSlide:We,onExport:Ze,onFormatText:Oe,onDeleteElement:we,onApplyLayout:_e,onPlay:qe,onAiAction:Ce,onAiResponseAction:Ke,onNewPresentation:Ae,onLoadPresentation:me,aiResponse:E,isAiLoading:se,selectedElement:Q,appName:l,appBgColor:C,uiScale:ce,source:Y}),(0,S.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,S.jsx)(Me,{slides:o.slides,currentSlideIndex:c,onSelectSlide:x,onDeleteSlide:Xe,onDuplicateSlide:Ge,onReorderSlides:Ye,uiScale:ce}),(0,S.jsx)("div",{className:"flex-1 flex items-center justify-center p-12 overflow-auto bg-white",children:(0,S.jsx)(ge,{slide:v,onElementUpdate:ye,onSelect:M,uiScale:ce})})]})]})};0&&(module.exports={PptEditor,PptxExporter,PptxParser});
18
18
  //# sourceMappingURL=index.js.map