1function y(e,t="Speaker"){const r=String(e??"").trim();if(!r)return"";const n=r.match(/^SPEAKER[_\s-]?(\d+)$/i);return n?`${t} ${Number(n[1])+1}`:r}function Z(e){return Array.isArray(e)?e.map((t,r)=>{const n=Number(t?.start),a=Number.isFinite(n)?n:0,o=String(t?.speaker??"").trim();return{id:`segment-${r}-${Math.round(a*1e3)}`,start:a,text:String(t?.text??"").trim(),...o?{speaker:o}:{}}}).filter(t=>t.text):[]}const v=Object.freeze({minChars:60,idealChars:180,maxChars:320,maxSeconds:20});function h(e){return String(e||"").replace(/\s+/g," ").replace(/([ã-é¿¿])\s+([ã-é¿¿])/g,"$1$2").replace(/([ï¼ãï¼ï¼ï¼ï¼])\s+(?=[ã-é¿¿])/g,"$1").replace(/\s+([,.;:!?ï¼ãï¼ï¼ï¼ï¼])/g,"$1").trim()}function I(e,t){const r=[];let n=h(e);for(;n.length>t;){const a=n.slice(0,t+1),o=Math.floor(t*.55);let i=-1;for(const s of[/[;:ï¼ï¼]\s*/g,/[,ï¼]\s*/g,/\s/g]){s.lastIndex=0;let c;for(;c=s.exec(a);)c.index>=o&&(i=c.index+c[0].length);if(i>0)break}i<=0&&(i=t),r.push(n.slice(0,i).trim()),n=n.slice(i).trim()}return n&&r.push(n),r}function K(e,t=v){if(!Array.isArray(e)||e.length===0)return[];const r=[];e.forEach(i=>{const s=h(i?.text);if(!s)return;const c=Number.isFinite(Number(i.start))?Number(i.start):0,u=Number(i.end),l=Number.isFinite(u)&&u>c?u-c:0,p=String(i?.speaker??"").trim(),d=s.match(/[^.!?;:,ãï¼ï¼ï¼ï¼ï¼]+(?:[.!?;:,ãï¼ï¼ï¼ï¼ï¼]+["')\]ââï¼ããã]*|$)/g)||[s];let g=0;d.forEach(L=>{const S=h(L);if(!S)return;const x=I(S,t.maxChars);x.forEach(f=>{const E=s.length?Math.min(1,g/s.length):0;r.push({text:f,start:c+l*E,semanticEnd:/[.!?ãï¼ï¼]["')\]ââï¼ããã]*$/.test(f)||x.length>1,clauseEnd:/[;:,ï¼ï¼ï¼]["')\]ââï¼ããã]*$/.test(f),speaker:p}),g+=f.length+1})})});const n=[];let a=null;const o=()=>{if(!a||!a.text.trim())return;const i=n.length;n.push({id:`paragraph-${i}-${Math.round(a.start*1e3)}`,start:a.start,text:h(a.text),...a.speaker?{speaker:a.speaker}:{}}),a=null};return r.forEach(i=>{a&&a.speaker!==i.speaker&&o(),a||(a={start:i.start,text:"",speaker:i.speaker}),a.text=h(`${a.text} ${i.text}`);const s=Math.max(0,i.start-a.start),c=a.text.length>=t.minChars,u=a.text.length>=t.idealChars,l=i.semanticEnd||i.clauseEnd&&(u||a.text.length>=t.maxChars||s>=t.maxSeconds),p=l&&(a.text.length>=t.maxChars||s>=t.maxSeconds),d=a.text.length>=Math.round(t.maxChars*1.2)||s>=t.maxSeconds+5;(l&&(c||s>=8)||l&&u||p||d)&&o()}),o(),n}function M(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function m(e){return _(e).replace(/<(\/?)(i|em|b|strong|u)>|<br(?:\s*\/)?>/gi,(t,r,n)=>n?`<${r}${String(n).toLowerCase()}>`:"<br>")}function J(e,t){const r=t.trim();if(!r)return m(e);const n=new RegExp(M(r),"gi");let a="",o=0,i;for(;i=n.exec(e);)a+=m(e.slice(o,i.index)),a+=`<mark class="transcript-hit">${_(i[0])}</mark>`,o=i.index+i[0].length,i[0].length===0&&n.lastIndex++;return a+=m(e.slice(o)),a}function Q(e,t){const r=t.trim();return r?(e.match(new RegExp(M(r),"gi"))||[]).length:0}function $(e){const t=String(e||"").slice(0,2e3);if(!t.trim())return"unknown";const r=i=>(t.match(i)||[]).length,n=[["kana",r(/[ã-ãã -ã¿]/g)],["hangul",r(/[ê°-í¯á-á¿]/g)],["han",r(/[ã-ä¶¿ä¸-é¿¿]/g)],["cyrillic",r(/[Ð-Ó¿]/g)],["arabic",r(/[Ø-Û¿Ý-Ý¿]/g)],["thai",r(/[à¸-๿]/g)],["devanagari",r(/[à¤-ॿ]/g)],["latin",r(/[A-Za-z]/g)]],[a,o]=n.reduce((i,s)=>s[1]>i[1]?s:i);return o>=8?a:"unknown"}function N(e){const t=e.toLowerCase();return t.startsWith("zh")?"han":t.startsWith("ja")?"kana":t.startsWith("ko")?"hangul":/^(ru|uk|bg|sr|mk|be|kk|mn)/.test(t)?"cyrillic":/^(ar|fa|ur|ps)/.test(t)?"arabic":t.startsWith("th")?"thai":/^(hi|mr|ne)/.test(t)?"devanagari":null}function X(e,t){if(!e)return!1;const r=N(e);if(!r){const a=$(t);return a==="latin"||a==="unknown"}const n=$(t);return n==="unknown"||n===r}const z=["zh-CN","zh-TW","en","ja","ko","es","fr","de"];function tt(e){const t=String(e||"").trim().toLowerCase().replace("_","-");if(!t)return;if(t.startsWith("zh"))return/hant|tw|hk|mo/.test(t)?"zh-TW":"zh-CN";const r=t.split("-")[0];return z.find(n=>n.toLowerCase()===r)}function et(e){const t=String(e??"").trim();if(!/^\d{1,2}(:\d{1,2}){1,2}$/.test(t))return null;const n=t.split(":").map(Number).reduce((a,o)=>a*60+o,0);return Number.isFinite(n)?n:null}
1function A(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60);return t>0?`${t.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}function R(e){if(e==null||!Number.isFinite(e)||e<0)return"--";const t=Math.floor(e/3600),r=Math.floor(e%3600/60);return t>0?r>0?`${t} hr ${r} min`:`${t} hr`:`${r} min`}function P(e){if(!e)return"--";const t=new Date(e),r=new Date,n=t.getDate()===r.getDate()&&t.getMonth()===r.getMonth()&&t.getFullYear()===r.getFullYear(),a=t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0});return n?`Today at ${a}`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function j(e){if(!e)return"";try{const t=new URL(e),r=t.hostname.replace(/^www\./,"").toLowerCase();let n="";return r==="youtu.be"?n=t.pathname.slice(1):(r.endsWith("youtube.com")||r.endsWith("youtube-nocookie.com"))&&(t.pathname==="/watch"?n=t.searchParams.get("v")||"":n=t.pathname.match(/^\/(?:embed|shorts|live|v)\/([^/]+)/)?.[1]||""),/^[A-Za-z0-9_-]{6,20}$/.test(n)?n:""}catch{return""}}function U(e){return!e||typeof e!="string"?!1:/youtube\.com|youtu\.be|vimeo\.com|dailymotion\.com|bilibili\.com|twitter\.com|twitch\.tv|facebook\.com\/.*\/videos|instagram\.com/i.test(e.toLowerCase())}function W(e){if(!e)return"";const t=(e.original_media_url||"").trim(),r=(e.audio_url||"").trim();return t||r||""}function b(e){if(!e)return 0;const t=e.toString().trim().replace(",","."),r=t.split(":");let n=0,a=0,o=0;return r.length===3?(n=parseInt(r[0],10)||0,a=parseInt(r[1],10)||0,o=parseFloat(r[2])||0):r.length===2?(a=parseInt(r[0],10)||0,o=parseFloat(r[1])||0):o=parseFloat(t)||0,n*3600+a*60+o}function F(e){if(!e||typeof e!="string")return[];const t=e.replace(/\r/g,"").split(` 2`),r=[];let n=0;for(;n<t.length;){let a=t[n].trim();if(a===""||a.toUpperCase()==="WEBVTT"){n++;continue}if(!a.includes("-->")&&n+1<t.length&&t[n+1].includes("-->")&&(n++,a=t[n].trim()),a.includes("-->")){const[o,i]=a.split("-->").map(l=>l.trim()),s=b(o),c=b(i);n++;const u=[];for(;n<t.length&&t[n].trim()!=="";)u.push(t[n]),n++;r.push({start:s,end:c,text:u.join(` 3`)})}for(;n<t.length&&t[n].trim()==="";)n++}return r}function k(e){if(!e)return 0;const t=e.toString().trim().match(/(\d{2}):(\d{2}):(\d{2}),(\d{3})/);if(!t)return 0;const r=parseInt(t[1],10)||0,n=parseInt(t[2],10)||0,a=parseInt(t[3],10)||0,o=parseInt(t[4],10)||0;return r*3600+n*60+a+o/1e3}function O(e){if(!e||typeof e!="string")return[];const t=e.replace(/\r/g,"").split(/\n\s*\n/),r=[];for(const n of t){const a=n.split(` 4`).map(u=>u.trim()).filter(Boolean);if(a.length<2)continue;let o=0;/^\d+$/.test(a[0])&&(o=1);const i=a[o];if(!i||!i.includes("-->"))continue;const[s,c]=i.split("-->").map(u=>u.trim());r.push({start:k(s),end:k(c),text:a.slice(o+1).join(` 5`)})}return r}function w(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=Math.floor(e%1*1e3);return`${t.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")},${a.toString().padStart(3,"0")}`}function T(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=Math.floor(e%60),a=Math.floor(e%1*1e3);return`${t.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}.${a.toString().padStart(3,"0")}`}function C(e){let t;return(e||[]).map(r=>{const n=String(r?.speaker??"").trim(),a=n!==""&&n!==t;return n&&(t=n),a?{...r,text:`${y(n)}: ${String(r.text??"").trim()}`}:r})}function B(e){return C(e).map((t,r)=>{const n=w(t.start),a=w(t.end);return`${r+1} 6${n} --> ${a} 7${t.text} 8`}).join(` 9`)}function V(e){let t=`WEBVTT 10 11`;return t+=C(e).map(r=>{const n=T(r.start),a=T(r.end);return`${n} --> ${a} 12${r.text} 13`}).join(` 14`),t}function G(e){const t=[];let r;for(const n of e||[]){const a=(n?.text||"").trim();if(!a)continue;const o=String(n?.speaker??"").trim();
14o&&o!==r&&(t.length&&t.push(""),t.push(`${y(o)}:`)),o&&(r=o),t.push(a)}return t.join(` 15`)}function D(e){return e?!!(e.translated_json_url||e.translated_vtt_url||e.translated_srt_url||e.translated_text_url||e.translated_text||e.translated):!1}const H=["completed","partial_completed","failed"];function q(e){return e==="pending"||e==="processing"}function Y(e,t,r="text/plain"){const n=new Blob([e],{type:r}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)}const rt=Object.freeze(Object.defineProperty({__proto__:null,TERMINAL_STATUSES:H,downloadTextFile:Y,formatCreatedAt:P,formatDuration:R,formatTimestamp:A,generatePlainText:G,generateSrt:B,generateVtt:V,getPlayMediaUrl:W,hasTranslation:D,isProcessingStatus:q,isThirdPartyMediaUrl:U,parseSrtToSegments:O,parseVttToSegments:F,youtubeVideoId:j},Symbol.toStringTag,{value:"Module"}));export{H as T,P as a,A as b,y as c,G as d,B as e,R as f,K as g,D as h,q as i,V as j,W as k,X as l,U as m,tt as n,Q as o,et as p,Y as q,J as r,rt as s,Z as t,j as y};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.