@phont-ai/subtitles-core 0.2.3 → 0.2.4
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/browser.d.mts +2 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +262 -2
- package/dist/index.d.ts +262 -2
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/dist/phont-subtitles.global.js +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);for(let r of
|
|
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};
|
|
1
|
+
var Tt=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,s){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),s!==void 0&&(this.state.soundByteFiltered=s),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,s){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),s!==void 0&&(this.vodState.soundByteFiltered=s),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 Mt=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 s=t||"original";this._subtitleCache.set(s,{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"],s=["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"],i=["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,c=0,m=0;r.forEach(h=>{e.includes(h)&&o++,s.includes(h)&&c++,i.includes(h)&&m++});let l=o/a,d=c/a,u=m/a,C=.1;return l>C&&l>d&&l>u?"de":d>C&&d>l&&d>u?"pl":u>C&&u>l&&u>d?"en-US":null}};var tn="phont_session_",en="phont_current_user";function ge(n){return`${tn}${n}`}function pe(){try{return localStorage.getItem(en)}catch(n){return console.error("Failed to get current user:",n),null}}function be(n){if(!n)return null;try{let t=localStorage.getItem(ge(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 nn(n){let t=be(n);return t?t.authToken:null}function sn(n){let t=be(n);return t?t.sessionId:null}function rn(n){if(n)try{localStorage.removeItem(ge(n))}catch(t){console.error("Failed to clear session:",t)}}function Ht(){let n=pe();return n?nn(n):null}function Jt(){let n=pe();return n?sn(n):null}var ct=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",an=process.env.NEXT_PUBLIC_SUBTITLE_SOURCE||"api";function Zt(){return an==="sidecar"}var _t=class{constructor(t,e){this._liveMasterUrl=null;this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=e||null}setPhontClient(t){this.phontClient=t}setLiveMasterUrl(t){this._liveMasterUrl=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 i=(await e.text()).split(`
|
|
2
|
+
`);for(let r of i)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 parseHLSMasterManifestForSubtitles(t){let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch master manifest: ${e.status}`);let i=(await e.text()).split(`
|
|
3
|
+
`);for(let r of i)if(r.includes("#EXT-X-MEDIA:TYPE=SUBTITLES")&&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 SUBTITLES rendition found in master manifest")}_getSidecarStreamInfo(t){let e=t.lastIndexOf("/"),s=t.substring(0,e),r=t.substring(e+1).replace(/_phont\.m3u8$/,"");return{base:s,streamId:r}}async parseAudioPlaylist(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch audio playlist: ${e.status}`);let s=await e.text(),i=new Map,r=s.split(`
|
|
4
|
+
`),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 c=o.match(/#EXTINF:([0-9.]+)/);if(c){let m=parseFloat(c[1]);i.set(a,m),a++}}return i}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let s=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!s)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let i=Zt()?await this.parseHLSMasterManifestForSubtitles(s):await this.parseHLSMasterManifest(s),r=await this.parseAudioPlaylist(i);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=Zt()?await this.parseHLSMasterManifestForSubtitles(t):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._liveMasterUrl!==null||Zt()){let i=this._liveMasterUrl||process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("Live master URL not configured. Call subtitleManager.setLiveMasterUrl(url) or set NEXT_PUBLIC_API_LIVE_URL.");let{base:r,streamId:a}=this._getSidecarStreamInfo(i),o=`${r}/${a}_subtitle${t}.json`,c=await fetch(o);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);e={subtitles:(await c.json()).cues||[],soundbite:void 0}}else if(this.phontClient){if(!ct&&!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=ct||this.phontClient.apiBaseUrl,r=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);e=await r.json()}else{if(!ct)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(`${ct}/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 s,i;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");i=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let c=r.searchParams.get("lang")||e||void 0,m=r.searchParams.get("model")||void 0;try{s=await this.phontClient.getSubtitleTrack(i,c||null,m||null)}catch(l){let d=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),u=typeof l?.message=="string"?l.message:String(l||""),C=d===404||u.includes("404")||u.includes("Not Found"),h=d===400||u.includes("400")||u.includes("Bad Request")||u.includes("HTTP error! status: 400");if(C||h)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${i} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:i};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{i=t;let r=e&&e.trim()||void 0;try{s=await this.phontClient.getSubtitleTrack(i,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),c=typeof a?.message=="string"?a.message:String(a||""),m=o===404||c.includes("404")||c.includes("Not Found"),l=o===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(m||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${i} (${m?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:i};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\/([^/?]+)/);i=l?l[1]:t.split("/").pop().split("?")[0]}else{if(i=t,!ct&&!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=ct||this.phontClient?.apiBaseUrl,d=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&d.append("lang",e.trim());let u=d.toString();r=u?`${l}/vod-subtitles/${i}?${u}`:`${l}/vod-subtitles/${i}`}let a={"Content-Type":"application/json"},o=Ht(),c=Jt();o&&(a.Authorization=`Bearer ${o}`),c&&(a["X-Session-ID"]=c);let m=await fetch(r,{headers:a,cache:"no-store"});if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);s=await m.json()}return this.stateManager.updateVodVideoId(i),{data:s,videoId:i}}catch(s){throw this.stateManager.clearVodState(),s}}};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","Crowd Cheering":"CrowdCheering.json","Crowd cheering":"CrowdCheering.json",Cheering:"CrowdCheering.json",Cheer:"CrowdCheering.json",Applause:"CrowdCheering.json",Clapping:"CrowdCheering.json",Crowd:"CrowdCheering.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Et=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[s,i]of Object.entries(ye)){let r=s.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return i}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let s of t.important){let i=this.mapEventLabelToAnimation(s.event_label);i&&e.push({id:`important_${s.event_label}_${s.start_time||s.onset}`,eventLabel:s.event_label,animationFile:i,startTime:s.start_time||s.onset,endTime:s.end_time||s.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let s of t.all){let i=this.mapEventLabelToAnimation(s.event_label);i&&e.push({id:`all_${s.event_label}_${s.start_time||s.onset}`,eventLabel:s.event_label,animationFile:i,startTime:s.start_time||s.onset,endTime:s.end_time||s.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(s=>{if(s.animationFile==="Laughter"){let i=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-s.startTime)<=1);if(i){i.endTime=Math.max(i.endTime,s.endTime);return}}e.push(s)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,s=2,i=[];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 c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;e>=m&&e<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:u})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;e>=m&&e<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:u})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;e>=m&&e<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:u})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let c of o){let m=this.mapEventLabelToAnimation(c.event_label);if(m){let l=c.start_time??c.onset??0,d=c.end_time??c.offset??0;if(e>=l&&e<=d){let C="all";this.stateManager.state.soundByteImportant?.includes(c)?C="important":this.stateManager.state.soundByteFiltered?.includes(c)&&(C="filtered"),i.push({id:`live_${c.event_label}_${l}`,eventLabel:c.event_label,animationFile:m,startTime:l,endTime:d,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};i.sort((o,c)=>{let m=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=c.eventLabel==="Laughter"?1:r[c.priority]||5;return m-l});let a=i.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=i=>Array.isArray(i)?i.length>0&&Array.isArray(i[0])?i.flat():i:[];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 s=[],i=[],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);s.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}return{all:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:i.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 s=t-e,i=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=s),this.stateManager.state.soundbiteAnimations.length<i&&this.stateManager.notify()}};var It=class{constructor(t,e,s){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=s}processVodData(t,e,s,i){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),c=a.flat().map(h=>({...h,sequence_number:o}));i&&i.length>0&&(c=this._mergeAnimationDataFromOriginal(c,i));let m=this._deduplicateSubtitles(c),{soundByteAll:l,soundByteImportant:d,soundByteFiltered:u}=this._processSoundbites(t.soundbite);if(l.length>0||d.length>0||u.length>0){let h={all:l,important:d,filtered:u},f=this.soundbiteProcessor.processSoundbiteAnimations(h);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...f]}let C=t.language||s||null;this.stateManager.vodState={subtitles:m,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:d,soundByteFiltered:u,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 s=new Map;for(let i of e){let r=`${i.start_time}-${i.end_time}`;(!s.has(r)||i.animations||i.emotion)&&s.set(r,i)}return t.map(i=>{let r=`${i.start_time}-${i.end_time}`,a=s.get(r);if(!a)return i;let o=i.animations&&typeof i.animations=="object"&&Object.keys(i.animations).length>0,c=i.emotion&&i.emotion!=="none"&&i.emotion!=="neutral",m=typeof i.animation_url=="string"&&i.animation_url.length>0;if(o&&m)return i;let l={...i};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!c&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!m&&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 u of a.words)d.set(`${u.start}-${u.end}`,u);l.words=l.words.map(u=>{let C=d.get(`${u.start}-${u.end}`);if(!C||u.animations&&typeof u.animations=="object"&&Object.keys(u.animations).length>0)return u;let f={...u};return C.animations&&Object.keys(C.animations).length>0&&(f.animations=C.animations),!f.emotion&&C.emotion&&(f.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(f.emotion_intensity=C.emotion_intensity)),!f.animation_url&&C.animation_url&&(f.animation_url=C.animation_url),f})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let s of t){let i=`${s.start_time}-${s.end_time}`;(!e.has(i)||s.emotion||s.animations)&&e.set(i,s)}return Array.from(e.values())}_processSoundbites(t){let e=[],s=[],i=[];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)&&(s=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(i=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:s,soundByteFiltered:i}}};var Lt=class{constructor(t,e,s){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=s}async processLiveSegment(t,e,s){this.stateManager.state.processedSequences.add(e),this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=s);let i=this.stateManager.state.videoTimeSeed;this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let r=s-i,a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:c,processedSoundbitesFiltered:m}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,c,m);let l={all:o,important:c,filtered:m},d=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(d),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(u=>u.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,s){return!t||!Array.isArray(t)?[]:t.map(i=>({...i,sequence_number:e,start_time:i.start_time+s,end_time:i.end_time+s,words:i.words?i.words.map(r=>({...r,start:r.start+s,end:r.end+s})):void 0}))}_processSoundbites(t,e){let s=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),i=(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:s,processedSoundbitesImportant:i,processedSoundbitesFiltered:r}}_updateState(t,e,s,i){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,...s],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...i]}};var kt=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,s=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),s&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let s=this.stateManager.state.initialSequenceOffset;s<t;s++){let i=this.stateManager.state.segmentDurations.get(s)||10;e+=i}return e}};var Ft=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 i=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;i=r.join(" ")}return{activeSubtitle:t,displayText:i}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return null;let s=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!s&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let i=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(i){let r=this._processSubtitleText(i,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,c=e.currentSubtitle!==o||e.currentSubtitleData!==a;return c&&(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),(s||c)&&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(s=>t.currentTime>=s.start_time&&t.currentTime<=s.end_time);if(e){t.currentSequence=e.sequence_number??null;let s=this._processSubtitleText(e,t.currentTime);if(!s)return null;let{activeSubtitle:i,displayText:r}=s;return(t.currentSubtitle!==r||t.currentSubtitleData!==i)&&(t.currentSubtitle=r,t.currentSubtitleData=i,this.stateManager.notify()),this._lastSubtitleData=i,this._lastSubtitleTime=t.currentTime,i}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 Se=new Set;function ve(){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 we(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 on(){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=we(t.raw),s=e!=null?`${e} segments`:"see payload";return console.log(`%c[vod-subtitles] ${s}`,"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 Qt(n,t){if(!ve()||typeof window>"u")return;let e=`${t?.vodId??""}|${t?.url??""}`;if(Se.has(e))return;Se.add(e);let s={at:new Date().toISOString(),vodId:t?.vodId??null,url:t?.url,raw:n},i=on();i.last=s;let r=we(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 bi=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function Ae(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var Pt=class{constructor(){this.stateManager=new Tt,this.cache=new Mt,this.fetcher=new _t(this.stateManager),this.soundbiteProcessor=new Et(this.stateManager),this.vodDataProcessor=new It(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new kt(this.stateManager),this.liveDataProcessor=new Lt(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new Ft(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)}setLiveMasterUrl(t){this.fetcher.setLiveMasterUrl(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}recordSegmentDuration(t,e){typeof e!="number"||!isFinite(e)||e<=0||this.stateManager.setSegmentDuration(t,e)}recordInitialSequenceOffset(t){typeof t!="number"||!isFinite(t)||this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t)}async fetchSubtitles(t,e){try{let s=await this.fetcher.fetchSubtitles(t);return s?typeof e!="number"||!isFinite(e)?(console.warn(`[SubtitleManager] fetchSubtitles(sn=${t}) called without fragStart; skipping live processing`),null):await this.liveDataProcessor.processLiveSegment(s,t,e):null}catch{return null}}updateLiveTimeFromVideo(t){if(typeof t!="number"||!isFinite(t))return;let e=this.stateManager.state,s=e.videoTimeSeed;if(s===null)return;let i=t-s;Math.abs(e.liveCurrentTime-i)>.001&&(e.liveCurrentTime=i,e.currentTime=i,this.stateManager.notify())}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,s,i){this.vodDataProcessor.processVodData(t,e,s,i)}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 s=t-e,i=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=s),this.state.subtitles.length<i&&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 s=null;if(t?s=this.vodState.currentSubtitleData:s=this.state.currentSubtitleData,!s||!s.words)return null;let i=s?.speaker;return i||null}async fetchSubtitleData(t,e=null,s=null){if(!e&&t){let i=new URLSearchParams(t.split("?")[1]||"");e=i.get("lang")||null,s||(s=i.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 i=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=i,o=r?.language||e||null;Qt(r,{vodId:a,url:t});let c=Ae(o??e),m=s?`${c}_${s}`:c,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(m,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let u;if(!!e&&String(e).trim()!==""){let h=this.cache._subtitleCache.get("original");h?.data?.subtitles&&(u=Array.isArray(h.data.subtitles)?h.data.subtitles.flat():[])}this._processVodData(r,t,o,u)}catch(i){let r=i?.status||i?.response?.status,a=r===404||typeof i?.message=="string"&&i.message.includes("404")||typeof i?.message=="string"&&i.message.includes("Not Found"),o=r===400||typeof i?.message=="string"&&i.message.includes("400")||typeof i?.message=="string"&&i.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:i?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",i),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,s=null){if(!e)return;let i=Ae(t);if(this.cache._loadingLanguages.has(i))return;let r=s?`${i}_${s}`:i,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(i);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 c=new URLSearchParams;t&&c.append("lang",t),s&&c.append("model",s);let m=c.toString(),l=`${o}/vod-subtitles/${e}${m?`?${m}`:""}`,d=!1;try{await this.fetchSubtitleData(l,t,s),d=!0}catch(u){if(u?.status===404||typeof u?.message=="string"&&u.message.includes("404"))if(t!==null)d=!0;else throw u;else throw u}if(!d)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,s)}finally{this.cache._loadingLanguages.delete(i)}}_loadCachedSubtitles(t,e,s){let i=t?.language||s||null,r;if(!!s&&String(s).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,i,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},ln=new Pt;function lt(){let n=new Set,t=new Set,e=[],s=new Set,i=!1,r=!1;return{source:{onSegmentLoaded(o){return r?()=>{}:(n.add(o),()=>n.delete(o))},onInitialPlaylist(o){return r?()=>{}:(t.add(o),()=>t.delete(o))},destroy(){if(!r){r=!0;for(let o of e)try{o()}catch{}e.length=0,n.clear(),t.clear(),s.clear()}}},emitSegment(o){r||!o||typeof o.sn!="number"||s.has(o.sn)||(s.add(o.sn),n.forEach(c=>{try{c(o)}catch(m){console.warn("[LiveSegmentSource] listener error:",m)}}))},emitInitial(o){r||i||!o||!Array.isArray(o.fragments)||o.fragments.length===0||(i=!0,t.forEach(c=>{try{c(o)}catch(m){console.warn("[LiveSegmentSource] listener error:",m)}}))},addTeardown(o){e.push(o)}}}function un(n,t){let{source:e,emitSegment:s,emitInitial:i,addTeardown:r}=lt(),a=(l,d)=>{let u=d&&d.frag;u&&(u.type!=="main"&&u.type!=="audio"||typeof u.sn=="number"&&s({sn:u.sn,duration:u.duration||0,start:typeof u.start=="number"?u.start:0,uri:u.url,type:u.type}))},o=l=>{if(!l||!Array.isArray(l.fragments)||l.fragments.length===0)return null;let d=l.fragments.filter(u=>typeof u.sn=="number").map(u=>({sn:u.sn,duration:u.duration||0,start:typeof u.start=="number"?u.start:0,uri:u.url,type:u.type||"main"}));return d.length===0?null:{startSn:d[0].sn,fragments:d,playlistUri:l.url}},c=(l,d)=>{let u=o(d&&d.details);u&&i(u)},m=(l,d)=>{let u=o(d&&d.details);u&&i(u)};return n.on(t.Events.FRAG_LOADED,a),n.on(t.Events.LEVEL_LOADED,c),n.on(t.Events.AUDIO_TRACK_LOADED,m),r(()=>{try{n.off(t.Events.FRAG_LOADED,a)}catch{}try{n.off(t.Events.LEVEL_LOADED,c)}catch{}try{n.off(t.Events.AUDIO_TRACK_LOADED,m)}catch{}}),e}function cn(n,t){let{source:e}=lt();throw new Error("[ShakaLiveSegmentSource] not implemented yet \u2014 see file header for outline")}function mn(n){let{source:t}=lt();throw new Error("[BitmovinLiveSegmentSource] not implemented yet \u2014 see file header for outline")}function dn(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[s,i]=e.split(","),r=t||typeof i=="string"&&(i.startsWith("#")||i.startsWith("%23")),a;return r?a=i.replace(/%23/g,"#"):a=parseFloat(i),{time:parseFloat(s),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 te(n){try{let t=Cn(n),e=new URLSearchParams(t),s={parameterStates:{}};if(e.has("name")&&(s.name=e.get("name")||void 0),e.has("user")&&(s.userName=e.get("user")||void 0),e.has("duration")&&(s.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(s.animationMode=e.get("mode")||void 0),e.has("text")&&(s.text=e.get("text")||void 0),e.get("format")==="normalized"&&(s.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?s.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:s.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{s.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"),c=dn(a,o);if(c.length>0){let m=o?"#000000":0;s.parameterStates[r]={points:c,currentValue:c[0]?.value||m}}}return s}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 fn(n){if(n===0)return 0;let t=4,e;if(n<=.7){let s=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*s}else{let s=(n-.7)/.3,i=Math.log(1+.5*(Math.exp(t)-1))/t;e=i+s*(1-i)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function Bt(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 Te(n,t,e){let s=i=>{let r=Math.round(Math.max(0,Math.min(255,i))).toString(16);return r.length===1?"0"+r:r};return"#"+s(n)+s(t)+s(e)}function xe(n,t,e){let s=Bt(n),i=Bt(t),r=Math.max(0,Math.min(1,e)),a=s.r+(i.r-s.r)*r,o=s.g+(i.g-s.g)*r,c=s.b+(i.b-s.b)*r;return Te(a,o,c)}function hn(n,t,e){if(e===0)return n;let s=Bt(n),i=Bt(t),r=s.r+(i.r-s.r)*e,a=s.g+(i.g-s.g)*e,o=s.b+(i.b-s.b)*e;return Te(r,a,o)}function ft(n,t,e,s=!1,i=null){if(!n||n.length===0)return null;let r=s?t:t*e,a=null,o=null;for(let c=0;c<n.length;c++){let m=n[c],l=m.time!==void 0?m.time:Array.isArray(m)?m[0]:0;if(l!==void 0&&l<=r&&(a=m),l!==void 0&&l>=r&&!o){o=m;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 c=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,m=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(c===m||l===null||d===null)return l??null;let u=(r-c)/(m-c),C=i==="color"||i==="shadowColor"||i==="outlineColor"||i==="outline2Color"||i==="outline3Color"||i==="outlineShadowColor"||i==="glowColor";if(C&&(typeof l=="string"||typeof d=="string"))return xe(typeof l=="string"?l:"#000000",typeof d=="string"?d:"#000000",u);if(!C&&(typeof l=="string"||typeof d=="string")){let h=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),f=typeof d=="string"&&(d.startsWith("#")||/^[0-9a-f]{6}$/i.test(d));if(h&&f){let g=l.startsWith("#")?l:`#${l}`,E=d.startsWith("#")?d:`#${d}`;return xe(g,E,u)}return d??null}return l+(d-l)*u}return null}var Me=.7,Dt=.7,gn={rawMode:!0};function ht(n,t,e,s,i=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*s/(Me*Dt),o=n.duration||2,m=n.format==="normalized"?e:e*o,l=!0,d=n.parameterStates||{},u=(M,D,Y=!0,Z=null)=>{let Ct=Z??a,rt=ft(d[M]?.points,m,o,l);return rt==null?D:Y?Ct===0?D:D+(rt-D)*Ct:rt},C=u("scale",1),h=u("skew",0),f=u("stretch",1),g=u("translateX",0),E=u("translateY",0),b=u("weight",500),I=u("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",O=n.text||"Hello",B=(M,D)=>{let Y=ft(d[M]?.points,m,o,l,M);if(Y==null)return D;let Z=typeof Y=="string"?Y.startsWith("#")?Y:`#${Y}`:`#${Math.round(Y).toString(16).padStart(6,"0")}`;return a===0?D:hn(D,Z,a)},L=B("color","#ffffff"),F=u("opacity",1),_=u("shadowX",0),x=u("shadowY",0),z=u("shadowBlur",4),K=u("shadowOpacity",.5),Q=B("shadowColor","#000000"),pt=u("outlineWidth",0),Vt=B("outlineColor","#000000"),R=M=>d[M]?.points?.length>0,mt=R("stretchX")?u("stretchX",1):void 0,bt=R("outline2Width")?u("outline2Width",0):void 0,yt=R("outline2Color")?B("outline2Color","#000000"):void 0,St=R("outline3Width")?u("outline3Width",0):void 0,vt=R("outline3Color")?B("outline3Color","#000000"):void 0,S=R("outlineShadowWidth")?u("outlineShadowWidth",0):void 0,j=R("outlineShadowColor")?B("outlineShadowColor","#000000"):void 0,W=R("outlineShadowBlur")?u("outlineShadowBlur",0):void 0,A=R("glowIntensity")?u("glowIntensity",0):void 0,P=R("glowColor")?B("glowColor","#ffffff"):void 0,N=R("snakeWave")?u("snakeWave",0):void 0,tt=R("karaoke")?u("karaoke",0):void 0,U=1-.5*Math.min(1,Math.max(0,s)),$=u("blur",0,!0,r?1:a*U),dt=ft(d.thinStroke?.points,m,o,l),G=ft(d.ascenderHeight?.points,m,o,l),st={};dt!=null&&typeof dt=="number"&&(st.YOPQ=dt),G!=null&&typeof G=="number"&&(st.YTAS=G),b!=null&&(st.wght=b),I!=null&&(st.wdth=I);let et=[];if((_!==0||x!==0||z!==4||K!==.5)&&K>0){let M=typeof Q=="string"?Q:"#000000",D=parseInt(M.slice(1,3),16),Y=parseInt(M.slice(3,5),16),Z=parseInt(M.slice(5,7),16);et.push(`${_}px ${x}px ${z}px rgba(${D}, ${Y}, ${Z}, ${K})`)}if(A!=null&&A>0){let M=typeof P=="string"?P:"#ffffff";et.push(`0 0 ${A}px ${M}`),et.push(`0 0 ${A*2}px ${M}`),et.push(`0 0 ${A*4}px ${M}`)}let qt=et.length>0?et.join(", "):"",ut=0;if(d.joy?.points&&d.joy.points.length>0)for(let M of d.joy.points){let D=Array.isArray(M)?M[1]:M.y??M.value??0;typeof D=="number"&&D>ut&&(ut=D)}let wt=u("joy",0,!1),zt=r?wt:Math.min(1,ut*a),H=u("fear",0),J=u("standardEmphasis",0,!1),nt=u("strongEmphasis",0,!1),T={rawIntensity:t,scaleFactor:a,scale:C,slant:h,stretchY:f,translateX:g,translateY:E,weight:b,width:I,fontFamily:y,textColor:L,opacity:F,textShadow:qt,shadowX:_,shadowY:x,blur:$,outlineWidth:pt,outlineColor:Vt,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:st,text:O,joy:zt,fear:H,standardEmphasis:J,strongEmphasis:nt,joyWaveProgress:m/o*1.5};return mt!==void 0&&(T.stretchX=mt),bt!==void 0&&(T.outline2Width=bt),yt!==void 0&&(T.outline2Color=yt),St!==void 0&&(T.outline3Width=St),vt!==void 0&&(T.outline3Color=vt),S!==void 0&&(T.outlineShadowWidth=S),j!==void 0&&(T.outlineShadowColor=j),W!==void 0&&(T.outlineShadowBlur=W),A!==void 0&&(T.glowIntensity=A),P!==void 0&&(T.glowColor=P),N!==void 0&&(T.snakeWave=N),tt!==void 0&&(T.karaoke=tt),T}var w={fontSize:54,opacity:1,weight:500,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:7,color:"rgba(0, 0, 0, 0.95)"},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},subtitleBackground:{background:"#000000",border:"none",borderRadius:0,boxShadow:"none",backdropFilter:"none",paddingX:12,paddingY:8}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:.85,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 Ot(n,t,e){let s=Math.max(0,Math.min(1,n)),i=e??t;if(typeof i=="number"&&Number.isFinite(i)){let r=Math.max(0,Math.min(1,i));return Math.min(1,Math.max(0,r*(s/Dt)))}return s}function ee(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 Vi(n,t){return n>=t}function _e(n,t){return t<=.2?0:n*t}function Ee(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 Le(n){return n>=p.strongEmphasis.minThreshold}function pn(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,c=n*n,m=c*n;return o*0+3*a*n*.42+3*r*c*.58+m*1}var ke=new WeakMap,ne={joy:1,social_positive:1,anger:-1,screaming:-1};function ie(n,t,e,s){let i=typeof e=="string"?e.toLowerCase():"";if(i==="joy")return bn(n,t,s);let r=Math.sign(t);return r!==0?r:i in ne?ne[i]:s}function bn(n,t,e){let s=Math.sign(t);if(n){let i=ke.get(n);if(i!==void 0)return i;let r=s!==0?s:Fe(e);return ke.set(n,r),r}return s!==0?s:Fe(e)}function Fe(n){return n!==0?n:ne.joy}function yn(n,t,e=1,s=0,i=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:c,scaleDownFrames:m,fps:l}=p.emphasis;if(!n||!Ie(a))return null;let d=t-n.start,u=i?n.start+i:n.end,C=u-n.start;if(d<0||t>=u)return null;let h=Math.max(0,Math.min(1,d/C)),f=0;h<.5?f=h*2:f=2-h*2,f=f*f*(3-2*f);let g=Ee(a),E=.55,b=3*E,k=ie(n,s,r,0)*b*f*e*g,y=140*f*e*g,O=1+o*E*f*e*g,B=h<1;return{scaleMultiplier:O,slantAdditive:k,weightBoost:y,scaleProgress:f,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:d,scaleActive:B}}function Sn(n,t,e={},s=1,i=null,r=0,a=""){let o=a==="anger"||a==="screaming",c=p.strongEmphasis,m=.7,l=i?n.start+i:n.end;if(t<n.start)return null;let d=n.emphasis||0;if(!Le(d))return null;let u=c.fadeOutTailDuration,C=l+u;if(t>=C)return null;let h=l-n.start,f=Math.max(0,Math.min(1,(t-n.start)/h)),g=1,E=t>=l;if(E){let x=(t-l)/u;g=1-pn(x),f=1}let b=0;f<.5?b=f*2:b=2-f*2;let I=b*b*(3-2*b),k=(d-c.minThreshold)/(1-c.minThreshold),y=I*k*s,O=y;y<.1&&(y=0);let B=ie(n,r,a,-1),L,F;if(o)L={scale:1+y*(c.maxScale-1)*m,rotation:y*c.maxRotation*m,translateY:-y*c.maxTranslateY*m,translateX:y*c.maxTranslateX*m,skewX:B*y*c.maxSkew*m,stretchY:1},F={brightness:1+y*c.maxBrightness*m,contrast:1+y*c.maxContrast*m,shadowBlur:y*c.maxShadowBlur*m,shadowOpacity:y*c.shadowOpacity*m,zIndex:Math.round(y*c.maxZIndex*m)};else{let K=I*20*Math.max(.2,k*s)*m,Q=ie(n,r,a,1);L={scale:1+y*.15*m,rotation:0,translateY:0,translateX:0,skewX:Q*K,stretchY:1},F={brightness:1+y*.2*m,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(L.scale=1+(L.scale-1)*g,L.rotation=L.rotation*g,L.translateX=L.translateX*g,L.translateY=L.translateY*g,L.skewX=L.skewX*g,F.brightness=1+(F.brightness-1)*g,F.contrast=1+(F.contrast-1)*g,F.shadowBlur=F.shadowBlur*g,F.shadowOpacity=F.shadowOpacity*g,F.zIndex=Math.round(F.zIndex*g),y=y*g);let _=280*y*s;return{emphasis:y,rawEmphasis:O,...L,...F,weightBoost:_,shadowOffsetX:y*c.shadowOffsetX,shadowOffsetY:y*c.shadowOffsetY,gtsMultiplier:s,emphasisMultiplier:k,fadeFactor:g,isInTail:E}}function Pe({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:s,wordBaseSlant:i,isActive:r,wordEmotion:a=""}){let o=r?yn(n,t,e,i,s,a):null,c=Sn(n,t,{},e,s,i,a);return{emphasisEffect:o,strongEmphasisData:c}}function Be(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 De(n){return 1-(1-n)*(1-n)}function Oe(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function Ji(n,t,e,s=1){let i=p.joy.letterWave,r=e<=6,a,o,c;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),c=a+o):(a=i.innerWidthRatio,o=i.outerWidthRatio,c=a+o);let m=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+c),u=m-d,C=a+o,h=o*.3;if(u>h||u<-C)return null;let f=0;if(u>0&&u<=h)f=(1-u/h)*.15;else if(u<=0&&u>=-a){let y=Math.abs(u)/Math.max(a,.01);f=Be(y)}else if(u<-a){let O=(Math.abs(u)-a)/Math.max(o,.01);f=De(1-O)}if(f<=.01)return null;let g=f*s,b=1-t%2*.15,I={scale:1+g*(i.maxScale-1)*b,rotation:g*i.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*i.maxTranslateY*b,skewX:-g*i.maxSkew*.5,stretchY:1},k={brightness:1+g*i.maxBrightness,contrast:1+g*i.maxContrast,shadowBlur:g*i.maxShadowBlur,shadowOpacity:g*i.shadowOpacity,zIndex:Math.round(g*i.maxZIndex)};return{pressure:g,...I,...k,shadowOffsetX:g*3,shadowOffsetY:g*3}}function Zi(n,t,e,s=1){let i=p.joy.letterBulge,r=i.innerWidthRatio,a=i.outerWidthRatio,o=r+a,c=e>1?t/Math.max(1,e-1):0,m=n*(1+o),l=c-m,d=a*.35,u=o;if(l>d||l<-u)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 O=Math.abs(l)/Math.max(r,1e-4);C=Be(O)}else if(l<-r){let B=(Math.abs(l)-r)/Math.max(a,1e-4);C=De(1-B)}if(C<=.01)return null;let h=C*s,f=Math.min(1,h*.85),g=1,E=t%3===0?1:-1,b=Math.max(1-i.maxCompressionX,1-f*i.maxCompressionX),I=1+f*i.maxStretchY,k={scale:1+f*(i.maxScale-1),stretchY:I,stretchX:b,rotation:f*i.maxRotation*g,translateX:f*i.maxTranslateX*E,translateY:-f*i.maxTranslateY,skewX:f*i.maxSkew*g},y={brightness:1+f*i.maxBrightness,contrast:1+f*i.maxContrast,shadowBlur:f*i.maxShadowBlur,shadowOpacity:f*i.shadowOpacity,zIndex:Math.round(f*i.maxZIndex)};return{pressure:f,bulgeIntensity:f,...k,...y,shadowOffsetX:f*1.8,shadowOffsetY:f*3}}function Qi(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,s=n.rotation||0,i=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${s}deg) skewX(${a}deg) translate(${i}px, ${r}px)`}function ts(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,s=n.shadowBlur||0,i=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})`),s>0&&i>0&&o.push(`drop-shadow(${r}px ${a}px ${s}px rgba(255, 255, 255, ${i}))`),o.join(" ")}var vn=["anger","fear","sadness","joy"];function wn(n){return vn.includes(n.toLowerCase())}function Rt(n){return n.map(([t,e])=>{let s=wn(t),i=s?1.5:1,r=e*i;return[t,e,r,i,s]})}function An(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 Wt(n){return n&&(n.subtitle||n.text)||""}function se(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function Nt(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function it(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function jt(n){return it(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function re(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function xn(n,t,e=null,s=null){if((s?.name==="children"||s?.name==="hello-kitty")&&e&&s.fonts?.[e])return s.fonts[e];let i=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 i?w.angryFont:r?w.joyFont:a?w.sadnessFont:w.defaultFont}function ae(n,t,e=null,s=null){let i=xn(n,t,e,s),r="sans-serif";return i==="Cormorant"&&(r="serif"),`"${i}", ${r}`}function ls(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function us(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function cs(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var Ne='"Roboto Flex", "Roboto", sans-serif',Re=new Map,Tn={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function Ut(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?Tn[t]||t:""}function oe(n){if(typeof n!="string"||n.length===0)return null;let t=Re.get(n);if(t)return t;try{let e=te(n);return Re.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function Mn(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 _n(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 Xt(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=Nt(n),s=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(s.length>0){let a=Rt(s).sort((o,c)=>c[2]-o[2])[0];return{emotion:Ut(a[0])||"none",intensity:a[1]}}let i=Ut(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!i||i==="none"||r<=0?Xt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:i,intensity:r}}function En(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 We(n,t,e,s){let{minWordDisplayTime:i,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,c=Math.max(0,n.end-n.start),m=Math.max(c,i);if(!s)return n.start+m;let l=typeof t.end_time=="number"?t.end_time:n.end,d=l-n.end,u=!1;if(e!=null&&e>l?(d=e-n.end,u=d>=o):e==null?(u=!0,d=1/0):u=d>=a,u){let h=d===1/0?i+r:n.end+d-n.start-.1,g=c<i?h:Math.min(i+r,h);m=Math.max(m,g)}return n.start+m}function In(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let s=n.findIndex(a=>t>=a.start&&t<a.animationEnd),i=n.reduce((a,o,c)=>t>=o.animationEnd?c:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||i!==-1&&o<=i?1:e?0:.3),currentWordIndex:s}}function Ue(n){if(!n)return w.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),s=e.toLowerCase();return s.includes("bricolage")?"Bricolage Grotesque":s.includes("rakkas")?w.angryFont:s.includes("parkinsans")?w.joyFont:s.includes("cormorant")?w.sadnessFont:s.includes("roboto")?w.defaultFont:e}function Ln(n,t,e){let s={text:"",fontSize:w.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:Ne,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return s;let i=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=i<=.2,c=ee((i-.2)/.8).gts,m=n.start_time,l=n.end_time,d=Math.max(.01,l-m),u=Math.max(0,Math.min(1,(t-m)/d)),C=je(n,r),h=o?"none":C.emotion,f=o?0:Math.max(0,C.intensity),g=oe(Xt(n)),E=Ot(c,n.gts,void 0),b=g?ht(g,f,u,E,d):null,I=b?.fontFamily?`"${Ue(b.fontFamily)}", sans-serif`:ae(h,i),k={fontSize:w.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??w.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?En(k):k,text:Wt(n),emotion:h,emotionIntensity:f,fontFamily:I,startTime:m,endTime:l,duration:d,isActive:t>=m&&t<l}}function kn(n,t,e){let s=e.maxExpression??1,i=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,c=e.transparentUntilSpoken??!1,m=s<=.2,l=ee((s-.2)/.8).gts,d={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:Ne,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return d;let u=it(n)?jt(n):[n],C=Mn(u),h=_n(u,t);if(!h&&o!=null&&t>n.end_time&&t<=o&&(h=u[u.length-1]||null),!h&&C&&t>=C.start&&t<=C.end&&(h=[...u].filter(S=>S&&t>=S.start_time).sort((S,j)=>j.start_time-S.start_time)[0]||null),h==null)return d;let f=h,g=je(f,i),E=m?"none":g.emotion,b=m?0:Math.max(0,g.intensity),I=f.start_time,k=f.end_time,y=Math.max(.01,k-I),O=Math.max(0,Math.min(1,(t-I)/y)),B=it(n)?null:oe(Xt(f)),L=f.gts??n.gts,F=Ot(l,L,void 0),_=B?ht(B,b,O,F,y):null,x={fontSize:w.fontSize,scale:_?.scale??(E==="none"?1:1+b*.16),opacity:_?.opacity??1,slant:_?.slant??0,weight:_?.weight??400,width:_?.width??100,textColor:_?.textColor??w.textColor,translateX:_?.translateX??0,translateY:_?.translateY??0,stretchY:_?.stretchY??1,textShadow:_?.textShadow??"",blur:_?.blur??0,outlineWidth:_?.outlineWidth??0,outlineColor:_?.outlineColor??"#000000",fontVariationAxes:_?.fontVariationAxes??{}},z=se(n).flatMap(S=>{let j=String(S?.word??""),W=j.trim();if(!W.includes(" "))return[S];let A=W.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,A.length),tt=j.startsWith(" ");return A.map((U,$)=>({...S,word:($===0&&tt?" ":"")+U,start:(S.start??0)+$*N,end:(S.start??0)+($+1)*N}))}),K=null;if(it(n)&&C?.end){let S=z[z.length-1],j=We(S,n,a,!0),W=o??j,{minWordDisplayTime:A,breathingRoomDuration:P}=p.timing,N=A+P,U=(z.length>0?Math.min(...z.map($=>$.start)):C.start)+N;K=Math.max(C.end,W,U)}let Q=z.map((S,j)=>{let W=j===z.length-1,A=We(S,n,a,W);return{...S,animationEnd:it(n)&&K?Math.max(A,K):A}}),{currentWordIndex:pt,opacities:Vt}=In(Q,t,c),R=Q.map((S,j)=>{let W=t>=S.start&&t<S.end,A=E,P=b,N=b,tt=it(n)?jt(n):null,U=tt?re(tt,S):f;if(U){let at=Nt(U),xt=Object.entries(at).filter(([,q])=>typeof q=="number"&&q>i),Gt=Object.entries(at).filter(([,q])=>typeof q=="number");if(Gt.length>0)N=[...Gt].sort((ot,Kt)=>Kt[1]-ot[1])[0][1];else{let q=Ut(U.emotion),ot=typeof U.emotion_intensity=="number"?U.emotion_intensity:0;q&&ot>0&&(A=q,N=ot,P=ot)}if(xt.length>0){let q=Rt(xt).sort((ot,Kt)=>Kt[2]-ot[2]);A=Ut(q[0][0])||"none",P=q[0][1]}else Gt.length>0&&(A="none",P=0)}m?(A="none",P=0):P===N&&P!==0&&(P=_e(P,s));let $=Math.max(.01,(S.end??0)-(S.start??0)),dt=Math.max(0,Math.min(1,(t-S.start)/$)),G=oe(Xt(U)),st=N>0?N:G?Math.max(1,b||0):0,et=Ot(l,L,S.gts),v=G?ht(G,st,dt,et,$):null,qt=Ue(G?.fontData?.style?.fontFamily),ut=(G?.parameterStates?.standardEmphasis?.points?.length??0)>0,wt=(G?.parameterStates?.strongEmphasis?.points?.length??0)>0,zt=ut||wt,H=W?v?.standardEmphasis??0:0,J=W?v?.strongEmphasis??0:0,nt=null,T=null;if(zt){let at=(v?.slant??0)>0?1:(v?.slant??0)<0?-1:0;if(ut&&(nt={scaleMultiplier:1+.272*H*s,slantAdditive:at*4.25*H*s,weightBoost:250*H*s,scaleProgress:H,gtsMultiplier:s,emphasis:H,emphasisMultiplier:H,elapsed:0,scaleActive:H>0}),wt&&!r){let xt=(v?.slant??0)>0?1:(v?.slant??0)<0?-1:1;T={emphasis:J,rawEmphasis:J,scale:1+J*.38,skewX:xt*J*30*s,weightBoost:400*J*s,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+J*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:s,emphasisMultiplier:J,fadeFactor:1,isInTail:!1}}}else{let at=Pe({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:s,emotionAnimationDuration:$,wordBaseSlant:v?.slant||0,isActive:W,wordEmotion:A});nt=at.emphasisEffect,T=r?null:at.strongEmphasisData}let M=Vt[j]??1,D=(v?.opacity??x.opacity??1)*M,Z=(v?.scale??x.scale??1)*(nt?.scaleMultiplier||1),Ct=(v?.slant??x.slant??0)+(nt?.slantAdditive||0),rt=Z,he=nt?.weightBoost||0;T&&(Ct+=T.skewX||0,he+=T.weightBoost||0,rt=Z*(T.scale||1));let V={...x,fontSize:w.fontSize,scale:rt,slant:Ct,stretchY:v?.stretchY??x.stretchY??1,weight:(v?.weight??x.weight??400)+he,width:v?.width??x.width??100,textColor:v?.textColor??x.textColor??w.textColor,opacity:D,translateX:v?.translateX??x.translateX??0,translateY:v?.translateY??x.translateY??0,textShadow:v?.textShadow??x.textShadow??"",blur:v?.blur??x.blur??0,outlineWidth:v?.outlineWidth??x.outlineWidth??0,outlineColor:v?.outlineColor??x.outlineColor??"#000000",letterShake:v?.fear??0,fontVariationAxes:{...x.fontVariationAxes,...v?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:v?.joy??0,urlFear:v?.fear??0,urlJoyProgress:v?.joyWaveProgress??0};r&&(V.translateX=-V.translateX,V.rotation=V.rotation?-V.rotation:0,V.slant=-V.slant,V.skewX!==void 0&&(V.skewX=-V.skewX));let At=A==="joy"?Oe(Q.length):null,Qe=At&&(At==="letter"||At==="letter-bulge")?Math.min(1.5,Math.max(0,(t-I)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:W,emotion:A,emotionIntensity:P,originalEmotionIntensity:N,fontFamily:qt,emphasis:S.emphasis||0,emphasisEffect:nt,strongEmphasis:T,animationParameters:V,joyAnimationMode:At,joyProgress:Qe}}),mt=o??k,bt=C?Math.max(C.end,mt):null,yt=C&&t>=C.start&&t<=(bt||C.end),St=t>=I&&t<mt,vt=C?!!yt:St;return{text:Wt(n),words:R,currentWordIndex:pt,emotion:E,emotionIntensity:b,fontFamily:ae(E,s),startTime:C?.start||I,endTime:C?.end||k,isActive:vt}}function Fn(n,t,e,s){let i=typeof e=="string"?e:"word",r=typeof e=="string"?s||{}:e||{};return i==="sentence"?Ln(n,t,r):kn(n,t,r)}var X=["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"],le={joy:X[0],anger:X[11],sadness:X[5],fear:X[4],disgust:X[7],surprise:X[6],social_positive:X[1],social_negative:X[7],lust:X[11],calmness:X[1],screaming:X[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 Pn(n){return le[n.toLowerCase()]||le.none}function Bn(n,{ttlMs:t=300*1e3}={}){let e=new Map,s=new Map,i=new Map;function r(l){let d=i.get(l);return!d||Date.now()-d>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(s.has(l))return s.get(l);let d=(async()=>{try{let u=await n(l),C=new Map;if(Array.isArray(u))for(let h of u)h.emotion&&h.url&&h.is_active&&C.set(h.emotion.toLowerCase(),h.url);return e.set(l,C),i.set(l,Date.now()),C}catch(u){console.warn("[publishedAnimationResolver] Failed to fetch active animations:",u?.message);let C=e.get(l)||new Map;return e.set(l,C),i.set(l,Date.now()),C}finally{s.delete(l)}})();return s.set(l,d),d}async function o(l,d="default"){return l&&(await a(d)).get(l.toLowerCase())||null}function c(l,d="default"){if(!l)return null;let u=e.get(d);return(!e.has(d)||r(d))&&(s.has(d)||a(d)),u?.get(l.toLowerCase())||null}function m(){e.clear(),s.clear(),i.clear()}return{prefetch:a,get:o,getSync:c,invalidate:m}}var Dn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Xe=["anger","fear","sadness","joy","disgust"];function On(n){let t=n.toLowerCase();return Xe.includes(t)?1.5:1}function Rn(n){return n.map(([t,e])=>{let s=On(t),i=e*s,r=Xe.includes(t.toLowerCase());return[t,e,i,s,r]})}function Ms(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([m,l])=>Dn.includes(m.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let i=Rn(e).sort(([,,m],[,,l])=>l-m),[r,a,,o,c]=i[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:i,importanceFactor:o,isCore:c}}function Es(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 Is(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function Wn(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),s=parseInt(n.slice(3,5),16),i=parseInt(n.slice(5,7),16);return`rgba(${e}, ${s}, ${i}, ${t})`}function Nn(n,t="",e="",s=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${Wn(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var jn={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function Un(n){return w.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function $e(n=1,t="",e=1,s=""){let{min:i,max:r}=w.wordSpacing,a=parseFloat(i),o=parseFloat(r),m=Un(t).wordSpacingMultiplier;if(n<=1)return`${(a*m).toFixed(3)}em`;let l=Math.max(...Object.values(jn)),d=Math.min(1,(n-1)/(l-1)),u=Math.pow(d,2),h=(a+(o-a)*u)*m;return s==="anger"||s==="screaming"?`${(h*.6).toFixed(3)}em`:`${h.toFixed(3)}em`}function Xn(n=1,t="",e=1,s=""){let i=parseFloat(w.wordSpacing.min),r=parseFloat($e(n,t,e,s)),a=Math.max(0,n-1)*.12;return`${Math.min(r,i+a).toFixed(3)}em`}function gt(n){return n?typeof n.animation_url=="string"&&n.animation_url.length>0||typeof n.emotion=="string"&&n.emotion.trim()!==""&&n.emotion.toLowerCase()!=="none"||typeof n.emotion_intensity=="number":!1}function $n(n,t){let e=gt(n),s=typeof n?.animation_url=="string"&&n.animation_url.length>0?n.animation_url:typeof t?.animation_url=="string"&&t.animation_url.length>0?t.animation_url:null,i=typeof n?.emotion=="string"&&n.emotion.trim()!==""?n.emotion:typeof t?.emotion=="string"&&t.emotion.trim()!==""?t.emotion:null,r=typeof n?.emotion_intensity=="number"?n.emotion_intensity:typeof t?.emotion_intensity=="number"?t.emotion_intensity:null;return{animationUrl:s,emotion:i,emotionIntensity:r,hasWordOverride:e}}var Ye=new Set(["none","neutral"]);function Ve(n){return n?Ye.has(n.toString().toLowerCase().trim()):!0}function ce(n){if(!n)return!1;if(typeof n.animation_url=="string"&&n.animation_url.length>0)return!0;let t=(n.emotion??"").toString().toLowerCase().trim();return!t||Ve(t)?!1:typeof n.emotion_intensity=="number"}function qe(n){let t={...n};return delete t.animation_url,delete t.emotion,delete t.emotion_intensity,t}function ze(n){let t={...n,emotion:"none",emotion_intensity:0};return delete t.animation_url,t}function Yn(n){let t=ze({...n});return Array.isArray(n.words)&&(t.words=n.words.map(e=>qe({...e}))),t}function Vn(n){return n?ce(n)?!0:(n.words||[]).some(t=>gt(t)):!1}function me(n){return n?`phont:manual-animations:${n}`:null}function qn(n){let t=me(n);if(!t||typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="1"}catch{return!1}}function zn(n,t){let e=me(n);if(!(!e||typeof window>"u"))try{t?window.localStorage.setItem(e,"1"):window.localStorage.removeItem(e)}catch{}}function de(n){return n?`phont:manual-soundbites:${n}`:null}function Gn(n){let t=de(n);if(!t||typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="1"}catch{return!1}}function Kn(n,t){let e=de(n);if(!(!e||typeof window>"u"))try{t?window.localStorage.setItem(e,"1"):window.localStorage.removeItem(e)}catch{}}function ue(n){return Math.max(0,Math.min(1,Math.round(n*1e3)/1e3))}function Hn(n,t){let e=0,s=0;for(let i of n)if(ce(i)&&typeof i.emotion_intensity=="number"&&(i.emotion_intensity=ue(i.emotion_intensity*t),e++),!!Array.isArray(i.words))for(let r of i.words)gt(r)&&typeof r.emotion_intensity=="number"&&(r.emotion_intensity=ue(r.emotion_intensity*t),s++);return{segmentCount:e,wordCount:s}}function $t(n){let t=Math.max(0,n.end-n.start);return Math.max(t,p.timing.minWordDisplayTime)}function Ge(n,t){let e=new Array(n.length).fill(null),s=-1/0;for(let i=0;i<n.length;i++){let r=n[i];if(t&&!t(r,i))continue;let a=$t(r),o=Math.max(r.start,s);e[i]={expressiveStart:o,expressiveDuration:a},s=o+a}return e}function Ce(){return w.wordAnimation?.allowOverlap!==!1}function Jn(n,t,e,s=Ce()){let i=$t(t);if(s)return Math.max(0,Math.min(1,(n-t.start)/i));if(!e)return 0;let r=e.expressiveStart,a=e.expressiveDuration;if(n<r)return 0;let o=n-r;return o>=a?0:Math.max(0,Math.min(1,o/a))}function Zn(n,t){let e=typeof n=="number"?n:0;return e+Math.max(0,(typeof t=="number"?t:e)-e)/2}function Qn(n,t,e){if(!Array.isArray(n)||t<0||t>=n.length)return null;let s=n[t];if(!s||typeof s.start!="number")return null;let i=$t(s);if(e?.allowOverlap??Ce())return s.start+i/2;let o=Ge(n,e?.shouldAnimate)[t];return o?o.expressiveStart+o.expressiveDuration/2:s.start+i/2}var ti=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 ei(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 ni(n,t,e){if(!n)return 1;let s=(n.word||n.text||"").trim();if(!s)return 1;let i=s.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!i)return 1;if(ti.has(i)||i.length<=2)return 0;let r=Math.min(1,i.length/7),a=ei(i);return .5*r+.5*a<.55?0:1}function Us({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:s,currentTime:i,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:c=1,fontSize:m=16}){let l=new Array(c).fill(0);return l}function $s(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:s=1.5}={}){let i=Math.abs((n??1)-1);return i<=t?0:Math.min(e,i*s)}function ii(n=0,t=1,e=1){let s=1-.5*Math.min(1,Math.max(0,e??0)),i=Ke(t)*s;return(n??0)+i}function Yt(n,t,e,s,i){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return s+a*(i-s)}function qs(n,t,e=null,s){if(!t)return s||400;let{min:i,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return s||a;let o,c;if(e?.mapping?.volume?(o=e.mapping.volume.min,c=e.mapping.volume.max):(o=i,c=r),s!==void 0){let m=(c-o)/4,l=Yt(n,0,1,-m,m);return Math.round(Math.max(i,Math.min(r,s+l)))}return Math.round(Yt(n,0,1,o,c))}function zs(n,t,e){if(!t)return e||100;let{min:s,max:i,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(i-s)/4,o=Yt(1-n,0,1,-a,a);return Math.round(Math.max(s,Math.min(i,e+o)))}return Math.round(Yt(1-n,0,1,s,i))}var He={},Je={"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 Ze(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=Je[t],s=document.createElement("link");s.rel="stylesheet",s.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(s)}function si(){Object.keys(Je).forEach(n=>Ze(n))}var fe=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 s=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,i=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};i&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(s,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let m=await a.clone().json();if(m.message)o=m.message;else if(m.error)o=m.error;else if(Array.isArray(m.detail)){let l=m.detail.map(d=>{let u=Array.isArray(d.loc)?d.loc.filter(C=>C!=="body").join("."):"";return u?`${u}: ${d.msg||"invalid"}`:d.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof m.detail=="string"&&(o=m.detail)}catch{try{let m=await a.clone().text();m&&(o=m)}catch{}}let c=new Error(o);throw c.status=a.status,c.response=a,c}return a}async login(t,e){let i=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!i.session_id||!i.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=i.auth_token,this.sessionId=i.session_id,i}async register(t,e,s,i){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:s,company:i.company,first_name:i.first_name,last_name:i.last_name})})).json()}async getSubtitleTrack(t,e,s){let i=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&i.append("lang",e.trim()),s&&typeof s=="string"&&s.trim()&&i.append("model",s.trim());let r=i.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{w as ANIMATION_STYLING,X as ANIMATION_URLS,gn as AUTHORED_PLAYBACK_OPTIONS,le as EMOTION_ANIMATION_URLS,Ye as NORMAL_ANIMATION_EMOTIONS,fe as PhontClient,Dt as REFERENCE_GTS,Me as REFERENCE_INTENSITY,p as RENDERING_CONTROL,Pt as SubtitleManager,Tt as SubtitleStateManager,Ge as buildSequentialExpressiveSchedule,ht as calculateAnimationParameters,Fn as calculateAnimationState,$e as calculateDynamicWordSpacing,Ee as calculateEmphasisMultiplier,ee as calculateGTSValues,Ji as calculateJoy,Zi as calculateJoyBulge,Is as calculateNormalizedTime,Xn as calculatePerWordSpacing,qs as calculateWeightFromVolume,zs as calculateWidthFromSpeechRate,Pe as calculateWordEmphasisEffects,Jn as calculateWordExpressiveProgress,Us as calculateWordLetterSpacing,_e as capEmotionIntensity,ue as clampAnimationIntensity,ze as clearSegmentAnimationFields,qe as clearWordAnimationFields,ni as computeProsodyWeight,mn as createBitmovinLiveSegmentSource,un as createHlsLiveSegmentSource,lt as createLiveSegmentSource,Bn as createPublishedAnimationResolver,cn as createShakaLiveSegmentSource,te as decodeAnimationUrl,Ze as ensureFont,re as findSubtitleForWord,Nn as generateTextShadow,Pn as getAnimationUrlForEmotion,ii as getCombinedBlurAmount,Ht as getCurrentAuthToken,Jt as getCurrentSessionId,ae as getFontFamilyCSS,Oe as getJoyAnimationMode,ts as getJoyFilter,Qi as getJoyTransform,me as getManualAnimationsStorageKey,de as getManualSoundbitesStorageKey,jt as getMergedSubtitles,Ke as getMotionBlurAmount,Zn as getSegmentAnimationPreviewTime,Nt as getSubtitleAnimations,Wt as getSubtitleText,Es as getSubtitleTiming,se as getSubtitleWords,Qn as getWordAnimationPreviewTime,An as getWordEmphasis,$t as getWordExpressiveDuration,it as hasMergedSubtitles,ce as hasSegmentAnimationOverride,gt as hasWordAnimationOverride,fn as hockeyStickIntensity,Ie as isInEmphasisRange,Le as isInStrongEmphasisRange,Ve as isNormalAnimationEmotion,ve as isSubtitleDebugEnabled,Ce as isWordAnimationOverlapAllowed,Qt as logSubtitleData,Vi as meetsEmotionThreshold,si as preloadAnimationFonts,Rt as processEmotionsWithImportance,qn as readManualAnimationsPreference,Gn as readManualSoundbitesPreference,Yn as resetSubtitleToNormal,Ot as resolveEffectiveGts,$n as resolveWordAnimationSource,ft as sampleParameterCurve,Hn as scaleAuthorAnimationIntensities,Ms as selectEmotion,xn as selectFontFamily,ls as shouldUseAngryFont,us as shouldUseJoyFont,cs as shouldUseSadnessFont,$s as splitTextIntoLetters,Vn as subtitleHasAnyAnimationOverride,ln as subtitleManager,zn as writeManualAnimationsPreference,Kn as writeManualSoundbitesPreference};
|