const s=/\.(zip|7z|rar|tar|gz|bz2|xz|dmg|pkg|exe|msi|iso|torrent|pdf|mp4|mkv|mp3|flac|apk|deb|rpm|ipa|img|bin)(?:$|[?#])/i,p=/^(text\/html|text\/plain|application\/json|application\/javascript|application\/xml|text\/xml)/i,d=/(^|\/)(download|downloads|dl|get|file|files|attachment|attachments)(\/|$)/i;function i(n,t){try{return new URL(n,t)}catch{return null}}function w(n,t){const e=i(n,t);return e?e.toString():String(n||"")}function a(n,t){const e=i(n,t);return e?s.test(e.pathname||""):s.test(String(n||""))}function g(n){const t=String(n||"").replace(/-/g,"+").replace(/_/g,"/");try{return atob(t)}catch{return""}}function m(n){if(!d.test(n))return!1;const t=String(n||"").split("/").filter(Boolean),e=t[t.length-1]||"";return!e||e.includes(".")?!1:/^[a-z0-9_-]{12,}$/i.test(e)}function h(n){const t=n.searchParams,e=t.get("golink");if(e){const r=g(e);if(r&&s.test(r))return!0}const o=t.get("filename")||t.get("file")||t.get("name")||t.get("out");return!!(o&&s.test(o)||t.has("attachment")||t.has("download"))}function y(n,t){const e=i(n,t);return!e||!["http:","https:","ftp:"].includes(e.protocol)?!1:!!(a(e.toString())||h(e)||m(e.pathname||""))}function L(n){const t=Array.isArray(n?.responseHeaders)?n.responseHeaders:[],e=l=>{const c=String(l||"").toLowerCase(),u=t.find(f=>String(f?.name||"").toLowerCase()===c);return String(u?.value||"")},o=e("content-disposition").toLowerCase(),r=e("content-type").toLowerCase();return o.includes("attachment")||a(n.url||"")?!0:!r||p.test(r)?!1:r.startsWith("application/")||r.startsWith("audio/")||r.startsWith("video/")}export{L as a,y as i,w as n};
