@banou/social 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +382 -2
- package/build/index.js +429 -0
- package/dist/index.d.mts +336 -0
- package/dist/index.mjs +284 -0
- package/dist/names.d.mts +14 -0
- package/dist/names.mjs +55 -0
- package/package.json +66 -4
package/build/index.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},r=`autoplay.fullscreen.picture-in-picture.encrypted-media.screen-wake-lock.speaker-selection.captured-surface-control.camera.microphone.display-capture.geolocation.midi.usb.serial.hid.bluetooth.gamepad.keyboard-map.xr-spatial-tracking.accelerometer.gyroscope.magnetometer.ambient-light-sensor.compute-pressure.clipboard-read.clipboard-write.storage-access.window-management.local-fonts.idle-detection.web-share.sync-xhr.unload.payment.publickey-credentials-get.publickey-credentials-create.otp-credentials.identity-credentials-get.digital-credentials-get.local-network.local-network-access.loopback-network`.split(`.`),i=()=>{try{let e=globalThis.document?.featurePolicy?.features?.();return e===void 0?void 0:new Set(e)}catch{return}},a=(e=!0,t=i())=>[...r,...e?[`cross-origin-isolated`]:[]].filter(e=>t===void 0||t.has(e)).join(`; `),o=`https://fkn.app`,s=e=>`${o}/api${e?`?coi=1`:``}`;`${JSON.stringify(r)}${JSON.stringify(s(!0))}${JSON.stringify(s(!1))}`;var c=Object.defineProperty,l=(e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:`Module`}),n},u=`__OSRA_KEY__`,d=`__OSRA_DEFAULT_KEY__`,f=`__OSRA_BOX__`,p=()=>globalThis.browser??globalThis.chrome,m=()=>p()?.runtime,h=(e,t)=>P(e)&&e.__OSRA_KEY__===t,g=(e,t)=>{if(e){if(e.aborted){t();return}e.addEventListener(`abort`,t,{once:!0})}},_=({listener:e,transport:t,remoteName:n,key:r=d,origin:i=`*`,unregisterSignal:a})=>{if(a?.aborted)return;let o=de(t)?t.receive:t;if(typeof o==`function`){let t=o((t,i)=>{a?.aborted||h(t,r)&&(n&&t.name!==n||e(t,i))});typeof t==`function`&&g(a,t);return}if(R(o)||z(o)||te(o)||ne(o)){let t=(t,i)=>{let o=(t,a)=>{h(t,r)&&(n&&t.name!==n||e(t,{port:i,sender:a}))};t.addListener(o),g(a,()=>t.removeListener(o))};if(R(o))t(o.onMessage);else if(te(o)){let e=e=>t(e.onMessage,e);o.addListener(e),g(a,()=>o.removeListener(e))}else ne(o)?t(o):t(o.onMessage);return}let s=M(o)?o.port:o,c=i!==`*`&&re(o),l=t=>{let a=t.data;if(typeof a==`string`)try{a=JSON.parse(a)}catch{return}h(a,r)&&(n&&a.name!==n||c&&t.origin&&t.origin!==i||e(a,{receiveTransport:o,source:t.source,origin:t.origin}))};s.addEventListener(`message`,l),s instanceof MessagePort&&s.start(),g(a,()=>s.removeEventListener(`message`,l))},v=new WeakSet,y=e=>String(e?.message??e).includes(`disconnected port`),b=(e,t,n=`*`,r=[])=>{let i=de(e)?e.emit:e;if(typeof i==`function`)i(t,r);else if(re(i))i.postMessage(t,n,r);else if(z(i)){if(v.has(i))return;try{i.postMessage(t)}catch(e){if(!y(e))throw e;v.add(i)}}else if(R(i))i.sendMessage(t)?.catch?.(e=>{if(!String(e?.message).includes(`Receiving end does not exist`))throw e});else if(D(i)){let e=JSON.stringify(t);i.readyState===WebSocket.CONNECTING?i.addEventListener(`open`,()=>i.send(e),{once:!0}):i.send(e)}else M(i)?i.port.postMessage(t,r):i.postMessage(t,r)},x=globalThis.Float16Array,S={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float16Array:x,Float32Array,Float64Array,BigInt64Array,BigUint64Array},C=Object.values(S),w=e=>{let t=e.constructor.name;if(t in S)return t;for(let[t,n]of Object.entries(S))if(n&&e instanceof n)return t;throw Error(`Unknown typed array type`)},T=e=>{let t=S[e];if(!t)throw Error(`Unknown typed array type`);return t},E=e=>F(e,C),D=e=>e instanceof WebSocket,O=e=>!!globalThis.ServiceWorkerContainer&&e instanceof ServiceWorkerContainer,k=e=>!!globalThis.ServiceWorker&&e instanceof ServiceWorker,A=e=>!!globalThis.Worker&&e instanceof Worker,j=e=>{let t=globalThis.DedicatedWorkerGlobalScope;return!!t&&e instanceof t},M=e=>!!globalThis.SharedWorker&&e instanceof SharedWorker,N=e=>e instanceof MessagePort,P=e=>!!e&&typeof e==`object`&&`__OSRA_KEY__`in e&&!!e.__OSRA_KEY__,F=(e,t)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return!1;for(let n of t)if(n&&e instanceof n)return!0;return!1},I=e=>F(e,[globalThis.SharedArrayBuffer]),L=e=>F(e,[globalThis.ArrayBuffer,globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.AudioData,globalThis.VideoFrame,globalThis.MediaSourceHandle,globalThis.MediaStreamTrack,globalThis.MIDIAccess,globalThis.RTCDataChannel,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream]),R=e=>{let t=m();return t?e===t:!1},z=(e,t=!1)=>!e||typeof e!=`object`||re(e)||!(`name`in e)||!(`disconnect`in e)||!(`postMessage`in e)?!1:!t||`sender`in e&&`onMessage`in e&&`onDisconnect`in e,ee=e=>!!e&&typeof e==`object`&&!re(e)&&`addListener`in e&&`hasListener`in e&&`removeListener`in e,te=e=>{let t=m();return t?e===t.onConnect||e===t.onConnectExternal:!1},ne=e=>ee(e),re=e=>{if(!e||typeof e!=`object`)return!1;try{return`window`in e&&e.window===e}catch{try{return`closed`in e&&typeof e.closed==`boolean`&&`close`in e&&typeof e.close==`function`}catch{return!1}}},ie=e=>D(e)||z(e)||R(e),B=e=>D(e)||z(e)||te(e)||ne(e)||R(e),ae=e=>!!e&&typeof e==`object`&&!re(e)&&`isJson`in e&&e.isJson===!0||ie(e)||B(e),oe=e=>re(e)||ie(e)||k(e)||A(e)||j(e)||M(e)||N(e)||le(e),se=e=>re(e)||B(e)||O(e)||A(e)||j(e)||M(e)||N(e)||ue(e),ce=e=>{if(!e||typeof e!=`object`||re(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},le=e=>!ce(e)||!(`emit`in e)?!1:oe(e.emit)||typeof e.emit==`function`,ue=e=>!ce(e)||!(`receive`in e)?!1:se(e.receive)||typeof e.receive==`function`,de=e=>le(e)||ue(e),fe=()=>globalThis.Buffer,pe=32768,me=e=>{let t=e.toBase64;if(typeof t==`function`)return t.call(e);let n=fe();if(n)return n.from(e).toString(`base64`);let r=``;for(let t=0;t<e.length;t+=pe)r+=String.fromCharCode(...e.subarray(t,t+pe));return btoa(r)},he=e=>{let t=Uint8Array.fromBase64;if(typeof t==`function`)return t(e);let n=fe();if(n)return new Uint8Array(n.from(e,`base64`));let r=atob(e),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i},V={[f]:`revivable`},ge=e=>!!e&&typeof e==`object`&&`__OSRA_BOX__`in e&&e.__OSRA_BOX__===`revivable`,_e=(e,t)=>ae(t.transport)?{base64Buffer:me(new Uint8Array(e))}:{arrayBuffer:e},ve=e=>`arrayBuffer`in e?e.arrayBuffer:he(e.base64Buffer).buffer,ye=l({box:()=>Se,isType:()=>xe,objectsOnly:()=>!0,revive:()=>Ce,type:()=>be}),be=`arrayBuffer`,xe=e=>e instanceof ArrayBuffer,Se=(e,t)=>({...V,type:be,..._e(e,t)}),Ce=(e,t)=>ve(e),we=l({box:()=>De,isType:()=>Ee,objectsOnly:()=>!0,revive:()=>Oe,type:()=>Te}),Te=`date`,Ee=e=>e instanceof Date,De=(e,t)=>({...V,type:Te,ISOString:e.toISOString()}),Oe=(e,t)=>new Date(e.ISOString),ke=l({box:()=>Me,isType:()=>je,objectsOnly:()=>!0,revive:()=>Ne,type:()=>Ae}),Ae=`headers`,je=e=>e instanceof Headers,Me=(e,t)=>({...V,type:Ae,entries:[...e.entries()]}),Ne=(e,t)=>new Headers(e.entries),Pe=l({box:()=>Re,isType:()=>Le,objectsOnly:()=>!0,revive:()=>ze,type:()=>Fe}),Fe=`error`,Ie={Error,TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError},Le=e=>e instanceof Error,Re=(e,t)=>{let n=`cause`in e&&e.cause!==void 0,r=typeof AggregateError<`u`&&e instanceof AggregateError,i=typeof DOMException<`u`&&e instanceof DOMException;return{...V,type:Fe,name:e.name,message:e.message,stack:e.stack||e.toString(),...n?{cause:ii(e.cause,t)}:{},...r?{errors:ii(e.errors,t)}:{},...i?{isDOMException:!0}:{}}},ze=(e,t)=>{let n=e.cause===void 0?void 0:oi(e.cause,t),r=n===void 0?void 0:{cause:n};if(e.isDOMException&&typeof DOMException<`u`){let t=new DOMException(e.message,e.name);if(e.stack)try{Object.defineProperty(t,"stack",{value:e.stack,configurable:!0})}catch{}return t}let i;if(e.errors!==void 0&&typeof AggregateError<`u`)i=AggregateError(oi(e.errors,t),e.message,r);else{let t=Ie[e.name]??Error;i=r===void 0?new t(e.message):new t(e.message,r)}return e.name&&i.name!==e.name&&(i.name=e.name),e.stack&&(i.stack=e.stack),i},Be=l({box:()=>Ue,isType:()=>He,objectsOnly:()=>!0,revive:()=>We,type:()=>Ve}),Ve=`typedArray`,He=E,Ue=(e,t)=>{let n=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return{...V,type:Ve,typedArrayType:w(e),..._e(n,t)}},We=(e,t)=>new(T(e.typedArrayType))(ve(e)),Ge=new WeakMap,Ke=new WeakSet,qe=(e,t)=>{if(Ke.has(e))return t(),()=>{};let n=Ge.get(e);return n||Ge.set(e,n=new Set),n.add(t),()=>n.delete(t)},Je=e=>Ke.has(e),Ye=e=>{if(Ke.has(e))return;Ke.add(e);let t=Ge.get(e);if(t){Ge.delete(e);for(let e of t)try{e()}catch{}}},Xe=l({box:()=>ct,forceTransfer:()=>at,isInTransfer:()=>it,isType:()=>st,objectsOnly:()=>!0,outsideTransfer:()=>ot,revive:()=>lt,transfer:()=>nt,type:()=>Ze}),Ze=`transfer`,Qe=Symbol.for(`osra.transfer`),$e=e=>typeof e==`object`&&!!e,et=e=>$e(e)&&Qe in e&&e[Qe]===!0,tt=e=>$e(e)?ArrayBuffer.isView(e)?!0:F(e,[globalThis.ArrayBuffer,globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.Request,globalThis.Response,globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.VideoFrame,globalThis.AudioData]):!1,nt=e=>tt(e)?{[Qe]:!0,value:e}:e,rt=0,it=()=>rt>0,at=e=>$e(e)&&!et(e)?{[Qe]:!0,value:e}:e,ot=e=>{let t=rt;rt=0;try{return e()}finally{rt=t}},st=e=>et(e),ct=(e,t)=>{rt++;try{return{...V,type:Ze,inner:ii(e.value,t),degraded:ae(t.transport)}}finally{rt--}},lt=(e,t)=>oi(e.inner,t),ut=e=>F(e,[globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.OffscreenCanvas,globalThis.MediaSourceHandle,globalThis.MediaStreamTrack,globalThis.MIDIAccess,globalThis.RTCDataChannel,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream]),dt=e=>ge(e)&&e.type===`transfer`,ft=e=>{let t=[],n=new WeakSet,r=(e,i)=>{if(e&&typeof e==`object`&&!n.has(e)&&(n.add(e),!I(e))){if(dt(e)){r(e.inner,i||!e.degraded);return}if(ut(e)){t.push(e);return}if(L(e)){i&&t.push(e);return}if(ArrayBuffer.isView(e)){i&&e instanceof DataView&&!I(e.buffer)&&!n.has(e.buffer)&&(n.add(e.buffer),t.push(e.buffer));return}if(Array.isArray(e)){for(let t of e)r(t,i);return}for(let t of Object.values(e))r(t,i)}};return r(e,!1),t},pt=class{_listeners=new Map;addEventListener(e,t,n){if(!t)return;let r=this._listeners.get(e);r||(r=new Map,this._listeners.set(e,r)),r.has(t)||r.set(t,typeof n==`object`&&!!n?.once)}removeEventListener(e,t,n){t&&this._listeners.get(e)?.delete(t)}_peer;_queue=[];_started=!1;_closed=!1;_onClose;_onmessage=null;get onmessage(){return this._onmessage}set onmessage(e){this._onmessage=e,e!==null&&this.start()}onmessageerror=null;dispatchEvent(e){e.type===`message`?this._onmessage?.call(this,e):e.type===`messageerror`&&this.onmessageerror?.call(this,e);let t=this._listeners.get(e.type);if(t)for(let[n,r]of[...t])r&&t.delete(n),typeof n==`function`?n.call(this,e):n.handleEvent(e);return!0}postMessage(e,t){let n=this._peer;n&&!n._closed&&queueMicrotask(()=>{if(n._closed)return;let t=new MessageEvent(`message`,{data:e});n._started?n.dispatchEvent(t):n._queue.push(t)})}start(){if(!this._started){this._started=!0;for(let e of this._queue.splice(0))this.dispatchEvent(e)}}close(){if(this._closed)return;this._closed=!0,this._queue.length=0,this._onClose?.();let e=this._peer;e&&!e._closed&&queueMicrotask(()=>{e._closed||e.dispatchEvent(new Event(`close`))})}},mt=class{port1;port2;constructor(){let e=new pt,t=new pt;e._peer=t,t._peer=e,this.port1=e,this.port2=t}},ht=new FinalizationRegistry(e=>{try{e()}catch{}}),gt=(e,t)=>{let n={};return ht.register(e,t,n),()=>ht.unregister(n)},_t=l({box:()=>zt,createRevivableChannel:()=>Wt,init:()=>kt,isType:()=>At,markPortsShipped:()=>Ht,objectsOnly:()=>!0,postPreBoxed:()=>Lt,revive:()=>Bt,type:()=>vt}),vt=`messagePort`,yt=2048,bt=128,xt=1024,St=new WeakMap,Ct=e=>{let t=St.get(e);if(!t)throw Error(`osra message-port: connection state missing; did init() run?`);return t},wt=(e,t)=>{let n=e.ports.get(t);return n||(n={nextSeq:0,buffer:new Map,outSeq:0},e.ports.set(t,n),e.pendingPorts++),n},Tt=(e,t)=>{let n=e.ports.get(t);if(n&&!n.handler&&e.pendingPorts--,e.ports.delete(t),e.tombstones.size>=bt){let t=e.tombstones.values().next().value;t!==void 0&&e.tombstones.delete(t)}e.tombstones.add(t)},Et=e=>{if(e.handler)for(let t=e.buffer.get(e.nextSeq);t!==void 0;t=e.buffer.get(e.nextSeq))e.buffer.delete(e.nextSeq),e.nextSeq++,e.handler(t)},Dt=(e,t)=>wt(Ct(e),t).outSeq++,Ot=(e,t,n)=>{let r=Ct(e);if(r.tombstones.has(t)){setTimeout(()=>n({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:t}));return}let i=wt(r,t);i.handler||r.pendingPorts--,i.handler=n,Et(i)},kt=e=>{let t={ports:new Map,tombstones:new Set,pendingPorts:0};St.set(e,t),e.eventTarget.addEventListener(`message`,({detail:n})=>{if(n.type!==`message`&&n.type!==`message-port-close`||t.tombstones.has(n.portId))return;let r=t.ports.get(n.portId);if(n.seq===void 0){r?.handler?.(n);return}if(!r){if(t.pendingPorts>=xt)return;r=wt(t,n.portId)}if(!(n.seq<r.nextSeq)){if(r.buffer.size>=yt&&!(n.seq===r.nextSeq&&r.handler)){r.buffer.clear(),Tt(t,n.portId),r.handler?.({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:n.portId});return}r.buffer.set(n.seq,n),Et(r)}}),qe(e,()=>{for(let[n,r]of[...t.ports])r.handler?.({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:n});t.ports.clear(),t.tombstones.clear(),t.pendingPorts=0})},At=e=>e instanceof MessagePort||e instanceof pt,jt=(e,t)=>{try{let n=Ct(e).ports.get(t);e.sendMessage({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:t,seq:n?n.outSeq++:0})}catch{}},Mt=(e,t,n)=>{if(n){e.postMessage(t);return}let r=ft(t);e.postMessage(t,r),Ht(r)},Nt=(e,t,n,r)=>{let i;try{i=oi(e,t)}catch(e){r(),globalThis.reportError?.(e);return}n(i)},Pt=(e,t,n)=>()=>{let r=e.deref();r&&jt(r,n);let i=t.deref();i&&Tt(i,n)},Ft=new WeakSet,It=e=>e!==null&&(typeof e==`object`||typeof e==`function`),Lt=(e,t,n)=>{It(t)&&Ft.add(t),e.postMessage(t,n??[])},Rt=(e,t)=>It(e)&&Ft.delete(e)?e:ot(()=>ii(e,t)),zt=(e,t,n)=>{let r=e instanceof pt;if(!r&&!ae(t.transport))return{...V,type:vt,port:e,...n?.autoBox?{autoBox:!0}:{}};let i=Ct(t),a=e,o=globalThis.crypto.randomUUID(),s=new WeakRef(a),c=new WeakRef(t),l=new WeakRef(i),u=!1,d=()=>{if(u)return;u=!0;let e=l.deref();e&&Tt(e,o),m?.();let t=s.deref();t?.removeEventListener(`message`,p),t instanceof pt&&(t._onClose=void 0)},f=e=>{if(e.type===`message-port-close`){d(),a.dispatchEvent(new Event(`close`)),a.close();return}Nt(e.data,t,e=>Mt(a,e,!1),()=>{})};function p({data:e}){t.sendMessage({type:`message`,remoteUuid:t.remoteUuid,data:Rt(e,t),portId:o,seq:Dt(t,o)})}let m=gt(a,Pt(c,l,o));return a.addEventListener(`message`,p),a.start(),a instanceof pt&&(a._onClose=()=>{u||(jt(t,o),d())}),Ot(t,o,f),{...V,type:vt,portId:o,synthetic:r}},Bt=(e,t)=>`port`in e?(Ht([e.port]),e.autoBox?Ut(e.port,t):e.port):Gt(e.portId,t,e.synthetic),Vt=new WeakMap,Ht=e=>{for(let t of e){let e=Vt.get(t);if(e){Vt.delete(t),e.shipped=!0;for(let t of e.pending.splice(0))t()}}},Ut=(e,t,n)=>{let r=new EventTarget,i=({data:e})=>{Nt(e,t,e=>r.dispatchEvent(new MessageEvent(`message`,{data:e})),()=>r.dispatchEvent(new Event(`messageerror`)))},a=()=>{r.dispatchEvent(new Event(`messageerror`))},o=()=>{r.dispatchEvent(new Event(`close`))};e.addEventListener(`message`,i),e.addEventListener(`messageerror`,a),e.addEventListener(`close`,o),r.postMessage=(r,i)=>{let a=ot(()=>ii(r,t)),o=ft(a),s=Array.isArray(i)?i:[],c=s.length?[...o,...s]:o,l=()=>{e.postMessage(a,c),Ht(c)};if(n&&!n.shipped){n.pending.push(l);return}l()},r.start=()=>e.start();let s=()=>{e.removeEventListener(`message`,i),e.removeEventListener(`messageerror`,a),e.removeEventListener(`close`,o),e.close()};return r.close=()=>{if(n&&!n.shipped){n.pending.push(s);return}s()},r},Wt=e=>{if(ae(e.transport)){let{port1:t,port2:n}=new mt;return{localPort:t,boxedRemote:zt(n,e)}}let{port1:t,port2:n}=new MessageChannel,r={shipped:!1,pending:[]};return Vt.set(n,r),{localPort:Ut(t,e,r),boxedRemote:zt(n,e,{autoBox:!0})}},Gt=(e,t,n)=>{let r=Ct(t),{port1:i,port2:a}=n?new mt:new MessageChannel,o=new WeakRef(i),s=new WeakRef(a),c=!1,l=!1;i instanceof pt||i.addEventListener(`close`,e=>{l&&e.stopImmediatePropagation()});let u=()=>{if(c)return;c=!0,Tt(r,e);let t=s.deref();t?.removeEventListener(`message`,f),t?.close(),p?.()},d=e=>{if(e.type===`message-port-close`){u();let e=o.deref();e?.dispatchEvent(new Event(`close`)),l=!0,e?.close();return}if(!o.deref()){u();return}let r=s.deref();r&&Nt(e.data,t,e=>Mt(r,e,n),()=>o.deref()?.dispatchEvent(new Event(`messageerror`)))},f=({data:n})=>{t.sendMessage({type:`message`,remoteUuid:t.remoteUuid,data:Rt(n,t),portId:e,seq:Dt(t,e)})},p=gt(i,()=>{jt(t,e),u()});return i instanceof pt&&(i._onClose=()=>{c||(jt(t,e),u())}),a.addEventListener(`message`,f),a.start(),Ot(t,e,d),i},Kt=l({box:()=>Zt,isType:()=>Xt,objectsOnly:()=>!0,revive:()=>Qt,type:()=>qt}),qt=`promise`,Jt=e=>e instanceof Promise,Yt=new Set,Xt=e=>e instanceof Promise,Zt=(e,t)=>{if(!Jt(e))throw TypeError(`Expected Promise`);let{localPort:n,boxedRemote:r}=Wt(t),i=e=>{n.postMessage(e),n.close()};return e.then(e=>i({type:`resolve`,data:e})).catch(e=>i({type:`reject`,error:e})),{...V,type:qt,port:r}},Qt=(e,t)=>{let n=Bt(e.port,t);Yt.add(n);let r=`portId`in e.port;return new Promise((e,i)=>{let a,o=()=>{n.close(),Yt.delete(n),a?.()};if(r&&Je(t)){i(Error(`osra: connection closed`)),o();return}a=r?qe(t,()=>{i(Error(`osra: connection closed`)),o()}):void 0,n.addEventListener(`message`,({data:t})=>{t.type===`resolve`?e(t.data):i(t.error),o()},{once:!0}),n.start()})},$t=l({box:()=>an,isType:()=>rn,objectsOnly:()=>!0,revive:()=>on,type:()=>en}),en=`function`,tn=new Set,nn=e=>{e instanceof ReadableStream?e.locked||e.cancel(Error(`osra: connection closed`)).catch(()=>{}):typeof WritableStream<`u`&&e instanceof WritableStream&&(e.locked||e.abort(Error(`osra: connection closed`)).catch(()=>{}))},rn=e=>typeof e==`function`,an=(e,t)=>{let{port1:n,port2:r}=new mt;return n.addEventListener(`message`,({data:n})=>{let[r,i]=n;(async()=>{let n;try{n={type:`return`,value:await e(...i)}}catch(e){n={type:`throw`,error:e}}if(Je(t)){n.type===`return`&&nn(n.value);try{r.close()}catch{}return}let a=(()=>{try{return ii(n,t)}catch(e){return ii({type:`throw`,error:e},t)}})();Lt(r,a),queueMicrotask(()=>{try{r.close()}catch{}})})()}),n.start(),{...V,type:en,port:zt(r,t)}},on=(e,t)=>{let n=Bt(e.port,t);return((...e)=>new Promise((r,i)=>{if(Je(t)){i(Error(`osra: connection closed`));return}let{port1:a,port2:o}=new mt;tn.add(a);let s,c=()=>{a.close(),tn.delete(a),s?.()};s=qe(t,()=>{i(Error(`osra: connection closed`)),c()}),a.addEventListener(`message`,({data:e})=>{let t=e;t.type===`return`?r(t.value):i(t.error),c()},{once:!0}),a.start();let l=ot(()=>ii([o,e],t));Lt(n,l)}))},sn=l({MAX_CREDIT_WINDOW:()=>64,box:()=>pn,isType:()=>ln,objectsOnly:()=>!0,revive:()=>_n,type:()=>cn}),cn=`readableStream`,ln=e=>e instanceof ReadableStream,un=2,dn=8,fn=4194304,pn=(e,t)=>{let{localPort:n,boxedRemote:r}=Wt(t),i=e.getReader(),a=it(),o=0,s=!1,c=!1,l=e=>{c=!0;try{n.postMessage(e)}catch{}n.close()},u=async()=>{if(!(s||c)){for(s=!0;o>0;){let e;try{e=await i.read()}catch(e){c||l({type:`error`,error:e});return}if(c)return;if(e.done){l({type:`end`});return}o--;let t=a?at(e.value):e.value;try{n.postMessage({type:`chunk`,value:t})}catch(e){l({type:`error`,error:e}),i.cancel(e).catch(()=>{});return}}s=!1}};return n.addEventListener(`message`,({data:e})=>{e instanceof Promise||!(`type`in e)||(e.type===`pull`?n.postMessage(i.read()):e.type===`credit`?(o+=e.n,u()):e.type===`cancel`&&(c=!0,i.cancel(e.reason).catch(()=>{}),n.close()))}),n.addEventListener(`close`,()=>{c||(c=!0,i.cancel(Error(`osra: connection closed`)).catch(()=>{}))},{once:!0}),n.start(),{...V,type:cn,credit:!0,port:r}},mn=e=>ArrayBuffer.isView(e)||e instanceof ArrayBuffer?e.byteLength:typeof e==`string`?e.length*2:typeof Blob<`u`&&e instanceof Blob?e.size:void 0,hn=e=>{let t=!1,n=0,r,i=[],a=!1,o=!1,s,c,l=()=>r===void 0?dn:Math.max(un,Math.min(64,Math.floor(fn/r))),u=()=>{let t=l(),r=n+i.length;if(r>t/2)return;let a=t-r;n+=a,e.postMessage({type:`credit`,n:a})},d=()=>{t=!0,queueMicrotask(()=>e.close())},f=e=>{if(o=!0,s=e,!c||i.length)return;let t=c;c=void 0,d(),t.reject(e)};return new ReadableStream({start:()=>{e.addEventListener(`message`,({data:o})=>{if(!(o instanceof Promise||!(`type`in o))){if(o.type===`chunk`){if(t)return;if(n<=0){i.length=0,f(Error(`osra: stream exceeded its credit window`)),queueMicrotask(()=>e.close());return}n--;let a=mn(o.value);if(a!==void 0&&(r=r===void 0?a:r*.875+a*.125),c){let e=c;c=void 0,e.controller.enqueue(o.value),e.resolve()}else i.push(o.value)}else if(o.type===`end`){if(t||(a=!0,!c||i.length))return;let e=c;c=void 0,d(),e.controller.close(),e.resolve()}else if(o.type===`error`){if(t)return;f(o.error)}}}),e.addEventListener(`messageerror`,()=>{t||f(Error(`osra: a chunk failed to deserialize on this platform`))}),e.addEventListener(`close`,()=>{t||a||o||f(Error(`osra: connection closed`))},{once:!0})},pull:e=>{if(!t){if(i.length){e.enqueue(i.shift()),!a&&!o&&u();return}if(o)return d(),Promise.reject(s);if(a){d(),e.close();return}return u(),new Promise((t,n)=>{c={controller:e,resolve:t,reject:n}})}},cancel:n=>{t=!0,i.length=0;let r=c;c=void 0,r?.resolve(),e.postMessage({type:`cancel`,reason:n}),queueMicrotask(()=>e.close())}})},gn=e=>{let t=!1;return new ReadableStream({start:n=>{e.addEventListener(`messageerror`,()=>{if(!t){t=!0;try{n.error(Error(`osra: a chunk failed to deserialize on this platform`))}catch{}queueMicrotask(()=>e.close())}}),e.addEventListener(`close`,()=>{if(!t){t=!0;try{n.error(Error(`osra: connection closed`))}catch{}}},{once:!0})},pull:n=>new Promise((r,i)=>{e.addEventListener(`message`,({data:a})=>{a instanceof Promise&&a.then(i=>{i.done?(t=!0,n.close(),e.postMessage({type:`cancel`}),queueMicrotask(()=>e.close())):n.enqueue(i.value),r()}).catch(e=>{t=!0,i(e)})},{once:!0}),e.postMessage({type:`pull`})}),cancel:n=>{t=!0,e.postMessage({type:`cancel`,reason:n}),queueMicrotask(()=>e.close())}})},_n=(e,t)=>{let n=Bt(e.port,t);return n.start(),e.credit?hn(n):gn(n)},vn=l({box:()=>xn,isType:()=>bn,objectsOnly:()=>!0,revive:()=>Sn,type:()=>yn}),yn=`writableStream`,bn=e=>e instanceof WritableStream,xn=(e,t)=>{let{localPort:n,boxedRemote:r}=Wt(t),i=e.getWriter(),a=!1,o=(e,t)=>e.then(()=>n.postMessage({type:`ack`})).catch(e=>n.postMessage({type:`err`,error:e?.message??String(e)})).then(()=>{t&&(a=!0,queueMicrotask(()=>n.close()))});return n.addEventListener(`message`,({data:e})=>{e&&typeof e==`object`&&`type`in e&&(e.type===`write`?o(i.write(e.chunk),!1):e.type===`close`?o(i.close(),!0):e.type===`abort`&&o(i.abort(e.reason),!0))}),n.addEventListener(`messageerror`,()=>{n.postMessage({type:`err`,error:`osra: a chunk failed to deserialize on this platform`})}),n.addEventListener(`close`,()=>{a||(a=!0,i.abort(Error(`osra: connection closed`)).catch(()=>{}))},{once:!0}),n.start(),{...V,type:yn,port:r,...it()?{transferChunks:!0}:{}}},Sn=(e,t)=>{let n=Bt(e.port,t);n.start();let r=new Set,i=!1;n.addEventListener(`close`,()=>{i=!0;let e=Error(`osra: connection closed`);for(let t of[...r])t(e);r.clear()},{once:!0});let a=Promise.resolve(),o=e=>{let t=a.then(()=>new Promise((t,a)=>{if(i){a(Error(`osra: connection closed`));return}let o=e=>{r.delete(a),e()};r.add(a),n.addEventListener(`message`,({data:e})=>{e&&typeof e==`object`&&`type`in e&&(e.type===`ack`?o(t):e.type===`err`&&o(()=>a(Error(e.error))))},{once:!0}),n.postMessage(e)}));return a=t.catch(()=>{}),t},s=e.transferChunks===!0;return new WritableStream({write:e=>o({type:`write`,chunk:s?at(e):e}),close:()=>o({type:`close`}),abort:e=>o({type:`abort`,reason:e})})},Cn=l({box:()=>Dn,isType:()=>Tn,objectsOnly:()=>!0,revive:()=>On,type:()=>wn}),wn=`abortSignal`,Tn=e=>e instanceof AbortSignal,En=new WeakMap,Dn=(e,t)=>{if(e.aborted)return{...V,type:wn,aborted:!0,reason:ii(e.reason,t)};let{localPort:n,boxedRemote:r}=Wt(t),i=()=>{n.postMessage({type:`abort`,reason:e.reason}),n.close(),a()},a=qe(t,()=>{e.removeEventListener(`abort`,i),n.close()});return e.addEventListener(`abort`,i,{once:!0}),{...V,type:wn,aborted:!1,reason:void 0,port:r}},On=(e,t)=>{let n=new AbortController;if(e.aborted||e.port===void 0)return n.abort(oi(e.reason,t)),n.signal;let r=Bt(e.port,t);return En.set(n.signal,r),r.start(),r.addEventListener(`message`,({data:e})=>{e.type===`abort`&&(n.abort(oi(e.reason,t)),En.delete(n.signal),r.close())}),n.signal},kn=l({box:()=>Mn,isType:()=>jn,objectsOnly:()=>!0,revive:()=>Nn,type:()=>An}),An=`response`,jn=e=>e instanceof Response,Mn=(e,t)=>({...V,type:An,status:e.status,statusText:e.statusText,headers:Me(e.headers,t),body:e.body?pn(e.body,t):null,url:e.url,redirected:e.redirected}),Nn=(e,t)=>{if(e.status===0)return Response.error();let n=Ne(e.headers,t),r=e.body?_n(e.body,t):null,i=e.status===101||e.status===204||e.status===205||e.status===304;r&&i&&r.cancel().catch(()=>{});let a=new Response(i?null:r,{status:e.status,statusText:e.statusText,headers:n});return e.url&&Object.defineProperty(a,"url",{value:e.url,configurable:!0}),e.redirected&&Object.defineProperty(a,"redirected",{value:!0,configurable:!0}),a},Pn=l({box:()=>Ln,isType:()=>In,objectsOnly:()=>!0,revive:()=>Rn,type:()=>Fn}),Fn=`request`,In=e=>e instanceof Request,Ln=(e,t)=>({...V,type:Fn,method:e.method,url:e.url,headers:Me(e.headers,t),body:e.body?pn(e.body,t):null,credentials:e.credentials,cache:e.cache,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,integrity:e.integrity,keepalive:e.keepalive,signal:Dn(e.signal,t)}),Rn=(e,t)=>{let n=Ne(e.headers,t),r={method:e.method,headers:n,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,integrity:e.integrity,keepalive:e.keepalive,signal:On(e.signal,t)};return e.mode!==`navigate`&&(r.mode=e.mode),e.body&&(r.body=_n(e.body,t),r.duplex=`half`),new Request(e.url,r)},zn=l({box:()=>Zn,boxByReference:()=>Qn,identity:()=>Gn,isType:()=>Jn,objectsOnly:()=>!0,revive:()=>$n,type:()=>Bn}),Bn=`identity`,Vn=e=>e!==null&&(typeof e==`object`||typeof e==`function`),Hn=e=>{if(e===null)return!1;let t=typeof e;return t===`object`||t===`function`||t===`symbol`&&Symbol.keyFor(e)===void 0},Un=new WeakMap,Wn=e=>{let t=Un.get(e);if(t!==void 0)return t;let n=globalThis.crypto.randomUUID();return Un.set(e,n),n},Gn=e=>(Vn(e)&&Wn(e),e),Kn=new WeakMap,qn=e=>{let t=Kn.get(e);if(t)return t;let n=new Map,r={idToLocal:n,pins:new Map,aliasIds:new WeakMap,disposeRegistry:new FinalizationRegistry(t=>{if(n.delete(t),!Je(e))try{e.sendMessage({type:`identity-dispose`,remoteUuid:e.remoteUuid,id:t})}catch{}})};return Kn.set(e,r),e.eventTarget.addEventListener(`message`,({detail:e})=>{e?.type===`identity-dispose`&&(r.pins.delete(e.id),r.idToLocal.delete(e.id))}),qe(e,()=>{r.pins.clear(),r.idToLocal.clear()}),r},Jn=e=>Vn(e)&&Un.has(e),Yn=(e,t)=>{let n=t.aliasIds.get(e);if(n!==void 0)return n;let r=Wn(e),i=t.idToLocal.get(r);if(i===void 0||i.deref()===e)return r;let a=globalThis.crypto.randomUUID();return t.aliasIds.set(e,a),a},Xn=(e,t,n)=>{let r=Yn(e,n);if(n.idToLocal.has(r))return{...V,type:Bn,id:r};let i=t();return n.idToLocal.set(r,new WeakRef(e)),n.disposeRegistry.register(e,r,e),Qr(()=>{},()=>{n.idToLocal.delete(r),n.disposeRegistry.unregister(e)}),{...V,type:Bn,id:r,inner:i}},Zn=(e,t)=>{let n=qn(t),r=()=>ai(e,t,Bn);return Hn(e)?Xn(e,r,n):{...V,type:Bn,id:globalThis.crypto.randomUUID(),inner:r()}},Qn=(e,t,n)=>Xn(e,()=>t,qn(n)),$n=(e,t)=>{let n=qn(t);if(n.pins.has(e.id))return n.pins.get(e.id);let r=n.idToLocal.get(e.id)?.deref();if(r!==void 0)return r;if(!(`inner`in e)||e.inner===void 0){try{t.sendMessage({type:`identity-dispose`,remoteUuid:t.remoteUuid,id:e.id})}catch{}throw Error(`osra identity: received id=${e.id} with no inner payload and nothing local to resolve it to`)}let i=oi(e.inner,t);return n.pins.set(e.id,i),Hn(i)&&(Un.has(i)||Un.set(i,e.id),n.idToLocal.set(e.id,new WeakRef(i))),i},er=l({box:()=>nr,isType:()=>tr,objectsOnly:()=>!0,revive:()=>rr,type:()=>`map`}),tr=e=>e instanceof Map,nr=(e,t)=>({...V,type:`map`,entries:Array.from(e,([e,n])=>[ii(e,t),ii(n,t)])}),rr=(e,t)=>new Map(e.entries.map(([e,n])=>[oi(e,t),oi(n,t)])),ir=l({box:()=>or,isType:()=>ar,objectsOnly:()=>!0,revive:()=>sr,type:()=>`set`}),ar=e=>e instanceof Set,or=(e,t)=>({...V,type:`set`,values:Array.from(e,e=>ii(e,t))}),sr=(e,t)=>new Set(e.values.map(e=>oi(e,t))),cr=l({box:()=>dr,isType:()=>ur,revive:()=>fr,type:()=>lr}),lr=`bigint`,ur=e=>typeof e==`bigint`,dr=(e,t)=>({...V,type:lr,value:e.toString()}),fr=(e,t)=>BigInt(e.value),pr=l({box:()=>gr,isType:()=>hr,objectsOnly:()=>!0,revive:()=>_r,type:()=>mr}),mr=`event`,hr=e=>e instanceof Event,gr=(e,t)=>({...V,type:mr,eventType:e.type,bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed,...e instanceof CustomEvent?{detail:ii(e.detail,t)}:{}}),_r=(e,t)=>{let n={bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed};return`detail`in e?new CustomEvent(e.eventType,{...n,detail:oi(e.detail,t)}):new Event(e.eventType,n)},vr=l({box:()=>xr,isType:()=>br,objectsOnly:()=>!0,revive:()=>Tr,type:()=>yr}),yr=`eventTarget`,br=e=>e instanceof EventTarget,xr=(e,t)=>{let n=[],r=e=>typeof e==`boolean`?e:!!e?.capture;return{...V,type:yr,addListener:an((t,i,a)=>{n.push({eventType:t,listener:i,capture:r(a)}),e.addEventListener(t,i,a)},t),removeListener:an((t,i,a)=>{let o=r(a),s=n.findIndex(e=>e.eventType===t&&e.listener===i&&e.capture===o);s!==-1&&n.splice(s,1),e.removeEventListener(t,i,a)},t),removeAllListeners:an(()=>{for(let{eventType:t,listener:r,capture:i}of n.splice(0))e.removeEventListener(t,r,{capture:i})},t)}},Sr=new WeakMap,Cr=e=>{if(typeof e==`function`)return e;let t=Sr.get(e);return t||Sr.set(e,t=t=>e.handleEvent(t)),t},wr=(e,t,n,r)=>e.find(e=>e.eventType===t&&e.listener===n&&e.capture===r),Tr=(e,t)=>{let n=on(e.addListener,t),r=on(e.removeListener,t),i=on(e.removeAllListeners,t),a=new EventTarget,o=[],s=e=>{let t=o.indexOf(e);t!==-1&&o.splice(t,1)};return Object.defineProperty(a,"addEventListener",{value:(e,t,r)=>{if(t===null)return;let i=Cr(t),a=typeof r==`boolean`?r:!!r?.capture;if(wr(o,e,i,a))return;let c=typeof r==`object`&&r?.once?e=>(s(l),i(e)):i,l={eventType:e,listener:i,capture:a,wire:c};o.push(l),(typeof r==`object`?r?.signal:void 0)?.addEventListener(`abort`,()=>s(l),{once:!0}),n(e,Gn(c),r).catch(()=>{})}}),Object.defineProperty(a,"removeEventListener",{value:(e,t,n)=>{if(t===null)return;let i=Cr(t),a=typeof n==`boolean`?n:!!n?.capture,c=wr(o,e,i,a);c&&(s(c),r(e,Gn(c.wire),{capture:a}).catch(()=>{}))}}),gt(a,()=>{i().catch(()=>{})}),a},Er=l({box:()=>kr,isType:()=>Or,revive:()=>Ar,type:()=>Dr}),Dr=`symbol`,Or=e=>typeof e==`symbol`,kr=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?Qn(e,{...V,type:Dr,description:e.description},t):{...V,type:Dr,registryKey:n}},Ar=(e,t)=>`registryKey`in e?Symbol.for(e.registryKey):Symbol(e.description),jr=l({box:()=>Pr,isType:()=>Nr,objectsOnly:()=>!0,revive:()=>Fr,type:()=>Mr}),Mr=`asyncIterator`,Nr=e=>!e||typeof e!=`object`||typeof ReadableStream<`u`&&e instanceof ReadableStream?!1:typeof e[Symbol.asyncIterator]==`function`,Pr=(e,t)=>{let n=e[Symbol.asyncIterator]();return{...V,type:Mr,next:an((e=>n.next(e)),t),return:an((e=>n.return?.(e)??Promise.resolve({done:!0,value:e})),t),throw:an((e=>n.throw?.(e)??Promise.reject(e)),t)}},Fr=(e,t)=>{let n=on(e.next,t),r=on(e.return,t),i=on(e.throw,t),a={next:(...e)=>n(...e),return:e=>r(e),throw:e=>i(e),[Symbol.asyncIterator]:()=>a};return a},Ir=[globalThis.File,globalThis.FileList,globalThis.RegExp,globalThis.DataView,globalThis.ImageData,globalThis.FormData,globalThis.DOMException,globalThis.DOMMatrix,globalThis.DOMMatrixReadOnly,globalThis.DOMPoint,globalThis.DOMPointReadOnly,globalThis.DOMQuad,globalThis.DOMRect,globalThis.DOMRectReadOnly,globalThis.CryptoKey,globalThis.FileSystemHandle,globalThis.FileSystemFileHandle,globalThis.FileSystemDirectoryHandle,globalThis.RTCCertificate],Lr=[globalThis.CropTarget,globalThis.EncodedAudioChunk,globalThis.EncodedVideoChunk,globalThis.FencedFrameConfig,globalThis.GPUCompilationInfo,globalThis.GPUCompilationMessage,globalThis.GPUPipelineError,globalThis.RTCEncodedAudioFrame,globalThis.RTCEncodedVideoFrame,globalThis.WebTransportError],Rr={type:`clonable`,capableOnly:!0,objectsOnly:!0,isType:e=>F(e,Ir)||F(e,Lr),box:(e,t)=>e,revive:(e,t)=>e},zr=[globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.WritableStream,globalThis.TransformStream,globalThis.MediaStreamTrack,globalThis.RTCDataChannel],Br=[globalThis.AudioData,globalThis.VideoFrame,globalThis.MediaSourceHandle,globalThis.MIDIAccess,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream],Vr={type:`transferable`,capableOnly:!0,objectsOnly:!0,isType:e=>F(e,zr)||F(e,Br),box:(e,t)=>e,revive:(e,t)=>e},Hr={type:`blob`,capableOnly:!0,objectsOnly:!0,isType:e=>typeof Blob<`u`&&e instanceof Blob,box:(e,t)=>{if(ae(t.transport))throw TypeError(`osra: Blob is only supported on structured-clone transports, send an ArrayBuffer or Uint8Array instead`);return e},revive:(e,t)=>e},Ur=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Wr=[Xe,zn,ye,we,ke,Pe,Be,Kt,$t,_t,sn,vn,Cn,kn,Pn,er,ir,cr,Er,pr,jr,{type:`nonFiniteNumber`,isType:e=>typeof e==`number`&&!Number.isFinite(e),box:(e,t)=>ae(t.transport)?{...V,type:`nonFiniteNumber`,value:String(e)}:e,revive:(e,t)=>Number(e.value)},{type:`undefined`,isType:e=>e===void 0,box:(e,t)=>ae(t.transport)?{...V,type:`undefined`}:e,revive:(e,t)=>void 0},Rr,Vr,Hr,vr,{type:`unclonable`,objectsOnly:!0,isType:e=>{if(typeof e!=`object`||!e||Array.isArray(e)||Ur(e))return!1;try{return structuredClone(e),!1}catch{return!0}},box:(e,t)=>({...V,type:`unclonable`}),revive:(e,t)=>({})}],Gr=(e,t)=>t.find(t=>t.type===e.type),Kr=e=>!!e&&typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype,qr=(e,t)=>Array.isArray(e)?e.map(e=>t(e)):Kr(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)])):e,Jr=new WeakSet,Yr=new WeakSet,Xr=0,Zr=[],Qr=(e,t)=>{if(Xr===0){e();return}Zr.push({commit:e,rollback:t})},$r=e=>{let t=Zr;Zr=[];for(let n of t)try{e?n.rollback():n.commit()}catch{}},ei=e=>e!==null&&(typeof e==`object`||typeof e==`function`),ti=new WeakMap,ni=e=>{let t=ti.get(e);if(t)return t;let n=e.filter(e=>!e.objectsOnly);return ti.set(e,n),n},ri=(e,t,n)=>{let r=(e===null||typeof e!=`object`&&typeof e!=`function`?ni(t.revivableModules):t.revivableModules).find(t=>t.type!==n&&t.isType(e));return r?r.box(e,t):qr(e,e=>ii(e,t))},ii=(e,t)=>{if(ge(e))return e;let n=ei(e);if(n){if(Jr.has(e))throw TypeError(`osra: cannot serialize a circular structure - break the cycle or send the container by reference`);Jr.add(e)}Xr++;let r=!0;try{let n=ri(e,t);return r=!1,n}finally{n&&Jr.delete(e),Xr--,Xr===0&&$r(r)}},ai=(e,t,n)=>ri(e,t,n),oi=(e,t)=>{let n=ei(e);if(n){if(Yr.has(e))throw TypeError(`osra: cannot revive a circular structure`);Yr.add(e)}try{if(ge(e)){let n=Gr(e,t.revivableModules);if(n)return n.revive(e,t)}return qr(e,e=>oi(e,t))}finally{n&&Yr.delete(e)}},si=l({init:()=>ui,startBidirectionalConnection:()=>li,type:()=>ci}),ci=`bidirectional`,li=({transport:e,value:t,remoteUuid:n,eventTarget:r,send:i,revivableModules:a})=>{let o={transport:e,remoteUuid:n,sendMessage:i,eventTarget:r,revivableModules:a};for(let e of a)e.init?.(o);let{promise:s,resolve:c}=Promise.withResolvers();return r.addEventListener(`message`,function e({detail:t}){t.type===`init`&&(c(t.data),r.removeEventListener(`message`,e))}),i({type:`init`,remoteUuid:n,data:ii(t,o)}),{revivableContext:o,remoteValue:s.then(e=>oi(e,o))}},ui=e=>{if(!(oe(e.transport)&&se(e.transport)))return;if(e.protocolEventTarget.addEventListener(`message`,({detail:{message:t,peer:n}})=>{if(t.type===`announce`){if(!t.remoteUuid){e.sendMessage({type:`announce`,remoteUuid:t.uuid});return}if(t.remoteUuid!==e.getUuid()||e.connectionContexts.has(t.uuid))return;e.sendMessage({type:`announce`,remoteUuid:t.uuid});let r=e.createConnectionEventTarget(),i={...n(),abort:()=>e.abortConnection(t.uuid)},a;try{let n=e.valueFor(i);if(e.claimPendingAbort(t.uuid)){e.sendMessage({type:`close`,remoteUuid:t.uuid});return}a=li({transport:e.transport,value:n,remoteUuid:t.uuid,eventTarget:r,send:t=>e.sendMessage(t),revivableModules:e.revivableModules})}catch(n){e.sendMessage({type:`close`,remoteUuid:t.uuid}),e.rejectRemoteValue(n);return}let o={type:`bidirectional`,eventTarget:r,connection:a};e.connectionContexts.set(t.uuid,o),o.connection.remoteValue.then(t=>e.addConnection(i,t),t=>e.rejectRemoteValue(t));return}if(t.type===`close`){if(t.remoteUuid!==e.getUuid())return;let n=e.connectionContexts.get(t.uuid);if(!n)return;e.connectionContexts.delete(t.uuid),Ye(n.connection.revivableContext),e.rejectRemoteValue(Error(`osra: peer closed the connection`));return}if(t.remoteUuid!==e.getUuid())return;let r=e.connectionContexts.get(t.uuid);r&&r.eventTarget.dispatchEvent(new CustomEvent(`message`,{detail:t}))}),e.presetRemoteUuid!==void 0){let t=e.presetRemoteUuid,n=e.createConnectionEventTarget(),r,i;try{i={abort:()=>e.abortConnection(t)};let a=e.valueFor(i);if(e.claimPendingAbort(t)){e.sendMessage({type:`close`,remoteUuid:t});return}r=li({transport:e.transport,value:a,remoteUuid:e.presetRemoteUuid,eventTarget:n,send:t=>e.sendMessage(t),revivableModules:e.revivableModules})}catch(n){e.sendMessage({type:`close`,remoteUuid:t}),e.rejectRemoteValue(n);return}let a={type:`bidirectional`,eventTarget:n,connection:r};e.connectionContexts.set(e.presetRemoteUuid,a),a.connection.remoteValue.then(t=>e.addConnection(i,t),t=>e.rejectRemoteValue(t));return}let t=50,n,r=()=>{if(!(e.unregisterSignal?.aborted||e.connectionContexts.size>0)){try{e.sendMessage({type:`announce`},`*`)}catch{}n=setTimeout(r,t),t=Math.min(t*2,1e3)}};e.unregisterSignal?.addEventListener(`abort`,()=>clearTimeout(n),{once:!0}),r()},di=()=>new EventTarget,fi=e=>{let t=de(e),n=t?e.emit:e,r=t?e.receive:e;return{isJson:t&&`isJson`in e&&e.isJson!==void 0?e.isJson:n!==void 0&&ae(n)||r!==void 0&&ae(r),...n===void 0?{}:{emit:n},...r===void 0?{}:{receive:r}}},pi=e=>e?e(Wr):Wr,mi=32,hi=()=>{let e=[],t=new Set,n=!1,r=()=>({value:void 0,done:!0});return{push:r=>{if(!n){if(t.size===0){e.push(r),e.length>mi&&e.shift();return}for(let e of t){let t=e.wake;if(t){e.wake=void 0,t({value:r,done:!1});continue}e.buffered.push(r)}}},close:()=>{n=!0;for(let e of t){let t=e.wake;e.wake=void 0,t?.(r())}},iterate:()=>{let i={buffered:[...e]};t.add(i);let a=!1;return{[Symbol.asyncIterator](){return this},next:()=>{if(a)return Promise.resolve(r());let e=i.buffered.shift();return e?Promise.resolve({value:e,done:!1}):n?Promise.resolve(r()):new Promise(e=>{i.wake=e})},return:()=>{a=!0,t.delete(i);let e=i.wake;return i.wake=void 0,e?.(r()),Promise.resolve(r())}}}}},gi=(e,t,n)=>{let r=e.then(n);r.catch(()=>{});let i=()=>{let e=t.iterate();return{[Symbol.asyncIterator](){return this},next:()=>e.next().then(e=>e.done?{value:void 0,done:!0}:{value:n(e.value),done:!1}),return:()=>e.return?.()??Promise.resolve({value:void 0,done:!0})}};return Object.assign(r,{[Symbol.asyncIterator]:i})},_i=Symbol.for(`osra.context`),vi=e=>typeof e==`object`&&!!e&&_i in e,yi=[si],bi=(e,{transport:t,name:n,remoteName:r,key:i=d,origin:a=`*`,unregisterSignal:o,revivableModules:s,uuid:c,remoteUuid:l,connection:f=({value:e})=>e})=>{let p=f,m=fi(t);if(!(oe(m)&&se(m))){let e=hi();e.close();let t=Promise.reject(Error(`osra: transport must be able to both emit and receive to establish a connection; pass a bidirectional platform transport or a custom { emit, receive } pair`));return t.catch(()=>{}),gi(t,e,p)}let h=pi(s),g=new Map,v=new Set,y=hi(),{promise:x,resolve:S,reject:C}=Promise.withResolvers();x.catch(()=>{});let w=c??globalThis.crypto.randomUUID(),T=(e,t=a)=>{let r={[u]:i,name:n,uuid:w,...e},o=ft(r);b(m,r,t,o),Ht(o)},E=(e,t)=>{o?.aborted||T(e,t)},D=di(),O={transport:m,valueFor:t=>vi(e)?e[_i](t):e,revivableModules:h,connectionContexts:g,getUuid:()=>w,presetRemoteUuid:l,sendMessage:E,protocolEventTarget:D,rejectRemoteValue:C,abortConnection:e=>{let t=g.get(e);if(!t){v.add(e);return}g.delete(e),T({type:`close`,remoteUuid:e}),Ye(t.connection.revivableContext),C(Error(`osra: connection aborted`))},claimPendingAbort:e=>v.delete(e),addConnection:(e,t)=>{let n={value:t,context:e};S(n),y.push(n)},createConnectionEventTarget:di,unregisterSignal:o};if(_({listener:(e,t)=>{e.uuid!==w&&D.dispatchEvent(new CustomEvent(`message`,{detail:{message:e,peer:()=>({...t.origin?{origin:t.origin}:{},...t.source?{source:t.source}:{},...t.port?{port:t.port}:{},...t.sender?{sender:t.sender}:{}})}}))},transport:m,remoteName:r,key:i,origin:a,unregisterSignal:o}),o?.aborted)return C(o.reason),y.close(),gi(x,y,p);o?.addEventListener(`abort`,()=>{for(let[e,t]of g)T({type:`close`,remoteUuid:e}),Ye(t.connection.revivableContext);g.clear(),y.close(),C(o.reason)},{once:!0});for(let e of yi)e.init(O);return gi(x,y,p)},xi=(e,t)=>bi(e,t),Si=1e4,Ci=16,wi=e=>{let t;try{t=e.contentWindow}catch{return!0}if(!t)return!0;try{let e=t.location.href;return e!==``&&e!==`about:blank`}catch{return!0}},Ti=(e,t=Si)=>new Promise(n=>{if(wi(e))return n();let r=()=>{clearInterval(i),clearTimeout(a),e.removeEventListener(`load`,r),n()},i=setInterval(()=>{wi(e)&&r()},Ci),a=setTimeout(r,t);e.addEventListener(`load`,r)}),Ei=5e3,Di=9e4,Oi=(e,t,n)=>{let r=1,i,a=e.ownerDocument.defaultView,o=()=>{clearTimeout(i),a?.removeEventListener(`message`,u),e.removeEventListener(`load`,l)},s=()=>{if(e.isConnected){if(r>=4)return o(),console.error(`FKN @fkn/lib: ${t} did not load in ${r} tries; reload the page`);r+=1,e.contentWindow?.location.replace(t),c(Di)}},c=e=>{clearTimeout(i),i=setTimeout(s,e)},l=()=>c(Ei),u=t=>{t.source===e.contentWindow&&t.origin===n&&o()};if(a?.addEventListener(`message`,u),e.addEventListener(`load`,l),wi(e))return c(Ei);i=setTimeout(()=>wi(e)?c(8e4):s(),Si)},ki=32,Ai=8,ji=120,Mi=typeof CSS<`u`&&CSS.supports(`clip-path`,`path('M0 0H1V1H0Z')`),Ni=typeof CSS<`u`&&CSS.supports(`clip-path`,`polygon(nonzero, 0px 0px, 1px 0px, 1px 1px)`),Pi=`light dark`,Fi=e=>{let t=e.style;t.setProperty(`display`,`block`,`important`),t.setProperty(`position`,`fixed`,`important`),t.setProperty(`top`,`0`,`important`),t.setProperty(`left`,`0`,`important`),t.setProperty(`width`,`100%`,`important`),t.setProperty(`height`,`100%`,`important`),t.setProperty(`border`,`none`,`important`),t.setProperty(`padding`,`0`,`important`),t.setProperty(`box-sizing`,`border-box`,`important`),t.setProperty(`clip-path`,`inset(100%)`,`important`),t.setProperty(`background`,`transparent`),t.setProperty(`color-scheme`,Pi),t.setProperty(`z-index`,`2147483647`),e.setAttribute(`title`,`FKN`)},Ii=({x:e,y:t,width:n,height:r,radius:i})=>{if(!i)return`M${e} ${t}h${n}v${r}h${-n}Z`;let a=Math.min(n,r)/2,[o,s,c,l]=i.map(e=>Math.max(0,Math.min(e,a)));return`M${e+o} ${t}h${n-o-s}a${s} ${s} 0 0 1 ${s} ${s}v${r-s-c}a${c} ${c} 0 0 1 ${-c} ${c}h${-(n-c-l)}a${l} ${l} 0 0 1 ${-l} ${-l}v${-(r-l-o)}a${o} ${o} 0 0 1 ${o} ${-o}Z`},Li=()=>Mi&&Ni,Ri=({x:e,y:t,width:n,height:r})=>[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],zi=e=>{let t=e[0];if(!t)return[];let n=Ri(t)[0],r=[];return e.forEach((t,i)=>{r.push(...Ri(t)),i>0&&i<e.length-1&&r.push(n)}),r},Bi=e=>`polygon(nonzero, ${zi(e).map(([e,t])=>`${e}px ${t}px`).join(`, `)})`,Vi=({x:e,y:t,width:n,height:r,radius:i},a)=>{let o=`${t}px ${a.width-e-n}px ${a.height-t-r}px ${e}px`;return i?`inset(${o} round ${i.map(e=>`${e}px`).join(` `)})`:`inset(${o})`},Hi=(e,t,n)=>{if(t)return`none`;if(e.length===0)return`inset(100%)`;let r=e.length===1?e[0]:void 0;return r?Vi(r,n):Ni&&e.length<=5&&!e.some(e=>e.radius)?Bi(e):`path('${e.map(Ii).join(``)}')`},Ui=e=>{if(e.length<2)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}},Wi=(e,t,n)=>t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height,Gi=16,Ki=(e,t,n)=>t===1?e*Gi:t===2?e*n:e,qi=(e,t,n)=>{let r=getComputedStyle(e);return n!==0&&/auto|scroll/.test(r.overflowY)&&e.scrollHeight>e.clientHeight?!0:t!==0&&/auto|scroll/.test(r.overflowX)&&e.scrollWidth>e.clientWidth},Ji=(e,t,n)=>{for(let r=e;r;r=r.parentElement)if(qi(r,t,n))return r;return document.scrollingElement},Yi=null,Xi=null,Zi=e=>({width:e.offsetWidth||window.innerWidth,height:e.offsetHeight||window.innerHeight}),Qi=e=>{if(!Xi||!Yi||!Wi(Xi,e.clientX,e.clientY))return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t||t===Yi)return;let n=Ki(e.deltaX,e.deltaMode,window.innerWidth),r=Ki(e.deltaY,e.deltaMode,window.innerHeight),i=Ji(t,n,r);i&&(i.scrollBy({left:n,top:r,behavior:`instant`}),e.cancelable&&e.preventDefault())},$i=e=>{let t=Xi!==null;Xi=e,t!==(e!==null)&&(e?window.addEventListener(`wheel`,Qi,{capture:!0,passive:!1}):window.removeEventListener(`wheel`,Qi,{capture:!0}))},ea=0,ta=e=>{if(e===ea)return;ea=e;let t=document.documentElement.style;e>0?(t.setProperty(`margin-top`,`${e}px`,`important`),t.setProperty(`--fkn-inset-top`,`${e}px`)):(t.removeProperty(`margin-top`),t.removeProperty(`--fkn-inset-top`))},na=(e,{modal:t,rects:n,inset:r},i)=>{if(ta(r),!Mi){let r=t||n.length>0;e.style.setProperty(`pointer-events`,r?`auto`:`none`,`important`),e.style.setProperty(`visibility`,r?`visible`:`hidden`,`important`);return}let a=Hi(n,t,i),o=a===`none`||CSS.supports(`clip-path`,a)?a:`inset(100%)`;e.style.setProperty(`clip-path`,o,`important`),$i(t||o!==a?null:Ui(n))},ra=e=>{if(typeof e!=`object`||!e)return 0;let{top:t}=e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?0:Math.min(Math.round(t),ji)},ia=e=>{if(Array.isArray(e)&&e.length===4&&e.every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))return e.some(e=>e>0)?e:void 0},aa=(e,t)=>{if(typeof e!=`object`||!e)return null;let{x:n,y:r,width:i,height:a}=e;if(![n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let o=t.width,s=t.height,c=Math.max(0,Math.min(Math.round(n),o)),l=Math.max(0,Math.min(Math.round(r),s)),u=Math.max(c,Math.min(Math.round(n+i),o)),d=Math.max(l,Math.min(Math.round(r+a),s)),f=ia(e.radius);return{x:c,y:l,width:u-c,height:d-l,...f?{radius:f}:{}}},oa={"not-rendered":`this page is not painting it at all, so it or an ancestor is display:none, or the frame was moved out of the layout`,clipped:`it is clipped away or positioned outside the viewport`,"not-shown":`it is rendered but would not be seen, so either something is drawn over it, or it or an ancestor has opacity below 1, visibility:hidden, or a filter`},sa=e=>Array.isArray(e)?e.slice(0,Ai).flatMap(e=>{if(typeof e!=`object`||!e)return[];let{kind:t,cause:n,level:r}=e;return typeof t!=`string`||t.length>40||typeof n!=`string`||!(n in oa)||r!==`full`&&r!==`liveness`?[]:[{kind:t,cause:n,level:r}]}):[],ca=new Set,la=e=>{for(let{kind:t,cause:n,level:r}of e)ca.has(t)||(ca.add(t),console.error(`[FKN] The FKN ${JSON.stringify(t)} is not visible on this page: ${oa[n]}. Nobody using this page can see or answer it.
|
|
2
|
+
@fkn/lib draws its UI inside <iframe title="FKN"> and sets display, position, top, left, width, height, border, padding, box-sizing, clip-path and z-index on that element. Leave those as they are, then check for an ancestor with opacity, visibility, display or a clipping transform, and for an element stacked above it.`+(r===`liveness`?`
|
|
3
|
+
This browser reports limited detail, so the cause above is a best guess.`:``)))},ua=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=e,r=(Array.isArray(n.rects)?n.rects.slice(0,ki):[]).map(e=>aa(e,t)).filter(e=>e!==null&&e.width>0&&e.height>0);return{modal:n.modal===!0,rects:r,hidden:sa(n.hidden),inset:ra(n.inset)}},da=()=>Yi!==null,fa=null,pa=null,ma=()=>{if(!Yi||fa===null)return;let e=Zi(Yi),t=ua(fa,e);t&&na(Yi,t,e)},ha=e=>{typeof ResizeObserver<`u`&&(pa??=new ResizeObserver(ma),pa.disconnect(),pa.observe(e))},ga=e=>{Fi(e),na(e,{modal:!1,rects:[],hidden:[],inset:0},Zi(e)),Yi=e,ha(e)},_a=e=>{if(!Yi)return;let t=Zi(Yi),n=ua(e,t);n&&(fa=e,na(Yi,n,t),la(n.hidden))},va=`https://fkn.app`,ya=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,ba=typeof globalThis<`u`&&globalThis.crossOriginIsolated===!0,xa=s(ba),Sa=`fkn-api-port`,Ca=`fkn-api-port-ack`,wa=2e3,Ta=()=>{if(!ya||typeof window>`u`||window.parent===window)return Promise.resolve(void 0);let e;try{e=window.parent}catch{return Promise.resolve(void 0)}let t=new MessageChannel;return new Promise(n=>{let r=e=>{if(clearTimeout(a),t.port1.removeEventListener(`message`,i),!e)try{t.port1.close()}catch{}n(e)},i=e=>{e.data?.type===Ca&&r(t.port1)},a=setTimeout(()=>r(void 0),wa);t.port1.addEventListener(`message`,i),t.port1.start();try{e.postMessage({type:Sa},va,[t.port2])}catch{r(void 0)}})},Ea,Da=()=>{if(Ea||!ya)return Ea;let e=ya.querySelector(`iframe[src="${xa}"]`);if(e)Ea=e;else{let e=ya.createElement(`iframe`);e.setAttribute(`allow`,a(ba)),e.src=xa,ya.body.appendChild(e),Ea=e}return Oi(Ea,xa,va),ga(Ea),Ea},Oa=(async()=>{if(!ya)return;let e=await Ta();if(e)return{receive:e,emit:e};let t=Da();if(!t)return;await Ti(t);let n=t.contentWindow;return n?{receive:window,emit:n}:void 0})(),ka=(e,{boundRetired:t=e=>e}={})=>{let n,r=0,i=!1,a=()=>{},o=()=>new Promise(e=>{a=e}),s=o(),c=s,l=new Set,u=new Set,d=0,f=0,p=()=>{let e=[...u];u.clear();let t=Error(`FKN: the broker was replaced while this call was pending; retry it`);for(let n of e)try{n(t)}catch{}};(async()=>{for await(let t of e){let e=++r;n={remote:t,epoch:e};let i=a;s=o(),i(t),p();for(let n of[...l])try{n(t,e)}catch{}}})().catch(()=>{});let m=async(e,r)=>{let a=n?.remote??await(i?t(s):s);for(let t of e.slice(0,-1))a=a[t];let o=a[e[e.length-1]??``];d=Date.now(),f+=1;let c=()=>{},l=new Promise((e,t)=>{c=t});u.add(c);try{return await Promise.race([Promise.resolve(o.apply(a,r)),l])}finally{--f,u.delete(c),d=Date.now()}},h=new Map,g=e=>{let t=e.join(`\0`),r=h.get(t);if(r)return r;let i=new Proxy(function(){},{get:(t,r)=>{if(typeof r!=`string`||r===`then`)return;let i=n;if(i){let t=i.remote;for(let n of e)t=t?.[n];if(t?.[r]===void 0)return}return g([...e,r])},apply:(t,n,r)=>m(e,r)});return h.set(t,i),i};return{facade:g([]),first:c.then(()=>{}),current:()=>n,onEpoch:e=>{if(l.add(e),n)try{e(n.remote,n.epoch)}catch{}return()=>{l.delete(e)}},lastCall:()=>d,inFlight:()=>f,routable:()=>n?Promise.resolve():s.then(()=>{}),retire:()=>{i=!0,n=void 0,p()}}},Aa=!1,ja=new Set,Ma=()=>Aa,Na=e=>{ja.add(e)},Pa=typeof window<`u`||typeof self<`u`,Fa=async()=>{if(typeof window<`u`)return Oa;if(typeof self<`u`)return{receive:self,emit:self}},Ia=`fkn-api`,La=`fkn-api-window`,Ra={async*[Symbol.asyncIterator](){let e=await Fa();if(!e){await new Promise(()=>{});return}if(!Ma()){let t=new AbortController;Na(()=>t.abort());for await(let n of xi({},{key:Ia,transport:e,unregisterSignal:t.signal})){if(t.signal.aborted)break;yield n}}yield*xi({},{key:La,transport:e})}},za=!1,Ba=Fa().then(e=>new Promise(t=>{if(!e)return;let{receive:n}=e,r=e=>{h(e.data,Ia)&&(n.removeEventListener(`message`,r),za=!0,t())};n.addEventListener(`message`,r)})),Va=ka(Ra,{boundRetired:e=>Promise.race([e,Ba.then(()=>Ja(e,()=>new qa))])});Na(()=>Va.retire());var Ha=Promise.race([Va.first,new Promise(e=>Na(e))]).then(()=>Va.facade),Ua=8e3,Wa=1e3,Ga=!1,Ka=class extends Error{constructor(e,t){super(`@fkn/lib: no broker connection within ${t}ms, so ${e} could not be requested`),this.name=`BrokerUnreachableError`}},qa=class extends Error{constructor(){super(`FKN @fkn/lib: this page relays its FKN channel to a worker, and the FKN page it reached predates a channel of the page's own; reload`),this.name=`OwnChannelUnavailableError`}},Ja=(e,t)=>{let n=Ga?Wa:Ua;return Promise.race([e,new Promise((e,r)=>setTimeout(()=>{Ga=!0,r(t(n))},n))])},Ya=e=>Ma()?Ja(Va.routable().then(()=>Va.facade),t=>za?new qa:new Ka(e,t)):Ja(Ha,t=>new Ka(e,t));Na(()=>{Ba.then(()=>{let e=setTimeout(()=>console.error(new qa),Ua);Va.routable().then(()=>clearTimeout(e))})});var Xa=Va.onEpoch,Za=Va.current;Va.lastCall,Va.inFlight,Xa(e=>{da()&&e.overlay.setHost(_a,{exactClips:Li(),colorScheme:Pi}).catch(()=>{})});var Qa=0,$a=new Set,eo=2e3,to=null,no=e=>{let t=e?.switched!==!1;t&&(Qa+=1,to&&=(clearTimeout(to.timer),null));for(let e of[...$a])try{e({switched:t})}catch{}},ro=!1,io=0,ao=()=>{let e=Za();e&&io!==e.epoch&&(io=e.epoch,Promise.resolve(e.remote.account.onChange(no)).catch(()=>{io===e.epoch&&(io=0)}))},oo=()=>{!ro&&Pa&&(ro=!0,Xa(ao))},so=()=>Qa,co=e=>($a.add(e),oo(),()=>{$a.delete(e)}),lo=e=>{if(e!==Qa||to?.generation===e)return;let t=setTimeout(()=>{to?.timer===t&&(to=null,Qa===e&&no({switched:!0}))},eo);to={generation:e,timer:t}},uo=async e=>Pa?co(e):()=>{},fo=new Map,po=new Set,mo=e=>{fo.set(e,(fo.get(e)??0)+1);let t=!1;return()=>{t||(t=!0,fo.set(e,Math.max(0,(fo.get(e)??1)-1)))}},ho=(e,t)=>{po.add({kind:e,probe:t})},go=e(((e,t)=>{t.exports={}}))(),_o={json:`application/json`,txt:`text/plain`,html:`text/html`,htm:`text/html`,css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,xml:`application/xml`,csv:`text/csv`,md:`text/markdown`,svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,pdf:`application/pdf`,wasm:`application/wasm`},vo=(e,t)=>{if(t)return t;let n=e.split(`/`).pop()??``,r=n.lastIndexOf(`.`);if(!(r<=0))return _o[n.slice(r+1).toLowerCase()]},yo=(e,t)=>({size:e,mtimeMs:t,mtime:new Date(t),atimeMs:t,ctimeMs:t,mode:420,isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}),bo=(e=0)=>({size:0,mtimeMs:e,mtime:new Date(e),atimeMs:e,ctimeMs:e,mode:493,isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1}),xo=(e,t,n)=>{let r=Error(`${e}: ${{ENOENT:`no such file or directory`,EEXIST:`file already exists`,ENOTDIR:`not a directory`,EISDIR:`illegal operation on a directory`,ENOTEMPTY:`directory not empty`,ERR_FS_EISDIR:`is a directory`}[e]??e}, ${n} '${t}'`);return r.code=e,r.path=t,r.syscall=n,r},So=e=>{let t=[];for(let n of e.split(`/`))if(n&&n!==`.`){if(n===`..`){t.pop();continue}t.push(n)}return t.join(`/`)},Co=e=>e.split(`/`).slice(0,-1).join(`/`),H=e=>typeof e==`string`?e:e instanceof URL?decodeURIComponent(e.pathname):e.toString(),wo=e=>typeof e==`string`?e:e?.encoding??void 0,To=e=>typeof e==`object`?e?.contentType:void 0,Eo=e=>typeof e==`object`&&!!e?.recursive,Do=(e,t)=>{let n=wo(t);return n?go.Buffer.from(e).toString(n):go.Buffer.from(e)},Oo=(e,t)=>{if(typeof e==`string`)return new Uint8Array(go.Buffer.from(e,wo(t)??`utf8`));if(e instanceof Uint8Array)return e.slice();if(e instanceof ArrayBuffer)return new Uint8Array(e).slice();if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice();throw TypeError(`The "data" argument must be of type string, Buffer, TypedArray, or DataView`)},ko=e=>{let t=new Map([[``,{kind:`dir`,mtimeMs:0}]]),n=new Map,r=new Map,i=()=>e.captureAccount?{pin:e.captureAccount()}:{};ho(`unsaved files`,()=>n.size>0||r.size>0);let a=new Set,o=()=>Date.now(),s=e=>{if(!e)return;let n=e.split(`/`),r=``;for(let e of n){r=r?`${r}/${e}`:e;let n=t.get(r);if(!n)t.set(r,{kind:`dir`,mtimeMs:o()});else if(n.kind===`file`)throw xo(`ENOTDIR`,r,`mkdir`)}},c,l=0,u=async()=>{let c=i(),u=await e.list(c).catch(()=>[]),d=new Set,f=!1;for(let i of u){let l=So(i.path);if(d.add(l),!r.has(l)&&(!n.has(l)||a.has(l)))try{let u=await(await e.readFile(i.path,c)).arrayBuffer();if(r.has(l)||n.has(l)&&!a.has(l))continue;s(Co(l));let d=Date.parse(i.updatedAt??``);t.set(l,{kind:`file`,data:new Uint8Array(u),mtimeMs:Number.isFinite(d)?d:o(),contentType:i.contentType??void 0}),a.delete(l),n.delete(l)}catch{f=!0,a.add(l)}}for(let e of a)d.has(e)||a.delete(e);l=f?Date.now():0},d=()=>(c&&(l===0||Date.now()-l<5e3)||(c=u()),c),f=async()=>{c=void 0,l=0,await d()},p=async()=>{let i=[...n].map(async([r,i])=>{if(a.has(r))return;let o=t.get(r);if(o?.kind!==`file`){n.delete(r);return}let s=o.data,c=vo(r,o.contentType);try{await e.writeFile(r,s,c?{contentType:c,...i}:i);let a=t.get(r);a?.kind===`file`&&a.data===s&&n.delete(r)}catch{}}),o=[...r].map(async([t,n])=>{try{await e.remove(t,n),r.get(t)===n&&r.delete(t)}catch{}});await Promise.all([...i,...o])},m,h=()=>{m||=setTimeout(()=>{m=void 0,p().catch(()=>{})},250)};typeof addEventListener<`u`&&(addEventListener(`pagehide`,()=>{p().catch(()=>{})}),addEventListener(`visibilitychange`,()=>{typeof document<`u`&&document.visibilityState===`hidden`&&p().catch(()=>{})}));let g=e=>e.kind===`file`?yo(e.data.byteLength,e.mtimeMs):bo(e.mtimeMs),_=e=>Object.assign(Error(`storage: ${e} exists but could not be read, retry once its scope is available`),{code:`FKN_E2E_LOCKED`}),v=e=>{let n=So(e);return t.has(n)||a.has(n)},y=e=>{let n=So(e),r=t.get(n);if(!r)throw a.has(n)?_(e):xo(`ENOENT`,e,`stat`);return g(r)},b=e=>{let n=So(e),r=t.get(n);if(!r)throw a.has(n)?_(e):xo(`ENOENT`,e,`open`);if(r.kind===`dir`)throw xo(`EISDIR`,e,`read`);return r.data},x=(e,t)=>{let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n},S=(e,c,l,u)=>{let d=So(e);if(!d)throw xo(`EISDIR`,e,`open`);if(a.has(d))throw _(e);let f=t.get(d);if(f?.kind===`dir`)throw xo(`EISDIR`,e,`open`);s(Co(d));let p=l&&f?.kind===`file`?x(f.data,c):c;t.set(d,{kind:`file`,data:p,mtimeMs:o(),contentType:u??(f?.kind===`file`?f.contentType:void 0)}),n.set(d,i()),r.delete(d),h()},C=(e,n)=>{let r=So(e);if(r){if(t.has(r)){if(n)return;throw xo(`EEXIST`,e,`mkdir`)}if(!n&&!t.has(Co(r)))throw xo(`ENOENT`,e,`mkdir`);s(r)}},w=e=>{let n=So(e),r=t.get(n);if(!r)throw xo(`ENOENT`,e,`scandir`);if(r.kind===`file`)throw xo(`ENOTDIR`,e,`scandir`);let i=n?`${n}/`:``,o=new Set;for(let e of[...t.keys(),...a]){if(!e||!e.startsWith(i))continue;let t=e.slice(i.length);t&&o.add(t.split(`/`)[0])}return[...o]},T=(e,{op:o,recursive:s,force:c})=>{let l=i(),u=So(e),d=t.get(u);if(!d&&a.has(u)){if(o===`rmdir`)throw xo(`ENOTDIR`,e,`rmdir`);a.delete(u),n.delete(u),r.set(u,l),h();return}if(!d){if(c||o===`rmdir`&&s)return;throw xo(`ENOENT`,e,o===`rmdir`?`rmdir`:`unlink`)}if(o===`unlink`&&d.kind===`dir`)throw xo(`EISDIR`,e,`unlink`);if(o===`rmdir`&&d.kind===`file`)throw xo(`ENOTDIR`,e,`rmdir`);if(o===`rm`&&d.kind===`dir`&&!s)throw xo(`ERR_FS_EISDIR`,e,`rm`);let f=`${u}/`,p=[...t.keys()].filter(e=>e.startsWith(f));if(p.length&&!s)throw xo(`ENOTEMPTY`,e,`rmdir`);for(let e of[u,...p]){let i=t.get(e);t.delete(e),i?.kind===`file`&&(n.delete(e),r.set(e,l))}h()};return{mount:d,remount:f,flush:p,exists:v,stat:y,readFile:b,writeFile:S,mkdir:C,readdir:w,remove:T,rename:(e,o)=>{let c=i(),l=So(e),u=So(o);if(!l)throw xo(`EBUSY`,e,`rename`);if(u===l||u.startsWith(`${l}/`))throw xo(`EINVAL`,e,`rename`);if(a.has(l))throw _(e);if(a.has(u))throw _(o);let d=t.get(l);if(!d)throw xo(`ENOENT`,e,`rename`);let f=t.get(u);if(f){if(f.kind!==d.kind)throw xo(d.kind===`dir`?`ENOTDIR`:`EISDIR`,o,`rename`);T(u,{op:`rm`,recursive:!0,force:!0})}s(Co(u));let p=`${l}/`,m=[l,...[...t.keys()].filter(e=>e.startsWith(p))];for(let e of m){let i=u+e.slice(l.length),a=t.get(e);t.set(i,a),t.delete(e),a.kind===`file`&&(n.set(i,c),r.delete(i),n.delete(e),r.set(e,c))}h()}}},Ao=(e,t)=>typeof e==`function`?e:t,jo=e=>typeof e==`function`?void 0:e,Mo=(e,t)=>{e.then(e=>t(null,e),e=>t(e))},No=e=>{let t=ko(e),n=(e,n)=>Do(t.readFile(H(e)),n),r=(e,n,r)=>t.writeFile(H(e),Oo(n,r),!1,To(r)),i=(e,n,r)=>t.writeFile(H(e),Oo(n,r),!0,To(r)),a=e=>t.exists(H(e)),o=e=>t.stat(H(e)),s=e=>t.readdir(H(e)),c=(e,n)=>t.mkdir(H(e),Eo(n)),l=(e,n)=>t.remove(H(e),{op:`rm`,...n}),u=(e,n)=>t.remove(H(e),{op:`rmdir`,...n}),d=e=>t.remove(H(e),{op:`unlink`}),f=(e,n)=>t.rename(H(e),H(n)),p=(e,n)=>{t.mount().finally(()=>{let t;try{t=e()}catch(e){n(e);return}n(null,t)})},m=e=>t.mount().then(()=>e());return{available:e.available,readFileSync:n,writeFileSync:r,appendFileSync:i,existsSync:a,statSync:o,lstatSync:o,readdirSync:s,mkdirSync:c,rmSync:l,rmdirSync:u,unlinkSync:d,renameSync:f,readFile:(e,n,r)=>p(()=>Do(t.readFile(H(e)),jo(n)),Ao(n,r)),writeFile:(e,n,r,i)=>p(()=>t.writeFile(H(e),Oo(n,jo(r)),!1,To(jo(r))),Ao(r,i)),appendFile:(e,n,r,i)=>p(()=>t.writeFile(H(e),Oo(n,jo(r)),!0,To(jo(r))),Ao(r,i)),stat:(e,n)=>p(()=>t.stat(H(e)),n),readdir:(e,n,r)=>p(()=>t.readdir(H(e)),Ao(n,r)),mkdir:(e,n,r)=>p(()=>t.mkdir(H(e),Eo(jo(n))),Ao(n,r)),rm:(e,n,r)=>p(()=>t.remove(H(e),{op:`rm`,...jo(n)}),Ao(n,r)),unlink:(e,n)=>p(()=>t.remove(H(e),{op:`unlink`}),n),rename:(e,n,r)=>p(()=>t.rename(H(e),H(n)),r),exists:(e,n)=>{t.mount().finally(()=>n(t.exists(H(e))))},promises:{readFile:(e,n)=>m(()=>Do(t.readFile(H(e)),n)),writeFile:(e,n,r)=>m(()=>t.writeFile(H(e),Oo(n,r),!1,To(r))),appendFile:(e,n,r)=>m(()=>t.writeFile(H(e),Oo(n,r),!0,To(r))),stat:e=>m(()=>t.stat(H(e))),lstat:e=>m(()=>t.stat(H(e))),readdir:e=>m(()=>t.readdir(H(e))),mkdir:(e,n)=>m(()=>t.mkdir(H(e),Eo(n))),rm:(e,n)=>m(()=>t.remove(H(e),{op:`rm`,...n})),rmdir:(e,n)=>m(()=>t.remove(H(e),{op:`rmdir`,...n})),unlink:e=>m(()=>t.remove(H(e),{op:`unlink`})),rename:(e,n)=>m(()=>t.rename(H(e),H(n))),access:e=>m(()=>{if(!t.exists(H(e)))throw xo(`ENOENT`,H(e),`access`)})},mount:t.mount,flush:t.flush,remount:t.remount}},Po=e=>{let t=()=>e.captureAccount?{pin:e.captureAccount()}:{},n=async(t,n)=>{let r=await e.readFile(H(t));return Do(new Uint8Array(await r.arrayBuffer()),n)},r=async(t,n,r)=>{let i=H(t),a=vo(i,To(r));await e.writeFile(i,Oo(n,r),a?{contentType:a}:void 0)},i=t=>e.remove(H(t)),a=async(n,r)=>{let i=t(),a=So(H(n)),o=So(H(r));if(a===o)return;let s=await e.readFile(a,i);await e.writeFile(o,s,i),await e.remove(a,i)},o=async t=>{let n=So(H(t)),r=n?`${n}/`:``,i=new Set;for(let t of await e.list()){let e=So(t.path);if(r&&!e.startsWith(r))continue;let n=e.slice(r.length);n&&i.add(n.split(`/`)[0])}return[...i]},s=async(e,t)=>{},c=async(n,r)=>{let i=t(),a=So(H(n));if(!r?.recursive){await e.remove(H(n),i);return}let o=`${a}/`,s=await e.list(i);await Promise.all(s.filter(e=>{let t=So(e.path);return t===a||t.startsWith(o)}).map(t=>e.remove(t.path,i).catch(()=>{})))},l=async t=>{let n=So(H(t)),r=await e.list(),i=r.find(e=>So(e.path)===n);if(i){let e=Date.parse(i.updatedAt??``);return yo(i.size,Number.isFinite(e)?e:0)}if(r.some(e=>So(e.path).startsWith(`${n}/`)))return bo();throw xo(`ENOENT`,H(t),`stat`)},u={readFile:n,writeFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:c,stat:l,lstat:l,access:async e=>{await l(e)}};return{available:e.available,promises:u,readFile:(e,t,r)=>Mo(n(e,jo(t)),Ao(t,r)),writeFile:(e,t,n,i)=>Mo(r(e,t,jo(n)),Ao(n,i)),unlink:(e,t)=>Mo(i(e),t),rename:(e,t,n)=>Mo(a(e,t),n),readdir:(e,t,n)=>Mo(o(e),Ao(t,n)),mkdir:(e,t,n)=>Mo(s(),Ao(t,n)),rm:(e,t,n)=>Mo(c(e,jo(t)),Ao(t,n)),stat:(e,t)=>Mo(l(e),t)}};function Fo(e,t){return t.memfs?No(e):Po(e)}var Io=`FKN_STORAGE_NOT_FOUND`,Lo=`FKN_ACCOUNT_CHANGED`,Ro=`FKN_ACCOUNT_PIN_UNSUPPORTED`,zo=n({StorageAccountChangedError:()=>Uo,StorageAccountPinUnsupportedError:()=>Wo,StorageLockedError:()=>Bo,StorageNotFoundError:()=>Vo,availability:()=>us,available:()=>as,captureAccount:()=>Jo,encryption:()=>vs,isAccountChanged:()=>Go,isInvalidPin:()=>Ko,isNotFound:()=>Ho,knownPin:()=>es,list:()=>ds,pinFor:()=>ts,quota:()=>fs,readFile:()=>ps,readFileSealed:()=>hs,remove:()=>_s,unlock:()=>ys,writeFile:()=>gs}),Bo=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},Vo=class extends Error{code=Io;constructor(e=`storage: no object at that path`){super(e)}},Ho=e=>e?.code===Io,Uo=class extends Error{code=Lo;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},Wo=class extends Error{code=Ro;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},Go=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),Ko=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),qo=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new Bo:Ho(e)?new Vo(e.message):Go(e)?new Uo:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new Wo:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new Vo(e.message):e},Jo=()=>(oo(),{generation:so()}),Yo=new Map,Xo=null,Zo=e=>typeof e?.accountPin==`function`,Qo=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return so()===e&&Yo.set(e,t),t});return Xo={generation:e,pin:n},n.catch(()=>{Xo?.pin===n&&(Xo=null)}),n},$o=async(e,t)=>{let n=Yo.get(e.generation);if(n!==void 0)return n;if(e.generation!==so())throw new Uo;let r=await(Xo?.generation===e.generation?Xo.pin:Qo(e.generation,t)).catch(qo);if(e.generation!==so())throw new Uo;return r},es=e=>Yo.get(e.generation),ts=async e=>{let t=(await Ha).cloud.fs;if(!Zo(t))throw new Wo;return $o(e,t)},ns=e=>{for(let[t,n]of Yo)if(n===e)return t},rs=e=>e?.pin??Jo(),is=async(e,t)=>{let n=(await Ha).cloud.fs;if(!Zo(n))throw new Wo;let r=`pin`in e?e.pin:await $o(e,n);if(!Zo(n))throw new Wo;return t(n,{accountPin:r}).catch(t=>{if(Go(t)){let t=`generation`in e?e.generation:ns(r);t!==void 0&&lo(t)}return qo(t)})},as=()=>Ha.then(e=>e.cloud.fs.available()).catch(()=>!1),os=8e3,ss=1e3,cs=!1,ls=async()=>{let e=(await Ha).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},us=async()=>{let e=cs?ss:os,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);ls().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(cs=!0,`unknown`):(cs=!1,t)},ds=e=>is(rs(e),(e,t)=>e.list(t)),fs=()=>Ha.then(e=>e.cloud.fs.quota()),ps=async(e,t)=>{let n=await is(rs(t),(t,n)=>t.readFile(e,n));return new Blob([n])},ms=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},hs=async(e,t)=>is(rs(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:ms(i.sealedAt)}}),gs=async(e,t,n)=>{let r=rs(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await is(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},_s=async(e,t)=>{await is(rs(t),(t,n)=>t.remove(e,n))},vs=()=>Ha.then(e=>e.cloud.fs.encryption()),ys=()=>Ha.then(e=>e.cloud.fs.unlock()),{available:bs,readFile:xs,writeFile:Ss,unlink:Cs,rename:ws,readdir:Ts,mkdir:Es,rm:Ds,stat:Os,promises:ks}=Fo(zo,{memfs:!1}),As=()=>ds(),js=e=>hs(e),Ms=`fkn-packages-connection`,Ns=`https://fkn.app`,Ps=(e,t,n)=>xi(e??{},{transport:t,key:Ms,unregisterSignal:n}),Fs=new Map;ho(`package view`,()=>Fs.size>0);var Is=null,Ls=!1,Rs=new Set,zs=[],Bs=new Map,Vs=!1,Hs=!1,Us=e=>{let t=Bs.get(e);t&&(Bs.delete(e),t())},Ws=(e,t)=>{try{e.postMessage({type:`fkn-packages-nack`,message:t})}catch{}try{e.close()}catch{}},Gs=async(e,t)=>{let{port:n,...r}=e;e.port.addEventListener(`message`,t=>{t.data?.type===`fkn-packages-disconnect`&&Us(e.port)});let i;try{i=await t.createPayload(r)}catch(t){throw Ws(e.port,t instanceof Error?t.message:`the package failed to produce a connection`),t}let a=new Promise(t=>Bs.set(e.port,t)),o=await Ps(i,e.port);t.handler?.({...r,remote:o,closed:a,port:e.port})},Ks=()=>{Vs||typeof window>`u`||window.parent===window||(Vs=!0,window.addEventListener(`message`,e=>{if(e.source!==window.parent)return;let t=e.data;if(t?.type===`fkn-packages-port`){let n=e.ports[0];if(!n)return;let r={port:n,from:typeof t.from==`string`?t.from:``,brokered:e.origin===Ns,protocol:typeof t.protocol==`string`?t.protocol:null,uri:typeof t.uri==`string`?t.uri:``,name:typeof t.name==`string`?t.name:``,version:typeof t.version==`string`?t.version:``};Is?Gs(r,Is).catch(e=>console.warn(`packages.onConnect:`,e)):zs.push(r)}if(t?.type===`fkn-packages-close`)for(let e of[...Bs.keys()])Us(e);if(t?.type===`fkn-packages-visibility`){Ls=t.visible===!0;for(let e of Rs)try{e(Ls)}catch{}}}))},qs=()=>{Hs||typeof window>`u`||window.parent===window||(Hs=!0,window.parent.postMessage({type:`fkn-packages-ready`},`*`))},Js=(e,t)=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Ks();let n={createPayload:e,handler:t};for(Is=n,qs();zs.length&&Is===n;)Gs(zs.shift(),n).catch(e=>console.warn(`packages.onConnect:`,e));return{unsubscribe:()=>{Is===n&&(Is=null)}}},Ys=e=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Ks(),Rs.add(e);try{e(Ls)}catch{}return{unsubscribe:()=>{Rs.delete(e)}}},Xs={default:6048e5,min:6e4,max:31536e6},Zs={notAFile:{code:`invalid`,message:`storage: the data is not a Blob or a ReadableStream`},badSize:{code:`invalid`,message:`storage: a stream needs the size it will deliver, a whole number of bytes`},shortStream:{code:`invalid`,message:`storage: the stream did not deliver the size it declared`},tooLarge:{code:`invalid`,message:`storage: the file is too large to store`},badKey:{code:`invalid`,message:`storage: the key is not 32 bytes base64url`},badUrl:{code:`invalid`,message:`storage: the url does not name a stored object`},badLimit:{code:`invalid`,message:`storage: the limit is out of range`},badCursor:{code:`invalid`,message:`storage: the cursor is not one list answered`},notFound:{code:`not-found`,message:`storage: no object at this url`},integrity:{code:`integrity`,message:`storage: the object does not match its key`},needsAccount:{code:`denied`,message:`storage: storing needs an account`},notCreator:{code:`denied`,message:`storage: only the app that stored the object can delete it`},quota:{code:`quota`,message:`storage: storage quota exceeded`},tooMany:{code:`too-many`,message:`storage: too many stored objects`},tooManyThisHour:{code:`too-many`,message:`storage: too many objects stored this hour, try again later`},accountChanged:{code:`account-changed`,message:`storage: the signed-in account changed`},unavailable:{code:`unavailable`,message:`storage: storage is unavailable`}},Qs={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,notClaimingApp:`rooms: only the app that claimed the room can change it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,mailboxUnavailable:`rooms: the mailbox switch is not available`,guestUnavailable:`rooms: guest joins are not available`,schemasUnavailable:`rooms: room schemas are not available`,badSchema:`rooms: the schema is not one a room can take`,newerSchema:`rooms: the room holds a newer schema`,noSchema:`rooms: the room has no schema`,misfit:`rooms: the message does not fit the room's schema`,ownerSends:`rooms: only the owner sends this type`,accountSends:`rooms: sending this needs an account`,perAccount:`rooms: you have as many of these here as the room allows`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},U=(e,t)=>Object.assign(Error(t),{code:e}),$s=e=>e instanceof Error&&typeof e.code==`string`,ec={send:!0,receive:!0,maxMessageBytes:262144},tc=2048,nc=()=>({messages:0,bytes:0,cap:5e8,archived:!1}),rc=async()=>{if(!Pa)return;let e=(await Ya(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},ic=()=>{throw U(`unavailable`,Qs.unavailable)},ac=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,oc=e=>{if(e!==void 0&&e!==!1)return e===!0?Xs.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=Xs.min&&e<=Xs.max?e:null},sc=(e,t)=>{let n=t?e?.guest:e;return typeof n?.join==`function`?n:void 0},cc=e=>{let t;try{t=JSON.stringify(e)}catch{}let n=t===void 0?void 0:JSON.parse(t),r=typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.type==`string`;if(t===void 0||!r||t.length>tc)throw U(`invalid`,Qs.misfit);return t},lc=e=>{let t;try{t=JSON.parse(JSON.stringify(e))}catch{}if(typeof t!=`object`||!t||Array.isArray(t))throw U(`invalid`,Qs.badSchema);return t},uc=e=>e?.schema===void 0?e:{...e,schema:lc(e.schema)},dc=e=>{if(e.schemas!==!0)throw U(`unavailable`,Qs.schemasUnavailable);return e},fc=e=>{let t=e?.guest;if(t!==void 0&&typeof t!=`boolean`)throw U(`invalid`,Qs.malformed);return t===!0},pc=async(e,t)=>{let n=e.invite,r=e,i=0,a=e.self,o=e.owner,s=e.claimed,c=e.mailbox,l=0,u=await e.defaults().catch(()=>ec),d=e.schemas===!0?await Promise.resolve(e.schema()).catch(()=>null):null,f=0,p=!1,m=new Set,h=new Set,g=mo(`room`),_=()=>{},v=()=>{},y=new Promise(e=>{v=e}),b=e=>{let t=[...h];h.clear();for(let n of t)try{n(e)}catch{}},x=e=>{p||(p=!0,_(),m.clear(),g(),b(U(`closed`,Qs.ended)),v({reason:e}))},S=e=>{if(p)return;let t=e;if(t.type===`defaults`&&(u=t.defaults),t.type===`schema`&&(f+=1,d=t.schema),t.type===`message`||t.type===`edited`){let e={...t.message,envelope:t.message.envelope??null};t=t.type===`message`?{...t,message:e}:{type:`edited`,message:e}}if(t.type===`permissions`&&t.id===a.id&&(a={id:a.id,permissions:t.permissions,maxMessageBytes:t.maxMessageBytes}),t.type===`claim`){l+=1;let e=t.claimed&&t.mailbox!==!1;t={type:`claim`,claimed:t.claimed,owner:t.owner,mailbox:e},s=t.claimed,o=t.owner,c=e?nc():null}for(let e of[...m])try{e(t)}catch{}},C=(e,t)=>{Promise.resolve(e.on(S)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===i&&x(e.reason)},()=>{})},w=async(e,l)=>{let f=sc(e,t);if(!f)return x(`unavailable`);let m=await f.join(n).catch(()=>void 0);if(p||l!==i)return;if(!m)return x(`unavailable`);if(`error`in m)return x(ac(m.error));if(m.self.id!==a.id)return Promise.resolve(m.leave()).catch(()=>{}),x(`unavailable`);r=m,a=m.self,o=m.owner,s=m.claimed,c=m.mailbox,C(m,l);let h=await m.defaults().catch(()=>void 0);if(h&&!p&&l===i&&(u=h),m.schemas!==!0)return;let g=await Promise.resolve(m.schema()).catch(()=>void 0);g!==void 0&&!p&&l===i&&(d=g)};_=Xa((e,t)=>{let n=i;i=t,!(p||n===0||n===t)&&(b(U(`unavailable`,Qs.unavailable)),w(e.rooms,t))}),C(e,i);let T=async e=>{if(p)throw U(`closed`,Qs.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});h.add(t);try{return await Promise.race([Promise.resolve(e(r)),n])}catch(e){throw $s(e)?e:U(`unavailable`,Qs.unavailable)}finally{h.delete(t)}},E=async e=>{let t=await T(e);if(`error`in t)throw U(t.error,t.message)},D=async e=>{let t=await T(e);if(typeof t==`object`&&t&&`error`in t)throw U(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:n,get self(){return a},get owner(){return o},get claimed(){return s},get mailbox(){return c},defaults:()=>u,members:()=>T(e=>e.members()),schema:()=>d,send:async(e,t)=>{if(t===void 0)return E(t=>t.send(e));let n=cc(t);return E(t=>dc(t).send(e,n))},edit:async(e,t,n)=>{if(n===void 0)return E(n=>n.edit(e,t));let r=cc(n);return E(n=>dc(n).edit(e,t,r))},setSchema:async e=>{let t=lc(e),n=f;await E(e=>dc(e).setSchema(t)),f===n&&(d=t)},delete:(e,t)=>E(n=>n.delete(e,t)),backlog:(e,t)=>D(n=>n.backlog(e,t)),setDefault:(e,t)=>E(n=>n.setDefault(e,t)),limit:(e,t)=>E(n=>n.limit(e,t)),grant:(e,t)=>E(n=>n.grant(e,t)),revoke:(e,t)=>E(n=>n.revoke(e,t)),remove:e=>E(t=>t.remove(e)),block:e=>E(t=>t.block(e)),unblock:e=>E(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw U(`invalid`,Qs.badDescription);let n=oc(e?.temporary);if(n===null)throw U(`invalid`,Qs.badTemporary);let r=e?.mailbox;if(r!==void 0&&typeof r!=`boolean`)throw U(`invalid`,Qs.malformed);let i={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n},...r===void 0?{}:{mailbox:r}};return Object.keys(i).length===0?E(e=>e.claim()):E(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw U(`unavailable`,Qs.temporaryUnavailable);if(r===!1&&e.mailboxSwitch!==!0)throw U(`unavailable`,Qs.mailboxUnavailable);return e.claim(i)})},setMailbox:async e=>{if(typeof e!=`boolean`)throw U(`invalid`,Qs.malformed);let t=l;await E(t=>{if(t.mailboxSwitch!==!0)throw U(`unavailable`,Qs.mailboxUnavailable);return t.setMailbox(e)}),l===t&&(e?c===null&&(c=nc()):c=null)},release:()=>E(e=>e.release()),usage:async()=>{let e=await D(e=>e.usage());return c=e,e},on:async e=>p?()=>{}:(m.add(e),()=>{m.delete(e)}),leave:async()=>{await Promise.resolve(r.leave()).catch(()=>{}),x(`left`)},closed:y}},mc=async(e,t,n)=>{let r=await rc();if(!r)throw U(`unavailable`,Qs.unavailable);let i=sc(r,e);if(!i)throw U(`unavailable`,Qs.guestUnavailable);let a=await n(i).catch(ic);if(`error`in a)throw U(a.error,a.message);if(t?.schema!==void 0&&a.schemas!==!0)throw await Promise.resolve(a.leave()).catch(()=>{}),U(`unavailable`,Qs.schemasUnavailable);return pc(a,e)},hc=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw U(`invalid`,Qs.badName);let n=fc(t),r=uc(t);return mc(n,r,t=>t.open(e,r))},gc=async e=>{let t=fc(e),n=uc(e);return mc(t,n,e=>e.create(n))},_c=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw U(`invalid`,Qs.inviteNoKey);return mc(fc(t),void 0,n=>n.join(e,t))},vc=new Map(Object.values(Zs).map(({code:e,message:t})=>[t,e])),yc=new Set(vc.values()),bc=(e,t)=>Object.assign(Error(t),{code:e}),xc=e=>bc(Zs[e].code,Zs[e].message),Sc=e=>e instanceof Error&&yc.has(e.code),Cc=e=>{if(Sc(e))return e;let t=e instanceof Error?e.message:``,n=vc.get(t);return n?bc(n,t):xc(`unavailable`)},wc=async()=>{if(!Pa)return;let e=(await Ya(`storage`).catch(()=>void 0))?.storage;return typeof e?.put==`function`?e:void 0},Tc=()=>{throw xc(`unavailable`)},Ec=e=>typeof e==`object`&&!!e&&typeof e.error==`string`&&typeof e.message==`string`,Dc=(e,t,n)=>{throw e.error===`aborted`?t?.reason??new DOMException(`The operation was aborted.`,`AbortError`):(e.error===`account-changed`&&n&&lo(n.generation),yc.has(e.error)?bc(e.error,e.message):xc(`unavailable`))},Oc=async e=>{try{return await ts(e)}catch(e){throw Go(e)?xc(`accountChanged`):e instanceof Error&&/not connected|not signed in/i.test(e.message)?xc(`needsAccount`):xc(`unavailable`)}},kc=(e,t)=>(e.catch(()=>{}),t?Promise.race([e,new Promise((e,n)=>t.addEventListener(`abort`,()=>n(t.reason),{once:!0}))]):e),Ac=async(e,t={})=>{let n=Jo(),{signal:r,onProgress:i,key:a}=t;r?.throwIfAborted();let o=typeof Blob<`u`&&e instanceof Blob,s=typeof ReadableStream<`u`&&e instanceof ReadableStream;if(!o&&!s)throw xc(`notAFile`);let c=o?e.size:t.size;if(typeof c!=`number`||!Number.isSafeInteger(c)||c<0||o&&t.size!==void 0&&t.size!==c)throw xc(`badSize`);let l=await wc();if(!l)throw xc(`unavailable`);let u=await Oc(n);r?.throwIfAborted();let d=await kc(Promise.resolve(l.put(e,{size:c,...a===void 0?{}:{key:a},accountPin:u,...r?{signal:r}:{},...typeof i==`function`?{onProgress:e=>{try{i(e)}catch{}}}:{}})).catch(Tc),r);return Ec(d)?Dc(d,r,n):d},jc=(e,t,n)=>{let r=(t,n)=>{if(t===void 0)return n;let r=Math.trunc(Number.isFinite(t)?t:t>0?e:-e);return r<0?Math.max(e+r,0):Math.min(r,e)},i=r(t,0);return{from:i,to:Math.max(i,r(n,e))}},Mc=async(e,t,n={})=>{if(typeof e!=`string`)throw xc(`badUrl`);if(typeof t!=`string`)throw xc(`badKey`);let{signal:r}=n;r?.throwIfAborted();let i=async()=>{let n=await wc();if(!n)throw xc(`unavailable`);let i=Za()?.epoch,a=await kc(Promise.resolve(n.get(e,t,r?{signal:r}:void 0)).catch(Tc),r);return Ec(a)?Dc(a,r):{handle:a,epoch:i}},a=await i(),o=async()=>{let e=Za()?.epoch;return a.epoch!==void 0&&e!==void 0&&e!==a.epoch&&(a=await i()),a.handle},s=(e,t)=>{let n;return new ReadableStream({pull:async r=>{try{if(!n){let r=await o(),i=await Promise.resolve(r.read(e,t)).catch(Tc);if(Ec(i))return Dc(i);n=i.getReader()}let{value:i,done:a}=await n.read();a?r.close():r.enqueue(i)}catch(e){throw Cc(e)}},cancel:e=>n?.cancel(e)},{highWaterMark:0})},c=(e,t)=>({size:t-e,stream:()=>s(e,t),arrayBuffer:async()=>{let n=new Uint8Array(t-e),r=s(e,t).getReader(),i=0;for(;;){let{value:e,done:t}=await r.read();if(t)break;n.set(e,i),i+=e.length}return n.buffer},slice:(n,r)=>{let i=jc(t-e,n,r);return c(e+i.from,e+i.to)}});return c(0,a.handle.size)},Nc=async(e={})=>{let t=Jo(),n=await wc();if(!n)throw xc(`unavailable`);let r=await Oc(t),{limit:i,cursor:a}=e,o=await Promise.resolve(n.list({accountPin:r,...i===void 0?{}:{limit:i},...a===void 0?{}:{cursor:a}})).catch(Tc);return Ec(o)?Dc(o,void 0,t):o},Pc=async e=>{let t=Jo();if(typeof e!=`string`)throw xc(`badUrl`);let n=await wc();if(!n)throw xc(`unavailable`);let r=await Oc(t),i=await Promise.resolve(n.delete(e,{accountPin:r})).catch(Tc);Ec(i)&&Dc(i,void 0,t)},W,Fc,Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc,Wc=Symbol.for(`pv`),Gc={},Kc=[],qc=/^m(i|n|o|s|text|space)$/,Jc=Array.isArray,Yc=Kc.slice,Xc=Object.assign;function Zc(e){e&&e.parentNode&&e.remove()}function Qc(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:Wc,__v:i||++Fc,__i:-1,__u:0};return!i&&W.vnode&&W.vnode(a),a}function G(e){return e.children}function $c(e,t){this.props=e,this.context=t,this.__g=0}function el(e,t){if(t==null)return e.__&&el(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:el(e)}function tl(e){var t,n=e.__v,r=n.__e,i=[],a=[],o=e.__P;o&&((t=Xc({constructor:Wc},n)).__v=n.__v+1,W.vnode&&W.vnode(t),pl(o,t,n,e.__n,o.namespaceURI,32&n.__u?[r]:null,i,r||el(n),32&n.__u,a),t.__v=n.__v,t.__.__k[t.__i]=t,gl(i,t,a),n.__=n.__e=null,t.__e!=r&&nl(t))}function nl(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),nl(e)}function rl(e){(8&e.__g||(e.__g|=8,Ic.push(e),Rc++))&&Lc==W.debounceRendering||((Lc=W.debounceRendering)||queueMicrotask)(il)}function il(){try{for(var e,t=1;Ic.length;)Ic.length>t&&Ic.sort(zc),e=Ic.shift(),t=Ic.length,8&e.__g&&tl(e)}finally{(Rc=Ic.length)&&(Lc||queueMicrotask)(il)}}function al(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r.__k||Kc,v=t.length;for(c=ol(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=~p.__i&&_[p.__i]||Gc,p.__i=d,g=pl(e,p,f,i,a,o,s,c,l,u),m=p.__e,(f.ref!=p.ref||8&f.__u)&&(f.ref&&vl(f.ref,null,p,f),p.ref&&u.push(p.ref,p.__c||m,p)),h||=m,4&p.__u?(c=sl(p,c,e,!f.__v),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-21);return n.__e=h,c}function ol(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,m=n.length,h=m,g=0,_=0,v=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor===String?o=v[a]=Qc(null,o):Jc(o)?o=v[a]=Qc(G,{children:o}):o.constructor===Wc&&o.__b?o=v[a]=Qc(o.type,o.props,o.key,o.ref,o.__v):v[a]=o,c=a+g,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=ll(o,n,c,h))&&(h--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?g--:l==c+1?g++:l!=c&&(l>c?g--:g++,_=1)):(~l||(i>m?g--:i<m&&g++),typeof o.type!=`function`&&(o.__u|=4))):v[a]=null;if(_){for(u=[],d=[],a=0;a<i;a++)if((o=v[a])&&16&o.__u){for(g=0,f=u.length;g<f;)u[p=g+f>>1]<o.__i?g=p+1:f=p;u[g]=o.__i,d[a]=g+1}for(g=u.length;a--;)d[a]&&(d[a]==g?g--:v[a].__u|=4)}if(h)for(a=0;a<m;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=el(s)),yl(s,s));return r}function sl(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=sl(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=el(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function cl(e,t){return t||=[],e!=null&&typeof e!=`boolean`&&(Jc(e)?e.some(function(e){cl(e,t)}):t.push(e)),t}function ll(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function ul(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function dl(e,t,n,r,i){var a,o;if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ul(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||ul(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)typeof n!=`function`&&(n=null),typeof r!=`function`&&(r=null),(e.__e||={})[t]=n,n&&r||(o=Uc[t]||(Uc[t]=fl(t)),(e.__a||={})[t]=Hc,a=t!=(t=t.replace(Vc,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function fl(e){return function(t){var n=this.__e;if(n){if(n=n[e],t[Bc]==null)t[Bc]=Hc++;else if(t[Bc]<this.__a[e])return;return n(W.event?W.event(t):t)}}}function pl(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t.type;if(t.constructor!==Wc)return null;128&n.__u&&(c=32&n.__u,u=n.__c.__z)&&(t.__u|=c,d=a=[],u.nodeType==8?s=ml(u,a):a.push(u),s=a[0]||s),(u=W.__b)&&u(t);n:if(typeof O==`function`){f=o.length;try{if(_=t.props,v=(u=O.prototype)&&u.render,y=(u=O.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,(p=n.__c)?(t.__c=p,2&p.__g&&(p.__g|=1)):(v?t.__c=p=new O(_,b):(t.__c=p=new $c(_,b),p.constructor=O,p.render=bl),y&&y.sub(p),p.state||(p.state={}),p.__n=r,p.__g|=8,p.__h=[],p.__k=[]),v&&(p.__s||(p.__s=p.state),O.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=Xc({},p.__s)),Xc(p.__s,O.getDerivedStateFromProps(_,p.__s)))),m=p.props,h=p.state,p.__v=t,n.__c){if(_!==m&&v&&!O.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(_,b),t.__v==n.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(_,p.__s,b)){t.__v!=n.__v&&(p.props=_,p.state=p.__s,p.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Kc.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&o.push(p),s=el(n);break n}p.componentWillUpdate&&p.componentWillUpdate(_,p.__s,b),v&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}else v&&!O.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),v&&p.componentDidMount&&p.__h.push(p.componentDidMount);p.context=b,p.props=_,p.__P=e,p.__g&=-5,x=W.__r,S=v?25:0;do p.__g&=-9,x&&x(t),u=p.render(p.props,p.state=p.__s,p.context);while(8&p.__g&&++S<25);v&&(Kc.push.apply(p.__h,p.__k),p.__k=[]),p.state=p.__s,p.getChildContext&&(r=Xc({},r,p.getChildContext())),v&&n.__c&&p.getSnapshotBeforeUpdate&&(g=p.getSnapshotBeforeUpdate(m,h)),C=u&&u.type===G&&u.key==null?u.props.children:u,_.__P&&(u=s,i=(e=_.__P).namespaceURI,c=a=null,n.props&&n.props.__P!=e&&(n.__k.some(function(e){e&&yl(e,e)}),n.__k=null),s=n.__k?el(n,0):null),s=al(e,Jc(C)?C:[C],t,n,r,i,a,o,s,c,l),_.__P&&(t.__e=null,s=u),t.__u&=-161,d&&d.some(Zc),p.__h.length&&o.push(p),1&p.__g&&(p.__g&=-4)}catch(e){if(o.length=f,t.__v=null,c||a){if(e&&e.then){if(t.__u|=128|c,a){for(~(E=a.indexOf(s||void 0))||(E=a.length);(D=a[E-1])&&D.nodeType==8;)E--;for(;E<a.length;E++)if(D=a[E]){if(a[E]=null,w){if(D==T)break}else{if(D.nodeType!=8)break;D.data.startsWith(`$s`)&&(T=ml(w=D))}}}if(!w){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;w=s}(u=ml(w=t.__c.__z||(t.__c.__z=w)))?(t.__e=w,s=u):t.__e=s,s&&=s.nextSibling}else a&&a.some(Zc)}else t.__e=n.__e;t.__k||=n.__k||[],e&&e.then||hl(t),W.__e(e,t,n)}}else s=t.__e=_l(n.__e,t,n,r,i,a,o,c,l,e);return(u=W.diffed)&&u(t),s}function ml(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function hl(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(hl))}function gl(e,t,n){for(var r=0;r<n.length;)vl(n[r++],n[r++],n[r++]);W.__c&&W.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){W.__e(e,t.__v)}})}function _l(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props||Gc,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a){for(u=0;u<a.length;u++)if((m=a[u])&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(!e){if(_=l.ownerDocument||document,!b)return _.createTextNode(y);e=_.createElementNS(i,b,y.is?y:l),s&&=(W.__m&&W.__m(t,a),!1),a=null}if(b){if(l=b==`template`&&e.content||e,a=b==`textarea`&&y.defaultValue!=null?null:a&&Yc.call(l.childNodes),!s&&a)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)m=v[u],u==`dangerouslySetInnerHTML`?f=m:u==`children`||u in y||u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y||dl(e,u,null,m,i);for(u in y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m||dl(e,u,m,v[u],i);d?(s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[]):(f&&(e.textContent=``),(b==`foreignObject`||i==`http://www.w3.org/1998/Math/MathML`&&qc.test(b))&&(i=`http://www.w3.org/1999/xhtml`),al(l,Jc(p)?p:[p],t,n,r,i,a,o,a?a[0]:n.__k&&el(n,0),s,c),a&&a.some(Zc)),s&&b!=`textarea`||(u=`value`,b==`progress`&&h==null?e.removeAttribute(u):h==null||h===e[u]&&(b!=`progress`||h)||dl(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&dl(e,u,g,v[u],i))}else v===y||s&&e.data==y||(e.data=y);return e}function vl(e,t,n,r){try{typeof e==`function`?t?t.__x=e(t)||1:(r&&=r.__c||r.__e)&&(t=r.__x)&&(r.__x=null,typeof t==`function`?t():e(null)):e.current=t}catch(e){W.__e(e,n)}}function yl(e,t,n){var r,i,a,o;if(W.unmount&&W.unmount(e),!(r=e.ref)||r.current&&r.current!=e.__e||vl(r,null,t,e),r=e.__c){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){W.__e(e,t)}r.__P=r.__n=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&yl(r[o],t,typeof e.type!=`function`||n&&!e.props.__P);!n&&(r=e.__c)&&(r=r.__z)&&(i=ml(r,a=[]))&&(r==e.__e&&a.some(Zc),Zc(i),Zc(r)),n||Zc(e.__e),e.__e=e.__c=e.__=null}function bl(e,t,n){return this.constructor(e,n)}function xl(e,t){var n,r,i,a;W.__&&W.__(e,t),t.nodeType==9&&(t=t.documentElement),r=(n=e&&32&e.__u)?null:t.__k,t.__k=Qc(G,{children:[e]}),i=[],a=[],pl(t,t.__k,r||Gc,Gc,t.namespaceURI,r?null:t.firstChild?Yc.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a),gl(i,t.__k,a),t.__k.props.children=null}W={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=(a=i.constructor)&&a.getDerivedStateFromError)&&i.setState(a.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),o=1),o&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw Rc=0,e}},Fc=0,$c.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=Xc({},this.state)),typeof e==`function`&&(e=e(Xc({},n),this.props)),e&&(Xc(n,e),this.__v&&(t&&this.__k.push(t),rl(this)))},$c.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),rl(this))},$c.prototype.render=G,Ic=[],Rc=0,zc=function(e,t){return e.__v.__b-t.__v.__b},Bc=Symbol(),Vc=/(PointerCapture)$|Capture$/i,Hc=0,Uc={};var Sl,Cl,wl,Tl,El=Object.is,Dl=0,Ol=[],kl=[],Al=W,jl=Al.__b,Ml=Al.__r,Nl=Al.diffed,Pl=Al.__c,Fl=Al.unmount,Il=Al.__;function Ll(e,t){Al.__h&&Al.__h(Cl,e,Dl||t),Dl=0;var n=Cl.__H||(Cl.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Dl=1,Rl(Xl,e)}function Rl(e,t,n){var r=Ll(Sl++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Xl(void 0,t),function(e){var t=(r.__N||r.__)[0],n=r.t(t,e);El(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Cl,!Cl.__f)){Cl.__f=!0;var i=Cl.shouldComponentUpdate;Cl.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,El(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function zl(e,t){var n=Ll(Sl++,3);!Al.__s&&Yl(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,Cl.__H.__h.push(n))}function Bl(e,t){var n=Ll(Sl++,4);!Al.__s&&Yl(n.__H,t)&&(n.__P=!1,n.__=e,n.u=t,Cl.__h.push(n))}function q(e){return Dl=5,Vl(function(){return{current:e}},[])}function Vl(e,t){var n=Ll(Sl++,7);return Yl(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Hl(e,t){return Dl=8,Vl(function(){return e},t)}function Ul(){var e;do{for(;e=kl.shift();)try{ql(e)}catch(t){Al.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=Ol.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ql),t.__h.some(Jl),t.__h=[]}catch(n){t.__h=[],Al.__e(n,e.__v)}}}while(kl.length)}Al.__b=function(e){Cl=null,jl&&jl(e)},Al.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Il&&Il(e,t)},Al.__r=function(e){Ml&&Ml(e),Sl=0;var t=(Cl=e.__c).__H;t&&(wl==Cl?Cl.__h=[]:(t.__h.some(ql),t.__h.some(Jl),Sl=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),wl=Cl},Al.diffed=function(e){Nl&&Nl(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Kl(Ol.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),wl=Cl=null},Al.__c=function(e,t){t.some(function(e){try{e.__h.some(ql),e.__h=e.__h.filter(function(e){return!e.__||Jl(e)})}catch(t){e.__h=[function(){throw t}]}}),Pl&&Pl(e,t)},Al.unmount=function(e){Fl&&Fl(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Kl(kl.push(r))}else ql(r)}catch(e){t=e}}),r.__H=void 0,t&&Al.__e(t,r.__v))};var Wl=typeof requestAnimationFrame==`function`;function Gl(e){var t,n=function(){clearTimeout(r),Wl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Wl&&(t=requestAnimationFrame(n))}function Kl(e){e!=1&&Tl==Al.requestAnimationFrame||((Tl=Al.requestAnimationFrame)||Gl)(Ul)}function ql(e){var t=Cl,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Cl=t}function Jl(e){var t=Cl;e.__c=e.__(),Cl=t}function Yl(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!El(t,e[n])})}function Xl(e,t){return typeof t==`function`?t(e):t}var Zl=Object.assign,Ql=/^(-|f[lo].*[^se]$|g.{5,}[^ps]$|z|o[pr]|(W.{5})?[lL]i.*(t|mp)$|an|(bo|s).{4}Im|sca|m.{6}[ds]|ta|c.*[st]$|wido|ini|asp|fill|st)/,$l=Symbol.for(`react.element`),eu=/^(?: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]/,tu=/[A-Z0-9]/g,nu=typeof document<`u`,ru=function(e){return/fil|che|rad/.test(e)};function iu(e,t,n){return t.__k??(t.textContent=``),xl(e,t),typeof n==`function`&&n(),e?e.__c:null}$c.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty($c.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var au=W.event;W.event=function(e){return au&&(e=au(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var ou={configurable:!0,get:function(){return this.class}},su=W.vnode;W.vnode=function(e){if(typeof e.type==`string`)(function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a==`value`&&`defaultValue`in t&&o==null||nu&&a==`children`&&n==`noscript`||a==`class`||a==`className`)){if(a==`style`&&o&&o.constructor==Object){var s=void 0;for(var c in o)typeof o[c]!=`number`||Ql.test(c)||(s||=o=Zl({},o),o[c]+=`px`)}else if(a==`defaultValue`&&`value`in t&&t.value==null)a=`value`;else if(a==`download`&&!0===o)o=``;else if(a==`translate`&&o===`no`)o=!1;else if(a[0]==`o`&&a[1]==`n`){var l=a.toLowerCase();l==`ondoubleclick`?a=`ondblclick`:l!=`onchange`||n!=`input`&&n!=`textarea`||ru(t.type)?l==`onfocus`?a=`onfocusin`:l==`onblur`&&(a=`onfocusout`):l=a=`oninput`,l==`oninput`&&r[a=l]&&(a=`oninputCapture`)}else i&&eu.test(a)?a=a.replace(tu,`-$&`).toLowerCase():o===null&&(o=void 0);r[a]=o}}if(n==`select`){var u=r.defaultValue==null?r.multiple&&Array.isArray(r.value)?r.value:null:r.defaultValue;u!=null&&(r.value=cl(t.children).forEach(function(e){e.props.selected=r.multiple?u.indexOf(e.props.value)!=-1:u==e.props.value}))}t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,"className",ou)):t.className&&(r.class=r.className=t.className),e.props=r})(e);else if(typeof e.type==`function`&&(`ref`in e.props&&`prototype`in e.type&&e.type.prototype.render&&(e.ref=e.props.ref,delete e.props.ref),e.type.defaultProps)){var t=Zl({},e.props);for(var n in e.type.defaultProps)t[n]===void 0&&(t[n]=e.type.defaultProps[n]);e.props=t}e.ref&&!(`ref`in e.props)&&Object.defineProperty(e.props,"ref",{value:e.ref,configurable:!0,writable:!0}),e.$$typeof=$l,su&&su(e)};function cu(e){return!!e.__k&&(xl(null,e),!0)}function lu(e){return{render:function(t){iu(t,e)},unmount:function(){cu(e)}}}var uu={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1},du=uu.VITE_SOCIAL_SITE??`https://social.fkn.app`;uu.VITE_SOCIAL_PACKAGE,uu.VITE_FKN_ORIGIN;var J=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},Y=e=>{if(!/^[A-Za-z0-9_-]*$/.test(e))return null;let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`);try{let e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}catch{return null}},fu=e=>e<=31||e>=127&&e<=159||e>=8234&&e<=8238||e>=8294&&e<=8297,pu=(e,{max:t,multiline:n})=>{if(e.normalize(`NFC`)!==e)return`characters`;let r=0;for(let t of e){if(fu(t.codePointAt(0))&&!(n&&t===`
|
|
4
|
+
`))return`characters`;r+=1}return r>t?`too-long`:null},mu=(e,t=200)=>{let n;try{n=new URL(e.trim())}catch{return null}return n.protocol===`https:`&&n.href.length<=t?n.href:null},hu={started:`Started`,watched:`Watched`,completed:`Finished`,rated:`Rated`},gu=Object.keys(hu),_u=36e5,vu={public:[],friends:[]},yu=/^[A-Za-z0-9_-]{22}$/,bu=RegExp(`^[\\x20-\\x7e]{1,64}$`),xu=(e,t)=>typeof e==`string`&&e!==``&&e.isWellFormed()&&pu(e,{max:t,multiline:!1})===null,Su=e=>typeof e==`string`&&mu(e,300)===e,Cu=e=>{try{return new URL(e)}catch{return null}},wu=e=>xu(e,100),Tu=e=>{let t=Cu(e);return t!==null&&(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e?t.host:e},Eu=(e,t)=>{let n=Cu(t);return n?.protocol!==`https:`||n.origin!==t||Cu(e)?.origin===t},Du=({id:e,app:t,at:n,kind:r,title:i,link:a,detail:o,image:s,subject:c})=>({id:e,app:t,at:n,kind:r,title:i,link:a,...o===void 0?{}:{detail:o},...s===void 0?{}:{image:s},...c===void 0?{}:{subject:c}}),Ou=e=>{if(typeof e!=`object`||!e)return null;let{id:t,app:n,at:r,kind:i,title:a,detail:o,link:s,image:c,subject:l}=e;return typeof t!=`string`||!yu.test(t)||!xu(n,100)||typeof r!=`number`||!Number.isSafeInteger(r)||r<0||typeof i!=`string`||!Object.hasOwn(hu,i)||!xu(a,150)||!Su(s)||!Eu(s,n)||o!==void 0&&!xu(o,40)||c!==void 0&&!Su(c)||l!==void 0&&(typeof l!=`string`||!bu.test(l))?null:Du({id:t,app:n,at:r,kind:i,title:a,link:s,detail:o,image:c,subject:l})},ku=e=>typeof e==`string`?e.normalize(`NFC`).trim():e,Au=(e,t,n)=>{if(typeof e!=`object`||!e)return null;let{kind:r,title:i,detail:a,link:o,image:s,subject:c}=e,l=ku(a),u=e=>typeof e==`string`?mu(e,300)??``:e;return Ou({id:J(crypto.getRandomValues(new Uint8Array(16))),app:t,at:n,kind:r,title:ku(i),link:u(o),...l===void 0||l===``?{}:{detail:l},...s===void 0?{}:{image:u(s)},...c===void 0?{}:{subject:c}})},ju=e=>{if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){let e=Ou(r);if(!(e===null||t.has(e.id))&&(t.add(e.id),n.push(e),n.length===50))break}return n},Mu=(e,t)=>{let n=new Map;for(let r of[...e,...t])n.has(r.id)||n.set(r.id,r);return[...n.values()].sort((e,t)=>t.at-e.at||(e.id<t.id?-1:+(e.id>t.id))).slice(0,50)},Nu=(e,t,n)=>[...e.public,...e.friends].filter(e=>e.app===t&&e.at>n).length,Pu=(e,t)=>({...e,public:e.public.filter(e=>!t.includes(e.id)),friends:e.friends.filter(e=>!t.includes(e.id))}),Fu=(e,t)=>({...e,public:e.public.filter(e=>e.app!==t),friends:e.friends.filter(e=>e.app!==t)}),Iu=(e,t)=>({...e,public:e.public.filter(e=>e.app!==t),friends:Mu(e.friends,e.public.filter(e=>e.app===t))}),Lu=(e,t)=>[t,...e.filter(e=>e.id!==t.id)].slice(0,50),Ru=(e,t)=>t===`off`?{...e,public:[],friends:[]}:t===`friends`?{...e,public:[],friends:Mu(e.friends,e.public)}:e,zu=BigInt(2**32-1),Bu=BigInt(32);function Vu(e,t=!1){return t?{h:Number(e&zu),l:Number(e>>Bu&zu)}:{h:Number(e>>Bu&zu)|0,l:Number(e&zu)|0}}function Hu(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=Vu(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var Uu=e=>e/2**32|0,Wu=e=>e>>>0;function Gu(e,t,n,r){let i=Uu(n),a=Wu(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}var Ku=(e,t,n)=>e>>>n,qu=(e,t,n)=>e<<32-n|t>>>n,Ju=(e,t,n)=>e>>>n|t<<32-n,Yu=(e,t,n)=>e<<32-n|t>>>n,Xu=(e,t,n)=>e<<64-n|t>>>n-32,Zu=(e,t,n)=>e>>>n-32|t<<64-n;function Qu(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var $u=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ed=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,td=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),nd=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,rd=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),id=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;function ad(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var od=e=>e?`"${e}" `:``;function sd(e,t=``){if(typeof e!=`number`)throw TypeError(od(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(od(t)+`expected integer >= 0, got `+e);return e}function cd(e,t,n=``){if(ad(e)&&(t===void 0||e.length===t))return e;t!==void 0&&sd(t,`length`);let r=ad(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=od(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function ld(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(sd(e.outputLen),sd(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var ud=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},dd=(e,t)=>{ud(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function fd(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function pd(e,t){cd(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function md(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function hd(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function gd(e,t){return e<<32-t|e>>>t}var _d=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,vd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function yd(e){if(cd(e),_d)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=vd[e[n]];return t}function bd(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function xd(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(_d)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=bd(e.charCodeAt(i)),a=bd(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Sd(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];cd(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function Cd(e,t,n=`opts`){return dd(e,`defaults`),t!==void 0&&dd(t,n),Object.assign(Object.create(null),e,t)}function wd(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=Cd({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Td(e=32){sd(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Ed=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Dd(e,t,n){return e&t^~e&n}function Od(e,t,n){return e&t^e&n^t&n}var kd=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=hd(this.buffer)}update(e){fd(this),cd(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=hd(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){fd(this),pd(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),Gu(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:hd(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},Ad=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jd=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Md=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Nd=new Uint32Array(64),Pd=class extends kd{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)Nd[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Nd[e-15],n=Nd[e-2],r=gd(t,7)^gd(t,18)^t>>>3,i=gd(n,17)^gd(n,19)^n>>>10;Nd[e]=i+Nd[e-7]+r+Nd[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=gd(o,6)^gd(o,11)^gd(o,25),u=l+t+Dd(o,s,c)+Md[e]+Nd[e]|0,d=(gd(n,2)^gd(n,13)^gd(n,22))+Od(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){md(Nd)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),md(this.buffer)}},Fd=class extends Pd{constructor(){super(32,Ad)}},Id=Hu(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Ld=Id[0],Rd=Id[1],zd=new Uint32Array(80),Bd=new Uint32Array(80),Vd=class extends kd{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=t[0]|0,this.Al=t[1]|0,this.Bh=t[2]|0,this.Bl=t[3]|0,this.Ch=t[4]|0,this.Cl=t[5]|0,this.Dh=t[6]|0,this.Dl=t[7]|0,this.Eh=t[8]|0,this.El=t[9]|0,this.Fh=t[10]|0,this.Fl=t[11]|0,this.Gh=t[12]|0,this.Gl=t[13]|0,this.Hh=t[14]|0,this.Hl=t[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)zd[n]=e.getUint32(t),Bd[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=zd[e-15]|0,n=Bd[e-15]|0,r=Ju(t,n,1)^Ju(t,n,8)^Ku(t,n,7),i=Yu(t,n,1)^Yu(t,n,8)^qu(t,n,7),a=zd[e-2]|0,o=Bd[e-2]|0,s=Ju(a,o,19)^Xu(a,o,61)^Ku(a,o,6),c=td(i,Yu(a,o,19)^Zu(a,o,61)^qu(a,o,6),Bd[e-7],Bd[e-16]),l=nd(c,r,s,zd[e-7],zd[e-16]);zd[e]=l|0,Bd[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Ju(u,d,14)^Ju(u,d,18)^Xu(u,d,41),v=Yu(u,d,14)^Yu(u,d,18)^Zu(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=rd(_,v,b,Rd[e],Bd[e]),S=id(x,g,t,y,Ld[e],zd[e]),C=x|0,w=Ju(n,r,28)^Xu(n,r,34)^Xu(n,r,39),T=Yu(n,r,28)^Zu(n,r,34)^Zu(n,r,39),E=n&i^n&o^i&o,D=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Qu(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let O=$u(C,T,D);n=ed(O,S,w,E),r=O|0}({h:n,l:r}=Qu(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Qu(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Qu(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Qu(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Qu(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Qu(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Qu(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Qu(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){md(zd,Bd)}destroy(){this.destroyed=!0,md(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Hd=class extends Vd{constructor(){super(64,jd)}},Ud=wd(()=>new Fd,Ed(1)),Wd=wd(()=>new Hd,Ed(3)),Gd=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,Kd=e=>{let t=0,n=0,r=``;for(let i of e)for(n=n<<8|i,t+=8;t>=5;)r+=Gd[n>>>t-5&31],t-=5;return t>0&&(r+=Gd[n<<5-t&31]),r},qd=e=>[...e].every(e=>Gd.includes(e)),Jd=e=>e.toUpperCase().replaceAll(`O`,`0`).replaceAll(`I`,`1`).replaceAll(`L`,`1`).replace(/[^0-9A-Z]/g,``),Yd=e=>{let t=0,n=0,r=[];for(let i of e){let e=Gd.indexOf(i);if(e<0)return null;n=n<<5|e,t+=5,t>=8&&(r.push(n>>>t-8&255),t-=8)}return t>0&&n&(1<<t)-1?null:new Uint8Array(r)},Xd=/^[a-z0-9]+(?:_[a-z0-9]+)*$/,Zd=new Set(`a.admin.administrator.anonymous.deleted.e.everyone.guest.help.here.i.index.me.mod.moderator.null.official.root.security.social.staff.support.system.team.u.undefined.unknown.you`.split(`.`)),Qd=e=>e.trim().replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32)),$d=e=>{let t=Qd(e);return t.length===0?{ok:!1,reason:`empty`}:Xd.test(t)?t.length<3?{ok:!1,reason:`too-short`}:t.length>20?{ok:!1,reason:`too-long`}:t.startsWith(`fkn`)||Zd.has(t)?{ok:!1,reason:`reserved`}:{ok:!0,name:t}:{ok:!1,reason:`characters`}},ef=e=>{let t=$d(e);return t.ok&&t.name===e},tf=e=>J(Ud(e)),nf=e=>Kd(Ud(e)).slice(0,16),rf=(e,t)=>`${e}#${nf(t)}`,af=e=>Kd(Ud(e)).slice(0,24).match(/.{4}/g)?.join(`-`)??``,of=1e3,sf=/^[A-Za-z0-9_-]{43}$/,cf=e=>{if(e===null)return null;if(typeof e!=`object`)return;let{url:t,key:n}=e;return typeof t==`string`&&t.length<=200&&typeof n==`string`&&sf.test(n)?{url:t,key:n}:void 0},lf=e=>{let t=e.profile.visibility?.value.level;return t===`me`||t===`public`?{level:t}:{level:`friends`}},uf=e=>pu(e,{max:32,multiline:!1})===null,df=e=>pu(e,{max:of,multiline:!0})===null,ff=e=>{let t=e.displayName.normalize(`NFC`).trim();if(!uf(t))return{ok:!1,reason:`display-name`};let n=e.bio.normalize(`NFC`).replaceAll(`\r
|
|
5
|
+
`,`
|
|
6
|
+
`).trim();if(!df(n))return{ok:!1,reason:`bio`};let r=e.links.map(e=>e.trim()).filter(e=>e!==``);if(r.length>5)return{ok:!1,reason:`links`};let i=[];for(let[e,t]of r.entries()){let n=mu(t);if(n===null)return{ok:!1,reason:`link`,index:e};i.push(n)}return{ok:!0,profile:{displayName:t,bio:n,links:i}}},pf=e=>{let{displayName:t,bio:n,links:r}=e.profile;return{displayName:t?.value??``,bio:n?.value??``,links:r?.value??[],version:Math.max(0,...Object.values(e.profile).map(e=>e?.lamport??0))}},mf=e=>{let t=pf(e);return lf(e).level===`me`?{displayName:``,bio:``,links:[],version:t.version}:t},hf=e=>{if(typeof e!=`object`||!e)return null;let{displayName:t,bio:n,links:r,version:i}=e;return typeof t!=`string`||!uf(t)||typeof n!=`string`||!df(n)||!Array.isArray(r)||r.length>5||!r.every(e=>typeof e==`string`&&mu(e)===e)||typeof i!=`number`||!Number.isSafeInteger(i)||i<0?null:{displayName:t,bio:n,links:r,version:i}},gf=(e,t)=>e!==null&&t.version<=e.version?e:t,_f=new TextDecoder,vf=e=>({list:async()=>(await e.list()).map(({path:e,updatedAt:t})=>({path:e,updatedAt:Date.parse(t)})),read:async t=>{try{return _f.decode((await e.readFileSealed(t)).data)}catch(n){if(!e.isNotFound(n))throw n;if((await e.list()).some(e=>e.path===t))throw Error(`social: ${t} is listed, but reading it found nothing`,{cause:n});return null}},write:(t,n)=>e.writeFile(t,n),remove:t=>e.unlink(t)}),yf=[`fkn:e2e-stale-epoch`,`fkn:e2e-integrity`,`fkn:e2e-retired-format`],bf=`FKN_E2E_LOCKED`,xf=e=>{let t=e instanceof Error?e.message:String(e);return yf.some(e=>t.includes(e))?`reset`:e?.code===bf||t.includes(`fkn:e2e-locked`)?`locked`:`unreachable`},Sf=(e,t)=>e.lamport===t.lamport?e.by>t.by:e.lamport>t.lamport,Cf=(e,t)=>Sf(e,t)?e:t,wf=(e,t)=>{let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=t===void 0?r:Cf(t,r)}return n},Tf=e=>{let t=0;for(let n of e)n.lamport>t&&(t=n.lamport);return t+1},Ef=()=>({v:2,profile:{},friends:{},apps:{},seen:{}}),Df=(e,t)=>wf(e,t),Of=(e,t)=>{let n=e.friends,r=e.profile,i=e.apps;for(let e of t)n=wf(n,e.friends),r=Df(r,e.profile),i=wf(i,e.apps);return{v:2,profile:r,friends:n,apps:i,seen:e.seen}},kf=e=>[...Object.values(e.friends),...Object.values(e.profile).filter(e=>e!==void 0),...Object.values(e.apps)],Af=(e,t)=>({lamport:Tf(kf(e)),by:t}),jf=e=>Object.entries(e.friends).filter(([,e])=>e.value.state===`active`).map(([e,t])=>({...t.value,fingerprint:e})).sort((e,t)=>e.fingerprint.localeCompare(t.fingerprint)),Mf=(e,t)=>t.filter(({writerId:t,updatedAt:n})=>{let r=e.seen[t];return r===void 0||r.updatedAt!==n}).map(({writerId:e})=>e),Nf=`v1/roster.json`,Pf=e=>`v1/w/${e}.json`,Ff=`v1/w/`,If=e=>{if(e===null)return null;try{return JSON.parse(e)}catch{return null}},Lf=e=>e.startsWith(Ff)&&e.endsWith(`.json`)?e.slice(5,-5):null,Rf=`social: the friend list was saved by a newer FKN Social`,zf=e=>{let{v:t,apps:n}=e;if(t!==1&&t!==2)throw Error(Rf);return{...e,v:2,apps:t===2?n??{}:{}}},Bf=async e=>{let[t,n]=await Promise.all([e.list(),e.read(Nf)]),r=t.map(({path:e,updatedAt:t})=>({writerId:Lf(e),updatedAt:t})).filter(e=>e.writerId!==null),i=zf(If(n)??Ef()),a=Mf(i,r);return{roster:i,cells:(await Promise.all(a.map(t=>e.read(Pf(t))))).map(e=>If(e)).filter(e=>e!==null).map(zf),listed:r}},Vf=e=>Of(e.roster,e.cells),Hf=e=>({v:2,by:e,friends:{},profile:{},apps:{}}),Uf=async(e,t,n,r)=>{let i=Of(t.roster,[...t.cells,n]),a=r(Af(i,n.by),n,i);return await e.write(Pf(n.by),JSON.stringify(a)),a},Wf=async(e,t)=>{let n=Vf(t),r={...n.seen};for(let{writerId:e,updatedAt:n}of t.listed){let i=t.cells.find(t=>t.by===e);r[e]={lamport:i===void 0?r[e]?.lamport??0:Math.max(0,...Object.values(i.friends).map(e=>e.lamport)),updatedAt:n}}let i={v:2,profile:n.profile,friends:n.friends,apps:n.apps,seen:r};return await e.write(Nf,JSON.stringify(i)),If(await e.read(`v1/roster.json`))??i},Gf=async(e,t,n)=>{let r=await Bf(e),i=If(await e.read(Pf(t))),a=await Uf(e,r,i===null?Hf(t):zf(i),n);try{let t=await Bf(e);return await Wf(e,t),Vf(t)}catch{return Of(r.roster,[...r.cells,a])}},Kf=e=>e instanceof Error&&e.message===`social: the friend list was saved by a newer FKN Social`?`newer`:xf(e),qf=async({cloud:e})=>{try{return{ok:!0,roster:Vf(await Bf(e))}}catch(e){return{ok:!1,reason:Kf(e)}}},Jf=async({cloud:e,writerId:t,exclusive:n},r)=>{if(t===null)return{ok:!1,reason:`no-writer`};try{return{ok:!0,roster:await n(()=>Gf(e,t,r))}}catch(e){return{ok:!1,reason:Kf(e)}}},Yf=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Xf=async(e,t,n)=>{let r=ff(t);return r.ok?Jf(e,(e,t)=>{let i={...t.profile};for(let t of[`displayName`,`bio`,`links`]){let a=r.profile[t];Yf(n[t],a)||(i[t]={value:a,...e})}return{...t,profile:i}}):r},Zf=(e,t)=>Jf(e,(e,n,r)=>{let i={...n.profile};for(let[n,a]of Object.entries(t(r)))i[n]={value:a,...e};return{...n,profile:i}}),Qf=(e,t,n)=>Jf(e,(e,r,i)=>{let a=n(i);if(a===null)return r;let o={...r.apps,[t]:{value:a.grant,...e}};return a.page===void 0?{...r,apps:o}:{...r,apps:o,profile:{...r.profile,page:{value:a.page,...e}}}}),$f=async(e,t,n)=>{let r=null,i=!0;return{outcome:await Zf(e,e=>(r=e.profile[t]?.value??null,i=n===null||lf(e).level!==`me`,i?{[t]:n}:{})),replaced:r,applied:i}},ep=(e,t,n)=>Jf(e,(e,r,i)=>{let a=i.friends[t];return a===void 0?r:{...r,friends:{...r.friends,[t]:{value:n(a.value),...e}}}}),tp=(e,t,n)=>ep(e,t,e=>({...e,nickname:n})),np=(e,t)=>ep(e,t,e=>({...e,state:`removed`})),rp=(e,t,n)=>({signKey:J(t.signKey),dhKey:J(t.dhKey),name:t.name,nickname:e?.nickname??null,profile:gf(e?.profile??null,t.profile),pairNonce:J(t.pairNonce),linkedAt:e?.state===`active`?e.linkedAt:n,linkedVia:e?.state===`active`?e.linkedVia:t.linkedVia,inbox:t.inbox??e?.inbox??null,state:`active`}),ip=(e,t,n)=>{let r=tf(t.signKey);return Jf(e,(e,i,a)=>({...i,friends:{...i.friends,[r]:{value:rp(a.friends[r]?.value,t,n),...e}}}))},ap={displayName:``,bio:``,links:[],version:0},op=async(e,t,n)=>{let r=tf(t.signKey),i=``,a=await Jf(e,(e,a,o)=>{let s=o.friends[r]?.value;if(s?.state===`active`||s?.state===`requested`)return i=s.pairNonce,a;i=J(crypto.getRandomValues(new Uint8Array(32)));let c={signKey:J(t.signKey),dhKey:J(t.dhKey),name:t.name,nickname:s?.nickname??null,profile:s?.profile??ap,pairNonce:i,linkedAt:n,linkedVia:`request`,inbox:t.inbox,state:`requested`};return{...a,friends:{...a.friends,[r]:{value:c,...e}}}});return a.ok?{ok:!0,nonce:i}:a},sp=async(e,t,n)=>{let r=tf(t.signKey),i=J(t.pairNonce),a=!1;return{outcome:await Jf(e,(e,o,s)=>{let c=s.friends[r]?.value;return a=c?.state===`active`||c?.state===`requested`&&c.pairNonce===i,a&&c!==void 0?{...o,friends:{...o.friends,[r]:{value:rp(c,{...t,name:c.name},n),...e}}}:o}),applied:a}};function cp(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}var lp=(e,t,n)=>cd(e,t,n),up=sd;function dp(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function fp(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var pp=yd,mp=(...e)=>Sd(...e),hp=e=>xd(e),gp=ad,_p=e=>Td(e),vp=BigInt(0),yp=BigInt(1),bp=e=>e?`"${e}" `:``;function xp(e,t=``){if(typeof e!=`boolean`)throw TypeError(bp(t)+`expected boolean, got type=`+typeof e);return e}function Sp(e){if(typeof e==`bigint`){if(!Ap(e))throw RangeError(`positive bigint expected, got `+e)}else up(e);return e}function Cp(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function wp(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?vp:BigInt(`0x`+e)}function Tp(e){return wp(yd(e))}function Ep(e){return wp(yd(kp(cd(e)).reverse()))}function Dp(e,t){if(sd(t),t===0)throw Error(`zero output length is invalid`);e=Sp(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return xd(r.padStart(n,`0`))}function Op(e,t){return Dp(e,t).reverse()}function kp(e){return Uint8Array.from(lp(e))}function Ap(e){return typeof e==`bigint`&&vp<=e}function jp(e,t,n){return Ap(e)&&Ap(t)&&Ap(n)&&t<=e&&e<n}function Mp(e,t,n,r){if(!jp(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Np(e){if(e<vp)throw Error(`expected non-negative bigint, got `+e);return e===vp?0:e.toString(2).length}var Pp=e=>(Cp(e,`n`),(yp<<BigInt(e))-yp);function Fp(e,t={},n={},r=`object`){dp(e,r),dp(t,`fields`),dp(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var Ip=BigInt(0),X=BigInt(1),Lp=BigInt(2),Rp=BigInt(3),zp=BigInt(4),Bp=BigInt(5),Vp=BigInt(7),Hp=BigInt(8),Up=BigInt(9),Wp=BigInt(15),Gp=BigInt(16),Kp=BigInt(`0x10000000000000000`);function Z(e,t){if(t<=Ip)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=Ip?n:t+n}function qp(e,t,n){if(n<=X)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<Ip)throw Error(`invalid exponent, negatives unsupported`);if(t===Ip)return X;if(t===X)return e;let r=e%n;if(r<Ip&&(r+=n),t<Kp){let e=X;for(;t>Ip;)t&X&&(e=e*r%n),r=r*r%n,t>>=X;return e}let i=[];for(;t>Ip;)i.push(Number(t&Wp)),t>>=zp;let a=Array(16);a[0]=X,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function Jp(e,t,n){if(n<=X)throw Error(`pow2: expected modulus > 1, got `+n);if(t<Ip)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-->Ip;)r*=r,r%=n;return r}function Yp(e,t){if(e===Ip)throw Error(`invert: expected non-zero number`);if(t<=X)throw Error(`invert: expected modulus > 1, got `+t);let n=Z(e,t),r=t,i=Ip,a=X;for(;n!==Ip;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==X)throw Error(`invert: does not exist`);return Z(i,t)}function Xp(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Zp(e,t){if((e&X)===Ip)throw Error(t+`: expected odd modulus, got `+e)}function Qp(e,t){let n=e,r=(n.ORDER+X)/zp,i=n.pow(t,r);return Xp(n,i,t),i}function $p(e,t){let n=e,r=(n.ORDER-Bp)/Hp,i=n.mul(t,Lp),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Lp),a),c=n.mul(o,n.sub(s,n.ONE));return Xp(n,c,t),c}function em(e){let t=dm(e),n=tm(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Vp)/Gp;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return Xp(n,m,t),m})}function tm(e){if(e<Rp)throw Error(`sqrt is not defined for small field`);Zp(e,`tonelliShanks`);let t=e-X,n=0;for(;t%Lp===Ip;)t/=Lp,n++;let r=Lp,i=dm(e);for(;sm(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Qp;let a=i.pow(r,t),o=(t+X)/Lp;return function(e,r){let i=e;if(i.is0(r))return r;if(sm(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=X<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function nm(e){return Zp(e,`Fp.sqrt`),e%zp===Rp?Qp:e%Hp===Bp?$p:e%Gp===Up?em(e):tm(e)}var rm=(e,t)=>(Z(e,t)&X)===X,im=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function am(e){if(dp(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);Cp(e.BYTES,`BYTES`),Cp(e.BITS,`BITS`);for(let t of im)fp(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=X)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function om(e,t,n=!1){am(e),cp(t,`nums`),xp(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function sm(e,t){am(e);let n=e;Zp(n.ORDER,`FpLegendre`);let r=(n.ORDER-X)/Lp,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function cm(e,t){if(t!==void 0&&up(t),e<=Ip)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Np(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var lm=new WeakMap,um=class{ORDER;BITS;BYTES;isLE;ZERO=Ip;ONE=X;_lengths;_mod;constructor(e,t={}){if(e<=X)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=cm(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return Z(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return Ip<=e&&e<this.ORDER}is0(e){return e===Ip}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&X)===X}neg(e){return Z(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Z(e*e,this.ORDER)}add(e,t){return Z(e+t,this.ORDER)}sub(e,t){return Z(e-t,this.ORDER)}mul(e,t){return Z(e*t,this.ORDER)}pow(e,t){return qp(e,t,this.ORDER)}div(e,t){return Z(e*Yp(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Yp(e,this.ORDER)}sqrt(e){let t=lm.get(this);return t||lm.set(this,t=nm(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Op(e,this.BYTES):Dp(e,this.BYTES)}fromBytes(e,t=!1){lp(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Ep(e):Tp(e);if(o&&(s=Z(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return om(this,e,!0)}cmov(e,t,n){return xp(n,`condition`),n?t:e}};function dm(e,t={}){return Object.freeze(um.prototype),new um(e,t)}var fm=BigInt(0),pm=BigInt(1),mm=BigInt(4),hm=16,gm=128,_m=5,vm=2**31;function ym(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);fp(t.fromAffine,`Point.fromAffine`),fp(t.fromBytes,`Point.fromBytes`),fp(t.fromHex,`Point.fromHex`),dp(t.BASE,`Point.BASE`),dp(t.ZERO,`Point.ZERO`),am(t.Fp),am(t.Fn)}function bm(e,t){ym(e),wm(t,e);let n=om(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function xm(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Sm(e,t){let n=e*(4*t+128);if(n>vm)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+vm/2**20+` MiB`)}function Cm(e,t){if(e!==void 0){fp(e,`randomBytes`);try{let n=e(t);if(!gp(n)||n.length!==t)return}catch{return}return e}}function wm(e,t){cp(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Tm(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):Ap(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Em=new WeakMap;function Dm(e){return Em.get(e)||1}function Om(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function km(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>fm;){let t=0;e&pm&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=pm}return a}function Am(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=pm),s.push(t)}if(e!==fm)throw Error(`invalid wnaf`);return s}function jm(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Mm=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){ym(e),this.randomBytes=Cm(t,hm),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=Am(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!jp(t,pm,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Dm(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+gm,i=this.randomBytes(hm);if(!gp(i)||i.length!==hm)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Tp(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=_m,i=Pp(r),a=Array(32);a[0]=this.ZERO;for(let t=1;t<32;t++)a[t]=a[t-1].add(e);let o=Math.ceil(n/r),s=this.ZERO;for(let e=o-1;e>=0;e--){if(e!==o-1)for(let e=0;e<r;e++)s=s.double();let n=Number(t>>BigInt(e*r)&i),c=a[0];for(let e=1;e<32;e++)c=e===n?a[e]:c;s=s.add(c)}return{p:s,f:s}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===pm||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!Ap(t))throw Error(`invalid scalar`);let r=Dm(e);if(r===1||t>=this.Point.Fn.ORDER)return Nm(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),xm(t,this.bits),Sm((Math.ceil((this.bits+gm)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Em.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Dm(e)!==1}};function Nm(e,t,n,r=!1){if(ym(e),wm(t,e),xp(r,`allowOversized`),Tm(n,e.Fn,r?e.Fn.ORDER**mm:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Om(e,4)),a=n.map(e=>km(e,4));return jm(e.ZERO,i,a)}function Pm(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return am(t),t}return dm(e,{isLE:n})}function Fm(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Fp(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(Ap(n)&&n!==fm))throw Error(`CURVE.${e} must be positive bigint`)}let i=Pm(t.p,n.Fp,r),a=Pm(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Im(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Lm=BigInt(0),Rm=BigInt(1),zm=BigInt(2),Bm=BigInt(4),Vm=BigInt(8);function Hm(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function Um(e,t={}){Fp(t,{},{},`extraOpts`);let n=t,r=Fm(`edwards`,e,n,n.FpFnLE),{Fp:i,Fn:a}=r,o=r.CURVE,{h:s}=o;if(sm(i,o.a)!==1)throw Error(`edwards: CURVE.a must be a square in Fp for complete addition formulas`);if(sm(i,o.d)!==-1)throw Error(`edwards: CURVE.d must be a non-square in Fp for complete addition formulas`);Fp(n,{},{uvRatio:`function`,randomBytes:`function`});let c=n.randomBytes===void 0?_p:n.randomBytes,l=zm<<BigInt(i.BYTES*8)-Rm;function u(e){if(!i.isOdd)throw Error(`Field does not have .isOdd()`);return i.isOdd(e)}let d=n.uvRatio===void 0?(e,t)=>{try{return{isValid:!0,value:i.sqrt(i.div(e,t))}}catch{return{isValid:!1,value:Lm}}}:n.uvRatio;if(!Hm(i,o,o.Gx,o.Gy))throw Error(`bad curve params: generator point`);let f=i.eql(o.a,i.neg(i.ONE))?e=>i.neg(e):i.eql(o.a,i.ONE)?e=>e:e=>i.mul(o.a,e);function p(e,t,n=!1){let r=n?Rm:Lm;return Mp(`coordinate `+e,t,r,l),t}function m(e){if(!(e instanceof h))throw Error(`EdwardsPoint expected`)}class h{static BASE=new h(o.Gx,o.Gy,i.ONE,i.mul(o.Gx,o.Gy));static ZERO=new h(i.ZERO,i.ONE,i.ONE,i.ZERO);static Fp=i;static Fn=a;X;Y;Z;T;constructor(e,t,n,r){this.X=p(`x`,e),this.Y=p(`y`,t),this.Z=p(`z`,n,!0),this.T=p(`t`,r),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){if(e instanceof h)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return p(`x`,t),p(`y`,n),new h(t,n,i.ONE,i.mul(t,n))}static fromBytes(e,t=!1){let n=i.BYTES,{a:r,d:a}=o;e=kp(lp(e,n,`point`)),xp(t,`zip215`);let s=kp(e),c=e[n-1];s[n-1]=c&-129;let f=Ep(s);Mp(`point.y`,f,Lm,t?l:i.ORDER);let p=i.sqr(f),m=i.sub(p,i.ONE),g=i.sub(i.mulN(a,p),r),{isValid:_,value:v}=d(m,g);if(!_)throw Error(`bad point: invalid y coordinate`);let y=u(v),b=!!(c&128);if(!t&&i.is0(v)&&b)throw Error(`bad point: x=0 and x_0=1`);return b!==y&&(v=i.neg(v)),h.fromAffine({x:v,y:f})}static fromHex(e,t=!1){return h.fromBytes(hp(e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return _.setWindowSize(this,e),t||this.multiply(zm),this}assertValidity(){let e=this,{a:t,d:n}=o;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:a,Z:s,T:c}=e,l=i.sqr(r),u=i.sqr(a),d=i.sqr(s),f=i.sqr(d),p=i.mul(l,t),m=i.mul(i.add(p,u),d),h=i.add(f,i.mul(n,i.mul(l,u)));if(!i.eql(m,h))throw Error(`bad point: equation left != right (1)`);let g=i.mul(r,a),_=i.mul(s,c);if(!i.eql(g,_))throw Error(`bad point: equation left != right (2)`)}equals(e){m(e);let{X:t,Y:n,Z:r}=this,{X:a,Y:o,Z:s}=e,c=i.mul(t,s),l=i.mul(a,r),u=i.mul(n,s),d=i.mul(o,r);return i.eql(c,l)&&i.eql(u,d)}is0(){return this.equals(h.ZERO)}negate(){return new h(i.neg(this.X),this.Y,this.Z,i.neg(this.T))}double(){let{X:e,Y:t,Z:n}=this,r=i.sqr(e),a=i.sqr(t),o=i.mul(i.sqr(n),zm),s=f(r),c=i.addN(e,t),l=i.sub(i.subN(i.sqr(c),r),a),u=i.addN(s,a),d=i.subN(u,o),p=i.subN(s,a),m=i.mul(l,d),g=i.mul(u,p),_=i.mul(l,p),v=i.mul(d,u);return new h(m,g,v,_)}add(e){m(e);let{d:t}=o,{X:n,Y:r,Z:a,T:s}=this,{X:c,Y:l,Z:u,T:d}=e,p=i.mul(n,c),g=i.mul(r,l),_=i.mul(i.mulN(s,t),d),v=i.mul(a,u),y=i.sub(i.subN(i.mulN(i.addN(n,r),i.addN(c,l)),p),g),b=i.subN(v,_),x=i.addN(v,_),S=i.sub(g,f(p)),C=i.mul(y,b),w=i.mul(x,S),T=i.mul(y,S),E=i.mul(b,x);return new h(C,w,E,T)}subtract(e){return m(e),this.add(e.negate())}multiply(e){if(!a.isValidNot0(e))throw RangeError(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=_.mulSecret(this,e,s,g);return g([t,n])[0]}multiplyUnsafe(e){if(!a.isValid(e))throw RangeError(`invalid scalar: expected 0 <= sc < curve.n`);return e===Lm?h.ZERO:this.is0()||e===Rm?this:_.mulUnsafe(this,e,g)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return _.mulUnsafe(this,o.n).is0()}toAffine(e){let t=this,n=e;if(n!=null&&typeof n!=`bigint`)throw TypeError(`"invertedZ" expected bigint, got type=`+typeof n);let{X:r,Y:a,Z:o}=t,s=t.is0();n??=s?i.create(Vm):i.inv(o);let c=i.mul(r,n),l=i.mul(a,n),u=i.mul(o,n);if(s)return{x:i.ZERO,y:i.ONE};if(!i.eql(u,i.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}clearCofactor(){return s===Rm?this:s===zm?this.double():s===Bm?this.double().double():s===Vm?this.double().double().double():this.multiplyUnsafe(s)}toBytes(){let{x:e,y:t}=this.toAffine(),n=i.toBytes(t);return n[n.length-1]|=u(e)?128:0,n}toHex(){return pp(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let g=e=>bm(h,e),_=new Mm(h,c);return _.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function Wm(e,t,n={}){if(ym(e),typeof t!=`function`)throw Error(`"hash" function param is required`);let r=t,i=n;Fp(i,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,zip215:`boolean`,mapToCurve:`function`,toMontgomery:`function`,toMontgomerySecret:`function`});let{prehash:a}=i,{BASE:o,Fp:s,Fn:c}=e,l=r.outputLen,u=2*s.BYTES;if(l!==void 0&&(Cp(l,`hash.outputLen`),l!==u))throw Error(`hash.outputLen must be ${u}, got ${l}`);let d=i.randomBytes===void 0?_p:i.randomBytes,f=i.toMontgomery,p=i.toMontgomerySecret,m=i.adjustScalarBytes===void 0?e=>e:i.adjustScalarBytes,h=i.domain===void 0?(e,t,n)=>{if(xp(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e}:i.domain;function g(e){return c.create(Ep(e))}function _(e){let t=T.secretKey;lp(e,T.secretKey,`secretKey`);let n=lp(r(e),2*t,`hashedSecretKey`),i=m(n.slice(0,t));return{head:i,prefix:n.slice(t,2*t),scalar:g(i)}}function v(e){let{head:t,prefix:n,scalar:r}=_(e),i=o.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}}function y(e){return v(e).pointBytes}function b(e=Uint8Array.of(),...t){let n=mp(...t);return g(r(h(n,lp(e,void 0,`context`),!!a)))}function x(e,t,n={}){Fp(n,{},{},`options`),e=kp(lp(e,void 0,`message`)),a&&(e=a(e));let{prefix:r,scalar:i,pointBytes:s}=v(t),l=b(n.context,r,e),u=o.multiply(l).toBytes(),d=b(n.context,u,s,e),f=c.create(l+d*i);if(!c.isValid(f))throw Error(`sign failed: invalid s`);return lp(mp(u,c.toBytes(f)),T.signature,`result`)}let S={zip215:i.zip215};function C(t,n,r,i=S){Fp(i);let{context:s}=i,c=i.zip215===void 0?!!S.zip215:i.zip215,l=T.signature;t=lp(t,l,`signature`),n=lp(n,void 0,`message`),r=lp(r,T.publicKey,`publicKey`),c!==void 0&&xp(c,`zip215`),a&&(n=a(n));let u=l/2,d=t.subarray(0,u),f=Ep(t.subarray(u,l)),p,m,h;try{p=e.fromBytes(r,c),m=e.fromBytes(d,c),h=o.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let g=b(s,d,r,n);return m.add(p.multiplyUnsafe(g)).subtract(h).clearCofactor().is0()}let w=s.BYTES,T={secretKey:w,publicKey:w,signature:2*w,seed:w};function E(e){return e=e===void 0?d(T.seed):e,lp(e,T.seed,`seed`)}function D(e){return gp(e)&&e.length===T.secretKey}function O(t,n){try{return!!e.fromBytes(t,n===void 0?S.zip215:n)}catch{return!1}}let k={getExtendedPublicKey:v,randomSecretKey:E,isValidSecretKey:D,isValidPublicKey:O,toMontgomery(t){if(f===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return f(e.fromBytes(t))},toMontgomerySecret(e){if(p===void 0)throw Error(`Montgomery conversion is not supported for this curve`);return p(e)}};return Object.freeze(T),Object.freeze(k),Object.freeze({keygen:Im(E,y),getPublicKey:y,sign:x,verify:C,utils:k,Point:e,lengths:T})}var Gm=BigInt(0),Km=BigInt(1),qm=BigInt(2);function Jm(e,t){return e+t-(t>>Km<<Km)}function Ym(e){let t=BigInt(6)*e;return(n,r,i)=>{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function Xm(e){return Fp(e,{P:`bigint`,type:`string`,adjustScalarBytes:`function`,powPminus2:`function`},{randomBytes:`function`,scalarMultBase:`function`}),Object.freeze({...e})}function Zm(e){let t=Xm(e),{P:n,type:r,adjustScalarBytes:i,powPminus2:a,randomBytes:o}=t,s=t.scalarMultBase,c=r===`x25519`;if(!c&&r!==`x448`)throw Error(`invalid type`);let l=o===void 0?_p:o,u=c?255:448,d=Ym(n),f=c?32:56,p=BigInt(c?9:5),m=BigInt(c?121665:39081),h=c?qm**BigInt(254):qm**BigInt(447),g=h+(c?BigInt(8)*(qm**BigInt(251)-Km):BigInt(4)*(qm**BigInt(445)-Km))+Km,_=e=>Z(e,n),v=y(p);function y(e){return Op(_(e),f)}function b(e){let t=kp(lp(e,f,`uCoordinate`));return c&&(t[31]&=127),_(Ep(t))}function x(e){return Ep(i(kp(lp(e,f,`scalar`))))}let S=new Set(c?[Gm,Km,n-Km,BigInt(`325606250916557431795983626356110631294008115727848805560023387167927233504`),BigInt(`39382357235489614581723060781553021112529911719440698176882885853963445705823`)]:[Gm,Km,n-Km]);function C(e,t){let n=b(t);if(S.has(n))throw Error(`invalid private or public key received`);let r=D(n,x(e));if(r===Gm)throw Error(`invalid private or public key received`);return y(r)}function w(e){if(s===void 0)return C(e,v);let t=x(e);Mp(`scalar`,t,h,g);let n=_(s(t));if(n===Gm)throw Error(`invalid private or public key received`);return y(n)}let T=w,E=C;function D(e,t){Mp(`u`,e,Gm,n),Mp(`scalar`,t,h,g);let r=t,i=e,o=Km,s=Gm,c=e,l=Km,f=r^r>>Km;for(let e=BigInt(u-1);e>=Gm;e--){let t=Jm(n,f>>e);({x_2:o,x_3:c}=d(t,o,c)),{x_2:s,x_3:l}=d(t,s,l);let r=o+s,a=_(r*r),u=o-s,p=_(u*u),h=a-p,g=c+l,v=c-l,y=_(v*r),b=_(g*u),x=y+b,S=y-b;c=_(x*x),l=_(i*_(S*S)),o=_(a*p),s=_(h*(a+_(m*h)))}let p=Jm(n,r);({x_2:o,x_3:c}=d(p,o,c)),{x_2:s,x_3:l}=d(p,s,l);let v=a(s);return _(o*v)}let O={secretKey:f,publicKey:f,seed:f},k=e=>(e=e===void 0?l(f):e,lp(e,O.seed,`seed`),e),A={randomSecretKey:k};return Object.freeze(O),Object.freeze(A),Object.freeze({keygen:Im(k,T),getSharedSecret:E,getPublicKey:T,scalarMult:C,scalarMultBase:w,utils:A,GuBytes:v.slice(),lengths:O})}var Qm=BigInt(0),$m=BigInt(1),eh=BigInt(2),th=BigInt(3),nh=BigInt(5),rh=BigInt(8),ih=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),ah={p:ih,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:rh,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function oh(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=ih,o=e*e%a*e%a,s=Jp(Jp(o,eh,a)*o%a,$m,a)*e%a,c=Jp(s,nh,a)*s%a,l=Jp(c,t,a)*c%a,u=Jp(l,n,a)*l%a,d=Jp(u,r,a)*u%a;return{pow_p_5_8:Jp(Jp(Jp(Jp(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,eh,a)*e%a,b2:o}}function sh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ch=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function lh(e,t){let n=ih,r=Z(t*t*t,n),i=oh(e*Z(r*r*t,n)).pow_p_5_8,a=Z(e*r*i,n),o=Z(t*a*a,n),s=a,c=Z(a*ch,n),l=o===e,u=o===Z(-e,n),d=o===Z(-e*ch,n);return l&&(a=s),(u||d)&&(a=c),rm(a,n)&&(a=Z(-a,n)),{isValid:l||u,value:a}}var uh=Um(ah,{uvRatio:lh}),dh=uh.Fp;function fh(e){let{y:t}=e;return dh.toBytes(dh.div($m+t,$m-t))}function ph(e){let t=uh.Fp.BYTES;return cd(e,t),sh(Wd(e.subarray(0,t))).subarray(0,t)}function mh(e){return Wm(uh,Wd,Object.assign({adjustScalarBytes:sh,toMontgomery:fh,toMontgomerySecret:ph,zip215:!0},e))}var hh=mh({}),gh=(()=>{let e=ih,t=t=>{let{pow_p_5_8:n,b2:r}=oh(t);return Z(Jp(n,th,e)*r,e)};return Zm({P:e,type:`x25519`,powPminus2:t,adjustScalarBytes:sh,scalarMultBase:n=>{let r=Z(n,uh.Fn.ORDER);if(r===Qm)return Qm;let i=uh.BASE.multiply(r);return Z((i.Z+i.Y)*t(Z(i.Z-i.Y,e)),e)}})})(),_h=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(ld(e),cd(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),md(r)}update(e){return fd(this),this.iHash.update(e),this}digestInto(e){fd(this),pd(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vh=(()=>{let e=((e,t,n)=>new _h(e,t).update(n).digest());return e.create=(e,t)=>new _h(e,t),e})(),yh=Uint8Array.of(0),bh=Uint8Array.of();function xh(e,t,n,r=32,i){ld(e),sd(r,`length`),cd(t,void 0,`prk`);let a=e.outputLen;if(t.length<a)throw Error(`"prk" must be at least HashLen octets`);if(r>255*a)throw Error(`Length must be <= 255*HashLen`);let o=Math.ceil(r/a);if(n===void 0?n=bh:cd(n,void 0,`info`),!o)return i&&md(t),new Uint8Array;let s=i&&o===1?t:new Uint8Array(o*a),{iHash:c,oHash:l}=vh.create(e,t),u=i?t:new Uint8Array(a),d=o>1?i?.iHash||e.create():void 0;for(let e=0;e<o-1;e++){yh[0]=e+1;let t=c._cloneInto(d);e&&t.update(u),t.update(n).update(yh).digestInto(u),l._cloneInto(d).update(u).digestInto(u),s.set(u,a*e)}if(yh[0]=o,o>1&&c.update(u),c.update(n).update(yh).digestInto(u),l.update(u).digestInto(u),s.set(u,a*(o-1)),c.destroy(),l.destroy(),d?.destroy(),u!==s&&md(u),md(yh),r===s.length)return s;let f=s.slice(0,r);return md(s),f}var Sh=(e,t,n,r,i)=>{ld(e),n===void 0&&(n=new Uint8Array(e.outputLen));let a=vh.create(e,n).update(t);return xh(e,a.digest(),r,i,a)},Ch=`fkn/social/v1/sign`,wh=`fkn/social/v1/dh`,Th=`fkn/social/v1/hello`,Eh=`fkn/social/v1/offer`,Dh=`fkn/social/v1/accept`,Oh=`fkn/social/v1/handshake`,kh=`fkn/social/v1/name`,Ah=`fkn/social/v2/name`,jh=`fkn/social/v1/name-room`,Mh=`fkn/social/v1/request`,Nh=`fkn/social/v1/request-seal`,Ph=`fkn/social/v1/friends`,Fh=`fkn/social/v1/friend-slot`,Ih=`fkn/social/v1/page`,Lh=e=>new TextEncoder().encode(e),Rh=()=>crypto.getRandomValues(new Uint8Array(32)),zh=e=>{if(e.length!==32)throw Error(`social: a seed is 32 bytes`);let t=Sh(Ud,e,void 0,Lh(Ch),32),n=Sh(Ud,e,void 0,Lh(wh),32);return{signSeed:t,signKey:hh.getPublicKey(t),dhSeed:n,dhKey:gh.getPublicKey(n)}},Bh={blue:{label:`Blue`,light:{accent:`#2f5bd3`,text:`#ffffff`},dark:{accent:`#7c9cff`,text:`#0d1430`}},purple:{label:`Purple`,light:{accent:`#7442c8`,text:`#ffffff`},dark:{accent:`#b99cff`,text:`#1f1236`}},pink:{label:`Pink`,light:{accent:`#b8327a`,text:`#ffffff`},dark:{accent:`#ff8ac4`,text:`#3a0f26`}},red:{label:`Red`,light:{accent:`#c0352b`,text:`#ffffff`},dark:{accent:`#ff8f84`,text:`#3d0f0b`}},orange:{label:`Orange`,light:{accent:`#b04e0f`,text:`#ffffff`},dark:{accent:`#ffa163`,text:`#3a1a05`}},green:{label:`Green`,light:{accent:`#2a7a3b`,text:`#ffffff`},dark:{accent:`#6fd38a`,text:`#0b2a13`}},teal:{label:`Teal`,light:{accent:`#0f7671`,text:`#ffffff`},dark:{accent:`#5fd0c8`,text:`#062a28`}},grey:{label:`Grey`,light:{accent:`#5c5a55`,text:`#ffffff`},dark:{accent:`#bdb9b0`,text:`#1d1c1a`}}},Vh=Object.keys(Bh),Hh={steel:{label:`Steel`,light:!1,bg:`#13161a`,sheet:`#181c21`,panel:`#20252c`,head:`#2b333e`,border:`#38414e`,text:`#f0f2f5`,muted:`#adb5c0`,accent:`#8cb4d8`,accentText:`#0f1720`,pill:`#283647`,skyTop:`#262d37`,skyBot:`#13161a`},midnight:{label:`Midnight`,light:!1,bg:`#11161d`,sheet:`#151c26`,panel:`#1c2431`,head:`#243245`,border:`#34465e`,text:`#eef2f7`,muted:`#a4b2c4`,accent:`#7ea8de`,accentText:`#0c1422`,pill:`#23354c`,skyTop:`#1b283a`,skyBot:`#11161d`},forest:{label:`Forest`,light:!1,bg:`#111714`,sheet:`#151e19`,panel:`#1c2721`,head:`#23372c`,border:`#334d3f`,text:`#edf4ef`,muted:`#a5bdaf`,accent:`#76d690`,accentText:`#0a2412`,pill:`#213a2c`,skyTop:`#1c3126`,skyBot:`#111714`},crimson:{label:`Crimson`,light:!1,bg:`#181214`,sheet:`#20171a`,panel:`#281d21`,head:`#3c242c`,border:`#54353f`,text:`#f7eef0`,muted:`#c4a8b0`,accent:`#ee95a3`,accentText:`#290b12`,pill:`#41252e`,skyTop:`#351d24`,skyBot:`#181214`},slate:{label:`Slate`,light:!1,bg:`#141416`,sheet:`#1b1c1f`,panel:`#222428`,head:`#2d3036`,border:`#3d4149`,text:`#f1f2f4`,muted:`#b2b6be`,accent:`#c4c8d0`,accentText:`#141518`,pill:`#30333b`,skyTop:`#26282e`,skyBot:`#141416`},daylight:{label:`Daylight`,light:!0,bg:`#eceef2`,sheet:`#ffffff`,panel:`#f5f6f9`,head:`#e3e7ef`,border:`#cfd5e0`,text:`#14161a`,muted:`#505662`,accent:`#2752c4`,accentText:`#ffffff`,pill:`#dce5f5`,skyTop:`#d7dfec`,skyBot:`#eceef2`}},Uh=Object.keys(Hh),Wh=`steel`,Gh={light:{error:`#b3261e`,warnBg:`#fff4dc`,warnLine:`#e9c46a`},dark:{error:`#ff8a80`,warnBg:`#352b16`,warnLine:`#8a6d1f`}},Kh={about:`About`,activity:`Activity`,favourites:`Favourites`,comments:`Comments`},qh=Object.keys(Kh),Jh={accent:`blue`,theme:Wh,sections:[{id:`about`},{id:`activity`,level:`off`},{id:`favourites`,level:`off`},{id:`comments`,level:`off`}]},Yh={accent:`blue`,sections:[`about`]},Xh=16,Zh=e=>typeof e==`string`&&qh.includes(e),Qh=e=>typeof e==`string`&&Object.hasOwn(Bh,e)?e:`blue`,$h=e=>typeof e==`string`&&Object.hasOwn(Hh,e)?e:Wh,eg=new Set([`public`,`friends`,`off`]),tg=(e,t)=>{if(e===`about`)return{id:e};let n=t?.level;return{id:e,level:typeof n==`string`&&eg.has(n)?n:`off`}},ng=e=>{let t=e.profile.page?.value;if(typeof t!=`object`||!t)return Jh;let{accent:n,theme:r,sections:i}=t,a=new Map;for(let e of Array.isArray(i)?i:[]){let t=e?.id;Zh(t)&&!a.has(t)&&a.set(t,tg(t,e))}for(let e of qh)a.has(e)||a.set(e,tg(e));return{accent:Qh(n),theme:$h(r),sections:[...a.values()]}},rg=(e,t)=>{let n=e.sections.find(e=>e.id===t);return n!==void 0&&n.id!==`about`?n.level:`off`},ig=(e,t)=>rg(ng(e),t),ag=(e,t,n)=>({...e,sections:e.sections.map(e=>e.id===t?{id:t,level:n}:e)}),og=(e,t,n)=>{let r=e.sections.findIndex(e=>e.id===t),i=r+n;if(r<0||i<0||i>=e.sections.length)return e;let a=[...e.sections];return[a[r],a[i]]=[a[i],a[r]],{...e,sections:a}},sg=(e,t)=>{if(e.profile.page===void 0)return null;let{accent:n,theme:r,sections:i}=ng(e);return{accent:n,...r===`steel`?{}:{theme:r},sections:i.filter(e=>e.id===`about`?t:e.level===`public`).map(({id:e})=>e)}},cg=(e,t)=>ng(e).sections.filter(e=>e.id===`about`?t:e.level!==`off`).map(({id:e})=>e),lg=e=>{if(typeof e!=`object`||!e)return Yh;let{accent:t,theme:n,sections:r}=e;if(!Array.isArray(r)||r.length>Xh||!r.every(e=>typeof e==`string`))return Yh;let i=$h(n);return{accent:Qh(t),...i===`steel`?{}:{theme:i},sections:[...new Set(r)].filter(Zh)}},ug=(e,t)=>JSON.stringify(e)===JSON.stringify(t),dg=(e,t,n)=>Zf(e,()=>ug(t,n)?{}:{page:t}),fg={avatar:262144,background:2097152},pg={avatar:4194304,background:10485760},mg={avatar:512,background:1920},hg={avatar:1024,background:3840},gg=1048576,_g=4194304,vg=1920,yg=2048,bg=e=>e===`artwork`?{staticBytes:gg,maxBytes:_g,side:vg,animatedSide:yg}:{staticBytes:fg[e],maxBytes:pg[e],side:mg[e],animatedSide:hg[e]},xg=(e,t,n)=>{for(let r=0;r<n.length;r++)if(e[t+r]!==n.charCodeAt(r))return!1;return!0},Sg=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,Cg=(e,t,n)=>{e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255},wg=e=>{let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n},Tg=(e,t)=>{let n=t;for(;n<e.length;){let t=e[n++];if(t===0)return n;if(n+=t,n>e.length)return-1}return-1},Eg=(e,t)=>{if(e.length<14||!xg(e,0,`GIF87a`)&&!xg(e,0,`GIF89a`))return null;let n=13+(e[10]&128?3*(1<<(e[10]&7)+1):0);if(n>e.length)return null;t?.push(e.subarray(0,n));let r=0;for(;n<e.length;){let i=n,a=e[n++];if(a===59)break;if(a===44){if(n+9>e.length)return null;if(r+=1,t===void 0&&r>=2)return r;let a=e[n+8],o=a&128?3*(1<<(a&7)+1):0;if(n+=9+o,n>=e.length||(n=Tg(e,n+1),n<0))return null;t?.push(e.subarray(i,n))}else if(a===33){if(n>=e.length)return null;let r=e[n++],a=n;if(n=Tg(e,a),n<0)return null;if(t!==void 0){let o=r===255&&a+12<=n&&e[a]===11&&(xg(e,a+1,`NETSCAPE2.0`)||xg(e,a+1,`ANIMEXTS1.0`));(r===249||o)&&t.push(e.subarray(i,n))}}else return null}return r<2?null:(t?.push(Uint8Array.of(59)),r)},Dg=e=>(Eg(e)??0)>=2,Og=e=>{let t=[];return Eg(e,t)===null?null:wg(t)},kg=new Set([`VP8X`,`ICCP`,`ANIM`,`ANMF`]),Ag=(e,t)=>{if(e.length<12||!xg(e,0,`RIFF`)||!xg(e,8,`WEBP`))return null;let n=Math.min(e.length,8+Sg(e,4)),r=[],i=12,a=!1,o=!1,s=0;for(;i+8<=n;){let c=Sg(e,i+4),l=i+8;if(c>n-l)return null;let u=String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3]);if(u===`VP8X`&&c>=10&&e[l]&2?a=!0:u===`ANIM`?o=!0:u===`ANMF`&&(s+=1),t&&kg.has(u)){let t=c+(c&1),n=new Uint8Array(8+t);n.set(e.subarray(i,i+4),0),Cg(n,4,c),n.set(e.subarray(l,l+c),8),u===`VP8X`&&c>=10&&(n[8]&=-13),r.push(n)}i=l+c+(c&1)}return{anim:(a||o)&&s>=2,parts:r}},jg=e=>Ag(e,!1)?.anim??!1,Mg=e=>{let t=Ag(e,!0);if(t===null||!t.anim)return null;let n=wg(t.parts),r=new Uint8Array(12+n.length);return r.set(e.subarray(0,4),0),Cg(r,4,4+n.length),r.set(e.subarray(8,12),8),r.set(n,12),r},Ng=e=>{let t=Pg(e);return t===`image/gif`?Dg(e):t===`image/webp`&&jg(e)},Pg=e=>e[0]===137&&xg(e,1,`PNG\r
|
|
7
|
+
|
|
8
|
+
`)?`image/png`:e[0]===255&&e[1]===216&&e[2]===255?`image/jpeg`:xg(e,0,`GIF87a`)||xg(e,0,`GIF89a`)?`image/gif`:xg(e,0,`RIFF`)&&xg(e,8,`WEBP`)?`image/webp`:null,Fg=e=>e?.code,Ig=async(e,t)=>{for(let n of t)n!==null&&await e.delete(n.url).catch(()=>{})},Lg=async(e,t,n)=>{if(t.size>n)return{ok:!1,reason:`too-large`};if(Pg(new Uint8Array(await t.slice(0,12).arrayBuffer()))===null)return{ok:!1,reason:`kind`};try{let n=await e.put(t);return{ok:!0,picture:{url:n.url,key:n.key}}}catch(e){let t=Fg(e);return{ok:!1,reason:t===`quota`||t===`too-many`?t:`storage-unavailable`}}},Rg=async(e,t,n)=>{let r=await Lg(e.storage,n,pg[t]);if(!r.ok)return r;let i=r.picture,{outcome:a,replaced:o,applied:s}=await $f(e,t,i);return await Ig(e.storage,[a.ok&&s?o:i]),a.ok&&!s?{ok:!1,reason:`not-public`}:a},zg=async(e,t)=>{let{outcome:n,replaced:r}=await $f(e,t,null);return n.ok&&await Ig(e.storage,[r]),n},Bg=async(e,t,n)=>{if(t===null)return null;try{let r=await e.get(t.url,t.key);if(r.size>n)return null;let i=new Uint8Array(await r.arrayBuffer()),a=Pg(i);return i.length>n||a===null?null:URL.createObjectURL(new Blob([i],{type:a}))}catch{return null}},Vg=[.86,.72,.58,.44],Hg=6,Ug=33554432,Wg=4194304,Gg=async(e,t,n,r)=>{let i=bg(n),a=e===`image/gif`?Og(t):Mg(t);if(a===null)return{ok:!1,reason:`kind`};if(a.length>i.maxBytes)return{ok:!1,reason:`too-large`};let o=new Blob([a.slice()],{type:e}),s;try{s=await r.decode(o)}catch{return{ok:!1,reason:`kind`}}try{let{width:e,height:t}=s;return e>0&&t>0?Math.max(e,t)>i.animatedSide?{ok:!1,reason:`too-large`}:{ok:!0,picture:{blob:o,width:e,height:t,animated:!0}}:{ok:!1,reason:`kind`}}finally{r.release?.(s.source)}},Kg=async(e,t,n)=>{let r=bg(t),i=Pg(new Uint8Array(await e.slice(0,12).arrayBuffer()));if(i===`image/gif`||i===`image/webp`){if(e.size>r.maxBytes){let t=new Uint8Array(await(e.size<=Ug?e:e.slice(0,Wg)).arrayBuffer());if(Ng(t)||i===`image/webp`&&e.size>Ug&&t.length>=21&&xg(t,12,`VP8X`)&&t[20]&2)return{ok:!1,reason:`too-large`}}else{let r=new Uint8Array(await e.arrayBuffer());if(Ng(r))return Gg(i,r,t,n)}}let a;try{a=await n.decode(e)}catch{return{ok:!1,reason:`kind`}}let{source:o,width:s,height:c}=a;try{if(!(s>0&&c>0))return{ok:!1,reason:`kind`};let e=Math.min(1,r.side/Math.max(s,c)),t={width:Math.max(1,Math.round(s*e)),height:Math.max(1,Math.round(c*e))},i=`image/webp`;for(let e=0;e<Hg;e++){for(let e of Vg){let a=await n.encode(o,t.width,t.height,i,e);if(a.type!==i&&i===`image/webp`&&(i=`image/jpeg`,a=await n.encode(o,t.width,t.height,i,e)),a.type!==i)return{ok:!1,reason:`kind`};if(a.size<=r.staticBytes)return{ok:!0,picture:{blob:a,...t}}}t={width:Math.max(1,Math.round(t.width*.75)),height:Math.max(1,Math.round(t.height*.75))}}return{ok:!1,reason:`too-large`}}catch{return{ok:!1,reason:`kind`}}finally{n.release?.(o)}},qg={decode:async e=>{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height}},encode:(e,t,n,r,i)=>new Promise((a,o)=>{let s=document.createElement(`canvas`);s.width=t,s.height=n;let c=s.getContext(`2d`);if(c===null)return o(Error(`social: no 2d canvas`));r===`image/jpeg`&&(c.fillStyle=`#fff`,c.fillRect(0,0,t,n)),c.imageSmoothingQuality=`high`,c.drawImage(e,0,0,t,n),s.toBlob(e=>e===null?o(Error(`social: the picture did not encode`)):a(e),r,i)}),release:e=>e.close()},Jg=2e3,Yg=/^[A-Za-z0-9_-]{8,32}$/,Xg=()=>J(crypto.getRandomValues(new Uint8Array(12))),Zg=e=>{let t=e.normalize(`NFC`).trim();return t!==``&&pu(t,{max:80,multiline:!1})===null?t:null},Qg=e=>{let t=e.normalize(`NFC`).replaceAll(`\r
|
|
9
|
+
`,`
|
|
10
|
+
`).trim();return t!==``&&pu(t,{max:2e3,multiline:!0})===null?t:null},$g=e=>{if(e===void 0)return;let t=e.normalize(`NFC`).trim();if(t!==``)return pu(t,{max:120,multiline:!1})===null?t:null},e_=e=>typeof e==`string`&&Yg.test(e),t_=e=>typeof e==`string`&&e.trim()===e&&e!==``&&pu(e,{max:80,multiline:!1})===null,n_=e=>typeof e==`string`&&e.trim()===e&&e!==``&&pu(e,{max:2e3,multiline:!0})===null,r_=e=>{if(e!==void 0)return typeof e!=`string`||e.trim()!==e||e===``||pu(e,{max:120,multiline:!1})!==null?null:e},i_=e=>{if(typeof e!=`object`||!e)return null;let{url:t,key:n,caption:r}=e,i=cf({url:t,key:n}),a=r_(r);return i==null||a===null?null:a===void 0?{url:i.url,key:i.key}:{url:i.url,key:i.key,caption:a}},a_=e=>e.kind===`text`?{id:e.id,kind:`text`,title:e.title,body:e.body}:{id:e.id,kind:`artwork`,title:e.title,items:e.items.map(({url:e,key:t,caption:n})=>n===void 0||n===``?{url:e,key:t}:{url:e,key:t,caption:n})},o_=e=>{if(typeof e!=`object`||!e)return null;let{id:t,kind:n,title:r}=e;if(!e_(t)||!t_(r))return null;if(n===`text`){let{body:n}=e;return n_(n)?{id:t,kind:`text`,title:r,body:n}:null}if(n===`artwork`){let{items:n}=e;if(!Array.isArray(n)||n.length===0||n.length>4)return null;let i=[];for(let e of n){let t=i_(e);t!==null&&!i.some(e=>e.url===t.url)&&i.push(t)}return i.length>0?{id:t,kind:`artwork`,title:r,items:i}:null}return null},s_=e=>{let t=[];for(let n of Array.isArray(e)?e:[]){let e=o_(n);e!==null&&!t.some(t=>t.id===e.id)&&t.length<6&&t.push(e)}return t},c_=e=>{let t=new Set;for(let n of Array.isArray(e)?e:[])if(e_(n)&&t.add(n),t.size>=12)break;return[...t]},l_=new Set([`public`,`friends`,`off`]),u_=e=>{if(typeof e!=`object`||!e)return null;let{id:t,kind:n,title:r,level:i}=e;if(!e_(t)||!t_(r)||typeof i!=`string`||!l_.has(i))return null;if(n===`text`){let{body:n}=e;return n_(n)?{id:t,kind:`text`,title:r,body:n,level:i}:null}if(n===`artwork`){let{items:n}=e;if(!Array.isArray(n)||n.length>4)return null;let a=[];for(let e of n){if(typeof e!=`object`||!e)continue;let{picture:t,caption:n}=e,r=cf(t),i=r_(n);r!=null&&i!==null&&!a.some(e=>e.picture.url===r.url)&&a.push(i===void 0?{picture:r}:{picture:r,caption:i})}return{id:t,kind:`artwork`,title:r,items:a,level:i}}return null},d_=e=>{let t=[];for(let n of Array.isArray(e.profile.panels?.value)?e.profile.panels.value:[]){let e=u_(n);e!==null&&!t.some(t=>t.id===e.id)&&t.length<6&&t.push(e)}return t},f_=e=>e.level===`off`?null:e.kind===`text`?{id:e.id,kind:`text`,title:e.title,body:e.body}:e.items.length===0?null:{id:e.id,kind:`artwork`,title:e.title,items:e.items.map(({picture:e,caption:t})=>t===void 0?{url:e.url,key:e.key}:{url:e.url,key:e.key,caption:t})},p_=e=>d_(e).filter(e=>e.level===`public`).map(f_).filter(e=>e!==null),m_=e=>d_(e).filter(e=>e.level===`friends`).map(f_).filter(e=>e!==null),h_=e=>d_(e).filter(e=>f_(e)!==null).map(e=>e.id),g_=e=>e.kind===`artwork`?e.items.map(e=>e.picture):[],__=async(e,t)=>{let n=Zg(t.title);if(n===null)return{ok:!1,reason:`title`};let r=Qg(t.body);if(r===null)return{ok:!1,reason:`body`};let i=!1,a=await Zf(e,e=>{let a=d_(e);return a.length>=6?(i=!0,{}):{panels:[...a,{id:Xg(),kind:`text`,title:n,body:r,level:t.level}]}});return i?{ok:!1,reason:`full`}:a},v_=async(e,t)=>{let n=Zg(t.title);if(n===null)return{ok:!1,reason:`title`};let r=!1,i=await Zf(e,e=>{let i=d_(e);return i.length>=6?(r=!0,{}):{panels:[...i,{id:Xg(),kind:`artwork`,title:n,items:[],level:t.level}]}});return r?{ok:!1,reason:`full`}:i},y_=async(e,t,n)=>{let r=Zg(n.title);if(r===null)return{ok:!1,reason:`title`};let i=Qg(n.body);if(i===null)return{ok:!1,reason:`body`};let a=!1,o=await Zf(e,e=>{let n=d_(e),o=n.findIndex(e=>e.id===t&&e.kind===`text`);if(o<0)return a=!0,{};let s=[...n];return s[o]={...n[o],title:r,body:i},{panels:s}});return a?{ok:!1,reason:`not-found`}:o},b_=async(e,t,n)=>{let r=Zg(n.title);if(r===null)return{ok:!1,reason:`title`};let i={};for(let[e,t]of Object.entries(n.captions)){let n=$g(t);if(n===null)return{ok:!1,reason:`caption`};i[e]=n}let a=!1,o=await Zf(e,e=>{let n=d_(e),o=n.findIndex(e=>e.id===t&&e.kind===`artwork`);if(o<0)return a=!0,{};let s=n[o],c=s.items.map(e=>{if(!Object.hasOwn(i,e.picture.url))return e;let t=i[e.picture.url];return t===void 0?{picture:e.picture}:{picture:e.picture,caption:t}}),l=[...n];return l[o]={...s,title:r,items:c},{panels:l}});return a?{ok:!1,reason:`not-found`}:o},x_=async(e,t,n)=>Zf(e,e=>{let r=d_(e),i=r.findIndex(e=>e.id===t),a=i+n;if(i<0||a<0||a>=r.length)return{};let o=[...r];return[o[i],o[a]]=[o[a],o[i]],{panels:o}}),S_=async(e,t,n)=>{let r=[],i=await Zf(e,e=>{let i=d_(e),a=i.findIndex(e=>e.id===t);if(a<0)return{};let o=i[a];if(o.level===n)return{};let s=o.level===`public`&&n!==`public`||o.level===`friends`&&n===`off`,c=[...i];return o.kind===`artwork`&&s&&o.items.length>0?(r=g_(o),c[a]={...o,items:[],level:n}):c[a]={...o,level:n},{panels:c}});return{outcome:i,dropped:i.ok?r:[]}},C_=async(e,t)=>{let n=[],r=await Zf(e,e=>{let r=d_(e),i=r.find(e=>e.id===t);return i===void 0?{}:(n=g_(i),{panels:r.filter(e=>e.id!==t)})});return{outcome:r,dropped:r.ok?n:[]}},w_=async(e,t,n,r)=>{let i=$g(r);if(i===null)return{ok:!1,reason:`caption`};let a=await Lg(e.storage,n,_g);if(!a.ok)return a;let o=null,s=await Zf(e,e=>{let n=d_(e),r=n.findIndex(e=>e.id===t&&e.kind===`artwork`);if(r<0)return o=`not-found`,{};let s=n[r];if(s.level===`off`)return o=`off`,{};if(s.items.length>=4)return o=`items-full`,{};let c=i===void 0?{picture:a.picture}:{picture:a.picture,caption:i},l=[...n];return l[r]={...s,items:[...s.items,c]},{panels:l}});return(!s.ok||o!==null)&&await Ig(e.storage,[a.picture]),o===null?s:{ok:!1,reason:o}},T_=async(e,t,n)=>{let r=[],i=await Zf(e,e=>{let i=d_(e),a=i.findIndex(e=>e.id===t&&e.kind===`artwork`);if(a<0)return{};let o=i[a],s=o.items.find(e=>e.picture.url===n);if(s===void 0)return{};r=[s.picture];let c=[...i];return c[a]={...o,items:o.items.filter(e=>e.picture.url!==n)},{panels:c}});return{outcome:i,dropped:i.ok?r:[]}},E_=(e,t)=>`${e}/${t}`,D_={public:[],friends:[]},O_=/^[A-Za-z0-9_-]{22}$/,k_=new TextEncoder,A_=e=>{if(typeof e!=`string`||!e.isWellFormed())return null;let t=e.normalize(`NFC`).trim();return t!==``&&pu(t,{max:500,multiline:!0})===null?t:null},j_=e=>J(Ud(k_.encode(e)).slice(0,16)),M_=({id:e,name:t,text:n,at:r})=>({id:e,name:t,text:n,at:r}),N_=e=>{if(typeof e!=`object`||!e)return null;let{id:t,name:n,text:r,at:i}=e;return typeof t!=`string`||!O_.test(t)||typeof n!=`string`||!ef(n)||typeof r!=`string`||A_(r)!==r||typeof i!=`number`||!Number.isSafeInteger(i)||i<0?null:{id:t,name:n,text:r,at:i}},P_=(...e)=>{let t=new Map;for(let n of e.flat())t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>t.at-e.at||(e.id<t.id?-1:+(e.id>t.id))).slice(0,20)},F_=e=>P_(Array.isArray(e)?e.map(N_).filter(e=>e!==null):[]),I_=e=>e.comments??D_,L_=(e,t)=>({public:P_(I_(e).public,I_(t).public),friends:P_(I_(e).friends,I_(t).friends)}),R_=(e,t)=>{let n=I_(e);return[...n.public,...n.friends].some(e=>e.id===t.id)?e:{...e,comments:{...n,public:P_([t],n.public)}}},z_=(e,t)=>{let n=I_(e);return{...e,comments:{public:n.public.filter(e=>!t.includes(e.id)),friends:n.friends.filter(e=>!t.includes(e.id))}}},B_=(e,t)=>{let n=I_(e);return t===`off`?{...e,comments:D_}:t===`friends`?{...e,comments:{public:[],friends:P_(n.friends,n.public)}}:e},V_=e=>{if(typeof e!=`object`||!e)return null;let{title:t,link:n,image:r}=e;return!xu(t,150)||!Su(n)||r!==void 0&&!Su(r)?null:r===void 0?{title:t,link:n}:{title:t,link:n,image:r}},H_=e=>{let t=[];for(let n of Array.isArray(e)?e:[]){let e=V_(n);e!==null&&!t.some(t=>t.link===e.link)&&t.length<8&&t.push(e)}return t},U_=e=>H_(e.profile.favourites?.value),W_=async(e,t,n)=>{let r=V_(t);if(r===null)return{ok:!1,reason:`invalid`};let i=!1,a=await Zf(e,e=>{let t=U_(e),a=t.filter(e=>e.link!==r.link);return n?a.length<t.length?{}:(i=t.length>=8,i?{}:{favourites:[...t,r]}):a.length===t.length?{}:{favourites:a}});return i?{ok:!1,reason:`full`}:a},G_=/^[A-Za-z0-9_-]{43}$/,K_=e=>{if(typeof e!=`string`||e[43]!==`.`||!G_.test(e.slice(0,43)))return null;let t=e.slice(44);return t.length>=1&&t.length<=300&&!t.includes(`\0`)?e:null},q_=e=>e.slice(44);function J_(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var Y_=e=>e?`"${e}" `:``;function X_(e,t=``){if(typeof e!=`boolean`)throw TypeError(Y_(t)+`expected boolean, got type=`+typeof e);return e}function Z_(e,t=``){if(typeof e!=`number`)throw TypeError(Y_(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(Y_(t)+`expected integer >= 0, got `+e);return e}function Q_(e,t,n=``){if(J_(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Z_(t,`length`);let r=J_(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=Y_(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var $_=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`)};function ev(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function tv(e,t){Q_(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function nv(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function rv(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function iv(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var av=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ov(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sv(e){for(let t=0;t<e.length;t++)e[t]=ov(e[t]);return e}var cv=av?e=>e:sv;function lv(e,t){return!e.byteLength||!t.byteLength?!1:e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function uv(e,t){if(lv(e,t)&&e.byteOffset<t.byteOffset)throw Error(`complex overlap of input and output is not supported`)}function dv(e,t){return $_(e,`defaults`),$_(t,`opts`),Object.assign(e,t)}function fv(e,t){if(e=Q_(e),t=Q_(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function pv(e,t,n){let r=t,i=n||(()=>[]),a=(e,t)=>r(t,...i(e)).update(e).digest(),o=r(new Uint8Array(e),...i(new Uint8Array));return a.outputLen=o.outputLen,a.blockLen=o.blockLen,a.create=(e,...t)=>r(e,...t),a}var mv=(e,t)=>{function n(n,...r){if(Q_(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];Q_(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength,a=e.nonceLength===void 0?0:1;if(!e.withAAD){for(let e=a;e<r.length;e++)if(J_(r[e]))throw Error(`AAD not supported`)}e.withAAD&&r[a]!==void 0&&Q_(r[a],void 0,`AAD`);let o=t(n,...r),s=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);Q_(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,Q_(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(Q_(e,void 0,`data`),i&&e.length<i)throw Error(`"ciphertext" expected length >= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function hv(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(Q_(t,e,`output`),n&&!_v(t))throw Error(`invalid output, must be aligned`);return t}function gv(e,t,n){Z_(e),Z_(t),X_(n);let r=new Uint8Array(16),i=iv(r);return i.setBigUint64(0,BigInt(t),n),i.setBigUint64(8,BigInt(e),n),r}function _v(e){return e.byteOffset%4==0}function vv(e){return Uint8Array.from(Q_(e))}var yv=e=>Uint8Array.from(e.split(``),e=>e.charCodeAt(0)),bv=cv(nv(yv(`expand 16-byte k`))),xv=cv(nv(yv(`expand 32-byte k`)));function Q(e,t){return e<<t|e>>>32-t}var Sv=64,Cv=16,wv=2**32-1,Tv=Uint32Array.of();function Ev(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Sv),u=nv(l),d=av&&_v(i)&&_v(a),f=d?nv(i):Tv,p=d?nv(a):Tv;if(!av){for(let d=0;d<c;o++){if(e(t,n,r,u,o,s),cv(u),o>=wv)throw Error(`arx: counter overflow`);let f=Math.min(Sv,c-d);for(let e=0,t;e<f;e++)t=d+e,a[t]=i[t]^l[e];d+=f}return}for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=wv)throw Error(`arx: counter overflow`);let h=Math.min(Sv,c-m);if(d&&h===Sv){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<Cv;t++)n=e+t,p[n]=f[n]^u[t];m+=Sv;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function Dv(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=dv({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return Z_(i),Z_(o),X_(a),X_(n),(t,s,c,l,u=0)=>{Q_(t,void 0,`key`),Q_(s,void 0,`nonce`),Q_(c,void 0,`data`);let d=c.length,f=l!==void 0;if(l=hv(d,l,!1),f&&uv(c,l),Z_(u),u<0||u>=wv)throw Error(`arx: counter overflow`);let p=[],m=t.length,h,g;if(m===32)p.push(h=vv(t)),g=xv;else if(m===16&&n)h=new Uint8Array(32),h.set(t),h.set(t,16),g=bv,p.push(h);else throw Q_(t,32,`arx key`),Error(`invalid key size`);(!av||!_v(s))&&p.push(s=vv(s));let _=nv(h);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);let e=s.subarray(0,16);if(av)r(g,_,nv(e),_);else{let t=cv(Uint32Array.from(g));r(t,_,nv(e),_),rv(t),cv(_)}s=s.subarray(16)}else av||cv(_);let v=16-i;if(v!==s.length)throw Error(`arx: nonce must be ${v} or 16 bytes`);if(v!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,p.push(s)}let y=cv(nv(s));try{return Ev(e,g,_,y,c,l,u,o),l}finally{rv(...p)}}}function Ov(e,t){return e[t++]&255|(e[t++]&255)<<8}var kv=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=vv(Q_(e,32,`key`));let t=Ov(e,0),n=Ov(e,2),r=Ov(e,4),i=Ov(e,6),a=Ov(e,8),o=Ov(e,10),s=Ov(e,12),c=Ov(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Ov(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Ov(e,t+0),_=Ov(e,t+2),v=Ov(e,t+4),y=Ov(e,t+6),b=Ov(e,t+8),x=Ov(e,t+10),S=Ov(e,t+12),C=Ov(e,t+14),w=i[0]+(g&8191),T=i[1]+((g>>>13|_<<3)&8191),E=i[2]+((_>>>10|v<<6)&8191),D=i[3]+((v>>>7|y<<9)&8191),O=i[4]+((y>>>4|b<<12)&8191),k=i[5]+(b>>>1&8191),A=i[6]+((b>>>14|x<<2)&8191),j=i[7]+((x>>>11|S<<5)&8191),M=i[8]+((S>>>8|C<<8)&8191),N=i[9]+(C>>>5|r),P=0,F=P+w*o+5*h*T+5*m*E+5*p*D+5*f*O;P=F>>>13,F&=8191,F+=5*d*k+5*u*A+5*l*j+5*c*M+5*s*N,P+=F>>>13,F&=8191;let I=P+w*s+T*o+5*h*E+5*m*D+5*p*O;P=I>>>13,I&=8191,I+=5*f*k+5*d*A+5*u*j+5*l*M+5*c*N,P+=I>>>13,I&=8191;let L=P+w*c+T*s+E*o+5*h*D+5*m*O;P=L>>>13,L&=8191,L+=5*p*k+5*f*A+5*d*j+5*u*M+5*l*N,P+=L>>>13,L&=8191;let R=P+w*l+T*c+E*s+D*o+5*h*O;P=R>>>13,R&=8191,R+=5*m*k+5*p*A+5*f*j+5*d*M+5*u*N,P+=R>>>13,R&=8191;let z=P+w*u+T*l+E*c+D*s+O*o;P=z>>>13,z&=8191,z+=5*h*k+5*m*A+5*p*j+5*f*M+5*d*N,P+=z>>>13,z&=8191;let ee=P+w*d+T*u+E*l+D*c+O*s;P=ee>>>13,ee&=8191,ee+=k*o+5*h*A+5*m*j+5*p*M+5*f*N,P+=ee>>>13,ee&=8191;let te=P+w*f+T*d+E*u+D*l+O*c;P=te>>>13,te&=8191,te+=k*s+A*o+5*h*j+5*m*M+5*p*N,P+=te>>>13,te&=8191;let ne=P+w*p+T*f+E*d+D*u+O*l;P=ne>>>13,ne&=8191,ne+=k*c+A*s+j*o+5*h*M+5*m*N,P+=ne>>>13,ne&=8191;let re=P+w*m+T*p+E*f+D*d+O*u;P=re>>>13,re&=8191,re+=k*l+A*c+j*s+M*o+5*h*N,P+=re>>>13,re&=8191;let ie=P+w*h+T*m+E*p+D*f+O*d;P=ie>>>13,ie&=8191,ie+=k*u+A*l+j*c+M*s+N*o,P+=ie>>>13,ie&=8191,P=(P<<2)+P|0,P=P+F|0,F=P&8191,P>>>=13,I+=P,i[0]=F,i[1]=I,i[2]=L,i[3]=R,i[4]=z,i[5]=ee,i[6]=te,i[7]=ne,i[8]=re,i[9]=ie}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;rv(n)}update(e){ev(this),Q_(e),e=vv(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){this.destroyed=!0,rv(this.h,this.r,this.buffer,this.pad)}digestInto(e){ev(this),tv(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}},Av=pv(32,e=>new kv(e));function jv(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],x=n[2],S=o,C=s,w=c,T=l,E=u,D=d,O=f,k=p,A=m,j=h,M=g,N=_,P=v,F=y,I=b,L=x;for(let e=0;e<a;e+=2)S=S+E|0,P=Q(P^S,16),A=A+P|0,E=Q(E^A,12),S=S+E|0,P=Q(P^S,8),A=A+P|0,E=Q(E^A,7),C=C+D|0,F=Q(F^C,16),j=j+F|0,D=Q(D^j,12),C=C+D|0,F=Q(F^C,8),j=j+F|0,D=Q(D^j,7),w=w+O|0,I=Q(I^w,16),M=M+I|0,O=Q(O^M,12),w=w+O|0,I=Q(I^w,8),M=M+I|0,O=Q(O^M,7),T=T+k|0,L=Q(L^T,16),N=N+L|0,k=Q(k^N,12),T=T+k|0,L=Q(L^T,8),N=N+L|0,k=Q(k^N,7),S=S+D|0,L=Q(L^S,16),M=M+L|0,D=Q(D^M,12),S=S+D|0,L=Q(L^S,8),M=M+L|0,D=Q(D^M,7),C=C+O|0,P=Q(P^C,16),N=N+P|0,O=Q(O^N,12),C=C+O|0,P=Q(P^C,8),N=N+P|0,O=Q(O^N,7),w=w+k|0,F=Q(F^w,16),A=A+F|0,k=Q(k^A,12),w=w+k|0,F=Q(F^w,8),A=A+F|0,k=Q(k^A,7),T=T+E|0,I=Q(I^T,16),j=j+I|0,E=Q(E^j,12),T=T+E|0,I=Q(I^T,8),j=j+I|0,E=Q(E^j,7);let R=0;r[R++]=o+S|0,r[R++]=s+C|0,r[R++]=c+w|0,r[R++]=l+T|0,r[R++]=u+E|0,r[R++]=d+D|0,r[R++]=f+O|0,r[R++]=p+k|0,r[R++]=m+A|0,r[R++]=h+j|0,r[R++]=g+M|0,r[R++]=_+N|0,r[R++]=v+P|0,r[R++]=y+F|0,r[R++]=b+I|0,r[R++]=x+L|0}function Mv(e,t,n,r){let i=av?e:cv(e.slice(0,4)),a=av?t:cv(t.slice(0,8)),o=av?n:cv(n.slice(0,4)),s=new Uint32Array(16);jv(i,a,o.subarray(1),s,o[0]);let c=0;r[c++]=s[0]-i[0]|0,r[c++]=s[1]-i[1]|0,r[c++]=s[2]-i[2]|0,r[c++]=s[3]-i[3]|0,r[c++]=s[12]-o[0]|0,r[c++]=s[13]-o[1]|0,r[c++]=s[14]-o[2]|0,r[c++]=s[15]-o[3]|0,cv(r),av||rv(i,a,o),rv(s)}var Nv=Dv(jv,{counterRight:!1,counterLength:8,extendNonceFn:Mv,allowShortKeys:!1}),Pv=new Uint8Array(16),Fv=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Pv.subarray(n))},Iv=new Uint8Array(32);function Lv(e,t,n,r,i){i!==void 0&&Q_(i,void 0,`AAD`);let a=e(t,n,Iv),o=gv(r.length,i?i.length:0,!0),s=Av.create(a);i&&Fv(s,i),Fv(s,r),s.update(o);let c=s.digest();return rv(a,o),c}var Rv=mv({blockSize:64,nonceLength:24,tagLength:16,withAAD:!0},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=hv(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Lv(e,t,n,s,r);return a.set(c,o),rv(c),a},decrypt(i,a){a=hv(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Lv(e,t,n,o,r);if(!fv(s,c))throw rv(c),Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),rv(c),a}}))(Nv)),zv=new TextEncoder,Bv=new TextDecoder,Vv=e=>zv.encode(e),Hv=Uint8Array.of(0),Uv=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},Wv=(e,t,n)=>Sh(Ud,gh.getSharedSecret(e,t),Vv(n),Vv(Oh),32),Gv=(e,t,n,r,i,a)=>Uv([Vv(e),Hv,Vv(t),Hv,Vv(n),Hv,Vv(r),Hv,Vv(i),Hv,Ud(a)]),Kv=(e,t)=>{let n=crypto.getRandomValues(new Uint8Array(24));return Uv([n,Rv(e,n).encrypt(t)])},qv=(e,t)=>{if(t.length<=24)return null;try{return Rv(e,t.slice(0,24)).decrypt(t.slice(24))}catch{return null}},Jv={"social.offer":Eh,"social.accept":Dh},Yv=(e,t,n,r)=>{let i=Kv(Wv(r.dhSeed,r.theirDhKey,n.roomId),Vv(JSON.stringify(t)));return{t:e,v:1,to:n.toMemberId,i:n.id,b:J(i),s:J(hh.sign(Gv(Jv[e],n.roomId,n.fromMemberId,n.toMemberId,n.id,i),r.signSeed))}},Xv=(e,t,n)=>Yv(`social.offer`,{n:J(e.nonce),p:e.profile,x:e.inbox},t,n),Zv=(e,t,n)=>Yv(`social.accept`,{o:e.offerId,p:e.profile,x:e.inbox},t,n),Qv=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return(t.t===`social.offer`||t.t===`social.accept`)&&t.v===1&&typeof t.to==`string`&&typeof t.i==`string`&&typeof t.b==`string`&&typeof t.s==`string`},$v=(e,t,n,r)=>{if(!Qv(t)||t.t!==e)return{ok:!1,reason:`malformed`};if(t.to!==n.selfMemberId)return{ok:!1,reason:`not-for-me`};let i=Y(t.b),a=Y(t.s);if(!i||!a||a.length!==64)return{ok:!1,reason:`malformed`};let o=Gv(Jv[e],n.roomId,n.fromMemberId,n.selfMemberId,t.i,i);try{if(!hh.verify(a,o,r.theirSignKey,{zip215:!1}))return{ok:!1,reason:`bad-signature`}}catch{return{ok:!1,reason:`bad-signature`}}let s=qv(Wv(r.dhSeed,r.theirDhKey,n.roomId),i);if(!s)return{ok:!1,reason:`unsealed`};if(s.length>16384)return{ok:!1,reason:`malformed`};try{let e=JSON.parse(Bv.decode(s));return typeof e!=`object`||!e?{ok:!1,reason:`malformed`}:{ok:!0,id:t.i,body:e}}catch{return{ok:!1,reason:`malformed`}}},ey=e=>e==null?null:K_(e)??void 0,ty=(e,t,n)=>{let r=$v(`social.offer`,e,t,n);if(!r.ok)return r;let i=typeof r.body.n==`string`?Y(r.body.n):null,a=hf(r.body.p),o=ey(r.body.x);return i?.length!==32||a===null||o===void 0?{ok:!1,reason:`malformed`}:{ok:!0,id:r.id,body:{nonce:i,profile:a,inbox:o}}},ny=(e,t,n)=>{let r=$v(`social.accept`,e,t,n);if(!r.ok)return r;let i=hf(r.body.p),a=ey(r.body.x);return typeof r.body.o!=`string`||i===null||a===void 0?{ok:!1,reason:`malformed`}:{ok:!0,body:{offerId:r.body.o,profile:i,inbox:a}}},ry=new TextEncoder,iy=new TextDecoder,ay=2e3,oy=(e,t)=>{if(e.includes(`\0`))throw Error(`social: a signed field may not contain a NUL`);return ry.encode(`${Mh}\u0000${e}\u0000${t}`)},sy=(e,t)=>Sh(Ud,e,ry.encode(t),ry.encode(Nh),32),cy=(e,t,n,r)=>{let i=JSON.stringify({k:J(r.signKey),d:J(r.dhKey),...n}),a=J(hh.sign(oy(e,i),r.signSeed)),o=gh.utils.randomSecretKey(),s=crypto.getRandomValues(new Uint8Array(24)),c=Rv(sy(gh.getSharedSecret(o,t),e),s).encrypt(ry.encode(JSON.stringify({b:i,s:a}))),l=new Uint8Array(24+c.length);return l.set(s),l.set(c,24),JSON.stringify({t:`social.request`,v:1,e:J(gh.getPublicKey(o)),b:J(l)})},ly=e=>{try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:null}catch{return null}},uy=(e,t)=>{let n=typeof e==`string`?Y(e):null;return n?.length===t?n:null},dy=(e,t,n,r)=>{let i=uy(n,32),a=typeof r==`string`?Y(r):null;if(i===null||a===null||a.length<=24)return null;try{return Rv(sy(gh.getSharedSecret(e.dhSeed,i),t),a.slice(0,24)).decrypt(a.slice(24))}catch{return null}},fy=(e,t)=>{if(e.kind===`party`){let n=typeof e.url==`string`?mu(e.url,ay):null;return n!==null&&n===e.url?{...t,kind:`party`,url:n}:null}if(e.kind===`comment`)return A_(e.text)===e.text?{...t,kind:`comment`,text:e.text}:null;if(e.kind!==`friend`&&e.kind!==`accept`)return null;let n=hf(e.p),r=K_(e.x),i=uy(e.r,32)===null?null:e.r;return n===null||i===null?null:e.kind===`friend`?r===null?null:{...t,kind:`friend`,p:n,x:r,r:i}:r===null&&e.x!==null&&e.x!==void 0?null:{...t,kind:`accept`,p:n,x:r,r:i}},py=(e,t,n)=>{let r=ly(e);if(r===null||r.t!==`social.request`||r.v!==1)return null;let i=dy(n,t,r.e,r.b),a=i===null?null:ly(iy.decode(i));if(a===null||typeof a.b!=`string`||ry.encode(a.b).length>16384)return null;let o=uy(a.s,64),s=ly(a.b),c=uy(s?.k,32);if(s===null||o===null||c===null)return null;try{if(!hh.verify(o,oy(t,a.b),c,{zip215:!1}))return null}catch{return null}let{name:l,to:u}=s;if(u!==J(n.signKey)||typeof l!=`string`||!ef(l))return null;let d=uy(s.d,32);if(d===null)return null;let f=fy(s,{k:s.k,d:s.d,name:l,to:u});return f===null?null:{body:f,signKey:c,dhKey:d}},my=new TextEncoder,hy=new TextDecoder,gy=Uint8Array.of(0),_y=Uint8Array.of(1),vy=(...e)=>{let t=e.map(e=>typeof e==`string`?my.encode(e):e),n=new Uint8Array(t.reduce((e,t)=>e+t.length,0)),r=0;for(let e of t)n.set(e,r),r+=e.length;return n},yy=(e,...t)=>vh(Ud,e,vy(...t)),by=e=>Math.max(8,2**Math.ceil(Math.log2(Math.max(1,e)))),xy=e=>Sh(Ud,e.dhSeed,void 0,my.encode(Ph),32),Sy=(e,t,n)=>yy(e,`k`,t,gy,n),Cy=(e,t,n)=>{try{return Sh(Ud,gh.getSharedSecret(e,t),my.encode(n),my.encode(Fh),32)}catch{return null}},wy=e=>e.map(J).sort().join(`\0`),Ty=(e,t,n,r)=>{let i=xy(e),a=my.encode(wy(n)),o=yy(i,`e`,[...r].sort().join(`\0`),_y,a).slice(0,16),s=n.map(n=>Cy(e.dhSeed,n,t)).filter(e=>e!==null);return{e:o,key:Sy(i,t,o),secret:i,members:a,slots:s}},Ey=e=>({displayName:e.displayName,bio:e.bio,links:e.links,...e.avatar==null?{}:{avatar:{url:e.avatar.url,key:e.avatar.key}},...e.background==null?{}:{background:{url:e.background.url,key:e.background.key}}}),Dy=e=>JSON.stringify({profile:e.profile===null?null:Ey(e.profile),sections:e.sections,feed:e.feed.map(Du),...e.favourites===void 0||e.favourites.length===0?{}:{favourites:e.favourites.map(({title:e,link:t,image:n})=>n===void 0?{title:e,link:t}:{title:e,link:t,image:n})},...e.comments===void 0||e.comments.length===0?{}:{comments:e.comments.map(M_)},...e.panels===void 0||e.panels.length===0?{}:{panels:e.panels.map(a_)},...e.panelOrder===void 0||e.panelOrder.length===0?{}:{panelOrder:e.panelOrder}}),Oy=(e,t,n,r)=>{let i=my.encode(Dy(n)),a=yy(e.key,`z`,r,gy,i,gy,e.members).slice(0,16),o=Rv(e.key,yy(e.key,`c`,a).slice(0,24),vy(t.roomId,gy,t.owner)).encrypt(i),s=e.slots.map(t=>({i:J(yy(t,`i`,a).slice(0,16)),w:J(Rv(t,yy(t,`w`,a).slice(0,24)).encrypt(e.key))}));for(let t=s.length;t<by(e.slots.length);t++){let n=Sh(Ud,e.secret,a,vy(`p`,String(t)),64);s.push({i:J(n.slice(0,16)),w:J(n.slice(16))})}return{e:J(e.e),z:J(a),c:J(o),s:s.sort((e,t)=>e.i<t.i?-1:+(e.i>t.i))}},ky=(e,t)=>{let n=`A`.repeat(22);return{e:n,z:n,c:`A`.repeat(Math.ceil((my.encode(Dy(t)).length+16)*4/3)),s:Array.from({length:by(e.slots.length)},()=>({i:n,w:`A`.repeat(64)}))}},Ay=/^[A-Za-z0-9_-]{22}$/,jy=/^[A-Za-z0-9_-]{64}$/,My=e=>{if(typeof e!=`object`||!e)return null;let{e:t,z:n,c:r,s:i}=e;if(typeof t!=`string`||!Ay.test(t)||typeof n!=`string`||!Ay.test(n)||typeof r!=`string`||r===``||Y(r)===null||!Array.isArray(i)||i.length>4096)return null;let a=[];for(let e of i){let{i:t,w:n}=e??{};if(typeof t!=`string`||!Ay.test(t)||typeof n!=`string`||!jy.test(n))return null;a.push({i:t,w:n})}return{e:t,z:n,c:r,s:a}},Ny=e=>{let t;try{t=JSON.parse(hy.decode(e))}catch{return null}if(typeof t!=`object`||!t)return null;let{profile:n,sections:r,feed:i,favourites:a,comments:o,panels:s,panelOrder:c}=t,l=typeof n==`object`&&n?n:null,u=l===null?null:hf({...l,version:0}),d=l?.avatar===void 0?null:cf(l.avatar)??null,f=l?.background===void 0?null:cf(l.background)??null,p=Array.isArray(r)?[...new Set(r)].filter(e=>typeof e==`string`&&Object.hasOwn(Kh,e)):[],m=s_(s),h=c_(c);return{profile:u===null?null:{displayName:u.displayName,bio:u.bio,links:u.links,...d===null?{}:{avatar:d},...f===null?{}:{background:f}},sections:p,feed:ju(i),favourites:H_(a),comments:F_(o),...m.length>0?{panels:m}:{},...h.length>0?{panelOrder:h}:{}}},Py=(e,t,n)=>{let r=Y(n.z);try{return Ny(Rv(e,yy(e,`c`,r).slice(0,24),vy(t.roomId,gy,t.owner)).decrypt(Y(n.c)))}catch{return null}},Fy=(e,t,n)=>Py(Sy(xy(e),t.roomId,Y(n.e)),t,n),Iy=(e,t,n,r)=>{let i=Cy(e.dhSeed,t,n.roomId);if(i===null)return null;let a=Y(r.z),o=J(yy(i,`i`,a).slice(0,16)),s=r.s.find(e=>e.i===o);if(s===void 0)return null;try{return Py(Rv(i,yy(i,`w`,a).slice(0,24)).decrypt(Y(s.w)),n,r)}catch{return null}},Ly=new TextEncoder,Ry={version:0,profile:null,inbox:null},zy=e=>J(Ud(Ly.encode(`${jh}\u0000${e}`))),By=(e,t,n)=>{if(e.includes(`\0`)||t.includes(`\0`))throw Error(`social: a signed field may not contain a NUL`);if(n.length!==32)throw Error(`social: a public key is 32 bytes`);let r=Ly.encode(`${kh}\u0000${e}\u0000${t}\u0000`),i=new Uint8Array(r.length+32);return i.set(r),i.set(n,r.length),i},Vy=(e,t,n)=>{if(e.includes(`\0`)||t.includes(`\0`))throw Error(`social: a signed field may not contain a NUL`);return Ly.encode(`${Ah}\u0000${e}\u0000${t}\u0000${n}`)},Hy=(e,t,n,r={})=>{let{profile:i,inbox:a,displayName:o,pageRoom:s,page:c,favourites:l,panels:u}=t,{feed:d,comments:f,friends:p}=r;return JSON.stringify({k:J(n.signKey),n:e,version:t.version,profile:i===null?null:{displayName:i.displayName,bio:i.bio,links:i.links,avatar:i.avatar,background:i.background},...a==null?{}:{inbox:{invite:a,dhKey:J(n.dhKey)}},...o?{displayName:o}:{},...s==null?{}:{pageRoom:s},...c==null?{}:{page:{accent:c.accent,...c.theme===void 0?{}:{theme:c.theme},sections:c.sections}},...d===void 0||d.length===0?{}:{feed:d.map(Du)},...l===void 0||l.length===0?{}:{favourites:l.map(({title:e,link:t,image:n})=>n===void 0?{title:e,link:t}:{title:e,link:t,image:n})},...f===void 0||f.length===0?{}:{comments:f.map(M_)},...u===void 0||u.length===0?{}:{panels:u.map(a_)},...p===void 0?{}:{friends:{e:p.e,z:p.z,c:p.c,s:p.s.map(({i:e,w:t})=>({i:e,w:t}))}}})},Uy=(e,t)=>({t:`social.name`,v:2,b:e,s:t}),Wy=e=>{try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:null}catch{return null}},Gy=(e,t,n)=>{try{return hh.verify(e,t(),n,{zip215:!1})}catch{return!1}},Ky=e=>{if(e==null)return null;if(typeof e!=`object`)return;let{invite:t,dhKey:n}=e,r=K_(t),i=typeof n==`string`?Y(n):null;return r!==null&&i?.length===32?{invite:r,dhKey:i}:void 0},qy=(e,t)=>{if(e===null)return null;if(typeof e!=`object`)return;let{displayName:n,bio:r,links:i,avatar:a,background:o}=e,s=hf({displayName:n,bio:r,links:i,version:t}),[c,l]=[cf(a),cf(o)];if(s!==null&&c!==void 0&&l!==void 0)return{displayName:s.displayName,bio:s.bio,links:s.links,avatar:c,background:l}},Jy=(e,t,n)=>{let{n:r,k:i,s:a}=e;if(r!==n||typeof i!=`string`||typeof a!=`string`)return null;let o=Y(i),s=Y(a);return o?.length!==32||s?.length!==64?null:Gy(s,()=>By(t,n,o),o)?{signKey:o,version:null,profile:null,inbox:null,page:Yh,feed:[],favourites:[],comments:[],friends:null}:null},Yy=(e,t,n,r)=>{let i=Wy(e);if(i===null||i.t!==`social.name`||!ef(r))return null;if(i.v===1)return Jy(i,t,r);let{v:a,b:o,s}=i;if(a!==2||typeof o!=`string`||typeof s!=`string`||Ly.encode(o).length>131072)return null;let c=Wy(o);if(c===null||typeof c.k!=`string`||c.n!==r)return null;let l=Y(c.k),u=Y(s);if(l?.length!==32||u?.length!==64||!Gy(u,()=>Vy(t,n,o),l))return null;let{version:d}=c;if(typeof d!=`number`||!Number.isSafeInteger(d)||d<0)return null;let f=qy(c.profile,d),p=Ky(c.inbox);if(f===void 0||p===void 0)return null;let m=c.pageRoom,h=m==null?void 0:K_(m);if(h===null)return null;let g=c.displayName,_;if(g!==void 0){if(typeof g!=`string`||g.trim().length===0||pu(g,{max:32,multiline:!1})!==null)return null;_=g}let v=s_(c.panels);return{signKey:l,version:d,profile:f,inbox:p,..._===void 0?{}:{displayName:_},...h===void 0?{}:{pageRoom:h},page:lg(c.page),feed:ju(c.feed),favourites:H_(c.favourites),comments:F_(c.comments),...v.length>0?{panels:v}:{},friends:My(c.friends)}},Xy=new TextEncoder,Zy=(e,t,n)=>{if(e.includes(`\0`)||t.includes(`\0`))throw Error(`social: a signed field may not contain a NUL`);return Xy.encode(`${Ih}\u0000${e}\u0000${t}\u0000${n}`)},Qy=(e,t,n={})=>{let{profile:r,page:i,favourites:a,panels:o}=e,{feed:s,comments:c,friends:l}=n;return JSON.stringify({k:J(t.signKey),version:e.version,profile:r===null?null:{displayName:r.displayName,bio:r.bio,links:r.links,avatar:r.avatar,background:r.background},...i==null?{}:{page:{accent:i.accent,...i.theme===void 0?{}:{theme:i.theme},sections:i.sections}},...s===void 0||s.length===0?{}:{feed:s.map(Du)},...a===void 0||a.length===0?{}:{favourites:a.map(({title:e,link:t,image:n})=>n===void 0?{title:e,link:t}:{title:e,link:t,image:n})},...c===void 0||c.length===0?{}:{comments:c.map(M_)},...o===void 0||o.length===0?{}:{panels:o.map(a_)},...l===void 0?{}:{friends:{e:l.e,z:l.z,c:l.c,s:l.s.map(({i:e,w:t})=>({i:e,w:t}))}}})},$y=(e,t)=>({t:`social.page`,v:1,b:e,s:t}),eb=(e,t,n)=>{let r=Wy(e);if(r===null||r.t!==`social.page`)return null;let{v:i,b:a,s:o}=r;if(i!==1||typeof a!=`string`||typeof o!=`string`||Xy.encode(a).length>131072)return null;let s=Wy(a);if(s===null||typeof s.k!=`string`)return null;let c=Y(s.k),l=Y(o);if(c?.length!==32||l?.length!==64||!Gy(l,()=>Zy(t,n,a),c))return null;let{version:u}=s;if(typeof u!=`number`||!Number.isSafeInteger(u)||u<0)return null;let d=qy(s.profile,u);if(d===void 0)return null;let f=s_(s.panels);return{signKey:c,version:u,profile:d,page:s.page===void 0?Yh:lg(s.page),feed:ju(s.feed),favourites:H_(s.favourites),comments:F_(s.comments),...f.length>0?{panels:f}:{},friends:My(s.friends)}},tb=1e4,nb=async(e,t=tb)=>{let n=Date.now()+t;for(;!e();){if(Date.now()>n)throw Error(`social: the room did not answer in time`);await new Promise(e=>setTimeout(e,20))}},rb=async(e,t,n)=>{let r={},i=await e.on(n=>{n.type===`message`&&n.message.from===e.self.id&&n.message.text===t&&(r.seq??=n.message.seq)});try{await e.send(t,n),await nb(()=>r.seq!==void 0)}finally{i()}let a=r.seq,o=(t,n)=>e.delete(t,n).catch(()=>{});a>1&&await o(1,a-1),await o(a+1,2**53-1)},ib=async e=>{if((await e.usage())?.messages!==1)return null;let t=new Map,n=await e.on(e=>{e.type===`message`&&t.set(e.message.seq,{seq:e.message.seq,from:e.message.from,text:e.message.text,type:e.message.envelope?.type??null})});try{let{last:n}=await e.backlog(0);if(n===0)return null;await nb(()=>t.has(n))}finally{n()}let r=[...t.values()];return r.length===1?r[0]:null},ab=async e=>(await ib(e))?.text??null,ob=e=>({type:`object`,properties:{type:{type:`string`,const:e}},required:[`type`],additionalProperties:!1}),sb={type:`page`},cb={type:`record`},lb={type:`request`},ub={version:2,types:{page:{envelope:ob(`page`),send:`owner`,maxBytes:262144}}},db={version:1,types:{request:{envelope:ob(`request`),send:`accounts`,maxBytes:65536,perAccount:{messages:16,bytes:131072}}},maxStoredBytes:4e6},fb={version:1,types:{page:{envelope:ob(`page`),send:`owner`,maxBytes:262144}}},pb=(e,t)=>e.schema()===null?void 0:t,mb=e=>{let t=e.schema()?.types;if(t!==void 0)return Object.hasOwn(t,sb.type)?sb:Object.hasOwn(t,cb.type)?cb:void 0},hb=e=>{let t=e.schema()?.types;return t!==void 0&&Object.hasOwn(t,sb.type)?sb:void 0},gb=async(e,t)=>{(e.schema()?.version??0)<t.version&&await e.setSchema(t).catch(()=>{})},_b=new TextEncoder,vb=e=>_b.encode(e).length,yb=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),bb={profile:null,sections:[],members:[],left:[]},xb=`A`.repeat(86),Sb=(e,t,n,r)=>{if(n===null||!e.claimed||e.owner!==e.self.id)return null;let i=r(n.text,e.id,e.owner);if(i!==null&&yb(i.signKey,t.signKey))return{proof:i,owner:e.owner,currentOwner:!0};if(n.from===e.owner)return null;let a=r(n.text,e.id,n.from);return a!==null&&yb(a.signKey,t.signKey)?{proof:a,owner:n.from,currentOwner:!1}:null},Cb=(e,t,n,r=e.owner)=>{let i=n.friends===null?null:Fy(t,{roomId:e.id,owner:r},n.friends);return{public:n.feed,friends:i?.feed??[],comments:{public:n.comments,friends:i?.comments??[]}}},wb=(e,t,n,r,i,a,o)=>{let s=n.friends??null,c=s===null?null:Ty(t,e.id,s.members,s.left),l=n.commentsLevel===`public`||n.commentsLevel===`friends`,u=r.comments??D_,[d,f,p]=[r.public.slice(0,50),r.friends.slice(0,50),!0],[m,h]=[u.public.slice(0,20),u.friends.slice(0,20)];for(;;){let t=s!==null&&c!==null&&p&&(s.profile!==null||f.length>0||s.favourites!==void 0||(s.panels?.length??0)>0||h.length>0||l)?{profile:s.profile,sections:s.sections,feed:f,favourites:s.favourites,comments:h,...s.panels&&s.panels.length>0?{panels:s.panels}:{},...s.panelOrder&&s.panelOrder.length>0?{panelOrder:s.panelOrder}:{}}:null,r=i(n,{feed:d,comments:m,friends:c===null||t===null?void 0:ky(c,t)}),u=a(r,xb);if(vb(r)<=131072&&vb(u)<=196568||d.length+f.length+m.length+h.length===0&&t===null){let r=c===null||t===null?void 0:Oy(c,{roomId:e.id,owner:e.self.id},t,i(n,{feed:d,comments:m})),s=i(n,{feed:d,comments:m,friends:r});return a(s,o(s))}f.length>0?f=f.slice(0,-1):h.length>0?h=h.slice(0,-1):t===null?d.length>0?d=d.slice(0,-1):m=m.slice(0,-1):p=!1}},Tb=async(e,t,n,r,i)=>{for(let a=0;a<2;a++){let a=await ib(e),o=Sb(e,t,a,r.read);if(o!==null&&o.currentOwner&&(o.proof.version??-1)>n.version)return`newer`;let s=r.prepare?r.prepare(o,n):n,c=r.emptyFeeds?.(s)||o===null?vu:Cb(e,t,o.proof,o.owner),l=i?.(c)??c,u=n.activity===void 0?l:Ru(l,n.activity),d=n.commentsLevel===void 0?u:B_(u,n.commentsLevel),f=s.friends==null&&(d.friends.length>0||(d.comments?.friends.length??0)>0)?{...s,friends:bb}:s,p=r.fit(f,d);if(a?.text===p)return`written`;let m=r.envelope();if(a!==null&&m===sb&&a.type===sb.type&&a.from===e.self.id?await e.edit(a.seq,p,m):await rb(e,p,m),(await ib(e))?.text===p)return`written`}return`failed`},Eb=`Your name and public page on FKN Social. Unclaiming it takes your page down and frees the name.`,Db=e=>e?.code,Ob=new Set([`bad-key`,`not-found`,`denied`,`blocked`,`closed`]),kb=(e,t)=>e.open(t,{key:zy(t),defaults:{send:!1,receive:!0}}),Ab=async e=>{e.defaults().send&&await e.setDefault(`send`,!1).catch(()=>{}),await gb(e,ub)},jb=(e,t)=>{let n=Db(e);return n===`bad-key`||n===`denied`?`taken`:n===`full`?t===`open`?`busy`:`out-of-claims`:`unavailable`},Mb=async(e,t)=>{let n=await ab(e);return n===null?null:Yy(n,e.id,e.owner,t)},Nb=async(e,t,n)=>{let r=await Mb(e,t);return r!==null&&yb(r.signKey,n)},Pb=(e,t,n,r,i=`none`)=>Tb(e,t.keys,n,{read:(e,n,r)=>Yy(e,n,r,t.name),prepare:(e,n)=>{if(i===`none`||e===null)return n;let r=e.proof.inbox!==null&&yb(e.proof.inbox.dhKey,t.keys.dhKey)?e.proof.inbox.invite:null;return{...n,inbox:r,...i===`all`&&e.proof.displayName!==void 0?{displayName:e.proof.displayName}:{},...i===`all`&&e.proof.pageRoom!==void 0?{pageRoom:e.proof.pageRoom}:{}}},emptyFeeds:e=>typeof e.pageRoom==`string`,fit:(n,r)=>wb(e,t.keys,n,r,(e,n)=>Hy(t.name,e,t.keys,n),(e,t)=>JSON.stringify(Uy(e,t??``)),n=>J(hh.sign(Vy(e.id,e.self.id,n),t.keys.signSeed))),envelope:()=>mb(e)},r),Fb=async(e,t,n,r,i)=>{let a;try{a=await kb(e,n)}catch(e){return{ok:!1,reason:jb(e,`open`)}}try{try{await a.claim({description:Eb})}catch(e){return{ok:!1,reason:jb(e,`claim`)}}return await Ab(a),await Pb(a,{keys:t,name:n},r??Ry,i,r===void 0?`all`:`none`).catch(()=>`failed`)===`failed`?{ok:!1,reason:`unrecorded`}:{ok:!0}}finally{await a.leave().catch(()=>{})}},Ib=async(e,t)=>{let n;try{n=await kb(e,t)}catch(e){return Db(e)===`bad-key`}try{return!n.claimed||n.owner!==n.self.id||await n.release(),!0}catch{return!1}finally{await n.leave().catch(()=>{})}},Lb=async(e,t,n,r)=>{if(!ef(t.name))return`retired`;let i;try{i=await kb(e,t.name)}catch(e){return Db(e)===`bad-key`?`taken`:`unknown`}try{if(!i.claimed)return`lost`;if(i.owner!==i.self.id)return`taken`;await Ab(i);let e=await n();if(e===null)return await Nb(i,t.name,t.keys.signKey)?`held`:`unrecorded`;let a=await r(e,async()=>{let e=Sb(i,t.keys,await ib(i),(e,n,r)=>Yy(e,n,r,t.name));return e===null?vu:Cb(i,t.keys,e.proof,e.owner)});return a===null?await Nb(i,t.name,t.keys.signKey)?`held`:`unrecorded`:(await i.claim({description:Eb}).catch(()=>{}),await Pb(i,t,a).catch(()=>`failed`)===`failed`?`unrecorded`:`held`)}catch{return`unknown`}finally{await i.leave().catch(()=>{})}},Rb=(e,t,n)=>Lb(e,t,()=>Promise.resolve(n),async e=>e),zb=async(e,t,n,r)=>{if(!ef(t.name))return`failed`;let i;try{i=await kb(e,t.name)}catch{return`failed`}try{return!i.claimed||i.owner!==i.self.id?`failed`:await Pb(i,t,n,r,`inbox`)}catch{return`failed`}finally{await i.leave().catch(()=>{})}},Bb=async(e,t,n,r,i)=>{let a=!1,o=await zb(e,t,n,e=>(a=Nu(e,r.app,r.at-_u)>=10,a?e:{...e,[i]:Lu(e[i],r)}));return a?`too-many`:o},Vb=async(e,t,n)=>{if(!ef(n))return vu;let r;try{r=await kb(e,n)}catch(e){return Ob.has(String(Db(e)))?vu:null}try{let e=Sb(r,t,await ib(r),(e,t,r)=>Yy(e,t,r,n));return e===null?vu:Cb(r,t,e.proof,e.owner)}catch{return null}finally{await r.leave().catch(()=>{})}},Hb=async(e,t)=>{if(!ef(t.name))return{inbox:null,pageRoom:null};let n;try{n=await kb(e,t.name)}catch{return{inbox:null,pageRoom:null}}try{let e=Sb(n,t.keys,await ib(n),(e,n,r)=>Yy(e,n,r,t.name));return{inbox:e!==null&&e.proof.inbox!==null&&yb(e.proof.inbox.dhKey,t.keys.dhKey)?e.proof.inbox.invite:null,pageRoom:e?.proof.pageRoom??null}}catch{return{inbox:null,pageRoom:null}}finally{await n.leave().catch(()=>{})}},Ub=async(e,t,n)=>{if(!ef(t))return!1;let r;try{r=await kb(e,t)}catch(e){return Db(e)!==`bad-key`&&null}try{return await Nb(r,t,n)}catch{return null}finally{await r.leave().catch(()=>{})}},Wb=async(e,t)=>{let n;try{n=await kb(e,t)}catch(e){let t=String(Db(e));return t===`full`?{view:{kind:`busy`}}:{view:Ob.has(t)?{kind:`none`}:{kind:`unavailable`}}}try{if(!n.claimed)return{view:{kind:`unheld`}};let e=await ab(n),r=e===null?null:Yy(e,n.id,n.owner,t);if(r===null)return{view:{kind:`none`}};let i={kind:`shown`,signKey:r.signKey,...r.displayName===void 0?{}:{displayName:r.displayName},profile:r.profile,inbox:r.inbox,page:r.page,feed:r.feed,favourites:r.favourites,comments:r.comments,...r.panels===void 0?{}:{panels:r.panels}};return r.pageRoom!==void 0&&e!==null?{view:i,pageRoom:r.pageRoom,coreRecord:{roomId:n.id,owner:n.owner,text:e}}:{view:r.friends===null||e===null?i:{...i,record:{name:t,roomId:n.id,owner:n.owner,text:e}}}}catch{return{view:{kind:`unavailable`}}}finally{await n.leave().catch(()=>{})}},Gb=async(e,t)=>(await Wb(e,t)).view,Kb=`Your inbox on FKN Social. Unclaiming it deletes the requests waiting there.`,qb={send:!0,receive:!1,maxMessageBytes:65536},Jb=5e3,Yb=e=>e?.code,Xb=e=>Y(e),Zb=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),Qb=e=>{let t=e.profile.inbox;return t===void 0?void 0:K_(t.value)},$b=async(e,t)=>{if(t!==void 0){let n=await Zf(e,e=>Qb(e)===t?{inbox:null}:{});if(!n.ok)return n}let n;try{n=await e.rooms.create({defaults:qb,schema:db})}catch(e){return{ok:!1,reason:Yb(e)===`full`?`busy`:`unavailable`}}try{try{await n.claim({description:Kb})}catch(t){if(Yb(t)!==`full`)return{ok:!1,reason:`unavailable`};let n=await Zf(e,e=>Qb(e)===void 0?{inbox:null}:{});return{ok:!1,reason:`out-of-claims`,roster:n.ok?n.roster:void 0}}let t=await Zf(e,e=>typeof Qb(e)==`string`?{}:{inbox:n.invite});return(!t.ok||Qb(t.roster)!==n.invite)&&await n.release().catch(()=>{}),t}finally{await n.leave().catch(()=>{})}},ex=async(e,t)=>{let n;try{n=await e.join(t)}catch(e){return Yb(e)===`bad-key`}try{return!n.claimed||n.owner!==n.self.id||await n.release(),!0}catch{return!1}finally{await n.leave().catch(()=>{})}},tx=(e,t)=>({status:e,roster:t,waiting:[],accepted:[]}),nx=async e=>{let t=new Map,n=[],r=await e.on(e=>{e.type===`message`&&t.set(e.message.seq,e.message.text)});try{let r=0;for(;t.size<100;){let i=await e.backlog(r,100-t.size);if(i.last>r&&await nb(()=>t.has(i.last),Jb).catch(()=>{n.push(i.last)}),!i.more||i.last<=r)break;r=i.last}}catch{}finally{r()}return{heard:[...t].sort(([e],[t])=>e-t).slice(0,100),unread:n}},rx=(e,t)=>e.friends[tf(t)]?.value.state===`active`,ix=async(e,t,n,r,i)=>{let a=i,o=!1,s=[...r.unread],c=[],l=[],u=new Map;for(let[i,d]of r.heard){let r=py(d,n.id,t);if(r===null||Zb(r.signKey,t.signKey)){s.push(i);continue}let{body:f,signKey:p,dhKey:m}=r,h={signKey:p,dhKey:m,name:f.name,fingerprint:tf(p),confirmed:null};if(f.kind===`accept`){let t=await sp(e,{signKey:p,dhKey:m,name:f.name,profile:f.p,pairNonce:Xb(f.r),linkedVia:`request`,inbox:f.x},Date.now());if(!t.outcome.ok)continue;if(t.applied){a=t.outcome.roster,o=!0;let e=a.friends[h.fingerprint]?.value.name??f.name;l.includes(e)||l.push(e)}s.push(i)}else if(f.kind===`friend`){let e=u.get(h.fingerprint);e!==void 0&&(s.push(e.seq),c.splice(c.indexOf(e),1));let t={kind:`friend`,inbox:n.invite,seq:i,sender:h,request:f,friend:rx(a,p)};u.set(h.fingerprint,t),c.push(t)}else if(f.kind===`comment`){let e=a.friends[h.fingerprint]?.value;e?.state===`active`&&ig(a,`comments`)!==`off`?c.push({kind:`comment`,inbox:n.invite,seq:i,sender:{...h,name:e.name},text:f.text,id:j_(d)}):s.push(i)}else rx(a,p)?c.push({kind:`party`,inbox:n.invite,seq:i,sender:h,url:f.url}):s.push(i)}return await Promise.all([...new Set(s)].map(e=>n.delete(e).catch(()=>{}))),{roster:o?a:void 0,waiting:c,accepted:l}},ax=async(e,t,n)=>{let r=Qb(n);if(r===void 0){let t=await $b(e);return t.ok?tx(`ready`,t.roster):tx(t.reason===`out-of-claims`?`out-of-claims`:`unavailable`,t.roster)}if(r===null)return tx(`none`);let i=async()=>{let t=await Zf(e,e=>Qb(e)===r?{inbox:null}:{});return tx(`none`,t.ok?t.roster:void 0)},a;try{a=await e.rooms.join(r)}catch(e){return Yb(e)===`bad-key`?i():tx(`unavailable`)}let o;try{if(!a.claimed)return await i();if(a.owner!==a.self.id)return tx(`taken`);if(await gb(a,db),a.mailbox===null)return tx(`not-kept`);o=await ix(e,t,a,await nx(a),n)}catch{return tx(`unavailable`)}finally{await a.leave().catch(()=>{})}return{status:`ready`,roster:o.roster,waiting:o.waiting,accepted:o.accepted}},ox=new Set([`bad-key`,`not-found`,`denied`,`blocked`,`closed`,`invalid`]),sx=async(e,t,n,r,i)=>{let a;try{a=await e.join(t)}catch(e){let t=String(Yb(e));return t===`full`?`busy`:ox.has(t)?`closed`:`unavailable`}try{return a.mailbox===null?`closed`:(await a.send(cy(a.id,n,r,i),pb(a,lb)),`sent`)}catch(e){let t=String(Yb(e));return t===`storage`||t===`quota`||t===`full`?`full`:t===`rate-limited`?`busy`:t===`denied`||t===`blocked`?`closed`:`unavailable`}finally{await a.leave().catch(()=>{})}},cx=async(e,t,n)=>{let r;try{r=await e.join(t)}catch{return}try{r.claimed&&r.owner===r.self.id&&await r.delete(n).catch(()=>{})}finally{await r.leave().catch(()=>{})}},lx=async(e,t,n)=>{if(Zb(n.signKey,t.keys.signKey))return{ok:!1,reason:`self`};if(t.inbox===null)return{ok:!1,reason:`no-inbox`};if(n.inbox===null)return{ok:!1,reason:`closed`};let{invite:r,dhKey:i}=n.inbox,a=await op(e,{signKey:n.signKey,dhKey:i,name:n.name,inbox:r},Date.now());if(!a.ok)return a;let o=await sx(e.rooms,r,i,{to:J(n.signKey),name:t.name,kind:`friend`,p:t.profile,x:t.inbox,r:a.nonce},t.keys);return o===`sent`?{ok:!0}:{ok:!1,reason:o}},ux=async(e,t,n,r)=>{if(!r)return await cx(e.rooms,n.inbox,n.seq),{ok:!0};let{sender:i,request:a}=n,o=await ip(e,{signKey:i.signKey,dhKey:i.dhKey,name:i.name,profile:a.p,pairNonce:Xb(a.r),linkedVia:`request`,inbox:a.x},Date.now());return o.ok?await sx(e.rooms,a.x,i.dhKey,{to:a.k,name:t.name,kind:`accept`,p:t.profile,x:t.inbox,r:a.r},t.keys)===`sent`?(await cx(e.rooms,n.inbox,n.seq),{ok:!0,roster:o.roster}):{ok:!1,reason:`unsent`,roster:o.roster}:o},dx=async(e,t,n,r)=>{let i=K_(n.inbox);if(i===null)return{ok:!1,reason:`no-inbox`};let a=mu(r,ay);if(a===null)return{ok:!1,reason:`link`};let o=await sx(e.rooms,i,Xb(n.dhKey),{to:n.signKey,name:t.name,kind:`party`,url:a},t.keys);return o===`sent`?{ok:!0}:{ok:!1,reason:o}},fx=(e,t)=>cx(e.rooms,t.inbox,t.seq),px=async(e,t,n,r)=>{let i=A_(r);if(i===null)return{ok:!1,reason:`invalid`};let a=await qf(e);if(!a.ok)return a;let o=await Gb(e.rooms,n);if(o.kind===`busy`||o.kind===`unavailable`)return{ok:!1,reason:o.kind};if(o.kind!==`shown`||!rx(a.roster,o.signKey))return{ok:!1,reason:`not-friend`};if(o.inbox===null)return{ok:!1,reason:`closed`};let s=await sx(e.rooms,o.inbox.invite,o.inbox.dhKey,{to:J(o.signKey),name:t.name,kind:`comment`,text:i},t.keys);return s===`sent`?{ok:!0}:{ok:!1,reason:s}},mx=`Your profile page on FKN Social. Unclaiming it deletes stored activity and comments and moves your profile back to your name room.`,hx={send:!1,receive:!0},gx=e=>e?.code,_x=e=>{let t=e.profile.pageRoom;return t===void 0?void 0:K_(t.value)},vx=e=>{let t=e.profile.visibility?.value;return t!==void 0&&`invite`in t&&typeof t.invite==`string`},yx=(e,t)=>{if(vx(e))return!1;if(lf(e).level===`public`)return!0;let n=pf(e);return n.displayName!==``||n.bio!==``||n.links.length>0||(e.profile.avatar?.value??null)!==null||(e.profile.background?.value??null)!==null||e.profile.page!==void 0||d_(e).length>0||U_(e).length>0||t!==void 0&&(t.public.length>0||t.friends.length>0||(t.comments?.public.length??0)>0||(t.comments?.friends.length??0)>0)},bx=async e=>{e.defaults().send&&await e.setDefault(`send`,!1).catch(()=>{}),await gb(e,fb)},xx=(e,t,n,r)=>Tb(e,t,n,{read:eb,fit:(n,r)=>wb(e,t,n,r,(e,n)=>Qy(e,t,n),(e,t)=>JSON.stringify($y(e,t??``)),n=>J(hh.sign(Zy(e.id,e.self.id,n),t.signSeed))),envelope:()=>hb(e)},r),Sx=e=>t=>({public:Mu(t.public,e.public),friends:Mu(t.friends,e.friends),comments:L_(t,e)}),Cx=async(e,t,n,r,i)=>{if(i!==void 0&&!(await Zf(e,e=>_x(e)===i?{pageRoom:null}:{})).ok)return{ok:!1,reason:`unavailable`};let a;try{a=await e.rooms.create({defaults:hx,schema:fb})}catch{return{ok:!1,reason:`unavailable`}}try{try{await a.claim({description:mx})}catch(t){if(gx(t)!==`full`)return{ok:!1,reason:`unavailable`};let n=await Zf(e,e=>_x(e)===void 0?{pageRoom:null}:{});return{ok:!1,reason:`out-of-claims`,roster:n.ok?n.roster:void 0}}if(await bx(a),await xx(a,t,n,r).catch(()=>`failed`)===`failed`)return await a.release().catch(()=>{}),{ok:!1,reason:`unavailable`};let i=await Zf(e,e=>typeof _x(e)==`string`?{}:{pageRoom:a.invite});if(i.ok&&_x(i.roster)===a.invite)return{ok:!0,invite:a.invite,roster:i.roster};if(await a.release().catch(()=>{}),!i.ok)return{ok:!1,reason:`unavailable`};let o=_x(i.roster);if(typeof o==`string`){let a=await wx(e,t,o,n,r);return a.status===`ready`?{ok:!0,invite:o,roster:i.roster}:{ok:!1,reason:`unavailable`,roster:a.roster??i.roster}}return{ok:!1,reason:`unavailable`}}finally{await a.leave().catch(()=>{})}},wx=async(e,t,n,r,i)=>{let a=async()=>{let t=await Zf(e,e=>_x(e)===n?{pageRoom:null}:{});return{status:`inline`,roster:t.ok?t.roster:void 0}},o;try{o=await e.rooms.join(n)}catch(e){return gx(e)===`bad-key`?await a():{status:`unavailable`}}try{return o.claimed?o.owner===o.self.id?(await bx(o),o.mailbox===null?{status:`not-kept`}:(await o.claim({description:mx}).catch(()=>{}),{status:await xx(o,t,r,i).catch(()=>`failed`)===`failed`?`unavailable`:`ready`})):{status:`taken`}:await a()}catch{return{status:`unavailable`}}finally{await o.leave().catch(()=>{})}},Tx=async(e,t,n,r,i)=>{let a;try{a=await e.join(t)}catch{return`failed`}try{return!a.claimed||a.owner!==a.self.id||a.mailbox===null?`failed`:await xx(a,n,r,i)}catch{return`failed`}finally{await a.leave().catch(()=>{})}},Ex=async(e,t,n,r,i,a)=>{let o=!1,s=await Tx(e,t,n,r,e=>(o=Nu(e,i.app,i.at-_u)>=10,o?e:{...e,[a]:Lu(e[a],i)}));return o?`too-many`:s},Dx=async(e,t)=>{let n;try{n=await e.join(t)}catch(e){return gx(e)===`bad-key`}try{return!n.claimed||n.owner!==n.self.id||await n.release(),!0}catch{return!1}finally{await n.leave().catch(()=>{})}},Ox=async(e,t,n)=>{let r;try{r=await e.join(n)}catch{return}try{if(!r.claimed||r.owner!==r.self.id||r.mailbox===null)return;let e=Sb(r,t,await ib(r),eb);if(e===null||e.currentOwner)return;await bx(r),await xx(r,t,{version:0,profile:null})}catch{}finally{await r.leave().catch(()=>{})}},kx=e=>e?.code,Ax=e=>[e.profile.avatar?.value??null,e.profile.background?.value??null],jx=e=>{let t=e.profile.visibility?.value;return t!==void 0&&`invite`in t&&typeof t.invite==`string`?t.invite:null},Mx=e=>{let t=lf(e).level,n=jx(e)===null,{displayName:r,bio:i,links:a}=pf(e),[o,s]=Ax(e),c=n?m_(e):[],l=n?p_(e):[];return{profile:t===`friends`&&n?{displayName:r,bio:i,links:a,...o===null?{}:{avatar:o},...s===null?{}:{background:s}}:null,sections:cg(e,t!==`me`&&n),...ig(e,`favourites`)===`friends`?{favourites:U_(e)}:{},...c.length>0?{panels:c}:{},...c.length>0&&l.length>0?{panelOrder:h_(e)}:{},members:jf(e).map(e=>Y(e.dhKey)).filter(e=>e?.length===32),left:Object.entries(e.friends).filter(([,e])=>e.value.state!==`active`).map(([e])=>e).sort()}},Nx=e=>{let t=pf(e),n=Math.max(0,...kf(e).map(({lamport:e})=>e)),r=jx(e)===null,i=lf(e).level===`public`&&r,a=sg(e,i),o=ig(e,`activity`),s=Mx(e),c=ig(e,`favourites`)===`public`?U_(e):void 0,l=r?p_(e):[],u=ig(e,`comments`);if(!i)return{version:n,profile:null,page:a,activity:o,favourites:c,commentsLevel:u,...l.length>0?{panels:l}:{},friends:s};let[d,f]=Ax(e);return{version:n,profile:{displayName:t.displayName,bio:t.bio,links:t.links,avatar:d,background:f},page:a,activity:o,favourites:c,commentsLevel:u,...l.length>0?{panels:l}:{},friends:s}},Px=(e,t=!1)=>({...Nx(e),inbox:t?null:Qb(e)??null}),Fx=(e,t,n=!1)=>{let r=Math.max(0,...kf(e).map(({lamport:e})=>e)),i=n?null:Qb(e)??null,a=jx(e)===null,o=lf(e).level===`public`&&a,s=t!==null&&o?pf(e).displayName:``;return{version:r,profile:null,inbox:i,...s===``?{}:{displayName:s},...t===null?{}:{pageRoom:t}}},Ix=e=>JSON.stringify({inbox:e.inbox??null,displayName:e.displayName??null,pageRoom:e.pageRoom??null}),Lx=(e,t=!1)=>{let n=_x(e);return typeof n==`string`?Fx(e,n,t):Px(e,t)},Rx=async(e,t,n,r)=>{if(r?.skipNameIfUnchanged===!0&&r.lastNameStatus===`held`&&n!==null&&!(`then`in n)){let{roster:i,inboxTaken:a}=n,o=_x(i);if(typeof o==`string`){let n=Ix(Fx(i,o,a));if(n===r.lastCoreKey){let r=await wx(e,t.keys,o,Nx(i));if(r.status!==`inline`)return{status:`held`,pageStatus:r.status,...r.roster?{roster:r.roster}:{},coreKey:n};let s=r.roster??i;return{status:await Rb(e.rooms,t,Px(s,a)),pageStatus:`inline`,...r.roster?{roster:r.roster}:{},coreKey:null}}}}let i=`unused`,a,o=null,s=n!==null&&!(`then`in n)?n:null,c=s?_x(s.roster):void 0,l=typeof c==`string`?wx(e,t.keys,c,Nx(s.roster)):null,u=await Lb(e.rooms,t,()=>Promise.resolve(n),async({roster:n,inboxTaken:r},s)=>{let c=_x(n);if(typeof c==`string`){l??=wx(e,t.keys,c,Nx(n));let s=await l;if(a=s.roster,s.status===`inline`)return i=`inline`,o=null,Px(s.roster??n,r);if(i=s.status,s.status===`unavailable`)return o=null,null;let u=Fx(n,c,r);return o=Ix(u),u}if(c===void 0){let c=await s();if(!yx(n,c))return i=`unused`,o=null,Px(n,r);let l=await Cx(e,t.keys,Nx(n),Sx(c));if(a=l.roster,l.ok){i=`ready`;let e=Fx(l.roster,l.invite,r);return o=Ix(e),e}return i=l.reason===`out-of-claims`?`out-of-claims`:`unavailable`,o=null,Px(l.roster??n,r)}return i=`inline`,o=null,Px(n,r)}),d=await Promise.resolve(n);if(d!==null&&l===null&&typeof _x(d.roster)==`string`&&(l=wx(e,t.keys,_x(d.roster),Nx(d.roster))),l!==null){let e=await l;i=e.status,e.roster!==void 0&&(a=e.roster)}return{status:u,pageStatus:i,...a?{roster:a}:{},coreKey:u===`held`?o:null}},zx=async(e,t,n)=>{for(let r=0;r<2;r++){let r=await qf(e);if(!r.ok)return`failed`;let i=_x(r.roster);if(typeof i==`string`&&e.rooms.join!==void 0){let a=await Tx(e.rooms,i,t.keys,Nx(r.roster),n);if(a!==`newer`)return a}else{let i=await zb(e.rooms,t,Px(r.roster),n);if(i!==`newer`)return i}}return`failed`},Bx=async(e,t,n)=>{let r={id:n.id,name:n.sender.name,text:n.text,at:Date.now()};return await zx(e,t,e=>R_(e,r))===`written`&&(await fx(e,n),!0)},Vx=async(e,t,n=!1)=>{let r=await Zf(e,e=>lf(e).level===`public`?{}:{visibility:{level:`public`}});if(!r.ok)return r;let i=await Rx(e,t,{roster:r.roster,inboxTaken:n});return{ok:!0,roster:i.roster??r.roster,status:i.status,pageStatus:i.pageStatus}},Hx=async(e,t,n=!1)=>{let r;try{r=await e.join(t)}catch(e){return kx(e)===`bad-key`}try{return r.claimed?r.owner===r.self.id?(await r.release(),!0):!n:!0}catch{return!1}finally{await r.leave().catch(()=>{})}},Ux=async(e,t,n,r,i=!1)=>{let a=jx(n);if(a!==null&&!await Hx(e.rooms,a))return{ok:!1,reason:`unavailable`};let o=lf(n).level,s=o===`public`,c=o===`friends`&&r===`me`,l=[],u=await Zf(e,e=>{if(s){let t=Ax(e);return l=t.some(e=>e!==null)?t:Ax(n),lf(e).level===r&&t.every(e=>e===null)?{}:{visibility:{level:r},avatar:null,background:null}}if(lf(e).level===`public`)return{};if(c){let t=Ax(e);if(t.some(e=>e!==null))return l=t,{visibility:{level:r},avatar:null,background:null}}return{visibility:{level:r}}});if(!u.ok)return u;let d=await Rx(e,t,{roster:u.roster,inboxTaken:i});return typeof _x(u.roster)==`string`&&d.pageStatus!==`ready`&&d.pageStatus!==`inline`?{ok:!1,reason:`unavailable`,pageStatus:d.pageStatus}:(await Ig(e.storage,l),{ok:!0,roster:d.roster??u.roster,status:d.status,pageStatus:d.pageStatus})},Wx=async(e,t)=>{let n=jx(t);if(n===null)return{ok:!0,roster:t};if(!await Hx(e.rooms,n,!0))return{ok:!1,reason:`unavailable`};let r=[],i=await Zf(e,e=>jx(e)===n?(r=Ax(e),{visibility:{level:`friends`},avatar:null,background:null}):{});return i.ok&&await Ig(e.storage,r),i},Gx=`FKNS`,Kx=e=>{if(e.length!==32)throw Error(`social: a seed is 32 bytes`);return`${Gx}-${(Kd(e).match(/.{1,4}/g)??[]).join(`-`)}`},qx=e=>{let t=Jd(e),n=t.length===56&&t.startsWith(`FKNS`)?t.slice(4):t;if(n.length!==52||!qd(n))return null;let r=Yd(n);return r!==null&&r.length===32?r:null},Jx=`v1/identity.json`,Yx=1024,Xx=3e3,Zx=({seed:e,name:t})=>{let n=JSON.stringify({v:1,seed:J(e),name:t,pad:``});return n.replace(`"pad":""`,`"pad":"${` `.repeat(Yx-n.length)}"`)},Qx=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{v:n,seed:r,name:i}=t;if(n!==1)return`newer`;if(typeof r!=`string`||i!==null&&typeof i!=`string`)return null;let a=Y(r);return a?.length===32?{seed:a,name:i}:null},$x=async e=>{let t;try{t=await e.read(Jx)}catch(e){return{ok:!1,refusal:xf(e)}}if(t===null)return{ok:!0,identity:null};let n=Qx(t);return n===`newer`?{ok:!1,refusal:`newer`}:n?{ok:!0,identity:n}:{ok:!1,refusal:`reset`}},eS=async(e,t)=>{try{return await e.write(Jx,Zx(t)),null}catch(e){return xf(e)}},tS=async(e,t)=>{let n=await $x(e);if(!n.ok||n.identity!==null)return n;let r=await eS(e,{seed:Rh(),name:null});return r===null?(await t(Xx),$x(e)):{ok:!1,refusal:r}},nS=(e,t)=>{let n=e=>t()?e():Promise.reject(Error(`social: the FKN account changed`)),{cloud:r,storage:i}=e;return{...e,cloud:{list:()=>n(()=>r.list()),read:e=>n(()=>r.read(e)),write:(e,t)=>n(()=>r.write(e,t)),remove:e=>n(()=>r.remove(e))},storage:{put:e=>n(()=>i.put(e)),get:(e,t)=>n(()=>i.get(e,t)),delete:e=>n(()=>i.delete(e)),list:()=>n(()=>i.list())}}},rS=e=>({kind:e}),iS=async({account:e,cloud:t},n)=>{let r=await e.availability().catch(()=>`unknown`);if(r===`unknown`)return{kind:`unreachable`};if(r===`disconnected`)return{kind:`signed-out`};let i=await e.encryption().catch(()=>null);if(i===null)return{kind:`unreachable`};if(!i.enrolled)return{kind:`no-keys`};if(!i.unlocked)return{kind:`locked`};n?.();let a=await $x(t);return a.ok?a.identity===null?{kind:`no-identity`}:{kind:`ready`,identity:a.identity}:rS(a.refusal)},aS=async(e,t,n)=>{let r=$d(t);if(!r.ok)return r;let i=await tS(e.cloud,e.sleep);if(!i.ok)return{ok:!1,reason:i.refusal};let a=i.identity;if(a===null)return{ok:!1,reason:`unreachable`};if(a.name===r.name)return{ok:!0};let o=zh(a.seed),s=typeof n?.pageRoom==`string`,c=a.name===null||s?void 0:await Vb(e.rooms,o,a.name);if(c===null)return{ok:!1,reason:`unavailable`};let l=await Fb(e.rooms,o,r.name,n,c===void 0?void 0:e=>({public:Mu(e.public,c.public),friends:Mu(e.friends,c.friends),comments:L_(e,c)}));if(!l.ok&&l.reason!==`unrecorded`)return l;if(l.ok&&n===void 0){let t=await Hb(e.rooms,{keys:o,name:r.name});t.pageRoom!==null&&await Ox(e.rooms,o,t.pageRoom)}if(!l.ok&&a.name!==null)return await Ib(e.rooms,r.name)?{ok:!1,reason:`unavailable`}:{ok:!1,reason:`unavailable`,kept:r.name};let u=await eS(e.cloud,{...a,name:r.name});return u===null?a.name===null||await Ib(e.rooms,a.name)?{ok:!0}:{ok:!0,kept:a.name}:{ok:!1,reason:u}},oS=async(e,t)=>await Ib(e.rooms,t)?{ok:!0}:{ok:!1,reason:`unavailable`},sS=async(e,t,n)=>t.name===null?{ok:!1,reason:`empty`}:Fb(e.rooms,zh(t.seed),t.name,n),cS=async(e,t)=>{let n=qx(t);if(n===null)return{ok:!1,reason:`bad-recovery-key`};let r=await eS(e.cloud,{seed:n,name:null});return r===null?{ok:!0}:{ok:!1,reason:r}},lS=async e=>{let t=await eS(e.cloud,{seed:Rh(),name:null});return t===null?{ok:!0}:{ok:!1,reason:t}},uS=async({cloud:e,rooms:t,storage:n})=>{let r=await qf({cloud:e});if(r.ok)return{ok:!0};if(r.reason!==`reset`)return{ok:!1,reason:r.reason};let i=await $x(e);if(i.ok&&i.identity?.name!=null){let n=await Hb(t,{keys:zh(i.identity.seed),name:i.identity.name});if(n.inbox!==null||n.pageRoom!==null){let r=await qf({cloud:e});if(r.ok)return{ok:!0};if(r.reason!==`reset`)return{ok:!1,reason:r.reason};n.inbox!==null&&await ex(t,n.inbox),n.pageRoom!==null&&await Dx(t,n.pageRoom)}}let a=await n.list().then(({objects:e})=>e,()=>[]);for(let{url:e}of a)await n.delete(e).catch(()=>{});try{let t=(await e.list()).map(({path:e})=>e).filter(e=>e!==Jx);for(let n of t)await e.remove(n);return{ok:!0}}catch(e){return{ok:!1,reason:xf(e)}}},dS=e=>Array.isArray(e)?gu.filter(t=>e.includes(t)):[],fS=(e,t)=>{let n=e.apps[t]?.value;if(typeof n!=`object`||!n)return null;let{kinds:r,level:i,state:a}=n;return{kinds:dS(r),level:i===`public`?`public`:`friends`,state:a===`asked`||a===`allowed`?a:`stopped`}},pS=e=>e?.state===`allowed`?{state:`allowed`,kinds:e.kinds}:e?.state===`asked`?{state:`asked`}:{state:`off`},mS=e=>e.reason===`locked`?`locked`:`unavailable`,hS=async e=>{let t=await iS(e);if(t.kind===`locked`)return`locked`;if(t.kind===`no-identity`)return`no-name`;if(t.kind!==`ready`)return`unavailable`;let{seed:n,name:r}=t.identity;if(r===null)return`no-name`;let i=await qf(e);return i.ok?{me:{keys:zh(n),name:r},roster:i.roster}:mS(i)},gS=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),_S=e=>{let t=async(t,n)=>{let r=await hS(e);if(typeof r==`string`)return{state:r};let i=fS(r.roster,t);if(n(i)===null)return pS(i);let a=await Qf(e,t,e=>{let r=n(fS(e,t));return r===null?null:{grant:r}});return a.ok?pS(fS(a.roster,t)):{state:mS(a)}},n=Promise.resolve(),r=e=>{let t=n.then(e,e);return n=t.catch(()=>{}),t};return{publishing:async t=>{let n=await hS(e);return typeof n==`string`?{state:n}:pS(fS(n.roster,t))},allow:(e,n)=>{let r=dS(n?.kinds);return t(e,e=>r.length===0||e?.state===`allowed`||e?.state===`asked`&&gS(e.kinds,r)?null:{kinds:r,level:e?.level??`friends`,state:`asked`})},stop:e=>t(e,e=>e===null||e.state===`stopped`?null:{...e,state:`stopped`}),publish:(t,n)=>r(async()=>{for(let r=0;r<2;r++){let r=await hS(e);if(typeof r==`string`)return{ok:!1,reason:r};let i=fS(r.roster,t),a=ig(r.roster,`activity`);if(i?.state!==`allowed`||a===`off`)return{ok:!1,reason:`not-allowed`};let o=Au(n,t,Date.now());if(o===null)return{ok:!1,reason:`invalid`};if(!i.kinds.includes(o.kind))return{ok:!1,reason:`not-allowed`};let s=_x(r.roster),c=typeof s==`string`?await Ex(e.rooms,s,r.me.keys,Nx(r.roster),o,i.level):await Bb(e.rooms,r.me,Px(r.roster),o,i.level);if(c===`written`)return{ok:!0,id:o.id};if(c!==`newer`)return{ok:!1,reason:c===`too-many`?`too-many`:`unavailable`}}return{ok:!1,reason:`unavailable`}})}},vS=(e,t,n)=>Qf(e,t,e=>{let r=fS(e,t);if(r===null)return null;let i={...r,...n},a=i.state===`allowed`&&r.state!==`allowed`&&ig(e,`activity`)===`off`?ag(ng(e),`activity`,i.level):void 0;return a===void 0&&JSON.stringify(i)===JSON.stringify(r)?null:{grant:i,page:a}}),yS=new TextEncoder,bS=e=>yS.encode(e),xS=0,SS=e=>{let t=[e.roomId,e.memberId,String(e.at),e.name,e.displayName,e.avatarUrl];for(let e of t)if(e.includes(`\0`))throw Error(`social: a signed field may not contain a NUL`);if(e.signKey.length!==32||e.dhKey.length!==32)throw Error(`social: a public key is 32 bytes`);let n=[bS(Th),Uint8Array.of(xS),bS(e.roomId),Uint8Array.of(xS),bS(e.memberId),Uint8Array.of(xS),bS(String(e.at)),Uint8Array.of(xS),e.signKey,Uint8Array.of(xS),e.dhKey,Uint8Array.of(xS),bS(e.name.normalize(`NFC`)),Uint8Array.of(xS),bS(e.displayName.normalize(`NFC`)),Uint8Array.of(xS),bS(e.avatarUrl)],r=n.reduce((e,t)=>e+t.length,0),i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i},CS=(e,t)=>({t:`social.hello`,v:1,k:J(e.signKey),d:J(e.dhKey),h:e.name,n:e.displayName,i:e.avatarUrl===``?null:e.avatarUrl,a:e.at,s:J(hh.sign(SS(e),t))}),wS=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t.t===`social.hello`&&typeof t.k==`string`&&typeof t.d==`string`&&typeof t.h==`string`&&typeof t.n==`string`&&(t.i===null||typeof t.i==`string`)&&typeof t.a==`number`&&typeof t.s==`string`},TS=(e,t,n)=>{if(!wS(e))return{ok:!1,reason:`malformed`};if(e.v!==1)return{ok:!1,reason:`unsupported-version`};let r=Y(e.k),i=Y(e.d),a=Y(e.s);if(!r||!i||!a)return{ok:!1,reason:`malformed`};if(r.length!==32||i.length!==32)return{ok:!1,reason:`bad-key`};if(a.length!==64||!Number.isSafeInteger(e.a))return{ok:!1,reason:`malformed`};let o={roomId:t,memberId:n,at:e.a,signKey:r,dhKey:i,name:e.h,displayName:e.n,avatarUrl:e.i??``},s;try{s=SS(o)}catch{return{ok:!1,reason:`malformed`}}try{if(!hh.verify(a,s,r,{zip215:!1}))return{ok:!1,reason:`bad-signature`}}catch{return{ok:!1,reason:`bad-signature`}}return{ok:!0,hello:o}},ES=(e,t)=>({roomId:e,selfMemberId:t,participants:new Map,keyByMember:new Map}),DS=(e,t)=>({memberId:e,status:`silent`,identity:null,refusal:null,self:e===t}),OS=(e,t)=>{e.participants.has(t)||e.participants.set(t,DS(t,e.selfMemberId))},kS=(e,t,n)=>{e.participants.set(t,{...DS(t,e.selfMemberId),status:`unverified`,refusal:n})},AS=(e,t,n)=>({fingerprint:tf(t),handle:rf(e.h,t),name:e.h,displayName:e.n,avatar:e.i,signKey:e.k,dhKey:e.d,shortFingerprint:af(t)}),jS=e=>Y(e),MS=(e,t,n,r,i)=>{if(typeof n!=`object`||!n)return!1;let a=n;if(a.t!==`social.hello`)return!1;if(OS(e,t),typeof a.h!=`string`||!ef(a.h)||typeof a.n!=`string`||pu(a.n,{max:32,multiline:!1})!==null)return kS(e,t,`bad-name`),!0;if(typeof a.a!=`number`||Math.abs(a.a-r)>6e5)return kS(e,t,`stale`),!0;let o=TS(n,e.roomId,t);if(!o.ok)return kS(e,t,o.reason),!0;let s=n,c=AS(s,jS(s.k),jS(s.d));for(let[n,r]of e.keyByMember)if(n!==t&&r===s.k)return kS(e,n,`duplicate-key`),kS(e,t,`duplicate-key`),e.keyByMember.set(t,s.k),!0;e.keyByMember.set(t,s.k);let l=i.friendByFingerprint(c.fingerprint)===null?i.friendNamed(c.name)?`rekeyed`:`verified`:`friend`;return e.participants.set(t,{memberId:t,status:l,identity:c,refusal:null,self:t===e.selfMemberId}),!0},NS=/^[A-Za-z0-9_-]+$/,PS=43,FS=(e,t)=>`${e}/i#${t.key}.${t.nonce}.${t.roomId}`,IS=e=>{if(e[PS]!==`.`||e[87]!==`.`)return null;let t=e.slice(0,PS),n=e.slice(44,87),r=e.slice(88);return r.length===0||!NS.test(t)||!NS.test(n)?null:{roomId:r,key:t,nonce:n}},LS=9e5,RS=1e4,zS={t:`social.whois`,v:1},BS=e=>({state:e,listeners:new Set}),VS=(e,t)=>{e.state=t;for(let n of e.listeners)n(t)},HS=e=>t=>(e.listeners.add(t),()=>{e.listeners.delete(t)}),US=()=>J(crypto.getRandomValues(new Uint8Array(16))),WS=e=>{try{let t=JSON.parse(e);return typeof t==`object`&&t?t:null}catch{return null}},GS=(e,t)=>JSON.stringify(CS({roomId:e.id,memberId:e.self.id,at:Date.now(),signKey:t.keys.signKey,dhKey:t.keys.dhKey,name:t.name,displayName:``,avatarUrl:``},t.keys.signSeed)),KS=(e,t,n,r,i,a,o)=>{let s=ES(t.id,t.self.id);MS(s,r,i,a,{friendByFingerprint:()=>null,friendNamed:()=>!1});let c=s.participants.get(r)?.identity;if(!c)return null;let l={memberId:r,fingerprint:c.fingerprint,name:c.name,displayName:c.displayName,signKey:Y(c.signKey),dhKey:Y(c.dhKey),confirmed:null,friend:n(c.fingerprint)};return Ub(e.rooms,l.name,l.signKey).then(e=>o({...l,confirmed:e})),l},qS=async(e,t,n)=>{if(e.writerId===null)return{ok:!1,reason:`no-writer`};let r;try{r=await e.rooms.create({members:2})}catch{return{ok:!1,reason:`unavailable`}}let i=crypto.getRandomValues(new Uint8Array(32)),a=r.invite.indexOf(`.`),o=FS(du,{key:r.invite.slice(0,a),nonce:J(i),roomId:r.invite.slice(a+1)}),s=Date.now()+LS,c=BS({kind:`waiting`}),l=new Map,u=null,d=null,f=!1,p=()=>{},m=()=>`peer`in c.state?c.state.peer:null,h=()=>c.state.kind===`friends`,g=async e=>{h()||VS(c,e),!f&&(f=!0,clearTimeout(x),p(),await r.leave().catch(()=>{}))},_=async()=>{let t=m();if(d===null||t===null)return;let n=await ip(e,d,Date.now());n.ok?await g({kind:`friends`,peer:t}):VS(c,{kind:`unsaved`,peer:t,reason:n.reason})},v=(t,i,a)=>{let o=m();if(o!==null&&o.memberId===t)return;let s=KS(e,r,n,t,i,a,e=>{m()?.memberId===e.memberId&&c.state.kind===`joined`&&VS(c,{kind:`joined`,peer:e})});s!==null&&(c.state.kind===`waiting`||c.state.kind===`left`)&&VS(c,{kind:`joined`,peer:s})},y=async(e,n)=>{let a=m();if(c.state.kind!==`offered`||a===null||a.memberId!==e)return;let o=ny(n,{roomId:r.id,fromMemberId:e,selfMemberId:r.self.id},{dhSeed:t.keys.dhSeed,theirSignKey:a.signKey,theirDhKey:a.dhKey});o.ok&&l.get(o.body.offerId)===e&&(d={signKey:a.signKey,dhKey:a.dhKey,name:a.name,profile:o.body.profile,pairNonce:i,linkedVia:`invite`,inbox:o.body.inbox},await _())},b=e=>{if(e.type===`left`&&d===null&&e.id===m()?.memberId&&(c.state.kind===`joined`||c.state.kind===`offered`)){VS(c,{kind:`left`});return}if(e.type!==`message`||e.message.from===r.self.id)return;let{from:n,text:i,at:a}=e.message,o=WS(i);o?.t===`social.whois`?(r.send(GS(r,t)).catch(()=>{}),c.state.kind===`offered`&&m()?.memberId===n&&u!==null&&r.send(u).catch(()=>{})):o?.t===`social.hello`?v(n,o,a):o?.t===`social.accept`&&y(n,o)},x=setTimeout(()=>void g({kind:`closed`}),LS);return p=await r.on(b),r.closed.then(()=>void g({kind:`closed`})),{ok:!0,invite:{link:o,expiresAt:s,state:()=>c.state,on:HS(c),add:async()=>{let e=m();if(c.state.kind!==`joined`||e===null)return!1;let n=US(),a=JSON.stringify(Xv({nonce:i,profile:t.profile,inbox:t.inbox},{roomId:r.id,fromMemberId:r.self.id,toMemberId:e.memberId,id:n},{signSeed:t.keys.signSeed,dhSeed:t.keys.dhSeed,theirDhKey:e.dhKey}));try{await r.send(a)}catch{return!1}return l.set(n,e.memberId),u=a,VS(c,{kind:`offered`,peer:e}),!0},saveAgain:_,close:()=>g({kind:`closed`})}}},JS=new Set([`bad-key`,`invalid`,`not-found`,`denied`,`blocked`,`closed`]),YS=(e,t,n,r)=>{let i=BS({kind:`joining`}),a=Y(n.nonce),o=null,s=()=>{},c,l=null,u=null,d=!1,f=()=>`host`in i.state?i.state.host:null,p=()=>[`friends`,`closed`,`in-use`,`unavailable`].includes(i.state.kind),m=async e=>{p()||VS(i,e),!d&&(d=!0,clearTimeout(c),s(),await o?.leave().catch(()=>{}))},h=(n,o,s,u)=>{if(o!==n.owner)return;let d=WS(s);if(d?.t===`social.hello`&&f()===null){let a=KS(e,n,r,o,d,u,e=>{let t=i.state;`host`in t&&t.host?.memberId===e.memberId&&VS(i,{...t,host:e})});if(a===null)return;clearTimeout(c),VS(i,{kind:`waiting`,host:a}),n.send(GS(n,t)).catch(()=>{})}else if(d?.t===`social.offer`){let e=f();if(e===null||i.state.kind!==`waiting`&&i.state.kind!==`offered`)return;let r=ty(d,{roomId:n.id,fromMemberId:o,selfMemberId:n.self.id},{dhSeed:t.keys.dhSeed,theirSignKey:e.signKey,theirDhKey:e.dhKey});if(!r.ok||a===null||!XS(r.body.nonce,a))return;l={id:r.id,nonce:r.body.nonce,profile:r.body.profile,inbox:r.body.inbox},VS(i,{kind:`offered`,host:e,profile:r.body.profile})}},g=async e=>{if(o!==null&&u!==null){try{await o.send(u)}catch{VS(i,{kind:`unsent`,host:e});return}await m({kind:`friends`,host:e})}};return(async()=>{let t;try{t=await e.rooms.join(`${n.key}.${n.roomId}`)}catch(e){let t=e?.code;VS(i,t===`full`?{kind:`in-use`}:JS.has(String(t))?{kind:`closed`}:{kind:`unavailable`});return}if(o=t,t.owner===t.self.id)return void m({kind:`closed`});if(d)return void t.leave().catch(()=>{});s=await t.on(e=>{e.type===`left`&&e.id===t.owner&&m({kind:`closed`}),e.type===`message`&&h(t,e.message.from,e.message.text,e.message.at)}),t.closed.then(()=>void m({kind:`closed`})),VS(i,{kind:`waiting`,host:null}),c=setTimeout(()=>{f()===null&&m({kind:`closed`})},RS),await t.send(JSON.stringify(zS)).catch(()=>{})})(),{state:()=>i.state,on:HS(i),accept:async()=>{let n=i.state;if(n.kind!==`offered`&&n.kind!==`failed`||l===null||o===null)return;let r=n.host;VS(i,{kind:`accepting`,host:r,profile:l.profile});let a=await ip(e,{signKey:r.signKey,dhKey:r.dhKey,name:r.name,profile:l.profile,pairNonce:l.nonce,linkedVia:`invite`,inbox:l.inbox},Date.now());if(!a.ok){VS(i,{kind:`failed`,host:r,profile:l.profile,reason:a.reason});return}u=JSON.stringify(Zv({offerId:l.id,profile:t.profile,inbox:t.inbox},{roomId:o.id,fromMemberId:o.self.id,toMemberId:r.memberId,id:US()},{signSeed:t.keys.signSeed,dhSeed:t.keys.dhSeed,theirDhKey:r.dhKey})),await g(r)},sendAgain:async()=>{let e=f();i.state.kind===`unsent`&&e!==null&&await g(e)},decline:()=>m({kind:`closed`})}},XS=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),ZS=e=>{let t=Ud(e),n=(t[0]*256+t[1])%360,r=[];for(let e=0;e<5;e++)for(let n=0;n<5;n++){let i=n<3?n:4-n,a=e*3+i;r.push((t[2+(a>>3)]>>(a&7)&1)==1)}return{hue:n,cells:r}},QS=Symbol.for(`pv`),$S=0;Array.isArray;function $(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:QS,__v:--$S,__i:-1,__u:0};return(i||a)&&(l.__source=i,l.__self=a),W.vnode&&W.vnode(l),l}var eC=({size:e=18})=>$(`svg`,{width:e,height:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`2.25`,y:`2.25`,width:`15.5`,height:`15.5`}),$(`path`,{d:`M2.25 10h8.5V2.25`}),$(`rect`,{x:`11.5`,y:`11.5`,width:`3.75`,height:`3.75`,fill:`currentColor`,stroke:`none`})]}),tC=({id:e})=>{switch(e){case`overview`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`2`,y:`2`,width:`5`,height:`5`}),$(`rect`,{x:`9`,y:`2`,width:`5`,height:`5`}),$(`rect`,{x:`2`,y:`9`,width:`5`,height:`5`}),$(`rect`,{x:`9`,y:`9`,width:`5`,height:`5`})]});case`customize`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`path`,{d:`M2 4h12M2 8h12M2 12h12`}),$(`rect`,{x:`4`,y:`2.5`,width:`2.5`,height:`3`,fill:`currentColor`}),$(`rect`,{x:`9.5`,y:`6.5`,width:`2.5`,height:`3`,fill:`currentColor`}),$(`rect`,{x:`5`,y:`10.5`,width:`2.5`,height:`3`,fill:`currentColor`})]});case`friends`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`2.5`,y:`3`,width:`4.5`,height:`4.5`}),$(`path`,{d:`M1.5 13.5V10h6.5v3.5`}),$(`rect`,{x:`9.5`,y:`4`,width:`4`,height:`4`}),$(`path`,{d:`M9.5 10h4.5v3.5`})]});case`inbox`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`}),$(`path`,{d:`M2 8.5h3.5l1.5 2h2l1.5-2H14`})]});case`apps`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`11`}),$(`path`,{d:`M2 6h12M6 6v7.5`})]});case`account`:return $(`svg`,{className:`social-ico`,width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:[$(`rect`,{x:`3`,y:`2.5`,width:`5.5`,height:`5.5`}),$(`path`,{d:`M8.5 5.25H14V8M11.75 5.25V7.5`}),$(`path`,{d:`M2.5 13.5h11`})]})}},nC=()=>$(`svg`,{className:`social-ico`,width:13,height:13,viewBox:`0 0 14 14`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:$(`path`,{d:`M7 11.5V3M3.5 6.5 7 3l3.5 3.5`})}),rC=()=>$(`svg`,{className:`social-ico`,width:13,height:13,viewBox:`0 0 14 14`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`square`,strokeLinejoin:`miter`,"aria-hidden":`true`,children:$(`path`,{d:`M7 2.5V11M3.5 7.5 7 11l3.5-3.5`})});new URL(du).host;var iC=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),aC=({children:e})=>$(`main`,{className:`social-shell`,children:$(`section`,{className:`social-panel`,children:[$(`div`,{className:`social-panel-mark`,"aria-hidden":`true`,children:$(eC,{size:18})}),e]})}),oC=({label:e,state:t,error:n})=>$(`main`,{className:`social-loader-stage`,"data-social-state":t,children:$(`div`,{className:`social-loader-box`,children:[n,$(`div`,{className:`social-loader-mark`,"aria-hidden":`true`,children:$(eC,{size:24})}),$(`div`,{className:`social-loader-brand`,children:`FKN Social`}),$(`div`,{className:`social-loader-track`,"aria-hidden":`true`,children:$(`div`,{className:`social-loader-bar`})}),$(`p`,{className:`social-loader-status`,role:`status`,children:e})]})}),sC=`Your FKN storage is locked on this device, so nothing changed. Unlock it under Security in your FKN settings, then try again.`,cC=`Your saved friend list will not open, so nothing changed. If you downloaded your FKN data before, bring it back under Security in your FKN settings.`,lC={empty:`Pick a name.`,"too-short":`A name has at least 3 characters.`,"too-long":`A name has at most 20 characters.`,characters:`Use lowercase letters and digits, with single underscores between them.`,reserved:`That name is reserved. Try another.`,taken:`That name is taken. Try another.`,"out-of-claims":`No claimed rooms left. Unclaim one under Rooms in your FKN settings, then try again.`,busy:`That name has too many connections right now. Close other FKN Social tabs, or try again in a moment.`,unrecorded:`The name's record could not be written. Check that Messages kept is on for it under Rooms in your FKN settings, then try again.`,unavailable:`FKN rooms did not answer. Try again in a moment.`,unreachable:`FKN could not be reached. Check your connection, then try again.`,locked:sC,reset:`Your saved identity will not open, so nothing changed. Reload the page, then enter your recovery key.`,"list-reset":cC,newer:`This needs a newer FKN Social. Reload the page to update.`,"no-writer":`This browser keeps no site data for FKN Social. Allow site data, then reload.`,"bad-recovery-key":`That is not a recovery key. A recovery key starts with FKNS, followed by 52 letters and digits.`},uC=({reason:e})=>e===null?null:$(`p`,{className:`social-error`,role:`alert`,children:lC[e]}),dC=e=>lC[e],fC={reset:cC,locked:sC,unreachable:`FKN could not be reached, so nothing changed. Check your connection, then try again.`,"no-writer":`This browser keeps no site data for FKN Social. Allow site data, then reload.`,newer:`Your friend list was saved by a newer FKN Social. Reload the page to update.`},pC={"display-name":`A display name has at most 32 characters, and no control or text direction characters.`,bio:`A bio has at most ${of.toLocaleString(`en`)} characters, and no control or text direction characters.`,links:`You can list at most 5 links.`,link:`Each link starts with https:// and has at most 200 characters.`},mC={title:`Give the panel a title of at most 80 characters, with no control or text direction characters.`,body:`Write panel text of at most ${Jg.toLocaleString(`en`)} characters, with no control or text direction characters.`,caption:`A caption has at most 120 characters, with no control or text direction characters.`,full:`You can have up to 6 panels. Delete one to add another.`,"items-full":`Each artwork panel holds up to 4 pictures. Remove one to add another.`,"not-found":`That panel is no longer on your page. Reload to see the latest list.`,off:`Set this panel to Friends or Public before uploading artwork.`,"sync-failed":`Your panel changed, but FKN rooms did not update yet. Reload in a moment to sync your page.`},hC=`FKN rooms did not answer, so nothing changed. Try again in a moment.`,gC={...fC,unavailable:hC,"out-of-claims":lC[`out-of-claims`],"not-public":`Your profile is set to Only me, so the picture was not saved. Reload the page.`,"too-large":`That picture is too large or could not be made small enough. Pick another.`,kind:`Pick a PNG, JPEG, GIF or WebP picture.`,quota:`Your FKN storage is full, so the picture was not published. Free some space, then try again.`,"too-many":`FKN is not accepting new files from your account right now, so the picture was not published. Try again later.`,"storage-unavailable":`FKN storage did not answer, so the picture was not published. Try again in a moment.`},_C=e=>{let t=e.replace(/[a-ln-vx-z0-9_]/g,``).length;return t*1.05+(e.length-t)*.72},vC=e=>({fontSize:`clamp(0.875rem, ${100/Math.max(1,...e.split(/\s+/).map(_C))}cqi, 1.75rem)`}),yC=e=>{e?.focus()},bC=({children:e})=>e===null?null:$(`p`,{className:`social-error`,role:`alert`,children:e}),xC=({signKey:e,label:t=`Your identicon`,small:n=!1})=>{let{hue:r,cells:i}=ZS(e);return $(`svg`,{className:n?`social-identicon social-identicon-small`:`social-identicon`,viewBox:`0 0 6 6`,role:`img`,"aria-label":t,children:[$(`rect`,{width:6,height:6,fill:`hsl(${r} 45% 92%)`}),i.map((e,t)=>e&&$(`rect`,{x:.5+t%5,y:.5+Math.floor(t/5),width:1,height:1,fill:`hsl(${r} 55% 42%)`},t))]})},SC=(e,t,n)=>{let r=t?.url??null,i=t?.key??null,[a,o]=K({storage:null,url:null,key:null,max:0,objectUrl:null});return zl(()=>{if(r===null||i===null){o(e=>e.objectUrl===null&&e.url===null?e:{storage:null,url:null,key:null,max:0,objectUrl:null});return}let t=!0,a=null;return Bg(e,{url:r,key:i},n).then(s=>{if(!t){s!==null&&URL.revokeObjectURL(s);return}a=s,o({storage:e,url:r,key:i,max:n,objectUrl:s})}),()=>{t=!1,a!==null&&URL.revokeObjectURL(a)}},[e,r,i,n]),r===null||i===null?null:a.storage===e&&a.url===r&&a.key===i&&a.max===n?a.objectUrl:void 0},CC=({signKey:e,src:t,url:n,label:r=`Your identicon`,avatarAlt:i=`Your avatar`,small:a=!1})=>{let o=a?`social-identicon social-identicon-small`:`social-identicon`;return t===void 0?$(`span`,{className:o,"data-social-avatar-reading":!0,"aria-hidden":`true`}):t===null?$(xC,{signKey:e,label:r,small:a}):$(`img`,{className:`${o} social-avatar-img`,src:t,alt:i,"data-social-avatar":n})},wC=async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}},TC=({text:e,label:t=`Copy`})=>{let[n,r]=K(null);return $(G,{children:[$(`button`,{type:`button`,onClick:()=>void wC(e).then(e=>r(e?`Copied`:`Copy did not work. Select the text and copy it.`)),children:t}),n!==null&&$(`span`,{className:`social-muted`,role:`status`,"data-social-copied":n===`Copied`,children:n})]})},EC=({url:e,site:t})=>{let[n,r]=K(!1),i=t();return $(`div`,{className:`social-link`,"data-social-link":e,children:[$(`div`,{className:`social-link-bar`,children:[$(`span`,{className:`social-link-text`,children:e}),$(`div`,{className:`social-link-actions`,children:[i!==null&&$(`button`,{type:`button`,"data-open-link":!0,onClick:()=>void i.open(e).catch(()=>r(!0)),children:`Open`}),$(TC,{text:e})]})]}),n&&$(`p`,{className:`social-muted`,children:`It did not open. Copy it instead.`})]})},DC={started:`start`,watched:`watch`,completed:`finish`,rated:`rate`},OC=e=>gu.filter(t=>e.includes(t)),kC=(e,t)=>{let n=OC(t).map(e=>DC[e]);if(n.length===0)return`${Tu(e)} asks to post to your page.`;let r=n.length===1?n[0]:`${n.slice(0,-1).join(`, `)} or ${n.at(-1)}`;return`${Tu(e)} asks to post when you ${r} something.`},AC=()=>{let[e,t]=K(!1),[n,r]=K(null);return{busy:e,problem:n,run:async n=>{if(e)return!1;t(!0),r(null);let i=await n();return t(!1),r(i),i===null}}},jC=({asks:e,actions:t,onAnswered:n})=>{let{busy:r,problem:i,run:a}=AC(),o=async(e,r)=>{await a(()=>t.change(e,r))&&n?.()};return e.length===0?null:$(`div`,{className:`social-stack`,"data-social-asks":!0,children:[e.map(({app:e,grant:t})=>$(`div`,{className:`social-invite`,"data-social-ask":e,children:[$(`p`,{children:kC(e,t.kinds)}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-social-allow":!0,"aria-disabled":r,onClick:()=>void o(e,{state:`allowed`,kinds:OC(t.kinds)}),children:`Allow`}),$(`button`,{type:`button`,"data-social-not-now":!0,"aria-disabled":r,onClick:()=>void o(e,{state:`stopped`}),children:`Not now`})]})]},e)),$(bC,{children:i})]})},MC=[{level:`public`,label:`Public`},{level:`friends`,label:`Friends`}],NC=({app:e,grant:t,actions:n})=>{let{busy:r,problem:i,run:a}=AC(),[o,s]=K(!1),c=q(null),l=Tu(e),u=t=>void a(()=>n.change(e,t)),d=e=>gu.filter(n=>n===e?!t.kinds.includes(n):t.kinds.includes(n)),f=()=>{s(!1),c.current?.focus()},p=async()=>{await a(()=>n.remove(e))&&f()};return $(`li`,{className:`social-section`,"data-social-app":e,"data-social-app-state":t.state,children:[$(`span`,{className:`social-choice-label`,children:l}),$(`div`,{className:`social-stack`,children:[$(`span`,{className:`social-label`,children:`What it posts`}),$(`div`,{className:`social-checks`,role:`group`,"aria-label":`What it posts`,children:gu.map(e=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`checkbox`,value:e,checked:t.kinds.includes(e),"aria-disabled":r,onChange:()=>u({kinds:d(e)})}),$(`span`,{className:`social-choice-label`,children:hu[e]})]},e))})]}),$(`div`,{className:`social-stack`,children:[$(`span`,{className:`social-label`,children:`Who sees its posts`}),$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`Who sees its posts`,children:MC.map(({level:n,label:i})=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`app-level-${e}`,value:n,checked:t.level===n,"aria-disabled":r,onChange:()=>u({level:n})}),$(`span`,{className:`social-choice-label`,children:i})]},n))})]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,"data-social-app-switch":!0,"aria-disabled":r,onClick:()=>u(t.state===`allowed`?{state:`stopped`}:{state:`allowed`,kinds:OC(t.kinds)}),children:t.state===`allowed`?`Stop`:`Allow`}),$(`button`,{type:`button`,"data-social-app-delete":!0,ref:c,"aria-disabled":r,onClick:()=>{r||s(!0)},children:`Delete everything it posted`})]}),o&&$(`div`,{className:`social-warn`,"data-social-delete-app":!0,children:[$(`p`,{children:[`Delete everything `,l,` posted?`]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,"data-social-delete-confirm":!0,ref:yC,"aria-disabled":r,onClick:()=>void p(),children:`Delete`}),$(`button`,{type:`button`,"aria-disabled":r,onClick:()=>{r||f()},children:`Cancel`})]})]}),$(bC,{children:i})]})},PC=({apps:e,actions:t})=>$(`ul`,{className:`social-list`,"data-social-apps":!0,children:e.map(({app:e,grant:n})=>$(NC,{app:e,grant:n,actions:t},e))}),FC=e=>t=>{t.key===`Enter`&&e()},IC=({name:e,label:t,placeholder:n,value:r,onChange:i,onSubmit:a})=>{let o=$d(r);return $(G,{children:[$(`input`,{name:e,"aria-label":t,autoComplete:`off`,autoCapitalize:`none`,spellcheck:!1,maxLength:40,placeholder:n,value:r,onChange:e=>i(e.currentTarget.value),onKeyDown:FC(a)}),!o.ok&&o.reason!==`empty`&&$(`p`,{className:`social-muted`,children:dC(o.reason)})]})},LC=({label:e,onPick:t})=>{let[n,r]=K(``),[i,a]=K(!1),[o,s]=K(null),c=$d(n),l=async()=>{if(!c.ok||i)return;a(!0),s(null);let e=await t(c.name);a(!1),e.ok||s(e.reason)};return $(`div`,{children:[$(IC,{name:`name`,label:`Name`,placeholder:`your name`,value:n,onChange:e=>{r(e),s(null)},onSubmit:()=>void l()}),c.ok&&c.name!==n&&$(`p`,{className:`social-muted`,children:[`Saved as `,c.name]}),$(uC,{reason:o}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-submit":!0,className:`social-primary`,"aria-disabled":!c.ok||i,onClick:()=>void l(),children:i?`Claiming...`:e})})]})},RC=({onRestore:e})=>{let[t,n]=K(``),[r,i]=K(!1),[a,o]=K(null),s=async()=>{if(r||t.trim()===``)return;i(!0),o(null);let n=await e(t);i(!1),n.ok||o(n.reason)};return $(`div`,{children:[$(`input`,{name:`recovery-key`,"aria-label":`Recovery key`,autoComplete:`off`,spellcheck:!1,placeholder:`FKNS-...`,value:t,onChange:e=>{n(e.currentTarget.value),o(null)},onKeyDown:FC(()=>void s())}),$(uC,{reason:a}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-submit":!0,"aria-disabled":t.trim()===``||r,onClick:()=>void s(),children:r?`Restoring...`:`Restore`})})]})},zC=({identity:e,fresh:t})=>{let[n,r]=K(t),i=Kx(e.seed);return $(G,{children:[$(`h2`,{children:t?`Save your recovery key`:`Recovery key`}),$(`p`,{className:`social-muted`,children:`Keep it somewhere private: anyone holding it can act as you.`}),n&&$(`code`,{className:`social-key`,"data-recovery-key":!0,children:i}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,onClick:()=>r(!n),children:n?`Hide`:`Show recovery key`}),n&&$(TC,{text:i})]})]})},BC={lost:`Your account no longer holds this name.`,unrecorded:`Your name's record is missing. Check that Messages kept is on for it under Rooms in your FKN settings, then write it again.`,taken:`Someone else holds this name now.`,retired:`Names like this one are no longer given out.`},VC={lost:`Claim it again`,unrecorded:`Write it again`},HC=({status:e,onClaimAgain:t,onRename:n})=>{let[r,i]=K(!1),[a,o]=K(null),s=BC[e];if(s===void 0)return null;let c=async()=>{if(r)return;i(!0);let e=await t();i(!1),o(e.ok?null:e.reason)},l=VC[e];return $(`div`,{className:`social-warn`,role:`status`,children:[$(`p`,{children:s}),$(uC,{reason:a}),$(`div`,{className:`social-row`,children:[l!==void 0&&$(`button`,{type:`button`,className:`social-primary`,"aria-disabled":r,onClick:()=>void c(),children:r?`Claiming...`:l}),$(`button`,{type:`button`,onClick:n,children:`Pick another name`})]})]})},UC=({name:e,onGiveBack:t})=>{let[n,r]=K(!1),[i,a]=K(null),o=async()=>{if(n)return;r(!0);let e=await t();r(!1),a(e.ok?null:e.reason)};return $(`div`,{className:`social-warn`,role:`status`,"data-social-kept":e,children:[$(`p`,{children:[`Your FKN account still holds `,e,`.`]}),$(uC,{reason:i}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"aria-disabled":n,onClick:()=>void o(),children:n?`Giving back...`:`Give it back`})})]})},WC=({identity:e,fresh:t,status:n,actions:r,avatar:i=null,avatarUrl:a,openRename:o=!1,onRenameOpened:s})=>{let[c,l]=K(!1),[u,d]=K(null),f=zh(e.seed);zl(()=>{o&&(l(!0),s?.())},[o,s]);let p=async e=>{let t=await r.rename(e);return t.ok&&l(!1),(t.ok||t.kept!==void 0)&&d(t.kept??null),t},m=async e=>{let t=await r.giveBack(e);return t.ok&&d(null),t};return $(G,{children:[$(`div`,{className:`social-card`,"data-social-claim":n,children:[$(CC,{signKey:f.signKey,src:i,url:a,avatarAlt:`${e.name}'s avatar`}),$(`div`,{children:[$(`div`,{className:`social-name`,"data-social-name":!0,style:vC(e.name),children:e.name}),$(`div`,{className:`social-muted`,children:`Your name on FKN Social`})]})]}),$(HC,{status:n,onClaimAgain:r.claimAgain,onRename:()=>l(!0)}),u!==null&&$(UC,{name:u,onGiveBack:()=>m(u)}),c?$(G,{children:[$(`h2`,{children:`Change your name`}),$(`p`,{className:`social-muted`,children:[e.name,` is given back.`]}),$(LC,{label:`Change name`,onPick:p}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:()=>l(!1),children:`Cancel`})})]}):$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:()=>l(!0),children:`Change name`})}),$(zC,{identity:e,fresh:t})]})},GC=`FKN rooms did not answer. Try again in a moment.`,KC=(e,t)=>({closed:`${t} is not taking friend requests.`,full:`${t}'s inbox is full. Try again later.`,busy:GC,unavailable:GC})[e],qC=(e,t)=>({...fC,self:`This is you.`,"no-inbox":`You need an inbox to send friend requests.`,closed:KC(`closed`,t),full:KC(`full`,t),busy:GC,unavailable:GC})[e],JC={none:`You have no inbox.`,"out-of-claims":`No inbox: your FKN account holds as many claimed rooms as it can. Unclaim one under Rooms in your FKN settings.`,taken:`Someone else holds your inbox now.`,"not-kept":`Your inbox keeps no messages. Turn on Messages kept for it under Rooms in your FKN settings.`,unavailable:GC},YC={...fC,"out-of-claims":JC[`out-of-claims`],busy:GC,unavailable:GC},XC=[`none`,`out-of-claims`,`taken`],ZC=({onMake:e})=>{let[t,n]=K(!1),[r,i]=K(null),a=async()=>{if(t)return;n(!0);let r=await e();n(!1),i(r.ok?null:YC[r.reason])};return $(G,{children:[$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-make-inbox":!0,"aria-disabled":t,onClick:()=>void a(),children:t?`Making an inbox...`:`Make an inbox`})}),r!==null&&$(`p`,{className:`social-error`,role:`alert`,children:r})]})},QC=({status:e,onMake:t})=>e===`ready`?null:$(`div`,{className:`social-stack`,"data-social-inbox-line":e,children:[$(`p`,{className:`social-warn-text`,children:JC[e]}),XC.includes(e)&&$(ZC,{onMake:t})]}),$C=e=>{try{return new URL(e).host}catch{return e}},ew=({signKey:e,name:t,displayName:n=``})=>$(`div`,{className:`social-card`,children:[$(xC,{signKey:e,label:`${t}'s identicon`,small:!0}),$(`div`,{children:[$(`div`,{className:`social-person-name`,children:n||t}),n!==``&&n!==t&&$(`div`,{className:`social-muted`,children:t})]})]}),tw=({waiting:e,actions:t})=>{let[n,r]=K(!1),[i,a]=K(null),[o,s]=K(!1),{sender:c,request:l}=e,u=async i=>{if(n)return;r(!0);let o=await t.answer(e,i);r(!1),s(!o.ok&&o.reason===`unsent`),a(o.ok||o.reason===`unsent`?null:fC[o.reason])};return $(`div`,{className:`social-invite`,"data-social-request":c.name,"data-social-confirmed":String(c.confirmed),children:[$(`p`,{children:[c.name,` sent you a friend request.`]}),$(ew,{signKey:c.signKey,name:c.name,displayName:l.p.displayName}),c.confirmed===!1&&$(`p`,{className:`social-warn-text`,children:`Their name room does not confirm this name.`}),e.friend&&$(`p`,{className:`social-muted`,children:`Already in your list.`}),o&&$(`p`,{className:`social-error`,role:`alert`,children:[`Your answer did not reach `,c.name,`.`]}),i!==null&&$(`p`,{className:`social-error`,role:`alert`,children:i}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-accept-request":!0,"aria-disabled":n,onClick:()=>void u(!0),children:o?`Send again`:`Accept`}),!o&&$(`button`,{type:`button`,"data-decline-request":!0,"aria-disabled":n,onClick:()=>void u(!1),children:`Decline`})]})]})},nw=({waiting:e,site:t,actions:n})=>{let[r,i]=K(!1),a=t(),o=async()=>{a!==null&&await a.open(e.url).catch(()=>i(!0))};return $(`div`,{className:`social-invite`,"data-social-party":e.sender.name,children:[$(`p`,{children:[e.sender.name,` invited you to a party at `,$C(e.url),`.`]}),$(ew,{signKey:e.sender.signKey,name:e.sender.name}),$(`div`,{className:`social-row`,children:[a!==null&&$(`button`,{type:`button`,className:`social-primary`,"data-open-party":!0,onClick:()=>void o(),children:`Open`}),$(TC,{text:e.url}),$(`button`,{type:`button`,"data-dismiss-party":!0,onClick:()=>void n.dismiss(e),children:`Dismiss`})]}),r&&$(`p`,{className:`social-muted`,children:`It did not open. Copy it instead.`})]})},rw=({waiting:e,actions:t})=>{let[n,r]=K(!1),[i,a]=K(!1),o=async()=>{if(n)return;r(!0);let i=await t.approve(e);r(!1),a(!i)};return $(`div`,{className:`social-invite`,"data-social-comment":e.sender.name,children:[$(`p`,{children:[e.sender.name,` commented on your page.`]}),$(ew,{signKey:e.sender.signKey,name:e.sender.name}),$(`p`,{className:`social-bio`,"data-social-comment-text":!0,children:e.text}),i&&$(`p`,{className:`social-error`,role:`alert`,children:`FKN rooms did not answer, so nothing changed. Try again in a moment.`}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-approve-comment":!0,"aria-disabled":n,onClick:()=>void o(),children:`Approve`}),$(`button`,{type:`button`,"data-delete-comment":!0,"aria-disabled":n,onClick:()=>{n||t.dismiss(e)},children:`Delete`})]})]})},iw=({status:e,waiting:t,accepted:n,site:r,actions:i,onMake:a})=>$(`div`,{className:`social-stack`,"data-social-inbox-status":e??`loading`,children:[n.map(e=>$(`p`,{"data-social-accepted":e,children:[e,` accepted your friend request.`]},e)),t.map(e=>e.kind===`friend`?$(tw,{waiting:e,actions:i},e.seq):e.kind===`comment`?$(rw,{waiting:e,actions:i},e.seq):$(nw,{waiting:e,site:r,actions:i},e.seq)),e!==null&&$(QC,{status:e,onMake:a})]}),aw=(e,t)=>({unheld:`Nobody holds the name ${t} on FKN Social right now.`,none:`${t}'s page shows nothing right now. Try again in a moment.`,busy:GC,unavailable:GC,malformed:`This link is incomplete. Ask for the link again.`})[e.kind],ow=({onAdd:e})=>{let[t,n]=K(``),r=$d(t),i=()=>{r.ok&&(e(r.name),n(``))};return $(`div`,{"data-social-add-by-name":!0,children:[$(IC,{name:`friend-name`,label:`Friend's name`,placeholder:`their name`,value:t,onChange:n,onSubmit:i}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-add-by-name":!0,"aria-disabled":!r.ok,onClick:i,children:`Request friend`})})]})},sw=({name:e,own:t,isFriend:n,read:r,send:i,onMake:a,onClose:o})=>{let[s,c]=K(e===null?{kind:`malformed`}:null),[l,u]=K(!1),[d,f]=K(null),p=q(null);zl(()=>{let e=document.activeElement;return p.current?.focus(),()=>{e instanceof HTMLElement&&e!==document.body&&e.isConnected&&(document.activeElement===document.body||p.current?.contains(document.activeElement))&&e.focus()}},[]),zl(()=>{if(e===null)return;let t=!0;return r(e).then(e=>{t&&c(e)}),()=>{t=!1}},[e,r]);let m=e??``,h=s?.kind===`shown`&&e!==null?{name:e,signKey:s.signKey,inbox:s.inbox}:null,g=h===null?null:iC(h.signKey,t)?{ok:!1,reason:`self`}:h.inbox===null?{ok:!1,reason:`closed`}:null,_=d??g,v=g===null?h:null,y=_===null?s===null?`loading`:s.kind===`shown`?`ready`:s.kind:_.ok?`sent`:_.reason,b=async()=>{v===null||l||(u(!0),f(await i(v)),u(!1))};return $(`div`,{ref:p,tabIndex:-1,className:`social-invite`,"data-social-send-request":y,children:[$(`h2`,{children:e===null?`Add a friend`:`Add ${m} as a friend`}),s===null&&$(`div`,{className:`social-inline-loader`,children:[$(`span`,{className:`social-loader-track social-loader-track-sm`,"aria-hidden":`true`,children:$(`span`,{className:`social-loader-bar`})}),$(`span`,{className:`social-muted`,children:`Loading...`})]}),s!==null&&s.kind!==`shown`&&$(`p`,{children:aw(s,m)}),s?.kind===`shown`&&$(ew,{signKey:s.signKey,name:m,displayName:s.profile?.displayName??s.displayName}),v!==null&&n(v.signKey)&&$(`p`,{className:`social-muted`,children:`Already in your list.`}),_?.ok===!0&&$(`p`,{role:`status`,children:`Sent.`}),_?.ok===!1&&$(`p`,{className:`social-error`,role:`alert`,children:qC(_.reason,m)}),_?.ok===!1&&_.reason===`no-inbox`&&$(ZC,{onMake:async()=>{let e=await a();return e.ok&&f(null),e}}),$(`div`,{className:`social-row`,children:[v!==null&&_?.ok!==!0&&$(`button`,{type:`button`,className:`social-primary`,"data-send-request":!0,"aria-disabled":l,onClick:()=>void b(),children:l?`Sending...`:`Send friend request`}),$(`button`,{type:`button`,"data-close-request":!0,onClick:o,children:`Close`})]})]})},cw=e=>Y(e.signKey)??new Uint8Array(32),lw=e=>e.nickname??(e.profile.displayName||e.name),uw=({friends:e,onOpen:t,focusRef:n})=>e.length===0?$(`p`,{className:`social-muted`,"data-social-friends":`0`,children:`No friends yet.`}):$(`ul`,{className:`social-list`,"data-social-friends":e.length,children:e.map(e=>$(`li`,{children:$(`button`,{type:`button`,className:`social-person`,"data-social-friend":e.name,ref:n?.(e.fingerprint),onClick:()=>t(e.fingerprint),children:[$(xC,{signKey:cw(e),label:`${e.name}'s identicon`,small:!0}),$(`span`,{children:[$(`span`,{className:`social-person-name`,children:lw(e)}),lw(e)!==e.name&&$(`span`,{className:`social-muted`,children:[` `,e.name]})]})]})},e.fingerprint))}),dw={invite:`Met through an invite link.`,party:`Met in a party.`,request:`Met through a friend request.`},fw=(e,t)=>e.ok?`Sent.`:e.reason===`link`?`A party link starts with https:// and has at most ${ay.toLocaleString(`en`)} characters.`:e.reason===`no-inbox`?`${t} has no inbox.`:e.reason===`closed`?`${t} cannot take party invites right now.`:KC(e.reason,t),pw=({name:e,onInvite:t})=>{let[n,r]=K(``),[i,a]=K(!1),[o,s]=K(null),c=async()=>{if(i||n.trim()===``)return;a(!0);let e=await t(n);a(!1),s(e),e.ok&&r(``)};return $(`div`,{className:`social-stack`,"data-social-party-invite":!0,children:[$(`label`,{className:`social-label`,children:[`Party link`,$(`input`,{name:`party-link`,autoComplete:`off`,inputMode:`url`,value:n,onChange:e=>{r(e.currentTarget.value),s(null)},onKeyDown:e=>{e.key===`Enter`&&c()}})]}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-send-party":!0,"aria-disabled":i||n.trim()===``,onClick:()=>void c(),children:i?`Sending...`:`Send invite`})}),o!==null&&$(`p`,{className:o.ok?`social-muted`:`social-error`,role:o.ok?`status`:`alert`,children:fw(o,e)})]})},mw=({friend:e,site:t,onNickname:n,onRemove:r,onBack:i,onInvite:a})=>{let[o,s]=K(e.nickname??``),[c,l]=K(!1),[u,d]=K(!1),[f,p]=K(null),m=async e=>{if(u)return;d(!0);let t=await e();d(!1),p(t.ok?null:fC[t.reason])},h=o.trim(),g=h===(e.nickname??``);return $(`div`,{className:`social-stack`,"data-social-friend-view":e.name,children:[$(`div`,{className:`social-card`,children:[$(xC,{signKey:cw(e),label:`${e.name}'s identicon`}),$(`div`,{children:[$(`div`,{className:`social-name`,tabIndex:-1,ref:yC,style:vC(lw(e)),children:lw(e)}),lw(e)!==e.name&&$(`div`,{className:`social-muted`,children:e.name})]})]}),e.profile.displayName!==``&&e.nickname!==null&&$(`p`,{children:e.profile.displayName}),e.profile.bio!==``&&$(`p`,{className:`social-bio`,"data-social-bio":!0,children:e.profile.bio}),e.profile.links.map(e=>$(EC,{url:e,site:t},e)),$(`p`,{className:`social-muted`,children:[`Friends since `,new Date(e.linkedAt).toLocaleDateString(`en`,{year:`numeric`,month:`long`,day:`numeric`}),`.`,` `,dw[e.linkedVia]]}),a!==void 0&&K_(e.inbox)!==null&&$(G,{children:[$(`h2`,{children:`Invite to a party`}),$(pw,{name:e.name,onInvite:a})]}),$(`label`,{className:`social-label`,children:[`Nickname, only for you`,$(`input`,{name:`nickname`,autoComplete:`off`,maxLength:64,value:o,onChange:e=>s(e.currentTarget.value)})]}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"aria-disabled":u||g,onClick:()=>{g||m(()=>n(h===``?null:h))},children:`Save nickname`})}),$(bC,{children:f}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,onClick:i,children:`Back to friends`}),c?$(`button`,{type:`button`,className:`social-danger`,"aria-disabled":u,onClick:()=>void m(r),children:[`Remove `,e.name]}):$(`button`,{type:`button`,onClick:()=>l(!0),children:`Remove`})]})]})},hw=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(hw||{}),gw=[0,1],_w=[1,0],vw=[2,3],yw=[3,2],bw={L:gw,M:_w,Q:vw,H:yw},xw=/^\d*$/,Sw=/^[A-Z0-9 $%*+./:-]*$/,Cw=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,ww=1,Tw=40,Ew=3,Dw=3,Ow=40,kw=10,Aw=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],jw=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Mw=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<ww||e>Tw)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,hw.Timing),this.setFunctionModule(e,6,e%2==0,hw.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Pw(r,e));this.setFunctionModule(8,7,Pw(r,6)),this.setFunctionModule(8,8,Pw(r,7)),this.setFunctionModule(7,8,Pw(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Pw(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Pw(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Pw(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Pw(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,hw.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,hw.Alignment)}setFunctionModule(e,t,n,r=hw.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Yw(t,n))throw RangeError(`Invalid argument`);let r=jw[n[0]][t],i=Aw[n[0]][t],a=Math.floor(Jw(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=Xw(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=Zw(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(Jw(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Pw(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Ew:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Ow),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Ow}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Ew:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Ow),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Ow}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Dw)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*kw,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Nw(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Pw(e,t){return!!(e>>>t&1)}var Fw=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},Iw=[1,10,12,14],Lw=[2,9,11,13],Rw=[4,8,16,16];function zw(e,t){return e[Math.floor((t+7)/17)+1]}function Bw(e){let t=[];for(let n of e)Nw(n,8,t);return new Fw(Rw,e.length,t)}function Vw(e){if(!Ww(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Nw(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Fw(Iw,e.length,t)}function Hw(e){if(!Gw(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Cw.indexOf(e.charAt(n))*45;r+=Cw.indexOf(e.charAt(n+1)),Nw(r,11,t)}return n<e.length&&Nw(Cw.indexOf(e.charAt(n)),6,t),new Fw(Lw,e.length,t)}function Uw(e){return e===``?[]:Ww(e)?[Vw(e)]:Gw(e)?[Hw(e)]:[Bw(qw(e))]}function Ww(e){return xw.test(e)}function Gw(e){return Sw.test(e)}function Kw(e,t){let n=0;for(let r of e){let e=zw(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function qw(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function Jw(e){if(e<ww||e>Tw)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Yw(e,t){return Math.floor(Jw(e)/8)-Aw[t[0]][e]*jw[t[0]][e]}function Xw(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=Qw(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Qw(n,2)}return t}function Zw(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=Qw(t,e))}return n}function Qw(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function $w(e,t,n=1,r=40,i=-1,a=!0){if(!(ww<=n&&n<=r&&r<=Tw)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Yw(o,t)*8,i=Kw(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[_w,vw,yw])a&&s<=Yw(o,e)*8&&(t=e);let c=[];for(let t of e){Nw(t.mode[0],4,c),Nw(t.numChars,zw(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Yw(o,t)*8;Nw(0,Math.min(4,l-c.length),c),Nw(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Nw(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Mw(o,t,u,i)}function eT(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?Uw(e):Array.isArray(e)?[Bw(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=$w(c,bw[n],i,a,o,r),u=tT({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function tT(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=hw.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var nT=({text:e})=>{let{size:t,data:n}=eT(e,{ecc:`L`,border:2}),r=``;return n.forEach((e,t)=>e.forEach((e,n)=>{e&&(r+=`M${n} ${t}h1v1h-1z`)})),$(`svg`,{className:`social-qr`,viewBox:`0 0 ${t} ${t}`,role:`img`,"aria-label":`QR code of the invite link`,shapeRendering:`crispEdges`,children:[$(`rect`,{width:t,height:t,fill:`#fff`}),$(`path`,{d:r,fill:`#000`})]})},rT=(e,t)=>{let n=Math.max(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`},iT=()=>{let[e,t]=K(()=>Date.now());return zl(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e},aT=({peer:e})=>$(`div`,{className:`social-stack`,"data-social-peer":e.name,"data-social-confirmed":String(e.confirmed),children:[$(`div`,{className:`social-card`,children:[$(xC,{signKey:e.signKey,label:`${e.name}'s identicon`,small:!0}),$(`div`,{children:[$(`div`,{className:`social-person-name`,children:e.displayName||e.name}),$(`div`,{className:`social-muted`,children:e.name})]})]}),e.confirmed===!1&&$(`p`,{className:`social-warn-text`,children:`This name could not be confirmed.`}),e.friend&&$(`p`,{className:`social-muted`,children:`Already your friend.`})]}),oT=({profile:e,site:t})=>$(G,{children:[e.bio!==``&&$(`p`,{className:`social-bio`,children:e.bio}),e.links.map(e=>$(EC,{url:e,site:t},e))]}),sT=({link:e,expiresAt:t,state:n,onAdd:r,onClose:i,onSaveAgain:a,onDismiss:o})=>{let s=iT(),[c,l]=K(!1),u=n.kind!==`friends`&&n.kind!==`closed`,d=n.kind===`joined`||n.kind===`offered`||n.kind===`unsaved`;return $(`div`,{className:`social-invite`,"data-social-host":n.kind,children:[u&&!d&&$(G,{children:[$(`code`,{className:`social-key`,"data-invite-link":!0,children:e}),$(`div`,{className:`social-row`,children:$(TC,{text:e,label:`Copy link`})}),$(nT,{text:e}),$(`p`,{className:`social-muted`,children:[`This link works while this tab is open, for `,rT(t,s),` more.`]})]}),$(`div`,{className:`social-stack`,role:`status`,children:[n.kind===`waiting`&&$(`p`,{children:`Waiting for someone to open the link.`}),n.kind===`left`&&$(`p`,{children:`They left. The link still works until it ends.`}),n.kind===`joined`&&$(G,{children:[$(`p`,{children:`Someone opened your link:`}),$(aT,{peer:n.peer}),c&&$(`p`,{className:`social-error`,role:`alert`,children:`The offer did not go out. Try again in a moment.`}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,"data-add":!0,onClick:()=>void r().then(e=>l(!e)),children:[`Add `,n.peer.name]})})]}),n.kind===`offered`&&$(G,{children:[$(aT,{peer:n.peer}),$(`p`,{children:[`Waiting for `,n.peer.name,` to accept.`]})]}),n.kind===`unsaved`&&$(G,{children:[$(aT,{peer:n.peer}),$(`p`,{className:`social-error`,role:`alert`,children:[n.peer.name,` accepted, but your friend list was not saved. `,fC[n.reason]]}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,onClick:a,children:`Save again`})})]}),n.kind===`friends`&&$(`p`,{"data-social-done":!0,children:[`You and `,n.peer.name,` are now friends.`]}),n.kind===`closed`&&$(`p`,{children:`This invite has ended.`})]}),$(`div`,{className:`social-row`,children:u?$(`button`,{type:`button`,"data-close-invite":!0,onClick:i,children:`Close the invite`}):$(`button`,{type:`button`,onClick:o,children:`Done`})})]})},cT=`This browser keeps no site data for FKN Social. Allow site data, then open the link again.`,lT=({state:e,site:t,onAccept:n,onDecline:r,onSendAgain:i,onDismiss:a})=>{let o=e.kind===`friends`||e.kind===`closed`||e.kind===`in-use`||e.kind===`unavailable`,s=e.kind===`accepting`;return $(`div`,{className:`social-invite`,"data-social-guest":e.kind,children:[$(`h2`,{children:`An invite to be friends`}),$(`div`,{className:`social-stack`,role:`status`,children:[e.kind===`joining`&&$(`p`,{children:`Opening the invite...`}),e.kind===`waiting`&&(e.host===null?$(`p`,{children:`Waiting for the person who made it to answer...`}):$(G,{children:[$(aT,{peer:e.host}),$(`p`,{children:[`Waiting for `,e.host.name,` to add you.`]})]})),(e.kind===`offered`||e.kind===`accepting`||e.kind===`failed`)&&$(G,{children:[$(aT,{peer:{...e.host,displayName:e.profile.displayName}}),$(oT,{profile:e.profile,site:t}),e.kind===`failed`&&$(`p`,{className:`social-error`,role:`alert`,children:e.reason===`no-writer`?cT:fC[e.reason]}),$(`div`,{className:`social-row`,children:[(e.kind!==`failed`||e.reason!==`no-writer`)&&$(`button`,{type:`button`,className:`social-primary`,"data-accept":!0,"aria-disabled":s,onClick:()=>{s||n()},children:s?`Accepting...`:e.kind===`failed`?`Try again`:`Accept`}),$(`button`,{type:`button`,"aria-disabled":s,onClick:()=>{s||r()},children:`Decline`})]})]}),e.kind===`unsent`&&$(G,{children:[$(`p`,{className:`social-error`,role:`alert`,children:[e.host.name,` is in your friend list, but your answer did not reach them.`]}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,onClick:i,children:`Send again`})})]}),e.kind===`friends`&&$(`p`,{"data-social-done":!0,children:[`You and `,e.host.name,` are now friends.`]}),e.kind===`in-use`&&$(`p`,{children:`Someone else is already using this invite. Ask for a new link.`}),e.kind===`unavailable`&&$(`p`,{children:`FKN rooms did not answer. Open the link again in a moment.`}),e.kind===`closed`&&$(`p`,{children:`This invite is no longer open. Ask for a new link.`})]}),o&&$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:a,children:`Done`})})]})},uT=[{level:`public`,label:`Public`},{level:`friends`,label:`Friends`},{level:`off`,label:`Off`}],dT={activity:`Delete all activity?`,comments:`Delete all comments?`},fT=(e,t)=>Object.keys(dT).filter(n=>rg(e,n)!==`off`&&rg(t,n)===`off`),pT=({layout:e,onSave:t})=>{let[n,r]=K(e),[i,a]=K(e),[o,s]=K(!1),[c,l]=K(null),[u,d]=K(!1),[f,p]=K(null),m=q(null),h=q(null),g=q(!1),_=e=>{g.current=!0,e?T(!0):p(null)},v=e=>{e!==null&&g.current&&(g.current=!1,e.focus())},y=JSON.stringify(e),[b,x]=K(y);y!==b&&(x(y),y!==JSON.stringify(i)&&(JSON.stringify(n)===JSON.stringify(i)&&r(e),a(e)));let S=e=>{r(e),l(null),d(!1),p(null)},C=(e,t)=>{h.current=`${e}-${t===-1?`up`:`down`}`,S(og(n,e,t))};Bl(()=>{if(h.current===null)return;let e=h.current;h.current=null,m.current?.querySelector(`[data-social-move="${e}"]`)?.focus()},[n.sections]);let w=(e,t)=>S(ag(n,e,t)),T=async(e=!1)=>{if(o)return;let r=fT(i,n);if(!e&&r.length>0)return p(r.length>1?`Delete all activity and comments?`:dT[r[0]]);p(null),s(!0);let c=await t(n,i);s(!1),c.ok&&a(n),d(c.ok),l(c.ok?null:fC[c.reason])};return $(`div`,{className:`social-stack`,"data-social-page-editor":!0,children:[$(`div`,{className:`social-stack`,role:`radiogroup`,"aria-label":`Theme`,children:[$(`span`,{className:`social-label`,children:`Theme`}),$(`div`,{className:`social-swatch-row`,children:Uh.map(e=>$(`label`,{className:`social-choice social-tile`,children:[$(`input`,{type:`radio`,name:`theme`,value:e,checked:n.theme===e,onChange:()=>S({...n,theme:e})}),$(`span`,{className:`social-swatch`,"data-social-theme-swatch":e,style:{background:`linear-gradient(135deg, ${Hh[e].bg} 0% 50%, ${Hh[e].accent} 50% 100%)`},"aria-hidden":`true`}),$(`span`,{className:`social-choice-label`,children:Hh[e].label})]},e))})]}),$(`div`,{className:`social-stack`,role:`radiogroup`,"aria-label":`Colour`,children:[$(`span`,{className:`social-label`,children:`Colour`}),$(`div`,{className:`social-swatch-row`,children:Vh.map(e=>$(`label`,{className:`social-choice social-tile`,children:[$(`input`,{type:`radio`,name:`accent`,value:e,checked:n.accent===e,onChange:()=>S({...n,accent:e})}),$(`span`,{className:`social-swatch`,"data-social-accent":e,"aria-hidden":`true`}),$(`span`,{className:`social-choice-label`,children:Bh[e].label})]},e))})]}),$(`span`,{className:`social-label`,children:`Sections`}),$(`ul`,{className:`social-list`,ref:m,children:n.sections.map((e,t)=>{let r=Kh[e.id],i=e=>e===-1?t===0:t===n.sections.length-1;return $(`li`,{className:`social-section`,"data-social-section":e.id,children:[$(`div`,{className:`social-section-head`,children:[$(`span`,{className:`social-choice-label`,children:r}),$(`div`,{className:`social-section-moves`,children:[[-1,`up`],[1,`down`]].map(([t,n])=>$(`button`,{type:`button`,"aria-label":`Move ${r} ${n}`,"aria-disabled":i(t),"data-social-move":`${e.id}-${n}`,onClick:()=>{i(t)||C(e.id,t)},children:[$(t===-1?nC:rC,{}),`Move `,n]},t))})]}),e.id!==`about`&&$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`Who sees ${r}`,children:uT.map(({level:t,label:n})=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`${e.id}-level`,value:t,checked:e.level===t,onChange:()=>w(e.id,t)}),$(`span`,{className:`social-choice-label`,children:n})]},t))})]},e.id)})}),$(bC,{children:c}),f===null?$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-save-layout":!0,ref:v,"aria-disabled":o,onClick:()=>void T(),children:o?`Saving...`:`Save layout`}),u&&$(`span`,{className:`social-muted`,"data-social-layout-saved":!0,children:`Saved`})]}):$(`div`,{className:`social-warn`,"data-social-drop-activity":!0,children:[$(`p`,{children:f}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,ref:yC,"data-social-drop-confirm":!0,onClick:()=>_(!0),children:`Delete`}),$(`button`,{type:`button`,onClick:()=>_(!1),children:`Cancel`})]})]})]})},mT=(e,t)=>{if(t===``)return;let n=e.at(-1);n?.kind===`text`?e[e.length-1]={kind:`text`,text:n.text+t}:e.push({kind:`text`,text:t})},hT=e=>e===` `||e===` `||e===`
|
|
11
|
+
`||e===`\r`,gT=e=>{if(/\s/.test(e))return null;let t=mu(e);if(t===null)return null;let n=new URL(t);return n.username===``&&n.password===``?t:null},_T=e=>{let t=[],n=[],r=!1,i=0;for(;i<e.length;){if(e[i]==="`"){if(!r){let t=e.indexOf("`",i+1);if(t>i+1){i=t+1;continue}t<0&&(r=!0)}i+=1;continue}if(e[i]===`*`){if(e[i+1]===`*`){let n=i+2;for(;e[n]===`*`;)n+=1;i>0&&!hT(e[i-1])&&t.push(n-2),i=n;continue}i>0&&e[i-1]!==`*`&&!hT(e[i-1])&&n.push(i)}i+=1}return{bold:t,italic:n}},vT=(e,t)=>{let{bold:n,italic:r}=t<2?_T(e):{bold:[],italic:[]},i=0,a=0,o=!1,s=!1,c=[],l=0;for(;l<e.length;){let u=e[l];if(u==="`"){if(!o){let t=e.indexOf("`",l+1);if(t>l+1){c.push({kind:`code`,text:e.slice(l+1,t)}),l=t+1;continue}t<0&&(o=!0)}}else if(u===`[`){let t=l+1;for(;t<e.length;){let n=e[t];if(n===`]`||n===`[`||n===`
|
|
12
|
+
`)break;t+=1}if(e[t]===`]`&&e[t+1]===`(`&&!s){let n=e.indexOf(`)`,t+2);if(n<0)s=!0;else{let r=gT(e.slice(t+2,n));if(r!==null){let i=e.slice(l+1,t).trim()||r;c.push({kind:`link`,label:i,href:r}),l=n+1;continue}}}}else if(t<2&&u===`*`){if(e[l+1]===`*`){if(!hT(e[l+2])){for(;i<n.length&&n[i]<=l+2;)i+=1;if(i<n.length){let r=n[i++];c.push({kind:`strong`,children:vT(e.slice(l+2,r),t+1)}),l=r+2;continue}}}else if(!hT(e[l+1])){for(;a<r.length&&r[a]<=l+1;)a+=1;if(a<r.length){let n=r[a++];c.push({kind:`em`,children:vT(e.slice(l+1,n),t+1)}),l=n+1;continue}}}mT(c,u),l+=1}return c},yT=e=>e.startsWith(`### `)?{level:3,body:e.slice(4)}:e.startsWith(`## `)?{level:2,body:e.slice(3)}:e.startsWith(`# `)?{level:1,body:e.slice(2)}:null,bT=e=>e.startsWith(`- `)||e.startsWith(`* `)?e.slice(2):null,xT=e=>{let t=e.replaceAll(`\r
|
|
13
|
+
`,`
|
|
14
|
+
`).split(`
|
|
15
|
+
`),n=[],r=null,i=null,a=()=>{if(r===null)return;let e=[];for(let[t,n]of r.entries())t>0&&e.push({kind:`break`}),e.push(...vT(n,0));n.push({kind:`paragraph`,children:e}),r=null},o=()=>{i!==null&&(n.push({kind:`list`,items:i}),i=null)};for(let e of t){if(e.trim()===``){a(),o();continue}let t=yT(e);if(t!==null){a(),o(),n.push({kind:`heading`,level:t.level,children:vT(t.body,0)});continue}let s=bT(e);if(s!==null){a(),i===null&&(i=[]),i.push(vT(s,0));continue}o(),r===null&&(r=[]),r.push(e)}return a(),o(),n},ST=(e,t)=>e.map((e,n)=>{let r=`${t}-${n}`;switch(e.kind){case`text`:return $(G,{children:e.text},r);case`break`:return $(`br`,{},r);case`code`:return $(`code`,{children:e.text},r);case`strong`:return $(`strong`,{children:ST(e.children,r)},r);case`em`:return $(`em`,{children:ST(e.children,r)},r);case`link`:return $(`a`,{className:`social-page-link`,href:e.href,target:`_blank`,rel:`noopener noreferrer nofollow ugc`,children:e.label},r)}}),CT=(e,t)=>{let n=`b-${t}`;switch(e.kind){case`heading`:{let t=ST(e.children,n);return e.level===1?$(`h3`,{children:t},n):e.level===2?$(`h4`,{children:t},n):$(`h5`,{children:t},n)}case`paragraph`:return $(`p`,{children:ST(e.children,n)},n);case`list`:return $(`ul`,{children:e.items.map((e,t)=>$(`li`,{children:ST(e,`${n}-i-${t}`)},`${n}-i-${t}`))},n)}},wT=({text:e})=>$(`div`,{className:`social-md`,"data-social-markdown":!0,children:Vl(()=>xT(e),[e]).map(CT)}),TT={...fC,...gC,...mC},ET=[{level:`public`,label:`Public`},{level:`friends`,label:`Friends`},{level:`off`,label:`Off`}],DT=e=>Math.max(1,Math.round(e/1024)).toLocaleString(`en`),OT=(e,t)=>e.kind===`artwork`&&e.items.length>0&&(e.level===`public`&&t!==`public`||e.level===`friends`&&t===`off`),kT=(e,t)=>e.kind===`artwork`&&e.items.length>0&&e.level!==`public`&&t===`public`,AT=e=>Object.fromEntries(e.items.map(e=>[e.picture.url,e.caption??``])),jT=({panel:e,index:t,total:n,onMove:r,onRemove:i,onListProblem:a,actions:o})=>{let[s,c]=K(e.title),[l,u]=K(e.kind===`text`?e.body:``),[d,f]=K(()=>e.kind===`artwork`?AT(e):{}),[p,m]=K(e.title),[h,g]=K(e.kind===`text`?e.body:``),[_,v]=K(()=>e.kind===`artwork`?JSON.stringify(e.items):``),[y,b]=K(()=>e.kind===`artwork`?AT(e):{});e.title!==p&&(m(e.title),c(e.title));let x=e.kind===`text`?e.body:``;x!==h&&(g(x),u(x));let S=e.kind===`artwork`?JSON.stringify(e.items):``;S!==_&&(v(S),e.kind===`artwork`?(b(AT(e)),f(t=>{let n={};for(let r of e.items){let e=r.picture.url,i=r.caption??``,a=y[e];n[e]=a!==void 0&&Object.hasOwn(t,e)&&t[e]!==a&&i===a?t[e]:i}return n})):b({}));let[C,w]=K(`write`),[T,E]=K(!1),[D,O]=K(!1),[k,A]=K(null),[j,M]=K(null),[N,P]=K(!1),[F,I]=K(!1),[L,R]=K(null),[z,ee]=K(``),te=q(null),ne=q(null),re=q(null),ie=q(null),B=q(null);zl(()=>()=>{L!==null&&URL.revokeObjectURL(L.url)},[L]);let ae=e.kind===`artwork`?e.items.length:0;Bl(()=>{B.current===`level`&&j===null?(B.current=null,re.current?.querySelector(`input:checked`)?.focus()):B.current===`file-or-save`&&L===null&&(B.current=null,(te.current??ie.current)?.focus())},[j,e.level,L,ae]);let oe=async(e,t=!1)=>{if(T)return;E(!0),A(null),a(null),O(!1);let n=await e();return E(!1),n.ok?(M(null),P(!1),t&&O(!0)):(B.current=null,n.reason===`sync-failed`&&(M(null),P(!1)),A(TT[n.reason])),n},se=t=>{if(!T){if(A(null),t===e.level){M(null);return}if(OT(e,t)||kT(e,t)){M(t);return}oe(()=>o.setLevel(e.id,t))}},ce=t=>{B.current=`level`,oe(()=>o.setLevel(e.id,t))},le=()=>{T||(M(null),re.current?.querySelector(`input:checked`)?.focus())},ue=async e=>{if(T){A(`Another change is still saving. Try again in a moment.`);return}E(!0),I(!0),A(null),O(!1);let t=await o.fitArtwork(e);if(E(!1),I(!1),!t.ok){A(TT[t.reason]);return}R({...t.picture,url:URL.createObjectURL(t.picture.blob)}),ee(``)},de=()=>{B.current=`file-or-save`,R(null),ee(``)};return $(`li`,{className:`social-section`,"data-social-panel-card":e.id,"data-social-panel-kind":e.kind,children:[$(`div`,{className:`social-section-head`,children:[$(`div`,{className:`social-panel-head-title`,children:[$(`span`,{className:`social-panel-tag`,children:e.kind===`text`?`Text`:`Artwork`}),$(`span`,{className:`social-choice-label`,children:e.title})]}),$(`div`,{className:`social-section-moves`,children:[$(`button`,{type:`button`,"aria-label":`Move ${e.title} up`,"aria-disabled":T||t===0,"data-panel-move":`${e.id}-up`,onClick:()=>{!T&&t>0&&r(-1)},children:[$(nC,{}),`Move up`]}),$(`button`,{type:`button`,"aria-label":`Move ${e.title} down`,"aria-disabled":T||t===n-1,"data-panel-move":`${e.id}-down`,onClick:()=>{!T&&t<n-1&&r(1)},children:[$(rC,{}),`Move down`]}),$(`button`,{type:`button`,ref:ne,className:`social-danger`,"aria-disabled":T,"data-panel-delete-start":e.id,onClick:()=>{T||P(!0)},children:`Delete`})]})]}),N&&$(`div`,{className:`social-warn`,"data-panel-delete-confirm":e.id,children:[$(`p`,{children:e.kind===`artwork`&&e.items.length>0?`Delete this panel and its uploaded artwork from storage?`:`Delete this panel?`}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,ref:yC,"data-panel-delete-confirm-btn":!0,"aria-disabled":T,onClick:()=>void oe(i),children:T?`Deleting...`:`Delete panel`}),$(`button`,{type:`button`,"aria-disabled":T,onClick:()=>{T||(P(!1),ne.current?.focus())},children:`Cancel`})]})]}),$(`div`,{className:`social-seg`,ref:re,role:`radiogroup`,"aria-label":`Who sees ${e.title}`,children:ET.map(({level:t,label:n})=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`panel-level-${e.id}`,value:t,checked:(j??e.level)===t,"aria-disabled":T,onChange:()=>se(t)}),$(`span`,{className:`social-choice-label`,children:n})]},t))}),j!==null&&OT(e,j)&&$(`div`,{className:`social-warn`,"data-panel-level-confirm":e.id,children:[$(`p`,{children:e.level===`public`?`Making this artwork panel non-public deletes its uploaded artwork so no public URL stays exposed.`:`Turning this artwork panel off deletes its uploaded artwork from storage.`}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,ref:yC,"data-panel-level-confirm-btn":!0,"aria-disabled":T,onClick:()=>ce(j),children:T?`Saving...`:`Confirm change`}),$(`button`,{type:`button`,"aria-disabled":T,onClick:le,children:[`Keep `,e.level===`public`?`public`:`for friends`]})]})]}),j!==null&&kT(e,j)&&$(`div`,{className:`social-invite`,"data-panel-publish-confirm":e.id,children:[$(`p`,{children:`Making this panel public lets anyone who opens your page see these artwork images.`}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,ref:yC,"data-panel-publish-confirm-btn":!0,"aria-disabled":T,onClick:()=>ce(`public`),children:T?`Publishing...`:`Make public`}),$(`button`,{type:`button`,"aria-disabled":T,onClick:le,children:[`Keep `,e.level===`friends`?`for friends`:`off`]})]})]}),$(`label`,{className:`social-label`,children:[`Title`,$(`input`,{name:`panel-title-${e.id}`,autoComplete:`off`,value:s,onChange:e=>{c(e.currentTarget.value),O(!1),A(null)}})]}),e.kind===`text`?$(G,{children:[$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`Markdown mode for ${e.title}`,children:[`write`,`preview`].map(t=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`panel-mode-${e.id}`,value:t,checked:C===t,onChange:()=>w(t)}),$(`span`,{className:`social-choice-label`,children:t===`write`?`Write`:`Preview`})]},t))}),C===`write`?$(G,{children:[$(`label`,{className:`social-label`,children:[`Markdown text`,$(`textarea`,{name:`panel-body-${e.id}`,rows:4,value:l,onChange:e=>{u(e.currentTarget.value),O(!1),A(null)}})]}),$(`span`,{className:`social-muted`,children:[l.length,` / `,Jg]})]}):$(`div`,{className:`social-md-preview`,"data-panel-preview":e.id,children:l.trim()?$(wT,{text:l}):$(`span`,{className:`social-muted`,children:`Nothing to preview yet.`})}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-panel-save":e.id,"aria-disabled":T,onClick:()=>void oe(()=>o.updateText(e.id,{title:s,body:l}),!0),children:T?`Saving...`:`Save panel`}),D&&$(`span`,{className:`social-muted`,"data-panel-saved":e.id,children:`Saved`})]})]}):$(G,{children:[e.items.length>0&&$(`div`,{className:`social-art-list`,"data-panel-art-items":e.id,children:e.items.map((t,n)=>$(`div`,{className:`social-art-row`,"data-panel-art-row":t.picture.url,children:[$(`div`,{className:`social-art-row-head`,children:[$(`span`,{className:`social-choice-label`,children:[`Artwork `,n+1]}),$(`button`,{type:`button`,"data-panel-art-remove":t.picture.url,"aria-disabled":T,onClick:()=>void oe(()=>o.removeArtItem(e.id,t.picture.url)),children:`Remove`})]}),$(`label`,{className:`social-label`,children:[`Caption`,$(`input`,{name:`panel-caption-${e.id}-${n}`,autoComplete:`off`,value:d[t.picture.url]??``,placeholder:`Optional caption`,onChange:e=>{let n=e.currentTarget.value;f(e=>({...e,[t.picture.url]:n})),O(!1),A(null)}})]})]},t.picture.url))}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,ref:ie,className:`social-primary`,"data-panel-save":e.id,"aria-disabled":T,onClick:()=>void oe(()=>o.updateArtwork(e.id,{title:s,captions:d}),!0),children:T?`Saving...`:`Save panel`}),D&&$(`span`,{className:`social-muted`,"data-panel-saved":e.id,children:`Saved`})]}),e.level===`off`?$(`p`,{className:`social-muted`,"data-panel-art-off":e.id,children:`Set this panel to Friends or Public to upload artwork.`}):e.items.length<4&&$(`div`,{className:`social-stack`,children:[$(`label`,{className:`social-label`,children:[`Add artwork (`,e.items.length,` / `,4,`)`,F?`: resizing...`:``,$(`input`,{ref:te,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,"aria-disabled":T,"data-panel-file":e.id,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&ue(t)}})]}),L!==null&&$(`div`,{className:`social-stack`,"data-panel-art-preview":e.id,children:[$(`img`,{className:`social-preview`,src:L.url,alt:`Fitted artwork preview`,"data-panel-art-preview-img":!0}),$(`p`,{className:`social-muted`,"data-panel-art-preview-size":!0,children:[L.width,` by `,L.height,` pixels, `,DT(L.blob.size),` KB`,L.animated?`, animated`:``]}),$(`label`,{className:`social-label`,children:[`Caption (optional)`,$(`input`,{name:`panel-new-caption-${e.id}`,autoComplete:`off`,value:z,onChange:e=>ee(e.currentTarget.value)})]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,ref:yC,"data-panel-use-art":e.id,"aria-disabled":T,onClick:()=>{if(L===null)return;let t=L;oe(async()=>{let n=await o.addArtItem(e.id,t.blob,z);return(n.ok||n.reason===`sync-failed`)&&de(),n})},children:`Add artwork`}),$(`button`,{type:`button`,"data-panel-another-art":e.id,"aria-disabled":T,onClick:()=>{T||de()},children:`Choose another`})]})]})]})]}),$(bC,{children:k})]})},MT=({panels:e,actions:t})=>{let[n,r]=K(null),[i,a]=K(null),[o,s]=K(null),[c,l]=K(!1),u=q(null),d=q(null),f=q(null),p=q(null),m=q(void 0);Bl(()=>{if(p.current!==null){let e=p.current;p.current=null,u.current?.querySelector(`[data-panel-move="${e}"]`)?.focus()}if(m.current!==void 0){let e=m.current;m.current=void 0,e===null?d.current?.focus():(u.current?.querySelector(`[data-panel-delete-start="${e}"]`)??d.current)?.focus()}},[e]);let h=t=>{c||e.length>=6||(a(null),s(null),r({kind:t,title:``,body:``,level:`friends`,mode:`write`}))},g=async()=>{if(c||n===null)return;l(!0),a(null),s(null);let e=n.kind===`text`?await t.addText({title:n.title,body:n.body,level:n.level}):await t.addArtwork({title:n.title,level:n.level});l(!1),e.ok?r(null):e.reason===`sync-failed`?(r(null),s(TT[e.reason])):a(TT[e.reason])},_=async(n,r)=>{if(c)return;let i=e.findIndex(e=>e.id===n),a=i+r;if(i<0||a<0||a>=e.length)return;p.current=`${n}-${r===-1?`up`:`down`}`,l(!0),s(null);let o=await t.move(n,r);l(!1),o.ok||(p.current=null,s(TT[o.reason]))},v=async n=>{let r=e.findIndex(e=>e.id===n);m.current=r<0?null:e[r+1]?.id??e[r-1]?.id??null;let i=await t.remove(n);return i.ok||(m.current=void 0,i.reason===`sync-failed`&&s(TT[i.reason])),i};return $(`div`,{className:`social-stack`,"data-social-panels-editor":!0,children:[$(`div`,{className:`social-panel-bar`,children:[$(`p`,{className:`social-muted`,children:`Add Markdown text boxes or artwork showcases. Public panels show on your page; Friends panels stay sealed for friends.`}),$(`span`,{className:`social-panel-count`,"data-social-panel-count":!0,children:[e.length,` / `,6]})]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,ref:d,className:`social-primary`,"data-add-text-panel":!0,"aria-disabled":c||e.length>=6,onClick:()=>h(`text`),children:`Add text panel`}),$(`button`,{type:`button`,ref:f,"data-add-artwork-panel":!0,"aria-disabled":c||e.length>=6,onClick:()=>h(`artwork`),children:`Add artwork panel`})]}),n!==null&&$(`div`,{className:`social-invite`,"data-social-panel-create":n.kind,children:[$(`h2`,{children:n.kind===`text`?`New text panel`:`New artwork panel`}),$(`label`,{className:`social-label`,children:[`Title`,$(`input`,{name:`panel-new-title`,ref:yC,autoComplete:`off`,value:n.title,onChange:e=>{let t=e.currentTarget.value;r(e=>e===null?null:{...e,title:t}),a(null)}})]}),$(`span`,{className:`social-label`,children:`Who sees it`}),$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`Who sees this new panel`,children:ET.map(({level:e,label:t})=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`panel-new-level`,value:e,checked:n.level===e,onChange:()=>r(t=>t===null?null:{...t,level:e})}),$(`span`,{className:`social-choice-label`,children:t})]},e))}),n.kind===`text`&&$(G,{children:[$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`New panel Markdown mode`,children:[`write`,`preview`].map(e=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`panel-new-mode`,value:e,checked:n.mode===e,onChange:()=>r(t=>t===null?null:{...t,mode:e})}),$(`span`,{className:`social-choice-label`,children:e===`write`?`Write`:`Preview`})]},e))}),n.mode===`write`?$(G,{children:[$(`label`,{className:`social-label`,children:[`Markdown text`,$(`textarea`,{name:`panel-new-body`,rows:5,value:n.body,onChange:e=>{let t=e.currentTarget.value;r(e=>e===null?null:{...e,body:t}),a(null)}})]}),$(`div`,{className:`social-muted`,children:[n.body.length,` / `,2e3," - Supports # headings, - lists, **bold**, *italic*, `code`, and [links](https://...)."]})]}):$(`div`,{className:`social-md-preview`,"data-social-new-preview":!0,children:n.body.trim()?$(wT,{text:n.body}):$(`span`,{className:`social-muted`,children:`Nothing to preview yet.`})})]}),$(bC,{children:i}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-create-panel":!0,"aria-disabled":c,onClick:()=>void g(),children:c?`Creating...`:`Create panel`}),$(`button`,{type:`button`,"aria-disabled":c,onClick:()=>{if(c)return;let e=n.kind;r(null),(e===`text`?d:f).current?.focus()},children:`Cancel`})]})]}),$(bC,{children:o}),e.length===0?$(`p`,{className:`social-muted`,"data-social-panels-empty":!0,children:`No custom panels yet.`}):$(`ul`,{className:`social-list`,ref:u,children:e.map((n,r)=>$(jT,{panel:n,index:r,total:e.length,onMove:e=>void _(n.id,e),onRemove:()=>v(n.id),onListProblem:s,actions:t},n.id))})]})},NT={...fC,...pC},PT=e=>e.length<5&&e.at(-1)!==``?[...e,``]:e,FT=e=>({displayName:e.displayName,bio:e.bio,links:PT(e.links)}),IT=({profile:e,onSave:t})=>{let[n,r]=K(()=>FT(e)),[i,a]=K(()=>({displayName:e.displayName,bio:e.bio,links:e.links})),[o,s]=K(!1),[c,l]=K(null),[u,d]=K(!1),f=e=>{r(t=>({...t,...e})),l(null),d(!1)},p=async()=>{if(o)return;s(!0);let e=await t(n,i);s(!1);let r=ff(n);e.ok&&r.ok&&a(r.profile),d(e.ok),l(e.ok?null:NT[e.reason])};return $(`div`,{className:`social-stack`,"data-social-profile":!0,children:[$(`label`,{className:`social-label`,children:[`Display name`,$(`input`,{name:`display-name`,autoComplete:`off`,value:n.displayName,onChange:e=>f({displayName:e.currentTarget.value})})]}),$(`label`,{className:`social-label`,children:[`Bio`,$(`textarea`,{name:`bio`,rows:4,value:n.bio,onChange:e=>f({bio:e.currentTarget.value})})]}),$(`span`,{className:`social-label`,children:`Links`}),n.links.map((e,t)=>$(`input`,{name:`link-${t}`,"aria-label":`Link ${t+1}`,autoComplete:`off`,spellcheck:!1,placeholder:`https://`,value:e,onChange:e=>f({links:PT(n.links.map((n,r)=>r===t?e.currentTarget.value:n))})},t)),$(bC,{children:c}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-save-profile":!0,"aria-disabled":o,onClick:()=>void p(),children:o?`Saving...`:`Save profile`}),u&&$(`span`,{className:`social-muted`,"data-social-saved":!0,children:`Saved`})]})]})},LT=[{level:`me`,label:`Only me`},{level:`friends`,label:`Friends`},{level:`public`,label:`Public`}],RT=({notice:e,page:t})=>{let n=t.replace(/^https?:\/\//,``);return e===`moved`?$(`p`,{className:`social-warn`,role:`status`,"data-social-notice":`moved`,children:[`Your old page was taken down. Publish again to show your profile at `,n,`.`]}):e===`old-page-stands`?$(`p`,{className:`social-muted`,role:`status`,"data-social-notice":`old-page-stands`,children:`Your old page could not be taken down yet. Reload to try again.`}):null},zT=[{slot:`avatar`,label:`Avatar`},{slot:`background`,label:`Background`}],BT=e=>Math.max(1,Math.round(e/1024)).toLocaleString(`en`),VT=({preview:e,busy:t,onUse:n,onAnother:r})=>$(`div`,{className:`social-stack`,"data-social-preview":e.slot,children:[$(`img`,{className:e.slot===`avatar`?`social-avatar`:`social-preview`,src:e.url,alt:`Your new ${e.slot}`,"data-social-preview-image":!0}),$(`p`,{className:`social-muted`,"data-social-preview-size":!0,children:[e.width,` by `,e.height,` pixels, `,BT(e.blob.size),` KB`,e.animated?`, animated`:``]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-use-picture":!0,ref:yC,"aria-disabled":t,onClick:n,children:`Use this picture`}),$(`button`,{type:`button`,"data-another-picture":!0,"aria-disabled":t,onClick:r,children:`Choose another`})]})]}),HT=`Your page shows nothing: see the warning above.`,UT={lost:HT,taken:HT,retired:HT,unrecorded:`Your page could not be written. Write it again from the warning above.`,unknown:`Your page could not be checked just now. Reload to try again.`},WT={"not-kept":`Your profile page room keeps no messages. Turn on Messages kept for it under Rooms in your FKN settings.`,taken:`Someone else holds your profile page room now.`,"out-of-claims":`Your account is at its claimed room limit, so your profile is kept in your name room. Free a room under Rooms in your FKN settings, then make a page room.`,inline:`Your profile is kept in your name room instead of a separate page room.`,unavailable:`FKN rooms did not answer, so your profile page room has not updated yet.`},GT=({visibility:e,page:t,pictures:n,status:r,pageRoomStatus:i=null,oldPage:a=!1,site:o,actions:s})=>{let[c,l]=K(null),[u,d]=K(!1),[f,p]=K(null),[m,h]=K(null),[g,_]=K(null),v=q(null),y=q(!1),b=e.level,x=t.replace(/^https?:\/\//,``);zl(()=>()=>{m!==null&&URL.revokeObjectURL(m.url)},[m]);let S=async(e,t=!1)=>{if(u)return;d(!0),p(null);let n=await e();n.ok&&t&&(y.current=!0),d(!1),n.ok?(l(null),t&&h(null)):p(gC[n.reason])},C=async(e,t)=>{if(u)return;d(!0),_(e),p(null);let n=await s.fitPicture(e,t);if(d(!1),_(null),!n.ok)return p(gC[n.reason]);h({...n.picture,slot:e,url:URL.createObjectURL(n.picture.blob)})},w=e=>{v.current=e,h(null)},T=e=>void S(async()=>{let t=await s.putPicture(e.slot,e.blob);return t.ok&&w(e.slot),t}),E=e=>t=>{t!==null&&v.current===e&&(v.current=null,t.focus())},D=e=>{e!==null&&y.current&&(y.current=!1,(e.querySelector(`input:checked`)??e).focus())},O=e=>{u||(p(null),e===b?l(null):e===`public`||b===`public`||b===`friends`&&e===`me`&&(n.avatar||n.background)?l(e):S(async()=>{let t=await s.setLevel(e);return t.ok&&e===`me`&&h(null),t}))},k=zT.map(({slot:e,label:t})=>$(`div`,{className:`social-stack`,"data-social-picture":e,"data-social-picture-set":n[e],children:[$(`label`,{className:`social-label`,children:[t,` picture: `,g===e?`resizing...`:n[e]?`one is set`:`none yet`,$(`input`,{type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,"aria-disabled":u,"data-picture-input":e,ref:E(e),onChange:t=>{let n=t.currentTarget.files?.[0];t.currentTarget.value=``,n&&C(e,n)}})]}),m?.slot===e&&$(VT,{preview:m,busy:u,onUse:()=>T(m),onAnother:()=>{u||w(e)}}),n[e]&&m?.slot!==e&&$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"aria-disabled":u,onClick:()=>void S(()=>s.removePicture(e)),children:[`Remove the `,t.toLowerCase()]})})]},e)),A=b===`public`&&c!==null&&c!==`public`?c:null,j=b===`friends`&&c===`me`,M=r===null?void 0:UT[r];return $(`div`,{className:`social-stack`,"data-social-level":b,children:[$(`div`,{className:`social-stack`,"data-social-page-link":t,children:[$(`span`,{className:`social-label`,children:`Your page`}),$(EC,{url:t,site:o})]}),$(`div`,{className:`social-seg`,role:`radiogroup`,"aria-label":`Who sees your profile`,ref:b===`public`?void 0:D,children:LT.map(({level:e,label:t})=>$(`label`,{className:`social-choice`,children:[$(`input`,{type:`radio`,name:`visibility`,value:e,checked:(c??b)===e,"aria-disabled":u,onChange:()=>O(e)}),$(`span`,{className:`social-choice-label`,children:t})]},e))}),c===`public`&&b!==`public`&&$(`div`,{className:`social-invite`,"data-social-publish":!0,children:[$(`h2`,{children:`Publish your profile`}),$(`p`,{className:`social-muted`,children:[`Anyone who opens `,x,` sees your profile and pictures.`]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,"data-publish":!0,"aria-disabled":u,onClick:()=>void S(s.publish,!0),children:u?`Publishing...`:`Publish`}),$(`button`,{type:`button`,"aria-disabled":u,onClick:()=>{u||l(null)},children:`Cancel`})]})]}),A!==null&&$(`div`,{className:`social-warn`,"data-social-unpublish":!0,children:[$(`p`,{children:[`Unpublishing deletes your pictures and shows your profile only to `,A===`friends`?`your friends`:`you`,`.`]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,"data-unpublish":!0,ref:yC,"aria-disabled":u,onClick:()=>void S(()=>s.setLevel(A),!0),children:u?`Unpublishing...`:`Unpublish`}),$(`button`,{type:`button`,"aria-disabled":u,onClick:()=>{u||l(null)},children:`Keep it public`})]})]}),j&&$(`div`,{className:`social-warn`,"data-social-hide-pictures":!0,children:[$(`p`,{children:`Switching to Only me deletes your pictures and hides your profile from your friends.`}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,"data-hide-pictures":!0,ref:yC,"aria-disabled":u,onClick:()=>void S(()=>s.setLevel(`me`),!0),children:u?`Saving...`:`Hide profile`}),$(`button`,{type:`button`,"aria-disabled":u,onClick:()=>{u||l(null)},children:`Keep for friends`})]})]}),b===`friends`&&!a&&$(`div`,{className:`social-invite`,"data-social-friends-pictures":!0,children:[$(`h2`,{children:`Profile pictures`}),$(`p`,{className:`social-muted`,children:`Shown only to your friends. Static images are resized; animated GIF and WebP files keep their motion.`}),k]}),b===`public`&&$(`div`,{className:`social-invite`,"data-social-public":r??`checking`,children:[$(`h2`,{tabIndex:-1,ref:D,children:`Your public page`}),M!==void 0&&$(`p`,{className:`social-warn-text`,role:`status`,"data-social-page-status":!0,children:M}),!a&&$(G,{children:[$(`p`,{className:`social-muted`,children:`Static images are resized; animated GIF and WebP files keep their motion.`}),k]}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-unpublish-start":!0,"aria-disabled":u,onClick:()=>{u||l(`friends`)},children:`Unpublish`})})]}),i!==null&&WT[i]!==void 0&&$(`div`,{className:`social-stack`,"data-social-page-room-status":i,children:[$(`p`,{className:`social-warn-text`,role:`status`,children:WT[i]}),(i===`taken`||i===`out-of-claims`||i===`inline`)&&s.makePage!==void 0&&$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,"data-make-page":!0,"aria-disabled":u,onClick:()=>void S(s.makePage),children:`Make a page room`})})]}),u&&c===null&&$(`p`,{className:`social-muted`,role:`status`,children:`Saving...`}),$(bC,{children:f})]})},KT=()=>null,qT=e=>Object.keys(e.apps).sort().flatMap(t=>{let n=fS(e,t);return n===null?[]:[{app:t,grant:n}]}),JT=(e,t)=>e.inbox===t.inbox&&e.seq===t.seq,YT=e=>{let[t,n]=K(e.state);return zl(()=>(n(e.state()),e.on(n)),[e]),t},XT=({invite:e,onDismiss:t})=>{let n=YT(e);return $(sT,{link:e.link,expiresAt:e.expiresAt,state:n,onAdd:e.add,onClose:()=>void e.close(),onSaveAgain:()=>void e.saveAgain(),onDismiss:t})},ZT=({invite:e,site:t,onDismiss:n})=>$(lT,{state:YT(e),site:t,onAccept:()=>void e.accept(),onDecline:()=>{e.decline(),n()},onSendAgain:()=>void e.sendAgain(),onDismiss:n}),QT={me:`Only me`,friends:`Friends`,public:`Public`},$T=({services:e,identity:t,listed:n,fresh:r,cutShort:i,onChanged:a,site:o,staged:s,onStagedTaken:c,adding:l,onAddDone:u,onAdd:d,editing:f,onEditDone:p})=>{let[m,h]=K(null),[g,_]=K(null),[v,y]=K(null),[b,x]=K([]),[S,C]=K(null),[w,T]=K(!1),[E,D]=K(()=>f?`customize`:s!==null||l!==void 0?`friends`:r?`account`:`overview`),[O,k]=K(()=>f?`layout`:`general`),[A,j]=K(!1),M=q(null),N=Vl(()=>zh(t.seed),[t.seed]),P=q(null);zl(()=>{let e=new Set;return P.current=e,()=>{P.current=null;for(let t of e)t()}},[]);let F=e=>P.current!==null&&(P.current.add(e),!0),I=q(null),[L,R]=K(!1),z=Hl(e=>(e.ok&&(I.current=e.roster,h(e.roster)),_(e.ok?null:fC[e.reason]),R(!e.ok&&e.reason===`reset`),e),[]),[ee,te]=K(!1),ne=Hl(async t=>{z(await(t??qf(e))),te(!0)},[e,z]),re=q(n);zl(()=>{ne(re.current??void 0)},[ne]);let ie=q(Promise.resolve()),B=Hl(e=>{let t=ie.current.then(e,e);return ie.current=t.catch(()=>{}),t},[]),[ae,oe]=K(null),[se,ce]=K(null),le=q(null),ue=q(null),[de,fe]=K(null),pe=Vl(()=>({keys:N,name:t.name}),[N,t.name]),[me,he]=K(null),V=q(!1),ge=q(!1),_e=async t=>{let n=await qf(e);return n.ok?(z(n),t(Lx(n.roster,ge.current))):{ok:!1,reason:n.reason===`reset`?`list-reset`:n.reason}},ve=Hl(async(t=!1)=>{let n=I.current;if(n!==null&&jx(n)!==null){let t=await Wx(e,n);fe(t.ok?`moved`:`old-page-stands`),t.ok&&(z(t),n=t.roster)}let r=n===null?null:V.current?{roster:n,inboxTaken:ge.current}:(async t=>{V.current=!0;let n=await ax(e,N,t);n.roster!==void 0&&z({ok:!0,roster:n.roster}),ge.current=n.status===`taken`,he(n);for(let t of n.waiting)Ub(e.rooms,t.sender.name,t.sender.signKey).then(e=>he(n=>n===null?n:{...n,waiting:n.waiting.map(n=>JT(n,t)?{...n,sender:{...n.sender,confirmed:e}}:n)}));return{roster:n.roster??t,inboxTaken:ge.current}})(n),i=await Rx(e,pe,r,{lastNameStatus:le.current,lastCoreKey:ue.current,skipNameIfUnchanged:!t});return i.roster!==void 0&&z({ok:!0,roster:i.roster}),le.current=i.status,ue.current=i.coreKey,oe(i.status),ce(i.pageStatus),i},[e,N,pe,z]),ye=Hl(()=>B(async()=>{await ve(!1)}),[B,ve]),be=Hl(()=>B(async()=>{await ve(!0)}),[B,ve]);zl(()=>{ee&&be()},[ee,be]);let xe={claimAgain:async()=>{let n=await B(()=>_e(n=>sS(e,t,n)));return await be(),n},rename:async t=>{let n=await B(()=>_e(n=>aS(e,t,n)));return n.ok&&await a(),n},giveBack:t=>oS(e,t)},Se=e=>{z({ok:!0,roster:e.roster}),le.current=e.status,oe(e.status),e.pageStatus!==void 0&&ce(e.pageStatus);let t=_x(e.roster);ue.current=typeof t==`string`?Ix(Fx(e.roster,t,ge.current)):null},Ce={setLevel:t=>B(async()=>{if(I.current===null)return{ok:!1,reason:`unavailable`};let n=await Ux(e,pe,I.current,t,ge.current);return n.ok?(Se(n),{ok:!0}):(n.pageStatus!==void 0&&ce(n.pageStatus),n)}),publish:()=>B(async()=>{let t=await Vx(e,pe,ge.current);return t.ok?(Se(t),fe(null),{ok:!0}):t}),fitPicture:(e,t)=>Kg(t,e,qg),putPicture:async(t,n)=>{let r=await B(()=>Rg(e,t,n));return r.ok?(z(r),await ye(),{ok:!0}):r},removePicture:async t=>{let n=await B(()=>zg(e,t));return n.ok?(z(n),await ye(),{ok:!0}):n},makePage:()=>B(async()=>{if(I.current===null)return{ok:!1,reason:`unavailable`};let t=I.current,n=_x(t)??void 0,r;if(n===void 0){let t=await Vb(e.rooms,N,pe.name);if(t===null)return{ok:!1,reason:`unavailable`};r=Sx(t)}let i=await Cx(e,N,Nx(t),r,n);return i.roster!==void 0&&z({ok:!0,roster:i.roster}),i.ok?(await ve(!0)).pageStatus===`ready`?{ok:!0}:{ok:!1,reason:`unavailable`}:(i.reason===`out-of-claims`&&ce(`out-of-claims`),{ok:!1,reason:i.reason})})},we=e=>e.pageStatus===`ready`||(e.pageStatus===`inline`||e.pageStatus===`unused`||e.pageStatus===`out-of-claims`)&&e.status===`held`,Te=async e=>{if(!e.ok)return e;`roster`in e&&z(e);let t=await ve(!1).catch(()=>null);return t!==null&&we(t)?{ok:!0}:{ok:!1,reason:`sync-failed`}},Ee=async({outcome:t,dropped:n})=>{if(!t.ok)return t;z(t);let r=null;try{r=await ve(!1)}catch{r=null}finally{await Ig(e.storage,n)}return r!==null&&we(r)?{ok:!0}:{ok:!1,reason:`sync-failed`}},De={addText:t=>B(async()=>Te(await __(e,t))),addArtwork:t=>B(async()=>Te(await v_(e,t))),updateText:(t,n)=>B(async()=>Te(await y_(e,t,n))),updateArtwork:(t,n)=>B(async()=>Te(await b_(e,t,n))),move:(t,n)=>B(async()=>Te(await x_(e,t,n))),setLevel:(t,n)=>B(async()=>Ee(await S_(e,t,n))),remove:t=>B(async()=>Ee(await C_(e,t))),fitArtwork:e=>Kg(e,`artwork`,qg),addArtItem:(t,n,r)=>B(async()=>Te(await w_(e,t,n,r))),removeArtItem:(t,n)=>B(async()=>Ee(await T_(e,t,n)))},Oe=e=>({keys:N,name:t.name,profile:mf(e),inbox:ge.current?null:Qb(e)??null}),ke=async()=>{let t=ge.current&&I.current!==null?Qb(I.current):void 0,n=await B(()=>$b(e,typeof t==`string`?t:void 0));return n.roster!==void 0&&z({ok:!0,roster:n.roster}),n.ok&&(ge.current=!1,he({status:`ready`,waiting:me?.waiting??[],accepted:me?.accepted??[]}),await ye()),n},Ae=e=>he(t=>t===null?t:{...t,waiting:t.waiting.filter(t=>!JT(t,e))}),je={answer:async(t,n)=>{if(I.current===null)return{ok:!1,reason:`unreachable`};let r=await ux(e,Oe(I.current),t,n);return r.roster!==void 0&&z({ok:!0,roster:r.roster}),r.ok&&Ae(t),r.ok&&n&&ye(),r},dismiss:async t=>{await fx(e,t),Ae(t)},approve:async t=>{let n=await B(()=>Bx(e,pe,t));return n&&Ae(t),n}},Me=Hl(t=>Gb(e.rooms,t),[e]),Ne=t=>B(async()=>{let n=await qf(e);if(!n.ok)return n;let r=await lx(e,Oe(n.roster),t);return ne(),r}),Pe=e=>t=>e.friends[t]?.value.state===`active`,Fe=e=>e.on(e=>{e.kind===`friends`&&ne().then(ye)});zl(()=>{if(s===null||m===null||M.current===s)return;M.current=s,c();let t=YS(e,Oe(m),s,Pe(m));F(t.decline),Fe(t),C(t)});let Ie=async()=>{if(m===null||w||b.length>=3)return;T(!0);let t=await qS(e,Oe(m),Pe(m));if(T(!1),!t.ok)return _(t.reason===`no-writer`?fC[`no-writer`]:`No invite was made. Try again in a moment.`);if(!F(t.invite.close))return void t.invite.close();Fe(t.invite),x(e=>[...e,t.invite])},Le=t=>B(async()=>await zx(e,pe,t)===`written`?null:hC),Re={change:async(t,n)=>{if(`level`in n&&n.level===`friends`){let e=await Le(e=>Iu(e,t));if(e!==null)return e}let r=await vS(e,t,n);return r.ok?(z(r),ye(),null):fC[r.reason]},remove:e=>Le(t=>Fu(t,e))},ze=q(null),[Be,Ve]=K(!1);zl(()=>{Be&&(ze.current?.focus(),Ve(!1))},[Be]),zl(()=>{f&&(D(`customize`),k(`layout`))},[f]),zl(()=>{(s!==null||l!==void 0)&&D(`friends`)},[s,l]);let He=o()!==null,Ue=m===null||!He?[]:qT(m),We=Ue.filter(({grant:e})=>e.state===`asked`),Ge=Ue.filter(({grant:e})=>e.state!==`asked`),Ke=m===null?[]:jf(m),qe=Ke.find(e=>e.fingerprint===v)??null,Je=q(void 0),Ye=e=>t=>{t!==null&&Je.current===e&&(Je.current=void 0,t.focus())},Xe=e=>{Je.current=e,y(null)},Ze=async()=>{let t=await uS(e);return t.ok&&(Je.current=null,D(`friends`),await ne().then(ye)),t},Qe=e=>{e!==null&&f&&(e.focus(),p())},$e=We.length+(me?.waiting.length??0)+(me?.accepted.length??0),et=E_(du,t.name),tt=m===null?null:pf(m),nt=m===null?`friends`:lf(m).level,rt=m?.profile.avatar?.value??null,it=SC(e.storage,rt,pg.avatar),at=[{id:`overview`,label:`Overview`},{id:`customize`,label:`Customize`},{id:`friends`,label:`Friends`,...Ke.length>0?{badge:Ke.length}:{}},{id:`inbox`,label:`Inbox`,...$e>0?{badge:$e,accentBadge:!0}:{}},...He?[{id:`apps`,label:`Apps`,...Ge.length>0?{badge:Ge.length}:{}}]:[],{id:`account`,label:`Account`}];return $(`div`,{className:`social-workspace`,"data-social-state":`ready`,children:[$(`aside`,{className:`social-sidebar`,children:[$(`div`,{className:`social-sidebar-head`,children:$(`span`,{className:`social-brand`,children:[$(eC,{size:16}),$(`span`,{children:`FKN Social`})]})}),$(`div`,{className:`social-sidebar-user`,"data-social-claim":ae??`unknown`,children:[$(CC,{signKey:N.signKey,src:it,url:rt?.url,avatarAlt:`${t.name}'s avatar`,small:!0}),$(`div`,{children:[$(`span`,{className:`social-brand-name`,"data-social-name":!0,children:t.name}),$(`span`,{className:`social-muted`,children:QT[nt]})]})]}),$(`nav`,{className:`social-nav`,"aria-label":`App pages`,children:at.map(e=>$(`button`,{type:`button`,className:`social-nav-btn`,"data-social-nav":e.id,"aria-current":E===e.id?`page`:void 0,onClick:()=>D(e.id),children:[$(`span`,{className:`social-nav-label`,children:[$(tC,{id:e.id}),$(`span`,{children:e.label})]}),e.badge!==void 0&&$(`span`,{className:e.accentBadge?`social-nav-badge social-nav-badge-accent`:`social-nav-badge`,children:e.badge})]},e.id))})]}),$(`main`,{className:`social-main`,"data-social-tab":E,children:[i&&$(`p`,{className:`social-error`,role:`alert`,"data-social-cut-link":!0,children:`This invite link is incomplete. Ask for the link again.`}),$(RT,{notice:de,page:et}),E!==`account`&&$(HC,{status:ae??`unknown`,onClaimAgain:xe.claimAgain,onRename:()=>{j(!0),D(`account`)}}),$(bC,{children:g}),m===null&&g!==null&&$(`div`,{className:`social-card-box`,children:[$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:()=>void ne(),children:`Try again`})}),L&&$(eE,{onReset:Ze})]}),E===`account`&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h1`,{children:`Account`})}),$(`div`,{className:`social-card-box`,children:$(WC,{identity:t,fresh:r,status:ae??`unknown`,actions:xe,avatar:it,avatarUrl:rt?.url,openRename:A,onRenameOpened:()=>j(!1)})})]}),m!==null&&E!==`account`&&$(G,{children:[E===`overview`&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h1`,{children:`Overview`})}),$(`div`,{className:`social-overview-grid`,children:[$(`div`,{className:`social-card-box`,children:[$(`div`,{className:`social-card`,children:[$(CC,{signKey:N.signKey,src:it,url:rt?.url,avatarAlt:`${t.name}'s avatar`}),$(`div`,{children:[$(`div`,{className:`social-name`,style:vC(tt?.displayName||t.name),children:tt?.displayName||t.name}),tt?.displayName&&tt.displayName!==t.name&&$(`div`,{className:`social-muted`,children:t.name}),$(`div`,{className:`social-muted`,children:QT[nt]})]})]}),tt?.bio&&$(`p`,{className:`social-bio`,children:tt.bio}),$(EC,{url:et,site:o})]}),$(`div`,{className:`social-card-box`,children:[$(`h2`,{children:`Shortcuts`}),$(`div`,{className:`social-stats-strip`,children:[$(`div`,{className:`social-stat-cell`,children:[$(`span`,{className:`social-stat-label`,children:`Friends`}),$(`strong`,{className:`social-stat-value`,children:Ke.length})]}),$(`div`,{className:`social-stat-cell`,children:[$(`span`,{className:`social-stat-label`,children:`Inbox`}),$(`strong`,{className:`social-stat-value`,children:$e})]})]}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-primary`,onClick:()=>D(`customize`),children:`Customize`}),$(`button`,{type:`button`,onClick:()=>D(`friends`),children:[`Friends (`,Ke.length,`)`]}),$e>0&&$(`button`,{type:`button`,onClick:()=>D(`inbox`),children:[`Inbox (`,$e,`)`]})]}),me!==null&&me.status!==`ready`&&$(`p`,{className:`social-warn-text`,children:`Check your inbox status under Inbox.`})]})]})]}),E===`customize`&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h1`,{children:`Customize`})}),$(`nav`,{className:`social-subtabs`,"aria-label":`Customize sections`,children:[[`general`,`General`],[`panels`,`Panels`],[`layout`,`Page layout`],[`visibility`,`Privacy`]].map(([e,t])=>$(`button`,{type:`button`,className:`social-subtab`,"data-social-subtab":e,"aria-current":O===e?`page`:void 0,onClick:()=>k(e),children:t},e))}),O===`general`&&$(`div`,{className:`social-card-box`,children:[$(`h2`,{children:`Profile`}),$(IT,{profile:pf(m),onSave:async(t,n)=>{let r=await Xf(e,t,n);return r.ok&&(z(r),ye()),r}})]}),O===`panels`&&$(`div`,{className:`social-card-box`,children:[$(`h2`,{children:`Custom panels`}),$(MT,{panels:d_(m),actions:De})]}),O===`layout`&&$(`div`,{className:`social-card-box`,children:[$(`h2`,{tabIndex:-1,ref:Qe,"data-social-layout":!0,children:`Page layout`}),$(pT,{layout:ng(m),onSave:async(t,n)=>{let r=await dg(e,t,n);return r.ok&&(z(r),ye()),r}})]}),O===`visibility`&&$(`div`,{className:`social-card-box`,children:[$(`h2`,{children:`Who sees your profile`}),$(GT,{visibility:lf(m),page:et,status:ae,pageRoomStatus:se,oldPage:jx(m)!==null,site:o,actions:Ce,pictures:{avatar:(m.profile.avatar?.value??null)!==null,background:(m.profile.background?.value??null)!==null}})]})]}),E===`friends`&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h2`,{tabIndex:-1,ref:Ye(null),children:`Friends`})}),S!==null&&$(ZT,{invite:S,site:o,onDismiss:()=>C(null)}),l!==void 0&&$(sw,{name:l,own:N.signKey,isFriend:e=>Pe(m)(tf(e)),read:Me,send:Ne,onMake:ke,onClose:u},l),b.map(e=>$(XT,{invite:e,onDismiss:()=>x(t=>t.filter(t=>t!==e))},e.link)),qe===null?$(`div`,{className:`social-friends-grid`,children:[$(`div`,{className:`social-card-box`,children:$(uw,{friends:Ke,onOpen:y,focusRef:Ye})}),$(`div`,{className:`social-card-box`,children:[$(ow,{onAdd:d}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,"data-new-invite":!0,"aria-disabled":w||b.length>=3,onClick:()=>void Ie(),children:w?`Making a link...`:`Invite a friend`})}),b.length>=3&&$(`p`,{className:`social-muted`,children:`Close an invite, or press Done, to make another.`})]})]}):$(`div`,{className:`social-card-box`,children:$(mw,{friend:qe,site:o,onBack:()=>Xe(qe.fingerprint),onInvite:async t=>dx(e,Oe(m),qe,t),onNickname:async t=>z(await tp(e,qe.fingerprint,t)),onRemove:async()=>{let t=Ke[Ke.indexOf(qe)+1]?.fingerprint??null,n=z(await np(e,qe.fingerprint));return n.ok&&(Xe(t),ye()),n}},qe.fingerprint)})]}),E===`inbox`&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h1`,{children:`Inbox`})}),$(`div`,{className:`social-card-box`,children:[$(jC,{asks:We,actions:Re,onAnswered:()=>{D(`apps`),Ve(!0)}}),$(iw,{status:me?.status??null,waiting:me?.waiting??[],accepted:me?.accepted??[],site:o,actions:je,onMake:ke}),We.length===0&&me?.status===`ready`&&me.waiting.length===0&&me.accepted.length===0&&$(`p`,{className:`social-muted`,children:`Nothing waiting.`})]})]}),E===`apps`&&He&&$(G,{children:[$(`div`,{className:`social-main-head`,children:$(`h2`,{ref:ze,tabIndex:-1,children:`Apps`})}),$(`div`,{className:`social-card-box`,children:Ge.length>0?$(PC,{apps:Ge,actions:Re}):$(`p`,{className:`social-muted`,children:`No connected apps yet.`})})]})]})]})]})},eE=({onReset:e})=>{let[t,n]=K(!1),[r,i]=K(!1),[a,o]=K(null),s=q(null),c=()=>{r||(n(!1),o(null),s.current?.focus())},l=async()=>{if(r)return;i(!0),o(null);let t=await e();i(!1),t.ok||o(t.reason)};return $(G,{children:[$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,ref:s,"data-social-reset":!0,onClick:()=>n(!0),children:`Reset Social`})}),t&&$(`div`,{className:`social-warn`,"data-social-reset-ask":!0,children:[$(`p`,{children:`Your friend list, profile, page layout, favourites and app permissions will be deleted for good.`}),$(uC,{reason:a}),$(`div`,{className:`social-row`,children:[$(`button`,{type:`button`,className:`social-danger`,ref:yC,"data-social-reset-confirm":!0,"aria-disabled":r,onClick:()=>void l(),children:r?`Resetting...`:`Reset`}),$(`button`,{type:`button`,"aria-disabled":r,onClick:c,children:`Cancel`})]})]})]})},tE=({title:e,children:t,onRetry:n})=>$(G,{children:[$(`h1`,{children:e}),$(`p`,{children:t}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:n,children:`Try again`})})]}),nE=({services:e,onChanged:t})=>{let[n,r]=K(!1),[i,a]=K(!1),[o,s]=K(null),c=async e=>(e.ok&&await t(),e),l=async()=>{if(i)return;a(!0),s(null);let t=await c(await lS(e));a(!1),t.ok||s(t.reason)};return $(G,{children:[$(`h1`,{children:`Your saved identity will not open`}),$(`p`,{children:`Enter your recovery key to bring it back.`}),$(RC,{onRestore:async t=>c(await cS(e,t))}),$(`h2`,{children:`No recovery key?`}),$(`p`,{className:`social-muted`,children:`You can start over with a new key, which nothing links to the old one.`}),$(uC,{reason:o}),$(`div`,{className:`social-row`,children:n?$(`button`,{type:`button`,"aria-disabled":i,onClick:()=>void l(),children:`Start over with a new key`}):$(`button`,{type:`button`,onClick:()=>r(!0),children:`Start over`})})]})},rE=({services:e,canRestore:t,inviteWaiting:n,onPicked:r,onChanged:i})=>{let[a,o]=K(!1);return $(G,{children:[$(`h1`,{children:`Pick your name`}),n&&$(`p`,{className:`social-warn`,"data-social-invite-waiting":!0,children:`Pick your name first, then the invite opens.`}),$(LC,{label:`Claim name`,onPick:async t=>{let n=await aS(e,t);return n.ok&&await r(),n}}),t&&(a?$(G,{children:[$(`h2`,{children:`Restore from a recovery key`}),$(RC,{onRestore:async t=>{let n=await cS(e,t);return n.ok&&await i(),n}})]}):$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,onClick:()=>o(!0),children:`I have a recovery key`})}))]})},iE=({state:e,props:t,listed:n=null,reload:r,fresh:i,setFresh:a,cutShort:o=!1,staged:s=null,onStagedTaken:c=()=>{},adding:l,onAddDone:u=()=>{},onAdd:d=()=>{},editing:f=!1,onEditDone:p=()=>{}})=>{let{services:m}=t,h=()=>void r();switch(e.kind){case`unreachable`:return $(tE,{title:`FKN cannot be reached`,onRetry:h,children:`Check your connection, then try again.`});case`signed-out`:return $(G,{children:[$(`h1`,{children:`Sign in to FKN`}),$(`p`,{children:`Sign in to FKN, then come back here.`}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,onClick:h,children:`I signed in`})})]});case`no-keys`:return $(tE,{title:`Set up encryption first`,onRetry:h,children:`Set up an encryption key in your FKN account, then try again.`});case`locked`:return $(G,{children:[$(`h1`,{children:`Unlock your FKN storage`}),$(`div`,{className:`social-row`,children:$(`button`,{type:`button`,className:`social-primary`,onClick:()=>void t.unlock().then(r),children:`Unlock`})})]});case`reset`:return $(nE,{services:m,onChanged:r});case`newer`:return $(tE,{title:`This needs a newer FKN Social`,onRetry:h,children:`Reload the page to update.`});case`no-identity`:return $(rE,{services:m,canRestore:!0,inviteWaiting:s!==null,onPicked:async()=>{a(!0),await r()},onChanged:r});case`ready`:{let{identity:h}=e;return h.name===null?$(rE,{services:m,canRestore:!1,inviteWaiting:s!==null,onPicked:async()=>{a(!0),await r()},onChanged:r}):$($T,{services:m,identity:{...h,name:h.name},listed:n,fresh:i,cutShort:o,onChanged:r,site:t.site??KT,staged:s,onStagedTaken:c,adding:l,onAddDone:u,onAdd:d,editing:f,onEditDone:p})}}},aE=e=>{let[t,n]=K(null),[r,i]=K(null),[a,o]=K(!1),[s,c]=K(null),[l,u]=K(!1),[d,f]=K(void 0),[p,m]=K(!1),h=Hl(()=>m(!1),[]),g=q(0),[_,v]=K(0),y=Vl(()=>nS(e.services,()=>g.current===_),[e.services,_]),b=Hl(async()=>{let e=null,t=await iS(y,()=>{e=qf(y)});g.current===_&&(i(e),n(t))},[y,_]);zl(()=>{b()},[b]);let{onAccountChange:x,invites:S,adds:C,edits:w}=e;zl(()=>{let e=x(e=>{e?.switched!==!1&&(g.current+=1,v(g.current),n(null),o(!1))});return()=>{e.then(e=>e())}},[x]),zl(()=>S?.(e=>{u(e===null),e!==null&&c(e)}),[S]),zl(()=>C?.(f),[C]),zl(()=>w?.(()=>m(!0)),[w]);let T=t?.kind===`ready`&&t.identity.name!==null;if(zl(()=>{p&&t!==null&&!T&&m(!1)},[p,t,T]),t===null)return $(oC,{state:`loading`,label:`Loading...`,error:l?$(`p`,{className:`social-error`,role:`alert`,"data-social-cut-link":!0,children:`This invite link is incomplete. Ask for the link again.`}):void 0});let E=$(iE,{state:t,props:{...e,services:y},listed:r,reload:b,fresh:a,setFresh:o,cutShort:l,staged:s,onStagedTaken:()=>c(null),adding:d,onAddDone:()=>f(void 0),onAdd:f,editing:p,onEditDone:h});return T?E:$(aC,{children:[l&&$(`p`,{className:`social-error`,role:`alert`,"data-social-cut-link":!0,children:`This invite link is incomplete. Ask for the link again.`}),$(`div`,{"data-social-state":t.kind,children:E})]})},{blue:oE}=Bh,sE=e=>Vh.map(t=>`[data-social-accent="${t}"] { --accent: ${Bh[t][e].accent}; --accent-text: ${Bh[t][e].text}; }`).join(`
|
|
16
|
+
`),cE=Uh.map(e=>{let t=Hh[e],n=t.light?Gh.light:Gh.dark,r=t.light?`#e3e7ef`:t.head,i=t.light?`#d5dbe6`:`color-mix(in srgb, ${t.head} 82%, #ffffff)`,a=t.light?`#9fa8b9`:`color-mix(in srgb, ${t.border} 72%, #ffffff)`,o=t.light?`color-mix(in srgb, ${t.accent} 86%, #000000)`:`color-mix(in srgb, ${t.accent} 86%, #ffffff)`;return`[data-social-theme="${e}"] {
|
|
17
|
+
color-scheme: ${t.light?`light`:`dark`};
|
|
18
|
+
--p-bg: ${t.bg};
|
|
19
|
+
--p-sheet: ${t.sheet};
|
|
20
|
+
--p-panel: ${t.panel};
|
|
21
|
+
--p-head: ${t.head};
|
|
22
|
+
--p-border: ${t.border};
|
|
23
|
+
--p-text: ${t.text};
|
|
24
|
+
--p-muted: ${t.muted};
|
|
25
|
+
--p-accent: ${t.accent};
|
|
26
|
+
--p-accent-text: ${t.accentText};
|
|
27
|
+
--p-pill: ${t.pill};
|
|
28
|
+
--p-sky-top: ${t.skyTop};
|
|
29
|
+
--p-sky-bot: ${t.skyBot};
|
|
30
|
+
--bg: ${t.bg};
|
|
31
|
+
--panel: ${t.panel};
|
|
32
|
+
--panel-2: ${t.head};
|
|
33
|
+
--control: ${r};
|
|
34
|
+
--control-hover: ${i};
|
|
35
|
+
--text: ${t.text};
|
|
36
|
+
--muted: ${t.muted};
|
|
37
|
+
--line: ${t.border};
|
|
38
|
+
--line-strong: ${a};
|
|
39
|
+
--accent: ${t.accent};
|
|
40
|
+
--accent-text: ${t.accentText};
|
|
41
|
+
--btn: ${t.accent};
|
|
42
|
+
--btn-ink: ${t.accentText};
|
|
43
|
+
--btn-hover: ${o};
|
|
44
|
+
--warn-bg: ${n.warnBg};
|
|
45
|
+
--warn-line: ${n.warnLine};
|
|
46
|
+
--error: ${n.error};
|
|
47
|
+
}`}).join(`
|
|
48
|
+
`),lE=`
|
|
49
|
+
:root {
|
|
50
|
+
color-scheme: light dark;
|
|
51
|
+
--bg: #f4f5f7;
|
|
52
|
+
--panel: #ffffff;
|
|
53
|
+
--panel-2: #eceef2;
|
|
54
|
+
--control: #e6e9ef;
|
|
55
|
+
--control-hover: #d8dde6;
|
|
56
|
+
--text: #14161a;
|
|
57
|
+
--muted: #525864;
|
|
58
|
+
--line: #dde0e7;
|
|
59
|
+
--line-strong: #b4bac8;
|
|
60
|
+
--line-ctrl: #767c8a;
|
|
61
|
+
--btn: #14161a;
|
|
62
|
+
--btn-ink: #ffffff;
|
|
63
|
+
--btn-hover: #2b2f38;
|
|
64
|
+
--accent: ${oE.light.accent};
|
|
65
|
+
--accent-text: ${oE.light.text};
|
|
66
|
+
--warn-bg: ${Gh.light.warnBg};
|
|
67
|
+
--warn-line: ${Gh.light.warnLine};
|
|
68
|
+
--error: ${Gh.light.error};
|
|
69
|
+
font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
70
|
+
-webkit-font-smoothing: antialiased;
|
|
71
|
+
}
|
|
72
|
+
@media (prefers-color-scheme: dark) {
|
|
73
|
+
:root {
|
|
74
|
+
--bg: #0f1012;
|
|
75
|
+
--panel: #16181c;
|
|
76
|
+
--panel-2: #1d2026;
|
|
77
|
+
--control: #24272f;
|
|
78
|
+
--control-hover: #2f333d;
|
|
79
|
+
--text: #f2f3f5;
|
|
80
|
+
--muted: #989fa9;
|
|
81
|
+
--line: #272a32;
|
|
82
|
+
--line-strong: #3e4350;
|
|
83
|
+
--line-ctrl: #7c8391;
|
|
84
|
+
--btn: #f2f3f5;
|
|
85
|
+
--btn-ink: #0f1012;
|
|
86
|
+
--btn-hover: #d6d9df;
|
|
87
|
+
--accent: ${oE.dark.accent};
|
|
88
|
+
--accent-text: ${oE.dark.text};
|
|
89
|
+
--warn-bg: ${Gh.dark.warnBg};
|
|
90
|
+
--warn-line: ${Gh.dark.warnLine};
|
|
91
|
+
--error: ${Gh.dark.error};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
${sE(`light`)}
|
|
95
|
+
@media (prefers-color-scheme: dark) {
|
|
96
|
+
${sE(`dark`)}
|
|
97
|
+
}
|
|
98
|
+
${cE}
|
|
99
|
+
${Vh.filter(e=>e!==`blue`).map(e=>`[data-social-theme][data-social-accent="${e}"]:not([data-social-theme="daylight"]) { --accent: ${Bh[e].dark.accent}; --accent-text: ${Bh[e].dark.text}; --btn: ${Bh[e].dark.accent}; --btn-ink: ${Bh[e].dark.text}; --btn-hover: color-mix(in srgb, ${Bh[e].dark.accent} 86%, #ffffff); }`).join(`
|
|
100
|
+
`)}
|
|
101
|
+
${Vh.map(e=>`[data-social-theme="daylight"][data-social-accent="${e}"] { --accent: ${Bh[e].light.accent}; --accent-text: ${Bh[e].light.text}; --btn: ${Bh[e].light.accent}; --btn-ink: ${Bh[e].light.text}; --btn-hover: color-mix(in srgb, ${Bh[e].light.accent} 86%, #000000); }`).join(`
|
|
102
|
+
`)}
|
|
103
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
104
|
+
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
|
|
105
|
+
.social-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
|
106
|
+
.social-ico { flex: none; display: block; }
|
|
107
|
+
|
|
108
|
+
/* Architectural full-viewport loading screen */
|
|
109
|
+
@keyframes social-progress {
|
|
110
|
+
0% { transform: translateX(-100%); }
|
|
111
|
+
50% { transform: translateX(65%); }
|
|
112
|
+
100% { transform: translateX(260%); }
|
|
113
|
+
}
|
|
114
|
+
@keyframes social-shimmer {
|
|
115
|
+
0% { background-position: 100% 0; }
|
|
116
|
+
100% { background-position: -100% 0; }
|
|
117
|
+
}
|
|
118
|
+
.social-loader-stage { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); color: var(--text); }
|
|
119
|
+
.social-loader-box { width: 100%; max-width: 300px; display: grid; justify-items: center; gap: 14px; text-align: center; }
|
|
120
|
+
.social-loader-mark { width: 48px; height: 48px; border: 1px solid var(--line-strong); background: var(--panel); display: grid; place-items: center; color: var(--text); }
|
|
121
|
+
.social-loader-brand { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text); }
|
|
122
|
+
.social-loader-track { width: 180px; height: 2px; background: var(--line); position: relative; overflow: hidden; display: block; }
|
|
123
|
+
.social-loader-track-sm { width: 72px; }
|
|
124
|
+
.social-loader-bar { position: absolute; top: 0; left: 0; bottom: 0; width: 42%; background: var(--text); animation: social-progress 1.25s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
|
|
125
|
+
.social-loader-status { margin: 0; font-size: 0.8125rem; font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.04em; color: var(--muted); }
|
|
126
|
+
.social-inline-loader { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
|
|
127
|
+
|
|
128
|
+
/* Centered auth / onboarding card */
|
|
129
|
+
.social-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
|
|
130
|
+
.social-panel { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 0; padding: 28px 26px; }
|
|
131
|
+
.social-panel-mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--line-strong); background: var(--bg); margin-bottom: 16px; color: var(--text); }
|
|
132
|
+
.social-panel h1, .social-main h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; margin: 0 0 8px; }
|
|
133
|
+
.social-panel h2, .social-main h2 { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; margin: 18px 0 8px; }
|
|
134
|
+
.social-panel p, .social-main p { margin: 0 0 12px; }
|
|
135
|
+
.social-muted { color: var(--muted); font-size: 0.875rem; }
|
|
136
|
+
.social-error { color: var(--error); font-size: 0.875rem; margin: 8px 0 0; }
|
|
137
|
+
.social-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 0; padding: 12px 14px; margin: 12px 0; }
|
|
138
|
+
.social-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
|
|
139
|
+
|
|
140
|
+
/* Full-viewport multi-page architectural workspace */
|
|
141
|
+
.social-workspace { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg); color: var(--text); }
|
|
142
|
+
.social-sidebar { background: var(--panel); border-bottom: 1px solid var(--line); display: grid; gap: 0; align-content: start; }
|
|
143
|
+
.social-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
|
|
144
|
+
.social-brand { display: inline-flex; align-items: center; gap: 9px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
|
|
145
|
+
.social-sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0; }
|
|
146
|
+
.social-sidebar-user > div { min-width: 0; flex: 1 1 0; }
|
|
147
|
+
.social-brand-name { font-weight: 650; font-size: 0.9375rem; overflow-wrap: anywhere; display: block; line-height: 1.25; }
|
|
148
|
+
.social-sidebar-user .social-muted { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; display: block; margin-top: 2px; }
|
|
149
|
+
.social-nav { display: flex; flex-wrap: wrap; gap: 0; }
|
|
150
|
+
.social-nav-btn { appearance: none; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: inherit; font-size: 0.875rem; font-weight: 600; padding: 11px 14px; border-radius: 0; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease; }
|
|
151
|
+
.social-nav-btn:hover { background: var(--panel-2); color: var(--text); }
|
|
152
|
+
.social-nav-btn[aria-current="page"] { background: var(--panel-2); border-bottom-color: var(--text); color: var(--text); }
|
|
153
|
+
.social-nav-label { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
|
|
154
|
+
.social-nav-badge { font: 600 0.72rem/1.4 ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 0; background: var(--control); border: 1px solid var(--line-strong); color: var(--text); }
|
|
155
|
+
.social-nav-badge-accent { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
|
|
156
|
+
.social-main { padding: 20px 16px 36px; max-width: 900px; width: 100%; margin: 0 auto; display: grid; gap: 18px; align-content: start; }
|
|
157
|
+
.social-main-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
|
158
|
+
.social-main-head h1, .social-main-head h2 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.025em; }
|
|
159
|
+
.social-card-box { background: var(--panel); border: 1px solid var(--line); border-radius: 0; padding: 20px; display: grid; gap: 14px; align-content: start; }
|
|
160
|
+
.social-card-box h2:first-child { margin-top: 0; }
|
|
161
|
+
.social-subtabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
|
|
162
|
+
.social-subtab { appearance: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--muted); font: inherit; font-size: 0.875rem; font-weight: 600; padding: 9px 14px; border-radius: 0; cursor: pointer; transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease; }
|
|
163
|
+
.social-subtab:hover { color: var(--text); background: var(--panel-2); }
|
|
164
|
+
.social-subtab[aria-current="page"] { border-bottom-color: var(--text); color: var(--text); }
|
|
165
|
+
.social-overview-grid { display: grid; gap: 16px; align-items: start; }
|
|
166
|
+
.social-friends-grid { display: grid; gap: 16px; align-items: start; }
|
|
167
|
+
.social-stats-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--bg); }
|
|
168
|
+
.social-stat-cell { padding: 10px 12px; display: grid; gap: 2px; }
|
|
169
|
+
.social-stat-cell + .social-stat-cell { border-left: 1px solid var(--line); }
|
|
170
|
+
.social-stat-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
|
|
171
|
+
.social-stat-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
|
|
172
|
+
|
|
173
|
+
@media (min-width: 840px) {
|
|
174
|
+
.social-workspace { grid-template-columns: 248px minmax(0, 1fr); }
|
|
175
|
+
.social-sidebar { border-bottom: 0; border-right: 1px solid var(--line); position: sticky; top: 0; min-height: 100vh; }
|
|
176
|
+
.social-nav { flex-direction: column; padding: 8px 0; }
|
|
177
|
+
.social-nav-btn { width: 100%; border-bottom: 0; border-left: 2px solid transparent; padding: 10px 16px; }
|
|
178
|
+
.social-nav-btn[aria-current="page"] { border-bottom-color: transparent; border-left-color: var(--text); }
|
|
179
|
+
.social-main { padding: 28px 34px 48px; }
|
|
180
|
+
.social-overview-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
|
|
181
|
+
.social-friends-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Shared controls, sharp architectural buttons, and form primitives */
|
|
185
|
+
.social-card { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 8px; container-type: inline-size; }
|
|
186
|
+
.social-card > div { flex: 1 1 0; min-width: 0; max-width: 100%; overflow-wrap: break-word; }
|
|
187
|
+
.social-name { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
|
|
188
|
+
.social-panel h1.social-name, .social-page h1.social-name { font-size: 1.75rem; margin: 0; }
|
|
189
|
+
.social-identicon { width: 72px; height: 72px; border-radius: 0; border: 1px solid var(--line); flex: none; display: block; }
|
|
190
|
+
.social-avatar-img { object-fit: cover; background: var(--panel-2); }
|
|
191
|
+
.social-panel input, .social-panel textarea, .social-workspace input, .social-workspace textarea, .social-page input, .social-page textarea {
|
|
192
|
+
width: 100%; font: inherit; padding: 9px 11px; border-radius: 0; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); transition: border-color 120ms ease;
|
|
193
|
+
}
|
|
194
|
+
.social-panel textarea, .social-workspace textarea, .social-page textarea { resize: vertical; }
|
|
195
|
+
.social-panel input:focus-visible, .social-panel textarea:focus-visible, .social-workspace input:focus-visible, .social-workspace textarea:focus-visible, .social-page input:focus-visible, .social-page textarea:focus-visible,
|
|
196
|
+
.social-panel button:focus-visible, .social-workspace button:focus-visible, .social-page button:focus-visible, .social-page a:focus-visible {
|
|
197
|
+
outline: 2px solid var(--btn); outline-offset: 2px;
|
|
198
|
+
}
|
|
199
|
+
.social-page button:focus-visible, .social-page a:focus-visible, .social-page input:focus-visible, .social-page textarea:focus-visible {
|
|
200
|
+
outline-color: var(--accent);
|
|
201
|
+
}
|
|
202
|
+
.social-stack { display: grid; gap: 10px; }
|
|
203
|
+
.social-label { display: grid; gap: 6px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
|
|
204
|
+
.social-label input, .social-label textarea { font-size: 0.9375rem; font-weight: 400; letter-spacing: normal; text-transform: none; }
|
|
205
|
+
.social-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
|
206
|
+
.social-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
207
|
+
.social-link { border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: var(--bg); display: grid; gap: 6px; }
|
|
208
|
+
.social-link-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
|
|
209
|
+
.social-link-text { font: 500 0.85rem/1.4 ui-monospace, 'SF Mono', Menlo, monospace; overflow-wrap: anywhere; color: var(--text); }
|
|
210
|
+
.social-link-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
|
|
211
|
+
.social-invite { border: 1px solid var(--line-strong); border-radius: 0; padding: 16px; margin: 8px 0; display: grid; gap: 10px; background: var(--bg); }
|
|
212
|
+
.social-invite h2 { margin-top: 0; }
|
|
213
|
+
.social-qr { width: 180px; height: 180px; border-radius: 0; border: 1px solid var(--line); display: block; }
|
|
214
|
+
.social-warn-text { color: var(--text); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 0; padding: 8px 12px; font-size: 0.875rem; }
|
|
215
|
+
|
|
216
|
+
/* Uniform button hierarchy without selector specificity inflation */
|
|
217
|
+
.social-panel button:not(.social-person):not(.social-primary):not([aria-pressed="true"]):not(.social-danger),
|
|
218
|
+
.social-workspace button:not(.social-nav-btn):not(.social-subtab):not(.social-person):not(.social-primary):not([aria-pressed="true"]):not(.social-danger),
|
|
219
|
+
.social-page button:not(.social-primary):not([aria-pressed="true"]):not(.social-danger) {
|
|
220
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
221
|
+
font: inherit; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em;
|
|
222
|
+
min-height: 36px; padding: 7px 14px; border-radius: 0;
|
|
223
|
+
border: 1px solid var(--line-strong); background: var(--control); color: var(--text);
|
|
224
|
+
cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
|
|
225
|
+
}
|
|
226
|
+
.social-panel button:not(.social-person):not(.social-primary):not([aria-pressed="true"]):not(.social-danger):hover:not([aria-disabled="true"]),
|
|
227
|
+
.social-workspace button:not(.social-nav-btn):not(.social-subtab):not(.social-person):not(.social-primary):not([aria-pressed="true"]):not(.social-danger):hover:not([aria-disabled="true"]),
|
|
228
|
+
.social-page button:not(.social-primary):not([aria-pressed="true"]):not(.social-danger):hover:not([aria-disabled="true"]) {
|
|
229
|
+
background: var(--control-hover); border-color: var(--muted);
|
|
230
|
+
}
|
|
231
|
+
.social-panel button.social-person, .social-workspace button.social-person {
|
|
232
|
+
width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
|
|
233
|
+
padding: 10px 12px; border-radius: 0; border: 1px solid var(--line);
|
|
234
|
+
background: var(--bg); color: var(--text); font: inherit; font-weight: 400; cursor: pointer;
|
|
235
|
+
overflow-wrap: anywhere; transition: background-color 120ms ease, border-color 120ms ease;
|
|
236
|
+
}
|
|
237
|
+
.social-panel button.social-person:hover, .social-workspace button.social-person:hover {
|
|
238
|
+
background: var(--panel-2); border-color: var(--line-strong);
|
|
239
|
+
}
|
|
240
|
+
.social-person-name { font-weight: 650; overflow-wrap: anywhere; }
|
|
241
|
+
.social-identicon-small { width: 36px; height: 36px; border-radius: 0; }
|
|
242
|
+
.social-panel button.social-primary, .social-panel button[aria-pressed="true"],
|
|
243
|
+
.social-workspace button.social-primary, .social-workspace button[aria-pressed="true"],
|
|
244
|
+
.social-page button.social-primary, .social-page button[aria-pressed="true"] {
|
|
245
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
246
|
+
font: inherit; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em;
|
|
247
|
+
min-height: 36px; padding: 7px 15px; border-radius: 0; cursor: pointer;
|
|
248
|
+
background: var(--btn); border: 1px solid var(--btn); color: var(--btn-ink);
|
|
249
|
+
transition: background-color 120ms ease, border-color 120ms ease;
|
|
250
|
+
}
|
|
251
|
+
.social-panel button.social-primary:hover:not([aria-disabled="true"]), .social-panel button[aria-pressed="true"]:hover:not([aria-disabled="true"]),
|
|
252
|
+
.social-workspace button.social-primary:hover:not([aria-disabled="true"]), .social-workspace button[aria-pressed="true"]:hover:not([aria-disabled="true"]),
|
|
253
|
+
.social-page button.social-primary:hover:not([aria-disabled="true"]), .social-page button[aria-pressed="true"]:hover:not([aria-disabled="true"]) {
|
|
254
|
+
background: var(--btn-hover); border-color: var(--btn-hover);
|
|
255
|
+
}
|
|
256
|
+
.social-panel button.social-danger, .social-workspace button.social-danger, .social-page button.social-danger {
|
|
257
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
258
|
+
font: inherit; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em;
|
|
259
|
+
min-height: 36px; padding: 7px 14px; border-radius: 0; cursor: pointer;
|
|
260
|
+
background: transparent; border: 1px solid var(--error); color: var(--error);
|
|
261
|
+
}
|
|
262
|
+
.social-panel button.social-danger:hover:not([aria-disabled="true"]),
|
|
263
|
+
.social-workspace button.social-danger:hover:not([aria-disabled="true"]),
|
|
264
|
+
.social-page button.social-danger:hover:not([aria-disabled="true"]) {
|
|
265
|
+
background: color-mix(in srgb, var(--error) 12%, transparent);
|
|
266
|
+
}
|
|
267
|
+
.social-panel [aria-disabled="true"], .social-workspace [aria-disabled="true"], .social-page [aria-disabled="true"] { opacity: 0.45; cursor: default; }
|
|
268
|
+
.social-panel a.social-action, .social-page a.social-action {
|
|
269
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 7px;
|
|
270
|
+
font: inherit; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.02em;
|
|
271
|
+
min-height: 36px; padding: 7px 16px; border-radius: 0; text-decoration: none;
|
|
272
|
+
background: var(--btn); border: 1px solid var(--btn); color: var(--btn-ink);
|
|
273
|
+
}
|
|
274
|
+
.social-panel a.social-action:hover, .social-page a.social-action:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
|
|
275
|
+
.social-key { display: block; font: 0.9rem/1.6 ui-monospace, 'SF Mono', Menlo, monospace; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 0; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
|
|
276
|
+
.social-panel input[type="file"], .social-workspace input[type="file"] { padding: 6px; font-size: 0.85rem; }
|
|
277
|
+
.social-panel input[type="file"]::file-selector-button, .social-workspace input[type="file"]::file-selector-button {
|
|
278
|
+
font: inherit; font-size: 0.8rem; font-weight: 600; padding: 5px 12px; margin-right: 10px;
|
|
279
|
+
border-radius: 0; border: 1px solid var(--line-strong); background: var(--control); color: var(--text); cursor: pointer;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* Sharp tiles, segmented radio controls, checkboxes, and reorderable sections */
|
|
283
|
+
.social-swatch-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 8px; }
|
|
284
|
+
.social-swatch { width: 18px; height: 18px; border-radius: 0; background: var(--accent); border: 1px solid var(--line-strong); flex: none; }
|
|
285
|
+
.social-choice { display: flex; gap: 9px; align-items: center; font-size: 0.875rem; cursor: pointer; }
|
|
286
|
+
.social-panel .social-choice input, .social-workspace .social-choice input { width: auto; flex: none; }
|
|
287
|
+
.social-choice-label { font-weight: 600; }
|
|
288
|
+
.social-tile { position: relative; padding: 9px 11px; border: 1px solid var(--line); background: var(--bg); transition: border-color 120ms ease, background-color 120ms ease; }
|
|
289
|
+
.social-tile:hover { border-color: var(--line-strong); background: var(--panel-2); }
|
|
290
|
+
.social-tile input { appearance: none; border-radius: 0; position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
|
|
291
|
+
.social-tile:has(input:checked) { border-color: var(--text); background: var(--control); box-shadow: inset 0 -2px 0 var(--text); }
|
|
292
|
+
.social-tile:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; position: relative; z-index: 1; }
|
|
293
|
+
.social-seg { display: inline-flex; flex-wrap: nowrap; border: 1px solid var(--line-strong); background: var(--bg); width: fit-content; max-width: 100%; }
|
|
294
|
+
.social-seg .social-choice { position: relative; gap: 0; padding: 6px 13px; border-right: 1px solid var(--line); font-size: 0.8125rem; color: var(--muted); transition: background-color 120ms ease, color 120ms ease; }
|
|
295
|
+
.social-seg .social-choice:last-child { border-right: 0; }
|
|
296
|
+
.social-seg .social-choice:hover { background: var(--panel-2); color: var(--text); }
|
|
297
|
+
.social-seg input { appearance: none; border-radius: 0; position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
|
|
298
|
+
.social-seg .social-choice:has(input:checked) { background: var(--btn); color: var(--btn-ink); }
|
|
299
|
+
.social-seg .social-choice:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; position: relative; z-index: 1; }
|
|
300
|
+
.social-checks { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
301
|
+
.social-checks .social-choice { border: 1px solid var(--line); background: var(--bg); padding: 6px 11px; }
|
|
302
|
+
.social-checks .social-choice:has(input:checked) { border-color: var(--text); background: var(--control); }
|
|
303
|
+
.social-checks .social-choice input { appearance: none; position: relative; flex: none; width: 14px; height: 14px; padding: 0; margin: 0; border-radius: 0; border: 1px solid var(--line-ctrl); background: var(--panel); cursor: pointer; }
|
|
304
|
+
.social-checks .social-choice input:checked { background: var(--btn); border-color: var(--btn); }
|
|
305
|
+
.social-checks .social-choice input:checked::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--btn-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
|
|
306
|
+
.social-section { border: 1px solid var(--line); border-radius: 0; padding: 12px 14px; background: var(--bg); display: grid; gap: 10px; }
|
|
307
|
+
.social-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
|
|
308
|
+
.social-section-moves { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
309
|
+
.social-section .social-row { margin-top: 6px; }
|
|
310
|
+
.social-panel-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
|
311
|
+
.social-panel-bar p { flex: 1 1 240px; margin: 0; }
|
|
312
|
+
.social-panel-count { font: 600 0.78rem/1.4 ui-monospace, 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; padding: 2px 8px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); flex: none; }
|
|
313
|
+
.social-panel-head-title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
|
|
314
|
+
.social-panel-tag { font: 700 0.7rem/1.3 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted); flex: none; }
|
|
315
|
+
.social-md-preview { border: 1px solid var(--line); background: var(--panel); padding: 12px 14px; min-height: 76px; }
|
|
316
|
+
.social-art-list { display: grid; gap: 8px; }
|
|
317
|
+
.social-art-row { border: 1px solid var(--line); background: var(--panel); padding: 10px 12px; display: grid; gap: 8px; }
|
|
318
|
+
.social-art-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
319
|
+
|
|
320
|
+
/* only measured: fkn.app's broker draws the package frame over this rect, in its own frame */
|
|
321
|
+
.social-frame { position: fixed; inset: 0; pointer-events: none; }
|
|
322
|
+
|
|
323
|
+
/* Steam-inspired architectural /<name> profile layout */
|
|
324
|
+
.social-page { position: relative; min-height: 100vh; background: radial-gradient(ellipse 90% 420px at 50% 0%, var(--p-sky-top, var(--bg)), transparent 72%), linear-gradient(180deg, var(--p-sky-top, var(--bg)) 0%, var(--p-sky-bot, var(--bg)) 320px, var(--p-bg, var(--bg)) 100%); color: var(--p-text, var(--text)); display: grid; grid-template-rows: auto 1fr; }
|
|
325
|
+
.social-topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 20px; background: color-mix(in srgb, var(--p-bg, var(--bg)) 88%, var(--p-head, var(--panel))); border-bottom: 1px solid var(--p-border, var(--line)); }
|
|
326
|
+
.social-topbar-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--p-text, var(--text)); text-decoration: none; font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; }
|
|
327
|
+
.social-backdrop { position: relative; z-index: 1; padding: 26px 16px 48px; }
|
|
328
|
+
.social-page-background { position: fixed; inset: 0; z-index: 0; background-size: cover; background-position: center; opacity: 0.36; pointer-events: none; -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%); mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%); }
|
|
329
|
+
.social-profile-sheet { position: relative; z-index: 1; width: 100%; max-width: 980px; margin: 0 auto; background: color-mix(in srgb, var(--p-sheet, var(--panel)) 94%, transparent); border: 1px solid var(--p-border, var(--line)); border-radius: 0; padding: 24px; display: grid; gap: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42); }
|
|
330
|
+
[data-social-theme="daylight"] .social-profile-sheet { box-shadow: 0 12px 32px rgba(15, 20, 30, 0.10); }
|
|
331
|
+
.social-hero { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 18px; margin: -24px -24px 0; padding: 24px; background: linear-gradient(180deg, color-mix(in srgb, var(--p-head, var(--panel-2)) 52%, transparent) 0%, transparent 100%); border-bottom: 1px solid var(--p-border, var(--line)); }
|
|
332
|
+
.social-hero .social-card { flex: 1 1 320px; margin-bottom: 0; }
|
|
333
|
+
.social-hero-side { display: grid; gap: 10px; justify-items: start; }
|
|
334
|
+
.social-hero-counts { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--p-border, var(--line)); background: var(--p-panel, var(--panel)); font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--muted); }
|
|
335
|
+
.social-hero-counts > span { padding: 5px 10px; border-right: 1px solid var(--p-border, var(--line)); }
|
|
336
|
+
.social-hero-counts > span:last-child { border-right: 0; }
|
|
337
|
+
.social-hero-counts strong { color: var(--text); }
|
|
338
|
+
.social-avatar { width: 84px; height: 84px; border-radius: 0; border: 2px solid var(--accent); flex: none; object-fit: cover; background: var(--p-head, var(--panel-2)); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35); display: block; }
|
|
339
|
+
.social-hero .social-identicon { width: 84px; height: 84px; border-radius: 0; border: 2px solid var(--accent); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35); }
|
|
340
|
+
[data-social-private], [data-social-friends-only] { display: inline-block; margin-top: 6px; padding: 2px 7px; border: 1px solid var(--p-border, var(--line)); background: var(--p-panel, var(--panel)); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
|
|
341
|
+
.social-preview { width: 100%; max-height: 220px; border-radius: 0; border: 1px solid var(--p-border, var(--line)); object-fit: cover; display: block; }
|
|
342
|
+
.social-page-link { color: var(--accent); overflow-wrap: anywhere; text-decoration: none; }
|
|
343
|
+
.social-page-link:hover { text-decoration: underline; }
|
|
344
|
+
.social-steam-body { display: grid; gap: 18px; align-items: start; }
|
|
345
|
+
.social-page-main { display: grid; gap: 16px; min-width: 0; }
|
|
346
|
+
.social-page-rail { display: grid; gap: 16px; min-width: 0; }
|
|
347
|
+
.social-showcase { background: var(--p-panel, var(--panel)); border: 1px solid var(--p-border, var(--line)); border-radius: 0; }
|
|
348
|
+
.social-showcase-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; background: linear-gradient(90deg, var(--p-head, var(--panel-2)) 0%, color-mix(in srgb, var(--p-head, var(--panel-2)) 25%, var(--p-panel, var(--panel))) 100%); border-bottom: 1px solid var(--p-border, var(--line)); }
|
|
349
|
+
.social-showcase-head h2 { margin: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--p-text, var(--text)); }
|
|
350
|
+
.social-panel-badge { font: 700 0.68rem/1.3 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; border: 1px solid var(--p-border, var(--line)); background: var(--p-panel, var(--panel)); color: var(--p-muted, var(--muted)); flex: none; }
|
|
351
|
+
.social-showcase-body { padding: 14px; display: grid; gap: 10px; }
|
|
352
|
+
.social-showcase-body p { margin: 0; }
|
|
353
|
+
.social-md { display: grid; gap: 10px; overflow-wrap: anywhere; }
|
|
354
|
+
.social-md h3, .social-md h4, .social-md h5 { margin: 2px 0 0; line-height: 1.3; font-weight: 700; color: var(--p-text, var(--text)); }
|
|
355
|
+
.social-md h3 { font-size: 1.05rem; }
|
|
356
|
+
.social-md h4 { font-size: 0.95rem; }
|
|
357
|
+
.social-md h5 { font-size: 0.875rem; color: var(--p-muted, var(--muted)); }
|
|
358
|
+
.social-md ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
|
|
359
|
+
.social-md code { font: 0.85em/1.4 ui-monospace, 'SF Mono', Menlo, monospace; padding: 1px 5px; border: 1px solid var(--p-border, var(--line)); background: var(--p-bg, var(--bg)); }
|
|
360
|
+
.social-artwork-grid { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
|
|
361
|
+
.social-artwork-tile { margin: 0; border: 1px solid var(--p-border, var(--line)); background: var(--p-bg, var(--bg)); display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
|
|
362
|
+
.social-artwork-tile img { width: 100%; display: block; object-fit: cover; max-height: 440px; }
|
|
363
|
+
.social-artwork-grid[data-social-artwork-count="1"] .social-artwork-tile img { object-fit: contain; height: auto; }
|
|
364
|
+
.social-artwork-grid[data-social-artwork-count="2"] .social-artwork-tile img,
|
|
365
|
+
.social-artwork-grid[data-social-artwork-count="4"] .social-artwork-tile img { aspect-ratio: 4 / 3; height: 100%; }
|
|
366
|
+
.social-artwork-skel { width: 100%; aspect-ratio: 4 / 3; min-height: 140px; }
|
|
367
|
+
.social-artwork-missing { padding: 28px 12px; text-align: center; font-size: 0.8125rem; color: var(--p-muted, var(--muted)); }
|
|
368
|
+
.social-artwork-caption { padding: 7px 10px; font-size: 0.8125rem; color: var(--p-muted, var(--muted)); border-top: 1px solid var(--p-border, var(--line)); background: var(--p-panel, var(--panel)); overflow-wrap: anywhere; }
|
|
369
|
+
@media (min-width: 560px) {
|
|
370
|
+
.social-artwork-grid[data-social-artwork-count="2"],
|
|
371
|
+
.social-artwork-grid[data-social-artwork-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
372
|
+
.social-artwork-grid[data-social-artwork-count="3"] { grid-template-columns: 1.55fr 1fr; }
|
|
373
|
+
.social-artwork-grid[data-social-artwork-count="3"] .social-artwork-tile:first-child { grid-row: span 2; }
|
|
374
|
+
.social-artwork-grid[data-social-artwork-count="3"] .social-artwork-tile:first-child img { height: 100%; min-height: 220px; }
|
|
375
|
+
.social-artwork-grid[data-social-artwork-count="3"] .social-artwork-tile:not(:first-child) img { aspect-ratio: 4 / 3; height: 100%; }
|
|
376
|
+
}
|
|
377
|
+
.social-rail-links { list-style: none; margin: -14px; padding: 0; display: grid; gap: 0; }
|
|
378
|
+
.social-rail-links li + li { border-top: 1px solid var(--p-border, var(--line)); }
|
|
379
|
+
.social-rail-links a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: transparent; font-size: 0.85rem; transition: background-color 120ms ease; }
|
|
380
|
+
.social-rail-links a:hover { background: var(--p-sheet, var(--panel)); text-decoration: underline; }
|
|
381
|
+
.social-rail-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; position: relative; z-index: 1; }
|
|
382
|
+
.social-rail-url { min-width: 0; overflow-wrap: anywhere; }
|
|
383
|
+
|
|
384
|
+
@media (min-width: 840px) {
|
|
385
|
+
.social-avatar, .social-hero .social-identicon { width: 120px; height: 120px; }
|
|
386
|
+
.social-hero-side { justify-items: end; text-align: right; }
|
|
387
|
+
.social-steam-body.social-steam-split { grid-template-columns: minmax(0, 1fr) 264px; }
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.social-entries { gap: 12px; }
|
|
391
|
+
.social-entries li + li { padding-top: 12px; border-top: 1px solid var(--p-border, var(--line)); }
|
|
392
|
+
.social-entry { display: flex; gap: 12px; align-items: flex-start; }
|
|
393
|
+
.social-entry-art { width: 48px; height: 48px; border-radius: 0; border: 1px solid var(--p-border, var(--line)); object-fit: cover; flex: none; display: block; }
|
|
394
|
+
.social-entry-text { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
|
|
395
|
+
.social-entry-text .social-row { margin-top: 6px; }
|
|
396
|
+
.social-favourites { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
|
|
397
|
+
.social-favourite { display: grid; gap: 6px; align-content: start; overflow-wrap: anywhere; font-size: 0.875rem; }
|
|
398
|
+
.social-favourite img { width: 100%; aspect-ratio: 3 / 4; border-radius: 0; object-fit: cover; border: 1px solid var(--p-border, var(--line)); display: block; transition: border-color 120ms ease; }
|
|
399
|
+
.social-favourite a:hover, .social-favourite:hover img { border-color: var(--accent); }
|
|
400
|
+
|
|
401
|
+
/* Profile loading skeleton and avatar placeholder */
|
|
402
|
+
.social-skel, [data-social-avatar-reading] {
|
|
403
|
+
display: block;
|
|
404
|
+
background: linear-gradient(90deg, var(--p-head, var(--panel-2)) 25%, color-mix(in srgb, var(--p-border, var(--line)) 70%, var(--p-head, var(--panel-2))) 50%, var(--p-head, var(--panel-2)) 75%);
|
|
405
|
+
background-size: 200% 100%;
|
|
406
|
+
animation: social-shimmer 1.4s ease-in-out infinite;
|
|
407
|
+
}
|
|
408
|
+
.social-skeleton-hero .social-card { align-items: center; }
|
|
409
|
+
.social-skeleton-lines { display: grid; gap: 10px; min-width: 160px; }
|
|
410
|
+
.social-skel-avatar { width: 84px; height: 84px; border: 1px solid var(--p-border, var(--line)); flex: none; }
|
|
411
|
+
.social-skel-title { width: 180px; height: 22px; }
|
|
412
|
+
.social-skel-sub { width: 110px; height: 14px; }
|
|
413
|
+
.social-skel-btn { width: 126px; height: 34px; }
|
|
414
|
+
.social-skel-meta { width: 156px; height: 14px; }
|
|
415
|
+
.social-skel-head { width: 92px; height: 11px; }
|
|
416
|
+
.social-skel-line { width: 100%; height: 14px; }
|
|
417
|
+
.social-skel-short { width: 68%; }
|
|
418
|
+
.social-skel-row { width: 100%; height: 28px; }
|
|
419
|
+
.social-skeleton-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
|
|
420
|
+
.social-skel-tile { width: 100%; aspect-ratio: 3 / 4; }
|
|
421
|
+
@media (min-width: 840px) {
|
|
422
|
+
.social-skel-avatar { width: 120px; height: 120px; }
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@media (prefers-reduced-motion: reduce) {
|
|
426
|
+
*, *::before, *::after { animation: none !important; transition: none !important; }
|
|
427
|
+
.social-loader-bar { left: 29%; width: 42%; transform: none; }
|
|
428
|
+
}
|
|
429
|
+
`,uE=()=>{let e=document.createElement(`style`);e.textContent=lE,document.head.append(e)},dE={ok:!1,reason:`none`},fE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),pE=e=>{if(typeof e!=`object`||!e)return!1;let{roomId:t,owner:n,text:r}=e;return typeof t==`string`&&typeof n==`string`&&typeof r==`string`},mE=e=>pE(e)&&typeof e.name==`string`&&(e.core===void 0||pE(e.core)),hE=e=>e===null?dE:{ok:!0,...e},gE=e=>{let t=Yy(e.text,e.roomId,e.owner,e.name);if(t!==null)return t;if(e.core===void 0)return null;let n=Yy(e.core.text,e.core.roomId,e.core.owner,e.name);if(n?.pageRoom===void 0||q_(n.pageRoom)!==e.roomId)return null;let r=eb(e.text,e.roomId,e.owner);return r!==null&&fE(r.signKey,n.signKey)?r:null},_E=async(e,t,n)=>{let r=gE(n);if(r?.friends==null)return dE;let i=await t();if(i.kind!==`ready`)return dE;let a=zh(i.identity.seed),o={roomId:n.roomId,owner:n.owner};if(fE(r.signKey,a.signKey))return hE(Fy(a,o,r.friends));let s=await qf(e),c=s.ok?s.roster.friends[tf(r.signKey)]?.value:void 0,l=c?.state===`active`?Y(c.dhKey):null;return l?.length===32?hE(Iy(a,l,o,r.friends)):dE},vE=e=>{let t=null,n=()=>t??=iS(e);return{own:async()=>{let e=await n();return e.kind===`ready`?zh(e.identity.seed).signKey:null},friends:t=>_E(e,n,t)}},yE=100,bE=e=>Array.isArray(e)&&e.length>0&&e.length<=yE&&e.every(e=>typeof e==`string`)?e:null,xE=[`not-friend`,`invalid`,`closed`,`full`],SE=e=>xE.includes(e),CE=e=>{let t=async()=>{let t=await iS(e);return t.kind===`ready`?t.identity.name===null?`none`:{keys:zh(t.identity.seed),name:t.identity.name}:`unavailable`},n=async e=>{let n=await t();return typeof n==`string`||n.name===e?n:`none`};return{deleteEntries:async t=>{let{name:r,ids:i}=t??{},a=bE(i);if(a===null)return{ok:!1,reason:`none`};let o=await n(r);return typeof o==`string`?{ok:!1,reason:o}:await zx(e,o,e=>Pu(e,a))===`written`?{ok:!0}:{ok:!1,reason:`unavailable`}},deleteComments:async t=>{let{name:r,ids:i}=t??{},a=bE(i);if(a===null)return{ok:!1,reason:`none`};let o=await n(r);return typeof o==`string`?{ok:!1,reason:o}:await zx(e,o,e=>z_(e,a))===`written`?{ok:!0}:{ok:!1,reason:`unavailable`}},sendComment:async n=>{let{name:r,text:i}=n??{};if(typeof r!=`string`||!ef(r))return{ok:!1,reason:`not-friend`};let a=await t();if(typeof a==`string`)return{ok:!1,reason:a};let o=await px(e,a,r,i);return o.ok?o:{ok:!1,reason:SE(o.reason)?o.reason:`unavailable`}},setFavourite:async t=>{let{name:r,favourite:i,on:a}=t??{};if(typeof a!=`boolean`)return{ok:!1,reason:`none`};let o=await n(r);if(typeof o==`string`)return{ok:!1,reason:o};let s=await W_(e,i,a);return s.ok?await zx(e,o,e=>e)===`written`?{ok:!0}:{ok:!1,reason:`unavailable`}:{ok:!1,reason:s.reason===`full`?`full`:s.reason===`invalid`?`none`:`unavailable`}}}},wE=e=>e.brokered===!0&&e.from===du,TE=e=>e.brokered===!0&&wu(e.from)?e.from:null,EE={state:`not-here`},DE=async(e,t,n)=>{let r=TE(e);return r===null?t:n(r)},OE=e=>wE(e)?e.remote:null,kE=(e,t,n={protocol:2,min:1})=>({hello:async()=>n,openInvite:async n=>{if(!wE(e))return{ok:!1,reason:`not-here`};let r=typeof n==`string`?IS(n):null;return t.onInvite(r),r===null?{ok:!1,reason:`malformed`}:{ok:!0}},openAdd:async n=>{if(!wE(e))return{ok:!1,reason:`not-here`};let r=typeof n==`string`?$d(n):null,i=r?.ok===!0?r.name:null;return t.onAdd(i),i===null?{ok:!1,reason:`malformed`}:{ok:!0}},openEdit:async()=>wE(e)?(t.onEdit(),{ok:!0}):{ok:!1,reason:`not-here`},ownKey:async()=>wE(e)?t.own():null,openFriends:async n=>wE(e)?mE(n)?t.friends(n):{ok:!1,reason:`none`}:{ok:!1,reason:`not-here`},deleteEntries:async n=>wE(e)?t.page.deleteEntries(n):{ok:!1,reason:`not-here`},setFavourite:async n=>wE(e)?t.page.setFavourite(n):{ok:!1,reason:`not-here`},deleteComments:async n=>wE(e)?t.page.deleteComments(n):{ok:!1,reason:`not-here`},sendComment:async n=>wE(e)?t.page.sendComment(n):{ok:!1,reason:`not-here`},publishing:()=>DE(e,EE,e=>t.apps.publishing(e)),allowPublishing:n=>DE(e,EE,e=>t.apps.allow(e,n)),publish:n=>DE(e,{ok:!1,reason:`not-here`},e=>t.apps.publish(e,n)),stopPublishing:()=>DE(e,EE,e=>t.apps.stop(e))}),AE=`social.writer`,jE=e=>{try{let t=e(),n=t.getItem(AE);if(n!==null&&/^[A-Za-z0-9_-]{22}$/.test(n))return n;let r=J(crypto.getRandomValues(new Uint8Array(16)));return t.setItem(AE,r),t.getItem(`social.writer`)===r?r:null}catch{return null}},ME=`social.roster`,NE=Promise.resolve(),PE=e=>{let t=globalThis.navigator?.locks;if(t)return t.request(ME,e);let n=NE.then(e,e);return NE=n.catch(()=>{}),n},FE=()=>{let e=[],t=new Set;return{hand:n=>{t.size===0&&e.push(n);for(let e of t)e(n)},take:n=>{t.add(n);for(let t of e.splice(0))n(t);return()=>{t.delete(n)}}}},IE=FE(),LE=FE(),RE=FE(),zE=null;(()=>{let e={account:{availability:us,encryption:vs},cloud:vf({list:As,readFileSealed:js,writeFile:(e,t)=>ks.writeFile(e,new TextEncoder().encode(t)),unlink:e=>ks.unlink(e),isNotFound:Ho}),rooms:{open:hc,create:gc,join:_c},storage:{put:e=>Ac(e),get:(e,t)=>Mc(e,t),delete:Pc,list:()=>Nc()},sleep:e=>new Promise(t=>setTimeout(t,e)),writerId:jE(()=>localStorage),exclusive:PE},t=_S(e),n=CE(e);Js(r=>kE(r,{onInvite:IE.hand,onAdd:LE.hand,onEdit:()=>RE.hand(!0),...vE(e),apps:t,page:n}),e=>{zE=OE(e)??zE}),uE();let r=!1;Ys(t=>{t&&!r&&(r=!0,lu(document.body.appendChild(document.createElement(`div`))).render($(aE,{services:e,unlock:ys,onAccountChange:uo,invites:IE.take,adds:LE.take,edits:RE.take,site:()=>zE})))})})();
|