@nice2dev/ui-video 1.2.1 → 1.3.0
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/dist/index.cjs +1 -1
- package/dist/index.mjs +651 -631
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),oe=require("@nice2dev/ui"),l=require("@nice2dev/ui-core"),u=require("react"),le={id:l.createId(),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"}}},de=[{type:"blur",name:"Blur",icon:"droplet"},{type:"brightness",name:"Brightness",icon:"sun"},{type:"contrast",name:"Contrast",icon:"moon"},{type:"saturation",name:"Saturation",icon:"palette"},{type:"grayscale",name:"Grayscale",icon:"square"},{type:"sepia",name:"Sepia",icon:"image"},{type:"chromaKey",name:"Chroma Key",icon:"layers"},{type:"crop",name:"Crop",icon:"crop"},{type:"zoom",name:"Zoom",icon:"search"}],ue=[{type:"fade",name:"Fade"},{type:"dissolve",name:"Dissolve"},{type:"wipe",name:"Wipe"},{type:"slide",name:"Slide"},{type:"zoom",name:"Zoom"},{type:"push",name:"Push"}],me=[{target:".nice-video-editor",titleKey:"tutorial.videoEditorPro.intro.title",title:"Video editor",contentKey:"tutorial.videoEditorPro.intro.content",content:"Add media to the timeline, arrange and trim clips, apply effects and transitions, then configure and run the export.",placement:"auto"}],ve=({project:z,onProjectChange:w,onExport:$,onAssetUpload:A,className:F="",tutorial:R})=>{const{t:g}=l.useNiceTranslation(),[a,n]=u.useState(z||le),[T,j]=u.useState("timeline"),[B,v]=u.useState(null),[b,f]=u.useState(null),[E,N]=u.useState(0),[L,U]=u.useState(!1),[y,q]=u.useState(1),[V,C]=u.useState(!0),[I,D]=u.useState(null),Q=u.useRef(null),X=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{z&&n(z)},[z]),u.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]);const _=u.useCallback(t=>{const c={...a,...t};n(c),w==null||w(c)},[a,w]),x=async t=>{const c=[];for(const i of Array.from(t)){const d=i.type.startsWith("video/")?"video":i.type.startsWith("audio/")?"audio":"image";let m;A?m=await A(i):m={id:l.createId(),type:d,name:i.name,url:URL.createObjectURL(i),size:i.size},c.push(m)}_({assets:[...a.assets,...c]})},P=t=>{const c={id:l.createId(),type:t,name:`${t.charAt(0).toUpperCase()+t.slice(1)} ${a.tracks.filter(i=>i.type===t).length+1}`,items:[],muted:!1,locked:!1,visible:!0};_({tracks:[...a.tracks,c]})},W=t=>{_({tracks:a.tracks.filter(c=>c.id!==t)}),B===t&&v(null)},O=t=>{_({tracks:a.tracks.map(c=>c.id===t?{...c,muted:!c.muted}:c)})},Z=t=>{_({tracks:a.tracks.map(c=>c.id===t?{...c,locked:!c.locked}:c)})},k=(t,c)=>{const i=a.tracks.find(p=>p.id===t);if(!i||i.locked)return;const d=i.items[i.items.length-1],m=d?d.startTime+d.duration:0,h={id:l.createId(),assetId:c.id,type:c.type,startTime:m,duration:c.duration||5,offset:0,properties:{x:0,y:0,opacity:1,scale:1,volume:1},effects:[],transitions:[]};_({tracks:a.tracks.map(p=>p.id===t?{...p,items:[...p.items,h]}:p)})},H=(t,c,i)=>{const d={id:l.createId(),type:i,name:i.charAt(0).toUpperCase()+i.slice(1),parameters:ee(i)};_({tracks:a.tracks.map(m=>m.id===t?{...m,items:m.items.map(h=>h.id===c?{...h,effects:[...h.effects,d]}:h)}:m)})},M=(t,c,i,d)=>{const m={id:l.createId(),type:i,duration:.5,position:d};_({tracks:a.tracks.map(h=>h.id===t?{...h,items:h.items.map(p=>p.id===c?{...p,transitions:[...p.transitions,m]}:p)}:h)})},ee=t=>{switch(t){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:"var(--nice-success, #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=()=>{L?(S.current&&clearInterval(S.current),U(!1)):(S.current=setInterval(()=>{N(t=>{const c=Math.max(...a.tracks.flatMap(i=>i.items.map(d=>d.startTime+d.duration)),0);return t>=c?(clearInterval(S.current),U(!1),0):t+1/a.frameRate})},1e3/a.frameRate),U(!0))},G=t=>{N(Math.max(0,t))},Y=async()=>{if($){D(0);try{const t=setInterval(()=>{D(c=>c!==null&&c<90?c+Math.random()*10:c)},500);await $(a,a.settings.video.codec),clearInterval(t),D(100),setTimeout(()=>D(null),2e3)}catch(t){D(null),console.error("Export failed:",t)}}},J=t=>{const c=Math.floor(t/60),i=Math.floor(t%60),d=Math.floor(t%1*a.frameRate);return`${c.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${d.toString().padStart(2,"0")}`},K=()=>{for(const t of a.tracks){const c=t.items.find(i=>i.id===b);if(c)return{track:t,item:c}}return null},ie=e.jsxs("header",{className:"nice-video-studio__header",children:[e.jsxs("div",{className:"nice-video-studio__header-project-info",children:[e.jsx("input",{type:"text",value:a.name,onChange:t=>_({name:t.target.value}),className:"nice-video-studio__project-name-input"}),e.jsxs("span",{className:"nice-video-studio__project-settings",children:[a.resolution.width,"x",a.resolution.height," • ",a.frameRate,"fps"]})]}),e.jsx("div",{className:"nice-video-studio__header-tabs",children:["timeline","effects","transitions","export"].map(t=>e.jsx("button",{className:`nice-video-studio__tab-button ${T===t?"nice-video-studio__tab-button--active":""}`,onClick:()=>j(t),children:t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsx("div",{className:"nice-video-studio__header-actions",children:e.jsx("button",{className:"nice-video-studio__action-button nice-video-studio__action-button--primary",onClick:Y,disabled:I!==null,children:I!==null?`Exporting ${Math.round(I)}%`:"Export"})})]}),te=b&&T!=="export"?(()=>{const t=K();if(!t)return null;const{track:c,item:i}=t;return e.jsxs("div",{className:"nice-video-studio__item-inspector",children:[e.jsx("h4",{children:g("videoEditor.itemProperties","Item Properties")}),e.jsxs("div",{className:"nice-video-studio__inspector-section",children:[e.jsxs("label",{children:[g("videoEditor.startTime","Start Time"),e.jsx("input",{type:"number",step:"0.1",value:i.startTime,onChange:d=>{const m=parseFloat(d.target.value);_({tracks:a.tracks.map(h=>h.id===c.id?{...h,items:h.items.map(p=>p.id===i.id?{...p,startTime:m}:p)}:h)})}})]}),e.jsxs("label",{children:[g("videoEditor.duration","Duration"),e.jsx("input",{type:"number",step:"0.1",value:i.duration,onChange:d=>{const m=parseFloat(d.target.value);_({tracks:a.tracks.map(h=>h.id===c.id?{...h,items:h.items.map(p=>p.id===i.id?{...p,duration:m}:p)}:h)})}})]}),e.jsxs("label",{children:[g("videoEditor.opacity","Opacity"),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:i.properties.opacity??1,onChange:d=>{const m=parseFloat(d.target.value);_({tracks:a.tracks.map(h=>h.id===c.id?{...h,items:h.items.map(p=>p.id===i.id?{...p,properties:{...p.properties,opacity:m}}:p)}:h)})}})]})]}),e.jsxs("h4",{children:["Effects (",i.effects.length,")"]}),e.jsx("div",{className:"nice-video-studio__effects-list",children:i.effects.map(d=>e.jsx("div",{className:"nice-video-studio__effect-badge",children:d.name},d.id))})]})})():null,s=V?e.jsxs("aside",{className:"nice-video-studio__asset-library",children:[e.jsxs("div",{className:"nice-video-studio__asset-library-header",children:[e.jsx("h3",{children:g("videoEditor.assets","Assets")}),e.jsx("button",{"aria-label":g("videoEditor.close","Close"),className:"nice-video-studio__close-button",onClick:()=>C(!1),children:e.jsx(l.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-video-studio__asset-library-upload",children:e.jsxs("label",{className:"nice-video-studio__upload-zone",children:[e.jsx("input",{type:"file",multiple:!0,accept:"video/*,audio/*,image/*",onChange:t=>t.target.files&&x(t.target.files),hidden:!0}),e.jsx("span",{className:"nice-video-studio__upload-icon",children:"+"}),e.jsx("span",{children:g("videoEditor.dropFilesOrClickTo","Drop files or click to upload")})]})}),e.jsx("div",{className:"nice-video-studio__asset-library-list",children:a.assets.map(t=>e.jsxs("div",{className:"nice-video-studio__asset-item",draggable:!0,onDragStart:c=>c.dataTransfer.setData("assetId",t.id),children:[e.jsx("div",{className:"nice-video-studio__asset-thumbnail",children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):e.jsx("span",{className:"nice-video-studio__asset-type-icon",children:e.jsx(l.NiceIcon,{name:t.type==="video"?"video":t.type==="audio"?"music":"image",size:24})})}),e.jsxs("div",{className:"nice-video-studio__asset-info",children:[e.jsx("span",{className:"nice-video-studio__asset-name",children:t.name}),e.jsxs("span",{className:"nice-video-studio__asset-meta",children:[(t.size/1024/1024).toFixed(1),"MB"]})]})]},t.id))})]}):void 0,r=e.jsx("div",{className:"nice-video-studio__preview-area",children:e.jsxs("div",{className:"nice-video-studio__preview-container",children:[e.jsxs("div",{className:"nice-video-studio__preview-canvas",style:{aspectRatio:`${a.resolution.width}/${a.resolution.height}`},children:[e.jsx("video",{ref:X,className:"nice-video-studio__preview-video"}),e.jsx("div",{className:"nice-video-studio__preview-overlay",children:!V&&e.jsx("button",{className:"nice-video-studio__toggle-library-button",onClick:()=>C(!0),"aria-label":g("videoEditor.showAssetLibrary","Show asset library"),children:e.jsx(l.NiceIcon,{name:"folder",size:16})})})]}),e.jsxs("div",{className:"nice-video-studio__playback-controls",children:[e.jsx("button",{onClick:()=>G(0),"aria-label":g("videoEditor.goToStart","Go to start"),children:e.jsx(l.NiceIcon,{name:"skip-back",size:16})}),e.jsx("button",{onClick:()=>G(E-1/a.frameRate),"aria-label":g("videoEditor.previousFrame","Previous frame"),children:e.jsx(l.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("button",{onClick:se,className:"nice-video-studio__play-button","aria-label":L?"Pause":"Play",children:e.jsx(l.NiceIcon,{name:L?"pause":"play",size:18})}),e.jsx("button",{onClick:()=>G(E+1/a.frameRate),"aria-label":g("videoEditor.nextFrame","Next frame"),children:e.jsx(l.NiceIcon,{name:"chevron-right",size:16})}),e.jsx("span",{className:"nice-video-studio__time-display",children:J(E)})]})]})}),o=e.jsxs("div",{className:"nice-video-studio__panel",children:[T==="timeline"&&e.jsxs("div",{className:"nice-video-studio__timeline-panel",children:[e.jsxs("div",{className:"nice-video-studio__timeline-toolbar",children:[e.jsxs("div",{className:"nice-video-studio__track-buttons",children:[e.jsx("button",{onClick:()=>P("video"),children:"+ Video Track"}),e.jsx("button",{onClick:()=>P("audio"),children:"+ Audio Track"}),e.jsx("button",{onClick:()=>P("text"),children:"+ Text Track"})]}),e.jsxs("div",{className:"nice-video-studio__zoom-controls",children:[e.jsx("button",{onClick:()=>q(Math.max(.25,y-.25)),children:"-"}),e.jsxs("span",{children:[Math.round(y*100),"%"]}),e.jsx("button",{onClick:()=>q(Math.min(4,y+.25)),children:"+"})]})]}),e.jsxs("div",{className:"nice-video-studio__timeline-container",ref:Q,children:[e.jsx("div",{className:"nice-video-studio__timeline-ruler",children:Array.from({length:Math.ceil(30/y)}).map((t,c)=>e.jsx("div",{className:"nice-video-studio__ruler-mark",style:{left:`${c*50*y}px`},children:J(c)},c))}),e.jsx("div",{className:"nice-video-studio__timeline-playhead",style:{left:`${E*50*y}px`}}),e.jsx("div",{className:"nice-video-studio__timeline-tracks",children:a.tracks.map(t=>e.jsxs("div",{className:`nice-video-studio__timeline-track ${B===t.id?"nice-video-studio__timeline-track--selected":""} ${t.locked?"nice-video-studio__timeline-track--locked":""}`,onClick:()=>v(t.id),onDrop:c=>{c.preventDefault();const i=c.dataTransfer.getData("assetId"),d=a.assets.find(m=>m.id===i);d&&k(t.id,d)},onDragOver:c=>c.preventDefault(),children:[e.jsxs("div",{className:"nice-video-studio__track-header",children:[e.jsx("span",{className:"nice-video-studio__track-name",children:t.name}),e.jsxs("div",{className:"nice-video-studio__track-controls",children:[e.jsx("button",{className:`nice-video-studio__track-toggle ${t.muted?"nice-video-studio__track-toggle--active":""}`,onClick:c=>{c.stopPropagation(),O(t.id)},children:e.jsx(l.NiceIcon,{name:t.muted?"volume-off":"volume",size:14})}),e.jsx("button",{className:`nice-video-studio__track-toggle ${t.locked?"nice-video-studio__track-toggle--active":""}`,onClick:c=>{c.stopPropagation(),Z(t.id)},children:e.jsx(l.NiceIcon,{name:t.locked?"lock":"unlock",size:14})}),e.jsx("button",{onClick:c=>{c.stopPropagation(),W(t.id)},"aria-label":g("videoEditor.removeTrack","Remove track"),children:e.jsx(l.NiceIcon,{name:"trash",size:14})})]})]}),e.jsx("div",{className:"nice-video-studio__track-items",children:t.items.map(c=>{const i=a.assets.find(d=>d.id===c.assetId);return e.jsxs("div",{className:`nice-video-studio__track-item nice-video-studio__track-item--${c.type} ${b===c.id?"nice-video-studio__track-item--selected":""}`,style:{left:`${c.startTime*50*y}px`,width:`${c.duration*50*y}px`},onClick:d=>{d.stopPropagation(),f(c.id)},children:[e.jsx("span",{className:"nice-video-studio__item-name",children:(i==null?void 0:i.name)||"Untitled"}),c.transitions.length>0&&e.jsx("span",{className:"nice-video-studio__item-transitions",children:e.jsx(l.NiceIcon,{name:"wand",size:12})}),c.effects.length>0&&e.jsx("span",{className:"nice-video-studio__item-effects",children:e.jsx(l.NiceIcon,{name:"palette",size:12})})]},c.id)})})]},t.id))})]})]}),T==="effects"&&e.jsxs("div",{className:"nice-video-studio__effects-panel",children:[e.jsx("h3",{children:g("videoEditor.videoEffects","Video Effects")}),e.jsx("p",{className:"nice-video-studio__panel-hint",children:g("videoEditor.selectAClipToApply","Select a clip to apply effects")}),e.jsx("div",{className:"nice-video-studio__effects-grid",children:de.map(t=>e.jsxs("button",{className:"nice-video-studio__effect-preset",disabled:!b,onClick:()=>{const c=K();c&&H(c.track.id,c.item.id,t.type)},children:[e.jsx("span",{className:"nice-video-studio__effect-icon",children:e.jsx(l.NiceIcon,{name:t.icon,size:16})}),e.jsx("span",{className:"nice-video-studio__effect-name",children:t.name})]},t.type))})]}),T==="transitions"&&e.jsxs("div",{className:"nice-video-studio__transitions-panel",children:[e.jsx("h3",{children:g("videoEditor.transitions","Transitions")}),e.jsx("p",{className:"nice-video-studio__panel-hint",children:g("videoEditor.selectAClipAndAdd","Select a clip and add transitions between clips")}),e.jsx("div",{className:"nice-video-studio__transitions-grid",children:ue.map(t=>e.jsxs("div",{className:"nice-video-studio__transition-preset",children:[e.jsx("span",{className:"nice-video-studio__transition-name",children:t.name}),e.jsxs("div",{className:"nice-video-studio__transition-buttons",children:[e.jsx("button",{disabled:!b,onClick:()=>{const c=K();c&&M(c.track.id,c.item.id,t.type,"start")},children:"In"}),e.jsx("button",{disabled:!b,onClick:()=>{const c=K();c&&M(c.track.id,c.item.id,t.type,"end")},children:"Out"})]})]},t.type))})]}),T==="export"&&e.jsxs("div",{className:"nice-video-studio__export-panel",children:[e.jsx("h3",{children:g("videoEditor.exportSettings","Export Settings")}),e.jsxs("div",{className:"nice-video-studio__export-settings",children:[e.jsxs("div",{className:"nice-video-studio__setting-group",children:[e.jsx("label",{children:g("videoEditor.resolution","Resolution")}),e.jsxs("select",{value:`${a.resolution.width}x${a.resolution.height}`,onChange:t=>{const[c,i]=t.target.value.split("x").map(Number);_({resolution:{width:c,height:i}})},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:"nice-video-studio__setting-group",children:[e.jsx("label",{children:g("videoEditor.frameRate","Frame Rate")}),e.jsxs("select",{value:a.frameRate,onChange:t=>_({frameRate:parseInt(t.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:"nice-video-studio__setting-group",children:[e.jsx("label",{children:g("videoEditor.videoCodec","Video Codec")}),e.jsxs("select",{value:a.settings.video.codec,onChange:t=>_({settings:{...a.settings,video:{...a.settings.video,codec:t.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:"nice-video-studio__setting-group",children:[e.jsx("label",{children:"Video Bitrate (Mbps)"}),e.jsx("input",{type:"number",value:a.settings.video.bitrate/1e3,onChange:t=>_({settings:{...a.settings,video:{...a.settings.video,bitrate:parseFloat(t.target.value)*1e3}}}),min:"1",max:"100"})]})]}),e.jsx("button",{className:"nice-video-studio__export-button",onClick:Y,disabled:I!==null,children:I!==null?`Exporting... ${Math.round(I)}%`:"Export Video"}),I!==null&&e.jsx("div",{className:"nice-video-studio__export-progress",children:e.jsx("div",{className:"nice-video-studio__export-progress-bar",style:{width:`${I}%`}})})]})]});return e.jsxs(oe.NiceAppShell,{flush:!0,className:`nice-video-editor nice-video-studio ${F}`,height:"100%",style:{position:"relative",minHeight:600},toolbar:ie,sidebar:s,rightSidebar:te??void 0,bottomPanel:o,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(l.NiceTutorialButton,{steps:l.resolveTutorial(R,me)})}),r]})},he={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"}},pe=({options:z,onRecordingStart:w,onRecordingStop:$,onRecordingPause:A,onRecordingResume:F,onError:R,className:g=""})=>{var t,c;const{t:a}=l.useNiceTranslation(),[n,T]=u.useState({...he,...z}),[j,B]=u.useState(null),[v,b]=u.useState("idle"),[f,E]=u.useState([]),[N,L]=u.useState(null),[U,y]=u.useState(null),[q,V]=u.useState(!1),[C,I]=u.useState(!1),[D,Q]=u.useState("pen"),[X,S]=u.useState("var(--nice-danger, #ff0000)"),_=u.useRef(null),x=u.useRef([]),P=u.useRef(null),W=u.useRef(null),O=u.useRef(null),Z=u.useRef(0);u.useEffect(()=>()=>{N&&N.getTracks().forEach(i=>i.stop()),O.current&&clearInterval(O.current)},[N]);const k=i=>{T(d=>({...d,...i,video:{...d.video,...i.video},audio:{...d.audio,...i.audio},output:{...d.output,...i.output}}))},H=async()=>{try{b("preparing");const i={video:{cursor:n.video.showCursor?"always":"never",frameRate:n.video.frameRate},audio:n.audio.source==="system"||n.audio.source==="both"},d=await navigator.mediaDevices.getDisplayMedia(i);if(n.audio.enabled&&(n.audio.source==="microphone"||n.audio.source==="both"))try{(await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:n.audio.echoCancellation,noiseSuppression:n.audio.noiseSuppression}})).getAudioTracks().forEach(h=>d.addTrack(h))}catch(m){console.warn("Could not access microphone:",m)}L(d),P.current&&(P.current.srcObject=d,P.current.play()),b("idle")}catch(i){b("error"),R==null||R(i instanceof Error?i:new Error("Failed to start preview"))}},M=async()=>{N||await H();for(let i=3;i>0;i--)y(i),await new Promise(d=>setTimeout(d,1e3));y(null);try{const i=N||await ee();if(!i)throw new Error("No stream available");const d=ie(n.output.format),m=new MediaRecorder(i,{mimeType:d,videoBitsPerSecond:te(n.output.quality)});x.current=[],m.ondataavailable=p=>{p.data.size>0&&x.current.push(p.data)},m.onstop=()=>{const p=new Blob(x.current,{type:d});j&&($==null||$({...j,status:"stopped"},p))},_.current=m,m.start(1e3),Z.current=Date.now();const h={id:l.createId(),status:"recording",startTime:new Date,duration:0,size:0,options:n,chunks:[]};B(h),b("recording"),w==null||w(h),O.current=setInterval(()=>{B(p=>p?{...p,duration:(Date.now()-Z.current)/1e3,size:x.current.reduce((re,ce)=>re+ce.size,0)}:null)},100)}catch(i){b("error"),R==null||R(i instanceof Error?i:new Error("Failed to start recording"))}},ee=async()=>(await H(),N),se=()=>{_.current&&v==="recording"&&(_.current.pause(),b("paused"),A==null||A())},G=()=>{_.current&&v==="paused"&&(_.current.resume(),b("recording"),F==null||F())},Y=()=>{O.current&&clearInterval(O.current),_.current&&(v==="recording"||v==="paused")&&(_.current.stop(),b("stopped")),N&&(N.getTracks().forEach(i=>i.stop()),L(null))},J=u.useCallback(i=>{if(v!=="recording")return;const d={id:l.createId(),time:(j==null?void 0:j.duration)||0,label:i||`Marker ${f.length+1}`,color:s()};E(m=>[...m,d])},[v,j==null?void 0:j.duration,f.length]),K=i=>{E(d=>d.filter(m=>m.id!==i))},ie=i=>{switch(i){case"mp4":return"video/mp4";case"mkv":return"video/x-matroska";default:return"video/webm;codecs=vp9"}},te=i=>{switch(i){case"low":return 25e5;case"medium":return 5e6;case"lossless":return 2e7;default:return 8e6}},s=()=>{const i=["var(--nice-danger, #ff4444)","#44ff44","#4444ff","#ffff44","#ff44ff","#44ffff"];return i[Math.floor(Math.random()*i.length)]},r=i=>{const d=Math.floor(i/3600),m=Math.floor(i%3600/60),h=Math.floor(i%60),p=Math.floor(i%1*100);return d>0?`${d}:${m.toString().padStart(2,"0")}:${h.toString().padStart(2,"0")}`:`${m.toString().padStart(2,"0")}:${h.toString().padStart(2,"0")}.${p.toString().padStart(2,"0")}`},o=i=>i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/1024/1024).toFixed(1)} MB`;return e.jsxs("div",{className:`nice-screen-recorder ${g}`,children:[e.jsxs("div",{className:"nice-screen-recorder__preview",children:[U!==null&&e.jsx("div",{className:"nice-screen-recorder__countdown-overlay",children:e.jsx("span",{className:"nice-screen-recorder__countdown-number",children:U})}),e.jsx("video",{ref:P,className:"nice-screen-recorder__preview-video",muted:!0,playsInline:!0}),C&&e.jsx("canvas",{ref:W,className:"nice-screen-recorder__annotation-canvas"}),!N&&v==="idle"&&e.jsx("div",{className:"nice-screen-recorder__preview-placeholder",children:e.jsxs("button",{className:"nice-screen-recorder__start-preview-button",onClick:H,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"monitor",size:18})}),e.jsx("span",{children:a("screenRecorder.selectScreenToRecord","Select Screen to Record")})]})}),v==="recording"&&e.jsxs("div",{className:"nice-screen-recorder__recording-indicator",children:[e.jsx("span",{className:"nice-screen-recorder__recording-dot"}),e.jsx("span",{children:"REC"})]})]}),e.jsxs("div",{className:"nice-screen-recorder__controls",children:[e.jsxs("div",{className:"nice-screen-recorder__controls-main",children:[v==="idle"&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--record",onClick:M,disabled:!!U,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"circle",size:18})}),e.jsx("span",{children:a("screenRecorder.startRecording","Start Recording")})]}),v==="recording"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--pause",onClick:se,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"pause",size:18})}),e.jsx("span",{children:a("screenRecorder.pause","Pause")})]}),e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--stop",onClick:Y,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"stop",size:18})}),e.jsx("span",{children:a("screenRecorder.stop","Stop")})]})]}),v==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--resume",onClick:G,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"play",size:18})}),e.jsx("span",{children:a("screenRecorder.resume","Resume")})]}),e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--stop",onClick:Y,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"stop",size:18})}),e.jsx("span",{children:a("screenRecorder.stop","Stop")})]})]}),v==="stopped"&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--new",onClick:()=>{b("idle"),B(null),E([])},children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"refresh",size:18})}),e.jsx("span",{children:a("screenRecorder.newRecording","New Recording")})]})]}),e.jsxs("div",{className:"nice-screen-recorder__controls-secondary",children:[(v==="recording"||v==="paused")&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--marker",onClick:()=>J(),children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"tag",size:18})}),e.jsx("span",{children:a("screenRecorder.addMarker","Add Marker")})]}),e.jsxs("button",{className:`nice-screen-recorder__control-button ${C?"nice-screen-recorder__control-button--active":""}`,onClick:()=>I(!C),disabled:v!=="recording",children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"pen",size:18})}),e.jsx("span",{children:a("screenRecorder.annotate","Annotate")})]}),e.jsx("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--settings",onClick:()=>V(!q),disabled:v==="recording","aria-label":a("screenRecorder.settings","Settings"),children:e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(l.NiceIcon,{name:"settings",size:18})})})]})]}),e.jsxs("div",{className:"nice-screen-recorder__status",children:[e.jsxs("div",{className:"nice-screen-recorder__status-info",children:[e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:"Duration:"})," ",r((j==null?void 0:j.duration)||0)]}),e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:"Size:"})," ",o((j==null?void 0:j.size)||0)]}),e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:"Markers:"})," ",f.length]})]}),e.jsxs("div",{className:"nice-screen-recorder__status-quality",children:[n.video.resolution&&e.jsxs("span",{children:[n.video.resolution.width,"x",n.video.resolution.height]}),e.jsxs("span",{children:[n.video.frameRate,"fps"]}),e.jsx("span",{className:`nice-screen-recorder__audio-status nice-screen-recorder__audio-status--${n.audio.enabled?"on":"off"}`,children:e.jsx(l.NiceIcon,{name:n.audio.enabled?"volume":"volume-off",size:14})})]})]}),C&&v==="recording"&&e.jsxs("div",{className:"nice-screen-recorder__annotation-tools",children:[e.jsx("div",{className:"nice-screen-recorder__tool-group",children:["pen","arrow","rectangle","text"].map(i=>e.jsx("button",{className:`nice-screen-recorder__tool-button ${D===i?"nice-screen-recorder__tool-button--active":""}`,onClick:()=>Q(i),"aria-label":i,children:e.jsx(l.NiceIcon,{name:i==="pen"?"pen":i==="arrow"?"arrow-right":i==="rectangle"?"square":"type",size:16})},i))}),e.jsx("div",{className:"nice-screen-recorder__color-group",children:["var(--nice-danger, #ff0000)","var(--nice-success, #00ff00)","var(--nice-primary, #0000ff)","var(--nice-warning, #ffff00)","var(--nice-bg, #fff)","var(--nice-text, #000000)"].map(i=>e.jsx("button",{className:`nice-screen-recorder__color-button ${X===i?"nice-screen-recorder__color-button--active":""}`,style:{backgroundColor:i},onClick:()=>S(i)},i))})]}),f.length>0&&e.jsxs("div",{className:"nice-screen-recorder__markers",children:[e.jsx("h4",{children:a("screenRecorder.markers","Markers")}),e.jsx("div",{className:"nice-screen-recorder__markers-list",children:f.map(i=>e.jsxs("div",{className:"nice-screen-recorder__marker-item",style:{borderLeftColor:i.color},children:[e.jsx("span",{className:"nice-screen-recorder__marker-time",children:r(i.time)}),e.jsx("input",{type:"text",value:i.label,onChange:d=>{E(m=>m.map(h=>h.id===i.id?{...h,label:d.target.value}:h))},className:"nice-screen-recorder__marker-label"}),e.jsx("button",{"aria-label":a("screenRecorder.close","Close"),className:"nice-screen-recorder__marker-remove",onClick:()=>K(i.id),children:e.jsx(l.NiceIcon,{name:"close",size:16})})]},i.id))})]}),q&&e.jsxs("div",{className:"nice-screen-recorder__settings",children:[e.jsxs("div",{className:"nice-screen-recorder__settings-header",children:[e.jsx("h3",{children:a("screenRecorder.recordingSettings","Recording Settings")}),e.jsx("button",{"aria-label":a("screenRecorder.close","Close"),className:"nice-screen-recorder__close-button",onClick:()=>V(!1),children:e.jsx(l.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:a("screenRecorder.video","Video")}),e.jsxs("label",{children:[a("screenRecorder.source","Source"),e.jsxs("select",{value:n.video.source,onChange:i=>k({video:{...n.video,source:i.target.value}}),children:[e.jsx("option",{value:"screen",children:a("screenRecorder.entireScreen","Entire Screen")}),e.jsx("option",{value:"window",children:a("screenRecorder.applicationWindow","Application Window")}),e.jsx("option",{value:"tab",children:a("screenRecorder.browserTab","Browser Tab")}),e.jsx("option",{value:"camera",children:a("screenRecorder.camera","Camera")})]})]}),e.jsxs("label",{children:[a("screenRecorder.resolution","Resolution"),e.jsxs("select",{value:`${(t=n.video.resolution)==null?void 0:t.width}x${(c=n.video.resolution)==null?void 0:c.height}`,onChange:i=>{const[d,m]=i.target.value.split("x").map(Number);k({video:{...n.video,resolution:{width:d,height:m}}})},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:[a("screenRecorder.frameRate","Frame Rate"),e.jsxs("select",{value:n.video.frameRate,onChange:i=>k({video:{...n.video,frameRate:parseInt(i.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:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.video.showCursor,onChange:i=>k({video:{...n.video,showCursor:i.target.checked}})}),a("screenRecorder.showCursor","Show Cursor")]})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:a("screenRecorder.audio","Audio")}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.audio.enabled,onChange:i=>k({audio:{...n.audio,enabled:i.target.checked}})}),a("screenRecorder.enableAudio","Enable Audio")]}),n.audio.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[a("screenRecorder.source","Source"),e.jsxs("select",{value:n.audio.source,onChange:i=>k({audio:{...n.audio,source:i.target.value}}),children:[e.jsx("option",{value:"system",children:a("screenRecorder.systemAudio","System Audio")}),e.jsx("option",{value:"microphone",children:a("screenRecorder.microphone","Microphone")}),e.jsx("option",{value:"both",children:a("screenRecorder.both","Both")})]})]}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.audio.echoCancellation,onChange:i=>k({audio:{...n.audio,echoCancellation:i.target.checked}})}),a("screenRecorder.echoCancellation","Echo Cancellation")]}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.audio.noiseSuppression,onChange:i=>k({audio:{...n.audio,noiseSuppression:i.target.checked}})}),a("screenRecorder.noiseSuppression","Noise Suppression")]})]})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:a("screenRecorder.output","Output")}),e.jsxs("label",{children:[a("screenRecorder.format","Format"),e.jsxs("select",{value:n.output.format,onChange:i=>k({output:{...n.output,format:i.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:[a("screenRecorder.quality","Quality"),e.jsxs("select",{value:n.output.quality,onChange:i=>k({output:{...n.output,quality:i.target.value}}),children:[e.jsx("option",{value:"low",children:"Low (Smaller file)"}),e.jsx("option",{value:"medium",children:a("screenRecorder.medium","Medium")}),e.jsx("option",{value:"high",children:"High (Recommended)"}),e.jsx("option",{value:"lossless",children:"Lossless (Largest file)"})]})]})]})]})]})},xe={id:l.createId(),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:"video",defaultUrl:"rtmp://a.rtmp.youtube.com/live2"},{platform:"twitch",name:"Twitch",icon:"gamepad",defaultUrl:"rtmp://live.twitch.tv/app"},{platform:"facebook",name:"Facebook",icon:"users",defaultUrl:"rtmps://live-api-s.facebook.com:443/rtmp"},{platform:"custom-rtmp",name:"Custom RTMP",icon:"link",defaultUrl:""},{platform:"custom-srt",name:"Custom SRT",icon:"lock",defaultUrl:""}],ne=[{type:"camera",name:"Camera",icon:"camera"},{type:"screen",name:"Screen Capture",icon:"monitor"},{type:"window",name:"Window Capture",icon:"window"},{type:"browser",name:"Browser Source",icon:"globe"},{type:"image",name:"Image",icon:"image"},{type:"video",name:"Video",icon:"video"},{type:"microphone",name:"Microphone",icon:"mic"},{type:"system-audio",name:"System Audio",icon:"volume"}],_e=({config:z,onConfigChange:w,onStreamStart:$,onStreamStop:A,onStatsUpdate:F,onError:R,className:g=""})=>{const{t:a}=l.useNiceTranslation(),[n,T]=u.useState(z||xe),[j,B]=u.useState("sources"),[v,b]=u.useState(!1),[f,E]=u.useState({duration:0,viewers:0,peakViewers:0,bitrate:0,fps:0,droppedFrames:0,cpuUsage:0,memoryUsage:0}),[N,L]=u.useState(null),[U,y]=u.useState(!1),[q,V]=u.useState(!1),[C,I]=u.useState([n.layout]),[D,Q]=u.useState(0),X=u.useRef(null),S=u.useRef(null),_=u.useRef(0);u.useEffect(()=>{z&&T(z)},[z]),u.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]);const x=u.useCallback(s=>{const r={...n,...s};T(r),w==null||w(r)},[n,w]),P=s=>{const r=ae.find(t=>t.platform===s),o={id:l.createId(),name:(r==null?void 0:r.name)||"Custom",platform:s,url:(r==null?void 0:r.defaultUrl)||"",streamKey:"",enabled:!0,status:"idle"};x({destinations:[...n.destinations,o]}),V(!1)},W=(s,r)=>{x({destinations:n.destinations.map(o=>o.id===s?{...o,...r}:o)})},O=s=>{x({destinations:n.destinations.filter(r=>r.id!==s)})},Z=async s=>{const r=ne.find(c=>c.type===s),o={id:l.createId(),type:s,name:`${(r==null?void 0:r.name)||s} ${n.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},d=(await navigator.mediaDevices.enumerateDevices()).filter(m=>s==="camera"?m.kind==="videoinput":m.kind==="audioinput");d.length>0&&(o.settings.deviceId=d[0].deviceId)}else(s==="screen"||s==="window")&&await navigator.mediaDevices.getDisplayMedia({video:!0})}catch(c){console.warn(`Could not access ${s}:`,c)}x({sources:[...n.sources,o]});const t={id:l.createId(),sourceId:o.id,position:{x:0,y:0},size:{width:n.layout.canvas.width,height:n.layout.canvas.height},visible:!0,opacity:1,zIndex:n.layout.layers.length};x({layout:{...n.layout,layers:[...n.layout.layers,t]}}),y(!1)},k=(s,r)=>{x({sources:n.sources.map(o=>o.id===s?{...o,...r}:o)})},H=s=>{x({sources:n.sources.filter(r=>r.id!==s),layout:{...n.layout,layers:n.layout.layers.filter(r=>r.sourceId!==s)}})},M=(s,r)=>{x({layout:{...n.layout,layers:n.layout.layers.map(o=>o.id===s?{...o,...r}:o)}})},ee=s=>{const r=n.layout.layers.findIndex(o=>o.id===s);if(r<n.layout.layers.length-1){const o=[...n.layout.layers];[o[r],o[r+1]]=[o[r+1],o[r]],o.forEach((t,c)=>{t.zIndex=c}),x({layout:{...n.layout,layers:o}})}},se=s=>{const r=n.layout.layers.findIndex(o=>o.id===s);if(r>0){const o=[...n.layout.layers];[o[r],o[r-1]]=[o[r-1],o[r]],o.forEach((t,c)=>{t.zIndex=c}),x({layout:{...n.layout,layers:o}})}},G=()=>{const s={name:`Scene ${C.length+1}`,canvas:{...n.layout.canvas},layers:[]};I([...C,s])},Y=s=>{const r=[...C];r[D]=n.layout,I(r),Q(s),x({layout:C[s]})},J=async()=>{try{x({destinations:n.destinations.map(s=>s.enabled?{...s,status:"connecting"}:s)}),await new Promise(s=>setTimeout(s,2e3)),x({destinations:n.destinations.map(s=>s.enabled?{...s,status:"live"}:s)}),b(!0),_.current=Date.now(),$==null||$(),S.current=setInterval(()=>{const s={duration:(Date.now()-_.current)/1e3,viewers:Math.floor(Math.random()*100)+f.viewers,peakViewers:Math.max(f.peakViewers,f.viewers),bitrate:n.settings.video.bitrate+Math.floor(Math.random()*500-250),fps:n.settings.video.frameRate-Math.random()*2,droppedFrames:f.droppedFrames+(Math.random()>.95?1:0),cpuUsage:15+Math.random()*30,memoryUsage:40+Math.random()*20};E(s),F==null||F(s)},1e3)}catch(s){R==null||R(s instanceof Error?s:new Error("Failed to start stream")),x({destinations:n.destinations.map(r=>({...r,status:"error"}))})}},K=()=>{S.current&&clearInterval(S.current),x({destinations:n.destinations.map(s=>({...s,status:"idle"}))}),b(!1),A==null||A()},ie=s=>{const r=Math.floor(s/3600),o=Math.floor(s%3600/60),t=Math.floor(s%60);return`${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`},te=s=>{switch(s){case"live":return"var(--nice-success, #00ff00)";case"connecting":return"var(--nice-warning, #ffff00)";case"error":return"var(--nice-danger, #ff0000)";default:return"var(--nice-text-secondary, #888888)"}};return e.jsxs("div",{className:`nice-live-streaming ${g}`,children:[e.jsxs("header",{className:"nice-live-streaming__header",children:[e.jsxs("div",{className:"nice-live-streaming__header-title",children:[e.jsx("input",{type:"text",value:n.name,onChange:s=>x({name:s.target.value}),className:"nice-live-streaming__stream-name-input"}),v&&e.jsxs("span",{className:"nice-live-streaming__live-badge",children:[e.jsx("span",{className:"nice-live-streaming__live-dot"})," ",a("liveStreaming.live","LIVE")]})]}),e.jsx("div",{className:"nice-live-streaming__header-stats",children:v&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(l.NiceIcon,{name:"clock",size:14})," ",ie(f.duration)]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(l.NiceIcon,{name:"users",size:14})," ",f.viewers]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(l.NiceIcon,{name:"bar-chart",size:14})," ",Math.round(f.bitrate)," kbps"]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(l.NiceIcon,{name:"video",size:14})," ",f.fps.toFixed(1)," fps"]})]})}),e.jsx("div",{className:"nice-live-streaming__header-actions",children:v?e.jsx("button",{className:"nice-live-streaming__action-button nice-live-streaming__action-button--stop",onClick:K,children:a("liveStreaming.endStream","End Stream")}):e.jsx("button",{className:"nice-live-streaming__action-button nice-live-streaming__action-button--go-live",onClick:J,disabled:n.destinations.filter(s=>s.enabled).length===0,children:a("liveStreaming.goLive","Go Live")})})]}),e.jsxs("div",{className:"nice-live-streaming__main",children:[e.jsxs("div",{className:"nice-live-streaming__preview",children:[e.jsxs("div",{className:"nice-live-streaming__scenes-bar",children:[C.map((s,r)=>e.jsx("button",{className:`nice-live-streaming__scene-button ${D===r?"nice-live-streaming__scene-button--active":""}`,onClick:()=>Y(r),children:s.name},r)),e.jsx("button",{className:"nice-live-streaming__scene-button nice-live-streaming__scene-button--add",onClick:G,children:"+"})]}),e.jsx("div",{ref:X,className:"nice-live-streaming__preview-canvas",style:{aspectRatio:`${n.layout.canvas.width}/${n.layout.canvas.height}`,backgroundColor:n.layout.canvas.backgroundColor},children:n.layout.layers.sort((s,r)=>s.zIndex-r.zIndex).map(s=>{var o;const r=n.sources.find(t=>t.id===s.sourceId);return!s.visible||!r?null:e.jsx("div",{className:`nice-live-streaming__canvas-layer ${N===s.id?"nice-live-streaming__canvas-layer--selected":""}`,style:{left:`${s.position.x/n.layout.canvas.width*100}%`,top:`${s.position.y/n.layout.canvas.height*100}%`,width:`${s.size.width/n.layout.canvas.width*100}%`,height:`${s.size.height/n.layout.canvas.height*100}%`,opacity:s.opacity,zIndex:s.zIndex},onClick:()=>L(s.id),children:e.jsxs("div",{className:"nice-live-streaming__layer-content",children:[e.jsx("span",{className:"nice-live-streaming__layer-icon",children:e.jsx(l.NiceIcon,{name:((o=ne.find(t=>t.type===r.type))==null?void 0:o.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__layer-name",children:r.name})]})},s.id)})})]}),e.jsxs("aside",{className:"nice-live-streaming__panel",children:[e.jsx("div",{className:"nice-live-streaming__panel-tabs",children:["sources","audio","destinations","settings"].map(s=>e.jsx("button",{className:`nice-live-streaming__panel-tab ${j===s?"nice-live-streaming__panel-tab--active":""}`,onClick:()=>B(s),children:s.charAt(0).toUpperCase()+s.slice(1)},s))}),e.jsxs("div",{className:"nice-live-streaming__panel-content",children:[j==="sources"&&e.jsxs("div",{className:"nice-live-streaming__sources-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:a("liveStreaming.sources","Sources")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>y(!0),disabled:v,children:"+ Add"})]}),e.jsx("div",{className:"nice-live-streaming__sources-list",children:n.sources.filter(s=>s.type!=="microphone"&&s.type!=="system-audio").map(s=>{var o;const r=n.layout.layers.find(t=>t.sourceId===s.id);return e.jsxs("div",{className:`nice-live-streaming__source-item ${N===(r==null?void 0:r.id)?"nice-live-streaming__source-item--selected":""}`,onClick:()=>r&&L(r.id),children:[e.jsx("span",{className:"nice-live-streaming__source-icon",children:e.jsx(l.NiceIcon,{name:((o=ne.find(t=>t.type===s.type))==null?void 0:o.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__source-name",children:s.name}),e.jsxs("div",{className:"nice-live-streaming__source-controls",children:[e.jsx("button",{className:`nice-live-streaming__visibility-toggle ${r!=null&&r.visible?"":"nice-live-streaming__visibility-toggle--hidden"}`,onClick:t=>{t.stopPropagation(),r&&M(r.id,{visible:!r.visible})},children:e.jsx(l.NiceIcon,{name:r!=null&&r.visible?"eye":"eye-off",size:14})}),e.jsx("button",{onClick:t=>{t.stopPropagation(),r&&ee(r.id)},children:e.jsx(l.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{onClick:t=>{t.stopPropagation(),r&&se(r.id)},children:e.jsx(l.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{onClick:t=>{t.stopPropagation(),H(s.id)},disabled:v,children:e.jsx(l.NiceIcon,{name:"trash",size:14})})]})]},s.id)})}),N&&e.jsxs("div",{className:"nice-live-streaming__layer-properties",children:[e.jsx("h4",{children:a("liveStreaming.properties","Properties")}),(()=>{const s=n.layout.layers.find(r=>r.id===N);return s?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[a("liveStreaming.xPosition","X Position"),e.jsx("input",{type:"number",value:s.position.x,onChange:r=>M(s.id,{position:{...s.position,x:parseInt(r.target.value)||0}})})]}),e.jsxs("label",{children:[a("liveStreaming.yPosition","Y Position"),e.jsx("input",{type:"number",value:s.position.y,onChange:r=>M(s.id,{position:{...s.position,y:parseInt(r.target.value)||0}})})]}),e.jsxs("label",{children:[a("liveStreaming.width","Width"),e.jsx("input",{type:"number",value:s.size.width,onChange:r=>M(s.id,{size:{...s.size,width:parseInt(r.target.value)||100}})})]}),e.jsxs("label",{children:[a("liveStreaming.height","Height"),e.jsx("input",{type:"number",value:s.size.height,onChange:r=>M(s.id,{size:{...s.size,height:parseInt(r.target.value)||100}})})]}),e.jsxs("label",{children:[a("liveStreaming.opacity","Opacity"),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.opacity,onChange:r=>M(s.id,{opacity:parseFloat(r.target.value)})})]})]}):null})()]})]}),j==="audio"&&e.jsxs("div",{className:"nice-live-streaming__audio-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:a("liveStreaming.audioMixer","Audio Mixer")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>{y(!0)},disabled:v,children:"+ Add"})]}),e.jsxs("div",{className:"nice-live-streaming__audio-sources",children:[n.sources.filter(s=>s.type==="microphone"||s.type==="system-audio"||s.type==="video").map(s=>{var r;return e.jsxs("div",{className:"nice-live-streaming__audio-source",children:[e.jsxs("div",{className:"nice-live-streaming__audio-header",children:[e.jsx("span",{className:"nice-live-streaming__audio-icon",children:e.jsx(l.NiceIcon,{name:((r=ne.find(o=>o.type===s.type))==null?void 0:r.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__audio-name",children:s.name}),e.jsx("button",{className:`nice-live-streaming__mute-toggle ${s.muted?"nice-live-streaming__mute-toggle--muted":""}`,onClick:()=>k(s.id,{muted:!s.muted}),children:e.jsx(l.NiceIcon,{name:s.muted?"volume-off":"volume",size:14})})]}),e.jsxs("div",{className:"nice-live-streaming__audio-slider",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:s.volume??1,onChange:o=>k(s.id,{volume:parseFloat(o.target.value)}),disabled:s.muted}),e.jsxs("span",{className:"nice-live-streaming__volume-value",children:[Math.round((s.volume??1)*100),"%"]})]}),e.jsx("div",{className:"nice-live-streaming__audio-meter",children:e.jsx("div",{className:"nice-live-streaming__meter-fill",style:{width:`${(s.volume??1)*70+Math.random()*30}%`}})})]},s.id)}),n.sources.filter(s=>s.type==="microphone"||s.type==="system-audio").length===0&&e.jsx("p",{className:"nice-live-streaming__empty-message",children:a("liveStreaming.noAudioSourcesAdded","No audio sources added")})]})]}),j==="destinations"&&e.jsxs("div",{className:"nice-live-streaming__destinations-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:a("liveStreaming.destinations","Destinations")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>V(!0),disabled:v,children:"+ Add"})]}),e.jsxs("div",{className:"nice-live-streaming__destinations-list",children:[n.destinations.map(s=>{var r;return e.jsxs("div",{className:"nice-live-streaming__destination-item",children:[e.jsxs("div",{className:"nice-live-streaming__destination-header",children:[e.jsx("span",{className:"nice-live-streaming__status-indicator",style:{backgroundColor:te(s.status)}}),e.jsx("span",{className:"nice-live-streaming__destination-icon",children:e.jsx(l.NiceIcon,{name:((r=ae.find(o=>o.platform===s.platform))==null?void 0:r.icon)??"link",size:16})}),e.jsx("span",{className:"nice-live-streaming__destination-name",children:s.name}),e.jsxs("label",{className:"nice-live-streaming__toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:o=>W(s.id,{enabled:o.target.checked}),disabled:v}),e.jsx("span",{className:"nice-live-streaming__toggle-slider"})]})]}),e.jsxs("div",{className:"nice-live-streaming__destination-config",children:[e.jsxs("label",{children:[a("liveStreaming.serverUrl","Server URL"),e.jsx("input",{type:"text",value:s.url,onChange:o=>W(s.id,{url:o.target.value}),placeholder:a("liveStreaming.rtmp","rtmp://..."),disabled:v})]}),e.jsxs("label",{children:[a("liveStreaming.streamKey","Stream Key"),e.jsx("input",{type:"password",value:s.streamKey||"",onChange:o=>W(s.id,{streamKey:o.target.value}),placeholder:a("liveStreaming.enterStreamKey","Enter stream key"),disabled:v})]})]}),e.jsx("button",{className:"nice-live-streaming__remove-button",onClick:()=>O(s.id),disabled:v,children:a("liveStreaming.remove","Remove")})]},s.id)}),n.destinations.length===0&&e.jsx("p",{className:"nice-live-streaming__empty-message",children:a("liveStreaming.noDestinationsConfigured","No destinations configured")})]})]}),j==="settings"&&e.jsxs("div",{className:"nice-live-streaming__settings-panel",children:[e.jsxs("div",{className:"nice-live-streaming__setting-section",children:[e.jsx("h4",{children:a("liveStreaming.video","Video")}),e.jsxs("label",{children:[a("liveStreaming.resolution","Resolution"),e.jsxs("select",{value:`${n.settings.video.resolution.width}x${n.settings.video.resolution.height}`,onChange:s=>{const[r,o]=s.target.value.split("x").map(Number);x({settings:{...n.settings,video:{...n.settings.video,resolution:{width:r,height:o}}},layout:{...n.layout,canvas:{...n.layout.canvas,width:r,height:o}}})},disabled:v,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:[a("liveStreaming.frameRate","Frame Rate"),e.jsxs("select",{value:n.settings.video.frameRate,onChange:s=>x({settings:{...n.settings,video:{...n.settings.video,frameRate:parseInt(s.target.value)}}}),disabled:v,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:n.settings.video.bitrate,onChange:s=>x({settings:{...n.settings,video:{...n.settings.video,bitrate:parseInt(s.target.value)||6e3}}}),min:"1000",max:"50000",disabled:v})]}),e.jsxs("label",{children:["Keyframe Interval (sec)",e.jsx("input",{type:"number",value:n.settings.video.keyframe,onChange:s=>x({settings:{...n.settings,video:{...n.settings.video,keyframe:parseInt(s.target.value)||2}}}),min:"1",max:"10",disabled:v})]})]}),e.jsxs("div",{className:"nice-live-streaming__setting-section",children:[e.jsx("h4",{children:a("liveStreaming.audio","Audio")}),e.jsxs("label",{children:[a("liveStreaming.sampleRate","Sample Rate"),e.jsxs("select",{value:n.settings.audio.sampleRate,onChange:s=>x({settings:{...n.settings,audio:{...n.settings.audio,sampleRate:parseInt(s.target.value)}}}),disabled:v,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:n.settings.audio.bitrate,onChange:s=>x({settings:{...n.settings,audio:{...n.settings.audio,bitrate:parseInt(s.target.value)}}}),disabled:v,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"})]})]})]})]})]})]})]}),v&&e.jsx("footer",{className:"nice-live-streaming__footer",children:e.jsxs("div",{className:"nice-live-streaming__footer-stats",children:[e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:"CPU"}),e.jsxs("span",{className:"nice-live-streaming__value",children:[f.cpuUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:a("liveStreaming.memory","Memory")}),e.jsxs("span",{className:"nice-live-streaming__value",children:[f.memoryUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:a("liveStreaming.dropped","Dropped")}),e.jsx("span",{className:"nice-live-streaming__value",children:f.droppedFrames})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:a("liveStreaming.peakViewers","Peak Viewers")}),e.jsx("span",{className:"nice-live-streaming__value",children:f.peakViewers})]})]})}),U&&e.jsx("div",{className:"nice-live-streaming__modal-overlay",children:e.jsxs("div",{className:"nice-live-streaming__modal",children:[e.jsxs("div",{className:"nice-live-streaming__modal-header",children:[e.jsx("h3",{children:a("liveStreaming.addSource","Add Source")}),e.jsx("button",{"aria-label":a("liveStreaming.close","Close"),className:"nice-live-streaming__close-button",onClick:()=>y(!1),children:e.jsx(l.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-live-streaming__modal-content",children:e.jsx("div",{className:"nice-live-streaming__source-type-grid",children:ne.map(s=>e.jsxs("button",{className:"nice-live-streaming__source-type-button",onClick:()=>Z(s.type),children:[e.jsx("span",{className:"nice-live-streaming__icon",children:e.jsx(l.NiceIcon,{name:s.icon,size:24})}),e.jsx("span",{className:"nice-live-streaming__name",children:s.name})]},s.type))})})]})}),q&&e.jsx("div",{className:"nice-live-streaming__modal-overlay",children:e.jsxs("div",{className:"nice-live-streaming__modal",children:[e.jsxs("div",{className:"nice-live-streaming__modal-header",children:[e.jsx("h3",{children:a("liveStreaming.addDestination","Add Destination")}),e.jsx("button",{"aria-label":a("liveStreaming.close","Close"),className:"nice-live-streaming__close-button",onClick:()=>V(!1),children:e.jsx(l.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-live-streaming__modal-content",children:e.jsx("div",{className:"nice-live-streaming__platform-grid",children:ae.map(s=>e.jsxs("button",{className:"nice-live-streaming__platform-button",onClick:()=>P(s.platform),children:[e.jsx("span",{className:"nice-live-streaming__icon",children:e.jsx(l.NiceIcon,{name:s.icon,size:24})}),e.jsx("span",{className:"nice-live-streaming__name",children:s.name})]},s.platform))})})]})})]})};exports.NiceLiveStreaming=_e;exports.NiceScreenRecorder=pe;exports.NiceVideoEditor=ve;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),oe=require("@nice2dev/ui"),o=require("@nice2dev/ui-core"),u=require("react"),le={id:o.createId(),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"}}},de=[{type:"blur",name:"Blur",icon:"droplet"},{type:"brightness",name:"Brightness",icon:"sun"},{type:"contrast",name:"Contrast",icon:"moon"},{type:"saturation",name:"Saturation",icon:"palette"},{type:"grayscale",name:"Grayscale",icon:"square"},{type:"sepia",name:"Sepia",icon:"image"},{type:"chromaKey",name:"Chroma Key",icon:"layers"},{type:"crop",name:"Crop",icon:"crop"},{type:"zoom",name:"Zoom",icon:"search"}],ue=[{type:"fade",name:"Fade"},{type:"dissolve",name:"Dissolve"},{type:"wipe",name:"Wipe"},{type:"slide",name:"Slide"},{type:"zoom",name:"Zoom"},{type:"push",name:"Push"}],me=[{target:".nice-video-editor",titleKey:"tutorial.videoEditorPro.intro.title",title:"Video editor",contentKey:"tutorial.videoEditorPro.intro.content",content:"Add media to the timeline, arrange and trim clips, apply effects and transitions, then configure and run the export.",placement:"auto"}],ve=({project:z,onProjectChange:w,onExport:$,onAssetUpload:A,className:F="",tutorial:R})=>{const{t:m}=o.useNiceTranslation(),[s,a]=u.useState(z||le),[E,j]=u.useState("timeline"),[K,h]=u.useState(null),[b,f]=u.useState(null),[T,N]=u.useState(0),[L,O]=u.useState(!1),[y,q]=u.useState(1),[V,C]=u.useState(!0),[I,D]=u.useState(null),Q=u.useRef(null),X=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{z&&a(z)},[z]),u.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]);const g=u.useCallback(n=>{const c={...s,...n};a(c),w==null||w(c)},[s,w]),_=async n=>{const c=[];for(const t of Array.from(n)){const d=t.type.startsWith("video/")?"video":t.type.startsWith("audio/")?"audio":"image";let v;A?v=await A(t):v={id:o.createId(),type:d,name:t.name,url:URL.createObjectURL(t),size:t.size},c.push(v)}g({assets:[...s.assets,...c]})},P=n=>{const c={id:o.createId(),type:n,name:`${n.charAt(0).toUpperCase()+n.slice(1)} ${s.tracks.filter(t=>t.type===n).length+1}`,items:[],muted:!1,locked:!1,visible:!0};g({tracks:[...s.tracks,c]})},W=n=>{g({tracks:s.tracks.filter(c=>c.id!==n)}),K===n&&h(null)},U=n=>{g({tracks:s.tracks.map(c=>c.id===n?{...c,muted:!c.muted}:c)})},Z=n=>{g({tracks:s.tracks.map(c=>c.id===n?{...c,locked:!c.locked}:c)})},k=(n,c)=>{const t=s.tracks.find(x=>x.id===n);if(!t||t.locked)return;const d=t.items[t.items.length-1],v=d?d.startTime+d.duration:0,p={id:o.createId(),assetId:c.id,type:c.type,startTime:v,duration:c.duration||5,offset:0,properties:{x:0,y:0,opacity:1,scale:1,volume:1},effects:[],transitions:[]};g({tracks:s.tracks.map(x=>x.id===n?{...x,items:[...x.items,p]}:x)})},H=(n,c,t)=>{const d={id:o.createId(),type:t,name:t.charAt(0).toUpperCase()+t.slice(1),parameters:ee(t)};g({tracks:s.tracks.map(v=>v.id===n?{...v,items:v.items.map(p=>p.id===c?{...p,effects:[...p.effects,d]}:p)}:v)})},M=(n,c,t,d)=>{const v={id:o.createId(),type:t,duration:.5,position:d};g({tracks:s.tracks.map(p=>p.id===n?{...p,items:p.items.map(x=>x.id===c?{...x,transitions:[...x.transitions,v]}:x)}:p)})},ee=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:"var(--nice-success, #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{}}},ie=()=>{L?(S.current&&clearInterval(S.current),O(!1)):(S.current=setInterval(()=>{N(n=>{const c=Math.max(...s.tracks.flatMap(t=>t.items.map(d=>d.startTime+d.duration)),0);return n>=c?(clearInterval(S.current),O(!1),0):n+1/s.frameRate})},1e3/s.frameRate),O(!0))},G=n=>{N(Math.max(0,n))},Y=async()=>{if($){D(0);try{const n=setInterval(()=>{D(c=>c!==null&&c<90?c+Math.random()*10:c)},500);await $(s,s.settings.video.codec),clearInterval(n),D(100),setTimeout(()=>D(null),2e3)}catch(n){D(null),console.error("Export failed:",n)}}},J=n=>{const c=Math.floor(n/60),t=Math.floor(n%60),d=Math.floor(n%1*s.frameRate);return`${c.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}:${d.toString().padStart(2,"0")}`},B=()=>{for(const n of s.tracks){const c=n.items.find(t=>t.id===b);if(c)return{track:n,item:c}}return null},se=e.jsxs("header",{className:"nice-video-studio__header",children:[e.jsxs("div",{className:"nice-video-studio__header-project-info",children:[e.jsx("input",{type:"text",value:s.name,onChange:n=>g({name:n.target.value}),className:"nice-video-studio__project-name-input"}),e.jsxs("span",{className:"nice-video-studio__project-settings",children:[s.resolution.width,"x",s.resolution.height," • ",s.frameRate,"fps"]})]}),e.jsx("div",{className:"nice-video-studio__header-tabs",children:["timeline","effects","transitions","export"].map(n=>e.jsx("button",{className:`nice-video-studio__tab-button ${E===n?"nice-video-studio__tab-button--active":""}`,onClick:()=>j(n),children:n.charAt(0).toUpperCase()+n.slice(1)},n))}),e.jsx("div",{className:"nice-video-studio__header-actions",children:e.jsx("button",{className:"nice-video-studio__action-button nice-video-studio__action-button--primary",onClick:Y,disabled:I!==null,children:I!==null?m("videoEditor.exporting","Exporting {exportProgress}%").replace("{exportProgress}",String(Math.round(I))):m("videoEditor.export","Export")})})]}),te=b&&E!=="export"?(()=>{const n=B();if(!n)return null;const{track:c,item:t}=n;return e.jsxs("div",{className:"nice-video-studio__item-inspector",children:[e.jsx("h4",{children:m("videoEditor.itemProperties","Item Properties")}),e.jsxs("div",{className:"nice-video-studio__inspector-section",children:[e.jsxs("label",{children:[m("videoEditor.startTime","Start Time"),e.jsx("input",{type:"number",step:"0.1",value:t.startTime,onChange:d=>{const v=parseFloat(d.target.value);g({tracks:s.tracks.map(p=>p.id===c.id?{...p,items:p.items.map(x=>x.id===t.id?{...x,startTime:v}:x)}:p)})}})]}),e.jsxs("label",{children:[m("videoEditor.duration","Duration"),e.jsx("input",{type:"number",step:"0.1",value:t.duration,onChange:d=>{const v=parseFloat(d.target.value);g({tracks:s.tracks.map(p=>p.id===c.id?{...p,items:p.items.map(x=>x.id===t.id?{...x,duration:v}:x)}:p)})}})]}),e.jsxs("label",{children:[m("videoEditor.opacity","Opacity"),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:t.properties.opacity??1,onChange:d=>{const v=parseFloat(d.target.value);g({tracks:s.tracks.map(p=>p.id===c.id?{...p,items:p.items.map(x=>x.id===t.id?{...x,properties:{...x.properties,opacity:v}}:x)}:p)})}})]})]}),e.jsx("h4",{children:m("videoEditor.effects","Effects ({effects})").replace("{effects}",String(t.effects.length))}),e.jsx("div",{className:"nice-video-studio__effects-list",children:t.effects.map(d=>e.jsx("div",{className:"nice-video-studio__effect-badge",children:d.name},d.id))})]})})():null,i=V?e.jsxs("aside",{className:"nice-video-studio__asset-library",children:[e.jsxs("div",{className:"nice-video-studio__asset-library-header",children:[e.jsx("h3",{children:m("videoEditor.assets","Assets")}),e.jsx("button",{"aria-label":m("videoEditor.close","Close"),className:"nice-video-studio__close-button",onClick:()=>C(!1),children:e.jsx(o.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-video-studio__asset-library-upload",children:e.jsxs("label",{className:"nice-video-studio__upload-zone",children:[e.jsx("input",{type:"file",multiple:!0,accept:"video/*,audio/*,image/*",onChange:n=>n.target.files&&_(n.target.files),hidden:!0}),e.jsx("span",{className:"nice-video-studio__upload-icon",children:"+"}),e.jsx("span",{children:m("videoEditor.dropFilesOrClickTo","Drop files or click to upload")})]})}),e.jsx("div",{className:"nice-video-studio__asset-library-list",children:s.assets.map(n=>e.jsxs("div",{className:"nice-video-studio__asset-item",draggable:!0,onDragStart:c=>c.dataTransfer.setData("assetId",n.id),children:[e.jsx("div",{className:"nice-video-studio__asset-thumbnail",children:n.thumbnail?e.jsx("img",{src:n.thumbnail,alt:n.name}):e.jsx("span",{className:"nice-video-studio__asset-type-icon",children:e.jsx(o.NiceIcon,{name:n.type==="video"?"video":n.type==="audio"?"music":"image",size:24})})}),e.jsxs("div",{className:"nice-video-studio__asset-info",children:[e.jsx("span",{className:"nice-video-studio__asset-name",children:n.name}),e.jsxs("span",{className:"nice-video-studio__asset-meta",children:[(n.size/1024/1024).toFixed(1),"MB"]})]})]},n.id))})]}):void 0,r=e.jsx("div",{className:"nice-video-studio__preview-area",children:e.jsxs("div",{className:"nice-video-studio__preview-container",children:[e.jsxs("div",{className:"nice-video-studio__preview-canvas",style:{aspectRatio:`${s.resolution.width}/${s.resolution.height}`},children:[e.jsx("video",{ref:X,className:"nice-video-studio__preview-video"}),e.jsx("div",{className:"nice-video-studio__preview-overlay",children:!V&&e.jsx("button",{className:"nice-video-studio__toggle-library-button",onClick:()=>C(!0),"aria-label":m("videoEditor.showAssetLibrary","Show asset library"),children:e.jsx(o.NiceIcon,{name:"folder",size:16})})})]}),e.jsxs("div",{className:"nice-video-studio__playback-controls",children:[e.jsx("button",{onClick:()=>G(0),"aria-label":m("videoEditor.goToStart","Go to start"),children:e.jsx(o.NiceIcon,{name:"skip-back",size:16})}),e.jsx("button",{onClick:()=>G(T-1/s.frameRate),"aria-label":m("videoEditor.previousFrame","Previous frame"),children:e.jsx(o.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("button",{onClick:ie,className:"nice-video-studio__play-button","aria-label":L?m("videoEditor.pause","Pause"):m("videoEditor.play","Play"),children:e.jsx(o.NiceIcon,{name:L?"pause":"play",size:18})}),e.jsx("button",{onClick:()=>G(T+1/s.frameRate),"aria-label":m("videoEditor.nextFrame","Next frame"),children:e.jsx(o.NiceIcon,{name:"chevron-right",size:16})}),e.jsx("span",{className:"nice-video-studio__time-display",children:J(T)})]})]})}),l=e.jsxs("div",{className:"nice-video-studio__panel",children:[E==="timeline"&&e.jsxs("div",{className:"nice-video-studio__timeline-panel",children:[e.jsxs("div",{className:"nice-video-studio__timeline-toolbar",children:[e.jsxs("div",{className:"nice-video-studio__track-buttons",children:[e.jsx("button",{onClick:()=>P("video"),children:m("videoEditor.videoTrack","+ Video Track")}),e.jsx("button",{onClick:()=>P("audio"),children:m("videoEditor.audioTrack","+ Audio Track")}),e.jsx("button",{onClick:()=>P("text"),children:m("videoEditor.textTrack","+ Text Track")})]}),e.jsxs("div",{className:"nice-video-studio__zoom-controls",children:[e.jsx("button",{onClick:()=>q(Math.max(.25,y-.25)),children:"-"}),e.jsxs("span",{children:[Math.round(y*100),"%"]}),e.jsx("button",{onClick:()=>q(Math.min(4,y+.25)),children:"+"})]})]}),e.jsxs("div",{className:"nice-video-studio__timeline-container",ref:Q,children:[e.jsx("div",{className:"nice-video-studio__timeline-ruler",children:Array.from({length:Math.ceil(30/y)}).map((n,c)=>e.jsx("div",{className:"nice-video-studio__ruler-mark",style:{left:`${c*50*y}px`},children:J(c)},c))}),e.jsx("div",{className:"nice-video-studio__timeline-playhead",style:{left:`${T*50*y}px`}}),e.jsx("div",{className:"nice-video-studio__timeline-tracks",children:s.tracks.map(n=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:o.clickOnActivationKey,className:`nice-video-studio__timeline-track ${K===n.id?"nice-video-studio__timeline-track--selected":""} ${n.locked?"nice-video-studio__timeline-track--locked":""}`,onClick:()=>h(n.id),onDrop:c=>{c.preventDefault();const t=c.dataTransfer.getData("assetId"),d=s.assets.find(v=>v.id===t);d&&k(n.id,d)},onDragOver:c=>c.preventDefault(),children:[e.jsxs("div",{className:"nice-video-studio__track-header",children:[e.jsx("span",{className:"nice-video-studio__track-name",children:n.name}),e.jsxs("div",{className:"nice-video-studio__track-controls",children:[e.jsx("button",{className:`nice-video-studio__track-toggle ${n.muted?"nice-video-studio__track-toggle--active":""}`,onClick:c=>{c.stopPropagation(),U(n.id)},children:e.jsx(o.NiceIcon,{name:n.muted?"volume-off":"volume",size:14})}),e.jsx("button",{className:`nice-video-studio__track-toggle ${n.locked?"nice-video-studio__track-toggle--active":""}`,onClick:c=>{c.stopPropagation(),Z(n.id)},children:e.jsx(o.NiceIcon,{name:n.locked?"lock":"unlock",size:14})}),e.jsx("button",{onClick:c=>{c.stopPropagation(),W(n.id)},"aria-label":m("videoEditor.removeTrack","Remove track"),children:e.jsx(o.NiceIcon,{name:"trash",size:14})})]})]}),e.jsx("div",{className:"nice-video-studio__track-items",children:n.items.map(c=>{const t=s.assets.find(d=>d.id===c.assetId);return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:o.clickOnActivationKey,className:`nice-video-studio__track-item nice-video-studio__track-item--${c.type} ${b===c.id?"nice-video-studio__track-item--selected":""}`,style:{left:`${c.startTime*50*y}px`,width:`${c.duration*50*y}px`},onClick:d=>{d.stopPropagation(),f(c.id)},children:[e.jsx("span",{className:"nice-video-studio__item-name",children:(t==null?void 0:t.name)||m("videoEditor.untitled","Untitled")}),c.transitions.length>0&&e.jsx("span",{className:"nice-video-studio__item-transitions",children:e.jsx(o.NiceIcon,{name:"wand",size:12})}),c.effects.length>0&&e.jsx("span",{className:"nice-video-studio__item-effects",children:e.jsx(o.NiceIcon,{name:"palette",size:12})})]},c.id)})})]},n.id))})]})]}),E==="effects"&&e.jsxs("div",{className:"nice-video-studio__effects-panel",children:[e.jsx("h3",{children:m("videoEditor.videoEffects","Video Effects")}),e.jsx("p",{className:"nice-video-studio__panel-hint",children:m("videoEditor.selectAClipToApply","Select a clip to apply effects")}),e.jsx("div",{className:"nice-video-studio__effects-grid",children:de.map(n=>e.jsxs("button",{className:"nice-video-studio__effect-preset",disabled:!b,onClick:()=>{const c=B();c&&H(c.track.id,c.item.id,n.type)},children:[e.jsx("span",{className:"nice-video-studio__effect-icon",children:e.jsx(o.NiceIcon,{name:n.icon,size:16})}),e.jsx("span",{className:"nice-video-studio__effect-name",children:n.name})]},n.type))})]}),E==="transitions"&&e.jsxs("div",{className:"nice-video-studio__transitions-panel",children:[e.jsx("h3",{children:m("videoEditor.transitions","Transitions")}),e.jsx("p",{className:"nice-video-studio__panel-hint",children:m("videoEditor.selectAClipAndAdd","Select a clip and add transitions between clips")}),e.jsx("div",{className:"nice-video-studio__transitions-grid",children:ue.map(n=>e.jsxs("div",{className:"nice-video-studio__transition-preset",children:[e.jsx("span",{className:"nice-video-studio__transition-name",children:n.name}),e.jsxs("div",{className:"nice-video-studio__transition-buttons",children:[e.jsx("button",{disabled:!b,onClick:()=>{const c=B();c&&M(c.track.id,c.item.id,n.type,"start")},children:m("videoEditor.in","In")}),e.jsx("button",{disabled:!b,onClick:()=>{const c=B();c&&M(c.track.id,c.item.id,n.type,"end")},children:m("videoEditor.out","Out")})]})]},n.type))})]}),E==="export"&&e.jsxs("div",{className:"nice-video-studio__export-panel",children:[e.jsx("h3",{children:m("videoEditor.exportSettings","Export Settings")}),e.jsxs("div",{className:"nice-video-studio__export-settings",children:[e.jsxs("div",{className:"nice-video-studio__setting-group",children:[e.jsx("label",{children:m("videoEditor.resolution","Resolution")}),e.jsxs("select",{value:`${s.resolution.width}x${s.resolution.height}`,onChange:n=>{const[c,t]=n.target.value.split("x").map(Number);g({resolution:{width:c,height:t}})},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:"nice-video-studio__setting-group",children:[e.jsx("label",{children:m("videoEditor.frameRate","Frame Rate")}),e.jsxs("select",{value:s.frameRate,onChange:n=>g({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:"nice-video-studio__setting-group",children:[e.jsx("label",{children:m("videoEditor.videoCodec","Video Codec")}),e.jsxs("select",{value:s.settings.video.codec,onChange:n=>g({settings:{...s.settings,video:{...s.settings.video,codec:n.target.value}}}),children:[e.jsx("option",{value:"h264",children:m("videoEditor.h264BestCompatibility","H.264 (Best Compatibility)")}),e.jsx("option",{value:"h265",children:m("videoEditor.h265HevcSmallerSize","H.265/HEVC (Smaller Size)")}),e.jsx("option",{value:"vp9",children:m("videoEditor.vp9WebOptimized","VP9 (Web Optimized)")}),e.jsx("option",{value:"av1",children:m("videoEditor.av1FutureStandard","AV1 (Future Standard)")})]})]}),e.jsxs("div",{className:"nice-video-studio__setting-group",children:[e.jsx("label",{children:m("videoEditor.videoBitrateMbps","Video Bitrate (Mbps)")}),e.jsx("input",{type:"number",value:s.settings.video.bitrate/1e3,onChange:n=>g({settings:{...s.settings,video:{...s.settings.video,bitrate:parseFloat(n.target.value)*1e3}}}),min:"1",max:"100"})]})]}),e.jsx("button",{className:"nice-video-studio__export-button",onClick:Y,disabled:I!==null,children:I!==null?m("videoEditor.exporting2","Exporting... {exportProgress}%").replace("{exportProgress}",String(Math.round(I))):m("videoEditor.exportVideo","Export Video")}),I!==null&&e.jsx("div",{className:"nice-video-studio__export-progress",children:e.jsx("div",{className:"nice-video-studio__export-progress-bar",style:{width:`${I}%`}})})]})]});return e.jsxs(oe.NiceAppShell,{flush:!0,className:`nice-video-editor nice-video-studio ${F}`,height:"100%",style:{position:"relative",minHeight:600},toolbar:se,sidebar:i,rightSidebar:te??void 0,bottomPanel:l,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(o.NiceTutorialButton,{steps:o.resolveTutorial(R,me)})}),r]})},he={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"}},pe=({options:z,onRecordingStart:w,onRecordingStop:$,onRecordingPause:A,onRecordingResume:F,onError:R,className:m=""})=>{var n,c;const{t:s}=o.useNiceTranslation(),[a,E]=u.useState({...he,...z}),[j,K]=u.useState(null),[h,b]=u.useState("idle"),[f,T]=u.useState([]),[N,L]=u.useState(null),[O,y]=u.useState(null),[q,V]=u.useState(!1),[C,I]=u.useState(!1),[D,Q]=u.useState("pen"),[X,S]=u.useState("var(--nice-danger, #ff0000)"),g=u.useRef(null),_=u.useRef([]),P=u.useRef(null),W=u.useRef(null),U=u.useRef(null),Z=u.useRef(0);u.useEffect(()=>()=>{N&&N.getTracks().forEach(t=>t.stop()),U.current&&clearInterval(U.current)},[N]);const k=t=>{E(d=>({...d,...t,video:{...d.video,...t.video},audio:{...d.audio,...t.audio},output:{...d.output,...t.output}}))},H=async()=>{try{b("preparing");const t={video:{cursor:a.video.showCursor?"always":"never",frameRate:a.video.frameRate},audio:a.audio.source==="system"||a.audio.source==="both"},d=await navigator.mediaDevices.getDisplayMedia(t);if(a.audio.enabled&&(a.audio.source==="microphone"||a.audio.source==="both"))try{(await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:a.audio.echoCancellation,noiseSuppression:a.audio.noiseSuppression}})).getAudioTracks().forEach(p=>d.addTrack(p))}catch(v){console.warn("Could not access microphone:",v)}L(d),P.current&&(P.current.srcObject=d,P.current.play()),b("idle")}catch(t){b("error"),R==null||R(t instanceof Error?t:new Error("Failed to start preview"))}},M=async()=>{N||await H();for(let t=3;t>0;t--)y(t),await new Promise(d=>setTimeout(d,1e3));y(null);try{const t=N||await ee();if(!t)throw new Error("No stream available");const d=se(a.output.format),v=new MediaRecorder(t,{mimeType:d,videoBitsPerSecond:te(a.output.quality)});_.current=[],v.ondataavailable=x=>{x.data.size>0&&_.current.push(x.data)},v.onstop=()=>{const x=new Blob(_.current,{type:d});j&&($==null||$({...j,status:"stopped"},x))},g.current=v,v.start(1e3),Z.current=Date.now();const p={id:o.createId(),status:"recording",startTime:new Date,duration:0,size:0,options:a,chunks:[]};K(p),b("recording"),w==null||w(p),U.current=setInterval(()=>{K(x=>x?{...x,duration:(Date.now()-Z.current)/1e3,size:_.current.reduce((re,ce)=>re+ce.size,0)}:null)},100)}catch(t){b("error"),R==null||R(t instanceof Error?t:new Error("Failed to start recording"))}},ee=async()=>(await H(),N),ie=()=>{g.current&&h==="recording"&&(g.current.pause(),b("paused"),A==null||A())},G=()=>{g.current&&h==="paused"&&(g.current.resume(),b("recording"),F==null||F())},Y=()=>{U.current&&clearInterval(U.current),g.current&&(h==="recording"||h==="paused")&&(g.current.stop(),b("stopped")),N&&(N.getTracks().forEach(t=>t.stop()),L(null))},J=u.useCallback(t=>{if(h!=="recording")return;const d={id:o.createId(),time:(j==null?void 0:j.duration)||0,label:t||s("screenRecorder.marker","Marker {markers}").replace("{markers}",String(f.length+1)),color:i()};T(v=>[...v,d])},[h,j==null?void 0:j.duration,f.length,s]),B=t=>{T(d=>d.filter(v=>v.id!==t))},se=t=>{switch(t){case"mp4":return"video/mp4";case"mkv":return"video/x-matroska";default:return"video/webm;codecs=vp9"}},te=t=>{switch(t){case"low":return 25e5;case"medium":return 5e6;case"lossless":return 2e7;default:return 8e6}},i=()=>{const t=["var(--nice-danger, #ff4444)","#44ff44","#4444ff","#ffff44","#ff44ff","#44ffff"];return t[Math.floor(Math.random()*t.length)]},r=t=>{const d=Math.floor(t/3600),v=Math.floor(t%3600/60),p=Math.floor(t%60),x=Math.floor(t%1*100);return d>0?`${d}:${v.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}`:`${v.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}.${x.toString().padStart(2,"0")}`},l=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`;return e.jsxs("div",{className:`nice-screen-recorder ${m}`,children:[e.jsxs("div",{className:"nice-screen-recorder__preview",children:[O!==null&&e.jsx("div",{className:"nice-screen-recorder__countdown-overlay",children:e.jsx("span",{className:"nice-screen-recorder__countdown-number",children:O})}),e.jsx("video",{ref:P,className:"nice-screen-recorder__preview-video",muted:!0,playsInline:!0}),C&&e.jsx("canvas",{ref:W,className:"nice-screen-recorder__annotation-canvas"}),!N&&h==="idle"&&e.jsx("div",{className:"nice-screen-recorder__preview-placeholder",children:e.jsxs("button",{className:"nice-screen-recorder__start-preview-button",onClick:H,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"monitor",size:18})}),e.jsx("span",{children:s("screenRecorder.selectScreenToRecord","Select Screen to Record")})]})}),h==="recording"&&e.jsxs("div",{className:"nice-screen-recorder__recording-indicator",children:[e.jsx("span",{className:"nice-screen-recorder__recording-dot"}),e.jsx("span",{children:s("screenRecorder.rec","REC")})]})]}),e.jsxs("div",{className:"nice-screen-recorder__controls",children:[e.jsxs("div",{className:"nice-screen-recorder__controls-main",children:[h==="idle"&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--record",onClick:M,disabled:!!O,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"circle",size:18})}),e.jsx("span",{children:s("screenRecorder.startRecording","Start Recording")})]}),h==="recording"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--pause",onClick:ie,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"pause",size:18})}),e.jsx("span",{children:s("screenRecorder.pause","Pause")})]}),e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--stop",onClick:Y,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"stop",size:18})}),e.jsx("span",{children:s("screenRecorder.stop","Stop")})]})]}),h==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--resume",onClick:G,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"play",size:18})}),e.jsx("span",{children:s("screenRecorder.resume","Resume")})]}),e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--stop",onClick:Y,children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"stop",size:18})}),e.jsx("span",{children:s("screenRecorder.stop","Stop")})]})]}),h==="stopped"&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--new",onClick:()=>{b("idle"),K(null),T([])},children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"refresh",size:18})}),e.jsx("span",{children:s("screenRecorder.newRecording","New Recording")})]})]}),e.jsxs("div",{className:"nice-screen-recorder__controls-secondary",children:[(h==="recording"||h==="paused")&&e.jsxs("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--marker",onClick:()=>J(),children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"tag",size:18})}),e.jsx("span",{children:s("screenRecorder.addMarker","Add Marker")})]}),e.jsxs("button",{className:`nice-screen-recorder__control-button ${C?"nice-screen-recorder__control-button--active":""}`,onClick:()=>I(!C),disabled:h!=="recording",children:[e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"pen",size:18})}),e.jsx("span",{children:s("screenRecorder.annotate","Annotate")})]}),e.jsx("button",{className:"nice-screen-recorder__control-button nice-screen-recorder__control-button--settings",onClick:()=>V(!q),disabled:h==="recording","aria-label":s("screenRecorder.settings","Settings"),children:e.jsx("span",{className:"nice-screen-recorder__icon",children:e.jsx(o.NiceIcon,{name:"settings",size:18})})})]})]}),e.jsxs("div",{className:"nice-screen-recorder__status",children:[e.jsxs("div",{className:"nice-screen-recorder__status-info",children:[e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:s("screenRecorder.duration","Duration:")})," ",r((j==null?void 0:j.duration)||0)]}),e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:s("screenRecorder.size","Size:")})," ",l((j==null?void 0:j.size)||0)]}),e.jsxs("span",{className:"nice-screen-recorder__status-item",children:[e.jsx("strong",{children:s("screenRecorder.markers2","Markers:")})," ",f.length]})]}),e.jsxs("div",{className:"nice-screen-recorder__status-quality",children:[a.video.resolution&&e.jsxs("span",{children:[a.video.resolution.width,"x",a.video.resolution.height]}),e.jsxs("span",{children:[a.video.frameRate,"fps"]}),e.jsx("span",{className:`nice-screen-recorder__audio-status nice-screen-recorder__audio-status--${a.audio.enabled?"on":"off"}`,children:e.jsx(o.NiceIcon,{name:a.audio.enabled?"volume":"volume-off",size:14})})]})]}),C&&h==="recording"&&e.jsxs("div",{className:"nice-screen-recorder__annotation-tools",children:[e.jsx("div",{className:"nice-screen-recorder__tool-group",children:["pen","arrow","rectangle","text"].map(t=>e.jsx("button",{className:`nice-screen-recorder__tool-button ${D===t?"nice-screen-recorder__tool-button--active":""}`,onClick:()=>Q(t),"aria-label":t,children:e.jsx(o.NiceIcon,{name:t==="pen"?"pen":t==="arrow"?"arrow-right":t==="rectangle"?"square":"type",size:16})},t))}),e.jsx("div",{className:"nice-screen-recorder__color-group",children:["var(--nice-danger, #ff0000)","var(--nice-success, #00ff00)","var(--nice-primary, #0000ff)","var(--nice-warning, #ffff00)","var(--nice-bg, #fff)","var(--nice-text, #000000)"].map(t=>e.jsx("button",{className:`nice-screen-recorder__color-button ${X===t?"nice-screen-recorder__color-button--active":""}`,style:{backgroundColor:t},onClick:()=>S(t)},t))})]}),f.length>0&&e.jsxs("div",{className:"nice-screen-recorder__markers",children:[e.jsx("h4",{children:s("screenRecorder.markers","Markers")}),e.jsx("div",{className:"nice-screen-recorder__markers-list",children:f.map(t=>e.jsxs("div",{className:"nice-screen-recorder__marker-item",style:{borderLeftColor:t.color},children:[e.jsx("span",{className:"nice-screen-recorder__marker-time",children:r(t.time)}),e.jsx("input",{type:"text",value:t.label,onChange:d=>{T(v=>v.map(p=>p.id===t.id?{...p,label:d.target.value}:p))},className:"nice-screen-recorder__marker-label"}),e.jsx("button",{"aria-label":s("screenRecorder.close","Close"),className:"nice-screen-recorder__marker-remove",onClick:()=>B(t.id),children:e.jsx(o.NiceIcon,{name:"close",size:16})})]},t.id))})]}),q&&e.jsxs("div",{className:"nice-screen-recorder__settings",children:[e.jsxs("div",{className:"nice-screen-recorder__settings-header",children:[e.jsx("h3",{children:s("screenRecorder.recordingSettings","Recording Settings")}),e.jsx("button",{"aria-label":s("screenRecorder.close","Close"),className:"nice-screen-recorder__close-button",onClick:()=>V(!1),children:e.jsx(o.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:s("screenRecorder.video","Video")}),e.jsxs("label",{children:[s("screenRecorder.source","Source"),e.jsxs("select",{value:a.video.source,onChange:t=>k({video:{...a.video,source:t.target.value}}),children:[e.jsx("option",{value:"screen",children:s("screenRecorder.entireScreen","Entire Screen")}),e.jsx("option",{value:"window",children:s("screenRecorder.applicationWindow","Application Window")}),e.jsx("option",{value:"tab",children:s("screenRecorder.browserTab","Browser Tab")}),e.jsx("option",{value:"camera",children:s("screenRecorder.camera","Camera")})]})]}),e.jsxs("label",{children:[s("screenRecorder.resolution","Resolution"),e.jsxs("select",{value:`${(n=a.video.resolution)==null?void 0:n.width}x${(c=a.video.resolution)==null?void 0:c.height}`,onChange:t=>{const[d,v]=t.target.value.split("x").map(Number);k({video:{...a.video,resolution:{width:d,height:v}}})},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:[s("screenRecorder.frameRate","Frame Rate"),e.jsxs("select",{value:a.video.frameRate,onChange:t=>k({video:{...a.video,frameRate:parseInt(t.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:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a.video.showCursor,onChange:t=>k({video:{...a.video,showCursor:t.target.checked}})}),s("screenRecorder.showCursor","Show Cursor")]})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:s("screenRecorder.audio","Audio")}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a.audio.enabled,onChange:t=>k({audio:{...a.audio,enabled:t.target.checked}})}),s("screenRecorder.enableAudio","Enable Audio")]}),a.audio.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[s("screenRecorder.source","Source"),e.jsxs("select",{value:a.audio.source,onChange:t=>k({audio:{...a.audio,source:t.target.value}}),children:[e.jsx("option",{value:"system",children:s("screenRecorder.systemAudio","System Audio")}),e.jsx("option",{value:"microphone",children:s("screenRecorder.microphone","Microphone")}),e.jsx("option",{value:"both",children:s("screenRecorder.both","Both")})]})]}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a.audio.echoCancellation,onChange:t=>k({audio:{...a.audio,echoCancellation:t.target.checked}})}),s("screenRecorder.echoCancellation","Echo Cancellation")]}),e.jsxs("label",{className:"nice-screen-recorder__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a.audio.noiseSuppression,onChange:t=>k({audio:{...a.audio,noiseSuppression:t.target.checked}})}),s("screenRecorder.noiseSuppression","Noise Suppression")]})]})]}),e.jsxs("div",{className:"nice-screen-recorder__settings-section",children:[e.jsx("h4",{children:s("screenRecorder.output","Output")}),e.jsxs("label",{children:[s("screenRecorder.format","Format"),e.jsxs("select",{value:a.output.format,onChange:t=>k({output:{...a.output,format:t.target.value}}),children:[e.jsx("option",{value:"webm",children:s("screenRecorder.webmBestWeb","WebM (Best Web)")}),e.jsx("option",{value:"mp4",children:s("screenRecorder.mp4MostCompatible","MP4 (Most Compatible)")}),e.jsx("option",{value:"mkv",children:s("screenRecorder.mkvLossless","MKV (Lossless)")})]})]}),e.jsxs("label",{children:[s("screenRecorder.quality","Quality"),e.jsxs("select",{value:a.output.quality,onChange:t=>k({output:{...a.output,quality:t.target.value}}),children:[e.jsx("option",{value:"low",children:s("screenRecorder.lowSmallerFile","Low (Smaller file)")}),e.jsx("option",{value:"medium",children:s("screenRecorder.medium","Medium")}),e.jsx("option",{value:"high",children:s("screenRecorder.highRecommended","High (Recommended)")}),e.jsx("option",{value:"lossless",children:s("screenRecorder.losslessLargestFile","Lossless (Largest file)")})]})]})]})]})]})},xe={id:o.createId(),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:"video",defaultUrl:"rtmp://a.rtmp.youtube.com/live2"},{platform:"twitch",name:"Twitch",icon:"gamepad",defaultUrl:"rtmp://live.twitch.tv/app"},{platform:"facebook",name:"Facebook",icon:"users",defaultUrl:"rtmps://live-api-s.facebook.com:443/rtmp"},{platform:"custom-rtmp",name:"Custom RTMP",icon:"link",defaultUrl:""},{platform:"custom-srt",name:"Custom SRT",icon:"lock",defaultUrl:""}],ne=[{type:"camera",name:"Camera",icon:"camera"},{type:"screen",name:"Screen Capture",icon:"monitor"},{type:"window",name:"Window Capture",icon:"window"},{type:"browser",name:"Browser Source",icon:"globe"},{type:"image",name:"Image",icon:"image"},{type:"video",name:"Video",icon:"video"},{type:"microphone",name:"Microphone",icon:"mic"},{type:"system-audio",name:"System Audio",icon:"volume"}],_e=({config:z,onConfigChange:w,onStreamStart:$,onStreamStop:A,onStatsUpdate:F,onError:R,className:m=""})=>{const{t:s}=o.useNiceTranslation(),[a,E]=u.useState(z||xe),[j,K]=u.useState("sources"),[h,b]=u.useState(!1),[f,T]=u.useState({duration:0,viewers:0,peakViewers:0,bitrate:0,fps:0,droppedFrames:0,cpuUsage:0,memoryUsage:0}),[N,L]=u.useState(null),[O,y]=u.useState(!1),[q,V]=u.useState(!1),[C,I]=u.useState([a.layout]),[D,Q]=u.useState(0),X=u.useRef(null),S=u.useRef(null),g=u.useRef(0);u.useEffect(()=>{z&&E(z)},[z]),u.useEffect(()=>()=>{S.current&&clearInterval(S.current)},[]);const _=u.useCallback(i=>{const r={...a,...i};E(r),w==null||w(r)},[a,w]),P=i=>{const r=ae.find(n=>n.platform===i),l={id:o.createId(),name:(r==null?void 0:r.name)||"Custom",platform:i,url:(r==null?void 0:r.defaultUrl)||"",streamKey:"",enabled:!0,status:"idle"};_({destinations:[...a.destinations,l]}),V(!1)},W=(i,r)=>{_({destinations:a.destinations.map(l=>l.id===i?{...l,...r}:l)})},U=i=>{_({destinations:a.destinations.filter(r=>r.id!==i)})},Z=async i=>{const r=ne.find(c=>c.type===i),l={id:o.createId(),type:i,name:`${(r==null?void 0:r.name)||i} ${a.sources.filter(c=>c.type===i).length+1}`,settings:{},volume:1,muted:!1};try{if(i==="camera"||i==="microphone"){const c=i==="camera"?{video:!0}:{audio:!0},d=(await navigator.mediaDevices.enumerateDevices()).filter(v=>i==="camera"?v.kind==="videoinput":v.kind==="audioinput");d.length>0&&(l.settings.deviceId=d[0].deviceId)}else(i==="screen"||i==="window")&&await navigator.mediaDevices.getDisplayMedia({video:!0})}catch(c){console.warn(`Could not access ${i}:`,c)}_({sources:[...a.sources,l]});const n={id:o.createId(),sourceId:l.id,position:{x:0,y:0},size:{width:a.layout.canvas.width,height:a.layout.canvas.height},visible:!0,opacity:1,zIndex:a.layout.layers.length};_({layout:{...a.layout,layers:[...a.layout.layers,n]}}),y(!1)},k=(i,r)=>{_({sources:a.sources.map(l=>l.id===i?{...l,...r}:l)})},H=i=>{_({sources:a.sources.filter(r=>r.id!==i),layout:{...a.layout,layers:a.layout.layers.filter(r=>r.sourceId!==i)}})},M=(i,r)=>{_({layout:{...a.layout,layers:a.layout.layers.map(l=>l.id===i?{...l,...r}:l)}})},ee=i=>{const r=a.layout.layers.findIndex(l=>l.id===i);if(r<a.layout.layers.length-1){const l=[...a.layout.layers];[l[r],l[r+1]]=[l[r+1],l[r]],l.forEach((n,c)=>{n.zIndex=c}),_({layout:{...a.layout,layers:l}})}},ie=i=>{const r=a.layout.layers.findIndex(l=>l.id===i);if(r>0){const l=[...a.layout.layers];[l[r],l[r-1]]=[l[r-1],l[r]],l.forEach((n,c)=>{n.zIndex=c}),_({layout:{...a.layout,layers:l}})}},G=()=>{const i={name:`Scene ${C.length+1}`,canvas:{...a.layout.canvas},layers:[]};I([...C,i])},Y=i=>{const r=[...C];r[D]=a.layout,I(r),Q(i),_({layout:C[i]})},J=async()=>{try{_({destinations:a.destinations.map(i=>i.enabled?{...i,status:"connecting"}:i)}),await new Promise(i=>setTimeout(i,2e3)),_({destinations:a.destinations.map(i=>i.enabled?{...i,status:"live"}:i)}),b(!0),g.current=Date.now(),$==null||$(),S.current=setInterval(()=>{const i={duration:(Date.now()-g.current)/1e3,viewers:Math.floor(Math.random()*100)+f.viewers,peakViewers:Math.max(f.peakViewers,f.viewers),bitrate:a.settings.video.bitrate+Math.floor(Math.random()*500-250),fps:a.settings.video.frameRate-Math.random()*2,droppedFrames:f.droppedFrames+(Math.random()>.95?1:0),cpuUsage:15+Math.random()*30,memoryUsage:40+Math.random()*20};T(i),F==null||F(i)},1e3)}catch(i){R==null||R(i instanceof Error?i:new Error("Failed to start stream")),_({destinations:a.destinations.map(r=>({...r,status:"error"}))})}},B=()=>{S.current&&clearInterval(S.current),_({destinations:a.destinations.map(i=>({...i,status:"idle"}))}),b(!1),A==null||A()},se=i=>{const r=Math.floor(i/3600),l=Math.floor(i%3600/60),n=Math.floor(i%60);return`${r.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},te=i=>{switch(i){case"live":return"var(--nice-success, #00ff00)";case"connecting":return"var(--nice-warning, #ffff00)";case"error":return"var(--nice-danger, #ff0000)";default:return"var(--nice-text-secondary, #888888)"}};return e.jsxs("div",{className:`nice-live-streaming ${m}`,children:[e.jsxs("header",{className:"nice-live-streaming__header",children:[e.jsxs("div",{className:"nice-live-streaming__header-title",children:[e.jsx("input",{type:"text",value:a.name,onChange:i=>_({name:i.target.value}),className:"nice-live-streaming__stream-name-input"}),h&&e.jsxs("span",{className:"nice-live-streaming__live-badge",children:[e.jsx("span",{className:"nice-live-streaming__live-dot"})," ",s("liveStreaming.live","LIVE")]})]}),e.jsx("div",{className:"nice-live-streaming__header-stats",children:h&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(o.NiceIcon,{name:"clock",size:14})," ",se(f.duration)]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(o.NiceIcon,{name:"users",size:14})," ",f.viewers]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(o.NiceIcon,{name:"bar-chart",size:14})," ",s("liveStreaming.kbps","{bitrate} kbps").replace("{bitrate}",String(Math.round(f.bitrate)))]}),e.jsxs("span",{className:"nice-live-streaming__stat-item",children:[e.jsx(o.NiceIcon,{name:"video",size:14})," ",f.fps.toFixed(1)," fps"]})]})}),e.jsx("div",{className:"nice-live-streaming__header-actions",children:h?e.jsx("button",{className:"nice-live-streaming__action-button nice-live-streaming__action-button--stop",onClick:B,children:s("liveStreaming.endStream","End Stream")}):e.jsx("button",{className:"nice-live-streaming__action-button nice-live-streaming__action-button--go-live",onClick:J,disabled:a.destinations.filter(i=>i.enabled).length===0,children:s("liveStreaming.goLive","Go Live")})})]}),e.jsxs("div",{className:"nice-live-streaming__main",children:[e.jsxs("div",{className:"nice-live-streaming__preview",children:[e.jsxs("div",{className:"nice-live-streaming__scenes-bar",children:[C.map((i,r)=>e.jsx("button",{className:`nice-live-streaming__scene-button ${D===r?"nice-live-streaming__scene-button--active":""}`,onClick:()=>Y(r),children:i.name},r)),e.jsx("button",{className:"nice-live-streaming__scene-button nice-live-streaming__scene-button--add",onClick:G,children:"+"})]}),e.jsx("div",{ref:X,className:"nice-live-streaming__preview-canvas",style:{aspectRatio:`${a.layout.canvas.width}/${a.layout.canvas.height}`,backgroundColor:a.layout.canvas.backgroundColor},children:a.layout.layers.sort((i,r)=>i.zIndex-r.zIndex).map(i=>{var l;const r=a.sources.find(n=>n.id===i.sourceId);return!i.visible||!r?null:e.jsx("div",{role:"presentation",className:`nice-live-streaming__canvas-layer ${N===i.id?"nice-live-streaming__canvas-layer--selected":""}`,style:{left:`${i.position.x/a.layout.canvas.width*100}%`,top:`${i.position.y/a.layout.canvas.height*100}%`,width:`${i.size.width/a.layout.canvas.width*100}%`,height:`${i.size.height/a.layout.canvas.height*100}%`,opacity:i.opacity,zIndex:i.zIndex},onClick:()=>L(i.id),children:e.jsxs("div",{className:"nice-live-streaming__layer-content",children:[e.jsx("span",{className:"nice-live-streaming__layer-icon",children:e.jsx(o.NiceIcon,{name:((l=ne.find(n=>n.type===r.type))==null?void 0:l.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__layer-name",children:r.name})]})},i.id)})})]}),e.jsxs("aside",{className:"nice-live-streaming__panel",children:[e.jsx("div",{className:"nice-live-streaming__panel-tabs",children:["sources","audio","destinations","settings"].map(i=>e.jsx("button",{className:`nice-live-streaming__panel-tab ${j===i?"nice-live-streaming__panel-tab--active":""}`,onClick:()=>K(i),children:i.charAt(0).toUpperCase()+i.slice(1)},i))}),e.jsxs("div",{className:"nice-live-streaming__panel-content",children:[j==="sources"&&e.jsxs("div",{className:"nice-live-streaming__sources-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:s("liveStreaming.sources","Sources")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>y(!0),disabled:h,children:s("liveStreaming.add","+ Add")})]}),e.jsx("div",{className:"nice-live-streaming__sources-list",children:a.sources.filter(i=>i.type!=="microphone"&&i.type!=="system-audio").map(i=>{var l;const r=a.layout.layers.find(n=>n.sourceId===i.id);return e.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?o.clickOnActivationKey:void 0,className:`nice-live-streaming__source-item ${N===(r==null?void 0:r.id)?"nice-live-streaming__source-item--selected":""}`,onClick:()=>r&&L(r.id),children:[e.jsx("span",{className:"nice-live-streaming__source-icon",children:e.jsx(o.NiceIcon,{name:((l=ne.find(n=>n.type===i.type))==null?void 0:l.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__source-name",children:i.name}),e.jsxs("div",{className:"nice-live-streaming__source-controls",children:[e.jsx("button",{className:`nice-live-streaming__visibility-toggle ${r!=null&&r.visible?"":"nice-live-streaming__visibility-toggle--hidden"}`,onClick:n=>{n.stopPropagation(),r&&M(r.id,{visible:!r.visible})},children:e.jsx(o.NiceIcon,{name:r!=null&&r.visible?"eye":"eye-off",size:14})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),r&&ee(r.id)},children:e.jsx(o.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),r&&ie(r.id)},children:e.jsx(o.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),H(i.id)},disabled:h,children:e.jsx(o.NiceIcon,{name:"trash",size:14})})]})]},i.id)})}),N&&e.jsxs("div",{className:"nice-live-streaming__layer-properties",children:[e.jsx("h4",{children:s("liveStreaming.properties","Properties")}),(()=>{const i=a.layout.layers.find(r=>r.id===N);return i?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[s("liveStreaming.xPosition","X Position"),e.jsx("input",{type:"number",value:i.position.x,onChange:r=>M(i.id,{position:{...i.position,x:parseInt(r.target.value)||0}})})]}),e.jsxs("label",{children:[s("liveStreaming.yPosition","Y Position"),e.jsx("input",{type:"number",value:i.position.y,onChange:r=>M(i.id,{position:{...i.position,y:parseInt(r.target.value)||0}})})]}),e.jsxs("label",{children:[s("liveStreaming.width","Width"),e.jsx("input",{type:"number",value:i.size.width,onChange:r=>M(i.id,{size:{...i.size,width:parseInt(r.target.value)||100}})})]}),e.jsxs("label",{children:[s("liveStreaming.height","Height"),e.jsx("input",{type:"number",value:i.size.height,onChange:r=>M(i.id,{size:{...i.size,height:parseInt(r.target.value)||100}})})]}),e.jsxs("label",{children:[s("liveStreaming.opacity","Opacity"),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:i.opacity,onChange:r=>M(i.id,{opacity:parseFloat(r.target.value)})})]})]}):null})()]})]}),j==="audio"&&e.jsxs("div",{className:"nice-live-streaming__audio-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:s("liveStreaming.audioMixer","Audio Mixer")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>{y(!0)},disabled:h,children:s("liveStreaming.add","+ Add")})]}),e.jsxs("div",{className:"nice-live-streaming__audio-sources",children:[a.sources.filter(i=>i.type==="microphone"||i.type==="system-audio"||i.type==="video").map(i=>{var r;return e.jsxs("div",{className:"nice-live-streaming__audio-source",children:[e.jsxs("div",{className:"nice-live-streaming__audio-header",children:[e.jsx("span",{className:"nice-live-streaming__audio-icon",children:e.jsx(o.NiceIcon,{name:((r=ne.find(l=>l.type===i.type))==null?void 0:r.icon)??"box",size:16})}),e.jsx("span",{className:"nice-live-streaming__audio-name",children:i.name}),e.jsx("button",{className:`nice-live-streaming__mute-toggle ${i.muted?"nice-live-streaming__mute-toggle--muted":""}`,onClick:()=>k(i.id,{muted:!i.muted}),children:e.jsx(o.NiceIcon,{name:i.muted?"volume-off":"volume",size:14})})]}),e.jsxs("div",{className:"nice-live-streaming__audio-slider",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:i.volume??1,onChange:l=>k(i.id,{volume:parseFloat(l.target.value)}),disabled:i.muted}),e.jsxs("span",{className:"nice-live-streaming__volume-value",children:[Math.round((i.volume??1)*100),"%"]})]}),e.jsx("div",{className:"nice-live-streaming__audio-meter",children:e.jsx("div",{className:"nice-live-streaming__meter-fill",style:{width:`${(i.volume??1)*70+Math.random()*30}%`}})})]},i.id)}),a.sources.filter(i=>i.type==="microphone"||i.type==="system-audio").length===0&&e.jsx("p",{className:"nice-live-streaming__empty-message",children:s("liveStreaming.noAudioSourcesAdded","No audio sources added")})]})]}),j==="destinations"&&e.jsxs("div",{className:"nice-live-streaming__destinations-panel",children:[e.jsxs("div",{className:"nice-live-streaming__panel-header",children:[e.jsx("h3",{children:s("liveStreaming.destinations","Destinations")}),e.jsx("button",{className:"nice-live-streaming__add-button",onClick:()=>V(!0),disabled:h,children:s("liveStreaming.add","+ Add")})]}),e.jsxs("div",{className:"nice-live-streaming__destinations-list",children:[a.destinations.map(i=>{var r;return e.jsxs("div",{className:"nice-live-streaming__destination-item",children:[e.jsxs("div",{className:"nice-live-streaming__destination-header",children:[e.jsx("span",{className:"nice-live-streaming__status-indicator",style:{backgroundColor:te(i.status)}}),e.jsx("span",{className:"nice-live-streaming__destination-icon",children:e.jsx(o.NiceIcon,{name:((r=ae.find(l=>l.platform===i.platform))==null?void 0:r.icon)??"link",size:16})}),e.jsx("span",{className:"nice-live-streaming__destination-name",children:i.name}),e.jsxs("label",{className:"nice-live-streaming__toggle",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:l=>W(i.id,{enabled:l.target.checked}),disabled:h}),e.jsx("span",{className:"nice-live-streaming__toggle-slider"})]})]}),e.jsxs("div",{className:"nice-live-streaming__destination-config",children:[e.jsxs("label",{children:[s("liveStreaming.serverUrl","Server URL"),e.jsx("input",{type:"text",value:i.url,onChange:l=>W(i.id,{url:l.target.value}),placeholder:s("liveStreaming.rtmp","rtmp://..."),disabled:h})]}),e.jsxs("label",{children:[s("liveStreaming.streamKey","Stream Key"),e.jsx("input",{type:"password",value:i.streamKey||"",onChange:l=>W(i.id,{streamKey:l.target.value}),placeholder:s("liveStreaming.enterStreamKey","Enter stream key"),disabled:h})]})]}),e.jsx("button",{className:"nice-live-streaming__remove-button",onClick:()=>U(i.id),disabled:h,children:s("liveStreaming.remove","Remove")})]},i.id)}),a.destinations.length===0&&e.jsx("p",{className:"nice-live-streaming__empty-message",children:s("liveStreaming.noDestinationsConfigured","No destinations configured")})]})]}),j==="settings"&&e.jsxs("div",{className:"nice-live-streaming__settings-panel",children:[e.jsxs("div",{className:"nice-live-streaming__setting-section",children:[e.jsx("h4",{children:s("liveStreaming.video","Video")}),e.jsxs("label",{children:[s("liveStreaming.resolution","Resolution"),e.jsxs("select",{value:`${a.settings.video.resolution.width}x${a.settings.video.resolution.height}`,onChange:i=>{const[r,l]=i.target.value.split("x").map(Number);_({settings:{...a.settings,video:{...a.settings.video,resolution:{width:r,height:l}}},layout:{...a.layout,canvas:{...a.layout.canvas,width:r,height:l}}})},disabled:h,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:[s("liveStreaming.frameRate","Frame Rate"),e.jsxs("select",{value:a.settings.video.frameRate,onChange:i=>_({settings:{...a.settings,video:{...a.settings.video,frameRate:parseInt(i.target.value)}}}),disabled:h,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:[s("liveStreaming.bitrateKbps","Bitrate (kbps)"),e.jsx("input",{type:"number",value:a.settings.video.bitrate,onChange:i=>_({settings:{...a.settings,video:{...a.settings.video,bitrate:parseInt(i.target.value)||6e3}}}),min:"1000",max:"50000",disabled:h})]}),e.jsxs("label",{children:[s("liveStreaming.keyframeIntervalSec","Keyframe Interval (sec)"),e.jsx("input",{type:"number",value:a.settings.video.keyframe,onChange:i=>_({settings:{...a.settings,video:{...a.settings.video,keyframe:parseInt(i.target.value)||2}}}),min:"1",max:"10",disabled:h})]})]}),e.jsxs("div",{className:"nice-live-streaming__setting-section",children:[e.jsx("h4",{children:s("liveStreaming.audio","Audio")}),e.jsxs("label",{children:[s("liveStreaming.sampleRate","Sample Rate"),e.jsxs("select",{value:a.settings.audio.sampleRate,onChange:i=>_({settings:{...a.settings,audio:{...a.settings.audio,sampleRate:parseInt(i.target.value)}}}),disabled:h,children:[e.jsx("option",{value:"44100",children:"44.1 kHz"}),e.jsx("option",{value:"48000",children:"48 kHz"})]})]}),e.jsxs("label",{children:[s("liveStreaming.audioBitrateKbps","Audio Bitrate (kbps)"),e.jsxs("select",{value:a.settings.audio.bitrate,onChange:i=>_({settings:{...a.settings,audio:{...a.settings.audio,bitrate:parseInt(i.target.value)}}}),disabled:h,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"})]})]})]})]})]})]})]}),h&&e.jsx("footer",{className:"nice-live-streaming__footer",children:e.jsxs("div",{className:"nice-live-streaming__footer-stats",children:[e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:"CPU"}),e.jsxs("span",{className:"nice-live-streaming__value",children:[f.cpuUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:s("liveStreaming.memory","Memory")}),e.jsxs("span",{className:"nice-live-streaming__value",children:[f.memoryUsage.toFixed(1),"%"]})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:s("liveStreaming.dropped","Dropped")}),e.jsx("span",{className:"nice-live-streaming__value",children:f.droppedFrames})]}),e.jsxs("span",{className:"nice-live-streaming__stat",children:[e.jsx("label",{children:s("liveStreaming.peakViewers","Peak Viewers")}),e.jsx("span",{className:"nice-live-streaming__value",children:f.peakViewers})]})]})}),O&&e.jsx("div",{className:"nice-live-streaming__modal-overlay",children:e.jsxs("div",{className:"nice-live-streaming__modal",children:[e.jsxs("div",{className:"nice-live-streaming__modal-header",children:[e.jsx("h3",{children:s("liveStreaming.addSource","Add Source")}),e.jsx("button",{"aria-label":s("liveStreaming.close","Close"),className:"nice-live-streaming__close-button",onClick:()=>y(!1),children:e.jsx(o.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-live-streaming__modal-content",children:e.jsx("div",{className:"nice-live-streaming__source-type-grid",children:ne.map(i=>e.jsxs("button",{className:"nice-live-streaming__source-type-button",onClick:()=>Z(i.type),children:[e.jsx("span",{className:"nice-live-streaming__icon",children:e.jsx(o.NiceIcon,{name:i.icon,size:24})}),e.jsx("span",{className:"nice-live-streaming__name",children:i.name})]},i.type))})})]})}),q&&e.jsx("div",{className:"nice-live-streaming__modal-overlay",children:e.jsxs("div",{className:"nice-live-streaming__modal",children:[e.jsxs("div",{className:"nice-live-streaming__modal-header",children:[e.jsx("h3",{children:s("liveStreaming.addDestination","Add Destination")}),e.jsx("button",{"aria-label":s("liveStreaming.close","Close"),className:"nice-live-streaming__close-button",onClick:()=>V(!1),children:e.jsx(o.NiceIcon,{name:"close",size:16})})]}),e.jsx("div",{className:"nice-live-streaming__modal-content",children:e.jsx("div",{className:"nice-live-streaming__platform-grid",children:ae.map(i=>e.jsxs("button",{className:"nice-live-streaming__platform-button",onClick:()=>P(i.platform),children:[e.jsx("span",{className:"nice-live-streaming__icon",children:e.jsx(o.NiceIcon,{name:i.icon,size:24})}),e.jsx("span",{className:"nice-live-streaming__name",children:i.name})]},i.platform))})})]})})]})};exports.NiceLiveStreaming=_e;exports.NiceScreenRecorder=pe;exports.NiceVideoEditor=ve;
|