@phont-ai/subtitles-core 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1463,4 +1463,47 @@ declare class PhontClient {
|
|
|
1463
1463
|
clearCredentials(): void;
|
|
1464
1464
|
}
|
|
1465
1465
|
|
|
1466
|
-
|
|
1466
|
+
/**
|
|
1467
|
+
* Get auth token for the current active user
|
|
1468
|
+
* Used by API client
|
|
1469
|
+
* @returns {string | null}
|
|
1470
|
+
*/
|
|
1471
|
+
declare function getCurrentAuthToken(): string | null;
|
|
1472
|
+
/**
|
|
1473
|
+
* Get session ID for the current active user
|
|
1474
|
+
* Used by API client
|
|
1475
|
+
* @returns {string | null}
|
|
1476
|
+
*/
|
|
1477
|
+
declare function getCurrentSessionId(): string | null;
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Opt-in: one pretty console dump per VOD fetch (no per-frame spam).
|
|
1481
|
+
*
|
|
1482
|
+
* Enable: `?debug=subtitles` or `?stage_debug=subtitles` or
|
|
1483
|
+
* `localStorage.setItem('phont_debug_subtitles', '1')`
|
|
1484
|
+
*/
|
|
1485
|
+
type SubtitleDebugEntry = {
|
|
1486
|
+
at: string;
|
|
1487
|
+
vodId?: string | null;
|
|
1488
|
+
url?: string;
|
|
1489
|
+
raw: unknown;
|
|
1490
|
+
};
|
|
1491
|
+
type SubtitleDebugStore = {
|
|
1492
|
+
enabled: boolean;
|
|
1493
|
+
last: SubtitleDebugEntry | null;
|
|
1494
|
+
dumpLast: () => SubtitleDebugEntry | null;
|
|
1495
|
+
copyLast: () => Promise<string>;
|
|
1496
|
+
};
|
|
1497
|
+
declare global {
|
|
1498
|
+
interface Window {
|
|
1499
|
+
__phontSubtitleDebug?: SubtitleDebugStore;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
declare function isSubtitleDebugEnabled(): boolean;
|
|
1503
|
+
/** One styled log per vodId (+ optional url key); stores payload on window.__phontSubtitleDebug */
|
|
1504
|
+
declare function logSubtitleData(data: unknown, meta?: {
|
|
1505
|
+
vodId?: string | null;
|
|
1506
|
+
url?: string;
|
|
1507
|
+
}): void;
|
|
1508
|
+
|
|
1509
|
+
export { ANIMATION_STYLING, ANIMATION_URLS, AUTHORED_PLAYBACK_OPTIONS, type AnimationFetcher, type AnimationOptions, type AnimationParameterState, type AnimationParameterStates, type AnimationRecord, type AnimationState, type CurvePoint, EMOTION_ANIMATION_URLS, type Emotion, type EmotionSelectionResult, type EmotionStyle, type EmphasisEffect, type FontAxisConfig, type FontConfig, type JoyEffect, type Letter, type LoginResponse, type ParameterState, type ParameterStates, PhontClient, type PhontClientOptions, type PublishedAnimationResolver, REFERENCE_GTS, REFERENCE_INTENSITY, RENDERING_CONTROL, type RegisterResponse, type SentenceAnimationState, type StateCallback, type StrongEmphasisData, type Stylesheet, type SubtitleDebugEntry, type SubtitleDebugStore, type SubtitleEngineState, type SubtitleLine, SubtitleManager, type SubtitleSegment, type SubtitleState$1 as SubtitleState, SubtitleStateManager, type SubtitleTrack, type SubtitleWord, type VodMetadata, type VodState$1 as VodState, type Word, type WordAnimationState, type WordLetterSpacingParams, calculateAnimationParameters, calculateAnimationState, calculateDynamicWordSpacing, calculateEmphasisMultiplier, calculateGTSValues, calculateJoy, calculateJoyBulge, calculateNormalizedTime, calculateWeightFromVolume, calculateWidthFromSpeechRate, calculateWordEmphasisEffects, calculateWordLetterSpacing, capEmotionIntensity, computeProsodyWeight, createPublishedAnimationResolver, decodeAnimationUrl, ensureFont, findSubtitleForWord, generateTextShadow, getAnimationUrlForEmotion, getCombinedBlurAmount, getCurrentAuthToken, getCurrentSessionId, getFontFamilyCSS, getJoyAnimationMode, getJoyFilter, getJoyTransform, getMergedSubtitles, getMotionBlurAmount, getSubtitleAnimations, getSubtitleText, getSubtitleTiming, getSubtitleWords, getWordEmphasis, hasMergedSubtitles, hockeyStickIntensity, isInEmphasisRange, isInStrongEmphasisRange, isSubtitleDebugEnabled, logSubtitleData, meetsEmotionThreshold, preloadAnimationFonts, processEmotionsWithImportance, resolveEffectiveGts, sampleParameterCurve, selectEmotion, selectFontFamily, shouldUseAngryFont, shouldUseJoyFont, shouldUseSadnessFont, splitTextIntoLetters, subtitleManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1463,4 +1463,47 @@ declare class PhontClient {
|
|
|
1463
1463
|
clearCredentials(): void;
|
|
1464
1464
|
}
|
|
1465
1465
|
|
|
1466
|
-
|
|
1466
|
+
/**
|
|
1467
|
+
* Get auth token for the current active user
|
|
1468
|
+
* Used by API client
|
|
1469
|
+
* @returns {string | null}
|
|
1470
|
+
*/
|
|
1471
|
+
declare function getCurrentAuthToken(): string | null;
|
|
1472
|
+
/**
|
|
1473
|
+
* Get session ID for the current active user
|
|
1474
|
+
* Used by API client
|
|
1475
|
+
* @returns {string | null}
|
|
1476
|
+
*/
|
|
1477
|
+
declare function getCurrentSessionId(): string | null;
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Opt-in: one pretty console dump per VOD fetch (no per-frame spam).
|
|
1481
|
+
*
|
|
1482
|
+
* Enable: `?debug=subtitles` or `?stage_debug=subtitles` or
|
|
1483
|
+
* `localStorage.setItem('phont_debug_subtitles', '1')`
|
|
1484
|
+
*/
|
|
1485
|
+
type SubtitleDebugEntry = {
|
|
1486
|
+
at: string;
|
|
1487
|
+
vodId?: string | null;
|
|
1488
|
+
url?: string;
|
|
1489
|
+
raw: unknown;
|
|
1490
|
+
};
|
|
1491
|
+
type SubtitleDebugStore = {
|
|
1492
|
+
enabled: boolean;
|
|
1493
|
+
last: SubtitleDebugEntry | null;
|
|
1494
|
+
dumpLast: () => SubtitleDebugEntry | null;
|
|
1495
|
+
copyLast: () => Promise<string>;
|
|
1496
|
+
};
|
|
1497
|
+
declare global {
|
|
1498
|
+
interface Window {
|
|
1499
|
+
__phontSubtitleDebug?: SubtitleDebugStore;
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
declare function isSubtitleDebugEnabled(): boolean;
|
|
1503
|
+
/** One styled log per vodId (+ optional url key); stores payload on window.__phontSubtitleDebug */
|
|
1504
|
+
declare function logSubtitleData(data: unknown, meta?: {
|
|
1505
|
+
vodId?: string | null;
|
|
1506
|
+
url?: string;
|
|
1507
|
+
}): void;
|
|
1508
|
+
|
|
1509
|
+
export { ANIMATION_STYLING, ANIMATION_URLS, AUTHORED_PLAYBACK_OPTIONS, type AnimationFetcher, type AnimationOptions, type AnimationParameterState, type AnimationParameterStates, type AnimationRecord, type AnimationState, type CurvePoint, EMOTION_ANIMATION_URLS, type Emotion, type EmotionSelectionResult, type EmotionStyle, type EmphasisEffect, type FontAxisConfig, type FontConfig, type JoyEffect, type Letter, type LoginResponse, type ParameterState, type ParameterStates, PhontClient, type PhontClientOptions, type PublishedAnimationResolver, REFERENCE_GTS, REFERENCE_INTENSITY, RENDERING_CONTROL, type RegisterResponse, type SentenceAnimationState, type StateCallback, type StrongEmphasisData, type Stylesheet, type SubtitleDebugEntry, type SubtitleDebugStore, type SubtitleEngineState, type SubtitleLine, SubtitleManager, type SubtitleSegment, type SubtitleState$1 as SubtitleState, SubtitleStateManager, type SubtitleTrack, type SubtitleWord, type VodMetadata, type VodState$1 as VodState, type Word, type WordAnimationState, type WordLetterSpacingParams, calculateAnimationParameters, calculateAnimationState, calculateDynamicWordSpacing, calculateEmphasisMultiplier, calculateGTSValues, calculateJoy, calculateJoyBulge, calculateNormalizedTime, calculateWeightFromVolume, calculateWidthFromSpeechRate, calculateWordEmphasisEffects, calculateWordLetterSpacing, capEmotionIntensity, computeProsodyWeight, createPublishedAnimationResolver, decodeAnimationUrl, ensureFont, findSubtitleForWord, generateTextShadow, getAnimationUrlForEmotion, getCombinedBlurAmount, getCurrentAuthToken, getCurrentSessionId, getFontFamilyCSS, getJoyAnimationMode, getJoyFilter, getJoyTransform, getMergedSubtitles, getMotionBlurAmount, getSubtitleAnimations, getSubtitleText, getSubtitleTiming, getSubtitleWords, getWordEmphasis, hasMergedSubtitles, hockeyStickIntensity, isInEmphasisRange, isInStrongEmphasisRange, isSubtitleDebugEnabled, logSubtitleData, meetsEmotionThreshold, preloadAnimationFonts, processEmotionsWithImportance, resolveEffectiveGts, sampleParameterCurve, selectEmotion, selectFontFamily, shouldUseAngryFont, shouldUseJoyFont, shouldUseSadnessFont, splitTextIntoLetters, subtitleManager };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ze=(n,t)=>{for(var e in t)te(n,e,{get:t[e],enumerable:!0})},Qe=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ke(t))!Je.call(n,s)&&s!==e&&te(n,s,{get:()=>t[s],enumerable:!(i=He(t,s))||i.enumerable});return n};var tn=n=>Qe(te({},"__esModule",{value:!0}),n);var qn={};Ze(qn,{ANIMATION_STYLING:()=>x,ANIMATION_URLS:()=>U,AUTHORED_PLAYBACK_OPTIONS:()=>Te,EMOTION_ANIMATION_URLS:()=>qt,PhontClient:()=>Gt,REFERENCE_GTS:()=>pt,REFERENCE_INTENSITY:()=>ee,RENDERING_CONTROL:()=>p,SubtitleManager:()=>gt,SubtitleStateManager:()=>ft,calculateAnimationParameters:()=>mt,calculateAnimationState:()=>Oe,calculateDynamicWordSpacing:()=>$e,calculateEmphasisMultiplier:()=>se,calculateGTSValues:()=>Nt,calculateJoy:()=>fn,calculateJoyBulge:()=>gn,calculateNormalizedTime:()=>Dn,calculateWeightFromVolume:()=>Yn,calculateWidthFromSpeechRate:()=>Vn,calculateWordEmphasisEffects:()=>le,calculateWordLetterSpacing:()=>$n,capEmotionIntensity:()=>ne,computeProsodyWeight:()=>Ue,createPublishedAnimationResolver:()=>je,decodeAnimationUrl:()=>Wt,ensureFont:()=>de,findSubtitleForWord:()=>$t,generateTextShadow:()=>Xe,getAnimationUrlForEmotion:()=>We,getCombinedBlurAmount:()=>Ye,getFontFamilyCSS:()=>Ut,getJoyAnimationMode:()=>ue,getJoyFilter:()=>bn,getJoyTransform:()=>pn,getMergedSubtitles:()=>At,getMotionBlurAmount:()=>me,getSubtitleAnimations:()=>wt,getSubtitleText:()=>St,getSubtitleTiming:()=>Rn,getSubtitleWords:()=>Xt,getWordEmphasis:()=>ke,hasMergedSubtitles:()=>tt,hockeyStickIntensity:()=>ve,isInEmphasisRange:()=>ie,isInStrongEmphasisRange:()=>ae,meetsEmotionThreshold:()=>cn,preloadAnimationFonts:()=>ze,processEmotionsWithImportance:()=>yt,resolveEffectiveGts:()=>bt,sampleParameterCurve:()=>ct,selectEmotion:()=>Ln,selectFontFamily:()=>Be,shouldUseAngryFont:()=>wn,shouldUseJoyFont:()=>An,shouldUseSadnessFont:()=>vn,splitTextIntoLetters:()=>Un,subtitleManager:()=>we});module.exports=tn(qn);var ft=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,e,i){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),i!==void 0&&(this.state.soundByteFiltered=i),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,e,i){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),i!==void 0&&(this.vodState.soundByteFiltered=i),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,e){this.state.segmentDurations.set(t,e)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var Bt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let e=t||"original";return this._subtitleCache.get(e)}set(t,e){let i=t||"original";this._subtitleCache.set(i,{data:e,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let e=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],i=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],s=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,m=0,u=0;r.forEach(f=>{e.includes(f)&&o++,i.includes(f)&&m++,s.includes(f)&&u++});let l=o/a,d=m/a,c=u/a,C=.1;return l>C&&l>d&&l>c?"de":d>C&&d>l&&d>c?"pl":c>C&&c>l&&c>d?"en-US":null}};var en="phont_session_",nn="phont_current_user";function he(n){return`${en}${n}`}function fe(){try{return localStorage.getItem(nn)}catch(n){return console.error("Failed to get current user:",n),null}}function ge(n){if(!n)return null;try{let t=localStorage.getItem(he(n));if(!t)return null;let e=JSON.parse(t);return!e.sessionId||!e.authToken||!e.username?(console.warn("Invalid session data found in storage"),rn(n),null):e}catch(t){return console.error("Failed to retrieve session:",t),null}}function sn(n){let t=ge(n);return t?t.authToken:null}function an(n){let t=ge(n);return t?t.sessionId:null}function rn(n){if(n)try{localStorage.removeItem(he(n))}catch(t){console.error("Failed to clear session:",t)}}function pe(){let n=fe();return n?sn(n):null}function be(){let n=fe();return n?an(n):null}var ut=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",Ft=class{constructor(t,e){this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=e||null}setPhontClient(t){this.phontClient=t}normalizeSubtitles(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:t&&Array.isArray(t.subtitles)?t.subtitles.length>0&&!Array.isArray(t.subtitles[0])&&typeof t.subtitles[0]=="object"?[t.subtitles]:t.subtitles:[]}normalizeSoundbites(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:[]}async parseHLSMasterManifest(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch master manifest: ${e.status}`);let s=(await e.text()).split(`
|
|
1
|
+
"use strict";var se=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var nn=(n,t)=>{for(var e in t)se(n,e,{get:t[e],enumerable:!0})},sn=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of tn(t))!en.call(n,s)&&s!==e&&se(n,s,{get:()=>t[s],enumerable:!(i=Qe(t,s))||i.enumerable});return n};var an=n=>sn(se({},"__esModule",{value:!0}),n);var Jn={};nn(Jn,{ANIMATION_STYLING:()=>x,ANIMATION_URLS:()=>U,AUTHORED_PLAYBACK_OPTIONS:()=>Ie,EMOTION_ANIMATION_URLS:()=>Ht,PhontClient:()=>Jt,REFERENCE_GTS:()=>pt,REFERENCE_INTENSITY:()=>ae,RENDERING_CONTROL:()=>p,SubtitleManager:()=>gt,SubtitleStateManager:()=>ft,calculateAnimationParameters:()=>dt,calculateAnimationState:()=>Xe,calculateDynamicWordSpacing:()=>qe,calculateEmphasisMultiplier:()=>oe,calculateGTSValues:()=>Ut,calculateJoy:()=>Sn,calculateJoyBulge:()=>wn,calculateNormalizedTime:()=>Xn,calculateWeightFromVolume:()=>Hn,calculateWidthFromSpeechRate:()=>Kn,calculateWordEmphasisEffects:()=>me,calculateWordLetterSpacing:()=>zn,capEmotionIntensity:()=>re,computeProsodyWeight:()=>ze,createPublishedAnimationResolver:()=>Ue,decodeAnimationUrl:()=>Xt,ensureFont:()=>ge,findSubtitleForWord:()=>Vt,generateTextShadow:()=>Ve,getAnimationUrlForEmotion:()=>$e,getCombinedBlurAmount:()=>Ge,getCurrentAuthToken:()=>Ft,getCurrentSessionId:()=>Pt,getFontFamilyCSS:()=>qt,getJoyAnimationMode:()=>Ce,getJoyFilter:()=>vn,getJoyTransform:()=>An,getMergedSubtitles:()=>At,getMotionBlurAmount:()=>fe,getSubtitleAnimations:()=>wt,getSubtitleText:()=>St,getSubtitleTiming:()=>Nn,getSubtitleWords:()=>Yt,getWordEmphasis:()=>Le,hasMergedSubtitles:()=>tt,hockeyStickIntensity:()=>_e,isInEmphasisRange:()=>le,isInStrongEmphasisRange:()=>ue,isSubtitleDebugEnabled:()=>ie,logSubtitleData:()=>Nt,meetsEmotionThreshold:()=>fn,preloadAnimationFonts:()=>Je,processEmotionsWithImportance:()=>yt,resolveEffectiveGts:()=>bt,sampleParameterCurve:()=>ct,selectEmotion:()=>jn,selectFontFamily:()=>De,shouldUseAngryFont:()=>Mn,shouldUseJoyFont:()=>_n,shouldUseSadnessFont:()=>En,splitTextIntoLetters:()=>Gn,subtitleManager:()=>Te});module.exports=an(Jn);var ft=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,e,i){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),i!==void 0&&(this.state.soundByteFiltered=i),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,e,i){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),i!==void 0&&(this.vodState.soundByteFiltered=i),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,e){this.state.segmentDurations.set(t,e)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var Bt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let e=t||"original";return this._subtitleCache.get(e)}set(t,e){let i=t||"original";this._subtitleCache.set(i,{data:e,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let e=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],i=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],s=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,u=0,d=0;r.forEach(f=>{e.includes(f)&&o++,i.includes(f)&&u++,s.includes(f)&&d++});let l=o/a,m=u/a,c=d/a,C=.1;return l>C&&l>m&&l>c?"de":m>C&&m>l&&m>c?"pl":c>C&&c>l&&c>m?"en-US":null}};var rn="phont_session_",on="phont_current_user";function be(n){return`${rn}${n}`}function ye(){try{return localStorage.getItem(on)}catch(n){return console.error("Failed to get current user:",n),null}}function Se(n){if(!n)return null;try{let t=localStorage.getItem(be(n));if(!t)return null;let e=JSON.parse(t);return!e.sessionId||!e.authToken||!e.username?(console.warn("Invalid session data found in storage"),cn(n),null):e}catch(t){return console.error("Failed to retrieve session:",t),null}}function ln(n){let t=Se(n);return t?t.authToken:null}function un(n){let t=Se(n);return t?t.sessionId:null}function cn(n){if(n)try{localStorage.removeItem(be(n))}catch(t){console.error("Failed to clear session:",t)}}function Ft(){let n=ye();return n?ln(n):null}function Pt(){let n=ye();return n?un(n):null}var ut=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",Lt=class{constructor(t,e){this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=e||null}setPhontClient(t){this.phontClient=t}normalizeSubtitles(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:t&&Array.isArray(t.subtitles)?t.subtitles.length>0&&!Array.isArray(t.subtitles[0])&&typeof t.subtitles[0]=="object"?[t.subtitles]:t.subtitles:[]}normalizeSoundbites(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:[]}async parseHLSMasterManifest(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch master manifest: ${e.status}`);let s=(await e.text()).split(`
|
|
2
2
|
`);for(let r of s)if(r.includes("#EXT-X-MEDIA:TYPE=AUDIO")&&r.includes("URI=")){let a=r.match(/URI="([^"]+)"/);if(a){let o=a[1];return o.startsWith("http")?o:`${t.substring(0,t.lastIndexOf("/"))}/${o}`}}throw new Error("No audio stream found in manifest")}catch(e){throw e}}async parseAudioPlaylist(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch audio playlist: ${e.status}`);let i=await e.text(),s=new Map,r=i.split(`
|
|
3
|
-
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let m=o.match(/#EXTINF:([0-9.]+)/);if(m){let u=parseFloat(m[1]);s.set(a,u),a++}}return s}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let i=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let s=await this.parseHLSMasterManifest(i),r=await this.parseAudioPlaylist(s);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let e=this._audioPlaylistCache.segmentDurations.get(t);return e!==void 0?e:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let e=await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(e)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let e;if(this.phontClient){if(!ut&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ut||this.phontClient.apiBaseUrl,s=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);e=await s.json()}else{if(!ut)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ut}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);e=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),e}catch{return null}}async fetchSubtitleData(t,e=null){if(this.stateManager.clearVodState(),!!t)try{let i,s;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");s=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let m=r.searchParams.get("lang")||e||void 0,u=r.searchParams.get("model")||void 0;try{i=await this.phontClient.getSubtitleTrack(s,m||null,u||null)}catch(l){let d=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),c=typeof l?.message=="string"?l.message:String(l||""),C=d===404||c.includes("404")||c.includes("Not Found"),f=d===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(C||f)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{s=t;let r=e&&e.trim()||void 0;try{i=await this.phontClient.getSubtitleTrack(s,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),m=typeof a?.message=="string"?a.message:String(a||""),u=o===404||m.includes("404")||m.includes("Not Found"),l=o===400||m.includes("400")||m.includes("Bad Request")||m.includes("HTTP error! status: 400");if(u||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${u?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);s=l?l[1]:t.split("/").pop().split("?")[0]}else{if(s=t,!ut&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ut||this.phontClient?.apiBaseUrl,d=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&d.append("lang",e.trim());let c=d.toString();r=c?`${l}/vod-subtitles/${s}?${c}`:`${l}/vod-subtitles/${s}`}let a={"Content-Type":"application/json"},o=pe(),m=be();o&&(a.Authorization=`Bearer ${o}`),m&&(a["X-Session-ID"]=m);let u=await fetch(r,{headers:a,cache:"no-store"});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);i=await u.json()}return this.stateManager.updateVodVideoId(s),{data:i,videoId:s}}catch(i){throw this.stateManager.clearVodState(),i}}};var ye={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Pt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[i,s]of Object.entries(ye)){let r=i.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return s}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let i of t.important){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`important_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let i of t.all){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`all_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(i=>{if(i.animationFile==="Laughter"){let s=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-i.startTime)<=1);if(s){s.endTime=Math.max(s.endTime,i.endTime);return}}e.push(i)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,i=2,s=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&e<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:c})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let m of o){let u=this.mapEventLabelToAnimation(m.event_label);if(u){let l=m.start_time??m.onset??0,d=m.end_time??m.offset??0;if(e>=l&&e<=d){let C="all";this.stateManager.state.soundByteImportant?.includes(m)?C="important":this.stateManager.state.soundByteFiltered?.includes(m)&&(C="filtered"),s.push({id:`live_${m.event_label}_${l}`,eventLabel:m.event_label,animationFile:u,startTime:l,endTime:d,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};s.sort((o,m)=>{let u=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=m.eventLabel==="Laughter"?1:r[m.priority]||5;return u-l});let a=s.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=s=>Array.isArray(s)?s.length>0&&Array.isArray(s[0])?s.flat():s:[];return t?{all:e(this.stateManager.vodState.soundByteAll||[]),important:e(this.stateManager.vodState.soundByteImportant||[]),filtered:e(this.stateManager.vodState.soundByteFiltered||[])}:{all:e(this.stateManager.state.soundByteAll||[]),important:e(this.stateManager.state.soundByteImportant||[]),filtered:e(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,e=null){let i=[],s=[],r=e??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}return{all:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,e=30){let i=t-e,s=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=i),this.stateManager.state.soundbiteAnimations.length<s&&this.stateManager.notify()}};var Lt=class{constructor(t,e,i){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=i}processVodData(t,e,i,s){let r=e.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(e?e.split("/").pop()?.split("?")[0]:void 0),m=a.flat().map(f=>({...f,sequence_number:o}));s&&s.length>0&&(m=this._mergeAnimationDataFromOriginal(m,s));let u=this._deduplicateSubtitles(m),{soundByteAll:l,soundByteImportant:d,soundByteFiltered:c}=this._processSoundbites(t.soundbite);if(l.length>0||d.length>0||c.length>0){let f={all:l,important:d,filtered:c},h=this.soundbiteProcessor.processSoundbiteAnimations(f);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...h]}let C=t.language||i||null;this.stateManager.vodState={subtitles:u,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:d,soundByteFiltered:c,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[VodDataProcessor] Processed VOD data:",{subtitleCount:u.length,firstSubtitle:u[0]?{start_time:u[0].start_time,end_time:u[0].end_time,text:u[0].text,hasWords:!!u[0].words,wordCount:u[0].words?.length||0,emotion:u[0].emotion,animations:u[0].animations}:null,videoId:r,languageCode:i}),this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,e){let i=new Map;for(let s of e){let r=`${s.start_time}-${s.end_time}`;(!i.has(r)||s.animations||s.emotion)&&i.set(r,s)}return t.map(s=>{let r=`${s.start_time}-${s.end_time}`,a=i.get(r);if(!a)return s;let o=s.animations&&typeof s.animations=="object"&&Object.keys(s.animations).length>0,m=s.emotion&&s.emotion!=="none"&&s.emotion!=="neutral",u=typeof s.animation_url=="string"&&s.animation_url.length>0;if(o&&u)return s;let l={...s};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!m&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!u&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let d=new Map;for(let c of a.words)d.set(`${c.start}-${c.end}`,c);l.words=l.words.map(c=>{let C=d.get(`${c.start}-${c.end}`);if(!C||c.animations&&typeof c.animations=="object"&&Object.keys(c.animations).length>0)return c;let h={...c};return C.animations&&Object.keys(C.animations).length>0&&(h.animations=C.animations),!h.emotion&&C.emotion&&(h.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(h.emotion_intensity=C.emotion_intensity)),!h.animation_url&&C.animation_url&&(h.animation_url=C.animation_url),h})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let i of t){let s=`${i.start_time}-${i.end_time}`;(!e.has(s)||i.emotion||i.animations)&&e.set(s,i)}return Array.from(e.values())}_processSoundbites(t){let e=[],i=[],s=[];return t&&(t.all&&Array.isArray(t.all)&&(e=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(i=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(s=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:i,soundByteFiltered:s}}};var Rt=class{constructor(t,e,i){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=i}async processLiveSegment(t,e,i){this.stateManager.state.processedSequences.add(e),this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let s=await i(e);this.stateManager.state.segmentDurations.set(e,s);let r=this.liveTimeGenerator.getCumulativeDuration(e),a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:m,processedSoundbitesFiltered:u}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,m,u);let l={all:o,important:m,filtered:u},d=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(d),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(c=>c.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,i){return!t||!Array.isArray(t)?[]:t.map(s=>({...s,sequence_number:e,start_time:s.start_time+i,end_time:s.end_time+i,words:s.words?s.words.map(r=>({...r,start:r.start+i,end:r.end+i})):void 0}))}_processSoundbites(t,e){let i=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),s=(t?.important||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e}));return{processedSoundbitesAll:i,processedSoundbitesImportant:s,processedSoundbitesFiltered:r}}_updateState(t,e,i,s){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...e],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...i],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...s]}};var Dt=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let e=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=e,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(e-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let e=t.src,i=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),i&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let i=this.stateManager.state.initialSequenceOffset;i<t;i++){let s=this.stateManager.state.segmentDurations.get(i)||10;e+=s}return e}};var Ot=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,e){if(!t)return null;let s=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(e>=a.start)r.push(a.word);else break;s=r.join(" ")}return{activeSubtitle:t,displayText:s}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[CurrentSubtitle] No subtitles in vodState:",{hasVodState:!!e,subtitleCount:e?.subtitles?.length||0,vodStateKeys:e?Object.keys(e):[]}),null;let i=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!i&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let s=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(typeof window<"u"&&window.location.search.includes("debug=subtitles")&&!s&&t>0&&console.log("[CurrentSubtitle] No subtitle found for time:",{time:t,subtitleCount:e.subtitles.length,firstSubtitle:e.subtitles[0]?{start_time:e.subtitles[0].start_time,end_time:e.subtitles[0].end_time,text:e.subtitles[0].text||e.subtitles[0].words?.map(r=>r.word).join(" ")}:null,lastSubtitle:e.subtitles[e.subtitles.length-1]?{start_time:e.subtitles[e.subtitles.length-1].start_time,end_time:e.subtitles[e.subtitles.length-1].end_time}:null}),s){let r=this._processSubtitleText(s,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,m=e.currentSubtitle!==o||e.currentSubtitleData!==a;return m&&(e.currentSubtitle=o,e.currentSubtitleData=a,e.currentSequence=e.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=e.currentSequence??null),(i||m)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return e.currentSubtitle!==""&&(e.currentSubtitle="",e.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let e=t.subtitles.find(i=>t.currentTime>=i.start_time&&t.currentTime<=i.end_time);if(e){t.currentSequence=e.sequence_number??null;let i=this._processSubtitleText(e,t.currentTime);if(!i)return null;let{activeSubtitle:s,displayText:r}=i;return(t.currentSubtitle!==r||t.currentSubtitleData!==s)&&(t.currentSubtitle=r,t.currentSubtitleData=s,this.stateManager.notify()),this._lastSubtitleData=s,this._lastSubtitleTime=t.currentTime,s}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var rs=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function Se(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var gt=class{constructor(){this.stateManager=new ft,this.cache=new Bt,this.fetcher=new Ft(this.stateManager),this.soundbiteProcessor=new Pt(this.stateManager),this.vodDataProcessor=new Lt(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new Dt(this.stateManager),this.liveDataProcessor=new Rt(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new Ot(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,e="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?e:"none",this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}async fetchSubtitles(t){try{let e=await this.fetcher.fetchSubtitles(t);return e?await this.liveDataProcessor.processLiveSegment(e,t,i=>this.getAudioSegmentDuration(i)):null}catch{return null}}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,i,s){this.vodDataProcessor.processVodData(t,e,i,s)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,e=30){let i=t-e,s=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=i),this.state.subtitles.length<s&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,e=null){return this.soundbiteProcessor.getActiveSoundbites(t,e)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,e=30){this.soundbiteProcessor.clearOldAnimations(t,e)}getCurrentSpeaker(t=!1,e=null){if(!this.state.isSpeaker)return null;let i=null;if(t?i=this.vodState.currentSubtitleData:i=this.state.currentSubtitleData,!i||!i.words)return null;let s=i?.speaker;return s||null}async fetchSubtitleData(t,e=null,i=null){if(!e&&t){let s=new URLSearchParams(t.split("?")[1]||"");e=s.get("lang")||null,i||(i=s.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let s=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=s,o=r?.language||e||null;console.log("[SubtitleManager] Fetched subtitle data:",{hasData:!!r,hasSubtitles:!!r?.subtitles,subtitleCount:r?.subtitles?.length||0,videoId:a,url:t,translation_provider:r?.translation_provider||"deepl",translation_model:r?.translation_model||"none",language:o||"ORIGINAL",usingLLM:r?.translation_provider==="phont"});let m=Se(o??e),u=i?`${m}_${i}`:m,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(u,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let c;if(!!e&&String(e).trim()!==""){let f=this.cache._subtitleCache.get("original");f?.data?.subtitles&&(c=Array.isArray(f.data.subtitles)?f.data.subtitles.flat():[])}console.log("[SubtitleManager] Processing VOD data..."),this._processVodData(r,t,o,c),console.log("[SubtitleManager] VOD data processed. State:",{subtitleCount:this.state.subtitles.length,vodSubtitleCount:this.vodState.subtitles?.length||0,currentSequence:this.state.currentSequence})}catch(s){let r=s?.status||s?.response?.status,a=r===404||typeof s?.message=="string"&&s.message.includes("404")||typeof s?.message=="string"&&s.message.includes("Not Found"),o=r===400||typeof s?.message=="string"&&s.message.includes("400")||typeof s?.message=="string"&&s.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:s?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",s),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,e,i=null){if(!e)return;let s=Se(t);if(this.cache._loadingLanguages.has(s))return;let r=i?`${s}_${i}`:s,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(s);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let m=new URLSearchParams;t&&m.append("lang",t),i&&m.append("model",i);let u=m.toString(),l=`${o}/vod-subtitles/${e}${u?`?${u}`:""}`,d=!1;try{await this.fetchSubtitleData(l,t,i),d=!0}catch(c){if(c?.status===404||typeof c?.message=="string"&&c.message.includes("404"))if(t!==null)d=!0;else throw c;else throw c}if(!d)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,i)}finally{this.cache._loadingLanguages.delete(s)}}_loadCachedSubtitles(t,e,i){let s=t?.language||i||null,r;if(!!i&&String(i).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,e,s,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},we=new gt;function on(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[i,s]=e.split(","),r=t||typeof s=="string"&&(s.startsWith("#")||s.startsWith("%23")),a;return r?a=s.replace(/%23/g,"#"):a=parseFloat(s),{time:parseFloat(i),value:a}})}catch(e){return console.error("Error decoding points:",e),[]}}function ln(n){if(!n)return"";if(n.includes("://"))try{let t=new URL(n);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=n.indexOf("?");return t!==-1?n.substring(t+1):n}return n.startsWith("?")?n.slice(1):n}function Wt(n){try{let t=ln(n),e=new URLSearchParams(t),i={parameterStates:{}};if(e.has("name")&&(i.name=e.get("name")||void 0),e.has("user")&&(i.userName=e.get("user")||void 0),e.has("duration")&&(i.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(i.animationMode=e.get("mode")||void 0),e.has("text")&&(i.text=e.get("text")||void 0),e.get("format")==="normalized"&&(i.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?i.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:i.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{i.backgroundStyle=JSON.parse(e.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of e.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),m=on(a,o);if(m.length>0){let u=o?"#000000":0;i.parameterStates[r]={points:m,currentValue:m[0]?.value||u}}}return i}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function ve(n){if(n===0)return 0;let t=4,e;if(n<=.7){let i=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*i}else{let i=(n-.7)/.3,s=Math.log(1+.5*(Math.exp(t)-1))/t;e=s+i*(1-s)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function jt(n){if(typeof n!="string")return{r:0,g:0,b:0};let t=n.replace("#","").padStart(6,"0"),e=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function xe(n,t,e){let i=s=>{let r=Math.round(Math.max(0,Math.min(255,s))).toString(16);return r.length===1?"0"+r:r};return"#"+i(n)+i(t)+i(e)}function Ae(n,t,e){let i=jt(n),s=jt(t),r=Math.max(0,Math.min(1,e)),a=i.r+(s.r-i.r)*r,o=i.g+(s.g-i.g)*r,m=i.b+(s.b-i.b)*r;return xe(a,o,m)}function un(n,t,e){if(e===0)return n;let i=jt(n),s=jt(t),r=i.r+(s.r-i.r)*e,a=i.g+(s.g-i.g)*e,o=i.b+(s.b-i.b)*e;return xe(r,a,o)}function ct(n,t,e,i=!1,s=null){if(!n||n.length===0)return null;let r=i?t:t*e,a=null,o=null;for(let m=0;m<n.length;m++){let u=n[m],l=u.time!==void 0?u.time:Array.isArray(u)?u[0]:0;if(l!==void 0&&l<=r&&(a=u),l!==void 0&&l>=r&&!o){o=u;break}}if(!a&&n[0])return(n[0].value!==void 0?n[0].value:Array.isArray(n[0])?n[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let m=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,u=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,d=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(m===u||l===null||d===null)return l??null;let c=(r-m)/(u-m),C=s==="color"||s==="shadowColor"||s==="outlineColor"||s==="outline2Color"||s==="outline3Color"||s==="outlineShadowColor"||s==="glowColor";if(C&&(typeof l=="string"||typeof d=="string"))return Ae(typeof l=="string"?l:"#000000",typeof d=="string"?d:"#000000",c);if(!C&&(typeof l=="string"||typeof d=="string")){let f=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),h=typeof d=="string"&&(d.startsWith("#")||/^[0-9a-f]{6}$/i.test(d));if(f&&h){let g=l.startsWith("#")?l:`#${l}`,_=d.startsWith("#")?d:`#${d}`;return Ae(g,_,c)}return d??null}return l+(d-l)*c}return null}var ee=.7,pt=.7,Te={rawMode:!0};function mt(n,t,e,i,s=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*i/(ee*pt),o=n.duration||2,u=n.format==="normalized"?e:e*o,l=!0,d=n.parameterStates||{},c=(A,B,$=!0,q=null)=>{let ht=q??a,at=ct(d[A]?.points,u,o,l);return at==null?B:$?ht===0?B:B+(at-B)*ht:at},C=c("scale",1),f=c("skew",0),h=c("stretch",1),g=c("translateX",0),_=c("translateY",0),b=c("weight",500),E=c("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",D=n.text||"Hello",R=(A,B)=>{let $=ct(d[A]?.points,u,o,l,A);if($==null)return B;let q=typeof $=="string"?$.startsWith("#")?$:`#${$}`:`#${Math.round($).toString(16).padStart(6,"0")}`;return a===0?B:un(B,q,a)},k=R("color","#ffffff"),P=c("opacity",1),I=c("shadowX",0),T=c("shadowY",0),H=c("shadowBlur",4),et=c("shadowOpacity",.5),O=R("shadowColor","#000000"),vt=c("outlineWidth",0),Ht=R("outlineColor","#000000"),W=A=>d[A]?.points?.length>0,dt=W("stretchX")?c("stretchX",1):void 0,xt=W("outline2Width")?c("outline2Width",0):void 0,Tt=W("outline2Color")?R("outline2Color","#000000"):void 0,Mt=W("outline3Width")?c("outline3Width",0):void 0,_t=W("outline3Color")?R("outline3Color","#000000"):void 0,S=W("outlineShadowWidth")?c("outlineShadowWidth",0):void 0,X=W("outlineShadowColor")?R("outlineShadowColor","#000000"):void 0,j=W("outlineShadowBlur")?c("outlineShadowBlur",0):void 0,v=W("glowIntensity")?c("glowIntensity",0):void 0,L=W("glowColor")?R("glowColor","#ffffff"):void 0,N=W("snakeWave")?c("snakeWave",0):void 0,nt=W("karaoke")?c("karaoke",0):void 0,Y=1-.5*Math.min(1,Math.max(0,i)),V=c("blur",0,!0,r?1:a*Y),Ct=ct(d.thinStroke?.points,u,o,l),K=ct(d.ascenderHeight?.points,u,o,l),it={};Ct!=null&&typeof Ct=="number"&&(it.YOPQ=Ct),K!=null&&typeof K=="number"&&(it.YTAS=K),b!=null&&(it.wght=b),E!=null&&(it.wdth=E);let J=[];if(I!==0||T!==0||H!==4||et!==.5){let A=typeof O=="string"?O:"#000000",B=parseInt(A.slice(1,3),16),$=parseInt(A.slice(3,5),16),q=parseInt(A.slice(5,7),16);J.push(`${I}px ${T}px ${H}px rgba(${B}, ${$}, ${q}, ${et})`)}else if(O&&typeof O=="string"&&O!=="#000000"){let A=O.startsWith("#")?O:`#${O}`,B=parseInt(A.slice(1,3),16)||0,$=parseInt(A.slice(3,5),16)||0,q=parseInt(A.slice(5,7),16)||0;J.push(`3px 2px 4px rgba(${B}, ${$}, ${q}, 0.5)`)}if(v!=null&&v>0){let A=typeof L=="string"?L:"#ffffff";J.push(`0 0 ${v}px ${A}`),J.push(`0 0 ${v*2}px ${A}`),J.push(`0 0 ${v*4}px ${A}`)}let Kt=J.length>0?J.join(", "):"",lt=0;if(d.joy?.points&&d.joy.points.length>0)for(let A of d.joy.points){let B=Array.isArray(A)?A[1]:A.y??A.value??0;typeof B=="number"&&B>lt&&(lt=B)}let Et=c("joy",0,!1),Jt=r?Et:Math.min(1,lt*a),Z=c("fear",0),Q=c("standardEmphasis",0,!1),st=c("strongEmphasis",0,!1),M={rawIntensity:t,scaleFactor:a,scale:C,slant:f,stretchY:h,translateX:g,translateY:_,weight:b,width:E,fontFamily:y,textColor:k,opacity:P,textShadow:Kt,blur:V,outlineWidth:vt,outlineColor:Ht,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:it,text:D,joy:Jt,fear:Z,standardEmphasis:Q,strongEmphasis:st,joyWaveProgress:u/o*1.5};return dt!==void 0&&(M.stretchX=dt),xt!==void 0&&(M.outline2Width=xt),Tt!==void 0&&(M.outline2Color=Tt),Mt!==void 0&&(M.outline3Width=Mt),_t!==void 0&&(M.outline3Color=_t),S!==void 0&&(M.outlineShadowWidth=S),X!==void 0&&(M.outlineShadowColor=X),j!==void 0&&(M.outlineShadowBlur=j),v!==void 0&&(M.glowIntensity=v),L!==void 0&&(M.glowColor=L),N!==void 0&&(M.snakeWave=N),nt!==void 0&&(M.karaoke=nt),M}var x={fontSize:54,opacity:1,weight:400,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:4,color:"rgba(0, 0, 0, 0.4)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:1.25,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function bt(n,t,e){let i=Math.max(0,Math.min(1,n)),s=e??t;if(typeof s=="number"&&Number.isFinite(s)){let r=Math.max(0,Math.min(1,s));return Math.min(1,Math.max(0,r*(i/pt)))}return i}function Nt(n){let t=.2+.8*n,e=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*n;return{gts:n,maxExpression:t,threshold:e,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function cn(n,t){return n>=t}function ne(n,t){if(t<=.2)return 0;let e=n*t;return n>.1&&console.log(`[GTS Scaling] Raw: ${n.toFixed(3)} \xD7 maxExpression: ${t.toFixed(3)} = Final: ${e.toFixed(3)} | Match check: ${n.toFixed(3)} === ${e.toFixed(3)}? ${n===e}`),e}function se(n){let{minThreshold:t,maxThreshold:e}=p.emphasis;return n<t||n>=e?0:(n-t)/(e-t)}function ie(n){return n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold}function ae(n){return n>=p.strongEmphasis.minThreshold}function mn(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,m=n*n,u=m*n;return o*0+3*a*n*.42+3*r*m*.58+u*1}var Me=new WeakMap,re={joy:1,social_positive:1,anger:-1,screaming:-1};function oe(n,t,e,i){let s=typeof e=="string"?e.toLowerCase():"";if(s==="joy")return dn(n,t,i);let r=Math.sign(t);return r!==0?r:s in re?re[s]:i}function dn(n,t,e){let i=Math.sign(t);if(n){let s=Me.get(n);if(s!==void 0)return s;let r=i!==0?i:_e(e);return Me.set(n,r),r}return i!==0?i:_e(e)}function _e(n){return n!==0?n:re.joy}function Cn(n,t,e=1,i=0,s=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:m,scaleDownFrames:u,fps:l}=p.emphasis;if(!n||!ie(a))return null;let d=t-n.start,c=s?n.start+s:n.end,C=c-n.start;if(d<0||t>=c)return null;let f=Math.max(0,Math.min(1,d/C)),h=0;f<.5?h=f*2:h=2-f*2,h=h*h*(3-2*h);let g=se(a),_=.55,b=3*_,F=oe(n,i,r,0)*b*h*e*g,y=140*h*e*g,D=1+o*_*h*e*g,R=f<1;return{scaleMultiplier:D,slantAdditive:F,weightBoost:y,scaleProgress:h,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:d,scaleActive:R}}function hn(n,t,e={},i=1,s=null,r=0,a=""){let o=a==="anger"||a==="screaming",m=p.strongEmphasis,u=.7,l=s?n.start+s:n.end;if(t<n.start)return null;let d=n.emphasis||0;if(!ae(d))return null;let c=m.fadeOutTailDuration,C=l+c;if(t>=C)return null;let f=l-n.start,h=Math.max(0,Math.min(1,(t-n.start)/f)),g=1,_=t>=l;if(_){let T=(t-l)/c;g=1-mn(T),h=1}let b=0;h<.5?b=h*2:b=2-h*2;let E=b*b*(3-2*b),F=(d-m.minThreshold)/(1-m.minThreshold),y=E*F*i,D=y;y<.1&&(y=0);let R=oe(n,r,a,-1),k,P;if(o)k={scale:1+y*(m.maxScale-1)*u,rotation:y*m.maxRotation*u,translateY:-y*m.maxTranslateY*u,translateX:y*m.maxTranslateX*u,skewX:R*y*m.maxSkew*u,stretchY:1},P={brightness:1+y*m.maxBrightness*u,contrast:1+y*m.maxContrast*u,shadowBlur:y*m.maxShadowBlur*u,shadowOpacity:y*m.shadowOpacity*u,zIndex:Math.round(y*m.maxZIndex*u)};else{let et=E*20*Math.max(.2,F*i)*u,O=oe(n,r,a,1);k={scale:1+y*.15*u,rotation:0,translateY:0,translateX:0,skewX:O*et,stretchY:1},P={brightness:1+y*.2*u,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(k.scale=1+(k.scale-1)*g,k.rotation=k.rotation*g,k.translateX=k.translateX*g,k.translateY=k.translateY*g,k.skewX=k.skewX*g,P.brightness=1+(P.brightness-1)*g,P.contrast=1+(P.contrast-1)*g,P.shadowBlur=P.shadowBlur*g,P.shadowOpacity=P.shadowOpacity*g,P.zIndex=Math.round(P.zIndex*g),y=y*g);let I=280*y*i;return{emphasis:y,rawEmphasis:D,...k,...P,weightBoost:I,shadowOffsetX:y*m.shadowOffsetX,shadowOffsetY:y*m.shadowOffsetY,gtsMultiplier:i,emphasisMultiplier:F,fadeFactor:g,isInTail:_}}function le({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:i,wordBaseSlant:s,isActive:r,wordEmotion:a=""}){let o=r?Cn(n,t,e,s,i,a):null,m=hn(n,t,{},e,i,s,a);return{emphasisEffect:o,strongEmphasisData:m}}function Ee(n){let t=2*Math.PI/3;return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*t)+1}function Ie(n){return 1-(1-n)*(1-n)}function ue(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function fn(n,t,e,i=1){let s=p.joy.letterWave,r=e<=6,a,o,m;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),m=a+o):(a=s.innerWidthRatio,o=s.outerWidthRatio,m=a+o);let u=t/Math.max(1,e-1),l=n;r&&e<=3?l=Math.min(1.2,n*1.25):r&&(l=Math.min(1.1,n*1.1));let d=l*(1+m),c=u-d,C=a+o,f=o*.3;if(c>f||c<-C)return null;let h=0;if(c>0&&c<=f)h=(1-c/f)*.15;else if(c<=0&&c>=-a){let y=Math.abs(c)/Math.max(a,.01);h=Ee(y)}else if(c<-a){let D=(Math.abs(c)-a)/Math.max(o,.01);h=Ie(1-D)}if(h<=.01)return null;let g=h*i,b=1-t%2*.15,E={scale:1+g*(s.maxScale-1)*b,rotation:g*s.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*s.maxTranslateY*b,skewX:-g*s.maxSkew*.5,stretchY:1},F={brightness:1+g*s.maxBrightness,contrast:1+g*s.maxContrast,shadowBlur:g*s.maxShadowBlur,shadowOpacity:g*s.shadowOpacity,zIndex:Math.round(g*s.maxZIndex)};return{pressure:g,...E,...F,shadowOffsetX:g*3,shadowOffsetY:g*3}}function gn(n,t,e,i=1){let s=p.joy.letterBulge,r=s.innerWidthRatio,a=s.outerWidthRatio,o=r+a,m=e>1?t/Math.max(1,e-1):0,u=n*(1+o),l=m-u,d=a*.35,c=o;if(l>d||l<-c)return null;let C=0;if(l>0&&l<=d)C=(1-l/Math.max(d,1e-4))*.18;else if(l<=0&&l>=-r){let D=Math.abs(l)/Math.max(r,1e-4);C=Ee(D)}else if(l<-r){let R=(Math.abs(l)-r)/Math.max(a,1e-4);C=Ie(1-R)}if(C<=.01)return null;let f=C*i,h=Math.min(1,f*.85),g=1,_=t%3===0?1:-1,b=Math.max(1-s.maxCompressionX,1-h*s.maxCompressionX),E=1+h*s.maxStretchY,F={scale:1+h*(s.maxScale-1),stretchY:E,stretchX:b,rotation:h*s.maxRotation*g,translateX:h*s.maxTranslateX*_,translateY:-h*s.maxTranslateY,skewX:h*s.maxSkew*g},y={brightness:1+h*s.maxBrightness,contrast:1+h*s.maxContrast,shadowBlur:h*s.maxShadowBlur,shadowOpacity:h*s.shadowOpacity,zIndex:Math.round(h*s.maxZIndex)};return{pressure:h,bulgeIntensity:h,...F,...y,shadowOffsetX:h*1.8,shadowOffsetY:h*3}}function pn(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,i=n.rotation||0,s=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${i}deg) skewX(${a}deg) translate(${s}px, ${r}px)`}function bn(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,i=n.shadowBlur||0,s=n.shadowOpacity||0,r=n.shadowOffsetX||0,a=n.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),e!==1&&o.push(`contrast(${e})`),i>0&&s>0&&o.push(`drop-shadow(${r}px ${a}px ${i}px rgba(255, 255, 255, ${s}))`),o.join(" ")}var yn=["anger","fear","sadness","joy"];function Sn(n){return yn.includes(n.toLowerCase())}function yt(n){return n.map(([t,e])=>{let i=Sn(t),s=i?1.5:1,r=e*s;return[t,e,r,s,i]})}function ke(n){if(!n)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=n.confidence_word||0,e=n.emphasis||0;return{confidence:t,emphasis:e,hasEmphasis:e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold,hasStrongEmphasis:e>=p.strongEmphasis.minThreshold}}function St(n){return n&&(n.subtitle||n.text)||""}function Xt(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function wt(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function tt(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function At(n){return tt(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function $t(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function Be(n,t,e=null,i=null){if((i?.name==="children"||i?.name==="hello-kitty")&&e&&i.fonts?.[e])return i.fonts[e];let s=p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold;return s?x.angryFont:r?x.joyFont:a?x.sadnessFont:x.defaultFont}function Ut(n,t,e=null,i=null){let s=Be(n,t,e,i),r="sans-serif";return s==="Cormorant"&&(r="serif"),`"${s}", ${r}`}function wn(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function An(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function vn(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var Le='"Roboto Flex", "Roboto", sans-serif',Fe=new Map,xn={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function Yt(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?xn[t]||t:""}function ce(n){if(typeof n!="string"||n.length===0)return null;let t=Fe.get(n);if(t)return t;try{let e=Wt(n);return Fe.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function Tn(n){if(!n||n.length===0)return null;let t=n.filter(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(e=>e.start_time)),end:Math.max(...t.map(e=>e.end_time))}}function Mn(n,t){return n.find(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number"&&t>=e.start_time&&t<=e.end_time)||null}function Vt(n){return n&&typeof n.animation_url=="string"&&n.animation_url.length>0?n.animation_url:null}function Re(n,t){if(!n)return{emotion:"none",intensity:0};let e=wt(n),i=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(i.length>0){let a=yt(i).sort((o,m)=>m[2]-o[2])[0];return{emotion:Yt(a[0])||"none",intensity:a[1]}}let s=Yt(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!s||s==="none"||r<=0?Vt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:s,intensity:r}}function _n(n){let t={...n};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function Pe(n,t,e,i){let{minWordDisplayTime:s,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,m=Math.max(0,n.end-n.start),u=Math.max(m,s);if(!i)return n.start+u;let l=typeof t.end_time=="number"?t.end_time:n.end,d=l-n.end,c=!1;if(e!=null&&e>l?(d=e-n.end,c=d>=o):e==null?(c=!0,d=1/0):c=d>=a,c){let f=d===1/0?s+r:n.end+d-n.start-.1,g=m<s?f:Math.min(s+r,f);u=Math.max(u,g)}return n.start+u}function En(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let i=n.findIndex(a=>t>=a.start&&t<a.animationEnd),s=n.reduce((a,o,m)=>t>=o.animationEnd?m:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||s!==-1&&o<=s?1:e?0:.3),currentWordIndex:i}}function De(n){if(!n)return x.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),i=e.toLowerCase();return i.includes("bricolage")?"Bricolage Grotesque":i.includes("rakkas")?x.angryFont:i.includes("parkinsans")?x.joyFont:i.includes("cormorant")?x.sadnessFont:i.includes("roboto")?x.defaultFont:e}function In(n,t,e){let i={text:"",fontSize:x.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:Le,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return i;let s=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=s<=.2,m=Nt((s-.2)/.8).gts,u=n.start_time,l=n.end_time,d=Math.max(.01,l-u),c=Math.max(0,Math.min(1,(t-u)/d)),C=Re(n,r),f=o?"none":C.emotion,h=o?0:Math.max(0,C.intensity),g=ce(Vt(n)),_=bt(m,n.gts,void 0),b=g?mt(g,h,c,_,d):null,E=b?.fontFamily?`"${De(b.fontFamily)}", sans-serif`:Ut(f,s),F={fontSize:x.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??x.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?_n(F):F,text:St(n),emotion:f,emotionIntensity:h,fontFamily:E,startTime:u,endTime:l,duration:d,isActive:t>=u&&t<l}}function kn(n,t,e){let i=e.maxExpression??1,s=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,m=e.transparentUntilSpoken??!1,u=i<=.2,l=Nt((i-.2)/.8).gts,d={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:Le,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return d;let c=tt(n)?At(n):[n],C=Tn(c),f=Mn(c,t);if(!f&&o!=null&&t>n.end_time&&t<=o&&(f=c[c.length-1]||null),!f&&C&&t>=C.start&&t<=C.end&&(f=[...c].filter(S=>S&&t>=S.start_time).sort((S,X)=>X.start_time-S.start_time)[0]||null),f==null)return d;let h=f,g=Re(h,s),_=u?"none":g.emotion,b=u?0:Math.max(0,g.intensity),E=h.start_time,F=h.end_time,y=Math.max(.01,F-E),D=Math.max(0,Math.min(1,(t-E)/y)),R=tt(n)?null:ce(Vt(h)),k=h.gts??n.gts,P=bt(l,k,void 0),I=R?mt(R,b,D,P,y):null,T={fontSize:x.fontSize,scale:I?.scale??(_==="none"?1:1+b*.16),opacity:I?.opacity??1,slant:I?.slant??0,weight:I?.weight??400,width:I?.width??100,textColor:I?.textColor??x.textColor,translateX:I?.translateX??0,translateY:I?.translateY??0,stretchY:I?.stretchY??1,textShadow:I?.textShadow??"",blur:I?.blur??0,outlineWidth:I?.outlineWidth??0,outlineColor:I?.outlineColor??"#000000",fontVariationAxes:I?.fontVariationAxes??{}},H=Xt(n).flatMap(S=>{let X=String(S?.word??""),j=X.trim();if(!j.includes(" "))return[S];let v=j.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,v.length),nt=X.startsWith(" ");return v.map((Y,V)=>({...S,word:(V===0&&nt?" ":"")+Y,start:(S.start??0)+V*N,end:(S.start??0)+(V+1)*N}))}),et=null;if(tt(n)&&C?.end){let S=H[H.length-1],X=Pe(S,n,a,!0),j=o??X,{minWordDisplayTime:v,breathingRoomDuration:L}=p.timing,N=v+L,Y=(H.length>0?Math.min(...H.map(V=>V.start)):C.start)+N;et=Math.max(C.end,j,Y)}let O=H.map((S,X)=>{let j=X===H.length-1,v=Pe(S,n,a,j);return{...S,animationEnd:tt(n)&&et?Math.max(v,et):v}}),{currentWordIndex:vt,opacities:Ht}=En(O,t,m),W=O.map((S,X)=>{let j=t>=S.start&&t<S.end,v=_,L=b,N=b,nt=tt(n)?At(n):null,Y=nt?$t(nt,S):h;if(Y){let rt=wt(Y),kt=Object.entries(rt).filter(([,G])=>typeof G=="number"&&G>s),Zt=Object.entries(rt).filter(([,G])=>typeof G=="number");if(Zt.length>0)N=[...Zt].sort((ot,Qt)=>Qt[1]-ot[1])[0][1];else{let G=Yt(Y.emotion),ot=typeof Y.emotion_intensity=="number"?Y.emotion_intensity:0;G&&ot>0&&(v=G,N=ot,L=ot)}if(kt.length>0){let G=yt(kt).sort((ot,Qt)=>Qt[2]-ot[2]);v=Yt(G[0][0])||"none",L=G[0][1]}else Zt.length>0&&(v="none",L=0)}u?(v="none",L=0):L===N&&L!==0&&(L=ne(L,i));let V=Math.max(.01,(S.end??0)-(S.start??0)),Ct=Math.max(0,Math.min(1,(t-S.start)/V)),K=ce(Vt(Y)),it=N>0?N:K?Math.max(1,b||0):0,J=bt(l,k,S.gts),w=K?mt(K,it,Ct,J,V):null,Kt=De(K?.fontData?.style?.fontFamily),lt=(K?.parameterStates?.standardEmphasis?.points?.length??0)>0,Et=(K?.parameterStates?.strongEmphasis?.points?.length??0)>0,Jt=lt||Et,Z=j?w?.standardEmphasis??0:0,Q=j?w?.strongEmphasis??0:0,st=null,M=null;if(Jt){let rt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:0;if(lt&&(st={scaleMultiplier:1+.272*Z*i,slantAdditive:rt*4.25*Z*i,weightBoost:250*Z*i,scaleProgress:Z,gtsMultiplier:i,emphasis:Z,emphasisMultiplier:Z,elapsed:0,scaleActive:Z>0}),Et&&!r){let kt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:1;M={emphasis:Q,rawEmphasis:Q,scale:1+Q*.38,skewX:kt*Q*30*i,weightBoost:400*Q*i,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+Q*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:i,emphasisMultiplier:Q,fadeFactor:1,isInTail:!1}}}else{let rt=le({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:i,emotionAnimationDuration:V,wordBaseSlant:w?.slant||0,isActive:j,wordEmotion:v});st=rt.emphasisEffect,M=r?null:rt.strongEmphasisData}let A=Ht[X]??1,B=(w?.opacity??T.opacity??1)*A,q=(w?.scale??T.scale??1)*(st?.scaleMultiplier||1),ht=(w?.slant??T.slant??0)+(st?.slantAdditive||0),at=q,Ce=st?.weightBoost||0;M&&(ht+=M.skewX||0,Ce+=M.weightBoost||0,at=q*(M.scale||1));let z={...T,fontSize:x.fontSize,scale:at,slant:ht,stretchY:w?.stretchY??T.stretchY??1,weight:(w?.weight??T.weight??400)+Ce,width:w?.width??T.width??100,textColor:w?.textColor??T.textColor??x.textColor,opacity:B,translateX:w?.translateX??T.translateX??0,translateY:w?.translateY??T.translateY??0,textShadow:w?.textShadow??T.textShadow??"",blur:w?.blur??T.blur??0,outlineWidth:w?.outlineWidth??T.outlineWidth??0,outlineColor:w?.outlineColor??T.outlineColor??"#000000",letterShake:w?.fear??0,fontVariationAxes:{...T.fontVariationAxes,...w?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:w?.joy??0,urlFear:w?.fear??0,urlJoyProgress:w?.joyWaveProgress??0};r&&(z.translateX=-z.translateX,z.rotation=z.rotation?-z.rotation:0,z.slant=-z.slant,z.skewX!==void 0&&(z.skewX=-z.skewX));let It=v==="joy"?ue(O.length):null,Ge=It&&(It==="letter"||It==="letter-bulge")?Math.min(1.5,Math.max(0,(t-E)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:j,emotion:v,emotionIntensity:L,originalEmotionIntensity:N,fontFamily:Kt,emphasis:S.emphasis||0,emphasisEffect:st,strongEmphasis:M,animationParameters:z,joyAnimationMode:It,joyProgress:Ge}}),dt=o??F,xt=C?Math.max(C.end,dt):null,Tt=C&&t>=C.start&&t<=(xt||C.end),Mt=t>=E&&t<dt,_t=C?!!Tt:Mt;return{text:St(n),words:W,currentWordIndex:vt,emotion:_,emotionIntensity:b,fontFamily:Ut(_,i),startTime:C?.start||E,endTime:C?.end||F,isActive:_t}}function Oe(n,t,e,i){let s=typeof e=="string"?e:"word",r=typeof e=="string"?i||{}:e||{};return s==="sentence"?In(n,t,r):kn(n,t,r)}var U=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],qt={joy:U[0],anger:U[11],sadness:U[5],fear:U[4],disgust:U[7],surprise:U[6],social_positive:U[1],social_negative:U[7],lust:U[11],calmness:U[1],screaming:U[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function We(n){return qt[n.toLowerCase()]||qt.none}function je(n,{ttlMs:t=300*1e3}={}){let e=new Map,i=new Map,s=new Map;function r(l){let d=s.get(l);return!d||Date.now()-d>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(i.has(l))return i.get(l);let d=(async()=>{try{let c=await n(l),C=new Map;if(Array.isArray(c))for(let f of c)f.emotion&&f.url&&f.is_active&&C.set(f.emotion.toLowerCase(),f.url);return e.set(l,C),s.set(l,Date.now()),C}catch(c){return console.warn("[publishedAnimationResolver] Failed to fetch active animations:",c?.message),e.get(l)||new Map}finally{i.delete(l)}})();return i.set(l,d),d}async function o(l,d="default"){return l&&(await a(d)).get(l.toLowerCase())||null}function m(l,d="default"){if(!l)return null;let c=e.get(d);return(!c||r(d))&&a(d),c?.get(l.toLowerCase())||null}function u(){e.clear(),i.clear(),s.clear()}return{prefetch:a,get:o,getSync:m,invalidate:u}}var Bn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Ne=["anger","fear","sadness","joy","disgust"];function Fn(n){let t=n.toLowerCase();return Ne.includes(t)?1.5:1}function Pn(n){return n.map(([t,e])=>{let i=Fn(t),s=e*i,r=Ne.includes(t.toLowerCase());return[t,e,s,i,r]})}function Ln(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([u,l])=>Bn.includes(u.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let s=Pn(e).sort(([,,u],[,,l])=>l-u),[r,a,,o,m]=s[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:s,importanceFactor:o,isCore:m}}function Rn(n){if(!n)return{startTime:0,endTime:0,duration:.01};let t=n.start_time||0,e=n.end_time||0;return{startTime:t,endTime:e,duration:Math.max(.01,e-t)}}function Dn(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function On(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),s=parseInt(n.slice(5,7),16);return`rgba(${e}, ${i}, ${s}, ${t})`}function Xe(n,t="",e="",i=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${On(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var Wn={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function jn(n){return x.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function $e(n=1,t="",e=1,i=""){let{min:s,max:r}=x.wordSpacing,a=parseFloat(s),o=parseFloat(r),u=jn(t).wordSpacingMultiplier;if(n<=1)return`${(a*u).toFixed(3)}em`;let l=Math.max(...Object.values(Wn)),d=Math.min(1,(n-1)/(l-1)),c=Math.pow(d,2),f=(a+(o-a)*c)*u;return i==="anger"||i==="screaming"?`${(f*.6).toFixed(3)}em`:`${f.toFixed(3)}em`}var Nn=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function Xn(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0;return Math.abs(t)%1e3/1e3}function Ue(n,t,e){if(!n)return 1;let i=(n.word||n.text||"").trim();if(!i)return 1;let s=i.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!s)return 1;if(Nn.has(s)||s.length<=2)return 0;let r=Math.min(1,s.length/7),a=Xn(s);return .5*r+.5*a<.55?0:1}function $n({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:i,currentTime:s,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:m=1,fontSize:u=16}){let l=new Array(m).fill(0);return l}function Un(n){return n.split("").map((t,e)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:e}))}function me(n,{minDeviation:t=.02,maxBlur:e=1.5,multiplier:i=1.5}={}){let s=Math.abs((n??1)-1);return s<=t?0:Math.min(e,s*i)}function Ye(n=0,t=1,e=1){let i=1-.5*Math.min(1,Math.max(0,e??0)),s=me(t)*i;return(n??0)+s}function zt(n,t,e,i,s){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return i+a*(s-i)}function Yn(n,t,e=null,i){if(!t)return i||400;let{min:s,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return i||a;let o,m;if(e?.mapping?.volume?(o=e.mapping.volume.min,m=e.mapping.volume.max):(o=s,m=r),i!==void 0){let u=(m-o)/4,l=zt(n,0,1,-u,u);return Math.round(Math.max(s,Math.min(r,i+l)))}return Math.round(zt(n,0,1,o,m))}function Vn(n,t,e){if(!t)return e||100;let{min:i,max:s,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(s-i)/4,o=zt(1-n,0,1,-a,a);return Math.round(Math.max(i,Math.min(s,e+o)))}return Math.round(zt(1-n,0,1,i,s))}var Ve={},qe={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function de(n){if(!n)return;let t=n.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||Ve[t]||(Ve[t]=!0,typeof document>"u"))return;let e=qe[t],i=document.createElement("link");i.rel="stylesheet",i.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(i)}function ze(){Object.keys(qe).forEach(n=>de(n))}var Gt=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,e={}){let i=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,s=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};s&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(i,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let u=await a.clone().json();if(u.message)o=u.message;else if(u.error)o=u.error;else if(Array.isArray(u.detail)){let l=u.detail.map(d=>{let c=Array.isArray(d.loc)?d.loc.filter(C=>C!=="body").join("."):"";return c?`${c}: ${d.msg||"invalid"}`:d.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof u.detail=="string"&&(o=u.detail)}catch{try{let u=await a.clone().text();u&&(o=u)}catch{}}let m=new Error(o);throw m.status=a.status,m.response=a,m}return a}async login(t,e){let s=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!s.session_id||!s.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=s.auth_token,this.sessionId=s.session_id,s}async register(t,e,i,s){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:i,company:s.company,first_name:s.first_name,last_name:s.last_name})})).json()}async getSubtitleTrack(t,e,i){let s=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&s.append("lang",e.trim()),i&&typeof i=="string"&&i.trim()&&s.append("model",i.trim());let r=s.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,e=10){return(await this.request(`/vods?skip=${t}&limit=${e}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};0&&(module.exports={ANIMATION_STYLING,ANIMATION_URLS,AUTHORED_PLAYBACK_OPTIONS,EMOTION_ANIMATION_URLS,PhontClient,REFERENCE_GTS,REFERENCE_INTENSITY,RENDERING_CONTROL,SubtitleManager,SubtitleStateManager,calculateAnimationParameters,calculateAnimationState,calculateDynamicWordSpacing,calculateEmphasisMultiplier,calculateGTSValues,calculateJoy,calculateJoyBulge,calculateNormalizedTime,calculateWeightFromVolume,calculateWidthFromSpeechRate,calculateWordEmphasisEffects,calculateWordLetterSpacing,capEmotionIntensity,computeProsodyWeight,createPublishedAnimationResolver,decodeAnimationUrl,ensureFont,findSubtitleForWord,generateTextShadow,getAnimationUrlForEmotion,getCombinedBlurAmount,getFontFamilyCSS,getJoyAnimationMode,getJoyFilter,getJoyTransform,getMergedSubtitles,getMotionBlurAmount,getSubtitleAnimations,getSubtitleText,getSubtitleTiming,getSubtitleWords,getWordEmphasis,hasMergedSubtitles,hockeyStickIntensity,isInEmphasisRange,isInStrongEmphasisRange,meetsEmotionThreshold,preloadAnimationFonts,processEmotionsWithImportance,resolveEffectiveGts,sampleParameterCurve,selectEmotion,selectFontFamily,shouldUseAngryFont,shouldUseJoyFont,shouldUseSadnessFont,splitTextIntoLetters,subtitleManager});
|
|
3
|
+
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let u=o.match(/#EXTINF:([0-9.]+)/);if(u){let d=parseFloat(u[1]);s.set(a,d),a++}}return s}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let i=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let s=await this.parseHLSMasterManifest(i),r=await this.parseAudioPlaylist(s);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let e=this._audioPlaylistCache.segmentDurations.get(t);return e!==void 0?e:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let e=await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(e)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let e;if(this.phontClient){if(!ut&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ut||this.phontClient.apiBaseUrl,s=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);e=await s.json()}else{if(!ut)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ut}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);e=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),e}catch{return null}}async fetchSubtitleData(t,e=null){if(this.stateManager.clearVodState(),!!t)try{let i,s;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");s=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let u=r.searchParams.get("lang")||e||void 0,d=r.searchParams.get("model")||void 0;try{i=await this.phontClient.getSubtitleTrack(s,u||null,d||null)}catch(l){let m=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),c=typeof l?.message=="string"?l.message:String(l||""),C=m===404||c.includes("404")||c.includes("Not Found"),f=m===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(C||f)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{s=t;let r=e&&e.trim()||void 0;try{i=await this.phontClient.getSubtitleTrack(s,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),u=typeof a?.message=="string"?a.message:String(a||""),d=o===404||u.includes("404")||u.includes("Not Found"),l=o===400||u.includes("400")||u.includes("Bad Request")||u.includes("HTTP error! status: 400");if(d||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${d?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);s=l?l[1]:t.split("/").pop().split("?")[0]}else{if(s=t,!ut&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ut||this.phontClient?.apiBaseUrl,m=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&m.append("lang",e.trim());let c=m.toString();r=c?`${l}/vod-subtitles/${s}?${c}`:`${l}/vod-subtitles/${s}`}let a={"Content-Type":"application/json"},o=Ft(),u=Pt();o&&(a.Authorization=`Bearer ${o}`),u&&(a["X-Session-ID"]=u);let d=await fetch(r,{headers:a,cache:"no-store"});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);i=await d.json()}return this.stateManager.updateVodVideoId(s),{data:i,videoId:s}}catch(i){throw this.stateManager.clearVodState(),i}}};var we={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Dt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[i,s]of Object.entries(we)){let r=i.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return s}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let i of t.important){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`important_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let i of t.all){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`all_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(i=>{if(i.animationFile==="Laughter"){let s=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-i.startTime)<=1);if(s){s.endTime=Math.max(s.endTime,i.endTime);return}}e.push(i)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,i=2,s=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&e<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:c})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let u of o){let d=this.mapEventLabelToAnimation(u.event_label);if(d){let l=u.start_time??u.onset??0,m=u.end_time??u.offset??0;if(e>=l&&e<=m){let C="all";this.stateManager.state.soundByteImportant?.includes(u)?C="important":this.stateManager.state.soundByteFiltered?.includes(u)&&(C="filtered"),s.push({id:`live_${u.event_label}_${l}`,eventLabel:u.event_label,animationFile:d,startTime:l,endTime:m,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};s.sort((o,u)=>{let d=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=u.eventLabel==="Laughter"?1:r[u.priority]||5;return d-l});let a=s.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=s=>Array.isArray(s)?s.length>0&&Array.isArray(s[0])?s.flat():s:[];return t?{all:e(this.stateManager.vodState.soundByteAll||[]),important:e(this.stateManager.vodState.soundByteImportant||[]),filtered:e(this.stateManager.vodState.soundByteFiltered||[])}:{all:e(this.stateManager.state.soundByteAll||[]),important:e(this.stateManager.state.soundByteImportant||[]),filtered:e(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,e=null){let i=[],s=[],r=e??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}return{all:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,e=30){let i=t-e,s=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=i),this.stateManager.state.soundbiteAnimations.length<s&&this.stateManager.notify()}};var Rt=class{constructor(t,e,i){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=i}processVodData(t,e,i,s){let r=e.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(e?e.split("/").pop()?.split("?")[0]:void 0),u=a.flat().map(f=>({...f,sequence_number:o}));s&&s.length>0&&(u=this._mergeAnimationDataFromOriginal(u,s));let d=this._deduplicateSubtitles(u),{soundByteAll:l,soundByteImportant:m,soundByteFiltered:c}=this._processSoundbites(t.soundbite);if(l.length>0||m.length>0||c.length>0){let f={all:l,important:m,filtered:c},h=this.soundbiteProcessor.processSoundbiteAnimations(f);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...h]}let C=t.language||i||null;this.stateManager.vodState={subtitles:d,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:m,soundByteFiltered:c,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,e){let i=new Map;for(let s of e){let r=`${s.start_time}-${s.end_time}`;(!i.has(r)||s.animations||s.emotion)&&i.set(r,s)}return t.map(s=>{let r=`${s.start_time}-${s.end_time}`,a=i.get(r);if(!a)return s;let o=s.animations&&typeof s.animations=="object"&&Object.keys(s.animations).length>0,u=s.emotion&&s.emotion!=="none"&&s.emotion!=="neutral",d=typeof s.animation_url=="string"&&s.animation_url.length>0;if(o&&d)return s;let l={...s};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!u&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!d&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let m=new Map;for(let c of a.words)m.set(`${c.start}-${c.end}`,c);l.words=l.words.map(c=>{let C=m.get(`${c.start}-${c.end}`);if(!C||c.animations&&typeof c.animations=="object"&&Object.keys(c.animations).length>0)return c;let h={...c};return C.animations&&Object.keys(C.animations).length>0&&(h.animations=C.animations),!h.emotion&&C.emotion&&(h.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(h.emotion_intensity=C.emotion_intensity)),!h.animation_url&&C.animation_url&&(h.animation_url=C.animation_url),h})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let i of t){let s=`${i.start_time}-${i.end_time}`;(!e.has(s)||i.emotion||i.animations)&&e.set(s,i)}return Array.from(e.values())}_processSoundbites(t){let e=[],i=[],s=[];return t&&(t.all&&Array.isArray(t.all)&&(e=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(i=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(s=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:i,soundByteFiltered:s}}};var Ot=class{constructor(t,e,i){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=i}async processLiveSegment(t,e,i){this.stateManager.state.processedSequences.add(e),this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let s=await i(e);this.stateManager.state.segmentDurations.set(e,s);let r=this.liveTimeGenerator.getCumulativeDuration(e),a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:u,processedSoundbitesFiltered:d}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,u,d);let l={all:o,important:u,filtered:d},m=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(m),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(c=>c.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,i){return!t||!Array.isArray(t)?[]:t.map(s=>({...s,sequence_number:e,start_time:s.start_time+i,end_time:s.end_time+i,words:s.words?s.words.map(r=>({...r,start:r.start+i,end:r.end+i})):void 0}))}_processSoundbites(t,e){let i=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),s=(t?.important||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e}));return{processedSoundbitesAll:i,processedSoundbitesImportant:s,processedSoundbitesFiltered:r}}_updateState(t,e,i,s){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...e],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...i],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...s]}};var Wt=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let e=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=e,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(e-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let e=t.src,i=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),i&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let i=this.stateManager.state.initialSequenceOffset;i<t;i++){let s=this.stateManager.state.segmentDurations.get(i)||10;e+=s}return e}};var jt=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,e){if(!t)return null;let s=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(e>=a.start)r.push(a.word);else break;s=r.join(" ")}return{activeSubtitle:t,displayText:s}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return null;let i=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!i&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let s=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(s){let r=this._processSubtitleText(s,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,u=e.currentSubtitle!==o||e.currentSubtitleData!==a;return u&&(e.currentSubtitle=o,e.currentSubtitleData=a,e.currentSequence=e.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=e.currentSequence??null),(i||u)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return e.currentSubtitle!==""&&(e.currentSubtitle="",e.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let e=t.subtitles.find(i=>t.currentTime>=i.start_time&&t.currentTime<=i.end_time);if(e){t.currentSequence=e.sequence_number??null;let i=this._processSubtitleText(e,t.currentTime);if(!i)return null;let{activeSubtitle:s,displayText:r}=i;return(t.currentSubtitle!==r||t.currentSubtitleData!==s)&&(t.currentSubtitle=r,t.currentSubtitleData=s,this.stateManager.notify()),this._lastSubtitleData=s,this._lastSubtitleTime=t.currentTime,s}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var Ae=new Set;function ie(){if(typeof window>"u")return!1;let n=window.location.search;if(n.includes("debug=subtitles")||n.includes("stage_debug=subtitles"))return!0;try{return localStorage.getItem("phont_debug_subtitles")==="1"}catch{return!1}}function ve(n){if(!n||typeof n!="object")return null;let t=n.subtitles;return Array.isArray(t)?t.flatMap(e=>Array.isArray(e)?e:[e]).length:null}function dn(){if(window.__phontSubtitleDebug)return window.__phontSubtitleDebug;let n={enabled:!0,last:null,dumpLast(){let t=n.last;if(!t)return console.warn("[vod-subtitles] No fetch recorded yet."),null;let e=ve(t.raw),i=e!=null?`${e} segments`:"see payload";return console.log(`%c[vod-subtitles] ${i}`,"font-weight:bold;font-size:12px",t.raw),t},async copyLast(){let t=n.last;if(!t)throw new Error("No subtitle fetch recorded yet.");let e=JSON.stringify(t.raw,null,2);try{await navigator.clipboard.writeText(e),console.info("[vod-subtitles] Copied JSON to clipboard.")}catch{console.log(e)}return e}};return window.__phontSubtitleDebug=n,n}function Nt(n,t){if(!ie()||typeof window>"u")return;let e=`${t?.vodId??""}|${t?.url??""}`;if(Ae.has(e))return;Ae.add(e);let i={at:new Date().toISOString(),vodId:t?.vodId??null,url:t?.url,raw:n},s=dn();s.last=i;let r=ve(n),a=r!=null?`${r} segments`:"see payload";console.log(`%c[vod-subtitles] Core GET /vod-subtitles \u2014 full response (${a})`,"font-weight:bold;font-size:12px",t?.vodId||t?.url?{vodId:t.vodId,url:t.url}:void 0,n)}var ms=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function xe(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var gt=class{constructor(){this.stateManager=new ft,this.cache=new Bt,this.fetcher=new Lt(this.stateManager),this.soundbiteProcessor=new Dt(this.stateManager),this.vodDataProcessor=new Rt(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new Wt(this.stateManager),this.liveDataProcessor=new Ot(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new jt(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,e="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?e:"none",this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}async fetchSubtitles(t){try{let e=await this.fetcher.fetchSubtitles(t);return e?await this.liveDataProcessor.processLiveSegment(e,t,i=>this.getAudioSegmentDuration(i)):null}catch{return null}}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,i,s){this.vodDataProcessor.processVodData(t,e,i,s)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,e=30){let i=t-e,s=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=i),this.state.subtitles.length<s&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,e=null){return this.soundbiteProcessor.getActiveSoundbites(t,e)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,e=30){this.soundbiteProcessor.clearOldAnimations(t,e)}getCurrentSpeaker(t=!1,e=null){if(!this.state.isSpeaker)return null;let i=null;if(t?i=this.vodState.currentSubtitleData:i=this.state.currentSubtitleData,!i||!i.words)return null;let s=i?.speaker;return s||null}async fetchSubtitleData(t,e=null,i=null){if(!e&&t){let s=new URLSearchParams(t.split("?")[1]||"");e=s.get("lang")||null,i||(i=s.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let s=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=s,o=r?.language||e||null;Nt(r,{vodId:a,url:t});let u=xe(o??e),d=i?`${u}_${i}`:u,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(d,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let c;if(!!e&&String(e).trim()!==""){let f=this.cache._subtitleCache.get("original");f?.data?.subtitles&&(c=Array.isArray(f.data.subtitles)?f.data.subtitles.flat():[])}this._processVodData(r,t,o,c)}catch(s){let r=s?.status||s?.response?.status,a=r===404||typeof s?.message=="string"&&s.message.includes("404")||typeof s?.message=="string"&&s.message.includes("Not Found"),o=r===400||typeof s?.message=="string"&&s.message.includes("400")||typeof s?.message=="string"&&s.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:s?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",s),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,e,i=null){if(!e)return;let s=xe(t);if(this.cache._loadingLanguages.has(s))return;let r=i?`${s}_${i}`:s,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(s);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let u=new URLSearchParams;t&&u.append("lang",t),i&&u.append("model",i);let d=u.toString(),l=`${o}/vod-subtitles/${e}${d?`?${d}`:""}`,m=!1;try{await this.fetchSubtitleData(l,t,i),m=!0}catch(c){if(c?.status===404||typeof c?.message=="string"&&c.message.includes("404"))if(t!==null)m=!0;else throw c;else throw c}if(!m)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,i)}finally{this.cache._loadingLanguages.delete(s)}}_loadCachedSubtitles(t,e,i){let s=t?.language||i||null,r;if(!!i&&String(i).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,e,s,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},Te=new gt;function mn(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[i,s]=e.split(","),r=t||typeof s=="string"&&(s.startsWith("#")||s.startsWith("%23")),a;return r?a=s.replace(/%23/g,"#"):a=parseFloat(s),{time:parseFloat(i),value:a}})}catch(e){return console.error("Error decoding points:",e),[]}}function Cn(n){if(!n)return"";if(n.includes("://"))try{let t=new URL(n);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=n.indexOf("?");return t!==-1?n.substring(t+1):n}return n.startsWith("?")?n.slice(1):n}function Xt(n){try{let t=Cn(n),e=new URLSearchParams(t),i={parameterStates:{}};if(e.has("name")&&(i.name=e.get("name")||void 0),e.has("user")&&(i.userName=e.get("user")||void 0),e.has("duration")&&(i.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(i.animationMode=e.get("mode")||void 0),e.has("text")&&(i.text=e.get("text")||void 0),e.get("format")==="normalized"&&(i.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?i.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:i.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{i.backgroundStyle=JSON.parse(e.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of e.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),u=mn(a,o);if(u.length>0){let d=o?"#000000":0;i.parameterStates[r]={points:u,currentValue:u[0]?.value||d}}}return i}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function _e(n){if(n===0)return 0;let t=4,e;if(n<=.7){let i=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*i}else{let i=(n-.7)/.3,s=Math.log(1+.5*(Math.exp(t)-1))/t;e=s+i*(1-s)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function $t(n){if(typeof n!="string")return{r:0,g:0,b:0};let t=n.replace("#","").padStart(6,"0"),e=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function Ee(n,t,e){let i=s=>{let r=Math.round(Math.max(0,Math.min(255,s))).toString(16);return r.length===1?"0"+r:r};return"#"+i(n)+i(t)+i(e)}function Me(n,t,e){let i=$t(n),s=$t(t),r=Math.max(0,Math.min(1,e)),a=i.r+(s.r-i.r)*r,o=i.g+(s.g-i.g)*r,u=i.b+(s.b-i.b)*r;return Ee(a,o,u)}function hn(n,t,e){if(e===0)return n;let i=$t(n),s=$t(t),r=i.r+(s.r-i.r)*e,a=i.g+(s.g-i.g)*e,o=i.b+(s.b-i.b)*e;return Ee(r,a,o)}function ct(n,t,e,i=!1,s=null){if(!n||n.length===0)return null;let r=i?t:t*e,a=null,o=null;for(let u=0;u<n.length;u++){let d=n[u],l=d.time!==void 0?d.time:Array.isArray(d)?d[0]:0;if(l!==void 0&&l<=r&&(a=d),l!==void 0&&l>=r&&!o){o=d;break}}if(!a&&n[0])return(n[0].value!==void 0?n[0].value:Array.isArray(n[0])?n[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let u=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,d=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,m=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(u===d||l===null||m===null)return l??null;let c=(r-u)/(d-u),C=s==="color"||s==="shadowColor"||s==="outlineColor"||s==="outline2Color"||s==="outline3Color"||s==="outlineShadowColor"||s==="glowColor";if(C&&(typeof l=="string"||typeof m=="string"))return Me(typeof l=="string"?l:"#000000",typeof m=="string"?m:"#000000",c);if(!C&&(typeof l=="string"||typeof m=="string")){let f=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),h=typeof m=="string"&&(m.startsWith("#")||/^[0-9a-f]{6}$/i.test(m));if(f&&h){let g=l.startsWith("#")?l:`#${l}`,_=m.startsWith("#")?m:`#${m}`;return Me(g,_,c)}return m??null}return l+(m-l)*c}return null}var ae=.7,pt=.7,Ie={rawMode:!0};function dt(n,t,e,i,s=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*i/(ae*pt),o=n.duration||2,d=n.format==="normalized"?e:e*o,l=!0,m=n.parameterStates||{},c=(A,B,$=!0,q=null)=>{let ht=q??a,at=ct(m[A]?.points,d,o,l);return at==null?B:$?ht===0?B:B+(at-B)*ht:at},C=c("scale",1),f=c("skew",0),h=c("stretch",1),g=c("translateX",0),_=c("translateY",0),b=c("weight",500),E=c("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",R=n.text||"Hello",D=(A,B)=>{let $=ct(m[A]?.points,d,o,l,A);if($==null)return B;let q=typeof $=="string"?$.startsWith("#")?$:`#${$}`:`#${Math.round($).toString(16).padStart(6,"0")}`;return a===0?B:hn(B,q,a)},k=D("color","#ffffff"),P=c("opacity",1),I=c("shadowX",0),T=c("shadowY",0),H=c("shadowBlur",4),et=c("shadowOpacity",.5),O=D("shadowColor","#000000"),vt=c("outlineWidth",0),Zt=D("outlineColor","#000000"),W=A=>m[A]?.points?.length>0,mt=W("stretchX")?c("stretchX",1):void 0,xt=W("outline2Width")?c("outline2Width",0):void 0,Tt=W("outline2Color")?D("outline2Color","#000000"):void 0,Mt=W("outline3Width")?c("outline3Width",0):void 0,_t=W("outline3Color")?D("outline3Color","#000000"):void 0,S=W("outlineShadowWidth")?c("outlineShadowWidth",0):void 0,X=W("outlineShadowColor")?D("outlineShadowColor","#000000"):void 0,j=W("outlineShadowBlur")?c("outlineShadowBlur",0):void 0,v=W("glowIntensity")?c("glowIntensity",0):void 0,L=W("glowColor")?D("glowColor","#ffffff"):void 0,N=W("snakeWave")?c("snakeWave",0):void 0,nt=W("karaoke")?c("karaoke",0):void 0,Y=1-.5*Math.min(1,Math.max(0,i)),V=c("blur",0,!0,r?1:a*Y),Ct=ct(m.thinStroke?.points,d,o,l),K=ct(m.ascenderHeight?.points,d,o,l),it={};Ct!=null&&typeof Ct=="number"&&(it.YOPQ=Ct),K!=null&&typeof K=="number"&&(it.YTAS=K),b!=null&&(it.wght=b),E!=null&&(it.wdth=E);let J=[];if(I!==0||T!==0||H!==4||et!==.5){let A=typeof O=="string"?O:"#000000",B=parseInt(A.slice(1,3),16),$=parseInt(A.slice(3,5),16),q=parseInt(A.slice(5,7),16);J.push(`${I}px ${T}px ${H}px rgba(${B}, ${$}, ${q}, ${et})`)}else if(O&&typeof O=="string"&&O!=="#000000"){let A=O.startsWith("#")?O:`#${O}`,B=parseInt(A.slice(1,3),16)||0,$=parseInt(A.slice(3,5),16)||0,q=parseInt(A.slice(5,7),16)||0;J.push(`3px 2px 4px rgba(${B}, ${$}, ${q}, 0.5)`)}if(v!=null&&v>0){let A=typeof L=="string"?L:"#ffffff";J.push(`0 0 ${v}px ${A}`),J.push(`0 0 ${v*2}px ${A}`),J.push(`0 0 ${v*4}px ${A}`)}let Qt=J.length>0?J.join(", "):"",lt=0;if(m.joy?.points&&m.joy.points.length>0)for(let A of m.joy.points){let B=Array.isArray(A)?A[1]:A.y??A.value??0;typeof B=="number"&&B>lt&&(lt=B)}let Et=c("joy",0,!1),te=r?Et:Math.min(1,lt*a),Z=c("fear",0),Q=c("standardEmphasis",0,!1),st=c("strongEmphasis",0,!1),M={rawIntensity:t,scaleFactor:a,scale:C,slant:f,stretchY:h,translateX:g,translateY:_,weight:b,width:E,fontFamily:y,textColor:k,opacity:P,textShadow:Qt,blur:V,outlineWidth:vt,outlineColor:Zt,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:it,text:R,joy:te,fear:Z,standardEmphasis:Q,strongEmphasis:st,joyWaveProgress:d/o*1.5};return mt!==void 0&&(M.stretchX=mt),xt!==void 0&&(M.outline2Width=xt),Tt!==void 0&&(M.outline2Color=Tt),Mt!==void 0&&(M.outline3Width=Mt),_t!==void 0&&(M.outline3Color=_t),S!==void 0&&(M.outlineShadowWidth=S),X!==void 0&&(M.outlineShadowColor=X),j!==void 0&&(M.outlineShadowBlur=j),v!==void 0&&(M.glowIntensity=v),L!==void 0&&(M.glowColor=L),N!==void 0&&(M.snakeWave=N),nt!==void 0&&(M.karaoke=nt),M}var x={fontSize:54,opacity:1,weight:400,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:4,color:"rgba(0, 0, 0, 0.4)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:1.25,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function bt(n,t,e){let i=Math.max(0,Math.min(1,n)),s=e??t;if(typeof s=="number"&&Number.isFinite(s)){let r=Math.max(0,Math.min(1,s));return Math.min(1,Math.max(0,r*(i/pt)))}return i}function Ut(n){let t=.2+.8*n,e=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*n;return{gts:n,maxExpression:t,threshold:e,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function fn(n,t){return n>=t}function re(n,t){return t<=.2?0:n*t}function oe(n){let{minThreshold:t,maxThreshold:e}=p.emphasis;return n<t||n>=e?0:(n-t)/(e-t)}function le(n){return n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold}function ue(n){return n>=p.strongEmphasis.minThreshold}function gn(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,u=n*n,d=u*n;return o*0+3*a*n*.42+3*r*u*.58+d*1}var ke=new WeakMap,ce={joy:1,social_positive:1,anger:-1,screaming:-1};function de(n,t,e,i){let s=typeof e=="string"?e.toLowerCase():"";if(s==="joy")return pn(n,t,i);let r=Math.sign(t);return r!==0?r:s in ce?ce[s]:i}function pn(n,t,e){let i=Math.sign(t);if(n){let s=ke.get(n);if(s!==void 0)return s;let r=i!==0?i:Be(e);return ke.set(n,r),r}return i!==0?i:Be(e)}function Be(n){return n!==0?n:ce.joy}function bn(n,t,e=1,i=0,s=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:u,scaleDownFrames:d,fps:l}=p.emphasis;if(!n||!le(a))return null;let m=t-n.start,c=s?n.start+s:n.end,C=c-n.start;if(m<0||t>=c)return null;let f=Math.max(0,Math.min(1,m/C)),h=0;f<.5?h=f*2:h=2-f*2,h=h*h*(3-2*h);let g=oe(a),_=.55,b=3*_,F=de(n,i,r,0)*b*h*e*g,y=140*h*e*g,R=1+o*_*h*e*g,D=f<1;return{scaleMultiplier:R,slantAdditive:F,weightBoost:y,scaleProgress:h,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:m,scaleActive:D}}function yn(n,t,e={},i=1,s=null,r=0,a=""){let o=a==="anger"||a==="screaming",u=p.strongEmphasis,d=.7,l=s?n.start+s:n.end;if(t<n.start)return null;let m=n.emphasis||0;if(!ue(m))return null;let c=u.fadeOutTailDuration,C=l+c;if(t>=C)return null;let f=l-n.start,h=Math.max(0,Math.min(1,(t-n.start)/f)),g=1,_=t>=l;if(_){let T=(t-l)/c;g=1-gn(T),h=1}let b=0;h<.5?b=h*2:b=2-h*2;let E=b*b*(3-2*b),F=(m-u.minThreshold)/(1-u.minThreshold),y=E*F*i,R=y;y<.1&&(y=0);let D=de(n,r,a,-1),k,P;if(o)k={scale:1+y*(u.maxScale-1)*d,rotation:y*u.maxRotation*d,translateY:-y*u.maxTranslateY*d,translateX:y*u.maxTranslateX*d,skewX:D*y*u.maxSkew*d,stretchY:1},P={brightness:1+y*u.maxBrightness*d,contrast:1+y*u.maxContrast*d,shadowBlur:y*u.maxShadowBlur*d,shadowOpacity:y*u.shadowOpacity*d,zIndex:Math.round(y*u.maxZIndex*d)};else{let et=E*20*Math.max(.2,F*i)*d,O=de(n,r,a,1);k={scale:1+y*.15*d,rotation:0,translateY:0,translateX:0,skewX:O*et,stretchY:1},P={brightness:1+y*.2*d,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(k.scale=1+(k.scale-1)*g,k.rotation=k.rotation*g,k.translateX=k.translateX*g,k.translateY=k.translateY*g,k.skewX=k.skewX*g,P.brightness=1+(P.brightness-1)*g,P.contrast=1+(P.contrast-1)*g,P.shadowBlur=P.shadowBlur*g,P.shadowOpacity=P.shadowOpacity*g,P.zIndex=Math.round(P.zIndex*g),y=y*g);let I=280*y*i;return{emphasis:y,rawEmphasis:R,...k,...P,weightBoost:I,shadowOffsetX:y*u.shadowOffsetX,shadowOffsetY:y*u.shadowOffsetY,gtsMultiplier:i,emphasisMultiplier:F,fadeFactor:g,isInTail:_}}function me({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:i,wordBaseSlant:s,isActive:r,wordEmotion:a=""}){let o=r?bn(n,t,e,s,i,a):null,u=yn(n,t,{},e,i,s,a);return{emphasisEffect:o,strongEmphasisData:u}}function Fe(n){let t=2*Math.PI/3;return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*t)+1}function Pe(n){return 1-(1-n)*(1-n)}function Ce(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function Sn(n,t,e,i=1){let s=p.joy.letterWave,r=e<=6,a,o,u;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),u=a+o):(a=s.innerWidthRatio,o=s.outerWidthRatio,u=a+o);let d=t/Math.max(1,e-1),l=n;r&&e<=3?l=Math.min(1.2,n*1.25):r&&(l=Math.min(1.1,n*1.1));let m=l*(1+u),c=d-m,C=a+o,f=o*.3;if(c>f||c<-C)return null;let h=0;if(c>0&&c<=f)h=(1-c/f)*.15;else if(c<=0&&c>=-a){let y=Math.abs(c)/Math.max(a,.01);h=Fe(y)}else if(c<-a){let R=(Math.abs(c)-a)/Math.max(o,.01);h=Pe(1-R)}if(h<=.01)return null;let g=h*i,b=1-t%2*.15,E={scale:1+g*(s.maxScale-1)*b,rotation:g*s.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*s.maxTranslateY*b,skewX:-g*s.maxSkew*.5,stretchY:1},F={brightness:1+g*s.maxBrightness,contrast:1+g*s.maxContrast,shadowBlur:g*s.maxShadowBlur,shadowOpacity:g*s.shadowOpacity,zIndex:Math.round(g*s.maxZIndex)};return{pressure:g,...E,...F,shadowOffsetX:g*3,shadowOffsetY:g*3}}function wn(n,t,e,i=1){let s=p.joy.letterBulge,r=s.innerWidthRatio,a=s.outerWidthRatio,o=r+a,u=e>1?t/Math.max(1,e-1):0,d=n*(1+o),l=u-d,m=a*.35,c=o;if(l>m||l<-c)return null;let C=0;if(l>0&&l<=m)C=(1-l/Math.max(m,1e-4))*.18;else if(l<=0&&l>=-r){let R=Math.abs(l)/Math.max(r,1e-4);C=Fe(R)}else if(l<-r){let D=(Math.abs(l)-r)/Math.max(a,1e-4);C=Pe(1-D)}if(C<=.01)return null;let f=C*i,h=Math.min(1,f*.85),g=1,_=t%3===0?1:-1,b=Math.max(1-s.maxCompressionX,1-h*s.maxCompressionX),E=1+h*s.maxStretchY,F={scale:1+h*(s.maxScale-1),stretchY:E,stretchX:b,rotation:h*s.maxRotation*g,translateX:h*s.maxTranslateX*_,translateY:-h*s.maxTranslateY,skewX:h*s.maxSkew*g},y={brightness:1+h*s.maxBrightness,contrast:1+h*s.maxContrast,shadowBlur:h*s.maxShadowBlur,shadowOpacity:h*s.shadowOpacity,zIndex:Math.round(h*s.maxZIndex)};return{pressure:h,bulgeIntensity:h,...F,...y,shadowOffsetX:h*1.8,shadowOffsetY:h*3}}function An(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,i=n.rotation||0,s=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${i}deg) skewX(${a}deg) translate(${s}px, ${r}px)`}function vn(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,i=n.shadowBlur||0,s=n.shadowOpacity||0,r=n.shadowOffsetX||0,a=n.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),e!==1&&o.push(`contrast(${e})`),i>0&&s>0&&o.push(`drop-shadow(${r}px ${a}px ${i}px rgba(255, 255, 255, ${s}))`),o.join(" ")}var xn=["anger","fear","sadness","joy"];function Tn(n){return xn.includes(n.toLowerCase())}function yt(n){return n.map(([t,e])=>{let i=Tn(t),s=i?1.5:1,r=e*s;return[t,e,r,s,i]})}function Le(n){if(!n)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=n.confidence_word||0,e=n.emphasis||0;return{confidence:t,emphasis:e,hasEmphasis:e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold,hasStrongEmphasis:e>=p.strongEmphasis.minThreshold}}function St(n){return n&&(n.subtitle||n.text)||""}function Yt(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function wt(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function tt(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function At(n){return tt(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function Vt(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function De(n,t,e=null,i=null){if((i?.name==="children"||i?.name==="hello-kitty")&&e&&i.fonts?.[e])return i.fonts[e];let s=p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold;return s?x.angryFont:r?x.joyFont:a?x.sadnessFont:x.defaultFont}function qt(n,t,e=null,i=null){let s=De(n,t,e,i),r="sans-serif";return s==="Cormorant"&&(r="serif"),`"${s}", ${r}`}function Mn(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function _n(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function En(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var We='"Roboto Flex", "Roboto", sans-serif',Re=new Map,In={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function zt(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?In[t]||t:""}function he(n){if(typeof n!="string"||n.length===0)return null;let t=Re.get(n);if(t)return t;try{let e=Xt(n);return Re.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function kn(n){if(!n||n.length===0)return null;let t=n.filter(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(e=>e.start_time)),end:Math.max(...t.map(e=>e.end_time))}}function Bn(n,t){return n.find(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number"&&t>=e.start_time&&t<=e.end_time)||null}function Gt(n){return n&&typeof n.animation_url=="string"&&n.animation_url.length>0?n.animation_url:null}function je(n,t){if(!n)return{emotion:"none",intensity:0};let e=wt(n),i=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(i.length>0){let a=yt(i).sort((o,u)=>u[2]-o[2])[0];return{emotion:zt(a[0])||"none",intensity:a[1]}}let s=zt(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!s||s==="none"||r<=0?Gt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:s,intensity:r}}function Fn(n){let t={...n};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function Oe(n,t,e,i){let{minWordDisplayTime:s,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,u=Math.max(0,n.end-n.start),d=Math.max(u,s);if(!i)return n.start+d;let l=typeof t.end_time=="number"?t.end_time:n.end,m=l-n.end,c=!1;if(e!=null&&e>l?(m=e-n.end,c=m>=o):e==null?(c=!0,m=1/0):c=m>=a,c){let f=m===1/0?s+r:n.end+m-n.start-.1,g=u<s?f:Math.min(s+r,f);d=Math.max(d,g)}return n.start+d}function Pn(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let i=n.findIndex(a=>t>=a.start&&t<a.animationEnd),s=n.reduce((a,o,u)=>t>=o.animationEnd?u:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||s!==-1&&o<=s?1:e?0:.3),currentWordIndex:i}}function Ne(n){if(!n)return x.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),i=e.toLowerCase();return i.includes("bricolage")?"Bricolage Grotesque":i.includes("rakkas")?x.angryFont:i.includes("parkinsans")?x.joyFont:i.includes("cormorant")?x.sadnessFont:i.includes("roboto")?x.defaultFont:e}function Ln(n,t,e){let i={text:"",fontSize:x.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:We,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return i;let s=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=s<=.2,u=Ut((s-.2)/.8).gts,d=n.start_time,l=n.end_time,m=Math.max(.01,l-d),c=Math.max(0,Math.min(1,(t-d)/m)),C=je(n,r),f=o?"none":C.emotion,h=o?0:Math.max(0,C.intensity),g=he(Gt(n)),_=bt(u,n.gts,void 0),b=g?dt(g,h,c,_,m):null,E=b?.fontFamily?`"${Ne(b.fontFamily)}", sans-serif`:qt(f,s),F={fontSize:x.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??x.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?Fn(F):F,text:St(n),emotion:f,emotionIntensity:h,fontFamily:E,startTime:d,endTime:l,duration:m,isActive:t>=d&&t<l}}function Dn(n,t,e){let i=e.maxExpression??1,s=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,u=e.transparentUntilSpoken??!1,d=i<=.2,l=Ut((i-.2)/.8).gts,m={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:We,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return m;let c=tt(n)?At(n):[n],C=kn(c),f=Bn(c,t);if(!f&&o!=null&&t>n.end_time&&t<=o&&(f=c[c.length-1]||null),!f&&C&&t>=C.start&&t<=C.end&&(f=[...c].filter(S=>S&&t>=S.start_time).sort((S,X)=>X.start_time-S.start_time)[0]||null),f==null)return m;let h=f,g=je(h,s),_=d?"none":g.emotion,b=d?0:Math.max(0,g.intensity),E=h.start_time,F=h.end_time,y=Math.max(.01,F-E),R=Math.max(0,Math.min(1,(t-E)/y)),D=tt(n)?null:he(Gt(h)),k=h.gts??n.gts,P=bt(l,k,void 0),I=D?dt(D,b,R,P,y):null,T={fontSize:x.fontSize,scale:I?.scale??(_==="none"?1:1+b*.16),opacity:I?.opacity??1,slant:I?.slant??0,weight:I?.weight??400,width:I?.width??100,textColor:I?.textColor??x.textColor,translateX:I?.translateX??0,translateY:I?.translateY??0,stretchY:I?.stretchY??1,textShadow:I?.textShadow??"",blur:I?.blur??0,outlineWidth:I?.outlineWidth??0,outlineColor:I?.outlineColor??"#000000",fontVariationAxes:I?.fontVariationAxes??{}},H=Yt(n).flatMap(S=>{let X=String(S?.word??""),j=X.trim();if(!j.includes(" "))return[S];let v=j.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,v.length),nt=X.startsWith(" ");return v.map((Y,V)=>({...S,word:(V===0&&nt?" ":"")+Y,start:(S.start??0)+V*N,end:(S.start??0)+(V+1)*N}))}),et=null;if(tt(n)&&C?.end){let S=H[H.length-1],X=Oe(S,n,a,!0),j=o??X,{minWordDisplayTime:v,breathingRoomDuration:L}=p.timing,N=v+L,Y=(H.length>0?Math.min(...H.map(V=>V.start)):C.start)+N;et=Math.max(C.end,j,Y)}let O=H.map((S,X)=>{let j=X===H.length-1,v=Oe(S,n,a,j);return{...S,animationEnd:tt(n)&&et?Math.max(v,et):v}}),{currentWordIndex:vt,opacities:Zt}=Pn(O,t,u),W=O.map((S,X)=>{let j=t>=S.start&&t<S.end,v=_,L=b,N=b,nt=tt(n)?At(n):null,Y=nt?Vt(nt,S):h;if(Y){let rt=wt(Y),kt=Object.entries(rt).filter(([,G])=>typeof G=="number"&&G>s),ee=Object.entries(rt).filter(([,G])=>typeof G=="number");if(ee.length>0)N=[...ee].sort((ot,ne)=>ne[1]-ot[1])[0][1];else{let G=zt(Y.emotion),ot=typeof Y.emotion_intensity=="number"?Y.emotion_intensity:0;G&&ot>0&&(v=G,N=ot,L=ot)}if(kt.length>0){let G=yt(kt).sort((ot,ne)=>ne[2]-ot[2]);v=zt(G[0][0])||"none",L=G[0][1]}else ee.length>0&&(v="none",L=0)}d?(v="none",L=0):L===N&&L!==0&&(L=re(L,i));let V=Math.max(.01,(S.end??0)-(S.start??0)),Ct=Math.max(0,Math.min(1,(t-S.start)/V)),K=he(Gt(Y)),it=N>0?N:K?Math.max(1,b||0):0,J=bt(l,k,S.gts),w=K?dt(K,it,Ct,J,V):null,Qt=Ne(K?.fontData?.style?.fontFamily),lt=(K?.parameterStates?.standardEmphasis?.points?.length??0)>0,Et=(K?.parameterStates?.strongEmphasis?.points?.length??0)>0,te=lt||Et,Z=j?w?.standardEmphasis??0:0,Q=j?w?.strongEmphasis??0:0,st=null,M=null;if(te){let rt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:0;if(lt&&(st={scaleMultiplier:1+.272*Z*i,slantAdditive:rt*4.25*Z*i,weightBoost:250*Z*i,scaleProgress:Z,gtsMultiplier:i,emphasis:Z,emphasisMultiplier:Z,elapsed:0,scaleActive:Z>0}),Et&&!r){let kt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:1;M={emphasis:Q,rawEmphasis:Q,scale:1+Q*.38,skewX:kt*Q*30*i,weightBoost:400*Q*i,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+Q*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:i,emphasisMultiplier:Q,fadeFactor:1,isInTail:!1}}}else{let rt=me({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:i,emotionAnimationDuration:V,wordBaseSlant:w?.slant||0,isActive:j,wordEmotion:v});st=rt.emphasisEffect,M=r?null:rt.strongEmphasisData}let A=Zt[X]??1,B=(w?.opacity??T.opacity??1)*A,q=(w?.scale??T.scale??1)*(st?.scaleMultiplier||1),ht=(w?.slant??T.slant??0)+(st?.slantAdditive||0),at=q,pe=st?.weightBoost||0;M&&(ht+=M.skewX||0,pe+=M.weightBoost||0,at=q*(M.scale||1));let z={...T,fontSize:x.fontSize,scale:at,slant:ht,stretchY:w?.stretchY??T.stretchY??1,weight:(w?.weight??T.weight??400)+pe,width:w?.width??T.width??100,textColor:w?.textColor??T.textColor??x.textColor,opacity:B,translateX:w?.translateX??T.translateX??0,translateY:w?.translateY??T.translateY??0,textShadow:w?.textShadow??T.textShadow??"",blur:w?.blur??T.blur??0,outlineWidth:w?.outlineWidth??T.outlineWidth??0,outlineColor:w?.outlineColor??T.outlineColor??"#000000",letterShake:w?.fear??0,fontVariationAxes:{...T.fontVariationAxes,...w?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:w?.joy??0,urlFear:w?.fear??0,urlJoyProgress:w?.joyWaveProgress??0};r&&(z.translateX=-z.translateX,z.rotation=z.rotation?-z.rotation:0,z.slant=-z.slant,z.skewX!==void 0&&(z.skewX=-z.skewX));let It=v==="joy"?Ce(O.length):null,Ze=It&&(It==="letter"||It==="letter-bulge")?Math.min(1.5,Math.max(0,(t-E)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:j,emotion:v,emotionIntensity:L,originalEmotionIntensity:N,fontFamily:Qt,emphasis:S.emphasis||0,emphasisEffect:st,strongEmphasis:M,animationParameters:z,joyAnimationMode:It,joyProgress:Ze}}),mt=o??F,xt=C?Math.max(C.end,mt):null,Tt=C&&t>=C.start&&t<=(xt||C.end),Mt=t>=E&&t<mt,_t=C?!!Tt:Mt;return{text:St(n),words:W,currentWordIndex:vt,emotion:_,emotionIntensity:b,fontFamily:qt(_,i),startTime:C?.start||E,endTime:C?.end||F,isActive:_t}}function Xe(n,t,e,i){let s=typeof e=="string"?e:"word",r=typeof e=="string"?i||{}:e||{};return s==="sentence"?Ln(n,t,r):Dn(n,t,r)}var U=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],Ht={joy:U[0],anger:U[11],sadness:U[5],fear:U[4],disgust:U[7],surprise:U[6],social_positive:U[1],social_negative:U[7],lust:U[11],calmness:U[1],screaming:U[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function $e(n){return Ht[n.toLowerCase()]||Ht.none}function Ue(n,{ttlMs:t=300*1e3}={}){let e=new Map,i=new Map,s=new Map;function r(l){let m=s.get(l);return!m||Date.now()-m>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(i.has(l))return i.get(l);let m=(async()=>{try{let c=await n(l),C=new Map;if(Array.isArray(c))for(let f of c)f.emotion&&f.url&&f.is_active&&C.set(f.emotion.toLowerCase(),f.url);return e.set(l,C),s.set(l,Date.now()),C}catch(c){console.warn("[publishedAnimationResolver] Failed to fetch active animations:",c?.message);let C=e.get(l)||new Map;return e.set(l,C),s.set(l,Date.now()),C}finally{i.delete(l)}})();return i.set(l,m),m}async function o(l,m="default"){return l&&(await a(m)).get(l.toLowerCase())||null}function u(l,m="default"){if(!l)return null;let c=e.get(m);return(!e.has(m)||r(m))&&(i.has(m)||a(m)),c?.get(l.toLowerCase())||null}function d(){e.clear(),i.clear(),s.clear()}return{prefetch:a,get:o,getSync:u,invalidate:d}}var Rn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Ye=["anger","fear","sadness","joy","disgust"];function On(n){let t=n.toLowerCase();return Ye.includes(t)?1.5:1}function Wn(n){return n.map(([t,e])=>{let i=On(t),s=e*i,r=Ye.includes(t.toLowerCase());return[t,e,s,i,r]})}function jn(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([d,l])=>Rn.includes(d.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let s=Wn(e).sort(([,,d],[,,l])=>l-d),[r,a,,o,u]=s[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:s,importanceFactor:o,isCore:u}}function Nn(n){if(!n)return{startTime:0,endTime:0,duration:.01};let t=n.start_time||0,e=n.end_time||0;return{startTime:t,endTime:e,duration:Math.max(.01,e-t)}}function Xn(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function $n(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),s=parseInt(n.slice(5,7),16);return`rgba(${e}, ${i}, ${s}, ${t})`}function Ve(n,t="",e="",i=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${$n(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var Un={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function Yn(n){return x.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function qe(n=1,t="",e=1,i=""){let{min:s,max:r}=x.wordSpacing,a=parseFloat(s),o=parseFloat(r),d=Yn(t).wordSpacingMultiplier;if(n<=1)return`${(a*d).toFixed(3)}em`;let l=Math.max(...Object.values(Un)),m=Math.min(1,(n-1)/(l-1)),c=Math.pow(m,2),f=(a+(o-a)*c)*d;return i==="anger"||i==="screaming"?`${(f*.6).toFixed(3)}em`:`${f.toFixed(3)}em`}var Vn=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function qn(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0;return Math.abs(t)%1e3/1e3}function ze(n,t,e){if(!n)return 1;let i=(n.word||n.text||"").trim();if(!i)return 1;let s=i.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!s)return 1;if(Vn.has(s)||s.length<=2)return 0;let r=Math.min(1,s.length/7),a=qn(s);return .5*r+.5*a<.55?0:1}function zn({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:i,currentTime:s,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:u=1,fontSize:d=16}){let l=new Array(u).fill(0);return l}function Gn(n){return n.split("").map((t,e)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:e}))}function fe(n,{minDeviation:t=.02,maxBlur:e=1.5,multiplier:i=1.5}={}){let s=Math.abs((n??1)-1);return s<=t?0:Math.min(e,s*i)}function Ge(n=0,t=1,e=1){let i=1-.5*Math.min(1,Math.max(0,e??0)),s=fe(t)*i;return(n??0)+s}function Kt(n,t,e,i,s){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return i+a*(s-i)}function Hn(n,t,e=null,i){if(!t)return i||400;let{min:s,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return i||a;let o,u;if(e?.mapping?.volume?(o=e.mapping.volume.min,u=e.mapping.volume.max):(o=s,u=r),i!==void 0){let d=(u-o)/4,l=Kt(n,0,1,-d,d);return Math.round(Math.max(s,Math.min(r,i+l)))}return Math.round(Kt(n,0,1,o,u))}function Kn(n,t,e){if(!t)return e||100;let{min:i,max:s,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(s-i)/4,o=Kt(1-n,0,1,-a,a);return Math.round(Math.max(i,Math.min(s,e+o)))}return Math.round(Kt(1-n,0,1,i,s))}var He={},Ke={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function ge(n){if(!n)return;let t=n.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||He[t]||(He[t]=!0,typeof document>"u"))return;let e=Ke[t],i=document.createElement("link");i.rel="stylesheet",i.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(i)}function Je(){Object.keys(Ke).forEach(n=>ge(n))}var Jt=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,e={}){let i=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,s=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};s&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(i,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let d=await a.clone().json();if(d.message)o=d.message;else if(d.error)o=d.error;else if(Array.isArray(d.detail)){let l=d.detail.map(m=>{let c=Array.isArray(m.loc)?m.loc.filter(C=>C!=="body").join("."):"";return c?`${c}: ${m.msg||"invalid"}`:m.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof d.detail=="string"&&(o=d.detail)}catch{try{let d=await a.clone().text();d&&(o=d)}catch{}}let u=new Error(o);throw u.status=a.status,u.response=a,u}return a}async login(t,e){let s=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!s.session_id||!s.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=s.auth_token,this.sessionId=s.session_id,s}async register(t,e,i,s){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:i,company:s.company,first_name:s.first_name,last_name:s.last_name})})).json()}async getSubtitleTrack(t,e,i){let s=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&s.append("lang",e.trim()),i&&typeof i=="string"&&i.trim()&&s.append("model",i.trim());let r=s.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,e=10){return(await this.request(`/vods?skip=${t}&limit=${e}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};0&&(module.exports={ANIMATION_STYLING,ANIMATION_URLS,AUTHORED_PLAYBACK_OPTIONS,EMOTION_ANIMATION_URLS,PhontClient,REFERENCE_GTS,REFERENCE_INTENSITY,RENDERING_CONTROL,SubtitleManager,SubtitleStateManager,calculateAnimationParameters,calculateAnimationState,calculateDynamicWordSpacing,calculateEmphasisMultiplier,calculateGTSValues,calculateJoy,calculateJoyBulge,calculateNormalizedTime,calculateWeightFromVolume,calculateWidthFromSpeechRate,calculateWordEmphasisEffects,calculateWordLetterSpacing,capEmotionIntensity,computeProsodyWeight,createPublishedAnimationResolver,decodeAnimationUrl,ensureFont,findSubtitleForWord,generateTextShadow,getAnimationUrlForEmotion,getCombinedBlurAmount,getCurrentAuthToken,getCurrentSessionId,getFontFamilyCSS,getJoyAnimationMode,getJoyFilter,getJoyTransform,getMergedSubtitles,getMotionBlurAmount,getSubtitleAnimations,getSubtitleText,getSubtitleTiming,getSubtitleWords,getWordEmphasis,hasMergedSubtitles,hockeyStickIntensity,isInEmphasisRange,isInStrongEmphasisRange,isSubtitleDebugEnabled,logSubtitleData,meetsEmotionThreshold,preloadAnimationFonts,processEmotionsWithImportance,resolveEffectiveGts,sampleParameterCurve,selectEmotion,selectFontFamily,shouldUseAngryFont,shouldUseJoyFont,shouldUseSadnessFont,splitTextIntoLetters,subtitleManager});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var vt=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,e,i){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),i!==void 0&&(this.state.soundByteFiltered=i),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,e,i){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),i!==void 0&&(this.vodState.soundByteFiltered=i),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,e){this.state.segmentDurations.set(t,e)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var xt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let e=t||"original";return this._subtitleCache.get(e)}set(t,e){let i=t||"original";this._subtitleCache.set(i,{data:e,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let e=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],i=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],s=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,
|
|
1
|
+
var vt=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,e,i){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),i!==void 0&&(this.state.soundByteFiltered=i),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,e,i){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),i!==void 0&&(this.vodState.soundByteFiltered=i),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,e){this.state.segmentDurations.set(t,e)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var xt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let e=t||"original";return this._subtitleCache.get(e)}set(t,e){let i=t||"original";this._subtitleCache.set(i,{data:e,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let e=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],i=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],s=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,u=0,d=0;r.forEach(f=>{e.includes(f)&&o++,i.includes(f)&&u++,s.includes(f)&&d++});let l=o/a,m=u/a,c=d/a,C=.1;return l>C&&l>m&&l>c?"de":m>C&&m>l&&m>c?"pl":c>C&&c>l&&c>m?"en-US":null}};var je="phont_session_",Ne="phont_current_user";function oe(n){return`${je}${n}`}function le(){try{return localStorage.getItem(Ne)}catch(n){return console.error("Failed to get current user:",n),null}}function ue(n){if(!n)return null;try{let t=localStorage.getItem(oe(n));if(!t)return null;let e=JSON.parse(t);return!e.sessionId||!e.authToken||!e.username?(console.warn("Invalid session data found in storage"),Ue(n),null):e}catch(t){return console.error("Failed to retrieve session:",t),null}}function Xe(n){let t=ue(n);return t?t.authToken:null}function $e(n){let t=ue(n);return t?t.sessionId:null}function Ue(n){if(n)try{localStorage.removeItem(oe(n))}catch(t){console.error("Failed to clear session:",t)}}function zt(){let n=le();return n?Xe(n):null}function Gt(){let n=le();return n?$e(n):null}var ut=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",Tt=class{constructor(t,e){this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=e||null}setPhontClient(t){this.phontClient=t}normalizeSubtitles(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:t&&Array.isArray(t.subtitles)?t.subtitles.length>0&&!Array.isArray(t.subtitles[0])&&typeof t.subtitles[0]=="object"?[t.subtitles]:t.subtitles:[]}normalizeSoundbites(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:[]}async parseHLSMasterManifest(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch master manifest: ${e.status}`);let s=(await e.text()).split(`
|
|
2
2
|
`);for(let r of s)if(r.includes("#EXT-X-MEDIA:TYPE=AUDIO")&&r.includes("URI=")){let a=r.match(/URI="([^"]+)"/);if(a){let o=a[1];return o.startsWith("http")?o:`${t.substring(0,t.lastIndexOf("/"))}/${o}`}}throw new Error("No audio stream found in manifest")}catch(e){throw e}}async parseAudioPlaylist(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch audio playlist: ${e.status}`);let i=await e.text(),s=new Map,r=i.split(`
|
|
3
|
-
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let m=o.match(/#EXTINF:([0-9.]+)/);if(m){let u=parseFloat(m[1]);s.set(a,u),a++}}return s}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let i=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let s=await this.parseHLSMasterManifest(i),r=await this.parseAudioPlaylist(s);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let e=this._audioPlaylistCache.segmentDurations.get(t);return e!==void 0?e:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let e=await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(e)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let e;if(this.phontClient){if(!ut&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ut||this.phontClient.apiBaseUrl,s=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);e=await s.json()}else{if(!ut)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ut}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);e=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),e}catch{return null}}async fetchSubtitleData(t,e=null){if(this.stateManager.clearVodState(),!!t)try{let i,s;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");s=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let m=r.searchParams.get("lang")||e||void 0,u=r.searchParams.get("model")||void 0;try{i=await this.phontClient.getSubtitleTrack(s,m||null,u||null)}catch(l){let d=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),c=typeof l?.message=="string"?l.message:String(l||""),C=d===404||c.includes("404")||c.includes("Not Found"),f=d===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(C||f)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{s=t;let r=e&&e.trim()||void 0;try{i=await this.phontClient.getSubtitleTrack(s,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),m=typeof a?.message=="string"?a.message:String(a||""),u=o===404||m.includes("404")||m.includes("Not Found"),l=o===400||m.includes("400")||m.includes("Bad Request")||m.includes("HTTP error! status: 400");if(u||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${u?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);s=l?l[1]:t.split("/").pop().split("?")[0]}else{if(s=t,!ut&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ut||this.phontClient?.apiBaseUrl,d=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&d.append("lang",e.trim());let c=d.toString();r=c?`${l}/vod-subtitles/${s}?${c}`:`${l}/vod-subtitles/${s}`}let a={"Content-Type":"application/json"},o=oe(),m=le();o&&(a.Authorization=`Bearer ${o}`),m&&(a["X-Session-ID"]=m);let u=await fetch(r,{headers:a,cache:"no-store"});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);i=await u.json()}return this.stateManager.updateVodVideoId(s),{data:i,videoId:s}}catch(i){throw this.stateManager.clearVodState(),i}}};var ue={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Mt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[i,s]of Object.entries(ue)){let r=i.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return s}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let i of t.important){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`important_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let i of t.all){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`all_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(i=>{if(i.animationFile==="Laughter"){let s=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-i.startTime)<=1);if(s){s.endTime=Math.max(s.endTime,i.endTime);return}}e.push(i)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,i=2,s=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&e<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:c})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let m of o){let u=this.mapEventLabelToAnimation(m.event_label);if(u){let l=m.start_time??m.onset??0,d=m.end_time??m.offset??0;if(e>=l&&e<=d){let C="all";this.stateManager.state.soundByteImportant?.includes(m)?C="important":this.stateManager.state.soundByteFiltered?.includes(m)&&(C="filtered"),s.push({id:`live_${m.event_label}_${l}`,eventLabel:m.event_label,animationFile:u,startTime:l,endTime:d,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};s.sort((o,m)=>{let u=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=m.eventLabel==="Laughter"?1:r[m.priority]||5;return u-l});let a=s.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=s=>Array.isArray(s)?s.length>0&&Array.isArray(s[0])?s.flat():s:[];return t?{all:e(this.stateManager.vodState.soundByteAll||[]),important:e(this.stateManager.vodState.soundByteImportant||[]),filtered:e(this.stateManager.vodState.soundByteFiltered||[])}:{all:e(this.stateManager.state.soundByteAll||[]),important:e(this.stateManager.state.soundByteImportant||[]),filtered:e(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,e=null){let i=[],s=[],r=e??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}return{all:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,e=30){let i=t-e,s=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=i),this.stateManager.state.soundbiteAnimations.length<s&&this.stateManager.notify()}};var _t=class{constructor(t,e,i){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=i}processVodData(t,e,i,s){let r=e.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(e?e.split("/").pop()?.split("?")[0]:void 0),m=a.flat().map(f=>({...f,sequence_number:o}));s&&s.length>0&&(m=this._mergeAnimationDataFromOriginal(m,s));let u=this._deduplicateSubtitles(m),{soundByteAll:l,soundByteImportant:d,soundByteFiltered:c}=this._processSoundbites(t.soundbite);if(l.length>0||d.length>0||c.length>0){let f={all:l,important:d,filtered:c},h=this.soundbiteProcessor.processSoundbiteAnimations(f);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...h]}let C=t.language||i||null;this.stateManager.vodState={subtitles:u,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:d,soundByteFiltered:c,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[VodDataProcessor] Processed VOD data:",{subtitleCount:u.length,firstSubtitle:u[0]?{start_time:u[0].start_time,end_time:u[0].end_time,text:u[0].text,hasWords:!!u[0].words,wordCount:u[0].words?.length||0,emotion:u[0].emotion,animations:u[0].animations}:null,videoId:r,languageCode:i}),this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,e){let i=new Map;for(let s of e){let r=`${s.start_time}-${s.end_time}`;(!i.has(r)||s.animations||s.emotion)&&i.set(r,s)}return t.map(s=>{let r=`${s.start_time}-${s.end_time}`,a=i.get(r);if(!a)return s;let o=s.animations&&typeof s.animations=="object"&&Object.keys(s.animations).length>0,m=s.emotion&&s.emotion!=="none"&&s.emotion!=="neutral",u=typeof s.animation_url=="string"&&s.animation_url.length>0;if(o&&u)return s;let l={...s};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!m&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!u&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let d=new Map;for(let c of a.words)d.set(`${c.start}-${c.end}`,c);l.words=l.words.map(c=>{let C=d.get(`${c.start}-${c.end}`);if(!C||c.animations&&typeof c.animations=="object"&&Object.keys(c.animations).length>0)return c;let h={...c};return C.animations&&Object.keys(C.animations).length>0&&(h.animations=C.animations),!h.emotion&&C.emotion&&(h.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(h.emotion_intensity=C.emotion_intensity)),!h.animation_url&&C.animation_url&&(h.animation_url=C.animation_url),h})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let i of t){let s=`${i.start_time}-${i.end_time}`;(!e.has(s)||i.emotion||i.animations)&&e.set(s,i)}return Array.from(e.values())}_processSoundbites(t){let e=[],i=[],s=[];return t&&(t.all&&Array.isArray(t.all)&&(e=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(i=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(s=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:i,soundByteFiltered:s}}};var Et=class{constructor(t,e,i){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=i}async processLiveSegment(t,e,i){this.stateManager.state.processedSequences.add(e),this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let s=await i(e);this.stateManager.state.segmentDurations.set(e,s);let r=this.liveTimeGenerator.getCumulativeDuration(e),a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:m,processedSoundbitesFiltered:u}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,m,u);let l={all:o,important:m,filtered:u},d=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(d),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(c=>c.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,i){return!t||!Array.isArray(t)?[]:t.map(s=>({...s,sequence_number:e,start_time:s.start_time+i,end_time:s.end_time+i,words:s.words?s.words.map(r=>({...r,start:r.start+i,end:r.end+i})):void 0}))}_processSoundbites(t,e){let i=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),s=(t?.important||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e}));return{processedSoundbitesAll:i,processedSoundbitesImportant:s,processedSoundbitesFiltered:r}}_updateState(t,e,i,s){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...e],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...i],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...s]}};var It=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let e=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=e,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(e-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let e=t.src,i=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),i&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let i=this.stateManager.state.initialSequenceOffset;i<t;i++){let s=this.stateManager.state.segmentDurations.get(i)||10;e+=s}return e}};var kt=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,e){if(!t)return null;let s=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(e>=a.start)r.push(a.word);else break;s=r.join(" ")}return{activeSubtitle:t,displayText:s}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[CurrentSubtitle] No subtitles in vodState:",{hasVodState:!!e,subtitleCount:e?.subtitles?.length||0,vodStateKeys:e?Object.keys(e):[]}),null;let i=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!i&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let s=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(typeof window<"u"&&window.location.search.includes("debug=subtitles")&&!s&&t>0&&console.log("[CurrentSubtitle] No subtitle found for time:",{time:t,subtitleCount:e.subtitles.length,firstSubtitle:e.subtitles[0]?{start_time:e.subtitles[0].start_time,end_time:e.subtitles[0].end_time,text:e.subtitles[0].text||e.subtitles[0].words?.map(r=>r.word).join(" ")}:null,lastSubtitle:e.subtitles[e.subtitles.length-1]?{start_time:e.subtitles[e.subtitles.length-1].start_time,end_time:e.subtitles[e.subtitles.length-1].end_time}:null}),s){let r=this._processSubtitleText(s,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,m=e.currentSubtitle!==o||e.currentSubtitleData!==a;return m&&(e.currentSubtitle=o,e.currentSubtitleData=a,e.currentSequence=e.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=e.currentSequence??null),(i||m)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return e.currentSubtitle!==""&&(e.currentSubtitle="",e.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let e=t.subtitles.find(i=>t.currentTime>=i.start_time&&t.currentTime<=i.end_time);if(e){t.currentSequence=e.sequence_number??null;let i=this._processSubtitleText(e,t.currentTime);if(!i)return null;let{activeSubtitle:s,displayText:r}=i;return(t.currentSubtitle!==r||t.currentSubtitleData!==s)&&(t.currentSubtitle=r,t.currentSubtitleData=s,this.stateManager.notify()),this._lastSubtitleData=s,this._lastSubtitleTime=t.currentTime,s}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var Dn=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function ce(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var Bt=class{constructor(){this.stateManager=new vt,this.cache=new xt,this.fetcher=new Tt(this.stateManager),this.soundbiteProcessor=new Mt(this.stateManager),this.vodDataProcessor=new _t(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new It(this.stateManager),this.liveDataProcessor=new Et(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new kt(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,e="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?e:"none",this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}async fetchSubtitles(t){try{let e=await this.fetcher.fetchSubtitles(t);return e?await this.liveDataProcessor.processLiveSegment(e,t,i=>this.getAudioSegmentDuration(i)):null}catch{return null}}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,i,s){this.vodDataProcessor.processVodData(t,e,i,s)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,e=30){let i=t-e,s=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=i),this.state.subtitles.length<s&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,e=null){return this.soundbiteProcessor.getActiveSoundbites(t,e)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,e=30){this.soundbiteProcessor.clearOldAnimations(t,e)}getCurrentSpeaker(t=!1,e=null){if(!this.state.isSpeaker)return null;let i=null;if(t?i=this.vodState.currentSubtitleData:i=this.state.currentSubtitleData,!i||!i.words)return null;let s=i?.speaker;return s||null}async fetchSubtitleData(t,e=null,i=null){if(!e&&t){let s=new URLSearchParams(t.split("?")[1]||"");e=s.get("lang")||null,i||(i=s.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let s=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=s,o=r?.language||e||null;console.log("[SubtitleManager] Fetched subtitle data:",{hasData:!!r,hasSubtitles:!!r?.subtitles,subtitleCount:r?.subtitles?.length||0,videoId:a,url:t,translation_provider:r?.translation_provider||"deepl",translation_model:r?.translation_model||"none",language:o||"ORIGINAL",usingLLM:r?.translation_provider==="phont"});let m=ce(o??e),u=i?`${m}_${i}`:m,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(u,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let c;if(!!e&&String(e).trim()!==""){let f=this.cache._subtitleCache.get("original");f?.data?.subtitles&&(c=Array.isArray(f.data.subtitles)?f.data.subtitles.flat():[])}console.log("[SubtitleManager] Processing VOD data..."),this._processVodData(r,t,o,c),console.log("[SubtitleManager] VOD data processed. State:",{subtitleCount:this.state.subtitles.length,vodSubtitleCount:this.vodState.subtitles?.length||0,currentSequence:this.state.currentSequence})}catch(s){let r=s?.status||s?.response?.status,a=r===404||typeof s?.message=="string"&&s.message.includes("404")||typeof s?.message=="string"&&s.message.includes("Not Found"),o=r===400||typeof s?.message=="string"&&s.message.includes("400")||typeof s?.message=="string"&&s.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:s?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",s),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,e,i=null){if(!e)return;let s=ce(t);if(this.cache._loadingLanguages.has(s))return;let r=i?`${s}_${i}`:s,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(s);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let m=new URLSearchParams;t&&m.append("lang",t),i&&m.append("model",i);let u=m.toString(),l=`${o}/vod-subtitles/${e}${u?`?${u}`:""}`,d=!1;try{await this.fetchSubtitleData(l,t,i),d=!0}catch(c){if(c?.status===404||typeof c?.message=="string"&&c.message.includes("404"))if(t!==null)d=!0;else throw c;else throw c}if(!d)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,i)}finally{this.cache._loadingLanguages.delete(s)}}_loadCachedSubtitles(t,e,i){let s=t?.language||i||null,r;if(!!i&&String(i).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,e,s,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},Ne=new Bt;function Xe(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[i,s]=e.split(","),r=t||typeof s=="string"&&(s.startsWith("#")||s.startsWith("%23")),a;return r?a=s.replace(/%23/g,"#"):a=parseFloat(s),{time:parseFloat(i),value:a}})}catch(e){return console.error("Error decoding points:",e),[]}}function $e(n){if(!n)return"";if(n.includes("://"))try{let t=new URL(n);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=n.indexOf("?");return t!==-1?n.substring(t+1):n}return n.startsWith("?")?n.slice(1):n}function zt(n){try{let t=$e(n),e=new URLSearchParams(t),i={parameterStates:{}};if(e.has("name")&&(i.name=e.get("name")||void 0),e.has("user")&&(i.userName=e.get("user")||void 0),e.has("duration")&&(i.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(i.animationMode=e.get("mode")||void 0),e.has("text")&&(i.text=e.get("text")||void 0),e.get("format")==="normalized"&&(i.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?i.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:i.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{i.backgroundStyle=JSON.parse(e.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of e.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),m=Xe(a,o);if(m.length>0){let u=o?"#000000":0;i.parameterStates[r]={points:m,currentValue:m[0]?.value||u}}}return i}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function Ue(n){if(n===0)return 0;let t=4,e;if(n<=.7){let i=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*i}else{let i=(n-.7)/.3,s=Math.log(1+.5*(Math.exp(t)-1))/t;e=s+i*(1-s)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function Ft(n){if(typeof n!="string")return{r:0,g:0,b:0};let t=n.replace("#","").padStart(6,"0"),e=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function de(n,t,e){let i=s=>{let r=Math.round(Math.max(0,Math.min(255,s))).toString(16);return r.length===1?"0"+r:r};return"#"+i(n)+i(t)+i(e)}function me(n,t,e){let i=Ft(n),s=Ft(t),r=Math.max(0,Math.min(1,e)),a=i.r+(s.r-i.r)*r,o=i.g+(s.g-i.g)*r,m=i.b+(s.b-i.b)*r;return de(a,o,m)}function Ye(n,t,e){if(e===0)return n;let i=Ft(n),s=Ft(t),r=i.r+(s.r-i.r)*e,a=i.g+(s.g-i.g)*e,o=i.b+(s.b-i.b)*e;return de(r,a,o)}function Ct(n,t,e,i=!1,s=null){if(!n||n.length===0)return null;let r=i?t:t*e,a=null,o=null;for(let m=0;m<n.length;m++){let u=n[m],l=u.time!==void 0?u.time:Array.isArray(u)?u[0]:0;if(l!==void 0&&l<=r&&(a=u),l!==void 0&&l>=r&&!o){o=u;break}}if(!a&&n[0])return(n[0].value!==void 0?n[0].value:Array.isArray(n[0])?n[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let m=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,u=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,d=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(m===u||l===null||d===null)return l??null;let c=(r-m)/(u-m),C=s==="color"||s==="shadowColor"||s==="outlineColor"||s==="outline2Color"||s==="outline3Color"||s==="outlineShadowColor"||s==="glowColor";if(C&&(typeof l=="string"||typeof d=="string"))return me(typeof l=="string"?l:"#000000",typeof d=="string"?d:"#000000",c);if(!C&&(typeof l=="string"||typeof d=="string")){let f=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),h=typeof d=="string"&&(d.startsWith("#")||/^[0-9a-f]{6}$/i.test(d));if(f&&h){let g=l.startsWith("#")?l:`#${l}`,_=d.startsWith("#")?d:`#${d}`;return me(g,_,c)}return d??null}return l+(d-l)*c}return null}var Ce=.7,Pt=.7,Ve={rawMode:!0};function ht(n,t,e,i,s=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*i/(Ce*Pt),o=n.duration||2,u=n.format==="normalized"?e:e*o,l=!0,d=n.parameterStates||{},c=(A,B,$=!0,q=null)=>{let dt=q??a,at=Ct(d[A]?.points,u,o,l);return at==null?B:$?dt===0?B:B+(at-B)*dt:at},C=c("scale",1),f=c("skew",0),h=c("stretch",1),g=c("translateX",0),_=c("translateY",0),b=c("weight",500),E=c("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",D=n.text||"Hello",R=(A,B)=>{let $=Ct(d[A]?.points,u,o,l,A);if($==null)return B;let q=typeof $=="string"?$.startsWith("#")?$:`#${$}`:`#${Math.round($).toString(16).padStart(6,"0")}`;return a===0?B:Ye(B,q,a)},k=R("color","#ffffff"),P=c("opacity",1),I=c("shadowX",0),T=c("shadowY",0),H=c("shadowBlur",4),tt=c("shadowOpacity",.5),O=R("shadowColor","#000000"),ft=c("outlineWidth",0),$t=R("outlineColor","#000000"),W=A=>d[A]?.points?.length>0,ct=W("stretchX")?c("stretchX",1):void 0,gt=W("outline2Width")?c("outline2Width",0):void 0,pt=W("outline2Color")?R("outline2Color","#000000"):void 0,bt=W("outline3Width")?c("outline3Width",0):void 0,yt=W("outline3Color")?R("outline3Color","#000000"):void 0,S=W("outlineShadowWidth")?c("outlineShadowWidth",0):void 0,X=W("outlineShadowColor")?R("outlineShadowColor","#000000"):void 0,j=W("outlineShadowBlur")?c("outlineShadowBlur",0):void 0,v=W("glowIntensity")?c("glowIntensity",0):void 0,L=W("glowColor")?R("glowColor","#ffffff"):void 0,N=W("snakeWave")?c("snakeWave",0):void 0,et=W("karaoke")?c("karaoke",0):void 0,U=1-.5*Math.min(1,Math.max(0,i)),V=c("blur",0,!0,r?1:a*U),mt=Ct(d.thinStroke?.points,u,o,l),K=Ct(d.ascenderHeight?.points,u,o,l),it={};mt!=null&&typeof mt=="number"&&(it.YOPQ=mt),K!=null&&typeof K=="number"&&(it.YTAS=K),b!=null&&(it.wght=b),E!=null&&(it.wdth=E);let J=[];if(I!==0||T!==0||H!==4||tt!==.5){let A=typeof O=="string"?O:"#000000",B=parseInt(A.slice(1,3),16),$=parseInt(A.slice(3,5),16),q=parseInt(A.slice(5,7),16);J.push(`${I}px ${T}px ${H}px rgba(${B}, ${$}, ${q}, ${tt})`)}else if(O&&typeof O=="string"&&O!=="#000000"){let A=O.startsWith("#")?O:`#${O}`,B=parseInt(A.slice(1,3),16)||0,$=parseInt(A.slice(3,5),16)||0,q=parseInt(A.slice(5,7),16)||0;J.push(`3px 2px 4px rgba(${B}, ${$}, ${q}, 0.5)`)}if(v!=null&&v>0){let A=typeof L=="string"?L:"#ffffff";J.push(`0 0 ${v}px ${A}`),J.push(`0 0 ${v*2}px ${A}`),J.push(`0 0 ${v*4}px ${A}`)}let Ut=J.length>0?J.join(", "):"",lt=0;if(d.joy?.points&&d.joy.points.length>0)for(let A of d.joy.points){let B=Array.isArray(A)?A[1]:A.y??A.value??0;typeof B=="number"&&B>lt&&(lt=B)}let St=c("joy",0,!1),Yt=r?St:Math.min(1,lt*a),Z=c("fear",0),Q=c("standardEmphasis",0,!1),nt=c("strongEmphasis",0,!1),M={rawIntensity:t,scaleFactor:a,scale:C,slant:f,stretchY:h,translateX:g,translateY:_,weight:b,width:E,fontFamily:y,textColor:k,opacity:P,textShadow:Ut,blur:V,outlineWidth:ft,outlineColor:$t,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:it,text:D,joy:Yt,fear:Z,standardEmphasis:Q,strongEmphasis:nt,joyWaveProgress:u/o*1.5};return ct!==void 0&&(M.stretchX=ct),gt!==void 0&&(M.outline2Width=gt),pt!==void 0&&(M.outline2Color=pt),bt!==void 0&&(M.outline3Width=bt),yt!==void 0&&(M.outline3Color=yt),S!==void 0&&(M.outlineShadowWidth=S),X!==void 0&&(M.outlineShadowColor=X),j!==void 0&&(M.outlineShadowBlur=j),v!==void 0&&(M.glowIntensity=v),L!==void 0&&(M.glowColor=L),N!==void 0&&(M.snakeWave=N),et!==void 0&&(M.karaoke=et),M}var x={fontSize:54,opacity:1,weight:400,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:4,color:"rgba(0, 0, 0, 0.4)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:1.25,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function Lt(n,t,e){let i=Math.max(0,Math.min(1,n)),s=e??t;if(typeof s=="number"&&Number.isFinite(s)){let r=Math.max(0,Math.min(1,s));return Math.min(1,Math.max(0,r*(i/Pt)))}return i}function Gt(n){let t=.2+.8*n,e=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*n;return{gts:n,maxExpression:t,threshold:e,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function Zn(n,t){return n>=t}function he(n,t){if(t<=.2)return 0;let e=n*t;return n>.1&&console.log(`[GTS Scaling] Raw: ${n.toFixed(3)} \xD7 maxExpression: ${t.toFixed(3)} = Final: ${e.toFixed(3)} | Match check: ${n.toFixed(3)} === ${e.toFixed(3)}? ${n===e}`),e}function fe(n){let{minThreshold:t,maxThreshold:e}=p.emphasis;return n<t||n>=e?0:(n-t)/(e-t)}function ge(n){return n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold}function pe(n){return n>=p.strongEmphasis.minThreshold}function qe(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,m=n*n,u=m*n;return o*0+3*a*n*.42+3*r*m*.58+u*1}var be=new WeakMap,Ht={joy:1,social_positive:1,anger:-1,screaming:-1};function Kt(n,t,e,i){let s=typeof e=="string"?e.toLowerCase():"";if(s==="joy")return ze(n,t,i);let r=Math.sign(t);return r!==0?r:s in Ht?Ht[s]:i}function ze(n,t,e){let i=Math.sign(t);if(n){let s=be.get(n);if(s!==void 0)return s;let r=i!==0?i:ye(e);return be.set(n,r),r}return i!==0?i:ye(e)}function ye(n){return n!==0?n:Ht.joy}function Ge(n,t,e=1,i=0,s=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:m,scaleDownFrames:u,fps:l}=p.emphasis;if(!n||!ge(a))return null;let d=t-n.start,c=s?n.start+s:n.end,C=c-n.start;if(d<0||t>=c)return null;let f=Math.max(0,Math.min(1,d/C)),h=0;f<.5?h=f*2:h=2-f*2,h=h*h*(3-2*h);let g=fe(a),_=.55,b=3*_,F=Kt(n,i,r,0)*b*h*e*g,y=140*h*e*g,D=1+o*_*h*e*g,R=f<1;return{scaleMultiplier:D,slantAdditive:F,weightBoost:y,scaleProgress:h,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:d,scaleActive:R}}function He(n,t,e={},i=1,s=null,r=0,a=""){let o=a==="anger"||a==="screaming",m=p.strongEmphasis,u=.7,l=s?n.start+s:n.end;if(t<n.start)return null;let d=n.emphasis||0;if(!pe(d))return null;let c=m.fadeOutTailDuration,C=l+c;if(t>=C)return null;let f=l-n.start,h=Math.max(0,Math.min(1,(t-n.start)/f)),g=1,_=t>=l;if(_){let T=(t-l)/c;g=1-qe(T),h=1}let b=0;h<.5?b=h*2:b=2-h*2;let E=b*b*(3-2*b),F=(d-m.minThreshold)/(1-m.minThreshold),y=E*F*i,D=y;y<.1&&(y=0);let R=Kt(n,r,a,-1),k,P;if(o)k={scale:1+y*(m.maxScale-1)*u,rotation:y*m.maxRotation*u,translateY:-y*m.maxTranslateY*u,translateX:y*m.maxTranslateX*u,skewX:R*y*m.maxSkew*u,stretchY:1},P={brightness:1+y*m.maxBrightness*u,contrast:1+y*m.maxContrast*u,shadowBlur:y*m.maxShadowBlur*u,shadowOpacity:y*m.shadowOpacity*u,zIndex:Math.round(y*m.maxZIndex*u)};else{let tt=E*20*Math.max(.2,F*i)*u,O=Kt(n,r,a,1);k={scale:1+y*.15*u,rotation:0,translateY:0,translateX:0,skewX:O*tt,stretchY:1},P={brightness:1+y*.2*u,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(k.scale=1+(k.scale-1)*g,k.rotation=k.rotation*g,k.translateX=k.translateX*g,k.translateY=k.translateY*g,k.skewX=k.skewX*g,P.brightness=1+(P.brightness-1)*g,P.contrast=1+(P.contrast-1)*g,P.shadowBlur=P.shadowBlur*g,P.shadowOpacity=P.shadowOpacity*g,P.zIndex=Math.round(P.zIndex*g),y=y*g);let I=280*y*i;return{emphasis:y,rawEmphasis:D,...k,...P,weightBoost:I,shadowOffsetX:y*m.shadowOffsetX,shadowOffsetY:y*m.shadowOffsetY,gtsMultiplier:i,emphasisMultiplier:F,fadeFactor:g,isInTail:_}}function Se({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:i,wordBaseSlant:s,isActive:r,wordEmotion:a=""}){let o=r?Ge(n,t,e,s,i,a):null,m=He(n,t,{},e,i,s,a);return{emphasisEffect:o,strongEmphasisData:m}}function we(n){let t=2*Math.PI/3;return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*t)+1}function Ae(n){return 1-(1-n)*(1-n)}function ve(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function is(n,t,e,i=1){let s=p.joy.letterWave,r=e<=6,a,o,m;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),m=a+o):(a=s.innerWidthRatio,o=s.outerWidthRatio,m=a+o);let u=t/Math.max(1,e-1),l=n;r&&e<=3?l=Math.min(1.2,n*1.25):r&&(l=Math.min(1.1,n*1.1));let d=l*(1+m),c=u-d,C=a+o,f=o*.3;if(c>f||c<-C)return null;let h=0;if(c>0&&c<=f)h=(1-c/f)*.15;else if(c<=0&&c>=-a){let y=Math.abs(c)/Math.max(a,.01);h=we(y)}else if(c<-a){let D=(Math.abs(c)-a)/Math.max(o,.01);h=Ae(1-D)}if(h<=.01)return null;let g=h*i,b=1-t%2*.15,E={scale:1+g*(s.maxScale-1)*b,rotation:g*s.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*s.maxTranslateY*b,skewX:-g*s.maxSkew*.5,stretchY:1},F={brightness:1+g*s.maxBrightness,contrast:1+g*s.maxContrast,shadowBlur:g*s.maxShadowBlur,shadowOpacity:g*s.shadowOpacity,zIndex:Math.round(g*s.maxZIndex)};return{pressure:g,...E,...F,shadowOffsetX:g*3,shadowOffsetY:g*3}}function as(n,t,e,i=1){let s=p.joy.letterBulge,r=s.innerWidthRatio,a=s.outerWidthRatio,o=r+a,m=e>1?t/Math.max(1,e-1):0,u=n*(1+o),l=m-u,d=a*.35,c=o;if(l>d||l<-c)return null;let C=0;if(l>0&&l<=d)C=(1-l/Math.max(d,1e-4))*.18;else if(l<=0&&l>=-r){let D=Math.abs(l)/Math.max(r,1e-4);C=we(D)}else if(l<-r){let R=(Math.abs(l)-r)/Math.max(a,1e-4);C=Ae(1-R)}if(C<=.01)return null;let f=C*i,h=Math.min(1,f*.85),g=1,_=t%3===0?1:-1,b=Math.max(1-s.maxCompressionX,1-h*s.maxCompressionX),E=1+h*s.maxStretchY,F={scale:1+h*(s.maxScale-1),stretchY:E,stretchX:b,rotation:h*s.maxRotation*g,translateX:h*s.maxTranslateX*_,translateY:-h*s.maxTranslateY,skewX:h*s.maxSkew*g},y={brightness:1+h*s.maxBrightness,contrast:1+h*s.maxContrast,shadowBlur:h*s.maxShadowBlur,shadowOpacity:h*s.shadowOpacity,zIndex:Math.round(h*s.maxZIndex)};return{pressure:h,bulgeIntensity:h,...F,...y,shadowOffsetX:h*1.8,shadowOffsetY:h*3}}function rs(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,i=n.rotation||0,s=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${i}deg) skewX(${a}deg) translate(${s}px, ${r}px)`}function os(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,i=n.shadowBlur||0,s=n.shadowOpacity||0,r=n.shadowOffsetX||0,a=n.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),e!==1&&o.push(`contrast(${e})`),i>0&&s>0&&o.push(`drop-shadow(${r}px ${a}px ${i}px rgba(255, 255, 255, ${s}))`),o.join(" ")}var Ke=["anger","fear","sadness","joy"];function Je(n){return Ke.includes(n.toLowerCase())}function Rt(n){return n.map(([t,e])=>{let i=Je(t),s=i?1.5:1,r=e*s;return[t,e,r,s,i]})}function Ze(n){if(!n)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=n.confidence_word||0,e=n.emphasis||0;return{confidence:t,emphasis:e,hasEmphasis:e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold,hasStrongEmphasis:e>=p.strongEmphasis.minThreshold}}function Dt(n){return n&&(n.subtitle||n.text)||""}function Jt(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function Ot(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function st(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function Wt(n){return st(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function Zt(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function Qe(n,t,e=null,i=null){if((i?.name==="children"||i?.name==="hello-kitty")&&e&&i.fonts?.[e])return i.fonts[e];let s=p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold;return s?x.angryFont:r?x.joyFont:a?x.sadnessFont:x.defaultFont}function Qt(n,t,e=null,i=null){let s=Qe(n,t,e,i),r="sans-serif";return s==="Cormorant"&&(r="serif"),`"${s}", ${r}`}function fs(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function gs(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function ps(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var Me='"Roboto Flex", "Roboto", sans-serif',xe=new Map,tn={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function jt(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?tn[t]||t:""}function te(n){if(typeof n!="string"||n.length===0)return null;let t=xe.get(n);if(t)return t;try{let e=zt(n);return xe.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function en(n){if(!n||n.length===0)return null;let t=n.filter(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(e=>e.start_time)),end:Math.max(...t.map(e=>e.end_time))}}function nn(n,t){return n.find(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number"&&t>=e.start_time&&t<=e.end_time)||null}function Nt(n){return n&&typeof n.animation_url=="string"&&n.animation_url.length>0?n.animation_url:null}function _e(n,t){if(!n)return{emotion:"none",intensity:0};let e=Ot(n),i=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(i.length>0){let a=Rt(i).sort((o,m)=>m[2]-o[2])[0];return{emotion:jt(a[0])||"none",intensity:a[1]}}let s=jt(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!s||s==="none"||r<=0?Nt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:s,intensity:r}}function sn(n){let t={...n};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function Te(n,t,e,i){let{minWordDisplayTime:s,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,m=Math.max(0,n.end-n.start),u=Math.max(m,s);if(!i)return n.start+u;let l=typeof t.end_time=="number"?t.end_time:n.end,d=l-n.end,c=!1;if(e!=null&&e>l?(d=e-n.end,c=d>=o):e==null?(c=!0,d=1/0):c=d>=a,c){let f=d===1/0?s+r:n.end+d-n.start-.1,g=m<s?f:Math.min(s+r,f);u=Math.max(u,g)}return n.start+u}function an(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let i=n.findIndex(a=>t>=a.start&&t<a.animationEnd),s=n.reduce((a,o,m)=>t>=o.animationEnd?m:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||s!==-1&&o<=s?1:e?0:.3),currentWordIndex:i}}function Ee(n){if(!n)return x.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),i=e.toLowerCase();return i.includes("bricolage")?"Bricolage Grotesque":i.includes("rakkas")?x.angryFont:i.includes("parkinsans")?x.joyFont:i.includes("cormorant")?x.sadnessFont:i.includes("roboto")?x.defaultFont:e}function rn(n,t,e){let i={text:"",fontSize:x.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:Me,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return i;let s=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=s<=.2,m=Gt((s-.2)/.8).gts,u=n.start_time,l=n.end_time,d=Math.max(.01,l-u),c=Math.max(0,Math.min(1,(t-u)/d)),C=_e(n,r),f=o?"none":C.emotion,h=o?0:Math.max(0,C.intensity),g=te(Nt(n)),_=Lt(m,n.gts,void 0),b=g?ht(g,h,c,_,d):null,E=b?.fontFamily?`"${Ee(b.fontFamily)}", sans-serif`:Qt(f,s),F={fontSize:x.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??x.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?sn(F):F,text:Dt(n),emotion:f,emotionIntensity:h,fontFamily:E,startTime:u,endTime:l,duration:d,isActive:t>=u&&t<l}}function on(n,t,e){let i=e.maxExpression??1,s=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,m=e.transparentUntilSpoken??!1,u=i<=.2,l=Gt((i-.2)/.8).gts,d={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:Me,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return d;let c=st(n)?Wt(n):[n],C=en(c),f=nn(c,t);if(!f&&o!=null&&t>n.end_time&&t<=o&&(f=c[c.length-1]||null),!f&&C&&t>=C.start&&t<=C.end&&(f=[...c].filter(S=>S&&t>=S.start_time).sort((S,X)=>X.start_time-S.start_time)[0]||null),f==null)return d;let h=f,g=_e(h,s),_=u?"none":g.emotion,b=u?0:Math.max(0,g.intensity),E=h.start_time,F=h.end_time,y=Math.max(.01,F-E),D=Math.max(0,Math.min(1,(t-E)/y)),R=st(n)?null:te(Nt(h)),k=h.gts??n.gts,P=Lt(l,k,void 0),I=R?ht(R,b,D,P,y):null,T={fontSize:x.fontSize,scale:I?.scale??(_==="none"?1:1+b*.16),opacity:I?.opacity??1,slant:I?.slant??0,weight:I?.weight??400,width:I?.width??100,textColor:I?.textColor??x.textColor,translateX:I?.translateX??0,translateY:I?.translateY??0,stretchY:I?.stretchY??1,textShadow:I?.textShadow??"",blur:I?.blur??0,outlineWidth:I?.outlineWidth??0,outlineColor:I?.outlineColor??"#000000",fontVariationAxes:I?.fontVariationAxes??{}},H=Jt(n).flatMap(S=>{let X=String(S?.word??""),j=X.trim();if(!j.includes(" "))return[S];let v=j.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,v.length),et=X.startsWith(" ");return v.map((U,V)=>({...S,word:(V===0&&et?" ":"")+U,start:(S.start??0)+V*N,end:(S.start??0)+(V+1)*N}))}),tt=null;if(st(n)&&C?.end){let S=H[H.length-1],X=Te(S,n,a,!0),j=o??X,{minWordDisplayTime:v,breathingRoomDuration:L}=p.timing,N=v+L,U=(H.length>0?Math.min(...H.map(V=>V.start)):C.start)+N;tt=Math.max(C.end,j,U)}let O=H.map((S,X)=>{let j=X===H.length-1,v=Te(S,n,a,j);return{...S,animationEnd:st(n)&&tt?Math.max(v,tt):v}}),{currentWordIndex:ft,opacities:$t}=an(O,t,m),W=O.map((S,X)=>{let j=t>=S.start&&t<S.end,v=_,L=b,N=b,et=st(n)?Wt(n):null,U=et?Zt(et,S):h;if(U){let rt=Ot(U),At=Object.entries(rt).filter(([,G])=>typeof G=="number"&&G>s),Vt=Object.entries(rt).filter(([,G])=>typeof G=="number");if(Vt.length>0)N=[...Vt].sort((ot,qt)=>qt[1]-ot[1])[0][1];else{let G=jt(U.emotion),ot=typeof U.emotion_intensity=="number"?U.emotion_intensity:0;G&&ot>0&&(v=G,N=ot,L=ot)}if(At.length>0){let G=Rt(At).sort((ot,qt)=>qt[2]-ot[2]);v=jt(G[0][0])||"none",L=G[0][1]}else Vt.length>0&&(v="none",L=0)}u?(v="none",L=0):L===N&&L!==0&&(L=he(L,i));let V=Math.max(.01,(S.end??0)-(S.start??0)),mt=Math.max(0,Math.min(1,(t-S.start)/V)),K=te(Nt(U)),it=N>0?N:K?Math.max(1,b||0):0,J=Lt(l,k,S.gts),w=K?ht(K,it,mt,J,V):null,Ut=Ee(K?.fontData?.style?.fontFamily),lt=(K?.parameterStates?.standardEmphasis?.points?.length??0)>0,St=(K?.parameterStates?.strongEmphasis?.points?.length??0)>0,Yt=lt||St,Z=j?w?.standardEmphasis??0:0,Q=j?w?.strongEmphasis??0:0,nt=null,M=null;if(Yt){let rt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:0;if(lt&&(nt={scaleMultiplier:1+.272*Z*i,slantAdditive:rt*4.25*Z*i,weightBoost:250*Z*i,scaleProgress:Z,gtsMultiplier:i,emphasis:Z,emphasisMultiplier:Z,elapsed:0,scaleActive:Z>0}),St&&!r){let At=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:1;M={emphasis:Q,rawEmphasis:Q,scale:1+Q*.38,skewX:At*Q*30*i,weightBoost:400*Q*i,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+Q*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:i,emphasisMultiplier:Q,fadeFactor:1,isInTail:!1}}}else{let rt=Se({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:i,emotionAnimationDuration:V,wordBaseSlant:w?.slant||0,isActive:j,wordEmotion:v});nt=rt.emphasisEffect,M=r?null:rt.strongEmphasisData}let A=$t[X]??1,B=(w?.opacity??T.opacity??1)*A,q=(w?.scale??T.scale??1)*(nt?.scaleMultiplier||1),dt=(w?.slant??T.slant??0)+(nt?.slantAdditive||0),at=q,se=nt?.weightBoost||0;M&&(dt+=M.skewX||0,se+=M.weightBoost||0,at=q*(M.scale||1));let z={...T,fontSize:x.fontSize,scale:at,slant:dt,stretchY:w?.stretchY??T.stretchY??1,weight:(w?.weight??T.weight??400)+se,width:w?.width??T.width??100,textColor:w?.textColor??T.textColor??x.textColor,opacity:B,translateX:w?.translateX??T.translateX??0,translateY:w?.translateY??T.translateY??0,textShadow:w?.textShadow??T.textShadow??"",blur:w?.blur??T.blur??0,outlineWidth:w?.outlineWidth??T.outlineWidth??0,outlineColor:w?.outlineColor??T.outlineColor??"#000000",letterShake:w?.fear??0,fontVariationAxes:{...T.fontVariationAxes,...w?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:w?.joy??0,urlFear:w?.fear??0,urlJoyProgress:w?.joyWaveProgress??0};r&&(z.translateX=-z.translateX,z.rotation=z.rotation?-z.rotation:0,z.slant=-z.slant,z.skewX!==void 0&&(z.skewX=-z.skewX));let wt=v==="joy"?ve(O.length):null,Le=wt&&(wt==="letter"||wt==="letter-bulge")?Math.min(1.5,Math.max(0,(t-E)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:j,emotion:v,emotionIntensity:L,originalEmotionIntensity:N,fontFamily:Ut,emphasis:S.emphasis||0,emphasisEffect:nt,strongEmphasis:M,animationParameters:z,joyAnimationMode:wt,joyProgress:Le}}),ct=o??F,gt=C?Math.max(C.end,ct):null,pt=C&&t>=C.start&&t<=(gt||C.end),bt=t>=E&&t<ct,yt=C?!!pt:bt;return{text:Dt(n),words:W,currentWordIndex:ft,emotion:_,emotionIntensity:b,fontFamily:Qt(_,i),startTime:C?.start||E,endTime:C?.end||F,isActive:yt}}function ln(n,t,e,i){let s=typeof e=="string"?e:"word",r=typeof e=="string"?i||{}:e||{};return s==="sentence"?rn(n,t,r):on(n,t,r)}var Y=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],ee={joy:Y[0],anger:Y[11],sadness:Y[5],fear:Y[4],disgust:Y[7],surprise:Y[6],social_positive:Y[1],social_negative:Y[7],lust:Y[11],calmness:Y[1],screaming:Y[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function un(n){return ee[n.toLowerCase()]||ee.none}function cn(n,{ttlMs:t=300*1e3}={}){let e=new Map,i=new Map,s=new Map;function r(l){let d=s.get(l);return!d||Date.now()-d>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(i.has(l))return i.get(l);let d=(async()=>{try{let c=await n(l),C=new Map;if(Array.isArray(c))for(let f of c)f.emotion&&f.url&&f.is_active&&C.set(f.emotion.toLowerCase(),f.url);return e.set(l,C),s.set(l,Date.now()),C}catch(c){return console.warn("[publishedAnimationResolver] Failed to fetch active animations:",c?.message),e.get(l)||new Map}finally{i.delete(l)}})();return i.set(l,d),d}async function o(l,d="default"){return l&&(await a(d)).get(l.toLowerCase())||null}function m(l,d="default"){if(!l)return null;let c=e.get(d);return(!c||r(d))&&a(d),c?.get(l.toLowerCase())||null}function u(){e.clear(),i.clear(),s.clear()}return{prefetch:a,get:o,getSync:m,invalidate:u}}var mn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Ie=["anger","fear","sadness","joy","disgust"];function dn(n){let t=n.toLowerCase();return Ie.includes(t)?1.5:1}function Cn(n){return n.map(([t,e])=>{let i=dn(t),s=e*i,r=Ie.includes(t.toLowerCase());return[t,e,s,i,r]})}function Ps(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([u,l])=>mn.includes(u.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let s=Cn(e).sort(([,,u],[,,l])=>l-u),[r,a,,o,m]=s[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:s,importanceFactor:o,isCore:m}}function Rs(n){if(!n)return{startTime:0,endTime:0,duration:.01};let t=n.start_time||0,e=n.end_time||0;return{startTime:t,endTime:e,duration:Math.max(.01,e-t)}}function Ds(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function hn(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),s=parseInt(n.slice(5,7),16);return`rgba(${e}, ${i}, ${s}, ${t})`}function fn(n,t="",e="",i=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${hn(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var gn={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function pn(n){return x.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function bn(n=1,t="",e=1,i=""){let{min:s,max:r}=x.wordSpacing,a=parseFloat(s),o=parseFloat(r),u=pn(t).wordSpacingMultiplier;if(n<=1)return`${(a*u).toFixed(3)}em`;let l=Math.max(...Object.values(gn)),d=Math.min(1,(n-1)/(l-1)),c=Math.pow(d,2),f=(a+(o-a)*c)*u;return i==="anger"||i==="screaming"?`${(f*.6).toFixed(3)}em`:`${f.toFixed(3)}em`}var yn=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function Sn(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0;return Math.abs(t)%1e3/1e3}function wn(n,t,e){if(!n)return 1;let i=(n.word||n.text||"").trim();if(!i)return 1;let s=i.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!s)return 1;if(yn.has(s)||s.length<=2)return 0;let r=Math.min(1,s.length/7),a=Sn(s);return .5*r+.5*a<.55?0:1}function $s({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:i,currentTime:s,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:m=1,fontSize:u=16}){let l=new Array(m).fill(0);return l}function Ys(n){return n.split("").map((t,e)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:e}))}function ke(n,{minDeviation:t=.02,maxBlur:e=1.5,multiplier:i=1.5}={}){let s=Math.abs((n??1)-1);return s<=t?0:Math.min(e,s*i)}function An(n=0,t=1,e=1){let i=1-.5*Math.min(1,Math.max(0,e??0)),s=ke(t)*i;return(n??0)+s}function Xt(n,t,e,i,s){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return i+a*(s-i)}function zs(n,t,e=null,i){if(!t)return i||400;let{min:s,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return i||a;let o,m;if(e?.mapping?.volume?(o=e.mapping.volume.min,m=e.mapping.volume.max):(o=s,m=r),i!==void 0){let u=(m-o)/4,l=Xt(n,0,1,-u,u);return Math.round(Math.max(s,Math.min(r,i+l)))}return Math.round(Xt(n,0,1,o,m))}function Gs(n,t,e){if(!t)return e||100;let{min:i,max:s,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(s-i)/4,o=Xt(1-n,0,1,-a,a);return Math.round(Math.max(i,Math.min(s,e+o)))}return Math.round(Xt(1-n,0,1,i,s))}var Be={},Fe={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function Pe(n){if(!n)return;let t=n.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||Be[t]||(Be[t]=!0,typeof document>"u"))return;let e=Fe[t],i=document.createElement("link");i.rel="stylesheet",i.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(i)}function vn(){Object.keys(Fe).forEach(n=>Pe(n))}var ne=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,e={}){let i=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,s=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};s&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(i,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let u=await a.clone().json();if(u.message)o=u.message;else if(u.error)o=u.error;else if(Array.isArray(u.detail)){let l=u.detail.map(d=>{let c=Array.isArray(d.loc)?d.loc.filter(C=>C!=="body").join("."):"";return c?`${c}: ${d.msg||"invalid"}`:d.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof u.detail=="string"&&(o=u.detail)}catch{try{let u=await a.clone().text();u&&(o=u)}catch{}}let m=new Error(o);throw m.status=a.status,m.response=a,m}return a}async login(t,e){let s=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!s.session_id||!s.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=s.auth_token,this.sessionId=s.session_id,s}async register(t,e,i,s){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:i,company:s.company,first_name:s.first_name,last_name:s.last_name})})).json()}async getSubtitleTrack(t,e,i){let s=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&s.append("lang",e.trim()),i&&typeof i=="string"&&i.trim()&&s.append("model",i.trim());let r=s.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,e=10){return(await this.request(`/vods?skip=${t}&limit=${e}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};export{x as ANIMATION_STYLING,Y as ANIMATION_URLS,Ve as AUTHORED_PLAYBACK_OPTIONS,ee as EMOTION_ANIMATION_URLS,ne as PhontClient,Pt as REFERENCE_GTS,Ce as REFERENCE_INTENSITY,p as RENDERING_CONTROL,Bt as SubtitleManager,vt as SubtitleStateManager,ht as calculateAnimationParameters,ln as calculateAnimationState,bn as calculateDynamicWordSpacing,fe as calculateEmphasisMultiplier,Gt as calculateGTSValues,is as calculateJoy,as as calculateJoyBulge,Ds as calculateNormalizedTime,zs as calculateWeightFromVolume,Gs as calculateWidthFromSpeechRate,Se as calculateWordEmphasisEffects,$s as calculateWordLetterSpacing,he as capEmotionIntensity,wn as computeProsodyWeight,cn as createPublishedAnimationResolver,zt as decodeAnimationUrl,Pe as ensureFont,Zt as findSubtitleForWord,fn as generateTextShadow,un as getAnimationUrlForEmotion,An as getCombinedBlurAmount,Qt as getFontFamilyCSS,ve as getJoyAnimationMode,os as getJoyFilter,rs as getJoyTransform,Wt as getMergedSubtitles,ke as getMotionBlurAmount,Ot as getSubtitleAnimations,Dt as getSubtitleText,Rs as getSubtitleTiming,Jt as getSubtitleWords,Ze as getWordEmphasis,st as hasMergedSubtitles,Ue as hockeyStickIntensity,ge as isInEmphasisRange,pe as isInStrongEmphasisRange,Zn as meetsEmotionThreshold,vn as preloadAnimationFonts,Rt as processEmotionsWithImportance,Lt as resolveEffectiveGts,Ct as sampleParameterCurve,Ps as selectEmotion,Qe as selectFontFamily,fs as shouldUseAngryFont,gs as shouldUseJoyFont,ps as shouldUseSadnessFont,Ys as splitTextIntoLetters,Ne as subtitleManager};
|
|
3
|
+
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let u=o.match(/#EXTINF:([0-9.]+)/);if(u){let d=parseFloat(u[1]);s.set(a,d),a++}}return s}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let i=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let s=await this.parseHLSMasterManifest(i),r=await this.parseAudioPlaylist(s);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let e=this._audioPlaylistCache.segmentDurations.get(t);return e!==void 0?e:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let e=await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(e)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let e;if(this.phontClient){if(!ut&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ut||this.phontClient.apiBaseUrl,s=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);e=await s.json()}else{if(!ut)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ut}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);e=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),e}catch{return null}}async fetchSubtitleData(t,e=null){if(this.stateManager.clearVodState(),!!t)try{let i,s;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");s=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let u=r.searchParams.get("lang")||e||void 0,d=r.searchParams.get("model")||void 0;try{i=await this.phontClient.getSubtitleTrack(s,u||null,d||null)}catch(l){let m=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),c=typeof l?.message=="string"?l.message:String(l||""),C=m===404||c.includes("404")||c.includes("Not Found"),f=m===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(C||f)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{s=t;let r=e&&e.trim()||void 0;try{i=await this.phontClient.getSubtitleTrack(s,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),u=typeof a?.message=="string"?a.message:String(a||""),d=o===404||u.includes("404")||u.includes("Not Found"),l=o===400||u.includes("400")||u.includes("Bad Request")||u.includes("HTTP error! status: 400");if(d||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${d?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);s=l?l[1]:t.split("/").pop().split("?")[0]}else{if(s=t,!ut&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ut||this.phontClient?.apiBaseUrl,m=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&m.append("lang",e.trim());let c=m.toString();r=c?`${l}/vod-subtitles/${s}?${c}`:`${l}/vod-subtitles/${s}`}let a={"Content-Type":"application/json"},o=zt(),u=Gt();o&&(a.Authorization=`Bearer ${o}`),u&&(a["X-Session-ID"]=u);let d=await fetch(r,{headers:a,cache:"no-store"});if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);i=await d.json()}return this.stateManager.updateVodVideoId(s),{data:i,videoId:s}}catch(i){throw this.stateManager.clearVodState(),i}}};var ce={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Mt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[i,s]of Object.entries(ce)){let r=i.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return s}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let i of t.important){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`important_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let i of t.all){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`all_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(i=>{if(i.animationFile==="Laughter"){let s=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-i.startTime)<=1);if(s){s.endTime=Math.max(s.endTime,i.endTime);return}}e.push(i)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,i=2,s=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&e<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let u=this.mapEventLabelToAnimation(o.event_label);if(u){let d=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-d<i?d+i:l;e>=d&&e<=c&&s.push({id:`vod_${o.event_label}_${d}`,eventLabel:o.event_label,animationFile:u,startTime:d,endTime:c,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:c})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let u of o){let d=this.mapEventLabelToAnimation(u.event_label);if(d){let l=u.start_time??u.onset??0,m=u.end_time??u.offset??0;if(e>=l&&e<=m){let C="all";this.stateManager.state.soundByteImportant?.includes(u)?C="important":this.stateManager.state.soundByteFiltered?.includes(u)&&(C="filtered"),s.push({id:`live_${u.event_label}_${l}`,eventLabel:u.event_label,animationFile:d,startTime:l,endTime:m,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};s.sort((o,u)=>{let d=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=u.eventLabel==="Laughter"?1:r[u.priority]||5;return d-l});let a=s.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=s=>Array.isArray(s)?s.length>0&&Array.isArray(s[0])?s.flat():s:[];return t?{all:e(this.stateManager.vodState.soundByteAll||[]),important:e(this.stateManager.vodState.soundByteImportant||[]),filtered:e(this.stateManager.vodState.soundByteFiltered||[])}:{all:e(this.stateManager.state.soundByteAll||[]),important:e(this.stateManager.state.soundByteImportant||[]),filtered:e(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,e=null){let i=[],s=[],r=e??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}return{all:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,e=30){let i=t-e,s=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=i),this.stateManager.state.soundbiteAnimations.length<s&&this.stateManager.notify()}};var _t=class{constructor(t,e,i){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=i}processVodData(t,e,i,s){let r=e.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(e?e.split("/").pop()?.split("?")[0]:void 0),u=a.flat().map(f=>({...f,sequence_number:o}));s&&s.length>0&&(u=this._mergeAnimationDataFromOriginal(u,s));let d=this._deduplicateSubtitles(u),{soundByteAll:l,soundByteImportant:m,soundByteFiltered:c}=this._processSoundbites(t.soundbite);if(l.length>0||m.length>0||c.length>0){let f={all:l,important:m,filtered:c},h=this.soundbiteProcessor.processSoundbiteAnimations(f);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...h]}let C=t.language||i||null;this.stateManager.vodState={subtitles:d,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:m,soundByteFiltered:c,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,e){let i=new Map;for(let s of e){let r=`${s.start_time}-${s.end_time}`;(!i.has(r)||s.animations||s.emotion)&&i.set(r,s)}return t.map(s=>{let r=`${s.start_time}-${s.end_time}`,a=i.get(r);if(!a)return s;let o=s.animations&&typeof s.animations=="object"&&Object.keys(s.animations).length>0,u=s.emotion&&s.emotion!=="none"&&s.emotion!=="neutral",d=typeof s.animation_url=="string"&&s.animation_url.length>0;if(o&&d)return s;let l={...s};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!u&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!d&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let m=new Map;for(let c of a.words)m.set(`${c.start}-${c.end}`,c);l.words=l.words.map(c=>{let C=m.get(`${c.start}-${c.end}`);if(!C||c.animations&&typeof c.animations=="object"&&Object.keys(c.animations).length>0)return c;let h={...c};return C.animations&&Object.keys(C.animations).length>0&&(h.animations=C.animations),!h.emotion&&C.emotion&&(h.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(h.emotion_intensity=C.emotion_intensity)),!h.animation_url&&C.animation_url&&(h.animation_url=C.animation_url),h})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let i of t){let s=`${i.start_time}-${i.end_time}`;(!e.has(s)||i.emotion||i.animations)&&e.set(s,i)}return Array.from(e.values())}_processSoundbites(t){let e=[],i=[],s=[];return t&&(t.all&&Array.isArray(t.all)&&(e=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(i=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(s=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:i,soundByteFiltered:s}}};var Et=class{constructor(t,e,i){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=i}async processLiveSegment(t,e,i){this.stateManager.state.processedSequences.add(e),this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let s=await i(e);this.stateManager.state.segmentDurations.set(e,s);let r=this.liveTimeGenerator.getCumulativeDuration(e),a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:u,processedSoundbitesFiltered:d}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,u,d);let l={all:o,important:u,filtered:d},m=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(m),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(c=>c.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,i){return!t||!Array.isArray(t)?[]:t.map(s=>({...s,sequence_number:e,start_time:s.start_time+i,end_time:s.end_time+i,words:s.words?s.words.map(r=>({...r,start:r.start+i,end:r.end+i})):void 0}))}_processSoundbites(t,e){let i=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),s=(t?.important||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e}));return{processedSoundbitesAll:i,processedSoundbitesImportant:s,processedSoundbitesFiltered:r}}_updateState(t,e,i,s){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...e],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...i],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...s]}};var It=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let e=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=e,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(e-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let e=t.src,i=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),i&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let i=this.stateManager.state.initialSequenceOffset;i<t;i++){let s=this.stateManager.state.segmentDurations.get(i)||10;e+=s}return e}};var kt=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,e){if(!t)return null;let s=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(e>=a.start)r.push(a.word);else break;s=r.join(" ")}return{activeSubtitle:t,displayText:s}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return null;let i=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!i&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let s=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(s){let r=this._processSubtitleText(s,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,u=e.currentSubtitle!==o||e.currentSubtitleData!==a;return u&&(e.currentSubtitle=o,e.currentSubtitleData=a,e.currentSequence=e.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=e.currentSequence??null),(i||u)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return e.currentSubtitle!==""&&(e.currentSubtitle="",e.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let e=t.subtitles.find(i=>t.currentTime>=i.start_time&&t.currentTime<=i.end_time);if(e){t.currentSequence=e.sequence_number??null;let i=this._processSubtitleText(e,t.currentTime);if(!i)return null;let{activeSubtitle:s,displayText:r}=i;return(t.currentSubtitle!==r||t.currentSubtitleData!==s)&&(t.currentSubtitle=r,t.currentSubtitleData=s,this.stateManager.notify()),this._lastSubtitleData=s,this._lastSubtitleTime=t.currentTime,s}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var de=new Set;function me(){if(typeof window>"u")return!1;let n=window.location.search;if(n.includes("debug=subtitles")||n.includes("stage_debug=subtitles"))return!0;try{return localStorage.getItem("phont_debug_subtitles")==="1"}catch{return!1}}function Ce(n){if(!n||typeof n!="object")return null;let t=n.subtitles;return Array.isArray(t)?t.flatMap(e=>Array.isArray(e)?e:[e]).length:null}function Ye(){if(window.__phontSubtitleDebug)return window.__phontSubtitleDebug;let n={enabled:!0,last:null,dumpLast(){let t=n.last;if(!t)return console.warn("[vod-subtitles] No fetch recorded yet."),null;let e=Ce(t.raw),i=e!=null?`${e} segments`:"see payload";return console.log(`%c[vod-subtitles] ${i}`,"font-weight:bold;font-size:12px",t.raw),t},async copyLast(){let t=n.last;if(!t)throw new Error("No subtitle fetch recorded yet.");let e=JSON.stringify(t.raw,null,2);try{await navigator.clipboard.writeText(e),console.info("[vod-subtitles] Copied JSON to clipboard.")}catch{console.log(e)}return e}};return window.__phontSubtitleDebug=n,n}function Ht(n,t){if(!me()||typeof window>"u")return;let e=`${t?.vodId??""}|${t?.url??""}`;if(de.has(e))return;de.add(e);let i={at:new Date().toISOString(),vodId:t?.vodId??null,url:t?.url,raw:n},s=Ye();s.last=i;let r=Ce(n),a=r!=null?`${r} segments`:"see payload";console.log(`%c[vod-subtitles] Core GET /vod-subtitles \u2014 full response (${a})`,"font-weight:bold;font-size:12px",t?.vodId||t?.url?{vodId:t.vodId,url:t.url}:void 0,n)}var $n=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function he(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var Bt=class{constructor(){this.stateManager=new vt,this.cache=new xt,this.fetcher=new Tt(this.stateManager),this.soundbiteProcessor=new Mt(this.stateManager),this.vodDataProcessor=new _t(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new It(this.stateManager),this.liveDataProcessor=new Et(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new kt(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,e="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?e:"none",this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}async fetchSubtitles(t){try{let e=await this.fetcher.fetchSubtitles(t);return e?await this.liveDataProcessor.processLiveSegment(e,t,i=>this.getAudioSegmentDuration(i)):null}catch{return null}}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,i,s){this.vodDataProcessor.processVodData(t,e,i,s)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,e=30){let i=t-e,s=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=i),this.state.subtitles.length<s&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,e=null){return this.soundbiteProcessor.getActiveSoundbites(t,e)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,e=30){this.soundbiteProcessor.clearOldAnimations(t,e)}getCurrentSpeaker(t=!1,e=null){if(!this.state.isSpeaker)return null;let i=null;if(t?i=this.vodState.currentSubtitleData:i=this.state.currentSubtitleData,!i||!i.words)return null;let s=i?.speaker;return s||null}async fetchSubtitleData(t,e=null,i=null){if(!e&&t){let s=new URLSearchParams(t.split("?")[1]||"");e=s.get("lang")||null,i||(i=s.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let s=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=s,o=r?.language||e||null;Ht(r,{vodId:a,url:t});let u=he(o??e),d=i?`${u}_${i}`:u,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(d,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let c;if(!!e&&String(e).trim()!==""){let f=this.cache._subtitleCache.get("original");f?.data?.subtitles&&(c=Array.isArray(f.data.subtitles)?f.data.subtitles.flat():[])}this._processVodData(r,t,o,c)}catch(s){let r=s?.status||s?.response?.status,a=r===404||typeof s?.message=="string"&&s.message.includes("404")||typeof s?.message=="string"&&s.message.includes("Not Found"),o=r===400||typeof s?.message=="string"&&s.message.includes("400")||typeof s?.message=="string"&&s.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:s?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",s),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,e,i=null){if(!e)return;let s=he(t);if(this.cache._loadingLanguages.has(s))return;let r=i?`${s}_${i}`:s,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(s);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let u=new URLSearchParams;t&&u.append("lang",t),i&&u.append("model",i);let d=u.toString(),l=`${o}/vod-subtitles/${e}${d?`?${d}`:""}`,m=!1;try{await this.fetchSubtitleData(l,t,i),m=!0}catch(c){if(c?.status===404||typeof c?.message=="string"&&c.message.includes("404"))if(t!==null)m=!0;else throw c;else throw c}if(!m)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,i)}finally{this.cache._loadingLanguages.delete(s)}}_loadCachedSubtitles(t,e,i){let s=t?.language||i||null,r;if(!!i&&String(i).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,e,s,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},Ve=new Bt;function qe(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[i,s]=e.split(","),r=t||typeof s=="string"&&(s.startsWith("#")||s.startsWith("%23")),a;return r?a=s.replace(/%23/g,"#"):a=parseFloat(s),{time:parseFloat(i),value:a}})}catch(e){return console.error("Error decoding points:",e),[]}}function ze(n){if(!n)return"";if(n.includes("://"))try{let t=new URL(n);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=n.indexOf("?");return t!==-1?n.substring(t+1):n}return n.startsWith("?")?n.slice(1):n}function Kt(n){try{let t=ze(n),e=new URLSearchParams(t),i={parameterStates:{}};if(e.has("name")&&(i.name=e.get("name")||void 0),e.has("user")&&(i.userName=e.get("user")||void 0),e.has("duration")&&(i.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(i.animationMode=e.get("mode")||void 0),e.has("text")&&(i.text=e.get("text")||void 0),e.get("format")==="normalized"&&(i.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?i.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:i.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{i.backgroundStyle=JSON.parse(e.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of e.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),u=qe(a,o);if(u.length>0){let d=o?"#000000":0;i.parameterStates[r]={points:u,currentValue:u[0]?.value||d}}}return i}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function Ge(n){if(n===0)return 0;let t=4,e;if(n<=.7){let i=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*i}else{let i=(n-.7)/.3,s=Math.log(1+.5*(Math.exp(t)-1))/t;e=s+i*(1-s)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function Ft(n){if(typeof n!="string")return{r:0,g:0,b:0};let t=n.replace("#","").padStart(6,"0"),e=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function ge(n,t,e){let i=s=>{let r=Math.round(Math.max(0,Math.min(255,s))).toString(16);return r.length===1?"0"+r:r};return"#"+i(n)+i(t)+i(e)}function fe(n,t,e){let i=Ft(n),s=Ft(t),r=Math.max(0,Math.min(1,e)),a=i.r+(s.r-i.r)*r,o=i.g+(s.g-i.g)*r,u=i.b+(s.b-i.b)*r;return ge(a,o,u)}function He(n,t,e){if(e===0)return n;let i=Ft(n),s=Ft(t),r=i.r+(s.r-i.r)*e,a=i.g+(s.g-i.g)*e,o=i.b+(s.b-i.b)*e;return ge(r,a,o)}function Ct(n,t,e,i=!1,s=null){if(!n||n.length===0)return null;let r=i?t:t*e,a=null,o=null;for(let u=0;u<n.length;u++){let d=n[u],l=d.time!==void 0?d.time:Array.isArray(d)?d[0]:0;if(l!==void 0&&l<=r&&(a=d),l!==void 0&&l>=r&&!o){o=d;break}}if(!a&&n[0])return(n[0].value!==void 0?n[0].value:Array.isArray(n[0])?n[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let u=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,d=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,m=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(u===d||l===null||m===null)return l??null;let c=(r-u)/(d-u),C=s==="color"||s==="shadowColor"||s==="outlineColor"||s==="outline2Color"||s==="outline3Color"||s==="outlineShadowColor"||s==="glowColor";if(C&&(typeof l=="string"||typeof m=="string"))return fe(typeof l=="string"?l:"#000000",typeof m=="string"?m:"#000000",c);if(!C&&(typeof l=="string"||typeof m=="string")){let f=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),h=typeof m=="string"&&(m.startsWith("#")||/^[0-9a-f]{6}$/i.test(m));if(f&&h){let g=l.startsWith("#")?l:`#${l}`,_=m.startsWith("#")?m:`#${m}`;return fe(g,_,c)}return m??null}return l+(m-l)*c}return null}var pe=.7,Pt=.7,Ke={rawMode:!0};function ht(n,t,e,i,s=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*i/(pe*Pt),o=n.duration||2,d=n.format==="normalized"?e:e*o,l=!0,m=n.parameterStates||{},c=(A,B,$=!0,q=null)=>{let mt=q??a,at=Ct(m[A]?.points,d,o,l);return at==null?B:$?mt===0?B:B+(at-B)*mt:at},C=c("scale",1),f=c("skew",0),h=c("stretch",1),g=c("translateX",0),_=c("translateY",0),b=c("weight",500),E=c("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",R=n.text||"Hello",D=(A,B)=>{let $=Ct(m[A]?.points,d,o,l,A);if($==null)return B;let q=typeof $=="string"?$.startsWith("#")?$:`#${$}`:`#${Math.round($).toString(16).padStart(6,"0")}`;return a===0?B:He(B,q,a)},k=D("color","#ffffff"),P=c("opacity",1),I=c("shadowX",0),T=c("shadowY",0),H=c("shadowBlur",4),tt=c("shadowOpacity",.5),O=D("shadowColor","#000000"),ft=c("outlineWidth",0),$t=D("outlineColor","#000000"),W=A=>m[A]?.points?.length>0,ct=W("stretchX")?c("stretchX",1):void 0,gt=W("outline2Width")?c("outline2Width",0):void 0,pt=W("outline2Color")?D("outline2Color","#000000"):void 0,bt=W("outline3Width")?c("outline3Width",0):void 0,yt=W("outline3Color")?D("outline3Color","#000000"):void 0,S=W("outlineShadowWidth")?c("outlineShadowWidth",0):void 0,X=W("outlineShadowColor")?D("outlineShadowColor","#000000"):void 0,j=W("outlineShadowBlur")?c("outlineShadowBlur",0):void 0,v=W("glowIntensity")?c("glowIntensity",0):void 0,L=W("glowColor")?D("glowColor","#ffffff"):void 0,N=W("snakeWave")?c("snakeWave",0):void 0,et=W("karaoke")?c("karaoke",0):void 0,U=1-.5*Math.min(1,Math.max(0,i)),V=c("blur",0,!0,r?1:a*U),dt=Ct(m.thinStroke?.points,d,o,l),K=Ct(m.ascenderHeight?.points,d,o,l),it={};dt!=null&&typeof dt=="number"&&(it.YOPQ=dt),K!=null&&typeof K=="number"&&(it.YTAS=K),b!=null&&(it.wght=b),E!=null&&(it.wdth=E);let J=[];if(I!==0||T!==0||H!==4||tt!==.5){let A=typeof O=="string"?O:"#000000",B=parseInt(A.slice(1,3),16),$=parseInt(A.slice(3,5),16),q=parseInt(A.slice(5,7),16);J.push(`${I}px ${T}px ${H}px rgba(${B}, ${$}, ${q}, ${tt})`)}else if(O&&typeof O=="string"&&O!=="#000000"){let A=O.startsWith("#")?O:`#${O}`,B=parseInt(A.slice(1,3),16)||0,$=parseInt(A.slice(3,5),16)||0,q=parseInt(A.slice(5,7),16)||0;J.push(`3px 2px 4px rgba(${B}, ${$}, ${q}, 0.5)`)}if(v!=null&&v>0){let A=typeof L=="string"?L:"#ffffff";J.push(`0 0 ${v}px ${A}`),J.push(`0 0 ${v*2}px ${A}`),J.push(`0 0 ${v*4}px ${A}`)}let Ut=J.length>0?J.join(", "):"",lt=0;if(m.joy?.points&&m.joy.points.length>0)for(let A of m.joy.points){let B=Array.isArray(A)?A[1]:A.y??A.value??0;typeof B=="number"&&B>lt&&(lt=B)}let St=c("joy",0,!1),Yt=r?St:Math.min(1,lt*a),Z=c("fear",0),Q=c("standardEmphasis",0,!1),nt=c("strongEmphasis",0,!1),M={rawIntensity:t,scaleFactor:a,scale:C,slant:f,stretchY:h,translateX:g,translateY:_,weight:b,width:E,fontFamily:y,textColor:k,opacity:P,textShadow:Ut,blur:V,outlineWidth:ft,outlineColor:$t,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:it,text:R,joy:Yt,fear:Z,standardEmphasis:Q,strongEmphasis:nt,joyWaveProgress:d/o*1.5};return ct!==void 0&&(M.stretchX=ct),gt!==void 0&&(M.outline2Width=gt),pt!==void 0&&(M.outline2Color=pt),bt!==void 0&&(M.outline3Width=bt),yt!==void 0&&(M.outline3Color=yt),S!==void 0&&(M.outlineShadowWidth=S),X!==void 0&&(M.outlineShadowColor=X),j!==void 0&&(M.outlineShadowBlur=j),v!==void 0&&(M.glowIntensity=v),L!==void 0&&(M.glowColor=L),N!==void 0&&(M.snakeWave=N),et!==void 0&&(M.karaoke=et),M}var x={fontSize:54,opacity:1,weight:400,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:4,color:"rgba(0, 0, 0, 0.4)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:1.25,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function Lt(n,t,e){let i=Math.max(0,Math.min(1,n)),s=e??t;if(typeof s=="number"&&Number.isFinite(s)){let r=Math.max(0,Math.min(1,s));return Math.min(1,Math.max(0,r*(i/Pt)))}return i}function Jt(n){let t=.2+.8*n,e=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*n;return{gts:n,maxExpression:t,threshold:e,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function as(n,t){return n>=t}function be(n,t){return t<=.2?0:n*t}function ye(n){let{minThreshold:t,maxThreshold:e}=p.emphasis;return n<t||n>=e?0:(n-t)/(e-t)}function Se(n){return n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold}function we(n){return n>=p.strongEmphasis.minThreshold}function Je(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,u=n*n,d=u*n;return o*0+3*a*n*.42+3*r*u*.58+d*1}var Ae=new WeakMap,Zt={joy:1,social_positive:1,anger:-1,screaming:-1};function Qt(n,t,e,i){let s=typeof e=="string"?e.toLowerCase():"";if(s==="joy")return Ze(n,t,i);let r=Math.sign(t);return r!==0?r:s in Zt?Zt[s]:i}function Ze(n,t,e){let i=Math.sign(t);if(n){let s=Ae.get(n);if(s!==void 0)return s;let r=i!==0?i:ve(e);return Ae.set(n,r),r}return i!==0?i:ve(e)}function ve(n){return n!==0?n:Zt.joy}function Qe(n,t,e=1,i=0,s=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:u,scaleDownFrames:d,fps:l}=p.emphasis;if(!n||!Se(a))return null;let m=t-n.start,c=s?n.start+s:n.end,C=c-n.start;if(m<0||t>=c)return null;let f=Math.max(0,Math.min(1,m/C)),h=0;f<.5?h=f*2:h=2-f*2,h=h*h*(3-2*h);let g=ye(a),_=.55,b=3*_,F=Qt(n,i,r,0)*b*h*e*g,y=140*h*e*g,R=1+o*_*h*e*g,D=f<1;return{scaleMultiplier:R,slantAdditive:F,weightBoost:y,scaleProgress:h,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:m,scaleActive:D}}function tn(n,t,e={},i=1,s=null,r=0,a=""){let o=a==="anger"||a==="screaming",u=p.strongEmphasis,d=.7,l=s?n.start+s:n.end;if(t<n.start)return null;let m=n.emphasis||0;if(!we(m))return null;let c=u.fadeOutTailDuration,C=l+c;if(t>=C)return null;let f=l-n.start,h=Math.max(0,Math.min(1,(t-n.start)/f)),g=1,_=t>=l;if(_){let T=(t-l)/c;g=1-Je(T),h=1}let b=0;h<.5?b=h*2:b=2-h*2;let E=b*b*(3-2*b),F=(m-u.minThreshold)/(1-u.minThreshold),y=E*F*i,R=y;y<.1&&(y=0);let D=Qt(n,r,a,-1),k,P;if(o)k={scale:1+y*(u.maxScale-1)*d,rotation:y*u.maxRotation*d,translateY:-y*u.maxTranslateY*d,translateX:y*u.maxTranslateX*d,skewX:D*y*u.maxSkew*d,stretchY:1},P={brightness:1+y*u.maxBrightness*d,contrast:1+y*u.maxContrast*d,shadowBlur:y*u.maxShadowBlur*d,shadowOpacity:y*u.shadowOpacity*d,zIndex:Math.round(y*u.maxZIndex*d)};else{let tt=E*20*Math.max(.2,F*i)*d,O=Qt(n,r,a,1);k={scale:1+y*.15*d,rotation:0,translateY:0,translateX:0,skewX:O*tt,stretchY:1},P={brightness:1+y*.2*d,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(k.scale=1+(k.scale-1)*g,k.rotation=k.rotation*g,k.translateX=k.translateX*g,k.translateY=k.translateY*g,k.skewX=k.skewX*g,P.brightness=1+(P.brightness-1)*g,P.contrast=1+(P.contrast-1)*g,P.shadowBlur=P.shadowBlur*g,P.shadowOpacity=P.shadowOpacity*g,P.zIndex=Math.round(P.zIndex*g),y=y*g);let I=280*y*i;return{emphasis:y,rawEmphasis:R,...k,...P,weightBoost:I,shadowOffsetX:y*u.shadowOffsetX,shadowOffsetY:y*u.shadowOffsetY,gtsMultiplier:i,emphasisMultiplier:F,fadeFactor:g,isInTail:_}}function xe({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:i,wordBaseSlant:s,isActive:r,wordEmotion:a=""}){let o=r?Qe(n,t,e,s,i,a):null,u=tn(n,t,{},e,i,s,a);return{emphasisEffect:o,strongEmphasisData:u}}function Te(n){let t=2*Math.PI/3;return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*t)+1}function Me(n){return 1-(1-n)*(1-n)}function _e(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function ds(n,t,e,i=1){let s=p.joy.letterWave,r=e<=6,a,o,u;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),u=a+o):(a=s.innerWidthRatio,o=s.outerWidthRatio,u=a+o);let d=t/Math.max(1,e-1),l=n;r&&e<=3?l=Math.min(1.2,n*1.25):r&&(l=Math.min(1.1,n*1.1));let m=l*(1+u),c=d-m,C=a+o,f=o*.3;if(c>f||c<-C)return null;let h=0;if(c>0&&c<=f)h=(1-c/f)*.15;else if(c<=0&&c>=-a){let y=Math.abs(c)/Math.max(a,.01);h=Te(y)}else if(c<-a){let R=(Math.abs(c)-a)/Math.max(o,.01);h=Me(1-R)}if(h<=.01)return null;let g=h*i,b=1-t%2*.15,E={scale:1+g*(s.maxScale-1)*b,rotation:g*s.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*s.maxTranslateY*b,skewX:-g*s.maxSkew*.5,stretchY:1},F={brightness:1+g*s.maxBrightness,contrast:1+g*s.maxContrast,shadowBlur:g*s.maxShadowBlur,shadowOpacity:g*s.shadowOpacity,zIndex:Math.round(g*s.maxZIndex)};return{pressure:g,...E,...F,shadowOffsetX:g*3,shadowOffsetY:g*3}}function ms(n,t,e,i=1){let s=p.joy.letterBulge,r=s.innerWidthRatio,a=s.outerWidthRatio,o=r+a,u=e>1?t/Math.max(1,e-1):0,d=n*(1+o),l=u-d,m=a*.35,c=o;if(l>m||l<-c)return null;let C=0;if(l>0&&l<=m)C=(1-l/Math.max(m,1e-4))*.18;else if(l<=0&&l>=-r){let R=Math.abs(l)/Math.max(r,1e-4);C=Te(R)}else if(l<-r){let D=(Math.abs(l)-r)/Math.max(a,1e-4);C=Me(1-D)}if(C<=.01)return null;let f=C*i,h=Math.min(1,f*.85),g=1,_=t%3===0?1:-1,b=Math.max(1-s.maxCompressionX,1-h*s.maxCompressionX),E=1+h*s.maxStretchY,F={scale:1+h*(s.maxScale-1),stretchY:E,stretchX:b,rotation:h*s.maxRotation*g,translateX:h*s.maxTranslateX*_,translateY:-h*s.maxTranslateY,skewX:h*s.maxSkew*g},y={brightness:1+h*s.maxBrightness,contrast:1+h*s.maxContrast,shadowBlur:h*s.maxShadowBlur,shadowOpacity:h*s.shadowOpacity,zIndex:Math.round(h*s.maxZIndex)};return{pressure:h,bulgeIntensity:h,...F,...y,shadowOffsetX:h*1.8,shadowOffsetY:h*3}}function Cs(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,i=n.rotation||0,s=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${i}deg) skewX(${a}deg) translate(${s}px, ${r}px)`}function hs(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,i=n.shadowBlur||0,s=n.shadowOpacity||0,r=n.shadowOffsetX||0,a=n.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),e!==1&&o.push(`contrast(${e})`),i>0&&s>0&&o.push(`drop-shadow(${r}px ${a}px ${i}px rgba(255, 255, 255, ${s}))`),o.join(" ")}var en=["anger","fear","sadness","joy"];function nn(n){return en.includes(n.toLowerCase())}function Dt(n){return n.map(([t,e])=>{let i=nn(t),s=i?1.5:1,r=e*s;return[t,e,r,s,i]})}function sn(n){if(!n)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=n.confidence_word||0,e=n.emphasis||0;return{confidence:t,emphasis:e,hasEmphasis:e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold,hasStrongEmphasis:e>=p.strongEmphasis.minThreshold}}function Rt(n){return n&&(n.subtitle||n.text)||""}function te(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function Ot(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function st(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function Wt(n){return st(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function ee(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function an(n,t,e=null,i=null){if((i?.name==="children"||i?.name==="hello-kitty")&&e&&i.fonts?.[e])return i.fonts[e];let s=p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold;return s?x.angryFont:r?x.joyFont:a?x.sadnessFont:x.defaultFont}function ne(n,t,e=null,i=null){let s=an(n,t,e,i),r="sans-serif";return s==="Cormorant"&&(r="serif"),`"${s}", ${r}`}function As(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function vs(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function xs(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var ke='"Roboto Flex", "Roboto", sans-serif',Ee=new Map,rn={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function jt(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?rn[t]||t:""}function se(n){if(typeof n!="string"||n.length===0)return null;let t=Ee.get(n);if(t)return t;try{let e=Kt(n);return Ee.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function on(n){if(!n||n.length===0)return null;let t=n.filter(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(e=>e.start_time)),end:Math.max(...t.map(e=>e.end_time))}}function ln(n,t){return n.find(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number"&&t>=e.start_time&&t<=e.end_time)||null}function Nt(n){return n&&typeof n.animation_url=="string"&&n.animation_url.length>0?n.animation_url:null}function Be(n,t){if(!n)return{emotion:"none",intensity:0};let e=Ot(n),i=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(i.length>0){let a=Dt(i).sort((o,u)=>u[2]-o[2])[0];return{emotion:jt(a[0])||"none",intensity:a[1]}}let s=jt(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!s||s==="none"||r<=0?Nt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:s,intensity:r}}function un(n){let t={...n};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function Ie(n,t,e,i){let{minWordDisplayTime:s,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,u=Math.max(0,n.end-n.start),d=Math.max(u,s);if(!i)return n.start+d;let l=typeof t.end_time=="number"?t.end_time:n.end,m=l-n.end,c=!1;if(e!=null&&e>l?(m=e-n.end,c=m>=o):e==null?(c=!0,m=1/0):c=m>=a,c){let f=m===1/0?s+r:n.end+m-n.start-.1,g=u<s?f:Math.min(s+r,f);d=Math.max(d,g)}return n.start+d}function cn(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let i=n.findIndex(a=>t>=a.start&&t<a.animationEnd),s=n.reduce((a,o,u)=>t>=o.animationEnd?u:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||s!==-1&&o<=s?1:e?0:.3),currentWordIndex:i}}function Fe(n){if(!n)return x.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),i=e.toLowerCase();return i.includes("bricolage")?"Bricolage Grotesque":i.includes("rakkas")?x.angryFont:i.includes("parkinsans")?x.joyFont:i.includes("cormorant")?x.sadnessFont:i.includes("roboto")?x.defaultFont:e}function dn(n,t,e){let i={text:"",fontSize:x.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:ke,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return i;let s=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=s<=.2,u=Jt((s-.2)/.8).gts,d=n.start_time,l=n.end_time,m=Math.max(.01,l-d),c=Math.max(0,Math.min(1,(t-d)/m)),C=Be(n,r),f=o?"none":C.emotion,h=o?0:Math.max(0,C.intensity),g=se(Nt(n)),_=Lt(u,n.gts,void 0),b=g?ht(g,h,c,_,m):null,E=b?.fontFamily?`"${Fe(b.fontFamily)}", sans-serif`:ne(f,s),F={fontSize:x.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??x.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?un(F):F,text:Rt(n),emotion:f,emotionIntensity:h,fontFamily:E,startTime:d,endTime:l,duration:m,isActive:t>=d&&t<l}}function mn(n,t,e){let i=e.maxExpression??1,s=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,u=e.transparentUntilSpoken??!1,d=i<=.2,l=Jt((i-.2)/.8).gts,m={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:ke,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return m;let c=st(n)?Wt(n):[n],C=on(c),f=ln(c,t);if(!f&&o!=null&&t>n.end_time&&t<=o&&(f=c[c.length-1]||null),!f&&C&&t>=C.start&&t<=C.end&&(f=[...c].filter(S=>S&&t>=S.start_time).sort((S,X)=>X.start_time-S.start_time)[0]||null),f==null)return m;let h=f,g=Be(h,s),_=d?"none":g.emotion,b=d?0:Math.max(0,g.intensity),E=h.start_time,F=h.end_time,y=Math.max(.01,F-E),R=Math.max(0,Math.min(1,(t-E)/y)),D=st(n)?null:se(Nt(h)),k=h.gts??n.gts,P=Lt(l,k,void 0),I=D?ht(D,b,R,P,y):null,T={fontSize:x.fontSize,scale:I?.scale??(_==="none"?1:1+b*.16),opacity:I?.opacity??1,slant:I?.slant??0,weight:I?.weight??400,width:I?.width??100,textColor:I?.textColor??x.textColor,translateX:I?.translateX??0,translateY:I?.translateY??0,stretchY:I?.stretchY??1,textShadow:I?.textShadow??"",blur:I?.blur??0,outlineWidth:I?.outlineWidth??0,outlineColor:I?.outlineColor??"#000000",fontVariationAxes:I?.fontVariationAxes??{}},H=te(n).flatMap(S=>{let X=String(S?.word??""),j=X.trim();if(!j.includes(" "))return[S];let v=j.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,v.length),et=X.startsWith(" ");return v.map((U,V)=>({...S,word:(V===0&&et?" ":"")+U,start:(S.start??0)+V*N,end:(S.start??0)+(V+1)*N}))}),tt=null;if(st(n)&&C?.end){let S=H[H.length-1],X=Ie(S,n,a,!0),j=o??X,{minWordDisplayTime:v,breathingRoomDuration:L}=p.timing,N=v+L,U=(H.length>0?Math.min(...H.map(V=>V.start)):C.start)+N;tt=Math.max(C.end,j,U)}let O=H.map((S,X)=>{let j=X===H.length-1,v=Ie(S,n,a,j);return{...S,animationEnd:st(n)&&tt?Math.max(v,tt):v}}),{currentWordIndex:ft,opacities:$t}=cn(O,t,u),W=O.map((S,X)=>{let j=t>=S.start&&t<S.end,v=_,L=b,N=b,et=st(n)?Wt(n):null,U=et?ee(et,S):h;if(U){let rt=Ot(U),At=Object.entries(rt).filter(([,G])=>typeof G=="number"&&G>s),Vt=Object.entries(rt).filter(([,G])=>typeof G=="number");if(Vt.length>0)N=[...Vt].sort((ot,qt)=>qt[1]-ot[1])[0][1];else{let G=jt(U.emotion),ot=typeof U.emotion_intensity=="number"?U.emotion_intensity:0;G&&ot>0&&(v=G,N=ot,L=ot)}if(At.length>0){let G=Dt(At).sort((ot,qt)=>qt[2]-ot[2]);v=jt(G[0][0])||"none",L=G[0][1]}else Vt.length>0&&(v="none",L=0)}d?(v="none",L=0):L===N&&L!==0&&(L=be(L,i));let V=Math.max(.01,(S.end??0)-(S.start??0)),dt=Math.max(0,Math.min(1,(t-S.start)/V)),K=se(Nt(U)),it=N>0?N:K?Math.max(1,b||0):0,J=Lt(l,k,S.gts),w=K?ht(K,it,dt,J,V):null,Ut=Fe(K?.fontData?.style?.fontFamily),lt=(K?.parameterStates?.standardEmphasis?.points?.length??0)>0,St=(K?.parameterStates?.strongEmphasis?.points?.length??0)>0,Yt=lt||St,Z=j?w?.standardEmphasis??0:0,Q=j?w?.strongEmphasis??0:0,nt=null,M=null;if(Yt){let rt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:0;if(lt&&(nt={scaleMultiplier:1+.272*Z*i,slantAdditive:rt*4.25*Z*i,weightBoost:250*Z*i,scaleProgress:Z,gtsMultiplier:i,emphasis:Z,emphasisMultiplier:Z,elapsed:0,scaleActive:Z>0}),St&&!r){let At=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:1;M={emphasis:Q,rawEmphasis:Q,scale:1+Q*.38,skewX:At*Q*30*i,weightBoost:400*Q*i,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+Q*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:i,emphasisMultiplier:Q,fadeFactor:1,isInTail:!1}}}else{let rt=xe({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:i,emotionAnimationDuration:V,wordBaseSlant:w?.slant||0,isActive:j,wordEmotion:v});nt=rt.emphasisEffect,M=r?null:rt.strongEmphasisData}let A=$t[X]??1,B=(w?.opacity??T.opacity??1)*A,q=(w?.scale??T.scale??1)*(nt?.scaleMultiplier||1),mt=(w?.slant??T.slant??0)+(nt?.slantAdditive||0),at=q,re=nt?.weightBoost||0;M&&(mt+=M.skewX||0,re+=M.weightBoost||0,at=q*(M.scale||1));let z={...T,fontSize:x.fontSize,scale:at,slant:mt,stretchY:w?.stretchY??T.stretchY??1,weight:(w?.weight??T.weight??400)+re,width:w?.width??T.width??100,textColor:w?.textColor??T.textColor??x.textColor,opacity:B,translateX:w?.translateX??T.translateX??0,translateY:w?.translateY??T.translateY??0,textShadow:w?.textShadow??T.textShadow??"",blur:w?.blur??T.blur??0,outlineWidth:w?.outlineWidth??T.outlineWidth??0,outlineColor:w?.outlineColor??T.outlineColor??"#000000",letterShake:w?.fear??0,fontVariationAxes:{...T.fontVariationAxes,...w?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:w?.joy??0,urlFear:w?.fear??0,urlJoyProgress:w?.joyWaveProgress??0};r&&(z.translateX=-z.translateX,z.rotation=z.rotation?-z.rotation:0,z.slant=-z.slant,z.skewX!==void 0&&(z.skewX=-z.skewX));let wt=v==="joy"?_e(O.length):null,We=wt&&(wt==="letter"||wt==="letter-bulge")?Math.min(1.5,Math.max(0,(t-E)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:j,emotion:v,emotionIntensity:L,originalEmotionIntensity:N,fontFamily:Ut,emphasis:S.emphasis||0,emphasisEffect:nt,strongEmphasis:M,animationParameters:z,joyAnimationMode:wt,joyProgress:We}}),ct=o??F,gt=C?Math.max(C.end,ct):null,pt=C&&t>=C.start&&t<=(gt||C.end),bt=t>=E&&t<ct,yt=C?!!pt:bt;return{text:Rt(n),words:W,currentWordIndex:ft,emotion:_,emotionIntensity:b,fontFamily:ne(_,i),startTime:C?.start||E,endTime:C?.end||F,isActive:yt}}function Cn(n,t,e,i){let s=typeof e=="string"?e:"word",r=typeof e=="string"?i||{}:e||{};return s==="sentence"?dn(n,t,r):mn(n,t,r)}var Y=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],ie={joy:Y[0],anger:Y[11],sadness:Y[5],fear:Y[4],disgust:Y[7],surprise:Y[6],social_positive:Y[1],social_negative:Y[7],lust:Y[11],calmness:Y[1],screaming:Y[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function hn(n){return ie[n.toLowerCase()]||ie.none}function fn(n,{ttlMs:t=300*1e3}={}){let e=new Map,i=new Map,s=new Map;function r(l){let m=s.get(l);return!m||Date.now()-m>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(i.has(l))return i.get(l);let m=(async()=>{try{let c=await n(l),C=new Map;if(Array.isArray(c))for(let f of c)f.emotion&&f.url&&f.is_active&&C.set(f.emotion.toLowerCase(),f.url);return e.set(l,C),s.set(l,Date.now()),C}catch(c){console.warn("[publishedAnimationResolver] Failed to fetch active animations:",c?.message);let C=e.get(l)||new Map;return e.set(l,C),s.set(l,Date.now()),C}finally{i.delete(l)}})();return i.set(l,m),m}async function o(l,m="default"){return l&&(await a(m)).get(l.toLowerCase())||null}function u(l,m="default"){if(!l)return null;let c=e.get(m);return(!e.has(m)||r(m))&&(i.has(m)||a(m)),c?.get(l.toLowerCase())||null}function d(){e.clear(),i.clear(),s.clear()}return{prefetch:a,get:o,getSync:u,invalidate:d}}var gn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Pe=["anger","fear","sadness","joy","disgust"];function pn(n){let t=n.toLowerCase();return Pe.includes(t)?1.5:1}function bn(n){return n.map(([t,e])=>{let i=pn(t),s=e*i,r=Pe.includes(t.toLowerCase());return[t,e,s,i,r]})}function Ns(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([d,l])=>gn.includes(d.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let s=bn(e).sort(([,,d],[,,l])=>l-d),[r,a,,o,u]=s[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:s,importanceFactor:o,isCore:u}}function $s(n){if(!n)return{startTime:0,endTime:0,duration:.01};let t=n.start_time||0,e=n.end_time||0;return{startTime:t,endTime:e,duration:Math.max(.01,e-t)}}function Us(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function yn(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),s=parseInt(n.slice(5,7),16);return`rgba(${e}, ${i}, ${s}, ${t})`}function Sn(n,t="",e="",i=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${yn(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var wn={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function An(n){return x.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function vn(n=1,t="",e=1,i=""){let{min:s,max:r}=x.wordSpacing,a=parseFloat(s),o=parseFloat(r),d=An(t).wordSpacingMultiplier;if(n<=1)return`${(a*d).toFixed(3)}em`;let l=Math.max(...Object.values(wn)),m=Math.min(1,(n-1)/(l-1)),c=Math.pow(m,2),f=(a+(o-a)*c)*d;return i==="anger"||i==="screaming"?`${(f*.6).toFixed(3)}em`:`${f.toFixed(3)}em`}var xn=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function Tn(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0;return Math.abs(t)%1e3/1e3}function Mn(n,t,e){if(!n)return 1;let i=(n.word||n.text||"").trim();if(!i)return 1;let s=i.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!s)return 1;if(xn.has(s)||s.length<=2)return 0;let r=Math.min(1,s.length/7),a=Tn(s);return .5*r+.5*a<.55?0:1}function Hs({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:i,currentTime:s,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:u=1,fontSize:d=16}){let l=new Array(u).fill(0);return l}function Js(n){return n.split("").map((t,e)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:e}))}function Le(n,{minDeviation:t=.02,maxBlur:e=1.5,multiplier:i=1.5}={}){let s=Math.abs((n??1)-1);return s<=t?0:Math.min(e,s*i)}function _n(n=0,t=1,e=1){let i=1-.5*Math.min(1,Math.max(0,e??0)),s=Le(t)*i;return(n??0)+s}function Xt(n,t,e,i,s){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return i+a*(s-i)}function ti(n,t,e=null,i){if(!t)return i||400;let{min:s,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return i||a;let o,u;if(e?.mapping?.volume?(o=e.mapping.volume.min,u=e.mapping.volume.max):(o=s,u=r),i!==void 0){let d=(u-o)/4,l=Xt(n,0,1,-d,d);return Math.round(Math.max(s,Math.min(r,i+l)))}return Math.round(Xt(n,0,1,o,u))}function ei(n,t,e){if(!t)return e||100;let{min:i,max:s,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(s-i)/4,o=Xt(1-n,0,1,-a,a);return Math.round(Math.max(i,Math.min(s,e+o)))}return Math.round(Xt(1-n,0,1,i,s))}var De={},Re={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function Oe(n){if(!n)return;let t=n.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||De[t]||(De[t]=!0,typeof document>"u"))return;let e=Re[t],i=document.createElement("link");i.rel="stylesheet",i.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(i)}function En(){Object.keys(Re).forEach(n=>Oe(n))}var ae=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,e={}){let i=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,s=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};s&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(i,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let d=await a.clone().json();if(d.message)o=d.message;else if(d.error)o=d.error;else if(Array.isArray(d.detail)){let l=d.detail.map(m=>{let c=Array.isArray(m.loc)?m.loc.filter(C=>C!=="body").join("."):"";return c?`${c}: ${m.msg||"invalid"}`:m.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof d.detail=="string"&&(o=d.detail)}catch{try{let d=await a.clone().text();d&&(o=d)}catch{}}let u=new Error(o);throw u.status=a.status,u.response=a,u}return a}async login(t,e){let s=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!s.session_id||!s.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=s.auth_token,this.sessionId=s.session_id,s}async register(t,e,i,s){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:i,company:s.company,first_name:s.first_name,last_name:s.last_name})})).json()}async getSubtitleTrack(t,e,i){let s=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&s.append("lang",e.trim()),i&&typeof i=="string"&&i.trim()&&s.append("model",i.trim());let r=s.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,e=10){return(await this.request(`/vods?skip=${t}&limit=${e}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};export{x as ANIMATION_STYLING,Y as ANIMATION_URLS,Ke as AUTHORED_PLAYBACK_OPTIONS,ie as EMOTION_ANIMATION_URLS,ae as PhontClient,Pt as REFERENCE_GTS,pe as REFERENCE_INTENSITY,p as RENDERING_CONTROL,Bt as SubtitleManager,vt as SubtitleStateManager,ht as calculateAnimationParameters,Cn as calculateAnimationState,vn as calculateDynamicWordSpacing,ye as calculateEmphasisMultiplier,Jt as calculateGTSValues,ds as calculateJoy,ms as calculateJoyBulge,Us as calculateNormalizedTime,ti as calculateWeightFromVolume,ei as calculateWidthFromSpeechRate,xe as calculateWordEmphasisEffects,Hs as calculateWordLetterSpacing,be as capEmotionIntensity,Mn as computeProsodyWeight,fn as createPublishedAnimationResolver,Kt as decodeAnimationUrl,Oe as ensureFont,ee as findSubtitleForWord,Sn as generateTextShadow,hn as getAnimationUrlForEmotion,_n as getCombinedBlurAmount,zt as getCurrentAuthToken,Gt as getCurrentSessionId,ne as getFontFamilyCSS,_e as getJoyAnimationMode,hs as getJoyFilter,Cs as getJoyTransform,Wt as getMergedSubtitles,Le as getMotionBlurAmount,Ot as getSubtitleAnimations,Rt as getSubtitleText,$s as getSubtitleTiming,te as getSubtitleWords,sn as getWordEmphasis,st as hasMergedSubtitles,Ge as hockeyStickIntensity,Se as isInEmphasisRange,we as isInStrongEmphasisRange,me as isSubtitleDebugEnabled,Ht as logSubtitleData,as as meetsEmotionThreshold,En as preloadAnimationFonts,Dt as processEmotionsWithImportance,Lt as resolveEffectiveGts,Ct as sampleParameterCurve,Ns as selectEmotion,an as selectFontFamily,As as shouldUseAngryFont,vs as shouldUseJoyFont,xs as shouldUseSadnessFont,Js as splitTextIntoLetters,Ve as subtitleManager};
|
package/package.json
CHANGED