@nice2dev/ui-video 1.0.10

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 ADDED
@@ -0,0 +1,265 @@
1
+ # @nice2dev/ui-video
2
+
3
+ Professional video components for React applications including video editing, screen recording, and live streaming.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @nice2dev/ui-video
9
+ # or
10
+ pnpm add @nice2dev/ui-video
11
+ ```
12
+
13
+ ## Components
14
+
15
+ ### NiceVideoEditor
16
+
17
+ Full-featured video editing component with timeline, effects, and transitions.
18
+
19
+ ```tsx
20
+ import { NiceVideoEditor } from '@nice2dev/ui-video';
21
+ import '@nice2dev/ui-video/style.css';
22
+
23
+ function App() {
24
+ const handleExport = async (project, format) => {
25
+ // Export logic
26
+ return new Blob([]);
27
+ };
28
+
29
+ return (
30
+ <NiceVideoEditor
31
+ onProjectChange={(project) => console.log('Project changed:', project)}
32
+ onExport={handleExport}
33
+ onAssetUpload={async (file) => {
34
+ // Upload file and return MediaAsset
35
+ return {
36
+ id: crypto.randomUUID(),
37
+ type: 'video',
38
+ name: file.name,
39
+ url: URL.createObjectURL(file),
40
+ size: file.size,
41
+ };
42
+ }}
43
+ />
44
+ );
45
+ }
46
+ ```
47
+
48
+ #### Features
49
+
50
+ - Multi-track timeline with video, audio, and text tracks
51
+ - Drag-and-drop from asset library
52
+ - Effects: blur, brightness, contrast, saturation, grayscale, sepia, chroma key, etc.
53
+ - Transitions: fade, dissolve, wipe, slide, zoom, push
54
+ - Export settings with codec and resolution selection
55
+ - Keyboard shortcuts for editing
56
+
57
+ ### NiceScreenRecorder
58
+
59
+ Screen recording component with annotation and markers support.
60
+
61
+ ```tsx
62
+ import { NiceScreenRecorder } from '@nice2dev/ui-video';
63
+ import '@nice2dev/ui-video/style.css';
64
+
65
+ function App() {
66
+ return (
67
+ <NiceScreenRecorder
68
+ options={{
69
+ video: {
70
+ source: 'screen',
71
+ frameRate: 30,
72
+ showCursor: true,
73
+ },
74
+ audio: {
75
+ enabled: true,
76
+ source: 'both',
77
+ },
78
+ output: {
79
+ format: 'webm',
80
+ quality: 'high',
81
+ },
82
+ }}
83
+ onRecordingStart={(session) => console.log('Recording started:', session)}
84
+ onRecordingStop={(session, blob) => {
85
+ const url = URL.createObjectURL(blob);
86
+ const a = document.createElement('a');
87
+ a.href = url;
88
+ a.download = 'recording.webm';
89
+ a.click();
90
+ }}
91
+ onError={(error) => console.error('Recording error:', error)}
92
+ />
93
+ );
94
+ }
95
+ ```
96
+
97
+ #### Features
98
+
99
+ - Screen, window, tab, or camera capture
100
+ - System audio and microphone recording
101
+ - Countdown timer before recording
102
+ - Annotation tools (pen, arrow, rectangle, text)
103
+ - Markers for navigation
104
+ - Customizable output format and quality
105
+
106
+ ### NiceLiveStreaming
107
+
108
+ Live streaming component with multi-destination support.
109
+
110
+ ```tsx
111
+ import { NiceLiveStreaming } from '@nice2dev/ui-video';
112
+ import '@nice2dev/ui-video/style.css';
113
+
114
+ function App() {
115
+ return (
116
+ <NiceLiveStreaming
117
+ config={{
118
+ name: 'My Stream',
119
+ destinations: [
120
+ {
121
+ id: '1',
122
+ name: 'YouTube',
123
+ platform: 'youtube',
124
+ url: 'rtmp://a.rtmp.youtube.com/live2',
125
+ streamKey: 'YOUR_STREAM_KEY',
126
+ enabled: true,
127
+ status: 'idle',
128
+ },
129
+ ],
130
+ sources: [],
131
+ layout: {
132
+ name: 'Default',
133
+ canvas: { width: 1920, height: 1080, backgroundColor: '#000000' },
134
+ layers: [],
135
+ },
136
+ settings: {
137
+ video: {
138
+ resolution: { width: 1920, height: 1080 },
139
+ frameRate: 30,
140
+ codec: 'h264',
141
+ bitrate: 6000,
142
+ keyframe: 2,
143
+ profile: 'high',
144
+ },
145
+ audio: {
146
+ sampleRate: 48000,
147
+ bitrate: 160,
148
+ channels: 2,
149
+ codec: 'aac',
150
+ },
151
+ },
152
+ }}
153
+ onStreamStart={() => console.log('Stream started')}
154
+ onStreamStop={() => console.log('Stream stopped')}
155
+ onStatsUpdate={(stats) => console.log('Stats:', stats)}
156
+ />
157
+ );
158
+ }
159
+ ```
160
+
161
+ #### Features
162
+
163
+ - Multi-platform streaming (YouTube, Twitch, Facebook, custom RTMP/SRT)
164
+ - Scene management with instant switching
165
+ - Source management (camera, screen, window, browser, images, videos)
166
+ - Audio mixer with volume controls
167
+ - Real-time stats (viewers, bitrate, fps, dropped frames)
168
+ - Canvas-based layout editor
169
+
170
+ ## Types
171
+
172
+ ### Video Editor Types
173
+
174
+ ```typescript
175
+ interface VideoProject {
176
+ id: string;
177
+ name: string;
178
+ resolution: VideoResolution;
179
+ frameRate: number;
180
+ duration: number;
181
+ tracks: VideoTrack[];
182
+ assets: MediaAsset[];
183
+ settings: ProjectSettings;
184
+ }
185
+
186
+ interface VideoTrack {
187
+ id: string;
188
+ type: 'video' | 'audio' | 'text' | 'effects';
189
+ name: string;
190
+ items: TrackItem[];
191
+ muted: boolean;
192
+ locked: boolean;
193
+ visible: boolean;
194
+ }
195
+
196
+ interface Effect {
197
+ id: string;
198
+ type: EffectType;
199
+ name: string;
200
+ parameters: Record<string, number | string | boolean>;
201
+ keyframes?: Keyframe[];
202
+ }
203
+ ```
204
+
205
+ ### Screen Recorder Types
206
+
207
+ ```typescript
208
+ interface RecordingOptions {
209
+ video: {
210
+ source: 'screen' | 'window' | 'tab' | 'camera';
211
+ resolution?: VideoResolution;
212
+ frameRate?: number;
213
+ showCursor: boolean;
214
+ };
215
+ audio: {
216
+ enabled: boolean;
217
+ source: 'system' | 'microphone' | 'both' | 'none';
218
+ echoCancellation?: boolean;
219
+ noiseSuppression?: boolean;
220
+ };
221
+ output: {
222
+ format: 'webm' | 'mp4' | 'mkv';
223
+ quality?: 'low' | 'medium' | 'high' | 'lossless';
224
+ };
225
+ }
226
+ ```
227
+
228
+ ### Live Streaming Types
229
+
230
+ ```typescript
231
+ interface StreamConfig {
232
+ id: string;
233
+ name: string;
234
+ protocol: 'rtmp' | 'rtmps' | 'hls' | 'webrtc' | 'srt';
235
+ destinations: StreamDestination[];
236
+ sources: StreamSource[];
237
+ layout: StreamLayout;
238
+ settings: StreamSettings;
239
+ }
240
+
241
+ interface StreamStats {
242
+ duration: number;
243
+ viewers: number;
244
+ peakViewers: number;
245
+ bitrate: number;
246
+ fps: number;
247
+ droppedFrames: number;
248
+ cpuUsage: number;
249
+ memoryUsage: number;
250
+ }
251
+ ```
252
+
253
+ ## Browser Support
254
+
255
+ These components use modern browser APIs:
256
+
257
+ - `MediaRecorder` API for recording
258
+ - `getDisplayMedia` API for screen capture
259
+ - `WebRTC` for streaming
260
+
261
+ Ensure your target browsers support these APIs. Fallbacks are not provided.
262
+
263
+ ## License
264
+
265
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),re={id:crypto.randomUUID(),name:"Untitled Project",resolution:{width:1920,height:1080,label:"1080p"},frameRate:30,duration:0,tracks:[{id:"1",type:"video",name:"Video 1",items:[],muted:!1,locked:!1,visible:!0},{id:"2",type:"audio",name:"Audio 1",items:[],muted:!1,locked:!1,visible:!0}],assets:[],settings:{backgroundColor:"#000000",audio:{sampleRate:48e3,channels:2,bitrate:320},video:{codec:"h264",bitrate:8e3,profile:"high"}}},le=[{type:"blur",name:"Blur",icon:"đŸ”ĩ"},{type:"brightness",name:"Brightness",icon:"â˜€ī¸"},{type:"contrast",name:"Contrast",icon:"◐"},{type:"saturation",name:"Saturation",icon:"🎨"},{type:"grayscale",name:"Grayscale",icon:"âŦ›"},{type:"sepia",name:"Sepia",icon:"🟤"},{type:"chromaKey",name:"Chroma Key",icon:"đŸŸĸ"},{type:"crop",name:"Crop",icon:"âœ‚ī¸"},{type:"zoom",name:"Zoom",icon:"🔍"}],oe=[{type:"fade",name:"Fade"},{type:"dissolve",name:"Dissolve"},{type:"wipe",name:"Wipe"},{type:"slide",name:"Slide"},{type:"zoom",name:"Zoom"},{type:"push",name:"Push"}],ce=({project:I,onProjectChange:w,onExport:R,onAssetUpload:T,className:A=""})=>{const[o,Y]=d.useState(I||re),[t,Z]=d.useState("timeline"),[v,V]=d.useState(null),[m,y]=d.useState(null),[j,E]=d.useState(0),[b,F]=d.useState(!1),[k,M]=d.useState(1),[W,z]=d.useState(!0),[g,$]=d.useState(null),J=d.useRef(null),ee=d.useRef(null),D=d.useRef(null);d.useEffect(()=>{I&&Y(I)},[I]),d.useEffect(()=>()=>{D.current&&clearInterval(D.current)},[]);const x=d.useCallback(n=>{const i={...o,...n};Y(i),w==null||w(i)},[o,w]),S=async n=>{const i=[];for(const u of Array.from(n)){const s=u.type.startsWith("video/")?"video":u.type.startsWith("audio/")?"audio":"image";let a;T?a=await T(u):a={id:crypto.randomUUID(),type:s,name:u.name,url:URL.createObjectURL(u),size:u.size},i.push(a)}x({assets:[...o.assets,...i]})},h=n=>{const i={id:crypto.randomUUID(),type:n,name:`${n.charAt(0).toUpperCase()+n.slice(1)} ${o.tracks.filter(u=>u.type===n).length+1}`,items:[],muted:!1,locked:!1,visible:!0};x({tracks:[...o.tracks,i]})},O=n=>{x({tracks:o.tracks.filter(i=>i.id!==n)}),v===n&&V(null)},q=n=>{x({tracks:o.tracks.map(i=>i.id===n?{...i,muted:!i.muted}:i)})},P=n=>{x({tracks:o.tracks.map(i=>i.id===n?{...i,locked:!i.locked}:i)})},Q=(n,i)=>{const u=o.tracks.find(c=>c.id===n);if(!u||u.locked)return;const s=u.items[u.items.length-1],a=s?s.startTime+s.duration:0,r={id:crypto.randomUUID(),assetId:i.id,type:i.type,startTime:a,duration:i.duration||5,offset:0,properties:{x:0,y:0,opacity:1,scale:1,volume:1},effects:[],transitions:[]};x({tracks:o.tracks.map(c=>c.id===n?{...c,items:[...c.items,r]}:c)})},N=(n,i,u)=>{const s={id:crypto.randomUUID(),type:u,name:u.charAt(0).toUpperCase()+u.slice(1),parameters:U(u)};x({tracks:o.tracks.map(a=>a.id===n?{...a,items:a.items.map(r=>r.id===i?{...r,effects:[...r.effects,s]}:r)}:a)})},B=(n,i,u,s)=>{const a={id:crypto.randomUUID(),type:u,duration:.5,position:s};x({tracks:o.tracks.map(r=>r.id===n?{...r,items:r.items.map(c=>c.id===i?{...c,transitions:[...c.transitions,a]}:c)}:r)})},U=n=>{switch(n){case"blur":return{radius:5};case"brightness":return{value:100};case"contrast":return{value:100};case"saturation":return{value:100};case"grayscale":return{amount:100};case"sepia":return{amount:100};case"chromaKey":return{color:"#00ff00",threshold:40};case"crop":return{top:0,right:0,bottom:0,left:0};case"zoom":return{scale:1,x:0,y:0};default:return{}}},se=()=>{b?(D.current&&clearInterval(D.current),F(!1)):(D.current=setInterval(()=>{E(n=>{const i=Math.max(...o.tracks.flatMap(u=>u.items.map(s=>s.startTime+s.duration)),0);return n>=i?(clearInterval(D.current),F(!1),0):n+1/o.frameRate})},1e3/o.frameRate),F(!0))},H=n=>{E(Math.max(0,n))},X=async()=>{if(R){$(0);try{const n=setInterval(()=>{$(i=>i!==null&&i<90?i+Math.random()*10:i)},500);await R(o,o.settings.video.codec),clearInterval(n),$(100),setTimeout(()=>$(null),2e3)}catch(n){$(null),console.error("Export failed:",n)}}},G=n=>{const i=Math.floor(n/60),u=Math.floor(n%60),s=Math.floor(n%1*o.frameRate);return`${i.toString().padStart(2,"0")}:${u.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`},K=()=>{for(const n of o.tracks){const i=n.items.find(u=>u.id===m);if(i)return{track:n,item:i}}return null};return e.jsxs("div",{className:`nice-video-editor ${A}`,children:[e.jsxs("header",{className:"video-editor__header",children:[e.jsxs("div",{className:"header__project-info",children:[e.jsx("input",{type:"text",value:o.name,onChange:n=>x({name:n.target.value}),className:"project-name-input"}),e.jsxs("span",{className:"project-settings",children:[o.resolution.width,"x",o.resolution.height," â€ĸ ",o.frameRate,"fps"]})]}),e.jsx("div",{className:"header__tabs",children:["timeline","effects","transitions","export"].map(n=>e.jsx("button",{className:`tab-button ${t===n?"tab-button--active":""}`,onClick:()=>Z(n),children:n.charAt(0).toUpperCase()+n.slice(1)},n))}),e.jsx("div",{className:"header__actions",children:e.jsx("button",{className:"action-button action-button--primary",onClick:X,disabled:g!==null,children:g!==null?`Exporting ${Math.round(g)}%`:"Export"})})]}),e.jsxs("div",{className:"video-editor__main",children:[W&&e.jsxs("aside",{className:"video-editor__asset-library",children:[e.jsxs("div",{className:"asset-library__header",children:[e.jsx("h3",{children:"Assets"}),e.jsx("button",{className:"close-button",onClick:()=>z(!1),children:"×"})]}),e.jsx("div",{className:"asset-library__upload",children:e.jsxs("label",{className:"upload-zone",children:[e.jsx("input",{type:"file",multiple:!0,accept:"video/*,audio/*,image/*",onChange:n=>n.target.files&&S(n.target.files),hidden:!0}),e.jsx("span",{className:"upload-icon",children:"+"}),e.jsx("span",{children:"Drop files or click to upload"})]})}),e.jsx("div",{className:"asset-library__list",children:o.assets.map(n=>e.jsxs("div",{className:"asset-item",draggable:!0,onDragStart:i=>i.dataTransfer.setData("assetId",n.id),children:[e.jsx("div",{className:"asset-thumbnail",children:n.thumbnail?e.jsx("img",{src:n.thumbnail,alt:n.name}):e.jsx("span",{className:"asset-type-icon",children:n.type==="video"?"đŸŽŦ":n.type==="audio"?"đŸŽĩ":"đŸ–ŧī¸"})}),e.jsxs("div",{className:"asset-info",children:[e.jsx("span",{className:"asset-name",children:n.name}),e.jsxs("span",{className:"asset-meta",children:[(n.size/1024/1024).toFixed(1),"MB"]})]})]},n.id))})]}),e.jsxs("div",{className:"video-editor__preview-area",children:[e.jsxs("div",{className:"preview-container",children:[e.jsxs("div",{className:"preview-canvas",style:{aspectRatio:`${o.resolution.width}/${o.resolution.height}`},children:[e.jsx("video",{ref:ee,className:"preview-video"}),e.jsx("div",{className:"preview-overlay",children:!W&&e.jsx("button",{className:"toggle-library-button",onClick:()=>z(!0),children:"📁"})})]}),e.jsxs("div",{className:"playback-controls",children:[e.jsx("button",{onClick:()=>H(0),children:"âŽī¸"}),e.jsx("button",{onClick:()=>H(j-1/o.frameRate),children:"âĒ"}),e.jsx("button",{onClick:se,className:"play-button",children:b?"â¸ī¸":"â–ļī¸"}),e.jsx("button",{onClick:()=>H(j+1/o.frameRate),children:"⏊"}),e.jsx("span",{className:"time-display",children:G(j)})]})]}),m&&t!=="export"&&e.jsx("div",{className:"item-inspector",children:(()=>{const n=K();if(!n)return null;const{track:i,item:u}=n;return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Item Properties"}),e.jsxs("div",{className:"inspector-section",children:[e.jsxs("label",{children:["Start Time",e.jsx("input",{type:"number",step:"0.1",value:u.startTime,onChange:s=>{const a=parseFloat(s.target.value);x({tracks:o.tracks.map(r=>r.id===i.id?{...r,items:r.items.map(c=>c.id===u.id?{...c,startTime:a}:c)}:r)})}})]}),e.jsxs("label",{children:["Duration",e.jsx("input",{type:"number",step:"0.1",value:u.duration,onChange:s=>{const a=parseFloat(s.target.value);x({tracks:o.tracks.map(r=>r.id===i.id?{...r,items:r.items.map(c=>c.id===u.id?{...c,duration:a}:c)}:r)})}})]}),e.jsxs("label",{children:["Opacity",e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:u.properties.opacity??1,onChange:s=>{const a=parseFloat(s.target.value);x({tracks:o.tracks.map(r=>r.id===i.id?{...r,items:r.items.map(c=>c.id===u.id?{...c,properties:{...c.properties,opacity:a}}:c)}:r)})}})]})]}),e.jsxs("h4",{children:["Effects (",u.effects.length,")"]}),e.jsx("div",{className:"effects-list",children:u.effects.map(s=>e.jsx("div",{className:"effect-badge",children:s.name},s.id))})]})})()})]})]}),e.jsxs("div",{className:"video-editor__panel",children:[t==="timeline"&&e.jsxs("div",{className:"timeline-panel",children:[e.jsxs("div",{className:"timeline-toolbar",children:[e.jsxs("div",{className:"track-buttons",children:[e.jsx("button",{onClick:()=>h("video"),children:"+ Video Track"}),e.jsx("button",{onClick:()=>h("audio"),children:"+ Audio Track"}),e.jsx("button",{onClick:()=>h("text"),children:"+ Text Track"})]}),e.jsxs("div",{className:"zoom-controls",children:[e.jsx("button",{onClick:()=>M(Math.max(.25,k-.25)),children:"-"}),e.jsxs("span",{children:[Math.round(k*100),"%"]}),e.jsx("button",{onClick:()=>M(Math.min(4,k+.25)),children:"+"})]})]}),e.jsxs("div",{className:"timeline-container",ref:J,children:[e.jsx("div",{className:"timeline-ruler",children:Array.from({length:Math.ceil(30/k)}).map((n,i)=>e.jsx("div",{className:"ruler-mark",style:{left:`${i*50*k}px`},children:G(i)},i))}),e.jsx("div",{className:"timeline-playhead",style:{left:`${j*50*k}px`}}),e.jsx("div",{className:"timeline-tracks",children:o.tracks.map(n=>e.jsxs("div",{className:`timeline-track ${v===n.id?"timeline-track--selected":""} ${n.locked?"timeline-track--locked":""}`,onClick:()=>V(n.id),onDrop:i=>{i.preventDefault();const u=i.dataTransfer.getData("assetId"),s=o.assets.find(a=>a.id===u);s&&Q(n.id,s)},onDragOver:i=>i.preventDefault(),children:[e.jsxs("div",{className:"track-header",children:[e.jsx("span",{className:"track-name",children:n.name}),e.jsxs("div",{className:"track-controls",children:[e.jsx("button",{className:n.muted?"active":"",onClick:i=>{i.stopPropagation(),q(n.id)},children:n.muted?"🔇":"🔊"}),e.jsx("button",{className:n.locked?"active":"",onClick:i=>{i.stopPropagation(),P(n.id)},children:n.locked?"🔒":"🔓"}),e.jsx("button",{onClick:i=>{i.stopPropagation(),O(n.id)},children:"đŸ—‘ī¸"})]})]}),e.jsx("div",{className:"track-items",children:n.items.map(i=>{const u=o.assets.find(s=>s.id===i.assetId);return e.jsxs("div",{className:`track-item track-item--${i.type} ${m===i.id?"track-item--selected":""}`,style:{left:`${i.startTime*50*k}px`,width:`${i.duration*50*k}px`},onClick:s=>{s.stopPropagation(),y(i.id)},children:[e.jsx("span",{className:"item-name",children:(u==null?void 0:u.name)||"Untitled"}),i.transitions.length>0&&e.jsx("span",{className:"item-transitions",children:"✨"}),i.effects.length>0&&e.jsx("span",{className:"item-effects",children:"🎨"})]},i.id)})})]},n.id))})]})]}),t==="effects"&&e.jsxs("div",{className:"effects-panel",children:[e.jsx("h3",{children:"Video Effects"}),e.jsx("p",{className:"panel-hint",children:"Select a clip to apply effects"}),e.jsx("div",{className:"effects-grid",children:le.map(n=>e.jsxs("button",{className:"effect-preset",disabled:!m,onClick:()=>{const i=K();i&&N(i.track.id,i.item.id,n.type)},children:[e.jsx("span",{className:"effect-icon",children:n.icon}),e.jsx("span",{className:"effect-name",children:n.name})]},n.type))})]}),t==="transitions"&&e.jsxs("div",{className:"transitions-panel",children:[e.jsx("h3",{children:"Transitions"}),e.jsx("p",{className:"panel-hint",children:"Select a clip and add transitions between clips"}),e.jsx("div",{className:"transitions-grid",children:oe.map(n=>e.jsxs("div",{className:"transition-preset",children:[e.jsx("span",{className:"transition-name",children:n.name}),e.jsxs("div",{className:"transition-buttons",children:[e.jsx("button",{disabled:!m,onClick:()=>{const i=K();i&&B(i.track.id,i.item.id,n.type,"start")},children:"In"}),e.jsx("button",{disabled:!m,onClick:()=>{const i=K();i&&B(i.track.id,i.item.id,n.type,"end")},children:"Out"})]})]},n.type))})]}),t==="export"&&e.jsxs("div",{className:"export-panel",children:[e.jsx("h3",{children:"Export Settings"}),e.jsxs("div",{className:"export-settings",children:[e.jsxs("div",{className:"setting-group",children:[e.jsx("label",{children:"Resolution"}),e.jsxs("select",{value:`${o.resolution.width}x${o.resolution.height}`,onChange:n=>{const[i,u]=n.target.value.split("x").map(Number);x({resolution:{width:i,height:u}})},children:[e.jsx("option",{value:"1920x1080",children:"1080p (1920x1080)"}),e.jsx("option",{value:"2560x1440",children:"1440p (2560x1440)"}),e.jsx("option",{value:"3840x2160",children:"4K (3840x2160)"}),e.jsx("option",{value:"1280x720",children:"720p (1280x720)"})]})]}),e.jsxs("div",{className:"setting-group",children:[e.jsx("label",{children:"Frame Rate"}),e.jsxs("select",{value:o.frameRate,onChange:n=>x({frameRate:parseInt(n.target.value)}),children:[e.jsx("option",{value:"24",children:"24 fps"}),e.jsx("option",{value:"30",children:"30 fps"}),e.jsx("option",{value:"60",children:"60 fps"}),e.jsx("option",{value:"120",children:"120 fps"})]})]}),e.jsxs("div",{className:"setting-group",children:[e.jsx("label",{children:"Video Codec"}),e.jsxs("select",{value:o.settings.video.codec,onChange:n=>x({settings:{...o.settings,video:{...o.settings.video,codec:n.target.value}}}),children:[e.jsx("option",{value:"h264",children:"H.264 (Best Compatibility)"}),e.jsx("option",{value:"h265",children:"H.265/HEVC (Smaller Size)"}),e.jsx("option",{value:"vp9",children:"VP9 (Web Optimized)"}),e.jsx("option",{value:"av1",children:"AV1 (Future Standard)"})]})]}),e.jsxs("div",{className:"setting-group",children:[e.jsx("label",{children:"Video Bitrate (Mbps)"}),e.jsx("input",{type:"number",value:o.settings.video.bitrate/1e3,onChange:n=>x({settings:{...o.settings,video:{...o.settings.video,bitrate:parseFloat(n.target.value)*1e3}}}),min:"1",max:"100"})]})]}),e.jsx("button",{className:"export-button",onClick:X,disabled:g!==null,children:g!==null?`Exporting... ${Math.round(g)}%`:"Export Video"}),g!==null&&e.jsx("div",{className:"export-progress",children:e.jsx("div",{className:"export-progress-bar",style:{width:`${g}%`}})})]})]})]})},de={video:{source:"screen",showCursor:!0,frameRate:30,resolution:{width:1920,height:1080}},audio:{enabled:!0,source:"both",echoCancellation:!0,noiseSuppression:!0},output:{format:"webm",quality:"high"}},ue=({options:I,onRecordingStart:w,onRecordingStop:R,onRecordingPause:T,onRecordingResume:A,onError:o,className:Y=""})=>{var c,C;const[t,Z]=d.useState({...de,...I}),[v,V]=d.useState(null),[m,y]=d.useState("idle"),[j,E]=d.useState([]),[b,F]=d.useState(null),[k,M]=d.useState(null),[W,z]=d.useState(!1),[g,$]=d.useState(!1),[J,ee]=d.useState("pen"),[D,x]=d.useState("#ff0000"),S=d.useRef(null),h=d.useRef([]),O=d.useRef(null),q=d.useRef(null),P=d.useRef(null),Q=d.useRef(0);d.useEffect(()=>()=>{b&&b.getTracks().forEach(l=>l.stop()),P.current&&clearInterval(P.current)},[b]);const N=l=>{Z(p=>({...p,...l,video:{...p.video,...l.video},audio:{...p.audio,...l.audio},output:{...p.output,...l.output}}))},B=async()=>{try{y("preparing");const l={video:{cursor:t.video.showCursor?"always":"never",frameRate:t.video.frameRate},audio:t.audio.source==="system"||t.audio.source==="both"},p=await navigator.mediaDevices.getDisplayMedia(l);if(t.audio.enabled&&(t.audio.source==="microphone"||t.audio.source==="both"))try{(await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:t.audio.echoCancellation,noiseSuppression:t.audio.noiseSuppression}})).getAudioTracks().forEach(_=>p.addTrack(_))}catch(f){console.warn("Could not access microphone:",f)}F(p),O.current&&(O.current.srcObject=p,O.current.play()),y("idle")}catch(l){y("error"),o==null||o(l instanceof Error?l:new Error("Failed to start preview"))}},U=async()=>{b||await B();for(let l=3;l>0;l--)M(l),await new Promise(p=>setTimeout(p,1e3));M(null);try{const l=b||await se();if(!l)throw new Error("No stream available");const p=i(t.output.format),f=new MediaRecorder(l,{mimeType:p,videoBitsPerSecond:u(t.output.quality)});h.current=[],f.ondataavailable=L=>{L.data.size>0&&h.current.push(L.data)},f.onstop=()=>{const L=new Blob(h.current,{type:p});v&&(R==null||R({...v,status:"stopped"},L))},S.current=f,f.start(1e3),Q.current=Date.now();const _={id:crypto.randomUUID(),status:"recording",startTime:new Date,duration:0,size:0,options:t,chunks:[]};V(_),y("recording"),w==null||w(_),P.current=setInterval(()=>{V(L=>L?{...L,duration:(Date.now()-Q.current)/1e3,size:h.current.reduce((ne,ie)=>ne+ie.size,0)}:null)},100)}catch(l){y("error"),o==null||o(l instanceof Error?l:new Error("Failed to start recording"))}},se=async()=>(await B(),b),H=()=>{S.current&&m==="recording"&&(S.current.pause(),y("paused"),T==null||T())},X=()=>{S.current&&m==="paused"&&(S.current.resume(),y("recording"),A==null||A())},G=()=>{P.current&&clearInterval(P.current),S.current&&(m==="recording"||m==="paused")&&(S.current.stop(),y("stopped")),b&&(b.getTracks().forEach(l=>l.stop()),F(null))},K=d.useCallback(l=>{if(m!=="recording")return;const p={id:crypto.randomUUID(),time:(v==null?void 0:v.duration)||0,label:l||`Marker ${j.length+1}`,color:s()};E(f=>[...f,p])},[m,v==null?void 0:v.duration,j.length]),n=l=>{E(p=>p.filter(f=>f.id!==l))},i=l=>{switch(l){case"mp4":return"video/mp4";case"mkv":return"video/x-matroska";default:return"video/webm;codecs=vp9"}},u=l=>{switch(l){case"low":return 25e5;case"medium":return 5e6;case"lossless":return 2e7;default:return 8e6}},s=()=>{const l=["#ff4444","#44ff44","#4444ff","#ffff44","#ff44ff","#44ffff"];return l[Math.floor(Math.random()*l.length)]},a=l=>{const p=Math.floor(l/3600),f=Math.floor(l%3600/60),_=Math.floor(l%60),L=Math.floor(l%1*100);return p>0?`${p}:${f.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`:`${f.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}.${L.toString().padStart(2,"0")}`},r=l=>l<1024?`${l} B`:l<1024*1024?`${(l/1024).toFixed(1)} KB`:`${(l/1024/1024).toFixed(1)} MB`;return e.jsxs("div",{className:`nice-screen-recorder ${Y}`,children:[e.jsxs("div",{className:"recorder__preview",children:[k!==null&&e.jsx("div",{className:"countdown-overlay",children:e.jsx("span",{className:"countdown-number",children:k})}),e.jsx("video",{ref:O,className:"preview-video",muted:!0,playsInline:!0}),g&&e.jsx("canvas",{ref:q,className:"annotation-canvas"}),!b&&m==="idle"&&e.jsx("div",{className:"preview-placeholder",children:e.jsxs("button",{className:"start-preview-button",onClick:B,children:[e.jsx("span",{className:"icon",children:"đŸ–Ĩī¸"}),e.jsx("span",{children:"Select Screen to Record"})]})}),m==="recording"&&e.jsxs("div",{className:"recording-indicator",children:[e.jsx("span",{className:"recording-dot"}),e.jsx("span",{children:"REC"})]})]}),e.jsxs("div",{className:"recorder__controls",children:[e.jsxs("div",{className:"controls__main",children:[m==="idle"&&e.jsxs("button",{className:"control-button control-button--record",onClick:U,disabled:!!k,children:[e.jsx("span",{className:"icon",children:"âēī¸"}),e.jsx("span",{children:"Start Recording"})]}),m==="recording"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"control-button control-button--pause",onClick:H,children:[e.jsx("span",{className:"icon",children:"â¸ī¸"}),e.jsx("span",{children:"Pause"})]}),e.jsxs("button",{className:"control-button control-button--stop",onClick:G,children:[e.jsx("span",{className:"icon",children:"âšī¸"}),e.jsx("span",{children:"Stop"})]})]}),m==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"control-button control-button--resume",onClick:X,children:[e.jsx("span",{className:"icon",children:"â–ļī¸"}),e.jsx("span",{children:"Resume"})]}),e.jsxs("button",{className:"control-button control-button--stop",onClick:G,children:[e.jsx("span",{className:"icon",children:"âšī¸"}),e.jsx("span",{children:"Stop"})]})]}),m==="stopped"&&e.jsxs("button",{className:"control-button control-button--new",onClick:()=>{y("idle"),V(null),E([])},children:[e.jsx("span",{className:"icon",children:"🔄"}),e.jsx("span",{children:"New Recording"})]})]}),e.jsxs("div",{className:"controls__secondary",children:[(m==="recording"||m==="paused")&&e.jsxs("button",{className:"control-button control-button--marker",onClick:()=>K(),children:[e.jsx("span",{className:"icon",children:"🚩"}),e.jsx("span",{children:"Add Marker"})]}),e.jsxs("button",{className:`control-button ${g?"control-button--active":""}`,onClick:()=>$(!g),disabled:m!=="recording",children:[e.jsx("span",{className:"icon",children:"âœī¸"}),e.jsx("span",{children:"Annotate"})]}),e.jsx("button",{className:"control-button control-button--settings",onClick:()=>z(!W),disabled:m==="recording",children:e.jsx("span",{className:"icon",children:"âš™ī¸"})})]})]}),e.jsxs("div",{className:"recorder__status",children:[e.jsxs("div",{className:"status__info",children:[e.jsxs("span",{className:"status-item",children:[e.jsx("strong",{children:"Duration:"})," ",a((v==null?void 0:v.duration)||0)]}),e.jsxs("span",{className:"status-item",children:[e.jsx("strong",{children:"Size:"})," ",r((v==null?void 0:v.size)||0)]}),e.jsxs("span",{className:"status-item",children:[e.jsx("strong",{children:"Markers:"})," ",j.length]})]}),e.jsxs("div",{className:"status__quality",children:[t.video.resolution&&e.jsxs("span",{children:[t.video.resolution.width,"x",t.video.resolution.height]}),e.jsxs("span",{children:[t.video.frameRate,"fps"]}),e.jsx("span",{className:t.audio.enabled?"audio-on":"audio-off",children:t.audio.enabled?"🔊":"🔇"})]})]}),g&&m==="recording"&&e.jsxs("div",{className:"recorder__annotation-tools",children:[e.jsx("div",{className:"tool-group",children:["pen","arrow","rectangle","text"].map(l=>e.jsxs("button",{className:`tool-button ${J===l?"tool-button--active":""}`,onClick:()=>ee(l),children:[l==="pen"&&"âœī¸",l==="arrow"&&"âžĄī¸",l==="rectangle"&&"âŦœ",l==="text"&&"T"]},l))}),e.jsx("div",{className:"color-group",children:["#ff0000","#00ff00","#0000ff","#ffff00","#ffffff","#000000"].map(l=>e.jsx("button",{className:`color-button ${D===l?"color-button--active":""}`,style:{backgroundColor:l},onClick:()=>x(l)},l))})]}),j.length>0&&e.jsxs("div",{className:"recorder__markers",children:[e.jsx("h4",{children:"Markers"}),e.jsx("div",{className:"markers-list",children:j.map(l=>e.jsxs("div",{className:"marker-item",style:{borderLeftColor:l.color},children:[e.jsx("span",{className:"marker-time",children:a(l.time)}),e.jsx("input",{type:"text",value:l.label,onChange:p=>{E(f=>f.map(_=>_.id===l.id?{..._,label:p.target.value}:_))},className:"marker-label"}),e.jsx("button",{className:"marker-remove",onClick:()=>n(l.id),children:"×"})]},l.id))})]}),W&&e.jsxs("div",{className:"recorder__settings",children:[e.jsxs("div",{className:"settings-header",children:[e.jsx("h3",{children:"Recording Settings"}),e.jsx("button",{className:"close-button",onClick:()=>z(!1),children:"×"})]}),e.jsxs("div",{className:"settings-section",children:[e.jsx("h4",{children:"Video"}),e.jsxs("label",{children:["Source",e.jsxs("select",{value:t.video.source,onChange:l=>N({video:{...t.video,source:l.target.value}}),children:[e.jsx("option",{value:"screen",children:"Entire Screen"}),e.jsx("option",{value:"window",children:"Application Window"}),e.jsx("option",{value:"tab",children:"Browser Tab"}),e.jsx("option",{value:"camera",children:"Camera"})]})]}),e.jsxs("label",{children:["Resolution",e.jsxs("select",{value:`${(c=t.video.resolution)==null?void 0:c.width}x${(C=t.video.resolution)==null?void 0:C.height}`,onChange:l=>{const[p,f]=l.target.value.split("x").map(Number);N({video:{...t.video,resolution:{width:p,height:f}}})},children:[e.jsx("option",{value:"1920x1080",children:"1080p (1920x1080)"}),e.jsx("option",{value:"2560x1440",children:"1440p (2560x1440)"}),e.jsx("option",{value:"3840x2160",children:"4K (3840x2160)"}),e.jsx("option",{value:"1280x720",children:"720p (1280x720)"})]})]}),e.jsxs("label",{children:["Frame Rate",e.jsxs("select",{value:t.video.frameRate,onChange:l=>N({video:{...t.video,frameRate:parseInt(l.target.value)}}),children:[e.jsx("option",{value:"15",children:"15 fps"}),e.jsx("option",{value:"24",children:"24 fps"}),e.jsx("option",{value:"30",children:"30 fps"}),e.jsx("option",{value:"60",children:"60 fps"})]})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.video.showCursor,onChange:l=>N({video:{...t.video,showCursor:l.target.checked}})}),"Show Cursor"]})]}),e.jsxs("div",{className:"settings-section",children:[e.jsx("h4",{children:"Audio"}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.audio.enabled,onChange:l=>N({audio:{...t.audio,enabled:l.target.checked}})}),"Enable Audio"]}),t.audio.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Source",e.jsxs("select",{value:t.audio.source,onChange:l=>N({audio:{...t.audio,source:l.target.value}}),children:[e.jsx("option",{value:"system",children:"System Audio"}),e.jsx("option",{value:"microphone",children:"Microphone"}),e.jsx("option",{value:"both",children:"Both"})]})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.audio.echoCancellation,onChange:l=>N({audio:{...t.audio,echoCancellation:l.target.checked}})}),"Echo Cancellation"]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t.audio.noiseSuppression,onChange:l=>N({audio:{...t.audio,noiseSuppression:l.target.checked}})}),"Noise Suppression"]})]})]}),e.jsxs("div",{className:"settings-section",children:[e.jsx("h4",{children:"Output"}),e.jsxs("label",{children:["Format",e.jsxs("select",{value:t.output.format,onChange:l=>N({output:{...t.output,format:l.target.value}}),children:[e.jsx("option",{value:"webm",children:"WebM (Best Web)"}),e.jsx("option",{value:"mp4",children:"MP4 (Most Compatible)"}),e.jsx("option",{value:"mkv",children:"MKV (Lossless)"})]})]}),e.jsxs("label",{children:["Quality",e.jsxs("select",{value:t.output.quality,onChange:l=>N({output:{...t.output,quality:l.target.value}}),children:[e.jsx("option",{value:"low",children:"Low (Smaller file)"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High (Recommended)"}),e.jsx("option",{value:"lossless",children:"Lossless (Largest file)"})]})]})]})]})]})},me={id:crypto.randomUUID(),name:"My Stream",protocol:"rtmp",destinations:[],sources:[],layout:{name:"Default",canvas:{width:1920,height:1080,backgroundColor:"#000000"},layers:[]},settings:{video:{resolution:{width:1920,height:1080},frameRate:30,codec:"h264",bitrate:6e3,keyframe:2,profile:"high"},audio:{sampleRate:48e3,bitrate:160,channels:2,codec:"aac"}}},ae=[{platform:"youtube",name:"YouTube",icon:"đŸ“ē",defaultUrl:"rtmp://a.rtmp.youtube.com/live2"},{platform:"twitch",name:"Twitch",icon:"🎮",defaultUrl:"rtmp://live.twitch.tv/app"},{platform:"facebook",name:"Facebook",icon:"📘",defaultUrl:"rtmps://live-api-s.facebook.com:443/rtmp"},{platform:"custom-rtmp",name:"Custom RTMP",icon:"🔗",defaultUrl:""},{platform:"custom-srt",name:"Custom SRT",icon:"🔒",defaultUrl:""}],te=[{type:"camera",name:"Camera",icon:"📷"},{type:"screen",name:"Screen Capture",icon:"đŸ–Ĩī¸"},{type:"window",name:"Window Capture",icon:"đŸĒŸ"},{type:"browser",name:"Browser Source",icon:"🌐"},{type:"image",name:"Image",icon:"đŸ–ŧī¸"},{type:"video",name:"Video",icon:"đŸŽŦ"},{type:"microphone",name:"Microphone",icon:"🎤"},{type:"system-audio",name:"System Audio",icon:"🔊"}],he=({config:I,onConfigChange:w,onStreamStart:R,onStreamStop:T,onStatsUpdate:A,onError:o,className:Y=""})=>{const[t,Z]=d.useState(I||me),[v,V]=d.useState("sources"),[m,y]=d.useState(!1),[j,E]=d.useState({duration:0,viewers:0,peakViewers:0,bitrate:0,fps:0,droppedFrames:0,cpuUsage:0,memoryUsage:0}),[b,F]=d.useState(null),[k,M]=d.useState(!1),[W,z]=d.useState(!1),[g,$]=d.useState([t.layout]),[J,ee]=d.useState(0),D=d.useRef(null),x=d.useRef(null),S=d.useRef(0);d.useEffect(()=>{I&&Z(I)},[I]),d.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]);const h=d.useCallback(s=>{const a={...t,...s};Z(a),w==null||w(a)},[t,w]),O=s=>{const a=ae.find(c=>c.platform===s),r={id:crypto.randomUUID(),name:(a==null?void 0:a.name)||"Custom",platform:s,url:(a==null?void 0:a.defaultUrl)||"",streamKey:"",enabled:!0,status:"idle"};h({destinations:[...t.destinations,r]}),z(!1)},q=(s,a)=>{h({destinations:t.destinations.map(r=>r.id===s?{...r,...a}:r)})},P=s=>{h({destinations:t.destinations.filter(a=>a.id!==s)})},Q=async s=>{const a=te.find(C=>C.type===s),r={id:crypto.randomUUID(),type:s,name:`${(a==null?void 0:a.name)||s} ${t.sources.filter(C=>C.type===s).length+1}`,settings:{},volume:1,muted:!1};try{if(s==="camera"||s==="microphone"){const C=s==="camera"?{video:!0}:{audio:!0},p=(await navigator.mediaDevices.enumerateDevices()).filter(f=>s==="camera"?f.kind==="videoinput":f.kind==="audioinput");p.length>0&&(r.settings.deviceId=p[0].deviceId)}else(s==="screen"||s==="window")&&await navigator.mediaDevices.getDisplayMedia({video:!0})}catch(C){console.warn(`Could not access ${s}:`,C)}h({sources:[...t.sources,r]});const c={id:crypto.randomUUID(),sourceId:r.id,position:{x:0,y:0},size:{width:t.layout.canvas.width,height:t.layout.canvas.height},visible:!0,opacity:1,zIndex:t.layout.layers.length};h({layout:{...t.layout,layers:[...t.layout.layers,c]}}),M(!1)},N=(s,a)=>{h({sources:t.sources.map(r=>r.id===s?{...r,...a}:r)})},B=s=>{h({sources:t.sources.filter(a=>a.id!==s),layout:{...t.layout,layers:t.layout.layers.filter(a=>a.sourceId!==s)}})},U=(s,a)=>{h({layout:{...t.layout,layers:t.layout.layers.map(r=>r.id===s?{...r,...a}:r)}})},se=s=>{const a=t.layout.layers.findIndex(r=>r.id===s);if(a<t.layout.layers.length-1){const r=[...t.layout.layers];[r[a],r[a+1]]=[r[a+1],r[a]],r.forEach((c,C)=>{c.zIndex=C}),h({layout:{...t.layout,layers:r}})}},H=s=>{const a=t.layout.layers.findIndex(r=>r.id===s);if(a>0){const r=[...t.layout.layers];[r[a],r[a-1]]=[r[a-1],r[a]],r.forEach((c,C)=>{c.zIndex=C}),h({layout:{...t.layout,layers:r}})}},X=()=>{const s={name:`Scene ${g.length+1}`,canvas:{...t.layout.canvas},layers:[]};$([...g,s])},G=s=>{const a=[...g];a[J]=t.layout,$(a),ee(s),h({layout:g[s]})},K=async()=>{try{h({destinations:t.destinations.map(s=>s.enabled?{...s,status:"connecting"}:s)}),await new Promise(s=>setTimeout(s,2e3)),h({destinations:t.destinations.map(s=>s.enabled?{...s,status:"live"}:s)}),y(!0),S.current=Date.now(),R==null||R(),x.current=setInterval(()=>{const s={duration:(Date.now()-S.current)/1e3,viewers:Math.floor(Math.random()*100)+j.viewers,peakViewers:Math.max(j.peakViewers,j.viewers),bitrate:t.settings.video.bitrate+Math.floor(Math.random()*500-250),fps:t.settings.video.frameRate-Math.random()*2,droppedFrames:j.droppedFrames+(Math.random()>.95?1:0),cpuUsage:15+Math.random()*30,memoryUsage:40+Math.random()*20};E(s),A==null||A(s)},1e3)}catch(s){o==null||o(s instanceof Error?s:new Error("Failed to start stream")),h({destinations:t.destinations.map(a=>({...a,status:"error"}))})}},n=()=>{x.current&&clearInterval(x.current),h({destinations:t.destinations.map(s=>({...s,status:"idle"}))}),y(!1),T==null||T()},i=s=>{const a=Math.floor(s/3600),r=Math.floor(s%3600/60),c=Math.floor(s%60);return`${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`},u=s=>{switch(s){case"live":return"#00ff00";case"connecting":return"#ffff00";case"error":return"#ff0000";default:return"#888888"}};return e.jsxs("div",{className:`nice-live-streaming ${Y}`,children:[e.jsxs("header",{className:"streaming__header",children:[e.jsxs("div",{className:"header__title",children:[e.jsx("input",{type:"text",value:t.name,onChange:s=>h({name:s.target.value}),className:"stream-name-input"}),m&&e.jsxs("span",{className:"live-badge",children:[e.jsx("span",{className:"live-dot"})," LIVE"]})]}),e.jsx("div",{className:"header__stats",children:m&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"stat-item",children:["âąī¸ ",i(j.duration)]}),e.jsxs("span",{className:"stat-item",children:["đŸ‘Ĩ ",j.viewers]}),e.jsxs("span",{className:"stat-item",children:["📊 ",Math.round(j.bitrate)," kbps"]}),e.jsxs("span",{className:"stat-item",children:["đŸŽŦ ",j.fps.toFixed(1)," fps"]})]})}),e.jsx("div",{className:"header__actions",children:m?e.jsx("button",{className:"action-button action-button--stop",onClick:n,children:"End Stream"}):e.jsx("button",{className:"action-button action-button--go-live",onClick:K,disabled:t.destinations.filter(s=>s.enabled).length===0,children:"Go Live"})})]}),e.jsxs("div",{className:"streaming__main",children:[e.jsxs("div",{className:"streaming__preview",children:[e.jsxs("div",{className:"scenes-bar",children:[g.map((s,a)=>e.jsx("button",{className:`scene-button ${J===a?"scene-button--active":""}`,onClick:()=>G(a),children:s.name},a)),e.jsx("button",{className:"scene-button scene-button--add",onClick:X,children:"+"})]}),e.jsx("div",{ref:D,className:"preview-canvas",style:{aspectRatio:`${t.layout.canvas.width}/${t.layout.canvas.height}`,backgroundColor:t.layout.canvas.backgroundColor},children:t.layout.layers.sort((s,a)=>s.zIndex-a.zIndex).map(s=>{var r;const a=t.sources.find(c=>c.id===s.sourceId);return!s.visible||!a?null:e.jsx("div",{className:`canvas-layer ${b===s.id?"canvas-layer--selected":""}`,style:{left:`${s.position.x/t.layout.canvas.width*100}%`,top:`${s.position.y/t.layout.canvas.height*100}%`,width:`${s.size.width/t.layout.canvas.width*100}%`,height:`${s.size.height/t.layout.canvas.height*100}%`,opacity:s.opacity,zIndex:s.zIndex},onClick:()=>F(s.id),children:e.jsxs("div",{className:"layer-content",children:[e.jsx("span",{className:"layer-icon",children:((r=te.find(c=>c.type===a.type))==null?void 0:r.icon)||"đŸ“Ļ"}),e.jsx("span",{className:"layer-name",children:a.name})]})},s.id)})})]}),e.jsxs("aside",{className:"streaming__panel",children:[e.jsx("div",{className:"panel-tabs",children:["sources","audio","destinations","settings"].map(s=>e.jsx("button",{className:`panel-tab ${v===s?"panel-tab--active":""}`,onClick:()=>V(s),children:s.charAt(0).toUpperCase()+s.slice(1)},s))}),e.jsxs("div",{className:"panel-content",children:[v==="sources"&&e.jsxs("div",{className:"sources-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h3",{children:"Sources"}),e.jsx("button",{className:"add-button",onClick:()=>M(!0),disabled:m,children:"+ Add"})]}),e.jsx("div",{className:"sources-list",children:t.sources.filter(s=>s.type!=="microphone"&&s.type!=="system-audio").map(s=>{var r;const a=t.layout.layers.find(c=>c.sourceId===s.id);return e.jsxs("div",{className:`source-item ${b===(a==null?void 0:a.id)?"source-item--selected":""}`,onClick:()=>a&&F(a.id),children:[e.jsx("span",{className:"source-icon",children:(r=te.find(c=>c.type===s.type))==null?void 0:r.icon}),e.jsx("span",{className:"source-name",children:s.name}),e.jsxs("div",{className:"source-controls",children:[e.jsx("button",{className:a!=null&&a.visible?"":"inactive",onClick:c=>{c.stopPropagation(),a&&U(a.id,{visible:!a.visible})},children:a!=null&&a.visible?"đŸ‘ī¸":"đŸ‘ī¸â€đŸ—¨ī¸"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),a&&se(a.id)},children:"âŦ†ī¸"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),a&&H(a.id)},children:"âŦ‡ī¸"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),B(s.id)},disabled:m,children:"đŸ—‘ī¸"})]})]},s.id)})}),b&&e.jsxs("div",{className:"layer-properties",children:[e.jsx("h4",{children:"Properties"}),(()=>{const s=t.layout.layers.find(a=>a.id===b);return s?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["X Position",e.jsx("input",{type:"number",value:s.position.x,onChange:a=>U(s.id,{position:{...s.position,x:parseInt(a.target.value)||0}})})]}),e.jsxs("label",{children:["Y Position",e.jsx("input",{type:"number",value:s.position.y,onChange:a=>U(s.id,{position:{...s.position,y:parseInt(a.target.value)||0}})})]}),e.jsxs("label",{children:["Width",e.jsx("input",{type:"number",value:s.size.width,onChange:a=>U(s.id,{size:{...s.size,width:parseInt(a.target.value)||100}})})]}),e.jsxs("label",{children:["Height",e.jsx("input",{type:"number",value:s.size.height,onChange:a=>U(s.id,{size:{...s.size,height:parseInt(a.target.value)||100}})})]}),e.jsxs("label",{children:["Opacity",e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.opacity,onChange:a=>U(s.id,{opacity:parseFloat(a.target.value)})})]})]}):null})()]})]}),v==="audio"&&e.jsxs("div",{className:"audio-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h3",{children:"Audio Mixer"}),e.jsx("button",{className:"add-button",onClick:()=>{M(!0)},disabled:m,children:"+ Add"})]}),e.jsxs("div",{className:"audio-sources",children:[t.sources.filter(s=>s.type==="microphone"||s.type==="system-audio"||s.type==="video").map(s=>{var a;return e.jsxs("div",{className:"audio-source",children:[e.jsxs("div",{className:"audio-header",children:[e.jsx("span",{className:"audio-icon",children:(a=te.find(r=>r.type===s.type))==null?void 0:a.icon}),e.jsx("span",{className:"audio-name",children:s.name}),e.jsx("button",{className:s.muted?"muted":"",onClick:()=>N(s.id,{muted:!s.muted}),children:s.muted?"🔇":"🔊"})]}),e.jsxs("div",{className:"audio-slider",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:s.volume??1,onChange:r=>N(s.id,{volume:parseFloat(r.target.value)}),disabled:s.muted}),e.jsxs("span",{className:"volume-value",children:[Math.round((s.volume??1)*100),"%"]})]}),e.jsx("div",{className:"audio-meter",children:e.jsx("div",{className:"meter-fill",style:{width:`${(s.volume??1)*70+Math.random()*30}%`}})})]},s.id)}),t.sources.filter(s=>s.type==="microphone"||s.type==="system-audio").length===0&&e.jsx("p",{className:"empty-message",children:"No audio sources added"})]})]}),v==="destinations"&&e.jsxs("div",{className:"destinations-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h3",{children:"Destinations"}),e.jsx("button",{className:"add-button",onClick:()=>z(!0),disabled:m,children:"+ Add"})]}),e.jsxs("div",{className:"destinations-list",children:[t.destinations.map(s=>{var a;return e.jsxs("div",{className:"destination-item",children:[e.jsxs("div",{className:"destination-header",children:[e.jsx("span",{className:"status-indicator",style:{backgroundColor:u(s.status)}}),e.jsx("span",{className:"destination-icon",children:(a=ae.find(r=>r.platform===s.platform))==null?void 0:a.icon}),e.jsx("span",{className:"destination-name",children:s.name}),e.jsxs("label",{className:"toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:r=>q(s.id,{enabled:r.target.checked}),disabled:m}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"destination-config",children:[e.jsxs("label",{children:["Server URL",e.jsx("input",{type:"text",value:s.url,onChange:r=>q(s.id,{url:r.target.value}),placeholder:"rtmp://...",disabled:m})]}),e.jsxs("label",{children:["Stream Key",e.jsx("input",{type:"password",value:s.streamKey||"",onChange:r=>q(s.id,{streamKey:r.target.value}),placeholder:"Enter stream key",disabled:m})]})]}),e.jsx("button",{className:"remove-button",onClick:()=>P(s.id),disabled:m,children:"Remove"})]},s.id)}),t.destinations.length===0&&e.jsx("p",{className:"empty-message",children:"No destinations configured"})]})]}),v==="settings"&&e.jsxs("div",{className:"settings-panel",children:[e.jsxs("div",{className:"setting-section",children:[e.jsx("h4",{children:"Video"}),e.jsxs("label",{children:["Resolution",e.jsxs("select",{value:`${t.settings.video.resolution.width}x${t.settings.video.resolution.height}`,onChange:s=>{const[a,r]=s.target.value.split("x").map(Number);h({settings:{...t.settings,video:{...t.settings.video,resolution:{width:a,height:r}}},layout:{...t.layout,canvas:{...t.layout.canvas,width:a,height:r}}})},disabled:m,children:[e.jsx("option",{value:"1920x1080",children:"1080p (1920x1080)"}),e.jsx("option",{value:"1280x720",children:"720p (1280x720)"}),e.jsx("option",{value:"2560x1440",children:"1440p (2560x1440)"})]})]}),e.jsxs("label",{children:["Frame Rate",e.jsxs("select",{value:t.settings.video.frameRate,onChange:s=>h({settings:{...t.settings,video:{...t.settings.video,frameRate:parseInt(s.target.value)}}}),disabled:m,children:[e.jsx("option",{value:"24",children:"24 fps"}),e.jsx("option",{value:"30",children:"30 fps"}),e.jsx("option",{value:"60",children:"60 fps"})]})]}),e.jsxs("label",{children:["Bitrate (kbps)",e.jsx("input",{type:"number",value:t.settings.video.bitrate,onChange:s=>h({settings:{...t.settings,video:{...t.settings.video,bitrate:parseInt(s.target.value)||6e3}}}),min:"1000",max:"50000",disabled:m})]}),e.jsxs("label",{children:["Keyframe Interval (sec)",e.jsx("input",{type:"number",value:t.settings.video.keyframe,onChange:s=>h({settings:{...t.settings,video:{...t.settings.video,keyframe:parseInt(s.target.value)||2}}}),min:"1",max:"10",disabled:m})]})]}),e.jsxs("div",{className:"setting-section",children:[e.jsx("h4",{children:"Audio"}),e.jsxs("label",{children:["Sample Rate",e.jsxs("select",{value:t.settings.audio.sampleRate,onChange:s=>h({settings:{...t.settings,audio:{...t.settings.audio,sampleRate:parseInt(s.target.value)}}}),disabled:m,children:[e.jsx("option",{value:"44100",children:"44.1 kHz"}),e.jsx("option",{value:"48000",children:"48 kHz"})]})]}),e.jsxs("label",{children:["Audio Bitrate (kbps)",e.jsxs("select",{value:t.settings.audio.bitrate,onChange:s=>h({settings:{...t.settings,audio:{...t.settings.audio,bitrate:parseInt(s.target.value)}}}),disabled:m,children:[e.jsx("option",{value:"96",children:"96 kbps"}),e.jsx("option",{value:"128",children:"128 kbps"}),e.jsx("option",{value:"160",children:"160 kbps"}),e.jsx("option",{value:"320",children:"320 kbps"})]})]})]})]})]})]})]}),m&&e.jsx("footer",{className:"streaming__footer",children:e.jsxs("div",{className:"footer-stats",children:[e.jsxs("span",{className:"stat",children:[e.jsx("label",{children:"CPU"}),e.jsxs("span",{className:"value",children:[j.cpuUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"stat",children:[e.jsx("label",{children:"Memory"}),e.jsxs("span",{className:"value",children:[j.memoryUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"stat",children:[e.jsx("label",{children:"Dropped"}),e.jsx("span",{className:"value",children:j.droppedFrames})]}),e.jsxs("span",{className:"stat",children:[e.jsx("label",{children:"Peak Viewers"}),e.jsx("span",{className:"value",children:j.peakViewers})]})]})}),k&&e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Add Source"}),e.jsx("button",{className:"close-button",onClick:()=>M(!1),children:"×"})]}),e.jsx("div",{className:"modal-content",children:e.jsx("div",{className:"source-type-grid",children:te.map(s=>e.jsxs("button",{className:"source-type-button",onClick:()=>Q(s.type),children:[e.jsx("span",{className:"icon",children:s.icon}),e.jsx("span",{className:"name",children:s.name})]},s.type))})})]})}),W&&e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Add Destination"}),e.jsx("button",{className:"close-button",onClick:()=>z(!1),children:"×"})]}),e.jsx("div",{className:"modal-content",children:e.jsx("div",{className:"platform-grid",children:ae.map(s=>e.jsxs("button",{className:"platform-button",onClick:()=>O(s.platform),children:[e.jsx("span",{className:"icon",children:s.icon}),e.jsx("span",{className:"name",children:s.name})]},s.platform))})})]})})]})};exports.NiceLiveStreaming=he;exports.NiceScreenRecorder=ue;exports.NiceVideoEditor=ce;