*/var N0;function H1(){if(N0)return et;N0=1;var c=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),T=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),w=Symbol.iterator;function C(y){return y===null||typeof y!="object"?null:(y=w&&y[w]||y["@@iterator"],typeof y=="function"?y:null)}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H=Object.assign,G={};function Q(y,N,X){this.props=y,this.context=N,this.refs=G,this.updater=X||B}Q.prototype.isReactComponent={},Q.prototype.setState=function(y,N){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,N,"setState")},Q.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function L(){}L.prototype=Q.prototype;function Y(y,N,X){this.props=y,this.context=N,this.refs=G,this.updater=X||B}var $=Y.prototype=new L;$.constructor=Y,H($,Q.prototype),$.isPureReactComponent=!0;var it=Array.isArray,I={H:null,A:null,T:null,S:null,V:null},zt=Object.prototype.hasOwnProperty;function Rt(y,N,X,q,J,ft){return X=ft.ref,{$$typeof:c,type:y,key:N,ref:X!==void 0?X:null,props:ft}}function Ot(y,N){return Rt(y.type,N,void 0,void 0,void 0,y.props)}function St(y){return typeof y=="object"&&y!==null&&y.$$typeof===c}function Jt(y){var N={"=":"=0",":":"=2"};return"$"+y.replace(/[=:]/g,function(X){returnN[X]})}varoe=/\/+/g;functionXt(y,N){returntypeofy=="object"&&y!==null&&y.key!=null?Jt(""+y.key):N.toString(36)}functionEl(){}functionTl(y){switch(y.status){case"fulfilled":returny.value;case"rejected":throwy.reason;default:switch(typeofy.status=="string"?y.then(El,El):(y.status="pending",y.then(function(N){y.status==="pending"&&(y.status="fulfilled",y.value=N)},function(N){y.status==="pending"&&(y.status="rejected",y.reason=N)})),y.status){case"fulfilled":returny.value;case"rejected":throwy.reason}}throwy}functionVt(y,N,X,q,J){varft=typeofy;(ft==="undefined"||ft==="boolean")&&(y=null);vartt=!1;if(y===null)tt=!0;elseswitch(ft){case"bigint":case"string":case"number":tt=!0;break;case"object":switch(y.$$typeof){casec:caseo:tt=!0;break;caseR:returntt=y._init,Vt(tt(y._payload),N,X,q,J)}}if(tt)returnJ=J(y),tt=q===""?"."+Xt(y,0):q,it(J)?(X="",tt!=null&&(X=tt.replace(oe,"$&/")+"/"),Vt(J,N,X,"",function($e){return$e})):J!=null&&(St(J)&&(J=Ot(J,X+(J.key==null||y&&y.key===J.key?"":(""+J.key).replace(oe,"$&/")+"/")+tt)),N.push(J)),1;tt=0;varte=q===""?".":q+":";if(it(y))for(varbt=0;bt<y.length;bt++)q=y[bt],ft=te+Xt(q,bt),tt+=Vt(q,N,X,ft,J);elseif(bt=C(y),typeofbt=="function")for(y=bt.call(y),bt=0;!(q=y.next()).done;)q=q.value,ft=te+Xt(q,bt++),tt+=Vt(q,N,X,ft,J);elseif(ft==="object"){if(typeofy.then=="function")returnVt(Tl(y),N,X,q,J);throwN=String(y),Error("Objects are not valid as a React child (found: "+(N==="[object Object]"?"object with keys {"+Object.keys(y).join(", ")+"}":N)+"). If you meant to render a collection of children, use an array instead.")}returntt}functionM(y,N,X){if(y==null)returny;varq=[],J=0;returnVt(y,q,"","",function(ft){returnN.call(X,ft,J++)}),q}functionj(y){if(y._status===-1){varN=y._result;N=N(),N.then(function(X){(y._status===0||y._status===-1)&&(y._status=1,y._result=X)},function(X){(y._status===0||y._status===-1)&&(y._status=2,y._result=X)}),y._status===-1&&(y._status=0,y._result=N)}if(y._status===1)returny._result.default;throwy._result}varF=typeofreportError=="function"?reportError:function(y){if(typeofwindow=="object"&&typeofwindow.ErrorEvent=="function"){varN=newwindow.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeofy=="object"&&y!==null&&typeofy.message=="string"?String(y.message):String(y),error:y});if(!window.dispatchEvent(
Pleasechangetheparent<Routepath="${Y}">to<Routepath="${Y==="/"?"*":`${Y}/*`}">.`)}let w=bl(),C;if(o){let Y=typeof o=="string"?Gl(o):o;Tt(d==="/"||((L=Y.pathname)==null?void 0:L.startsWith(d)),`Whenoverridingthelocationusing\`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${Y.pathname}" was given in the \`location\` prop.`),C=Y}elseC=w;letB=C.pathname||"/",H=B;if(d!=="/"){letY=d.replace(/^\//,"").split("/");H="/"+B.replace(/^\//,"").split("/").slice(Y.length).join("/")}letG=$0(c,{pathname:H});be(R||G!=null,`No routes matched location "${C.pathname}${C.search}${C.hash}" `),be(G==null||G[G.length-1].route.element!==void0||G[G.length-1].route.Component!==void0||G[G.length-1].route.lazy!==void0,`Matched leaf route at location "${C.pathname}${C.search}${C.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);letQ=xm(G&&G.map(Y=>Object.assign({},Y,{params:Object.assign({},O,Y.params),pathname:Je([d,h.encodeLocation?h.encodeLocation(Y.pathname).pathname:Y.pathname]),pathnameBase:Y.pathnameBase==="/"?d:Je([d,h.encodeLocation?h.encodeLocation(Y.pathnameBase).pathname:Y.pathnameBase])})),v,s,r);returno&&Q?_.createElement(Uu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...C},navigationType:"POP"}},Q):Q}functionSm(){letc=Dm(),o=dm(c)?`${c.status}${c.statusText}`:cinstanceofError?c.message:JSON.stringify(c),s=cinstanceofError?c.stack:null,r="rgba(200,200,200, 0.5)",h={padding:"0.5rem",backgroundColor:r},v={padding:"2px 4px",backgroundColor:r},T=null;returnconsole.error("Error handled by React Router default ErrorBoundary:",c),T=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:v},"ErrorBoundary")," or"," ",_.createElement("code",{style:v},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},o),s?_.createElement("pre",{style:h},s):null,T)}varbm=_.createElement(Sm,null),Em=classextends_.Component{constructor(c){super(c),this.state={location:c.location,revalidation:c.revalidation,error:c.error}}staticgetDerivedStateFromError(c){return{error:c}}staticgetDerivedStateFromProps(c,o){returno.location!==c.location||o.revalidation!=="idle"&&c.revalidation==="idle"?{error:c.error,location:c.location,revalidation:c.revalidation}:{error:c.error!==void0?c.error:o.error,location:o.location,revalidation:c.revalidation||o.revalidation}}componentDidCatch(c,o){console.error("React Router caught the following error during render",c,o)}render(){returnthis.state.error!==void0?_.createElement(Ce.Provider,{value:this.props.routeContext},_.createElement(Uf.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};functionTm({routeContext:c,match:o,children:s}){letr=_.useContext(Da);returnr&&r.static&&r.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=o.route.id),_.createElement(Ce.Provider,{value:c},s)}functionxm(c,o=[],s=null,r=null){if(c==null){if(!s)returnnull;if(s.errors)c=s.matches;elseif(o.length===0&&!s.initialized&&s.matches.length>0)c=s.matches;elsereturnnull}leth=c,v=s==null?void0:s.errors;if(v!=null){letp=h.findIndex(d=>d.route.id&&(v==null?void0:v[d.route.id])!==void0);Tt(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(v).join(",")}`),h=h.slice(0,Math.min(h.length,p+1))}letT=!1,O=-1;if(s)for(letp=0;p<h.length;p++){letd=h[p];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(O=p),d.route.id){let{loaderData:R,errors:w}=s,C=d.route.loader&&!R.hasOwnProperty(d.route.id)&
`):K.jsx("span",{className:"text-gray-400",children:"None"})})]})}function k0({onConfigSaved:c}){const[o,s]=_.useState(""),[r,h]=_.useState(null),[v,T]=_.useState(null),[O,p]=_.useState(null),[d,R]=_.useState(!1),w=Nf();_.useEffect(()=>{chrome.storage.local.get("cdrm_instance",B=>{chrome.runtime.lastError?console.error("Error fetching CDRM instance:",chrome.runtime.lastError):B.cdrm_instance&&h(B.cdrm_instance)})},[]);const C=async()=>{const B=o.trim().replace(/\/+$/,"");if(!B){T("Please enter a valid URL."),p("error");return}const H=B+"/api/extension";R(!0),T(null);try{if((await(await fetch(H,{method:"POST",headers:{"Content-Type":"application/json"}})).json()).status===!0){T("Successfully connected to CDRM Instance."),p("success");const L=await fetch(`${B}/remotecdm/widevine/deviceinfo`);if(!L.ok)throw new Error("Failed to fetch Widevine device info");const Y=await L.json(),$=await fetch(`${B}/remotecdm/playready/deviceinfo`);if(!$.ok)throw new Error("Failed to fetch PlayReady device info");const it=await $.json();chrome.storage.local.set({valid_config:!0,cdrm_instance:B,widevine_device:{device_type:Y.device_type,system_id:Y.system_id,security_level:Y.security_level,secret:Y.secret,device_name:Y.device_name,host:B},playready_device:{security_level:it.security_level,secret:it.secret,device_name:it.device_name,host:B}},()=>{chrome.runtime.lastError?(console.error("Error saving to chrome.storage:",chrome.runtime.lastError),T("Error saving configuration."),p("error")):(console.log("Configuration saved."),h(B),s(""),c&&c(),w("/results"))})}else throw new Error("Invalid response from endpoint.")}catch(G){console.error("Connection error:",G),T("Invalid endpoint or device info could not be retrieved."),p("error")}finally{R(!1)}};return K.jsxs("div",{className:"w-full h-full overflow-y-auto overflow-x-auto flex flex-col p-4",children:[K.jsx("input",{type:"text",value:o,onChange:B=>s(B.target.value),placeholder:r?`CurrentCDRMInstance:${r}`:"CDRM Instance URL (e.g., https://cdrm-project.com/, http://127.0.0.1:5000/)",className:"w-full p-4 text-lg bg-gray-800 text-white border border-gray-700 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 mt-4"}),K.jsx("button",{onClick:C,disabled:d,className:`mt-4p-2${d?"bg-blue-400":"bg-blue-600 hover:bg-blue-700"}text-whiterounded-mdtransitionduration-300`,children:d?"Connecting...":"Save Settings"}),v&&K.jsx("p",{className:`mt-2text-smtext-center${O==="success"?"text-green-400":"text-red-400"}`,children:v})]})}function p2(){const[c,o]=_.useState(!1),[s,r]=_.useState(null);return _.useEffect(()=>{chrome.storage.local.get("valid_config",h=>{chrome.runtime.lastError?(console.error("Error reading valid_config:",chrome.runtime.lastError),r(!1)):r(h.valid_config===!0)})},[]),s===null?K.jsx("div",{className:"flex items-center justify-center h-screen bg-black text-white",children:"Loading..."}):K.jsx(l2,{children:K.jsxs("div",{className:"min-w-full min-h-full w-full h-full flex flex-grow bg-black/95 flex-col relative",children:[K.jsx("div",{className:"w-full min-h-16 max-h-16 h-16 shrink-0 flex sticky top-0 z-20 border-b border-b-white bg-black overflow-x-hidden",children:K.jsx(d2,{onMenuClick:()=>o(!0)})}),K.jsx("div",{id:"currentpagecontainer",className:"w-full grow overflow-y-auto",children:K.jsx(Um,{children:s?K.jsxs(K.Fragment,{children:[K.jsx(Oa,{path:"/",element:K.jsx(K0,{to:"/results",replace:!0})}),K.jsx(Oa,{path:"/results",element:K.jsx(g2,{})}),K.jsx(Oa,{path:"/settings",element:K.jsx(k0,{})})]}):K.jsxs(K.Fragment,{children:[K.jsx(Oa,{path:"/settings",element:K.jsx(k0,{onConfigSaved:()=>r(!0)})}),K.jsx(Oa,{path:"*",element:K.jsx(K0,{to:"/settings",replace:!0})})]})})}),K.jsx("div",{className:`fixedtop-0left-0w-fullh-fullz-50bg-blacktransformtransition-transformduration-300ease-in-out${c?"translate-x-0":"-translate-x-full"}`,children:K.jsx(y2,{onClose:()=>o(!1)})})]})})}G1.createRoot(document.getElementById("root")).render(K.jsx(_.StrictMode,{children:K.jsx(p2,{})}));