/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/srt-parser-2@1.2.3/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
class Parser{seperator=",";timestampToSeconds(t){const[r,e]=t.split(","),i=parseInt(e),[s,d,a]=r.split(":").map((t=>parseInt(t))),n=.001*i+a+60*d+3600*s;return Math.round(1e3*n)/1e3}correctFormat(t){let r=t.replace(".",",");var e,[i,s]=r.split(",");e=this.fixed_str_digit(3,s);var[d,a,n]=i.split(":");return`${this.fixed_str_digit(2,d,!1)}:${this.fixed_str_digit(2,a,!1)}:${this.fixed_str_digit(2,n,!1)},${e}`}fixed_str_digit(t,r,e=!0){return r.length==t?r:r.length>t?r.slice(0,t):r.length<t?e?r.padEnd(t,"0"):r.padStart(t,"0"):void 0}tryComma(t){let r=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return r.shift(),r}tryDot(t){let r=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return r.shift(),this.seperator=".",r}fromSrt(t){var r=t,e=this.tryComma(r);0==e.length&&(e=this.tryDot(r));for(var i=[],s=0;s<e.length;s+=4){const t=this.correctFormat(e[s+1].trim()),r=this.correctFormat(e[s+2].trim());var d={id:e[s].trim(),startTime:t,startSeconds:this.timestampToSeconds(t),endTime:r,endSeconds:this.timestampToSeconds(r),text:e[s+3].trim()};i.push(d)}return i}toSrt(t){var r="";const e="\r\n";for(var i=0;i<t.length;i++){var s=t[i];r+=s.id+e,r+=s.startTime+" --\x3e "+s.endTime+e,r+=s.text.replace("\n",e)+e+e}return r}}export default Parser;
//# sourceMappingURL=/sm/92fb5930d4b9ca1ac0480fea918422c6278defc4fc536e3060f6779e551d6c75.map