PageSourceSearch

https://static.alugha.com/assets/TextEditorSubtitleSegmentsPage-index-CB82XwYp.js

js alugha.com collected 2026-09-24 23:09:24 UTC 29,542 bytes, 30 lines download raw bytes

1import{cy as Tt,r as h,lB as q,az as ct,a7 as W,V as j,bH as H,gD as Q,ck as Mt,cc as dt,cm as lt,aA as jt,j as r,bz as wt,dU as B,hm as Et,dL as I,H as D,cg as It,ae as Dt,x as M,b9 as Vt,aB as U,t as At,a1 as Nt,p as _,bq as Bt,gC as Pt,ez as Ft,aU as $,bD as ut,dX as K,lz as A,bE as Rt,bF as Wt,aT as mt,o as _t,cj as $t,dw as Lt,lU as zt,ct as qt,gE as Ut,dK as Ot,Z as Ht,$ as Qt,u as Kt,fr as Gt}from"./index-CNagSlXC.js";import{_ as Zt,r as pt,a9 as Xt,ac as Jt,Z as Yt,K as te,m as ee}from"./AudioPlayerProvider-index-CGlrCoIZ.js";import{u as ft,a as ie,S as oe,W as se,b as bt,P as re,A as O,c as ne,d as ae,T as gt,e as kt,R as St,f as ce,g as de,h as L,B as ht,i as G,j as et,Q as le,k as R,l as ue,m as me,O as pe,n as fe,o as be}from"./useSortTabsByPreferredLanguage-B6O_6nDY.js";import{f as Z,Q as ge}from"./QualityWarning-index-uUuc60t2.js";import{T as ke}from"./TabsMenu-index-o_0XqI2f.js";import{m as Se,u as xt,S as he}from"./SegmentMutations-index-BD82PTfk.js";import{d as it,A as xe}from"./AutoHeightTextarea-index-BvgxkaEX.js";import{e as ve}from"./errors-DecWiRMw.js";import{u as Ce}from"./usePlaybackSegments-Cr84oaq4.js";import"./ErrorPicture-DRLL-zOC.js";import"./connect-B5-6MHo9.js";import"./loadable-BUkpCPp0.js";import"./Error-D7UaxmAi.js";import"./LoadingCircle-DpTAWnMM.js";import"./VideoPageQuery-C1E57atT.js";import"./ArticleCardContent-BVliUN3a.js";import"./molecules-intl-CGpXOgec.js";import"./PublisherDropzone-intl-D6kZyBaS.js";import"./useVoices-CjvN4e0d.js";import"./Alugha2GoVideoMeta-intl-BF2qUw12.js";import"./CompoundSlider-index-BBhvFVi9.js";import"./Alugha2GoVideoMeta-styled-7cua_Kmd.js";import"./ContentWide-index-CRfP4tTu.js";import"./CheckBox-CW170eiZ.js";import"./alugha2Go_Background_Banner-BkzPCBlP.js";import"./Elements-intl-DKaDo41Q.js";import"./skills-UdgW5vj7.js";import"./PublishAndDownloadModal-intl-LZqu8auH.js";import"./CopyFeedback-index-BkwJtf2r.js";import"./LanguageSelection-index-CBpRQsr1.js";import"./Tag-index-BqpvIaRb.js";import"./useDebounce-index-CEXMPes-.js";import"./sortBy-BnKyAN6u.js";import"./_baseIteratee-Bsayzfo8.js";import"./_baseIsEqual-CbgBRosw.js";import"./_setToArray-DMMUXyzd.js";import"./LoadingDropzone-rCCfF07b.js";import"./Poster-CnG32-YI.js";import"./react-files-dist-index-Bgw1ow9d.js";import"./FormLabel-index-B2le3SNn.js";import"./TextArea-index-DV3nthrt.js";import"./normalizeHeight-ig0K_vT0.js";import"./SwitchButton-index-CQKlQrea.js";import"./PersistentHeightLoadingSpinner-index-CB-V5cBK.js";import"./LanguageWrapper-index-QCCtRxbs.js";import"./BuyCreditsButton-index-wNKL8Uvw.js";import"./IconWarning-DDLdbt1r.js";import"./AddMedia-styled-C_LlhyRN.js";import"./_baseUniq-BTN8Igg0.js";import"./_arrayIncludesWith-pBMhzuR3.js";import"./uniq-DwZZeh5H.js";import"./useUpdateVideo-CMhAkKPO.js";import"./UpdateVideo-CeETjOlt.js";import"./Carousel-Dz4o9aNF.js";import"./times-yE5soP0-.js";import"./toInteger-Gkw9HAuo.js";import"./bi-index-oUQ3HotX.js";import"./vsc-index-BqgmN9Y_.js";import"./Divider-index-ChiFOg6w.js";import"./marketplace-index-BlNp_kSL.js";import"./displayLoadingState-_uAu-p5c.js";import"./marketplace-intl-Bjkl-JPu.js";import"./MoreButton-index-C7xHF10n.js";import"./SmartTime-index-BEKcZBD3.js";import"./AssetOwner-intl-33rrTN6g.js";import"./Overview-styled-YspejFqI.js";import"./InfiniteScroll-Dp2J86N5.js";import"./assetAttributes-C7jPswTp.js";import"./upperFirst-Dy1vIeaa.js";import"./withQuery-BRGRXkeF.js";import"./IconLaunch-BZe1sJH3.js";import"./Licenses-intl-CNNsPGQd.js";import"./Input-index-CiBry2FD.js";import"./Tags-styled-BgPVmyyC.js";import"./isEqual-VV6axsoc.js";import"./customerData-BGtEJCBa.js";import"./Checkbox-Dczt0Ua5.js";import"./Video-DO-3MnJZ.js";import"./DownloadAndPublishModalSections-styled-BmQJ0vXT.js";import"./DownloadAndPublishModalSections-intl-zJxoYE7B.js";import"./AlucationPage-intl-BUNj6CIA.js";import"./FinishTrackHeader-messages-C7Z5ozTU.js";import"./react-intersection-observer.m-DG9EqUKj.js";import"./ColorPicker-rEbPiQ22.js";import"./_baseAssignValue-B9b5URRE.js";import"./QRCode-B8L9qZ5R.js";import"./BrandModal-index-DKQ52eVi.js";import"./ImageUpload-Bl4jlr65.js";import"./ShareVideoOrArticle-index-DhPOH3mE.js";import"./EmbedPlayer-xc-MBBbH.js";import"./Whitelist-CXE_gOy0.js";import"./AdWrappedPlayer-CUVrIjuH.js";import"./locales-DVoF7sBb.js";import"./TooltipBox-CLXZrL21.js";import"./parseTimeToSeconds-CVThKkQc.js";import"./ContactForm-intl-purNclH1.js";import"./Whitelist-intl-CFfk5RXh.js";import"./UpdateTrack-CYTa4gkz.js";import"./useMount-index-Dkg_MXfU.js";import"./DraggableVideos-styled-DNR2hR4h.js";import"./DownloadSample-index-Z-ZOt5nq.js";import"./RadioButton-index-DQgw53-a.js";
1import"./IconEyeCircle-CFiA6rAc.js";import"./animated-BBOFBePl.js";import"./lottie-BeikJyiQ.js";import"./TTSRecordingButton-CxxSB9wP.js";import"./usePrevious-Dcje39ch.js";import"./SegmentSelector-styled-BC5IkuYA.js";import"./AudioRecorderContainer-intl-B0AvMQmj.js";import"./TabList-B-8x4Zux.js";import"./react-motion-E0wc_y9e.js";import"./useDebounceEffect-index-BxjaRAZw.js";import"./useUpdateEffect-index-CLeP3gib.js";import"./Dubbr-CgC_-Efh.js";import"./es-index-TMPXmDVa.js";import"./deepmerge-dist-cjs-i1gyAUHG.js";import"./UnverifiedHint-index-eytvCD6p.js";import"./DiscountBanner-styled-B2Rv6U0t.js";import"./useChatwoot-DcYXye79.js";import"./shake-Daf8nyjE.js";const ye=`#import "../fragments/TrackWithSubtitles.graphql"
2#import "../fragments/TrackWithClosedCaptions.graphql"
3
4query TextEditorSubtitleSegmentsPage($videoId: ID!) {
5  dubbrVideo(id: $videoId) {
6    id
7    defaultTrackId
8    duration
9    voices {
10      id
11      name
12      color
13    }
14    asset {
15      id
16      fps
17    }
18    dubbrTracks {
19      id
20      ...TrackWithSubtitles
21      ...TrackWithClosedCaptions
22    }
23  }
24}
25`,N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"TextEditorSubtitleSegmentsPage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"videoId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"dubbrVideo"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"videoId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"defaultTrackId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"duration"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"voices"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"color"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"asset"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"fps"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"dubbrTracks"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"FragmentSpread",name:{kind:"Name",value:"TrackWithSubtitles"},directives:[]},{kind:"FragmentSpread",name:{kind:"Name",value:"TrackWithClosedCaptions"},directives:[]}]}}]}}]}}],loc:{start:0,end:454,source:{name:"GraphQL request",locationOffset:{line:1,column:1},body:ye}}},vt=t=>{const e={};return t.filter(function(s){if(s.kind!=="FragmentDefinition")return!0;const i=s.name.value;return e[i]?!1:(e[i]=!0,!0)})};N.definitions=vt(N.definitions.concat(Zt.definitions));N.definitions=vt(N.definitions.concat(Tt.definitions));const Te=(t,e)=>{const s=(d,m)=>{if(d.kind==="FragmentSpread")m.add(d.name.value);else if(d.kind==="VariableDefinition"){const l=d.type;l.kind==="NamedType"&&m.add(l.name.value)}return d&&"selectionSet"in d&&d.selectionSet&&d.selectionSet.selections.forEach(l=>{s(l,m)}),d&&"variableDefinitions"in d&&d.variableDefinitions&&d.variableDefinitions.forEach(l=>{s(l,m)}),d&&"definitions"in d&&d.definitions&&d.definitions.forEach(l=>{s(l,m)}),m},i=d=>{const m={};return d.definitions.forEach(function(l){"name"in l&&l.name&&(m[l.name.value]=s(l,new Set))}),m},u=(d,m)=>{for(let l=0;l<d.definitions.length;l++){const o=d.definitions[l];if(o&&"name"in o&&o.name&&o.name.value==m)return o}},p=i(t),f=Object.assign({},t,{definitions:[u(t,e)]}),c=p[e]||new Set,b=new Set;let n=new Set;for(c.forEach(d=>{n.add(d)});n.size>0;){const d=n;n=new Set,d.forEach(m=>{b.has(m)||(b.add(m),(p[m]||new Set).forEach(o=>{n.add(o)}))})}return b.forEach(d=>{const m=u(t,d);m&&f.definitions.push(m)}),f};Te(N,"TextEditorSubtitleSegmentsPage");const z=(t,e,s,i,u,p)=>{const f=(o,k,v,a)=>{const x=new Map,C=[];
25return k.forEach(g=>{const T=`${Math.floor(g.start/10)*10}-${g.voice.id}`;x.set(T,g)}),o.forEach(g=>{const T=`${Math.floor(g.start/10)*10}-${g.voice.id}`;x.has(T)||C.push({...g,id:`mock_${T}`,text:"",isMock:!0,langCode:v,trackId:a,type:"subtitle"})}),C},c=(o,k)=>o.start!==k.start?o.start-k.start:o.voice.name.localeCompare(k.voice.name),b=(o,k,v)=>{const a={};return o.map(x=>{a[x.voice.id]||(a[x.voice.id]=1);const C=a[x.voice.id]++;return{...x,segmentNumber:C,type:"subtitle",trackId:k,langCode:v}})};if(t==null||!p||!u){const o=b(e.sort(c),s,i);return{activeTrackSegments:o,comparisonTrackSegments:o}}const n=f(e,t,p,u),d=f(t,e,i,s),m=b([...e],s,i);return{comparisonTrackSegments:[...b([...t].sort(c),u,p),...n].sort(c),activeTrackSegments:[...m,...d].sort(c)}},Me=(t,e,s,i,u)=>h.useMemo(()=>{const p=i.get(e||""),f=i.get(s||"");if(!e||!p)return{comparisonSegments:[],activeTrackSegments:[]};const c=t.find(o=>o.langCode===p);if(!c)return{comparisonSegments:[],activeTrackSegments:[]};const b=[...c.subtitleSegments.map(o=>({...o,qualityFeedback:q({...o,langCode:c.langCode,trackId:c.id,type:"subtitle"},c.subtitleSegments,c?.subtitleRuleMeta)})),...c.closedCaptions?.segments.map(o=>({...o,isClosedCaption:!0,qualityFeedback:q({...o,langCode:c.langCode,trackId:c.id,type:"subtitle"},c.closedCaptions?.segments,c?.subtitleRuleMeta)}))||[]].sort((o,k)=>o.start-k.start);if(b.length===0){const o=t.find(a=>a.langCode===f),k=o?.subtitleSegments;if(!k?.length||!o||!f||!s)return{activeTrackSegments:[],comparisonSegments:[]};const{comparisonTrackSegments:v}=z([...k],[],e,p,s,f);return{comparisonSegments:u?v.filter(a=>a.voice.id===u):v,activeTrackSegments:[]}}const n=t.find(o=>o.langCode===f);if(!n||!f||!s){const{activeTrackSegments:o}=z(null,[...b],e,p,s,f),k=u?o.filter(v=>v.voice.id===u):o;return{comparisonSegments:k,activeTrackSegments:k}}const d=[...n.subtitleSegments,...n.closedCaptions?.segments.map(o=>({...o,isClosedCaption:!0}))||[]].sort((o,k)=>o.start-k.start),{activeTrackSegments:m,comparisonTrackSegments:l}=z([...d],[...b],e,p,s,f);return{comparisonSegments:u?l.filter(o=>o.voice.id===u):l,activeTrackSegments:u?m.filter(o=>o.voice.id===u):m}},[e,s,i,t,u]),je=({video:t})=>{const e=ct(),s=W(),i=j(H),u=j(Q),p=j(Mt),[f,c]=h.useState(null),b=h.useMemo(()=>t.dubbrTracks.map(({id:g,langCode:S})=>({trackId:g,langCode:S})),[t.dubbrTracks]),n=ft(b,t.defaultTrackId||""),d=ie(t.dubbrTracks),{activeTrackSegments:m,comparisonSegments:l}=Me(t.dubbrTracks,i,u,d,f?.id),o=h.useMemo(()=>{const g=t.dubbrTracks.find(y=>y.id===i);if(!g)return[];const S=new Map(g.subtitleSegments.map(y=>[y.voice.id,y.voice])),T=Array.from(S.values());return g.closedCaptions?.voice&&T.push(g.closedCaptions.voice),T},[t.dubbrTracks,i]),k=h.useCallback(g=>{if(!g||g.value==="__all__"){c(null);return}const S=o.find(T=>T.id===g.value);S&&(s(dt(S)),c(S))},[o,s]);h.useEffect(()=>{f&&m.length>0&&s(lt(m[0]))},[f,m,s]);const v=jt(`(max-width: ${e.newScreenBreakpoints.large}px)`);h.useEffect(()=>{f&&!o.some(g=>g.id===f.id)&&c(null)},[f,o]),h.useEffect(()=>{v&&c(null)},[v,c]);const a=h.useMemo(()=>{const g=t.dubbrTracks[0].subtitleSegments,S=t.dubbrTracks[0].closedCaptions?.segments.length?t.dubbrTracks[0].closedCaptions?.segments:[];return[...g,...S].sort((T,y)=>T.start-y.start)},[t.dubbrTracks]),x=h.useMemo(()=>{if(!p||!i)return null;try{let g=0;if(a.length){const S=a[a.length-1];g=S.start+S.duration+1}return Z([...a],g,p)}catch{return null}},[i,a,p]),C=h.useMemo(()=>{const g=t.voices.map(({id:y})=>({id:y})),S=t.dubbrTracks[0]?.closedCaptions?.voice,T=S&&!g.some(y=>y.id===S.id)?[{id:S.id}]:[];return[...g,...T]},[t.voices,t.dubbrTracks]);return r.jsx(oe,{activeTrackSegments:m,comparisonSegments:l,tabs:n,trackIdToLangCode:d,voices:C,dubbrTracks:t.dubbrTracks,selectedVoice:f,handleSelectVoice:k,activeTrackVoices:o,nextSegmentPositions:x,ccVoice:t.dubbrTracks[0]?.closedCaptions?.voice})},ot=t=>t.sort((e,s)=>e.start-s.start),st=t=>t.reduce((e,s)=>(e.has(s.start)?e.get(s.start)?.push(s):e.set(s.start,[s]),e),new Map),we=t=>t.sort((e,s)=>e.start===s.start?e.voice.name===s.voice.name?e.voice.id>s.voice.id?1:-1:e.voice.name>s.voice.name?1:-1:e.start-s.start),F=(t,e)=>t.type=="sound"?{...t,isMock:!0,trackId:e||t.trackId,text:"",langCode:""}:{...t,isMock:!0,trackId:e||t.trackId},Ee=(t,e)=>{if(!t.length)return!0;const s=e.start+e.duration;try{const i=Z(t.filter(u=>u.start<s&&u.start+u.duration>=e.start),e.start,s);return i[0]===e.start&&i[1]===e.duration?!0:{start:i[0],duration:i[1]}}catch{return!1}},Ie=t=>{const e=t.reduce((i,u)=>{const p=u.voice?.id;if(!p||u.isMock)return i;const f=i.get(p);return f?f.push(u):i.set(p,[u]),i},new Map);return t.map(i=>{if(!i.isMock)return i;const u=e.get(i.voice.id);if(!u)return i;const p=Ee(u,i);return p===!1?i.creationBlocked=!0:typeof p!="boolean"&&(i.start=p.start,i.duration=p.duration),i})},rt=({type:t,trackId:e,langCode:s,currentSegs:i,comparedSegs:u,allVideoVoices:p,videoDuration:f,isAddingSegments:c,fitSuggestions:b})=>{if(!i||!u)return i?.slice()||[];let n=[];const d=st(ot(i.slice())),m=st(ot(u));for(;d.size;){const[l=0]=d.keys(),o=[...m.keys()],k=o.reverse().findIndex(S=>S<l);
25(k!==-1?o.slice(k).reverse():[]).forEach(S=>{n=[...n,...(m.get(S)||[]).map(T=>F(T,e))],m.delete(S)});const a=m.get(l);if(m.delete(l),!a){n=[...n,...d.get(l)||[]],d.delete(l);continue}const x=d.get(l);d.delete(l);const C=x.map(S=>S.voice.name),g=a.filter(S=>!C.includes(S.voice.name)).map(S=>F(S,e));n=[...n,...g,...x]}if(m.forEach(l=>{n=[...n,...l.map(o=>F(o,e))]}),c){const l=p.slice().sort((o,k)=>o.name===k.name?0:o.name>k.name?-1:1);for(const o of l){const k=n.find(a=>a.voice.id===o.id);if(!k){n=[F({id:"origin_segment_"+o.id,voice:o,trackId:e,langCode:s,text:"",type:t,start:0,duration:Math.min(f,1e4),isMock:!0},e),...n];continue}k.start>=500&&(n=[{id:"origin_segment_"+o.id,voice:o,trackId:e,langCode:s,text:"",type:"subtitle",start:0,duration:Math.min(k.start-1,1e4),isMock:!0},...n]);const v=n.filter(a=>a.voice.id===o.id&&!a.isMock);for(const a of v){const x=a.start+a.duration+1;try{const[C,g]=Z(v,x,f);if(C!==x)continue;n=[...n,{id:`new_${C}_${a.voice.id}`,type:a.type,trackId:a.trackId,langCode:s,start:C,duration:g,text:"",voice:a.voice,isMock:!0}]}catch{continue}}}}return n=we(n),[...b?Ie(n):n]},De=()=>wt([H,Q,B,(t,e)=>e],(t,e,s,i)=>{const u=s===I.addSegments;let p=[],f=[];const c=i.dubbrTracks.find(n=>n.id===e);if(c){const n={},d=c.subtitleSegments.map(l=>(n[l.voice.id]=(n[l.voice.id]||0)+1,{...Et(l,"__typename"),trackId:c.id,langCode:c.langCode,type:"subtitle",meta:void 0,asset:void 0,segmentNumber:n[l.voice.id]})),m=c.closedCaptions?.segments.map(l=>{const o=c.closedCaptions.voice.id;return n[o]=(n[o]||0)+1,{...l,voice:c.closedCaptions.voice,trackId:c.id,langCode:c.langCode,type:"subtitle",segmentNumber:n[o],isClosedCaption:!0}})||[];p=[...d,...m].sort((l,o)=>l.start-o.start).filter((l,o,k)=>o===k.findIndex(v=>v.id===l.id))}const b=i.dubbrTracks.find(n=>n.id===t);if(b){const n={},d=b.subtitleSegments.map(a=>(n[a.voice.id]=(n[a.voice.id]||0)+1,{...a,trackId:b.id,langCode:b.langCode,type:"subtitle",videoFps:i?.asset?.fps,segmentNumber:n[a.voice.id]})),m=b.closedCaptions?.segments.map(a=>{const x=b.closedCaptions.voice.id;return n[x]=(n[x]||0)+1,{...a,voice:b.closedCaptions.voice,trackId:b.id,langCode:b.langCode,type:"subtitle",videoFps:i?.asset?.fps,segmentNumber:n[x],isClosedCaption:!0}})||[],o=[...d,...m].sort((a,x)=>a.start-x.start).filter((a,x,C)=>x===C.findIndex(g=>g.id===a.id)),k=Math.round(i.duration?i.duration*1e3:0),v=[...i.voices];if(b.closedCaptions?.voice){const a=b.closedCaptions.voice;v.some(x=>x.id===a.id)||v.push(a)}if(c?.closedCaptions?.voice){const a=c.closedCaptions.voice;v.some(x=>x.id===a.id)||v.push(a)}f=rt({trackId:b.id,langCode:b.langCode,currentSegs:o,comparedSegs:p,allVideoVoices:v,videoDuration:k,fitSuggestions:!0,isAddingSegments:u,type:"subtitle"}),p=rt({trackId:"mock",langCode:c?.langCode||"eng",currentSegs:p,comparedSegs:o,allVideoVoices:v,videoDuration:k,isAddingSegments:u,type:"subtitle"})}return{left:p,right:f}}),Ve=D.div.withConfig({componentId:"sc-4e321d32-0"})([""," width:100%;height:100%;min-height:calc(100% - 1rem);overflow-x:hidden;overflow-y:auto;position:relative;"],It),Ae=D.div.withConfig({componentId:"sc-4e321d32-1"})(["display:flex;flex:1;flex-flow:row nowrap;"]),Ne=D.div.withConfig({componentId:"sc-4e321d32-2"})(["display:flex;flex:1;flex-flow:column nowrap;"]),Be=D.div.withConfig({componentId:"sc-4e321d32-3"})(["display:flex;flex:0 0 100%;flex-flow:row nowrap;position:sticky;bottom:0;z-index:21;"]),nt=D.div.withConfig({componentId:"sc-4e321d32-4"})(["height:6px;background:",";border:1px solid ",";border-top:0;border-radius:3px;flex:1 1 50%;:first-of-type{",";}:last-of-type{",";}"],({theme:t})=>t.colors.backgroundDark,({theme:t})=>t.colors.backgroundSecondary,Dt(M(10)),Vt(M(10)));class Pe extends U.Component{render(){return this.props.text.split(/\s+/).filter(e=>e).map((e,s)=>r.jsx("span",{children:e},s))}}const Fe=D(At).withConfig({componentId:"sc-171d7b9-0"})(["width:",";height:",";margin-right:",";",";"],t=>M(t.isText?12:10),t=>M(t.isText?12:10),M(5),t=>t.isText&&`
26    position: absolute;
27    left: ${M(5)};
28    top: ${M(2)};
29  `),Ct=D.div.withConfig({componentId:"sc-171d7b9-1"})(["direction:",";color:",";font-size:",";line-height:",";min-height:",";padding:"," "," "," ",";width:100%;word-break:break-word;border-bottom:1px solid ",";"],t=>t.textDirection,t=>t.theme.dubbr.texteditor.comparedSegmentColor,t=>M(t.theme.dubbr.texteditor.textFontSize),t=>M(t.theme.dubbr.texteditor.textFontSize),t=>M(t.theme.dubbr.texteditor.textFontSize+12),M(10),M(2),M(11),M(2),t=>t.isActive?t.theme.colors.accentSecondary:"transparent"),Re=D(Ct.withComponent("textarea")).withConfig({componentId:"sc-171d7b9-2"})(["border-bottom:0;:focus{color:"," !important;}"],t=>Nt(.5,t.theme.dubbr.texteditor.colorActive)),We=t=>t.trimLeft().replace(/[\t\r]/g," "),X=({direction:t="ltr",value:e,isActive:s,isLoading:i,isDisabled:u,setSegmentActive:p,handleUpdate:f,handlePressedCtrlSpace:c})=>{const b=_(),n=ct(),d=Bt(e),m=b.formatMessage(Se.segmentDefaultText),[l,o]=h.useState(e),k=h.useRef(!1),v=Pt(()=>{if(k.current){k.current=!1;return}it.test(l.trim())&&Ft.error(b.formatMessage(ve.emptyLine),{position:"top-right"});const y=l.trim().replaceAll(it,`
30`);e!==y&&f?.(y),o(y)});h.useEffect(()=>{e!==d&&o(e)},[d,e]);const a=h.useCallback(y=>{const w=We(y.target.value);o(w)},[]),x=h.useCallback(()=>{!s&&p!=null&&p()},[s,p]),C=h.useCallback(y=>{const w=y.currentTarget;if(y.key==="Enter"&&!y.shiftKey){if(y.ctrlKey){const V=w.parentElement?.parentElement?.parentElement?.nextElementSibling;if(V){const P=V.querySelector("textarea");if(P)return P.focus()}}w.blur()}else y.key==="Escape"?(k.current=!0,o(e),w.blur()):y.key===" "&&y.ctrlKey&&c?.()},[c,e]),g=$(b.locale),S=l?t:g,T=h.useMemo(()=>({padding:`${M(10)} ${M(3)}`,direction:S,overflow:"hidden auto"}),[S]);return r.jsxs(r.Fragment,{children:[i&&r.jsx(Fe,{}),u?r.jsx(Ct,{isActive:s,textDirection:S,children:l||(u?"":m)}
30):r.jsx(xe,{as:Re,value:l,onChange:a,onFocus:x,onBlur:v,onKeyDown:C,placeholder:m,lineHeightPx:n.dubbr.texteditor.textFontSize,textColor:s?n.dubbr.texteditor.colorActive:n.dubbr.texteditor.color,borderColor:s?n.dubbr.texteditor.borderColorActive:"transparent",maxLength:2e3,maxHeight:88,disableFocusBackground:!0,style:T,preventEmptyLines:!0})]})},_e=({children:t})=>r.jsx(r.Fragment,{children:t}),$e=({segment:t,direction:e,isActiveSegment:s,isLastSegment:i,textEditingDisabled:u,segmentDeletionDisabled:p,setSegmentActive:f,handlePlayOrPause:c,handleUpdateText:b,handleRemoveSegment:n})=>{const d=j(B)===I.moveAndResize,m=j(ut),l=s&&d,o=s&&d&&!p,k=h.useMemo(()=>d&&s&&m?se:_e,[s,d,m]);return r.jsxs(bt,{isActive:s,children:[l&&r.jsx(re,{children:r.jsx(O,{variant:"text",color:"primary",onClick:c,children:m?r.jsx(ne,{}):r.jsx(ae,{})})}),r.jsx(gt,{...K("dubbr-te-text-input"),children:r.jsx(k,{segment:t,children:r.jsx(X,{value:t.text||"",isActive:s,setSegmentActive:f,handleUpdate:b,handlePressedCtrlSpace:c,isDisabled:u,direction:e})})}),o&&r.jsx(kt,{isLast:i,children:r.jsx(O,{variant:"text",color:"negative",onClick:n,children:r.jsx(St,{})})})]})},Le=({segment:t,isActiveSegment:e,isLastSegment:s,textEditingDisabled:i,segmentDeleti
30onDisabled:u,direction:p,setSegmentActive:f,handlePlayOrPause:c,handleRemoveSegment:b,handleUpdateText:n})=>{const d=j(B)===I.moveAndResize,m=e&&d&&!u;return r.jsxs(bt,{isActive:e,children:[r.jsx(gt,{...K("dubbr-te-text-input"),children:r.jsx(X,{value:t.text||"",isActive:e,setSegmentActive:f,handleUpdate:n,handlePressedCtrlSpace:c,isDisabled:i,direction:p})}),m&&r.jsx(kt,{isLast:s,children:r.jsx(O,{variant:"text",color:"negative",onClick:b,children:r.jsx(St,{})})})]})},J=({voice:t,segmentNumber:e})=>{const s=_(),i=$(s.locale);return r.jsxs(ce,{direction:i,children:[e,t.color&&r.jsx(de,{color:t.color}),t.name]})},ze=({segment:t,isActiveSegment:e,isFirst:s,isLast:i,hasLeftTrack:u,isUsingScissorsTool:p,setSegmentActive:f})=>{const{updateDubbingSegment:c,updateSubtitleSegment:b,removeSubtitleSegment:n,removeDubbingSegment:d}=xt(),m=W(),l=j(ut),o=t?.type==="dubbing",k=h.useMemo(()=>({start:A(t?.start||0),end:A(t?t.start+t.duration:0)}),[t]),v=h.useCallback(E=>{if(!t)return Promise.resolve();const tt=t.duration+(t.start-E);if(t.type==="dubbing")return c(t,{start:E,duration:tt});if(t.type==="subtitle")return b(t,{start:E,duration:tt})},[t,c,b]),a=h.useCallback(E=>{if(!t)return Promise.resolve();if(t.type==="dubbing")return c(t,{duration:E-t.start});if(t.type==="subtitle")return b(t,{duration:E-t.start})},[t,c,b]),x=h.useCallback(E=>{if(t){if(t.type==="dubbing")return c(t,{text:E});if(t.type==="subtitle")return b(t,{text:E})}},[t,c,b]),C=h.useCallback(async()=>{if(t){if(t.type==="dubbing")return d(t.id);if(t.type==="subtitle")return n(t.id)}},[d,n,t]),g=h.useCallback(()=>{o&&m(l?Rt():Wt())},[m,o,l]),{videoPermissions:S,getTrackPermissions:T}=pt(),y=!t||t.type==="dubbing"&&!T(t.trackId).updateDubbingSegmentText||t.type==="subtitle"&&!T(t.trackId).updateSubtitleSegmentText,w=!t||t.type==="dubbing"&&!S.moveDubbingSegments||t.type==="subtitle"&&!S.moveSubtitleSegments,V=!t||t.type==="dubbing"&&!S.deleteDubbingSegments||t.type==="subtitle"&&!S.deleteSubtitleSegments,P=h.useMemo(()=>t?.langCode?$(mt(t.langCode)):"ltr",[t]),Y={isActiveSegment:e,isLastSegment:i,segmentDeleti
30onDisabled:V,textEditingDisabled:y,handlePlayOrPause:g,handleUpdateText:x,handleRemoveSegment:C,setSegmentActive:f,direction:P};return r.jsx(L,{active:e,isFirst:s,isLast:i,hasLeftTrack:u,isRightTrack:!0,children:r.jsxs(ht,{show:t?.type==="subtitle",children:[t&&r.jsxs(r.Fragment,{children:[r.jsxs(G,{children:[r.jsx(et,{value:k.start,isActive:e,setSegmentActive:f,handleUpdate:v,handlePressedCtrlSpace:g,isDisabled:w}),r.jsx(J,{voice:t.voice,segmentNumber:t.segmentNumber}),r.jsx(et,{value:k.end,isActive:e,setSegmentActive:f,handleUpdate:a,handlePressedCtrlSpace:g,isDisabled:w})]}),p?r.jsx(Pe,{text:t.text||""}):t.type==="dubbing"?r.jsx($e,{segment:t,...Y}):r.jsx(Le,{segment:t,...Y})]}),t?.type==="subtitle"&&r.jsx(le,{isActive:e,children:r.jsx(ge,{segment:t,attachment:"bottom center",showRenderTarget:!0,isHover:!1,contentWithMargin:!0})})]})})},yt=({isFirst:t,isLast:e,hasLeftTrack:s,isRightTrack:i})=>r.jsx(L,{isFirst:t,isLast:e,hasLeftTrack:s,isRightTrack:i}),qe=({isActive:t,isFirst:e,isLast:s,segment:i})=>{const{formatMessage:u}=_(),p=h.useMemo(()=>({start:A(i?.start||0),end:A(i?i.start+i.duration:0)}),[i]),f=h.useMemo(()=>i?.langCode?$(mt(i.langCode)):"ltr",[i]);return!i||i.isMock?r.jsx(yt,{isFirst:e,isLast:s,hasLeftTrack:!0}):r.jsx(L,{isFirst:e,isLast:s,hasLeftTrack:!0,children:r.jsxs(ht,{show:i.type==="subtitle",children:[r.jsxs(G,{children:[r.jsx(R,{children:p.start}),r.jsx(J,{voice:i.voice,segmentNumber:i.segmentNumber}),r.jsx(R,{children:p.end})]}),r.jsx(X,{value:i.text||u(Xt.noSegmentText),isActive:t,direction:f,isDisabled:!0})]})})},Ue=_t({tooltipBlocked:{id:"dubbr.TextEditorListItem.tooltipBlocked",defaultMessage:"Segment creation is blocked by overlapping segments of the same voice"}}),Oe=({isFirst:t,isLast:e,hasLeftTrack:s,segment:i})=>{const[u,p]=h.useState(!1),{createSubtitleSegment:f,createDubbingSegment:c}=xt(),b=_(),n=h.useCallback(()=>{if(i.creationBlocked)return;const k={trackId:i.trackId,voiceId:i.voice.id,start:i.start,duration:i.duration};if(i.type==="subtitle")return f(k);if(i.type==="dubbing")return c(k)},[c,f,i.creationBlocked,i.duration,i.start,i.trackId,i.type,i.voice.id]),d=h.useCallback(()=>{p(!0)},[]),m=h.useCallback(()=>{p(!1)},[]),l=h.useMemo(()=>({start:A(i.start||0),end:A(i.start+i.duration)}),[i]);let o;return u&&(o=b.formatMessage(Jt.btnCreate)),i.creationBlocked&&(o=b.formatMessage(Ue.tooltipBlocked)),r.jsx(L,{isFirst:t,isLast:e,hasLeftTrack:s,isRightTrack:!0,children:!i.creationBlocked&&r.jsxs(ue,{title:o,onMouseEnter:d,onMouseLeave:m,onClick:n,isDisabled:i.creationBlocked,children:[r.jsxs(G,{children:[r.jsx(R,{isSuggestion:!0,children:l.start}),i.voice&&r.jsx(J,{voice:i.voice}),r.jsx(R,{isSuggestion:!0,children:l.end})]}),r.jsx(me,{children:i.text||""})]})})},at=({leftSegment:t,rightSegment:e,hasLeftTrack:s,isFirst:i,isLast:u})=>{const p=j($t),f=j(Lt),c=j(B),b=W(),{videoPermissions:n}=pt(),d=p?e?.id===p:!1,m=c===I.addSegments,l=m&&!!e?.id.startsWith("new_"),o=e&&(e.type!=="dubbing"||n.addDubbingSegments),k=f!=null&&e?.voice.id===f.id,v=h.useCallback(()=>{e&&c===I.moveAndResize&&(k||b(dt(e.voice)),d||(b(lt(e)),b(zt(e.start/1e3))))},[c,b,d,k,e]),a=h.useCallback(()=>{v()},[v]),x=h.useMemo(()=>{let C=r.jsx(ze,{setSegmentActive:v,isFirst:i,isLast:u,hasLeftTrack:s,isActiveSegment:d,isUsingScissorsTool:c===I.scissors,segment:e});return m&&e?.isMock?C=r.jsx(Oe,{isFirst:i,isLast:u,hasLeftTrack:s,segment:e}):!m&&e?.isMock&&(C=r.jsx(yt,{isFirst:i,isLast:u,hasLeftTrack:s,isRightTrack:!0})),C},[c,s,m,d,i,u,e,v]);return l&&!o?null:r.jsxs(pe,{onPointerDown:a,"data-pep":"none",children:[s&&r.jsx(qe,{isFirst:i,isLast:u,isActive:d,segment:t}),x]})};function He(t,e){return t.dubbrTracks.find(s=>s.id===e)}const Qe=({type:t,video:e,trackTabs:s,leftSegments:i,rightSegments:u,defaultTrackId:p})=>{const f=ft(s,p);fe(f[0]?.trackId),be(f[1]?.trackId);const c=j(H),b=j(Q),n=j(B),d=n===I.addSegments,m=W();h.useEffect(()=>{let a=c,x=b;f.some(g=>g.trackId===a)||(a=f[0]?.trackId||null);const C=a!=null?f.filter(g=>g.trackId!==a):f;C.some(g=>g.trackId===x)||(x=C[0]?.trackId||null),m(qt(a)),m(Ut(x))},[c,b,f,m]);const l=h.useMemo(()=>{const a=[],x=Math.max(i?.length||0,u?.length||0);for(let C=0;C<x;C+=1){const g=i?.[C],S=u?.[C];if(g?.type!="sound"&&S?.type!="sound"){const T=He(e,c);let y=[];if(T&&"subtitleSegments"in T&&(y=[...T.subtitleSegments]),T&&"closedCaptions"in T){const w=T.closedCaptions?.segments||[];y=[...y,...w]}y.sort((w,V)=>w.start-V.start),S&&S.type==="subtitle"&&(S.qualityFeedback=q(S,y,T?.subtitleRuleMeta)),a.push(r.jsx(at,{leftSegment:g,rightSegment:S,hasLeftTrack:!0},g?.id||S?.id||C))}}if(a.length){const C=a.pop();C&&a.push(U.cloneElement(C,{isLast:!0}));const g=a.shift();g&&a.unshift(U.cloneElement(g,{isFirst:!0}))}return a},[e,i,u,c]),o=h.useMemo(()=>{const a=[];for(const x of e.dubbrTracks)a.push(x.id);return a},[e.dubbrTracks]);h.useEffect(()=>{n===I.scissors&&m(Ot(I.moveAndResize))},[m,n]);const k=h.useMemo(()=>t==="subtitle"?e.dubbrTracks.some(a=>a.subtitleSegments.length>0):l.length>0,[l.length,t,e]),v=!e.voices.length||!k&&!d;return r.jsx(he,{segments:u||[],trackIds:o,children:r.jsx(Ve,{...K("dubbr-text-editor"),children:v?r.jsx(Yt,{numVoices:e.voices.length}):r.jsxs(r.Fragment,{children:[r.jsx(ke,{tracks:f,withBorder:!0}),r.jsx(Ae,{children:r.jsx(Ne,{children:!v&&!i?.length&&!u?.length?r.jsx(at,{hasLeftTrack:!0}):l})}),r.jsxs(Be,{children:[r.jsx(nt,{}),r.jsx(nt,{})]})]})})})},Ke=({video:t})=>{const e=h.useMemo(De,[]),{left:s,right:i}=j(p=>e(p,t)),u=h.useMemo(()=>t.dubbrTracks.map(p=>({trackId:p.id,langCode:p.langCode})),[t.dubbrTracks]);return r.jsx(Qe,{type:"subtitle",video:t,leftSegments:s,rightSegments:i,trackTabs:u,defaultTrackId:t.defaultTrackId})},cs=({match:t})=>{const e=Ht(Qt.NewEditorForSubtitles),{data:s,loading:i}=Kt(N,{variables:{videoId:t.params.videoId}}),u=Ce(),p=j(Gt),{audioPlayer:f,loading:c}=h.useContext(te);if(h.useEffect(()=>{f!=null&&!c&&f.load(u,p.trackAssets.backgroundAssets)},[f,c,u,p.trackAssets.backgroundAssets]),i)return r.jsx(ee,{loading:i});if(!s?.dubbrVideo)throw new Error("Video not found");return e?r.jsx(je,{video:s.dubbrVideo}):r.jsx(Ke,{video:s.dubbrVideo})};export{cs 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.