PageSourceSearch

https://ribbi.ai/_next/static/chunks/2575-26c0d3491a78b72e.js

js ribbi.ai collected 2026-10-05 12:33:22 UTC 62,545 bytes, 24 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2575],{7624:(e,t,r)=>{r.d(t,{J:()=>u});var l=r(12115),s=r(61482),n=r(40028);class a{constructor(){this.worker=new Worker(r.tu(new URL(r.p+r.u(5979),r.b)),{type:void 0}),this.worker.onmessage=e=>{let t=e.data;switch(t.type){case"ready":this.onReady?.(t);break;case"frame":this.onFrame?.(t);break;case"hit":this.onHit?.(t);break;case"edit":this.onEdit?.(t);break;case"fontSize":this.onFontSize?.(t.value);break;case"assSnapshot":this.onAssSnapshot?.(t.texts);break;case"fullAss":this.onFullAss?.(t.ass);break;case"error":this.onError?.(t.message)}}}init(e,t,r,l,s){let n=e.transferControlToOffscreen();this.worker.postMessage({type:"init",canvas:n,script:t,fonts:r,width:l,height:s},[n,...r])}seek(e){this.worker.postMessage({type:"seek",timeMs:e})}play(){this.worker.postMessage({type:"play"})}pause(){this.worker.postMessage({type:"pause"})}hit(e,t,r){this.worker.postMessage({type:"hit",x:e,y:t,pointerId:r})}drag(e,t,r){this.worker.postMessage({type:"drag",index:e,x:t,y:r})}setFontSize(e,t){this.worker.postMessage({type:"fontSize",index:e,value:t})}setColor(e,t,r,l){this.worker.postMessage({type:"color",index:e,r:t,g:r,b:l})}setBorder(e,t){this.worker.postMessage({type:"border",index:e,value:t})}setShadow(e,t){this.worker.postMessage({type:"shadow",index:e,value:t})}setAlign(e,t){this.worker.postMessage({type:"align",index:e,value:t})}resizeStart(e){this.worker.postMessage({type:"resizeStart",index:e})}resize(e,t){this.worker.postMessage({type:"resize",index:e,ratio:t})}resizeEnd(){this.worker.postMessage({type:"resizeEnd"})}editAt(e,t){this.worker.postMessage({type:"editAt",x:e,y:t})}caretSet(e,t){this.worker.postMessage({type:"caretSet",x:e,y:t})}caretMove(e){this.worker.postMessage({type:"caretMove",dir:e})}insert(e){this.worker.postMessage({type:"insert",text:e})}backspace(){this.worker.postMessage({type:"backspace"})}deleteForward(){this.worker.postMessage({type:"deleteForward"})}editEnd(){this.worker.postMessage({type:"editEnd"})}getAss(){this.worker.postMessage({type:"getAss"})}reloadScript(e){this.worker.postMessage({type:"reloadScript",script:e})}resetCanvas(e,t,r){let l=e.transferControlToOffscreen();this.worker.postMessage({type:"resetCanvas",canvas:l,width:t,height:r},[l])}fetchFullAss(){return new Promise(e=>{let t=this.onFullAss;this.onFullAss=r=>{this.onFullAss=t,e(r)},this.worker.postMessage({type:"getFullAss"})})}destroy(){this.worker.terminate()}}let i=[{file:"HomemadeApple-Regular.ttf",url:"/fonts/HomemadeApple-Regular.ttf"},{file:"PlaywriteAUVICGuides-Regular.ttf",url:"/fonts/PlaywriteAUVICGuides-Regular.ttf"},{file:"Honk-Regular-VariableFont.ttf",url:"/fonts/Honk-Regular-VariableFont.ttf"},{file:"DMSans-Regular.ttf",url:"/fonts/DMSans-Regular.ttf"},{file:"Montserrat-Regular.ttf",url:"/fonts/Montserrat-Regular.ttf"},{file:"Inter-Regular.ttf",url:"/fonts/Inter-Regular.ttf"},{file:"NotoSansSC-Regular.ttf",url:"https://cdn.ribbi.ai/fonts/NotoSansSC-Regular.ttf"}];function o(e,t){let r=e.findIndex(e=>{let r=(0,n.fq)(e.start),l=(0,n.fq)(e.end);return t>=r&&t<l});return r>=0?r:null}function u({subtitleText:e,videoWidth:t,videoHeight:r}){let[d,c]=(0,l.useState)("idle"),[h,f]=(0,l.useState)(null),[p,x]=(0,l.useState)(null),[b,m]=(0,l.useState)(null),[y,g]=(0,l.useState)(null),[C,v]=(0,l.useState)([]),[w,k]=(0,l.useState)(null),[j,S]=(0,l.useState)(!1),[E,M]=(0,l.useState)(0),[N,L]=(0,l.useState)(null),[F,R]=(0,l.useState)(!0),[$,_]=(0,l.useState)(!1),[z,A]=(0,l.useState)(0),[I,H]=(0,l.useState)(!1),[T,D]=(0,l.useState)(!1),[O,V]=(0,l.useState)([]),[B,G]=(0,l.useState)(null),[U,P]=(0,l.useState)(0),[Z,W]=(0,l.useState)(0),X=(0,l.useRef)(null),Y=(0,l.useRef)(null),K=(0,l.useRef)(null),q=(0,l.useRef)(null);(0,l.useRef)(null);let J=(0,l.useRef)(0),Q=(0,l.useRef)([]),ee=(0,l.useRef)(0),et=(0,l.useRef)([]),er=(0,l.useRef)([]),el=(0,l.useRef)(null),es=(0,l.useRef)(null),en=(0,l.useRef)(null),ea=(0,l.useRef)(null),ei=(0,l.useRef)(null),eo=(0,l.useRef)(null),eu=(0,l.useRef)(new Map),ed=(0,l.useCallback)(()=>{for(let e of eu.current.values())URL.revokeObjectURL(e.url);eu.current.clear()},[]),ec=(0,l.useCallback)(e=>{J.current=e,M(e),L(o(Q.current,e))},[]),eh=(0,l.useCallback)(e=>{let t=e.getEvents();Q.current=t,v(t),L(o(t,J.current))},[]);(0,l.useCallback)(()=>{let e=X.current;return e?e.getEvents().map(e=>{let t=(0,n.fq)(e.start),r=(0,n.fq)(e.end);return{key:`${e.start}|${e.end}`,start:t,end:r,mid:(t+r)/2}}):[]},[]),(0,l.useCallback)(async(e,t)=>{},[]),(0,l.useEffect)(()=>
1{if(!e||!t||!r)return;let l=!1;return++ee.current,(async()=>{try{c("loading-engine"),f(null);let o=new s.v((0,s.VU)(e,t,r));if(X.current=o,eh(o),k(o.getStyleSummary()),await new Promise(e=>setTimeout(e,50)),l)return;let u=K.current;if(!u)throw Error("renderCanvas 未挂载");let d=new a;Y.current=d,d.onReady=()=>{l||c("ready")},d.onFrame=e=>{if(V(e.boxes),P(e.renderMs),W(e.p95),void 0!==e.caret&&G(e.caret),e.boxes.length>=5){let t=e.boxes[1],r=e.boxes[2],l=e.boxes[3],s=e.boxes[4];x({x:t,y:r,w:l-t,h:s-r})}ec(e.timeMs/1e3)},d.onHit=e=>{e.index>=0&&R(!0)},d.onEdit=e=>{if(_(e.active),e.active)void 0!==e.index&&void 0!==e.text&&(ei.current={index:e.index,text:e.text}),G(e.geom&&3===e.geom.length?e.geom:null),q.current?.();else{G(null);let e=ei.current;ei.current=null,e&&eL(e.index,e.text)}},d.onFontSize=e=>{eo.current&&(eo.current.value=e)},d.onError=e=>{console.error("unit-ass worker:",e)};let h=await Promise.all(i.map(e=>fetch(e.url).then(e=>e.arrayBuffer())));if(l)return void d.destroy();d.init(u,o.toAss(),h,t,r),el.current={text:o.baseAss(),offset:{x:0,y:0},corrections:null},et.current=[],er.current=[],es.current=null,H(!1),D(!1),R(!0);let p=o.getEvents()[0],b=p?(0,n.Je)(p.start,p.end):0;d.seek(1e3*b)}catch(e){l||(f(e instanceof Error?e.message:String(e)),c("error"))}})(),()=>{l=!0,ed(),Y.current?.destroy(),Y.current=null}},[e,t,r]);let ef=(0,l.useCallback)(async e=>{let t=X.current,r=Y.current;t&&r&&(r.reloadScript(t.toAss()),r.seek(1e3*J.current),ee.current===e&&c("ready"))},[]),ep=(0,l.useCallback)(async e=>{let t=Y.current;t&&(t.seek(1e3*e),ec(e))},[ec]),ex=(0,l.useCallback)(()=>{let e=X.current;return e?{text:e.baseAss(),offset:{...e.globalOffset},corrections:e.xCorrections?[...e.xCorrections]:null}:null},[]),eb=(0,l.useCallback)(e=>{if(null!=e&&es.current===e)return;let t=ex();t&&(et.current.push(t),er.current.length=0,es.current=e??null,H(!0),D(!1))},[ex]),em=(0,l.useCallback)(async e=>{let t=new s.v(e.text);t.globalOffset={...e.offset},t.setXCorrections(e.corrections?[...e.corrections]:null),X.current=t,eh(t),k(t.getStyleSummary()),S(!0),ed(),A(e=>e+1);let r=++ee.current;c("rendering"),await ef(r),ep(J.current)},[ed,ep,eh,ef]),ey=(0,l.useCallback)(async()=>{let e=et.current.pop();if(!e)return;let t=ex();t&&er.current.push(t),es.current=null,H(et.current.length>0),D(!0),await em(e)},[ex,em]),eg=(0,l.useCallback)(async()=>{let e=er.current.pop();if(!e)return;let t=ex();t&&et.current.push(t),es.current=null,H(!0),D(er.current.length>0),await em(e)},[ex,em]),eC=(0,l.useCallback)(async()=>{let e=el.current;e&&(eb(),await em(e))},[eb,em]),ev=(0,l.useCallback)((e,t,r)=>{let l=X.current,s=l?(0,n.ap)(e,t,r,l.playRes):{x:0,y:0},a=en.current??p;if(!l||!a)return{assDelta:s,px:{x:e,y:t},guides:{x:null,y:null}};let i=8*(l.playRes.x/r.width),o={x:a.x+s.x,y:a.y+s.y,w:a.w,h:a.h},u=(0,n.uF)(o,l.playRes,i),d={x:s.x+u.dx,y:s.y+u.dy};return{assDelta:d,px:{x:d.x*r.width/l.playRes.x,y:d.y*r.height/l.playRes.y},guides:{x:u.guideX,y:u.guideY}}},[p]),ew=(0,l.useCallback)(e=>{en.current=p,ea.current=e?{...e,moved:!1}:null,m({x:0,y:0})},[p]),ek=(0,l.useCallback)((e,t,r)=>{let l=ev(e,t,r),s=ea.current;s?(Y.current?.drag(s.index,s.anchor.x+l.assDelta.x,s.anchor.y+l.assDelta.y),s.moved=!0,m({x:0,y:0})):m(l.px),g(l.guides)},[ev]),ej=(0,l.useCallback)(async(e,t,r)=>{let l=X.current,s=ea.current?.moved??!1;if(ea.current=null,g(null),!l){en.current=null;return}if(Math.abs(e)+Math.abs(t)<=2){if(en.current=null,m(null),s){let e=++ee.current;await ef(e)}return}let n=ev(e,t,r);en.current=null,eb(),l.translateAll(n.assDelta.x,n.assDelta.y),S(!0),ed();let a=++ee.current;await ef(a),m(null)},[ev,eb,ed,ef]),eS=(0,l.useCallback)(async(e,t)=>{let r=X.current;if(!r)return;eb(),r.translateAll(e,t),S(!0),ed();let l=++ee.current;await ef(l)},[eb,ed,ef]),eE=(0,l.useCallback)(e=>{let t=X.current;return t&&p?(0,n.JG)(p,e,t.playRes):null},[p]),eM=(0,l.useCallback)(async e=>{let t=X.current;if(!t)return;S(!0),ed(),eh(t),k(t.getStyleSummary()),c("rendering");let r=++ee.current;await ef(r),ep(J.current)},[ed,eh,ef,ep]),eN=(0,l.useCallback)(async(e,t)=>{eb(e),X.current?.setEventText(e,t),await eM(e)},[eM,eb]),eL=(0,l.useCallback)(async(e,t)=>{let r=X.current;if(!r)return;let l=r.getEvents()[e];l&&l.displayText!==t&&(eb(),r.setEventText(e,t),await eM(e))},[eM,eb]),eF=(0,l.useCallback)(async(e,t,r)=>{eb(),X.current?.setEventTime(e,t,r),await eM(e)},[eM,eb]),eR=(0,l.useCallback)(async(e,t)=>
1{eb(t),X.current?.applyGlobalStyle(e),await eM()},[eM,eb]),e$=(0,l.useCallback)(async()=>{eb(),X.current?.resetGlobalOffset(),S(!0),ed();let e=++ee.current;await ef(e)},[ed,eb,ef]),e_=(0,l.useCallback)(()=>X.current?.toAss()??"",[]),ez=(0,l.useCallback)(()=>({...X.current?.globalOffset??{x:0,y:0}}),[]),eA=(0,l.useCallback)(()=>S(!1),[]),eI=(0,l.useCallback)(async e=>{},[]),eH=(0,l.useCallback)(e=>null,[]),eT=(0,l.useCallback)((e,t,r)=>Y.current?.hit(e,t,r),[]),eD=(0,l.useCallback)((e,t,r)=>Y.current?.drag(e,t,r),[]),eO=(0,l.useCallback)((e,t)=>Y.current?.editAt(e,t),[]),eV=(0,l.useCallback)((e,t)=>Y.current?.caretSet(e,t),[]),eB=(0,l.useCallback)(()=>Y.current?.editEnd(),[]),eG=(0,l.useCallback)(e=>Y.current?.insert(e),[]),eU=(0,l.useCallback)(()=>Y.current?.backspace(),[]),eP=(0,l.useCallback)(()=>Y.current?.deleteForward(),[]),eZ=(0,l.useCallback)(e=>Y.current?.caretMove(e),[]),eW=(0,l.useCallback)(e=>{eo.current={index:e,value:null},Y.current?.resizeStart(e)},[]),eX=(0,l.useCallback)((e,t)=>Y.current?.resize(e,t),[]),eY=(0,l.useCallback)(()=>{Y.current?.resizeEnd();let e=eo.current;eo.current=null;let t=X.current;e&&null!=e.value&&t&&(eb(),t.applyGlobalStyle({fontsize:Math.round(e.value)}),eM())},[eM,eb]),eK=(0,l.useCallback)(e=>Y.current?.seek(e),[]),eq=(0,l.useCallback)((e,t)=>Y.current?.setFontSize(e,t),[]),eJ=(0,l.useCallback)((e,t,r,l)=>Y.current?.setColor(e,t,r,l),[]),eQ=(0,l.useCallback)((e,t)=>Y.current?.setBorder(e,t),[]),e0=(0,l.useCallback)((e,t)=>Y.current?.setShadow(e,t),[]),e1=null==N?null:C.find(e=>e.index===N)??null;return{status:d,error:h,renderCanvasRef:K,boxes:O,caretGeom:B,renderMs:U,p95Ms:Z,onEditActiveRef:q,selBox:p,dragOffsetPx:b,snapGuides:y,events:C,styleSummary:w,getGlobalOffset:ez,dirty:j,markSaved:eA,previewTime:E,currentEvent:e1,currentEventIndex:N,setTimelineTime:ec,selected:F,setSelected:R,isEditing:$,docVersion:z,canUndo:I,canRedo:T,undo:ey,redo:eg,resetAll:eC,nudge:eS,dragStart:ew,dragMove:ek,dragEnd:ej,selBoxToClient:eE,setEventText:eN,setEventTime:eF,applyGlobalStyle:eR,resetOffset:e$,toAss:e_,preparePlayback:eI,segmentUrlForTime:eH,hit:eT,drag:eD,editAt:eO,caretSet:eV,exitEdit:eB,insert:eG,backspace:eU,deleteForward:eP,caretMove:eZ,resizeStart:eW,resize:eX,resizeEnd:eY,renderAt:ep,seek:eK,setFontSize:eq,setColor:eJ,setBorder:eQ,setShadow:e0}}},24377:(e,t,r)=>{r.d(t,{i:()=>d});var l=r(95155),s=r(12115),n=r(89045),a=r(40028);let i='url("/subtitle-editor/cursor-move.svg") 10 9, move',o='url("/subtitle-editor/cursor-resize.svg") 12 12, nwse-resize';function u(e){let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${String(r).padStart(2,"0")}`}function d({videoSrc:e,posterUrl:t,videoWidth:r,videoHeight:c,controller:h,className:f,videoClassName:p}){let x,b,m,y,g,C,{t:v}=(0,n.s)(),w=(0,s.useRef)(null),k=(0,s.useRef)(null),j=(0,s.useRef)(null),S=(0,s.useRef)(null),E=(0,s.useRef)(null),M=(0,s.useRef)(!1),[N,L]=(0,s.useState)(null),[F,R]=(0,s.useState)(!1),[$,_]=(0,s.useState)(0),[z,A]=(0,s.useState)(0),[I,H]=(0,s.use
1State)(!1),[T,D]=(0,s.useState)(null),[O,V]=(0,s.useState)(!0),[B,G]=(0,s.useState)("default"),[U,P]=(0,s.useState)(!1),[Z,W]=(0,s.useState)(o),X=(0,s.useRef)(null),Y=(0,s.useRef)(null);(0,s.useRef)(null);let K=function(e){let t=[];for(let r=0;r+6-1<e.length;r+=6)t.push({idx:e[r],x1:e[r+1],y1:e[r+2],x2:e[r+3],y2:e[r+4],align:e[r+5]});return t}(h.boxes),q=h.selected?K[0]?.idx??-1:-1,J=K.find(e=>e.idx===q),{selBox:Q,dragOffsetPx:ee,snapGuides:et,status:er,error:el,previewTime:es,selected:en}=h,{dragStart:ea,dragMove:ei,dragEnd:eo,nudge:eu,preparePlayback:ed,renderAt:ec,segmentUrlForTime:eh,setSelected:ef,setTimelineTime:ep}=h,ex=null!==ee;(0,s.useEffect)(()=>{let e=w.current;if(!e||!r||!c)return;let t=()=>{let t,l,s=e.clientWidth;if(!s)return;let n=e.clientHeight,a=n>0&&n<.8*window.innerHeight,i=c>r;if(a)l=Math.min(c/r*s,Math.max(180,n-22)),t=r/c*l;else if(i){let e=n>0?n-22:.85*window.innerHeight;(l=c/r*(t=s))>e&&(t=r/c*(l=e))}else l=Math.min(c/r*s,Math.max(180,Math.min(.56*window.innerHeight,520))),t=r/c*l;let o={width:Math.round(t),height:Math.round(l)};L(e=>e&&e.width===o.width&&e.height===o.height?e:o)};t();let l=new ResizeObserver(t);return l.observe(e),window.addEventListener("resize",t),()=>{l.disconnect(),window.removeEventListener("resize",t)}},[c,r]),(0,s.useEffect)(()=>{let e=S.current;e&&(e.width=r,e.height=c)},[r,c]);let eb=(0,s.useCallback)(()=>{let e=S.current;if(!e)return;let t=e.getContext("2d");if(t&&(t.clearRect(0,0,e.width,e.height),h.isEditing&&h.caretGeom&&O)){let[e,r,l]=h.caretGeom;t.fillStyle="#ffffff",t.fillRect(e-1.5,r,3,l)}},[h.isEditing,h.caretGeom,O]);(0,s.useEffect)(()=>{eb()},[eb]),(0,s.useEffect)(()=>(h.onEditActiveRef.current=()=>{V(!0),X.current&&clearInterval(X.current),X.current=setInterval(()=>V(e=>!e),530),E.current?.focus()},()=>{h.onEditActiveRef.current=null}),[h]),(0,s.useEffect)(()=>(h.isEditing||(X.current&&clearInterval(X.current),V(!0)),()=>{X.current&&clearInterval(X.current)}),[h.isEditing]),(0,s.useEffect)(()=>{let e=E.current;if(!e)return;let t=e=>{if(!h.isEditing)return;let t={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",ArrowDown:"down"};t[e.key]?(h.caretMove(t[e.key]),e.preventDefault()):"Backspace"===e.key?(h.backspace(),e.preventDefault()):"Delete"===e.key?(h.deleteForward(),e.preventDefault()):"Enter"===e.key?(h.insert("\n"),e.preventDefault()):"Escape"===e.key&&(h.exitEdit(),e.preventDefault())},r=()=>{!M.current&&e.value&&(h.insert(e.value),e.value="")},l=()=>{M.current=!0},s=t=>{M.current=!1,t.data&&(h.insert(t.data),e.value="")};return e.addEventListener("keydown",t),e.addEventListener("input",r),e.addEventListener("compositionstart",l),e.addEventListener("compositionend",s),()=>{e.removeEventListener("keydown",t),e.removeEventListener("input",r),e.removeEventListener("compositionstart",l),e.removeEventListener("compositionend",s)}},[h]),(0,s.useEffect)(()=>{if(!en)return;let e=e=>{let t=e.target;if(t&&(t.closest("input, textarea")||t.isContentEditable)||h.isEditing)return;let r=e.shiftKey?10:1,l={ArrowLeft:[-r,0],ArrowRight:[r,0],ArrowUp:[0,-r],ArrowDown:[0,r]}[e.key];l&&(e.preventDefault(),eu(l[0],l[1]))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[en,eu,h.isEditing]);let em=(0,s.useCallback)(()=>{R(!1);let e=j.current;e&&(ep(e.currentTime),ec(e.currentTime))},[ec,ep]),ey=(0,s.useCallback)(()=>{let e=j.current;e&&(ep(e.currentTime),e.paused&&ec(e.currentTime))},[ec,ep]);(0,s.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>R(!0),r=()=>{_(e.duration||0),A(e.currentTime)},l=()=>{A(e.currentTime),ep(e.currentTime)};return e.addEventListener("play",t),e.addEventListener("pause",em),e.addEventListener("seeked",ey),e.addEventListener("loadedmetadata",r),e.addEventListener("timeupdate",l),e.readyState>=1&&r(),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",em),e.removeEventListener("seeked",ey),e.removeEventListener("loadedmetadata",r),e.removeEventListener("timeupdate",l)}},[em,ey,ep]),(0,s.useEffect)(()=>{if(!F){Y.current&&cancelAnimationFrame(Y.current),Y.current=null;return}let e=()=>{let t=j.current;t&&(A(t.currentTime),ep(t.currentTime),Y.current=requestAnimationFrame(e))};return Y.current=requestAnimationFrame(e),()=>{Y.current&&cancelAnimationFrame(Y.current),Y.current=null}},[F,ep]),(0,s.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>h.seek?.(1e3*e.currentTime);return e.addEventListener("timeupdate",t),()=>e.removeEventListener("timeupdate",t)},[h]);let eg=(0,s.useCallback)(async()=>{let e=j.current;if(e)if(e.paused){D("0%");try{await ed((e,t)=>D(t?`${Math.round(e/t*100)}%`:null))}catch(e){console.error("preparePlayback failed:",e)}finally{D(null)}e.play()}else e.pause()},[ed]),eC=(0,s.useCallback)(e=>{let t=j.current;if(!t)return;let r=Math.min(Math.max(t.currentTime+e,0),t.duration||0);t.currentTime=r,A(r),ep(r)},[ep]),ev=(0,s.useCallback)(e=>{let t=j.current;if(!t||!$)return;let r=e.currentTarget.getBoundingClientRect(),l=(e.clientX-r.left)/r.width*$;t.currentTime=l,A(l),ep(l)},[$,ep]),ew=(0,s.useCallback)(()=>{en?ef(!1):eg()},[en,ef,eg]),ek=e=>{let t=S.current.getBoundingClientRect();return[(e.clientX-t.left)*r/t.width,(e.clientY-t.top)*c/t.height]},ej=(e,t)=>[[t.x1-6,t.y1-6],[t.x2+6,t.y1-6],[t.x1-6,t.y2+6],[t.x2+6,t.y2+6]].findIndex(([t,r])=>18>=Math.abs(e[0]-t)&&18>=Math.abs(e[1]-r)),eS=e=>1===e||2===e?'url("/subtitle-editor/cursor-resize-flip.svg") 12 12, nesw-resize':o,eE=(0,s.useRef)(null),eM=(0,s.useRef)(null),eN=e=>{eE.current&&(h.resizeEnd(),eE.current=null,P(!1));let t=eM.current;if(!t||t.pointerId!==e.pointerId)return;let l=t.lastCanvasX-t.startCanvasX,s=t.lastCanvasY-t.startCanvasY;if(eM.current=null,Math.abs(l)+Math.abs(s)<=2)return void h.dragEnd(0,0,{left:0,top:0,width:1,height:1});let n=k.current?.getBoundingClientRect();if(!n)return;let a=l*n.width/r,i=s*n.height/c,o={left:0,top:0,width:n.width,height:n.height};h.dragEnd(a,i,o)},eL=Q?{left:`${Q.x/r*100}%`,top:`${Q.y/c*100}%`,width:`${Q.w/r*100}%`,height:`${Q.h/c*100}%`,transform:ee?`translate(${ee.x}px, ${ee.y}px)`:void 0}:void 0,eF="relative flex h-8 w-8 items-center justify-center rounded-full transition-colors hover:bg-white/15 disabled:opacity-50";return(0,l.jsx)("div",{ref:w,className:`flex w-full flex-col items-center${f?` ${f}`:""}`,"data-testid":"subtitle-edit-overlay-unit",children:(0,l.jsxs)("div",{ref:k,className:"relative max-w-full select-none overflow-hidden rounded bg-black",style:{aspectRatio:`${r} / ${c}`,width:N?`${N.width}px`:"100%",height:N?`${N.height}px`:void 0,outline:ex&&!F&&(et?.x!=null||et?.y!=null)?"1px solid #CEFF02":void 0}
1,children:[(0,l.jsx)("video",{ref:j,src:e,poster:t,playsInline:!0,muted:I,className:`absolute inset-0 h-full w-full ${p??""}`,onClick:ew,style:{zIndex:0}}),(0,l.jsx)("canvas",{ref:h.renderCanvasRef,width:r,height:c,className:"pointer-events-none absolute inset-0 h-full w-full",style:{zIndex:1}}),ex&&!F&&(x=r*a.rg,b=c*a.rg,m=et?.x!=null&&(et.x===x||et.x===r-x),y=et?.y!=null&&(et.y===b||et.y===c-b),g=et?.x!=null&&!m,C=et?.y!=null&&!y,(0,l.jsxs)(l.Fragment,{children:[(m||y)&&(0,l.jsx)("div",{className:"pointer-events-none absolute z-[13] border border-solid",style:{left:`${100*a.rg}%`,top:`${100*a.rg}%`,right:`${100*a.rg}%`,bottom:`${100*a.rg}%`,borderColor:"#CEFF02"}}),g&&(0,l.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-1/2 z-[13] w-px",style:{backgroundColor:"#CEFF02"}}),C&&(0,l.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 z-[13] h-px",style:{backgroundColor:"#CEFF02"}})]})),eL&&!F&&"ready"===er&&(0,l.jsx)("div",{"data-testid":"subtitle-selbox",className:"pointer-events-none absolute z-[14] rounded-xs border-2 border-white/30",style:{...eL,boxShadow:"0 0 4px 0 rgba(0,0,0,0.10)"}}),(0,l.jsx)("canvas",{ref:S,width:r,height:c,className:"absolute inset-0 h-full w-full",style:{zIndex:15,cursor:h.isEditing?"text":U?Z:ex?i:B,pointerEvents:F?"none":"auto"},onPointerDown:e=>{let t,r,l=ek(e),s=!h.isEditing&&J?ej(l,J):-1;if(J&&s>=0){let t=[(J.x1+J.x2)/2,(J.y1+J.y2)/2],r=Math.hypot(l[0]-t[0],l[1]-t[1]);if(r>4){eE.current={index:J.idx,anchor:t,startDist:r},W(eS(s)),P(!0),h.resizeStart(J.idx),S.current?.setPointerCapture(e.pointerId);return}}if(h.isEditing){if(J&&l[0]>=J.x1-8&&l[0]<=J.x2+8&&l[1]>=J.y1-8&&l[1]<=J.y2+8){h.caretSet(l[0],l[1]),E.current?.focus();return}h.exitEdit();return}h.hit(l[0],l[1],e.pointerId),S.current?.setPointerCapture(e.pointerId);let n=J?(t=(J.align-1)%3,r=Math.floor((J.align-1)/3),{x:0===t?J.x1:1===t?(J.x1+J.x2)/2:J.x2,y:0===r?J.y2:1===r?(J.y1+J.y2)/2:J.y1}):null,a=n?[n.x,n.y]:[l[0],l[1]];eM.current={startCanvasX:l[0],startCanvasY:l[1],lastCanvasX:l[0],lastCanvasY:l[1],pointerId:e.pointerId,anchor:a},h.dragStart(J?{index:J.idx,anchor:{x:a[0],y:a[1]}}:void 0)},onPointerMove:e=>{let t=ek(e);if(eE.current){let{anchor:e,startDist:r,index:l}=eE.current,s=Math.hypot(t[0]-e[0],t[1]-e[1]);r>0&&h.resize(l,s/r);return}if(!eM.current&&!h.isEditing&&J){let e=ej(t,J);e>=0?G(eS(e)):G(t[0]>=J.x1&&t[0]<=J.x2&&t[1]>=J.y1&&t[1]<=J.y2?i:"default")}let l=eM.current;if(!l||l.pointerId!==e.pointerId||h.isEditing)return;l.lastCanvasX=t[0],l.lastCanvasY=t[1];let s=k.current?.getBoundingClientRect();if(s){let e=(t[0]-l.startCanvasX)*s.width/r,n=(t[1]-l.startCanvasY)*s.height/c;h.dragMove(e,n,s)}},onPointerUp:eN,onPointerLeave:e=>{eN(e),G("default")},onDoubleClick:e=>{let t=ek(e);eM.current=null,h.editAt(t[0],t[1])}}),(0,l.jsx)("input",{ref:E,style:{position:"fixed",left:-9999,top:0,width:1,height:1,opacity:0,zIndex:3},"aria-hidden":"true"}),!ex&&(0,l.jsxs)("div",{className:"absolute inset-x-0 bottom-0 z-[16] flex flex-col items-center gap-2 bg-gradient-to-b from-transparent to-[rgba(8,9,13,0.3)] p-2 backdrop-blur-[2px]",children:[(0,l.jsx)("div",{className:"w-full h-[12px] flex items-center cursor-pointer",onClick:ev,role:"slider","aria-label":"seek","aria-valuemin":0,"aria-valuemax":$,"aria-valuenow":z,children:(0,l.jsx)("div",{className:"w-full h-0.5 relative rounded-md bg-white/30",children:(0,l.jsx)("div",{className:"absolute left-0 top-0 h-0.5 rounded-md bg-[#d9d9d9]",style:{width:$?`${z/$*100}%`:"0%"}})})}),(0,l.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-[4.478px]",children:[(0,l.jsx)("button",{type:"button",onClick:()=>void eg(),disabled:null!==T,"data-testid":"subtitle-editor-play",className:eF,"aria-label":v(F?"subtitleEditor.pause":"subtitleEditor.play"),children:F?(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[(0,l.jsx)("path",{d:"M9.52 2.07C9.52 1.66 9.86 1.33 10.29 1.33H12.57C12.99 1.33 13.33 1.66 13.33 2.07V13.93C13.33 14.34 12.99 14.67 12.57 14.67H10.29C9.86 14.67 9.52 14.34 9.52 13.93V2.07Z",fill:"white"}),(0,l.jsx)("path",{d:"M2.67 2.07C2.67 1.66 3.01 1.33 3.43 1.33H5.71C6.14 1.33 6.48 1.66 6.48 2.07V13.93C6.48 14.34 6.14 14.67 5.71 14.67H3.43C3.01 14.67 2.67 14.34 2.67 13.93V2.07Z",fill:"white"})]}):(0,l.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,l.jsx)("path",{d:"M4 2.5C4 1.93 4.62 1.58 5.11 1.87L13.61 7.37C14.06 7.66 14.06 8.34 13.61 8.63L5.11 14.13C4.62 14.42 4 14.07 4 13.5V2.5Z",fill:"white"})})}),(0,l.jsx)("button",{type:"button",onClick:()=>eC(-5),className:eF,"aria-label":v("subtitleEditor.seekBack"),children:(0,l.jsxs)("svg",{width:"18",height:"19",viewBox:"0 0 17.3334 18.6667",fill:"none",style:{overflow:"visible"},children:[(0,l.jsx)("path",{d:"M7.66668 12.3748C7.87559 12.5579 8.13528 12.6663 8.41668 12.6663C9.10703 12.6663 9.66668 12.0134 9.66668 11.208C9.66668 10.4026 9.10703 9.74968 8.41668 9.74968C8.13528 9.74968 7.87559 9.85816 7.66668 10.0412L7.91668 7.99968H9.66668",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),(0,l.jsx)("path",{d:"M3.21071 4.53608C-0.0206005 7.46516 -0.197377 12.386 2.81587 15.527C5.82912 18.6681 10.8913 18.8399 14.1226 15.9108C17.354 12.9818 17.5307 8.06095 14.5175 4.91989C12.8035 3.13326 10.4267 2.30727 8.10092 2.46616M9.23811 0.66667L7.20053 2.5553L9.23811 4.58066",stroke:"white",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}),(0,l.jsx)("button",{type:"button",onClick:()=>eC(5),className:eF,"aria-label":v("subtitleEditor.seekForward"),children:(0,l.jsxs)("svg",{width:"18",height:"19",viewBox:"0 0 17.3334 18.6667",fill:"none",style:{overflow:"visible"},children:[(0,l.jsx)("path",{d:"M7.66668 12.3748C7.87559 12.5579 8.13528 12.6663 8.41668 12.6663C9.10703 12.6663 9.66668 12.0134 9.66668 11.208C9.66668 10.4026 9.10703 9.74968 8.41668 9.74968C8.13528 9.74968 7.87559 9.85816 7.66668 10.0412L7.91668 7.99968H9.66668",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),(0,l.jsx)("path",{d:"M14.1226 4.53608C17.354 7.46516 17.5307 12.386 14.5175 15.527C11.5042 18.6681 6.44202 18.8399 3.21071 15.9108C-0.0206008 12.9818 -0.197377 8.06095 2.81587 4.91989C4.52981 3.13326 6.90667 2.30727 9.23243 2.46616M8.09525 0.66667L10.1328 2.5553L8.09525 4.58066",stroke:"white",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]})}),T&&(0,l.jsxs)("span",{className:"ml-1 text-xs text-white/80",children:[v("subtitleEditor.rendering")," ",T]}),(0,l.jsxs)("span",{className:"ml-1 text-sm text-white/80 whitespace-nowrap font-medium tabular-nums",children:[u(F?z:es)," / ",u($)]})]}),(0,l.jsx)("button",{type:"button",onClick:()=>H(e=>!e),className:eF,"aria-label":v("subtitleEditor.volume"),children:(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:I?"opacity-40":void 0,children:[(0,l.jsx)("path",{d:"M14.535 5.33333C14.6221 6.21042 14.6667 7.1 14.6667 8C14.6667 8.9 14.6221 9.78958 14.535 10.6667",stroke:"white",strokeLinecap:"round"}),(0,l.jsx)("path",{d:"M11.9178 6C11.9722 6.65947 12 7.32649 12 8C12 8.67351 11.9722 9.34053 11.9178 10",stroke:"white",strokeLinecap:"round"}),(0,l.jsx)("path",{d:"M8.66667 8C8.66667 6.30542 8.52324 4.64674 8.24868 3.03712C8.1663 2.55415 7.60183 2.34214 7.21166 2.63848L5.02418 4.2999C4.79223 4.47606 4.50899 4.57143 4.21773 4.57143H2C1.26362 4.57143 0.666667 5.16838 0.666667 5.90476V10.0952C0.666667 10.8316 1.26362 11.4286 2 11.4286H4.21773C4.50899 11.4286 4.79223 11.5239 5.02418 11.7001L7.21166 13.3615C7.60183 13.6579 8.1663 13.4459 8.24868 12.9629C8.52324 11.3533 8.66667 9.69458 8.66667 8Z",fill:"white",stroke:"white",strokeWidth:"0.666667",strokeLinejoin:"round"})]})})]})]}),"error"===er&&(0,l.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 p-4",children:(0,l.jsx)("span",{className:"text-sm text-red-400","data-testid":"subtitle-editor-error",children:el})})]})})}},40028:(e,t,r)=>{function l(e){let t=e.split("\n"),r=function(e){let t=!1;for(let r of e){let e=r.trim();if(e.startsWith("[")&&(t=/^\[events\]/i.test(e)),t&&e.startsWith("Format:"))return e.slice(7).split(",").map(e=>e.trim().toLowerCase())}return["layer","start","end","style","name","marginl","marginr","marginv","effect","text"]}
1(t),l=r.indexOf("start"),s=r.indexOf("end"),n=r.indexOf("style"),a=r.indexOf("text"),i=[];return t.forEach((e,t)=>{if(e.startsWith("Dialogue:")){let r=e.slice(9).split(","),o=r.slice(a).join(",").replace(/^\s/,"");i.push({lineIdx:t,start:r[l]?.trim()??"",end:r[s]?.trim()??"",style:r[n]?.trim()??"",text:o,_iStart:l,_iEnd:s,_iText:a})}}),{lines:t,cues:i}}function s(e,t){let r=[...e];for(let e of t){let t=r[e.lineIdx].slice(9).split(",");t[e._iStart]=e.start,t[e._iEnd]=e.end;let l=t.slice(0,e._iText).join(",");r[e.lineIdx]="Dialogue:"+l+","+e.text}return r.join("\n")}function n(e,t={x:1920,y:1080}){let{x:r,y:l}=t;for(let t of e.split("\n")){let e=t.match(/^\s*PlayResX\s*:\s*(\d+)/i);e&&(r=+e[1]);let s=t.match(/^\s*PlayResY\s*:\s*(\d+)/i);s&&(l=+s[1])}return{x:r,y:l}}function a(e){let t=e.split("\n"),r=null,l=!1,s={};return t.forEach((e,t)=>{let n=e.trim();if(n.startsWith("[")&&(l=/^\[v4\+? styles\]/i.test(n)),l){if(n.startsWith("Format:"))r=n.slice(7).split(",").map(e=>e.trim().toLowerCase());else if(n.startsWith("Style:")&&r){let e=n.slice(6).split(","),l={};r.forEach((t,r)=>{l[t]=void 0!==e[r]?e[r].trim():""}),s[l.name]={lineIdx:t,fmt:r,rec:l}}}}),s}function i(e,t,r){let l=e.split("\n"),s=a(e)[t];if(!s)return e;let n={...s.rec,...r};return l[s.lineIdx]="Style: "+s.fmt.map(e=>n[e]??"").join(","),l.join("\n")}r.d(t,{$Z:()=>b,Fx:()=>h,JG:()=>w,Je:()=>R,L:()=>S,Ml:()=>j,Op:()=>a,ZK:()=>n,ap:()=>v,dk:()=>k,eV:()=>d,fq:()=>L,ig:()=>m,j2:()=>C,nX:()=>i,oj:()=>E,r3:()=>F,rg:()=>M,t0:()=>g,uF:()=>N,z7:()=>s,z8:()=>l,zK:()=>y,zs:()=>o});let o="Noto Sans SC",u="Noto Sans SC",d=[{id:"homemade-apple",label:"Homemade Apple",assFamily:"Homemade Apple",cssFamily:'"Homemade Apple", "Noto Sans SC", cursive',patch:{fontname:"Homemade Apple",bold:!1}},{id:"playwrite-au-vic-guides",label:"Playwrite AU VIC Guides",assFamily:"Playwrite AU VIC Guides",cssFamily:'"Playwrite AU VIC Guides", "Noto Sans SC", cursive',patch:{fontname:"Playwrite AU VIC Guides",bold:!1}},{id:"honk",label:"Honk",assFamily:"Honk",cssFamily:'"Honk", "Noto Sans SC", fantasy',patch:{fontname:"Honk",bold:!1}},{id:"dm-sans",label:"DM Sans Regular",assFamily:"DM Sans",cssFamily:'"DM Sans", "Noto Sans SC", sans-serif',patch:{fontname:"DM Sans",bold:!1}},{id:"montserrat",label:"Montserrat Regular",assFamily:"Montserrat",cssFamily:'"Montserrat", "Noto Sans SC", sans-serif',patch:{fontname:"Montserrat",bold:!1}},{id:"inter",label:"Inter Regular",assFamily:"Inter",cssFamily:'"Inter", "
1Noto Sans SC", sans-serif',patch:{fontname:"Inter",bold:!1}},{id:"noto-sans-sc",label:"Noto Sans SC",assFamily:u,cssFamily:'"Noto Sans SC", sans-serif',patch:{fontname:u,bold:!1}}],c=d.map(e=>e.assFamily);function h(e){let t=e,r=a(t);for(let e of Object.keys(r)){let l=r[e].rec.fontname??"";c.some(e=>e.toLowerCase()===l.toLowerCase())||(t=i(t,e,{fontname:o}))}return t}let f=/^(?:\{[^}]*\})+/,p=/\{[^}]*\}/g,x=/[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff00-\uffef\uac00-\ud7af]+/gu;function b(e){return e.replace(p,"").replace(/\\[Nn]/g,"\n").replace(/\\h/g," ")}function m(e,t){return(e.match(f)?.[0]??"")+t.replace(/\r\n?/g,"\n").split("\n").join("\\N")}function y(e,t){let r=t?.trim()||o;x.lastIndex=0;let l=x.test(e);if(x.lastIndex=0,(r??"").trim().toLowerCase()===u.toLowerCase()||!l)return e;let s="",n=0,a=e=>{x.lastIndex=0,s+=e.replace(x,e=>`{\\fn${u}}${e}{\\fn${r}}`)};for(let t of(p.lastIndex=0,e.matchAll(p))){let r=t.index??0;a(e.slice(n,r)),s+=t[0],n=r+t[0].length}return a(e.slice(n)),s}function g(e){if(!e)return"#ffffff";let t=e.trim().replace(/^&?H/i,"").replace(/&$/,"").padStart(8,"0"),r=t.slice(2,4),l=t.slice(4,6);return("#"+t.slice(6,8)+l+r).toLowerCase()}function C(e,t="00"){let r=e.replace("#","").padStart(6,"0"),l=r.slice(0,2),s=r.slice(2,4);return("&H"+t+r.slice(4,6)+s+l).toUpperCase()}function v(e,t,r,l){return{x:e*(l.x/r.width),y:t*(l.y/r.height)}}function w(e,t,r){let l=t.width/r.x,s=t.height/r.y;return{left:e.x*l,top:e.y*s,width:e.w*l,height:e.h*s}}function k(e,t,r,l,s){let n=r/2,a=l/2,i=s.x-n,o=s.y-a;return{x:i>=n?Math.min(Math.max(e,n),i):s.x/2,y:o>=a?Math.min(Math.max(t,a),o):s.y/2}}function j(e,t){let r=parseInt(e.alignment||"2",10)||2,l=parseFloat(e.marginl||"0")||0,s=parseFloat(e.marginr||"0")||0,n=parseFloat(e.marginv||"0")||0,a=(r-1)%3,i=Math.floor((r-1)/3);return{x:0===a?l:1===a?l+(t.x-l-s)/2:t.x-s,y:0===i?t.y-n:1===i?t.y/2:n,an:r}}function S(e){let t=e.match(/\\pos\(\s*([\d.+-]+)\s*,\s*([\d.+-]+)\s*\)/);return t?{x:parseFloat(t[1]),y:parseFloat(t[2])}:null}function E(e){let t=e.match(/\\an(\d)/);return t?parseInt(t[1],10):null}let M=.05;function N(e,t,r){let l=t.x*M,s=t.y*M,n=[[e.x+e.w/2,t.x/2],[e.x,l],[e.x+e.w,t.x-l]],a=[[e.y+e.h/2,t.y/2],[e.y,s],[e.y+e.h,t.y-s]],i=e=>{let t=0,l=null,s=r;for(let[r,n]of e){let e=Math.abs(n-r);e<=s&&(s=e,t=n-r,l=n)}return{delta:t,guide:l}},o=i(n),u=i(a);return{dx:o.delta,dy:u.delta,guideX:o.guide,guideY:u.guide}}function L(e){let t=String(e).trim().match(/(\d+):(\d{2}):(\d{2})[.](\d{1,2})/);return t?3600*t[1]+60*t[2]+ +t[3]+ +`0.${t[4]}`:0}function F(e){let t=Math.max(0,e),r=Math.floor(t/3600),l=Math.floor(t%3600/60),s=Math.floor(t%60),n=Math.round((t-Math.floor(t))*100),a=e=>String(e).padStart(2,"0");return`${r}:${a(l)}:${a(s)}.${a(100===n?99:n)}`}function R(e,t){return(L(e)+L(t))/2}},61482:(e,t,r)=>{r.d(t,{P$:()=>i,VU:()=>o,rv:()=>n,v:()=>s});var l=r(40028);class s{constructor(e){this.globalOffset={x:0,y:0},this.xCorrections=null,this._lines=[],this._cues=[],this._raw=(0,l.Fx)(e),this.playRes=(0,l.ZK)(this._raw),this._reparse(),this._healLegacyPositions()}_healLegacyPositions(){if(this._cues.length<2)return;let e=[];for(let t of this._cues){if(!/\\an5\\pos\(/.test(t.text))return;let r=(0,l.L)(t.text);if(!r)return;e.push(r)}let t=e.map(e=>e.y);if(Math.max(...t)-Math.min(...t)>40)return;let r=e=>{let t=[...e].sort((e,t)=>e-t);return t[Math.floor(t.length/2)]},s=Math.round(r(e.map(e=>e.x))),n=Math.round(r(t));for(let e of this._cues)e.text=e.text.replace(/\\pos\([^)]*\)/,`\\pos(${s},${n})`);this._raw=(0,l.z7)(this._lines,this._cues),this._reparse()}_reparse(){let{lines:e,cues:t}=(0,l.z8)(this._raw);this._lines=e,this._cues=t}getEvents(){return this._cues.map((e,t)=>({index:t,start:e.start,end:e.end,style:e.style,text:e.text,displayText:(0,l.$Z)(e.text)}))}getStyles(){return(0,l.Op)(this._raw)}getStyleSummary(){let e=(0,l.Op)(this._raw),t=Object.keys(e)[0],r=e[t]?.rec??{};return{fontname:r.fontname||"Noto Sans SC",fontsize:parseFloat(r.fontsize||"48"),primary:(0,l.t0)(r.primarycolour),outlineColor:(0,l.t0)(r.outlinecolour),outline:parseFloat(r.outline||"0"),bold:"0"!==(r.bold||"0"),italic:"0"!==(r.italic||"0"),alignment:parseInt(r.alignment||"2",10)}}getAnchor(e){let t=this._cues[e];if(!t)return null;let r=(0,l.Op)(this._raw)[t.style]?.rec??{},s=(0,l.Ml)(r,this.playRes),n=(0,l.L)(t.text),a=(0,l.oj)(t.text)??s.an;return n?{...n,an:a}:{x:s.x,y:s.y,an:a}}setXCorrections(e){this.xCorrections=e}translateAll(e,t){this.globalOffset.x+=e,this.globalOffset.y+=t}resetGlobalOffset(){this.globalOffset={x:0,y:0}}setGlobalStyleFields(e){let t=this._raw;for(let r of Object.keys((0,l.Op)(t)))t=(0,l.nX)(t,r,e);this._raw=t,this._reparse()}applyGlobalStyle(e){let t={};if(void 0!==e.fontname&&(t.fontname=e.fontname),void 0!==e.fontsize&&(t.fontsize=String(e.fontsize)),void 0!==e.primary&&(t.primarycolour=(0,l.j2)(e.primary)),void 0!==e.outlineColor&&(t.outlinecolour=(0,l.j2)(e.outlineColor)),void 0!==e.outline&&(t.outline=e.outline.toFixed(2)),void 0!==e.bold&&(t.bold=e.bold?"-1":"0"),void 0!==e.italic&&(t.italic=e.italic?"-1":"0"),this.setGlobalStyleFields(t),void 0!==e.fontsize){let e=!1;for(let t of this._cues){let r=t.text.replace(/\\fs[\d.+-]+/g,"");r!==t.text&&(t.text=r,e=!0)}e&&(this._raw=(0,l.z7)(this._lines,this._cues),this._reparse())}}setEventText(e,t){this._cues[e]&&(this._cues[e].text=(0,l.ig)(this._cues[e].text,t),this._raw=(0,l.z7)(this._lines,this._cues),this._reparse())}setEventTime(e,t,r){this._cues[e]&&(null!=t&&(this._cues[e].start=t),null!=r&&(this._cues[e].end=r),this._raw=(0,l.z7)(this._lines,this._cues),this._reparse())}baseAssForRender(){let e=(0,l.Op)(this._raw),t=this._cues.map(t=>{let r=e[t.style]?.rec??{},s=(0,l.zK)(t.text,r.fontname||l.zs);return s===t.text?t:{...t,text:s}});return(0,l.z7)(this._lines,t)}toAss(){let e=this.globalOffset,t=(0,l.Op)(this._raw),r=this._cues.map((r,s)=>{let n=t[r.style]?.rec??{},a=(0,l.L)(r.text),i=(0,l.oj)(r.text),o=(0,l.Ml)(n,this.playRes),u=a??{x:o.x,y:o.y},d=i??o.an,c=this.xCorrections?.[s]??0,h=r.text;if(0!==e.x||0!==e.y||Math.abs(c)>=1){let t=(0,l.dk)(u.x+c+e.x,u.y+e.y,1,1,this.playRes);h=h.replace(/\\pos\([^)]*\)/g,"").replace(/\\an\d/g,"");let r=`\\an${d}\\pos(${Math.round(t.x)},${Math.round(t.y)})`;h=h.startsWith("{")?h.replace("{",`{${r}`):`{${r}}`+h}return(h=(0,l.zK)(h,n.fontname||l.zs))===r.text?r:{...r,text:h}});return(0,l.z7)(this._lines,r)}baseAss(){return(0,l.z7)(this._lines,this._cues)}}function n(e){let t=e.toLowerCase();return t.includes("[events]")&&t.includes("dialogue:")?"ass":"vtt"}function a(e){let t=e.trim().match(/(?:(\d+):)?(\d{1,2}):(\d{2})[.,](\d{1,3})/);return t?(t[1]??0)*3600+60*t[2]+ +t[3]+ +`0.${t[4]}`:0}function i(e,t,r){let s=e.replace(/\r/g,"").split("\n"),n=`[Script Info]
2ScriptType: v4.00+
3PlayResX: ${t}
4PlayResY: ${r}
5WrapStyle: 2
6ScaledBorderAndShadow: yes
7YCbCr Matrix: TV.601
8
9[V4+ Styles]
10Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
11Style: Default,Noto Sans SC,48,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,
110,0,0,0,100,100,2.00,0,1,3.00,2.00,2,50,50,80,1
12
13[Events]
14Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
15`,i=0;for(;i<s.length;){let e=s[i].match(/([\d:.,]+)\s*-->\s*([\d:.,]+)/);if(e){let t=(0,l.r3)(a(e[1])),r=(0,l.r3)(a(e[2])),o=[];for(i++;i<s.length&&""!==s[i].trim();)o.push(s[i]),i++;let u=o.join("\\N").replace(/<[^>]+>/g,"").trim();u&&(n+=`Dialogue: 0,${t},${r},Default,,0,0,0,,${u}
16`)}i++}return n}function o(e,t,r){return"ass"===n(e)?e:i(e,t,r)}},82575:(e,t,r)=>{r.r(t),r.d(t,{AssDocument:()=>l.v,GlobalStylePanel:()=>L,SubtitleCueList:()=>N,SubtitleEditToolbar:()=>m,SubtitleEditorPanel:()=>M,SubtitleGlyphIcon:()=>F.U,detectSubtitleFormat:()=>l.rv,normalizeFontnames:()=>s.Fx,toEditableAss:()=>l.VU,useSubtitleExport:()=>u,useUnitAssEditing:()=>n.J,vttToAss:()=>l.P$});var l=r(61482),s=r(40028),n=r(7624),a=r(12115),i=r(83881),o=r(75499);function u(){let[e,t]=(0,a.useState)("idle"),[r,l]=(0,a.useState)(0);return{stage:e,progress:r,saveSubtitleVersion:(0,a.useCallback)(async(e,r)=>{try{t("uploading"),l(0);let s=new File([e],`subtitle-edited-${Date.now()}.ass`,{type:"text/x-ssa"}),n=await (0,o.Tn)(s,{type:"subtitle"},e=>l(Math.round(e)));t("saving");let a=await i.uE.post(`/user_assets/${r.id}/subtitles`,{fileUrl:n.url,mimeType:"text/x-ssa",title:"Edited"});if(!a.success)throw Error("save subtitle version failed");return{subtitleUrl:n.url,asset:a.data}}finally{t("idle")}},[]),burnVideo:(0,a.useCallback)(async(e,r)=>{try{t("uploading"),l(0);let s=new File([e],`subtitle-burn-${Date.now()}.ass`,{type:"text/x-ssa"}),n=await (0,o.Tn)(s,{type:"subtitle"},e=>l(Math.round(e)));t("burning");let a=await fetch("/api/v1/burn-subtitle",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({video_url:r,subtitle_url:n.url})});if(!a.ok)throw Error(`burn-subtitle failed: ${a.status}`);let i=await a.json();if(!i.success||!i.video_url)throw Error(i.error||"burn-subtitle failed");return i.video_url}finally{t("idle")}},[])}}var d=r(95155),c=r(47650),h=r(6296),f=r(5785),p=r(89045),x=r(70872);let b=[{id:"white",c:"#ffffff"},{id:"black",c:"#000000"},{id:"purple",c:"#ad5ffa"},{id:"blue",c:"#3b7ef2"},{id:"green",c:"#79d375"},{id:"yellow",c:"#f7d054"},{id:"red",c:"#e7464b"}];function m({controller:e,onExit:t,onDone:r,doneLabel:l,doneDisabled:n=!1}){let{t:i}=(0,p.s)(),o=(0,a.useRef)(null),[u,c]=(0,a.useState)(null),h=e.styleSummary,f="loading-engine"===e.status||"error"===e.status,S=(0,a.useCallback)(e=>c(t=>t===e?null:e),[]);(0,a.useEffect)(()=>{if(!u)return;let e=e=>{o.current?.contains(e.target)||c(null)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[u]),(0,a.useEffect)(()=>{let t=t=>{if(!(t.metaKey||t.ctrlKey)||"z"!==t.key.toLowerCase())return;let r=t.target;r&&(r.closest("input, textarea")||r.isContentEditable)||(t.preventDefault(),t.shiftKey?e.redo():e.undo())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e]);let E=(0,a.useCallback)(()=>{c(null),e.setSelected(!1),r?.()},[e,r]),M=e=>"group flex h-9 w-9 items-center justify-center rounded-full transition-colors disabled:cursor-default disabled:bg-transparent "+(e?"bg-[#e7e7e7] dark:bg-white/15":"bg-transparent hover:bg-[#e7e7e7] dark:hover:bg-white/15"),N=e=>"transition-colors group-disabled:text-black/15 dark:group-disabled:text-white/15 "+(e?"text-black/50 dark:text-white/70":"text-black/30 group-hover:text-black/50 dark:text-white/40 dark:group-hover:text-white/70");return(0,d.jsxs)("div",{ref:o,className:"relative","data-testid":"subtitle-edit-toolbar",children:[(0,d.jsxs)("div",{className:`flex h-9 items-center ${t?"justify-between":"justify-end"}`,children:[t&&(0,d.jsx)("button",{type:"button",onClick:t,"aria-label":i("subtitleEditor.exit"),"data-testid":"subtitle-exit-btn",className:"flex h-9 w-9 items-center justify-center rounded-[10.8px] bg-[#f3f3f1] transition-colors hover:bg-[#eaeae7] active:bg-[#e2e2df] dark:bg-white/10 dark:hover:bg-white/15",children:(0,d.jsx)("svg",{width:"9",height:"11",viewBox:"0 0 8.88889 10.6667",fill:"none",className:"text-black/30 dark:text-white/50",children:(0,d.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.01294 5.70725C1.80762 5.49949 1.80762 5.16522 2.01294 4.95746L5.41545 1.51456C5.6225 1.30505 5.96018 1.30306 6.16968 1.51011C6.37919 1.71715 6.38118 2.05484 6.17413 2.26434L3.14212 5.33236L6.17413 8.40037C6.38118 8.60987 6.37919 8.94756 6.16968 9.1546C5.96018 9.36165 5.6225 9.35966 5.41545 9.15015L2.01294 5.70725Z",fill:"currentColor"})})}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"relative flex items-center",children:[(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f,onClick:()=>S("color"),"aria-label":i("subtitleEditor.captionColor"),"aria-haspopup":"true","data-testid":"subtitle-tool-color",className:M("color"===u),children:(0,d.jsx)(k,{})})}),"color"!==u&&(0,d.jsx)(x.ZI,{children:i("subtitleEditor.captionColor")})]}),"color"===u&&(0,d.jsx)("div",{role:"menu","aria-label":i("subtitleEditor.captionColor"),"data-testid":"subtitle-color-popover",className:"absolute left-0 top-[44px] z-30 flex h-[50px] items-center gap-2.5 rounded-[32px] bg-[#323234] px-6 py-3",children:b.map(({id:t,c:r})=>{let l=h?.primary?.toLowerCase()===r;return(0,d.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":l,"aria-label":t,"data-testid":`subtitle-color-${t}`,onClick:()=>{l||e.applyGlobalStyle({primary:r})},className:"relative h-[26px] w-[26px] shrink-0 rounded-full transition-transform hover:scale-110",style:l?{background:"transparent",border:`2.17px solid ${r}`,transform:"none"}:{background:r},children:l&&(0,d.jsx)("span",{className:"absolute left-1/2 top-1/2 h-[18.78px] w-[18.78px] -translate-x-1/2 -translate-y-1/2 roun
16ded-full",style:{background:r}})},t)})})]}),(0,d.jsx)(C,{}),(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f,onClick:()=>S("stroke"),"aria-label":i("subtitleEditor.stroke"),"aria-haspopup":"true","data-testid":"subtitle-tool-stroke",className:M("stroke"===u),children:(0,d.jsx)(w,{className:N("stroke"===u)})})}),"stroke"!==u&&(0,d.jsx)(x.ZI,{children:i("subtitleEditor.stroke")})]}),(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f,onClick:()=>S("font"),"aria-label":i("subtitleEditor.font"),"aria-haspopup":"true","data-testid":"subtitle-tool-font",className:M("font"===u),children:(0,d.jsx)(j,{className:N("font"===u)})})}),"font"!==u&&(0,d.jsx)(x.ZI,{children:i("subtitleEditor.font")})]}),(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f||!e.canUndo,onClick:()=>void e.undo(),"aria-label":i("subtitleEditor.undo"),"data-testid":"subtitle-tool-undo",className:M(!1),children:(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:N(!1),children:(0,d.jsx)("path",{d:"M5 13.292C4.58579 13.292 4.25 12.9562 4.25 12.542C4.25 12.1278 4.58579 11.792 5 11.792H9.575C10.3625 11.792 11.047 11.542 11.6285 11.042C12.21 10.542 12.5005 9.91699 12.5 9.16699C12.4995 8.41699 12.209 7.79199 11.6285 7.29199C11.048 6.79199 10.3635 6.54199 9.575 6.54199H4.85L6.275 7.96699C6.56495 8.25694 6.56495 8.72704 6.275 9.01699C5.98505 9.30694 5.51495 9.30694 5.225 9.01699L2 5.79199L5.225 2.56699C5.51495 2.27704 5.98505 2.27704 6.275 2.56699C6.56495 2.85694 6.56495 3.32704 6.275 3.61699L4.85 5.04199H9.575C10.7875 5.04199 11.8283 5.43574 12.6973 6.22324C13.5663 7.01074 14.0005 7.99199 14 9.16699C13.9995 10.342 13.5653 11.3232 12.6973 12.1107C11.8293 12.8982 10.7885 13.292 9.575 13.292H5Z",fill:"currentColor"})})})}),(0,d.jsx)(x.ZI,{children:i("subtitleEditor.undo")})]}),(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f||!e.canRedo,onClick:()=>void e.redo(),"aria-label":i("subtitleEditor.redo"),"data-testid":"subtitle-tool-redo",className:M(!1),children:(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:N(!1),children:(0,d.jsx)("path",{transform:"translate(16 0) scale(-1 1)",d:"M5 13.292C4.58579 13.292 4.25 12.9562 4.25 12.542C4.25 12.1278 4.58579 11.792 5 11.792H9.575C10.3625 11.792 11.047 11.542 11.6285 11.042C12.21 10.542 12.5005 9.91699 12.5 9.16699C12.4995 8.41699 12.209 7.79199 11.6285 7.29199C11.048 6.79199 10.3635 6.54199 9.575 6.54199H4.85L6.275 7.96699C6.56495 8.25694 6.56495 8.72704 6.275 9.01699C5.98505 9.30694 5.51495 9.30694 5.225 9.01699L2 5.79199L5.225 2.56699C5.51495 2.27704 5.98505 2.27704 6.275 2.56699C6.56495 2.85694 6.56495 3.32704 6.275 3.61699L4.85 5.04199H9.575C10.7875 5.04199 11.8283 5.43574 12.6973 6.22324C13.5663 7.01074 14.0005 7.99199 14 9.16699C13.9995 10.342 13.5653 11.3232 12.6973 12.1107C11.8293 12.8982 10.7885 13.292 9.575 13.292H5Z",fill:"currentColor"})})})}),(0,d.jsx)(x.ZI,{children:i("subtitleEditor.redo")})]}),(0,d.jsxs)(x.m_,{children:[(0,d.jsx)(x.k$,{asChild:!0,children:(0,d.jsx)("button",{type:"button",disabled:f,onClick:()=>{c(null),e.resetAll()},"aria-label":i("subtitleEditor.resetAll"),"data-testid":"subtitle-tool-reset",className:M(!1),children:(0,d.jsx)(v,{className:N(!1)})})}),(0,d.jsx)(x.ZI,{children:i("subtitleEditor.resetAll")})]})]}),(0,d.jsx)("button",{type:"button",disabled:n,onClick:E,"data-testid":"subtitle-done-btn",className:"flex h-9 items-center justify-center rounded-lg bg-[#252627] px-4 pb-2 pt-2.5 font-trap text-sm font-semibold text-white transition-colors hover:bg-[#3a3b3d] active:bg-[#1c1d1e] disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:bg-[#252627]",children:l??i("subtitleEditor.done")})]})]}),"stroke"===u&&(0,d.jsx)(y,{ariaLabel:i("subtitleEditor.stroke"),className:"right-[52px]",testid:"subtitle-stroke-dropdown",children:[{stroked:!1,label:i("subtitleEditor.noStroke")},{stroked:!0,label:i("subtitleEditor.strokeOn")}].map(({stroked:t,label:r})=>{let l=(!!h&&h.outline>0)===t;return(0,d.jsx)(g,{selected:l,testid:`subtitle-stroke-${t?"on":"off"}`,onClick:()=>{l||e.applyGlobalStyle(t?{outline:3,outlineColor:"#000000"}:{outline:0}),c(null)},children:r},String(t))})}),"font"===u&&(0,d.jsx)(y,{ariaLabel:i("subtitleEditor.font"),className:"right-0",testid:"subtitle-font-dropdown",children:s.eV.map(t=>{let r=h?.fontname===t.assFamily;return(0,d.jsx)(g,{selected:r,testid:`subtitle-font-${t.id}`,onClick:()=>{r||e.applyGlobalStyle({...t.patch}),c(null)},children:(0,d.jsx)("span",{className:"truncate text-base leading-5",style:{fontFamily:t.cssFamily,fontWeight:500},title:t.label,children:t.label})},t.id)})})]})}function y({children:e,ariaLabel:t,className:r,testid:l}){return(0,d.jsx)("div",{role:"menu","aria-label":t,"data-testid":l,className:`absolute top-[44px] z-30 flex w-[245px] flex-col gap-1 rounded-2xl border-[0.5px] border-[#e9eae6] bg-white p-2 drop-shadow-[0_0_10px_rgba(58,65,85,0.12)] dark:border-white/10 dark:bg-neutral-800 ${r??""}`,children:e})}function g({children:e,selected:t,onClick:r,testid:l}){return(0,d.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":t,"data-testid":l,onClick:r,className:`flex h-10 w-full items-center rounded py-2 pl-2 text-left text-sm leading-5 text-[#252627] transition-colors dark:text-neutral-100 ${t?"bg-[#ececea] dark:bg-white/15":"hover:bg-[#f3f3f1] dark:hover:bg-white/10"}`,children:e})}function C(){return(0,d.jsx)("svg",{width:"16",height:"34.5",viewBox:"0 0 16 34.5",fill:"none","aria-hidden":"true",className:"shrink-0 text-black dark:text-white",preserveAspectRatio:"none",children:(0,d.jsx)("path",{opacity:"0.1",d:"M8 12V22.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function v({className:e}){return(0,d.jsx)("svg",{width:"12",height:"12",viewBox:"11 11 14 14",fill:"none",className:e,children:(0,d.jsx)("path",{d:"M11.3359 18.0002C11.3359 21.6822 14.3206 24.6668 18.0026 24.6668C21.6846 24.6668 24.6693 21.6822 24.6693 18.0002C24.6693 14.5429 22.0378 11.7004 18.6684 11.3663C18.302 11.33 18.0026 11.632 18.0026 12.0002C18.0026 12.3684 18.3022 12.6626 18.6675 12.7085C19.7033 12.8388 20.6834 13.271 21.4818 13.9585C22.4495 14.7917 23.0862 15.9444 23.2761 17.2072C23.4659 18.47 23.1964 19.759 22.5165 20.8399C21.8365 21.9208 20.7913 22.7219 19.5709 23.0975C18.3504 23.4732 17.0356 23.3984 15.8656 22.8869C14.6955 22.3754 13.7479 21.461 13.1948 20.31C12.6418 19.159 12.52 17.8478 12.8518 16.6146C13.1835 15.3815 13.9467 14.3083 15.0026 13.5902V14.6668C15.0026 15.035 15.3011 15.3335 15.6693 15.3335C16.0375 15.3335 16.3359 15.035 16.3359 14.6668V11.3335H13.0026C12.6344 
1611.3335 12.3359 11.632 12.3359 12.0002C12.3359 12.3684 12.6344 12.6668 13.0026 12.6668H14.0026C13.1742 13.2875 12.5019 14.0926 12.0391 15.0184C11.5762 15.9442 11.3354 16.9651 11.3359 18.0002Z",fill:"currentColor"})})}function w({className:e}){return(0,d.jsx)("span",{className:`relative block h-4 w-4 ${e??""}`,"aria-hidden":"true",children:(0,d.jsxs)("svg",{width:"14.4444",height:"14.4444",viewBox:"0 0 14.4444 14.4444",fill:"none",className:"absolute left-[0.778px] top-[0.778px]",preserveAspectRatio:"none",style:{overflow:"visible"},children:[(0,d.jsx)("path",{d:"M12.6389 0.722222H1.80556C1.20725 0.722222 0.722222 1.20725 0.722222 1.80556V12.6389C0.722222 13.2372 1.20725 13.7222 1.80556 13.7222H12.6389C13.2372 13.7222 13.7222 13.2372 13.7222 12.6389V1.80556C13.7222 1.20725 13.2372 0.722222 12.6389 0.722222Z",stroke:"currentColor",strokeWidth:"1.44444",strokeLinejoin:"round"}),(0,d.jsx)("path",{d:"M4.33941 5.41688V4.33355H10.1172V5.41688M6.50608 10.8336H7.95052M7.2283 5.05577V10.8336",stroke:"currentColor",strokeWidth:"1.44444",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function k(){return(0,d.jsxs)("svg",{width:"26",height:"26",viewBox:"0 0 26 26",fill:"none",className:"-rotate-90",children:[(0,d.jsx)("circle",{cx:"13",cy:"13",r:"13",transform:"rotate(90 13 13)",fill:"white"}),(0,d.jsx)("mask",{id:"cp_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"26",height:"26",children:(0,d.jsx)("circle",{cx:"13",cy:"13",r:"13",transform:"rotate(90 13 13)",fill:"#C4C4C4"})}),(0,d.jsxs)("g",{mask:"url(#cp_mask)",children:[(0,d.jsxs)("g",{filter:"url(#cp_blur)",children:[(0,d.jsx)("ellipse",{cx:"25.28",cy:"13",rx:"7.94",ry:"7.94",fill:"#F7FF07"}),(0,d.jsx)("ellipse",{cx:"0.72",cy:"13",rx:"7.94",ry:"7.94",fill:"#532FF1"}),(0,d.jsx)("ellipse",{cx:"13",cy:"25.27",rx:"7.94",ry:"7.94",fill:"#F32E22"}),(0,d.jsx)("ellipse",{cx:"13",cy:"0.72",rx:"7.94",ry:"7.94",fill:"#2FFF65"})]}),(0,d.jsxs)("g",{opacity:"0.7",filter:"url(#cp_blur)",children:[(0,d.jsx)("ellipse",{cx:"21.68",cy:"21.68",rx:"7.94",ry:"7.94",transform:"rotate(45 21.68 21.68)",fill:"#DB8F4D"}),(0,d.jsx)("ellipse",{cx:"4.32",cy:"4.32",rx:"7.94",ry:"7.94",transform:"rotate(45 4.32 4.32)",fill:"#67BAE3"}),(0,d.jsx)("ellipse",{cx:"4.32",cy:"21.68",rx:"7.94",ry:"7.94",transform:"rotate(45 4.32 21.68)",fill:"#B351B2"}),(0,d.jsx)("ellipse",{cx:"21.68",cy:"4.32",rx:"7.94",ry:"7.94",transform:"rotate(45 21.68 4.32)",fill:"#97E45D"})]})]}),(0,d.jsx)("defs",{children:(0,d.jsxs)("filter",{id:"cp_blur",x:"-16",y:"-16",width:"58",height:"58",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,d.jsx)("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),(0,d.jsx)("feBlend",{mode:"normal",in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),(0,d.jsx)("feGaussianBlur",{stdDeviation:"4.33"})]})})]})}function j({className:e}){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,children:(0,d.jsx)("path",{d:"M9.14151 12.743L5.39151 2.74304C5.34238 2.61199 5.25442 2.49905 5.13939 2.41932C5.02435 2.33959 4.88773 2.29688 4.74776 2.29688C4.6078 2.29687 4.47117 2.33959 4.35614 2.41932C4.24111 2.49905 4.15314 2.61199 4.10401 2.74304L0.354013 12.743C0.291991 12.9133 0.299716 13.1012 0.37551 13.2658C0.451303 13.4305 0.589033 13.5585 0.75874 13.6221C0.928446 13.6857 1.1164 13.6797 1.28172 13.6055C1.44704 13.5312 1.57634 13.3947 1.64151 13.2255L2.77151 10.2124C2.77596 10.2005 2.78394 10.1902 2.79438 10.183C2.80483 10.1757 2.81723 10.1718 2.82995 10.1718H6.66558C6.67829 10.1718 6.6907 10.1757 6.70114 10.183C6.71158 10.1902 6.71956 10.2005 6.72401 10.2124L7.85401 13.2255C7.91918 13.3947 8.04849 13.5312 8.21381 13.6055C8.37913 13.6797 8.56708 13.6857 8.73679 13.6221C8.90649 13.5585 9.04422 13.4305 9.12002 13.2658C9.19581 13.1012 9.20354 12.9133 9.14151 12.743ZM3.33401 8.71179L4.68933 5.09773C4.69382 5.08587 4.70182 5.07566 4.71226 5.06846C4.7227 5.06125 4.73508 5.05739 4.74776 5.05739C4.76045 5.05739 4.77283 5.06125 4.78327 5.06846C4.7937 5.07566 4.8017 5.08587 4.8062 5.09773L6.16151 8.71242C6.16504 8.72186 6.16623 8.73202 6.16499 8.74203C6.16374 8.75203 6.16009 8.76159 6.15435 8.76988C6.14861 8.77817 6.14094 8.78494 6.13202 8.78963C6.12309 8.79432 6.11316 8.79677 6.10308 8.79679H3.39245C3.38237 8.79677 3.37244 8.79432 3.36351 8.78963C3.35458 8.78494 3.34692 8.77817 3.34118 8.76988C3.33544 8.76159 3.33179 8.75203 3.33054 8.74203C3.32929 8.73202 3.33048 8.72186 3.33401 8.71242V8.71179ZM12.5218 5.29679C11.2181 5.28742 10.0506 6.04273 9.55308 7.21554C9.4818 7.38337 9.48011 7.57265 9.54839 7.74172C9.61666 7.9108 9.74931 8.04583 9.91714 8.1171C10.085 8.18838 10.2742 8.19007 10.4433 8.12179C10.6124 8.05352 10.7474 7.92087 10.8187 7.75304C11.0962 7.10023 11.749 6.67679 12.485 6.67179C13.495 6.66492 14.3103 7.49992 14.3103 8.51085C14.3103 8.52302 14.3055 8.53471 14.2971 8.54346C14.2886 8.55221 14.2771 8.55732 14.265 8.55773C13.58 8.57679 12.7675 8.62242 12.0425 8.70773C10.3315 8.90898 9.31026 9.84179 9.31026 11.203C9.31026 11.9277 9.58401 12.578 10.0812 13.0368C10.5478 13.4665 11.1853 13.703 11.8728 13.703C12.8415 13.703 13.6756 13.453 14.3084 12.9774H14.3103C14.3099 13.0677 14.3273 13.1572 14.3615 13.2407C14.3957 13.3243 14.446 13.4003 14.5095 13.4644C14.5731 13.5285 14.6487 13.5795 14.7319 13.6144C14.8152 13.6493 14.9045 13.6675 14.9948 13.6679C15.0851 13.6683 15.1746 13.6509 15.2581 13.6167C15.3417 13.5825 15.4177 13.5322 15.4818 13.4686C15.5459 13.4051 15.5969 13.3295 15.6318 13.2462C15.6667 13.163 15.6849 13.0736 15.6853 12.9834V8.514
166C15.6853 6.75898 14.279 5.3096 12.5218 5.29679ZM11.8728 12.328C11.325 12.328 10.6853 12.0334 10.6853 11.203C10.6853 10.8696 10.805 10.6362 11.0737 10.4459C11.3353 10.2605 11.7362 10.1284 12.2031 10.0734C12.8631 9.99554 13.6037 9.95273 14.2387 9.93367C14.2472 9.93366 14.2556 9.93537 14.2634 9.9387C14.2712 9.94204 14.2782 9.94692 14.284 9.95306C14.2899 9.9592 14.2944 9.96647 14.2974 9.97441C14.3003 9.98236 14.3016 9.99082 14.3012 9.99929C14.2165 11.5655 13.4184 12.328 11.8728 12.328Z",fill:"currentColor"})})}var S=r(24377);let E={fontname:"字体",fontsize:"字号",primary:"颜色",outlineColor:"描边颜色",outline:"描边宽度",bold:"加粗",italic:"斜体",alignment:"对齐"};function M({asset:e,videoSrc:t,subtitleUrl:r,posterUrl:l,onAssetUpdated:s,onSubtitleEditCommitted:i,onExit:o}){let{t:x}=(0,p.s)(),[b,y]=(0,a.useState)(null),[g,C]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{e||C(document.getElementById("subtitle-toolbar-slot"))}),()=>{e=!0}},[]);let[v,w]=(0,a.useState)(()=>(function(e){let t=e.data;if(t?.width&&t?.height)return{w:t.width,h:t.height};let r=t?.size?.match(/^(\d+)x(\d+)$/);return r?{w:+r[1],h:+r[2]}:null})(e)),[k,j]=(0,a.useState)(null),N=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(N.current)return;let e=!1,t=r.startsWith("/")||new URL(r,window.location.origin).origin===window.location.origin;return fetch(r,t?{credentials:"include"}:void 0).then(e=>{if(!e.ok)throw Error(`fetch subtitle failed: ${e.status}`);return e.text()}).then(t=>{e||(N.current=!0,y(t))}).catch(t=>{e||j(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[r]),(0,a.useEffect)(()=>{if(v)return;let e=document.createElement("video");e.preload="metadata",e.src=t,e.onloadedmetadata=()=>{e.videoWidth&&e.videoHeight&&w({w:e.videoWidth,h:e.videoHeight}),e.onerror=null,e.removeAttribute("src"),e.load()},e.onerror=()=>j("video metadata load failed")},[v,t]);let L=(0,n.J)({subtitleText:v&&b?b:"",videoWidth:v?.w??0,videoHeight:v?.h??0}),F=u(),R=(0,a.useRef)(null);(0,a.useEffect)(()=>{null===R.current&&L.styleSummary&&(R.current={...L.styleSummary})},[L.styleSummary]);let $=(0,a.useCallback)(async()=>
16{try{L.isEditing&&(L.exitEdit(),await new Promise(e=>setTimeout(e,80)));let t=await F.saveSubtitleVersion(L.toAss(),e);L.markSaved();let r=function(e){let{assetId:t,subtitleUrl:r,cueCount:l,initialStyle:s,currentStyle:n,offset:a}=e,i="无样式变更";if(s&&n){let e=[];Object.keys(E).forEach(t=>{let r=s[t],l=n[t];r!==l&&e.push(`${E[t]} ${r}→${l}`)}),e.length>0&&(i=e.join(";"))}let o=Math.round(a.x),u=Math.round(a.y),d=0===o&&0===u?"无位置变化":`整体偏移 (${o}, ${u}) px`,c=n?`字体=${n.fontname} 字号=${n.fontsize} 颜色=${n.primary} 描边=${n.outlineColor}/${n.outline} 对齐=${n.alignment}`:"未知";return`<system-reminder>
17用户在字幕编辑器中编辑了字幕并保存为新版本。这是系统通知,无需回复。
18- 资产 ID: ${t}
19- 新字幕文件 URL: ${r}
20- 字幕条数: ${l}
21- 样式变更: ${i}
22- 位置变化: ${d}
23- 当前样式: ${c}
24</system-reminder>`}({assetId:e.id,subtitleUrl:t.subtitleUrl,cueCount:L.events.length,initialStyle:R.current,currentStyle:L.styleSummary,offset:L.getGlobalOffset()});i?.(r),s?.(t.asset),o?.()}catch(e){console.error("save subtitle failed:",e),f.oR.error(x("subtitleEditor.saveFailed"))}}
24,[L,L,F,e,s,i,o,x]);if(k)return(0,d.jsx)("div",{className:"flex h-full items-center justify-center p-6 text-sm text-red-500",children:k});if(!b||!v)return(0,d.jsx)("div",{className:"flex h-full items-center justify-center p-6",children:(0,d.jsx)(h.A,{className:"h-6 w-6 animate-spin text-neutral-400 dark:text-neutral-500"})});let _="ready"!==L.status||"idle"!==F.stage,z="uploading"===F.stage||"saving"===F.stage?x("subtitleEditor.saving"):void 0,A=(0,d.jsx)(m,{controller:L,onExit:g?void 0:o,onDone:()=>void $(),doneLabel:z,doneDisabled:_});return(0,d.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3 overflow-hidden px-4 pb-6",children:[g?(0,c.createPortal)(A,g):A,(0,d.jsx)(S.i,{videoSrc:t,posterUrl:l,videoWidth:v.w,videoHeight:v.h,controller:L,className:"min-h-0 flex-1"})]})}function N({controller:e}){let{t}=(0,p.s)(),r=e.currentEvent,l="loading-engine"===e.status||"error"===e.status||!r,s=(0,a.useRef)(null),n=(0,a.useRef)(null),i=(0,a.useCallback)((t,r)=>{let l=()=>{let t=s.current;s.current=null,t&&e.setEventText(t.i,t.v).catch(e=>console.error("setEventText failed:",e))};s.current={i:t,v:r},n.current||(l(),n.current=setTimeout(()=>{n.current=null,l()},200))},[e]);return(0,d.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"subtitle-cue-list",children:[(0,d.jsx)("div",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:t("subtitleEditor.cues")}),(0,d.jsx)("div",{className:"rounded-md bg-neutral-100 p-2 dark:bg-white/5","data-testid":r?`subtitle-cue-${r.index}`:"subtitle-cue-empty",children:(0,d.jsx)("textarea",{defaultValue:r?.displayText??"",disabled:l,rows:2,"data-testid":r?`subtitle-cue-text-${r.index}`:"subtitle-cue-text-empty",onChange:e=>{r&&i(r.index,e.target.value)},className:"w-full resize-none rounded-sm border border-neutral-300 bg-white px-2 py-1 text-sm disabled:opacity-70 dark:border-white/15 dark:bg-black/30 dark:text-white"})},`${e.docVersion}-${r?.index??"empty"}`)]})}function L({controller:e}){let{t}=(0,p.s)(),r=e.styleSummary;if(!r)return null;let l="ready"!==e.status;return(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 rounded-md bg-neutral-100 p-3 text-sm dark:bg-white/5","data-testid":"subtitle-style-panel",children:[(0,d.jsxs)("label",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-neutral-600 dar
24k:text-neutral-300",children:t("subtitleEditor.fontSize")}),(0,d.jsx)("input",{type:"number",min:8,max:200,defaultValue:r.fontsize,disabled:l,"data-testid":"subtitle-style-fontsize",onBlur:t=>{let l=parseInt(t.target.value,10);Number.isFinite(l)&&l!==r.fontsize&&e.applyGlobalStyle({fontsize:l})},className:"w-16 rounded-sm border border-neutral-300 bg-white px-1 py-0.5 text-right dark:border-white/15 dark:bg-black/30 dark:text-white"})]}),(0,d.jsxs)("label",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-neutral-600 dark:text-neutral-300",children:t("subtitleEditor.textColor")}),(0,d.jsx)("input",{type:"color",value:r.primary,disabled:l,"data-testid":"subtitle-style-color",onChange:t=>void e.applyGlobalStyle({primary:t.target.value}),className:"h-6 w-10 cursor-pointer rounded-sm border border-neutral-300 dark:border-white/15"})]}),(0,d.jsxs)("label",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("span",{className:"text-neutral-600 dark:text-neutral-300",children:t("subtitleEditor.outlineColor")}),(0,d.jsx)("input",{type:"color",value:r.outlineColor,disabled:l,onChange:t=>void e.applyGlobalStyle({outlineColor:t.target.value}),className:"h-6 w-10 cursor-pointer rounded-sm border border-neutral-300 dark:border-white/15"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsxs)("label",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{type:"checkbox",checked:r.bold,disabled:l,"data-testid":"subtitle-style-bold",onChange:t=>void e.applyGlobalStyle({bold:t.target.checked})}
24),(0,d.jsx)("span",{className:"font-bold text-neutral-600 dark:text-neutral-300",children:t("subtitleEditor.bold")})]}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{type:"checkbox",checked:r.italic,disabled:l,onChange:t=>void e.applyGlobalStyle({italic:t.target.checked})}),(0,d.jsx)("span",{className:"italic text-neutral-600 dark:text-neutral-300",children:t("subtitleEditor.italic")})]})]})]})}var F=r(54200)}}]);

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.