import{i as e}from"./jsx-runtime-CutOxEx1.js";var t=e({ensureHostPermissionForUrl:()=>i,hostPermissionPatternMatchesOrigin:()=>r}),n=e=>{let t=String(e||``).trim().replace(/\/+$/,``);return t?`${t}/*`:``},r=(e,t)=>{let n=String(e||``).trim(),r=String(t||``).trim().replace(/\/+$/,``);if(!n||!r)return!1;if(n===`<all_urls>`)return!0;try{let e=new URL(r),t=n.match(/^(\*|https?|file|ftp):\/\/([^/]+)\/\*$/i);if(!t)return!1;let i=String(t[1]||``).toLowerCase(),a=String(t[2]||``).toLowerCase(),o=String(e.protocol||``).replace(/:$/,``).toLowerCase(),s=String(e.hostname||``).toLowerCase();if(i!==`*`&&i!==o)return!1;if(a===`*`)return!0;if(a.startsWith(`*.`)){let e=a.slice(2);return s===e||s.endsWith(`.${e}`)}return s===a}catch{return!1}},i=async e=>{let t=String(e||``).trim();if(!t)return!1;let i=``;try{i=new URL(t,globalThis?.location?.origin||void 0).origin}catch{return!1}if(i===globalThis?.location?.origin)return!0;let a=n(i);if(!a)return!1;try{let e=globalThis?.chrome?.runtime?.getManifest?.();if((Array.isArray(e?.host_permissions)?e.host_permissions:[]).some(e=>r(e,i)))return!0}catch{}let o=globalThis?.chrome?.permissions;if(!o?.contains||!o?.request)return!0;try{if(await new Promise(e=>{try{o.contains({origins:[a]},t=>e(!!t))}catch{e(!1)}}))return!0}catch{}try{return!!await new Promise(e=>{try{o.request({origins:[a]},t=>e(!!t))}catch{e(!1)}})}catch{return!1}};export{t as n,i as t};