import{r as u}from"./chunk-CoYD1fGq.js";import{b1 as p,C as f,z as g}from"./chunk-B8Q4vgLh.js";import{aZ as m}from"./chunk-02oqS8tD.js";function v(){const e=r=>document.querySelector(`meta[name="${r}"]`)?.content?.trim()||void 0,t=e("version")??e("app-version")??e("build")??e("build-version")??e("release");if(t)return t;const i=window;for(const r of["__APP_VERSION__","__BUILD_VERSION__","APP_VERSION","__COMMIT_HASH__"]){const s=i[r];if(typeof s=="string"&&s.trim()!=="")return s.trim();if(typeof s=="number")return String(s)}}function w(){const e=i=>{try{return i?.length??0}catch{return 0}};let t=0;try{t=document.cookie===""?0:document.cookie.split(";").length}catch{t=0}return{cookies:t,localStorageKeys:e(window.localStorage),sessionStorageKeys:e(window.sessionStorage),cacheKeys:0,serviceWorkers:0,title:document.title}}const S={block:"Blocked",delay:"Delayed",redirect:"Redirected","modify-request":"Request modified","mock-response":"Mocked response","modify-response":"Response modified"};async function y(e={}){const t=e.environment??await m(),i=t.tab?.tabId??null;let r,s;if(i!==null&&t.tab?.targetable===!0)try{const[o,d]=await Promise.all([chrome.scripting.executeScript({target:{tabId:i},func:w}),chrome.scripting.executeScript({target:{tabId:i},func:v})]);r=o[0]?.result,s=d[0]?.result}catch{}let c=r?.cookies??0;if(t.tab?.url)try{c=(await chrome.cookies.getAll({url:t.tab.url})).length}catch{}const n=t.viewport,a=n?p(n.profileId):void 0,l=e.rules!==void 0?e.rules.filter(o=>o.enabled).map(o=>({name:o.name,action:g(o),match:f(o.match)})):(t.intercept?.rules??[]).map(o=>({name:o.name,action:S[o.action]??o.action,match:`${o.method} ${o.match}`}));return{capturedAt:Date.now(),...t.tab?.url?{url:t.tab.url}:{},...r?.title||t.tab?.title?{pageTitle:r?.title??t.tab?.title??""}:{},device:u(),...n&&a?{viewport:{profileId:n.profileId,width:n.appliedWidth,height:n.appliedHeight,rotate:n.rotate,emulated:!0}}:{},...t.network?{network:{...t.network.conditions,packetLossStatus:t.network.packetLossStatus}}:{},...t.geo?{geo:t.geo.geo}:{},...t.permissions&&Object.keys(t.permissions.permissions).length>0?{permissions:t.permissions.permissions}:{},...l.length===0?{}:{rules:l},state:{cookies:c,localStorageKeys:r?.localStorageKeys??0,sessionStorageKeys:r?.sessionStorageKeys??0,indexedDBDatabases:0,cacheKeys:r?.cacheKeys??0,serviceWorkers:r?.serviceWorkers??0},...e.profile===void 0?{}:{profile:e.profile},...s===void 0?{}:{appVersion:s},...e.context===void 0?{}:{context:e.context}}}function h(e){const t=[];if(e.url&&t.push(e.url),e.device&&t.push(`${e.device.browser} ${e.device.browserVersion} on ${e.device.os}`),e.viewport?t.push(`${String(e.viewport.width)} × ${String(e.viewport.height)} (emulated)`):e.device&&t.push(`${String(e.device.viewport.width)} × ${String(e.device.viewport.height)}`),e.network){const i=e.network;if(i.offline)t.push("Offline");else if(i.presetId!=="online"){const r=i.packetLoss>0?i.packetLossStatus==="rejected"?`, ${String(i.packetLoss)}% packet loss NOT applied by this browser`:`, ${String(i.packetLoss)}% packet loss requested (unverified)`:"";t.push(`${i.presetId.toUpperCase()} — ${String(i.latencyMs)}ms, ${String(i.downloadKbps)} kbps down${r}`)}}if(e.geo&&t.push(`Location: ${e.geo.label} (${e.geo.permission})`),e.permissions){const i=Object.entries(e.permissions);i.length>0&&t.push(`Permissions: ${i.map(([r,s])=>`${r}=${String(s)}`).join(", ")}`)}for(const i of e.rules??[])t.push(`Rule: ${i.match} → ${i.action}`);return e.state&&t.push(`State: ${String(e.state.cookies)} cookies, ${String(e.state.localStorageKeys)} localStorage keys`),e.appVersion&&t.push(`App version: ${e.appVersion}`),t}function I(e){const t=[];return e.device&&t.push(`${e.device.browser} ${e.device.browserVersion.split(".")[0]}`),e.viewport&&t.push(`${String(e.viewport.width)}×${String(e.viewport.height)}`),e.network&&e.network.presetId!=="online"&&t.push(e.network.offline?"Offline":e.network.presetId.toUpperCase()),e.geo&&t.push(e.geo.label.split(",")[0]),e.rules&&e.rules.length>0&&t.push(`${String(e.rules.length)} rule${e.rules.length===1?"":"s"}`),t.join(" · ")}export{y as c,h as d,I as s};
//# sourceMappingURL=chunk-Cd_gpmCR.js.map
