@fkn/lib 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_redirects +5 -0
- package/{background-Y_zGUlba.cjs → background-DWzRqH12.cjs} +1 -1
- package/{background-DkW0j6iK.js → background-_3_Cnyol.js} +160 -47
- package/index.cjs +11 -1
- package/index.d.ts +698 -76
- package/index.js +2310 -121
- package/{locator-DpMUq6q3.js → locator-1wWrCOyE.js} +588 -499
- package/locator-DHsqhrFb.cjs +31 -0
- package/logo.png +0 -0
- package/logo.svg +7 -0
- package/package.json +4 -5
- package/locator-CcAGamNm.cjs +0 -31
package/_redirects
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# SPA fallback: serve the app shell for client-routed paths (e.g. /privacy) so a
|
|
2
|
+
# direct load or refresh doesn't 404. Real static files (assets, api.html — the
|
|
3
|
+
# sandbox iframe) are served before this rule, so only unknown paths fall back.
|
|
4
|
+
# Cloudflare Pages / Netlify format.
|
|
5
|
+
/* /index.html 200
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./locator-CcAGamNm.cjs`);let t=require(`osra`);var n=e.m(((e,t)=>{(function(n,r){if(typeof define==`function`&&define.amd)define(`webextension-polyfill`,[`module`],r);else if(e!==void 0)r(t);else{var i={exports:{}};r(i),n.browser=i.exports}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:e,function(e){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw Error(`This script should only be loaded in a browser extension.`);globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id?e.exports=globalThis.browser:e.exports=(e=>{let t={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(t).length===0)throw Error(`api-metadata.json has not been included in browser-polyfill`);class n extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}let r=e=>e&&typeof e==`object`&&typeof e.then==`function`,i=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&n.singleCallbackArg!==!1?t.resolve(r[0]):t.resolve(r)},a=e=>e==1?`argument`:`arguments`,o=(e,t)=>function(n,...r){if(r.length<t.minArgs)throw Error(`Expected at least ${t.minArgs} ${a(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw Error(`Expected at most ${t.maxArgs} ${a(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise((a,o)=>{if(t.fallbackToNoCallback)try{n[e](...r,i({resolve:a,reject:o},t))}catch(i){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,i),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,a()}else t.noCallback?(n[e](...r),a()):n[e](...r,i({resolve:a,reject:o},t))})},s=(e,t,n)=>new Proxy(t,{apply(t,r,i){return n.call(r,e,...i)}}),c=Function.call.bind(Object.prototype.hasOwnProperty),l=(e,t={},n={})=>{let r=Object.create(null);return new Proxy(Object.create(e),{has(t,n){return n in e||n in r},get(i,a,u){if(a in r)return r[a];if(!(a in e))return;let d=e[a];if(typeof d==`function`)if(typeof t[a]==`function`)d=s(e,e[a],t[a]);else if(c(n,a)){let t=o(a,n[a]);d=s(e,e[a],t)}else d=d.bind(e);else if(typeof d==`object`&&d&&(c(t,a)||c(n,a)))d=l(d,t[a],n[a]);else if(c(n,`*`))d=l(d,t[a],n[`*`]);else return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get(){return e[a]},set(t){e[a]=t}}),d;return r[a]=d,d},set(t,n,i,a){return n in r?r[n]=i:e[n]=i,!0},defineProperty(e,t,n){return Reflect.defineProperty(r,t,n)},deleteProperty(e,t){return Reflect.deleteProperty(r,t)}})},u=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener(t,n){return t.hasListener(e.get(n))},removeListener(t,n){t.removeListener(e.get(n))}}),d=new n(e=>typeof e==`function`?function(t){e(l(t,{},{getContent:{minArgs:0,maxArgs:0}}))}:e),f=new n(e=>typeof e==`function`?function(t,n,i){let a=!1,o,s=new Promise(e=>{o=function(t){a=!0,e(t)}}),c;try{c=e(t,n,o)}catch(e){c=Promise.reject(e)}let l=c!==!0&&r(c);return c!==!0&&!l&&!a?!1:((e=>{e.then(e=>{i(e)},e=>{let t;t=e&&(e instanceof Error||typeof e.message==`string`)?e.message:`An unexpected error occurred`,i({__mozWebExtensionPolyfillReject__:!0,message:t})}).catch(e=>{console.error(`Failed to send onMessage rejected reply`,e)})})(l?c:s),!0)}:e),p=({reject:t,resolve:n},r)=>{e.runtime.lastError?e.runtime.lastError.message===`The message port closed before a response was received.`?n():t(Error(e.runtime.lastError.message)):r&&r.__mozWebExtensionPolyfillReject__?t(Error(r.message)):n(r)},m=(e,t,n,...r)=>{if(r.length<t.minArgs)throw Error(`Expected at least ${t.minArgs} ${a(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw Error(`Expected at most ${t.maxArgs} ${a(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise((e,t)=>{let i=p.bind(null,{resolve:e,reject:t});r.push(i),n.sendMessage(...r)})},h={devtools:{network:{onRequestFinished:u(d)}},runtime:{onMessage:u(f),onMessageExternal:u(f),sendMessage:m.bind(null,`sendMessage`,{minArgs:1,maxArgs:3})},tabs:{sendMessage:m.bind(null,`sendMessage`,{minArgs:2,maxArgs:3})}},g={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return t.privacy={network:{"*":g},services:{"*":g},websites:{"*":g}},l(e,h,t)})(chrome)})}))(),r=`FKN_WEB_EXTENSION_BACKGROUND_COMMUNICATION_OSRA_KEY`,i=`FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY`,a=`FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY`,o=t=>e.p(t)&&t.FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY===!0&&typeof t.from==`string`&&e.p(t.message),s=new Map,c=r=>{let o=s.get(r);if(o)return o;let{promise:c,resolve:l}=Promise.withResolvers(),{promise:u,resolve:d}=Promise.withResolvers(),f={resolvers:(0,t.expose)(h,{key:i,revivableModules:e.r,transport:{isJson:!0,receive:e=>l(e),emit:e=>{n.runtime.sendMessage({[a]:!0,target:r,message:e}).catch(()=>{})}}}),listener:c,stale:u,markStale:d};return s.set(r,f),f};n.runtime.onMessage.addListener((e,n)=>{o(e)&&(0,t.checkOsraMessageKey)(e.message,`FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY`)&&c(e.from).listener.then(t=>t(e.message,{sender:n}))}),e.f(e=>{let t=s.get(e);t&&(t.markStale(),s.delete(e))});var l=async e=>{let t=c(e);return{resolvers:await Promise.race([t.resolvers,t.stale.then(()=>{throw Error(`peer ${e} became stale before connect completed`)})]),stale:t.stale}},u={[e.n]:e.t,[e.d]:e.u},d=(e,t)=>e.find(e=>e.type===t),f=e=>{let t=u[e.locatorType];if(!t)throw Error(`Unknown locator kind: "${e.locatorType}"`);let n=t.selectorModules,r=d(n,e.type);if(!r)throw Error(`Unknown selector: "${e.locatorType}.${e.type}"`);return r},p=e=>e.reduce((e,t)=>f(t).resolve({elements:e},...t.args),[document.documentElement]),m=e=>{for(let t=0;t<e.length;t++){let n=f(e[t]);if(n.resolvePeer)return{module:n,index:t}}return null},h={contentScriptDummy:()=>{},executeLocator:async(t,n,r)=>{let i=m(t);if(i){let e=await i.module.resolvePeer({parts:t,selfIndex:i.index,resolveLocal:p}),{resolvers:a,stale:o}=await l(e),s=t.slice(i.index+1);return Promise.race([a.executeLocator(s,n,r),o.then(()=>{throw Error(`peer ${e} became stale during call, retrying`)})])}let a=d([...e.t.operationModules,...e.u.operationModules],n);if(!a)throw Error(`Unknown operation: "${n}"`);return a.resolve({elements:p(t)},...r)}},g=(0,t.expose)(h,{key:r,transport:{isJson:!0,receive:n.runtime.onMessage,emit:n.runtime}});exports.backgroundResolvers=g;
|
|
1
|
+
const e=require(`./locator-DHsqhrFb.cjs`);let t=require(`osra`);var n=e.h(((e,t)=>{(function(n,r){if(typeof define==`function`&&define.amd)define(`webextension-polyfill`,[`module`],r);else if(e!==void 0)r(t);else{var i={exports:{}};r(i),n.browser=i.exports}})(typeof globalThis<`u`?globalThis:typeof self<`u`?self:e,function(e){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw Error(`This script should only be loaded in a browser extension.`);globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id?e.exports=globalThis.browser:e.exports=(e=>{let t={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(t).length===0)throw Error(`api-metadata.json has not been included in browser-polyfill`);class n extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}let r=e=>e&&typeof e==`object`&&typeof e.then==`function`,i=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&n.singleCallbackArg!==!1?t.resolve(r[0]):t.resolve(r)},a=e=>e==1?`argument`:`arguments`,o=(e,t)=>function(n,...r){if(r.length<t.minArgs)throw Error(`Expected at least ${t.minArgs} ${a(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw Error(`Expected at most ${t.maxArgs} ${a(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise((a,o)=>{if(t.fallbackToNoCallback)try{n[e](...r,i({resolve:a,reject:o},t))}catch(i){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,i),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,a()}else t.noCallback?(n[e](...r),a()):n[e](...r,i({resolve:a,reject:o},t))})},s=(e,t,n)=>new Proxy(t,{apply(t,r,i){return n.call(r,e,...i)}}),c=Function.call.bind(Object.prototype.hasOwnProperty),l=(e,t={},n={})=>{let r=Object.create(null);return new Proxy(Object.create(e),{has(t,n){return n in e||n in r},get(i,a,u){if(a in r)return r[a];if(!(a in e))return;let d=e[a];if(typeof d==`function`)if(typeof t[a]==`function`)d=s(e,e[a],t[a]);else if(c(n,a)){let t=o(a,n[a]);d=s(e,e[a],t)}else d=d.bind(e);else if(typeof d==`object`&&d&&(c(t,a)||c(n,a)))d=l(d,t[a],n[a]);else if(c(n,`*`))d=l(d,t[a],n[`*`]);else return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get(){return e[a]},set(t){e[a]=t}}),d;return r[a]=d,d},set(t,n,i,a){return n in r?r[n]=i:e[n]=i,!0},defineProperty(e,t,n){return Reflect.defineProperty(r,t,n)},deleteProperty(e,t){return Reflect.deleteProperty(r,t)}})},u=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener(t,n){return t.hasListener(e.get(n))},removeListener(t,n){t.removeListener(e.get(n))}}),d=new n(e=>typeof e==`function`?function(t){e(l(t,{},{getContent:{minArgs:0,maxArgs:0}}))}:e),f=new n(e=>typeof e==`function`?function(t,n,i){let a=!1,o,s=new Promise(e=>{o=function(t){a=!0,e(t)}}),c;try{c=e(t,n,o)}catch(e){c=Promise.reject(e)}let l=c!==!0&&r(c);return c!==!0&&!l&&!a?!1:((e=>{e.then(e=>{i(e)},e=>{let t;t=e&&(e instanceof Error||typeof e.message==`string`)?e.message:`An unexpected error occurred`,i({__mozWebExtensionPolyfillReject__:!0,message:t})}).catch(e=>{console.error(`Failed to send onMessage rejected reply`,e)})})(l?c:s),!0)}:e),p=({reject:t,resolve:n},r)=>{e.runtime.lastError?e.runtime.lastError.message===`The message port closed before a response was received.`?n():t(Error(e.runtime.lastError.message)):r&&r.__mozWebExtensionPolyfillReject__?t(Error(r.message)):n(r)},m=(e,t,n,...r)=>{if(r.length<t.minArgs)throw Error(`Expected at least ${t.minArgs} ${a(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw Error(`Expected at most ${t.maxArgs} ${a(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise((e,t)=>{let i=p.bind(null,{resolve:e,reject:t});r.push(i),n.sendMessage(...r)})},h={devtools:{network:{onRequestFinished:u(d)}},runtime:{onMessage:u(f),onMessageExternal:u(f),sendMessage:m.bind(null,`sendMessage`,{minArgs:1,maxArgs:3})},tabs:{sendMessage:m.bind(null,`sendMessage`,{minArgs:2,maxArgs:3})}},g={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return t.privacy={network:{"*":g},services:{"*":g},websites:{"*":g}},l(e,h,t)})(chrome)})}))(),r=`FKN_WEB_EXTENSION_BACKGROUND_COMMUNICATION_OSRA_KEY`,i=`FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY`,a=`FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY`,o=t=>e.c(t)&&t.FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY===!0&&typeof t.from==`string`&&e.c(t.message),s=new Map,c=r=>{let o=s.get(r);if(o)return o;let{promise:c,resolve:l}=Promise.withResolvers(),{promise:u,resolve:d}=Promise.withResolvers(),f={resolvers:(0,t.expose)(D,{key:i,revivableModules:e.l,transport:{isJson:!0,receive:e=>l(e),emit:e=>{n.runtime.sendMessage({[a]:!0,target:r,message:e}).catch(()=>{})}}}),listener:c,stale:u,markStale:d};return s.set(r,f),f};n.runtime.onMessage.addListener((e,n)=>{o(e)&&(0,t.checkOsraMessageKey)(e.message,`FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY`)&&c(e.from).listener.then(t=>t(e.message,{sender:n}))}),e.s(e=>{let t=s.get(e);t&&(t.markStale(),s.delete(e))});var l=async e=>{let t=c(e);return{resolvers:await Promise.race([t.resolvers,t.stale.then(()=>{throw Error(`peer ${e} became stale before connect completed`)})]),stale:t.stale}},u=[`position: fixed`,`border: 2px solid oklch(63% 0.24 25)`,`border-radius: 4px`,`background: oklch(63% 0.24 25 / 0.12)`,`box-shadow: 0 0 0 2px oklch(63% 0.24 25 / 0.5), 0 0 0 100vmax oklch(0% 0 0 / 0.5)`,`z-index: 2147483647`,`pointer-events: none`,`box-sizing: border-box`],d=(e,t)=>{let n=t.getBoundingClientRect();e.setAttribute(`style`,[...u,`left: ${n.left}px`,`top: ${n.top}px`,`width: ${n.width}px`,`height: ${n.height}px`].map(e=>`${e} !important`).join(`; `))},f=e=>{let t=e.getBoundingClientRect();return{clientX:t.left+t.width/2,clientY:t.top+t.height/2}},p=0,m=e=>{p^=1;let{clientX:t,clientY:n}=f(e),r={bubbles:!0,cancelable:!0,composed:!0,clientX:t+p,clientY:n};e.dispatchEvent(new PointerEvent(`pointermove`,{...r,pointerType:`mouse`,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent(`mousemove`,r))},h=[[PointerEvent,`pointerover`,!0],[PointerEvent,`pointerenter`,!1],[MouseEvent,`mouseover`,!0],[MouseEvent,`mouseenter`,!1]],g=[[PointerEvent,`pointerout`,!0],[PointerEvent,`pointerleave`,!1],[MouseEvent,`mouseout`,!0],[MouseEvent,`mouseleave`,!1]],_=(e,t)=>t.forEach(([t,n,r])=>e.dispatchEvent(new t(n,{bubbles:r,cancelable:!0,composed:!0,...f(e)}))),v=e=>{_(e,h),m(e)},y=e=>_(e,g),b=null,x=e=>{S();try{e.scrollIntoView({block:`center`,inline:`center`})}catch{}let t=document.createElement(`div`);(document.body??document.documentElement).appendChild(t),v(e);let n=requestAnimationFrame(function r(){d(t,e),n=requestAnimationFrame(r)}),r=window.setInterval(()=>m(e),300);b={stop:()=>{cancelAnimationFrame(n),clearInterval(r),y(e),t.remove()}}},S=()=>{b?.stop(),b=null},C={[e.n]:e.t,[e.a]:e.i},w=e=>{let t=C[e.locatorType];if(!t)throw Error(`Unknown locator kind: "${e.locatorType}"`);let n=t.selectorModules.find(t=>t.type===e.type);if(!n)throw Error(`Unknown selector: "${e.locatorType}.${e.type}"`);return n},T=e=>e.reduce((e,t)=>w(t).resolve({elements:e},...t.args),[document.documentElement]),E=e=>{for(let t=0;t<e.length;t++){let n=w(e[t]);if(n.resolvePeer)return{module:n,index:t}}return null},D={contentScriptDummy:()=>{},executeLocator:async(t,n,r)=>{let i=E(t);if(i){let e=await i.module.resolvePeer({parts:t,selfIndex:i.index,resolveLocal:T}),{resolvers:a,stale:o}=await l(e),s=t.slice(i.index+1);return Promise.race([a.executeLocator(s,n,r),o.then(()=>{throw Error(`peer ${e} became stale during call, retrying`)})])}if(n===`__fkn_highlight`){if(r[0]?.on){let n=T(t)[0];n&&(e.o(!0),x(n))}else S(),e.o(!1);return}let a=[...e.t.operationModules,...e.i.operationModules].find(e=>e.type===n);if(!a)throw Error(`Unknown operation: "${n}"`);return a.resolve({elements:T(t)},...r)}},O=(0,t.expose)(D,{key:r,transport:{isJson:!0,receive:n.runtime.onMessage,emit:n.runtime}});exports.backgroundResolvers=O;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { checkOsraMessageKey as
|
|
1
|
+
import { a as e, c as t, h as n, i as r, l as i, n as a, o, s, t as c } from "./locator-1wWrCOyE.js";
|
|
2
|
+
import { checkOsraMessageKey as l, expose as u } from "osra";
|
|
3
3
|
//#endregion
|
|
4
|
-
//#region
|
|
5
|
-
var
|
|
4
|
+
//#region ../web-extension/lib/background/constants.js
|
|
5
|
+
var d = (/* @__PURE__ */ n(((e, t) => {
|
|
6
6
|
(function(n, r) {
|
|
7
7
|
if (typeof define == "function" && define.amd) define("webextension-polyfill", ["module"], r);
|
|
8
8
|
else if (e !== void 0) r(t);
|
|
@@ -827,19 +827,19 @@ var u = (/* @__PURE__ */ n(((e, t) => {
|
|
|
827
827
|
}, l(e, h, t);
|
|
828
828
|
})(chrome);
|
|
829
829
|
});
|
|
830
|
-
})))(),
|
|
831
|
-
let t =
|
|
830
|
+
})))(), f = "FKN_WEB_EXTENSION_BACKGROUND_COMMUNICATION_OSRA_KEY", p = "FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY", m = "FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY", h = (e) => t(e) && e.FKN_WEB_EXTENSION_CONTENT_SCRIPT_RELAY_ENVELOPE_KEY === !0 && typeof e.from == "string" && t(e.message), g = /* @__PURE__ */ new Map(), _ = (e) => {
|
|
831
|
+
let t = g.get(e);
|
|
832
832
|
if (t) return t;
|
|
833
|
-
let { promise: n, resolve: r } = Promise.withResolvers(), { promise:
|
|
834
|
-
resolvers:
|
|
835
|
-
key:
|
|
836
|
-
revivableModules:
|
|
833
|
+
let { promise: n, resolve: r } = Promise.withResolvers(), { promise: a, resolve: o } = Promise.withResolvers(), s = {
|
|
834
|
+
resolvers: u(I, {
|
|
835
|
+
key: p,
|
|
836
|
+
revivableModules: i,
|
|
837
837
|
transport: {
|
|
838
838
|
isJson: !0,
|
|
839
839
|
receive: (e) => r(e),
|
|
840
840
|
emit: (t) => {
|
|
841
|
-
|
|
842
|
-
[
|
|
841
|
+
d.runtime.sendMessage({
|
|
842
|
+
[m]: !0,
|
|
843
843
|
target: e,
|
|
844
844
|
message: t
|
|
845
845
|
}).catch(() => {});
|
|
@@ -847,68 +847,181 @@ var u = (/* @__PURE__ */ n(((e, t) => {
|
|
|
847
847
|
}
|
|
848
848
|
}),
|
|
849
849
|
listener: n,
|
|
850
|
-
stale:
|
|
850
|
+
stale: a,
|
|
851
851
|
markStale: o
|
|
852
852
|
};
|
|
853
|
-
return
|
|
853
|
+
return g.set(e, s), s;
|
|
854
854
|
};
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}),
|
|
858
|
-
let t =
|
|
859
|
-
t && (t.markStale(),
|
|
855
|
+
d.runtime.onMessage.addListener((e, t) => {
|
|
856
|
+
h(e) && l(e.message, "FKN_WEB_EXTENSION_CONTENT_SCRIPT_PEER_OSRA_KEY") && _(e.from).listener.then((n) => n(e.message, { sender: t }));
|
|
857
|
+
}), s((e) => {
|
|
858
|
+
let t = g.get(e);
|
|
859
|
+
t && (t.markStale(), g.delete(e));
|
|
860
860
|
});
|
|
861
|
-
var
|
|
862
|
-
let t =
|
|
861
|
+
var v = async (e) => {
|
|
862
|
+
let t = _(e);
|
|
863
863
|
return {
|
|
864
864
|
resolvers: await Promise.race([t.resolvers, t.stale.then(() => {
|
|
865
865
|
throw Error(`peer ${e} became stale before connect completed`);
|
|
866
866
|
})]),
|
|
867
867
|
stale: t.stale
|
|
868
868
|
};
|
|
869
|
-
},
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
869
|
+
}, y = [
|
|
870
|
+
"position: fixed",
|
|
871
|
+
"border: 2px solid oklch(63% 0.24 25)",
|
|
872
|
+
"border-radius: 4px",
|
|
873
|
+
"background: oklch(63% 0.24 25 / 0.12)",
|
|
874
|
+
"box-shadow: 0 0 0 2px oklch(63% 0.24 25 / 0.5), 0 0 0 100vmax oklch(0% 0 0 / 0.5)",
|
|
875
|
+
"z-index: 2147483647",
|
|
876
|
+
"pointer-events: none",
|
|
877
|
+
"box-sizing: border-box"
|
|
878
|
+
], b = (e, t) => {
|
|
879
|
+
let n = t.getBoundingClientRect();
|
|
880
|
+
e.setAttribute("style", [
|
|
881
|
+
...y,
|
|
882
|
+
`left: ${n.left}px`,
|
|
883
|
+
`top: ${n.top}px`,
|
|
884
|
+
`width: ${n.width}px`,
|
|
885
|
+
`height: ${n.height}px`
|
|
886
|
+
].map((e) => `${e} !important`).join("; "));
|
|
887
|
+
}, x = (e) => {
|
|
888
|
+
let t = e.getBoundingClientRect();
|
|
889
|
+
return {
|
|
890
|
+
clientX: t.left + t.width / 2,
|
|
891
|
+
clientY: t.top + t.height / 2
|
|
892
|
+
};
|
|
893
|
+
}, S = 0, C = (e) => {
|
|
894
|
+
S ^= 1;
|
|
895
|
+
let { clientX: t, clientY: n } = x(e), r = {
|
|
896
|
+
bubbles: !0,
|
|
897
|
+
cancelable: !0,
|
|
898
|
+
composed: !0,
|
|
899
|
+
clientX: t + S,
|
|
900
|
+
clientY: n
|
|
901
|
+
};
|
|
902
|
+
e.dispatchEvent(new PointerEvent("pointermove", {
|
|
903
|
+
...r,
|
|
904
|
+
pointerType: "mouse",
|
|
905
|
+
pointerId: 1,
|
|
906
|
+
isPrimary: !0
|
|
907
|
+
})), e.dispatchEvent(new MouseEvent("mousemove", r));
|
|
908
|
+
}, w = [
|
|
909
|
+
[
|
|
910
|
+
PointerEvent,
|
|
911
|
+
"pointerover",
|
|
912
|
+
!0
|
|
913
|
+
],
|
|
914
|
+
[
|
|
915
|
+
PointerEvent,
|
|
916
|
+
"pointerenter",
|
|
917
|
+
!1
|
|
918
|
+
],
|
|
919
|
+
[
|
|
920
|
+
MouseEvent,
|
|
921
|
+
"mouseover",
|
|
922
|
+
!0
|
|
923
|
+
],
|
|
924
|
+
[
|
|
925
|
+
MouseEvent,
|
|
926
|
+
"mouseenter",
|
|
927
|
+
!1
|
|
928
|
+
]
|
|
929
|
+
], T = [
|
|
930
|
+
[
|
|
931
|
+
PointerEvent,
|
|
932
|
+
"pointerout",
|
|
933
|
+
!0
|
|
934
|
+
],
|
|
935
|
+
[
|
|
936
|
+
PointerEvent,
|
|
937
|
+
"pointerleave",
|
|
938
|
+
!1
|
|
939
|
+
],
|
|
940
|
+
[
|
|
941
|
+
MouseEvent,
|
|
942
|
+
"mouseout",
|
|
943
|
+
!0
|
|
944
|
+
],
|
|
945
|
+
[
|
|
946
|
+
MouseEvent,
|
|
947
|
+
"mouseleave",
|
|
948
|
+
!1
|
|
949
|
+
]
|
|
950
|
+
], E = (e, t) => t.forEach(([t, n, r]) => e.dispatchEvent(new t(n, {
|
|
951
|
+
bubbles: r,
|
|
952
|
+
cancelable: !0,
|
|
953
|
+
composed: !0,
|
|
954
|
+
...x(e)
|
|
955
|
+
}))), D = (e) => {
|
|
956
|
+
E(e, w), C(e);
|
|
957
|
+
}, O = (e) => E(e, T), k = null, A = (e) => {
|
|
958
|
+
j();
|
|
959
|
+
try {
|
|
960
|
+
e.scrollIntoView({
|
|
961
|
+
block: "center",
|
|
962
|
+
inline: "center"
|
|
963
|
+
});
|
|
964
|
+
} catch {}
|
|
965
|
+
let t = document.createElement("div");
|
|
966
|
+
(document.body ?? document.documentElement).appendChild(t), D(e);
|
|
967
|
+
let n = requestAnimationFrame(function r() {
|
|
968
|
+
b(t, e), n = requestAnimationFrame(r);
|
|
969
|
+
}), r = window.setInterval(() => C(e), 300);
|
|
970
|
+
k = { stop: () => {
|
|
971
|
+
cancelAnimationFrame(n), clearInterval(r), O(e), t.remove();
|
|
972
|
+
} };
|
|
973
|
+
}, j = () => {
|
|
974
|
+
k?.stop(), k = null;
|
|
975
|
+
}, M = {
|
|
976
|
+
[a]: c,
|
|
977
|
+
[e]: r
|
|
978
|
+
}, N = (e) => {
|
|
979
|
+
let t = M[e.locatorType];
|
|
874
980
|
if (!t) throw Error(`Unknown locator kind: "${e.locatorType}"`);
|
|
875
|
-
let n = t.selectorModules
|
|
876
|
-
if (!
|
|
877
|
-
return
|
|
878
|
-
},
|
|
981
|
+
let n = t.selectorModules.find((t) => t.type === e.type);
|
|
982
|
+
if (!n) throw Error(`Unknown selector: "${e.locatorType}.${e.type}"`);
|
|
983
|
+
return n;
|
|
984
|
+
}, P = (e) => e.reduce((e, t) => N(t).resolve({ elements: e }, ...t.args), [document.documentElement]), F = (e) => {
|
|
879
985
|
for (let t = 0; t < e.length; t++) {
|
|
880
|
-
let n =
|
|
986
|
+
let n = N(e[t]);
|
|
881
987
|
if (n.resolvePeer) return {
|
|
882
988
|
module: n,
|
|
883
989
|
index: t
|
|
884
990
|
};
|
|
885
991
|
}
|
|
886
992
|
return null;
|
|
887
|
-
},
|
|
993
|
+
}, I = {
|
|
888
994
|
contentScriptDummy: () => {},
|
|
889
995
|
executeLocator: async (e, t, n) => {
|
|
890
|
-
let
|
|
891
|
-
if (
|
|
892
|
-
let
|
|
996
|
+
let i = F(e);
|
|
997
|
+
if (i) {
|
|
998
|
+
let r = await i.module.resolvePeer({
|
|
893
999
|
parts: e,
|
|
894
|
-
selfIndex:
|
|
895
|
-
resolveLocal:
|
|
896
|
-
}), { resolvers: a, stale: o } = await
|
|
1000
|
+
selfIndex: i.index,
|
|
1001
|
+
resolveLocal: P
|
|
1002
|
+
}), { resolvers: a, stale: o } = await v(r), s = e.slice(i.index + 1);
|
|
897
1003
|
return Promise.race([a.executeLocator(s, t, n), o.then(() => {
|
|
898
|
-
throw Error(`peer ${
|
|
1004
|
+
throw Error(`peer ${r} became stale during call, retrying`);
|
|
899
1005
|
})]);
|
|
900
1006
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1007
|
+
if (t === "__fkn_highlight") {
|
|
1008
|
+
if (n[0]?.on) {
|
|
1009
|
+
let t = P(e)[0];
|
|
1010
|
+
t && (o(!0), A(t));
|
|
1011
|
+
} else j(), o(!1);
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
let a = [...c.operationModules, ...r.operationModules].find((e) => e.type === t);
|
|
1015
|
+
if (!a) throw Error(`Unknown operation: "${t}"`);
|
|
1016
|
+
return a.resolve({ elements: P(e) }, ...n);
|
|
904
1017
|
}
|
|
905
|
-
},
|
|
906
|
-
key:
|
|
1018
|
+
}, L = u(I, {
|
|
1019
|
+
key: f,
|
|
907
1020
|
transport: {
|
|
908
1021
|
isJson: !0,
|
|
909
|
-
receive:
|
|
910
|
-
emit:
|
|
1022
|
+
receive: d.runtime.onMessage,
|
|
1023
|
+
emit: d.runtime
|
|
911
1024
|
}
|
|
912
1025
|
});
|
|
913
1026
|
//#endregion
|
|
914
|
-
export {
|
|
1027
|
+
export { L as backgroundResolvers };
|
package/index.cjs
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./locator-CcAGamNm.cjs`);let t=require(`osra`),n=require(`stream`),r=require(`events`),i=require(`ip-address`),a=require(`buffer`);var o=`https://fkn.app`,s=globalThis?.document.querySelector(`iframe[src="${o}/api"]`),c=globalThis.document?.createElement(`iframe`);!s&&c&&(c.src=`${o}/api`,c.style.display=`none`,document.body.appendChild(c));var l=s||c,u=l.contentWindow;if(!l.contentWindow)throw Error(`Missing iframe content window`);var d=e=>new Promise((n,r)=>{let i=new AbortController,a=setTimeout(()=>{i.abort(),r(Error(`Timeout waiting for api to be exposed`))},e);(0,t.expose)({},{key:`fkn-api`,unregisterSignal:i.signal,transport:{receive:window,emit:u}}).then(e=>{clearTimeout(a),n(e)}).catch(e=>{clearTimeout(a),r(e)})}),f=(e=50)=>d(e).then(e=>e).catch(t=>{if(t.message===`Timeout waiting for api to be exposed`)return f(Math.min(e*2,500));throw t}),p=f(),m=(e,t)=>p.then(n=>n.proxyFetch(e,t)),h=new TextEncoder;new TextDecoder;var g=e=>i.Address4.isValid(e),_=e=>i.Address6.isValid(e),v=e=>g(e)?4:_(e)?6:0,y=(...e)=>{if(typeof e[0]==`string`)throw Error(`FKN WebVPN does not support IPC connections`);let t=typeof e.at(-1)==`function`?e.at(-1):void 0;return e[0]&&typeof e[0]==`object`?{...e[0],callback:t}:{port:e[0]??0,host:typeof e[1]==`string`?e[1]:void 0,callback:t}},b=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0]??0,r=typeof e[1]==`string`?e[1]:void 0;return typeof e[0]==`object`?{...e[0],address:e[0].address??r,port:e[0].port??n,callback:t}:{address:r,port:n,callback:t}},x=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0];if(typeof e[2]==`number`)return{message:n,offset:e[1],length:e[2],port:typeof e[3]==`number`?e[3]:0,address:typeof e[4]==`string`?e[4]:void 0,callback:t};{let r=typeof e[1]==`number`?e[1]:0,i=typeof e[2]==`string`?e[2]:void 0;return{message:n,offset:0,length:n.length,port:r,address:i,callback:t}}};new TextEncoder,new TextDecoder;var S=e.h({Server:()=>w,Socket:()=>C,_default:()=>O,connect:()=>T,createConnection:()=>E,createServer:()=>D,default:()=>O,isIP:()=>v,isIPv4:()=>g,isIPv6:()=>_}),C=class extends n.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super(e),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}__webvpn_tcp_socket_init__(e){if(this._webVPNTcpSocketPromise=e.then(e=>{let t=e.dataReadableStream.getReader(),n=e.dataWritableStream.getWriter();return this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._remoteAddress={address:e.remoteAddress,family:e.remoteFamily,port:e.remotePort},{...e,reader:t,writer:n}}).catch(e=>{this.emit(`error`,e)}),!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);return this._webVPNTcpSocketPromise.then(e=>{e&&this.emit(`connect`)}),this._webVPNTcpSocketPromise}_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{if(!e)throw Error(`Socket not connected`);e.reader.read().then(({value:e,done:t})=>{if(t){this.push(null);return}this._restartTimeoutTimer(),this.push(e)}).catch(e=>{this.destroy(e)})})}_write(e,t,n){if(!this._webVPNTcpSocketPromise){n(Error(`Socket not connected`));return}this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e),this._restartTimeoutTimer(),n()}).catch(n)}connect(...e){let t=y(...e),n=this.__webvpn_tcp_socket_init__(p.then(e=>e.webVpnTcpSocket({remoteAddress:t.host??`localhost`,remotePort:t.port})));return t.callback&&n.then(e=>{e&&t.callback()}),this}_end(...e){return this._webVPNTcpSocketPromise?(e.length!==0&&this.write(e[0],e[1],e[2]),this._webVPNTcpSocketPromise.then(async e=>{e&&await e.end()}),this):this}_destroy(e){return this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroy()}),this}destroySoon(){this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroySoon()})}resetAndDestroy(){return this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.resetAndDestroy()}),this}_timeoutMs;_timeoutTimer;_restartTimeoutTimer(){this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._timeoutMs&&(this._timeoutTimer=setTimeout(()=>this.emit(`timeout`),this._timeoutMs))}setTimeout(e,t){return t&&this.on(`timeout`,t),this._timeoutMs=e,this._restartTimeoutTimer(),this}setNoDelay(e){let t=e??!0;return this._setTcpOption({type:0,value:t}),this}setKeepAlive(e,t){let n=e??!1,r=t!==void 0&&t>0?Math.max(1,Math.round(t/1e3)):0;return this._setTcpOption({type:2,enabled:n,initialDelaySeconds:r}),this}setSendBufferSize(e){return this._setTcpOption({type:3,value:e}),this}setRecvBufferSize(e){return this._setTcpOption({type:4,value:e}),this}_setTcpOption(e){if(!this._webVPNTcpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before connect`));return}this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}write(e,t,...n){return super.write(e,t,...n)}address(){return this._localAddress??{}}unref(){return this}ref(){return this}autoSelectFamilyAttemptedAddresses;bufferSize;bytesRead;bytesWritten;connecting;pending;get localAddress(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.address}get localPort(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.port}get localFamily(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.family}readyState;get remoteAddress(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.address}get remotePort(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.port}get remoteFamily(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.family}timeout},w=class extends r.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;constructor(e,t){super(e),t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}__webvpn_tcp_socket_listener_init__(e){return this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e)).catch(e=>{this.emit(`error`,e)}),this._webVPNTcpSocketListenerPromise.then(e=>{e&&this.emit(`listening`)}),this._webVPNTcpSocketListenerPromise}listen(...e){let t=y(...e),n=this.__webvpn_tcp_socket_listener_init__(p.then(e=>e.webVpnTcpSocketListener({localAddress:t.host??`::`,localPort:t.port,onConnection:e=>{let t=new C({connection:Promise.resolve(e)});this.emit(`connection`,t)}})));return t.callback&&n.then(e=>{e&&t.callback()}),this}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this.emit(`close`),e&&e()}catch(t){this._localAddress=void 0,this.emit(`close`),e&&e(t)}}),this}address(){return this._localAddress??null}getConnections(e){throw Error(`Method not implemented.`)}ref(){throw Error(`Method not implemented.`)}unref(){throw Error(`Method not implemented.`)}maxConnections;connections;listening;async[Symbol.asyncDispose](){}},T=(e,t)=>new C().connect(e,t),E=(e,t)=>new C().connect(e,t),D=(e,t)=>{let n=new w(e);return t&&n.on(`connection`,t),n},O={Socket:C,Server:w,connect:T,createConnection:E,createServer:D,isIP:v,isIPv4:g,isIPv6:_},k=e.h({Socket:()=>A,createSocket:()=>N}),A=class extends r.EventEmitter{_type;_localAddress;_remoteAddress;_webVPNUdpSocketPromise;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}addMembership(e,t){if(i.Address4.isValid(e)){let n=j(e),r=t&&i.Address4.isValid(t)?j(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(i.Address6.isValid(e)){let t=M(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let t=b(...e),n=this._type===`udp6`?`::`:`0.0.0.0`;return this._webVPNUdpSocketPromise=p.then(e=>e.webVpnUdpSocket({type:this._type,address:t.address??n,port:t.port})).then(e=>{let t=e.dataReadableStream.getReader(),n=async()=>{let{value:e,done:r}=await t.read();r||(this.emit(`message`,a.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size}),n())};return n(),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{e&&this.emit(`listening`)}),t.callback&&this._webVPNUdpSocketPromise.then(e=>{e&&t.callback()}),this}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);await t.close(),e&&e(),this.emit(`close`)}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0;await t.connect({remotePort:n,remoteAddress:i}),this._remoteAddress={address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},a&&a()})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async e=>{if(!e)throw Error(`Socket not bound`);await e.connect({remotePort:0,remoteAddress:this._type===`udp4`?`0.0.0.0`:`::`})})}dropMembership(e,t){if(i.Address4.isValid(e)){let n=j(e),r=t&&i.Address4.isValid(t)?j(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(i.Address6.isValid(e)){let t=M(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=x(...e),n=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let r=typeof t.message==`string`?h.encode(t.message):t.message;e.send({...t,address:t.address??n,message:r.buffer})})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},j=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},M=e=>{let t=new i.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},N=(e,t)=>{let n=new A(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n};(()=>{let t={},n=[...e.t.selectorModules,...e.u.selectorModules];for(let e of n)e.render&&!(e.type in t)&&(t[e.type]=e.render);return t})();var P=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,F=`fknExtension`,I=(0,t.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(P,e=>{I.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:e.detail.enabled}}))});var L=()=>document.documentElement.dataset[F]===`true`,R=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,z,B=new Proxy({},{get:(n,r)=>async(...n)=>{if(!L())throw Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`);return z??=(0,t.expose)({},{transport:window,revivableModules:e.r}),(await z)[r](...n)}}),V=async({iframe:t,domains:n=[]})=>{let r=crypto.randomUUID();t.dispatchEvent(new CustomEvent(R,{detail:r}));let{executeLocator:i,goto:a}=await B.attachFrame({marker:r,domains:n}),o=e.l(i),s=(e,t={})=>a({url:e,...t}),c=()=>t.src;return{...o,goto:s,url:c}};exports.ATTACH_FRAME_EVENT_KEY=R,exports.attachFrame=V,exports.box=e.i,exports.createVideoElementHandle=e.a,Object.defineProperty(exports,`dgram`,{enumerable:!0,get:function(){return k}}),exports.handleRevivableModules=e.r,exports.isType=e.o,Object.defineProperty(exports,`net`,{enumerable:!0,get:function(){return S}}),exports.revive=e.s,exports.serverProxyFetch=m,exports.type=e.c;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./locator-DHsqhrFb.cjs`);let t=require(`osra`),n=require(`preact`),r=require(`@cloudflare/blindrsa-ts`),i=require(`stream`),a=require(`events`),o=require(`ip-address`),s=require(`buffer`);var c=`https://fkn.app`,l=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,u=l?.querySelector(`iframe[src="${c}/api"]`)??null,d=l?.createElement(`iframe`)??null;!u&&d&&l&&(d.src=`${c}/api`,d.style.display=`none`,l.body.appendChild(d));var f=u??d,p=f?.contentWindow??null,m=f?.style.cssText??``,h=e=>{f&&Object.assign(f.style,e)},g=()=>{f&&(f.style.cssText=m)},_=typeof window<`u`&&f?{changeIframeStyle:h,resetIframeStyle:g}:{},v=()=>{if(typeof window<`u`)return p?{receive:window,emit:p}:void 0;if(typeof self<`u`)return{receive:self,emit:self}},y=e=>new Promise((n,r)=>{let i=v();if(!i)return;let a=new AbortController,o=setTimeout(()=>{a.abort(),r(Error(`Timeout waiting for api to be exposed`))},e);(0,t.expose)(_,{key:`fkn-api`,unregisterSignal:a.signal,transport:i}).then(e=>{clearTimeout(o),n(e)}).catch(e=>{clearTimeout(o),r(e)})}),b=(e=50)=>y(e).then(e=>e).catch(t=>{if(t.message===`Timeout waiting for api to be exposed`)return b(Math.min(e*2,500));throw t}),x=b(),ee=(e,t)=>x.then(n=>n.proxyFetch(e,t)),te=`https://fkn.app`,ne=(e,n)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);if(!f?.contentWindow)throw Error(`FKN @fkn/lib: relayWorker called before the FKN iframe was injected`);(0,t.relay)({receive:window,emit:f.contentWindow},e,{key:`fkn-api`,originA:n?.originA??te,originB:n?.originB??`*`,unregisterSignal:n?.unregisterSignal})},re=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,ie=`fknExtension`,S=(0,t.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(re,e=>{S.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:e.detail.enabled}}))});var C=()=>document.documentElement.dataset[ie]===`true`,ae=null,oe=e=>{ae=e},se=(e=1e3)=>new Promise((t,n)=>{if(C())return t();let r=e=>{clearTimeout(s),a.disconnect(),document.removeEventListener(`readystatechange`,o),e()},i=()=>r(async()=>{if(ae&&(await ae().catch(()=>{}),C()))return t();n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),a=new MutationObserver(()=>{C()&&r(t)}),o=()=>{document.readyState===`complete`&&!C()&&i()},s=setTimeout(i,e);if(document.readyState===`complete`)return i();a.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,o),C()&&r(t)}),ce,w=new Proxy({},{get:(n,r)=>async(...n)=>{await se(),ce??=(0,t.expose)({},{transport:window,revivableModules:e.l});let i=(await ce)[r];return i(...n)}}),le={scope:`network.fetch`,category:`network`,severity:0,title:`Fetch data from other sites`,description:`Lets the app download public data from other websites directly, past the usual cross-origin limits.`},ue={scope:`network.fetchCredentialed`,category:`network`,severity:3,unsafe:!0,title:`Fetch from other sites — signed in as you`,description:`Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see.`},de=[`origin`,`referer`],fe=e=>{if(!e?.headers)return;let t=new Headers(e.headers),n=de.map(e=>{let n=t.get(e);return n===null?void 0:[e,n]}).filter(e=>e!==void 0);return n.length?n:void 0},pe=async(e,t)=>{let n=new Request(e,t),r=n.body?await n.arrayBuffer():null;return w.proxyFetch({url:n.url,method:n.method,headers:[...n.headers],body:r,credentials:t?.credentials===`include`?`include`:`omit`,redirect:n.redirect,unsafeHeaders:fe(t),reason:t?.reason,signal:t?.signal??void 0})},me={scope:`network.readCookie`,category:`network`,severity:3,unsafe:!0,title:`Read a site’s cookie`,description:`Lets the app read a named cookie from another site, which can include the login token only that site should see.`},he={get:e=>w.getCookie(e)},ge={scope:`network.modifyRequestHeaders`,category:`network`,severity:2,unsafe:!0,title:`Rewrite request headers to other sites`,description:`Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites.`},_e=e=>w.setRequestHeaderRule(e),ve=e=>w.removeRequestHeaderRule({ruleId:e});(()=>{let t={},n=[...e.t.selectorModules,...e.i.selectorModules];for(let e of n)e.render&&!(e.type in t)&&(t[e.type]=e.render);return t})();var ye=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,be={scope:`embed.iframe`,category:`embed`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},xe={scope:`embed.open`,category:`embed`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},Se=async({iframe:t,domains:n=[]})=>{let r=crypto.randomUUID();if(await se(),!t.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);t.dispatchEvent(new CustomEvent(ye,{detail:r}));let{executeLocator:i,ensureLocatorPermission:a,goto:o}=await w.attachFrame({marker:r,domains:n}),s=e.r(i,a),c=(e,t={})=>o({url:e,...t}),l=()=>t.src;return{...s,goto:c,url:l}},Ce={request:e=>w.requestPermissions(e.map(e=>({key:e.key,scope:e.scope??``,reason:e.reason})))},we=async e=>{if(typeof window>`u`)return!1;if(C())return!0;let t=await x,n=null,r=new Promise(e=>{n=()=>{C()&&e(!0)},S.addEventListener(`statuschange`,n)}),i=t.showInstallPrompt(e).then(()=>!1),a=await Promise.race([r,i]);return n&&S.removeEventListener(`statuschange`,n),await t.hideInstallPrompt().catch(()=>{}),a},Te=null;oe(()=>(Te||=we().then(()=>void 0).finally(()=>{Te=null}),Te));var T,Ee,De,Oe=[],E=n.options,ke=E.__b,Ae=E.__r,je=E.diffed,Me=E.__c,Ne=E.unmount,Pe=E.__;function Fe(){for(var e;e=Oe.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(D),e.__H.__h.forEach(Re),e.__H.__h=[]}catch(t){e.__H.__h=[],E.__e(t,e.__v)}}E.__b=function(e){T=null,ke&&ke(e)},E.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pe&&Pe(e,t)},E.__r=function(e){Ae&&Ae(e);var t=(T=e.__c).__H;t&&(Ee===T?(t.__h=[],T.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(D),t.__h.forEach(Re),t.__h=[])),Ee=T},E.diffed=function(e){je&&je(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Oe.push(t)!==1&&De===E.requestAnimationFrame||((De=E.requestAnimationFrame)||Le)(Fe)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Ee=T=null},E.__c=function(e,t){t.some(function(e){try{e.__h.forEach(D),e.__h=e.__h.filter(function(e){return!e.__||Re(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],E.__e(n,e.__v)}}),Me&&Me(e,t)},E.unmount=function(e){Ne&&Ne(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{D(e)}catch(e){t=e}}),n.__H=void 0,t&&E.__e(t,n.__v))};var Ie=typeof requestAnimationFrame==`function`;function Le(e){var t,n=function(){clearTimeout(r),Ie&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ie&&(t=requestAnimationFrame(n))}function D(e){var t=T,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),T=t}function Re(e){var t=T;e.__c=e.__(),T=t}function ze(e,t){for(var n in t)e[n]=t[n];return e}function Be(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Ve(e,t){this.props=e,this.context=t}(Ve.prototype=new n.Component).isPureReactComponent=!0,Ve.prototype.shouldComponentUpdate=function(e,t){return Be(this.props,e)||Be(this.state,t)};var He=n.options.__b;n.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)},typeof Symbol<`u`&&Symbol.for,n.toChildArray;var Ue=n.options.__e;n.options.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Ue(e,t,n,r)};var We=n.options.unmount;function Ge(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=ze({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Ge(e,t,n)})),e}function Ke(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ke(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function qe(){this.__u=0,this.o=null,this.__b=null}function Je(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function O(){this.i=null,this.l=null}n.options.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),We&&We(e)},(qe.prototype=new n.Component).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Je(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ke(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},qe.prototype.componentWillUnmount=function(){this.o=[]},qe.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement(`div`),i=this.__v.__k[0].__c;this.__v.__k[0]=Ge(this.__b,r,i.__O=i.__P)}this.__b=null}var a=t.__a&&(0,n.createElement)(n.Fragment,null,e.fallback);return a&&(a.__u&=-33),[(0,n.createElement)(n.Fragment,null,t.__a?null:e.children),a]};var Ye=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(O.prototype=new n.Component).__a=function(e){var t=this,n=Je(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ye(t,e,r)):i()};n?n(a):a()}},O.prototype.render=function(e){this.i=null,this.l=new Map;var t=(0,n.toChildArray)(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var r=t.length;r--;)this.l.set(t[r],this.i=[1,0,this.i]);return e.children},O.prototype.componentDidUpdate=O.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ye(e,n,t)})};var Xe=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,Ze=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Qe=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,$e=/[A-Z0-9]/g,et=typeof document<`u`,tt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};n.Component.prototype.isReactComponent={},[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(n.Component.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var nt=n.options.event;function rt(){}function it(){return this.cancelBubble}function at(){return this.defaultPrevented}n.options.event=function(e){return nt&&(e=nt(e)),e.persist=rt,e.isPropagationStopped=it,e.isDefaultPrevented=at,e.nativeEvent=e};var ot={enumerable:!1,configurable:!0,get:function(){return this.class}},st=n.options.vnode;n.options.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,r=e.type,i={},a=r.indexOf(`-`)===-1;for(var o in t){var s=t[o];if(!(o===`value`&&`defaultValue`in t&&s==null||et&&o===`children`&&r===`noscript`||o===`class`||o===`className`)){var c=o.toLowerCase();o===`defaultValue`&&`value`in t&&t.value==null?o=`value`:o===`download`&&!0===s?s=``:c===`translate`&&s===`no`?s=!1:c[0]===`o`&&c[1]===`n`?c===`ondoubleclick`?o=`ondblclick`:c!==`onchange`||r!==`input`&&r!==`textarea`||tt(t.type)?c===`onfocus`?o=`onfocusin`:c===`onblur`?o=`onfocusout`:Qe.test(o)&&(o=c):c=o=`oninput`:a&&Ze.test(o)?o=o.replace($e,`-$&`).toLowerCase():s===null&&(s=void 0),c===`oninput`&&i[o=c]&&(o=`oninputCapture`),i[o]=s}}r==`select`&&i.multiple&&Array.isArray(i.value)&&(i.value=(0,n.toChildArray)(t.children).forEach(function(e){e.props.selected=i.value.indexOf(e.props.value)!=-1})),r==`select`&&i.defaultValue!=null&&(i.value=(0,n.toChildArray)(t.children).forEach(function(e){e.props.selected=i.multiple?i.defaultValue.indexOf(e.props.value)!=-1:i.defaultValue==e.props.value})),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,`className`,ot)):(t.className&&!t.class||t.class&&t.className)&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=Xe,st&&st(e)};var ct=n.options.__r;n.options.__r=function(e){ct&&ct(e),e.__c};var lt=n.options.diffed;n.options.diffed=function(e){lt&<(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};var ut=Symbol.for(`better-auth:broadcast-channel`),dt=()=>Math.floor(Date.now()/1e3),ft=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(!(typeof window>`u`))try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:dt()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event!==`session`||!t?.data||this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function pt(e=`better-auth.message`){return globalThis[ut]||(globalThis[ut]=new ft(e)),globalThis[ut]}var mt=Symbol.for(`better-auth:focus-manager`),ht=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function gt(){return globalThis[mt]||(globalThis[mt]=new ht),globalThis[mt]}var _t=Symbol.for(`better-auth:online-manager`),vt=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function yt(){return globalThis[_t]||(globalThis[_t]=new vt),globalThis[_t]}var bt={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},xt=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,St={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},Ct=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function wt(e){return e instanceof Date&&!isNaN(e.getTime())}function Tt(e){let t=Ct.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return wt(f)?f:null}function Et(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in St)return St[s];if(!xt.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(bt).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=Tt(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function Dt(e,t={strict:!0}){return Et(e,t)}var k=[],A=0,j=4,Ot=globalThis.nanostoresGlobal||={epoch:0},kt=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=A+j;t<k.length;)k[t]===e?k.splice(t,j):t+=j;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){Ot.epoch++;let i=!k.length;for(let i of t)k.push(i,n.value,e,r);if(i){for(A=0;A<k.length;A+=j)k[A](k[A+1],k[A+2],k[A+3]);k.length=0}},off(){},set(e){let t=n.value;t!==e&&(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},At=5,M=6,N=10,jt=(e,t,n,r)=>(e.events=e.events||{},e.events[n+N]||(e.events[n+N]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+N](),delete e.events[n+N])}),Mt=1e3,Nt=(e,t)=>jt(e,n=>{let r=t(n);r&&e.events[M].push(r)},At,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[M]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[M])t();e.events[M]=[]}},Mt)},()=>{e.listen=n,e.off=r}}),Pt=()=>typeof window>`u`,Ft=(e,t,n,r)=>{let i=kt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>a(e)}),a=async e=>new Promise(a=>{let o=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...o,query:{...o?.query,...e?.query},async onSuccess(e){i.set({data:e.data,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(n&&r<n)return;let a=e.error.status===401;i.set({error:e.error,data:a?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch}),await o?.onError?.(e)},async onRequest(e){let t=i.get();i.set({isPending:t.data===null,data:t.data,error:null,isRefetching:!0,refetch:i.value.refetch}),await o?.onRequest?.(e)}}).catch(e=>{i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{a(void 0)})});e=Array.isArray(e)?e:[e];let o=!1;for(let t of e)t.subscribe(async()=>{Pt()||(o?await a():Nt(i,()=>{let e=setTimeout(async()=>{o||(o=!0,await a())},0);return()=>{i.off(),t.off(),clearTimeout(e)}}))});return i},P=()=>Math.floor(Date.now()/1e3);function It(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}var Lt=5;function Rt(e){let{sessionAtom:t,sessionSignal:n,$fetch:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={lastSync:0,lastSessionRequest:0,cachedSession:void 0},l=()=>s||yt().isOnline,u=e=>{if(!l())return;if(e?.event===`storage`){c.lastSync=P(),n.set(!n.get());return}let i=t.get(),a=()=>{c.lastSessionRequest=P(),r(`/get-session`).then(async e=>{let{data:a,error:o}=It(e);if(a?.needsRefresh)try{let e=await r(`/get-session`,{method:`POST`});({data:a,error:o}=It(e))}catch{}let s=a?.session&&a?.user?a:null;t.set({...i,data:s,error:o}),c.lastSync=P(),n.set(!n.get())}).catch(()=>{})};if(e?.event===`poll`){a();return}if(e?.event===`visibilitychange`){if(P()-c.lastSessionRequest<Lt)return;c.lastSessionRequest=P()}if(e?.event===`visibilitychange`){a();return}(i?.data===null||i?.data===void 0)&&(c.lastSync=P(),n.set(!n.get()))},d=e=>{pt().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{t.get()?.data&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=pt().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=gt().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=yt().subscribe(e=>{e&&u({event:`visibilitychange`})})};return{init:()=>{f(),p(),m(),h(),pt().setup(),gt().setup(),yt().setup()},cleanup:()=>{c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.lastSync=0,c.lastSessionRequest=0,c.cachedSession=void 0},triggerRefetch:u,broadcastSessionUpdate:d}}var F=Object.create(null),I=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?F:globalThis),L=new Proxy(F,{get(e,t){return I()[t]??F[t]},has(e,t){return t in I()||t in F},set(e,t,n){let r=I(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=I(!0);return delete n[t],!0},ownKeys(){let e=I(!0);return Object.keys(e)}});typeof process<`u`&&process.env;function R(e,t){return typeof process<`u`&&process.env?process.env[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return R(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return R(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return R(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return R(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return R(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return R(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return R(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function zt(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Bt(e){let t=e.split(`
|
|
2
|
+
at `);return t.length<=1?e:(t.splice(1,1),t.join(`
|
|
3
|
+
at `))}function Vt(e,t){class n extends e{#e;constructor(...e){if(zt()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Bt(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,`constructor`,{get(){return t},enumerable:!1,configurable:!0}),n}var Ht={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Vt(class extends Error{constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Ht[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var z=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Ut=47;function Wt(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Ut;)t--;return t===e.length?e:e.slice(0,t)}function Gt(e){try{return(Wt(new URL(e).pathname)||`/`)!==`/`}catch{throw new z(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function Kt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new z(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof z?t:new z(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function B(e,t=`/api/auth`){if(Kt(e),Gt(e))return e;let n=Wt(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function qt(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function Jt(e,t,n,r,i){if(e)return B(e,t);if(r!==!1){let e=L.BETTER_AUTH_URL||L.NEXT_PUBLIC_BETTER_AUTH_URL||L.PUBLIC_BETTER_AUTH_URL||L.NUXT_PUBLIC_BETTER_AUTH_URL||L.NUXT_PUBLIC_AUTH_URL||(L.BASE_URL===`/`?void 0:L.BASE_URL);if(e)return B(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&qt(o,`proto`)&&qt(a,`host`))try{return B(`${o}://${a}`,t)}catch{}if(n){let e=Yt(n.url);if(!e)throw new z(`Could not get origin from request. Please provide a valid base URL.`);return B(e,t)}if(typeof window<`u`&&window.location)return B(window.location.origin,t)}function Yt(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var Xt=[`javascript:`,`data:`,`vbscript:`];function Zt(e){let t;try{t=new URL(e)}catch{return!0}return!Xt.includes(t.protocol)}var Qt={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Zt(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function $t(e,t){let n=kt(!1),r=Ft(n,`/get-session`,e,{method:`GET`}),i=()=>{};return Nt(r,()=>{let a=Rt({sessionAtom:r,sessionSignal:n,$fetch:e,options:t});return a.init(),i=a.broadcastSessionUpdate,()=>{a.cleanup()}}),{session:r,$sessionSignal:n,broadcastSessionUpdate:e=>i(e)}}function en(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function tn(e,t,n=`.`,r){if(!en(t))return tn(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(Array.isArray(a)&&Array.isArray(i[t])?i[t]=[...a,...i[t]]:en(a)&&en(i[t])?i[t]=tn(a,i[t],(n?`${n}.`:``)+t.toString(),r):i[t]=a))}return i}function nn(e){return(...t)=>t.reduce((t,n)=>tn(t,n,``,e),{})}var rn=nn(),an=Object.defineProperty,on=Object.defineProperties,sn=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,ln=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable,dn=(e,t,n)=>t in e?an(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||={})ln.call(t,n)&&dn(e,n,t[n]);if(cn)for(var n of cn(t))un.call(t,n)&&dn(e,n,t[n]);return e},H=(e,t)=>on(e,sn(t)),fn=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},pn=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let r=await i.init?.call(i,e.toString(),t);n=r.options||n,e=r.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},mn=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},hn=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function gn(e){if(typeof e==`number`)return new mn({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new mn(e);case`exponential`:return new hn(e);default:throw Error(`Invalid retry strategy`)}}var _n=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},vn=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function yn(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return vn.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function bn(e){try{return JSON.parse(e),!0}catch{return!1}}function xn(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function Sn(e){try{return JSON.parse(e)}catch{return e}}function Cn(e){return typeof e==`function`}function wn(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&Cn(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&Cn(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}async function Tn(e){let t=new Headers(e?.headers),n=await _n(e);for(let[e,r]of Object.entries(n||{}))t.set(e,r);if(!t.has(`content-type`)){let n=En(e?.body);n&&t.set(`content-type`,n)}return t}function En(e){return xn(e)?`application/json`:null}function Dn(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(xn(e.body)&&!t.has(`content-type`)){for(let[t,n]of Object.entries(e?.body))n instanceof Date&&(e.body[t]=n.toISOString());return JSON.stringify(e.body)}return t.has(`content-type`)&&t.get(`content-type`)===`application/x-www-form-urlencoded`&&xn(e.body)?new URLSearchParams(e.body).toString():e.body}function On(e,t){if(t?.method)return t.method.toUpperCase();if(e.startsWith(`@`)){let n=e.split(`@`)[1]?.split(`/`)[0];return jn.includes(n)?n.toUpperCase():t?.body?`POST`:`GET`}return t?.body?`POST`:`GET`}function kn(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var An=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function U(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new An(n.issues);return n.value}var jn=[`get`,`post`,`put`,`patch`,`delete`],Mn=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){let r=e.plugins?.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1)?.schema||e.schema;if(r){let e=t;r.config?.prefix&&e.startsWith(r.config.prefix)&&(e=e.replace(r.config.prefix,``),r.config.baseURL&&(t=t.replace(r.config.prefix,r.config.baseURL))),r.config?.baseURL&&e.startsWith(r.config.baseURL)&&(e=e.replace(r.config.baseURL,``));let i=r.schema[e];if(i){let e=H(V({},n),{method:i.method,output:i.output});return n?.disableValidation||(e=H(V({},e),{body:i.input?await U(i.input,n?.body):n?.body,params:i.params?await U(i.params,n?.params):n?.params,query:i.query?await U(i.query,n?.query):n?.query})),{url:t,options:e}}}return{url:t,options:n}}}),Nn=e=>{async function t(t,n){let r=H(V(V({},e),n),{plugins:[...e?.plugins||[],Mn(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Fn(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await Fn(t,r)}return t};function Pn(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``;if(e.startsWith(`@`)){let t=e.toString().split(`@`)[1].split(`/`)[0];jn.includes(t)&&(e=e.replace(`@${t}/`,`/`))}a.endsWith(`/`)||(a+=`/`);let[o,s]=e.replace(a,``).split(`?`),c=new URLSearchParams(s);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)c.append(e,n);continue}else n=JSON.stringify(t);c.set(e,n)}if(r)if(Array.isArray(r)){let e=o.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];o=o.replace(n,e)}}else for(let[e,t]of Object.entries(r))o=o.replace(`:${e}`,String(t));o=o.split(`/`).map(encodeURIComponent).join(`/`),o.startsWith(`/`)&&(o=o.slice(1));let l=c.toString();return l=l.length>0?`?${l}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${o}${l}`,a):`${a}${o}${l}`}var Fn=async(e,t)=>{let{hooks:n,url:r,options:i}=await pn(e,t),a=wn(i),o=new AbortController,s=i.signal??o.signal,c=Pn(r,i),l=Dn(i),u=await Tn(i),d=On(r,i),f=H(V({},i),{url:c,headers:u,body:l,method:d,signal:s});for(let e of n.onRequest)if(e){let t=await e(f);typeof t==`object`&&t&&(f=t)}(`pipeTo`in f&&typeof f.pipeTo==`function`||typeof t?.body?.pipe==`function`)&&(`duplex`in f||(f.duplex=`half`));let{clearTimeout:p}=kn(i,o),m=await a(f.url,f);p();let h={response:m,request:f};for(let e of n.onResponse)if(e){let n=await e(H(V({},h),{response:t?.hookOptions?.cloneResponse?m.clone():m}));n instanceof Response?m=n:typeof n==`object`&&n&&(m=n.response)}if(m.ok){if(f.method===`HEAD`)return{data:``,error:null};let e=yn(m),r={data:null,response:m,request:f};if(e===`json`||e===`text`){let e=await m.text();r.data=await(f.jsonParser??Sn)(e)}else r.data=await m[e]();f?.output&&f.output&&!f.disableValidation&&(r.data=await U(f.output,r.data));for(let e of n.onSuccess)e&&await e(H(V({},r),{response:t?.hookOptions?.cloneResponse?m.clone():m}));return t?.throw?r.data:{data:r.data,error:null}}let g=t?.jsonParser??Sn,_=await m.text(),v=bn(_),y=v?await g(_):null,b={response:m,responseText:_,request:f,error:H(V({},y),{status:m.status,statusText:m.statusText})};for(let e of n.onError)e&&await e(H(V({},b),{response:t?.hookOptions?.cloneResponse?m.clone():m}));if(t?.retry){let r=gn(t.retry),i=t.retryAttempt??0;if(await r.shouldAttemptRetry(i,m)){for(let e of n.onRetry)e&&await e(h);let a=r.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await Fn(e,H(V({},t),{retryAttempt:i+1}))}}if(t?.throw)throw new fn(m.status,m.statusText,v?y:_);return{data:null,error:H(V({},y),{status:m.status,statusText:m.statusText})}},In=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if(process.env.NEXT_PUBLIC_AUTH_URL)return process.env.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if(process.env.NEXTAUTH_URL)try{return process.env.NEXTAUTH_URL}catch{}if(process.env.VERCEL_URL)try{let e=process.env.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${process.env.VERCEL_URL}`).origin}${t}`}catch{}}},Ln=(e,t)=>{let n=`credentials`in Request.prototype,r=Jt(e?.baseURL,e?.basePath,void 0,t)??In(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=Nn({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?Dt(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Qt],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=$t(d,e),h=e?.plugins||[],g={},_={$sessionSignal:f,session:p},v={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},y=[{signal:`$sessionSignal`,matcher(e){return e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`},callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of h)e.getAtoms&&Object.assign(_,e.getAtoms?.(d)),e.pathMethods&&Object.assign(v,e.pathMethods),e.atomListeners&&y.push(...e.atomListeners);let b={notify:e=>{_[e].set(!_[e].get())},listen:(e,t)=>{_[e].subscribe(t)},atoms:_};for(let t of h)t.getActions&&(g=rn(t.getActions?.(d,b,e)??{},g));return{get baseURL(){return r},pluginsActions:g,pluginsAtoms:_,pluginPathMethods:v,atomListeners:y,$fetch:d,$store:b}};function Rn(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function zn(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Bn=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,Vn=/['\u2019]/g;function Hn(e){return e.replace(Vn,``).match(Bn)??[]}function Un(e){return Hn(e).map(e=>e.toLowerCase()).join(`-`)}function Wn(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Gn(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Rn(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Un).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Wn(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Kn(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,$fetch:i,atomListeners:a,$store:o}=Ln(e),s={};for(let[e,t]of Object.entries(r))s[`use${zn(e)}`]=t;return Gn({...n,...s,$fetch:i,$store:o},i,t,r,a)}var qn=`https://api.fkn.app`,Jn=qn,{signIn:Yn,signUp:Xn,signOut:Zn}=Kn({baseURL:qn}),Qn=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},$n=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r},er=`fkn-e2e`,tr=`keys`,nr=`dek`,rr=()=>new Promise((e,t)=>{let n=indexedDB.open(er,1);n.onupgradeneeded=()=>{n.result.createObjectStore(tr)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),ir=async(e,t)=>{let n=await rr();return new Promise((r,i)=>{let a=n.transaction(tr,e),o=t(a.objectStore(tr));o.onsuccess=()=>r(o.result),o.onerror=()=>i(o.error),a.oncomplete=()=>n.close()})},ar=()=>ir(`readonly`,e=>e.get(nr)),or=async(e,t)=>{let n=await ar();if(!n)throw Error(`no_dek`);let r=crypto.getRandomValues(new Uint8Array(12)),i={name:`AES-GCM`,iv:r};t&&(i.additionalData=t);let a=new Uint8Array(await crypto.subtle.encrypt(i,n,e)),o=new Uint8Array(r.length+a.length);return o.set(r),o.set(a,r.length),o},sr=async(e,t)=>{let n=await ar();if(!n)throw Error(`no_dek`);let r=e.slice(0,12),i=e.slice(12),a={name:`AES-GCM`,iv:r};return t&&(a.additionalData=t),new Uint8Array(await crypto.subtle.decrypt(a,n,i))},cr=`${Jn}/api/v1/storage`,lr=new TextEncoder,ur=(e,t)=>lr.encode(`${e}\0${t}`),W=async()=>{if(!await ar())throw Error(`no_dek`)},G=(e,t)=>fetch(`${cr}${e}`,{credentials:`include`,...t}),K=async e=>{let t=await e.json().catch(()=>null);if(!e.ok||!t)throw Error(t?.error??`storage_request_failed_${e.status}`);return t},dr={set:async(e,t,n)=>{await W();let r=await or(n,ur(e,t));await K(await G(`/set`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({namespace:e,key:t,value:Qn(r)})}))},get:async(e,t)=>{await W();let n=await G(`/get?namespace=${encodeURIComponent(e)}&key=${encodeURIComponent(t)}`,{method:`GET`});if(n.status===404)return null;let{value:r}=await K(n);return sr($n(r),ur(e,t))},list:async(e,t)=>(await W(),K(await G(`/list`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({namespace:e,limit:t?.limit,cursor:t?.cursor})}))),remove:async(e,t)=>{await W(),await K(await G(`/delete`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({namespace:e,key:t})}))}},fr=`fkn-premium`,q=`premium-tokens`,pr=()=>new Promise((e,t)=>{let n=indexedDB.open(fr,1);n.onupgradeneeded=()=>{n.result.createObjectStore(q,{autoIncrement:!0})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),mr=async(e,t)=>{let n=await pr();return new Promise((r,i)=>{let a=n.transaction(q,e),o=t(a.objectStore(q));o.onsuccess=()=>r(o.result),o.onerror=()=>i(o.error),a.oncomplete=()=>n.close()})},hr=async e=>{let t=await pr();await new Promise((n,r)=>{let i=t.transaction(q,`readwrite`),a=i.objectStore(q);for(let t of e)a.add(t);i.oncomplete=()=>{t.close(),n()},i.onerror=()=>r(i.error)})},gr=()=>mr(`readonly`,e=>e.count()),_r=()=>mr(`readwrite`,e=>e.clear()),vr=new r.BlindRSA({name:`RSABSSA-SHA256-PSS-Deterministic`,hash:`SHA-256`,saltLength:32,prepareType:0,supportsRSARAW:!1}),yr=10,br=3,xr=`${Jn}/api/v1/tokens`,Sr=e=>$n(e.replace(`-----BEGIN PUBLIC KEY-----`,``).replace(`-----END PUBLIC KEY-----`,``).replace(/\s+/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)),Cr=async e=>crypto.subtle.importKey(`spki`,Sr(e),{name:`RSA-PSS`,hash:`SHA-256`},!0,[`verify`]),wr=async()=>{let e=await fetch(`${xr}/pubkey`,{credentials:`include`}),t=await e.json().catch(()=>null);if(!e.ok||!t?.publicKey)throw Error(t?.error??`pubkey_failed_${e.status}`);return Cr(t.publicKey)},Tr=async e=>{let t=Array.from({length:yr},()=>({message:vr.prepare(crypto.getRandomValues(new Uint8Array(32)))})),n=await Promise.all(t.map(({message:t})=>vr.blind(e,t))),r=await fetch(xr,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({blinded:n.map(({blindedMsg:e})=>Qn(e))})}),i=await r.json().catch(()=>null);if(!r.ok||!i?.signatures)throw Error(i?.error??`issue_failed_${r.status}`);let a=i.signatures;return Promise.all(t.map(async({message:t},r)=>{let i=$n(a[r]??``);return{message:t,signature:await vr.finalize(e,t,i,n[r].inv)}}))},Er=async()=>{await gr()>=br||await hr(await Tr(await wr()))},Dr=new TextEncoder;new TextDecoder;var Or=e=>o.Address4.isValid(e),kr=e=>o.Address6.isValid(e),Ar=e=>Or(e)?4:kr(e)?6:0,jr=(...e)=>{if(typeof e[0]==`string`)throw Error(`FKN WebVPN does not support IPC connections`);let t=typeof e.at(-1)==`function`?e.at(-1):void 0;return e[0]&&typeof e[0]==`object`?{...e[0],callback:t}:{port:e[0]??0,host:typeof e[1]==`string`?e[1]:void 0,callback:t}},Mr=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0]??0,r=typeof e[1]==`string`?e[1]:void 0;return typeof e[0]==`object`?{...e[0],address:e[0].address??r,port:e[0].port??n,callback:t}:{address:r,port:n,callback:t}},Nr=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0];if(typeof e[2]==`number`)return{message:n,offset:e[1],length:e[2],port:typeof e[3]==`number`?e[3]:0,address:typeof e[4]==`string`?e[4]:void 0,callback:t};{let r=typeof e[1]==`number`?e[1]:0,i=typeof e[2]==`string`?e[2]:void 0;return{message:n,offset:0,length:n.length,port:r,address:i,callback:t}}};new TextEncoder,new TextDecoder;var Pr=e.g({Server:()=>Y,Socket:()=>J,_default:()=>Rr,connect:()=>Fr,createConnection:()=>Ir,createServer:()=>Lr,default:()=>Rr,isIP:()=>Ar,isIPv4:()=>Or,isIPv6:()=>kr}),J=class extends i.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super(e),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}__webvpn_tcp_socket_init__(e){if(this._webVPNTcpSocketPromise=e.then(e=>{let t=e.dataReadableStream.getReader(),n=e.dataWritableStream.getWriter();return this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._remoteAddress={address:e.remoteAddress,family:e.remoteFamily,port:e.remotePort},{...e,reader:t,writer:n}}).catch(e=>{this.emit(`error`,e)}),!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);return this._webVPNTcpSocketPromise.then(e=>{e&&this.emit(`connect`)}),this._webVPNTcpSocketPromise}_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{if(!e){this.push(null);return}e.reader.read().then(({value:e,done:t})=>{if(t){this.push(null);return}this._restartTimeoutTimer(),this.push(e)}).catch(e=>{this.destroy(e)})})}_write(e,t,n){if(!this._webVPNTcpSocketPromise){n(Error(`Socket not connected`));return}this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e),this._restartTimeoutTimer(),n()}).catch(n)}connect(...e){let t=jr(...e),n=this.__webvpn_tcp_socket_init__(x.then(e=>e.webVpnTcpSocket({remoteAddress:t.host??`localhost`,remotePort:t.port})));return t.callback&&n.then(e=>{e&&t.callback.call(this)}),this}_end(...e){return this._webVPNTcpSocketPromise?(e.length!==0&&this.write(e[0],e[1],e[2]),this._webVPNTcpSocketPromise.then(async e=>{e&&await e.end()}),this):this}_destroy(e){return this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroy()}),this}destroySoon(){this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroySoon()})}resetAndDestroy(){return this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.resetAndDestroy()}),this}_timeoutMs;_timeoutTimer;_restartTimeoutTimer(){this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._timeoutMs&&(this._timeoutTimer=setTimeout(()=>this.emit(`timeout`),this._timeoutMs))}setTimeout(e,t){return t&&this.on(`timeout`,t),this._timeoutMs=e,this._restartTimeoutTimer(),this}setNoDelay(e){let t=e??!0;return this._setTcpOption({type:0,value:t}),this}setKeepAlive(e,t){let n=e??!1,r=t!==void 0&&t>0?Math.max(1,Math.round(t/1e3)):0;return this._setTcpOption({type:2,enabled:n,initialDelaySeconds:r}),this}setSendBufferSize(e){return this._setTcpOption({type:3,value:e}),this}setRecvBufferSize(e){return this._setTcpOption({type:4,value:e}),this}_setTcpOption(e){if(!this._webVPNTcpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before connect`));return}this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}write(e,t,...n){return super.write(e,t,...n)}address(){return this._localAddress??{}}unref(){return this}ref(){return this}autoSelectFamilyAttemptedAddresses;bufferSize;bytesRead;bytesWritten;connecting;pending;get localAddress(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.address}get localPort(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.port}get localFamily(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.family}readyState;get remoteAddress(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.address}get remotePort(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.port}get remoteFamily(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.family}timeout},Y=class extends a.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;constructor(e,t){super(e),t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}__webvpn_tcp_socket_listener_init__(e){return this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e)).catch(e=>{this.emit(`error`,e)}),this._webVPNTcpSocketListenerPromise.then(e=>{e&&this.emit(`listening`)}),this._webVPNTcpSocketListenerPromise}listen(...e){let t=jr(...e),n=e=>{let t=new J({connection:Promise.resolve(e)});this.emit(`connection`,t)},r=e=>x.then(r=>r.webVpnTcpSocketListener({localAddress:e,localPort:t.port,onConnection:n})),i=t.host?r(t.host):r(`::`).catch(()=>r(`0.0.0.0`)),a=this.__webvpn_tcp_socket_listener_init__(i);return t.callback&&a.then(e=>{e&&t.callback.call(this)}),this}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this.emit(`close`),e&&e()}catch(t){this._localAddress=void 0,this.emit(`close`),e&&e(t)}}),this}address(){return this._localAddress??null}getConnections(e){throw Error(`Method not implemented.`)}ref(){return this}unref(){return this}maxConnections;connections;listening;async[Symbol.asyncDispose](){}},Fr=(e,t)=>new J().connect(e,t),Ir=(e,t)=>new J().connect(e,t),Lr=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new Y(e);return t&&n.on(`connection`,t),n},Rr={Socket:J,Server:Y,connect:Fr,createConnection:Ir,createServer:Lr,isIP:Ar,isIPv4:Or,isIPv6:kr},zr=e.g({Socket:()=>Br,createSocket:()=>Hr}),Br=class extends a.EventEmitter{_type;_localAddress;_remoteAddress;_webVPNUdpSocketPromise;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}addMembership(e,t){if(o.Address4.isValid(e)){let n=X(e),r=t&&o.Address4.isValid(t)?X(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=Vr(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let t=Mr(...e),n=this._type===`udp6`?`::`:`0.0.0.0`;return this._webVPNUdpSocketPromise=x.then(e=>e.webVpnUdpSocket({type:this._type,address:t.address??n,port:t.port})).then(e=>{let t=e.dataReadableStream.getReader(),n=async()=>{let{value:e,done:r}=await t.read();r||(this.emit(`message`,s.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size}),n())};return n(),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{e&&this.emit(`listening`)}),t.callback&&this._webVPNUdpSocketPromise.then(e=>{e&&t.callback()}),this}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);await t.close(),e&&e(),this.emit(`close`)}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0;await t.connect({remotePort:n,remoteAddress:i}),this._remoteAddress={address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},a&&a()})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async e=>{if(!e)throw Error(`Socket not bound`);await e.connect({remotePort:0,remoteAddress:this._type===`udp4`?`0.0.0.0`:`::`})})}dropMembership(e,t){if(o.Address4.isValid(e)){let n=X(e),r=t&&o.Address4.isValid(t)?X(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=Vr(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=Nr(...e),n=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let r=typeof t.message==`string`?Dr.encode(t.message):t.message;e.send({...t,address:t.address??n,message:r.buffer})})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},X=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},Vr=e=>{let t=new o.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},Hr=(e,t)=>{let n=new Br(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},Ur=e.g({Agent:()=>oi,ClientRequest:()=>$,HTTPParser:()=>ei,IncomingMessage:()=>Q,METHODS:()=>Gr,STATUS_CODES:()=>Kr,Server:()=>ai,ServerResponse:()=>ri,_default:()=>di,createServer:()=>ui,default:()=>di,get:()=>li,globalAgent:()=>si,request:()=>ci}),Wr=new TextDecoder(`latin1`),Gr=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),Kr={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},qr=new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),Jr=13,Yr=10,Xr=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,Z=(e,t)=>(e.code=t,e),Zr=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},Qr=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===Jr&&e[n+1]===Yr)return n;return-1},$r=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===Jr&&e[t+1]===Yr&&e[t+2]===Jr&&e[t+3]===Yr)return t;return-1},ei=class{buf=new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=Zr(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=$r(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=Wr.decode(e).split(`\r
|
|
4
|
+
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],a={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(a,n,r)}let o={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:a,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);o.method=(e??`GET`).toUpperCase(),o.url=t??`/`,this.applyVersion(o,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);o.statusCode=parseInt(a,10)||0,o.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(o,t)}return o}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:qr.has(r)||(e[r]=`${i}, ${n}`)}setupBody(e){if(this.skipBody){this.framing=`none`;return}let t=e.headers[`transfer-encoding`];if(typeof t==`string`&&t.toLowerCase().includes(`chunked`)){this.framing=`chunked`,this.chunkState=`size`;return}let n=e.headers[`content-length`];if(typeof n==`string`&&n!==``){let e=parseInt(n,10);e>0?(this.framing=`length`,this.bodyRemaining=e):this.framing=`none`;return}if(this.mode===`response`){let t=e.statusCode??0;t>=100&&t<200||t===204||t===304?this.framing=`none`:this.framing=`eof`}else this.framing=`none`}consumeBody(){if(this.framing===`length`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);return this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0}return this.framing===`eof`?(this.buf.length>0&&(this.handlers.onBody(this.buf),this.buf=new Uint8Array),!1):this.framing===`chunked`?this.consumeChunked():!0}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=Qr(this.buf,0);if(e===-1)return!1;let t=Wr.decode(this.buf.subarray(0,e)),n=parseInt(t.split(`;`)[0].trim(),16);if(this.buf=this.buf.subarray(e+2),Number.isNaN(n))return!0;n===0?this.chunkState=`trailer`:(this.bodyRemaining=n,this.chunkState=`data`)}else if(this.chunkState===`data`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0&&(this.chunkState=`dataCRLF`)}else if(this.chunkState===`dataCRLF`){if(this.buf.length<2)return!1;this.buf=this.buf.subarray(2),this.chunkState=`size`}else{let e=Qr(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},ti=(e,t)=>s.Buffer.isBuffer(e)?e:typeof e==`string`?s.Buffer.from(e,t??`utf8`):e instanceof Uint8Array?s.Buffer.from(e):e instanceof ArrayBuffer?s.Buffer.from(new Uint8Array(e)):s.Buffer.from(String(e)),Q=class extends i.Stream.Readable{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];trailers={};rawTrailers=[];method;url;statusCode;statusMessage;complete=!1;socket;constructor(e){super(),this.socket=e}get connection(){return this.socket}_applyHead(e){this.httpVersion=e.httpVersion,this.httpVersionMajor=e.httpVersionMajor,this.httpVersionMinor=e.httpVersionMinor,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.method=e.method,this.url=e.url,this.statusCode=e.statusCode,this.statusMessage=e.statusMessage}_read(){}setTimeout(e,t){return this.socket.setTimeout(e,t),this}},ni=class extends i.Stream.Writable{_headerStore=new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw Z(Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!Xr.test(e))throw Z(TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw Z(TypeError(`Invalid value "undefined" for header "${e}"`),`ERR_HTTP_INVALID_HEADER_VALUE`);return this._headerStore.set(e.toLowerCase(),[e,Array.isArray(t)?[...t]:t]),this}getHeader(e){return this._headerStore.get(e.toLowerCase())?.[1]}getHeaderNames(){return[...this._headerStore.values()].map(([e])=>e)}getHeaders(){let e={};for(let[t,n]of this._headerStore.values())e[t]=n;return e}hasHeader(e){return this._headerStore.has(e.toLowerCase())}removeHeader(e){if(this.headersSent)throw Error(`Cannot remove headers after they are sent to the client`);this._headerStore.delete(e.toLowerCase())}_storeHeader(e){let t=this.hasHeader(`content-length`),n=this.getHeader(`transfer-encoding`);typeof n==`string`&&n.toLowerCase().includes(`chunked`)?this.chunkedEncoding=!0:!t&&this._shouldSendBody()&&(this.chunkedEncoding=!0,this.setHeader(`Transfer-Encoding`,`chunked`));let r=e+`\r
|
|
5
|
+
`;for(let[e,t]of this._headerStore.values())if(Array.isArray(t))for(let n of t)r+=`${e}: ${n}\r\n`;else r+=`${e}: ${t}\r\n`;return r+=`\r
|
|
6
|
+
`,r}_writeToSocket(e,t){if(!this.socket){t(Error(`Socket is not available`));return}this.socket.write(e,t)}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,n){let r=ti(e),i=[];if(this.headersSent||=(this._implicitHeader(),i.push(s.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?r.length>0&&(i.push(s.Buffer.from(`${r.length.toString(16)}\r\n`,`latin1`)),i.push(r),i.push(s.Buffer.from(`\r
|
|
7
|
+
`,`latin1`))):i.push(r),i.length===0){n();return}this._writeToSocket(s.Buffer.concat(i),n)}_final(e){let t=[];if(this.headersSent||=(!this.chunkedEncoding&&!this.hasHeader(`content-length`)&&this.setHeader(`Content-Length`,0),this._implicitHeader(),t.push(s.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding&&t.push(s.Buffer.from(`0\r
|
|
8
|
+
\r
|
|
9
|
+
`,`latin1`)),this.finished=!0,t.length===0){e();return}this._writeToSocket(s.Buffer.concat(t),e)}end(e,t,n){if(e!=null&&typeof e!=`function`&&!this._bodyWritten&&!this.headersSent&&!this.chunkedEncoding&&!this.hasHeader(`content-length`)){let n=typeof t==`string`?t:void 0;this.setHeader(`Content-Length`,ti(e,n).length)}return super.end(e,t,n)}_headBlock},ri=class extends ni{statusCode=200;statusMessage;_writeHeadCalled=!1;sendDate=!0;req;socket;_keepAlive=!0;constructor(e){super(),this.req=e,this.socket=e.socket}_shouldSendBody(){if(this.req.method===`HEAD`)return!1;let e=this.statusCode;return!(e>=100&&e<200||e===204||e===304)}writeHead(e,t,n){if(this._writeHeadCalled||this.headersSent)throw Z(Error(`Cannot render headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);this._writeHeadCalled=!0,this.statusCode=e;let r=n;if(typeof t==`string`?this.statusMessage=t:t!=null&&(r=t),Array.isArray(r)){let e=Array.isArray(r[0])?r:Array.from({length:Math.floor(r.length/2)},(e,t)=>[r[t*2],r[t*2+1]]);for(let[t,n]of e)n!==void 0&&this._appendHeader(t,n)}else if(r)for(let[e,t]of Object.entries(r))t!==void 0&&this.setHeader(e,t);return this}_appendHeader(e,t){let n=this.getHeader(e);if(n===void 0)this.setHeader(e,t);else{let r=[...Array.isArray(n)?n:[n],...Array.isArray(t)?t:[t]].map(String);this.setHeader(e,r)}}_implicitHeader(){let e=this.statusMessage??Kr[this.statusCode]??`unknown`;this.sendDate&&!this.hasHeader(`date`)&&this.setHeader(`Date`,new Date().toUTCString()),this.hasHeader(`connection`)||this.setHeader(`Connection`,this._keepAlive?`keep-alive`:`close`),this._headBlock=this._storeHeader(`HTTP/1.1 ${this.statusCode} ${e}`)}writeContinue(){this._writeToSocket(s.Buffer.from(`HTTP/1.1 100 Continue\r
|
|
10
|
+
\r
|
|
11
|
+
`,`latin1`),()=>{})}setTimeout(e,t){return this.socket?.setTimeout(e,t),this}},ii=(...e)=>{let t={},n={},r,i=[...e],a=i.shift();if(typeof a==`string`||a instanceof URL){let e=typeof a==`string`?new URL(a):a;t={protocol:e.protocol,hostname:e.hostname,host:e.hostname,port:e.port,path:`${e.pathname}${e.search}`,auth:e.username?`${e.username}:${e.password}`:void 0};let o=i.shift();typeof o==`function`?r=o:o&&typeof o==`object`&&(n=o,r=i.shift())}else a&&typeof a==`object`&&(n=a,r=i.shift());return{options:{...t,...n},callback:r}},$=class extends ni{method;path;host;protocol;socket;get connection(){return this.socket}res=null;aborted=!1;_aborted=!1;constructor(e,t){super(),this.method=(e.method??`GET`).toUpperCase(),this.path=e.path??`/`,this.protocol=e.protocol??`http:`;let n=e.hostname??e.host??`localhost`;this.host=n;let r=Number(e.port??(this.protocol===`https:`?443:80));if(t&&this.once(`response`,t),e.headers)for(let[t,n]of Object.entries(e.headers))n!==void 0&&this.setHeader(t,n);if(!this.hasHeader(`host`)){let e=this.protocol===`https:`&&r===443||this.protocol!==`https:`&&r===80;this.setHeader(`Host`,e?n:`${n}:${r}`)}e.auth&&!this.hasHeader(`authorization`)&&this.setHeader(`Authorization`,`Basic ${s.Buffer.from(e.auth).toString(`base64`)}`),this.socket=new J,this.emit(`socket`,this.socket),this.socket.on(`error`,e=>{this._aborted||this.emit(`error`,e)}),this._attachResponseParser(),this.socket.connect({host:n,port:r},()=>{this.emit(`connect`)})}_shouldSendBody(){return this.method!==`GET`&&this.method!==`HEAD`&&this.method!==`DELETE`}_implicitHeader(){this._headBlock=this._storeHeader(`${this.method} ${this.path} HTTP/1.1`)}_attachResponseParser(){let e=new Q(this.socket),t=new ei(`response`,{onHeaders:n=>{e._applyHead(n),this.method===`HEAD`&&(t.skipBody=!0),this.res=e,this.emit(`response`,e)},onBody:t=>{e.push(s.Buffer.from(t))},onComplete:()=>{e.complete=!0,e.push(null)}});this.socket.on(`data`,e=>{this._aborted||t.execute(e)}),this.socket.on(`end`,()=>{t.finish()}),this.socket.on(`close`,()=>{this.emit(`close`)})}abort(){this._aborted||(this._aborted=!0,this.aborted=!0,this.emit(`abort`),this.socket.destroy())}destroy(e){return this._aborted?this:(this._aborted=!0,this.socket.destroy(e),super.destroy(e),this)}end(e,t,n){return this._aborted?this:super.end(e,t,n)}_writeToSocket(e,t){if(this._aborted){t();return}super._writeToSocket(e,t)}setTimeout(e,t){return this.socket.setTimeout(e,t),this}setNoDelay(e){this.socket.setNoDelay(e)}setSocketKeepAlive(e,t){this.socket.setKeepAlive(e,t)}},ai=new Proxy(class extends Y{constructor(e,t){let n={},r=t;typeof e==`function`?r=e:e&&(n=e),super(n),r&&this.on(`request`,r),this.on(`connection`,e=>this._handleConnection(e))}_handleConnection(e){let t=null,n=new ei(`request`,{onHeaders:r=>{t=new Q(e),t._applyHead(r),r.method===`HEAD`&&(n.skipBody=!0);let i=new ri(t),a=String(r.headers.connection??``).toLowerCase();i._keepAlive=r.httpVersionMinor>=1?a!==`close`:a===`keep-alive`,i.on(`finish`,()=>{i._keepAlive||e.end()}),this.emit(`request`,t,i)},onBody:e=>{t?.push(s.Buffer.from(e))},onComplete:()=>{t&&(t.complete=!0,t.push(null)),t=null}});e.on(`data`,e=>n.execute(e)),e.on(`end`,()=>{n.finish(),t&&t.push(null)}),e.on(`error`,t=>this.emit(`clientError`,t,e))}},{apply:(e,t,n)=>new e(...n)}),oi=class{maxSockets;maxFreeSockets;keepAlive;options;constructor(e={}){this.options=e,this.keepAlive=!!e.keepAlive,this.maxSockets=e.maxSockets??1/0,this.maxFreeSockets=e.maxFreeSockets??256}getName(e={}){return`${e.host??`localhost`}:${e.port??``}:${e.localAddress??``}`}destroy(){}},si=new oi,ci=(...e)=>{let{options:t,callback:n}=ii(...e);return new $(t,n)},li=(...e)=>{let t=ci(...e);return t.end(),t},ui=(e,t)=>new ai(e,t),di={METHODS:Gr,STATUS_CODES:Kr,Agent:oi,globalAgent:si,Server:ai,ServerResponse:ri,IncomingMessage:Q,ClientRequest:$,OutgoingMessage:ni,createServer:ui,request:ci,get:li};exports.ATTACH_FRAME_EVENT_KEY=ye,exports.attachFrame=Se,exports.attachFramePermission=be,exports.box=e.u,exports.changeIframeStyle=h,exports.clearPremiumTokens=_r,exports.cookies=he,exports.countPremiumTokens=gr,exports.createVideoElementHandle=e.d,Object.defineProperty(exports,`dgram`,{enumerable:!0,get:function(){return zr}}),exports.extension=S,exports.fetch=pe,exports.fetchCredentialedPermission=ue,exports.fetchPermission=le,exports.gotoPermission=xe,exports.handleRevivableModules=e.l,Object.defineProperty(exports,`http`,{enumerable:!0,get:function(){return Ur}}),exports.isExtensionExposed=C,exports.isType=e.f,exports.modifyRequestHeadersPermission=ge,Object.defineProperty(exports,`net`,{enumerable:!0,get:function(){return Pr}}),exports.permissions=Ce,exports.promptInstall=we,exports.readCookiePermission=me,exports.refillPremiumTokens=Er,exports.relayWorker=ne,exports.removeRequestHeaderRule=ve,exports.resetIframeStyle=g,exports.revive=e.p,exports.serverProxyFetch=ee,exports.setMissingExtensionHandler=oe,exports.setRequestHeaderRule=_e,exports.storage=dr,exports.type=e.m,exports.waitForExtensionExposure=se;
|