PageSourceSearch

https://storymotion.video/assets/chunks/chunk-DojFnSdj.js

js storymotion.video collected 2026-10-06 16:27:39 UTC 10,758 bytes, 2 lines download raw bytes

1import{r as i,j as t,u as ie}from"./chunk-Dd5i3kUi.js";import{F as T,G as ce,H as le,I as de,J as ue,B as me,d as fe}from"./chunk-CRHzQu7D.js";import{z as pe}from"./chunk-cKPYAOrf.js";import{D as xe,S as W,O as ge,a as he}from"./chunk-sUJGvPm7.js";import{M as be}from"./chunk-BFNdsG77.js";import{R as ke,h as ye,U as q,j as we,A as G,k as ve}from"./chunk-Bg_eTBSu.js";import{p as V}from"./chunk-BFAiRT_b.js";import{u as P,a as U}from"./chunk-BurZFMUW.js";import{u as B}from"./chunk-CWOCMFmd.js";/* empty css              */import"./chunk-CkgDg7cv.js";import"./chunk-4MQXs7et.js";import"./chunk-DWJ4oAWS.js";import"./chunk-CpTOQht3.js";import"./chunk-BwgI00Gv.js";import"./chunk-Bxs7W2hn.js";import"./chunk-Cbe5Fgch.js";import"./chunk-B84M-TV3.js";/* empty css              */import"./chunk-jJFeuH8t.js";import"./chunk-DTHZb5Z2.js";/* empty css              */import"./chunk-B35OuwoP.js";import"./chunk-BFrH_fqN.js";/* empty css              */(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"0962c6fd0bea418f28b4d5b4a85fe9ad3a267ce3"};var f=new a.Error().stack;f&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[f]="65ba2129-616b-44ed-a08f-0b133af7993a",a._sentryDebugIdIdentifier="sentry-dbid-65ba2129-616b-44ed-a08f-0b133af7993a")}catch{}})();const je=({stream:a})=>{const f=i.useRef(null);return i.useEffect(()=>{const h=f.current,s=h?.getContext("2d");if(!h||!s)return;const l=new AudioContext,y=l.createMediaStreamSource(a),u=l.createAnalyser();u.fftSize=2048,y.connect(u);const p=u.fftSize,R=new Uint8Array(p);let E=0;const x=()=>{E=requestAnimationFrame(x),u.getByteTimeDomainData(R);const{width:m,height:w}=h;s.clearRect(0,0,m,w),s.lineWidth=2,s.strokeStyle="#ef4444",s.beginPath();const N=m/p;let k=0;for(let v=0;v<p;v++){const S=R[v]/128*(w/2);v===0?s.moveTo(k,S):s.lineTo(k,S),k+=N}s.lineTo(m,w/2),s.stroke()};return l.resume().finally(x),()=>{cancelAnimationFrame(E),y.disconnect(),u.disconnect(),l.close().catch(()=>{})}},[a]),t.jsx("canvas",{ref:f,width:440,height:80,className:"w-full h-20 rounded bg-gray-50"})},H=3,J=a=>{if(!Number.isFinite(a))return"--:--";const f=Math.floor(a/1e3),h=Math.floor(f/60).toString().padStart(2,"0"),s=(f%60).toString().padStart(2,"0");return`${h}:${s}`},Ye=({isOpen:a,onClose:f})=>{const[h,s]=i.useState({kind:"idle"}),[l,y]=i.useState([]),[u,p]=i.useState(null),R=ie(e=>e.user),x=P(e=>e.props).editTrackId,m=i.useRef(null),w=i.useRef(null),N=i.useRef([]),k=i.useRef(null),v=i.useRef(0),S=i.useRef(0),I=i.useRef(new Set),M=i.useRef(null),j=i.useCallback(()=>{k.current&&(clearInterval(k.current),k.current=null)},[]),C=i.useCallback(()=>{j();const e=w.current;e&&e.state!=="inactive"&&(e.onstop=null,e.ondataavailable=null,e.stop()),w.current=null,m.current?.getTracks().forEach(r=>r.stop()),m.current=null,N.current=[],M.current=null,I.current.forEach(r=>URL.revokeObjectURL(r)),I.current.clear(),y([]),p(null),s({kind:"idle"})},[j]),$=e=>{j(),N.current=[];const r=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"",c=new MediaRecorder(e,r?{mimeType:r}:void 0);w.current=c,c.ondataavailable=d=>{d.data.size>0&&N.current.push(d.data)},c.onstop=async()=>{j();const d=new Blob(N.current,{type:r||"audio/webm"}),b=await ve(d).catch(()=>0),o=S.current+=1,n=URL.createObjectURL(d);I.current.add(n);const g={id:`take-${o}`,label:`Take ${o}`,url:n,blob:d,durationMs:b};y(A=>[...A,g]),p(g.id),M.current?.(),M.current=null},c.start(),v.current=performance.now(),s({kind:"recording",elapsedMs:0}),k.current=setInterval(()=>{s({kind:"recording",elapsedMs:performance.now()-v.current})},100)},F=e=>{j();let r=H;s({kind:"countdown",count:r}),k.current=setInterval(()=>{r-=1,r<=0?(j(),$(e)):s({kind:"countdown",count:r})},1e3)},_=async()=>{if(m.current&&m.current.active)return m.current;s({kind:"requesting"});try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});return m.current=e,e}catch{return s({kind:"error",message:"Microphone access was blocked. Allow it in your browser settings, then try again."}),null}},O=()=>new Promise(e=>{const r=w.current;if(!r||r.state==="inactive"){e();return}M.current=e,r.stop()}),D=async()=>{const e=await _();e&&F(e)},Y=async()=>{const e=await _();e&&$(e)},K=async()=>{await O(),s({kind:"idle"})},Q=async()=>{await O();const e=m.current;e&&e.active?F(e):D()},X=()=>{j(),s({kind:"idle"})}
1,Z=e=>{const r=l.find(d=>d.id===e);r&&(URL.revokeObjectURL(r.url),I.current.delete(r.url));const c=l.filter(d=>d.id!==e);y(c),u===e&&p(c.length?c[c.length-1].id:null)},L=i.useCallback(()=>{C(),f()},[C,f]),ee=async()=>{const e=l.find(r=>r.id===u);if(e){if(!R){P.getState().openModal("signin-modal");return}if(!B.getState()._metadata?.id){V.open({title:"Project Unsaved",message:"Please save your project before inserting a recording."});return}try{await G.getInstance().insertRecordedTake({blob:e.blob,durationMs:e.durationMs}),U.success("Recording inserted",{closeButton:!0}),L()}catch(r){const c=r;U.error(c.detail||c.message||"Failed to insert recording")}}},te=async()=>{const e=l.find(o=>o.id===u);if(!e||!x)return;if(!R){P.getState().openModal("signin-modal");return}const r=B.getState(),d=[...r.mainTimeline?.tracks??[],...r.scenes.flatMap(o=>o.audioTracks??[])].find(o=>o.id===x);if(!(d&&d.activeTakeId===u&&!l.some(o=>!o.persisted))&&!r._metadata?.id){V.open({title:"Project Unsaved",message:"Please save your project before saving a recording."});return}try{await G.getInstance().applyTakeToTrack({trackId:x,newTake:e.persisted?void 0:{blob:e.blob,durationMs:e.durationMs},existingTakeId:e.persisted?e.id:void 0}),U.success("Recording saved",{closeButton:!0}),L()}catch(o){const n=o;U.error(n.detail||n.message||"Failed to save recording")}};i.useEffect(()=>{if(a)return S.current=0,s({kind:"idle"}),y([]),p(null),()=>C()},[a,C]),i.useEffect(()=>{if(!a||!x)return;(async()=>{const r=B.getState(),c=r._metadata?.id,b=[...r.mainTimeline?.tracks??[],...r.scenes.flatMap(n=>n.audioTracks??[])].find(n=>n.id===x);if(!b||!b.takes?.length)return;const o=[];for(const n of b.takes){let g=q.get(n.fileId);if(!g&&c){const oe=n.format??"webm",{file:z}=await we(`${c}/${n.fileId}.${oe}`,b.displayName);z&&(g=z,q.set(n.fileId,g))}if(!g)continue;const A=URL.createObjectURL(g);I.current.add(A);const ae=n.id===b.activeTakeId;o.push({id:n.id,label:ae?`${n.label??"Take"} (current)`:n.label??`Take ${b.takes.indexOf(n)+1}`,url:A,blob:g,durationMs:n.durationMs,persisted:!0})}if(o.length>0){y(o);const n=o.find(g=>g.id===b.activeTakeId);p(n?.id??o[0].id)}})()},[a,x]);const re=l.length>0&&(h.kind==="idle"||h.kind==="error"),se=l.find(e=>e.id===u)??null,ne=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-xs text-gray-400",children:R?"Recordings stay in memory until inserted.":"Sign in to add a recording to your timeline."}),t.jsx(he,{onClick:x?te:ee,disabled:!se,children:x?"Save":"Insert"})]});return t.jsxs(be,{open:a,onOpenChange:e=>{e||L()},size:"sm",title:"Record Voice",footer:ne,children:[t.jsx("div",{className:"p-6 flex flex-col items-center justify-center gap-4 border-b min-h-[180px]",children:pe(h).with({kind:"idle"},()=>t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(xe,{onClick:D,className:"px-5 py-2.5",children:[t.jsx(T,{icon:ce,className:"mr-2"}),l.length?"Record another":"Start recording"]}),t.jsx("button",{type:"button",onClick:Y,className:"text-sm text-gray-600 px-3 py-2.5 rounded-lg hover:bg-gray-100 transition-colors",children:"Record now"})]}),t.jsxs("p",{className:"text-xs text-gray-400",children:[H,'s countdown, or "Record now" to skip it']})]})).with({kind:"requesting"},()=>t.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-500",children:[t.jsx(T,{icon:le,className:"text-3xl animate-pulse"}),t.jsx("p",{className:"text-sm",children:"Waiting for microphone…"})]})).with({kind:"countdown"},({count:e})=>t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-24 h-24 rounded-full border-4 border-red-500 flex items-center justify-center",children:t.jsx("span",{className:"text-5xl font-bold text-red-500 tabular-nums",children:e})}),t.jsx("button",{type:"button",onClick:X,className:"text-sm text-gray-500 hover:text-gray-700",children:"Cancel"})]})).with({kind:"recording"},({elapsedMs:e})=>t.jsxs("div",{className:"flex flex-col items-center gap-4 w-full",children:[t.jsxs("div",{className:"flex items-center justify-between w-full",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-3 h-3 rounded-full bg-red-500 animate-pulse"}),t.jsx("span",{className:"text-sm font-medium text-red-500 uppercase tracking-wide",children:"Recording"})]}),t.jsx("span",{className:"text-2xl font-mono text-gray-800 tabular-nums",children:J(e)})]}),m.current&&t.jsx(je,{stream:m.current}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(W,{onClick:K,className:"bg-gray-900 text-white hover:bg-black px-5 py-2",children:[t.jsx(T,{icon:de,className:"mr-2"}),"Stop"]}),t.jsxs(ge,{onClick:Q,className:"px-4 py-2",children:[t.jsx(T,{icon:ue,className:"mr-2"}),"Re-record"]})]})]})).with({kind:"error"},({message:e})=>t.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[t.jsx(T,{icon:me,className:"text-3xl text-amber-500"}),t.jsx("p",{className:"text-sm text-gray-600",children:e}),t.jsx(W,{onClick:D,className:"bg-gray-900 text-white hover:bg-black px-5 py-2",children:"Try again"})]})).exhaustive()}),re&&t.jsxs(ke,{value:u??"",onValueChange:p,className:"flex-1 p-4 flex flex-col gap-2",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Takes"}),l.map(e=>t.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg border cursor-pointer transition-colors ${u===e.id?"border-red-400 bg-red-50":"border-gray-200 hover:bg-gray-50"}`,onClick:()=>p(e.id),children:[t.jsx(ye,{value:e.id,id:e.id,className:"border-red-400 text-red-600 shrink-0",onClick:r=>r.stopPropagation()}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsxs("span",{className:"text-sm font-medium text-gray-800",children:[e.label,t.jsx("span",{className:"ml-2 text-xs font-normal text-gray-400",children:J(e.durationMs)})]}),t.jsx("audio",{src:e.url,controls:!0,className:"w-full mt-1 h-8"})]}),!e.persisted&&t.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),Z(e.id)},className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors",title:"Remove take",children:t.jsx(T,{icon:fe})})]},e.id))]})]})};export{Ye as RecordVoiceModal};
2//# sourceMappingURL=chunk-DojFnSdj.js.map

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.