#!/usr/bin/env node import{createRequire as yF}from"node:module";var wF=Object.create;var{getPrototypeOf:SF,defineProperty:Eu,getOwnPropertyNames:TF}=Object;var bF=Object.prototype.hasOwnProperty;var KD=(u,D,E)=>{E=u!=null?wF(SF(u)):{};let F=D||!u||!u.__esModule?Eu(E,"default",{value:u,enumerable:!0}):E;for(let C of TF(u))if(!bF.call(F,C))Eu(F,C,{get:()=>u[C],enumerable:!0});return F};var I=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var n=yF(import.meta.url);var Iu=I((y3,xu)=>{class qu{constructor(u,D,E){this.etaBufferLength=u||100,this.valueBuffer=[E],this.timeBuffer=[D],this.eta="0"}update(u,D,E){this.valueBuffer.push(D),this.timeBuffer.push(u),this.calculate(E-D)}getTime(){return this.eta}calculate(u){let D=this.valueBuffer.length,E=Math.min(this.etaBufferLength,D),F=this.valueBuffer[D-1]-this.valueBuffer[D-E],C=this.timeBuffer[D-1]-this.timeBuffer[D-E],B=F/C;this.valueBuffer=this.valueBuffer.slice(-this.etaBufferLength),this.timeBuffer=this.timeBuffer.slice(-this.etaBufferLength);let A=Math.ceil(u/B/1000);if(isNaN(A))this.eta="NULL";else if(!isFinite(A))this.eta="INF";else if(A>1e7)this.eta="INF";else if(A<0)this.eta=0;else this.eta=A}}xu.exports=qu});var wD=I((v3,Mu)=>{var p=n("readline");class Vu{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;p.cursorTo(this.stream,u,D)}cursorRelative(u=null,D=null){if(!this.stream.isTTY)return;this.dy=this.dy+D,p.moveCursor(this.stream,u,D)}cursorRelativeReset(){if(!this.stream.isTTY)return;p.moveCursor(this.stream,0,-this.dy),p.cursorTo(this.stream,0,null),this.dy=0}clearRight(){if(!this.stream.isTTY)return;p.clearLine(this.stream,1)}clearLine(){if(!this.stream.isTTY)return;p.clearLine(this.stream,0)}clearBottom(){if(!this.stream.isTTY)return;p.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)}}Mu.exports=Vu});var Ru=I((P3,Ou)=>{Ou.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 ju=I((h3,Lu)=>{var C8=Ru();Lu.exports=(u)=>typeof u==="string"?u.replace(C8(),""):u});var Su=I((f3,SD)=>{var wu=(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};SD.exports=wu;SD.exports.default=wu});var bu=I((g3,Tu)=>{Tu.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 vu=I((m3,TD)=>{var B8=ju(),A8=Su(),Z8=bu(),yu=(u)=>{if(typeof u!=="string"||u.length===0)return 0;if(u=B8(u),u.length===0)return 0;u=u.replace(Z8()," ");let D=0;for(let E=0;E=127&&F<=159)continue;if(F>=768&&F<=879)continue;if(F>65535)E++;D+=A8(F)?2:1}return D};TD.exports=yu;TD.exports.default=yu});var bD=I((c3,Pu)=>{Pu.exports=function(D,E,F){if(E.autopadding!==!0)return D;function C(B,A){return(E.autopaddingChar+B).slice(-A)}switch(F){case"percentage":return C(D,3);default:return D}}});var yD=I((l3,hu)=>{hu.exports=function(D,E){let F=Math.round(D*E.barsize),C=E.barsize-F;return E.barCompleteString.substr(0,F)+E.barGlue+E.barIncompleteString.substr(0,C)}});var vD=I((d3,fu)=>{fu.exports=function(D,E,F){function C(A){if(F)return F*Math.round(A/F);else return A}function B(A){return(E.autopaddingChar+A).slice(-2)}if(D>3600)return B(Math.floor(D/3600))+"h"+B(C(D%3600/60))+"m";else if(D>60)return B(Math.floor(D/60))+"m"+B(C(D%60))+"s";else if(D>10)return B(C(D))+"s";else return B(D)+"s"}});var PD=I((p3,gu)=>{var $8=vu(),J8=bD(),K8=yD(),X8=vD();gu.exports=function(D,E,F){let C=D.format,B=D.formatTime||X8,A=D.formatValue||J8,Z=D.formatBar||K8,J=Math.floor(E.progress*100)+"",G=E.stopTime||Date.now(),X=Math.round((G-E.startTime)/1000),Y=Object.assign({},F,{bar:Z(E.progress,D),percentage:A(J,D,"percentage"),total:A(E.total,D,"total"),value:A(E.value,D,"value"),eta:A(E.eta,D,"eta"),eta_formatted:B(E.eta,D,5),duration:A(X,D,"duration"),duration_formatted:B(X,D,1)});C=C.replace(/\{(\w+)\}/g,function(K,_){if(typeof Y[_]<"u")return Y[_];return K});let $=Math.max(0,E.maxWidth-$8(C)-2),N=Math.floor($/2);switch(D.align){case"right":C=$>0?" ".repeat($)+C:C;break;case"center":C=N>0?" ".repeat(N)+C:C;break;case"left":default:break}return C}});var WD=I((n3,mu)=>{function H(u,D){if(typeof u>"u"||u===null)return D;else return u}mu.exports={parse:function(D,E){let F={},C=Object.assign({},E,D);return F.throttleTime=1000/H(C.fps,10),F.stream=H(C.stream,process.stderr),F.terminal=H(C.terminal,null),F.clearOnComplete=H(C.clearOnComplete,!1),F.stopOnComplete=H(C.stopOnComplete,!1),F.barsize=H(C.barsize,40),F.align=H(C.align,"left"),F.hideCursor=H(C.hideCursor,!1),F.linewrap=H(C.linewrap,!1),F.barGlue=H(C.barGlue,""),F.barCompleteChar=H(C.barCompleteChar,"="),F.barIncompleteChar=H(C.barIncompleteChar,"-"),F.format=H(C.format,"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}"),F.formatTime=H(C.formatTime,null),F.formatValue=H(C.formatValue,null),F.formatBar=H(C.formatBar,null),F.etaBufferLength=H(C.etaBuffer,10),F.etaAsynchronousUpdate=H(C.etaAsynchronousUpdate,!1),F.progressCalculationRelative=H(C.progressCalculationRelative,!1),F.synchronousUpdate=H(C.synchronousUpdate,!0),F.noTTYOutput=H(C.noTTYOutput,!1),F.notTTYSchedule=H(C.notTTYSchedule,2000),F.emptyOnZero=H(C.emptyOnZero,!1),F.forceRedraw=H(C.forceRedraw,!1),F.autopadding=H(C.autopadding,!1),F.gracefulExit=H(C.gracefulExit,!1),F},assignDerivedOptions:function(D){return D.barCompleteString=D.barCompleteChar.repeat(D.barsize+1),D.barIncompleteString=D.barIncompleteChar.repeat(D.barsize+1),D.autopaddingChar=D.autopadding?H(D.autopaddingChar," "):"",D}}});var hD=I((s3,lu)=>{var cu=Iu(),Y8=wD(),G8=PD(),U8=WD(),W8=n("events");lu.exports=class extends W8{constructor(D){super();this.options=U8.assignDerivedOptions(D),this.terminal=this.options.terminal?this.options.terminal:new Y8(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 cu(this.options.etaBufferLength,0,0),this.payload={},this.isActive=!1,this.formatter=typeof this.options.format==="function"?this.options.format:G8}render(D=!1){let E={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 F=this.formatter(this.options,E,this.payload);if(D||this.options.forceRedraw||this.options.noTTYOutput&&!this.terminal.isTTY()||this.lastDrawnString!=F)this.emit("redraw-pre"),this.terminal.cursorTo(0,null),this.terminal.write(F),this.terminal.clearRight(),this.lastDrawnString=F,this.lastRedraw=Date.now(),this.emit("redraw-post")}start(D,E,F){this.value=E||0,this.total=typeof D<"u"&&D>=0?D:100,this.startValue=E||0,this.payload=F||{},this.startTime=Date.now(),this.stopTime=null,this.lastDrawnString="",this.eta=new cu(this.options.etaBufferLength,this.startTime,this.value),this.isActive=!0,this.emit("start",D,E)}stop(){this.isActive=!1,this.stopTime=Date.now(),this.emit("stop",this.total,this.value)}update(D,E={}){if(typeof D==="number")this.value=D,this.eta.update(Date.now(),D,this.total);let F=(typeof D==="object"?D:E)||{};this.emit("update",this.total,this.value);for(let C in F)this.payload[C]=F[C];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,E={}){if(typeof D==="object")this.update(this.value+1,D);else this.update(this.value+D,E)}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 pu=I((a3,du)=>{var k8=hD(),N8=WD();du.exports=class extends k8{constructor(D,E){super(N8.parse(D,E));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,E){if(!this.timer)return;if(super.update(D,E),this.options.synchronousUpdate&&this.lastRedraw+this.options.throttleTime*2{var Q8=wD(),_8=hD(),z8=WD(),H8=n("events");nu.exports=class extends H8{constructor(D,E){super();this.bars=[],this.options=z8.parse(D,E),this.options.synchronousUpdate=!1,this.terminal=this.options.terminal?this.options.terminal:new Q8(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,E,F,C={}){let B=new _8(Object.assign({},this.options,{terminal:this.terminal},C));if(this.bars.push(B),this.options.noTTYOutput===!1&&this.terminal.isTTY()===!1)return B;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,B.start(D,E,F),this.emit("start"),B}remove(D){let E=this.bars.indexOf(D);if(E<0)return!1;return this.bars.splice(E,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 iu=I((r3,au)=>{au.exports={format:"progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"=",barIncompleteChar:"-"}});var ou=I((o3,ru)=>{ru.exports={format:" {bar} {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var eu=I((t3,tu)=>{tu.exports={format:" \x1B[90m{bar}\x1B[0m {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"█",barIncompleteChar:"░"}});var uF=I((e3,DF)=>{DF.exports={format:" {bar}■ {percentage}% | ETA: {eta}s | {value}/{total}",barCompleteChar:"■",barIncompleteChar:" "}});var EF=I((D2,FF)=>{var q8=iu(),x8=ou(),I8=eu(),V8=uF();FF.exports={legacy:q8,shades_classic:x8,shades_grey:I8,rect:V8}});var AF=I((u2,BF)=>{var CF=pu(),M8=su(),O8=EF(),R8=PD(),L8=bD(),j8=yD(),w8=vD();BF.exports={Bar:CF,SingleBar:CF,MultiBar:M8,Presets:O8,Format:{Formatter:R8,BarFormat:j8,ValueFormat:L8,TimeFormat:w8}}});import{join as UD,basename as _u,extname as zu}from"node:path";import{randomUUID as D8}from"node:crypto";import{rm as Hu}from"node:fs/promises";import{spawn as s}from"node:child_process";import{appendFile as vF}from"node:fs/promises";var qD=null;function xD(u){qD=u}async function f(u){if(qD)try{await vF(qD,u,"utf-8")}catch(D){}}async function a(){return new Promise((u)=>{let D=s("ffmpeg",["-version"]);D.on("error",()=>u(!1)),D.on("close",(E)=>u(E===0))})}async function i(){return new Promise((u)=>{let D=s("MP4Box",["-version"]);D.on("error",()=>u(!1)),D.on("close",(E)=>u(E===0))})}async function r(){let u=await new Promise((C)=>{let B=s("ffmpeg",["-hide_banner","-encoders"]),A="";B.stdout.on("data",(Z)=>{A+=Z.toString()}),B.on("error",()=>C("")),B.on("close",()=>C(A))}),D=(C)=>u.includes(C),E=[],F=[{acc:"nvenc",h264:D("h264_nvenc")?"h264_nvenc":void 0,av1:D("av1_nvenc")?"av1_nvenc":void 0},{acc:"qsv",h264:D("h264_qsv")?"h264_qsv":void 0,av1:D("av1_qsv")?"av1_qsv":void 0},{acc:"amf",h264:D("h264_amf")?"h264_amf":void 0,av1:D("av1_amf")?"av1_amf":void 0},{acc:"vaapi",h264:D("h264_vaapi")?"h264_vaapi":void 0,av1:D("av1_vaapi")?"av1_vaapi":void 0},{acc:"videotoolbox",h264:D("h264_videotoolbox")?"h264_videotoolbox":void 0,av1:D("av1_videotoolbox")?"av1_videotoolbox":void 0},{acc:"v4l2",h264:D("h264_v4l2m2m")?"h264_v4l2m2m":void 0,av1:D("av1_v4l2m2m")?"av1_v4l2m2m":void 0}];for(let C of F)if(C.h264||C.av1)E.push({accelerator:C.acc,h264Encoder:C.h264,av1Encoder:C.av1});return E}async function o(){let D=(await new Promise((C)=>{let B=s("ffmpeg",["-hide_banner","-hwaccels"]),A="";B.stdout.on("data",(Z)=>A+=Z.toString()),B.on("error",()=>C("")),B.on("close",()=>C(A))})).split(` `).map((C)=>C.trim()).filter(Boolean),E=[],F={cuda:"nvenc",qsv:"qsv",vaapi:"vaapi",videotoolbox:"videotoolbox",v4l2m2m:"v4l2",dxva2:"amf"};for(let C of D){let B=F[C];if(B)E.push({accelerator:B})}return E}async function l(u,D,E){let C=` === FFmpeg Command [${new Date().toISOString()}] === ffmpeg ${u.join(" ")} `;return await f(C),new Promise((B,A)=>{let Z=s("ffmpeg",u),J="";Z.stderr.on("data",(G)=>{let X=G.toString();if(J+=X,D&&E){let Y=X.match(/time=(\d{2}):(\d{2}):(\d{2}\.\d{2})/);if(Y){let $=parseInt(Y[1]),N=parseInt(Y[2]),K=parseFloat(Y[3]),_=$*3600+N*60+K,W=Math.min(100,_/E*100);D(W)}}}),Z.on("error",(G)=>{f(`ERROR: ${G.message} `),A(Error(`FFmpeg error: ${G.message}`))}),Z.on("close",(G)=>{if(G===0){let Y=J.split(` `).filter(($)=>$.trim()).slice(-10).join(` `);f(`SUCCESS: Exit code ${G} --- Last 10 lines of output --- ${Y} `),B()}else f(`FAILED: Exit code ${G} --- Full error output --- ${J} `),A(Error(`FFmpeg failed with exit code ${G} ${J}`))})})}async function ID(u){let E=` === MP4Box Command [${new Date().toISOString()}] === MP4Box ${u.join(" ")} `;return await f(E),new Promise((F,C)=>{let B=s("MP4Box",u),A="",Z="";B.stdout.on("data",(J)=>{A+=J.toString()}),B.stderr.on("data",(J)=>{Z+=J.toString()}),B.on("error",(J)=>{f(`ERROR: ${J.message} `),C(Error(`MP4Box error: ${J.message}`))}),B.on("close",(J)=>{if(J===0){let Y=(A||Z).split(` `).filter(($)=>$.trim()).slice(-10).join(` `);f(`SUCCESS: Exit code ${J} --- Last 10 lines of output --- ${Y} `),F()}else{let G=Z||A;f(`FAILED: Exit code ${J} --- Full error output --- ${G} `),C(Error(`MP4Box failed with exit code ${J} ${G}`))}})})}import{spawn as PF}from"node:child_process";async function t(u){return new Promise((D,E)=>{let F=PF("ffprobe",["-v","error","-show_entries","stream=width,height,duration,r_frame_rate,codec_name,codec_type,bit_rate","-show_entries","format=duration","-of","json",u]),C="";F.stdout.on("data",(B)=>{C+=B.toString()}),F.on("error",(B)=>{E(Error(`ffprobe error: ${B.message}`))}),F.on("close",(B)=>{if(B!==0){E(Error(`ffprobe failed with exit code ${B}`));return}try{let A=JSON.parse(C),Z=A.streams.find((_)=>_.codec_type==="video"),J=A.streams.find((_)=>_.codec_type==="audio"),G=A.format;if(!Z){E(Error("No video stream found in input file"));return}let X=30;if(Z.r_frame_rate){let[_,W]=Z.r_frame_rate.split("/").map(Number);if(_&&W&&W!==0)X=_/W}let Y=parseFloat(Z.duration||G.duration||"0"),$=A.streams.find((_)=>_.codec_type==="audio"&&_.bit_rate),N=$?.bit_rate?Math.round(parseInt($.bit_rate)/1000):void 0,K=Z.bit_rate?Math.round(parseInt(Z.bit_rate)/1000):void 0;D({width:Z.width,height:Z.height,duration:Y,fps:X,codec:Z.codec_name,hasAudio:Boolean(J),audioBitrate:N,videoBitrate:K})}catch(A){E(Error(`Failed to parse ffprobe output: ${A}`))}})})}function XD(u,D=256){if(!u)return`${D}k`;let E=Math.min(u,D);if(E<=64)return"64k";if(E<=96)return"96k";if(E<=128)return"128k";if(E<=192)return"192k";return"256k"}function YD(u){let D=Math.floor(u/3600),E=Math.floor(u%3600/60),F=u%60;return`${String(D).padStart(2,"0")}:${String(E).padStart(2,"0")}:${F.toFixed(3).padStart(6,"0")}`}import{mkdir as hF,access as fF,constants as gF}from"node:fs/promises";async function d(u){try{await fF(u,gF.F_OK)}catch{await hF(u,{recursive:!0})}}function lF(u,D){let E=u*D;if(E<=230400)return 0.08;if(E<=409920)return 0.075;if(E<=921600)return 0.07;if(E<=2073600)return 0.065;if(E<=3686400)return 0.06;return 0.055}function v(u,D,E=30,F){let C=lF(u,D),B=Math.round(u*D*E*C/1000);if(F&&B>F)B=F;return`${B}k`}var VD=[{name:"360p",width:640,height:360,videoBitrate:v(640,360,30),audioBitrate:"192k"},{name:"480p",width:854,height:480,videoBitrate:v(854,480,30),audioBitrate:"192k"},{name:"720p",width:1280,height:720,videoBitrate:v(1280,720,30),audioBitrate:"192k"},{name:"1080p",width:1920,height:1080,videoBitrate:v(1920,1080,30),audioBitrate:"256k"},{name:"1440p",width:2560,height:1440,videoBitrate:v(2560,1440,30),audioBitrate:"256k"},{name:"2160p",width:3840,height:2160,videoBitrate:v(3840,2160,30),audioBitrate:"256k"}];function AD(u,D,E=30,F){let C=[],B=VD.filter((A)=>{return A.width<=u&&A.height<=D});for(let A of B)C.push({...A,videoBitrate:v(A.width,A.height,30,F),fps:30});return C}function dF(u,D,E){return{...u,name:`${u.name}-${D}`,videoBitrate:v(u.width,u.height,D,E),fps:D}}function Cu(u){let E=u.trim().match(/^(\d+)p?(?:[@-](\d+))?$/i);if(!E)return null;let F=E[1]+"p",C=E[2]?parseInt(E[2]):30;return{resolution:F,fps:C}}function Bu(u,D=30,E){let F=VD.find((C)=>C.name===u);if(!F)return null;if(D===30)return{...F,videoBitrate:v(F.width,F.height,30,E),fps:30};return dF(F,D,E)}function pF(u,D,E,F){let C=Cu(u);if(!C)return{error:`Invalid profile format: ${u}. Use format like: 360, 720@60, 1080-60`};let B=Bu(C.resolution,C.fps);if(!B)return{error:`Unknown resolution: ${C.resolution}. Available: 360, 480, 720, 1080, 1440, 2160`};if(B.width>D||B.height>E)return{error:`Source resolution (${D}x${E}) is lower than ${u} (${B.width}x${B.height})`};let A=120,Z=C.fps,J;if(C.fps>F)Z=Math.min(F,A),J=`Requested ${C.fps} FPS in ${u}, but source is ${F} FPS. Using ${Z} FPS instead`;else if(C.fps>A)Z=A,J=`Requested ${C.fps} FPS in ${u} exceeds maximum ${A} FPS. Using ${Z} FPS instead`;return J?{warning:J,adjustedFps:Z}:{}}function GD(u,D,E,F,C){let B=[],A=[],Z=[];for(let J of u){let G=pF(J,D,E,F);if(G.error){A.push(G.error);continue}if(G.warning)Z.push(G.warning);let X=Cu(J);if(!X)continue;let Y=G.adjustedFps!==void 0?G.adjustedFps:X.fps,$=Bu(X.resolution,Y,C);if($)B.push($)}return{profiles:B,errors:A,warnings:Z}}import{join as g}from"node:path";import{readdir as nF,unlink as Au,rmdir as sF,writeFile as Zu}from"node:fs/promises";async function $u(u,D,E="00:00:00"){let F=g(D,"poster.jpg"),C=/^\d+(\.\d+)?$/.test(E)?E:E;return await l(["-ss",C,"-i",u,"-vframes","1","-q:v","2","-y",F]),F}async function Ju(u,D,E,F){let{width:C,height:B,interval:A,columns:Z}=F,J=g(D,".thumbnails_temp");await d(J),await Zu(g(J,".keep"),"");let G=g(J,"thumb_%04d.jpg");await l(["-i",u,"-vf",`fps=1/${A},scale=${C}:${B}`,"-q:v","5",G]);let Y=(await nF(J)).filter((k)=>k.startsWith("thumb_")&&k.endsWith(".jpg")).sort();if(Y.length===0)throw Error("No thumbnails generated");let $=Y.length,N=Math.ceil($/Z),K=g(D,"thumbnails.jpg"),_=`tile=${Z}x${N}`;await l(["-i",G,"-filter_complex",_,"-q:v","5",K]);let W=g(D,"thumbnails.vtt"),U=aF($,A,C,B,Z,"thumbnails.jpg");await Zu(W,U);for(let k of Y)await Au(g(J,k));return await Au(g(J,".keep")),await sF(J),{spritePath:K,vttPath:W}}function aF(u,D,E,F,C,B){let A=`WEBVTT `;for(let Z=0;Z ${YD(G)} `,A+=`${B}#xywh=${$},${N},${E},${F} `}return A}import{join as iF}from"node:path";function rF(u,D,E){if(E)if(D==="h264")return 32;else return 42;else if(D==="h264"){if(u<=360)return 25;if(u<=480)return 24;if(u<=720)return 23;if(u<=1080)return 22;if(u<=1440)return 21;return 20}else{if(u<=360)return 40;if(u<=480)return 38;if(u<=720)return 35;if(u<=1080)return 32;if(u<=1440)return 30;return 28}}async function Ku(u,D,E,F,C,B,A,Z,J,G,X,Y,$){let N=iF(D,`video_${J}_${E.name}.mp4`),K=["-y"];if(Y){if(Y==="nvenc")K.push("-hwaccel","cuda","-hwaccel_output_format","cuda");else if(Y==="qsv")K.push("-hwaccel","qsv");else if(Y==="vaapi")K.push("-hwaccel","vaapi");else if(Y==="videotoolbox")K.push("-hwaccel","videotoolbox");else if(Y==="v4l2")K.push("-hwaccel","v4l2")}K.push("-i",u,"-c:v",F);let _=F.includes("nvenc")||F.includes("qsv")||F.includes("amf")||F.includes("vaapi")||F.includes("videotoolbox")||F.includes("v4l2"),W;if(_&&G?.cq!==void 0)W=G.cq;else if(!_&&G?.crf!==void 0)W=G.crf;else W=rF(E.height,J,_);if(F==="h264_nvenc")K.push("-rc:v","vbr"),K.push("-cq",String(W)),K.push("-preset",C),K.push("-2pass","0");else if(F==="av1_nvenc")K.push("-rc:v","vbr"),K.push("-cq",String(W)),K.push("-preset",C),K.push("-2pass","0");else if(F==="av1_qsv")K.push("-preset",C),K.push("-global_quality",String(W));else if(F==="h264_qsv")K.push("-preset",C),K.push("-global_quality",String(W));else if(F==="av1_amf")K.push("-quality","balanced"),K.push("-rc","cqp"),K.push("-qp_i",String(W)),K.push("-qp_p",String(W));else if(F==="h264_amf")K.push("-quality","balanced"),K.push("-rc","cqp"),K.push("-qp_i",String(W)),K.push("-qp_p",String(W));else if(F==="libsvtav1")K.push("-crf",String(W)),K.push("-preset",C),K.push("-svtav1-params","tune=0:enable-overlays=1");else if(F==="libx264")K.push("-crf",String(W)),K.push("-preset",C);else K.push("-preset",C);let U=J==="av1"?0.6:1,k=Math.round(parseInt(E.videoBitrate)*U*1.5);K.push("-maxrate",`${k}k`),K.push("-bufsize",`${k*2}k`);let q=E.fps||30,V=Math.round(q*A);K.push("-g",String(V),"-keyint_min",String(V),"-sc_threshold","0");let O=[`scale=${E.width}:${E.height}`];if(X){if(X.deinterlace)O.push("yadif");if(X.denoise)O.push("hqdn3d");if(X.customFilters)O.push(...X.customFilters)}K.push("-vf",O.join(","));let y=parseInt(E.audioBitrate)||256,P=XD(Z,y);if(K.push("-c:a","aac","-b:a",P),X?.audioNormalize)K.push("-af","loudnorm");return K.push("-f","mp4",N),await l(K,$,B),N}async function Xu(u,D,E,F,C,B,A,Z,J,G,X,Y,$,N,K){let _=new Map;if(J&&E.length>1)for(let W=0;WKu(u,D,V,F,C,B,A,Z,X,Y,$,N,(O)=>{if(K)K(V.name,O)}));(await Promise.all(k)).forEach((V,O)=>{let y=U[O];_.set(y.name,V)})}else for(let W of E){let U=await Ku(u,D,W,F,C,B,A,Z,X,Y,$,N,(k)=>{if(K)K(W.name,k)});_.set(W.name,U)}return _}import{join as R}from"node:path";import{readdir as ku,rename as Q3,mkdir as _3,writeFile as LD}from"node:fs/promises";import{readFile as MD,writeFile as OD}from"node:fs/promises";async function Yu(u){let D=await MD(u,"utf-8");D=D.replace(/\/\/>/g,"/>"),D=D.replace(/\/\s+\/>/g,"/>"),D=D.replace(/(]+)\s+\/>/g,"$1/>"),D=D.replace(/]+)\/>\s*<\/Representation>/g,""),D=D.replace(/]+)\/>\s*(]*\/>)/g,` $2 `),D=D.replace(/]+)>\s*(?=<(?:Representation|\/AdaptationSet))/g,` `),await OD(u,D,"utf-8")}async function Gu(u,D,E){let F=await MD(u,"utf-8");F=F.replace(/media="\$RepresentationID\$_\$Number\$\.m4s"/g,'media="$RepresentationID$/$RepresentationID$_$Number$.m4s"'),F=F.replace(/initialization="\$RepresentationID\$_\.mp4"/g,'initialization="$RepresentationID$/$RepresentationID$_.mp4"'),await OD(u,F,"utf-8")}async function Uu(u){let E=(await MD(u,"utf-8")).split(` `),F=[],C=0;while(C")){let $=E[C];if($.includes(""))Y=!1}else if($.includes("0&&X.length>0)F.push(B),J.forEach(($)=>F.push($)),G.forEach(($)=>F.push($)),F.push(" "),F.push(B),J.forEach(($)=>F.push($)),X.forEach(($)=>F.push($)),F.push(" ");else{F.push(B);for(let $=A+1;$q.endsWith(".m4s")).sort((q,V)=>{let O=parseInt(q.match(/_(\d+)\.m4s$/)?.[1]||"0"),y=parseInt(V.match(/_(\d+)\.m4s$/)?.[1]||"0");return O-y}),_=N.find((q)=>q.endsWith("_.mp4"));if(!_||K.length===0)continue;let W=RD(K,_,E),U=R($,"playlist.m3u8");await LD(U,W,"utf-8");let k=parseInt(X.videoBitrate)*1000;A.push({path:`${Y}/playlist.m3u8`,bandwidth:k,resolution:`${X.width}x${X.height}`,fps:X.fps||30})}let Z,J=[];if(C){let X=R(u,"audio"),Y=[];try{Y=await ku(X)}catch{Y=[]}if(J=Y.filter(($)=>$.endsWith(".m4s")).sort(($,N)=>{let K=parseInt($.match(/_(\d+)\.m4s$/)?.[1]||"0"),_=parseInt(N.match(/_(\d+)\.m4s$/)?.[1]||"0");return K-_}),Z=Y.find(($)=>$.endsWith("_.mp4")),Z&&J.length>0){let $=RD(J,Z,E);await LD(R(X,"playlist.m3u8"),$,"utf-8")}}let G=Wu(A,C&&Z!==void 0&&J.length>0);return await LD(B,G,"utf-8"),B}async function jD(u){let{input:D,outputDir:E,segmentDuration:F=2,profiles:C,customProfiles:B,codec:A="dual",format:Z="both",hardwareDecoder:J,hardwareAccelerator:G,quality:X,generateThumbnails:Y=!0,thumbnailConfig:$={},generatePoster:N=!0,posterTimecode:K="00:00:00",parallel:_=!0,onProgress:W}=u,U=UD("/tmp",`dash-converter-${D8()}`);await d(U);let k=_u(D,zu(D)),q=UD(E,k);await d(q);let V=UD(q,"conversion.log");xD(V);let{writeFile:O}=await import("node:fs/promises"),y=`=========================================== DASH Conversion Log Started: ${new Date().toISOString()} Input: ${D} Output: ${q} Codec: ${A} Format: ${Z} =========================================== `;await O(V,y,"utf-8");try{return await u8(D,E,U,F,C,B,A,Z,G,J,X,Y,$,N,K,_,W)}finally{let{appendFile:P}=await import("node:fs/promises");try{await P(V,` Completed: ${new Date().toISOString()} `,"utf-8")}catch(QD){}try{await Hu(U,{recursive:!0,force:!0})}catch(QD){console.warn(`Warning: Failed to cleanup temp directory: ${U}`)}}}async function u8(u,D,E,F,C,B,A,Z,J,G,X,Y,$,N,K,_,W){if(!await a())throw Error("FFmpeg is not installed or not in PATH");if(!await i())throw Error("MP4Box is not installed or not in PATH. Install gpac package.");let U=(z,x,zD,HD)=>{if(W)W({stage:z,percent:x,message:zD,currentProfile:HD})};U("analyzing",0,"Analyzing input video...");let k=await t(u),q=k.hasAudio,V=J&&J!=="auto"?J:"auto",O=await r(),y=await o(),{selected:P,h264Encoder:QD,av1Encoder:_F,warnings:aD}=F8(O,V,A);if(aD.length>0)for(let z of aD)console.warn(`⚠️ ${z}`);let{selected:JD}=E8(y,G||"auto"),zF=O.some((z)=>z.av1Encoder),c=A;if(A==="dual"&&!zF)console.warn("⚠️ AV1 hardware encoder not detected. Switching to H.264 only."),c="h264";let L;if(B&&B.length>0){let z=GD(B,k.width,k.height,k.fps,k.videoBitrate);if(z.errors.length>0){console.warn(` ❌ Profile errors:`);for(let x of z.errors)console.warn(` - ${x}`);console.warn("")}if(z.warnings.length>0){console.warn(` ⚠️ Profile warnings:`);for(let x of z.warnings)console.warn(` - ${x}`);console.warn("")}if(L=z.profiles,L.length===0)throw Error("No valid profiles found in custom list. Check errors above.")}else if(C)L=C;else L=AD(k.width,k.height,k.fps,k.videoBitrate);if(L.length===0)throw Error("No suitable profiles found for input video resolution");let HF=_u(u,zu(u)),CD=UD(D,HF);try{await Hu(CD,{recursive:!0,force:!0})}catch(z){}await d(CD);let h=[];if(c==="h264"||c==="dual"){let z=QD||"libx264",x=Qu(z,"h264");h.push({type:"h264",codec:z,preset:x})}if(c==="av1"||c==="dual"){let z=_F||"libsvtav1",x=Qu(z,"av1");h.push({type:"av1",codec:z,preset:x})}let qF=h.map((z)=>z.type.toUpperCase()).join(" + "),xF=P==="cpu"?"CPU":P.toUpperCase();U("analyzing",20,`Using ${qF} encoding (${xF}, decoder ${JD.toUpperCase()})`,void 0);let IF=P==="cpu"?2:3,_D=new Map;for(let z=0;z{let d8=L.findIndex((jF)=>jF.name===BD),uu=25+eD*40,Fu=Du/100*(40*OF/L.length);if(U("encoding",uu+Fu,`Encoding ${x.toUpperCase()} ${BD}...`,`${x}-${BD}`),W)W({stage:"encoding",percent:uu+Fu,currentProfile:`${x}-${BD}`,profilePercent:Du,message:`Encoding ${x.toUpperCase()} ${BD}...`})});_D.set(x,LF)}U("encoding",65,"Stage 1 complete: All codecs and profiles encoded"),U("encoding",70,"Stage 2: Creating segments and manifests...");let{manifestPath:VF,hlsManifestPath:MF}=await Nu(_D,CD,L,F,c,Z,q),iD=[];for(let z of _D.values())iD.push(...Array.from(z.values()));U("encoding",80,"Stage 2 complete: All formats packaged");let rD,oD;if(Y){U("thumbnails",80,"Generating thumbnail sprites...");let z={width:$.width||160,height:$.height||90,interval:$.interval||1,columns:$.columns||10},x=await Ju(u,CD,k.duration,z);rD=x.spritePath,oD=x.vttPath,U("thumbnails",90,"Thumbnails generated")}let tD;if(N)U("thumbnails",92,"Generating poster image..."),tD=await $u(u,CD,K),U("thumbnails",95,"Poster generated");return U("manifest",95,"Finalizing..."),U("complete",100,"Conversion complete!"),{manifestPath:VF,hlsManifestPath:MF,videoPaths:iD,thumbnailSpritePath:rD,thumbnailVttPath:oD,posterPath:tD,duration:k.duration,profiles:L,usedNvenc:h.some((z)=>z.codec.includes("nvenc")),selectedAccelerator:P,selectedDecoder:JD,codecType:c,format:Z}}var e={nvenc:100,qsv:90,amf:80,vaapi:70,videotoolbox:65,v4l2:60,cpu:1};function F8(u,D,E){let F=E==="h264"||E==="dual",C=E==="av1"||E==="dual",B=[],A=new Set(["nvenc","qsv","amf"]),Z=u.filter((U)=>F&&U.h264Encoder||C&&U.av1Encoder),J=Z.filter((U)=>A.has(U.accelerator)),G=(U)=>Z.find((k)=>k.accelerator===U),X;if(D!=="auto"){if(D==="cpu")X=void 0;else if(!A.has(D))B.push(`Ускоритель "${D}" пока не поддерживается, использую CPU`);else if(X=G(D),!X)throw Error(`Аппаратный ускоритель "${D}" недоступен в системе`)}else if(X=(J.length>0?J:[]).sort((k,q)=>(e[q.accelerator]||0)-(e[k.accelerator]||0))[0],!X&&Z.length>0)B.push("Доступен аппаратный ускоритель, но он пока не поддерживается пайплайном, использую CPU");let $=(J.length>0?J:[]).sort((U,k)=>(e[k.accelerator]||0)-(e[U.accelerator]||0)),N=(U)=>{let k=U==="h264"?X?.h264Encoder:X?.av1Encoder;if(k)return{encoder:k,accel:X?.accelerator};let q=$.find((V)=>U==="h264"?V.h264Encoder:V.av1Encoder);if(q){if(D!=="auto"&&X)B.push(`Выбранный ускоритель "${X.accelerator}" не поддерживает ${U.toUpperCase()}, использую ${q.accelerator}`);return{encoder:U==="h264"?q.h264Encoder:q.av1Encoder,accel:q.accelerator}}if(D!=="auto"&&D!=="cpu")B.push(`Ускоритель "${D}" не поддерживает ${U.toUpperCase()}, использую CPU`);return{encoder:void 0,accel:"cpu"}},K=F?N("h264"):{encoder:void 0,accel:X?.accelerator},_=C?N("av1"):{encoder:void 0,accel:X?.accelerator};return{selected:X?.accelerator||K.accel||_.accel||"cpu",h264Encoder:K.encoder,av1Encoder:_.encoder,warnings:B}}function E8(u,D){let E=new Set(["nvenc","qsv","vaapi","videotoolbox","v4l2"]),F=(A)=>u.find((Z)=>Z.accelerator===A);if(D!=="auto"){if(D==="cpu")return{selected:"cpu"};let A=F(D);return{selected:A?A.accelerator:"cpu"}}let C=u.filter((A)=>E.has(A.accelerator));if(C.length===0)return{selected:"cpu"};return{selected:C.sort((A,Z)=>(e[Z.accelerator]||0)-(e[A.accelerator]||0))[0].accelerator}}function Qu(u,D){if(u.includes("nvenc"))return"p4";if(u.includes("qsv"))return"medium";if(u.includes("amf"))return"balanced";if(u.includes("vaapi"))return"5";if(u.includes("videotoolbox"))return"medium";if(u.includes("v4l2"))return"medium";if(u==="libsvtav1")return"8";if(u==="libx264")return"medium";return D==="av1"?"8":"medium"}var mD=KD(AF(),1);import{statSync as S8}from"node:fs";var Q=process.argv.slice(2),ZD,dD,j="dual",DD="both",pD=[],w,S,T,b,uD,FD;for(let u=0;uF.trim()).filter((F)=>F.length>0)}else if(Q[u]==="-p"||Q[u]==="--poster")dD=Q[u+1],u++;else if(Q[u]==="-c"||Q[u]==="--codec"){let D=Q[u+1];if(D==="av1"||D==="h264"||D==="dual")j=D;else console.error(`❌ Invalid codec: ${D}. Valid options: av1, h264, dual`),process.exit(1);u++}else if(Q[u]==="-f"||Q[u]==="--format"){let D=Q[u+1];if(D==="dash"||D==="hls"||D==="both")DD=D;else console.error(`❌ Invalid format: ${D}. Valid options: dash, hls, both`),process.exit(1);u++}else if(Q[u]==="--h264-cq"){if(w=parseInt(Q[u+1]),isNaN(w)||w<0||w>51)console.error(`❌ Invalid H.264 CQ value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--h264-crf"){if(S=parseInt(Q[u+1]),isNaN(S)||S<0||S>51)console.error(`❌ Invalid H.264 CRF value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--av1-cq"){if(T=parseInt(Q[u+1]),isNaN(T)||T<0||T>51)console.error(`❌ Invalid AV1 CQ value: ${Q[u+1]}. Must be 0-51`),process.exit(1);u++}else if(Q[u]==="--av1-crf"){if(b=parseInt(Q[u+1]),isNaN(b)||b<0||b>63)console.error(`❌ Invalid AV1 CRF value: ${Q[u+1]}. Must be 0-63`),process.exit(1);u++}else if(Q[u]==="--accel"||Q[u]==="--hardware"||Q[u]==="-e"||Q[u]==="--encoder"){let D=Q[u+1];if(!["auto","nvenc","qsv","amf","cpu","vaapi","videotoolbox","v4l2"].includes(D))console.error(`❌ Invalid accelerator: ${D}. Valid: auto, nvenc, qsv, amf, vaapi, videotoolbox, v4l2, cpu`),process.exit(1);uD=D,u++}else if(Q[u]==="-d"||Q[u]==="--decoder"){let D=Q[u+1];if(!["auto","nvenc","qsv","amf","vaapi","videotoolbox","v4l2","cpu"].includes(D))console.error(`❌ Invalid decoder: ${D}. Valid: auto, nvenc, qsv, amf, vaapi, videotoolbox, v4l2, cpu`),process.exit(1);FD=D,u++}else if(!Q[u].startsWith("-"))pD.push(Q[u]);var ED=pD[0],GF=pD[1]||".";if(!ED)console.error("❌ Usage: create-vod [output-dir] [options]"),console.error(` Options:`),console.error(" -r, --resolutions Video resolutions (e.g., 360,480,720 or 720@60,1080@60)"),console.error(" -c, --codec Video codec: av1, h264, or dual (default: dual)"),console.error(" -f, --format Streaming format: dash, hls, or both (default: both)"),console.error(" -p, --poster Poster timecode (e.g., 00:00:05 or 10)"),console.error(" -e, --encoder Hardware encoder: auto|nvenc|qsv|amf|vaapi|videotoolbox|v4l2|cpu (default: auto)"),console.error(" -d, --decoder Hardware decoder: auto|nvenc|qsv|amf|vaapi|videotoolbox|v4l2|cpu (default: auto)"),console.error(` Quality Options (override defaults):`),console.error(" --h264-cq H.264 GPU CQ value (0-51, lower = better, default: auto)"),console.error(" --h264-crf H.264 CPU CRF value (0-51, lower = better, default: auto)"),console.error(" --av1-cq AV1 GPU CQ value (0-51, lower = better, default: auto)"),console.error(" --av1-crf AV1 CPU CRF value (0-63, lower = better, default: auto)"),console.error(` Examples:`),console.error(" create-vod video.mp4"),console.error(" create-vod video.mp4 ./output"),console.error(" create-vod video.mp4 -r 360,480,720"),console.error(" create-vod video.mp4 -c av1 --av1-cq 40"),console.error(" create-vod video.mp4 -c dual --h264-cq 30 --av1-cq 39"),console.error(" create-vod video.mp4 -f hls"),console.error(" create-vod video.mp4 -c dual -f both"),console.error(" create-vod video.mp4 -r 720@60,1080@60,2160@60 -c av1 -f dash"),console.error(" create-vod video.mp4 -p 00:00:05"),console.error(" create-vod video.mp4 ./output -r 720,1080 -c dual -f both -p 10 --h264-cq 28 --av1-cq 37"),process.exit(1);console.log(`\uD83D\uDD0D Checking system... `);var UF=await a(),WF=await i(),nD=await r(),kF=nD.some((u)=>u.av1Encoder),sD=await o(),ZF={nvenc:100,qsv:90,amf:80,vaapi:70,videotoolbox:65,v4l2:60},$F=nD.slice().sort((u,D)=>(ZF[D.accelerator]||0)-(ZF[u.accelerator]||0))[0];console.log(`FFmpeg: ${UF?"✅":"❌"}`);console.log(`MP4Box: ${WF?"✅":"❌"}`);var cD=Array.from(new Set(nD.map((u)=>u.accelerator.toUpperCase()))),$D=$F?$F.accelerator.toUpperCase():void 0,B2=cD.filter((u)=>u!==$D),JF=uD?uD.toUpperCase():$D||"CPU",NF=cD.length>0?cD:["CPU"],ND=Array.from(new Set(sD.map((u)=>u.accelerator.toUpperCase()))),KF=FD?FD.toUpperCase():ND[0]||"CPU",QF=ND.length>0?ND:["CPU"];console.log(`Encoder: ${JF==="AUTO"?$D||"CPU":JF} (${NF.join(", ")})`);console.log(`Decoder: ${KF==="AUTO"?ND[0]||"CPU":KF} (${QF.join(", ")})`);console.log("");if(!UF)console.error("❌ FFmpeg not found. Please install FFmpeg first."),process.exit(1);if(!WF)console.error("❌ MP4Box not found. Please install: sudo pacman -S gpac"),process.exit(1);if((j==="av1"||j==="dual")&&!kF){if(j==="av1")console.error("⚠️ Warning: AV1 encoding requested but no hardware AV1 encoder found."),console.error(" CPU-based AV1 encoding (libsvtav1) will be VERY slow."),console.error(` Consider using --codec h264 for faster encoding. `);else if(j==="dual")console.warn("⚠️ AV1 hardware encoder not detected. Using H.264 only (disable AV1)."),j="h264"}if((DD==="hls"||DD==="both")&&j==="av1")console.error("❌ Error: HLS format requires H.264 codec for Safari/iOS compatibility."),console.error(` Please use --codec h264 or --codec dual with --format hls `),process.exit(1);console.log(`\uD83D\uDCCA Analyzing video... `);var M=await t(ED),T8=S8(ED),b8=(T8.size/1048576).toFixed(2);console.log("\uD83D\uDCF9 Video Information:");console.log(` File: ${ED}`);console.log(` Size: ${b8} MB`);console.log(` Resolution: ${M.width}x${M.height}`);console.log(` FPS: ${M.fps.toFixed(2)}`);console.log(` Duration: ${Math.floor(M.duration/60)}m ${Math.floor(M.duration%60)}s`);console.log(` Codec: ${M.codec}`);if(M.videoBitrate)console.log(` Video Bitrate: ${(M.videoBitrate/1000).toFixed(2)} Mbps`);if(M.audioBitrate)console.log(` Audio Bitrate: ${M.audioBitrate} kbps`);var lD=[];if(ZD&&ZD.length>0){let u=GD(ZD,M.width,M.height,M.fps,M.videoBitrate);if(u.errors.length>0)console.error(` ❌ Profile errors:`),u.errors.forEach((D)=>console.error(` - ${D}`)),process.exit(1);if(u.warnings.length>0)console.warn(` ⚠️ Profile warnings:`),u.warnings.forEach((D)=>console.warn(` - ${D}`));lD=u.profiles.map((D)=>D.name)}else lD=AD(M.width,M.height,M.fps,M.videoBitrate).map((D)=>D.name);var y8=DD==="both"?"DASH (manifest.mpd), HLS (master.m3u8)":DD==="dash"?"DASH (manifest.mpd)":"HLS (master.m3u8)",v8=!0,P8=dD||"00:00:00",h8=j==="dual"?"dual (AV1 + H.264)":j,f8=j==="h264"&&!kF?" (AV1 disabled: no HW)":"",XF=uD?uD.toUpperCase():$D||"CPU",YF=FD?FD.toUpperCase():sD[0]?.accelerator.toUpperCase()||"CPU",g8=XF==="AUTO"?$D||"CPU":XF,m8=YF==="AUTO"?sD[0]?.accelerator.toUpperCase()||"CPU":YF,c8=NF.join(", "),l8=QF.join(", ");console.log(` \uD83D\uDCE6 Parameters:`);console.log(` Input: ${ED}`);console.log(` Output: ${GF}`);console.log(` Codec: ${h8}${f8}`);console.log(` Profiles: ${lD.join(", ")}`);console.log(` Manifests: ${y8}`);console.log(` Poster: ${P8} (will be generated)`);console.log(` Thumbnails: ${v8?"yes (with VTT)":"no"}`);console.log(` Encoder: ${g8} (available: ${c8})`);console.log(` Decoder: ${m8} (available: ${l8})`);var m;if(w!==void 0||S!==void 0||T!==void 0||b!==void 0){if(m={},w!==void 0||S!==void 0){if(m.h264={},w!==void 0)m.h264.cq=w;if(S!==void 0)m.h264.crf=S;console.log(`\uD83C\uDF9A️ H.264 Quality: ${w!==void 0?`CQ ${w}`:""}${S!==void 0?` CRF ${S}`:""}`)}if(T!==void 0||b!==void 0){if(m.av1={},T!==void 0)m.av1.cq=T;if(b!==void 0)m.av1.crf=b;console.log(`\uD83C\uDF9A️ AV1 Quality: ${T!==void 0?`CQ ${T}`:""}${b!==void 0?` CRF ${b}`:""}`)}}console.log(` \uD83D\uDE80 Starting conversion... `);var kD=new mD.default.MultiBar({format:"{stage} | {bar} | {percentage}% | {name}",barCompleteChar:"█",barIncompleteChar:"░",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0},mD.default.Presets.shades_classic),fD={},gD=null;try{let u=Date.now(),D=await jD({input:ED,outputDir:GF,customProfiles:ZD,posterTimecode:dD,codec:j,format:DD,segmentDuration:2,hardwareAccelerator:uD,hardwareDecoder:FD,quality:m,generateThumbnails:!0,generatePoster:!0,parallel:!0,onProgress:(C)=>{let B=C.stage==="encoding"?"Encoding":C.stage==="thumbnails"?"Thumbnails":C.stage==="manifest"?"Manifest":C.stage==="analyzing"?"Analyzing":"Complete";if(C.stage==="encoding"&&C.currentProfile){if(!fD[C.currentProfile])fD[C.currentProfile]=kD.create(100,0,{stage:"Encode",name:C.currentProfile});let A=C.profilePercent??C.percent;fD[C.currentProfile].update(A,{stage:"Encode",name:C.currentProfile})}if(!gD)gD=kD.create(100,0,{stage:B,name:"Overall"});gD.update(C.percent,{stage:B,name:C.message||"Overall"})}});kD.stop();let F=((Date.now()-u)/1000).toFixed(2);console.log(` ✅ Conversion completed successfully! (${F}s) `)}catch(u){kD.stop(),console.error(` ❌ Error during conversion:`),console.error(u),process.exit(1)}