"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))(function(n,l){function a(e){try{s(o.next(e))}catch(e){l(e)}}function r(e){try{s(o.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(a,r)}s((o=o.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStream=void 0;const getStream=function(e){return __awaiter(this,arguments,void 0,function*({link:e,providerContext:t}){var i,o,n,l,a,r,s,d,p;const{axios:c,cheerio:u}=t,v={"sec-ch-ua":'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',Referer:"https://multimovies.online/","Sec-Fetch-User":"?1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"};try{const t=(yield c.get(e,{headers:v})).data,y=u.load(t),g=[],w=y("#player-option-1").attr("data-post"),b=y("#player-option-1").attr("data-nume"),_=y("#player-option-1").attr("data-type"),x=e.split("/").slice(0,3).join("/"),j=new FormData;j.append("action","doo_player_ajax"),j.append("post",w||""),j.append("nume",b||""),j.append("type",_||"");const S=yield fetch(`${x}/wp-admin/admin-ajax.php`,{headers:v,body:j,method:"POST"}),O=yield S.json();let M=(null===(o=null===(i=null==O?void 0:O.embed_url)||void 0===i?void 0:i.match(/]+src="([^"]+)"[^>]*>/i))||void 0===o?void 0:o[1])||(null==O?void 0:O.embed_url);if(!M.includes("multimovies")){let e=M.split("/").slice(0,3).join("/");const t=yield c.head(e,{headers:v});t&&(e=null===(l=null===(n=t.request)||void 0===n?void 0:n.responseURL)||void 0===l?void 0:l.split("/").slice(0,3).join("/"));const i=M.split("/").pop(),o=new FormData;o.append("sid",i);const d=yield fetch(`${e}/embedhelper.php`,{headers:v,body:o,method:"POST"}),p=yield d.json(),u=null===(a=null==p?void 0:p.siteUrls)||void 0===a?void 0:a.smwh,h=u+((null===(r=JSON.parse(atob(null==p?void 0:p.mresult)))||void 0===r?void 0:r.smwh)||(null===(s=null==p?void 0:p.mresult)||void 0===s?void 0:s.smwh));h&&(M=h)}const k=(yield c.get(M,{headers:Object.assign(Object.assign({},v),{Referer:e})})).data;var h=/eval\(function\((.*?)\)\{.*?return p\}.*?\('(.*?)'\.split/.exec(k);let A="";if(h){var m=h[2];A=null===(d=m.split("',36,"))||void 0===d?void 0:d[0].trim();let e=36,t=m.split("',36,")[1].slice(2).split("|").length,i=m.split("',36,")[1].slice(2).split("|");for(;t--;)if(i[t]){var f=new RegExp("\\b"+t.toString(e)+"\\b","g");A=A.replace(f,i[t])}}const E=null===(p=null==A?void 0:A.match(/https?:\/\/[^"]+?\.m3u8[^"]*/))||void 0===p?void 0:p[0],P=[],R=null==A?void 0:A.match(/https:\/\/[^\s"]+\.vtt/g);return(null==R?void 0:R.length)&&R.forEach(e=>{const t=e.match(/_([a-zA-Z]{3})\.vtt$/)[1];P.push({language:t,uri:e,type:"text/vtt",title:t})}),E&&g.push({server:"Multi",link:E.replace(/&i=\d+,'\.4&/,"&i=0.4&"),type:"m3u8",subtitles:P}),g}catch(e){return[]}})};exports.getStream=getStream;