PageSourceSearch

https://ballo.io/assets/BlQsU2ok.js

js ballo.io collected 2026-10-04 06:10:19 UTC 87,688 bytes, 1 lines download raw bytes

1var Ps=Object.defineProperty;var s=(t,n)=>Ps(t,"name",{value:n,configurable:!0});import{j as e}from"./C8EeKvrq.js";import{r as l,d as Zs}from"./DjJLEu1G.js";import{v as b,b as Hs}from"./DuNFk3UT.js";import{af as xe,R as v,a5 as Ae,aB as Ws,T as lt,a3 as V,a4 as D,aa as mt,ad as it,eX as Dt,a2 as _s,b_ as Gs,S as Xs,Q as qs,eY as Qs,eZ as Js,ar as Lt,aJ as Ys}from"./VbOR_FEF.js";import{X as de,l as nt,G as at,aF as en,L as B,aR as tn,ao as De,_ as gt,aq as ye,aG as Ft,c6 as sn,V as ct,aj as ts,eR as bt,aZ as Rt,as as nn,at as an,a2 as rn,eS as ln,bN as cn,c1 as on,j as ss,aD as rt,S as dn,cY as ns,f as as,bm as un,aC as jt,az as He,K as vt,T as hn,d as mn,w as wt,am as xn,bV as rs,a as We,A as fn,eg as pn,bf as gn,b3 as is,cp as ls,ef as bn,a_ as cs,cg as jn,U as vn,cF as xt,bh as Ot,d0 as $t,D as Kt,e9 as Ut}from"./CyudszgP.js";import{u as wn,B as kn,w as ft,a as Nn,I as yn}from"./BgINzr46.js";import{O as Sn}from"./DGDIQDzE.js";import{O as st}from"./AkLd-TbO.js";import"./BjV-FQ_Q.js";import"./BuwJzJuA.js";import"./DbWYqldV.js";function Cn({video:t,onClose:n,onChanged:o}){const[r,c]=l.useState(t.visibility),[d,h]=l.useState([]),[g,f]=l.useState(""),[C,E]=l.useState([]),[j,m]=l.useState(!1),[z,N]=l.useState(!1),[k,A]=l.useState([]),[I,T]=l.useState(""),[S,y]=l.useState("7"),[_,P]=l.useState(!1),[ie,ue]=l.useState(null),[M,U]=l.useState(null),[he,se]=l.useState(null),J=l.useRef(null),Z=l.useRef(null);l.useEffect(()=>()=>{J.current!==null&&clearTimeout(J.current),Z.current!==null&&clearTimeout(Z.current)},[]);const H=l.useCallback(async()=>{try{h(await b.listShares(t.id))}catch{}},[t.id]),Y=l.useCallback(async()=>{try{A(await b.listShareLinks(t.id))}catch{}},[t.id]);l.useEffect(()=>{H(),Y()},[H,Y]),l.useEffect(()=>{if(!g.trim()){E([]);return}const x=setTimeout(async()=>{m(!0);try{E(await b.searchUsers(g))}catch{E([])}finally{m(!1)}},300);return()=>clearTimeout(x)},[g]);const W=new Set(d.map(x=>x.id)),G=s(async x=>{N(!0);try{await b.share(t.id,{userIds:[x.id]}),f(""),E([]),await H(),o()}catch(K){V(D(K,"Freigabe fehlgeschlagen"))}finally{N(!1)}},"addUser"),X=s(async x=>{N(!0);try{await b.revoke(t.id,x),await H(),o()}catch(K){V(D(K,"Entfernen fehlgeschlagen"))}finally{N(!1)}},"removeUser"),fe=s(async()=>{P(!0);try{const x=S?Number(S):void 0;await b.createShareLink(t.id,{label:I.trim()||void 0,expiresInDays:x}),T(""),await Y()}catch(x){V(D(x,"Link konnte nicht erstellt werden"))}finally{P(!1)}},"createLink"),$=s(async x=>{try{await b.revokeShareLink(t.id,x),await Y()}catch(K){V(D(K,"Widerruf fehlgeschlagen"))}},"revokeLink"),le=s(async x=>{try{await navigator.clipboard.writeText(Hs(x)),ue(x),J.current!==null&&clearTimeout(J.current),J.current=setTimeout(()=>{J.current=null,ue(K=>K===x?null:K)},1800)}catch{V("Konnte nicht in die Zwischenablage kopieren.")}},"copyLink"),ve=s(async x=>{try{await navigator.clipboard.writeText(b.embedSnippet(x,t.title)),se(x),Z.current!==null&&clearTimeout(Z.current),Z.current=setTimeout(()=>{Z.current=null,se(K=>K===x?null:K)},1800)}catch{V("Konnte den Einbettungscode nicht kopieren.")}},"copyEmbed"),ce=s(async x=>{c(x),N(!0);try{await b.share(t.id,{visibility:x}),o()}catch(K){c(t.visibility),V(D(K,"Sichtbarkeit konnte nicht geändert werden"))}finally{N(!1)}},"changeVisibility");return e.jsx(xe,{onClose:n,className:"z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl bg-surface shadow-2xl",onClick:s(x=>x.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"truncate text-lg font-semibold text-text-primary",children:"Freigeben"}),e.jsx("p",{className:"truncate text-sm text-text-soft",children:t.title})]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:n,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"space-y-5 p-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-medium text-text-strong",children:"Sichtbarkeit"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:s(()=>ce("privat"),"onClick"),disabled:z,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${r==="privat"?"border-brand-500 bg-brand-50 text-brand-stark dark:bg-brand-950/30":"border-strong text-text-strong hover:bg-subtle-soft"}`,children:[e.jsx(nt,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Privat",e.jsx("span",{className:"block text-xs text-text-muted",children:"nur Freigegebene"})]})]}),e.jsxs("button",{onClick:s(()=>ce("instanz"),"onClick"),disabled:z,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${r==="instanz"?"border-brand-500 bg-brand-50 text-brand-stark dark:bg-brand-950/30":"border-strong text-text-strong hover:bg-subtle-soft"}`,children:[e.jsx(at,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Instanzweit",e.jsx("span",{className:"block text-xs text-text-muted",children:"alle Nutzer · steht in der Videothek"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-medium text-text-strong",children:"Einzelne Benutzer freigeben"}),e.jsxs("div",{className:"relative",children:[e.jsx(en,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-muted"}),e.jsx(Ae,{type:"text",value:g,onChange:s(x=>f(x.target.value),"onChange"),placeholder:"Name oder E-Mail suchen…",className:"pl-9"}),j&&e.jsx(B,{className:"absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin text-text-muted"})]}),C.length>0&&e.jsx("div",{className:"mt-2 max-h-44 overflow-y-auto rounded-lg border border-default",children:C.map(x=>e.jsxs("button",{onClick:s(()=>G(x),"onClick"),disabled:z||W.has(x.id),className:"flex w-full items-center justify-between px-3 py-2 text-left text-sm hover:bg-subtle-soft disabled:opacity-40",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-text-primary",children:x.name}),e.jsx("span",{className:"block truncate text-xs text-text-muted",children:x.email})]}),W.has(x.id)?e.jsx("span",{className:"text-xs text-text-muted",children:"bereits"}):e.jsx(tn,{className:"h-4 w-4 shrink-0 text-brand-600"})]},x.id))})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"mb-2 text-sm font-medium text-text-strong",children:["Freigegeben an ",d.length]}),d.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:r==="instanz"?"Steht in der Videothek, für alle sichtbar — keine Einzel-Freigaben nötig.":"Noch niemandem freigegeben."}):e.jsx("div",{className:"space-y-1",children:d.map(x=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-subtle-soft px-3 py-2",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-sm text-text-primary",children:x.name}),e.jsx("span",{className:"block truncate text-xs text-text-muted",children:x.email})]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:s(()=>X(x.id),"onClick"),disabled:z,children:e.jsx(De,{className:"h-4 w-4"})})]},x.id))})]}),e.jsxs("div",{className:"border-t border-default pt-5",children:[e.jsxs("p",{className:"mb-1 flex items-center gap-2 text-sm font-medium text-text-strong",children:[e.jsx(gt,{className:"h-4 w-4"}),"Öffentlicher Link"]}),e.jsx("p",{className:"mb-2 text-xs text-text-muted",children:"Für Externe ohne ballo-Account. Zeitlich begrenzt und jederzeit widerrufbar."}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"min-w-[7rem] flex-1",children:[e.jsx("label",{className:"mb-1 block text-xs text-text-soft",children:"Merkname (optional)"}),e.jsx(Ae,{type:"text",value:I,onChange:s(x=>T(x.target.value),"onChange"),placeholder:"z. B. Patrick"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-soft",children:"Gültig"}),e.jsxs(Ws,{value:S,onChange:s(x=>y(x.target.value),"onChange"),children:[e.jsx("option",{value:"1",children:"1 Tag"}),e.jsx("option",{value:"7",children:"7 Tage"}),e.jsx("option",{value:"30",children:"30 Tage"}),e.jsx("option",{value:"90",children:"90 Tage"}),e.jsx("option",{value:"",children:"unbegrenzt"})]})]}),e.jsxs(v,{onClick:fe,disabled:_,children:[_?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(gt,{className:"h-4 w-4"}),"Link erstellen"]})]}),k.length>0&&e.jsx("div",{className:"mt-3 space-y-1",children:k.map(x=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg bg-subtle-soft px-3 py-2",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-text-primary",children:[e.jsx("span",{className:"truncate",children:x.label||"Freigabe-Link"}),x.isActive?e.jsx("span",{className:"shrink-0 rounded-full bg-green-100 px-1.5 text-[11px] font-medium text-green-700 dark:bg-green-900/40 dark:text-green-300",children:"aktiv"}):e.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 text-[11px] font-medium text-text-soft",children:x.revokedAt?"widerrufen":"abgelaufen"})]}),e.jsx("span",{className:"block truncate text-xs text-text-muted",children:x.expiresAt?`läuft ab am ${new Date(x.expiresAt).toLocaleDateString("de-DE")}`:"unbegrenzt gültig"})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[x.isActive&&e.jsx(v,{variant:"secondary",size:"iconSm",onClick:s(()=>le(x.token),"onClick"),title:"Link kopieren",className:"w-8",children:ie===x.token?e.jsx(ye,{className:"h-4 w-4 text-green-600"}):e.jsx(Ft,{className:"h-4 w-4"})}),x.isActive&&e.jsx("button",{onClick:s(()=>U(K=>K===x.token?null:x.token),"onClick"),title:"Auf Website einbetten",className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border ${M===x.token?"border-brand-500 bg-brand-50 text-brand-stark dark:bg-brand-950/30":"border-strong text-text-secondary hover:bg-white dark:hover:bg-gray-700"}`,children:e.jsx(sn,{className:"h-4 w-4"})}),!x.revokedAt&&e.jsx(v,{variant:"secondary",size:"iconSm",onClick:s(()=>$(x.id),"onClick"),title:"Widerrufen",className:"w-8",children:e.jsx(De,{className:"h-4 w-4"})})]})]}),x.isActive&&M===x.token&&e.jsxs("div",{className:"mt-1 rounded-lg border border-default bg-surface p-3",children:[e.jsxs("div",{className:"mb-2 flex items-start gap-2 rounded-lg border border-amber-300 bg-amber-50 p-2.5 text-xs text-amber-800 dark:border-amber-700/60 dark:bg-amber-950/30 dark:text-amber-300",children:[e.jsx(ct,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Achtung §203 StGB:"})," Ein eingebettetes Video ist für ",e.jsx("strong",{children:"jeden"})," ","Besucher der fremden Website sichtbar. Es dürfen ",e.jsx("strong",{children:"keinerlei Mandantendaten"})," ","(Namen, Fälle, Unterlagen, personenbezogene Daten) im Video enthalten sein. Nur allgemeine, zur Veröffentlichung freigegebene Inhalte einbetten."]})]}),e.jsx("label",{className:"mb-1 block text-xs text-text-soft",children:"HTML-Einbettungscode"}),e.jsx(lt,{readOnly:!0,rows:3,value:b.embedSnippet(x.token,t.title),onFocus:s(K=>K.currentTarget.select(),"onFocus"),className:"resize-none font-mono text-[11px]"}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(v,{size:"sm",onClick:s(()=>ve(x.token),"onClick"),children:[he===x.token?e.jsx(ye,{className:"h-4 w-4"}):e.jsx(Ft,{className:"h-4 w-4"}),he===x.token?"Kopiert":"Code kopieren"]})})]})]},x.id))})]})]}),e.jsx("div",{className:"flex justify-end border-t border-default px-5 py-3",children:e.jsx(v,{onClick:n,children:"Fertig"})})]})})}s(Cn,"FreigabeModal");function os(t){const{canvasW:n,canvasH:o,fraction:r=.2,minDiameter:c=96,maxDiameter:d=320,marginFraction:h=.03,minMargin:g=16}=t,f=Math.max(1,n),C=Math.max(1,o),E=Math.min(d,Math.min(f,C)*.5),j=f*r,z=M
1ath.round(Math.min(Math.max(j,c),Math.max(c,E)))/2,N=Math.round(Math.max(f*h,g)),k=N+z,A=C-N-z;return{cx:k,cy:A,radius:z}}s(os,"computePipCircle");function pt(t,n,o){const r=(t??"").trim();return r||`${n==="audio"?"Mikrofon":"Kamera"} ${o+1}`}s(pt,"deviceLabel");function Bt(t){return t.some(n=>!(n.label??"").trim())}s(Bt,"hasUnnamedDevices");function Mn(t=globalThis){const n=t;return typeof n.MediaStreamTrackProcessor=="function"&&typeof n.MediaStreamTrackGenerator=="function"&&typeof n.VideoFrame=="function"&&typeof n.OffscreenCanvas=="function"}s(Mn,"unterstuetztInsertableStreams");function Tn(t,n,o,r,c){const d=Math.min(o,r),h=(o-d)/2,g=(r-d)/2;t.save(),t.beginPath(),t.arc(c.cx,c.cy,c.radius,0,Math.PI*2),t.closePath(),t.clip(),t.translate(c.cx*2,0),t.scale(-1,1),t.drawImage(n,h,g,d,d,c.cx-c.radius,c.cy-c.radius,c.radius*2,c.radius*2),t.restore(),t.save(),t.beginPath(),t.arc(c.cx,c.cy,c.radius,0,Math.PI*2),t.lineWidth=Math.max(2,c.radius*.06),t.strokeStyle="rgba(255,255,255,0.92)",t.stroke(),t.restore()}s(Tn,"zeichneBlase");const Pt=1080,Zt=1920;function zn(t,n){if(t<=0||n<=0)return{breite:Zt,hoehe:Pt};const o=Math.min(Zt/t,Pt/n,1),r=s(c=>Math.max(2,Math.round(c*o/2)*2),"gerade");return{breite:r(t),hoehe:r(n)}}s(zn,"deckleAufFullHd");function Vn(t){const{bildschirmSpur:n,kameraSpur:o,breite:r,hoehe:c}=t,d=t.bereich??globalThis,h=new d.OffscreenCanvas(r,c),g=h.getContext("2d");if(!g)throw new Error("OffscreenCanvas ohne 2D-Kontext");const f=new d.MediaStreamTrackGenerator({kind:"video"}),C=new d.MediaStreamTrackProcessor({track:n}).readable,E=new d.MediaStreamTrackProcessor({track:o}).readable;let j=null,m=!1,z=null;const N=60;let k=0;const A=new AbortController;return C.pipeTo(new WritableStream({write(I){if(m){I.close();return}j==null||j.close(),j=I}}),{signal:A.signal}).catch(()=>{}),E.pipeThrough(new TransformStream({transform(I,T){if(!j&&k<N){k++,I.close();return}z===null&&(z=I.timestamp);const S=Math.max(0,I.timestamp-z);try{j?g.drawImage(j,0,0,r,c):(g.fillStyle="#000",g.fillRect(0,0,r,c)),Tn(g,I,I.displayWidth,I.displayHeight,os({canvasW:r,canvasH:c}))}finally{I.close()}T.enqueue(new d.VideoFrame(h,{timestamp:S}))}}),{signal:A.signal}).pipeTo(f.writable,{signal:A.signal}).catch(()=>{}),{spur:f,stop(){if(!m){m=!0,A.abort(),j==null||j.close(),j=null;try{f.stop()}catch{}}}}}s(Vn,"komponiereSpur");function En(t,n=globalThis){const o=t.filter(f=>f&&f.readyState!=="ended");if(o.length===0)return{spur:null,stop:s(()=>{},"stop")};if(o.length===1)return{spur:o[0],stop:s(()=>{},"stop")};const r=n;if(typeof r.AudioContext!="function")return{spur:o[0],stop:s(()=>{},"stop")};const c=r.MediaStream??globalThis.MediaStream,d=new r.AudioContext,h=d.createMediaStreamDestination();o.forEach(f=>{try{d.createMediaStreamSource(new c([f])).connect(h)}catch{}});let g=!1;return{spur:h.stream.getAudioTracks()[0]??o[0],stop(){g||(g=!0,d.state!=="closed"&&d.close().catch(()=>{}))}}}s(En,"mischeAudio");const In=3e3;function An(t){return Number.isFinite(t)&&t>0}s(An,"istDauerBrauchbar");function Dn(t,n=(o,r)=>setTimeout(o,r)){if(An(t.duration))return!1;let o=!1;const r=s(()=>{o||(o=!0,t.removeEventListener("seeked",r),t.currentTime=0)},"zurueck");return t.addEventListener("seeked",r),n(r,In),t.currentTime=1e101,!0}s(Dn,"erzwingeDauer");async function Ln(t,n){if(!t)return null;const o=t;if(!o.videoWidth||!o.videoHeight)return null;try{const r=n.erzeugeCanvas();r.width=o.videoWidth,r.height=o.videoHeight;const c=r.getContext("2d");if(!c)return null;c.drawImage(t,0,0,r.width,r.height);const d=await new Promise(h=>r.toBlob(h,"image/webp",.8));return d?n.alsUrl(d):null}catch{return null}}s(Ln,"standbildAusStream");const Fn={erzeugeCanvas:s(()=>document.createElement("canvas"),"erzeugeCanvas"),alsUrl:s(t=>URL.createObjectURL(t),"alsUrl")};function Rn(){const t=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"];for(const n of t)if(typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(n))return n;return"video/webm"}s(Rn,"pickMimeType");function Ht(t){const n=Math.floor(t/60),o=t%60;return`${n}:${String(o).padStart(2,"0")}`}s(Ht,"fmtElapsed");function On(t,n,o){const r=n.videoWidth||640,c=n.videoHeight||480,d=Math.min(r,c),h=(r-d)/2,g=(c-d)/2;t.save(),t.beginPath(),t.arc(o.cx,o.cy,o.radius,0,Math.PI*2),t.closePath(),t.clip(),t.translate(o.cx*2,0),t.scale(-1,1),t.drawImage(n,h,g,d,d,o.cx-o.radius,o.cy-o.radius,o.radius*2,o.radius*2),t.restore(
1),t.save(),t.beginPath(),t.arc(o.cx,o.cy,o.radius,0,Math.PI*2),t.lineWidth=Math.max(2,o.radius*.06),t.strokeStyle="rgba(255,255,255,0.92)",t.stroke(),t.restore()}s(On,"drawCamBubble");function $n({mode:t,onClose:n,onRecorded:o}){const[r,c]=l.useState("setup"),[d,h]=l.useState(!0),[g,f]=l.useState(!1),[C,E]=l.useState(0),[j,m]=l.useState(!1),[z,N]=l.useState(null),[k,A]=l.useState(null),[I,T]=l.useState(null),[S,y]=l.useState([]),[_,P]=l.useState([]),[ie,ue]=l.useState(""),[M,U]=l.useState(""),[he,se]=l.useState(!1),J=l.useRef(null),Z=l.useRef(null),H=l.useRef(null),Y=l.useRef([]),W=l.useRef(null),G=l.useRef(null),X=l.useRef([]),fe=l.useRef(null),$=l.useRef(null),le=l.useRef(null),ve=l.useRef(null),ce=l.useCallback(()=>{X.current.forEach(p=>p.getTracks().forEach(w=>w.stop())),X.current=[]},[]),x=l.useCallback(()=>{var p,w;fe.current!=null&&cancelAnimationFrame(fe.current),fe.current=null,(p=le.current)==null||p.stop(),le.current=null,(w=ve.current)==null||w.stop(),ve.current=null,$.current=null},[]),K=l.useCallback(()=>{if(G.current&&clearInterval(G.current),G.current=null,H.current&&H.current.state!=="inactive")try{H.current.stop()}catch{}H.current=null,x(),ce()},[ce,x]),ee=l.useCallback(async()=>{var p;if(!(typeof navigator>"u"||!((p=navigator.mediaDevices)!=null&&p.enumerateDevices)))try{const w=await navigator.mediaDevices.enumerateDevices();y(w.filter(L=>L.kind==="audioinput")),P(w.filter(L=>L.kind==="videoinput"))}catch{}},[]);l.useEffect(()=>{var w;ee();const p=typeof navigator<"u"?navigator.mediaDevices:void 0;return(w=p==null?void 0:p.addEventListener)==null||w.call(p,"devicechange",ee),()=>{var L;return(L=p==null?void 0:p.removeEventListener)==null?void 0:L.call(p,"devicechange",ee)}},[ee]);const Se=l.useRef({preview:null,poster:null});Se.current={preview:z,poster:k},l.useEffect(()=>()=>{K();const{preview:p,poster:w}=Se.current;p&&URL.revokeObjectURL(p),w&&URL.revokeObjectURL(w)},[]);const we=s(async()=>{var p;if(!(typeof navigator>"u"||!((p=navigator.mediaDevices)!=null&&p.getUserMedia))){se(!0);try{const w=t==="kamera"||g;(await navigator.mediaDevices.getUserMedia({audio:!0,video:w})).getTracks().forEach(F=>F.stop()),await ee()}catch{V("Zugriff auf Kamera/Mikrofon wurde abgelehnt.")}finally{se(!1)}}},"primeDevices"),ke=s(()=>ie?{deviceId:{exact:ie}}:!0,"audioConstraint"),Le=s(()=>M?{deviceId:{exact:M}}:!0,"videoConstraint"),Ce=s(async(p,w,L)=>{const F=p.getVideoTracks()[0],R=w.getVideoTracks()[0];if(F&&R&&Mn()){const te=F.getSettings(),{breite:q,hoehe:ne}=zn(te.width||1280,te.height||720),Q=Vn({bildschirmSpur:F,kameraSpur:R,breite:q,hoehe:ne});le.current=Q;const pe=new MediaStream([Q.spur,...L]);return X.current.push(pe),pe}return _e(p,w,L)},"composeStream"),_e=s(async(p,w,L)=>{const F=document.createElement("video");F.muted=!0,F.playsInline=!0,F.srcObject=new MediaStream(p.getVideoTracks()),await F.play().catch(()=>{});const R=document.createElement("video");R.muted=!0,R.playsInline=!0,R.srcObject=new MediaStream(w.getVideoTracks()),await R.play().catch(()=>{}),await new Promise(ge=>{if(F.videoWidth>0)return ge();F.onloadedmetadata=()=>ge(),setTimeout(ge,800)});const te=F.videoWidth||1280,q=F.videoHeight||720,ne=document.createElement("canvas");ne.width=te,ne.height=q;const Q=ne.getContext("2d");$.current={screen:F,cam:R};const pe=s(()=>{if(!Q)return;Q.drawImage(F,0,0,te,q);const ge=os({canvasW:te,canvasH:q});On(Q,R,ge),fe.current=requestAnimationFrame(pe)},"draw");fe.current=requestAnimationFrame(pe);const Ve=ne.captureStream(30);return L.forEach(ge=>Ve.addTrack(ge)),X.current.push(Ve),Ve},"composeCanvasStream"),Ge=s(async()=>{var p;m(!0);try{let w;if(t==="bildschirm"){const R=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});X.current.push(R);const te=[...R.getAudioTracks()];if(d)try{const Q=await navigator.mediaDevices.getUserMedia({audio:ke()});X.current.push(Q),Q.getAudioTracks().forEach(pe=>te.push(pe))}catch{}const q=En(te);ve.current=q;const ne=q.spur?[q.spur]:[];if(g){const Q=await navigator.mediaDevices.getUserMedia({video:Le(),audio:!1});X.current.push(Q),w=await Ce(R,Q,ne)}else w=new MediaStream([...R.getVideoTracks(),...ne]),X.current.push(w);(p=R.getVideoTracks()[0])==null||p.addEventListener("ended",()=>Me())}else w=await navigator.mediaDevices.getUserMedia({video:Le(),audio:d?ke():!1}),X.current.push(w);J.current&&(J.current.srcObject=w,await J.current.play().catch(()=>{}));const L=Rn(),F=new MediaRecorder(w,{mimeType:L});Y.current=[],F.ondataavailable=R=>{R.data.size>0&&Y.current.push(R.data)},F.onstop=()=>{Ln(J.current,Fn).then(q=>{q&&A(q)});const R=new Blob(Y.current,{type:L.split(";")[0]});W.current=R,T(R.size===0?"Die Aufzeichnung ist leer geblieben — es kamen keine Daten vom Rekorder an.":null);const te=URL.createObjectURL(R);N(te),c("vorschau"),x(),ce()},H.current=F,F.start(1e3),E(0),G.current=setInterval(()=>E(R=>
1R+1),1e3),c("aufnahme")}catch(w){const L=w;(L==null?void 0:L.name)==="NotAllowedError"?V("Zugriff auf Bildschirm/Kamera wurde abgelehnt."):V("Aufnahme konnte nicht gestartet werden."),x(),ce()}finally{m(!1)}},"startRecording"),Me=l.useCallback(()=>{G.current&&clearInterval(G.current),G.current=null,H.current&&H.current.state!=="inactive"&&H.current.stop()},[]),Xe=s(()=>{z&&URL.revokeObjectURL(z),k&&URL.revokeObjectURL(k),N(null),A(null),T(null),W.current=null,E(0),c("setup")},"retake"),oe=s(()=>{if(!W.current)return;const p=W.current.type.includes("mp4")?"mp4":"webm",w=new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),L=t==="bildschirm"?"Bildschirmaufnahme":"Kamera-Aufnahme",F=new File([W.current],`${L}-${w}.${p}`,{type:W.current.type});o(F)},"useRecording"),qe=typeof navigator<"u"&&!!navigator.mediaDevices&&(t==="bildschirm"?!!navigator.mediaDevices.getDisplayMedia:!!navigator.mediaDevices.getUserMedia)&&typeof MediaRecorder<"u",Fe=t==="bildschirm"?ts:bt,Re=t==="bildschirm"?"Bildschirm aufnehmen":"Mit Kamera aufnehmen",Te=t==="kamera"||g,ze=d&&Bt(S)||Te&&Bt(_),Oe="h-9 w-full rounded-lg border border-strong bg-surface px-2 text-sm text-text-strong disabled:opacity-50";return e.jsx(xe,{onClose:s(()=>r!=="aufnahme"&&n(),"onClose"),className:"z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-2xl rounded-2xl bg-surface shadow-2xl",onClick:s(p=>p.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-5 py-4",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold text-text-primary",children:[e.jsx(Fe,{className:"h-5 w-5 text-brand-600"}),Re]}),r!=="aufnahme"&&e.jsx(v,{variant:"ghost",size:"iconXs",onClick:n,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"p-5",children:qe?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-4 aspect-video w-full overflow-hidden rounded-xl bg-gray-900",children:[r==="vorschau"&&z?e.jsxs(e.Fragment,{children:[e.jsx("video",{ref:Z,src:z,controls:!0,preload:"auto",poster:k??void 0,playsInline:!0,className:"h-full w-full bg-black",onLoadedMetadata:s(p=>Dn(p.currentTarget),"onLoadedMetadata"),onError:s(p=>{var L;const w=(L=p.currentTarget.error)==null?void 0:L.code;T(`Die Vorschau lässt sich nicht abspielen (Fehler ${w??"?"}). Die Aufzeichnung selbst ist davon nicht betroffen — „Übernehmen & hochladen" funktioniert.`)},"onError")}),I&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-black/80 px-3 py-2 text-xs text-white",children:I})]}):e.jsx("video",{ref:J,muted:!0,playsInline:!0,className:`h-full w-full bg-black ${t==="kamera"&&r!=="aufnahme"?"-scale-x-100":""}`}),r==="setup"&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-text-muted",children:[e.jsx(Fe,{className:"h-10 w-10"}),e.jsx("span",{className:"text-xs",children:t==="bildschirm"?"Beim Start wählst du Fenster/Tab/Bildschirm":"Beim Start fragt der Browser nach der Kamera"})]}),r==="aufnahme"&&e.jsxs("span",{className:"absolute left-3 top-3 inline-flex items-center gap-1.5 rounded-full bg-red-600 px-2 py-0.5 text-xs font-medium text-white",children:[e.jsx(Rt,{className:"h-2.5 w-2.5 animate-pulse fill-white"}),Ht(C)]})]}),r==="setup"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("button",{onClick:s(()=>h(p=>!p),"onClick"),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg border px-3 text-sm font-medium sm:w-44 ${d?"border-brand-500 bg-brand-50 text-brand-stark dark:bg-brand-950/30":"border-strong text-text-secondary"}`,children:[d?e.jsx(nn,{className:"h-4 w-4"}):e.jsx(an,{className:"h-4 w-4"}),"Mikrofon ",d?"an":"aus"]}),e.jsxs("select",{"aria-label":"Mikrofon-Quelle",value:ie,onChange:s(p=>ue(p.target.value),"onChange"),disabled:!d,className:Oe,children:[e.jsx("option",{value:"",children:"Standard-Mikrofon"}),S.map((p,w)=>e.jsx("option",{value:p.deviceId,children:pt(p.label,"audio",w)},p.deviceId||w))]})]}),t==="bildschirm"&&e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("button",{onClick:s(()=>f(p=>!p),"onClick"),className:`inline-flex h-9 shrink-0 items-center gap-1.5 rounded-lg border px-3 text-sm font-medium sm:w-44 ${g?"border-brand-500 bg-brand-50 text-brand-stark dark:bg-brand-950/30":"border-strong text-text-secondary"}`,children:[g?e.jsx(rn,{className:"h-4 w-4"}):e.jsx(ln,{className:"h-4 w-4"}),"Kamera ",g?"an":"aus"]}),g?e.jsxs("select",{"aria-label":"Kamera-Quelle",value:M,onChange:s(p=>U(p.target.value),"onChange"),className:Oe,children:[e.jsx("option",{value:"",children:"Standard-Kamera"}),_.map((p,w)=>e.jsx("option",{value:p.deviceId,children:pt(p.label,"video",w)},p.deviceId||w))]}):e.jsx("span",{className:"text-xs text-text-soft",children:"Blendet dein Kamerabild als runde Blase unten links ein."})]}),t==="kamera"&&e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("span",{className:"inline-flex h-9 shrink-0 items-center gap-1.5 px-1 text-sm font-medium text-text-secondary sm:w-44",children:[e.jsx(bt,{className:"h-4 w-4"}),"Kamera-Quelle"]}),e.jsxs("select",{"aria-label":"Kamera-Quelle",value:M,onChange:s(p=>U(p.target.value),"onChange"),className:Oe,children:[e.jsx("option",{value:"",children:"Standard-Kamera"}),_.map((p,w)=>e.jsx("option",{value:p.deviceId,children:pt(p.label,"video",w)},p.deviceId||w))]})]}),ze&&e.jsxs(v,{variant:"link",size:"sm",onClick:s(()=>void we(),"onClick"),disabled:he,children:[he&&e.jsx(B,{className:"h-3 w-3 animate-spin"}),"Geräte freigeben, um echte Namen anzuzeigen"]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(v,{variant:"danger",onClick:s(()=>void Ge(),"onClick"),disabled:j,children:[j?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(Rt,{className:"h-4 w-4 fill-white"}),"Aufnahme starten"]})})]}),r==="aufnahme"&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(v,{onClick:Me,className:"bg-gray-900 text-sm hover:bg-gray-800 dark:text-text-primary",children:[e.jsx(cn,{className:"h-4 w-4 fill-current"}),"Aufnahme beenden"]})}),r==="vorschau"&&e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsxs("span",{className:"mr-auto text-xs text-text-soft",children:["Aufgezeichnet: ",Ht(C),W.current?` · ${(W.current.size/1048576).toFixed(1)} MB`:""]}),e.jsxs(v,{variant:"secondary",onClick:Xe,children:[e.jsx(on,{className:"h-4 w-4"}),"Neu aufnehmen"]}),e.jsxs(v,{onClick:oe,children:[e.jsx(ye,{className:"h-4 w-4"}),"Übernehmen & hochladen"]})]})]}):e.jsx("p",{className:"py-8 text-center text-sm text-text-soft",children:"Dieser Browser unterstützt die Aufnahme nicht. Bitte einen aktuellen Chrome/Edge/Firefox nutzen (und die Seite über HTTPS öffnen)."})})]})})}s($n,"AufnahmeModal");function Wt(t){const n=Math.max(0,Math.floor(t));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}s(Wt,"fmtTime");function Kn(t){var c;if(!t)return"?";
1const n=t.trim().split(/\s+/).filter(Boolean),o=((c=n[0])==null?void 0:c[0])??"",r=n.length>1?n[n.length-1][0]:"";return(o+r).toUpperCase()||"?"}s(Kn,"initials");function Un(t){const n=["bg-brand-100 text-brand-stark dark:bg-brand-900/40","bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300","bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300","bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300","bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300","bg-rose-100 text-rose-700 dark:bg-rose-900/40 dark:text-rose-300"];let o=0;for(const r of t??"")o=(o*31+r.charCodeAt(0))%n.length;return n[o]}s(Un,"avatarClasses");function Bn(t){const n=new Date(t).getTime(),o=Math.max(0,Date.now()-n),r=Math.floor(o/6e4);if(r<1)return"gerade eben";if(r<60)return`vor ${r} Min.`;const c=Math.floor(r/60);if(c<24)return`vor ${c} Std.`;const d=Math.floor(c/24);return d<30?`vor ${d} Tg.`:new Date(t).toLocaleDateString("de-DE")}s(Bn,"relTime");function Pn({videoId:t,currentTime:n,onSeek:o}){const[r,c]=l.useState([]),[d,h]=l.useState(!0),[g,f]=l.useState(""),[C,E]=l.useState(!1),[j,m]=l.useState(0),[z,N]=l.useState(!1),k=l.useRef(null),A=l.useCallback(async()=>{h(!0);try{c(await b.listComments(t))}catch(y){V(D(y,"Kommentare konnten nicht geladen werden"))}finally{h(!1)}},[t]);l.useEffect(()=>{A()},[A]);const I=s(()=>{m(Math.floor(n())),E(!0)},"attachTime"),T=s(async()=>{const y=g.trim();if(!(!y||z)){N(!0);try{const _=await b.addComment(t,{body:y,timecodeSeconds:C?j:null});c(P=>[...P,_]),f(""),E(!1),requestAnimationFrame(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)})}catch(_){V(D(_,"Kommentar konnte nicht gespeichert werden"))}finally{N(!1)}}},"submit"),S=s(async y=>{const _=r;c(P=>P.filter(ie=>ie.id!==y.id));try{await b.deleteComment(t,y.id)}catch(P){c(_),V(D(P,"Kommentar konnte nicht gelöscht werden"))}},"remove");return e.jsxs("div",{className:"mt-3 rounded-2xl bg-surface p-4",children:[e.jsxs("p",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary",children:[e.jsx(ss,{className:"h-4 w-4 text-brand-600"}),"Kommentare",r.length>0&&e.jsxs("span",{className:"text-text-muted",children:["(",r.length,")"]})]}),e.jsx("div",{ref:k,className:"max-h-64 space-y-3 overflow-y-auto pr-1",children:d?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(B,{className:"h-5 w-5 animate-spin text-brand-500"})}):r.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:"Noch keine Kommentare — schreib den ersten."}):r.map(y=>e.jsxs("div",{className:"group flex gap-2.5",children:[e.jsx("span",{title:y.authorName??void 0,className:`mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold ${Un(y.authorName)}`,children:Kn(y.authorName)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-semibold text-gray-800 dark:text-gray-200",children:y.authorName??"Unbe
1kannt"}),e.jsx("span",{className:"shrink-0 text-[11px] text-text-muted",children:Bn(y.createdAt)}),y.timecodeSeconds!=null&&e.jsxs(v,{variant:"secondary",size:"sm",onClick:s(()=>o(y.timecodeSeconds),"onClick"),title:"Im Video an diese Stelle springen",className:"bg-brand-50 text-[11px] text-brand-stark hover:bg-brand-100 dark:bg-brand-950/40",children:[e.jsx(rt,{className:"h-3 w-3"}),Wt(y.timecodeSeconds)]})]}),e.jsx("p",{className:"whitespace-pre-line break-words text-sm text-text-strong",children:y.body})]}),y.canDelete&&e.jsx(v,{variant:"ghost",size:"iconXs",onClick:s(()=>void S(y),"onClick"),title:"Löschen",className:"w-6",children:e.jsx(De,{className:"h-3.5 w-3.5"})})]},y.id))}),e.jsxs("div",{className:"mt-3 border-t border-soft pt-3",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(lt,{value:g,onChange:s(y=>f(y.target.value),"onChange"),onKeyDown:s(y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&T()},"onKeyDown"),rows:2,placeholder:"Kommentar schreiben… (⌘/Strg + Enter zum Senden)",className:"min-h-[2.5rem] resize-none"}),e.jsx(v,{size:"icon",onClick:s(()=>void T(),"onClick"),disabled:z||!g.trim(),title:"Senden",className:"w-10",children:z?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(dn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"mt-1.5",children:C?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-50 py-0.5 pl-2 pr-1 text-xs font-medium text-brand-stark dark:bg-brand-950/40",children:[e.jsx(rt,{className:"h-3 w-3"}),"bei ",Wt(j),e.jsx("button",{onClick:s(()=>E(!1),"onClick"),className:"rounded-full px-1 text-brand-400 hover:text-brand-700",title:"Zeitanker entfernen",children:"×"})]}):e.jsxs(v,{variant:"ghost",size:"sm",onClick:I,title:"Aktuelle Videostelle anhängen",children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),"Aktuelle Stelle anhängen"]})})]})]})}s(Pn,"KommentarPanel");const Zn=36e4,Hn=255;function Wn(t){const n=(t??"").trim();if(!n||!/^\d+(:\d{1,2}){0,2}$/.test(n))return null;const o=n.split(":").map(c=>Number(c));let r;if(o.length===1)r=o[0];else if(o.length===2){const[c,d]=o;if(d>=60)return null;r=c*60+d}else{const[c,d,h]=o;if(d>=60||h>=60)return null;r=c*3600+d*60+h}return!Number.isFinite(r)||r<0||r>Zn?null:r}s(Wn,"parseZeitmarke");function ds(t){const n=Math.max(0,Math.floor(t)),o=Math.floor(n/3600),r=Math.floor(n%3600/60),c=n%60,d=s(h=>String(h).padStart(2,"0"),"p");return o>0?`${o}:${d(r)}:${d(c)}`:`${r}:${d(c)}`}s(ds,"formatZeitmarke");function _n(t){return t.map(n=>({zeit:ds(n.startSeconds),titel:n.title}))}s(_n,"zuZeilen");function Gn(t){const n=[],o=new Set;for(let r=0;r<t.length;r++){const{zeit:c,titel:d}=t[r];if(!c.trim()&&!d.trim())continue;const h=Wn(c);if(h==null)return{chapters:[],fehler:`Zeile ${r+1}: ungültige Zeitmarke „${c.trim()}" — erwartet m:ss oder h:mm:ss.`};const g=d.replace(/\s+/g," ").trim().slice(0,Hn);if(!g)return{chapters:[],fehler:`Zeile ${r+1}: Kapiteltitel darf nicht leer sein.`};if(o.has(h))return{chapters:[],fehler:`Zeile ${r+1}: Zeitmarke ${ds(h)} ist doppelt.`};o.add(h),n.push({startSeconds:h,title:g})}return n.sort((r,c)=>r.startSeconds-c.startSeconds),{chapters:n,fehler:null}}s(Gn,"zeilenZuKapiteln");function Xn({videoId:t,chapters:n,onClose:o,onSaved:r}){const[c,d]=l.useState(()=>n.length?_n(n):[{zeit:"0:00",titel:""}]),[h,g]=l.useState(null),[f,C]=l.useState(!1),E=s((N,k)=>{d(A=>A.map((I,T)=>T===N?{...I,...k}:I)),g(null)},"setZeile"),j=s(()=>d(N=>[...N,{zeit:"",titel:""}]),"addZeile"),m=s(N=>d(k=>k.filter((A,I)=>I!==N)),"removeZeile"),z=s(async()=>{const N=Gn(c);if(N.fehler){g(N.fehler);return}C(!0);try{const k=await b.updateChapters(t,N.chapters);r(k),o()}catch(k){V(D(k,"Kapitel konnten nicht gespeichert werden"))}finally{C(!1)}},"save");return e.jsx(xe,{onClose:o,className:"z-[70] flex items-center justify-center p-4",children:e.jsxs("div",{className:"flex max-h-[85vh] w-full max-w-lg flex-col rounded-2xl bg-surface shadow-2xl",onClick:s(N=>N.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-5 py-4",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold text-text-primary",children:[e.jsx(ns,{className:"h-5 w-5 text-brand-600"}),"Kapitel bearbeiten"]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:o,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[e.jsx("p",{className:"mb-3 text-xs text-text-soft",children:"Zeitmarke als m:ss (z. B. 1:30) oder h:mm:ss. Zeilen ohne Inhalt werden ignoriert; eine leere Liste entfernt alle Kapitel."}),e.jsx("div",{className:"space-y-2",children:c.map((N,k)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{size:"sm",type:"text",value:N.zeit,onChange:s(A=>E(k,{zeit:A.target.value}),"onChange"),placeholder:"m:ss",className:"w-20 text-center font-mono"}),e.jsx(Ae,{type:"text",value:N.titel,onChange:s(A=>E(k,{titel:A.target.value}),"onChange"),placeholder:"Kapiteltitel",className:"flex-1"}),e.jsx(v,{variant:"secondary",size:"icon",onClick:s(()=>m(k),"onClick"),title:"Zeile entfernen","aria-label":"Zeile entfernen",children:e.jsx(De,{className:"h-4 w-4"})})]},k))}),e.jsxs(v,{variant:"secondary",size:"sm",onClick:j,className:"mt-3 border-dashed",children:[e.jsx(as,{className:"h-3.5 w-3.5"}),"Kapitel hinzufügen"]}),h&&e.jsx("p",{className:"mt-3 rounded-lg bg-red-50 px-3 py-2 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300",children:h})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-default px-5 py-3",children:[e.jsx(v,{variant:"ghost",onClick:o,children:"Abbrechen"}),e.jsxs(v,{onClick:z,disabled:f,children:[f?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(ye,{className:"h-4 w-4"}),"Speichern"]})]})]})})}s(Xn,"KapitelEditorModal");function _t(t){const n=Math.max(0,Math.floor(t)),o=Math.floor(n/3600),r=M
1ath.floor(n%3600/60),c=n%60,d=s(h=>String(h).padStart(2,"0"),"p");return o>0?`${o}:${d(r)}:${d(c)}`:`${r}:${d(c)}`}s(_t,"fmt");function Gt({videoId:t,onSeek:n,canEdit:o=!1}){const[r,c]=l.useState(null),[d,h]=l.useState(!0),[g,f]=l.useState(!1),C=l.useCallback(async()=>{h(!0);try{c(await b.getTranscript(t))}catch(j){V(D(j,"Transkript konnte nicht geladen werden")),c(null)}finally{h(!1)}},[t]);if(l.useEffect(()=>{C()},[C]),l.useEffect(()=>{if((r==null?void 0:r.status)!=="ausstehend"&&(r==null?void 0:r.status)!=="verarbeitung")return;const j=setInterval(()=>void C(),15e3);return()=>clearInterval(j)},[r==null?void 0:r.status,C]),d&&!r)return e.jsx("div",{className:"mt-3 flex justify-center rounded-2xl bg-surface py-6",children:e.jsx(B,{className:"h-5 w-5 animate-spin text-brand-500"})});if(!r||r.status==null||r.status==="deaktiviert")return null;const E=r.status==="ausstehend"||r.status==="verarbeitung";return e.jsxs("div",{className:"mt-3 rounded-2xl bg-surface p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-semibold text-text-primary",children:[e.jsx(un,{className:"h-4 w-4 text-brand-600"}),"Transkript & Kapitel"]}),o&&r.status==="fertig"&&e.jsxs(v,{variant:"secondary",size:"sm",onClick:s(()=>f(!0),"onClick"),children:[e.jsx(jt,{className:"h-3 w-3"}),"Kapitel bearbeiten"]})]}),E&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-subtle-soft px-3 py-2 text-sm text-text-soft",children:[e.jsx(B,{className:"h-4 w-4 animate-spin text-brand-500"}),"Das Video wird gerade transkribiert – Untertitel und Kapitel erscheinen in Kürze."]}),r.status==="fehler"&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-subtle-soft px-3 py-2 text-sm text-text-soft",children:[e.jsx(ct,{className:"h-4 w-4 text-amber-500"}),"Für dieses Video konnte kein Transkript erstellt werden."]}),r.status==="fertig"&&e.jsxs(e.Fragment,{children:[r.chapters.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-semibold text-text-soft",children:[e.jsx(ns,{className:"h-3.5 w-3.5"}),"Kapitel"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.chapters.map((j,m)=>e.jsxs(v,{variant:"secondary",size:"sm",onClick:s(()=>n(j.startSeconds),"onClick"),title:`Springe zu ${_t(j.startSeconds)}`,className:"max-w-full rounded-full",children:[e.jsx(rt,{className:"h-3 w-3 shrink-0 text-brand-500"}),e.jsx("span",{className:"shrink-0 font-medium text-brand",children:_t(j.startSeconds)}),e.jsx("span",{className:"truncate",children:j.title})]},m))})]}),r.text?e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-lg bg-subtle-soft p-3 text-sm leading-relaxed text-text-strong",children:e.jsx("p",{className:"whitespace-pre-line break-words",children:r.text})}):e.jsx("p",{className:"text-sm text-text-muted",children:"Kein Transkripttext verfügbar."})]}),g&&e.jsx(Xn,{videoId:t,chapters:r.chapters,onClose:s(()=>f(!1),"onClose"),onSaved:s(j=>c(j),"onSaved")})]})}s(Gt,"TranskriptPanel");function qn(t){const n=Math.max(0,Math.round(t)),o=Math.floor(n/3600),r=Math.floor(n%3600/60);return o>0?`${o} h ${r} min`:r>0?`${r} min`:`${n} s`}s(qn,"formatDuration");function Qn(t){if(t==null)return"—";const n=Math.max(0,Math.round(t));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}s(Qn,"formatShort");function me(t){return t.toLocaleString("de-DE")}s(me,"fmtNum");function Jn({onClose:t}){const[n,o]=l.useState(null),[r,c]=l.useState(!0),[d,h]=l.useState(!1);l.useEffect(()=>{let f=!1;return b.getStats().then(C=>{f||o(C)}).catch(()=>{f||h(!0)}).finally(()=>{f||c(!1)}),()=>{f=!0}},[]);const g=n?[{icon:e.jsx(He,{className:"h-4 w-4"}),label:"Videos",value:me(n.videoCount)},{icon:e.jsx(vt,{className:"h-4 w-4"}),label:"Aufrufe gesamt",value:me(n.totalViews)},{icon:e.jsx(hn,{className:"h-4 w-4"}),label:"Ø Aufrufe / Video",value:n.avgViewsPerVideo.toLocaleString("de-DE")},{icon:e.jsx(mn,{className:"h-4 w-4"}),label:"Gesamtdauer",value:qn(n.totalDurationSeconds)},{icon:e.jsx(wt,{className:"h-4 w-4"}),label:"Favoriten",value:me(n.totalFavorites)},{icon:e.jsx(ss,{className:"h-4 w-4"}),label:"Kommentare",value:me(n.totalComments)},{icon:e.jsx(xn,{className:"h-4 w-4"}),label:"Transkribiert",value:`${me(n.transcribedCount)} / ${me(n.videoCount)}`},{icon:e.jsx(gt,{className:"h-4 w-4"}),label:"Aktive Links",value:me(n.activePublicLinks)}]:[];return e.jsx(xe,{onClose:t,className:"z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-h-[90vh] w-full max-w-2xl overflow-y-auto rounded-2xl bg-surface shadow-2xl",onClick:s(f=>f.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"sticky top-0 flex items-center justify-between border-b border-default bg-surface px-5 py-4",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold text-text-primary",children:[e.jsx(rs,{className:"h-5 w-5 text-brand-600"}),"Statistik",n&&e.jsx("span",{className:"rounded-full bg-subtle px-2 py-0.5 text-xs font-medium text-text-soft",children:n.scope==="instanz"?"instanzweit":"meine Videos"})]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:t,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"p-5",children:r?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(B,{className:"h-7 w-7 animate-spin text-brand-500"})}):d||!n?e.jsx("p",{className:"py-12 text-center text-sm text-text-soft",children:"Statistik konnte nicht geladen werden."}):n.videoCount===0?e.jsx("p",{className:"py-12 text-center text-sm text-text-soft",children:"Noch keine Videos — sobald du Videos hochlädst oder aufnimmst, er
1scheinen hier die Auswertungen."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:g.map(f=>e.jsxs("div",{className:"rounded-xl border border-default bg-subtle-soft p-3",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-text-soft",children:[f.icon,f.label]}),e.jsx("span",{className:"mt-1 block text-xl font-bold text-text-primary",children:f.value})]},f.label))}),(n.processingCount>0||n.errorCount>0)&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[n.processingCount>0&&e.jsxs("span",{className:"rounded-full bg-amber-100 px-2.5 py-1 font-medium text-amber-700 dark:bg-amber-950/40 dark:text-amber-300",children:[me(n.processingCount)," in Verarbeitung"]}),n.errorCount>0&&e.jsxs("span",{className:"rounded-full bg-red-100 px-2.5 py-1 font-medium text-red-700 dark:bg-red-950/40 dark:text-red-300",children:[me(n.errorCount)," fehlgeschlagen"]})]}),n.topVideos.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-semibold text-text-strong",children:"Meistgesehene Videos"}),e.jsx("div",{className:"space-y-1",children:n.topVideos.map((f,C)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-subtle-soft px-3 py-2",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-brand-100 text-xs font-bold text-brand-stark dark:bg-brand-950/40",children:C+1}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:f.title}),e.jsx("span",{className:"shrink-0 text-xs text-text-muted",children:Qn(f.durationSeconds)}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-sm font-medium text-text-strong",children:[e.jsx(vt,{className:"h-3.5 w-3.5 text-text-muted"}),me(f.viewCount)]})]},f.id))})]})]})})]})})}s(Jn,"StatistikModal");function Yn(t){const n=Math.max(0,Math.floor(t));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}s(Yn,"formatClock");function ea({video:t,onClose:n,onApplied:o,onVorschlagVerbraucht:r}){const[c,d]=l.useState(null),[h,g]=l.useState(!0),[f,C]=l.useState(null),[E,j]=l.useState(!1),[m,z]=l.useState(!1),[N,k]=l.useState(!0),[A,I]=l.useState(!0),[T,S]=l.useState(!0),y=s(M=>{d(M),k(!!M.title&&M.title!==t.title),I(!!M.description&&M.description!==(t.description??"")),S(M.chapters.length>0)},"uebernehmenVorschlag"),_=s(M=>(g(!0),C(null),b.kiVorschlag(t.id,{neu:M}).then(y).catch(U=>C(D(U,"KI-Vorschlag fehlgeschlagen"))).finally(()=>g(!1))),"laden");l.useEffect(()=>{let M=!1;return b.kiVorschlag(t.id).then(U=>{M||(d(U),k(!!U.title&&U.title!==t.title),I(!!U.description&&U.description!==(t.description??"")),S(U.chapters.length>0))}).catch(U=>{M||C(D(U,"KI-Vorschlag fehlgeschlagen"))}).finally(()=>{M||g(!1)}),()=>{M=!0}},[t.id,t.title,t.description]);const P=s(async()=>{z(!0);try{await b.kiVorschlagVerwerfen(t.id),r==null||r()}catch{}finally{z(!1),n()}},"verwerfen"),ie=s(async()=>{if(!c)return;const M=N&&!!c.title,U=A&&!!c.description,he=T&&c.chapters.length>0;if(!M&&!U&&!he){n();return}j(!0);try{(M||U)&&await b.update(t.id,{...M?{title:c.title}:{},...U?{description:c.description}:{}}),he&&await b.updateChapters(t.id,c.chapters),await b.kiVorschlagVerwerfen(t.id).catch(()=>{}),r==null||r(),o(),n()}catch(se){V(D(se,"Übernahme fehlgeschlagen"))}finally{j(!1)}},"apply"),ue=!c||(!N||!c.title)&&(!A||!c.description)&&(!T||!c.chapters.length);return e.jsx(xe,{onClose:n,className:"z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-h-[90vh] w-full max-w-2xl overflow-y-auto rounded-2xl bg-surface shadow-2xl",onClick:s(M=>M.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"sticky top-0 flex items-center justify-between border-b border-default bg-surface px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold text-text-primary",children:[e.jsx(We,{className:"h-5 w-5 text-brand-600"}),"KI-Videoprojekt"]}),e.jsx("p",{className:"truncate text-sm text-text-soft",children:t.title})]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:n,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"p-5",children:h?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-14",children:[e.jsx(B,{className:"h-7 w-7 animate-spin text-brand-500"}),e.jsx("p",{className:"text-sm text-text-soft",children:"Transkript wird analysiert — die KI formuliert Titel, Beschreibung und Kapitel …"})]}):f?e.jsx("p",{className:"py-12 text-center text-sm text-text-soft",children:f}):c?e.jsxs("div",{className:"space-y-4",children:[c.createdAt&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-text-soft",children:[e.jsx(We,{className:"h-3.5 w-3.5 text-brand-500"}),"Automatisch nach der Transkription erstellt (",new Date(c.createdAt).toLocaleStr
1ing("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})," Uhr",")"]}),c.title&&e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-default p-3",children:[e.jsx(mt,{checked:N,onChange:s(M=>k(M.target.checked),"onChange"),className:"mt-1"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-text-strong",children:"Titel"}),e.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-text-muted line-through",children:t.title}),e.jsx(fn,{className:"h-3.5 w-3.5 shrink-0 text-text-muted"}),e.jsx("span",{className:"font-medium text-text-primary",children:c.title})]})]})]}),c.description&&e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-default p-3",children:[e.jsx(mt,{checked:A,onChange:s(M=>I(M.target.checked),"onChange"),className:"mt-1"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-text-strong",children:"Beschreibung"}),t.description&&e.jsx("span",{className:"mt-1 block text-xs text-text-muted line-through",children:t.description}),e.jsx("span",{className:"mt-1 block whitespace-pre-line text-sm text-text-primary",children:c.description})]})]}),c.chapters.length>0&&e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-default p-3",children:[e.jsx(mt,{checked:T,onChange:s(M=>S(M.target.checked),"onChange"),className:"mt-1"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-text-strong",children:[e.jsx(pn,{className:"h-4 w-4"}),"Kapiteltitel (",c.chapters.length,")"]}),e.jsx("span",{className:"mt-2 block space-y-1",children:c.chapters.map(M=>e.jsxs("span",{className:"flex items-baseline gap-2 text-sm text-text-primary",children:[e.jsx("span",{className:"shrink-0 font-mono text-xs text-text-muted",children:Yn(M.startSeconds)}),e.jsx("span",{className:"min-w-0",children:M.title})]},M.startSeconds))})]})]}),!c.title&&!c.description&&!c.chapters.length&&e.jsx("p",{className:"py-8 text-center text-sm text-text-soft",children:"Die KI hat keinen brauchbaren Vorschlag geliefert."})]}):e.jsx("p",{className:"py-12 text-center text-sm text-text-soft",children:"Die KI hat keinen brauchbaren Vorschlag geliefert."})}),!h&&!f&&c&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-default px-5 py-3",children:[e.jsxs(v,{variant:"secondary",onClick:s(()=>void _(!0),"onClick"),disabled:E||m,title:"Gespeicherten Vorschlag ignorieren und frisch generieren",children:[e.jsx(gn,{className:"h-4 w-4"}),"Neu generieren"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"ghost",onClick:s(()=>void P(),"onClick"),disabled:E||m,children:[m&&e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Verwerfen"]}),e.jsxs(v,{onClick:ie,disabled:E||m||ue,children:[E?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(ye,{className:"h-4 w-4"}),"Auswahl übernehmen"]})]})]})]})})}s(ea,"KiProjektModal");function ta({video:t,onClose:n,onSaved:o}){const[r,c]=l.useState(0),[d,h]=l.useState(null),[g,f]=l.useState(!1),[C,E]=l.useState(!0),[j,m]=l.useState(null),[z,N]=l.useState(()=>Date.now()),k=l.useRef(null);l.useEffect(()=>{let T=!1;return b.vorschaubildKandidaten(t.id).then(S=>{T||(c(S.anzahl),h(S.aktivIndex),f(S.eigenesBild))}).catch(S=>V(D(S,"Vorschaubilder konnten nicht geladen werden"))).finally(()=>!T&&E(!1)),()=>{T=!0}},[t.id]);const A=s(async T=>{m(T);try{const S=await b.waehleVorschaubild(t.id,T);h(T),f(!1),N(Date.now()),o(S),it("Vorschaubild geändert")}catch(S){V(D(S,"Vorschaubild konnte nicht gesetzt werden"))}finally{m(null)}},"waehle"),I=s(async T=>{m("upload");try{const S=await b.ladeVorschaubildHoch(t.id,T);h(null),f(!0),N(Date.now()),o(S),it("Vorschaubild hochgeladen")}catch(S){V(D(S,"Bild konnte nicht hochgeladen werden"))}finally{m(null),k.current&&(k.current.value="")}},"ladeHoch");return e.jsx(xe,{onClose:n,className:"z-[70] flex items-center justify-center p-4",children:e.jsxs("div",{className:"flex max-h-[85vh] w-full max-w-2xl flex-col rounded-2xl bg-surface shadow-2xl",onClick:s(T=>T.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-5 py-4",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold text-text-primary",children:[e.jsx(is,{className:"h-5 w-5 text-brand-600"}
1),"Vorschaubild wählen"]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:n,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5",children:C?e.jsx("div",{className:"flex items-center justify-center py-10 text-text-muted",children:e.jsx(B,{className:"h-6 w-6 animate-spin"})}):e.jsxs(e.Fragment,{children:[r>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-3 text-xs text-text-soft",children:"Standbilder aus verschiedenen Stellen des Videos. Klick übernimmt das Bild."}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:Array.from({length:r},(T,S)=>{const y=d===S;return e.jsxs("button",{onClick:s(()=>A(S),"onClick"),disabled:j!==null,"aria-pressed":y,className:`group relative aspect-video overflow-hidden rounded-xl border-2 transition ${y?"border-brand-500 ring-2 ring-brand-500/30":"border-default hover:border-brand-400"} disabled:opacity-60`,children:[e.jsx("img",{src:`${b.mediaUrl(t.id,`kandidat:${S}`)}&c=${z}`,alt:`Vorschlag ${S+1}`,className:"h-full w-full bg-gray-900 object-cover"}),y&&e.jsx("span",{className:"absolute right-2 top-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-brand-600 text-white",children:e.jsx(ye,{className:"h-4 w-4"})}),j===S&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(B,{className:"h-5 w-5 animate-spin text-white"})})]},S)})})]}):e.jsx("p",{className:"mb-3 text-xs text-text-soft",children:"Für dieses Video gibt es keine automatischen Vorschläge — es wurde hochgeladen, bevor es diese Funktion gab. Du kannst ein eigenes Bild verwenden."}),e.jsxs("div",{className:"mt-5 border-t border-default pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(v,{variant:"secondary",onClick:s(()=>{var T;return(T=k.current)==null?void 0:T.click()},"onClick"),disabled:j!==null,children:[j==="upload"?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(ls,{className:"h-4 w-4"}),"Eigenes Bild hochladen"]}),g&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-brand-stark",children:[e.jsx(ye,{className:"h-4 w-4"}),"Eigenes Bild aktiv"]})]}),e.jsx("p",{className:"mt-2 text-xs text-text-soft",children:"JPG, PNG oder WebP, höchstens 8 MB. Das Bild wird auf Vorschaugrösse gebracht."}),e.jsx("input",{ref:k,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:s(T=>{var y;const S=(y=T.target.files)==null?void 0:y[0];S&&I(S)},"onChange")})]})]})}),e.jsx("div",{className:"flex justify-end border-t border-default px-5 py-4",children:e.jsx(v,{onClick:n,children:"Fertig"})})]})})}s(ta,"VorschaubildModal");function sa({video:t,onClose:n,onGespeichert:o}){const[r,c]=l.useState(t.title),[d,h]=l.useState(t.description??""),[g,f]=l.useState(!1),C=r.trim(),E=C===t.title&&d.trim()===(t.description??"").trim(),j=s(async()=>{if(!C){V("Der Titel darf nicht leer sein.");return}f(!0);try{await b.update(t.id,{title:C,description:d.trim()||null}),it("Titel gespeichert"),o(),n()}catch(m){V(D(m,"Speichern fehlgeschlagen"))}finally{f(!1)}},"speichern");return e.jsx(xe,{onClose:n,className:"z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl bg-surface p-5 shadow-xl",onClick:s(m=>m.stopPropagation(),"onClick"),role:"dialog","aria-modal":"true","aria-labelledby":"videothek-titel-bearbeiten",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{id:"videothek-titel-bearbeiten",className:"text-base font-semibold text-text-primary",children:"Video bearbeiten"}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:n,"aria-label":"Schließen",children:e.jsx(de,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"videothek-titel",className:"mb-1 block text-xs font-medium text-text-secondary",children:"Titel *"}),e.jsx(Ae,{id:"videothek-titel",value:r,onChange:s(m=>c(m.target.value),"onChange"),maxLength:255,autoFocus:!0,onKeyDown:s(m=>{m.key==="Enter"&&j()},"onKeyDown")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"videothek-beschreibung",className:"mb-1 block text-xs font-medium text-text-secondary",children:"Beschreibung"}),e.jsx(lt,{id:"videothek-beschreibung",value:d,onChange:s(m=>h(m.target.value),"onChange"),maxLength:5e3,rows:3})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(v,{variant:"secondary",size:"sm",onClick:n,children:"Abbrechen"}),e.jsxs(v,{size:"sm",onClick:s(()=>void j(),"onClick"),disabled:g||!C||E,children:[g&&e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),"Speichern"]})]})]})})}s(sa,"TitelBearbeitenModal");function na({ordner:t,anzahl:n,aktuellerOrdner:o,onWaehle:r,onClose:c}){const d=[{id:null,name:"Ohne Ordner"},...[...t].sort((h,g)=>h.name.localeCompare(g.name,"de")).map(h=>({id:h.id,name:h.name}))];return e.jsx(xe,{onClose:c,label:"In Ordner verschieben",className:"z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"flex max-h-[70vh] w-full max-w-md flex-col overflow-hidden rounded-xl border border-default bg-surface shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-4 py-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-text-primary",children:[n===1?"Video":`${n} Videos`," verschieben nach …"]}),e.jsx(v,{variant:"ghost",size:"iconXs",onClick:c,"aria-label":"Schließen",children:e.jsx(de,{"aria-hidden":!0})})]}),e.jsx("ul",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:d.map(h=>{const g=o!==void 0&&h.id===o,f=h.id===null?bn:cs;return e.jsx("li",{children:e.jsxs(v,{variant:"ghost",fullWidth:!0,disabled:g,onClick:s(()=>r(h.id),"onClick"),className:"justify-start font-normal text-text-primary",leftIcon:e.jsx(f,{className:"text-text-muted","aria-hidden":!0}),children:[e.jsx("span",{className:"min-w-0 truncate",children:h.name}),g&&e.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(hier)"})]})},h.id??"ohne")})}),t.length===0&&e.jsx("p",{className:"border-t border-default px-4 py-3 text-xs text-text-muted",children:'Du hast noch keine Ordner. Leg links unter „Ordner" einen an.'})]})})}s(na,"OrdnerWahlModal");function aa(t){return t?{text:Dt,zielPfad:"/mediathek",knopfText:"Zur Mediathek"}:{text:Dt}}s(aa,"nichtVideoHinweis");function ra(t){return t.type.startsWith("video/")}s(ra,"istVideoDatei");function us(t){return t.filter(n=>n.istMeins)}s(us,"meine");function hs(t){return t.filter(n=>!n.istMeins&&(n.istInstanzweit||n.istMitMirGeteilt))}s(hs,"fuerMichFreigegeben");function ms(t){return t.filter(n=>n.isFavorite)}s(ms,"favoriten");function ia(t,n){return t.folderId==null||!n.has(t.folderId)}s(ia,"liegtOhneMeinenOrdner");function la(t,n){return t.filter(o=>ia(o,n))}s(la,"ohneOrdner");function ca(t,n){return t.filter(o=>o.folderId===n)}s(ca,"imOrdner");const xs="videothek:recent",oa=8;function fs(){try{const t=localStorage.getItem(xs),n=t?JSON.parse(t):[];return Array.isArray(n)?n.filter(o=>typeof o=="number"):[]}catch{return[]}}s(fs,"ladeZuletztAngesehen");function da(t){const n=[t,...fs().filter(o=>o!==t)].slice(0,oa);try{localStorage.setItem(xs,JSON.stringify(n))}catch{}return n}s(da,"merkeZuletztAngesehen");function ps(t,n){const o=new Map(t.map(r=>[r.id,r]));return n.map(r=>o.get(r)).filter(r=>!!r&&r.status==="fertig")}s(ps,"zuletztAngesehen");function ua(t,n,o=[]){switch(n){case"meine":return us(t);case"fuer-mich":return hs(t);case"favoriten":return ms(t);case"zuletzt":return ps(t,o);case"alle":default:return[...t]}}s(ua,"filtereBereich");function ha(t,n=[]){return{alle:t.length,meine:us(t).length,"fuer-mich":hs(t).length,favoriten:ms(t).length,zuletzt:ps(t,n).length}}
1s(ha,"bereichsZaehler");function ma(t,n){const o=new Map([...n].map(c=>[c,0]));let r=0;for(const c of t)c.folderId==null||!n.has(c.folderId)?r+=1:o.set(c.folderId,(o.get(c.folderId)??0)+1);return{ohneOrdner:r,jeOrdner:o}}s(ma,"ordnerZaehler");const Xt=[{id:"neueste",satz:"Neueste zuerst"},{id:"aelteste",satz:"Älteste zuerst"},{id:"titel",satz:"Titel A–Z"},{id:"meistgesehen",satz:"Meistgesehen zuerst"}];function xa(t,n){const o=[...t];return o.sort((r,c)=>{switch(n){case"aelteste":return r.createdAt.localeCompare(c.createdAt);case"titel":return r.title.localeCompare(c.title,"de");case"meistgesehen":return(c.viewCount??0)-(r.viewCount??0)||c.createdAt.localeCompare(r.createdAt);case"neueste":default:return c.createdAt.localeCompare(r.createdAt)}}),o}s(xa,"sortiereVideos");function fa(t,n){const o=n.trim().toLowerCase();return o?t.filter(r=>{var c,d;return r.title.toLowerCase().includes(o)||(((c=r.description)==null?void 0:c.toLowerCase().includes(o))??!1)||(((d=r.uploaderName)==null?void 0:d.toLowerCase().includes(o))??!1)}):[...t]}s(fa,"sucheInVideos");function qt(t){if(!t||t<=0)return null;const n=Math.floor(t/3600),o=Math.floor(t%3600/60),r=Math.floor(t%60),c=s(d=>String(d).padStart(2,"0"),"pad");return n>0?`${n}:${c(o)}:${c(r)}`:`${o}:${c(r)}`}s(qt,"formatDauer");function kt(t){const n=new Date(t);return Number.isNaN(n.getTime())?"—":n.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}s(kt,"datumDe");function pa(t){if(t.status==="verarbeitung")return"Wird verarbeitet …";if(t.status==="fehler")return"Verarbeitung fehlgeschlagen";const n=kt(t.createdAt);return t.uploaderName?`${t.uploaderName} · ${n}`:n}s(pa,"metaZeile");function ga(t){if(t.visibility==="instanz")return"Für alle in der Instanz";const n=t.shareCount??0;return n>0?n===1?"An 1 Person freigegeben":`An ${n} Personen freigegeben`:!t.istMeins&&t.istMitMirGeteilt?"Dir freigegeben":"Privat"}s(ga,"freigabeStand");const ba=["alle","meine","fuer-mich","favoriten","zuletzt"],Qt="alle";function ja(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`:""}s(ja,"formatSize");function va(t){const n=Math.max(0,Math.floor(t));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}s(va,"formatTimecode");function Jt(t){var n,o;return typeof navigator>"u"?!1:t==="bildschirm"?!!((n=navigator.mediaDevices)!=null&&n.getDisplayMedia):!!((o=navigator.mediaDevices)!=null&&o.getUserMedia)}s(Jt,"kannAufnehmen");function Ze(t){return t.status==="fertig"&&t.mp4Status==="verarbeitung"}s(Ze,"mp4WirdErstellt");const Yt="MP4 wird erstellt – gleich verfügbar";function es({v:t,version:n}){return t.status==="verarbeitung"?e.jsxs("span",{className:"flex flex-col items-center gap-2 text-text-muted",children:[e.jsx(B,{className:"h-7 w-7 animate-spin text-brand","aria-hidden":!0}),e.jsx("span",{className:"text-xs",children:"Wird verarbeitet …"})]}):t.status==="fehler"?e.jsxs("span",{className:"flex flex-col items-center gap-2 text-danger",title:t.errorMessage??void 0,children:[e.jsx(ct,{className:"h-7 w-7","aria-hidden":!0}),e.jsx("span",{className:"text-xs",children:"Verarbeitung fehlgeschlagen"})]}):t.hasThumbnail?e.jsx("img",{src:`${b.mediaUrl(t.id,"thumbnail")}&c=${n}`,alt:"",loading:"lazy",className:"h-full w-full object-cover"}):e.jsx(He,{className:"h-10 w-10","aria-hidden":!0})}s(es,"VideoPoster");function Aa(){const t=_s(),n=Zs(),{can:o}=Gs(),{isEnabled:r}=Xs(),c=qs(a=>{var i;return(i=a.user)==null?void 0:i.role})??"angemeldet",d=Qs(c,o("dms","lesen"),r("dmsDrives")),[h,g]=l.useState([]),[f,C]=l.useState(!0),[E,j]=l.useState(!1),[m,z]=l.useState(null),[N,k]=l.useState(null),[A,I]=l.useState(null),[T,S]=l.useState(null),[y,_]=l.useState({}),[P,ie]=l.useState(""),[ue,M]=l.useState(Xt[0].id),[U,he]=l.useState("kacheln"),[se,J]=l.useState(new Set),[Z,H]=l.useState([]),[Y,W]=l.useState(null),[G,X]=l.useState(null),fe=l.useMemo(()=>f||E?null:Z.map(a=>String(a.id)),[f,E,Z]),{aktiv:$,onWechsel:le}=wn(Qt,ba,fe),[ve,ce]=l.useState(!1),[x,K]=l.useState(null),[ee,Se]=l.useState(null),[we,ke]=l.useState(""),[Le,Ce]=l.useState(null),[_e,Ge]=l.useState(""),[Me,Xe]=l.useState("privat"),[oe,qe]=l.useState(!1),[Fe,Re]=l.useState(0),Te=l.useRef(null),[ze,Oe]=l.useState(()=>fs()),p=l.useRef(null),[w,L]=l.useState(!1),[F,R]=l.useState(null),[te,q]=l.useState(!1),[ne,Q]=l.useState(null),[pe,Ve]=l.useState(null),[ge,ot]=l.useState(!1),[Nt,gs]=l.useState(!1),[Ee,dt]=l.useState(null),[yt,St]=l.useState(!1),$e=l.useRef(null),Ke=l.useCallback(a=>{z(a),Oe(da(a.id))},[]),ut=l.useCallback(a=>{const i=p.current;i&&(i.currentTime=a,i.play().catch(()=>{}))},[]),bs=l.useCallback(async a=>{const i=a.trim();if(!(i.length<2)){St(!0);try{dt(await b.search(i))}catch(u){V(D(u,"Suche fehlgeschlagen"))}finally{St(!1)}}},[]),js=l.useCallback(async a=>{try{const i=await b.getOne(a.videoId);$e.current=a.timecodeSeconds??null,Ke(i)}catch(i){V(D(i,"Video konnte nicht geöffnet werden"))}},[Ke]);l.useEffect(()=>{if(q(!1),!(m!=null&&m.isOwner)||!m.hasTranscript)return;let a=!1;return b.kiVorschlagStatus(m.id).then(i=>{a||q(i.vorhanden)}).catch(()=>{}),()=>{a=!0}},[m]),l.useEffect(()=>{if(!(m!=null&&m.hasTranscript)){Q(null);return}let a=null,i=!1;return b.getSubtitles(m.id).then(u=>{i||!u||(a=URL.createObjectURL(new Blob([u],{type:"text/vtt"})),Q(a))}).catch(()=>V("Die Untertitel konnten nicht geladen werden")),()=>{i=!0,a&&URL.revokeObjectURL(a),Q(null)}},[m]);const vs=s(()=>Lt('Öffne ein eigenes Video mit fertigem Transkript und klicke im Player auf „Mit KI verbessern" — die KI schlägt Titel, Beschreibung und Kapitel vor.'),"kiHint"),ws=s(a=>{Ce(null),Se(a),ke(a.name.replace(/\.[^.]+$/,"")),K(Ie),ce(!0)},"onRecorded"),be=l.useCallback(async()=>{C(!0);try{const[a,i]=await Promise.all([b.listAlle(),b.listFolders()]);g(a),H(i),j(!1)}catch{j(!0)}finally{C(!1)}},[]);l.useEffect(()=>{be()},[be]);const Ct=l.useCallback(async()=>{try{g(await b.listAlle())}catch{}},[]);l.useEffect(()=>{const a=h.some(u=>u.status==="verarbeitung");if(!a&&!h.some(Ze))return;const i=setInterval(()=>void Ct(),a?4e3:15e3);return()=>clearInterval(i)},[h,Ct]);const Qe=(m==null?void 0:m.id)??null;l.useEffect(()=>{if(Ve(null),ot(!1),Qe===null)return;let a=!1;return b.getStreamToken(Qe).then(({token:i})=>
1{a||Ve(b.streamUrl(Qe,i))}).catch(i=>{a||(ot(!0),V(D(i,"Video konnte nicht geladen werden.")))}),()=>{a=!0}},[Qe]),l.useEffect(()=>{if(!m)return;const a=s(i=>{const u=p.current;switch(i.key){case"Escape":z(null);break;case" ":case"k":i.preventDefault(),u&&(u.paused?u.play():u.pause());break;case"ArrowLeft":u&&(u.currentTime=Math.max(0,u.currentTime-5));break;case"ArrowRight":u&&(u.currentTime=Math.min(u.duration||1/0,u.currentTime+5));break;case"m":u&&(u.muted=!u.muted);break;case"f":u!=null&&u.requestFullscreen&&u.requestFullscreen().catch(()=>{});break}},"onKey");return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[m]);const Ue=l.useMemo(()=>new Set(Z.map(a=>a.id)),[Z]),Be=l.useMemo(()=>ha(h,ze),[h,ze]),ht=l.useMemo(()=>ma(h,Ue),[h,Ue]),Mt=$.ordner===null&&$.bereich==="zuletzt",ks=l.useMemo(()=>{let a;$.ordner===st?a=la(h,Ue):$.ordner!==null?a=ca(h,Number($.ordner)):a=ua(h,$.bereich,ze);const i=Mt?a:xa(a,ue);return fa(i,P)},[h,$,Ue,ze,Mt,ue,P]),je=l.useMemo(()=>new Map(h.map(a=>[String(a.id),a])),[h]),Ns=[{id:"alle",name:"Alle Videos",icon:jn,zaehler:f?void 0:Be.alle},{id:"meine",name:"Meine Videos",icon:vn,zaehler:f?void 0:Be.meine},{id:"fuer-mich",name:"Für mich freigegeben",icon:xt,zaehler:f?void 0:Be["fuer-mich"]},{id:"favoriten",name:"Favoriten",icon:wt,zaehler:f?void 0:Be.favoriten},{id:"zuletzt",name:"Zuletzt angesehen",icon:vt,zaehler:f?void 0:Be.zuletzt}],ys=l.useMemo(()=>[...Z].sort((a,i)=>a.name.localeCompare(i.name,"de")).map(a=>({id:String(a.id),name:a.name,zaehler:f?void 0:ht.jeOrdner.get(a.id)??0})),[Z,ht,f]),Ie=$.ordner&&$.ordner!==st?Z.find(a=>String(a.id)===$.ordner)??null:null,Tt=s(a=>{if(a){if(!ra(a)){const{text:i,zielPfad:u,knopfText:O}=aa(d);Ys.error(i,{action:u&&O?{label:O,onClick:s(()=>n(u),"onClick")}:void 0});return}Se(a),we||ke(a.name.replace(/\.[^.]+$/,"")),K(Ie),ce(!0)}},"pickFile"),Je=s(()=>{ce(!1),Se(null),ke(""),Ge(""),Xe("privat"),Re(0),K(null),Te.current&&(Te.current.value="")},"resetUpload"),Ss=s(async()=>{if(!(!ee||!we.trim())){qe(!0),Re(0);try{const a=await b.upload(ee,{title:we.trim(),description:_e.trim()||void 0,visibility:Me},Re),i=x;if(Je(),i)try{await b.moveToFolder(a.id,i.id)}catch(u){V(`Hochgeladen, aber nicht in „${i.name}“ abgelegt: ${D(u)}`),le(ft($,"meine"))}else le(ft($,"meine"));await be()}catch(a){V(D(a,"Upload fehlgeschlagen"))}finally{qe(!1)}}},"doUpload"),zt=s(async a=>{const i=a.filter(u=>u.canManage);if(i.length!==0&&await t({title:i.length===1?"Video wirklich löschen?":`${i.length} Videos wirklich löschen?`,description:i.length===1?`„${i[0].title}“ wird unwiderruflich entfernt.`:"Die Videos werden unwiderruflich entfernt.",variant:"danger",confirmLabel:"Löschen"}))try{for(const u of i)await b.remove(u.id)}catch(u){V(D(u,"Löschen fehlgeschlagen"))}finally{await be()}},"deleteVideos"),Vt=s(async a=>{try{const{token:i}=await b.getStreamToken(a.id),u=document.createElement("a");u.href=b.downloadUrl(a.id,i),u.download="",document.body.appendChild(u),u.click(),u.remove()}catch(i){V(D(i,"Download konnte nicht gestartet werden"))}},"downloadVideo"),Ye=s(async(a,i)=>{const u=i?"instanz":"privat";J(O=>new Set(O).add(a.id));try{await b.share(a.id,{visibility:u}),g(O=>O.map(ae=>ae.id===a.id?{...ae,visibility:u,istInstanzweit:i}:ae)),z(O=>O&&O.id===a.id?{...O,visibility:u}:O),it(i?`„${a.title}“ steht jetzt in der Videothek und ist für alle sichtbar.`:`„${a.title}“ ist wieder privat.`)}catch(O){V(D(O,"Sichtbarkeit konnte nicht geändert werden"))}finally{J(O=>{const ae=new Set(O);return ae.delete(a.id),ae})}},"setInVideothek"),Cs=s(async a=>{g(i=>i.map(u=>u.id===a.id?{...u,isFavorite:!u.isFavorite}:u));try{await b.setFavorite(a.id,!a.isFavorite)}catch(i){g(u=>u.map(O=>O.id===a.id?{...O,isFavorite:a.isFavorite}:O)),V(D(i,"Favorit konnte nicht geändert werden"))}},"toggleFavorite"),Ms=s(async a=>{if((G==null?void 0:G.art)==="umbenennen"&&G.id!==void 0){const u=await b.renameFolder(G.id,a);H(O=>O.map(ae=>ae.id===u.id?u:ae));return}const i=await b.createFolder(a);H(u=>[...u,i]),le(Nn($,String(i.id)))},"ordnerNameSpeichern"),Ts=s(async a=>{if(await t({title:"Ordner löschen?",description:`„${a.name}“ wird entfernt. Die enthaltenen Videos bleiben erhalten (danach ohne Ordner).`,variant:"danger",confirmLabel:"Löschen"}))try{await b.deleteFolder(a.id),$.ordner===String(a.id)&&le(ft($,Qt)),await be()}catch(i){V(D(i,"Löschen fehlgeschlagen"))}},"removeFolder"),Et=s(async(a,i)=>{const u=h.filter(re=>a.includes(re.id)&&re.canManage);if(u.length===0){V("Diese Videos darfst du nicht einsortieren.");return}const O=new Map(u.map(re=>[re.id,re.folderId]));g(re=>re.map(Ne=>O.has(Ne.id)?{...Ne,folderId:i}:Ne));const ae=await Promise.allSettled(u.map(re=>b.moveToFolder(re.id,i))),At=u.filter((re,Ne)=>ae[Ne].status==="rejected");if(At.length>0){const re=new Set(At.map(Pe=>Pe.id));g(Pe=>Pe.map(tt=>re.has(tt.id)?{...tt,folderId:O.get(tt.id)??null}:tt));const Ne=ae.find(Pe=>Pe.status==="rejected");
1V(D(Ne.reason,"Verschieben fehlgeschlagen"))}},"verschiebe"),zs=[...Jt("bildschirm")?[{id:"bildschirm",titel:"Bildschirm aufnehmen",unter:"direkt im Browser",icon:ts,onSelect:s(()=>Ce("bildschirm"),"onSelect")}]:[],...Jt("kamera")?[{id:"kamera",titel:"Mit Kamera aufnehmen",unter:"direkt im Browser",icon:bt,onSelect:s(()=>Ce("kamera"),"onSelect")}]:[]],Vs={label:"Neues Video",icon:as,eintraege:[{id:"hochladen",titel:"Video hochladen",unter:"MP4, MOV · bis 5 GB",icon:ls,onSelect:s(()=>{var a;return(a=Te.current)==null?void 0:a.click()},"onSelect")},...zs,{art:"trenner",id:"trenner"},{id:"ki",titel:"KI-Videoprojekt",unter:"Titel und Kapitel aus dem Transkript",icon:We,onSelect:vs},{id:"ordner",titel:"Ordner anlegen",icon:$t,onSelect:s(()=>X({art:"anlegen"}),"onSelect")}]},Es=[{id:"anlegen",titel:"Ordner anlegen",icon:$t,onSelect:s(()=>X({art:"anlegen"}),"onSelect")}],Is=[{id:"statistik",titel:"Statistik der Videothek",unter:"Aufrufe, Dauer und Engagement",icon:rs,onSelect:s(()=>L(!0),"onSelect")},...Ie?[{art:"trenner",id:"trenner-ordner"},{id:"ordner-umbenennen",titel:"Ordner umbenennen",icon:jt,onSelect:s(()=>X({art:"umbenennen",name:Ie.name,id:Ie.id}),"onSelect")},{id:"ordner-loeschen",titel:"Ordner löschen",unter:"Die Videos bleiben erhalten",icon:De,gefaehrlich:!0,onSelect:s(()=>void Ts(Ie),"onSelect")}]:[]],As=ks.map(a=>{const i=a.status==="fertig"?qt(a.durationSeconds):null;return{id:String(a.id),titel:a.title,meta:pa(a),dauer:i??void 0,nebenzeile:a.uploaderName??void 0,spalten:[i??"—",kt(a.createdAt)]}}),Ds=s(a=>{const i=je.get(a.id);if(!i)return[];const u=[{id:"favorit",label:i.isFavorite?"Favorit entfernen":"Als Favorit",icon:wt,aktiv:i.isFavorite,onClick:s(()=>void Cs(i),"onClick")}];return i.canManage&&u.push({id:"verschieben",label:"In Ordner verschieben",icon:Ut,onClick:s(()=>W([i.id]),"onClick")},{id:"freigeben",label:"Freigabe verwalten",icon:xt,onClick:s(()=>k(i),"onClick")}),u},"kartenAktionen"),Ls=s(a=>{const i=je.get(a.id);if(!i)return[];const u=[];return i.status==="fertig"&&u.push({id:"abspielen",titel:"Abspielen",icon:Ot,onSelect:s(()=>Ke(i),"onSelect")}),i.canManage&&u.push(i.visibility==="instanz"?{id:"privat",titel:"Aus der Videothek nehmen",unter:"Danach nur für dich und Freigegebene",icon:nt,deaktiviert:se.has(i.id),onSelect:s(()=>void Ye(i,!1),"onSelect")}:{id:"instanz",titel:"In die Videothek stellen",unter:"Für alle in der Instanz sichtbar",icon:at,deaktiviert:se.has(i.id),onSelect:s(()=>void Ye(i,!0),"onSelect")}),i.canManage&&(u.push({id:"freigeben",titel:"Freigabe verwalten",icon:xt,onSelect:s(()=>k(i),"onSelect")},{id:"verschieben",titel:"In Ordner verschieben",icon:Ut,onSelect:s(()=>W([i.id]),"onSelect")}),i.status==="fertig"&&u.push({id:"herunterladen",titel:"Herunterladen",unter:Ze(i)?Yt:"Als Datei speichern",icon:Kt,deaktiviert:Ze(i),onSelect:s(()=>void Vt(i),"onSelect")})),i.canManage&&(u.push({id:"titel",titel:"Titel bearbeiten",icon:jt,onSelect:s(()=>S(i),"onSelect")}),i.status==="fertig"&&u.push({id:"vorschaubild",titel:"Vorschaubild wählen",icon:is,onSelect:s(()=>I(i),"onSelect")})),i.canManage&&u.push({art:"trenner",id:"trenner"},{id:"loeschen",titel:"Löschen",icon:De,gefaehrlich:!0,onSelect:s(()=>void zt([i]),"onSelect")}),u},"kartenMenue"),It=s(a=>a.map(i=>je.get(i)).filter(i=>!!i),"ausIds"),Fs=[{id:"verschieben",label:"In Ordner verschieben",onClick:s(a=>W(It(a).filter(i=>i.canManage).map(i=>i.id)),"onClick")},{id:"loeschen",label:"Löschen",gefaehrlich:!0,onClick:s(a=>void zt(It(a)),"onClick")}],Rs=(()=>{if(P.trim())return{titel:"Keine Treffer",satz:`Kein Video passt zu „${P.trim()}“.`};if($.ordner===st)return{titel:"Alle Videos liegen in Ordnern"};if($.ordner)return{titel:"Noch kein Video in diesem Ordner",satz:"Neue Videos landen direkt hier. Vorhandene ziehst du auf den Ordner.",aktion:"Video hochladen"};switch($.bereich){case"meine":return{titel:"Noch keine eigenen Videos",satz:"Lade ein Video hoch oder nimm deinen Bildschirm direkt im Browser auf.",aktion:"Neues Video"};case"fuer-mich":return{titel:"Dir wurde noch nichts freigegeben"};case"favoriten":return{titel:"Noch keine Favoriten",satz:"Markiere ein Video mit dem Stern, dann steht es hier."};case"zuletzt":return{titel:"Noch nichts angesehen",satz:"Videos, die du abspielst, stehen hier."};default:return{titel:"Noch keine Videos",satz:"Lade ein Video hoch oder nimm deinen Bildschirm direkt im Browser auf.",aktion:"Neues Video"}}})(),Os=s(a=>{var i;return a.folderId==null||!Ue.has(a.folderId)?"Ohne Ordner":((i=Z.find(u=>u.id===a.folderId))==null?void 0:i.name)??"—"},"ordnerName"),$s=s(a=>{const i=je.get(a);if(!i)return null;const u=i.transcriptStatus!=null&&i.transcriptStatus!=="deaktiviert";return{titel:i.title,vorschau:e.jsx(es,{v:i,version:y[i.id]??0}),daten:[{begriff:"Von",wert:i.uploaderName??"—"},{begriff:"Hochgeladen",wert:kt(i.createdAt)},{begriff:"Dauer",wert:qt(i.durationSeconds)??"—"},{begriff:"Freigabe",wert:ga(i)}
1,{begriff:"Ordner",wert:Os(i)},...i.isOwner?[{begriff:"Aufrufe",wert:String(i.viewCount??0)}]:[]],kinder:e.jsxs(e.Fragment,{children:[i.description&&e.jsx(yn,{titel:"Beschreibung",children:e.jsx("p",{className:"whitespace-pre-line text-xs text-text-secondary",children:i.description})}),u&&i.status==="fertig"&&e.jsx("div",{className:"mt-5 border-t border-default [&>div]:px-0",children:e.jsx(Gt,{videoId:i.id,canEdit:i.isOwner,onSeek:s(O=>{$e.current=O,Ke(i)},"onSeek")})})]})}},"infoLade"),Ks=s(a=>{const i=je.get(a);i&&(i.status==="fertig"?Ke(i):i.status==="verarbeitung"?Lt("Das Video wird noch verarbeitet."):V(i.errorMessage??"Die Verarbeitung ist fehlgeschlagen."))},"onOeffnen"),et=Y?h.filter(a=>Y.includes(a.id)):[],Us=et.length>0&&et.every(a=>a.folderId===et[0].folderId)?et[0].folderId:void 0,Bs=Nt&&(yt||Ee)&&e.jsx("div",{className:"mb-3 rounded-2xl border border-default bg-subtle-soft p-4 md:mx-6",children:yt?e.jsxs("p",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[e.jsx(B,{className:"h-4 w-4 animate-spin text-brand","aria-hidden":!0}),"Die Videothek sucht in den Transkripten …"]}):Ee?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-2",children:[Ee.answer?e.jsxs("p",{className:"flex flex-1 gap-2 whitespace-pre-line text-sm leading-relaxed text-text-primary",children:[e.jsx(We,{className:"mt-0.5 h-4 w-4 shrink-0 text-brand","aria-hidden":!0}),e.jsx("span",{children:Ee.answer})]}):e.jsx("span",{className:"flex-1"}),e.jsx(v,{variant:"ghost",size:"iconXs","aria-label":"Antwort schließen",onClick:s(()=>dt(null),"onClick"),children:e.jsx(de,{"aria-hidden":!0})})]}),Ee.citations.length===0?e.jsx("p",{className:"mt-2 text-sm text-text-soft",children:"Keine passenden Stellen in den Video-Transkripten gefunden."}):e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-text-soft",children:"Fundstellen"}),Ee.citations.map((a,i)=>e.jsxs(v,{variant:"secondary",fullWidth:!0,onClick:s(()=>void js(a),"onClick"),className:"h-auto items-start justify-start whitespace-normal p-2.5 text-left font-normal",children:[e.jsxs("span",{className:"mt-0.5 inline-flex shrink-0 items-center gap-1 rounded bg-selected px-1.5 py-0.5 text-[11px] font-medium text-brand",children:[e.jsx(Ot,{className:"h-3 w-3","aria-hidden":!0}),a.timecodeSeconds!=null?va(a.timecodeSeconds):"Video"]}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-xs font-medium text-text-primary",children:a.title}),e.jsx("span",{className:"block text-xs text-text-soft",children:a.snippet})]})]},i))]})]}):null});return e.jsxs(kn,{icon:He,titel:"Videothek",untertitel:"Videos aufnehmen, hochladen und im Haus teilen.",primaer:Vs,bereiche:Ns,ordner:ys,ohneOrdner:{zaehler:f?void 0:ht.ohneOrdner},ordnerMenue:Es,aktiv:$,onWechsel:le,werkzeuge:{suche:P,onSuche:ie,suchPlatzhalter:"In der Videothek suchen …",fragenModus:{aktiv:Nt,onUmschalten:s(a=>{gs(a),a||dt(null)},"onUmschalten"),platzhalter:"Frag die Videothek — z. B. „Wo wird die Belegerfassung erklärt?“",onFragen:s(a=>void bs(a),"onFragen")},ansicht:U,onAnsicht:he,sortierungen:Xt,sortierung:ue,onSortierung:M,mehr:Is},eintraege:As,laedt:f,vorschau:s(a=>{const i=je.get(a.id);return i?e.jsx(es,{v:i,version:y[i.id]??0}):null},"vorschau"),listenSymbol:s(()=>e.jsx(He,{className:"h-4 w-4 text-brand","aria-hidden":!0}),"listenSymbol"),spaltenTitel:["Dauer","Hochgeladen"],kartenAktionen:Ds,kartenMenue:Ls,onOeffnen:Ks,auswahlAktionen:Fs,leer:Rs,fehler:E?{text:"Videos konnten nicht geladen werden.",onErneut:s(()=>void be(),"onErneut")}:null,infoLade:$s,onOrdnerDrop:s((a,i)=>void Et(i.map(Number),a===st?null:Number(a)),"onOrdnerDrop"),onDateienAbgelegt:s(a=>Tt(a[0]??null),"onDateienAbgelegt"),oberhalbInhalt:Bs||void 0,children:[e.jsx("input",{type:"file",ref:Te,accept:"video/*",className:"hidden","data-testid":"videothek-datei",onChange:s(a=>{var i;return Tt(((i=a.target.files)==null?void 0:i[0])??null)},"onChange")}),e.jsx(Sn,{auftrag:G,onSpeichern:Ms,onSchliessen:s(()=>X(null),"onSchliessen")}),Y&&Y.length>0&&e.jsx(na,{ordner:Z,anzahl:Y.length,aktuellerOrdner:Us,onClose:s(()=>W(null),"onClose"),onWaehle:s(a=>{const i=Y;W(null),Et(i,a)},"onWaehle")}),m&&e.jsx(xe,{onClose:s(()=>z(null),"onClose"),className:"z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"flex max-h-[92vh] w-full max-w-5xl flex-col overflow-y-auto",onClick:s(a=>a.stopPropagation(),"onClick"),children:[e.jsx(v,{variant:"ghost",size:"iconXs",onClick:s(()=>z(null),"onClick"),className:"mb-2 ml-auto",children:e.jsx(de,{className:"h-6 w-6"})}),e.jsxs("div",{className:"overflow-hidden rounded-2xl bg-black shadow-2xl",children:[ge?e.jsxs("div",{className:"flex h-64 w-full flex-col items-center justify-center gap-2 px-6 text-center",children:[e.jsx(ct,{className:"h-8 w-8 text-amber-400"}),e.jsx("p",{className:"text-sm text-white",children:"Das Video konnte nicht geladen werden."}),e.jsx("p",{className:"text-xs text-white/70",children:"Schließe den Player und starte das Video noch einmal."})]}):e.jsx("video",{ref:p,src:pe??void 0,poster:m.hasThumbnail?b.mediaUrl(m.id,"thumbnail"):void 0,controls:!0,autoPlay:!0,onLoadedMetadata:s(()=>{$e.current!=null&&(ut($e.current),$e.current=null)}
1,"onLoadedMetadata"),onTimeUpdate:Js,onError:s(()=>ot(!0),"onError"),className:"max-h-[70vh] w-full bg-black",children:ne&&e.jsx("track",{kind:"subtitles",srcLang:"de",label:"Deutsch",src:ne,default:!0})}),e.jsxs("div",{className:"flex items-start justify-between gap-3 bg-gray-900 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white",children:m.title}),m.description&&e.jsx("p",{className:"mt-1 whitespace-pre-line text-xs text-text-muted",children:m.description})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[m.canManage&&(m.visibility==="instanz"?e.jsxs(v,{variant:"outline",size:"sm",onClick:s(()=>void Ye(m,!1),"onClick"),disabled:se.has(m.id),title:"Danach nur noch für dich und Freigegebene sichtbar",children:[e.jsx(nt,{className:"h-3.5 w-3.5"}),"Aus der Videothek nehmen"]}):e.jsxs(v,{size:"sm",onClick:s(()=>void Ye(m,!0),"onClick"),disabled:se.has(m.id),title:"Für alle in der Instanz sichtbar machen",children:[e.jsx(at,{className:"h-3.5 w-3.5"}),"In die Videothek stellen"]})),m.canManage&&e.jsxs(v,{variant:"outline",size:"sm",onClick:s(()=>void Vt(m),"onClick"),disabled:Ze(je.get(String(m.id))??m),title:Ze(je.get(String(m.id))??m)?Yt:"Als Datei speichern",children:[e.jsx(Kt,{className:"h-3.5 w-3.5"}),"Herunterladen"]}),m.isOwner&&m.hasTranscript&&e.jsxs(v,{variant:"outline",size:"sm",onClick:s(()=>R(m),"onClick"),title:te?"Ein KI-Vorschlag liegt bereit — Titel, Beschreibung und Kapitel ansehen":"Titel, Beschreibung und Kapitel aus dem Transkript vorschlagen lassen",className:"relative",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),"Mit KI verbessern",te&&e.jsxs("span",{className:"absolute -right-1 -top-1 flex h-2.5 w-2.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-brand-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-brand-500"})]})]}),e.jsxs("span",{className:"hidden items-center gap-1 text-[11px] text-text-soft sm:inline-flex",children:[e.jsx("kbd",{className:"rounded bg-gray-800 px-1",children:"Space"})," Play ·",e.jsx("kbd",{className:"rounded bg-gray-800 px-1",children:"←→"})," 5s ·",e.jsx("kbd",{className:"rounded bg-gray-800 px-1",children:"F"})," Vollbild"]})]})]})]}),e.jsx(Gt,{videoId:m.id,onSeek:ut,canEdit:m.isOwner}),e.jsx(Pn,{videoId:m.id,currentTime:s(()=>{var a;return((a=p.current)==null?void 0:a.currentTime)??0},"currentTime"),onSeek:ut})]})}),N&&e.jsx(Cn,{video:N,onClose:s(()=>k(null),"onClose"),onChanged:be}),A&&e.jsx(ta,{video:A,onClose:s(()=>I(null),"onClose"),onSaved:s(a=>{g(i=>i.map(u=>u.id===a.id?{...u,...a}:u)),_(i=>({...i,[a.id]:Date.now()}))},"onSaved")}),T&&e.jsx(sa,{video:T,onClose:s(()=>S(null),"onClose"),onGespeichert:be}),Le&&e.jsx($n,{mode:Le,onClose:s(()=>Ce(null),"onClose"),onRecorded:ws}),w&&e.jsx(Jn,{onClose:s(()=>L(!1),"onClose")}),F&&e.jsx(ea,{video:F,onClose:s(()=>R(null),"onClose"),onVorschlagVerbraucht:s(()=>q(!1),"onVorschlagVerbraucht"),onApplied:s(()=>{be(),b.getOne(F.id).then(a=>z(i=>i&&i.id===a.id?a:i)).catch(()=>{})},"onApplied")}),ve&&e.jsx(xe,{onClose:s(()=>!oe&&Je(),"onClose"),className:"z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-surface shadow-2xl",onClick:s(a=>a.stopPropagation(),"onClick"),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-default px-5 py-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Video hochladen"}),!oe&&e.jsx(v,{variant:"ghost",size:"iconXs",onClick:Je,children:e.jsx(de,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-subtle-soft px-3 py-2 text-sm text-text-secondary",children:[e.jsx(He,{className:"h-4 w-4 shrink-0 text-brand-600"}),e.jsx("span",{className:"truncate",children:ee==null?void 0:ee.name}),e.jsx("span",{className:"ml-auto shrink-0 text-xs text-text-muted",children:ja((ee==null?void 0:ee.size)??null)})]}),x&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[e.jsx(cs,{className:"h-3.5 w-3.5 text-text-muted","aria-hidden":!0}),"Landet im Ordner „",x.name,"“"]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-strong",children:"Titel"}),e.jsx(Ae,{type:"text",value:we,onChange:s(a=>ke(a.target.value),"onChange"),disabled:oe})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 block text-sm font-medium text-text-strong",children:["Beschreibung ",e.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),e.jsx(lt,{value:_e,onChange:s(a=>Ge(a.target.value),"onChange"),disabled:oe,rows:3})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-strong",children:"Sichtbarkeit"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{wert:"privat",label:"Privat",Icon:nt},{wert:"instanz",label:"Instanzweit",Icon:at}].map(({wert:a,label:i,Icon:u})=>e.jsx(v,{variant:"secondary","aria-pressed":Me===a,onClick:s(()=>Xe(a),"onClick"),disabled:oe,className:`justify-start font-normal ${Me===a?"border-brand-500 bg-selected text-brand hover:bg-selected":""}`,leftIcon:e.jsx(u,{"aria-hidden":!0}),children:i},a))})]}),oe&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex justify-between text-xs text-text-soft",children:[e.jsx("span",{children:"Wird hochgeladen…"}),e.jsxs("span",{children:[Fe,"%"]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-brand-600 transition-all",style:{width:`${Fe}%`}})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-default px-5 py-3",children:[e.jsx(v,{variant:"ghost",onClick:Je,disabled:oe,children:"Abbrechen"}),e.jsxs(v,{onClick:Ss,disabled:oe||!we.trim()||!ee,children:[oe&&e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Hochladen"]})]})]})})]})}s(Aa,"Videothek");export{Aa as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.