@fkn/lib 0.9.42 → 0.9.43

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.
@@ -0,0 +1,53 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./hosts-GNBhZO3-.cjs");let n=require("osra");var r=(e,t)=>{let n=new EventTarget,r=new Map,i=EventTarget.prototype.addEventListener.bind(n),a=EventTarget.prototype.removeEventListener.bind(n);return Object.defineProperty(n,"addEventListener",{configurable:!0,value:(a,o,s)=>{if(o!==null){if(!r.has(a)){let i=r=>{n.dispatchEvent(new CustomEvent(a,{detail:t(r,e),bubbles:r.bubbles,cancelable:r.cancelable,composed:r.composed}))};e.addEventListener(a,i),r.set(a,i)}i(a,o,s)}}}),Object.defineProperty(n,"removeEventListener",{configurable:!0,value:(t,n,i)=>{if(n===null)return;a(t,n,i);let o=r.get(t);o&&(e.removeEventListener(t,o),r.delete(t))}}),n},i=e=>typeof e==`boolean`?+!!e:+!!e?.capture,a=e=>{let t=new WeakMap;return{addEventListener:(n,r,a)=>{if(r===null)return;let o=`${n}|${i(a)}`,s=t.get(r);if(s||(s=new Map,t.set(r,s)),s.has(o))return;let c=typeof a==`object`&&!!a&&!!a.once,l=t=>{c&&s.delete(o);let i=e.unenrich(t,n);typeof r==`function`?r.call(e.target,i):r.handleEvent(i)};s.set(o,l),e.remoteEvents.addEventListener(n,l,a)},removeEventListener:(n,r,a)=>{if(r===null)return;let o=`${n}|${i(a)}`,s=t.get(r),c=s?.get(o);c&&(e.remoteEvents.removeEventListener(n,c,a),s.delete(o))},dispatchEvent:t=>e.remoteEvents.dispatchEvent(t)}},o=e.t({box:()=>S,createVideoElementHandle:()=>x,isType:()=>te,revive:()=>C,type:()=>s}),s=`videoElement`,c=[`currentTime`,`volume`,`muted`,`playbackRate`,`src`,`loop`,`autoplay`,`preload`,`poster`,`disableRemotePlayback`],l=[`duration`,`paused`,`ended`,`seeking`,`readyState`,`currentSrc`],u=[`buffered`,`seekable`],d=Symbol.for(`fkn.remoteVideoElement`),f=Symbol.for(`fkn.remoteVideoElement.state`),p=Symbol.for(`fkn.remoteVideoElement.controller`),m=e=>e?Array.from({length:e.length},(t,n)=>[e.start(n),e.end(n)]):[],h=e=>{let t={};for(let n of[...c,...l])t[n]=e[n];for(let n of u)t[n]=m(e[n]);return t.error=e.error?{code:e.error.code,message:e.error.message}:null,t},g=e=>{let t=t=>{if(!Number.isInteger(t)||t<0||t>=e.length)throw new DOMException(`Index or size is negative or greater than the allowed amount`,`IndexSizeError`)};return{get length(){return e.length},start(n){return t(n),e[n][0]},end(n){return t(n),e[n][1]}}},_=e=>e?{code:e.code,message:e.message,MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4}:null,v=e=>r(e,(e,t)=>({originalDetail:e instanceof CustomEvent?e.detail:null,snapshot:h(t)})),y=async(e,t)=>{switch(t){case`play`:return await e.play(),null;case`pause`:return e.pause(),null;case`load`:return e.load(),null;case`requestPictureInPicture`:if(typeof e.requestPictureInPicture!=`function`)throw Error(`requestPictureInPicture is not supported in this environment`);return await e.requestPictureInPicture(),null;case`exitPictureInPicture`:{let t=e.ownerDocument;if(typeof t?.exitPictureInPicture!=`function`)throw Error(`exitPictureInPicture is not supported in this environment`);return await t.exitPictureInPicture(),null}default:throw Error(`videoElement: unknown method "${t}"`)}},ee=e=>({call:async t=>y(e,t),set:async(t,n)=>{try{e[t]=n}catch{}return h(e)},events:v(e)}),b=(e,t)=>{let n=new EventTarget;Object.defineProperty(n,d,{value:!0}),Object.defineProperty(n,f,{value:e}),Object.defineProperty(n,p,{value:t});let r=a({target:n,remoteEvents:t.events,unenrich:(t,n)=>{if(!(t instanceof CustomEvent))return t;let r=t.detail;if(!r||!(`snapshot`in r))return t;Object.assign(e,r.snapshot);let i={bubbles:t.bubbles,cancelable:t.cancelable,composed:t.composed};return r.originalDetail===null?new Event(n,i):new CustomEvent(n,{...i,detail:r.originalDetail})}}),i={addEventListener:{configurable:!0,value:r.addEventListener},removeEventListener:{configurable:!0,value:r.removeEventListener},dispatchEvent:{configurable:!0,value:r.dispatchEvent},error:{configurable:!0,enumerable:!0,get(){return _(e.error)}},play:{configurable:!0,value:()=>t.call(`play`,[])},pause:{configurable:!0,value:()=>{t.call(`pause`,[]).catch(()=>{})}},load:{configurable:!0,value:()=>{t.call(`load`,[]).catch(()=>{})}},requestPictureInPicture:{configurable:!0,value:()=>t.call(`requestPictureInPicture`,[])},exitPictureInPicture:{configurable:!0,value:()=>t.call(`exitPictureInPicture`,[])},HAVE_FUTURE_DATA:{enumerable:!0,value:3},HAVE_ENOUGH_DATA:{enumerable:!0,value:4}};for(let n of c)i[n]={configurable:!0,enumerable:!0,get(){return e[n]},set(r){e[n]=r,t.set(n,r).then(t=>{Object.assign(e,t)},()=>{})}};for(let t of l)i[t]={configurable:!0,enumerable:!0,get(){return e[t]}};for(let t of u)i[t]={configurable:!0,enumerable:!0,get(){return g(e[t])}};return Object.defineProperties(n,i),n},x=e=>b(h(e),ee(e)),te=e=>typeof e==`object`&&!!e&&e[d]===!0,S=(e,t)=>{let r=e;return{...n.BoxBase,type:s,initialState:r[f],controller:(0,n.recursiveBox)(r[p],t)}},C=(e,t)=>{let r=(0,n.recursiveRevive)(e.controller,t);return b({...e.initialState},r)},w=e=>[o,...e],ne=4,re=0,ie=`fknExtension`,ae=`fknExtensionAbi`,oe=`fknExtensionOps`,se=[`data-fkn-extension`,`data-fkn-extension-abi`,`data-fkn-extension-ops`],ce=e=>{if(e===void 0)return 0;let t=Number(e);return Number.isInteger(t)&&t>=0?t:0},le=e=>e===void 0?null:e.split(`,`).map(e=>e.trim()).filter(Boolean),ue=(e,t=0)=>{if(e.fknExtension!==`true`)return{status:`absent`};let n=ce(e[ae]),r=le(e[oe]);return n<t?{status:`outdated`,abi:n,required:t,operations:r}:{status:`ok`,abi:n,operations:r}},de=(e,t)=>e.status===`ok`?e.operations===null||e.operations.includes(t):!1,fe=(e,t)=>e.status===`ok`&&e.operations!==null&&e.operations.includes(t),T=class extends Error{abi;required;name=`ExtensionOutdatedError`;constructor(e,t){super(`The FKN WebExtension is installed but too old for this page: it speaks ABI ${e} and this page needs at least ${t}. Updating the extension fixes this.`),this.abi=e,this.required=t}},E=class extends Error{operation;abi;name=`ExtensionOperationUnsupportedError`;constructor(e,t,n){super(n??`The FKN WebExtension does not support "${e}" (ABI ${t}). Updating the extension may add it.`),this.operation=e,this.abi=t}},pe=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,me=ie,he=(0,n.createTypedEventTarget)();typeof document<`u`&&document.addEventListener(pe,()=>{he.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:ge()}}))});var ge=()=>typeof document>`u`?!1:document.documentElement.dataset[me]===`true`,D=()=>typeof document>`u`?{status:`absent`}:ue(document.documentElement.dataset),_e=null,ve=e=>{_e=e},ye=150,O=(e=1e3)=>new Promise((t,n)=>{let r=()=>D().status===`ok`;if(r())return t();let i,a=e=>{clearTimeout(i),c.disconnect(),document.removeEventListener(`readystatechange`,l),e()},o=()=>a(async()=>{let e=D();if(e.status===`outdated`)return n(new T(e.abi,e.required));if(_e){if(await _e().catch(()=>{}),r())return t();let e=D();if(e.status===`outdated`)return n(new T(e.abi,e.required))}n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),s=()=>{clearTimeout(i),i=setTimeout(()=>r()?a(t):o(),ye)},c=new MutationObserver(()=>{r()&&a(t)}),l=()=>{document.readyState===`complete`&&!r()&&s()};if(i=setTimeout(o,e),c.observe(document.documentElement,{attributes:!0,attributeFilter:[...se]}),document.addEventListener(`readystatechange`,l),document.readyState===`complete`)return s();r()&&a(t)}),be,k=new Proxy({},{get:(e,t)=>async(...e)=>{await O(),be??=(0,n.expose)({},{transport:window,revivableModules:w});let r=(await be)[t];return r(...e)}}),xe=[`origin`,`referer`,`cookie`],Se=(e,t)=>(e??[]).some(([e,n])=>e.trim().toLowerCase()===t&&n!==``),Ce=e=>Se(e,`cookie`),we=(e,t)=>{if(t===`include`&&Ce(e))throw Error(`fetch: a forged Cookie header and credentials:'include' are different identities - send one or the other`)},Te=e=>{let t=[...new Set((e??[]).map(([e])=>e.trim().toLowerCase()).filter(e=>!xe.includes(e)))];if(t.length)throw Error(`fetch: refusing to forge request header(s): ${t.join(`, `)}`)},Ee=[`fkn.app`,`fkn.dev`,`sdbx.app`],De=e=>e.replace(/\.+$/,``),Oe=e=>{let t=De(e);return Ee.some(e=>t===e||t.endsWith(`.${e}`))},ke={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.`},Ae={scope:`network.fetchCredentialed`,category:`network`,severity:3,chip:`load as you`,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.`},je={scope:`network.fetchLocal`,category:`network`,severity:3,chip:`local network`,unsafe:!0,title:`Access devices on your local network`,description:`Lets the app reach devices and services on your home or work network, which websites normally cannot touch.`},Me=e=>{let t=e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);if(!t)return!1;let[n,r]=[Number(t[1]),Number(t[2])];return n===10||n===127||n===0||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168},Ne=e=>{let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.replace(/^\[|\]$/g,``).toLowerCase().replace(/\.$/,``);return n===`localhost`||n.endsWith(`.localhost`)||n.endsWith(`.local`)||n.endsWith(`.internal`)||n.endsWith(`.home.arpa`)?!0:n.includes(`:`)?n===`::`||n===`::1`||n.startsWith(`fc`)||n.startsWith(`fd`)||/^fe[89ab]/.test(n)||n.startsWith(`::ffff:`):Me(n)},Pe=e=>{let t;try{t=new URL(e)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`||Oe(t.hostname)},Fe=e=>{if(Pe(e))throw Error(`fetch: refusing to target the extension's own pages or FKN platform domains`)},Ie=e=>{if(!e?.headers)return;let t=new Headers(e.headers),n=xe.map(e=>{let n=t.get(e);return n===null||n===``?void 0:[e,n]}).filter(e=>e!==void 0);return n.length?n:void 0},Le=async(e,t)=>{let n=new Request(e,t);Fe(n.url);let r=n.body?await n.arrayBuffer():null;return k.proxyFetch({url:n.url,method:n.method,headers:[...n.headers],body:r,credentials:t?.credentials===`include`?`include`:`omit`,redirect:n.redirect,unsafeHeaders:Ie(t),reason:t?.reason,signal:t?.signal??void 0})},Re={scope:`network.readCookie`,category:`network`,severity:3,chip:`read cookie`,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.`},ze={get:e=>k.getCookie(e)},Be={scope:`network.modifyRequestHeaders`,category:`network`,severity:2,chip:`rewrite headers`,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.`},Ve=e=>k.setRequestHeaderRule(e),He=e=>k.removeRequestHeaderRule({ruleId:e}),Ue=class extends Error{reason;filename;line;column;source;constructor(e,t,n,r,i){super(`${e}:${n}:${r}: ${t}`),this.reason=t,this.filename=e,this.line=n,this.column=r,this.source=i}},We=class{start;end;source;constructor(e,t,n){this.start=e,this.end=t,this.source=n}},A;(function(e){e.stylesheet=`stylesheet`,e.rule=`rule`,e.declaration=`declaration`,e.comment=`comment`,e.atRule=`at-rule`,e.container=`container`,e.charset=`charset`,e.counterStyle=`counter-style`,e.document=`document`,e.customMedia=`custom-media`,e.fontFace=`font-face`,e.fontFeatureValues=`font-feature-values`,e.host=`host`,e.import=`import`,e.keyframes=`keyframes`,e.keyframe=`keyframe`,e.layer=`layer`,e.media=`media`,e.namespace=`namespace`,e.page=`page`,e.pageMarginBox=`page-margin-box`,e.positionTry=`position-try`,e.property=`property`,e.scope=`scope`,e.startingStyle=`starting-style`,e.supports=`supports`,e.viewTransition=`view-transition`})(A||={});var Ge=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);if(e[o]!==`\\`)return o;r=o+2,i--}while(i>0);throw Error(`Too many escaping`)},j=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`(`,r)),n.push(e.indexOf(`"`,r)),n.push(e.indexOf(`'`,r)),n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);switch(e[o]){case`\\`:r=o+2;break;case`(`:{let t=j(e,[`)`],o+1);if(t===-1)return-1;r=t+1}break;case`"`:{let t=Ge(e,[`"`],o+1);if(t===-1)return-1;r=t+1}break;case`'`:{let t=Ge(e,[`'`],o+1);if(t===-1)return-1;r=t+1}break;default:return o}i--}while(i>0);throw Error(`Too many escaping`)},Ke=/\/\*[^]*?(?:\*\/|$)/g;function M(e){return e?e.trim():``}function N(e,t){let n=e&&typeof e.type==`string`,r=n?e:t;for(let t in e){let n=e[t];Array.isArray(n)?n.forEach(e=>{N(e,r)}):n&&typeof n==`object`&&N(n,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var qe=class{level=0;indentation=` `;compress=!1;constructor(e){typeof e?.indent==`string`&&(this.indentation=e?.indent),e?.compress&&(this.compress=!0)}emit(e,t){return e}indent(e){return this.level=this.level||1,e?(this.level+=e,``):Array(this.level).join(this.indentation)}visit(e){switch(e.type){case A.stylesheet:return this.stylesheet(e);case A.rule:return this.rule(e);case A.declaration:return this.declaration(e);case A.comment:return this.comment(e);case A.container:return this.container(e);case A.charset:return this.charset(e);case A.counterStyle:return this.counterStyle(e);case A.document:return this.document(e);case A.customMedia:return this.customMedia(e);case A.fontFace:return this.fontFace(e);case A.fontFeatureValues:return this.fontFeatureValues(e);case A.host:return this.host(e);case A.import:return this.import(e);case A.keyframes:return this.keyframes(e);case A.keyframe:return this.keyframe(e);case A.layer:return this.layer(e);case A.media:return this.media(e);case A.namespace:return this.namespace(e);case A.page:return this.page(e);case A.pageMarginBox:return this.pageMarginBox(e);case A.positionTry:return this.positionTry(e);case A.property:return this.property(e);case A.scope:return this.scope(e);case A.startingStyle:return this.startingStyle(e);case A.supports:return this.supports(e);case A.viewTransition:return this.viewTransition(e);case A.atRule:return this.genericAtRule(e)}}mapVisit(e,t){let n=``;t||=``;for(let r=0,i=e.length;r<i;r++)n+=this.visit(e[r]),t&&r<i-1&&(n+=this.emit(t));return n}compile(e){return this.compress?e.stylesheet.rules.map(this.visit,this).join(``):this.stylesheet(e)}stylesheet(e){return this.mapVisit(e.stylesheet.rules,`
2
+
3
+ `)}comment(e){return this.compress?this.emit(``,e.position):this.emit(`${this.indent()}/*${e.comment}*/`,e.position)}container(e){return this.compress?this.emit(`@container ${e.container}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@container ${e.container}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
4
+
5
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}layer(e){return this.compress?this.emit(`@layer ${e.layer}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`):this.emit(`${this.indent()}@layer ${e.layer}`,e.position)+(e.rules?this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
6
+
7
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`):`;`)}import(e){return this.emit(`@import ${e.import};`,e.position)}media(e){return this.compress?this.emit(`@media ${e.media}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@media ${e.media}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
8
+
9
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}document(e){let t=`@${e.vendor||``}document ${e.document}`;return this.compress?this.emit(t,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(t,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
10
+
11
+ `)+this.emit(`${this.indent(-1)}\n}`)}charset(e){return this.emit(`@charset ${e.charset};`,e.position)}namespace(e){return this.emit(`@namespace ${e.namespace};`,e.position)}startingStyle(e){return this.compress?this.emit(`@starting-style`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@starting-style`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
12
+
13
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}supports(e){return this.compress?this.emit(`@supports ${e.supports}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@supports ${e.supports}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
14
+
15
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}keyframes(e){return this.compress?this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.keyframes)+this.emit(`}`):this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.keyframes,`
16
+ `)+this.emit(`${this.indent(-1)}}`)}keyframe(e){let t=e.declarations;return this.compress?this.emit(e.values.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`):this.emit(this.indent())+this.emit(e.values.join(`, `),e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(t,`
17
+ `)+this.emit(`${this.indent(-1)}\n${this.indent()}}\n`)}page(e){if(this.compress){let t=e.selectors.length?e.selectors.join(`, `):``;return this.emit(`@page ${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`)}let t=e.selectors.length?`${e.selectors.join(`, `)} `:``;return this.emit(`@page ${t}`,e.position)+this.emit(`{
18
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
19
+ `)+this.emit(this.indent(-1))+this.emit(`
20
+ }`)}pageMarginBox(e){return this.compress?this.emit(`@${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`${this.indent()}@${e.name} `,e.position)+this.emit(`{
21
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
22
+ `)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}fontFace(e){return this.compress?this.emit(`@font-face`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@font-face `,e.position)+this.emit(`{
23
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
24
+ `)+this.emit(this.indent(-1))+this.emit(`
25
+ }`)}host(e){return this.compress?this.emit(`@host`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`@host`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
26
+
27
+ `)+this.emit(`${this.indent(-1)}\n}`)}customMedia(e){return this.emit(`@custom-media ${e.name} ${e.media};`,e.position)}property(e){return this.compress?this.emit(`@property ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@property ${e.name} `,e.position)+this.emit(`{
28
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
29
+ `)+this.emit(this.indent(-1))+this.emit(`
30
+ }`)}counterStyle(e){return this.compress?this.emit(`@counter-style ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@counter-style ${e.name} `,e.position)+this.emit(`{
31
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
32
+ `)+this.emit(this.indent(-1))+this.emit(`
33
+ }`)}fontFeatureValues(e){return this.compress?this.emit(`@font-feature-values ${e.fontFamily}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@font-feature-values ${e.fontFamily}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
34
+
35
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}scope(e){let t=e.scope?` ${e.scope}`:``;return this.compress?this.emit(`@scope${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@scope${t}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
36
+
37
+ `)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}viewTransition(e){return this.compress?this.emit(`@view-transition`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@view-transition `,e.position)+this.emit(`{
38
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
39
+ `)+this.emit(this.indent(-1))+this.emit(`
40
+ }`)}positionTry(e){return this.compress?this.emit(`@position-try ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@position-try ${e.name} `,e.position)+this.emit(`{
41
+ `)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
42
+ `)+this.emit(this.indent(-1))+this.emit(`
43
+ }`)}genericAtRule(e){let t=e.prelude?` ${e.prelude}`:``;if(this.compress)return this.emit(`@${e.name}${t}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`);if(!e.rules)return this.emit(`${this.indent()}@${e.name}${t};`,e.position);let n=e.rules.some(e=>e.type!==A.declaration&&e.type!==A.comment),r=n?`
44
+
45
+ `:`
46
+ `;return this.emit(`${this.indent()}@${e.name}${t}`,e.position)+this.emit(n?` {\n${this.indent(1)}`:` {
47
+ `)+this.emit(n?``:this.indent(1))+this.mapVisit(e.rules,r)+this.emit(n?`\n${this.indent(-1)}${this.indent()}}`:`${this.indent(-1)}\n${this.indent()}}`)}rule(e){let t=e.declarations;if(!t.length)return``;if(this.compress)return this.emit(e.selectors.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`);let n=this.indent();return this.emit(e.selectors.map(e=>n+e).join(`,
48
+ `),e.position)+this.emit(` {
49
+ `)+this.emit(this.indent(1))+this.mapVisit(t,`
50
+ `)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}declaration(e){return this.compress?this.emit(`${e.property}:${e.value}`,e.position)+this.emit(`;`):e.property===`grid-template-areas`?this.emit(this.indent())+this.emit(e.property+`: `+e.value.split(`
51
+ `).join(`
52
+ `.padEnd(22)+this.indent()),e.position)+this.emit(`;`):this.emit(this.indent())+this.emit(`${e.property}: ${e.value}`,e.position)+this.emit(`;`)}},Je=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new We(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new Ue(t?.source||``,i,n,r,e);if(!t?.silent)throw o;a.push(o)}function s(){let t=/^{\s*/.exec(e);return!!t&&(l(t),!0)}function c(){let t=/^}/.exec(e);return!!t&&(l(t),!0)}function l(t){let i=t[0];return function(e){let t=e.match(/\n/g);t&&(n+=t.length);let i=e.lastIndexOf(`
53
+ `);r=~i?e.length-i:r+e.length}(i),e=e.slice(i.length),t}function u(){let t=/^\s*/.exec(e);t&&l(t)}function d(e){e||=[];let t=f();for(;t;)e.push(t),t=f();return e}function f(){let t=i();if(e.charAt(0)!==`/`||e.charAt(1)!==`*`)return;let n=/^\/\*[^]*?\*\//.exec(e);return n?(l(n),t({type:A.comment,comment:n[0].slice(2,-2)})):o(`End of comment missing`)}function p(){let t=j(e,[`{`]);if(t===-1||t===0)return;let n=e.substring(0,t);return l([n]),((e,t)=>{let n=[],r=0;for(;r<e.length;){let i=j(e,t,r);if(i===-1)return n.push(e.substring(r)),n;n.push(e.substring(r,i)),r=i+1}return n})(M(n).replace(Ke,``),[`,`]).map(e=>M(e))}function m(){let t=i(),n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!n)return;l(n);let r=M(n[0]),a=/^:\s*/.exec(e);if(!a)return o(`property missing ':'`);l(a);let s=``,c=j(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=M(s).replace(Ke,``));let u=t({type:A.declaration,property:r.replace(Ke,``),value:s}),d=/^[;\s]*/.exec(e);return d&&l(d),u}function h(){let n=[];if(!s())return o(`missing '{'`);d(n);let r=m();for(;r;)n.push(r),d(n),r=m();for(;t?.silent&&e.length&&e.charAt(0)!==`}`;){let t=e.indexOf(`;`),i=e.indexOf(`}`);if(t===-1||!(i===-1||t<i))break;for(l([e.substring(0,t+1)]),u(),d(n),r=m();r;)n.push(r),d(n),r=m()}return c()?n:o(`missing '}'`)}function g(){let t=j(e,[`{`]);if(t===-1)return!1;let n=j(e,[`;`]),r=j(e,[`}`]);return!(n!==-1&&n<t)&&!(r!==-1&&r<t)}function _(){let n=[];if(!s())return o(`missing '{'`);for(d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=C();if(e){n.push(e),d(n);continue}}if(g()){let e=w();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return c()?n:o(`missing '}'`)}function v(){let n=[];for(u(),d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=C();if(e){n.push(e),d(n);continue}}if(g()){let e=w();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return n}function y(){let t=[],n=i(),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);for(;r;){let n=l(r);t.push(n[1]);let i=/^,\s*/.exec(e);i&&l(i),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e)}if(t.length)return n({type:A.keyframe,values:t,declarations:h()||[]})}let ee=RegExp(`^@(${[`top-left-corner`,`top-left`,`top-center`,`top-right`,`top-right-corner`,`bottom-left-corner`,`bottom-left`,`bottom-center`,`bottom-right`,`bottom-right-corner`,`left-top`,`left-middle`,`left-bottom`,`right-top`,`right-middle`,`right-bottom`].join(`|`)})(?![\\w-])\\s*`),b=S(`import`),x=S(`charset`),te=S(`namespace`);function S(t){let n=RegExp(`^@`+t+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return()=>{let r=i(),a=n.exec(e);if(!a)return;let o=l(a),s={type:t};return s[t]=o[1].trim(),r(s)}}function C(){if(e[0]===`@`)return function(){let t=i(),n=/^@([-\w]+)?keyframes\s*/.exec(e);if(!n)return;let r=l(n)[1],a=/^([-\w]+)\s*/.exec(e);if(!a)return o(`@keyframes missing name`);let u=l(a)[1];if(!s())return o(`@keyframes missing '{'`);let f=d(),p=y();for(;p;)f.push(p),f=f.concat(d()),p=y();return c()?t({type:A.keyframes,name:u,vendor:r,keyframes:f}):o(`@keyframes missing '}'`)}()||function(){let t=i(),n=/^@media *([^{]+)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s())return o(`@media missing '{'`);let a=v();return c()?t({type:A.media,media:r,rules:a}):o(`@media missing '}'`)}()||function(){let t=i(),n=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!n)return;let r=l(n);return t({type:A.customMedia,name:M(r[1]),media:M(r[2])})}()||function(){let t=i(),n=/^@supports *([^{]+)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s())return o(`@supports missing '{'`);let a=v();return c()?t({type:A.supports,supports:r,rules:a}):o(`@supports missing '}'`)}()||b()||x()||te()||function(){let t=i(),n=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!n)return;let r=l(n),a=M(r[1]),u=M(r[2]);if(!s())return o(`@document missing '{'`);let d=v();return c()?t({type:A.document,document:u,vendor:a,rules:d}):o(`@document missing '}'`)}()||function(){let t=i(),n=/^@page */.exec(e);if(!n)return;l(n);let r=p()||[];if(!s())return o(`@page missing '{'`);let a=[];for(d(a);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=C();if(e){a.push(e),d(a);continue}}let t=m();if(!t)break;a.push(t),d(a)}return c()?t({type:A.page,selectors:r,declarations:a}):o(`@page missing '}'`)}()||function(){let t=i(),n=/^@host\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@host missing '{'`);let r=v();return c()?t({type:A.host,rules:r}):o(`@host missing '}'`)}()||function(){let t=i(),n=/^@font-face\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@font-face missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:A.fontFace,declarations:r}):o(`@font-face missing '}'`)}()||function(){let t=i(),n=/^@font-feature-values\s+([^{]+)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s())return o(`@font-feature-values missing '{'`);let a=v();return c()?t({type:A.fontFeatureValues,fontFamily:r,rules:a}):o(`@font-feature-values missing '}'`)}()||function(){let t=i(),n=/^@container *([^{]+)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s())return o(`@container missing '{'`);let a=v();return c()?t({type:A.container,container:r,rules:a}):o(`@container missing '}'`)}()||function(){let t=i(),n=/^@starting-style\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@starting-style missing '{'`);let r=v();return c()?t({type:A.startingStyle,rules:r}):o(`@starting-style missing '}'`)}()||function(){let t=i(),n=/^@layer *([^{;@]+)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s()){let n=/^[;\s]*/.exec(e);return n&&l(n),t({type:A.layer,layer:r})}let a=v();return c()?t({type:A.layer,layer:r,rules:a}):o(`@layer missing '}'`)}()||function(){let t=i(),n=/^@property\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@property missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:A.property,name:r,declarations:a}):o(`@property missing '}'`)}()||function(){let t=i(),n=/^@counter-style\s+([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@counter-style missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:A.counterStyle,name:r,declarations:a}):o(`@counter-style missing '}'`)}()||function(){let t=i(),n=/^@scope\s*([^{]*)/.exec(e);if(!n)return;let r=M(l(n)[1]);if(!s())return o(`@scope missing '{'`);let a=v();return c()?t({type:A.scope,scope:r,rules:a}):o(`@scope missing '}'`)}()||function(){let t=i(),n=/^@view-transition\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@view-transition missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:A.viewTransition,declarations:r}):o(`@view-transition missing '}'`)}()||function(){let t=i(),n=/^@position-try\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@position-try missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:A.positionTry,name:r,declarations:a}):o(`@position-try missing '}'`)}()||function(){let t=i(),n=ee.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@${r} missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:A.pageMarginBox,name:r,declarations:a}):o(`@${r} missing '}'`)}()||function(){let t=i(),n=/^@([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1],a=``,u=j(e,[`{`,`;`]);if(u!==-1&&u>0&&(a=M(e.substring(0,u)),l([e.substring(0,u)])),s()){let e=v();return c()?t({type:A.atRule,name:r,prelude:a,rules:e}):o(`@${r} missing '}'`)}let d=/^[;\s]*/.exec(e);return d&&l(d),t({type:A.atRule,name:r,prelude:a})}()}function w(){let e=i(),t=p();return t?(d(),e({type:A.rule,selectors:t,declarations:_()||[]})):o(`selector missing`)}return N(function(){let n=function(){let n,r=[];for(u(),d(r);e.length;){if(e.charAt(0)===`}`){if(t?.silent){o(`extra '}'`),l([`}`]),u(),d(r);continue}break}if(n=C()||w(),!n){if(t?.silent){l([e.charAt(0)]),u(),d(r);continue}break}r.push(n),d(r)}return r}();return{type:A.stylesheet,stylesheet:{source:t?.source,rules:n,parsingErrors:a}}}())},Ye=(e,t)=>new qe(t||{}).compile(e),Xe=Object.defineProperty,Ze=(e,t)=>{let n={};for(var r in e)Xe(n,r,{get:e[r],enumerable:!0});return t||Xe(n,Symbol.toStringTag,{value:`Module`}),n},Qe=`LocatorError`,P=`LocatorUnsupportedError`,F=`LocatorDeniedError`,I=`LocatorInvalidError`,L=e=>typeof e==`object`&&e?e.name:void 0,R=e=>Object.assign(Error(e),{name:Qe}),z=(e,t=``,n)=>Object.assign(Error(e),{name:P,operation:t,backend:n}),$e=(e,t)=>z(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),B=(e,t)=>Object.assign(Error(e),{name:F,operation:t}),et=(e,t)=>Object.assign(Error(e),{name:I,operation:t}),V=class extends Error{name=`TimeoutError`;constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause})}},tt=e=>L(e)===P,nt=e=>L(e)===F,H=e=>L(e)===I,rt=e=>nt(e)||tt(e)||H(e),U=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw R(`the resolved element belongs to a document with no window`);return t},it=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},at=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return it(U(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=it(globalThis,t);return r&&e instanceof r?r:null},W=(e,t)=>at(e,t)!==null,G=e=>{if(e.length===0)throw R(`No elements found`);if(e.length>1)throw R(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},ot=(e,t)=>{if(!W(e,t))throw R(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},st=e=>e.tagName.toLowerCase(),ct=new Set,lt=e=>{ct.add(e)},ut=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,dt=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),ft=e=>!ut.test(dt(e.value)),pt=new Set([A.import,A.fontFace,A.namespace,A.charset,A.document,A.comment]),mt=e=>{if(pt.has(e.type))return null;if(e.type===A.declaration)return ft(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=ht(r))}return n},ht=e=>e.map(e=>mt(e)).filter(e=>e!==null),gt=e=>{let t;try{t=Je(e,{silent:!0})}catch{return``}return t.stylesheet.rules=ht(t.stylesheet.rules),Ye(t)},_t=(e,t)=>{let n=()=>{t.parentNode||(e.head??e.documentElement).appendChild(t)};if(n(),e.readyState===`complete`)return;let r=new MutationObserver(e=>{for(let r of e)for(let e of r.removedNodes)if(e===t||e.contains?.(t)){n();return}});r.observe(e.documentElement,{childList:!0,subtree:!0});let i=()=>r.disconnect(),a=e.defaultView;a?a.addEventListener(`load`,i,{once:!0}):setTimeout(i,3e4)},vt={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:gt(t.content);try{_t(e.document,n)}catch(e){console.error(e)}lt(n)}},yt=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},K={kind:`frame`,ensureArgs:e=>[void 0,e],resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw et(`fetch: url must be a string`,`fetch`);let r=U(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw et(`fetch: not a valid url: ${t}`,`fetch`)}let a=await r.fetch(i,{method:n.method??`GET`,headers:n.headers,body:n.body??null,redirect:n.redirect??`follow`,credentials:n.credentials??`include`});return{status:a.status,statusText:a.statusText,ok:a.ok,url:a.url,redirected:a.redirected,type:a.type,headers:yt(a.headers),body:await a.arrayBuffer()}}},q=Ze({click:()=>xt,count:()=>kt,exists:()=>At,fill:()=>Tt,getAttribute:()=>Dt,hover:()=>St,isVisible:()=>Ot,textContent:()=>Et}),bt=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},xt={resolve:(e,t={})=>{let n=G(e.elements),r=U(n),i={bubbles:!0,cancelable:!0,composed:!0,...bt(n,t.position),button:0},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerdown`,{...a,buttons:1})),n.dispatchEvent(new r.MouseEvent(`mousedown`,{...i,buttons:1})),n.dispatchEvent(new r.PointerEvent(`pointerup`,{...a,buttons:0})),n.dispatchEvent(new r.MouseEvent(`mouseup`,{...i,buttons:0})),n.dispatchEvent(new r.MouseEvent(`click`,{...i,buttons:0}))}},St={resolve:(e,t={})=>{let n=G(e.elements),r=U(n),i={bubbles:!0,cancelable:!0,composed:!0,...bt(n,t.position)},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerover`,a)),n.dispatchEvent(new r.PointerEvent(`pointerenter`,{...a,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseenter`,{...i,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseover`,i)),n.dispatchEvent(new r.PointerEvent(`pointermove`,a)),n.dispatchEvent(new r.MouseEvent(`mousemove`,i))}},Ct=(e,t)=>{e._valueTracker?.setValue(``);let n=(at(e,`HTMLTextAreaElement`)??at(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},wt=(e,t)=>{if(e.type!==`range`)return null;let n=Number(e.min||0),r=Number(e.max||100);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=Number(t);if(!Number.isFinite(i))return null;let a=Math.max(0,Math.min(1,(i-n)/(r-n))),o=e.getBoundingClientRect(),s={bubbles:!0,cancelable:!0,composed:!0,clientX:o.left+o.width*a,clientY:o.top+o.height/2,button:0},c={...s,pointerType:`mouse`,pointerId:1,isPrimary:!0};return{pointerDown:{...c,buttons:1},pointerUp:{...c,buttons:0},mouseDown:{...s,buttons:1},mouseUp:{...s,buttons:0}}},Tt={resolve:(e,t,n={})=>{let r=G(e.elements),i=U(r),a=W(r,`HTMLInputElement`);if(a||W(r,`HTMLTextAreaElement`)){let e=r,n=a?wt(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),Ct(e,t),r.dispatchEvent(new i.Event(`input`,{bubbles:!0})),n&&(r.dispatchEvent(new i.PointerEvent(`pointerup`,n.pointerUp)),r.dispatchEvent(new i.MouseEvent(`mouseup`,n.mouseUp))),r.dispatchEvent(new i.Event(`change`,{bubbles:!0}));return}if(W(r,`HTMLElement`)&&r.isContentEditable){r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));return}throw Error(`fill: element <${st(r)}> is not fillable`)}},Et={resolve:(e,t={})=>G(e.elements).textContent},Dt={resolve:(e,t,n={})=>G(e.elements).getAttribute(t)},Ot={resolve:(e,t={})=>{let n=G(e.elements);if(!W(n,`HTMLElement`))return!0;let r=U(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},kt={resolve:(e,t={})=>e.elements.length},At={resolve:(e,t={})=>e.elements.length>0},J=(e,t)=>e.elements.flatMap(e=>[...e.querySelectorAll(t)]),jt=e=>e.replaceAll(`"`,`\\"`),Mt={to:`element`,css:!0,resolve:(e,t)=>J(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},Nt={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>J(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},Pt={element:{selectors:{locator:Mt,frameLocator:Nt,getByRole:{to:`element`,resolve:(e,t)=>J(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${jt(e)}"]`:`[role]`})},getByText:{to:`element`,resolve:(e,t)=>e.elements.flatMap(e=>[e,...e.querySelectorAll(`*`)]).filter(e=>e.textContent?.includes(t)),render:e=>({fragment:typeof e==`string`?`:has-text("${jt(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>J(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${jt(e)}"]`:`[data-testid]`})},first:{to:`element`,resolve:e=>e.elements.slice(0,1),render:()=>({fragment:`:first`})},nth:{to:`element`,resolve:(e,t)=>{let n=e.elements.at(t);return n?[n]:[]},render:e=>({fragment:typeof e==`number`?`:nth(${e})`:`:nth(?)`})}},operations:{click:xt,fill:Tt,hover:St,textContent:Et,getAttribute:Dt,isVisible:Ot,count:kt,exists:At}},frame:{selectors:{locator:Mt,frameLocator:Nt,owner:{to:`frame`,barrier:`up`,resolve:e=>{throw Error(`owner: must be processed by the executor as an upward pivot`)},render:()=>({fragment:``,separator:`up`})}},operations:{addStyleTag:vt,fetch:K}}},Ft=(e,t=Pt)=>({element:{selectors:{...t.element.selectors,...e.element?.selectors},operations:{...t.element.operations,...e.element?.operations}},frame:{selectors:{...t.frame.selectors,...e.frame?.selectors},operations:{...t.frame.operations,...e.frame?.operations}}}),It=3e4,Lt=50,Rt=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},zt=e=>{let t=Rt(e)?.timeout;return typeof t==`number`?t:It},Bt=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),Vt=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,Bt(e))},Ht=(e,t)=>{if(t!==void 0&&typeof t==`number`&&!(Number.isFinite(t)&&t>0))throw TypeError(`${e}: timeout must be a positive number of milliseconds, not ${t}; every call ends at its deadline, so 0 does not turn it off`)},Ut=e=>typeof e==`object`&&e&&typeof e.message==`string`?e.message:String(e),Wt=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;Ht(i,Rt(a)?.timeout),n&&await n({parts:r,operation:i,args:a,phase:`execute`},Bt(e));let o=zt(a),s=Date.now()+o,c=Error(`Locator timeout (${o}ms): ${i}`),{promise:l,reject:u}=Promise.withResolvers();l.catch(()=>{});let d=setTimeout(()=>u(c),o),f=c;try{for(;Date.now()<s;)try{return await Promise.race([t.execute(r,i,a),l])}catch(e){if(e===c)break;if(rt(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(Lt,t)))}}finally{clearTimeout(d)}throw f===c?new V(c.message):new V(Ut(f),{cause:f})},Gt=(e,t,n,r,i)=>{let a={};for(let[o,s]of Object.entries(t[r].selectors))a[o]=(...a)=>Gt(e,t,n,s.to,[...i,{kind:r,name:o,args:a}]);for(let[n,o]of Object.entries(t[r].operations))a[n]=async(...t)=>Wt({...e,parts:i,operation:n,args:o.send?o.send(...t):t});for(let[o,{to:s,rewrite:c}]of Object.entries(n[r]??{}))a[o]=(...r)=>Gt(e,t,n,s,c(i,...r));return a.ensure=(n,a={})=>{let o=t[r].operations[n]?.ensureArgs;return Vt({...e,parts:i,operation:n,args:o?.(a)??[a]})},a},Kt=e=>Gt(e,e.modules??Pt,e.rewrites??{},`frame`,[]),qt=()=>{let e=D();return e.status===`ok`&&e.abi>=2},Jt=async()=>{await O();let e=D();if(e.status===`ok`&&e.abi<2)throw new T(e.abi,2)},Yt=e=>`Read the text, links and details ${e} shows.`,Xt=e=>`Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`,Zt=[{id:`interaction`,heading:`Interaction`,summary:`Allow the app to interact with the website (clicks, type in text, etc.)`,title:e=>`Interact with ${e}`,description:(e,t)=>t?`Click, type and hover on ${e} for you. If you are signed in there, this happens as you.`:`Click, type and hover on ${e} for you, in a signed-out view.`,cloudTitle:e=>`Click and type on ${e}`,cloudDescription:e=>`Clicks, types and scrolls on ${e} for you.`},{id:`storage`,heading:`Site data`,summary:`Can read the website's data`,title:e=>`Read data from ${e}`,description:Yt,cloudTitle:e=>`Read what's on ${e}`,cloudDescription:Yt},{id:`network`,heading:`Network`,summary:`Make requests on behalf of the website (using your cookies, etc.)`,title:e=>`Make requests to ${e} as you`,description:e=>`Load pages and data from ${e} and send changes there with your signed-in session.`,cloudTitle:e=>`Load and send data on ${e}`,cloudDescription:e=>`Loads pages and data from ${e} and sends changes there.`},{id:`evaluation`,heading:`Evaluation`,summary:`Can execute arbitrary code on the website`,title:e=>`Run code on ${e}`,description:Xt,cloudTitle:e=>`Run its own code on ${e}`,cloudDescription:Xt}],Qt=e=>t=>{if(typeof t!=`object`||!t)return t===void 0?[]:[t];if(t.position!==void 0)throw TypeError(`${e}: position is Playwright's offset in pixels, which no backend serves yet; pass relativePosition, a 0..1 fraction of the box`);let{relativePosition:n,...r}=t;return[n===void 0?r:{...r,position:n}]},$t=Ft({element:{operations:{click:{resolve:(e,t={})=>q.click.resolve(e,t),send:Qt(`click`)},hover:{resolve:(e,t={})=>q.hover.resolve(e,t),send:Qt(`hover`)},fill:{resolve:(e,t,n={})=>q.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>q.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>q.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>q.isVisible.resolve(e)},count:{resolve:(e,t={})=>q.count.resolve(e)},exists:{resolve:(e,t={})=>q.exists.resolve(e)},videoElement:{resolve:(e,t={})=>x(ot(G(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>vt.resolve(e,t)},fetch:{resolve:(e,t,n={})=>K.resolve(e,t,n),kind:K.kind,ensureArgs:K.ensureArgs},evaluate:{kind:`frame`,typed:!1,resolve:(e,t,n)=>{throw $e(`evaluate`,`this realm`)}}}}}),en=e=>e[e.length-1],tn={element:{last:{to:`element`,rewrite:e=>[...e,{kind:`element`,name:`nth`,args:[-1]}]},contentFrame:{to:`frame`,rewrite:e=>{let t=en(e);if(t?.name!==`locator`)throw TypeError(`locator.contentFrame: only a locator that ends in locator(selector) can enter its frame; use frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`frameLocator`}]}}},frame:{owner:{to:`element`,rewrite:e=>{let t=en(e);if(t?.name!==`frameLocator`)throw TypeError(`frameLocator.owner: this frame was not entered through frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`locator`}]}},getByTestId:{to:`element`,rewrite:(e,t)=>[...e,{kind:`element`,name:`getByTestId`,args:[t]}]}}},nn=e=>{if(!e||e===`about:blank`)return!1;let t;try{t=new URL(e,location.href)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`||t.protocol!==`about:`&&Oe(t.hostname)},Y=e=>{if(nn(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},rn=({src:e,domains:t,lockdown:n})=>{if(n&&!t.length&&e&&e!==`about:blank`)throw Error(`attachFrame: lockdown needs domains when the frame already has a src; pass domains or load it via goto`)},an={scope:`embed.iframe`,category:`interaction`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},on={scope:`embed.open`,category:`interaction`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},sn=[`load`,`commit`],cn=e=>{if(`timeoutMs`in e)throw TypeError(`frame.goto: pass timeout, in milliseconds; timeoutMs is not an option`);let{waitUntil:t,timeout:n}=e;if(t!==void 0&&!sn.includes(t))throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);if(n!==void 0&&typeof n!=`number`)throw TypeError(`frame.goto: timeout must be a number of milliseconds`);Ht(`frame.goto`,n)},ln=class extends Error{name=`FrameWindowBlockedError`;constructor(){super(`attachFrame: the browser did not open the window. Call attachFrame directly in a click or key handler, and allow popups for this page`)}},un=new Set([`jar-unreachable`,`bad-url`,`opaque-opener`]),dn=class extends Error{name=`FrameWindowRefusedError`;reason;constructor(e){let t=un.has(e)?e:`unknown`;super(t===`opaque-opener`?`attachFrame: this page has an opaque origin, which a window can never answer, so no window was opened`:`attachFrame: the window refused to attach (${t}), and loaded nothing`),this.reason=t}},fn=[`message`,`document`],pn=e=>{if(e===`*`)return`*`;let t=()=>TypeError(`frame.postMessage: targetOrigin must be '*' or an origin, not ${JSON.stringify(e)}`);if(typeof e!=`string`)throw t();let n;try{n=new URL(e).origin}catch{throw t()}if(n===`null`)throw t();return n},mn=(e,t)=>{let n=typeof e==`object`&&!!e;if(n&&t!==void 0)throw TypeError(`frame.postMessage: pass transfer inside the options object, not after it`);let r=n?e.targetOrigin??`*`:e??`*`,i=n?e.transfer:t;if(i!==void 0&&!Array.isArray(i))throw TypeError(`frame.postMessage: transfer must be an array`);return{targetOrigin:pn(r),transfer:i===void 0?[]:[...i]}},hn=[`url`,`path`,`type`],gn=[`content`,`sourceUrl`],_n=/[\n\r\u2028\u2029]/,vn=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`frame.addScriptTag: options must be an object { content }`);let t=Object.keys(e),n=t.find(e=>hn.includes(e));if(n!==void 0)throw TypeError(`frame.addScriptTag: "${n}" is not served; it runs content as a classic inline script`);let r=t.find(e=>!gn.includes(e));if(r!==void 0)throw TypeError(`frame.addScriptTag: unknown option "${r}"`);let{content:i,sourceUrl:a}=e;if(typeof i!=`string`)throw TypeError(`frame.addScriptTag: content must be a string`);if(a!==void 0&&(typeof a!=`string`||a===``||_n.test(a)))throw TypeError(`frame.addScriptTag: sourceUrl must be a non-empty string with no line break`);return a===void 0?{content:i}:{content:i,sourceUrl:a}},yn=[`name`,`domain`,`path`],bn=e=>e instanceof RegExp||Object.prototype.toString.call(e)===`[object RegExp]`,xn=e=>{if(e===void 0)return{};if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`frame.clearCookies: options must be an object`);let t=e,n=Object.keys(t).find(e=>!yn.includes(e));if(n!==void 0)throw TypeError(`frame.clearCookies: unknown option "${n}"`);let r=yn.flatMap(e=>{let n=t[e];return n===void 0?[]:[{key:e,value:n}]}),i=r.find(({value:e})=>bn(e));if(i!==void 0)throw TypeError(`frame.clearCookies: ${i.key} is a RegExp, and clearCookies takes strings for name, domain and path for now`);let a=r.find(({value:e})=>typeof e!=`string`);if(a!==void 0)throw TypeError(`frame.clearCookies: ${a.key} must be a string`);let o=r.find(({value:e})=>e===``);if(o!==void 0)throw TypeError(`frame.clearCookies: ${o.key} must not be empty; leave it out to match every ${o.key}`);let s={};for(let{key:e,value:t}of r)s[e]={equals:t};return s},Sn=e=>{typeof globalThis.reportError==`function`?globalThis.reportError(e):console.error(e)},Cn=e=>{let{owner:t,...n}=Kt({executor:e.executor,modules:$t,rewrites:tn,gate:e.gate}),r=async(t,n={})=>(Y(t),cn(n),e.goto(t,n)),i=()=>e.url(),a=async t=>{let n=e.requestPermissions;if(!n)throw Error(`frame.requestPermissions: this backend cannot ask for permission categories`);return n(t)},o=async(t,n)=>{let r=e.evaluate;if(!r)throw Error(`frame.evaluate: this backend cannot run code in the attached frame`);let i=typeof t==`function`?t.toString():t;if(typeof i!=`string`)throw TypeError(`frame.evaluate: pass a function or a source string`);return r(i,structuredClone(n))},s=async t=>{let{content:n,...r}=vn(t),i=e.addScriptTag;if(!i)throw Error(`frame.addScriptTag: this backend cannot run scripts in the attached frame`);await i(n,r)},c=async t=>{let n=xn(t),r=e.clearCookies;if(!r)throw Error(`frame.clearCookies: this backend cannot clear cookies`);await r(n)},l=((t,n,r)=>{try{let i=e.postMessage;if(!i)throw Error(`frame.postMessage: this backend cannot message the attached frame`);let a=mn(n,r);return i(t,a.targetOrigin,a.transfer)}catch(e){return Promise.reject(e)}}),u={message:new Set,document:new Set},d=null,f=(e,t)=>{if(!fn.includes(e))throw TypeError(`frame.${t}: the event type must be ${fn.map(e=>`'${e}'`).join(` or `)}, not ${JSON.stringify(e)}`);return u[e]},p=e=>{let t=e.type===`message`?Object.freeze({type:`message`,data:e.data,origin:e.origin,ports:Object.freeze([...e.ports]),source:_}):Object.freeze({type:`document`,origin:e.origin});for(let n of[...u[e.type]])try{n(t)}catch(e){Sn(e)}},m=(e,t)=>{if(f(e,`off`).delete(t),d!==null&&!u.message.size&&!u.document.size){let e=d;d=null,e()}},h=(t,n,r={})=>{let i=f(t,`on`);if(typeof n!=`function`)throw TypeError(`frame.on: the listener must be a function`);let{signal:a}=r;if(!(a?.aborted||i.has(n))){if(d===null){let t=e.listen;if(!t)throw Error(`frame.on: this backend cannot relay the page's messages`);d=t(p)}i.add(n),a?.addEventListener(`abort`,()=>m(t,n),{once:!0})}},g=()=>e.backend,_={...n,goto:r,url:i,backend:g,requestPermissions:a,evaluate:o,addScriptTag:s,clearCookies:c,postMessage:l,on:h,off:m};return _},wn=[t.v,t._,t.y,t.h,t.g,t.n,t.i,t.r,t.f,t.a,t.o,t.s,t.p,an,on,t.u,t.d,ke,Ae,je,Re,Be],Tn=Zt.map(e=>e.id),En={interaction:`act.click`,storage:`read.text`,network:`network.fetchCredentialed`,evaluation:`media.appearU`},Dn=e=>e===0?`auto`:e===4?`critical`:`bundled`,On=wn,X=new Map,kn={};(()=>{X=new Map(On.map(e=>[e.scope,e])),kn=Object.fromEntries(X),On.filter(e=>e.severity===4).map(e=>e.scope);let e=e=>On.filter(t=>t.category===e&&Dn(t.severity)===`bundled`);Object.fromEntries(Tn.map(t=>[t,Math.max(0,...e(t).map(e=>e.severity))])),Object.fromEntries(Tn.map(t=>[t,e(t).some(e=>e.unsafe===!0)]))})();var An=e=>X.get(e)?.category,jn=e=>{let t=X.get(e);return t&&Dn(t.severity)},Mn=e=>{let t=X.get(e);if(t)return Dn(t.severity)===`critical`?t.scope:t.category},Nn=e=>En[e],Pn=({category:e,key:t})=>{let n=t??(e&&Nn(e));return n!==void 0&&An(n)!==void 0?n:void 0},Fn=(e,t)=>{for(let{category:n,key:r}of t)if(Pn({category:n,key:r})===void 0)throw TypeError(r===void 0?n===void 0?`${e}: name a category or a permission key`:`${e}: unknown permission category "${n}"`:`${e}: unknown permission key "${r}"`)},In=(e,t={})=>{let n=[],r=e.map(e=>{let r=Pn(e),i=[];if(r!==void 0)for(let a of e.hosts)i.push(n.length),n.push({...t,key:r,scope:``,site:a,hosts:e.hosts,reason:e.reason});return{key:r!==void 0&&jn(r)===`critical`?r:void 0,category:r===void 0?e.category??`interaction`:kn[r].category,hosts:e.hosts,indexes:i}});return{items:n,answer:e=>r.map(({key:t,category:n,hosts:r,indexes:i})=>({category:n,...t===void 0?{}:{key:t},hosts:r,allow:i.length>0&&i.every(t=>e[t]?.allow===!0)}))}},Ln=e=>typeof e==`object`&&!!e,Rn=typeof chrome<`u`&&!!chrome.runtime?.id,zn=e=>Ln(e)&&e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY===!0&&typeof e.frameId==`string`&&typeof e.document==`string`,Bn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,Un=new Set;typeof window<`u`&&Rn&&window.addEventListener(`message`,e=>{if(!zn(e.data))return;e.stopImmediatePropagation();let t=e.source;if(!t||typeof t!=`object`)return;let n=t,r=Bn.get(n),i=e.data.frameId,a=e.data.document;if(Bn.set(n,i),Vn.set(n,a),r)for(let e of Un)e(r);let o=Hn.get(n);if(o){for(let e of[...o])(e.notDocument===void 0||e.notDocument!==a)&&(o.delete(e),e.resolve(i));o.size||Hn.delete(n)}},{capture:!0});var Wn=3e4,Gn=`frame.evaluate: the code did not settle within ${Wn}ms`,Kn=()=>new V(Gn),qn=e=>H(e)&&e.message===Gn?Kn():e,Jn=[/^frame load timed out after \d+ms for /,/^frame goto: documentstart timed out$/,/^navigation to .+ did not commit a document within \d+ms$/s],Yn=e=>{if(e instanceof V)return e;let t=typeof e?.message==`string`?e.message:``;return Jn.some(e=>e.test(t))?new V(t):e},Xn=e=>{let t=e;if(t.window===void 0)return`iframe`;if(t.iframe!==void 0)throw TypeError(`attachFrame: pass either iframe or window, not both`);if(t.lockdown)throw TypeError(`attachFrame: lockdown applies to an iframe, never to a window`);if(t.blank!==void 0)throw TypeError(`attachFrame: blank does not apply to a window`);if(typeof t.window!=`object`||t.window===null)throw TypeError(`attachFrame: window must be an object`);return`window`},Zn=(e,t,n)=>{if(e===void 0)return t;if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw TypeError(`attachFrame: window.${n} must be a positive number of CSS pixels`);return Math.round(e)},Qn=({url:e,width:t,height:n})=>{let r=(()=>{if(e===void 0||e===``||e===`about:blank`)return``;if(typeof e!=`string`)throw TypeError(`attachFrame: window.url must be a string`);let t=(()=>{try{return new URL(e,location.href)}catch{throw TypeError(`attachFrame: window.url is not a valid URL: ${e}`)}})();if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`attachFrame: window.url must be an http or https address`);return t.href})();return r&&Y(r),{url:r,width:Zn(t,500,`width`),height:Zn(n,700,`height`)}},$n=`attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'`,er=1e11,tr=[`name`,`value`,`domain`,`path`,`expires`,`httpOnly`,`secure`,`sameSite`],nr=[`Strict`,`Lax`,`None`],rr=/[;\x00-\x1f\x7f]/,Z=(e,t)=>TypeError(`attachFrame: storageState${e} ${t}`),Q=e=>Object.prototype.toString.call(e)===`[object Object]`,ir=e=>{let t=e.startsWith(`.`)?e.slice(1):e;if(t===``)return null;try{return new URL(`http://${t}/`).hostname===t.toLowerCase()?t.toLowerCase():null}catch{return null}},ar=(e,t)=>{if(!Q(e))throw Z(t,`must be an object`);let n=Object.keys(e).find(e=>!tr.includes(e));if(n!==void 0)throw Z(`${t}.${n}`,`is not a cookie field`);let{name:r,value:i,domain:a,path:o,expires:s,httpOnly:c,secure:l,sameSite:u}=e;if(typeof r!=`string`||r===``||r.includes(`=`)||rr.test(r))throw Z(`${t}.name`,`must be a non-empty string with no "=", ";" or control character`);if(typeof i!=`string`||rr.test(i))throw Z(`${t}.value`,`must be a string with no ";" or control character`);if(typeof a!=`string`||ir(a)===null)throw Z(`${t}.domain`,`must be a host: ".youtube.com" for a cookie its subdomains also receive, "www.youtube.com" for a host-only one`);if(o!==void 0&&(typeof o!=`string`||!o.startsWith(`/`)||rr.test(o)))throw Z(`${t}.path`,`must be a string starting with "/"`);if(s!==void 0&&(typeof s!=`number`||!Number.isFinite(s)||s<=0&&s!==-1))throw Z(`${t}.expires`,`must be -1 for a session cookie, or milliseconds since the epoch`);if(c!==void 0&&typeof c!=`boolean`)throw Z(`${t}.httpOnly`,`must be a boolean`);if(l!==void 0&&typeof l!=`boolean`)throw Z(`${t}.secure`,`must be a boolean`);if(u!==void 0&&!nr.includes(u))throw Z(`${t}.sameSite`,`must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);let d=r.toLowerCase();if(u===`None`&&l!==!0)throw Z(t,`is SameSite=None, which needs secure: true`);if(d.startsWith(`__secure-`)&&l!==!0)throw Z(t,`is a __Secure- cookie, which needs secure: true`);if(d.startsWith(`__host-`)&&(l!==!0||a.startsWith(`.`)||(o??`/`)!==`/`))throw Z(t,`is a __Host- cookie, which needs secure: true, a host-only domain and path "/"`);let f={name:r,value:i,domain:a};return o!==void 0&&(f.path=o),s!==void 0&&(f.expires=s),c!==void 0&&(f.httpOnly=c),l!==void 0&&(f.secure=l),u!==void 0&&(f.sameSite=u),f},or=(e,t)=>{if(!Q(e))throw Z(t,`must be an object { origin, localStorage }`);let n=Object.keys(e).find(e=>e!==`origin`&&e!==`localStorage`);if(n!==void 0)throw Z(`${t}.${n}`,`is not an origin field`);let{origin:r,localStorage:i}=e,a=(()=>{try{return typeof r==`string`?new URL(r):null}catch{return null}})();if(a===null||a.protocol!==`http:`&&a.protocol!==`https:`||a.origin!==r)throw Z(`${t}.origin`,`must be an absolute http or https origin, not ${JSON.stringify(r)}`);if(!Array.isArray(i))throw Z(`${t}.localStorage`,`must be an array`);return{origin:r,localStorage:i.map((e,n)=>{let{name:r,value:i}=Q(e)&&Object.keys(e).every(e=>e===`name`||e===`value`)?e:{};if(typeof r!=`string`||typeof i!=`string`)throw Z(`${t}.localStorage[${n}]`,`must be { name, value } strings`);return{name:r,value:i}})}},sr=e=>{if(!Q(e))throw Z(``,`must be an object { cookies?, origins? }`);let t=Object.keys(e).find(e=>e!==`cookies`&&e!==`origins`);if(t!==void 0)throw Z(`.${t}`,`is not a storageState key; it takes cookies and origins`);let{cookies:n=[],origins:r=[]}=e;if(!Array.isArray(n))throw Z(`.cookies`,`must be an array`);if(!Array.isArray(r))throw Z(`.origins`,`must be an array`);let i=n.map((e,t)=>ar(e,`.cookies[${t}]`)),a=r.map((e,t)=>or(e,`.origins[${t}]`));return i.forEach(({expires:e},t)=>{if(e!==void 0&&e>0&&e<er)throw Z(`.cookies[${t}].expires`,`is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`)}),{cookies:i,origins:a}},cr=[`persistent`,`ephemeral`,`native`],lr=`attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'`,ur=e=>{if(`syncCookies`in e)throw TypeError(lr);let{cookies:t=`persistent`}=e;if(!cr.includes(t))throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);if(e.storageState!==void 0&&t!==`ephemeral`)throw TypeError($n);let n=e.storageState===void 0?void 0:sr(e.storageState),r=Xn(e);if(r===`iframe`&&e.lockdown&&t!==`native`)throw TypeError(`attachFrame: lockdown runs on the extension, which serves only cookies: 'native'`);return n===void 0?{kind:r,cookies:t}:{kind:r,cookies:t,storageState:n}},dr=e=>{try{return new URL(e).hostname}catch{return``}},fr=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,pr=!1,mr=()=>{pr||(pr=!0,console.warn(`[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this.`))},hr=`frame: this frame no longer holds the document the app attached it to`,gr=`frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin`,_r=()=>{let e=D();if(e.status===`ok`&&e.abi>=1)return;let t=e.status===`absent`?0:e.abi;throw new E(`lockdown`,t,`attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`)},vr=e=>{try{return new URL(e,location.href).hostname}catch{return``}},$=()=>{let e=D();return e.status===`absent`?0:e.abi},yr=`attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame`,br=`frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame`,xr=`frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar`,Sr=async({iframe:e,domains:n=[],lockdown:r=!1,permissions:i,blank:a})=>{if(a!==void 0)throw new E(`blank`,$(),yr);let o=crypto.randomUUID();if(Y(e.src),rn({src:e.src,domains:n,lockdown:r}),await O(),r&&_r(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(fr,{detail:o}));let{executeLocator:s,highlightLocator:c,ensureLocatorPermission:l,requestCategories:u,evaluateFrame:d,goto:f}=await k.attachFrame({marker:o,domains:n,syncCookies:!0,lockdown:r}),p=new Set(t.t([...n,vr(e.src)],{ipv6:!0})),m=e=>p.has(t.t([dr(e)],{ipv6:!0})[0]??``),h=Cn({backend:`extension`,executor:{execute:s,highlight:c},gate:e=>l(e.parts,e.operation,e.args),requestPermissions:async e=>(Fn(`frame.requestPermissions`,e),await Jt(),u(e)),evaluate:async(e,t)=>{if(!fe(D(),`evaluate`)){let e=D();throw new E(`evaluate`,e.status===`ok`?e.abi:0)}return d({source:e,arg:t}).catch(e=>{throw qn(e)})},addScriptTag:async()=>{throw new E(`addScriptTag`,$(),br)},clearCookies:async()=>{throw new E(`clearCookies`,$(),xr)},postMessage:(t,n,r)=>{if(n===`*`)throw z(gr,`postMessage`,`extension`);if(!m(n))throw B(hr,`postMessage`);let i=e.contentWindow;if(i===null)throw B(`frame: navigate the frame before postMessage`,`postMessage`);return i.postMessage(t,n,r),Promise.resolve()},listen:t=>{let n=n=>{n.source!==null&&n.source===e.contentWindow&&!zn(n.data)&&m(n.origin)&&t({type:`message`,data:n.data,origin:n.origin,ports:n.ports})},r=()=>t({type:`document`,origin:``});return window.addEventListener(`message`,n),e.addEventListener(`load`,r),()=>{window.removeEventListener(`message`,n),e.removeEventListener(`load`,r)}},goto:(e,{waitUntil:n,timeout:r,...i}={})=>{for(let n of t.t([vr(e)],{ipv6:!0}))p.add(n);return f({url:e,...i,...n===void 0?{}:{waitUntil:n===`commit`?`documentstart`:n},...r===void 0?{}:{timeoutMs:r}}).catch(e=>{throw Yn(e)})},url:()=>e.src});return i?.length&&(qt()?await h.requestPermissions(i):mr()),h},Cr=`attachFrame: a window on cookies: 'native' is not served yet; a window runs on the cloud render proxy, which has no browser cookies`,wr=e=>`attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`,Tr=async e=>{throw Qn(e.window),new E(`attachWindow`,$(),Cr)},Er=(async e=>{let{kind:t,cookies:n}=ur(e);if(n!==`native`)throw new E(`cookies`,$(),wr(n));return t===`window`?Tr(e):Sr(e)}),Dr=`permissions.request: pass hosts, the sites the grant applies to`,Or={request:async e=>{let n=e.map(e=>{let{category:n,key:r,scope:i,reason:a,hosts:o}=e;if(!(`hosts`in e)&&!(`category`in e))return{legacy:{key:r,scope:i??``,reason:a}};let s=t.t(o??[],{ipv6:!0});if(!s.length)throw TypeError(Dr);return{ask:{category:n,key:r,reason:a,hosts:s}}}),r=n.flatMap(e=>`ask`in e?[e.ask]:[]);Fn(`permissions.request`,r),r.length&&await Jt();let{items:i,answer:a}=In(r),o=n.flatMap(e=>`legacy`in e?[e.legacy]:[]),s=[...i,...o],c=s.length?await k.requestPermissions(s):[],l=a(c.slice(0,i.length)),u=c.slice(i.length),d=0,f=0;return n.map(e=>`ask`in e?l[d++]:u[f++])}},kr=`PermissionDeniedError`,Ar=e=>e instanceof Error?e.name===kr:Ln(e)&&e.name===`PermissionDeniedError`;Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return nn}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return rn}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return on}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Fn}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return jn}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return An}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return kr}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return an}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return Ve}});
@@ -1,6 +1,6 @@
1
+ import { Ct as TcpSocketListenerResult, K as Resolvers, Tt as TcpSocketResult } from "./contract-DJxGa8lb.js";
1
2
  import { o as TcpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { Ct as TcpSocketListenerResult, K as Resolvers, Tt as TcpSocketResult } from "./contract-CCxPKIC7.js";
3
- import "./api-SwxtiYVU.js";
3
+ import "./api-H1TzWitc.js";
4
4
  import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
5
5
  import { DuplexOptions, Stream } from "stream";
6
6
  import { EventEmitter } from "events";
package/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-DcLF-6E-.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-BOswhyfE.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fkn/lib",
3
- "version": "0.9.42",
3
+ "version": "0.9.43",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
package/packages.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as InstalledPackage, F as PackageResult, G as Radii, I as PackagesErrorCode, P as PackageQuery, R as PickOptions, T as InstallOptions, m as ConnectOptions, xt as SurfaceRect, z as Placement } from "./contract-CCxPKIC7.js";
1
+ import { E as InstalledPackage, F as PackageResult, G as Radii, I as PackagesErrorCode, P as PackageQuery, R as PickOptions, T as InstallOptions, m as ConnectOptions, xt as SurfaceRect, z as Placement } from "./contract-DJxGa8lb.js";
2
2
  import { Remote } from "osra";
3
3
  declare namespace packages_d_exports {
4
4
  export { AppConnectOptions, Connect, ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, InstallOptions, InstalledPackage, MountOptions, MountedPackage, PackageConnection, PackageQuery, PackageResult, PackageView, PackagesError, PackagesErrorCode, PickOptions, Placement, Radii, RawPackageConnection, ShowOptions, SurfaceRect, attach, connect, hide, install, isVisible, list, mount, onConnect, onVisibilityChange, pick, search, show, uninstall };
@@ -1,5 +1,5 @@
1
- import { K as Resolvers } from "./contract-CCxPKIC7.js";
2
- import "./api-SwxtiYVU.js";
1
+ import { K as Resolvers } from "./contract-DJxGa8lb.js";
2
+ import "./api-H1TzWitc.js";
3
3
  //#region src/proxy.d.ts
4
4
  type ProxyFetch = Resolvers['cloud']['fetch'];
5
5
  type FetchParameters = Parameters<ProxyFetch>;
package/rooms.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-CCxPKIC7.js";
1
+ import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-DJxGa8lb.js";
2
2
  declare namespace rooms_d_exports {
3
3
  export { RoomClaimOptions as ClaimOptions, RoomCreateOptions as CreateOptions, RoomJoinOptions as JoinOptions, RoomOpenOptions as OpenOptions, Room, RoomBacklog, RoomDefaults, RoomEnd, RoomEvent, RoomMailbox, RoomMember, RoomMessage, RoomPermission, RoomPermissions, RoomsError, RoomsErrorCode, available, create, join, open };
4
4
  }
@@ -1 +0,0 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-CfdmsLoI.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./api--LOXTOpv.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CFK-KiwE.cjs"),o=require("./attach-policy.cjs"),s=require("./contract.cjs"),c=require("./dns.cjs"),l=require("./cloud/fs.cjs"),u=require("./net.cjs"),d=require("./dgram.cjs"),f=require("./http.cjs");let p=require("osra");var m=async()=>{let e=()=>r.s(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof r.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},h=`frame: this frame no longer holds the document the app attached it to`,g=!1,_=()=>{g||(g=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},v=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),y=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,b=e=>{let{assertLive:r,attach:i,consent:a,current:s,declaredHosts:c,documentHost:l,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(s()).hostname}catch{return``}},g=async()=>l?await l():m(),b=()=>n.t([...c,...v(f)]),x=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:s,phase:l})=>{r();let _=n.m(e,s);if(_===null)return;let v=t.m(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:c,approvedOrigins:f},l===`ensure`?void 0:s[0],{classifier:`fetchTarget`});if(l===`ensure`&&!d)throw t.D(e.kind===`refuse`?e.reason:``,`fetch`);if(l!==`ensure`&&e.kind===`refuse`)throw t.D(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.D(e.reason,`fetch`);if(!await i({scope:n.c(s[0],s[1]).scope,hosts:e.promptHosts}))throw t.D(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await g(),p=n.t([u,...c]);if(!p.length)throw t.D(`frame: navigate the frame before fetch`,`fetch`);if(await x(r,{category:`network`,hosts:p})===!1)throw t.D(y(`fetch`,`network`,u||null),`fetch`);return}let S=await g();if(!S)throw t.D(`frame: navigate the frame before ${e}`,e);if(!b().includes(S))throw t.D(h,e);let C=t.p(_);if(C===void 0||C===`evaluation`&&S===m()&&await u?.()||v===`critical`&&p.has(`${_} ${S}`))return;let{request:w}=await a();if(!w)return;let T=n.t([S,...c]),E=await x(w,v===`critical`?{key:_,hosts:T,attach:i}:{category:C,hosts:T});if(E===!1)throw t.D(y(e,C,null),e);if(E===`once`&&l!==`ensure`)for(let e of T)p.add(`${_} ${e}`)},requestCategories:async e=>{r(),t.d(`frame.requestPermissions`,e);let o=await g(),s=n.t(o?[o,...c]:c);if(!s.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let l=e.map(e=>{let n=e.key;return n===void 0?{named:void 0,critical:!1,category:e.category}:{named:n,critical:t.m(n)===`critical`,category:t.f(n)}}),u=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:s,allow:r}),{request:d}=await a();if(!d)return _(),l.map(e=>u(e,!1));let f=await d(l.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:s,attach:i}:{category:n,hosts:s}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:b}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,E=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.w(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},D=e=>Object.assign(Error(e),{name:t.T}),O=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,k=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,A=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,j=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,M=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,N=3e4,P=`frame.clearCookies: the render proxy did not answer within ${N}ms; the cookies may or may not be gone, and calling it again is safe`,F=e=>t.E(e)&&e.message===t.k(`addScriptTag`).message,I=!1,L=()=>{I||(I=!0,console.warn(`[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one.`))},R=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},z=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},B=({control:e,target:n,blank:r=!1,session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,guard:l,consent:u,onNavigated:d,relay:f})=>{let p=n,m=r&&i!==``,g=async()=>{if(!m)return!1;let t=typeof e.blank==`function`?await l(()=>e.blank()):``;return(typeof t!=`string`||t.split(`#`)[0]!==n.split(`#`)[0])&&(m=!1),m},_=Promise.resolve(),{gate:v,requestCategories:y,boundary:x}=b({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:z(u),freshBlank:g});return t.v({backend:`cloud`,executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.k(r,`cloud`)):(c(),l(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:v,requestPermissions:y,evaluate:async(n,r)=>(c(),await v({parts:[],operation:`evaluate`,args:[n,r],phase:`execute`}),E(l(()=>e.executeLocator([],`evaluate`,[n,r])),t.l,t.u)),addScriptTag:async(n,r)=>{c();let i=[n,r];await v({parts:[],operation:`addScriptTag`,args:i,phase:`execute`});try{await E(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,A)}catch(e){throw F(e)?t.j(k,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.j(j,`clearCookies`,`cloud`);if(x().length===0)throw t.D(M,`clearCookies`);await E(l(()=>e.clearCookies(n)),N,P)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.j(O,`postMessage`,`cloud`);if(r!==`*`&&!x().includes(new URL(r).hostname))throw t.D(h,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=_.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return _=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&L(),f(t)),goto:async(n,{timeout:r,...i}={})=>{let a=new URL(n,location.href).href;c(),m=!1;let s=(()=>{try{return new URL(a).origin}catch{return``}})(),u=s!==``&&!o.has(s);u&&o.add(s);try{await E(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw u&&o.delete(s),t.c(e)}p=a,d()},url:()=>p})},ee=250,te=500,ne=65e3,re=2e3,ie=2e3,ae=2,oe=2e3,se=2e3,ce=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);return a.searchParams.set(`attach`,i),t&&a.searchParams.set(`url`,t),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.href},V=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);return r.searchParams.set(`attach`,t),n.src=r.href,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`style`,`display:none`),(document.body??document.documentElement).appendChild(n),n},H=(e,t)=>{let n=new MutationObserver(()=>{e.isConnected||t.aborted||(n.disconnect(),console.warn(`cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},U=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),W=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),le=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),ue=()=>D(`cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window`),de=async(e,r)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:a=[],permissions:o}=e,{url:c,width:l,height:u}=t.s(e.window);if(window.origin===`null`)throw new t.g(`opaque-opener`);let d=w(),f=crypto.randomUUID(),m=T(r),h=n.t(a),g=new Set;c&&g.add(new URL(c).origin);let _=r===`persistent`?V(d,f):null,v=window.open(ce({origin:d,target:c,session:m,domains:h,attach:f}),`_blank`,`popup,width=${l},height=${u}`);if(!v)throw _?.remove(),new t.h;let y=new AbortController,b=!1,S=null,C=(e,t=!1)=>{if(S===null){S=e,y.abort(t?W():U());try{v.closed||v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:f,...t?{unanswered:t}:{}},d)}catch{}_&&setTimeout(()=>_.remove(),se)}};_&&H(_,y.signal);let D=new Promise((e,t)=>{y.signal.addEventListener(`abort`,()=>t(y.signal.reason),{once:!0})});D.catch(()=>{});let O=D.then(()=>{},()=>{}),k=()=>{if(y.signal.aborted)throw y.signal.reason},A=e=>y.signal.aborted?Promise.reject(y.signal.reason):Promise.race([e(),D]),j=e=>e.source===v&&e.origin===d;window.addEventListener(`message`,e=>{if(!j(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===f&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?C(new t.g(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&C(b?U():le()))},{signal:y.signal}),window.addEventListener(`pagehide`,()=>C(U()),{signal:y.signal});let M=()=>{try{v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:f},d)}catch{}};M();let N=setInterval(M,ee),P=setInterval(()=>{v.closed&&C(b?U():ue())},te);y.signal.addEventListener(`abort`,()=>{clearInterval(N),clearInterval(P)},{once:!0});let F=async e=>{try{return await Promise.race([e,D])}catch(e){throw S??e}};try{let e=await F(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>v.postMessage(e,d,t??[]),receive:e=>{let t=t=>{j(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:y.signal,revivableModules:x(t.ct)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));b=!0,clearInterval(N);let n=0,r=setInterval(()=>{E(A(()=>e.ping()),ie,`ping`).then(()=>{n=0},()=>{y.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=ae&&C(W(),!0))})},re);y.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await F(E(e.ready(),ne,`cloud.attachFrame: the window never became ready`));let a=i.t(`attached frame`);y.signal.aborted?a():y.signal.addEventListener(`abort`,a,{once:!0});let l=B({control:e,target:c,session:m,declaredHosts:h,approvedOrigins:g,attach:f,assertLive:k,guard:A,consent:{request:t=>A(()=>e.requestConsent(t)),ensure:t=>A(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:R({from:()=>v,origin:d,attach:f,signal:y.signal})}),u=null,_=Object.assign(l,{close:()=>u??=(async()=>{y.signal.aborted||await E(Promise.allSettled([A(()=>e.flushCookies()),A(()=>e.sweepStorage())]),oe,`close`).catch(()=>{});try{v.close()}catch{}C(U())})(),closed:O});return o?.length&&await F(_.requestPermissions(o)),_}catch(e){let n=S??e;if(!(n instanceof t.g))try{v.close()}catch{}throw C(n),n}},fe=2e4,G=65e3,K=e=>!e||e===`about:blank`,pe=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,me=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,q=e=>e.split(`#`)[0]??``,J=({iframe:e,lockdown:n,cookies:r,blank:i})=>{if(i===void 0)return``;if(typeof i!=`object`||!i)throw TypeError(`attachFrame: blank must be an object { url }`);let a=Object.keys(i).find(e=>e!==`url`);if(a!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${a}"`);let{url:o}=i,s=(()=>{try{return typeof o==`string`?new URL(o):null}catch{return null}})();if(!s||s.protocol!==`http:`&&s.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(o)}"`);let c=e.getAttribute(`src`)??``;if(!K(c))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${c}"`);if(n)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(r===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(t.b(s.href),!Se())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return s.href},he=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,w());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ge=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{(!e.isConnected||e.parentNode!==r)&&(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},_e=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),ve=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},ye=[300,1200,4e3],Y=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of ye)setTimeout(t,e)},X=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},be=async(e,n)=>{let r=typeof e.blank==`function`?await E(e.blank(),G,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||q(r)!==q(n))throw t.j(pe,`blank`,`cloud`)},xe=async(e,a)=>{let o=J(e),{iframe:c,domains:l=[],permissions:u}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!c.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);X(c);let d=c.getAttribute(`src`)??``,f=(()=>{if(K(d))return null;try{return new URL(c.src||d,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${d}`)}})();if(f){let e=new URL(`/attach-frame`,w());if(f.origin===e.origin&&f.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let h=f?.href??``;h&&t.b(h);let g=T(a),_=n.t(l),v=new Set;try{v.add(new URL(o||h).origin)}catch{}let y=new AbortController,b=c.referrerPolicy,S=c.allow,C=crypto.randomUUID();if(c.referrerPolicy=`origin`,c.allow=ve(r.m(),c.allow),c.src=he({target:h,blank:o,session:g,domains:_,attach:C}),!c.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:c.contentWindow},unregisterSignal:y.signal,revivableModules:x(t.ct)}),fe,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(e.ready(),G,`cloud.attachFrame: the render proxy never became ready`),o&&await be(e,o),(h||o)&&Y(c),ge(c,()=>y.abort());let n=i.t(`attached frame`);y.signal.aborted?n():y.signal.addEventListener(`abort`,n,{once:!0});let r=c.contentWindow,a=B({control:e,target:o||h,blank:o!==``,session:g,declaredHosts:_,approvedOrigins:v,attach:C,assertLive:()=>{if(y.signal.aborted||!c.isConnected||c.contentWindow!==r)throw y.abort(),_e()},guard:e=>e(),consent:m,onNavigated:()=>Y(c),relay:R({from:()=>r,origin:w(),attach:C,signal:y.signal})});return u?.length&&await a.requestPermissions(u),a}catch(e){throw y.abort(),c.referrerPolicy=b,c.allow=S,c.src=h||`about:blank`,e}},Z=(async e=>{let{kind:n,cookies:r}=t.o(e);if(r===`native`)throw TypeError(me);return n===`window`?de(e,r):xe(e,r)}),Se=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.o.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},Ce=e.t({attachFrame:()=>Z,available:()=>$,dgram:()=>d.t,dns:()=>c.t,fetch:()=>a.t,fs:()=>l.t,http:()=>f.t,net:()=>u.t,quota:()=>Q}),$=()=>r.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});