From 2c292d11b8b81e13648fc542510b7e323cb2825d Mon Sep 17 00:00:00 2001 From: Yoshiofthewire Date: Wed, 25 Nov 2026 18:04:24 -0500 Subject: [PATCH] feat(web): ask the browser to keep the storage that holds the key Once the vault keeps this browser's encryption key, KyNotes asks for persistent storage, so the browser does not clear the key on its own to free space or after days without a visit. Firefox asks the user; Chromium and Safari decide silently. A refusal changes nothing. Co-Authored-By: Claude Opus 5.5 --- ...age-f0oQsOxU.js => CanvasPage-CCePUo_W.js} | 4 +- ...ata-DkoSvmMO.js => emoji-data--iPt3NLx.js} | 2 +- ...BOlYJYx0.js => exportNotebook-BDS11KSz.js} | 2 +- internal/web/dist/assets/index-BqKtmCPh.js | 38 ------------------- internal/web/dist/assets/index-DcxPhBy8.js | 38 +++++++++++++++++++ internal/web/dist/index.html | 2 +- web/e2e/persistent-storage.e2e.ts | 32 ++++++++++++++++ web/src/persist.test.ts | 30 +++++++++++++++ web/src/persist.ts | 15 ++++++++ web/src/storage.ts | 5 ++- 10 files changed, 124 insertions(+), 44 deletions(-) rename internal/web/dist/assets/{CanvasPage-f0oQsOxU.js => CanvasPage-CCePUo_W.js} (99%) rename internal/web/dist/assets/{emoji-data-DkoSvmMO.js => emoji-data--iPt3NLx.js} (99%) rename internal/web/dist/assets/{exportNotebook-BOlYJYx0.js => exportNotebook-BDS11KSz.js} (98%) delete mode 100644 internal/web/dist/assets/index-BqKtmCPh.js create mode 100644 internal/web/dist/assets/index-DcxPhBy8.js create mode 100644 web/e2e/persistent-storage.e2e.ts create mode 100644 web/src/persist.test.ts create mode 100644 web/src/persist.ts diff --git a/internal/web/dist/assets/CanvasPage-f0oQsOxU.js b/internal/web/dist/assets/CanvasPage-CCePUo_W.js similarity index 99% rename from internal/web/dist/assets/CanvasPage-f0oQsOxU.js rename to internal/web/dist/assets/CanvasPage-CCePUo_W.js index 0c04ab55..7314a533 100644 --- a/internal/web/dist/assets/CanvasPage-f0oQsOxU.js +++ b/internal/web/dist/assets/CanvasPage-CCePUo_W.js @@ -1,3 +1,3 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/emoji-data-DkoSvmMO.js","assets/index-BqKtmCPh.js","assets/rolldown-runtime-COiEfhsA.js","assets/index-DXs7t0vx.css"])))=>i.map(i=>d[i]); -import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{_ as n,a as r,f as i,g as a,h as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m,v as h}from"./index-BqKtmCPh.js";import{$ as g,A as _,B as v,D as y,H as b,I as x,J as S,K as C,L as w,M as T,N as E,O as D,P as O,R as k,U as A,V as j,W as M,X as N,Y as P,_ as ee,a as te,at as ne,b as re,c as F,ct as ie,d as ae,dt as oe,ft as se,i as I,it as ce,j as le,k as ue,l as de,lt as fe,n as L,nt as pe,o as me,ot as he,p as ge,pt as _e,q as ve,r as ye,s as be,st as xe,u as Se,ut as Ce,v as we,w as Te,y as Ee}from"./blocknote-BePxcw92.js";var De=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Oe=t(((e,t)=>{t.exports=De()})),ke=t((e=>{var t=n(),r=Oe();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ae=t(((e,t)=>{t.exports=ke()})),je=t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o===`_owner`&&t.$$typeof)&&!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),R=e(n(),1),Me=Ae(),Ne=e(s(),1),Pe=e(je(),1),z=a(),Fe=(0,R.createContext)(void 0);function Ie(e){return(0,R.useContext)(Fe)}function B(e){let t=Ie(e);if(!t?.editor)throw Error(`useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component`);return t.editor}function Le(e,t=e=>e,n=Re){return(0,Me.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,n)}function Re(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=ze(e);return n.length===ze(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))}function ze(e){return[...Object.keys(e),...Object.getOwnPropertySymbols(e)]}var Be=typeof window<`u`?R.useLayoutEffect:R.useEffect,Ve=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(e){this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e,t){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},n=this.editor._tiptapEditor,r={all:[`transaction`,`create`,`mount`,`unmount`],mount:[`create`,`mount`,`unmount`],selection:[`selectionUpdate`],change:[`update`]};for(let i of r[t])n.on(i,e);return()=>{for(let i of r[t])n.off(i,e)}}}};function He(e){let t=Ie(),n=e.editor||t?.editor||null,r=e.on||`all`,[i]=(0,R.useState)(()=>new Ve(n)),a=(0,Me.useSyncExternalStoreWithSelector)(i.subscribe,i.getSnapshot,i.getServerSnapshot,e.selector,e.equalityFn??Pe.default);return Be(()=>i.watch(n,r),[n,i,r]),(0,R.useDebugValue)(a),a}function Ue(e){let t=Ie();if(e||=t?.editor,!e)throw Error("'editor' is required in `useEditorDOMElement`, either from BlockNoteContext or as a function argument");return He({editor:e,selector:e=>e.editor.domElement,equalityFn:(e,t)=>e===t,on:`mount`})}var We=(0,R.createContext)(void 0);function Ge(){return(0,R.useContext)(We)}var Ke=typeof window<`u`?R.useInsertionEffect:R.useEffect,qe=(0,R.createContext)(null);function Je(){let e=(0,R.useContext)(qe),t=Ue();return e||(t?.parentElement??null)}function Ye(e){return(0,z.jsx)(qe.Provider,{value:null,children:e.children})}function Xe(e){let{target:t,children:n}=e,r=B(),i=Ge()?.applyThemedRoot,[a]=(0,R.useState)(()=>typeof document>`u`?null:document.createElement(`div`));return Ke(()=>{if(a&&t)return t.appendChild(a),()=>a.remove()},[a,t]),Ke(()=>{a&&t&&i?.(a)},[a,t,i]),Ke(()=>{if(a&&t)return r.registerPortalElement(a),()=>r.unregisterPortalElement(a)},[r,a,t]),t===void 0?n:(0,z.jsx)(qe.Provider,{value:a,children:n})}function Ze(e){return(0,z.jsx)(Xe,{target:e.target,children:(0,z.jsx)(Qe,{children:e.children})})}function Qe(e){let t=Je();return t?(0,Ne.createPortal)(e.children,t):null}function $e(){let[e]=(0,R.useState)(()=>{if(typeof document>`u`)return null;let e=document.createElement(`span`);return e.className=`bn-portal-anchor`,e}),t=(0,R.useCallback)(t=>{t&&e&&e.parentElement!==t&&t.appendChild(e)},[e]);return{anchor:e,holder:(0,z.jsx)(`span`,{ref:t,className:et,style:{position:`absolute`,width:0,height:0,overflow:`visible`}})}}var et=`bn-portal-anchor-holder`;function tt(e){return Array.from(e.childNodes).some(e=>!(e instanceof Element&&e.classList.contains(et)))}function nt(e){let{anchor:t,holder:n}=$e(),r=Je(),i=t??r,a=typeof e.children==`function`?e.children(i):e.children;return(0,z.jsxs)(z.Fragment,{children:[n,(0,z.jsx)(qe.Provider,{value:i,children:a})]})}var rt=(0,R.createContext)(void 0);function V(){return(0,R.useContext)(rt)}function H(){return Ie().editor.dictionary}var it={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},at=R.createContext&&R.createContext(it),ot=[`attr`,`size`,`title`];function st(e,t){if(e==null)return{};var n,r,i=ct(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;rR.createElement(e.tag,dt({key:t},e.attr),ht(e.child)))}function U(e){return t=>R.createElement(gt,lt({attr:dt({},e.attr)},t),ht(e.child))}function gt(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=st(e,ot),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),R.createElement(`svg`,lt({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:dt(dt({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&R.createElement(`title`,null,i),e.children)};return at===void 0?t(it):R.createElement(at.Consumer,null,e=>t(e))}function _t(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z`},child:[]}]})(e)}function vt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z`},child:[]}]})(e)}function yt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11V13H19V11H5Z`},child:[]}]})(e)}function bt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z`},child:[]}]})(e)}function xt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z`},child:[]}]})(e)}function St(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z`},child:[]}]})(e)}function Ct(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function wt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function Tt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z`},child:[]}]})(e)}function Et(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z`},child:[]}]})(e)}function Dt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z`},child:[]}]})(e)}function Ot(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z`},child:[]}]})(e)}function kt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z`},child:[]}]})(e)}function At(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z`},child:[]}]})(e)}function jt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z`},child:[]}]})(e)}function Mt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z`},child:[]}]})(e)}function Nt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z`},child:[]}]})(e)}function Pt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 6V21H11V6H5V4H19V6H13Z`},child:[]}]})(e)}function Ft(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z`},child:[]}]})(e)}function It(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z`},child:[]}]})(e)}function Lt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z`},child:[]}]})(e)}function Rt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z`},child:[]}]})(e)}function zt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z`},child:[]}]})(e)}function Bt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function Vt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function Ht(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z`},child:[]}]})(e)}function Ut(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z`},child:[]}]})(e)}function Wt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z`},child:[]}]})(e)}function Gt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z`},child:[]}]})(e)}function Kt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z`},child:[]}]})(e)}function qt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z`},child:[]}]})(e)}function Jt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z`},child:[]}]})(e)}function Yt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z`},child:[]}]})(e)}function Xt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function Zt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z`},child:[]}]})(e)}function Qt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function $t(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z`},child:[]}]})(e)}function en(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z`},child:[]}]})(e)}function tn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z`},child:[]}]})(e)}function nn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z`},child:[]}]})(e)}function rn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z`},child:[]}]})(e)}function an(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z`},child:[]}]})(e)}function on(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z`},child:[]}]})(e)}function sn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z`},child:[]}]})(e)}function cn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z`},child:[]}]})(e)}function ln(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z`},child:[]}]})(e)}function un(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z`},child:[]}]})(e)}function dn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z`},child:[]}]})(e)}function fn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z`},child:[]}]})(e)}function pn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z`},child:[]}]})(e)}function mn(){return typeof window<`u`}function hn(e){return vn(e)?(e.nodeName||``).toLowerCase():`#document`}function gn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _n(e){return((vn(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function vn(e){return mn()?e instanceof Node||e instanceof gn(e).Node:!1}function yn(e){return mn()?e instanceof Element||e instanceof gn(e).Element:!1}function bn(e){return mn()?e instanceof HTMLElement||e instanceof gn(e).HTMLElement:!1}function xn(e){return!mn()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof gn(e).ShadowRoot}function Sn(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Nn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Cn(e){return/^(table|td|th)$/.test(hn(e))}function wn(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Tn=/transform|translate|scale|rotate|perspective|filter/,En=/paint|layout|strict|content/,Dn=e=>!!e&&e!==`none`,On;function kn(e){let t=yn(e)?Nn(e):e;return Dn(t.transform)||Dn(t.translate)||Dn(t.scale)||Dn(t.rotate)||Dn(t.perspective)||!jn()&&(Dn(t.backdropFilter)||Dn(t.filter))||Tn.test(t.willChange||``)||En.test(t.contain||``)}function An(e){let t=Fn(e);for(;bn(t)&&!Mn(t);){if(kn(t))return t;if(wn(t))return null;t=Fn(t)}return null}function jn(){return On??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),On}function Mn(e){return/^(html|body|#document)$/.test(hn(e))}function Nn(e){return gn(e).getComputedStyle(e)}function Pn(e){return yn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(hn(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||xn(e)&&e.host||_n(e);return xn(t)?t.host:t}function In(e){let t=Fn(e);return Mn(t)?(e.ownerDocument||e).body:bn(t)&&Sn(t)?t:In(t)}function Ln(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=In(e),i=r===e.ownerDocument?.body,a=gn(r);if(i){let e=Rn(a);return t.concat(a,a.visualViewport||[],Sn(r)?r:[],e&&n?Ln(e):[])}return t.concat(r,Ln(r,[],n))}function Rn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var zn=[`top`,`right`,`bottom`,`left`],Bn=[`start`,`end`],Vn=zn.reduce((e,t)=>e.concat(t,t+`-`+Bn[0],t+`-`+Bn[1]),[]),Hn=Math.min,Un=Math.max,Wn=Math.round,Gn=Math.floor,Kn=e=>({x:e,y:e}),qn={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Jn(e,t,n){return Un(e,Hn(t,n))}function Yn(e,t){return typeof e==`function`?e(t):e}function Xn(e){return e.split(`-`)[0]}function Zn(e){return e.split(`-`)[1]}function Qn(e){return e===`x`?`y`:`x`}function $n(e){return e===`y`?`height`:`width`}function er(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function tr(e){return Qn(er(e))}function nr(e,t,n){n===void 0&&(n=!1);let r=Zn(e),i=tr(e),a=$n(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=dr(o)),[o,dr(o)]}function rr(e){let t=dr(e);return[ir(e),t,ir(t)]}function ir(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ar=[`left`,`right`],or=[`right`,`left`],sr=[`top`,`bottom`],cr=[`bottom`,`top`];function lr(e,t,n){switch(e){case`top`:case`bottom`:return n?t?or:ar:t?ar:or;case`left`:case`right`:return t?sr:cr;default:return[]}}function ur(e,t,n,r){let i=Zn(e),a=lr(Xn(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ir)))),a}function dr(e){let t=Xn(e);return qn[t]+e.slice(t.length)}function fr(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function pr(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:fr(e)}function mr(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}var hr=`input:not([inert]):not([inert] *),select:not([inert]):not([inert] *),textarea:not([inert]):not([inert] *),a[href]:not([inert]):not([inert] *),area[href]:not([inert]):not([inert] *),button:not([inert]):not([inert] *),[tabindex]:not(slot):not([inert]):not([inert] *),audio[controls]:not([inert]):not([inert] *),video[controls]:not([inert]):not([inert] *),[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *),details>summary:first-of-type:not([inert]):not([inert] *),details:not([inert]):not([inert] *)`,gr=typeof Element>`u`,_r=gr?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,vr=!gr&&Element.prototype.getRootNode?function(e){return e==null||e.getRootNode==null?void 0:e.getRootNode()}:function(e){return e?.ownerDocument},yr=function(e,t){t===void 0&&(t=!0);var n=e==null||e.getAttribute==null?void 0:e.getAttribute(`inert`);return n===``||n===`true`||t&&e&&(typeof e.closest==`function`?e.closest(`[inert]`):yr(e.parentNode))},br=function(e){var t,n=e==null||e.getAttribute==null||(t=e.getAttribute(`contenteditable`))==null?void 0:t.toLowerCase();return n===``||n===`true`||n===`plaintext-only`},xr=function(e,t,n){if(yr(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(hr));return t&&_r.call(e,hr)&&r.unshift(e),r=r.filter(n),r},Sr=function(e,t,n){for(var r=[],i=Array.from(e);i.length;){var a=i.shift();if(!yr(a,!1)){if(a.tagName===`SLOT`){var o=a.assignedElements(),s=Sr(o.length?o:a.children,!0,n);n.flatten?r.push.apply(r,s):r.push({scopeParent:a,candidates:s})}else{_r.call(a,hr)&&n.filter(a)&&(t||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof n.getShadowRoot==`function`&&n.getShadowRoot(a),l=!yr(c,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(c&&l){var u=Sr(c===!0?a.children:c.children,!0,n);n.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else i.unshift.apply(i,a.children)}}}return r},Cr=function(e){return!isNaN(parseInt(e.getAttribute(`tabindex`),10))},wr=function(e){if(!e)throw Error(`No node provided`);return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||br(e))&&!Cr(e)?0:e.tabIndex},Tr=function(e,t){var n=wr(e);return n<0&&t&&!Cr(e)?0:n},Er=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},Dr=function(e){return e.tagName===`INPUT`},Or=function(e){return Dr(e)&&e.type===`hidden`},kr=function(e){return e.tagName===`DETAILS`&&Array.prototype.slice.apply(e.children).some(function(e){return e.tagName===`SUMMARY`})},Ar=function(e,t){for(var n=0;nsummary:first-of-type`)?e.parentElement:e;if(_r.call(a,`details:not([open]) *`))return!0;if(!n||n===`full`||n===`full-native`||n===`legacy-full`){if(typeof r==`function`){for(var o=e;e;){var s=e.parentElement,c=vr(e);if(s&&!s.shadowRoot&&r(s)===!0)return Pr(e);e=e.assignedSlot?e.assignedSlot:!s&&c!==e.ownerDocument?c.host:s}e=o}if(e.isConnected)return!e.getClientRects().length;if(n!==`legacy-full`)return!0}else if(n===`non-zero-area`)return Pr(e);return!1},Ir=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName===`FIELDSET`&&t.disabled){for(var n=0;n=0)},Br=function(e){var t=[],n=[];return e.forEach(function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,o=Tr(a,i),s=i?Br(e.candidates):a;o===0?i?t.push.apply(t,s):t.push(a):n.push({documentOrder:r,tabIndex:o,item:e,isScope:i,content:s})}),n.sort(Er).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},Vr=function(e,t){return t||={},Br(t.getShadowRoot?Sr([e],t.includeContainer,{filter:Rr.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:zr}):xr(e,t.includeContainer,Rr.bind(null,t)))},Hr=function(e,t){return t||={},t.getShadowRoot?Sr([e],t.includeContainer,{filter:Lr.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):xr(e,t.includeContainer,Lr.bind(null,t))},Ur=function(e,t){if(t||={},!e)throw Error(`No node provided`);return _r.call(e,hr)!==!1&&Rr(t,e)};function Wr(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function Gr(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(e=>{let{brand:t,version:n}=e;return t+`/`+n}).join(` `):navigator.userAgent}function Kr(){return/apple/i.test(navigator.vendor)}function qr(){let e=/android/i;return e.test(Wr())||e.test(Gr())}function Jr(){return Wr().toLowerCase().startsWith(`mac`)&&!navigator.maxTouchPoints}function Yr(){return Gr().includes(`jsdom/`)}var Xr=`data-floating-ui-focusable`,Zr=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`;function Qr(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function $r(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&xn(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function ei(e){return`composedPath`in e?e.composedPath()[0]:e.target}function ti(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function ni(e){return e.matches(`html,body`)}function ri(e){return e?.ownerDocument||document}function ii(e){return bn(e)&&e.matches(Zr)}function ai(e){return e?e.getAttribute(`role`)===`combobox`&&ii(e):!1}function oi(e){if(!e||Yr())return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function si(e){return e?e.hasAttribute(Xr)?e:e.querySelector(`[`+Xr+`]`)||e:null}function ci(e,t,n){return n===void 0&&(n=!0),e.filter(e=>e.parentId===t&&(!n||e.context?.open)).flatMap(t=>[t,...ci(e,t.id,n)])}function li(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function ui(e){e.preventDefault(),e.stopPropagation()}function di(e){return`nativeEvent`in e}function fi(e){return e.mozInputSource===0&&e.isTrusted?!0:qr()&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function pi(e){return Yr()?!1:!qr()&&e.width===0&&e.height===0||qr()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function mi(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}var hi=typeof document<`u`?R.useLayoutEffect:function(){},gi={...R};function _i(e){let t=R.useRef(e);return hi(()=>{t.current=e}),t}var vi=gi.useInsertionEffect||(e=>e());function yi(e){let t=R.useRef(()=>{});return vi(()=>{t.current=e}),R.useCallback(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}var bi=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver==`function`&&ResizeObserver.toString().includes(`[native code]`)?`full`:`none`});function xi(e,t){let n=Vr(e,bi()),r=n.length;if(r===0)return;let i=Qr(ri(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Si(e){return xi(ri(e).body,1)||e}function Ci(e){return xi(ri(e).body,-1)||e}function wi(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!$r(n,r)}function Ti(e){Vr(e,bi()).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Ei(e){e.querySelectorAll(`[data-tabindex]`).forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Di(e,t,n){let{reference:r,floating:i}=e,a=er(t),o=tr(t),s=$n(o),c=Xn(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Zn(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Oi(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Yn(t,e),p=pr(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=mr(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=mr(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ki=50,Ai=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Oi},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Di(l,r,c),f=r,p=0,m={};for(let n=0;n({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Yn(e,t)||{};if(l==null)return{};let d=pr(u),f={x:n,y:r},p=tr(i),m=$n(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Hn(d[_],T),D=Hn(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Jn(E,k,O),j=!c.arrow&&Zn(i)!=null&&k!==A&&a.reference[m]/2-(kZn(t)===e),...n.filter(t=>Zn(t)!==e)]:n.filter(e=>Xn(e)===e)).filter(n=>!e||Zn(n)===e||(t?ir(n)!==n:!1))}var Ni=function(e){return e===void 0&&(e={}),{name:`autoPlacement`,options:e,async fn(t){let{rects:n,middlewareData:r,placement:i,platform:a,elements:o}=t,{crossAxis:s=!1,alignment:c,allowedPlacements:l=Vn,autoAlignment:u=!0,...d}=Yn(e,t),f=c!==void 0||l===Vn?Mi(c||null,u,l):l,p=r.autoPlacement?.index||0,m=f[p];if(m==null)return{};if(i!==m)return{reset:{placement:f[0]}};let h=await a.detectOverflow(t,d),g=nr(m,n,await(a.isRTL==null?void 0:a.isRTL(o.floating))),_=[h[Xn(m)],h[g[0]],h[g[1]]],v=[...r.autoPlacement?.overflows||[],{placement:m,overflows:_}],y=f[p+1];if(y)return{data:{index:p+1,overflows:v},reset:{placement:y}};let b=v.map(e=>{let t=Zn(e.placement);return[e.placement,t&&s?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),x=b.filter(e=>e[2].slice(0,Zn(e[0])?2:3).every(e=>e<=0))[0]?.[0]||b[0][0];return x===i?{}:{data:{index:p+1,overflows:v},reset:{placement:x}}}}},Pi=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Yn(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Xn(r),_=er(o),v=Xn(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[dr(o)]:rr(o)),x=p!==`none`;!d&&x&&b.push(...ur(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=nr(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===er(t)||T.every(e=>er(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=er(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Fi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ii(e){return zn.some(t=>e[t]>=0)}var Li=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Yn(e,t);switch(i){case`referenceHidden`:{let e=Fi(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ii(e)}}}case`escaped`:{let e=Fi(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ii(e)}}}default:return{}}}}};function Ri(e){let t=Hn(...e.map(e=>e.left)),n=Hn(...e.map(e=>e.top)),r=Un(...e.map(e=>e.right)),i=Un(...e.map(e=>e.bottom));return{x:t,y:n,width:r-t,height:i-n}}function zi(e){let t=e.slice().sort((e,t)=>e.y-t.y),n=[],r=null;for(let e=0;er.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(e=>mr(Ri(e)))}var Bi=function(e){return e===void 0&&(e={}),{name:`inline`,options:e,async fn(t){let{placement:n,elements:r,rects:i,platform:a,strategy:o}=t,{padding:s=2,x:c,y:l}=Yn(e,t),u=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(r.reference))||[]);if(!u.length)return{};let d=zi(u),f=mr(Ri(u)),p=pr(s);function m(){if(d.length===2&&(d[0].left>d[1].right||d[1].left>d[0].right)&&c!=null&&l!=null)return d.find(e=>c>e.left-p.left&&ce.top-p.top&&l=2){if(er(n)===`y`){let e=d[0],t=d[d.length-1],r=Xn(n)===`top`,i=e.top,a=t.bottom,o=r?e.left:t.left;return mr({x:o,y:i,width:(r?e.right:t.right)-o,height:a-i})}let e=Xn(n)===`left`,t=Un(...d.map(e=>e.right)),r=Hn(...d.map(e=>e.left)),i=d.filter(n=>e?n.left===r:n.right===t),a=i[0].top,o=i[i.length-1].bottom;return mr({x:r,y:a,width:t-r,height:o-a})}return f}let h=await a.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:o});return i.reference.x!==h.reference.x||i.reference.y!==h.reference.y||i.reference.width!==h.reference.width||i.reference.height!==h.reference.height?{reset:{rects:h}}:{}}}},Vi=new Set([`left`,`top`]);async function Hi(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Xn(n),s=Zn(n),c=er(n)===`y`,l=Vi.has(o)?-1:1,u=a&&c?-1:1,d=Yn(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Ui=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Hi(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Wi=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Yn(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=er(i),p=Qn(f),m=u[p],h=u[f],g=(e,t)=>Jn(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Gi=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Yn(e,t),u={x:n,y:r},d=er(i),f=Qn(d),p=u[f],m=u[d],h=Yn(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;pn&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Vi.has(Xn(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);mr&&(m=r)}return{[f]:p,[d]:m}}}},Ki=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Yn(e,t),c=await i.detectOverflow(t,s),l=Xn(n),u=Zn(n),d=er(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Hn(p-c[m],g),y=Hn(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Un(c.left,c.right):S=p-2*Un(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function qi(e){let t=Nn(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=bn(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Wn(n)!==a||Wn(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ji(e){return yn(e)?e:e.contextElement}function Yi(e){let t=Ji(e);if(!bn(t))return Kn(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=qi(t),o=(a?Wn(n.width):n.width)/r,s=(a?Wn(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Xi=Kn(0);function Zi(e){let t=gn(e);return!jn()||!t.visualViewport?Xi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qi(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===gn(e)}function $i(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ji(e),o=Kn(1);t&&(r?yn(r)&&(o=Yi(r)):o=Yi(e));let s=Qi(a,n,r)?Zi(a):Kn(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=gn(a),t=yn(r)?gn(r):r,n=e,i=Rn(n);for(;i&&t!==n;){let e=Yi(i),t=i.getBoundingClientRect(),r=Nn(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=gn(i),i=Rn(n)}}return mr({width:u,height:d,x:c,y:l})}function ea(e,t){let n=Pn(e).scrollLeft;return t?t.left+n:$i(_n(e)).left+n}function ta(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ea(e,n),y:n.top+t.scrollTop}}function na(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=_n(r),s=t?wn(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Kn(1),u=Kn(0),d=bn(r);if((d||!a)&&((hn(r)!==`body`||Sn(o))&&(c=Pn(r)),d)){let e=$i(r);l=Yi(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ta(o,c):Kn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ra(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ia(e){let t=Pn(e),n=e.ownerDocument.body,r=Un(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Un(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ea(e),o=-t.scrollTop;return Nn(n).direction===`rtl`&&(a+=Un(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var aa=25;function oa(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=gn(e),a=_n(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!jn()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(ea(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=aa&&(s-=o)}return{width:s,height:c,x:l,y:u}}function sa(e,t){let n=$i(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Yi(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ca(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=oa(e,n,t);else if(t===`document`)r=ia(_n(e));else if(yn(t))r=sa(t,n);else{let n=Zi(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return mr(r)}function la(e,t){let n=t.get(e);if(n)return n;let r=Ln(e,[],!1).filter(e=>yn(e)&&hn(e)!==`body`),i=null,a=Nn(e).position===`fixed`,o=a?Fn(e):e;for(;yn(o)&&!Mn(o);){let e=Nn(o),t=kn(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Fn(o)}return t.set(e,r),r}function ua(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?wn(t)?[]:la(t,this._c):[].concat(n),r],o=ca(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=gn(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function xa(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ji(e),u=i||a?[...l?Ln(l):[],...t?Ln(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ba(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$i(e):null;c&&g();function g(){let t=$i(e);h&&!ya(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Sa=Ui,Ca=Ni,wa=Wi,Ta=Pi,Ea=Ki,Da=Li,Oa=ji,ka=Bi,Aa=Gi,ja=(e,t,n)=>{let r=new Map,i=n??{},a={...va,...i.platform,_c:r};return Ai(e,t,{...i,platform:a})},Ma=typeof document<`u`?R.useLayoutEffect:function(){};function Na(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Na(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Na(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Pa(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fa(e,t){let n=Pa(e);return Math.round(t*n)/n}function Ia(e){let t=R.useRef(e);return Ma(()=>{t.current=e}),t}function La(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=R.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=R.useState(r);Na(f,r)||p(r);let[m,h]=R.useState(null),[g,_]=R.useState(null),v=R.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=R.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=R.useRef(null),C=R.useRef(null),w=R.useRef(u),T=c!=null,E=Ia(c),D=Ia(i),O=Ia(l),k=R.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),ja(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Na(w.current,t)&&(w.current=t,Ne.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Ma(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=R.useRef(!1);Ma(()=>(A.current=!0,()=>{A.current=!1}),[]),Ma(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=R.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=R.useMemo(()=>({reference:b,floating:x}),[b,x]),N=R.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Fa(M.floating,u.x),r=Fa(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Pa(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return R.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Ra=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Oa({element:r.current,padding:i}).fn(n):r?Oa({element:r,padding:i}).fn(n):{}}}},za=(e,t)=>{let n=Sa(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ba=(e,t)=>{let n=wa(e);return{name:n.name,fn:n.fn,options:[e,t]}},Va=(e,t)=>({fn:Aa(e).fn,options:[e,t]}),Ha=(e,t)=>{let n=Ta(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ua=(e,t)=>{let n=Ea(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wa=(e,t)=>{let n=Ca(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ga=(e,t)=>{let n=Da(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ka=(e,t)=>{let n=ka(e);return{name:n.name,fn:n.fn,options:[e,t]}},qa=(e,t)=>{let n=Ra(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Ja(e){let t=R.useRef(void 0),n=R.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return R.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}var Ya=`data-floating-ui-focusable`,Xa=`active`,Za=`selected`,Qa=`ArrowLeft`,$a=`ArrowRight`,eo=`ArrowUp`,to=`ArrowDown`,no=[Qa,$a],ro=[eo,to];[...no,...ro];var io={...R},ao=!1,oo=0,so=()=>`floating-ui-`+Math.random().toString(36).slice(2,6)+oo++;function co(){let[e,t]=R.useState(()=>ao?so():void 0);return hi(()=>{e??t(so())},[]),R.useEffect(()=>{ao=!0},[]),e}var lo=io.useId||co;function uo(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}var fo=R.createContext(null),po=R.createContext(null),mo=()=>R.useContext(fo)?.id||null,ho=()=>R.useContext(po);function go(e){return`data-floating-ui-`+e}function _o(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}var vo=go(`safe-polygon`);function yo(e,t,n){if(n&&!mi(n))return 0;if(typeof e==`number`)return e;if(typeof e==`function`){let n=e();return typeof n==`number`?n:n?.[t]}return e?.[t]}function bo(e){return typeof e==`function`?e():e}function xo(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:i,events:a,elements:o}=e,{enabled:s=!0,delay:c=0,handleClose:l=null,mouseOnly:u=!1,restMs:d=0,move:f=!0}=t,p=ho(),m=mo(),h=_i(l),g=_i(c),_=_i(n),v=_i(d),y=R.useRef(),b=R.useRef(-1),x=R.useRef(),S=R.useRef(-1),C=R.useRef(!0),w=R.useRef(!1),T=R.useRef(()=>{}),E=R.useRef(!1),D=yi(()=>{let e=i.current.openEvent?.type;return e?.includes(`mouse`)&&e!==`mousedown`});R.useEffect(()=>{if(!s)return;function e(e){let{open:t}=e;t||(_o(b),_o(S),C.current=!0,E.current=!1)}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[s,a]),R.useEffect(()=>{if(!s||!h.current||!n)return;function e(e){D()&&r(!1,e,`hover`)}let t=ri(o.floating).documentElement;return t.addEventListener(`mouseleave`,e),()=>{t.removeEventListener(`mouseleave`,e)}},[o.floating,n,r,s,h,D]);let O=R.useCallback(function(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=`hover`);let i=yo(g.current,`close`,y.current);i&&!x.current?(_o(b),b.current=window.setTimeout(()=>r(!1,e,n),i)):t&&(_o(b),r(!1,e,n))},[g,r]),k=yi(()=>{T.current(),x.current=void 0}),A=yi(()=>{if(w.current){let e=ri(o.floating).body;e.style.pointerEvents=``,e.removeAttribute(vo),w.current=!1}}),j=yi(()=>i.current.openEvent?[`click`,`mousedown`].includes(i.current.openEvent.type):!1);R.useEffect(()=>{if(!s)return;function e(e){if(_o(b),C.current=!1,u&&!mi(y.current)||bo(v.current)>0&&!yo(g.current,`open`))return;let t=yo(g.current,`open`,y.current);t?b.current=window.setTimeout(()=>{_.current||r(!0,e,`hover`)},t):n||r(!0,e,`hover`)}function t(e){if(j()){A();return}T.current();let t=ri(o.floating);if(_o(S),E.current=!1,h.current&&i.current.floatingContext){n||_o(b),x.current=h.current({...i.current.floatingContext,tree:p,x:e.clientX,y:e.clientY,onClose(){A(),k(),j()||O(e,!0,`safe-polygon`)}});let r=x.current;t.addEventListener(`mousemove`,r),T.current=()=>{t.removeEventListener(`mousemove`,r)}}else y.current===`touch`&&$r(o.floating,e.relatedTarget)||O(e)}function a(e){j()||i.current.floatingContext&&(h.current==null||h.current({...i.current.floatingContext,tree:p,x:e.clientX,y:e.clientY,onClose(){A(),k(),j()||O(e)}})(e))}function c(){_o(b)}function l(e){j()||O(e,!1)}if(yn(o.domReference)){let r=o.domReference,i=o.floating;return n&&r.addEventListener(`mouseleave`,a),f&&r.addEventListener(`mousemove`,e,{once:!0}),r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),i&&(i.addEventListener(`mouseleave`,a),i.addEventListener(`mouseenter`,c),i.addEventListener(`mouseleave`,l)),()=>{n&&r.removeEventListener(`mouseleave`,a),f&&r.removeEventListener(`mousemove`,e),r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t),i&&(i.removeEventListener(`mouseleave`,a),i.removeEventListener(`mouseenter`,c),i.removeEventListener(`mouseleave`,l))}}},[o,s,e,u,f,O,k,A,r,n,_,p,g,h,i,j,v]),hi(()=>{var e;if(s&&n&&(e=h.current)!=null&&(e=e.__options)!=null&&e.blockPointerEvents&&D()){w.current=!0;let e=o.floating;if(yn(o.domReference)&&e){var t;let n=ri(o.floating).body;n.setAttribute(vo,``);let r=o.domReference,i=p==null||(t=p.nodesRef.current.find(e=>e.id===m))==null||(t=t.context)==null?void 0:t.elements.floating;return i&&(i.style.pointerEvents=``),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,e.style.pointerEvents=`auto`,()=>{n.style.pointerEvents=``,r.style.pointerEvents=``,e.style.pointerEvents=``}}}},[s,n,m,o,p,h,D]),hi(()=>{n||(y.current=void 0,E.current=!1,k(),A())},[n,k,A]),R.useEffect(()=>()=>{k(),_o(b),_o(S),A()},[s,o.domReference,k,A]);let M=R.useMemo(()=>{function e(e){y.current=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e;function i(){!C.current&&!_.current&&r(!0,t,`hover`)}u&&!mi(y.current)||n||bo(v.current)===0||E.current&&e.movementX**2+e.movementY**2<2||(_o(S),y.current===`touch`?i():(E.current=!0,S.current=window.setTimeout(i,bo(v.current))))}}},[u,r,n,_,v]);return R.useMemo(()=>s?{reference:M}:{},[s,M])}var So=()=>{},Co=R.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:So,setState:So,isInstantPhase:!1}),wo=()=>R.useContext(Co);function To(e){let{children:t,delay:n,timeoutMs:r=0}=e,[i,a]=R.useReducer((e,t)=>({...e,...t}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),o=R.useRef(null),s=R.useCallback(e=>{a({currentId:e})},[]);return hi(()=>{i.currentId?o.current===null?o.current=i.currentId:i.isInstantPhase||a({isInstantPhase:!0}):(i.isInstantPhase&&a({isInstantPhase:!1}),o.current=null)},[i.currentId,i.isInstantPhase]),(0,z.jsx)(Co.Provider,{value:R.useMemo(()=>({...i,setState:a,setCurrentId:s}),[i,s]),children:t})}function Eo(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,floatingId:i}=e,{id:a,enabled:o=!0}=t,s=a??i,c=wo(),{currentId:l,setCurrentId:u,initialDelay:d,setState:f,timeoutMs:p}=c;return hi(()=>{o&&l&&(f({delay:{open:1,close:yo(d,`close`)}}),l!==s&&r(!1))},[o,s,r,f,l,d]),hi(()=>{function e(){r(!1),f({delay:d,currentId:null})}if(o&&l&&!n&&l===s){if(p){let t=window.setTimeout(e,p);return()=>{clearTimeout(t)}}e()}},[o,n,f,l,s,r,d,p]),hi(()=>{o&&u!==So&&n&&u(s)},[o,n,u,s]),c}var Do=0;function Oo(e,t){t===void 0&&(t={});let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(Do);let a=()=>e?.focus({preventScroll:n});i?a():Do=requestAnimationFrame(a)}function ko(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&xn(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Ao(e){return`composedPath`in e?e.composedPath()[0]:e.target}function jo(e){return e?.ownerDocument||document}var Mo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function No(e){return e===`inert`?Mo.inert:e===`aria-hidden`?Mo[`aria-hidden`]:Mo.none}var Po=new WeakSet,Fo={},Io=0,Lo=()=>typeof HTMLElement<`u`&&`inert`in HTMLElement.prototype;function Ro(e){return e?xn(e)?e.host:Ro(e.parentNode):null}var zo=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Ro(t);return e.contains(n)?n:null}).filter(e=>e!=null);function Bo(e,t,n,r){let i=`data-floating-ui-inert`,a=r?`inert`:n?`aria-hidden`:null,o=zo(t,e),s=new Set,c=new Set(o),l=[];Fo[i]||(Fo[i]=new WeakMap);let u=Fo[i];o.forEach(d),f(t),s.clear();function d(e){e&&!s.has(e)&&(s.add(e),e.parentNode&&d(e.parentNode))}function f(e){e&&!c.has(e)&&[].forEach.call(e.children,e=>{if(hn(e)!==`script`){if(s.has(e))f(e);else{let t=a?e.getAttribute(a):null,n=t!==null&&t!==`false`,r=No(a),o=(r.get(e)||0)+1,s=(u.get(e)||0)+1;r.set(e,o),u.set(e,s),l.push(e),o===1&&n&&Po.add(e),s===1&&e.setAttribute(i,``),!n&&a&&e.setAttribute(a,a===`inert`?``:`true`)}}})}return Io++,()=>{l.forEach(e=>{let t=No(a),n=(t.get(e)||0)-1,r=(u.get(e)||0)-1;t.set(e,n),u.set(e,r),n||(!Po.has(e)&&a&&e.removeAttribute(a),Po.delete(e)),r||e.removeAttribute(i)}),Io--,Io||(Mo.inert=new WeakMap,Mo[`aria-hidden`]=new WeakMap,Mo.none=new WeakMap,Po=new WeakSet,Fo={})}}function Vo(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);let r=jo(e[0]).body;return Bo(e.concat(Array.from(r.querySelectorAll(`[aria-live],[role="status"],output`))),r,t,n)}var Ho={border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`fixed`,whiteSpace:`nowrap`,width:`1px`,top:0,left:0},Uo=R.forwardRef(function(e,t){let[n,r]=R.useState();hi(()=>{Kr()&&r(`button`)},[]);let i={ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,[go(`focus-guard`)]:``,style:Ho};return(0,z.jsx)(`span`,{...e,...i})}),Wo={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},Go=R.createContext(null),Ko=go(`portal`);function qo(e){e===void 0&&(e={});let{id:t,root:n}=e,r=lo(),i=Yo(),[a,o]=R.useState(null),s=R.useRef(null);return hi(()=>()=>{a?.remove(),queueMicrotask(()=>{s.current=null})},[a]),hi(()=>{if(!r||s.current)return;let e=t?document.getElementById(t):null;if(!e)return;let n=document.createElement(`div`);n.id=r,n.setAttribute(Ko,``),e.appendChild(n),s.current=n,o(n)},[t,r]),hi(()=>{if(n===null||!r||s.current)return;let e=n||i?.portalNode;e&&!vn(e)&&(e=e.current),e||=document.body;let a=null;t&&(a=document.createElement(`div`),a.id=t,e.appendChild(a));let c=document.createElement(`div`);c.id=r,c.setAttribute(Ko,``),e=a||e,e.appendChild(c),s.current=c,o(c)},[t,n,r,i]),a}function Jo(e){let{children:t,id:n,root:r,preserveTabOrder:i=!0}=e,a=qo({id:n,root:r}),[o,s]=R.useState(null),c=R.useRef(null),l=R.useRef(null),u=R.useRef(null),d=R.useRef(null),f=o?.modal,p=o?.open,m=!!o&&!o.modal&&o.open&&i&&!!(r||a);return R.useEffect(()=>{if(!a||!i||f)return;function e(e){a&&wi(e)&&(e.type===`focusin`?Ei:Ti)(a)}return a.addEventListener(`focusin`,e,!0),a.addEventListener(`focusout`,e,!0),()=>{a.removeEventListener(`focusin`,e,!0),a.removeEventListener(`focusout`,e,!0)}},[a,i,f]),R.useEffect(()=>{a&&(p||Ei(a))},[p,a]),(0,z.jsxs)(Go.Provider,{value:R.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:l,beforeInsideRef:u,afterInsideRef:d,portalNode:a,setFocusManagerState:s}),[i,a]),children:[m&&a&&(0,z.jsx)(Uo,{"data-type":`outside`,ref:c,onFocus:e=>{if(wi(e,a)){var t;(t=u.current)==null||t.focus()}else Ci(o?o.domReference:null)?.focus()}}),m&&a&&(0,z.jsx)(`span`,{"aria-owns":a.id,style:Wo}),a&&Ne.createPortal(t,a),m&&a&&(0,z.jsx)(Uo,{"data-type":`outside`,ref:l,onFocus:e=>{if(wi(e,a)){var t;(t=d.current)==null||t.focus()}else Si(o?o.domReference:null)?.focus(),o!=null&&o.closeOnFocusOut&&o?.onOpenChange(!1,e.nativeEvent,`focus-out`)}})]})}var Yo=()=>R.useContext(Go);function Xo(e){return R.useMemo(()=>t=>{e.forEach(e=>{e&&(e.current=t)})},e)}var Zo=20,Qo=[];function $o(){Qo=Qo.filter(e=>e.deref()?.isConnected)}function es(e){$o(),e&&hn(e)!==`body`&&(Qo.push(new WeakRef(e)),Qo.length>Zo&&(Qo=Qo.slice(-20)))}function ts(){return $o(),Qo[Qo.length-1]?.deref()}function ns(e){let t=bi();return Ur(e,t)?e:Vr(e,t)[0]||e}function rs(e,t){var n;if(!t.current.includes(`floating`)&&!((n=e.getAttribute(`role`))!=null&&n.includes(`dialog`)))return;let r=bi(),i=Hr(e,r).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Ur(e,r)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),a=e.getAttribute(`tabindex`);t.current.includes(`floating`)||i.length===0?a!==`0`&&e.setAttribute(`tabindex`,`0`):(a!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}var is=R.forwardRef(function(e,t){return(0,z.jsx)(`button`,{...e,type:`button`,ref:t,tabIndex:-1,style:Ho})});function as(e){let{context:t,children:n,disabled:r=!1,order:i=[`content`],guards:a=!0,initialFocus:o=0,returnFocus:s=!0,restoreFocus:c=!1,modal:l=!0,visuallyHiddenDismiss:u=!1,closeOnFocusOut:d=!0,outsideElementsInert:f=!1,getInsideElements:p=()=>[]}=e,{open:m,onOpenChange:h,events:g,dataRef:_,elements:{domReference:v,floating:y}}=t,b=yi(()=>_.current.floatingContext?.nodeId),x=yi(p),S=typeof o==`number`&&o<0,C=ai(v)&&S,w=Lo(),T=!w||a,E=!T||w&&f,D=_i(i),O=_i(o),k=_i(s),A=ho(),j=Yo(),M=R.useRef(null),N=R.useRef(null),P=R.useRef(!1),ee=R.useRef(!1),te=R.useRef(-1),ne=R.useRef(-1),re=j!=null,F=si(y),ie=yi(function(e){return e===void 0&&(e=F),e?Vr(e,bi()):[]}),ae=yi(e=>{let t=ie(e);return D.current.map(e=>v&&e===`reference`?v:F&&e===`floating`?F:t).filter(Boolean).flat()});R.useEffect(()=>{if(r||!l)return;function e(e){if(e.key===`Tab`){$r(F,Qr(ri(F)))&&ie().length===0&&!C&&ui(e);let t=ae(),n=ei(e);D.current[0]===`reference`&&n===v&&(ui(e),e.shiftKey?Oo(t[t.length-1]):Oo(t[1])),D.current[1]===`floating`&&n===F&&e.shiftKey&&(ui(e),Oo(t[0]))}}let t=ri(F);return t.addEventListener(`keydown`,e),()=>{t.removeEventListener(`keydown`,e)}},[r,v,F,l,D,C,ie,ae]),R.useEffect(()=>{if(r||!y)return;function e(e){let t=ei(e),n=ie().indexOf(t);n!==-1&&(te.current=n)}return y.addEventListener(`focusin`,e),()=>{y.removeEventListener(`focusin`,e)}},[r,y,ie]),R.useEffect(()=>{if(r||!d)return;function e(){ee.current=!0,setTimeout(()=>{ee.current=!1})}function t(e){let t=e.relatedTarget,n=e.currentTarget,r=ei(e);queueMicrotask(()=>{let i=b(),a=!($r(v,t)||$r(y,t)||$r(t,y)||$r(j?.portalNode,t)||t!=null&&t.hasAttribute(go(`focus-guard`))||A&&(ci(A.nodesRef.current,i).find(e=>$r(e.context?.elements.floating,t)||$r(e.context?.elements.domReference,t))||li(A.nodesRef.current,i).find(e=>[e.context?.elements.floating,si(e.context?.elements.floating)].includes(t)||e.context?.elements.domReference===t)));if(n===v&&F&&rs(F,D),c&&n!==v&&!(r!=null&&r.isConnected)&&Qr(ri(F))===ri(F).body){bn(F)&&F.focus();let e=te.current,t=ie(),n=t[e]||t[t.length-1]||F;bn(n)&&n.focus()}_.current.insideReactTree?_.current.insideReactTree=!1:(C||!l)&&t&&a&&!ee.current&&t!==ts()&&(P.current=!0,h(!1,e,`focus-out`))})}let n=!(A||!j);function i(){_o(ne),_.current.insideReactTree=!0,ne.current=window.setTimeout(()=>{_.current.insideReactTree=!1})}if(y&&bn(v))return v.addEventListener(`focusout`,t),v.addEventListener(`pointerdown`,e),y.addEventListener(`focusout`,t),n&&y.addEventListener(`focusout`,i,!0),()=>{v.removeEventListener(`focusout`,t),v.removeEventListener(`pointerdown`,e),y.removeEventListener(`focusout`,t),n&&y.removeEventListener(`focusout`,i,!0)}},[r,v,y,F,l,A,j,h,d,c,ie,C,b,D,_]);let oe=R.useRef(null),se=R.useRef(null),I=Xo([oe,j?.beforeInsideRef]),ce=Xo([se,j?.afterInsideRef]);R.useEffect(()=>{var e,t;if(r||!y)return;let n=Array.from((j==null||(e=j.portalNode)==null?void 0:e.querySelectorAll(`[`+go(`portal`)+`]`))||[]),i=(t=(A?li(A.nodesRef.current,b()):[]).find(e=>ai(e.context?.elements.domReference||null)))==null||(t=t.context)==null?void 0:t.elements.domReference,a=[y,i,...n,...x(),M.current,N.current,oe.current,se.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,D.current.includes(`reference`)||C?v:null].filter(e=>e!=null),o=l||C?Vo(a,!E,E):Vo(a);return()=>{o()}},[r,v,y,l,D,j,C,T,E,A,b,x]),hi(()=>{if(r||!bn(F))return;let e=Qr(ri(F));queueMicrotask(()=>{let t=ae(F),n=O.current,r=(typeof n==`number`?t[n]:n.current)||F,i=$r(F,e);!S&&!i&&m&&Oo(r,{preventScroll:r===F})})},[r,m,F,S,ae,O]),hi(()=>{if(r||!F)return;let e=ri(F);es(Qr(e));function t(e){let{reason:t,event:n,nested:r}=e;if([`hover`,`safe-polygon`].includes(t)&&n.type===`mouseleave`&&(P.current=!0),t===`outside-press`){if(r)P.current=!1;else if(fi(n)||pi(n))P.current=!1;else{let e=!1;document.createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?P.current=!1:P.current=!0}}}g.on(`openchange`,t);let n=e.createElement(`span`);n.setAttribute(`tabindex`,`-1`),n.setAttribute(`aria-hidden`,`true`),Object.assign(n.style,Ho),re&&v&&v.insertAdjacentElement(`afterend`,n);function i(){if(typeof k.current==`boolean`){let e=v||ts();return e&&e.isConnected?e:n}return k.current.current||n}return()=>{g.off(`openchange`,t);let r=Qr(e),a=$r(y,r)||A&&ci(A.nodesRef.current,b(),!1).some(e=>$r(e.context?.elements.floating,r)),o=i();queueMicrotask(()=>{let t=ns(o);k.current&&!P.current&&bn(t)&&(t===r||r===e.body||a)&&t.focus({preventScroll:!0}),n.remove()})}},[r,y,F,k,_,g,A,re,v,b]),R.useEffect(()=>(queueMicrotask(()=>{P.current=!1}),()=>{queueMicrotask($o)}),[r]),hi(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:d,open:m,onOpenChange:h,domReference:v}),()=>{j.setFocusManagerState(null)}},[r,j,l,m,h,d,v]),hi(()=>{r||F&&rs(F,D)},[r,F,D]);function le(e){return r||!u||!l?null:(0,z.jsx)(is,{ref:e===`start`?M:N,onClick:e=>h(!1,e.nativeEvent),children:typeof u==`string`?u:`Dismiss`})}let ue=!r&&T&&(!l||!C)&&(re||l);return(0,z.jsxs)(z.Fragment,{children:[ue&&(0,z.jsx)(Uo,{"data-type":`inside`,ref:I,onFocus:e=>{if(l){let e=ae();Oo(i[0]===`reference`?e[0]:e[e.length-1])}else if(j!=null&&j.preserveTabOrder&&j.portalNode){if(P.current=!1,wi(e,j.portalNode))Si(v)?.focus();else{var t;(t=j.beforeOutsideRef.current)==null||t.focus()}}}}),!C&&le(`start`),n,le(`end`),ue&&(0,z.jsx)(Uo,{"data-type":`inside`,ref:ce,onFocus:e=>{if(l)Oo(ae()[0]);else if(j!=null&&j.preserveTabOrder&&j.portalNode){if(d&&(P.current=!0),wi(e,j.portalNode))Ci(v)?.focus();else{var t;(t=j.afterOutsideRef.current)==null||t.focus()}}}})]})}var os={pointerdown:`onPointerDown`,mousedown:`onMouseDown`,click:`onClick`},ss={pointerdown:`onPointerDownCapture`,mousedown:`onMouseDownCapture`,click:`onClickCapture`},cs=e=>({escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0});function ls(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,elements:i,dataRef:a}=e,{enabled:o=!0,escapeKey:s=!0,outsidePress:c=!0,outsidePressEvent:l=`pointerdown`,referencePress:u=!1,referencePressEvent:d=`pointerdown`,ancestorScroll:f=!1,bubbles:p,capture:m}=t,h=ho(),g=yi(typeof c==`function`?c:()=>!1),_=typeof c==`function`?g:c,v=R.useRef(!1),{escapeKey:y,outsidePress:b}=cs(p),{escapeKey:x,outsidePress:S}=cs(m),C=R.useRef(!1),w=yi(e=>{if(!n||!o||!s||e.key!==`Escape`||C.current)return;let t=a.current.floatingContext?.nodeId,i=h?ci(h.nodesRef.current,t):[];if(!y&&(e.stopPropagation(),i.length>0)){let e=!0;if(i.forEach(t=>{var n;(n=t.context)!=null&&n.open&&!t.context.dataRef.current.__escapeKeyBubbles&&(e=!1)}),!e)return}r(!1,di(e)?e.nativeEvent:e,`escape-key`)}),T=yi(e=>{var t;let n=()=>{var t;w(e),(t=ei(e))==null||t.removeEventListener(`keydown`,n)};(t=ei(e))==null||t.addEventListener(`keydown`,n)}),E=yi(e=>{let t=a.current.insideReactTree;a.current.insideReactTree=!1;let n=v.current;if(v.current=!1,l===`click`&&n||t||typeof _==`function`&&!_(e))return;let o=ei(e),s=`[`+go(`inert`)+`]`,c=ri(i.floating).querySelectorAll(s),u=yn(o)?o:null;for(;u&&!Mn(u);){let e=Fn(u);if(Mn(e)||!yn(e))break;u=e}if(c.length&&yn(o)&&!ni(o)&&!$r(o,i.floating)&&Array.from(c).every(e=>!$r(u,e)))return;if(bn(o)&&k){let t=Mn(o),n=Nn(o),r=/auto|scroll/,i=t||r.test(n.overflowX),a=t||r.test(n.overflowY),s=i&&o.clientWidth>0&&o.scrollWidth>o.clientWidth,c=a&&o.clientHeight>0&&o.scrollHeight>o.clientHeight,l=n.direction===`rtl`,u=c&&(l?e.offsetX<=o.offsetWidth-o.clientWidth:e.offsetX>o.clientWidth),d=s&&e.offsetY>o.clientHeight;if(u||d)return}let d=a.current.floatingContext?.nodeId,f=h&&ci(h.nodesRef.current,d).some(t=>ti(e,t.context?.elements.floating));if(ti(e,i.floating)||ti(e,i.domReference)||f)return;let p=h?ci(h.nodesRef.current,d):[];if(p.length>0){let e=!0;if(p.forEach(t=>{var n;(n=t.context)!=null&&n.open&&!t.context.dataRef.current.__outsidePressBubbles&&(e=!1)}),!e)return}r(!1,e,`outside-press`)}),D=yi(e=>{var t;let n=()=>{var t;E(e),(t=ei(e))==null||t.removeEventListener(l,n)};(t=ei(e))==null||t.addEventListener(l,n)});R.useEffect(()=>{if(!n||!o)return;a.current.__escapeKeyBubbles=y,a.current.__outsidePressBubbles=b;let e=-1;function t(e){r(!1,e,`ancestor-scroll`)}function c(){window.clearTimeout(e),C.current=!0}function u(){e=window.setTimeout(()=>{C.current=!1},jn()?5:0)}let d=ri(i.floating);s&&(d.addEventListener(`keydown`,x?T:w,x),d.addEventListener(`compositionstart`,c),d.addEventListener(`compositionend`,u)),_&&d.addEventListener(l,S?D:E,S);let p=[];return f&&(yn(i.domReference)&&(p=Ln(i.domReference)),yn(i.floating)&&(p=p.concat(Ln(i.floating))),!yn(i.reference)&&i.reference&&i.reference.contextElement&&(p=p.concat(Ln(i.reference.contextElement)))),p=p.filter(e=>e!==d.defaultView?.visualViewport),p.forEach(e=>{e.addEventListener(`scroll`,t)}),()=>{s&&(d.removeEventListener(`keydown`,x?T:w,x),d.removeEventListener(`compositionstart`,c),d.removeEventListener(`compositionend`,u)),_&&d.removeEventListener(l,S?D:E,S),p.forEach(e=>{e.removeEventListener(`scroll`,t)}),window.clearTimeout(e)}},[a,i,s,_,l,n,r,f,o,y,b,w,x,T,E,S,D]),R.useEffect(()=>{a.current.insideReactTree=!1},[a,_,l]);let O=R.useMemo(()=>({onKeyDown:w,...u&&{[os[d]]:e=>{r(!1,e.nativeEvent,`reference-press`)},...d!==`click`&&{onClick(e){r(!1,e.nativeEvent,`reference-press`)}}}}),[w,r,u,d]),k=R.useMemo(()=>{function e(e){e.button===0&&(v.current=!0)}return{onKeyDown:w,onMouseDown:e,onMouseUp:e,[ss[l]]:()=>{a.current.insideReactTree=!0}}},[w,l,a]);return R.useMemo(()=>o?{reference:O,floating:k}:{},[o,O,k])}function us(e){let{open:t=!1,onOpenChange:n,elements:r}=e,i=lo(),a=R.useRef({}),[o]=R.useState(()=>uo()),s=mo()!=null,[c,l]=R.useState(r.reference),u=yi((e,t,r)=>{a.current.openEvent=e?t:void 0,o.emit(`openchange`,{open:e,event:t,reason:r,nested:s}),n?.(e,t,r)}),d=R.useMemo(()=>({setPositionReference:l}),[]),f=R.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return R.useMemo(()=>({dataRef:a,open:t,onOpenChange:u,elements:f,events:o,floatingId:i,refs:d}),[t,u,f,o,i,d])}function ds(e){let{elements:t,...n}=e===void 0?{}:e,{nodeId:r}=n,i=us({...n,elements:{reference:t?.reference??null,floating:t?.floating??null}}),a=n.rootContext||i,o=a.elements,[s,c]=R.useState(null),[l,u]=R.useState(null),d=o?.domReference||s,f=R.useRef(null),p=ho();hi(()=>{d&&(f.current=d)},[d]);let m=La({...n,elements:{...o,...l&&{reference:l}}}),h=R.useCallback(e=>{let t=yn(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=R.useCallback(e=>{(yn(e)||e===null)&&(f.current=e,c(e)),(yn(m.refs.reference.current)||m.refs.reference.current===null||e!==null&&!yn(e))&&m.refs.setReference(e)},[m.refs]),_=R.useMemo(()=>({...m.refs,setReference:g,setPositionReference:h,domReference:f}),[m.refs,g,h]),v=R.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),y=R.useMemo(()=>({...m,...a,refs:_,elements:v,nodeId:r}),[m,_,v,r,a]);return hi(()=>{a.dataRef.current.floatingContext=y;let e=p?.nodesRef.current.find(e=>e.id===r);e&&(e.context=y)}),R.useMemo(()=>({...m,context:y,refs:_,elements:v}),[m,_,v,y])}function fs(){return Jr()&&Kr()}function ps(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,events:i,dataRef:a,elements:o}=e,{enabled:s=!0,visibleOnly:c=!0}=t,l=R.useRef(!1),u=R.useRef(-1),d=R.useRef(!0);R.useEffect(()=>{if(!s)return;let e=gn(o.domReference);function t(){!n&&bn(o.domReference)&&o.domReference===Qr(ri(o.domReference))&&(l.current=!0)}function r(){d.current=!0}function i(){d.current=!1}return e.addEventListener(`blur`,t),fs()&&(e.addEventListener(`keydown`,r,!0),e.addEventListener(`pointerdown`,i,!0)),()=>{e.removeEventListener(`blur`,t),fs()&&(e.removeEventListener(`keydown`,r,!0),e.removeEventListener(`pointerdown`,i,!0))}},[o.domReference,n,s]),R.useEffect(()=>{if(!s)return;function e(e){let{reason:t}=e;(t===`reference-press`||t===`escape-key`)&&(l.current=!0)}return i.on(`openchange`,e),()=>{i.off(`openchange`,e)}},[i,s]),R.useEffect(()=>()=>{_o(u)},[]);let f=R.useMemo(()=>({onMouseLeave(){l.current=!1},onFocus(e){if(l.current)return;let t=ei(e.nativeEvent);if(c&&yn(t)){if(fs()&&!e.relatedTarget){if(!d.current&&!ii(t))return}else if(!oi(t))return}r(!0,e.nativeEvent,`focus`)},onBlur(e){l.current=!1;let t=e.relatedTarget,n=e.nativeEvent,i=yn(t)&&t.hasAttribute(go(`focus-guard`))&&t.getAttribute(`data-type`)===`outside`;u.current=window.setTimeout(()=>{let e=Qr(o.domReference?o.domReference.ownerDocument:document);!t&&e===o.domReference||$r(a.current.floatingContext?.refs.floating.current,e)||$r(o.domReference,e)||i||r(!1,n,`focus`)})}}),[a,o.domReference,r,c]);return R.useMemo(()=>s?{reference:f}:{},[s,f])}function ms(e,t,n){let r=new Map,i=n===`item`,a=e;if(i&&e){let{[Xa]:t,[Za]:n,...r}=e;a=r}return{...n===`floating`&&{tabIndex:-1,[Ya]:``},...a,...t.map(t=>{let r=t?t[n]:null;return typeof r==`function`?e?r(e):null:r}).concat(e).reduce((e,t)=>(t&&Object.entries(t).forEach(t=>{let[n,a]=t;if(!(i&&[Xa,Za].includes(n))){if(n.indexOf(`on`)===0){if(r.has(n)||r.set(n,[]),typeof a==`function`){var o;(o=r.get(n))==null||o.push(a),e[n]=function(){var e=[...arguments];return r.get(n)?.map(t=>t(...e)).find(e=>e!==void 0)}}}else e[n]=a}}),e),{})}}function hs(e){e===void 0&&(e=[]);let t=e.map(e=>e?.reference),n=e.map(e=>e?.floating),r=e.map(e=>e?.item),i=R.useCallback(t=>ms(t,e,`reference`),t),a=R.useCallback(t=>ms(t,e,`floating`),n),o=R.useCallback(t=>ms(t,e,`item`),r);return R.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:o}),[i,a,o])}var gs=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function _s(e,t){t===void 0&&(t={});let{open:n,elements:r,floatingId:i}=e,{enabled:a=!0,role:o=`dialog`}=t,s=lo(),c=r.domReference?.id||s,l=R.useMemo(()=>si(r.floating)?.id||i,[r.floating,i]),u=gs.get(o)??o,d=mo()!=null,f=R.useMemo(()=>u===`tooltip`||o===`label`?{[`aria-`+(o===`label`?`labelledby`:`describedby`)]:n?l:void 0}:{"aria-expanded":n?`true`:`false`,"aria-haspopup":u===`alertdialog`?`dialog`:u,"aria-controls":n?l:void 0,...u===`listbox`&&{role:`combobox`},...u===`menu`&&{id:c},...u===`menu`&&d&&{role:`menuitem`},...o===`select`&&{"aria-autocomplete":`none`},...o===`combobox`&&{"aria-autocomplete":`list`}},[u,l,d,n,c,o]),p=R.useMemo(()=>{let e={id:l,...u&&{role:u}};return u===`tooltip`||o===`label`?e:{...e,...u===`menu`&&{"aria-labelledby":c}}},[u,l,c,o]),m=R.useCallback(e=>{let{active:t,selected:n}=e,r={role:`option`,...t&&{id:l+`-fui-option`}};switch(o){case`select`:case`combobox`:return{...r,"aria-selected":n}}return{}},[l,o]);return R.useMemo(()=>a?{reference:f,floating:p,item:m}:{},[a,f,p,m])}var vs=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?`-`:``)+e.toLowerCase());function ys(e,t){return typeof e==`function`?e(t):e}function bs(e,t){let[n,r]=R.useState(e);return e&&!n&&r(!0),R.useEffect(()=>{if(!e&&n){let e=setTimeout(()=>r(!1),t);return()=>clearTimeout(e)}},[e,n,t]),n}function xs(e,t){t===void 0&&(t={});let{open:n,elements:{floating:r}}=e,{duration:i=250}=t,a=(typeof i==`number`?i:i.close)||0,[o,s]=R.useState(`unmounted`),c=bs(n,a);return!c&&o===`close`&&s(`unmounted`),hi(()=>{if(r){if(n){s(`initial`);let e=requestAnimationFrame(()=>{Ne.flushSync(()=>{s(`open`)})});return()=>{cancelAnimationFrame(e)}}s(`close`)}},[n,r]),{isMounted:c,status:o}}function Ss(e,t){t===void 0&&(t={});let{initial:n={opacity:0},open:r,close:i,common:a,duration:o=250}=t,s=e.placement,c=s.split(`-`)[0],l=R.useMemo(()=>({side:c,placement:s}),[c,s]),u=typeof o==`number`,d=(u?o:o.open)||0,f=(u?o:o.close)||0,[p,m]=R.useState(()=>({...ys(a,l),...ys(n,l)})),{isMounted:h,status:g}=xs(e,{duration:o}),_=_i(n),v=_i(r),y=_i(i),b=_i(a);return hi(()=>{let e=ys(_.current,l),t=ys(y.current,l),n=ys(b.current,l),r=ys(v.current,l)||Object.keys(e).reduce((e,t)=>(e[t]=``,e),{});if(g===`initial`&&m(t=>({transitionProperty:t.transitionProperty,...n,...e})),g===`open`&&m({transitionProperty:Object.keys(r).map(vs).join(`,`),transitionDuration:d+`ms`,...n,...r}),g===`close`){let r=t||e;m({transitionProperty:Object.keys(r).map(vs).join(`,`),transitionDuration:f+`ms`,...n,...r})}},[f,y,_,v,b,d,g,l]),{isMounted:h,styles:p}}function Cs(e,t,n){return n===void 0&&(n=!0),e.filter(e=>e.parentId===t&&(!n||e.context?.open)).flatMap(t=>[t,...Cs(e,t.id,n)])}function ws(e,t){let[n,r]=e,i=!1,a=t.length;for(let e=0,o=a-1;e=r!=l>=r&&n<=(c-a)*(r-s)/(l-s)+a&&(i=!i)}return i}function Ts(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Es(e){e===void 0&&(e={});let{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,i={current:-1},a=!1,o=null,s=null,c=typeof performance<`u`?performance.now():0;function l(e,t){let n=performance.now(),r=n-c;if(o===null||s===null||r===0)return o=e,s=t,c=n,null;let i=e-o,a=t-s,l=Math.sqrt(i*i+a*a)/r;return o=e,s=t,c=n,l}let u=e=>{let{x:n,y:o,placement:s,elements:c,onClose:u,nodeId:d,tree:f}=e;return function(e){function p(){_o(i),u()}if(_o(i),!c.domReference||!c.floating||s==null||n==null||o==null)return;let{clientX:m,clientY:h}=e,g=[m,h],_=Ao(e),v=e.type===`mouseleave`,y=ko(c.floating,_),b=ko(c.domReference,_),x=c.domReference.getBoundingClientRect(),S=c.floating.getBoundingClientRect(),C=s.split(`-`)[0],w=n>S.right-S.width/2,T=o>S.bottom-S.height/2,E=Ts(g,x),D=S.width>x.width,O=S.height>x.height,k=(D?x:S).left,A=(D?x:S).right,j=(O?x:S).top,M=(O?x:S).bottom;if(y&&(a=!0,!v))return;if(b&&(a=!1),b&&!v){a=!0;return}if(v&&yn(e.relatedTarget)&&ko(c.floating,e.relatedTarget)||f&&Cs(f.nodesRef.current,d).length)return;if(C===`top`&&o>=x.bottom-1||C===`bottom`&&o<=x.top+1||C===`left`&&n>=x.right-1||C===`right`&&n<=x.left+1)return p();let N=[];switch(C){case`top`:N=[[k,x.top+1],[k,S.bottom-1],[A,S.bottom-1],[A,x.top+1]];break;case`bottom`:N=[[k,S.top+1],[k,x.bottom-1],[A,x.bottom-1],[A,S.top+1]];break;case`left`:N=[[S.right-1,M],[S.right-1,j],[x.left+1,j],[x.left+1,M]];break;case`right`:N=[[x.right-1,M],[x.right-1,j],[S.left+1,j],[S.left+1,M]]}function P(e){let[n,r]=e;switch(C){case`top`:return[[D?n+t/2:w?n+t*4:n-t*4,r+t+1],[D?n-t/2:w?n+t*4:n-t*4,r+t+1],[S.left,w||D?S.bottom-t:S.top],[S.right,w?D?S.bottom-t:S.top:S.bottom-t]];case`bottom`:return[[D?n+t/2:w?n+t*4:n-t*4,r-t],[D?n-t/2:w?n+t*4:n-t*4,r-t],[S.left,w||D?S.top+t:S.bottom],[S.right,w?D?S.top+t:S.bottom:S.top+t]];case`left`:{let e=[n+t+1,O?r+t/2:T?r+t*4:r-t*4],i=[n+t+1,O?r-t/2:T?r+t*4:r-t*4];return[[T||O?S.right-t:S.left,S.top],[T?O?S.right-t:S.left:S.right-t,S.bottom],e,i]}case`right`:return[[n-t,O?r+t/2:T?r+t*4:r-t*4],[n-t,O?r-t/2:T?r+t*4:r-t*4],[T||O?S.left+t:S.right,S.top],[T?O?S.left+t:S.right:S.left+t,S.bottom]]}}if(!ws([m,h],N)){if(a&&!E)return p();if(!v&&r){let t=l(e.clientX,e.clientY);if(t!==null&&t<.1)return p()}ws([m,h],P([n,o]))?!a&&r&&(i.current=window.setTimeout(p,40)):p()}}};return u.__options={blockPointerEvents:n},u}function W(e,t){let n=(t?.editor??B()).getExtension(e);if(!n)throw Error(`Extension not found`,{cause:{plugin:e}});return n}function G(e,t){let{store:n}=W(e,t);if(!n)throw Error(`Store not found on plugin`,{cause:{plugin:e}});return Le(n,t?.selector,t?.equalityFn)}function Ds(e){let t=new DOMRect,n=`getBoundingClientRect`in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(t=n()),t):n()}function Os(e,t){return e?t?(n,r,i)=>{let a=e(n,r,i),o=t(n,r,i);return()=>{a?.(),o?.()}}:e:t}var ks=e=>{let t=B(),n=Je(),{whileElementsMounted:r,middleware:i,...a}=e.useFloatingOptions??{},{refs:o,floatingStyles:s,context:c,middlewareData:l}=ds({whileElementsMounted:Os(xa,e.useFloatingOptions?.whileElementsMounted),middleware:[...i??[],Ga()],...a}),{isMounted:u,styles:d}=Ss(c,e.useTransitionStylesProps),{status:f}=xs(c,e.useTransitionStatusProps),{getFloatingProps:p}=hs([ls(c,e.useDismissProps),xo(c,{enabled:!1,...e.useHoverProps})]),m=(0,R.useRef)(``),h=(0,R.useRef)(null),g=Ja([h,o.setFloating]);if((0,R.useEffect)(()=>{if(e.reference){let n=`element`in e.reference?e.reference.element:void 0;n!==void 0&&(e.focusManagerProps?.disabled||!t.isWithinEditor(n))&&o.setReference(n);let r=`getClientRects`in e.reference?e.reference.getClientRects:n?()=>n.getClientRects():void 0;o.setPositionReference({getBoundingClientRect:Ds(e.reference),...r?{getClientRects:r}:{},contextElement:n})}},[e.reference,o,e.focusManagerProps?.disabled,t]),(0,R.useEffect)(()=>{(f===`initial`||f===`open`)&&h.current&&tt(h.current)&&(m.current=h.current.innerHTML)},[f,e.reference,e.children]),!u||!n)return!1;let _={...e.elementProps,style:{display:`flex`,...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...d,...l.hide?.referenceHidden?{visibility:`hidden`}:{}},...p()};return f===`close`?(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(`div`,{ref:g,..._,dangerouslySetInnerHTML:{__html:m.current}})}):e.focusManagerProps?.disabled?(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(`div`,{ref:g,..._,children:(0,z.jsx)(nt,{children:e.children})})}):(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(as,{...e.focusManagerProps,context:c,children:(0,z.jsx)(`div`,{ref:g,..._,children:(0,z.jsx)(nt,{children:e.children})})})})},As=e=>{let{position:t,children:n,...r}=e,{from:i,to:a}=t||{},o=B(),s=Ue(),c=(0,R.useMemo)(()=>{if(i!==void 0&&a!==void 0)return{element:s?.firstElementChild||void 0,getBoundingClientRect:()=>he(o.prosemirrorView,i,a??i)}},[o,s,i,a]);return(0,z.jsx)(ks,{reference:c,...r,children:t!==void 0&&n})},js=(e={},t=[])=>(0,R.useMemo)(()=>{let t=L.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},t),Ms=e=>{let[t,n]=(0,R.useState)(!1),r=He({editor:e.editor,selector:({editor:e})=>e.isEmpty}),i=V(),a=(0,R.useCallback)(()=>{n(!0)},[]),o=(0,R.useCallback)(()=>{n(!1)},[]);return(0,R.useEffect)(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i.Comments.Editor,{autoFocus:e.autoFocus,className:`bn-comment-editor`,editor:e.editor,onFocus:a,onBlur:o,editable:e.editable}),e.actions&&(0,z.jsx)(`div`,{className:`bn-comment-actions-wrapper`,children:e.actions({isFocused:t,isEmpty:r})})]})},{textColor:Ns,backgroundColor:Ps,...Fs}=we,Is=re.create({blockSpecs:{paragraph:Te()},styleSpecs:Fs});function Ls(e){return!e.hasUnsavedContent||!e.confirmBeforeDiscard||(e.confirm??(e=>window.confirm(e)))(e.message)}var Rs=se(({editor:e,options:{submitOnEnter:t=!0,onSubmit:n}})=>{let r=!1;async function i(){if(!(!e.isEditable||e.isEmpty||r)){r=!0;try{await n(e)}finally{r=!1}}}function a({event:t}){let n=e.prosemirrorView;return!n.editable||n.composing||t.isComposing||t.keyCode===229?!1:(t.repeat||i(),!0)}return{key:`commentEditorSubmit`,submit:i,runsBefore:[`default`],keyboardShortcuts:{"Mod-Enter":a,...t?{Enter:a}:{}}}}),zs=g.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:D,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,ne(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),Bs=new Ce(`blocknote-comments`);function Vs(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var Hs=se(({editor:e,options:{schema:t,threadStore:n,resolveUsers:r,confirmBeforeDiscard:i=!0,submitOnEnter:a=!0}})=>{if(!r)throw Error(`resolveUsers is required to be defined when using comments`);if(!n)throw Error(`threadStore is required to be defined when using comments`);let o=Se(r),s=zs.name,c=_e({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(t,n){t.selectedThreadId!==n.selectedThreadId&&e.transact(e=>e.setMeta(Bs,!0))}}),l=t=>{e.transact(e=>{e.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===s){let a=i.type,o=i.attrs.threadId,s=t.get(o),l=!!(!s||s.resolved||s.deletedAt);if(l!==i.attrs.orphan){let t=Math.max(r,0),s=Math.min(r+n.nodeSize,e.doc.content.size-1,e.doc.content.size-1);e.removeMark(t,s,i),e.addMark(t,s,a.create({...i.attrs,orphan:l})),l&&c.state.selectedThreadId===o&&c.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:c,userStore:o,runsBefore:[`link`],tiptapExtensions:[zs],prosemirrorPlugins:[new fe({key:Bs,state:{init(){return{decorations:ie.empty}},apply(e,t){let n=e.getMeta(Bs);if(!e.docChanged&&!n)return t;let r=e.docChanged?Vs(e.doc,s):c.state.threadPositions;(r.size>0||c.state.threadPositions.size>0)&&c.setState(e=>({...e,threadPositions:r}));let i=[];if(c.state.selectedThreadId){let e=r.get(c.state.selectedThreadId);e&&i.push(xe.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:ie.create(e.doc,i)}}},props:{decorations(e){return Bs.getState(e)?.decorations??ie.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return c.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===s&&e.attrs.orphan!==!0);if(!i)return c.state.selectedThreadId!==void 0&&c.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a!==c.state.selectedThreadId&&(c.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:n,mount(){let t=n.subscribe(l);l(n.getThreads());let r=e.onSelectionChange(()=>{c.state.pendingComment&&c.setState(e=>({...e,pendingComment:!1}))});return()=>{t(),r()}},selectThread(t,n=!0){if(c.state.selectedThreadId!==t&&(c.setState(e=>({...e,pendingComment:!1,selectedThreadId:t})),t&&n)){let n=c.state.threadPositions.get(t);if(!n)return;(e.prosemirrorView?.domAtPos(n.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),e.domElement?.focus(),e.getExtension(ae)?.showSelection(!0,`comments`)},stopPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),e.getExtension(ae)?.showSelection(!1,`comments`)},async createThread(t){let r=await n.createThread(t);n.addThreadToDocument?await n.addThreadToDocument({threadId:r.id,selection:e.transact(e=>e.selection),editor:e}):e._tiptapEditor.commands.setMark(s,{orphan:!1,threadId:r.id})},commentEditorSchema:t,confirmBeforeDiscard:i,submitOnEnter:a}}),Us=Object.defineProperty,Ws=(e,t)=>{for(var n in t)Us(e,n,{get:t[n],enumerable:!0})},Gs={};Ws(Gs,{ActiveEmoji:()=>Gl,Empty:()=>Wl,List:()=>Bl,Loading:()=>Hl,Root:()=>Sl,Search:()=>Cl,SkinTone:()=>Kl,SkinToneSelector:()=>Vl,Viewport:()=>Tl});var Ks=`'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif`,qs=[`none`,`light`,`medium-light`,`medium`,`medium-dark`,`dark`];function Js(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ys=2,Xs=null;function Zs(e){try{Xs??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0})}catch{}if(!Xs||(queueMicrotask(()=>{Xs&&=null}),Xs.canvas.width=Ys,Xs.canvas.height=Ys,Xs.font=`2px ${Ks}`,Xs.textBaseline=`middle`,Xs.measureText(e).width>=Ys*2))return!1;Xs.fillStyle=`#00f`,Xs.fillText(e,0,0);let t=Xs.getImageData(0,0,Ys,Ys).data;Xs.clearRect(0,0,Ys,Ys),Xs.fillStyle=`#f00`,Xs.fillText(e,0,0);let n=Xs.getImageData(0,0,Ys,Ys).data;for(let e=0;et===void 0?void 0:e(t)}function tc(e){if(typeof e!=`string`)throw Error();return e}function nc(e){if(typeof e!=`number`)throw Error();return e}function rc(e){if(typeof e!=`boolean`)throw Error();return e}function ic(e){return t=>{if(typeof t!=`object`||!t)throw Error();let n={};for(let r in e){let i=t[r];i===void 0&&e[r](void 0),n[r]=e[r](i)}return n}}function ac(e){return t=>{if(!Array.isArray(t))throw Error();return t.length>0&&e(t[0]),t}}var oc=`frimousse/data`,sc=ic({locale:tc,emojis:ac(ic({emoji:tc,category:nc,label:tc,version:nc,tags:ac(tc),aliases:ec(ac(tc)),countryFlag:ec(rc),skins:ec(ic({light:tc,"medium-light":tc,medium:tc,"medium-dark":tc,dark:tc}))})),categories:ac(ic({index:nc,label:tc})),skinTones:ic({light:tc,"medium-light":tc,medium:tc,"medium-dark":tc,dark:tc})});function cc({name:e=oc}={}){let t=`${e}/`,n=ic({data:sc,metadata:e=>e});return{get(e){try{return Qs(localStorage,`${t}${e}`,n)}catch{return null}},set(e,n,...[r]){try{$s(localStorage,`${t}${e}`,{data:n,metadata:r})}catch{}},delete(e){try{localStorage.removeItem(`${t}${e}`)}catch{}},clear(){try{for(let e of Object.keys(localStorage))e.startsWith(t)&&localStorage.removeItem(e)}catch{}}}}var lc=new Map,uc=new WeakMap,dc=new Set;function fc({emojiVersion:e,emojibaseUrl:t}){return t??(typeof e==`number`?`https://cdn.jsdelivr.net/npm/emojibase-data@${Math.floor(e)}`:`https://cdn.jsdelivr.net/npm/emojibase-data@latest`)}function pc(e,t){return(t.resolveEmojiData?uc.get(t.resolveEmojiData):lc)?.get(gc(e,t))?.data}function mc(e,t,n){let r=_c(e,t),i=r.load?.status===`pending`?r.load:void 0;r.data=n,r.load=void 0,i?.complete();for(let e of dc)e()}async function hc(e,t,n){n.signal?.throwIfAborted();let r=await e(t,n);return n.signal?.throwIfAborted(),mc(t,{...n,resolveEmojiData:e},r),r}function gc(e,t){return t.resolveEmojiData?JSON.stringify([e,t.emojibaseUrl,t.emojiVersion]):JSON.stringify([e,fc(t)])}function _c(e,t){let n=lc;if(t.resolveEmojiData){let e=uc.get(t.resolveEmojiData);n=e??new Map,e||uc.set(t.resolveEmojiData,n)}let r=gc(e,t),i=n.get(r);return i||(i={},n.set(r,i)),i}var vc=(e,t)=>`${e}/${t}/data.json`,yc=(e,t)=>`${e}/${t}/messages.json`,bc=`bn.da.de.en-gb.en.es-mx.es.et.fi.fr.hi.hu.it.ja.ko.lt.ms.nb.nl.pl.pt.ru.sv.th.uk.vi.zh-hant.zh`.split(`.`),xc=`en`,Sc=e=>`frimousse/metadata/${e}`,Cc=new Map;function wc(e){return cc({name:`frimousse/data/${e}`})}async function Tc(e,t){try{return(await fetch(e,{method:`HEAD`,signal:t})).headers.get(`etag`)}catch{return null}}async function Ec(e,t,n){let[{emojis:r,emojisEtag:i},{messages:a,messagesEtag:o}]=await Promise.all([fetch(vc(e,t),{signal:n}).then(async e=>({emojis:await e.json(),emojisEtag:e.headers.get(`etag`)})),fetch(yc(e,t),{signal:n}).then(async e=>({messages:await e.json(),messagesEtag:e.headers.get(`etag`)}))]);return{emojis:r,messages:a,emojisEtag:i,messagesEtag:o}}async function Dc(e,t,n){let[r,i]=await Promise.all([Tc(vc(e,t),n),Tc(yc(e,t),n)]);return{emojisEtag:r,messagesEtag:i}}function Oc(e){return e.skins?e.skins.filter(e=>typeof e.tone==`number`).reduce((e,t)=>{let n=qs[t.tone];return e[n]=t.emoji,e},{}):void 0}async function kc(e,t,n){let{emojis:r,emojisEtag:i,messages:a,messagesEtag:o}=await Ec(e,t,n);n?.throwIfAborted();let s=a.subgroups.find(e=>e.key===`country-flag`||e.key===`subdivision-flag`),c=a.groups.filter(e=>e.key!==`component`),l=r.filter(e=>`group`in e),u=c.map(e=>({index:e.order,label:Js(e.message)})),d=a.skinTones.reduce((e,t)=>(e[t.key]=Js(t.message),e),{}),f={locale:t,emojis:l.map(e=>{let t=e.skins?.filter(e=>Array.isArray(e.tone)).map(e=>e.emoji);return{emoji:e.emoji,category:e.group,version:e.version,label:Js(e.label),tags:e.tags??[],countryFlag:s&&e.subgroup===s.order||void 0,skins:Oc(e),aliases:t?.length?t:void 0}}),categories:u,skinTones:d};return wc(e).set(t,f,{emojisEtag:i,messagesEtag:o}),f}function Ac(e){let t=new Map;for(let n of e)t.has(n.version)||t.set(n.version,n.emoji);let n=[...t.keys()].sort((e,t)=>t-e),r=n[0]??0,i=Zs(`🇪🇺`);for(let e of n)if(Zs(t.get(e)))return{emojiVersion:e,countryFlags:i};return{emojiVersion:r,countryFlags:i}}var jc=ic({emojiVersion:ec(nc),countryFlags:ec(rc),revalidated:ac(tc)});function Mc(e){try{return Qs(sessionStorage,Sc(e),jc)}catch{return null}}function Nc(e,t){try{$s(sessionStorage,Sc(e),t)}catch{}}function Pc(e,t,n){if(n?.aborted)return Promise.reject(n.reason);let r=vc(e,t),i=pc(t,{emojibaseUrl:e});if(i)return Promise.resolve(i);let a=Cc.get(r);if(!a||a.controller.signal.aborted){let n=new AbortController,i=Fc(e,t,n.signal).then(r=>(n.signal.throwIfAborted(),mc(t,{emojibaseUrl:e},r),r)).finally(()=>{Cc.get(r)?.promise===i&&Cc.delete(r)});a={promise:i,controller:n,callers:0},Cc.set(r,a)}let o=a;o.callers++;let s;return new Promise((e,t)=>{s=()=>t(n?.reason),n?.addEventListener(`abort`,s,{once:!0}),o.promise.then(e,t)}).finally(()=>{n?.removeEventListener(`abort`,s),o.callers--,o.callers===0&&Cc.get(r)===o&&o.controller.abort()})}async function Fc(e,t,n){let r=Mc(e),i=wc(e).get(t),a;if(!i)a=await kc(e,t,n);else if(r?.revalidated.includes(t))a=i.data;else try{let{emojisEtag:r,messagesEtag:o}=await Dc(e,t,n);n.throwIfAborted(),a=!r||!o||r!==i.metadata?.emojisEtag||o!==i.metadata?.messagesEtag?await kc(e,t,n):i.data}catch{n.throwIfAborted(),a=i.data}n.throwIfAborted();let o=Mc(e),s=o?.revalidated??[];return Nc(e,{...o,revalidated:s.includes(t)?s:[...s,t]}),a}var Ic=async(e,{emojiVersion:t,emojibaseUrl:n,signal:r}={})=>{let i=Lc(e),a=fc({emojiVersion:t,emojibaseUrl:n}),o=await Pc(a,i,r);r?.throwIfAborted();let s=Mc(a),c=s?.emojiVersion!==void 0&&s.countryFlags!==void 0?{emojiVersion:s.emojiVersion,countryFlags:s.countryFlags}:Ac(o.emojis);return Nc(a,{...c,revalidated:s?.revalidated??[i]}),{locale:i,emojis:o.emojis.filter(e=>{let n=e.version<=(t??c.emojiVersion);return e.countryFlag?n&&c.countryFlags:n}),categories:o.categories,skinTones:o.skinTones}};function Lc(e){return bc.find(t=>t===e)||(console.warn(`Locale "${e}" is not supported, using "${xc}" instead.`),xc)}function Rc(e){return qs.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),`none`)}function zc(e,t){let n=[];if(t<=0)return n;for(let r=0,i=e.length;r{let t=0;e.label.toLowerCase().includes(n)&&(t+=10);for(let r of e.tags)r.toLowerCase().includes(n)&&(t+=1);return t>0&&(r.set(e,t),!0)}).sort((e,t)=>(r.get(t)??0)-(r.get(e)??0))}function Vc(e,t,n,r){let i=Bc(e.emojis,r),a=[],o=[],s=[],c={},l=0,u=0;for(let e of i)c[e.category]||(c[e.category]=[]),c[e.category].push({emoji:n&&n!==`none`&&e.skins?e.skins[n]:e.emoji,label:e.label});for(let n of e.categories){let e=c[n.index];if(!e||e.length===0)continue;let r=zc(Array.from(e),t).map(e=>({categoryIndex:l,emojis:e}));a.push(...r),o.push({label:n.label,rowsCount:r.length,startRowIndex:u}),s.push(u),l++,u+=r.length}return{count:i.length,categories:o,categoriesStartRowIndices:s,rows:a,skinTones:e.skinTones}}function Hc(e){let t={},n=null,r=null,i=new Set,a=()=>{if(n){t=n,n=null;for(let e of i)e(t)}r=null},o=()=>n??t,s=e=>{n??=t,Object.assign(n,typeof e==`function`?e(o()):e),r||=requestAnimationFrame(a)};return t=e(s,o),{get:o,set:s,subscribe:e=>(i.add(e),()=>i.delete(e))}}function Uc(e){let[t]=(0,R.useState)(e);return t}function Wc(e){let t=(0,R.createContext)(null);return{useStore:()=>{let n=(0,R.useContext)(t);if(!n)throw Error(e);return n},Provider:({store:e,children:n})=>(0,z.jsx)(t.Provider,{value:e,children:n})}}function Gc(e,t,n=Object.is){let[r,i]=(0,R.useState)(()=>t(e.get()));return(0,R.useEffect)(()=>e.subscribe(()=>{let r=t(e.get());i(e=>n(e,r)?e:r)}),[e,t,n]),(0,R.useDebugValue)(r),r}function Kc(e,t,n){return Gc(e,(0,R.useCallback)(e=>e[t],[t]),n)}var qc=2;function Jc(e,t,n,r,i){let a=0;return Hc((o,s)=>({locale:t,columns:n,sticky:r,skinTone:i,onEmojiSelect:e,data:null,search:``,interaction:`none`,activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:e=>{let t=s(),n=e?.data??t.data,r=e?.categoryHeaderHeight??t.categoryHeaderHeight,i=e?.rowHeight??t.rowHeight,c=e?.viewportHeight??t.viewportHeight;if(!n||n.rows.length===0||!r||!i||!c)return o({...e,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let l=0,u=0;for(let e of n.categories)if(u++*r+e.startRowIndex*i{s().updateViewportState({data:e,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:e=>{o({search:e,interaction:e?`keyboard`:`none`})},onActiveEmojiChange:(e,t,n)=>{if(o({interaction:e,activeColumnIndex:t,activeRowIndex:n}),e!==`keyboard`)return;let{listRef:r,viewportRef:i,sticky:c,rowHeight:l,viewportHeight:u,categoryHeaderHeight:d}=s(),f=r?.current,p=i?.current;if(!f||!p||!l||!d||!u)return;let m=n;m===0&&p.scrollTo({top:0,behavior:`instant`});let h=f.querySelector(`[aria-rowindex="${m}"]`);if(!(h instanceof HTMLElement))return;let g=h.offsetTop,_=getComputedStyle(h),v=Number.parseFloat(_.scrollMarginTop),y=Number.parseFloat(_.scrollMarginBottom),b=a+v;c&&gx)&&p.scrollTo({top:Math.max(g{o({interaction:`none`,activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:e=>{s().updateViewportState({rowHeight:e})},onCategoryHeaderHeightChange:e=>{s().updateViewportState({categoryHeaderHeight:e})},onViewportSizeChange:(e,t)=>{s().updateViewportState({viewportWidth:e,viewportHeight:t})},onViewportScroll:e=>{a=e,s().updateViewportState()}}))}var{useStore:Yc,Provider:Xc}=Wc(`EmojiPicker.Root is missing.`);function Zc(e){return e.search}function Qc(e){return e.interaction===`none`?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function $c(e){return e.data===void 0||typeof e.data?.count==`number`&&e.data.count===0}function el(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function tl(e){return e.data?.rows.length}function nl(e){return e.data?.categories.length}function rl(e){return e.data?.categoriesStartRowIndices}function il(e){return e.data?.skinTones}function al(e,t){return e?.emoji===t?.emoji}function ol(e,t){return e?.categoryIndex!==t?.categoryIndex||e?.emojis.length!==t?.emojis.length?!1:!!e?.emojis.every((e,n)=>al(e,t?.emojis[n]))}var sl=`‍`,cl=/\p{Emoji_Modifier_Base}/u,ll=/\uFE0F$/,ul=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,dl={light:`🏻`,"medium-light":`🏼`,medium:`🏽`,"medium-dark":`🏾`,dark:`🏿`};function fl(e,t){if(!e.split(sl).some(e=>cl.test(e)))return e;let n=e.split(sl).map(e=>e.replace(ul,``)).join(sl);return t===`none`?n:n.split(sl).map((e,n,r)=>{let i=r.length>1;return!cl.test(e)||i&&e===`🤝`?e:e.replace(ll,``)+dl[t]}).join(sl)}function pl(e){return qs.map(t=>({skinTone:t,emoji:fl(e,t)}))}function ml(){let e=Gc(Yc(),Qc,al);return(0,R.useDeferredValue)(e)}function hl(e=`✋`){let t=Yc(),n=Kc(t,`skinTone`),r=(0,R.useMemo)(()=>pl(e),[e]);return[n,(0,R.useCallback)(e=>{t.set({skinTone:e})},[]),r]}function gl(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>n in t&&e[n]===t[n])}function _l(...e){}function vl(e,t){let n=null;if(typeof window.requestIdleCallback==`function`)n=window.requestIdleCallback(e,t);else{let r=Date.now();n=window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,(t?.timeout??50)-(Date.now()-r))})},10)}return()=>{typeof window.cancelIdleCallback==`function`?window.cancelIdleCallback(n):window.clearTimeout(n)}}var yl=typeof window<`u`?R.useLayoutEffect:R.useEffect;function bl(e){let t=(0,R.useRef)(e);return yl(()=>{t.current=e}),(0,R.useCallback)((...e)=>t.current(...e),[])}function xl({emojiVersion:e,emojibaseUrl:t,resolveEmojiData:n=Ic}){let[r,i]=(0,R.useState)(void 0),a=Yc(),o=Kc(a,`locale`),s=Kc(a,`columns`),c=Kc(a,`skinTone`),l=Kc(a,`search`),u=bl((e,t)=>n===Ic?Ic(e,t):hc(n,e,t));return(0,R.useEffect)(()=>{let n=new AbortController,r=n.signal;return Promise.resolve().then(()=>u(o,{emojiVersion:e,emojibaseUrl:t,signal:r})).then(e=>{r.aborted||i(e)}).catch(e=>{r.aborted||console.error(e)}),()=>{n.abort()}},[e,t,o,u]),(0,R.useEffect)(()=>{if(r)return vl(()=>{a.get().onDataChange(Vc(r,s,c,l))},{timeout:100})},[r,s,c,l]),null}var Sl=(0,R.forwardRef)(({locale:e=`en`,columns:t=9,skinTone:n=`none`,onEmojiSelect:r=_l,emojiVersion:i,emojibaseUrl:a,resolveEmojiData:o,onFocusCapture:s,onBlurCapture:c,children:l,style:u,sticky:d=!0,...f},p)=>{let m=bl(r),h=Uc(()=>Jc(m,e,t,d,Rc(n))),[g,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),y=(0,R.useCallback)(e=>{e&&(v.current=e,h.set({rootRef:v}))},[]);yl(()=>{h.set({locale:e})},[e]),yl(()=>{h.set({columns:t})},[t]),yl(()=>{h.set({sticky:d})},[d]),yl(()=>{h.set({skinTone:Rc(n)})},[n]);let b=(0,R.useCallback)(e=>{s?.(e);let{searchRef:t,viewportRef:n}=h.get(),r=e.target===t?.current||e.target.hasAttribute(`frimousse-search`),i=e.target===n?.current||e.target.hasAttribute(`frimousse-viewport`);e.isDefaultPrevented()||(_(r||i),e.isDefaultPrevented()||(_(r||i),i?h.get().onActiveEmojiChange(`keyboard`,0,0):r&&h.get().search===``&&h.set({interaction:`none`})))},[s]),x=(0,R.useCallback)(e=>{c?.(e),!e.isDefaultPrevented()&&!e.currentTarget.contains(e.relatedTarget)&&_(!1)},[c]);return yl(()=>{g||h.get().onActiveEmojiReset()},[g]),(0,R.useImperativeHandle)(p,()=>v.current),(0,R.useEffect)(()=>{if(!g)return;function e(e){if(e.defaultPrevented||!e.key.startsWith(`Arrow`)&&e.key!==`Enter`)return;let{data:t,onEmojiSelect:n,onActiveEmojiChange:r,interaction:i,activeColumnIndex:a,activeRowIndex:o}=h.get();if(e.key===`Enter`){let t=Qc(h.get());t&&(e.preventDefault(),n(t))}if(e.key.startsWith(`Arrow`)){let n=a,s=o;if(e.preventDefault(),i!==`none`){if(t?.rows&&t.rows.length>0)switch(e.key){case`ArrowLeft`:if(n===0){let e=s-1,r=t.rows[e];r&&(s=e,n=r.emojis.length-1)}else--n;break;case`ArrowRight`:if(n===t.rows[s].emojis.length-1){let e=s+1;t.rows[e]&&(s=e,n=0)}else n+=1;break;case`ArrowUp`:{let e=t.rows[s-1];e&&(--s,e.emojis[n]||(n=e.emojis.length-1));break}case`ArrowDown`:{let e=t.rows[s+1];e&&(s+=1,e.emojis[n]||(n=e.emojis.length-1));break}}r(`keyboard`,n,s)}else r(`keyboard`,0,0)}}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[g]),yl(()=>{let e=null,t=null,n=null,r=null,i=h.subscribe(i=>{v.current&&(e!==i.viewportWidth&&(e=i.viewportWidth,v.current.style.setProperty(`--frimousse-viewport-width`,`${i.viewportWidth}px`)),t!==i.viewportHeight&&(t=i.viewportHeight,v.current.style.setProperty(`--frimousse-viewport-height`,`${i.viewportHeight}px`)),n!==i.rowHeight&&(n=i.rowHeight,v.current.style.setProperty(`--frimousse-row-height`,`${i.rowHeight}px`)),r!==i.categoryHeaderHeight&&(r=i.categoryHeaderHeight,v.current.style.setProperty(`--frimousse-category-header-height`,`${i.categoryHeaderHeight}px`)))}),{viewportWidth:a,viewportHeight:o,rowHeight:s,categoryHeaderHeight:c}=h.get();return a&&v.current.style.setProperty(`--frimousse-viewport-width`,`${a}px`),o&&v.current.style.setProperty(`--frimousse-viewport-height`,`${o}px`),s&&v.current.style.setProperty(`--frimousse-row-height`,`${s}px`),c&&v.current.style.setProperty(`--frimousse-category-header-height`,`${c}px`),i},[]),(0,z.jsx)(`div`,{"data-focused":g?``:void 0,"frimousse-root":``,onBlurCapture:x,onFocusCapture:b,...f,ref:y,style:{"--frimousse-emoji-font":Ks,...u},children:(0,z.jsxs)(Xc,{store:h,children:[(0,z.jsx)(xl,{emojibaseUrl:a,emojiVersion:i,resolveEmojiData:o}),l]})})}),Cl=(0,R.forwardRef)(({value:e,defaultValue:t,onChange:n,...r},i)=>{let a=Yc(),o=(0,R.useRef)(null),s=(0,R.useCallback)(e=>{e&&(o.current=e,a.set({searchRef:o}))},[]),c=typeof e==`string`,l=(0,R.useRef)(c);(0,R.useEffect)(()=>{l.current=c},[c]),yl(()=>{a.set({search:typeof e==`string`?e:typeof t==`string`?t:``})},[]),yl(()=>{typeof e==`string`&&a.get().onSearchChange(e)},[e]);let u=(0,R.useCallback)(e=>{n?.(e),e.isDefaultPrevented()||a.get().onSearchChange(e.target.value)},[n]);return(0,R.useImperativeHandle)(i,()=>o.current),(0,z.jsx)(`input`,{autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,enterKeyHint:`done`,"frimousse-search":``,placeholder:`Search…`,spellCheck:!1,type:`search`,...r,defaultValue:t,onChange:u,ref:s,value:e})}),wl=(0,R.memo)(()=>{let e=ml();return e?(0,z.jsx)(`div`,{"aria-live":`polite`,style:{border:0,clip:`rect(0, 0, 0, 0)`,height:1,margin:-1,overflow:`hidden`,padding:0,position:`absolute`,whiteSpace:`nowrap`,width:1,wordWrap:`normal`},children:e.label}):null}),Tl=(0,R.forwardRef)(({children:e,onScroll:t,onKeyDown:n,style:r,...i},a)=>{let o=Yc(),s=(0,R.useRef)(null),c=(0,R.useCallback)(e=>{e&&(s.current=e,o.set({viewportRef:s}))},[]),l=Gc(o,tl),u=Gc(o,nl),d=(0,R.useCallback)(e=>{t?.(e),o.get().onViewportScroll(e.currentTarget.scrollTop)},[t]);return yl(()=>{if(!s.current)return;let e=new ResizeObserver(([e])=>{let t=e?.borderBoxSize[0]?.inlineSize??0,n=e?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:r,viewportHeight:i,viewportWidth:a}=o.get();(i!==n||a!==t)&&r(t,n)});return e.observe(s.current),o.get().onViewportSizeChange(s.current.offsetWidth,s.current.clientHeight),()=>{e.disconnect()}},[]),(0,R.useImperativeHandle)(a,()=>s.current),(0,z.jsxs)(`div`,{"frimousse-viewport":``,...i,onScroll:d,ref:c,style:{position:`relative`,boxSizing:`border-box`,contain:`layout paint`,containIntrinsicSize:typeof l==`number`&&typeof u==`number`?`var(--frimousse-viewport-width, auto) calc(${l} * var(--frimousse-row-height) + ${u} * var(--frimousse-category-header-height))`:void 0,overflowY:`auto`,overscrollBehavior:`contain`,scrollbarGutter:`stable`,willChange:`scroll-position`,...r},children:[(0,z.jsx)(wl,{}),e]})});function El(e,t,n){return{emoji:{...e,isActive:n},role:`gridcell`,"aria-colindex":t,"aria-selected":n||void 0,"aria-label":e.label,"data-active":n?``:void 0,"frimousse-emoji":``,style:{fontFamily:`var(--frimousse-emoji-font)`},tabIndex:-1}}function Dl(e,t=!1){return{role:t?void 0:`row`,"aria-rowindex":t?void 0:e,"frimousse-row":``,style:{contain:t?void 0:`content`,height:t?void 0:`var(--frimousse-row-height)`,display:`flex`}}}function Ol(e,t){return{"frimousse-category":``,style:{contain:`content`,top:t?`calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))`:void 0,height:t?`calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))`:void 0,width:`100%`,pointerEvents:`none`,position:`absolute`}}}function kl(e,t=!1,n=!0){return{category:e,"frimousse-category-header":``,style:{contain:t?void 0:`layout paint`,height:t?void 0:`var(--frimousse-category-header-height)`,pointerEvents:`auto`,position:n?`sticky`:void 0,top:0}}}function Al(e,t,n,r){return{"frimousse-list-sizer":``,style:{position:`relative`,boxSizing:`border-box`,height:`calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,paddingTop:`calc(${n} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`}}}function jl(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":``,style:{"--frimousse-list-columns":e,...n},role:`grid`}}function Ml(e){e.preventDefault()}var Nl=(0,R.memo)(({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let i=Yc(),a=Gc(i,e=>Qc(e)?.emoji===t.emoji),o=(0,R.useCallback)(()=>{i.get().onEmojiSelect(t)},[t]),s=(0,R.useCallback)(()=>{i.get().onActiveEmojiChange(`pointer`,n,r)},[n,r]),c=(0,R.useCallback)(()=>{i.get().onActiveEmojiReset()},[]);return(0,z.jsx)(e,{...El(t,n,a),onClick:o,onPointerDown:Ml,onPointerEnter:s,onPointerLeave:c})}),Pl=(0,R.memo)(({Row:e,Emoji:t,rowIndex:n})=>{let r=Gc(Yc(),e=>e.data?.rows[n],ol);return r?(0,z.jsx)(e,{...Dl(n),children:r.emojis.map((e,r)=>(0,z.jsx)(Nl,{columnIndex:r,Emoji:t,emoji:e,rowIndex:n},e.label))}):null}),Fl=(0,R.memo)(({CategoryHeader:e,categoryIndex:t})=>{let n=Yc(),r=Gc(n,e=>e.data?.categories[t],gl),i=Kc(n,`sticky`);return r?(0,z.jsx)(`div`,{...Ol(t,r),children:(0,z.jsx)(e,{...kl({label:r.label},!1,i)})}):null}),Il=(0,R.memo)(({CategoryHeader:e,Row:t,Emoji:n})=>{let r=(0,R.useRef)(null),i=Yc(),a=Kc(i,`columns`),o=(0,R.useMemo)(()=>Array(a).fill({emoji:`🙂`,label:``}),[a]),s=(0,R.useMemo)(()=>({label:`Category`}),[]),c=(0,R.useRef)(null),l=(0,R.useRef)(null);return yl(()=>{let e=r.current?.parentElement?.parentElement;if(!e||!c.current||!l.current)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.height,{onRowHeightChange:n,onCategoryHeaderHeightChange:r,rowHeight:a,categoryHeaderHeight:o}=i.get();t.target===c.current&&a!==e&&n(e),t.target===l.current&&o!==e&&r(e)}});t.observe(e),t.observe(c.current),t.observe(l.current);let{onRowHeightChange:n,onCategoryHeaderHeightChange:a}=i.get();return n(c.current.clientHeight),a(l.current.clientHeight),()=>{t.disconnect()}},[]),(0,z.jsxs)(`div`,{"aria-hidden":!0,ref:r,style:{height:0,visibility:`hidden`},children:[(0,z.jsx)(`div`,{"frimousse-row-sizer":``,ref:c,children:(0,z.jsx)(t,{...Dl(-1,!0),children:o.map((e,t)=>(0,z.jsx)(n,{...El(e,t,!1)},t))})}),(0,z.jsx)(`div`,{...Ol(-1),children:(0,z.jsx)(`div`,{"frimousse-category-header-sizer":``,ref:l,children:(0,z.jsx)(e,{...kl(s,!0)})})})]})});function Ll({category:e,...t}){return(0,z.jsx)(`div`,{...t,children:e.label})}function Rl({emoji:e,...t}){return(0,z.jsx)(`button`,{type:`button`,...t,children:e.emoji})}function zl({...e}){return(0,z.jsx)(`div`,{...e})}var Bl=(0,R.forwardRef)(({style:e,components:t,...n},r)=>{let i=Yc(),a=(0,R.useRef)(null),o=(0,R.useCallback)(e=>{e&&(a.current=e,i.set({listRef:a}))},[]),s=t?.CategoryHeader??Ll,c=t?.Emoji??Rl,l=t?.Row??zl,u=Kc(i,`columns`),d=Kc(i,`viewportStartRowIndex`),f=Kc(i,`viewportEndRowIndex`),p=Gc(i,tl),m=Gc(i,rl,gl),h=(0,R.useMemo)(()=>m?.filter(e=>ea.current),!p||!m||g===0?(0,z.jsx)(`div`,{...jl(u,0,e),...n,children:(0,z.jsx)(`div`,{...Al(0,0,0,0),children:(0,z.jsx)(Il,{CategoryHeader:s,Emoji:c,Row:l})})}):(0,z.jsx)(`div`,{...jl(u,p,e),...n,ref:o,children:(0,z.jsxs)(`div`,{...Al(p,g,d,h),children:[(0,z.jsx)(Il,{CategoryHeader:s,Emoji:c,Row:l}),Array.from({length:f-d+1},(e,t)=>{let n=d+t,r=m.indexOf(n);return(0,z.jsxs)(R.Fragment,{children:[r>=0&&(0,z.jsx)(`div`,{style:{height:`var(--frimousse-category-header-height)`}}),(0,z.jsx)(Pl,{Emoji:c,Row:l,rowIndex:n})]},n)}),Array.from({length:g},(e,t)=>(0,z.jsx)(Fl,{CategoryHeader:s,categoryIndex:t},t))]})})}),Vl=(0,R.forwardRef)(({emoji:e,onClick:t,"aria-label":n=`Change skin tone`,...r},i)=>{let a=Gc(Yc(),il,gl),[o,s,c]=hl(e),l=(0,R.useMemo)(()=>Math.max(0,c.findIndex(e=>e.skinTone===o)),[o,c]),u=c[l],d=c[(l+1)%c.length].skinTone,f=d===`none`?void 0:a?.[d],p=(0,R.useCallback)(e=>{t?.(e),e.isDefaultPrevented()||s(d)},[t,s,d]);return(0,z.jsx)(`button`,{type:`button`,...r,"aria-label":n+(f?` (${f})`:``),"aria-live":`polite`,"frimousse-skin-tone-selector":``,onClick:p,ref:i,children:u.emoji})});function Hl({children:e,...t}){return Gc(Yc(),el)?(0,z.jsx)(`span`,{"frimousse-loading":``,...t,children:e}):null}function Ul({children:e}){return e({search:Gc(Yc(),Zc)})}function Wl({children:e,...t}){return Gc(Yc(),$c)?(0,z.jsx)(`span`,{"frimousse-empty":``,...t,children:typeof e==`function`?(0,z.jsx)(Ul,{children:e}):e}):null}function Gl({children:e}){return e({emoji:ml()})}function Kl({children:e,emoji:t}){let[n,r,i]=hl(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:i})}Sl.displayName=`EmojiPicker.Root`,Cl.displayName=`EmojiPicker.Search`,Tl.displayName=`EmojiPicker.Viewport`,Bl.displayName=`EmojiPicker.List`,Hl.displayName=`EmojiPicker.Loading`,Wl.displayName=`EmojiPicker.Empty`,Vl.displayName=`EmojiPicker.SkinToneSelector`,Gl.displayName=`EmojiPicker.ActiveEmoji`,Kl.displayName=`EmojiPicker.SkinTone`;var ql=Oe();function Jl(e,t){if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!==`insertParagraph`&&t.inputType!==`insertLineBreak`||!ce()&&!pe())return;let n=e.view,r=n.root,i=(r.getSelection?.call(r)??n.dom.ownerDocument.getSelection())?.anchorNode,a=(i?.nodeType===1?i:i?.parentElement)?.closest(`[data-node-view-content-react]`);if(!a||!n.dom.contains(a))return;let o=n.input.lastKeyCode;o===13&&(n.input.lastKeyCode=null),n.domObserver.forceFlush(),n.domObserver.flush();let s=new KeyboardEvent(`keydown`,{key:`Enter`,code:`Enter`,keyCode:13,shiftKey:t.inputType===`insertLineBreak`,bubbles:!0,cancelable:!0});n.someProp(`handleKeyDown`,e=>e(n,s))?(t.preventDefault(),n.input.lastIOSEnter=0,clearTimeout(n.input.lastIOSEnterFallbackTimeout)):o===13&&(n.input.lastKeyCode=o)}var Yl=new Ce(`reactMobileEnter`),Xl=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Zl=({contentComponent:e})=>{let t=(0,ql.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})};function Ql(){let e=new Set,t={},n=!1,r=()=>{!n&&e.size&&(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:Ne.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var $l=class extends R.Component{constructor(e){super(e),this.editorContentRef=R.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.view.updateRoot(),e.setOptions({element:t}),e.contentComponent=Ql(),e.createNodeViews(),e.registerPlugin(new fe({key:Yl,props:{handleDOMEvents:{beforeinput:(t,n)=>Jl(e,n)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(Yl),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{ref:Xl(t,this.editorContentRef),...n}),e?.contentComponent&&(0,z.jsx)(Zl,{contentComponent:e.contentComponent})]})}},eu=(0,R.forwardRef)((e,t)=>{let n=R.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return R.createElement($l,{key:n,innerRef:t,...e})}),tu=R.memo(eu);typeof window>`u`||typeof window<`u`&&window.next;var nu=(0,R.createContext)({editor:null});nu.Consumer;var ru=(0,R.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),iu=()=>(0,R.useContext)(ru);R.forwardRef((e,t)=>{let{onDragStart:n}=iu(),r=e.as||`div`;return(0,z.jsx)(r,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),R.createContext({markViewContentRef:()=>{}});var au=(0,R.createContext)({get editor(){throw Error(`useTiptap must be used within a provider`)}});au.displayName=`TiptapContext`;var ou=()=>(0,R.useContext)(au);function su({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,R.useMemo)(()=>({editor:n}),[n]),i=(0,R.useMemo)(()=>({editor:n}),[n]);return(0,z.jsx)(nu.Provider,{value:i,children:(0,z.jsx)(au.Provider,{value:r,children:e})})}su.displayName=`Tiptap`;function cu({...e}){let{editor:t}=ou();return(0,z.jsx)(tu,{editor:t,...e})}cu.displayName=`Tiptap.Content`,Object.assign(su,{Content:cu}),u();var lu=Object.defineProperty,uu=(e,t)=>{let n={};for(var r in e)lu(n,r,{get:e[r],enumerable:!0});return t||lu(n,Symbol.toStringTag,{value:`Module`}),n},du=e=>{let{blockId:t,children:n,...r}=e,i=B(),a=(0,R.useMemo)(()=>i.transact(e=>{if(!t)return;let n=te(t,e.doc);if(!n)return;let r=ye(i.prosemirrorView,n.posBeforeNode,t);return r?{element:r}:void 0}),[i,t]);return(0,z.jsx)(ks,{reference:a,...r,children:t!==void 0&&n})},fu=e=>{let t=V(),n=H(),r=B(),i=r.getBlock(e.blockId),[a,o]=(0,R.useState)(``),s=(0,R.useCallback)(e=>{o(e.currentTarget.value)},[]),c=(0,R.useCallback)(()=>{r.getBlock(e.blockId)&&r.updateBlock(e.blockId,{props:{name:O(a),url:a}})},[r,e.blockId,a]);return i?(0,z.jsx)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:c,submitButton:(0,z.jsx)(t.FilePanel.Button,{className:`bn-button`,type:`submit`,"data-test":`embed-input-button`,children:n.file_panel.embed.embed_button[i.type]||n.file_panel.embed.embed_button.file}),children:(0,z.jsx)(t.FilePanel.TextInput,{className:`bn-text-input`,placeholder:n.file_panel.embed.url_placeholder,value:a,onChange:s,"data-test":`embed-input`})})}):null},pu=e=>{let t=V(),n=H(),{setLoading:r}=e,i=B(),a=i.getBlock(e.blockId),[o,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{o&&setTimeout(()=>{s(!1)},3e3)},[o]);let c=(0,R.useCallback)(t=>{if(t===null)return;async function n(t){if(r(!0),i.uploadFile!==void 0)try{let n=await i.uploadFile(t,e.blockId);if(!i.getBlock(e.blockId))return;typeof n==`string`&&(n={props:{name:t.name,url:n}}),i.updateBlock(e.blockId,n)}catch{s(!0)}finally{r(!1)}}n(t)},[e.blockId,i,r]);if(!a)return null;let l=i.schema.blockSpecs[a.type],u=l.implementation.meta.fileBlockAccept?.length?l.implementation.meta.fileBlockAccept.join(`,`):`*/*`;return(0,z.jsxs)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:[(0,z.jsx)(t.FilePanel.FileInput,{className:`bn-file-input`,"data-test":`upload-input`,accept:u,placeholder:n.file_panel.upload.file_placeholder[a.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:c}),o&&(0,z.jsx)(`div`,{className:`bn-error-text`,children:n.file_panel.upload.upload_error})]})},mu=e=>{let t=V(),n=H(),r=B(),[i,a]=(0,R.useState)(!1),o=e.tabs??[...r.uploadFile===void 0?[]:[{name:n.file_panel.upload.title,tabPanel:(0,z.jsx)(pu,{blockId:e.blockId,setLoading:a})}],{name:n.file_panel.embed.title,tabPanel:(0,z.jsx)(fu,{blockId:e.blockId})}],[s,c]=(0,R.useState)(e.defaultOpenTab||o[0].name);return(0,z.jsx)(t.FilePanel.Root,{className:`bn-panel`,defaultOpenTab:s,openTab:s,setOpenTab:c,tabs:o,loading:i})},hu=e=>{let t=B(),n=W(E),r=G(E),i=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(e,r,i)=>{e||n.closeMenu(),i===`escape-key`&&t.focus()},middleware:[za(10),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:90},...e.floatingUIOptions?.elementProps}}),[r,t,n,e.floatingUIOptions]),a=e.filePanel||mu;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(du,{blockId:r,...i,children:r&&(0,z.jsx)(a,{blockId:r})})})},gu={bold:rn,italic:Gt,underline:Nt,strike:It,code:ln};function _u(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema===`boolean`}var vu=e=>{let t=H(),n=V(),r=B(),i=He({editor:r,selector:({editor:t})=>{if(t.isEditable&&_u(e.basicTextStyle,t)&&(t.getSelection()?.blocks||[t.getTextCursorPosition().block]).find(e=>e.content!==void 0))return e.basicTextStyle in t.getActiveStyles()?{active:!0}:{active:!1}}}),a=(0,R.useCallback)(e=>{r.focus(),r.toggleStyles({[e]:!0})},[r]);if(i===void 0)return null;let o=gu[e.basicTextStyle];return(0,z.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":e.basicTextStyle,onClick:()=>a(e.basicTextStyle),isSelected:i.active,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:x(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:(0,z.jsx)(o,{})})},yu=(0,R.createContext)(`desktop`);function bu(){return(0,R.useContext)(yu)}var xu=e=>{let t=e.textColor||`default`,n=e.backgroundColor||`default`,r=e.size||16,i=(0,R.useMemo)(()=>({pointerEvents:`none`,fontSize:(r*.75).toString()+`px`,height:r.toString()+`px`,lineHeight:r.toString()+`px`,textAlign:`center`,width:r.toString()+`px`}),[r]);return(0,z.jsx)(`div`,{className:`bn-color-icon`,"data-background-color":n,"data-text-color":t,style:i,children:`A`})},Su=[`default`,`gray`,`brown`,`red`,`orange`,`yellow`,`green`,`blue`,`purple`,`pink`],Cu=e=>{let t=V(),n=H();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(()=>e.text?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(t.Generic.Menu.Label,{children:n.color_picker.text_title}),Su.map(r=>(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.text.setColor(r)},"data-test":`text-color-`+r,icon:(0,z.jsx)(xu,{textColor:r,size:e.iconSize}),checked:e.text.color===r,children:n.color_picker.colors[r]},`text-color-`+r))]}):null,{}),(0,z.jsx)(()=>e.background?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(t.Generic.Menu.Label,{children:n.color_picker.background_title}),Su.map(r=>(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.background.setColor(r)},"data-test":`background-color-`+r,icon:(0,z.jsx)(xu,{backgroundColor:r,size:e.iconSize}),checked:e.background.color===r,children:n.color_picker.colors[r]},`background-color-`+r))]}):null,{})]})};function wu(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema===`string`}var Tu=()=>{let e=V(),t=H(),n=bu(),r=Je(),i=B(),a=wu(`text`,i),o=wu(`background`,i),s=He({editor:i,selector:({editor:e})=>{if(!e.isEditable||!(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return;let t=wu(`text`,e),n=wu(`background`,e);if(t||n)return{textColor:t?e.getActiveStyles().textColor||`default`:void 0,backgroundColor:n?e.getActiveStyles().backgroundColor||`default`:void 0}}}),c=(0,R.useCallback)(e=>{if(!a)throw Error(`Tried to set text color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({textColor:e}):i.addStyles({textColor:e}),i.focus()},[i,a]),l=(0,R.useCallback)(e=>{if(!o)throw Error(`Tried to set background color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({backgroundColor:e}):i.addStyles({backgroundColor:e}),i.focus()},[o,i]);return s===void 0?null:(0,z.jsxs)(e.Generic.Menu.Root,{portalElement:r,preventFocusOnOpen:n===`mobile`,children:[(0,z.jsx)(e.Generic.Menu.Trigger,{children:(0,z.jsx)(e.FormattingToolbar.Button,{className:`bn-button`,"data-test":`colors`,label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:(0,z.jsx)(xu,{textColor:s.textColor,backgroundColor:s.backgroundColor,size:20})})}),(0,z.jsx)(e.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{text:s.textColor?{color:s.textColor,setColor:c}:void 0,background:s.backgroundColor?{color:s.backgroundColor,setColor:l}:void 0})})]})};function Eu(){let e=H();return(0,z.jsx)(`button`,{className:`bn-screen-reader-only-submit`,tabIndex:-1,type:`submit`,children:e.generic.form_submit})}var Du=e=>{for(let t of me)if(e.startsWith(t))return e;return`${de}://${e}`},Ou=e=>{let t=V(),n=H(),{editLink:r}=W(be),{url:i,text:a,showTextField:o}=e,[s,c]=(0,R.useState)(i),[l,u]=(0,R.useState)(a);(0,R.useEffect)(()=>{c(i),u(a)},[a,i]);let d=(0,R.useCallback)(e=>c(e.currentTarget.value),[]),f=(0,R.useCallback)(e=>u(e.currentTarget.value),[]),p=(0,R.useCallback)(()=>{r(Du(s),l,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1)},[r,s,l,e]);return(0,z.jsxs)(t.Generic.Form.Root,{onSubmit:p,submitButton:(0,z.jsx)(Eu,{}),children:[(0,z.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`url`,icon:(0,z.jsx)(Ut,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onChange:d}),o!==!1&&(0,z.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`title`,icon:(0,z.jsx)(Pt,{}),placeholder:n.link_toolbar.form.title_placeholder,value:l,onChange:f})]})};function ku(e){return`link`in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link===`link`}var Au=()=>{let e=B(),t=Ue(),n=V(),r=H(),i=Je(),a=W(A),{showSelection:o}=W(ae),[s,c]=(0,R.useState)(!1);(0,R.useEffect)(()=>(o(s,`createLinkButton`),()=>o(!1,`createLinkButton`)),[s,o]);let l=(0,R.useCallback)(t=>{t||e.focus(),c(t)},[e]),u=He({editor:e,selector:({editor:e})=>{if(e.isEditable&&!e.prosemirrorState.selection.empty&&ku(e)&&!v(e.prosemirrorState.selection)&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{url:e.getSelectedLinkUrl(),text:e.getSelectedText(),range:{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}}}});return(0,R.useEffect)(()=>{c(!1)},[u]),(0,R.useEffect)(()=>{let n=t=>{e.isEditable&&(t.ctrlKey||t.metaKey)&&t.key===`k`&&(c(!0),t.preventDefault())};return t?.addEventListener(`keydown`,n),()=>{t?.removeEventListener(`keydown`,n)}},[e,t]),u===void 0?null:(0,z.jsxs)(n.Generic.Popover.Root,{open:s,onOpenChange:l,portalElement:i,children:[(0,z.jsx)(n.Generic.Popover.Trigger,{children:(0,z.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":`createLink`,label:r.formatting_toolbar.link.tooltip,mainTooltip:r.formatting_toolbar.link.tooltip,secondaryTooltip:x(r.formatting_toolbar.link.secondary_tooltip,r.generic.ctrl_shortcut),icon:(0,z.jsx)(Ut,{}),onClick:()=>l(!s)})}),(0,z.jsx)(n.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(Ou,{url:u.url||``,text:u.text,range:u.range,showTextField:!1,setToolbarOpen:e=>a.store.setState(e)})})]})},ju=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,caption:`string`}))return n}}),[a,o]=(0,R.useState)(!1),s=(0,R.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,R.useCallback)(e=>{i!==void 0&&j(r,i.type,{caption:`string`})&&r.updateBlock(i.id,{props:{caption:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:(0,z.jsx)(Kt,{}),onClick:()=>s(!a)})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,z.jsx)(Eu,{}),children:(0,z.jsx)(t.Generic.Form.TextInput,{name:`file-caption`,icon:(0,z.jsx)(Kt,{}),value:i.props.caption,autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onChange:c})})})]})},Mu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&(n.focus(),n.removeBlocks([r.id]))},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:(0,z.jsx)(wt,{}),onClick:i})},Nu=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,name:`string`}))return n}}),[a,o]=(0,R.useState)(!1),s=(0,R.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,R.useCallback)(e=>{i!==void 0&&j(r,i.type,{name:`string`})&&r.updateBlock(i.id,{props:{name:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:(0,z.jsx)(tn,{}),onClick:()=>s(!a)})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,z.jsx)(Eu,{}),children:(0,z.jsx)(t.Generic.Form.TextInput,{name:`file-name`,icon:(0,z.jsx)(tn,{}),value:i.props.name,autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[i.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onChange:c})})})]})},Pu=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}});return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{onOpenChange:e=>{e||r.focus()},portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,mainTooltip:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:(0,z.jsx)(kt,{})})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-panel-popover`,variant:`panel-popover`,children:(0,z.jsx)(mu,{blockId:i.id})})]})},Fu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canNestBlock:e.canNestBlock()}}}),i=(0,R.useCallback)(()=>{r!==void 0&&r.canNestBlock&&(n.focus(),n.nestBlock())},[n,r]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`nestBlock`,onClick:i,isDisabled:!r.canNestBlock,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:x(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,z.jsx)(qt,{})})},Iu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canUnnestBlock:e.canUnnestBlock()}}}),i=(0,R.useCallback)(()=>{r!==void 0&&r.canUnnestBlock&&(n.focus(),n.unnestBlock())},[n,r]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`unnestBlock`,onClick:i,isDisabled:!r.canUnnestBlock,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:x(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,z.jsx)(Jt,{})})},Lu={paragraph:Pt,heading:en,heading_2:$t,heading_3:Qt,heading_4:Zt,heading_5:Xt,heading_6:Yt,toggle_heading:en,toggle_heading_2:$t,toggle_heading_3:Qt,quote:Lt,toggle_list:Ot,bullet_list:Bt,numbered_list:Vt,check_list:Ht},Ru=e=>C(e).map(({key:t,type:n,props:r})=>({name:e.dictionary.slash_menu[t].title,type:n,props:r,icon:Lu[t]})),zu=e=>{let t=V(),n=bu(),r=Je(),i=B(),a=He({editor:i,selector:({editor:e})=>e.getSelection()?.blocks||[e.getTextCursorPosition().block]}),o=a[0],s=(0,R.useMemo)(()=>(e.items||Ru(i)).filter(e=>j(i,e.type,Object.fromEntries(Object.entries(e.props||{}).map(([e,t])=>[e,typeof t])))),[i,e.items]),c=(0,R.useMemo)(()=>s.map(e=>{let t=e.icon,n=e.type===o.type,r=Object.entries(e.props||{}).filter(([e,t])=>t!==o.props[e]).length===0;return{text:e.name,icon:(0,z.jsx)(t,{size:16}),onClick:()=>{i.focus(),i.transact(()=>{for(let t of a)i.updateBlock(t,{type:e.type,props:e.props})})},isSelected:n&&r}}),[i,s,o.props,o.type,a]);return!(0,R.useMemo)(()=>c.find(e=>e.isSelected)!==void 0,[c])||!i.isEditable?null:(0,z.jsx)(t.FormattingToolbar.Select,{className:`bn-select`,items:c,portalElement:r,preventFocusOnOpen:n===`mobile`})},Bu=()=>{let e=H(),t=V(),n=B(),r=W(`comments`),{store:i}=W(A),a=He({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),o=(0,R.useCallback)(()=>{r.startPendingComment(),i.setState(!1)},[r,i]);return a?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,z.jsx)(dn,{}),onClick:o})},Vu=()=>B().getExtension(`comments`)?(0,z.jsx)(Bu,{}):null,Hu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),i=(0,R.useCallback)(()=>{n._tiptapEditor.chain().focus().addPendingComment().run()},[n]);return!n._tiptapEditor.commands.addPendingComment||!n.isEditable||r?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,z.jsx)(dn,{}),onClick:i})};function Uu(e,t){try{let n=new URL(e,t);if(n.protocol!==`javascript:`)return n.href}catch{}return`#`}var Wu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&(n.focus(),n.resolveFileUrl?n.resolveFileUrl(r.props.url).then(e=>window.open(Uu(e,window.location.href))):window.open(Uu(r.props.url,window.location.href)))},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,icon:(0,z.jsx)(St,{}),onClick:i})},Gu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,showPreview:`boolean`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&j(n,r.type,{showPreview:`boolean`})&&n.updateBlock(r.id,{props:{showPreview:!r.props.showPreview}})},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:`Toggle preview`,mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:(0,z.jsx)(At,{}),isSelected:r.props.showPreview,onClick:i})},Ku=()=>{let e=H(),t=V(),n=B(),r=W(F),i=He({editor:n,selector:({editor:e})=>{if(!e.isEditable||!e.settings.tables.splitCells)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(n.type===`table`)return{mergeDirection:r.getMergeDirection(n)}}}),a=(0,R.useCallback)(()=>{r?.mergeCells()},[r]);return i===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:e.formatting_toolbar.table_cell_merge.tooltip,icon:i.mergeDirection===`horizontal`?(0,z.jsx)(zt,{}):(0,z.jsx)(Rt,{}),onClick:a})},qu=()=>B().getExtension(F)?(0,z.jsx)(Ku,{}):null,Ju={left:on,center:cn,right:an,justify:sn},Yu=e=>{let t=V(),n=H(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block],n=t[0];if(b(n,e,n.type,{textAlignment:y.textAlignment}))return{textAlignment:n.props.textAlignment,blocks:t};if(t.length===1&&b(n,e,`table`))return e.getExtension(F)?.getCellSelection()?{textAlignment:le(n.content.rows[0].cells[0]).props.textAlignment,blocks:[n]}:void 0}}),a=(0,R.useCallback)(e=>{if(i!==void 0){r.focus();for(let t of i.blocks)if(b(t,r,t.type,{textAlignment:y.textAlignment})&&j(r,t.type,{textAlignment:y.textAlignment}))r.updateBlock(t,{props:{textAlignment:e}});else if(t.type===`table`){let n=r.getExtension(F)?.getCellSelection();if(!n)continue;let i=t.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));n.cells.forEach(({row:t,col:n})=>{i[t].cells[n].props.textAlignment=e}),r.updateBlock(t,{type:`table`,content:{...t.content,type:`tableContent`,rows:i}}),r.setTextCursorPosition(t)}}},[r,i]);if(i===void 0)return null;let o=Ju[e.textAlignment];return(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>a(e.textAlignment),isSelected:i.textAlignment===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:(0,z.jsx)(o,{})})},Xu=e=>[(0,z.jsx)(zu,{items:e},`blockTypeSelect`),(0,z.jsx)(qu,{},`tableCellMergeButton`),(0,z.jsx)(ju,{},`fileCaptionButton`),(0,z.jsx)(Pu,{},`replaceFileButton`),(0,z.jsx)(Nu,{},`fileRenameButton`),(0,z.jsx)(Mu,{},`fileDeleteButton`),(0,z.jsx)(Wu,{},`fileDownloadButton`),(0,z.jsx)(Gu,{},`filePreviewButton`),(0,z.jsx)(vu,{basicTextStyle:`bold`},`boldStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`italic`},`italicStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`underline`},`underlineStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`strike`},`strikeStyleButton`),(0,z.jsx)(Yu,{textAlignment:`left`},`textAlignLeftButton`),(0,z.jsx)(Yu,{textAlignment:`center`},`textAlignCenterButton`),(0,z.jsx)(Yu,{textAlignment:`right`},`textAlignRightButton`),(0,z.jsx)(Tu,{},`colorStyleButton`),(0,z.jsx)(Fu,{},`nestBlockButton`),(0,z.jsx)(Iu,{},`unnestBlockButton`),(0,z.jsx)(Au,{},`createLinkButton`),(0,z.jsx)(Vu,{},`addCommentButton`),(0,z.jsx)(Hu,{},`addTiptapCommentButton`)],Zu=e=>{let t=V();return(0,z.jsx)(t.FormattingToolbar.Root,{className:`bn-toolbar bn-formatting-toolbar`,children:e.children||Xu(e.blockTypeSelectItems)})},Qu=e=>{switch(e){case`left`:return`top-start`;case`center`:return`top`;case`right`:return`top-end`;default:return`top-start`}},$u=e=>{let t=B(),n=W(A,{editor:t}),r=G(A,{editor:t}),i=He({editor:t,selector:({editor:e})=>n.store.state?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),a=He({editor:t,selector:({editor:e})=>{let t=e.getTextCursorPosition().block;return b(t,e,t.type,{textAlignment:y.textAlignment})?Qu(t.props.textAlignment):`top-start`}}),o=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,r,i)=>{n.store.setState(e),i===`escape-key`&&t.focus()},placement:a,middleware:[za(10),Ba(),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:40},...e.floatingUIOptions?.elementProps}}),[r,a,e.floatingUIOptions,n.store,t]),s=e.formattingToolbar||Zu;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(As,{position:i,...o,children:r&&(0,z.jsx)(s,{})})})};function ed(e,t){let n=Ie(),r=t??n?.editor;if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);let i=e?.includeEditorUI??!1,a=(0,R.useRef)(void 0);(a.current===void 0||a.current.editor!==r||a.current.includeEditorUI!==i)&&(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})});let o=(0,R.useCallback)(e=>(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})},e(),r.onFocusChange((t,n)=>{a.current={editor:r,includeEditorUI:i,value:n.focused},e()},{includeEditorUI:i})),[r,i]),s=(0,R.useCallback)(()=>a.current.value,[]);return(0,R.useSyncExternalStore)(o,s,s)}var td=0,nd=0;function rd(){if(typeof window>`u`)return!1;let e=window.visualViewport,t=e?.scale??1,n=(e?.height??window.innerHeight)*t,r=document.documentElement.clientWidth;return Math.abs(r-nd)>nd*.2&&(nd=r,td=0),td=Math.max(td,n),td-n>150}var id=[`--bn-vv-top`,`--bn-vv-left`,`--bn-vv-width`,`--bn-vv-height`,`--bn-vv-scale`],ad=0;function od(){let[e,t]=(0,R.useState)(rd);return(0,R.useLayoutEffect)(()=>{let e=document.documentElement,n=window.visualViewport,r=()=>document.querySelectorAll(`.bn-scroll-container`),i=()=>{e.style.setProperty(`--bn-vv-top`,`${n?.offsetTop??0}px`),e.style.setProperty(`--bn-vv-left`,`${n?.offsetLeft??0}px`),e.style.setProperty(`--bn-vv-width`,`${n?.width??window.innerWidth}px`),e.style.setProperty(`--bn-vv-height`,`${n?.height??window.innerHeight}px`),e.style.setProperty(`--bn-vv-scale`,`${n?.scale??1}`)},a=(e,t)=>e.toggleAttribute(`data-bn-allow-pull-to-refresh`,!t&&e.scrollTop<=0),o=()=>{let e=rd();t(e),i();for(let t of r())a(t,e)};ad++,o(),n?.addEventListener(`resize`,o),n?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o);let s=e=>{e.target instanceof HTMLElement&&e.target.classList.contains(`bn-scroll-container`)&&a(e.target,rd())};return document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{if(n?.removeEventListener(`resize`,o),n?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),document.removeEventListener(`scroll`,s,{capture:!0}),ad--,ad===0){for(let t of id)e.style.removeProperty(t);for(let e of r())e.removeAttribute(`data-bn-allow-pull-to-refresh`);td=0,nd=0}}},[]),e}var sd=e=>{let t=od(),n=ed({includeEditorUI:!0});if(!t||!n)return null;let r=e.formattingToolbar||Zu;return(0,z.jsx)(Ze,{target:document.body,children:(0,z.jsx)(yu.Provider,{value:`mobile`,children:(0,z.jsx)(nt,{children:(0,z.jsx)(`div`,{className:`bn-mobile-formatting-toolbar`,children:(0,z.jsx)(r,{})})})})})},cd=e=>{let t=od();return _()&&t?(0,z.jsx)(sd,{formattingToolbar:e.formattingToolbar}):(0,z.jsx)($u,{...e})},ld=e=>{let t=V(),n=H(),{deleteLink:r}=W(be);return(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{r(e.range.from),e.setToolbarOpen?.(!1)},icon:(0,z.jsx)(Wt,{})})},ud=e=>{let t=V(),n=Je(),r=H();return(0,z.jsxs)(t.Generic.Popover.Root,{onOpenChange:e.setToolbarPositionFrozen,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:r.link_toolbar.edit.tooltip,isSelected:!1,children:r.link_toolbar.edit.text})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(Ou,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen})})]})},dd=e=>{let t=V(),n=H();return(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(Uu(e.url,window.location.href),`_blank`)},icon:(0,z.jsx)(xt,{})})},fd=e=>{let t=V();return(0,z.jsx)(t.LinkToolbar.Root,{className:`bn-toolbar bn-link-toolbar`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ud,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen}),(0,z.jsx)(dd,{url:e.url}),(0,z.jsx)(ld,{range:e.range,setToolbarOpen:e.setToolbarOpen})]})})},pd=e=>{let t=B(),n=He({editor:t,selector:({editor:e})=>e?.isEditable??!1}),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!1),s=Ue(),c=W(be),[l,u]=(0,R.useState)(void 0);(0,R.useEffect)(()=>{if(!n){u(void 0),i(!1);return}let e=()=>{let e=c.getLinkAtSelection();e?(u({cursorType:`text`,url:e.mark.attrs.href,text:e.text,range:e.range,element:c.getLinkElementAtPos(e.range.from)}),a||i(!0)):(u(void 0),a||i(!1))},r=e=>{if(l!==void 0&&l.cursorType===`text`||!(e.target instanceof HTMLElement))return;let t=c.getLinkAtElement(e.target);t&&u({cursorType:`mouse`,url:t.mark.attrs.href,text:t.text,range:t.range,element:c.getLinkElementAtPos(t.range.from)})},o=t.onChange(e),d=t.onSelectionChange(e);return s?.addEventListener(`mouseover`,r),()=>{o(),d(),s?.removeEventListener(`mouseover`,r)}},[t,s,n,c,l,a]);let d=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,n,r)=>{a||(l===void 0||l.cursorType!==`text`||r!==`hover`)&&(r===`escape-key`&&t.focus(),i(e))},placement:`top-start`,middleware:[za(10),Ha()],...e.floatingUIOptions?.useFloatingOptions},useHoverProps:{enabled:l!==void 0&&l.cursorType===`mouse`,delay:{open:250,close:250},handleClose:Es(),...e.floatingUIOptions?.useHoverProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:50},...e.floatingUIOptions?.elementProps}}),[t,l,e.floatingUIOptions,r,a]),f=(0,R.useMemo)(()=>l?.element?{element:l.element}:void 0,[l?.element]);if(!n)return null;let p=e.linkToolbar||fd;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(ks,{reference:f,...d,children:l&&(0,z.jsx)(p,{url:l.url,text:l.text,range:l.range,setToolbarOpen:i,setToolbarPositionFrozen:o})})})};function md(e){return U({tag:`svg`,attr:{viewBox:`0 0 1024 1024`},child:[{tag:`path`,attr:{d:`M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z`},child:[]},{tag:`path`,attr:{d:`M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z`},child:[]}]})(e)}var hd=()=>{let e=V(),t=H(),n=B(),r=W(N),i=G(I,{editor:n,selector:e=>e?.block}),a=(0,R.useCallback)(()=>{if(i===void 0)return;let e=i.content;if(e!==void 0&&Array.isArray(e)&&e.length===0)n.setTextCursorPosition(i),r.openSuggestionMenu(`/`);else{let e=n.insertBlocks([{type:`paragraph`}],i,`after`)[0];n.setTextCursorPosition(e),r.openSuggestionMenu(`/`)}},[i,n,r]);return i===void 0?null:(0,z.jsx)(e.SideMenu.Button,{className:`bn-button`,label:t.side_menu.add_block_label,icon:(0,z.jsx)(md,{size:24,onClick:a,"data-test":`dragHandleAdd`})})};function gd(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`m7 10 5 5 5-5z`},child:[]}]})(e)}function _d(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`},child:[]}]})(e)}var vd=e=>{let t=V(),n=Je(),r=B(),i=G(I,{editor:r,selector:e=>e?.block});return i===void 0||!b(i,r,i.type,{textColor:`string`})&&!b(i,r,i.type,{backgroundColor:`string`})?null:(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:b(i,r,i.type,{textColor:`string`})&&j(r,i.type,{textColor:`string`})?{color:i.props.textColor,setColor:e=>r.updateBlock(i,{type:i.type,props:{textColor:e}})}:void 0,background:b(i,r,i.type,{backgroundColor:`string`})&&j(r,i.type,{backgroundColor:`string`})?{color:i.props.backgroundColor,setColor:e=>r.updateBlock(i,{props:{backgroundColor:e}})}:void 0})})]})},yd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});return r===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,onClick:()=>{let e=n.getSelection()?.blocks,t=e&&e.some(e=>e.id===r.id)?e:[r];n.removeBlocks(t)},children:e.children})},bd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerRows;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerRows:i?void 0:1}})},children:e.children})},xd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerCols;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerCols:i?void 0:1}})},children:e.children})},Sd=e=>{let t=V(),n=H();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-drag-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(yd,{children:n.drag_handle.delete_menuitem}),(0,z.jsx)(vd,{children:n.drag_handle.colors_menuitem}),(0,z.jsx)(bd,{children:n.drag_handle.header_row_menuitem}),(0,z.jsx)(xd,{children:n.drag_handle.header_column_menuitem})]})})},Cd=e=>{let t=V(),n=Je(),r=H(),i=W(I),a=G(I,{selector:e=>e?.block});if(a===void 0)return null;let o=e.dragHandleMenu||Sd;return(0,z.jsxs)(t.Generic.Menu.Root,{onOpenChange:e=>{e?i.freezeMenu():i.unfreezeMenu()},position:`left`,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{children:(0,z.jsx)(t.SideMenu.Button,{label:r.side_menu.drag_handle_label,draggable:!0,onDragStart:e=>i.blockDragStart(e,a),onDragEnd:i.blockDragEnd,className:`bn-button`,icon:(0,z.jsx)(_d,{size:24,"data-test":`dragHandle`})})}),(0,z.jsx)(o,{children:e.children})]})},wd=e=>{let t=V();return(0,z.jsx)(t.SideMenu.Root,{className:`bn-side-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(hd,{}),(0,z.jsx)(Cd,{dragHandleMenu:e.dragHandleMenu})]})})};function Td(e,t){if(t.type===`heading`)switch(t.props.level){case 1:return 39;case 2:return 27;case 3:return 18.5;default:return 0}return e.schema.blockSpecs[t.type]?.implementation.meta?.fileBlockAccept&&!t.props.url?12:t.type===`file`?4:t.type===`audio`||t.type===`table`?15:0}var Ed=e=>{let t=B(),{show:n,block:r}=G(I,{selector:e=>e===void 0?void 0:{show:e.show,block:e.block}})||{},i=(0,R.useCallback)((e,n,r)=>{let i=t.getExtension(I);i?.setMenuElement(n);let a=!1,o=xa(e,n,()=>{a?i?.hideMenuIfNotFrozen():a=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1});return()=>{o(),i?.setMenuElement(void 0)}},[t]),a=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,placement:`left-start`,middleware:[za({crossAxis:r?Td(t,r):0})],whileElementsMounted:i,...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:!1,...e.floatingUIOptions?.useDismissProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:20},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,n,r,t,i]),o=e.sideMenu||wd;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(du,{blockId:n?r?.id:void 0,...a,children:r?.id&&(0,z.jsx)(o,{})})})},Dd=({format:e,dictionary:t})=>{let n=t.suggestion_changes.formatting_change;if(e.length===0)return n;let r=t.formatting_toolbar,i=[];for(let t of e){if(t===`link`)return n;let e=r[t],a=e&&typeof e==`object`&&`tooltip`in e?e.tooltip:void 0;if(typeof a!=`string`)return n;i.push(a)}return i.join(`, `)},Od=e=>{let t=V(),n=H(),r=(0,R.useMemo)(()=>{let t=n.suggestion_changes,r=e.formatChangeLabel??Dd,i=e.users.join(`, `);if(e.modificationType===`insert`)return i?t.inserted_by(i):t.inserted;if(e.modificationType===`delete`)return i?t.deleted_by(i):t.deleted;if(e.modificationType===`change`)return i?t.changed_by(i):t.changed;if(e.modificationType===`attrs`)return i?`${t.formatting_change}: ${i}`:t.formatting_change;let a=e.format?r({format:e.format,dictionary:n}):``;return!a||a===t.formatting_change?i?`${t.formatting_change}: ${i}`:t.formatting_change:i?t.formatting_change_by(a,i):`${t.formatting_change} (${a})`},[n,e]);return(0,z.jsx)(t.AttributionTooltip.Root,{className:`bn-suggestion-tooltip`,markClassName:e.className,backgroundColor:e.className?void 0:e.color,children:r})};function kd(e){let t=e.firstElementChild??e,n=t.getBoundingClientRect();return n.width||n.height?t:t.firstElementChild??t}function Ad(e,t){let{anchor:n,reference:r,...i}=e;return{...i,formatChangeLabel:t}}var jd=e=>{let t=G(`attribution`,{selector:e=>e}),n=(0,R.useMemo)(()=>t?{element:t.reference??kd(t.anchor)}:void 0,[t]),r=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!t,placement:`top-start`,middleware:[Ka(),za(4),Ha(),Ba({padding:4})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:1e4,pointerEvents:`none`},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,t]),i=e.attributionTooltip||Od,a=t?Ad(t,e.formatChangeLabel):void 0;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(ks,{reference:n,...r,children:a&&(0,z.jsx)(i,{...a})})})},Md=10,Nd=10,Pd=600,Fd=300,Id={name:`placeBelowUnlessCramped`,async fn(e){let{rects:t,placement:n,platform:r}=e,i={...t.floating,height:Fd},a=await r.detectOverflow({...e,rects:{...t,floating:i},y:t.reference.y+t.reference.height+Md},{padding:Nd}),o=`bottom-start`;return a.bottom>0&&(await r.detectOverflow({...e,rects:{...t,floating:i},y:t.reference.y-Md-Fd},{padding:Nd})).top=(parseFloat(e.style.minWidth)||0)+1&&(e.style.minWidth=`${Math.ceil(t)}px`)}var Rd=[Id,za(Md),Ba(),Ua({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,Math.min(t,Pd))}px`,Ld(e.floating)},padding:Nd})];function zd(e){let{triggerCharacter:t,shouldOpen:n,minQueryLength:r,enabled:i=!0,middleware:a=Rd,zIndex:o=80}=e,s=Ue(),c=W(N);(0,R.useEffect)(()=>{i&&c.addSuggestionMenu({triggerCharacter:t,shouldOpen:n})},[i,c,t,n]);let l=G(N),u=G(N,{selector:e=>({element:s?.firstElementChild??void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect}),equalityFn:(e,t)=>{let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.element===t.element&&n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}}),d=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:l?.show&&l.triggerCharacter===t,onOpenChange:e=>{e||c.closeMenu()},placement:`bottom-start`,middleware:a,...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:o},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,l?.show,l?.triggerCharacter,c,t,a,o]);return!i||!l||!l.ignoreQueryLength&&r&&(l.query.startsWith(` `)||l.query.length=4))return!1;e.fillStyle=`#00f`,e.fillText(t,0,0);let n=e.getImageData(0,0,Bd,Bd).data;e.clearRect(0,0,Bd,Bd),e.fillStyle=`#f00`,e.fillText(t,0,0);let r=e.getImageData(0,0,Bd,Bd).data;for(let e=0;e<16;e+=4)if(n[e]!==r[e]||n[e+1]!==r[e+1]||n[e+2]!==r[e+2])return!1;return!0}function Ud(e){let t=null;try{t=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0})}catch{}let n=new Map;for(let t of e.emojis)n.has(t.version)||n.set(t.version,t.emoji);let r=[...n.keys()].sort((e,t)=>t-e),i=r[0]??0,a=Hd(t,`🇪🇺`);for(let e of r)if(Hd(t,n.get(e)))return{emojiVersion:e,countryFlags:a};return{emojiVersion:i,countryFlags:a}}function Wd(e,t,n){return{...e,emojis:e.emojis.filter(e=>e.version<=(n??t.emojiVersion)&&(!e.countryFlag||t.countryFlags))}}async function Gd(e,{emojiVersion:t,signal:n}={}){let{loadFrimousseData:r}=await h(async()=>{let{loadFrimousseData:e}=await import(`./emoji-data-DkoSvmMO.js`);return{loadFrimousseData:e}},__vite__mapDeps([0,1,2,3]));n?.throwIfAborted();let i=await r(e);return n?.throwIfAborted(),Wd(i,Ud(i),t)}function Kd(e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function qd(e){return(0,R.useMemo)(()=>Kd(e),e)}function Jd({emoji:e,label:t,placeholder:n}){return(0,z.jsxs)(`div`,{className:`bn-frimousse-active-emoji`,children:[e&&(0,z.jsx)(`span`,{className:`bn-frimousse-active-emoji-glyph`,children:e}),(0,z.jsx)(`span`,{className:`bn-frimousse-active-emoji-label`,children:e?t:n})]})}function Yd({onEmojiSelect:e,onEscape:t,locale:n,dictionary:r}){let i=`${r.search}…`;return(0,z.jsxs)(Gs.Root,{className:`bn-frimousse-picker`,locale:n,resolveEmojiData:Gd,onEmojiSelect:({emoji:t})=>e(t),onKeyDownCapture:e=>{e.key===`Escape`&&t&&(e.stopPropagation(),t())},children:[(0,z.jsx)(Gs.Search,{placeholder:r.search,autoFocus:!0}),(0,z.jsxs)(Gs.Viewport,{children:[(0,z.jsx)(Gs.Loading,{className:`bn-frimousse-loading`,children:r.loading}),(0,z.jsx)(Gs.Empty,{className:`bn-frimousse-empty`,children:r.search_no_results}),(0,z.jsx)(Gs.List,{})]}),(0,z.jsxs)(`div`,{className:`bn-frimousse-footer`,children:[(0,z.jsx)(Gs.ActiveEmoji,{children:({emoji:e})=>(0,z.jsx)(Jd,{emoji:e?.emoji,label:e?.label,placeholder:i})}),(0,z.jsx)(Gs.SkinToneSelector,{className:`bn-frimousse-skin-tone`})]})]})}function Xd(e){return e===void 0?void 0:`bn-suggestion-menu-item-`+e}function Zd(e,t,n,r=3){let i=(0,R.useRef)(0);(0,R.useEffect)(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>r&&n())},[n,r,e.length,t])}function Qd(e){let t=new Map;for(let n of e.emojis){let e=t.get(n.category);e?e.push(n):t.set(n.category,[n])}let n=[],r=0;for(let i of e.categories){let e=t.get(i.index);if(e){for(let t=0;t({emoji:e,score:(e.label.toLowerCase().includes(n)?10:0)+e.tags.filter(e=>e.toLowerCase().includes(n)).length})).filter(({score:e})=>e>0).sort((e,t)=>t.score-e.score);return{...e,emojis:r.map(({emoji:e})=>e)}}function ef(e,t,n){let r=n[e.row];if(!r)return e;switch(t){case`ArrowLeft`:{if(e.column>0)return{...e,column:e.column-1};let t=n[e.row-1];return t?{row:e.row-1,column:t.emojis.length-1}:e}case`ArrowRight`:return e.column{let t=o.current;if(t?.closest(`[aria-rowindex]`))return a?.(e.emoji,t)},[e.emoji,c,a]),(0,z.jsx)(`button`,{type:`button`,className:`bn-frimousse-emoji`,...n,ref:s,"data-selected":i?``:void 0,"data-active":void 0,"aria-selected":i||void 0,children:e.emoji})}var of={Emoji:af};function sf(e,t,n){let r=e.get(n);return r?.closest(`[aria-rowindex]`)?.getAttribute(`aria-rowindex`)===String(t.row)&&r.getAttribute(`aria-colindex`)===String(t.column)&&r.textContent===n?r:null}function cf(e,t,n){let r=e.querySelector(`[frimousse-viewport]`);if(!r)return;let i=getComputedStyle(e),a=Number.parseFloat(i.getPropertyValue(`--frimousse-row-height`))||32,o=Number.parseFloat(i.getPropertyValue(`--frimousse-category-header-height`))||30,s=t.row*a+(n+1)*o,c=r.clientHeight;(sr.scrollTop+c-o)&&r.scrollTo({top:Math.max(0,s-c/3),behavior:`instant`})}function lf(e){let{query:t,insertEmoji:n,rootRef:r,data:i}=e,a=Ue(),o=Ie().setContentEditableProps,s=H(),[c]=hl(),l=(0,R.useRef)(new Map),u=(0,R.useRef)(void 0),d=(0,R.useCallback)((e,t)=>(l.current.set(e,t),u.current?.(),()=>{l.current.get(e)===t&&(l.current.delete(e),u.current?.())}),[]),f=(0,R.useMemo)(()=>i?Qd(i):[],[i]),[p,m]=(0,R.useState)({query:t,position:rf});p.query!==t&&m({query:t,position:rf});let h=p.query===t?p.position:rf,g=f[h.row],_=g?.emojis[h.column],v=_&&(c===`none`?_.emoji:_.skins?.[c]??_.emoji),y=f.slice(0,h.row).reduce((e,t)=>e+t.emojis.length,0)+h.column;(0,R.useEffect)(()=>(o(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{o(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[o]),(0,R.useEffect)(()=>{function e(e){o(t=>t?.[`aria-activedescendant`]===e?t:{...t,"aria-activedescendant":e})}let t=r.current;if(!t||!v||!g){e(void 0);return}let n=!0,i=v,a=y,s=null;function c(){let t=sf(l.current,h,i);s!==t&&(s?.removeAttribute(`id`),s=t),t?(n&&(n=!1,t.scrollIntoView({block:`nearest`,behavior:`instant`})),t.id=Xd(a),e(t.id)):e(void 0)}return u.current=c,sf(l.current,h,v)||cf(t,h,g.categoryIndex),c(),()=>{u.current=void 0,s?.removeAttribute(`id`),e(void 0)}},[r,v,y,h,g,o]),(0,R.useEffect)(()=>{let e=e=>{if(e.isComposing)return;let r=e.key;if(r===`ArrowRight`||r===`ArrowLeft`||r===`ArrowDown`||r===`ArrowUp`){let n=ef(h,r,f);if(n===h)return;e.preventDefault(),m({query:t,position:n})}else e.key===`Enter`&&v&&(e.preventDefault(),e.stopPropagation(),sf(l.current,h,v)&&n(v))};return a?.addEventListener(`keydown`,e,!0),()=>{a?.removeEventListener(`keydown`,e,!0)}},[f,a,n,t,v,h]);let b=`${s.emoji_picker.search}…`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Gs.Search,{hidden:!0,value:t,readOnly:!0,tabIndex:-1}),(0,z.jsxs)(Gs.Viewport,{children:[!i&&(0,z.jsx)(Gs.Loading,{className:`bn-frimousse-loading`,children:s.emoji_picker.loading}),(0,z.jsx)(Gs.Empty,{className:`bn-frimousse-empty`,children:s.emoji_picker.search_no_results}),(0,z.jsx)(tf.Provider,{value:v,children:(0,z.jsx)(nf.Provider,{value:d,children:(0,z.jsx)(Gs.List,{components:of})})})]}),(0,z.jsxs)(`div`,{className:`bn-frimousse-footer`,children:[(0,z.jsx)(Jd,{emoji:v,label:_?.label,placeholder:b}),(0,z.jsx)(Gs.SkinToneSelector,{className:`bn-frimousse-skin-tone`})]})]})}function uf(e){let t=B(),n=H().locale??`en`,[r,i]=(0,R.useState)(),a=(0,R.useRef)(null),o=(0,R.useMemo)(()=>r?.locale===n?$d(r.data,e.query):void 0,[r,n,e.query]);Zd(o?.emojis??[],o?e.query:void 0,e.closeMenu);let[s]=(0,R.useState)(()=>async(e,t)=>{let n=await Gd(e,t);return t.signal?.aborted||i({locale:e,data:n}),n});function c(n){e.clearQuery(),e.closeMenu(),t.insertInlineContent(n+` `)}return(0,z.jsx)(Gs.Root,{ref:a,id:`bn-suggestion-menu`,className:`bn-frimousse-picker`,locale:n,columns:9,resolveEmojiData:s,onEmojiSelect:({emoji:e})=>c(e),children:(0,z.jsx)(lf,{query:e.query,insertEmoji:c,rootRef:a,data:o})},n)}var df=[za(10),Wa({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),Ba(),Ua({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})];function ff(e){let t=B(),n=`text`in t.schema.inlineContentSchema&&t.schema.inlineContentSchema.text===ge.text;return(0,z.jsx)(zd,{...e,minQueryLength:e.minQueryLength??2,enabled:n,middleware:df,zIndex:70,children:e=>(0,z.jsx)(uf,{...e})})}function pf(e){let t=V(),n=H(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o}=e,s=i===`loading-initial`||i===`loading`?(0,z.jsx)(t.SuggestionMenu.Loader,{className:`bn-suggestion-menu-loader`}):null,c=(0,R.useMemo)(()=>{let e,n=[];for(let i=0;io?.(s)},s.title))}return n},[t,r,o,a]);return(0,z.jsxs)(t.SuggestionMenu.Root,{id:`bn-suggestion-menu`,className:`bn-suggestion-menu`,children:[c,c.length===0&&(e.loadingState===`loading`||e.loadingState===`loaded`)&&(0,z.jsx)(t.SuggestionMenu.EmptyItem,{className:`bn-suggestion-menu-item`,children:n.suggestion_menu.no_items_title}),s]})}function mf(e,t){let[n,r]=(0,R.useState)([]),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(void 0),s=(0,R.useRef)(void 0);return(0,R.useEffect)(()=>{let n=e;o.current=e,a(!0),t(e).then(e=>{o.current===n&&(r(e),a(!1),s.current=n)})},[e,t]),{items:n||[],usedQuery:s.current,loadingState:s.current===void 0?`loading-initial`:i?`loading`:`loaded`}}function hf(e,t){let[n,r]=(0,R.useState)(0);return{selectedIndex:n,setSelectedIndex:r,handler:i=>{if(i.key===`ArrowUp`)return i.preventDefault(),e.length&&r((n-1+e.length)%e.length),!0;if(i.key===`ArrowDown`)return i.preventDefault(),e.length&&r((n+1)%e.length),!0;if(i.key===`PageUp`)return i.preventDefault(),e.length&&r(0),!0;if(i.key===`PageDown`)return i.preventDefault(),e.length&&r(e.length-1),!0;let a=gf(i)?i.nativeEvent.isComposing:i.isComposing;return i.key===`Enter`&&!a&&(i.preventDefault(),i.stopPropagation(),e.length&&t?.(e[n]),!0)}}}function gf(e){return e.nativeEvent!==void 0}function _f(e,t,n,r,i){let a=Ue(),{selectedIndex:o,setSelectedIndex:s,handler:c}=hf(n,r);return(0,R.useEffect)(()=>{let e=i||a;return e?.addEventListener(`keydown`,c,!0),()=>{e?.removeEventListener(`keydown`,c,!0)}},[a,n,o,r,i,c]),(0,R.useEffect)(()=>{s(0)},[t,s]),{selectedIndex:n.length===0?void 0:o}}function vf(e){let t=Ie().setContentEditableProps,n=B(),{getItems:r,suggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c}=e,l=(0,R.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:u,usedQuery:d,loadingState:f}=mf(a,r);Zd(u,d,s);let{selectedIndex:p}=_f(n,a,u,l);return(0,R.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,R.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Xd(p)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,p]),(0,z.jsx)(i,{items:u,onItemClick:l,loadingState:f,selectedIndex:p})}var yf={heading:en,heading_2:$t,heading_3:Qt,heading_4:Zt,heading_5:Xt,heading_6:Yt,toggle_heading:en,toggle_heading_2:$t,toggle_heading_3:Qt,quote:Lt,toggle_list:Ot,numbered_list:Vt,bullet_list:Bt,check_list:Ht,paragraph:Pt,table:Ft,image:jt,video:Mt,audio:Dt,file:un,emoji:vt,code_block:nn,divider:yt};function bf(e){return M(e).map(e=>{let t=yf[e.key];return{...e,icon:(0,z.jsx)(t,{size:18})}})}function xf(e){let t=B(),{triggerCharacter:n,suggestionMenuComponent:r,onItemClick:i,getItems:a}=e,o=(0,R.useMemo)(()=>i||(e=>{e.onItemClick(t)}),[t,i]),s=(0,R.useMemo)(()=>a||(async e=>P(bf(t),e)),[t,a]);return(0,z.jsx)(zd,{...e,children:e=>n&&(0,z.jsx)(vf,{...e,getItems:s,suggestionMenuComponent:r||pf,onItemClick:o})})}var Sf=(e,t=.3)=>{let n=Math.floor(e)+t,r=Math.ceil(e)-t;return e>=n&&e<=r?Math.round(e):e{let t=V(),n=B(),r=W(F),i=G(F,{selector:e=>e?.block}),a=(0,R.useRef)(!1),[o,s]=(0,R.useState)(),c=(0,R.useCallback)(t=>{r.freezeHandles(),e.hideOtherElements(!0),i&&(s({originalContent:i.content,originalCroppedContent:{rows:r.cropEmptyRowsOrColumns(i,e.orientation===`addOrRemoveColumns`?`columns`:`rows`)},startPos:e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY}),a.current=!1,t.preventDefault())},[i,e,r]),l=(0,R.useCallback)(()=>{i&&!a.current&&n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns(i,`columns`,1):r.addRowsOrColumns(i,`rows`,1)}})},[i,n,e.orientation,r]);return(0,R.useEffect)(()=>{let t=t=>{if(!i)return;if(!o)throw Error(`editingState is undefined`);a.current=!0;let s=(e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY)-o.startPos,c=e.orientation===`addOrRemoveColumns`?o.originalCroppedContent.rows[0]?.cells.length??0:o.originalCroppedContent.rows.length,l=e.orientation===`addOrRemoveColumns`?o.originalContent.rows[0]?.cells.length??0:o.originalContent.rows.length,u=e.orientation===`addOrRemoveColumns`?i.content.rows[0].cells.length:i.content.rows.length,d=l+Sf(s/(e.orientation===`addOrRemoveColumns`?120:31),.3);d>=c&&d>0&&d!==u&&(n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`columns`,d-c):r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`rows`,d-c)}}),i.content&&n.setTextCursorPosition(i))};return o&&window.addEventListener(`mousemove`,t),()=>{window.removeEventListener(`mousemove`,t)}},[i,o,n,e.orientation,r]),(0,R.useEffect)(()=>{let t=()=>{e.hideOtherElements(!1),r.unfreezeHandles(),s(void 0)};return o&&window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mouseup`,t)}},[o,e,r]),n.isEditable?(0,z.jsx)(t.TableHandle.ExtendButton,{className:w(`bn-extend-button`,e.orientation===`addOrRemoveColumns`?`bn-extend-button-add-remove-columns`:`bn-extend-button-add-remove-rows`,o===null?``:`bn-extend-button-editing`),onClick:l,onMouseDown:c,children:e.children||(0,z.jsx)(Et,{size:18,"data-test":`extendButton`})}):null},wf=e=>{let t=V(),n=Je(),r=H(),i=B(),{block:a,colIndex:o,rowIndex:s}=G(F,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})}),c=(e,t)=>{if(a===void 0||o===void 0||s===void 0)return;let n=a.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));t===`text`?n[s].cells[o].props.textColor=e:n[s].cells[o].props.backgroundColor=e,i.updateBlock(a,{type:`table`,content:{...a.content,rows:n}}),i.setTextCursorPosition(a)};if(a===void 0||o===void 0||s===void 0)return null;let l=a.content.rows[s]?.cells?.[o];return!l||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1?null:(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:i.settings.tables.cellTextColor?{color:S(l)?l.props.textColor:`default`,setColor:e=>c(e,`text`)}:void 0,background:i.settings.tables.cellBackgroundColor?{color:S(l)?l.props.backgroundColor:`default`,setColor:e=>c(e,`background`)}:void 0})})]})},Tf=()=>{let e=V(),t=H(),n=B(),r=W(F),{block:i,colIndex:a,rowIndex:o}=G(F,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})});if(i===void 0||a===void 0||o===void 0)return null;let s=i.content.rows[o]?.cells?.[a];return!s||!S(s)||ve(s)===1&&ue(s)===1||!n.settings.tables.splitCells?null:(0,z.jsx)(e.Generic.Menu.Item,{onClick:()=>{r.splitCell({row:o,col:a})},children:t.table_handle.split_cell_menuitem})},Ef=e=>{let t=V();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-table-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Tf,{}),(0,z.jsx)(wf,{})]})})},Df=e=>{let t=V(),n=Je(),r=B(),i=W(F),a=e.tableCellMenu||Ef;return!r.settings.tables.splitCells&&!r.settings.tables.cellBackgroundColor&&!r.settings.tables.cellTextColor?null:(0,z.jsxs)(t.Generic.Menu.Root,{onOpenChange:t=>{t?(i.freezeHandles(),e.hideOtherElements(!0)):(i.unfreezeHandles(),e.hideOtherElements(!1),r.focus())},position:`right`,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{children:(0,z.jsx)(t.Generic.Menu.Button,{className:`bn-table-cell-handle`,children:e.children||(0,z.jsx)(gd,{size:12,"data-test":`tableCellHandle`})})}),(0,z.jsx)(a,{})]})},Of=e=>{let t=V(),n=H(),r=W(F),i=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{r.addRowOrColumn(i,e.orientation===`row`?{orientation:`row`,side:e.side}:{orientation:`column`,side:e.side})},children:n.table_handle[`add_${e.side}_menuitem`]})},kf=e=>{let t=V(),n=H(),r=W(F),i=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>r.removeRowOrColumn(i,e.orientation),children:e.orientation===`row`?n.table_handle.delete_row_menuitem:n.table_handle.delete_column_menuitem})},Af=e=>{let t=V(),n=Je(),r=H(),i=B(),a=W(F),{block:o,index:s}=G(F,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})}),c=(0,R.useMemo)(()=>a===void 0||o===void 0||s===void 0?[]:e.orientation===`row`?a.getCellsAtRowHandle(o,s):a.getCellsAtColumnHandle(o,s),[o,s,e.orientation,a]),l=(e,t)=>{if(o===void 0)return;let n=o.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));c.forEach(({row:r,col:i})=>{t===`text`?n[r].cells[i].props.textColor=e:n[r].cells[i].props.backgroundColor=e}),i.updateBlock(o,{type:`table`,content:{...o.content,rows:n}}),i.setTextCursorPosition(o)};if(!c||!c[0]||!a||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1)return null;let u=le(c[0].cell);return(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:i.settings.tables.cellTextColor?{color:c.every(({cell:e})=>S(e)&&e.props.textColor===u.props.textColor)?u.props.textColor:`default`,setColor:e=>{l(e,`text`)}}:void 0,background:i.settings.tables.cellBackgroundColor?{color:c.every(({cell:e})=>S(e)&&e.props.backgroundColor===u.props.backgroundColor)?u.props.backgroundColor:`default`,setColor:e=>l(e,`background`)}:void 0})})]})},jf=e=>{let t=V(),n=H(),r=B(),i=W(F),{block:a,index:o}=G(F,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})});if(i===void 0||a===void 0||o!==0||e.orientation!==`row`||!r.settings.tables.headers)return null;let s=!!a.content.headerRows;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerRows:s?void 0:1}})},children:n.drag_handle.header_row_menuitem})},Mf=e=>{let t=V(),n=H(),r=B(),i=W(F),a=G(F,{selector:e=>e?.block}),o=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});if(!i||o!==0||!a||e.orientation!==`column`||!r.settings.tables.headers)return null;let s=!!a.content.headerCols;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerCols:s?void 0:1}})},children:n.drag_handle.header_column_menuitem})},Nf=e=>{let t=V();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-table-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kf,{orientation:e.orientation}),(0,z.jsx)(Of,{orientation:e.orientation,side:e.orientation===`row`?`above`:`left`}),(0,z.jsx)(Of,{orientation:e.orientation,side:e.orientation===`row`?`below`:`right`}),(0,z.jsx)(jf,{orientation:e.orientation}),(0,z.jsx)(Mf,{orientation:e.orientation}),(0,z.jsx)(Af,{orientation:e.orientation})]})})},Pf=e=>{let t=B(),n=V(),r=Je(),[i,a]=(0,R.useState)(!1),o=e.tableHandleMenu||Nf,s=W(F),c=G(F),l=(0,R.useMemo)(()=>!s||!c||!c.block||c.block.type!==`table`?!1:e.orientation===`column`?s.getCellsAtColumnHandle(c.block,c.colIndex).every(({cell:e})=>ue(e)===1):s.getCellsAtRowHandle(c.block,c.rowIndex).every(({cell:e})=>ve(e)===1),[e.orientation,c,s]);return c?(0,z.jsxs)(n.Generic.Menu.Root,{onOpenChange:n=>{n?(s.freezeHandles(),e.hideOtherElements(!0)):(s.unfreezeHandles(),e.hideOtherElements(!1),t.focus())},position:`right`,portalElement:r,children:[(0,z.jsx)(n.Generic.Menu.Trigger,{children:(0,z.jsx)(n.TableHandle.Root,{className:w(`bn-table-handle`,i?`bn-table-handle-dragging`:``,l?``:`bn-table-handle-not-draggable`),draggable:l,onDragStart:t=>{a(!0),e.hideOtherElements(!0),e.orientation===`column`?s.colDragStart(t):s.rowDragStart(t)},onDragEnd:()=>{s.dragEnd(),e.hideOtherElements(!1),a(!1)},style:e.orientation===`column`?{transform:`rotate(0.25turn)`}:void 0,children:e.children||(0,z.jsx)(_d,{size:24,"data-test":`tableHandle`})})}),(0,z.jsx)(o,{orientation:e.orientation})]}):null},Ff=e=>{let t=B(),[n,r]=(0,R.useState)(),i=G(F),a=(0,R.useMemo)(()=>{let e={};if(i===void 0)return{};let n=te(i.block.id,t.prosemirrorState.doc);if(!n)return{};let r=n.posBeforeNode+1,a=t.prosemirrorView.domAtPos(r+1).node;if(!(a instanceof Element))return{};if(e.tableReference={element:a},i.rowIndex===void 0||i.colIndex===void 0)return e;let o=t.prosemirrorState.doc.resolve(r+1).posAtIndex(i.rowIndex),s=t.prosemirrorState.doc.resolve(o+1).posAtIndex(i.colIndex),c=t.prosemirrorView.domAtPos(s+1).node;return c instanceof Element?(e.cellReference={element:c},e.rowReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(e.x,i.draggingState&&i.draggingState.draggedCellOrientation===`row`?i.draggingState.mousePos-t.height/2:t.y,e.width,t.height)}},e.columnReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(i.draggingState&&i.draggingState.draggedCellOrientation===`col`?i.draggingState.mousePos-t.width/2:t.x,e.y,t.width,e.height)}},e):{}},[t,i]),o=(0,R.useCallback)((e,n,r)=>{let i=!1;return xa(e,n,()=>{i?t.getExtension(F)?.hideHandlesIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),s=(0,R.useMemo)(()=>i===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`),placement:`left`,middleware:[za(-10)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`),placement:`top`,middleware:[za(-12)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`),placement:`top-end`,middleware:[za({mainAxis:-15,crossAxis:-1})],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`),placement:`bottom`,whileElementsMounted:o,middleware:[Ua({apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`),placement:`right`,whileElementsMounted:o,middleware:[Ua({apply({rects:e,elements:t}){Object.assign(t.floating.style,{height:`${e.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[n,i,o]);if(!i)return null;let c=e.tableHandle||Pf,l=e.extendButton||Cf,u=e.tableCellHandle||Df;return(0,z.jsxs)(Xe,{target:e.portalElement,children:[(0,z.jsx)(ks,{reference:a?.rowReference,...s?.rowTableHandle,children:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`)&&(0,z.jsx)(c,{orientation:`row`,hideOtherElements:e=>r(e?`rowTableHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.columnReference,...s?.columnTableHandle,children:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`)&&(0,z.jsx)(c,{orientation:`column`,hideOtherElements:e=>r(e?`columnTableHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.cellReference,...s?.tableCellHandle,children:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`)&&(0,z.jsx)(u,{hideOtherElements:e=>r(e?`tableCellHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.tableReference,...s?.extendRowsButton,children:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`)&&(0,z.jsx)(l,{orientation:`addOrRemoveRows`,hideOtherElements:e=>r(e?`extendRowsButton`:void 0)})}),(0,z.jsx)(ks,{reference:a?.tableReference,...s?.extendColumnsButton,children:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`)&&(0,z.jsx)(l,{orientation:`addOrRemoveColumns`,hideOtherElements:e=>r(e?`extendColumnsButton`:void 0)})})]})};function If(e){if(e!==void 0){if(typeof e==`string`){if(typeof document>`u`)return;let t=document.querySelector(e);if(!t){console.warn(`[BlockNote] portalElements selector "${e}" did not match any element`);return}return t}return e}}var Lf=(0,R.lazy)(()=>Promise.resolve().then(()=>lp)),Rf=(0,R.lazy)(()=>Promise.resolve().then(()=>mp));function zf(e){let t=B();if(!t)throw Error(`BlockNoteDefaultUI must be used within a BlockNoteContext.Provider`);let n=e.portalElements,r=If(n?.formattingToolbar),i=If(n?.linkToolbar),a=If(n?.slashMenu),o=If(n?.emojiPicker),s=If(n?.sideMenu),c=If(n?.filePanel),l=If(n?.tableHandles),u=If(n?.comments),d=If(n?.attributionTooltip);return(0,z.jsxs)(z.Fragment,{children:[t.getExtension(A)&&e.formattingToolbar!==!1&&(0,z.jsx)(cd,{portalElement:r}),t.getExtension(be)&&e.linkToolbar!==!1&&(0,z.jsx)(pd,{portalElement:i}),t.getExtension(N)&&e.slashMenu!==!1&&(0,z.jsx)(xf,{triggerCharacter:`/`,shouldOpen:e=>!e.selection.$from.parent.type.isInGroup(`tableContent`),portalElement:a}),t.getExtension(N)&&e.emojiPicker!==!1&&(0,z.jsx)(ff,{triggerCharacter:`:`,portalElement:o}),t.getExtension(I)&&e.sideMenu!==!1&&(0,z.jsx)(Ed,{portalElement:s}),t.getExtension(E)&&e.filePanel!==!1&&(0,z.jsx)(hu,{portalElement:c}),t.getExtension(F)&&e.tableHandles!==!1&&(0,z.jsx)(Ff,{portalElement:l}),t.getExtension(Hs)&&e.comments!==!1&&(0,z.jsxs)(R.Suspense,{children:[(0,z.jsx)(Lf,{portalElement:u}),(0,z.jsx)(Rf,{portalElement:u})]}),t.getExtension(`attribution`)&&e.attributionTooltip!==!1&&(0,z.jsx)(jd,{portalElement:d})]})}var Bf=!1;function Vf(){typeof process<`u`||Bf||typeof document>`u`||(Bf=!0,(document.querySelector(`meta[name="viewport"]`)?.getAttribute(`content`)??``).replace(/\s/g,``).includes(`interactive-widget=resizes-content`)||console.warn(`[BlockNote] This page's viewport meta tag is missing "interactive-widget=resizes-content" in its content attribute. Add it to ensure proper mobile functionality, e.g. . See https://www.blocknotejs.org/docs/getting-started#mobile-compatibility for more information`))}function Hf(e,t){let n=Ie(),r=t??n?.editor,i=(0,R.useRef)(e);Be(()=>{i.current=e}),(0,R.useEffect)(()=>{if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return r.onChange((...e)=>i.current(...e))},[r])}function Uf(e,t,n){let r=Ie(),i=t??r?.editor,a=(0,R.useRef)(e);Be(()=>{a.current=e}),(0,R.useEffect)(()=>{if(!i)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return i.onSelectionChange(e=>a.current(e),n)},[i,n])}var Wf=()=>{let e=(0,R.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`),[]),t=(0,R.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: light)`),[]),n=e?.matches,r=t?.matches,[i,a]=(0,R.useState)(n?`dark`:r?`light`:`no-preference`);return(0,R.useEffect)(()=>{a(n?`dark`:r?`light`:`no-preference`)},[n,r]),(0,R.useEffect)(()=>{if(typeof e?.addEventListener==`function`){let n=({matches:e})=>e&&a(`dark`),r=({matches:e})=>e&&a(`light`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,r),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,r)}}{let n=()=>a(e.matches?`dark`:t.matches?`light`:`no-preference`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,n),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,n)}}},[e,t]),window.matchMedia,i};function Gf(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:(0,Ne.createPortal)(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Kf=({contentComponent:e})=>{let t=(0,R.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})},qf=(0,R.forwardRef)((e,t)=>{let[n,r]=(0,R.useState)();return(0,R.useImperativeHandle)(t,()=>(e,t)=>{(0,Ne.flushSync)(()=>{r({node:e,container:t})}),r(void 0)},[]),(0,z.jsx)(z.Fragment,{children:n&&(0,Ne.createPortal)(n.node,n.container)})}),Jf=()=>{};function Yf(e,t){let{editor:n,className:r,theme:i,children:a,editable:o,onSelectionChange:s,onChange:c,formattingToolbar:l,linkToolbar:u,slashMenu:d,emojiPicker:f,sideMenu:p,filePanel:m,tableHandles:h,comments:g,portalElements:_,applyThemedRoot:v,autoFocus:y,renderEditor:b=!0,...x}=e,S=(0,R.useMemo)(()=>If(_?.default),[_?.default]),[C,T]=(0,R.useState)(),E=Ie(),D=Wf(),O=E?.colorSchemePreference||D,k=i||(O===`dark`?`dark`:`light`),A=V(),j=(0,R.useMemo)(()=>({formattingToolbar:A?l:!1,linkToolbar:A?u:!1,sideMenu:A?p:!1,slashMenu:A?d:!1,filePanel:A?m:!1,tableHandles:A?h:!1,emojiPicker:A?f:!1,comments:A?g:!1,portalElements:_}),[g,A,f,m,l,u,p,d,h,_]);Hf(c||Jf,n),Uf(s||Jf,n);let M=(0,R.useCallback)(e=>{n.elementRenderer=e},[n]),N=(0,R.useCallback)(e=>{e.className=w(`bn-root`,k,r||``),e.setAttribute(`data-color-scheme`,k),v?.(e)},[k,r,v]),P=(0,R.useMemo)(()=>({...E,editor:n,setContentEditableProps:T,colorSchemePreference:k}),[E,n,k]),ee=(0,R.useMemo)(()=>({editorProps:{autoFocus:y,contentEditableProps:C,editable:o},defaultUIProps:j,applyThemedRoot:N}),[y,C,o,j,N]);return(0,z.jsx)(Fe.Provider,{value:P,children:(0,z.jsxs)(We.Provider,{value:ee,children:[(0,z.jsx)(qf,{ref:M}),(0,z.jsx)(Xf,{className:r,renderEditor:b,editorColorScheme:k,defaultPortalElement:S,ref:t,...x,children:a})]})})}var Xf=R.forwardRef(({className:e,renderEditor:t,editorColorScheme:n,defaultPortalElement:r,children:i,...a},o)=>(0,z.jsx)(`div`,{className:w(`bn-root`,`bn-container`,n,e),"data-color-scheme":n,...a,ref:o,children:(0,z.jsx)(Ye,{children:(0,z.jsx)(Xe,{target:r,children:t?(0,z.jsx)(Qf,{children:i}):i})})})),Zf=R.forwardRef(Yf),Qf=e=>{let t=Ge(),n=B(),r=(0,R.useMemo)(()=>Gf(),[]);(0,R.useEffect)(()=>{Vf()},[]);let i=(0,R.useCallback)(e=>{n.isEditable=t.editorProps.editable!==!1,n._tiptapEditor.contentComponent=r,e?n.mount(e):n.unmount()},[t.editorProps.editable,n,r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Kf,{contentComponent:r}),(0,z.jsx)($f,{...t.editorProps,...e,mount:i}),(0,z.jsx)(zf,{...t.defaultUIProps}),e.children]})},$f=e=>{let{autoFocus:t,mount:n,contentEditableProps:r}=e;return(0,z.jsx)(`div`,{"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"data-bn-autofocus":t,ref:n,...r})};ee();var ep=e=>{let[t,n]=(0,R.useState)(!1),r=V(),i=Je(),a=H(),o=a.locale??`en`;function s(t){n(t),e.onOpenChange?.(t)}return(0,z.jsxs)(r.Generic.Popover.Root,{open:t,onOpenChange:s,portalElement:i,children:[(0,z.jsx)(r.Generic.Popover.Trigger,{children:(0,z.jsx)(`div`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),s(!t)},style:{display:`flex`,justifyContent:`center`,alignItems:`center`},children:e.children})}),(0,z.jsx)(r.Generic.Popover.Content,{className:`bn-emoji-picker-popover`,variant:`panel-popover`,children:t&&(0,z.jsx)(Yd,{onEmojiSelect:t=>{e.onEmojiSelect(t),s(!1)},onEscape:()=>s(!1),locale:o,dictionary:a.emoji_picker})})]})};function tp(e){let{userStore:t}=W(Hs),n=e.join(`,`);return(0,R.useEffect)(()=>{t.loadUsers(e)},[t,n]),Le(t.store,t=>{let n=new Map;for(let r of e){let e=t.get(r);e&&n.set(r,e)}return n})}function np(e){return tp([e]).get(e)}var rp=e=>{let t=V(),n=H(),r=W(Hs),i=e.comment.reactions.find(t=>t.emoji===e.emoji);if(!i)throw Error(`Trying to render reaction badge for non-existing reaction`);let[a,o]=(0,R.useState)([]),s=tp(a);return(0,z.jsx)(t.Generic.Badge.Root,{className:w(`bn-badge`,`bn-comment-reaction`),text:i.userIds.length.toString(),icon:i.emoji,isSelected:r.threadStore.auth.canDeleteReaction(e.comment,i.emoji),onClick:()=>e.onReactionSelect(i.emoji),onMouseEnter:()=>o(i.userIds),mainTooltip:n.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(s.values()).map(e=>e.username).join(` +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/emoji-data--iPt3NLx.js","assets/index-DcxPhBy8.js","assets/rolldown-runtime-COiEfhsA.js","assets/index-DXs7t0vx.css"])))=>i.map(i=>d[i]); +import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{_ as n,a as r,f as i,g as a,h as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m,v as h}from"./index-DcxPhBy8.js";import{$ as g,A as _,B as v,D as y,H as b,I as x,J as S,K as C,L as w,M as T,N as E,O as D,P as O,R as k,U as A,V as j,W as M,X as N,Y as P,_ as ee,a as te,at as ne,b as re,c as F,ct as ie,d as ae,dt as oe,ft as se,i as I,it as ce,j as le,k as ue,l as de,lt as fe,n as L,nt as pe,o as me,ot as he,p as ge,pt as _e,q as ve,r as ye,s as be,st as xe,u as Se,ut as Ce,v as we,w as Te,y as Ee}from"./blocknote-BePxcw92.js";var De=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Oe=t(((e,t)=>{t.exports=De()})),ke=t((e=>{var t=n(),r=Oe();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Ae=t(((e,t)=>{t.exports=ke()})),je=t(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],n.get(i[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(i of t.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(t[i]!==n[i])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o===`_owner`&&t.$$typeof)&&!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),R=e(n(),1),Me=Ae(),Ne=e(s(),1),Pe=e(je(),1),z=a(),Fe=(0,R.createContext)(void 0);function Ie(e){return(0,R.useContext)(Fe)}function B(e){let t=Ie(e);if(!t?.editor)throw Error(`useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component`);return t.editor}function Le(e,t=e=>e,n=Re){return(0,Me.useSyncExternalStoreWithSelector)(e.subscribe,()=>e.state,()=>e.state,t,n)}function Re(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=ze(e);return n.length===ze(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))}function ze(e){return[...Object.keys(e),...Object.getOwnPropertySymbols(e)]}var Be=typeof window<`u`?R.useLayoutEffect:R.useEffect,Ve=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(e){this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e,t){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},n=this.editor._tiptapEditor,r={all:[`transaction`,`create`,`mount`,`unmount`],mount:[`create`,`mount`,`unmount`],selection:[`selectionUpdate`],change:[`update`]};for(let i of r[t])n.on(i,e);return()=>{for(let i of r[t])n.off(i,e)}}}};function He(e){let t=Ie(),n=e.editor||t?.editor||null,r=e.on||`all`,[i]=(0,R.useState)(()=>new Ve(n)),a=(0,Me.useSyncExternalStoreWithSelector)(i.subscribe,i.getSnapshot,i.getServerSnapshot,e.selector,e.equalityFn??Pe.default);return Be(()=>i.watch(n,r),[n,i,r]),(0,R.useDebugValue)(a),a}function Ue(e){let t=Ie();if(e||=t?.editor,!e)throw Error("'editor' is required in `useEditorDOMElement`, either from BlockNoteContext or as a function argument");return He({editor:e,selector:e=>e.editor.domElement,equalityFn:(e,t)=>e===t,on:`mount`})}var We=(0,R.createContext)(void 0);function Ge(){return(0,R.useContext)(We)}var Ke=typeof window<`u`?R.useInsertionEffect:R.useEffect,qe=(0,R.createContext)(null);function Je(){let e=(0,R.useContext)(qe),t=Ue();return e||(t?.parentElement??null)}function Ye(e){return(0,z.jsx)(qe.Provider,{value:null,children:e.children})}function Xe(e){let{target:t,children:n}=e,r=B(),i=Ge()?.applyThemedRoot,[a]=(0,R.useState)(()=>typeof document>`u`?null:document.createElement(`div`));return Ke(()=>{if(a&&t)return t.appendChild(a),()=>a.remove()},[a,t]),Ke(()=>{a&&t&&i?.(a)},[a,t,i]),Ke(()=>{if(a&&t)return r.registerPortalElement(a),()=>r.unregisterPortalElement(a)},[r,a,t]),t===void 0?n:(0,z.jsx)(qe.Provider,{value:a,children:n})}function Ze(e){return(0,z.jsx)(Xe,{target:e.target,children:(0,z.jsx)(Qe,{children:e.children})})}function Qe(e){let t=Je();return t?(0,Ne.createPortal)(e.children,t):null}function $e(){let[e]=(0,R.useState)(()=>{if(typeof document>`u`)return null;let e=document.createElement(`span`);return e.className=`bn-portal-anchor`,e}),t=(0,R.useCallback)(t=>{t&&e&&e.parentElement!==t&&t.appendChild(e)},[e]);return{anchor:e,holder:(0,z.jsx)(`span`,{ref:t,className:et,style:{position:`absolute`,width:0,height:0,overflow:`visible`}})}}var et=`bn-portal-anchor-holder`;function tt(e){return Array.from(e.childNodes).some(e=>!(e instanceof Element&&e.classList.contains(et)))}function nt(e){let{anchor:t,holder:n}=$e(),r=Je(),i=t??r,a=typeof e.children==`function`?e.children(i):e.children;return(0,z.jsxs)(z.Fragment,{children:[n,(0,z.jsx)(qe.Provider,{value:i,children:a})]})}var rt=(0,R.createContext)(void 0);function V(){return(0,R.useContext)(rt)}function H(){return Ie().editor.dictionary}var it={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},at=R.createContext&&R.createContext(it),ot=[`attr`,`size`,`title`];function st(e,t){if(e==null)return{};var n,r,i=ct(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;rR.createElement(e.tag,dt({key:t},e.attr),ht(e.child)))}function U(e){return t=>R.createElement(gt,lt({attr:dt({},e.attr)},t),ht(e.child))}function gt(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=st(e,ot),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),R.createElement(`svg`,lt({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:dt(dt({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&R.createElement(`title`,null,i),e.children)};return at===void 0?t(it):R.createElement(at.Consumer,null,e=>t(e))}function _t(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z`},child:[]}]})(e)}function vt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z`},child:[]}]})(e)}function yt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11V13H19V11H5Z`},child:[]}]})(e)}function bt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z`},child:[]}]})(e)}function xt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z`},child:[]}]})(e)}function St(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z`},child:[]}]})(e)}function Ct(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function wt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z`},child:[]}]})(e)}function Tt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z`},child:[]}]})(e)}function Et(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z`},child:[]}]})(e)}function Dt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z`},child:[]}]})(e)}function Ot(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z`},child:[]}]})(e)}function kt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z`},child:[]}]})(e)}function At(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z`},child:[]}]})(e)}function jt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z`},child:[]}]})(e)}function Mt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z`},child:[]}]})(e)}function Nt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z`},child:[]}]})(e)}function Pt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 6V21H11V6H5V4H19V6H13Z`},child:[]}]})(e)}function Ft(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z`},child:[]}]})(e)}function It(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z`},child:[]}]})(e)}function Lt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z`},child:[]}]})(e)}function Rt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z`},child:[]}]})(e)}function zt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z`},child:[]}]})(e)}function Bt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function Vt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z`},child:[]}]})(e)}function Ht(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z`},child:[]}]})(e)}function Ut(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z`},child:[]}]})(e)}function Wt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z`},child:[]}]})(e)}function Gt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z`},child:[]}]})(e)}function Kt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z`},child:[]}]})(e)}function qt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z`},child:[]}]})(e)}function Jt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z`},child:[]}]})(e)}function Yt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z`},child:[]}]})(e)}function Xt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function Zt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z`},child:[]}]})(e)}function Qt(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z`},child:[]}]})(e)}function $t(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z`},child:[]}]})(e)}function en(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z`},child:[]}]})(e)}function tn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z`},child:[]}]})(e)}function nn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z`},child:[]}]})(e)}function rn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z`},child:[]}]})(e)}function an(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z`},child:[]}]})(e)}function on(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z`},child:[]}]})(e)}function sn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z`},child:[]}]})(e)}function cn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z`},child:[]}]})(e)}function ln(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z`},child:[]}]})(e)}function un(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z`},child:[]}]})(e)}function dn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z`},child:[]}]})(e)}function fn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z`},child:[]}]})(e)}function pn(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z`},child:[]}]})(e)}function mn(){return typeof window<`u`}function hn(e){return vn(e)?(e.nodeName||``).toLowerCase():`#document`}function gn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _n(e){return((vn(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function vn(e){return mn()?e instanceof Node||e instanceof gn(e).Node:!1}function yn(e){return mn()?e instanceof Element||e instanceof gn(e).Element:!1}function bn(e){return mn()?e instanceof HTMLElement||e instanceof gn(e).HTMLElement:!1}function xn(e){return!mn()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof gn(e).ShadowRoot}function Sn(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Nn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Cn(e){return/^(table|td|th)$/.test(hn(e))}function wn(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Tn=/transform|translate|scale|rotate|perspective|filter/,En=/paint|layout|strict|content/,Dn=e=>!!e&&e!==`none`,On;function kn(e){let t=yn(e)?Nn(e):e;return Dn(t.transform)||Dn(t.translate)||Dn(t.scale)||Dn(t.rotate)||Dn(t.perspective)||!jn()&&(Dn(t.backdropFilter)||Dn(t.filter))||Tn.test(t.willChange||``)||En.test(t.contain||``)}function An(e){let t=Fn(e);for(;bn(t)&&!Mn(t);){if(kn(t))return t;if(wn(t))return null;t=Fn(t)}return null}function jn(){return On??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),On}function Mn(e){return/^(html|body|#document)$/.test(hn(e))}function Nn(e){return gn(e).getComputedStyle(e)}function Pn(e){return yn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(hn(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||xn(e)&&e.host||_n(e);return xn(t)?t.host:t}function In(e){let t=Fn(e);return Mn(t)?(e.ownerDocument||e).body:bn(t)&&Sn(t)?t:In(t)}function Ln(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=In(e),i=r===e.ownerDocument?.body,a=gn(r);if(i){let e=Rn(a);return t.concat(a,a.visualViewport||[],Sn(r)?r:[],e&&n?Ln(e):[])}return t.concat(r,Ln(r,[],n))}function Rn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var zn=[`top`,`right`,`bottom`,`left`],Bn=[`start`,`end`],Vn=zn.reduce((e,t)=>e.concat(t,t+`-`+Bn[0],t+`-`+Bn[1]),[]),Hn=Math.min,Un=Math.max,Wn=Math.round,Gn=Math.floor,Kn=e=>({x:e,y:e}),qn={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Jn(e,t,n){return Un(e,Hn(t,n))}function Yn(e,t){return typeof e==`function`?e(t):e}function Xn(e){return e.split(`-`)[0]}function Zn(e){return e.split(`-`)[1]}function Qn(e){return e===`x`?`y`:`x`}function $n(e){return e===`y`?`height`:`width`}function er(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function tr(e){return Qn(er(e))}function nr(e,t,n){n===void 0&&(n=!1);let r=Zn(e),i=tr(e),a=$n(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=dr(o)),[o,dr(o)]}function rr(e){let t=dr(e);return[ir(e),t,ir(t)]}function ir(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ar=[`left`,`right`],or=[`right`,`left`],sr=[`top`,`bottom`],cr=[`bottom`,`top`];function lr(e,t,n){switch(e){case`top`:case`bottom`:return n?t?or:ar:t?ar:or;case`left`:case`right`:return t?sr:cr;default:return[]}}function ur(e,t,n,r){let i=Zn(e),a=lr(Xn(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ir)))),a}function dr(e){let t=Xn(e);return qn[t]+e.slice(t.length)}function fr(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function pr(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:fr(e)}function mr(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}var hr=`input:not([inert]):not([inert] *),select:not([inert]):not([inert] *),textarea:not([inert]):not([inert] *),a[href]:not([inert]):not([inert] *),area[href]:not([inert]):not([inert] *),button:not([inert]):not([inert] *),[tabindex]:not(slot):not([inert]):not([inert] *),audio[controls]:not([inert]):not([inert] *),video[controls]:not([inert]):not([inert] *),[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *),details>summary:first-of-type:not([inert]):not([inert] *),details:not([inert]):not([inert] *)`,gr=typeof Element>`u`,_r=gr?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,vr=!gr&&Element.prototype.getRootNode?function(e){return e==null||e.getRootNode==null?void 0:e.getRootNode()}:function(e){return e?.ownerDocument},yr=function(e,t){t===void 0&&(t=!0);var n=e==null||e.getAttribute==null?void 0:e.getAttribute(`inert`);return n===``||n===`true`||t&&e&&(typeof e.closest==`function`?e.closest(`[inert]`):yr(e.parentNode))},br=function(e){var t,n=e==null||e.getAttribute==null||(t=e.getAttribute(`contenteditable`))==null?void 0:t.toLowerCase();return n===``||n===`true`||n===`plaintext-only`},xr=function(e,t,n){if(yr(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(hr));return t&&_r.call(e,hr)&&r.unshift(e),r=r.filter(n),r},Sr=function(e,t,n){for(var r=[],i=Array.from(e);i.length;){var a=i.shift();if(!yr(a,!1)){if(a.tagName===`SLOT`){var o=a.assignedElements(),s=Sr(o.length?o:a.children,!0,n);n.flatten?r.push.apply(r,s):r.push({scopeParent:a,candidates:s})}else{_r.call(a,hr)&&n.filter(a)&&(t||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof n.getShadowRoot==`function`&&n.getShadowRoot(a),l=!yr(c,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(c&&l){var u=Sr(c===!0?a.children:c.children,!0,n);n.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else i.unshift.apply(i,a.children)}}}return r},Cr=function(e){return!isNaN(parseInt(e.getAttribute(`tabindex`),10))},wr=function(e){if(!e)throw Error(`No node provided`);return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||br(e))&&!Cr(e)?0:e.tabIndex},Tr=function(e,t){var n=wr(e);return n<0&&t&&!Cr(e)?0:n},Er=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},Dr=function(e){return e.tagName===`INPUT`},Or=function(e){return Dr(e)&&e.type===`hidden`},kr=function(e){return e.tagName===`DETAILS`&&Array.prototype.slice.apply(e.children).some(function(e){return e.tagName===`SUMMARY`})},Ar=function(e,t){for(var n=0;nsummary:first-of-type`)?e.parentElement:e;if(_r.call(a,`details:not([open]) *`))return!0;if(!n||n===`full`||n===`full-native`||n===`legacy-full`){if(typeof r==`function`){for(var o=e;e;){var s=e.parentElement,c=vr(e);if(s&&!s.shadowRoot&&r(s)===!0)return Pr(e);e=e.assignedSlot?e.assignedSlot:!s&&c!==e.ownerDocument?c.host:s}e=o}if(e.isConnected)return!e.getClientRects().length;if(n!==`legacy-full`)return!0}else if(n===`non-zero-area`)return Pr(e);return!1},Ir=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName===`FIELDSET`&&t.disabled){for(var n=0;n=0)},Br=function(e){var t=[],n=[];return e.forEach(function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,o=Tr(a,i),s=i?Br(e.candidates):a;o===0?i?t.push.apply(t,s):t.push(a):n.push({documentOrder:r,tabIndex:o,item:e,isScope:i,content:s})}),n.sort(Er).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},Vr=function(e,t){return t||={},Br(t.getShadowRoot?Sr([e],t.includeContainer,{filter:Rr.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:zr}):xr(e,t.includeContainer,Rr.bind(null,t)))},Hr=function(e,t){return t||={},t.getShadowRoot?Sr([e],t.includeContainer,{filter:Lr.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):xr(e,t.includeContainer,Lr.bind(null,t))},Ur=function(e,t){if(t||={},!e)throw Error(`No node provided`);return _r.call(e,hr)!==!1&&Rr(t,e)};function Wr(){let e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function Gr(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(e=>{let{brand:t,version:n}=e;return t+`/`+n}).join(` `):navigator.userAgent}function Kr(){return/apple/i.test(navigator.vendor)}function qr(){let e=/android/i;return e.test(Wr())||e.test(Gr())}function Jr(){return Wr().toLowerCase().startsWith(`mac`)&&!navigator.maxTouchPoints}function Yr(){return Gr().includes(`jsdom/`)}var Xr=`data-floating-ui-focusable`,Zr=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`;function Qr(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function $r(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&xn(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function ei(e){return`composedPath`in e?e.composedPath()[0]:e.target}function ti(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function ni(e){return e.matches(`html,body`)}function ri(e){return e?.ownerDocument||document}function ii(e){return bn(e)&&e.matches(Zr)}function ai(e){return e?e.getAttribute(`role`)===`combobox`&&ii(e):!1}function oi(e){if(!e||Yr())return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function si(e){return e?e.hasAttribute(Xr)?e:e.querySelector(`[`+Xr+`]`)||e:null}function ci(e,t,n){return n===void 0&&(n=!0),e.filter(e=>e.parentId===t&&(!n||e.context?.open)).flatMap(t=>[t,...ci(e,t.id,n)])}function li(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function ui(e){e.preventDefault(),e.stopPropagation()}function di(e){return`nativeEvent`in e}function fi(e){return e.mozInputSource===0&&e.isTrusted?!0:qr()&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function pi(e){return Yr()?!1:!qr()&&e.width===0&&e.height===0||qr()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function mi(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}var hi=typeof document<`u`?R.useLayoutEffect:function(){},gi={...R};function _i(e){let t=R.useRef(e);return hi(()=>{t.current=e}),t}var vi=gi.useInsertionEffect||(e=>e());function yi(e){let t=R.useRef(()=>{});return vi(()=>{t.current=e}),R.useCallback(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}var bi=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver==`function`&&ResizeObserver.toString().includes(`[native code]`)?`full`:`none`});function xi(e,t){let n=Vr(e,bi()),r=n.length;if(r===0)return;let i=Qr(ri(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Si(e){return xi(ri(e).body,1)||e}function Ci(e){return xi(ri(e).body,-1)||e}function wi(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!$r(n,r)}function Ti(e){Vr(e,bi()).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Ei(e){e.querySelectorAll(`[data-tabindex]`).forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Di(e,t,n){let{reference:r,floating:i}=e,a=er(t),o=tr(t),s=$n(o),c=Xn(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Zn(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Oi(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Yn(t,e),p=pr(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=mr(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=mr(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ki=50,Ai=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Oi},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Di(l,r,c),f=r,p=0,m={};for(let n=0;n({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Yn(e,t)||{};if(l==null)return{};let d=pr(u),f={x:n,y:r},p=tr(i),m=$n(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Hn(d[_],T),D=Hn(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Jn(E,k,O),j=!c.arrow&&Zn(i)!=null&&k!==A&&a.reference[m]/2-(kZn(t)===e),...n.filter(t=>Zn(t)!==e)]:n.filter(e=>Xn(e)===e)).filter(n=>!e||Zn(n)===e||(t?ir(n)!==n:!1))}var Ni=function(e){return e===void 0&&(e={}),{name:`autoPlacement`,options:e,async fn(t){let{rects:n,middlewareData:r,placement:i,platform:a,elements:o}=t,{crossAxis:s=!1,alignment:c,allowedPlacements:l=Vn,autoAlignment:u=!0,...d}=Yn(e,t),f=c!==void 0||l===Vn?Mi(c||null,u,l):l,p=r.autoPlacement?.index||0,m=f[p];if(m==null)return{};if(i!==m)return{reset:{placement:f[0]}};let h=await a.detectOverflow(t,d),g=nr(m,n,await(a.isRTL==null?void 0:a.isRTL(o.floating))),_=[h[Xn(m)],h[g[0]],h[g[1]]],v=[...r.autoPlacement?.overflows||[],{placement:m,overflows:_}],y=f[p+1];if(y)return{data:{index:p+1,overflows:v},reset:{placement:y}};let b=v.map(e=>{let t=Zn(e.placement);return[e.placement,t&&s?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),x=b.filter(e=>e[2].slice(0,Zn(e[0])?2:3).every(e=>e<=0))[0]?.[0]||b[0][0];return x===i?{}:{data:{index:p+1,overflows:v},reset:{placement:x}}}}},Pi=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Yn(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Xn(r),_=er(o),v=Xn(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[dr(o)]:rr(o)),x=p!==`none`;!d&&x&&b.push(...ur(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=nr(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===er(t)||T.every(e=>er(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=er(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Fi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ii(e){return zn.some(t=>e[t]>=0)}var Li=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Yn(e,t);switch(i){case`referenceHidden`:{let e=Fi(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ii(e)}}}case`escaped`:{let e=Fi(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ii(e)}}}default:return{}}}}};function Ri(e){let t=Hn(...e.map(e=>e.left)),n=Hn(...e.map(e=>e.top)),r=Un(...e.map(e=>e.right)),i=Un(...e.map(e=>e.bottom));return{x:t,y:n,width:r-t,height:i-n}}function zi(e){let t=e.slice().sort((e,t)=>e.y-t.y),n=[],r=null;for(let e=0;er.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(e=>mr(Ri(e)))}var Bi=function(e){return e===void 0&&(e={}),{name:`inline`,options:e,async fn(t){let{placement:n,elements:r,rects:i,platform:a,strategy:o}=t,{padding:s=2,x:c,y:l}=Yn(e,t),u=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(r.reference))||[]);if(!u.length)return{};let d=zi(u),f=mr(Ri(u)),p=pr(s);function m(){if(d.length===2&&(d[0].left>d[1].right||d[1].left>d[0].right)&&c!=null&&l!=null)return d.find(e=>c>e.left-p.left&&ce.top-p.top&&l=2){if(er(n)===`y`){let e=d[0],t=d[d.length-1],r=Xn(n)===`top`,i=e.top,a=t.bottom,o=r?e.left:t.left;return mr({x:o,y:i,width:(r?e.right:t.right)-o,height:a-i})}let e=Xn(n)===`left`,t=Un(...d.map(e=>e.right)),r=Hn(...d.map(e=>e.left)),i=d.filter(n=>e?n.left===r:n.right===t),a=i[0].top,o=i[i.length-1].bottom;return mr({x:r,y:a,width:t-r,height:o-a})}return f}let h=await a.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:o});return i.reference.x!==h.reference.x||i.reference.y!==h.reference.y||i.reference.width!==h.reference.width||i.reference.height!==h.reference.height?{reset:{rects:h}}:{}}}},Vi=new Set([`left`,`top`]);async function Hi(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Xn(n),s=Zn(n),c=er(n)===`y`,l=Vi.has(o)?-1:1,u=a&&c?-1:1,d=Yn(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Ui=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Hi(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Wi=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Yn(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=er(i),p=Qn(f),m=u[p],h=u[f],g=(e,t)=>Jn(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Gi=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Yn(e,t),u={x:n,y:r},d=er(i),f=Qn(d),p=u[f],m=u[d],h=Yn(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;pn&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Vi.has(Xn(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);mr&&(m=r)}return{[f]:p,[d]:m}}}},Ki=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Yn(e,t),c=await i.detectOverflow(t,s),l=Xn(n),u=Zn(n),d=er(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Hn(p-c[m],g),y=Hn(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Un(c.left,c.right):S=p-2*Un(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function qi(e){let t=Nn(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=bn(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Wn(n)!==a||Wn(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ji(e){return yn(e)?e:e.contextElement}function Yi(e){let t=Ji(e);if(!bn(t))return Kn(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=qi(t),o=(a?Wn(n.width):n.width)/r,s=(a?Wn(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Xi=Kn(0);function Zi(e){let t=gn(e);return!jn()||!t.visualViewport?Xi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qi(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===gn(e)}function $i(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ji(e),o=Kn(1);t&&(r?yn(r)&&(o=Yi(r)):o=Yi(e));let s=Qi(a,n,r)?Zi(a):Kn(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=gn(a),t=yn(r)?gn(r):r,n=e,i=Rn(n);for(;i&&t!==n;){let e=Yi(i),t=i.getBoundingClientRect(),r=Nn(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=gn(i),i=Rn(n)}}return mr({width:u,height:d,x:c,y:l})}function ea(e,t){let n=Pn(e).scrollLeft;return t?t.left+n:$i(_n(e)).left+n}function ta(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ea(e,n),y:n.top+t.scrollTop}}function na(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=_n(r),s=t?wn(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Kn(1),u=Kn(0),d=bn(r);if((d||!a)&&((hn(r)!==`body`||Sn(o))&&(c=Pn(r)),d)){let e=$i(r);l=Yi(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ta(o,c):Kn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function ra(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ia(e){let t=Pn(e),n=e.ownerDocument.body,r=Un(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Un(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ea(e),o=-t.scrollTop;return Nn(n).direction===`rtl`&&(a+=Un(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var aa=25;function oa(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=gn(e),a=_n(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!jn()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(ea(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=aa&&(s-=o)}return{width:s,height:c,x:l,y:u}}function sa(e,t){let n=$i(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Yi(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ca(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=oa(e,n,t);else if(t===`document`)r=ia(_n(e));else if(yn(t))r=sa(t,n);else{let n=Zi(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return mr(r)}function la(e,t){let n=t.get(e);if(n)return n;let r=Ln(e,[],!1).filter(e=>yn(e)&&hn(e)!==`body`),i=null,a=Nn(e).position===`fixed`,o=a?Fn(e):e;for(;yn(o)&&!Mn(o);){let e=Nn(o),t=kn(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Fn(o)}return t.set(e,r),r}function ua(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?wn(t)?[]:la(t,this._c):[].concat(n),r],o=ca(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=gn(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function xa(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ji(e),u=i||a?[...l?Ln(l):[],...t?Ln(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ba(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?$i(e):null;c&&g();function g(){let t=$i(e);h&&!ya(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Sa=Ui,Ca=Ni,wa=Wi,Ta=Pi,Ea=Ki,Da=Li,Oa=ji,ka=Bi,Aa=Gi,ja=(e,t,n)=>{let r=new Map,i=n??{},a={...va,...i.platform,_c:r};return Ai(e,t,{...i,platform:a})},Ma=typeof document<`u`?R.useLayoutEffect:function(){};function Na(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Na(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Na(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Pa(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fa(e,t){let n=Pa(e);return Math.round(t*n)/n}function Ia(e){let t=R.useRef(e);return Ma(()=>{t.current=e}),t}function La(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=R.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=R.useState(r);Na(f,r)||p(r);let[m,h]=R.useState(null),[g,_]=R.useState(null),v=R.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=R.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=R.useRef(null),C=R.useRef(null),w=R.useRef(u),T=c!=null,E=Ia(c),D=Ia(i),O=Ia(l),k=R.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),ja(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Na(w.current,t)&&(w.current=t,Ne.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Ma(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=R.useRef(!1);Ma(()=>(A.current=!0,()=>{A.current=!1}),[]),Ma(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=R.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=R.useMemo(()=>({reference:b,floating:x}),[b,x]),N=R.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Fa(M.floating,u.x),r=Fa(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Pa(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return R.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Ra=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Oa({element:r.current,padding:i}).fn(n):r?Oa({element:r,padding:i}).fn(n):{}}}},za=(e,t)=>{let n=Sa(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ba=(e,t)=>{let n=wa(e);return{name:n.name,fn:n.fn,options:[e,t]}},Va=(e,t)=>({fn:Aa(e).fn,options:[e,t]}),Ha=(e,t)=>{let n=Ta(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ua=(e,t)=>{let n=Ea(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wa=(e,t)=>{let n=Ca(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ga=(e,t)=>{let n=Da(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ka=(e,t)=>{let n=ka(e);return{name:n.name,fn:n.fn,options:[e,t]}},qa=(e,t)=>{let n=Ra(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Ja(e){let t=R.useRef(void 0),n=R.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return R.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}var Ya=`data-floating-ui-focusable`,Xa=`active`,Za=`selected`,Qa=`ArrowLeft`,$a=`ArrowRight`,eo=`ArrowUp`,to=`ArrowDown`,no=[Qa,$a],ro=[eo,to];[...no,...ro];var io={...R},ao=!1,oo=0,so=()=>`floating-ui-`+Math.random().toString(36).slice(2,6)+oo++;function co(){let[e,t]=R.useState(()=>ao?so():void 0);return hi(()=>{e??t(so())},[]),R.useEffect(()=>{ao=!0},[]),e}var lo=io.useId||co;function uo(){let e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}var fo=R.createContext(null),po=R.createContext(null),mo=()=>R.useContext(fo)?.id||null,ho=()=>R.useContext(po);function go(e){return`data-floating-ui-`+e}function _o(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}var vo=go(`safe-polygon`);function yo(e,t,n){if(n&&!mi(n))return 0;if(typeof e==`number`)return e;if(typeof e==`function`){let n=e();return typeof n==`number`?n:n?.[t]}return e?.[t]}function bo(e){return typeof e==`function`?e():e}function xo(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,dataRef:i,events:a,elements:o}=e,{enabled:s=!0,delay:c=0,handleClose:l=null,mouseOnly:u=!1,restMs:d=0,move:f=!0}=t,p=ho(),m=mo(),h=_i(l),g=_i(c),_=_i(n),v=_i(d),y=R.useRef(),b=R.useRef(-1),x=R.useRef(),S=R.useRef(-1),C=R.useRef(!0),w=R.useRef(!1),T=R.useRef(()=>{}),E=R.useRef(!1),D=yi(()=>{let e=i.current.openEvent?.type;return e?.includes(`mouse`)&&e!==`mousedown`});R.useEffect(()=>{if(!s)return;function e(e){let{open:t}=e;t||(_o(b),_o(S),C.current=!0,E.current=!1)}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[s,a]),R.useEffect(()=>{if(!s||!h.current||!n)return;function e(e){D()&&r(!1,e,`hover`)}let t=ri(o.floating).documentElement;return t.addEventListener(`mouseleave`,e),()=>{t.removeEventListener(`mouseleave`,e)}},[o.floating,n,r,s,h,D]);let O=R.useCallback(function(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=`hover`);let i=yo(g.current,`close`,y.current);i&&!x.current?(_o(b),b.current=window.setTimeout(()=>r(!1,e,n),i)):t&&(_o(b),r(!1,e,n))},[g,r]),k=yi(()=>{T.current(),x.current=void 0}),A=yi(()=>{if(w.current){let e=ri(o.floating).body;e.style.pointerEvents=``,e.removeAttribute(vo),w.current=!1}}),j=yi(()=>i.current.openEvent?[`click`,`mousedown`].includes(i.current.openEvent.type):!1);R.useEffect(()=>{if(!s)return;function e(e){if(_o(b),C.current=!1,u&&!mi(y.current)||bo(v.current)>0&&!yo(g.current,`open`))return;let t=yo(g.current,`open`,y.current);t?b.current=window.setTimeout(()=>{_.current||r(!0,e,`hover`)},t):n||r(!0,e,`hover`)}function t(e){if(j()){A();return}T.current();let t=ri(o.floating);if(_o(S),E.current=!1,h.current&&i.current.floatingContext){n||_o(b),x.current=h.current({...i.current.floatingContext,tree:p,x:e.clientX,y:e.clientY,onClose(){A(),k(),j()||O(e,!0,`safe-polygon`)}});let r=x.current;t.addEventListener(`mousemove`,r),T.current=()=>{t.removeEventListener(`mousemove`,r)}}else y.current===`touch`&&$r(o.floating,e.relatedTarget)||O(e)}function a(e){j()||i.current.floatingContext&&(h.current==null||h.current({...i.current.floatingContext,tree:p,x:e.clientX,y:e.clientY,onClose(){A(),k(),j()||O(e)}})(e))}function c(){_o(b)}function l(e){j()||O(e,!1)}if(yn(o.domReference)){let r=o.domReference,i=o.floating;return n&&r.addEventListener(`mouseleave`,a),f&&r.addEventListener(`mousemove`,e,{once:!0}),r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),i&&(i.addEventListener(`mouseleave`,a),i.addEventListener(`mouseenter`,c),i.addEventListener(`mouseleave`,l)),()=>{n&&r.removeEventListener(`mouseleave`,a),f&&r.removeEventListener(`mousemove`,e),r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t),i&&(i.removeEventListener(`mouseleave`,a),i.removeEventListener(`mouseenter`,c),i.removeEventListener(`mouseleave`,l))}}},[o,s,e,u,f,O,k,A,r,n,_,p,g,h,i,j,v]),hi(()=>{var e;if(s&&n&&(e=h.current)!=null&&(e=e.__options)!=null&&e.blockPointerEvents&&D()){w.current=!0;let e=o.floating;if(yn(o.domReference)&&e){var t;let n=ri(o.floating).body;n.setAttribute(vo,``);let r=o.domReference,i=p==null||(t=p.nodesRef.current.find(e=>e.id===m))==null||(t=t.context)==null?void 0:t.elements.floating;return i&&(i.style.pointerEvents=``),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,e.style.pointerEvents=`auto`,()=>{n.style.pointerEvents=``,r.style.pointerEvents=``,e.style.pointerEvents=``}}}},[s,n,m,o,p,h,D]),hi(()=>{n||(y.current=void 0,E.current=!1,k(),A())},[n,k,A]),R.useEffect(()=>()=>{k(),_o(b),_o(S),A()},[s,o.domReference,k,A]);let M=R.useMemo(()=>{function e(e){y.current=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e;function i(){!C.current&&!_.current&&r(!0,t,`hover`)}u&&!mi(y.current)||n||bo(v.current)===0||E.current&&e.movementX**2+e.movementY**2<2||(_o(S),y.current===`touch`?i():(E.current=!0,S.current=window.setTimeout(i,bo(v.current))))}}},[u,r,n,_,v]);return R.useMemo(()=>s?{reference:M}:{},[s,M])}var So=()=>{},Co=R.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:So,setState:So,isInstantPhase:!1}),wo=()=>R.useContext(Co);function To(e){let{children:t,delay:n,timeoutMs:r=0}=e,[i,a]=R.useReducer((e,t)=>({...e,...t}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),o=R.useRef(null),s=R.useCallback(e=>{a({currentId:e})},[]);return hi(()=>{i.currentId?o.current===null?o.current=i.currentId:i.isInstantPhase||a({isInstantPhase:!0}):(i.isInstantPhase&&a({isInstantPhase:!1}),o.current=null)},[i.currentId,i.isInstantPhase]),(0,z.jsx)(Co.Provider,{value:R.useMemo(()=>({...i,setState:a,setCurrentId:s}),[i,s]),children:t})}function Eo(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,floatingId:i}=e,{id:a,enabled:o=!0}=t,s=a??i,c=wo(),{currentId:l,setCurrentId:u,initialDelay:d,setState:f,timeoutMs:p}=c;return hi(()=>{o&&l&&(f({delay:{open:1,close:yo(d,`close`)}}),l!==s&&r(!1))},[o,s,r,f,l,d]),hi(()=>{function e(){r(!1),f({delay:d,currentId:null})}if(o&&l&&!n&&l===s){if(p){let t=window.setTimeout(e,p);return()=>{clearTimeout(t)}}e()}},[o,n,f,l,s,r,d,p]),hi(()=>{o&&u!==So&&n&&u(s)},[o,n,u,s]),c}var Do=0;function Oo(e,t){t===void 0&&(t={});let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(Do);let a=()=>e?.focus({preventScroll:n});i?a():Do=requestAnimationFrame(a)}function ko(e,t){if(!e||!t)return!1;let n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&xn(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Ao(e){return`composedPath`in e?e.composedPath()[0]:e.target}function jo(e){return e?.ownerDocument||document}var Mo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function No(e){return e===`inert`?Mo.inert:e===`aria-hidden`?Mo[`aria-hidden`]:Mo.none}var Po=new WeakSet,Fo={},Io=0,Lo=()=>typeof HTMLElement<`u`&&`inert`in HTMLElement.prototype;function Ro(e){return e?xn(e)?e.host:Ro(e.parentNode):null}var zo=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Ro(t);return e.contains(n)?n:null}).filter(e=>e!=null);function Bo(e,t,n,r){let i=`data-floating-ui-inert`,a=r?`inert`:n?`aria-hidden`:null,o=zo(t,e),s=new Set,c=new Set(o),l=[];Fo[i]||(Fo[i]=new WeakMap);let u=Fo[i];o.forEach(d),f(t),s.clear();function d(e){e&&!s.has(e)&&(s.add(e),e.parentNode&&d(e.parentNode))}function f(e){e&&!c.has(e)&&[].forEach.call(e.children,e=>{if(hn(e)!==`script`){if(s.has(e))f(e);else{let t=a?e.getAttribute(a):null,n=t!==null&&t!==`false`,r=No(a),o=(r.get(e)||0)+1,s=(u.get(e)||0)+1;r.set(e,o),u.set(e,s),l.push(e),o===1&&n&&Po.add(e),s===1&&e.setAttribute(i,``),!n&&a&&e.setAttribute(a,a===`inert`?``:`true`)}}})}return Io++,()=>{l.forEach(e=>{let t=No(a),n=(t.get(e)||0)-1,r=(u.get(e)||0)-1;t.set(e,n),u.set(e,r),n||(!Po.has(e)&&a&&e.removeAttribute(a),Po.delete(e)),r||e.removeAttribute(i)}),Io--,Io||(Mo.inert=new WeakMap,Mo[`aria-hidden`]=new WeakMap,Mo.none=new WeakMap,Po=new WeakSet,Fo={})}}function Vo(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);let r=jo(e[0]).body;return Bo(e.concat(Array.from(r.querySelectorAll(`[aria-live],[role="status"],output`))),r,t,n)}var Ho={border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`fixed`,whiteSpace:`nowrap`,width:`1px`,top:0,left:0},Uo=R.forwardRef(function(e,t){let[n,r]=R.useState();hi(()=>{Kr()&&r(`button`)},[]);let i={ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,[go(`focus-guard`)]:``,style:Ho};return(0,z.jsx)(`span`,{...e,...i})}),Wo={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},Go=R.createContext(null),Ko=go(`portal`);function qo(e){e===void 0&&(e={});let{id:t,root:n}=e,r=lo(),i=Yo(),[a,o]=R.useState(null),s=R.useRef(null);return hi(()=>()=>{a?.remove(),queueMicrotask(()=>{s.current=null})},[a]),hi(()=>{if(!r||s.current)return;let e=t?document.getElementById(t):null;if(!e)return;let n=document.createElement(`div`);n.id=r,n.setAttribute(Ko,``),e.appendChild(n),s.current=n,o(n)},[t,r]),hi(()=>{if(n===null||!r||s.current)return;let e=n||i?.portalNode;e&&!vn(e)&&(e=e.current),e||=document.body;let a=null;t&&(a=document.createElement(`div`),a.id=t,e.appendChild(a));let c=document.createElement(`div`);c.id=r,c.setAttribute(Ko,``),e=a||e,e.appendChild(c),s.current=c,o(c)},[t,n,r,i]),a}function Jo(e){let{children:t,id:n,root:r,preserveTabOrder:i=!0}=e,a=qo({id:n,root:r}),[o,s]=R.useState(null),c=R.useRef(null),l=R.useRef(null),u=R.useRef(null),d=R.useRef(null),f=o?.modal,p=o?.open,m=!!o&&!o.modal&&o.open&&i&&!!(r||a);return R.useEffect(()=>{if(!a||!i||f)return;function e(e){a&&wi(e)&&(e.type===`focusin`?Ei:Ti)(a)}return a.addEventListener(`focusin`,e,!0),a.addEventListener(`focusout`,e,!0),()=>{a.removeEventListener(`focusin`,e,!0),a.removeEventListener(`focusout`,e,!0)}},[a,i,f]),R.useEffect(()=>{a&&(p||Ei(a))},[p,a]),(0,z.jsxs)(Go.Provider,{value:R.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:l,beforeInsideRef:u,afterInsideRef:d,portalNode:a,setFocusManagerState:s}),[i,a]),children:[m&&a&&(0,z.jsx)(Uo,{"data-type":`outside`,ref:c,onFocus:e=>{if(wi(e,a)){var t;(t=u.current)==null||t.focus()}else Ci(o?o.domReference:null)?.focus()}}),m&&a&&(0,z.jsx)(`span`,{"aria-owns":a.id,style:Wo}),a&&Ne.createPortal(t,a),m&&a&&(0,z.jsx)(Uo,{"data-type":`outside`,ref:l,onFocus:e=>{if(wi(e,a)){var t;(t=d.current)==null||t.focus()}else Si(o?o.domReference:null)?.focus(),o!=null&&o.closeOnFocusOut&&o?.onOpenChange(!1,e.nativeEvent,`focus-out`)}})]})}var Yo=()=>R.useContext(Go);function Xo(e){return R.useMemo(()=>t=>{e.forEach(e=>{e&&(e.current=t)})},e)}var Zo=20,Qo=[];function $o(){Qo=Qo.filter(e=>e.deref()?.isConnected)}function es(e){$o(),e&&hn(e)!==`body`&&(Qo.push(new WeakRef(e)),Qo.length>Zo&&(Qo=Qo.slice(-20)))}function ts(){return $o(),Qo[Qo.length-1]?.deref()}function ns(e){let t=bi();return Ur(e,t)?e:Vr(e,t)[0]||e}function rs(e,t){var n;if(!t.current.includes(`floating`)&&!((n=e.getAttribute(`role`))!=null&&n.includes(`dialog`)))return;let r=bi(),i=Hr(e,r).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Ur(e,r)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),a=e.getAttribute(`tabindex`);t.current.includes(`floating`)||i.length===0?a!==`0`&&e.setAttribute(`tabindex`,`0`):(a!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}var is=R.forwardRef(function(e,t){return(0,z.jsx)(`button`,{...e,type:`button`,ref:t,tabIndex:-1,style:Ho})});function as(e){let{context:t,children:n,disabled:r=!1,order:i=[`content`],guards:a=!0,initialFocus:o=0,returnFocus:s=!0,restoreFocus:c=!1,modal:l=!0,visuallyHiddenDismiss:u=!1,closeOnFocusOut:d=!0,outsideElementsInert:f=!1,getInsideElements:p=()=>[]}=e,{open:m,onOpenChange:h,events:g,dataRef:_,elements:{domReference:v,floating:y}}=t,b=yi(()=>_.current.floatingContext?.nodeId),x=yi(p),S=typeof o==`number`&&o<0,C=ai(v)&&S,w=Lo(),T=!w||a,E=!T||w&&f,D=_i(i),O=_i(o),k=_i(s),A=ho(),j=Yo(),M=R.useRef(null),N=R.useRef(null),P=R.useRef(!1),ee=R.useRef(!1),te=R.useRef(-1),ne=R.useRef(-1),re=j!=null,F=si(y),ie=yi(function(e){return e===void 0&&(e=F),e?Vr(e,bi()):[]}),ae=yi(e=>{let t=ie(e);return D.current.map(e=>v&&e===`reference`?v:F&&e===`floating`?F:t).filter(Boolean).flat()});R.useEffect(()=>{if(r||!l)return;function e(e){if(e.key===`Tab`){$r(F,Qr(ri(F)))&&ie().length===0&&!C&&ui(e);let t=ae(),n=ei(e);D.current[0]===`reference`&&n===v&&(ui(e),e.shiftKey?Oo(t[t.length-1]):Oo(t[1])),D.current[1]===`floating`&&n===F&&e.shiftKey&&(ui(e),Oo(t[0]))}}let t=ri(F);return t.addEventListener(`keydown`,e),()=>{t.removeEventListener(`keydown`,e)}},[r,v,F,l,D,C,ie,ae]),R.useEffect(()=>{if(r||!y)return;function e(e){let t=ei(e),n=ie().indexOf(t);n!==-1&&(te.current=n)}return y.addEventListener(`focusin`,e),()=>{y.removeEventListener(`focusin`,e)}},[r,y,ie]),R.useEffect(()=>{if(r||!d)return;function e(){ee.current=!0,setTimeout(()=>{ee.current=!1})}function t(e){let t=e.relatedTarget,n=e.currentTarget,r=ei(e);queueMicrotask(()=>{let i=b(),a=!($r(v,t)||$r(y,t)||$r(t,y)||$r(j?.portalNode,t)||t!=null&&t.hasAttribute(go(`focus-guard`))||A&&(ci(A.nodesRef.current,i).find(e=>$r(e.context?.elements.floating,t)||$r(e.context?.elements.domReference,t))||li(A.nodesRef.current,i).find(e=>[e.context?.elements.floating,si(e.context?.elements.floating)].includes(t)||e.context?.elements.domReference===t)));if(n===v&&F&&rs(F,D),c&&n!==v&&!(r!=null&&r.isConnected)&&Qr(ri(F))===ri(F).body){bn(F)&&F.focus();let e=te.current,t=ie(),n=t[e]||t[t.length-1]||F;bn(n)&&n.focus()}_.current.insideReactTree?_.current.insideReactTree=!1:(C||!l)&&t&&a&&!ee.current&&t!==ts()&&(P.current=!0,h(!1,e,`focus-out`))})}let n=!(A||!j);function i(){_o(ne),_.current.insideReactTree=!0,ne.current=window.setTimeout(()=>{_.current.insideReactTree=!1})}if(y&&bn(v))return v.addEventListener(`focusout`,t),v.addEventListener(`pointerdown`,e),y.addEventListener(`focusout`,t),n&&y.addEventListener(`focusout`,i,!0),()=>{v.removeEventListener(`focusout`,t),v.removeEventListener(`pointerdown`,e),y.removeEventListener(`focusout`,t),n&&y.removeEventListener(`focusout`,i,!0)}},[r,v,y,F,l,A,j,h,d,c,ie,C,b,D,_]);let oe=R.useRef(null),se=R.useRef(null),I=Xo([oe,j?.beforeInsideRef]),ce=Xo([se,j?.afterInsideRef]);R.useEffect(()=>{var e,t;if(r||!y)return;let n=Array.from((j==null||(e=j.portalNode)==null?void 0:e.querySelectorAll(`[`+go(`portal`)+`]`))||[]),i=(t=(A?li(A.nodesRef.current,b()):[]).find(e=>ai(e.context?.elements.domReference||null)))==null||(t=t.context)==null?void 0:t.elements.domReference,a=[y,i,...n,...x(),M.current,N.current,oe.current,se.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,D.current.includes(`reference`)||C?v:null].filter(e=>e!=null),o=l||C?Vo(a,!E,E):Vo(a);return()=>{o()}},[r,v,y,l,D,j,C,T,E,A,b,x]),hi(()=>{if(r||!bn(F))return;let e=Qr(ri(F));queueMicrotask(()=>{let t=ae(F),n=O.current,r=(typeof n==`number`?t[n]:n.current)||F,i=$r(F,e);!S&&!i&&m&&Oo(r,{preventScroll:r===F})})},[r,m,F,S,ae,O]),hi(()=>{if(r||!F)return;let e=ri(F);es(Qr(e));function t(e){let{reason:t,event:n,nested:r}=e;if([`hover`,`safe-polygon`].includes(t)&&n.type===`mouseleave`&&(P.current=!0),t===`outside-press`){if(r)P.current=!1;else if(fi(n)||pi(n))P.current=!1;else{let e=!1;document.createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?P.current=!1:P.current=!0}}}g.on(`openchange`,t);let n=e.createElement(`span`);n.setAttribute(`tabindex`,`-1`),n.setAttribute(`aria-hidden`,`true`),Object.assign(n.style,Ho),re&&v&&v.insertAdjacentElement(`afterend`,n);function i(){if(typeof k.current==`boolean`){let e=v||ts();return e&&e.isConnected?e:n}return k.current.current||n}return()=>{g.off(`openchange`,t);let r=Qr(e),a=$r(y,r)||A&&ci(A.nodesRef.current,b(),!1).some(e=>$r(e.context?.elements.floating,r)),o=i();queueMicrotask(()=>{let t=ns(o);k.current&&!P.current&&bn(t)&&(t===r||r===e.body||a)&&t.focus({preventScroll:!0}),n.remove()})}},[r,y,F,k,_,g,A,re,v,b]),R.useEffect(()=>(queueMicrotask(()=>{P.current=!1}),()=>{queueMicrotask($o)}),[r]),hi(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:d,open:m,onOpenChange:h,domReference:v}),()=>{j.setFocusManagerState(null)}},[r,j,l,m,h,d,v]),hi(()=>{r||F&&rs(F,D)},[r,F,D]);function le(e){return r||!u||!l?null:(0,z.jsx)(is,{ref:e===`start`?M:N,onClick:e=>h(!1,e.nativeEvent),children:typeof u==`string`?u:`Dismiss`})}let ue=!r&&T&&(!l||!C)&&(re||l);return(0,z.jsxs)(z.Fragment,{children:[ue&&(0,z.jsx)(Uo,{"data-type":`inside`,ref:I,onFocus:e=>{if(l){let e=ae();Oo(i[0]===`reference`?e[0]:e[e.length-1])}else if(j!=null&&j.preserveTabOrder&&j.portalNode){if(P.current=!1,wi(e,j.portalNode))Si(v)?.focus();else{var t;(t=j.beforeOutsideRef.current)==null||t.focus()}}}}),!C&&le(`start`),n,le(`end`),ue&&(0,z.jsx)(Uo,{"data-type":`inside`,ref:ce,onFocus:e=>{if(l)Oo(ae()[0]);else if(j!=null&&j.preserveTabOrder&&j.portalNode){if(d&&(P.current=!0),wi(e,j.portalNode))Ci(v)?.focus();else{var t;(t=j.afterOutsideRef.current)==null||t.focus()}}}})]})}var os={pointerdown:`onPointerDown`,mousedown:`onMouseDown`,click:`onClick`},ss={pointerdown:`onPointerDownCapture`,mousedown:`onMouseDownCapture`,click:`onClickCapture`},cs=e=>({escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0});function ls(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,elements:i,dataRef:a}=e,{enabled:o=!0,escapeKey:s=!0,outsidePress:c=!0,outsidePressEvent:l=`pointerdown`,referencePress:u=!1,referencePressEvent:d=`pointerdown`,ancestorScroll:f=!1,bubbles:p,capture:m}=t,h=ho(),g=yi(typeof c==`function`?c:()=>!1),_=typeof c==`function`?g:c,v=R.useRef(!1),{escapeKey:y,outsidePress:b}=cs(p),{escapeKey:x,outsidePress:S}=cs(m),C=R.useRef(!1),w=yi(e=>{if(!n||!o||!s||e.key!==`Escape`||C.current)return;let t=a.current.floatingContext?.nodeId,i=h?ci(h.nodesRef.current,t):[];if(!y&&(e.stopPropagation(),i.length>0)){let e=!0;if(i.forEach(t=>{var n;(n=t.context)!=null&&n.open&&!t.context.dataRef.current.__escapeKeyBubbles&&(e=!1)}),!e)return}r(!1,di(e)?e.nativeEvent:e,`escape-key`)}),T=yi(e=>{var t;let n=()=>{var t;w(e),(t=ei(e))==null||t.removeEventListener(`keydown`,n)};(t=ei(e))==null||t.addEventListener(`keydown`,n)}),E=yi(e=>{let t=a.current.insideReactTree;a.current.insideReactTree=!1;let n=v.current;if(v.current=!1,l===`click`&&n||t||typeof _==`function`&&!_(e))return;let o=ei(e),s=`[`+go(`inert`)+`]`,c=ri(i.floating).querySelectorAll(s),u=yn(o)?o:null;for(;u&&!Mn(u);){let e=Fn(u);if(Mn(e)||!yn(e))break;u=e}if(c.length&&yn(o)&&!ni(o)&&!$r(o,i.floating)&&Array.from(c).every(e=>!$r(u,e)))return;if(bn(o)&&k){let t=Mn(o),n=Nn(o),r=/auto|scroll/,i=t||r.test(n.overflowX),a=t||r.test(n.overflowY),s=i&&o.clientWidth>0&&o.scrollWidth>o.clientWidth,c=a&&o.clientHeight>0&&o.scrollHeight>o.clientHeight,l=n.direction===`rtl`,u=c&&(l?e.offsetX<=o.offsetWidth-o.clientWidth:e.offsetX>o.clientWidth),d=s&&e.offsetY>o.clientHeight;if(u||d)return}let d=a.current.floatingContext?.nodeId,f=h&&ci(h.nodesRef.current,d).some(t=>ti(e,t.context?.elements.floating));if(ti(e,i.floating)||ti(e,i.domReference)||f)return;let p=h?ci(h.nodesRef.current,d):[];if(p.length>0){let e=!0;if(p.forEach(t=>{var n;(n=t.context)!=null&&n.open&&!t.context.dataRef.current.__outsidePressBubbles&&(e=!1)}),!e)return}r(!1,e,`outside-press`)}),D=yi(e=>{var t;let n=()=>{var t;E(e),(t=ei(e))==null||t.removeEventListener(l,n)};(t=ei(e))==null||t.addEventListener(l,n)});R.useEffect(()=>{if(!n||!o)return;a.current.__escapeKeyBubbles=y,a.current.__outsidePressBubbles=b;let e=-1;function t(e){r(!1,e,`ancestor-scroll`)}function c(){window.clearTimeout(e),C.current=!0}function u(){e=window.setTimeout(()=>{C.current=!1},jn()?5:0)}let d=ri(i.floating);s&&(d.addEventListener(`keydown`,x?T:w,x),d.addEventListener(`compositionstart`,c),d.addEventListener(`compositionend`,u)),_&&d.addEventListener(l,S?D:E,S);let p=[];return f&&(yn(i.domReference)&&(p=Ln(i.domReference)),yn(i.floating)&&(p=p.concat(Ln(i.floating))),!yn(i.reference)&&i.reference&&i.reference.contextElement&&(p=p.concat(Ln(i.reference.contextElement)))),p=p.filter(e=>e!==d.defaultView?.visualViewport),p.forEach(e=>{e.addEventListener(`scroll`,t)}),()=>{s&&(d.removeEventListener(`keydown`,x?T:w,x),d.removeEventListener(`compositionstart`,c),d.removeEventListener(`compositionend`,u)),_&&d.removeEventListener(l,S?D:E,S),p.forEach(e=>{e.removeEventListener(`scroll`,t)}),window.clearTimeout(e)}},[a,i,s,_,l,n,r,f,o,y,b,w,x,T,E,S,D]),R.useEffect(()=>{a.current.insideReactTree=!1},[a,_,l]);let O=R.useMemo(()=>({onKeyDown:w,...u&&{[os[d]]:e=>{r(!1,e.nativeEvent,`reference-press`)},...d!==`click`&&{onClick(e){r(!1,e.nativeEvent,`reference-press`)}}}}),[w,r,u,d]),k=R.useMemo(()=>{function e(e){e.button===0&&(v.current=!0)}return{onKeyDown:w,onMouseDown:e,onMouseUp:e,[ss[l]]:()=>{a.current.insideReactTree=!0}}},[w,l,a]);return R.useMemo(()=>o?{reference:O,floating:k}:{},[o,O,k])}function us(e){let{open:t=!1,onOpenChange:n,elements:r}=e,i=lo(),a=R.useRef({}),[o]=R.useState(()=>uo()),s=mo()!=null,[c,l]=R.useState(r.reference),u=yi((e,t,r)=>{a.current.openEvent=e?t:void 0,o.emit(`openchange`,{open:e,event:t,reason:r,nested:s}),n?.(e,t,r)}),d=R.useMemo(()=>({setPositionReference:l}),[]),f=R.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return R.useMemo(()=>({dataRef:a,open:t,onOpenChange:u,elements:f,events:o,floatingId:i,refs:d}),[t,u,f,o,i,d])}function ds(e){let{elements:t,...n}=e===void 0?{}:e,{nodeId:r}=n,i=us({...n,elements:{reference:t?.reference??null,floating:t?.floating??null}}),a=n.rootContext||i,o=a.elements,[s,c]=R.useState(null),[l,u]=R.useState(null),d=o?.domReference||s,f=R.useRef(null),p=ho();hi(()=>{d&&(f.current=d)},[d]);let m=La({...n,elements:{...o,...l&&{reference:l}}}),h=R.useCallback(e=>{let t=yn(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=R.useCallback(e=>{(yn(e)||e===null)&&(f.current=e,c(e)),(yn(m.refs.reference.current)||m.refs.reference.current===null||e!==null&&!yn(e))&&m.refs.setReference(e)},[m.refs]),_=R.useMemo(()=>({...m.refs,setReference:g,setPositionReference:h,domReference:f}),[m.refs,g,h]),v=R.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),y=R.useMemo(()=>({...m,...a,refs:_,elements:v,nodeId:r}),[m,_,v,r,a]);return hi(()=>{a.dataRef.current.floatingContext=y;let e=p?.nodesRef.current.find(e=>e.id===r);e&&(e.context=y)}),R.useMemo(()=>({...m,context:y,refs:_,elements:v}),[m,_,v,y])}function fs(){return Jr()&&Kr()}function ps(e,t){t===void 0&&(t={});let{open:n,onOpenChange:r,events:i,dataRef:a,elements:o}=e,{enabled:s=!0,visibleOnly:c=!0}=t,l=R.useRef(!1),u=R.useRef(-1),d=R.useRef(!0);R.useEffect(()=>{if(!s)return;let e=gn(o.domReference);function t(){!n&&bn(o.domReference)&&o.domReference===Qr(ri(o.domReference))&&(l.current=!0)}function r(){d.current=!0}function i(){d.current=!1}return e.addEventListener(`blur`,t),fs()&&(e.addEventListener(`keydown`,r,!0),e.addEventListener(`pointerdown`,i,!0)),()=>{e.removeEventListener(`blur`,t),fs()&&(e.removeEventListener(`keydown`,r,!0),e.removeEventListener(`pointerdown`,i,!0))}},[o.domReference,n,s]),R.useEffect(()=>{if(!s)return;function e(e){let{reason:t}=e;(t===`reference-press`||t===`escape-key`)&&(l.current=!0)}return i.on(`openchange`,e),()=>{i.off(`openchange`,e)}},[i,s]),R.useEffect(()=>()=>{_o(u)},[]);let f=R.useMemo(()=>({onMouseLeave(){l.current=!1},onFocus(e){if(l.current)return;let t=ei(e.nativeEvent);if(c&&yn(t)){if(fs()&&!e.relatedTarget){if(!d.current&&!ii(t))return}else if(!oi(t))return}r(!0,e.nativeEvent,`focus`)},onBlur(e){l.current=!1;let t=e.relatedTarget,n=e.nativeEvent,i=yn(t)&&t.hasAttribute(go(`focus-guard`))&&t.getAttribute(`data-type`)===`outside`;u.current=window.setTimeout(()=>{let e=Qr(o.domReference?o.domReference.ownerDocument:document);!t&&e===o.domReference||$r(a.current.floatingContext?.refs.floating.current,e)||$r(o.domReference,e)||i||r(!1,n,`focus`)})}}),[a,o.domReference,r,c]);return R.useMemo(()=>s?{reference:f}:{},[s,f])}function ms(e,t,n){let r=new Map,i=n===`item`,a=e;if(i&&e){let{[Xa]:t,[Za]:n,...r}=e;a=r}return{...n===`floating`&&{tabIndex:-1,[Ya]:``},...a,...t.map(t=>{let r=t?t[n]:null;return typeof r==`function`?e?r(e):null:r}).concat(e).reduce((e,t)=>(t&&Object.entries(t).forEach(t=>{let[n,a]=t;if(!(i&&[Xa,Za].includes(n))){if(n.indexOf(`on`)===0){if(r.has(n)||r.set(n,[]),typeof a==`function`){var o;(o=r.get(n))==null||o.push(a),e[n]=function(){var e=[...arguments];return r.get(n)?.map(t=>t(...e)).find(e=>e!==void 0)}}}else e[n]=a}}),e),{})}}function hs(e){e===void 0&&(e=[]);let t=e.map(e=>e?.reference),n=e.map(e=>e?.floating),r=e.map(e=>e?.item),i=R.useCallback(t=>ms(t,e,`reference`),t),a=R.useCallback(t=>ms(t,e,`floating`),n),o=R.useCallback(t=>ms(t,e,`item`),r);return R.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:o}),[i,a,o])}var gs=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function _s(e,t){t===void 0&&(t={});let{open:n,elements:r,floatingId:i}=e,{enabled:a=!0,role:o=`dialog`}=t,s=lo(),c=r.domReference?.id||s,l=R.useMemo(()=>si(r.floating)?.id||i,[r.floating,i]),u=gs.get(o)??o,d=mo()!=null,f=R.useMemo(()=>u===`tooltip`||o===`label`?{[`aria-`+(o===`label`?`labelledby`:`describedby`)]:n?l:void 0}:{"aria-expanded":n?`true`:`false`,"aria-haspopup":u===`alertdialog`?`dialog`:u,"aria-controls":n?l:void 0,...u===`listbox`&&{role:`combobox`},...u===`menu`&&{id:c},...u===`menu`&&d&&{role:`menuitem`},...o===`select`&&{"aria-autocomplete":`none`},...o===`combobox`&&{"aria-autocomplete":`list`}},[u,l,d,n,c,o]),p=R.useMemo(()=>{let e={id:l,...u&&{role:u}};return u===`tooltip`||o===`label`?e:{...e,...u===`menu`&&{"aria-labelledby":c}}},[u,l,c,o]),m=R.useCallback(e=>{let{active:t,selected:n}=e,r={role:`option`,...t&&{id:l+`-fui-option`}};switch(o){case`select`:case`combobox`:return{...r,"aria-selected":n}}return{}},[l,o]);return R.useMemo(()=>a?{reference:f,floating:p,item:m}:{},[a,f,p,m])}var vs=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?`-`:``)+e.toLowerCase());function ys(e,t){return typeof e==`function`?e(t):e}function bs(e,t){let[n,r]=R.useState(e);return e&&!n&&r(!0),R.useEffect(()=>{if(!e&&n){let e=setTimeout(()=>r(!1),t);return()=>clearTimeout(e)}},[e,n,t]),n}function xs(e,t){t===void 0&&(t={});let{open:n,elements:{floating:r}}=e,{duration:i=250}=t,a=(typeof i==`number`?i:i.close)||0,[o,s]=R.useState(`unmounted`),c=bs(n,a);return!c&&o===`close`&&s(`unmounted`),hi(()=>{if(r){if(n){s(`initial`);let e=requestAnimationFrame(()=>{Ne.flushSync(()=>{s(`open`)})});return()=>{cancelAnimationFrame(e)}}s(`close`)}},[n,r]),{isMounted:c,status:o}}function Ss(e,t){t===void 0&&(t={});let{initial:n={opacity:0},open:r,close:i,common:a,duration:o=250}=t,s=e.placement,c=s.split(`-`)[0],l=R.useMemo(()=>({side:c,placement:s}),[c,s]),u=typeof o==`number`,d=(u?o:o.open)||0,f=(u?o:o.close)||0,[p,m]=R.useState(()=>({...ys(a,l),...ys(n,l)})),{isMounted:h,status:g}=xs(e,{duration:o}),_=_i(n),v=_i(r),y=_i(i),b=_i(a);return hi(()=>{let e=ys(_.current,l),t=ys(y.current,l),n=ys(b.current,l),r=ys(v.current,l)||Object.keys(e).reduce((e,t)=>(e[t]=``,e),{});if(g===`initial`&&m(t=>({transitionProperty:t.transitionProperty,...n,...e})),g===`open`&&m({transitionProperty:Object.keys(r).map(vs).join(`,`),transitionDuration:d+`ms`,...n,...r}),g===`close`){let r=t||e;m({transitionProperty:Object.keys(r).map(vs).join(`,`),transitionDuration:f+`ms`,...n,...r})}},[f,y,_,v,b,d,g,l]),{isMounted:h,styles:p}}function Cs(e,t,n){return n===void 0&&(n=!0),e.filter(e=>e.parentId===t&&(!n||e.context?.open)).flatMap(t=>[t,...Cs(e,t.id,n)])}function ws(e,t){let[n,r]=e,i=!1,a=t.length;for(let e=0,o=a-1;e=r!=l>=r&&n<=(c-a)*(r-s)/(l-s)+a&&(i=!i)}return i}function Ts(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Es(e){e===void 0&&(e={});let{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,i={current:-1},a=!1,o=null,s=null,c=typeof performance<`u`?performance.now():0;function l(e,t){let n=performance.now(),r=n-c;if(o===null||s===null||r===0)return o=e,s=t,c=n,null;let i=e-o,a=t-s,l=Math.sqrt(i*i+a*a)/r;return o=e,s=t,c=n,l}let u=e=>{let{x:n,y:o,placement:s,elements:c,onClose:u,nodeId:d,tree:f}=e;return function(e){function p(){_o(i),u()}if(_o(i),!c.domReference||!c.floating||s==null||n==null||o==null)return;let{clientX:m,clientY:h}=e,g=[m,h],_=Ao(e),v=e.type===`mouseleave`,y=ko(c.floating,_),b=ko(c.domReference,_),x=c.domReference.getBoundingClientRect(),S=c.floating.getBoundingClientRect(),C=s.split(`-`)[0],w=n>S.right-S.width/2,T=o>S.bottom-S.height/2,E=Ts(g,x),D=S.width>x.width,O=S.height>x.height,k=(D?x:S).left,A=(D?x:S).right,j=(O?x:S).top,M=(O?x:S).bottom;if(y&&(a=!0,!v))return;if(b&&(a=!1),b&&!v){a=!0;return}if(v&&yn(e.relatedTarget)&&ko(c.floating,e.relatedTarget)||f&&Cs(f.nodesRef.current,d).length)return;if(C===`top`&&o>=x.bottom-1||C===`bottom`&&o<=x.top+1||C===`left`&&n>=x.right-1||C===`right`&&n<=x.left+1)return p();let N=[];switch(C){case`top`:N=[[k,x.top+1],[k,S.bottom-1],[A,S.bottom-1],[A,x.top+1]];break;case`bottom`:N=[[k,S.top+1],[k,x.bottom-1],[A,x.bottom-1],[A,S.top+1]];break;case`left`:N=[[S.right-1,M],[S.right-1,j],[x.left+1,j],[x.left+1,M]];break;case`right`:N=[[x.right-1,M],[x.right-1,j],[S.left+1,j],[S.left+1,M]]}function P(e){let[n,r]=e;switch(C){case`top`:return[[D?n+t/2:w?n+t*4:n-t*4,r+t+1],[D?n-t/2:w?n+t*4:n-t*4,r+t+1],[S.left,w||D?S.bottom-t:S.top],[S.right,w?D?S.bottom-t:S.top:S.bottom-t]];case`bottom`:return[[D?n+t/2:w?n+t*4:n-t*4,r-t],[D?n-t/2:w?n+t*4:n-t*4,r-t],[S.left,w||D?S.top+t:S.bottom],[S.right,w?D?S.top+t:S.bottom:S.top+t]];case`left`:{let e=[n+t+1,O?r+t/2:T?r+t*4:r-t*4],i=[n+t+1,O?r-t/2:T?r+t*4:r-t*4];return[[T||O?S.right-t:S.left,S.top],[T?O?S.right-t:S.left:S.right-t,S.bottom],e,i]}case`right`:return[[n-t,O?r+t/2:T?r+t*4:r-t*4],[n-t,O?r-t/2:T?r+t*4:r-t*4],[T||O?S.left+t:S.right,S.top],[T?O?S.left+t:S.right:S.left+t,S.bottom]]}}if(!ws([m,h],N)){if(a&&!E)return p();if(!v&&r){let t=l(e.clientX,e.clientY);if(t!==null&&t<.1)return p()}ws([m,h],P([n,o]))?!a&&r&&(i.current=window.setTimeout(p,40)):p()}}};return u.__options={blockPointerEvents:n},u}function W(e,t){let n=(t?.editor??B()).getExtension(e);if(!n)throw Error(`Extension not found`,{cause:{plugin:e}});return n}function G(e,t){let{store:n}=W(e,t);if(!n)throw Error(`Store not found on plugin`,{cause:{plugin:e}});return Le(n,t?.selector,t?.equalityFn)}function Ds(e){let t=new DOMRect,n=`getBoundingClientRect`in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(t=n()),t):n()}function Os(e,t){return e?t?(n,r,i)=>{let a=e(n,r,i),o=t(n,r,i);return()=>{a?.(),o?.()}}:e:t}var ks=e=>{let t=B(),n=Je(),{whileElementsMounted:r,middleware:i,...a}=e.useFloatingOptions??{},{refs:o,floatingStyles:s,context:c,middlewareData:l}=ds({whileElementsMounted:Os(xa,e.useFloatingOptions?.whileElementsMounted),middleware:[...i??[],Ga()],...a}),{isMounted:u,styles:d}=Ss(c,e.useTransitionStylesProps),{status:f}=xs(c,e.useTransitionStatusProps),{getFloatingProps:p}=hs([ls(c,e.useDismissProps),xo(c,{enabled:!1,...e.useHoverProps})]),m=(0,R.useRef)(``),h=(0,R.useRef)(null),g=Ja([h,o.setFloating]);if((0,R.useEffect)(()=>{if(e.reference){let n=`element`in e.reference?e.reference.element:void 0;n!==void 0&&(e.focusManagerProps?.disabled||!t.isWithinEditor(n))&&o.setReference(n);let r=`getClientRects`in e.reference?e.reference.getClientRects:n?()=>n.getClientRects():void 0;o.setPositionReference({getBoundingClientRect:Ds(e.reference),...r?{getClientRects:r}:{},contextElement:n})}},[e.reference,o,e.focusManagerProps?.disabled,t]),(0,R.useEffect)(()=>{(f===`initial`||f===`open`)&&h.current&&tt(h.current)&&(m.current=h.current.innerHTML)},[f,e.reference,e.children]),!u||!n)return!1;let _={...e.elementProps,style:{display:`flex`,...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...d,...l.hide?.referenceHidden?{visibility:`hidden`}:{}},...p()};return f===`close`?(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(`div`,{ref:g,..._,dangerouslySetInnerHTML:{__html:m.current}})}):e.focusManagerProps?.disabled?(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(`div`,{ref:g,..._,children:(0,z.jsx)(nt,{children:e.children})})}):(0,z.jsx)(Jo,{root:n,children:(0,z.jsx)(as,{...e.focusManagerProps,context:c,children:(0,z.jsx)(`div`,{ref:g,..._,children:(0,z.jsx)(nt,{children:e.children})})})})},As=e=>{let{position:t,children:n,...r}=e,{from:i,to:a}=t||{},o=B(),s=Ue(),c=(0,R.useMemo)(()=>{if(i!==void 0&&a!==void 0)return{element:s?.firstElementChild||void 0,getBoundingClientRect:()=>he(o.prosemirrorView,i,a??i)}},[o,s,i,a]);return(0,z.jsx)(ks,{reference:c,...r,children:t!==void 0&&n})},js=(e={},t=[])=>(0,R.useMemo)(()=>{let t=L.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},t),Ms=e=>{let[t,n]=(0,R.useState)(!1),r=He({editor:e.editor,selector:({editor:e})=>e.isEmpty}),i=V(),a=(0,R.useCallback)(()=>{n(!0)},[]),o=(0,R.useCallback)(()=>{n(!1)},[]);return(0,R.useEffect)(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(i.Comments.Editor,{autoFocus:e.autoFocus,className:`bn-comment-editor`,editor:e.editor,onFocus:a,onBlur:o,editable:e.editable}),e.actions&&(0,z.jsx)(`div`,{className:`bn-comment-actions-wrapper`,children:e.actions({isFocused:t,isEmpty:r})})]})},{textColor:Ns,backgroundColor:Ps,...Fs}=we,Is=re.create({blockSpecs:{paragraph:Te()},styleSpecs:Fs});function Ls(e){return!e.hasUnsavedContent||!e.confirmBeforeDiscard||(e.confirm??(e=>window.confirm(e)))(e.message)}var Rs=se(({editor:e,options:{submitOnEnter:t=!0,onSubmit:n}})=>{let r=!1;async function i(){if(!(!e.isEditable||e.isEmpty||r)){r=!0;try{await n(e)}finally{r=!1}}}function a({event:t}){let n=e.prosemirrorView;return!n.editable||n.composing||t.isComposing||t.keyCode===229?!1:(t.repeat||i(),!0)}return{key:`commentEditorSubmit`,submit:i,runsBefore:[`default`],keyboardShortcuts:{"Mod-Enter":a,...t?{Enter:a}:{}}}}),zs=g.create({name:`comment`,excludes:``,inclusive:!1,keepOnSplit:!0,group:D,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute(`data-orphan`),renderHTML:e=>e.orphan?{"data-orphan":`true`}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute(`data-bn-thread-id`),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:``}}},renderHTML({HTMLAttributes:e}){return[`span`,ne(e,{class:`bn-thread-mark`})]},parseHTML(){return[{tag:`span.bn-thread-mark`}]},extendMarkSchema(e){return e.name===`comment`?{blocknoteIgnore:!0}:{}}}),Bs=new Ce(`blocknote-comments`);function Vs(e,t){let n=new Map;return e.descendants((e,r)=>{e.marks.forEach(i=>{if(i.type.name===t){let t=i.attrs.threadId;if(!t)return;let a=r,o=a+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(a,s.from),to:Math.max(o,s.to)})}})}),n}var Hs=se(({editor:e,options:{schema:t,threadStore:n,resolveUsers:r,confirmBeforeDiscard:i=!0,submitOnEnter:a=!0}})=>{if(!r)throw Error(`resolveUsers is required to be defined when using comments`);if(!n)throw Error(`threadStore is required to be defined when using comments`);let o=Se(r),s=zs.name,c=_e({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(t,n){t.selectedThreadId!==n.selectedThreadId&&e.transact(e=>e.setMeta(Bs,!0))}}),l=t=>{e.transact(e=>{e.doc.descendants((n,r)=>{n.marks.forEach(i=>{if(i.type.name===s){let a=i.type,o=i.attrs.threadId,s=t.get(o),l=!!(!s||s.resolved||s.deletedAt);if(l!==i.attrs.orphan){let t=Math.max(r,0),s=Math.min(r+n.nodeSize,e.doc.content.size-1,e.doc.content.size-1);e.removeMark(t,s,i),e.addMark(t,s,a.create({...i.attrs,orphan:l})),l&&c.state.selectedThreadId===o&&c.setState(e=>({...e,selectedThreadId:void 0}))}}})})})};return{key:`comments`,store:c,userStore:o,runsBefore:[`link`],tiptapExtensions:[zs],prosemirrorPlugins:[new fe({key:Bs,state:{init(){return{decorations:ie.empty}},apply(e,t){let n=e.getMeta(Bs);if(!e.docChanged&&!n)return t;let r=e.docChanged?Vs(e.doc,s):c.state.threadPositions;(r.size>0||c.state.threadPositions.size>0)&&c.setState(e=>({...e,threadPositions:r}));let i=[];if(c.state.selectedThreadId){let e=r.get(c.state.selectedThreadId);e&&i.push(xe.inline(e.from,e.to,{class:`bn-thread-mark-selected`}))}return{decorations:ie.create(e.doc,i)}}},props:{decorations(e){return Bs.getState(e)?.decorations??ie.empty},handleClick:(e,t,n)=>{if(n.button!==0)return!1;let r=e.state.doc.nodeAt(t);if(!r)return c.setState(e=>({...e,selectedThreadId:void 0})),!1;let i=r.marks.find(e=>e.type.name===s&&e.attrs.orphan!==!0);if(!i)return c.state.selectedThreadId!==void 0&&c.setState(e=>({...e,selectedThreadId:void 0})),!1;let a=i.attrs.threadId;return a!==c.state.selectedThreadId&&(c.setState(e=>({...e,selectedThreadId:a})),!0)}}})],threadStore:n,mount(){let t=n.subscribe(l);l(n.getThreads());let r=e.onSelectionChange(()=>{c.state.pendingComment&&c.setState(e=>({...e,pendingComment:!1}))});return()=>{t(),r()}},selectThread(t,n=!0){if(c.state.selectedThreadId!==t&&(c.setState(e=>({...e,pendingComment:!1,selectedThreadId:t})),t&&n)){let n=c.state.threadPositions.get(t);if(!n)return;(e.prosemirrorView?.domAtPos(n.from).node)?.scrollIntoView({behavior:`smooth`,block:`center`})}},startPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!0})),e.domElement?.focus(),e.getExtension(ae)?.showSelection(!0,`comments`)},stopPendingComment(){c.setState(e=>({...e,selectedThreadId:void 0,pendingComment:!1})),e.getExtension(ae)?.showSelection(!1,`comments`)},async createThread(t){let r=await n.createThread(t);n.addThreadToDocument?await n.addThreadToDocument({threadId:r.id,selection:e.transact(e=>e.selection),editor:e}):e._tiptapEditor.commands.setMark(s,{orphan:!1,threadId:r.id})},commentEditorSchema:t,confirmBeforeDiscard:i,submitOnEnter:a}}),Us=Object.defineProperty,Ws=(e,t)=>{for(var n in t)Us(e,n,{get:t[n],enumerable:!0})},Gs={};Ws(Gs,{ActiveEmoji:()=>Gl,Empty:()=>Wl,List:()=>Bl,Loading:()=>Hl,Root:()=>Sl,Search:()=>Cl,SkinTone:()=>Kl,SkinToneSelector:()=>Vl,Viewport:()=>Tl});var Ks=`'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif`,qs=[`none`,`light`,`medium-light`,`medium`,`medium-dark`,`dark`];function Js(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ys=2,Xs=null;function Zs(e){try{Xs??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0})}catch{}if(!Xs||(queueMicrotask(()=>{Xs&&=null}),Xs.canvas.width=Ys,Xs.canvas.height=Ys,Xs.font=`2px ${Ks}`,Xs.textBaseline=`middle`,Xs.measureText(e).width>=Ys*2))return!1;Xs.fillStyle=`#00f`,Xs.fillText(e,0,0);let t=Xs.getImageData(0,0,Ys,Ys).data;Xs.clearRect(0,0,Ys,Ys),Xs.fillStyle=`#f00`,Xs.fillText(e,0,0);let n=Xs.getImageData(0,0,Ys,Ys).data;for(let e=0;et===void 0?void 0:e(t)}function tc(e){if(typeof e!=`string`)throw Error();return e}function nc(e){if(typeof e!=`number`)throw Error();return e}function rc(e){if(typeof e!=`boolean`)throw Error();return e}function ic(e){return t=>{if(typeof t!=`object`||!t)throw Error();let n={};for(let r in e){let i=t[r];i===void 0&&e[r](void 0),n[r]=e[r](i)}return n}}function ac(e){return t=>{if(!Array.isArray(t))throw Error();return t.length>0&&e(t[0]),t}}var oc=`frimousse/data`,sc=ic({locale:tc,emojis:ac(ic({emoji:tc,category:nc,label:tc,version:nc,tags:ac(tc),aliases:ec(ac(tc)),countryFlag:ec(rc),skins:ec(ic({light:tc,"medium-light":tc,medium:tc,"medium-dark":tc,dark:tc}))})),categories:ac(ic({index:nc,label:tc})),skinTones:ic({light:tc,"medium-light":tc,medium:tc,"medium-dark":tc,dark:tc})});function cc({name:e=oc}={}){let t=`${e}/`,n=ic({data:sc,metadata:e=>e});return{get(e){try{return Qs(localStorage,`${t}${e}`,n)}catch{return null}},set(e,n,...[r]){try{$s(localStorage,`${t}${e}`,{data:n,metadata:r})}catch{}},delete(e){try{localStorage.removeItem(`${t}${e}`)}catch{}},clear(){try{for(let e of Object.keys(localStorage))e.startsWith(t)&&localStorage.removeItem(e)}catch{}}}}var lc=new Map,uc=new WeakMap,dc=new Set;function fc({emojiVersion:e,emojibaseUrl:t}){return t??(typeof e==`number`?`https://cdn.jsdelivr.net/npm/emojibase-data@${Math.floor(e)}`:`https://cdn.jsdelivr.net/npm/emojibase-data@latest`)}function pc(e,t){return(t.resolveEmojiData?uc.get(t.resolveEmojiData):lc)?.get(gc(e,t))?.data}function mc(e,t,n){let r=_c(e,t),i=r.load?.status===`pending`?r.load:void 0;r.data=n,r.load=void 0,i?.complete();for(let e of dc)e()}async function hc(e,t,n){n.signal?.throwIfAborted();let r=await e(t,n);return n.signal?.throwIfAborted(),mc(t,{...n,resolveEmojiData:e},r),r}function gc(e,t){return t.resolveEmojiData?JSON.stringify([e,t.emojibaseUrl,t.emojiVersion]):JSON.stringify([e,fc(t)])}function _c(e,t){let n=lc;if(t.resolveEmojiData){let e=uc.get(t.resolveEmojiData);n=e??new Map,e||uc.set(t.resolveEmojiData,n)}let r=gc(e,t),i=n.get(r);return i||(i={},n.set(r,i)),i}var vc=(e,t)=>`${e}/${t}/data.json`,yc=(e,t)=>`${e}/${t}/messages.json`,bc=`bn.da.de.en-gb.en.es-mx.es.et.fi.fr.hi.hu.it.ja.ko.lt.ms.nb.nl.pl.pt.ru.sv.th.uk.vi.zh-hant.zh`.split(`.`),xc=`en`,Sc=e=>`frimousse/metadata/${e}`,Cc=new Map;function wc(e){return cc({name:`frimousse/data/${e}`})}async function Tc(e,t){try{return(await fetch(e,{method:`HEAD`,signal:t})).headers.get(`etag`)}catch{return null}}async function Ec(e,t,n){let[{emojis:r,emojisEtag:i},{messages:a,messagesEtag:o}]=await Promise.all([fetch(vc(e,t),{signal:n}).then(async e=>({emojis:await e.json(),emojisEtag:e.headers.get(`etag`)})),fetch(yc(e,t),{signal:n}).then(async e=>({messages:await e.json(),messagesEtag:e.headers.get(`etag`)}))]);return{emojis:r,messages:a,emojisEtag:i,messagesEtag:o}}async function Dc(e,t,n){let[r,i]=await Promise.all([Tc(vc(e,t),n),Tc(yc(e,t),n)]);return{emojisEtag:r,messagesEtag:i}}function Oc(e){return e.skins?e.skins.filter(e=>typeof e.tone==`number`).reduce((e,t)=>{let n=qs[t.tone];return e[n]=t.emoji,e},{}):void 0}async function kc(e,t,n){let{emojis:r,emojisEtag:i,messages:a,messagesEtag:o}=await Ec(e,t,n);n?.throwIfAborted();let s=a.subgroups.find(e=>e.key===`country-flag`||e.key===`subdivision-flag`),c=a.groups.filter(e=>e.key!==`component`),l=r.filter(e=>`group`in e),u=c.map(e=>({index:e.order,label:Js(e.message)})),d=a.skinTones.reduce((e,t)=>(e[t.key]=Js(t.message),e),{}),f={locale:t,emojis:l.map(e=>{let t=e.skins?.filter(e=>Array.isArray(e.tone)).map(e=>e.emoji);return{emoji:e.emoji,category:e.group,version:e.version,label:Js(e.label),tags:e.tags??[],countryFlag:s&&e.subgroup===s.order||void 0,skins:Oc(e),aliases:t?.length?t:void 0}}),categories:u,skinTones:d};return wc(e).set(t,f,{emojisEtag:i,messagesEtag:o}),f}function Ac(e){let t=new Map;for(let n of e)t.has(n.version)||t.set(n.version,n.emoji);let n=[...t.keys()].sort((e,t)=>t-e),r=n[0]??0,i=Zs(`🇪🇺`);for(let e of n)if(Zs(t.get(e)))return{emojiVersion:e,countryFlags:i};return{emojiVersion:r,countryFlags:i}}var jc=ic({emojiVersion:ec(nc),countryFlags:ec(rc),revalidated:ac(tc)});function Mc(e){try{return Qs(sessionStorage,Sc(e),jc)}catch{return null}}function Nc(e,t){try{$s(sessionStorage,Sc(e),t)}catch{}}function Pc(e,t,n){if(n?.aborted)return Promise.reject(n.reason);let r=vc(e,t),i=pc(t,{emojibaseUrl:e});if(i)return Promise.resolve(i);let a=Cc.get(r);if(!a||a.controller.signal.aborted){let n=new AbortController,i=Fc(e,t,n.signal).then(r=>(n.signal.throwIfAborted(),mc(t,{emojibaseUrl:e},r),r)).finally(()=>{Cc.get(r)?.promise===i&&Cc.delete(r)});a={promise:i,controller:n,callers:0},Cc.set(r,a)}let o=a;o.callers++;let s;return new Promise((e,t)=>{s=()=>t(n?.reason),n?.addEventListener(`abort`,s,{once:!0}),o.promise.then(e,t)}).finally(()=>{n?.removeEventListener(`abort`,s),o.callers--,o.callers===0&&Cc.get(r)===o&&o.controller.abort()})}async function Fc(e,t,n){let r=Mc(e),i=wc(e).get(t),a;if(!i)a=await kc(e,t,n);else if(r?.revalidated.includes(t))a=i.data;else try{let{emojisEtag:r,messagesEtag:o}=await Dc(e,t,n);n.throwIfAborted(),a=!r||!o||r!==i.metadata?.emojisEtag||o!==i.metadata?.messagesEtag?await kc(e,t,n):i.data}catch{n.throwIfAborted(),a=i.data}n.throwIfAborted();let o=Mc(e),s=o?.revalidated??[];return Nc(e,{...o,revalidated:s.includes(t)?s:[...s,t]}),a}var Ic=async(e,{emojiVersion:t,emojibaseUrl:n,signal:r}={})=>{let i=Lc(e),a=fc({emojiVersion:t,emojibaseUrl:n}),o=await Pc(a,i,r);r?.throwIfAborted();let s=Mc(a),c=s?.emojiVersion!==void 0&&s.countryFlags!==void 0?{emojiVersion:s.emojiVersion,countryFlags:s.countryFlags}:Ac(o.emojis);return Nc(a,{...c,revalidated:s?.revalidated??[i]}),{locale:i,emojis:o.emojis.filter(e=>{let n=e.version<=(t??c.emojiVersion);return e.countryFlag?n&&c.countryFlags:n}),categories:o.categories,skinTones:o.skinTones}};function Lc(e){return bc.find(t=>t===e)||(console.warn(`Locale "${e}" is not supported, using "${xc}" instead.`),xc)}function Rc(e){return qs.includes(e)?e:(console.warn(`Skin tone "${e}" is not valid, using "none" instead.`),`none`)}function zc(e,t){let n=[];if(t<=0)return n;for(let r=0,i=e.length;r{let t=0;e.label.toLowerCase().includes(n)&&(t+=10);for(let r of e.tags)r.toLowerCase().includes(n)&&(t+=1);return t>0&&(r.set(e,t),!0)}).sort((e,t)=>(r.get(t)??0)-(r.get(e)??0))}function Vc(e,t,n,r){let i=Bc(e.emojis,r),a=[],o=[],s=[],c={},l=0,u=0;for(let e of i)c[e.category]||(c[e.category]=[]),c[e.category].push({emoji:n&&n!==`none`&&e.skins?e.skins[n]:e.emoji,label:e.label});for(let n of e.categories){let e=c[n.index];if(!e||e.length===0)continue;let r=zc(Array.from(e),t).map(e=>({categoryIndex:l,emojis:e}));a.push(...r),o.push({label:n.label,rowsCount:r.length,startRowIndex:u}),s.push(u),l++,u+=r.length}return{count:i.length,categories:o,categoriesStartRowIndices:s,rows:a,skinTones:e.skinTones}}function Hc(e){let t={},n=null,r=null,i=new Set,a=()=>{if(n){t=n,n=null;for(let e of i)e(t)}r=null},o=()=>n??t,s=e=>{n??=t,Object.assign(n,typeof e==`function`?e(o()):e),r||=requestAnimationFrame(a)};return t=e(s,o),{get:o,set:s,subscribe:e=>(i.add(e),()=>i.delete(e))}}function Uc(e){let[t]=(0,R.useState)(e);return t}function Wc(e){let t=(0,R.createContext)(null);return{useStore:()=>{let n=(0,R.useContext)(t);if(!n)throw Error(e);return n},Provider:({store:e,children:n})=>(0,z.jsx)(t.Provider,{value:e,children:n})}}function Gc(e,t,n=Object.is){let[r,i]=(0,R.useState)(()=>t(e.get()));return(0,R.useEffect)(()=>e.subscribe(()=>{let r=t(e.get());i(e=>n(e,r)?e:r)}),[e,t,n]),(0,R.useDebugValue)(r),r}function Kc(e,t,n){return Gc(e,(0,R.useCallback)(e=>e[t],[t]),n)}var qc=2;function Jc(e,t,n,r,i){let a=0;return Hc((o,s)=>({locale:t,columns:n,sticky:r,skinTone:i,onEmojiSelect:e,data:null,search:``,interaction:`none`,activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:e=>{let t=s(),n=e?.data??t.data,r=e?.categoryHeaderHeight??t.categoryHeaderHeight,i=e?.rowHeight??t.rowHeight,c=e?.viewportHeight??t.viewportHeight;if(!n||n.rows.length===0||!r||!i||!c)return o({...e,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let l=0,u=0;for(let e of n.categories)if(u++*r+e.startRowIndex*i{s().updateViewportState({data:e,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:e=>{o({search:e,interaction:e?`keyboard`:`none`})},onActiveEmojiChange:(e,t,n)=>{if(o({interaction:e,activeColumnIndex:t,activeRowIndex:n}),e!==`keyboard`)return;let{listRef:r,viewportRef:i,sticky:c,rowHeight:l,viewportHeight:u,categoryHeaderHeight:d}=s(),f=r?.current,p=i?.current;if(!f||!p||!l||!d||!u)return;let m=n;m===0&&p.scrollTo({top:0,behavior:`instant`});let h=f.querySelector(`[aria-rowindex="${m}"]`);if(!(h instanceof HTMLElement))return;let g=h.offsetTop,_=getComputedStyle(h),v=Number.parseFloat(_.scrollMarginTop),y=Number.parseFloat(_.scrollMarginBottom),b=a+v;c&&gx)&&p.scrollTo({top:Math.max(g{o({interaction:`none`,activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:e=>{s().updateViewportState({rowHeight:e})},onCategoryHeaderHeightChange:e=>{s().updateViewportState({categoryHeaderHeight:e})},onViewportSizeChange:(e,t)=>{s().updateViewportState({viewportWidth:e,viewportHeight:t})},onViewportScroll:e=>{a=e,s().updateViewportState()}}))}var{useStore:Yc,Provider:Xc}=Wc(`EmojiPicker.Root is missing.`);function Zc(e){return e.search}function Qc(e){return e.interaction===`none`?void 0:e.data?.rows[e.activeRowIndex]?.emojis[e.activeColumnIndex]}function $c(e){return e.data===void 0||typeof e.data?.count==`number`&&e.data.count===0}function el(e){return e.data===null||e.viewportHeight===null||e.rowHeight===null||e.categoryHeaderHeight===null}function tl(e){return e.data?.rows.length}function nl(e){return e.data?.categories.length}function rl(e){return e.data?.categoriesStartRowIndices}function il(e){return e.data?.skinTones}function al(e,t){return e?.emoji===t?.emoji}function ol(e,t){return e?.categoryIndex!==t?.categoryIndex||e?.emojis.length!==t?.emojis.length?!1:!!e?.emojis.every((e,n)=>al(e,t?.emojis[n]))}var sl=`‍`,cl=/\p{Emoji_Modifier_Base}/u,ll=/\uFE0F$/,ul=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,dl={light:`🏻`,"medium-light":`🏼`,medium:`🏽`,"medium-dark":`🏾`,dark:`🏿`};function fl(e,t){if(!e.split(sl).some(e=>cl.test(e)))return e;let n=e.split(sl).map(e=>e.replace(ul,``)).join(sl);return t===`none`?n:n.split(sl).map((e,n,r)=>{let i=r.length>1;return!cl.test(e)||i&&e===`🤝`?e:e.replace(ll,``)+dl[t]}).join(sl)}function pl(e){return qs.map(t=>({skinTone:t,emoji:fl(e,t)}))}function ml(){let e=Gc(Yc(),Qc,al);return(0,R.useDeferredValue)(e)}function hl(e=`✋`){let t=Yc(),n=Kc(t,`skinTone`),r=(0,R.useMemo)(()=>pl(e),[e]);return[n,(0,R.useCallback)(e=>{t.set({skinTone:e})},[]),r]}function gl(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>n in t&&e[n]===t[n])}function _l(...e){}function vl(e,t){let n=null;if(typeof window.requestIdleCallback==`function`)n=window.requestIdleCallback(e,t);else{let r=Date.now();n=window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,(t?.timeout??50)-(Date.now()-r))})},10)}return()=>{typeof window.cancelIdleCallback==`function`?window.cancelIdleCallback(n):window.clearTimeout(n)}}var yl=typeof window<`u`?R.useLayoutEffect:R.useEffect;function bl(e){let t=(0,R.useRef)(e);return yl(()=>{t.current=e}),(0,R.useCallback)((...e)=>t.current(...e),[])}function xl({emojiVersion:e,emojibaseUrl:t,resolveEmojiData:n=Ic}){let[r,i]=(0,R.useState)(void 0),a=Yc(),o=Kc(a,`locale`),s=Kc(a,`columns`),c=Kc(a,`skinTone`),l=Kc(a,`search`),u=bl((e,t)=>n===Ic?Ic(e,t):hc(n,e,t));return(0,R.useEffect)(()=>{let n=new AbortController,r=n.signal;return Promise.resolve().then(()=>u(o,{emojiVersion:e,emojibaseUrl:t,signal:r})).then(e=>{r.aborted||i(e)}).catch(e=>{r.aborted||console.error(e)}),()=>{n.abort()}},[e,t,o,u]),(0,R.useEffect)(()=>{if(r)return vl(()=>{a.get().onDataChange(Vc(r,s,c,l))},{timeout:100})},[r,s,c,l]),null}var Sl=(0,R.forwardRef)(({locale:e=`en`,columns:t=9,skinTone:n=`none`,onEmojiSelect:r=_l,emojiVersion:i,emojibaseUrl:a,resolveEmojiData:o,onFocusCapture:s,onBlurCapture:c,children:l,style:u,sticky:d=!0,...f},p)=>{let m=bl(r),h=Uc(()=>Jc(m,e,t,d,Rc(n))),[g,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),y=(0,R.useCallback)(e=>{e&&(v.current=e,h.set({rootRef:v}))},[]);yl(()=>{h.set({locale:e})},[e]),yl(()=>{h.set({columns:t})},[t]),yl(()=>{h.set({sticky:d})},[d]),yl(()=>{h.set({skinTone:Rc(n)})},[n]);let b=(0,R.useCallback)(e=>{s?.(e);let{searchRef:t,viewportRef:n}=h.get(),r=e.target===t?.current||e.target.hasAttribute(`frimousse-search`),i=e.target===n?.current||e.target.hasAttribute(`frimousse-viewport`);e.isDefaultPrevented()||(_(r||i),e.isDefaultPrevented()||(_(r||i),i?h.get().onActiveEmojiChange(`keyboard`,0,0):r&&h.get().search===``&&h.set({interaction:`none`})))},[s]),x=(0,R.useCallback)(e=>{c?.(e),!e.isDefaultPrevented()&&!e.currentTarget.contains(e.relatedTarget)&&_(!1)},[c]);return yl(()=>{g||h.get().onActiveEmojiReset()},[g]),(0,R.useImperativeHandle)(p,()=>v.current),(0,R.useEffect)(()=>{if(!g)return;function e(e){if(e.defaultPrevented||!e.key.startsWith(`Arrow`)&&e.key!==`Enter`)return;let{data:t,onEmojiSelect:n,onActiveEmojiChange:r,interaction:i,activeColumnIndex:a,activeRowIndex:o}=h.get();if(e.key===`Enter`){let t=Qc(h.get());t&&(e.preventDefault(),n(t))}if(e.key.startsWith(`Arrow`)){let n=a,s=o;if(e.preventDefault(),i!==`none`){if(t?.rows&&t.rows.length>0)switch(e.key){case`ArrowLeft`:if(n===0){let e=s-1,r=t.rows[e];r&&(s=e,n=r.emojis.length-1)}else--n;break;case`ArrowRight`:if(n===t.rows[s].emojis.length-1){let e=s+1;t.rows[e]&&(s=e,n=0)}else n+=1;break;case`ArrowUp`:{let e=t.rows[s-1];e&&(--s,e.emojis[n]||(n=e.emojis.length-1));break}case`ArrowDown`:{let e=t.rows[s+1];e&&(s+=1,e.emojis[n]||(n=e.emojis.length-1));break}}r(`keyboard`,n,s)}else r(`keyboard`,0,0)}}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[g]),yl(()=>{let e=null,t=null,n=null,r=null,i=h.subscribe(i=>{v.current&&(e!==i.viewportWidth&&(e=i.viewportWidth,v.current.style.setProperty(`--frimousse-viewport-width`,`${i.viewportWidth}px`)),t!==i.viewportHeight&&(t=i.viewportHeight,v.current.style.setProperty(`--frimousse-viewport-height`,`${i.viewportHeight}px`)),n!==i.rowHeight&&(n=i.rowHeight,v.current.style.setProperty(`--frimousse-row-height`,`${i.rowHeight}px`)),r!==i.categoryHeaderHeight&&(r=i.categoryHeaderHeight,v.current.style.setProperty(`--frimousse-category-header-height`,`${i.categoryHeaderHeight}px`)))}),{viewportWidth:a,viewportHeight:o,rowHeight:s,categoryHeaderHeight:c}=h.get();return a&&v.current.style.setProperty(`--frimousse-viewport-width`,`${a}px`),o&&v.current.style.setProperty(`--frimousse-viewport-height`,`${o}px`),s&&v.current.style.setProperty(`--frimousse-row-height`,`${s}px`),c&&v.current.style.setProperty(`--frimousse-category-header-height`,`${c}px`),i},[]),(0,z.jsx)(`div`,{"data-focused":g?``:void 0,"frimousse-root":``,onBlurCapture:x,onFocusCapture:b,...f,ref:y,style:{"--frimousse-emoji-font":Ks,...u},children:(0,z.jsxs)(Xc,{store:h,children:[(0,z.jsx)(xl,{emojibaseUrl:a,emojiVersion:i,resolveEmojiData:o}),l]})})}),Cl=(0,R.forwardRef)(({value:e,defaultValue:t,onChange:n,...r},i)=>{let a=Yc(),o=(0,R.useRef)(null),s=(0,R.useCallback)(e=>{e&&(o.current=e,a.set({searchRef:o}))},[]),c=typeof e==`string`,l=(0,R.useRef)(c);(0,R.useEffect)(()=>{l.current=c},[c]),yl(()=>{a.set({search:typeof e==`string`?e:typeof t==`string`?t:``})},[]),yl(()=>{typeof e==`string`&&a.get().onSearchChange(e)},[e]);let u=(0,R.useCallback)(e=>{n?.(e),e.isDefaultPrevented()||a.get().onSearchChange(e.target.value)},[n]);return(0,R.useImperativeHandle)(i,()=>o.current),(0,z.jsx)(`input`,{autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,enterKeyHint:`done`,"frimousse-search":``,placeholder:`Search…`,spellCheck:!1,type:`search`,...r,defaultValue:t,onChange:u,ref:s,value:e})}),wl=(0,R.memo)(()=>{let e=ml();return e?(0,z.jsx)(`div`,{"aria-live":`polite`,style:{border:0,clip:`rect(0, 0, 0, 0)`,height:1,margin:-1,overflow:`hidden`,padding:0,position:`absolute`,whiteSpace:`nowrap`,width:1,wordWrap:`normal`},children:e.label}):null}),Tl=(0,R.forwardRef)(({children:e,onScroll:t,onKeyDown:n,style:r,...i},a)=>{let o=Yc(),s=(0,R.useRef)(null),c=(0,R.useCallback)(e=>{e&&(s.current=e,o.set({viewportRef:s}))},[]),l=Gc(o,tl),u=Gc(o,nl),d=(0,R.useCallback)(e=>{t?.(e),o.get().onViewportScroll(e.currentTarget.scrollTop)},[t]);return yl(()=>{if(!s.current)return;let e=new ResizeObserver(([e])=>{let t=e?.borderBoxSize[0]?.inlineSize??0,n=e?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:r,viewportHeight:i,viewportWidth:a}=o.get();(i!==n||a!==t)&&r(t,n)});return e.observe(s.current),o.get().onViewportSizeChange(s.current.offsetWidth,s.current.clientHeight),()=>{e.disconnect()}},[]),(0,R.useImperativeHandle)(a,()=>s.current),(0,z.jsxs)(`div`,{"frimousse-viewport":``,...i,onScroll:d,ref:c,style:{position:`relative`,boxSizing:`border-box`,contain:`layout paint`,containIntrinsicSize:typeof l==`number`&&typeof u==`number`?`var(--frimousse-viewport-width, auto) calc(${l} * var(--frimousse-row-height) + ${u} * var(--frimousse-category-header-height))`:void 0,overflowY:`auto`,overscrollBehavior:`contain`,scrollbarGutter:`stable`,willChange:`scroll-position`,...r},children:[(0,z.jsx)(wl,{}),e]})});function El(e,t,n){return{emoji:{...e,isActive:n},role:`gridcell`,"aria-colindex":t,"aria-selected":n||void 0,"aria-label":e.label,"data-active":n?``:void 0,"frimousse-emoji":``,style:{fontFamily:`var(--frimousse-emoji-font)`},tabIndex:-1}}function Dl(e,t=!1){return{role:t?void 0:`row`,"aria-rowindex":t?void 0:e,"frimousse-row":``,style:{contain:t?void 0:`content`,height:t?void 0:`var(--frimousse-row-height)`,display:`flex`}}}function Ol(e,t){return{"frimousse-category":``,style:{contain:`content`,top:t?`calc(${e} * var(--frimousse-category-header-height) + ${t.startRowIndex} * var(--frimousse-row-height))`:void 0,height:t?`calc(var(--frimousse-category-header-height) + ${t.rowsCount} * var(--frimousse-row-height))`:void 0,width:`100%`,pointerEvents:`none`,position:`absolute`}}}function kl(e,t=!1,n=!0){return{category:e,"frimousse-category-header":``,style:{contain:t?void 0:`layout paint`,height:t?void 0:`var(--frimousse-category-header-height)`,pointerEvents:`auto`,position:n?`sticky`:void 0,top:0}}}function Al(e,t,n,r){return{"frimousse-list-sizer":``,style:{position:`relative`,boxSizing:`border-box`,height:`calc(${e} * var(--frimousse-row-height) + ${t} * var(--frimousse-category-header-height))`,paddingTop:`calc(${n} * var(--frimousse-row-height) + ${r} * var(--frimousse-category-header-height))`}}}function jl(e,t,n){return{"aria-colcount":e,"aria-rowcount":t,"frimousse-list":``,style:{"--frimousse-list-columns":e,...n},role:`grid`}}function Ml(e){e.preventDefault()}var Nl=(0,R.memo)(({Emoji:e,emoji:t,columnIndex:n,rowIndex:r})=>{let i=Yc(),a=Gc(i,e=>Qc(e)?.emoji===t.emoji),o=(0,R.useCallback)(()=>{i.get().onEmojiSelect(t)},[t]),s=(0,R.useCallback)(()=>{i.get().onActiveEmojiChange(`pointer`,n,r)},[n,r]),c=(0,R.useCallback)(()=>{i.get().onActiveEmojiReset()},[]);return(0,z.jsx)(e,{...El(t,n,a),onClick:o,onPointerDown:Ml,onPointerEnter:s,onPointerLeave:c})}),Pl=(0,R.memo)(({Row:e,Emoji:t,rowIndex:n})=>{let r=Gc(Yc(),e=>e.data?.rows[n],ol);return r?(0,z.jsx)(e,{...Dl(n),children:r.emojis.map((e,r)=>(0,z.jsx)(Nl,{columnIndex:r,Emoji:t,emoji:e,rowIndex:n},e.label))}):null}),Fl=(0,R.memo)(({CategoryHeader:e,categoryIndex:t})=>{let n=Yc(),r=Gc(n,e=>e.data?.categories[t],gl),i=Kc(n,`sticky`);return r?(0,z.jsx)(`div`,{...Ol(t,r),children:(0,z.jsx)(e,{...kl({label:r.label},!1,i)})}):null}),Il=(0,R.memo)(({CategoryHeader:e,Row:t,Emoji:n})=>{let r=(0,R.useRef)(null),i=Yc(),a=Kc(i,`columns`),o=(0,R.useMemo)(()=>Array(a).fill({emoji:`🙂`,label:``}),[a]),s=(0,R.useMemo)(()=>({label:`Category`}),[]),c=(0,R.useRef)(null),l=(0,R.useRef)(null);return yl(()=>{let e=r.current?.parentElement?.parentElement;if(!e||!c.current||!l.current)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.height,{onRowHeightChange:n,onCategoryHeaderHeightChange:r,rowHeight:a,categoryHeaderHeight:o}=i.get();t.target===c.current&&a!==e&&n(e),t.target===l.current&&o!==e&&r(e)}});t.observe(e),t.observe(c.current),t.observe(l.current);let{onRowHeightChange:n,onCategoryHeaderHeightChange:a}=i.get();return n(c.current.clientHeight),a(l.current.clientHeight),()=>{t.disconnect()}},[]),(0,z.jsxs)(`div`,{"aria-hidden":!0,ref:r,style:{height:0,visibility:`hidden`},children:[(0,z.jsx)(`div`,{"frimousse-row-sizer":``,ref:c,children:(0,z.jsx)(t,{...Dl(-1,!0),children:o.map((e,t)=>(0,z.jsx)(n,{...El(e,t,!1)},t))})}),(0,z.jsx)(`div`,{...Ol(-1),children:(0,z.jsx)(`div`,{"frimousse-category-header-sizer":``,ref:l,children:(0,z.jsx)(e,{...kl(s,!0)})})})]})});function Ll({category:e,...t}){return(0,z.jsx)(`div`,{...t,children:e.label})}function Rl({emoji:e,...t}){return(0,z.jsx)(`button`,{type:`button`,...t,children:e.emoji})}function zl({...e}){return(0,z.jsx)(`div`,{...e})}var Bl=(0,R.forwardRef)(({style:e,components:t,...n},r)=>{let i=Yc(),a=(0,R.useRef)(null),o=(0,R.useCallback)(e=>{e&&(a.current=e,i.set({listRef:a}))},[]),s=t?.CategoryHeader??Ll,c=t?.Emoji??Rl,l=t?.Row??zl,u=Kc(i,`columns`),d=Kc(i,`viewportStartRowIndex`),f=Kc(i,`viewportEndRowIndex`),p=Gc(i,tl),m=Gc(i,rl,gl),h=(0,R.useMemo)(()=>m?.filter(e=>ea.current),!p||!m||g===0?(0,z.jsx)(`div`,{...jl(u,0,e),...n,children:(0,z.jsx)(`div`,{...Al(0,0,0,0),children:(0,z.jsx)(Il,{CategoryHeader:s,Emoji:c,Row:l})})}):(0,z.jsx)(`div`,{...jl(u,p,e),...n,ref:o,children:(0,z.jsxs)(`div`,{...Al(p,g,d,h),children:[(0,z.jsx)(Il,{CategoryHeader:s,Emoji:c,Row:l}),Array.from({length:f-d+1},(e,t)=>{let n=d+t,r=m.indexOf(n);return(0,z.jsxs)(R.Fragment,{children:[r>=0&&(0,z.jsx)(`div`,{style:{height:`var(--frimousse-category-header-height)`}}),(0,z.jsx)(Pl,{Emoji:c,Row:l,rowIndex:n})]},n)}),Array.from({length:g},(e,t)=>(0,z.jsx)(Fl,{CategoryHeader:s,categoryIndex:t},t))]})})}),Vl=(0,R.forwardRef)(({emoji:e,onClick:t,"aria-label":n=`Change skin tone`,...r},i)=>{let a=Gc(Yc(),il,gl),[o,s,c]=hl(e),l=(0,R.useMemo)(()=>Math.max(0,c.findIndex(e=>e.skinTone===o)),[o,c]),u=c[l],d=c[(l+1)%c.length].skinTone,f=d===`none`?void 0:a?.[d],p=(0,R.useCallback)(e=>{t?.(e),e.isDefaultPrevented()||s(d)},[t,s,d]);return(0,z.jsx)(`button`,{type:`button`,...r,"aria-label":n+(f?` (${f})`:``),"aria-live":`polite`,"frimousse-skin-tone-selector":``,onClick:p,ref:i,children:u.emoji})});function Hl({children:e,...t}){return Gc(Yc(),el)?(0,z.jsx)(`span`,{"frimousse-loading":``,...t,children:e}):null}function Ul({children:e}){return e({search:Gc(Yc(),Zc)})}function Wl({children:e,...t}){return Gc(Yc(),$c)?(0,z.jsx)(`span`,{"frimousse-empty":``,...t,children:typeof e==`function`?(0,z.jsx)(Ul,{children:e}):e}):null}function Gl({children:e}){return e({emoji:ml()})}function Kl({children:e,emoji:t}){let[n,r,i]=hl(t);return e({skinTone:n,setSkinTone:r,skinToneVariations:i})}Sl.displayName=`EmojiPicker.Root`,Cl.displayName=`EmojiPicker.Search`,Tl.displayName=`EmojiPicker.Viewport`,Bl.displayName=`EmojiPicker.List`,Hl.displayName=`EmojiPicker.Loading`,Wl.displayName=`EmojiPicker.Empty`,Vl.displayName=`EmojiPicker.SkinToneSelector`,Gl.displayName=`EmojiPicker.ActiveEmoji`,Kl.displayName=`EmojiPicker.SkinTone`;var ql=Oe();function Jl(e,t){if(e.isDestroyed||t.defaultPrevented||!t.cancelable||!e.isEditable||t.inputType!==`insertParagraph`&&t.inputType!==`insertLineBreak`||!ce()&&!pe())return;let n=e.view,r=n.root,i=(r.getSelection?.call(r)??n.dom.ownerDocument.getSelection())?.anchorNode,a=(i?.nodeType===1?i:i?.parentElement)?.closest(`[data-node-view-content-react]`);if(!a||!n.dom.contains(a))return;let o=n.input.lastKeyCode;o===13&&(n.input.lastKeyCode=null),n.domObserver.forceFlush(),n.domObserver.flush();let s=new KeyboardEvent(`keydown`,{key:`Enter`,code:`Enter`,keyCode:13,shiftKey:t.inputType===`insertLineBreak`,bubbles:!0,cancelable:!0});n.someProp(`handleKeyDown`,e=>e(n,s))?(t.preventDefault(),n.input.lastIOSEnter=0,clearTimeout(n.input.lastIOSEnterFallbackTimeout)):o===13&&(n.input.lastKeyCode=o)}var Yl=new Ce(`reactMobileEnter`),Xl=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Zl=({contentComponent:e})=>{let t=(0,ql.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})};function Ql(){let e=new Set,t={},n=!1,r=()=>{!n&&e.size&&(n=!0,queueMicrotask(()=>{n=!1,e.forEach(e=>e())}))};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(e,n){t={...t,[e]:Ne.createPortal(n.reactElement,n.element,e)},r()},removeRenderer(e){let n={...t};delete n[e],t=n,r()}}}var $l=class extends R.Component{constructor(e){super(e),this.editorContentRef=R.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.view.updateRoot(),e.setOptions({element:t}),e.contentComponent=Ql(),e.createNodeViews(),e.registerPlugin(new fe({key:Yl,props:{handleDOMEvents:{beforeinput:(t,n)=>Jl(e,n)}}})),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||(e.unregisterPlugin(Yl),e.view.setProps({nodeViews:{}})),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{ref:Xl(t,this.editorContentRef),...n}),e?.contentComponent&&(0,z.jsx)(Zl,{contentComponent:e.contentComponent})]})}},eu=(0,R.forwardRef)((e,t)=>{let n=R.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return R.createElement($l,{key:n,innerRef:t,...e})}),tu=R.memo(eu);typeof window>`u`||typeof window<`u`&&window.next;var nu=(0,R.createContext)({editor:null});nu.Consumer;var ru=(0,R.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),iu=()=>(0,R.useContext)(ru);R.forwardRef((e,t)=>{let{onDragStart:n}=iu(),r=e.as||`div`;return(0,z.jsx)(r,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),R.createContext({markViewContentRef:()=>{}});var au=(0,R.createContext)({get editor(){throw Error(`useTiptap must be used within a provider`)}});au.displayName=`TiptapContext`;var ou=()=>(0,R.useContext)(au);function su({children:e,...t}){let n=`editor`in t?t.editor:t.instance;if(!n)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let r=(0,R.useMemo)(()=>({editor:n}),[n]),i=(0,R.useMemo)(()=>({editor:n}),[n]);return(0,z.jsx)(nu.Provider,{value:i,children:(0,z.jsx)(au.Provider,{value:r,children:e})})}su.displayName=`Tiptap`;function cu({...e}){let{editor:t}=ou();return(0,z.jsx)(tu,{editor:t,...e})}cu.displayName=`Tiptap.Content`,Object.assign(su,{Content:cu}),u();var lu=Object.defineProperty,uu=(e,t)=>{let n={};for(var r in e)lu(n,r,{get:e[r],enumerable:!0});return t||lu(n,Symbol.toStringTag,{value:`Module`}),n},du=e=>{let{blockId:t,children:n,...r}=e,i=B(),a=(0,R.useMemo)(()=>i.transact(e=>{if(!t)return;let n=te(t,e.doc);if(!n)return;let r=ye(i.prosemirrorView,n.posBeforeNode,t);return r?{element:r}:void 0}),[i,t]);return(0,z.jsx)(ks,{reference:a,...r,children:t!==void 0&&n})},fu=e=>{let t=V(),n=H(),r=B(),i=r.getBlock(e.blockId),[a,o]=(0,R.useState)(``),s=(0,R.useCallback)(e=>{o(e.currentTarget.value)},[]),c=(0,R.useCallback)(()=>{r.getBlock(e.blockId)&&r.updateBlock(e.blockId,{props:{name:O(a),url:a}})},[r,e.blockId,a]);return i?(0,z.jsx)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:c,submitButton:(0,z.jsx)(t.FilePanel.Button,{className:`bn-button`,type:`submit`,"data-test":`embed-input-button`,children:n.file_panel.embed.embed_button[i.type]||n.file_panel.embed.embed_button.file}),children:(0,z.jsx)(t.FilePanel.TextInput,{className:`bn-text-input`,placeholder:n.file_panel.embed.url_placeholder,value:a,onChange:s,"data-test":`embed-input`})})}):null},pu=e=>{let t=V(),n=H(),{setLoading:r}=e,i=B(),a=i.getBlock(e.blockId),[o,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{o&&setTimeout(()=>{s(!1)},3e3)},[o]);let c=(0,R.useCallback)(t=>{if(t===null)return;async function n(t){if(r(!0),i.uploadFile!==void 0)try{let n=await i.uploadFile(t,e.blockId);if(!i.getBlock(e.blockId))return;typeof n==`string`&&(n={props:{name:t.name,url:n}}),i.updateBlock(e.blockId,n)}catch{s(!0)}finally{r(!1)}}n(t)},[e.blockId,i,r]);if(!a)return null;let l=i.schema.blockSpecs[a.type],u=l.implementation.meta.fileBlockAccept?.length?l.implementation.meta.fileBlockAccept.join(`,`):`*/*`;return(0,z.jsxs)(t.FilePanel.TabPanel,{className:`bn-tab-panel`,children:[(0,z.jsx)(t.FilePanel.FileInput,{className:`bn-file-input`,"data-test":`upload-input`,accept:u,placeholder:n.file_panel.upload.file_placeholder[a.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:c}),o&&(0,z.jsx)(`div`,{className:`bn-error-text`,children:n.file_panel.upload.upload_error})]})},mu=e=>{let t=V(),n=H(),r=B(),[i,a]=(0,R.useState)(!1),o=e.tabs??[...r.uploadFile===void 0?[]:[{name:n.file_panel.upload.title,tabPanel:(0,z.jsx)(pu,{blockId:e.blockId,setLoading:a})}],{name:n.file_panel.embed.title,tabPanel:(0,z.jsx)(fu,{blockId:e.blockId})}],[s,c]=(0,R.useState)(e.defaultOpenTab||o[0].name);return(0,z.jsx)(t.FilePanel.Root,{className:`bn-panel`,defaultOpenTab:s,openTab:s,setOpenTab:c,tabs:o,loading:i})},hu=e=>{let t=B(),n=W(E),r=G(E),i=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(e,r,i)=>{e||n.closeMenu(),i===`escape-key`&&t.focus()},middleware:[za(10),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:90},...e.floatingUIOptions?.elementProps}}),[r,t,n,e.floatingUIOptions]),a=e.filePanel||mu;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(du,{blockId:r,...i,children:r&&(0,z.jsx)(a,{blockId:r})})})},gu={bold:rn,italic:Gt,underline:Nt,strike:It,code:ln};function _u(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema===`boolean`}var vu=e=>{let t=H(),n=V(),r=B(),i=He({editor:r,selector:({editor:t})=>{if(t.isEditable&&_u(e.basicTextStyle,t)&&(t.getSelection()?.blocks||[t.getTextCursorPosition().block]).find(e=>e.content!==void 0))return e.basicTextStyle in t.getActiveStyles()?{active:!0}:{active:!1}}}),a=(0,R.useCallback)(e=>{r.focus(),r.toggleStyles({[e]:!0})},[r]);if(i===void 0)return null;let o=gu[e.basicTextStyle];return(0,z.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":e.basicTextStyle,onClick:()=>a(e.basicTextStyle),isSelected:i.active,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:x(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:(0,z.jsx)(o,{})})},yu=(0,R.createContext)(`desktop`);function bu(){return(0,R.useContext)(yu)}var xu=e=>{let t=e.textColor||`default`,n=e.backgroundColor||`default`,r=e.size||16,i=(0,R.useMemo)(()=>({pointerEvents:`none`,fontSize:(r*.75).toString()+`px`,height:r.toString()+`px`,lineHeight:r.toString()+`px`,textAlign:`center`,width:r.toString()+`px`}),[r]);return(0,z.jsx)(`div`,{className:`bn-color-icon`,"data-background-color":n,"data-text-color":t,style:i,children:`A`})},Su=[`default`,`gray`,`brown`,`red`,`orange`,`yellow`,`green`,`blue`,`purple`,`pink`],Cu=e=>{let t=V(),n=H();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(()=>e.text?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(t.Generic.Menu.Label,{children:n.color_picker.text_title}),Su.map(r=>(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.text.setColor(r)},"data-test":`text-color-`+r,icon:(0,z.jsx)(xu,{textColor:r,size:e.iconSize}),checked:e.text.color===r,children:n.color_picker.colors[r]},`text-color-`+r))]}):null,{}),(0,z.jsx)(()=>e.background?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(t.Generic.Menu.Label,{children:n.color_picker.background_title}),Su.map(r=>(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{e.onClick?.(),e.background.setColor(r)},"data-test":`background-color-`+r,icon:(0,z.jsx)(xu,{backgroundColor:r,size:e.iconSize}),checked:e.background.color===r,children:n.color_picker.colors[r]},`background-color-`+r))]}):null,{})]})};function wu(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema===`string`}var Tu=()=>{let e=V(),t=H(),n=bu(),r=Je(),i=B(),a=wu(`text`,i),o=wu(`background`,i),s=He({editor:i,selector:({editor:e})=>{if(!e.isEditable||!(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return;let t=wu(`text`,e),n=wu(`background`,e);if(t||n)return{textColor:t?e.getActiveStyles().textColor||`default`:void 0,backgroundColor:n?e.getActiveStyles().backgroundColor||`default`:void 0}}}),c=(0,R.useCallback)(e=>{if(!a)throw Error(`Tried to set text color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({textColor:e}):i.addStyles({textColor:e}),i.focus()},[i,a]),l=(0,R.useCallback)(e=>{if(!o)throw Error(`Tried to set background color, but style does not exist in editor schema.`);e==="default"?i.removeStyles({backgroundColor:e}):i.addStyles({backgroundColor:e}),i.focus()},[o,i]);return s===void 0?null:(0,z.jsxs)(e.Generic.Menu.Root,{portalElement:r,preventFocusOnOpen:n===`mobile`,children:[(0,z.jsx)(e.Generic.Menu.Trigger,{children:(0,z.jsx)(e.FormattingToolbar.Button,{className:`bn-button`,"data-test":`colors`,label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:(0,z.jsx)(xu,{textColor:s.textColor,backgroundColor:s.backgroundColor,size:20})})}),(0,z.jsx)(e.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{text:s.textColor?{color:s.textColor,setColor:c}:void 0,background:s.backgroundColor?{color:s.backgroundColor,setColor:l}:void 0})})]})};function Eu(){let e=H();return(0,z.jsx)(`button`,{className:`bn-screen-reader-only-submit`,tabIndex:-1,type:`submit`,children:e.generic.form_submit})}var Du=e=>{for(let t of me)if(e.startsWith(t))return e;return`${de}://${e}`},Ou=e=>{let t=V(),n=H(),{editLink:r}=W(be),{url:i,text:a,showTextField:o}=e,[s,c]=(0,R.useState)(i),[l,u]=(0,R.useState)(a);(0,R.useEffect)(()=>{c(i),u(a)},[a,i]);let d=(0,R.useCallback)(e=>c(e.currentTarget.value),[]),f=(0,R.useCallback)(e=>u(e.currentTarget.value),[]),p=(0,R.useCallback)(()=>{r(Du(s),l,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1)},[r,s,l,e]);return(0,z.jsxs)(t.Generic.Form.Root,{onSubmit:p,submitButton:(0,z.jsx)(Eu,{}),children:[(0,z.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`url`,icon:(0,z.jsx)(Ut,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:s,onChange:d}),o!==!1&&(0,z.jsx)(t.Generic.Form.TextInput,{className:`bn-text-input`,name:`title`,icon:(0,z.jsx)(Pt,{}),placeholder:n.link_toolbar.form.title_placeholder,value:l,onChange:f})]})};function ku(e){return`link`in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link===`link`}var Au=()=>{let e=B(),t=Ue(),n=V(),r=H(),i=Je(),a=W(A),{showSelection:o}=W(ae),[s,c]=(0,R.useState)(!1);(0,R.useEffect)(()=>(o(s,`createLinkButton`),()=>o(!1,`createLinkButton`)),[s,o]);let l=(0,R.useCallback)(t=>{t||e.focus(),c(t)},[e]),u=He({editor:e,selector:({editor:e})=>{if(e.isEditable&&!e.prosemirrorState.selection.empty&&ku(e)&&!v(e.prosemirrorState.selection)&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{url:e.getSelectedLinkUrl(),text:e.getSelectedText(),range:{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}}}});return(0,R.useEffect)(()=>{c(!1)},[u]),(0,R.useEffect)(()=>{let n=t=>{e.isEditable&&(t.ctrlKey||t.metaKey)&&t.key===`k`&&(c(!0),t.preventDefault())};return t?.addEventListener(`keydown`,n),()=>{t?.removeEventListener(`keydown`,n)}},[e,t]),u===void 0?null:(0,z.jsxs)(n.Generic.Popover.Root,{open:s,onOpenChange:l,portalElement:i,children:[(0,z.jsx)(n.Generic.Popover.Trigger,{children:(0,z.jsx)(n.FormattingToolbar.Button,{className:`bn-button`,"data-test":`createLink`,label:r.formatting_toolbar.link.tooltip,mainTooltip:r.formatting_toolbar.link.tooltip,secondaryTooltip:x(r.formatting_toolbar.link.secondary_tooltip,r.generic.ctrl_shortcut),icon:(0,z.jsx)(Ut,{}),onClick:()=>l(!s)})}),(0,z.jsx)(n.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(Ou,{url:u.url||``,text:u.text,range:u.range,showTextField:!1,setToolbarOpen:e=>a.store.setState(e)})})]})},ju=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,caption:`string`}))return n}}),[a,o]=(0,R.useState)(!1),s=(0,R.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,R.useCallback)(e=>{i!==void 0&&j(r,i.type,{caption:`string`})&&r.updateBlock(i.id,{props:{caption:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:(0,z.jsx)(Kt,{}),onClick:()=>s(!a)})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,z.jsx)(Eu,{}),children:(0,z.jsx)(t.Generic.Form.TextInput,{name:`file-caption`,icon:(0,z.jsx)(Kt,{}),value:i.props.caption,autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onChange:c})})})]})},Mu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&(n.focus(),n.removeBlocks([r.id]))},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:(0,z.jsx)(wt,{}),onClick:i})},Nu=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,name:`string`}))return n}}),[a,o]=(0,R.useState)(!1),s=(0,R.useCallback)(e=>{e||r.focus(),o(e)},[r]),c=(0,R.useCallback)(e=>{i!==void 0&&j(r,i.type,{name:`string`})&&r.updateBlock(i.id,{props:{name:e.currentTarget.value}})},[i,r]);return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{open:a,onOpenChange:s,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[i.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:(0,z.jsx)(tn,{}),onClick:()=>s(!a)})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(t.Generic.Form.Root,{onSubmit:()=>s(!1),submitButton:(0,z.jsx)(Eu,{}),children:(0,z.jsx)(t.Generic.Form.TextInput,{name:`file-name`,icon:(0,z.jsx)(tn,{}),value:i.props.name,autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[i.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onChange:c})})})]})},Pu=()=>{let e=H(),t=V(),n=Je(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}});return i===void 0?null:(0,z.jsxs)(t.Generic.Popover.Root,{onOpenChange:e=>{e||r.focus()},portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,mainTooltip:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[i.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:(0,z.jsx)(kt,{})})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-panel-popover`,variant:`panel-popover`,children:(0,z.jsx)(mu,{blockId:i.id})})]})},Fu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canNestBlock:e.canNestBlock()}}}),i=(0,R.useCallback)(()=>{r!==void 0&&r.canNestBlock&&(n.focus(),n.nestBlock())},[n,r]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`nestBlock`,onClick:i,isDisabled:!r.canNestBlock,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:x(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,z.jsx)(qt,{})})},Iu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(e.isEditable&&(e.getSelection()?.blocks||[e.getTextCursorPosition().block]).find(e=>e.content!==void 0))return{canUnnestBlock:e.canUnnestBlock()}}}),i=(0,R.useCallback)(()=>{r!==void 0&&r.canUnnestBlock&&(n.focus(),n.unnestBlock())},[n,r]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`unnestBlock`,onClick:i,isDisabled:!r.canUnnestBlock,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:x(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:(0,z.jsx)(Jt,{})})},Lu={paragraph:Pt,heading:en,heading_2:$t,heading_3:Qt,heading_4:Zt,heading_5:Xt,heading_6:Yt,toggle_heading:en,toggle_heading_2:$t,toggle_heading_3:Qt,quote:Lt,toggle_list:Ot,bullet_list:Bt,numbered_list:Vt,check_list:Ht},Ru=e=>C(e).map(({key:t,type:n,props:r})=>({name:e.dictionary.slash_menu[t].title,type:n,props:r,icon:Lu[t]})),zu=e=>{let t=V(),n=bu(),r=Je(),i=B(),a=He({editor:i,selector:({editor:e})=>e.getSelection()?.blocks||[e.getTextCursorPosition().block]}),o=a[0],s=(0,R.useMemo)(()=>(e.items||Ru(i)).filter(e=>j(i,e.type,Object.fromEntries(Object.entries(e.props||{}).map(([e,t])=>[e,typeof t])))),[i,e.items]),c=(0,R.useMemo)(()=>s.map(e=>{let t=e.icon,n=e.type===o.type,r=Object.entries(e.props||{}).filter(([e,t])=>t!==o.props[e]).length===0;return{text:e.name,icon:(0,z.jsx)(t,{size:16}),onClick:()=>{i.focus(),i.transact(()=>{for(let t of a)i.updateBlock(t,{type:e.type,props:e.props})})},isSelected:n&&r}}),[i,s,o.props,o.type,a]);return!(0,R.useMemo)(()=>c.find(e=>e.isSelected)!==void 0,[c])||!i.isEditable?null:(0,z.jsx)(t.FormattingToolbar.Select,{className:`bn-select`,items:c,portalElement:r,preventFocusOnOpen:n===`mobile`})},Bu=()=>{let e=H(),t=V(),n=B(),r=W(`comments`),{store:i}=W(A),a=He({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),o=(0,R.useCallback)(()=>{r.startPendingComment(),i.setState(!1)},[r,i]);return a?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,z.jsx)(dn,{}),onClick:o})},Vu=()=>B().getExtension(`comments`)?(0,z.jsx)(Bu,{}):null,Hu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>e.prosemirrorState.selection.empty}),i=(0,R.useCallback)(()=>{n._tiptapEditor.chain().focus().addPendingComment().run()},[n]);return!n._tiptapEditor.commands.addPendingComment||!n.isEditable||r?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:(0,z.jsx)(dn,{}),onClick:i})};function Uu(e,t){try{let n=new URL(e,t);if(n.protocol!==`javascript:`)return n.href}catch{}return`#`}var Wu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&(n.focus(),n.resolveFileUrl?n.resolveFileUrl(r.props.url).then(e=>window.open(Uu(e,window.location.href))):window.open(Uu(r.props.url,window.location.href)))},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,icon:(0,z.jsx)(St,{}),onClick:i})},Gu=()=>{let e=H(),t=V(),n=B(),r=He({editor:n,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(b(n,e,n.type,{url:`string`,showPreview:`boolean`}))return n}}),i=(0,R.useCallback)(()=>{r!==void 0&&j(n,r.type,{showPreview:`boolean`})&&n.updateBlock(r.id,{props:{showPreview:!r.props.showPreview}})},[r,n]);return r===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:`Toggle preview`,mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:(0,z.jsx)(At,{}),isSelected:r.props.showPreview,onClick:i})},Ku=()=>{let e=H(),t=V(),n=B(),r=W(F),i=He({editor:n,selector:({editor:e})=>{if(!e.isEditable||!e.settings.tables.splitCells)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block];if(t.length!==1)return;let n=t[0];if(n.type===`table`)return{mergeDirection:r.getMergeDirection(n)}}}),a=(0,R.useCallback)(()=>{r?.mergeCells()},[r]);return i===void 0?null:(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:e.formatting_toolbar.table_cell_merge.tooltip,icon:i.mergeDirection===`horizontal`?(0,z.jsx)(zt,{}):(0,z.jsx)(Rt,{}),onClick:a})},qu=()=>B().getExtension(F)?(0,z.jsx)(Ku,{}):null,Ju={left:on,center:cn,right:an,justify:sn},Yu=e=>{let t=V(),n=H(),r=B(),i=He({editor:r,selector:({editor:e})=>{if(!e.isEditable)return;let t=e.getSelection()?.blocks||[e.getTextCursorPosition().block],n=t[0];if(b(n,e,n.type,{textAlignment:y.textAlignment}))return{textAlignment:n.props.textAlignment,blocks:t};if(t.length===1&&b(n,e,`table`))return e.getExtension(F)?.getCellSelection()?{textAlignment:le(n.content.rows[0].cells[0]).props.textAlignment,blocks:[n]}:void 0}}),a=(0,R.useCallback)(e=>{if(i!==void 0){r.focus();for(let t of i.blocks)if(b(t,r,t.type,{textAlignment:y.textAlignment})&&j(r,t.type,{textAlignment:y.textAlignment}))r.updateBlock(t,{props:{textAlignment:e}});else if(t.type===`table`){let n=r.getExtension(F)?.getCellSelection();if(!n)continue;let i=t.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));n.cells.forEach(({row:t,col:n})=>{i[t].cells[n].props.textAlignment=e}),r.updateBlock(t,{type:`table`,content:{...t.content,type:`tableContent`,rows:i}}),r.setTextCursorPosition(t)}}},[r,i]);if(i===void 0)return null;let o=Ju[e.textAlignment];return(0,z.jsx)(t.FormattingToolbar.Button,{className:`bn-button`,"data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>a(e.textAlignment),isSelected:i.textAlignment===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:(0,z.jsx)(o,{})})},Xu=e=>[(0,z.jsx)(zu,{items:e},`blockTypeSelect`),(0,z.jsx)(qu,{},`tableCellMergeButton`),(0,z.jsx)(ju,{},`fileCaptionButton`),(0,z.jsx)(Pu,{},`replaceFileButton`),(0,z.jsx)(Nu,{},`fileRenameButton`),(0,z.jsx)(Mu,{},`fileDeleteButton`),(0,z.jsx)(Wu,{},`fileDownloadButton`),(0,z.jsx)(Gu,{},`filePreviewButton`),(0,z.jsx)(vu,{basicTextStyle:`bold`},`boldStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`italic`},`italicStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`underline`},`underlineStyleButton`),(0,z.jsx)(vu,{basicTextStyle:`strike`},`strikeStyleButton`),(0,z.jsx)(Yu,{textAlignment:`left`},`textAlignLeftButton`),(0,z.jsx)(Yu,{textAlignment:`center`},`textAlignCenterButton`),(0,z.jsx)(Yu,{textAlignment:`right`},`textAlignRightButton`),(0,z.jsx)(Tu,{},`colorStyleButton`),(0,z.jsx)(Fu,{},`nestBlockButton`),(0,z.jsx)(Iu,{},`unnestBlockButton`),(0,z.jsx)(Au,{},`createLinkButton`),(0,z.jsx)(Vu,{},`addCommentButton`),(0,z.jsx)(Hu,{},`addTiptapCommentButton`)],Zu=e=>{let t=V();return(0,z.jsx)(t.FormattingToolbar.Root,{className:`bn-toolbar bn-formatting-toolbar`,children:e.children||Xu(e.blockTypeSelectItems)})},Qu=e=>{switch(e){case`left`:return`top-start`;case`center`:return`top`;case`right`:return`top-end`;default:return`top-start`}},$u=e=>{let t=B(),n=W(A,{editor:t}),r=G(A,{editor:t}),i=He({editor:t,selector:({editor:e})=>n.store.state?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),a=He({editor:t,selector:({editor:e})=>{let t=e.getTextCursorPosition().block;return b(t,e,t.type,{textAlignment:y.textAlignment})?Qu(t.props.textAlignment):`top-start`}}),o=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,r,i)=>{n.store.setState(e),i===`escape-key`&&t.focus()},placement:a,middleware:[za(10),Ba(),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:40},...e.floatingUIOptions?.elementProps}}),[r,a,e.floatingUIOptions,n.store,t]),s=e.formattingToolbar||Zu;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(As,{position:i,...o,children:r&&(0,z.jsx)(s,{})})})};function ed(e,t){let n=Ie(),r=t??n?.editor;if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);let i=e?.includeEditorUI??!1,a=(0,R.useRef)(void 0);(a.current===void 0||a.current.editor!==r||a.current.includeEditorUI!==i)&&(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})});let o=(0,R.useCallback)(e=>(a.current={editor:r,includeEditorUI:i,value:r.isFocused({includeEditorUI:i})},e(),r.onFocusChange((t,n)=>{a.current={editor:r,includeEditorUI:i,value:n.focused},e()},{includeEditorUI:i})),[r,i]),s=(0,R.useCallback)(()=>a.current.value,[]);return(0,R.useSyncExternalStore)(o,s,s)}var td=0,nd=0;function rd(){if(typeof window>`u`)return!1;let e=window.visualViewport,t=e?.scale??1,n=(e?.height??window.innerHeight)*t,r=document.documentElement.clientWidth;return Math.abs(r-nd)>nd*.2&&(nd=r,td=0),td=Math.max(td,n),td-n>150}var id=[`--bn-vv-top`,`--bn-vv-left`,`--bn-vv-width`,`--bn-vv-height`,`--bn-vv-scale`],ad=0;function od(){let[e,t]=(0,R.useState)(rd);return(0,R.useLayoutEffect)(()=>{let e=document.documentElement,n=window.visualViewport,r=()=>document.querySelectorAll(`.bn-scroll-container`),i=()=>{e.style.setProperty(`--bn-vv-top`,`${n?.offsetTop??0}px`),e.style.setProperty(`--bn-vv-left`,`${n?.offsetLeft??0}px`),e.style.setProperty(`--bn-vv-width`,`${n?.width??window.innerWidth}px`),e.style.setProperty(`--bn-vv-height`,`${n?.height??window.innerHeight}px`),e.style.setProperty(`--bn-vv-scale`,`${n?.scale??1}`)},a=(e,t)=>e.toggleAttribute(`data-bn-allow-pull-to-refresh`,!t&&e.scrollTop<=0),o=()=>{let e=rd();t(e),i();for(let t of r())a(t,e)};ad++,o(),n?.addEventListener(`resize`,o),n?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o);let s=e=>{e.target instanceof HTMLElement&&e.target.classList.contains(`bn-scroll-container`)&&a(e.target,rd())};return document.addEventListener(`scroll`,s,{capture:!0,passive:!0}),()=>{if(n?.removeEventListener(`resize`,o),n?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),document.removeEventListener(`scroll`,s,{capture:!0}),ad--,ad===0){for(let t of id)e.style.removeProperty(t);for(let e of r())e.removeAttribute(`data-bn-allow-pull-to-refresh`);td=0,nd=0}}},[]),e}var sd=e=>{let t=od(),n=ed({includeEditorUI:!0});if(!t||!n)return null;let r=e.formattingToolbar||Zu;return(0,z.jsx)(Ze,{target:document.body,children:(0,z.jsx)(yu.Provider,{value:`mobile`,children:(0,z.jsx)(nt,{children:(0,z.jsx)(`div`,{className:`bn-mobile-formatting-toolbar`,children:(0,z.jsx)(r,{})})})})})},cd=e=>{let t=od();return _()&&t?(0,z.jsx)(sd,{formattingToolbar:e.formattingToolbar}):(0,z.jsx)($u,{...e})},ld=e=>{let t=V(),n=H(),{deleteLink:r}=W(be);return(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{r(e.range.from),e.setToolbarOpen?.(!1)},icon:(0,z.jsx)(Wt,{})})},ud=e=>{let t=V(),n=Je(),r=H();return(0,z.jsxs)(t.Generic.Popover.Root,{onOpenChange:e.setToolbarPositionFrozen,portalElement:n,children:[(0,z.jsx)(t.Generic.Popover.Trigger,{children:(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:r.link_toolbar.edit.tooltip,isSelected:!1,children:r.link_toolbar.edit.text})}),(0,z.jsx)(t.Generic.Popover.Content,{className:`bn-popover-content bn-form-popover`,variant:`form-popover`,children:(0,z.jsx)(Ou,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen})})]})},dd=e=>{let t=V(),n=H();return(0,z.jsx)(t.LinkToolbar.Button,{className:`bn-button`,mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(Uu(e.url,window.location.href),`_blank`)},icon:(0,z.jsx)(xt,{})})},fd=e=>{let t=V();return(0,z.jsx)(t.LinkToolbar.Root,{className:`bn-toolbar bn-link-toolbar`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ud,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen}),(0,z.jsx)(dd,{url:e.url}),(0,z.jsx)(ld,{range:e.range,setToolbarOpen:e.setToolbarOpen})]})})},pd=e=>{let t=B(),n=He({editor:t,selector:({editor:e})=>e?.isEditable??!1}),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!1),s=Ue(),c=W(be),[l,u]=(0,R.useState)(void 0);(0,R.useEffect)(()=>{if(!n){u(void 0),i(!1);return}let e=()=>{let e=c.getLinkAtSelection();e?(u({cursorType:`text`,url:e.mark.attrs.href,text:e.text,range:e.range,element:c.getLinkElementAtPos(e.range.from)}),a||i(!0)):(u(void 0),a||i(!1))},r=e=>{if(l!==void 0&&l.cursorType===`text`||!(e.target instanceof HTMLElement))return;let t=c.getLinkAtElement(e.target);t&&u({cursorType:`mouse`,url:t.mark.attrs.href,text:t.text,range:t.range,element:c.getLinkElementAtPos(t.range.from)})},o=t.onChange(e),d=t.onSelectionChange(e);return s?.addEventListener(`mouseover`,r),()=>{o(),d(),s?.removeEventListener(`mouseover`,r)}},[t,s,n,c,l,a]);let d=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(e,n,r)=>{a||(l===void 0||l.cursorType!==`text`||r!==`hover`)&&(r===`escape-key`&&t.focus(),i(e))},placement:`top-start`,middleware:[za(10),Ha()],...e.floatingUIOptions?.useFloatingOptions},useHoverProps:{enabled:l!==void 0&&l.cursorType===`mouse`,delay:{open:250,close:250},handleClose:Es(),...e.floatingUIOptions?.useHoverProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:50},...e.floatingUIOptions?.elementProps}}),[t,l,e.floatingUIOptions,r,a]),f=(0,R.useMemo)(()=>l?.element?{element:l.element}:void 0,[l?.element]);if(!n)return null;let p=e.linkToolbar||fd;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(ks,{reference:f,...d,children:l&&(0,z.jsx)(p,{url:l.url,text:l.text,range:l.range,setToolbarOpen:i,setToolbarPositionFrozen:o})})})};function md(e){return U({tag:`svg`,attr:{viewBox:`0 0 1024 1024`},child:[{tag:`path`,attr:{d:`M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z`},child:[]},{tag:`path`,attr:{d:`M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z`},child:[]}]})(e)}var hd=()=>{let e=V(),t=H(),n=B(),r=W(N),i=G(I,{editor:n,selector:e=>e?.block}),a=(0,R.useCallback)(()=>{if(i===void 0)return;let e=i.content;if(e!==void 0&&Array.isArray(e)&&e.length===0)n.setTextCursorPosition(i),r.openSuggestionMenu(`/`);else{let e=n.insertBlocks([{type:`paragraph`}],i,`after`)[0];n.setTextCursorPosition(e),r.openSuggestionMenu(`/`)}},[i,n,r]);return i===void 0?null:(0,z.jsx)(e.SideMenu.Button,{className:`bn-button`,label:t.side_menu.add_block_label,icon:(0,z.jsx)(md,{size:24,onClick:a,"data-test":`dragHandleAdd`})})};function gd(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`m7 10 5 5 5-5z`},child:[]}]})(e)}function _d(e){return U({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z`},child:[]}]})(e)}var vd=e=>{let t=V(),n=Je(),r=B(),i=G(I,{editor:r,selector:e=>e?.block});return i===void 0||!b(i,r,i.type,{textColor:`string`})&&!b(i,r,i.type,{backgroundColor:`string`})?null:(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:b(i,r,i.type,{textColor:`string`})&&j(r,i.type,{textColor:`string`})?{color:i.props.textColor,setColor:e=>r.updateBlock(i,{type:i.type,props:{textColor:e}})}:void 0,background:b(i,r,i.type,{backgroundColor:`string`})&&j(r,i.type,{backgroundColor:`string`})?{color:i.props.backgroundColor,setColor:e=>r.updateBlock(i,{props:{backgroundColor:e}})}:void 0})})]})},yd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});return r===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,onClick:()=>{let e=n.getSelection()?.blocks,t=e&&e.some(e=>e.id===r.id)?e:[r];n.removeBlocks(t)},children:e.children})},bd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerRows;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerRows:i?void 0:1}})},children:e.children})},xd=e=>{let t=V(),n=B(),r=G(I,{editor:n,selector:e=>e?.block});if(r===void 0||r.type!==`table`||!n.settings.tables.headers)return null;let i=!!r.content.headerCols;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:i,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerCols:i?void 0:1}})},children:e.children})},Sd=e=>{let t=V(),n=H();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-drag-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(yd,{children:n.drag_handle.delete_menuitem}),(0,z.jsx)(vd,{children:n.drag_handle.colors_menuitem}),(0,z.jsx)(bd,{children:n.drag_handle.header_row_menuitem}),(0,z.jsx)(xd,{children:n.drag_handle.header_column_menuitem})]})})},Cd=e=>{let t=V(),n=Je(),r=H(),i=W(I),a=G(I,{selector:e=>e?.block});if(a===void 0)return null;let o=e.dragHandleMenu||Sd;return(0,z.jsxs)(t.Generic.Menu.Root,{onOpenChange:e=>{e?i.freezeMenu():i.unfreezeMenu()},position:`left`,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{children:(0,z.jsx)(t.SideMenu.Button,{label:r.side_menu.drag_handle_label,draggable:!0,onDragStart:e=>i.blockDragStart(e,a),onDragEnd:i.blockDragEnd,className:`bn-button`,icon:(0,z.jsx)(_d,{size:24,"data-test":`dragHandle`})})}),(0,z.jsx)(o,{children:e.children})]})},wd=e=>{let t=V();return(0,z.jsx)(t.SideMenu.Root,{className:`bn-side-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(hd,{}),(0,z.jsx)(Cd,{dragHandleMenu:e.dragHandleMenu})]})})};function Td(e,t){if(t.type===`heading`)switch(t.props.level){case 1:return 39;case 2:return 27;case 3:return 18.5;default:return 0}return e.schema.blockSpecs[t.type]?.implementation.meta?.fileBlockAccept&&!t.props.url?12:t.type===`file`?4:t.type===`audio`||t.type===`table`?15:0}var Ed=e=>{let t=B(),{show:n,block:r}=G(I,{selector:e=>e===void 0?void 0:{show:e.show,block:e.block}})||{},i=(0,R.useCallback)((e,n,r)=>{let i=t.getExtension(I);i?.setMenuElement(n);let a=!1,o=xa(e,n,()=>{a?i?.hideMenuIfNotFrozen():a=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1});return()=>{o(),i?.setMenuElement(void 0)}},[t]),a=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,placement:`left-start`,middleware:[za({crossAxis:r?Td(t,r):0})],whileElementsMounted:i,...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:!1,...e.floatingUIOptions?.useDismissProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:20},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,n,r,t,i]),o=e.sideMenu||wd;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(du,{blockId:n?r?.id:void 0,...a,children:r?.id&&(0,z.jsx)(o,{})})})},Dd=({format:e,dictionary:t})=>{let n=t.suggestion_changes.formatting_change;if(e.length===0)return n;let r=t.formatting_toolbar,i=[];for(let t of e){if(t===`link`)return n;let e=r[t],a=e&&typeof e==`object`&&`tooltip`in e?e.tooltip:void 0;if(typeof a!=`string`)return n;i.push(a)}return i.join(`, `)},Od=e=>{let t=V(),n=H(),r=(0,R.useMemo)(()=>{let t=n.suggestion_changes,r=e.formatChangeLabel??Dd,i=e.users.join(`, `);if(e.modificationType===`insert`)return i?t.inserted_by(i):t.inserted;if(e.modificationType===`delete`)return i?t.deleted_by(i):t.deleted;if(e.modificationType===`change`)return i?t.changed_by(i):t.changed;if(e.modificationType===`attrs`)return i?`${t.formatting_change}: ${i}`:t.formatting_change;let a=e.format?r({format:e.format,dictionary:n}):``;return!a||a===t.formatting_change?i?`${t.formatting_change}: ${i}`:t.formatting_change:i?t.formatting_change_by(a,i):`${t.formatting_change} (${a})`},[n,e]);return(0,z.jsx)(t.AttributionTooltip.Root,{className:`bn-suggestion-tooltip`,markClassName:e.className,backgroundColor:e.className?void 0:e.color,children:r})};function kd(e){let t=e.firstElementChild??e,n=t.getBoundingClientRect();return n.width||n.height?t:t.firstElementChild??t}function Ad(e,t){let{anchor:n,reference:r,...i}=e;return{...i,formatChangeLabel:t}}var jd=e=>{let t=G(`attribution`,{selector:e=>e}),n=(0,R.useMemo)(()=>t?{element:t.reference??kd(t.anchor)}:void 0,[t]),r=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!t,placement:`top-start`,middleware:[Ka(),za(4),Ha(),Ba({padding:4})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:1e4,pointerEvents:`none`},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,t]),i=e.attributionTooltip||Od,a=t?Ad(t,e.formatChangeLabel):void 0;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(ks,{reference:n,...r,children:a&&(0,z.jsx)(i,{...a})})})},Md=10,Nd=10,Pd=600,Fd=300,Id={name:`placeBelowUnlessCramped`,async fn(e){let{rects:t,placement:n,platform:r}=e,i={...t.floating,height:Fd},a=await r.detectOverflow({...e,rects:{...t,floating:i},y:t.reference.y+t.reference.height+Md},{padding:Nd}),o=`bottom-start`;return a.bottom>0&&(await r.detectOverflow({...e,rects:{...t,floating:i},y:t.reference.y-Md-Fd},{padding:Nd})).top=(parseFloat(e.style.minWidth)||0)+1&&(e.style.minWidth=`${Math.ceil(t)}px`)}var Rd=[Id,za(Md),Ba(),Ua({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,Math.min(t,Pd))}px`,Ld(e.floating)},padding:Nd})];function zd(e){let{triggerCharacter:t,shouldOpen:n,minQueryLength:r,enabled:i=!0,middleware:a=Rd,zIndex:o=80}=e,s=Ue(),c=W(N);(0,R.useEffect)(()=>{i&&c.addSuggestionMenu({triggerCharacter:t,shouldOpen:n})},[i,c,t,n]);let l=G(N),u=G(N,{selector:e=>({element:s?.firstElementChild??void 0,getBoundingClientRect:()=>e?.referencePos||new DOMRect}),equalityFn:(e,t)=>{let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return e.element===t.element&&n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height}}),d=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:l?.show&&l.triggerCharacter===t,onOpenChange:e=>{e||c.closeMenu()},placement:`bottom-start`,middleware:a,...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:e=>e.preventDefault(),style:{zIndex:o},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,l?.show,l?.triggerCharacter,c,t,a,o]);return!i||!l||!l.ignoreQueryLength&&r&&(l.query.startsWith(` `)||l.query.length=4))return!1;e.fillStyle=`#00f`,e.fillText(t,0,0);let n=e.getImageData(0,0,Bd,Bd).data;e.clearRect(0,0,Bd,Bd),e.fillStyle=`#f00`,e.fillText(t,0,0);let r=e.getImageData(0,0,Bd,Bd).data;for(let e=0;e<16;e+=4)if(n[e]!==r[e]||n[e+1]!==r[e+1]||n[e+2]!==r[e+2])return!1;return!0}function Ud(e){let t=null;try{t=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0})}catch{}let n=new Map;for(let t of e.emojis)n.has(t.version)||n.set(t.version,t.emoji);let r=[...n.keys()].sort((e,t)=>t-e),i=r[0]??0,a=Hd(t,`🇪🇺`);for(let e of r)if(Hd(t,n.get(e)))return{emojiVersion:e,countryFlags:a};return{emojiVersion:i,countryFlags:a}}function Wd(e,t,n){return{...e,emojis:e.emojis.filter(e=>e.version<=(n??t.emojiVersion)&&(!e.countryFlag||t.countryFlags))}}async function Gd(e,{emojiVersion:t,signal:n}={}){let{loadFrimousseData:r}=await h(async()=>{let{loadFrimousseData:e}=await import(`./emoji-data--iPt3NLx.js`);return{loadFrimousseData:e}},__vite__mapDeps([0,1,2,3]));n?.throwIfAborted();let i=await r(e);return n?.throwIfAborted(),Wd(i,Ud(i),t)}function Kd(e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function qd(e){return(0,R.useMemo)(()=>Kd(e),e)}function Jd({emoji:e,label:t,placeholder:n}){return(0,z.jsxs)(`div`,{className:`bn-frimousse-active-emoji`,children:[e&&(0,z.jsx)(`span`,{className:`bn-frimousse-active-emoji-glyph`,children:e}),(0,z.jsx)(`span`,{className:`bn-frimousse-active-emoji-label`,children:e?t:n})]})}function Yd({onEmojiSelect:e,onEscape:t,locale:n,dictionary:r}){let i=`${r.search}…`;return(0,z.jsxs)(Gs.Root,{className:`bn-frimousse-picker`,locale:n,resolveEmojiData:Gd,onEmojiSelect:({emoji:t})=>e(t),onKeyDownCapture:e=>{e.key===`Escape`&&t&&(e.stopPropagation(),t())},children:[(0,z.jsx)(Gs.Search,{placeholder:r.search,autoFocus:!0}),(0,z.jsxs)(Gs.Viewport,{children:[(0,z.jsx)(Gs.Loading,{className:`bn-frimousse-loading`,children:r.loading}),(0,z.jsx)(Gs.Empty,{className:`bn-frimousse-empty`,children:r.search_no_results}),(0,z.jsx)(Gs.List,{})]}),(0,z.jsxs)(`div`,{className:`bn-frimousse-footer`,children:[(0,z.jsx)(Gs.ActiveEmoji,{children:({emoji:e})=>(0,z.jsx)(Jd,{emoji:e?.emoji,label:e?.label,placeholder:i})}),(0,z.jsx)(Gs.SkinToneSelector,{className:`bn-frimousse-skin-tone`})]})]})}function Xd(e){return e===void 0?void 0:`bn-suggestion-menu-item-`+e}function Zd(e,t,n,r=3){let i=(0,R.useRef)(0);(0,R.useEffect)(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>r&&n())},[n,r,e.length,t])}function Qd(e){let t=new Map;for(let n of e.emojis){let e=t.get(n.category);e?e.push(n):t.set(n.category,[n])}let n=[],r=0;for(let i of e.categories){let e=t.get(i.index);if(e){for(let t=0;t({emoji:e,score:(e.label.toLowerCase().includes(n)?10:0)+e.tags.filter(e=>e.toLowerCase().includes(n)).length})).filter(({score:e})=>e>0).sort((e,t)=>t.score-e.score);return{...e,emojis:r.map(({emoji:e})=>e)}}function ef(e,t,n){let r=n[e.row];if(!r)return e;switch(t){case`ArrowLeft`:{if(e.column>0)return{...e,column:e.column-1};let t=n[e.row-1];return t?{row:e.row-1,column:t.emojis.length-1}:e}case`ArrowRight`:return e.column{let t=o.current;if(t?.closest(`[aria-rowindex]`))return a?.(e.emoji,t)},[e.emoji,c,a]),(0,z.jsx)(`button`,{type:`button`,className:`bn-frimousse-emoji`,...n,ref:s,"data-selected":i?``:void 0,"data-active":void 0,"aria-selected":i||void 0,children:e.emoji})}var of={Emoji:af};function sf(e,t,n){let r=e.get(n);return r?.closest(`[aria-rowindex]`)?.getAttribute(`aria-rowindex`)===String(t.row)&&r.getAttribute(`aria-colindex`)===String(t.column)&&r.textContent===n?r:null}function cf(e,t,n){let r=e.querySelector(`[frimousse-viewport]`);if(!r)return;let i=getComputedStyle(e),a=Number.parseFloat(i.getPropertyValue(`--frimousse-row-height`))||32,o=Number.parseFloat(i.getPropertyValue(`--frimousse-category-header-height`))||30,s=t.row*a+(n+1)*o,c=r.clientHeight;(sr.scrollTop+c-o)&&r.scrollTo({top:Math.max(0,s-c/3),behavior:`instant`})}function lf(e){let{query:t,insertEmoji:n,rootRef:r,data:i}=e,a=Ue(),o=Ie().setContentEditableProps,s=H(),[c]=hl(),l=(0,R.useRef)(new Map),u=(0,R.useRef)(void 0),d=(0,R.useCallback)((e,t)=>(l.current.set(e,t),u.current?.(),()=>{l.current.get(e)===t&&(l.current.delete(e),u.current?.())}),[]),f=(0,R.useMemo)(()=>i?Qd(i):[],[i]),[p,m]=(0,R.useState)({query:t,position:rf});p.query!==t&&m({query:t,position:rf});let h=p.query===t?p.position:rf,g=f[h.row],_=g?.emojis[h.column],v=_&&(c===`none`?_.emoji:_.skins?.[c]??_.emoji),y=f.slice(0,h.row).reduce((e,t)=>e+t.emojis.length,0)+h.column;(0,R.useEffect)(()=>(o(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{o(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[o]),(0,R.useEffect)(()=>{function e(e){o(t=>t?.[`aria-activedescendant`]===e?t:{...t,"aria-activedescendant":e})}let t=r.current;if(!t||!v||!g){e(void 0);return}let n=!0,i=v,a=y,s=null;function c(){let t=sf(l.current,h,i);s!==t&&(s?.removeAttribute(`id`),s=t),t?(n&&(n=!1,t.scrollIntoView({block:`nearest`,behavior:`instant`})),t.id=Xd(a),e(t.id)):e(void 0)}return u.current=c,sf(l.current,h,v)||cf(t,h,g.categoryIndex),c(),()=>{u.current=void 0,s?.removeAttribute(`id`),e(void 0)}},[r,v,y,h,g,o]),(0,R.useEffect)(()=>{let e=e=>{if(e.isComposing)return;let r=e.key;if(r===`ArrowRight`||r===`ArrowLeft`||r===`ArrowDown`||r===`ArrowUp`){let n=ef(h,r,f);if(n===h)return;e.preventDefault(),m({query:t,position:n})}else e.key===`Enter`&&v&&(e.preventDefault(),e.stopPropagation(),sf(l.current,h,v)&&n(v))};return a?.addEventListener(`keydown`,e,!0),()=>{a?.removeEventListener(`keydown`,e,!0)}},[f,a,n,t,v,h]);let b=`${s.emoji_picker.search}…`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Gs.Search,{hidden:!0,value:t,readOnly:!0,tabIndex:-1}),(0,z.jsxs)(Gs.Viewport,{children:[!i&&(0,z.jsx)(Gs.Loading,{className:`bn-frimousse-loading`,children:s.emoji_picker.loading}),(0,z.jsx)(Gs.Empty,{className:`bn-frimousse-empty`,children:s.emoji_picker.search_no_results}),(0,z.jsx)(tf.Provider,{value:v,children:(0,z.jsx)(nf.Provider,{value:d,children:(0,z.jsx)(Gs.List,{components:of})})})]}),(0,z.jsxs)(`div`,{className:`bn-frimousse-footer`,children:[(0,z.jsx)(Jd,{emoji:v,label:_?.label,placeholder:b}),(0,z.jsx)(Gs.SkinToneSelector,{className:`bn-frimousse-skin-tone`})]})]})}function uf(e){let t=B(),n=H().locale??`en`,[r,i]=(0,R.useState)(),a=(0,R.useRef)(null),o=(0,R.useMemo)(()=>r?.locale===n?$d(r.data,e.query):void 0,[r,n,e.query]);Zd(o?.emojis??[],o?e.query:void 0,e.closeMenu);let[s]=(0,R.useState)(()=>async(e,t)=>{let n=await Gd(e,t);return t.signal?.aborted||i({locale:e,data:n}),n});function c(n){e.clearQuery(),e.closeMenu(),t.insertInlineContent(n+` `)}return(0,z.jsx)(Gs.Root,{ref:a,id:`bn-suggestion-menu`,className:`bn-frimousse-picker`,locale:n,columns:9,resolveEmojiData:s,onEmojiSelect:({emoji:e})=>c(e),children:(0,z.jsx)(lf,{query:e.query,insertEmoji:c,rootRef:a,data:o})},n)}var df=[za(10),Wa({allowedPlacements:[`bottom-start`,`top-start`],padding:10}),Ba(),Ua({apply({elements:e,availableHeight:t}){e.floating.style.maxHeight=`${Math.max(0,t)}px`},padding:10})];function ff(e){let t=B(),n=`text`in t.schema.inlineContentSchema&&t.schema.inlineContentSchema.text===ge.text;return(0,z.jsx)(zd,{...e,minQueryLength:e.minQueryLength??2,enabled:n,middleware:df,zIndex:70,children:e=>(0,z.jsx)(uf,{...e})})}function pf(e){let t=V(),n=H(),{items:r,loadingState:i,selectedIndex:a,onItemClick:o}=e,s=i===`loading-initial`||i===`loading`?(0,z.jsx)(t.SuggestionMenu.Loader,{className:`bn-suggestion-menu-loader`}):null,c=(0,R.useMemo)(()=>{let e,n=[];for(let i=0;io?.(s)},s.title))}return n},[t,r,o,a]);return(0,z.jsxs)(t.SuggestionMenu.Root,{id:`bn-suggestion-menu`,className:`bn-suggestion-menu`,children:[c,c.length===0&&(e.loadingState===`loading`||e.loadingState===`loaded`)&&(0,z.jsx)(t.SuggestionMenu.EmptyItem,{className:`bn-suggestion-menu-item`,children:n.suggestion_menu.no_items_title}),s]})}function mf(e,t){let[n,r]=(0,R.useState)([]),[i,a]=(0,R.useState)(!1),o=(0,R.useRef)(void 0),s=(0,R.useRef)(void 0);return(0,R.useEffect)(()=>{let n=e;o.current=e,a(!0),t(e).then(e=>{o.current===n&&(r(e),a(!1),s.current=n)})},[e,t]),{items:n||[],usedQuery:s.current,loadingState:s.current===void 0?`loading-initial`:i?`loading`:`loaded`}}function hf(e,t){let[n,r]=(0,R.useState)(0);return{selectedIndex:n,setSelectedIndex:r,handler:i=>{if(i.key===`ArrowUp`)return i.preventDefault(),e.length&&r((n-1+e.length)%e.length),!0;if(i.key===`ArrowDown`)return i.preventDefault(),e.length&&r((n+1)%e.length),!0;if(i.key===`PageUp`)return i.preventDefault(),e.length&&r(0),!0;if(i.key===`PageDown`)return i.preventDefault(),e.length&&r(e.length-1),!0;let a=gf(i)?i.nativeEvent.isComposing:i.isComposing;return i.key===`Enter`&&!a&&(i.preventDefault(),i.stopPropagation(),e.length&&t?.(e[n]),!0)}}}function gf(e){return e.nativeEvent!==void 0}function _f(e,t,n,r,i){let a=Ue(),{selectedIndex:o,setSelectedIndex:s,handler:c}=hf(n,r);return(0,R.useEffect)(()=>{let e=i||a;return e?.addEventListener(`keydown`,c,!0),()=>{e?.removeEventListener(`keydown`,c,!0)}},[a,n,o,r,i,c]),(0,R.useEffect)(()=>{s(0)},[t,s]),{selectedIndex:n.length===0?void 0:o}}function vf(e){let t=Ie().setContentEditableProps,n=B(),{getItems:r,suggestionMenuComponent:i,query:a,clearQuery:o,closeMenu:s,onItemClick:c}=e,l=(0,R.useCallback)(e=>{s(),o(),c?.(e)},[c,s,o]),{items:u,usedQuery:d,loadingState:f}=mf(a,r);Zd(u,d,s);let{selectedIndex:p}=_f(n,a,u,l);return(0,R.useEffect)(()=>(t(e=>({...e,"aria-expanded":!0,"aria-controls":`bn-suggestion-menu`})),()=>{t(e=>({...e,"aria-expanded":!1,"aria-controls":void 0}))}),[t]),(0,R.useEffect)(()=>(t(e=>({...e,"aria-activedescendant":Xd(p)})),()=>{t(e=>({...e,"aria-activedescendant":void 0}))}),[t,p]),(0,z.jsx)(i,{items:u,onItemClick:l,loadingState:f,selectedIndex:p})}var yf={heading:en,heading_2:$t,heading_3:Qt,heading_4:Zt,heading_5:Xt,heading_6:Yt,toggle_heading:en,toggle_heading_2:$t,toggle_heading_3:Qt,quote:Lt,toggle_list:Ot,numbered_list:Vt,bullet_list:Bt,check_list:Ht,paragraph:Pt,table:Ft,image:jt,video:Mt,audio:Dt,file:un,emoji:vt,code_block:nn,divider:yt};function bf(e){return M(e).map(e=>{let t=yf[e.key];return{...e,icon:(0,z.jsx)(t,{size:18})}})}function xf(e){let t=B(),{triggerCharacter:n,suggestionMenuComponent:r,onItemClick:i,getItems:a}=e,o=(0,R.useMemo)(()=>i||(e=>{e.onItemClick(t)}),[t,i]),s=(0,R.useMemo)(()=>a||(async e=>P(bf(t),e)),[t,a]);return(0,z.jsx)(zd,{...e,children:e=>n&&(0,z.jsx)(vf,{...e,getItems:s,suggestionMenuComponent:r||pf,onItemClick:o})})}var Sf=(e,t=.3)=>{let n=Math.floor(e)+t,r=Math.ceil(e)-t;return e>=n&&e<=r?Math.round(e):e{let t=V(),n=B(),r=W(F),i=G(F,{selector:e=>e?.block}),a=(0,R.useRef)(!1),[o,s]=(0,R.useState)(),c=(0,R.useCallback)(t=>{r.freezeHandles(),e.hideOtherElements(!0),i&&(s({originalContent:i.content,originalCroppedContent:{rows:r.cropEmptyRowsOrColumns(i,e.orientation===`addOrRemoveColumns`?`columns`:`rows`)},startPos:e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY}),a.current=!1,t.preventDefault())},[i,e,r]),l=(0,R.useCallback)(()=>{i&&!a.current&&n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns(i,`columns`,1):r.addRowsOrColumns(i,`rows`,1)}})},[i,n,e.orientation,r]);return(0,R.useEffect)(()=>{let t=t=>{if(!i)return;if(!o)throw Error(`editingState is undefined`);a.current=!0;let s=(e.orientation===`addOrRemoveColumns`?t.clientX:t.clientY)-o.startPos,c=e.orientation===`addOrRemoveColumns`?o.originalCroppedContent.rows[0]?.cells.length??0:o.originalCroppedContent.rows.length,l=e.orientation===`addOrRemoveColumns`?o.originalContent.rows[0]?.cells.length??0:o.originalContent.rows.length,u=e.orientation===`addOrRemoveColumns`?i.content.rows[0].cells.length:i.content.rows.length,d=l+Sf(s/(e.orientation===`addOrRemoveColumns`?120:31),.3);d>=c&&d>0&&d!==u&&(n.updateBlock(i,{type:`table`,content:{...i.content,rows:e.orientation===`addOrRemoveColumns`?r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`columns`,d-c):r.addRowsOrColumns({type:`table`,content:o.originalCroppedContent},`rows`,d-c)}}),i.content&&n.setTextCursorPosition(i))};return o&&window.addEventListener(`mousemove`,t),()=>{window.removeEventListener(`mousemove`,t)}},[i,o,n,e.orientation,r]),(0,R.useEffect)(()=>{let t=()=>{e.hideOtherElements(!1),r.unfreezeHandles(),s(void 0)};return o&&window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mouseup`,t)}},[o,e,r]),n.isEditable?(0,z.jsx)(t.TableHandle.ExtendButton,{className:w(`bn-extend-button`,e.orientation===`addOrRemoveColumns`?`bn-extend-button-add-remove-columns`:`bn-extend-button-add-remove-rows`,o===null?``:`bn-extend-button-editing`),onClick:l,onMouseDown:c,children:e.children||(0,z.jsx)(Et,{size:18,"data-test":`extendButton`})}):null},wf=e=>{let t=V(),n=Je(),r=H(),i=B(),{block:a,colIndex:o,rowIndex:s}=G(F,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})}),c=(e,t)=>{if(a===void 0||o===void 0||s===void 0)return;let n=a.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));t===`text`?n[s].cells[o].props.textColor=e:n[s].cells[o].props.backgroundColor=e,i.updateBlock(a,{type:`table`,content:{...a.content,rows:n}}),i.setTextCursorPosition(a)};if(a===void 0||o===void 0||s===void 0)return null;let l=a.content.rows[s]?.cells?.[o];return!l||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1?null:(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:i.settings.tables.cellTextColor?{color:S(l)?l.props.textColor:`default`,setColor:e=>c(e,`text`)}:void 0,background:i.settings.tables.cellBackgroundColor?{color:S(l)?l.props.backgroundColor:`default`,setColor:e=>c(e,`background`)}:void 0})})]})},Tf=()=>{let e=V(),t=H(),n=B(),r=W(F),{block:i,colIndex:a,rowIndex:o}=G(F,{selector:e=>({block:e?.block,colIndex:e?.colIndex,rowIndex:e?.rowIndex})});if(i===void 0||a===void 0||o===void 0)return null;let s=i.content.rows[o]?.cells?.[a];return!s||!S(s)||ve(s)===1&&ue(s)===1||!n.settings.tables.splitCells?null:(0,z.jsx)(e.Generic.Menu.Item,{onClick:()=>{r.splitCell({row:o,col:a})},children:t.table_handle.split_cell_menuitem})},Ef=e=>{let t=V();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-menu-dropdown bn-table-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Tf,{}),(0,z.jsx)(wf,{})]})})},Df=e=>{let t=V(),n=Je(),r=B(),i=W(F),a=e.tableCellMenu||Ef;return!r.settings.tables.splitCells&&!r.settings.tables.cellBackgroundColor&&!r.settings.tables.cellTextColor?null:(0,z.jsxs)(t.Generic.Menu.Root,{onOpenChange:t=>{t?(i.freezeHandles(),e.hideOtherElements(!0)):(i.unfreezeHandles(),e.hideOtherElements(!1),r.focus())},position:`right`,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{children:(0,z.jsx)(t.Generic.Menu.Button,{className:`bn-table-cell-handle`,children:e.children||(0,z.jsx)(gd,{size:12,"data-test":`tableCellHandle`})})}),(0,z.jsx)(a,{})]})},Of=e=>{let t=V(),n=H(),r=W(F),i=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>{r.addRowOrColumn(i,e.orientation===`row`?{orientation:`row`,side:e.side}:{orientation:`column`,side:e.side})},children:n.table_handle[`add_${e.side}_menuitem`]})},kf=e=>{let t=V(),n=H(),r=W(F),i=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});return r===void 0||i===void 0?null:(0,z.jsx)(t.Generic.Menu.Item,{onClick:()=>r.removeRowOrColumn(i,e.orientation),children:e.orientation===`row`?n.table_handle.delete_row_menuitem:n.table_handle.delete_column_menuitem})},Af=e=>{let t=V(),n=Je(),r=H(),i=B(),a=W(F),{block:o,index:s}=G(F,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})}),c=(0,R.useMemo)(()=>a===void 0||o===void 0||s===void 0?[]:e.orientation===`row`?a.getCellsAtRowHandle(o,s):a.getCellsAtColumnHandle(o,s),[o,s,e.orientation,a]),l=(e,t)=>{if(o===void 0)return;let n=o.content.rows.map(e=>({...e,cells:e.cells.map(e=>le(e))}));c.forEach(({row:r,col:i})=>{t===`text`?n[r].cells[i].props.textColor=e:n[r].cells[i].props.backgroundColor=e}),i.updateBlock(o,{type:`table`,content:{...o.content,rows:n}}),i.setTextCursorPosition(o)};if(!c||!c[0]||!a||i.settings.tables.cellTextColor===!1&&i.settings.tables.cellBackgroundColor===!1)return null;let u=le(c[0].cell);return(0,z.jsxs)(t.Generic.Menu.Root,{position:`right`,sub:!0,portalElement:n,children:[(0,z.jsx)(t.Generic.Menu.Trigger,{sub:!0,children:(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,subTrigger:!0,children:e.children||r.drag_handle.colors_menuitem})}),(0,z.jsx)(t.Generic.Menu.Dropdown,{sub:!0,className:`bn-menu-dropdown bn-color-picker-dropdown`,children:(0,z.jsx)(Cu,{iconSize:18,text:i.settings.tables.cellTextColor?{color:c.every(({cell:e})=>S(e)&&e.props.textColor===u.props.textColor)?u.props.textColor:`default`,setColor:e=>{l(e,`text`)}}:void 0,background:i.settings.tables.cellBackgroundColor?{color:c.every(({cell:e})=>S(e)&&e.props.backgroundColor===u.props.backgroundColor)?u.props.backgroundColor:`default`,setColor:e=>l(e,`background`)}:void 0})})]})},jf=e=>{let t=V(),n=H(),r=B(),i=W(F),{block:a,index:o}=G(F,{selector:t=>({block:t?.block,index:e.orientation===`column`?t?.colIndex:t?.rowIndex})});if(i===void 0||a===void 0||o!==0||e.orientation!==`row`||!r.settings.tables.headers)return null;let s=!!a.content.headerRows;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerRows:s?void 0:1}})},children:n.drag_handle.header_row_menuitem})},Mf=e=>{let t=V(),n=H(),r=B(),i=W(F),a=G(F,{selector:e=>e?.block}),o=G(F,{selector:t=>e.orientation===`column`?t?.colIndex:t?.rowIndex});if(!i||o!==0||!a||e.orientation!==`column`||!r.settings.tables.headers)return null;let s=!!a.content.headerCols;return(0,z.jsx)(t.Generic.Menu.Item,{className:`bn-menu-item`,checked:s,onClick:()=>{r.updateBlock(a,{...a,content:{...a.content,headerCols:s?void 0:1}})},children:n.drag_handle.header_column_menuitem})},Nf=e=>{let t=V();return(0,z.jsx)(t.Generic.Menu.Dropdown,{className:`bn-table-handle-menu`,children:e.children||(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kf,{orientation:e.orientation}),(0,z.jsx)(Of,{orientation:e.orientation,side:e.orientation===`row`?`above`:`left`}),(0,z.jsx)(Of,{orientation:e.orientation,side:e.orientation===`row`?`below`:`right`}),(0,z.jsx)(jf,{orientation:e.orientation}),(0,z.jsx)(Mf,{orientation:e.orientation}),(0,z.jsx)(Af,{orientation:e.orientation})]})})},Pf=e=>{let t=B(),n=V(),r=Je(),[i,a]=(0,R.useState)(!1),o=e.tableHandleMenu||Nf,s=W(F),c=G(F),l=(0,R.useMemo)(()=>!s||!c||!c.block||c.block.type!==`table`?!1:e.orientation===`column`?s.getCellsAtColumnHandle(c.block,c.colIndex).every(({cell:e})=>ue(e)===1):s.getCellsAtRowHandle(c.block,c.rowIndex).every(({cell:e})=>ve(e)===1),[e.orientation,c,s]);return c?(0,z.jsxs)(n.Generic.Menu.Root,{onOpenChange:n=>{n?(s.freezeHandles(),e.hideOtherElements(!0)):(s.unfreezeHandles(),e.hideOtherElements(!1),t.focus())},position:`right`,portalElement:r,children:[(0,z.jsx)(n.Generic.Menu.Trigger,{children:(0,z.jsx)(n.TableHandle.Root,{className:w(`bn-table-handle`,i?`bn-table-handle-dragging`:``,l?``:`bn-table-handle-not-draggable`),draggable:l,onDragStart:t=>{a(!0),e.hideOtherElements(!0),e.orientation===`column`?s.colDragStart(t):s.rowDragStart(t)},onDragEnd:()=>{s.dragEnd(),e.hideOtherElements(!1),a(!1)},style:e.orientation===`column`?{transform:`rotate(0.25turn)`}:void 0,children:e.children||(0,z.jsx)(_d,{size:24,"data-test":`tableHandle`})})}),(0,z.jsx)(o,{orientation:e.orientation})]}):null},Ff=e=>{let t=B(),[n,r]=(0,R.useState)(),i=G(F),a=(0,R.useMemo)(()=>{let e={};if(i===void 0)return{};let n=te(i.block.id,t.prosemirrorState.doc);if(!n)return{};let r=n.posBeforeNode+1,a=t.prosemirrorView.domAtPos(r+1).node;if(!(a instanceof Element))return{};if(e.tableReference={element:a},i.rowIndex===void 0||i.colIndex===void 0)return e;let o=t.prosemirrorState.doc.resolve(r+1).posAtIndex(i.rowIndex),s=t.prosemirrorState.doc.resolve(o+1).posAtIndex(i.colIndex),c=t.prosemirrorView.domAtPos(s+1).node;return c instanceof Element?(e.cellReference={element:c},e.rowReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(e.x,i.draggingState&&i.draggingState.draggedCellOrientation===`row`?i.draggingState.mousePos-t.height/2:t.y,e.width,t.height)}},e.columnReference={element:a,getBoundingClientRect:()=>{let e=a.getBoundingClientRect(),t=c.getBoundingClientRect();return new DOMRect(i.draggingState&&i.draggingState.draggedCellOrientation===`col`?i.draggingState.mousePos-t.width/2:t.x,e.y,t.width,e.height)}},e):{}},[t,i]),o=(0,R.useCallback)((e,n,r)=>{let i=!1;return xa(e,n,()=>{i?t.getExtension(F)?.hideHandlesIfNotFrozen():i=!0},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[t]),s=(0,R.useMemo)(()=>i===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`),placement:`left`,middleware:[za(-10)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`),placement:`top`,middleware:[za(-12)],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`),placement:`top-end`,middleware:[za({mainAxis:-15,crossAxis:-1})],whileElementsMounted:o},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`),placement:`bottom`,whileElementsMounted:o,middleware:[Ua({apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`),placement:`right`,whileElementsMounted:o,middleware:[Ua({apply({rects:e,elements:t}){Object.assign(t.floating.style,{height:`${e.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[n,i,o]);if(!i)return null;let c=e.tableHandle||Pf,l=e.extendButton||Cf,u=e.tableCellHandle||Df;return(0,z.jsxs)(Xe,{target:e.portalElement,children:[(0,z.jsx)(ks,{reference:a?.rowReference,...s?.rowTableHandle,children:i.show&&i.rowIndex!==void 0&&(!n||n===`rowTableHandle`)&&(0,z.jsx)(c,{orientation:`row`,hideOtherElements:e=>r(e?`rowTableHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.columnReference,...s?.columnTableHandle,children:i.show&&i.colIndex!==void 0&&(!n||n===`columnTableHandle`)&&(0,z.jsx)(c,{orientation:`column`,hideOtherElements:e=>r(e?`columnTableHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.cellReference,...s?.tableCellHandle,children:i.show&&i.rowIndex!==void 0&&i.colIndex!==void 0&&(!n||n===`tableCellHandle`)&&(0,z.jsx)(u,{hideOtherElements:e=>r(e?`tableCellHandle`:void 0)})}),(0,z.jsx)(ks,{reference:a?.tableReference,...s?.extendRowsButton,children:i.show&&i.showAddOrRemoveRowsButton&&(!n||n===`extendRowsButton`)&&(0,z.jsx)(l,{orientation:`addOrRemoveRows`,hideOtherElements:e=>r(e?`extendRowsButton`:void 0)})}),(0,z.jsx)(ks,{reference:a?.tableReference,...s?.extendColumnsButton,children:i.show&&i.showAddOrRemoveColumnsButton&&(!n||n===`extendColumnsButton`)&&(0,z.jsx)(l,{orientation:`addOrRemoveColumns`,hideOtherElements:e=>r(e?`extendColumnsButton`:void 0)})})]})};function If(e){if(e!==void 0){if(typeof e==`string`){if(typeof document>`u`)return;let t=document.querySelector(e);if(!t){console.warn(`[BlockNote] portalElements selector "${e}" did not match any element`);return}return t}return e}}var Lf=(0,R.lazy)(()=>Promise.resolve().then(()=>lp)),Rf=(0,R.lazy)(()=>Promise.resolve().then(()=>mp));function zf(e){let t=B();if(!t)throw Error(`BlockNoteDefaultUI must be used within a BlockNoteContext.Provider`);let n=e.portalElements,r=If(n?.formattingToolbar),i=If(n?.linkToolbar),a=If(n?.slashMenu),o=If(n?.emojiPicker),s=If(n?.sideMenu),c=If(n?.filePanel),l=If(n?.tableHandles),u=If(n?.comments),d=If(n?.attributionTooltip);return(0,z.jsxs)(z.Fragment,{children:[t.getExtension(A)&&e.formattingToolbar!==!1&&(0,z.jsx)(cd,{portalElement:r}),t.getExtension(be)&&e.linkToolbar!==!1&&(0,z.jsx)(pd,{portalElement:i}),t.getExtension(N)&&e.slashMenu!==!1&&(0,z.jsx)(xf,{triggerCharacter:`/`,shouldOpen:e=>!e.selection.$from.parent.type.isInGroup(`tableContent`),portalElement:a}),t.getExtension(N)&&e.emojiPicker!==!1&&(0,z.jsx)(ff,{triggerCharacter:`:`,portalElement:o}),t.getExtension(I)&&e.sideMenu!==!1&&(0,z.jsx)(Ed,{portalElement:s}),t.getExtension(E)&&e.filePanel!==!1&&(0,z.jsx)(hu,{portalElement:c}),t.getExtension(F)&&e.tableHandles!==!1&&(0,z.jsx)(Ff,{portalElement:l}),t.getExtension(Hs)&&e.comments!==!1&&(0,z.jsxs)(R.Suspense,{children:[(0,z.jsx)(Lf,{portalElement:u}),(0,z.jsx)(Rf,{portalElement:u})]}),t.getExtension(`attribution`)&&e.attributionTooltip!==!1&&(0,z.jsx)(jd,{portalElement:d})]})}var Bf=!1;function Vf(){typeof process<`u`||Bf||typeof document>`u`||(Bf=!0,(document.querySelector(`meta[name="viewport"]`)?.getAttribute(`content`)??``).replace(/\s/g,``).includes(`interactive-widget=resizes-content`)||console.warn(`[BlockNote] This page's viewport meta tag is missing "interactive-widget=resizes-content" in its content attribute. Add it to ensure proper mobile functionality, e.g. . See https://www.blocknotejs.org/docs/getting-started#mobile-compatibility for more information`))}function Hf(e,t){let n=Ie(),r=t??n?.editor,i=(0,R.useRef)(e);Be(()=>{i.current=e}),(0,R.useEffect)(()=>{if(!r)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return r.onChange((...e)=>i.current(...e))},[r])}function Uf(e,t,n){let r=Ie(),i=t??r?.editor,a=(0,R.useRef)(e);Be(()=>{a.current=e}),(0,R.useEffect)(()=>{if(!i)throw Error(`'editor' is required, either from BlockNoteContext or as a function argument`);return i.onSelectionChange(e=>a.current(e),n)},[i,n])}var Wf=()=>{let e=(0,R.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`),[]),t=(0,R.useMemo)(()=>window.matchMedia?.(`(prefers-color-scheme: light)`),[]),n=e?.matches,r=t?.matches,[i,a]=(0,R.useState)(n?`dark`:r?`light`:`no-preference`);return(0,R.useEffect)(()=>{a(n?`dark`:r?`light`:`no-preference`)},[n,r]),(0,R.useEffect)(()=>{if(typeof e?.addEventListener==`function`){let n=({matches:e})=>e&&a(`dark`),r=({matches:e})=>e&&a(`light`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,r),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,r)}}{let n=()=>a(e.matches?`dark`:t.matches?`light`:`no-preference`);return e?.addEventListener(`change`,n),t?.addEventListener(`change`,n),()=>{e?.removeEventListener(`change`,n),t?.removeEventListener(`change`,n)}}},[e,t]),window.matchMedia,i};function Gf(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:(0,Ne.createPortal)(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Kf=({contentComponent:e})=>{let t=(0,R.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,z.jsx)(z.Fragment,{children:Object.values(t)})},qf=(0,R.forwardRef)((e,t)=>{let[n,r]=(0,R.useState)();return(0,R.useImperativeHandle)(t,()=>(e,t)=>{(0,Ne.flushSync)(()=>{r({node:e,container:t})}),r(void 0)},[]),(0,z.jsx)(z.Fragment,{children:n&&(0,Ne.createPortal)(n.node,n.container)})}),Jf=()=>{};function Yf(e,t){let{editor:n,className:r,theme:i,children:a,editable:o,onSelectionChange:s,onChange:c,formattingToolbar:l,linkToolbar:u,slashMenu:d,emojiPicker:f,sideMenu:p,filePanel:m,tableHandles:h,comments:g,portalElements:_,applyThemedRoot:v,autoFocus:y,renderEditor:b=!0,...x}=e,S=(0,R.useMemo)(()=>If(_?.default),[_?.default]),[C,T]=(0,R.useState)(),E=Ie(),D=Wf(),O=E?.colorSchemePreference||D,k=i||(O===`dark`?`dark`:`light`),A=V(),j=(0,R.useMemo)(()=>({formattingToolbar:A?l:!1,linkToolbar:A?u:!1,sideMenu:A?p:!1,slashMenu:A?d:!1,filePanel:A?m:!1,tableHandles:A?h:!1,emojiPicker:A?f:!1,comments:A?g:!1,portalElements:_}),[g,A,f,m,l,u,p,d,h,_]);Hf(c||Jf,n),Uf(s||Jf,n);let M=(0,R.useCallback)(e=>{n.elementRenderer=e},[n]),N=(0,R.useCallback)(e=>{e.className=w(`bn-root`,k,r||``),e.setAttribute(`data-color-scheme`,k),v?.(e)},[k,r,v]),P=(0,R.useMemo)(()=>({...E,editor:n,setContentEditableProps:T,colorSchemePreference:k}),[E,n,k]),ee=(0,R.useMemo)(()=>({editorProps:{autoFocus:y,contentEditableProps:C,editable:o},defaultUIProps:j,applyThemedRoot:N}),[y,C,o,j,N]);return(0,z.jsx)(Fe.Provider,{value:P,children:(0,z.jsxs)(We.Provider,{value:ee,children:[(0,z.jsx)(qf,{ref:M}),(0,z.jsx)(Xf,{className:r,renderEditor:b,editorColorScheme:k,defaultPortalElement:S,ref:t,...x,children:a})]})})}var Xf=R.forwardRef(({className:e,renderEditor:t,editorColorScheme:n,defaultPortalElement:r,children:i,...a},o)=>(0,z.jsx)(`div`,{className:w(`bn-root`,`bn-container`,n,e),"data-color-scheme":n,...a,ref:o,children:(0,z.jsx)(Ye,{children:(0,z.jsx)(Xe,{target:r,children:t?(0,z.jsx)(Qf,{children:i}):i})})})),Zf=R.forwardRef(Yf),Qf=e=>{let t=Ge(),n=B(),r=(0,R.useMemo)(()=>Gf(),[]);(0,R.useEffect)(()=>{Vf()},[]);let i=(0,R.useCallback)(e=>{n.isEditable=t.editorProps.editable!==!1,n._tiptapEditor.contentComponent=r,e?n.mount(e):n.unmount()},[t.editorProps.editable,n,r]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Kf,{contentComponent:r}),(0,z.jsx)($f,{...t.editorProps,...e,mount:i}),(0,z.jsx)(zf,{...t.defaultUIProps}),e.children]})},$f=e=>{let{autoFocus:t,mount:n,contentEditableProps:r}=e;return(0,z.jsx)(`div`,{"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"data-bn-autofocus":t,ref:n,...r})};ee();var ep=e=>{let[t,n]=(0,R.useState)(!1),r=V(),i=Je(),a=H(),o=a.locale??`en`;function s(t){n(t),e.onOpenChange?.(t)}return(0,z.jsxs)(r.Generic.Popover.Root,{open:t,onOpenChange:s,portalElement:i,children:[(0,z.jsx)(r.Generic.Popover.Trigger,{children:(0,z.jsx)(`div`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),s(!t)},style:{display:`flex`,justifyContent:`center`,alignItems:`center`},children:e.children})}),(0,z.jsx)(r.Generic.Popover.Content,{className:`bn-emoji-picker-popover`,variant:`panel-popover`,children:t&&(0,z.jsx)(Yd,{onEmojiSelect:t=>{e.onEmojiSelect(t),s(!1)},onEscape:()=>s(!1),locale:o,dictionary:a.emoji_picker})})]})};function tp(e){let{userStore:t}=W(Hs),n=e.join(`,`);return(0,R.useEffect)(()=>{t.loadUsers(e)},[t,n]),Le(t.store,t=>{let n=new Map;for(let r of e){let e=t.get(r);e&&n.set(r,e)}return n})}function np(e){return tp([e]).get(e)}var rp=e=>{let t=V(),n=H(),r=W(Hs),i=e.comment.reactions.find(t=>t.emoji===e.emoji);if(!i)throw Error(`Trying to render reaction badge for non-existing reaction`);let[a,o]=(0,R.useState)([]),s=tp(a);return(0,z.jsx)(t.Generic.Badge.Root,{className:w(`bn-badge`,`bn-comment-reaction`),text:i.userIds.length.toString(),icon:i.emoji,isSelected:r.threadStore.auth.canDeleteReaction(e.comment,i.emoji),onClick:()=>e.onReactionSelect(i.emoji),onMouseEnter:()=>o(i.userIds),mainTooltip:n.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(s.values()).map(e=>e.username).join(` `)}`},i.emoji)},ip=(0,R.memo)(({isEmpty:e,comment:t,isEditing:n,threadStore:r,onReactionSelect:i,onEditSubmit:a,onEditCancel:o,onEmojiPickerOpenChange:s,Components:c,dict:l})=>{let u=r.auth.canAddReaction(t);return(0,z.jsxs)(z.Fragment,{children:[t.reactions.length>0&&!n&&(0,z.jsxs)(c.Generic.Badge.Group,{className:w(`bn-badge-group`,`bn-comment-reactions`),children:[t.reactions.map(e=>(0,z.jsx)(rp,{comment:t,emoji:e.emoji,onReactionSelect:i},e.emoji)),u&&(0,z.jsx)(ep,{onEmojiSelect:i,onOpenChange:s,children:(0,z.jsx)(c.Generic.Badge.Root,{className:w(`bn-badge`,`bn-comment-add-reaction`),text:`+`,icon:(0,z.jsx)(_t,{size:16}),mainTooltip:l.comments.actions.add_reaction})})]}),n&&(0,z.jsxs)(c.Generic.Toolbar.Root,{variant:`action-toolbar`,className:w(`bn-action-toolbar`,`bn-comment-actions`),children:[(0,z.jsx)(c.Generic.Toolbar.Button,{mainTooltip:l.comments.save_button_text,variant:`compact`,onClick:a,isDisabled:e,children:l.comments.save_button_text}),(0,z.jsx)(c.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:l.comments.cancel_button_text,variant:`compact`,onClick:o,children:l.comments.cancel_button_text})]})]})}),ap=({comment:e,thread:t,showResolveButton:n})=>{let r=W(Hs),i=H(),[a,o]=(0,R.useState)(!1),s=js({initialContent:e.body,trailingBlock:!1,dictionary:{...i,placeholders:{emptyDocument:i.placeholders.edit_comment}},schema:r.commentEditorSchema||Is,extensions:[Rs({submitOnEnter:r.submitOnEnter,onSubmit:async n=>{await r.threadStore.updateComment({commentId:e.id,comment:{body:n.document},threadId:t.id}),o(!1)}})]}),c=V(),l=Je(),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),m=r.threadStore,h=(0,R.useCallback)(()=>{o(!0)},[]),g=(0,R.useCallback)(()=>{s.replaceBlocks(s.document,e.body),o(!1)},[s,e.body]),_=s.getExtension(Rs).submit,v=(0,R.useCallback)(async()=>{await m.deleteComment({commentId:e.id,threadId:t.id})},[e,t.id,m]),y=(0,R.useCallback)(async n=>{m.auth.canAddReaction(e,n)?await m.addReaction({threadId:t.id,commentId:e.id,emoji:n}):m.auth.canDeleteReaction(e,n)&&await m.deleteReaction({threadId:t.id,commentId:e.id,emoji:n})},[m,e,t.id]),b=(0,R.useCallback)(async()=>{await m.resolveThread({threadId:t.id})},[t.id,m]),x=(0,R.useCallback)(async()=>{await m.unresolveThread({threadId:t.id})},[t.id,m]),S=np(e.userId);if(!e.body)return null;let C,T=m.auth.canAddReaction(e),E=m.auth.canDeleteComment(e),D=m.auth.canUpdateComment(e),O=n&&(t.resolved?m.auth.canUnresolveThread(t):m.auth.canResolveThread(t));a||(C=(0,z.jsxs)(c.Generic.Toolbar.Root,{className:w(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:[T&&(0,z.jsx)(ep,{onEmojiSelect:y,onOpenChange:d,children:(0,z.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.add_reaction,variant:`compact`,children:(0,z.jsx)(_t,{size:16})},`add-reaction`)}),O&&(t.resolved?(0,z.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.reopen,variant:`compact`,onClick:x,children:(0,z.jsx)(pn,{size:16})},`reopen`):(0,z.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.resolve,variant:`compact`,onClick:b,children:(0,z.jsx)(Tt,{size:16})},`resolve`)),(E||D)&&(0,z.jsxs)(c.Generic.Menu.Root,{position:`bottom-start`,onOpenChange:p,portalElement:l,children:[(0,z.jsx)(c.Generic.Menu.Trigger,{children:(0,z.jsx)(c.Generic.Toolbar.Button,{mainTooltip:i.comments.actions.more_actions,variant:`compact`,children:(0,z.jsx)(bt,{size:16})},`more-actions`)}),(0,z.jsxs)(c.Generic.Menu.Dropdown,{className:`bn-menu-dropdown`,children:[D&&(0,z.jsx)(c.Generic.Menu.Item,{icon:(0,z.jsx)(fn,{}),onClick:h,children:i.comments.actions.edit_comment},`edit-comment`),E&&(0,z.jsx)(c.Generic.Menu.Item,{icon:(0,z.jsx)(Ct,{}),onClick:v,children:i.comments.actions.delete_comment},`delete-comment`)]})]})]}));let k=e.createdAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`});if(!e.body)throw Error(`soft deletes are not yet supported`);return(0,z.jsx)(c.Comments.Comment,{authorInfo:S??`loading`,timeString:k,edited:e.updatedAt.getTime()!==e.createdAt.getTime(),showActions:f||`hover`,actions:C,className:`bn-thread-comment`,emojiPickerOpen:u,children:(0,z.jsx)(Ms,{autoFocus:a,editor:s,editable:a,actions:e.reactions.length>0||a?({isFocused:t,isEmpty:n})=>(0,z.jsx)(ip,{isFocused:t,isEmpty:n,comment:e,isEditing:a,threadStore:m,onReactionSelect:y,onEditSubmit:_,onEditCancel:g,onEmojiPickerOpenChange:d,Components:c,dict:i}):void 0})})},op=({thread:e,maxCommentsBeforeCollapse:t})=>{let n=V(),r=H(),i=tp(e.resolvedBy?[e.resolvedBy]:[]),a=e.comments.map((t,n)=>(0,z.jsx)(ap,{thread:e,comment:t,showResolveButton:n===0},t.id+JSON.stringify(t.body||`{}`)));if(e.resolved&&e.resolvedUpdatedAt&&e.resolvedBy){if(!i.get(e.resolvedBy))throw Error(`User ${e.resolvedBy} resolved thread ${e.id}, but their data could not be found.`);let t=e.comments.findLastIndex(t=>e.resolvedUpdatedAt.getTime()>t.createdAt.getTime())+1;a.splice(t,0,(0,z.jsx)(n.Comments.Comment,{className:`bn-thread-comment`,authorInfo:e.resolvedBy&&i.get(e.resolvedBy)||`loading`,timeString:e.resolvedUpdatedAt.toLocaleDateString(void 0,{month:`short`,day:`numeric`}),edited:!1,showActions:!1,children:(0,z.jsx)(`div`,{className:`bn-resolved-text`,children:r.comments.sidebar.marked_as_resolved})},`resolved-comment`))}return t&&a.length>t&&a.splice(1,a.length-2,(0,z.jsx)(n.Comments.ExpandSectionsPrompt,{className:`bn-thread-expand-prompt`,children:r.comments.sidebar.more_replies(e.comments.length-2)},`expand-prompt`)),a},sp=(0,R.memo)(({isEmpty:e,onSave:t,Components:n,dict:r})=>(0,z.jsx)(n.Generic.Toolbar.Root,{className:w(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:(0,z.jsx)(n.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})}));function cp(e){let t=e.newCommentEditor,n=V(),r=H(),i=t.getExtension(Rs);if(!i)throw Error(`FloatingComposer's newCommentEditor must include CommentEditorSubmitExtension.`);let a=i.submit;return(0,z.jsx)(n.Comments.Card,{className:`bn-thread`,children:(0,z.jsx)(Ms,{autoFocus:!0,editable:!0,editor:t,actions:({isFocused:e,isEmpty:t})=>(0,z.jsx)(sp,{isFocused:e,isEmpty:t,onSave:a,Components:n,dict:r})})})}var lp=uu({default:()=>up});function up(e){let t=B(),n=H(),r=W(Hs),i=G(Hs,{editor:t,selector:e=>e.pendingComment}),a=js({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.new_comment}},schema:r.commentEditorSchema||Is,extensions:[Rs({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{await r.createThread({initialComment:{body:e.document}}),r.stopPendingComment(),t.transact(e=>{e.setSelection(oe.create(e.doc,e.selection.to))}),t.focus()}})]},[i]),o=He({editor:t,selector:({editor:e})=>i?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),s=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:e=>{if(!e){if(!Ls({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;r.stopPendingComment(),t.focus()}},placement:`bottom`,middleware:[za(10),Ba(),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!1},elementProps:{style:{zIndex:60},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,i,e.floatingUIOptions]),c=e.floatingComposer||cp;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(As,{position:o,...s,children:(0,z.jsx)(c,{newCommentEditor:a})})})}var dp=(0,R.memo)(({isEmpty:e,onNewCommentSave:t,Components:n,dict:r})=>e?null:(0,z.jsx)(n.Generic.Toolbar.Root,{variant:`action-toolbar`,className:w(`bn-action-toolbar`,`bn-comment-actions`),children:(0,z.jsx)(n.Generic.Toolbar.Button,{mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})})),fp=({thread:e,selected:t,orphaned:n,referenceText:r,maxCommentsBeforeCollapse:i,onFocus:a,onBlur:o,tabIndex:s,newCommentEditor:c})=>{let l=V(),u=H(),d=W(Hs),f=(0,R.useRef)(e.id);f.current=e.id;let p=js({trailingBlock:!1,dictionary:{...u,placeholders:{emptyDocument:u.placeholders.comment_reply}},schema:d.commentEditorSchema||Is,extensions:[Rs({submitOnEnter:d.submitOnEnter,onSubmit:async e=>{await d.threadStore.addComment({comment:{body:e.document},threadId:f.current}),e.removeBlocks(e.document)}})]}),m=c??p,h=m.getExtension(Rs);if(!h)throw Error(`Thread's newCommentEditor must include CommentEditorSubmitExtension.`);let g=h.submit;return(0,z.jsxs)(l.Comments.Card,{className:w(`bn-thread`,n&&`bn-thread-orphaned`),headerText:r,onFocus:a,onBlur:o,selected:t,tabIndex:s,children:[(0,z.jsx)(l.Comments.CardSection,{className:`bn-thread-comments`,children:(0,z.jsx)(op,{thread:e,maxCommentsBeforeCollapse:t?void 0:i||5})}),t&&(0,z.jsx)(l.Comments.CardSection,{className:`bn-thread-composer`,children:(0,z.jsx)(Ms,{autoFocus:!1,editable:!0,editor:m,actions:({isFocused:e,isEmpty:t})=>(0,z.jsx)(dp,{isFocused:e,isEmpty:t,onNewCommentSave:g,Components:l,dict:u})})})]})};function pp(){let e=W(Hs).threadStore,t=(0,R.useRef)(void 0);t.current||=e.getThreads();let n=(0,R.useCallback)(n=>e.subscribe(e=>{t.current=e,n()}),[e]);return(0,R.useSyncExternalStore)(n,()=>t.current)}var mp=uu({default:()=>hp});function hp(e){let t=B(),n=H(),r=W(Hs),i=G(Hs,{editor:t,selector:e=>e.selectedThreadId?{id:e.selectedThreadId,position:e.threadPositions.get(e.selectedThreadId)}:void 0}),a=js({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.comment_reply}},schema:r.commentEditorSchema||Is,extensions:[Rs({submitOnEnter:r.submitOnEnter,onSubmit:async e=>{i&&(await r.threadStore.addComment({comment:{body:e.document},threadId:i.id}),e.removeBlocks(e.document))}})]},[i?.id]),o=pp(),s=(0,R.useMemo)(()=>i?o.get(i.id):void 0,[i,o]),c=(0,R.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!i,onOpenChange:(e,i,o)=>{if(!e){if(!Ls({hasUnsavedContent:!a.isEmpty,confirmBeforeDiscard:r.confirmBeforeDiscard,message:n.comments.discard_pending_comment}))return;o===`escape-key`&&t.focus(),r.selectThread(void 0)}},placement:`bottom`,middleware:[za(10),Ba(),Ha()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:30},...e.floatingUIOptions?.elementProps}}),[r,n,t,a,e.floatingUIOptions,i]),l=e.floatingThread||fp;return(0,z.jsx)(Xe,{target:e.portalElement,children:(0,z.jsx)(As,{position:i?.position,...c,children:s&&(0,z.jsx)(l,{thread:s,selected:!0,newCommentEditor:a})})})}R.memo(({thread:e,selectedThreadId:t,maxCommentsBeforeCollapse:n,referenceText:r,orphaned:i})=>{let a=W(Hs),o=(0,R.useCallback)(t=>{t.target.closest(`.bn-action-toolbar`)||a.selectThread(e.id)},[a,e.id]),s=(0,R.useCallback)(e=>{if(!e.relatedTarget||e.relatedTarget.closest(`.bn-action-toolbar`))return;let t=e.target instanceof Node?e.target:null,n=e.relatedTarget instanceof Node?e.relatedTarget.closest(`.bn-thread`):null;t&&n&&n.contains(t)||a.selectThread(void 0)},[a]);return(0,z.jsx)(fp,{thread:e,selected:e.id===t,orphaned:i,referenceText:r,maxCommentsBeforeCollapse:n,onFocus:o,onBlur:s,tabIndex:0})});function gp(e){let t=(0,R.useRef)(null);return(0,R.useEffect)(()=>{e&&t.current?.focus({preventScroll:!0})},[e]),t}function _p(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.topr.bottom;return i&&a?`both`:i?`top`:a?`bottom`:`none`}function vp(e){_()?e.preventDefault():k()&&e.currentTarget.focus()}function yp(e){return Object.keys(e)}function bp(e){return e&&typeof e==`object`&&!Array.isArray(e)}function xp(e,t){let n={...e},r=t;return bp(e)&&bp(t)&&Object.keys(t).forEach(t=>{bp(r[t])&&t in e?n[t]=xp(n[t],r[t]):n[t]=r[t]}),n}function Sp(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Cp(e){return typeof e!=`string`||!e.includes(`var(--mantine-scale)`)?e:e.match(/^calc\((.*?)\)$/)?.[1].split(`*`)[0].trim()}function wp(e){let t=Cp(e);return typeof t==`number`?t:typeof t==`string`?t.includes(`calc`)||t.includes(`var`)?t:t.includes(`px`)?Number(t.replace(`px`,``)):t.includes(`rem`)?Number(t.replace(`rem`,``))*16:t.includes(`em`)?Number(t.replace(`em`,``))*16:Number(t):NaN}function Tp(e){return e===`0rem`?`0rem`:`calc(${e} * var(--mantine-scale))`}function Ep(e,{shouldScale:t=!1}={}){function n(r){if(r===0||r===`0`)return`0${e}`;if(typeof r==`number`){let n=`${r/16}${e}`;return t?Tp(n):n}if(typeof r==`string`){if(r===``||r.startsWith(`calc(`)||r.startsWith(`clamp(`)||r.includes(`rgba(`))return r;if(r.includes(`,`))return r.split(`,`).map(e=>n(e)).join(`,`);if(r.includes(` `))return r.split(` `).map(e=>n(e)).join(` `);let i=r.replace(`px`,``);if(!Number.isNaN(Number(i))){let n=`${Number(i)/16}${e}`;return t?Tp(n):n}}return r}return n}var K=Ep(`rem`,{shouldScale:!0}),Dp=Ep(`em`);function Op(e){return Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&(t[n]=e[n]),t),{})}function kp(e){if(typeof e==`number`)return!0;if(typeof e==`string`){if(e.startsWith(`calc(`)||e.startsWith(`var(`)||e.includes(` `)&&e.trim()!==``)return!0;let t=/^[+-]?(?:[0-9]*\.)?[0-9]+(px|em|rem|ex|ch|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|cm|mm|in|pt|pc|q|cqw|cqh|cqi|cqb|cqmin|cqmax|%)?$/;return e.trim().split(/\s+/).every(e=>t.test(e))}return!1}function Ap(e){return Array.isArray(e)||e===null?!1:typeof e==`object`&&e.type!==R.Fragment}function jp(e){let t=(0,R.createContext)(null);return[t,()=>{let n=(0,R.use)(t);if(n===null)throw Error(e);return n}]}function Mp(e,t){return n=>{if(typeof n!=`string`||n.trim().length===0)throw Error(t);return`${e}-${n}`}}function Np(e,t){let n=e;for(;(n=n.parentElement)&&!n.matches(t););return n}function Pp(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].disabled)return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].disabled)return e}return e}function Fp(e,t,n){for(let n=e+1;n{n?.(s);let c=Array.from(Np(s.currentTarget,e)?.querySelectorAll(t)||[]).filter(t=>Ip(s.currentTarget,t,e)),l=c.findIndex(e=>s.currentTarget===e),u=Fp(l,c,r),d=Pp(l,c,r),f=a===`rtl`?d:u,p=a===`rtl`?u:d;switch(s.key){case`ArrowRight`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[f].focus(),i&&c[f].click());break;case`ArrowLeft`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[p].focus(),i&&c[p].click());break;case`ArrowUp`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[d].focus(),i&&c[d].click());break;case`ArrowDown`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[u].focus(),i&&c[u].click());break;case`Home`:{s.stopPropagation(),s.preventDefault();let e=c[Fp(-1,c,!1)];e?.focus(),i&&e?.getAttribute(`aria-selected`)!==`true`&&e?.click();break}case`End`:{s.stopPropagation(),s.preventDefault();let e=c[Pp(c.length,c,!1)];e?.focus(),i&&e?.getAttribute(`aria-selected`)!==`true`&&e?.click();break}}}}var Rp={app:100,modal:200,popover:300,overlay:400,max:9999};function zp(e){return Rp[e]}var Bp=()=>{};function Vp(e,t={active:!0}){return typeof e!=`function`||!t.active?t.onKeyDown||Bp:n=>{n.key===`Escape`&&(e(n),t.onTrigger?.())}}function Hp(e,t=`size`,n=!0){if(e!==void 0)return kp(e)?n?K(e):e:`var(--${t}-${e})`}function Up(e){return Hp(e,`mantine-spacing`)}function Wp(e){return e===void 0?`var(--mantine-radius-default)`:Hp(e,`mantine-radius`)}function Gp(e){return Hp(e,`mantine-font-size`)}function Kp(e){return Hp(e,`mantine-line-height`,!1)}function qp(e){if(e)return Hp(e,`mantine-shadow`,!1)}function Jp(e,t){return n=>{e?.(n),t?.(n)}}function Yp(e,t,n){return n?Array.from(Np(n,t)?.querySelectorAll(e)||[]).findIndex(e=>e===n):null}function Xp(e=`mantine-`){return`${e}${Math.random().toString(36).slice(2,11)}`}var Zp=[`mousedown`,`touchstart`];function Qp(e,t,n,r=!0,i=!1){let a=(0,R.useRef)(null),o=t||Zp,s=(0,R.useEffectEvent)(t=>{let{target:r}=t??{};if(!document.body.contains(r)&&r?.tagName!==`HTML`)return;let i=t.composedPath();Array.isArray(n)?n.every(e=>!!e&&!i.includes(e))&&e(t):a.current&&!i.includes(a.current)&&e(t)}),c=o.join(`,`);return(0,R.useEffect)(()=>{if(!r)return;let e=c.split(`,`);return e.forEach(e=>document.addEventListener(e,s,i)),()=>{e.forEach(e=>document.removeEventListener(e,s,i))}},[c,r,i]),a}function $p(e,t){if(typeof t==`boolean`)return t;if(typeof window<`u`&&`matchMedia`in window)try{return window.matchMedia(e).matches}catch{return!1}return!1}function em(e,t,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){let[r,i]=(0,R.useState)(n?t:$p(e));return(0,R.useEffect)(()=>{try{if(`matchMedia`in window){let t=window.matchMedia(e);i(t.matches);let n=e=>i(e.matches);return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}}}catch{return}},[e]),r||!1}var tm=typeof document<`u`?R.useLayoutEffect:R.useEffect;function nm(e,t){return e.length!==t.length||t.some((t,n)=>!Object.is(t,e[n]))}function rm(e,t){let n=(0,R.useRef)(!1),r=(0,R.useRef)(null),i=(0,R.useRef)(void 0),a={};(0,R.useEffect)(()=>{let o=r.current===a,s=i.current;if(r.current=a,i.current=t,!n.current)n.current=!0;else if(!o&&!(t&&s&&!nm(s,t)))return e()},t)}function im({opened:e,shouldReturnFocus:t=!0}){let n=(0,R.useRef)(null),r=()=>{n.current&&`focus`in n.current&&typeof n.current.focus==`function`&&n.current?.focus({preventScroll:!0})};return rm(()=>{let i=-1,a=e=>{e.key===`Tab`&&window.clearTimeout(i)};if(document.addEventListener(`keydown`,a),e)n.current=document.activeElement;else if(t){let e=document.activeElement;i=window.setTimeout(()=>{let t=document.activeElement;(t===null||t===document.body||t===e)&&r()},10)}return()=>{window.clearTimeout(i),document.removeEventListener(`keydown`,a)}},[e,t]),r}var am=/input|select|textarea|button|object|summary|iframe/,om=`a, input, select, textarea, button, object, summary, iframe, audio[controls], video[controls], [contenteditable], [tabindex]`;function sm(e){let t=e.getAttribute(`contenteditable`);return t!==null&&t!==`false`}function cm(e){let t=e.nodeName.toLowerCase();return(t===`audio`||t===`video`)&&e.hasAttribute(`controls`)}function lm(e){return e.style.display===`none`}function um(e){if(e.getAttribute(`aria-hidden`)||e.getAttribute(`hidden`)||e.getAttribute(`type`)===`hidden`)return!1;let t=e;for(;t&&t!==document.body&&t.nodeType!==11;){if(lm(t))return!1;t=t.parentNode}return!0}function dm(e){let t=e.getAttribute(`tabindex`);return t===null&&(t=void 0),parseInt(t,10)}function fm(e){let t=e.nodeName.toLowerCase(),n=!Number.isNaN(dm(e));return(am.test(t)&&!e.disabled||sm(e)||cm(e)||e instanceof HTMLAnchorElement&&e.href||n)&&um(e)}function pm(e){let t=dm(e);return(Number.isNaN(t)||t>=0)&&fm(e)}function mm(e){let t=Array.from(e.querySelectorAll(om)).filter(pm),n=t.filter(e=>dm(e)>0).sort((e,t)=>dm(e)-dm(t)),r=t.filter(e=>!(dm(e)>0));return[...n,...r]}var hm=[`date`,`time`,`datetime-local`,`month`,`week`],gm=[`audio`,`video`,`iframe`,`object`,`embed`];function _m(e){return!!e&&e.tagName===`INPUT`&&e.type===`radio`}function vm(e,t){return e.name!==``&&e.name===t.name&&e.form===t.form}function ym(e){let t=e.nodeName.toLowerCase();return t===`input`?hm.includes(e.type):gm.includes(t)}function bm(e,t){let n=mm(e);return n.filter(e=>e===t||!_m(e)?!0:_m(t)&&vm(e,t)?!1:e.checked?!0:!n.some(t=>_m(t)&&t.checked&&vm(t,e)))}function xm(e,t,n,r){let i=e.indexOf(t);if(i!==-1)return i+1;if(t===n)return 0;let a=r?Node.DOCUMENT_POSITION_PRECEDING:Node.DOCUMENT_POSITION_FOLLOWING,o=e.findIndex(e=>(t.compareDocumentPosition(e)&a)!==0);return o===-1?0:o}function Sm(e,t,n){let r=bm(e,t);n&&r.reverse();let i=xm(r,t,e,n);return[...r.slice(i),...r.slice(0,i)].filter(e=>e!==t)}function Cm(e,t){for(let n of e)if(n.focus(),t.activeElement===n)return}function wm(e,t){let n=e.getRootNode(),r=n.activeElement;if(!r||r!==e&&!e.contains(r))return;let i=Sm(e,r,t.shiftKey);ym(r)?setTimeout(()=>{let t=n.activeElement;e.isConnected&&t!==r&&t!==i[0]&&Cm([...i,r],n)}):(t.preventDefault(),Cm(i,n))}var Tm=new Set;function Em(e,t){let n=t.getRootNode().activeElement;if(!n)return!1;for(let r of Tm){let i=r.current;if(r!==e&&i&&i!==t&&t.contains(i)&&i.contains(n))return!0}return!1}function Dm(e=!0){let t=(0,R.useRef)(null),n=e=>{let t=e.querySelector(`[data-autofocus]`);if(!t){let n=Array.from(e.querySelectorAll(om));t=n.find(pm)||n.find(fm)||null,!t&&fm(e)&&(t=e)}t?t.focus({preventScroll:!0}):console.warn(`[@mantine/hooks/use-focus-trap] Failed to find focusable element within provided node`,e)},r=(0,R.useCallback)(r=>{e&&(r===null?t.current=null:t.current!==r&&(setTimeout(()=>{r.getRootNode()?n(r):console.warn(`[@mantine/hooks/use-focus-trap] Ref node is not part of the dom`,r)}),t.current=r))},[e]);return(0,R.useEffect)(()=>{if(!e)return;t.current&&setTimeout(()=>{t.current&&n(t.current)});let r=e=>{e.key!==`Tab`||e.defaultPrevented||!t.current||Em(t,t.current)||wm(t.current,e)};return Tm.add(t),document.addEventListener(`keydown`,r),()=>{Tm.delete(t),document.removeEventListener(`keydown`,r)}},[e]),r}var Om=e=>(e+1)%1e6;function km(){let[,e]=(0,R.useReducer)(Om,0);return e}function Am(e){let t=(0,R.useId)(),[n,r]=(0,R.useState)(`mantine-${t.replace(/:/g,``)}`),i=(0,R.useRef)(!1);return tm(()=>{i.current||(i.current=!0,r(Xp()))},[]),typeof e==`string`?e:n}function jm(e,t){if(typeof e==`function`)return e(t);typeof e==`object`&&e&&`current`in e&&(e.current=t)}function Mm(...e){let t=new Map;return n=>{if(e.forEach(e=>{let r=jm(e,n);r&&t.set(e,r)}),t.size>0)return()=>{e.forEach(e=>{let n=t.get(e);n&&typeof n==`function`?n():jm(e,null)}),t.clear()}}}function Nm(...e){return(0,R.useCallback)(Mm(...e),e)}function Pm({value:e,defaultValue:t,finalValue:n,onChange:r=()=>{}}){let[i,a]=(0,R.useState)(t===void 0?n:t);return e===void 0?[i,(e,...t)=>{a(e),r?.(e,...t)},!1]:[e,r,!0]}function Fm(e,t){return em(`(prefers-reduced-motion: reduce)`,e,t)}function Im(){let[e,t]=(0,R.useState)(!1),n=(0,R.useRef)(null),r=(0,R.useCallback)(()=>{t(!0)},[]),i=(0,R.useCallback)(()=>{t(!1)},[]);return{ref:(0,R.useCallback)(e=>(n.current&&(n.current.removeEventListener(`mouseenter`,r),n.current.removeEventListener(`mouseleave`,i)),e&&(e.addEventListener(`mouseenter`,r),e.addEventListener(`mouseleave`,i)),n.current=e,()=>{e&&(e.removeEventListener(`mouseenter`,r),e.removeEventListener(`mouseleave`,i)),n.current===e&&(n.current=null),t(!1)}),[r,i]),hovered:e}}var Lm=[`mouse`,`touch`],Rm=10;function zm(e,t={}){let{threshold:n=400,events:r=Lm,cancelOnMove:i=!1,onStart:a,onFinish:o,onCancel:s}=t,c=(0,R.useRef)(!1),l=(0,R.useRef)(!1),u=(0,R.useRef)(-1),d=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>window.clearTimeout(u.current),[]);let f=r.join(`,`);return(0,R.useMemo)(()=>{if(typeof e!=`function`)return{};let t=i!==!1,f=i===!0?Rm:i===!1?0:i,p=t=>{l.current||!Hm(t)&&!Vm(t)||(a&&a(t),d.current=Bm(t),l.current=!0,u.current=window.setTimeout(()=>{e(t),c.current=!0},n))},m=e=>{(Hm(e)||Vm(e))&&(c.current?o&&o(e):l.current&&s&&s(e),c.current=!1,l.current=!1,d.current=null,u.current!==-1&&(window.clearTimeout(u.current),u.current=-1))},h=e=>{if(!t||!l.current||c.current)return;let n=Bm(e);if(!n||!d.current)return;let r=n.x-d.current.x,i=n.y-d.current.y;Math.sqrt(r*r+i*i)>f&&m(e)},g={};return r.includes(`mouse`)&&(g.onMouseDown=p,g.onMouseUp=m,g.onMouseLeave=m,t&&(g.onMouseMove=h)),r.includes(`touch`)&&(g.onTouchStart=p,g.onTouchEnd=m,g.onTouchCancel=m,t&&(g.onTouchMove=h)),g},[e,n,s,o,a,i,f])}function Bm(e){if(Vm(e)){let t=e.touches[0]??e.changedTouches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function Vm(e){return window.TouchEvent?e.nativeEvent instanceof TouchEvent:`touches`in e.nativeEvent}function Hm(e){return e.nativeEvent instanceof MouseEvent}function Um(e){return e?.props?.ref}function Wm(e){let t=R.Children.toArray(e);return t.length!==1||!Ap(t[0])?null:t[0]}function q(e){return e}function Gm(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t{Object.entries(e).forEach(([e,n])=>{t[e]?t[e]=Km(t[e],n):t[e]=n})}),t}function Ym({theme:e,classNames:t,props:n,stylesCtx:r}){return Jm((Array.isArray(t)?t:[t]).map(t=>typeof t==`function`?t(e,n,r):t||qm))}function Xm({theme:e,styles:t,props:n,stylesCtx:r}){let i=Array.isArray(t)?t:[t],a={};for(let t of i)typeof t==`function`?Object.assign(a,t(e,n,r)):t&&Object.assign(a,t);return a}function Zm(e){return e===`auto`||e===`dark`||e===`light`}function Qm({key:e=`mantine-color-scheme-value`}={}){let t;return{get:t=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return Zm(n)?n:t}catch{return t}},set:t=>{try{window.localStorage.setItem(e,t)}catch(e){console.warn(`[@mantine/core] Local storage color scheme manager was unable to save color scheme.`,e)}},subscribe:n=>{t=t=>{t.storageArea===window.localStorage&&t.key===e&&Zm(t.newValue)&&n(t.newValue)},window.addEventListener(`storage`,t)},unsubscribe:()=>{window.removeEventListener(`storage`,t)},clear:()=>{window.localStorage.removeItem(e)}}}function $m(e,t){return typeof e.primaryShade==`number`?e.primaryShade:t===`dark`?e.primaryShade.dark:e.primaryShade.light}function eh(e){return/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(e)}function th(e){let t=e.replace(`#`,``);if((t.length===3||t.length===4)&&(t=t.split(``).map(e=>e+e).join(``)),t.length===8){let e=parseInt(t.slice(6,8),16)/255;return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16),a:e}}let n=parseInt(t,16);return{r:n>>16&255,g:n>>8&255,b:n&255,a:1}}function nh(e){let[t,n,r,i]=e.replace(/[^0-9,./\s]/g,``).trim().split(/\s*[/,]\s*|\s+/).map(Number);return{r:t,g:n,b:r,a:i===void 0?1:i}}function rh(e){let t=e.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*(,\s*(0?\.\d+|\d+(\.\d+)?))?\s*\)$/i);if(!t)return{r:0,g:0,b:0,a:1};let n=parseInt(t[1],10),r=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,a=t[5]?parseFloat(t[5]):void 0,o=(1-Math.abs(2*i-1))*r,s=n/60,c=o*(1-Math.abs(s%2-1)),l=i-o/2,u,d,f;return s>=0&&s<1?(u=o,d=c,f=0):s>=1&&s<2?(u=c,d=o,f=0):s>=2&&s<3?(u=0,d=o,f=c):s>=3&&s<4?(u=0,d=c,f=o):s>=4&&s<5?(u=c,d=0,f=o):(u=o,d=0,f=c),{r:Math.round((u+l)*255),g:Math.round((d+l)*255),b:Math.round((f+l)*255),a:a===void 0?1:a}}function ih(e){return eh(e)?th(e):e.startsWith(`rgb`)?nh(e):e.startsWith(`hsl`)?rh(e):{r:0,g:0,b:0,a:1}}function ah(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function oh(e){let t=e.match(/oklch\((.*?)%\s/);return t?parseFloat(t[1]):null}function sh(e){if(e.startsWith(`oklch(`))return(oh(e)||0)/100;let{r:t,g:n,b:r}=ih(e),i=t/255,a=n/255,o=r/255,s=ah(i),c=ah(a),l=ah(o);return .2126*s+.7152*c+.0722*l}function ch(e,t=.179){return!e.startsWith(`var(`)&&sh(e)>t}function lh({color:e,theme:t,colorScheme:n}){if(typeof e!=`string`)throw Error(`[@mantine/core] Failed to parse color. Expected color to be a string, instead got ${typeof e}`);if(e===`bright`)return{color:e,value:n===`dark`?t.white:t.black,shade:void 0,isThemeColor:!1,isLight:ch(n===`dark`?t.white:t.black,t.luminanceThreshold),variable:`--mantine-color-bright`};if(e===`dimmed`)return{color:e,value:n===`dark`?t.colors.dark[2]:t.colors.gray[7],shade:void 0,isThemeColor:!1,isLight:ch(n===`dark`?t.colors.dark[2]:t.colors.gray[6],t.luminanceThreshold),variable:`--mantine-color-dimmed`};if(e===`white`||e===`black`)return{color:e,value:e===`white`?t.white:t.black,shade:void 0,isThemeColor:!1,isLight:ch(e===`white`?t.white:t.black,t.luminanceThreshold),variable:`--mantine-color-${e}`};let[r,i]=e.split(`.`),a=i?Number(i):void 0,o=r in t.colors;if(o){let e=a===void 0?t.colors[r][$m(t,n||`light`)]:t.colors[r][a];return{color:r,value:e,shade:a,isThemeColor:o,isLight:ch(e,t.luminanceThreshold),variable:i?`--mantine-color-${r}-${a}`:`--mantine-color-${r}-filled`}}return{color:e,value:e,isThemeColor:o,isLight:ch(e,t.luminanceThreshold),shade:a,variable:void 0}}function uh(e,t){let n=lh({color:e||t.primaryColor,theme:t});return n.variable?`var(${n.variable})`:e}function dh(e){return!!e&&typeof e==`object`&&`mantine-virtual-color`in e}function fh(e,t){if(e.startsWith(`var(`))return`color-mix(in srgb, ${e}, black ${t*100}%)`;let{r:n,g:r,b:i,a}=ih(e),o=1-t,s=e=>Math.round(e*o);return`rgba(${s(n)}, ${s(r)}, ${s(i)}, ${a})`}function ph(e,t){let n={from:e?.from||t.defaultGradient.from,to:e?.to||t.defaultGradient.to,deg:e?.deg??t.defaultGradient.deg??0},r=uh(n.from,t),i=uh(n.to,t);return`linear-gradient(${n.deg}deg, ${r} 0%, ${i} 100%)`}function mh(e,t){if(typeof e!=`string`||t>1||t<0)return`rgba(0, 0, 0, 1)`;if(e.startsWith(`var(`))return`color-mix(in srgb, ${e}, transparent ${(1-t)*100}%)`;if(e.startsWith(`oklch`))return e.includes(`/`)?e.replace(/\/\s*[\d.]+\s*\)/,`/ ${t})`):e.replace(`)`,` / ${t})`);let{r:n,g:r,b:i}=ih(e);return`rgba(${n}, ${r}, ${i}, ${t})`}var hh=mh,gh=({color:e,theme:t,variant:n,gradient:r,autoContrast:i})=>{let a=lh({color:e,theme:t}),o=typeof i==`boolean`?i:t.autoContrast;if(n===`none`)return{background:`transparent`,hover:`transparent`,color:`inherit`,border:`none`};if(n===`filled`){let n=a.isThemeColor&&a.shade===void 0&&dh(t.colors[a.color]),r=o?n?`var(--mantine-color-${a.color}-contrast)`:a.isLight?`var(--mantine-color-black)`:`var(--mantine-color-white)`:`var(--mantine-color-white)`;return a.isThemeColor?a.shade===void 0?{background:`var(--mantine-color-${e}-filled)`,hover:`var(--mantine-color-${e}-filled-hover)`,color:r,border:`${K(1)} solid transparent`}:{background:`var(--mantine-color-${a.color}-${a.shade})`,hover:`var(--mantine-color-${a.color}-${a.shade===9?8:a.shade+1})`,color:r,border:`${K(1)} solid transparent`}:{background:e,hover:fh(e,.1),color:r,border:`${K(1)} solid transparent`}}if(n===`light`){if(a.isThemeColor){if(a.shade===void 0)return{background:`var(--mantine-color-${e}-light)`,hover:`var(--mantine-color-${e}-light-hover)`,color:`var(--mantine-color-${e}-light-color)`,border:`${K(1)} solid transparent`};let n=t.colors[a.color][a.shade];return{background:n,hover:fh(n,.1),color:`var(--mantine-color-${a.color}-light-color)`,border:`${K(1)} solid transparent`}}return{background:mh(e,.1),hover:mh(e,.12),color:e,border:`${K(1)} solid transparent`}}if(n===`outline`)return a.isThemeColor?a.shade===void 0?{background:`transparent`,hover:`var(--mantine-color-${e}-outline-hover)`,color:`var(--mantine-color-${e}-outline)`,border:`${K(1)} solid var(--mantine-color-${e}-outline)`}:{background:`transparent`,hover:mh(t.colors[a.color][a.shade],.05),color:`var(--mantine-color-${a.color}-${a.shade})`,border:`${K(1)} solid var(--mantine-color-${a.color}-${a.shade})`}:{background:`transparent`,hover:mh(e,.05),color:e,border:`${K(1)} solid ${e}`};if(n===`subtle`){if(a.isThemeColor){if(a.shade===void 0)return{background:`transparent`,hover:`var(--mantine-color-${e}-light-hover)`,color:`var(--mantine-color-${e}-light-color)`,border:`${K(1)} solid transparent`};let n=t.colors[a.color][a.shade];return{background:`transparent`,hover:mh(n,.12),color:`var(--mantine-color-${a.color}-${Math.min(a.shade,6)})`,border:`${K(1)} solid transparent`}}return{background:`transparent`,hover:mh(e,.12),color:e,border:`${K(1)} solid transparent`}}return n===`transparent`?a.isThemeColor?a.shade===void 0?{background:`transparent`,hover:`transparent`,color:`var(--mantine-color-${e}-light-color)`,border:`${K(1)} solid transparent`}:{background:`transparent`,hover:`transparent`,color:`var(--mantine-color-${a.color}-${Math.min(a.shade,6)})`,border:`${K(1)} solid transparent`}:{background:`transparent`,hover:`transparent`,color:e,border:`${K(1)} solid transparent`}:n===`white`?a.isThemeColor?a.shade===void 0?{background:`var(--mantine-color-white)`,hover:fh(t.white,.01),color:`var(--mantine-color-${e}-filled)`,border:`${K(1)} solid transparent`}:{background:`var(--mantine-color-white)`,hover:fh(t.white,.01),color:`var(--mantine-color-${a.color}-${a.shade})`,border:`${K(1)} solid transparent`}:{background:`var(--mantine-color-white)`,hover:fh(t.white,.01),color:e,border:`${K(1)} solid transparent`}:n===`gradient`?{background:ph(r,t),hover:ph(r,t),color:`var(--mantine-color-white)`,border:`none`}:n==="default"?{background:`var(--mantine-color-default)`,hover:`var(--mantine-color-default-hover)`,color:`var(--mantine-color-default-color)`,border:`${K(1)} solid var(--mantine-color-default-border)`}:{}};function _h({color:e,theme:t,autoContrast:n,colorScheme:r}){return(typeof n==`boolean`?n:t.autoContrast)&&lh({color:e||t.primaryColor,theme:t,colorScheme:r}).isLight?`var(--mantine-color-black)`:`var(--mantine-color-white)`}function vh(e,t,n){return _h({color:n===`dark`?e.dark:e.light,theme:t,colorScheme:n,autoContrast:!0})}function yh(e,t){let n=e.colors[e.primaryColor];return dh(n)?e.autoContrast?vh(n,e,t):`var(--mantine-color-white)`:_h({color:n[$m(e,t)],theme:e,autoContrast:null})}function bh(e,t){return typeof e==`boolean`?e:t.autoContrast}var xh=(0,R.createContext)(null);function Sh(){let e=(0,R.use)(xh);if(!e)throw Error(`[@mantine/core] MantineProvider was not found in tree`);return e}function Ch(){return Sh().cssVariablesResolver}function wh(){return Sh().classNamesPrefix}function Th(){return Sh().getStyleNonce}function Eh(){return Sh().withStaticClasses}function Dh(){return Sh().headless}function Oh(){return Sh().stylesTransform?.sx}function kh(){return Sh().stylesTransform?.styles}function Ah(){return Sh().env||`default`}function jh(){return Sh().deduplicateInlineStyles}function Mh(e,t){let n=typeof window<`u`&&`matchMedia`in window&&window.matchMedia(`(prefers-color-scheme: dark)`)?.matches,r=e===`auto`?n?`dark`:`light`:e;t()?.setAttribute(`data-mantine-color-scheme`,r)}function Nh({manager:e,defaultColorScheme:t,getRootElement:n,forceColorScheme:r}){let i=(0,R.useRef)(null),[a,o]=(0,R.useState)(()=>e.get(t)),s=r||a,c=(0,R.useCallback)(t=>{r||(Mh(t,n),o(t),e.set(t))},[e.set,s,r]),l=(0,R.useCallback)(()=>{o(t),Mh(t,n),e.clear()},[e.clear,t]);return(0,R.useEffect)(()=>(e.subscribe(c),e.unsubscribe),[e.subscribe,e.unsubscribe]),tm(()=>{Mh(e.get(t),n)},[]),(0,R.useEffect)(()=>{if(r)return Mh(r,n),()=>{};r===void 0&&Mh(a,n),typeof window<`u`&&`matchMedia`in window&&(i.current=window.matchMedia(`(prefers-color-scheme: dark)`));let e=e=>{a===`auto`&&Mh(e.matches?`dark`:`light`,n)};return i.current?.addEventListener(`change`,e),()=>i.current?.removeEventListener(`change`,e)},[a,r]),{colorScheme:s,setColorScheme:c,clearColorScheme:l}}var Ph={dark:[`#C9C9C9`,`#b8b8b8`,`#828282`,`#696969`,`#424242`,`#3b3b3b`,`#2e2e2e`,`#242424`,`#1f1f1f`,`#141414`],gray:[`#f8f9fa`,`#f1f3f5`,`#e9ecef`,`#dee2e6`,`#ced4da`,`#adb5bd`,`#868e96`,`#495057`,`#343a40`,`#212529`],red:[`#fff5f5`,`#ffe3e3`,`#ffc9c9`,`#ffa8a8`,`#ff8787`,`#ff6b6b`,`#fa5252`,`#f03e3e`,`#e03131`,`#c92a2a`],pink:[`#fff0f6`,`#ffdeeb`,`#fcc2d7`,`#faa2c1`,`#f783ac`,`#f06595`,`#e64980`,`#d6336c`,`#c2255c`,`#a61e4d`],grape:[`#f8f0fc`,`#f3d9fa`,`#eebefa`,`#e599f7`,`#da77f2`,`#cc5de8`,`#be4bdb`,`#ae3ec9`,`#9c36b5`,`#862e9c`],violet:[`#f3f0ff`,`#e5dbff`,`#d0bfff`,`#b197fc`,`#9775fa`,`#845ef7`,`#7950f2`,`#7048e8`,`#6741d9`,`#5f3dc4`],indigo:[`#edf2ff`,`#dbe4ff`,`#bac8ff`,`#91a7ff`,`#748ffc`,`#5c7cfa`,`#4c6ef5`,`#4263eb`,`#3b5bdb`,`#364fc7`],blue:[`#e7f5ff`,`#d0ebff`,`#a5d8ff`,`#74c0fc`,`#4dabf7`,`#339af0`,`#228be6`,`#1c7ed6`,`#1971c2`,`#1864ab`],cyan:[`#e3fafc`,`#c5f6fa`,`#99e9f2`,`#66d9e8`,`#3bc9db`,`#22b8cf`,`#15aabf`,`#1098ad`,`#0c8599`,`#0b7285`],teal:[`#e6fcf5`,`#c3fae8`,`#96f2d7`,`#63e6be`,`#38d9a9`,`#20c997`,`#12b886`,`#0ca678`,`#099268`,`#087f5b`],green:[`#ebfbee`,`#d3f9d8`,`#b2f2bb`,`#8ce99a`,`#69db7c`,`#51cf66`,`#40c057`,`#37b24d`,`#2f9e44`,`#2b8a3e`],lime:[`#f4fce3`,`#e9fac8`,`#d8f5a2`,`#c0eb75`,`#a9e34b`,`#94d82d`,`#82c91e`,`#74b816`,`#66a80f`,`#5c940d`],yellow:[`#fff9db`,`#fff3bf`,`#ffec99`,`#ffe066`,`#ffd43b`,`#fcc419`,`#fab005`,`#f59f00`,`#f08c00`,`#e67700`],orange:[`#fff4e6`,`#ffe8cc`,`#ffd8a8`,`#ffc078`,`#ffa94d`,`#ff922b`,`#fd7e14`,`#f76707`,`#e8590c`,`#d9480f`]},Fh=`-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji`,Ih={scale:1,fontSmoothing:!0,focusRing:`auto`,white:`#fff`,black:`#000`,colors:Ph,primaryShade:{light:6,dark:8},primaryColor:`blue`,variantColorResolver:gh,autoContrast:!1,luminanceThreshold:.3,fontFamily:Fh,fontFamilyMonospace:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace`,respectReducedMotion:!1,cursorType:`default`,defaultGradient:{from:`blue`,to:`cyan`,deg:45},defaultRadius:`md`,activeClassName:`mantine-active`,focusClassName:``,headings:{fontFamily:Fh,fontWeight:`700`,textWrap:`wrap`,sizes:{h1:{fontSize:K(34),lineHeight:`1.3`},h2:{fontSize:K(26),lineHeight:`1.35`},h3:{fontSize:K(22),lineHeight:`1.4`},h4:{fontSize:K(18),lineHeight:`1.45`},h5:{fontSize:K(16),lineHeight:`1.5`},h6:{fontSize:K(14),lineHeight:`1.5`}}},fontSizes:{xs:K(12),sm:K(14),md:K(16),lg:K(18),xl:K(20)},lineHeights:{xs:`1.4`,sm:`1.45`,md:`1.55`,lg:`1.6`,xl:`1.65`},fontWeights:{regular:`400`,medium:`600`,bold:`700`},radius:{xs:K(2),sm:K(4),md:K(8),lg:K(16),xl:K(32)},spacing:{xs:K(10),sm:K(12),md:K(16),lg:K(20),xl:K(32)},breakpoints:{xs:`36em`,sm:`48em`,md:`62em`,lg:`75em`,xl:`88em`},shadows:{xs:`0 ${K(1)} ${K(3)} rgba(0, 0, 0, 0.05), 0 ${K(1)} ${K(2)} rgba(0, 0, 0, 0.1)`,sm:`0 ${K(1)} ${K(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${K(10)} ${K(15)} ${K(-5)}, rgba(0, 0, 0, 0.04) 0 ${K(7)} ${K(7)} ${K(-5)}`,md:`0 ${K(1)} ${K(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${K(20)} ${K(25)} ${K(-5)}, rgba(0, 0, 0, 0.04) 0 ${K(10)} ${K(10)} ${K(-5)}`,lg:`0 ${K(1)} ${K(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${K(28)} ${K(23)} ${K(-7)}, rgba(0, 0, 0, 0.04) 0 ${K(12)} ${K(12)} ${K(-7)}`,xl:`0 ${K(1)} ${K(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${K(36)} ${K(28)} ${K(-7)}, rgba(0, 0, 0, 0.04) 0 ${K(17)} ${K(17)} ${K(-7)}`},other:{},components:{}},Lh=`[@mantine/core] MantineProvider: Invalid theme.primaryColor, it accepts only key of theme.colors, learn more – https://mantine.dev/theming/colors/#primary-color`,Rh=`[@mantine/core] MantineProvider: Invalid theme.primaryShade, it accepts only 0-9 integers or an object { light: 0-9, dark: 0-9 }`;function zh(e){return e<0||e>9?!1:parseInt(e.toString(),10)===e}function Bh(e){if(!(e.primaryColor in e.colors))throw Error(Lh);if(typeof e.primaryShade==`object`&&(!zh(e.primaryShade.dark)||!zh(e.primaryShade.light))||typeof e.primaryShade==`number`&&!zh(e.primaryShade))throw Error(Rh)}function Vh(e,t){if(!t)return Bh(e),e;let n=xp(e,t);return t.fontFamily&&!t.headings?.fontFamily&&(n.headings={...n.headings,fontFamily:t.fontFamily}),Bh(n),n}var Hh=(0,R.createContext)(null),Uh=()=>(0,R.use)(Hh)||Ih;function Wh(){let e=(0,R.use)(Hh);if(!e)throw Error(`@mantine/core: MantineProvider was not found in component tree, make sure you have it in your app`);return e}function Gh({theme:e,children:t,inherit:n=!0}){let r=Uh(),i=(0,R.useMemo)(()=>Vh(n?r:Ih,e),[e,r,n]);return(0,z.jsx)(Hh,{value:i,children:t})}Gh.displayName=`@mantine/core/MantineThemeProvider`;function Kh(e){return Object.entries(e).map(([e,t])=>`${e}: ${t};`).join(``)}function qh(e,t){let n=t?[t]:[`:root`,`:host`],r=Kh(e.variables),i=r?`${n.join(`, `)}{${r}}`:``,a=Kh(e.dark),o=Kh(e.light),s=e=>n.map(t=>t===`:host`?`${t}([data-mantine-color-scheme="${e}"])`:`${t}[data-mantine-color-scheme="${e}"]`).join(`, `);return`${i}\n\n${a?`${s(`dark`)}{${a}}`:``}\n\n${o?`${s(`light`)}{${o}}`:``}`}function Jh({theme:e,color:t,colorScheme:n,name:r=t,withColorValues:i=!0}){if(!e.colors[t])return{};if(n===`light`){let n=$m(e,`light`),a={[`--mantine-color-${r}-text`]:`var(--mantine-color-${r}-filled)`,[`--mantine-color-${r}-filled`]:`var(--mantine-color-${r}-${n})`,[`--mantine-color-${r}-filled-hover`]:`var(--mantine-color-${r}-${n===9?8:n+1})`,[`--mantine-color-${r}-light`]:`var(--mantine-color-${r}-1)`,[`--mantine-color-${r}-light-hover`]:`var(--mantine-color-${r}-2)`,[`--mantine-color-${r}-light-color`]:`var(--mantine-color-${r}-9)`,[`--mantine-color-${r}-outline`]:`var(--mantine-color-${r}-${n})`,[`--mantine-color-${r}-outline-hover`]:hh(e.colors[t][n],.05)};return i?{[`--mantine-color-${r}-0`]:e.colors[t][0],[`--mantine-color-${r}-1`]:e.colors[t][1],[`--mantine-color-${r}-2`]:e.colors[t][2],[`--mantine-color-${r}-3`]:e.colors[t][3],[`--mantine-color-${r}-4`]:e.colors[t][4],[`--mantine-color-${r}-5`]:e.colors[t][5],[`--mantine-color-${r}-6`]:e.colors[t][6],[`--mantine-color-${r}-7`]:e.colors[t][7],[`--mantine-color-${r}-8`]:e.colors[t][8],[`--mantine-color-${r}-9`]:e.colors[t][9],...a}:a}let a=$m(e,`dark`),o={[`--mantine-color-${r}-text`]:`var(--mantine-color-${r}-4)`,[`--mantine-color-${r}-filled`]:`var(--mantine-color-${r}-${a})`,[`--mantine-color-${r}-filled-hover`]:`var(--mantine-color-${r}-${a===9?8:a+1})`,[`--mantine-color-${r}-light`]:fh(e.colors[t][9],.5),[`--mantine-color-${r}-light-hover`]:fh(e.colors[t][9],.3),[`--mantine-color-${r}-light-color`]:`var(--mantine-color-${r}-0)`,[`--mantine-color-${r}-outline`]:`var(--mantine-color-${r}-${Math.max(a-4,0)})`,[`--mantine-color-${r}-outline-hover`]:hh(e.colors[t][Math.max(a-4,0)],.05)};return i?{[`--mantine-color-${r}-0`]:e.colors[t][0],[`--mantine-color-${r}-1`]:e.colors[t][1],[`--mantine-color-${r}-2`]:e.colors[t][2],[`--mantine-color-${r}-3`]:e.colors[t][3],[`--mantine-color-${r}-4`]:e.colors[t][4],[`--mantine-color-${r}-5`]:e.colors[t][5],[`--mantine-color-${r}-6`]:e.colors[t][6],[`--mantine-color-${r}-7`]:e.colors[t][7],[`--mantine-color-${r}-8`]:e.colors[t][8],[`--mantine-color-${r}-9`]:e.colors[t][9],...o}:o}function Yh(e,t,n){yp(t).forEach(r=>Object.assign(e,{[`--mantine-${n}-${r}`]:t[r]}))}var Xh=e=>{let t=$m(e,`light`),n=e.defaultRadius in e.radius?e.radius[e.defaultRadius]:K(e.defaultRadius),r={variables:{"--mantine-z-index-app":`100`,"--mantine-z-index-modal":`200`,"--mantine-z-index-popover":`300`,"--mantine-z-index-overlay":`400`,"--mantine-z-index-max":`9999`,"--mantine-scale":e.scale.toString(),"--mantine-cursor-type":e.cursorType,"--mantine-webkit-font-smoothing":e.fontSmoothing?`antialiased`:`unset`,"--mantine-moz-font-smoothing":e.fontSmoothing?`grayscale`:`unset`,"--mantine-color-white":e.white,"--mantine-color-black":e.black,"--mantine-line-height":e.lineHeights.md,"--mantine-font-family":e.fontFamily,"--mantine-font-family-monospace":e.fontFamilyMonospace,"--mantine-font-family-headings":e.headings.fontFamily,"--mantine-heading-font-weight":e.headings.fontWeight,"--mantine-heading-text-wrap":e.headings.textWrap,"--mantine-radius-default":n,"--mantine-primary-color-filled":`var(--mantine-color-${e.primaryColor}-filled)`,"--mantine-primary-color-filled-hover":`var(--mantine-color-${e.primaryColor}-filled-hover)`,"--mantine-primary-color-light":`var(--mantine-color-${e.primaryColor}-light)`,"--mantine-primary-color-light-hover":`var(--mantine-color-${e.primaryColor}-light-hover)`,"--mantine-primary-color-light-color":`var(--mantine-color-${e.primaryColor}-light-color)`},light:{"--mantine-color-scheme":`light`,"--mantine-primary-color-contrast":yh(e,`light`),"--mantine-color-bright":`var(--mantine-color-black)`,"--mantine-color-text":e.black,"--mantine-color-body":e.white,"--mantine-color-error":`var(--mantine-color-red-6)`,"--mantine-color-success":`var(--mantine-color-teal-8)`,"--mantine-color-placeholder":`var(--mantine-color-gray-5)`,"--mantine-color-anchor":`var(--mantine-color-${e.primaryColor}-${t})`,"--mantine-color-default":`var(--mantine-color-white)`,"--mantine-color-default-hover":`var(--mantine-color-gray-0)`,"--mantine-color-default-color":`var(--mantine-color-black)`,"--mantine-color-default-border":`var(--mantine-color-gray-4)`,"--mantine-color-dimmed":`var(--mantine-color-gray-6)`,"--mantine-color-disabled":`var(--mantine-color-gray-2)`,"--mantine-color-disabled-color":`var(--mantine-color-gray-5)`,"--mantine-color-disabled-border":`var(--mantine-color-gray-3)`},dark:{"--mantine-color-scheme":`dark`,"--mantine-primary-color-contrast":yh(e,`dark`),"--mantine-color-bright":`var(--mantine-color-white)`,"--mantine-color-text":`var(--mantine-color-dark-0)`,"--mantine-color-body":`var(--mantine-color-dark-7)`,"--mantine-color-error":`var(--mantine-color-red-8)`,"--mantine-color-success":`var(--mantine-color-teal-8)`,"--mantine-color-placeholder":`var(--mantine-color-dark-3)`,"--mantine-color-anchor":`var(--mantine-color-${e.primaryColor}-4)`,"--mantine-color-default":`var(--mantine-color-dark-6)`,"--mantine-color-default-hover":`var(--mantine-color-dark-5)`,"--mantine-color-default-color":`var(--mantine-color-white)`,"--mantine-color-default-border":`var(--mantine-color-dark-4)`,"--mantine-color-dimmed":`var(--mantine-color-dark-2)`,"--mantine-color-disabled":`var(--mantine-color-dark-6)`,"--mantine-color-disabled-color":`var(--mantine-color-dark-3)`,"--mantine-color-disabled-border":`var(--mantine-color-dark-4)`}};Yh(r.variables,e.breakpoints,`breakpoint`),Yh(r.variables,e.spacing,`spacing`),Yh(r.variables,e.fontSizes,`font-size`),Yh(r.variables,e.lineHeights,`line-height`),Yh(r.variables,e.shadows,`shadow`),Yh(r.variables,e.radius,`radius`),Yh(r.variables,e.fontWeights,`font-weight`),e.colors[e.primaryColor].forEach((t,n)=>{r.variables[`--mantine-primary-color-${n}`]=`var(--mantine-color-${e.primaryColor}-${n})`}),yp(e.colors).forEach(t=>{let n=e.colors[t];dh(n)?(Object.assign(r.light,Jh({theme:e,name:n.name,color:n.light,colorScheme:`light`,withColorValues:!0})),Object.assign(r.dark,Jh({theme:e,name:n.name,color:n.dark,colorScheme:`dark`,withColorValues:!0})),r.light[`--mantine-color-${n.name}-contrast`]=vh(n,e,`light`),r.dark[`--mantine-color-${n.name}-contrast`]=vh(n,e,`dark`)):(n.forEach((e,n)=>{r.variables[`--mantine-color-${t}-${n}`]=e}),Object.assign(r.light,Jh({theme:e,color:t,colorScheme:`light`,withColorValues:!1})),Object.assign(r.dark,Jh({theme:e,color:t,colorScheme:`dark`,withColorValues:!1})))});let i=e.headings.sizes;return yp(i).forEach(t=>{r.variables[`--mantine-${t}-font-size`]=i[t].fontSize,r.variables[`--mantine-${t}-line-height`]=i[t].lineHeight,r.variables[`--mantine-${t}-font-weight`]=i[t].fontWeight||e.headings.fontWeight}),r};function Zh(){let e=Wh(),t=Th(),n=yp(e.breakpoints).reduce((t,n)=>{let r=e.breakpoints[n].includes(`px`),i=wp(e.breakpoints[n]);return`${t}@media (max-width: ${r?`${i-.1}px`:Dp(i-.1)}) {.mantine-visible-from-${n} {display: none !important;}}@media (min-width: ${r?`${i}px`:Dp(i)}) {.mantine-hidden-from-${n} {display: none !important;}}`},``);return(0,z.jsx)(`style`,{"data-mantine-styles":`classes`,nonce:t?.(),dangerouslySetInnerHTML:{__html:n}})}function Qh({theme:e,generator:t}){let n=Xh(e),r=t?.(e);return r?xp(n,r):n}var $h=Xh(Ih);function eg(e){let t={variables:{},light:{},dark:{}};return yp(e.variables).forEach(n=>{$h.variables[n]!==e.variables[n]&&(t.variables[n]=e.variables[n])}),yp(e.light).forEach(n=>{$h.light[n]!==e.light[n]&&(t.light[n]=e.light[n])}),yp(e.dark).forEach(n=>{$h.dark[n]!==e.dark[n]&&(t.dark[n]=e.dark[n])}),t}function tg(e){return qh({variables:{},dark:{"--mantine-color-scheme":`dark`},light:{"--mantine-color-scheme":`light`}},e)}function ng({cssVariablesSelector:e,deduplicateCssVariables:t}){let n=Wh(),r=Th(),i=Qh({theme:n,generator:Ch()}),a=(e===void 0||e===`:root`||e===`:host`)&&t,o=qh(a?eg(i):i,e);return o?(0,z.jsx)(`style`,{"data-mantine-styles":!0,nonce:r?.(),dangerouslySetInnerHTML:{__html:`${o}${a?``:tg(e)}`}}):null}ng.displayName=`@mantine/CssVariables`;function rg({respectReducedMotion:e,getRootElement:t}){tm(()=>{e&&t()?.setAttribute(`data-respect-reduced-motion`,`true`)},[e])}function ig({theme:e,children:t,getStyleNonce:n,withStaticClasses:r=!0,withGlobalClasses:i=!0,deduplicateCssVariables:a=!0,withCssVariables:o=!0,cssVariablesSelector:s,classNamesPrefix:c=`mantine`,colorSchemeManager:l=Qm(),defaultColorScheme:u=`light`,getRootElement:d=()=>document.documentElement,cssVariablesResolver:f,forceColorScheme:p,stylesTransform:m,env:h,deduplicateInlineStyles:g=!1}){let{colorScheme:_,setColorScheme:v,clearColorScheme:y}=Nh({defaultColorScheme:u,forceColorScheme:p,manager:l,getRootElement:d});return rg({respectReducedMotion:e?.respectReducedMotion||!1,getRootElement:d}),(0,z.jsx)(xh,{value:{colorScheme:_,setColorScheme:v,clearColorScheme:y,getRootElement:d,classNamesPrefix:c,getStyleNonce:n,cssVariablesResolver:f,cssVariablesSelector:s??`:root`,withStaticClasses:r,stylesTransform:m,env:h,deduplicateInlineStyles:g},children:(0,z.jsxs)(Gh,{theme:e,children:[o&&(0,z.jsx)(ng,{cssVariablesSelector:s,deduplicateCssVariables:a}),i&&(0,z.jsx)(Zh,{}),t]})})}ig.displayName=`@mantine/core/MantineProvider`;function J(e,t,n){let r=Wh(),i=(Array.isArray(e)?e:[e]).filter(Boolean),a={};for(let e of i){let t=r.components[e]?.defaultProps,n=typeof t==`function`?t(r):t;n&&(a={...a,...n})}return{...t,...a,...Op(n)}}function ag({classNames:e,styles:t,props:n,stylesCtx:r}){let i=Wh();return{resolvedClassNames:e===void 0?void 0:Ym({theme:i,classNames:e,props:n,stylesCtx:r||void 0}),resolvedStyles:t===void 0?void 0:Xm({theme:i,styles:t,props:n,stylesCtx:r||void 0})}}var og={always:`mantine-focus-always`,auto:`mantine-focus-auto`,never:`mantine-focus-never`};function sg({theme:e,options:t,unstyled:n}){return Km(t?.focusable&&!n&&(e.focusClassName||og[e.focusRing]),t?.active&&!n&&e.activeClassName)}function cg(e,t,n=1){if(Object.is(e,t))return!0;if(n===0||typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r`${t}-${e}-${n}`)}function mg({options:e,classes:t,selector:n,unstyled:r}){return e?.variant&&!r?t[`${n}--${e.variant}`]:void 0}function hg({theme:e,options:t,themeName:n,selector:r,classNamesPrefix:i,resolvedClassNames:a,resolvedThemeClassNames:o,classes:s,unstyled:c,className:l,rootSelector:u,props:d,stylesCtx:f,withStaticClasses:p,headless:m,transformedStyles:h}){return Km(sg({theme:e,options:t,unstyled:c||m}),o.map(e=>e[r]),mg({options:t,classes:s,selector:r,unstyled:c||m}),a[r],ug({selector:r,stylesCtx:f,theme:e,classNames:h,props:d}),lg({selector:r,stylesCtx:f,options:t,props:d,theme:e}),dg({rootSelector:u,selector:r,className:l}),fg({selector:r,classes:s,unstyled:c||m}),p&&!m&&pg({themeName:n,classNamesPrefix:i,selector:r,withStaticClass:t?.withStaticClass}),t?.className)}function gg({style:e,theme:t}){return Array.isArray(e)?e.reduce((e,n)=>({...e,...gg({style:n,theme:t})}),{}):typeof e==`function`?e(t):e??{}}function _g({theme:e,selector:t,options:n,props:r,stylesCtx:i,rootSelector:a,withStylesTransform:o,resolvedStyles:s,resolvedThemeStyles:c,resolvedVars:l,resolvedRootStyle:u}){return{...c[t],...s[t],...!o&&Xm({theme:e,styles:n?.styles,props:n?.props||r,stylesCtx:i})[t],...l[t],...a===t?u:null,...gg({style:n?.style,theme:e})}}function vg(e){return e.reduce((e,t)=>(t&&Object.keys(t).forEach(n=>{e[n]={...e[n],...Op(t[n])}}),e),{})}function yg({props:e,stylesCtx:t,themeName:n,theme:r}){let i=kh()?.();return{getTransformedStyles:a=>i?[...a.map(n=>i(n,{props:e,theme:r,ctx:t})),...n.map(n=>i(r.components[n]?.styles,{props:e,theme:r,ctx:t}))].filter(Boolean):[],withStylesTransform:!!i}}function Y({name:e,classes:t,props:n,stylesCtx:r,className:i,style:a,rootSelector:o=`root`,unstyled:s,classNames:c,styles:l,vars:u,varsResolver:d,attributes:f,stable:p}){let m=Wh(),h=wh(),g=Eh(),_=Dh(),v=(Array.isArray(e)?e:[e]).filter(e=>e),{withStylesTransform:y,getTransformedStyles:b}=yg({props:n,stylesCtx:r,themeName:v,theme:m}),x=Ym({theme:m,classNames:c,props:n,stylesCtx:r}),S=v.map(e=>Ym({theme:m,classNames:m.components[e]?.classNames,props:n,stylesCtx:r})),C=y?{}:Xm({theme:m,styles:l,props:n,stylesCtx:r}),w={};if(!y)for(let e of v){let t=Xm({theme:m,styles:m.components[e]?.styles,props:n,stylesCtx:r});for(let e of Object.keys(t))w[e]={...w[e],...t[e]}}let T=vg([_?{}:d?.(m,n,r),...v.map(e=>m.components?.[e]?.vars?.(m,n,r)),u?.(m,n,r)]),E=gg({style:a,theme:m});return bg((e,a)=>({...f?.[e],className:hg({theme:m,options:a,themeName:v,selector:e,classNamesPrefix:h,resolvedClassNames:x,resolvedThemeClassNames:S,classes:t,unstyled:s,className:i,rootSelector:o,props:n,stylesCtx:r,withStaticClasses:g,headless:_,transformedStyles:b([a?.styles,l])}),style:_g({theme:m,selector:e,options:a,props:n,stylesCtx:r,rootSelector:o,withStylesTransform:y,resolvedStyles:C,resolvedThemeStyles:w,resolvedVars:T,resolvedRootStyle:E})}),!!p,[m,h,g,_,y?n:null,t,s,i,o,f,r,x,S,C,w,T,E])}function bg(e,t,n){let r=(0,R.useRef)(null);return t?(r.current&&cg(r.current.deps,n,3)||(r.current={deps:n,getStyles:e}),r.current.getStyles):e}function xg(e){return yp(e).reduce((t,n)=>e[n]===void 0?t:`${t}${Sp(n)}:${e[n]};`,``).trim()}function Sg({selector:e,styles:t,media:n,container:r}){let i=t?xg(t):``,a=Array.isArray(n)?n.map(t=>`@media${t.query}{${e}{${xg(t.styles)}}}`):[],o=Array.isArray(r)?r.map(t=>`@container ${t.query}{${e}{${xg(t.styles)}}}`):[];return`${i?`${e}{${i}}`:``}${a.join(``)}${o.join(``)}`.trim()}function Cg(e){let t=5381;for(let n=0;n>>0).toString(36)}function wg({deduplicate:e,...t}){let n=Th(),r=Sg(t);return e?(0,z.jsx)(`style`,{href:`mantine-${Cg(r)}`,precedence:`mantine`,nonce:n?.(),children:r}):(0,z.jsx)(`style`,{"data-mantine-styles":`inline`,nonce:n?.(),dangerouslySetInnerHTML:{__html:r}})}function Tg(e){let t=5381;for(let n=0;n>>0).toString(36)}function Eg(e,t){return`__mdi__-${Tg(`${e?xg(e):``}|${Array.isArray(t)?t.map(e=>`${e.query}:${xg(e.styles)}`).join(`|`):``}`)}`}function Dg(e){let{m:t,mx:n,my:r,mt:i,mb:a,ml:o,mr:s,me:c,ms:l,mis:u,mie:d,p:f,px:p,py:m,pt:h,pb:g,pl:_,pr:v,pe:y,ps:b,pis:x,pie:S,bd:C,bdrs:w,bg:T,c:E,opacity:D,ff:O,fz:k,fw:A,lts:j,ta:M,lh:N,fs:P,tt:ee,td:te,w:ne,miw:re,maw:F,h:ie,mih:ae,mah:oe,bgsz:se,bgp:I,bgr:ce,bga:le,pos:ue,top:de,left:fe,bottom:L,right:pe,inset:me,display:he,flex:ge,hiddenFrom:_e,visibleFrom:ve,lightHidden:ye,darkHidden:be,sx:xe,...Se}=e;return{styleProps:Op({m:t,mx:n,my:r,mt:i,mb:a,ml:o,mr:s,me:c,ms:l,mis:u,mie:d,p:f,px:p,py:m,pt:h,pb:g,pl:_,pr:v,pis:x,pie:S,pe:y,ps:b,bd:C,bg:T,c:E,opacity:D,ff:O,fz:k,fw:A,lts:j,ta:M,lh:N,fs:P,tt:ee,td:te,w:ne,miw:re,maw:F,h:ie,mih:ae,mah:oe,bgsz:se,bgp:I,bgr:ce,bga:le,pos:ue,top:de,left:fe,bottom:L,right:pe,inset:me,display:he,flex:ge,bdrs:w,hiddenFrom:_e,visibleFrom:ve,lightHidden:ye,darkHidden:be,sx:xe}),rest:Se}}var Og={m:{type:`spacing`,property:`margin`},mt:{type:`spacing`,property:`marginTop`},mb:{type:`spacing`,property:`marginBottom`},ml:{type:`spacing`,property:`marginLeft`},mr:{type:`spacing`,property:`marginRight`},ms:{type:`spacing`,property:`marginInlineStart`},me:{type:`spacing`,property:`marginInlineEnd`},mis:{type:`spacing`,property:`marginInlineStart`},mie:{type:`spacing`,property:`marginInlineEnd`},mx:{type:`spacing`,property:`marginInline`},my:{type:`spacing`,property:`marginBlock`},p:{type:`spacing`,property:`padding`},pt:{type:`spacing`,property:`paddingTop`},pb:{type:`spacing`,property:`paddingBottom`},pl:{type:`spacing`,property:`paddingLeft`},pr:{type:`spacing`,property:`paddingRight`},ps:{type:`spacing`,property:`paddingInlineStart`},pe:{type:`spacing`,property:`paddingInlineEnd`},pis:{type:`spacing`,property:`paddingInlineStart`},pie:{type:`spacing`,property:`paddingInlineEnd`},px:{type:`spacing`,property:`paddingInline`},py:{type:`spacing`,property:`paddingBlock`},bd:{type:`border`,property:`border`},bdrs:{type:`radius`,property:`borderRadius`},bg:{type:`color`,property:`background`},c:{type:`textColor`,property:`color`},opacity:{type:`identity`,property:`opacity`},ff:{type:`fontFamily`,property:`fontFamily`},fz:{type:`fontSize`,property:`fontSize`},fw:{type:`identity`,property:`fontWeight`},lts:{type:`size`,property:`letterSpacing`},ta:{type:`identity`,property:`textAlign`},lh:{type:`lineHeight`,property:`lineHeight`},fs:{type:`identity`,property:`fontStyle`},tt:{type:`identity`,property:`textTransform`},td:{type:`identity`,property:`textDecoration`},w:{type:`spacing`,property:`width`},miw:{type:`spacing`,property:`minWidth`},maw:{type:`spacing`,property:`maxWidth`},h:{type:`spacing`,property:`height`},mih:{type:`spacing`,property:`minHeight`},mah:{type:`spacing`,property:`maxHeight`},bgsz:{type:`size`,property:`backgroundSize`},bgp:{type:`identity`,property:`backgroundPosition`},bgr:{type:`identity`,property:`backgroundRepeat`},bga:{type:`identity`,property:`backgroundAttachment`},pos:{type:`identity`,property:`position`},top:{type:`size`,property:`top`},left:{type:`size`,property:`left`},bottom:{type:`size`,property:`bottom`},right:{type:`size`,property:`right`},inset:{type:`size`,property:`inset`},display:{type:`identity`,property:`display`},flex:{type:`identity`,property:`flex`}};function kg(e,t){let n=lh({color:e,theme:t});return n.color===`dimmed`?`var(--mantine-color-dimmed)`:n.color===`bright`?`var(--mantine-color-bright)`:n.variable?`var(${n.variable})`:n.color}function Ag(e,t){let n=lh({color:e,theme:t});return n.isThemeColor&&n.shade===void 0?`var(--mantine-color-${n.color}-text)`:kg(e,t)}function jg(e,t){if(typeof e==`number`)return K(e);if(typeof e==`string`){let[n,r,...i]=e.split(` `).filter(e=>e.trim()!==``),a=`${K(n)}`;return r&&(a+=` ${r}`),i.length>0&&(a+=` ${kg(i.join(` `),t)}`),a.trim()}return e}var Mg={text:`var(--mantine-font-family)`,mono:`var(--mantine-font-family-monospace)`,monospace:`var(--mantine-font-family-monospace)`,heading:`var(--mantine-font-family-headings)`,headings:`var(--mantine-font-family-headings)`};function Ng(e){return typeof e==`string`&&e in Mg?Mg[e]:e}var Pg=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function Fg(e,t){return typeof e==`string`&&e in t.fontSizes?`var(--mantine-font-size-${e})`:typeof e==`string`&&Pg.includes(e)?`var(--mantine-${e}-font-size)`:typeof e==`number`||typeof e==`string`?K(e):e}function Ig(e){return e}var Lg=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function Rg(e,t){return typeof e==`string`&&e in t.lineHeights?`var(--mantine-line-height-${e})`:typeof e==`string`&&Lg.includes(e)?`var(--mantine-${e}-line-height)`:e}function zg(e,t){return typeof e==`string`&&e in t.radius?`var(--mantine-radius-${e})`:typeof e==`number`||typeof e==`string`?K(e):e}function Bg(e){return typeof e==`number`?K(e):e}function Vg(e,t){if(typeof e==`number`)return K(e);if(typeof e==`string`){let n=e.replace(`-`,``);if(!(n in t.spacing))return K(e);let r=`--mantine-spacing-${n}`;return e.startsWith(`-`)?`calc(var(${r}) * -1)`:`var(${r})`}return e}var Hg={color:kg,textColor:Ag,fontSize:Fg,spacing:Vg,radius:zg,identity:Ig,size:Bg,lineHeight:Rg,fontFamily:Ng,border:jg};function Ug(e){return e.replace(`(min-width: `,``).replace(`em)`,``)}function Wg({media:e,...t}){let n=Object.keys(e).sort((e,t)=>Number(Ug(e))-Number(Ug(t))).map(t=>({query:t,styles:e[t]}));return{...t,media:n}}function Gg(e){if(typeof e!=`object`||!e)return!1;let t=Object.keys(e);return t.length!==1||t[0]!==`base`}function Kg(e){return typeof e==`object`&&e?`base`in e?e.base:void 0:e}function qg(e){return typeof e==`object`&&e?yp(e).filter(e=>e!==`base`):[]}function Jg(e,t){return typeof e==`object`&&e&&t in e?e[t]:e}function Yg({styleProps:e,data:t,theme:n}){return Wg(yp(e).reduce((r,i)=>{if(i===`hiddenFrom`||i===`visibleFrom`||i===`sx`)return r;let a=t[i],o=Array.isArray(a.property)?a.property:[a.property],s=Kg(e[i]);if(!Gg(e[i]))return o.forEach(e=>{r.inlineStyles[e]=Hg[a.type](s,n)}),r;r.hasResponsiveStyles=!0;let c=qg(e[i]);return o.forEach(t=>{s!=null&&(r.styles[t]=Hg[a.type](s,n)),c.forEach(o=>{let s=`(min-width: ${n.breakpoints[o]})`;r.media[s]={...r.media[s],[t]:Hg[a.type](Jg(e[i],o),n)}})}),r},{hasResponsiveStyles:!1,styles:{},inlineStyles:{},media:{}}))}function Xg(){return`__m__-${(0,R.useId)().replace(/[:«»]/g,``)}`}function Zg(e,t){return Array.isArray(e)?[...e].reduce((e,n)=>({...e,...Zg(n,t)}),{}):typeof e==`function`?e(t):e??{}}function Qg(e){return e}var $g=Qg;function e_(e){return e}function X(e){let t=e;return t.extend=e_,t.withProps=e=>{let n=n=>(0,z.jsx)(t,{...e,...n});return n.extend=t.extend,n.displayName=`WithProps(${t.displayName})`,n},t}function t_(e){return X(e)}function n_(e){let t=e;return t.withProps=e=>{let n=n=>(0,z.jsx)(t,{...e,...n});return n.extend=t.extend,n.displayName=`WithProps(${t.displayName})`,n},t.extend=e_,t}function r_(e){return`data-${(e.startsWith(`data-`)?e.slice(5):e).replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}`}function i_(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r===void 0||r===``||r===!1||r===null||(t[r_(n)]=e[n]),t},{})}function a_(e){return e?typeof e==`string`?{[r_(e)]:!0}:Array.isArray(e)?[...e].reduce((e,t)=>({...e,...a_(t)}),{}):i_(e):null}function o_(e,t){return Array.isArray(e)?[...e].reduce((e,n)=>({...e,...o_(n,t)}),{}):typeof e==`function`?e(t):e??{}}function s_({theme:e,style:t,vars:n,styleProps:r}){let i=o_(t,e),a=o_(n,e);return{...i,...a,...r}}function c_({component:e,style:t,__vars:n,className:r,variant:i,mod:a,size:o,hiddenFrom:s,visibleFrom:c,lightHidden:l,darkHidden:u,renderRoot:d,__size:f,ref:p,...m}){let h=Wh(),g=e||`div`,{styleProps:_,rest:v}=Dg(m),y=Oh()?.()?.(_.sx),b=Xg(),x=Yg({styleProps:_,theme:h,data:Og}),S=jh(),C=S&&x.hasResponsiveStyles?Eg(x.styles,x.media):b,w={ref:p,style:s_({theme:h,style:t,vars:n,styleProps:x.inlineStyles}),className:Km(r,y,{[C]:x.hasResponsiveStyles,"mantine-light-hidden":l,"mantine-dark-hidden":u,[`mantine-hidden-from-${s}`]:s,[`mantine-visible-from-${c}`]:c}),"data-variant":i,"data-size":kp(o)?void 0:o||void 0,size:f,...a_(a),...v};return(0,z.jsxs)(z.Fragment,{children:[x.hasResponsiveStyles&&(0,z.jsx)(wg,{selector:`.${C}`,styles:x.styles,media:x.media,deduplicate:S}),typeof d==`function`?d(w):(0,z.jsx)(g,{...w})]})}c_.displayName=`@mantine/core/Box`;var Z=$g(c_),l_=(0,R.createContext)({dir:`ltr`,toggleDirection:()=>{},setDirection:()=>{}});function u_(){return(0,R.use)(l_)}var d_={root:`m_87cf2631`},f_={__staticSelector:`UnstyledButton`},p_=n_(e=>{let t=J(`UnstyledButton`,f_,e),{className:n,component:r=`button`,__staticSelector:i,unstyled:a,classNames:o,styles:s,style:c,attributes:l,...u}=t,d=Y({name:i,props:t,classes:d_,className:n,style:c,classNames:o,styles:s,unstyled:a,attributes:l});return(0,z.jsx)(Z,{...d(`root`,{focusable:!0}),component:r,type:r===`button`?`button`:void 0,...u})});p_.classes=d_,p_.displayName=`@mantine/core/UnstyledButton`;var m_={root:`m_515a97f8`},h_=X(e=>{let t=J(`VisuallyHidden`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,...l}=t,u=Y({name:`VisuallyHidden`,classes:m_,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c});return(0,z.jsx)(Z,{component:`span`,...u(`root`),...l})});h_.classes=m_,h_.displayName=`@mantine/core/VisuallyHidden`;var g_={root:`m_1b7284a3`},__=q((e,{radius:t,shadow:n})=>({root:{"--paper-radius":t===void 0?void 0:Wp(t),"--paper-shadow":qp(n)}})),v_=n_(e=>{let t=J(`Paper`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,withBorder:s,vars:c,radius:l,shadow:u,variant:d,mod:f,attributes:p,...m}=t,h=Y({name:`Paper`,props:t,classes:g_,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:c,varsResolver:__});return(0,z.jsx)(Z,{mod:[{withBorder:s},f],...h(`root`),variant:d,...m})});v_.classes=g_,v_.varsResolver=__,v_.displayName=`@mantine/core/Paper`;function y_(e,t,n,r){return e===`center`||r===`center`?{top:t}:e===`end`?{bottom:n}:e===`start`?{top:n}:{}}function b_(e,t,n,r,i){return e===`center`||r===`center`?{left:t}:e===`end`?{[i===`ltr`?`right`:`left`]:n}:e===`start`?{[i===`ltr`?`left`:`right`]:n}:{}}var x_={bottom:`borderTopLeftRadius`,left:`borderTopRightRadius`,right:`borderBottomLeftRadius`,top:`borderBottomRightRadius`};function S_({position:e,arrowSize:t,dir:n}){let[r,i]=e.split(`-`);if(!i)return;let a={width:t,height:t,position:`absolute`};if(r===`bottom`){let e=i===`start`,r=e?n===`ltr`?`left`:`right`:n===`ltr`?`right`:`left`;return{...a,top:-t,[r]:0,clipPath:e===(n===`rtl`)?`polygon(100% 0%, 0% 100%, 100% 100%)`:`polygon(0% 0%, 0% 100%, 100% 100%)`}}if(r===`top`){let e=i===`start`,r=e?n===`ltr`?`left`:`right`:n===`ltr`?`right`:`left`;return{...a,bottom:-t,[r]:0,clipPath:e===(n===`rtl`)?`polygon(0% 0%, 100% 0%, 100% 100%)`:`polygon(0% 0%, 100% 0%, 0% 100%)`}}if(r===`left`)return{...a,right:-t,[i===`start`?`top`:`bottom`]:0,clipPath:i===`start`?`polygon(0% 0%, 100% 0%, 0% 100%)`:`polygon(0% 0%, 0% 100%, 100% 100%)`};if(r===`right`)return{...a,left:-t,[i===`start`?`top`:`bottom`]:0,clipPath:i===`start`?`polygon(0% 0%, 100% 0%, 100% 100%)`:`polygon(100% 0%, 0% 100%, 100% 100%)`}}function C_({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:i,arrowX:a,arrowY:o,dir:s}){if(i===`merge`){let n=S_({position:e,arrowSize:t,dir:s});if(n)return n}let[c,l=`center`]=e.split(`-`),u={width:t,height:t,transform:`rotate(45deg)`,position:`absolute`,[x_[c]]:r},d=-t/2;return c===`left`?{...u,...y_(l,o,n,i),right:d,borderLeftColor:`transparent`,borderBottomColor:`transparent`,clipPath:`polygon(100% 0, 0 0, 100% 100%)`}:c===`right`?{...u,...y_(l,o,n,i),left:d,borderRightColor:`transparent`,borderTopColor:`transparent`,clipPath:`polygon(0 100%, 0 0, 100% 100%)`}:c===`top`?{...u,...b_(l,a,n,i,s),bottom:d,borderTopColor:`transparent`,borderLeftColor:`transparent`,clipPath:`polygon(0 100%, 100% 100%, 100% 0)`}:c===`bottom`?{...u,...b_(l,a,n,i,s),top:d,borderBottomColor:`transparent`,borderRightColor:`transparent`,clipPath:`polygon(0 100%, 0 0, 100% 0)`}:{}}function w_({position:e,dir:t}){let[n,r]=e.split(`-`);if(!r)return;let i=r===`start`&&t===`ltr`||r===`end`&&t===`rtl`;if(n===`bottom`)return i?{borderTopLeftRadius:0}:{borderTopRightRadius:0};if(n===`top`)return i?{borderBottomLeftRadius:0}:{borderBottomRightRadius:0};if(n===`left`)return r===`start`?{borderTopRightRadius:0}:{borderBottomRightRadius:0};if(n===`right`)return r===`start`?{borderTopLeftRadius:0}:{borderBottomLeftRadius:0}}function T_({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:i,visible:a,arrowX:o,arrowY:s,style:c,...l}){let{dir:u}=u_();return a?(0,z.jsx)(`div`,{role:`presentation`,...l,style:{...c,...C_({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:i,dir:u,arrowX:o,arrowY:s})}}):null}T_.displayName=`@mantine/core/FloatingArrow`;function E_(e,t){if(e===`rtl`&&(t.includes(`right`)||t.includes(`left`))){let[e,n]=t.split(`-`),r=e===`right`?`left`:`right`;return n===void 0?r:`${r}-${n}`}return t}function D_({open:e,close:t,openDelay:n,closeDelay:r}){let i=(0,R.useRef)(-1),a=(0,R.useRef)(-1),o=()=>{window.clearTimeout(i.current),window.clearTimeout(a.current)};return(0,R.useEffect)(()=>o,[]),{openDropdown:()=>{o(),n===0||n===void 0?e():i.current=window.setTimeout(e,n)},closeDropdown:()=>{o(),r===0||r===void 0?t():a.current=window.setTimeout(t,r)}}}var O_={root:`m_9814e45f`},k_={zIndex:zp(`modal`)},A_=q((e,{gradient:t,color:n,backgroundOpacity:r,blur:i,radius:a,zIndex:o})=>({root:{"--overlay-bg":t||(n!==void 0||r!==void 0)&&mh(n||`#000`,r??.6)||void 0,"--overlay-filter":i?`blur(${K(i)})`:void 0,"--overlay-radius":a===void 0?void 0:Wp(a),"--overlay-z-index":o?.toString()}})),j_=n_(e=>{let t=J(`Overlay`,k_,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,fixed:c,center:l,children:u,radius:d,zIndex:f,gradient:p,blur:m,color:h,backgroundOpacity:g,mod:_,attributes:v,...y}=t,b=Y({name:`Overlay`,props:t,classes:O_,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:v,vars:s,varsResolver:A_});return(0,z.jsx)(Z,{...b(`root`),mod:[{center:l,fixed:c},_],...y,children:u})});j_.classes=O_,j_.varsResolver=A_,j_.displayName=`@mantine/core/Overlay`;function M_(e){let t=document.createElement(`div`);return t.setAttribute(`data-portal`,`true`),typeof e.className==`string`&&t.classList.add(...e.className.split(` `).filter(Boolean)),typeof e.style==`object`&&Object.assign(t.style,e.style),typeof e.id==`string`&&t.setAttribute(`id`,e.id),t}var N_=null;function P_({target:e,reuseTargetNode:t,...n}){if(e)return typeof e==`string`?document.querySelector(e)||M_(n):e;if(t){if(N_){if(document.body.contains(N_))return N_;N_=null}let e=document.querySelector(`[data-mantine-shared-portal-node]`);if(e)return N_=e,e;let t=M_(n);return t.setAttribute(`data-mantine-shared-portal-node`,`true`),document.body.appendChild(t),N_=t,t}return M_(n)}var F_={reuseTargetNode:!0},I_=X(e=>{let{children:t,target:n,reuseTargetNode:r,ref:i,...a}=J(`Portal`,F_,e),[o,s]=(0,R.useState)(!1),c=(0,R.useRef)(null);return tm(()=>(s(!0),c.current=P_({target:n,reuseTargetNode:r,...a}),jm(i,c.current),!n&&!r&&c.current&&document.body.appendChild(c.current),()=>{!n&&!r&&c.current&&document.body.removeChild(c.current)}),[n]),!o||!c.current?null:(0,Ne.createPortal)((0,z.jsx)(z.Fragment,{children:t}),c.current)});I_.displayName=`@mantine/core/Portal`;var L_=X(({withinPortal:e=!0,children:t,...n})=>Ah()===`test`||!e?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(I_,{...n,children:t}));L_.displayName=`@mantine/core/OptionalPortal`;var R_=e=>({in:{opacity:1,transform:`scale(1)`},out:{opacity:0,transform:`scale(.9) translateY(${e===`bottom`?10:-10}px)`},transitionProperty:`transform, opacity`}),z_={fade:{in:{opacity:1},out:{opacity:0},transitionProperty:`opacity`},"fade-up":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(30px)`},transitionProperty:`opacity, transform`},"fade-down":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(-30px)`},transitionProperty:`opacity, transform`},"fade-left":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(30px)`},transitionProperty:`opacity, transform`},"fade-right":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(-30px)`},transitionProperty:`opacity, transform`},scale:{in:{opacity:1,transform:`scale(1)`},out:{opacity:0,transform:`scale(0)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"scale-y":{in:{opacity:1,transform:`scaleY(1)`},out:{opacity:0,transform:`scaleY(0)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"scale-x":{in:{opacity:1,transform:`scaleX(1)`},out:{opacity:0,transform:`scaleX(0)`},common:{transformOrigin:`left`},transitionProperty:`transform, opacity`},"skew-up":{in:{opacity:1,transform:`translateY(0) skew(0deg, 0deg)`},out:{opacity:0,transform:`translateY(-20px) skew(-10deg, -5deg)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"skew-down":{in:{opacity:1,transform:`translateY(0) skew(0deg, 0deg)`},out:{opacity:0,transform:`translateY(20px) skew(-10deg, -5deg)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"rotate-left":{in:{opacity:1,transform:`translateY(0) rotate(0deg)`},out:{opacity:0,transform:`translateY(20px) rotate(-5deg)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"rotate-right":{in:{opacity:1,transform:`translateY(0) rotate(0deg)`},out:{opacity:0,transform:`translateY(20px) rotate(5deg)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"slide-down":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(-100%)`},common:{transformOrigin:`top`},transitionProperty:`transform, opacity`},"slide-up":{in:{opacity:1,transform:`translateY(0)`},out:{opacity:0,transform:`translateY(100%)`},common:{transformOrigin:`bottom`},transitionProperty:`transform, opacity`},"slide-left":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(100%)`},common:{transformOrigin:`left`},transitionProperty:`transform, opacity`},"slide-right":{in:{opacity:1,transform:`translateX(0)`},out:{opacity:0,transform:`translateX(-100%)`},common:{transformOrigin:`right`},transitionProperty:`transform, opacity`},pop:{...R_(`bottom`),common:{transformOrigin:`center center`}},"pop-bottom-left":{...R_(`bottom`),common:{transformOrigin:`bottom left`}},"pop-bottom-right":{...R_(`bottom`),common:{transformOrigin:`bottom right`}},"pop-top-left":{...R_(`top`),common:{transformOrigin:`top left`}},"pop-top-right":{...R_(`top`),common:{transformOrigin:`top right`}}},B_={entering:`in`,entered:`in`,exiting:`out`,exited:`out`,"pre-exiting":`out`,"pre-entering":`out`};function V_({transition:e,state:t,duration:n,timingFunction:r}){let i={WebkitBackfaceVisibility:`hidden`,transitionDuration:`${n}ms`,transitionTimingFunction:r};return typeof e==`string`?e in z_?{transitionProperty:z_[e].transitionProperty,...i,...z_[e].common,...z_[e][B_[t]]}:{}:{transitionProperty:e.transitionProperty,...i,...e.common,...e[B_[t]]}}function H_({duration:e,exitDuration:t,timingFunction:n,mounted:r,onEnter:i,onExit:a,onEntered:o,onExited:s,enterDelay:c,exitDelay:l}){let u=Wh(),d=Fm(),f=u.respectReducedMotion?d:!1,[p,m]=(0,R.useState)(f?0:e),[h,g]=(0,R.useState)(r?`entered`:`exited`),_=(0,R.useRef)(-1),v=(0,R.useRef)(-1),y=(0,R.useRef)(-1);function b(){window.clearTimeout(_.current),window.clearTimeout(v.current),cancelAnimationFrame(y.current),y.current=-1}let x=n=>{b();let r=n?i:a,c=n?o:s,l=f?0:n?e:t;if(m(l),l===0)typeof r==`function`&&r(),typeof c==`function`&&c(),g(n?`entered`:`exited`);else{let e=requestAnimationFrame(()=>{Ne.flushSync(()=>{g(n?`pre-entering`:`pre-exiting`)}),y.current===e&&(y.current=requestAnimationFrame(()=>{typeof r==`function`&&r(),g(n?`entering`:`exiting`),_.current=window.setTimeout(()=>{typeof c==`function`&&c(),g(n?`entered`:`exited`)},l)}))});y.current=e}},S=e=>{b(),typeof(e?c:l)==`number`?v.current=window.setTimeout(()=>{x(e)},e?c:l):x(e)};return rm(()=>{S(r)},[r]),(0,R.useEffect)(()=>()=>{b()},[]),{transitionDuration:p,transitionStatus:h,transitionTimingFunction:n||`ease`}}function U_({keepMounted:e,keepMountedMode:t=`activity`,transition:n=`fade`,duration:r=250,exitDuration:i=r,mounted:a,children:o,timingFunction:s=`ease`,onExit:c,onEntered:l,onEnter:u,onExited:d,enterDelay:f,exitDelay:p}){let m=Ah(),{transitionDuration:h,transitionStatus:g,transitionTimingFunction:_}=H_({mounted:a,exitDuration:i,duration:r,timingFunction:s,onExit:c,onEntered:l,onEnter:u,onExited:d,enterDelay:f,exitDelay:p});if(m===`test`)return a?(0,z.jsx)(z.Fragment,{children:o({})}):e?o({display:`none`}):null;if(h===0)return e?t===`display-none`?a?(0,z.jsx)(z.Fragment,{children:o({})}):o({display:`none`}):(0,z.jsx)(R.Activity,{mode:a?`visible`:`hidden`,children:o({})}):a?(0,z.jsx)(z.Fragment,{children:o({})}):null;let v=g===`exited`;if(e){let e=o(v?t===`display-none`?{display:`none`}:{}:V_({transition:n,duration:h,state:g,timingFunction:_}));return t===`display-none`?e:(0,z.jsx)(R.Activity,{mode:v?`hidden`:`visible`,children:e})}return v?null:(0,z.jsx)(z.Fragment,{children:o(V_({transition:n,duration:h,state:g,timingFunction:_}))})}U_.displayName=`@mantine/core/Transition`;var W_={duration:100,transition:`fade`};function G_(e,t){return{...W_,...t,...e}}var[K_,q_]=jp(`Popover component was not found in the tree`);function J_({childProps:e,disabled:t,opened:n,longPressDelay:r=500,setReference:i,open:a}){let o=(0,R.useRef)(!1),s=(0,R.useRef)(!1),c=(0,R.useRef)(null),l=(0,R.useRef)(t);l.current=t;let u=(e,t,n)=>{i({getBoundingClientRect:()=>({x:e,y:t,width:0,height:0,top:t,left:e,right:e,bottom:t,toJSON:()=>void 0}),contextElement:n}),a()},d=Jp(e.onMouseDown,e=>{t||e.button===2&&e.stopPropagation()}),f=Jp(e.onContextMenu,e=>{t||e.defaultPrevented||(e.preventDefault(),s.current||(u(e.clientX,e.clientY,e.currentTarget),o.current&&(s.current=!0)))}),p=zm(e=>{if(l.current||s.current)return;let t=e,n=t.touches[0]??t.changedTouches[0];n&&(u(n.clientX,n.clientY,c.current),s.current=!0)},{threshold:r,events:[`touch`],cancelOnMove:!0,onStart:e=>{o.current=!0,s.current=!1,c.current=e.currentTarget},onFinish:e=>{o.current=!1,s.current=!1,l.current||e.preventDefault()},onCancel:()=>{o.current=!1,s.current=!1}});return{onContextMenu:f,onMouseDown:d,onTouchStart:Jp(e.onTouchStart,p.onTouchStart),onTouchEnd:Jp(e.onTouchEnd,p.onTouchEnd),onTouchCancel:Jp(e.onTouchCancel,p.onTouchCancel),onTouchMove:Jp(e.onTouchMove,p.onTouchMove),style:t?e.style:{...e.style,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},"data-expanded":n?!0:void 0}}function Y_(e){let{children:t,disabled:n,longPressDelay:r}=J(`PopoverContextMenu`,null,e),i=Wm(t);if(!i)throw Error(`Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let a=q_(),o=J_({childProps:i.props,disabled:n||a.disabled,opened:a.opened,longPressDelay:r,setReference:a.reference,open:()=>{a.opened||a.onToggle()}});return(0,R.cloneElement)(i,o)}Y_.displayName=`@mantine/core/PopoverContextMenu`;function X_({children:e,active:t=!0,refProp:n=`ref`,innerRef:r}){let i=Nm(Dm(t),r),a=Wm(e);return a?(0,R.cloneElement)(a,{[n]:i}):e}function Z_(e){return(0,z.jsx)(h_,{tabIndex:-1,"data-autofocus":!0,...e})}X_.displayName=`@mantine/core/FocusTrap`,Z_.displayName=`@mantine/core/FocusTrapInitialFocus`,X_.InitialFocus=Z_;var Q_={dropdown:`m_38a85659`,arrow:`m_a31dc6c1`,overlay:`m_3d7bc908`},$_=X(e=>{let t=J(`PopoverDropdown`,null,e),{className:n,style:r,vars:i,children:a,onKeyDownCapture:o,variant:s,classNames:c,styles:l,ref:u,...d}=t,f=q_(),{dir:p}=u_(),m=f.arrowPosition===`merge`&&f.withArrow?w_({position:f.placement,dir:p}):void 0,h=im({opened:f.opened,shouldReturnFocus:f.returnFocus}),g=f.withRoles?{"aria-labelledby":f.getTargetId(),id:f.getDropdownId(),role:`dialog`,tabIndex:-1}:{},_=Nm(u,f.floating);return f.disabled?null:(0,z.jsx)(L_,{...f.portalProps,withinPortal:f.withinPortal,children:(0,z.jsx)(U_,{mounted:f.opened,...f.transitionProps,transition:f.transitionProps?.transition||`fade`,duration:f.transitionProps?.duration??150,keepMounted:f.keepMounted,keepMountedMode:f.keepMountedMode,exitDuration:typeof f.transitionProps?.exitDuration==`number`?f.transitionProps.exitDuration:f.transitionProps?.duration,children:e=>(0,z.jsx)(X_,{active:f.trapFocus&&f.opened,innerRef:_,children:(0,z.jsxs)(Z,{...g,...d,variant:s,onKeyDownCapture:Vp(()=>{f.onClose?.(),f.onDismiss?.()},{active:f.closeOnEscape,onTrigger:h,onKeyDown:o}),"data-position":f.placement,"data-fixed":f.floatingStrategy===`fixed`||void 0,...f.getStyles(`dropdown`,{className:n,props:t,classNames:c,styles:l,style:[{...e,...m,zIndex:f.zIndex,top:f.y??0,left:f.x??0,width:f.width===`target`?void 0:K(f.width),...f.referenceHidden?{display:`none`}:null},f.resolvedStyles?.dropdown,l?.dropdown,r]}),children:[a,(0,z.jsx)(T_,{ref:f.arrowRef,arrowX:f.arrowX,arrowY:f.arrowY,visible:f.withArrow,position:f.placement,arrowSize:f.arrowSize,arrowRadius:f.arrowRadius,arrowOffset:f.arrowOffset,arrowPosition:f.arrowPosition,...f.getStyles(`arrow`,{props:t,classNames:c,styles:l})})]})})})})});$_.classes=Q_,$_.displayName=`@mantine/core/PopoverDropdown`;var ev={refProp:`ref`,popupType:`dialog`},tv=X(e=>{let{children:t,refProp:n,popupType:r,ref:i,...a}=J(`PopoverTarget`,ev,e),o=Wm(t);if(!o)throw Error(`Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let s=a,c=q_(),l=Nm(c.reference,Um(o),i),u=c.withRoles?{"aria-haspopup":r,"aria-expanded":c.opened,"aria-controls":c.opened?c.getDropdownId():void 0,id:c.getTargetId()}:{},d=o.props;return(0,R.cloneElement)(o,{...s,...u,...c.targetProps,className:Km(c.targetProps.className,s.className,d.className),[n]:l,...c.controlled?null:{onClick:e=>{c.onToggle(),d.onClick?.(e)}}})});tv.displayName=`@mantine/core/PopoverTarget`;function nv(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function rv(e,t,n,r){let i=nv(e.middlewares),a=[za(e.offset),Ga()];if(i.flip&&!n){let e=typeof i.flip==`boolean`?{}:i.flip,t=r?{fallbackStrategy:`initialPlacement`,...e}:e;a.push(Ha(t))}if(i.shift){let t=typeof i.shift==`boolean`?{}:i.shift;a.push(Ba(n=>{let r=n.placement.startsWith(`top`)||n.placement.startsWith(`bottom`);return{limiter:Va(),padding:5,...e.width===`target`&&r?{mainAxis:!1}:null,...t}}))}return i.inline&&a.push(typeof i.inline==`boolean`?Ka():Ka(i.inline)),a.push(qa({element:e.arrowRef,padding:e.arrowOffset})),(i.size||e.width===`target`)&&a.push(Ua({...typeof i.size==`boolean`?{}:i.size,apply({rects:n,availableWidth:r,availableHeight:a,...o}){let s=t().refs.floating.current?.style??{};i.size&&(typeof i.size==`object`&&i.size.apply?i.size.apply({rects:n,availableWidth:r,availableHeight:a,...o}):Object.assign(s,{maxWidth:`${r}px`,maxHeight:`${a}px`})),e.width===`target`&&Object.assign(s,{width:`${n.reference.width}px`})}})),a}function iv(e){let[t,n]=Pm({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),r=(0,R.useRef)(t),i=(0,R.useRef)(!1),[a,o]=(0,R.useState)(null),s=e.preventPositionChangeWhenVisible!==!1,c=(0,R.useRef)(t);t!==c.current&&(c.current=t,t&&a!==null&&o(null));let l=(0,R.useRef)(e.position);e.position!==l.current&&(l.current=e.position,i.current=!1,a!==null&&o(null));let u=(0,R.useCallback)(()=>o(null),[]),d=()=>{t&&!e.disabled&&n(!1)},f=()=>{e.disabled||n(!t)},p=ds({open:t,strategy:e.strategy,placement:s?a??e.position:e.position,middleware:rv(e,()=>p,s&&a!==null,s),whileElementsMounted:e.keepMounted?void 0:xa}),m=(0,R.useRef)(p.placement);m.current=p.placement,(0,R.useEffect)(()=>{if(!e.keepMounted)return;let n=p.refs.reference.current,r=p.refs.floating.current;if(t&&n&&r)return xa(n,r,p.update)},[e.keepMounted,t,p.update,p.elements.reference,p.elements.floating]),tm(()=>{if(!t){i.current=!1;return}if(!s||a!==null)return;let e=p.refs.floating.current;if(e&&e.offsetHeight!==0&&e.offsetWidth!==0){if(!i.current){i.current=!0,p.update();let e=requestAnimationFrame(()=>o(m.current));return()=>cancelAnimationFrame(e)}p.isPositioned&&o(p.placement)}},[s,t,p.isPositioned,p.placement,a,p.update]);let h=(0,R.useRef)(p.placement);return tm(()=>{h.current!==p.placement&&(h.current=p.placement,e.onPositionChange?.(p.placement))},[p.placement]),rm(()=>{t!==r.current&&(t?e.onOpen?.():e.onClose?.()),r.current=t},[t,e.onClose,e.onOpen]),{floating:p,controlled:typeof e.opened==`boolean`,opened:t,onClose:d,onToggle:f,resetLockedPlacement:u}}var av={position:`bottom`,offset:8,transitionProps:{transition:`fade`,duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,withOverlay:!1,hideDetached:!0,preventPositionChangeWhenVisible:!0,clickOutsideEvents:[`mousedown`,`touchstart`],clickOutsideCapture:!1,zIndex:zp(`popover`),__staticSelector:`Popover`,width:`max-content`},ov=q((e,{radius:t,shadow:n})=>({dropdown:{"--popover-radius":t===void 0?void 0:Wp(t),"--popover-shadow":qp(n)}}));function sv(e){let t=J(`Popover`,av,e),{children:n,position:r,offset:i,onPositionChange:a,opened:o,transitionProps:s,onExitTransitionEnd:c,onEnterTransitionEnd:l,width:u,middlewares:d,withArrow:f,arrowSize:p,arrowOffset:m,arrowRadius:h,arrowPosition:g,unstyled:_,classNames:v,styles:y,closeOnClickOutside:b,withinPortal:x,portalProps:S,closeOnEscape:C,clickOutsideEvents:w,clickOutsideCapture:T,trapFocus:E,onClose:D,onDismiss:O,onOpen:k,onChange:A,zIndex:j,radius:M,shadow:N,id:P,defaultOpened:ee,__staticSelector:te,withRoles:ne,disabled:re,returnFocus:F,variant:ie,keepMounted:ae,keepMountedMode:oe,vars:se,floatingStrategy:I,withOverlay:ce,overlayProps:le,hideDetached:ue,attributes:de,preventPositionChangeWhenVisible:fe,...L}=t,pe=Y({name:te,props:t,classes:Q_,classNames:v,styles:y,unstyled:_,attributes:de,rootSelector:`dropdown`,vars:se,varsResolver:ov}),{resolvedStyles:me}=ag({classNames:v,styles:y,props:t}),he=(0,R.useRef)(null),[ge,_e]=(0,R.useState)(null),[ve,ye]=(0,R.useState)(null),{dir:be}=u_(),xe=Ah(),Se=Am(P),Ce=iv({middlewares:d,width:u,position:E_(be,r),offset:typeof i==`number`?i+(f?p/2:0):i,arrowRef:he,arrowOffset:m,onPositionChange:a,opened:o,defaultOpened:ee,onChange:A,onOpen:k,onClose:D,onDismiss:O,strategy:I,disabled:re,preventPositionChangeWhenVisible:fe,keepMounted:ae});Qp(()=>{b&&(Ce.onClose(),O?.())},w,[ge,ve],!0,T);let we=(0,R.useCallback)(e=>{_e(e),Ce.floating.refs.setReference(e)},[Ce.floating.refs.setReference]),Te=(0,R.useCallback)(e=>{ye(e),Ce.floating.refs.setFloating(e)},[Ce.floating.refs.setFloating]),Ee=(0,R.useCallback)(()=>{s?.onExited?.(),c?.(),Ce.resetLockedPlacement()},[s?.onExited,c,Ce.resetLockedPlacement]),De=(0,R.useCallback)(()=>{s?.onEntered?.(),l?.()},[s?.onEntered,l]);return(0,z.jsxs)(K_,{value:{returnFocus:F,disabled:re,controlled:Ce.controlled,reference:we,floating:Te,x:Ce.floating.x,y:Ce.floating.y,arrowX:Ce.floating?.middlewareData?.arrow?.x,arrowY:Ce.floating?.middlewareData?.arrow?.y,opened:Ce.opened,arrowRef:he,transitionProps:{...s,onExited:Ee,onEntered:De},width:u,withArrow:f,arrowSize:p,arrowOffset:m,arrowRadius:h,arrowPosition:g,placement:Ce.floating.placement,trapFocus:E,withinPortal:x,portalProps:S,zIndex:j,radius:M,shadow:N,closeOnEscape:C,onDismiss:O,onClose:Ce.onClose,onToggle:Ce.onToggle,getTargetId:()=>Se,getDropdownId:()=>`${Se}-dropdown`,withRoles:ne,targetProps:L,__staticSelector:te,classNames:v,styles:y,unstyled:_,variant:ie,keepMounted:ae,keepMountedMode:oe,getStyles:pe,resolvedStyles:me,floatingStrategy:I,referenceHidden:ue&&xe!==`test`?Ce.floating.middlewareData.hide?.referenceHidden:!1},children:[n,ce&&(0,z.jsx)(U_,{transition:`fade`,mounted:Ce.opened,duration:s?.duration??250,exitDuration:s?.exitDuration??s?.duration??250,children:e=>(0,z.jsx)(L_,{withinPortal:x,children:(0,z.jsx)(j_,{...le,...pe(`overlay`,{className:le?.className,style:[e,le?.style]})})})})]})}sv.Target=tv,sv.Dropdown=$_,sv.ContextMenu=Y_,sv.varsResolver=ov,sv.displayName=`@mantine/core/Popover`,sv.extend=e=>e,sv.withProps=e=>{let t=t=>(0,z.jsx)(sv,{...e,...t});return t.extend=sv.extend,t.displayName=`WithProps(${sv.displayName})`,t};var cv={root:`m_5ae2e3c`,barsLoader:`m_7a2bd4cd`,bar:`m_870bb79`,"bars-loader-animation":`m_5d2b3b9d`,dotsLoader:`m_4e3f22d7`,dot:`m_870c4af`,"loader-dots-animation":`m_aac34a1`,ovalLoader:`m_b34414df`,"oval-loader-animation":`m_f8e89c4b`},lv=({className:e,...t})=>(0,z.jsxs)(Z,{component:`span`,className:Km(cv.barsLoader,e),...t,children:[(0,z.jsx)(`span`,{className:cv.bar}),(0,z.jsx)(`span`,{className:cv.bar}),(0,z.jsx)(`span`,{className:cv.bar})]});lv.displayName=`@mantine/core/Bars`;var uv=({className:e,...t})=>(0,z.jsxs)(Z,{component:`span`,className:Km(cv.dotsLoader,e),...t,children:[(0,z.jsx)(`span`,{className:cv.dot}),(0,z.jsx)(`span`,{className:cv.dot}),(0,z.jsx)(`span`,{className:cv.dot})]});uv.displayName=`@mantine/core/Dots`;var dv=({className:e,...t})=>(0,z.jsx)(Z,{component:`span`,className:Km(cv.ovalLoader,e),...t});dv.displayName=`@mantine/core/Oval`;var fv={bars:lv,oval:dv,dots:uv},pv={loaders:fv,type:`oval`},mv=q((e,{size:t,color:n})=>({root:{"--loader-size":Hp(t,`loader-size`),"--loader-color":n?uh(n,e):void 0}})),hv=X(e=>{let t=J(`Loader`,pv,e),{size:n,color:r,type:i,vars:a,className:o,style:s,classNames:c,styles:l,unstyled:u,loaders:d,variant:f,children:p,attributes:m,...h}=t,g=Y({name:`Loader`,props:t,classes:cv,className:o,style:s,classNames:c,styles:l,unstyled:u,attributes:m,vars:a,varsResolver:mv});return p?(0,z.jsx)(Z,{...g(`root`),...h,children:p}):(0,z.jsx)(Z,{...g(`root`),component:d[i],variant:f,size:n,...h})});hv.defaultLoaders=fv,hv.classes=cv,hv.varsResolver=mv,hv.displayName=`@mantine/core/Loader`;var gv={root:`m_8d3f4000`,icon:`m_8d3afb97`,loader:`m_302b9fb1`,group:`m_1a0f1b21`,groupSection:`m_437b6484`},_v={orientation:`horizontal`},vv=q((e,{borderWidth:t})=>({group:{"--ai-border-width":K(t)}})),yv=X(e=>{let t=J(`ActionIconGroup`,_v,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,variant:u,mod:d,attributes:f,...p}=t,m=Y({name:`ActionIconGroup`,props:t,classes:gv,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:f,vars:c,varsResolver:vv,rootSelector:`group`});return(0,z.jsx)(Z,{...m(`group`),variant:u,mod:[{orientation:s},d],role:`group`,...p})});yv.classes=gv,yv.varsResolver=vv,yv.displayName=`@mantine/core/ActionIconGroup`;var bv=q((e,{radius:t,color:n,gradient:r,variant:i,autoContrast:a,size:o})=>{let s=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:a});return{groupSection:{"--section-height":Hp(o,`section-height`),"--section-padding-x":Hp(o,`section-padding-x`),"--section-fz":Gp(o),"--section-radius":t===void 0?void 0:Wp(t),"--section-bg":n||i?s.background:void 0,"--section-color":s.color,"--section-bd":n||i?s.border:void 0}}}),xv=X(e=>{let t=J(`ActionIconGroupSection`,null,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,vars:s,variant:c,gradient:l,radius:u,autoContrast:d,attributes:f,...p}=t,m=Y({name:`ActionIconGroupSection`,props:t,classes:gv,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:bv,rootSelector:`groupSection`});return(0,z.jsx)(Z,{...m(`groupSection`),variant:c,...p})});xv.classes=gv,xv.varsResolver=bv,xv.displayName=`@mantine/core/ActionIconGroupSection`;var Sv=q((e,{size:t,radius:n,variant:r,gradient:i,color:a,autoContrast:o})=>{let s=e.variantColorResolver({color:a||e.primaryColor,theme:e,gradient:i,variant:r||`filled`,autoContrast:o});return{root:{"--ai-size":Hp(t,`ai-size`),"--ai-radius":n===void 0?void 0:Wp(n),"--ai-bg":a||r?s.background:void 0,"--ai-hover":a||r?s.hover:void 0,"--ai-hover-color":a||r?s.hoverColor:void 0,"--ai-color":s.color,"--ai-bd":a||r?s.border:void 0}}}),Cv=n_(e=>{let t=J(`ActionIcon`,null,e),{className:n,unstyled:r,variant:i,classNames:a,styles:o,style:s,loading:c,loaderProps:l,size:u,color:d,radius:f,__staticSelector:p,gradient:m,vars:h,children:g,disabled:_,"data-disabled":v,autoContrast:y,mod:b,attributes:x,...S}=t,C=Y({name:[`ActionIcon`,p],props:t,className:n,style:s,classes:gv,classNames:a,styles:o,unstyled:r,attributes:x,vars:h,varsResolver:Sv});return(0,z.jsxs)(p_,{...C(`root`,{active:!_&&!c&&!v}),"aria-busy":c||void 0,...S,unstyled:r,variant:i,size:u,disabled:_||c,mod:[{loading:c,disabled:_||v},b],children:[typeof c==`boolean`&&(0,z.jsx)(U_,{mounted:c,transition:`slide-down`,duration:150,children:e=>(0,z.jsx)(Z,{component:`span`,...C(`loader`,{style:e}),"aria-hidden":!0,children:(0,z.jsx)(hv,{color:`var(--ai-color)`,size:`calc(var(--ai-size) * 0.55)`,...l})})}),(0,z.jsx)(Z,{component:`span`,mod:{loading:c},...C(`icon`),children:g})]})});Cv.classes=gv,Cv.varsResolver=Sv,Cv.displayName=`@mantine/core/ActionIcon`,Cv.Group=yv,Cv.GroupSection=xv;function wv({size:e=`var(--cb-icon-size, 70%)`,style:t,...n}){return(0,z.jsx)(`svg`,{viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{...t,width:e,height:e},...n,children:(0,z.jsx)(`path`,{d:`M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}wv.displayName=`@mantine/core/CloseIcon`;var Tv={root:`m_86a44da5`,"root--subtle":`m_220c80f2`},Ev={variant:`subtle`},Dv=q((e,{size:t,radius:n,iconSize:r})=>({root:{"--cb-size":Hp(t,`cb-size`),"--cb-radius":n===void 0?void 0:Wp(n),"--cb-icon-size":K(r)}})),Ov=n_(e=>{let t=J(`CloseButton`,Ev,e),{iconSize:n,children:r,vars:i,radius:a,className:o,classNames:s,style:c,styles:l,unstyled:u,"data-disabled":d,disabled:f,variant:p,icon:m,mod:h,attributes:g,__staticSelector:_,...v}=t,y=Y({name:_||`CloseButton`,props:t,className:o,style:c,classes:Tv,classNames:s,styles:l,unstyled:u,attributes:g,vars:i,varsResolver:Dv});return(0,z.jsxs)(p_,{...v,unstyled:u,variant:p,disabled:f,mod:[{disabled:f||d},h],...y(`root`,{variant:p,active:!f&&!d}),children:[m||(0,z.jsx)(wv,{}),r]})});Ov.classes=Tv,Ov.varsResolver=Dv,Ov.displayName=`@mantine/core/CloseButton`;function kv(e){return R.Children.toArray(e).filter(Boolean)}var Av={root:`m_4081bf90`},jv={preventGrowOverflow:!0,gap:`md`,align:`center`,justify:`flex-start`,wrap:`wrap`},Mv=q((e,{grow:t,preventGrowOverflow:n,gap:r,align:i,justify:a,wrap:o},{childWidth:s})=>({root:{"--group-child-width":t&&n?s:void 0,"--group-gap":Up(r),"--group-align":i,"--group-justify":a,"--group-wrap":o}})),Nv=X(e=>{let t=J(`Group`,jv,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,children:s,gap:c,align:l,justify:u,wrap:d,grow:f,preventGrowOverflow:p,vars:m,variant:h,__size:g,mod:_,attributes:v,...y}=t,b=kv(s),x=b.length,S=Up(c??`md`),C=Y({name:`Group`,props:t,stylesCtx:{childWidth:`calc(${100/x}% - (${S} - ${S} / ${x}))`},className:r,style:i,classes:Av,classNames:n,styles:a,unstyled:o,attributes:v,vars:m,varsResolver:Mv});return(0,z.jsx)(Z,{...C(`root`),variant:h,mod:[{grow:f},_],size:g,...y,children:b})});Nv.classes=Av,Nv.varsResolver=Mv,Nv.displayName=`@mantine/core/Group`;var Pv=(0,R.createContext)({size:`sm`}),Fv=X(e=>{let t=J(`InputClearButton`,null,e),{size:n,variant:r,vars:i,classNames:a,styles:o,...s}=t,c=(0,R.use)(Pv),{resolvedClassNames:l,resolvedStyles:u}=ag({classNames:a,styles:o,props:t});return(0,z.jsx)(Ov,{variant:r||`transparent`,size:n||c?.size||`sm`,classNames:l,styles:u,__staticSelector:`InputClearButton`,style:{pointerEvents:`all`,background:`var(--input-bg)`,...s.style},...s})});Fv.displayName=`@mantine/core/InputClearButton`;var Iv={xs:7,sm:8,md:10,lg:12,xl:15};function Lv({__clearable:e,__clearSection:t,rightSection:n,__defaultRightSection:r,size:i=`sm`,__clearSectionMode:a=`both`}){let o=e&&t;return a===`rightSection`?n===null?null:n||r:a===`clear`?n===null?null:o||r:o&&(n||r)?(0,z.jsxs)(`div`,{"data-combined-clear-section":!0,style:{display:`flex`,gap:2,alignItems:`center`,paddingInlineEnd:Iv[i]},children:[o,n||r]}):n===null?null:n||o||r}var Rv=(0,R.createContext)({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0}),zv={wrapper:`m_6c018570`,input:`m_8fb7ebe7`,bottomSection:`m_93f4ed57`,section:`m_82577fc2`,placeholder:`m_88bacfd0`,root:`m_46b77525`,label:`m_8fdc1311`,required:`m_78a94662`,error:`m_8f816625`,success:`m_9d9d40e0`,description:`m_fe47ce59`},Bv=q((e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`}})),Vv=X(e=>{let t=J(`InputDescription`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,__inheritStyles:l=!0,attributes:u,...d}=J(`InputDescription`,null,t),f=(0,R.use)(Rv),p=Y({name:[`InputWrapper`,c],props:t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,rootSelector:`description`,vars:s,varsResolver:Bv}),m=l&&f?.getStyles||p;return(0,z.jsx)(Z,{component:`p`,...m(`description`,f?.getStyles?{className:r,style:i}:void 0),...d})});Vv.classes=zv,Vv.varsResolver=Bv,Vv.displayName=`@mantine/core/InputDescription`;var Hv=q((e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`}})),Uv=X(e=>{let t=J(`InputError`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=Y({name:[`InputWrapper`,l],props:t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`error`,vars:s,varsResolver:Hv}),p=(0,R.use)(Rv),m=u&&p?.getStyles||f;return(0,z.jsx)(Z,{component:`p`,...m(`error`,p?.getStyles?{className:r,style:i}:void 0),...d})});Uv.classes=zv,Uv.varsResolver=Hv,Uv.displayName=`@mantine/core/InputError`;var Wv={labelElement:`label`},Gv=q((e,{size:t})=>({label:{"--input-label-size":Gp(t),"--input-asterisk-color":void 0}})),Kv=X(e=>{let t=J(`InputLabel`,Wv,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,labelElement:c,required:l,htmlFor:u,onMouseDown:d,children:f,__staticSelector:p,mod:m,attributes:h,...g}=t,_=Y({name:[`InputWrapper`,p],props:t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`label`,vars:s,varsResolver:Gv}),v=(0,R.use)(Rv),y=v?.getStyles||_,b=g.component||c,x=typeof b!=`string`||b===`label`;return(0,z.jsxs)(Z,{...y(`label`,v?.getStyles?{className:r,style:i}:void 0),component:c,htmlFor:x?u:void 0,mod:[{required:l},m],onMouseDown:e=>{d?.(e),!e.defaultPrevented&&e.detail>1&&e.preventDefault()},...g,children:[f,l&&(0,z.jsx)(`span`,{...y(`required`),"aria-hidden":!0,children:` *`})]})});Kv.classes=zv,Kv.varsResolver=Gv,Kv.displayName=`@mantine/core/InputLabel`;var qv=X(e=>{let t=J(`InputPlaceholder`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,__staticSelector:c,error:l,mod:u,attributes:d,...f}=t,p=Y({name:[`InputPlaceholder`,c],props:t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:d,rootSelector:`placeholder`});return(0,z.jsx)(Z,{...p(`placeholder`),mod:[{error:!!l},u],component:`span`,...f})});qv.classes=zv,qv.displayName=`@mantine/core/InputPlaceholder`;var Jv=q((e,{size:t})=>({success:{"--input-success-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`}})),Yv=X(e=>{let t=J(`InputSuccess`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,attributes:c,__staticSelector:l,__inheritStyles:u=!0,...d}=t,f=Y({name:[`InputWrapper`,l],props:t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:c,rootSelector:`success`,vars:s,varsResolver:Jv}),p=(0,R.use)(Rv),m=u&&p?.getStyles||f;return(0,z.jsx)(Z,{component:`p`,...m(`success`,p?.getStyles?{className:r,style:i}:void 0),...d})});Yv.classes=zv,Yv.varsResolver=Jv,Yv.displayName=`@mantine/core/InputSuccess`;function Xv(e,{hasDescription:t,hasError:n}){let r=e.findIndex(e=>e===`input`),i=e.slice(0,r),a=e.slice(r+1),o=t&&i.includes(`description`)||n&&i.includes(`error`);return{offsetBottom:t&&a.includes(`description`)||n&&a.includes(`error`),offsetTop:o}}var Zv={labelElement:`label`,inputContainer:e=>e,inputWrapperOrder:[`label`,`description`,`input`,`error`]},Qv=q((e,{size:t})=>({label:{"--input-label-size":Gp(t),"--input-asterisk-color":void 0},error:{"--input-error-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`},success:{"--input-success-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`},description:{"--input-description-size":t===void 0?void 0:`calc(${Gp(t)} - ${K(2)})`}})),$v=X(e=>{let t=J(`InputWrapper`,Zv,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,variant:l,__staticSelector:u,inputContainer:d,inputWrapperOrder:f,label:p,error:m,success:h,description:g,labelProps:_,descriptionProps:v,errorProps:y,successProps:b,labelElement:x,children:S,withAsterisk:C,id:w,required:T,__stylesApiProps:E,mod:D,attributes:O,...k}=t,A=Y({name:[`InputWrapper`,u],props:E||t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:O,vars:s,varsResolver:Qv}),j={size:c,variant:l,__staticSelector:u},M=Am(w),N=typeof C==`boolean`?C:T,P=y?.id||`${M}-error`,ee=b?.id||`${M}-success`,te=v?.id||`${M}-description`,ne=M,re=!!m&&typeof m!=`boolean`,F=!!h&&typeof h!=`boolean`&&!m,ie=!!g,ae=re&&f.includes(`error`),oe=F&&f.includes(`error`),se=ie&&f.includes(`description`),I=`${ae?P:``} ${oe?ee:``} ${se?te:``}`,ce=I.trim().length>0?I.trim():void 0,le=_?.id||`${M}-label`,ue=p&&(0,z.jsx)(Kv,{labelElement:x,id:le,htmlFor:ne,required:N,...j,..._,children:p},`label`),de=ie&&(0,z.jsx)(Vv,{...v,...j,size:v?.size||j.size,id:v?.id||te,children:g},`description`),fe=(0,z.jsx)(R.Fragment,{children:d(S)},`input`),L=re&&(0,R.createElement)(Uv,{...y,...j,size:y?.size||j.size,key:`error`,id:y?.id||P},m),pe=F&&(0,R.createElement)(Yv,{...b,...j,size:b?.size||j.size,key:`success`,id:b?.id||ee},h),me=f.map(e=>{switch(e){case`label`:return ue;case`input`:return fe;case`description`:return de;case`error`:return L||pe;default:return null}});return(0,z.jsx)(Rv,{value:{getStyles:A,describedBy:ce,inputId:ne,labelId:ue&&f.includes(`label`)?le:void 0,...Xv(f,{hasDescription:ie,hasError:re||F})},children:(0,z.jsx)(Z,{variant:l,size:c,mod:[{error:!!m,success:!!h&&!m},D],id:x===`label`?void 0:w,...A(`root`),...k,children:me})})});$v.classes=zv,$v.varsResolver=Qv,$v.displayName=`@mantine/core/InputWrapper`;var ey={variant:`default`,leftSectionPointerEvents:`none`,rightSectionPointerEvents:`none`,withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:`sm`,loading:!1,loadingPosition:`right`},ty=q((e,t,n)=>({wrapper:{"--input-margin-top":n.offsetTop?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-margin-bottom":n.offsetBottom?`calc(var(--mantine-spacing-xs) / 2)`:void 0,"--input-height":Hp(t.size,`input-height`),"--input-fz":Gp(t.size),"--input-radius":t.radius===void 0?void 0:Wp(t.radius),"--input-left-section-width":t.leftSectionWidth===void 0?void 0:K(t.leftSectionWidth),"--input-right-section-width":t.rightSectionWidth===void 0?void 0:K(t.rightSectionWidth),"--input-padding-y":t.multiline?Hp(t.size,`input-padding-y`):void 0,"--input-left-section-pointer-events":t.leftSectionPointerEvents,"--input-right-section-pointer-events":t.rightSectionPointerEvents}})),ny=n_(e=>{let t=J(`Input`,ey,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,required:s,__staticSelector:c,__stylesApiProps:l,size:u,wrapperProps:d,error:f,success:p,disabled:m,leftSection:h,leftSectionProps:g,leftSectionWidth:_,rightSection:v,rightSectionProps:y,rightSectionWidth:b,rightSectionPointerEvents:x,leftSectionPointerEvents:S,variant:C,vars:w,pointer:T,multiline:E,radius:D,id:O,withAria:k,withErrorStyles:A,withSuccessStyles:j,mod:M,inputSize:N,attributes:P,__clearSection:ee,__clearable:te,__clearSectionMode:ne,__defaultRightSection:re,loading:F,loadingPosition:ie,loaderProps:ae,__bottomSection:oe,__bottomSectionProps:se,rootRef:I,dir:ce,...le}=t,{styleProps:ue,rest:de}=Dg(le),fe=(0,R.use)(Rv),L={offsetBottom:fe?.offsetBottom,offsetTop:fe?.offsetTop},pe=Y({name:[`Input`,c],props:l||t,classes:zv,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:P,stylesCtx:L,rootSelector:`wrapper`,vars:w,varsResolver:ty}),me=k?{required:s,disabled:m,"aria-invalid":f?!0:void 0,"aria-describedby":fe?.describedBy,id:fe?.inputId||O}:{},he=F?(0,z.jsx)(hv,{size:ie===`left`?`calc(var(--input-left-section-size) / 2)`:`calc(var(--input-right-section-size) / 2)`,...ae}):null,ge=F&&ie===`left`?he:h,_e=Lv({__clearable:te,__clearSection:ee,rightSection:F&&ie===`right`?he:v,__defaultRightSection:re,size:u,__clearSectionMode:ne});return(0,z.jsx)(Pv,{value:{size:u||`sm`},children:(0,z.jsxs)(Z,{ref:I,dir:ce,...pe(`wrapper`),...ue,...d,mod:[{error:!!f&&A,success:!!p&&!f&&j,pointer:T,disabled:m,multiline:E,withRightSection:!!_e,withLeftSection:!!ge,withBottomSection:!!oe},M],variant:C,size:u,children:[ge&&(0,z.jsx)(`div`,{...g,"data-position":`left`,...pe(`section`,{className:g?.className,style:g?.style}),children:ge}),(0,z.jsx)(Z,{component:`input`,...de,...me,required:s,mod:{disabled:m,error:!!f&&A,success:!!p&&!f&&j},variant:C,__size:N,...pe(`input`)}),oe&&(0,z.jsx)(`div`,{...se,...pe(`bottomSection`,{className:se?.className,style:se?.style}),children:oe}),_e&&(0,z.jsx)(`div`,{...y,"data-position":`right`,...pe(`section`,{className:y?.className,style:y?.style}),children:_e})]})})});ny.classes=zv,ny.varsResolver=ty,ny.Wrapper=$v,ny.Label=Kv,ny.Error=Uv,ny.Success=Yv,ny.Description=Vv,ny.Placeholder=qv,ny.ClearButton=Fv,ny.displayName=`@mantine/core/Input`;function ry(e,t,n){let r=J([`Input`,`InputWrapper`,e],t,n),{label:i,description:a,error:o,success:s,required:c,classNames:l,styles:u,className:d,unstyled:f,__staticSelector:p,__stylesApiProps:m,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,wrapperProps:y,id:b,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,vars:D,mod:O,attributes:k,...A}=r,{styleProps:j,rest:M}=Dg(A),N={label:i,description:a,error:o,success:s,required:c,classNames:l,className:d,__staticSelector:p,__stylesApiProps:m||r,errorProps:h,successProps:g,labelProps:_,descriptionProps:v,unstyled:f,styles:u,size:x,style:S,inputContainer:C,inputWrapperOrder:w,withAsterisk:T,variant:E,id:b,mod:O,attributes:k,...y};return{...M,classNames:l,styles:u,unstyled:f,wrapperProps:{...N,...j},inputProps:{required:c,classNames:l,styles:u,unstyled:f,size:x,__staticSelector:p,__stylesApiProps:m||r,error:o,success:s,variant:E,id:b,attributes:k}}}var iy={__staticSelector:`InputBase`,withAria:!0,size:`sm`},ay=n_(e=>{let{inputProps:t,wrapperProps:n,...r}=ry(`InputBase`,iy,e);return(0,z.jsx)(ny.Wrapper,{...n,children:(0,z.jsx)(ny,{...t,...r})})});ay.classes={...ny.classes,...ny.Wrapper.classes},ay.displayName=`@mantine/core/InputBase`;var oy={gap:{type:`spacing`,property:`gap`},rowGap:{type:`spacing`,property:`rowGap`},columnGap:{type:`spacing`,property:`columnGap`},align:{type:`identity`,property:`alignItems`},justify:{type:`identity`,property:`justifyContent`},wrap:{type:`identity`,property:`flexWrap`},direction:{type:`identity`,property:`flexDirection`}},sy={root:`m_8bffd616`},cy=n_(e=>{let t=J(`Flex`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,gap:c,rowGap:l,columnGap:u,align:d,justify:f,wrap:p,direction:m,attributes:h,...g}=t,_=Y({name:`Flex`,classes:sy,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s}),v=Wh(),y=Xg(),b=Yg({styleProps:{gap:c,rowGap:l,columnGap:u,align:d,justify:f,wrap:p,direction:m},theme:v,data:oy}),x=jh(),S=x&&b.hasResponsiveStyles?Eg(b.styles,b.media):y;return(0,z.jsxs)(z.Fragment,{children:[b.hasResponsiveStyles&&(0,z.jsx)(wg,{selector:`.${S}`,styles:b.styles,media:b.media,deduplicate:x}),(0,z.jsx)(Z,{..._(`root`,{className:S,style:Op(b.inlineStyles)}),...g})]})});cy.classes=sy,cy.displayName=`@mantine/core/Flex`;function ly({style:e,size:t=16,...n}){return(0,z.jsx)(`svg`,{viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{...e,width:K(t),height:K(t),display:`block`},...n,children:(0,z.jsx)(`path`,{d:`M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}ly.displayName=`@mantine/core/AccordionChevron`;var uy={root:`m_b6d8b162`};function dy(e){if(e===`start`)return`start`;if(e===`end`||e)return`end`}var fy={inherit:!1},py=q((e,{variant:t,lineClamp:n,gradient:r,size:i,textWrap:a})=>({root:{"--text-fz":Gp(i),"--text-lh":Kp(i),"--text-gradient":t===`gradient`?ph(r,e):void 0,"--text-line-clamp":typeof n==`number`?n.toString():void 0,"--text-text-wrap":a}})),my=n_(e=>{let t=J(`Text`,fy,e),{lineClamp:n,truncate:r,inline:i,inherit:a,gradient:o,span:s,textWrap:c,__staticSelector:l,vars:u,className:d,style:f,classNames:p,styles:m,unstyled:h,variant:g,mod:_,size:v,attributes:y,...b}=t,x=Y({name:[`Text`,l],props:t,classes:uy,className:d,style:f,classNames:p,styles:m,unstyled:h,attributes:y,vars:u,varsResolver:py});return(0,z.jsx)(Z,{...x(`root`,{focusable:!0}),component:s?`span`:`p`,variant:g,mod:[{truncate:dy(r),lineClamp:typeof n==`number`,inline:i,inherit:a},_],size:v,...b})});my.classes=uy,my.varsResolver=py,my.displayName=`@mantine/core/Text`;function hy({size:e,style:t,...n}){let r=e===void 0?t:{width:K(e),height:K(e),...t};return(0,z.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,z.jsx)(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}var gy={group:`m_11def92b`,root:`m_f85678b6`,image:`m_11f8ac07`,placeholder:`m_104cd71f`},_y=(0,R.createContext)({withinGroup:!1}),vy=q((e,{spacing:t})=>({group:{"--ag-spacing":Up(t)}})),yy=X(e=>{let t=J(`AvatarGroup`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,spacing:c,attributes:l,...u}=t,d=Y({name:`AvatarGroup`,classes:gy,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:l,vars:s,varsResolver:vy,rootSelector:`group`});return(0,z.jsx)(_y,{value:{withinGroup:!0},children:(0,z.jsx)(Z,{...d(`group`),...u})})});yy.classes=gy,yy.varsResolver=vy,yy.displayName=`@mantine/core/AvatarGroup`;function by(e){return(0,z.jsx)(`svg`,{...e,"data-avatar-placeholder-icon":!0,viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,z.jsx)(`path`,{d:`M0.877014 7.49988C0.877014 3.84219 3.84216 0.877045 7.49985 0.877045C11.1575 0.877045 14.1227 3.84219 14.1227 7.49988C14.1227 11.1575 11.1575 14.1227 7.49985 14.1227C3.84216 14.1227 0.877014 11.1575 0.877014 7.49988ZM7.49985 1.82704C4.36683 1.82704 1.82701 4.36686 1.82701 7.49988C1.82701 8.97196 2.38774 10.3131 3.30727 11.3213C4.19074 9.94119 5.73818 9.02499 7.50023 9.02499C9.26206 9.02499 10.8093 9.94097 11.6929 11.3208C12.6121 10.3127 13.1727 8.97172 13.1727 7.49988C13.1727 4.36686 10.6328 1.82704 7.49985 1.82704ZM10.9818 11.9787C10.2839 10.7795 8.9857 9.97499 7.50023 9.97499C6.01458 9.97499 4.71624 10.7797 4.01845 11.9791C4.97952 12.7272 6.18765 13.1727 7.49985 13.1727C8.81227 13.1727 10.0206 12.727 10.9818 11.9787ZM5.14999 6.50487C5.14999 5.207 6.20212 4.15487 7.49999 4.15487C8.79786 4.15487 9.84999 5.207 9.84999 6.50487C9.84999 7.80274 8.79786 8.85487 7.49999 8.85487C6.20212 8.85487 5.14999 7.80274 5.14999 6.50487ZM7.49999 5.10487C6.72679 5.10487 6.09999 5.73167 6.09999 6.50487C6.09999 7.27807 6.72679 7.90487 7.49999 7.90487C8.27319 7.90487 8.89999 7.27807 8.89999 6.50487C8.89999 5.73167 8.27319 5.10487 7.49999 5.10487Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}function xy(e){let t=0;for(let n=0;ne[0]).slice(0,t).join(``).toUpperCase()}var Ty=q((e,{size:t,radius:n,variant:r,gradient:i,color:a,autoContrast:o,name:s,allowedInitialsColors:c})=>{let l=a===`initials`&&typeof s==`string`?Cy(s,c):a,u=e.variantColorResolver({color:l||`gray`,theme:e,gradient:i,variant:r||`light`,autoContrast:o});return{root:{"--avatar-size":Hp(t,`avatar-size`),"--avatar-radius":n===void 0?void 0:Wp(n),"--avatar-bg":l||r?u.background:void 0,"--avatar-color":l||r?u.color:void 0,"--avatar-bd":l||r?u.border:void 0}}}),Ey=n_(e=>{let t=J(`Avatar`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,src:c,alt:l,radius:u,color:d,gradient:f,imageProps:p,children:m,autoContrast:h,mod:g,name:_,allowedInitialsColors:v,attributes:y,...b}=t,x=(0,R.use)(_y),[S,C]=(0,R.useState)(!c),w=Y({name:`Avatar`,props:t,classes:gy,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Ty});return(0,R.useEffect)(()=>C(!c),[c]),(0,z.jsx)(Z,{...w(`root`),mod:[{"within-group":x.withinGroup},g],...b,children:S||!c?(0,z.jsx)(`span`,{...w(`placeholder`),title:l,children:m||typeof _==`string`&&wy(_)||(0,z.jsx)(by,{})}):(0,z.jsx)(`img`,{...p,...w(`image`),src:c,alt:l,onError:e=>{C(!0),p?.onError?.(e)}})})});Ey.classes=gy,Ey.varsResolver=Ty,Ey.displayName=`@mantine/core/Avatar`,Ey.Group=yy;var Dy={root:`m_347db0ec`,"root--dot":`m_fbd81e3d`,label:`m_5add502a`,section:`m_91fdda9b`},Oy=q((e,{radius:t,color:n,gradient:r,variant:i,size:a,autoContrast:o,circle:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:o});return{root:{"--badge-height":Hp(a,`badge-height`),"--badge-padding-x":Hp(a,`badge-padding-x`),"--badge-fz":Hp(a,`badge-fz`),"--badge-radius":s||t===void 0?void 0:Wp(t),"--badge-bg":n||i?c.background:void 0,"--badge-color":n||i?c.color:void 0,"--badge-bd":n||i?c.border:void 0,"--badge-dot-color":i===`dot`?uh(n,e):void 0}}}),ky=n_(e=>{let t=J(`Badge`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,radius:c,color:l,gradient:u,leftSection:d,rightSection:f,children:p,variant:m,fullWidth:h,autoContrast:g,circle:_,mod:v,attributes:y,...b}=t,x=Y({name:`Badge`,props:t,classes:Dy,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:y,vars:s,varsResolver:Oy});return(0,z.jsxs)(Z,{variant:m,mod:[{block:h,circle:_,"with-right-section":!!f,"with-left-section":!!d},v],...x(`root`,{variant:m}),...b,children:[d&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`left`,children:d}),(0,z.jsx)(`span`,{...x(`label`),children:p}),f&&(0,z.jsx)(`span`,{...x(`section`),"data-position":`right`,children:f})]})});ky.classes=Dy,ky.varsResolver=Oy,ky.displayName=`@mantine/core/Badge`;var Ay={root:`m_77c9d27d`,inner:`m_80f1301b`,label:`m_811560b9`,section:`m_a74036a`,loader:`m_a25b86ee`,group:`m_80d6d844`,groupSection:`m_70be2a01`},jy={orientation:`horizontal`},My=q((e,{borderWidth:t})=>({group:{"--button-border-width":K(t)}})),Ny=X(e=>{let t=J(`ButtonGroup`,jy,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,orientation:s,vars:c,borderWidth:l,mod:u,attributes:d,...f}=J(`ButtonGroup`,jy,e),p=Y({name:`ButtonGroup`,props:t,classes:Ay,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:c,varsResolver:My,rootSelector:`group`});return(0,z.jsx)(Z,{...p(`group`),mod:[{orientation:s},u],role:`group`,...f})});Ny.classes=Ay,Ny.varsResolver=My,Ny.displayName=`@mantine/core/ButtonGroup`;var Py=q((e,{radius:t,color:n,gradient:r,variant:i,autoContrast:a,size:o})=>{let s=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:a});return{groupSection:{"--section-height":Hp(o,`section-height`),"--section-padding-x":Hp(o,`section-padding-x`),"--section-fz":o?.includes(`compact`)?Gp(o.replace(`compact-`,``)):Gp(o),"--section-radius":t===void 0?void 0:Wp(t),"--section-bg":n||i?s.background:void 0,"--section-color":s.color,"--section-bd":n||i?s.border:void 0}}}),Fy=X(e=>{let t=J(`ButtonGroupSection`,null,e),{className:n,style:r,classNames:i,styles:a,unstyled:o,vars:s,gradient:c,radius:l,autoContrast:u,attributes:d,...f}=t,p=Y({name:`ButtonGroupSection`,props:t,classes:Ay,className:n,style:r,classNames:i,styles:a,unstyled:o,attributes:d,vars:s,varsResolver:Py,rootSelector:`groupSection`});return(0,z.jsx)(Z,{...p(`groupSection`),...f})});Fy.classes=Ay,Fy.varsResolver=Py,Fy.displayName=`@mantine/core/ButtonGroupSection`;var Iy={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${K(1)}))`},out:{opacity:0,transform:`translate(-50%, -200%)`},common:{transformOrigin:`center`},transitionProperty:`transform, opacity`},Ly=q((e,{radius:t,color:n,gradient:r,variant:i,size:a,justify:o,autoContrast:s})=>{let c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:i||`filled`,autoContrast:s});return{root:{"--button-justify":o,"--button-height":Hp(a,`button-height`),"--button-padding-x":Hp(a,`button-padding-x`),"--button-fz":a?.includes(`compact`)?Gp(a.replace(`compact-`,``)):Gp(a),"--button-radius":t===void 0?void 0:Wp(t),"--button-bg":n||i?c.background:void 0,"--button-hover":n||i?c.hover:void 0,"--button-color":c.color,"--button-bd":n||i?c.border:void 0,"--button-hover-color":n||i?c.hoverColor:void 0}}}),Ry=n_(e=>{let t=J(`Button`,null,e),{style:n,vars:r,className:i,color:a,disabled:o,children:s,leftSection:c,rightSection:l,fullWidth:u,variant:d,radius:f,loading:p,loaderProps:m,gradient:h,classNames:g,styles:_,unstyled:v,"data-disabled":y,autoContrast:b,mod:x,attributes:S,...C}=t,w=Y({name:`Button`,props:t,classes:Ay,className:i,style:n,classNames:g,styles:_,unstyled:v,attributes:S,vars:r,varsResolver:Ly}),T=!!c,E=!!l;return(0,z.jsxs)(p_,{...w(`root`,{active:!o&&!p&&!y}),unstyled:v,variant:d,disabled:o||p,mod:[{disabled:o||y,loading:p,block:u,"with-left-section":T,"with-right-section":E},x],...C,children:[typeof p==`boolean`&&(0,z.jsx)(U_,{mounted:p,transition:Iy,duration:150,children:e=>(0,z.jsx)(Z,{component:`span`,...w(`loader`,{style:e}),"aria-hidden":!0,children:(0,z.jsx)(hv,{color:`var(--button-color)`,size:`calc(var(--button-height) / 1.8)`,...m})})}),(0,z.jsxs)(`span`,{...w(`inner`),children:[c&&(0,z.jsx)(Z,{component:`span`,...w(`section`),mod:{position:`left`},children:c}),(0,z.jsx)(Z,{component:`span`,mod:{loading:p},...w(`label`),children:s}),l&&(0,z.jsx)(Z,{component:`span`,...w(`section`),mod:{position:`right`},children:l})]})]})});Ry.classes=Ay,Ry.varsResolver=Ly,Ry.displayName=`@mantine/core/Button`,Ry.Group=Ny,Ry.GroupSection=Fy;var[zy,By]=jp(`Card component was not found in tree`),Vy={root:`m_e615b15f`,section:`m_599a2148`},Hy=n_(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,withBorder:o,inheritPadding:s,mod:c,...l}=J(`CardSection`,null,e),u=By();return(0,z.jsx)(Z,{mod:[{"with-border":o,"inherit-padding":s},c],...u.getStyles(`section`,{className:n,style:r,styles:i,classNames:t}),...l})});Hy.classes=Vy,Hy.displayName=`@mantine/core/CardSection`;var Uy=q((e,{padding:t})=>({root:{"--card-padding":Up(t)}})),Wy={orientation:`vertical`},Gy=n_(e=>{let t=J(`Card`,Wy,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,children:c,padding:l,attributes:u,orientation:d,...f}=t,p=Y({name:`Card`,props:t,classes:Vy,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,vars:s,varsResolver:Uy}),m=R.Children.toArray(c),h=m.map((e,t)=>typeof e==`object`&&e&&`type`in e&&(e.type===Hy||e.type?.displayName===`@mantine/core/CardSection`)?(0,R.cloneElement)(e,{"data-orientation":d,"data-first-section":t===0||void 0,"data-last-section":t===m.length-1||void 0}):e);return(0,z.jsx)(zy,{value:{getStyles:p},children:(0,z.jsx)(v_,{unstyled:o,"data-orientation":d,...p(`root`),...f,children:h})})});Gy.classes=Vy,Gy.varsResolver=Uy,Gy.displayName=`@mantine/core/Card`,Gy.Section=Hy;var Ky=t_(e=>{let{value:t,defaultValue:n,onChange:r,multiple:i,children:a}=J(`ChipGroup`,null,e),[o,s]=Pm({value:t,defaultValue:n,finalValue:i?[]:null,onChange:r});return(0,z.jsx)(qy,{value:{isChipSelected:e=>Array.isArray(o)?o.includes(e):e===o,onChange:e=>{let t=e.currentTarget.value;s(Array.isArray(o)?o.includes(t)?o.filter(e=>e!==t):[...o,t]:t)},multiple:i},children:a})});Ky.displayName=`@mantine/core/ChipGroup`;var qy=(0,R.createContext)(null),Jy={root:`m_f59ffda3`,label:`m_be049a53`,"label--outline":`m_3904c1af`,"label--filled":`m_fa109255`,"label--light":`m_f7e165c3`,iconWrapper:`m_9ac86df9`,checkIcon:`m_d6d72580`,input:`m_bde07329`},Yy={type:`checkbox`},Xy=q((e,{size:t,radius:n,variant:r,color:i,autoContrast:a})=>{let o=e.variantColorResolver({color:i||e.primaryColor,theme:e,variant:r||`filled`,autoContrast:a});return{root:{"--chip-fz":Gp(t),"--chip-size":Hp(t,`chip-size`),"--chip-radius":n===void 0?void 0:Wp(n),"--chip-checked-padding":Hp(t,`chip-checked-padding`),"--chip-padding":Hp(t,`chip-padding`),"--chip-icon-size":Hp(t,`chip-icon-size`),"--chip-bg":i||r?o.background:void 0,"--chip-hover":i||r?o.hover:void 0,"--chip-color":i||r?o.color:void 0,"--chip-bd":i||r?o.border:void 0,"--chip-spacing":Hp(t,`chip-spacing`)}}}),Zy=X(e=>{let t=J(`Chip`,Yy,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,id:c,checked:l,defaultChecked:u,onChange:d,value:f,wrapperProps:p,type:m,disabled:h,children:g,size:_,variant:v,icon:y,rootRef:b,autoContrast:x,mod:S,attributes:C,readOnly:w,...T}=t,E=Y({name:`Chip`,classes:Jy,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:C,vars:s,varsResolver:Xy}),D=(0,R.use)(qy),O=Am(c),{styleProps:k,rest:A}=Dg(T),[j,M]=Pm({value:l,defaultValue:u,finalValue:!1,onChange:d}),N=D?{checked:D.isChipSelected(f),onChange:e=>{w||(D.onChange(e),d?.(e.currentTarget.checked))},type:D.multiple?`checkbox`:`radio`}:{},P=N.checked||j;return(0,z.jsxs)(Z,{size:_,variant:v,ref:b,mod:S,...E(`root`),...k,...p,children:[(0,z.jsx)(`input`,{type:m,...E(`input`),checked:P,onChange:e=>!w&&M(e.currentTarget.checked),id:O,disabled:h,readOnly:w,value:f,...N,...A}),(0,z.jsxs)(Z,{component:`label`,htmlFor:O,mod:{checked:P,disabled:h},...E(`label`,{variant:v||`filled`}),children:[P&&y!==null&&y!==!1&&(0,z.jsx)(`span`,{...E(`iconWrapper`),children:y===void 0?(0,z.jsx)(hy,{...E(`checkIcon`)}):y}),(0,z.jsx)(`span`,{children:g})]})]})});Zy.classes=Jy,Zy.varsResolver=Xy,Zy.displayName=`@mantine/core/Chip`,Zy.Group=Ky;var Qy={root:`m_3eebeb36`,label:`m_9e365f20`},$y={orientation:`horizontal`},eb=q((e,{color:t,variant:n,size:r})=>({root:{"--divider-color":t?uh(t,e):void 0,"--divider-border-style":n,"--divider-size":Hp(r,`divider-size`)}})),tb=X(e=>{let t=J(`Divider`,$y,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,color:c,orientation:l,label:u,labelPosition:d,mod:f,attributes:p,...m}=t,h=Y({name:`Divider`,classes:Qy,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:eb});return(0,z.jsx)(Z,{mod:[{orientation:l,withLabel:!!u},f],role:`separator`,"aria-orientation":l,...h(`root`),...m,children:u&&(0,z.jsx)(Z,{component:`span`,mod:{position:d},...h(`label`),children:u})})});tb.classes=Qy,tb.varsResolver=eb,tb.displayName=`@mantine/core/Divider`;var nb=t_(e=>{let{onChange:t,children:n,multiple:r,accept:i,name:a,form:o,resetRef:s,disabled:c,capture:l,inputProps:u,ref:d,...f}=J(`FileButton`,null,e),p=(0,R.useRef)(null),m=()=>{!c&&p.current?.click()};return jm(s,()=>{p.current&&(p.current.value=``)}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{style:{display:`none`},type:`file`,accept:i,multiple:r,onChange:e=>{if(e.currentTarget.files===null)return t(r?[]:null);t(r?Array.from(e.currentTarget.files):e.currentTarget.files[0]||null)},ref:Nm(d,p),name:a,form:o,capture:l,...u}),n({onClick:m,...f})]})});nb.displayName=`@mantine/core/FileButton`;var rb={valueComponent:({value:e})=>(0,z.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:Array.isArray(e)?e.map(e=>e.name).join(`, `):e?.name}),size:`sm`},ib=t_(e=>{let t=J([`Input`,`InputWrapper`,`FileInput`],rb,e),{unstyled:n,vars:r,onChange:i,value:a,defaultValue:o,multiple:s,accept:c,name:l,form:u,valueComponent:d,clearable:f,clearSectionMode:p,clearButtonProps:m,readOnly:h,capture:g,fileInputProps:_,rightSection:v,size:y,placeholder:b,component:x,resetRef:S,classNames:C,styles:w,attributes:T,...E}=t,D=(0,R.useRef)(null),{resolvedClassNames:O,resolvedStyles:k}=ag({classNames:C,styles:w,props:t}),[A,j]=Pm({value:a,defaultValue:o,onChange:i,finalValue:s?[]:null}),M=Array.isArray(A)?A.length!==0:A!==null,N=(0,z.jsx)(Ov,{...m,variant:`subtle`,onClick:()=>j(s?[]:null),size:y,unstyled:n}),P=f&&M&&!h;return(0,R.useEffect)(()=>{(Array.isArray(A)&&A.length===0||A===null)&&D.current?.()},[A]),(0,z.jsx)(nb,{onChange:j,multiple:s,accept:c,name:l,form:u,resetRef:Nm(D,S),disabled:h,capture:g,inputProps:_,children:e=>(0,z.jsx)(ay,{component:x||`button`,rightSection:v,__clearSection:N,__clearable:P,__clearSectionMode:p,...e,...E,__staticSelector:`FileInput`,multiline:!0,type:`button`,pointer:!0,__stylesApiProps:t,unstyled:n,size:y,classNames:C,styles:w,attributes:T,children:M?(0,z.jsx)(d,{value:A}):(0,z.jsx)(ny.Placeholder,{__staticSelector:`FileInput`,classNames:O,styles:k,attributes:T,children:b})})})});ib.classes=ay.classes,ib.displayName=`@mantine/core/FileInput`;var ab={root:`m_6e45937b`,loader:`m_e8eb006c`,overlay:`m_df587f17`},ob={transitionProps:{transition:`fade`,duration:0},overlayProps:{backgroundOpacity:.75},zIndex:zp(`overlay`)},sb=q((e,{zIndex:t})=>({root:{"--lo-z-index":t?.toString()}})),cb=X(e=>{let t=J(`LoadingOverlay`,ob,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,transitionProps:c,loaderProps:l,overlayProps:u,visible:d,zIndex:f,attributes:p,onEnter:m,onEntered:h,onExit:g,onExited:_,...v}=t,y=Wh(),b=Y({name:`LoadingOverlay`,classes:ab,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:p,vars:s,varsResolver:sb}),x={...ob.overlayProps,...u};return(0,z.jsx)(U_,{transition:`fade`,...c,mounted:!!d,onEnter:m,onEntered:h,onExit:g,onExited:_,children:e=>(0,z.jsxs)(Z,{...b(`root`,{style:e}),...v,children:[(0,z.jsx)(hv,{unstyled:o,...l,...b(`loader`,{className:l?.className,style:l?.style})}),(0,z.jsx)(j_,{...x,...b(`overlay`,{className:x?.className,style:x?.style}),darkHidden:!0,unstyled:o,color:u?.color||y.white}),(0,z.jsx)(j_,{...x,...b(`overlay`,{className:x?.className,style:x?.style}),lightHidden:!0,unstyled:o,color:u?.color||y.colors.dark[5]})]})})});cb.classes=ab,cb.varsResolver=sb,cb.displayName=`@mantine/core/LoadingOverlay`;var[lb,ub]=jp(`Menu component was not found in the tree`),db=(0,R.createContext)(null);function fb(e){let{value:t,defaultValue:n,onChange:r,children:i}=J(`MenuCheckboxGroup`,null,e),[a,o]=Pm({value:t,defaultValue:n,finalValue:[],onChange:r}),s=(0,R.useCallback)(e=>{o(a.includes(e)?a.filter(t=>t!==e):[...a,e])},[a,o]);return(0,z.jsx)(db,{value:{values:a,onChange:s},children:i})}fb.displayName=`@mantine/core/MenuCheckboxGroup`;var pb=(0,R.createContext)(null);function mb({role:e,checked:t,indicator:n,onSelect:r,color:i,closeMenuOnClick:a,rightSection:o,children:s,disabled:c,dataDisabled:l,className:u,style:d,styles:f,classNames:p,buttonRef:m,others:h}){let g=ub(),_=(0,R.use)(pb),v=Wh(),{dir:y}=u_(),b=y===`rtl`?`ArrowRight`:`ArrowLeft`,x=(0,R.useRef)(null),S=Jp(h.onClick,()=>{l||(r(),a&&g.closeDropdownImmediately())}),C=Jp(h.onMouseMove,()=>{if(!g.hasSearch)return;let e=x.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==x.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),w=Jp(h.onKeyDown,e=>{e.key===b&&_&&(_.close(),_.focusParentItem())}),T=i?v.variantColorResolver({color:i,theme:v,variant:`light`}):void 0,E=i?lh({color:i,theme:v}):null,D=g.alignItemsLabels!==`none`||t;return(0,z.jsxs)(p_,{onMouseDown:e=>e.preventDefault(),...h,unstyled:g.unstyled,tabIndex:g.menuItemTabIndex,...g.getStyles(`item`,{className:u,style:d,styles:f,classNames:p}),ref:Nm(x,m),role:e,"aria-checked":t,disabled:c,"aria-disabled":h[`aria-disabled`]??(c||l||void 0),"data-menu-item":!0,"data-checked":t||void 0,"data-disabled":c||l||void 0,"data-mantine-stop-propagation":!0,onClick:S,onMouseMove:C,onKeyDown:Lp({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:g.loop,dir:y,orientation:`vertical`,onKeyDown:w}),__vars:{"--menu-item-color":E?.isThemeColor&&E?.shade===void 0?`var(--mantine-color-${E.color}-6)`:T?.color,"--menu-item-hover":T?.hover},children:[D&&(0,z.jsx)(`div`,{...g.getStyles(`itemIndicator`,{styles:f,classNames:p}),"data-checked":t||void 0,children:t?n:null}),s&&(0,z.jsx)(`div`,{...g.getStyles(`itemLabel`,{styles:f,classNames:p}),"data-menu-item-label":!0,children:s}),o&&(0,z.jsx)(`div`,{...g.getStyles(`itemSection`,{styles:f,classNames:p}),"data-position":`right`,children:o})]})}var hb={dropdown:`m_dc9b7c9f`,label:`m_9bfac126`,divider:`m_efdf90cb`,item:`m_99ac2aa1`,search:`m_ef8769b6`,itemLabel:`m_5476e0d3`,itemIndicator:`m_8395186e`,itemSection:`m_8b75e504`,chevron:`m_b85b0bed`},gb=X(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,color:o,closeMenuOnClick:s,rightSection:c,children:l,disabled:u,"data-disabled":d,value:f,checked:p,defaultChecked:m,onChange:h,checkIcon:g,ref:_,...v}=J(`MenuCheckboxItem`,null,e),y=ub(),b=(0,R.use)(db),x=b&&f!==void 0?b.values.includes(f):void 0,[S,C]=Pm({value:p??x,defaultValue:m,finalValue:!1,onChange:h}),w=g??y.checkIcon??(0,z.jsx)(hy,{size:10});return(0,z.jsx)(mb,{role:`menuitemcheckbox`,checked:S,indicator:w,onSelect:()=>{h?C(!S):b&&f!==void 0?b.onChange(f):C(!S)},color:o,closeMenuOnClick:s,rightSection:c,disabled:u,dataDisabled:d,className:n,style:r,styles:i,classNames:t,buttonRef:_,others:v,children:l})});gb.classes=hb,gb.displayName=`@mantine/core/MenuCheckboxItem`;function _b(e){let{children:t,disabled:n,longPressDelay:r}=J(`MenuContextMenu`,null,e),i=Wm(t);if(!i)throw Error(`Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let a=ub(),o=q_(),s=J_({childProps:i.props,disabled:n||o.disabled,opened:a.opened,longPressDelay:r,setReference:o.reference,open:()=>a.openDropdown()});return(0,R.cloneElement)(i,s)}_b.displayName=`@mantine/core/MenuContextMenu`;var vb=X(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=J(`MenuDivider`,null,e),s=ub();return(0,z.jsx)(Z,{...s.getStyles(`divider`,{className:n,style:r,styles:i,classNames:t}),...o})});vb.classes=hb,vb.displayName=`@mantine/core/MenuDivider`;var yb=500;function bb(e){return((e.querySelector(`[data-menu-item-label]`)??e).textContent??``).trim().toLowerCase()}function xb(e){return e.length>1&&e.split(``).every(t=>t===e[0])}function Sb({enabled:e,opened:t,getDropdown:n}){let r=(0,R.useRef)({buffer:``,timeoutId:null});return(0,R.useEffect)(()=>{if(t&&e)return;let n=r.current;n.timeoutId!==null&&(window.clearTimeout(n.timeoutId),n.timeoutId=null),n.buffer=``},[t,e]),(0,R.useEffect)(()=>()=>{let{timeoutId:e}=r.current;e!==null&&window.clearTimeout(e)},[]),t=>{if(!e||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.key.length!==1||t.key===` `)return;let i=t.target;if(i&&(i.tagName===`INPUT`||i.tagName===`TEXTAREA`||i.tagName===`SELECT`||i.isContentEditable))return;let a=n();if(!a)return;let o=Array.from(a.querySelectorAll(`[data-menu-item]:not([data-disabled])`)).filter(e=>e.closest(`[data-menu-dropdown]`)===a);if(o.length===0)return;let s=r.current;s.buffer=(s.buffer+t.key).toLowerCase(),s.timeoutId!==null&&window.clearTimeout(s.timeoutId),s.timeoutId=window.setTimeout(()=>{s.buffer=``,s.timeoutId=null},yb);let c=document.activeElement,l=c?o.indexOf(c):-1,u=null;if(s.buffer.length===1||xb(s.buffer)){let e=s.buffer[0],t=l+1;for(let n=0;n{let{classNames:t,className:n,style:r,styles:i,vars:a,onMouseEnter:o,onMouseLeave:s,onKeyDown:c,children:l,ref:u,...d}=J(`MenuDropdown`,null,e),f=(0,R.useRef)(null),p=ub(),m=Sb({enabled:!p.hasSearch,opened:p.opened,getDropdown:()=>f.current}),h=Jp(c,e=>{m(e),e.defaultPrevented||p.hasSearch||(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),f.current?.querySelectorAll(`[data-menu-item]:not(:disabled)`)[0]?.focus())}),g=Jp(o,()=>(p.trigger===`hover`||p.trigger===`click-hover`)&&p.openDropdown()),_=Jp(s,()=>(p.trigger===`hover`||p.trigger===`click-hover`)&&p.closeDropdown());return(0,z.jsxs)(sv.Dropdown,{...d,onMouseEnter:g,onMouseLeave:_,role:`menu`,"aria-orientation":`vertical`,ref:Nm(u,f),...p.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:h,children:[p.withInitialFocusPlaceholder&&!p.hasSearch&&(0,z.jsx)(`div`,{role:`presentation`,tabIndex:-1,"data-autofocus":!0,"data-mantine-stop-propagation":!0,style:{outline:0}}),l]})});Cb.classes=hb,Cb.displayName=`@mantine/core/MenuDropdown`;var wb=n_(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,color:o,closeMenuOnClick:s,leftSection:c,rightSection:l,children:u,disabled:d,"data-disabled":f,ref:p,...m}=J(`MenuItem`,null,e),h=ub(),g=(0,R.use)(pb),_=Wh(),{dir:v}=u_(),y=v===`rtl`?`ArrowRight`:`ArrowLeft`,b=(0,R.useRef)(null),x=m,S=Jp(x.onClick,()=>{f||(typeof s==`boolean`?s&&h.closeDropdownImmediately():h.closeOnItemClick&&h.closeDropdownImmediately())}),C=Jp(x.onMouseMove,()=>{if(!h.hasSearch)return;let e=b.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==b.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),w=o?_.variantColorResolver({color:o,theme:_,variant:`light`}):void 0,T=o?lh({color:o,theme:_}):null,E=Jp(x.onKeyDown,e=>{e.key===y&&g&&(g.close(),g.focusParentItem())});return(0,z.jsxs)(p_,{onMouseDown:e=>e.preventDefault(),...m,unstyled:h.unstyled,tabIndex:h.menuItemTabIndex,...h.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:Nm(b,p),role:`menuitem`,disabled:d,"aria-disabled":x[`aria-disabled`]??(d||f||void 0),"data-menu-item":!0,"data-disabled":d||f||void 0,"data-mantine-stop-propagation":!0,onClick:S,onMouseMove:C,onKeyDown:Lp({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:h.loop,dir:v,orientation:`vertical`,onKeyDown:E}),__vars:{"--menu-item-color":T?.isThemeColor&&T?.shade===void 0?`var(--mantine-color-${T.color}-6)`:w?.color,"--menu-item-hover":w?.hover},children:[h.alignItemsLabels===`all`&&(0,z.jsx)(`div`,{...h.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),c&&(0,z.jsx)(`div`,{...h.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:c}),u&&(0,z.jsx)(`div`,{...h.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:u}),l&&(0,z.jsx)(`div`,{...h.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:l})]})});wb.classes=hb,wb.displayName=`@mantine/core/MenuItem`;var Tb=X(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=J(`MenuLabel`,null,e),s=ub();return(0,z.jsx)(Z,{...s.getStyles(`label`,{className:n,style:r,styles:i,classNames:t}),...o})});Tb.classes=hb,Tb.displayName=`@mantine/core/MenuLabel`;var Eb=(0,R.createContext)(null);function Db(e){let{value:t,defaultValue:n,onChange:r,children:i}=J(`MenuRadioGroup`,null,e),[a,o]=Pm({value:t,defaultValue:n,finalValue:null,onChange:r});return(0,z.jsx)(Eb,{value:{value:a,onChange:e=>o(e)},children:i})}Db.displayName=`@mantine/core/MenuRadioGroup`;function Ob({size:e,style:t,...n}){return(0,z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:K(e),height:K(e),...t},"aria-hidden":!0,...n,children:(0,z.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var kb=X(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,color:o,closeMenuOnClick:s,rightSection:c,children:l,disabled:u,"data-disabled":d,value:f,checked:p,onChange:m,checkIcon:h,ref:g,..._}=J(`MenuRadioItem`,null,e),v=ub(),y=(0,R.use)(Eb),b=p??(y?y.value===f:!1),x=h??v.checkIcon??(0,z.jsx)(Ob,{size:5});return(0,z.jsx)(mb,{role:`menuitemradio`,checked:b,indicator:x,onSelect:()=>{b||(m?m(f):y&&y.onChange(f))},color:o,closeMenuOnClick:s,rightSection:c,disabled:u,dataDisabled:d,className:n,style:r,styles:i,classNames:t,buttonRef:g,others:_,children:l})});kb.classes=hb,kb.displayName=`@mantine/core/MenuRadioItem`;var Ab=`[data-menu-item]:not([data-disabled])`,jb=`[data-menu-active]`;function Mb(e){return e?.closest(`[data-menu-dropdown]`)}function Nb(e){return e?Array.from(e.querySelectorAll(Ab)).filter(t=>t.closest(`[data-menu-dropdown]`)===e):[]}function Pb(e){e&&e.querySelectorAll(jb).forEach(t=>{t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}function Fb(e,t){Pb(t),e&&(e.setAttribute(`data-menu-active`,`true`),e.scrollIntoView({block:`nearest`}))}function Ib(e){return e.findIndex(e=>e.hasAttribute(`data-menu-active`))}var Lb={clearSearchOnClose:!0},Rb=X(e=>{let{classNames:t,styles:n,onKeyDown:r,onChange:i,size:a,clearSearchOnClose:o,ref:s,...c}=J(`MenuSearch`,Lb,e),l=ub(),{dir:u}=u_(),d=(0,R.useRef)(null),f=Nm(s,d),p=(0,R.useRef)(i);p.current=i,(0,R.useEffect)(()=>l.registerSearch(),[l.registerSearch]),(0,R.useEffect)(()=>{o?l.searchExitClearRef.current=()=>{p.current?.({currentTarget:{value:``}})}:l.searchExitClearRef.current=null},[o,l.searchExitClearRef]),(0,R.useEffect)(()=>{l.opened||Pb(Mb(d.current))},[l.opened]);let m=Jp(i,e=>{Pb(Mb(e.currentTarget))}),h=Jp(r,e=>{if(e.defaultPrevented)return;let t=Mb(e.currentTarget),n=Nb(t);if(e.key===`ArrowDown`){if(e.preventDefault(),n.length===0)return;let r=Ib(n);Fb(n[r>=n.length-1?l.loop?0:r:r+1]??null,t)}else if(e.key===`ArrowUp`){if(e.preventDefault(),n.length===0)return;let r=Ib(n);Fb(n[r<=0?r===-1||l.loop?n.length-1:0:r-1]??null,t)}else if(e.key===`Home`)e.preventDefault(),n.length>0&&Fb(n[0],t);else if(e.key===`End`)e.preventDefault(),n.length>0&&Fb(n[n.length-1],t);else if(e.key===`Enter`){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;let t=n[Ib(n)];t&&(e.preventDefault(),t.hasAttribute(`data-sub-menu-item`)?(t.focus(),t.dispatchEvent(new KeyboardEvent(`keydown`,{key:u===`rtl`?`ArrowLeft`:`ArrowRight`,bubbles:!0}))):t.click())}}),g=l.getStyles(`search`);return(0,z.jsx)(ny,{"data-autofocus":!0,"data-mantine-stop-propagation":!0,type:`search`,size:a,...c,ref:f,classNames:[{input:g.className},t],styles:[{input:g.style},n],onKeyDown:h,onChange:m,__staticSelector:`Menu`})});Rb.classes=hb,Rb.displayName=`@mantine/core/MenuSearch`;var zb=X(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,onMouseEnter:o,onMouseLeave:s,onPointerEnter:c,onPointerLeave:l,onKeyDown:u,children:d,ref:f,...p}=J(`MenuSubDropdown`,null,e),m=(0,R.useRef)(null),h=ub(),g=(0,R.use)(pb),_=Sb({enabled:!h.hasSearch,opened:g?.opened??!1,getDropdown:()=>m.current}),v=Jp(u,e=>{_(e),e.ctrlKey||e.metaKey||e.altKey||e.key.length!==1||e.key===` `||e.stopPropagation()}),y=g?.getFloatingProps({onMouseEnter:o,onMouseLeave:s,onPointerEnter:c,onPointerLeave:l});return(0,z.jsx)(sv.Dropdown,{...p,...y,role:`menu`,"aria-orientation":`vertical`,ref:Nm(f,m,g?.setFloating),...h.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:v,children:d})});zb.classes=hb,zb.displayName=`@mantine/core/MenuSubDropdown`;var Bb=n_(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,color:o,leftSection:s,rightSection:c,children:l,disabled:u,"data-disabled":d,closeMenuOnClick:f,ref:p,...m}=J(`MenuSubItem`,null,e),h=ub(),g=(0,R.use)(pb),_=Wh(),{dir:v}=u_(),y=v===`rtl`?`ArrowLeft`:`ArrowRight`,b=v===`rtl`?`ArrowRight`:`ArrowLeft`,x=(0,R.useRef)(null),S=m,C=o?_.variantColorResolver({color:o,theme:_,variant:`light`}):void 0,w=o?lh({color:o,theme:_}):null,T=Jp(S.onKeyDown,e=>{e.key===y&&(g?.open(),g?.focusFirstItem()),e.key===b&&g?.parentContext&&(g.parentContext.close(),g.parentContext.focusParentItem())}),E=Jp(S.onClick,()=>{!d&&f&&h.closeDropdownImmediately()}),D=Jp(S.onMouseMove,()=>{if(!h.hasSearch)return;let e=x.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==x.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),O=g?.getReferenceProps({onMouseEnter:S.onMouseEnter,onMouseLeave:S.onMouseLeave,onPointerEnter:S.onPointerEnter,onPointerLeave:S.onPointerLeave});return(0,z.jsxs)(p_,{onMouseDown:e=>e.preventDefault(),...m,...O,unstyled:h.unstyled,tabIndex:h.menuItemTabIndex,...h.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:Nm(x,p,g?.setReference),role:`menuitem`,disabled:u,"aria-disabled":S[`aria-disabled`]??(u||d||void 0),"data-menu-item":!0,"data-sub-menu-item":!0,"data-disabled":u||d||void 0,"data-mantine-stop-propagation":!0,onClick:E,onMouseMove:D,onKeyDown:Lp({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:h.loop,dir:v,orientation:`vertical`,onKeyDown:T}),__vars:{"--menu-item-color":w?.isThemeColor&&w?.shade===void 0?`var(--mantine-color-${w.color}-6)`:C?.color,"--menu-item-hover":C?.hover},children:[h.alignItemsLabels===`all`&&(0,z.jsx)(`div`,{...h.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),s&&(0,z.jsx)(`div`,{...h.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:s}),l&&(0,z.jsx)(`div`,{...h.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:l}),(0,z.jsx)(`div`,{...h.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:c||(0,z.jsx)(ly,{...h.getStyles(`chevron`),size:14})})]})});Bb.classes=hb,Bb.displayName=`@mantine/core/MenuSubItem`;function Vb({children:e,refProp:t}){if(!Ap(e))throw Error(`Menu.Sub.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return ub(),(0,z.jsx)(sv.Target,{refProp:t,popupType:`menu`,children:e})}Vb.displayName=`@mantine/core/MenuSubTarget`;var Hb={offset:0,position:`right-start`,safeAreaPolygon:!0,transitionProps:{duration:0},openDelay:0,middlewares:{shift:{crossAxis:!0}}};function Ub(e){let{children:t,closeDelay:n,openDelay:r,position:i,safeAreaPolygon:a,opened:o,onChange:s,...c}=J(`MenuSub`,Hb,e),l=Am(),[u,d]=Pm({value:o,finalValue:!1,onChange:s}),f=(0,R.use)(pb),p=ub(),{dir:m}=u_(),h=E_(m,i),g=f?.registerOpenSub??p.registerOpenSub,_=(0,R.useRef)(null),v=(0,R.useCallback)(e=>{let t=_.current;return t&&t!==e&&t(),_.current=e,()=>{_.current===e&&(_.current=null)}},[]),y=(0,R.useRef)(d);y.current=d;let b=(0,R.useCallback)(()=>y.current(!0),[]),x=(0,R.useCallback)(()=>y.current(!1),[]);(0,R.useEffect)(()=>{if(u)return g(x)},[u,g,x]);let{context:S,refs:C}=ds({placement:h,open:u,onOpenChange:e=>{e?b():x()}}),{getReferenceProps:w,getFloatingProps:T}=hs([xo(S,{handleClose:a?Es(typeof a==`object`?a:void 0):void 0,delay:{open:r,close:n}})]);return(0,z.jsx)(pb,{value:{opened:u,close:x,open:b,focusFirstItem:()=>window.setTimeout(()=>{document.getElementById(`${l}-dropdown`)?.querySelectorAll(`[data-menu-item]:not([data-disabled])`)[0]?.focus()},16),focusParentItem:()=>window.setTimeout(()=>{document.getElementById(l)?.focus()},16),parentContext:f,setReference:C.setReference,setFloating:C.setFloating,getReferenceProps:w,getFloatingProps:T,registerOpenSub:v},children:(0,z.jsx)(sv,{opened:u,onChange:e=>e?b():x(),withArrow:!1,id:l,position:i,...c,withinPortal:!1,children:t})})}Ub.extend=e=>e,Ub.displayName=`@mantine/core/MenuSub`,Ub.Target=Vb,Ub.Dropdown=zb,Ub.Item=Bb;var Wb={refProp:`ref`};function Gb(e){let{children:t,refProp:n,...r}=J(`MenuTarget`,Wb,e),i=Wm(t);if(!i)throw Error(`Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let a=ub(),o=i.props,s=Jp(o.onClick,()=>{a.trigger===`click`?a.toggleDropdown():a.trigger===`click-hover`&&(a.setOpenedViaClick(!0),a.opened||a.openDropdown())}),c=Jp(o.onMouseEnter,()=>(a.trigger===`hover`||a.trigger===`click-hover`)&&a.openDropdown()),l=Jp(o.onMouseLeave,()=>{(a.trigger===`hover`||a.trigger===`click-hover`&&!a.openedViaClick)&&a.closeDropdown()});return(0,z.jsx)(sv.Target,{refProp:n,popupType:`menu`,...r,children:(0,R.cloneElement)(i,{onClick:s,onMouseEnter:c,onMouseLeave:l,"data-expanded":a.opened?!0:void 0})})}Gb.displayName=`@mantine/core/MenuTarget`;var Kb={trapFocus:!0,closeOnItemClick:!0,withInitialFocusPlaceholder:!0,clickOutsideEvents:[`mousedown`,`touchstart`,`keydown`],loop:!0,trigger:`click`,openDelay:0,closeDelay:100,menuItemTabIndex:-1,alignItemsLabels:`with-indicators`},Q=X(e=>{let t=J(`Menu`,Kb,e),{children:n,onOpen:r,onClose:i,opened:a,defaultOpened:o,trapFocus:s,onChange:c,closeOnItemClick:l,loop:u,closeOnEscape:d,trigger:f,openDelay:p,closeDelay:m,classNames:h,styles:g,unstyled:_,variant:v,vars:y,menuItemTabIndex:b,keepMounted:x,withInitialFocusPlaceholder:S,attributes:C,onExitTransitionEnd:w,alignItemsLabels:T,checkIcon:E,...D}=t,O=Y({name:`Menu`,classes:hb,props:t,classNames:h,styles:g,unstyled:_,attributes:C}),[k,A]=Pm({value:a,defaultValue:o,finalValue:!1,onChange:c}),[j,M]=(0,R.useState)(!1),N=()=>{A(!1),M(!1),k&&i?.()},P=()=>{A(!0),!k&&r?.()},ee=()=>{k?N():P()},{openDropdown:te,closeDropdown:ne}=D_({open:P,close:N,closeDelay:m,openDelay:p}),re=(0,R.useRef)(null),F=(0,R.useCallback)(e=>{let t=re.current;return t&&t!==e&&t(),re.current=e,()=>{re.current===e&&(re.current=null)}},[]),ie=(0,R.useRef)(0),[ae,oe]=(0,R.useState)(!1),se=(0,R.useCallback)(()=>(ie.current+=1,ie.current===1&&oe(!0),()=>{--ie.current,ie.current===0&&oe(!1)}),[]),I=(0,R.useRef)(null),ce=()=>{I.current?.(),w?.()},le=e=>Yp(`[data-menu-item]`,`[data-menu-dropdown]`,e),{resolvedClassNames:ue,resolvedStyles:de}=ag({classNames:h,styles:g,props:t});return(0,z.jsx)(lb,{value:{getStyles:O,opened:k,toggleDropdown:ee,getItemIndex:le,openedViaClick:j,setOpenedViaClick:M,closeOnItemClick:l,closeDropdown:f===`click`?N:ne,openDropdown:f===`click`?P:te,closeDropdownImmediately:N,loop:u,trigger:f,unstyled:_,menuItemTabIndex:b,withInitialFocusPlaceholder:S,registerOpenSub:F,hasSearch:ae,registerSearch:se,searchExitClearRef:I,alignItemsLabels:T,checkIcon:E},children:(0,z.jsx)(sv,{returnFocus:!0,...D,opened:k,onChange:ee,defaultOpened:o,trapFocus:!x&&s,closeOnEscape:d,__staticSelector:`Menu`,classNames:ue,styles:de,unstyled:_,variant:v,keepMounted:x,onExitTransitionEnd:ce,children:n})})});Q.displayName=`@mantine/core/Menu`,Q.classes=hb,Q.Item=wb,Q.Label=Tb,Q.Dropdown=Cb,Q.Target=Gb,Q.Divider=vb,Q.Search=Rb,Q.Sub=Ub,Q.CheckboxItem=gb,Q.CheckboxGroup=fb,Q.RadioItem=kb,Q.RadioGroup=Db,Q.ContextMenu=_b;function qb({offset:e,position:t,defaultOpened:n}){let[r,i]=(0,R.useState)(n),a=(0,R.useRef)(null),{x:o,y:s,elements:c,refs:l,update:u,placement:d}=ds({placement:t,middleware:[Ba({crossAxis:!0,padding:5,rootBoundary:`document`})]}),f=d.includes(`right`)?e:t.includes(`left`)?e*-1:0,p=d.includes(`bottom`)?e:t.includes(`top`)?e*-1:0,m=(0,R.useCallback)(({clientX:e,clientY:t})=>{Number.isFinite(e)&&Number.isFinite(t)&&l.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,left:e+f,top:t+p,right:e,bottom:t}}})},[c.reference]);return(0,R.useEffect)(()=>{if(l.floating.current){let e=a.current;e.addEventListener(`mousemove`,m);let t=Ln(l.floating.current);return t.forEach(e=>{e.addEventListener(`scroll`,u)}),()=>{e.removeEventListener(`mousemove`,m),t.forEach(e=>{e.removeEventListener(`scroll`,u)})}}},[c.reference,l.floating.current,u,m,r]),{handleMouseMove:m,x:o,y:s,opened:r,setOpened:i,boundaryRef:a,floating:l.setFloating}}var Jb={tooltip:`m_1b3c8819`,arrow:`m_f898399f`},Yb={refProp:`ref`,withinPortal:!0,offset:10,position:`right`,zIndex:zp(`popover`)},Xb=q((e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:Wp(t),"--tooltip-bg":n?uh(n,e):void 0,"--tooltip-color":n?`var(--mantine-color-white)`:void 0}})),Zb=X(e=>{let t=J(`TooltipFloating`,Yb,e),{children:n,refProp:r,withinPortal:i,style:a,className:o,classNames:s,styles:c,unstyled:l,radius:u,color:d,label:f,offset:p,position:m,multiline:h,zIndex:g,disabled:_,defaultOpened:v,variant:y,vars:b,portalProps:x,attributes:S,ref:C,...w}=t,T=Wh(),E=Y({name:`TooltipFloating`,props:t,classes:Jb,className:o,style:a,classNames:s,styles:c,unstyled:l,attributes:S,rootSelector:`tooltip`,vars:b,varsResolver:Xb}),{handleMouseMove:D,x:O,y:k,opened:A,boundaryRef:j,floating:M,setOpened:N}=qb({offset:p,position:m,defaultOpened:v}),P=Wm(n);if(!P)throw Error(`[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported`);let ee=Nm(j,Um(P),C),te=P.props,ne=e=>{te.onMouseEnter?.(e),D(e),N(!0)},re=e=>{te.onMouseLeave?.(e),N(!1)};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L_,{...x,withinPortal:i,children:(0,z.jsx)(Z,{...w,...E(`tooltip`,{style:{...Zg(a,T),zIndex:g,display:!_&&A?`block`:`none`,top:Number.isFinite(k)?Math.round(k):``,left:Number.isFinite(O)?Math.round(O):``}}),variant:y,ref:M,mod:{multiline:h},children:f})}),(0,R.cloneElement)(P,{...te,[r]:ee,onMouseEnter:ne,onMouseLeave:re})]})});Zb.classes=Jb,Zb.varsResolver=Xb,Zb.displayName=`@mantine/core/TooltipFloating`;var Qb=(0,R.createContext)({withinGroup:!1}),$b={openDelay:0,closeDelay:0};function ex(e){let{openDelay:t,closeDelay:n,children:r}=J(`TooltipGroup`,$b,e);return(0,z.jsx)(Qb,{value:{withinGroup:!0},children:(0,z.jsx)(To,{delay:{open:t,close:n},children:r})})}ex.displayName=`@mantine/core/TooltipGroup`,ex.extend=e=>e;function tx(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function nx(e){let t=tx(e.middlewares),n=[za(e.offset),Ga()];return t.shift&&n.push(Ba(typeof t.shift==`boolean`?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip==`boolean`?Ha():Ha(t.flip)),n.push(qa({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline==`boolean`?Ka():Ka(t.inline)):e.inline&&n.push(Ka()),n}function rx(e){let[t,n]=(0,R.useState)(e.defaultOpened),r=typeof e.opened==`boolean`,i=!e.disabled&&(r?e.opened:t);(0,R.useEffect)(()=>{e.disabled&&n(!1)},[e.disabled]);let a=(0,R.use)(Qb).withinGroup,o=Am(),s=Ah(),c=(0,R.useCallback)(e=>{n(e),e&&y(o)},[o]),{x:l,y:u,context:d,refs:f,placement:p,middlewareData:{arrow:{x:m,y:h}={},hide:g}}=ds({strategy:e.strategy,placement:e.position,open:i,onOpenChange:c,middleware:nx(e),whileElementsMounted:xa}),{delay:_,currentId:v,setCurrentId:y}=Eo(d,{id:o}),{getReferenceProps:b,getFloatingProps:x}=hs([xo(d,{enabled:!e.disabled&&e.events?.hover,delay:a?_:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch,handleClose:e.interactive?Es():null}),ps(d,{enabled:!e.disabled&&e.events?.focus,visibleOnly:!0}),_s(d,{role:`tooltip`}),ls(d,{enabled:e.opened===void 0})]),S=(0,R.useRef)(p);tm(()=>{S.current!==p&&(S.current=p,e.onPositionChange?.(p))},[p]);let C=i&&v&&v!==o;return{x:l,y:u,arrowX:m,arrowY:h,reference:f.setReference,floating:f.setFloating,getFloatingProps:x,getReferenceProps:b,isGroupPhase:C,opened:i,placement:p,referenceHidden:e.hideDetached&&s!==`test`?g?.referenceHidden:!1}}var ix={position:`top`,refProp:`ref`,withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,offset:5,transitionProps:{duration:100,transition:`fade`},events:{hover:!0,focus:!1,touch:!1},zIndex:zp(`popover`),middlewares:{flip:!0,shift:!0,inline:!1},hideDetached:!0},ax=q((e,{radius:t,color:n,variant:r,autoContrast:i})=>{let a=e.variantColorResolver({theme:e,color:n||e.primaryColor,autoContrast:i,variant:r||`filled`});return{tooltip:{"--tooltip-radius":t===void 0?void 0:Wp(t),"--tooltip-bg":n?a.background:void 0,"--tooltip-color":n?a.color:void 0}}}),ox=X(e=>{let t=J(`Tooltip`,ix,e),{children:n,position:r,refProp:i,label:a,openDelay:o,closeDelay:s,onPositionChange:c,opened:l,defaultOpened:u,withinPortal:d,radius:f,color:p,classNames:m,styles:h,unstyled:g,style:_,className:v,withArrow:y,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,offset:w,transitionProps:T,multiline:E,events:D,interactive:O,zIndex:k,disabled:A,onClick:j,onMouseEnter:M,onMouseLeave:N,inline:P,variant:ee,keepMounted:te,vars:ne,portalProps:re,mod:F,floatingStrategy:ie,middlewares:ae,autoContrast:oe,attributes:se,target:I,hideDetached:ce,ref:le,...ue}=t,{dir:de}=u_(),fe=(0,R.useRef)(null),L=rx({position:E_(de,r),closeDelay:s,openDelay:o,onPositionChange:c,opened:l,defaultOpened:u,disabled:A,events:D,interactive:O,arrowRef:fe,arrowOffset:x,offset:typeof w==`number`?w+(y?b/2:0):w,inline:P,strategy:ie,middlewares:ae,hideDetached:ce});(0,R.useEffect)(()=>{let e=I instanceof HTMLElement?I:typeof I==`string`?document.querySelector(I):I?.current||null;e&&L.reference(e)},[I,L]);let pe=Y({name:`Tooltip`,props:t,classes:Jb,className:v,style:_,classNames:m,styles:h,unstyled:g,attributes:se,rootSelector:`tooltip`,vars:ne,varsResolver:ax}),me=Wm(n);if(!I&&!me)throw Error(`[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported`);let he=pe(`tooltip`),ge=O&&!A&&!!L.opened,_e=C===`merge`&&y?w_({position:L.placement,dir:de}):void 0;if(I){let e=G_(T,{duration:100,transition:`fade`});return(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(L_,{...re,withinPortal:d,children:(0,z.jsx)(U_,{...e,keepMounted:te,mounted:!A&&!!L.opened,duration:L.isGroupPhase?10:e.duration,children:e=>(0,z.jsxs)(Z,{...ue,"data-fixed":ie===`fixed`||void 0,variant:ee,mod:[{multiline:E,interactive:ge},F],...he,...L.getFloatingProps({ref:L.floating,className:he.className,style:{...he.style,...e,..._e,zIndex:k,top:L.y??0,left:L.x??0,...L.referenceHidden?{display:`none`}:null}}),children:[a,(0,z.jsx)(T_,{ref:fe,arrowX:L.arrowX,arrowY:L.arrowY,visible:y,position:L.placement,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,...pe(`arrow`)})]})})})})}let ve=me.props,ye=Nm(L.reference,Um(me),le),be=G_(T,{duration:100,transition:`fade`});return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L_,{...re,withinPortal:d,children:(0,z.jsx)(U_,{...be,keepMounted:te,mounted:!A&&!!L.opened,duration:L.isGroupPhase?10:be.duration,children:e=>(0,z.jsxs)(Z,{...ue,"data-fixed":ie===`fixed`||void 0,variant:ee,mod:[{multiline:E,interactive:ge},F],...L.getFloatingProps({ref:L.floating,className:pe(`tooltip`).className,style:{...pe(`tooltip`).style,...e,..._e,zIndex:k,top:L.y??0,left:L.x??0,...L.referenceHidden?{display:`none`}:null}}),children:[a,(0,z.jsx)(T_,{ref:fe,arrowX:L.arrowX,arrowY:L.arrowY,visible:y,position:L.placement,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,...pe(`arrow`)})]})})}),(0,R.cloneElement)(me,L.getReferenceProps({onClick:j,onMouseEnter:M,onMouseLeave:N,onMouseMove:t.onMouseMove,onPointerDown:t.onPointerDown,onPointerEnter:t.onPointerEnter,...ve,className:Km(v,ve.className),[i]:ye}))]})});ox.classes=Jb,ox.varsResolver=ax,ox.displayName=`@mantine/core/Tooltip`,ox.Floating=Zb,ox.Group=ex;var sx={root:`m_18320242`,"skeleton-fade":`m_299c329c`},cx={visible:!0,animate:!0},lx=q((e,{width:t,height:n,radius:r,circle:i})=>({root:{"--skeleton-height":K(n),"--skeleton-width":K(i?n:t),"--skeleton-radius":i?`1000px`:r===void 0?void 0:Wp(r)}})),ux=X(e=>{let t=J(`Skeleton`,cx,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,width:c,height:l,circle:u,visible:d,radius:f,animate:p,mod:m,attributes:h,...g}=t,_=Y({name:`Skeleton`,classes:sx,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,vars:s,varsResolver:lx});return(0,z.jsx)(Z,{..._(`root`),mod:[{visible:d,animate:p},m],...g})});ux.classes=sx,ux.varsResolver=lx,ux.displayName=`@mantine/core/Skeleton`;var dx={root:`m_6d731127`},fx={gap:`md`,align:`stretch`,justify:`flex-start`},px=q((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":Up(t),"--stack-align":n,"--stack-justify":r}})),mx=X(e=>{let t=J(`Stack`,fx,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,align:c,justify:l,gap:u,variant:d,attributes:f,...p}=t,m=Y({name:`Stack`,props:t,classes:dx,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:px});return(0,z.jsx)(Z,{...m(`root`),variant:d,...p})});mx.classes=dx,mx.varsResolver=px,mx.displayName=`@mantine/core/Stack`;var[hx,gx]=jp(`Tabs component was not found in the tree`),_x={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},vx=X(e=>{let t=J(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,d=gx();return(0,z.jsx)(Z,{...d.getStyles(`list`,{className:r,style:c,classNames:o,styles:s,props:t,variant:d.variant}),role:`tablist`,variant:d.variant,mod:[{grow:i,orientation:d.orientation,placement:d.orientation===`vertical`&&d.placement,inverted:d.inverted},l],"aria-orientation":d.orientation,__vars:{"--tabs-justify":a},...u,children:n})});vx.classes=_x,vx.displayName=`@mantine/core/TabsList`;var yx=X(e=>{let t=J(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,d=Ah(),f=gx();(0,R.useEffect)(()=>(f.setMountedPanel(i,!0),()=>{f.setMountedPanel(i,!1)}),[i]);let p=f.value===i,m=f.keepMounted||l,h=f.keepMountedMode!==`display-none`,g=m&&h&&d!==`test`?(0,z.jsx)(R.Activity,{mode:p?`visible`:`hidden`,children:n}):m||p?n:null;return(0,z.jsx)(Z,{...f.getStyles(`panel`,{className:r,classNames:a,styles:o,style:[s,p?void 0:{display:`none`}],props:t}),mod:[{orientation:f.orientation},c],role:`tabpanel`,id:f.getPanelId(i),"aria-labelledby":f.getTabId(i),...u,children:g})});yx.classes=_x,yx.displayName=`@mantine/core/TabsPanel`;var bx=X(e=>{let t=J(`TabsTab`,null,e),{className:n,children:r,rightSection:i,leftSection:a,value:o,onClick:s,onKeyDown:c,disabled:l,color:u,style:d,classNames:f,styles:p,vars:m,mod:h,tabIndex:g,..._}=t,v=Wh(),{dir:y}=u_(),b=gx(),x=o===b.value,S=e=>{b.onChange(b.allowTabDeactivation&&o===b.value?null:o),s?.(e)},C={classNames:f,styles:p,props:t};return(0,z.jsxs)(p_,{...b.getStyles(`tab`,{className:n,style:d,variant:b.variant,...C}),disabled:l,unstyled:b.unstyled,variant:b.variant,mod:[{active:x,disabled:l,orientation:b.orientation,inverted:b.inverted,placement:b.orientation===`vertical`&&b.placement},h],role:`tab`,id:b.getTabId(o),"aria-selected":x,tabIndex:g===void 0?x||b.value===null?0:-1:g,"aria-controls":b.mountedPanels.current.has(o)?b.getPanelId(o):void 0,onClick:S,__vars:{"--tabs-color":u?uh(u,v):void 0},onKeyDown:Lp({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:b.activateTabWithKeyboard,loop:b.loop,orientation:b.orientation||`horizontal`,dir:y,onKeyDown:c}),..._,children:[a&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`left`,children:a}),r&&(0,z.jsx)(`span`,{...b.getStyles(`tabLabel`,C),children:r}),i&&(0,z.jsx)(`span`,{...b.getStyles(`tabSection`,C),"data-position":`right`,children:i})]})});bx.classes=_x,bx.displayName=`@mantine/core/TabsTab`;var xx=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,Sx={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},Cx=q((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":Wp(t),"--tabs-color":uh(n,e),"--tabs-text-color":bh(r,e)?_h({color:n,theme:e,autoContrast:r}):void 0}})),wx=X(e=>{let t=J(`Tabs`,Sx,e),{defaultValue:n,value:r,onChange:i,orientation:a,children:o,loop:s,id:c,activateTabWithKeyboard:l,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,placement:h,keepMounted:g,keepMountedMode:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=t,O=Am(c),k=(0,R.useRef)(new Set),A=km(),j=(0,R.useCallback)((e,t)=>{let n=k.current;t&&!n.has(e)?(n.add(e),A()):!t&&n.has(e)&&(n.delete(e),A())},[]),[M,N]=Pm({value:r,defaultValue:n,finalValue:null,onChange:i}),P=Y({name:`Tabs`,props:t,classes:_x,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:Cx});return(0,z.jsx)(hx,{value:{placement:h,value:M,orientation:a,id:O,loop:s,activateTabWithKeyboard:l,getTabId:Mp(`${O}-tab`,xx),getPanelId:Mp(`${O}-panel`,xx),onChange:N,allowTabDeactivation:u,variant:d,color:f,radius:p,inverted:m,keepMounted:g,keepMountedMode:_,unstyled:b,getStyles:P,mountedPanels:k,setMountedPanel:j},children:(0,z.jsx)(Z,{id:O,variant:d,mod:[{orientation:a,inverted:a===`horizontal`&&m,placement:a===`vertical`&&h},T],...P(`root`),...D,children:o})})});wx.classes=_x,wx.varsResolver=Cx,wx.displayName=`@mantine/core/Tabs`,wx.Tab=bx,wx.Panel=yx,wx.List=vx;var Tx=X(e=>{let t=J([`Input`,`InputWrapper`,`TextInput`],null,e);return(0,z.jsx)(ay,{component:`input`,...t,__staticSelector:`TextInput`})});Tx.classes=ay.classes,Tx.displayName=`@mantine/core/TextInput`;var Ex=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],Dx=[`xs`,`sm`,`md`,`lg`,`xl`];function Ox(e,t){let n=t===void 0?`h${e}`:t;return Ex.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:Dx.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:K(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var kx={root:`m_8a5d1357`},Ax={order:1},jx=q((e,{order:t,size:n,lineClamp:r,textWrap:i})=>{let a=Ox(t||1,n);return{root:{"--title-fw":a.fontWeight,"--title-lh":a.lineHeight,"--title-fz":a.fontSize,"--title-line-clamp":typeof r==`number`?r.toString():void 0,"--title-text-wrap":i}}}),Mx=X(e=>{let t=J(`Title`,Ax,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,order:s,vars:c,size:l,variant:u,lineClamp:d,textWrap:f,mod:p,attributes:m,...h}=t,g=Y({name:`Title`,props:t,classes:kx,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:m,vars:c,varsResolver:jx});return[1,2,3,4,5,6].includes(s)?(0,z.jsx)(Z,{...g(`root`),component:`h${s}`,variant:u,mod:[{order:s,lineClamp:typeof d==`number`},p],size:l,...h}):null});Mx.classes=kx,Mx.varsResolver=jx,Mx.displayName=`@mantine/core/Title`;var Nx=(e,t,n=!1)=>{let r=[];function i(e,r=`--bn`){for(let a in e){let o=`${r}-${a.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}`;typeof e[a]==`object`?i(e[a],o):(typeof e[a]==`number`&&(e[a]=`${e[a]}px`),n?t.style.removeProperty(o):t.style.setProperty(o,e[a].toString()))}}return i(e),r},Px=(e,t)=>Nx(e,t),Fx={colors:{editor:{text:void 0,background:void 0},menu:{text:void 0,background:void 0},tooltip:{text:void 0,background:void 0},hovered:{text:void 0,background:void 0},selected:{text:void 0,background:void 0},disabled:{text:void 0,background:void 0},shadow:void 0,border:void 0,sideMenu:void 0,highlights:{gray:{text:void 0,background:void 0},brown:{text:void 0,background:void 0},red:{text:void 0,background:void 0},orange:{text:void 0,background:void 0},yellow:{text:void 0,background:void 0},green:{text:void 0,background:void 0},blue:{text:void 0,background:void 0},purple:{text:void 0,background:void 0},pink:{text:void 0,background:void 0}}},borderRadius:void 0,fontFamily:void 0},Ix=e=>Nx(Fx,e,!0),Lx=e=>(0,z.jsxs)(mx,{gap:0,className:`bn-tooltip`,children:[(0,z.jsx)(my,{size:`sm`,lineClamp:5,children:e.mainTooltip}),e.secondaryTooltip&&(0,z.jsx)(my,{size:`xs`,lineClamp:5,children:e.secondaryTooltip})]}),Rx=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,mainTooltip:i,secondaryTooltip:a,icon:o,isSelected:s,isDisabled:c,onClick:l,label:u,variant:d,...f}=e;T(f,!1);let[p,m]=(0,R.useState)(!1),h=r?(0,z.jsx)(Ry,{"aria-label":u,className:n,onMouseDown:vp,onClick:e=>{m(!0),l?.(e)},onPointerLeave:()=>m(!1),"aria-pressed":s,"data-selected":s||void 0,"data-test":i?i.slice(0,1).toLowerCase()+i.replace(/\s+/g,``).slice(1):void 0,size:d===`compact`?`compact-xs`:`xs`,disabled:c||!1,ref:t,...f,children:r}):(0,z.jsx)(Cv,{className:n,"aria-label":u,onMouseDown:vp,onClick:e=>{m(!0),l?.(e)},onPointerLeave:()=>m(!1),"aria-pressed":s,"data-selected":s||void 0,"data-test":i?i.slice(0,1).toLowerCase()+i.replace(/\s+/g,``).slice(1):void 0,size:d===`compact`?20:30,disabled:c||!1,ref:t,...f,children:o});return i?(0,z.jsx)(ox,{disabled:p,withinPortal:!1,label:(0,z.jsx)(Lx,{mainTooltip:i,secondaryTooltip:a}),children:h}):h}),zx=(0,R.forwardRef)((e,t)=>{let{className:n,text:r,icon:i,isSelected:a,mainTooltip:o,secondaryTooltip:s,onClick:c,onMouseEnter:l,...u}=e;T(u,!1);let[d,f]=(0,R.useState)(!1),p=(0,z.jsxs)(Zy,{className:n,checked:a===!0,wrapperProps:{onMouseEnter:l,onMouseLeave:()=>f(!1),onClick:e=>{f(!0),c?.(e)}},variant:`light`,icon:null,ref:t,children:[(0,z.jsx)(`span`,{children:i}),(0,z.jsx)(`span`,{children:r})]});return!o||d?p:(0,z.jsx)(ox,{refProp:`rootRef`,withinPortal:!1,label:(0,z.jsx)(Lx,{mainTooltip:o,secondaryTooltip:s}),children:p})}),Bx=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i),(0,z.jsx)(Nv,{className:n,ref:t,children:r})}),Vx=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,headerText:i,selected:a,onFocus:o,onBlur:s,tabIndex:c,...l}=e;return T(l,!1),(0,z.jsxs)(Gy,{className:w(n,a?`selected`:``),onFocus:o,onBlur:s,tabIndex:c,ref:t,children:[i&&(0,z.jsx)(my,{className:`bn-header-text`,children:i}),r]})}),Hx=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i,!1),(0,z.jsx)(Gy.Section,{className:n,ref:t,children:r})}),Ux=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i,!1),(0,z.jsx)(tb,{className:n,label:(0,z.jsx)(my,{children:r}),ref:t})}),Wx=(0,R.forwardRef)((e,t)=>{let{authorInfo:n,timeString:r,edited:i,...a}=e,o=H();return T(a,!1),n===`loading`?(0,z.jsxs)(Nv,{children:[(0,z.jsx)(ux,{height:24,width:24}),(0,z.jsx)(`div`,{children:(0,z.jsx)(ux,{height:12,width:100})})]}):(0,z.jsxs)(Nv,{children:[(0,z.jsx)(Ey,{src:n.avatarUrl,alt:n.username,radius:`xl`,size:`sm`,color:`initials`}),(0,z.jsxs)(my,{fz:`sm`,fw:`bold`,children:[n.username,(0,z.jsxs)(my,{fz:`xs`,c:`dimmed`,span:!0,ml:`xs`,children:[r,` `,i&&`(${o.comments.edited})`]})]})]})}),Gx=(0,R.forwardRef)((e,t)=>{let{className:n,showActions:r,authorInfo:i,timeString:a,edited:o,actions:s,emojiPickerOpen:c,children:l,...u}=e,{hovered:d,ref:f}=Im(),p=Kd([t,f]);return T(u,!1),(0,z.jsxs)(Nv,{pos:`relative`,ref:p,className:n,children:[s&&(r===!0||r===void 0||r===`hover`&&d||c)?(0,z.jsx)(Nv,{style:{position:`absolute`,right:0,top:0,zIndex:10},children:s}):null,(0,z.jsx)(Wx,{...e}),l]})}),Kx=(0,R.forwardRef)((e,t)=>{let{className:n,autoFocus:r,onFocus:i,onBlur:a,editor:o,editable:s,...c}=e;T(c,!1);let l=Ie();return(0,z.jsx)(WS,{autoFocus:r,className:n,editor:e.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:s,theme:l?.colorSchemePreference,ref:t,onFocus:i,onBlur:a,children:(0,z.jsx)(cd,{formattingToolbar:qx})})}),qx=()=>{let e=Xu([]).filter(e=>e.key!==`nestBlockButton`&&e.key!==`unnestBlockButton`);return(0,z.jsx)(Zu,{blockTypeSelectItems:[],children:e})},Jx=e=>{let{children:t,onSubmit:n,submitButton:r,...i}=e;return T(i),(0,z.jsxs)(`form`,{className:`bn-form`,onSubmit:e=>{e.preventDefault(),n?.()},children:[t,r===`none`?null:r]})},Yx=(0,R.forwardRef)((e,t)=>{let{className:n,name:r,label:i,variant:a,icon:o,value:s,autoFocus:c,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m,rightSection:h,...g}=e;T(g);let _=qd([gp(c),t]);return(0,z.jsx)(Tx,{size:`xs`,className:w(n||``,a===`large`?`bn-mt-input-large`:``),ref:_,name:r,label:i,leftSection:o,value:s,"data-autofocus":c?`true`:void 0,rightSection:h,placeholder:l,disabled:u,onKeyDown:d,onChange:f,autoComplete:p,"aria-activedescendant":m})}),Xx=(0,R.createContext)(void 0),Zx=e=>{let{children:t,onOpenChange:n,position:r,portalElement:i,preventFocusOnOpen:a,sub:o,...s}=e;return T(s),o?(0,z.jsx)(Q.Sub,{transitionProps:{duration:250,exitDelay:250},middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:n,position:r,children:t}):(0,z.jsx)(Q,{withinPortal:!!i,portalProps:i?{target:i}:void 0,trapFocus:!a&&void 0,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:n,position:r,returnFocus:!1,children:t})},Qx=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,checked:a,disabled:o,subTrigger:s,onClick:c,...l}=e;return T(l,!1),(0,z.jsx)(s?Q.Sub.Item:Q.Item,{className:n,ref:t,leftSection:i,rightSection:a?(0,z.jsx)(hy,{size:10}):a===!1?(0,z.jsx)(`div`,{className:`bn-tick-space`}):null,onClick:c,disabled:o,...l,children:r})}),$x=e=>{let{children:t,sub:n,...r}=e;return T(r),(0,z.jsx)(n?Q.Sub.Target:Q.Target,{children:t})},eS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,sub:i,...a}=e;T(a);let o=(0,R.useContext)(Xx);return(0,z.jsx)(i?Q.Sub.Dropdown:Q.Dropdown,{className:n,ref:t,onMouseOver:o?.onMenuMouseOver,onMouseLeave:o?.onMenuMouseLeave,children:r})}),tS=(0,R.forwardRef)((e,t)=>{let{className:n,...r}=e;return T(r),(0,z.jsx)(Q.Divider,{className:n,ref:t})}),nS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i),(0,z.jsx)(Q.Label,{className:n,ref:t,children:r})}),rS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,label:l,...u}=e;return T(u,!1),i?(0,z.jsx)(Cv,{size:24,className:n,ref:t,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,"aria-label":l,...u,children:i}):(0,z.jsx)(Ry,{className:n,ref:t,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,"aria-label":l,...u,children:r})}),iS=(0,R.forwardRef)((e,t)=>{let{className:n,tabs:r,defaultOpenTab:i,openTab:a,setOpenTab:o,loading:s,...c}=e;return T(c),(0,z.jsx)(Nv,{className:n,ref:t,children:(0,z.jsxs)(wx,{value:a,defaultValue:i,onChange:o,children:[s&&(0,z.jsx)(cb,{visible:s}),(0,z.jsx)(wx.List,{children:r.map(e=>(0,z.jsx)(wx.Tab,{"data-test":`${e.name.toLowerCase()}-tab`,value:e.name,children:e.name},e.name))}),r.map(e=>(0,z.jsx)(wx.Panel,{value:e.name,children:e.tabPanel},e.name))]})})}),aS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,type:i,onClick:a,label:o,...s}=e;return T(s),(0,z.jsx)(Ry,{type:i,size:`xs`,"aria-label":o,className:n,ref:t,onClick:a,...s,children:r})}),oS=(0,R.forwardRef)((e,t)=>{let{className:n,accept:r,value:i,placeholder:a,onChange:o,...s}=e;return T(s),(0,z.jsx)(ib,{size:`xs`,className:n,ref:t,accept:r,value:i,placeholder:a,onChange:o,...s})}),sS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i),(0,z.jsx)(`div`,{className:n,ref:t,children:r})}),cS=(0,R.forwardRef)((e,t)=>{let{className:n,value:r,placeholder:i,onKeyDown:a,onChange:o,...s}=e;return T(s),(0,z.jsx)(Tx,{size:`xs`,"data-test":`embed-input`,className:n,ref:t,value:r,placeholder:i,onKeyDown:a,onChange:o})}),lS=e=>{let{open:t,onOpenChange:n,position:r,portalElement:i,children:a,...o}=e;return T(o),(0,z.jsx)(sv,{middlewares:{size:{padding:20}},withinPortal:!!i,portalProps:i?{target:i}:void 0,trapFocus:!1,hideDetached:!1,opened:t,onChange:n,position:r,children:a})},uS=e=>{let{children:t,...n}=e;return T(n),(0,z.jsx)(tv,{children:t})},dS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,variant:i,...a}=e;return T(a),(0,z.jsx)($_,{className:n,ref:t,children:r})}),fS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i,!1),(0,z.jsx)(Nv,{align:`center`,gap:0,className:n,ref:t,...i,children:r})}),pS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,icon:i,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,label:l,...u}=e;return T(u,!1),i?(0,z.jsx)(Cv,{size:24,className:n,ref:t,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,"aria-label":l,...u,children:i}):(0,z.jsx)(Ry,{className:n,ref:t,onClick:a,onDragEnd:o,onDragStart:s,draggable:c,"aria-label":l,...u,children:r})}),mS=(0,R.forwardRef)((e,t)=>{let{className:n,markClassName:r,backgroundColor:i,children:a,...o}=e;return T(o),(0,z.jsx)(`span`,{className:w(n||``,r||``),style:r?void 0:{backgroundColor:i},ref:t,children:a})}),hS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,id:i,...a}=e;return T(a),(0,z.jsx)(mx,{gap:0,className:n,ref:t,id:i,role:`listbox`,children:r})}),gS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i),(0,z.jsx)(Nv,{className:n,ref:t,children:(0,z.jsx)(Nv,{className:`bn-mt-suggestion-menu-item-title`,children:r})})}),_S=(0,R.forwardRef)((e,t)=>{let{className:n,isSelected:r,onClick:i,item:a,id:o,...s}=e;T(s);let c=(0,R.useRef)(null);return(0,R.useEffect)(()=>{c.current&&r&&_p(c.current,c.current.closest(`.bn-suggestion-menu, #ai-suggestion-menu`))!==`none`&&c.current.scrollIntoView({block:`nearest`})},[r]),(0,z.jsxs)(Nv,{gap:0,className:n,ref:Mm(t,c),id:o,role:`option`,onMouseDown:e=>e.preventDefault(),onClick:i,"aria-selected":r||void 0,children:[a.icon&&(0,z.jsx)(Nv,{className:`bn-mt-suggestion-menu-item-section`,"data-position":`left`,children:a.icon}),(0,z.jsxs)(mx,{gap:0,className:`bn-mt-suggestion-menu-item-body`,children:[(0,z.jsx)(my,{className:`bn-mt-suggestion-menu-item-title`,children:a.title}),(0,z.jsx)(my,{className:`bn-mt-suggestion-menu-item-subtitle`,children:a.subtext})]}),a.badge&&(0,z.jsx)(Nv,{"data-position":`right`,className:`bn-mt-suggestion-menu-item-section`,children:(0,z.jsx)(ky,{size:`xs`,children:a.badge})})]})}),vS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,...i}=e;return T(i),(0,z.jsx)(Nv,{className:n,ref:t,children:r})}),yS=(0,R.forwardRef)((e,t)=>{let{className:n,...r}=e;return T(r),(0,z.jsx)(`div`,{ref:t,children:(0,z.jsx)(hv,{className:n,type:`dots`,size:16})})}),bS=(0,R.forwardRef)((e,t)=>{let{children:n,className:r,onMouseDown:i,onClick:a,...o}=e;return T(o,!1),(0,z.jsx)(Ry,{className:r,ref:t,onMouseDown:i,onClick:a,...o,children:n})}),xS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,draggable:i,onDragStart:a,onDragEnd:o,style:s,label:c,...l}=e;return T(l,!1),(0,z.jsx)(Ry,{className:n,ref:t,"aria-label":c,draggable:i,onDragStart:a,onDragEnd:o,style:s,...l,children:r})}),SS=(0,R.forwardRef)((e,t)=>{let{className:n,"aria-label":r,children:i,onMouseEnter:a,onMouseLeave:o,variant:s,trapFocus:c,...l}=e;return T(l),(0,z.jsx)(cy,{className:n,"aria-label":r,ref:t,role:`toolbar`,onMouseEnter:a,onMouseLeave:o,gap:s===`action-toolbar`?2:void 0,children:i})}),CS={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wS=R.createContext&&R.createContext(CS),TS=[`attr`,`size`,`title`];function ES(e,t){if(e==null)return{};var n,r,i=DS(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;rR.createElement(e.tag,AS({key:t},e.attr),PS(e.child)))}function FS(e){return t=>R.createElement(IS,OS({attr:AS({},e.attr)},t),PS(e.child))}function IS(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=ES(e,TS),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),R.createElement(`svg`,OS({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:AS(AS({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&R.createElement(`title`,null,i),e.children)};return wS===void 0?t(CS):R.createElement(wS.Consumer,null,e=>t(e))}function LS(e){return FS({tag:`svg`,attr:{viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z`,clipRule:`evenodd`},child:[]}]})(e)}var RS=(0,R.forwardRef)((e,t)=>{let{className:n,items:r,isDisabled:i,portalElement:a,preventFocusOnOpen:o,...s}=e;T(s);let c=r.filter(e=>e.isSelected)[0];return c?(0,z.jsxs)(Q,{withinPortal:!!a,portalProps:a?{target:a}:void 0,transitionProps:{exitDuration:0},disabled:i,trapFocus:!o&&void 0,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},children:[(0,z.jsx)(Q.Target,{children:(0,z.jsx)(Ry,{onMouseDown:vp,leftSection:c.icon,rightSection:(0,z.jsx)(LS,{}),size:`xs`,variant:`subtle`,disabled:i,children:c.text})}),(0,z.jsx)(Q.Dropdown,{className:n,ref:t,children:r.map(e=>(0,z.jsx)(Q.Item,{onClick:e.onClick,leftSection:e.icon,rightSection:e.isSelected?(0,z.jsx)(hy,{size:10,className:`bn-tick-icon`}):(0,z.jsx)(`div`,{className:`bn-tick-space`}),disabled:e.isDisabled,children:e.text},e.text))})]}):null}),zS=(0,R.forwardRef)((e,t)=>{let{className:n,children:r,"aria-label":i,...a}=e;return T(a,!1),(0,z.jsx)(Z,{className:n,ref:t,role:`region`,"aria-label":i,children:r})});function BS(e){let{className:t,title:n,actions:r,closeAction:i,...a}=e;return T(a,!1),(0,z.jsxs)(Nv,{className:t,justify:`space-between`,wrap:`nowrap`,children:[(0,z.jsxs)(Nv,{className:`bn-versioning-sidebar-header-title`,gap:6,wrap:`nowrap`,children:[(0,z.jsx)(Mx,{className:`bn-versioning-sidebar-title`,order:2,children:n}),r]}),i]})}function VS(e){return e.mode===`display`?(0,z.jsx)(my,{component:`span`,className:`bn-snapshot-name`,children:e.value}):(0,z.jsx)(Z,{component:`span`,className:`bn-snapshot-name-sizer`,"data-value":e.value===``?e.placeholder:e.value,children:(0,z.jsx)(ny,{ref:e.inputRef,className:`bn-snapshot-name`,classNames:{input:`bn-snapshot-name`},unstyled:!0,type:`text`,value:e.value,placeholder:e.placeholder,"aria-label":e[`aria-label`],onChange:e.onChange,onClick:e.onClick,onKeyDown:e.onKeyDown,onBlur:e.onBlur})})}var HS=(0,R.forwardRef)((e,t)=>{let{className:n,id:r,"aria-label":i,state:a,tabIndex:o,"aria-busy":s,onClick:c,onKeyDown:l,onFocus:u,actions:d,name:f,date:p,restoredFrom:m,users:h,comparingLabel:g,comparingIcon:_,...v}=e;T(v,!1);let y={default:``,selected:`selected`,"comparison-source":`selected bn-snapshot-comparison-source`,"comparison-baseline":`comparing`}[a];return(0,z.jsxs)(Gy,{className:w(n,y),id:r,role:`listitem`,"aria-label":i,"aria-current":a===`selected`||a===`comparison-source`?`true`:void 0,"aria-busy":s,tabIndex:o,onClick:c,onKeyDown:l,onFocus:u,ref:t,children:[g&&(0,z.jsxs)(Nv,{className:`bn-snapshot-comparing-to`,gap:4,wrap:`nowrap`,children:[_,(0,z.jsx)(my,{component:`span`,children:g})]}),(0,z.jsxs)(mx,{className:`bn-snapshot-body`,gap:2,children:[(0,z.jsx)(Nv,{className:`bn-snapshot-title-row`,gap:6,wrap:`nowrap`,children:f}),p&&(0,z.jsx)(my,{className:`bn-snapshot-date`,children:p}),m&&(0,z.jsx)(my,{className:`bn-snapshot-original-date`,children:m}),h?.length?(0,z.jsx)(`div`,{className:`bn-snapshot-users`,children:h.map((e,t)=>(0,z.jsxs)(`span`,{className:`bn-snapshot-user`,children:[t>0&&(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),typeof e!=`string`&&e.color&&(0,z.jsx)(`span`,{className:`bn-snapshot-user-color`,"aria-hidden":`true`,style:{color:e.color,"--bn-user-color-light":e.colorLight??e.color}}),(0,z.jsx)(`span`,{children:typeof e==`string`?e:e.username})]},t))}):null]}),d&&(0,z.jsx)(Z,{className:`bn-snapshot-menu`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:d})]})}),US={FormattingToolbar:{Root:SS,Button:Rx,Select:RS},FilePanel:{Root:iS,Button:aS,FileInput:oS,TabPanel:sS,TextInput:cS},LinkToolbar:{Root:SS,Button:Rx,Select:RS},SideMenu:{Root:fS,Button:pS},SuggestionMenu:{Root:hS,Item:_S,EmptyItem:gS,Label:vS,Loader:yS},AttributionTooltip:{Root:mS},TableHandle:{Root:xS,ExtendButton:bS},Generic:{Badge:{Root:zx,Group:Bx},Form:{Root:Jx,TextInput:Yx},Menu:{Root:Zx,Trigger:$x,Dropdown:eS,Divider:tS,Label:nS,Item:Qx,Button:rS},Popover:{Root:lS,Trigger:uS,Content:dS},Toolbar:{Root:SS,Button:Rx,Select:RS}},Comments:{Comment:Gx,Editor:Kx,Card:Vx,CardSection:Hx,ExpandSectionsPrompt:Ux},Versioning:{Sidebar:zS,Header:BS,Name:VS,Snapshot:HS,Loader:yS}},WS=e=>{let{className:t,theme:n,editor:r,...i}=e,a=Ie(),o=Wf(),s=a?.colorSchemePreference||o,c=typeof n==`string`?n:s===`no-preference`?`light`:s,l=(0,R.useCallback)(e=>{if(e&&(Ix(e),typeof n==`object`)){if(`light`in n&&`dark`in n){Px(n[s===`dark`?`dark`:`light`],e);return}Px(n,e)}},[s,n]),u=(0,R.useCallback)(e=>{e.setAttribute(`data-mantine-color-scheme`,c),l(e)},[l,c]),d=(0,R.useContext)(xh),f=(0,z.jsx)(rt.Provider,{value:US,children:(0,z.jsx)(Zf,{"data-mantine-color-scheme":c,className:w(`bn-mantine`,t||``),applyThemedRoot:u,theme:typeof n==`object`?void 0:n,editor:r,...i,ref:l})});return d?f:(0,z.jsx)(ig,{withCssVariables:!1,getRootElement:()=>void 0,children:f})},$=[`#FFFFFF`,`#EFEFEF`,`#CFCFCF`,`#AFAFAF`,`#7F7F7F`,`#3F3F3F`,`#1F1F1F`,`#161616`,`#0F0F0F`,`#000000`],GS={colors:{editor:{text:$[5],background:$[0]},menu:{text:$[5],background:$[0]},tooltip:{text:$[5],background:$[1]},hovered:{text:$[5],background:$[1]},selected:{text:$[0],background:$[5]},disabled:{text:$[3],background:$[1]},shadow:$[2],border:$[1],sideMenu:$[2],highlights:Ee},borderRadius:6,fontFamily:`"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif`};$[2],$[6],$[2],$[6],$[2],$[7],$[2],$[7],$[2],$[8],$[5],$[7],$[8],$[7],$[4],GS.borderRadius,GS.fontFamily;var KS=e=>e===``||/\s$/u.test(e),qS=e=>/^\p{L}{2}/u.test(e);function JS({noteID:e,initialContent:t,legacyMarkdown:n,onChange:r,uploadFile:i,resolveFileUrl:a,editable:o=!0,autoFocus:s,onHydrated:l,onActive:u}){let d=(0,R.useRef)(!1),f=(0,R.useRef)(r),m=(0,R.useRef)(i),h=(0,R.useRef)(a),g=(0,R.useRef)(l);g.current=l,f.current=r,m.current=i,h.current=a;let _=js({initialContent:n?void 0:t,uploadFile:e=>m.current(e),resolveFileUrl:e=>h.current(e)},[e]),v=(0,R.useCallback)(e=>KS(e.selection.$from.parent.textBetween(0,e.selection.$from.parentOffset,void 0,` `)),[]),y=G(N,{editor:_,selector:e=>e?.triggerCharacter===`:`?e.query:``});return(0,R.useEffect)(()=>{y.length>=2&&!qS(y)&&_.getExtension(N)?.closeMenu()},[_,y]),(0,R.useEffect)(()=>{if(d.current=!1,n){let e=_.tryParseMarkdownToBlocks(n);e.length&&(_.replaceBlocks(_.document,e),g.current?.(_.document))}d.current=!0},[_,n]),(0,R.useEffect)(()=>{s&&_.focus()},[_,s]),(0,z.jsx)(`div`,{className:`blocknote-editor`,onFocus:()=>u?.(_),children:(0,z.jsx)(WS,{editor:_,editable:o,emojiPicker:!1,onChange:e=>{if(!d.current)return;let t=c(e.document,p(new Date));if(!t.length)return f.current(e.document);e.transact(()=>t.forEach(t=>{e.updateBlock(t.id,{content:t.content}),e.insertBlocks([t.next],t.id,`after`)}))},children:(0,z.jsx)(ff,{triggerCharacter:`:`,minQueryLength:2,shouldOpen:v})})})}var YS=9437184,XS=e=>new TextEncoder().encode(e).length<=YS,ZS=24,QS=120,$S=e=>Math.min(f,Math.max(0,Math.round(e)));function eC(e,t,n,r=[{type:`paragraph`,content:``}],i=640){if(e.boxes.length>=500)return;let a=crypto.randomUUID();return{id:a,page:{...e,boxes:[...e.boxes,{id:a,x:$S(t),y:$S(n),width:i,blocks:r}]}}}function tC(e,t,n){return{...e,boxes:e.boxes.map(e=>{if(e.id!==t)return e;let r={...e,...n},i=(e,t)=>Number.isFinite(e)?e:t;return{...r,x:$S(i(r.x,e.x)),y:$S(i(r.y,e.y)),width:Math.min(d,Math.max(160,Math.round(i(r.width,e.width))))}})}}function nC(e){return e.blocks.every(e=>{if((e.type??`paragraph`)!==`paragraph`||e.children?.length)return!1;let t=e.content;return t===void 0||t===``||Array.isArray(t)&&t.every(e=>typeof e==`object`&&!!e&&`text`in e&&e.text===``)})}function rC(e){let t=e.boxes.filter(e=>!nC(e));return t.length===e.boxes.length?e:{...e,boxes:t}}function iC(e,t,n,r){let i=e.filter(e=>{let i=(r+e.size/2)**2;for(let r=0;r+2/^[a-z]$/i.test(e)?e.toLowerCase()===`z`:t===`KeyZ`;function lC(e){let t=[...e].sort((e,t)=>e.y-t.y||e.x-t.x);return new Map(t.map((e,t)=>[e.id,t]))}var uC=class{past=[];future=[];push(e){this.past.push(e),this.past.length>100&&this.past.shift(),this.future=[]}undo(e){let t=this.past.pop();return t!==void 0&&this.future.push(e),t}redo(e){let t=this.future.pop();return t!==void 0&&this.past.push(e),t}},{PI:dC}=Math,fC=dC+1e-4,pC=.5,mC=[1,1];function hC(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}var{min:gC}=Math;function _C(e,t,n){let r=gC(1,t/n);return gC(1,e+(gC(1,1-r)-e)*(r*.275))}function vC(e){return[-e[0],-e[1]]}function yC(e,t){return[e[0]+t[0],e[1]+t[1]]}function bC(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function xC(e,t){return[e[0]-t[0],e[1]-t[1]]}function SC(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function CC(e,t){return[e[0]*t,e[1]*t]}function wC(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function TC(e,t){return[e[0]/t,e[1]/t]}function EC(e){return[e[1],-e[0]]}function DC(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function OC(e,t){return e[0]*t[0]+e[1]*t[1]}function kC(e,t){return e[0]===t[0]&&e[1]===t[1]}function AC(e){return Math.hypot(e[0],e[1])}function jC(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function MC(e){return TC(e,AC(e))}function NC(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function PC(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function FC(e,t,n,r){let i=Math.sin(r),a=Math.cos(r),o=t[0]-n[0],s=t[1]-n[1],c=o*a-s*i,l=o*i+s*a;return e[0]=c+n[0],e[1]=l+n[1],e}function IC(e,t,n){return yC(e,CC(xC(t,e),n))}function LC(e,t,n,r){let i=n[0]-t[0],a=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+a*r,e}function RC(e,t,n){return yC(e,CC(t,n))}var zC=[0,0],BC=[0,0],VC=[0,0];function HC(e,t){let n=RC(e,MC(EC(xC(e,yC(e,[1,1])))),-t),r=[],i=1/13;for(let t=i;t<=1;t+=i)r.push(PC(n,e,fC*2*t));return r}function UC(e,t,n){let r=[],i=1/n;for(let n=i;n<=1;n+=i)r.push(PC(t,e,fC*n));return r}function WC(e,t,n){let r=xC(t,n),i=CC(r,.5),a=CC(r,.51);return[xC(e,i),xC(e,a),yC(e,a),yC(e,i)]}function GC(e,t,n,r){let i=[],a=RC(e,t,n),o=1/r;for(let t=o;t<1;t+=o)i.push(PC(a,e,fC*3*t));return i}function KC(e,t,n){return[yC(e,CC(t,n)),yC(e,CC(t,n*.99)),xC(e,CC(t,n*.99)),xC(e,CC(t,n))]}function qC(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function JC(e,t,n){return e.slice(0,10).reduce((e,r)=>{let i=r.pressure;return t&&(i=_C(e,r.distance,n)),(e+i)/2},e[0].pressure)}function YC(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=qC(s.taper,n,m),g=qC(c.taper,n,m),_=(n*r)**2,v=[],y=[],b=JC(e,a,n),x=hC(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,O=!1;for(let t=0;t_)&&(v.push(E),w=E),bC(VC,s,zC),D=[VC[0],VC[1]],(t<=1||jC(T,D)>_)&&(y.push(D),T=D),b=r,C=c)}let k=[e[0].point[0],e[0].point[1]],A=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:yC(e[0].point,[1,1]),j=[],M=[];if(e.length===1){if(!(h||g)||l)return HC(k,S||x)}else{h||g&&e.length===1||(u?j.push(...UC(k,y[0],13)):j.push(...WC(k,v[0],y[0])));let t=EC(vC(e[e.length-1].vector));g||h&&e.length===1?M.push(A):f?M.push(...GC(A,t,x,29)):M.push(...KC(A,t,x))}return v.concat(M,y.reverse(),j)}var XC=[0,0];function ZC(e){return e!=null&&e>=0}function QC(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=pC})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(IC(o[0],e,t/4))}o.length===1&&(o=[...o,[...yC(o[0],mC),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:ZC(o[0][2])?o[0][2]:.25,vector:[...mC],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e`${e.toFixed(1)},${t.toFixed(1)}`).join(`L`)}Z`:``}function tw(e){let t=e.getCoalescedEvents?.()??[];return t.length?t:[e]}var nw=[[`h1`,`Heading 1`],[`h2`,`Heading 2`],[`h3`,`Heading 3`],[`bold`,`Bold`],[`italic`,`Italic`],[`bullets`,`Bulleted list`],[`numbers`,`Numbered list`],[`checklist`,`Checklist`],[`link`,`Link`],[`code`,`Code`]],rw={h1:{type:`heading`,props:{level:1}},h2:{type:`heading`,props:{level:2}},h3:{type:`heading`,props:{level:3}},bullets:{type:`bulletListItem`},numbers:{type:`numberedListItem`},checklist:{type:`checkListItem`}},iw=e=>rw[e];function aw(e){let t=e?.trim();if(t)try{let e=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)?t:`https://${t}`);return[`http:`,`https:`,`mailto:`].includes(e.protocol)?e.href:void 0}catch{return}}function ow(e,t,n){if(e.focus(),t===`bold`||t===`italic`||t===`code`)return e.toggleStyles({[t]:!0});if(t===`link`){let t=aw(n());t&&e.createLink(t,e.getSelectedText()||t);return}let r=rw[t],i=e.getSelection()?.blocks??[e.getTextCursorPosition().block],a=i.every(e=>e.type===r.type&&(!r.props||e.props.level===r.props.level));e.transact(()=>i.forEach(t=>e.updateBlock(t,a?{type:`paragraph`}:r)))}var sw=[[`pen`,`Pen`],[`highlighter`,`Highlighter`],[`eraser`,`Eraser`]],cw=new Set([`h3`,`italic`,`checklist`]),lw={pen:[2,4,8],highlighter:[12,20,28]},uw=10,dw=`This page is full. Start a new page for more ink.`,fw=()=>window.matchMedia(`(max-width: 800px)`).matches,pw=e=>e.pointerType===`pen`?Math.round(e.pressure*100)/100:.5,mw=(0,R.memo)(function({pageID:e,box:t,rank:n,autoFocus:r,editable:i,legacyMarkdown:a,actions:o}){let s=()=>o.current,c=(0,R.useRef)(null);return(0,R.useLayoutEffect)(()=>s().observe(c.current),[]),(0,z.jsxs)(`div`,{ref:c,"data-box":t.id,className:`canvas-box`,style:{left:t.x,top:t.y,width:t.width,order:n},children:[(0,z.jsx)(`div`,{className:`canvas-box-handle`,role:`button`,tabIndex:0,"aria-label":`Move text box ${n+1} with arrow keys`,onPointerDown:e=>s().startDrag(e,t.id,`move`),onPointerMove:e=>s().dragMove(e),onPointerUp:()=>s().endDrag(),onPointerCancel:()=>s().endDrag(),onKeyDown:e=>s().nudge(e,t.id)}),(0,z.jsx)(JS,{noteID:`${e}/${t.id}`,initialContent:t.blocks,legacyMarkdown:a,autoFocus:r,editable:i,onChange:e=>s().change(t.id,e),onHydrated:e=>s().hydrated(t.id,e),uploadFile:e=>s().uploadFile(e),resolveFileUrl:e=>s().resolveFileUrl(e),onActive:e=>s().active(t.id,e)}),(0,z.jsx)(`div`,{className:`canvas-box-resize`,"aria-hidden":`true`,onPointerDown:e=>s().startDrag(e,t.id,`resize`),onPointerMove:e=>s().dragMove(e),onPointerUp:()=>s().endDrag(),onPointerCancel:()=>s().endDrag()})]})});function hw({pageID:e,body:t,onChange:n,onError:a,uploadFile:s,resolveFileUrl:c,editable:u=!0}){let[d]=(0,R.useState)(()=>m(t)),[f,p]=(0,R.useState)(d),h=(0,R.useRef)(d),[g,_]=(0,R.useState)(`type`),[v,y]=(0,R.useState)(`ink`),[b,x]=(0,R.useState)(1),[S,C]=(0,R.useState)(null),[,w]=(0,R.useState)(0),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useRef)(null),O=(0,R.useRef)(!1),k=(0,R.useRef)(null),A=(0,R.useRef)(null),j=(0,R.useRef)(new uC),M=(0,R.useRef)(new WeakMap),N=lw[g===`highlighter`?`highlighter`:`pen`][b],P=e=>{h.current=e,p(e)},ee=(e,t=!1)=>{if(!u)return!1;let r=i(e);return t&&!XS(r)?(a(dw),!1):(P(e),n(r),!0)},te=e=>{let t=T.current.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},[ne,re]=(0,R.useState)({}),F=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>F.current?.disconnect(),[]);let ie=e=>(F.current??=new ResizeObserver(e=>re(t=>{let n={...t};for(let t of e){let e=t.target;n[e.dataset.box]=e.offsetHeight}return n})),F.current.observe(e),()=>F.current?.unobserve(e)),ae=()=>{let e=T.current?.parentElement;return e&&!fw()?{left:e.scrollLeft,width:e.clientWidth}:void 0};(0,R.useLayoutEffect)(()=>{let e=h.current.boxes.find(e=>e.id===l);if(!e)return;let{width:t}=sC(e.x,e.width,ae());t{if(!u)return;let r=sC(e,640,ae()),i=eC(rC(h.current),r.x,t,n,r.width);if(!i)return a(`This page has the maximum number of text boxes.`);C(i.id),n?ee(i.page):P(i.page)},se=(0,R.useRef)(oe);se.current=oe;let I=(0,R.useRef)(null);I.current={change:(e,t)=>ee(tC(h.current,e,{blocks:t})),hydrated:(e,t)=>P(tC(h.current,e,{blocks:t})),startDrag:(e,t,n)=>{if(!u)return;let r=h.current.boxes.find(e=>e.id===t);r&&e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),k.current={id:t,mode:n,px:e.clientX,py:e.clientY,x:r.x,y:r.y,width:r.width,start:h.current})},dragMove:e=>{if(!u)return;let t=k.current;if(!t)return;let n=e.clientX-t.px,r=e.clientY-t.py;P(tC(h.current,t.id,t.mode===`move`?{x:t.x+n,y:t.y+r}:{width:t.width+n}))},endDrag:()=>{if(!k.current)return;let{start:e}=k.current;k.current=null,h.current!==e&&ee(h.current)},nudge:(e,t)=>{if(!u)return;let n=e.shiftKey?50:10,r={ArrowLeft:[-n,0],ArrowRight:[n,0],ArrowUp:[0,-n],ArrowDown:[0,n]}[e.key],i=h.current.boxes.find(e=>e.id===t);r&&i&&(e.preventDefault(),ee(tC(h.current,t,{x:i.x+r[0],y:i.y+r[1]})))},observe:ie,uploadFile:s,resolveFileUrl:c,active:(e,t)=>{ue.current={id:e,editor:t}}};let ce=()=>{if(!u)return;let e=j.current.undo(h.current.strokes);e&&ee({...h.current,strokes:e})},le=()=>{if(!u)return;let e=j.current.redo(h.current.strokes);e&&ee({...h.current,strokes:e})},ue=(0,R.useRef)(null),de=e=>{if(!u)return;g!==`type`&&_(`type`);let t=e=>e&&T.current?.querySelector(`[data-box="${CSS.escape(e)}"] .bn-editor`);if(!t(ue.current?.id)){ue.current=null;let e=[...h.current.boxes].sort((e,t)=>e.y-t.y||e.x-t.x)[0],n=t(e?.id);n&&n.focus()}if(ue.current)return ow(ue.current.editor,e,()=>window.prompt(`Link address`));let n=oC(h.current,ne),r=iw(e);oe(n.x,n.y,r&&[{...r,content:``}])},fe=(0,R.useRef)(()=>{});fe.current=e=>{(e.ctrlKey||e.metaKey)&&cC(e)&&(e.target?.closest?.(`.bn-container, dialog, input, textarea, select, [contenteditable]:not([contenteditable=false])`)||(e.preventDefault(),e.shiftKey?le():ce()))},(0,R.useEffect)(()=>{if(!u)return;let e=e=>fe.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]),(0,R.useEffect)(()=>{u||(E.current=null,D.current=null,k.current=null,A.current=null)},[u]);let L=(e,t)=>{let n=h.current,r=iC(n.strokes,e,t,uw);r!==n.strokes&&P({...n,strokes:r})},pe=e=>{if(!u)return;if(e.pointerType===`pen`)O.current=!0;else if(e.pointerType===`touch`&&O.current)return;if(e.button!==0||A.current!==null)return;e.currentTarget.setPointerCapture(e.pointerId),A.current=e.pointerId;let{x:t,y:n}=te(e);g===`eraser`?(D.current=h.current.strokes,L(t,n)):(E.current=[Math.round(t),Math.round(n),pw(e)],w(e=>e+1))},me=e=>{if(e.pointerId!==A.current)return;if(D.current){let{x:t,y:n}=te(e);L(t,n);return}let t=E.current;if(t){for(let n of tw(e.nativeEvent)){if(t.length>=3e4)break;let{x:e,y:r}=te(n);t.push(Math.round(e),Math.round(r),pw(n))}w(e=>e+1)}},he=e=>{if(e.pointerId!==A.current)return;A.current=null;let t=D.current;if(t){D.current=null,h.current.strokes!==t&&ee(h.current)&&j.current.push(t);return}let n=E.current;if(E.current=null,w(e=>e+1),!n)return;let r=h.current;if(r.strokes.length>=5e3)return a(dw);let i={id:crypto.randomUUID(),tool:g===`highlighter`?`highlighter`:`pen`,color:v,size:N,points:n};ee({...r,strokes:[...r.strokes,i]},!0)&&j.current.push(r.strokes)},ge=e=>{if(!u||g!==`type`||e.target!==T.current||fw())return;let{x:t,y:n}=te(e);oe(t,n)},_e=async e=>{if(!u||e.target!==T.current)return;let t=[...e.dataTransfer.files].filter(e=>e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault();let{x:n,y:r}=te(e);for(let[e,i]of t.entries())try{let t=await s(i);se.current(n+e*24,r+e*24,[{type:`image`,props:{url:t,name:i.name}}])}catch(e){a(e instanceof Error?e.message:`Unable to add image`)}},ve=e=>{let t=M.current.get(e);return t===void 0&&(t=ew(e.points,e.size,e.tool===`highlighter`),M.current.set(e,t)),t},ye=aC(f,ne),be=lC(f.boxes);return(0,z.jsxs)(`div`,{className:`canvas-page tool-${u?g:`type`}`,children:[(0,z.jsxs)(`div`,{className:`canvas-toolbar`,role:`toolbar`,"aria-label":`Page tools`,children:[nw.map(([e,t])=>(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(`button`,{className:`quiet icon-tool`,"aria-label":t,title:t,disabled:!u,onMouseDown:e=>e.preventDefault(),onClick:()=>de(e),children:(0,z.jsx)(o,{name:e})}),cw.has(e)&&(0,z.jsx)(`span`,{className:`canvas-tool-divider`,"aria-hidden":`true`})]},e)),(0,z.jsx)(`span`,{className:`canvas-tool-divider`,"aria-hidden":`true`}),(0,z.jsx)(`button`,{className:`quiet`,disabled:!u,onClick:()=>{let e=oC(h.current,ne);oe(e.x,e.y)},children:`Add text`}),(0,z.jsxs)(`button`,{className:`quiet ink-tool draw-toggle`,"aria-pressed":g!==`type`,disabled:!u,onClick:()=>_(g===`type`?`pen`:`type`),children:[(0,z.jsx)(o,{name:`draw`}),(0,z.jsx)(`span`,{children:`Draw`})]})]}),g!==`type`&&(0,z.jsxs)(`div`,{className:`canvas-toolbar ink-toolbar`,role:`toolbar`,"aria-label":`Ink tools`,children:[sw.map(([e,t])=>(0,z.jsx)(`button`,{className:`quiet ink-tool`,"aria-pressed":g===e,disabled:!u,onClick:()=>_(e),children:t},e)),(g===`pen`||g===`highlighter`)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`canvas-tool-divider`,"aria-hidden":`true`}),r.map(e=>(0,z.jsx)(`button`,{className:`quiet ink-tool ink-swatch ink-${e}`,"aria-label":`${e} ink`,"aria-pressed":v===e,disabled:!u,onClick:()=>y(e)},e)),lw[g].map((e,t)=>(0,z.jsx)(`button`,{className:`quiet ink-tool`,"aria-label":`Size ${e}`,"aria-pressed":b===t,disabled:!u,onClick:()=>x(t),children:[`S`,`M`,`L`][t]},e))]}),(0,z.jsx)(`span`,{className:`canvas-tool-divider`,"aria-hidden":`true`}),(0,z.jsx)(`button`,{className:`quiet ink-tool`,disabled:!u,onClick:ce,"aria-keyshortcuts":`Control+Z`,children:`Undo ink`}),(0,z.jsx)(`button`,{className:`quiet ink-tool`,disabled:!u,onClick:le,"aria-keyshortcuts":`Control+Shift+Z`,children:`Redo ink`})]}),f.strokes.length>0&&(0,z.jsx)(`p`,{className:`canvas-ink-note`,children:`This page has ink. Open it on a wider screen to see it.`}),(0,z.jsx)(`div`,{className:`canvas-scroll`,children:(0,z.jsxs)(`div`,{ref:T,className:`canvas-surface`,style:{width:ye.width+400,height:ye.height+400},onClick:ge,onDragOver:e=>{e.target===T.current&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>void _e(e),children:[f.boxes.length===0&&(0,z.jsx)(`p`,{className:`canvas-hint`,children:`Click anywhere to type, or choose Add text.`}),f.boxes.map(t=>(0,z.jsx)(mw,{pageID:e,box:t,rank:be.get(t.id)??0,autoFocus:t.id===S,editable:u,legacyMarkdown:t.id===`legacy`?d.legacyMarkdown:void 0,actions:I},t.id)),(0,z.jsxs)(`svg`,{className:`canvas-ink`,"aria-hidden":`true`,onPointerDown:pe,onPointerMove:me,onPointerUp:he,onPointerCancel:he,children:[f.strokes.map(e=>(0,z.jsx)(`path`,{d:ve(e),className:`ink ink-${e.color} ${e.tool}`},e.id)),E.current&&(0,z.jsx)(`path`,{d:ew(E.current,N,g===`highlighter`),className:`ink ink-${v} ${g}`})]})]})})]})}export{hw as default}; \ No newline at end of file diff --git a/internal/web/dist/assets/emoji-data-DkoSvmMO.js b/internal/web/dist/assets/emoji-data--iPt3NLx.js similarity index 99% rename from internal/web/dist/assets/emoji-data-DkoSvmMO.js rename to internal/web/dist/assets/emoji-data--iPt3NLx.js index d8796ed6..0773d48a 100644 --- a/internal/web/dist/assets/emoji-data-DkoSvmMO.js +++ b/internal/web/dist/assets/emoji-data--iPt3NLx.js @@ -1,4 +1,4 @@ -import{v as e}from"./index-BqKtmCPh.js";var t={ar:()=>e(()=>import(`./ar-DPJDxCQI-DVxXrl8b.js`),[]),de:()=>e(()=>import(`./de-CakHBokE-Bc7uuGiX.js`),[]),en:()=>e(()=>import(`./en-BGdzE27X-TW1aad9S.js`),[]),es:()=>e(()=>import(`./es-VeBX6MEG-Kiej93jn.js`),[]),fa:()=>e(()=>import(`./fa-Dt7EYtKf-B5W0KSh4.js`),[]),fr:()=>e(()=>import(`./fr-DUhhjxrJ-ZlHjDAmJ.js`),[]),he:()=>e(()=>import(`./he-BShJg1dK-LKJKt0F1.js`),[]),hr:()=>e(()=>import(`./hr-BXtyqmwg-DyP3pX1K.js`),[]),is:()=>e(()=>import(`./is-2Fb-0w_j-BgcKBDLw.js`),[]),it:()=>e(()=>import(`./it-CiZtVb3Y-DvxSJeVo.js`),[]),ja:()=>e(()=>import(`./ja-CsxD3kEL-CvaZrDnL.js`),[]),ko:()=>e(()=>import(`./ko-It6g03Cy-ZSCK4kOT.js`),[]),nb:()=>e(()=>import(`./nb-CLao87La-CG_xJQwn.js`),[]),nl:()=>e(()=>import(`./nl-JQSo8dht-CaVSlD7w.js`),[]),pl:()=>e(()=>import(`./pl-DEMBgHEP-Dj8IbNR0.js`),[]),pt:()=>e(()=>import(`./pt-CBCdYAax-CxE-Nyim.js`),[]),ru:()=>e(()=>import(`./ru-BQk_9Q-L-c3bOsG2P.js`),[]),sk:()=>e(()=>import(`./sk-kgB2DtDL-Dc169kAC.js`),[]),tr:()=>e(()=>import(`./tr-DkcSXX8f-jMWTyLfk.js`),[]),uk:()=>e(()=>import(`./uk-Bib-e6bV-ErQ7vi1L.js`),[]),uz:()=>e(()=>import(`./uz-B2jaKhJb-BWnnlbUQ.js`),[]),vi:()=>e(()=>import(`./vi-V_GFRxE8-B_ZUa_6s.js`),[]),zh:()=>e(()=>import(`./zh-jglyCmjs-BDbB1o9o.js`),[]),"zh-hant":()=>e(()=>import(`./zh-hant-2ZrAkFnC-CdiPnK-W.js`),[])},n={no:`nb`,"zh-tw":`zh-hant`},r=new Map;function i(e){return{light:e(0),"medium-light":e(1),medium:e(2),"medium-dark":e(3),dark:e(4)}}function a(e){let[t,n,r,...a]=e.split(` +import{v as e}from"./index-DcxPhBy8.js";var t={ar:()=>e(()=>import(`./ar-DPJDxCQI-DVxXrl8b.js`),[]),de:()=>e(()=>import(`./de-CakHBokE-Bc7uuGiX.js`),[]),en:()=>e(()=>import(`./en-BGdzE27X-TW1aad9S.js`),[]),es:()=>e(()=>import(`./es-VeBX6MEG-Kiej93jn.js`),[]),fa:()=>e(()=>import(`./fa-Dt7EYtKf-B5W0KSh4.js`),[]),fr:()=>e(()=>import(`./fr-DUhhjxrJ-ZlHjDAmJ.js`),[]),he:()=>e(()=>import(`./he-BShJg1dK-LKJKt0F1.js`),[]),hr:()=>e(()=>import(`./hr-BXtyqmwg-DyP3pX1K.js`),[]),is:()=>e(()=>import(`./is-2Fb-0w_j-BgcKBDLw.js`),[]),it:()=>e(()=>import(`./it-CiZtVb3Y-DvxSJeVo.js`),[]),ja:()=>e(()=>import(`./ja-CsxD3kEL-CvaZrDnL.js`),[]),ko:()=>e(()=>import(`./ko-It6g03Cy-ZSCK4kOT.js`),[]),nb:()=>e(()=>import(`./nb-CLao87La-CG_xJQwn.js`),[]),nl:()=>e(()=>import(`./nl-JQSo8dht-CaVSlD7w.js`),[]),pl:()=>e(()=>import(`./pl-DEMBgHEP-Dj8IbNR0.js`),[]),pt:()=>e(()=>import(`./pt-CBCdYAax-CxE-Nyim.js`),[]),ru:()=>e(()=>import(`./ru-BQk_9Q-L-c3bOsG2P.js`),[]),sk:()=>e(()=>import(`./sk-kgB2DtDL-Dc169kAC.js`),[]),tr:()=>e(()=>import(`./tr-DkcSXX8f-jMWTyLfk.js`),[]),uk:()=>e(()=>import(`./uk-Bib-e6bV-ErQ7vi1L.js`),[]),uz:()=>e(()=>import(`./uz-B2jaKhJb-BWnnlbUQ.js`),[]),vi:()=>e(()=>import(`./vi-V_GFRxE8-B_ZUa_6s.js`),[]),zh:()=>e(()=>import(`./zh-jglyCmjs-BDbB1o9o.js`),[]),"zh-hant":()=>e(()=>import(`./zh-hant-2ZrAkFnC-CdiPnK-W.js`),[])},n={no:`nb`,"zh-tw":`zh-hant`},r=new Map;function i(e){return{light:e(0),"medium-light":e(1),medium:e(2),"medium-dark":e(3),dark:e(4)}}function a(e){let[t,n,r,...a]=e.split(` `),o=`0,1,3,4,5,6,7,8,9`.split(`,`).map(Number),s=`😀 0 1 😃 0 0.6 😄 0 0.6 diff --git a/internal/web/dist/assets/exportNotebook-BOlYJYx0.js b/internal/web/dist/assets/exportNotebook-BDS11KSz.js similarity index 98% rename from internal/web/dist/assets/exportNotebook-BOlYJYx0.js rename to internal/web/dist/assets/exportNotebook-BDS11KSz.js index de1ee457..b6c86cec 100644 --- a/internal/web/dist/assets/exportNotebook-BOlYJYx0.js +++ b/internal/web/dist/assets/exportNotebook-BDS11KSz.js @@ -1,3 +1,3 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/blocknote-BePxcw92.js","assets/rolldown-runtime-COiEfhsA.js"])))=>i.map(i=>d[i]); -import{C as e,E as t,S as n,T as r,b as i,d as a,i as o,v as s,w as c,x as l}from"./index-BqKtmCPh.js";var u=`kynotes.export.v1`,d=`attachment://`,f=`attachments`,p=`kynotes-export:`,m=100,h=/[\u0000-\u001f\u007f-\u009f<>:"/\\|?*‎‏‪-‮⁦-⁩]/g,g=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/i;function _(e,t){let n=e=>e.replace(/^[\s.]+|[\s.]+$/g,``),r=n(Array.from(n(e.normalize(`NFC`).replace(h,`_`))).slice(0,m).join(``));return r?g.test(r)?`_${r}`:r:t}function v(){let e=new Map;return(t,n,r=``)=>{let i=e.get(t)??new Set;e.set(t,i);for(let e=1;;e+=1){let t=e===1?n:`${n} (${e})`,a=[t+r,...r===`.md`?[`${t}.canvas.json`,`${t}.json`]:[]].map(e=>e.toLowerCase());if(!a.some(e=>i.has(e)))return a.forEach(e=>i.add(e)),t}}}var y=(...e)=>e.filter(Boolean).join(`/`);function b(e,t){let n=e.split(`/`).slice(0,-1),r=t.split(`/`),i=0;for(;ie.map(e=>{let t=e.props?.url,o;if(typeof t==`string`&&t){let e=t.startsWith(d)?n.get(t.slice(13)):void 0;o=`${p}${i.push(e?b(r,e):t)-1}`}return{...e,...o?{props:{...e.props,url:o}}:{},...e.children?{children:a(e.children)}:{}}});return t(a(e)).replace(RegExp(`${p}(\\d+)`,`g`),(e,t)=>i[Number(t)]??``)}async function C(o,s=new Date){let d=new TextEncoder,p=v(),m=_(o.name,`Notebook`),h=[],g=o.unreadable;p(m,`manifest`,`.json`),p(m,f);let C=c(o.groups),w=new Map,T=e=>{if(e===void 0)return m;let t=w.get(e);if(t!==void 0)return t;let n=T(C.get(e)),r=o.groups.find(t=>t.id===e),i=y(n,p(n,_(r.title,`Untitled group`)));return w.set(e,i),i};[...o.groups].sort(i).sort((e,t)=>r(e.id,C).length-r(t.id,C).length).forEach(e=>T(e.id));let E=n(o.sections),D=new Map(E.map(e=>{let n=T(t(e,C));return[e.id,y(n,p(n,_(e.title,`Untitled section`)))]})),O=new Map,k=new Map,A=new Set,j=async e=>{let t;try{t=await o.attachments.list(e)}catch{return g+=1,[]}let n=[];for(let e of t){if(A.has(e.id)||n.some(t=>t.id===e.id))continue;let t=k.get(e.id);if(!t)try{let n=await o.attachments.open(e),r=y(y(m,f,_(e.id,`attachment`)),_(n.name,`file`));t={id:e.id,name:n.name,type:n.type,path:r},k.set(e.id,t),O.set(e.id,r),h.push({path:r,data:n.bytes})}catch{A.add(e.id),g+=1;continue}n.push(t)}return n},M=[],N=[...E.map(e=>[e.id,D.get(e.id)]),[void 0,y(m,p(m,`Quick Notes`))]];for(let[t,n]of N){let r=l(o.notes,o.sections,t??`quick`),i=e(r);for(let[e,s]of r.entries()){let r=s.title.trim()||`Untitled page`,c=p(n,`${String(e+1).padStart(3,`0`)} ${_(r,`Untitled page`)}`,`.md`),l=y(n,`${c}.md`),u=await j(s.id),f=x(s.body),v=y(n,`${c}${f?`.canvas`:``}.json`),C=!0,w;try{w=S(a(s.body),o.toMarkdown,O,l).trim()}catch{C=!1,g+=1,w=`_This page could not be converted to Markdown. Its content is kept as saved in [${c}${f?`.canvas`:``}.json](${b(l,v)})._`}let T=`# ${r.replace(/\s+/g,` `)}\n\n${w}\n`;f&&C&&(T+=`\n_Canvas page: positions and ink are in [${c}.canvas.json](${b(l,v)})._\n`),u.length&&(T+=`\n## Attachments\n\n${u.map(e=>`- [${e.name.replace(/[[\]\\]/g,`\\$&`)}](${b(l,e.path)})`).join(` +import{C as e,E as t,S as n,T as r,b as i,d as a,i as o,v as s,w as c,x as l}from"./index-DcxPhBy8.js";var u=`kynotes.export.v1`,d=`attachment://`,f=`attachments`,p=`kynotes-export:`,m=100,h=/[\u0000-\u001f\u007f-\u009f<>:"/\\|?*‎‏‪-‮⁦-⁩]/g,g=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/i;function _(e,t){let n=e=>e.replace(/^[\s.]+|[\s.]+$/g,``),r=n(Array.from(n(e.normalize(`NFC`).replace(h,`_`))).slice(0,m).join(``));return r?g.test(r)?`_${r}`:r:t}function v(){let e=new Map;return(t,n,r=``)=>{let i=e.get(t)??new Set;e.set(t,i);for(let e=1;;e+=1){let t=e===1?n:`${n} (${e})`,a=[t+r,...r===`.md`?[`${t}.canvas.json`,`${t}.json`]:[]].map(e=>e.toLowerCase());if(!a.some(e=>i.has(e)))return a.forEach(e=>i.add(e)),t}}}var y=(...e)=>e.filter(Boolean).join(`/`);function b(e,t){let n=e.split(`/`).slice(0,-1),r=t.split(`/`),i=0;for(;ie.map(e=>{let t=e.props?.url,o;if(typeof t==`string`&&t){let e=t.startsWith(d)?n.get(t.slice(13)):void 0;o=`${p}${i.push(e?b(r,e):t)-1}`}return{...e,...o?{props:{...e.props,url:o}}:{},...e.children?{children:a(e.children)}:{}}});return t(a(e)).replace(RegExp(`${p}(\\d+)`,`g`),(e,t)=>i[Number(t)]??``)}async function C(o,s=new Date){let d=new TextEncoder,p=v(),m=_(o.name,`Notebook`),h=[],g=o.unreadable;p(m,`manifest`,`.json`),p(m,f);let C=c(o.groups),w=new Map,T=e=>{if(e===void 0)return m;let t=w.get(e);if(t!==void 0)return t;let n=T(C.get(e)),r=o.groups.find(t=>t.id===e),i=y(n,p(n,_(r.title,`Untitled group`)));return w.set(e,i),i};[...o.groups].sort(i).sort((e,t)=>r(e.id,C).length-r(t.id,C).length).forEach(e=>T(e.id));let E=n(o.sections),D=new Map(E.map(e=>{let n=T(t(e,C));return[e.id,y(n,p(n,_(e.title,`Untitled section`)))]})),O=new Map,k=new Map,A=new Set,j=async e=>{let t;try{t=await o.attachments.list(e)}catch{return g+=1,[]}let n=[];for(let e of t){if(A.has(e.id)||n.some(t=>t.id===e.id))continue;let t=k.get(e.id);if(!t)try{let n=await o.attachments.open(e),r=y(y(m,f,_(e.id,`attachment`)),_(n.name,`file`));t={id:e.id,name:n.name,type:n.type,path:r},k.set(e.id,t),O.set(e.id,r),h.push({path:r,data:n.bytes})}catch{A.add(e.id),g+=1;continue}n.push(t)}return n},M=[],N=[...E.map(e=>[e.id,D.get(e.id)]),[void 0,y(m,p(m,`Quick Notes`))]];for(let[t,n]of N){let r=l(o.notes,o.sections,t??`quick`),i=e(r);for(let[e,s]of r.entries()){let r=s.title.trim()||`Untitled page`,c=p(n,`${String(e+1).padStart(3,`0`)} ${_(r,`Untitled page`)}`,`.md`),l=y(n,`${c}.md`),u=await j(s.id),f=x(s.body),v=y(n,`${c}${f?`.canvas`:``}.json`),C=!0,w;try{w=S(a(s.body),o.toMarkdown,O,l).trim()}catch{C=!1,g+=1,w=`_This page could not be converted to Markdown. Its content is kept as saved in [${c}${f?`.canvas`:``}.json](${b(l,v)})._`}let T=`# ${r.replace(/\s+/g,` `)}\n\n${w}\n`;f&&C&&(T+=`\n_Canvas page: positions and ink are in [${c}.canvas.json](${b(l,v)})._\n`),u.length&&(T+=`\n## Attachments\n\n${u.map(e=>`- [${e.name.replace(/[[\]\\]/g,`\\$&`)}](${b(l,e.path)})`).join(` `)}\n`),h.push({path:l,data:d.encode(T)}),(f||!C)&&h.push({path:v,data:d.encode(s.body)}),M.push({id:s.id,title:s.title,section:t??null,level:i[e],path:l.slice(m.length+1),...f?{canvas:y(n,`${c}.canvas.json`).slice(m.length+1)}:{},attachments:u.map(e=>({...e,path:e.path.slice(m.length+1)}))})}}let P={format:u,notebook:o.name,exportedAt:s.toISOString(),groups:o.groups.map(e=>({id:e.id,title:e.title,color:e.color,parent:C.get(e.id)??null,path:w.get(e.id).slice(m.length+1)})),sections:E.map(e=>({id:e.id,title:e.title,color:e.color,group:t(e,C)??null,path:D.get(e.id).slice(m.length+1)})),pages:M,unreadable:g};return h.unshift({path:y(m,`manifest.json`),data:d.encode(`${JSON.stringify(P,null,2)}\n`)}),{entries:h,pages:M.length,unreadable:g}}async function w(){let{BlockNoteEditor:e}=await s(async()=>{let{BlockNoteEditor:e}=await import(`./blocknote-BePxcw92.js`).then(e=>e.t);return{BlockNoteEditor:e}},__vite__mapDeps([0,1])),t=e.create();return e=>t.blocksToMarkdownLossy(e)}export{w as blockNoteMarkdown,C as buildNotebookExport,_ as safeName}; \ No newline at end of file diff --git a/internal/web/dist/assets/index-BqKtmCPh.js b/internal/web/dist/assets/index-BqKtmCPh.js deleted file mode 100644 index 8acc9331..00000000 --- a/internal/web/dist/assets/index-BqKtmCPh.js +++ /dev/null @@ -1,38 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CanvasPage-f0oQsOxU.js","assets/rolldown-runtime-COiEfhsA.js","assets/blocknote-BePxcw92.js","assets/CanvasPage-EZlfyAbl.css"])))=>i.map(i=>d[i]); -import{i as e,r as t,t as n}from"./rolldown-runtime-COiEfhsA.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var i=e=>e?`"${e}" `:``;function a(e,t=``){if(typeof e!=`number`)throw TypeError(i(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(i(t)+`expected integer >= 0, got `+e);return e}function o(e,t,n=``){if(r(e)&&(t===void 0||e.length===t))return e;t!==void 0&&a(t,`length`);let o=r(e),s=t===void 0?``:` of length ${t}`,c=o?`length=${e.length}`:`type=${typeof e}`,l=i(n)+`expected Uint8Array`+s+`, got `+c;throw o?RangeError(l):TypeError(l)}function s(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(a(e.outputLen),a(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var c=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},l=(e,t)=>{c(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 u(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function d(e,t){o(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function f(...e){for(let t=0;t>>t}var h=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,g=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function _(e){if(o(e),h)return e.toHex();let t=``;for(let n=0;n=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function y(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(h)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;te(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 S(e=32){a(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 C=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),w=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(s(e),o(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{let e=((e,t,n)=>new w(e,t).update(n).digest());return e.create=(e,t)=>new w(e,t),e})(),E=Uint8Array.of(0),D=Uint8Array.of();function O(e,t,n,r=32,i){s(e),a(r,`length`),o(t,void 0,`prk`);let c=e.outputLen;if(t.length255*c)throw Error(`Length must be <= 255*HashLen`);let l=Math.ceil(r/c);if(n===void 0?n=D:o(n,void 0,`info`),!l)return i&&f(t),new Uint8Array;let u=i&&l===1?t:new Uint8Array(l*c),{iHash:d,oHash:p}=T.create(e,t),m=i?t:new Uint8Array(c),h=l>1?i?.iHash||e.create():void 0;for(let e=0;e1&&d.update(m),d.update(n).update(E).digestInto(m),p.update(m).digestInto(m),u.set(m,c*(l-1)),d.destroy(),p.destroy(),h?.destroy(),m!==u&&f(m),f(E),r===u.length)return u;let g=u.slice(0,r);return f(u),g}var k=(e,t,n,r,i)=>{s(e),n===void 0&&(n=new Uint8Array(e.outputLen));let a=T.create(e,n).update(t);return O(e,a.digest(),r,i,a)},A=e=>e/2**32|0,j=e=>e>>>0;function M(e,t,n,r){let i=A(n),a=j(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function N(e,t,n){return e&t^~e&n}function P(e,t,n){return e&t^e&n^t&n}var F=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=p(this.buffer)}update(e){u(this),o(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;or-a&&(this.process(n,0),t.fill(0)),M(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:p(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>>3,i=m(n,17)^m(n,19)^n>>>10;R[e]=i+R[e-7]+r+R[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=m(o,6)^m(o,11)^m(o,25),u=l+t+N(o,s,c)+L[e]+R[e]|0,d=(m(n,2)^m(n,13)^m(n,22))+P(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(){f(R)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),f(this.buffer)}},te=class extends ee{constructor(){super(32,I)}},z=x(()=>new te,C(1)),ne=`0123456789abcdefghijklmnopqrstuvwxyz`,re=/^[0-9a-z]*[1-9a-z]$/,B=e=>typeof e==`string`&&e.length<=512&&re.test(e);function ie(e,t){let n=e??``,r=t;if(r!==null&&n>=r)throw Error(`order keys out of order`);let i=``;for(let a=0;;a+=1){let o=ao&&c512)throw Error(`order key limit reached`);return e}i+=ne[o],r=null}}var ae=e=>Math.min(2,Math.max(0,e??0)),oe=(e,t)=>t>0&&e[t].section===e[t-1].section;function V(e){let t=[];return e.forEach((n,r)=>t.push(oe(e,r)?Math.min(ae(n.level),t[r-1]+1):0)),t}function H(e,t){let n=t+1;for(;ne[t];)n+=1;return[t,n]}function se(e,t){let n=V(e),r=[],i=1/0;return e.forEach((a,o)=>{let s=n[o];if(s>i)return;i=1/0;let c=o+1s,l=c&&t.has(a.id);r.push({item:a,level:s,hasChildren:c,collapsed:l}),l&&(i=s)}),r}function ce(e,t){let n=V(e),r=e.findIndex(e=>e.id===t),i=[],a=n[r];for(let t=r-1;t>=0&&a>0;--t)n[t]2)&&!(n===1&&(!oe(e,t)||i>r[t-1]+1)))return i}function ue(e,t,n,r){let i=Math.max(0,Math.min(r,e.length)),a=V(e),o=Math.min(n[0],i===0?0:a[i-1]+1),s=n.map(e=>ae(e-n[0]+o)),c=e[i-1]?.order??null,l=e[i]?.order??null;if(e.every(e=>e.order)&&(c===null||l===null||c(e=ie(e,l),{id:t.id,order:e,level:s[n]}))}catch{}let u=null;return[...e.slice(0,i).map(e=>({id:e.id})),...t.map((e,t)=>({id:e.id,level:s[t]})),...e.slice(i).map(e=>({id:e.id}))].map(e=>(u=ie(u,null),e.level===void 0?{id:e.id,order:u}:{id:e.id,order:u,level:e.level}))}function de(e){let t=new Map(e.map(e=>[e.id,e.group])),n=new Map;for(let{id:r,group:i}of e){let e=new Set([r]),a=1,o=i;for(;o!==void 0&&t.has(o)&&!e.has(o)&&a<=4;)e.add(o),a+=1,o=t.get(o);let s=o!==void 0&&e.has(o);n.set(r,i!==void 0&&t.has(i)&&!s&&a<=4?i:void 0)}return n}var fe=(e,t)=>e.group!==void 0&&t.has(e.group)?e.group:void 0;function pe(e,t){let n=[],r=e;for(;r!==void 0&&t.has(r)&&n.length<=4;)n.unshift(r),r=t.get(r);return n}function me(e,t){let n=0;for(let[r,i]of t)i===e&&(n=Math.max(n,me(r,t)));return n+1}function he(e,t,n){let r=pe(t,n);return!r.includes(e)&&r.length+me(e,n)<=4}function ge(e,t,n){let r=ve(e);return e.filter(e=>n===void 0||he(n,e.id,t)).map(e=>({id:e.id,label:pe(e.id,t).map(e=>r.get(e)).join(` › `)})).sort((e,t)=>e.label.localeCompare(t.label))}function _e(e,t,n){let r=ve(t);return e.map(e=>({id:e.id,label:[...pe(fe(e,n),n).map(e=>r.get(e)),e.title||`Untitled section`].join(` › `)})).sort((e,t)=>e.label.localeCompare(t.label))}var ve=e=>new Map(e.map(e=>[e.id,e.title||`Untitled group`]));function ye(e,t,n){let r=t.find(t=>t.id===e);return r?fe(r,n):void 0}function be(e,t,n){let r=e[t];if(n===-1){let n=t-1;for(;n>=0&&e[n]>r;)--n;return n>=0&&e[n]===r?n:void 0}let i=H(e,t)[1];return e[i]===r?H(e,i)[1]:void 0}function xe(e,t,n){let[r,i]=H(e,t);if(!(n>=r&&ntypeof e==`string`):[])}catch{return new Set}}var Ce=`quick`,we=[`orange`,`blue`,`green`,`purple`,`red`,`teal`,`yellow`,`gray`],Te=/^obj_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,Ee=/^cnt_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,De=/^(cmt_[0-9abcdefghjkmnpqrstvwxyz]{26}|att_[0-9abcdefghjkmnpqrstvwxyz]{26}(\/meta)?)$/,Oe=/^[0-9a-f]{64}$/;function ke(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e):[];return Object.fromEntries(t.filter(([e,t])=>De.test(e)&&typeof t==`string`&&Oe.test(t)))}function Ae(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=B(t.order)?t.order:void 0,r=typeof t.group==`string`&&Te.test(t.group)?t.group:void 0;if(t.type===`section`||t.type===`group`)return{type:t.type,title:typeof t.title==`string`?t.title:t.type===`group`?`Untitled group`:`Untitled section`,color:we.includes(t.color)?t.color:`gray`,order:n,group:r};if(typeof t.body!=`string`)return;let i={type:`page`,title:typeof t.title==`string`?t.title:``,body:t.body};return`section`in t&&(i.section=typeof t.section==`string`&&Te.test(t.section)?t.section:void 0),`order`in t&&(i.order=n),`level`in t&&(i.level=t.level===0||t.level===1||t.level===2?t.level:void 0),`legacy`in t&&(i.legacy=ke(t.legacy)),i}function je(e,t){return e.order&&t.order&&e.order!==t.order?e.ordert.id):e.order?-1:1}var Me=e=>[...e].sort(je);function Ne(e,t,n){let r=new Set(t.map(e=>e.id));return e.filter(e=>n===`quick`?!e.section||!r.has(e.section):e.section===n).sort(je)}function Pe(e){return ie(e.reduce((e,t)=>t.order&&(e===null||t.order>e)?t.order:e,null),null)}function Fe(e,t,n){let r=e.filter(e=>e.id!==t),i=Math.max(0,Math.min(n,r.length));if(r.every(e=>e.order))try{return[{id:t,order:ie(r[i-1]?.order??null,r[i]?.order??null)}]}catch{}let a=null;return[...r.slice(0,i),{id:t},...r.slice(i)].map(e=>(a=ie(a,null),{id:e.id,order:a}))}function Ie(e,t,n){let r=V(e),i=e.findIndex(e=>e.id===t.id),a=Fe(e,``,i<0?e.length:H(r,i)[1]);return{page:{type:`page`,title:`${n.title||`Untitled page`} (conflicting copy)`,body:n.body,section:t.section,order:a.find(e=>e.id===``)?.order,level:i<0?void 0:r[i],legacy:{}},moves:a.filter(e=>e.id!==``)}}function Le(e,t){let n=e=>JSON.stringify([e.title,e.body]),r=[],i=new Map;for(let a of[...t].sort((e,t)=>e.createdAtt.createdAt))){let t=n(a.payload),o=i.get(t);t===n(e)?r.push(a.id):o?o.ids.push(a.id):i.set(t,{payload:a.payload,ids:[a.id]})}return{resolveOnly:r,groups:[...i.values()]}}function Re(e,t){return e===`quick`||e&&t.some(t=>t.id===e)?e:Me(t)[0]?.id??`quick`}function ze(e){let[t=``,n=``,r=``]=e.replace(/^#\/?/,``).split(`/`);return{container:Ee.test(t)?t:void 0,section:n===`quick`||Te.test(n)?n:void 0,page:Te.test(r)?r:void 0}}function Be({container:e,section:t,page:n}){return e?`#/${[e,t,t?n:void 0].filter(Boolean).join(`/`)}`:``}var Ve=[[`account`,`Account`],[`devices`,`Phones & apps`],[`appearance`,`Appearance`],[`reminders`,`Reminders`],[`colleague-keys`,`Colleague keys`],[`share-links`,`Share links`],[`unsent`,`Unsent edits`]],He={"#password":`account`,"#device":`account`,"#link-this-browser":`devices`,"#link-devices":`devices`,"#reminders":`reminders`,"#colleague-keys":`colleague-keys`};function Ue(e){let t=/^#\/settings(?:\/([a-z-]+))?$/.exec(e);return t?Ve.find(([e])=>e===(t[1]??`account`))?.[0]:He[e]}var We=e=>`#/settings/${e}`,Ge=new TextEncoder,Ke=new TextDecoder,qe=(e,t,n,r)=>k(z,e,n,r,t),Je=`KyNotes needs a secure connection. Open it over HTTPS, or on localhost.`,Ye=()=>typeof crypto<`u`&&typeof crypto.getRandomValues==`function`&&typeof crypto.subtle?.importKey==`function`;function Xe(){if(!Ye())throw Error(Je);return crypto.subtle}function Ze(e){if(!Ye())throw Error(Je);return crypto.getRandomValues(e)}function Qe(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function $e(e){let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))}function et(e){return e.slice().buffer}async function tt(e){return new Uint8Array(await Xe().digest(`SHA-256`,et(e)))}async function nt(e){return[...await tt(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function rt(e,t,n){let r=await Xe().importKey(`raw`,et(e),`PBKDF2`,!1,[`deriveBits`]);return new Uint8Array(await Xe().deriveBits({name:`PBKDF2`,salt:et(t),iterations:n,hash:`SHA-256`},r,256))}var it=(e,t,n)=>rt(Ge.encode(e),$e(t),n),at=6e5,ot=Ge.encode(`kynotes/recovery-kek/v1`);function st(e,t){let n=new Uint8Array(ot.length+t.length);return n.set(ot),n.set(t,ot.length),rt(e,n,at)}var ct=6e5,lt=1e5;async function ut(e,t,n,r=ct){if(!Number.isSafeInteger(n)||nqe(i,32,new Uint8Array,Ge.encode(e));return{authSecret:[...a(`kynotes/auth/v1`)].map(e=>e.toString(16).padStart(2,`0`)).join(``),userKEK:a(`kynotes/user-kek/v1`)}}async function dt(e,t,n,r=ct){return(await ut(e,t,n,r)).authSecret}function ft(){return Qe(Ze(new Uint8Array(16)))}var U=2,pt=`kynotes/content/v2`;function mt(e,t){if(e.byteLength!==32)throw Error(`Refusing a content key that is not 256 bits`);return Xe().importKey(`raw`,et(e),`AES-GCM`,!1,[t])}async function ht(e,t,n){let r=Ze(new Uint8Array(12)),i=await mt(e,`encrypt`),a=await Xe().encrypt({name:`AES-GCM`,iv:et(r),...n&&{additionalData:et(n)}},i,et(t)),o=+!!n,s=new Uint8Array(o+r.byteLength+a.byteLength);return n&&(s[0]=U),s.set(r,o),s.set(new Uint8Array(a),o+r.byteLength),s}async function gt(e,t,n){let r=+!!n;if(t.byteLengthGe.encode(e)),i=new Uint8Array(r.reduce((e,t)=>e+2+t.length,0)),a=0;for(let e of r){if(e.length>65535)throw Error(`content ID too long`);new DataView(i.buffer).setUint16(a,e.length),i.set(e,a+2),a+=2+e.length}return i}var bt=(e,t,n,r,i)=>ht(vt(e,t,pt),i,yt(t,n,r));async function xt(e,t,n,r,i,a,o){if(a[0]===U)try{return{plaintext:await gt(vt(e,t,pt),a,yt(t,n,r)),v1:!1}}catch(e){if(!o)throw e}if(!o)throw Error(`Unable to decrypt: an older format this notebook no longer accepts, or tampered ciphertext`);return{plaintext:await gt(vt(e,t,i),a),v1:!0}}var W=async(...e)=>JSON.parse(Ke.decode((await xt(...e)).plaintext));async function St(e,t,n,r=!1){return bt(e,t,t,`container-meta`,Ge.encode(JSON.stringify(r?{name:n,objects:2}:{name:n})))}async function Ct(e,t,n,r){if(n.byteLength<13)throw Error(`Encrypted workspace metadata is too short`);let i=await xt(e,t,t,`container-meta`,`kynotes/container-meta/v1`,n,r),a=JSON.parse(Ke.decode(i.plaintext));if(typeof a.name!=`string`)throw Error(`Invalid workspace metadata`);return!i.v1&&a.objects===2?{name:a.name,objects:2}:{name:a.name}}var wt=(e,t,n,r,i=``)=>bt(e,t,n,`comment`,Ge.encode(JSON.stringify({body:r,section:i})));async function Tt(e,t,n,r,i){return W(e,t,n,`comment`,`kynotes/comment/v1`,r,i)}var Et=(e,t,n,r)=>bt(e,t,n,`share-label`,Ge.encode(JSON.stringify(r))),G=(e,t,n,r)=>W(e,t,n,`share-label`,`kynotes/share-label/v1`,r,!1),Dt=(e,t,n,r)=>bt(e,t,n,`attachment-meta`,Ge.encode(JSON.stringify(r)));async function Ot(e,t,n,r,i){return W(e,t,n,`attachment-meta`,`kynotes/attachment-meta/v1`,r,i)}var kt=(e,t,n,r)=>bt(e,t,n,`attachment`,r);async function At(e,t,n,r,i){return(await xt(e,t,n,`attachment`,`kynotes/object/v1`,r,i)).plaintext}async function jt(e,t,n,r){return bt(e,t,n,`object`,Ge.encode(JSON.stringify(r)))}async function Mt(e,t,n,r,i){if(r.byteLength<13)throw Error(`Encrypted data is too short`);let a=await xt(e,t,n,`object`,`kynotes/object/v1`,r,i);return{payload:Ae(JSON.parse(Ke.decode(a.plaintext))),v1:a.v1}}var Nt=async(...e)=>(await Mt(...e)).payload,Pt=e=>`${e}/meta`;async function Ft(e,t,n,r){return e?e.legacy?Object.hasOwn(e.legacy,n)&&e.legacy[n]===await nt(r):!t:!1}async function It(e){let t=Ze(new Uint8Array(32));return{ciphertext:await ht(t,Ge.encode(JSON.stringify(e))),key:Rt(t)}}async function Lt(e,t){let n=await gt(zt(t),e);return JSON.parse(Ke.decode(n))}function Rt(e){return Qe(e).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}function zt(e){return $e(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`)+`=`.repeat((4-e.length%4)%4))}var Bt=e=>({type:`page`,title:e.title,body:e.body,section:e.section,order:e.order,level:e.level,legacy:e.legacy});function Vt(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}var Ht=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])};function Ut(e,t,n,r){return e.map(e=>e.id===t.id?Ht(e,t)?n:{...e,...r}:e)}function Wt(e,t,n){return e.map(e=>e.id===t&&n.version>e.version?{...e,version:n.version,updatedAt:n.updatedAt??e.updatedAt}:e)}var Gt=(e,t)=>e.title===t.title&&e.body===t.body&&e.section===t.section&&e.order===t.order&&e.level===t.level&&e.legacy===t.legacy;function Kt(e,t){return t&&t.version>=e.version?{...e,title:t.title,body:t.body}:e}function qt(e,t){return e.map(e=>{let n=t.get(e.id);return n&&n.version>e.version?{...e,version:n.version}:e})}function Jt(e,t){return[...t].reduce((e,[t,n])=>Wt(e,t,n),e)}function Yt(e,t,n){return e?.id===t?n?Gt(e,n)?`done`:`again`:`failed`:`done`}async function Xt(e,t,n){let r=e()?.id;if(!r)return`done`;for(let i=0;i`${e} item(s) in this notebook could not be read or decrypted and are not shown. They remain on the server; reload to try again.`;function Qt(e){switch(e){case`unauthenticated`:case`password_change_required`:return`You were signed out, so your edits are kept only in this browser. Sign out, then sign in again to send them.`;case`quota_exceeded`:return`Your storage is full, so this edit is kept only in this browser. Delete pages or notebooks, or ask your administrator to raise your quota; it is sent once there is room.`;case`payload_too_large`:return`This page is too large to save, so the edit is kept only in this browser. Split it into smaller pages.`}}function $t(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;ro(e,t,n),tn=a;function nn(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 rn(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var an=_,on=e=>y(e),sn=r,cn=e=>S(e),ln=BigInt(0),un=BigInt(1),dn=e=>e?`"${e}" `:``;function fn(e,t=``){if(typeof e!=`boolean`)throw TypeError(dn(t)+`expected boolean, got type=`+typeof e);return e}function pn(e){if(typeof e==`bigint`){if(!xn(e))throw RangeError(`positive bigint expected, got `+e)}else tn(e);return e}function mn(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 hn(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?ln:BigInt(`0x`+e)}function gn(e){return hn(_(e))}function _n(e){return hn(_(bn(o(e)).reverse()))}function vn(e,t){if(a(t),t===0)throw Error(`zero output length is invalid`);e=pn(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return y(r.padStart(n,`0`))}function yn(e,t){return vn(e,t).reverse()}function bn(e){return Uint8Array.from(en(e))}function xn(e){return typeof e==`bigint`&&ln<=e}function Sn(e,t,n){return xn(e)&&xn(t)&&xn(n)&&t<=e&&e(mn(e,`n`),(un<Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var Dn=BigInt(0),K=BigInt(1),On=BigInt(2),kn=BigInt(3),An=BigInt(4),jn=BigInt(5),Mn=BigInt(7),Nn=BigInt(8),Pn=BigInt(9),Fn=BigInt(15),In=BigInt(16),Ln=BigInt(`0x10000000000000000`);function Rn(e,t){if(t<=Dn)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=Dn?n:t+n}function zn(e,t,n){if(n<=K)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(tDn;)t&K&&(e=e*r%n),r=r*r%n,t>>=K;return e}let i=[];for(;t>Dn;)i.push(Number(t&Fn)),t>>=An;let a=Array(16);a[0]=K,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 Bn(e,t,n){if(n<=K)throw Error(`pow2: expected modulus > 1, got `+n);if(tDn;)r*=r,r%=n;return r}function Vn(e,t){if(e===Dn)throw Error(`invert: expected non-zero number`);if(t<=K)throw Error(`invert: expected modulus > 1, got `+t);let n=Rn(e,t),r=t,i=Dn,a=K;for(;n!==Dn;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==K)throw Error(`invert: does not exist`);return Rn(i,t)}function Hn(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Un(e,t){if((e&K)===Dn)throw Error(t+`: expected odd modulus, got `+e)}function Wn(e,t){let n=e,r=(n.ORDER+K)/An,i=n.pow(t,r);return Hn(n,i,t),i}function Gn(e,t){let n=e,r=(n.ORDER-jn)/Nn,i=n.mul(t,On),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,On),a),c=n.mul(o,n.sub(s,n.ONE));return Hn(n,c,t),c}function Kn(e){let t=rr(e),n=qn(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Mn)/In;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 Hn(n,m,t),m})}function qn(e){if(e1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Wn;let a=i.pow(r,t),o=(t+K)/On;return function(e,r){let i=e;if(i.is0(r))return r;if($n(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=K<(Rn(e,t)&K)===K,Xn=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Zn(e){if(nn(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);mn(e.BYTES,`BYTES`),mn(e.BITS,`BITS`);for(let t of Xn)rn(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=K)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function Qn(e,t,n=!1){Zn(e),$t(t,`nums`),fn(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 $n(e,t){Zn(e);let n=e;Un(n.ORDER,`FpLegendre`);let r=(n.ORDER-K)/On,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 er(e,t){if(t!==void 0&&tn(t),e<=Dn)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=wn(e);if(t!==void 0&&t= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var tr=new WeakMap,nr=class{ORDER;BITS;BYTES;isLE;ZERO=Dn;ONE=K;_lengths;_mod;constructor(e,t={}){if(e<=K)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}=er(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 Rn(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return Dn<=e&&er)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?_n(e):gn(e);if(o&&(s=Rn(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return Qn(this,e,!0)}cmov(e,t,n){return fn(n,`condition`),n?t:e}};function rr(e,t={}){return Object.freeze(nr.prototype),new nr(e,t)}var ir=BigInt(0),ar=BigInt(1),or=BigInt(4),sr=16,cr=128,lr=5,ur=2**31;function dr(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);rn(t.fromAffine,`Point.fromAffine`),rn(t.fromBytes,`Point.fromBytes`),rn(t.fromHex,`Point.fromHex`),nn(t.BASE,`Point.BASE`),nn(t.ZERO,`Point.ZERO`),Zn(t.Fp),Zn(t.Fn)}function fr(e,t){dr(e),gr(t,e);let n=Qn(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function pr(e,t,n=1){if(!Number.isSafeInteger(e)||et)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function mr(e,t){let n=e*(4*t+128);if(n>ur)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+ur/2**20+` MiB`)}function hr(e,t){if(e!==void 0){rn(e,`randomBytes`);try{let n=e(t);if(!sn(n)||n.length!==t)return}catch{return}return e}}function gr(e,t){$t(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function _r(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):xn(e)&&eir;){let t=0;e&ar&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=ar}return a}function Sr(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t>=o,t>i&&(t-=r,e+=ar),s.push(t)}if(e!==ir)throw Error(`invalid wnaf`);return s}function Cr(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>1];i=i.add(a<0?e.negate():e)}}}return i}var wr=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){dr(e),this.randomBytes=hr(t,sr),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;et.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),!Sn(t,ar,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=yr(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+cr,i=this.randomBytes(sr);if(!sn(i)||i.length!==sr)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+gn(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=lr,i=Tn(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>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===ar||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),!xn(t))throw Error(`invalid scalar`);let r=yr(e);if(r===1||t>=this.Point.Fn.ORDER)return Tr(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),pr(t,this.bits),mr((Math.ceil((this.bits+cr)/t)+1)*2**(t-1),this.Point.Fp.BYTES),vr.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return yr(e)!==1}};function Tr(e,t,n,r=!1){if(dr(e),gr(t,e),fn(r,`allowOversized`),_r(n,e.Fn,r?e.Fn.ORDER**or:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>br(e,4)),a=n.map(e=>xr(e,4));return Cr(e.ZERO,i,a)}function Er(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Zn(t),t}return rr(e,{isLE:n})}function Dr(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`);En(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(xn(n)&&n!==ir))throw Error(`CURVE.${e} must be positive bigint`)}let i=Er(t.p,n.Fp,r),a=Er(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 Or(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var kr=BigInt(0),Ar=BigInt(1),jr=BigInt(2),Mr=BigInt(4),Nr=BigInt(8);function Pr(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 Fr(e,t={}){En(t,{},{},`extraOpts`);let n=t,r=Dr(`edwards`,e,n,n.FpFnLE),{Fp:i,Fn:a}=r,o=r.CURVE,{h:s}=o;if($n(i,o.a)!==1)throw Error(`edwards: CURVE.a must be a square in Fp for complete addition formulas`);if($n(i,o.d)!==-1)throw Error(`edwards: CURVE.d must be a non-square in Fp for complete addition formulas`);En(n,{},{uvRatio:`function`,randomBytes:`function`});let c=n.randomBytes===void 0?cn:n.randomBytes,l=jr<{try{return{isValid:!0,value:i.sqrt(i.div(e,t))}}catch{return{isValid:!1,value:kr}}}:n.uvRatio;if(!Pr(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?Ar:kr;return Cn(`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=bn(en(e,n,`point`)),fn(t,`zip215`);let s=bn(e),c=e[n-1];s[n-1]=c&-129;let f=_n(s);Cn(`point.y`,f,kr,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(on(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(jr),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),jr),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===kr?h.ZERO:this.is0()||e===Ar?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(Nr):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===Ar?this:s===jr?this.double():s===Mr?this.double().double():s===Nr?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 an(this.toBytes())}toString(){return``}}let g=e=>fr(h,e),_=new wr(h,c);return _.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}var Ir=BigInt(0),Lr=BigInt(1),Rr=BigInt(2);function zr(e,t){return e+t-(t>>Lr<{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function Vr(e){return En(e,{P:`bigint`,type:`string`,adjustScalarBytes:`function`,powPminus2:`function`},{randomBytes:`function`,scalarMultBase:`function`}),Object.freeze({...e})}function Hr(e){let t=Vr(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?cn:o,u=c?255:448,d=Br(n),f=c?32:56,p=BigInt(c?9:5),m=BigInt(c?121665:39081),h=c?Rr**BigInt(254):Rr**BigInt(447),g=h+(c?BigInt(8)*(Rr**BigInt(251)-Lr):BigInt(4)*(Rr**BigInt(445)-Lr))+Lr,_=e=>Rn(e,n),v=y(p);function y(e){return yn(_(e),f)}function b(e){let t=bn(en(e,f,`uCoordinate`));return c&&(t[31]&=127),_(_n(t))}function x(e){return _n(i(bn(en(e,f,`scalar`))))}let S=new Set(c?[Ir,Lr,n-Lr,BigInt(`325606250916557431795983626356110631294008115727848805560023387167927233504`),BigInt(`39382357235489614581723060781553021112529911719440698176882885853963445705823`)]:[Ir,Lr,n-Lr]);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===Ir)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);Cn(`scalar`,t,h,g);let n=_(s(t));if(n===Ir)throw Error(`invalid private or public key received`);return y(n)}let T=w,E=C;function D(e,t){Cn(`u`,e,Ir,n),Cn(`scalar`,t,h,g);let r=t,i=e,o=Lr,s=Ir,c=e,l=Lr,f=r^r>>Lr;for(let e=BigInt(u-1);e>=Ir;e--){let t=zr(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=zr(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,en(e,O.seed,`seed`),e),A={randomSecretKey:k};return Object.freeze(O),Object.freeze(A),Object.freeze({keygen:Or(k,T),getSharedSecret:E,getPublicKey:T,scalarMult:C,scalarMultBase:w,utils:A,GuBytes:v.slice(),lengths:O})}var Ur=BigInt(0),Wr=BigInt(1),Gr=BigInt(2),Kr=BigInt(3),qr=BigInt(5),Jr=BigInt(8),Yr=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),Xr={p:Yr,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:Jr,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function Zr(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Yr,o=e*e%a*e%a,s=Bn(Bn(o,Gr,a)*o%a,Wr,a)*e%a,c=Bn(s,qr,a)*s%a,l=Bn(c,t,a)*c%a,u=Bn(l,n,a)*l%a,d=Bn(u,r,a)*u%a;return{pow_p_5_8:Bn(Bn(Bn(Bn(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Gr,a)*e%a,b2:o}}function Qr(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var $r=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function ei(e,t){let n=Yr,r=Rn(t*t*t,n),i=Zr(e*Rn(r*r*t,n)).pow_p_5_8,a=Rn(e*r*i,n),o=Rn(t*a*a,n),s=a,c=Rn(a*$r,n),l=o===e,u=o===Rn(-e,n),d=o===Rn(-e*$r,n);return l&&(a=s),(u||d)&&(a=c),Yn(a,n)&&(a=Rn(-a,n)),{isValid:l||u,value:a}}var ti=Fr(Xr,{uvRatio:ei}),ni=(()=>{let e=Yr,t=t=>{let{pow_p_5_8:n,b2:r}=Zr(t);return Rn(Bn(n,Kr,e)*r,e)};return Hr({P:e,type:`x25519`,powPminus2:t,adjustScalarBytes:Qr,scalarMultBase:n=>{let r=Rn(n,ti.Fn.ORDER);if(r===Ur)return Ur;let i=ti.BASE.multiply(r);return Rn((i.Z+i.Y)*t(Rn(i.Z-i.Y,e)),e)}})})();function ri(e){let t=$e(e);if(t.length!==32)throw Error(`invalid identity public key`);return t}var ii=e=>{try{return ri(e).length===32}catch{return!1}};function ai(e,t){try{let[n,r]=[ri(e),ri(t)];return n.every((e,t)=>e===r[t])}catch{return!1}}var oi=class extends Error{member;pinned;constructor(e,t){super(`${e.username}'s identity key changed`),this.member=e,this.pinned=t,this.name=`FingerprintChangedError`}},si=new WeakSet,ci;(class e{userId;key;pins;static{ci=(t,n,r)=>{let i=new e(t,n,r);return si.add(i),i}}constructor(e,t,n){this.userId=e,this.key=t,this.pins=n}});var li=e=>typeof e==`object`&&!!e&&si.has(e);function ui(e,t){let n=t.identity?.publicKey;if(!n||!ii(n))throw Error(`invalid identity public key`);return ci(t.userId,n,{...e,[t.userId]:n})}function di(e,t){let n=[],r=[];for(let i of t){let t=i.identity?.publicKey;if(!t)continue;let a=e[i.userId];a===void 0?ii(t)&&n.push(i):ai(a,t)||r.push({member:i,pinned:a})}return{fresh:n,changed:r}}var fi=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/g,pi=e=>{let t=[...e.replace(fi,` `).replace(/\s+/g,` `).trim()];return t.length>64?`${t.slice(0,63).join(``)}…`:t.join(``)};function mi(e,t){return`${pi(t)} · ${pi(e)||`(no name)`}`}async function hi(e){return(await nt(ri(e))).match(/.{4}/g).join(` `)}function gi(e,t){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{let r=t[e];return{userId:e,pinned:n,current:r,state:r===void 0?`unseen`:ai(n,r)?`same`:`changed`}})}function _i(e,t,n){if(n&&ii(n.publicKey)&&ai(t,n.publicKey))return{userId:e,username:e,role:``,identity:{deviceId:n.deviceId,publicKey:n.publicKey}}}function vi({userId:e,name:t,newPrint:n,oldPrint:r}){let i=mi(t,e);return`Trust the new encryption key of ${i}?\n\nNew: ${n}\nWas: ${r}\n\nA password reset or account recovery changes it; so would a server substituting its own key. The name comes from the server; the user ID and fingerprints are what you are trusting. Compare the new fingerprint with ${i} in person (their Settings shows it) before trusting it.`}function yi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var bi=e=>e?`"${e}" `:``;function xi(e,t=``){if(typeof e!=`boolean`)throw TypeError(bi(t)+`expected boolean, got type=`+typeof e);return e}function Si(e,t=``){if(typeof e!=`number`)throw TypeError(bi(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(bi(t)+`expected integer >= 0, got `+e);return e}function Ci(e,t,n=``){if(yi(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Si(t,`length`);let r=yi(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=bi(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var wi=(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 Ti(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Ei(e,t){Ci(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function Di(e,t){if(Ei(e,t),!Ji(e))throw Error(`invalid output, must be aligned`)}function Oi(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ki(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ai(...e){for(let t=0;t>>8&65280|e>>>24&255}var Pi=Mi?e=>e:e=>Ni(e)>>>0;function Fi(e){for(let t=0;te:Fi,Li=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Ri=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function zi(e){if(Ci(e),Li)return e.toHex();let t=``;for(let n=0;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 Gi=(e,t)=>{function n(n,...r){if(Ci(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];Ci(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{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);Ci(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,Ci(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(Ci(e,void 0,`data`),i&&e.length= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function Ki(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(Ci(t,e,`output`),n&&!Ji(t))throw Error(`invalid output, must be aligned`);return t}function qi(e,t,n){Si(e),Si(t),xi(n);let r=new Uint8Array(16),i=ji(r);return i.setBigUint64(0,BigInt(t),n),i.setBigUint64(8,BigInt(e),n),r}function Ji(e){return e.byteOffset%4==0}function q(e){return Uint8Array.from(Ci(e))}function Yi(e=32){Si(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 Xi=16,Zi=new Uint8Array(16),Qi=ki(Zi),$i=225,ea=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^$i<<24&-(i&1)}},ta=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255,na=e=>e>65536?8:e>1024?4:2,ra=class{blockLen=Xi;outputLen=Xi;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(e,t){Ci(e,16,`key`),e=q(e);let n=ji(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:ta(r),s1:ta(i),s2:ta(a),s3:ta(o)}),{s0:r,s1:i,s2:a,s3:o}=ea(r,i,a,o);let c=na(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){Ti(this),Ci(e),e=q(e);let t=ki(e),n=Math.floor(e.length/Xi),r=e.length%Xi;for(let e=0;enew ra(e,t),e=>[e.length]),aa=16,oa=4,sa=new Uint8Array(aa),ca=283;function la(e){if(![16,24,32].includes(e.length))throw Error(`"aes key" expected Uint8Array of length 16/24/32, got length=`+e.length)}function ua(e){return e<<1^ca&-(e>>7)}function da(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=ua(e);return n}var fa=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=ua(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return Ai(e),t})(),pa=e=>e<<24|e>>>8,ma=e=>e<<8|e>>>24;function ha(e,t){if(e.length!==256)throw Error(`wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(ma),i=r.map(ma),a=i.map(ma),o=new Uint32Array(65536),s=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var ga=ha(fa,e=>da(e,3)<<24|e<<16|e<<8|da(e,2)),_a=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=ua(n))e[t]=n;return e})();function va(e){Ci(e);let t=e.length;la(e);let{sbox2:n}=ga,r=[];Mi&&Ji(e)||r.push(e=q(e));let i=Ii(ki(e)),a=i.length,o=e=>ba(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return Ai(...r),s}function ya(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function ba(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function xa(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=ga,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a>>0,s.setUint32(u,f,t)}let p=aa*Math.floor(c.length/oa);if(pUint8Array.from(e.split(``),e=>e.charCodeAt(0)),Ea=Ii(ki(Ta(`expand 16-byte k`))),Da=Ii(ki(Ta(`expand 32-byte k`)));function Oa(e,t){return e<>>32-t}var ka=64,Aa=16,ja=2**32-1,Ma=Uint32Array.of();function Na(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(ka),u=ki(l),d=Mi&&Ji(i)&&Ji(a),f=d?ki(i):Ma,p=d?ki(a):Ma;if(Mi)for(let m=0;m=ja)throw Error(`arx: counter overflow`);let h=Math.min(ka,c-m);if(d&&h===ka){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t=ja)throw Error(`arx: counter overflow`);let f=Math.min(ka,c-d);for(let e=0,t;e{Ci(t,void 0,`key`),Ci(s,void 0,`nonce`),Ci(c,void 0,`data`);let d=c.length,f=l!==void 0;if(l=Ki(d,l,!1),f&&Vi(c,l),Si(u),u<0||u>=ja)throw Error(`arx: counter overflow`);let p=[],m=t.length,h,g;if(m===32)p.push(h=q(t)),g=Da;else if(m===16&&n)h=new Uint8Array(32),h.set(t),h.set(t,16),g=Ea,p.push(h);else throw Ci(t,32,`arx key`),Error(`invalid key size`);Mi&&Ji(s)||p.push(s=q(s));let _=ki(h);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);let e=s.subarray(0,16);if(Mi)r(g,_,ki(e),_);else{let t=Ii(Uint32Array.from(g));r(t,_,ki(e),_),Ai(t),Ii(_)}s=s.subarray(16)}else Mi||Ii(_);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=Ii(ki(s));try{return Na(e,g,_,y,c,l,u,o),l}finally{Ai(...p)}}}function Fa(e,t){return e[t++]&255|(e[t++]&255)<<8}var Ia=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=q(Ci(e,32,`key`));let t=Fa(e,0),n=Fa(e,2),r=Fa(e,4),i=Fa(e,6),a=Fa(e,8),o=Fa(e,10),s=Fa(e,12),c=Fa(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]=Fa(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=Fa(e,t+0),_=Fa(e,t+2),v=Fa(e,t+4),y=Fa(e,t+6),b=Fa(e,t+8),x=Fa(e,t+10),S=Fa(e,t+12),C=Fa(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 ee=P+w*u+T*l+E*c+D*s+O*o;P=ee>>>13,ee&=8191,ee+=5*h*k+5*m*A+5*p*j+5*f*M+5*d*N,P+=ee>>>13,ee&=8191;let te=P+w*d+T*u+E*l+D*c+O*s;P=te>>>13,te&=8191,te+=k*o+5*h*A+5*m*j+5*p*M+5*f*N,P+=te>>>13,te&=8191;let z=P+w*f+T*d+E*u+D*l+O*c;P=z>>>13,z&=8191,z+=k*s+A*o+5*h*j+5*m*M+5*p*N,P+=z>>>13,z&=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 B=P+w*h+T*m+E*p+D*f+O*d;P=B>>>13,B&=8191,B+=k*u+A*l+j*c+M*s+N*o,P+=B>>>13,B&=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]=ee,i[5]=te,i[6]=z,i[7]=ne,i[8]=re,i[9]=B}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;Ai(n)}update(e){Ti(this),Ci(e),e=q(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i>>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}},La=Wi(32,e=>new Ia(e));function Ra(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{e.update(t);let n=t.length%16;n&&e.update(Ba.subarray(n))},Ha=new Uint8Array(32);function Ua(e,t,n,r,i){i!==void 0&&Ci(i,void 0,`AAD`);let a=e(t,n,Ha),o=qi(r.length,i?i.length:0,!0),s=La.create(a);i&&Va(s,i),Va(s,r),s.update(o);let c=s.digest();return Ai(a,o),c}var Wa=Gi({blockSize:64,nonceLength:12,tagLength:16,withAAD:!0},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Ki(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Ua(e,t,n,s,r);return a.set(c,o),Ai(c),a},decrypt(i,a){a=Ki(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Ua(e,t,n,o,r);if(!Ui(s,c))throw Ai(c),Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Ai(c),a}}))(za)),Ga=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},Ka=class extends Ga{},qa=class extends Ga{},Ja=class extends Ga{},Ya=class extends Ga{},Xa=class extends Ga{},Za=class extends Ga{},Qa=class extends Ga{},$a=class extends Ga{},eo=class extends Ga{},to=class extends Ga{},no=class extends Ga{},ro=io(globalThis,{});function io(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}var ao=`modulepreload`,oo=function(e){return`/`+e},so={},co=function(e){return e.pathname.endsWith(`.css`)},lo=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},uo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=oo(t,n);let r=s(t),i=co(r);return lo(so,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ao,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function fo(){if(ro!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:t}=await uo(async()=>{let{webcrypto:t}=await Promise.resolve().then(()=>e(yo()));return{webcrypto:t}},void 0);return t.subtle}catch(e){throw new no(e)}}var po=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await fo())}},mo=new Uint8Array,ho=0n,go=1n,_o=2n,vo=new Uint8Array([75,69,77,0,0]),yo=n(((e,t)=>{t.exports={}})),bo=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function xo(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r{let{webcrypto:t}=await Promise.resolve().then(()=>e(yo()));return{webcrypto:t}},void 0);return wo=t,wo}catch{throw Error(`failed to load Crypto`)}}}function Do(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r>8,n]),Oo,this._suiteId,e,t)}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):Ao(e),r=Ao(t);if(n.byteLength!==this.hashSize&&this._fallbackExtract!==void 0)return this._fallbackExtract(new Uint8Array(n),new Uint8Array(r)).buffer;let i=await this._api.importKey(`raw`,n,{name:this.algHash.name,hash:this.algHash.hash},!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){if(await this._setup(),n>255*this.hashSize)throw Error(`Entropy limit reached`);let r=Ao(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new Uint8Array(n),o=mo,s=ko(t);for(let e=1,t=0;t8192)throw new Ka(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():bo(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey),i=mo,a=mo,o=mo;try{a=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),i=a;let s=mo;if(e.senderKey!==void 0){let t=bo(e.senderKey)?e.senderKey.privateKey:e.senderKey;o=new Uint8Array(await this._prim.dh(t,e.recipientPublicKey)),i=So(a,o),a.fill(0),o.fill(0);let n=bo(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey);s=new Uint8Array(await this._prim.serializePublicKey(n))}let c=So(new Uint8Array(n),new Uint8Array(r),s);return{enc:n,sharedSecret:await this._generateSharedSecret(i,c)}}catch(e){throw new Ya(e)}finally{i.fill(0),a.fill(0),o.fill(0)}}async decap(e){let t=Ao(e.enc),n=await this._prim.deserializePublicKey(t),r=bo(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=bo(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i),o=mo,s=mo,c=mo;try{s=new Uint8Array(await this._prim.dh(r,n)),o=s;let i=mo;e.senderPublicKey!==void 0&&(c=new Uint8Array(await this._prim.dh(r,e.senderPublicKey)),o=So(s,c),s.fill(0),c.fill(0),i=new Uint8Array(await this._prim.serializePublicKey(e.senderPublicKey)));let l=So(new Uint8Array(t),new Uint8Array(a),i);return await this._generateSharedSecret(o,l)}catch(e){throw new Xa(e)}finally{o.fill(0),s.fill(0),c.fill(0)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(J,e);try{let e=this._kdf.buildLabeledInfo(No,t,this.secretSize);return await this._kdf.extractAndExpand(mo,n,e,this.secretSize)}finally{n.fill(0)}}},Fo=[`deriveBits`],Io=new Uint8Array([100,107,112,95,112,114,107]),Lo=new Uint8Array([115,107]),Ro=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},zo=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new qa(e))}}async deserializePublicKey(e){try{return await this._importRawKey(Ao(e),!0)}catch(e){throw new Ja(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new qa(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(Ao(e),!1)}catch(e){throw new Ja(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new Ja(e)}}async generateKeyPair(){try{let e;try{e=this._curve.utils.randomSecretKey()}catch{let t=await Eo(),n=new Uint8Array(this._nSk);t.getRandomValues(n),e=n}let t=new Ro(this._algName,e,`private`,Fo),n=this._curve.getPublicKey(e);return{publicKey:new Ro(this._algName,n,`public`),privateKey:t}}catch(e){throw new no(e)}}async deriveKeyPair(e){try{let t=Ao(e),n=await this._hkdf.labeledExtract(mo.buffer,Io,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Lo,mo,this._nSk),i=new Ro(this._algName,new Uint8Array(r),`private`,Fo);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new to(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new Ro(this._algName,t,`public`))}catch(e){return Promise.reject(new Ja(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new qa(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new Ro(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:Fo))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new Ro(this._algName,Co(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new Ro(this._algName,Co(e.d),`private`,Fo)))})}};function Bo(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Vo(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function Y(e,t,n=``){let r=Bo(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function Ho(e){if(typeof e==`bigint`){if(!Xo(e))throw Error(`positive bigint expected, got `+e)}else Vo(e);return e}function Uo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Wo(...e){for(let t=0;t=0;n--)t=t<<8n|BigInt(e[n]);return t}function Jo(e,t){Vo(t);let n=BigInt(Ho(e)),r=new Uint8Array(t);for(let e=0;e>=8n;if(n!==0n)throw Error(`number too large`);return r}function Yo(e){return Uint8Array.from(e)}function Xo(e){return typeof e==`bigint`&&0n<=e}function Zo(e,t,n){return Xo(e)&&Xo(t)&&Xo(n)&&t<=e&&e=0n?n:t+n}function ts(e,t,n){let r=e;for(;t-->ho;)r*=r,r%=n;return r}function ns(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function rs(e,t){return e+t-(t>>go<{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function as(e){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);for(let t of[`adjustScalarBytes`,`powPminus2`]){let n=typeof e[t];if(n!==`function`)throw Error(`param "${t}" is invalid: expected function, got ${n}`)}return Object.freeze({...e})}function os(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=as(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||$o,c=o?255:448,l=is(t),u=o?32:56,d=o?9n:5n,f=o?121665n:39081n,p=o?_o**254n:_o**447n,m=p+(o?8n*_o**251n-go:4n*_o**445n-go)+go,h=e=>es(e,t),g=_(d);function _(e){return Jo(h(e),u)}let v=o?(go<<255n)-go:ho;function y(e){Y(e,u,`uCoordinate`);let t=qo(e);return o&&(t&=v),h(t)}function b(e){return qo(r(Yo(Y(e,u,`scalar`))))}let x=new Set(o?[ho,go,t-go,325606250916557431795983626356110631294008115727848805560023387167927233504n,39382357235489614581723060781553021112529911719440698176882885853963445705823n]:[ho,go,t-go]);function S(e,t){let n=y(t);if(x.has(n))throw Error(`invalid private or public key received`);let r=D(n,b(e));if(r===0n)throw Error(`invalid private or public key received`);return _(r)}let C=h(d);function w(e){let t=D(C,b(e));if(t===0n)throw Error(`invalid private or public key received`);return _(t)}let T=w,E=S;function D(e,n){Qo(`u`,e,ho,t),Qo(`scalar`,n,p,m);let r=n,a=e,o=go,s=ho,u=e,d=go,g=r^r>>go;for(let e=c-1;e>=0;e--){let n=rs(t,g>>BigInt(e));({x_2:o,x_3:u}=l(n,o,u)),{x_2:s,x_3:d}=l(n,s,d);let r=o+s,i=h(r*r),c=o-s,p=h(c*c),m=i-p,_=u+d,v=u-d,y=h(v*r),b=h(_*c),x=y+b,S=y-b;u=h(x*x),d=h(a*h(S*S)),o=h(i*p),s=h(m*(i+f*m))}let _=rs(t,r);({x_2:o,x_3:u}=l(_,o,u)),{x_2:s,x_3:d}=l(_,s,d);let v=i(s);return h(o*v)}let O={secretKey:u,publicKey:u,seed:u},k=e=>(e===void 0&&(e=s(u)),Y(e,O.seed,`seed`),e),A={randomSecretKey:k};return Object.freeze({keygen:ns(k,T),getSharedSecret:E,getPublicKey:T,scalarMult:S,scalarMultBase:w,utils:A,GuBytes:g.slice(),lengths:O})}var ss=1n,cs=2n,ls=3n,us=5n,ds=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function fs(e){let t=10n,n=80n,r=ds,i=e*e%r*e%r,a=ts(ts(i,cs,r)*i%r,ss,r)*e%r,o=ts(a,us,r)*a%r,s=ts(o,t,r)*o%r,c=ts(s,20n,r)*s%r,l=ts(c,40n,r)*c%r;return{pow_p_5_8:ts(ts(ts(ts(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,cs,r)*e%r,b2:i}}function ps(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ms=(()=>{let e=ds;return os({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=fs(t);return es(ts(n,ls,e)*r,e)},adjustScalarBytes:ps})})();function hs(e){function t(t,n,r){if(Y(t,void 0,`key`),!Go)throw Error(`Non little-endian hardware is not yet supported`);Y(n,12,`nonce`),r!==void 0&&Y(r,void 0,`AAD`);let i=e(t,n,r),a=!1;return{encrypt(e,t){if(a)throw Error(`cannot encrypt() twice with same key + nonce`);return a=!0,Y(e),t!==void 0&&Y(t,void 0,`output`),i.encrypt(e,t)},decrypt(e,t){if(Y(e),e.length<16)throw Error(`"ciphertext" expected length bigger than tagLength=16`);return t!==void 0&&Y(t,void 0,`output`),i.decrypt(e,t)}}}return Object.assign(t,{blockSize:64,nonceLength:12,tagLength:16})}function gs(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r>>32-t}var xs=64,Ss=16,Cs=2**32-1,ws=Uint32Array.of();function Ts(e,t,n,r,i,a,o){let s=i.length,c=new Uint8Array(xs),l=Uo(c),u=vs(i)&&vs(a),d=u?Uo(i):ws,f=u?Uo(a):ws;for(let p=0;p=Cs)throw Error(`arx: counter overflow`);let m=Math.min(xs,s-p);if(u&&m===xs){let e=p/4;if(p%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t{Y(t,32,`arx key`),Y(n,12,`nonce`),Y(r,void 0,`data`);let o=r.length;if(i===void 0&&(i=new Uint8Array(o)),Y(i,void 0,`output`),!Number.isSafeInteger(a)||a<0||a>=Cs)throw Error(`arx: counter overflow`);if(i.length>>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 e=0;e<10;e++)this.r5[e]=5*this.r[e];for(let t=0;t<8;t++)this.pad[t]=Ds(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a,r5:o}=this,s=a[0],c=a[1],l=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],h=a[8],g=a[9],_=o[1],v=o[2],y=o[3],b=o[4],x=o[5],S=o[6],C=o[7],w=o[8],T=o[9],E=Ds(e,t+0),D=Ds(e,t+2),O=Ds(e,t+4),k=Ds(e,t+6),A=Ds(e,t+8),j=Ds(e,t+10),M=Ds(e,t+12),N=Ds(e,t+14),P=i[0]+(E&8191),F=i[1]+((E>>>13|D<<3)&8191),I=i[2]+((D>>>10|O<<6)&8191),L=i[3]+((O>>>7|k<<9)&8191),R=i[4]+((k>>>4|A<<12)&8191),ee=i[5]+(A>>>1&8191),te=i[6]+((A>>>14|j<<2)&8191),z=i[7]+((j>>>11|M<<5)&8191),ne=i[8]+((M>>>8|N<<8)&8191),re=i[9]+(N>>>5|r),B=0,ie=B+P*s+F*T+I*w+L*C+R*S;B=ie>>>13,ie&=8191,ie+=ee*x+te*b+z*y+ne*v+re*_,B+=ie>>>13,ie&=8191;let ae=B+P*c+F*s+I*T+L*w+R*C;B=ae>>>13,ae&=8191,ae+=ee*S+te*x+z*b+ne*y+re*v,B+=ae>>>13,ae&=8191;let oe=B+P*l+F*c+I*s+L*T+R*w;B=oe>>>13,oe&=8191,oe+=ee*C+te*S+z*x+ne*b+re*y,B+=oe>>>13,oe&=8191;let V=B+P*u+F*l+I*c+L*s+R*T;B=V>>>13,V&=8191,V+=ee*w+te*C+z*S+ne*x+re*b,B+=V>>>13,V&=8191;let H=B+P*d+F*u+I*l+L*c+R*s;B=H>>>13,H&=8191,H+=ee*T+te*w+z*C+ne*S+re*x,B+=H>>>13,H&=8191;let se=B+P*f+F*d+I*u+L*l+R*c;B=se>>>13,se&=8191,se+=ee*s+te*T+z*w+ne*C+re*S,B+=se>>>13,se&=8191;let ce=B+P*p+F*f+I*d+L*u+R*l;B=ce>>>13,ce&=8191,ce+=ee*c+te*s+z*T+ne*w+re*C,B+=ce>>>13,ce&=8191;let le=B+P*m+F*p+I*f+L*d+R*u;B=le>>>13,le&=8191,le+=ee*l+te*c+z*s+ne*T+re*w,B+=le>>>13,le&=8191;let ue=B+P*h+F*m+I*p+L*f+R*d;B=ue>>>13,ue&=8191,ue+=ee*u+te*l+z*c+ne*s+re*T,B+=ue>>>13,ue&=8191;let de=B+P*g+F*h+I*m+L*p+R*f;B=de>>>13,de&=8191,de+=ee*d+te*u+z*l+ne*c+re*s,B+=de>>>13,de&=8191,B=(B<<2)+B|0,B=B+ie|0,ie=B&8191,B>>>=13,ae+=B,i[0]=ie,i[1]=ae,i[2]=oe,i[3]=V,i[4]=H,i[5]=se,i[6]=ce,i[7]=le,i[8]=ue,i[9]=de}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;Wo(n)}update(e){this.assertActive();let{buffer:t}=this,n=e.length;for(let r=0;r>>0,e[r++]=t[n]>>>8;let i=e.slice();return this.destroy(),i}};function ks(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(t,n,r)=>({encrypt(i,a){let o=i.length;a=_s(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Ms(e,t,n,s,r);return a.set(c,o),Wo(c),a},decrypt(i,a){a=_s(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Ms(e,t,n,o,r);if(!gs(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Wo(c),a}}))(As)),Ps=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(Ao(e))}async seal(e,t,n){return Ns(this._key,new Uint8Array(Ao(e)),new Uint8Array(Ao(n))).encrypt(new Uint8Array(Ao(t))).buffer}async open(e,t,n){return Ns(this._key,new Uint8Array(Ao(e)),new Uint8Array(Ao(n))).decrypt(new Uint8Array(Ao(t))).buffer}},Fs=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Ps(e)}},Is=new Uint8Array([115,101,99]),Ls=class{constructor(e,t){Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._kdf=e,this.exporterSecret=t}seal(e,t){return Promise.reject(new no(`Not supported`))}open(e,t){return Promise.reject(new no(`Not supported`))}async export(e,t){let n=Ao(e);if(n.byteLength>8192)throw new Ka(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Is,new Uint8Array(n),t)}catch(e){throw new Za(e)}}},Rs=class extends Ls{},zs=class extends Ls{constructor(e,t,n){super(e,t),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=n}},Bs=class extends Ls{constructor(e,t){super(e,t.exporterSecret),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ctx={key:t.aead.createEncryptionContext(t.key),baseNonce:t.baseNonce,seq:t.seq}}computeNonce(e){let t=xo(e.seq,e.baseNonce.byteLength);return Do(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new eo(`Message limit reached`);e.seq+=1}},Vs=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Hs=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Us,Ws=class{constructor(){Us.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Vs(this,Us,`f`);return Hs(this,Us,t,`f`),await n,e}};Us=new WeakMap;var Gs=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ks=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},qs,Js=class extends Bs{constructor(){super(...arguments),qs.set(this,void 0)}async open(e,t=mo.buffer){Ks(this,qs,Gs(this,qs,`f`)??new Ws,`f`);let n=await Gs(this,qs,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),Ao(e),Ao(t))}catch(e){throw new $a(e)}finally{n()}return this.incrementSeq(this._ctx),r}};qs=new WeakMap;var Ys=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Xs=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Zs,Qs=class extends Bs{constructor(e,t,n){super(e,t),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Zs.set(this,void 0),this.enc=n}async seal(e,t=mo.buffer){Xs(this,Zs,Ys(this,Zs,`f`)??new Ws,`f`);let n=await Ys(this,Zs,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),Ao(e),Ao(t))}catch(e){throw new Qa(e)}finally{n()}return this.incrementSeq(this._ctx),r}};Zs=new WeakMap;function $s(e){if(`auth`in e&&e.auth===!1)throw new no(`Auth and AuthPSK modes are not supported by this KEM`)}var ec=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),tc=new Uint8Array([101,120,112]),nc=new Uint8Array([105,110,102,111,95,104,97,115,104]),rc=new Uint8Array([107,101,121]),ic=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),ac=new Uint8Array([115,101,99,114,101,116]),oc=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),sc=class extends po{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new Ka(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new Ka(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new Ka(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(oc),this._suiteId.set(xo(this._kem.id,2),4),this._suiteId.set(xo(this._kdf.id,2),6),this._suiteId.set(xo(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){e.senderKey!==void 0&&$s(this._kem),this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n=(e.psk===void 0?0:1)|(e.senderKey===void 0?0:2);return await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){e.senderPublicKey!==void 0&&$s(this._kem),this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n=(e.psk===void 0?0:1)|(e.senderPublicKey===void 0?0:2);return await this._keyScheduleR(n,t,e)}async seal(e,t,n=mo.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=mo.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?mo:ko(n.psk.id),i=await this._kdf.labeledExtract(mo,ic,r),a=n.info===void 0?mo:ko(n.info),o=await this._kdf.labeledExtract(mo,nc,a),s=So(new Uint8Array([e]),new Uint8Array(i),new Uint8Array(o)),c=n.psk===void 0?mo:ko(n.psk.key),l=this._kdf.buildLabeledIkm(ac,c),u=this._kdf.buildLabeledInfo(tc,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===65535)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(rc,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(ec,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new zs(this._kdf,i.exporterSecret,n):new Qs(this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new Rs(this._kdf,r.exporterSecret):new Js(this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new Ka(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new Ka(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new Ka(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new Ka(`Too long psk.id`)}}},cc=class extends sc{},lc=class extends Mo{},uc=class extends Mo{},dc=class extends zo{constructor(e){super(`X25519`,32,ms,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new qa(e))}}},fc=class extends Po{constructor(){let e=new uc;super(32,new dc(e),e),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32})}},pc=`hpke-auth-x25519-hkdfsha256-chacha20poly1305`,mc=`aes-256-gcm`,hc=`kynotes/envelope/v3`,gc=`kynotes/envelope/v2`,_c=`kynotes/identity/v1`,vc=/^(cnt|dev|usr|lnk)_[0-9a-hjkmnp-tv-z]{26}$/,yc=new TextEncoder,bc=new cc({kem:new fc,kdf:new lc,aead:new Fs});function xc(e,t){if(!t.startsWith(`${e}_`)||!vc.test(t))throw Error(`invalid ${e} id`);return yc.encode(t)}function Sc(...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}function Cc(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r4294967295)throw Error(`invalid key generation`);let a=new Uint8Array(4);return new DataView(a.buffer).setUint32(0,n),Sc(yc.encode(e),xc(`cnt`,t),a,xc(`dev`,r),xc(`dev`,i))}var Ec=(e,t,n,r)=>Tc(hc,e,t,n,r);async function Dc(e){return{privateKey:await bc.kem.deserializePrivateKey(e),publicKey:await bc.kem.deserializePublicKey(ni.getPublicKey(e))}}async function Oc(e,t,n,r,i,a,o){if(e.length!==32||t.length!==32)throw Error(`invalid envelope input`);let s=Ec(n,r,i,a.deviceId),c={recipientPublicKey:await bc.kem.deserializePublicKey(t),senderKey:await Dc(a.privateKey),info:s},{enc:l,ct:u}=await bc.seal(o?{...c,ekm:o}:c,e);return Sc(Uint8Array.of(3),yc.encode(a.deviceId),new Uint8Array(l),new Uint8Array(u))}function kc(e,t,n,r,i,a){return Oc(e,t,n,r,i,a)}function Ac(e,t){let[n,r]=e===`hpke-auth-x25519-hkdfsha256-chacha20poly1305`?[3,111]:e===`x25519-hkdf-sha256-chacha20poly1305`?[2,123]:[-1,-1];if(t.length!==r||t[0]!==n)throw Error(`unsupported envelope`);let i=new TextDecoder().decode(t.subarray(1,31));return xc(`dev`,i),i}async function jc(e,t,n,r,i,a,o){let s=Ac(e,t);if(o.length!==32)throw Error(`invalid sender key`);if(e===`x25519-hkdf-sha256-chacha20poly1305`)return Mc(t,n,r,i,a,s,o);let c=await bc.open({recipientKey:await Dc(n),senderPublicKey:await bc.kem.deserializePublicKey(o),enc:t.subarray(31,63),info:Ec(r,i,a,s)},t.subarray(63));return new Uint8Array(c)}function Mc(e,t,n,r,i,a,o){let s=Tc(gc,n,r,i,a),c=e.subarray(31,63),l=e.subarray(63,75);return Wa(qe(Sc(ni.getSharedSecret(t,c),ni.getSharedSecret(t,o)),32,Sc(c,ni.getPublicKey(t),o),yc.encode(gc)),l,s).decrypt(e.subarray(75))}function Nc(e){return Sc(yc.encode(_c),xc(`usr`,e))}function Pc(e,t,n,r){if(e.length!==32||t.length!==32||r.length!==12)throw Error(`invalid identity input`);return Sc(r,wa(e,r,Nc(n)).encrypt(t))}function Fc(e,t,n){return Pc(e,t,n,Yi(12))}function Ic(e,t,n){if(e.length!==32||t.length!==60)throw Error(`invalid wrapped identity`);let r=wa(e,t.subarray(0,12),Nc(n)).decrypt(t.subarray(12));return{privateKey:r,publicKey:ni.getPublicKey(r)}}var Lc=`kynotes-web`,Rc=`notes`,zc=[`owner`,`id`];function Bc(){return new Promise((e,t)=>{let n=indexedDB.open(Lc,7);n.onupgradeneeded=e=>{let t=n.result;if(e.oldVersion<6){for(let e of[Rc,`pending`,`uploads`])t.objectStoreNames.contains(e)&&t.deleteObjectStore(e);try{localStorage.removeItem(`kynotes-pending-saves`)}catch{}}if(t.objectStoreNames.contains(Rc)||t.createObjectStore(Rc,{keyPath:zc}),t.objectStoreNames.contains(`pending`)||t.createObjectStore(`pending`,{keyPath:zc}),t.objectStoreNames.contains(`uploads`)||t.createObjectStore(`uploads`,{keyPath:`uploadId`}),t.objectStoreNames.contains(`keys`)||t.createObjectStore(`keys`,{keyPath:`username`}),e.oldVersion<7){let e=n.transaction.objectStore(`keys`).openCursor();e.onsuccess=()=>{let t=e.result;if(t){if(`authSecret`in t.value){let{authSecret:e,...n}=t.value;t.update(n)}t.continue()}}}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Unable to open local note store`))})}function Vc(e,t){return new Promise((n,r)=>{e.oncomplete=()=>n(t()),e.onerror=()=>r(e.error??Error(`Local store write failed`)),e.onabort=()=>r(e.error??Error(`Local store write aborted`))})}var Hc=(e,t)=>()=>{try{t()}catch{e.abort()}};async function Uc(e,t){let n=await Bc();try{let r=n.transaction(e,`readwrite`),i=Vc(r,()=>void 0);Hc(r,()=>t(r.objectStore(e)))(),await i}finally{n.close()}}async function Wc(e,t){await Uc(Rc,n=>n.put({...t,owner:e}))}async function Gc(e){let t=await Bc(),n=await new Promise((n,r)=>{let i=t.transaction(Rc).objectStore(Rc).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error)});if(t.close(),!n)return;let{owner:r,...i}=n;return i}var Kc=(e,t)=>Gc([e,t]);async function qc(e,t){await Uc(Rc,n=>n.delete([e,t]))}async function Jc(e){await Uc(`pending`,t=>t.put(e))}async function Yc(e){let t=await Bc();try{let n=t.transaction([Rc,`pending`],`readwrite`),r=Vc(n,()=>void 0);Hc(n,()=>{n.objectStore(Rc).put({...e,unsent:!0}),n.objectStore(`pending`).put(e)})(),await r}finally{t.close()}}async function Xc(e,t){let n=await Bc();try{return await new Promise((r,i)=>{let a=n.transaction(`pending`).objectStore(`pending`).get([e,t]);a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)})}finally{n.close()}}async function Zc(e,t,n){let r=await Bc();try{let i=r.transaction([Rc,`pending`],`readwrite`),a,o=Vc(i,()=>a),s=i.objectStore(`pending`).get([e,t]);return s.onsuccess=Hc(i,()=>{a=s.result;let r=i.objectStore(Rc).get([e,t]);r.onsuccess=Hc(i,()=>{let t=r.result;t&&n&&!a?.gone&&!a?.previousKey&&Qc(t,n)&&(t={...t,unsent:!0},i.objectStore(Rc).put(t)),!t?.unsent||a?.gone||a?.previousKey||a&&a.updatedAt>t.updatedAt||a&&Cc(a.payload,t.payload)||(a={...t,owner:e},i.objectStore(`pending`).put(a))})}),await o}finally{r.close()}}var Qc=(e,t)=>!!(e&&e.updatedAt===t.updatedAt&&e.version===t.version&&e.keyGeneration===t.keyGeneration&&Cc(e.payload,t.payload));async function $c(e,t){let n=await Bc();try{let r=n.transaction([Rc,`pending`],`readwrite`),i=Vc(r,()=>void 0),a=[e.owner,e.id],o=r.objectStore(`pending`).get(a);o.onsuccess=Hc(r,()=>{Qc(o.result,e)&&r.objectStore(`pending`).delete(a)});let s=r.objectStore(Rc).get(a);s.onsuccess=Hc(r,()=>{let n=s.result;if(n&&Qc(n,e)){if(t===void 0)r.objectStore(Rc).delete(a);else{let{unsent:e,...i}=n;r.objectStore(Rc).put({...i,version:t})}}}),await i}finally{n.close()}}async function el(){let e=await Bc(),t=await new Promise((t,n)=>{let r=e.transaction(`pending`).objectStore(`pending`).getAll();r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});return e.close(),t}async function tl(e,t,n){await Uc(`pending`,r=>{let i=r.get([e,t]);i.onsuccess=Hc(r.transaction,()=>{i.result?.updatedAt===n&&r.delete([e,t])})})}async function nl(e,t){let n=await Bc();try{let r=n.transaction([Rc,`pending`],`readwrite`),i=!1,a=Vc(r,()=>i),o=[e.owner,e.id],s=r.objectStore(`pending`),c=s.get(o);return c.onsuccess=Hc(r,()=>{if(i=Qc(c.result,e),!i)return;if(!t){s.delete(o);return}let n={...t,owner:e.owner,id:e.id};s.put(n);let a=r.objectStore(Rc).get(o);a.onsuccess=Hc(r,()=>{let t=a.result;Qc(t,e)&&r.objectStore(Rc).put({...n,unsent:t?.unsent})})}),await a}finally{n.close()}}async function rl(e){await Uc(`uploads`,t=>t.put(e))}async function il(e){let t=await Bc(),n=await new Promise((e,n)=>{let r=t.transaction(`uploads`).objectStore(`uploads`).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});return t.close(),e?n.filter(t=>t.owner===e):[]}async function al(e,t){await Uc(`uploads`,n=>{let r=n.get(t);r.onsuccess=Hc(n.transaction,()=>{r.result?.owner===e&&n.delete(t)})})}async function ol(e){await Uc(`keys`,t=>{let n=t.get(e);n.onsuccess=Hc(t.transaction,()=>t.put({...n.result,username:e,updatedAt:new Date().toISOString()}))})}async function sl(e,t,n){let r=await e();try{await ol(t),n&&await pl(t,n.userID,n.identity)}catch{}return r}var cl=()=>globalThis.isSecureContext===!0&&typeof globalThis.crypto?.subtle?.generateKey==`function`?`wrapped`:`plain`,ll=(e,t)=>new TextEncoder().encode(`kynotes/device-identity/v1|${e}|${t}`);async function ul(e,t){let n={userID:e,deviceId:t.deviceId,publicKey:t.publicKey.slice()};if(cl()===`plain`)return{...n,privateKey:t.privateKey.slice()};let r=await crypto.subtle.generateKey({name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]),i=crypto.getRandomValues(new Uint8Array(12)),a=new Uint8Array(await crypto.subtle.encrypt({name:`AES-GCM`,iv:i,additionalData:ll(e,t.deviceId)},r,t.privateKey.slice())),o=new Uint8Array(12+a.length);return o.set(i),o.set(a,12),{...n,sealed:o,deviceKey:r}}async function dl(e){try{let t=`privateKey`in e?e.privateKey:new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:e.sealed.slice(0,12),additionalData:ll(e.userID,e.deviceId)},e.deviceKey,e.sealed.slice(12)));return Cc(ni.getPublicKey(t),e.publicKey)?{deviceId:e.deviceId,publicKey:e.publicKey,privateKey:t}:void 0}catch{return}}var fl=(e,t,n)=>{let r=e.identity?.userID===t?e.identity:void 0;return n===null?!r:r!==void 0&&Cc(r.publicKey,n.publicKey)};async function pl(e,t,n,r){let i=await ul(t,n).catch(()=>void 0);return i?bl(e,e=>{if(r!==void 0&&!fl(e,t,r))return;let{resetSent:a,...o}=e;return a&&a.userID===t&&Cc(a.publicKey,n.publicKey)?{...o,identity:i}:{...e,identity:i}}):!1}async function ml(e,t,n){await bl(e,e=>({...e,resetSent:{userID:t,publicKey:n.slice()}}))}async function hl(e,t){let n=(await yl(e).catch(()=>void 0))?.resetSent;return n?.userID===t?n.publicKey:void 0}async function gl(e,t){let n=(await yl(e))?.identity;if(!n||n.userID!==t)return;let r=await dl(n);if(r&&`privateKey`in n&&cl()===`wrapped`){let i=await ul(t,r).catch(()=>void 0);i&&await bl(e,e=>e.identity&&`privateKey`in e.identity&&Cc(e.identity.privateKey,n.privateKey)?{...e,identity:i}:void 0)}return r}async function _l(e,t){let n=await gl(e,t);return n?.deviceId?n:void 0}async function vl(e){try{return await yl(e)!==void 0}catch{return!1}}async function yl(e){let t=await Bc(),n=await new Promise((n,r)=>{let i=t.transaction(`keys`).objectStore(`keys`).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error)});return t.close(),n}async function bl(e,t){let n=!1;try{return await Uc(`keys`,r=>{let i=r.get(e);i.onsuccess=Hc(r.transaction,()=>{let e=i.result,a=e&&t(e);a&&(r.put(a),n=!0)})}),n}catch{return!1}}var xl=(e,t)=>e.pins?.userID===t?e.pins.keys:{};async function Sl(e,t){let n=await yl(e);return n?xl(n,t):{}}async function Cl(e,t,n){let r={ok:!1,conflicts:[]};try{return await Uc(`keys`,i=>{let a=i.get(e);a.onsuccess=Hc(i.transaction,()=>{let e=a.result;if(!e)return;let o=xl(e,t),s=Object.keys(n).filter(e=>o[e]!==void 0&&o[e]!==n[e]&&!ai(o[e],n[e]));s.length?r={ok:!1,conflicts:s}:(i.put({...e,pins:{userID:t,keys:{...n,...o}}}),r={ok:!0})})}),r}catch{return{ok:!1,conflicts:[]}}}async function wl(e,t,n,r){return li(n)?bl(e,e=>{let i=xl(e,t),a=i[n.userId];if(r===void 0||a!==void 0&&ai(a,r))return{...e,pins:{userID:t,keys:{...i,[n.userId]:n.key}}}}):!1}var Tl=(e,t)=>e.keyStates?.userID===t?e.keyStates.byContainer:{};async function El(e,t,n){let r=await yl(e),i=r&&Tl(r,t)[n];return i?{mark:i.mark,digests:i.digests,...i.shared===void 0?{}:{shared:i.shared},...i.generation===void 0?{}:{generation:i.generation},...i.objects===2?{objects:2}:{}}:{mark:0,digests:{}}}async function Dl(e,t,n,r){return bl(e,e=>{let i=Tl(e,t),a=i[n]??{mark:0,digests:{}},o={mark:Math.max(a.mark,r.mark),digests:{...r.digests,...a.digests},shared:Math.max(a.shared??0,r.shared??0),generation:Math.max(a.generation??0,r.generation??0),...a.objects===2||r.objects===2?{objects:2}:{}};return{...e,keyStates:{userID:t,byContainer:{...i,[n]:o}}}})}async function Ol(e){await Uc(`keys`,t=>t.delete(e))}var kl=e=>JSON.stringify(e.type===`page`?[e.type,e.title,e.body,e.section,e.order,e.level,e.legacy]:[e.type,e.title,e.color,e.order,e.group]),Al=(e,t)=>kl(e)===kl(t);function jl({owner:e,containerID:t,note:n,write:r}){return Ml({owner:e,containerID:t,id:n.id,version:n.version,content:Bt(n),write:r})}async function Ml({owner:e,containerID:t,id:n,version:r,content:i,write:a}){let o=await Xc(e,n).catch(()=>void 0),s=await Kc(e,n).catch(()=>void 0),c=s?.unsent&&(!o||s.updatedAt>=o.updatedAt)?{...s,owner:e}:o;if(c&&!c.gone&&!c.previousKey&&c.containerID===t&&c.version===r&&c.keyGeneration===a.generation){let e=await Mt(a.key,t,n,c.payload,!0).catch(()=>void 0);if(e?.payload&&!e.v1&&kl(e.payload)===kl(i))return c}return{owner:e,id:n,containerID:t,version:r,keyGeneration:a.generation,payload:await jt(a.key,t,n,i),updatedAt:new Date().toISOString()}}async function Nl({owner:e,id:t,version:n,mode:r,open:i,server:a}){let o=await(r===`recover`?Zc(e,t):Xc(e,t)),s=await Kc(e,t);for(;s&&!s.unsent&&s.version===n&&!o?.gone&&!o?.previousKey&&(!o||s.updatedAt>=o.updatedAt);){let n=await i(s),c=await a();if(n?.type!==`page`||c?.type!==`page`||Al(n,c))break;if(r===`read`)return s;let l=s;if(o=await Zc(e,t,l),s=await Kc(e,t),Qc(s,l))break}let c=o&&!o.gone&&!o.previousKey?o:void 0,l=s?.unsent&&(!c||s.updatedAt>=c.updatedAt)?s:c??s;return l&&(l.unsent||l===c||l.version>=n)?l:void 0}var Pl=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=Pl()})),X=e(Fl(),1);async function Il(e,t){let n=`/api/v1/auth/oidc/step-up/${encodeURIComponent(e)}`,r={popup:null},i=!1,a=new AbortController,o=document.createElement(`dialog`),s=document.createElement(`h2`);s.id=`sso-confirm-${e}`,s.textContent=`Confirm this action`,o.setAttribute(`aria-labelledby`,s.id);let c=document.createElement(`p`);c.textContent=`Sign in again with KySignOn to authorize only the action you just requested.`;let l=document.createElement(`button`);l.textContent=`Continue to KySignOn`;let u=document.createElement(`button`);u.textContent=`Cancel`,o.append(s,c,l,u),document.body.append(o);let d=!1;try{await new Promise((e,t)=>{let n=()=>{d=!0,a.abort(),t(Error(`Action confirmation cancelled`))};o.addEventListener(`cancel`,e=>{e.preventDefault(),n()}),u.onclick=n,l.onclick=()=>{r.popup=window.open(`about:blank`,`_blank`,`popup,width=600,height=750`),r.popup?(r.popup.opener=null,l.disabled=!0,c.textContent=`Complete sign-in in the KySignOn window. You can cancel here at any time.`,e()):t(Error(`Allow the KySignOn sign-in window to confirm this action`))},o.showModal()}),u.onclick=()=>{d=!0,a.abort()};let s=await fetch(`/api/v1/auth/oidc/step-up`,{signal:a.signal,method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,"X-CSRF-Token":t},body:JSON.stringify({challenge:e})}),f=await s.json();if(!s.ok||typeof f!=`object`||!f||!(`url`in f)||typeof f.url!=`string`)throw Error(`Unable to start KySignOn confirmation`);let p=new URL(f.url);if(p.protocol!==`https:`&&!(p.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(p.hostname)))throw Error(`Invalid sign-in URL`);let m=r.popup;if(!m||d)throw Error(`Action confirmation cancelled`);m.location.href=p.href;let h=Date.now()+3e5;for(;!d&&Date.now()setTimeout(e,1e3))}throw Error(`Action confirmation cancelled or expired`)}finally{r.popup?.close(),o.close(),o.remove(),i||await fetch(n,{method:`DELETE`,credentials:`include`,headers:{"X-CSRF-Token":t}}).catch(()=>void 0)}}function Ll(e){let t=typeof e==`string`?/^\d+$/.test(e)?Number(e):NaN:e;return typeof t==`number`&&Number.isSafeInteger(t)&&t>=0?t:void 0}var Rl=e=>e.map(e=>({...e,keyGeneration:Ll(e.keyGeneration)})),Z=class extends Error{code;challenge;conflictId;currentVersion;status;constructor(e,t,n){super(e),this.name=`APIRequestError`,this.code=t.error?.code,this.challenge=typeof t.error?.challenge==`string`?t.error.challenge:void 0,this.conflictId=t.conflictId,this.currentVersion=t.currentVersion,this.status=n}},zl=`shared-v2`;function Bl(){return document.cookie.split(`; `).find(e=>e.startsWith(`csrf_token=`))?.slice(11)??``}async function Vl(e,t={}){let n=await fetch(e,t);if(n.status!==403)return n;let r;try{r=await n.clone().json()}catch{return n}if(typeof r!=`object`||!r||!(`error`in r)||typeof r.error!=`object`||r.error===null)return n;let i=r.error;if(!(`code`in i)||i.code!==`sso_step_up_required`||!(`challenge`in i)||typeof i.challenge!=`string`)return n;await Il(i.challenge,Bl());let a=new Headers(t.headers);return a.set(`X-Kynotes-Step-Up`,i.challenge),fetch(e,{...t,headers:a})}async function Q(e,t={}){let n=(t.method??`GET`).toUpperCase(),r=new Headers(t.headers);r.set(`Accept`,`application/json`),t.body&&!r.has(`Content-Type`)&&r.set(`Content-Type`,`application/json`),[`POST`,`PUT`,`PATCH`,`DELETE`].includes(n)&&(r.set(`X-CSRF-Token`,Bl()),r.set(`X-Kynotes-Key-Scheme`,zl));let i=await Vl(e,{...t,headers:r,credentials:`include`});if(!i.ok){let e={};try{e=await i.json()}catch{}throw new Z(e.error?.message??`Request failed (${i.status})`,e,i.status)}if(i.status!==204)return i.json()}async function Hl(){return Q(`/api/v1/setup`)}function Ul(e,t,n){return Q(`/api/v1/setup`,{method:`POST`,body:JSON.stringify({admin:e,everyday:t,setupToken:n.trim()})})}async function Wl(e){return Q(`/api/v1/auth/login-params`,{method:`POST`,body:JSON.stringify({username:e})})}async function Gl(e,t){return Q(`/api/v1/auth/login`,{method:`POST`,body:JSON.stringify({username:e,authSecret:t})})}var Kl=()=>Q(`/api/v1/auth/sso-config`),ql=()=>Q(`/api/v1/admin/sso`),Jl=e=>Q(`/api/v1/admin/sso`,{method:`POST`,body:JSON.stringify(e)}),Yl=(e,t,n)=>Q(`/api/v1/admin/sso/pair`,{method:`POST`,body:JSON.stringify({issuerUrl:e,pairingToken:t,callbackUrl:n})}),Xl=()=>Q(`/api/v1/admin/rate-limit-networks`),Zl=e=>Q(`/api/v1/admin/rate-limit-networks`,{method:`PUT`,body:JSON.stringify({networks:e})}),Ql=()=>Q(`/api/v1/auth/session`),$l=()=>Q(`/api/v1/suite/apps`),eu=()=>Q(`/api/v1/auth/logout`,{method:`POST`}),tu=()=>Q(`/api/v1/containers`);function nu(e=`workbook`,t=``){return Q(`/api/v1/containers`,{method:`POST`,body:JSON.stringify({kind:e,teamId:t})})}var ru=e=>Q(`/api/v1/containers/${encodeURIComponent(e)}`,{method:`DELETE`});function iu(e,t,n,r){return Q(`/api/v1/containers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({metaCiphertext:t,baseVersion:n,keyGeneration:r})})}async function au(){let[e,t]=await Promise.all([fetch(`/healthz`).then(e=>e.ok,()=>!1),fetch(`/readyz`).then(e=>e.ok,()=>!1)]);return{health:e,ready:t}}var ou=()=>Q(`/api/v1/admin/users`),su=()=>Q(`/api/v1/admin/audit`),cu=()=>Q(`/api/v1/admin/teams`);function lu(e){return Q(`/api/v1/admin/teams`,{method:`POST`,body:JSON.stringify({ownerUserId:e})})}function uu(e,t){return Q(`/api/v1/containers/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}/approve`,{method:`POST`})}function du(e){return Q(`/api/v1/admin/users`,{method:`POST`,body:JSON.stringify(e)})}function fu(e,t){return Q(`/api/v1/admin/users/${encodeURIComponent(e)}/password`,{method:`POST`,body:JSON.stringify(t)})}function pu(e,t,n){return Q(`/api/v1/admin/teams/${encodeURIComponent(e)}/members`,{method:`POST`,body:JSON.stringify({userId:t,role:n})})}function mu(e){return Q(`/api/v1/admin/users/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify(e)})}function hu(e){return Q(`/api/v1/auth/password`,{method:`POST`,body:JSON.stringify(e)})}function gu(e){return Q(`/api/v1/auth/login-upgrade`,{method:`POST`,body:JSON.stringify(e)})}function _u(e){return Q(`/api/v1/auth/step-up`,{method:`POST`,body:JSON.stringify({authSecret:e})})}async function vu(){try{return await Q(`/api/v1/me/identity`)}catch(e){if(e instanceof Z&&e.code===`not_found`)return;throw e}}var yu=e=>Q(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify(e)}),bu=e=>Q(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify({publicKey:e,wrapAlg:`none`})}),xu=e=>Q(`/api/v1/me/identity/recovery`,{method:`PUT`,body:JSON.stringify(e)});async function Su(){try{return await Q(`/api/v1/me/identity/recovery/fetch`,{method:`POST`})}catch(e){if(e instanceof Z&&e.code===`not_found`)return;throw e}}var Cu={myIdentity:vu,putRecovery:xu,fetchRecovery:Su,replaceIdentity:e=>Q(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify({...e,replace:!0})})},wu=(e,t=``)=>`/api/v1/me/link-requests/${encodeURIComponent(e)}${t}`,Tu=e=>Q(`/api/v1/me/link-requests`,{method:`POST`,body:JSON.stringify({commitment:e})}),Eu=()=>Q(`/api/v1/me/link-requests`),Du=(e,t)=>Q(wu(e,`/claim`),{method:`POST`,body:JSON.stringify({approverKey:t})}),Ou=(e,t)=>Q(wu(e,`/reveal`),{method:`POST`,body:JSON.stringify({newcomerKey:t})}),ku=(e,t)=>Q(wu(e,`/approve`),{method:`POST`,body:JSON.stringify({bundle:t})}),Au=e=>Q(wu(e,`/collect`),{method:`POST`}),ju=(e,t=!1)=>Q(wu(e),{method:`DELETE`,keepalive:t}),Mu=e=>Q(`/api/v1/auth/oidc/step-up/${encodeURIComponent(e)}`,{method:`DELETE`}),Nu={myIdentity:vu,putMyIdentity:yu,stepUp:async e=>(await _u(e))?.identity},Pu=e=>Q(`/api/v1/containers/${encodeURIComponent(e)}/envelopes`),Fu=(e,t)=>Q(`/api/v1/containers/${encodeURIComponent(e)}/envelopes`,{method:`PUT`,body:JSON.stringify({envelopes:t})}),Iu=(e,t,n)=>Q(`/api/v1/containers/${encodeURIComponent(e)}/key-rotations`,{method:`POST`,body:JSON.stringify({expectedGeneration:t,envelopes:n})});async function Lu(e){try{return await Q(`/api/v1/users/${encodeURIComponent(e)}/identity`)}catch(e){if(e instanceof Z&&e.code===`not_found`)return;throw e}}var Ru=async e=>(await Q(`/api/v1/containers/${encodeURIComponent(e)}/members`)).map(e=>({...e,approved:e.approved===!0})),zu=()=>Q(`/api/v1/notifications`);function Bu(e,t){return Q(`/api/v1/presence`,{method:`POST`,body:JSON.stringify({containerId:e,state:t})})}function Vu(e,t,n,r=[]){return Q(`/api/v1/containers/${encodeURIComponent(e)}/invitations`,{method:`POST`,body:JSON.stringify(r.length?{inviteeId:t,role:n,envelopes:r}:{inviteeId:t,role:n})})}var Hu=(e,t)=>Q(`/api/v1/invitations/${encodeURIComponent(e)}/accept`,{method:`POST`,body:JSON.stringify({token:t})});function Uu(e,t){return Q(`/api/v1/containers/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`DELETE`})}var Wu=e=>Q(`/api/v1/objects/${encodeURIComponent(e)}/comments`).then(Rl),Gu=e=>Q(`/api/v1/comments/${encodeURIComponent(e)}`,{method:`DELETE`});function Ku(e,t,n,r=[]){return Q(`/api/v1/objects/${encodeURIComponent(e)}/comments`,{method:`POST`,body:JSON.stringify({bodyCiphertext:t,keyGeneration:n,mentions:r})})}async function qu(e,t=0){return Q(`/api/v1/containers/${encodeURIComponent(e)}/changes?since=${t}`)}async function Ju(e,t=`note`){return Q(`/api/v1/containers/${encodeURIComponent(e)}/objects`,{method:`POST`,body:JSON.stringify({kind:t})})}async function Yu(e,t){let n=await fetch(`/api/v1/objects/${encodeURIComponent(e)}${t?`?version=${t}`:``}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!n.ok)throw Error(`Unable to read note (${n.status})`);let r=Ll(n.headers.get(`X-Kynotes-Key-Generation`)),i=n.headers.get(`X-Kynotes-Saved-At`)??``;return{bytes:new Uint8Array(await n.arrayBuffer()),version:Number(n.headers.get(`X-Kynotes-Version`)??0),keyGeneration:r,savedAt:i}}async function Xu(e,t,n,r,i){return Q(`/api/v1/objects/${encodeURIComponent(e)}`,{method:`PUT`,body:t,headers:{"Content-Type":`application/octet-stream`,"X-Kynotes-Base-Version":String(n),"X-Kynotes-Key-Generation":String(r),"Idempotency-Key":i}})}function Zu(e,t,n){return Q(`/api/v1/containers/${encodeURIComponent(e)}/uploads`,{method:`POST`,body:JSON.stringify({declaredBytes:t,expectedDigest:n,kind:`attachment`})})}var Qu=e=>Q(`/api/v1/uploads/${encodeURIComponent(e)}`),$u=e=>Q(`/api/v1/uploads/${encodeURIComponent(e)}`,{method:`DELETE`});function ed(e,t,n){return Q(`/api/v1/uploads/${encodeURIComponent(e)}`,{method:`PATCH`,body:n,headers:{"Content-Type":`application/octet-stream`,"X-Kynotes-Chunk-Index":String(t)}})}function td(e,t,n){return Q(`/api/v1/uploads/${encodeURIComponent(e)}/finalize`,{method:`POST`,body:JSON.stringify({metadataCiphertext:t,keyGeneration:n})})}function nd(e,t,n){return Q(`/api/v1/objects/${encodeURIComponent(e)}/attachments`,{method:`POST`,body:JSON.stringify({attachmentId:t,objectVersion:n})})}var rd=e=>Q(`/api/v1/objects/${encodeURIComponent(e)}/attachments`).then(Rl);async function id(e){let t=await fetch(`/api/v1/attachments/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`Unable to download attachment`);return new Uint8Array(await t.arrayBuffer())}var ad=e=>Q(`/api/v1/objects/${encodeURIComponent(e)}/conflicts`).then(Rl);async function od(e){let t=await fetch(`/api/v1/conflicts/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`Unable to read conflicting version (${t.status})`);return new Uint8Array(await t.arrayBuffer())}var sd=e=>Q(`/api/v1/conflicts/${encodeURIComponent(e)}/resolve`,{method:`POST`});function cd(e,t){let n=``;for(let t of e)n+=String.fromCharCode(t);return Q(`/api/v1/share-links`,{method:`POST`,body:JSON.stringify({ciphertext:btoa(n).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``),expiresAt:t})})}var ld=()=>Q(`/api/v1/share-links`),ud=e=>Q(`/api/v1/share-links/${encodeURIComponent(e)}`,{method:`DELETE`});async function dd(e){let t=await fetch(`/api/v1/share-links/${encodeURIComponent(e)}`,{headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`This encrypted link is invalid or expired.`);return new Uint8Array(await t.arrayBuffer())}var fd=e=>Q(`/api/v1/objects/${encodeURIComponent(e)}`,{method:`DELETE`}),pd=()=>Q(`/api/v1/push/web/key`),md=e=>Q(`/api/v1/push/web/subscriptions`,{method:`PUT`,body:JSON.stringify({endpoint:e})}),hd=e=>Q(`/api/v1/push/web/subscriptions`,{method:`DELETE`,body:JSON.stringify({endpoint:e})}),gd=()=>Q(`/api/v1/reminders`),_d=(e,t)=>Q(`/api/v1/reminders/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({at:t})}),vd=e=>Q(`/api/v1/reminders/${encodeURIComponent(e)}`,{method:`DELETE`});function yd(e){if(!bd(e))throw Error(`Invalid mirror result`);return{uploaded:Sd(e.uploaded),skipped:Sd(e.skipped),failed:Sd(e.failed),missing:Sd(e.missing)}}function bd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xd(e){if(typeof e!=`string`)throw Error(`Invalid backup response`);return e}function Sd(e){if(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)throw Error(`Invalid backup response`);return e}function Cd(e){if(!bd(e)||typeof e.paired!=`boolean`||typeof e.allow_private_recovery!=`boolean`||!Array.isArray(e.local_copies))throw Error(`Invalid backup status`);let t=null;if(e.receipt!==null){if(!bd(e.receipt))throw Error(`Invalid backup receipt`);t={id:xd(e.receipt.capsule_id),digest:xd(e.receipt.digest),at:xd(e.receipt.deposited_at)}}if(!bd(e.mirror)||typeof e.mirror.configured!=`boolean`)throw Error(`Invalid mirror status`);return{mirror:{configured:e.mirror.configured,target:xd(e.mirror.target),pending:Sd(e.mirror.pending),last:e.mirror.last===null?null:yd(e.mirror.last)},keyID:xd(e.key_id),keyError:xd(e.key_error??``),paired:e.paired,remoteURL:xd(e.remote_url),localDirectory:xd(e.local_directory),localCopies:e.local_copies.length,localError:xd(e.local_error??``),intervalSeconds:Sd(e.interval_seconds),nextRun:e.next_run===null?null:xd(e.next_run),lastAttempt:xd(e.last_attempt),lastResult:xd(e.last_result),receipt:t,blobCount:Sd(e.blob_count),blobBytes:Sd(e.blob_bytes),allowPrivate:e.allow_private_recovery,databaseBytes:Sd(e.database_bytes??0),capsuleLimitBytes:Sd(e.capsule_limit_bytes??0)}}var wd=e=>e.capsuleLimitBytes>0&&e.databaseBytes>=e.capsuleLimitBytes*.8;function Td(e){return e.intervalSeconds?e.keyID?!e.paired&&!e.localDirectory?`Waiting for a destination`:e.nextRun?`Next ${new Date(e.nextRun).toLocaleString()}`:`Next run not scheduled`:`Waiting for recovery key`:`Manual only`}async function Ed(){return Cd(await Q(`/api/v1/admin/backup/status`))}function Dd(e,t={}){return Q(`/api/v1/admin/backup/${e}`,{method:`POST`,body:JSON.stringify(t)})}async function Od(){let e=await Q(`/api/v1/admin/backup/deposit`,{method:`POST`}).catch(e=>{throw e instanceof Z&&e.code===`database_too_large`?Error(`The database is now larger than one capsule can hold, so no backup was made. Delete unneeded notebooks or old pages, then back up again.`):e});if(!bd(e)||!bd(e.result))throw Error(`Invalid backup result`);let t=typeof e.result.local_path==`string`&&e.result.local_path!==``,n=bd(e.result.receipt),r=e.result.mirror===void 0?` Mirror: not run.`:` Mirror: ${jd(yd(e.result.mirror))}`,i=`Local copy: ${t?`saved`:`not saved`}. KyRecovery: ${n?`deposited`:`not deposited`}.${r}`;return e.error_code||e.result.local_error?`${i} A capsule destination, blob transfer or receipt/audit write failed; check status before relying on this run.`:i}async function kd(){let e=await Q(`/api/v1/admin/backup/drill`,{method:`POST`});if(!bd(e)||typeof e.passed!=`boolean`)throw Error(`Invalid drill response`);if(!e.passed)throw Error(`Restore drill failed. Check the restored database, secrets and inventory.`);return`Synthetic restore drill passed. Ciphertext blobs and real custodian cards require separate recovery proof.`}async function Ad(){let e=await Vl(`/api/v1/admin/backup/export-capsule`,{method:`POST`,credentials:`include`,headers:{"X-CSRF-Token":Bl()}});if(!e.ok){let t=await e.json();throw bd(t)&&bd(t.error)?new Z(xd(t.error.message),{error:{code:xd(t.error.code)}}):Error(`Capsule download failed`)}let t=URL.createObjectURL(await e.blob()),n=document.createElement(`a`);n.href=t,n.download=`KyNotes.kycap`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)}function jd(e){return`${e.uploaded} uploaded, ${e.skipped} already recorded, ${e.failed} failed (${e.missing} missing).`}async function Md(){let e=await Q(`/api/v1/admin/backup/mirror`,{method:`POST`});if(!bd(e))throw Error(`Invalid mirror response`);let t=jd(yd(e.result));return e.error_code?`${t} Mirror incomplete; check status and retry.`:t}var Nd=`none`;function Pd(e,t,n){if(e.wrapAlg!==`aes-256-gcm`)throw Error(`unsupported identity wrap`);let r=Ic(t,$e(e.wrappedPrivateKey),n);if(!Cc(r.publicKey,$e(e.publicKey)))throw Error(`identity public key mismatch`);return{...r,deviceId:e.deviceId}}var Fd=(e,t,n)=>e.wrapAlg===`none`?`device-only`:Pd(e,t.userKEK,n);async function Id(e,t,n,r){if(r)return Fd(r,n,t);let i=await e.stepUp(n.authSecret);if(i)return Fd(i,n,t);let a=wc(),o={publicKey:Qe(a.publicKey),wrapAlg:mc,wrappedPrivateKey:Qe(Fc(n.userKEK,a.privateKey,t))};try{let{deviceId:t}=await e.putMyIdentity(o);return{...a,deviceId:t}}catch(r){let i=r.code;if(i===`password_change_required`)return`admin-password`;let a=i===`identity_exists`?await e.stepUp(n.authSecret):void 0;if(!a)throw r;return Fd(a,n,t)}}async function Ld(e,t,n,r,i){let a=await e.myIdentity();if(!a)return;let o=e=>e?.deviceId===a.deviceId&&Cc(e.publicKey,$e(a.publicKey)),s;if(a.wrapAlg===`none`){if(a.passwordCopy!==`addable`||!o(i))return;s=i}else{let r=await e.stepUp(n.authSecret);if(s=r?Pd(r,n.userKEK,t):o(i)?i:void 0,!s)throw Error(`Sign in with your password on this device before changing it`)}let c=Fc(r.userKEK,s.privateKey,t);if(!Cc(Ic(r.userKEK,c,t).publicKey,$e(a.publicKey)))throw Error(`This browser's copy of your key is damaged. Use Forget this device, then sign in again.`);return{identity:s,identityDeviceId:s.deviceId,wrappedIdentityKey:Qe(c)}}async function Rd(e,t,n=!1,r=!1){let i=await t.load(),a=await e.myIdentity();if(a)return Hd(i,a)||(i=await t.load()),i&&Hd(i,a)?Ud(t,i,a.deviceId):{kind:`link`};if(i?.deviceId&&!n)return{kind:`orphaned`};let o=i&&!i.deviceId?i:{...wc(),deviceId:``};if(o!==i&&!await t.save(o,i??null))return r?{kind:`unsaved`}:Rd(e,t,!1,!0);try{let{deviceId:n}=await e.putDeviceOnlyIdentity(Qe(o.publicKey));return await Ud(t,o,n)}catch(n){if(n.code!==`identity_exists`)throw n;let i=await e.myIdentity();if(i&&Hd(o,i))return Ud(t,o,i.deviceId);if(!r)return Rd(e,t,!1,!0);throw n}}async function zd(e,t,n,r,i){let a=await t.load(),o=await Id(e,n,r,i);return typeof o==`string`?o:t.save(o,a??null)}var Bd=(e,t,n)=>!!(e&&t&&n&&Cc(n,$e(t.publicKey))&&!Cc(e.publicKey,n)),Vd=e=>!(!e||e.wrapAlg!==`aes-256-gcm`&&!e.recoveryId),Hd=(e,t)=>e!==void 0&&Cc(e.publicKey,$e(t.publicKey));async function Ud(e,t,n){let r={...t,deviceId:n};if(t.deviceId===n||await e.save(r,t))return{kind:`held`,identity:r};let i=await e.load();return i?.deviceId===n&&Cc(i.publicKey,t.publicKey)?{kind:`held`,identity:i}:{kind:`unsaved`}}function Wd(e,t){return t?!e||!Cc(e.publicKey,$e(t.publicKey))?`link`:e.deviceId===t.deviceId?`held`:`create`:e?.deviceId?`orphaned`:`create`}function Gd(e,t){if(e?.deviceId)return t===`unreachable`||Wd(e,t)===`held`?e:void 0}var Kd=`kynotes.login-pins.v1`,qd=e=>e.trim().toLowerCase();function Jd(){try{let e=JSON.parse(localStorage.getItem(Kd)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}var Yd=e=>Jd().includes(qd(e))?ct:lt;function Xd(e){let t=Jd();if(!t.includes(qd(e)))try{localStorage.setItem(Kd,JSON.stringify([...t,qd(e)]))}catch{}}async function Zd(e,t,n,r,i){let a=ft(),o=await ut(n,a,ct),s;if(i?.wrapAlg===`aes-256-gcm`){let e=Pd(i,r.userKEK,t);s={identityDeviceId:e.deviceId,wrappedIdentityKey:Qe(Fc(o.userKEK,e.privateKey,t))}}return await e({currentAuthSecret:r.authSecret,newAuthSecret:o.authSecret,newLoginSalt:a,iterations:ct,...s}),{keys:o,identity:i&&s?{...i,wrappedPrivateKey:s.wrappedIdentityKey}:i}}async function Qd(e,t){let{loginSalt:n,iterations:r}=await Wl(e),i=await dt(t,n,r,Yd(e));return await _u(i),i}function $d(e){let t=document.createElement(`dialog`);t.className=`ky-dialog`;let n=document.createElement(`form`),r=document.createElement(`h2`);r.id=`password-step-up`,r.textContent=`Confirm your password`,t.setAttribute(`aria-labelledby`,r.id);let i=document.createElement(`label`);i.textContent=`Password`;let a=document.createElement(`input`);a.type=`password`,a.autocomplete=`current-password`,a.required=!0,i.append(a);let o=document.createElement(`p`);o.setAttribute(`aria-live`,`polite`);let s=document.createElement(`button`);s.textContent=`Confirm`;let c=document.createElement(`button`);c.type=`button`,c.className=`secondary`,c.textContent=`Cancel`;let l=document.createElement(`div`);return l.className=`dialog-actions`,l.append(c,s),n.append(r,i,o,l),t.append(n),document.body.append(t),new Promise((r,i)=>{let l=()=>t.remove(),u=()=>{l(),i(Error(`Password confirmation cancelled`))};t.addEventListener(`cancel`,e=>{e.preventDefault(),u()}),c.onclick=u,n.onsubmit=t=>{t.preventDefault();let n=a.value;a.value=``,s.disabled=!0,o.textContent=``,Qd(e,n).then(e=>{l(),r(e)},e=>{s.disabled=!1,o.textContent=e instanceof Error?e.message:`Password not confirmed`})},t.showModal()})}function ef(e){return e instanceof Z&&e.code===`step_up_required`}async function tf(e,t,n=$d){try{return await t()}catch(r){if(!ef(r))throw r;return await n(e),t()}}var nf=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),rf=n(((e,t)=>{t.exports=nf()})),$=rf();function af({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`1440`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(`2`),[_,v]=(0,X.useState)(`3`);async function y(){let e=await Ed();n(e),c(String(e.intervalSeconds/60))}(0,X.useEffect)(()=>{y().catch(e=>o(e instanceof Error?e.message:`Backup status unavailable`))},[]);async function b(t){i(!0),o(``);try{let n=await tf(e,t);await y(),o(n??`Backup settings updated.`)}catch(e){o(e instanceof Error?e.message:`Backup action failed`)}finally{i(!1)}}return(0,$.jsxs)(`div`,{className:`admin-panel backups`,children:[(0,$.jsx)(`p`,{children:`Sealed capsules carry the database, deployment secrets, recovery public key, configuration and blob inventory. Note and attachment ciphertext blobs require a separate mirror; a capsule alone cannot restore that content.`}),t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`backup-facts`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{children:`Recovery key`}),(0,$.jsx)(`p`,{className:`backup-key`,children:t.keyID||`No key pinned`}),t.keyError&&(0,$.jsx)(`p`,{role:`alert`,children:`Pinned key is missing or invalid.`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{children:`KyRecovery`}),(0,$.jsx)(`p`,{children:t.paired?t.remoteURL:`Not paired`}),t.receipt&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Receipt: `,t.receipt.id]}),(0,$.jsx)(`p`,{children:t.receipt.at}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Receipt digest`}),(0,$.jsx)(`p`,{className:`backup-key`,children:t.receipt.digest})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{children:`Local copies`}),(0,$.jsx)(`p`,{children:t.localDirectory||`No local directory configured`}),(0,$.jsxs)(`p`,{children:[t.localCopies,` retained`]}),t.localError&&(0,$.jsx)(`p`,{role:`alert`,children:`Local directory unavailable.`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{children:`Ciphertext blobs`}),(0,$.jsx)(`p`,{children:t.mirror.configured?t.mirror.target:`No mirror configured`}),(0,$.jsx)(`p`,{children:t.mirror.configured?`${t.mirror.pending} awaiting upload`:`Configure KYNOTES_BLOB_TARGET to protect note and attachment content.`}),t.mirror.last&&(0,$.jsxs)(`p`,{children:[`Last mirror: `,t.mirror.last.uploaded,` uploaded, `,t.mirror.last.skipped,` already recorded, `,t.mirror.last.failed,` failed (`,t.mirror.last.missing,` missing).`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{children:`Schedule`}),(0,$.jsx)(`p`,{children:t.intervalSeconds?`Every ${t.intervalSeconds/60} minutes`:`Off`}),(0,$.jsx)(`p`,{children:Td(t)}),(0,$.jsxs)(`p`,{children:[`Last attempt: `,t.lastAttempt||`None`,` `,t.lastResult]})]})]}),!t.keyID&&(0,$.jsx)(`p`,{role:`status`,children:`Pair with KyRecovery or pin the suite public key by hand to enable backups.`}),t.keyID&&!t.paired&&!t.localDirectory&&(0,$.jsx)(`p`,{role:`status`,children:`The key is pinned, but there is no destination. Pair KyRecovery or configure KYNOTES_BACKUP_DIR.`}),!t.intervalSeconds&&(0,$.jsx)(`p`,{role:`status`,children:`Automatic backups are off.`}),wd(t)&&(0,$.jsxs)(`p`,{role:`alert`,children:[`The database (`,t.databaseBytes.toLocaleString(),` bytes) is past 80% of what one capsule can hold (`,t.capsuleLimitBytes.toLocaleString(),` bytes). New comments and share links are refused if their write would push the database past 90%. Delete unneeded comments, pages or notebooks; revoke unneeded share links (garbage collection reclaims them).`]}),(0,$.jsxs)(`p`,{children:[t.blobCount,` ciphertext blobs (`,t.blobBytes.toLocaleString(),` bytes) are excluded from capsules.`]})]}),(0,$.jsxs)(`div`,{className:`backup-actions`,children:[(0,$.jsx)(`button`,{disabled:r,onClick:()=>void b(Od),children:`Back up now`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(Ad),children:`Download capsule`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r||!t?.mirror.configured,onClick:()=>void b(Md),children:`Mirror now`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(kd),children:`Run drill`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(y),children:`Refresh status`})]}),(0,$.jsx)(`p`,{"aria-live":`polite`,children:r?`Working…`:a}),(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),b(async()=>{await Dd(`schedule`,{interval_seconds:Number(s)*60})})},children:[(0,$.jsxs)(`label`,{children:[`Backup interval in minutes (0 turns it off; otherwise at least 15)`,(0,$.jsx)(`input`,{type:`number`,min:`0`,max:`527040`,step:`1`,value:s,onChange:e=>c(e.target.value),required:!0})]}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,children:`Save schedule`})]}),(0,$.jsx)(`p`,{children:`To preserve backup capacity, the server refuses new comments and share links before the database passes 90% of the capsule limit. Other capsule members still count toward the full limit.`}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Pair with KyRecovery`}),(0,$.jsx)(`p`,{children:`Generate a six-digit pairing code in KyRecovery. Compare the suite key fingerprint out of band, or pin it below before pairing. HTTPS protects the incoming key, token and receipt.`}),(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=d;f(``),b(async()=>{await Dd(`pair-remote`,{url:l,pairing_code:t})})},children:[(0,$.jsxs)(`label`,{children:[`KyRecovery HTTPS URL`,(0,$.jsx)(`input`,{type:`url`,placeholder:`https://kyrecovery.example.com`,value:l,onChange:e=>u(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Six-digit pairing code`,(0,$.jsx)(`input`,{inputMode:`numeric`,pattern:`[0-9]{6}`,maxLength:6,value:d,onChange:e=>f(e.target.value),required:!0})]}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,children:`Pair KyRecovery`})]}),(0,$.jsxs)(`p`,{children:[`Private recovery destinations are `,t?.allowPrivate?`enabled`:`disabled`,`. For a LAN host, configure KYNOTES_BACKUP_ALLOW_PRIVATE_RECOVERY and the documented DNS override.`]}),(0,$.jsx)(`p`,{children:`Unpair removes this server’s URL and token rows. The key, receipts and local copies remain. A KyRecovery administrator must separately revoke the credential.`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r||!t?.paired,onClick:()=>void b(async()=>{await Dd(`unpair`)}),children:`Unpair`})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Pin the suite public key by hand`}),(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),b(async()=>{await Dd(`pin-key`,{public_key:p,threshold:Number(h),total_shares:Number(_)})})},children:[(0,$.jsxs)(`label`,{children:[`Public key (base64)`,(0,$.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Required custodian cards`,(0,$.jsx)(`input`,{type:`number`,min:`2`,max:`255`,value:h,onChange:e=>g(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Total cards`,(0,$.jsx)(`input`,{type:`number`,min:`2`,max:`255`,value:_,onChange:e=>v(e.target.value),required:!0})]}),(0,$.jsx)(`p`,{children:`Only paste the public key. Custodian shares are entered locally during restore. A different pinned key is refused.`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:r,children:`Pin public key`})]})]})]})}var of=e=>e.split(`,`).filter(Boolean).join(` -`),sf=e=>e.split(/[\s,]+/).filter(Boolean).join(`,`);function cf({status:e,text:t,busy:n,message:r,onText:i,onSave:a}){return(0,$.jsxs)(`section`,{className:`config-card office-networks`,"aria-labelledby":`office-networks-heading`,children:[(0,$.jsx)(`h2`,{id:`office-networks-heading`,children:`Office networks`}),(0,$.jsx)(`p`,{className:`admin-note`,children:`Sign-in is limited per network address. Staff in one office usually share one address and can trip that limit together. Networks listed here skip it; per-account limits and lockouts still apply.`}),(0,$.jsxs)(`form`,{onSubmit:a,children:[(0,$.jsxs)(`label`,{children:[`Networks that skip the per-address limit, one per line`,(0,$.jsx)(`textarea`,{rows:4,value:t,onChange:e=>i(e.target.value),placeholder:`203.0.113.0/24`,"aria-describedby":`office-networks-hint`,disabled:!e,spellCheck:!1})]}),(0,$.jsx)(`p`,{id:`office-networks-hint`,className:`admin-note`,children:`List only networks you control: everyone behind a listed address loses the limit, so never add guest Wi-Fi, a VPN provider or your reverse proxy. The widest range accepted is /16 (IPv4) or /48 (IPv6).`}),(0,$.jsx)(`button`,{disabled:n||!e,children:n?`Saving…`:`Save networks`})]}),r&&(0,$.jsx)(`p`,{role:r.error?`alert`:`status`,className:r.error?`error`:`status-line`,children:r.text}),e&&(0,$.jsxs)(`dl`,{className:`status-list`,children:[e.environment&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Also set by the server configuration`}),(0,$.jsx)(`dd`,{className:`backup-key`,children:e.environment.split(`,`).join(`, `)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Requests that skipped the limit`}),(0,$.jsxs)(`dd`,{children:[e.exempted,` since the last change or restart`]})]})]})]})}function lf({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),l=e=>{n(e),i(of(e.networks))};(0,X.useEffect)(()=>{Xl().then(l,()=>c({text:`Could not load the networks.`,error:!0}))},[]);async function u(t){t.preventDefault(),o(!0),c(null);try{let t=await tf(e,()=>Zl(sf(r)));l(t),c({text:t.networks?`Saved. These networks now skip the per-address limit.`:`Saved. No network you listed skips the limit.`,error:!1})}catch(e){if(e instanceof Error&&e.message===`Password confirmation cancelled`)return;c({text:e instanceof Error?e.message:`Could not save the networks.`,error:!0})}finally{o(!1)}}return(0,$.jsx)(cf,{status:t,text:r,busy:a,message:s,onText:i,onSave:e=>void u(e)})}var uf={notebook:[[`path`,{d:`M2 6h4`}],[`path`,{d:`M2 10h4`}],[`path`,{d:`M2 14h4`}],[`path`,{d:`M2 18h4`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`path`,{d:`M16 2v20`}]],work:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`}]],team:[[`path`,{d:`M18 21a8 8 0 0 0-16 0`}],[`circle`,{cx:`10`,cy:`8`,r:`5`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`}]],plus:[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],chevron:[[`path`,{d:`m6 9 6 6 6-6`}]],check:[[`path`,{d:`M20 6 9 17l-5-5`}]],more:[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],settings:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],palette:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],signout:[[`path`,{d:`m16 17 5-5-5-5`}],[`path`,{d:`M21 12H9`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}]],signin:[[`path`,{d:`m10 17 5-5-5-5`}],[`path`,{d:`M15 12H3`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`}]],menu:[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],notes:[[`path`,{d:`M2 6h4`}],[`path`,{d:`M2 10h4`}],[`path`,{d:`M2 14h4`}],[`path`,{d:`M2 18h4`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`path`,{d:`M9.5 8h5`}],[`path`,{d:`M9.5 12H16`}],[`path`,{d:`M9.5 16H14`}]],users:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`}],[`circle`,{cx:`9`,cy:`7`,r:`4`}]],sso:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],backups:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`}],[`path`,{d:`M10 12h4`}]],audit:[[`path`,{d:`M15 12h-5`}],[`path`,{d:`M15 8h-5`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`}]],server:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],account:[[`circle`,{cx:`12`,cy:`8`,r:`5`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`}]],close:[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],back:[[`path`,{d:`m15 18-6-6 6-6`}]],search:[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],h1:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`m17 12 3-2v8`}]],h2:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`}]],h3:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`}]],bold:[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`}]],italic:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`}]],bullets:[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],numbers:[[`path`,{d:`M11 5h10`}],[`path`,{d:`M11 12h10`}],[`path`,{d:`M11 19h10`}],[`path`,{d:`M4 4h1v5`}],[`path`,{d:`M4 9h2`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`}]],checklist:[[`path`,{d:`M13 5h8`}],[`path`,{d:`M13 12h8`}],[`path`,{d:`M13 19h8`}],[`path`,{d:`m3 17 2 2 4-4`}],[`path`,{d:`m3 7 2 2 4-4`}]],link:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`}]],code:[[`path`,{d:`m18 16 4-4-4-4`}],[`path`,{d:`m6 8-4 4 4 4`}],[`path`,{d:`m14.5 4-5 16`}]],draw:[[`path`,{d:`M13 21h8`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}]]};function df({name:e}){return(0,$.jsx)(`svg`,{className:`nav-icon`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:uf[e].map(([e,t],n)=>(0,X.createElement)(e,{key:n,...t}))})}function ff({size:e}){let t=(0,X.useId)().replace(/[^\w-]/g,``);return(0,$.jsxs)(`svg`,{className:`app-mark`,width:e,height:e,viewBox:`0 0 256 256`,"aria-hidden":`true`,children:[(0,$.jsx)(`filter`,{id:`${t}f`,children:(0,$.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .55 .55 .55 0 -.33`})}),(0,$.jsx)(`mask`,{id:`${t}m`,children:(0,$.jsx)(`image`,{href:`/app-icon.png`,width:`256`,height:`256`,filter:`url(#${t}f)`})}),(0,$.jsx)(`rect`,{className:`app-mark-tile`,width:`256`,height:`256`,rx:`44`}),(0,$.jsx)(`rect`,{className:`app-mark-glyph`,width:`256`,height:`256`,mask:`url(#${t}m)`})]})}var pf=Object.freeze({kypost:`data:image/png;base64,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`,kycalendar:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22320%22%20y%3D%22345%22%20width%3D%22614%22%20height%3D%22565%22%20rx%3D%2270%22%20fill%3D%22%23f2efe8%22%2F%3E%3Crect%20x%3D%22320%22%20y%3D%22475%22%20width%3D%22614%22%20height%3D%2234%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22425%22%20y%3D%22275%22%20width%3D%2284%22%20height%3D%22150%22%20rx%3D%2242%22%20fill%3D%22%23f2efe8%22%20stroke%3D%22%23182326%22%20stroke-width%3D%2234%22%2F%3E%3Crect%20x%3D%22745%22%20y%3D%22275%22%20width%3D%2284%22%20height%3D%22150%22%20rx%3D%2242%22%20fill%3D%22%23f2efe8%22%20stroke%3D%22%23182326%22%20stroke-width%3D%2234%22%2F%3E%3Crect%20x%3D%22395%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22567%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22739%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23e2562a%22%2F%3E%3Crect%20x%3D%22395%22%20y%3D%22730%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22567%22%20y%3D%22730%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3C%2Fsvg%3E`,kydrive:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20d%3D%22M300%20395%20a55%2055%200%200%201%2055%20-55%20h185%20a55%2055%200%200%201%2045%2024%20l45%2066%20h260%20a55%2055%200%200%201%2055%2055%20v365%20a55%2055%200%200%201%20-55%2055%20h-535%20a55%2055%200%200%201%20-55%20-55%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Crect%20x%3D%22300%22%20y%3D%22500%22%20width%3D%22654%22%20height%3D%2234%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20d%3D%22M627%20585%20l135%20140%20h-80%20v120%20h-110%20v-120%20h-80%20z%22%20fill%3D%22%23e2562a%22%20stroke%3D%22%23e2562a%22%20stroke-width%3D%2224%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E`,kynotes:`data:image/png;base64,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`,kymessage:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20transform%3D%22translate(0%2025)%22%20d%3D%22M370%20300%20h514%20a90%2090%200%200%201%2090%2090%20v300%20a90%2090%200%200%201%20-90%2090%20h-330%20l-170%20140%20v-140%20h-14%20a90%2090%200%200%201%20-90%20-90%20v-300%20a90%2090%200%200%201%2090%20-90%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Ccircle%20cx%3D%22467%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22627%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22787%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,"kymessage-chat":`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20transform%3D%22translate(0%2025)%22%20d%3D%22M370%20300%20h514%20a90%2090%200%200%201%2090%2090%20v300%20a90%2090%200%200%201%20-90%2090%20h-330%20l-170%20140%20v-140%20h-14%20a90%2090%200%200%201%20-90%20-90%20v-300%20a90%2090%200%200%201%2090%20-90%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Ccircle%20cx%3D%22467%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22627%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22787%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,kyidentity:`data:image/png;base64,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`,kydns:`data:image/png;base64,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`,kypulse:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpolyline%20points%3D%22280%2C650%20430%2C650%20515%2C440%20640%2C840%20745%2C560%20800%2C650%20850%2C650%22%20fill%3D%22none%22%20stroke%3D%22%23f2efe8%22%20stroke-width%3D%22104%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Ccircle%20cx%3D%22930%22%20cy%3D%22650%22%20r%3D%2278%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,kyrecovery:`data:image/png;base64,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`,kyyard:`data:image/png;base64,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`});function mf(e){if(Object.hasOwn(pf,e))return pf[e];let t=/^(?:ky)?([a-z0-9])/i.exec(String(e))?.[1].toUpperCase()??`?`;return`data:image/svg+xml,${encodeURIComponent(`${t}`)}`}function hf(e){let t=e.ownerDocument,n=t.getElementById(e.getAttribute(`aria-controls`));if(!n)return()=>{};let r=()=>[...n.querySelectorAll(`[role="menuitem"]`)],i=()=>e.getAttribute(`aria-expanded`)===`true`;for(let e of r())e.tabIndex=-1;e.setAttribute(`aria-expanded`,`false`),n.hidden=!0;let a=t=>{e.setAttribute(`aria-expanded`,`true`),n.hidden=!1,r().at(t)?.focus()},o=t=>{i()&&(e.setAttribute(`aria-expanded`,`false`),n.hidden=!0,t&&e.focus())},s=(e,t)=>{let n=r();n[(n.indexOf(e)+t+n.length)%n.length]?.focus()},c=()=>i()?o(!1):a(0),l=e=>{e.key===`Escape`&&o(!0),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),a(e.key===`ArrowDown`?0:-1))},u=e=>{let t=e.target.closest(`[role="menuitem"]`),n=r();if(e.key===`ArrowDown`)s(t,1);else if(e.key===`ArrowUp`)s(t,-1);else if(e.key===`Home`)n[0]?.focus();else if(e.key===`End`)n.at(-1)?.focus();else if(e.key===`Escape`)o(!0);else if(e.key===` `)t?.click();else if(e.key===`Tab`){o(!1);return}else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let r=e.key.toLowerCase(),i=n.indexOf(t);[...n.slice(i+1),...n.slice(0,i+1)].find(e=>e.textContent.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()},d=e=>{e.target.closest(`[role="menuitem"]`)&&o(!0)},f=t=>{i()&&!e.contains(t.target)&&!n.contains(t.target)&&o(!1)},p=t=>{let r=t.relatedTarget;r&&!e.contains(r)&&!n.contains(r)&&o(!1)};return e.addEventListener(`click`,c),e.addEventListener(`keydown`,l),n.addEventListener(`keydown`,u),n.addEventListener(`click`,d),n.addEventListener(`focusout`,p),t.addEventListener(`pointerdown`,f),()=>{e.removeEventListener(`click`,c),e.removeEventListener(`keydown`,l),n.removeEventListener(`keydown`,u),n.removeEventListener(`click`,d),n.removeEventListener(`focusout`,p),t.removeEventListener(`pointerdown`,f)}}var gf=`MIT License - -Copyright (c) 2026 Busnes.app - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -`;function _f({version:e,onClose:t}){let n=new Date().getFullYear();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`ky-about-head`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{className:`ky-about-name`,children:[`KyNotes `,e?(0,$.jsxs)(`span`,{className:`ky-about-version`,children:[`v`,e]}):null]}),(0,$.jsx)(`p`,{className:`ky-about-meta`,children:`Developed by Busnes.app`}),(0,$.jsxs)(`p`,{className:`ky-about-meta`,children:[`© `,n,` · Licensed under the MIT License`]})]}),(0,$.jsx)(`button`,{type:`button`,className:`ky-about-close`,onClick:t,children:`Close`})]}),(0,$.jsx)(`textarea`,{className:`ky-about-license`,readOnly:!0,value:gf,"aria-label":`MIT License`})]})}function vf({signedIn:e,className:t=`app-footer`,children:n}){let[r,i]=(0,X.useState)(``),a=(0,X.useRef)(null),[o,s]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!o||!e)return;let t=!1;return Ql().then(e=>{t||i(e.version??``)}).catch(()=>void 0),()=>{t=!0}},[o,e]),(0,$.jsxs)(`footer`,{className:t,children:[n,(0,$.jsxs)(`button`,{type:`button`,className:`ky-license-link`,onClick:()=>{a.current?.showModal(),s(!0)},children:[`© `,new Date().getFullYear(),` · MIT License`]}),(0,$.jsx)(`dialog`,{ref:a,className:`ky-about`,"aria-label":`About KyNotes`,onClose:()=>s(!1),onClick:e=>{e.target===a.current&&a.current.close()},children:(0,$.jsx)(_f,{version:e?r:``,onClose:()=>a.current?.close()})})]})}function yf({name:e,role:t,actions:n}){return(0,$.jsxs)(`div`,{className:`ky-user`,children:[(0,$.jsxs)(`div`,{className:`ky-user-copy`,children:[(0,$.jsx)(`p`,{className:`ky-user-name`,children:e}),(0,$.jsx)(`p`,{className:`ky-user-role`,children:t})]}),(0,$.jsx)(`div`,{className:`ky-user-actions`,children:n})]})}var bf=`(max-width: 720px)`,xf=e=>{let t=matchMedia(bf);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)};function Sf(){return(0,X.useSyncExternalStore)(xf,()=>matchMedia(bf).matches)}function Cf({icon:e,label:t,current:n,href:r,disabled:i,expanded:a,controls:o,onClick:s}){let c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(df,{name:e}),(0,$.jsx)(`span`,{children:t})]});return r?(0,$.jsx)(`a`,{className:`ky-nav-item`,href:r,"aria-current":n?`page`:void 0,onClick:s,children:c}):(0,$.jsx)(`button`,{type:`button`,className:`ky-nav-item`,"aria-current":n?`page`:void 0,"aria-expanded":a,"aria-controls":o,disabled:i,onClick:s,children:c})}function wf({apps:e}){return e.length?(0,$.jsxs)(`nav`,{className:`ky-app-rail`,"aria-label":`Apps`,children:[(0,$.jsx)(`p`,{className:`ky-app-rail-label`,"aria-hidden":`true`,children:`Apps`}),(0,$.jsx)(`ul`,{children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`a`,{href:e.url,title:e.name,"aria-label":e.name,"aria-current":e.id===`kynotes`?`page`:void 0,children:(0,$.jsx)(`img`,{src:mf(e.id),width:24,height:24,alt:``})})},e.id))})]}):null}function Tf({id:e,items:t,current:n}){let r=(0,X.useRef)(null);return(0,X.useEffect)(()=>hf(r.current),[]),(0,$.jsxs)(`div`,{className:`ky-menu`,children:[(0,$.jsx)(`button`,{ref:r,type:`button`,className:`ky-icon-button`,"aria-label":`Settings`,title:`Settings`,"aria-haspopup":`menu`,"aria-expanded":`false`,"aria-controls":e,"aria-current":n?`page`:void 0,children:(0,$.jsx)(df,{name:`settings`})}),(0,$.jsx)(`div`,{className:`ky-menu-list`,id:e,role:`menu`,"aria-label":`Settings`,hidden:!0,children:t.map(e=>(0,$.jsx)(`a`,{role:`menuitem`,tabIndex:-1,href:e.href,"aria-current":e.current?`page`:void 0,children:e.label},e.href))})]})}function Ef({label:e,nav:t,tree:n,user:r,settings:i,onSignOut:a,className:o=``,children:s}){let[c,l]=(0,X.useState)([]);(0,X.useEffect)(()=>{let e=!0;return $l().then(t=>{e&&l(t.apps)}).catch(()=>void 0),()=>{e=!1}},[]);let u=(0,$.jsx)(wf,{apps:c}),d=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tf,{id:e,items:i.items,current:i.current}),(0,$.jsx)(`button`,{type:`button`,className:`ky-icon-button`,"aria-label":`Sign out`,title:`Sign out`,onClick:a,children:(0,$.jsx)(df,{name:`signout`})})]});return(0,$.jsxs)(`div`,{className:`ky-app ${o}`,children:[(0,$.jsxs)(`header`,{className:`ky-sidebar`,children:[(0,$.jsxs)(`div`,{className:`ky-mobile-head`,children:[(0,$.jsxs)(`div`,{className:`ky-brand`,children:[(0,$.jsx)(ff,{size:28}),(0,$.jsx)(`span`,{children:`KyNotes`})]}),(0,$.jsx)(`div`,{className:`ky-mobile-actions`,children:d(`settings-menu-header`)})]}),(0,$.jsx)(`nav`,{className:`ky-nav`,"aria-label":e,children:t}),n,(0,$.jsxs)(`div`,{className:`ky-sidebar-foot`,children:[u,(0,$.jsx)(yf,{name:r.name,role:r.role,actions:d(`settings-menu-footer`)}),(0,$.jsx)(vf,{signedIn:!0})]})]}),(0,$.jsxs)(`main`,{className:`ky-content`,children:[s,(0,$.jsx)(vf,{signedIn:!0,className:`ky-content-foot`,children:u})]})]})}var Df=Object.freeze({id:`system`,name:`Match system`,scheme:`system`,aliases:Object.freeze([])}),Of=(e,t,n,r,i=[])=>Object.freeze({id:e,name:t,scheme:n,pair:r,aliases:Object.freeze(i)}),kf=Object.freeze([Of(`busnes-light`,`Busnes Light`,`light`,`busnes-pair`),Of(`busnes-dark`,`Busnes Dark`,`dark`,`busnes-pair`),Of(`light-matter`,`Matter Light`,`light`,`matter-pair`,[`Light Matter`]),Of(`dark-matter`,`Matter Dark`,`dark`,`matter-pair`,[`Dark Matter`,`Current`]),Of(`white-cliffs`,`Ocean Light`,`light`,`ocean-pair`,[`White Cliffs`,`Cliffs`]),Of(`ocean`,`Ocean Dark`,`dark`,`ocean-pair`,[`Ocean`]),Of(`forest-light`,`Forest Light`,`light`,`forest-pair`),Of(`forest`,`Forest Dark`,`dark`,`forest-pair`,[`Forest`]),Of(`polished-ky`,`Ky Light`,`light`,`ky-pair`,[`Polished Ky`]),Of(`patina-ky`,`Ky Dark`,`dark`,`ky-pair`,[`Patina Ky`,`patina`,`Patina Ky (base)`]),Of(`paper`,`Nord Light`,`light`,`nord-pair`,[`Paper Clean`]),Of(`nord`,`Nord Dark`,`dark`,`nord-pair`,[`Nord`,`Nord Slate`])]),Af=(e,t,n,r)=>Object.freeze({id:e,name:t,light:n,dark:r}),jf=Object.freeze([Af(`busnes-pair`,`Busnes`,`busnes-light`,`busnes-dark`),Af(`matter-pair`,`Matter`,`light-matter`,`dark-matter`),Af(`ocean-pair`,`Ocean`,`white-cliffs`,`ocean`),Af(`forest-pair`,`Forest`,`forest-light`,`forest`),Af(`ky-pair`,`Ky`,`polished-ky`,`patina-ky`),Af(`nord-pair`,`Nord`,`paper`,`nord`)]),Mf=(e,t,n,r,i,a,o,s,c,l,u,d=`color-mix(in srgb, ${t} 93%, ${r})`,f=`color-mix(in srgb, ${o} 60%, ${r})`,p,m)=>Object.freeze({bg:e,panel:t,ink:n,inkStrong:r,accent:i,accentSoft:a,line:o,glow:s,sidebarStart:c,sidebarEnd:l,buttonText:u,panelHover:d,lineStrong:f,inkMuted:`color-mix(in srgb, ${n} 90%, ${t})`,...p&&{danger:p},...m&&{success:m}}),Nf=Object.freeze({"light-matter":Mf(`#f5efe5`,`#fff8ee`,`#4c3d32`,`#2d1f15`,`#805a39`,`#e2d0b8`,`#d4c7b5`,`transparent`,`#ede2d2`,`#ede2d2`,`#ffffff`),"dark-matter":Mf(`#1d1b19`,`#292725`,`#cfc6bb`,`#f0e9df`,`#c29a72`,`#49392c`,`#45403a`,`transparent`,`#25221f`,`#25221f`,`#24170f`),"white-cliffs":Mf(`#f7f9fb`,`#ffffff`,`#2e4c63`,`#163246`,`#1d5fa6`,`#dde9f7`,`#c7d6df`,`transparent`,`#eaf1f8`,`#eaf1f8`,`#ffffff`),ocean:Mf(`#0f1b24`,`#152a36`,`#b8d8e8`,`#e0f2fb`,`#6aa8e8`,`#1f3a55`,`#2f5567`,`rgba(58, 130, 155, 0.24)`,`#112430`,`#173342`,`#0a1b22`),"forest-light":Mf(`#f3f6ef`,`#fcfdf9`,`#435342`,`#203322`,`#4b6b37`,`#e2ebda`,`#c5d0bc`,`transparent`,`#e8eee1`,`#e8eee1`,`#ffffff`,void 0,void 0,void 0,`#00737a`),forest:Mf(`#142018`,`#1f2f24`,`#c7dbc7`,`#e3f0df`,`#8faa74`,`#3a5837`,`#4f694f`,`rgba(118, 148, 95, 0.24)`,`#18261c`,`#223629`,`#12200f`,void 0,void 0,void 0,`#6ee0d0`),"polished-ky":Mf(`#eef2f6`,`#ffffff`,`#475569`,`#0f172a`,`#08758b`,`#daf2f4`,`#c2cdd8`,`transparent`,`#e7edf3`,`#e7edf3`,`#ffffff`),"patina-ky":Mf(`#10161e`,`#1b2530`,`#afbdca`,`#e2e8f0`,`#6fc9cc`,`#203d41`,`#34414d`,`transparent`,`#161e27`,`#161e27`,`#10161e`),paper:Mf(`#eceff4`,`#ffffff`,`#4c566a`,`#2e3440`,`#4a6a94`,`#dbe4ef`,`#c5cdd9`,`transparent`,`#e5e9f0`,`#e5e9f0`,`#ffffff`),nord:Mf(`#2e3440`,`#3b4252`,`#d8dee9`,`#eceff4`,`#88c0d0`,`rgba(136, 192, 208, 0.2)`,`#4c566a`,`transparent`,`#3b4252`,`#3b4252`,`#0d0f14`,`#434c5e`,`#5e81ac`,`#ecc4c8`,`#bcd4aa`)}),Pf=Object.freeze(Object.fromEntries([...Object.keys(Nf.nord),`warning`].map(e=>[e,`--`+e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase())]))),Ff=()=>globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1;function If(e){return jf.find(t=>t.id===e)}function Lf(e,t=Ff()){if(e===Df.id)return Df;let n=If(e);return n&&(e=t?n.dark:n.light),kf.find(t=>t.id===e||t.name===e||t.aliases.includes(e))}function Rf(e,t=globalThis.document?.documentElement){let n=Lf(e),r=Nf[n?.id];for(let e of Object.values(Pf))t.style.removeProperty(e);if(t.style.colorScheme=``,!r)return null;for(let[e,n]of Object.entries(Pf))r[e]&&t.style.setProperty(n,r[e]);return t.style.setProperty(`--danger`,r.danger??`var(--ky-danger-${n.scheme})`),t.style.setProperty(`--success`,r.success??`var(--ky-success-${n.scheme})`),t.style.setProperty(`--warning`,`var(--ky-warning-${n.scheme})`),t.style.colorScheme=n.scheme,n.scheme}Object.freeze([`system`,`busnes-light`,`busnes-dark`]);function zf(e){try{return globalThis.localStorage.getItem(e)}catch{return null}}function Bf(e,t){try{globalThis.localStorage.setItem(e,t)}catch{}}function Vf(e,t){let n=globalThis.window??globalThis,r=n=>{(n.key===e||n.key===null)&&t()},i=n.matchMedia?.(`(prefers-color-scheme: dark)`),a=()=>t();return n.addEventListener?.(`storage`,r),i?.addEventListener(`change`,a),()=>{n.removeEventListener?.(`storage`,r),i?.removeEventListener(`change`,a)}}var Hf=`kynotes-theme`,Uf=jf.map(e=>({pair:e,choices:[{mode:`system`,label:`Match system`,value:e.id===`busnes-pair`?Df.id:e.id},{mode:`light`,label:`Light`,value:e.light},{mode:`dark`,label:`Dark`,value:e.dark}]})),Wf=()=>window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1;function Gf(){let e=zf(Hf);return If(e)?.id??Lf(e)?.id??Df.id}function Kf(e,t=!1){let n=Lf(e,Wf());if(!n)return;let r=document.documentElement;if(Rf(e,r))delete r.dataset.theme;else{let e=n.id===`system`?Wf()?`busnes-dark`:`busnes-light`:n.id;r.dataset.theme=e,r.style.colorScheme=e===`busnes-dark`?`dark`:`light`}t&&Bf(Hf,If(e)?.id??n.id)}function qf(){Kf(Gf())}typeof window<`u`&&Vf(Hf,qf);function Jf(){let[e,t]=(0,X.useState)(Gf);return(0,X.useEffect)(()=>{let e=()=>t(Gf());return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,e=>{t(e),Kf(e,!0)}]}function Yf(){let[e,t]=Jf();return(0,$.jsxs)(`section`,{className:`appearance-section`,"aria-labelledby":`appearance-heading`,children:[(0,$.jsx)(`h2`,{id:`appearance-heading`,className:`visually-hidden`,children:`Appearance`}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Pick a palette and how it handles light and dark. Match system switches with your device’s setting; Light or Dark keeps one. Your choice applies straight away and is saved in this browser only.`}),(0,$.jsxs)(`fieldset`,{className:`ky-appearance`,children:[(0,$.jsx)(`legend`,{className:`ky-appearance-legend`,children:`Theme`}),(0,$.jsx)(`div`,{className:`ky-appearance-grid appearance-pairs`,children:Uf.map(({pair:n,choices:r})=>(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":`${n.id}-name`,className:`appearance-pair`,children:[(0,$.jsxs)(`div`,{className:`appearance-pair-head`,children:[(0,$.jsx)(`h2`,{id:`${n.id}-name`,className:`appearance-pair-name`,children:n.name}),(0,$.jsxs)(`span`,{className:`appearance-pair-halves`,children:[Lf(n.light)?.name,` · `,Lf(n.dark)?.name]})]}),(0,$.jsx)(`span`,{className:`ky-appearance-preview`,"data-ky-preview":n.id,"aria-hidden":`true`}),(0,$.jsx)(`div`,{className:`appearance-modes`,children:r.map(({mode:n,label:r,value:i})=>(0,$.jsxs)(`label`,{className:`appearance-mode`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`kynotes-theme`,value:i,checked:e===i,onChange:()=>t(i)}),e===i&&(0,$.jsx)(df,{name:`check`}),(0,$.jsx)(`span`,{children:r})]},n))})]},n.id))})]})]})}function Xf(){let[e,t]=Jf();return(0,$.jsx)(`select`,{"aria-label":`Color theme`,value:e,onChange:e=>t(e.target.value),children:Uf.map(({pair:e,choices:t})=>(0,$.jsx)(`optgroup`,{label:e.name,children:t.map(({mode:t,label:n,value:r})=>(0,$.jsxs)(`option`,{value:r,children:[e.name,` · `,n]},t))},e.id))})}function Zf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Qf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,$f=e=>typeof e==`string`,ep=e=>$f(e)&&e.length>0&&e.length<=128;function tp(e){return Zf(e)&&ep(e.id)&&$f(e.status)&&$f(e.homeRegion)&&typeof e.enabled==`boolean`&&Qf(e.revision)&&$f(e.lastPoll)&&Qf(e.notesUsedBytes)&&Qf(e.poolBytes)&&Qf(e.orgUsedBytes)&&Qf(e.ceilingBytes)&&$f(e.grantExpiresAt)}function np(e){return Zf(e)&&ep(e.id)&&$f(e.username)&&$f(e.role)&&(e.accountKind===`user`||e.accountKind===`admin`)&&$f(e.status)&&Qf(e.quotaBytes)&&$f(e.createdAt)&&Qf(e.usedBytes)}async function rp(){let e=await Q(`/api/v1/admin/orgs`);if(!Array.isArray(e)||!e.every(tp))throw Error(`Organization metadata could not be read. Refresh to try again.`);return e}async function ip(e){let t=await Q(`/api/v1/admin/users?org=${encodeURIComponent(e)}`);if(!Array.isArray(t)||!t.every(np))throw Error(`Account metadata could not be read. Refresh to try again.`);return t}async function ap(e){let t=await Q(`/api/v1/admin/audit${e?`?org=${encodeURIComponent(e)}`:``}`);if(!Array.isArray(t)||!t.every(e=>Zf(e)&&Object.values(e).every($f)))throw Error(`Audit metadata could not be read. Refresh to try again.`);return t}var op=[[`orgs`,`Organizations`,`team`,`Organization status and shared storage-pool metadata.`],[`users`,`Users`,`users`,`Select an organization to inspect its accounts. KyIdentity manages customer accounts.`],[`sso`,`Single sign-on`,`sso`,`Shared sign-in configuration is managed by the deployment.`],[`backups`,`Backups`,`backups`,`Platform recovery configuration and scheduled backups.`],[`audit`,`Audit log`,`audit`,`Platform events or one organization's metadata-only audit history.`],[`server`,`Server`,`server`,`Health, readiness and platform office-network settings.`]],sp=e=>`${e.toLocaleString()} B`,cp=e=>e instanceof Error?e.message:`Metadata could not be read. Refresh to try again.`;function lp({username:e,sso:t,onLogout:n,password:r}){let i=[...t?[]:[[`account`,`Account`]],[`appearance`,`Appearance`]],a=()=>[...op,...i].find(([e])=>location.hash===`#${e}`)?.[0]??`orgs`,[o,s]=(0,X.useState)(a),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)({kind:`loading`}),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)({scope:``,state:{kind:`loading`}}),[v,y]=(0,X.useState)({scope:``,state:{kind:`loading`}}),[b,x]=(0,X.useState)({kind:`loading`}),[S,C]=(0,X.useState)(null);(0,X.useEffect)(()=>{window.scrollTo(0,0);let e=()=>s(a());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,X.useEffect)(()=>{let e=!0;return d({kind:`loading`}),rp().then(t=>{e&&(d({kind:`ready`,value:t}),p(e=>t.some(t=>t.id===e)?e:``))}).catch(t=>{e&&d({kind:`failed`,message:cp(t)})}),ql().then(t=>{e&&x({kind:`ready`,value:t})}).catch(t=>{e&&x({kind:`failed`,message:cp(t)})}),au().then(t=>{e&&C(t)}).catch(()=>{e&&C(null)}),()=>{e=!1}},[c]),(0,X.useEffect)(()=>{let e=!0;if(o===`users`){if(_({scope:f,state:{kind:`loading`}}),!f)_({scope:f,state:{kind:`ready`,value:[]}});else return ip(f).then(t=>{e&&_({scope:f,state:{kind:`ready`,value:t}})}).catch(t=>{e&&_({scope:f,state:{kind:`failed`,message:cp(t)}})}),()=>{e=!1}}},[f,c,o]),(0,X.useEffect)(()=>{let e=!0;if(o===`audit`)return y({scope:m,state:{kind:`loading`}}),ap(m).then(t=>{e&&y({scope:m,state:{kind:`ready`,value:t}})}).catch(t=>{e&&y({scope:m,state:{kind:`failed`,message:cp(t)}})}),()=>{e=!1}},[m,c,o]);let w=e=>{p(e),location.hash=`users`,s(`users`)},T=u.kind===`ready`?u.value:[];return(0,$.jsxs)(Ef,{className:`admin-shell`,label:`Administration sections`,onSignOut:n,user:{name:e,role:`Staff administrator`},settings:{items:i.map(([e,t])=>({href:`#${e}`,label:t,current:o===e})),current:i.some(([e])=>e===o)},nav:(0,$.jsx)($.Fragment,{children:op.map(([e,t,n])=>(0,$.jsx)(Cf,{icon:n,label:t,href:`#${e}`,current:o===e},e))}),children:[(0,$.jsxs)(`section`,{className:`page-view admin-view`,hidden:!i.some(([e])=>e===o),"aria-labelledby":`staff-settings-heading`,children:[(0,$.jsx)(`header`,{className:`ky-page-head`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{id:`staff-settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,$.jsx)(`p`,{className:`ky-page-lede`,children:`Your administrator account and browser appearance.`})]})}),(0,$.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:i.map(([e,t])=>(0,$.jsx)(`a`,{className:`ky-nav-item`,href:`#${e}`,"aria-current":o===e?`page`:void 0,children:t},e))}),!t&&(0,$.jsx)(`div`,{hidden:o!==`account`,children:r}),(0,$.jsx)(`div`,{hidden:o!==`appearance`,children:(0,$.jsx)(Yf,{})})]}),op.map(([t,n,,r])=>(0,$.jsxs)(`section`,{id:t,className:`page-view admin-view`,hidden:o!==t,"aria-labelledby":`staff-${t}-heading`,children:[(0,$.jsxs)(`header`,{className:`ky-page-head`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{id:`staff-${t}-heading`,className:`ky-page-title`,children:n}),(0,$.jsx)(`p`,{className:`ky-page-lede`,children:r})]}),(0,$.jsx)(`button`,{className:`secondary`,type:`button`,onClick:()=>l(e=>e+1),children:`Refresh`})]}),t===`orgs`&&(0,$.jsx)(up,{state:u,empty:`No organizations are mirrored yet.`,children:e=>(0,$.jsxs)(dp,{label:`Organization directory`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`col`,children:`Organization`}),(0,$.jsx)(`th`,{scope:`col`,children:`Status`}),(0,$.jsx)(`th`,{scope:`col`,children:`Region`}),(0,$.jsx)(`th`,{scope:`col`,children:`Notes stored`}),(0,$.jsx)(`th`,{scope:`col`,children:`Shared pool`}),(0,$.jsx)(`th`,{scope:`col`,children:`Last poll`})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`row`,children:(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>w(e.id),children:e.id})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":e.status===`active`&&e.enabled?`success`:void 0,children:e.status===`active`&&!e.enabled?`App disabled`:e.status.replaceAll(`_`,` `)})}),(0,$.jsx)(`td`,{children:e.homeRegion}),(0,$.jsx)(`td`,{children:sp(e.notesUsedBytes)}),(0,$.jsxs)(`td`,{children:[sp(e.orgUsedBytes),` / `,sp(e.poolBytes)]}),(0,$.jsx)(`td`,{children:e.lastPoll||`Not polled`})]},e.id))})]})}),(t===`users`||t===`audit`)&&u.kind===`failed`&&(0,$.jsx)(`p`,{role:`alert`,children:u.message}),t===`users`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`field`,children:[`Organization`,(0,$.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),disabled:T.length===0,children:[(0,$.jsx)(`option`,{value:``,children:`Select an organization`}),T.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,$.jsx)(up,{state:g.scope===f?g.state:{kind:`loading`},empty:f?`No accounts in this organization.`:`Select an organization to view accounts.`,children:e=>(0,$.jsxs)(dp,{label:`Organization accounts`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`col`,children:`Account`}),(0,$.jsx)(`th`,{scope:`col`,children:`Role`}),(0,$.jsx)(`th`,{scope:`col`,children:`Status`}),(0,$.jsx)(`th`,{scope:`col`,children:`Stored`})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`row`,children:e.username}),(0,$.jsx)(`td`,{children:e.accountKind===`admin`?`Administrator`:`Everyday`}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":e.status===`active`?`success`:void 0,children:e.status})}),(0,$.jsx)(`td`,{children:sp(e.usedBytes)})]},e.id))})]})})]}),t===`audit`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`field`,children:[`Audit scope`,(0,$.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Platform`}),T.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,$.jsx)(up,{state:v.scope===m?v.state:{kind:`loading`},empty:`No audit events recorded.`,children:e=>(0,$.jsx)(`div`,{className:`audit-log`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`audit-row`,children:[(0,$.jsx)(`strong`,{children:e.event}),(0,$.jsxs)(`span`,{children:[e.outcome,` · `,e.at]})]},`${e.at}-${t}`))})})]}),t===`sso`&&(b.kind===`ready`?(0,$.jsxs)(`dl`,{className:`status-list`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Status`}),(0,$.jsx)(`dd`,{children:b.value.enabled?`Enabled`:`Disabled`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Issuer`}),(0,$.jsx)(`dd`,{children:b.value.issuerUrl})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Client`}),(0,$.jsx)(`dd`,{children:b.value.clientId})]})]}):(0,$.jsx)(`p`,{role:b.kind===`failed`?`alert`:`status`,children:b.kind===`failed`?b.message:`Loading sign-in configuration…`})),t===`backups`&&(0,$.jsx)(af,{username:e}),t===`server`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{role:`note`,className:`admin-note`,children:`Staff administration does not grant access to notes or content keys.`}),(0,$.jsxs)(`dl`,{className:`status-list`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Health`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(fp,{ok:S?.health})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Readiness`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(fp,{ok:S?.ready})})]})]}),(0,$.jsx)(lf,{username:e})]})]},t))]})}function up({state:e,empty:t,children:n}){switch(e.kind){case`loading`:return(0,$.jsx)(`p`,{role:`status`,children:`Loading metadata…`});case`failed`:return(0,$.jsx)(`p`,{role:`alert`,children:e.message});case`ready`:return e.value.length===0?(0,$.jsx)(`p`,{className:`config-muted`,children:t}):n(e.value)}}function dp({label:e,children:t}){return(0,$.jsx)(`div`,{role:`region`,"aria-label":e,tabIndex:0,style:{overflowX:`auto`},children:(0,$.jsx)(`table`,{className:`data-table`,children:t})})}function fp({ok:e}){return(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":e===void 0?void 0:e?`success`:`danger`,children:e===void 0?`Checking…`:e?`OK`:`Failed`})}var pp=[[`users`,`Users`,`users`,`Everyone who can sign in to this server.`],[`teams`,`Teams`,`team`,`A team belongs to an everyday owner, who names it and shares its keys. Administrators never see its name or its notes.`],[`sso`,`Single sign-on`,`sso`,`Connect KyNotes to KySignOn Server for one-click single sign-on and automated user directory replication.`],[`backups`,`Backups`,`backups`,`Scheduled backups of this server, kept in a local directory or in KyRecovery.`],[`audit`,`Audit log`,`audit`,`Metadata-only records of administrative actions.`],[`server`,`Server`,`server`,`Health and readiness of this KyNotes server, and the office networks that skip the sign-in limit.`]];function mp(e){return e.deployment===`multi`?(0,$.jsx)(lp,{...e}):(0,$.jsx)(hp,{...e})}function hp({username:e,sso:t,onLogout:n,password:r}){let i=[...t?[]:[[`account`,`Account`]],[`appearance`,`Appearance`]],a=()=>[...pp,...i].find(([e])=>location.hash===`#${e}`)?.[0]??`users`,[o,s]=(0,X.useState)(a),c=(e,t,n)=>(0,$.jsx)(Cf,{icon:n,label:t,href:`#${e}`,current:o===e},e),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)([]);return(0,X.useEffect)(()=>{window.scrollTo(0,0);let e=()=>s(a());return window.addEventListener(`hashchange`,e),Promise.all([ou(),su(),au()]).then(([e,t,n])=>{f(e),m(t),u(n)}).catch(()=>{}),()=>window.removeEventListener(`hashchange`,e)},[]),(0,$.jsxs)(Ef,{className:`admin-shell`,label:`Administration sections`,onSignOut:n,user:{name:e,role:`Administrator`},settings:{items:i.map(([e,t])=>({href:`#${e}`,label:t,current:o===e})),current:i.some(([e])=>e===o)},nav:(0,$.jsx)($.Fragment,{children:pp.map(([e,t,n])=>c(e,t,n))}),children:[(0,$.jsxs)(`section`,{className:`page-view admin-view`,hidden:!i.some(([e])=>e===o),"aria-labelledby":`settings-heading`,children:[(0,$.jsx)(`header`,{className:`ky-page-head`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{id:`settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,$.jsx)(`p`,{className:`ky-page-lede`,children:t?`How KyNotes looks in this browser.`:`Your administrator password, and how KyNotes looks in this browser.`})]})}),(0,$.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:i.map(([e,t])=>(0,$.jsx)(`a`,{className:`ky-nav-item`,href:`#${e}`,"aria-current":o===e?`page`:void 0,children:t},e))}),!t&&(0,$.jsx)(`div`,{id:`account`,hidden:o!==`account`,children:r}),(0,$.jsx)(`div`,{id:`appearance`,hidden:o!==`appearance`,children:(0,$.jsx)(Yf,{})})]}),pp.map(([t,n,,r])=>(0,$.jsxs)(`section`,{id:t,className:`page-view admin-view`,hidden:o!==t,"aria-labelledby":`${t}-heading`,children:[(0,$.jsxs)(`header`,{className:`ky-page-head`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{id:`${t}-heading`,className:`ky-page-title`,children:n}),(0,$.jsx)(`p`,{className:`ky-page-lede`,children:r})]}),t===`users`&&(0,$.jsx)(vp,{username:e,onCreated:()=>void ou().then(f)})]}),t===`users`&&(0,$.jsx)(bp,{username:e,users:d,onChange:e=>f(t=>t.map(t=>t.id===e.id?e:t))}),t===`teams`&&(0,$.jsx)(xp,{users:d,username:e}),t===`sso`&&(0,$.jsx)(Sp,{username:e}),t===`backups`&&(0,$.jsx)(af,{username:e}),t===`audit`&&(0,$.jsx)(`div`,{className:`audit-log`,children:p.length===0?(0,$.jsx)(`p`,{className:`config-muted`,children:`No audit events recorded.`}):p.map((e,t)=>(0,$.jsxs)(`div`,{className:`audit-row`,children:[(0,$.jsx)(`strong`,{children:e.event}),(0,$.jsxs)(`span`,{children:[e.outcome,` · `,e.at]})]},`${e.at}-${t}`))}),t===`server`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{role:`note`,className:`admin-note`,children:`This is an administrator account. It manages KyNotes and cannot open notes. Sign in with your everyday account to write.`}),(0,$.jsxs)(`dl`,{className:`status-list`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Health`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(gp,{ok:l?.health})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{children:`Readiness`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(gp,{ok:l?.ready})})]})]}),(0,$.jsx)(lf,{username:e})]})]},t))]})}var gp=({ok:e})=>(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":e===void 0?void 0:e?`success`:`danger`,children:e===void 0?`Checking…`:e?`OK`:`Failed`}),_p=e=>t=>{t instanceof Error&&t.message===`Password confirmation cancelled`||alert(t instanceof Error?t.message:e)};function vp({username:e,onCreated:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`user`),[l,u]=(0,X.useState)(!1);async function d(c){c.preventDefault(),u(!0);try{let c=ft(),l=await dt(a,c,6e5);await tf(e,()=>du({username:r,authSecret:l,loginSalt:c,iterations:6e5,accountKind:s})),i(``),o(``),n.current?.close(),t()}catch(e){_p(`Unable to create user`)(e)}finally{u(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`ky-page-action`,onClick:()=>n.current?.showModal(),children:[(0,$.jsx)(df,{name:`plus`}),`Create user`]}),(0,$.jsx)(`dialog`,{ref:n,className:`ky-dialog`,"aria-labelledby":`create-user-heading`,children:(0,$.jsxs)(`form`,{onSubmit:d,children:[(0,$.jsx)(`h2`,{id:`create-user-heading`,children:`Create user`}),(0,$.jsxs)(`label`,{children:[`Username`,(0,$.jsx)(`input`,{autoComplete:`off`,value:r,onChange:e=>i(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Temporary password`,(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Account type`,(0,$.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,$.jsx)(`option`,{value:`user`,children:`Everyday`}),(0,$.jsx)(`option`,{value:`admin`,children:`Administrator`})]})]}),(0,$.jsx)(`p`,{className:`dialog-hint`,children:`They choose their own password at first sign-in.`}),(0,$.jsxs)(`div`,{className:`dialog-actions`,children:[(0,$.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>n.current?.close(),children:`Cancel`}),(0,$.jsx)(`button`,{disabled:l,children:l?`Creating…`:`Create user`})]})]})})]})}var yp=`Password reset. All existing sessions and paired device credentials were revoked. The account keeps its encryption key: after changing the temporary password, the user gets it back from a browser that holds it or with their recovery code (an account linked to KySignOn gets no password copy back). With neither, they can reset it themselves, and their personal notebooks are lost. If a browser holding the key was lost or stolen, ask the user to reset their encryption key in Settings: this reset does not cut that browser off.`;function bp({username:e,users:t,onChange:n}){let r=e=>document.getElementById(e)?.hidePopover();async function i(t){try{await tf(e,()=>mu(t)),n(t)}catch(e){_p(`Unable to update user`)(e)}}async function a(t){let n=prompt(`New temporary password for ${t.username}`);if(n)try{let r=ft(),i=await dt(n,r,6e5);await tf(e,()=>fu(t.id,{newAuthSecret:i,newLoginSalt:r,iterations:6e5})),alert(yp)}catch(e){_p(`Unable to reset password`)(e)}}return(0,$.jsxs)(`table`,{className:`data-table`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{scope:`col`,children:`Account`}),(0,$.jsx)(`th`,{scope:`col`,children:`Role`}),(0,$.jsx)(`th`,{scope:`col`,children:`Status`}),(0,$.jsx)(`th`,{scope:`col`,children:(0,$.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,$.jsx)(`tbody`,{children:t.map((e,t)=>{let n=`user-menu-${t}`,o=e.status===`active`;return(0,$.jsxs)(`tr`,{className:`admin-user`,children:[(0,$.jsx)(`th`,{scope:`row`,children:e.username}),(0,$.jsx)(`td`,{children:e.accountKind===`admin`?e.role===`admin`?`Administrator`:`Administrator, grant revoked`:`Everyday`}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":o?`success`:void 0,children:o?`Active`:`Disabled`})}),(0,$.jsxs)(`td`,{className:`row-actions`,children:[(0,$.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:n,"aria-label":`Actions for ${e.username}`,style:{anchorName:`--${n}`},children:(0,$.jsx)(df,{name:`more`})}),(0,$.jsxs)(`div`,{className:`section-menu anchored-menu row-menu`,id:n,popover:`auto`,style:{positionAnchor:`--${n}`},children:[(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>{r(n),a(e)},children:`Reset password`}),e.accountKind===`admin`&&(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>{r(n),i({...e,role:e.role===`admin`?`user`:`admin`})},children:e.role===`admin`?`Revoke administrator grant`:`Restore administrator grant`}),(0,$.jsx)(`button`,{className:o?`quiet danger`:`quiet`,onClick:()=>{r(n),i({...e,status:o?`disabled`:`active`})},children:o?`Disable account`:`Enable account`})]})]})]},e.id)})})]})}function xp({users:e,username:t}){let[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(`editor`),f=e.filter(e=>e.status===`active`&&e.accountKind===`user`);async function p(){try{r(await cu())}catch{}}(0,X.useEffect)(()=>{p()},[]);async function m(){if(i)try{s((await tf(t,()=>lu(i))).id),await p()}catch(e){_p(`Unable to create team`)(e)}}async function h(){if(o&&c)try{await tf(t,()=>pu(o,c,u)),alert(`Person added. They get the team's keys once one of its owners approves them.`),await p()}catch(e){_p(`Unable to add person`)(e)}}return(0,$.jsxs)(`div`,{className:`admin-panel`,children:[(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Owner`}),(0,$.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select owner`}),f.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,$.jsx)(`button`,{disabled:!i,onClick:()=>void m(),children:`Create team`}),(0,$.jsx)(`ul`,{className:`admin-teams`,children:n.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`code`,{children:e.id}),` · owner `,e.ownerUsername,` · `,e.memberCount,` `,e.memberCount===1?`member`:`members`,` · `,e.named?`named`:`not named yet`,` · `,e.keyed?`keyed`:`waiting for its owner`]},e.id))}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Team`}),(0,$.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select team`}),n.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.ownerUsername]},e.id))]})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Person`}),(0,$.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select person`}),f.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Role`}),(0,$.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,$.jsx)(`option`,{children:`editor`}),(0,$.jsx)(`option`,{children:`commenter`}),(0,$.jsx)(`option`,{children:`viewer`})]})]}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>void h(),children:`Add to team`})]})}function Sp({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null);(0,X.useEffect)(()=>{ql().then(n).catch(()=>{})},[]);async function d(t){if(t.preventDefault(),r.trim()&&a.trim()){c(!0),u(null);try{let t=await tf(e,()=>Yl(a.trim(),r.trim()));n(t.settings),i(``),u({text:`Successfully paired with KySignOn (System ID: ${t.systemId})!`,type:`success`})}catch(e){u({text:e instanceof Error?e.message:`Pairing failed`,type:`error`})}finally{c(!1)}}}async function f(r){if(r.preventDefault(),t){c(!0),u(null);try{let r=await tf(e,()=>Jl(t));n(r),u({text:`Single Sign-On settings saved successfully.`,type:`success`})}catch(e){u({text:e instanceof Error?e.message:`Unable to save SSO settings`,type:`error`})}finally{c(!1)}}}return t?(0,$.jsxs)(`div`,{className:`admin-panel`,children:[l&&(0,$.jsx)(`p`,{className:l.type===`error`?`error`:`status-line`,style:{margin:`14px 0`},children:l.text}),(0,$.jsxs)(`div`,{style:{background:`var(--accent-soft)`,padding:`16px`,borderRadius:`4px`,margin:`18px 0`},children:[(0,$.jsx)(`h3`,{style:{margin:`0 0 8px`,fontSize:`14px`,font:`12px Mono, monospace`,letterSpacing:`.1em`,textTransform:`uppercase`},children:`Quick Pair with KySignOn`}),(0,$.jsx)(`p`,{className:`config-muted`,style:{margin:`0 0 14px`,fontSize:`13px`},children:`Generate a 90-second system pairing token in KySignOn Admin Dashboard to pair KyNotes automatically.`}),(0,$.jsxs)(`form`,{onSubmit:d,style:{display:`grid`,gap:`12px`},children:[(0,$.jsxs)(`label`,{className:`field`,style:{marginTop:0},children:[(0,$.jsx)(`span`,{children:`KySignOn Issuer URL`}),(0,$.jsx)(`input`,{placeholder:`http://localhost:5867 or https://auth.example.com`,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{className:`field`,style:{marginTop:0},children:[(0,$.jsx)(`span`,{children:`90-Second Pairing Token`}),(0,$.jsx)(`input`,{placeholder:`Enter pairing token from KySignOn UI`,value:r,onChange:e=>i(e.target.value),required:!0})]}),(0,$.jsx)(`button`,{disabled:s,style:{width:`fit-content`},children:s?`Pairing…`:`Pair with KySignOn`})]})]}),(0,$.jsxs)(`form`,{onSubmit:f,style:{marginTop:`24px`},children:[(0,$.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`},children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:e=>n({...t,enabled:e.target.checked}),style:{width:`18px`,height:`18px`}}),(0,$.jsx)(`strong`,{style:{fontSize:`14px`},children:`Enable OpenID Connect / Single Sign-On`})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`OIDC Issuer URL`}),(0,$.jsx)(`input`,{value:t.issuerUrl,onChange:e=>n({...t,issuerUrl:e.target.value}),placeholder:`https://auth.example.com`})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Client ID`}),(0,$.jsx)(`input`,{value:t.clientId,onChange:e=>n({...t,clientId:e.target.value}),placeholder:`kynotes`})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:t.clientSecretSet?`Client Secret: set. Enter a new one only to replace it`:`Client Secret (Optional for PKCE)`}),(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:t.clientSecret??``,onChange:e=>n({...t,clientSecret:e.target.value}),placeholder:t.clientSecretSet?`Leave empty to keep the current secret`:``})]}),t.clientSecretSet&&(0,$.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.clearClientSecret??!1,onChange:e=>n({...t,clearClientSecret:e.target.checked})}),(0,$.jsx)(`span`,{children:`Remove the client secret`})]}),(0,$.jsxs)(`p`,{className:`config-muted`,children:[`Directory sync secret: `,t.hmacSecretSet?`set`:`not set`]}),t.hmacSecretSet&&(0,$.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.clearHmacSecret??!1,onChange:e=>n({...t,clearHmacSecret:e.target.checked})}),(0,$.jsx)(`span`,{children:`Remove the directory sync secret (turns directory sync off)`})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Custom Redirect URI (Optional override)`}),(0,$.jsx)(`input`,{value:t.redirectUri??``,onChange:e=>n({...t,redirectUri:e.target.value}),placeholder:`https://notes.example.com/api/v1/auth/oidc/callback`})]}),(0,$.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,marginTop:`16px`,cursor:`pointer`},children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.autoProvision,onChange:e=>n({...t,autoProvision:e.target.checked}),style:{width:`18px`,height:`18px`}}),(0,$.jsx)(`span`,{style:{fontSize:`13px`},children:`Auto-provision new user accounts on first SSO login`})]}),(0,$.jsx)(`button`,{disabled:s,style:{marginTop:`20px`},children:s?`Saving…`:`Save SSO Settings`})]})]}):(0,$.jsx)(`p`,{className:`config-muted`,children:`Loading Single Sign-On configuration…`})}function Cp(e){let t=e.admin.trim().toLowerCase(),n=e.everyday.trim().toLowerCase();if(!t||!n)return`Both usernames are required.`;if(t===n)return`Use a different username for each account.`;if(e.adminPassword!==e.adminConfirm||e.everydayPassword!==e.everydayConfirm)return`Passwords do not match.`;if(e.adminPassword.length<8||e.everydayPassword.length<8)return`Passwords must be at least 8 characters.`;if(e.adminPassword===e.everydayPassword)return`Use a different password for each account.`}function wp(e,t,n){let r=URL.createObjectURL(typeof t==`string`?new Blob([t],{type:n}):t),i=document.createElement(`a`);i.href=r,i.download=e,document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}var Tp=`kynotes/link/v2`,Ep=`kynotes/link-commit/v1`,Dp=`kynotes/link-check/v1`,Op=2,kp=new TextEncoder;function Ap(e){if(e.length!==32)throw Error(`invalid link key`);return e}var jp=new WeakSet;function Mp(){let e=wc();return jp.add(e),e}function Np(e){e.privateKey.fill(0),jp.delete(e)}var Pp=e=>jp.has(e),Fp=e=>z(Sc(kp.encode(Ep),Ap(e)));function Ip(e,t,n,r){let i=z(Sc(kp.encode(Dp),xc(`usr`,e),xc(`lnk`,t),Ap(n),Ap(r))),a=String(new DataView(i.buffer,i.byteOffset,4).getUint32(0)%1e6).padStart(6,`0`);return`${a.slice(0,3)} ${a.slice(3)}`}var Lp=e=>Sc(kp.encode(Tp),xc(`usr`,e.userID),xc(`lnk`,e.requestID),xc(`dev`,e.identityDeviceID),Ap(e.approverKey),Ap(e.newcomerKey));async function Rp(e,t,n,r){if(e.length!==32||!Cc(t.publicKey,n.approverKey))throw Error(`invalid link input`);let i={recipientPublicKey:await bc.kem.deserializePublicKey(Ap(n.newcomerKey)),senderKey:await Dc(t.privateKey),info:Lp(n)},{enc:a,ct:o}=await bc.seal(r?{...i,ekm:r}:i,e);return Sc(Uint8Array.of(Op),new Uint8Array(a),new Uint8Array(o))}var zp=(e,t,n)=>Rp(e,t,n),Bp=e=>Error(`link bundle refused: ${e}`);async function Vp(e,t,n){if(e.length!==81||e[0]!==Op||n.approverKey.length!==32)throw Bp(`format`);if(!Cc(t.publicKey,n.newcomerKey))throw Bp(`newcomer-key`);try{ni.getSharedSecret(t.privateKey,n.approverKey)}catch{throw Bp(`low-order`)}try{return new Uint8Array(await bc.open({recipientKey:await Dc(t.privateKey),senderPublicKey:await bc.kem.deserializePublicKey(n.approverKey),enc:e.subarray(1,33),info:Lp(n)},e.subarray(33)))}catch{throw Bp(`aead`)}}var Hp=new WeakSet,Up;(class e{requestID;code;static{Up=(t,n)=>{let r=new e(t,n);return Object.freeze(r),Hp.add(r),r}}constructor(e,t){this.requestID=e,this.code=t}});var Wp=(e,t)=>Up(e,t),Gp=(e,t)=>typeof e==`object`&&!!e&&Hp.has(e)&&e.requestID===t,Kp=new WeakSet,qp=e=>e.normalize(`NFKC`).replace(/\s/g,``);function Jp(e,t,n){if(!t||qp(n)!==qp(t))throw Error(`That is not the code the other browser shows. Type it again; if the codes differ, cancel.`);let r=Up(e,t);return Kp.add(r),r}var Yp=(e,t)=>Gp(e,t)&&Kp.has(e),Xp={},Zp=(e,t)=>({...e,shared:Math.max(e.shared??0,t.sharedGeneration),generation:Math.max(e.generation??0,t.keyGeneration)}),Qp=(e,t)=>({shared:Math.max(e?.shared??0,t.shared??0),generation:Math.max(e?.generation??0,t.generation??0)});function $p(e,t){let n=t.shared??0,r=t.generation??0;return{container:{...e,sharedGeneration:Math.max(e.sharedGeneration,n),keyGeneration:Math.max(e.keyGeneration,r)},rollback:e.sharedGeneratione===`owner`||e===`admin`;async function nm(e){let{containerID:t,envelopes:n,me:r,members:i,pins:a}=e,o=new Map,s={...e.known,mark:Math.max(0,e.known.mark),digests:{...e.known.digests}},c={ring:o,pins:{...a},fresh:[],changed:[],conflicts:[],known:s},l=Object.values(a).flatMap(e=>{try{return[ri(e)]}catch{return[]}}),u=(e,t)=>{let n=zi(z(t)),r=o.get(e);return(r?zi(z(r))===n:(s.digests[e]??n)===n)?(o.set(e,r??t),s.digests[e]??=n,!0):(c.conflicts.includes(e)||c.conflicts.push(e),!1)};for(let[t,n]of e.held??[])u(t,n);if(!r)return c;let d=async(e,n,i,a)=>{try{return _t(await jc(e,n,r.privateKey,t,i,r.deviceId,a))}catch{return}},f=[];for(let e of n)if(!(e.deviceId!==r.deviceId||e.alg!==`hpke-auth-x25519-hkdfsha256-chacha20poly1305`&&e.alg!==`x25519-hkdf-sha256-chacha20poly1305`))try{let t=$e(e.envelope),n=Ac(e.alg,t),a=n===r.deviceId,o=a?void 0:i.find(e=>e.identity?.deviceId===n);if(o?.userId===r.userId)continue;let l=o&&tm(o.role)?o:void 0,p=l&&c.pins[l.userId],m=a||l&&(p===void 0||ai(p,l.identity.publicKey));l&&!m&&!c.changed.some(e=>e.member.userId===l.userId)&&c.changed.push({member:l,pinned:p});let h=m?await d(e.alg,t,e.keyGeneration,a?r.publicKey:ri(l.identity.publicKey)):void 0;if(!h){f.push({alg:e.alg,envelope:t,generation:e.keyGeneration});continue}if(!u(e.keyGeneration,h))continue;s.mark=Math.max(s.mark,e.keyGeneration),l&&p===void 0&&(c.pins[l.userId]=l.identity.publicKey,c.fresh.push(l))}catch{}for(let{alg:e,envelope:t,generation:n}of f)if(!(n>=s.mark))for(let r of l){let i=await d(e,t,n,r);if(i){u(n,i);break}}return c}function rm(e,t,n){let{container:r,rollback:i}=$p(e,n);if(i||r.sharedGeneration===0)return;let a=t.get(r.keyGeneration);return a&&{key:a,generation:r.keyGeneration}}var im=e=>_t(qe(e.privateKey,32,new Uint8Array,new TextEncoder().encode(`kynotes/waiting/v1`))),am=e=>qe(e.privateKey,32,new Uint8Array,new TextEncoder().encode(`kynotes/reminder-id/v1`));function om(e,t,n,r){let i=Math.max(e.sharedGeneration,r.shared??0);if(i===0||n===void 0||!Number.isInteger(n)||nn===0?i?[i]:[]:om(e,t,n,r);async function cm(e,t){let n=Error(`no content key`);for(let r of e)try{return await t(r)}catch(e){n=e}throw n}function lm(e){let{container:t,me:n,members:r,envelopes:i,ring:a}=e,o=r.find(e=>e.userId===n);if(!o?.identity||!tm(o.role))return{kind:`idle`};let s=r.filter(e=>e.identity&&e.approved!==!1);if(t.sharedGeneration===0)return e.recoverable?{kind:`mint`,recipients:s}:{kind:`unrecoverable`};if(!i.some(e=>e.keyGeneration===t.keyGeneration))return{kind:`mint`,recipients:s};let c=new Set(i.map(e=>`${e.deviceId}:${e.keyGeneration}`)),l=s.flatMap(e=>[...a.keys()].filter(e=>e>=t.sharedGeneration&&e<=t.keyGeneration).filter(t=>!c.has(`${e.identity.deviceId}:${t}`)).map(t=>({member:e,generation:t})));return l.length?{kind:`wrap`,grants:l}:{kind:`idle`}}async function um(e,t,n,r,i,a){let o=e.identity,s=ri(o.publicKey),c=a,l=[];if(e.userId===i.userId){if(o.deviceId!==i.deviceId||!ai(o.publicKey,Qe(i.publicKey)))throw Error(`own identity mismatch`)}else if(a[e.userId]===void 0)c={...a,[e.userId]:o.publicKey},l=[e];else if(!ai(a[e.userId],o.publicKey))throw new oi(e,a[e.userId]);let u=Qe(await kc(r,s,t,n,o.deviceId,i));return{envelope:{deviceId:o.deviceId,keyGeneration:n,alg:pc,envelope:u},pins:c,fresh:l}}var dm=()=>_t(Yi(32));function fm(e,t,n){let r=new Set(n.filter(t=>t.keyGeneration===e.keyGeneration).map(e=>e.deviceId));return Object.fromEntries(t.flatMap(t=>t.approved===!1?[[t.userId,`unapproved`]]:t.identity?e.sharedGeneration===0?[]:[[t.userId,r.has(t.identity.deviceId)?`has-key`:`waiting`]]:[[t.userId,`no-identity`]]))}function pm(e,t,n){return!n||!e?`wait`:t===n.generation?`send`:`reseal`}async function mm(e,t,n,r,i,a){let o=pm(n,e.keyGeneration,r);if(o===`wait`)return;let s=await cm(sm(t,i,e.keyGeneration,n,a),t=>Mt(t,e.containerID,e.id,e.payload,!0));if(o===`send`&&!s.v1)return e;if(s.payload)return{...e,payload:await jt(r.key,e.containerID,e.id,s.payload),keyGeneration:r.generation}}async function hm(e,t,n,r,i){return{payload:await kt(e.key,t,n,r),metadataCiphertext:Qe(await Dt(e.key,t,n,i)),keyGeneration:e.generation}}async function gm(e,t,n,r,i,a){let o=pm(n,e.keyGeneration,r);if(o===`wait`)return{kind:o};let s=sm(t,i,e.keyGeneration,n,a);return o===`send`&&await cm(s,t=>Ot(t,e.containerID,e.objectID,$e(e.metadataCiphertext),!1)).then(()=>!0,()=>!1)?{kind:`send`}:{kind:`reseal`,plaintext:await cm(s,t=>At(t,e.containerID,e.objectID,e.payload,!0)),file:await cm(s,t=>Ot(t,e.containerID,e.objectID,$e(e.metadataCiphertext),!0))}}var _m=`Not saved: neither the server nor this browser kept this edit. It exists only in this tab; keep the tab open and copy the edit.`,vm=()=>{throw Error(_m)},ym=e=>e?`This note changed on another device, and this browser could not keep a local copy of your edit. It exists only in this tab: copy or export it now, before closing or reloading.`:`This note changed on another device. Your encrypted draft is preserved locally; review the conflict before saving again.`,bm={},xm={},Sm=new Set,Cm=()=>{for(let e of Sm)e()},wm=(e,t)=>{let n=xm[e];n&&delete xm[e],bm={...bm,[e]:Qp(Qp(bm[e],t),n??{})},Cm()},Tm=typeof BroadcastChannel>`u`?null:new BroadcastChannel(`kynotes-floors`),Em=/^cnt_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,Dm=e=>Number.isSafeInteger(e)&&e>=0;Tm&&(Tm.onmessage=e=>{let{containerID:t,shared:n,generation:r}=e.data??{};typeof t==`string`&&Em.test(t)&&Dm(n)&&Dm(r)&&(bm[t]?wm(t,{shared:n,generation:r}):xm[t]=Qp(xm[t],{shared:n,generation:r}))});var Om=e=>bm[e];function km(e,t){wm(e,t);let{shared:n=0,generation:r=0}=bm[e];Tm?.postMessage({containerID:e,shared:n,generation:r})}function Am(e,t,n){(n||bm[e])&&km(e,t)}function jm(){bm={},xm={},Cm()}var Mm=e=>(Sm.add(e),()=>{Sm.delete(e)}),Nm=()=>(0,X.useSyncExternalStore)(Mm,()=>bm),Pm=class extends Error{constructor(){super(`This notebook's keys changed or are not shared yet; the change stays on this device until they are.`),this.name=`KeysWaitingError`}},Fm;function Im(e){return Fm=e,()=>{Fm===e&&(Fm=void 0)}}function Lm(e){let t=Fm?.(e.container);if(pm(Om(e.container.id),e.generation,t)!==`send`)throw new Pm}var Rm=async(e,t,n,r)=>{let i=`${t}:${r}:${e.generation}:${await nt(n)}`;return Lm(e),Xu(t,n,r,e.generation,i)},zm=(e,t,n)=>(Lm(e),iu(e.container.id,t,n,e.generation)),Bm=(e,t,n,r)=>(Lm(e),Ku(t,n,e.generation,r)),Vm=(e,t,n)=>(Lm(e),Zu(e.container.id,t,n)),Hm=(e,t,n,r)=>(Lm(e),ed(t,n,r)),Um=(e,t,n)=>(Lm(e),td(t,n,e.generation));function Wm(e,t,n){if(!Yp(e,t))throw Error(`Compare the check codes on both screens first.`);return ku(t,Qe(n))}function Gm(e,t){if(!Pp(e))throw Error(`This link attempt ended. Start again on both browsers.`);return Au(t)}var Km=class extends Error{constructor(){super(`This browser cannot keep an encryption key (site storage is blocked or unavailable), so it cannot be linked.`),this.name=`LinkStorageError`}},qm=class extends Error{constructor(){super(`The other browser's key changed while linking. Nothing was linked; start again on both browsers.`),this.name=`LinkTamperedError`}},Jm=class extends Error{constructor(){super(`This link attempt ended. Nothing was linked; start again on both browsers.`),this.name=`LinkEndedError`}},Ym=class extends Error{constructor(){super(`Your account has no encryption key yet, so there is nothing to link. Set one up first, or link this browser from one that holds it.`),this.name=`LinkNoIdentityError`}},Xm=e=>Np(e.key);function Zm(e,t){if(!Pp(e.key))throw new Jm;if(t!==e.userID)throw Xm(e),Error(`The signed-in account changed while linking. Nothing was linked; start again on both browsers.`)}async function Qm(e,t){try{return await t()}catch(t){throw Xm(e),t}}var $m=new WeakMap,eh=`This browser holds another copy of your key. Use Forget this device first.`;async function th(e,t){let n=await t.load();if(!n)return!1;let r=await e.myIdentity();return!r||!Cc(n.publicKey,ri(r.publicKey))}async function nh(e,t,n){if(!await t())throw new Km;let r=Mp(),{id:i,expiresAt:a}=await Qm({id:``,userID:n,key:r},()=>e.create(Qe(Fp(r.publicKey)))).catch(e=>{throw e instanceof Z&&e.code===`not_found`?new Ym:e});return{id:i,userID:n,key:r,expiresAt:a}}async function rh(e,t,n){Zm(t,n);let r=await e.collect(t.key,t.id),i=$m.get(t.key.privateKey);if(i){if(r.approverKey&&!Cc(ri(r.approverKey),i.approverKey))throw Xm(t),new qm;return{link:{...t,...i},bundle:r.bundle?$e(r.bundle):void 0}}if(!r.approverKey)return{link:t};let a=await Qm(t,async()=>{let n=ri(r.approverKey),i={approverKey:n,code:Ip(t.userID,t.id,n,t.key.publicKey)};return $m.set(t.key.privateKey,i),await e.reveal(t.id,Qe(t.key.publicKey)),i});return{link:{...t,...a}}}var ih=4e3,ah=3e4,oh=6e5,sh=e=>e instanceof Z&&e.status===429||e instanceof TypeError,ch=e=>new Promise(t=>setTimeout(t,e));async function lh(e,t,n,r,i,a=ch,o=Date.now){let s=ih,c;for(;;){if(await a(s),!r())return;try{let a=await rh(e,t,n);if(!r())return;if(i(a.link),a.bundle)return a.bundle;s=ih,c=void 0}catch(e){if(!sh(e)||!Pp(t.key))throw e;if(c??=o(),o()-c>=oh)throw Xm(t),new Jm;s=Math.min(s*2,ah)}}}async function uh(e,t,n,r,i,a){Zm(e,r);let o=$m.get(e.key.privateKey);if(!o||!Gp(n,e.id)||n.code!==o.code)throw Error(`Compare the check codes on both screens first.`);try{let n=await i.myIdentity();if(!n)throw Error(`Your account has no encryption key to link.`);let r=await Vp(t,e.key,{userID:e.userID,requestID:e.id,identityDeviceID:n.deviceId,approverKey:o.approverKey,newcomerKey:e.key.publicKey}),s=ni.getPublicKey(r);if(!Cc(s,ri(n.publicKey)))throw Error(`The key sent is not your account's encryption key. Nothing was linked.`);let c={deviceId:n.deviceId,publicKey:s,privateKey:r},l=await a.load();if(l&&!Cc(l.publicKey,s))throw Error(eh);if(l?.deviceId===c.deviceId)return l;if(!await a.save(c,l??null))throw new Km;return c}finally{Xm(e)}}async function dh(e,t,n){let r=$e(t.commitment);if(r.length!==32)throw new qm;let i={id:t.id,userID:n,key:Mp(),commitment:r};return await Qm(i,()=>e.claim(t.id,Qe(i.key.publicKey))),i}function fh(e,t,n){if(Zm(e,n),e.newcomerKey||t?.id!==e.id||!t.newcomerKey)return e;let r;try{r=ri(t.newcomerKey)}catch{r=new Uint8Array}if(r.length!==32||!Cc(Fp(r),e.commitment))throw Xm(e),new qm;return{...e,newcomerKey:r,code:Ip(e.userID,e.id,e.key.publicKey,r)}}var ph=(e,t)=>Jp(e.id,e.code??``,t);async function mh(e,t,n,r,i,a=Wm){if(Zm(e,r),!e.newcomerKey||!e.code)throw Error(`The other browser has not answered yet.`);if(!Yp(t,e.id)||t.code!==e.code)throw Error(`Type the code the other browser shows first.`);let o=await zp(n.privateKey,e.key,{userID:e.userID,requestID:e.id,identityDeviceID:n.deviceId,approverKey:e.key.publicKey,newcomerKey:e.newcomerKey});await i(),await a(t,e.id,o),Xm(e)}async function hh(e,t,n){let r=await e;if(t())return r;Xm(r),await n(r.id).catch(()=>void 0)}function gh(e,t=`link a browser`){let n=e instanceof Z?e.code:void 0;if(n===`step_up_pending`){let t=e.challenge;return{message:`A KySignOn confirmation is still open for this account. Finish it in its window, or cancel it and try again.`,cancel:t?()=>Mu(t):void 0}}return n===`sso_sign_in_required`?{message:`Sign in with KySignOn to continue. This session signed in with a password an administrator set, so it cannot ${t}.`}:n===`password_change_required`?{message:`An administrator set this account's password. Change your password before you ${t}.`}:{message:e instanceof Error?e.message:`Linking failed.`}}var _h=`pbkdf2-sha256-600000/aes-256-gcm`,vh=16,yh=16,bh=12,xh=28,Sh=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,Ch=`kynotes/recovery-code/v1`,wh=`kynotes/identity-recovery/v1`,Th=new TextEncoder,Eh=`Check the recovery code: a character is wrong or missing.`,Dh=`This recovery code does not open your key. Check it and try again.`,Oh=`Your account has no recovery code. Link this browser from one that holds your key, or reset your encryption key.`,kh=class extends Error{constructor(e=Eh){super(e),this.name=`RecoveryCodeError`}},Ah=e=>{let t=z(Sc(Th.encode(Ch),e));return BigInt(t[0]<<2|t[1]>>6)};function jh(e){if(e.length!==vh)throw Error(`invalid recovery secret`);let t=e.reduce((e,t)=>e<<8n|BigInt(t),0n)<<10n|Ah(e),n=[];for(let e=0;e>=5n;return n.join(``).match(/.{4}/g).join(`-`)}function Mh(e){let t=e.normalize(`NFKC`).toUpperCase().replace(/[\s-]/g,``).replace(/[IL]/g,`1`).replace(/O/g,`0`);if(t.length!==xh)throw new kh;let n=0n;for(let e of t){let t=Sh.indexOf(e);if(t<0)throw new kh;n=n<<5n|BigInt(t)}if(n>>138n)throw new kh;let r=new Uint8Array(vh),i=n>>10n;for(let e=15;e>=0;e--)r[e]=Number(i&255n),i>>=8n;if(Ah(r)!==(n&1023n))throw new kh;return r}function Nh(){let e=Yi(vh);return{code:jh(e),secret:e}}var Ph=e=>{try{return ri(e)}catch{return}},Fh=(e,t)=>Sc(Th.encode(wh),xc(`usr`,e),t);async function Ih(e,t,n,r,i){if(e.length!==vh||t.length!==32||r.length!==yh||i.length!==bh)throw Error(`invalid recovery input`);let a=await st(e,r);try{return Sc(r,i,wa(a,i,Fh(n,ni.getPublicKey(t))).encrypt(t))}finally{a.fill(0)}}var Lh=(e,t,n)=>Ih(e,t.privateKey,n,Yi(yh),Yi(bh));async function Rh(e,t,n,r){let i=Ph(r.publicKey);if(!i||r.wrapAlg!==`pbkdf2-sha256-600000/aes-256-gcm`||t.length!==76||e.length!==vh)throw new kh(Dh);let a=await st(e,t.subarray(0,yh)),o;try{o=wa(a,t.subarray(yh,28),Fh(n,i)).decrypt(t.subarray(28))}catch{throw new kh(Dh)}finally{a.fill(0)}if(!Cc(ni.getPublicKey(o),i))throw o.fill(0),new kh(Dh);return{deviceId:r.deviceId,publicKey:i,privateKey:o}}var zh=`Type the asked group of your saved recovery code first.`,Bh=`Your recovery code was changed in another tab or browser, so this one was not saved. Make a new code here only if you no longer have that one.`,Vh=`The server's recovery copy is not for your account's current key. Reload and try again.`,Hh=`This recovery code was saved by a newer version of KyNotes. Update this browser's page and try again.`,Uh=`Too many attempts. Wait a few minutes and try again.`,Wh=`reset your encryption key`,Gh=`Too many key resets. Each reset makes your teams wait for a new key, so an account can reset at most 3 times a day. Try again later.`,Kh=`RESET`;`${Kh}`;var qh=`Type ${Kh} to confirm the reset.`,Jh=e=>e?.trim()===Kh,Yh=e=>`Type group ${e} of 7 from your saved copy`,Xh=`The connection failed, so this browser cannot tell whether the reset finished. Keep the code you saved and try again: the retry sends the same new key.`,Zh=class extends Error{cause;constructor(e){super(Xh),this.cause=e,this.name=`ResetUncertainError`}},Qh=class extends Error{live;code=`already_exists`;constructor(e){super(Bh),this.live=e,this.name=`RecoveryMovedError`}},$h=new WeakSet;function eg(e){for(;;){let t=Yi(1)[0];if(t>=252)continue;let n=t%7+1;if(n!==e)return n}}async function tg(e,t){let{code:n,secret:r}=Nh();try{return Object.freeze({code:n,check:eg(),identity:e,userID:t,wrappedKey:Qe(await Lh(r,e,t))})}finally{r.fill(0)}}var ng=e=>Object.freeze({...e,check:eg(e.check)});function rg(e,t){let n=(e=>e.normalize(`NFKC`).toUpperCase().replace(/[\s-]/g,``).replace(/[IL]/g,`1`).replace(/O/g,`0`))(t)===e.code.split(`-`)[e.check-1];return n&&$h.add(e),n}var ig=e=>e instanceof Z&&e.code===`already_exists`;async function ag(e,t,n,r){if(!$h.has(t))throw Error(zh);if(!Cc(t.identity.publicKey,n.publicKey))throw Error(`This recovery code was made for another key. Start again.`);try{let{recoveryId:i}=await e.putRecovery({deviceId:n.deviceId,expectedRecoveryId:r,wrapAlg:_h,wrappedKey:t.wrappedKey});return $h.delete(t),i}catch(n){throw ig(n)?($h.delete(t),new Qh(await e.myIdentity().catch(()=>void 0))):n}}async function og(e,t,n,r,i){let a=Mh(r);try{let r=await t.load(),o=await e.myIdentity(),s=o&&Ph(o.publicKey);if(!o||!s)throw Error(Oh);if(r&&!Cc(r.publicKey,s))throw Error(eh);if(r?.deviceId===o.deviceId)return r;await i();let c=await e.fetchRecovery();if(!c)throw Error(Oh);if(c.wrapAlg!==`pbkdf2-sha256-600000/aes-256-gcm`)throw Error(Hh);if(o.deviceId!==c.deviceId||!Cc(s,Ph(c.publicKey)??new Uint8Array))throw new kh(Vh);let l;try{l=$e(c.wrappedKey)}catch{throw new kh(Dh)}let u=await Rh(a,l,n,{deviceId:o.deviceId,publicKey:o.publicKey,wrapAlg:c.wrapAlg}),d=!1;try{if(await t.save(u,r??null))return d=!0,u;let e=await t.load();if(e&&Cc(e.publicKey,u.publicKey))return e;throw e?Error(eh):new Km}finally{d||u.privateKey.fill(0)}}finally{a.fill(0)}}async function sg(e,t,n,r,i,a){if(!Jh(i))throw Error(qh);if(!$h.has(n))throw Error(zh);let o={wrapAlg:Nd};a&&(await a.stepUp(a.keys.authSecret),o={wrapAlg:mc,wrappedPrivateKey:Qe(Fc(a.keys.userKEK,n.identity.privateKey,n.userID))});let s;await t.noteReset?.(n.identity.publicKey).catch(()=>void 0);let c=t=>e.replaceIdentity({publicKey:Qe(n.identity.publicKey),...t,expectedDeviceId:r,recovery:{wrapAlg:_h,wrappedKey:n.wrappedKey}});try{({deviceId:s}=await c(o).catch(e=>{if(!(e instanceof Z&&e.code===`device_only_required`))throw e;return c({wrapAlg:Nd})}))}catch(t){let r;try{r=await e.myIdentity()}catch{throw new Zh(t)}let i=r&&Ph(r.publicKey);if(!r||!i||!Cc(i,n.identity.publicKey))throw t;s=r.deviceId}$h.delete(n);let l={...n.identity,deviceId:s};return{identity:l,kept:await t.save(l)}}function cg(e,t){return e instanceof Z?e.status===429||e.code===`rate_limited`?{message:t===`reset your encryption key`?Gh:Uh}:e.code===`sso_step_up_required`?{message:`Confirm with KySignOn to ${t}. The confirmation window did not finish; allow pop-ups for this site and try again.`}:e.code===`step_up_required`?{message:`Confirm your password to ${t}.`}:e.code===`already_exists`?{message:`Your encryption key changed in another tab or browser. Reload and check before trying again.`}:e.code===`identity_exists`?{message:`Start the reset again: a new key is needed.`}:e.code===`unauthenticated`?{message:`Your session ended or the password was wrong. Sign in again.`}:e.code===`step_up_pending`||e.code===`sso_sign_in_required`||e.code===`password_change_required`?gh(e,t):{message:`Could not ${t}. Try again.`}:e instanceof TypeError?{message:`Could not reach KyNotes to ${t}. Check the connection and try again.`}:e instanceof Error?{message:e.message}:{message:`Could not ${t}.`}}var lg=`Save a recovery code so you can get your encryption key back if no browser holds it and your password cannot open it.`,ug=`A recovery code gets your encryption key back when no browser holds it and your password cannot open it: after an administrator resets your password, or always on a single sign-on account, whose key has no password copy. KyNotes shows it once and cannot show it again. The server keeps only a copy of your key locked with the code, which it cannot open.`,dg=`Write this code down or store it in a password manager. Anyone who has it and can sign in as you can read your notebooks.`,fg=`If no browser holds your key and your password cannot open it, this code is the only way back to your notebooks.`,pg=`Recovery code saved. Keep it somewhere safe.`,mg=`New recovery code saved. Your previous code no longer works here, but older server backups still hold a copy it opens: if it may have leaked, reset your encryption key instead.`,hg=`No other browser holds your key? Enter your recovery code.`,gg=`This browser holds your encryption key, so you do not need a reset to get it back: save a recovery code instead. Reset only if a browser that holds your key was lost or stolen.`,_g=`Only if no browser holds your key and you have no recovery code. Your personal notebooks are lost.`,vg=`Your encryption key was reset. Team owners share their notebooks' keys with you again when they next open them.`,yg=`Your encryption key was reset, but this browser could not keep it (site storage is blocked). Restore it with your new recovery code in a browser that allows site storage.`,bg=`That password is not right. Nothing was reset.`,xg=`The reset did not go through. Keep the code you saved: trying again sends the same new key.`,Sg=`That group does not match. Check your saved copy, or go back to see the code again.`,Cg=e=>e?`Confirm it is you in the KySignOn window that opens.`:`Confirming it is you…`,wg={autoComplete:`off`,spellCheck:!1,autoCapitalize:`characters`,autoCorrect:`off`,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-bwignore":`true`,"data-form-type":`other`},Tg=e=>e.normalize(`NFKC`).toUpperCase().replace(/[^0-9A-Z]/g,``).slice(0,28).match(/.{1,4}/g)?.join(`-`)??``,Eg=e=>`KyNotes recovery code\n\n${e}\n\n${dg}\n${fg}\n`;function Dg(){document.body.classList.add(`print-recovery`);try{window.print()}finally{document.body.classList.remove(`print-recovery`)}}async function Og(e,t,n){try{Mh(t).fill(0)}catch(e){return e.message}try{await n(e);return}catch(e){return cg(e,`restore your key`).message}}async function kg(e,t){let n=await e.derive(t);try{return await e.stepUp(n.authSecret),n}catch(e){return n.userKEK.fill(0),e.code===`unauthenticated`?bg:cg(e,Wh).message}}function Ag(e){let[t,n]=(0,X.useState)(),r=(0,X.useRef)(void 0),i=(t=!1)=>{e&&!t&&r.current?.identity.privateKey.fill(0),r.current=void 0,n(void 0)};return(0,X.useEffect)(()=>()=>{i()},[]),{prepared:t,hold:e=>{i(),r.current=e,n(e)},forget:i,showAgain:()=>{r.current&&(r.current=ng(r.current),n(r.current))}}}function jg({code:e,onNext:t}){return(0,$.jsxs)(`div`,{className:`recovery-step recovery-sheet`,children:[(0,$.jsx)(`p`,{className:`config-muted`,children:ug}),(0,$.jsx)(`code`,{className:`recovery-code`,"aria-label":`Recovery code`,children:e}),(0,$.jsxs)(`p`,{className:`config-muted`,children:[dg,` KyNotes shows it once.`]}),(0,$.jsx)(`p`,{role:`note`,children:(0,$.jsx)(`strong`,{children:fg})}),(0,$.jsxs)(`div`,{className:`recovery-actions`,children:[(0,$.jsx)(`button`,{type:`button`,className:`quiet`,onClick:Dg,children:`Print`}),(0,$.jsx)(`button`,{type:`button`,className:`quiet`,onClick:()=>wp(`kynotes-recovery-code.txt`,Eg(e),`text/plain`),children:`Download as a text file`}),(0,$.jsx)(`button`,{type:`button`,onClick:t,children:`I saved it`})]})]})}function Mg({prepared:e,onBack:t,onConfirmed:n}){let[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``);return(0,$.jsxs)(`form`,{className:`recovery-step`,onSubmit:t=>{t.preventDefault(),rg(e,r)?n():o(Sg)},children:[(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:Yh(e.check)}),(0,$.jsx)(`input`,{name:`recovery-group`,value:r,onChange:e=>i(e.target.value.toUpperCase()),maxLength:8,...wg})]}),a&&(0,$.jsx)(`p`,{role:`alert`,children:a}),(0,$.jsx)(`button`,{type:`button`,className:`quiet`,onClick:t,children:`Show the code again`}),(0,$.jsx)(`button`,{children:`Save recovery code`})]})}function Ng({userID:e,held:t,live:n,sso:r,stepUp:i,autoStart:a=!1,onSaved:o}){let{prepared:s,hold:c,forget:l,showAgain:u}=Ag(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``);async function h(){m(``);let n=await t();n?(c(await tg(n,e)),f(!1)):m(`This browser does not hold your encryption key.`)}(0,X.useEffect)(()=>{a&&h()},[a]);async function g(){try{let e=await t();if(!e)throw Error(`This browser does not hold your encryption key.`);m(Cg(r)),await i(),await ag(Cu,s,e,n?.recoveryId??``),m(n?.recoveryId?mg:pg),l(),o()}catch(e){m(cg(e,`save a recovery code`).message),e.code===`already_exists`&&l()}}return(0,$.jsxs)(`section`,{id:`recovery`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Recovery code`}),(0,$.jsx)(`p`,{className:`config-muted`,children:n?.recoveryId?`You saved a recovery code on ${new Date(n.recoverySetAt??``).toLocaleDateString()}.`:lg}),!s&&(0,$.jsx)(`button`,{onClick:()=>void h(),children:n?.recoveryId?`Replace recovery code`:`Create recovery code`}),s&&!d&&(0,$.jsx)(jg,{code:s.code,onNext:()=>f(!0)}),s&&d&&(0,$.jsx)(Mg,{prepared:s,onBack:()=>{u(),f(!1)},onConfirmed:g}),p&&(0,$.jsx)(`p`,{role:`status`,children:p})]})}function Pg({userID:e,sso:t,store:n,stepUp:r,onRestored:i}){let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1);return(0,$.jsxs)(`form`,{id:`recovery-restore`,className:`config-card`,onSubmit:s=>{s.preventDefault(),u(!0),c(`Checking…`),(async()=>{let s,l=await Og(r,a,async r=>{s=await og(Cu,n,e,a,async()=>{c(Cg(t)),await r()})});u(!1),l?c(l):(o(``),c(``),i(s))})()},children:[(0,$.jsx)(`h2`,{children:`Use a recovery code`}),(0,$.jsx)(`p`,{className:`config-muted`,children:hg}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Recovery code`}),(0,$.jsx)(`input`,{name:`recovery-code`,value:a,onChange:e=>o(Tg(e.target.value)),...wg})]}),(0,$.jsx)(`button`,{disabled:l||!a.trim(),children:`Restore`}),s&&(0,$.jsx)(`p`,{role:`status`,children:s})]})}function Fg({userID:e,store:t,live:n,held:r,stepUp:i,exportWaiting:a,onReset:o,password:s,startOpen:c=!1}){let{prepared:l,hold:u,forget:d,showAgain:f}=Ag(!0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(c),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(void 0),E=()=>{T.current?.userKEK.fill(0),T.current=void 0};(0,X.useEffect)(()=>()=>{E()},[]);function D(){d(),E(),m(!1),g(!1),v(``),b(``)}async function O(){try{let e=await a();w(e?`Exported ${e} unsent edit${e===1?``:`s`}.`:`This browser has no unsent edits to export.`)}catch{w(`Could not export the unsent edits.`)}}async function k(){if(Jh(_)){w(``);try{if(s){E();let e=await kg(s,y);if(b(``),typeof e==`string`){w(e);return}T.current=e}u(await tg(wc(),e)),S(!1)}catch(e){w(cg(e,Wh).message)}}}async function A(){let e=T.current;try{w(Cg(!s)),e||await i();let{identity:r,kept:a}=await sg(Cu,t,l,n?.deviceId??``,_,e&&{keys:e,stepUp:s.stepUp});w(a?vg:yg),m(!1),d(!0),E(),g(!1),o(r)}catch(e){let t=cg(e,Wh).message;w(e instanceof Error&&e.name===`ResetUncertainError`?t:`${t} ${xg}`),m(!0)}}return(0,$.jsxs)(`section`,{id:`identity-reset`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Reset encryption key`}),(0,$.jsx)(`p`,{className:`config-muted`,children:r?gg:_g}),!h&&(0,$.jsx)(`button`,{className:`secondary danger`,onClick:()=>g(!0),children:`Reset encryption key…`}),h&&!l&&(0,$.jsxs)(`form`,{className:`recovery-step`,onSubmit:e=>{e.preventDefault(),k()},children:[(0,$.jsx)(`p`,{role:`alert`,children:`Reset your encryption key? Your personal notebooks become unreadable for good, on every browser, and so does any team notebook whose keys no other owner or admin holds. Unsent edits waiting for a notebook's keys are never sent afterwards: export them first. Team owners must share each team's keys with you again, and colleagues are asked to trust your new key. Type RESET to continue.`}),(0,$.jsx)(`button`,{type:`button`,className:`quiet`,onClick:()=>void O(),children:`Export unsent edits first`}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsxs)(`span`,{children:[`Type `,`RESET`,` to confirm`]}),(0,$.jsx)(`input`,{name:`reset-phrase`,value:_,onChange:e=>v(e.target.value),...wg})]}),s&&(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Your password`}),(0,$.jsx)(`input`,{name:`reset-password`,type:`password`,autoComplete:`current-password`,value:y,onChange:e=>b(e.target.value)})]}),(0,$.jsx)(`button`,{type:`button`,className:`quiet`,onClick:D,children:`Cancel`}),(0,$.jsx)(`button`,{className:`secondary danger`,disabled:!Jh(_)||!!s&&!y,children:`Continue`})]}),l&&!x&&(0,$.jsx)(jg,{code:l.code,onNext:()=>S(!0)}),l&&x&&!p&&(0,$.jsx)(Mg,{prepared:l,onBack:()=>{f(),S(!1)},onConfirmed:A}),l&&p&&(0,$.jsxs)(`div`,{className:`recovery-actions`,children:[(0,$.jsx)(`button`,{className:`secondary danger`,onClick:()=>void A(),children:`Try the reset again`}),(0,$.jsx)(`button`,{className:`quiet`,onClick:D,children:`Cancel`})]}),C&&(0,$.jsx)(`p`,{role:`status`,children:C})]})}var Ig=Array.from({length:256},(e,t)=>{let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function Lg(e){let t=4294967295;for(let n of e)t=Ig[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function Rg(e,t=new Date){if(e.length>65535)throw Error(`Too many files for one zip`);let n=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1,r=Math.max(0,t.getFullYear()-1980)<<9|t.getMonth()+1<<5|t.getDate(),i=new TextEncoder,a=[],o=[],s=0;for(let t of e){let e=i.encode(t.path),c=Lg(t.data),l=t.data.length;if(s+30+e.length+l>4294967295)throw Error(`Export is larger than 4 GiB`);let u=new Uint8Array(30+e.length),d=new DataView(u.buffer);d.setUint32(0,67324752,!0),d.setUint16(4,20,!0),d.setUint16(6,2048,!0),d.setUint16(10,n,!0),d.setUint16(12,r,!0),d.setUint32(14,c,!0),d.setUint32(18,l,!0),d.setUint32(22,l,!0),d.setUint16(26,e.length,!0),u.set(e,30);let f=new Uint8Array(46+e.length),p=new DataView(f.buffer);p.setUint32(0,33639248,!0),p.setUint16(4,20,!0),p.setUint16(6,20,!0),p.setUint16(8,2048,!0),p.setUint16(12,n,!0),p.setUint16(14,r,!0),p.setUint32(16,c,!0),p.setUint32(20,l,!0),p.setUint32(24,l,!0),p.setUint16(28,e.length,!0),p.setUint32(42,s,!0),f.set(e,46),o.push(f),a.push(u,t.data.slice().buffer),s+=u.length+l}let c=o.reduce((e,t)=>e+t.length,0),l=new Uint8Array(22),u=new DataView(l.buffer);return u.setUint32(0,101010256,!0),u.setUint16(8,e.length,!0),u.setUint16(10,e.length,!0),u.setUint32(12,c,!0),u.setUint32(16,s,!0),new Blob([...a,...o,l],{type:`application/zip`})}function zg(e,t){return t?e.filter(e=>!t.has(e.containerID)):[]}function Bg(e,t,n){let r=e.filter(e=>e.owner===n),i=new Set(zg(r,t));return r.filter(e=>e.gone||i.has(e))}async function Vg(e,t){let n=[],r=0;for(let i of e){let e=await t(i).catch(()=>void 0);e===void 0?r+=1:n.push({id:i.id,notebook:i.containerID,updatedAt:i.updatedAt,content:e})}return{json:JSON.stringify(n,null,2),unreadable:r}}async function Hg(e,t,n,r){for(let i of e){if(i.owner!==t||i.keyGeneration!==0||i.previousKey)continue;let e=await n(i).catch(()=>void 0);await r(i,{...i,...e&&{payload:e},previousKey:!0})}}async function Ug(e,t,n,r){let i=[];for(let a of e)a.owner===t&&(a.previousKey||n&&a.keyGeneration===0&&!await r(a))&&i.push(a);return i}var Wg=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Gg=n(((e,t)=>{t.exports=Wg()})),Kg=n((e=>{var t=Fl();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Kg()})),Jg=n((e=>{var t=Gg(),n=Fl(),r=qg();function i(e){var t=`https://react.dev/errors/`+e;if(1le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=cp(t),e=lp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){var t=e.memoizedState;t!==null&&(ah._currentValue=t.memoizedState,fe(ge,e)),t=pe.current;var n=lp(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),ah._currentValue=se)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{we=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ce(n):``}function Ee(e,t){switch(e.tag){case 26:case 27:case 5:return Ce(e.type);case 16:return Ce(`Lazy`);case 13:return e.child!==t&&t!==null?Ce(`Suspense Fallback`):Ce(`Suspense`);case 19:return Ce(`SuspenseList`);case 0:case 15:return Te(e.type,!1);case 11:return Te(e.type.render,!1);case 1:return Te(e.type,!0);case 31:return Ce(`Activity`);case 30:return Ce(`ViewTransition`);default:return``}}function De(e){try{var t=``,n=null;do t+=Ee(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Oe=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ae=t.unstable_cancelCallback,je=t.unstable_shouldYield,Me=t.unstable_requestPaint,Ne=t.unstable_now,Pe=t.unstable_getCurrentPriorityLevel,Fe=t.unstable_ImmediatePriority,Ie=t.unstable_UserBlockingPriority,Le=t.unstable_NormalPriority,Re=t.unstable_LowPriority,ze=t.unstable_IdlePriority,Be=t.log,Ve=t.unstable_setDisableYieldValue,He=null,Ue=null;function We(e){if(typeof Be==`function`&&Ve(e),Ue&&typeof Ue.setStrictMode==`function`)try{Ue.setStrictMode(He,e)}catch{}}var Ge=Math.clz32?Math.clz32:Je,Ke=Math.log,qe=Math.LN2;function Je(e){return e>>>=0,e===0?32:31-(Ke(e)/qe|0)|0}var Ye=256,Xe=262144,Ze=4194304;function Qe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function $e(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Qe(n))):i=Qe(o):i=Qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Qe(n))):i=Qe(o)):i=Qe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function et(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function at(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ot(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=nr),ar=` `,or=!1;function sr(e,t){switch(e){case`keyup`:return er.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function cr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var lr=!1;function ur(e,t){switch(e){case`compositionend`:return cr(t);case`keypress`:return t.which===32?(or=!0,ar):null;case`textInput`:return e=t.data,e===ar&&or?null:e;default:return null}}function dr(e,t){if(lr)return e===`compositionend`||!tr&&sr(e,t)?(e=wn(),Cn=Sn=xn=null,lr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Pr(n)}}function Ir(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ir(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Lr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Nr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Nr(e.document)}return t}function Rr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var zr=vn&&`documentMode`in document&&11>=document.documentMode,Br=null,Vr=null,Hr=null,Ur=!1;function Wr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ur||Br==null||Br!==Nr(r)||(r=Br,`selectionStart`in r&&Rr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Hr&&Mr(Hr,r)||(Hr=r,r=Gf(Vr,`onSelect`),0>=o,i-=o,Bi=1<<32-Ge(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),q&&Hi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),q&&Hi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return q&&Hi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),q&&Hi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),Qa(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===L&&Ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Qa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Di(o.props.children,e.mode,c,o.key),Qa(c,o),c.return=e,e=c):(c=Ei(o.type,o.key,o.props,null,e.mode,c),Qa(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ai(o,e.mode,c),c.return=e,e=c}return s(e);case L:return o=Ga(o),_(e,r,o,c)}if(oe(o))return h(e,r,o,c);if(B(o)){if(l=B(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,Za(o),c);if(o.$$typeof===M)return _(e,r,ga(e,o),c);$a(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Oi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Xa=0;var i=_(e,t,n,r);return Ya=null,i}catch(t){if(t===za||t===Va)throw t;var a=Si(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var to=eo(!0),no=eo(!1),ro=!1;function io(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ao(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function oo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function so(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Gu&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=yi(e),vi(e,null,n),t}return hi(e,r,t,n),yi(e)}function co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}function lo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var uo=!1;function fo(){if(uo){var e=Aa;if(e!==null)throw e}}function po(e,t,n,r){uo=!1;var i=e.updateQueue;ro=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Ju&f)===f:(r&f)===f){f!==0&&f===ka&&(uo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:ro=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),nd|=o,e.lanes=o,e.memoizedState=d}}function mo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function ho(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=V.T,s={};s.types=o===null?null:o.types,V.T=s,tc(e,!1,t,n);try{var c=i(),l=V.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ec(e,t,Na(c,r),Dd(e)):ec(e,t,r,Dd(e))}catch(n){ec(e,t,{then:function(){},status:`rejected`,reason:n},Dd())}finally{H.p=a,o!==null&&s.types!==null&&(o.types=s.types),V.T=o}}function Ws(){}function Gs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ks(e).queue;Us(e,a,t,se,n===null?Ws:function(){return qs(e),n(r)})}function Ks(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function qs(e){var t=Ks(e);t.next===null&&(t=e.alternate.memoizedState),ec(e,t.next.queue,{},Dd())}function Js(){return ha(ah)}function Ys(){return Zo().memoizedState}function Xs(){return Zo().memoizedState}function Zs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Dd();e=oo(n);var r=so(t,e,n);r!==null&&(Ad(r,t,n),co(r,t,n)),t={cache:Sa()},e.payload=t;return}t=t.return}}function Qs(e,t,n){var r=Dd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},nc(e)?rc(t,n):(n=gi(e,t,n,r),n!==null&&(Ad(n,e,r),ic(n,t,r)))}function $s(e,t,n){ec(e,t,n,Dd())}function ec(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(nc(e))rc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,jr(s,o))return hi(e,t,i,0),Ku===null&&mi(),!1}catch{}if(n=gi(e,t,i,r),n!==null)return Ad(n,e,r),ic(n,t,r),!0}return!1}function tc(e,t,n,r){if(r={lane:2,revertLane:Af(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},nc(e)){if(t)throw Error(i(479))}else t=gi(e,n,r,2),t!==null&&Ad(t,e,2)}function nc(e){var t=e.alternate;return e===J||t!==null&&t===J}function rc(e,t){Io=Fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ic(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}var ac={readContext:ha,use:es,useCallback:Y,useContext:Y,useEffect:Y,useImperativeHandle:Y,useLayoutEffect:Y,useInsertionEffect:Y,useMemo:Y,useReducer:Y,useRef:Y,useState:Y,useDebugValue:Y,useDeferredValue:Y,useTransition:Y,useSyncExternalStore:Y,useId:Y,useHostTransitionStatus:Y,useFormState:Y,useActionState:Y,useOptimistic:Y,useMemoCache:Y,useCacheRefresh:Y,useEffectEvent:Y},oc={readContext:ha,use:es,useCallback:function(e,t){return Xo().memoizedState=[e,t===void 0?null:t],e},useContext:ha,useEffect:As,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Os(4194308,4,Is.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Os(4194308,4,e,t)},useInsertionEffect:function(e,t){Os(4,2,e,t)},useMemo:function(e,t){var n=Xo();t=t===void 0?null:t;var r=e();if(Lo){We(!0);try{e()}finally{We(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Xo();if(n!==void 0){var i=n(t);if(Lo){We(!0);try{n(t)}finally{We(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Qs.bind(null,J,e),[r.memoizedState,e]},useRef:function(e){var t=Xo();return e={current:e},t.memoizedState=e},useState:function(e){e=fs(e);var t=e.queue,n=$s.bind(null,J,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Rs,useDeferredValue:function(e,t){return Vs(Xo(),e,t)},useTransition:function(){var e=fs(!1);return e=Us.bind(null,J,e.queue,!0,!1),Xo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=J,a=Xo();if(q){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ku===null)throw Error(i(349));Ju&127||ss(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,As(ls.bind(null,r,o,e),[e]),r.flags|=2048,Es(9,{destroy:void 0},cs.bind(null,r,o,n,t),null),n},useId:function(){var e=Xo(),t=Ku.identifierPrefix;if(q){var n=Vi,r=Bi;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ro++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[mt]=t,o[ht]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(ep(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&il(t)}}return ll(t),t.subtreeFlags&=-33554433,al(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&il(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=he.current,ta(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=qi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[mt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Zf(e.nodeValue,n)),e||Qi(t,!0)}else e=sp(e).createTextNode(r),e[mt]=t,t.stateNode=e}return ll(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ta(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[mt]=t}else na(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),e=!1}else n=ra(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Do(t),t):(Do(t),null);if(t.flags&128)throw Error(i(558))}return ll(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ta(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[mt]=t}else na(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),a=!1}else a=ra(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Do(t),t):(Do(t),null)}return Do(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),sl(t,t.updateQueue),ll(t),null);case 4:return ve(),e===null&&Vf(t.stateNode.containerInfo),t.flags|=67108864,ll(t),null;case 10:return la(t.type),ll(t),null;case 19:if(Ao(t),r=t.memoizedState,r===null)return ll(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)cl(r,!1);else{if(td!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=jo(e),o!==null){for(t.flags|=128,cl(r,!1),e=o.updateQueue,t.updateQueue=e,sl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ti(n,e),n=n.sibling;return ko(t,Oo.current&1|2),q&&Hi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ne()>fd&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=jo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,sl(t,e),cl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!q)return ll(t),null}else 2*Ne()-r.renderingStartTime>fd&&n!==536870912&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ne(),e.sibling=null,o=Oo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||q?ko(t,o):(n=o,fe(xo,t),fe(Oo,n),So===null&&(So=t)),q&&Hi(t,r.treeForkCount),e}return ll(t),null;case 22:case 23:return Do(t),bo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(ll(t),t.subtreeFlags&6&&(t.flags|=8192)):ll(t),n=t.updateQueue,n!==null&&sl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&de(Fa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),la(xa),ll(t),null;case 25:return null;case 30:return t.flags|=33554432,ll(t),null}throw Error(i(156,t.tag))}function dl(e,t){switch(Gi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return la(xa),ve(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return be(t),null;case 31:if(t.memoizedState!==null){if(Do(t),t.alternate===null)throw Error(i(340));na()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Do(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));na()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ao(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ve(),null;case 10:return la(t.type),null;case 22:case 23:return Do(t),bo(),e!==null&&de(Fa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return la(xa),null;case 25:return null;default:return null}}function fl(e,t){switch(Gi(t),t.tag){case 3:la(xa),ve();break;case 26:case 27:case 5:be(t);break;case 4:ve();break;case 31:t.memoizedState!==null&&Do(t);break;case 13:Do(t);break;case 19:Ao(t);break;case 10:la(t.type);break;case 22:case 23:Do(t),bo(),e!==null&&de(Fa);break;case 24:la(xa)}}function pl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){lf(t,t.return,e)}}function ml(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){lf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){lf(t,t.return,e)}}function hl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ho(t,n)}catch(t){lf(e,e.return,t)}}}function gl(e,t,n){n.props=pc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){lf(e,t,n)}}function _l(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=si(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Mp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Np(e);f(e.child,!1,Xp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){lf(e,t,n)}}function vl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){lf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){lf(e,t,n)}else n.current=null}}function yl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),ep(r,t,n),r[mt]=e,G(r),t=r;break a;case`link`:if(o=Um(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Fr(s,h),v=Fr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,V.T=null,n=bd,bd=null;var o=gd,s=vd;if(hd=0,_d=gd=null,vd=0,Gu&6)throw Error(i(331));var c=Gu;if(Gu|=4,Bu(o.current),Mu(o,o.current,s,n),Gu=c,Cf(0,!1),Ue&&typeof Ue.onPostCommitFiberRoot==`function`)try{Ue.onPostCommitFiberRoot(He,o)}catch{}return!0}finally{H.p=a,V.T=r,af(e,t)}}function cf(e,t,n){t=Mi(n,t),t=yc(e.stateNode,t,2),e=so(e,t,2),e!==null&&(at(e,2),Sf(e))}function lf(e,t,n){if(e.tag===3)cf(e,e,n);else for(;t!==null;){if(t.tag===3){cf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(md===null||!md.has(r))){e=Mi(n,e),n=bc(2),r=so(t,n,2),r!==null&&(xc(n,r,t,e),at(r,2),Sf(r));break}}t=t.return}}function uf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Wu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||($u=!0,i.add(n),e=df.bind(null,e,t,n),t.then(e,e))}function df(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ku===e&&(Ju&n)===n&&(td===4||td===3&&(Ju&62914560)===Ju&&300>Ne()-ud?Gu&2?id|=n:Ld(e,0):id|=n,od===Ju&&(od=0)),Sf(e)}function ff(e,t){t===0&&(t=rt()),e=_i(e,t),e!==null&&(at(e,t),Sf(e))}function pf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ff(e,n)}function mf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),ff(e,n)}function hf(e,t){return ke(e,t)}var gf=null,_f=null,vf=!1,yf=!1,bf=!1,xf=0;function Sf(e){e!==_f&&e.next===null&&(_f===null?gf=_f=e:_f=_f.next=e),yf=!0,vf||(vf=!0,kf())}function Cf(e,t){if(!bf&&yf){bf=!0;do for(var n=!1,r=gf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ge(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Of(r,a))}else a=Ju,a=$e(r,r===Ku?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||et(r,a)||(n=!0,Of(r,a))}r=r.next}while(n);bf=!1}}function wf(){Tf()}function Tf(){yf=vf=!1;var e=0;xf!==0&&pp()&&(e=xf);for(var t=Ne(),n=null,r=gf;r!==null;){var i=r.next,a=Ef(r,t);a===0?(r.next=null,n===null?gf=i:n.next=i,i===null&&(_f=n)):(n=r,(e!==0||a&3)&&(yf=!0)),r=i}hd!==0&&hd!==5||Cf(e,!1),xf!==0&&(xf=0)}function Ef(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&rp(d)&&(c=c.responseEnd,o+=u*(cZm){s.length=o;break}f=new Promise(kp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Cm(e,t,n){var r=Sm;if(r&&typeof t==`string`&&t){var i=qt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_m.has(i)||(_m.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ep(t,`link`,e),G(t),r.head.appendChild(t)))}}function wm(e){ym.D(e),Cm(`dns-prefetch`,e,null)}function Tm(e,t){ym.C(e,t),Cm(`preconnect`,e,t)}function Em(e,t,n){ym.L(e,t,n);var r=Sm;if(r&&e&&t){var i=`link[rel="preload"][as="`+qt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+qt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+qt(n.imageSizes)+`"]`)):i+=`[href="`+qt(e)+`"]`;var a=i;switch(t){case`style`:a=Mm(e);break;case`script`:a=Im(e)}if(!(gm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nm(a))||t===`script`&&r.querySelector(Lm(a))))){var o=r.createElement(`link`);ep(o,`link`,e),t===`style`&&(o[W]=!0,o.onload=o.onerror=function(){Dt(o)}),G(o),r.head.appendChild(o)}}}function Dm(e,t){ym.m(e,t);var n=Sm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+qt(r)+`"][href="`+qt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Im(e)}if(!gm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),gm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Lm(a)))return}r=n.createElement(`link`),ep(r,`link`,e),G(r),n.head.appendChild(r)}}}function Om(e,t,n){ym.S(e,t,n);var r=Sm;if(r&&e){var i=Et(r).hoistableStyles,a=Mm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gm.get(a))&&Bm(e,n);var c=o=r.createElement(`link`);G(c),ep(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,zm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function km(e,t){ym.X(e,t);var n=Sm;if(n&&e){var r=Et(n).hoistableScripts,i=Im(e),a=r.get(i);a||(a=n.querySelector(Lm(i)),a||(e=w({src:e,async:!0},t),(t=gm.get(i))&&Vm(e,t),a=n.createElement(`script`),G(a),ep(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Am(e,t){ym.M(e,t);var n=Sm;if(n&&e){var r=Et(n).hoistableScripts,i=Im(e),a=r.get(i);a||(a=n.querySelector(Lm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=gm.get(i))&&Vm(e,t),a=n.createElement(`script`),G(a),ep(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jm(e,t,n,r){var a=(a=he.current)?vm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Mm(n.href),t=Et(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mm(n.href);var o=Et(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Nm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=gm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gm.set(e,o)),Fm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Im(n),t=Et(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mm(e){return`href="`+qt(e)+`"`}function Nm(e){return`link[rel="stylesheet"][`+e+`]`}function Pm(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Fm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[W]){r.loading=1;return}}else t=e.createElement(`link`),t[W]=!0,t.onload=t.onerror=Dt.bind(null,t),ep(t,`link`,n),G(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Im(e){return`[src="`+qt(e)+`"]`}function Lm(e){return`script[async]`+e}function Rm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+qt(n.href)+`"]`);if(r)return t.instance=r,G(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),G(r),ep(r,`style`,a),zm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mm(n.href);var o=e.querySelector(Nm(a));if(o)return t.state.loading|=4,t.instance=o,G(o),o;r=Pm(n),(a=gm.get(a))&&Bm(r,a),o=(e.ownerDocument||e).createElement(`link`),G(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ep(o,`link`,r),t.state.loading|=4,zm(o,n.precedence,e),t.instance=o;case`script`:return o=Im(n.src),(a=e.querySelector(Lm(o)))?(t.instance=a,G(a),a):(r=n,(a=gm.get(o))&&(r=w({},n),Vm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),G(a),ep(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,zm(r,n.precedence,e));return t.instance}function zm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Gm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Km(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function qm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Jm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Ym(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Jm(t),e.suspenseyImages.push(t)),e=th.bind(e),t.decode().then(e,e))}function Xm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Mm(r.href),a=t.querySelector(Nm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=eh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,G(a);return}a=t.ownerDocument||t,r=Pm(r),(i=gm.get(i))&&Bm(r,i),a=a.createElement(`link`),G(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ep(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=eh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Zm=0;function Qm(e,t){return e.stylesheets&&e.count===0&&rh(e,e.stylesheets),0Zm?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function $m(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)rh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function eh(){this.count--,$m(this)}function th(){this.imgCount--,$m(this)}var nh=null;function rh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,nh=new Map,t.forEach(ih,e),nh=null,eh.call(e))}function ih(e,t){if(!(t.state.loading&4)){var n=nh.get(e);if(n)var r=n.get(null);else{n=new Map,nh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Jg()})),Xg=Yg(),Zg=e=>e.slice(-6).toUpperCase(),Qg=2e3,$g=`This link request ended: it was cancelled on the other browser or expired. Start again.`,e_=`Linking cancelled: the codes differed. Someone may be interfering; start again on both browsers.`,t_=`Request cancelled.`,n_=e=>e instanceof Jm||e instanceof Z&&e.code===`not_found`,r_=(e,t=!1)=>void ju(e,t).catch(()=>void 0);function i_({status:e,set:t}){if(!e)return null;let n=e.cancel;return(0,$.jsxs)(`p`,{role:`status`,className:`link-status`,children:[e.message,n&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>void n().then(()=>t(void 0),e=>t(gh(e))),children:`Cancel the KySignOn confirmation`})]})]})}function a_({userID:e,canKeep:t,store:n,onLinked:r}){let[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(),u=(0,X.useRef)(0),d=(0,X.useRef)({}),f={create:Tu,collect:Gm,reveal:Ou,myIdentity:vu};function p(e,t=!1){u.current+=1;let{attempt:n}=d.current;d.current={},a(void 0),s(!1),l(e?{message:e}:void 0),n&&(Xm(n),r_(n.id,t))}(0,X.useEffect)(()=>{let e=()=>p(void 0,!0);return addEventListener(`pagehide`,e),()=>{removeEventListener(`pagehide`,e),p()}},[]);async function m(){let{attempt:t,bundle:i,confirmation:o}=d.current;if(t&&i&&o){u.current+=1,d.current={},a(void 0),s(!1);try{r(await uh(t,i,o,e,f,n))}catch(e){r_(t.id),l(gh(e))}}}async function h(){p();let r=u.current;try{if(await th(f,n)){l({message:eh});return}let i=await nh(f,t,e);if(u.current!==r){Xm(i),r_(i.id);return}d.current.attempt=i,a(i);let o=await lh(f,i,e,()=>u.current===r,a);if(!o)return;d.current.bundle=o,await m()}catch(e){if(u.current!==r)return;p(),l(n_(e)?{message:$g}:gh(e))}}function g(){i?.code&&(d.current.confirmation=Wp(i.id,i.code),s(!0),m())}return(0,$.jsxs)(`section`,{id:`link-this-browser`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Link this browser`}),!i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`config-muted`,children:`This browser does not hold your encryption key, so it cannot open team notebooks. A browser where you already use KyNotes can send it here; KyNotes only relays it encrypted.`}),(0,$.jsx)(`button`,{onClick:()=>void h(),children:`Link this browser`})]}),i&&!i.code&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`On a browser that holds your key, open Settings → Link another browser and approve request `,(0,$.jsx)(`code`,{className:`link-code`,children:Zg(i.id)}),`. Waiting…`]}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>p(t_),children:`Cancel`})]}),i?.code&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Check code: `,(0,$.jsx)(`code`,{className:`check-code`,children:i.code})]}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Type this code on the other browser. Choose Codes match once it accepts the code; if it does not, choose Codes differ.`}),o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Waiting for the other browser to send the key…`}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>p(t_),children:`Cancel`})]}):(0,$.jsxs)(`div`,{className:`link-actions`,children:[(0,$.jsx)(`button`,{onClick:g,children:`Codes match`}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>p(e_),children:`Codes differ`})]})]}),(0,$.jsx)(i_,{status:c,set:l})]})}function o_({userID:e,held:t,stepUp:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(void 0),m=(0,X.useRef)(!1),h=(0,X.useRef)(!1),[g,_]=(0,X.useState)(!1),v=(0,X.useRef)(!1),y=e=>{p.current=e,o(e)};function b(e,t){let n=p.current;n&&Xm(n),y(void 0),c(``),u(t?{message:t}:void 0),e&&r_(e)}(0,X.useEffect)(()=>{v.current=!0;let t=!1,n,r=async()=>{try{let n=await Eu();if(t)return;i(n);let r=p.current;if(r&&!m.current){let t=n.find(e=>e.id===r.id);t?r.newcomerKey||y(fh(r,t,e)):(Xm(r),y(void 0),c(``),u({message:$g}))}}catch(e){t||(e instanceof qm||e instanceof Jm?b(p.current?.id,e.message):u(gh(e)))}t||(n=setTimeout(()=>void r(),Qg))};n=setTimeout(()=>void r(),0);let a=e=>{let t=p.current;p.current=void 0,t&&(Xm(t),m.current||r_(t.id,e))},s=()=>{a(!0),o(void 0),c(``)};return addEventListener(`pagehide`,s),()=>{t=!0,v.current=!1,clearTimeout(n),removeEventListener(`pagehide`,s),a(!1)}},[e]);async function x(t){if(!(h.current||p.current)){h.current=!0,_(!0),u(void 0),c(``);try{let n=await hh(dh({claim:Du},t,e),()=>v.current&&!p.current,ju);n&&y(n)}catch(e){v.current&&u(gh(e))}finally{h.current=!1,v.current&&_(!1)}}}function S(e){try{return!!ph(e,s)}catch{return!1}}async function C(){let r=p.current;if(r){u(void 0),m.current=!0,f(!0);try{let i=await t();if(!i){b(r.id,`This browser no longer holds your encryption key.`);return}await mh(r,ph(r,s),i,e,n),y(void 0),c(``),u({message:`Key sent. Finish on the other browser.`})}catch(e){e instanceof qm||e instanceof Jm||n_(e)?b(r.id,n_(e)?$g:e.message):u(gh(e))}finally{m.current=!1,f(!1)}}}return(0,$.jsxs)(`section`,{id:`link-devices`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Link another browser`}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Approve only a request you started yourself, on a browser in front of you. That browser then shows a check code; type it here to send your key.`}),!a&&(r.length?r.map(e=>(0,$.jsxs)(`div`,{className:`pin-row`,children:[(0,$.jsxs)(`span`,{children:[`Request `,(0,$.jsx)(`code`,{className:`link-code`,children:Zg(e.id)}),` · started `,new Date(e.createdAt).toLocaleTimeString()]}),e.claimed?(0,$.jsx)(`span`,{className:`config-muted`,children:`Being approved in another tab`}):(0,$.jsx)(`button`,{disabled:g,onClick:()=>void x(e),children:`Approve…`}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>b(e.id,t_),children:`Not me`})]},e.id)):(0,$.jsx)(`p`,{className:`config-muted`,children:`No browser is asking to be linked.`})),a&&!a.code&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Waiting for request `,(0,$.jsx)(`code`,{className:`link-code`,children:Zg(a.id)}),` to answer…`]}),(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>b(a.id,t_),children:`Cancel`})]}),a?.code&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Check code shown on the other browser`}),(0,$.jsx)(`input`,{className:`check-code-input`,value:s,onChange:e=>c(e.currentTarget.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`})]}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Type it from the other browser's screen. If that browser shows no code, or this one does not accept it, choose Codes differ.`}),(0,$.jsxs)(`div`,{className:`link-actions`,children:[(0,$.jsx)(`button`,{disabled:d||!S(a),onClick:()=>void C(),children:`Approve — send key`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:d,onClick:()=>b(a.id,e_),children:`Codes differ`})]})]}),(0,$.jsx)(i_,{status:l,set:u})]})}var s_=e=>e.code,c_=(e,t)=>e.filter((n,r)=>e.findIndex(e=>t(e)===t(n))===r);async function l_(e,t,n,r,i,a,o){let s=n.identity,c=s&&{...s,userId:n.userId},l=s&&{deviceId:s.deviceId,publicKey:Qe(s.publicKey)},u=[],d=async(s,d)=>{let f=await e.container(t),p=await r.loadKeyState(f.id),{rollback:m}=$p(f,p),h=Zp(p,f);o?.(f.id,{shared:h.shared,generation:h.generation}),(h.shared!==p.shared||h.generation!==p.generation)&&await r.saveKeyState(f.id,h).catch(()=>!1);let g=await e.envelopes(f.id),_=g,v=await Promise.all((await e.members(f.id)).map(async t=>({...t,identity:t.userId===n.userId&&l?l:await e.userIdentity(t.userId)}))),y=(e,t,n)=>nm({containerID:f.id,envelopes:t,me:c,members:v,pins:e,known:h,held:n??a}),b=e=>(d.saved={containerID:f.id,known:Zp(e.known,f)},e),x=async()=>{let e=await r.load(),t=await y(e,g);return t.fresh.length?(d.saved={containerID:f.id,known:h},{...await y(e,[]),known:h}):b(t)},S=e=>{if(!e.ok)return e.conflicts.length?{kind:`untrusted`,members:v.filter(t=>e.conflicts.includes(t.userId)).map(e=>mi(e.username,e.userId))}:{kind:`pins-unsaved`}},C=!1,w=(e,t=g)=>{if(!c)return{kind:`idle`};let r=lm({container:f,me:n.userId,members:v,envelopes:t,ring:e.ring,recoverable:n.recoverable}),i=r.kind===`wrap`?r.grants.filter(t=>!e.conflicts.includes(t.generation)):[],a=r.kind===`wrap`?i.length?{kind:`wrap`,grants:i}:{kind:`idle`}:r;return C=!n.canWrap&&(a.kind===`mint`||a.kind===`wrap`),n.canWrap||a.kind===`unrecoverable`?a:{kind:`idle`}},T=e=>(e.kind===`mint`?e.recipients:e.kind===`wrap`?e.grants.map(e=>e.member):[]).filter(e=>e.userId!==n.userId),E=await r.load(),D=await y(E,g);if(m){let e=D.fresh.length?await x():b(D);return{container:f,changed:[],conflicts:e.conflicts,known:Zp(e.known,f),fresh:[],ring:e.ring,plan:{kind:`rollback`},minted:!1,members:v,envelopes:g,deferred:!1}}let O=w(D),k=[],A=(e,t,n=D)=>({container:f,changed:k,conflicts:n.conflicts,known:Zp(n.known,f),fresh:c_([...u,...t],e=>e.userId),members:v,envelopes:_,deferred:C,...e}),j=async(e,t)=>{C=!1;let n=await x();return A({ring:n.ring,plan:e,minted:!1},t,n)};for(;;){let e=c_([...D.changed,...di(E,T(O)).changed],e=>e.member.userId);if(!e.length)break;if(k.push(...e),await i(e)!==!0)return j({kind:`untrusted`,members:e.map(e=>mi(e.member.username,e.member.userId))},[]);for(let t of e){let e=ui(E,t.member);if(!await r.confirm(e,t.pinned))return j({kind:`pins-unsaved`},[]);E=e.pins}D=await y(E,g),O=w(D)}let M=[...D.fresh],N=D.fresh.length?S(await r.addFresh(D.pins)):void 0;if(N)return j(N,[]);if(b(D),O.kind===`idle`||O.kind===`unrecoverable`)return A({ring:D.ring,plan:O,minted:!1},M);E=D.pins;let P=async e=>{let t=[];for(let{member:n,generation:r,key:i}of e){let e=await um(n,f.id,r,i,c,E);E=e.pins,M.push(...e.fresh),t.push(e.envelope)}return t},F;if(O.kind===`mint`){let e=dm();F=await P(O.recipients.map(t=>({member:t,generation:f.keyGeneration+1,key:e})))}else F=await P(O.grants.map(e=>({member:e.member,generation:e.generation,key:D.ring.get(e.generation)})));let I=M.length>D.fresh.length?S(await r.addFresh(E)):void 0;if(I)return j(I,D.fresh);try{if(await e.stepUp(),O.kind===`mint`){let t=await e.rotate(f.id,f.keyGeneration,F);f={...f,keyGeneration:t.keyGeneration,sharedGeneration:f.sharedGeneration||t.keyGeneration},d.saved={containerID:f.id,known:Zp(d.saved.known,f)},o?.(f.id,{shared:f.sharedGeneration,generation:f.keyGeneration})}else await e.putEnvelopes(f.id,F)}catch(e){if(s_(e)!==`already_exists`||s>0)throw e;return u.push(...M),`retry`}if(_=[...g,...F],O.kind===`wrap`)return A({ring:D.ring,plan:O,minted:!1},M);let L=b(await y(E,_,D.ring)),R=w(L,_);if(R.kind===`wrap`&&!di(E,T(R)).changed.length){let t=M.length,n=await P(R.grants.map(e=>({member:e.member,generation:e.generation,key:L.ring.get(e.generation)})));if(!(M.length>t&&S(await r.addFresh(E))))try{await e.stepUp(),await e.putEnvelopes(f.id,n),_=[..._,...n]}catch{}}return A({ring:L.ring,plan:O,minted:!0},M,L)};for(let e=0;;e+=1){let t={},n,i=!1;try{n=await d(e,t)}finally{t.saved&&(i=await r.saveKeyState(t.saved.containerID,t.saved.known).catch(()=>!1))}if(n!==`retry`)return{...n,keyStateSaved:i}}}async function u_(e,t,n,r,i,a){let{container:o,ring:s}=t,c=async t=>({invitation:await e.invite(o.id,n.userId,n.role,[]),keys:t});if(!r.identity||!r.canWrap)return c(`cannot-wrap`);if(!t.floor)return c(`no-keys`);let l=await i.loadKeyState(o.id);if(!em(o,Qp(t.floor,l)))return c(`rollback`);let u=o.sharedGeneration>0?s.get(o.keyGeneration):void 0;if(!u||l.digests[o.keyGeneration]!==zi(z(u)))return c(`no-keys`);let d=await e.userIdentity(n.userId);if(!d)return c(`no-identity`);try{ri(d.publicKey)}catch{return c(`invalid-identity`)}let f={...n,identity:{deviceId:d.deviceId,publicKey:d.publicKey}},p=await i.load(),{changed:m}=di(p,[f]);if(m.length){if(await a(m)!==!0)return c(`untrusted`);let e=ui(p,f);if(!await i.confirm(e,m[0].pinned))return c(`pins-unsaved`);p=e.pins}let h=await um(f,o.id,o.keyGeneration,u,{...r.identity,userId:r.userId},p);if(h.fresh.length){let e=await i.addFresh({[f.userId]:d.publicKey});if(!e.ok)return c(e.conflicts.length?`untrusted`:`pins-unsaved`)}await e.stepUp();try{return{invitation:await e.invite(o.id,n.userId,n.role,[{...h.envelope,containerId:o.id}]),keys:`sealed`,recipient:f}}catch(e){if(s_(e)===`already_exists`)return c(`moved`);if(s_(e)===`invalid_request`)return c(`invalid-identity`);throw e}}function d_(e,t,n){return t.filter(t=>t.userId!==n&&f_(t.username).test(e)).map(e=>e.userId)}var f_=e=>RegExp(`(^|\\s)@${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}(?![\\p{L}\\p{N}_-]|\\.[\\p{L}\\p{N}])`,`iu`),p_=/^#\/invite\/(inv_[0-9a-hjkmnp-tv-z]{26})\/([A-Za-z0-9_-]{43})$/,m_=`kynotes-invitation`,h_=(e,t)=>`${e}/#/invite/${t.id}/${t.token}`;function g_(e){let t=p_.exec(e);return t?{id:t[1],token:t[2]}:void 0}var __;function v_(){try{return globalThis.sessionStorage}catch{return}}function y_(e,t,n){let r=g_(e.hash);if(r){__=r;try{n?.setItem(m_,JSON.stringify(r))}catch{}return t.replaceState(null,``,e.pathname),r}}function b_(e){try{let t=JSON.parse(e?.getItem(m_)??`null`),n=t?g_(`#/invite/${t.id}/${t.token}`):void 0;if(n)return n}catch{}return __}function x_(e){__=void 0;try{e?.removeItem(m_)}catch{}}var S_=(e,t)=>e===404&&t===`not_found`||e===409&&t===`already_exists`||e===410;function C_(e){let t=e.stewards.length?e.stewards.join(` or `):`a team owner`,n=e.fingerprint?` My encryption key fingerprint is ${e.fingerprint}; please check it matches what your browser shows for me.`:``;return`Hi ${t}: please open the team notebook "${e.notebook}" in KyNotes so your browser shares its key with me.${n} ${e.link}`}function w_(){let e=0;return{begin(){let t=++e;return{superseded:()=>e!==t}},mark(){let t=e;return()=>e!==t}}}var T_=`unreadable key`,E_=e=>hi(e).catch(()=>T_);function D_({username:e,userID:t,names:n}){let[r,i]=(0,X.useState)(void 0),[a,o]=(0,X.useState)(``),s=e=>n[e.userId]??``,c=(0,X.useMemo)(w_,[]);async function l(){let{superseded:n}=c.begin();try{let r=await Sl(e,t),a=Object.fromEntries(await Promise.all(Object.keys(r).map(async e=>[e,await Lu(e).catch(()=>void 0)]))),o=Object.fromEntries(Object.entries(a).map(([e,t])=>[e,t?.publicKey])),s=await Promise.all(gi(r,o).map(async e=>({...e,pinnedPrint:await E_(e.pinned),currentPrint:e.current===void 0?void 0:await E_(e.current)})));n()||i(s)}catch{n()||o(`This browser could not read the colleague keys it saved.`)}}(0,X.useEffect)(()=>{l()},[e,t]);async function u(n){if(n.current===void 0||n.currentPrint===void 0||n.currentPrint===T_)return;let r=_i(n.userId,n.current,await Lu(n.userId).catch(()=>void 0));if(!r)o(`That colleague's key changed again or could not be read. Check the fingerprint shown now.`),await l();else if(confirm(vi({userId:n.userId,name:s(n),newPrint:n.currentPrint,oldPrint:n.pinnedPrint}))){try{if(!await wl(e,t,ui(await Sl(e,t),r),n.pinned))throw Error(`not stored`)}catch{o(`The new key was not saved: the saved key changed meanwhile, or this browser cannot store it. Check the keys shown now.`),await l();return}o(``),await l()}}return(0,$.jsxs)(`section`,{id:`colleague-keys`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Colleague keys`}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Keys this browser trusts when sharing team notebooks. Fingerprints are computed here, not taken from the server.`}),a&&(0,$.jsx)(`p`,{className:`config-muted`,role:`alert`,children:a}),r?.length===0&&(0,$.jsx)(`p`,{className:`config-muted`,children:`No colleague keys yet. A key is saved the first time you share a team notebook with someone.`}),r?.map(e=>(0,$.jsxs)(`div`,{className:`pin-row`,children:[(0,$.jsx)(`strong`,{children:mi(s(e),e.userId)}),(0,$.jsx)(`code`,{children:e.pinnedPrint}),e.state===`same`&&(0,$.jsx)(`span`,{className:`config-muted`,children:`matches the server`}),e.state===`unseen`&&(0,$.jsx)(`span`,{className:`config-muted`,children:`not visible now (no shared notebook, or no key yet)`}),e.state===`changed`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`config-muted`,children:[`changed to `,(0,$.jsx)(`code`,{children:e.currentPrint})]}),e.currentPrint!==T_&&(0,$.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>void u(e),children:`Trust new key`})]})]},e.userId))]})}async function O_(e,t){let n={shared:t.sharedGeneration??0,generation:t.keyGeneration??0},r=await e.load(t.id).then(e=>e,()=>void 0),i=Qp(r,n);return Am(t.id,i,r!==void 0),i.shared===(r?.shared??0)&&i.generation===(r?.generation??0)&&r||await e.save(t.id,{mark:0,digests:{},...n}).catch(()=>!1),t}var k_=(e,t)=>Promise.all(t.map(t=>O_(e,t))),A_=async e=>k_(e,await tu()),j_=async(e,...t)=>O_(e,await nu(...t)),M_=`The notebook could not get its own key, so it was not created. Try again.`;async function N_(e,t,n){let r=await e();try{return await t(r)}catch(e){throw await n(r.id).then(()=>!0,()=>!1)?Error(M_,{cause:e}):e}}function P_({username:e,userID:t,keysFor:n,waitingHeld:r}){let[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)([]),c=[...i,...o],l=e=>cm(n(e),t=>Nt(t,e.containerID,e.id,e.payload,!0));async function u(){let n=await A_({load:n=>El(e,t,n),save:(n,r)=>Dl(e,t,n,r)}).then(e=>new Set(e.map(e=>e.id)),()=>void 0),i=(await el().catch(()=>[])).filter(e=>e.owner===t),a=Bg(i,n,t),o=new Set(a.map(e=>e.id));return{lost:a,previous:await Ug(i.filter(e=>!o.has(e.id)),t,r,e=>l(e).then(()=>!0,()=>!1))}}let d=async()=>{let e=await u();a(e.lost),s(e.previous)};if((0,X.useEffect)(()=>{d()},[t,r]),!c.length)return(0,$.jsx)(`p`,{className:`config-muted`,children:`No unsent edits on this browser.`});async function f(){let e=await Vg(c,l);e.unreadable===c.length?alert(`None of these edits can be opened in this browser: they are sealed with a notebook key it no longer holds.`):(wp(`kynotes-unsent-edits.json`,e.json,`application/json`),e.unreadable&&alert(`${e.unreadable} edit(s) are sealed with a notebook key this browser no longer holds and were left out.`))}async function p(){if(!confirm(`Delete ${c.length} unsent edit(s) from this browser? They can never be sent and cannot be recovered afterwards. Export them first if you need them.`))return;let e=await u(),n=new Set([...e.lost,...e.previous].map(e=>e.id));for(let e of c)n.has(e.id)&&await nl(e)&&await qc(t,e.id);await d()}return(0,$.jsxs)(`section`,{id:`unsent-edits`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Unsent edits`}),i.length>0&&(0,$.jsxs)(`p`,{className:`config-muted`,children:[i.length,` edit(s) on this device belong to notebooks you can no longer open, so they can never be saved.`]}),o.length>0&&(0,$.jsxs)(`p`,{className:`config-muted`,children:[o.length,` edit(s) on this device are `,`sealed under your previous key`,`: they were waiting for a notebook's key when your encryption key was reset, so they are never sent. Export them to keep their content.`]}),(0,$.jsx)(`p`,{className:`config-muted`,children:`The export is decrypted in this browser and saved as an unencrypted file. Store it somewhere safe and delete it when done.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void f(),children:`Export unsent edits`}),(0,$.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>void p(),children:`Discard unsent edits`})]})}var F_=e=>`share:${e}`;async function I_(e,t,n,r,i){await Wc(e,{id:F_(t),containerID:n,version:0,payload:await Et(r.key,n,t,i),updatedAt:new Date().toISOString(),keyGeneration:r.generation})}async function L_(e,t,n){let r=await Kc(e,F_(t)).catch(()=>void 0);return r?cm(n(r),e=>G(e,r.containerID,t,r.payload)).catch(()=>`unreadable`):`none`}var R_=(e,t)=>qc(e,F_(t)).catch(()=>void 0);function z_({userID:e,keysFor:t}){let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)(``),o=()=>ld().then(n=>Promise.all(n.map(async n=>({...n,label:await L_(e,n.id,t)})))).then(e=>{r(e),a(``)},()=>a(`Unable to load your share links.`));(0,X.useEffect)(()=>{o()},[]);async function s(t){if(confirm(`Revoke the share link ${H_(t)}? Anyone who has it can no longer open it. This cannot be undone.`)){try{await ud(t.id),await R_(e,t.id)}catch(e){a(e instanceof Error?e.message:`Unable to revoke the link.`)}await o()}}return(0,$.jsxs)(`section`,{id:`share-links`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Share links`}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Links you made with Share. Each holds an encrypted copy of the page as it was then, counts toward your storage and stops working when it expires (30 days at most). The server cannot read them; only the browser that made a link knows which page it shares.`}),i&&(0,$.jsx)(`p`,{className:`error`,role:`alert`,children:i}),n?.length===0&&(0,$.jsx)(`p`,{className:`config-muted`,children:`You have no live share links.`}),n?.map(e=>(0,$.jsxs)(`div`,{className:`pin-row`,children:[(0,$.jsxs)(`span`,{children:[V_(e),`: made `,B_(e.createdAt),`, expires `,B_(e.expiresAt),` (`,Math.max(1,Math.round(e.bytes/1024)),` KB)`]}),(0,$.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>void s(e),children:`Revoke`})]},e.id))]})}var B_=e=>new Date(e).toLocaleString(),V_=({label:e})=>e===`none`?`Made on another device`:e===`unreadable`?`Made in this browser, page no longer readable`:`"${e.title}" in ${e.notebook}`,H_=e=>typeof e.label==`object`?`for "${e.label.title}"`:`made ${B_(e.createdAt)}`;function U_(e,t){if(!e||e!==t)return`New passwords do not match.`}var W_=(e,t)=>{if(!e)return;let n=e.find(e=>e.userId===t);return!!(n&&tm(n.role))},G_=`This notebook is read-only until its keys reach this browser.`,K_=`This notebook gets its own key once your encryption key can be recovered. Save a recovery code in Settings first.`,q_=`This notebook is read-only here: this browser does not hold your encryption key. Link it, or restore your key with your recovery code, in Settings.`,J_=`This notebook is read-only until another owner's browser shares its current key with you.`,Y_=`This notebook is read-only until its key is set up. Reopen it to try again.`;function X_(e){return e.steward===void 0?{text:G_}:e.steward?e.held?e.shared?{text:J_,action:`ask`}:e.recoverable?{text:Y_}:{text:K_,action:`settings`}:{text:q_,action:`settings`}:{text:G_,action:`ask`}}var Z_=e=>new Date(e).toLocaleString();function Q_(e){let t=e.filter(e=>e.keyResetAt).sort((e,t)=>Date.parse(t.keyResetAt)-Date.parse(e.keyResetAt))[0];return t&&`${mi(t.username,t.userId)} reset their encryption key on ${Z_(t.keyResetAt)}, which retired this notebook's key; an owner's next open shares a new one.`}var $_=e=>e===!1?`Saved on this device only. It is sent once a team owner shares this notebook's keys; until then, do not clear this browser's data.`:`Saved on this device only. It is sent once this notebook's key reaches this browser; until then, do not clear this browser's data.`;async function ev(e,t,n,r){if(n)return`migrated`;let i=t===0;for(let t of e)if(!(t.type===`page`?!t.v1&&t.legacy:!t.v1))try{let e=t.type===`page`?await r.savePage(t.id,await r.pins(t.id)):await r.saveStructure(t.type,t.id);i&&=e}catch{i=!1}if(!i)return`partial`;let a=!1;for(let t of e)if(t.type===`page`)try{a=await r.legacyConflict(t.id)||a}catch{return`partial`}return a?`conflicts`:await r.mark()?`migrated`:`partial`}var tv=`application/x-kynotes-page`,nv=`application/x-kynotes-section`,rv=`root`;function iv(e){let{sections:t,groups:n,path:r,current:i,busy:a,onSelect:o,onDropPage:s}=e,c=r[r.length-1]?.id,l=c===void 0,u=(e,t)=>{t.some(t=>e.dataTransfer.types.includes(t))&&e.preventDefault()},d=(t,n,r)=>{let i=t.dataTransfer.getData(tv),a=t.dataTransfer.getData(nv);i?s(i,n):a&&n!==`quick`&&e.onMove(`section`,a,r),t.preventDefault()},f=e=>document.getElementById(e)?.hidePopover(),p=(t,n,i,o,s)=>{let u=`${t}-menu-${n.id}`,d=e.moveTargets(t,n.id).filter(e=>e.id!==c);return(0,$.jsxs)(`div`,{className:`section-menu`,id:u,popover:`auto`,style:t===`group`?{positionAnchor:`--group-${n.id}`}:void 0,children:[(0,$.jsx)(`button`,{className:`quiet`,disabled:a,onClick:()=>{f(u),e.onRename(t,n)},children:`Rename`}),(0,$.jsx)(`div`,{className:`section-colors`,role:`group`,"aria-label":t===`section`?`Section color`:`Group color`,children:we.map(r=>(0,$.jsx)(`button`,{className:`section-swatch`,"aria-label":r,"aria-pressed":n.color===r,style:{background:`var(--section-${r})`},disabled:a,onClick:()=>{f(u),e.onColor(t,n,r)}},r))}),(0,$.jsx)(`button`,{className:`quiet`,disabled:a||i===0,onClick:()=>{f(u),e.onMove(t,n.id,i-1)},children:`Move up`}),(0,$.jsx)(`button`,{className:`quiet`,disabled:a||i===o-1,onClick:()=>{f(u),e.onMove(t,n.id,i+1)},children:`Move down`}),(0,$.jsxs)(`select`,{"aria-label":`Move into group`,value:``,disabled:a||l&&!d.length,onChange:r=>{f(u),e.onMoveIntoGroup(t,n.id,r.target.value===rv?void 0:r.target.value)},children:[(0,$.jsx)(`option`,{value:``,disabled:!0,children:`Move into group…`}),!l&&(0,$.jsxs)(`option`,{value:rv,children:[`Top level of `,r[0].title]}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,$.jsx)(`button`,{className:`quiet danger`,disabled:a,onClick:()=>{f(u),s()},children:t===`section`?`Delete section`:`Delete group`})]})},m=(n,r,s,c,l)=>(0,$.jsxs)(`li`,{className:`section-tab-item`,children:[(0,$.jsx)(`button`,{className:`quiet ky-nav-item section-tab${n===`quick`?` section-tab-quick`:``}`,"aria-current":i===n?`true`:void 0,style:{"--tab-color":`var(--section-${s})`},draggable:!!l&&!a,onDragStart:e=>e.dataTransfer.setData(nv,n),onDragOver:e=>u(e,[tv,nv]),onDrop:e=>d(e,n,c),onClick:()=>o(n),children:r||`Untitled section`}),l&&i===n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`quiet section-tab-menu`,popoverTarget:`section-menu-${n}`,"aria-label":`Section options for ${r||`Untitled section`}`,children:`⋯`}),p(`section`,l,c,t.length,()=>e.onDelete(l))]})]},n);return(0,$.jsxs)(`nav`,{id:`section-navigation`,className:`section-tabs`,"aria-label":`Sections`,children:[!l&&(0,$.jsx)(`ol`,{className:`section-breadcrumb`,"aria-label":`Section groups`,children:r.map((t,n)=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{className:`quiet`,"aria-current":n===r.length-1?`location`:void 0,onClick:()=>e.onOpenGroup(t.id),children:t.title})},t.id??rv))}),(0,$.jsxs)(`ul`,{role:`list`,children:[t.map((e,t)=>m(e.id,e.title,e.color,t,e)),l&&m(`quick`,`Quick Notes`,`gray`,t.length),n.map((t,r)=>(0,$.jsxs)(`li`,{className:`section-tab-item`,children:[(0,$.jsxs)(`button`,{className:`quiet ky-nav-item section-tab group-tab`,style:{"--tab-color":`var(--section-${t.color})`},onDragOver:e=>u(e,[nv]),onDrop:n=>{let r=n.dataTransfer.getData(nv);r&&e.onMoveIntoGroup(`section`,r,t.id),n.preventDefault()},onClick:()=>e.onOpenGroup(t.id),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`📁 `}),t.title||`Untitled group`]}),(0,$.jsx)(`button`,{className:`quiet section-tab-menu`,style:{anchorName:`--group-${t.id}`},popoverTarget:`group-menu-${t.id}`,"aria-label":`Group options for ${t.title||`Untitled group`}`,children:`⋯`}),p(`group`,t,r,n.length,()=>e.onDeleteGroup(t))]},t.id)),!l&&!t.length&&!n.length&&(0,$.jsx)(`li`,{className:`section-empty`,children:`This group is empty. Add a section from the notebook menu.`})]})]})}var av=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function ov(e,t=new Date){let n=new Date(e);if(!e||Number.isNaN(n.getTime()))return``;let r=Math.round((av(t)-av(n))/864e5);return r<=0?n.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):r===1?`Yesterday`:r<7?n.toLocaleDateString([],{weekday:`long`}):n.toLocaleDateString([],n.getFullYear()===t.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`})}function sv(e,t=new DOMParser){return cv(t.parseFromString(e,`text/html`))}function cv(e=globalThis.document){return[...e.querySelectorAll(`script[src], link[rel~="stylesheet"][href]`)].filter(e=>!e.closest(`noscript`)).map(e=>e.getAttribute(e.localName===`script`?`src`:`href`)).filter(Boolean)}function lv({name:e=`This app`,url:t=`/`,interval:n=3e5,doc:r=globalThis.document,fetch:i=globalThis.fetch}={}){let a=r.defaultView??globalThis,o=cv(r).join(` -`),s=Date.now(),c=!1,l=!1,u=null,d=async()=>{if(c||u||r.visibilityState===`hidden`||a.navigator?.onLine===!1||Date.now()-se.abort(),3e4);try{let n=await i(t,{cache:`no-store`,credentials:`same-origin`,redirect:`manual`,headers:{Accept:`text/html`},signal:e.signal});if(!n.ok||!/text\/html/i.test(n.headers.get(`content-type`)??``))return;let r=sv(await n.text(),new a.DOMParser);!l&&r.length&&o&&r.join(` -`)!==o&&f()}catch{}finally{a.clearTimeout(d),c=!1}},f=()=>{h(),u=r.createElement(`div`),u.className=`ky-update`,u.setAttribute(`role`,`status`);let t=r.createElement(`p`);t.className=`ky-update-text`;let n=r.createElement(`button`);n.type=`button`,n.className=`ky-update-reload`,n.textContent=`Reload`,n.addEventListener(`click`,()=>a.location.reload());let i=r.createElement(`button`);i.type=`button`,i.className=`ky-update-dismiss`,i.setAttribute(`aria-label`,`Dismiss`),i.title=`Dismiss`,i.textContent=`×`,i.addEventListener(`click`,()=>{u.remove()}),u.append(t,n,i),r.body.append(u),t.textContent=`${e} was updated. Reload to use the new version.`},p=()=>{r.visibilityState===`visible`&&d()},m=a.setInterval(d,n);r.addEventListener(`visibilitychange`,p),a.addEventListener(`focus`,d),a.addEventListener(`online`,d);function h(){a.clearInterval(m),r.removeEventListener(`visibilitychange`,p),a.removeEventListener(`focus`,d),a.removeEventListener(`online`,d)}return()=>{l=!0,h(),u?.remove()}}var uv=`kynotes.blocknote.v1`;function dv(e=[]){return e.flatMap(e=>{if(e.type===`hardBreak`)return[{type:`text`,text:` -`}];if(e.type!==`text`||typeof e.text!=`string`)return dv(e.content);let t={},n;for(let r of e.marks??[])r.type===`bold`&&(t.bold=!0),r.type===`italic`&&(t.italic=!0),r.type===`strike`&&(t.strike=!0),r.type===`code`&&(t.code=!0),r.type===`underline`&&(t.underline=!0),r.type===`link`&&typeof r.attrs?.href==`string`&&(n={href:r.attrs.href,content:[{type:`text`,text:e.text,styles:t}]});return n?[{type:`link`,...n}]:[{type:`text`,text:e.text,styles:t}]})}function fv(e=[]){return e.flatMap(e=>{let t=dv(e.content);switch(e.type){case`paragraph`:return[{type:`paragraph`,content:t}];case`heading`:return[{type:`heading`,props:{level:Number(e.attrs?.level)||1},content:t}];case`bulletList`:return pv(e.content,`bulletListItem`);case`orderedList`:return pv(e.content,`numberedListItem`);case`blockquote`:return[{type:`quote`,children:fv(e.content)}];case`codeBlock`:return[{type:`codeBlock`,props:{language:typeof e.attrs?.language==`string`?e.attrs.language:``},content:e.content?.map(e=>e.text??``).join(``)??``}];case`image`:return[{type:`image`,props:{url:typeof e.attrs?.src==`string`?e.attrs.src:``,name:typeof e.attrs?.alt==`string`?e.attrs.alt:``}}];case`horizontalRule`:return[{type:`divider`}];default:return e.content?fv(e.content):[]}})}function pv(e=[],t){return e.filter(e=>e.type===`listItem`).map(e=>{let n=fv(e.content);return{...n[0]??{type:`paragraph`,content:``},type:t,children:n.slice(1)}})}function mv(e){let t=e,n=t?.format===`kynotes.tiptap.v1`?t.document:t;if(n?.type===`doc`)return fv(n.content)}function hv(e){try{return mv(JSON.parse(e))}catch{return}}var gv=()=>({format:uv,document:[{type:`paragraph`,content:``}]}),_v=`kynotes.canvas.v1`,vv=`legacy`,yv=1e5,bv=5e3,xv=1e4,Sv=2e3,Cv=[`ink`,`blue`,`red`,`green`,`orange`,`yellow`],wv=/^[A-Za-z0-9-]{1,64}$/,Tv=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ev=(e,t,n,r)=>typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r;function Dv(e){if(!Tv(e)||typeof e.id!=`string`||!wv.test(e.id))return;let t=Array.isArray(e.blocks)?e.blocks.filter(Tv):[];return{id:e.id,x:Ev(e.x,0,yv,0),y:Ev(e.y,0,yv,0),width:Ev(e.width,160,Sv,640),blocks:t.length?t:gv().document}}function Ov(e){if(!Tv(e)||typeof e.id!=`string`||!wv.test(e.id)||!Array.isArray(e.points))return;let t=e.points.slice(0,xv*3),n=[];for(let e=0;e+2typeof e==`number`&&Number.isFinite(e))&&n.push(Ev(r,0,yv,0),Ev(i,0,yv,0),Ev(a,0,1,.5))}if(n.length)return{id:e.id,tool:e.tool===`highlighter`?`highlighter`:`pen`,color:Cv.includes(e.color)?e.color:`ink`,size:Ev(e.size,1,64,4),points:n}}function kv(e,t,n){let r=new Set,i=[];for(let a of Array.isArray(e)?e.slice(0,t):[]){let e=n(a);e&&!r.has(e.id)&&(r.add(e.id),i.push(e))}return i}var Av=()=>({format:_v,boxes:[],strokes:[]});function jv(e){let t;try{t=JSON.parse(e)}catch{}if(Tv(t)&&t.format===`kynotes.canvas.v1`)return{format:_v,boxes:kv(t.boxes,500,Dv),strokes:kv(t.strokes,bv,Ov)};let n={id:vv,x:0,y:0,width:640,blocks:Fv(e).document};return{...Av(),boxes:[n],legacyMarkdown:e&&!Bv(e)?e:void 0}}var Mv=({boxes:e,strokes:t})=>JSON.stringify({format:_v,boxes:e,strokes:t});function Nv(e){let t;try{t=JSON.parse(e)}catch{return}return Tv(t)&&t.format===`kynotes.canvas.v1`?kv(t.boxes,500,Dv).sort((e,t)=>e.y-t.y||e.x-t.x).flatMap(e=>e.blocks):Tv(t)&&t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document)?t.document:mv(t)}var Pv=e=>Nv(e)??Fv(e).document;function Fv(e){try{let t=JSON.parse(e);if(t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document))return{format:uv,document:t.document}}catch{}let t=hv(e);return t?{format:uv,document:t.length?t:gv().document}:e?{format:uv,document:[{type:`paragraph`,content:e}]}:gv()}function Iv(e){let t=[],n=e=>{if(typeof e.content==`string`&&t.push(e.content),Array.isArray(e.content)){let n=e=>{typeof e==`object`&&e&&(`text`in e&&typeof e.text==`string`&&t.push(e.text),`content`in e&&Array.isArray(e.content)&&e.content.forEach(n))};e.content.forEach(n)}e.type===`image`&&typeof e.props?.name==`string`&&t.push(`[${e.props.name}]`),e.children?.forEach(n)};try{Pv(e).forEach(n)}catch{return``}return t.join(` `)}var Lv=e=>jv(e).strokes.length>0,Rv=e=>Lv(e)?Mv({...jv(e),strokes:[]}):e,zv=e=>Lv(e)&&Iv(e).trim()===``;function Bv(e){try{let t=JSON.parse(e);if(t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document)||t.format===`kynotes.canvas.v1`)return!0}catch{}return hv(e)!==void 0}var Vv=[[`overdue`,`Overdue`],[`today`,`Today`],[`upcoming`,`Upcoming`],[`later`,`Later`],[`undated`,`No date`]],Hv=(e,t=2)=>String(e).padStart(t,`0`),Uv={daily:{unit:`day`,every:1},weekly:{unit:`week`,every:1},monthly:{unit:`month`,every:1},yearly:{unit:`year`,every:1}};function Wv(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=t.slice(1).map(Number),a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i}function Gv(e){if(Uv[e])return Uv[e];let t=/^every-(\d{1,3})-(days|weeks)$/.exec(e),n=Number(t?.[1]);return t&&n>=1&&n<=365?{unit:t[2]===`days`?`day`:`week`,every:n}:void 0}function Kv(e){let t=[];for(let n of e.matchAll(/\S+/g)){let e=/^(due|repeat|remind|push):(\S+)$/.exec(n[0]);if(!e||t.some(t=>t.key===e[1]))continue;let[,r,i]=e;(r===`due`?Wv(i):r===`repeat`?Gv(i):r===`push`?i===`yes`:/^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):[0-5]\d$/.test(i)&&Wv(i.slice(0,10)))&&t.push({key:r,value:i,start:n.index,end:n.index+n[0].length})}return t}function qv(e){let t={text:``},n=e;for(let r of Kv(e).reverse())r.key===`repeat`?t.repeat=Gv(r.value):r.key===`push`?t.push=!0:t[r.key]=r.value,n=n.slice(0,r.start)+n.slice(r.end);return t.text=n.replace(/\s+/g,` `).trim(),t.remind||delete t.push,t}function Jv(e){return`${e.getFullYear()}-${Hv(e.getMonth()+1)}-${Hv(e.getDate())}`}function Yv(e,t){let[n,r,i]=e.split(`-`).map(Number);if(t.unit===`day`||t.unit===`week`){let e=new Date(Date.UTC(n,r-1,i+t.every*(t.unit===`week`?7:1)));return`${Hv(e.getUTCFullYear(),4)}-${Hv(e.getUTCMonth()+1)}-${Hv(e.getUTCDate())}`}let a=r-1+t.every*(t.unit===`year`?12:1),o=n+Math.floor(a/12),s=a%12,c=new Date(Date.UTC(o,s+1,0)).getUTCDate();return`${Hv(o,4)}-${Hv(s+1)}-${Hv(Math.min(i,c))}`}function Xv(e,t){return e.repeat?{due:Yv(e.due??t,e.repeat),remind:e.remind&&`${Yv(e.remind.slice(0,10),e.repeat)}${e.remind.slice(10)}`}:{}}function Zv(e){let[t,n,r]=e.slice(0,10).split(`-`).map(Number);return new Date(t,n-1,r,Number(e.slice(11,13)),Number(e.slice(14,16))).getTime()}function Qv(e,t,n=!1){if(n)return`overdue`;if(!e.due)return`undated`;let r=Jv(t);return e.duet?a.next=Math.min(a.next??e,e):i&&e>n?a.fire.push(o):a.missed.add(o)}return a}var ey=100;function ty(e,t){let n=e.map(e=>typeof e.text==`string`).lastIndexOf(!0),r=0;return e.map((e,i)=>{if(typeof e.text!=`string`)return e;let a=r;r+=e.text.length;let o=``;for(let s=a;ss>=e.start&&se.text!==``)}var ny=e=>e.map(e=>typeof e.text==`string`?e.text:``).join(``),ry=(e,t)=>{let n=+!!/\s$/.test(e.slice(0,t.start)),r=n||!/^\s/.test(e.slice(t.end))?0:1;return{start:t.start-n,end:t.end+r}};function iy(e,t){let n=[],r=(e,i)=>{if(!(i>ey)){if(e.type===`checkListItem`&&e.props?.checked===!0&&e.id&&Array.isArray(e.content)){let r=e.content,i=ny(r),a=Kv(i),o=a.find(e=>e.key===`repeat`);if(o){let s=Xv(qv(i),t),c=a.flatMap(({key:e,start:t,end:n})=>e===`repeat`||e===`push`?[]:[{start:t,end:n,text:`${e}:${s[e]}`}]);a.some(e=>e.key===`due`)||c.push({start:i.length,end:i.length,text:`${/\S$/.test(i)?` `:``}due:${s.due}`}),n.push({id:e.id,content:ty(r,[{...ry(i,o),text:``}]),next:{type:`checkListItem`,props:{checked:!1},content:ty(r,c)}})}}e.children?.forEach(e=>r(e,i+1))}};return e.forEach(e=>r(e,0)),n}var ay=100,oy=new WeakMap,sy=new WeakMap,cy=new WeakMap;function ly(e){return e.map(e=>{let t=oy.get(e);return t||(t={id:e.id,title:e.title,updatedAt:e.updatedAt,body:Iv(e.body),sourceBody:e.body,note:e},oy.set(e,t)),t})}function uy(e){return[...e.body.matchAll(/\[\[([^\]]+)\]\]/g)].map(e=>e[1].trim()).filter(Boolean)}function dy(e){return[...e.body.matchAll(/(?:^|\s)#([a-zA-Z0-9_-]+)/g)].map(e=>e[1].toLowerCase())}function fy(e){let t=sy.get(e);return t||(t=my(e.sourceBody??e.body),sy.set(e,t)),t}function py(e){let t=cy.get(e);return t||(t=fy(e).map(e=>({...qv(e),raw:e})),cy.set(e,t)),t}function my(e){try{return hy(e)}catch{return[]}}function hy(e){let t=[],n=Nv(e);if(n){let e=e=>Array.isArray(e)?e.map(e=>typeof e==`object`&&e&&`text`in e&&typeof e.text==`string`?e.text:``).join(``):typeof e==`string`?e:``,r=(n,i=0)=>{if(!(i>ay||typeof n!=`object`||!n)){if(n.type===`checkListItem`&&n.props?.checked!==!0){let r=e(n.content).trim();r&&t.push(r)}if(n.type===`bulletListItem`){let r=e(n.content).trim().match(/^\[ \] (.+)$/)?.[1];r&&t.push(r.trim())}Array.isArray(n.children)&&n.children.forEach(e=>r(e,i+1))}};return n.forEach(e=>r(e)),t}return e.split(` -`).filter(e=>/^\s*- \[ \] /.test(e)).map(e=>e.replace(/^\s*- \[ \] /,``).trim())}function gy(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>`${e.title}\n${e.body}`.toLowerCase().includes(n)):e}function _y(e){return e.filter(e=>fy(e).length>0)}function vy(e,t){if(!t)return _y(e).slice(0,5);let n=new Set(uy(t));return e.filter(e=>e.id!==t.id&&(n.has(e.id)||fy(e).length>0||dy(e).some(e=>dy(t).includes(e)))).slice(0,5)}function yy(e){let t=new Set(e.map(e=>e.id));return e.flatMap(e=>uy(e).filter(e=>t.has(e)).map(t=>({from:e.id,to:t})))}var by=`kynotes-reminders`,xy=`kynotes-reminder-text`,Sy=`kynotes-reminder-push`,Cy=864e5,wy=Date.now(),Ty={display:`flex`,alignItems:`center`,gap:10,marginTop:16},Ey=()=>typeof Notification<`u`&&Notification.permission===`granted`,Dy=()=>typeof navigator<`u`&&`serviceWorker`in navigator&&typeof PushManager<`u`,Oy=(e,t)=>zf(`${e}:${t}`)===`on`;function ky(e){return{enabled:Oy(by,e)&&Ey(),showText:Oy(xy,e),push:Oy(Sy,e)&&Ey()&&Dy()}}function Ay(e,t){Bf(`${by}:${e}`,t.enabled?`on`:`off`),Bf(`${xy}:${e}`,t.showText?`on`:`off`),Bf(`${Sy}:${e}`,t.push?`on`:`off`)}var jy=e=>Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),My=(e,t)=>e!==null&&e.byteLength===t.length&&new Uint8Array(e).every((e,n)=>e===t[n]);async function Ny(){await navigator.serviceWorker.register(`/sw.js`,{scope:`/`});let e=await navigator.serviceWorker.ready,t=jy((await pd()).publicKey),n=await e.pushManager.getSubscription();n&&!My(n.options.applicationServerKey,t)&&(await n.unsubscribe(),n=null),n??=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),await md(n.endpoint)}async function Py(){if(!Dy())return;let e=await(await navigator.serviceWorker.getRegistration(`/`))?.pushManager.getSubscription();if(e)try{await hd(e.endpoint)}finally{await e.unsubscribe()}}function Fy(e,t){let n=(0,X.useRef)(new Set),[r,i]=(0,X.useState)(0),a=t.enabled&&Ey(),o=$v(e,Date.now(),wy,n.current,a);return(0,X.useEffect)(()=>{for(let r of o.fire){if(n.current.has(r))continue;n.current.add(r);let i=e.find(e=>e.key===r)?.text;new Notification(`KyNotes`,{body:t.showText&&i?`A task is due: ${i}`:`A task is due`,tag:r})}if(o.next===void 0)return;let r=window.setTimeout(()=>i(e=>e+1),Math.min(Math.max(o.next-Date.now(),0),Cy));return()=>window.clearTimeout(r)},[e,a,t.showText,r]),o.missed}function Iy({userID:e,prefs:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=t=>{Ay(e,t),n(t)};async function c(e){if(i(!1),!e)return s({...t,enabled:!1});(typeof Notification>`u`?`denied`:await Notification.requestPermission())===`granted`?s({...t,enabled:!0}):i(!0)}async function l(e){i(!1),o(``);try{if(!e)return s({...t,push:!1}),await Py();if(!Dy())return o(`This browser cannot receive pushes for KyNotes.`);if(await Notification.requestPermission()!==`granted`)return i(!0);await Ny(),s({...t,push:!0})}catch(e){o(e instanceof Error?`Push reminders failed: ${e.message}`:`Push reminders failed.`)}}return(0,$.jsxs)(`section`,{id:`reminders`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Reminders`}),(0,$.jsxs)(`p`,{className:`config-muted`,children:[`Tasks with `,(0,$.jsx)(`code`,{children:`remind:2026-11-01T09:00`}),` notify you in this browser while a KyNotes tab is open. Reminders that pass with no tab open show as missed in the work queue.`]}),(0,$.jsxs)(`label`,{style:Ty,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:e=>void c(e.target.checked)}),(0,$.jsx)(`span`,{children:`Show reminders while KyNotes is open`})]}),(0,$.jsxs)(`label`,{style:Ty,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.showText,onChange:e=>s({...t,showText:e.target.checked})}),(0,$.jsx)(`span`,{children:`Show task text in reminders`})]}),(0,$.jsx)(`p`,{className:`config-muted`,children:`With task text off, a reminder says only "A task is due", so nothing from your notes shows on a locked screen.`}),(0,$.jsxs)(`label`,{style:Ty,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.push,onChange:e=>void l(e.target.checked)}),(0,$.jsx)(`span`,{children:`Also remind me when KyNotes is closed (sends reminder times to the server)`})]}),(0,$.jsxs)(`p`,{className:`config-muted`,children:[`For tasks you mark `,(0,$.jsx)(`code`,{children:`push:yes`}),`, the server learns each reminder's time and how many you have, never which task, and your browser's push service (Google, Mozilla, Apple or Microsoft) sees an empty push arrive; the notification says only "A reminder is due".`]}),a&&(0,$.jsx)(`p`,{role:`status`,children:a}),r&&(0,$.jsx)(`p`,{role:`status`,children:`This browser blocked notifications for KyNotes. Allow them in the site settings, then try again.`})]})}var Ly=`0123456789abcdefghjkmnpqrstvwxyz`;function Ry(e,t,n){let r=T(z,e,new TextEncoder().encode(`${t}\n${n}`)),i=0n;for(let e of r.subarray(0,17))i=i<<8n|BigInt(e);i>>=6n;let a=``;for(let e=0;e<26;e+=1,i>>=5n)a=Ly[Number(i&31n)]+a;return a}var zy=e=>`${new Date(Zv(e)).toISOString().slice(0,16)}:00Z`;function By(e,t,n){let r=new Map;for(let i of t){if(!i.push||!i.remind||Zv(i.remind)<=n)continue;let t=Ry(e,i.noteID,i.remind);r.set(t,{id:t,at:zy(i.remind)})}return[...r.values()].sort((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id)).slice(0,500)}function Vy(e,t,n,r){if(!n)return{puts:[],deletes:[]};let i=new Map(t.map(e=>[e.id,e.at])),a=new Set(e.map(e=>e.id)),o=r&&new Map(r.map(e=>[e.id,e.at]));return{puts:e.filter(e=>i.get(e.id)!==e.at&&(!o||o.get(e.id)!==e.at)),deletes:t.filter(e=>!a.has(e.id)&&(!o||o.has(e.id))).map(e=>e.id)}}var Hy=15e3;function Uy(e,t=Date.now()){return t-egl(e,t),save:(n,r)=>pl(e,t,n,r)},t,n,r)}catch{}}var qy=100,Jy=`This notebook's upgrade to the current encryption format is waiting on pages with conflicting versions saved by an older KyNotes. Open each page that says another device saved it first and choose Keep the other version as a copy; the upgrade finishes on a later visit. Until then, the notebook keeps working as it is.`,Yy=`You can read this notebook but not change its pages: your role here is viewer or commenter.`,Xy=`You can no longer edit the page an unsent edit belongs to, so it cannot be saved. It is kept under Settings → Unsent edits, where you can export or discard it.`,Zy=`Your role in this notebook could not be loaded, so it is read-only for now. Reopen the notebook to try again.`,Qy=`A page you edited was deleted elsewhere, so the edit cannot be saved to it. It is kept under Settings → Unsent edits, where you can export or discard it.`,$y=5,eb=`The export is not encrypted: anyone who gets the file can read these notes and attachments.`,tb=`Deleting a notebook needs a sign-in from the last 5 minutes. Sign out now, sign in again, then delete it?`;function nb(e,t){return`Delete "${e}"? This deletes ${t?`its pages, comments and attachments, and every notebook in this team with theirs,`:`its pages, comments and attachments`} for every member. It cannot be undone.\n\nType the notebook's name to confirm.`}var rb=`kynotes-chunk-reload`,ib=e=>{try{return e===null?sessionStorage.removeItem(rb):e!==void 0&&sessionStorage.setItem(rb,e),sessionStorage.getItem(rb)}catch{return null}},ab=(0,X.lazy)(()=>uo(()=>import(`./CanvasPage-f0oQsOxU.js`).then(e=>(ib(null),e),e=>{if(!navigator.onLine||ib()===location.href||ib(location.href)!==location.href)throw e;return location.reload(),new Promise(()=>{})}),__vite__mapDeps([0,1,2,3]))),ob=class extends X.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,$.jsxs)(`div`,{className:`editor-loading`,role:`alert`,children:[(0,$.jsxs)(`p`,{children:[navigator.onLine?`This page's editor could not be loaded.`:`This page's editor could not be loaded while offline.`,` Your other pages and unsent edits are safe. Reload once you are connected.`]}),(0,$.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>{ib(null),location.reload()},children:`Reload`})]}):this.props.children}},sb=`The server reported an older key state for this notebook than this device has seen; writes are paused.`,cb=`The server sent an older copy of a notebook's encrypted name than this device has seen (from before its encryption upgrade); it is not shown. Rename the notebook to replace it.`,lb=`The notebook was created, but its key is not set up yet. Open it again to finish.`,ub=`This browser does not hold your encryption key, so it cannot create a notebook. Link it, or restore your key with your recovery code, in Settings.`,db=`Saved to the server, but this browser could not keep its local copy (site storage may be full or blocked).`;function fb(e,t){return e===`link`?` Link it from a browser that does, under Phones & apps.`:e===`create`?t?` Set up your encryption key from the notebook list.`:` Sign in with your password to create it.`:``}var pb=`Forget this device and sign out? This browser's copy of your encryption key and your colleague key pins are removed. To get the key back here, link this browser from another one or enter your recovery code (or sign in with your password, if it still unlocks your key; accounts that use KySignOn have no password copy). Unsent edits stay on this browser until they are sent, or until you discard them under Unsent edits.`,mb=e=>({derive:async t=>{let n=await Wl(e);return ut(t,n.loginSalt,n.iterations,Yd(e))},stepUp:e=>_u(e)}),hb={"has-key":`has key`,waiting:`waiting for key`,"no-identity":`no encryption key yet`,unapproved:`awaiting approval`},gb=`An administrator created this team notebook for you. Name it so its members can find it.`,_b=e=>`${e} was added by an administrator. They get this notebook's keys only after you approve them.`,vb={"cannot-wrap":`The invitation carries no keys: this browser cannot share keys at invitation time (it holds no encryption key, or you signed in with single sign-on). A team owner's browser shares them after the person joins.`,rollback:`The invitation carries no keys: the server reports an older sharing state for this team than this browser has seen.`,"no-keys":`The invitation carries no keys: this browser holds none for this team yet. A team owner's browser shares them after the person joins.`,"no-identity":`The invitation carries no keys: you cannot see this person's encryption key yet. A team owner's browser shares them after they join.`,"invalid-identity":`The invitation carries no keys: this person's encryption key could not be used. A team owner's browser shares them after they join.`,untrusted:`The invitation carries no keys: you did not confirm this person's new encryption key.`,"pins-unsaved":`The invitation carries no keys: this browser could not save this person's key. Allow site storage.`,moved:`The invitation carries no keys: this team's key changed meanwhile. A team owner's browser shares the new one after the person joins.`};function yb(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0);(0,X.useEffect)(()=>{qf(),Ql().then(async e=>{e.user?.username&&(e.user.accountKind===`admin`||e.passwordChangeRequired?t({username:e.user.username,authSecret:``,user:e.user,sso:e.sso,passwordChangeRequired:e.passwordChangeRequired}):e.sso?(await ol(e.user.username).catch(()=>void 0),t({username:e.user.username,authSecret:``,user:e.user,sso:!0})):(r(e.user),await vl(e.user.username)&&t({username:e.user.username,authSecret:``,user:e.user})))}).catch(()=>{r(null)}).finally(()=>a(!1))},[]);let o=e?.user.id;if((0,X.useEffect)(()=>{if(!o||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`kynotes-account`);return e.onmessage=e=>{e.data!==o&&location.reload()},e.postMessage(o),()=>e.close()},[o]),i)return(0,$.jsx)(`main`,{className:`center`,children:`Loading KyNotes…`});if(location.pathname.startsWith(`/share/`))return(0,$.jsx)(bb,{});let s=()=>Py().catch(()=>void 0).then(eu),c=()=>{s().finally(()=>{jm(),t(null),r(null)})};return e?.passwordChangeRequired?(0,$.jsx)(Db,{auth:e,onChanged:n=>t({...e,authSecret:e.user.accountKind===`admin`?``:n,passwordChangeRequired:!1}),onLogout:c}):e?.user.accountKind===`admin`?(0,$.jsx)(mp,{deployment:e.user.tenancy===`multi`?`multi`:`single`,username:e.username,sso:e.sso===!0,onLogout:c,password:(0,$.jsx)(wb,{username:e.username,userID:e.user.id,everyday:!1,onAuthSecret:()=>{},onIdentityCreated:()=>{}})}):e?(0,$.jsx)(Cb,{auth:e,onAuthSecret:e=>t(t=>t&&{...t,authSecret:e}),onLogout:c,onForgetDevice:()=>{Ol(e.username).then(()=>{s().finally(()=>{jm(),t(null),r(null)})})}}):(0,$.jsx)(xb,{sessionUser:n,onClearSession:()=>{s().finally(()=>r(null))},onForgetDevice:e=>{Ol(e).then(()=>{s().finally(()=>r(null))})},onLogin:t})}function bb(){let[e,t]=(0,X.useState)({});return(0,X.useEffect)(()=>{let e=location.pathname.split(`/`).pop()??``,n=location.hash.slice(1);!e||!n?t({error:`This link is missing its decryption key.`}):dd(e).then(e=>Lt(e,n)).then(e=>t({note:e})).catch(e=>t({error:e instanceof Error?e.message:`Unable to decrypt this note.`}))},[]),e.error?(0,$.jsx)(Sb,{tagline:`Private notes on your own server.`,children:(0,$.jsxs)(`div`,{className:`ky-auth-card`,children:[(0,$.jsx)(`h2`,{children:`Encrypted link unavailable`}),(0,$.jsx)(`p`,{className:`error`,children:e.error})]})}):e.note?(0,$.jsx)(`main`,{className:`shared-page`,children:(0,$.jsxs)(`article`,{className:`shared-note`,children:[(0,$.jsx)(`p`,{className:`shared-note-source`,children:`Shared from KyNotes · encrypted link`}),(0,$.jsx)(`h1`,{children:e.note.title}),(0,$.jsx)(`div`,{className:`shared-note-body`,children:Iv(e.note.body)})]})}):(0,$.jsx)(`main`,{className:`center`,children:`Decrypting encrypted note…`})}function xb({onLogin:e,sessionUser:t,onClearSession:n,onForgetDevice:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(()=>t?.username??``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(`admin`),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(null);(0,X.useEffect)(()=>{Hl().then(e=>{e.setupRequired&&a(!0)}).catch(()=>{}),Kl().then(D).catch(()=>{})},[]),(0,X.useEffect)(()=>{t?.username&&s(t.username)},[t]);async function O(t){t.preventDefault();let n=Cp({admin:f,adminPassword:c,adminConfirm:u,everyday:m,everydayPassword:g,everydayConfirm:v});if(n)x(n);else{x(``),C(!0);try{let t=async(e,t)=>{let n=ft();return{username:e.trim(),authSecret:(await ut(t,n,6e5)).authSecret,loginSalt:n,iterations:6e5}},n=await Ul(await t(f,c),await t(m,g),w);e({username:f.trim(),authSecret:``,user:n.user})}catch(e){x(e instanceof Error?e.message:`Setup failed`)}finally{C(!1)}}}async function k(n){n.preventDefault(),x(``),C(!0);try{let n=o.trim()||t?.username||``,r=await Wl(n),i=await ut(c,r.loginSalt,r.iterations,Yd(n)),a=i.authSecret,s=await Gl(n,a);r.iterations>=6e5&&Xd(n);let{keys:u,identity:d}=r.iterations<6e5&&!s.passwordChangeRequired?await Gy(n,s.user.id,c,i,s.identity):{keys:i,identity:s.identity},f=s.user.accountKind===`user`;f&&!s.passwordChangeRequired&&(await sl(async()=>s,n),await Ky(n,s.user.id,u,d)),e({username:n,authSecret:f?u.authSecret:``,user:s.user,passwordChangeRequired:s.passwordChangeRequired}),l(``)}catch(e){x(e instanceof Error?e.message:`Unable to sign in`)}finally{C(!1)}}return i?(0,$.jsx)(Sb,{tagline:`Private notes on your own server.`,help:`Each password stays in this browser. It derives that account's sign-in verifier and is never sent to or stored on the server.`,children:(0,$.jsxs)(`form`,{className:`ky-auth-card setup-form`,onSubmit:O,children:[(0,$.jsx)(`h2`,{children:`Set up KyNotes`}),(0,$.jsx)(`p`,{className:`setup-lede`,children:`Create two accounts: one to run the server and one to write notes with.`}),(0,$.jsxs)(`label`,{children:[`Setup token`,(0,$.jsx)(`input`,{autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value),required:!0})]}),(0,$.jsxs)(`p`,{className:`setup-hint`,children:[`Proves you run this server. Find it in the server's startup log (`,(0,$.jsx)(`code`,{children:`docker compose logs kynotes-server`}),`) or in `,(0,$.jsx)(`code`,{children:`secrets/setup.token`}),` in its data volume.`]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsx)(`legend`,{children:`Administrator login`}),(0,$.jsx)(`p`,{className:`setup-hint`,children:`Manages users, teams, sign-on and backups. It cannot open notes.`}),(0,$.jsxs)(`label`,{children:[`Administrator username`,(0,$.jsx)(`input`,{autoComplete:`username`,value:f,onChange:e=>p(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Administrator password`,(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Confirm administrator password`,(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:u,onChange:e=>d(e.target.value),required:!0})]})]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsx)(`legend`,{children:`Everyday login`}),(0,$.jsx)(`p`,{className:`setup-hint`,children:`The account you write notes with.`}),(0,$.jsxs)(`label`,{children:[`Everyday username`,(0,$.jsx)(`input`,{autoComplete:`off`,value:m,onChange:e=>h(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Everyday password`,(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:g,onChange:e=>_(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{children:[`Confirm everyday password`,(0,$.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:v,onChange:e=>y(e.target.value),required:!0})]})]}),b&&(0,$.jsx)(`p`,{className:`error`,role:`alert`,children:b}),(0,$.jsx)(`button`,{className:`ky-auth-submit`,disabled:S,children:S?`Initializing…`:`Initialize KyNotes`})]})}):(0,$.jsx)(Sb,{tagline:`Private notes on your own server.`,help:`Your notes are encrypted in this browser before they leave it, and your password never leaves it.`,children:(0,$.jsxs)(`div`,{className:`ky-auth-card`,children:[t&&(0,$.jsxs)(`p`,{className:`auth-session`,role:`status`,children:[`Signed in as `,(0,$.jsx)(`strong`,{children:t.username||t.id}),`. Enter your password to keep using KyNotes in this browser.`,n&&(0,$.jsx)(`button`,{type:`button`,className:`ky-auth-link`,onClick:n,children:`Sign out`})]}),(0,$.jsxs)(`form`,{onSubmit:k,children:[!t&&(0,$.jsxs)(`div`,{className:`ky-auth-field`,children:[(0,$.jsx)(`label`,{htmlFor:`login-username`,children:`Username`}),(0,$.jsx)(`input`,{id:`login-username`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,value:o,onChange:e=>s(e.target.value),required:!0})]}),(0,$.jsxs)(`div`,{className:`ky-auth-field`,children:[(0,$.jsx)(`label`,{htmlFor:`login-password`,children:`Password`}),(0,$.jsx)(`input`,{id:`login-password`,type:`password`,autoComplete:`current-password`,value:c,onChange:e=>l(e.target.value),required:!0,autoFocus:!!t})]}),b&&(0,$.jsx)(`p`,{className:`error`,role:`alert`,children:b}),(0,$.jsx)(`p`,{className:`ky-auth-check`}),(0,$.jsxs)(`button`,{className:`ky-auth-submit`,disabled:S,children:[(0,$.jsx)(df,{name:`signin`}),S?`Signing in…`:`Sign in`]})]}),!t&&E?.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`hr`,{className:`ky-auth-divider`}),(0,$.jsx)(`a`,{className:`ky-auth-sso`,href:`/api/v1/auth/oidc/login`,children:`Continue with single sign-on`})]})]})})}function Sb({tagline:e,help:t,children:n}){return(0,$.jsxs)(`main`,{className:`ky-auth`,children:[(0,$.jsx)(`div`,{className:`ky-auth-theme`,children:(0,$.jsx)(Xf,{})}),(0,$.jsxs)(`div`,{className:`ky-auth-body`,children:[(0,$.jsxs)(`div`,{className:`ky-auth-brand`,children:[(0,$.jsx)(ff,{size:56}),(0,$.jsx)(`h1`,{children:`KyNotes`}),(0,$.jsx)(`p`,{children:e})]}),n,t&&(0,$.jsx)(`p`,{className:`ky-auth-help`,children:t})]})]})}function Cb({auth:e,onLogout:t,onForgetDevice:n,onAuthSecret:r}){let[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),d=(0,X.useRef)(null),f=Sf(),[p,m]=(0,X.useState)({}),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)([]),y=(0,X.useRef)([]);y.current=_;let b=e=>{y.current=e(y.current),v(t=>e(t))},[x,S]=(0,X.useState)([]),C=(0,X.useRef)([]),w=e=>{C.current=e(C.current),S(C.current)},[T,E]=(0,X.useState)([]),D=(0,X.useRef)([]),O=e=>{D.current=e(D.current),E(D.current)},k=(0,X.useMemo)(()=>de(T),[T]),[A,j]=(0,X.useState)(Ce),[M,N]=(0,X.useState)(void 0),P=e=>{j(e),N(ye(e,C.current,de(D.current)))},[F,I]=(0,X.useState)([]),[L,R]=(0,X.useState)(()=>ky(e.user.id)),[ee,te]=(0,X.useState)(!1),[z,ne]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(z&&f&&(s(!1),u.current)){u.current=!1,l(!1);let e=requestAnimationFrame(()=>d.current?.focus());return()=>cancelAnimationFrame(e)}},[z?.id]);let[re,B]=(0,X.useState)([]),[ie,ae]=(0,X.useState)([]),[oe,me]=(0,X.useState)(!1),[ve,Te]=(0,X.useState)(!1),[Ee,De]=(0,X.useState)(!1),Oe=re.length>0,ke=ie.length>0;(0,X.useEffect)(()=>me(Oe),[z?.id,Oe]),(0,X.useEffect)(()=>De(ke),[z?.id,ke]);let[Ae,He]=(0,X.useState)({}),Ge=(0,X.useRef)([]),[Ke,qe]=(0,X.useState)({}),Je=(0,X.useRef)(new Set),[Ye,Xe]=(0,X.useState)(``),[Ze,et]=(0,X.useState)(``);(0,X.useEffect)(()=>{Xe(``),et(``)},[z?.id]);let[tt,rt]=(0,X.useState)(new Set),it=(0,X.useRef)(new Map),[at,ot]=(0,X.useState)(``),[st,ct]=(0,X.useState)(`saved`),lt=(0,X.useRef)(!1),ut=(0,X.useRef)(!1),dt=(0,X.useRef)(Promise.resolve()),ft=(0,X.useRef)(null),U=(0,X.useRef)(null),pt=(0,X.useRef)(null);pt.current=h,U.current=z;let[mt,ht]=(0,X.useState)(0),[gt,_t]=(0,X.useState)([]),[vt,yt]=(0,X.useState)(`unknown`),bt=(0,X.useRef)(vt);bt.current=vt;let[xt,W]=(0,X.useState)(``),[Et,G]=(0,X.useState)(!1),[Dt,kt]=(0,X.useState)(!1),Lt=(0,X.useRef)(!1),Rt=e=>{Lt.current=e,kt(e)},zt=(0,X.useRef)({}),[Ht,Yt]=(0,X.useState)(zt.current),$t=(e,t)=>{zt.current={...zt.current,[e]:t},Yt(zt.current)},en=new Map;Nm();let tn=e=>Om(e.id);async function nn(e){let t=tn(e);if(t)return t;let n=await rr.loadKeyState(e.id);return km(e.id,n),n}let rn=(e,t)=>{let n=tn(e);return n?om(e,zt.current[e.id]??en,t,n):[]},an=(e,t)=>{let n=e&&tn(e);return e&&!n?[]:sm(e??{sharedGeneration:0},(e&&zt.current[e.id])??en,t,n??Xp,Fn.current)},on=e=>{let t=tn(e);return t&&em(e,t)?rm(e,zt.current[e.id]??en,t):void 0};(0,X.useEffect)(()=>Im(on),[]);let sn=(0,X.useRef)(new Set);async function cn(e){sn.current.add(e),await rr.saveKeyState(e,{mark:0,digests:{},objects:2}).catch(()=>!1)}async function ln(e){let t=await cm(rn(e,e.keyGeneration),t=>Ct(t,e.id,$e(e.metaCiphertext),!0));return t.objects===2&&await cn(e.id),t}let un=(e,t,n,r)=>Ft(y.current.find(e=>e.id===t),sn.current.has(e),n,r),dn=e=>on(e)??(Fn.current&&{key:Fn.current,generation:0}),fn=e=>{let t=tn(e);return!(!t||em(e,t))},pn=e=>g(t=>t?.id===e.id?{...t,keyGeneration:e.keyGeneration,sharedGeneration:e.sharedGeneration}:t),mn=!(!h||on(h)),hn=e=>e===`owner`||e===`admin`||e===`editor`,gn=!hn(vt),_n=W_(gt,e.user.id)===!0,vn=t=>W_(Dn?.containerID===t.id?Dn.members:void 0,e.user.id),yn=!!(h&&fn(h)),bn=()=>{let e=pt.current;return!e||on(e)?!1:(W(fn(e)?sb:G_),!0)},xn=()=>bn()?!0:!pt.current||hn(bt.current)?!1:(W(bt.current===`unknown`?Zy:Yy),!0),[Sn,Cn]=(0,X.useState)(``),[wn,Tn]=(0,X.useState)(!1),En=(0,X.useRef)(void 0),[Dn,K]=(0,X.useState)(void 0),On=(0,X.useRef)({}),[kn,An]=(0,X.useState)(()=>b_(v_())),jn=(0,X.useRef)(p);jn.current=p;let Mn=(0,X.useRef)(new Set),Nn=(0,X.useRef)({}),Pn=(0,X.useRef)(void 0),Fn=(0,X.useRef)(void 0),[In,Ln]=(0,X.useState)(!1),Rn=(0,X.useRef)(void 0),[zn,Bn]=(0,X.useState)(),[Vn,Hn]=(0,X.useState)(!1);async function Un(){if(!Pn.current){let t=await _l(e.username,e.user.id).catch(()=>void 0),n=t?await vu().catch(()=>`unreachable`):void 0;Pn.current=Gd(t,n),Fn.current=Pn.current&&im(Pn.current),Ln(!!Fn.current)}return Pn.current}let[Wn,Gn]=(0,X.useState)(`unknown`),[Kn,qn]=(0,X.useState)(!1);async function Jn(){Pn.current=void 0;let[t,n,r]=await Promise.all([gl(e.username,e.user.id).catch(()=>void 0),vu(),hl(e.username,e.user.id)]);Rn.current=n??null,Bn(n??null),Gn(Wd(t,n)),qn(Bd(t,n,r)),await Un()}async function Yn(t){let n=Fn.current,r=im(t);await Hg((await el()).filter(t=>t.owner===e.user.id),e.user.id,async e=>{let t=n&&await Nt(n,e.containerID,e.id,e.payload,!0);return t?jt(r,e.containerID,e.id,t):void 0},nl)}(0,X.useEffect)(()=>{Jn().catch(()=>void 0),Un().catch(()=>void 0)},[]);let Xn=()=>{Hn(!1),W(``),Jn().then(()=>Ei(),()=>void 0)},[Zn,Qn]=(0,X.useState)(),$n={load:()=>gl(e.username,e.user.id),save:(t,n)=>pl(e.username,e.user.id,t,n),noteReset:t=>ml(e.username,e.user.id,t)};async function er(e){if(!e||confirm(`Replace this browser's encryption key with a new one? Team owners must share their notebooks' keys with you again, and colleagues are asked to trust your new key.`)){Qn(void 0);try{let t=await Rd({myIdentity:vu,putDeviceOnlyIdentity:bu},$n,e);t.kind===`held`&&(Hn(!0),Cr(`account`)),t.kind===`unsaved`&&Qn({message:`This browser cannot keep an encryption key (site storage is blocked or unavailable), so none was created.`}),await Jn()}catch(e){Qn(gh(e,`set up an encryption key`))}}}async function tr(e){let t=(await A_(ir)).find(t=>t.id===e);if(!t)throw Error(`Notebook not found`);return t}let nr={container:tr,envelopes:Pu,members:Ru,userIdentity:Lu,stepUp:e.sso?async()=>{}:async()=>{if(e.authSecret)return void await _u(e.authSecret);En.current??=$d(e.username).then(e=>(r(e),e));try{await _u(await En.current)}catch(e){throw En.current=void 0,e}},putEnvelopes:Fu,rotate:Iu},rr={load:()=>Sl(e.username,e.user.id),addFresh:t=>Cl(e.username,e.user.id,t),confirm:(t,n)=>wl(e.username,e.user.id,t,n),loadKeyState:t=>El(e.username,e.user.id,t),saveKeyState:(t,n)=>Dl(e.username,e.user.id,t,n)},ir={load:rr.loadKeyState,save:rr.saveKeyState},ar=e=>hi(e).catch(()=>`unreadable key`),or=e=>`${e.member.userId}:${e.member.identity?.publicKey??``}`;function sr(e){return async e=>{if(e.some(e=>Mn.current.has(or(e))))return!1;let t=await Promise.all(e.map(async e=>`${mi(e.member.username,e.member.userId)}: ${await ar(e.member.identity.publicKey)} (was ${await ar(e.pinned)})`)),n=confirm(`The encryption key of ${e.map(e=>mi(e.member.username,e.member.userId)).join(`, `)} changed since this browser last saw it. A password reset or account recovery does this; so would a server substituting its own key. Compare these fingerprints with the person (Settings shows theirs) before continuing:\n\n${t.join(` -`)}\n\nTrust the new key and exchange this notebook's keys with it?`);if(!n)for(let t of e)Mn.current.add(or(t));return n}}async function cr(e,t,n){let r=[],i=e.plan;return i.kind===`unrecoverable`?r.push(K_):i.kind===`untrusted`?r.push(n?`No keys were exchanged with ${i.members.join(`, `)}: you did not confirm their new encryption key.`:`The encryption key of ${i.members.join(`, `)} changed. Reopen this notebook to compare fingerprints.`):i.kind===`rollback`?r.push(sb):i.kind===`pins-unsaved`&&r.push(`No keys were exchanged: this browser could not save the colleague keys it checked. Allow site storage and reopen the notebook.`),e.conflicts.length&&r.push(`A different key was offered for this notebook than the one this device already accepted; it was refused.`),t.length&&r.push(`Now sharing with: ${(await Promise.all(t.map(async e=>`${mi(e.username,e.userId)} (fingerprint ${await ar(e.identity.publicKey)})`))).join(`, `)}.`),e.keyStateSaved||r.push(`This browser could not save its key memory; after a reload it cannot tell if this notebook's keys were swapped.`),r.join(` `)}let lr=(0,X.useRef)(new Map);function ur(e,t){let n=(lr.current.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return lr.current.set(e,n.catch(()=>void 0)),n}async function dr(t,n=!1,r=()=>!1,i=!1){return await nn(t),Rn.current===void 0&&await Jn().catch(()=>void 0),ur(t.id,async()=>{let o=n?()=>!1:e=>!r()&&sr(t.id)(e),s=await l_(nr,t.id,{userId:e.user.id,identity:await Un(),canWrap:i||!e.sso&&(!n||e.authSecret!==``),recoverable:Vd(Rn.current)},rr,o,zt.current[t.id],km);$t(t.id,s.ring);for(let e of s.members)On.current[e.userId]=e.username;km(t.id,s.known);let c={...t,keyGeneration:s.container.keyGeneration,sharedGeneration:s.container.sharedGeneration};a(e=>e.map(e=>e.id===c.id?{...e,keyGeneration:c.keyGeneration,sharedGeneration:c.sharedGeneration}:e));let l=``;s.minted&&([c,l]=await pr(c,s.members.some(t=>t.userId!==e.user.id)));let u=[...Nn.current[t.id]??[],...s.plan.kind===`pins-unsaved`?[]:s.fresh];return!r()&&(Or.current??pt.current?.id)===t.id?(delete Nn.current[t.id],K({containerID:t.id,members:s.members,status:s.plan.kind===`rollback`?{}:fm(s.container,s.members,s.envelopes)}),Tn(s.deferred),Cn([await cr(s,u,!n),l].filter(Boolean).join(` `))):Nn.current[t.id]=u,c})}async function fr(){let e=pt.current;if(e){Qn(void 0);try{pn(await dr(e,!1,()=>!1,!0))}catch(e){Qn(gh(e,`share keys`))}}}async function pr(e,t){try{let n=await tr(e.id),r={...e,metaCiphertext:n.metaCiphertext,metaVersion:n.metaVersion,changeSeq:n.changeSeq,keyGeneration:n.keyGeneration,sharedGeneration:n.sharedGeneration},i=on(n);if(!i||!n.metaCiphertext)return[r,``];let o=$e(n.metaCiphertext),s=t=>cm(t,t=>Ct(t,e.id,o,!sn.current.has(e.id))).then(async t=>(t.objects===2&&await cn(e.id),t.name),()=>void 0);if(await s([i.key])!==void 0)return[r,``];let c=zt.current[e.id]??en,l=jn.current[e.id];if(l){if(await s([...c.values()])!==l)return[r,`This notebook's name changed while its keys were shared. Rename it so every member can read it.`]}else{if(l=await s([...c.entries()].filter(([e])=>et-e).map(([,e])=>e))??``,!l)return[r,t?`This notebook's name could not be shared with its members yet. Rename it so every member can read it.`:`This notebook's name could not be sealed with its key yet. Rename it to try again.`];let n=l;m(t=>({...t,[e.id]:n}))}let u=Qe(await St(i.key,e.id,l,sn.current.has(e.id))),d=await zm({container:n,generation:i.generation},u,n.metaVersion);return a(t=>t.map(t=>t.id===e.id?{...t,metaCiphertext:u,metaVersion:d.metaVersion,changeSeq:d.changeSeq}:t)),[{...r,metaCiphertext:u,metaVersion:d.metaVersion,changeSeq:d.changeSeq},t?`Sealed this notebook's name with its key: ${l}.`:``]}catch{return[e,t?`This notebook's name could not be shared with its members yet. Rename it to try again.`:`This notebook's name could not be sealed with its key yet. Rename it to try again.`]}}let[mr,hr]=(0,X.useState)(0),[gr,_r]=(0,X.useState)(null),vr=(0,X.useRef)(!1),[yr,br]=(0,X.useState)(()=>Ue(location.hash)),[xr,Sr]=(0,X.useState)(yr?`settings`:`workspace`);function Cr(e){location.hash=We(e)}let[wr,Tr]=(0,X.useState)(!1),[Er,Dr]=(0,X.useState)(!1),Or=(0,X.useRef)(void 0),kr=(0,X.useMemo)(w_,[]),Ar=(0,X.useRef)(new Map),jr=(e,t)=>{Or.current&&Ar.current.set(e,t)},Mr=(0,X.useRef)(Promise.resolve()),Nr=e=>{let t=Mr.current.then(e);return Mr.current=t.catch(()=>{}),t},Pr=e=>Nr(e).then(()=>!1,()=>!0),[Fr,Ir]=(0,X.useState)(``),[Lr,Rr]=(0,X.useState)(null),[,zr]=(0,X.useState)(0),Br=e=>p[e.id]||`Notebook ${e.id.slice(4,10)}`,Vr=(0,X.useDeferredValue)(_),Hr=(0,X.useMemo)(()=>[...Vr].sort(je),[Vr]),Ur=(0,X.useMemo)(()=>Ne(_,x,A),[_,x,A]),Wr=(0,X.useMemo)(()=>V(Ur),[Ur]),Gr=h?`kynotes-collapsed-${e.user.id}-${h.id}`:``,[Kr,qr]=(0,X.useState)(()=>new Set);(0,X.useEffect)(()=>{qr(Se(Gr?zf(Gr):null))},[Gr]);function Jr(e){let t=new Set(y.current.map(e=>e.id)),n=[...Kr].filter(n=>n!==e&&t.has(n));Kr.has(e)||n.push(e),Gr&&Bf(Gr,JSON.stringify(n)),qr(new Set(n))}let Yr=(e,t)=>{let n=ce(e,t);qr(e=>n.some(t=>e.has(t))?new Set([...e].filter(e=>!n.includes(e))):e)};(0,X.useEffect)(()=>{let e=z?.id;e&&Yr(Ur,e)},[z?.id,A,Gr]);let Xr=e=>x.find(t=>t.id===e)?.title??`Quick Notes`,Zr=(0,X.useMemo)(()=>ly(Hr),[Hr]);(0,X.useEffect)(()=>{let e=!1,t=[];return Promise.all(ie.filter(e=>e.type.startsWith(`image/`)).map(async e=>{try{let n=await id(e.id),r=h?.id??``,i=await un(r,e.page,e.id,n),a=await cm(h?rn(h,e.keyGeneration):[],t=>At(t,r,e.page,n,i)),o=URL.createObjectURL(new Blob([a.slice().buffer],{type:e.type}));return t.push(o),[e.id,o]}catch{return null}})).then(t=>{e||He(Object.fromEntries(t.filter(e=>e!==null)))}),()=>{e=!0,t.forEach(e=>URL.revokeObjectURL(e)),He({})}},[ie,Ht,h?.id,h?.sharedGeneration]),(0,X.useEffect)(()=>()=>{Ge.current.forEach(e=>URL.revokeObjectURL(e)),Ge.current=[]},[z?.id]);let Qr=(0,X.useMemo)(()=>gy(Zr,Fr).map(e=>e.note),[Zr,Fr]),$r=(0,X.useMemo)(()=>{let e=new Map(_.map(e=>[e.id,e]));z&&e.set(z.id,z);let t=new Set(F.map(e=>e.note.id)),n=h&&h.kind!==`team`&&!h.teamId?[...e.values()].filter(e=>!t.has(e.id)).map(e=>({note:e,container:h})):[];return[...F.map(t=>({...t,note:e.get(t.note.id)??t.note})),...n]},[F,_,z,h]),ei=(0,X.useMemo)(()=>{let e=_y(gy(ly($r.map(e=>e.note)),Fr)),t=new Map($r.map(e=>[e.note.id,e]));return e.map(e=>t.get(e.note.id)).filter(e=>!!e)},[$r,Fr]),ti=(0,X.useMemo)(()=>$r.flatMap(e=>py(ly([e.note])[0]).map(t=>({...t,entry:e,key:`${e.note.id}\n${t.raw}`}))),[$r]),ni=Fy(ti,L);(0,X.useEffect)(()=>{(L.enabled||L.push||wr)&&i.length&&Mi().catch(()=>void 0)},[L.enabled,L.push,i.length]),(0,X.useEffect)(()=>{(L.push?Ny():Py()).catch(()=>void 0)},[]);let ri=(0,X.useMemo)(()=>ti.filter(e=>e.push).map(e=>({noteID:e.entry.note.id,remind:e.remind,push:!0})),[ti]),ii=ri.map(e=>`${e.noteID}\n${e.remind}`).sort().join(` -`),ai=(0,X.useRef)(Promise.resolve()),oi=(0,X.useRef)(void 0);(0,X.useEffect)(()=>{!L.push||!ee?oi.current=void 0:ai.current=ai.current.then(async()=>{let e=await Un();if(!e)return;let t=By(am(e),ri,Date.now()),n=Vy(t,await gd(),ee,oi.current);for(let e of n.deletes)await vd(e);for(let e of n.puts)await _d(e.id,e.at);oi.current=t}).catch(()=>void 0)},[L.push,ee,ii]);let si=wr?ei:(Fr.trim()?Qr:Ur).map(e=>({note:e,container:h})).filter(e=>!!e.container),ci=!wr&&!Fr.trim()&&!gn,li=new Set(ei.map(e=>e.note.id)),ui=wr?ti.filter(e=>li.has(e.entry.note.id)).map(e=>({...e,missed:ni.has(e.key),group:Qv(e,new Date,ni.has(e.key))})).sort((e,t)=>(e.due??`~`).localeCompare(t.due??`~`)):[],di=!wr&&ye(A,x,k)!==M,fi=di&&ci,pi=ci&&h?se(di?[]:Ur,Kr).map(e=>({note:e.item,container:h,row:e})):si.map(e=>({...e,row:void 0})),gi=e=>Ur.findIndex(t=>t.id===e),_i=(e,t)=>gi(e)>=0&&le(Ur,gi(e),t)!==void 0,vi=(0,X.useMemo)(()=>{let e=new Map;return(t,n)=>{let r=t===`group`?n:``;return e.has(r)||e.set(r,ge(T,k,t===`group`?n:void 0)),e.get(r)}},[T,k]),yi=e=>{let[t,n]=H(Wr,gi(e));return n-t-1},bi=e=>e===void 0?void 0:Ur[e]?.id??null,xi=(0,X.useMemo)(()=>vy(Zr,z?ly([z])[0]:void 0).map(e=>e.note),[Zr,z]),Si=(0,X.useMemo)(()=>yy(Zr),[Zr]);(0,X.useEffect)(()=>{Ei()},[]),(0,X.useEffect)(()=>{Na();let e=window.setInterval(()=>void Na(),15e3);return()=>window.clearInterval(e)},[]),(0,X.useEffect)(()=>{let e=typeof BroadcastChannel>`u`?null:new BroadcastChannel(`kynotes-sync`);ft.current=e,e?.addEventListener(`message`,()=>void qi());let t=()=>void qi();window.addEventListener(`online`,t),qi();let n=window.setInterval(t,15e3);return()=>{window.removeEventListener(`online`,t),window.clearInterval(n),e?.close(),ft.current=null}},[]),(0,X.useEffect)(()=>{let e=()=>{let e=Ue(location.hash);e&&location.hash!==We(e)&&history.replaceState(null,``,We(e)),e&&(s(!1),br(e)),Sr(e?`settings`:`workspace`)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Ci=(0,X.useRef)(xr);Ci.current=xr,(0,X.useEffect)(()=>{xr===`workspace`&&Ue(location.hash)&&(wr||!h?history.pushState(null,``,location.pathname+location.search):location.hash=Be({container:h.id,section:A,page:z?.id}))},[xr]),(0,X.useEffect)(()=>{if(Ci.current!==`workspace`||Ue(location.hash)||wr||Er||!h)return;let e=Be({container:h.id,section:A,page:z?.id});location.hash!==e&&(ze(location.hash).container?location.hash=e:history.replaceState(null,``,e))},[wr,Er,h?.id,A,z?.id]),(0,X.useEffect)(()=>{let e=()=>void(async()=>{let e=y_(location,history,v_());if(e){An(e);return}let t=ze(location.hash),n=i.find(e=>e.id===t.container);if(!n||t.container===Or.current||n.id===h?.id&&t.section===A&&t.page===z?.id)return;let r=()=>h&&history.replaceState(null,``,Be({container:h.id,section:A,page:U.current?.id}));if(n.id!==h?.id){await ki(n,t)||r();return}let a=_.find(e=>e.id===t.page);t.page!==U.current?.id&&!await Ki()?r():(P(Re(t.section,x)),a?await Fi(a)||r():ze(location.hash).page||ne(null))})();return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[i,h?.id,A,z?.id,_,x]),(0,X.useEffect)(()=>{if(!Lr)return;let e=window.setInterval(()=>zr(e=>e+1),1e3),t=window.setTimeout(()=>Rr(null),Hy);return()=>{window.clearInterval(e),window.clearTimeout(t)}},[Lr]),(0,X.useEffect)(()=>{if(!h)return;Bu(h.id,z?`editing`:`viewing`).catch(()=>{});let e=window.setInterval(()=>{Bu(h.id,z?`editing`:`viewing`).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[h?.id,z?.id]);let wi=(0,X.useRef)(()=>void 0);wi.current=()=>{let e=pt.current;e&&!Or.current&&document.visibilityState===`visible`&&dr(e,!0).then(e=>{pn(e),on(e)&&qi()}).catch(()=>void 0)},(0,X.useEffect)(()=>{let e=()=>{zu().then(e=>ht(e.length)).catch(()=>ht(0)),wi.current()};e();let t=window.setInterval(e,9e4);return()=>window.clearInterval(t)},[]),(0,X.useEffect)(()=>{document.title=mt?`(${mt}) KyNotes`:`KyNotes`},[mt]),(0,X.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()===`l`&&z&&(e.preventDefault(),Xa())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]),(0,X.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&z&&(e.preventDefault(),Gi(z))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z,h]);let Ti=Dt&&z!==null&&!tt.has(z.id);(0,X.useEffect)(()=>{if(!Ti)return;let e=window.setTimeout(()=>{Gi(z,!0)},900);return()=>window.clearTimeout(e)},[z?.title,z?.body,Ti]),(0,X.useEffect)(()=>{if(!Ti)return;let e=window.setInterval(()=>{U.current&&Gi(U.current,!0)},15e3);return()=>window.clearInterval(e)},[z?.id,Ti]),(0,X.useEffect)(()=>{let e=()=>{let e=U.current;e&&Dt&&(Xi(e),Gi(e,!0))},t=()=>{document.visibilityState===`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,e)}},[Dt,h?.id]);async function Ei(t=!0){let n=kr.mark();try{let r=await A_(ir),i={},o=!1,s=await Un(),c={...nr,container:async e=>r.find(t=>t.id===e)??tr(e)};for(let t of r)try{let n=t,r=await rr.loadKeyState(t.id);if(km(t.id,r),r.objects===2&&sn.current.add(t.id),t.sharedGeneration>0||(r.shared??0)>0){let r=await ur(t.id,async()=>{let n=await l_(c,t.id,{userId:e.user.id,identity:s,canWrap:!1,recoverable:!1},rr,()=>!1,zt.current[t.id],km);$t(t.id,n.ring);for(let e of n.members)On.current[e.userId]=e.username;return km(t.id,n.known),n});r.plan.kind!==`pins-unsaved`&&r.fresh.length&&(Nn.current[t.id]=[...Nn.current[t.id]??[],...r.fresh]),n={...t,keyGeneration:r.container.keyGeneration,sharedGeneration:r.container.sharedGeneration}}if(t.metaCiphertext){let e=await ln(n);sn.current.has(t.id)&&e.objects!==2?o=!0:i[t.id]=e.name}}catch{}if(n())return await Ei(!1);m(i),a(r),o&&W(cb);let l=ze(location.hash),u=r.find(e=>e.id===l.container)??r[0];u&&t&&await ki(u,u.id===l.container?l:void 0,!1)}catch(e){W(e instanceof Error?e.message:`Unable to load notebooks`)}}async function Di(t,n=`recover`){let r=0,i=new Set,a=!sn.current.has(t.id),o=[],s=[],c=[],l=(e,t,n,r)=>{t&&(t.type===`section`?s.push({...t,id:e,version:n}):t.type===`group`?c.push({...t,id:e,version:n}):o.push({id:e,title:t.title,body:t.body,section:t.section,order:t.order,level:t.level,legacy:t.legacy,version:n,updatedAt:r}))},u=0;for(let o=0;oe.kind===`object`&&!e.deleted))try{let r=await Yu(s.id),o=e=>cm(rn(t,r.keyGeneration),n=>Mt(n,t.id,s.id,r.bytes,e)),c=await Nl({owner:e.user.id,id:s.id,version:r.version,mode:n,open:e=>cm(an(t,e.keyGeneration),n=>Nt(n,t.id,s.id,e.payload,!0)),server:()=>o(a).then(e=>e.payload)}),u=!!c,d=u?await cm(an(t,c.keyGeneration),e=>Nt(e,t.id,s.id,c.payload,!0)):await o(a).then(e=>(e.v1&&i.add(s.id),e.payload));u&&await o(!1).then(()=>!1,()=>!0)&&i.add(s.id),l(s.id,d,u?c.version:r.version,u?c.updatedAt:r.savedAt)}catch{try{let n=await Kc(e.user.id,s.id);if(!n)throw Error(`no local copy`);l(s.id,await cm(an(t,n.keyGeneration),e=>Nt(e,t.id,s.id,n.payload,!0)),n.version,n.updatedAt),i.add(s.id)}catch{r+=1}}if(!o.hasMore)break;let s=Number(o.nextCursor);if(!Number.isSafeInteger(s)||s<=u)break;u=s}return{notes:o,sections:s,groups:c,unreadable:r,legacy:i}}async function Oi(e){let t=xr!==`workspace`&&h?.id===e.id&&!wr;Sr(`workspace`),t?s(!1):await ki(e)}async function ki(e,t,n=!0){let r=kr.begin();Or.current=e.id,Dr(!0);try{return await Ai(e,t,r.superseded,n)}finally{r.superseded()||(Or.current=void 0,Dr(!1))}}async function Ai(t,n,r,i){if(!await Ki())return null;if(r())return[];g(t),yt(`unknown`),i&&Tr(!1),U.current=null,ne(null),b(()=>[]),w(()=>[]),O(()=>[]),N(void 0),B([]),ae([]),Ar.current.clear(),Cn(``),Tn(!1);try{let i=await dr(t,!1,r).catch(e=>(r()||W(e instanceof Error?`Unable to share this notebook's keys: ${e.message}`:`Unable to share this notebook's keys`),t));if(r())return[];g(i),(await rr.loadKeyState(i.id)).objects===2&&sn.current.add(i.id);let a=await Di(i);if(r())return[];a.unreadable&&W(Zt(a.unreadable));let o=Jt(a.notes,Ar.current),s=qt(a.sections,Ar.current);w(()=>s),O(()=>qt(a.groups,Ar.current)),Ar.current.clear(),b(()=>o),P(Re(n?.section,s));let c=n?.page?o.find(e=>e.id===n.page):void 0;c&&await Fi(c,i);let l=t.kind===`team`?await Ru(t.id).catch(()=>void 0):[];r()||_t(l??[]);let u=t.teamId?await Ru(t.id).catch(()=>void 0):l,d=t.kind===`team`||t.teamId?u?.find(t=>t.userId===e.user.id)?.role??`unknown`:`owner`;if(r()||yt(d),!r()&&d===`unknown`&&W(Zy),!r()&&hn(d)&&await ji(r),!r()&&(d===`owner`||d===`admin`||d===`editor`)){let e=[...o.map(e=>({id:e.id,type:`page`,legacy:e.legacy})),...s.map(({id:e})=>({id:e,type:`section`})),...a.groups.map(({id:e})=>({id:e,type:`group`}))];$i.current={containerID:i.id,unreadable:a.unreadable,objects:e.map(e=>({...e,v1:a.legacy.has(e.id)}))},ta(e=>e+1)}return o}catch(e){return r()||W(e instanceof Error?e.message:`Unable to load notebook`),[]}}async function ji(t){let n=U.current;if(!n)return;let r=await Xc(e.user.id,n.id).catch(()=>void 0);t()||U.current?.id!==n.id||!r||r.gone||r.previousKey||r.conflicted||Rt(!0)}async function Mi(){let e=i.filter(e=>e.kind!==`team`&&!e.teamId),t=await Promise.allSettled(e.map(async e=>{let{notes:t,unreadable:n}=await Di(e);return{container:e,notes:t,unreadable:n}}));t.some(e=>e.status===`rejected`)&&W(`Some personal notebooks could not be loaded; the work queue may be incomplete.`),te(t.every(e=>e.status===`fulfilled`&&e.value.unreadable===0));let n=t.flatMap(e=>e.status===`fulfilled`?e.value.notes.map(t=>({note:t,container:e.value.container})):[]);I(n)}async function Ni(){s(!1),Sr(`workspace`),Tr(!0),G(!0);try{await Mi()}catch(e){W(e instanceof Error?e.message:`Unable to load work queue`)}finally{G(!1)}}async function Pi(e){let t=await ki(e.container);if(!t)return;let n=t.find(t=>t.id===e.note.id);n&&await Fi(n,e.container),Tr(!0)}async function Fi(t,n=h){let r=n?.id??``;if(n&&(Or.current??pt.current?.id)!==r)return!1;let i=U.current;if(i&&i.id!==t.id&&!await Ki()||n&&(Or.current??pt.current?.id)!==r)return!1;let a=i?.id===t.id?i:y.current.find(e=>e.id===t.id)??t;if(U.current=a,ne(a),i?.id!==a.id){Rt(!1),ot(a.version>0?a.updatedAt:``);let t=await Xc(e.user.id,a.id).catch(()=>void 0);t&&U.current?.id===a.id&&(ct(t.conflicted||t.gone?`attention`:`local`),ot(``))}let o=()=>U.current?.id===a.id;try{let e=await ad(a.id);rt(t=>{let n=new Set(t);return e.some(e=>!e.resolved)?n.add(a.id):n.delete(a.id),n})}catch{}try{let e=await Wu(a.id),t=[];for(let i of e)try{let e=$e(i.bodyCiphertext),o=await un(r,a.id,i.id,e),s=await cm(n?rn(n,i.keyGeneration):[],t=>Tt(t,r,a.id,e,o));t.push({id:i.id,authorUserId:i.authorUserId,username:i.username,body:s.body,section:s.section,createdAt:i.createdAt})}catch{}o()&&B(t)}catch{o()&&B([])}try{let e=await rd(a.id),t=[];for(let i of e)try{let e=$e(i.metadataCiphertext),o=await un(r,a.id,Pt(i.id),e),s=await cm(n?rn(n,i.keyGeneration):[],t=>Ot(t,r,a.id,e,o));t.push({id:i.id,...s,keyGeneration:i.keyGeneration,page:a.id})}catch{}o()&&ae(t)}catch{o()&&ae([])}return!0}async function Ii(e,t){if(!await Un())throw Error(ub);if(Rn.current===void 0&&await Jn().catch(()=>void 0),!Vd(Rn.current))throw Error(K_);let n=await N_(e,async e=>{let n=await dr(e,!1,()=>!1,!0),r=on(n);if(!r)throw Error(lb);let i=Qe(await St(r.key,n.id,t,!0)),a=await zm({container:n,generation:r.generation},i,n.metaVersion);return{...n,metaCiphertext:i,metaVersion:a.metaVersion,changeSeq:a.changeSeq}},ru);return await cn(n.id),m(e=>({...e,[n.id]:t})),a(e=>[...e.filter(e=>e.id!==n.id),n]),n}async function Li(){let e=prompt(`Notebook name`,`My notebook`)?.trim();if(e){G(!0);try{await Oi(await Ii(()=>j_(ir,`workbook`),e))}catch(e){W(e instanceof Error?e.message:`Unable to create notebook`)}finally{G(!1)}}}async function Ri(e){let t=prompt(`Notebook name`,`New notebook`)?.trim();if(t){G(!0);try{await Oi(await Ii(()=>j_(ir,`workbook`,e.id),t))}catch(e){W(e instanceof Error?e.message:`Unable to create team notebook`)}finally{G(!1)}}}async function zi(){if(!h)return;let e=prompt(`Notebook name`,Br(h))?.trim();if(e){G(!0);try{let t=await dr(await tr(h.id)),n=on(t);if(!n)throw Error(G_);t.metaCiphertext&&await ln(t).catch(()=>void 0);let r=Qe(await St(n.key,t.id,e,sn.current.has(t.id))),i=await zm({container:t,generation:n.generation},r,h.metaVersion),o={...t,metaCiphertext:r,metaVersion:i.metaVersion,changeSeq:i.changeSeq};m(t=>({...t,[h.id]:e})),a(e=>e.map(e=>e.id===o.id?o:e)),g(e=>e?.id===o.id?o:e)}catch(e){W(e instanceof Error?e.message:`Unable to rename notebook`)}finally{G(!1)}}}async function Bi(){let n=pt.current;if(!n)return;let r=Br(n),o=prompt(nb(r,n.kind===`team`));if(o===null)return;if(o.trim()!==r.trim()){W(`The name did not match, so nothing was deleted.`);return}G(!0);try{await ru(n.id)}catch(e){e instanceof Z&&e.status===403&&e.message===`re-authentication required`?confirm(tb)&&t():W(e instanceof Error?e.message:`Unable to delete notebook`);return}finally{G(!1)}let s=e=>e.id===n.id||e.teamId===n.id,c=new Set(i.filter(s).map(e=>e.id).concat(n.id));a(e=>e.filter(e=>!s(e)));let l=Or.current??pt.current?.id,u=!!(l&&c.has(l)),d=u?y.current.map(e=>e.id):[],f=Promise.resolve();if(u){Rt(!1),U.current=null,ne(null),history.replaceState(null,``,location.pathname+location.search);let e=i.find(e=>!s(e));e?f=ki(e):(g(null),b(()=>[]),w(()=>[]),O(()=>[]))}for(let t of d)await qc(e.user.id,t).catch(()=>void 0);for(let t of(await el().catch(()=>[])).filter(t=>t.owner===e.user.id))c.has(t.containerID)&&await tl(t.owner,t.id,t.updatedAt).catch(()=>void 0);await f}async function Vi(){if(!h)return;let e=h,t=Br(e);if(confirm(`${eb}\n\nExport "${t}"?`)){G(!0);try{let{blockNoteMarkdown:n,buildNotebookExport:r,safeName:i}=await uo(async()=>{let{blockNoteMarkdown:e,buildNotebookExport:t,safeName:n}=await import(`./exportNotebook-BOlYJYx0.js`);return{blockNoteMarkdown:e,buildNotebookExport:t,safeName:n}},[]),a=await Di(e,`read`),o=await r({name:t,...a,toMarkdown:await n(),attachments:{list:async e=>(await rd(e)).map(t=>({...t,pageID:e})),open:async t=>{let n=rn(e,t.keyGeneration),r=a.notes.find(e=>e.id===t.pageID),i=sn.current.has(e.id),o=$e(t.metadataCiphertext),s=await Ft(r,i,Pt(t.id),o),c=await cm(n,n=>Ot(n,e.id,t.pageID,o,s)),l=await id(t.id),u=await Ft(r,i,t.id,l);return{id:t.id,...c,bytes:await cm(n,n=>At(n,e.id,t.pageID,l,u))}}}});wp(`${i(t,`notebook`)}.zip`,Rg(o.entries),`application/zip`),W(`Exported ${o.pages} pages.${o.unreadable?` ${o.unreadable} items could not be read and are not in the file.`:``}`)}catch(e){W(e instanceof Error?e.message:`Unable to export notebook`)}finally{G(!1)}}}async function Hi(){if(!(!h||mn||xn())){G(!0);try{if(!await Ki())return;let e=Pe(Ne(y.current,C.current,A)),t=await Ju(h.id);if((Or.current??pt.current?.id)!==h.id){await fd(t.id).catch(()=>void 0);return}let n={id:t.id,title:`Untitled page`,body:Mv(Av()),section:A===`quick`?void 0:A,order:e,legacy:{},version:0,updatedAt:new Date().toISOString()};b(e=>[n,...e]),U.current=n,ne(n),Rt(!0),Xi(n),await Gi(n,!0)}catch(e){W(e instanceof Error?e.message:`Unable to create note`)}finally{G(!1)}}}async function Ui(t,n=!1){if(h&&hn(bt.current)){n||G(!0);try{let n=dn(h)??vm(),r,i=await Pr(async()=>{r=await jl({owner:e.user.id,containerID:h.id,note:t,write:n}),await Yc(r)}),a=r??vm(),o=a.payload,s=a.updatedAt,c=h.id;if(n.generation===0)return await Jc({id:t.id,containerID:c,version:t.version,payload:o,updatedAt:s,keyGeneration:n.generation,owner:e.user.id}).catch(vm),ct(`local`),W($_(vn(h))),t;try{let e=await Rm({container:h,generation:n.generation},t.id,o,t.version);it.current.delete(a.id);let r=await Pr(()=>$c(a,e.version));Rr(Date.now()),rt(e=>{let n=new Set(e);return n.delete(t.id),n});let c={...t,version:e.version,updatedAt:s};ot(s),ct(`saved`),(i||r)&&W(db),b(e=>Wt(e,c.id,c)),jr(c.id,c),I(e=>e.flatMap(e=>e.note.id===c.id?_y(ly([c])).length?[{...e,note:c}]:[]:[e]));let l=U.current;if(l?.id===c.id){let[e]=Wt([l],c.id,c);U.current=e,ne(e),Gt(l,t)&&Rt(!1)}}catch(e){if(e instanceof Z&&e.code===`version_conflict`)it.current.set(a.id,a),rt(e=>new Set(e).add(t.id)),ct(`attention`),W(ym(i)),await nl(a,{...a,conflicted:!0}).catch(()=>void 0);else{let n=e instanceof Z&&e.code===`not_found`?{gone:!0}:{};if(await Jc({...a,...n}).catch(vm),ft.current?.postMessage({type:`queued`,id:t.id}),ct(`local`),e instanceof Z&&e.code===`already_exists`||e instanceof Pm)qi();else if(e instanceof Z&&e.code===`not_found`)ct(`attention`),W(Qy);else{let t=Qt(e instanceof Z?e.code:void 0);t&&ct(`attention`),W(t??`Saved locally; encrypted change queued for the server.`)}}}return t}catch(e){W(e instanceof Error?e.message:`Unable to save note`);return}finally{n||G(!1)}}}function Wi(e){let t=dt.current.then(e);return dt.current=t.then(()=>{},()=>{}),t}function Gi(e,t=!1){return Wi(()=>{let n=U.current;if(n&&n.id===e.id)return Ui(n,t)})}async function Ki(){if(!Lt.current)return!0;let e=await Xt(()=>U.current,e=>Gi(e,!0),$y);return e===`busy`&&W(`This page is still saving. Try again in a moment.`),e===`done`}function qi(){lt.current||(lt.current=!0,Wi(Ji))}async function Ji(){try{let t=(await el()).filter(t=>t.owner===e.user.id).filter(e=>!e.previousKey);if(!t.length)return;ct(`syncing`);let n=!1,r=!1,i=new Map;for(let e of t){if(e.gone||e.conflicted||Qc(it.current.get(e.id),e)){r=!0;continue}let t=e;try{let e=await q(t,i).catch(e=>{let t=Qt(e instanceof Z?e.code:void 0);t&&(r=!0,W(t))});if(!e){n=!0;continue}t=e.item;let a=await Rm({container:e.container,generation:t.keyGeneration},t.id,t.payload,t.version);it.current.delete(t.id),await $c(t,a.version);let o={version:a.version,updatedAt:t.updatedAt};b(e=>Wt(e,t.id,o)),jr(t.id,o),w(e=>e.map(e=>e.id===t.id?{...e,version:a.version}:e)),O(e=>e.map(e=>e.id===t.id?{...e,version:a.version}:e));let s=U.current;if(s?.id===t.id){let[e]=Wt([s],t.id,o);U.current=e,ne(e),ot(t.updatedAt)}}catch(e){if(e instanceof Z&&e.code===`version_conflict`)it.current.set(t.id,t),rt(e=>new Set(e).add(t.id)),r=!0,W(ym(!1)),await nl(t,{...t,conflicted:!0}).catch(()=>void 0);else if(e instanceof Z&&(e.code===`not_found`||e.code===`forbidden`))await nl(t,{...t,gone:!0}),r=!0,W(e.code===`forbidden`?Xy:Qy);else{let t=Qt(e instanceof Z?e.code:void 0);t?(r=!0,W(t)):n=!0}}}ct(r?`attention`:n?`local`:`saved`)}catch{ct(`local`)}finally{lt.current=!1}}async function q(t,n){n.has(t.containerID)||n.set(t.containerID,tr(t.containerID).then(async t=>{let n=(await Ru(t.id)).find(t=>t.userId===e.user.id)?.role;return n&&hn(n)?dr(t,!0):void 0}));let r=await n.get(t.containerID);if(!r)return;pn(r);let i=await mm(t,r,tn(r),on(r),zt.current[r.id]??en,Fn.current);if(!i)return;let a=i===t?t:{...i,owner:e.user.id};if(a===t||await nl(t,a))return{item:a,container:r}}async function Yi(t){if(!xn()&&confirm(`Delete this page?`))try{await fd(t.id),await qc(e.user.id,t.id),b(e=>e.filter(e=>e.id!==t.id)),ne(null)}catch(e){W(e instanceof Error?e.message:`Unable to delete note`)}}function Xi(t){if(!h)return;let n=h.id,r=dn(h);r&&Nr(async()=>{let i=await jl({owner:e.user.id,containerID:n,note:t,write:r});await Wc(e.user.id,{...i,unsent:!0})}).catch(()=>{})}async function Zi(t,n,r){if(!h)return null;let i=dn(h)??vm(),a=h.id,o,s=await Pr(async()=>{o=await Ml({owner:e.user.id,containerID:a,id:t,version:n,content:r,write:i}),await Yc(o)}),c=o??vm(),l=c.payload,u=c.updatedAt;if(i.generation===0)return await Jc({id:t,containerID:a,version:n,payload:l,updatedAt:u,keyGeneration:i.generation,owner:e.user.id}).catch(vm),ct(`local`),W($_(vn(h))),null;try{let e=await Rm({container:h,generation:i.generation},t,l,n);it.current.delete(c.id);let r=await Pr(()=>$c(c,e.version));return jr(t,{version:e.version,updatedAt:u}),(s||r)&&W(db),e.version}catch(e){if(e instanceof Z&&e.code===`version_conflict`)it.current.set(c.id,c),rt(e=>new Set(e).add(t)),ct(`attention`),W(`This item changed on another device. Reopen the notebook before changing it again.`),await nl(c,{...c,conflicted:!0}).catch(()=>void 0);else{await Jc(c).catch(vm),ft.current?.postMessage({type:`queued`,id:t});let n=Qt(e instanceof Z?e.code:void 0);ct(n?`attention`:`local`),n&&W(n),(e instanceof Z&&e.code===`already_exists`||e instanceof Pm)&&qi()}return null}}function Qi(e,t,n){if(xn())return Promise.resolve(!1);let r=t=>e===`section`?w(t):O(t);return r(e=>e.map(e=>e.id===t?{...e,...n}:e)),Wi(async()=>{let n=e===`section`?C.current.find(e=>e.id===t):D.current.find(e=>e.id===t);if(!n)return!1;let{id:i,version:a,...o}=n,s=await Zi(t,a,o);return s!==null&&r(e=>e.map(e=>e.id===t?{...e,version:s}:e)),s!==null})}let $i=(0,X.useRef)(void 0),[ea,ta]=(0,X.useState)(0),na=(0,X.useRef)(!1);(0,X.useEffect)(()=>{let e=$i.current;$i.current=void 0,e&&!na.current&&h?.id===e.containerID&&on(h)&&(na.current=!0,ra(h,e).then(t=>{t===`conflicts`&&pt.current?.id===e.containerID&&W(Jy)},()=>void 0).finally(()=>{na.current=!1}))},[ea]);function ra(e,t){let n=()=>pt.current?.id===e.id;return ev(t.objects,t.unreadable,sn.current.has(e.id),{pins:t=>ia(e,t),legacyConflict:async t=>{for(let n of(await ad(t)).filter(e=>!e.resolved)){let r=await od(n.id),i=rn(e,n.keyGeneration);if(!i.length)throw Error(`conflict key missing`);let a=n=>cm(i,i=>Nt(i,e.id,t,r,n)).then(()=>!0,()=>!1);if(!await a(!1)&&await a(!0))return!0}return!1},savePage:async(e,t)=>n()&&aa(e,t),saveStructure:async(e,t)=>n()&&Qi(e,t,{}),mark:async()=>{let t=pt.current,n=jn.current[e.id],r=t?.id===e.id?on(t):void 0;if(!t||!r||n===void 0)return!1;let i=Qe(await St(r.key,e.id,n,!0)),o=await zm({container:t,generation:r.generation},i,t.metaVersion);await cn(e.id);let s={metaCiphertext:i,metaVersion:o.metaVersion,changeSeq:o.changeSeq};return a(t=>t.map(t=>t.id===e.id?{...t,...s}:t)),g(t=>t?.id===e.id?{...t,...s}:t),!0}})}async function ia(e,t){let n={},r=(t,n)=>cm(rn(e,t),n).then(()=>!0,()=>!1),i=async(e,t)=>!await r(e,e=>t(e,!1))&&r(e,e=>t(e,!0));for(let r of await Wu(t)){let a=$e(r.bodyCiphertext);await i(r.keyGeneration,(n,r)=>Tt(n,e.id,t,a,r))&&(n[r.id]=await nt(a))}for(let a of await rd(t)){let o=$e(a.metadataCiphertext);if(!await i(a.keyGeneration,(n,r)=>Ot(n,e.id,t,o,r)))continue;let s=await id(a.id);await r(a.keyGeneration,n=>At(n,e.id,t,s,!0))&&(n[a.id]=await nt(s),n[Pt(a.id)]=await nt(o))}return n}function aa(e,t){return Wi(async()=>{b(n=>Vt(n,e,{legacy:t}));let n=U.current;if(n?.id===e){let e={...n,legacy:t};return U.current=e,ne(e),Xi(e),await Ui(e,!0),!1}let r=y.current.find(t=>t.id===e);if(!r)return!1;let i=Kt(r,await oa(e)),a=await Zi(e,i.version,Bt(i));return a!==null&&b(t=>Wt(t,e,{version:a})),a!==null})}async function oa(t){if(!h)return;let n=await Kc(e.user.id,t).catch(()=>void 0);if(!n)return;let r=h.id,i=await cm(an(h,n.keyGeneration),e=>Nt(e,r,t,n.payload,!0)).catch(()=>void 0);return i?.type===`page`?{version:n.version,title:i.title,body:i.body}:void 0}async function sa(e,t){if(xn())return;let{level:n,...r}=t,i=n===void 0?r:t;b(t=>Vt(t,e,i));let a=U.current;if(a?.id===e){let e={...a,...i};U.current=e,ne(e),Rt(!0),Xi(e),await Gi(e,!0);return}let o=y.current.find(t=>t.id===e);if(!o)return;let s=Kt(o,await oa(e));b(t=>Vt(t,e,{title:s.title,body:s.body}));let c=await Zi(e,s.version,Bt(s));c!==null&&b(t=>Wt(t,e,{version:c}))}let ca=(0,X.useMemo)(()=>Me(x),[x]),la=(0,X.useMemo)(()=>ca.filter(e=>fe(e,k)===M),[ca,k,M]),ua=(0,X.useMemo)(()=>T.filter(e=>k.get(e.id)===M).sort(je),[T,k,M]);function da(e,t){let n=de(D.current);return e===`section`?Me(C.current).filter(e=>fe(e,n)===t):D.current.filter(e=>n.get(e.id)===t).sort(je)}async function fa(e){if(h&&!xn()){G(!0);try{let t=M,n=Pe(da(e,t)),r=await Ju(h.id,`folder`);if((Or.current??pt.current?.id)!==h.id){await fd(r.id).catch(()=>void 0);return}let i={id:r.id,version:r.version,order:n,group:t};e===`section`?(w(e=>[...e,{...i,type:`section`,title:`New section`,color:we[e.length%we.length]}]),P(r.id)):O(e=>[...e,{...i,type:`group`,title:`New group`,color:we[e.length%we.length]}]),await Qi(e,r.id,{})}catch(t){W(t instanceof Error?t.message:`Unable to create ${e}`)}finally{G(!1)}}}let pa=e=>W(e instanceof Error?e.message:`Unable to update section or group`);function ma(e,t){if(xn())return;let n=prompt(e===`section`?`Section name`:`Group name`,t.title)?.trim();n&&Qi(e,t.id,{title:n}).catch(pa)}async function ha(t){if(xn())return;let n=Ne(_,x,t.id).length;if(confirm(`Delete section "${t.title}"? Its ${n} page${n===1?``:`s`} will move to Quick Notes.`))try{await fd(t.id),await qc(e.user.id,t.id),w(e=>e.filter(e=>e.id!==t.id)),P(Ce)}catch(e){W(e instanceof Error?e.message:`Unable to delete section`)}}async function ga(t){if(!xn()&&confirm(`Delete group "${t.title||`Untitled group`}"? Its sections and groups move up one level.`)){G(!0);try{let n=de(D.current).get(t.id);for(let e of[`section`,`group`])for(let r of da(e,t.id))if(!await Qi(e,r.id,{group:n})){W(e=>e||`Could not move everything out of the group, so it was kept. Try again.`);return}await fd(t.id),await qc(e.user.id,t.id),O(e=>e.filter(e=>e.id!==t.id)),N(e=>e===t.id?n:e)}catch(e){W(e instanceof Error?e.message:`Unable to delete group`)}finally{G(!1)}}}async function _a(e,t,n){let r=e===`section`?C.current.find(e=>e.id===t):D.current.find(e=>e.id===t);if(!r)return;let i=e===`section`?fe(r,k):k.get(t);for(let r of Fe(da(e,i),t,n))await Qi(e,r.id,{order:r.order}).catch(pa)}async function va(e,t,n){e===`group`&&!he(t,n,de(D.current))?W(`A group cannot move into itself or its own groups, or nest deeper than 4 levels.`):(await Qi(e,t,{group:n,order:Pe(da(e,n).filter(e=>e.id!==t))}).catch(pa),e===`section`&&t===A&&N(n))}async function ya(e){if(e===A)return P(e);if(!await Ki())return;U.current=null,ne(null),P(e);let t=Ne(y.current,C.current,e)[0];t&&await Fi(t)}async function ba(e){if(ye(A,x,k)===e)return N(e);let t=ca.find(t=>fe(t,k)===e)?.id??(e===void 0?`quick`:void 0);if(t!==void 0)return ya(t);await Ki()&&(ne(null),N(e))}let xa=h?[{id:void 0,title:Br(h)},...pe(M,k).map(e=>({id:e,title:T.find(t=>t.id===e)?.title||`Untitled group`}))]:[],Sa=(0,X.useRef)(Promise.resolve()),Ca=e=>e.section&&C.current.some(t=>t.id===e.section)?e.section:Ce;function wa(e){let t=Sa.current.then(e);return Sa.current=t.catch(()=>{}),t.catch(e=>W(e instanceof Error?e.message:`Unable to move page`))}function Ta(e,t,n){return wa(async()=>{if(xn())return;let r=y.current.find(t=>t.id===e);if(!r)return;let i=Ne(y.current,C.current,Ca(r)),a=V(i),[o,s]=H(a,i.findIndex(t=>t.id===e)),c=i.slice(o,s),l=new Set(c.map(e=>e.id)),u=Ne(y.current,C.current,t).filter(e=>!l.has(e.id)),d=n===null?-1:u.findIndex(e=>e.id===n),f=t===`quick`?void 0:t;for(let e of ue(u,c,a.slice(o,s),d<0?u.length:d)){let t=y.current.find(t=>t.id===e.id);await sa(e.id,l.has(e.id)?{section:f,order:e.order,level:e.level}:{section:t?.section,order:e.order})}})}function Ea(e,t){return wa(async()=>{if(xn())return;let n=y.current.find(t=>t.id===e);if(!n)return;let r=Ne(y.current,C.current,Ca(n)),i=le(r,r.findIndex(t=>t.id===e),t);i!==void 0&&(Yr(r.map(t=>t.id===e?{...t,level:i}:t),e),await sa(e,{section:n.section,order:n.order,level:i}))})}async function Da(e,t,n,r=()=>!0){let{page:i,moves:a}=Ie(Ne(y.current,C.current,Ca(t)),t,n),o=await Ju(e),s={id:o.id,title:i.title,body:i.body,section:i.section,order:i.order,level:i.level,legacy:i.legacy,version:0,updatedAt:new Date().toISOString()};r()&&b(e=>[...e,s]);let c=await Zi(o.id,0,i);if(c===null)return!1;r()&&b(e=>Wt(e,o.id,{version:c}));let l=Sa.current.then(async()=>{for(let e of a)await sa(e.id,{section:y.current.find(t=>t.id===e.id)?.section,order:e.order})});return Sa.current=l.catch(()=>{}),await l,!0}async function Oa(){let t=U.current;if(vr.current||!h||!t||xn())return;vr.current=!0,_r(t.id);let n=h,r=h.id,i=()=>(Or.current??pt.current?.id)===r;try{Dt&&await Gi(t,!0);let a=U.current;a?.id===t.id&&!Gt(a,t)&&await Gi(a,!0),await Mr.current;let o=await Xc(e.user.id,t.id).catch(()=>void 0),s=o?.conflicted?o:void 0,c=await Yu(t.id),l=!sn.current.has(r),u=await cm(rn(n,c.keyGeneration),e=>Nt(e,r,t.id,c.bytes,l));if(u?.type!==`page`)throw Error(`Unable to read the server version of this page.`);let d={title:u.title,body:u.body,section:u.section,order:u.order,level:u.level,legacy:u.legacy,version:c.version};if(i()&&b(e=>e.map(e=>e.id===t.id?{...e,...d}:e)),U.current?.id===t.id){let e={...U.current,...d};U.current=e,ne(e),Rt(!1),hr(e=>e+1)}W(``);let f=0,p=0,m=[],h=(await ad(t.id)).filter(e=>!e.resolved);for(let e of h)try{let i=await od(e.id),a=await cm(rn(n,e.keyGeneration),e=>Nt(e,r,t.id,i,l)).catch(()=>void 0);a?.type===`page`?m.push({id:e.id,createdAt:e.createdAt,payload:a}):p+=1}catch(e){f+=1,W(e instanceof Error?e.message:`Unable to read a conflicting version`)}let{resolveOnly:g,groups:_}=Le(d,m);for(let e of g)await sd(e).catch(()=>{f+=1});for(let e of _)if(!i()||xn())f+=1;else try{if(!await Da(r,y.current.find(e=>e.id===t.id)??{id:t.id,...d},e.payload,i)){f+=1;continue}for(let t of e.ids)await sd(t)}catch(e){f+=1,W(e instanceof Error?e.message:`Unable to keep a conflicting version`)}let v=y.current.find(e=>e.id===t.id);if(v&&i()&&U.current?.id===t.id&&P(Ca(v)),p?W(`${p} version(s) could not be opened with this notebook's key and remain on the server.`):f&&W(e=>e||`Some conflicting versions could not be copied; try again.`),!f&&!p){s&&await $c(s);let n=await Xc(e.user.id,t.id).catch(()=>void 0);if(n){ct(n.conflicted?`attention`:`local`);return}it.current.delete(t.id),rt(e=>{let n=new Set(e);return n.delete(t.id),n}),ct(`saved`)}}catch(e){W(e instanceof Error?e.message:`Unable to keep the conflicting version`)}finally{vr.current=!1,_r(null)}}function ka(e,t){let n=U.current;if(n?.id!==e||gr===e)return;let r={...n,...t};U.current=r,ne(r),b(e=>Ut(e,n,r,t)),Rt(!0),Xi(r)}async function Aa(t,n,r,i,a){let o=on(t);if(!o)throw new Pm;let s=await hm(o,t.id,n,i,a),c=await Vm({container:t,generation:s.keyGeneration},s.payload.byteLength,await nt(s.payload)),l={uploadId:c.uploadId,owner:e.user.id,containerID:t.id,objectID:n,objectVersion:r,...s,chunkBytes:c.chunkBytes,nextChunk:c.nextChunk,name:a.name,type:a.type,size:a.size};return await rl(l),l}async function ja(t,n,r,i){let a=await Aa(n,t.objectID,t.objectVersion,r,i);return await $u(t.uploadId).catch(()=>void 0),await al(e.user.id,t.uploadId),qe(e=>{let n={...e};return delete n[t.uploadId],n}),a}async function Ma(t,n=0){if(n>1)throw new Pm;if(t.owner!==e.user.id)throw Error(`This upload belongs to another account.`);let r=await dr(await tr(t.containerID),!0),i=await gm(t,r,tn(r),on(r),zt.current[r.id]??en,Fn.current);if(i.kind===`wait`)throw new Pm;if(i.kind===`reseal`)return Ma(await ja(t,r,i.plaintext,i.file),n+1);let a={container:r,generation:t.keyGeneration},o=await Qu(t.uploadId),s=o.nextChunk,c=s*t.chunkBytes;for(qe(e=>({...e,[t.uploadId]:{name:t.name,uploaded:o.receivedBytes,total:t.payload.byteLength}}));c({...e,[t.uploadId]:{name:t.name,uploaded:n.receivedBytes,total:t.payload.byteLength}}))}let l;try{l=await Um(a,t.uploadId,t.metadataCiphertext)}catch(e){if(!(e instanceof Z&&e.code===`already_exists`))throw e;return Ma(t,n+1)}return await nd(t.objectID,l.attachmentId,t.objectVersion),await al(e.user.id,t.uploadId),qe(e=>{let n={...e};return delete n[t.uploadId],n}),{id:l.attachmentId,keyGeneration:t.keyGeneration}}async function Na(){if(!ut.current){ut.current=!0;try{for(let t of await il(e.user.id))try{await Ma(t),W(`Attachment uploaded: ${t.name}`)}catch{qe(e=>({...e,[t.uploadId]:{name:t.name,uploaded:0,total:t.payload.byteLength,failed:!0}})),W(`Attachment waiting to resume: ${t.name}`)}}catch{}finally{ut.current=!1}}}async function Pa(t){Je.current.add(t);try{await $u(t)}catch{}await al(e.user.id,t),qe(e=>{let n={...e};return delete n[t],n})}async function Fa(t){Je.current.delete(t);let n=(await il(e.user.id)).find(e=>e.uploadId===t);if(n)try{await Ma(n)}catch{W(`Attachment waiting to resume: ${n.name}`)}}async function Ia(e){if(!h||!z)throw Error(`Select a note first`);let t=await Aa(h,z.id,z.version,new Uint8Array(await e.arrayBuffer()),{name:e.name,type:e.type,size:e.size}),n=await Ma(t);return{id:n.id,name:e.name,type:e.type,size:e.size,keyGeneration:n.keyGeneration,page:t.objectID}}async function La(e){if(h&&z&&!xn()){G(!0);try{let t=await Ia(e);ae(e=>[...e,t]),W(`Attachment uploaded and encrypted.`)}catch(e){W(e instanceof Error?e.message:`Unable to upload attachment`)}finally{G(!1)}}}async function Ra(e){let t=await Ia(e);return ae(e=>[...e,t]),`attachment://${t.id}`}async function za(e){if(!e.startsWith(`attachment://`)||!h)return e;let t=e.slice(13),n=Ae[t];if(n)return n;let r=ie.find(e=>e.id===t);if(!r)return e;let i=await id(r.id),a=h.id,o=await un(a,r.page,r.id,i),s=await cm(rn(h,r.keyGeneration),e=>At(e,a,r.page,i,o)),c=URL.createObjectURL(new Blob([s.slice().buffer],{type:r.type}));return Ge.current.push(c),c}async function Ba(e){if(h)try{let t=await id(e.id),n=h.id,r=await un(n,e.page,e.id,t),i=await cm(rn(h,e.keyGeneration),i=>At(i,n,e.page,t,r)),a=URL.createObjectURL(new Blob([i.slice().buffer],{type:e.type||`application/octet-stream`})),o=document.createElement(`a`);o.href=a,o.download=e.name,o.click(),URL.revokeObjectURL(a)}catch(e){W(e instanceof Error?e.message:`Unable to open attachment`)}}async function Va(t){let n=U.current?.id,r=pt.current?.id;if(!n||!r||t.authorUserId!==e.user.id&&bt.current!==`owner`&&bt.current!==`admin`||!confirm(`Delete this comment for everyone? This cannot be undone.`))return;G(!0);let i=()=>U.current?.id===n&&pt.current?.id===r;try{await Gu(t.id),i()&&B(e=>e.filter(e=>e.id!==t.id))}catch(e){i()&&W(e instanceof Error?e.message:`Unable to delete comment`)}finally{G(!1)}}async function Ha(){if(z&&h&&Ye.trim()&&!bn()){G(!0);try{let t=on(h);if(!t)throw Error(G_);let n=await wt(t.key,h.id,z.id,Ye.trim(),Ze.trim());try{let r=Dn?.containerID===h.id?Dn.members:gt;await Bm({container:h,generation:t.generation},z.id,Qe(n),d_(Ye,r,e.user.id))}catch(e){if(!(e instanceof Z&&e.code===`already_exists`))throw e;let t=await dr(h);throw g(e=>e?.id===t.id?t:e),Error(`This notebook's keys just changed. Send the comment again.`)}if(U.current?.id!==z.id)return;Xe(``),et(``),await Fi(z)}catch(e){W(e instanceof Error?e.message:`Unable to add comment`)}finally{G(!1)}}}async function Ua(){let t=h;if(!t)return;let n=prompt(`User ID to invite (Settings shows each person's user ID)`)?.trim();if(n)try{let r={container:t,ring:zt.current[t.id]??en,floor:tn(t)},i={userId:n,username:On.current[n]??``,role:`editor`},a={userId:e.user.id,identity:await Un(),canWrap:!e.sso,recoverable:Vd(Rn.current)},{invitation:o,keys:s,recipient:c}=await u_({userIdentity:Lu,stepUp:nr.stepUp,invite:Vu},r,i,a,rr,sr(t.id)),l=s===`sealed`?`The invitation carries this team's keys, sealed for the key with fingerprint ${await ar(c.identity.publicKey)}; compare it with ${mi(i.username,n)} (their Settings shows it).`:vb[s];prompt(`${l} Send this link to the person you invited. It works once, only for their account, until ${new Date(o.expiresAt).toLocaleString()}.`,h_(location.origin,o))}catch(e){W(e instanceof Error?e.message:`Unable to invite member`)}}function Wa(){An(void 0),x_(v_())}async function Ga(){let e=kn;if(e){An(void 0);try{await Hu(e.id,e.token),Wa(),W(`You joined the team.`)}catch(t){let n=t instanceof Z?t:void 0,r=t instanceof Error?t.message:`Unable to join the team`;S_(n?.status,n?.code)?(Wa(),W(n?.code===`not_found`?`This invitation is no longer valid: it expired, was already used, is for another account, or its sender can no longer invite.`:n?.code===`already_exists`?`You are already a member of this team.`:r)):(An(e),W(`Could not join the team: ${r}. The invitation is kept; choose Join team to try again.`))}await Ei()}}async function Ka(){let t=pt.current;if(!t)return;let n=(Dn?.containerID===t.id?Dn.members:[]).filter(t=>(t.role===`owner`||t.role===`admin`)&&t.userId!==e.user.id).map(e=>mi(e.username,e.userId)),r=await Un(),i=C_({notebook:Br(t),stewards:n,fingerprint:r?await ar(Qe(r.publicKey)):``,link:`${location.origin}/${Be({container:t.id})}`});prompt(`Send this to ${n.join(` or `)||`a team owner`}. Their browser shares this notebook's key when they open it.`,i)}async function qa(e){if(h&&confirm(`Remove this person from the team?`))try{await Uu(h.id,e),await Ja(h)}catch(e){W(e instanceof Error?e.message:`Unable to remove member`)}}async function Ja(e,t=!1){for(let n of i.filter(t=>t.teamId===e.id))await dr(n,!1,()=>!1,t);let n=await dr(e,!1,()=>!1,t);g(e=>e?.id===n.id?n:e);let r=await Ru(e.id);pt.current?.id===e.id&&_t(r)}async function Ya(e){if(h?.kind===`team`){G(!0);try{await uu(h.id,e),await Ja(h,!0)}catch(e){W(e instanceof Error?e.message:`Unable to approve`)}finally{G(!1)}}}async function Xa(){if(z){if(zv(z.body))W(`This page has only a drawing. Shared links show a page's text, so there is nothing to share yet; add text to share it.`);else try{let t=await It({title:z.title,body:Rv(z.body)}),n=await cd(t.ciphertext,new Date(Date.now()+6048e5).toISOString()),r=h&&dn(h);h&&r&&await I_(e.user.id,n.id,h.id,r,{title:z.title,notebook:Br(h)}).catch(()=>void 0),await navigator.clipboard.writeText(`${location.origin}/share/${n.token}#${t.key}`);let i=Lv(z.body);W(i?`Encrypted share link copied. It shows the page's text only; drawings are not included. The key is only in the URL fragment. Revoke it under Settings → Share links.`:`Encrypted share link copied. The key is only in the URL fragment. Revoke it under Settings → Share links.`)}catch(e){W(e instanceof Z&&e.code===`payload_too_large`?`This page is too large to share as a link. Export it instead, or split it into smaller pages.`:e instanceof Error?e.message:`Unable to create encrypted link`)}}}let Za=i.filter(e=>e.kind!==`team`&&!e.teamId),Qa=i.filter(e=>e.kind===`team`),$a=e=>i.filter(t=>t.teamId===e),eo=xr===`workspace`,to=(e,t,n=!1)=>{let r=!wr&&h?.id===e.id,i=(0,$.jsxs)(`button`,{className:`ky-nav-item nav-item notebook-item${n?` nested-nav-item`:``}`,"aria-current":r?`true`:void 0,"data-open":h?.id===e.id?`true`:void 0,onClick:()=>{l(!0),Oi(e)},children:[(0,$.jsx)(df,{name:t}),(0,$.jsx)(`span`,{children:Br(e)})]},e.id);return!r||!h?i:(0,$.jsxs)(X.Fragment,{children:[(0,$.jsxs)(`div`,{className:`notebook-row`,children:[i,(0,$.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`notebook-menu`,"aria-label":`Notebook options`,style:{anchorName:`--notebook-menu`},children:(0,$.jsx)(df,{name:`more`})}),(0,$.jsxs)(`div`,{className:`section-menu anchored-menu`,id:`notebook-menu`,popover:`auto`,style:{positionAnchor:`--notebook-menu`},children:[(0,$.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),zi()},children:`Rename notebook`}),(0,$.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),Vi()},children:`Export notebook`}),(0,$.jsx)(`button`,{className:`quiet`,disabled:Et||mn||gn,onClick:()=>{no(`notebook-menu`),fa(`section`)},children:`New section`}),(0,$.jsx)(`button`,{className:`quiet`,disabled:Et||mn||gn||pe(M,k).length>=4,onClick:()=>{no(`notebook-menu`),fa(`group`)},children:`New section group`}),h.kind===`team`&&_n&&(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>{no(`notebook-menu`),Ua()},children:`Add person`}),h.kind===`team`&&_n&&(0,$.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),Ri(h)},children:`Create team notebook`}),vt===`owner`&&(0,$.jsx)(`button`,{className:`quiet danger`,disabled:Et,onClick:()=>{no(`notebook-menu`),Bi()},children:`Delete notebook`})]})]}),(0,$.jsx)(`div`,{className:`notebook-sections`,children:(0,$.jsx)(iv,{sections:la,groups:ua,path:xa,current:A,busy:Et||mn||gn,moveTargets:vi,onSelect:e=>{Sr(`workspace`),s(!1),l(!0),ya(e)},onRename:ma,onColor:(e,t,n)=>void Qi(e,t.id,{color:n}).catch(pa),onDelete:e=>void ha(e),onDeleteGroup:e=>void ga(e),onMove:(e,t,n)=>void _a(e,t,n),onMoveIntoGroup:(e,t,n)=>void va(e,t,n),onOpenGroup:e=>void ba(e),onDropPage:(e,t)=>{let n=y.current.find(t=>t.id===e);n&&Ca(n)!==t&&Ta(e,t,null)}})})]},e.id)},no=e=>document.getElementById(e)?.hidePopover(),ro=Dt?`Unsaved changes`:st===`syncing`?`Syncing…`:st===`local`?`Saved locally`:st===`attention`?`Needs attention`:`Saved to server`,io=z&&[Ti?`Autosaving…`:st===`local`?`Encrypted, waiting to sync`:st!==`attention`&&at?new Date(at).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):``,z.version?`Version ${z.version}`:`Draft`].filter(Boolean).join(` · `),ao=h??i[0],oo=()=>{s(!1),wr&&ao?Oi(ao):Sr(`workspace`)},so=Wn===`held`&&zn&&!zn.recoveryId&&!ve&&(0,$.jsxs)(`div`,{className:`recovery-notice`,children:[(0,$.jsxs)(`details`,{children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(df,{name:`sso`}),(0,$.jsx)(`span`,{children:`Save a recovery code`}),(0,$.jsx)(df,{name:`chevron`})]}),(0,$.jsxs)(`div`,{className:`recovery-notice-body`,role:`status`,children:[`Save a recovery code so you can get your encryption key back if no browser holds it and your password cannot open it.`,` `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>Cr(`account`),children:`Create recovery code`})]})]}),(0,$.jsx)(`button`,{type:`button`,className:`icon-button quiet`,"aria-label":`Dismiss the recovery code reminder for now`,onClick:()=>Te(!0),children:(0,$.jsx)(df,{name:`close`})})]});return(0,$.jsxs)(Ef,{className:`workspace${wr?` queue-mode`:``}${eo?` has-panes`:``}`,label:`Primary`,onSignOut:t,user:{name:e.username||e.user.id.slice(0,12),role:`Everyday account`},settings:{items:Ve.map(([e,t])=>({href:We(e),label:t,current:xr===`settings`&&(yr??`account`)===e})),current:xr===`settings`},nav:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Cf,{icon:`notes`,label:`Notes`,current:eo&&!wr,disabled:wr&&!ao,expanded:f&&eo&&!wr?o:void 0,controls:f?`notebook-tree`:void 0,onClick:()=>f&&eo&&!wr?s(e=>!e):oo()}),(0,$.jsx)(Cf,{icon:`work`,label:`Work queue`,current:eo&&wr,onClick:()=>{Et||(l(!0),Ni())}})]}),tree:(0,$.jsx)(`div`,{id:`notebook-tree`,className:`notes-tree`,"data-open":o||void 0,children:(0,$.jsxs)(`nav`,{id:`notebook-navigation`,className:`sidebar`,"aria-label":`Notebooks`,children:[(0,$.jsx)(`div`,{className:`section-label`,children:`Notebooks`}),Za.map(e=>to(e,`notebook`)),Qa.length>0&&(0,$.jsx)(`div`,{className:`section-label team-label`,children:`Team notebooks`}),Qa.map(e=>(0,$.jsxs)(X.Fragment,{children:[to(e,`team`),$a(e.id).map(e=>to(e,`notebook`,!0))]},e.id)),(0,$.jsxs)(`button`,{className:`new-workspace personal-create`,"aria-label":`+ New notebook`,disabled:Et,onClick:()=>void Li(),children:[(0,$.jsx)(df,{name:`plus`}),` New notebook`]}),h?.kind===`team`&>.length>0&&(0,$.jsxs)(`div`,{className:`member-list`,children:[(0,$.jsxs)(`div`,{className:`section-label`,children:[`People in `,Br(h)]}),gt.map(t=>(0,$.jsxs)(`div`,{className:`member-row`,children:[(0,$.jsxs)(`span`,{children:[mi(t.username,t.userId),` · `,t.pendingRole?`${t.pendingRole} once approved`:t.role,Dn?.containerID===h.id&&Dn.status[t.userId]&&` · ${hb[Dn.status[t.userId]]}`,t.keyResetAt&&` · reset their key ${Z_(t.keyResetAt)}`]}),_n&&t.userId!==e.user.id&&(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>void qa(t.userId),children:`Remove`})]},t.userId))]})]})}),children:[(0,$.jsxs)(`div`,{className:`notes-panes`,hidden:!eo,"data-phone-view":!h&&!wr?void 0:!z||c?`list`:`page`,children:[(0,$.jsxs)(`section`,{id:`page-navigation`,className:`note-list${!h&&!wr?` no-notebook`:``}`,"aria-busy":Er,"aria-labelledby":`page-navigation-title`,children:[h&&!wr&&(0,$.jsx)(`p`,{className:`workspace-title`,children:Br(h)}),(0,$.jsxs)(`div`,{className:`pane-head`,children:[(0,$.jsx)(`h2`,{id:`page-navigation-title`,className:`pane-title`,children:wr?`Work queue`:Fr.trim()?`Search results`:Xr(A)}),h&&!wr&&(0,$.jsx)(`button`,{className:`icon-button quiet`,"aria-label":`New page`,title:`New page`,disabled:Et||di||mn||gn,onClick:()=>{Sr(`workspace`),s(!1),l(!1),Hi()},children:(0,$.jsx)(df,{name:`plus`})})]}),wr&&(0,$.jsxs)(`p`,{className:`workspace-kind`,children:[`Open tasks across your personal notebooks · `,ui.length,` open task`,ui.length===1?``:`s`]}),(h||wr)&&(0,$.jsxs)(`label`,{className:`note-search-field`,children:[(0,$.jsx)(df,{name:`search`}),(0,$.jsx)(`input`,{"aria-label":wr?`Search the work queue`:`Search this notebook`,className:`note-search`,type:`search`,value:Fr,onChange:e=>Ir(e.target.value),placeholder:`Search`})]}),wr&&Vv.map(([e,t])=>{let n=ui.filter(t=>t.group===e);return n.length>0&&(0,$.jsxs)(`div`,{className:`task-group`,"data-task-group":e,children:[(0,$.jsx)(`h3`,{className:`notes-heading`,children:t}),n.map((e,t)=>(0,$.jsx)(`div`,{className:`note-row-wrap ${z?.id===e.entry.note.id?`selected`:``}`,children:(0,$.jsxs)(`button`,{className:`note-row`,onClick:()=>{Sr(`workspace`),u.current=f,Pi(e.entry)},children:[(0,$.jsx)(`strong`,{children:e.text||`Untitled task`}),(0,$.jsx)(`span`,{children:[e.due&&`Due ${e.due}`,e.repeat&&`repeats`,e.push&&`push`,e.missed&&`missed reminder`,e.entry.note.title||`Untitled page`].filter(Boolean).join(` · `)})]})},`${e.key}\n${t}`))]},e)}),!wr&&pi.map(({note:e,row:t})=>{let n=e.title||`Untitled page`;return(0,$.jsxs)(`div`,{className:`note-row-wrap ${z?.id===e.id?`selected`:``}`,style:t?{paddingInlineStart:t.level*16}:void 0,onDragOver:e=>{ci&&e.dataTransfer.types.includes(`application/x-kynotes-page`)&&e.preventDefault()},onDrop:t=>{let n=t.dataTransfer.getData(`application/x-kynotes-page`),r=gi(n);if(!ci||r<0)return;let i=bi(xe(Wr,r,gi(e.id)));i!==void 0&&Ta(n,A,i)},children:[t&&!t.hasChildren&&(0,$.jsx)(`span`,{className:`page-toggle-space`,"aria-hidden":`true`}),t?.hasChildren&&(0,$.jsx)(`button`,{className:`page-toggle quiet`,"aria-expanded":!t.collapsed,"aria-label":`${t.collapsed?`Expand`:`Collapse`} ${n}`,onClick:()=>Jr(e.id),children:(0,$.jsx)(df,{name:`chevron`})}),(0,$.jsxs)(`button`,{className:`note-row`,"aria-current":eo&&z?.id===e.id?`page`:void 0,"data-page-id":e.id,draggable:!gn,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-kynotes-page`,e.id)},onKeyDown:t=>{if(!ci)return;let n=gi(e.id),r=t.ctrlKey&&t.altKey?t.key===`]`||t.code===`BracketRight`?1:t.key===`[`||t.code===`BracketLeft`?-1:0:0;if(r){let n=r;if(!_i(e.id,n))return;t.preventDefault(),Ea(e.id,n);return}if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;let i=bi(be(Wr,n,t.key===`ArrowUp`?-1:1));i!==void 0&&(t.preventDefault(),Ta(e.id,A,i).then(()=>document.querySelector(`.note-row[data-page-id="${CSS.escape(e.id)}"]`)?.focus()))},"aria-keyshortcuts":ci?`Alt+ArrowUp Alt+ArrowDown Control+Alt+BracketRight Control+Alt+BracketLeft`:void 0,onClick:()=>{Sr(`workspace`),z?.id===e.id?(s(!1),l(!1),f&&requestAnimationFrame(()=>d.current?.focus())):(u.current=f,Fi(e))},children:[(0,$.jsxs)(`span`,{className:`note-row-head`,children:[(0,$.jsx)(`strong`,{children:n}),(0,$.jsx)(`time`,{dateTime:e.updatedAt,title:e.updatedAt?new Date(e.updatedAt).toLocaleString():void 0,children:ov(e.updatedAt)})]}),t&&(t.level>0||t.hasChildren)&&(0,$.jsxs)(`span`,{className:`visually-hidden`,children:[t.level>0?`, subpage level ${t.level}`:``,t.hasChildren?t.collapsed?`, collapsed, ${yi(e.id)} subpages hidden`:`, expanded`:``]}),(0,$.jsxs)(`span`,{className:`note-snippet`,children:[Fr.trim()&&(0,$.jsxs)(`em`,{className:`page-section`,children:[Xr(e.section),` · `]}),ly([e])[0].body.slice(0,160)||`Empty page`]})]})]},e.id)}),h&&(si.length===0||fi)&&(0,$.jsx)(`p`,{className:`empty-list`,children:wr?`No open tasks here. Tasks from note checklists appear here.`:fi?`This group has no sections. Add one from the notebook menu to add pages.`:`No pages in this section yet.`}),xi.length>0&&(0,$.jsxs)(`div`,{className:`context-panel`,children:[(0,$.jsx)(`div`,{className:`section-label`,children:`Resurfacing`}),xi.map(e=>(0,$.jsx)(`button`,{className:`context-link`,onClick:()=>{Sr(`workspace`),Fi(e)},children:e.title||`Untitled page`},e.id))]}),Si.length>0&&(0,$.jsxs)(`div`,{className:`context-panel`,children:[(0,$.jsx)(`div`,{className:`section-label`,children:`Knowledge graph`}),(0,$.jsxs)(`span`,{className:`config-muted`,children:[Si.length,` local link`,Si.length===1?``:`s`]})]})]}),(0,$.jsxs)(`section`,{className:`editor`,children:[(0,$.jsxs)(`div`,{className:`workspace-notices`,children:[!wr&&mn&&h&&(0,$.jsx)(`p`,{className:`workspace-kind`,role:`status`,children:yn?sb:(()=>{let e=X_({steward:vn(h),held:Wn===`held`,recoverable:Vd(zn),shared:Math.max(h.sharedGeneration,tn(h)?.shared??0)>0}),t=Dn?.containerID===h.id?Q_(Dn.members):void 0;return(0,$.jsxs)($.Fragment,{children:[e.text,t&&(0,$.jsxs)($.Fragment,{children:[` `,t]}),e.action===`ask`&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>void Ka(),children:`Ask an owner`})]}),e.action===`settings`&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>Cr(Wn===`held`?`account`:`devices`),children:`Open Settings`})]})]})})()}),!wr&&Sn&&(0,$.jsx)(`p`,{className:`workspace-kind`,role:`status`,children:Sn}),!wr&&wn&&(0,$.jsxs)(`p`,{className:`workspace-kind`,role:`status`,children:[`This notebook's keys are not set up or shared yet. `,(0,$.jsxs)(`button`,{className:`quiet`,onClick:()=>void fr(),children:[`Set up keys (confirm with `,e.sso?`KySignOn`:`your password`,`)`]})]}),Kn&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`A reset of your encryption key from this browser finished on the server, but its answer never arrived here, so this browser still holds your previous key. Use Forget this device, sign in again, then restore with the new recovery code the reset showed you, or link this browser from one that holds the new key.`,` `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>{confirm(pb)&&n?.()},children:`Forget this device`})]}),Wn===`link`&&!Kn&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`This browser does not hold your encryption key, so your notebooks are read-only here. `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>Cr(`devices`),children:`Link this browser`})]}),e.sso&&Wn===`create`&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`Set up your encryption key so you can write in your notebooks and team owners can share theirs with you. `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>void er(!1),children:`Set up encryption key`})]}),e.sso&&Wn===`orphaned`&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`The server no longer lists the encryption key this browser holds (a reset from another browser replaced it). `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>void er(!0),children:`Replace encryption key`})]}),(!z||f&&c)&&so,h&&_n&&h.metaVersion===0&&on(h)&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[gb,` `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>void zi(),children:`Name notebook`})]}),_n&>.filter(e=>e.approved===!1).map(e=>(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[_b(mi(e.username,e.userId)),` `,(0,$.jsx)(`button`,{className:`secondary`,disabled:Et,onClick:()=>void Ya(e.userId),children:`Approve and share keys`})]},e.userId)),(0,$.jsx)(i_,{status:Zn,set:Qn}),kn&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`You were invited to a team notebook.`,` `,(0,$.jsx)(`button`,{className:`secondary`,onClick:()=>void Ga(),children:`Join team`}),` `,(0,$.jsx)(`button`,{className:`quiet`,onClick:Wa,children:`Not now`})]})]}),z?(0,$.jsxs)($.Fragment,{children:[tt.has(z.id)&&(0,$.jsxs)(`div`,{className:`conflict-banner`,role:`alert`,children:[gr===z.id?`Saving the other version as a copy…`:`Another device saved this page first. Your version was kept separately; save it as a copy next to this page.`,(0,$.jsx)(`button`,{className:`secondary`,disabled:gr!==null||mn||gn,onClick:()=>void Oa(),children:`Keep the other version as a copy`})]}),(0,$.jsxs)(`button`,{type:`button`,className:`quiet pane-back`,onClick:()=>{l(!0),requestAnimationFrame(()=>document.querySelector(`.note-list .note-row[aria-current]`)?.focus())},children:[(0,$.jsx)(df,{name:`back`}),(0,$.jsx)(`span`,{children:wr?`Work queue`:Xr(A)})]}),(0,$.jsxs)(`div`,{className:`page-head`,children:[(0,$.jsx)(`input`,{ref:d,"aria-label":`Page title`,className:`title-input`,readOnly:gr===z.id||mn||gn,value:z.title,onChange:e=>ka(z.id,{title:e.target.value})}),(0,$.jsxs)(`div`,{className:`page-head-actions`,children:[!(f&&c)&&so,(0,$.jsxs)(`p`,{className:`save-state`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`ky-status`,"data-ky-status":Dt?void 0:Tb[st],children:ro}),io&&(0,$.jsx)(`span`,{className:`save-detail`,children:io})]}),(0,$.jsx)(`button`,{className:`save-button secondary`,disabled:Et,onClick:()=>void Gi(z),children:Et?`Saving…`:`Save`}),(0,$.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`page-menu`,"aria-label":`Page options`,style:{anchorName:`--page-menu`},children:(0,$.jsx)(df,{name:`more`})}),(0,$.jsxs)(`div`,{className:`section-menu anchored-menu page-menu`,id:`page-menu`,popover:`auto`,style:{positionAnchor:`--page-menu`},children:[(0,$.jsx)(`span`,{className:`menu-caption`,"aria-hidden":`true`,children:`Section`}),(0,$.jsxs)(`div`,{className:`page-section-control`,children:[(0,$.jsxs)(`select`,{"aria-label":`Move page to section`,disabled:mn||gn,value:Ne([z],x,`quick`).length?Ce:z.section,onChange:e=>{no(`page-menu`),Ta(z.id,e.target.value,null)},children:[_e(x,T,k).map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id)),(0,$.jsx)(`option`,{value:Ce,children:`Quick Notes`})]}),(0,$.jsx)(df,{name:`chevron`})]}),(0,$.jsx)(`button`,{className:`quiet`,disabled:mn||gn||!_i(z.id,1),title:`Ctrl+Alt+]`,onClick:()=>{no(`page-menu`),Ea(z.id,1)},children:`Indent page`}),(0,$.jsx)(`button`,{className:`quiet`,disabled:mn||gn||!_i(z.id,-1),title:`Ctrl+Alt+[`,onClick:()=>{no(`page-menu`),Ea(z.id,-1)},children:`Outdent page`}),(0,$.jsx)(`button`,{className:`quiet danger`,disabled:mn||gn,onClick:()=>{no(`page-menu`),Yi(z)},children:`Delete page`})]})]})]}),(0,$.jsx)(`div`,{className:`page-canvas`,children:(0,$.jsx)(ob,{children:(0,$.jsx)(X.Suspense,{fallback:(0,$.jsx)(`div`,{className:`editor-loading`,children:`Loading page…`}),children:(0,$.jsx)(ab,{pageID:z.id,body:z.body,editable:gr!==z.id&&!mn&&!gn,onChange:e=>ka(z.id,{body:e}),onError:W,uploadFile:Ra,resolveFileUrl:za},`${z.id}:${mr}`)})},z.id)}),(0,$.jsxs)(`details`,{className:`page-panel comments`,open:oe,onToggle:e=>me(e.currentTarget.open),children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(`span`,{children:`Comments`}),re.length>0&&(0,$.jsx)(`span`,{className:`page-panel-count`,children:re.length}),(0,$.jsx)(df,{name:`chevron`})]}),re.map(t=>(0,$.jsxs)(`div`,{className:`comment`,children:[(0,$.jsxs)(`div`,{className:`comment-head`,children:[(0,$.jsxs)(`strong`,{children:[t.username,t.section?` · § ${t.section}`:``]}),(t.authorUserId===e.user.id||vt===`owner`||vt===`admin`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`comment-menu-${t.id}`,"aria-label":`Comment options by ${t.username}`,style:{anchorName:`--comment-${t.id}`},children:(0,$.jsx)(df,{name:`more`})}),(0,$.jsx)(`div`,{className:`section-menu anchored-menu`,id:`comment-menu-${t.id}`,popover:`auto`,style:{positionAnchor:`--comment-${t.id}`},children:(0,$.jsx)(`button`,{className:`quiet danger`,disabled:Et,onClick:()=>{no(`comment-menu-${t.id}`),Va(t)},children:`Delete comment`})})]})]}),(0,$.jsx)(`span`,{children:t.body})]},t.id)),(0,$.jsxs)(`div`,{className:`comment-compose`,children:[(0,$.jsx)(`input`,{"aria-label":`Comment section (optional)`,value:Ze,onChange:e=>et(e.target.value),placeholder:`Section (optional)`}),(0,$.jsx)(`input`,{"aria-label":`Comment`,value:Ye,onChange:e=>Xe(e.target.value),placeholder:`Add a comment…`}),(0,$.jsx)(`button`,{className:`secondary`,disabled:Et||mn,onClick:()=>void Ha(),children:`Comment`})]})]}),(0,$.jsxs)(`details`,{className:`page-panel attachments`,open:Ee,onToggle:e=>De(e.currentTarget.open),children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(`span`,{children:`Attachments`}),ie.length>0&&(0,$.jsx)(`span`,{className:`page-panel-count`,children:ie.length}),(0,$.jsx)(df,{name:`chevron`})]}),Object.entries(Ke).map(([e,t])=>(0,$.jsxs)(`div`,{className:`upload-row`,children:[(0,$.jsxs)(`span`,{children:[t.name,` · `,t.failed?`waiting to retry`:`${Math.round(t.uploaded/Math.max(t.total,1)*100)}%`]}),(0,$.jsxs)(`div`,{className:`upload-actions`,children:[t.failed&&(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>void Fa(e),children:`Retry`}),(0,$.jsx)(`button`,{className:`quiet`,onClick:()=>void Pa(e),children:`Cancel`})]})]},e)),ie.map(e=>(0,$.jsxs)(`button`,{className:`attachment-row`,onClick:()=>void Ba(e),children:[(0,$.jsx)(`strong`,{children:e.name}),(0,$.jsxs)(`span`,{children:[Math.ceil(e.size/1024),` KB`]})]},e.id)),(0,$.jsxs)(`label`,{className:`attachment-picker`,children:[(0,$.jsx)(df,{name:`plus`}),(0,$.jsx)(`span`,{children:`Add encrypted file`}),(0,$.jsx)(`input`,{type:`file`,disabled:Et||mn||gn,onChange:e=>{let t=e.target.files?.[0];t&&La(t),e.currentTarget.value=``}})]})]})]}):(0,$.jsxs)(`div`,{className:`empty-editor`,children:[(0,$.jsx)(`h2`,{children:!h&&!wr?i.length?`Select a notebook`:`No notebooks yet`:`Your private desk`}),(0,$.jsxs)(`p`,{children:[!h&&!wr?`Start with a notebook to keep your notes together.`:`Select a page or create one.`,` The server receives ciphertext only.`]}),!h&&!wr&&(0,$.jsx)(`button`,{disabled:Et,onClick:()=>void Li(),children:`New notebook`}),h&&(0,$.jsx)(`button`,{disabled:mn||gn,onClick:()=>void Hi(),children:`Create a note`})]})]})]}),xr===`settings`&&(0,$.jsx)(Ob,{tab:yr??`account`,username:e.username,userID:e.user.id,colleagueNames:On.current,keysFor:e=>an(i.find(t=>t.id===e.containerID),e.keyGeneration),onForgetDevice:n,onAuthSecret:r,identityState:Wn,sso:!!e.sso,heldIdentity:Un,identityStore:$n,stepUp:nr.stepUp,live:zn,recoveryPrompt:Vn,onIdentityChanged:Xn,onReset:e=>{Yn(e).catch(()=>void 0).finally(Xn)},resetUnfinished:Kn,waitingHeld:In,reminders:L,onReminders:R}),Lr&&Uy(Lr)&&(0,$.jsxs)(`button`,{className:`toast commit-toast`,onClick:()=>Rr(null),children:[Wy(Lr),` ×`]}),xt&&(0,$.jsxs)(`button`,{className:`toast error`,onClick:()=>W(``),children:[xt,` ×`]})]})}function wb({username:e,userID:t,everyday:n,onAuthSecret:r,onIdentityCreated:i,onChanged:a}){let[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1);async function m(u){u.preventDefault();let f=u.currentTarget.elements.namedItem(`confirm`)?.value,m=U_(c,f);if(m)d(m);else{p(!0);try{let u=e||prompt(`Username`)?.trim();if(!u)throw Error(`Username is required`);let f=await Wl(u),p=await ut(o,f.loginSalt,f.iterations,Yd(u)),m=ft(),h=await ut(c,m,6e5);if(!n){await hu({currentAuthSecret:p.authSecret,newAuthSecret:h.authSecret,newLoginSalt:m,iterations:6e5}),Xd(u),s(``),l(``),d(`Password changed.`),a?.(h.authSecret);return}let g=await Ld(Nu,t,p,h,await _l(u,t).catch(()=>void 0));await sl(()=>hu({currentAuthSecret:p.authSecret,newAuthSecret:h.authSecret,newLoginSalt:m,iterations:6e5,identityDeviceId:g?.identityDeviceId,wrappedIdentityKey:g?.wrappedIdentityKey}),u,g&&{userID:t,identity:g.identity}),Xd(u),g||(await Ky(u,t,h),i()),r(h.authSecret),s(``),l(``),d(`Password changed.`),a?.(h.authSecret)}catch(e){d(e instanceof Error?e.message:`Unable to change password`)}finally{p(!1)}}}return(0,$.jsxs)(`section`,{className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Change password`}),(0,$.jsx)(`p`,{className:`config-muted`,children:`Passwords are converted to client-derived secrets in this browser. They are never sent to the server. Changing it signs out your other browsers and unpairs your devices; this browser stays signed in.`}),(0,$.jsxs)(`form`,{onSubmit:m,children:[(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Current password`}),(0,$.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`New password`}),(0,$.jsx)(`input`,{type:`password`,value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,$.jsxs)(`label`,{className:`field`,children:[(0,$.jsx)(`span`,{children:`Confirm new password`}),(0,$.jsx)(`input`,{name:`confirm`,type:`password`,required:!0})]}),(0,$.jsx)(`button`,{disabled:f,children:f?`Changing…`:`Change password`})]}),u&&(0,$.jsx)(`p`,{className:`status-line`,children:u})]})}var Tb={saved:`success`,attention:`danger`},Eb=`An administrator set this account's password. Choose your own before you continue.`;function Db({auth:e,onChanged:t,onLogout:n}){return(0,$.jsx)(Sb,{tagline:`Choose your own password.`,children:(0,$.jsxs)(`div`,{className:`ky-auth-card choose-password`,children:[(0,$.jsx)(`p`,{role:`status`,children:Eb}),(0,$.jsx)(wb,{username:e.username,userID:e.user.id,everyday:e.user.accountKind===`user`,onAuthSecret:()=>{},onIdentityCreated:()=>{},onChanged:t}),(0,$.jsx)(`button`,{type:`button`,className:`ky-auth-link`,onClick:n,children:`Sign out`})]})})}function Ob({tab:e,username:t,userID:n,onForgetDevice:r,onAuthSecret:i,colleagueNames:a,keysFor:o,identityState:s,sso:c,heldIdentity:l,identityStore:u,stepUp:d,onIdentityChanged:f,onReset:p,resetUnfinished:m,waitingHeld:h,live:g,recoveryPrompt:_,reminders:v,onReminders:y}){let[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``);async function w(){let e=(await el()).filter(e=>e.owner===n);if(!e.length)return 0;let t=await Vg(e,e=>cm(o(e),t=>Nt(t,e.containerID,e.id,e.payload,!0)));return wp(`kynotes-unsent-edits.json`,t.json,`application/json`),e.length-t.unreadable}return(0,X.useEffect)(()=>{_l(t,n).then(e=>e?hi(Qe(e.publicKey)):``).then(x,()=>x(``))},[t,n,s]),(0,$.jsxs)(`section`,{className:`page-view settings-view`,"aria-labelledby":`settings-heading`,children:[(0,$.jsx)(`header`,{className:`ky-page-head`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{id:`settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,$.jsx)(`p`,{className:`ky-page-lede`,children:`Your account, the browsers linked to it, how KyNotes looks, and your reminders and keys.`})]})}),(0,$.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:Ve.map(([t,n])=>(0,$.jsx)(`a`,{className:`ky-nav-item`,href:We(t),"aria-current":e===t?`page`:void 0,children:n},t))}),S&&(0,$.jsx)(`p`,{role:`status`,children:S===`restored`?`Restored. This browser now holds your encryption key.`:`Linked. This browser now holds your encryption key.`}),(0,$.jsxs)(`div`,{className:`settings-content`,hidden:e!==`account`,children:[(0,$.jsx)(`div`,{id:`password`,children:(0,$.jsx)(wb,{username:t,userID:n,everyday:!0,onAuthSecret:i,onIdentityCreated:f})}),(0,$.jsxs)(`section`,{id:`device`,className:`config-card`,children:[(0,$.jsx)(`h2`,{children:`Trusted Device & SSO`}),(0,$.jsx)(`p`,{className:`config-muted`,children:b?`This browser holds your encryption key, so your notes open here while you are signed in. It keeps nothing that can sign you in.`:`This browser keeps nothing that can sign you in.`}),(0,$.jsxs)(`p`,{className:`config-muted`,children:[`Your user ID: `,(0,$.jsx)(`code`,{children:n}),`. Team owners need it to invite you.`]}),(0,$.jsx)(`p`,{className:`config-muted`,children:b?(0,$.jsxs)($.Fragment,{children:[`Your encryption key fingerprint: `,(0,$.jsx)(`code`,{children:b}),`. Team owners see it when your key changes; compare it with them in person.`]}):`This browser holds no encryption key for team notebooks.${fb(s,c)}`}),b&&(0,$.jsx)(`p`,{className:`config-muted`,children:cl()===`wrapped`?`This browser keeps it wrapped under a browser key that pages cannot export. That is not protection at rest: anyone who can read this browser's profile on disk can still recover it. Use "Forget this device" on shared computers.`:`This site is not served over HTTPS, so this browser stores your key unwrapped in its site storage. Anyone who can read this browser's profile can copy it. Use "Forget this device" on shared computers.`}),r&&(0,$.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>{confirm(pb)&&r()},children:`Forget this device & sign out`})]}),s===`held`&&(0,$.jsx)(Ng,{userID:n,held:l,live:g,sso:c,stepUp:d,autoStart:_,onSaved:f}),m&&(0,$.jsx)(`p`,{role:`status`,children:`A reset of your encryption key from this browser finished on the server, but its answer never arrived here, so this browser still holds your previous key. Use Forget this device, sign in again, then restore with the new recovery code the reset showed you, or link this browser from one that holds the new key.`}),g&&(0,$.jsx)(Fg,{userID:n,store:u,live:g,held:s===`held`,stepUp:d,exportWaiting:w,onReset:p,password:c?void 0:mb(t)})]}),(0,$.jsxs)(`div`,{className:`settings-content`,hidden:e!==`devices`,children:[s===`link`&&(0,$.jsx)(a_,{userID:n,canKeep:()=>vl(t),store:u,onLinked:()=>{C(`linked`),f()}}),s===`link`&&(0,$.jsx)(Pg,{userID:n,sso:c,store:u,stepUp:d,onRestored:()=>{C(`restored`),f()}}),s===`held`&&(0,$.jsx)(o_,{userID:n,held:l,stepUp:d}),s!==`link`&&s!==`held`&&(0,$.jsx)(`p`,{className:`config-muted`,children:`This browser holds no encryption key to link another browser with.${fb(s,c)}`})]}),(0,$.jsx)(`div`,{hidden:e!==`appearance`,children:(0,$.jsx)(Yf,{})}),(0,$.jsx)(`div`,{className:`settings-content`,hidden:e!==`reminders`,children:(0,$.jsx)(Iy,{userID:n,prefs:v,onChange:y})}),(0,$.jsx)(`div`,{className:`settings-content`,hidden:e!==`colleague-keys`,children:(0,$.jsx)(D_,{username:t,userID:n,names:a})}),(0,$.jsx)(`div`,{className:`settings-content`,hidden:e!==`share-links`,children:e===`share-links`&&(0,$.jsx)(z_,{userID:n,keysFor:o})}),(0,$.jsx)(`div`,{className:`settings-content`,hidden:e!==`unsent`,children:(0,$.jsx)(P_,{username:t,userID:n,keysFor:o,waitingHeld:h})})]})}y_(location,history,v_()),lv({name:`KyNotes`}),(0,Xg.createRoot)(document.getElementById(`root`)).render(Ye()?(0,$.jsx)(X.StrictMode,{children:(0,$.jsx)(yb,{})}):(0,$.jsx)(`p`,{role:`alert`,children:Je}));export{V as C,fe as E,Me as S,pe as T,Fl as _,Cv as a,je as b,bv as c,Pv as d,Mv as f,rf as g,df as h,_v as i,xv as l,qg as m,iy as n,vv as o,Yg as p,Sv as r,yv as s,Jv as t,jv as u,uo as v,de as w,Ne as x,Ce as y}; \ No newline at end of file diff --git a/internal/web/dist/assets/index-DcxPhBy8.js b/internal/web/dist/assets/index-DcxPhBy8.js new file mode 100644 index 00000000..b7cb9044 --- /dev/null +++ b/internal/web/dist/assets/index-DcxPhBy8.js @@ -0,0 +1,38 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CanvasPage-CCePUo_W.js","assets/rolldown-runtime-COiEfhsA.js","assets/blocknote-BePxcw92.js","assets/CanvasPage-EZlfyAbl.css"])))=>i.map(i=>d[i]); +import{i as e,r as t,t as n}from"./rolldown-runtime-COiEfhsA.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var i=e=>e?`"${e}" `:``;function a(e,t=``){if(typeof e!=`number`)throw TypeError(i(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(i(t)+`expected integer >= 0, got `+e);return e}function o(e,t,n=``){if(r(e)&&(t===void 0||e.length===t))return e;t!==void 0&&a(t,`length`);let o=r(e),s=t===void 0?``:` of length ${t}`,c=o?`length=${e.length}`:`type=${typeof e}`,l=i(n)+`expected Uint8Array`+s+`, got `+c;throw o?RangeError(l):TypeError(l)}function s(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(a(e.outputLen),a(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var c=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},l=(e,t)=>{c(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 u(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function d(e,t){o(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function f(...e){for(let t=0;t>>t}var h=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,g=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function _(e){if(o(e),h)return e.toHex();let t=``;for(let n=0;n=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function y(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(h)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;te(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 S(e=32){a(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 C=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),w=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(s(e),o(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{let e=((e,t,n)=>new w(e,t).update(n).digest());return e.create=(e,t)=>new w(e,t),e})(),E=Uint8Array.of(0),D=Uint8Array.of();function O(e,t,n,r=32,i){s(e),a(r,`length`),o(t,void 0,`prk`);let c=e.outputLen;if(t.length255*c)throw Error(`Length must be <= 255*HashLen`);let l=Math.ceil(r/c);if(n===void 0?n=D:o(n,void 0,`info`),!l)return i&&f(t),new Uint8Array;let u=i&&l===1?t:new Uint8Array(l*c),{iHash:d,oHash:p}=T.create(e,t),m=i?t:new Uint8Array(c),h=l>1?i?.iHash||e.create():void 0;for(let e=0;e1&&d.update(m),d.update(n).update(E).digestInto(m),p.update(m).digestInto(m),u.set(m,c*(l-1)),d.destroy(),p.destroy(),h?.destroy(),m!==u&&f(m),f(E),r===u.length)return u;let g=u.slice(0,r);return f(u),g}var k=(e,t,n,r,i)=>{s(e),n===void 0&&(n=new Uint8Array(e.outputLen));let a=T.create(e,n).update(t);return O(e,a.digest(),r,i,a)},A=e=>e/2**32|0,j=e=>e>>>0;function M(e,t,n,r){let i=A(n),a=j(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function N(e,t,n){return e&t^~e&n}function P(e,t,n){return e&t^e&n^t&n}var F=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=p(this.buffer)}update(e){u(this),o(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;or-a&&(this.process(n,0),t.fill(0)),M(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:p(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>>3,i=m(n,17)^m(n,19)^n>>>10;R[e]=i+R[e-7]+r+R[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=m(o,6)^m(o,11)^m(o,25),u=l+t+N(o,s,c)+L[e]+R[e]|0,d=(m(n,2)^m(n,13)^m(n,22))+P(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(){f(R)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),f(this.buffer)}},te=class extends ee{constructor(){super(32,I)}},z=x(()=>new te,C(1)),ne=`0123456789abcdefghijklmnopqrstuvwxyz`,re=/^[0-9a-z]*[1-9a-z]$/,B=e=>typeof e==`string`&&e.length<=512&&re.test(e);function ie(e,t){let n=e??``,r=t;if(r!==null&&n>=r)throw Error(`order keys out of order`);let i=``;for(let a=0;;a+=1){let o=ao&&c512)throw Error(`order key limit reached`);return e}i+=ne[o],r=null}}var ae=e=>Math.min(2,Math.max(0,e??0)),oe=(e,t)=>t>0&&e[t].section===e[t-1].section;function V(e){let t=[];return e.forEach((n,r)=>t.push(oe(e,r)?Math.min(ae(n.level),t[r-1]+1):0)),t}function H(e,t){let n=t+1;for(;ne[t];)n+=1;return[t,n]}function se(e,t){let n=V(e),r=[],i=1/0;return e.forEach((a,o)=>{let s=n[o];if(s>i)return;i=1/0;let c=o+1s,l=c&&t.has(a.id);r.push({item:a,level:s,hasChildren:c,collapsed:l}),l&&(i=s)}),r}function ce(e,t){let n=V(e),r=e.findIndex(e=>e.id===t),i=[],a=n[r];for(let t=r-1;t>=0&&a>0;--t)n[t]2)&&!(n===1&&(!oe(e,t)||i>r[t-1]+1)))return i}function ue(e,t,n,r){let i=Math.max(0,Math.min(r,e.length)),a=V(e),o=Math.min(n[0],i===0?0:a[i-1]+1),s=n.map(e=>ae(e-n[0]+o)),c=e[i-1]?.order??null,l=e[i]?.order??null;if(e.every(e=>e.order)&&(c===null||l===null||c(e=ie(e,l),{id:t.id,order:e,level:s[n]}))}catch{}let u=null;return[...e.slice(0,i).map(e=>({id:e.id})),...t.map((e,t)=>({id:e.id,level:s[t]})),...e.slice(i).map(e=>({id:e.id}))].map(e=>(u=ie(u,null),e.level===void 0?{id:e.id,order:u}:{id:e.id,order:u,level:e.level}))}function de(e){let t=new Map(e.map(e=>[e.id,e.group])),n=new Map;for(let{id:r,group:i}of e){let e=new Set([r]),a=1,o=i;for(;o!==void 0&&t.has(o)&&!e.has(o)&&a<=4;)e.add(o),a+=1,o=t.get(o);let s=o!==void 0&&e.has(o);n.set(r,i!==void 0&&t.has(i)&&!s&&a<=4?i:void 0)}return n}var fe=(e,t)=>e.group!==void 0&&t.has(e.group)?e.group:void 0;function pe(e,t){let n=[],r=e;for(;r!==void 0&&t.has(r)&&n.length<=4;)n.unshift(r),r=t.get(r);return n}function me(e,t){let n=0;for(let[r,i]of t)i===e&&(n=Math.max(n,me(r,t)));return n+1}function he(e,t,n){let r=pe(t,n);return!r.includes(e)&&r.length+me(e,n)<=4}function ge(e,t,n){let r=ve(e);return e.filter(e=>n===void 0||he(n,e.id,t)).map(e=>({id:e.id,label:pe(e.id,t).map(e=>r.get(e)).join(` › `)})).sort((e,t)=>e.label.localeCompare(t.label))}function _e(e,t,n){let r=ve(t);return e.map(e=>({id:e.id,label:[...pe(fe(e,n),n).map(e=>r.get(e)),e.title||`Untitled section`].join(` › `)})).sort((e,t)=>e.label.localeCompare(t.label))}var ve=e=>new Map(e.map(e=>[e.id,e.title||`Untitled group`]));function ye(e,t,n){let r=t.find(t=>t.id===e);return r?fe(r,n):void 0}function be(e,t,n){let r=e[t];if(n===-1){let n=t-1;for(;n>=0&&e[n]>r;)--n;return n>=0&&e[n]===r?n:void 0}let i=H(e,t)[1];return e[i]===r?H(e,i)[1]:void 0}function xe(e,t,n){let[r,i]=H(e,t);if(!(n>=r&&ntypeof e==`string`):[])}catch{return new Set}}var Ce=`quick`,we=[`orange`,`blue`,`green`,`purple`,`red`,`teal`,`yellow`,`gray`],Te=/^obj_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,Ee=/^cnt_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,De=/^(cmt_[0-9abcdefghjkmnpqrstvwxyz]{26}|att_[0-9abcdefghjkmnpqrstvwxyz]{26}(\/meta)?)$/,Oe=/^[0-9a-f]{64}$/;function ke(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e):[];return Object.fromEntries(t.filter(([e,t])=>De.test(e)&&typeof t==`string`&&Oe.test(t)))}function Ae(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=B(t.order)?t.order:void 0,r=typeof t.group==`string`&&Te.test(t.group)?t.group:void 0;if(t.type===`section`||t.type===`group`)return{type:t.type,title:typeof t.title==`string`?t.title:t.type===`group`?`Untitled group`:`Untitled section`,color:we.includes(t.color)?t.color:`gray`,order:n,group:r};if(typeof t.body!=`string`)return;let i={type:`page`,title:typeof t.title==`string`?t.title:``,body:t.body};return`section`in t&&(i.section=typeof t.section==`string`&&Te.test(t.section)?t.section:void 0),`order`in t&&(i.order=n),`level`in t&&(i.level=t.level===0||t.level===1||t.level===2?t.level:void 0),`legacy`in t&&(i.legacy=ke(t.legacy)),i}function je(e,t){return e.order&&t.order&&e.order!==t.order?e.ordert.id):e.order?-1:1}var Me=e=>[...e].sort(je);function Ne(e,t,n){let r=new Set(t.map(e=>e.id));return e.filter(e=>n===`quick`?!e.section||!r.has(e.section):e.section===n).sort(je)}function Pe(e){return ie(e.reduce((e,t)=>t.order&&(e===null||t.order>e)?t.order:e,null),null)}function Fe(e,t,n){let r=e.filter(e=>e.id!==t),i=Math.max(0,Math.min(n,r.length));if(r.every(e=>e.order))try{return[{id:t,order:ie(r[i-1]?.order??null,r[i]?.order??null)}]}catch{}let a=null;return[...r.slice(0,i),{id:t},...r.slice(i)].map(e=>(a=ie(a,null),{id:e.id,order:a}))}function Ie(e,t,n){let r=V(e),i=e.findIndex(e=>e.id===t.id),a=Fe(e,``,i<0?e.length:H(r,i)[1]);return{page:{type:`page`,title:`${n.title||`Untitled page`} (conflicting copy)`,body:n.body,section:t.section,order:a.find(e=>e.id===``)?.order,level:i<0?void 0:r[i],legacy:{}},moves:a.filter(e=>e.id!==``)}}function Le(e,t){let n=e=>JSON.stringify([e.title,e.body]),r=[],i=new Map;for(let a of[...t].sort((e,t)=>e.createdAtt.createdAt))){let t=n(a.payload),o=i.get(t);t===n(e)?r.push(a.id):o?o.ids.push(a.id):i.set(t,{payload:a.payload,ids:[a.id]})}return{resolveOnly:r,groups:[...i.values()]}}function Re(e,t){return e===`quick`||e&&t.some(t=>t.id===e)?e:Me(t)[0]?.id??`quick`}function ze(e){let[t=``,n=``,r=``]=e.replace(/^#\/?/,``).split(`/`);return{container:Ee.test(t)?t:void 0,section:n===`quick`||Te.test(n)?n:void 0,page:Te.test(r)?r:void 0}}function Be({container:e,section:t,page:n}){return e?`#/${[e,t,t?n:void 0].filter(Boolean).join(`/`)}`:``}var Ve=[[`account`,`Account`],[`devices`,`Phones & apps`],[`appearance`,`Appearance`],[`reminders`,`Reminders`],[`colleague-keys`,`Colleague keys`],[`share-links`,`Share links`],[`unsent`,`Unsent edits`]],He={"#password":`account`,"#device":`account`,"#link-this-browser":`devices`,"#link-devices":`devices`,"#reminders":`reminders`,"#colleague-keys":`colleague-keys`};function Ue(e){let t=/^#\/settings(?:\/([a-z-]+))?$/.exec(e);return t?Ve.find(([e])=>e===(t[1]??`account`))?.[0]:He[e]}var We=e=>`#/settings/${e}`,Ge=new TextEncoder,Ke=new TextDecoder,qe=(e,t,n,r)=>k(z,e,n,r,t),Je=`KyNotes needs a secure connection. Open it over HTTPS, or on localhost.`,Ye=()=>typeof crypto<`u`&&typeof crypto.getRandomValues==`function`&&typeof crypto.subtle?.importKey==`function`;function Xe(){if(!Ye())throw Error(Je);return crypto.subtle}function Ze(e){if(!Ye())throw Error(Je);return crypto.getRandomValues(e)}function Qe(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function $e(e){let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))}function et(e){return e.slice().buffer}async function tt(e){return new Uint8Array(await Xe().digest(`SHA-256`,et(e)))}async function nt(e){return[...await tt(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function rt(e,t,n){let r=await Xe().importKey(`raw`,et(e),`PBKDF2`,!1,[`deriveBits`]);return new Uint8Array(await Xe().deriveBits({name:`PBKDF2`,salt:et(t),iterations:n,hash:`SHA-256`},r,256))}var it=(e,t,n)=>rt(Ge.encode(e),$e(t),n),at=6e5,ot=Ge.encode(`kynotes/recovery-kek/v1`);function st(e,t){let n=new Uint8Array(ot.length+t.length);return n.set(ot),n.set(t,ot.length),rt(e,n,at)}var ct=6e5,lt=1e5;async function ut(e,t,n,r=ct){if(!Number.isSafeInteger(n)||nqe(i,32,new Uint8Array,Ge.encode(e));return{authSecret:[...a(`kynotes/auth/v1`)].map(e=>e.toString(16).padStart(2,`0`)).join(``),userKEK:a(`kynotes/user-kek/v1`)}}async function dt(e,t,n,r=ct){return(await ut(e,t,n,r)).authSecret}function ft(){return Qe(Ze(new Uint8Array(16)))}var U=2,pt=`kynotes/content/v2`;function mt(e,t){if(e.byteLength!==32)throw Error(`Refusing a content key that is not 256 bits`);return Xe().importKey(`raw`,et(e),`AES-GCM`,!1,[t])}async function ht(e,t,n){let r=Ze(new Uint8Array(12)),i=await mt(e,`encrypt`),a=await Xe().encrypt({name:`AES-GCM`,iv:et(r),...n&&{additionalData:et(n)}},i,et(t)),o=+!!n,s=new Uint8Array(o+r.byteLength+a.byteLength);return n&&(s[0]=U),s.set(r,o),s.set(new Uint8Array(a),o+r.byteLength),s}async function gt(e,t,n){let r=+!!n;if(t.byteLengthGe.encode(e)),i=new Uint8Array(r.reduce((e,t)=>e+2+t.length,0)),a=0;for(let e of r){if(e.length>65535)throw Error(`content ID too long`);new DataView(i.buffer).setUint16(a,e.length),i.set(e,a+2),a+=2+e.length}return i}var bt=(e,t,n,r,i)=>ht(vt(e,t,pt),i,yt(t,n,r));async function xt(e,t,n,r,i,a,o){if(a[0]===U)try{return{plaintext:await gt(vt(e,t,pt),a,yt(t,n,r)),v1:!1}}catch(e){if(!o)throw e}if(!o)throw Error(`Unable to decrypt: an older format this notebook no longer accepts, or tampered ciphertext`);return{plaintext:await gt(vt(e,t,i),a),v1:!0}}var W=async(...e)=>JSON.parse(Ke.decode((await xt(...e)).plaintext));async function St(e,t,n,r=!1){return bt(e,t,t,`container-meta`,Ge.encode(JSON.stringify(r?{name:n,objects:2}:{name:n})))}async function Ct(e,t,n,r){if(n.byteLength<13)throw Error(`Encrypted workspace metadata is too short`);let i=await xt(e,t,t,`container-meta`,`kynotes/container-meta/v1`,n,r),a=JSON.parse(Ke.decode(i.plaintext));if(typeof a.name!=`string`)throw Error(`Invalid workspace metadata`);return!i.v1&&a.objects===2?{name:a.name,objects:2}:{name:a.name}}var wt=(e,t,n,r,i=``)=>bt(e,t,n,`comment`,Ge.encode(JSON.stringify({body:r,section:i})));async function Tt(e,t,n,r,i){return W(e,t,n,`comment`,`kynotes/comment/v1`,r,i)}var Et=(e,t,n,r)=>bt(e,t,n,`share-label`,Ge.encode(JSON.stringify(r))),G=(e,t,n,r)=>W(e,t,n,`share-label`,`kynotes/share-label/v1`,r,!1),Dt=(e,t,n,r)=>bt(e,t,n,`attachment-meta`,Ge.encode(JSON.stringify(r)));async function Ot(e,t,n,r,i){return W(e,t,n,`attachment-meta`,`kynotes/attachment-meta/v1`,r,i)}var kt=(e,t,n,r)=>bt(e,t,n,`attachment`,r);async function At(e,t,n,r,i){return(await xt(e,t,n,`attachment`,`kynotes/object/v1`,r,i)).plaintext}async function jt(e,t,n,r){return bt(e,t,n,`object`,Ge.encode(JSON.stringify(r)))}async function Mt(e,t,n,r,i){if(r.byteLength<13)throw Error(`Encrypted data is too short`);let a=await xt(e,t,n,`object`,`kynotes/object/v1`,r,i);return{payload:Ae(JSON.parse(Ke.decode(a.plaintext))),v1:a.v1}}var Nt=async(...e)=>(await Mt(...e)).payload,Pt=e=>`${e}/meta`;async function Ft(e,t,n,r){return e?e.legacy?Object.hasOwn(e.legacy,n)&&e.legacy[n]===await nt(r):!t:!1}async function It(e){let t=Ze(new Uint8Array(32));return{ciphertext:await ht(t,Ge.encode(JSON.stringify(e))),key:Rt(t)}}async function Lt(e,t){let n=await gt(zt(t),e);return JSON.parse(Ke.decode(n))}function Rt(e){return Qe(e).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}function zt(e){return $e(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`)+`=`.repeat((4-e.length%4)%4))}var Bt=e=>({type:`page`,title:e.title,body:e.body,section:e.section,order:e.order,level:e.level,legacy:e.legacy});function Vt(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}var Ht=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])};function Ut(e,t,n,r){return e.map(e=>e.id===t.id?Ht(e,t)?n:{...e,...r}:e)}function Wt(e,t,n){return e.map(e=>e.id===t&&n.version>e.version?{...e,version:n.version,updatedAt:n.updatedAt??e.updatedAt}:e)}var Gt=(e,t)=>e.title===t.title&&e.body===t.body&&e.section===t.section&&e.order===t.order&&e.level===t.level&&e.legacy===t.legacy;function Kt(e,t){return t&&t.version>=e.version?{...e,title:t.title,body:t.body}:e}function qt(e,t){return e.map(e=>{let n=t.get(e.id);return n&&n.version>e.version?{...e,version:n.version}:e})}function Jt(e,t){return[...t].reduce((e,[t,n])=>Wt(e,t,n),e)}function Yt(e,t,n){return e?.id===t?n?Gt(e,n)?`done`:`again`:`failed`:`done`}async function Xt(e,t,n){let r=e()?.id;if(!r)return`done`;for(let i=0;i`${e} item(s) in this notebook could not be read or decrypted and are not shown. They remain on the server; reload to try again.`;function Qt(e){switch(e){case`unauthenticated`:case`password_change_required`:return`You were signed out, so your edits are kept only in this browser. Sign out, then sign in again to send them.`;case`quota_exceeded`:return`Your storage is full, so this edit is kept only in this browser. Delete pages or notebooks, or ask your administrator to raise your quota; it is sent once there is room.`;case`payload_too_large`:return`This page is too large to save, so the edit is kept only in this browser. Split it into smaller pages.`}}function $t(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;ro(e,t,n),tn=a;function nn(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 rn(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var an=_,on=e=>y(e),sn=r,cn=e=>S(e),ln=BigInt(0),un=BigInt(1),dn=e=>e?`"${e}" `:``;function fn(e,t=``){if(typeof e!=`boolean`)throw TypeError(dn(t)+`expected boolean, got type=`+typeof e);return e}function pn(e){if(typeof e==`bigint`){if(!xn(e))throw RangeError(`positive bigint expected, got `+e)}else tn(e);return e}function mn(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 hn(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?ln:BigInt(`0x`+e)}function gn(e){return hn(_(e))}function _n(e){return hn(_(bn(o(e)).reverse()))}function vn(e,t){if(a(t),t===0)throw Error(`zero output length is invalid`);e=pn(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return y(r.padStart(n,`0`))}function yn(e,t){return vn(e,t).reverse()}function bn(e){return Uint8Array.from(en(e))}function xn(e){return typeof e==`bigint`&&ln<=e}function Sn(e,t,n){return xn(e)&&xn(t)&&xn(n)&&t<=e&&e(mn(e,`n`),(un<Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var Dn=BigInt(0),On=BigInt(1),kn=BigInt(2),An=BigInt(3),jn=BigInt(4),Mn=BigInt(5),Nn=BigInt(7),Pn=BigInt(8),Fn=BigInt(9),In=BigInt(15),Ln=BigInt(16),Rn=BigInt(`0x10000000000000000`);function zn(e,t){if(t<=Dn)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=Dn?n:t+n}function Bn(e,t,n){if(n<=On)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(tDn;)t&On&&(e=e*r%n),r=r*r%n,t>>=On;return e}let i=[];for(;t>Dn;)i.push(Number(t&In)),t>>=jn;let a=Array(16);a[0]=On,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 Vn(e,t,n){if(n<=On)throw Error(`pow2: expected modulus > 1, got `+n);if(tDn;)r*=r,r%=n;return r}function Hn(e,t){if(e===Dn)throw Error(`invert: expected non-zero number`);if(t<=On)throw Error(`invert: expected modulus > 1, got `+t);let n=zn(e,t),r=t,i=Dn,a=On;for(;n!==Dn;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==On)throw Error(`invert: does not exist`);return zn(i,t)}function Un(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Wn(e,t){if((e&On)===Dn)throw Error(t+`: expected odd modulus, got `+e)}function Gn(e,t){let n=e,r=(n.ORDER+On)/jn,i=n.pow(t,r);return Un(n,i,t),i}function Kn(e,t){let n=e,r=(n.ORDER-Mn)/Pn,i=n.mul(t,kn),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,kn),a),c=n.mul(o,n.sub(s,n.ONE));return Un(n,c,t),c}function qn(e){let t=ir(e),n=Jn(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Nn)/Ln;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 Un(n,m,t),m})}function Jn(e){if(e1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Gn;let a=i.pow(r,t),o=(t+On)/kn;return function(e,r){let i=e;if(i.is0(r))return r;if(er(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=On<(zn(e,t)&On)===On,Zn=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Qn(e){if(nn(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);mn(e.BYTES,`BYTES`),mn(e.BITS,`BITS`);for(let t of Zn)rn(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=On)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function $n(e,t,n=!1){Qn(e),$t(t,`nums`),fn(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 er(e,t){Qn(e);let n=e;Wn(n.ORDER,`FpLegendre`);let r=(n.ORDER-On)/kn,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 tr(e,t){if(t!==void 0&&tn(t),e<=Dn)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=wn(e);if(t!==void 0&&t= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var nr=new WeakMap,rr=class{ORDER;BITS;BYTES;isLE;ZERO=Dn;ONE=On;_lengths;_mod;constructor(e,t={}){if(e<=On)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}=tr(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 zn(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return Dn<=e&&er)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?_n(e):gn(e);if(o&&(s=zn(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return $n(this,e,!0)}cmov(e,t,n){return fn(n,`condition`),n?t:e}};function ir(e,t={}){return Object.freeze(rr.prototype),new rr(e,t)}var ar=BigInt(0),or=BigInt(1),sr=BigInt(4),cr=16,lr=128,ur=5,dr=2**31;function fr(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);rn(t.fromAffine,`Point.fromAffine`),rn(t.fromBytes,`Point.fromBytes`),rn(t.fromHex,`Point.fromHex`),nn(t.BASE,`Point.BASE`),nn(t.ZERO,`Point.ZERO`),Qn(t.Fp),Qn(t.Fn)}function pr(e,t){fr(e),_r(t,e);let n=$n(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function mr(e,t,n=1){if(!Number.isSafeInteger(e)||et)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function hr(e,t){let n=e*(4*t+128);if(n>dr)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+dr/2**20+` MiB`)}function gr(e,t){if(e!==void 0){rn(e,`randomBytes`);try{let n=e(t);if(!sn(n)||n.length!==t)return}catch{return}return e}}function _r(e,t){$t(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function vr(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):xn(e)&&ear;){let t=0;e&or&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=or}return a}function Cr(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t>=o,t>i&&(t-=r,e+=or),s.push(t)}if(e!==ar)throw Error(`invalid wnaf`);return s}function wr(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>1];i=i.add(a<0?e.negate():e)}}}return i}var Tr=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){fr(e),this.randomBytes=gr(t,cr),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;et.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),!Sn(t,or,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=br(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+lr,i=this.randomBytes(cr);if(!sn(i)||i.length!==cr)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+gn(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=ur,i=Tn(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>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===or||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),!xn(t))throw Error(`invalid scalar`);let r=br(e);if(r===1||t>=this.Point.Fn.ORDER)return Er(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),mr(t,this.bits),hr((Math.ceil((this.bits+lr)/t)+1)*2**(t-1),this.Point.Fp.BYTES),yr.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return br(e)!==1}};function Er(e,t,n,r=!1){if(fr(e),_r(t,e),fn(r,`allowOversized`),vr(n,e.Fn,r?e.Fn.ORDER**sr:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>xr(e,4)),a=n.map(e=>Sr(e,4));return wr(e.ZERO,i,a)}function Dr(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Qn(t),t}return ir(e,{isLE:n})}function Or(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`);En(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(xn(n)&&n!==ar))throw Error(`CURVE.${e} must be positive bigint`)}let i=Dr(t.p,n.Fp,r),a=Dr(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 kr(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Ar=BigInt(0),jr=BigInt(1),Mr=BigInt(2),Nr=BigInt(4),Pr=BigInt(8);function Fr(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 Ir(e,t={}){En(t,{},{},`extraOpts`);let n=t,r=Or(`edwards`,e,n,n.FpFnLE),{Fp:i,Fn:a}=r,o=r.CURVE,{h:s}=o;if(er(i,o.a)!==1)throw Error(`edwards: CURVE.a must be a square in Fp for complete addition formulas`);if(er(i,o.d)!==-1)throw Error(`edwards: CURVE.d must be a non-square in Fp for complete addition formulas`);En(n,{},{uvRatio:`function`,randomBytes:`function`});let c=n.randomBytes===void 0?cn:n.randomBytes,l=Mr<{try{return{isValid:!0,value:i.sqrt(i.div(e,t))}}catch{return{isValid:!1,value:Ar}}}:n.uvRatio;if(!Fr(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?jr:Ar;return Cn(`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=bn(en(e,n,`point`)),fn(t,`zip215`);let s=bn(e),c=e[n-1];s[n-1]=c&-129;let f=_n(s);Cn(`point.y`,f,Ar,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(on(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(Mr),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),Mr),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===Ar?h.ZERO:this.is0()||e===jr?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(Pr):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===jr?this:s===Mr?this.double():s===Nr?this.double().double():s===Pr?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 an(this.toBytes())}toString(){return``}}let g=e=>pr(h,e),_=new Tr(h,c);return _.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}var Lr=BigInt(0),Rr=BigInt(1),zr=BigInt(2);function Br(e,t){return e+t-(t>>Rr<{let a=r+i,o=((t+i-r)*n+r)%e;return{x_2:o,x_3:a-o}}}function Hr(e){return En(e,{P:`bigint`,type:`string`,adjustScalarBytes:`function`,powPminus2:`function`},{randomBytes:`function`,scalarMultBase:`function`}),Object.freeze({...e})}function Ur(e){let t=Hr(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?cn:o,u=c?255:448,d=Vr(n),f=c?32:56,p=BigInt(c?9:5),m=BigInt(c?121665:39081),h=c?zr**BigInt(254):zr**BigInt(447),g=h+(c?BigInt(8)*(zr**BigInt(251)-Rr):BigInt(4)*(zr**BigInt(445)-Rr))+Rr,_=e=>zn(e,n),v=y(p);function y(e){return yn(_(e),f)}function b(e){let t=bn(en(e,f,`uCoordinate`));return c&&(t[31]&=127),_(_n(t))}function x(e){return _n(i(bn(en(e,f,`scalar`))))}let S=new Set(c?[Lr,Rr,n-Rr,BigInt(`325606250916557431795983626356110631294008115727848805560023387167927233504`),BigInt(`39382357235489614581723060781553021112529911719440698176882885853963445705823`)]:[Lr,Rr,n-Rr]);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===Lr)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);Cn(`scalar`,t,h,g);let n=_(s(t));if(n===Lr)throw Error(`invalid private or public key received`);return y(n)}let T=w,E=C;function D(e,t){Cn(`u`,e,Lr,n),Cn(`scalar`,t,h,g);let r=t,i=e,o=Rr,s=Lr,c=e,l=Rr,f=r^r>>Rr;for(let e=BigInt(u-1);e>=Lr;e--){let t=Br(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=Br(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,en(e,O.seed,`seed`),e),A={randomSecretKey:k};return Object.freeze(O),Object.freeze(A),Object.freeze({keygen:kr(k,T),getSharedSecret:E,getPublicKey:T,scalarMult:C,scalarMultBase:w,utils:A,GuBytes:v.slice(),lengths:O})}var Wr=BigInt(0),Gr=BigInt(1),Kr=BigInt(2),qr=BigInt(3),Jr=BigInt(5),Yr=BigInt(8),Xr=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),Zr={p:Xr,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:Yr,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function Qr(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Xr,o=e*e%a*e%a,s=Vn(Vn(o,Kr,a)*o%a,Gr,a)*e%a,c=Vn(s,Jr,a)*s%a,l=Vn(c,t,a)*c%a,u=Vn(l,n,a)*l%a,d=Vn(u,r,a)*u%a;return{pow_p_5_8:Vn(Vn(Vn(Vn(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Kr,a)*e%a,b2:o}}function $r(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ei=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function ti(e,t){let n=Xr,r=zn(t*t*t,n),i=Qr(e*zn(r*r*t,n)).pow_p_5_8,a=zn(e*r*i,n),o=zn(t*a*a,n),s=a,c=zn(a*ei,n),l=o===e,u=o===zn(-e,n),d=o===zn(-e*ei,n);return l&&(a=s),(u||d)&&(a=c),Xn(a,n)&&(a=zn(-a,n)),{isValid:l||u,value:a}}var ni=Ir(Zr,{uvRatio:ti}),ri=(()=>{let e=Xr,t=t=>{let{pow_p_5_8:n,b2:r}=Qr(t);return zn(Vn(n,qr,e)*r,e)};return Ur({P:e,type:`x25519`,powPminus2:t,adjustScalarBytes:$r,scalarMultBase:n=>{let r=zn(n,ni.Fn.ORDER);if(r===Wr)return Wr;let i=ni.BASE.multiply(r);return zn((i.Z+i.Y)*t(zn(i.Z-i.Y,e)),e)}})})();async function ii(e=globalThis.navigator?.storage){if(!e?.persisted||!e.persist)return!1;try{return await e.persisted()||await e.persist()}catch{return!1}}function ai(e){let t=$e(e);if(t.length!==32)throw Error(`invalid identity public key`);return t}var oi=e=>{try{return ai(e).length===32}catch{return!1}};function si(e,t){try{let[n,r]=[ai(e),ai(t)];return n.every((e,t)=>e===r[t])}catch{return!1}}var ci=class extends Error{member;pinned;constructor(e,t){super(`${e.username}'s identity key changed`),this.member=e,this.pinned=t,this.name=`FingerprintChangedError`}},li=new WeakSet,ui;(class e{userId;key;pins;static{ui=(t,n,r)=>{let i=new e(t,n,r);return li.add(i),i}}constructor(e,t,n){this.userId=e,this.key=t,this.pins=n}});var di=e=>typeof e==`object`&&!!e&&li.has(e);function fi(e,t){let n=t.identity?.publicKey;if(!n||!oi(n))throw Error(`invalid identity public key`);return ui(t.userId,n,{...e,[t.userId]:n})}function pi(e,t){let n=[],r=[];for(let i of t){let t=i.identity?.publicKey;if(!t)continue;let a=e[i.userId];a===void 0?oi(t)&&n.push(i):si(a,t)||r.push({member:i,pinned:a})}return{fresh:n,changed:r}}var mi=/[\u0000-\u001f\u007f-\u009f\u061c\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/g,hi=e=>{let t=[...e.replace(mi,` `).replace(/\s+/g,` `).trim()];return t.length>64?`${t.slice(0,63).join(``)}…`:t.join(``)};function gi(e,t){return`${hi(t)} · ${hi(e)||`(no name)`}`}async function _i(e){return(await nt(ai(e))).match(/.{4}/g).join(` `)}function vi(e,t){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{let r=t[e];return{userId:e,pinned:n,current:r,state:r===void 0?`unseen`:si(n,r)?`same`:`changed`}})}function yi(e,t,n){if(n&&oi(n.publicKey)&&si(t,n.publicKey))return{userId:e,username:e,role:``,identity:{deviceId:n.deviceId,publicKey:n.publicKey}}}function bi({userId:e,name:t,newPrint:n,oldPrint:r}){let i=gi(t,e);return`Trust the new encryption key of ${i}?\n\nNew: ${n}\nWas: ${r}\n\nA password reset or account recovery changes it; so would a server substituting its own key. The name comes from the server; the user ID and fingerprints are what you are trusting. Compare the new fingerprint with ${i} in person (their Settings shows it) before trusting it.`}function xi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var Si=e=>e?`"${e}" `:``;function Ci(e,t=``){if(typeof e!=`boolean`)throw TypeError(Si(t)+`expected boolean, got type=`+typeof e);return e}function wi(e,t=``){if(typeof e!=`number`)throw TypeError(Si(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(Si(t)+`expected integer >= 0, got `+e);return e}function Ti(e,t,n=``){if(xi(e)&&(t===void 0||e.length===t))return e;t!==void 0&&wi(t,`length`);let r=xi(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=Si(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var Ei=(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 Di(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Oi(e,t){Ti(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function ki(e,t){if(Oi(e,t),!K(e))throw Error(`invalid output, must be aligned`)}function Ai(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ji(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mi(...e){for(let t=0;t>>8&65280|e>>>24&255}var Ii=Pi?e=>e:e=>Fi(e)>>>0;function Li(e){for(let t=0;te:Li,zi=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Bi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Vi(e){if(Ti(e),zi)return e.toHex();let t=``;for(let n=0;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 qi=(e,t)=>{function n(n,...r){if(Ti(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];Ti(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{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);Ti(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,Ti(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(Ti(e,void 0,`data`),i&&e.length= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function Ji(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(Ti(t,e,`output`),n&&!K(t))throw Error(`invalid output, must be aligned`);return t}function Yi(e,t,n){wi(e),wi(t),Ci(n);let r=new Uint8Array(16),i=Ni(r);return i.setBigUint64(0,BigInt(t),n),i.setBigUint64(8,BigInt(e),n),r}function K(e){return e.byteOffset%4==0}function Xi(e){return Uint8Array.from(Ti(e))}function Zi(e=32){wi(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 Qi=16,$i=new Uint8Array(16),ea=ji($i),ta=225,na=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^ta<<24&-(i&1)}},ra=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255,ia=e=>e>65536?8:e>1024?4:2,aa=class{blockLen=Qi;outputLen=Qi;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(e,t){Ti(e,16,`key`),e=Xi(e);let n=Ni(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:ra(r),s1:ra(i),s2:ra(a),s3:ra(o)}),{s0:r,s1:i,s2:a,s3:o}=na(r,i,a,o);let c=ia(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){Di(this),Ti(e),e=Xi(e);let t=ji(e),n=Math.floor(e.length/Qi),r=e.length%Qi;for(let e=0;enew aa(e,t),e=>[e.length]),sa=16,ca=4,la=new Uint8Array(sa),ua=283;function da(e){if(![16,24,32].includes(e.length))throw Error(`"aes key" expected Uint8Array of length 16/24/32, got length=`+e.length)}function fa(e){return e<<1^ua&-(e>>7)}function pa(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=fa(e);return n}var ma=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=fa(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return Mi(e),t})(),ha=e=>e<<24|e>>>8,ga=e=>e<<8|e>>>24;function _a(e,t){if(e.length!==256)throw Error(`wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(ga),i=r.map(ga),a=i.map(ga),o=new Uint32Array(65536),s=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var va=_a(ma,e=>pa(e,3)<<24|e<<16|e<<8|pa(e,2)),ya=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=fa(n))e[t]=n;return e})();function ba(e){Ti(e);let t=e.length;da(e);let{sbox2:n}=va,r=[];Pi&&K(e)||r.push(e=Xi(e));let i=Ri(ji(e)),a=i.length,o=e=>Sa(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return Mi(...r),s}function xa(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function Sa(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function Ca(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=va,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a>>0,s.setUint32(u,f,t)}let p=sa*Math.floor(c.length/ca);if(pUint8Array.from(e.split(``),e=>e.charCodeAt(0)),Oa=Ri(ji(Da(`expand 16-byte k`))),ka=Ri(ji(Da(`expand 32-byte k`)));function q(e,t){return e<>>32-t}var Aa=64,ja=16,Ma=2**32-1,Na=Uint32Array.of();function Pa(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Aa),u=ji(l),d=Pi&&K(i)&&K(a),f=d?ji(i):Na,p=d?ji(a):Na;if(Pi)for(let m=0;m=Ma)throw Error(`arx: counter overflow`);let h=Math.min(Aa,c-m);if(d&&h===Aa){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t=Ma)throw Error(`arx: counter overflow`);let f=Math.min(Aa,c-d);for(let e=0,t;e{Ti(t,void 0,`key`),Ti(s,void 0,`nonce`),Ti(c,void 0,`data`);let d=c.length,f=l!==void 0;if(l=Ji(d,l,!1),f&&Ui(c,l),wi(u),u<0||u>=Ma)throw Error(`arx: counter overflow`);let p=[],m=t.length,h,g;if(m===32)p.push(h=Xi(t)),g=ka;else if(m===16&&n)h=new Uint8Array(32),h.set(t),h.set(t,16),g=Oa,p.push(h);else throw Ti(t,32,`arx key`),Error(`invalid key size`);Pi&&K(s)||p.push(s=Xi(s));let _=ji(h);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);let e=s.subarray(0,16);if(Pi)r(g,_,ji(e),_);else{let t=Ri(Uint32Array.from(g));r(t,_,ji(e),_),Mi(t),Ri(_)}s=s.subarray(16)}else Pi||Ri(_);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=Ri(ji(s));try{return Pa(e,g,_,y,c,l,u,o),l}finally{Mi(...p)}}}function Ia(e,t){return e[t++]&255|(e[t++]&255)<<8}var La=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=Xi(Ti(e,32,`key`));let t=Ia(e,0),n=Ia(e,2),r=Ia(e,4),i=Ia(e,6),a=Ia(e,8),o=Ia(e,10),s=Ia(e,12),c=Ia(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]=Ia(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=Ia(e,t+0),_=Ia(e,t+2),v=Ia(e,t+4),y=Ia(e,t+6),b=Ia(e,t+8),x=Ia(e,t+10),S=Ia(e,t+12),C=Ia(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 ee=P+w*u+T*l+E*c+D*s+O*o;P=ee>>>13,ee&=8191,ee+=5*h*k+5*m*A+5*p*j+5*f*M+5*d*N,P+=ee>>>13,ee&=8191;let te=P+w*d+T*u+E*l+D*c+O*s;P=te>>>13,te&=8191,te+=k*o+5*h*A+5*m*j+5*p*M+5*f*N,P+=te>>>13,te&=8191;let z=P+w*f+T*d+E*u+D*l+O*c;P=z>>>13,z&=8191,z+=k*s+A*o+5*h*j+5*m*M+5*p*N,P+=z>>>13,z&=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 B=P+w*h+T*m+E*p+D*f+O*d;P=B>>>13,B&=8191,B+=k*u+A*l+j*c+M*s+N*o,P+=B>>>13,B&=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]=ee,i[5]=te,i[6]=z,i[7]=ne,i[8]=re,i[9]=B}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;Mi(n)}update(e){Di(this),Ti(e),e=Xi(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i>>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}},Ra=Ki(32,e=>new La(e));function za(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{e.update(t);let n=t.length%16;n&&e.update(Va.subarray(n))},Ua=new Uint8Array(32);function Wa(e,t,n,r,i){i!==void 0&&Ti(i,void 0,`AAD`);let a=e(t,n,Ua),o=Yi(r.length,i?i.length:0,!0),s=Ra.create(a);i&&Ha(s,i),Ha(s,r),s.update(o);let c=s.digest();return Mi(a,o),c}var Ga=qi({blockSize:64,nonceLength:12,tagLength:16,withAAD:!0},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Ji(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Wa(e,t,n,s,r);return a.set(c,o),Mi(c),a},decrypt(i,a){a=Ji(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Wa(e,t,n,o,r);if(!Gi(s,c))throw Mi(c),Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Mi(c),a}}))(Ba)),Ka=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},qa=class extends Ka{},Ja=class extends Ka{},Ya=class extends Ka{},Xa=class extends Ka{},Za=class extends Ka{},Qa=class extends Ka{},$a=class extends Ka{},eo=class extends Ka{},to=class extends Ka{},no=class extends Ka{},ro=class extends Ka{},io=ao(globalThis,{});function ao(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}var oo=`modulepreload`,so=function(e){return`/`+e},co={},lo=function(e){return e.pathname.endsWith(`.css`)},uo=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},fo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=so(t,n);let r=s(t),i=lo(r);return uo(co,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:oo,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function po(){if(io!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:t}=await fo(async()=>{let{webcrypto:t}=await Promise.resolve().then(()=>e(bo()));return{webcrypto:t}},void 0);return t.subtle}catch(e){throw new ro(e)}}var mo=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await po())}},ho=new Uint8Array,go=0n,_o=1n,vo=2n,yo=new Uint8Array([75,69,77,0,0]),bo=n(((e,t)=>{t.exports={}})),xo=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function So(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r{let{webcrypto:t}=await Promise.resolve().then(()=>e(bo()));return{webcrypto:t}},void 0);return To=t,To}catch{throw Error(`failed to load Crypto`)}}}function Oo(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r>8,n]),ko,this._suiteId,e,t)}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):jo(e),r=jo(t);if(n.byteLength!==this.hashSize&&this._fallbackExtract!==void 0)return this._fallbackExtract(new Uint8Array(n),new Uint8Array(r)).buffer;let i=await this._api.importKey(`raw`,n,{name:this.algHash.name,hash:this.algHash.hash},!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){if(await this._setup(),n>255*this.hashSize)throw Error(`Entropy limit reached`);let r=jo(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new Uint8Array(n),o=ho,s=Ao(t);for(let e=1,t=0;t8192)throw new qa(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():xo(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey),i=ho,a=ho,o=ho;try{a=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),i=a;let s=ho;if(e.senderKey!==void 0){let t=xo(e.senderKey)?e.senderKey.privateKey:e.senderKey;o=new Uint8Array(await this._prim.dh(t,e.recipientPublicKey)),i=Co(a,o),a.fill(0),o.fill(0);let n=xo(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey);s=new Uint8Array(await this._prim.serializePublicKey(n))}let c=Co(new Uint8Array(n),new Uint8Array(r),s);return{enc:n,sharedSecret:await this._generateSharedSecret(i,c)}}catch(e){throw new Xa(e)}finally{i.fill(0),a.fill(0),o.fill(0)}}async decap(e){let t=jo(e.enc),n=await this._prim.deserializePublicKey(t),r=xo(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=xo(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i),o=ho,s=ho,c=ho;try{s=new Uint8Array(await this._prim.dh(r,n)),o=s;let i=ho;e.senderPublicKey!==void 0&&(c=new Uint8Array(await this._prim.dh(r,e.senderPublicKey)),o=Co(s,c),s.fill(0),c.fill(0),i=new Uint8Array(await this._prim.serializePublicKey(e.senderPublicKey)));let l=Co(new Uint8Array(t),new Uint8Array(a),i);return await this._generateSharedSecret(o,l)}catch(e){throw new Za(e)}finally{o.fill(0),s.fill(0),c.fill(0)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(No,e);try{let e=this._kdf.buildLabeledInfo(Po,t,this.secretSize);return await this._kdf.extractAndExpand(ho,n,e,this.secretSize)}finally{n.fill(0)}}},Io=[`deriveBits`],Lo=new Uint8Array([100,107,112,95,112,114,107]),Ro=new Uint8Array([115,107]),zo=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},Bo=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Ja(e))}}async deserializePublicKey(e){try{return await this._importRawKey(jo(e),!0)}catch(e){throw new Ya(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new Ja(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(jo(e),!1)}catch(e){throw new Ya(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new Ya(e)}}async generateKeyPair(){try{let e;try{e=this._curve.utils.randomSecretKey()}catch{let t=await Do(),n=new Uint8Array(this._nSk);t.getRandomValues(n),e=n}let t=new zo(this._algName,e,`private`,Io),n=this._curve.getPublicKey(e);return{publicKey:new zo(this._algName,n,`public`),privateKey:t}}catch(e){throw new ro(e)}}async deriveKeyPair(e){try{let t=jo(e),n=await this._hkdf.labeledExtract(ho.buffer,Lo,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Ro,ho,this._nSk),i=new zo(this._algName,new Uint8Array(r),`private`,Io);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new no(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new zo(this._algName,t,`public`))}catch(e){return Promise.reject(new Ya(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new Ja(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new zo(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:Io))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new zo(this._algName,wo(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new zo(this._algName,wo(e.d),`private`,Io)))})}};function Vo(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ho(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function Uo(e,t,n=``){let r=Vo(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function Wo(e){if(typeof e==`bigint`){if(!Qo(e))throw Error(`positive bigint expected, got `+e)}else Ho(e);return e}function Go(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ko(...e){for(let t=0;t=0;n--)t=t<<8n|BigInt(e[n]);return t}function Xo(e,t){Ho(t);let n=BigInt(Wo(e)),r=new Uint8Array(t);for(let e=0;e>=8n;if(n!==0n)throw Error(`number too large`);return r}function Zo(e){return Uint8Array.from(e)}function Qo(e){return typeof e==`bigint`&&0n<=e}function $o(e,t,n){return Qo(e)&&Qo(t)&&Qo(n)&&t<=e&&e=0n?n:t+n}function rs(e,t,n){let r=e;for(;t-->go;)r*=r,r%=n;return r}function is(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function as(e,t){return e+t-(t>>_o<<_o)}function os(e){let t=6n*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 ss(e){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);for(let t of[`adjustScalarBytes`,`powPminus2`]){let n=typeof e[t];if(n!==`function`)throw Error(`param "${t}" is invalid: expected function, got ${n}`)}return Object.freeze({...e})}function cs(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=ss(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||ts,c=o?255:448,l=os(t),u=o?32:56,d=o?9n:5n,f=o?121665n:39081n,p=o?vo**254n:vo**447n,m=p+(o?8n*vo**251n-_o:4n*vo**445n-_o)+_o,h=e=>ns(e,t),g=_(d);function _(e){return Xo(h(e),u)}let v=o?(_o<<255n)-_o:go;function y(e){Uo(e,u,`uCoordinate`);let t=Yo(e);return o&&(t&=v),h(t)}function b(e){return Yo(r(Zo(Uo(e,u,`scalar`))))}let x=new Set(o?[go,_o,t-_o,325606250916557431795983626356110631294008115727848805560023387167927233504n,39382357235489614581723060781553021112529911719440698176882885853963445705823n]:[go,_o,t-_o]);function S(e,t){let n=y(t);if(x.has(n))throw Error(`invalid private or public key received`);let r=D(n,b(e));if(r===0n)throw Error(`invalid private or public key received`);return _(r)}let C=h(d);function w(e){let t=D(C,b(e));if(t===0n)throw Error(`invalid private or public key received`);return _(t)}let T=w,E=S;function D(e,n){es(`u`,e,go,t),es(`scalar`,n,p,m);let r=n,a=e,o=_o,s=go,u=e,d=_o,g=r^r>>_o;for(let e=c-1;e>=0;e--){let n=as(t,g>>BigInt(e));({x_2:o,x_3:u}=l(n,o,u)),{x_2:s,x_3:d}=l(n,s,d);let r=o+s,i=h(r*r),c=o-s,p=h(c*c),m=i-p,_=u+d,v=u-d,y=h(v*r),b=h(_*c),x=y+b,S=y-b;u=h(x*x),d=h(a*h(S*S)),o=h(i*p),s=h(m*(i+f*m))}let _=as(t,r);({x_2:o,x_3:u}=l(_,o,u)),{x_2:s,x_3:d}=l(_,s,d);let v=i(s);return h(o*v)}let O={secretKey:u,publicKey:u,seed:u},k=e=>(e===void 0&&(e=s(u)),Uo(e,O.seed,`seed`),e),A={randomSecretKey:k};return Object.freeze({keygen:is(k,T),getSharedSecret:E,getPublicKey:T,scalarMult:S,scalarMultBase:w,utils:A,GuBytes:g.slice(),lengths:O})}var ls=1n,us=2n,ds=3n,fs=5n,ps=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function ms(e){let t=10n,n=80n,r=ps,i=e*e%r*e%r,a=rs(rs(i,us,r)*i%r,ls,r)*e%r,o=rs(a,fs,r)*a%r,s=rs(o,t,r)*o%r,c=rs(s,20n,r)*s%r,l=rs(c,40n,r)*c%r;return{pow_p_5_8:rs(rs(rs(rs(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,us,r)*e%r,b2:i}}function hs(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var gs=(()=>{let e=ps;return cs({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=ms(t);return ns(rs(n,ds,e)*r,e)},adjustScalarBytes:hs})})();function _s(e){function t(t,n,r){if(Uo(t,void 0,`key`),!qo)throw Error(`Non little-endian hardware is not yet supported`);Uo(n,12,`nonce`),r!==void 0&&Uo(r,void 0,`AAD`);let i=e(t,n,r),a=!1;return{encrypt(e,t){if(a)throw Error(`cannot encrypt() twice with same key + nonce`);return a=!0,Uo(e),t!==void 0&&Uo(t,void 0,`output`),i.encrypt(e,t)},decrypt(e,t){if(Uo(e),e.length<16)throw Error(`"ciphertext" expected length bigger than tagLength=16`);return t!==void 0&&Uo(t,void 0,`output`),i.decrypt(e,t)}}}return Object.assign(t,{blockSize:64,nonceLength:12,tagLength:16})}function vs(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r>>32-t}var Cs=64,ws=16,Ts=2**32-1,Es=Uint32Array.of();function Ds(e,t,n,r,i,a,o){let s=i.length,c=new Uint8Array(Cs),l=Go(c),u=bs(i)&&bs(a),d=u?Go(i):Es,f=u?Go(a):Es;for(let p=0;p=Ts)throw Error(`arx: counter overflow`);let m=Math.min(Cs,s-p);if(u&&m===Cs){let e=p/4;if(p%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t{Uo(t,32,`arx key`),Uo(n,12,`nonce`),Uo(r,void 0,`data`);let o=r.length;if(i===void 0&&(i=new Uint8Array(o)),Uo(i,void 0,`output`),!Number.isSafeInteger(a)||a<0||a>=Ts)throw Error(`arx: counter overflow`);if(i.length>>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 e=0;e<10;e++)this.r5[e]=5*this.r[e];for(let t=0;t<8;t++)this.pad[t]=ks(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a,r5:o}=this,s=a[0],c=a[1],l=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],h=a[8],g=a[9],_=o[1],v=o[2],y=o[3],b=o[4],x=o[5],S=o[6],C=o[7],w=o[8],T=o[9],E=ks(e,t+0),D=ks(e,t+2),O=ks(e,t+4),k=ks(e,t+6),A=ks(e,t+8),j=ks(e,t+10),M=ks(e,t+12),N=ks(e,t+14),P=i[0]+(E&8191),F=i[1]+((E>>>13|D<<3)&8191),I=i[2]+((D>>>10|O<<6)&8191),L=i[3]+((O>>>7|k<<9)&8191),R=i[4]+((k>>>4|A<<12)&8191),ee=i[5]+(A>>>1&8191),te=i[6]+((A>>>14|j<<2)&8191),z=i[7]+((j>>>11|M<<5)&8191),ne=i[8]+((M>>>8|N<<8)&8191),re=i[9]+(N>>>5|r),B=0,ie=B+P*s+F*T+I*w+L*C+R*S;B=ie>>>13,ie&=8191,ie+=ee*x+te*b+z*y+ne*v+re*_,B+=ie>>>13,ie&=8191;let ae=B+P*c+F*s+I*T+L*w+R*C;B=ae>>>13,ae&=8191,ae+=ee*S+te*x+z*b+ne*y+re*v,B+=ae>>>13,ae&=8191;let oe=B+P*l+F*c+I*s+L*T+R*w;B=oe>>>13,oe&=8191,oe+=ee*C+te*S+z*x+ne*b+re*y,B+=oe>>>13,oe&=8191;let V=B+P*u+F*l+I*c+L*s+R*T;B=V>>>13,V&=8191,V+=ee*w+te*C+z*S+ne*x+re*b,B+=V>>>13,V&=8191;let H=B+P*d+F*u+I*l+L*c+R*s;B=H>>>13,H&=8191,H+=ee*T+te*w+z*C+ne*S+re*x,B+=H>>>13,H&=8191;let se=B+P*f+F*d+I*u+L*l+R*c;B=se>>>13,se&=8191,se+=ee*s+te*T+z*w+ne*C+re*S,B+=se>>>13,se&=8191;let ce=B+P*p+F*f+I*d+L*u+R*l;B=ce>>>13,ce&=8191,ce+=ee*c+te*s+z*T+ne*w+re*C,B+=ce>>>13,ce&=8191;let le=B+P*m+F*p+I*f+L*d+R*u;B=le>>>13,le&=8191,le+=ee*l+te*c+z*s+ne*T+re*w,B+=le>>>13,le&=8191;let ue=B+P*h+F*m+I*p+L*f+R*d;B=ue>>>13,ue&=8191,ue+=ee*u+te*l+z*c+ne*s+re*T,B+=ue>>>13,ue&=8191;let de=B+P*g+F*h+I*m+L*p+R*f;B=de>>>13,de&=8191,de+=ee*d+te*u+z*l+ne*c+re*s,B+=de>>>13,de&=8191,B=(B<<2)+B|0,B=B+ie|0,ie=B&8191,B>>>=13,ae+=B,i[0]=ie,i[1]=ae,i[2]=oe,i[3]=V,i[4]=H,i[5]=se,i[6]=ce,i[7]=le,i[8]=ue,i[9]=de}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;Ko(n)}update(e){this.assertActive();let{buffer:t}=this,n=e.length;for(let r=0;r>>0,e[r++]=t[n]>>>8;let i=e.slice();return this.destroy(),i}};function js(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(t,n,r)=>({encrypt(i,a){let o=i.length;a=ys(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=Ps(e,t,n,s,r);return a.set(c,o),Ko(c),a},decrypt(i,a){a=ys(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=Ps(e,t,n,o,r);if(!vs(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Ko(c),a}}))(Ms)),Is=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(jo(e))}async seal(e,t,n){return Fs(this._key,new Uint8Array(jo(e)),new Uint8Array(jo(n))).encrypt(new Uint8Array(jo(t))).buffer}async open(e,t,n){return Fs(this._key,new Uint8Array(jo(e)),new Uint8Array(jo(n))).decrypt(new Uint8Array(jo(t))).buffer}},Ls=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Is(e)}},Rs=new Uint8Array([115,101,99]),zs=class{constructor(e,t){Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._kdf=e,this.exporterSecret=t}seal(e,t){return Promise.reject(new ro(`Not supported`))}open(e,t){return Promise.reject(new ro(`Not supported`))}async export(e,t){let n=jo(e);if(n.byteLength>8192)throw new qa(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Rs,new Uint8Array(n),t)}catch(e){throw new Qa(e)}}},Bs=class extends zs{},Vs=class extends zs{constructor(e,t,n){super(e,t),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=n}},Hs=class extends zs{constructor(e,t){super(e,t.exporterSecret),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ctx={key:t.aead.createEncryptionContext(t.key),baseNonce:t.baseNonce,seq:t.seq}}computeNonce(e){let t=So(e.seq,e.baseNonce.byteLength);return Oo(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new to(`Message limit reached`);e.seq+=1}},Us=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Ws=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Gs,Ks=class{constructor(){Gs.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Us(this,Gs,`f`);return Ws(this,Gs,t,`f`),await n,e}};Gs=new WeakMap;var qs=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Js=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},Ys,Xs=class extends Hs{constructor(){super(...arguments),Ys.set(this,void 0)}async open(e,t=ho.buffer){Js(this,Ys,qs(this,Ys,`f`)??new Ks,`f`);let n=await qs(this,Ys,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),jo(e),jo(t))}catch(e){throw new eo(e)}finally{n()}return this.incrementSeq(this._ctx),r}};Ys=new WeakMap;var Zs=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Qs=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},$s,ec=class extends Hs{constructor(e,t,n){super(e,t),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),$s.set(this,void 0),this.enc=n}async seal(e,t=ho.buffer){Qs(this,$s,Zs(this,$s,`f`)??new Ks,`f`);let n=await Zs(this,$s,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),jo(e),jo(t))}catch(e){throw new $a(e)}finally{n()}return this.incrementSeq(this._ctx),r}};$s=new WeakMap;function tc(e){if(`auth`in e&&e.auth===!1)throw new ro(`Auth and AuthPSK modes are not supported by this KEM`)}var nc=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),rc=new Uint8Array([101,120,112]),ic=new Uint8Array([105,110,102,111,95,104,97,115,104]),ac=new Uint8Array([107,101,121]),oc=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),sc=new Uint8Array([115,101,99,114,101,116]),cc=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),lc=class extends mo{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new qa(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new qa(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new qa(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(cc),this._suiteId.set(So(this._kem.id,2),4),this._suiteId.set(So(this._kdf.id,2),6),this._suiteId.set(So(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){e.senderKey!==void 0&&tc(this._kem),this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n=(e.psk===void 0?0:1)|(e.senderKey===void 0?0:2);return await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){e.senderPublicKey!==void 0&&tc(this._kem),this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n=(e.psk===void 0?0:1)|(e.senderPublicKey===void 0?0:2);return await this._keyScheduleR(n,t,e)}async seal(e,t,n=ho.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=ho.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?ho:Ao(n.psk.id),i=await this._kdf.labeledExtract(ho,oc,r),a=n.info===void 0?ho:Ao(n.info),o=await this._kdf.labeledExtract(ho,ic,a),s=Co(new Uint8Array([e]),new Uint8Array(i),new Uint8Array(o)),c=n.psk===void 0?ho:Ao(n.psk.key),l=this._kdf.buildLabeledIkm(sc,c),u=this._kdf.buildLabeledInfo(rc,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===65535)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(ac,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(nc,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new Vs(this._kdf,i.exporterSecret,n):new ec(this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new Bs(this._kdf,r.exporterSecret):new Xs(this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new qa(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new qa(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new qa(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new qa(`Too long psk.id`)}}},uc=class extends lc{},dc=class extends J{},fc=class extends J{},pc=class extends Bo{constructor(e){super(`X25519`,32,gs,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new Ja(e))}}},mc=class extends Fo{constructor(){let e=new fc;super(32,new pc(e),e),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32})}},hc=`hpke-auth-x25519-hkdfsha256-chacha20poly1305`,gc=`aes-256-gcm`,_c=`kynotes/envelope/v3`,vc=`kynotes/envelope/v2`,yc=`kynotes/identity/v1`,bc=/^(cnt|dev|usr|lnk)_[0-9a-hjkmnp-tv-z]{26}$/,xc=new TextEncoder,Sc=new uc({kem:new mc,kdf:new dc,aead:new Ls});function Cc(e,t){if(!t.startsWith(`${e}_`)||!bc.test(t))throw Error(`invalid ${e} id`);return xc.encode(t)}function wc(...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}function Y(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r4294967295)throw Error(`invalid key generation`);let a=new Uint8Array(4);return new DataView(a.buffer).setUint32(0,n),wc(xc.encode(e),Cc(`cnt`,t),a,Cc(`dev`,r),Cc(`dev`,i))}var Dc=(e,t,n,r)=>Ec(_c,e,t,n,r);async function Oc(e){return{privateKey:await Sc.kem.deserializePrivateKey(e),publicKey:await Sc.kem.deserializePublicKey(ri.getPublicKey(e))}}async function kc(e,t,n,r,i,a,o){if(e.length!==32||t.length!==32)throw Error(`invalid envelope input`);let s=Dc(n,r,i,a.deviceId),c={recipientPublicKey:await Sc.kem.deserializePublicKey(t),senderKey:await Oc(a.privateKey),info:s},{enc:l,ct:u}=await Sc.seal(o?{...c,ekm:o}:c,e);return wc(Uint8Array.of(3),xc.encode(a.deviceId),new Uint8Array(l),new Uint8Array(u))}function Ac(e,t,n,r,i,a){return kc(e,t,n,r,i,a)}function jc(e,t){let[n,r]=e===`hpke-auth-x25519-hkdfsha256-chacha20poly1305`?[3,111]:e===`x25519-hkdf-sha256-chacha20poly1305`?[2,123]:[-1,-1];if(t.length!==r||t[0]!==n)throw Error(`unsupported envelope`);let i=new TextDecoder().decode(t.subarray(1,31));return Cc(`dev`,i),i}async function Mc(e,t,n,r,i,a,o){let s=jc(e,t);if(o.length!==32)throw Error(`invalid sender key`);if(e===`x25519-hkdf-sha256-chacha20poly1305`)return Nc(t,n,r,i,a,s,o);let c=await Sc.open({recipientKey:await Oc(n),senderPublicKey:await Sc.kem.deserializePublicKey(o),enc:t.subarray(31,63),info:Dc(r,i,a,s)},t.subarray(63));return new Uint8Array(c)}function Nc(e,t,n,r,i,a,o){let s=Ec(vc,n,r,i,a),c=e.subarray(31,63),l=e.subarray(63,75);return Ga(qe(wc(ri.getSharedSecret(t,c),ri.getSharedSecret(t,o)),32,wc(c,ri.getPublicKey(t),o),xc.encode(vc)),l,s).decrypt(e.subarray(75))}function Pc(e){return wc(xc.encode(yc),Cc(`usr`,e))}function Fc(e,t,n,r){if(e.length!==32||t.length!==32||r.length!==12)throw Error(`invalid identity input`);return wc(r,Ea(e,r,Pc(n)).encrypt(t))}function Ic(e,t,n){return Fc(e,t,n,Zi(12))}function Lc(e,t,n){if(e.length!==32||t.length!==60)throw Error(`invalid wrapped identity`);let r=Ea(e,t.subarray(0,12),Pc(n)).decrypt(t.subarray(12));return{privateKey:r,publicKey:ri.getPublicKey(r)}}var Rc=`kynotes-web`,zc=`notes`,Bc=[`owner`,`id`];function Vc(){return new Promise((e,t)=>{let n=indexedDB.open(Rc,7);n.onupgradeneeded=e=>{let t=n.result;if(e.oldVersion<6){for(let e of[zc,`pending`,`uploads`])t.objectStoreNames.contains(e)&&t.deleteObjectStore(e);try{localStorage.removeItem(`kynotes-pending-saves`)}catch{}}if(t.objectStoreNames.contains(zc)||t.createObjectStore(zc,{keyPath:Bc}),t.objectStoreNames.contains(`pending`)||t.createObjectStore(`pending`,{keyPath:Bc}),t.objectStoreNames.contains(`uploads`)||t.createObjectStore(`uploads`,{keyPath:`uploadId`}),t.objectStoreNames.contains(`keys`)||t.createObjectStore(`keys`,{keyPath:`username`}),e.oldVersion<7){let e=n.transaction.objectStore(`keys`).openCursor();e.onsuccess=()=>{let t=e.result;if(t){if(`authSecret`in t.value){let{authSecret:e,...n}=t.value;t.update(n)}t.continue()}}}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Unable to open local note store`))})}function Hc(e,t){return new Promise((n,r)=>{e.oncomplete=()=>n(t()),e.onerror=()=>r(e.error??Error(`Local store write failed`)),e.onabort=()=>r(e.error??Error(`Local store write aborted`))})}var Uc=(e,t)=>()=>{try{t()}catch{e.abort()}};async function Wc(e,t){let n=await Vc();try{let r=n.transaction(e,`readwrite`),i=Hc(r,()=>void 0);Uc(r,()=>t(r.objectStore(e)))(),await i}finally{n.close()}}async function Gc(e,t){await Wc(zc,n=>n.put({...t,owner:e}))}async function Kc(e){let t=await Vc(),n=await new Promise((n,r)=>{let i=t.transaction(zc).objectStore(zc).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error)});if(t.close(),!n)return;let{owner:r,...i}=n;return i}var qc=(e,t)=>Kc([e,t]);async function Jc(e,t){await Wc(zc,n=>n.delete([e,t]))}async function Yc(e){await Wc(`pending`,t=>t.put(e))}async function Xc(e){let t=await Vc();try{let n=t.transaction([zc,`pending`],`readwrite`),r=Hc(n,()=>void 0);Uc(n,()=>{n.objectStore(zc).put({...e,unsent:!0}),n.objectStore(`pending`).put(e)})(),await r}finally{t.close()}}async function Zc(e,t){let n=await Vc();try{return await new Promise((r,i)=>{let a=n.transaction(`pending`).objectStore(`pending`).get([e,t]);a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)})}finally{n.close()}}async function Qc(e,t,n){let r=await Vc();try{let i=r.transaction([zc,`pending`],`readwrite`),a,o=Hc(i,()=>a),s=i.objectStore(`pending`).get([e,t]);return s.onsuccess=Uc(i,()=>{a=s.result;let r=i.objectStore(zc).get([e,t]);r.onsuccess=Uc(i,()=>{let t=r.result;t&&n&&!a?.gone&&!a?.previousKey&&$c(t,n)&&(t={...t,unsent:!0},i.objectStore(zc).put(t)),!t?.unsent||a?.gone||a?.previousKey||a&&a.updatedAt>t.updatedAt||a&&Y(a.payload,t.payload)||(a={...t,owner:e},i.objectStore(`pending`).put(a))})}),await o}finally{r.close()}}var $c=(e,t)=>!!(e&&e.updatedAt===t.updatedAt&&e.version===t.version&&e.keyGeneration===t.keyGeneration&&Y(e.payload,t.payload));async function el(e,t){let n=await Vc();try{let r=n.transaction([zc,`pending`],`readwrite`),i=Hc(r,()=>void 0),a=[e.owner,e.id],o=r.objectStore(`pending`).get(a);o.onsuccess=Uc(r,()=>{$c(o.result,e)&&r.objectStore(`pending`).delete(a)});let s=r.objectStore(zc).get(a);s.onsuccess=Uc(r,()=>{let n=s.result;if(n&&$c(n,e)){if(t===void 0)r.objectStore(zc).delete(a);else{let{unsent:e,...i}=n;r.objectStore(zc).put({...i,version:t})}}}),await i}finally{n.close()}}async function tl(){let e=await Vc(),t=await new Promise((t,n)=>{let r=e.transaction(`pending`).objectStore(`pending`).getAll();r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});return e.close(),t}async function nl(e,t,n){await Wc(`pending`,r=>{let i=r.get([e,t]);i.onsuccess=Uc(r.transaction,()=>{i.result?.updatedAt===n&&r.delete([e,t])})})}async function rl(e,t){let n=await Vc();try{let r=n.transaction([zc,`pending`],`readwrite`),i=!1,a=Hc(r,()=>i),o=[e.owner,e.id],s=r.objectStore(`pending`),c=s.get(o);return c.onsuccess=Uc(r,()=>{if(i=$c(c.result,e),!i)return;if(!t){s.delete(o);return}let n={...t,owner:e.owner,id:e.id};s.put(n);let a=r.objectStore(zc).get(o);a.onsuccess=Uc(r,()=>{let t=a.result;$c(t,e)&&r.objectStore(zc).put({...n,unsent:t?.unsent})})}),await a}finally{n.close()}}async function il(e){await Wc(`uploads`,t=>t.put(e))}async function al(e){let t=await Vc(),n=await new Promise((e,n)=>{let r=t.transaction(`uploads`).objectStore(`uploads`).getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)});return t.close(),e?n.filter(t=>t.owner===e):[]}async function ol(e,t){await Wc(`uploads`,n=>{let r=n.get(t);r.onsuccess=Uc(n.transaction,()=>{r.result?.owner===e&&n.delete(t)})})}async function sl(e){await Wc(`keys`,t=>{let n=t.get(e);n.onsuccess=Uc(t.transaction,()=>t.put({...n.result,username:e,updatedAt:new Date().toISOString()}))})}async function cl(e,t,n){let r=await e();try{await sl(t),n&&await ml(t,n.userID,n.identity)}catch{}return r}var ll=()=>globalThis.isSecureContext===!0&&typeof globalThis.crypto?.subtle?.generateKey==`function`?`wrapped`:`plain`,ul=(e,t)=>new TextEncoder().encode(`kynotes/device-identity/v1|${e}|${t}`);async function dl(e,t){let n={userID:e,deviceId:t.deviceId,publicKey:t.publicKey.slice()};if(ll()===`plain`)return{...n,privateKey:t.privateKey.slice()};let r=await crypto.subtle.generateKey({name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]),i=crypto.getRandomValues(new Uint8Array(12)),a=new Uint8Array(await crypto.subtle.encrypt({name:`AES-GCM`,iv:i,additionalData:ul(e,t.deviceId)},r,t.privateKey.slice())),o=new Uint8Array(12+a.length);return o.set(i),o.set(a,12),{...n,sealed:o,deviceKey:r}}async function fl(e){try{let t=`privateKey`in e?e.privateKey:new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:e.sealed.slice(0,12),additionalData:ul(e.userID,e.deviceId)},e.deviceKey,e.sealed.slice(12)));return Y(ri.getPublicKey(t),e.publicKey)?{deviceId:e.deviceId,publicKey:e.publicKey,privateKey:t}:void 0}catch{return}}var pl=(e,t,n)=>{let r=e.identity?.userID===t?e.identity:void 0;return n===null?!r:r!==void 0&&Y(r.publicKey,n.publicKey)};async function ml(e,t,n,r){let i=await dl(t,n).catch(()=>void 0),a=i?await xl(e,e=>{if(r!==void 0&&!pl(e,t,r))return;let{resetSent:a,...o}=e;return a&&a.userID===t&&Y(a.publicKey,n.publicKey)?{...o,identity:i}:{...e,identity:i}}):!1;return a&&ii(),a}async function hl(e,t,n){await xl(e,e=>({...e,resetSent:{userID:t,publicKey:n.slice()}}))}async function gl(e,t){let n=(await bl(e).catch(()=>void 0))?.resetSent;return n?.userID===t?n.publicKey:void 0}async function _l(e,t){let n=(await bl(e))?.identity;if(!n||n.userID!==t)return;let r=await fl(n);if(r&&`privateKey`in n&&ll()===`wrapped`){let i=await dl(t,r).catch(()=>void 0);i&&await xl(e,e=>e.identity&&`privateKey`in e.identity&&Y(e.identity.privateKey,n.privateKey)?{...e,identity:i}:void 0)}return r}async function vl(e,t){let n=await _l(e,t);return n?.deviceId?n:void 0}async function yl(e){try{return await bl(e)!==void 0}catch{return!1}}async function bl(e){let t=await Vc(),n=await new Promise((n,r)=>{let i=t.transaction(`keys`).objectStore(`keys`).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error)});return t.close(),n}async function xl(e,t){let n=!1;try{return await Wc(`keys`,r=>{let i=r.get(e);i.onsuccess=Uc(r.transaction,()=>{let e=i.result,a=e&&t(e);a&&(r.put(a),n=!0)})}),n}catch{return!1}}var Sl=(e,t)=>e.pins?.userID===t?e.pins.keys:{};async function Cl(e,t){let n=await bl(e);return n?Sl(n,t):{}}async function wl(e,t,n){let r={ok:!1,conflicts:[]};try{return await Wc(`keys`,i=>{let a=i.get(e);a.onsuccess=Uc(i.transaction,()=>{let e=a.result;if(!e)return;let o=Sl(e,t),s=Object.keys(n).filter(e=>o[e]!==void 0&&o[e]!==n[e]&&!si(o[e],n[e]));s.length?r={ok:!1,conflicts:s}:(i.put({...e,pins:{userID:t,keys:{...n,...o}}}),r={ok:!0})})}),r}catch{return{ok:!1,conflicts:[]}}}async function Tl(e,t,n,r){return di(n)?xl(e,e=>{let i=Sl(e,t),a=i[n.userId];if(r===void 0||a!==void 0&&si(a,r))return{...e,pins:{userID:t,keys:{...i,[n.userId]:n.key}}}}):!1}var El=(e,t)=>e.keyStates?.userID===t?e.keyStates.byContainer:{};async function Dl(e,t,n){let r=await bl(e),i=r&&El(r,t)[n];return i?{mark:i.mark,digests:i.digests,...i.shared===void 0?{}:{shared:i.shared},...i.generation===void 0?{}:{generation:i.generation},...i.objects===2?{objects:2}:{}}:{mark:0,digests:{}}}async function Ol(e,t,n,r){return xl(e,e=>{let i=El(e,t),a=i[n]??{mark:0,digests:{}},o={mark:Math.max(a.mark,r.mark),digests:{...r.digests,...a.digests},shared:Math.max(a.shared??0,r.shared??0),generation:Math.max(a.generation??0,r.generation??0),...a.objects===2||r.objects===2?{objects:2}:{}};return{...e,keyStates:{userID:t,byContainer:{...i,[n]:o}}}})}async function kl(e){await Wc(`keys`,t=>t.delete(e))}var Al=e=>JSON.stringify(e.type===`page`?[e.type,e.title,e.body,e.section,e.order,e.level,e.legacy]:[e.type,e.title,e.color,e.order,e.group]),jl=(e,t)=>Al(e)===Al(t);function Ml({owner:e,containerID:t,note:n,write:r}){return Nl({owner:e,containerID:t,id:n.id,version:n.version,content:Bt(n),write:r})}async function Nl({owner:e,containerID:t,id:n,version:r,content:i,write:a}){let o=await Zc(e,n).catch(()=>void 0),s=await qc(e,n).catch(()=>void 0),c=s?.unsent&&(!o||s.updatedAt>=o.updatedAt)?{...s,owner:e}:o;if(c&&!c.gone&&!c.previousKey&&c.containerID===t&&c.version===r&&c.keyGeneration===a.generation){let e=await Mt(a.key,t,n,c.payload,!0).catch(()=>void 0);if(e?.payload&&!e.v1&&Al(e.payload)===Al(i))return c}return{owner:e,id:n,containerID:t,version:r,keyGeneration:a.generation,payload:await jt(a.key,t,n,i),updatedAt:new Date().toISOString()}}async function Pl({owner:e,id:t,version:n,mode:r,open:i,server:a}){let o=await(r===`recover`?Qc(e,t):Zc(e,t)),s=await qc(e,t);for(;s&&!s.unsent&&s.version===n&&!o?.gone&&!o?.previousKey&&(!o||s.updatedAt>=o.updatedAt);){let n=await i(s),c=await a();if(n?.type!==`page`||c?.type!==`page`||jl(n,c))break;if(r===`read`)return s;let l=s;if(o=await Qc(e,t,l),s=await qc(e,t),$c(s,l))break}let c=o&&!o.gone&&!o.previousKey?o:void 0,l=s?.unsent&&(!c||s.updatedAt>=c.updatedAt)?s:c??s;return l&&(l.unsent||l===c||l.version>=n)?l:void 0}var Fl=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=Fl()})),X=e(Il(),1);async function Ll(e,t){let n=`/api/v1/auth/oidc/step-up/${encodeURIComponent(e)}`,r={popup:null},i=!1,a=new AbortController,o=document.createElement(`dialog`),s=document.createElement(`h2`);s.id=`sso-confirm-${e}`,s.textContent=`Confirm this action`,o.setAttribute(`aria-labelledby`,s.id);let c=document.createElement(`p`);c.textContent=`Sign in again with KySignOn to authorize only the action you just requested.`;let l=document.createElement(`button`);l.textContent=`Continue to KySignOn`;let u=document.createElement(`button`);u.textContent=`Cancel`,o.append(s,c,l,u),document.body.append(o);let d=!1;try{await new Promise((e,t)=>{let n=()=>{d=!0,a.abort(),t(Error(`Action confirmation cancelled`))};o.addEventListener(`cancel`,e=>{e.preventDefault(),n()}),u.onclick=n,l.onclick=()=>{r.popup=window.open(`about:blank`,`_blank`,`popup,width=600,height=750`),r.popup?(r.popup.opener=null,l.disabled=!0,c.textContent=`Complete sign-in in the KySignOn window. You can cancel here at any time.`,e()):t(Error(`Allow the KySignOn sign-in window to confirm this action`))},o.showModal()}),u.onclick=()=>{d=!0,a.abort()};let s=await fetch(`/api/v1/auth/oidc/step-up`,{signal:a.signal,method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,"X-CSRF-Token":t},body:JSON.stringify({challenge:e})}),f=await s.json();if(!s.ok||typeof f!=`object`||!f||!(`url`in f)||typeof f.url!=`string`)throw Error(`Unable to start KySignOn confirmation`);let p=new URL(f.url);if(p.protocol!==`https:`&&!(p.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(p.hostname)))throw Error(`Invalid sign-in URL`);let m=r.popup;if(!m||d)throw Error(`Action confirmation cancelled`);m.location.href=p.href;let h=Date.now()+3e5;for(;!d&&Date.now()setTimeout(e,1e3))}throw Error(`Action confirmation cancelled or expired`)}finally{r.popup?.close(),o.close(),o.remove(),i||await fetch(n,{method:`DELETE`,credentials:`include`,headers:{"X-CSRF-Token":t}}).catch(()=>void 0)}}function Rl(e){let t=typeof e==`string`?/^\d+$/.test(e)?Number(e):NaN:e;return typeof t==`number`&&Number.isSafeInteger(t)&&t>=0?t:void 0}var zl=e=>e.map(e=>({...e,keyGeneration:Rl(e.keyGeneration)})),Bl=class extends Error{code;challenge;conflictId;currentVersion;status;constructor(e,t,n){super(e),this.name=`APIRequestError`,this.code=t.error?.code,this.challenge=typeof t.error?.challenge==`string`?t.error.challenge:void 0,this.conflictId=t.conflictId,this.currentVersion=t.currentVersion,this.status=n}},Vl=`shared-v2`;function Hl(){return document.cookie.split(`; `).find(e=>e.startsWith(`csrf_token=`))?.slice(11)??``}async function Ul(e,t={}){let n=await fetch(e,t);if(n.status!==403)return n;let r;try{r=await n.clone().json()}catch{return n}if(typeof r!=`object`||!r||!(`error`in r)||typeof r.error!=`object`||r.error===null)return n;let i=r.error;if(!(`code`in i)||i.code!==`sso_step_up_required`||!(`challenge`in i)||typeof i.challenge!=`string`)return n;await Ll(i.challenge,Hl());let a=new Headers(t.headers);return a.set(`X-Kynotes-Step-Up`,i.challenge),fetch(e,{...t,headers:a})}async function Z(e,t={}){let n=(t.method??`GET`).toUpperCase(),r=new Headers(t.headers);r.set(`Accept`,`application/json`),t.body&&!r.has(`Content-Type`)&&r.set(`Content-Type`,`application/json`),[`POST`,`PUT`,`PATCH`,`DELETE`].includes(n)&&(r.set(`X-CSRF-Token`,Hl()),r.set(`X-Kynotes-Key-Scheme`,Vl));let i=await Ul(e,{...t,headers:r,credentials:`include`});if(!i.ok){let e={};try{e=await i.json()}catch{}throw new Bl(e.error?.message??`Request failed (${i.status})`,e,i.status)}if(i.status!==204)return i.json()}async function Wl(){return Z(`/api/v1/setup`)}function Gl(e,t,n){return Z(`/api/v1/setup`,{method:`POST`,body:JSON.stringify({admin:e,everyday:t,setupToken:n.trim()})})}async function Kl(e){return Z(`/api/v1/auth/login-params`,{method:`POST`,body:JSON.stringify({username:e})})}async function ql(e,t){return Z(`/api/v1/auth/login`,{method:`POST`,body:JSON.stringify({username:e,authSecret:t})})}var Jl=()=>Z(`/api/v1/auth/sso-config`),Yl=()=>Z(`/api/v1/admin/sso`),Xl=e=>Z(`/api/v1/admin/sso`,{method:`POST`,body:JSON.stringify(e)}),Zl=(e,t,n)=>Z(`/api/v1/admin/sso/pair`,{method:`POST`,body:JSON.stringify({issuerUrl:e,pairingToken:t,callbackUrl:n})}),Ql=()=>Z(`/api/v1/admin/rate-limit-networks`),$l=e=>Z(`/api/v1/admin/rate-limit-networks`,{method:`PUT`,body:JSON.stringify({networks:e})}),eu=()=>Z(`/api/v1/auth/session`),tu=()=>Z(`/api/v1/suite/apps`),nu=()=>Z(`/api/v1/auth/logout`,{method:`POST`}),ru=()=>Z(`/api/v1/containers`);function iu(e=`workbook`,t=``){return Z(`/api/v1/containers`,{method:`POST`,body:JSON.stringify({kind:e,teamId:t})})}var au=e=>Z(`/api/v1/containers/${encodeURIComponent(e)}`,{method:`DELETE`});function ou(e,t,n,r){return Z(`/api/v1/containers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({metaCiphertext:t,baseVersion:n,keyGeneration:r})})}async function su(){let[e,t]=await Promise.all([fetch(`/healthz`).then(e=>e.ok,()=>!1),fetch(`/readyz`).then(e=>e.ok,()=>!1)]);return{health:e,ready:t}}var cu=()=>Z(`/api/v1/admin/users`),lu=()=>Z(`/api/v1/admin/audit`),uu=()=>Z(`/api/v1/admin/teams`);function du(e){return Z(`/api/v1/admin/teams`,{method:`POST`,body:JSON.stringify({ownerUserId:e})})}function fu(e,t){return Z(`/api/v1/containers/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}/approve`,{method:`POST`})}function pu(e){return Z(`/api/v1/admin/users`,{method:`POST`,body:JSON.stringify(e)})}function mu(e,t){return Z(`/api/v1/admin/users/${encodeURIComponent(e)}/password`,{method:`POST`,body:JSON.stringify(t)})}function hu(e,t,n){return Z(`/api/v1/admin/teams/${encodeURIComponent(e)}/members`,{method:`POST`,body:JSON.stringify({userId:t,role:n})})}function gu(e){return Z(`/api/v1/admin/users/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify(e)})}function _u(e){return Z(`/api/v1/auth/password`,{method:`POST`,body:JSON.stringify(e)})}function vu(e){return Z(`/api/v1/auth/login-upgrade`,{method:`POST`,body:JSON.stringify(e)})}function yu(e){return Z(`/api/v1/auth/step-up`,{method:`POST`,body:JSON.stringify({authSecret:e})})}async function bu(){try{return await Z(`/api/v1/me/identity`)}catch(e){if(e instanceof Bl&&e.code===`not_found`)return;throw e}}var xu=e=>Z(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify(e)}),Su=e=>Z(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify({publicKey:e,wrapAlg:`none`})}),Cu=e=>Z(`/api/v1/me/identity/recovery`,{method:`PUT`,body:JSON.stringify(e)});async function wu(){try{return await Z(`/api/v1/me/identity/recovery/fetch`,{method:`POST`})}catch(e){if(e instanceof Bl&&e.code===`not_found`)return;throw e}}var Tu={myIdentity:bu,putRecovery:Cu,fetchRecovery:wu,replaceIdentity:e=>Z(`/api/v1/me/identity`,{method:`PUT`,body:JSON.stringify({...e,replace:!0})})},Eu=(e,t=``)=>`/api/v1/me/link-requests/${encodeURIComponent(e)}${t}`,Du=e=>Z(`/api/v1/me/link-requests`,{method:`POST`,body:JSON.stringify({commitment:e})}),Ou=()=>Z(`/api/v1/me/link-requests`),ku=(e,t)=>Z(Eu(e,`/claim`),{method:`POST`,body:JSON.stringify({approverKey:t})}),Au=(e,t)=>Z(Eu(e,`/reveal`),{method:`POST`,body:JSON.stringify({newcomerKey:t})}),ju=(e,t)=>Z(Eu(e,`/approve`),{method:`POST`,body:JSON.stringify({bundle:t})}),Mu=e=>Z(Eu(e,`/collect`),{method:`POST`}),Nu=(e,t=!1)=>Z(Eu(e),{method:`DELETE`,keepalive:t}),Pu=e=>Z(`/api/v1/auth/oidc/step-up/${encodeURIComponent(e)}`,{method:`DELETE`}),Fu={myIdentity:bu,putMyIdentity:xu,stepUp:async e=>(await yu(e))?.identity},Iu=e=>Z(`/api/v1/containers/${encodeURIComponent(e)}/envelopes`),Lu=(e,t)=>Z(`/api/v1/containers/${encodeURIComponent(e)}/envelopes`,{method:`PUT`,body:JSON.stringify({envelopes:t})}),Ru=(e,t,n)=>Z(`/api/v1/containers/${encodeURIComponent(e)}/key-rotations`,{method:`POST`,body:JSON.stringify({expectedGeneration:t,envelopes:n})});async function zu(e){try{return await Z(`/api/v1/users/${encodeURIComponent(e)}/identity`)}catch(e){if(e instanceof Bl&&e.code===`not_found`)return;throw e}}var Bu=async e=>(await Z(`/api/v1/containers/${encodeURIComponent(e)}/members`)).map(e=>({...e,approved:e.approved===!0})),Vu=()=>Z(`/api/v1/notifications`);function Hu(e,t){return Z(`/api/v1/presence`,{method:`POST`,body:JSON.stringify({containerId:e,state:t})})}function Uu(e,t,n,r=[]){return Z(`/api/v1/containers/${encodeURIComponent(e)}/invitations`,{method:`POST`,body:JSON.stringify(r.length?{inviteeId:t,role:n,envelopes:r}:{inviteeId:t,role:n})})}var Wu=(e,t)=>Z(`/api/v1/invitations/${encodeURIComponent(e)}/accept`,{method:`POST`,body:JSON.stringify({token:t})});function Gu(e,t){return Z(`/api/v1/containers/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`DELETE`})}var Ku=e=>Z(`/api/v1/objects/${encodeURIComponent(e)}/comments`).then(zl),qu=e=>Z(`/api/v1/comments/${encodeURIComponent(e)}`,{method:`DELETE`});function Ju(e,t,n,r=[]){return Z(`/api/v1/objects/${encodeURIComponent(e)}/comments`,{method:`POST`,body:JSON.stringify({bodyCiphertext:t,keyGeneration:n,mentions:r})})}async function Yu(e,t=0){return Z(`/api/v1/containers/${encodeURIComponent(e)}/changes?since=${t}`)}async function Xu(e,t=`note`){return Z(`/api/v1/containers/${encodeURIComponent(e)}/objects`,{method:`POST`,body:JSON.stringify({kind:t})})}async function Zu(e,t){let n=await fetch(`/api/v1/objects/${encodeURIComponent(e)}${t?`?version=${t}`:``}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!n.ok)throw Error(`Unable to read note (${n.status})`);let r=Rl(n.headers.get(`X-Kynotes-Key-Generation`)),i=n.headers.get(`X-Kynotes-Saved-At`)??``;return{bytes:new Uint8Array(await n.arrayBuffer()),version:Number(n.headers.get(`X-Kynotes-Version`)??0),keyGeneration:r,savedAt:i}}async function Qu(e,t,n,r,i){return Z(`/api/v1/objects/${encodeURIComponent(e)}`,{method:`PUT`,body:t,headers:{"Content-Type":`application/octet-stream`,"X-Kynotes-Base-Version":String(n),"X-Kynotes-Key-Generation":String(r),"Idempotency-Key":i}})}function $u(e,t,n){return Z(`/api/v1/containers/${encodeURIComponent(e)}/uploads`,{method:`POST`,body:JSON.stringify({declaredBytes:t,expectedDigest:n,kind:`attachment`})})}var ed=e=>Z(`/api/v1/uploads/${encodeURIComponent(e)}`),td=e=>Z(`/api/v1/uploads/${encodeURIComponent(e)}`,{method:`DELETE`});function nd(e,t,n){return Z(`/api/v1/uploads/${encodeURIComponent(e)}`,{method:`PATCH`,body:n,headers:{"Content-Type":`application/octet-stream`,"X-Kynotes-Chunk-Index":String(t)}})}function rd(e,t,n){return Z(`/api/v1/uploads/${encodeURIComponent(e)}/finalize`,{method:`POST`,body:JSON.stringify({metadataCiphertext:t,keyGeneration:n})})}function id(e,t,n){return Z(`/api/v1/objects/${encodeURIComponent(e)}/attachments`,{method:`POST`,body:JSON.stringify({attachmentId:t,objectVersion:n})})}var ad=e=>Z(`/api/v1/objects/${encodeURIComponent(e)}/attachments`).then(zl);async function od(e){let t=await fetch(`/api/v1/attachments/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`Unable to download attachment`);return new Uint8Array(await t.arrayBuffer())}var sd=e=>Z(`/api/v1/objects/${encodeURIComponent(e)}/conflicts`).then(zl);async function cd(e){let t=await fetch(`/api/v1/conflicts/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`Unable to read conflicting version (${t.status})`);return new Uint8Array(await t.arrayBuffer())}var ld=e=>Z(`/api/v1/conflicts/${encodeURIComponent(e)}/resolve`,{method:`POST`});function ud(e,t){let n=``;for(let t of e)n+=String.fromCharCode(t);return Z(`/api/v1/share-links`,{method:`POST`,body:JSON.stringify({ciphertext:btoa(n).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``),expiresAt:t})})}var dd=()=>Z(`/api/v1/share-links`),fd=e=>Z(`/api/v1/share-links/${encodeURIComponent(e)}`,{method:`DELETE`});async function pd(e){let t=await fetch(`/api/v1/share-links/${encodeURIComponent(e)}`,{headers:{Accept:`application/octet-stream`}});if(!t.ok)throw Error(`This encrypted link is invalid or expired.`);return new Uint8Array(await t.arrayBuffer())}var md=e=>Z(`/api/v1/objects/${encodeURIComponent(e)}`,{method:`DELETE`}),hd=()=>Z(`/api/v1/push/web/key`),gd=e=>Z(`/api/v1/push/web/subscriptions`,{method:`PUT`,body:JSON.stringify({endpoint:e})}),_d=e=>Z(`/api/v1/push/web/subscriptions`,{method:`DELETE`,body:JSON.stringify({endpoint:e})}),vd=()=>Z(`/api/v1/reminders`),yd=(e,t)=>Z(`/api/v1/reminders/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({at:t})}),bd=e=>Z(`/api/v1/reminders/${encodeURIComponent(e)}`,{method:`DELETE`});function xd(e){if(!Sd(e))throw Error(`Invalid mirror result`);return{uploaded:wd(e.uploaded),skipped:wd(e.skipped),failed:wd(e.failed),missing:wd(e.missing)}}function Sd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Cd(e){if(typeof e!=`string`)throw Error(`Invalid backup response`);return e}function wd(e){if(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)throw Error(`Invalid backup response`);return e}function Td(e){if(!Sd(e)||typeof e.paired!=`boolean`||typeof e.allow_private_recovery!=`boolean`||!Array.isArray(e.local_copies))throw Error(`Invalid backup status`);let t=null;if(e.receipt!==null){if(!Sd(e.receipt))throw Error(`Invalid backup receipt`);t={id:Cd(e.receipt.capsule_id),digest:Cd(e.receipt.digest),at:Cd(e.receipt.deposited_at)}}if(!Sd(e.mirror)||typeof e.mirror.configured!=`boolean`)throw Error(`Invalid mirror status`);return{mirror:{configured:e.mirror.configured,target:Cd(e.mirror.target),pending:wd(e.mirror.pending),last:e.mirror.last===null?null:xd(e.mirror.last)},keyID:Cd(e.key_id),keyError:Cd(e.key_error??``),paired:e.paired,remoteURL:Cd(e.remote_url),localDirectory:Cd(e.local_directory),localCopies:e.local_copies.length,localError:Cd(e.local_error??``),intervalSeconds:wd(e.interval_seconds),nextRun:e.next_run===null?null:Cd(e.next_run),lastAttempt:Cd(e.last_attempt),lastResult:Cd(e.last_result),receipt:t,blobCount:wd(e.blob_count),blobBytes:wd(e.blob_bytes),allowPrivate:e.allow_private_recovery,databaseBytes:wd(e.database_bytes??0),capsuleLimitBytes:wd(e.capsule_limit_bytes??0)}}var Ed=e=>e.capsuleLimitBytes>0&&e.databaseBytes>=e.capsuleLimitBytes*.8;function Dd(e){return e.intervalSeconds?e.keyID?!e.paired&&!e.localDirectory?`Waiting for a destination`:e.nextRun?`Next ${new Date(e.nextRun).toLocaleString()}`:`Next run not scheduled`:`Waiting for recovery key`:`Manual only`}async function Od(){return Td(await Z(`/api/v1/admin/backup/status`))}function kd(e,t={}){return Z(`/api/v1/admin/backup/${e}`,{method:`POST`,body:JSON.stringify(t)})}async function Ad(){let e=await Z(`/api/v1/admin/backup/deposit`,{method:`POST`}).catch(e=>{throw e instanceof Bl&&e.code===`database_too_large`?Error(`The database is now larger than one capsule can hold, so no backup was made. Delete unneeded notebooks or old pages, then back up again.`):e});if(!Sd(e)||!Sd(e.result))throw Error(`Invalid backup result`);let t=typeof e.result.local_path==`string`&&e.result.local_path!==``,n=Sd(e.result.receipt),r=e.result.mirror===void 0?` Mirror: not run.`:` Mirror: ${Nd(xd(e.result.mirror))}`,i=`Local copy: ${t?`saved`:`not saved`}. KyRecovery: ${n?`deposited`:`not deposited`}.${r}`;return e.error_code||e.result.local_error?`${i} A capsule destination, blob transfer or receipt/audit write failed; check status before relying on this run.`:i}async function jd(){let e=await Z(`/api/v1/admin/backup/drill`,{method:`POST`});if(!Sd(e)||typeof e.passed!=`boolean`)throw Error(`Invalid drill response`);if(!e.passed)throw Error(`Restore drill failed. Check the restored database, secrets and inventory.`);return`Synthetic restore drill passed. Ciphertext blobs and real custodian cards require separate recovery proof.`}async function Md(){let e=await Ul(`/api/v1/admin/backup/export-capsule`,{method:`POST`,credentials:`include`,headers:{"X-CSRF-Token":Hl()}});if(!e.ok){let t=await e.json();throw Sd(t)&&Sd(t.error)?new Bl(Cd(t.error.message),{error:{code:Cd(t.error.code)}}):Error(`Capsule download failed`)}let t=URL.createObjectURL(await e.blob()),n=document.createElement(`a`);n.href=t,n.download=`KyNotes.kycap`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),6e4)}function Nd(e){return`${e.uploaded} uploaded, ${e.skipped} already recorded, ${e.failed} failed (${e.missing} missing).`}async function Pd(){let e=await Z(`/api/v1/admin/backup/mirror`,{method:`POST`});if(!Sd(e))throw Error(`Invalid mirror response`);let t=Nd(xd(e.result));return e.error_code?`${t} Mirror incomplete; check status and retry.`:t}var Fd=`none`;function Id(e,t,n){if(e.wrapAlg!==`aes-256-gcm`)throw Error(`unsupported identity wrap`);let r=Lc(t,$e(e.wrappedPrivateKey),n);if(!Y(r.publicKey,$e(e.publicKey)))throw Error(`identity public key mismatch`);return{...r,deviceId:e.deviceId}}var Ld=(e,t,n)=>e.wrapAlg===`none`?`device-only`:Id(e,t.userKEK,n);async function Rd(e,t,n,r){if(r)return Ld(r,n,t);let i=await e.stepUp(n.authSecret);if(i)return Ld(i,n,t);let a=Tc(),o={publicKey:Qe(a.publicKey),wrapAlg:gc,wrappedPrivateKey:Qe(Ic(n.userKEK,a.privateKey,t))};try{let{deviceId:t}=await e.putMyIdentity(o);return{...a,deviceId:t}}catch(r){let i=r.code;if(i===`password_change_required`)return`admin-password`;let a=i===`identity_exists`?await e.stepUp(n.authSecret):void 0;if(!a)throw r;return Ld(a,n,t)}}async function zd(e,t,n,r,i){let a=await e.myIdentity();if(!a)return;let o=e=>e?.deviceId===a.deviceId&&Y(e.publicKey,$e(a.publicKey)),s;if(a.wrapAlg===`none`){if(a.passwordCopy!==`addable`||!o(i))return;s=i}else{let r=await e.stepUp(n.authSecret);if(s=r?Id(r,n.userKEK,t):o(i)?i:void 0,!s)throw Error(`Sign in with your password on this device before changing it`)}let c=Ic(r.userKEK,s.privateKey,t);if(!Y(Lc(r.userKEK,c,t).publicKey,$e(a.publicKey)))throw Error(`This browser's copy of your key is damaged. Use Forget this device, then sign in again.`);return{identity:s,identityDeviceId:s.deviceId,wrappedIdentityKey:Qe(c)}}async function Bd(e,t,n=!1,r=!1){let i=await t.load(),a=await e.myIdentity();if(a)return Wd(i,a)||(i=await t.load()),i&&Wd(i,a)?Gd(t,i,a.deviceId):{kind:`link`};if(i?.deviceId&&!n)return{kind:`orphaned`};let o=i&&!i.deviceId?i:{...Tc(),deviceId:``};if(o!==i&&!await t.save(o,i??null))return r?{kind:`unsaved`}:Bd(e,t,!1,!0);try{let{deviceId:n}=await e.putDeviceOnlyIdentity(Qe(o.publicKey));return await Gd(t,o,n)}catch(n){if(n.code!==`identity_exists`)throw n;let i=await e.myIdentity();if(i&&Wd(o,i))return Gd(t,o,i.deviceId);if(!r)return Bd(e,t,!1,!0);throw n}}async function Vd(e,t,n,r,i){let a=await t.load(),o=await Rd(e,n,r,i);return typeof o==`string`?o:t.save(o,a??null)}var Hd=(e,t,n)=>!!(e&&t&&n&&Y(n,$e(t.publicKey))&&!Y(e.publicKey,n)),Ud=e=>!(!e||e.wrapAlg!==`aes-256-gcm`&&!e.recoveryId),Wd=(e,t)=>e!==void 0&&Y(e.publicKey,$e(t.publicKey));async function Gd(e,t,n){let r={...t,deviceId:n};if(t.deviceId===n||await e.save(r,t))return{kind:`held`,identity:r};let i=await e.load();return i?.deviceId===n&&Y(i.publicKey,t.publicKey)?{kind:`held`,identity:i}:{kind:`unsaved`}}function Kd(e,t){return t?!e||!Y(e.publicKey,$e(t.publicKey))?`link`:e.deviceId===t.deviceId?`held`:`create`:e?.deviceId?`orphaned`:`create`}function qd(e,t){if(e?.deviceId)return t===`unreachable`||Kd(e,t)===`held`?e:void 0}var Jd=`kynotes.login-pins.v1`,Yd=e=>e.trim().toLowerCase();function Xd(){try{let e=JSON.parse(localStorage.getItem(Jd)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}var Zd=e=>Xd().includes(Yd(e))?ct:lt;function Qd(e){let t=Xd();if(!t.includes(Yd(e)))try{localStorage.setItem(Jd,JSON.stringify([...t,Yd(e)]))}catch{}}async function $d(e,t,n,r,i){let a=ft(),o=await ut(n,a,ct),s;if(i?.wrapAlg===`aes-256-gcm`){let e=Id(i,r.userKEK,t);s={identityDeviceId:e.deviceId,wrappedIdentityKey:Qe(Ic(o.userKEK,e.privateKey,t))}}return await e({currentAuthSecret:r.authSecret,newAuthSecret:o.authSecret,newLoginSalt:a,iterations:ct,...s}),{keys:o,identity:i&&s?{...i,wrappedPrivateKey:s.wrappedIdentityKey}:i}}async function ef(e,t){let{loginSalt:n,iterations:r}=await Kl(e),i=await dt(t,n,r,Zd(e));return await yu(i),i}function tf(e){let t=document.createElement(`dialog`);t.className=`ky-dialog`;let n=document.createElement(`form`),r=document.createElement(`h2`);r.id=`password-step-up`,r.textContent=`Confirm your password`,t.setAttribute(`aria-labelledby`,r.id);let i=document.createElement(`label`);i.textContent=`Password`;let a=document.createElement(`input`);a.type=`password`,a.autocomplete=`current-password`,a.required=!0,i.append(a);let o=document.createElement(`p`);o.setAttribute(`aria-live`,`polite`);let s=document.createElement(`button`);s.textContent=`Confirm`;let c=document.createElement(`button`);c.type=`button`,c.className=`secondary`,c.textContent=`Cancel`;let l=document.createElement(`div`);return l.className=`dialog-actions`,l.append(c,s),n.append(r,i,o,l),t.append(n),document.body.append(t),new Promise((r,i)=>{let l=()=>t.remove(),u=()=>{l(),i(Error(`Password confirmation cancelled`))};t.addEventListener(`cancel`,e=>{e.preventDefault(),u()}),c.onclick=u,n.onsubmit=t=>{t.preventDefault();let n=a.value;a.value=``,s.disabled=!0,o.textContent=``,ef(e,n).then(e=>{l(),r(e)},e=>{s.disabled=!1,o.textContent=e instanceof Error?e.message:`Password not confirmed`})},t.showModal()})}function nf(e){return e instanceof Bl&&e.code===`step_up_required`}async function rf(e,t,n=tf){try{return await t()}catch(r){if(!nf(r))throw r;return await n(e),t()}}var af=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),of=n(((e,t)=>{t.exports=af()})),Q=of();function sf({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`1440`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(`2`),[_,v]=(0,X.useState)(`3`);async function y(){let e=await Od();n(e),c(String(e.intervalSeconds/60))}(0,X.useEffect)(()=>{y().catch(e=>o(e instanceof Error?e.message:`Backup status unavailable`))},[]);async function b(t){i(!0),o(``);try{let n=await rf(e,t);await y(),o(n??`Backup settings updated.`)}catch(e){o(e instanceof Error?e.message:`Backup action failed`)}finally{i(!1)}}return(0,Q.jsxs)(`div`,{className:`admin-panel backups`,children:[(0,Q.jsx)(`p`,{children:`Sealed capsules carry the database, deployment secrets, recovery public key, configuration and blob inventory. Note and attachment ciphertext blobs require a separate mirror; a capsule alone cannot restore that content.`}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`backup-facts`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:`Recovery key`}),(0,Q.jsx)(`p`,{className:`backup-key`,children:t.keyID||`No key pinned`}),t.keyError&&(0,Q.jsx)(`p`,{role:`alert`,children:`Pinned key is missing or invalid.`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:`KyRecovery`}),(0,Q.jsx)(`p`,{children:t.paired?t.remoteURL:`Not paired`}),t.receipt&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Receipt: `,t.receipt.id]}),(0,Q.jsx)(`p`,{children:t.receipt.at}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{children:`Receipt digest`}),(0,Q.jsx)(`p`,{className:`backup-key`,children:t.receipt.digest})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:`Local copies`}),(0,Q.jsx)(`p`,{children:t.localDirectory||`No local directory configured`}),(0,Q.jsxs)(`p`,{children:[t.localCopies,` retained`]}),t.localError&&(0,Q.jsx)(`p`,{role:`alert`,children:`Local directory unavailable.`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:`Ciphertext blobs`}),(0,Q.jsx)(`p`,{children:t.mirror.configured?t.mirror.target:`No mirror configured`}),(0,Q.jsx)(`p`,{children:t.mirror.configured?`${t.mirror.pending} awaiting upload`:`Configure KYNOTES_BLOB_TARGET to protect note and attachment content.`}),t.mirror.last&&(0,Q.jsxs)(`p`,{children:[`Last mirror: `,t.mirror.last.uploaded,` uploaded, `,t.mirror.last.skipped,` already recorded, `,t.mirror.last.failed,` failed (`,t.mirror.last.missing,` missing).`]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:`Schedule`}),(0,Q.jsx)(`p`,{children:t.intervalSeconds?`Every ${t.intervalSeconds/60} minutes`:`Off`}),(0,Q.jsx)(`p`,{children:Dd(t)}),(0,Q.jsxs)(`p`,{children:[`Last attempt: `,t.lastAttempt||`None`,` `,t.lastResult]})]})]}),!t.keyID&&(0,Q.jsx)(`p`,{role:`status`,children:`Pair with KyRecovery or pin the suite public key by hand to enable backups.`}),t.keyID&&!t.paired&&!t.localDirectory&&(0,Q.jsx)(`p`,{role:`status`,children:`The key is pinned, but there is no destination. Pair KyRecovery or configure KYNOTES_BACKUP_DIR.`}),!t.intervalSeconds&&(0,Q.jsx)(`p`,{role:`status`,children:`Automatic backups are off.`}),Ed(t)&&(0,Q.jsxs)(`p`,{role:`alert`,children:[`The database (`,t.databaseBytes.toLocaleString(),` bytes) is past 80% of what one capsule can hold (`,t.capsuleLimitBytes.toLocaleString(),` bytes). New comments and share links are refused if their write would push the database past 90%. Delete unneeded comments, pages or notebooks; revoke unneeded share links (garbage collection reclaims them).`]}),(0,Q.jsxs)(`p`,{children:[t.blobCount,` ciphertext blobs (`,t.blobBytes.toLocaleString(),` bytes) are excluded from capsules.`]})]}),(0,Q.jsxs)(`div`,{className:`backup-actions`,children:[(0,Q.jsx)(`button`,{disabled:r,onClick:()=>void b(Ad),children:`Back up now`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(Md),children:`Download capsule`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r||!t?.mirror.configured,onClick:()=>void b(Pd),children:`Mirror now`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(jd),children:`Run drill`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,onClick:()=>void b(y),children:`Refresh status`})]}),(0,Q.jsx)(`p`,{"aria-live":`polite`,children:r?`Working…`:a}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),b(async()=>{await kd(`schedule`,{interval_seconds:Number(s)*60})})},children:[(0,Q.jsxs)(`label`,{children:[`Backup interval in minutes (0 turns it off; otherwise at least 15)`,(0,Q.jsx)(`input`,{type:`number`,min:`0`,max:`527040`,step:`1`,value:s,onChange:e=>c(e.target.value),required:!0})]}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,children:`Save schedule`})]}),(0,Q.jsx)(`p`,{children:`To preserve backup capacity, the server refuses new comments and share links before the database passes 90% of the capsule limit. Other capsule members still count toward the full limit.`}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{children:`Pair with KyRecovery`}),(0,Q.jsx)(`p`,{children:`Generate a six-digit pairing code in KyRecovery. Compare the suite key fingerprint out of band, or pin it below before pairing. HTTPS protects the incoming key, token and receipt.`}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=d;f(``),b(async()=>{await kd(`pair-remote`,{url:l,pairing_code:t})})},children:[(0,Q.jsxs)(`label`,{children:[`KyRecovery HTTPS URL`,(0,Q.jsx)(`input`,{type:`url`,placeholder:`https://kyrecovery.example.com`,value:l,onChange:e=>u(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Six-digit pairing code`,(0,Q.jsx)(`input`,{inputMode:`numeric`,pattern:`[0-9]{6}`,maxLength:6,value:d,onChange:e=>f(e.target.value),required:!0})]}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,children:`Pair KyRecovery`})]}),(0,Q.jsxs)(`p`,{children:[`Private recovery destinations are `,t?.allowPrivate?`enabled`:`disabled`,`. For a LAN host, configure KYNOTES_BACKUP_ALLOW_PRIVATE_RECOVERY and the documented DNS override.`]}),(0,Q.jsx)(`p`,{children:`Unpair removes this server’s URL and token rows. The key, receipts and local copies remain. A KyRecovery administrator must separately revoke the credential.`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r||!t?.paired,onClick:()=>void b(async()=>{await kd(`unpair`)}),children:`Unpair`})]}),(0,Q.jsxs)(`details`,{children:[(0,Q.jsx)(`summary`,{children:`Pin the suite public key by hand`}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),b(async()=>{await kd(`pin-key`,{public_key:p,threshold:Number(h),total_shares:Number(_)})})},children:[(0,Q.jsxs)(`label`,{children:[`Public key (base64)`,(0,Q.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Required custodian cards`,(0,Q.jsx)(`input`,{type:`number`,min:`2`,max:`255`,value:h,onChange:e=>g(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Total cards`,(0,Q.jsx)(`input`,{type:`number`,min:`2`,max:`255`,value:_,onChange:e=>v(e.target.value),required:!0})]}),(0,Q.jsx)(`p`,{children:`Only paste the public key. Custodian shares are entered locally during restore. A different pinned key is refused.`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:r,children:`Pin public key`})]})]})]})}var cf=e=>e.split(`,`).filter(Boolean).join(` +`),lf=e=>e.split(/[\s,]+/).filter(Boolean).join(`,`);function uf({status:e,text:t,busy:n,message:r,onText:i,onSave:a}){return(0,Q.jsxs)(`section`,{className:`config-card office-networks`,"aria-labelledby":`office-networks-heading`,children:[(0,Q.jsx)(`h2`,{id:`office-networks-heading`,children:`Office networks`}),(0,Q.jsx)(`p`,{className:`admin-note`,children:`Sign-in is limited per network address. Staff in one office usually share one address and can trip that limit together. Networks listed here skip it; per-account limits and lockouts still apply.`}),(0,Q.jsxs)(`form`,{onSubmit:a,children:[(0,Q.jsxs)(`label`,{children:[`Networks that skip the per-address limit, one per line`,(0,Q.jsx)(`textarea`,{rows:4,value:t,onChange:e=>i(e.target.value),placeholder:`203.0.113.0/24`,"aria-describedby":`office-networks-hint`,disabled:!e,spellCheck:!1})]}),(0,Q.jsx)(`p`,{id:`office-networks-hint`,className:`admin-note`,children:`List only networks you control: everyone behind a listed address loses the limit, so never add guest Wi-Fi, a VPN provider or your reverse proxy. The widest range accepted is /16 (IPv4) or /48 (IPv6).`}),(0,Q.jsx)(`button`,{disabled:n||!e,children:n?`Saving…`:`Save networks`})]}),r&&(0,Q.jsx)(`p`,{role:r.error?`alert`:`status`,className:r.error?`error`:`status-line`,children:r.text}),e&&(0,Q.jsxs)(`dl`,{className:`status-list`,children:[e.environment&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Also set by the server configuration`}),(0,Q.jsx)(`dd`,{className:`backup-key`,children:e.environment.split(`,`).join(`, `)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Requests that skipped the limit`}),(0,Q.jsxs)(`dd`,{children:[e.exempted,` since the last change or restart`]})]})]})]})}function df({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(null),l=e=>{n(e),i(cf(e.networks))};(0,X.useEffect)(()=>{Ql().then(l,()=>c({text:`Could not load the networks.`,error:!0}))},[]);async function u(t){t.preventDefault(),o(!0),c(null);try{let t=await rf(e,()=>$l(lf(r)));l(t),c({text:t.networks?`Saved. These networks now skip the per-address limit.`:`Saved. No network you listed skips the limit.`,error:!1})}catch(e){if(e instanceof Error&&e.message===`Password confirmation cancelled`)return;c({text:e instanceof Error?e.message:`Could not save the networks.`,error:!0})}finally{o(!1)}}return(0,Q.jsx)(uf,{status:t,text:r,busy:a,message:s,onText:i,onSave:e=>void u(e)})}var ff={notebook:[[`path`,{d:`M2 6h4`}],[`path`,{d:`M2 10h4`}],[`path`,{d:`M2 14h4`}],[`path`,{d:`M2 18h4`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`path`,{d:`M16 2v20`}]],work:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`}]],team:[[`path`,{d:`M18 21a8 8 0 0 0-16 0`}],[`circle`,{cx:`10`,cy:`8`,r:`5`}],[`path`,{d:`M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3`}]],plus:[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],chevron:[[`path`,{d:`m6 9 6 6 6-6`}]],check:[[`path`,{d:`M20 6 9 17l-5-5`}]],more:[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],settings:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],palette:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],signout:[[`path`,{d:`m16 17 5-5-5-5`}],[`path`,{d:`M21 12H9`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}]],signin:[[`path`,{d:`m10 17 5-5-5-5`}],[`path`,{d:`M15 12H3`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`}]],menu:[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],notes:[[`path`,{d:`M2 6h4`}],[`path`,{d:`M2 10h4`}],[`path`,{d:`M2 14h4`}],[`path`,{d:`M2 18h4`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`}],[`path`,{d:`M9.5 8h5`}],[`path`,{d:`M9.5 12H16`}],[`path`,{d:`M9.5 16H14`}]],users:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`}],[`circle`,{cx:`9`,cy:`7`,r:`4`}]],sso:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]],backups:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`}],[`path`,{d:`M10 12h4`}]],audit:[[`path`,{d:`M15 12h-5`}],[`path`,{d:`M15 8h-5`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`}]],server:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`}]],account:[[`circle`,{cx:`12`,cy:`8`,r:`5`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`}]],close:[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],back:[[`path`,{d:`m15 18-6-6 6-6`}]],search:[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],h1:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`m17 12 3-2v8`}]],h2:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`}]],h3:[[`path`,{d:`M4 12h8`}],[`path`,{d:`M4 18V6`}],[`path`,{d:`M12 18V6`}],[`path`,{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`}],[`path`,{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`}]],bold:[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`}]],italic:[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`}]],bullets:[[`path`,{d:`M3 5h.01`}],[`path`,{d:`M3 12h.01`}],[`path`,{d:`M3 19h.01`}],[`path`,{d:`M8 5h13`}],[`path`,{d:`M8 12h13`}],[`path`,{d:`M8 19h13`}]],numbers:[[`path`,{d:`M11 5h10`}],[`path`,{d:`M11 12h10`}],[`path`,{d:`M11 19h10`}],[`path`,{d:`M4 4h1v5`}],[`path`,{d:`M4 9h2`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`}]],checklist:[[`path`,{d:`M13 5h8`}],[`path`,{d:`M13 12h8`}],[`path`,{d:`M13 19h8`}],[`path`,{d:`m3 17 2 2 4-4`}],[`path`,{d:`m3 7 2 2 4-4`}]],link:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`}]],code:[[`path`,{d:`m18 16 4-4-4-4`}],[`path`,{d:`m6 8-4 4 4 4`}],[`path`,{d:`m14.5 4-5 16`}]],draw:[[`path`,{d:`M13 21h8`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}]]};function pf({name:e}){return(0,Q.jsx)(`svg`,{className:`nav-icon`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:ff[e].map(([e,t],n)=>(0,X.createElement)(e,{key:n,...t}))})}function mf({size:e}){let t=(0,X.useId)().replace(/[^\w-]/g,``);return(0,Q.jsxs)(`svg`,{className:`app-mark`,width:e,height:e,viewBox:`0 0 256 256`,"aria-hidden":`true`,children:[(0,Q.jsx)(`filter`,{id:`${t}f`,children:(0,Q.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .55 .55 .55 0 -.33`})}),(0,Q.jsx)(`mask`,{id:`${t}m`,children:(0,Q.jsx)(`image`,{href:`/app-icon.png`,width:`256`,height:`256`,filter:`url(#${t}f)`})}),(0,Q.jsx)(`rect`,{className:`app-mark-tile`,width:`256`,height:`256`,rx:`44`}),(0,Q.jsx)(`rect`,{className:`app-mark-glyph`,width:`256`,height:`256`,mask:`url(#${t}m)`})]})}var hf=Object.freeze({kypost:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAOkUlEQVR42t1baXBU15X+zr2vW0JSC4QE1sIiAZaQEBJLohiwIWRsbMsQj/GQMDZ2jEg8wTVxPKlUzSRTqfKQSsozybjsGS/xOiwGy2MbEmISgjcoMJZASGDJFiMJyeybNkBrd7975kdv771+vUhIHnse1UL99O59957znXO/e865BP+1pHw5zl+4gMTERDS3tKLgxunZ13p7b9e9ejkzzwF4IjM0pRQzWEghEwEQ4P/JwW/Br74fdhcDRJaHyPQE+b+ytQ/y9x+hbyJAKR4UQlwWQhzVpNyVkpK0q+7I0dNz5pbi6tVrKJs/B5WbNoXeunb9I/ivra9jZv6NSHWlJHV0dq9yu93rdV2fw8wJGOWLwQZJXndnpm6IyK1pssGpOZ4fP35cZVf3lZ72zi7kT8tD9d4PQEvKl2Pf/gPIzMzExAkZ2VeuXN3g8XjWMKuEkHJGYGAUAxEBEVBk7dppGxylW5gF4XQ43nClpPzc7XGfudTeiRXLloJmzP0aNCngdDqzr1699rvBwcEVoQEZxcnD0xDZNI0CX8AnAY5XAIY+OY6xaFJ7Z9zY1PV9ff1nvEpB5uRNQ1JSUlJHR+e/ud3u1eHqIlsbDdyhOAZJBBBHGLhBuEPRfnBEflcS1ifZI00pzvfq3gnj08btkVJ4ZK9Hh8PpuG9gYPCfmVkjopjTI8sLTE9SpAYxpzKyVhUYF5nvMBisuNDr9Z46ee5CrcwvLs7u7en9LbOaSiNh61/wRRQfEoPPM8BgycyTJmXesFu43Z7lSqk5Q5X8qMkqMKM4wcF+2+ch9E8MKMWz+wcHVwi3273CuNRRnCvNUGw13oWEQL738+jDhpkdHo9nuWDm+cbZ8FDtkULkxOgPyIAUIrJ3VGH27PsXz4px3VwBDGYuFbquTzSOLOC1h+SJo46TgtqNOaYgvEYbAT670XU1QTCzNNsUx28LZP8gm+bBIb7HXxrX6V94WdMiOZbwexz82BP/ONFnR/2tL7RA0LS3MBArMiM62FQIgVgrWmArosUzaKUUXCkpmJ43Felp4yCEsLcTDo0sNGg2Pxs3DMjCIjnEeIx9GNijUgodXd1o/fwUrvX0xCEEii0ApRRKZhXi0YfXYl7pbCQmJvjsmaIZ8hAYNI/AHohDm6qBgQHU1Tfi6d+9jPrPjkcRAkGQAGXnFzJH0IpSClMn5+DpJzagdFYhdF0HR2VjbCMECrOSiOiIy6lGty0ighQCRxsa8djPH8fJ02d8iLW5HA4NInqfjDtuXYriwgJ4vV6f/Vs+QZfANrsR/984YKTBNhyCsfH3YDcGdmPzTtuPYcxeXcfsogLcumRRTLlFFYDDoeHGabmQMddFjkWbYquU7TweD2EhtkxMCEyflgcpRNQXipioYkSE0Iizk+FQzAhCkkL4Vq2hIoAsPuDNnbtQVVMHIuvSQqNA1XiYe0LDNyEAEA5U12DHO7tjtpau9AmPR+v69NlzOFBdA6+uY3ruVCQnJYG/PIzGPBkp0d7RiZdfq8Rvn3kRLa1tQaXZMVwpJSinoIhZ+Tl4BM+qmKFpErcs+AbWVzyAuSXF/sAkj8IufuiXEAK6rlB1pA7Pv7oZh47UQSkGEQUJT3ggleFwOCBd6RmP21sKG6ItPtG1nTyF/VWHoXSFGXm5GDMm8f8IDRSkc1JKXGrvwEtbXse/P/MimlpaDVon3+9sz1uklFFMwO/8lixaAADo6u6GEALXentx6EgdjjefwKScLGTeMBGjE0ih2FpXCgeqDmPDb57Gzj/vQX9/v2/nqXwKmlVUgNNnzvmZvyUOzX4BpNgKgIOwefihNfje6nvR3tmNU2fOgpUCsw8NH1UdBjNjRl4ukr4oNPi1fvFyO17YuBVPPvsSWlrbIASBmeF0OrDsW0vwL//0EyQkOLH3wMcR5RkdAf7rmzcvwLKli7HoG1+DKyUJLa0n0dPb60NDTy+qamrRfKINk3OykTlxAkYzrBbQ+v6Pq7HhN0/jnb+8h4GBAQhB0HWF7KxM/P33v4dH/64CU3KycbThM+z7qCqq09QiuSQKRE7gY1aprhT84MH7UFpchGde2ohDtcfAzNB1hXf37kdjUwsq1nwXK1fciVRXCpSuRtzDX7h0GZvfeBv/veOP6OjsCpIcIoHFC8vwo4cfwrySYgCArlTs1ZY50mYo3GkE4L3g6/MwLXcqNr3+Fiq370T3lSuQUuLs+Qv416eeQ3VNHdavexCzCwvM8YXhIl4I6LqO/R9V4blXNqP2WD2YGVIKKF0hffx43P+de7Bm1T1IH58GZZw4+94fhkoikH/nqg2Vm+i6woSMdPzD+nWYV1qMZ1/ehE8+bYQgglf3Ys+H+9DY1IyKNauxcvkdcKUkQx8mGgJa3/LGdlRu34nO7u4QtWVg/pwS/OjhtVhYNh9CCPPkAym3SCbpD75qUXlwhLasFIQQ+KvFN6NgxjS88tob2PHObvT09EIKiTPnzuOJp57F4dqj+OHaB1A0Mz+0CYovjQWlFPYdrMbzr25GTd0nPq37Jzk21YVVdy/HQ/etQnbmDdCVsu2bTJFK+3drPIxVKLBCKKVjUnYWfvbYI/j63BI8/+praGxqBpGAx+PFn979EA2NTfj+A3+Lu8tvQ0pycpiW7LR+qb0DWyrfwuvbd6KzswtCyqA5lc4qxPp1D+Kbi26Cw+GArusRhcimdIi9ELThMDbrfkHTNJTf9i0U5s/Ay1sq8cfd76G3rw9CCJw6ew6/evI/UH2kDj9cez+KCvINoTUbD191CM+9sgU1tUehmCGkhK7rGJvqwr0ryvHQfaswKTsLyh8BiqokMro0DgasjNPSRmp7opRC3tQp+MVPH0XZvDl4YeNWNJ1ohSCCx+PFrj3vo6Hxf1Cx5rv46/JlcLlcPgflt9NL7R3Y+ubvsfXNHWjv6ISUIqj1kuJCPFLxIJbevAAOhyMmioJaZ/s4oAkBBICJroPbm4XgdDpxd/kyzC6aiRc3bcOud99HX18/hBA4efoMfv3kf+JgdQ2+fedtyJs6BUopHG9uwVs7/4zDtUehlA4pJZSukJqagnuW34mK+7+DyTnZ0JWKa/LhOI2caNCiByppWOE6pRSm5U7B4//4GMrmz8GLG7eiubUNQvh8w18+2It9B6uQkpwMBnD16jW43W5IKX26U4zZs2ZifcUDWHrLQjij2HoU/YcC836HTjbhOc1qM1ZZDBcVSikkJCRg5fI7UDJrJl7YuA273/sQff39kELC7fagY7ArFMeTEkrX4Up14Z67bse6NasxOQ5bj2S4xJaUaSDUZhGUFisfcF3hDb+zm5GXiw0/+wnK5pXipc3bcKLtZNDxsX+CRIRZRT6t37p4kc/DKzUiY4hMzzmWE+TrCFmHwKaUQmJCAlbdfRdKi4uw9c0d+PhwLTo6O0EkMDEjHUtvWYjVK7+NyTlZUGo4WrfbzsW+tJENT0VuH0BD/vRc/OKnP8bFy5dxub0DQkpMzEjHxIx0WzY3eiFIXwxS41gaHGGzUIohBCE78wbkZGWahDOSkw/WMMRISWuR6pnYsCmiUVEAj2r8gI31BlEeEra7xBGo38GXIwkcvUiDAEHWLTBZlpMvIF0/WpU2UZdx/wPi/4Oio/lga2Ka7EyAKEAeLPV8X2GpcIRSP4Y5ZScsVSPhXOkLSYuNlv2HezWyS40FErtks22grzAEdF33+wCKwE7IsgoEKr4oEP7ScaLtJJT66rlBXdfRfKItOrcga3KUzSAhInyw/yMcb27x7dS+IpWkmibxyWfHse9gVSizTeEO0DY5SmT0oITuK1dwou1zTMv11QdpUgaLkIb6ARHEMNpFag///4F7AODxeHHkWD2eeOpZNLe0mnyYlRhJIUFZN87kWIEwZsaEjHSUFhdiUlYWpBTh3MBgaxxmaWTKNtmdE+E4A3NkfpWpYsyr6zh7/iKO1n+Kjs6uqEkaZobDoYULINr+PjKpGMWqTgwvgxQzQ+XPLWiB+p1YDSJViZhrJf0FiMxDkwWFFXGOvnz98UEhBAWBG6n+n6LE7wOOkYdRaUymOmMyVHDGcRAjjnvRy34JggQLqclrVvGy3XkRslSyk22ddyj1RNb2FMYuTRWeoXIyGGtRI1bOk6Ug27ac3xgGpvCwGVGXIEZ9rHp2NlFLc97NXlz2GxMiAhOHH3Rgm/4DPVOIn5jgaXmluYCXDA7ZDgm+xlKT9cLpdP6JhFAR5cSGMz9sZtjBJdMvDHMk1kCujNzCqisiExwild1zsC8zZQnowLg0MrFhPIEhhnkWnYh2CafT8TYRNUUKhBEogoFZlie/kDiYkfUPyqYGnii6lZM5pOOboKWInaIcXyG2CXCwGQBSikanw7FdXj53tn1CTs4YXddvpdArjWU44RkWu7WabBykJToTScSBE2Nkl9YyQjlo+wRT9ZOhf7bueW30R0LoTofz1y3HanfL4rKbkDwm8figx1OkdFXANui0nhAzdmr05EFHaVMcTmQFNkzEKewkGtlvxkL9cOxi8wjnGZxOx1vp6Wm/zMjKHpTK4YRi7k9OTq7VdX2uUmpKsAO2kaLdqToOw26Y5MjAszmoL7KtyzDTcdv665hLdBBZJjsgOJ3O98e6XD/u6xu42NPXB7F44U1oa/gE5y9eahozJrHC4XT8QRAp4+SJDbbBdgeGyFLlysalxhCdZcOSh1DRtMERssHBBZpQxJNq0c7MsVk3JLwOTasc63L9oKOru62prgZLFpRBNtbX4/6KdTi09wMkj8/oTE9L26Mr1cGMKQDSgkETvyrY5qRMtOAuUezTKKMVCyUikCCvQ3M0JCQ4fznW5frVwODgxc8bjuGulX+Dt7dtDU2jfOVKHPv0ONLGjUVD9ccoWbCooH9g4F6P23M7MxcxOA0MaefkYk+cbLM2VjMI3bcpaWDDO8OQaDr1xrquD0ohuoWUDVKIXSnJyX84enB/W3HZTbh6rQfzSkvw+8ptAID/BQ3LmloepqnmAAAAAElFTkSuQmCC`,kycalendar:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22320%22%20y%3D%22345%22%20width%3D%22614%22%20height%3D%22565%22%20rx%3D%2270%22%20fill%3D%22%23f2efe8%22%2F%3E%3Crect%20x%3D%22320%22%20y%3D%22475%22%20width%3D%22614%22%20height%3D%2234%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22425%22%20y%3D%22275%22%20width%3D%2284%22%20height%3D%22150%22%20rx%3D%2242%22%20fill%3D%22%23f2efe8%22%20stroke%3D%22%23182326%22%20stroke-width%3D%2234%22%2F%3E%3Crect%20x%3D%22745%22%20y%3D%22275%22%20width%3D%2284%22%20height%3D%22150%22%20rx%3D%2242%22%20fill%3D%22%23f2efe8%22%20stroke%3D%22%23182326%22%20stroke-width%3D%2234%22%2F%3E%3Crect%20x%3D%22395%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22567%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22739%22%20y%3D%22570%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23e2562a%22%2F%3E%3Crect%20x%3D%22395%22%20y%3D%22730%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3Crect%20x%3D%22567%22%20y%3D%22730%22%20width%3D%22120%22%20height%3D%22105%22%20rx%3D%2218%22%20fill%3D%22%23182326%22%2F%3E%3C%2Fsvg%3E`,kydrive:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20d%3D%22M300%20395%20a55%2055%200%200%201%2055%20-55%20h185%20a55%2055%200%200%201%2045%2024%20l45%2066%20h260%20a55%2055%200%200%201%2055%2055%20v365%20a55%2055%200%200%201%20-55%2055%20h-535%20a55%2055%200%200%201%20-55%20-55%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Crect%20x%3D%22300%22%20y%3D%22500%22%20width%3D%22654%22%20height%3D%2234%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20d%3D%22M627%20585%20l135%20140%20h-80%20v120%20h-110%20v-120%20h-80%20z%22%20fill%3D%22%23e2562a%22%20stroke%3D%22%23e2562a%22%20stroke-width%3D%2224%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E`,kynotes:`data:image/png;base64,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`,kymessage:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20transform%3D%22translate(0%2025)%22%20d%3D%22M370%20300%20h514%20a90%2090%200%200%201%2090%2090%20v300%20a90%2090%200%200%201%20-90%2090%20h-330%20l-170%20140%20v-140%20h-14%20a90%2090%200%200%201%20-90%20-90%20v-300%20a90%2090%200%200%201%2090%20-90%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Ccircle%20cx%3D%22467%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22627%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22787%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,"kymessage-chat":`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpath%20transform%3D%22translate(0%2025)%22%20d%3D%22M370%20300%20h514%20a90%2090%200%200%201%2090%2090%20v300%20a90%2090%200%200%201%20-90%2090%20h-330%20l-170%20140%20v-140%20h-14%20a90%2090%200%200%201%20-90%20-90%20v-300%20a90%2090%200%200%201%2090%20-90%20z%22%20fill%3D%22%23f2efe8%22%2F%3E%3Ccircle%20cx%3D%22467%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22627%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23182326%22%2F%3E%3Ccircle%20cx%3D%22787%22%20cy%3D%22565%22%20r%3D%2262%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,kyidentity:`data:image/png;base64,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`,kydns:`data:image/png;base64,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`,kypulse:`data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%22163%20162%20927%20928%22%3E%3Crect%20x%3D%22163%22%20y%3D%22162%22%20width%3D%22927%22%20height%3D%22928%22%20rx%3D%22155%22%20fill%3D%22%23182326%22%2F%3E%3Cpolyline%20points%3D%22280%2C650%20430%2C650%20515%2C440%20640%2C840%20745%2C560%20800%2C650%20850%2C650%22%20fill%3D%22none%22%20stroke%3D%22%23f2efe8%22%20stroke-width%3D%22104%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Ccircle%20cx%3D%22930%22%20cy%3D%22650%22%20r%3D%2278%22%20fill%3D%22%23e2562a%22%2F%3E%3C%2Fsvg%3E`,kyrecovery:`data:image/png;base64,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`,kyyard:`data:image/png;base64,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`});function gf(e){if(Object.hasOwn(hf,e))return hf[e];let t=/^(?:ky)?([a-z0-9])/i.exec(String(e))?.[1].toUpperCase()??`?`;return`data:image/svg+xml,${encodeURIComponent(`${t}`)}`}function _f(e){let t=e.ownerDocument,n=t.getElementById(e.getAttribute(`aria-controls`));if(!n)return()=>{};let r=()=>[...n.querySelectorAll(`[role="menuitem"]`)],i=()=>e.getAttribute(`aria-expanded`)===`true`;for(let e of r())e.tabIndex=-1;e.setAttribute(`aria-expanded`,`false`),n.hidden=!0;let a=t=>{e.setAttribute(`aria-expanded`,`true`),n.hidden=!1,r().at(t)?.focus()},o=t=>{i()&&(e.setAttribute(`aria-expanded`,`false`),n.hidden=!0,t&&e.focus())},s=(e,t)=>{let n=r();n[(n.indexOf(e)+t+n.length)%n.length]?.focus()},c=()=>i()?o(!1):a(0),l=e=>{e.key===`Escape`&&o(!0),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),a(e.key===`ArrowDown`?0:-1))},u=e=>{let t=e.target.closest(`[role="menuitem"]`),n=r();if(e.key===`ArrowDown`)s(t,1);else if(e.key===`ArrowUp`)s(t,-1);else if(e.key===`Home`)n[0]?.focus();else if(e.key===`End`)n.at(-1)?.focus();else if(e.key===`Escape`)o(!0);else if(e.key===` `)t?.click();else if(e.key===`Tab`){o(!1);return}else if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let r=e.key.toLowerCase(),i=n.indexOf(t);[...n.slice(i+1),...n.slice(0,i+1)].find(e=>e.textContent.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()},d=e=>{e.target.closest(`[role="menuitem"]`)&&o(!0)},f=t=>{i()&&!e.contains(t.target)&&!n.contains(t.target)&&o(!1)},p=t=>{let r=t.relatedTarget;r&&!e.contains(r)&&!n.contains(r)&&o(!1)};return e.addEventListener(`click`,c),e.addEventListener(`keydown`,l),n.addEventListener(`keydown`,u),n.addEventListener(`click`,d),n.addEventListener(`focusout`,p),t.addEventListener(`pointerdown`,f),()=>{e.removeEventListener(`click`,c),e.removeEventListener(`keydown`,l),n.removeEventListener(`keydown`,u),n.removeEventListener(`click`,d),n.removeEventListener(`focusout`,p),t.removeEventListener(`pointerdown`,f)}}var vf=`MIT License + +Copyright (c) 2026 Busnes.app + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +`;function yf({version:e,onClose:t}){let n=new Date().getFullYear();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`ky-about-head`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h2`,{className:`ky-about-name`,children:[`KyNotes `,e?(0,Q.jsxs)(`span`,{className:`ky-about-version`,children:[`v`,e]}):null]}),(0,Q.jsx)(`p`,{className:`ky-about-meta`,children:`Developed by Busnes.app`}),(0,Q.jsxs)(`p`,{className:`ky-about-meta`,children:[`© `,n,` · Licensed under the MIT License`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`ky-about-close`,onClick:t,children:`Close`})]}),(0,Q.jsx)(`textarea`,{className:`ky-about-license`,readOnly:!0,value:vf,"aria-label":`MIT License`})]})}function bf({signedIn:e,className:t=`app-footer`,children:n}){let[r,i]=(0,X.useState)(``),a=(0,X.useRef)(null),[o,s]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!o||!e)return;let t=!1;return eu().then(e=>{t||i(e.version??``)}).catch(()=>void 0),()=>{t=!0}},[o,e]),(0,Q.jsxs)(`footer`,{className:t,children:[n,(0,Q.jsxs)(`button`,{type:`button`,className:`ky-license-link`,onClick:()=>{a.current?.showModal(),s(!0)},children:[`© `,new Date().getFullYear(),` · MIT License`]}),(0,Q.jsx)(`dialog`,{ref:a,className:`ky-about`,"aria-label":`About KyNotes`,onClose:()=>s(!1),onClick:e=>{e.target===a.current&&a.current.close()},children:(0,Q.jsx)(yf,{version:e?r:``,onClose:()=>a.current?.close()})})]})}function xf({name:e,role:t,actions:n}){return(0,Q.jsxs)(`div`,{className:`ky-user`,children:[(0,Q.jsxs)(`div`,{className:`ky-user-copy`,children:[(0,Q.jsx)(`p`,{className:`ky-user-name`,children:e}),(0,Q.jsx)(`p`,{className:`ky-user-role`,children:t})]}),(0,Q.jsx)(`div`,{className:`ky-user-actions`,children:n})]})}var Sf=`(max-width: 720px)`,Cf=e=>{let t=matchMedia(Sf);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)};function wf(){return(0,X.useSyncExternalStore)(Cf,()=>matchMedia(Sf).matches)}function Tf({icon:e,label:t,current:n,href:r,disabled:i,expanded:a,controls:o,onClick:s}){let c=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pf,{name:e}),(0,Q.jsx)(`span`,{children:t})]});return r?(0,Q.jsx)(`a`,{className:`ky-nav-item`,href:r,"aria-current":n?`page`:void 0,onClick:s,children:c}):(0,Q.jsx)(`button`,{type:`button`,className:`ky-nav-item`,"aria-current":n?`page`:void 0,"aria-expanded":a,"aria-controls":o,disabled:i,onClick:s,children:c})}function Ef({apps:e}){return e.length?(0,Q.jsxs)(`nav`,{className:`ky-app-rail`,"aria-label":`Apps`,children:[(0,Q.jsx)(`p`,{className:`ky-app-rail-label`,"aria-hidden":`true`,children:`Apps`}),(0,Q.jsx)(`ul`,{children:e.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`a`,{href:e.url,title:e.name,"aria-label":e.name,"aria-current":e.id===`kynotes`?`page`:void 0,children:(0,Q.jsx)(`img`,{src:gf(e.id),width:24,height:24,alt:``})})},e.id))})]}):null}function Df({id:e,items:t,current:n}){let r=(0,X.useRef)(null);return(0,X.useEffect)(()=>_f(r.current),[]),(0,Q.jsxs)(`div`,{className:`ky-menu`,children:[(0,Q.jsx)(`button`,{ref:r,type:`button`,className:`ky-icon-button`,"aria-label":`Settings`,title:`Settings`,"aria-haspopup":`menu`,"aria-expanded":`false`,"aria-controls":e,"aria-current":n?`page`:void 0,children:(0,Q.jsx)(pf,{name:`settings`})}),(0,Q.jsx)(`div`,{className:`ky-menu-list`,id:e,role:`menu`,"aria-label":`Settings`,hidden:!0,children:t.map(e=>(0,Q.jsx)(`a`,{role:`menuitem`,tabIndex:-1,href:e.href,"aria-current":e.current?`page`:void 0,children:e.label},e.href))})]})}function Of({label:e,nav:t,tree:n,user:r,settings:i,onSignOut:a,className:o=``,children:s}){let[c,l]=(0,X.useState)([]);(0,X.useEffect)(()=>{let e=!0;return tu().then(t=>{e&&l(t.apps)}).catch(()=>void 0),()=>{e=!1}},[]);let u=(0,Q.jsx)(Ef,{apps:c}),d=e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Df,{id:e,items:i.items,current:i.current}),(0,Q.jsx)(`button`,{type:`button`,className:`ky-icon-button`,"aria-label":`Sign out`,title:`Sign out`,onClick:a,children:(0,Q.jsx)(pf,{name:`signout`})})]});return(0,Q.jsxs)(`div`,{className:`ky-app ${o}`,children:[(0,Q.jsxs)(`header`,{className:`ky-sidebar`,children:[(0,Q.jsxs)(`div`,{className:`ky-mobile-head`,children:[(0,Q.jsxs)(`div`,{className:`ky-brand`,children:[(0,Q.jsx)(mf,{size:28}),(0,Q.jsx)(`span`,{children:`KyNotes`})]}),(0,Q.jsx)(`div`,{className:`ky-mobile-actions`,children:d(`settings-menu-header`)})]}),(0,Q.jsx)(`nav`,{className:`ky-nav`,"aria-label":e,children:t}),n,(0,Q.jsxs)(`div`,{className:`ky-sidebar-foot`,children:[u,(0,Q.jsx)(xf,{name:r.name,role:r.role,actions:d(`settings-menu-footer`)}),(0,Q.jsx)(bf,{signedIn:!0})]})]}),(0,Q.jsxs)(`main`,{className:`ky-content`,children:[s,(0,Q.jsx)(bf,{signedIn:!0,className:`ky-content-foot`,children:u})]})]})}var kf=Object.freeze({id:`system`,name:`Match system`,scheme:`system`,aliases:Object.freeze([])}),Af=(e,t,n,r,i=[])=>Object.freeze({id:e,name:t,scheme:n,pair:r,aliases:Object.freeze(i)}),jf=Object.freeze([Af(`busnes-light`,`Busnes Light`,`light`,`busnes-pair`),Af(`busnes-dark`,`Busnes Dark`,`dark`,`busnes-pair`),Af(`light-matter`,`Matter Light`,`light`,`matter-pair`,[`Light Matter`]),Af(`dark-matter`,`Matter Dark`,`dark`,`matter-pair`,[`Dark Matter`,`Current`]),Af(`white-cliffs`,`Ocean Light`,`light`,`ocean-pair`,[`White Cliffs`,`Cliffs`]),Af(`ocean`,`Ocean Dark`,`dark`,`ocean-pair`,[`Ocean`]),Af(`forest-light`,`Forest Light`,`light`,`forest-pair`),Af(`forest`,`Forest Dark`,`dark`,`forest-pair`,[`Forest`]),Af(`polished-ky`,`Ky Light`,`light`,`ky-pair`,[`Polished Ky`]),Af(`patina-ky`,`Ky Dark`,`dark`,`ky-pair`,[`Patina Ky`,`patina`,`Patina Ky (base)`]),Af(`paper`,`Nord Light`,`light`,`nord-pair`,[`Paper Clean`]),Af(`nord`,`Nord Dark`,`dark`,`nord-pair`,[`Nord`,`Nord Slate`])]),Mf=(e,t,n,r)=>Object.freeze({id:e,name:t,light:n,dark:r}),Nf=Object.freeze([Mf(`busnes-pair`,`Busnes`,`busnes-light`,`busnes-dark`),Mf(`matter-pair`,`Matter`,`light-matter`,`dark-matter`),Mf(`ocean-pair`,`Ocean`,`white-cliffs`,`ocean`),Mf(`forest-pair`,`Forest`,`forest-light`,`forest`),Mf(`ky-pair`,`Ky`,`polished-ky`,`patina-ky`),Mf(`nord-pair`,`Nord`,`paper`,`nord`)]),Pf=(e,t,n,r,i,a,o,s,c,l,u,d=`color-mix(in srgb, ${t} 93%, ${r})`,f=`color-mix(in srgb, ${o} 60%, ${r})`,p,m)=>Object.freeze({bg:e,panel:t,ink:n,inkStrong:r,accent:i,accentSoft:a,line:o,glow:s,sidebarStart:c,sidebarEnd:l,buttonText:u,panelHover:d,lineStrong:f,inkMuted:`color-mix(in srgb, ${n} 90%, ${t})`,...p&&{danger:p},...m&&{success:m}}),Ff=Object.freeze({"light-matter":Pf(`#f5efe5`,`#fff8ee`,`#4c3d32`,`#2d1f15`,`#805a39`,`#e2d0b8`,`#d4c7b5`,`transparent`,`#ede2d2`,`#ede2d2`,`#ffffff`),"dark-matter":Pf(`#1d1b19`,`#292725`,`#cfc6bb`,`#f0e9df`,`#c29a72`,`#49392c`,`#45403a`,`transparent`,`#25221f`,`#25221f`,`#24170f`),"white-cliffs":Pf(`#f7f9fb`,`#ffffff`,`#2e4c63`,`#163246`,`#1d5fa6`,`#dde9f7`,`#c7d6df`,`transparent`,`#eaf1f8`,`#eaf1f8`,`#ffffff`),ocean:Pf(`#0f1b24`,`#152a36`,`#b8d8e8`,`#e0f2fb`,`#6aa8e8`,`#1f3a55`,`#2f5567`,`rgba(58, 130, 155, 0.24)`,`#112430`,`#173342`,`#0a1b22`),"forest-light":Pf(`#f3f6ef`,`#fcfdf9`,`#435342`,`#203322`,`#4b6b37`,`#e2ebda`,`#c5d0bc`,`transparent`,`#e8eee1`,`#e8eee1`,`#ffffff`,void 0,void 0,void 0,`#00737a`),forest:Pf(`#142018`,`#1f2f24`,`#c7dbc7`,`#e3f0df`,`#8faa74`,`#3a5837`,`#4f694f`,`rgba(118, 148, 95, 0.24)`,`#18261c`,`#223629`,`#12200f`,void 0,void 0,void 0,`#6ee0d0`),"polished-ky":Pf(`#eef2f6`,`#ffffff`,`#475569`,`#0f172a`,`#08758b`,`#daf2f4`,`#c2cdd8`,`transparent`,`#e7edf3`,`#e7edf3`,`#ffffff`),"patina-ky":Pf(`#10161e`,`#1b2530`,`#afbdca`,`#e2e8f0`,`#6fc9cc`,`#203d41`,`#34414d`,`transparent`,`#161e27`,`#161e27`,`#10161e`),paper:Pf(`#eceff4`,`#ffffff`,`#4c566a`,`#2e3440`,`#4a6a94`,`#dbe4ef`,`#c5cdd9`,`transparent`,`#e5e9f0`,`#e5e9f0`,`#ffffff`),nord:Pf(`#2e3440`,`#3b4252`,`#d8dee9`,`#eceff4`,`#88c0d0`,`rgba(136, 192, 208, 0.2)`,`#4c566a`,`transparent`,`#3b4252`,`#3b4252`,`#0d0f14`,`#434c5e`,`#5e81ac`,`#ecc4c8`,`#bcd4aa`)}),If=Object.freeze(Object.fromEntries([...Object.keys(Ff.nord),`warning`].map(e=>[e,`--`+e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase())]))),Lf=()=>globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1;function Rf(e){return Nf.find(t=>t.id===e)}function $(e,t=Lf()){if(e===kf.id)return kf;let n=Rf(e);return n&&(e=t?n.dark:n.light),jf.find(t=>t.id===e||t.name===e||t.aliases.includes(e))}function zf(e,t=globalThis.document?.documentElement){let n=$(e),r=Ff[n?.id];for(let e of Object.values(If))t.style.removeProperty(e);if(t.style.colorScheme=``,!r)return null;for(let[e,n]of Object.entries(If))r[e]&&t.style.setProperty(n,r[e]);return t.style.setProperty(`--danger`,r.danger??`var(--ky-danger-${n.scheme})`),t.style.setProperty(`--success`,r.success??`var(--ky-success-${n.scheme})`),t.style.setProperty(`--warning`,`var(--ky-warning-${n.scheme})`),t.style.colorScheme=n.scheme,n.scheme}Object.freeze([`system`,`busnes-light`,`busnes-dark`]);function Bf(e){try{return globalThis.localStorage.getItem(e)}catch{return null}}function Vf(e,t){try{globalThis.localStorage.setItem(e,t)}catch{}}function Hf(e,t){let n=globalThis.window??globalThis,r=n=>{(n.key===e||n.key===null)&&t()},i=n.matchMedia?.(`(prefers-color-scheme: dark)`),a=()=>t();return n.addEventListener?.(`storage`,r),i?.addEventListener(`change`,a),()=>{n.removeEventListener?.(`storage`,r),i?.removeEventListener(`change`,a)}}var Uf=`kynotes-theme`,Wf=Nf.map(e=>({pair:e,choices:[{mode:`system`,label:`Match system`,value:e.id===`busnes-pair`?kf.id:e.id},{mode:`light`,label:`Light`,value:e.light},{mode:`dark`,label:`Dark`,value:e.dark}]})),Gf=()=>window.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1;function Kf(){let e=Bf(Uf);return Rf(e)?.id??$(e)?.id??kf.id}function qf(e,t=!1){let n=$(e,Gf());if(!n)return;let r=document.documentElement;if(zf(e,r))delete r.dataset.theme;else{let e=n.id===`system`?Gf()?`busnes-dark`:`busnes-light`:n.id;r.dataset.theme=e,r.style.colorScheme=e===`busnes-dark`?`dark`:`light`}t&&Vf(Uf,Rf(e)?.id??n.id)}function Jf(){qf(Kf())}typeof window<`u`&&Hf(Uf,Jf);function Yf(){let[e,t]=(0,X.useState)(Kf);return(0,X.useEffect)(()=>{let e=()=>t(Kf());return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,e=>{t(e),qf(e,!0)}]}function Xf(){let[e,t]=Yf();return(0,Q.jsxs)(`section`,{className:`appearance-section`,"aria-labelledby":`appearance-heading`,children:[(0,Q.jsx)(`h2`,{id:`appearance-heading`,className:`visually-hidden`,children:`Appearance`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Pick a palette and how it handles light and dark. Match system switches with your device’s setting; Light or Dark keeps one. Your choice applies straight away and is saved in this browser only.`}),(0,Q.jsxs)(`fieldset`,{className:`ky-appearance`,children:[(0,Q.jsx)(`legend`,{className:`ky-appearance-legend`,children:`Theme`}),(0,Q.jsx)(`div`,{className:`ky-appearance-grid appearance-pairs`,children:Wf.map(({pair:n,choices:r})=>(0,Q.jsxs)(`div`,{role:`group`,"aria-labelledby":`${n.id}-name`,className:`appearance-pair`,children:[(0,Q.jsxs)(`div`,{className:`appearance-pair-head`,children:[(0,Q.jsx)(`h2`,{id:`${n.id}-name`,className:`appearance-pair-name`,children:n.name}),(0,Q.jsxs)(`span`,{className:`appearance-pair-halves`,children:[$(n.light)?.name,` · `,$(n.dark)?.name]})]}),(0,Q.jsx)(`span`,{className:`ky-appearance-preview`,"data-ky-preview":n.id,"aria-hidden":`true`}),(0,Q.jsx)(`div`,{className:`appearance-modes`,children:r.map(({mode:n,label:r,value:i})=>(0,Q.jsxs)(`label`,{className:`appearance-mode`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`kynotes-theme`,value:i,checked:e===i,onChange:()=>t(i)}),e===i&&(0,Q.jsx)(pf,{name:`check`}),(0,Q.jsx)(`span`,{children:r})]},n))})]},n.id))})]})]})}function Zf(){let[e,t]=Yf();return(0,Q.jsx)(`select`,{"aria-label":`Color theme`,value:e,onChange:e=>t(e.target.value),children:Wf.map(({pair:e,choices:t})=>(0,Q.jsx)(`optgroup`,{label:e.name,children:t.map(({mode:t,label:n,value:r})=>(0,Q.jsxs)(`option`,{value:r,children:[e.name,` · `,n]},t))},e.id))})}function Qf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var $f=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ep=e=>typeof e==`string`,tp=e=>ep(e)&&e.length>0&&e.length<=128;function np(e){return Qf(e)&&tp(e.id)&&ep(e.status)&&ep(e.homeRegion)&&typeof e.enabled==`boolean`&&$f(e.revision)&&ep(e.lastPoll)&&$f(e.notesUsedBytes)&&$f(e.poolBytes)&&$f(e.orgUsedBytes)&&$f(e.ceilingBytes)&&ep(e.grantExpiresAt)}function rp(e){return Qf(e)&&tp(e.id)&&ep(e.username)&&ep(e.role)&&(e.accountKind===`user`||e.accountKind===`admin`)&&ep(e.status)&&$f(e.quotaBytes)&&ep(e.createdAt)&&$f(e.usedBytes)}async function ip(){let e=await Z(`/api/v1/admin/orgs`);if(!Array.isArray(e)||!e.every(np))throw Error(`Organization metadata could not be read. Refresh to try again.`);return e}async function ap(e){let t=await Z(`/api/v1/admin/users?org=${encodeURIComponent(e)}`);if(!Array.isArray(t)||!t.every(rp))throw Error(`Account metadata could not be read. Refresh to try again.`);return t}async function op(e){let t=await Z(`/api/v1/admin/audit${e?`?org=${encodeURIComponent(e)}`:``}`);if(!Array.isArray(t)||!t.every(e=>Qf(e)&&Object.values(e).every(ep)))throw Error(`Audit metadata could not be read. Refresh to try again.`);return t}var sp=[[`orgs`,`Organizations`,`team`,`Organization status and shared storage-pool metadata.`],[`users`,`Users`,`users`,`Select an organization to inspect its accounts. KyIdentity manages customer accounts.`],[`sso`,`Single sign-on`,`sso`,`Shared sign-in configuration is managed by the deployment.`],[`backups`,`Backups`,`backups`,`Platform recovery configuration and scheduled backups.`],[`audit`,`Audit log`,`audit`,`Platform events or one organization's metadata-only audit history.`],[`server`,`Server`,`server`,`Health, readiness and platform office-network settings.`]],cp=e=>`${e.toLocaleString()} B`,lp=e=>e instanceof Error?e.message:`Metadata could not be read. Refresh to try again.`;function up({username:e,sso:t,onLogout:n,password:r}){let i=[...t?[]:[[`account`,`Account`]],[`appearance`,`Appearance`]],a=()=>[...sp,...i].find(([e])=>location.hash===`#${e}`)?.[0]??`orgs`,[o,s]=(0,X.useState)(a),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)({kind:`loading`}),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)({scope:``,state:{kind:`loading`}}),[v,y]=(0,X.useState)({scope:``,state:{kind:`loading`}}),[b,x]=(0,X.useState)({kind:`loading`}),[S,C]=(0,X.useState)(null);(0,X.useEffect)(()=>{window.scrollTo(0,0);let e=()=>s(a());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,X.useEffect)(()=>{let e=!0;return d({kind:`loading`}),ip().then(t=>{e&&(d({kind:`ready`,value:t}),p(e=>t.some(t=>t.id===e)?e:``))}).catch(t=>{e&&d({kind:`failed`,message:lp(t)})}),Yl().then(t=>{e&&x({kind:`ready`,value:t})}).catch(t=>{e&&x({kind:`failed`,message:lp(t)})}),su().then(t=>{e&&C(t)}).catch(()=>{e&&C(null)}),()=>{e=!1}},[c]),(0,X.useEffect)(()=>{let e=!0;if(o===`users`){if(_({scope:f,state:{kind:`loading`}}),!f)_({scope:f,state:{kind:`ready`,value:[]}});else return ap(f).then(t=>{e&&_({scope:f,state:{kind:`ready`,value:t}})}).catch(t=>{e&&_({scope:f,state:{kind:`failed`,message:lp(t)}})}),()=>{e=!1}}},[f,c,o]),(0,X.useEffect)(()=>{let e=!0;if(o===`audit`)return y({scope:m,state:{kind:`loading`}}),op(m).then(t=>{e&&y({scope:m,state:{kind:`ready`,value:t}})}).catch(t=>{e&&y({scope:m,state:{kind:`failed`,message:lp(t)}})}),()=>{e=!1}},[m,c,o]);let w=e=>{p(e),location.hash=`users`,s(`users`)},T=u.kind===`ready`?u.value:[];return(0,Q.jsxs)(Of,{className:`admin-shell`,label:`Administration sections`,onSignOut:n,user:{name:e,role:`Staff administrator`},settings:{items:i.map(([e,t])=>({href:`#${e}`,label:t,current:o===e})),current:i.some(([e])=>e===o)},nav:(0,Q.jsx)(Q.Fragment,{children:sp.map(([e,t,n])=>(0,Q.jsx)(Tf,{icon:n,label:t,href:`#${e}`,current:o===e},e))}),children:[(0,Q.jsxs)(`section`,{className:`page-view admin-view`,hidden:!i.some(([e])=>e===o),"aria-labelledby":`staff-settings-heading`,children:[(0,Q.jsx)(`header`,{className:`ky-page-head`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{id:`staff-settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,Q.jsx)(`p`,{className:`ky-page-lede`,children:`Your administrator account and browser appearance.`})]})}),(0,Q.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:i.map(([e,t])=>(0,Q.jsx)(`a`,{className:`ky-nav-item`,href:`#${e}`,"aria-current":o===e?`page`:void 0,children:t},e))}),!t&&(0,Q.jsx)(`div`,{hidden:o!==`account`,children:r}),(0,Q.jsx)(`div`,{hidden:o!==`appearance`,children:(0,Q.jsx)(Xf,{})})]}),sp.map(([t,n,,r])=>(0,Q.jsxs)(`section`,{id:t,className:`page-view admin-view`,hidden:o!==t,"aria-labelledby":`staff-${t}-heading`,children:[(0,Q.jsxs)(`header`,{className:`ky-page-head`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{id:`staff-${t}-heading`,className:`ky-page-title`,children:n}),(0,Q.jsx)(`p`,{className:`ky-page-lede`,children:r})]}),(0,Q.jsx)(`button`,{className:`secondary`,type:`button`,onClick:()=>l(e=>e+1),children:`Refresh`})]}),t===`orgs`&&(0,Q.jsx)(dp,{state:u,empty:`No organizations are mirrored yet.`,children:e=>(0,Q.jsxs)(fp,{label:`Organization directory`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,children:`Organization`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Status`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Region`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Notes stored`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Shared pool`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Last poll`})]})}),(0,Q.jsx)(`tbody`,{children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`row`,children:(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>w(e.id),children:e.id})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":e.status===`active`&&e.enabled?`success`:void 0,children:e.status===`active`&&!e.enabled?`App disabled`:e.status.replaceAll(`_`,` `)})}),(0,Q.jsx)(`td`,{children:e.homeRegion}),(0,Q.jsx)(`td`,{children:cp(e.notesUsedBytes)}),(0,Q.jsxs)(`td`,{children:[cp(e.orgUsedBytes),` / `,cp(e.poolBytes)]}),(0,Q.jsx)(`td`,{children:e.lastPoll||`Not polled`})]},e.id))})]})}),(t===`users`||t===`audit`)&&u.kind===`failed`&&(0,Q.jsx)(`p`,{role:`alert`,children:u.message}),t===`users`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`field`,children:[`Organization`,(0,Q.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),disabled:T.length===0,children:[(0,Q.jsx)(`option`,{value:``,children:`Select an organization`}),T.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,Q.jsx)(dp,{state:g.scope===f?g.state:{kind:`loading`},empty:f?`No accounts in this organization.`:`Select an organization to view accounts.`,children:e=>(0,Q.jsxs)(fp,{label:`Organization accounts`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,children:`Account`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Role`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Status`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Stored`})]})}),(0,Q.jsx)(`tbody`,{children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`row`,children:e.username}),(0,Q.jsx)(`td`,{children:e.accountKind===`admin`?`Administrator`:`Everyday`}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":e.status===`active`?`success`:void 0,children:e.status})}),(0,Q.jsx)(`td`,{children:cp(e.usedBytes)})]},e.id))})]})})]}),t===`audit`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`field`,children:[`Audit scope`,(0,Q.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Platform`}),T.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),(0,Q.jsx)(dp,{state:v.scope===m?v.state:{kind:`loading`},empty:`No audit events recorded.`,children:e=>(0,Q.jsx)(`div`,{className:`audit-log`,children:e.map((e,t)=>(0,Q.jsxs)(`div`,{className:`audit-row`,children:[(0,Q.jsx)(`strong`,{children:e.event}),(0,Q.jsxs)(`span`,{children:[e.outcome,` · `,e.at]})]},`${e.at}-${t}`))})})]}),t===`sso`&&(b.kind===`ready`?(0,Q.jsxs)(`dl`,{className:`status-list`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Status`}),(0,Q.jsx)(`dd`,{children:b.value.enabled?`Enabled`:`Disabled`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Issuer`}),(0,Q.jsx)(`dd`,{children:b.value.issuerUrl})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Client`}),(0,Q.jsx)(`dd`,{children:b.value.clientId})]})]}):(0,Q.jsx)(`p`,{role:b.kind===`failed`?`alert`:`status`,children:b.kind===`failed`?b.message:`Loading sign-in configuration…`})),t===`backups`&&(0,Q.jsx)(sf,{username:e}),t===`server`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{role:`note`,className:`admin-note`,children:`Staff administration does not grant access to notes or content keys.`}),(0,Q.jsxs)(`dl`,{className:`status-list`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Health`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(pp,{ok:S?.health})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Readiness`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(pp,{ok:S?.ready})})]})]}),(0,Q.jsx)(df,{username:e})]})]},t))]})}function dp({state:e,empty:t,children:n}){switch(e.kind){case`loading`:return(0,Q.jsx)(`p`,{role:`status`,children:`Loading metadata…`});case`failed`:return(0,Q.jsx)(`p`,{role:`alert`,children:e.message});case`ready`:return e.value.length===0?(0,Q.jsx)(`p`,{className:`config-muted`,children:t}):n(e.value)}}function fp({label:e,children:t}){return(0,Q.jsx)(`div`,{role:`region`,"aria-label":e,tabIndex:0,style:{overflowX:`auto`},children:(0,Q.jsx)(`table`,{className:`data-table`,children:t})})}function pp({ok:e}){return(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":e===void 0?void 0:e?`success`:`danger`,children:e===void 0?`Checking…`:e?`OK`:`Failed`})}var mp=[[`users`,`Users`,`users`,`Everyone who can sign in to this server.`],[`teams`,`Teams`,`team`,`A team belongs to an everyday owner, who names it and shares its keys. Administrators never see its name or its notes.`],[`sso`,`Single sign-on`,`sso`,`Connect KyNotes to KySignOn Server for one-click single sign-on and automated user directory replication.`],[`backups`,`Backups`,`backups`,`Scheduled backups of this server, kept in a local directory or in KyRecovery.`],[`audit`,`Audit log`,`audit`,`Metadata-only records of administrative actions.`],[`server`,`Server`,`server`,`Health and readiness of this KyNotes server, and the office networks that skip the sign-in limit.`]];function hp(e){return e.deployment===`multi`?(0,Q.jsx)(up,{...e}):(0,Q.jsx)(gp,{...e})}function gp({username:e,sso:t,onLogout:n,password:r}){let i=[...t?[]:[[`account`,`Account`]],[`appearance`,`Appearance`]],a=()=>[...mp,...i].find(([e])=>location.hash===`#${e}`)?.[0]??`users`,[o,s]=(0,X.useState)(a),c=(e,t,n)=>(0,Q.jsx)(Tf,{icon:n,label:t,href:`#${e}`,current:o===e},e),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)([]);return(0,X.useEffect)(()=>{window.scrollTo(0,0);let e=()=>s(a());return window.addEventListener(`hashchange`,e),Promise.all([cu(),lu(),su()]).then(([e,t,n])=>{f(e),m(t),u(n)}).catch(()=>{}),()=>window.removeEventListener(`hashchange`,e)},[]),(0,Q.jsxs)(Of,{className:`admin-shell`,label:`Administration sections`,onSignOut:n,user:{name:e,role:`Administrator`},settings:{items:i.map(([e,t])=>({href:`#${e}`,label:t,current:o===e})),current:i.some(([e])=>e===o)},nav:(0,Q.jsx)(Q.Fragment,{children:mp.map(([e,t,n])=>c(e,t,n))}),children:[(0,Q.jsxs)(`section`,{className:`page-view admin-view`,hidden:!i.some(([e])=>e===o),"aria-labelledby":`settings-heading`,children:[(0,Q.jsx)(`header`,{className:`ky-page-head`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{id:`settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,Q.jsx)(`p`,{className:`ky-page-lede`,children:t?`How KyNotes looks in this browser.`:`Your administrator password, and how KyNotes looks in this browser.`})]})}),(0,Q.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:i.map(([e,t])=>(0,Q.jsx)(`a`,{className:`ky-nav-item`,href:`#${e}`,"aria-current":o===e?`page`:void 0,children:t},e))}),!t&&(0,Q.jsx)(`div`,{id:`account`,hidden:o!==`account`,children:r}),(0,Q.jsx)(`div`,{id:`appearance`,hidden:o!==`appearance`,children:(0,Q.jsx)(Xf,{})})]}),mp.map(([t,n,,r])=>(0,Q.jsxs)(`section`,{id:t,className:`page-view admin-view`,hidden:o!==t,"aria-labelledby":`${t}-heading`,children:[(0,Q.jsxs)(`header`,{className:`ky-page-head`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{id:`${t}-heading`,className:`ky-page-title`,children:n}),(0,Q.jsx)(`p`,{className:`ky-page-lede`,children:r})]}),t===`users`&&(0,Q.jsx)(yp,{username:e,onCreated:()=>void cu().then(f)})]}),t===`users`&&(0,Q.jsx)(xp,{username:e,users:d,onChange:e=>f(t=>t.map(t=>t.id===e.id?e:t))}),t===`teams`&&(0,Q.jsx)(Sp,{users:d,username:e}),t===`sso`&&(0,Q.jsx)(Cp,{username:e}),t===`backups`&&(0,Q.jsx)(sf,{username:e}),t===`audit`&&(0,Q.jsx)(`div`,{className:`audit-log`,children:p.length===0?(0,Q.jsx)(`p`,{className:`config-muted`,children:`No audit events recorded.`}):p.map((e,t)=>(0,Q.jsxs)(`div`,{className:`audit-row`,children:[(0,Q.jsx)(`strong`,{children:e.event}),(0,Q.jsxs)(`span`,{children:[e.outcome,` · `,e.at]})]},`${e.at}-${t}`))}),t===`server`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{role:`note`,className:`admin-note`,children:`This is an administrator account. It manages KyNotes and cannot open notes. Sign in with your everyday account to write.`}),(0,Q.jsxs)(`dl`,{className:`status-list`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Health`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(_p,{ok:l?.health})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Readiness`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(_p,{ok:l?.ready})})]})]}),(0,Q.jsx)(df,{username:e})]})]},t))]})}var _p=({ok:e})=>(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":e===void 0?void 0:e?`success`:`danger`,children:e===void 0?`Checking…`:e?`OK`:`Failed`}),vp=e=>t=>{t instanceof Error&&t.message===`Password confirmation cancelled`||alert(t instanceof Error?t.message:e)};function yp({username:e,onCreated:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`user`),[l,u]=(0,X.useState)(!1);async function d(c){c.preventDefault(),u(!0);try{let c=ft(),l=await dt(a,c,6e5);await rf(e,()=>pu({username:r,authSecret:l,loginSalt:c,iterations:6e5,accountKind:s})),i(``),o(``),n.current?.close(),t()}catch(e){vp(`Unable to create user`)(e)}finally{u(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`ky-page-action`,onClick:()=>n.current?.showModal(),children:[(0,Q.jsx)(pf,{name:`plus`}),`Create user`]}),(0,Q.jsx)(`dialog`,{ref:n,className:`ky-dialog`,"aria-labelledby":`create-user-heading`,children:(0,Q.jsxs)(`form`,{onSubmit:d,children:[(0,Q.jsx)(`h2`,{id:`create-user-heading`,children:`Create user`}),(0,Q.jsxs)(`label`,{children:[`Username`,(0,Q.jsx)(`input`,{autoComplete:`off`,value:r,onChange:e=>i(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Temporary password`,(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Account type`,(0,Q.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,Q.jsx)(`option`,{value:`user`,children:`Everyday`}),(0,Q.jsx)(`option`,{value:`admin`,children:`Administrator`})]})]}),(0,Q.jsx)(`p`,{className:`dialog-hint`,children:`They choose their own password at first sign-in.`}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>n.current?.close(),children:`Cancel`}),(0,Q.jsx)(`button`,{disabled:l,children:l?`Creating…`:`Create user`})]})]})})]})}var bp=`Password reset. All existing sessions and paired device credentials were revoked. The account keeps its encryption key: after changing the temporary password, the user gets it back from a browser that holds it or with their recovery code (an account linked to KySignOn gets no password copy back). With neither, they can reset it themselves, and their personal notebooks are lost. If a browser holding the key was lost or stolen, ask the user to reset their encryption key in Settings: this reset does not cut that browser off.`;function xp({username:e,users:t,onChange:n}){let r=e=>document.getElementById(e)?.hidePopover();async function i(t){try{await rf(e,()=>gu(t)),n(t)}catch(e){vp(`Unable to update user`)(e)}}async function a(t){let n=prompt(`New temporary password for ${t.username}`);if(n)try{let r=ft(),i=await dt(n,r,6e5);await rf(e,()=>mu(t.id,{newAuthSecret:i,newLoginSalt:r,iterations:6e5})),alert(bp)}catch(e){vp(`Unable to reset password`)(e)}}return(0,Q.jsxs)(`table`,{className:`data-table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,children:`Account`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Role`}),(0,Q.jsx)(`th`,{scope:`col`,children:`Status`}),(0,Q.jsx)(`th`,{scope:`col`,children:(0,Q.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,Q.jsx)(`tbody`,{children:t.map((e,t)=>{let n=`user-menu-${t}`,o=e.status===`active`;return(0,Q.jsxs)(`tr`,{className:`admin-user`,children:[(0,Q.jsx)(`th`,{scope:`row`,children:e.username}),(0,Q.jsx)(`td`,{children:e.accountKind===`admin`?e.role===`admin`?`Administrator`:`Administrator, grant revoked`:`Everyday`}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":o?`success`:void 0,children:o?`Active`:`Disabled`})}),(0,Q.jsxs)(`td`,{className:`row-actions`,children:[(0,Q.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:n,"aria-label":`Actions for ${e.username}`,style:{anchorName:`--${n}`},children:(0,Q.jsx)(pf,{name:`more`})}),(0,Q.jsxs)(`div`,{className:`section-menu anchored-menu row-menu`,id:n,popover:`auto`,style:{positionAnchor:`--${n}`},children:[(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>{r(n),a(e)},children:`Reset password`}),e.accountKind===`admin`&&(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>{r(n),i({...e,role:e.role===`admin`?`user`:`admin`})},children:e.role===`admin`?`Revoke administrator grant`:`Restore administrator grant`}),(0,Q.jsx)(`button`,{className:o?`quiet danger`:`quiet`,onClick:()=>{r(n),i({...e,status:o?`disabled`:`active`})},children:o?`Disable account`:`Enable account`})]})]})]},e.id)})})]})}function Sp({users:e,username:t}){let[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(`editor`),f=e.filter(e=>e.status===`active`&&e.accountKind===`user`);async function p(){try{r(await uu())}catch{}}(0,X.useEffect)(()=>{p()},[]);async function m(){if(i)try{s((await rf(t,()=>du(i))).id),await p()}catch(e){vp(`Unable to create team`)(e)}}async function h(){if(o&&c)try{await rf(t,()=>hu(o,c,u)),alert(`Person added. They get the team's keys once one of its owners approves them.`),await p()}catch(e){vp(`Unable to add person`)(e)}}return(0,Q.jsxs)(`div`,{className:`admin-panel`,children:[(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Owner`}),(0,Q.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Select owner`}),f.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,Q.jsx)(`button`,{disabled:!i,onClick:()=>void m(),children:`Create team`}),(0,Q.jsx)(`ul`,{className:`admin-teams`,children:n.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{children:e.id}),` · owner `,e.ownerUsername,` · `,e.memberCount,` `,e.memberCount===1?`member`:`members`,` · `,e.named?`named`:`not named yet`,` · `,e.keyed?`keyed`:`waiting for its owner`]},e.id))}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Team`}),(0,Q.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Select team`}),n.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.ownerUsername]},e.id))]})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Person`}),(0,Q.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Select person`}),f.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Role`}),(0,Q.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,Q.jsx)(`option`,{children:`editor`}),(0,Q.jsx)(`option`,{children:`commenter`}),(0,Q.jsx)(`option`,{children:`viewer`})]})]}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>void h(),children:`Add to team`})]})}function Cp({username:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null);(0,X.useEffect)(()=>{Yl().then(n).catch(()=>{})},[]);async function d(t){if(t.preventDefault(),r.trim()&&a.trim()){c(!0),u(null);try{let t=await rf(e,()=>Zl(a.trim(),r.trim()));n(t.settings),i(``),u({text:`Successfully paired with KySignOn (System ID: ${t.systemId})!`,type:`success`})}catch(e){u({text:e instanceof Error?e.message:`Pairing failed`,type:`error`})}finally{c(!1)}}}async function f(r){if(r.preventDefault(),t){c(!0),u(null);try{let r=await rf(e,()=>Xl(t));n(r),u({text:`Single Sign-On settings saved successfully.`,type:`success`})}catch(e){u({text:e instanceof Error?e.message:`Unable to save SSO settings`,type:`error`})}finally{c(!1)}}}return t?(0,Q.jsxs)(`div`,{className:`admin-panel`,children:[l&&(0,Q.jsx)(`p`,{className:l.type===`error`?`error`:`status-line`,style:{margin:`14px 0`},children:l.text}),(0,Q.jsxs)(`div`,{style:{background:`var(--accent-soft)`,padding:`16px`,borderRadius:`4px`,margin:`18px 0`},children:[(0,Q.jsx)(`h3`,{style:{margin:`0 0 8px`,fontSize:`14px`,font:`12px Mono, monospace`,letterSpacing:`.1em`,textTransform:`uppercase`},children:`Quick Pair with KySignOn`}),(0,Q.jsx)(`p`,{className:`config-muted`,style:{margin:`0 0 14px`,fontSize:`13px`},children:`Generate a 90-second system pairing token in KySignOn Admin Dashboard to pair KyNotes automatically.`}),(0,Q.jsxs)(`form`,{onSubmit:d,style:{display:`grid`,gap:`12px`},children:[(0,Q.jsxs)(`label`,{className:`field`,style:{marginTop:0},children:[(0,Q.jsx)(`span`,{children:`KySignOn Issuer URL`}),(0,Q.jsx)(`input`,{placeholder:`http://localhost:5867 or https://auth.example.com`,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{className:`field`,style:{marginTop:0},children:[(0,Q.jsx)(`span`,{children:`90-Second Pairing Token`}),(0,Q.jsx)(`input`,{placeholder:`Enter pairing token from KySignOn UI`,value:r,onChange:e=>i(e.target.value),required:!0})]}),(0,Q.jsx)(`button`,{disabled:s,style:{width:`fit-content`},children:s?`Pairing…`:`Pair with KySignOn`})]})]}),(0,Q.jsxs)(`form`,{onSubmit:f,style:{marginTop:`24px`},children:[(0,Q.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`},children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:e=>n({...t,enabled:e.target.checked}),style:{width:`18px`,height:`18px`}}),(0,Q.jsx)(`strong`,{style:{fontSize:`14px`},children:`Enable OpenID Connect / Single Sign-On`})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`OIDC Issuer URL`}),(0,Q.jsx)(`input`,{value:t.issuerUrl,onChange:e=>n({...t,issuerUrl:e.target.value}),placeholder:`https://auth.example.com`})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Client ID`}),(0,Q.jsx)(`input`,{value:t.clientId,onChange:e=>n({...t,clientId:e.target.value}),placeholder:`kynotes`})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:t.clientSecretSet?`Client Secret: set. Enter a new one only to replace it`:`Client Secret (Optional for PKCE)`}),(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:t.clientSecret??``,onChange:e=>n({...t,clientSecret:e.target.value}),placeholder:t.clientSecretSet?`Leave empty to keep the current secret`:``})]}),t.clientSecretSet&&(0,Q.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.clearClientSecret??!1,onChange:e=>n({...t,clearClientSecret:e.target.checked})}),(0,Q.jsx)(`span`,{children:`Remove the client secret`})]}),(0,Q.jsxs)(`p`,{className:`config-muted`,children:[`Directory sync secret: `,t.hmacSecretSet?`set`:`not set`]}),t.hmacSecretSet&&(0,Q.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.clearHmacSecret??!1,onChange:e=>n({...t,clearHmacSecret:e.target.checked})}),(0,Q.jsx)(`span`,{children:`Remove the directory sync secret (turns directory sync off)`})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Custom Redirect URI (Optional override)`}),(0,Q.jsx)(`input`,{value:t.redirectUri??``,onChange:e=>n({...t,redirectUri:e.target.value}),placeholder:`https://notes.example.com/api/v1/auth/oidc/callback`})]}),(0,Q.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,marginTop:`16px`,cursor:`pointer`},children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.autoProvision,onChange:e=>n({...t,autoProvision:e.target.checked}),style:{width:`18px`,height:`18px`}}),(0,Q.jsx)(`span`,{style:{fontSize:`13px`},children:`Auto-provision new user accounts on first SSO login`})]}),(0,Q.jsx)(`button`,{disabled:s,style:{marginTop:`20px`},children:s?`Saving…`:`Save SSO Settings`})]})]}):(0,Q.jsx)(`p`,{className:`config-muted`,children:`Loading Single Sign-On configuration…`})}function wp(e){let t=e.admin.trim().toLowerCase(),n=e.everyday.trim().toLowerCase();if(!t||!n)return`Both usernames are required.`;if(t===n)return`Use a different username for each account.`;if(e.adminPassword!==e.adminConfirm||e.everydayPassword!==e.everydayConfirm)return`Passwords do not match.`;if(e.adminPassword.length<8||e.everydayPassword.length<8)return`Passwords must be at least 8 characters.`;if(e.adminPassword===e.everydayPassword)return`Use a different password for each account.`}function Tp(e,t,n){let r=URL.createObjectURL(typeof t==`string`?new Blob([t],{type:n}):t),i=document.createElement(`a`);i.href=r,i.download=e,document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}var Ep=`kynotes/link/v2`,Dp=`kynotes/link-commit/v1`,Op=`kynotes/link-check/v1`,kp=2,Ap=new TextEncoder;function jp(e){if(e.length!==32)throw Error(`invalid link key`);return e}var Mp=new WeakSet;function Np(){let e=Tc();return Mp.add(e),e}function Pp(e){e.privateKey.fill(0),Mp.delete(e)}var Fp=e=>Mp.has(e),Ip=e=>z(wc(Ap.encode(Dp),jp(e)));function Lp(e,t,n,r){let i=z(wc(Ap.encode(Op),Cc(`usr`,e),Cc(`lnk`,t),jp(n),jp(r))),a=String(new DataView(i.buffer,i.byteOffset,4).getUint32(0)%1e6).padStart(6,`0`);return`${a.slice(0,3)} ${a.slice(3)}`}var Rp=e=>wc(Ap.encode(Ep),Cc(`usr`,e.userID),Cc(`lnk`,e.requestID),Cc(`dev`,e.identityDeviceID),jp(e.approverKey),jp(e.newcomerKey));async function zp(e,t,n,r){if(e.length!==32||!Y(t.publicKey,n.approverKey))throw Error(`invalid link input`);let i={recipientPublicKey:await Sc.kem.deserializePublicKey(jp(n.newcomerKey)),senderKey:await Oc(t.privateKey),info:Rp(n)},{enc:a,ct:o}=await Sc.seal(r?{...i,ekm:r}:i,e);return wc(Uint8Array.of(kp),new Uint8Array(a),new Uint8Array(o))}var Bp=(e,t,n)=>zp(e,t,n),Vp=e=>Error(`link bundle refused: ${e}`);async function Hp(e,t,n){if(e.length!==81||e[0]!==kp||n.approverKey.length!==32)throw Vp(`format`);if(!Y(t.publicKey,n.newcomerKey))throw Vp(`newcomer-key`);try{ri.getSharedSecret(t.privateKey,n.approverKey)}catch{throw Vp(`low-order`)}try{return new Uint8Array(await Sc.open({recipientKey:await Oc(t.privateKey),senderPublicKey:await Sc.kem.deserializePublicKey(n.approverKey),enc:e.subarray(1,33),info:Rp(n)},e.subarray(33)))}catch{throw Vp(`aead`)}}var Up=new WeakSet,Wp;(class e{requestID;code;static{Wp=(t,n)=>{let r=new e(t,n);return Object.freeze(r),Up.add(r),r}}constructor(e,t){this.requestID=e,this.code=t}});var Gp=(e,t)=>Wp(e,t),Kp=(e,t)=>typeof e==`object`&&!!e&&Up.has(e)&&e.requestID===t,qp=new WeakSet,Jp=e=>e.normalize(`NFKC`).replace(/\s/g,``);function Yp(e,t,n){if(!t||Jp(n)!==Jp(t))throw Error(`That is not the code the other browser shows. Type it again; if the codes differ, cancel.`);let r=Wp(e,t);return qp.add(r),r}var Xp=(e,t)=>Kp(e,t)&&qp.has(e),Zp={},Qp=(e,t)=>({...e,shared:Math.max(e.shared??0,t.sharedGeneration),generation:Math.max(e.generation??0,t.keyGeneration)}),$p=(e,t)=>({shared:Math.max(e?.shared??0,t.shared??0),generation:Math.max(e?.generation??0,t.generation??0)});function em(e,t){let n=t.shared??0,r=t.generation??0;return{container:{...e,sharedGeneration:Math.max(e.sharedGeneration,n),keyGeneration:Math.max(e.keyGeneration,r)},rollback:e.sharedGeneratione===`owner`||e===`admin`;async function rm(e){let{containerID:t,envelopes:n,me:r,members:i,pins:a}=e,o=new Map,s={...e.known,mark:Math.max(0,e.known.mark),digests:{...e.known.digests}},c={ring:o,pins:{...a},fresh:[],changed:[],conflicts:[],known:s},l=Object.values(a).flatMap(e=>{try{return[ai(e)]}catch{return[]}}),u=(e,t)=>{let n=Vi(z(t)),r=o.get(e);return(r?Vi(z(r))===n:(s.digests[e]??n)===n)?(o.set(e,r??t),s.digests[e]??=n,!0):(c.conflicts.includes(e)||c.conflicts.push(e),!1)};for(let[t,n]of e.held??[])u(t,n);if(!r)return c;let d=async(e,n,i,a)=>{try{return _t(await Mc(e,n,r.privateKey,t,i,r.deviceId,a))}catch{return}},f=[];for(let e of n)if(!(e.deviceId!==r.deviceId||e.alg!==`hpke-auth-x25519-hkdfsha256-chacha20poly1305`&&e.alg!==`x25519-hkdf-sha256-chacha20poly1305`))try{let t=$e(e.envelope),n=jc(e.alg,t),a=n===r.deviceId,o=a?void 0:i.find(e=>e.identity?.deviceId===n);if(o?.userId===r.userId)continue;let l=o&&nm(o.role)?o:void 0,p=l&&c.pins[l.userId],m=a||l&&(p===void 0||si(p,l.identity.publicKey));l&&!m&&!c.changed.some(e=>e.member.userId===l.userId)&&c.changed.push({member:l,pinned:p});let h=m?await d(e.alg,t,e.keyGeneration,a?r.publicKey:ai(l.identity.publicKey)):void 0;if(!h){f.push({alg:e.alg,envelope:t,generation:e.keyGeneration});continue}if(!u(e.keyGeneration,h))continue;s.mark=Math.max(s.mark,e.keyGeneration),l&&p===void 0&&(c.pins[l.userId]=l.identity.publicKey,c.fresh.push(l))}catch{}for(let{alg:e,envelope:t,generation:n}of f)if(!(n>=s.mark))for(let r of l){let i=await d(e,t,n,r);if(i){u(n,i);break}}return c}function im(e,t,n){let{container:r,rollback:i}=em(e,n);if(i||r.sharedGeneration===0)return;let a=t.get(r.keyGeneration);return a&&{key:a,generation:r.keyGeneration}}var am=e=>_t(qe(e.privateKey,32,new Uint8Array,new TextEncoder().encode(`kynotes/waiting/v1`))),om=e=>qe(e.privateKey,32,new Uint8Array,new TextEncoder().encode(`kynotes/reminder-id/v1`));function sm(e,t,n,r){let i=Math.max(e.sharedGeneration,r.shared??0);if(i===0||n===void 0||!Number.isInteger(n)||nn===0?i?[i]:[]:sm(e,t,n,r);async function lm(e,t){let n=Error(`no content key`);for(let r of e)try{return await t(r)}catch(e){n=e}throw n}function um(e){let{container:t,me:n,members:r,envelopes:i,ring:a}=e,o=r.find(e=>e.userId===n);if(!o?.identity||!nm(o.role))return{kind:`idle`};let s=r.filter(e=>e.identity&&e.approved!==!1);if(t.sharedGeneration===0)return e.recoverable?{kind:`mint`,recipients:s}:{kind:`unrecoverable`};if(!i.some(e=>e.keyGeneration===t.keyGeneration))return{kind:`mint`,recipients:s};let c=new Set(i.map(e=>`${e.deviceId}:${e.keyGeneration}`)),l=s.flatMap(e=>[...a.keys()].filter(e=>e>=t.sharedGeneration&&e<=t.keyGeneration).filter(t=>!c.has(`${e.identity.deviceId}:${t}`)).map(t=>({member:e,generation:t})));return l.length?{kind:`wrap`,grants:l}:{kind:`idle`}}async function dm(e,t,n,r,i,a){let o=e.identity,s=ai(o.publicKey),c=a,l=[];if(e.userId===i.userId){if(o.deviceId!==i.deviceId||!si(o.publicKey,Qe(i.publicKey)))throw Error(`own identity mismatch`)}else if(a[e.userId]===void 0)c={...a,[e.userId]:o.publicKey},l=[e];else if(!si(a[e.userId],o.publicKey))throw new ci(e,a[e.userId]);let u=Qe(await Ac(r,s,t,n,o.deviceId,i));return{envelope:{deviceId:o.deviceId,keyGeneration:n,alg:hc,envelope:u},pins:c,fresh:l}}var fm=()=>_t(Zi(32));function pm(e,t,n){let r=new Set(n.filter(t=>t.keyGeneration===e.keyGeneration).map(e=>e.deviceId));return Object.fromEntries(t.flatMap(t=>t.approved===!1?[[t.userId,`unapproved`]]:t.identity?e.sharedGeneration===0?[]:[[t.userId,r.has(t.identity.deviceId)?`has-key`:`waiting`]]:[[t.userId,`no-identity`]]))}function mm(e,t,n){return!n||!e?`wait`:t===n.generation?`send`:`reseal`}async function hm(e,t,n,r,i,a){let o=mm(n,e.keyGeneration,r);if(o===`wait`)return;let s=await lm(cm(t,i,e.keyGeneration,n,a),t=>Mt(t,e.containerID,e.id,e.payload,!0));if(o===`send`&&!s.v1)return e;if(s.payload)return{...e,payload:await jt(r.key,e.containerID,e.id,s.payload),keyGeneration:r.generation}}async function gm(e,t,n,r,i){return{payload:await kt(e.key,t,n,r),metadataCiphertext:Qe(await Dt(e.key,t,n,i)),keyGeneration:e.generation}}async function _m(e,t,n,r,i,a){let o=mm(n,e.keyGeneration,r);if(o===`wait`)return{kind:o};let s=cm(t,i,e.keyGeneration,n,a);return o===`send`&&await lm(s,t=>Ot(t,e.containerID,e.objectID,$e(e.metadataCiphertext),!1)).then(()=>!0,()=>!1)?{kind:`send`}:{kind:`reseal`,plaintext:await lm(s,t=>At(t,e.containerID,e.objectID,e.payload,!0)),file:await lm(s,t=>Ot(t,e.containerID,e.objectID,$e(e.metadataCiphertext),!0))}}var vm=`Not saved: neither the server nor this browser kept this edit. It exists only in this tab; keep the tab open and copy the edit.`,ym=()=>{throw Error(vm)},bm=e=>e?`This note changed on another device, and this browser could not keep a local copy of your edit. It exists only in this tab: copy or export it now, before closing or reloading.`:`This note changed on another device. Your encrypted draft is preserved locally; review the conflict before saving again.`,xm={},Sm={},Cm=new Set,wm=()=>{for(let e of Cm)e()},Tm=(e,t)=>{let n=Sm[e];n&&delete Sm[e],xm={...xm,[e]:$p($p(xm[e],t),n??{})},wm()},Em=typeof BroadcastChannel>`u`?null:new BroadcastChannel(`kynotes-floors`),Dm=/^cnt_[0-9abcdefghjkmnpqrstvwxyz]{26}$/,Om=e=>Number.isSafeInteger(e)&&e>=0;Em&&(Em.onmessage=e=>{let{containerID:t,shared:n,generation:r}=e.data??{};typeof t==`string`&&Dm.test(t)&&Om(n)&&Om(r)&&(xm[t]?Tm(t,{shared:n,generation:r}):Sm[t]=$p(Sm[t],{shared:n,generation:r}))});var km=e=>xm[e];function Am(e,t){Tm(e,t);let{shared:n=0,generation:r=0}=xm[e];Em?.postMessage({containerID:e,shared:n,generation:r})}function jm(e,t,n){(n||xm[e])&&Am(e,t)}function Mm(){xm={},Sm={},wm()}var Nm=e=>(Cm.add(e),()=>{Cm.delete(e)}),Pm=()=>(0,X.useSyncExternalStore)(Nm,()=>xm),Fm=class extends Error{constructor(){super(`This notebook's keys changed or are not shared yet; the change stays on this device until they are.`),this.name=`KeysWaitingError`}},Im;function Lm(e){return Im=e,()=>{Im===e&&(Im=void 0)}}function Rm(e){let t=Im?.(e.container);if(mm(km(e.container.id),e.generation,t)!==`send`)throw new Fm}var zm=async(e,t,n,r)=>{let i=`${t}:${r}:${e.generation}:${await nt(n)}`;return Rm(e),Qu(t,n,r,e.generation,i)},Bm=(e,t,n)=>(Rm(e),ou(e.container.id,t,n,e.generation)),Vm=(e,t,n,r)=>(Rm(e),Ju(t,n,e.generation,r)),Hm=(e,t,n)=>(Rm(e),$u(e.container.id,t,n)),Um=(e,t,n,r)=>(Rm(e),nd(t,n,r)),Wm=(e,t,n)=>(Rm(e),rd(t,n,e.generation));function Gm(e,t,n){if(!Xp(e,t))throw Error(`Compare the check codes on both screens first.`);return ju(t,Qe(n))}function Km(e,t){if(!Fp(e))throw Error(`This link attempt ended. Start again on both browsers.`);return Mu(t)}var qm=class extends Error{constructor(){super(`This browser cannot keep an encryption key (site storage is blocked or unavailable), so it cannot be linked.`),this.name=`LinkStorageError`}},Jm=class extends Error{constructor(){super(`The other browser's key changed while linking. Nothing was linked; start again on both browsers.`),this.name=`LinkTamperedError`}},Ym=class extends Error{constructor(){super(`This link attempt ended. Nothing was linked; start again on both browsers.`),this.name=`LinkEndedError`}},Xm=class extends Error{constructor(){super(`Your account has no encryption key yet, so there is nothing to link. Set one up first, or link this browser from one that holds it.`),this.name=`LinkNoIdentityError`}},Zm=e=>Pp(e.key);function Qm(e,t){if(!Fp(e.key))throw new Ym;if(t!==e.userID)throw Zm(e),Error(`The signed-in account changed while linking. Nothing was linked; start again on both browsers.`)}async function $m(e,t){try{return await t()}catch(t){throw Zm(e),t}}var eh=new WeakMap,th=`This browser holds another copy of your key. Use Forget this device first.`;async function nh(e,t){let n=await t.load();if(!n)return!1;let r=await e.myIdentity();return!r||!Y(n.publicKey,ai(r.publicKey))}async function rh(e,t,n){if(!await t())throw new qm;let r=Np(),{id:i,expiresAt:a}=await $m({id:``,userID:n,key:r},()=>e.create(Qe(Ip(r.publicKey)))).catch(e=>{throw e instanceof Bl&&e.code===`not_found`?new Xm:e});return{id:i,userID:n,key:r,expiresAt:a}}async function ih(e,t,n){Qm(t,n);let r=await e.collect(t.key,t.id),i=eh.get(t.key.privateKey);if(i){if(r.approverKey&&!Y(ai(r.approverKey),i.approverKey))throw Zm(t),new Jm;return{link:{...t,...i},bundle:r.bundle?$e(r.bundle):void 0}}if(!r.approverKey)return{link:t};let a=await $m(t,async()=>{let n=ai(r.approverKey),i={approverKey:n,code:Lp(t.userID,t.id,n,t.key.publicKey)};return eh.set(t.key.privateKey,i),await e.reveal(t.id,Qe(t.key.publicKey)),i});return{link:{...t,...a}}}var ah=4e3,oh=3e4,sh=6e5,ch=e=>e instanceof Bl&&e.status===429||e instanceof TypeError,lh=e=>new Promise(t=>setTimeout(t,e));async function uh(e,t,n,r,i,a=lh,o=Date.now){let s=ah,c;for(;;){if(await a(s),!r())return;try{let a=await ih(e,t,n);if(!r())return;if(i(a.link),a.bundle)return a.bundle;s=ah,c=void 0}catch(e){if(!ch(e)||!Fp(t.key))throw e;if(c??=o(),o()-c>=sh)throw Zm(t),new Ym;s=Math.min(s*2,oh)}}}async function dh(e,t,n,r,i,a){Qm(e,r);let o=eh.get(e.key.privateKey);if(!o||!Kp(n,e.id)||n.code!==o.code)throw Error(`Compare the check codes on both screens first.`);try{let n=await i.myIdentity();if(!n)throw Error(`Your account has no encryption key to link.`);let r=await Hp(t,e.key,{userID:e.userID,requestID:e.id,identityDeviceID:n.deviceId,approverKey:o.approverKey,newcomerKey:e.key.publicKey}),s=ri.getPublicKey(r);if(!Y(s,ai(n.publicKey)))throw Error(`The key sent is not your account's encryption key. Nothing was linked.`);let c={deviceId:n.deviceId,publicKey:s,privateKey:r},l=await a.load();if(l&&!Y(l.publicKey,s))throw Error(th);if(l?.deviceId===c.deviceId)return l;if(!await a.save(c,l??null))throw new qm;return c}finally{Zm(e)}}async function fh(e,t,n){let r=$e(t.commitment);if(r.length!==32)throw new Jm;let i={id:t.id,userID:n,key:Np(),commitment:r};return await $m(i,()=>e.claim(t.id,Qe(i.key.publicKey))),i}function ph(e,t,n){if(Qm(e,n),e.newcomerKey||t?.id!==e.id||!t.newcomerKey)return e;let r;try{r=ai(t.newcomerKey)}catch{r=new Uint8Array}if(r.length!==32||!Y(Ip(r),e.commitment))throw Zm(e),new Jm;return{...e,newcomerKey:r,code:Lp(e.userID,e.id,e.key.publicKey,r)}}var mh=(e,t)=>Yp(e.id,e.code??``,t);async function hh(e,t,n,r,i,a=Gm){if(Qm(e,r),!e.newcomerKey||!e.code)throw Error(`The other browser has not answered yet.`);if(!Xp(t,e.id)||t.code!==e.code)throw Error(`Type the code the other browser shows first.`);let o=await Bp(n.privateKey,e.key,{userID:e.userID,requestID:e.id,identityDeviceID:n.deviceId,approverKey:e.key.publicKey,newcomerKey:e.newcomerKey});await i(),await a(t,e.id,o),Zm(e)}async function gh(e,t,n){let r=await e;if(t())return r;Zm(r),await n(r.id).catch(()=>void 0)}function _h(e,t=`link a browser`){let n=e instanceof Bl?e.code:void 0;if(n===`step_up_pending`){let t=e.challenge;return{message:`A KySignOn confirmation is still open for this account. Finish it in its window, or cancel it and try again.`,cancel:t?()=>Pu(t):void 0}}return n===`sso_sign_in_required`?{message:`Sign in with KySignOn to continue. This session signed in with a password an administrator set, so it cannot ${t}.`}:n===`password_change_required`?{message:`An administrator set this account's password. Change your password before you ${t}.`}:{message:e instanceof Error?e.message:`Linking failed.`}}var vh=`pbkdf2-sha256-600000/aes-256-gcm`,yh=16,bh=16,xh=12,Sh=28,Ch=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,wh=`kynotes/recovery-code/v1`,Th=`kynotes/identity-recovery/v1`,Eh=new TextEncoder,Dh=`Check the recovery code: a character is wrong or missing.`,Oh=`This recovery code does not open your key. Check it and try again.`,kh=`Your account has no recovery code. Link this browser from one that holds your key, or reset your encryption key.`,Ah=class extends Error{constructor(e=Dh){super(e),this.name=`RecoveryCodeError`}},jh=e=>{let t=z(wc(Eh.encode(wh),e));return BigInt(t[0]<<2|t[1]>>6)};function Mh(e){if(e.length!==yh)throw Error(`invalid recovery secret`);let t=e.reduce((e,t)=>e<<8n|BigInt(t),0n)<<10n|jh(e),n=[];for(let e=0;e>=5n;return n.join(``).match(/.{4}/g).join(`-`)}function Nh(e){let t=e.normalize(`NFKC`).toUpperCase().replace(/[\s-]/g,``).replace(/[IL]/g,`1`).replace(/O/g,`0`);if(t.length!==Sh)throw new Ah;let n=0n;for(let e of t){let t=Ch.indexOf(e);if(t<0)throw new Ah;n=n<<5n|BigInt(t)}if(n>>138n)throw new Ah;let r=new Uint8Array(yh),i=n>>10n;for(let e=15;e>=0;e--)r[e]=Number(i&255n),i>>=8n;if(jh(r)!==(n&1023n))throw new Ah;return r}function Ph(){let e=Zi(yh);return{code:Mh(e),secret:e}}var Fh=e=>{try{return ai(e)}catch{return}},Ih=(e,t)=>wc(Eh.encode(Th),Cc(`usr`,e),t);async function Lh(e,t,n,r,i){if(e.length!==yh||t.length!==32||r.length!==bh||i.length!==xh)throw Error(`invalid recovery input`);let a=await st(e,r);try{return wc(r,i,Ea(a,i,Ih(n,ri.getPublicKey(t))).encrypt(t))}finally{a.fill(0)}}var Rh=(e,t,n)=>Lh(e,t.privateKey,n,Zi(bh),Zi(xh));async function zh(e,t,n,r){let i=Fh(r.publicKey);if(!i||r.wrapAlg!==`pbkdf2-sha256-600000/aes-256-gcm`||t.length!==76||e.length!==yh)throw new Ah(Oh);let a=await st(e,t.subarray(0,bh)),o;try{o=Ea(a,t.subarray(bh,28),Ih(n,i)).decrypt(t.subarray(28))}catch{throw new Ah(Oh)}finally{a.fill(0)}if(!Y(ri.getPublicKey(o),i))throw o.fill(0),new Ah(Oh);return{deviceId:r.deviceId,publicKey:i,privateKey:o}}var Bh=`Type the asked group of your saved recovery code first.`,Vh=`Your recovery code was changed in another tab or browser, so this one was not saved. Make a new code here only if you no longer have that one.`,Hh=`The server's recovery copy is not for your account's current key. Reload and try again.`,Uh=`This recovery code was saved by a newer version of KyNotes. Update this browser's page and try again.`,Wh=`Too many attempts. Wait a few minutes and try again.`,Gh=`reset your encryption key`,Kh=`Too many key resets. Each reset makes your teams wait for a new key, so an account can reset at most 3 times a day. Try again later.`,qh=`RESET`;`${qh}`;var Jh=`Type ${qh} to confirm the reset.`,Yh=e=>e?.trim()===qh,Xh=e=>`Type group ${e} of 7 from your saved copy`,Zh=`The connection failed, so this browser cannot tell whether the reset finished. Keep the code you saved and try again: the retry sends the same new key.`,Qh=class extends Error{cause;constructor(e){super(Zh),this.cause=e,this.name=`ResetUncertainError`}},$h=class extends Error{live;code=`already_exists`;constructor(e){super(Vh),this.live=e,this.name=`RecoveryMovedError`}},eg=new WeakSet;function tg(e){for(;;){let t=Zi(1)[0];if(t>=252)continue;let n=t%7+1;if(n!==e)return n}}async function ng(e,t){let{code:n,secret:r}=Ph();try{return Object.freeze({code:n,check:tg(),identity:e,userID:t,wrappedKey:Qe(await Rh(r,e,t))})}finally{r.fill(0)}}var rg=e=>Object.freeze({...e,check:tg(e.check)});function ig(e,t){let n=(e=>e.normalize(`NFKC`).toUpperCase().replace(/[\s-]/g,``).replace(/[IL]/g,`1`).replace(/O/g,`0`))(t)===e.code.split(`-`)[e.check-1];return n&&eg.add(e),n}var ag=e=>e instanceof Bl&&e.code===`already_exists`;async function og(e,t,n,r){if(!eg.has(t))throw Error(Bh);if(!Y(t.identity.publicKey,n.publicKey))throw Error(`This recovery code was made for another key. Start again.`);try{let{recoveryId:i}=await e.putRecovery({deviceId:n.deviceId,expectedRecoveryId:r,wrapAlg:vh,wrappedKey:t.wrappedKey});return eg.delete(t),i}catch(n){throw ag(n)?(eg.delete(t),new $h(await e.myIdentity().catch(()=>void 0))):n}}async function sg(e,t,n,r,i){let a=Nh(r);try{let r=await t.load(),o=await e.myIdentity(),s=o&&Fh(o.publicKey);if(!o||!s)throw Error(kh);if(r&&!Y(r.publicKey,s))throw Error(th);if(r?.deviceId===o.deviceId)return r;await i();let c=await e.fetchRecovery();if(!c)throw Error(kh);if(c.wrapAlg!==`pbkdf2-sha256-600000/aes-256-gcm`)throw Error(Uh);if(o.deviceId!==c.deviceId||!Y(s,Fh(c.publicKey)??new Uint8Array))throw new Ah(Hh);let l;try{l=$e(c.wrappedKey)}catch{throw new Ah(Oh)}let u=await zh(a,l,n,{deviceId:o.deviceId,publicKey:o.publicKey,wrapAlg:c.wrapAlg}),d=!1;try{if(await t.save(u,r??null))return d=!0,u;let e=await t.load();if(e&&Y(e.publicKey,u.publicKey))return e;throw e?Error(th):new qm}finally{d||u.privateKey.fill(0)}}finally{a.fill(0)}}async function cg(e,t,n,r,i,a){if(!Yh(i))throw Error(Jh);if(!eg.has(n))throw Error(Bh);let o={wrapAlg:Fd};a&&(await a.stepUp(a.keys.authSecret),o={wrapAlg:gc,wrappedPrivateKey:Qe(Ic(a.keys.userKEK,n.identity.privateKey,n.userID))});let s;await t.noteReset?.(n.identity.publicKey).catch(()=>void 0);let c=t=>e.replaceIdentity({publicKey:Qe(n.identity.publicKey),...t,expectedDeviceId:r,recovery:{wrapAlg:vh,wrappedKey:n.wrappedKey}});try{({deviceId:s}=await c(o).catch(e=>{if(!(e instanceof Bl&&e.code===`device_only_required`))throw e;return c({wrapAlg:Fd})}))}catch(t){let r;try{r=await e.myIdentity()}catch{throw new Qh(t)}let i=r&&Fh(r.publicKey);if(!r||!i||!Y(i,n.identity.publicKey))throw t;s=r.deviceId}eg.delete(n);let l={...n.identity,deviceId:s};return{identity:l,kept:await t.save(l)}}function lg(e,t){return e instanceof Bl?e.status===429||e.code===`rate_limited`?{message:t===`reset your encryption key`?Kh:Wh}:e.code===`sso_step_up_required`?{message:`Confirm with KySignOn to ${t}. The confirmation window did not finish; allow pop-ups for this site and try again.`}:e.code===`step_up_required`?{message:`Confirm your password to ${t}.`}:e.code===`already_exists`?{message:`Your encryption key changed in another tab or browser. Reload and check before trying again.`}:e.code===`identity_exists`?{message:`Start the reset again: a new key is needed.`}:e.code===`unauthenticated`?{message:`Your session ended or the password was wrong. Sign in again.`}:e.code===`step_up_pending`||e.code===`sso_sign_in_required`||e.code===`password_change_required`?_h(e,t):{message:`Could not ${t}. Try again.`}:e instanceof TypeError?{message:`Could not reach KyNotes to ${t}. Check the connection and try again.`}:e instanceof Error?{message:e.message}:{message:`Could not ${t}.`}}var ug=`Save a recovery code so you can get your encryption key back if no browser holds it and your password cannot open it.`,dg=`A recovery code gets your encryption key back when no browser holds it and your password cannot open it: after an administrator resets your password, or always on a single sign-on account, whose key has no password copy. KyNotes shows it once and cannot show it again. The server keeps only a copy of your key locked with the code, which it cannot open.`,fg=`Write this code down or store it in a password manager. Anyone who has it and can sign in as you can read your notebooks.`,pg=`If no browser holds your key and your password cannot open it, this code is the only way back to your notebooks.`,mg=`Recovery code saved. Keep it somewhere safe.`,hg=`New recovery code saved. Your previous code no longer works here, but older server backups still hold a copy it opens: if it may have leaked, reset your encryption key instead.`,gg=`No other browser holds your key? Enter your recovery code.`,_g=`This browser holds your encryption key, so you do not need a reset to get it back: save a recovery code instead. Reset only if a browser that holds your key was lost or stolen.`,vg=`Only if no browser holds your key and you have no recovery code. Your personal notebooks are lost.`,yg=`Your encryption key was reset. Team owners share their notebooks' keys with you again when they next open them.`,bg=`Your encryption key was reset, but this browser could not keep it (site storage is blocked). Restore it with your new recovery code in a browser that allows site storage.`,xg=`That password is not right. Nothing was reset.`,Sg=`The reset did not go through. Keep the code you saved: trying again sends the same new key.`,Cg=`That group does not match. Check your saved copy, or go back to see the code again.`,wg=e=>e?`Confirm it is you in the KySignOn window that opens.`:`Confirming it is you…`,Tg={autoComplete:`off`,spellCheck:!1,autoCapitalize:`characters`,autoCorrect:`off`,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-bwignore":`true`,"data-form-type":`other`},Eg=e=>e.normalize(`NFKC`).toUpperCase().replace(/[^0-9A-Z]/g,``).slice(0,28).match(/.{1,4}/g)?.join(`-`)??``,Dg=e=>`KyNotes recovery code\n\n${e}\n\n${fg}\n${pg}\n`;function Og(){document.body.classList.add(`print-recovery`);try{window.print()}finally{document.body.classList.remove(`print-recovery`)}}async function kg(e,t,n){try{Nh(t).fill(0)}catch(e){return e.message}try{await n(e);return}catch(e){return lg(e,`restore your key`).message}}async function Ag(e,t){let n=await e.derive(t);try{return await e.stepUp(n.authSecret),n}catch(e){return n.userKEK.fill(0),e.code===`unauthenticated`?xg:lg(e,Gh).message}}function jg(e){let[t,n]=(0,X.useState)(),r=(0,X.useRef)(void 0),i=(t=!1)=>{e&&!t&&r.current?.identity.privateKey.fill(0),r.current=void 0,n(void 0)};return(0,X.useEffect)(()=>()=>{i()},[]),{prepared:t,hold:e=>{i(),r.current=e,n(e)},forget:i,showAgain:()=>{r.current&&(r.current=rg(r.current),n(r.current))}}}function Mg({code:e,onNext:t}){return(0,Q.jsxs)(`div`,{className:`recovery-step recovery-sheet`,children:[(0,Q.jsx)(`p`,{className:`config-muted`,children:dg}),(0,Q.jsx)(`code`,{className:`recovery-code`,"aria-label":`Recovery code`,children:e}),(0,Q.jsxs)(`p`,{className:`config-muted`,children:[fg,` KyNotes shows it once.`]}),(0,Q.jsx)(`p`,{role:`note`,children:(0,Q.jsx)(`strong`,{children:pg})}),(0,Q.jsxs)(`div`,{className:`recovery-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`quiet`,onClick:Og,children:`Print`}),(0,Q.jsx)(`button`,{type:`button`,className:`quiet`,onClick:()=>Tp(`kynotes-recovery-code.txt`,Dg(e),`text/plain`),children:`Download as a text file`}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,children:`I saved it`})]})]})}function Ng({prepared:e,onBack:t,onConfirmed:n}){let[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``);return(0,Q.jsxs)(`form`,{className:`recovery-step`,onSubmit:t=>{t.preventDefault(),ig(e,r)?n():o(Cg)},children:[(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:Xh(e.check)}),(0,Q.jsx)(`input`,{name:`recovery-group`,value:r,onChange:e=>i(e.target.value.toUpperCase()),maxLength:8,...Tg})]}),a&&(0,Q.jsx)(`p`,{role:`alert`,children:a}),(0,Q.jsx)(`button`,{type:`button`,className:`quiet`,onClick:t,children:`Show the code again`}),(0,Q.jsx)(`button`,{children:`Save recovery code`})]})}function Pg({userID:e,held:t,live:n,sso:r,stepUp:i,autoStart:a=!1,onSaved:o}){let{prepared:s,hold:c,forget:l,showAgain:u}=jg(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``);async function h(){m(``);let n=await t();n?(c(await ng(n,e)),f(!1)):m(`This browser does not hold your encryption key.`)}(0,X.useEffect)(()=>{a&&h()},[a]);async function g(){try{let e=await t();if(!e)throw Error(`This browser does not hold your encryption key.`);m(wg(r)),await i(),await og(Tu,s,e,n?.recoveryId??``),m(n?.recoveryId?hg:mg),l(),o()}catch(e){m(lg(e,`save a recovery code`).message),e.code===`already_exists`&&l()}}return(0,Q.jsxs)(`section`,{id:`recovery`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Recovery code`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:n?.recoveryId?`You saved a recovery code on ${new Date(n.recoverySetAt??``).toLocaleDateString()}.`:ug}),!s&&(0,Q.jsx)(`button`,{onClick:()=>void h(),children:n?.recoveryId?`Replace recovery code`:`Create recovery code`}),s&&!d&&(0,Q.jsx)(Mg,{code:s.code,onNext:()=>f(!0)}),s&&d&&(0,Q.jsx)(Ng,{prepared:s,onBack:()=>{u(),f(!1)},onConfirmed:g}),p&&(0,Q.jsx)(`p`,{role:`status`,children:p})]})}function Fg({userID:e,sso:t,store:n,stepUp:r,onRestored:i}){let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1);return(0,Q.jsxs)(`form`,{id:`recovery-restore`,className:`config-card`,onSubmit:s=>{s.preventDefault(),u(!0),c(`Checking…`),(async()=>{let s,l=await kg(r,a,async r=>{s=await sg(Tu,n,e,a,async()=>{c(wg(t)),await r()})});u(!1),l?c(l):(o(``),c(``),i(s))})()},children:[(0,Q.jsx)(`h2`,{children:`Use a recovery code`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:gg}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Recovery code`}),(0,Q.jsx)(`input`,{name:`recovery-code`,value:a,onChange:e=>o(Eg(e.target.value)),...Tg})]}),(0,Q.jsx)(`button`,{disabled:l||!a.trim(),children:`Restore`}),s&&(0,Q.jsx)(`p`,{role:`status`,children:s})]})}function Ig({userID:e,store:t,live:n,held:r,stepUp:i,exportWaiting:a,onReset:o,password:s,startOpen:c=!1}){let{prepared:l,hold:u,forget:d,showAgain:f}=jg(!0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(c),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(void 0),E=()=>{T.current?.userKEK.fill(0),T.current=void 0};(0,X.useEffect)(()=>()=>{E()},[]);function D(){d(),E(),m(!1),g(!1),v(``),b(``)}async function O(){try{let e=await a();w(e?`Exported ${e} unsent edit${e===1?``:`s`}.`:`This browser has no unsent edits to export.`)}catch{w(`Could not export the unsent edits.`)}}async function k(){if(Yh(_)){w(``);try{if(s){E();let e=await Ag(s,y);if(b(``),typeof e==`string`){w(e);return}T.current=e}u(await ng(Tc(),e)),S(!1)}catch(e){w(lg(e,Gh).message)}}}async function A(){let e=T.current;try{w(wg(!s)),e||await i();let{identity:r,kept:a}=await cg(Tu,t,l,n?.deviceId??``,_,e&&{keys:e,stepUp:s.stepUp});w(a?yg:bg),m(!1),d(!0),E(),g(!1),o(r)}catch(e){let t=lg(e,Gh).message;w(e instanceof Error&&e.name===`ResetUncertainError`?t:`${t} ${Sg}`),m(!0)}}return(0,Q.jsxs)(`section`,{id:`identity-reset`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Reset encryption key`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:r?_g:vg}),!h&&(0,Q.jsx)(`button`,{className:`secondary danger`,onClick:()=>g(!0),children:`Reset encryption key…`}),h&&!l&&(0,Q.jsxs)(`form`,{className:`recovery-step`,onSubmit:e=>{e.preventDefault(),k()},children:[(0,Q.jsx)(`p`,{role:`alert`,children:`Reset your encryption key? Your personal notebooks become unreadable for good, on every browser, and so does any team notebook whose keys no other owner or admin holds. Unsent edits waiting for a notebook's keys are never sent afterwards: export them first. Team owners must share each team's keys with you again, and colleagues are asked to trust your new key. Type RESET to continue.`}),(0,Q.jsx)(`button`,{type:`button`,className:`quiet`,onClick:()=>void O(),children:`Export unsent edits first`}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsxs)(`span`,{children:[`Type `,`RESET`,` to confirm`]}),(0,Q.jsx)(`input`,{name:`reset-phrase`,value:_,onChange:e=>v(e.target.value),...Tg})]}),s&&(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Your password`}),(0,Q.jsx)(`input`,{name:`reset-password`,type:`password`,autoComplete:`current-password`,value:y,onChange:e=>b(e.target.value)})]}),(0,Q.jsx)(`button`,{type:`button`,className:`quiet`,onClick:D,children:`Cancel`}),(0,Q.jsx)(`button`,{className:`secondary danger`,disabled:!Yh(_)||!!s&&!y,children:`Continue`})]}),l&&!x&&(0,Q.jsx)(Mg,{code:l.code,onNext:()=>S(!0)}),l&&x&&!p&&(0,Q.jsx)(Ng,{prepared:l,onBack:()=>{f(),S(!1)},onConfirmed:A}),l&&p&&(0,Q.jsxs)(`div`,{className:`recovery-actions`,children:[(0,Q.jsx)(`button`,{className:`secondary danger`,onClick:()=>void A(),children:`Try the reset again`}),(0,Q.jsx)(`button`,{className:`quiet`,onClick:D,children:`Cancel`})]}),C&&(0,Q.jsx)(`p`,{role:`status`,children:C})]})}var Lg=Array.from({length:256},(e,t)=>{let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function Rg(e){let t=4294967295;for(let n of e)t=Lg[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function zg(e,t=new Date){if(e.length>65535)throw Error(`Too many files for one zip`);let n=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1,r=Math.max(0,t.getFullYear()-1980)<<9|t.getMonth()+1<<5|t.getDate(),i=new TextEncoder,a=[],o=[],s=0;for(let t of e){let e=i.encode(t.path),c=Rg(t.data),l=t.data.length;if(s+30+e.length+l>4294967295)throw Error(`Export is larger than 4 GiB`);let u=new Uint8Array(30+e.length),d=new DataView(u.buffer);d.setUint32(0,67324752,!0),d.setUint16(4,20,!0),d.setUint16(6,2048,!0),d.setUint16(10,n,!0),d.setUint16(12,r,!0),d.setUint32(14,c,!0),d.setUint32(18,l,!0),d.setUint32(22,l,!0),d.setUint16(26,e.length,!0),u.set(e,30);let f=new Uint8Array(46+e.length),p=new DataView(f.buffer);p.setUint32(0,33639248,!0),p.setUint16(4,20,!0),p.setUint16(6,20,!0),p.setUint16(8,2048,!0),p.setUint16(12,n,!0),p.setUint16(14,r,!0),p.setUint32(16,c,!0),p.setUint32(20,l,!0),p.setUint32(24,l,!0),p.setUint16(28,e.length,!0),p.setUint32(42,s,!0),f.set(e,46),o.push(f),a.push(u,t.data.slice().buffer),s+=u.length+l}let c=o.reduce((e,t)=>e+t.length,0),l=new Uint8Array(22),u=new DataView(l.buffer);return u.setUint32(0,101010256,!0),u.setUint16(8,e.length,!0),u.setUint16(10,e.length,!0),u.setUint32(12,c,!0),u.setUint32(16,s,!0),new Blob([...a,...o,l],{type:`application/zip`})}function Bg(e,t){return t?e.filter(e=>!t.has(e.containerID)):[]}function Vg(e,t,n){let r=e.filter(e=>e.owner===n),i=new Set(Bg(r,t));return r.filter(e=>e.gone||i.has(e))}async function Hg(e,t){let n=[],r=0;for(let i of e){let e=await t(i).catch(()=>void 0);e===void 0?r+=1:n.push({id:i.id,notebook:i.containerID,updatedAt:i.updatedAt,content:e})}return{json:JSON.stringify(n,null,2),unreadable:r}}async function Ug(e,t,n,r){for(let i of e){if(i.owner!==t||i.keyGeneration!==0||i.previousKey)continue;let e=await n(i).catch(()=>void 0);await r(i,{...i,...e&&{payload:e},previousKey:!0})}}async function Wg(e,t,n,r){let i=[];for(let a of e)a.owner===t&&(a.previousKey||n&&a.keyGeneration===0&&!await r(a))&&i.push(a);return i}var Gg=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Kg=n(((e,t)=>{t.exports=Gg()})),qg=n((e=>{var t=Il();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=qg()})),Yg=n((e=>{var t=Kg(),n=Il(),r=Jg();function i(e){var t=`https://react.dev/errors/`+e;if(1le||(e.current=ce[le],ce[le]=null,le--)}function fe(e,t){le++,ce[le]=e.current,e.current=t}var pe=ue(null),me=ue(null),he=ue(null),ge=ue(null);function _e(e,t){switch(fe(he,t),fe(me,e),fe(pe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=cp(t),e=lp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}de(pe),fe(pe,e)}function ve(){de(pe),de(me),de(he)}function ye(e){var t=e.memoizedState;t!==null&&(ah._currentValue=t.memoizedState,fe(ge,e)),t=pe.current;var n=lp(t,e.type);t!==n&&(fe(me,e),fe(pe,n))}function be(e){me.current===e&&(de(pe),de(me)),ge.current===e&&(de(ge),ah._currentValue=se)}var xe,Se;function Ce(e){if(xe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);xe=t&&t[1]||``,Se=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{we=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ce(n):``}function Ee(e,t){switch(e.tag){case 26:case 27:case 5:return Ce(e.type);case 16:return Ce(`Lazy`);case 13:return e.child!==t&&t!==null?Ce(`Suspense Fallback`):Ce(`Suspense`);case 19:return Ce(`SuspenseList`);case 0:case 15:return Te(e.type,!1);case 11:return Te(e.type.render,!1);case 1:return Te(e.type,!0);case 31:return Ce(`Activity`);case 30:return Ce(`ViewTransition`);default:return``}}function De(e){try{var t=``,n=null;do t+=Ee(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var Oe=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ae=t.unstable_cancelCallback,je=t.unstable_shouldYield,Me=t.unstable_requestPaint,Ne=t.unstable_now,Pe=t.unstable_getCurrentPriorityLevel,Fe=t.unstable_ImmediatePriority,Ie=t.unstable_UserBlockingPriority,Le=t.unstable_NormalPriority,Re=t.unstable_LowPriority,ze=t.unstable_IdlePriority,Be=t.log,Ve=t.unstable_setDisableYieldValue,He=null,Ue=null;function We(e){if(typeof Be==`function`&&Ve(e),Ue&&typeof Ue.setStrictMode==`function`)try{Ue.setStrictMode(He,e)}catch{}}var Ge=Math.clz32?Math.clz32:Je,Ke=Math.log,qe=Math.LN2;function Je(e){return e>>>=0,e===0?32:31-(Ke(e)/qe|0)|0}var Ye=256,Xe=262144,Ze=4194304;function Qe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function $e(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Qe(n))):i=Qe(o):i=Qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Qe(n))):i=Qe(o)):i=Qe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function et(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function at(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ot(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=rr),or=` `,sr=!1;function cr(e,t){switch(e){case`keyup`:return tr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function lr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ur=!1;function dr(e,t){switch(e){case`compositionend`:return lr(t);case`keypress`:return t.which===32?(sr=!0,or):null;case`textInput`:return e=t.data,e===or&&sr?null:e;default:return null}}function fr(e,t){if(ur)return e===`compositionend`||!nr&&cr(e,t)?(e=wn(),Cn=Sn=xn=null,ur=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Fr(n)}}function Lr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Lr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Rr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Pr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pr(e.document)}return t}function zr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Br=vn&&`documentMode`in document&&11>=document.documentMode,Vr=null,Hr=null,Ur=null,Wr=!1;function Gr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Wr||Vr==null||Vr!==Pr(r)||(r=Vr,`selectionStart`in r&&zr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ur&&Nr(Ur,r)||(Ur=r,r=Gf(Hr,`onSelect`),0>=o,i-=o,Vi=1<<32-Ge(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),K&&Ui(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),K&&Ui(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return K&&Ui(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),K&&Ui(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),Qa(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===L&&Ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Qa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Oi(o.props.children,e.mode,c,o.key),Qa(c,o),c.return=e,e=c):(c=Di(o.type,o.key,o.props,null,e.mode,c),Qa(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=ji(o,e.mode,c),c.return=e,e=c}return s(e);case L:return o=Ga(o),_(e,r,o,c)}if(oe(o))return h(e,r,o,c);if(B(o)){if(l=B(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,Za(o),c);if(o.$$typeof===M)return _(e,r,_a(e,o),c);$a(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ki(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Xa=0;var i=_(e,t,n,r);return Ya=null,i}catch(t){if(t===za||t===Va)throw t;var a=Ci(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var to=eo(!0),no=eo(!1),ro=!1;function io(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ao(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function oo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function so(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ku&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=bi(e),yi(e,null,n),t}return gi(e,r,t,n),bi(e)}function co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}function lo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var uo=!1;function fo(){if(uo){var e=Aa;if(e!==null)throw e}}function po(e,t,n,r){uo=!1;var i=e.updateQueue;ro=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Yu&f)===f:(r&f)===f){f!==0&&f===q&&(uo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:ro=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),rd|=o,e.lanes=o,e.memoizedState=d}}function mo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function ho(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=V.T,s={};s.types=o===null?null:o.types,V.T=s,nc(e,!1,t,n);try{var c=i(),l=V.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?tc(e,t,Na(c,r),Od(e)):tc(e,t,r,Od(e))}catch(n){tc(e,t,{then:function(){},status:`rejected`,reason:n},Od())}finally{H.p=a,o!==null&&s.types!==null&&(o.types=s.types),V.T=o}}function Gs(){}function Ks(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=qs(e).queue;Ws(e,a,t,se,n===null?Gs:function(){return Js(e),n(r)})}function qs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rs,lastRenderedState:se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rs,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Js(e){var t=qs(e);t.next===null&&(t=e.alternate.memoizedState),tc(e,t.next.queue,{},Od())}function Ys(){return ga(ah)}function Xs(){return Qo().memoizedState}function Zs(){return Qo().memoizedState}function Qs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Od();e=oo(n);var r=so(t,e,n);r!==null&&(jd(r,t,n),co(r,t,n)),t={cache:Ca()},e.payload=t;return}t=t.return}}function $s(e,t,n){var r=Od();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},rc(e)?ic(t,n):(n=_i(e,t,n,r),n!==null&&(jd(n,e,r),ac(n,t,r)))}function ec(e,t,n){tc(e,t,n,Od())}function tc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(rc(e))ic(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Mr(s,o))return gi(e,t,i,0),qu===null&&hi(),!1}catch{}if(n=_i(e,t,i,r),n!==null)return jd(n,e,r),ac(n,t,r),!0}return!1}function nc(e,t,n,r){if(r={lane:2,revertLane:jf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},rc(e)){if(t)throw Error(i(479))}else t=_i(e,n,r,2),t!==null&&jd(t,e,2)}function rc(e){var t=e.alternate;return e===J||t!==null&&t===J}function ic(e,t){Io=Fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ac(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ct(e,n)}}var oc={readContext:ga,use:ts,useCallback:Ho,useContext:Ho,useEffect:Ho,useImperativeHandle:Ho,useLayoutEffect:Ho,useInsertionEffect:Ho,useMemo:Ho,useReducer:Ho,useRef:Ho,useState:Ho,useDebugValue:Ho,useDeferredValue:Ho,useTransition:Ho,useSyncExternalStore:Ho,useId:Ho,useHostTransitionStatus:Ho,useFormState:Ho,useActionState:Ho,useOptimistic:Ho,useMemoCache:Ho,useCacheRefresh:Ho,useEffectEvent:Ho},sc={readContext:ga,use:ts,useCallback:function(e,t){return Zo().memoizedState=[e,t===void 0?null:t],e},useContext:ga,useEffect:js,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ks(4194308,4,Ls.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ks(4194308,4,e,t)},useInsertionEffect:function(e,t){ks(4,2,e,t)},useMemo:function(e,t){var n=Zo();t=t===void 0?null:t;var r=e();if(Lo){We(!0);try{e()}finally{We(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Zo();if(n!==void 0){var i=n(t);if(Lo){We(!0);try{n(t)}finally{We(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=$s.bind(null,J,e),[r.memoizedState,e]},useRef:function(e){var t=Zo();return e={current:e},t.memoizedState=e},useState:function(e){e=ps(e);var t=e.queue,n=ec.bind(null,J,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:zs,useDeferredValue:function(e,t){return Hs(Zo(),e,t)},useTransition:function(){var e=ps(!1);return e=Ws.bind(null,J,e.queue,!0,!1),Zo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=J,a=Zo();if(K){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),qu===null)throw Error(i(349));Yu&127||cs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,js(us.bind(null,r,o,e),[e]),r.flags|=2048,Ds(9,{destroy:void 0},ls.bind(null,r,o,n,t),null),n},useId:function(){var e=Zo(),t=qu.identifierPrefix;if(K){var n=Hi,r=Vi;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ro++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[mt]=t,o[ht]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(ep(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&il(t)}}return ll(t),t.subtreeFlags&=-33554433,al(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&il(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=he.current,na(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ji,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[mt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Zf(e.nodeValue,n)),e||$i(t,!0)}else e=sp(e).createTextNode(r),e[mt]=t,t.stateNode=e}return ll(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=na(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[mt]=t}else ra(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),e=!1}else n=ia(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Do(t),t):(Do(t),null);if(t.flags&128)throw Error(i(558))}return ll(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=na(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[mt]=t}else ra(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;ll(t),a=!1}else a=ia(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Do(t),t):(Do(t),null)}return Do(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),sl(t,t.updateQueue),ll(t),null);case 4:return ve(),e===null&&Vf(t.stateNode.containerInfo),t.flags|=67108864,ll(t),null;case 10:return ua(t.type),ll(t),null;case 19:if(Ao(t),r=t.memoizedState,r===null)return ll(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)cl(r,!1);else{if(nd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=jo(e),o!==null){for(t.flags|=128,cl(r,!1),e=o.updateQueue,t.updateQueue=e,sl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ei(n,e),n=n.sibling;return ko(t,Oo.current&1|2),K&&Ui(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ne()>pd&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=jo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,sl(t,e),cl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!K)return ll(t),null}else 2*Ne()-r.renderingStartTime>pd&&n!==536870912&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ne(),e.sibling=null,o=Oo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||K?ko(t,o):(n=o,fe(xo,t),fe(Oo,n),So===null&&(So=t)),K&&Ui(t,r.treeForkCount),e}return ll(t),null;case 22:case 23:return Do(t),bo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(ll(t),t.subtreeFlags&6&&(t.flags|=8192)):ll(t),n=t.updateQueue,n!==null&&sl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&de(Fa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ua(Sa),ll(t),null;case 25:return null;case 30:return t.flags|=33554432,ll(t),null}throw Error(i(156,t.tag))}function dl(e,t){switch(Ki(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ua(Sa),ve(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return be(t),null;case 31:if(t.memoizedState!==null){if(Do(t),t.alternate===null)throw Error(i(340));ra()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Do(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ra()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ao(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ve(),null;case 10:return ua(t.type),null;case 22:case 23:return Do(t),bo(),e!==null&&de(Fa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ua(Sa),null;case 25:return null;default:return null}}function fl(e,t){switch(Ki(t),t.tag){case 3:ua(Sa),ve();break;case 26:case 27:case 5:be(t);break;case 4:ve();break;case 31:t.memoizedState!==null&&Do(t);break;case 13:Do(t);break;case 19:Ao(t);break;case 10:ua(t.type);break;case 22:case 23:Do(t),bo(),e!==null&&de(Fa);break;case 24:ua(Sa)}}function pl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){uf(t,t.return,e)}}function ml(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){uf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){uf(t,t.return,e)}}function hl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ho(t,n)}catch(t){uf(e,e.return,t)}}}function gl(e,t,n){n.props=mc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){uf(e,t,n)}}function _l(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=ci(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Mp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Np(e);f(e.child,!1,Xp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){uf(e,t,n)}}function vl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){uf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){uf(e,t,n)}else n.current=null}}function yl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),ep(r,t,n),r[mt]=e,G(r),t=r;break a;case`link`:if(o=Um(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Ir(s,h),v=Ir(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,V.T=null,n=xd,xd=null;var o=_d,s=yd;if(gd=0,vd=_d=null,yd=0,Ku&6)throw Error(i(331));var c=Ku;if(Ku|=4,Vu(o.current),Nu(o,o.current,s,n),Ku=c,wf(0,!1),Ue&&typeof Ue.onPostCommitFiberRoot==`function`)try{Ue.onPostCommitFiberRoot(He,o)}catch{}return!0}finally{H.p=a,V.T=r,Q(e,t)}}function lf(e,t,n){t=Ni(n,t),t=bc(e.stateNode,t,2),e=so(e,t,2),e!==null&&(at(e,2),Cf(e))}function uf(e,t,n){if(e.tag===3)lf(e,e,n);else for(;t!==null;){if(t.tag===3){lf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(hd===null||!hd.has(r))){e=Ni(n,e),n=xc(2),r=so(t,n,2),r!==null&&(Sc(n,r,t,e),at(r,2),Cf(r));break}}t=t.return}}function df(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Gu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ed=!0,i.add(n),e=ff.bind(null,e,t,n),t.then(e,e))}function ff(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,qu===e&&(Yu&n)===n&&(nd===4||nd===3&&(Yu&62914560)===Yu&&300>Ne()-dd?Ku&2?ad|=n:Rd(e,0):ad|=n,sd===Yu&&(sd=0)),Cf(e)}function pf(e,t){t===0&&(t=rt()),e=vi(e,t),e!==null&&(at(e,t),Cf(e))}function mf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),pf(e,n)}function hf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),pf(e,n)}function gf(e,t){return ke(e,t)}var _f=null,vf=null,yf=!1,bf=!1,xf=!1,Sf=0;function Cf(e){e!==vf&&e.next===null&&(vf===null?_f=vf=e:vf=vf.next=e),bf=!0,yf||(yf=!0,Af())}function wf(e,t){if(!xf&&bf){xf=!0;do for(var n=!1,r=_f;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ge(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,kf(r,a))}else a=Yu,a=$e(r,r===qu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||et(r,a)||(n=!0,kf(r,a))}r=r.next}while(n);xf=!1}}function Tf(){Ef()}function Ef(){bf=yf=!1;var e=0;Sf!==0&&pp()&&(e=Sf);for(var t=Ne(),n=null,r=_f;r!==null;){var i=r.next,a=Df(r,t);a===0?(r.next=null,n===null?_f=i:n.next=i,i===null&&(vf=n)):(n=r,(e!==0||a&3)&&(bf=!0)),r=i}gd!==0&&gd!==5||wf(e,!1),Sf!==0&&(Sf=0)}function Df(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&rp(d)&&(c=c.responseEnd,o+=u*(cZm){s.length=o;break}f=new Promise(kp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Cm(e,t,n){var r=Sm;if(r&&typeof t==`string`&&t){var i=qt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),_m.has(i)||(_m.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ep(t,`link`,e),G(t),r.head.appendChild(t)))}}function wm(e){ym.D(e),Cm(`dns-prefetch`,e,null)}function Tm(e,t){ym.C(e,t),Cm(`preconnect`,e,t)}function Em(e,t,n){ym.L(e,t,n);var r=Sm;if(r&&e&&t){var i=`link[rel="preload"][as="`+qt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+qt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+qt(n.imageSizes)+`"]`)):i+=`[href="`+qt(e)+`"]`;var a=i;switch(t){case`style`:a=Mm(e);break;case`script`:a=Im(e)}if(!(gm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),gm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Nm(a))||t===`script`&&r.querySelector(Lm(a))))){var o=r.createElement(`link`);ep(o,`link`,e),t===`style`&&(o[W]=!0,o.onload=o.onerror=function(){Dt(o)}),G(o),r.head.appendChild(o)}}}function Dm(e,t){ym.m(e,t);var n=Sm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+qt(r)+`"][href="`+qt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Im(e)}if(!gm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),gm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Lm(a)))return}r=n.createElement(`link`),ep(r,`link`,e),G(r),n.head.appendChild(r)}}}function Om(e,t,n){ym.S(e,t,n);var r=Sm;if(r&&e){var i=Et(r).hoistableStyles,a=Mm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Nm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=gm.get(a))&&Bm(e,n);var c=o=r.createElement(`link`);G(c),ep(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,zm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function km(e,t){ym.X(e,t);var n=Sm;if(n&&e){var r=Et(n).hoistableScripts,i=Im(e),a=r.get(i);a||(a=n.querySelector(Lm(i)),a||(e=w({src:e,async:!0},t),(t=gm.get(i))&&Vm(e,t),a=n.createElement(`script`),G(a),ep(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Am(e,t){ym.M(e,t);var n=Sm;if(n&&e){var r=Et(n).hoistableScripts,i=Im(e),a=r.get(i);a||(a=n.querySelector(Lm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=gm.get(i))&&Vm(e,t),a=n.createElement(`script`),G(a),ep(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jm(e,t,n,r){var a=(a=he.current)?vm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Mm(n.href),t=Et(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Mm(n.href);var o=Et(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Nm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=gm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},gm.set(e,o)),Fm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Im(n),t=Et(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Mm(e){return`href="`+qt(e)+`"`}function Nm(e){return`link[rel="stylesheet"][`+e+`]`}function Pm(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Fm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[W]){r.loading=1;return}}else t=e.createElement(`link`),t[W]=!0,t.onload=t.onerror=Dt.bind(null,t),ep(t,`link`,n),G(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Im(e){return`[src="`+qt(e)+`"]`}function Lm(e){return`script[async]`+e}function Rm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+qt(n.href)+`"]`);if(r)return t.instance=r,G(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),G(r),ep(r,`style`,a),zm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Mm(n.href);var o=e.querySelector(Nm(a));if(o)return t.state.loading|=4,t.instance=o,G(o),o;r=Pm(n),(a=gm.get(a))&&Bm(r,a),o=(e.ownerDocument||e).createElement(`link`),G(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ep(o,`link`,r),t.state.loading|=4,zm(o,n.precedence,e),t.instance=o;case`script`:return o=Im(n.src),(a=e.querySelector(Lm(o)))?(t.instance=a,G(a),a):(r=n,(a=gm.get(o))&&(r=w({},n),Vm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),G(a),ep(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,zm(r,n.precedence,e));return t.instance}function zm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Gm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Km(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function qm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Jm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Ym(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Jm(t),e.suspenseyImages.push(t)),e=th.bind(e),t.decode().then(e,e))}function Xm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Mm(r.href),a=t.querySelector(Nm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=eh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,G(a);return}a=t.ownerDocument||t,r=Pm(r),(i=gm.get(i))&&Bm(r,i),a=a.createElement(`link`),G(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ep(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=eh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Zm=0;function Qm(e,t){return e.stylesheets&&e.count===0&&rh(e,e.stylesheets),0Zm?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function $m(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)rh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function eh(){this.count--,$m(this)}function th(){this.imgCount--,$m(this)}var nh=null;function rh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,nh=new Map,t.forEach(ih,e),nh=null,eh.call(e))}function ih(e,t){if(!(t.state.loading&4)){var n=nh.get(e);if(n)var r=n.get(null);else{n=new Map,nh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Yg()})),Zg=Xg(),Qg=e=>e.slice(-6).toUpperCase(),$g=2e3,e_=`This link request ended: it was cancelled on the other browser or expired. Start again.`,t_=`Linking cancelled: the codes differed. Someone may be interfering; start again on both browsers.`,n_=`Request cancelled.`,r_=e=>e instanceof Ym||e instanceof Bl&&e.code===`not_found`,i_=(e,t=!1)=>void Nu(e,t).catch(()=>void 0);function a_({status:e,set:t}){if(!e)return null;let n=e.cancel;return(0,Q.jsxs)(`p`,{role:`status`,className:`link-status`,children:[e.message,n&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>void n().then(()=>t(void 0),e=>t(_h(e))),children:`Cancel the KySignOn confirmation`})]})]})}function o_({userID:e,canKeep:t,store:n,onLinked:r}){let[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(),u=(0,X.useRef)(0),d=(0,X.useRef)({}),f={create:Du,collect:Km,reveal:Au,myIdentity:bu};function p(e,t=!1){u.current+=1;let{attempt:n}=d.current;d.current={},a(void 0),s(!1),l(e?{message:e}:void 0),n&&(Zm(n),i_(n.id,t))}(0,X.useEffect)(()=>{let e=()=>p(void 0,!0);return addEventListener(`pagehide`,e),()=>{removeEventListener(`pagehide`,e),p()}},[]);async function m(){let{attempt:t,bundle:i,confirmation:o}=d.current;if(t&&i&&o){u.current+=1,d.current={},a(void 0),s(!1);try{r(await dh(t,i,o,e,f,n))}catch(e){i_(t.id),l(_h(e))}}}async function h(){p();let r=u.current;try{if(await nh(f,n)){l({message:th});return}let i=await rh(f,t,e);if(u.current!==r){Zm(i),i_(i.id);return}d.current.attempt=i,a(i);let o=await uh(f,i,e,()=>u.current===r,a);if(!o)return;d.current.bundle=o,await m()}catch(e){if(u.current!==r)return;p(),l(r_(e)?{message:e_}:_h(e))}}function g(){i?.code&&(d.current.confirmation=Gp(i.id,i.code),s(!0),m())}return(0,Q.jsxs)(`section`,{id:`link-this-browser`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Link this browser`}),!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`config-muted`,children:`This browser does not hold your encryption key, so it cannot open team notebooks. A browser where you already use KyNotes can send it here; KyNotes only relays it encrypted.`}),(0,Q.jsx)(`button`,{onClick:()=>void h(),children:`Link this browser`})]}),i&&!i.code&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`On a browser that holds your key, open Settings → Link another browser and approve request `,(0,Q.jsx)(`code`,{className:`link-code`,children:Qg(i.id)}),`. Waiting…`]}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>p(n_),children:`Cancel`})]}),i?.code&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Check code: `,(0,Q.jsx)(`code`,{className:`check-code`,children:i.code})]}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Type this code on the other browser. Choose Codes match once it accepts the code; if it does not, choose Codes differ.`}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`Waiting for the other browser to send the key…`}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>p(n_),children:`Cancel`})]}):(0,Q.jsxs)(`div`,{className:`link-actions`,children:[(0,Q.jsx)(`button`,{onClick:g,children:`Codes match`}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>p(t_),children:`Codes differ`})]})]}),(0,Q.jsx)(a_,{status:c,set:l})]})}function s_({userID:e,held:t,stepUp:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(void 0),m=(0,X.useRef)(!1),h=(0,X.useRef)(!1),[g,_]=(0,X.useState)(!1),v=(0,X.useRef)(!1),y=e=>{p.current=e,o(e)};function b(e,t){let n=p.current;n&&Zm(n),y(void 0),c(``),u(t?{message:t}:void 0),e&&i_(e)}(0,X.useEffect)(()=>{v.current=!0;let t=!1,n,r=async()=>{try{let n=await Ou();if(t)return;i(n);let r=p.current;if(r&&!m.current){let t=n.find(e=>e.id===r.id);t?r.newcomerKey||y(ph(r,t,e)):(Zm(r),y(void 0),c(``),u({message:e_}))}}catch(e){t||(e instanceof Jm||e instanceof Ym?b(p.current?.id,e.message):u(_h(e)))}t||(n=setTimeout(()=>void r(),$g))};n=setTimeout(()=>void r(),0);let a=e=>{let t=p.current;p.current=void 0,t&&(Zm(t),m.current||i_(t.id,e))},s=()=>{a(!0),o(void 0),c(``)};return addEventListener(`pagehide`,s),()=>{t=!0,v.current=!1,clearTimeout(n),removeEventListener(`pagehide`,s),a(!1)}},[e]);async function x(t){if(!(h.current||p.current)){h.current=!0,_(!0),u(void 0),c(``);try{let n=await gh(fh({claim:ku},t,e),()=>v.current&&!p.current,Nu);n&&y(n)}catch(e){v.current&&u(_h(e))}finally{h.current=!1,v.current&&_(!1)}}}function S(e){try{return!!mh(e,s)}catch{return!1}}async function C(){let r=p.current;if(r){u(void 0),m.current=!0,f(!0);try{let i=await t();if(!i){b(r.id,`This browser no longer holds your encryption key.`);return}await hh(r,mh(r,s),i,e,n),y(void 0),c(``),u({message:`Key sent. Finish on the other browser.`})}catch(e){e instanceof Jm||e instanceof Ym||r_(e)?b(r.id,r_(e)?e_:e.message):u(_h(e))}finally{m.current=!1,f(!1)}}}return(0,Q.jsxs)(`section`,{id:`link-devices`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Link another browser`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Approve only a request you started yourself, on a browser in front of you. That browser then shows a check code; type it here to send your key.`}),!a&&(r.length?r.map(e=>(0,Q.jsxs)(`div`,{className:`pin-row`,children:[(0,Q.jsxs)(`span`,{children:[`Request `,(0,Q.jsx)(`code`,{className:`link-code`,children:Qg(e.id)}),` · started `,new Date(e.createdAt).toLocaleTimeString()]}),e.claimed?(0,Q.jsx)(`span`,{className:`config-muted`,children:`Being approved in another tab`}):(0,Q.jsx)(`button`,{disabled:g,onClick:()=>void x(e),children:`Approve…`}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>b(e.id,n_),children:`Not me`})]},e.id)):(0,Q.jsx)(`p`,{className:`config-muted`,children:`No browser is asking to be linked.`})),a&&!a.code&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[`Waiting for request `,(0,Q.jsx)(`code`,{className:`link-code`,children:Qg(a.id)}),` to answer…`]}),(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>b(a.id,n_),children:`Cancel`})]}),a?.code&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Check code shown on the other browser`}),(0,Q.jsx)(`input`,{className:`check-code-input`,value:s,onChange:e=>c(e.currentTarget.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":`true`})]}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Type it from the other browser's screen. If that browser shows no code, or this one does not accept it, choose Codes differ.`}),(0,Q.jsxs)(`div`,{className:`link-actions`,children:[(0,Q.jsx)(`button`,{disabled:d||!S(a),onClick:()=>void C(),children:`Approve — send key`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:d,onClick:()=>b(a.id,t_),children:`Codes differ`})]})]}),(0,Q.jsx)(a_,{status:l,set:u})]})}var c_=e=>e.code,l_=(e,t)=>e.filter((n,r)=>e.findIndex(e=>t(e)===t(n))===r);async function u_(e,t,n,r,i,a,o){let s=n.identity,c=s&&{...s,userId:n.userId},l=s&&{deviceId:s.deviceId,publicKey:Qe(s.publicKey)},u=[],d=async(s,d)=>{let f=await e.container(t),p=await r.loadKeyState(f.id),{rollback:m}=em(f,p),h=Qp(p,f);o?.(f.id,{shared:h.shared,generation:h.generation}),(h.shared!==p.shared||h.generation!==p.generation)&&await r.saveKeyState(f.id,h).catch(()=>!1);let g=await e.envelopes(f.id),_=g,v=await Promise.all((await e.members(f.id)).map(async t=>({...t,identity:t.userId===n.userId&&l?l:await e.userIdentity(t.userId)}))),y=(e,t,n)=>rm({containerID:f.id,envelopes:t,me:c,members:v,pins:e,known:h,held:n??a}),b=e=>(d.saved={containerID:f.id,known:Qp(e.known,f)},e),x=async()=>{let e=await r.load(),t=await y(e,g);return t.fresh.length?(d.saved={containerID:f.id,known:h},{...await y(e,[]),known:h}):b(t)},S=e=>{if(!e.ok)return e.conflicts.length?{kind:`untrusted`,members:v.filter(t=>e.conflicts.includes(t.userId)).map(e=>gi(e.username,e.userId))}:{kind:`pins-unsaved`}},C=!1,w=(e,t=g)=>{if(!c)return{kind:`idle`};let r=um({container:f,me:n.userId,members:v,envelopes:t,ring:e.ring,recoverable:n.recoverable}),i=r.kind===`wrap`?r.grants.filter(t=>!e.conflicts.includes(t.generation)):[],a=r.kind===`wrap`?i.length?{kind:`wrap`,grants:i}:{kind:`idle`}:r;return C=!n.canWrap&&(a.kind===`mint`||a.kind===`wrap`),n.canWrap||a.kind===`unrecoverable`?a:{kind:`idle`}},T=e=>(e.kind===`mint`?e.recipients:e.kind===`wrap`?e.grants.map(e=>e.member):[]).filter(e=>e.userId!==n.userId),E=await r.load(),D=await y(E,g);if(m){let e=D.fresh.length?await x():b(D);return{container:f,changed:[],conflicts:e.conflicts,known:Qp(e.known,f),fresh:[],ring:e.ring,plan:{kind:`rollback`},minted:!1,members:v,envelopes:g,deferred:!1}}let O=w(D),k=[],A=(e,t,n=D)=>({container:f,changed:k,conflicts:n.conflicts,known:Qp(n.known,f),fresh:l_([...u,...t],e=>e.userId),members:v,envelopes:_,deferred:C,...e}),j=async(e,t)=>{C=!1;let n=await x();return A({ring:n.ring,plan:e,minted:!1},t,n)};for(;;){let e=l_([...D.changed,...pi(E,T(O)).changed],e=>e.member.userId);if(!e.length)break;if(k.push(...e),await i(e)!==!0)return j({kind:`untrusted`,members:e.map(e=>gi(e.member.username,e.member.userId))},[]);for(let t of e){let e=fi(E,t.member);if(!await r.confirm(e,t.pinned))return j({kind:`pins-unsaved`},[]);E=e.pins}D=await y(E,g),O=w(D)}let M=[...D.fresh],N=D.fresh.length?S(await r.addFresh(D.pins)):void 0;if(N)return j(N,[]);if(b(D),O.kind===`idle`||O.kind===`unrecoverable`)return A({ring:D.ring,plan:O,minted:!1},M);E=D.pins;let P=async e=>{let t=[];for(let{member:n,generation:r,key:i}of e){let e=await dm(n,f.id,r,i,c,E);E=e.pins,M.push(...e.fresh),t.push(e.envelope)}return t},F;if(O.kind===`mint`){let e=fm();F=await P(O.recipients.map(t=>({member:t,generation:f.keyGeneration+1,key:e})))}else F=await P(O.grants.map(e=>({member:e.member,generation:e.generation,key:D.ring.get(e.generation)})));let I=M.length>D.fresh.length?S(await r.addFresh(E)):void 0;if(I)return j(I,D.fresh);try{if(await e.stepUp(),O.kind===`mint`){let t=await e.rotate(f.id,f.keyGeneration,F);f={...f,keyGeneration:t.keyGeneration,sharedGeneration:f.sharedGeneration||t.keyGeneration},d.saved={containerID:f.id,known:Qp(d.saved.known,f)},o?.(f.id,{shared:f.sharedGeneration,generation:f.keyGeneration})}else await e.putEnvelopes(f.id,F)}catch(e){if(c_(e)!==`already_exists`||s>0)throw e;return u.push(...M),`retry`}if(_=[...g,...F],O.kind===`wrap`)return A({ring:D.ring,plan:O,minted:!1},M);let L=b(await y(E,_,D.ring)),R=w(L,_);if(R.kind===`wrap`&&!pi(E,T(R)).changed.length){let t=M.length,n=await P(R.grants.map(e=>({member:e.member,generation:e.generation,key:L.ring.get(e.generation)})));if(!(M.length>t&&S(await r.addFresh(E))))try{await e.stepUp(),await e.putEnvelopes(f.id,n),_=[..._,...n]}catch{}}return A({ring:L.ring,plan:O,minted:!0},M,L)};for(let e=0;;e+=1){let t={},n,i=!1;try{n=await d(e,t)}finally{t.saved&&(i=await r.saveKeyState(t.saved.containerID,t.saved.known).catch(()=>!1))}if(n!==`retry`)return{...n,keyStateSaved:i}}}async function d_(e,t,n,r,i,a){let{container:o,ring:s}=t,c=async t=>({invitation:await e.invite(o.id,n.userId,n.role,[]),keys:t});if(!r.identity||!r.canWrap)return c(`cannot-wrap`);if(!t.floor)return c(`no-keys`);let l=await i.loadKeyState(o.id);if(!tm(o,$p(t.floor,l)))return c(`rollback`);let u=o.sharedGeneration>0?s.get(o.keyGeneration):void 0;if(!u||l.digests[o.keyGeneration]!==Vi(z(u)))return c(`no-keys`);let d=await e.userIdentity(n.userId);if(!d)return c(`no-identity`);try{ai(d.publicKey)}catch{return c(`invalid-identity`)}let f={...n,identity:{deviceId:d.deviceId,publicKey:d.publicKey}},p=await i.load(),{changed:m}=pi(p,[f]);if(m.length){if(await a(m)!==!0)return c(`untrusted`);let e=fi(p,f);if(!await i.confirm(e,m[0].pinned))return c(`pins-unsaved`);p=e.pins}let h=await dm(f,o.id,o.keyGeneration,u,{...r.identity,userId:r.userId},p);if(h.fresh.length){let e=await i.addFresh({[f.userId]:d.publicKey});if(!e.ok)return c(e.conflicts.length?`untrusted`:`pins-unsaved`)}await e.stepUp();try{return{invitation:await e.invite(o.id,n.userId,n.role,[{...h.envelope,containerId:o.id}]),keys:`sealed`,recipient:f}}catch(e){if(c_(e)===`already_exists`)return c(`moved`);if(c_(e)===`invalid_request`)return c(`invalid-identity`);throw e}}function f_(e,t,n){return t.filter(t=>t.userId!==n&&p_(t.username).test(e)).map(e=>e.userId)}var p_=e=>RegExp(`(^|\\s)@${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}(?![\\p{L}\\p{N}_-]|\\.[\\p{L}\\p{N}])`,`iu`),m_=/^#\/invite\/(inv_[0-9a-hjkmnp-tv-z]{26})\/([A-Za-z0-9_-]{43})$/,h_=`kynotes-invitation`,g_=(e,t)=>`${e}/#/invite/${t.id}/${t.token}`;function __(e){let t=m_.exec(e);return t?{id:t[1],token:t[2]}:void 0}var v_;function y_(){try{return globalThis.sessionStorage}catch{return}}function b_(e,t,n){let r=__(e.hash);if(r){v_=r;try{n?.setItem(h_,JSON.stringify(r))}catch{}return t.replaceState(null,``,e.pathname),r}}function x_(e){try{let t=JSON.parse(e?.getItem(h_)??`null`),n=t?__(`#/invite/${t.id}/${t.token}`):void 0;if(n)return n}catch{}return v_}function S_(e){v_=void 0;try{e?.removeItem(h_)}catch{}}var C_=(e,t)=>e===404&&t===`not_found`||e===409&&t===`already_exists`||e===410;function w_(e){let t=e.stewards.length?e.stewards.join(` or `):`a team owner`,n=e.fingerprint?` My encryption key fingerprint is ${e.fingerprint}; please check it matches what your browser shows for me.`:``;return`Hi ${t}: please open the team notebook "${e.notebook}" in KyNotes so your browser shares its key with me.${n} ${e.link}`}function T_(){let e=0;return{begin(){let t=++e;return{superseded:()=>e!==t}},mark(){let t=e;return()=>e!==t}}}var E_=`unreadable key`,D_=e=>_i(e).catch(()=>E_);function O_({username:e,userID:t,names:n}){let[r,i]=(0,X.useState)(void 0),[a,o]=(0,X.useState)(``),s=e=>n[e.userId]??``,c=(0,X.useMemo)(T_,[]);async function l(){let{superseded:n}=c.begin();try{let r=await Cl(e,t),a=Object.fromEntries(await Promise.all(Object.keys(r).map(async e=>[e,await zu(e).catch(()=>void 0)]))),o=Object.fromEntries(Object.entries(a).map(([e,t])=>[e,t?.publicKey])),s=await Promise.all(vi(r,o).map(async e=>({...e,pinnedPrint:await D_(e.pinned),currentPrint:e.current===void 0?void 0:await D_(e.current)})));n()||i(s)}catch{n()||o(`This browser could not read the colleague keys it saved.`)}}(0,X.useEffect)(()=>{l()},[e,t]);async function u(n){if(n.current===void 0||n.currentPrint===void 0||n.currentPrint===E_)return;let r=yi(n.userId,n.current,await zu(n.userId).catch(()=>void 0));if(!r)o(`That colleague's key changed again or could not be read. Check the fingerprint shown now.`),await l();else if(confirm(bi({userId:n.userId,name:s(n),newPrint:n.currentPrint,oldPrint:n.pinnedPrint}))){try{if(!await Tl(e,t,fi(await Cl(e,t),r),n.pinned))throw Error(`not stored`)}catch{o(`The new key was not saved: the saved key changed meanwhile, or this browser cannot store it. Check the keys shown now.`),await l();return}o(``),await l()}}return(0,Q.jsxs)(`section`,{id:`colleague-keys`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Colleague keys`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Keys this browser trusts when sharing team notebooks. Fingerprints are computed here, not taken from the server.`}),a&&(0,Q.jsx)(`p`,{className:`config-muted`,role:`alert`,children:a}),r?.length===0&&(0,Q.jsx)(`p`,{className:`config-muted`,children:`No colleague keys yet. A key is saved the first time you share a team notebook with someone.`}),r?.map(e=>(0,Q.jsxs)(`div`,{className:`pin-row`,children:[(0,Q.jsx)(`strong`,{children:gi(s(e),e.userId)}),(0,Q.jsx)(`code`,{children:e.pinnedPrint}),e.state===`same`&&(0,Q.jsx)(`span`,{className:`config-muted`,children:`matches the server`}),e.state===`unseen`&&(0,Q.jsx)(`span`,{className:`config-muted`,children:`not visible now (no shared notebook, or no key yet)`}),e.state===`changed`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`config-muted`,children:[`changed to `,(0,Q.jsx)(`code`,{children:e.currentPrint})]}),e.currentPrint!==E_&&(0,Q.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>void u(e),children:`Trust new key`})]})]},e.userId))]})}async function k_(e,t){let n={shared:t.sharedGeneration??0,generation:t.keyGeneration??0},r=await e.load(t.id).then(e=>e,()=>void 0),i=$p(r,n);return jm(t.id,i,r!==void 0),i.shared===(r?.shared??0)&&i.generation===(r?.generation??0)&&r||await e.save(t.id,{mark:0,digests:{},...n}).catch(()=>!1),t}var A_=(e,t)=>Promise.all(t.map(t=>k_(e,t))),j_=async e=>A_(e,await ru()),M_=async(e,...t)=>k_(e,await iu(...t)),N_=`The notebook could not get its own key, so it was not created. Try again.`;async function P_(e,t,n){let r=await e();try{return await t(r)}catch(e){throw await n(r.id).then(()=>!0,()=>!1)?Error(N_,{cause:e}):e}}function F_({username:e,userID:t,keysFor:n,waitingHeld:r}){let[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)([]),c=[...i,...o],l=e=>lm(n(e),t=>Nt(t,e.containerID,e.id,e.payload,!0));async function u(){let n=await j_({load:n=>Dl(e,t,n),save:(n,r)=>Ol(e,t,n,r)}).then(e=>new Set(e.map(e=>e.id)),()=>void 0),i=(await tl().catch(()=>[])).filter(e=>e.owner===t),a=Vg(i,n,t),o=new Set(a.map(e=>e.id));return{lost:a,previous:await Wg(i.filter(e=>!o.has(e.id)),t,r,e=>l(e).then(()=>!0,()=>!1))}}let d=async()=>{let e=await u();a(e.lost),s(e.previous)};if((0,X.useEffect)(()=>{d()},[t,r]),!c.length)return(0,Q.jsx)(`p`,{className:`config-muted`,children:`No unsent edits on this browser.`});async function f(){let e=await Hg(c,l);e.unreadable===c.length?alert(`None of these edits can be opened in this browser: they are sealed with a notebook key it no longer holds.`):(Tp(`kynotes-unsent-edits.json`,e.json,`application/json`),e.unreadable&&alert(`${e.unreadable} edit(s) are sealed with a notebook key this browser no longer holds and were left out.`))}async function p(){if(!confirm(`Delete ${c.length} unsent edit(s) from this browser? They can never be sent and cannot be recovered afterwards. Export them first if you need them.`))return;let e=await u(),n=new Set([...e.lost,...e.previous].map(e=>e.id));for(let e of c)n.has(e.id)&&await rl(e)&&await Jc(t,e.id);await d()}return(0,Q.jsxs)(`section`,{id:`unsent-edits`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Unsent edits`}),i.length>0&&(0,Q.jsxs)(`p`,{className:`config-muted`,children:[i.length,` edit(s) on this device belong to notebooks you can no longer open, so they can never be saved.`]}),o.length>0&&(0,Q.jsxs)(`p`,{className:`config-muted`,children:[o.length,` edit(s) on this device are `,`sealed under your previous key`,`: they were waiting for a notebook's key when your encryption key was reset, so they are never sent. Export them to keep their content.`]}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`The export is decrypted in this browser and saved as an unencrypted file. Store it somewhere safe and delete it when done.`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void f(),children:`Export unsent edits`}),(0,Q.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>void p(),children:`Discard unsent edits`})]})}var I_=e=>`share:${e}`;async function L_(e,t,n,r,i){await Gc(e,{id:I_(t),containerID:n,version:0,payload:await Et(r.key,n,t,i),updatedAt:new Date().toISOString(),keyGeneration:r.generation})}async function R_(e,t,n){let r=await qc(e,I_(t)).catch(()=>void 0);return r?lm(n(r),e=>G(e,r.containerID,t,r.payload)).catch(()=>`unreadable`):`none`}var z_=(e,t)=>Jc(e,I_(t)).catch(()=>void 0);function B_({userID:e,keysFor:t}){let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)(``),o=()=>dd().then(n=>Promise.all(n.map(async n=>({...n,label:await R_(e,n.id,t)})))).then(e=>{r(e),a(``)},()=>a(`Unable to load your share links.`));(0,X.useEffect)(()=>{o()},[]);async function s(t){if(confirm(`Revoke the share link ${U_(t)}? Anyone who has it can no longer open it. This cannot be undone.`)){try{await fd(t.id),await z_(e,t.id)}catch(e){a(e instanceof Error?e.message:`Unable to revoke the link.`)}await o()}}return(0,Q.jsxs)(`section`,{id:`share-links`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Share links`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Links you made with Share. Each holds an encrypted copy of the page as it was then, counts toward your storage and stops working when it expires (30 days at most). The server cannot read them; only the browser that made a link knows which page it shares.`}),i&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:i}),n?.length===0&&(0,Q.jsx)(`p`,{className:`config-muted`,children:`You have no live share links.`}),n?.map(e=>(0,Q.jsxs)(`div`,{className:`pin-row`,children:[(0,Q.jsxs)(`span`,{children:[H_(e),`: made `,V_(e.createdAt),`, expires `,V_(e.expiresAt),` (`,Math.max(1,Math.round(e.bytes/1024)),` KB)`]}),(0,Q.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>void s(e),children:`Revoke`})]},e.id))]})}var V_=e=>new Date(e).toLocaleString(),H_=({label:e})=>e===`none`?`Made on another device`:e===`unreadable`?`Made in this browser, page no longer readable`:`"${e.title}" in ${e.notebook}`,U_=e=>typeof e.label==`object`?`for "${e.label.title}"`:`made ${V_(e.createdAt)}`;function W_(e,t){if(!e||e!==t)return`New passwords do not match.`}var G_=(e,t)=>{if(!e)return;let n=e.find(e=>e.userId===t);return!!(n&&nm(n.role))},K_=`This notebook is read-only until its keys reach this browser.`,q_=`This notebook gets its own key once your encryption key can be recovered. Save a recovery code in Settings first.`,J_=`This notebook is read-only here: this browser does not hold your encryption key. Link it, or restore your key with your recovery code, in Settings.`,Y_=`This notebook is read-only until another owner's browser shares its current key with you.`,X_=`This notebook is read-only until its key is set up. Reopen it to try again.`;function Z_(e){return e.steward===void 0?{text:K_}:e.steward?e.held?e.shared?{text:Y_,action:`ask`}:e.recoverable?{text:X_}:{text:q_,action:`settings`}:{text:J_,action:`settings`}:{text:K_,action:`ask`}}var Q_=e=>new Date(e).toLocaleString();function $_(e){let t=e.filter(e=>e.keyResetAt).sort((e,t)=>Date.parse(t.keyResetAt)-Date.parse(e.keyResetAt))[0];return t&&`${gi(t.username,t.userId)} reset their encryption key on ${Q_(t.keyResetAt)}, which retired this notebook's key; an owner's next open shares a new one.`}var ev=e=>e===!1?`Saved on this device only. It is sent once a team owner shares this notebook's keys; until then, do not clear this browser's data.`:`Saved on this device only. It is sent once this notebook's key reaches this browser; until then, do not clear this browser's data.`;async function tv(e,t,n,r){if(n)return`migrated`;let i=t===0;for(let t of e)if(!(t.type===`page`?!t.v1&&t.legacy:!t.v1))try{let e=t.type===`page`?await r.savePage(t.id,await r.pins(t.id)):await r.saveStructure(t.type,t.id);i&&=e}catch{i=!1}if(!i)return`partial`;let a=!1;for(let t of e)if(t.type===`page`)try{a=await r.legacyConflict(t.id)||a}catch{return`partial`}return a?`conflicts`:await r.mark()?`migrated`:`partial`}var nv=`application/x-kynotes-page`,rv=`application/x-kynotes-section`,iv=`root`;function av(e){let{sections:t,groups:n,path:r,current:i,busy:a,onSelect:o,onDropPage:s}=e,c=r[r.length-1]?.id,l=c===void 0,u=(e,t)=>{t.some(t=>e.dataTransfer.types.includes(t))&&e.preventDefault()},d=(t,n,r)=>{let i=t.dataTransfer.getData(nv),a=t.dataTransfer.getData(rv);i?s(i,n):a&&n!==`quick`&&e.onMove(`section`,a,r),t.preventDefault()},f=e=>document.getElementById(e)?.hidePopover(),p=(t,n,i,o,s)=>{let u=`${t}-menu-${n.id}`,d=e.moveTargets(t,n.id).filter(e=>e.id!==c);return(0,Q.jsxs)(`div`,{className:`section-menu`,id:u,popover:`auto`,style:t===`group`?{positionAnchor:`--group-${n.id}`}:void 0,children:[(0,Q.jsx)(`button`,{className:`quiet`,disabled:a,onClick:()=>{f(u),e.onRename(t,n)},children:`Rename`}),(0,Q.jsx)(`div`,{className:`section-colors`,role:`group`,"aria-label":t===`section`?`Section color`:`Group color`,children:we.map(r=>(0,Q.jsx)(`button`,{className:`section-swatch`,"aria-label":r,"aria-pressed":n.color===r,style:{background:`var(--section-${r})`},disabled:a,onClick:()=>{f(u),e.onColor(t,n,r)}},r))}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:a||i===0,onClick:()=>{f(u),e.onMove(t,n.id,i-1)},children:`Move up`}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:a||i===o-1,onClick:()=>{f(u),e.onMove(t,n.id,i+1)},children:`Move down`}),(0,Q.jsxs)(`select`,{"aria-label":`Move into group`,value:``,disabled:a||l&&!d.length,onChange:r=>{f(u),e.onMoveIntoGroup(t,n.id,r.target.value===iv?void 0:r.target.value)},children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:`Move into group…`}),!l&&(0,Q.jsxs)(`option`,{value:iv,children:[`Top level of `,r[0].title]}),d.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,Q.jsx)(`button`,{className:`quiet danger`,disabled:a,onClick:()=>{f(u),s()},children:t===`section`?`Delete section`:`Delete group`})]})},m=(n,r,s,c,l)=>(0,Q.jsxs)(`li`,{className:`section-tab-item`,children:[(0,Q.jsx)(`button`,{className:`quiet ky-nav-item section-tab${n===`quick`?` section-tab-quick`:``}`,"aria-current":i===n?`true`:void 0,style:{"--tab-color":`var(--section-${s})`},draggable:!!l&&!a,onDragStart:e=>e.dataTransfer.setData(rv,n),onDragOver:e=>u(e,[nv,rv]),onDrop:e=>d(e,n,c),onClick:()=>o(n),children:r||`Untitled section`}),l&&i===n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`quiet section-tab-menu`,popoverTarget:`section-menu-${n}`,"aria-label":`Section options for ${r||`Untitled section`}`,children:`⋯`}),p(`section`,l,c,t.length,()=>e.onDelete(l))]})]},n);return(0,Q.jsxs)(`nav`,{id:`section-navigation`,className:`section-tabs`,"aria-label":`Sections`,children:[!l&&(0,Q.jsx)(`ol`,{className:`section-breadcrumb`,"aria-label":`Section groups`,children:r.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`button`,{className:`quiet`,"aria-current":n===r.length-1?`location`:void 0,onClick:()=>e.onOpenGroup(t.id),children:t.title})},t.id??iv))}),(0,Q.jsxs)(`ul`,{role:`list`,children:[t.map((e,t)=>m(e.id,e.title,e.color,t,e)),l&&m(`quick`,`Quick Notes`,`gray`,t.length),n.map((t,r)=>(0,Q.jsxs)(`li`,{className:`section-tab-item`,children:[(0,Q.jsxs)(`button`,{className:`quiet ky-nav-item section-tab group-tab`,style:{"--tab-color":`var(--section-${t.color})`},onDragOver:e=>u(e,[rv]),onDrop:n=>{let r=n.dataTransfer.getData(rv);r&&e.onMoveIntoGroup(`section`,r,t.id),n.preventDefault()},onClick:()=>e.onOpenGroup(t.id),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`📁 `}),t.title||`Untitled group`]}),(0,Q.jsx)(`button`,{className:`quiet section-tab-menu`,style:{anchorName:`--group-${t.id}`},popoverTarget:`group-menu-${t.id}`,"aria-label":`Group options for ${t.title||`Untitled group`}`,children:`⋯`}),p(`group`,t,r,n.length,()=>e.onDeleteGroup(t))]},t.id)),!l&&!t.length&&!n.length&&(0,Q.jsx)(`li`,{className:`section-empty`,children:`This group is empty. Add a section from the notebook menu.`})]})]})}var ov=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function sv(e,t=new Date){let n=new Date(e);if(!e||Number.isNaN(n.getTime()))return``;let r=Math.round((ov(t)-ov(n))/864e5);return r<=0?n.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):r===1?`Yesterday`:r<7?n.toLocaleDateString([],{weekday:`long`}):n.toLocaleDateString([],n.getFullYear()===t.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`})}function cv(e,t=new DOMParser){return lv(t.parseFromString(e,`text/html`))}function lv(e=globalThis.document){return[...e.querySelectorAll(`script[src], link[rel~="stylesheet"][href]`)].filter(e=>!e.closest(`noscript`)).map(e=>e.getAttribute(e.localName===`script`?`src`:`href`)).filter(Boolean)}function uv({name:e=`This app`,url:t=`/`,interval:n=3e5,doc:r=globalThis.document,fetch:i=globalThis.fetch}={}){let a=r.defaultView??globalThis,o=lv(r).join(` +`),s=Date.now(),c=!1,l=!1,u=null,d=async()=>{if(c||u||r.visibilityState===`hidden`||a.navigator?.onLine===!1||Date.now()-se.abort(),3e4);try{let n=await i(t,{cache:`no-store`,credentials:`same-origin`,redirect:`manual`,headers:{Accept:`text/html`},signal:e.signal});if(!n.ok||!/text\/html/i.test(n.headers.get(`content-type`)??``))return;let r=cv(await n.text(),new a.DOMParser);!l&&r.length&&o&&r.join(` +`)!==o&&f()}catch{}finally{a.clearTimeout(d),c=!1}},f=()=>{h(),u=r.createElement(`div`),u.className=`ky-update`,u.setAttribute(`role`,`status`);let t=r.createElement(`p`);t.className=`ky-update-text`;let n=r.createElement(`button`);n.type=`button`,n.className=`ky-update-reload`,n.textContent=`Reload`,n.addEventListener(`click`,()=>a.location.reload());let i=r.createElement(`button`);i.type=`button`,i.className=`ky-update-dismiss`,i.setAttribute(`aria-label`,`Dismiss`),i.title=`Dismiss`,i.textContent=`×`,i.addEventListener(`click`,()=>{u.remove()}),u.append(t,n,i),r.body.append(u),t.textContent=`${e} was updated. Reload to use the new version.`},p=()=>{r.visibilityState===`visible`&&d()},m=a.setInterval(d,n);r.addEventListener(`visibilitychange`,p),a.addEventListener(`focus`,d),a.addEventListener(`online`,d);function h(){a.clearInterval(m),r.removeEventListener(`visibilitychange`,p),a.removeEventListener(`focus`,d),a.removeEventListener(`online`,d)}return()=>{l=!0,h(),u?.remove()}}var dv=`kynotes.blocknote.v1`;function fv(e=[]){return e.flatMap(e=>{if(e.type===`hardBreak`)return[{type:`text`,text:` +`}];if(e.type!==`text`||typeof e.text!=`string`)return fv(e.content);let t={},n;for(let r of e.marks??[])r.type===`bold`&&(t.bold=!0),r.type===`italic`&&(t.italic=!0),r.type===`strike`&&(t.strike=!0),r.type===`code`&&(t.code=!0),r.type===`underline`&&(t.underline=!0),r.type===`link`&&typeof r.attrs?.href==`string`&&(n={href:r.attrs.href,content:[{type:`text`,text:e.text,styles:t}]});return n?[{type:`link`,...n}]:[{type:`text`,text:e.text,styles:t}]})}function pv(e=[]){return e.flatMap(e=>{let t=fv(e.content);switch(e.type){case`paragraph`:return[{type:`paragraph`,content:t}];case`heading`:return[{type:`heading`,props:{level:Number(e.attrs?.level)||1},content:t}];case`bulletList`:return mv(e.content,`bulletListItem`);case`orderedList`:return mv(e.content,`numberedListItem`);case`blockquote`:return[{type:`quote`,children:pv(e.content)}];case`codeBlock`:return[{type:`codeBlock`,props:{language:typeof e.attrs?.language==`string`?e.attrs.language:``},content:e.content?.map(e=>e.text??``).join(``)??``}];case`image`:return[{type:`image`,props:{url:typeof e.attrs?.src==`string`?e.attrs.src:``,name:typeof e.attrs?.alt==`string`?e.attrs.alt:``}}];case`horizontalRule`:return[{type:`divider`}];default:return e.content?pv(e.content):[]}})}function mv(e=[],t){return e.filter(e=>e.type===`listItem`).map(e=>{let n=pv(e.content);return{...n[0]??{type:`paragraph`,content:``},type:t,children:n.slice(1)}})}function hv(e){let t=e,n=t?.format===`kynotes.tiptap.v1`?t.document:t;if(n?.type===`doc`)return pv(n.content)}function gv(e){try{return hv(JSON.parse(e))}catch{return}}var _v=()=>({format:dv,document:[{type:`paragraph`,content:``}]}),vv=`kynotes.canvas.v1`,yv=`legacy`,bv=1e5,xv=5e3,Sv=1e4,Cv=2e3,wv=[`ink`,`blue`,`red`,`green`,`orange`,`yellow`],Tv=/^[A-Za-z0-9-]{1,64}$/,Ev=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Dv=(e,t,n,r)=>typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r;function Ov(e){if(!Ev(e)||typeof e.id!=`string`||!Tv.test(e.id))return;let t=Array.isArray(e.blocks)?e.blocks.filter(Ev):[];return{id:e.id,x:Dv(e.x,0,bv,0),y:Dv(e.y,0,bv,0),width:Dv(e.width,160,Cv,640),blocks:t.length?t:_v().document}}function kv(e){if(!Ev(e)||typeof e.id!=`string`||!Tv.test(e.id)||!Array.isArray(e.points))return;let t=e.points.slice(0,Sv*3),n=[];for(let e=0;e+2typeof e==`number`&&Number.isFinite(e))&&n.push(Dv(r,0,bv,0),Dv(i,0,bv,0),Dv(a,0,1,.5))}if(n.length)return{id:e.id,tool:e.tool===`highlighter`?`highlighter`:`pen`,color:wv.includes(e.color)?e.color:`ink`,size:Dv(e.size,1,64,4),points:n}}function Av(e,t,n){let r=new Set,i=[];for(let a of Array.isArray(e)?e.slice(0,t):[]){let e=n(a);e&&!r.has(e.id)&&(r.add(e.id),i.push(e))}return i}var jv=()=>({format:vv,boxes:[],strokes:[]});function Mv(e){let t;try{t=JSON.parse(e)}catch{}if(Ev(t)&&t.format===`kynotes.canvas.v1`)return{format:vv,boxes:Av(t.boxes,500,Ov),strokes:Av(t.strokes,xv,kv)};let n={id:yv,x:0,y:0,width:640,blocks:Iv(e).document};return{...jv(),boxes:[n],legacyMarkdown:e&&!Vv(e)?e:void 0}}var Nv=({boxes:e,strokes:t})=>JSON.stringify({format:vv,boxes:e,strokes:t});function Pv(e){let t;try{t=JSON.parse(e)}catch{return}return Ev(t)&&t.format===`kynotes.canvas.v1`?Av(t.boxes,500,Ov).sort((e,t)=>e.y-t.y||e.x-t.x).flatMap(e=>e.blocks):Ev(t)&&t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document)?t.document:hv(t)}var Fv=e=>Pv(e)??Iv(e).document;function Iv(e){try{let t=JSON.parse(e);if(t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document))return{format:dv,document:t.document}}catch{}let t=gv(e);return t?{format:dv,document:t.length?t:_v().document}:e?{format:dv,document:[{type:`paragraph`,content:e}]}:_v()}function Lv(e){let t=[],n=e=>{if(typeof e.content==`string`&&t.push(e.content),Array.isArray(e.content)){let n=e=>{typeof e==`object`&&e&&(`text`in e&&typeof e.text==`string`&&t.push(e.text),`content`in e&&Array.isArray(e.content)&&e.content.forEach(n))};e.content.forEach(n)}e.type===`image`&&typeof e.props?.name==`string`&&t.push(`[${e.props.name}]`),e.children?.forEach(n)};try{Fv(e).forEach(n)}catch{return``}return t.join(` `)}var Rv=e=>Mv(e).strokes.length>0,zv=e=>Rv(e)?Nv({...Mv(e),strokes:[]}):e,Bv=e=>Rv(e)&&Lv(e).trim()===``;function Vv(e){try{let t=JSON.parse(e);if(t.format===`kynotes.blocknote.v1`&&Array.isArray(t.document)||t.format===`kynotes.canvas.v1`)return!0}catch{}return gv(e)!==void 0}var Hv=[[`overdue`,`Overdue`],[`today`,`Today`],[`upcoming`,`Upcoming`],[`later`,`Later`],[`undated`,`No date`]],Uv=(e,t=2)=>String(e).padStart(t,`0`),Wv={daily:{unit:`day`,every:1},weekly:{unit:`week`,every:1},monthly:{unit:`month`,every:1},yearly:{unit:`year`,every:1}};function Gv(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return!1;let[n,r,i]=t.slice(1).map(Number),a=new Date(Date.UTC(n,r-1,i));return a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i}function Kv(e){if(Wv[e])return Wv[e];let t=/^every-(\d{1,3})-(days|weeks)$/.exec(e),n=Number(t?.[1]);return t&&n>=1&&n<=365?{unit:t[2]===`days`?`day`:`week`,every:n}:void 0}function qv(e){let t=[];for(let n of e.matchAll(/\S+/g)){let e=/^(due|repeat|remind|push):(\S+)$/.exec(n[0]);if(!e||t.some(t=>t.key===e[1]))continue;let[,r,i]=e;(r===`due`?Gv(i):r===`repeat`?Kv(i):r===`push`?i===`yes`:/^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):[0-5]\d$/.test(i)&&Gv(i.slice(0,10)))&&t.push({key:r,value:i,start:n.index,end:n.index+n[0].length})}return t}function Jv(e){let t={text:``},n=e;for(let r of qv(e).reverse())r.key===`repeat`?t.repeat=Kv(r.value):r.key===`push`?t.push=!0:t[r.key]=r.value,n=n.slice(0,r.start)+n.slice(r.end);return t.text=n.replace(/\s+/g,` `).trim(),t.remind||delete t.push,t}function Yv(e){return`${e.getFullYear()}-${Uv(e.getMonth()+1)}-${Uv(e.getDate())}`}function Xv(e,t){let[n,r,i]=e.split(`-`).map(Number);if(t.unit===`day`||t.unit===`week`){let e=new Date(Date.UTC(n,r-1,i+t.every*(t.unit===`week`?7:1)));return`${Uv(e.getUTCFullYear(),4)}-${Uv(e.getUTCMonth()+1)}-${Uv(e.getUTCDate())}`}let a=r-1+t.every*(t.unit===`year`?12:1),o=n+Math.floor(a/12),s=a%12,c=new Date(Date.UTC(o,s+1,0)).getUTCDate();return`${Uv(o,4)}-${Uv(s+1)}-${Uv(Math.min(i,c))}`}function Zv(e,t){return e.repeat?{due:Xv(e.due??t,e.repeat),remind:e.remind&&`${Xv(e.remind.slice(0,10),e.repeat)}${e.remind.slice(10)}`}:{}}function Qv(e){let[t,n,r]=e.slice(0,10).split(`-`).map(Number);return new Date(t,n-1,r,Number(e.slice(11,13)),Number(e.slice(14,16))).getTime()}function $v(e,t,n=!1){if(n)return`overdue`;if(!e.due)return`undated`;let r=Yv(t);return e.duet?a.next=Math.min(a.next??e,e):i&&e>n?a.fire.push(o):a.missed.add(o)}return a}var ty=100;function ny(e,t){let n=e.map(e=>typeof e.text==`string`).lastIndexOf(!0),r=0;return e.map((e,i)=>{if(typeof e.text!=`string`)return e;let a=r;r+=e.text.length;let o=``;for(let s=a;ss>=e.start&&se.text!==``)}var ry=e=>e.map(e=>typeof e.text==`string`?e.text:``).join(``),iy=(e,t)=>{let n=+!!/\s$/.test(e.slice(0,t.start)),r=n||!/^\s/.test(e.slice(t.end))?0:1;return{start:t.start-n,end:t.end+r}};function ay(e,t){let n=[],r=(e,i)=>{if(!(i>ty)){if(e.type===`checkListItem`&&e.props?.checked===!0&&e.id&&Array.isArray(e.content)){let r=e.content,i=ry(r),a=qv(i),o=a.find(e=>e.key===`repeat`);if(o){let s=Zv(Jv(i),t),c=a.flatMap(({key:e,start:t,end:n})=>e===`repeat`||e===`push`?[]:[{start:t,end:n,text:`${e}:${s[e]}`}]);a.some(e=>e.key===`due`)||c.push({start:i.length,end:i.length,text:`${/\S$/.test(i)?` `:``}due:${s.due}`}),n.push({id:e.id,content:ny(r,[{...iy(i,o),text:``}]),next:{type:`checkListItem`,props:{checked:!1},content:ny(r,c)}})}}e.children?.forEach(e=>r(e,i+1))}};return e.forEach(e=>r(e,0)),n}var oy=100,sy=new WeakMap,cy=new WeakMap,ly=new WeakMap;function uy(e){return e.map(e=>{let t=sy.get(e);return t||(t={id:e.id,title:e.title,updatedAt:e.updatedAt,body:Lv(e.body),sourceBody:e.body,note:e},sy.set(e,t)),t})}function dy(e){return[...e.body.matchAll(/\[\[([^\]]+)\]\]/g)].map(e=>e[1].trim()).filter(Boolean)}function fy(e){return[...e.body.matchAll(/(?:^|\s)#([a-zA-Z0-9_-]+)/g)].map(e=>e[1].toLowerCase())}function py(e){let t=cy.get(e);return t||(t=hy(e.sourceBody??e.body),cy.set(e,t)),t}function my(e){let t=ly.get(e);return t||(t=py(e).map(e=>({...Jv(e),raw:e})),ly.set(e,t)),t}function hy(e){try{return gy(e)}catch{return[]}}function gy(e){let t=[],n=Pv(e);if(n){let e=e=>Array.isArray(e)?e.map(e=>typeof e==`object`&&e&&`text`in e&&typeof e.text==`string`?e.text:``).join(``):typeof e==`string`?e:``,r=(n,i=0)=>{if(!(i>oy||typeof n!=`object`||!n)){if(n.type===`checkListItem`&&n.props?.checked!==!0){let r=e(n.content).trim();r&&t.push(r)}if(n.type===`bulletListItem`){let r=e(n.content).trim().match(/^\[ \] (.+)$/)?.[1];r&&t.push(r.trim())}Array.isArray(n.children)&&n.children.forEach(e=>r(e,i+1))}};return n.forEach(e=>r(e)),t}return e.split(` +`).filter(e=>/^\s*- \[ \] /.test(e)).map(e=>e.replace(/^\s*- \[ \] /,``).trim())}function _y(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>`${e.title}\n${e.body}`.toLowerCase().includes(n)):e}function vy(e){return e.filter(e=>py(e).length>0)}function yy(e,t){if(!t)return vy(e).slice(0,5);let n=new Set(dy(t));return e.filter(e=>e.id!==t.id&&(n.has(e.id)||py(e).length>0||fy(e).some(e=>fy(t).includes(e)))).slice(0,5)}function by(e){let t=new Set(e.map(e=>e.id));return e.flatMap(e=>dy(e).filter(e=>t.has(e)).map(t=>({from:e.id,to:t})))}var xy=`kynotes-reminders`,Sy=`kynotes-reminder-text`,Cy=`kynotes-reminder-push`,wy=864e5,Ty=Date.now(),Ey={display:`flex`,alignItems:`center`,gap:10,marginTop:16},Dy=()=>typeof Notification<`u`&&Notification.permission===`granted`,Oy=()=>typeof navigator<`u`&&`serviceWorker`in navigator&&typeof PushManager<`u`,ky=(e,t)=>Bf(`${e}:${t}`)===`on`;function Ay(e){return{enabled:ky(xy,e)&&Dy(),showText:ky(Sy,e),push:ky(Cy,e)&&Dy()&&Oy()}}function jy(e,t){Vf(`${xy}:${e}`,t.enabled?`on`:`off`),Vf(`${Sy}:${e}`,t.showText?`on`:`off`),Vf(`${Cy}:${e}`,t.push?`on`:`off`)}var My=e=>Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),Ny=(e,t)=>e!==null&&e.byteLength===t.length&&new Uint8Array(e).every((e,n)=>e===t[n]);async function Py(){await navigator.serviceWorker.register(`/sw.js`,{scope:`/`});let e=await navigator.serviceWorker.ready,t=My((await hd()).publicKey),n=await e.pushManager.getSubscription();n&&!Ny(n.options.applicationServerKey,t)&&(await n.unsubscribe(),n=null),n??=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),await gd(n.endpoint)}async function Fy(){if(!Oy())return;let e=await(await navigator.serviceWorker.getRegistration(`/`))?.pushManager.getSubscription();if(e)try{await _d(e.endpoint)}finally{await e.unsubscribe()}}function Iy(e,t){let n=(0,X.useRef)(new Set),[r,i]=(0,X.useState)(0),a=t.enabled&&Dy(),o=ey(e,Date.now(),Ty,n.current,a);return(0,X.useEffect)(()=>{for(let r of o.fire){if(n.current.has(r))continue;n.current.add(r);let i=e.find(e=>e.key===r)?.text;new Notification(`KyNotes`,{body:t.showText&&i?`A task is due: ${i}`:`A task is due`,tag:r})}if(o.next===void 0)return;let r=window.setTimeout(()=>i(e=>e+1),Math.min(Math.max(o.next-Date.now(),0),wy));return()=>window.clearTimeout(r)},[e,a,t.showText,r]),o.missed}function Ly({userID:e,prefs:t,onChange:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),s=t=>{jy(e,t),n(t)};async function c(e){if(i(!1),!e)return s({...t,enabled:!1});(typeof Notification>`u`?`denied`:await Notification.requestPermission())===`granted`?s({...t,enabled:!0}):i(!0)}async function l(e){i(!1),o(``);try{if(!e)return s({...t,push:!1}),await Fy();if(!Oy())return o(`This browser cannot receive pushes for KyNotes.`);if(await Notification.requestPermission()!==`granted`)return i(!0);await Py(),s({...t,push:!0})}catch(e){o(e instanceof Error?`Push reminders failed: ${e.message}`:`Push reminders failed.`)}}return(0,Q.jsxs)(`section`,{id:`reminders`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Reminders`}),(0,Q.jsxs)(`p`,{className:`config-muted`,children:[`Tasks with `,(0,Q.jsx)(`code`,{children:`remind:2026-11-01T09:00`}),` notify you in this browser while a KyNotes tab is open. Reminders that pass with no tab open show as missed in the work queue.`]}),(0,Q.jsxs)(`label`,{style:Ey,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:e=>void c(e.target.checked)}),(0,Q.jsx)(`span`,{children:`Show reminders while KyNotes is open`})]}),(0,Q.jsxs)(`label`,{style:Ey,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.showText,onChange:e=>s({...t,showText:e.target.checked})}),(0,Q.jsx)(`span`,{children:`Show task text in reminders`})]}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`With task text off, a reminder says only "A task is due", so nothing from your notes shows on a locked screen.`}),(0,Q.jsxs)(`label`,{style:Ey,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.push,onChange:e=>void l(e.target.checked)}),(0,Q.jsx)(`span`,{children:`Also remind me when KyNotes is closed (sends reminder times to the server)`})]}),(0,Q.jsxs)(`p`,{className:`config-muted`,children:[`For tasks you mark `,(0,Q.jsx)(`code`,{children:`push:yes`}),`, the server learns each reminder's time and how many you have, never which task, and your browser's push service (Google, Mozilla, Apple or Microsoft) sees an empty push arrive; the notification says only "A reminder is due".`]}),a&&(0,Q.jsx)(`p`,{role:`status`,children:a}),r&&(0,Q.jsx)(`p`,{role:`status`,children:`This browser blocked notifications for KyNotes. Allow them in the site settings, then try again.`})]})}var Ry=`0123456789abcdefghjkmnpqrstvwxyz`;function zy(e,t,n){let r=T(z,e,new TextEncoder().encode(`${t}\n${n}`)),i=0n;for(let e of r.subarray(0,17))i=i<<8n|BigInt(e);i>>=6n;let a=``;for(let e=0;e<26;e+=1,i>>=5n)a=Ry[Number(i&31n)]+a;return a}var By=e=>`${new Date(Qv(e)).toISOString().slice(0,16)}:00Z`;function Vy(e,t,n){let r=new Map;for(let i of t){if(!i.push||!i.remind||Qv(i.remind)<=n)continue;let t=zy(e,i.noteID,i.remind);r.set(t,{id:t,at:By(i.remind)})}return[...r.values()].sort((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id)).slice(0,500)}function Hy(e,t,n,r){if(!n)return{puts:[],deletes:[]};let i=new Map(t.map(e=>[e.id,e.at])),a=new Set(e.map(e=>e.id)),o=r&&new Map(r.map(e=>[e.id,e.at]));return{puts:e.filter(e=>i.get(e.id)!==e.at&&(!o||o.get(e.id)!==e.at)),deletes:t.filter(e=>!a.has(e.id)&&(!o||o.has(e.id))).map(e=>e.id)}}var Uy=15e3;function Wy(e,t=Date.now()){return t-e_l(e,t),save:(n,r)=>ml(e,t,n,r)},t,n,r)}catch{}}var Jy=100,Yy=`This notebook's upgrade to the current encryption format is waiting on pages with conflicting versions saved by an older KyNotes. Open each page that says another device saved it first and choose Keep the other version as a copy; the upgrade finishes on a later visit. Until then, the notebook keeps working as it is.`,Xy=`You can read this notebook but not change its pages: your role here is viewer or commenter.`,Zy=`You can no longer edit the page an unsent edit belongs to, so it cannot be saved. It is kept under Settings → Unsent edits, where you can export or discard it.`,Qy=`Your role in this notebook could not be loaded, so it is read-only for now. Reopen the notebook to try again.`,$y=`A page you edited was deleted elsewhere, so the edit cannot be saved to it. It is kept under Settings → Unsent edits, where you can export or discard it.`,eb=5,tb=`The export is not encrypted: anyone who gets the file can read these notes and attachments.`,nb=`Deleting a notebook needs a sign-in from the last 5 minutes. Sign out now, sign in again, then delete it?`;function rb(e,t){return`Delete "${e}"? This deletes ${t?`its pages, comments and attachments, and every notebook in this team with theirs,`:`its pages, comments and attachments`} for every member. It cannot be undone.\n\nType the notebook's name to confirm.`}var ib=`kynotes-chunk-reload`,ab=e=>{try{return e===null?sessionStorage.removeItem(ib):e!==void 0&&sessionStorage.setItem(ib,e),sessionStorage.getItem(ib)}catch{return null}},ob=(0,X.lazy)(()=>fo(()=>import(`./CanvasPage-CCePUo_W.js`).then(e=>(ab(null),e),e=>{if(!navigator.onLine||ab()===location.href||ab(location.href)!==location.href)throw e;return location.reload(),new Promise(()=>{})}),__vite__mapDeps([0,1,2,3]))),sb=class extends X.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,Q.jsxs)(`div`,{className:`editor-loading`,role:`alert`,children:[(0,Q.jsxs)(`p`,{children:[navigator.onLine?`This page's editor could not be loaded.`:`This page's editor could not be loaded while offline.`,` Your other pages and unsent edits are safe. Reload once you are connected.`]}),(0,Q.jsx)(`button`,{type:`button`,className:`secondary`,onClick:()=>{ab(null),location.reload()},children:`Reload`})]}):this.props.children}},cb=`The server reported an older key state for this notebook than this device has seen; writes are paused.`,lb=`The server sent an older copy of a notebook's encrypted name than this device has seen (from before its encryption upgrade); it is not shown. Rename the notebook to replace it.`,ub=`The notebook was created, but its key is not set up yet. Open it again to finish.`,db=`This browser does not hold your encryption key, so it cannot create a notebook. Link it, or restore your key with your recovery code, in Settings.`,fb=`Saved to the server, but this browser could not keep its local copy (site storage may be full or blocked).`;function pb(e,t){return e===`link`?` Link it from a browser that does, under Phones & apps.`:e===`create`?t?` Set up your encryption key from the notebook list.`:` Sign in with your password to create it.`:``}var mb=`Forget this device and sign out? This browser's copy of your encryption key and your colleague key pins are removed. To get the key back here, link this browser from another one or enter your recovery code (or sign in with your password, if it still unlocks your key; accounts that use KySignOn have no password copy). Unsent edits stay on this browser until they are sent, or until you discard them under Unsent edits.`,hb=e=>({derive:async t=>{let n=await Kl(e);return ut(t,n.loginSalt,n.iterations,Zd(e))},stepUp:e=>yu(e)}),gb={"has-key":`has key`,waiting:`waiting for key`,"no-identity":`no encryption key yet`,unapproved:`awaiting approval`},_b=`An administrator created this team notebook for you. Name it so its members can find it.`,vb=e=>`${e} was added by an administrator. They get this notebook's keys only after you approve them.`,yb={"cannot-wrap":`The invitation carries no keys: this browser cannot share keys at invitation time (it holds no encryption key, or you signed in with single sign-on). A team owner's browser shares them after the person joins.`,rollback:`The invitation carries no keys: the server reports an older sharing state for this team than this browser has seen.`,"no-keys":`The invitation carries no keys: this browser holds none for this team yet. A team owner's browser shares them after the person joins.`,"no-identity":`The invitation carries no keys: you cannot see this person's encryption key yet. A team owner's browser shares them after they join.`,"invalid-identity":`The invitation carries no keys: this person's encryption key could not be used. A team owner's browser shares them after they join.`,untrusted:`The invitation carries no keys: you did not confirm this person's new encryption key.`,"pins-unsaved":`The invitation carries no keys: this browser could not save this person's key. Allow site storage.`,moved:`The invitation carries no keys: this team's key changed meanwhile. A team owner's browser shares the new one after the person joins.`};function bb(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0);(0,X.useEffect)(()=>{Jf(),eu().then(async e=>{e.user?.username&&(e.user.accountKind===`admin`||e.passwordChangeRequired?t({username:e.user.username,authSecret:``,user:e.user,sso:e.sso,passwordChangeRequired:e.passwordChangeRequired}):e.sso?(await sl(e.user.username).catch(()=>void 0),t({username:e.user.username,authSecret:``,user:e.user,sso:!0})):(r(e.user),await yl(e.user.username)&&t({username:e.user.username,authSecret:``,user:e.user})))}).catch(()=>{r(null)}).finally(()=>a(!1))},[]);let o=e?.user.id;if((0,X.useEffect)(()=>{if(!o||typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`kynotes-account`);return e.onmessage=e=>{e.data!==o&&location.reload()},e.postMessage(o),()=>e.close()},[o]),i)return(0,Q.jsx)(`main`,{className:`center`,children:`Loading KyNotes…`});if(location.pathname.startsWith(`/share/`))return(0,Q.jsx)(xb,{});let s=()=>Fy().catch(()=>void 0).then(nu),c=()=>{s().finally(()=>{Mm(),t(null),r(null)})};return e?.passwordChangeRequired?(0,Q.jsx)(Ob,{auth:e,onChanged:n=>t({...e,authSecret:e.user.accountKind===`admin`?``:n,passwordChangeRequired:!1}),onLogout:c}):e?.user.accountKind===`admin`?(0,Q.jsx)(hp,{deployment:e.user.tenancy===`multi`?`multi`:`single`,username:e.username,sso:e.sso===!0,onLogout:c,password:(0,Q.jsx)(Tb,{username:e.username,userID:e.user.id,everyday:!1,onAuthSecret:()=>{},onIdentityCreated:()=>{}})}):e?(0,Q.jsx)(wb,{auth:e,onAuthSecret:e=>t(t=>t&&{...t,authSecret:e}),onLogout:c,onForgetDevice:()=>{kl(e.username).then(()=>{s().finally(()=>{Mm(),t(null),r(null)})})}}):(0,Q.jsx)(Sb,{sessionUser:n,onClearSession:()=>{s().finally(()=>r(null))},onForgetDevice:e=>{kl(e).then(()=>{s().finally(()=>r(null))})},onLogin:t})}function xb(){let[e,t]=(0,X.useState)({});return(0,X.useEffect)(()=>{let e=location.pathname.split(`/`).pop()??``,n=location.hash.slice(1);!e||!n?t({error:`This link is missing its decryption key.`}):pd(e).then(e=>Lt(e,n)).then(e=>t({note:e})).catch(e=>t({error:e instanceof Error?e.message:`Unable to decrypt this note.`}))},[]),e.error?(0,Q.jsx)(Cb,{tagline:`Private notes on your own server.`,children:(0,Q.jsxs)(`div`,{className:`ky-auth-card`,children:[(0,Q.jsx)(`h2`,{children:`Encrypted link unavailable`}),(0,Q.jsx)(`p`,{className:`error`,children:e.error})]})}):e.note?(0,Q.jsx)(`main`,{className:`shared-page`,children:(0,Q.jsxs)(`article`,{className:`shared-note`,children:[(0,Q.jsx)(`p`,{className:`shared-note-source`,children:`Shared from KyNotes · encrypted link`}),(0,Q.jsx)(`h1`,{children:e.note.title}),(0,Q.jsx)(`div`,{className:`shared-note-body`,children:Lv(e.note.body)})]})}):(0,Q.jsx)(`main`,{className:`center`,children:`Decrypting encrypted note…`})}function Sb({onLogin:e,sessionUser:t,onClearSession:n,onForgetDevice:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(()=>t?.username??``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(`admin`),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(null);(0,X.useEffect)(()=>{Wl().then(e=>{e.setupRequired&&a(!0)}).catch(()=>{}),Jl().then(D).catch(()=>{})},[]),(0,X.useEffect)(()=>{t?.username&&s(t.username)},[t]);async function O(t){t.preventDefault();let n=wp({admin:f,adminPassword:c,adminConfirm:u,everyday:m,everydayPassword:g,everydayConfirm:v});if(n)x(n);else{x(``),C(!0);try{let t=async(e,t)=>{let n=ft();return{username:e.trim(),authSecret:(await ut(t,n,6e5)).authSecret,loginSalt:n,iterations:6e5}},n=await Gl(await t(f,c),await t(m,g),w);e({username:f.trim(),authSecret:``,user:n.user})}catch(e){x(e instanceof Error?e.message:`Setup failed`)}finally{C(!1)}}}async function k(n){n.preventDefault(),x(``),C(!0);try{let n=o.trim()||t?.username||``,r=await Kl(n),i=await ut(c,r.loginSalt,r.iterations,Zd(n)),a=i.authSecret,s=await ql(n,a);r.iterations>=6e5&&Qd(n);let{keys:u,identity:d}=r.iterations<6e5&&!s.passwordChangeRequired?await Ky(n,s.user.id,c,i,s.identity):{keys:i,identity:s.identity},f=s.user.accountKind===`user`;f&&!s.passwordChangeRequired&&(await cl(async()=>s,n),await qy(n,s.user.id,u,d)),e({username:n,authSecret:f?u.authSecret:``,user:s.user,passwordChangeRequired:s.passwordChangeRequired}),l(``)}catch(e){x(e instanceof Error?e.message:`Unable to sign in`)}finally{C(!1)}}return i?(0,Q.jsx)(Cb,{tagline:`Private notes on your own server.`,help:`Each password stays in this browser. It derives that account's sign-in verifier and is never sent to or stored on the server.`,children:(0,Q.jsxs)(`form`,{className:`ky-auth-card setup-form`,onSubmit:O,children:[(0,Q.jsx)(`h2`,{children:`Set up KyNotes`}),(0,Q.jsx)(`p`,{className:`setup-lede`,children:`Create two accounts: one to run the server and one to write notes with.`}),(0,Q.jsxs)(`label`,{children:[`Setup token`,(0,Q.jsx)(`input`,{autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value),required:!0})]}),(0,Q.jsxs)(`p`,{className:`setup-hint`,children:[`Proves you run this server. Find it in the server's startup log (`,(0,Q.jsx)(`code`,{children:`docker compose logs kynotes-server`}),`) or in `,(0,Q.jsx)(`code`,{children:`secrets/setup.token`}),` in its data volume.`]}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:`Administrator login`}),(0,Q.jsx)(`p`,{className:`setup-hint`,children:`Manages users, teams, sign-on and backups. It cannot open notes.`}),(0,Q.jsxs)(`label`,{children:[`Administrator username`,(0,Q.jsx)(`input`,{autoComplete:`username`,value:f,onChange:e=>p(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Administrator password`,(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Confirm administrator password`,(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:u,onChange:e=>d(e.target.value),required:!0})]})]}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:`Everyday login`}),(0,Q.jsx)(`p`,{className:`setup-hint`,children:`The account you write notes with.`}),(0,Q.jsxs)(`label`,{children:[`Everyday username`,(0,Q.jsx)(`input`,{autoComplete:`off`,value:m,onChange:e=>h(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Everyday password`,(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:g,onChange:e=>_(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{children:[`Confirm everyday password`,(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:v,onChange:e=>y(e.target.value),required:!0})]})]}),b&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:b}),(0,Q.jsx)(`button`,{className:`ky-auth-submit`,disabled:S,children:S?`Initializing…`:`Initialize KyNotes`})]})}):(0,Q.jsx)(Cb,{tagline:`Private notes on your own server.`,help:`Your notes are encrypted in this browser before they leave it, and your password never leaves it.`,children:(0,Q.jsxs)(`div`,{className:`ky-auth-card`,children:[t&&(0,Q.jsxs)(`p`,{className:`auth-session`,role:`status`,children:[`Signed in as `,(0,Q.jsx)(`strong`,{children:t.username||t.id}),`. Enter your password to keep using KyNotes in this browser.`,n&&(0,Q.jsx)(`button`,{type:`button`,className:`ky-auth-link`,onClick:n,children:`Sign out`})]}),(0,Q.jsxs)(`form`,{onSubmit:k,children:[!t&&(0,Q.jsxs)(`div`,{className:`ky-auth-field`,children:[(0,Q.jsx)(`label`,{htmlFor:`login-username`,children:`Username`}),(0,Q.jsx)(`input`,{id:`login-username`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,autoFocus:!0,value:o,onChange:e=>s(e.target.value),required:!0})]}),(0,Q.jsxs)(`div`,{className:`ky-auth-field`,children:[(0,Q.jsx)(`label`,{htmlFor:`login-password`,children:`Password`}),(0,Q.jsx)(`input`,{id:`login-password`,type:`password`,autoComplete:`current-password`,value:c,onChange:e=>l(e.target.value),required:!0,autoFocus:!!t})]}),b&&(0,Q.jsx)(`p`,{className:`error`,role:`alert`,children:b}),(0,Q.jsx)(`p`,{className:`ky-auth-check`}),(0,Q.jsxs)(`button`,{className:`ky-auth-submit`,disabled:S,children:[(0,Q.jsx)(pf,{name:`signin`}),S?`Signing in…`:`Sign in`]})]}),!t&&E?.enabled&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`hr`,{className:`ky-auth-divider`}),(0,Q.jsx)(`a`,{className:`ky-auth-sso`,href:`/api/v1/auth/oidc/login`,children:`Continue with single sign-on`})]})]})})}function Cb({tagline:e,help:t,children:n}){return(0,Q.jsxs)(`main`,{className:`ky-auth`,children:[(0,Q.jsx)(`div`,{className:`ky-auth-theme`,children:(0,Q.jsx)(Zf,{})}),(0,Q.jsxs)(`div`,{className:`ky-auth-body`,children:[(0,Q.jsxs)(`div`,{className:`ky-auth-brand`,children:[(0,Q.jsx)(mf,{size:56}),(0,Q.jsx)(`h1`,{children:`KyNotes`}),(0,Q.jsx)(`p`,{children:e})]}),n,t&&(0,Q.jsx)(`p`,{className:`ky-auth-help`,children:t})]})]})}function wb({auth:e,onLogout:t,onForgetDevice:n,onAuthSecret:r}){let[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),d=(0,X.useRef)(null),f=wf(),[p,m]=(0,X.useState)({}),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)([]),y=(0,X.useRef)([]);y.current=_;let b=e=>{y.current=e(y.current),v(t=>e(t))},[x,S]=(0,X.useState)([]),C=(0,X.useRef)([]),w=e=>{C.current=e(C.current),S(C.current)},[T,E]=(0,X.useState)([]),D=(0,X.useRef)([]),O=e=>{D.current=e(D.current),E(D.current)},k=(0,X.useMemo)(()=>de(T),[T]),[A,j]=(0,X.useState)(Ce),[M,N]=(0,X.useState)(void 0),P=e=>{j(e),N(ye(e,C.current,de(D.current)))},[F,I]=(0,X.useState)([]),[L,R]=(0,X.useState)(()=>Ay(e.user.id)),[ee,te]=(0,X.useState)(!1),[z,ne]=(0,X.useState)(null);(0,X.useEffect)(()=>{if(z&&f&&(s(!1),u.current)){u.current=!1,l(!1);let e=requestAnimationFrame(()=>d.current?.focus());return()=>cancelAnimationFrame(e)}},[z?.id]);let[re,B]=(0,X.useState)([]),[ie,ae]=(0,X.useState)([]),[oe,me]=(0,X.useState)(!1),[ve,Te]=(0,X.useState)(!1),[Ee,De]=(0,X.useState)(!1),Oe=re.length>0,ke=ie.length>0;(0,X.useEffect)(()=>me(Oe),[z?.id,Oe]),(0,X.useEffect)(()=>De(ke),[z?.id,ke]);let[Ae,He]=(0,X.useState)({}),Ge=(0,X.useRef)([]),[Ke,qe]=(0,X.useState)({}),Je=(0,X.useRef)(new Set),[Ye,Xe]=(0,X.useState)(``),[Ze,et]=(0,X.useState)(``);(0,X.useEffect)(()=>{Xe(``),et(``)},[z?.id]);let[tt,rt]=(0,X.useState)(new Set),it=(0,X.useRef)(new Map),[at,ot]=(0,X.useState)(``),[st,ct]=(0,X.useState)(`saved`),lt=(0,X.useRef)(!1),ut=(0,X.useRef)(!1),dt=(0,X.useRef)(Promise.resolve()),ft=(0,X.useRef)(null),U=(0,X.useRef)(null),pt=(0,X.useRef)(null);pt.current=h,U.current=z;let[mt,ht]=(0,X.useState)(0),[gt,_t]=(0,X.useState)([]),[vt,yt]=(0,X.useState)(`unknown`),bt=(0,X.useRef)(vt);bt.current=vt;let[xt,W]=(0,X.useState)(``),[Et,G]=(0,X.useState)(!1),[Dt,kt]=(0,X.useState)(!1),Lt=(0,X.useRef)(!1),Rt=e=>{Lt.current=e,kt(e)},zt=(0,X.useRef)({}),[Ht,Yt]=(0,X.useState)(zt.current),$t=(e,t)=>{zt.current={...zt.current,[e]:t},Yt(zt.current)},en=new Map;Pm();let tn=e=>km(e.id);async function nn(e){let t=tn(e);if(t)return t;let n=await ir.loadKeyState(e.id);return Am(e.id,n),n}let rn=(e,t)=>{let n=tn(e);return n?sm(e,zt.current[e.id]??en,t,n):[]},an=(e,t)=>{let n=e&&tn(e);return e&&!n?[]:cm(e??{sharedGeneration:0},(e&&zt.current[e.id])??en,t,n??Zp,In.current)},on=e=>{let t=tn(e);return t&&tm(e,t)?im(e,zt.current[e.id]??en,t):void 0};(0,X.useEffect)(()=>Lm(on),[]);let sn=(0,X.useRef)(new Set);async function cn(e){sn.current.add(e),await ir.saveKeyState(e,{mark:0,digests:{},objects:2}).catch(()=>!1)}async function ln(e){let t=await lm(rn(e,e.keyGeneration),t=>Ct(t,e.id,$e(e.metaCiphertext),!0));return t.objects===2&&await cn(e.id),t}let un=(e,t,n,r)=>Ft(y.current.find(e=>e.id===t),sn.current.has(e),n,r),dn=e=>on(e)??(In.current&&{key:In.current,generation:0}),fn=e=>{let t=tn(e);return!(!t||tm(e,t))},pn=e=>g(t=>t?.id===e.id?{...t,keyGeneration:e.keyGeneration,sharedGeneration:e.sharedGeneration}:t),mn=!(!h||on(h)),hn=e=>e===`owner`||e===`admin`||e===`editor`,gn=!hn(vt),_n=G_(gt,e.user.id)===!0,vn=t=>G_(Dn?.containerID===t.id?Dn.members:void 0,e.user.id),yn=!!(h&&fn(h)),bn=()=>{let e=pt.current;return!e||on(e)?!1:(W(fn(e)?cb:K_),!0)},xn=()=>bn()?!0:!pt.current||hn(bt.current)?!1:(W(bt.current===`unknown`?Qy:Xy),!0),[Sn,Cn]=(0,X.useState)(``),[wn,Tn]=(0,X.useState)(!1),En=(0,X.useRef)(void 0),[Dn,On]=(0,X.useState)(void 0),kn=(0,X.useRef)({}),[An,jn]=(0,X.useState)(()=>x_(y_())),Mn=(0,X.useRef)(p);Mn.current=p;let Nn=(0,X.useRef)(new Set),Pn=(0,X.useRef)({}),Fn=(0,X.useRef)(void 0),In=(0,X.useRef)(void 0),[Ln,Rn]=(0,X.useState)(!1),zn=(0,X.useRef)(void 0),[Bn,Vn]=(0,X.useState)(),[Hn,Un]=(0,X.useState)(!1);async function Wn(){if(!Fn.current){let t=await vl(e.username,e.user.id).catch(()=>void 0),n=t?await bu().catch(()=>`unreachable`):void 0;Fn.current=qd(t,n),In.current=Fn.current&&am(Fn.current),Rn(!!In.current)}return Fn.current}let[Gn,Kn]=(0,X.useState)(`unknown`),[qn,Jn]=(0,X.useState)(!1);async function Yn(){Fn.current=void 0;let[t,n,r]=await Promise.all([_l(e.username,e.user.id).catch(()=>void 0),bu(),gl(e.username,e.user.id)]);zn.current=n??null,Vn(n??null),Kn(Kd(t,n)),Jn(Hd(t,n,r)),await Wn()}async function Xn(t){let n=In.current,r=am(t);await Ug((await tl()).filter(t=>t.owner===e.user.id),e.user.id,async e=>{let t=n&&await Nt(n,e.containerID,e.id,e.payload,!0);return t?jt(r,e.containerID,e.id,t):void 0},rl)}(0,X.useEffect)(()=>{Yn().catch(()=>void 0),Wn().catch(()=>void 0)},[]);let Zn=()=>{Un(!1),W(``),Yn().then(()=>Di(),()=>void 0)},[Qn,$n]=(0,X.useState)(),er={load:()=>_l(e.username,e.user.id),save:(t,n)=>ml(e.username,e.user.id,t,n),noteReset:t=>hl(e.username,e.user.id,t)};async function tr(e){if(!e||confirm(`Replace this browser's encryption key with a new one? Team owners must share their notebooks' keys with you again, and colleagues are asked to trust your new key.`)){$n(void 0);try{let t=await Bd({myIdentity:bu,putDeviceOnlyIdentity:Su},er,e);t.kind===`held`&&(Un(!0),wr(`account`)),t.kind===`unsaved`&&$n({message:`This browser cannot keep an encryption key (site storage is blocked or unavailable), so none was created.`}),await Yn()}catch(e){$n(_h(e,`set up an encryption key`))}}}async function nr(e){let t=(await j_(ar)).find(t=>t.id===e);if(!t)throw Error(`Notebook not found`);return t}let rr={container:nr,envelopes:Iu,members:Bu,userIdentity:zu,stepUp:e.sso?async()=>{}:async()=>{if(e.authSecret)return void await yu(e.authSecret);En.current??=tf(e.username).then(e=>(r(e),e));try{await yu(await En.current)}catch(e){throw En.current=void 0,e}},putEnvelopes:Lu,rotate:Ru},ir={load:()=>Cl(e.username,e.user.id),addFresh:t=>wl(e.username,e.user.id,t),confirm:(t,n)=>Tl(e.username,e.user.id,t,n),loadKeyState:t=>Dl(e.username,e.user.id,t),saveKeyState:(t,n)=>Ol(e.username,e.user.id,t,n)},ar={load:ir.loadKeyState,save:ir.saveKeyState},or=e=>_i(e).catch(()=>`unreadable key`),sr=e=>`${e.member.userId}:${e.member.identity?.publicKey??``}`;function cr(e){return async e=>{if(e.some(e=>Nn.current.has(sr(e))))return!1;let t=await Promise.all(e.map(async e=>`${gi(e.member.username,e.member.userId)}: ${await or(e.member.identity.publicKey)} (was ${await or(e.pinned)})`)),n=confirm(`The encryption key of ${e.map(e=>gi(e.member.username,e.member.userId)).join(`, `)} changed since this browser last saw it. A password reset or account recovery does this; so would a server substituting its own key. Compare these fingerprints with the person (Settings shows theirs) before continuing:\n\n${t.join(` +`)}\n\nTrust the new key and exchange this notebook's keys with it?`);if(!n)for(let t of e)Nn.current.add(sr(t));return n}}async function lr(e,t,n){let r=[],i=e.plan;return i.kind===`unrecoverable`?r.push(q_):i.kind===`untrusted`?r.push(n?`No keys were exchanged with ${i.members.join(`, `)}: you did not confirm their new encryption key.`:`The encryption key of ${i.members.join(`, `)} changed. Reopen this notebook to compare fingerprints.`):i.kind===`rollback`?r.push(cb):i.kind===`pins-unsaved`&&r.push(`No keys were exchanged: this browser could not save the colleague keys it checked. Allow site storage and reopen the notebook.`),e.conflicts.length&&r.push(`A different key was offered for this notebook than the one this device already accepted; it was refused.`),t.length&&r.push(`Now sharing with: ${(await Promise.all(t.map(async e=>`${gi(e.username,e.userId)} (fingerprint ${await or(e.identity.publicKey)})`))).join(`, `)}.`),e.keyStateSaved||r.push(`This browser could not save its key memory; after a reload it cannot tell if this notebook's keys were swapped.`),r.join(` `)}let ur=(0,X.useRef)(new Map);function dr(e,t){let n=(ur.current.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return ur.current.set(e,n.catch(()=>void 0)),n}async function fr(t,n=!1,r=()=>!1,i=!1){return await nn(t),zn.current===void 0&&await Yn().catch(()=>void 0),dr(t.id,async()=>{let o=n?()=>!1:e=>!r()&&cr(t.id)(e),s=await u_(rr,t.id,{userId:e.user.id,identity:await Wn(),canWrap:i||!e.sso&&(!n||e.authSecret!==``),recoverable:Ud(zn.current)},ir,o,zt.current[t.id],Am);$t(t.id,s.ring);for(let e of s.members)kn.current[e.userId]=e.username;Am(t.id,s.known);let c={...t,keyGeneration:s.container.keyGeneration,sharedGeneration:s.container.sharedGeneration};a(e=>e.map(e=>e.id===c.id?{...e,keyGeneration:c.keyGeneration,sharedGeneration:c.sharedGeneration}:e));let l=``;s.minted&&([c,l]=await mr(c,s.members.some(t=>t.userId!==e.user.id)));let u=[...Pn.current[t.id]??[],...s.plan.kind===`pins-unsaved`?[]:s.fresh];return!r()&&(kr.current??pt.current?.id)===t.id?(delete Pn.current[t.id],On({containerID:t.id,members:s.members,status:s.plan.kind===`rollback`?{}:pm(s.container,s.members,s.envelopes)}),Tn(s.deferred),Cn([await lr(s,u,!n),l].filter(Boolean).join(` `))):Pn.current[t.id]=u,c})}async function pr(){let e=pt.current;if(e){$n(void 0);try{pn(await fr(e,!1,()=>!1,!0))}catch(e){$n(_h(e,`share keys`))}}}async function mr(e,t){try{let n=await nr(e.id),r={...e,metaCiphertext:n.metaCiphertext,metaVersion:n.metaVersion,changeSeq:n.changeSeq,keyGeneration:n.keyGeneration,sharedGeneration:n.sharedGeneration},i=on(n);if(!i||!n.metaCiphertext)return[r,``];let o=$e(n.metaCiphertext),s=t=>lm(t,t=>Ct(t,e.id,o,!sn.current.has(e.id))).then(async t=>(t.objects===2&&await cn(e.id),t.name),()=>void 0);if(await s([i.key])!==void 0)return[r,``];let c=zt.current[e.id]??en,l=Mn.current[e.id];if(l){if(await s([...c.values()])!==l)return[r,`This notebook's name changed while its keys were shared. Rename it so every member can read it.`]}else{if(l=await s([...c.entries()].filter(([e])=>et-e).map(([,e])=>e))??``,!l)return[r,t?`This notebook's name could not be shared with its members yet. Rename it so every member can read it.`:`This notebook's name could not be sealed with its key yet. Rename it to try again.`];let n=l;m(t=>({...t,[e.id]:n}))}let u=Qe(await St(i.key,e.id,l,sn.current.has(e.id))),d=await Bm({container:n,generation:i.generation},u,n.metaVersion);return a(t=>t.map(t=>t.id===e.id?{...t,metaCiphertext:u,metaVersion:d.metaVersion,changeSeq:d.changeSeq}:t)),[{...r,metaCiphertext:u,metaVersion:d.metaVersion,changeSeq:d.changeSeq},t?`Sealed this notebook's name with its key: ${l}.`:``]}catch{return[e,t?`This notebook's name could not be shared with its members yet. Rename it to try again.`:`This notebook's name could not be sealed with its key yet. Rename it to try again.`]}}let[hr,gr]=(0,X.useState)(0),[_r,vr]=(0,X.useState)(null),yr=(0,X.useRef)(!1),[br,xr]=(0,X.useState)(()=>Ue(location.hash)),[Sr,Cr]=(0,X.useState)(br?`settings`:`workspace`);function wr(e){location.hash=We(e)}let[Tr,Er]=(0,X.useState)(!1),[Dr,Or]=(0,X.useState)(!1),kr=(0,X.useRef)(void 0),Ar=(0,X.useMemo)(T_,[]),jr=(0,X.useRef)(new Map),Mr=(e,t)=>{kr.current&&jr.current.set(e,t)},Nr=(0,X.useRef)(Promise.resolve()),Pr=e=>{let t=Nr.current.then(e);return Nr.current=t.catch(()=>{}),t},Fr=e=>Pr(e).then(()=>!1,()=>!0),[Ir,Lr]=(0,X.useState)(``),[Rr,zr]=(0,X.useState)(null),[,Br]=(0,X.useState)(0),Vr=e=>p[e.id]||`Notebook ${e.id.slice(4,10)}`,Hr=(0,X.useDeferredValue)(_),Ur=(0,X.useMemo)(()=>[...Hr].sort(je),[Hr]),Wr=(0,X.useMemo)(()=>Ne(_,x,A),[_,x,A]),Gr=(0,X.useMemo)(()=>V(Wr),[Wr]),Kr=h?`kynotes-collapsed-${e.user.id}-${h.id}`:``,[qr,Jr]=(0,X.useState)(()=>new Set);(0,X.useEffect)(()=>{Jr(Se(Kr?Bf(Kr):null))},[Kr]);function Yr(e){let t=new Set(y.current.map(e=>e.id)),n=[...qr].filter(n=>n!==e&&t.has(n));qr.has(e)||n.push(e),Kr&&Vf(Kr,JSON.stringify(n)),Jr(new Set(n))}let Xr=(e,t)=>{let n=ce(e,t);Jr(e=>n.some(t=>e.has(t))?new Set([...e].filter(e=>!n.includes(e))):e)};(0,X.useEffect)(()=>{let e=z?.id;e&&Xr(Wr,e)},[z?.id,A,Kr]);let Zr=e=>x.find(t=>t.id===e)?.title??`Quick Notes`,Qr=(0,X.useMemo)(()=>uy(Ur),[Ur]);(0,X.useEffect)(()=>{let e=!1,t=[];return Promise.all(ie.filter(e=>e.type.startsWith(`image/`)).map(async e=>{try{let n=await od(e.id),r=h?.id??``,i=await un(r,e.page,e.id,n),a=await lm(h?rn(h,e.keyGeneration):[],t=>At(t,r,e.page,n,i)),o=URL.createObjectURL(new Blob([a.slice().buffer],{type:e.type}));return t.push(o),[e.id,o]}catch{return null}})).then(t=>{e||He(Object.fromEntries(t.filter(e=>e!==null)))}),()=>{e=!0,t.forEach(e=>URL.revokeObjectURL(e)),He({})}},[ie,Ht,h?.id,h?.sharedGeneration]),(0,X.useEffect)(()=>()=>{Ge.current.forEach(e=>URL.revokeObjectURL(e)),Ge.current=[]},[z?.id]);let $r=(0,X.useMemo)(()=>_y(Qr,Ir).map(e=>e.note),[Qr,Ir]),ei=(0,X.useMemo)(()=>{let e=new Map(_.map(e=>[e.id,e]));z&&e.set(z.id,z);let t=new Set(F.map(e=>e.note.id)),n=h&&h.kind!==`team`&&!h.teamId?[...e.values()].filter(e=>!t.has(e.id)).map(e=>({note:e,container:h})):[];return[...F.map(t=>({...t,note:e.get(t.note.id)??t.note})),...n]},[F,_,z,h]),ti=(0,X.useMemo)(()=>{let e=vy(_y(uy(ei.map(e=>e.note)),Ir)),t=new Map(ei.map(e=>[e.note.id,e]));return e.map(e=>t.get(e.note.id)).filter(e=>!!e)},[ei,Ir]),ni=(0,X.useMemo)(()=>ei.flatMap(e=>my(uy([e.note])[0]).map(t=>({...t,entry:e,key:`${e.note.id}\n${t.raw}`}))),[ei]),ri=Iy(ni,L);(0,X.useEffect)(()=>{(L.enabled||L.push||Tr)&&i.length&&Ni().catch(()=>void 0)},[L.enabled,L.push,i.length]),(0,X.useEffect)(()=>{(L.push?Py():Fy()).catch(()=>void 0)},[]);let ii=(0,X.useMemo)(()=>ni.filter(e=>e.push).map(e=>({noteID:e.entry.note.id,remind:e.remind,push:!0})),[ni]),ai=ii.map(e=>`${e.noteID}\n${e.remind}`).sort().join(` +`),oi=(0,X.useRef)(Promise.resolve()),si=(0,X.useRef)(void 0);(0,X.useEffect)(()=>{!L.push||!ee?si.current=void 0:oi.current=oi.current.then(async()=>{let e=await Wn();if(!e)return;let t=Vy(om(e),ii,Date.now()),n=Hy(t,await vd(),ee,si.current);for(let e of n.deletes)await bd(e);for(let e of n.puts)await yd(e.id,e.at);si.current=t}).catch(()=>void 0)},[L.push,ee,ai]);let ci=Tr?ti:(Ir.trim()?$r:Wr).map(e=>({note:e,container:h})).filter(e=>!!e.container),li=!Tr&&!Ir.trim()&&!gn,ui=new Set(ti.map(e=>e.note.id)),di=Tr?ni.filter(e=>ui.has(e.entry.note.id)).map(e=>({...e,missed:ri.has(e.key),group:$v(e,new Date,ri.has(e.key))})).sort((e,t)=>(e.due??`~`).localeCompare(t.due??`~`)):[],fi=!Tr&&ye(A,x,k)!==M,pi=fi&&li,mi=li&&h?se(fi?[]:Wr,qr).map(e=>({note:e.item,container:h,row:e})):ci.map(e=>({...e,row:void 0})),hi=e=>Wr.findIndex(t=>t.id===e),vi=(e,t)=>hi(e)>=0&&le(Wr,hi(e),t)!==void 0,yi=(0,X.useMemo)(()=>{let e=new Map;return(t,n)=>{let r=t===`group`?n:``;return e.has(r)||e.set(r,ge(T,k,t===`group`?n:void 0)),e.get(r)}},[T,k]),bi=e=>{let[t,n]=H(Gr,hi(e));return n-t-1},xi=e=>e===void 0?void 0:Wr[e]?.id??null,Si=(0,X.useMemo)(()=>yy(Qr,z?uy([z])[0]:void 0).map(e=>e.note),[Qr,z]),Ci=(0,X.useMemo)(()=>by(Qr),[Qr]);(0,X.useEffect)(()=>{Di()},[]),(0,X.useEffect)(()=>{Na();let e=window.setInterval(()=>void Na(),15e3);return()=>window.clearInterval(e)},[]),(0,X.useEffect)(()=>{let e=typeof BroadcastChannel>`u`?null:new BroadcastChannel(`kynotes-sync`);ft.current=e,e?.addEventListener(`message`,()=>void Ji());let t=()=>void Ji();window.addEventListener(`online`,t),Ji();let n=window.setInterval(t,15e3);return()=>{window.removeEventListener(`online`,t),window.clearInterval(n),e?.close(),ft.current=null}},[]),(0,X.useEffect)(()=>{let e=()=>{let e=Ue(location.hash);e&&location.hash!==We(e)&&history.replaceState(null,``,We(e)),e&&(s(!1),xr(e)),Cr(e?`settings`:`workspace`)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let wi=(0,X.useRef)(Sr);wi.current=Sr,(0,X.useEffect)(()=>{Sr===`workspace`&&Ue(location.hash)&&(Tr||!h?history.pushState(null,``,location.pathname+location.search):location.hash=Be({container:h.id,section:A,page:z?.id}))},[Sr]),(0,X.useEffect)(()=>{if(wi.current!==`workspace`||Ue(location.hash)||Tr||Dr||!h)return;let e=Be({container:h.id,section:A,page:z?.id});location.hash!==e&&(ze(location.hash).container?location.hash=e:history.replaceState(null,``,e))},[Tr,Dr,h?.id,A,z?.id]),(0,X.useEffect)(()=>{let e=()=>void(async()=>{let e=b_(location,history,y_());if(e){jn(e);return}let t=ze(location.hash),n=i.find(e=>e.id===t.container);if(!n||t.container===kr.current||n.id===h?.id&&t.section===A&&t.page===z?.id)return;let r=()=>h&&history.replaceState(null,``,Be({container:h.id,section:A,page:U.current?.id}));if(n.id!==h?.id){await Ai(n,t)||r();return}let a=_.find(e=>e.id===t.page);t.page!==U.current?.id&&!await qi()?r():(P(Re(t.section,x)),a?await Ii(a)||r():ze(location.hash).page||ne(null))})();return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[i,h?.id,A,z?.id,_,x]),(0,X.useEffect)(()=>{if(!Rr)return;let e=window.setInterval(()=>Br(e=>e+1),1e3),t=window.setTimeout(()=>zr(null),Uy);return()=>{window.clearInterval(e),window.clearTimeout(t)}},[Rr]),(0,X.useEffect)(()=>{if(!h)return;Hu(h.id,z?`editing`:`viewing`).catch(()=>{});let e=window.setInterval(()=>{Hu(h.id,z?`editing`:`viewing`).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[h?.id,z?.id]);let Ti=(0,X.useRef)(()=>void 0);Ti.current=()=>{let e=pt.current;e&&!kr.current&&document.visibilityState===`visible`&&fr(e,!0).then(e=>{pn(e),on(e)&&Ji()}).catch(()=>void 0)},(0,X.useEffect)(()=>{let e=()=>{Vu().then(e=>ht(e.length)).catch(()=>ht(0)),Ti.current()};e();let t=window.setInterval(e,9e4);return()=>window.clearInterval(t)},[]),(0,X.useEffect)(()=>{document.title=mt?`(${mt}) KyNotes`:`KyNotes`},[mt]),(0,X.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()===`l`&&z&&(e.preventDefault(),Xa())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z]),(0,X.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&z&&(e.preventDefault(),Ki(z))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[z,h]);let Ei=Dt&&z!==null&&!tt.has(z.id);(0,X.useEffect)(()=>{if(!Ei)return;let e=window.setTimeout(()=>{Ki(z,!0)},900);return()=>window.clearTimeout(e)},[z?.title,z?.body,Ei]),(0,X.useEffect)(()=>{if(!Ei)return;let e=window.setInterval(()=>{U.current&&Ki(U.current,!0)},15e3);return()=>window.clearInterval(e)},[z?.id,Ei]),(0,X.useEffect)(()=>{let e=()=>{let e=U.current;e&&Dt&&(Zi(e),Ki(e,!0))},t=()=>{document.visibilityState===`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,e)}},[Dt,h?.id]);async function Di(t=!0){let n=Ar.mark();try{let r=await j_(ar),i={},o=!1,s=await Wn(),c={...rr,container:async e=>r.find(t=>t.id===e)??nr(e)};for(let t of r)try{let n=t,r=await ir.loadKeyState(t.id);if(Am(t.id,r),r.objects===2&&sn.current.add(t.id),t.sharedGeneration>0||(r.shared??0)>0){let r=await dr(t.id,async()=>{let n=await u_(c,t.id,{userId:e.user.id,identity:s,canWrap:!1,recoverable:!1},ir,()=>!1,zt.current[t.id],Am);$t(t.id,n.ring);for(let e of n.members)kn.current[e.userId]=e.username;return Am(t.id,n.known),n});r.plan.kind!==`pins-unsaved`&&r.fresh.length&&(Pn.current[t.id]=[...Pn.current[t.id]??[],...r.fresh]),n={...t,keyGeneration:r.container.keyGeneration,sharedGeneration:r.container.sharedGeneration}}if(t.metaCiphertext){let e=await ln(n);sn.current.has(t.id)&&e.objects!==2?o=!0:i[t.id]=e.name}}catch{}if(n())return await Di(!1);m(i),a(r),o&&W(lb);let l=ze(location.hash),u=r.find(e=>e.id===l.container)??r[0];u&&t&&await Ai(u,u.id===l.container?l:void 0,!1)}catch(e){W(e instanceof Error?e.message:`Unable to load notebooks`)}}async function Oi(t,n=`recover`){let r=0,i=new Set,a=!sn.current.has(t.id),o=[],s=[],c=[],l=(e,t,n,r)=>{t&&(t.type===`section`?s.push({...t,id:e,version:n}):t.type===`group`?c.push({...t,id:e,version:n}):o.push({id:e,title:t.title,body:t.body,section:t.section,order:t.order,level:t.level,legacy:t.legacy,version:n,updatedAt:r}))},u=0;for(let o=0;oe.kind===`object`&&!e.deleted))try{let r=await Zu(s.id),o=e=>lm(rn(t,r.keyGeneration),n=>Mt(n,t.id,s.id,r.bytes,e)),c=await Pl({owner:e.user.id,id:s.id,version:r.version,mode:n,open:e=>lm(an(t,e.keyGeneration),n=>Nt(n,t.id,s.id,e.payload,!0)),server:()=>o(a).then(e=>e.payload)}),u=!!c,d=u?await lm(an(t,c.keyGeneration),e=>Nt(e,t.id,s.id,c.payload,!0)):await o(a).then(e=>(e.v1&&i.add(s.id),e.payload));u&&await o(!1).then(()=>!1,()=>!0)&&i.add(s.id),l(s.id,d,u?c.version:r.version,u?c.updatedAt:r.savedAt)}catch{try{let n=await qc(e.user.id,s.id);if(!n)throw Error(`no local copy`);l(s.id,await lm(an(t,n.keyGeneration),e=>Nt(e,t.id,s.id,n.payload,!0)),n.version,n.updatedAt),i.add(s.id)}catch{r+=1}}if(!o.hasMore)break;let s=Number(o.nextCursor);if(!Number.isSafeInteger(s)||s<=u)break;u=s}return{notes:o,sections:s,groups:c,unreadable:r,legacy:i}}async function ki(e){let t=Sr!==`workspace`&&h?.id===e.id&&!Tr;Cr(`workspace`),t?s(!1):await Ai(e)}async function Ai(e,t,n=!0){let r=Ar.begin();kr.current=e.id,Or(!0);try{return await ji(e,t,r.superseded,n)}finally{r.superseded()||(kr.current=void 0,Or(!1))}}async function ji(t,n,r,i){if(!await qi())return null;if(r())return[];g(t),yt(`unknown`),i&&Er(!1),U.current=null,ne(null),b(()=>[]),w(()=>[]),O(()=>[]),N(void 0),B([]),ae([]),jr.current.clear(),Cn(``),Tn(!1);try{let i=await fr(t,!1,r).catch(e=>(r()||W(e instanceof Error?`Unable to share this notebook's keys: ${e.message}`:`Unable to share this notebook's keys`),t));if(r())return[];g(i),(await ir.loadKeyState(i.id)).objects===2&&sn.current.add(i.id);let a=await Oi(i);if(r())return[];a.unreadable&&W(Zt(a.unreadable));let o=Jt(a.notes,jr.current),s=qt(a.sections,jr.current);w(()=>s),O(()=>qt(a.groups,jr.current)),jr.current.clear(),b(()=>o),P(Re(n?.section,s));let c=n?.page?o.find(e=>e.id===n.page):void 0;c&&await Ii(c,i);let l=t.kind===`team`?await Bu(t.id).catch(()=>void 0):[];r()||_t(l??[]);let u=t.teamId?await Bu(t.id).catch(()=>void 0):l,d=t.kind===`team`||t.teamId?u?.find(t=>t.userId===e.user.id)?.role??`unknown`:`owner`;if(r()||yt(d),!r()&&d===`unknown`&&W(Qy),!r()&&hn(d)&&await Mi(r),!r()&&(d===`owner`||d===`admin`||d===`editor`)){let e=[...o.map(e=>({id:e.id,type:`page`,legacy:e.legacy})),...s.map(({id:e})=>({id:e,type:`section`})),...a.groups.map(({id:e})=>({id:e,type:`group`}))];ea.current={containerID:i.id,unreadable:a.unreadable,objects:e.map(e=>({...e,v1:a.legacy.has(e.id)}))},na(e=>e+1)}return o}catch(e){return r()||W(e instanceof Error?e.message:`Unable to load notebook`),[]}}async function Mi(t){let n=U.current;if(!n)return;let r=await Zc(e.user.id,n.id).catch(()=>void 0);t()||U.current?.id!==n.id||!r||r.gone||r.previousKey||r.conflicted||Rt(!0)}async function Ni(){let e=i.filter(e=>e.kind!==`team`&&!e.teamId),t=await Promise.allSettled(e.map(async e=>{let{notes:t,unreadable:n}=await Oi(e);return{container:e,notes:t,unreadable:n}}));t.some(e=>e.status===`rejected`)&&W(`Some personal notebooks could not be loaded; the work queue may be incomplete.`),te(t.every(e=>e.status===`fulfilled`&&e.value.unreadable===0));let n=t.flatMap(e=>e.status===`fulfilled`?e.value.notes.map(t=>({note:t,container:e.value.container})):[]);I(n)}async function Pi(){s(!1),Cr(`workspace`),Er(!0),G(!0);try{await Ni()}catch(e){W(e instanceof Error?e.message:`Unable to load work queue`)}finally{G(!1)}}async function Fi(e){let t=await Ai(e.container);if(!t)return;let n=t.find(t=>t.id===e.note.id);n&&await Ii(n,e.container),Er(!0)}async function Ii(t,n=h){let r=n?.id??``;if(n&&(kr.current??pt.current?.id)!==r)return!1;let i=U.current;if(i&&i.id!==t.id&&!await qi()||n&&(kr.current??pt.current?.id)!==r)return!1;let a=i?.id===t.id?i:y.current.find(e=>e.id===t.id)??t;if(U.current=a,ne(a),i?.id!==a.id){Rt(!1),ot(a.version>0?a.updatedAt:``);let t=await Zc(e.user.id,a.id).catch(()=>void 0);t&&U.current?.id===a.id&&(ct(t.conflicted||t.gone?`attention`:`local`),ot(``))}let o=()=>U.current?.id===a.id;try{let e=await sd(a.id);rt(t=>{let n=new Set(t);return e.some(e=>!e.resolved)?n.add(a.id):n.delete(a.id),n})}catch{}try{let e=await Ku(a.id),t=[];for(let i of e)try{let e=$e(i.bodyCiphertext),o=await un(r,a.id,i.id,e),s=await lm(n?rn(n,i.keyGeneration):[],t=>Tt(t,r,a.id,e,o));t.push({id:i.id,authorUserId:i.authorUserId,username:i.username,body:s.body,section:s.section,createdAt:i.createdAt})}catch{}o()&&B(t)}catch{o()&&B([])}try{let e=await ad(a.id),t=[];for(let i of e)try{let e=$e(i.metadataCiphertext),o=await un(r,a.id,Pt(i.id),e),s=await lm(n?rn(n,i.keyGeneration):[],t=>Ot(t,r,a.id,e,o));t.push({id:i.id,...s,keyGeneration:i.keyGeneration,page:a.id})}catch{}o()&&ae(t)}catch{o()&&ae([])}return!0}async function Li(e,t){if(!await Wn())throw Error(db);if(zn.current===void 0&&await Yn().catch(()=>void 0),!Ud(zn.current))throw Error(q_);let n=await P_(e,async e=>{let n=await fr(e,!1,()=>!1,!0),r=on(n);if(!r)throw Error(ub);let i=Qe(await St(r.key,n.id,t,!0)),a=await Bm({container:n,generation:r.generation},i,n.metaVersion);return{...n,metaCiphertext:i,metaVersion:a.metaVersion,changeSeq:a.changeSeq}},au);return await cn(n.id),m(e=>({...e,[n.id]:t})),a(e=>[...e.filter(e=>e.id!==n.id),n]),n}async function Ri(){let e=prompt(`Notebook name`,`My notebook`)?.trim();if(e){G(!0);try{await ki(await Li(()=>M_(ar,`workbook`),e))}catch(e){W(e instanceof Error?e.message:`Unable to create notebook`)}finally{G(!1)}}}async function zi(e){let t=prompt(`Notebook name`,`New notebook`)?.trim();if(t){G(!0);try{await ki(await Li(()=>M_(ar,`workbook`,e.id),t))}catch(e){W(e instanceof Error?e.message:`Unable to create team notebook`)}finally{G(!1)}}}async function Bi(){if(!h)return;let e=prompt(`Notebook name`,Vr(h))?.trim();if(e){G(!0);try{let t=await fr(await nr(h.id)),n=on(t);if(!n)throw Error(K_);t.metaCiphertext&&await ln(t).catch(()=>void 0);let r=Qe(await St(n.key,t.id,e,sn.current.has(t.id))),i=await Bm({container:t,generation:n.generation},r,h.metaVersion),o={...t,metaCiphertext:r,metaVersion:i.metaVersion,changeSeq:i.changeSeq};m(t=>({...t,[h.id]:e})),a(e=>e.map(e=>e.id===o.id?o:e)),g(e=>e?.id===o.id?o:e)}catch(e){W(e instanceof Error?e.message:`Unable to rename notebook`)}finally{G(!1)}}}async function Vi(){let n=pt.current;if(!n)return;let r=Vr(n),o=prompt(rb(r,n.kind===`team`));if(o===null)return;if(o.trim()!==r.trim()){W(`The name did not match, so nothing was deleted.`);return}G(!0);try{await au(n.id)}catch(e){e instanceof Bl&&e.status===403&&e.message===`re-authentication required`?confirm(nb)&&t():W(e instanceof Error?e.message:`Unable to delete notebook`);return}finally{G(!1)}let s=e=>e.id===n.id||e.teamId===n.id,c=new Set(i.filter(s).map(e=>e.id).concat(n.id));a(e=>e.filter(e=>!s(e)));let l=kr.current??pt.current?.id,u=!!(l&&c.has(l)),d=u?y.current.map(e=>e.id):[],f=Promise.resolve();if(u){Rt(!1),U.current=null,ne(null),history.replaceState(null,``,location.pathname+location.search);let e=i.find(e=>!s(e));e?f=Ai(e):(g(null),b(()=>[]),w(()=>[]),O(()=>[]))}for(let t of d)await Jc(e.user.id,t).catch(()=>void 0);for(let t of(await tl().catch(()=>[])).filter(t=>t.owner===e.user.id))c.has(t.containerID)&&await nl(t.owner,t.id,t.updatedAt).catch(()=>void 0);await f}async function Hi(){if(!h)return;let e=h,t=Vr(e);if(confirm(`${tb}\n\nExport "${t}"?`)){G(!0);try{let{blockNoteMarkdown:n,buildNotebookExport:r,safeName:i}=await fo(async()=>{let{blockNoteMarkdown:e,buildNotebookExport:t,safeName:n}=await import(`./exportNotebook-BDS11KSz.js`);return{blockNoteMarkdown:e,buildNotebookExport:t,safeName:n}},[]),a=await Oi(e,`read`),o=await r({name:t,...a,toMarkdown:await n(),attachments:{list:async e=>(await ad(e)).map(t=>({...t,pageID:e})),open:async t=>{let n=rn(e,t.keyGeneration),r=a.notes.find(e=>e.id===t.pageID),i=sn.current.has(e.id),o=$e(t.metadataCiphertext),s=await Ft(r,i,Pt(t.id),o),c=await lm(n,n=>Ot(n,e.id,t.pageID,o,s)),l=await od(t.id),u=await Ft(r,i,t.id,l);return{id:t.id,...c,bytes:await lm(n,n=>At(n,e.id,t.pageID,l,u))}}}});Tp(`${i(t,`notebook`)}.zip`,zg(o.entries),`application/zip`),W(`Exported ${o.pages} pages.${o.unreadable?` ${o.unreadable} items could not be read and are not in the file.`:``}`)}catch(e){W(e instanceof Error?e.message:`Unable to export notebook`)}finally{G(!1)}}}async function Ui(){if(!(!h||mn||xn())){G(!0);try{if(!await qi())return;let e=Pe(Ne(y.current,C.current,A)),t=await Xu(h.id);if((kr.current??pt.current?.id)!==h.id){await md(t.id).catch(()=>void 0);return}let n={id:t.id,title:`Untitled page`,body:Nv(jv()),section:A===`quick`?void 0:A,order:e,legacy:{},version:0,updatedAt:new Date().toISOString()};b(e=>[n,...e]),U.current=n,ne(n),Rt(!0),Zi(n),await Ki(n,!0)}catch(e){W(e instanceof Error?e.message:`Unable to create note`)}finally{G(!1)}}}async function Wi(t,n=!1){if(h&&hn(bt.current)){n||G(!0);try{let n=dn(h)??ym(),r,i=await Fr(async()=>{r=await Ml({owner:e.user.id,containerID:h.id,note:t,write:n}),await Xc(r)}),a=r??ym(),o=a.payload,s=a.updatedAt,c=h.id;if(n.generation===0)return await Yc({id:t.id,containerID:c,version:t.version,payload:o,updatedAt:s,keyGeneration:n.generation,owner:e.user.id}).catch(ym),ct(`local`),W(ev(vn(h))),t;try{let e=await zm({container:h,generation:n.generation},t.id,o,t.version);it.current.delete(a.id);let r=await Fr(()=>el(a,e.version));zr(Date.now()),rt(e=>{let n=new Set(e);return n.delete(t.id),n});let c={...t,version:e.version,updatedAt:s};ot(s),ct(`saved`),(i||r)&&W(fb),b(e=>Wt(e,c.id,c)),Mr(c.id,c),I(e=>e.flatMap(e=>e.note.id===c.id?vy(uy([c])).length?[{...e,note:c}]:[]:[e]));let l=U.current;if(l?.id===c.id){let[e]=Wt([l],c.id,c);U.current=e,ne(e),Gt(l,t)&&Rt(!1)}}catch(e){if(e instanceof Bl&&e.code===`version_conflict`)it.current.set(a.id,a),rt(e=>new Set(e).add(t.id)),ct(`attention`),W(bm(i)),await rl(a,{...a,conflicted:!0}).catch(()=>void 0);else{let n=e instanceof Bl&&e.code===`not_found`?{gone:!0}:{};if(await Yc({...a,...n}).catch(ym),ft.current?.postMessage({type:`queued`,id:t.id}),ct(`local`),e instanceof Bl&&e.code===`already_exists`||e instanceof Fm)Ji();else if(e instanceof Bl&&e.code===`not_found`)ct(`attention`),W($y);else{let t=Qt(e instanceof Bl?e.code:void 0);t&&ct(`attention`),W(t??`Saved locally; encrypted change queued for the server.`)}}}return t}catch(e){W(e instanceof Error?e.message:`Unable to save note`);return}finally{n||G(!1)}}}function Gi(e){let t=dt.current.then(e);return dt.current=t.then(()=>{},()=>{}),t}function Ki(e,t=!1){return Gi(()=>{let n=U.current;if(n&&n.id===e.id)return Wi(n,t)})}async function qi(){if(!Lt.current)return!0;let e=await Xt(()=>U.current,e=>Ki(e,!0),eb);return e===`busy`&&W(`This page is still saving. Try again in a moment.`),e===`done`}function Ji(){lt.current||(lt.current=!0,Gi(Yi))}async function Yi(){try{let t=(await tl()).filter(t=>t.owner===e.user.id).filter(e=>!e.previousKey);if(!t.length)return;ct(`syncing`);let n=!1,r=!1,i=new Map;for(let e of t){if(e.gone||e.conflicted||$c(it.current.get(e.id),e)){r=!0;continue}let t=e;try{let e=await K(t,i).catch(e=>{let t=Qt(e instanceof Bl?e.code:void 0);t&&(r=!0,W(t))});if(!e){n=!0;continue}t=e.item;let a=await zm({container:e.container,generation:t.keyGeneration},t.id,t.payload,t.version);it.current.delete(t.id),await el(t,a.version);let o={version:a.version,updatedAt:t.updatedAt};b(e=>Wt(e,t.id,o)),Mr(t.id,o),w(e=>e.map(e=>e.id===t.id?{...e,version:a.version}:e)),O(e=>e.map(e=>e.id===t.id?{...e,version:a.version}:e));let s=U.current;if(s?.id===t.id){let[e]=Wt([s],t.id,o);U.current=e,ne(e),ot(t.updatedAt)}}catch(e){if(e instanceof Bl&&e.code===`version_conflict`)it.current.set(t.id,t),rt(e=>new Set(e).add(t.id)),r=!0,W(bm(!1)),await rl(t,{...t,conflicted:!0}).catch(()=>void 0);else if(e instanceof Bl&&(e.code===`not_found`||e.code===`forbidden`))await rl(t,{...t,gone:!0}),r=!0,W(e.code===`forbidden`?Zy:$y);else{let t=Qt(e instanceof Bl?e.code:void 0);t?(r=!0,W(t)):n=!0}}}ct(r?`attention`:n?`local`:`saved`)}catch{ct(`local`)}finally{lt.current=!1}}async function K(t,n){n.has(t.containerID)||n.set(t.containerID,nr(t.containerID).then(async t=>{let n=(await Bu(t.id)).find(t=>t.userId===e.user.id)?.role;return n&&hn(n)?fr(t,!0):void 0}));let r=await n.get(t.containerID);if(!r)return;pn(r);let i=await hm(t,r,tn(r),on(r),zt.current[r.id]??en,In.current);if(!i)return;let a=i===t?t:{...i,owner:e.user.id};if(a===t||await rl(t,a))return{item:a,container:r}}async function Xi(t){if(!xn()&&confirm(`Delete this page?`))try{await md(t.id),await Jc(e.user.id,t.id),b(e=>e.filter(e=>e.id!==t.id)),ne(null)}catch(e){W(e instanceof Error?e.message:`Unable to delete note`)}}function Zi(t){if(!h)return;let n=h.id,r=dn(h);r&&Pr(async()=>{let i=await Ml({owner:e.user.id,containerID:n,note:t,write:r});await Gc(e.user.id,{...i,unsent:!0})}).catch(()=>{})}async function Qi(t,n,r){if(!h)return null;let i=dn(h)??ym(),a=h.id,o,s=await Fr(async()=>{o=await Nl({owner:e.user.id,containerID:a,id:t,version:n,content:r,write:i}),await Xc(o)}),c=o??ym(),l=c.payload,u=c.updatedAt;if(i.generation===0)return await Yc({id:t,containerID:a,version:n,payload:l,updatedAt:u,keyGeneration:i.generation,owner:e.user.id}).catch(ym),ct(`local`),W(ev(vn(h))),null;try{let e=await zm({container:h,generation:i.generation},t,l,n);it.current.delete(c.id);let r=await Fr(()=>el(c,e.version));return Mr(t,{version:e.version,updatedAt:u}),(s||r)&&W(fb),e.version}catch(e){if(e instanceof Bl&&e.code===`version_conflict`)it.current.set(c.id,c),rt(e=>new Set(e).add(t)),ct(`attention`),W(`This item changed on another device. Reopen the notebook before changing it again.`),await rl(c,{...c,conflicted:!0}).catch(()=>void 0);else{await Yc(c).catch(ym),ft.current?.postMessage({type:`queued`,id:t});let n=Qt(e instanceof Bl?e.code:void 0);ct(n?`attention`:`local`),n&&W(n),(e instanceof Bl&&e.code===`already_exists`||e instanceof Fm)&&Ji()}return null}}function $i(e,t,n){if(xn())return Promise.resolve(!1);let r=t=>e===`section`?w(t):O(t);return r(e=>e.map(e=>e.id===t?{...e,...n}:e)),Gi(async()=>{let n=e===`section`?C.current.find(e=>e.id===t):D.current.find(e=>e.id===t);if(!n)return!1;let{id:i,version:a,...o}=n,s=await Qi(t,a,o);return s!==null&&r(e=>e.map(e=>e.id===t?{...e,version:s}:e)),s!==null})}let ea=(0,X.useRef)(void 0),[ta,na]=(0,X.useState)(0),ra=(0,X.useRef)(!1);(0,X.useEffect)(()=>{let e=ea.current;ea.current=void 0,e&&!ra.current&&h?.id===e.containerID&&on(h)&&(ra.current=!0,ia(h,e).then(t=>{t===`conflicts`&&pt.current?.id===e.containerID&&W(Yy)},()=>void 0).finally(()=>{ra.current=!1}))},[ta]);function ia(e,t){let n=()=>pt.current?.id===e.id;return tv(t.objects,t.unreadable,sn.current.has(e.id),{pins:t=>aa(e,t),legacyConflict:async t=>{for(let n of(await sd(t)).filter(e=>!e.resolved)){let r=await cd(n.id),i=rn(e,n.keyGeneration);if(!i.length)throw Error(`conflict key missing`);let a=n=>lm(i,i=>Nt(i,e.id,t,r,n)).then(()=>!0,()=>!1);if(!await a(!1)&&await a(!0))return!0}return!1},savePage:async(e,t)=>n()&&oa(e,t),saveStructure:async(e,t)=>n()&&$i(e,t,{}),mark:async()=>{let t=pt.current,n=Mn.current[e.id],r=t?.id===e.id?on(t):void 0;if(!t||!r||n===void 0)return!1;let i=Qe(await St(r.key,e.id,n,!0)),o=await Bm({container:t,generation:r.generation},i,t.metaVersion);await cn(e.id);let s={metaCiphertext:i,metaVersion:o.metaVersion,changeSeq:o.changeSeq};return a(t=>t.map(t=>t.id===e.id?{...t,...s}:t)),g(t=>t?.id===e.id?{...t,...s}:t),!0}})}async function aa(e,t){let n={},r=(t,n)=>lm(rn(e,t),n).then(()=>!0,()=>!1),i=async(e,t)=>!await r(e,e=>t(e,!1))&&r(e,e=>t(e,!0));for(let r of await Ku(t)){let a=$e(r.bodyCiphertext);await i(r.keyGeneration,(n,r)=>Tt(n,e.id,t,a,r))&&(n[r.id]=await nt(a))}for(let a of await ad(t)){let o=$e(a.metadataCiphertext);if(!await i(a.keyGeneration,(n,r)=>Ot(n,e.id,t,o,r)))continue;let s=await od(a.id);await r(a.keyGeneration,n=>At(n,e.id,t,s,!0))&&(n[a.id]=await nt(s),n[Pt(a.id)]=await nt(o))}return n}function oa(e,t){return Gi(async()=>{b(n=>Vt(n,e,{legacy:t}));let n=U.current;if(n?.id===e){let e={...n,legacy:t};return U.current=e,ne(e),Zi(e),await Wi(e,!0),!1}let r=y.current.find(t=>t.id===e);if(!r)return!1;let i=Kt(r,await sa(e)),a=await Qi(e,i.version,Bt(i));return a!==null&&b(t=>Wt(t,e,{version:a})),a!==null})}async function sa(t){if(!h)return;let n=await qc(e.user.id,t).catch(()=>void 0);if(!n)return;let r=h.id,i=await lm(an(h,n.keyGeneration),e=>Nt(e,r,t,n.payload,!0)).catch(()=>void 0);return i?.type===`page`?{version:n.version,title:i.title,body:i.body}:void 0}async function ca(e,t){if(xn())return;let{level:n,...r}=t,i=n===void 0?r:t;b(t=>Vt(t,e,i));let a=U.current;if(a?.id===e){let e={...a,...i};U.current=e,ne(e),Rt(!0),Zi(e),await Ki(e,!0);return}let o=y.current.find(t=>t.id===e);if(!o)return;let s=Kt(o,await sa(e));b(t=>Vt(t,e,{title:s.title,body:s.body}));let c=await Qi(e,s.version,Bt(s));c!==null&&b(t=>Wt(t,e,{version:c}))}let la=(0,X.useMemo)(()=>Me(x),[x]),ua=(0,X.useMemo)(()=>la.filter(e=>fe(e,k)===M),[la,k,M]),da=(0,X.useMemo)(()=>T.filter(e=>k.get(e.id)===M).sort(je),[T,k,M]);function fa(e,t){let n=de(D.current);return e===`section`?Me(C.current).filter(e=>fe(e,n)===t):D.current.filter(e=>n.get(e.id)===t).sort(je)}async function pa(e){if(h&&!xn()){G(!0);try{let t=M,n=Pe(fa(e,t)),r=await Xu(h.id,`folder`);if((kr.current??pt.current?.id)!==h.id){await md(r.id).catch(()=>void 0);return}let i={id:r.id,version:r.version,order:n,group:t};e===`section`?(w(e=>[...e,{...i,type:`section`,title:`New section`,color:we[e.length%we.length]}]),P(r.id)):O(e=>[...e,{...i,type:`group`,title:`New group`,color:we[e.length%we.length]}]),await $i(e,r.id,{})}catch(t){W(t instanceof Error?t.message:`Unable to create ${e}`)}finally{G(!1)}}}let ma=e=>W(e instanceof Error?e.message:`Unable to update section or group`);function ha(e,t){if(xn())return;let n=prompt(e===`section`?`Section name`:`Group name`,t.title)?.trim();n&&$i(e,t.id,{title:n}).catch(ma)}async function ga(t){if(xn())return;let n=Ne(_,x,t.id).length;if(confirm(`Delete section "${t.title}"? Its ${n} page${n===1?``:`s`} will move to Quick Notes.`))try{await md(t.id),await Jc(e.user.id,t.id),w(e=>e.filter(e=>e.id!==t.id)),P(Ce)}catch(e){W(e instanceof Error?e.message:`Unable to delete section`)}}async function _a(t){if(!xn()&&confirm(`Delete group "${t.title||`Untitled group`}"? Its sections and groups move up one level.`)){G(!0);try{let n=de(D.current).get(t.id);for(let e of[`section`,`group`])for(let r of fa(e,t.id))if(!await $i(e,r.id,{group:n})){W(e=>e||`Could not move everything out of the group, so it was kept. Try again.`);return}await md(t.id),await Jc(e.user.id,t.id),O(e=>e.filter(e=>e.id!==t.id)),N(e=>e===t.id?n:e)}catch(e){W(e instanceof Error?e.message:`Unable to delete group`)}finally{G(!1)}}}async function va(e,t,n){let r=e===`section`?C.current.find(e=>e.id===t):D.current.find(e=>e.id===t);if(!r)return;let i=e===`section`?fe(r,k):k.get(t);for(let r of Fe(fa(e,i),t,n))await $i(e,r.id,{order:r.order}).catch(ma)}async function ya(e,t,n){e===`group`&&!he(t,n,de(D.current))?W(`A group cannot move into itself or its own groups, or nest deeper than 4 levels.`):(await $i(e,t,{group:n,order:Pe(fa(e,n).filter(e=>e.id!==t))}).catch(ma),e===`section`&&t===A&&N(n))}async function ba(e){if(e===A)return P(e);if(!await qi())return;U.current=null,ne(null),P(e);let t=Ne(y.current,C.current,e)[0];t&&await Ii(t)}async function xa(e){if(ye(A,x,k)===e)return N(e);let t=la.find(t=>fe(t,k)===e)?.id??(e===void 0?`quick`:void 0);if(t!==void 0)return ba(t);await qi()&&(ne(null),N(e))}let Sa=h?[{id:void 0,title:Vr(h)},...pe(M,k).map(e=>({id:e,title:T.find(t=>t.id===e)?.title||`Untitled group`}))]:[],Ca=(0,X.useRef)(Promise.resolve()),wa=e=>e.section&&C.current.some(t=>t.id===e.section)?e.section:Ce;function Ta(e){let t=Ca.current.then(e);return Ca.current=t.catch(()=>{}),t.catch(e=>W(e instanceof Error?e.message:`Unable to move page`))}function Ea(e,t,n){return Ta(async()=>{if(xn())return;let r=y.current.find(t=>t.id===e);if(!r)return;let i=Ne(y.current,C.current,wa(r)),a=V(i),[o,s]=H(a,i.findIndex(t=>t.id===e)),c=i.slice(o,s),l=new Set(c.map(e=>e.id)),u=Ne(y.current,C.current,t).filter(e=>!l.has(e.id)),d=n===null?-1:u.findIndex(e=>e.id===n),f=t===`quick`?void 0:t;for(let e of ue(u,c,a.slice(o,s),d<0?u.length:d)){let t=y.current.find(t=>t.id===e.id);await ca(e.id,l.has(e.id)?{section:f,order:e.order,level:e.level}:{section:t?.section,order:e.order})}})}function Da(e,t){return Ta(async()=>{if(xn())return;let n=y.current.find(t=>t.id===e);if(!n)return;let r=Ne(y.current,C.current,wa(n)),i=le(r,r.findIndex(t=>t.id===e),t);i!==void 0&&(Xr(r.map(t=>t.id===e?{...t,level:i}:t),e),await ca(e,{section:n.section,order:n.order,level:i}))})}async function Oa(e,t,n,r=()=>!0){let{page:i,moves:a}=Ie(Ne(y.current,C.current,wa(t)),t,n),o=await Xu(e),s={id:o.id,title:i.title,body:i.body,section:i.section,order:i.order,level:i.level,legacy:i.legacy,version:0,updatedAt:new Date().toISOString()};r()&&b(e=>[...e,s]);let c=await Qi(o.id,0,i);if(c===null)return!1;r()&&b(e=>Wt(e,o.id,{version:c}));let l=Ca.current.then(async()=>{for(let e of a)await ca(e.id,{section:y.current.find(t=>t.id===e.id)?.section,order:e.order})});return Ca.current=l.catch(()=>{}),await l,!0}async function ka(){let t=U.current;if(yr.current||!h||!t||xn())return;yr.current=!0,vr(t.id);let n=h,r=h.id,i=()=>(kr.current??pt.current?.id)===r;try{Dt&&await Ki(t,!0);let a=U.current;a?.id===t.id&&!Gt(a,t)&&await Ki(a,!0),await Nr.current;let o=await Zc(e.user.id,t.id).catch(()=>void 0),s=o?.conflicted?o:void 0,c=await Zu(t.id),l=!sn.current.has(r),u=await lm(rn(n,c.keyGeneration),e=>Nt(e,r,t.id,c.bytes,l));if(u?.type!==`page`)throw Error(`Unable to read the server version of this page.`);let d={title:u.title,body:u.body,section:u.section,order:u.order,level:u.level,legacy:u.legacy,version:c.version};if(i()&&b(e=>e.map(e=>e.id===t.id?{...e,...d}:e)),U.current?.id===t.id){let e={...U.current,...d};U.current=e,ne(e),Rt(!1),gr(e=>e+1)}W(``);let f=0,p=0,m=[],h=(await sd(t.id)).filter(e=>!e.resolved);for(let e of h)try{let i=await cd(e.id),a=await lm(rn(n,e.keyGeneration),e=>Nt(e,r,t.id,i,l)).catch(()=>void 0);a?.type===`page`?m.push({id:e.id,createdAt:e.createdAt,payload:a}):p+=1}catch(e){f+=1,W(e instanceof Error?e.message:`Unable to read a conflicting version`)}let{resolveOnly:g,groups:_}=Le(d,m);for(let e of g)await ld(e).catch(()=>{f+=1});for(let e of _)if(!i()||xn())f+=1;else try{if(!await Oa(r,y.current.find(e=>e.id===t.id)??{id:t.id,...d},e.payload,i)){f+=1;continue}for(let t of e.ids)await ld(t)}catch(e){f+=1,W(e instanceof Error?e.message:`Unable to keep a conflicting version`)}let v=y.current.find(e=>e.id===t.id);if(v&&i()&&U.current?.id===t.id&&P(wa(v)),p?W(`${p} version(s) could not be opened with this notebook's key and remain on the server.`):f&&W(e=>e||`Some conflicting versions could not be copied; try again.`),!f&&!p){s&&await el(s);let n=await Zc(e.user.id,t.id).catch(()=>void 0);if(n){ct(n.conflicted?`attention`:`local`);return}it.current.delete(t.id),rt(e=>{let n=new Set(e);return n.delete(t.id),n}),ct(`saved`)}}catch(e){W(e instanceof Error?e.message:`Unable to keep the conflicting version`)}finally{yr.current=!1,vr(null)}}function q(e,t){let n=U.current;if(n?.id!==e||_r===e)return;let r={...n,...t};U.current=r,ne(r),b(e=>Ut(e,n,r,t)),Rt(!0),Zi(r)}async function Aa(t,n,r,i,a){let o=on(t);if(!o)throw new Fm;let s=await gm(o,t.id,n,i,a),c=await Hm({container:t,generation:s.keyGeneration},s.payload.byteLength,await nt(s.payload)),l={uploadId:c.uploadId,owner:e.user.id,containerID:t.id,objectID:n,objectVersion:r,...s,chunkBytes:c.chunkBytes,nextChunk:c.nextChunk,name:a.name,type:a.type,size:a.size};return await il(l),l}async function ja(t,n,r,i){let a=await Aa(n,t.objectID,t.objectVersion,r,i);return await td(t.uploadId).catch(()=>void 0),await ol(e.user.id,t.uploadId),qe(e=>{let n={...e};return delete n[t.uploadId],n}),a}async function Ma(t,n=0){if(n>1)throw new Fm;if(t.owner!==e.user.id)throw Error(`This upload belongs to another account.`);let r=await fr(await nr(t.containerID),!0),i=await _m(t,r,tn(r),on(r),zt.current[r.id]??en,In.current);if(i.kind===`wait`)throw new Fm;if(i.kind===`reseal`)return Ma(await ja(t,r,i.plaintext,i.file),n+1);let a={container:r,generation:t.keyGeneration},o=await ed(t.uploadId),s=o.nextChunk,c=s*t.chunkBytes;for(qe(e=>({...e,[t.uploadId]:{name:t.name,uploaded:o.receivedBytes,total:t.payload.byteLength}}));c({...e,[t.uploadId]:{name:t.name,uploaded:n.receivedBytes,total:t.payload.byteLength}}))}let l;try{l=await Wm(a,t.uploadId,t.metadataCiphertext)}catch(e){if(!(e instanceof Bl&&e.code===`already_exists`))throw e;return Ma(t,n+1)}return await id(t.objectID,l.attachmentId,t.objectVersion),await ol(e.user.id,t.uploadId),qe(e=>{let n={...e};return delete n[t.uploadId],n}),{id:l.attachmentId,keyGeneration:t.keyGeneration}}async function Na(){if(!ut.current){ut.current=!0;try{for(let t of await al(e.user.id))try{await Ma(t),W(`Attachment uploaded: ${t.name}`)}catch{qe(e=>({...e,[t.uploadId]:{name:t.name,uploaded:0,total:t.payload.byteLength,failed:!0}})),W(`Attachment waiting to resume: ${t.name}`)}}catch{}finally{ut.current=!1}}}async function Pa(t){Je.current.add(t);try{await td(t)}catch{}await ol(e.user.id,t),qe(e=>{let n={...e};return delete n[t],n})}async function Fa(t){Je.current.delete(t);let n=(await al(e.user.id)).find(e=>e.uploadId===t);if(n)try{await Ma(n)}catch{W(`Attachment waiting to resume: ${n.name}`)}}async function Ia(e){if(!h||!z)throw Error(`Select a note first`);let t=await Aa(h,z.id,z.version,new Uint8Array(await e.arrayBuffer()),{name:e.name,type:e.type,size:e.size}),n=await Ma(t);return{id:n.id,name:e.name,type:e.type,size:e.size,keyGeneration:n.keyGeneration,page:t.objectID}}async function La(e){if(h&&z&&!xn()){G(!0);try{let t=await Ia(e);ae(e=>[...e,t]),W(`Attachment uploaded and encrypted.`)}catch(e){W(e instanceof Error?e.message:`Unable to upload attachment`)}finally{G(!1)}}}async function Ra(e){let t=await Ia(e);return ae(e=>[...e,t]),`attachment://${t.id}`}async function za(e){if(!e.startsWith(`attachment://`)||!h)return e;let t=e.slice(13),n=Ae[t];if(n)return n;let r=ie.find(e=>e.id===t);if(!r)return e;let i=await od(r.id),a=h.id,o=await un(a,r.page,r.id,i),s=await lm(rn(h,r.keyGeneration),e=>At(e,a,r.page,i,o)),c=URL.createObjectURL(new Blob([s.slice().buffer],{type:r.type}));return Ge.current.push(c),c}async function Ba(e){if(h)try{let t=await od(e.id),n=h.id,r=await un(n,e.page,e.id,t),i=await lm(rn(h,e.keyGeneration),i=>At(i,n,e.page,t,r)),a=URL.createObjectURL(new Blob([i.slice().buffer],{type:e.type||`application/octet-stream`})),o=document.createElement(`a`);o.href=a,o.download=e.name,o.click(),URL.revokeObjectURL(a)}catch(e){W(e instanceof Error?e.message:`Unable to open attachment`)}}async function Va(t){let n=U.current?.id,r=pt.current?.id;if(!n||!r||t.authorUserId!==e.user.id&&bt.current!==`owner`&&bt.current!==`admin`||!confirm(`Delete this comment for everyone? This cannot be undone.`))return;G(!0);let i=()=>U.current?.id===n&&pt.current?.id===r;try{await qu(t.id),i()&&B(e=>e.filter(e=>e.id!==t.id))}catch(e){i()&&W(e instanceof Error?e.message:`Unable to delete comment`)}finally{G(!1)}}async function Ha(){if(z&&h&&Ye.trim()&&!bn()){G(!0);try{let t=on(h);if(!t)throw Error(K_);let n=await wt(t.key,h.id,z.id,Ye.trim(),Ze.trim());try{let r=Dn?.containerID===h.id?Dn.members:gt;await Vm({container:h,generation:t.generation},z.id,Qe(n),f_(Ye,r,e.user.id))}catch(e){if(!(e instanceof Bl&&e.code===`already_exists`))throw e;let t=await fr(h);throw g(e=>e?.id===t.id?t:e),Error(`This notebook's keys just changed. Send the comment again.`)}if(U.current?.id!==z.id)return;Xe(``),et(``),await Ii(z)}catch(e){W(e instanceof Error?e.message:`Unable to add comment`)}finally{G(!1)}}}async function Ua(){let t=h;if(!t)return;let n=prompt(`User ID to invite (Settings shows each person's user ID)`)?.trim();if(n)try{let r={container:t,ring:zt.current[t.id]??en,floor:tn(t)},i={userId:n,username:kn.current[n]??``,role:`editor`},a={userId:e.user.id,identity:await Wn(),canWrap:!e.sso,recoverable:Ud(zn.current)},{invitation:o,keys:s,recipient:c}=await d_({userIdentity:zu,stepUp:rr.stepUp,invite:Uu},r,i,a,ir,cr(t.id)),l=s===`sealed`?`The invitation carries this team's keys, sealed for the key with fingerprint ${await or(c.identity.publicKey)}; compare it with ${gi(i.username,n)} (their Settings shows it).`:yb[s];prompt(`${l} Send this link to the person you invited. It works once, only for their account, until ${new Date(o.expiresAt).toLocaleString()}.`,g_(location.origin,o))}catch(e){W(e instanceof Error?e.message:`Unable to invite member`)}}function Wa(){jn(void 0),S_(y_())}async function Ga(){let e=An;if(e){jn(void 0);try{await Wu(e.id,e.token),Wa(),W(`You joined the team.`)}catch(t){let n=t instanceof Bl?t:void 0,r=t instanceof Error?t.message:`Unable to join the team`;C_(n?.status,n?.code)?(Wa(),W(n?.code===`not_found`?`This invitation is no longer valid: it expired, was already used, is for another account, or its sender can no longer invite.`:n?.code===`already_exists`?`You are already a member of this team.`:r)):(jn(e),W(`Could not join the team: ${r}. The invitation is kept; choose Join team to try again.`))}await Di()}}async function Ka(){let t=pt.current;if(!t)return;let n=(Dn?.containerID===t.id?Dn.members:[]).filter(t=>(t.role===`owner`||t.role===`admin`)&&t.userId!==e.user.id).map(e=>gi(e.username,e.userId)),r=await Wn(),i=w_({notebook:Vr(t),stewards:n,fingerprint:r?await or(Qe(r.publicKey)):``,link:`${location.origin}/${Be({container:t.id})}`});prompt(`Send this to ${n.join(` or `)||`a team owner`}. Their browser shares this notebook's key when they open it.`,i)}async function qa(e){if(h&&confirm(`Remove this person from the team?`))try{await Gu(h.id,e),await Ja(h)}catch(e){W(e instanceof Error?e.message:`Unable to remove member`)}}async function Ja(e,t=!1){for(let n of i.filter(t=>t.teamId===e.id))await fr(n,!1,()=>!1,t);let n=await fr(e,!1,()=>!1,t);g(e=>e?.id===n.id?n:e);let r=await Bu(e.id);pt.current?.id===e.id&&_t(r)}async function Ya(e){if(h?.kind===`team`){G(!0);try{await fu(h.id,e),await Ja(h,!0)}catch(e){W(e instanceof Error?e.message:`Unable to approve`)}finally{G(!1)}}}async function Xa(){if(z){if(Bv(z.body))W(`This page has only a drawing. Shared links show a page's text, so there is nothing to share yet; add text to share it.`);else try{let t=await It({title:z.title,body:zv(z.body)}),n=await ud(t.ciphertext,new Date(Date.now()+6048e5).toISOString()),r=h&&dn(h);h&&r&&await L_(e.user.id,n.id,h.id,r,{title:z.title,notebook:Vr(h)}).catch(()=>void 0),await navigator.clipboard.writeText(`${location.origin}/share/${n.token}#${t.key}`);let i=Rv(z.body);W(i?`Encrypted share link copied. It shows the page's text only; drawings are not included. The key is only in the URL fragment. Revoke it under Settings → Share links.`:`Encrypted share link copied. The key is only in the URL fragment. Revoke it under Settings → Share links.`)}catch(e){W(e instanceof Bl&&e.code===`payload_too_large`?`This page is too large to share as a link. Export it instead, or split it into smaller pages.`:e instanceof Error?e.message:`Unable to create encrypted link`)}}}let Za=i.filter(e=>e.kind!==`team`&&!e.teamId),Qa=i.filter(e=>e.kind===`team`),$a=e=>i.filter(t=>t.teamId===e),eo=Sr===`workspace`,to=(e,t,n=!1)=>{let r=!Tr&&h?.id===e.id,i=(0,Q.jsxs)(`button`,{className:`ky-nav-item nav-item notebook-item${n?` nested-nav-item`:``}`,"aria-current":r?`true`:void 0,"data-open":h?.id===e.id?`true`:void 0,onClick:()=>{l(!0),ki(e)},children:[(0,Q.jsx)(pf,{name:t}),(0,Q.jsx)(`span`,{children:Vr(e)})]},e.id);return!r||!h?i:(0,Q.jsxs)(X.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`notebook-row`,children:[i,(0,Q.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`notebook-menu`,"aria-label":`Notebook options`,style:{anchorName:`--notebook-menu`},children:(0,Q.jsx)(pf,{name:`more`})}),(0,Q.jsxs)(`div`,{className:`section-menu anchored-menu`,id:`notebook-menu`,popover:`auto`,style:{positionAnchor:`--notebook-menu`},children:[(0,Q.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),Bi()},children:`Rename notebook`}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),Hi()},children:`Export notebook`}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:Et||mn||gn,onClick:()=>{no(`notebook-menu`),pa(`section`)},children:`New section`}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:Et||mn||gn||pe(M,k).length>=4,onClick:()=>{no(`notebook-menu`),pa(`group`)},children:`New section group`}),h.kind===`team`&&_n&&(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>{no(`notebook-menu`),Ua()},children:`Add person`}),h.kind===`team`&&_n&&(0,Q.jsx)(`button`,{className:`quiet`,disabled:Et,onClick:()=>{no(`notebook-menu`),zi(h)},children:`Create team notebook`}),vt===`owner`&&(0,Q.jsx)(`button`,{className:`quiet danger`,disabled:Et,onClick:()=>{no(`notebook-menu`),Vi()},children:`Delete notebook`})]})]}),(0,Q.jsx)(`div`,{className:`notebook-sections`,children:(0,Q.jsx)(av,{sections:ua,groups:da,path:Sa,current:A,busy:Et||mn||gn,moveTargets:yi,onSelect:e=>{Cr(`workspace`),s(!1),l(!0),ba(e)},onRename:ha,onColor:(e,t,n)=>void $i(e,t.id,{color:n}).catch(ma),onDelete:e=>void ga(e),onDeleteGroup:e=>void _a(e),onMove:(e,t,n)=>void va(e,t,n),onMoveIntoGroup:(e,t,n)=>void ya(e,t,n),onOpenGroup:e=>void xa(e),onDropPage:(e,t)=>{let n=y.current.find(t=>t.id===e);n&&wa(n)!==t&&Ea(e,t,null)}})})]},e.id)},no=e=>document.getElementById(e)?.hidePopover(),ro=Dt?`Unsaved changes`:st===`syncing`?`Syncing…`:st===`local`?`Saved locally`:st===`attention`?`Needs attention`:`Saved to server`,io=z&&[Ei?`Autosaving…`:st===`local`?`Encrypted, waiting to sync`:st!==`attention`&&at?new Date(at).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):``,z.version?`Version ${z.version}`:`Draft`].filter(Boolean).join(` · `),ao=h??i[0],oo=()=>{s(!1),Tr&&ao?ki(ao):Cr(`workspace`)},so=Gn===`held`&&Bn&&!Bn.recoveryId&&!ve&&(0,Q.jsxs)(`div`,{className:`recovery-notice`,children:[(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(pf,{name:`sso`}),(0,Q.jsx)(`span`,{children:`Save a recovery code`}),(0,Q.jsx)(pf,{name:`chevron`})]}),(0,Q.jsxs)(`div`,{className:`recovery-notice-body`,role:`status`,children:[`Save a recovery code so you can get your encryption key back if no browser holds it and your password cannot open it.`,` `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>wr(`account`),children:`Create recovery code`})]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button quiet`,"aria-label":`Dismiss the recovery code reminder for now`,onClick:()=>Te(!0),children:(0,Q.jsx)(pf,{name:`close`})})]});return(0,Q.jsxs)(Of,{className:`workspace${Tr?` queue-mode`:``}${eo?` has-panes`:``}`,label:`Primary`,onSignOut:t,user:{name:e.username||e.user.id.slice(0,12),role:`Everyday account`},settings:{items:Ve.map(([e,t])=>({href:We(e),label:t,current:Sr===`settings`&&(br??`account`)===e})),current:Sr===`settings`},nav:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Tf,{icon:`notes`,label:`Notes`,current:eo&&!Tr,disabled:Tr&&!ao,expanded:f&&eo&&!Tr?o:void 0,controls:f?`notebook-tree`:void 0,onClick:()=>f&&eo&&!Tr?s(e=>!e):oo()}),(0,Q.jsx)(Tf,{icon:`work`,label:`Work queue`,current:eo&&Tr,onClick:()=>{Et||(l(!0),Pi())}})]}),tree:(0,Q.jsx)(`div`,{id:`notebook-tree`,className:`notes-tree`,"data-open":o||void 0,children:(0,Q.jsxs)(`nav`,{id:`notebook-navigation`,className:`sidebar`,"aria-label":`Notebooks`,children:[(0,Q.jsx)(`div`,{className:`section-label`,children:`Notebooks`}),Za.map(e=>to(e,`notebook`)),Qa.length>0&&(0,Q.jsx)(`div`,{className:`section-label team-label`,children:`Team notebooks`}),Qa.map(e=>(0,Q.jsxs)(X.Fragment,{children:[to(e,`team`),$a(e.id).map(e=>to(e,`notebook`,!0))]},e.id)),(0,Q.jsxs)(`button`,{className:`new-workspace personal-create`,"aria-label":`+ New notebook`,disabled:Et,onClick:()=>void Ri(),children:[(0,Q.jsx)(pf,{name:`plus`}),` New notebook`]}),h?.kind===`team`&>.length>0&&(0,Q.jsxs)(`div`,{className:`member-list`,children:[(0,Q.jsxs)(`div`,{className:`section-label`,children:[`People in `,Vr(h)]}),gt.map(t=>(0,Q.jsxs)(`div`,{className:`member-row`,children:[(0,Q.jsxs)(`span`,{children:[gi(t.username,t.userId),` · `,t.pendingRole?`${t.pendingRole} once approved`:t.role,Dn?.containerID===h.id&&Dn.status[t.userId]&&` · ${gb[Dn.status[t.userId]]}`,t.keyResetAt&&` · reset their key ${Q_(t.keyResetAt)}`]}),_n&&t.userId!==e.user.id&&(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>void qa(t.userId),children:`Remove`})]},t.userId))]})]})}),children:[(0,Q.jsxs)(`div`,{className:`notes-panes`,hidden:!eo,"data-phone-view":!h&&!Tr?void 0:!z||c?`list`:`page`,children:[(0,Q.jsxs)(`section`,{id:`page-navigation`,className:`note-list${!h&&!Tr?` no-notebook`:``}`,"aria-busy":Dr,"aria-labelledby":`page-navigation-title`,children:[h&&!Tr&&(0,Q.jsx)(`p`,{className:`workspace-title`,children:Vr(h)}),(0,Q.jsxs)(`div`,{className:`pane-head`,children:[(0,Q.jsx)(`h2`,{id:`page-navigation-title`,className:`pane-title`,children:Tr?`Work queue`:Ir.trim()?`Search results`:Zr(A)}),h&&!Tr&&(0,Q.jsx)(`button`,{className:`icon-button quiet`,"aria-label":`New page`,title:`New page`,disabled:Et||fi||mn||gn,onClick:()=>{Cr(`workspace`),s(!1),l(!1),Ui()},children:(0,Q.jsx)(pf,{name:`plus`})})]}),Tr&&(0,Q.jsxs)(`p`,{className:`workspace-kind`,children:[`Open tasks across your personal notebooks · `,di.length,` open task`,di.length===1?``:`s`]}),(h||Tr)&&(0,Q.jsxs)(`label`,{className:`note-search-field`,children:[(0,Q.jsx)(pf,{name:`search`}),(0,Q.jsx)(`input`,{"aria-label":Tr?`Search the work queue`:`Search this notebook`,className:`note-search`,type:`search`,value:Ir,onChange:e=>Lr(e.target.value),placeholder:`Search`})]}),Tr&&Hv.map(([e,t])=>{let n=di.filter(t=>t.group===e);return n.length>0&&(0,Q.jsxs)(`div`,{className:`task-group`,"data-task-group":e,children:[(0,Q.jsx)(`h3`,{className:`notes-heading`,children:t}),n.map((e,t)=>(0,Q.jsx)(`div`,{className:`note-row-wrap ${z?.id===e.entry.note.id?`selected`:``}`,children:(0,Q.jsxs)(`button`,{className:`note-row`,onClick:()=>{Cr(`workspace`),u.current=f,Fi(e.entry)},children:[(0,Q.jsx)(`strong`,{children:e.text||`Untitled task`}),(0,Q.jsx)(`span`,{children:[e.due&&`Due ${e.due}`,e.repeat&&`repeats`,e.push&&`push`,e.missed&&`missed reminder`,e.entry.note.title||`Untitled page`].filter(Boolean).join(` · `)})]})},`${e.key}\n${t}`))]},e)}),!Tr&&mi.map(({note:e,row:t})=>{let n=e.title||`Untitled page`;return(0,Q.jsxs)(`div`,{className:`note-row-wrap ${z?.id===e.id?`selected`:``}`,style:t?{paddingInlineStart:t.level*16}:void 0,onDragOver:e=>{li&&e.dataTransfer.types.includes(`application/x-kynotes-page`)&&e.preventDefault()},onDrop:t=>{let n=t.dataTransfer.getData(`application/x-kynotes-page`),r=hi(n);if(!li||r<0)return;let i=xi(xe(Gr,r,hi(e.id)));i!==void 0&&Ea(n,A,i)},children:[t&&!t.hasChildren&&(0,Q.jsx)(`span`,{className:`page-toggle-space`,"aria-hidden":`true`}),t?.hasChildren&&(0,Q.jsx)(`button`,{className:`page-toggle quiet`,"aria-expanded":!t.collapsed,"aria-label":`${t.collapsed?`Expand`:`Collapse`} ${n}`,onClick:()=>Yr(e.id),children:(0,Q.jsx)(pf,{name:`chevron`})}),(0,Q.jsxs)(`button`,{className:`note-row`,"aria-current":eo&&z?.id===e.id?`page`:void 0,"data-page-id":e.id,draggable:!gn,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-kynotes-page`,e.id)},onKeyDown:t=>{if(!li)return;let n=hi(e.id),r=t.ctrlKey&&t.altKey?t.key===`]`||t.code===`BracketRight`?1:t.key===`[`||t.code===`BracketLeft`?-1:0:0;if(r){let n=r;if(!vi(e.id,n))return;t.preventDefault(),Da(e.id,n);return}if(!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;let i=xi(be(Gr,n,t.key===`ArrowUp`?-1:1));i!==void 0&&(t.preventDefault(),Ea(e.id,A,i).then(()=>document.querySelector(`.note-row[data-page-id="${CSS.escape(e.id)}"]`)?.focus()))},"aria-keyshortcuts":li?`Alt+ArrowUp Alt+ArrowDown Control+Alt+BracketRight Control+Alt+BracketLeft`:void 0,onClick:()=>{Cr(`workspace`),z?.id===e.id?(s(!1),l(!1),f&&requestAnimationFrame(()=>d.current?.focus())):(u.current=f,Ii(e))},children:[(0,Q.jsxs)(`span`,{className:`note-row-head`,children:[(0,Q.jsx)(`strong`,{children:n}),(0,Q.jsx)(`time`,{dateTime:e.updatedAt,title:e.updatedAt?new Date(e.updatedAt).toLocaleString():void 0,children:sv(e.updatedAt)})]}),t&&(t.level>0||t.hasChildren)&&(0,Q.jsxs)(`span`,{className:`visually-hidden`,children:[t.level>0?`, subpage level ${t.level}`:``,t.hasChildren?t.collapsed?`, collapsed, ${bi(e.id)} subpages hidden`:`, expanded`:``]}),(0,Q.jsxs)(`span`,{className:`note-snippet`,children:[Ir.trim()&&(0,Q.jsxs)(`em`,{className:`page-section`,children:[Zr(e.section),` · `]}),uy([e])[0].body.slice(0,160)||`Empty page`]})]})]},e.id)}),h&&(ci.length===0||pi)&&(0,Q.jsx)(`p`,{className:`empty-list`,children:Tr?`No open tasks here. Tasks from note checklists appear here.`:pi?`This group has no sections. Add one from the notebook menu to add pages.`:`No pages in this section yet.`}),Si.length>0&&(0,Q.jsxs)(`div`,{className:`context-panel`,children:[(0,Q.jsx)(`div`,{className:`section-label`,children:`Resurfacing`}),Si.map(e=>(0,Q.jsx)(`button`,{className:`context-link`,onClick:()=>{Cr(`workspace`),Ii(e)},children:e.title||`Untitled page`},e.id))]}),Ci.length>0&&(0,Q.jsxs)(`div`,{className:`context-panel`,children:[(0,Q.jsx)(`div`,{className:`section-label`,children:`Knowledge graph`}),(0,Q.jsxs)(`span`,{className:`config-muted`,children:[Ci.length,` local link`,Ci.length===1?``:`s`]})]})]}),(0,Q.jsxs)(`section`,{className:`editor`,children:[(0,Q.jsxs)(`div`,{className:`workspace-notices`,children:[!Tr&&mn&&h&&(0,Q.jsx)(`p`,{className:`workspace-kind`,role:`status`,children:yn?cb:(()=>{let e=Z_({steward:vn(h),held:Gn===`held`,recoverable:Ud(Bn),shared:Math.max(h.sharedGeneration,tn(h)?.shared??0)>0}),t=Dn?.containerID===h.id?$_(Dn.members):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[e.text,t&&(0,Q.jsxs)(Q.Fragment,{children:[` `,t]}),e.action===`ask`&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>void Ka(),children:`Ask an owner`})]}),e.action===`settings`&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>wr(Gn===`held`?`account`:`devices`),children:`Open Settings`})]})]})})()}),!Tr&&Sn&&(0,Q.jsx)(`p`,{className:`workspace-kind`,role:`status`,children:Sn}),!Tr&&wn&&(0,Q.jsxs)(`p`,{className:`workspace-kind`,role:`status`,children:[`This notebook's keys are not set up or shared yet. `,(0,Q.jsxs)(`button`,{className:`quiet`,onClick:()=>void pr(),children:[`Set up keys (confirm with `,e.sso?`KySignOn`:`your password`,`)`]})]}),qn&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`A reset of your encryption key from this browser finished on the server, but its answer never arrived here, so this browser still holds your previous key. Use Forget this device, sign in again, then restore with the new recovery code the reset showed you, or link this browser from one that holds the new key.`,` `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>{confirm(mb)&&n?.()},children:`Forget this device`})]}),Gn===`link`&&!qn&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`This browser does not hold your encryption key, so your notebooks are read-only here. `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>wr(`devices`),children:`Link this browser`})]}),e.sso&&Gn===`create`&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`Set up your encryption key so you can write in your notebooks and team owners can share theirs with you. `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>void tr(!1),children:`Set up encryption key`})]}),e.sso&&Gn===`orphaned`&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`The server no longer lists the encryption key this browser holds (a reset from another browser replaced it). `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>void tr(!0),children:`Replace encryption key`})]}),(!z||f&&c)&&so,h&&_n&&h.metaVersion===0&&on(h)&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[_b,` `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>void Bi(),children:`Name notebook`})]}),_n&>.filter(e=>e.approved===!1).map(e=>(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[vb(gi(e.username,e.userId)),` `,(0,Q.jsx)(`button`,{className:`secondary`,disabled:Et,onClick:()=>void Ya(e.userId),children:`Approve and share keys`})]},e.userId)),(0,Q.jsx)(a_,{status:Qn,set:$n}),An&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`status`,children:[`You were invited to a team notebook.`,` `,(0,Q.jsx)(`button`,{className:`secondary`,onClick:()=>void Ga(),children:`Join team`}),` `,(0,Q.jsx)(`button`,{className:`quiet`,onClick:Wa,children:`Not now`})]})]}),z?(0,Q.jsxs)(Q.Fragment,{children:[tt.has(z.id)&&(0,Q.jsxs)(`div`,{className:`conflict-banner`,role:`alert`,children:[_r===z.id?`Saving the other version as a copy…`:`Another device saved this page first. Your version was kept separately; save it as a copy next to this page.`,(0,Q.jsx)(`button`,{className:`secondary`,disabled:_r!==null||mn||gn,onClick:()=>void ka(),children:`Keep the other version as a copy`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`quiet pane-back`,onClick:()=>{l(!0),requestAnimationFrame(()=>document.querySelector(`.note-list .note-row[aria-current]`)?.focus())},children:[(0,Q.jsx)(pf,{name:`back`}),(0,Q.jsx)(`span`,{children:Tr?`Work queue`:Zr(A)})]}),(0,Q.jsxs)(`div`,{className:`page-head`,children:[(0,Q.jsx)(`input`,{ref:d,"aria-label":`Page title`,className:`title-input`,readOnly:_r===z.id||mn||gn,value:z.title,onChange:e=>q(z.id,{title:e.target.value})}),(0,Q.jsxs)(`div`,{className:`page-head-actions`,children:[!(f&&c)&&so,(0,Q.jsxs)(`p`,{className:`save-state`,"aria-live":`polite`,children:[(0,Q.jsx)(`span`,{className:`ky-status`,"data-ky-status":Dt?void 0:Eb[st],children:ro}),io&&(0,Q.jsx)(`span`,{className:`save-detail`,children:io})]}),(0,Q.jsx)(`button`,{className:`save-button secondary`,disabled:Et,onClick:()=>void Ki(z),children:Et?`Saving…`:`Save`}),(0,Q.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`page-menu`,"aria-label":`Page options`,style:{anchorName:`--page-menu`},children:(0,Q.jsx)(pf,{name:`more`})}),(0,Q.jsxs)(`div`,{className:`section-menu anchored-menu page-menu`,id:`page-menu`,popover:`auto`,style:{positionAnchor:`--page-menu`},children:[(0,Q.jsx)(`span`,{className:`menu-caption`,"aria-hidden":`true`,children:`Section`}),(0,Q.jsxs)(`div`,{className:`page-section-control`,children:[(0,Q.jsxs)(`select`,{"aria-label":`Move page to section`,disabled:mn||gn,value:Ne([z],x,`quick`).length?Ce:z.section,onChange:e=>{no(`page-menu`),Ea(z.id,e.target.value,null)},children:[_e(x,T,k).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id)),(0,Q.jsx)(`option`,{value:Ce,children:`Quick Notes`})]}),(0,Q.jsx)(pf,{name:`chevron`})]}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:mn||gn||!vi(z.id,1),title:`Ctrl+Alt+]`,onClick:()=>{no(`page-menu`),Da(z.id,1)},children:`Indent page`}),(0,Q.jsx)(`button`,{className:`quiet`,disabled:mn||gn||!vi(z.id,-1),title:`Ctrl+Alt+[`,onClick:()=>{no(`page-menu`),Da(z.id,-1)},children:`Outdent page`}),(0,Q.jsx)(`button`,{className:`quiet danger`,disabled:mn||gn,onClick:()=>{no(`page-menu`),Xi(z)},children:`Delete page`})]})]})]}),(0,Q.jsx)(`div`,{className:`page-canvas`,children:(0,Q.jsx)(sb,{children:(0,Q.jsx)(X.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`editor-loading`,children:`Loading page…`}),children:(0,Q.jsx)(ob,{pageID:z.id,body:z.body,editable:_r!==z.id&&!mn&&!gn,onChange:e=>q(z.id,{body:e}),onError:W,uploadFile:Ra,resolveFileUrl:za},`${z.id}:${hr}`)})},z.id)}),(0,Q.jsxs)(`details`,{className:`page-panel comments`,open:oe,onToggle:e=>me(e.currentTarget.open),children:[(0,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(`span`,{children:`Comments`}),re.length>0&&(0,Q.jsx)(`span`,{className:`page-panel-count`,children:re.length}),(0,Q.jsx)(pf,{name:`chevron`})]}),re.map(t=>(0,Q.jsxs)(`div`,{className:`comment`,children:[(0,Q.jsxs)(`div`,{className:`comment-head`,children:[(0,Q.jsxs)(`strong`,{children:[t.username,t.section?` · § ${t.section}`:``]}),(t.authorUserId===e.user.id||vt===`owner`||vt===`admin`)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`icon-button quiet menu-button`,popoverTarget:`comment-menu-${t.id}`,"aria-label":`Comment options by ${t.username}`,style:{anchorName:`--comment-${t.id}`},children:(0,Q.jsx)(pf,{name:`more`})}),(0,Q.jsx)(`div`,{className:`section-menu anchored-menu`,id:`comment-menu-${t.id}`,popover:`auto`,style:{positionAnchor:`--comment-${t.id}`},children:(0,Q.jsx)(`button`,{className:`quiet danger`,disabled:Et,onClick:()=>{no(`comment-menu-${t.id}`),Va(t)},children:`Delete comment`})})]})]}),(0,Q.jsx)(`span`,{children:t.body})]},t.id)),(0,Q.jsxs)(`div`,{className:`comment-compose`,children:[(0,Q.jsx)(`input`,{"aria-label":`Comment section (optional)`,value:Ze,onChange:e=>et(e.target.value),placeholder:`Section (optional)`}),(0,Q.jsx)(`input`,{"aria-label":`Comment`,value:Ye,onChange:e=>Xe(e.target.value),placeholder:`Add a comment…`}),(0,Q.jsx)(`button`,{className:`secondary`,disabled:Et||mn,onClick:()=>void Ha(),children:`Comment`})]})]}),(0,Q.jsxs)(`details`,{className:`page-panel attachments`,open:Ee,onToggle:e=>De(e.currentTarget.open),children:[(0,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(`span`,{children:`Attachments`}),ie.length>0&&(0,Q.jsx)(`span`,{className:`page-panel-count`,children:ie.length}),(0,Q.jsx)(pf,{name:`chevron`})]}),Object.entries(Ke).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`upload-row`,children:[(0,Q.jsxs)(`span`,{children:[t.name,` · `,t.failed?`waiting to retry`:`${Math.round(t.uploaded/Math.max(t.total,1)*100)}%`]}),(0,Q.jsxs)(`div`,{className:`upload-actions`,children:[t.failed&&(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>void Fa(e),children:`Retry`}),(0,Q.jsx)(`button`,{className:`quiet`,onClick:()=>void Pa(e),children:`Cancel`})]})]},e)),ie.map(e=>(0,Q.jsxs)(`button`,{className:`attachment-row`,onClick:()=>void Ba(e),children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.jsxs)(`span`,{children:[Math.ceil(e.size/1024),` KB`]})]},e.id)),(0,Q.jsxs)(`label`,{className:`attachment-picker`,children:[(0,Q.jsx)(pf,{name:`plus`}),(0,Q.jsx)(`span`,{children:`Add encrypted file`}),(0,Q.jsx)(`input`,{type:`file`,disabled:Et||mn||gn,onChange:e=>{let t=e.target.files?.[0];t&&La(t),e.currentTarget.value=``}})]})]})]}):(0,Q.jsxs)(`div`,{className:`empty-editor`,children:[(0,Q.jsx)(`h2`,{children:!h&&!Tr?i.length?`Select a notebook`:`No notebooks yet`:`Your private desk`}),(0,Q.jsxs)(`p`,{children:[!h&&!Tr?`Start with a notebook to keep your notes together.`:`Select a page or create one.`,` The server receives ciphertext only.`]}),!h&&!Tr&&(0,Q.jsx)(`button`,{disabled:Et,onClick:()=>void Ri(),children:`New notebook`}),h&&(0,Q.jsx)(`button`,{disabled:mn||gn,onClick:()=>void Ui(),children:`Create a note`})]})]})]}),Sr===`settings`&&(0,Q.jsx)(kb,{tab:br??`account`,username:e.username,userID:e.user.id,colleagueNames:kn.current,keysFor:e=>an(i.find(t=>t.id===e.containerID),e.keyGeneration),onForgetDevice:n,onAuthSecret:r,identityState:Gn,sso:!!e.sso,heldIdentity:Wn,identityStore:er,stepUp:rr.stepUp,live:Bn,recoveryPrompt:Hn,onIdentityChanged:Zn,onReset:e=>{Xn(e).catch(()=>void 0).finally(Zn)},resetUnfinished:qn,waitingHeld:Ln,reminders:L,onReminders:R}),Rr&&Wy(Rr)&&(0,Q.jsxs)(`button`,{className:`toast commit-toast`,onClick:()=>zr(null),children:[Gy(Rr),` ×`]}),xt&&(0,Q.jsxs)(`button`,{className:`toast error`,onClick:()=>W(``),children:[xt,` ×`]})]})}function Tb({username:e,userID:t,everyday:n,onAuthSecret:r,onIdentityCreated:i,onChanged:a}){let[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1);async function m(u){u.preventDefault();let f=u.currentTarget.elements.namedItem(`confirm`)?.value,m=W_(c,f);if(m)d(m);else{p(!0);try{let u=e||prompt(`Username`)?.trim();if(!u)throw Error(`Username is required`);let f=await Kl(u),p=await ut(o,f.loginSalt,f.iterations,Zd(u)),m=ft(),h=await ut(c,m,6e5);if(!n){await _u({currentAuthSecret:p.authSecret,newAuthSecret:h.authSecret,newLoginSalt:m,iterations:6e5}),Qd(u),s(``),l(``),d(`Password changed.`),a?.(h.authSecret);return}let g=await zd(Fu,t,p,h,await vl(u,t).catch(()=>void 0));await cl(()=>_u({currentAuthSecret:p.authSecret,newAuthSecret:h.authSecret,newLoginSalt:m,iterations:6e5,identityDeviceId:g?.identityDeviceId,wrappedIdentityKey:g?.wrappedIdentityKey}),u,g&&{userID:t,identity:g.identity}),Qd(u),g||(await qy(u,t,h),i()),r(h.authSecret),s(``),l(``),d(`Password changed.`),a?.(h.authSecret)}catch(e){d(e instanceof Error?e.message:`Unable to change password`)}finally{p(!1)}}}return(0,Q.jsxs)(`section`,{className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Change password`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:`Passwords are converted to client-derived secrets in this browser. They are never sent to the server. Changing it signs out your other browsers and unpairs your devices; this browser stays signed in.`}),(0,Q.jsxs)(`form`,{onSubmit:m,children:[(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Current password`}),(0,Q.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`New password`}),(0,Q.jsx)(`input`,{type:`password`,value:c,onChange:e=>l(e.target.value),required:!0})]}),(0,Q.jsxs)(`label`,{className:`field`,children:[(0,Q.jsx)(`span`,{children:`Confirm new password`}),(0,Q.jsx)(`input`,{name:`confirm`,type:`password`,required:!0})]}),(0,Q.jsx)(`button`,{disabled:f,children:f?`Changing…`:`Change password`})]}),u&&(0,Q.jsx)(`p`,{className:`status-line`,children:u})]})}var Eb={saved:`success`,attention:`danger`},Db=`An administrator set this account's password. Choose your own before you continue.`;function Ob({auth:e,onChanged:t,onLogout:n}){return(0,Q.jsx)(Cb,{tagline:`Choose your own password.`,children:(0,Q.jsxs)(`div`,{className:`ky-auth-card choose-password`,children:[(0,Q.jsx)(`p`,{role:`status`,children:Db}),(0,Q.jsx)(Tb,{username:e.username,userID:e.user.id,everyday:e.user.accountKind===`user`,onAuthSecret:()=>{},onIdentityCreated:()=>{},onChanged:t}),(0,Q.jsx)(`button`,{type:`button`,className:`ky-auth-link`,onClick:n,children:`Sign out`})]})})}function kb({tab:e,username:t,userID:n,onForgetDevice:r,onAuthSecret:i,colleagueNames:a,keysFor:o,identityState:s,sso:c,heldIdentity:l,identityStore:u,stepUp:d,onIdentityChanged:f,onReset:p,resetUnfinished:m,waitingHeld:h,live:g,recoveryPrompt:_,reminders:v,onReminders:y}){let[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``);async function w(){let e=(await tl()).filter(e=>e.owner===n);if(!e.length)return 0;let t=await Hg(e,e=>lm(o(e),t=>Nt(t,e.containerID,e.id,e.payload,!0)));return Tp(`kynotes-unsent-edits.json`,t.json,`application/json`),e.length-t.unreadable}return(0,X.useEffect)(()=>{vl(t,n).then(e=>e?_i(Qe(e.publicKey)):``).then(x,()=>x(``))},[t,n,s]),(0,Q.jsxs)(`section`,{className:`page-view settings-view`,"aria-labelledby":`settings-heading`,children:[(0,Q.jsx)(`header`,{className:`ky-page-head`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{id:`settings-heading`,className:`ky-page-title`,children:`Settings`}),(0,Q.jsx)(`p`,{className:`ky-page-lede`,children:`Your account, the browsers linked to it, how KyNotes looks, and your reminders and keys.`})]})}),(0,Q.jsx)(`nav`,{className:`ky-settings-tabs`,"aria-label":`Settings sections`,children:Ve.map(([t,n])=>(0,Q.jsx)(`a`,{className:`ky-nav-item`,href:We(t),"aria-current":e===t?`page`:void 0,children:n},t))}),S&&(0,Q.jsx)(`p`,{role:`status`,children:S===`restored`?`Restored. This browser now holds your encryption key.`:`Linked. This browser now holds your encryption key.`}),(0,Q.jsxs)(`div`,{className:`settings-content`,hidden:e!==`account`,children:[(0,Q.jsx)(`div`,{id:`password`,children:(0,Q.jsx)(Tb,{username:t,userID:n,everyday:!0,onAuthSecret:i,onIdentityCreated:f})}),(0,Q.jsxs)(`section`,{id:`device`,className:`config-card`,children:[(0,Q.jsx)(`h2`,{children:`Trusted Device & SSO`}),(0,Q.jsx)(`p`,{className:`config-muted`,children:b?`This browser holds your encryption key, so your notes open here while you are signed in. It keeps nothing that can sign you in.`:`This browser keeps nothing that can sign you in.`}),(0,Q.jsxs)(`p`,{className:`config-muted`,children:[`Your user ID: `,(0,Q.jsx)(`code`,{children:n}),`. Team owners need it to invite you.`]}),(0,Q.jsx)(`p`,{className:`config-muted`,children:b?(0,Q.jsxs)(Q.Fragment,{children:[`Your encryption key fingerprint: `,(0,Q.jsx)(`code`,{children:b}),`. Team owners see it when your key changes; compare it with them in person.`]}):`This browser holds no encryption key for team notebooks.${pb(s,c)}`}),b&&(0,Q.jsx)(`p`,{className:`config-muted`,children:ll()===`wrapped`?`This browser keeps it wrapped under a browser key that pages cannot export. That is not protection at rest: anyone who can read this browser's profile on disk can still recover it. Use "Forget this device" on shared computers.`:`This site is not served over HTTPS, so this browser stores your key unwrapped in its site storage. Anyone who can read this browser's profile can copy it. Use "Forget this device" on shared computers.`}),r&&(0,Q.jsx)(`button`,{type:`button`,className:`secondary danger`,onClick:()=>{confirm(mb)&&r()},children:`Forget this device & sign out`})]}),s===`held`&&(0,Q.jsx)(Pg,{userID:n,held:l,live:g,sso:c,stepUp:d,autoStart:_,onSaved:f}),m&&(0,Q.jsx)(`p`,{role:`status`,children:`A reset of your encryption key from this browser finished on the server, but its answer never arrived here, so this browser still holds your previous key. Use Forget this device, sign in again, then restore with the new recovery code the reset showed you, or link this browser from one that holds the new key.`}),g&&(0,Q.jsx)(Ig,{userID:n,store:u,live:g,held:s===`held`,stepUp:d,exportWaiting:w,onReset:p,password:c?void 0:hb(t)})]}),(0,Q.jsxs)(`div`,{className:`settings-content`,hidden:e!==`devices`,children:[s===`link`&&(0,Q.jsx)(o_,{userID:n,canKeep:()=>yl(t),store:u,onLinked:()=>{C(`linked`),f()}}),s===`link`&&(0,Q.jsx)(Fg,{userID:n,sso:c,store:u,stepUp:d,onRestored:()=>{C(`restored`),f()}}),s===`held`&&(0,Q.jsx)(s_,{userID:n,held:l,stepUp:d}),s!==`link`&&s!==`held`&&(0,Q.jsx)(`p`,{className:`config-muted`,children:`This browser holds no encryption key to link another browser with.${pb(s,c)}`})]}),(0,Q.jsx)(`div`,{hidden:e!==`appearance`,children:(0,Q.jsx)(Xf,{})}),(0,Q.jsx)(`div`,{className:`settings-content`,hidden:e!==`reminders`,children:(0,Q.jsx)(Ly,{userID:n,prefs:v,onChange:y})}),(0,Q.jsx)(`div`,{className:`settings-content`,hidden:e!==`colleague-keys`,children:(0,Q.jsx)(O_,{username:t,userID:n,names:a})}),(0,Q.jsx)(`div`,{className:`settings-content`,hidden:e!==`share-links`,children:e===`share-links`&&(0,Q.jsx)(B_,{userID:n,keysFor:o})}),(0,Q.jsx)(`div`,{className:`settings-content`,hidden:e!==`unsent`,children:(0,Q.jsx)(F_,{username:t,userID:n,keysFor:o,waitingHeld:h})})]})}b_(location,history,y_()),uv({name:`KyNotes`}),(0,Zg.createRoot)(document.getElementById(`root`)).render(Ye()?(0,Q.jsx)(X.StrictMode,{children:(0,Q.jsx)(bb,{})}):(0,Q.jsx)(`p`,{role:`alert`,children:Je}));export{V as C,fe as E,Me as S,pe as T,Il as _,wv as a,je as b,xv as c,Fv as d,Nv as f,of as g,pf as h,vv as i,Sv as l,Jg as m,ay as n,yv as o,Xg as p,Cv as r,bv as s,Yv as t,Mv as u,fo as v,de as w,Ne as x,Ce as y}; \ No newline at end of file diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index 56ae5ddf..edaf5e18 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -9,7 +9,7 @@ KyNotes - + diff --git a/web/e2e/persistent-storage.e2e.ts b/web/e2e/persistent-storage.e2e.ts new file mode 100644 index 00000000..0f4edf0b --- /dev/null +++ b/web/e2e/persistent-storage.e2e.ts @@ -0,0 +1,32 @@ +import { expect, test } from "@playwright/test"; +import { adminConsole, OWNER, person, signIn } from "./people"; + +declare global { + interface Window { persistAsked?: number } +} + +test("signing in asks the browser to keep the storage that holds the encryption key", async ({ browser }) => { + const admin = await person(browser); + const owner = await person(browser); + try { + await adminConsole(admin.page); + const { page } = owner; + // Counts the requests; the browser still answers them itself. + await page.addInitScript(() => { + const storage = navigator.storage; + const persist = storage.persist.bind(storage); + window.persistAsked = 0; + storage.persist = () => { + window.persistAsked = (window.persistAsked ?? 0) + 1; + return persist(); + }; + }); + await signIn(page, OWNER.username, OWNER.password); + // Asked once the vault keeps the key, unless the browser already keeps this site's storage. + await expect.poll(() => page.evaluate(async () => (window.persistAsked ?? 0) > 0 || (await navigator.storage.persisted()))).toBe(true); + expect(owner.unexpected).toEqual([]); + } finally { + await admin.page.context().close(); + await owner.page.context().close(); + } +}); diff --git a/web/src/persist.test.ts b/web/src/persist.test.ts new file mode 100644 index 00000000..c155cdd4 --- /dev/null +++ b/web/src/persist.test.ts @@ -0,0 +1,30 @@ +import { describe, expect, it } from "vitest"; +import { keepStorage } from "./persist"; + +const storage = (persisted: boolean, granted: boolean) => { + const asked: string[] = []; + return { + asked, + persisted: async () => { asked.push("persisted"); return persisted; }, + persist: async () => { asked.push("persist"); return granted; }, + }; +}; + +describe("keepStorage", () => { + it("does not ask again once storage is kept", async () => { + const kept = storage(true, false); + expect(await keepStorage(kept)).toBe(true); + expect(kept.asked).toEqual(["persisted"]); + }); + it("asks once, and reports the browser's answer", async () => { + const granted = storage(false, true); + expect(await keepStorage(granted)).toBe(true); + expect(granted.asked).toEqual(["persisted", "persist"]); + expect(await keepStorage(storage(false, false))).toBe(false); + }); + it("is false without the API, or when the browser throws", async () => { + expect(await keepStorage(undefined)).toBe(false); + expect(await keepStorage({})).toBe(false); + expect(await keepStorage({ persisted: async () => { throw new Error("no"); }, persist: async () => true })).toBe(false); + }); +}); diff --git a/web/src/persist.ts b/web/src/persist.ts new file mode 100644 index 00000000..ddf9453d --- /dev/null +++ b/web/src/persist.ts @@ -0,0 +1,15 @@ +type Persistable = Pick; + +/** + * Asks the browser not to clear this site's storage on its own (to free space, or after Safari's + * days without a visit), since it holds this browser's encryption key. Firefox asks the user; + * Chromium and Safari decide silently. Best effort: true only when storage is kept. + */ +export async function keepStorage(storage: Partial | undefined = globalThis.navigator?.storage): Promise { + if (!storage?.persisted || !storage.persist) return false; + try { + return (await storage.persisted()) || (await storage.persist()); + } catch { + return false; + } +} diff --git a/web/src/storage.ts b/web/src/storage.ts index ff4c5a1f..a1ce5979 100644 --- a/web/src/storage.ts +++ b/web/src/storage.ts @@ -1,6 +1,7 @@ import { x25519 } from "@noble/curves/ed25519.js"; import type { HeldIdentity } from "./identity"; import type { KeyState } from "./keyring"; +import { keepStorage } from "./persist"; import { isPinConfirmation, sameKey, type PinConfirmation, type Pins } from "./pins"; import { sameBytes } from "./teamKeys"; const databaseName = "kynotes-web"; @@ -332,12 +333,14 @@ const holds = (record: VaultRecord, userID: string, expected: HeldIdentity | nul export async function storeIdentityKey(username: string, userID: string, identity: HeldIdentity, expected?: HeldIdentity | null): Promise { const stored = await sealForDevice(userID, identity).catch(() => undefined); // Only in an opened vault record: updateRecord never creates one. - return stored ? updateRecord(username, (record) => { + const kept = stored ? await updateRecord(username, (record) => { if (expected !== undefined && !holds(record, userID, expected)) return undefined; const { resetSent, ...rest } = record; // Keeping the key a reset sent finishes that reset here. return resetSent && resetSent.userID === userID && sameBytes(resetSent.publicKey, identity.publicKey) ? { ...rest, identity: stored } : { ...record, identity: stored }; }) : false; + if (kept) void keepStorage(); + return kept; } /** Records, before a reset is sent, the new public key; best-effort (M4: an unanswered reset is explained on the next load). */