import{a as e,h as t,o as n,s as r}from"./issue-reports-DoFnf__I.js";var i=`us-central1`,a=`6LesFFotAAAAAOVXNLTtJFNLgpzEr0IQxnpWbC6Z`,o=`beta`,s=`https://stockpopover.com/auth/chrome-extension/`;function c(){return{apiKey:`AIzaSyBpcBYI3OIacy1B0iOwGzCsMp0uz15kCdU`,authDomain:`stockpopover.com`,projectId:`ir-safari`,appId:`1:964370079831:web:1ebf0894b2a251e5460312`}}function l(e=c()){return s}function u(e){return e.expireTimeMillis-Date.now()>6e4}function d(e){let t=e.trim();if(!t)return;let n=globalThis;n.FIREBASE_APPCHECK_DEBUG_TOKEN=t===`true`?!0:t}function f(){try{return chrome.runtime.id||`dev-extension`}catch{return`dev-extension`}}function p(){try{let e=chrome.runtime.getManifest(),t=e.version_name?.trim()||e.version?.trim();if(t)return t}catch{}throw Error(`Extension runtime manifest version is unavailable.`)}async function m(){try{let e=`irsp.extensionInstallId`,t=(await chrome.storage.local.get(e))[e];if(typeof t==`string`&&t)return t;let n=crypto.randomUUID();return await chrome.storage.local.set({[e]:n}),n}catch{return`dev-install`}}function h(e=`3600s`){let t=/^(\d+(?:\.\d+)?)s$/.exec(e);return t?Math.max(6e4,Number(t[1])*1e3):3600*1e3}var g=[.82,.72,.62,.5,.4];async function _(i,a=new Date().toISOString(),o={}){if(i.type!==`image/png`&&i.type!==`image/jpeg`)throw Error(`Choose a PNG or JPEG screenshot.`);if(i.size<=0||!o.allowTrustedBrowserCaptureResize&&i.size>4194304)throw Error(`Choose a screenshot smaller than 4 MiB.`);let s=await createImageBitmap(i);try{if((s.width>8e3||s.height>8e3||s.width*s.height>2e7)&&!o.allowTrustedBrowserCaptureResize)throw Error(`Choose a screenshot no larger than 8000 px per side or 20 megapixels.`);let i=Math.min(1,e/Math.max(s.width,s.height),Math.sqrt(n/(s.width*s.height))),c=Math.max(1,Math.floor(s.width*i)),l=Math.max(1,Math.floor(s.height*i)),u=new OffscreenCanvas(c,l),d=u.getContext(`2d`);if(!d)throw Error(`Screenshot processing is unavailable.`);d.drawImage(s,0,0,c,l);let f;for(let e of g)if(f=await u.convertToBlob({type:`image/jpeg`,quality:e}),f.size<=35e5)break;for(let e=0;f&&f.size>35e5&&e<3;e+=1){let e=Math.min(.9,Math.sqrt(r/f.size)*.94);c=Math.max(1,Math.floor(c*e)),l=Math.max(1,Math.floor(l*e));let t=new OffscreenCanvas(c,l),n=t.getContext(`2d`);if(!n)throw Error(`Screenshot processing is unavailable.`);n.drawImage(u,0,0,u.width,u.height,0,0,c,l),u=t,f=await u.convertToBlob({type:`image/jpeg`,quality:.72})}if(!f||f.size>35e5)throw Error(`The screenshot could not be reduced below 3.5 MiB.`);return t.parse({dataUrl:await b(f),mimeType:`image/jpeg`,sizeBytes:f.size,width:c,height:l,capturedAt:a})}finally{s.close()}}async function v(e,t=new Date().toISOString(),n={}){return _(y(e),t,n)}function y(e){let t=/^data:(image\/(?:jpeg|png));base64,([A-Za-z0-9+/]*={0,2})$/u.exec(e);if(!t)throw Error(`Chrome returned an invalid screenshot encoding.`);let[,n,r]=t;if(!n||r===void 0||r.length%4==1)throw Error(`Chrome returned an invalid screenshot encoding.`);let i;try{i=atob(r)}catch{throw Error(`Chrome returned an invalid screenshot encoding.`)}if(!i.length)throw Error(`Chrome returned an empty screenshot.`);let a=new Uint8Array(i.length);for(let e=0;e<i.length;e+=1)a[e]=i.charCodeAt(e);return new Blob([a],{type:n})}async function b(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return`data:${e.type};base64,${btoa(n)}`}export{o as a,p as c,h as d,c as f,l as i,i as l,v as n,m as o,d as p,a as r,f as s,_ as t,u};