#!/usr/bin/env node import{createRequire as Xu}from"node:module";var qu=Object.create;var{getPrototypeOf:Zu,defineProperty:qD,getOwnPropertyNames:Lu}=Object;var Qu=Object.prototype.hasOwnProperty;var g=(u,D,F)=>{F=u!=null?qu(Zu(u)):{};let C=D||!u||!u.__esModule?qD(F,"default",{value:u,enumerable:!0}):F;for(let E of Lu(u))if(!Qu.call(C,E))qD(C,E,{get:()=>u[E],enumerable:!0});return C};var I=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var N=Xu(import.meta.url);var RD=I((hF,ID)=>{class GD{constructor(u,D,F){this.etaBufferLength=u||100,this.valueBuffer=[F],this.timeBuffer=[D],this.eta="0"}update(u,D,F){this.valueBuffer.push(D),this.timeBuffer.push(u),this.calculate(F-D)}getTime(){return this.eta}calculate(u){let D=this.valueBuffer.length,F=Math.min(this.etaBufferLength,D),C=this.valueBuffer[D-1]-this.valueBuffer[D-F],E=this.timeBuffer[D-1]-this.timeBuffer[D-F],A=C/E;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let B=Math.ceil(u/A/1000);if(isNaN(B))this.eta="NULL";else if(!isFinite(B))this.eta="INF";else if(B>1e7)this.eta="INF";else if(B<0)this.eta=0;else this.eta=B}}ID.exports=GD});var a=I((PF,xD)=>{var k=N("readline");class $D{constructor(u){this.stream=u,this.linewrap=!0,this.dy=0}cursorSave(){if(!this.stream.isTTY)return;this.stream.write("\x1B7")}cursorRestore(){if(!this.stream.isTTY)return;this.stream.write("\x1B8")}cursor(u){if(!this.stream.isTTY)return;if(u)this.stream.write("\x1B[?25h");else this.stream.write("\x1B[?25l")}cursorTo(u=null,D=null){if(!this.stream.isTTY)return;k.cursorTo(this.stream,u,D)}cursorRelative(u=null,D=null){if(!this.stream.isTTY)return;this.dy=this.dy+D,k.moveCursor(this.stream,u,D)}cursorRelativeReset(){if(!this.stream.isTTY)return;k.moveCursor(this.stream,0,-this.dy),k.cursorTo(this.stream,0,null),this.dy=0}clearRight(){if(!this.stream.isTTY)return;k.clearLine(this.stream,1)}clearLine(){if(!this.stream.isTTY)return;k.clearLine(this.stream,0)}clearBottom(){if(!this.stream.isTTY)return;k.clearScreenDown(this.stream)}newline(){this.stream.write(` `),this.dy++}write(u,D=!1){if(this.linewrap===!0&&D===!1)this.stream.write(u.substr(0,this.getWidth()));else this.stream.write(u)}lineWrapping(u){if(!this.stream.isTTY)return;if(this.linewrap=u,u)this.stream.write("\x1B[?7h");else this.stream.write("\x1B[?7l")}isTTY(){return this.stream.isTTY===!0}getWidth(){return this.stream.columns||(this.stream.isTTY?80:200)}}xD.exports=$D});var UD=I((fF,HD)=>{HD.exports=({onlyFirst:u=!1}={})=>{let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}});var _D=I((cF,WD)=>{var Vu=UD();WD.exports=(u)=>typeof u==="string"?u.replace(Vu(),""):u});var yD=I((gF,p)=>{var kD=(u)=>{if(Number.isNaN(u))return!1;if(u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141))return!0;return!1};p.exports=kD;p.exports.default=kD});var MD=I((mF,VD)=>{VD.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var SD=I((dF,s)=>{var Mu=_D(),zu=yD(),Su=MD(),zD=(u)=>{if(typeof u!=="string"||u.length===0)return 0;if(u=Mu(u),u.length===0)return 0;u=u.replace(Su()," ");let D=0;for(let F=0;F=127&&C<=159)continue;if(C>=768&&C<=879)continue;if(C>65535)F++;D+=zu(C)?2:1}return D};s.exports=zD;s.exports.default=zD});var n=I((lF,ND)=>{ND.exports=function(D,F,C){if(F.autopadding!==!0)return D;function E(A,B){return(F.autopaddingChar+A).slice(-B)}switch(C){case"percentage":return E(D,3);default:return D}}});var r=I((aF,wD)=>{wD.exports=function(D,F){let C=Math.round(D*F.barsize),E=F.barsize-C;return F.barCompleteString.substr(0,C)+F.barGlue+F.barIncompleteString.substr(0,E)}});var i=I((pF,jD)=>{jD.exports=function(D,F,C){function E(B){if(C)return C*Math.round(B/C);else return B}function A(B){return(F.autopaddingChar+B).slice(-2)}if(D>3600)return A(Math.floor(D/3600))+"h"+A(E(D%3600/60))+"m";else if(D>60)return A(Math.floor(D/60))+"m"+A(E(D%60))+"s";else if(D>10)return A(E(D))+"s";else return A(D)+"s"}});var t=I((sF,TD)=>{var Nu=SD(),wu=n(),ju=r(),Tu=i();TD.exports=function(D,F,C){let E=D.format,A=D.formatTime||Tu,B=D.formatValue||wu,q=D.formatBar||ju,Q=Math.floor(F.progress*100)+"",Z=F.stopTime||Date.now(),L=Math.round((Z-F.startTime)/1000),K=Object.assign({},C,{bar:q(F.progress,D),percentage:B(Q,D,"percentage"),total:B(F.total,D,"total"),value:B(F.value,D,"value"),eta:B(F.eta,D,"eta"),eta_formatted:A(F.eta,D,5),duration:B(L,D,"duration"),duration_formatted:A(L,D,1)});E=E.replace(/\{(\w+)\}/g,function(Y,R){if(typeof K[R]<"u")return K[R];return Y});let X=Math.max(0,F.maxWidth-Nu(E)-2),G=Math.floor(X/2);switch(D.align){case"right":E=X>0?" ".repeat(X)+E:E;break;case"center":E=G>0?" ".repeat(G)+E:E;break;case"left":default:break}return E}});var f=I((nF,OD)=>{function J(u,D){if(typeof u>"u"||u===null)return D;else return u}OD.exports={parse:function(D,F){let C={},E=Object.assign({},F,D);return C.throttleTime=1000/J(E.fps,10),C.stream=J(E.stream,process.stderr),C.terminal=J(E.terminal,null),C.clearOnComplete=J(E.clearOnComplete,!1),C.stopOnComplete=J(E.stopOnComplete,!1),C.barsize=J(E.barsize,40),C.align=J(E.align,"left"),C.hideCursor=J(E.hideCursor,!1),C.linewrap=J(E.linewrap,!1),C.barGlue=J(E.barGlue,""),C.barCompleteChar=J(E.barCompleteChar,"="),C.barIncompleteChar=J(E.barIncompleteChar,"-"),C.format=J(E.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),C.formatTime=J(E.formatTime,null),C.formatValue=J(E.formatValue,null),C.formatBar=J(E.formatBar,null),C.etaBufferLength=J(E.etaBuffer,10),C.etaAsynchronousUpdate=J(E.etaAsynchronousUpdate,!1),C.progressCalculationRelative=J(E.progressCalculationRelative,!1),C.synchronousUpdate=J(E.synchronousUpdate,!0),C.noTTYOutput=J(E.noTTYOutput,!1),C.notTTYSchedule=J(E.notTTYSchedule,2000),C.emptyOnZero=J(E.emptyOnZero,!1),C.forceRedraw=J(E.forceRedraw,!1),C.autopadding=J(E.autopadding,!1),C.gracefulExit=J(E.gracefulExit,!1),C},assignDerivedOptions:function(D){return D.barCompleteString=D.barCompleteChar.repeat(D.barsize+1),D.barIncompleteString=D.barIncompleteChar.repeat(D.barsize+1),D.autopaddingChar=D.autopadding?J(D.autopaddingChar," "):"",D}}});var e=I((rF,vD)=>{var bD=RD(),Ou=a(),bu=t(),vu=f(),hu=N("events");vD.exports=class extends hu{constructor(D){super();this.options=vu.assignDerivedOptions(D),this.terminal=this.options.terminal?this.options.terminal:new Ou(this.options.stream),this.value=0,this.startValue=0,this.total=100,this.lastDrawnString=null,this.startTime=null,this.stopTime=null,this.lastRedraw=Date.now(),this.eta=new bD(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format==="function"?this.options.format:bu}render(D=!1){let F={progress:this.getProgress(),eta:this.eta.getTime(),startTime:this.startTime,stopTime:this.stopTime,total:this.total,value:this.value,maxWidth:this.terminal.getWidth()};if(this.options.etaAsynchronousUpdate)this.updateETA();let C=this.formatter(this.options,F,this.payload);if(D||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=C)this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(C),this.terminal.clearRight(),this.lastDrawnString=C,this.lastRedraw=Date.now(),this.emit("redraw-post")}start(D,F,C){this.value=F||0,this.total=typeof D<"u"&&D>=0?D:100,this.startValue=F||0,this.payload=C||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new bD(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",D,F)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(D,F={}){if(typeof D==="number")this.value=D,this.eta.update(Date.now(),D,this.total);let C=(typeof D==="object"?D:F)||{};this.emit("update",this.total,this.value);for(let E in C)this.payload[E]=C[E];if(this.value>=this.getTotal()&&this.options.stopOnComplete)this.stop()}getProgress(){let D=this.value/this.total;if(this.options.progressCalculationRelative)D=(this.value-this.startValue)/(this.total-this.startValue);if(isNaN(D))D=this.options&&this.options.emptyOnZero?0:1;return D=Math.min(Math.max(D,0),1),D}increment(D=1,F={}){if(typeof D==="object")this.update(this.value+1,D);else this.update(this.value+D,F)}getTotal(){return this.total}setTotal(D){if(typeof D<"u"&&D>=0)this.total=D}updateETA(){this.eta.update(Date.now(),this.value,this.total)}}});var PD=I((iF,hD)=>{var Pu=e(),fu=f();hD.exports=class extends Pu{constructor(D,F){super(fu.parse(D,F));if(this.timer=null,this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.options.synchronousUpdate=!1;this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.sigintCallback=null}render(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(super.render(),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline();this.timer=setTimeout(this.render.bind(this),this.schedulingRate)}update(D,F){if(!this.timer)return;if(super.update(D,F),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2{var cu=a(),gu=e(),mu=f(),du=N("events");fD.exports=class extends du{constructor(D,F){super();this.bars=[],this.options=mu.parse(D,F),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new cu(this.options.stream),this.timer=null,this.isActive=!1,this.schedulingRate=this.terminal.isTTY()?this.options.throttleTime:this.options.notTTYSchedule,this.loggingBuffer=[],this.sigintCallback=null}create(D,F,C,E={}){let A=new gu(Object.assign({},this.options,{terminal:this.terminal},E));if(this.bars.push(A),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return A;if(this.sigintCallback===null&&this.options.gracefulExit)this.sigintCallback=this.stop.bind(this),process.once("SIGINT",this.sigintCallback),process.once("SIGTERM",this.sigintCallback);if(!this.isActive){if(this.options.hideCursor===!0)this.terminal.cursor(!1);if(this.options.linewrap===!1)this.terminal.lineWrapping(!1);this.timer=setTimeout(this.update.bind(this),this.schedulingRate)}return this.isActive=!0,A.start(D,F,C),this.emit("start"),A}remove(D){let F=this.bars.indexOf(D);if(F<0)return!1;return this.bars.splice(F,1),this.update(),this.terminal.newline(),this.terminal.clearBottom(),!0}update(){if(this.timer)clearTimeout(this.timer),this.timer=null;if(this.emit("update-pre"),this.terminal.cursorRelativeReset(),this.emit("redraw-pre"),this.loggingBuffer.length>0){this.terminal.clearLine();while(this.loggingBuffer.length>0)this.terminal.write(this.loggingBuffer.shift(),!0)}for(let D=0;D0)this.terminal.newline();this.bars[D].render()}if(this.emit("redraw-post"),this.options.noTTYOutput&&this.terminal.isTTY()===!1)this.terminal.newline(),this.terminal.newline();if(this.timer=setTimeout(this.update.bind(this),this.schedulingRate),this.emit("update-post"),this.options.stopOnComplete&&!this.bars.find((D)=>D.isActive))this.stop()}stop(){if(clearTimeout(this.timer),this.timer=null,this.sigintCallback)process.removeListener("SIGINT",this.sigintCallback),process.removeListener("SIGTERM",this.sigintCallback),this.sigintCallback=null;if(this.isActive=!1,this.options.hideCursor===!0)this.terminal.cursor(!0);if(this.options.linewrap===!1)this.terminal.lineWrapping(!0);if(this.terminal.cursorRelativeReset(),this.emit("stop-pre-clear"),this.options.clearOnComplete)this.terminal.clearBottom();else{for(let D=0;D0)this.terminal.newline();this.bars[D].render(),this.bars[D].stop()}this.terminal.newline()}this.emit("stop")}log(D){this.loggingBuffer.push(D)}}});var mD=I((eF,gD)=>{gD.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var lD=I((oF,dD)=>{dD.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var pD=I((DC,aD)=>{aD.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var nD=I((uC,sD)=>{sD.exports={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "}});var iD=I((FC,rD)=>{var lu=mD(),au=lD(),pu=pD(),su=nD();rD.exports={legacy:lu,shades_classic:au,shades_grey:pu,rect:su}});var oD=I((CC,eD)=>{var tD=PD(),nu=cD(),ru=iD(),iu=t(),tu=n(),eu=r(),ou=i();eD.exports={Bar:tD,SingleBar:tD,MultiBar:nu,Presets:ru,Format:{Formatter:iu,BarFormat:eu,ValueFormat:tu,TimeFormat:ou}}});import{join as KD,basename as Uu,extname as Wu}from"node:path";import{randomUUID as _u}from"node:crypto";import{rm as ku}from"node:fs/promises";import{spawn as w}from"node:child_process";async function y(){return new Promise((u)=>{let D=w("ffmpeg",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function V(){return new Promise((u)=>{let D=w("MP4Box",["-version"]);D.on("error",()=>u(!1)),D.on("close",(F)=>u(F===0))})}async function M(){return new Promise((u)=>{let D=w("ffmpeg",["-hide_banner","-encoders"]),F="";D.stdout.on("data",(C)=>{F+=C.toString()}),D.on("error",()=>u(!1)),D.on("close",(C)=>{if(C!==0)u(!1);else u(F.includes("h264_nvenc")||F.includes("hevc_nvenc"))})})}async function z(u,D,F){return new Promise((C,E)=>{let A=w("ffmpeg",u),B="";A.stderr.on("data",(q)=>{let Q=q.toString();if(B+=Q,D&&F){let Z=Q.match(/time=(\d{2}):(\d{2}):(\d{2}\.\d{2})/);if(Z){let L=parseInt(Z[1]),K=parseInt(Z[2]),X=parseFloat(Z[3]),G=L*3600+K*60+X,Y=Math.min(100,G/F*100);D(Y)}}}),A.on("error",(q)=>{E(Error(`FFmpeg error: ${q.message}`))}),A.on("close",(q)=>{if(q===0)C();else E(Error(`FFmpeg failed with exit code ${q} ${B}`))})})}async function m(u){return new Promise((D,F)=>{let C=w("MP4Box",u),E="",A="";C.stdout.on("data",(B)=>{E+=B.toString()}),C.stderr.on("data",(B)=>{A+=B.toString()}),C.on("error",(B)=>{F(Error(`MP4Box error: ${B.message}`))}),C.on("close",(B)=>{if(B===0)D();else F(Error(`MP4Box failed with exit code ${B} ${A||E}`))})})}import{spawn as Yu}from"node:child_process";async function b(u){return new Promise((D,F)=>{let C=Yu("ffprobe",["-v","error","-select_streams","v:0","-show_entries","stream=width,height,duration,r_frame_rate,codec_name","-select_streams","a:0","-show_entries","stream=bit_rate","-show_entries","format=duration","-of","json",u]),E="";C.stdout.on("data",(A)=>{E+=A.toString()}),C.on("error",(A)=>{F(Error(`ffprobe error: ${A.message}`))}),C.on("close",(A)=>{if(A!==0){F(Error(`ffprobe failed with exit code ${A}`));return}try{let B=JSON.parse(E),q=B.streams.find((R)=>R.width!==void 0),Q=B.streams.find((R)=>R.bit_rate!==void 0&&R.width===void 0),Z=B.format,[L,K]=q.r_frame_rate.split("/").map(Number),X=L/K,G=parseFloat(q.duration||Z.duration||"0"),Y=Q?.bit_rate?Math.round(parseInt(Q.bit_rate)/1000):void 0;D({width:q.width,height:q.height,duration:G,fps:X,codec:q.codec_name,audioBitrate:Y})}catch(B){F(Error(`Failed to parse ffprobe output: ${B}`))}})})}function v(u,D=256){if(!u)return`${D}k`;let F=Math.min(u,D);if(F<=64)return"64k";if(F<=96)return"96k";if(F<=128)return"128k";if(F<=192)return"192k";return"256k"}function h(u){let D=Math.floor(u/3600),F=Math.floor(u%3600/60),C=u%60;return`${String(D).padStart(2,"0")}:${String(F).padStart(2,"0")}:${C.toFixed(3).padStart(6,"0")}`}import{mkdir as Ju,exists as Ku}from"node:fs/promises";async function P(u){if(!await Ku(u))await Ju(u,{recursive:!0})}var ZD=[{name:"1080p",width:1920,height:1080,videoBitrate:"5000k",audioBitrate:"256k"},{name:"720p",width:1280,height:720,videoBitrate:"3000k",audioBitrate:"256k"},{name:"480p",width:854,height:480,videoBitrate:"1500k",audioBitrate:"256k"},{name:"360p",width:640,height:360,videoBitrate:"800k",audioBitrate:"256k"}];function d(u,D){return ZD.filter((F)=>{return F.width<=u&&F.height<=D})}import{join as W}from"node:path";import{readdir as Gu,unlink as LD,rmdir as Iu}from"node:fs/promises";async function QD(u,D,F,C){let{width:E,height:A,interval:B,columns:q}=C,Q=W(D,".thumbnails_temp");await Bun.write(W(Q,".keep"),"");let Z=W(Q,"thumb_%04d.jpg");await z(["-i",u,"-vf",`fps=1/${B},scale=${E}:${A}`,"-q:v","5",Z]);let K=(await Gu(Q)).filter((x)=>x.startsWith("thumb_")&&x.endsWith(".jpg")).sort();if(K.length===0)throw Error("No thumbnails generated");let X=K.length,G=Math.ceil(X/q),Y=W(D,"thumbnails.jpg"),R=`tile=${q}x${G}`;await z(["-i",Z,"-filter_complex",R,"-q:v","5",Y]);let $=W(D,"thumbnails.vtt"),j=Ru(X,B,E,A,q,"thumbnails.jpg");await Bun.write($,j);for(let x of K)await LD(W(Q,x));return await LD(W(Q,".keep")),await Iu(Q),{spritePath:Y,vttPath:$}}function Ru(u,D,F,C,E,A){let B=`WEBVTT `;for(let q=0;q ${h(Z)} `,B+=`${A}#xywh=${X},${G},${F},${C} `}return B}import{join as $u}from"node:path";async function XD(u,D,F,C,E,A,B,q,Q,Z,L){let K=$u(D,`video_${F.name}.mp4`),X=["-y","-i",u,"-c:v",C];if(C==="h264_nvenc")X.push("-rc:v","vbr"),X.push("-preset",E),X.push("-2pass","0");else X.push("-preset",E);X.push("-b:v",F.videoBitrate,"-maxrate",F.videoBitrate,"-bufsize",`${parseInt(F.videoBitrate)*2}k`);let G=Math.round(q*B);X.push("-g",String(G),"-keyint_min",String(G),"-sc_threshold","0");let Y=[`scale=${F.width}:${F.height}`];if(Z){if(Z.deinterlace)Y.push("yadif");if(Z.denoise)Y.push("hqdn3d");if(Z.customFilters)Y.push(...Z.customFilters)}X.push("-vf",Y.join(","));let R=parseInt(F.audioBitrate)||256,$=v(Q,R);if(X.push("-c:a","aac","-b:a",$),Z?.audioNormalize)X.push("-af","loudnorm");return X.push("-f","mp4",K),await z(X,L,A),K}async function YD(u,D,F,C,E,A,B,q,Q,Z,L,K,X){let G=new Map;if(Z&&F.length>1)for(let Y=0;YXD(u,D,x,C,E,A,B,q,Q,K,(S)=>{if(X)X(x.name,S)}));(await Promise.all($)).forEach((x,S)=>{let T=R[S];G.set(T.name,x)})}else for(let Y of F){let R=await XD(u,D,Y,C,E,A,B,q,Q,K,($)=>{if(X)X(Y.name,$)});G.set(Y.name,R)}return G}import{join as _}from"node:path";async function JD(u,D,F,C){let E=_(D,"manifest.mpd"),A=["-dash",String(C*1000),"-frag",String(C*1000),"-rap","-segment-name","$RepresentationID$_$Number$","-out",E];for(let B of F){let q=u.get(B.name);if(!q)throw Error(`MP4 file not found for profile: ${B.name}`);if(A.push(`${q}#video:id=${B.name}`),B===F[0])A.push(`${q}#audio:id=audio`)}return await m(A),await xu(D,F),await Hu(E,F),E}async function xu(u,D){let{readdir:F,rename:C,mkdir:E}=await import("node:fs/promises");for(let q of D){let Q=_(u,q.name);await E(Q,{recursive:!0})}let A=_(u,"audio");await E(A,{recursive:!0});let B=await F(u);for(let q of B){if(q==="manifest.mpd")continue;if(q.startsWith("audio_")||q==="audio_init.m4s"){let Q=_(u,q),Z=_(A,q);await C(Q,Z);continue}for(let Q of D)if(q.startsWith(`${Q.name}_`)){let Z=_(u,q),L=_(u,Q.name,q);await C(Z,L);break}}}async function Hu(u,D){let{readFile:F,writeFile:C}=await import("node:fs/promises"),E=await F(u,"utf-8");E=E.replace(/media="\$RepresentationID\$_\$Number\$\.m4s"/g,'media="$RepresentationID$/$RepresentationID$_$Number$.m4s"'),E=E.replace(/initialization="\$RepresentationID\$_\.mp4"/g,'initialization="$RepresentationID$/$RepresentationID$_.mp4"'),await C(u,E,"utf-8")}async function l(u){let{input:D,outputDir:F,segmentDuration:C=2,profiles:E,useNvenc:A,generateThumbnails:B=!0,thumbnailConfig:q={},parallel:Q=!0,onProgress:Z}=u,L=KD("/tmp",`dash-converter-${_u()}`);await P(L);try{return await yu(D,F,L,C,E,A,B,q,Q,Z)}finally{try{await ku(L,{recursive:!0,force:!0})}catch(K){console.warn(`Warning: Failed to cleanup temp directory: ${L}`)}}}async function yu(u,D,F,C,E,A,B,q,Q,Z){if(!await y())throw Error("FFmpeg is not installed or not in PATH");if(!await V())throw Error("MP4Box is not installed or not in PATH. Install gpac package.");let L=(H,U,BD,O)=>{if(Z)Z({stage:H,percent:U,message:BD,currentProfile:O})};L("analyzing",0,"Analyzing input video...");let K=await b(u),X=A!==!1?await M():!1,G=A===!0?!0:A===!1?!1:X;if(A===!0&&!X)throw Error("NVENC requested but not available. Check NVIDIA drivers and GPU support.");let Y=E||d(K.width,K.height);if(Y.length===0)throw Error("No suitable profiles found for input video resolution");let R=Uu(u,Wu(u)),$=KD(D,R);await P($),L("analyzing",20,`Using ${G?"NVENC":"CPU"} encoding`,void 0);let j=G?"h264_nvenc":"libx264",x=G?"p4":"medium",S=G?3:2;L("encoding",25,`Stage 1: Encoding ${Y.length} profiles to MP4...`);let T=await YD(u,F,Y,j,x,K.duration,C,K.fps||25,K.audioBitrate,Q,S,void 0,(H,U)=>{let O=25+Y.findIndex((Au)=>Au.name===H)/Y.length*40,AD=U/100*(40/Y.length);if(L("encoding",O+AD,`Encoding ${H}...`,H),Z)Z({stage:"encoding",percent:O+AD,currentProfile:H,profilePercent:U,message:`Encoding ${H}...`})});L("encoding",65,"Stage 1 complete: All profiles encoded"),L("encoding",70,"Stage 2: Creating DASH with MP4Box...");let Eu=await JD(T,$,Y,C),Bu=Array.from(T.values());L("encoding",80,"Stage 2 complete: DASH created");let CD,ED;if(B){L("thumbnails",80,"Generating thumbnail sprites...");let H={width:q.width||160,height:q.height||90,interval:q.interval||1,columns:q.columns||10},U=await QD(u,$,K.duration,H);CD=U.spritePath,ED=U.vttPath,L("thumbnails",90,"Thumbnails generated")}return L("manifest",95,"Finalizing manifest..."),L("complete",100,"Conversion complete!"),{manifestPath:Eu,videoPaths:Bu,thumbnailSpritePath:CD,thumbnailVttPath:ED,duration:K.duration,profiles:Y,usedNvenc:G}}var uD=g(oD(),1),FD=process.argv[2],Du=process.argv[3]||"./output";if(!FD)console.error("❌ Usage: bun run test.ts [output-dir]"),process.exit(1);console.log(`\uD83D\uDD0D Checking system... `);var uu=await y(),Fu=await M(),Cu=await V();console.log(`FFmpeg: ${uu?"✅":"❌"}`);console.log(`NVENC: ${Fu?"✅ (GPU acceleration)":"⚠️ (CPU only)"}`);console.log(`MP4Box: ${Cu?"✅":"❌"} `);if(!uu)console.error("❌ FFmpeg not found. Please install FFmpeg first."),process.exit(1);if(!Cu)console.error("❌ MP4Box not found. Please install: sudo pacman -S gpac"),process.exit(1);console.log(`\uD83D\uDCF9 Input: ${FD}`);console.log(`\uD83D\uDCC1 Output: ${Du} `);console.log(`\uD83D\uDE80 Starting conversion... `);var c=new uD.default.MultiBar({format:"{stage} | {bar} | {percentage}% | {name}",barCompleteChar:"█",barIncompleteChar:"░",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},uD.default.Presets.shades_classic),o={},DD=null;try{let u=await l({input:FD,outputDir:Du,segmentDuration:2,useNvenc:Fu,generateThumbnails:!0,parallel:!0,onProgress:(D)=>{let F=D.stage==="encoding"?"Encoding":D.stage==="thumbnails"?"Thumbnails":D.stage==="manifest"?"Manifest":D.stage==="analyzing"?"Analyzing":"Complete";if(D.stage==="encoding"&&D.currentProfile){if(!o[D.currentProfile])o[D.currentProfile]=c.create(100,0,{stage:"Encode",name:D.currentProfile});let C=D.profilePercent??D.percent;o[D.currentProfile].update(C,{stage:"Encode",name:D.currentProfile})}if(!DD)DD=c.create(100,0,{stage:F,name:"Overall"});DD.update(D.percent,{stage:F,name:D.message||"Overall"})}});if(c.stop(),console.log(` ✅ Conversion completed successfully! `),console.log("\uD83D\uDCCA Results:"),console.log(` Manifest: ${u.manifestPath}`),console.log(` Duration: ${u.duration.toFixed(2)}s`),console.log(` Profiles: ${u.profiles.map((D)=>D.name).join(", ")}`),console.log(` Encoder: ${u.usedNvenc?"⚡ NVENC (GPU)":"\uD83D\uDD27 libx264 (CPU)"}`),u.thumbnailSpritePath)console.log(` Thumbnails: ${u.thumbnailSpritePath}`),console.log(` VTT file: ${u.thumbnailVttPath}`);console.log(` \uD83C\uDF89 Done! You can now use the manifest file in your video player.`)}catch(u){c.stop(),console.error(` ❌ Error during conversion:`),console.error(u),process.exit(1)}