@vite-hub/comments 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +243 -0
  3. package/dist/anchor.d.ts +40 -0
  4. package/dist/anchor.js +128 -0
  5. package/dist/client.d.ts +101 -0
  6. package/dist/client.js +553 -0
  7. package/dist/console-BIz9t2cO.d.ts +243 -0
  8. package/dist/database/postgres.d.ts +1011 -0
  9. package/dist/database/postgres.js +60 -0
  10. package/dist/database-BSnVrwHn.js +60 -0
  11. package/dist/database-C-ktS9Do.js +95 -0
  12. package/dist/database-Cb2xjC1V.d.ts +1096 -0
  13. package/dist/database.d.ts +104 -0
  14. package/dist/database.js +3 -0
  15. package/dist/define-BzW2Ychn.d.ts +46 -0
  16. package/dist/define-Cbhl6QVJ.js +32 -0
  17. package/dist/errors-BAQYcy3_.d.ts +89 -0
  18. package/dist/errors-DeD6wTCl.js +77 -0
  19. package/dist/h3-v1-request-DDGXJ9E7.js +166 -0
  20. package/dist/identity-3qtVC4rF.js +34 -0
  21. package/dist/index-DklG2Etf.d.ts +111 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.js +5 -0
  24. package/dist/operations-0B0QTVWX.d.ts +138 -0
  25. package/dist/operations-NZG5dB8y.js +732 -0
  26. package/dist/operations.d.ts +7 -0
  27. package/dist/operations.js +2 -0
  28. package/dist/overlay/overlay.js +195 -0
  29. package/dist/page/loader.js +22 -0
  30. package/dist/page-BtXADR6d.d.ts +21 -0
  31. package/dist/page-BuroSMXO.js +38 -0
  32. package/dist/page-tools-shared-D-amu6sx.js +53 -0
  33. package/dist/plugin-QElKQYkA.js +725 -0
  34. package/dist/realtime.d.ts +18 -0
  35. package/dist/realtime.js +48 -0
  36. package/dist/request-DVc3M_AG.js +14 -0
  37. package/dist/rpc.d.ts +29 -0
  38. package/dist/rpc.js +75 -0
  39. package/dist/runtime/auth.d.ts +6 -0
  40. package/dist/runtime/auth.js +15 -0
  41. package/dist/runtime/connect/node.d.ts +1 -0
  42. package/dist/runtime/connect/node.js +2 -0
  43. package/dist/runtime/connect.d.ts +1 -0
  44. package/dist/runtime/connect.js +2 -0
  45. package/dist/runtime/console.d.ts +5 -0
  46. package/dist/runtime/console.js +59 -0
  47. package/dist/runtime/index.d.ts +222 -0
  48. package/dist/runtime/index.js +665 -0
  49. package/dist/server-BomGg3Gb.js +63 -0
  50. package/dist/server.d.ts +94 -0
  51. package/dist/server.js +326 -0
  52. package/dist/src-CRTwnaEG.js +1362 -0
  53. package/dist/testing.d.ts +30 -0
  54. package/dist/testing.js +175 -0
  55. package/dist/types-Cj8K7Vx7.d.ts +176 -0
  56. package/dist/types-Un2dcJWD.d.ts +288 -0
  57. package/dist/vite.d.ts +304 -0
  58. package/dist/vite.js +1921 -0
  59. package/package.json +156 -4
@@ -0,0 +1,7 @@
1
+ import { t as AnyOperation } from "./operations-0B0QTVWX.js";
2
+ //#region src/operations-core/operations.d.ts
3
+ /** Longest message, in characters. */
4
+ export declare const maximumCommentBodyLength = 10000;
5
+ /** The comment operations. The Console, the CLI, MCP, and the comments client call them. */
6
+ export declare const commentsOperations: readonly AnyOperation[];
7
+ //#endregion
@@ -0,0 +1,2 @@
1
+ import { n as maximumCommentBodyLength, t as commentsOperations } from "./operations-NZG5dB8y.js";
2
+ export { commentsOperations, maximumCommentBodyLength };
@@ -0,0 +1,195 @@
1
+ function e(e,t=typeof __VITEHUB_APP_BASE_URL__>`u`?`/`:__VITEHUB_APP_BASE_URL__){return t===`/`?e:`${t.replace(/\/+$/,``)}${e}`}function t(e,...t){return typeof e==`function`?e(...t):e}const n=Error.captureStackTrace;var r=class e extends Error{name;code;docs;fix;sources;data;get why(){return this.message}constructor(t,r=e){super(t.why,{cause:t.cause}),this.code=this.name=t.code,this.fix=t.fix,this.docs=t.docs,this.sources=t.sources,this.data=t.data,n?.(this,r)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,data:this.data,stack:this.stack}}};function i(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}/* @__NO_SIDE_EFFECTS__ */
2
+ function a(e){let n=e.reporters??[],a={},{docsBase:o}=e;for(let s of Object.keys(e.codes)){let c=e.codes[s],l=c.docs===!1?void 0:c.docs||i(o,s),u=(e={},i={})=>{let a=new r({code:s,why:t(c.why,e),fix:t(c.fix,e),docs:l,cause:e.cause,sources:e.sources,data:t(c.data,e)},u);for(let e of n)e(a,i);return a};a[s]=u}return a}const o={why:({message:e})=>e===void 0?``:String(e)},s=/*#__PURE__*/ a({docsBase:()=>`https://vitehub.dev/docs/reference/errors-diagnostics`,codes:{RUNTIME_R0001:o,RUNTIME_R0002:o,RUNTIME_R0003:o,RUNTIME_R0004:o,RUNTIME_R0005:o,RUNTIME_R0006:o,RUNTIME_R0007:o,RUNTIME_R0008:o,RUNTIME_R0009:o,RUNTIME_R0010:o,RUNTIME_R0011:o,RUNTIME_R0012:o,RUNTIME_R0013:o,RUNTIME_R0014:o,RUNTIME_R0015:o,RUNTIME_R0016:o}});function c(e,t){switch(t){case`bigint`:case`boolean`:case`function`:case`number`:case`object`:case`string`:case`symbol`:case`undefined`:{let n=typeof e;return(n===`undefined`&&e!==void 0?`function`:n)===t}}throw s.RUNTIME_R0008({message:`Unsupported runtime type: ${t}`})}function l(e){return e!==null&&Object(e)===e}const u=/* @__PURE__ */ new WeakMap;function d(){throw s.RUNTIME_R0006({message:`[vitehub] ViteHubError requires a valid public error contract.`})}function f(e){try{return Array.isArray(e)}catch{d()}}function p(e,t,n=!1){try{let r=Object.getOwnPropertyDescriptor(e,t);return r===void 0?void 0:((!(`value`in r)||n&&!r.enumerable)&&d(),r.value)}catch{d()}}function ee(e,t,n,r){if(t.nodes+=1,t.nodes>1024&&d(),e===void 0&&r)return;if(e===null||typeof e==`boolean`||typeof e==`string`&&e.length<=16384||typeof e==`number`&&Number.isFinite(e))return e;(typeof e!=`object`||n>8||t.ancestors.has(e))&&d();let i,a;try{i=Object.getPrototypeOf(e),a=Reflect.ownKeys(e)}catch{d()}t.ancestors.add(e);try{if(f(e)){let r=p(e,`length`);(!Number.isSafeInteger(r)||r<0||r>128||a.length!==r+1||!a.includes(`length`))&&d();let i=[];for(let o=0;o<r;o+=1){let r=String(o);a.includes(r)||d(),i.push(ee(p(e,r,!0),t,n+1,!1))}return Object.freeze(i)}i!==Object.prototype&&i!==null&&d(),(a.length>128||a.some(e=>typeof e!=`string`))&&d();let r={};for(let i of a)(i.length===0||i.length>128)&&d(),Object.defineProperty(r,i,{enumerable:!0,value:ee(p(e,i,!0),t,n+1,!0),writable:!0});return Object.freeze(r)}finally{t.ancestors.delete(e)}}function te(e){if(e!==void 0)return(typeof e!=`object`||!e||f(e))&&d(),ee(e,{ancestors:/* @__PURE__ */ new Set,nodes:0},0,!1)}function m(e,t,n){(typeof e!=`string`||e.length===0||e.length>128)&&d(),(typeof t!=`string`||t.length===0||t.length>16384)&&d(),(typeof n!=`object`||!n||f(n))&&d();let r=p(n,`cause`),i=te(p(n,`details`)),a=p(n,`requestId`);return a!==void 0&&(typeof a!=`string`||a.length===0||a.length>256)&&d(),{cause:r,code:e,details:i,message:t,name:`ViteHubError`,requestId:a,shape:Object.freeze({code:e,...i===void 0?{}:{details:i},message:t,name:`ViteHubError`,...a===void 0?{}:{requestId:a}})}}var ne=class extends Error{code;details;requestId;constructor(e,t,n={}){let r=m(e,t,n);super(r.message,r.cause===void 0?void 0:{cause:r.cause}),this.name=`ViteHubError`,this.code=r.code,this.details=r.details,this.requestId=r.requestId;let i=this.toJSON.bind(this);Object.defineProperties(this,{code:{configurable:!0,enumerable:!0,value:r.code,writable:!1},details:{configurable:!0,enumerable:!0,value:r.details,writable:!1},message:{configurable:!0,enumerable:!1,value:r.message,writable:!1},name:{configurable:!1,enumerable:!1,value:r.name,writable:!1},requestId:{configurable:!0,enumerable:!0,value:r.requestId,writable:!1},toJSON:{configurable:!1,enumerable:!1,value:i,writable:!1}}),u.set(this,r.shape)}toJSON(){let e=u.get(this);if(e)return e;let t=m(p(this,`code`),p(this,`message`),{details:p(this,`details`),requestId:p(this,`requestId`)});return u.set(this,t.shape),t.shape}};function re(e){let t=t=>{let n=Object.getOwnPropertyDescriptor(e,t);return n?n.configurable===!0:Object.isExtensible(e)},n=t(`name`)&&t(`toJSON`)?e:new r({code:e.code,why:e.why,fix:e.fix,docs:e.docs,cause:e.cause,data:e.data,sources:e.sources});return n!==e&&(n.stack=e.stack),Object.defineProperty(n,"name",{configurable:!0,value:n.code,writable:!0}),Object.defineProperty(n,"toJSON",{configurable:!0,value:()=>({code:n.code,docs:n.docs,fix:n.fix,name:n.name,why:n.why})}),n}function ie(e){let t=/* @__PURE__ */ a({codes:e.codes,docsBase:t=>`${e.docs}#${String(t).toLowerCase()}`}),n={};for(let[e,r]of Object.entries(t))n[e]=e=>re(r(e));return n}Object.getOwnPropertyDescriptor(Blob.prototype,`type`)?.get,Object.getOwnPropertyDescriptor(Blob.prototype,`stream`)?.value,Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get;const ae=(()=>{let e=Object.getOwnPropertyDescriptor(globalThis,`WebAssembly`)?.value;return c(e,`object`)?Object.getOwnPropertyDescriptor(e,`Module`)?.value:void 0})();c(ae,`function`)&&Object.getOwnPropertyDescriptor(ae,`exports`)?.value;const h=Function.prototype.toString,oe=(()=>{try{if(Object.prototype.hasOwnProperty.call(h,`prototype`)||h.name!==`toString`||h.length!==1||h.call(h).replace(/\s+/g,` `)!==`function toString() { [native code] }`)return!1;function e(){return 1}if(h.call(e)!==`function probe() { return 1 }`)return!1;let t=[function(){},function(){},function(){},function(){}];for(let e of t)if(h.call(e).includes(`[native code]`))return!1;let n=Object.getOwnPropertyDescriptor({get byteLength(){return 0}},`byteLength`)?.get;if(!n||h.call(n).includes(`[native code]`))return!1;try{return h.call(null),!1}catch{return!0}}catch{return!1}})();function se(e,t){if(!oe||!c(e,`function`))return!1;try{return h.call(e).replace(/\s+/g,` `)===`function ${t}() { [native code] }`}catch{return!1}}function ce(){try{let e,t=Object.getOwnPropertyDescriptor(globalThis,`SharedArrayBuffer`)?.value;if(se(t,`SharedArrayBuffer`))e=Reflect.construct(t,[0]);else{let t=Object.getOwnPropertyDescriptor(globalThis,`WebAssembly`)?.value;if(!l(t))return;let n=Object.getOwnPropertyDescriptor(t,`Memory`)?.value;if(!se(n,`Memory`))return;let r=Reflect.construct(n,[{initial:0,maximum:1,shared:!0}]),i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(r),`buffer`)?.get;if(!se(i,`get buffer`))return;e=i.call(r)}if(!l(e))return;let n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),`byteLength`)?.get;if(!se(n,`get byteLength`)||n.call(e)!==0)return;let r=[{},Object.create(null)];for(let e of r)try{n.call(e);return}catch{}return n}catch{return}}function le(){try{let e=Object.getOwnPropertyDescriptor(globalThis,`ArrayBuffer`)?.value,t=Object.getOwnPropertyDescriptor(globalThis,`DataView`)?.value;if(!se(e,`ArrayBuffer`)||!se(t,`DataView`))return;let n=Reflect.construct(e,[0]),r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n),`byteLength`)?.get;if(!se(r,`get byteLength`)||r.call(n)!==0)return;Reflect.construct(t,[n,0,0]);try{Reflect.construct(t,[{},0,0]);return}catch{return{byteLength:r,dataView:t}}}catch{return}}ce(),le();const ue=/*#__PURE__*/ ie({docs:`https://vitehub.dev/docs/realtime/limits-and-errors`,codes:{REALTIME_DISABLED:{why:({action:e})=>`Realtime is disabled, so \`${e}()\` cannot run.`,fix:"Set `enabled` to `true` on `useRealtimeTiptap()` before you call the method."},REALTIME_DISCONNECTED:{why:({action:e})=>`The realtime document disconnected or changed during \`${e}()\`.`,fix:"Call the method again after the new document connects. Read `synced` to know when it is ready."},REALTIME_INVALID_RESPONSE:{why:({action:e})=>`The realtime server answered \`${e}()\` with a response that the client cannot use.`,fix:"Use the same `@vite-hub/realtime` version on the client and the server, and build again."},REALTIME_MISSING_DOCUMENT:{why:({action:e})=>`\`${e}()\` needs a document, and \`documentId\` is empty.`,fix:"Pass a document path to `useRealtimeTiptap(definition, documentId)` before you call the method."},REALTIME_REQUEST_FAILED:{why:({action:e,message:t,status:n})=>`The realtime \`${e}()\` request failed${n===void 0?``:` with HTTP ${n}`}${t?`: ${t}`:`.`}`,fix:"Read `error.why` for the server message, and `error.cause` for a network error. Retry when the server is available again."},REALTIME_AWARENESS_OWNERSHIP_CONFLICT:{why:`A realtime awareness client id belongs to another peer.`,fix:`Let each editor tab use its own Yjs awareness client. Do not reuse a client id on two connections.`},REALTIME_AWARENESS_TOO_LARGE:{why:`Realtime awareness state exceeds the 8 MiB room quota.`,fix:`Keep less data in awareness state. Store large values in the document or in Workspace.`},REALTIME_DOCUMENT_TOO_LARGE:{why:`The realtime document exceeds the 8 MiB room quota.`,fix:`Split the document into smaller documents, or keep large assets in Workspace or Blob.`},REALTIME_INVALID_AWARENESS:{why:`A realtime awareness update has a state that is not a plain object.`,fix:"Set awareness state to a plain object, for example `awareness.setLocalStateField('user', { name })`."},REALTIME_TOO_MANY_AWARENESS_CLIENTS:{why:`One realtime peer sent more than 1,024 awareness clients.`,fix:`Use one awareness client for each editor tab.`},REALTIME_DOCUMENT_CONFLICT:{why:({problem:e})=>e??`The stored document changed since the realtime room loaded it.`,fix:"Realtime re-seeds the room from the stored document. Listen to `onReset()` to recover text that the room did not save."},REALTIME_INVALID_PERSISTENCE:{why:({name:e,reason:t})=>t===`below-debounce`?"Realtime `persistence.maxWait` must be at least `persistence.debounce`.":`Realtime \`persistence.${e}\` must be a non-negative number of milliseconds.`,fix:"Set `persistence: { debounce: 2_000, maxWait: 10_000 }`, or remove the option to use these defaults."},REALTIME_INVALID_USER:{why:"The realtime identity needs a user `id` that is a non-empty string of at most 256 characters.",fix:"Return a user with an `id` from the Auth session or from `authorize()`."},REALTIME_MISSING_DIGEST:{why:({operation:e})=>e===`save`?`Realtime saves need Workspace file digests, and the Workspace Store did not return one.`:`Realtime checkpoints need a stored document, and the save returned no digest.`,fix:"Use a Workspace Store that returns file digests, or return `digest` from the document adapter `save()`."},REALTIME_AUTHORITY_CONFLICT:{why:({authority:e,preset:t})=>e===`memory`?`Realtime authority "memory" is single-process only, and the ${t} deployment preset runs more than one process.`:`Realtime authority "cloudflare" does not work with the ${t} deployment preset.`,fix:'Set `realtime.authority` to "cloudflare" with a Cloudflare preset, or to "memory" for one Node.js process.'},REALTIME_MISSING_AUTHORITY:{why:`Realtime production builds need one room authority, and ViteHub cannot select one for this deployment.`,fix:'Deploy with a Cloudflare preset to use Durable Objects, or set `realtime.authority` to "memory" for one Node.js process.'}}}),g=Math.floor,de=Math.abs,fe=(e,t)=>e<t?e:t,pe=(e,t)=>e>t?e:t;Number.isNaN;const me=Math.pow,he=e=>e===0?1/e<0:e<0,ge=2**53-1,_e=-(2**53-1),ve=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&g(e)===e);Number.isNaN,Number.parseInt;const ye=()=>/* @__PURE__ */ new Set,be=e=>e[e.length-1],xe=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},_=Array.from,Se=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ce=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},we=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Te=Array.isArray,Ee=String.fromCharCode;String.fromCodePoint,Ee(65535);const De=e=>e.toLowerCase(),Oe=/^\s*/g,ke=e=>e.replace(Oe,``),Ae=/([A-Z])/g,je=(e,t)=>ke(e.replace(Ae,e=>`${t}${De(e)}`)),Me=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ne=typeof TextEncoder<`u`?new TextEncoder:null,Pe=Ne?e=>Ne.encode(e):Me;
3
+ /* c8 ignore next */
4
+ let Fe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});
5
+ /* c8 ignore start */
6
+ Fe&&Fe.decode(/* @__PURE__ */ new Uint8Array).length===1&&
7
+ /* c8 ignore next */
8
+ (Fe=null);const Ie=(e,t)=>we(t,()=>e).join(``),v=e=>Error(e),y=()=>{throw v(`Method unimplemented`)},b=()=>{throw v(`Unexpected case`)};var Le=class{constructor(){this.cpos=0,this.cbuf=/* @__PURE__ */ new Uint8Array(100),this.bufs=[]}};const x=()=>new Le,Re=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array(Re(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},ze=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(pe(n,t)*2),e.cpos=0)},C=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Be=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=g(t/128);C(e,127&t)},Ve=(e,t)=>{let n=he(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=g(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=g(t/128)},He=/* @__PURE__ */ new Uint8Array(3e4),Ue=He.length/3,We=Ne&&Ne.encodeInto?(e,t)=>{if(t.length<Ue){
9
+ /* c8 ignore next */
10
+ let n=Ne.encodeInto(t,He).written||0;w(e,n);for(let t=0;t<n;t++)C(e,He[t])}else T(e,Pe(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},Ge=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=fe(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(pe(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),Ge(e,t)},Ke=(e,t)=>{ze(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},qe=(e,t)=>Ke(e,4).setFloat32(0,t,!1),Je=(e,t)=>Ke(e,8).setFloat64(0,t,!1),Ye=(e,t)=>Ke(e,8).setBigInt64(0,t,!1),Xe=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4)),Ze=e=>(Xe.setFloat32(0,e),Xe.getFloat32(0)===e),Qe=(e,t)=>{switch(typeof t){case`string`:C(e,119),We(e,t);break;case`number`:ve(t)&&de(t)<=2147483647?(C(e,125),Ve(e,t)):Ze(t)?(C(e,124),qe(e,t)):(C(e,123),Je(e,t));break;case`bigint`:C(e,122),Ye(e,t);break;case`object`:if(t===null)C(e,126);else if(Te(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)Qe(e,t[n])}else if(t instanceof Uint8Array)C(e,116),T(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];We(e,i),Qe(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}};var $e=class extends Le{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};const et=e=>{e.count>0&&(Ve(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))};var tt=class{constructor(){this.encoder=new Le,this.s=0,this.count=0}write(e){this.s===e?this.count++:(et(this),this.count=1,this.s=e)}toUint8Array(){return et(this),S(this.encoder)}};const nt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Ve(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}};var rt=class{constructor(){this.encoder=new Le,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(nt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return nt(this),S(this.encoder)}},it=class{constructor(){this.sarr=[],this.s=``,this.lensE=new tt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Le;return this.sarr.push(this.s),this.s=``,We(e,this.sarr.join(``)),Ge(e,this.lensE.toUint8Array()),S(e)}};const at=v(`Unexpected end of array`),ot=v(`Integer out of Range`),st=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw at;return new Uint8Array(e.buffer,e.byteOffset+t,n)},ct=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw at;return new DataView(e.buffer,e.byteOffset+t,n)};var lt=class{constructor(e){this.arr=e,this.pos=0}};const ut=e=>new lt(e),dt=e=>e.pos!==e.arr.length,ft=(e,t)=>{let n=st(e.arr,e.pos,t);return e.pos+=t,n},E=e=>ft(e,D(e)),pt=e=>e.arr[e.pos++],D=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;
11
+ /* c8 ignore start */
12
+ if(t>ge)throw ot}throw at},mt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;
13
+ /* c8 ignore start */
14
+ if(n>ge)throw ot}throw at},O=Fe?e=>Fe.decode(E(e)):e=>{let t=D(e);if(t===0)return``;{let n=String.fromCodePoint(pt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(pt(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},ht=(e,t)=>{let n=ct(e.arr,e.pos,t);return e.pos+=t,n},gt=[e=>void 0,e=>null,mt,e=>ht(e,4).getFloat32(0,!1),e=>ht(e,8).getFloat64(0,!1),e=>ht(e,8).getBigInt64(0,!1),e=>!1,e=>!0,O,e=>{let t=D(e),n={};for(let r=0;r<t;r++){let t=O(e);n[t]=_t(e)}return n},e=>{let t=D(e),n=[];for(let r=0;r<t;r++)n.push(_t(e));return n},E],_t=e=>gt[127-pt(e)](e);var vt=class extends lt{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=dt(this)?D(this)+1:-1),this.count--,this.s}},yt=class extends lt{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=mt(this);let e=he(this.s);this.count=1,e&&(this.s=-this.s,this.count=D(this)+2)}return this.count--,this.s}},bt=class extends lt{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=mt(this),t=e&1;this.diff=g(e/2),this.count=1,t&&(this.count=D(this)+2)}return this.s+=this.diff,this.count--,this.s}},xt=class{constructor(e){this.decoder=new yt(e),this.str=O(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};function St(e){let t=e.slice(0,4096);return new ne(`WORKSPACE_PATH_INVALID`,`[vitehub] Workspace path escapes the workspace root: ${JSON.stringify(t)}.`,{details:{path:t}})}function Ct(e){let t=e.toLowerCase().split(`:`,1)[0];return{normalized:t.replace(/[ .]+$/,``),isTraversal:/^(?:\.(?: +[. ]*)?|\.\.(?: +[. ]*)?)$/.test(t)}}function wt(e=``,t={}){let n=e.replace(/\\/g,`/`),r=n.replace(/^\/+/,``).replace(/\/+$/,``),i=r.split(`/`).filter(Boolean);if(!t.allowEmpty&&!r||n.startsWith(`/`)||/^[a-z]:/i.test(n)||n.includes(`\0`)||i.some((e,n)=>{let r=e.toLowerCase(),i=Ct(e),a=i.normalized===`.git`||/^git~\d+$/.test(i.normalized)||n===0&&i.normalized===`.vitehub`||n===0&&/^vitehu~\d+$/.test(i.normalized),o=(i.normalized===`.git`||n===0&&i.normalized===`.vitehub`)&&r===i.normalized;return i.isTraversal||a&&(!t.allowReserved||!o)}))throw St(e);return r}function Tt(e){return e===null||Object(e)!==e||Array.isArray(e)?!1:typeof e==`object`}const Et=[`#E11D48`,`#D97706`,`#059669`,`#0891B2`,`#2563EB`,`#7C3AED`,`#C026D3`];function k(e){try{return String(e)===e}catch{return!1}}function Dt(e){if(!k(e.id)||!e.id||e.id.length>256)throw ue.REALTIME_INVALID_USER();let t=0;for(let n=0;n<e.id.length;n++)t=Math.imul(31,t)+e.id.charCodeAt(n)|0;let n=(k(e.name)&&e.name||k(e.email)&&e.email||`Anonymous`).slice(0,256),r={color:Et[Math.abs(t)%Et.length],id:e.id,name:n};return k(e.image)&&e.image&&e.image.length<=2048&&(r.image=e.image),r}function Ot(e){return Tt(e)?k(e.id)&&e.id.length>0&&e.id.length<=256&&k(e.name)&&e.name.length>0&&e.name.length<=256&&k(e.color)&&/^#[\da-f]{6}$/i.test(e.color)&&(e.image===void 0||k(e.image)&&e.image.length<=2048):!1}function kt(e){let t=[];for(let[n,r]of e)if(Ot(r.user)){let{color:e,id:i,image:a,name:o}=r.user,s={color:e,id:i,name:o,clientId:n};a!==void 0&&(s.image=a),t.push(s)}return t}function At(e){try{let t=JSON.parse(O(e));if(!t||typeof t!=`object`||!(`epoch`in t)||!(`type`in t)||typeof t.epoch!=`string`||!t.epoch)return;if(t.type===`session`&&`access`in t&&(t.access===`read`||t.access===`write`))return t.access===`read`&&`reason`in t&&(t.reason===`access`||t.reason===`document`)?{type:`session`,access:t.access,epoch:t.epoch,reason:t.reason}:{type:`session`,access:t.access,epoch:t.epoch};if(t.type===`reset`&&`reason`in t&&(t.reason===`source-changed`||t.reason===`stale`))return{type:`reset`,epoch:t.epoch,reason:t.reason}}catch{}}function jt(e){if(typeof e!=`string`||e.length===0||e.length>4096||e.includes(`\0`)||e.startsWith(`/`)||e.endsWith(`/`)||e.includes(`\\`)||e.includes(`//`)||/^[a-z]:/i.test(e))return!1;try{return wt(e)===e}catch{return!1}}function Mt(e){try{let t=JSON.parse(O(e));if((t.operation===`create`||t.operation===`delete`||t.operation===`update`)&&jt(t.path))return{operation:t.operation,path:t.path};if(t.operation===`move`&&jt(t.from)&&jt(t.to))return{operation:t.operation,from:t.from,to:t.to}}catch{}}function Nt(e){let t=x();return w(t,4),We(t,JSON.stringify(e)),S(t)}const A=Date.now,j=()=>/* @__PURE__ */ new Map,Pt=e=>{let t=j();return e.forEach((e,n)=>{t.set(n,e)}),t},M=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ft=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},It=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var Lt=class{constructor(){this._observers=j()}on(e,t){return M(this._observers,e,ye).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||j()).values()).forEach(e=>e(...t))}destroy(){this._observers=j()}},Rt=class{constructor(){this._observers=j()}on(e,t){M(this._observers,e,ye).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return _((this._observers.get(e)||j()).values()).forEach(e=>e(...t))}destroy(){this._observers=j()}};
15
+ /* c8 ignore end */
16
+ const zt=Symbol(`Equality`),Bt=(e,t)=>e===t||!!e?.[zt]?.(t)||!1,Vt=e=>typeof e==`object`,Ht=Object.assign,Ut=Object.keys,Wt=(e,t)=>{for(let n in e)t(e[n],n)},Gt=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n},Kt=e=>Ut(e).length,qt=e=>{for(let t in e)return!1;return!0},Jt=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Yt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Xt=(e,t)=>e===t||Kt(e)===Kt(t)&&Jt(e,(e,n)=>(e!==void 0||Yt(t,n))&&Bt(t[n],e)),Zt=Object.freeze,Qt=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Qt(e[t])}return Zt(e)},$t=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&$t(e,t,n+1)}},en=e=>e,tn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[zt]!=null)return e[zt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!tn(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Kt(e)!==Kt(t))return!1;for(let n in e)if(!Yt(e,n)||!tn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!tn(e[n],t[n]))return!1;break;default:return!1}return!0},nn=(e,t)=>t.includes(e);crypto.subtle;const rn=crypto.getRandomValues.bind(crypto),an=()=>rn(/* @__PURE__ */ new Uint32Array(1))[0],on=()=>`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^an()&15>>e/4).toString(16)),sn=e=>new Promise(e);Promise.all.bind(Promise);
17
+ /* c8 ignore next */
18
+ const cn=e=>e===void 0?null:e;
19
+ /* c8 ignore stop */
20
+ let ln=new class{constructor(){this.map=/* @__PURE__ */ new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},un=!0;
21
+ /* c8 ignore start */
22
+ try{typeof localStorage<`u`&&localStorage&&(ln=localStorage,un=!1)}catch{}
23
+ /* c8 ignore stop */
24
+ /* c8 ignore next */
25
+ const dn=ln,fn=e=>un||addEventListener(`storage`,e),pn=e=>un||removeEventListener(`storage`,e),mn=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,hn=typeof window<`u`&&typeof document<`u`&&!mn;typeof navigator<`u`&&/Mac/.test(navigator.platform);let N;const gn=[],_n=()=>{if(N===void 0){if(mn){N=j();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&N.set(t,``),t=r):t===null?gn.push(r):(N.set(t,r),t=null)}t!==null&&N.set(t,``)}else typeof location==`object`?(N=j(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);N.set(`--${je(t,`-`)}`,n),N.set(`-${je(t,`-`)}`,n)}})):N=j()}return N},vn=e=>_n().has(e),yn=e=>cn(mn?process.env[e.toUpperCase().replaceAll(`-`,`_`)]:dn.getItem(e)),bn=e=>vn(`--`+e)||yn(e)!==null,xn=bn(`production`),Sn=mn&&nn(process.env.FORCE_COLOR,[`true`,`1`,`2`])||!vn(`--no-colors`)&&!bn(`no-color`)&&(!mn||process.stdout.isTTY)&&(!mn||vn(`--color`)||yn(`COLORTERM`)!==null||(yn(`TERM`)||``).includes(`color`)),Cn=e=>new Uint8Array(e),wn=e=>new Uint8Array(e),Tn=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ee(e[n]);return btoa(t)},En=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Dn=e=>{let t=atob(e),n=Cn(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},On=e=>new Uint8Array(Buffer.from(e,`base64`)),kn=hn?Tn:En,An=hn?Dn:On,jn=e=>{let t=Cn(e.byteLength);return t.set(e),t};var Mn=class{constructor(e,t){this.left=e,this.right=t}};const P=(e,t)=>new Mn(e,t),Nn=e=>e.next()>=.5,Pn=(e,t,n)=>g(e.next()*(n+1-t)+t),Fn=(e,t,n)=>g(e.next()*(n+1-t)+t),In=(e,t,n)=>Fn(e,t,n),Ln=e=>Ee(In(e,97,122)),Rn=(e,t=0,n=20)=>{let r=In(e,t,n),i=``;for(let t=0;t<r;t++)i+=Ln(e);return i},zn=(e,t)=>t[In(e,0,t.length-1)],Bn=Symbol(`0schema`);var Vn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];
26
+ /* c8 ignore next */
27
+ e.push(Ie(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
28
+ `)}};const Hn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[zt]?Bt(e,t):Te(e)?Se(e,e=>Ce(t,t=>Hn(e,t))):Vt(e)?Jt(e,(e,n)=>Hn(e,t[n])):!1;var F=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Hn(t,n)}equals(e){return this.constructor===e.constructor&&tn(this.shape,e.shape)}[Bn](){return!0}[zt](e){return this.equals(e)}validate(e){return this.check(e)}
29
+ /* c8 ignore start */
30
+ check(e,t){y()}
31
+ /* c8 ignore stop */
32
+ get nullable(){return yr(this,Pr)}get optional(){return new Zn(this)}cast(e){return Rr(e,this),e}expect(e){return Rr(e,this),e}},Un=class extends F{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}};const I=(e,t=null)=>new Un(e,t);I(Un);var Wn=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}};const L=e=>new Wn(e);I(Wn);var Gn=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}};const Kn=(...e)=>new Gn(e),qn=I(Gn),Jn=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Yn=e=>{if(kr.check(e))return[Jn(e)];if(qn.check(e))return e.shape.map(e=>e+``);if(Or.check(e))return[`[+-]?\\d+.?\\d*`];if(Ar.check(e))return[`.*`];if(br.check(e))return e.shape.map(Yn).flat(1);
33
+ /* c8 ignore next 2 */
34
+ b()};I(class extends F{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Yn).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});const Xn=Symbol(`optional`);var Zn=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Xn](){return!0}};const Qn=I(Zn);var $n=class extends F{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new $n,I($n);var er=class e extends F{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?
35
+ /* c8 ignore next */
36
+ (t?.extend(null,`object`,`null`),!1):Jt(this.shape,(n,r)=>{let i=this._isPartial&&!Yt(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}};const tr=e=>new er(e),nr=I(er),rr=L(e=>e!=null&&(e.constructor===Object||e.constructor==null));var ir=class extends F{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Jt(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}};const ar=(e,t)=>new ir(e,t),or=I(ir);var sr=class extends F{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Jt(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}};const cr=(...e)=>new sr(e);I(sr);var lr=class extends F{constructor(e){super(),this.shape=e.length===1?e[0]:new vr(e)}check(e,t){let n=Te(e)&&Se(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}};const ur=(...e)=>new lr(e),dr=I(lr),fr=L(e=>Te(e));var pr=class extends F{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}};const mr=(e,t=null)=>new pr(e,t);I(pr);const hr=mr(F),gr=I(class extends F{constructor(e){super(),this.len=e.length-1,this.args=cr(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),_r=L(e=>typeof e==`function`);I(class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=Se(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var vr=class extends F{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Ce(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}};const yr=(...e)=>e.findIndex(e=>br.check(e))>=0?yr(...e.map(e=>Lr(e)).map(e=>br.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new vr(e),br=I(vr),xr=()=>!0,Sr=L(xr),Cr=I(Wn,e=>e.shape===xr),wr=L(e=>typeof e==`bigint`),Tr=L(e=>e===wr),Er=L(e=>typeof e==`symbol`);L(e=>e===Er);const Dr=L(e=>typeof e==`number`),Or=L(e=>e===Dr),kr=L(e=>typeof e==`string`),Ar=L(e=>e===kr),jr=L(e=>typeof e==`boolean`),Mr=L(e=>e===jr),Nr=Kn(void 0);I(Gn,e=>e.shape.length===1&&e.shape[0]===void 0),Kn(void 0);const Pr=Kn(null),Fr=I(Gn,e=>e.shape.length===1&&e.shape[0]===null);I(Uint8Array),I(Un,e=>e.shape===Uint8Array);const Ir=yr(Dr,kr,Pr,Nr,wr,jr,Er);(()=>{let e=ur(Sr),t=ar(kr,Sr),n=yr(Dr,kr,Pr,jr,e,t);return e.shape=n,t.shape.values=n,n})();const Lr=e=>{if(hr.check(e))return e;if(rr.check(e)){let t={};for(let n in e)t[n]=Lr(e[n]);return tr(t)}if(fr.check(e))return yr(...e.map(Lr));if(Ir.check(e))return Kn(e);if(_r.check(e))return I(e);
37
+ /* c8 ignore next */
38
+ b()},Rr=xn?()=>{}:(e,t)=>{let n=new Vn;if(!t.check(e,n))throw v(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)};
39
+ /* c8 ignore end */
40
+ var zr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Lr(e),h:t}),this}else(e){return this.if(Sr,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw v(`Unhandled pattern`)}}};const Br=(e=>new zr(e))(Sr).if(Or,(e,t)=>Pn(t,_e,ge)).if(Ar,(e,t)=>Rn(t)).if(Mr,(e,t)=>Nn(t)).if(Tr,(e,t)=>BigInt(Pn(t,_e,ge))).if(br,(e,t)=>Vr(t,zn(t,e.shape))).if(nr,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Qn.check(i)){if(Nn(t))continue;i=i.shape}n[r]=Br(i,t)}return n}).if(dr,(e,t)=>{let n=[],r=Fn(t,0,42);for(let i=0;i<r;i++)n.push(Vr(t,e.shape));return n}).if(qn,(e,t)=>zn(t,e.shape)).if(Fr,(e,t)=>null).if(gr,(e,t)=>{let n=Vr(t,e.res);return()=>n}).if(Cr,(e,t)=>Vr(t,zn(t,[Dr,kr,Pr,Nr,wr,jr,ur(Dr),ar(yr(`a`,`b`,`c`),Dr)]))).if(or,(e,t)=>{let n={},r=Pn(t,0,3);for(let i=0;i<r;i++){let r=Vr(t,e.shape.keys);n[r]=Vr(t,e.shape.values)}return n}).done(),Vr=(e,t)=>Br(Lr(t),e),Hr=typeof document<`u`?document:{};L(e=>e.nodeType===qr),typeof DOMParser<`u`&&new DOMParser,L(e=>e.nodeType===Wr),L(e=>e.nodeType===Gr);const Ur=e=>Ft(e,(e,t)=>`${t}:${e};`).join(``),Wr=Hr.ELEMENT_NODE,Gr=Hr.TEXT_NODE;Hr.CDATA_SECTION_NODE,Hr.COMMENT_NODE;const Kr=Hr.DOCUMENT_NODE;Hr.DOCUMENT_TYPE_NODE;const qr=Hr.DOCUMENT_FRAGMENT_NODE;L(e=>e.nodeType===Kr);
41
+ /* c8 ignore stop */
42
+ const R=Symbol,Jr=R(),Yr=R(),Xr=R(),Zr=R(),Qr=R(),$r=R(),ei=R(),ti=R(),ni=R(),ri=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};A();
43
+ /* c8 ignore stop */
44
+ const ii={[Jr]:P(`font-weight`,`bold`),[Yr]:P(`font-weight`,`normal`),[Xr]:P(`color`,`blue`),[Qr]:P(`color`,`green`),[Zr]:P(`color`,`grey`),[$r]:P(`color`,`red`),[ei]:P(`color`,`purple`),[ti]:P(`color`,`orange`),[ni]:P(`color`,`black`)},ai=Sn?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=j(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=ii[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Ur(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:ri,oi=(...e)=>{
45
+ /* c8 ignore next */
46
+ console.log(...ai(e)),ci.forEach(t=>t.print(e))},si=(...e)=>{console.warn(...ai(e)),e.unshift(ti),ci.forEach(t=>t.print(e))},ci=ye(),li=e=>({[Symbol.iterator](){return this},next:e}),ui=(e,t)=>li(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),di=(e,t)=>li(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var fi=class{constructor(e,t){this.clock=e,this.len=t}},pi=class{constructor(){this.clients=/* @__PURE__ */ new Map}};const mi=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])_a(e,i,o.clock,o.len,n)}}),hi=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=g((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},gi=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&hi(n,t.clock)!==null},_i=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new fi(r.clock,pe(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},vi=e=>{let t=new pi;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)xe(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return _i(t),t},yi=(e,t,n,r)=>{M(e.clients,t,()=>[]).push(new fi(n,r))},bi=()=>new pi,xi=e=>{let t=bi();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new fi(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Si=(e,t)=>{w(e.restEncoder,t.clients.size),_(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),w(e.restEncoder,t);let r=n.length;w(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Ci=e=>{let t=new pi,n=D(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=D(e.restDecoder),r=D(e.restDecoder);if(r>0){let i=M(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new fi(e.readDsClock(),e.readDsLen()))}}return t},wi=(e,t,n)=>{let r=new pi,i=D(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=D(e.restDecoder),a=D(e.restDecoder),o=n.clients.get(i)||[],s=B(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&yi(r,i,s,a-s);let e=V(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,xs(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,xs(t,c,a-c.id.clock)),c.delete(t))}else yi(r,i,n,a-n)}}if(r.clients.size>0){let e=new Pi;return w(e.restEncoder,0),Si(e,r),e.toUint8Array()}return null},Ti=an;var Ei=class e extends Lt{constructor({guid:e=on(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Ti(),this.guid=e,this.collectionid=t,this.share=/* @__PURE__ */ new Map,this.store=new la,this._transaction=null,this._transactionCleanups=[],this.subdocs=/* @__PURE__ */ new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=sn(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>sn(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&H(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(_(this.subdocs).map(e=>e.guid))}transact(e,t=null){return H(this,e,t)}get(e,t=W){let n=M(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==W&&r!==t){if(r===W){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,mo)}getText(e=``){return this.get(e,Fo)}getMap(e=``){return this.get(e,_o)}getXmlElement(e=``){return this.get(e,Bo)}getXmlFragment(e=``){return this.get(e,Ro)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,_(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,H(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Di=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return D(this.restDecoder)}readDsLen(){return D(this.restDecoder)}},Oi=class extends Di{readLeftID(){return z(D(this.restDecoder),D(this.restDecoder))}readRightID(){return z(D(this.restDecoder),D(this.restDecoder))}readClient(){return D(this.restDecoder)}readInfo(){return pt(this.restDecoder)}readString(){return O(this.restDecoder)}readParentInfo(){return D(this.restDecoder)===1}readTypeRef(){return D(this.restDecoder)}readLen(){return D(this.restDecoder)}readAny(){return _t(this.restDecoder)}readBuf(){return jn(E(this.restDecoder))}readJSON(){return JSON.parse(O(this.restDecoder))}readKey(){return O(this.restDecoder)}},ki=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=D(this.restDecoder),this.dsCurrVal}readDsLen(){let e=D(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Ai=class extends ki{constructor(e){super(e),this.keys=[],D(e),this.keyClockDecoder=new bt(E(e)),this.clientDecoder=new yt(E(e)),this.leftClockDecoder=new bt(E(e)),this.rightClockDecoder=new bt(E(e)),this.infoDecoder=new vt(E(e),pt),this.stringDecoder=new xt(E(e)),this.parentInfoDecoder=new vt(E(e),pt),this.typeRefDecoder=new yt(E(e)),this.lenDecoder=new yt(E(e))}readLeftID(){return new ra(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ra(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return _t(this.restDecoder)}readBuf(){return E(this.restDecoder)}readJSON(){return _t(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},ji=class{constructor(){this.restEncoder=x()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},Mi=class extends ji{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){Be(this.restEncoder,e)}writeString(e){We(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){Qe(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){We(this.restEncoder,JSON.stringify(e))}writeKey(e){We(this.restEncoder,e)}},Ni=class{constructor(){this.restEncoder=x(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){e===0&&b(),w(this.restEncoder,e-1),this.dsCurrVal+=e}},Pi=class extends Ni{constructor(){super(),this.keyMap=/* @__PURE__ */ new Map,this.keyClock=0,this.keyClockEncoder=new rt,this.clientEncoder=new tt,this.leftClockEncoder=new rt,this.rightClockEncoder=new rt,this.infoEncoder=new $e(Be),this.stringEncoder=new it,this.parentInfoEncoder=new $e(Be),this.typeRefEncoder=new tt,this.lenEncoder=new tt}toUint8Array(){let e=x();return w(e,0),T(e,this.keyClockEncoder.toUint8Array()),T(e,this.clientEncoder.toUint8Array()),T(e,this.leftClockEncoder.toUint8Array()),T(e,this.rightClockEncoder.toUint8Array()),T(e,S(this.infoEncoder)),T(e,this.stringEncoder.toUint8Array()),T(e,S(this.parentInfoEncoder)),T(e,this.typeRefEncoder.toUint8Array()),T(e,this.lenEncoder.toUint8Array()),Ge(e,S(this.restEncoder)),S(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Qe(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){Qe(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}};const Fi=(e,t,n,r)=>{r=pe(r,t[0].id.clock);let i=V(t,r);w(e.restEncoder,t.length-i),e.writeClient(n),w(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},Ii=(e,t,n)=>{let r=/* @__PURE__ */ new Map;n.forEach((e,n)=>{B(t,n)>e&&r.set(n,e)}),ua(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),_(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Fi(e,t.clients.get(n),n,r)})},Li=(e,t)=>{let n=j(),r=D(e.restDecoder);for(let i=0;i<r;i++){let r=D(e.restDecoder),i=Array(r),a=e.readClient(),o=D(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new G(z(a,o),t),o+=t;break}case 10:{let t=D(e.restDecoder);i[n]=new J(z(a,o),t),o+=t;break}default:{let s=!(r&192),c=new q(z(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Ss(e,r));i[n]=c,o+=c.length}}}}return n},Ri=(e,t,n)=>{let r=[],i=_(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new la,c=/* @__PURE__ */ new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=/* @__PURE__ */ new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==J){let i=M(d,u.id.client,()=>B(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,B(t,a)),f();else{u=e.refs[e.i++];continue}}else(i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Pi;return Ii(e,s,/* @__PURE__ */ new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},zi=(e,t)=>Ii(e,t.doc.store,t.beforeState),Bi=(e,t,n,r=new Ai(e))=>H(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Li(r,n),o=Ri(e,i,a),s=i.pendingStructs;if(s){for(let[e,n]of s.missing)if(n<B(i,e)){t=!0;break}if(o){for(let[e,t]of o.missing){let n=s.missing.get(e);(n==null||n>t)&&s.missing.set(e,t)}s.update=Aa([s.update,o.update])}}else i.pendingStructs=o;let c=wi(r,e,i);if(i.pendingDs){let t=new Ai(ut(i.pendingDs));D(t.restDecoder);let n=wi(t,e,i);i.pendingDs=c&&n?Aa([c,n]):c||n}else i.pendingDs=c;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Vi(e.doc,t)}},n,!1),Vi=(e,t,n,r=Ai)=>{let i=ut(t);Bi(i,e,n,new r(i))},Hi=(e,t,n)=>Vi(e,t,n,Oi),Ui=(e,t,n=/* @__PURE__ */ new Map)=>{Ii(e,t.store,n),Si(e,xi(t.store))},Wi=(e,t=new Uint8Array([0]),n=new Pi)=>{let r=qi(t);Ui(n,e,r);let i=[n.toUint8Array()];if(e.store.pendingDs&&i.push(e.store.pendingDs),e.store.pendingStructs&&i.push(ja(e.store.pendingStructs.update,t)),i.length>1){if(n.constructor===Mi)return Oa(i.map((e,t)=>t===0?e:Ia(e)));if(n.constructor===Pi)return Aa(i)}return i[0]},Gi=(e,t)=>Wi(e,t,new Mi),Ki=e=>{let t=/* @__PURE__ */ new Map,n=D(e.restDecoder);for(let r=0;r<n;r++){let n=D(e.restDecoder),r=D(e.restDecoder);t.set(n,r)}return t},qi=e=>Ki(new Di(ut(e))),Ji=(e,t)=>(w(e.restEncoder,t.size),_(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),Yi=(e,t)=>Ji(e,ua(t.store)),Xi=(e,t=new Ni)=>(e instanceof Map?Ji(t,e):Yi(t,e),t.toUint8Array()),Zi=e=>Xi(e,new ji);var Qi=class{constructor(){this.l=[]}};const $i=()=>new Qi,ea=(e,t)=>e.l.push(t),ta=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},na=(e,t,n)=>$t(e.l,[t,n]);var ra=class{constructor(e,t){this.client=e,this.clock=t}};const ia=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,z=(e,t)=>new ra(e,t),aa=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw b()};var oa=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new oa(e,t))(bi(),/* @__PURE__ */ new Map);const sa=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!gi(t.ds,e.id),ca=(e,t)=>{let n=M(e.meta,ca,ye),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<B(r,n)&&ma(e,z(n,t))}),mi(e,t.ds,e=>{}),n.add(t))};var la=class{constructor(){this.clients=/* @__PURE__ */ new Map,this.pendingStructs=null,this.pendingDs=null}};const ua=e=>{let t=/* @__PURE__ */ new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},B=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},da=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw b()}n.push(t)},V=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=g(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=g((n+r)/2)}throw b()},fa=(e,t)=>{let n=e.clients.get(t.client);return n[V(n,t.clock)]},pa=(e,t,n)=>{let r=V(t,n),i=t[r];return i.id.clock<n&&i instanceof q?(t.splice(r+1,0,xs(e,i,n-i.id.clock)),r+1):r},ma=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[pa(e,n,t.clock)]},ha=(e,t,n)=>{let r=t.clients.get(n.client),i=V(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==G&&r.splice(i+1,0,xs(e,a,n.clock-a.id.clock+1)),a},ga=(e,t,n)=>{let r=e.clients.get(t.id.client);r[V(r,t.id.clock)]=n},_a=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=pa(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&pa(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)};var va=class{constructor(e,t,n){this.doc=e,this.deleteSet=new pi,this.beforeState=ua(e.store),this.afterState=/* @__PURE__ */ new Map,this.changed=/* @__PURE__ */ new Map,this.changedParentTypes=/* @__PURE__ */ new Map,this._mergeStructs=[],this.origin=t,this.meta=/* @__PURE__ */ new Map,this.local=n,this.subdocsAdded=/* @__PURE__ */ new Set,this.subdocsRemoved=/* @__PURE__ */ new Set,this.subdocsLoaded=/* @__PURE__ */ new Set,this._needFormattingCleanup=!1}};const ya=(e,t)=>t.deleteSet.clients.size===0&&!It(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(_i(t.deleteSet),zi(e,t),Si(e,t.deleteSet),!0),ba=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&M(e.changed,t,ye).add(n)},xa=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof q&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Sa=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=V(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof q&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ca=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=fe(r.length-1,1+V(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+xa(r,e)}})},wa=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{_i(a),n.afterState=ua(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&e.push(()=>{t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),na(r._dEH,t,n)})}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Mo(n)})}),$t(e,[])}finally{r.gc&&Sa(a,i,r.gcFilter),Ca(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=pe(V(e,r),1);for(let t=e.length-1;t>=n;)t-=1+xa(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=V(r,n);a+1<r.length&&xa(r,a+1)>1||a>0&&xa(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(oi(ti,Jr,`[yjs] `,Yr,$r,`Changed the client-id because another client seems to be using it.`),r.clientID=Ti()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Mi;ya(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Pi;ya(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):wa(e,t+1)}}},H=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new va(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&wa(i,0)}}return o};function*Ta(e){let t=D(e.restDecoder);for(let n=0;n<t;n++){let t=D(e.restDecoder),n=e.readClient(),r=D(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=D(e.restDecoder);yield new J(z(n,r),t),r+=t}else if(31&t){let i=!(t&192),a=new q(z(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Ss(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new G(z(n,r),t),r+=t}}}}var Ea=class{constructor(e,t){this.gen=Ta(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===J);return this.curr}},Da=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}};const Oa=e=>Aa(e,Oi,Mi),ka=(e,t)=>{if(e.constructor===G){let{client:n,clock:r}=e.id;return new G(z(n,r+t),e.length-t)}if(e.constructor===J){let{client:n,clock:r}=e.id;return new J(z(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new q(z(r,i+t),null,z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Aa=(e,t=Ai,n=Pi)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(ut(e))),i=r.map(e=>new Ea(e,!0)),a=null,o=new n,s=new Da(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===J?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Na(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock){if(a.struct.constructor===J)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Na(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new J(z(t,a.struct.id.clock+a.struct.length),e),offset:0}}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===J?a.struct.length-=t:n=ka(n,t)),a.struct.mergeWith(n)||(Na(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==J;n=e.next())Na(s,a.struct,a.offset),a={struct:n,offset:0}}a!==null&&(Na(s,a.struct,a.offset),a=null),Pa(s);let c=r.map(e=>Ci(e)),l=vi(c);return Si(o,l),o.toUint8Array()},ja=(e,t,n=Ai,r=Pi)=>{let i=qi(t),a=new r,o=new Da(a),s=new n(ut(e)),c=new Ea(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===J){c.next();continue}if(e.id.clock+e.length>n)for(Na(o,e,pe(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Na(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}Pa(o);let l=Ci(s);return Si(a,l),a.toUint8Array()},Ma=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=x(),e.written=0)},Na=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Ma(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Pa=e=>{Ma(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];w(t,r.written),Ge(t,r.restEncoder)}},Fa=(e,t,n,r)=>{let i=new n(ut(e)),a=new Ea(i,!1),o=new r,s=new Da(o);for(let e=a.curr;e!==null;e=a.next())Na(s,t(e),0);Pa(s);let c=Ci(i);return Si(o,c),o.toUint8Array()},Ia=e=>Fa(e,en,Ai,Mi),La=`You must not compute changes after the event-handler fired.`;var Ra=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=za(this.currentTarget,this.target)}deletes(e){return gi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw v(La);let e=/* @__PURE__ */ new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=be(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=be(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=be(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw v(La);let t=this.target,n=ye(),r=ye(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}};const za=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},U=()=>{si(`Invalid access: Add Yjs type to a document before reading data.`)};let Ba=0;var Va=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Ba++}};const Ha=e=>{e.timestamp=Ba++},Ua=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Ba++},Wa=(e,t,n)=>{if(e.length>=80){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Ua(r,t,n),r}{let r=new Va(t,n);return e.push(r),r}},Ga=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>de(t-e.index)<de(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Ha(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&de(n.index-i)<r.parent.length/80?(Ua(n,r,i),n):Wa(e._searchMarker,r,i)},Ka=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=pe(t,i.index+n))}},qa=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;M(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;na(r._eH,n,t)};var W=class{constructor(){this._item=null,this._map=/* @__PURE__ */ new Map,this._start=null,this.doc=null,this._length=0,this._eH=$i(),this._dEH=$i(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw y()}clone(){throw y()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){ea(this._eH,e)}observeDeep(e){ea(this._dEH,e)}unobserve(e){ta(this._eH,e)}unobserveDeep(e){ta(this._dEH,e)}toJSON(){}};const Ja=(e,t,n)=>{e.doc??U(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},Ya=e=>{e.doc??U();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Xa=(e,t)=>{let n=0,r=e._start;for(e.doc??U();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},Za=(e,t)=>{let n=[];return Xa(e,(r,i)=>{n.push(t(r,i,e))}),n},Qa=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},$a=(e,t)=>{e.doc??U();let n=Ga(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},eo=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new q(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ss(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new q(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Jo(new Uint8Array(n))),i.integrate(e,0);break;case Ei:i=new q(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new $o(n)),i.integrate(e,0);break;default:if(n instanceof W)i=new q(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ys(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},to=()=>v(`Length exceeded!`),no=(e,t,n,r)=>{if(n>t._length)throw to();if(n===0)return t._searchMarker&&Ka(t._searchMarker,n,r.length),eo(e,t,null,r);let i=n,a=Ga(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&ma(e,z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Ka(t._searchMarker,i,r.length),eo(e,t,o,r)},ro=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return eo(e,t,r,n)},io=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Ga(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&ma(e,z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&ma(e,z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw to();t._searchMarker&&Ka(t._searchMarker,i,-a+r)},ao=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},oo=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new ss([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new ss([r]);break;case Uint8Array:s=new Jo(r);break;case Ei:s=new $o(r);break;default:if(r instanceof W)s=new ys(r);else throw Error(`Unexpected content type`)}new q(z(o,B(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},so=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},co=e=>{let t={};return e.doc??U(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},lo=(e,t)=>{e.doc??U();let n=e._map.get(t);return n!==void 0&&!n.deleted},uo=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&sa(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},fo=e=>(e.doc??U(),ui(e._map.entries(),e=>!e[1].deleted));var po=class extends Ra{},mo=class e extends W{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._length}_callObserver(e,t){super._callObserver(e,t),qa(this,e,new po(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{no(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):H(this.doc,t=>{ro(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{io(n,this,e,t)})}get(e){return $a(this,e)}toArray(){return Ya(this)}slice(e=0,t=this.length){return Ja(this,e,t)}toJSON(){return this.map(e=>e instanceof W?e.toJSON():e)}map(e){return Za(this,e)}forEach(e){Xa(this,e)}[Symbol.iterator](){return Qa(this)}_write(e){e.writeTypeRef(fs)}};const ho=e=>new mo;var go=class extends Ra{constructor(e,t,n){super(e,t),this.keysChanged=n}},_o=class e extends W{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?/* @__PURE__ */ new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof W?e.clone():e)}),t}_callObserver(e,t){qa(this,e,new go(this,e,t))}toJSON(){this.doc??U();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof W?r.toJSON():r}}),e}get size(){return[...fo(this)].length}keys(){return di(fo(this),e=>e[0])}values(){return di(fo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return di(fo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??U(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):H(this.doc,t=>{ao(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):H(this.doc,n=>{oo(n,this,e,t)}),t}get(e){return so(this,e)}has(e){return lo(this,e)}clear(){this.doc===null?this._prelimContent.clear():H(this.doc,e=>{this.forEach(function(t,n,r){ao(e,r,n)})})}_write(e){e.writeTypeRef(ps)}};const vo=e=>new _o,yo=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Xt(e,t);var bo=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&b(),this.right.content.constructor){case K:this.right.deleted||wo(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}};const xo=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case K:t.right.deleted||wo(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&ma(e,z(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length)}t.left=t.right,t.right=t.right.right}return t},So=(e,t,n,r)=>{let i=/* @__PURE__ */ new Map,a=r?Ga(t,n):null;if(a){let t=new bo(a.p.left,a.p,a.index,i);return xo(e,t,n-a.index)}{let r=new bo(null,t._start,0,i);return xo(e,r,n)}},Co=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===K&&yo(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new q(z(a,B(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new K(o,r));l.integrate(e,0),n.right=l,n.forward()})},wo=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},To=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===K&&yo(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Eo=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=/* @__PURE__ */ new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!yo(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new q(z(a,B(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new K(s,c)),n.right.integrate(e,0),n.forward()}}return o},Do=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;To(n,i);let s=Eo(e,t,n,i),c=r.constructor===String?new ls(r):r instanceof W?new ys(r):new ts(r),{left:l,right:u,index:d}=n;t._searchMarker&&Ka(t._searchMarker,n.index,c.getLength()),u=new q(z(o,B(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Co(e,t,n,s)},Oo=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;To(n,i);let s=Eo(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===K));){if(!n.right.deleted)switch(n.right.content.constructor){case K:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(yo(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&ma(e,z(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
47
+ `;n.right=new q(z(o,B(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new ls(i)),n.right.integrate(e,0),n.forward()}Co(e,t,n,s)},ko=(e,t,n,r,i)=>{let a=t,o=j();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===K){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case K:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&wo(i,n);break}}}t=t.right}return s},Ao=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=/* @__PURE__ */ new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===K){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},jo=e=>{let t=0;return H(e.doc,n=>{let r=e._start,i=e._start,a=j(),o=Pt(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case K:wo(o,i.content);break;default:t+=ko(n,r,i,a,o),a=Pt(o),r=i}i=i.right}}),t},Mo=e=>{let t=/* @__PURE__ */ new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&_a(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===K&&e.constructor!==G&&t.add(e.parent)})}H(n,n=>{mi(e,e.deleteSet,e=>{if(e instanceof G||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===K?t.add(r):Ao(n,e)});for(let e of t)jo(e)})},No=(e,t,n)=>{let r=n,i=Pt(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case ys:case ts:case ls:n<t.right.length&&ma(e,z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&ko(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Ka(o._searchMarker,t.index,-r+n),t};var Po=class extends Ra{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=/* @__PURE__ */ new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:/* @__PURE__ */ new Set,deleted:/* @__PURE__ */ new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];H(e,e=>{let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},qt(o)||(e.attributes=Ht({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case ys:case ts:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case ls:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case K:{let{key:t,value:s}=i.content;if(this.adds(i)){if(!this.deletes(i)){let c=n.get(t)??null;yo(c,s)?s!==null&&i.delete(e):(a===`retain`&&u(),yo(s,r.get(t)??null)?delete o[t]:o[t]=s)}}else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;yo(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(yo(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),wo(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Fo=class e extends W{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??U(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new Po(this,e,t);qa(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??U();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===ls&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):H(this.doc,n=>{let r=new bo(null,this._start,0,/* @__PURE__ */ new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
48
+ `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Do(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&No(n,r,a.delete):Oo(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??U();let r=[],i=/* @__PURE__ */ new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(sa(s,e)||t!==void 0&&sa(s,t))switch(s.content.constructor){case ls:{let r=i.get(`ychange`);e!==void 0&&!sa(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!sa(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case ys:case ts:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case K:sa(s,e)&&(c(),wo(i,s.content))}s=s.right}c()};return e||t?H(a,n=>{e&&ca(n,e),t&&ca(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):H(r,r=>{let i=So(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Do(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):H(r,r=>{let i=So(r,this,e,!n);Do(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):H(n,n=>{No(n,So(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):H(r,r=>{let i=So(r,this,e,!1);i.right!==null&&Oo(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):H(this.doc,t=>{ao(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):H(this.doc,n=>{oo(n,this,e,t)})}getAttribute(e){return so(this,e)}getAttributes(){return co(this)}_write(e){e.writeTypeRef(ms)}};const Io=e=>new Fo;var Lo=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??U()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Bo||t.constructor===Ro)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Ro=class e extends W{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}get length(){return this.doc??U(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Lo(this,e)}querySelector(e){e=e.toUpperCase();let t=new Lo(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),_(new Lo(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){qa(this,e,new Ho(this,t,e))}toString(){return Za(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Xa(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):H(this.doc,n=>{no(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)H(this.doc,n=>{let r=e&&e instanceof W?e._item:e;eo(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw v(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):H(this.doc,n=>{io(n,this,e,t)})}toArray(){return Ya(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return $a(this,e)}slice(e=0,t=this.length){return Ja(this,e,t)}forEach(e){Xa(this,e)}_write(e){e.writeTypeRef(gs)}};const zo=e=>new Ro;var Bo=class e extends Ro{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=/* @__PURE__ */ new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return Wt(n,(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof W?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):H(this.doc,t=>{ao(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):H(this.doc,n=>{oo(n,this,e,t)})}getAttribute(e){return so(this,e)}hasAttribute(e){return lo(this,e)}getAttributes(e){return e?uo(this,e):co(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Xa(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(hs),e.writeKey(this.nodeName)}};const Vo=e=>new Bo(e.readKey());var Ho=class extends Ra{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=/* @__PURE__ */ new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},Uo=class e extends _o{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(_s),e.writeKey(this.hookName)}};const Wo=e=>new Uo(e.readKey());var Go=class e extends Fo{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(vs)}};const Ko=e=>new Go;var qo=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw y()}mergeWith(e){return!1}write(e,t,n){throw y()}integrate(e,t){throw y()}},G=class extends qo{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),da(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}},Jo=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw y()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}};const Yo=e=>new Jo(e.readBuf());var Xo=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){yi(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}};const Zo=e=>new Xo(e.readLen()),Qo=(e,t)=>new Ei({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});var $o=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Qo(this.doc.guid,this.opts))}splice(e){throw y()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}};const es=e=>new $o(Qo(e.readString(),e.readAny()));var ts=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw y()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}};const ns=e=>new ts(e.readJSON());var K=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw y()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}};const rs=e=>new K(e.readKey(),e.readJSON());var is=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}};const as=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new is(n)},os=yn(`node_env`)===`development`;var ss=class e{constructor(e){this.arr=e,os&&Qt(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}};const cs=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new ss(n)};var ls=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}};const us=e=>new ls(e.readString()),ds=[ho,vo,Io,Vo,zo,Wo,Ko],fs=0,ps=1,ms=2,hs=3,gs=4,_s=5,vs=6;var ys=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw y()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=/* @__PURE__ */ new Map}write(e,t){this.type._write(e)}getRef(){return 7}};const bs=e=>new ys(ds[e.readTypeRef()](e)),xs=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new q(z(r,i+n),t,z(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=z(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a};var q=class e extends qo{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=B(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=B(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ra&&this.id.client!==this.parent.client&&this.parent.clock>=B(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=ha(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=ma(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===G||this.right&&this.right.constructor===G)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ra){let e=fa(n,this.parent);this.parent=e.constructor===G?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ha(e,e.doc.store,z(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),ia(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ia(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(fa(e.doc.store,n.origin)))r.has(fa(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),da(e.doc.store,this),this.content.integrate(e,this),ba(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new G(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ia(e.origin,this.lastId)&&this.right===e&&ia(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),yi(e.deleteSet,this.id.client,this.id.clock,this.length),ba(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw b();this.content.gc(e),t?ga(e,this,new G(this.id,this.length)):this.content=new Xo(this.length)}write(e,t){let n=t>0?z(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=aa(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===ra?(e.writeParentInfo(!1),e.writeLeftID(t)):b();i!==null&&e.writeString(i)}this.content.write(e,t)}};const Ss=(e,t)=>Cs[t&31](e),Cs=[()=>{b()},Zo,as,Yo,us,ns,rs,bs,cs,es,()=>{b()}];var J=class extends qo{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){b()}write(e,t){e.writeInfo(10),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}};const ws=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Ts=`__ $YJS$ __`;ws[Ts]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),ws[Ts]=!0;var Es=class extends Rt{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=/* @__PURE__ */ new Map,this.meta=/* @__PURE__ */ new Map,this._checkInterval=setInterval(()=>{let e=A();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Ds(this,t,`timeout`)},g(3e3)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:A()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),tn(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}};const Ds=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:A()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},Os=(e,t,n=e.states)=>{let r=t.length,i=x();w(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;w(i,r),w(i,s),We(i,JSON.stringify(o))}return S(i)},ks=(e,t,n)=>{let r=ut(t),i=A(),a=[],o=[],s=[],c=[],l=D(r);for(let t=0;t<l;t++){let t=D(r),n=D(r),l=JSON.parse(O(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(tn(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},As=/* @__PURE__ */ new Map;
49
+ /* c8 ignore start */
50
+ var js=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:An(t.newValue||``)}),fn(this._onChange)}postMessage(e){dn.setItem(this.room,kn(wn(e)))}close(){pn(this._onChange)}};
51
+ /* c8 ignore stop */
52
+ /* c8 ignore next */
53
+ const Ms=typeof BroadcastChannel>`u`?js:BroadcastChannel,Ns=e=>M(As,e,()=>{let t=ye(),n=new Ms(e);return n.onmessage=e=>t.forEach(t=>t(e.data,`broadcastchannel`)),{bc:n,subs:t}}),Ps=(e,t)=>(Ns(e).subs.add(t),t),Fs=(e,t)=>{let n=Ns(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),As.delete(e)),r},Is=(e,t,n=null)=>{let r=Ns(e);r.bc.postMessage(t),r.subs.forEach(e=>e(t,n))},Ls=(e,t)=>{w(e,0);let n=Zi(t);T(e,n)},Rs=(e,t,n)=>{w(e,1),T(e,Gi(t,n))},zs=(e,t,n)=>Rs(t,n,E(e)),Bs=(e,t,n,r)=>{try{Hi(t,E(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Vs=(e,t)=>{w(e,2),T(e,t)},Hs=Bs,Us=(e,t,n,r,i)=>{let a=D(e);switch(a){case 0:zs(e,t,n);break;case 1:Bs(e,n,r,i);break;case 2:Hs(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Ws=(e,t,n)=>{D(e)===0&&n(t,O(e))},Gs=e=>Gt(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join(`&`),Ks=[];Ks[0]=(e,t,n,r,i)=>{w(e,0);let a=Us(t,e,n.doc,n);r&&a===1&&!n.synced&&(n.synced=!0)},Ks[3]=(e,t,n,r,i)=>{w(e,1),T(e,Os(n.awareness,Array.from(n.awareness.getStates().keys())))},Ks[1]=(e,t,n,r,i)=>{ks(n.awareness,E(t),n)},Ks[2]=(e,t,n,r,i)=>{Ws(t,n.doc,(e,t)=>Js(n,t))};const qs=3e4,Js=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),Ys=(e,t,n)=>{let r=ut(t),i=x(),a=D(r),o=e.messageHandlers[a];return o?o(i,r,e,n,a):console.error(`Unable to compute message`),i},Xs=e=>!(e.code>=4400&&e.code<4500),Zs=(e,t,n)=>{if(t!==null&&t===e.ws){e.emit(`connection-close`,[n,e]),e.ws=null,t.onmessage=null,t.onopen=null,t.onclose=null,t.onerror=()=>{},t.close(),e.wsconnecting=!1,e.wsconnected&&(e.wsconnected=!1,e.synced=!1,Ds(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit(`status`,[{status:`disconnected`}])),e.wsUnsuccessfulReconnects++;let r=null;n!=null&&!e.shouldReconnect(n,e)&&(e.shouldConnect=!1,r={code:n.code,reason:n.reason}),setTimeout(Qs,fe(me(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e),r!==null&&e.emit(`closed`,[r,e])}},Qs=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType=`arraybuffer`,e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{if(e.ws!==t)return;e.wsLastMessageReceived=A();let r=Ys(e,new Uint8Array(n.data),!0);Re(r)>1&&t.send(S(r))},t.onerror=n=>{e.ws===t&&e.emit(`connection-error`,[n,e])},t.onclose=n=>{Zs(e,t,n)},t.onopen=()=>{if(e.ws!==t)return;e.wsLastMessageReceived=A(),e.wsconnecting=!1,e.wsconnected=!0,e.emit(`status`,[{status:`connected`}]);let n=x();if(w(n,0),Ls(n,e.doc),t.send(S(n)),e.awareness.getLocalState()!==null){let n=x();w(n,1),T(n,Os(e.awareness,[e.doc.clientID])),t.send(S(n))}},e.emit(`status`,[{status:`connecting`}])}},$s=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&Is(e.bcChannel,t,e)};var ec=class extends Lt{constructor(e,t,n,{connect:r=!0,awareness:i=new Es(n),params:a={},protocols:o=[],WebSocketPolyfill:s=WebSocket,resyncInterval:c=-1,maxBackoffTime:l=2500,disableBc:u=!1,shouldReconnect:d=Xs}={}){for(super();e[e.length-1]===`/`;)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+`/`+t,this.maxBackoffTime=l,this.shouldReconnect=d,this.params=a,this.protocols=o,this.roomname=t,this.doc=n,this._WS=s,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Ks.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=x();w(e,0),Ls(e,n),this.ws.send(S(e))}},c)),this._bcSubscriber=(e,t)=>{if(t!==this){let t=Ys(this,new Uint8Array(e),!1);Re(t)>1&&Is(this.bcChannel,S(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){let t=x();w(t,0),Vs(t,e),$s(this,S(t))}},this.doc.on(`update`,this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{let a=e.concat(t).concat(n),o=x();w(o,1),T(o,Os(i,a)),$s(this,S(o))},this._exitHandler=()=>{Ds(this.awareness,[n.clientID],`app closed`)},mn&&typeof process<`u`&&process.on(`exit`,this._exitHandler),i.on(`update`,this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&qs<A()-this.wsLastMessageReceived&&Zs(this,this.ws,null)},qs/10),r&&this.connect()}get url(){let e=Gs(this.params);return this.serverUrl+`/`+this.roomname+(e.length===0?``:`?`+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,e&&(this.wsUnsuccessfulReconnects=0),this.emit(`synced`,[e]),this.emit(`sync`,[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),mn&&typeof process<`u`&&process.off(`exit`,this._exitHandler),this.awareness.off(`update`,this._awarenessUpdateHandler),this.doc.off(`update`,this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||=(Ps(this.bcChannel,this._bcSubscriber),!0);let e=x();w(e,0),Ls(e,this.doc),Is(this.bcChannel,S(e),this);let t=x();w(t,0),Rs(t,this.doc),Is(this.bcChannel,S(t),this);let n=x();w(n,3),Is(this.bcChannel,S(n),this);let r=x();w(r,1),T(r,Os(this.awareness,[this.doc.clientID])),Is(this.bcChannel,S(r),this)}disconnectBc(){let e=x();w(e,1),T(e,Os(this.awareness,[this.doc.clientID],/* @__PURE__ */ new Map)),$s(this,S(e)),this.bcconnected&&=(Fs(this.bcChannel,this._bcSubscriber),!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&Zs(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Qs(this),this.connectBc())}};function tc(t,n,r={}){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=[],s=`connecting`,c=!1,l,u,d=()=>{for(let e of i)e()},f=()=>`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e(`/api/_vitehub/realtime/${encodeURIComponent(t)}`,r.baseURL)}`,p=n.split(`/`).map(encodeURIComponent).join(`/`),ee={};function te(){l=new Ei,u=new ec(f(),p,l,{disableBc:!0,params:{}});let e=u;e.messageHandlers[5]=(t,n)=>{let r=At(n);if(r){if(r.type===`session`){e.params.epoch=r.epoch;return}e.destroy(),l.destroy(),c||te()}},e.awareness.off(`update`,e._awarenessUpdateHandler),e.awareness.on(`update`,({added:t,removed:n,updated:r})=>{let i=[...t,...r,...n].filter(t=>t===e.doc.clientID),a=e.ws;if(!i.length||!e.wsconnected||!a||a.readyState!==a.OPEN)return;let o=x();w(o,1),T(o,Os(e.awareness,i)),a.send(S(o))});let t=r.identity??{id:`guest:${l.clientID}`};e.awareness.setLocalState({...ee,user:Dt({...t,id:t.id||`guest:${l.clientID}`})}),e.awareness.on(`change`,d),e.on(`status`,e=>{s=e.status,d()})}te();let m;r.changes&&(m=new ec(f(),`%40workspace`,new Ei,{disableBc:!0,params:{workspace:`events`}}),m.awareness.setLocalState(null),m.messageHandlers[4]=(e,t)=>{let n=Mt(t);if(n)for(let e of a)e(n)},m.on(`status`,e=>{e.status===`connected`&&ne()}));function ne(){let e=m?.ws;if(m?.wsconnected&&e&&e.readyState===e.OPEN)for(;o.length;)e.send(Uint8Array.from(Nt(o.shift())))}return{get awareness(){return u.awareness},get clientId(){return l.clientID},people:()=>kt(u.awareness.getStates()),states:()=>{let e=new Map(u.awareness.getStates());return e.delete(l.clientID),e},status:()=>s,setLocal(e,t){t===null?delete ee[e]:ee[e]=t,u.awareness.setLocalStateField(e,t)},notify(e){m&&(o.push(e),ne())},onUpdate(e){return i.add(e),()=>i.delete(e)},onChange(e){return a.add(e),()=>a.delete(e)},destroy(){c=!0,u.destroy(),l.destroy(),m?.destroy(),m?.doc.destroy(),i.clear(),a.clear()}}}const nc=`data-content-field`;function rc(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,e=>`\\${e}`)}function ic(e,t){return`[${e}="${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"]`}function ac(e){let t=[],n=e;for(;n&&n!==document.documentElement&&t.length<10;){if(n.id)return t.unshift(`#${rc(n.id)}`),t.join(` > `);let e=n.getAttribute(nc);if(e)return t.unshift(ic(nc,e)),t.join(` > `);let r=n.tagName.toLowerCase(),i=n.parentElement;if(!i){t.unshift(r);break}let a=[...i.children].filter(e=>e.tagName===n.tagName);t.unshift(a.length>1?`${r}:nth-of-type(${a.indexOf(n)+1})`:r),n=i}return t.join(` > `)}function oc(e){let t=(e.textContent??``).replace(/\s+/g,` `).trim().slice(0,40),n=e.tagName.toLowerCase();return t?`${n} ${t}`:n}function sc(e,t){return t?Math.min(1e3,Math.max(0,Math.round(e/t*1e3))):0}function cc(){return Math.max(document.documentElement.scrollWidth,document.documentElement.clientWidth,1)}function lc(e){return e.closest(`[data-content-field]`)??void 0}function uc(e,t,n){let r=e.getBoundingClientRect(),i=lc(e)?.getAttribute(`data-content-field`)??void 0;return{...i?{field:i}:{},selector:ac(e),label:oc(e),x:sc(t-r.left,r.width),y:sc(n-r.top,r.height),page:{x:sc(t+window.scrollX,cc()),y:Math.max(0,Math.round(n+window.scrollY))},viewport:{width:window.innerWidth}}}function dc(e){try{return document.querySelector(e)??void 0}catch{return}}function fc(e,t){return oc(e)===t}function pc(e){let t=e.split(` `,1)[0];if(t&&t!==e)try{for(let n of document.querySelectorAll(t))if(fc(n,e))return n}catch{}}function mc(e){let t;if(e.field){t=dc(ic(nc,e.field));let n=dc(e.selector);t&&n&&lc(n)?.getAttribute(`data-content-field`)===e.field&&(t=n)}if(!t){let n=dc(e.selector);n&&fc(n,e.label)&&(t=n)}if(t??=pc(e.label),t){let n=t.getBoundingClientRect();return!n.width&&!n.height?{state:`hidden`,element:t}:{state:`exact`,element:t,x:n.left+e.x/1e3*n.width,y:n.top+e.y/1e3*n.height}}return{state:`moved`,x:e.page.x/1e3*cc()-window.scrollX,y:e.page.y-window.scrollY}}const hc=`/api/_vitehub/comments`;function gc(e){let t=new URL(e).pathname,n=t.lastIndexOf(`${hc}/assets/`);return n===-1?hc:`${t.slice(0,n)}${hc}`}function _c(e){let t=e.split(/[?#]/,1)[0]??``;return t.startsWith(`/`)||(t=`/${t}`),t=t.replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`/`}function vc(e){let t=2166136261,n=1523705862;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2671213388)>>>0}return`pages/${t.toString(16).padStart(8,`0`)}${n.toString(16).padStart(8,`0`)}`}const yc=`vitehub-comments-guest`,bc=gc(import.meta.url);function xc(){try{let e=JSON.parse(localStorage.getItem(yc)??`null`);if(e&&typeof e==`object`&&`id`in e&&`name`in e&&typeof e.id==`string`&&typeof e.name==`string`)return{id:e.id,name:e.name}}catch{}}function Sc(e){let t={id:xc()?.id??crypto.randomUUID(),name:e};return localStorage.setItem(yc,JSON.stringify(t)),t}async function Y(e,t={}){let n=new Headers(t.headers);t.body&&n.set(`content-type`,`application/json`);let r=xc();r&&(n.set(`x-vitehub-comments-guest-id`,r.id),n.set(`x-vitehub-comments-guest-name`,encodeURIComponent(r.name)));let i;try{i=await fetch(`${bc}${e}`,{...t,headers:n,credentials:`same-origin`})}catch{return[{code:`COMMENTS_OFFLINE`,why:`The server cannot be reached.`},void 0]}let a=await i.json().catch(()=>void 0);if(a&&typeof a==`object`){if(`error`in a&&a.error&&typeof a.error==`object`)return[a.error,void 0];if(`data`in a)return[void 0,a.data]}return[{code:`COMMENTS_FAILED`,why:`The server answered ${i.status}.`},void 0]}const Cc=e=>({method:`POST`,body:JSON.stringify(e)}),X={session:()=>Y(`/session`),threads:e=>Y(`/threads?page=${encodeURIComponent(e)}`),create:e=>Y(`/threads`,Cc(e)),reply:(e,t)=>Y(`/threads/${encodeURIComponent(e)}/comments`,Cc(t)),resolve:e=>Y(`/threads/${encodeURIComponent(e)}/resolve`,{method:`POST`}),reopen:e=>Y(`/threads/${encodeURIComponent(e)}/reopen`,{method:`POST`}),remove:e=>Y(`/threads/${encodeURIComponent(e)}`,{method:`DELETE`}),removeComment:(e,t)=>Y(`/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`,{method:`DELETE`}),people:e=>Y(`/people?q=${encodeURIComponent(e)}`),field:e=>Y(`/fields?field=${encodeURIComponent(e)}`),saveField:e=>Y(`/fields`,Cc(e))};function wc(e){return typeof e==`string`&&e?e:void 0}function Tc(e){let t=wc(e?.__name)??wc(e?.name);return t?{name:t}:void 0}function Ec(){let e=[];for(let t of document.querySelectorAll(`[data-v-app], #__nuxt, #app`))t._vnode&&e.push(t);return e}function Dc(e){let t=/* @__PURE__ */ new Map,n=(e,r,i)=>{if(!e||typeof e!=`object`||i>4e3)return;let a=e;if(a.component){let e=Tc(a.component.type);n(a.component.subTree,e?[...r,e]:r,i+1);return}if(a.el&&!t.has(a.el)&&t.set(a.el,r),a.suspense?.activeBranch&&n(a.suspense.activeBranch,r,i+1),Array.isArray(a.children))for(let e of a.children)n(e,r,i+1)};for(let e of Ec())n(e._vnode,[],0);for(let n=e;n;n=n.parentElement){let e=t.get(n);if(e)return e.slice(-12)}return[]}function Oc(){for(let e of Ec()){let t=e.__vue_app__?.config?.globalProperties?.$router?.currentRoute?.value?.matched,n=t?.length?wc(t.at(-1)?.path):void 0;if(n)return n}}const kc={button:`button`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,img:`img`,nav:`navigation`,textarea:`textbox`};function Ac(e,t){if(t===`a`)return e.hasAttribute(`href`)?`link`:void 0;if(t===`select`)return e.hasAttribute(`multiple`)||Number(e.getAttribute(`size`))>1?`listbox`:`combobox`;if(t===`input`){let t=e.getAttribute(`type`)?.toLowerCase()??`text`;switch(t){case`checkbox`:return`checkbox`;case`radio`:return`radio`;case`button`:case`submit`:case`reset`:case`image`:return`button`;case`range`:return`slider`;case`number`:return`spinbutton`;case`hidden`:case`password`:case`file`:case`color`:case`date`:case`datetime-local`:case`month`:case`time`:case`week`:return;default:{let n=e.getAttribute(`list`);return n&&e.ownerDocument.getElementById(n)?.localName===`datalist`?`combobox`:t===`search`?`searchbox`:`textbox`}}}return Object.hasOwn(kc,t)?kc[t]:void 0}function jc(e){let t=e.tagName.toLowerCase(),n={tag:t};e.id&&(n.id=e.id.slice(0,128));let r=e.closest(`[data-testid], [data-test], [data-cy]`),i=r?.getAttribute(`data-testid`)??r?.getAttribute(`data-test`)??r?.getAttribute(`data-cy`);i&&(n.testId=i.slice(0,128));let a=e.getAttribute(`role`)??Ac(e,t);a&&(n.role=a.slice(0,64));let o=e.getAttribute(`aria-label`)??e.getAttribute(`alt`)??e.getAttribute(`title`)??e.textContent?.replace(/\s+/g,` `).trim();o&&(n.name=o.slice(0,120));let s=[...e.classList].slice(0,8).map(e=>e.slice(0,64));return s.length&&(n.classes=s),n}function Mc(e){let t=new URL(location.href),n={url:`${t.origin}${t.pathname}`.slice(0,2048),environment:{viewport:{width:innerWidth,height:innerHeight},devicePixelRatio,userAgent:navigator.userAgent.slice(0,512),language:navigator.language,colorScheme:matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}};document.title&&(n.title=document.title.slice(0,256));let r=Oc();if(r&&(n.route=r.slice(0,256)),e){n.element=jc(e);let t=Dc(e);t.length&&(n.components=t)}return n}const Nc=`
54
+ :host { all: initial; }
55
+ * { box-sizing: border-box; }
56
+ .root, .bar {
57
+ --surface: #fff; --surface-inset: #f4f4f5; --hover: rgb(0 0 0 / .05); --text: #18181b; --body: #3f3f46; --muted: #71717a;
58
+ --ring: rgb(0 0 0 / .08); --divider: rgb(0 0 0 / .06); --accent: #2563eb; --on-accent: #fff; --accent-soft: rgb(37 99 235 / .1);
59
+ --accent-text: #1d4ed8; --danger: #dc2626;
60
+ --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px -6px rgb(0 0 0 / .16);
61
+ --ease-out: cubic-bezier(.23, 1, .32, 1);
62
+ font: 13px/1.5 var(--font, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif); color: var(--text);
63
+ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
64
+ }
65
+ .root { position: fixed; inset: 0; pointer-events: none; z-index: 2147482999; }
66
+ .root[data-theme="dark"], .bar[data-theme="dark"] {
67
+ --surface: #1c1c1f; --surface-inset: #121214; --hover: rgb(255 255 255 / .06); --text: #fafafa; --body: #e4e4e7; --muted: #a1a1aa;
68
+ --ring: rgb(255 255 255 / .1); --divider: rgb(255 255 255 / .07); --accent-soft: rgb(96 165 250 / .14); --accent-text: #93c5fd; --danger: #f87171;
69
+ --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -8px rgb(0 0 0 / .6);
70
+ }
71
+ .root * { pointer-events: auto; }
72
+ .layer { position: fixed; inset: 0; pointer-events: none; }
73
+ .layer * { pointer-events: none; }
74
+ button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; transition: background-color 120ms ease, color 120ms ease, transform 120ms ease; }
75
+ button:active:not(:disabled) { transform: scale(.96); }
76
+ button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
77
+ textarea:focus-visible, input:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
78
+ .icon svg, .tool svg { flex: none; }
79
+
80
+ .toolbar { display: flex; align-items: center; gap: 2px; }
81
+ .tool { height: 32px; min-width: 32px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--body); font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
82
+ .tool:hover { background: var(--hover); color: var(--text); }
83
+ .tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
84
+ kbd { font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); padding: 3px 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--ring); }
85
+ .tool[aria-pressed="true"] kbd { color: inherit; }
86
+ .sep { width: 1px; height: 16px; background: var(--divider); margin: 0 4px; }
87
+ .people { display: flex; padding: 0 6px 0 4px; }
88
+ .people .avatar { width: 24px; height: 24px; margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
89
+ .people .avatar:first-child { margin-left: 0; }
90
+ .avatar { width: 24px; height: 24px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: #18181b; overflow: hidden; }
91
+ .avatar img { width: 100%; height: 100%; object-fit: cover; outline: 1px solid rgb(0 0 0 / .1); outline-offset: -1px; border-radius: 50%; }
92
+ .tool img.me { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
93
+
94
+ .pin { position: fixed; transform: translate(-50%, -50%); }
95
+ .layer .pin, .layer .pin * { pointer-events: auto; }
96
+ .pin-button { position: relative; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #18181b; box-shadow: 0 0 0 2px #fff, 0 2px 8px rgb(0 0 0 / .25); transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease; }
97
+ .pin-button::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
98
+ @media (hover: hover) and (pointer: fine) { .pin-button:hover { transform: scale(1.08); } }
99
+ .pin[data-open="true"] .pin-button { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent), 0 2px 8px rgb(0 0 0 / .25); }
100
+ .pin[data-state="resolved"] .pin-button { background: #e4e4e7 !important; color: #52525b; opacity: .85; }
101
+ .pin[data-state="draft"] .pin-button { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent), 0 2px 8px rgb(0 0 0 / .25); }
102
+ .pin[data-state="moved"] .pin-button { box-shadow: 0 0 0 2px #fff, 0 2px 8px rgb(0 0 0 / .25); outline: 2px dashed #f59e0b; outline-offset: 3px; }
103
+
104
+ .card { position: fixed; width: 320px; max-height: min(480px, calc(100vh - 32px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; transform-origin: top left; }
105
+ .card-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0 14px; color: var(--muted); font-size: 12px; }
106
+ .card-head .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
107
+ .icon { position: relative; width: 28px; height: 28px; flex: none; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
108
+ .icon:hover { background: var(--hover); color: var(--text); }
109
+ .icon.danger:hover { color: var(--danger); }
110
+ .messages { overflow: auto; padding: 4px 0 8px; overscroll-behavior: contain; }
111
+ .message { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; padding: 8px 14px; }
112
+ .message-head { display: flex; align-items: center; gap: 6px; min-height: 24px; }
113
+ .message-head .name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
114
+ .message-head .time { color: var(--muted); font-size: 12px; flex: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
115
+ .message-head .icon { width: 24px; height: 24px; margin: -2px -4px -2px 0; opacity: 0; }
116
+ .message:hover .message-head .icon, .message:focus-within .message-head .icon { opacity: 1; }
117
+ .body { grid-column: 2; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--body); text-wrap: pretty; }
118
+ .mention { color: var(--accent-text); font-weight: 500; }
119
+ .compose { padding: 8px; display: flex; flex-direction: column; gap: 6px; position: relative; border-top: 1px solid var(--divider); }
120
+ .card[data-card="new"] .compose { border-top: 0; }
121
+ textarea, input { width: 100%; font: inherit; color: var(--text); background: var(--surface-inset); border: 0; border-radius: 6px; padding: 8px 10px; resize: none; box-shadow: inset 0 0 0 1px var(--ring); }
122
+ textarea::placeholder, input::placeholder { color: var(--muted); }
123
+ textarea { min-height: 38px; max-height: 160px; field-sizing: content; }
124
+ @media (pointer: coarse) { textarea, input { font-size: 16px; } }
125
+ .row { display: flex; justify-content: flex-end; gap: 6px; align-items: center; padding-left: 2px; }
126
+ .row .hint { flex: 1; color: var(--muted); font-size: 12px; }
127
+ .primary { height: 28px; padding: 0 12px; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-weight: 500; }
128
+ .primary:hover:not(:disabled) { background: #1d4ed8; }
129
+ .primary:disabled { background: var(--surface-inset); color: var(--muted); box-shadow: inset 0 0 0 1px var(--ring); cursor: default; }
130
+ .secondary { height: 28px; padding: 0 10px; border-radius: 6px; color: var(--body); font-weight: 500; }
131
+ .secondary:hover { background: var(--hover); color: var(--text); }
132
+ .suggest { position: absolute; left: 8px; right: 8px; bottom: calc(100% - 4px); background: var(--surface); border-radius: 10px; padding: 4px; box-shadow: var(--shadow); }
133
+ .suggest button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 4px 8px 4px 4px; border-radius: 6px; }
134
+ .suggest .avatar { width: 20px; height: 20px; font-size: 9px; }
135
+ .suggest button[aria-selected="true"], .suggest button:hover { background: var(--hover); }
136
+
137
+ .panel { position: fixed; top: 16px; right: 16px; bottom: 72px; width: 340px; display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; transform-origin: right center; }
138
+ .panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 10px 16px; border-bottom: 1px solid var(--divider); }
139
+ .panel-head .title { flex: 1; min-width: 0; }
140
+ .panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
141
+ .panel-head .page { color: var(--muted); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
142
+ .switch { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 6px; color: var(--body); font-size: 12px; font-weight: 500; }
143
+ .switch:hover { background: var(--hover); }
144
+ .switch .track { width: 26px; height: 16px; border-radius: 999px; background: var(--ring); position: relative; transition: background-color 120ms ease; }
145
+ .switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform 160ms var(--ease-out); }
146
+ .switch[aria-checked="true"] .track { background: var(--accent); }
147
+ .switch[aria-checked="true"] .track::after { transform: translateX(10px); }
148
+ .panel-list { overflow: auto; flex: 1; padding: 6px; overscroll-behavior: contain; }
149
+ .panel-item { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; width: 100%; text-align: left; padding: 10px; border-radius: 8px; }
150
+ .panel-item:hover { background: var(--hover); }
151
+ .panel-item[aria-current="true"] { background: var(--accent-soft); }
152
+ .panel-item .top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
153
+ .panel-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
154
+ .panel-item .time { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
155
+ .panel-item .excerpt { grid-column: 2; color: var(--body); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
156
+ .panel-item .meta { grid-column: 2; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
157
+ .panel-item[data-state="resolved"] .avatar, .panel-item[data-state="resolved"] .excerpt { opacity: .6; }
158
+ .empty { display: grid; justify-items: center; gap: 4px; padding: 40px 24px; color: var(--muted); text-align: center; text-wrap: balance; }
159
+ .empty strong { color: var(--text); font-weight: 600; }
160
+
161
+ .cursor { position: fixed; transform: translate(-2px, -2px); transition: left 80ms linear, top 80ms linear; }
162
+ .cursor svg { display: block; filter: drop-shadow(0 1px 1px rgb(0 0 0 / .25)); }
163
+ .cursor span { display: inline-block; margin: 2px 0 0 12px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: #18181b; white-space: nowrap; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
164
+
165
+ .outline { position: fixed; border: 2px solid var(--accent); border-radius: 4px; }
166
+ .outline[data-kind="draft"] { border-style: dashed; border-color: #f59e0b; }
167
+ .tag { position: fixed; transform: translateY(-100%); padding: 2px 6px; border-radius: 4px 4px 0 0; background: #f59e0b; color: #18181b; font-size: 11px; font-weight: 600; }
168
+ .outline[data-kind="hover"] + .tag { background: var(--accent); color: var(--on-accent); }
169
+
170
+ .toast { position: fixed; left: 50%; bottom: 68px; translate: -50% 0; max-width: min(520px, calc(100vw - 32px)); padding: 8px 8px 8px 14px; background: var(--surface); color: var(--body); border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; text-wrap: pretty; }
171
+ .toast[data-kind="error"] { box-shadow: 0 0 0 1px rgb(220 38 38 / .35), 0 8px 24px -6px rgb(0 0 0 / .16); }
172
+ .toast a { color: var(--accent-text); font-weight: 500; white-space: nowrap; text-underline-offset: 3px; }
173
+ .toast > span { padding: 4px 0; }
174
+
175
+ @keyframes enter { from { opacity: 0; transform: translateY(4px) scale(.97); } }
176
+ @keyframes enter-panel { from { opacity: 0; transform: translateX(8px); } }
177
+ @keyframes fade { from { opacity: 0; } }
178
+ .card:not([data-static]), .toast:not([data-static]) { animation: enter 180ms var(--ease-out); }
179
+ .panel:not([data-static]) { animation: enter-panel 200ms var(--ease-out); }
180
+ @media (prefers-reduced-motion: reduce) {
181
+ .card:not([data-static]), .toast:not([data-static]), .panel:not([data-static]) { animation: fade 120ms ease-out; }
182
+ button, .pin-button, .switch .track::after { transition: none; }
183
+ button:active:not(:disabled) { transform: none; }
184
+ .cursor { transition: none; }
185
+ }
186
+ `;function Pc(){return`${gc(import.meta.url).slice(0,-22)}/_vitehub/content`}function Z(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!==void 0&&n!==!1&&n!==null&&(e.startsWith(`on`)&&n instanceof Function?r.addEventListener(e.slice(2).toLowerCase(),n):e===`className`?r.className=String(n):r.setAttribute(e,n===!0?``:String(n)));for(let e of n)e&&r.append(e);return r}function Fc(...e){return e.filter(e=>!!e)}const Q=e=>{let t=document.createElement(`template`);return t.innerHTML=`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,t.content.firstChild},$={comment:()=>Q(`<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>`),edit:()=>Q(`<path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/>`),list:()=>Q(`<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>`),close:()=>Q(`<path d="M18 6 6 18M6 6l12 12"/>`),check:()=>Q(`<path d="M20 6 9 17l-5-5"/>`),reopen:()=>Q(`<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>`),trash:()=>Q(`<path d="M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"/>`)};function Ic(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``)||`?`}function Lc(e){let t=[`#fb7185`,`#fbbf24`,`#34d399`,`#22d3ee`,`#60a5fa`,`#a78bfa`,`#f472b6`],n=0;for(let t=0;t<e.length;t++)n=Math.imul(31,n)+e.charCodeAt(t)|0;return t[Math.abs(n)%t.length]}function Rc(e){return Z(`span`,{className:`avatar`,style:`background:${Lc(e.id)}`,"aria-hidden":`true`},e.image?Z(`img`,{src:e.image,alt:``}):Ic(e.name))}function zc(){let e=document.documentElement;if(e.classList.contains(`dark`))return!0;if(e.classList.contains(`light`))return!1;if(e.dataset.theme===`dark`)return!0;if(e.dataset.theme===`light`)return!1;let t=getComputedStyle(e).colorScheme;return t===`dark`||t!==`light`&&matchMedia(`(prefers-color-scheme: dark)`).matches}function Bc(e){let t=Math.round((Date.now()-Date.parse(e))/1e3);return t<60?`now`:t<3600?`${Math.floor(t/60)} min`:t<86400?`${Math.floor(t/3600)} h`:new Date(e).toLocaleDateString()}function Vc(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))}function Hc(e,t){let n=/* @__PURE__ */ new Set;return t.filter(t=>e.includes(`@${t.name}`)&&!n.has(t.id)&&n.add(t.id))}function Uc(e,t){let n=Z(`div`,{className:`body`});if(!t.length)return n.textContent=e,n;let r=t.map(e=>`@${e.name}`.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`));for(let i of e.split(RegExp(`(${r.join(`|`)})`,`g`)))n.append(t.some(e=>`@${e.name}`===i)?Z(`span`,{className:`mention`},i):i);return n}var Wc=class extends HTMLElement{context;shadow=this.attachShadow({mode:`open`});root=Z(`div`,{className:`root`});layer=Z(`div`,{className:`layer`});pins=Z(`div`);outlines=Z(`div`);pinElements=/* @__PURE__ */ new Map;cursors=Z(`div`,{className:`layer`});floating=Z(`div`);composeMentions=/* @__PURE__ */ new WeakMap;toolbar=Z(`div`,{className:`bar toolbar`,role:`group`,"aria-label":`Comments`});session;page=_c(location.pathname);threads=[];mode=`view`;openThread;draft;panel=!1;pageWindow;panelBody;showResolved=!1;room;frame=0;hover;drafted=/* @__PURE__ */ new Set;editing;editStop;toastTimer;toast;lastCursor=0;loadRevision=0;navigationRevision=0;cleanups=[];get active(){return this.isConnected&&!this.context?.signal.aborted}async connectedCallback(){this.shadow.append(Z(`style`,{},Nc),this.root),this.root.append(this.layer,this.cursors,this.floating),this.layer.append(this.outlines,this.pins);let e=this.context?.bar;e&&(e.tabIndex=-1),e&&(e.hidden=!0,e.attachShadow({mode:`open`}).append(Z(`style`,{},Nc),this.toolbar));let t=getComputedStyle(document.body).fontFamily;for(let e of[this.root,this.toolbar])e.style.setProperty(`--font`,t);this.followTheme();let n=Z(`style`,{"data-vitehub-comments":!0},`
187
+ html.vitehub-comment-mode, html.vitehub-comment-mode * { cursor: crosshair !important; }
188
+ html.vitehub-edit-mode [data-content-field] { cursor: text !important; }
189
+ [data-vitehub-editing] { outline: 2px solid #2563eb !important; outline-offset: 2px; border-radius: 2px; }
190
+ `);document.head.append(n),this.cleanups.push(()=>n.remove());let[r,i]=await X.session();if(this.active){if(r){this.showToast(r.why,`error`,{keep:!0,action:[`Close`,()=>this.exit()]});return}if(!i.can.read){this.showDenied(i);return}this.session=i,e&&(e.hidden=!1),this.listen(),this.renderToolbar(),await this.load(),this.active&&(this.joinRoom(),this.openFromHash(),this.context?.onOpen(()=>this.showPanel()),this.context?.beforeExit(()=>!this.hasUnsentComment()||window.confirm(`Turn off tools without sending your comment?`)),this.context?.open&&this.showPanel())}}disconnectedCallback(){this.loadRevision++,this.navigationRevision++;for(let e of this.cleanups.splice(0))e();this.room?.destroy(),this.room=void 0,cancelAnimationFrame(this.frame)}followTheme(){let e=()=>{this.root.dataset.theme=this.toolbar.dataset.theme=zc()?`dark`:`light`,this.panelBody&&(this.panelBody.dataset.theme=this.root.dataset.theme)};e();let t=new MutationObserver(e);t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]});let n=matchMedia(`(prefers-color-scheme: dark)`);n.addEventListener(`change`,e),this.cleanups.push(()=>{t.disconnect(),n.removeEventListener(`change`,e)})}on(e,t,n,r){e.addEventListener(t,n,r),this.cleanups.push(()=>e.removeEventListener(t,n,r))}listen(){let e=()=>this.schedule();this.on(window,`scroll`,e,{capture:!0,passive:!0}),this.on(window,`resize`,e);let t=new ResizeObserver(e);t.observe(document.documentElement);let n,r=new MutationObserver(t=>{t.every(e=>e.target===this||this.contains(e.target))||(clearTimeout(n),n=setTimeout(e,50))});r.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`]}),this.cleanups.push(()=>{t.disconnect(),r.disconnect()});let i=()=>queueMicrotask(()=>this.navigated());for(let e of[`pushState`,`replaceState`]){let t=history[e];history[e]=function(...e){let n=t.apply(this,e);return i(),n},this.cleanups.push(()=>{history[e]=t})}this.on(window,`popstate`,i),this.on(window,`hashchange`,()=>this.openFromHash()),this.on(document,`pointermove`,e=>this.pointerMoved(e),{passive:!0}),this.on(document,`pointerleave`,()=>this.room?.setLocal(`cursor`,null)),this.on(document,`click`,e=>this.clicked(e),{capture:!0}),this.on(document,`keydown`,e=>this.keyed(e)),this.on(document,`visibilitychange`,()=>{document.visibilityState===`visible`&&this.load()});let a=setInterval(()=>{document.visibilityState===`visible`&&this.load()},3e4);this.cleanups.push(()=>clearInterval(a))}ours(e){let t=e.composedPath(),n=this.context?.bar.parentElement;return t.includes(this)||t.some(e=>e instanceof Element&&e.localName===`vitehub-window`)||!!(n&&t.includes(n))}elementAt(e,t){return document.elementsFromPoint(e,t).find(e=>e!==this&&!this.contains(e)&&e!==document.documentElement)}pointerMoved(e){if(this.ours(e))return;if(this.mode===`edit`){let t=this.elementAt(e.clientX,e.clientY),n=t?lc(t):void 0;n!==this.hover&&(this.hover=n,this.schedule())}if(!this.room||e.timeStamp-this.lastCursor<80)return;this.lastCursor=e.timeStamp;let t=this.elementAt(e.clientX,e.clientY);if(!t)return;let n=t.getBoundingClientRect(),r={selector:ac(t),x:n.width?Math.round((e.clientX-n.left)/n.width*1e3):0,y:n.height?Math.round((e.clientY-n.top)/n.height*1e3):0};this.room.setLocal(`cursor`,r)}clicked(e){if(this.ours(e)||this.mode===`view`)return;let t=this.elementAt(e.clientX,e.clientY);if(t){if(this.mode===`edit`){let n=lc(t);if(!n||n===this.editing?.element)return;e.preventDefault(),e.stopPropagation(),this.startEdit(n);return}e.preventDefault(),e.stopPropagation(),this.openThread=void 0,this.draft={anchor:uc(t,e.clientX,e.clientY),context:Mc(t),x:e.clientX,y:e.clientY},this.render()}}keyed(e){if(e.key===`Escape`){this.draft||this.openThread?(this.draft=void 0,this.openThread=void 0):this.setMode(`view`),this.render();return}Vc(e)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`c`&&this.session?.can.comment&&this.setMode(this.mode===`comment`?`view`:`comment`),e.key===`e`&&this.session?.content&&this.session.can.comment&&this.setMode(this.mode===`edit`?`view`:`edit`))}setMode(e){this.mode=e,this.hover=void 0,document.documentElement.classList.toggle(`vitehub-comment-mode`,e===`comment`),document.documentElement.classList.toggle(`vitehub-edit-mode`,e===`edit`),e!==`comment`&&(this.draft=void 0),this.renderToolbar(),this.render()}async navigated(){if(!this.active)return;let e=_c(location.pathname);if(e===this.page)return;let t=++this.navigationRevision;this.page=e,this.threads=[],this.openThread=void 0,this.draft=void 0,this.room?.destroy(),this.room=void 0,this.render(),await this.load(),t===this.navigationRevision&&this.joinRoom()}openFromHash(){let e=/^#comment-(.+)$/.exec(location.hash);if(!e)return;let t=this.threads.find(t=>t.id===e[1]);if(!t)return;this.showResolved||=t.status===`resolved`,this.openThread=t.id;let n=mc(t.anchor);n.state===`exact`&&n.element.scrollIntoView({block:`center`}),this.render()}async load(){let e=this.page,t=++this.loadRevision,[n,r]=await X.threads(e);if(e!==this.page||t!==this.loadRevision||!this.active)return;if(n){this.showToast(n.why,`error`);return}let i=new Map(this.threads.map(e=>[e.id,e]));this.threads=r.map(e=>{let t=i.get(e.id);return t?Object.assign(t,e):e}),this.renderToolbar(),this.render()}account(){let e=this.session?.user;return e&&!(e.guest&&e.id===`guest:console`)?e:void 0}joinRoom(e=!1){if(!this.session?.realtime||!this.active||this.room&&!e)return;this.room?.destroy();let t=xc(),n=this.account()??(t?{id:`guest:${t.id}`,name:`${t.name} (guest)`}:void 0),r=gc(import.meta.url).slice(0,-22),i=tc(`comments`,vc(this.page),{identity:n,changes:!0,baseURL:r});i.onUpdate(()=>{this.renderToolbar(),this.schedule()}),i.onChange(e=>{`path`in e&&e.path===vc(this.page)&&this.load()}),this.room=i}changed(){this.loadRevision++,this.room?.notify({operation:`update`,path:vc(this.page)})}failed(e){this.showToast(e.fix?`${e.why} ${e.fix}`:e.why,`error`)}ensureAuthor(e){if(this.account()||xc())return!0;let t=e?.value.trim();return t?(Sc(t),this.joinRoom(!0),!0):(e?.focus(),!1)}async create(e,t,n){if(!this.draft||!this.ensureAuthor(n))return;let[r,i]=await X.create({page:this.page,anchor:this.draft.anchor,context:this.draft.context,body:e,mentions:Hc(e,t)});if(r)return this.failed(r);this.threads=[i,...this.threads],this.draft=void 0,this.openThread=i.id,this.changed(),this.renderToolbar(),this.render()}async reply(e,t,n,r){if(!this.ensureAuthor(r))return;let[i,a]=await X.reply(e.id,{body:t,mentions:Hc(t,n)});if(i)return this.failed(i);e.comments.push(a);for(let n of[this.panelBody,this.floating])for(let r of n?.querySelectorAll(`textarea`)??[])r.closest(`[data-card]`)?.dataset.card===`thread-${e.id}`&&r.value.trim()===t&&(r.value=``);this.changed(),this.render()}async setStatus(e,t){let[n,r]=t?await X.resolve(e.id):await X.reopen(e.id);if(n)return this.failed(n);this.threads=this.threads.map(t=>t.id===e.id?r:t),t&&!this.showResolved&&(this.openThread=void 0),this.changed(),this.renderToolbar(),this.render()}async removeComment(e,t){let n=e.comments[0]?.id===t,[r]=await X.removeComment(e.id,t);if(r)return this.failed(r);n?(this.threads=this.threads.filter(t=>t.id!==e.id),this.openThread=void 0):e.comments=e.comments.filter(e=>e.id!==t),this.changed(),this.renderToolbar(),this.render()}async startEdit(e){await this.finishEdit(!0);let t=e.getAttribute(nc);if(!t)return;let[n,r]=await X.field(t);if(n)return this.failed(n);let i=`/content/${encodeURIComponent(r.collection)}/${r.id.split(`/`).map(encodeURIComponent).join(`/`)}`;if(await this.context?.openTool(`content`,i))return;if(!r.editable||r.value===null){this.showToast(`This field is not plain text. Edit it in the Console.`,`info`,{link:[`Open Content`,Pc()]});return}this.editing={element:e,field:t,digest:r.digest,original:e.textContent??``,initial:r.value},e.textContent=r.value,e.setAttribute(`data-vitehub-editing`,``),e.contentEditable=`plaintext-only`,e.contentEditable!==`plaintext-only`&&(e.contentEditable=`true`),e.focus();let a=document.createRange();a.selectNodeContents(e),getSelection()?.removeAllRanges(),getSelection()?.addRange(a);let o=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),this.finishEdit(!0)),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.finishEdit(!1))},s=()=>void this.finishEdit(!0);e.addEventListener(`keydown`,o),e.addEventListener(`blur`,s,{once:!0}),this.editStop=()=>{e.removeEventListener(`keydown`,o),e.removeEventListener(`blur`,s)}}async finishEdit(e){let t=this.editing;if(!t)return;this.editing=void 0,this.editStop?.();let{element:n,field:r,digest:i,original:a,initial:o}=t;n.contentEditable=`inherit`,n.removeAttribute(`data-vitehub-editing`);let s=(n.textContent??``).trim();if(!e){n.textContent=a;return}if(s===o.trim())return;let[c]=await X.saveField({field:r,value:s,ifDigest:i});if(c)return n.textContent=a,this.failed(c);this.drafted.add(r),this.showToast(`Saved as a draft. Publish it in the Console.`,`info`,{link:[`Review and publish`,Pc()]}),this.schedule()}schedule(){cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>this.render())}visibleThreads(){return this.threads.filter(e=>this.showResolved||e.status===`open`)}renderToolbar(){let e=this.session;if(!e)return;let t=this.threads.filter(e=>e.status===`open`).length,n=e.signOut,r=this.room?.people()??[],i=/* @__PURE__ */ new Set,a=r.filter(e=>!i.has(e.id)&&i.add(e.id)).slice(0,5).map(e=>Z(`span`,{className:`avatar`,title:e.name,style:`background:${e.color}`},e.image?Z(`img`,{src:e.image,alt:``}):Ic(e.name))),o=`${t} open ${t===1?`thread`:`threads`}`;this.toolbar.replaceChildren(...Fc(e.can.comment&&Z(`button`,{className:`tool`,"aria-pressed":String(this.mode===`comment`),title:`Comment (C)`,onClick:()=>this.setMode(this.mode===`comment`?`view`:`comment`)},$.comment(),`Comment`,Z(`kbd`,{},`C`)),e.content&&e.can.comment&&Z(`button`,{className:`tool`,"aria-pressed":String(this.mode===`edit`),title:`Edit text (E)`,onClick:()=>this.setMode(this.mode===`edit`?`view`:`edit`)},$.edit(),`Edit`,Z(`kbd`,{},`E`)),Z(`span`,{className:`sep`}),Z(`button`,{className:`tool`,"aria-pressed":String(this.panel),title:`Comments on this page`,"aria-label":`Comments on this page, ${o}`,onClick:()=>{this.panel?this.pageWindow?.hide():this.showPanel()}},$.list(),String(t)),a.length>0&&Z(`span`,{className:`people`,"aria-label":`${r.length} on this page`},...a),n&&e.github&&Z(`button`,{className:`tool`,title:`Signed in as @${e.github.login}. Sign out`,"aria-label":`Sign out @${e.github.login}`,onClick:()=>void this.signOut(n)},e.user?.image?Z(`img`,{className:`me`,src:e.user.image,alt:``}):Ic(e.user?.name??e.github.login))))}render(){this.session&&(this.renderPins(),this.renderCursors(),this.renderFloating())}renderPins(){let e=[],t=[];if(this.visibleThreads().forEach((n,r)=>{let i=mc(n.anchor);if(i.state===`hidden`)return;for(;t.some(e=>Math.abs(e.x-i.x)<20&&Math.abs(e.y-i.y)<20);)i.x+=22;if(t.push({x:i.x,y:i.y}),i.x<-40||i.y<-40||i.x>innerWidth+40||i.y>innerHeight+40)return;let a=n.status===`resolved`?`resolved`:i.state===`moved`?`moved`:`open`,o=n.comments[0]?.author??n.createdBy,s=this.pinElements.get(n.id);s||(s=Z(`div`,{className:`pin`},Z(`button`,{className:`pin-button`,onClick:e=>{e.stopPropagation(),this.draft=void 0,this.openThread=this.openThread===n.id&&(!this.pageWindow||this.panel)?void 0:n.id,this.openThread&&this.pageWindow?this.showPanel():this.render()}})),this.pinElements.set(n.id,s));let c=s.firstElementChild;s.dataset.state=a,c.style.background=Lc(o.id),s.dataset.open=String(this.openThread===n.id),s.style.left=`${i.x}px`,s.style.top=`${i.y}px`,c.setAttribute(`title`,`${o.name}: ${n.comments[0]?.body??``}${a===`moved`?` (the element moved)`:``}`),c.setAttribute(`aria-label`,`Thread ${r+1} by ${o.name}`),c.textContent=Ic(o.name),e.push(s)}),this.draft){let t=this.session?.user??{id:`guest`,name:xc()?.name??`You`};e.push(Z(`div`,{className:`pin`,"data-state":`draft`,style:`left:${this.draft.x}px;top:${this.draft.y}px`},Z(`span`,{className:`pin-button`,style:`background:${Lc(t.id)}`,"aria-hidden":`true`},Ic(t.name))))}for(let e of this.pinElements.keys())this.threads.some(t=>t.id===e)||this.pinElements.delete(e);let n=[];if(this.mode===`edit`)for(let e of document.querySelectorAll(`[${nc}]`)){let t=e.getAttribute(nc),r=e===this.hover?`hover`:this.drafted.has(t)?`draft`:void 0;if(!r)continue;let i=e.getBoundingClientRect();n.push(Z(`div`,{className:`outline`,"data-kind":r,style:`left:${i.left-3}px;top:${i.top-3}px;width:${i.width+6}px;height:${i.height+6}px`})),n.push(Z(`div`,{className:`tag`,style:`left:${i.left-3}px;top:${i.top-3}px`},r===`draft`?`Draft`:t))}this.outlines.replaceChildren(...n);for(let t of Array.from(this.pins.children))e.includes(t)||t.remove();e.forEach((e,t)=>{this.pins.children[t]!==e&&this.pins.insertBefore(e,this.pins.children[t]??null)})}renderCursors(){let e=[];for(let[,t]of this.room?.states()??[]){let n=t.cursor,r=t.user;if(!n||!r?.id||r.id===this.session?.user?.id)continue;let i=null;try{i=document.querySelector(n.selector)}catch{}if(!i)continue;let a=i.getBoundingClientRect(),o=a.left+n.x/1e3*a.width,s=a.top+n.y/1e3*a.height,c=typeof r.color==`string`&&/^#[\da-f]{6}$/i.test(r.color)?r.color:Lc(r.id),l=Q(`<path d="M4 2l16 7-7 2-3 8z" fill="${c}" stroke="#000" stroke-width="1.5"/>`);e.push(Z(`div`,{className:`cursor`,style:`left:${o}px;top:${s}px`},l,Z(`span`,{style:`background:${c}`},r.name??`Someone`)))}this.cursors.replaceChildren(...e)}place(e,t,n){let r=innerWidth-(this.panel?368:8),i=Math.max(8,t+24+320<=r?t+24:Math.min(t-24-320,r-320)),a=Math.min(Math.max(8,n-14),innerHeight-200);e.style.left=`${i}px`,e.style.top=`${a}px`}hasUnsentComment(){return[...this.floating.querySelectorAll(`textarea`),...this.panelBody?.querySelectorAll(`textarea`)??[]].some(e=>e.value.trim().length>0)}showPanel(){if(this.context){if(!this.pageWindow){this.pageWindow=this.context.createWindow({id:`comments`,title:`Comments`,trigger:this.context.bar,onHide:()=>{this.panel=!1,this.renderToolbar()}});let e=document.createElement(`div`),t=e.attachShadow({mode:`open`});this.panelBody=Z(`div`,{className:`root`}),t.append(Z(`style`,{},Nc+`
191
+ :host{display:block;height:100%}.root{position:static;height:100%;pointer-events:auto}
192
+ .panel,.card{position:static;width:auto;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none}
193
+ .panel-head>.title h2,.panel-head>.icon{display:none}.panel-list{max-height:40vh}
194
+ .card{border-top:1px solid var(--line)}
195
+ `),this.panelBody),this.pageWindow.body.append(e)}this.panel=!0,this.pageWindow.show(),this.renderToolbar(),this.render()}}renderFloating(){let e=[];if(this.draft){let t=this.renderComposer();this.place(t,this.draft.x,this.draft.y),e.push(t)}let t=this.threads.find(e=>e.id===this.openThread);if(t&&!this.pageWindow){let n=mc(t.anchor),r=this.renderThread(t);n.state===`hidden`?this.place(r,innerWidth/2,innerHeight/3):this.place(r,n.x,n.y),e.push(r)}this.toast&&e.push(this.toast);let n=this.panel?this.visibleThreads().map(e=>[e.id,e.status,e.updatedAt,e.comments.length,e.comments[0]?.body]):void 0,r=JSON.stringify([this.page,this.panel,n,this.showResolved,this.draft?.anchor,t?.id,t?.status,t?.comments.length,t?.can,this.threads.length,!!this.toast]);if(this.panelBody&&this.panel&&this.panelBody.dataset.key!==r){let e=new Map([...this.panelBody.querySelectorAll(`textarea`)].map(e=>[e.closest(`[data-card]`)?.dataset.card,{value:e.value,mentions:this.composeMentions.get(e)??[]}]));this.panelBody.dataset.key=r,this.panelBody.dataset.theme=zc()?`dark`:`light`,this.panelBody.replaceChildren(this.renderPanel(),...t?[this.renderThread(t)]:[]);for(let t of this.panelBody.querySelectorAll(`textarea`)){let n=e.get(t.closest(`[data-card]`)?.dataset.card);n?.value&&(t.value=n.value,this.composeMentions.get(t)?.push(...n.mentions),t.dispatchEvent(new Event(`input`,{bubbles:!0})))}}if(this.floating.dataset.key===r){for(let t of this.floating.querySelectorAll(`.card`)){let n=e.find(e=>e instanceof HTMLElement&&e.dataset.card===t.dataset.card);n&&(t.style.left=n.style.left,t.style.top=n.style.top)}return}this.floating.dataset.key=r;let i=new Set(Array.from(this.floating.querySelectorAll(`[data-card]`),e=>e.dataset.card));for(let t of e)t instanceof HTMLElement&&(this.floating.contains(t)||i.has(t.dataset.card))&&(t.dataset.static=``);this.floating.replaceChildren(...e),this.floating.querySelector(`textarea[data-autofocus]`)?.focus()}renderPanel(){let e=this.visibleThreads();return Z(`div`,{className:`panel`,role:`dialog`,"aria-labelledby":`vitehub-comments-panel-title`,"data-card":`panel`},Z(`div`,{className:`panel-head`},Z(`div`,{className:`title`},Z(`h2`,{id:`vitehub-comments-panel-title`},`Comments`),Z(`div`,{className:`page`,title:this.page},this.page)),Z(`button`,{className:`switch`,role:`switch`,"aria-checked":String(this.showResolved),onClick:()=>{this.showResolved=!this.showResolved,this.render()}},`Show resolved`,Z(`span`,{className:`track`,"aria-hidden":`true`})),Z(`button`,{className:`icon`,"aria-label":`Close comments`,title:`Close`,onClick:()=>{this.pageWindow?.hide()}},$.close())),e.length?Z(`div`,{className:`panel-list`},...e.map(e=>{let t=e.comments[0],n=t?.author??e.createdBy,r=mc(e.anchor),i=e.comments.length-1;return Z(`button`,{className:`panel-item`,"data-state":e.status,"aria-current":String(this.openThread===e.id),onClick:()=>{this.openThread=e.id,r.state===`exact`&&r.element.scrollIntoView({block:`center`,behavior:`smooth`}),this.render()}},Rc(n),Z(`div`,{className:`top`},Z(`span`,{className:`name`},n.name),Z(`span`,{className:`time`},Bc(e.updatedAt))),Z(`div`,{className:`excerpt`},t?.body??``),(i>0||e.status===`resolved`||r.state===`moved`)&&Z(`div`,{className:`meta`},i>0&&Z(`span`,{},`${i} ${i===1?`reply`:`replies`}`),e.status===`resolved`&&Z(`span`,{},`Resolved`),r.state===`moved`&&Z(`span`,{},`The element moved`)))})):Z(`div`,{className:`empty`},Z(`strong`,{},this.showResolved?`No comments on this page`:`No open comments`),this.session?.can.comment?Z(`span`,{},`Press C, then click anything on the page.`):null))}renderThread(e){let t=this.session,n=e.can??t.can,r=e.status===`resolved`;return Z(`div`,{className:`card`,role:`dialog`,"aria-label":`Comment thread`,"data-card":`thread-${e.id}`},Z(`div`,{className:`card-head`},Z(`span`,{className:`grow`},e.anchor.field?`On ${e.anchor.field}`:r?`Resolved by ${e.resolvedBy?.name??`someone`}`:`${e.comments.length} ${e.comments.length===1?`comment`:`comments`}`),n.resolve&&Z(`button`,{className:`icon`,title:r?`Reopen`:`Resolve`,"aria-label":r?`Reopen`:`Resolve`,onClick:()=>void this.setStatus(e,!r)},r?$.reopen():$.check()),Z(`button`,{className:`icon`,"aria-label":`Close`,onClick:()=>{this.openThread=void 0,this.render()}},$.close())),Z(`div`,{className:`messages`},...e.comments.map(r=>Z(`div`,{className:`message`},Rc(r.author),Z(`div`,{className:`message-head`},Z(`span`,{className:`name`},r.author.guest?`${r.author.name} (guest)`:r.author.name),Z(`time`,{className:`time`,datetime:r.createdAt,title:new Date(r.createdAt).toLocaleString()},Bc(r.createdAt)),t.user&&!t.user.guest&&(n.resolve||n.comment&&!r.author.guest&&r.author.id===t.user.id)&&Z(`button`,{className:`icon danger`,title:`Delete`,"aria-label":`Delete comment`,onClick:()=>void this.removeComment(e,r.id)},$.trash())),Uc(r.body,r.mentions)))),!r&&n.comment&&this.renderCompose(`Reply`,(t,n,r)=>this.reply(e,t,n,r)))}renderComposer(){return Z(`div`,{className:`card`,role:`dialog`,"aria-label":`New comment`,"data-card":`new`},this.renderCompose(`Comment`,(e,t,n)=>this.create(e,t,n),!0))}renderCompose(e,t,n=!1){let r=[],i=!this.account()&&!xc()?Z(`input`,{placeholder:`Your name`,"aria-label":`Your name`,maxlength:64}):void 0,a=Z(`textarea`,{placeholder:this.account()||xc()?`${e}… Use @ to mention`:`${e}…`,"aria-label":e,"data-autofocus":n||void 0,maxlength:4e3});this.composeMentions.set(a,r);let o=Z(`button`,{className:`primary`,disabled:!0},e),s=Z(`div`,{className:`suggest`,role:`listbox`,hidden:!0}),c=[],l=0,u,d=!1,f=async()=>{let e=a.value.trim();if(e&&!d){d=!0,o.disabled=!0;try{await t(e,r,i)}finally{d=!1,o.disabled=!a.value.trim()}}},p=e=>{if(!u)return;let t=a.value.slice(0,u.start),n=a.value.slice(a.selectionStart);a.value=`${t}@${e.name} ${n}`,r.push(e),u=void 0,s.hidden=!0,a.focus()},ee=()=>{s.hidden=!c.length,s.replaceChildren(...c.map((e,t)=>Z(`button`,{role:`option`,"aria-selected":String(t===l),onMousedown:t=>{t.preventDefault(),p(e)}},Rc(e),e.name)))};return a.addEventListener(`input`,async()=>{o.disabled=d||!a.value.trim();let e=a.value.slice(0,a.selectionStart),t=/(^|\s)@([^\s@]{0,32})$/.exec(e);if(!t){u=void 0,s.hidden=!0;return}u={start:e.length-t[2].length-1,text:t[2]};let[n,r]=await X.people(t[2]);n||u?.text!==t[2]||(c=r,l=0,ee())}),a.addEventListener(`keydown`,e=>{if(!s.hidden&&c.length){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),l=(l+(e.key===`ArrowDown`?1:c.length-1))%c.length,ee();return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),p(c[l]);return}}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}),o.addEventListener(`click`,()=>void f()),Z(`div`,{className:`compose`},s,i,a,Z(`div`,{className:`row`},Z(`span`,{className:`hint`},`${/Mac|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`} Enter to send`),o))}showToast(e,t,n={}){clearTimeout(this.toastTimer),this.toast=Z(`div`,{className:`toast`,role:`status`,"data-kind":t},Z(`span`,{},e),n.link&&Z(`a`,{href:n.link[1]},n.link[0]),n.action&&Z(`button`,{className:`secondary`,onClick:n.action[1]},n.action[0])),this.session?this.render():this.floating.replaceChildren(this.toast),n.keep||(this.toastTimer=setTimeout(()=>{this.toast=void 0,this.render()},t===`error`?8e3:5e3))}showDenied(e){let t=e.signIn&&`${e.signIn.url}?return=${encodeURIComponent(location.pathname+location.search+location.hash)}`,n=e.github;if(n&&e.signOut){let t=n.repository?`@${n.login} cannot push to ${n.repository}, so cannot comment here.`:`Signed in as @${n.login}, but this site does not say which GitHub repository it is built from.`,r=e.signOut;this.showToast(t,`error`,{keep:!0,action:[`Use another account`,()=>void this.signOut(r)]});return}if(t){this.showToast(`Sign in to comment on this page.`,`info`,{keep:!0,link:[`Sign in with GitHub`,t],action:[`Close`,()=>this.exit()]});return}this.showToast(`Comments are only for the site's team. Sign in with an account that may comment.`,`error`,{keep:!0,action:[`Close`,()=>this.exit()]})}async signOut(e){await fetch(e,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`}).catch(()=>void 0),location.reload()}stop(){this.finishEdit(!1),this.setMode(`view`),this.remove()}exit(){this.context?.exit()}};const Gc=e=>{customElements.get(`vitehub-comments`)||customElements.define(`vitehub-comments`,Wc);let t=document.createElement(`vitehub-comments`);if(t instanceof Wc)return t.context=e,document.body.append(t),()=>t.stop()};export{Gc as default};
@@ -0,0 +1,22 @@
1
+ function e(e){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let[e,n]of Object.entries({width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.75`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`}))t.setAttribute(e,n);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttribute(`d`,e),t.append(n),t}function t(t){let n=document.createElement(`vitehub-window`);n.hidden=!0;let r=n.attachShadow({mode:`open`}),i=document.createElement(`style`);i.textContent=`
2
+ :host{all:initial;--surface:light-dark(#fff,#000);--text:light-dark(#18181b,#fafafa);--muted:light-dark(#52525b,#a1a1aa);--line:light-dark(#d4d4d8,#3f3f46);--hover:light-dark(#f4f4f5,#27272a);--focus:#3b82f6;position:fixed;inset:0;z-index:2147483000;pointer-events:none;color:var(--text);font:400 .875rem/1.5 system-ui,sans-serif;color-scheme:light dark}
3
+ :host([hidden]){display:none}
4
+ .window{position:absolute;right:16px;bottom:76px;width:min(600px,calc(100vw - 32px));height:min(640px,calc(100dvh - 100px));min-width:300px;min-height:240px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 100px);display:flex;flex-direction:column;overflow:hidden;resize:both;pointer-events:auto;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 8px 32px #0002}
5
+ .window.expanded{inset:12px 12px 76px;width:auto!important;height:auto!important;max-width:none;max-height:none;resize:none}
6
+ header{display:flex;align-items:center;gap:4px;min-height:44px;padding:0 8px;border-bottom:1px solid var(--line);flex:none}
7
+ h2{font:600 .875rem/1.5 system-ui,sans-serif;margin:0;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 8px}
8
+ button{display:grid;place-items:center;width:36px;height:36px;border:0;border-radius:6px;background:transparent;color:var(--muted);cursor:pointer;font:inherit}
9
+ button:hover{background:var(--hover);color:var(--text)}
10
+ button:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
11
+ .body{flex:1;min-height:0;overflow:auto;position:relative}iframe{display:block;border:0;width:100%;height:100%;background:var(--surface)}
12
+ @media(max-width:640px){.window,.window.expanded{inset:0 0 68px;width:auto!important;height:auto!important;max-width:none;max-height:none;min-width:0;min-height:0;border-radius:0;resize:none}button{width:44px;height:44px}.expand{display:none}}
13
+ @media(forced-colors:active){.window{border:1px solid CanvasText}button:focus-visible{outline-color:Highlight}}
14
+ `;let a=document.createElement(`section`);a.className=`window`,a.setAttribute(`role`,`dialog`),a.setAttribute(`aria-labelledby`,`title`);let o=document.createElement(`header`),s=document.createElement(`h2`);s.id=`title`,s.textContent=t.title;let c=document.createElement(`div`);c.className=`body`;let l=(t,n,r)=>{let i=document.createElement(`button`);return i.className=t,i.type=`button`,i.setAttribute(`aria-label`,n),i.title=n,i.append(e(r)),i},u=l(`expand`,`Expand window`,`M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5`),d=l(`hide`,`Minimize window`,`M5 12h14`);o.append(s,u,d),a.append(o,c),r.append(i,a);let f=`vitehub-window:${t.id}`;try{let e=JSON.parse(localStorage.getItem(f)??`null`);e&&typeof e==`object`&&`width`in e&&`height`in e&&typeof e.width==`number`&&typeof e.height==`number`&&(Number.isFinite(e.width)&&(a.style.width=`${Math.max(300,e.width)}px`),Number.isFinite(e.height)&&(a.style.height=`${Math.max(240,e.height)}px`))}catch{}let p=new ResizeObserver(()=>{if(n.hidden||a.classList.contains(`expanded`)||innerWidth<=640)return;let{width:e,height:t}=a.getBoundingClientRect();try{localStorage.setItem(f,JSON.stringify({width:e,height:t}))}catch{}});p.observe(a);let m=()=>{n.hidden=!0,t.trigger.setAttribute(`aria-expanded`,`false`),t.trigger.focus({preventScroll:!0}),t.onHide?.()};u.addEventListener(`click`,()=>{let e=a.classList.toggle(`expanded`);u.setAttribute(`aria-label`,e?`Restore window size`:`Expand window`),u.title=e?`Restore window size`:`Expand window`,u.setAttribute(`aria-pressed`,String(e))}),d.addEventListener(`click`,m),r.addEventListener(`keydown`,e=>{e instanceof KeyboardEvent&&e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),e.stopPropagation(),m())});let h=()=>{p.disconnect(),n.remove()};return t.signal.aborted?h():(t.signal.addEventListener(`abort`,h,{once:!0}),document.body.append(n)),{body:c,show(){t.signal.aborted||(n.style.colorScheme=getComputedStyle(t.trigger).colorScheme,n.hidden=!1,t.trigger.setAttribute(`aria-expanded`,`true`),d.focus({preventScroll:!0}))},hide:m,destroy:h}}const n=`vitehub`,r=`/_vitehub/page/session`;function i(e){let t=new URL(e,`http://localhost`).pathname,n=t.lastIndexOf(`/_vitehub/page/assets/`);return n===-1?r:`${t.slice(0,n)}${r}`}function a(e){return typeof e==`string`&&e?e:void 0}function o(e){if(typeof e!=`object`||!e)return;let t=a(Reflect.get(e,`id`)),n=a(Reflect.get(e,`script`));if(!t||!n)return;let r={id:t,label:a(Reflect.get(e,`label`))??t,icon:a(Reflect.get(e,`icon`))??``,script:n};Reflect.get(e,`lazy`)===!0&&(r.lazy=!0);let i=a(Reflect.get(e,`hotkey`));return i&&(r.hotkey=i),r}function s(e){let t=typeof e==`object`&&e?Reflect.get(e,`tools`):void 0;return{tools:Array.isArray(t)?t.map(o).filter(e=>!!e):[]}}function c(e){let t=typeof e==`object`&&e?Reflect.get(e,`default`):void 0;return t instanceof Function?t:void 0}function l(){let e=document.documentElement;if(e.classList.contains(`dark`)||e.dataset.theme===`dark`)return!0;if(e.classList.contains(`light`)||e.dataset.theme===`light`)return!1;let t=getComputedStyle(e).colorScheme;return t===`dark`||t.includes(`dark`)&&matchMedia(`(prefers-color-scheme: dark)`).matches}function u(e,t,n){let r=document.createElement(`vitehub-pill`),i=r.attachShadow({mode:`open`}),a=document.createElement(`style`);a.textContent=`:host{all:initial;position:fixed;left:50%;bottom:16px;translate:-50% 0;z-index:2147483001;font-size:13px;line-height:1.5;color:light-dark(#3f3f46,#e4e4e7);-webkit-font-smoothing:antialiased}
15
+ div{max-width:calc(100vw - 24px);overflow-x:auto;--line:light-dark(#0000000f,#ffffff12);display:flex;align-items:center;gap:2px;padding:4px;border-radius:999px;background:light-dark(#fff,#1c1c1f);box-shadow:0 0 0 1px light-dark(#00000014,#ffffff1a),0 1px 2px #0000000a,0 8px 24px -6px light-dark(#00000029,#0009)}
16
+ ::slotted(*){flex-shrink:0;display:flex;align-items:center;padding-right:5px;margin-right:3px;background:linear-gradient(var(--line),var(--line)) right/1px 16px no-repeat}
17
+ ::slotted([hidden]){display:none!important}
18
+ button{all:unset;flex-shrink:0;position:sticky;right:0;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;cursor:pointer;color:light-dark(#71717a,#a1a1aa)}
19
+ button:hover{background:light-dark(#0000000d,#ffffff0f);color:light-dark(#18181b,#fafafa)}
20
+ :focus-visible{outline:2px solid #2563eb;outline-offset:2px}`;let o=document.createElement(`div`);o.setAttribute(`role`,`toolbar`),o.setAttribute(`aria-label`,`ViteHub tools`);let s=document.createElement(`button`);s.setAttribute(`aria-label`,`Turn off ViteHub tools`),s.title=`Turn off ViteHub tools`;let c=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let[e,t]of Object.entries({width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"aria-hidden":`true`}))c.setAttribute(e,t);let u=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);u.setAttribute(`d`,`M18 6 6 18M6 6l12 12`),c.append(u),s.append(c),o.append(s),i.append(a,o);for(let t of e){let e=document.createElement(`slot`);e.name=t.id,o.insertBefore(e,s)}s.addEventListener(`click`,t),r.style.fontFamily=getComputedStyle(document.body).fontFamily;let d=()=>{r.style.colorScheme=l()?`dark`:`light`};d();let f=new MutationObserver(d);return f.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]}),matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,d,{signal:n}),n.addEventListener(`abort`,()=>{f.disconnect(),r.remove()},{once:!0}),document.body.append(r),r}async function d(e={}){let r=new URLSearchParams(location.search);if(!r.has(`vitehub`)&&!document.cookie.split(`;`).some(e=>e.trim()===`vitehub-tools=1`))return[];let a=e.load??(e=>import(
21
+ /* @vite-ignore */
22
+ e)),o;try{let t=await fetch(e.session??i(import.meta.url),{credentials:`same-origin`,headers:{accept:`application/json`}});if(!t.ok)return[];o=s(await t.json())}catch{return[]}if(o.tools.length===0||document.querySelector(`vitehub-pill`))return[];let l=r.get(n),d=o.tools.some(e=>e.id===l),f=new AbortController,p=o.tools.map(()=>new AbortController),m=/* @__PURE__ */ new Set,h=()=>{if([...m].some(e=>!e()))return;for(let e of o.tools)y(e.id,!1);document.cookie=`vitehub-tools=; Path=/; Max-Age=0; SameSite=Lax`;let e=new URL(location.href);e.searchParams.has(`vitehub`)&&(e.searchParams.delete(n),history.replaceState(history.state,``,e));for(let e of p)e.abort();f.abort()},g=u(o.tools,h,f.signal),_=/* @__PURE__ */ new Map,v=t=>`vitehub-open:${e.session??i(import.meta.url)}:${t}`,y=(e,t)=>{try{sessionStorage.setItem(v(e),String(t))}catch{}},b=e=>{try{return sessionStorage.getItem(v(e))===`true`}catch{return!1}},x=/* @__PURE__ */ new Map,S=async(e,t)=>await x.get(e)?.(t)??!1,C=(await Promise.all(o.tools.map(async(e,n)=>{let{signal:r}=p[n],i=document.createElement(`vitehub-tool`);i.slot=e.id,g.append(i);let o,s,u=!1,f=()=>{let t=document.createElement(`vitehub-tool`);t.slot=e.id,i.replaceWith(t),i=t},v=()=>{let e=i.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=`button{all:unset;display:block;box-sizing:border-box;font:inherit;color:inherit;border-radius:999px;padding:0 12px;min-height:36px;cursor:pointer}button:focus-visible{outline:2px solid #2563eb;outline-offset:-2px}`,e.append(t,w)},C=(n,d=!0)=>r.aborted?Promise.resolve(!1):u?(o?.(n),Promise.resolve(!0)):s?s.then(e=>(e&&o?.(n),e)):(s=(async()=>{let p=new AbortController,g=()=>p.abort();r.addEventListener(`abort`,g,{once:!0});try{i.setAttribute(`aria-busy`,`true`);let s=c(await a(e.script));if(!s)throw TypeError(`The script ${e.script} has no default export function.`);if(r.aborted)return!1;w.remove(),i.shadowRoot?f():i.replaceChildren();let g=s({beforeExit:e=>{let t=()=>e();m.add(t),p.signal.addEventListener(`abort`,()=>m.delete(t),{once:!0})},tool:e,bar:i,signal:p.signal,open:d&&(e.lazy===!0||e.id===l||b(e.id)),exit:h,createWindow:n=>{let r=t({...n,signal:p.signal,onHide:()=>{y(e.id,!1),n.onHide?.()}}),i={...r,show(){if(!p.signal.aborted){for(let[t,n]of _)t!==e.id&&n.hide();y(e.id,!0),r.show()}},destroy(){_.get(e.id)===i&&(_.delete(e.id),y(e.id,!1)),r.destroy()}};return _.set(e.id,i),i},openTool:S,onOpen:e=>{o=e}});return u=!0,n&&o?.(n),!i.shadowRoot&&!i.hasChildNodes()&&(i.hidden=!0),g instanceof Function&&(r.aborted?g():p.signal.addEventListener(`abort`,()=>g(),{once:!0})),!r.aborted}catch(t){return p.abort(),r.removeEventListener(`abort`,g),_.delete(e.id)&&y(e.id,!1),o=void 0,u=!1,console.error(`[vitehub] The page tool "${e.id}" did not start.`,t),e.lazy?(f(),w.textContent=`Retry ${e.label}`,w.title=`The tool could not load. Try again.`,i.hidden=!1,v()):(x.delete(e.id),i.remove()),!1}finally{i.removeAttribute(`aria-busy`),s=void 0}})(),s),w=document.createElement(`button`);if(w.type=`button`,w.textContent=e.label,w.addEventListener(`click`,()=>void C()),x.set(e.id,C),e.lazy&&e.id!==l&&!b(e.id))return v(),e;let T=await C(void 0,!d||e.id===l);return!r.aborted&&(T||e.lazy)?e:void 0}))).filter(e=>!!e);return C.length===0&&f.abort(),C}d({session:new URL(`../session`,import.meta.url).pathname});