@vite-hub/comments 0.1.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +79 -31
  2. package/dist/anchor.d.ts +7 -4
  3. package/dist/anchor.js +10 -5
  4. package/dist/client-diagnostics-CcFpkbAk.js +40 -0
  5. package/dist/client.d.ts +78 -3
  6. package/dist/client.js +198 -13
  7. package/dist/{console-BIz9t2cO.d.ts → console-h4KlhIik.d.ts} +97 -8
  8. package/dist/context-BqIsmYP1.js +61 -0
  9. package/dist/database/postgres.d.ts +738 -347
  10. package/dist/database/postgres.js +28 -7
  11. package/dist/{database-Cb2xjC1V.d.ts → database-CA1aHKN7.d.ts} +675 -276
  12. package/dist/database.d.ts +6 -98
  13. package/dist/database.js +2 -3
  14. package/dist/define-43mMR39K.js +89 -0
  15. package/dist/define-B3TF9zzn.d.ts +204 -0
  16. package/dist/errors-4gelGVmK.js +57 -0
  17. package/dist/errors-C6qptPoG.js +135 -0
  18. package/dist/errors-CyQyKAvy.d.ts +185 -0
  19. package/dist/fold-name-B7Zb3-MF.js +7 -0
  20. package/dist/{identity-3qtVC4rF.js → identity-CBOzgxSf.js} +7 -2
  21. package/dist/index-DNhy69Wt.d.ts +83 -0
  22. package/dist/index.d.ts +7 -7
  23. package/dist/index.js +196 -5
  24. package/dist/install-BcMPgPk_.js +1154 -0
  25. package/dist/install-W9ghhGoh.d.ts +36 -0
  26. package/dist/installed-B-PfERBU.js +30 -0
  27. package/dist/invariant-D8_xBqmZ.js +22 -0
  28. package/dist/migrate-B0k_0swk.d.ts +54 -0
  29. package/dist/migrate-BDQ8xqUs.js +289 -0
  30. package/dist/object-Da1zyPCR.js +11 -0
  31. package/dist/{operations-0B0QTVWX.d.ts → operations-D4A1Fcgf.d.ts} +37 -15
  32. package/dist/operations-DMMIfYPW.js +1159 -0
  33. package/dist/operations-GLeOqgMt.d.ts +257 -0
  34. package/dist/operations.d.ts +3 -7
  35. package/dist/operations.js +3 -2
  36. package/dist/overlay/client-DmsSMOzi.js +4 -0
  37. package/dist/overlay/dist-BoHMOFax.js +14 -0
  38. package/dist/overlay/dist-yIZmvSaU.js +1 -0
  39. package/dist/overlay/overlay.js +183 -177
  40. package/dist/page/loader.js +138 -18
  41. package/dist/{page-BuroSMXO.js → page-B41ozN63.js} +8 -6
  42. package/dist/{page-BtXADR6d.d.ts → page-DtbMOEMd.d.ts} +6 -5
  43. package/dist/page-tools-shared-NHUjKI8E.js +117 -0
  44. package/dist/path--zk6PEMz.js +18 -0
  45. package/dist/plugin-PS8PMYus.js +74 -0
  46. package/dist/realtime.d.ts +6 -12
  47. package/dist/realtime.js +23 -24
  48. package/dist/rpc-HBcWtg0T.d.ts +17 -0
  49. package/dist/rpc-RKPAusHp.js +153 -0
  50. package/dist/rpc.d.ts +2 -29
  51. package/dist/rpc.js +2 -75
  52. package/dist/runtime/auth.d.ts +5 -3
  53. package/dist/runtime/auth.js +8 -5
  54. package/dist/runtime/console.d.ts +1 -1
  55. package/dist/runtime/console.js +26 -21
  56. package/dist/runtime/index.d.ts +108 -60
  57. package/dist/runtime/index.js +684 -236
  58. package/dist/{server-BomGg3Gb.js → server-D8k-0GXe.js} +16 -7
  59. package/dist/server.d.ts +14 -88
  60. package/dist/server.js +7 -326
  61. package/dist/service-CFVm23k7.d.ts +158 -0
  62. package/dist/service-GHhhyQj4.js +609 -0
  63. package/dist/session-DVx-1Tym.d.ts +14 -0
  64. package/dist/session-EkudzUmm.js +503 -0
  65. package/dist/testing.d.ts +1 -1
  66. package/dist/testing.js +14 -2
  67. package/dist/tokens-DSbwkVSy.js +58 -0
  68. package/dist/types-BIS0hCEl.d.ts +124 -0
  69. package/dist/types-CZujrMFd.d.ts +322 -0
  70. package/dist/vite.d.ts +91 -87
  71. package/dist/vite.js +535 -796
  72. package/package.json +24 -27
  73. package/dist/database-BSnVrwHn.js +0 -60
  74. package/dist/database-C-ktS9Do.js +0 -95
  75. package/dist/define-BzW2Ychn.d.ts +0 -46
  76. package/dist/define-Cbhl6QVJ.js +0 -32
  77. package/dist/errors-BAQYcy3_.d.ts +0 -89
  78. package/dist/errors-DeD6wTCl.js +0 -77
  79. package/dist/h3-v1-request-DDGXJ9E7.js +0 -166
  80. package/dist/index-DklG2Etf.d.ts +0 -111
  81. package/dist/operations-NZG5dB8y.js +0 -732
  82. package/dist/page-tools-shared-D-amu6sx.js +0 -53
  83. package/dist/plugin-QElKQYkA.js +0 -725
  84. package/dist/request-DVc3M_AG.js +0 -14
  85. package/dist/src-CRTwnaEG.js +0 -1362
  86. package/dist/types-Cj8K7Vx7.d.ts +0 -176
  87. package/dist/types-Un2dcJWD.d.ts +0 -288
@@ -1,195 +1,201 @@
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;
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["client-DmsSMOzi.js","dist-yIZmvSaU.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,t}from"./dist-yIZmvSaU.js";var n=Object.defineProperty,r=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},i=`button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:var(--vitehub-pill-justify,center);gap:4px;min-width:28px;height:28px;padding:0 8px;border-radius:8px;font:inherit;white-space:nowrap;color:var(--vitehub-pill-text);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition-property:background-color,color,scale;transition-duration:150ms;transition-timing-function:cubic-bezier(.23,1,.32,1)}
3
+ @media(hover:hover){button:where(:not(:disabled):hover){background:var(--vitehub-pill-hover);color:var(--vitehub-pill-strong)}}
4
+ button:where(:not(:disabled):active){scale:.96}
5
+ button[aria-pressed=true],button[aria-expanded=true]{background:var(--vitehub-pill-on);color:var(--vitehub-pill-on-text)}
6
+ :host([aria-busy=true]) button,button[aria-busy=true]{background:var(--vitehub-pill-on);color:var(--vitehub-pill-on-text);cursor:progress}
7
+ button:focus-visible{outline:2px solid var(--vitehub-pill-on);outline-offset:1px}
8
+ button svg{width:14px;height:14px;flex:none}
9
+ @media(any-pointer:coarse){button{min-width:44px;height:44px}}
10
+ @media(prefers-reduced-motion:reduce){button{transition:none}}`,a=`:root,:host{--vh-comment-default-mark:oklch(58.8% .158 241.966);--vh-comment-default-pin:oklch(20.5% 0 0);--vh-comment-default-pin-text:oklch(98.5% 0 0);--vh-comment-default-surface:oklch(100% 0 0);--vh-comment-default-muted:oklch(50% 0 0);--vh-comment-default-ink:oklch(20.5% 0 0);--vh-comment-shadow:oklch(0% 0 0/.18)}:root,:host,:where([data-slot^=comment-mark],[data-slot=comment-pin],[data-slot^=comment-layer-area]){--vh-comment-mark:var(--vh-ui-comment-mark,var(--vh-focus,var(--vh-comment-default-mark)));--vh-comment-pin:var(--vh-ui-comment-pin,var(--vh-primary,var(--vh-comment-default-pin)));--vh-comment-pin-text:var(--vh-ui-comment-pin-text,var(--vh-inverted,var(--vh-comment-default-pin-text)));--vh-comment-surface:var(--vh-ui-comment-surface,var(--vh-bg,var(--vh-comment-default-surface)));--vh-comment-muted:var(--vh-ui-comment-muted,var(--vh-muted,var(--vh-comment-default-muted)));--vh-comment-ink:var(--vh-ui-comment-ink,var(--vh-highlighted,var(--vh-comment-default-ink)));--vh-comment-pin-size:var(--vh-ui-comment-pin-size,28px)}:root.dark,:root[data-theme=dark],:host(.dark),:host([data-theme=dark]){--vh-comment-default-mark:oklch(74.6% .16 232.661);--vh-comment-default-pin:oklch(98.5% 0 0);--vh-comment-default-pin-text:oklch(20.5% 0 0);--vh-comment-default-surface:oklch(14.5% 0 0);--vh-comment-default-muted:oklch(70.8% 0 0);--vh-comment-default-ink:oklch(98.5% 0 0)}@media (prefers-color-scheme:dark){:root:not(.light,.dark,[data-theme]){--vh-comment-default-mark:oklch(74.6% .16 232.661);--vh-comment-default-pin:oklch(98.5% 0 0);--vh-comment-default-pin-text:oklch(20.5% 0 0);--vh-comment-default-surface:oklch(14.5% 0 0);--vh-comment-default-muted:oklch(70.8% 0 0);--vh-comment-default-ink:oklch(98.5% 0 0)}}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]){background:var(--vh-comment-pin);border-radius:calc(var(--vh-comment-pin-size) / 2) calc(var(--vh-comment-pin-size) / 2) calc(var(--vh-comment-pin-size) / 2) 4px;box-shadow:0 0 0 2px var(--vh-comment-surface), 0 2px 8px var(--vh-comment-shadow);box-sizing:border-box;color:var(--vh-comment-pin-text);cursor:pointer;height:var(--vh-comment-pin-size);letter-spacing:.02em;scale:var(--vh-comment-zoom,1);transform-origin:0 100%;width:var(--vh-comment-pin-size);border:0;place-items:center;padding:0;font-size:11px;font-weight:600;line-height:1;transition:scale .12s ease-out,opacity .15s ease-out;display:grid;position:absolute}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-shape=round]{border-radius:calc(var(--vh-comment-pin-size) / 2);transform-origin:50%}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])>img{border-radius:inherit;object-fit:cover;width:100%;height:100%;display:block}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):before{content:"";border-radius:50%;position:absolute;inset:-8px}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):is(:hover,:focus-visible,[data-active=true]){scale:calc(var(--vh-comment-zoom,1) * 1.06)}@media not ((hover:hover) and (pointer:fine)){:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):hover:not(:focus-visible,[data-active=true]){scale:var(--vh-comment-zoom,1)}}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-status=resolved]{filter:grayscale();opacity:.55}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-status=resolved]:not(:has(img)){background:var(--vh-comment-muted)}:is([data-slot=comment-mark-area],[data-slot=comment-layer-area]){border:calc(1px * var(--vh-comment-zoom,1)) solid color-mix(in oklab, var(--vh-comment-ink) 22%, transparent);box-sizing:border-box;pointer-events:none;border-radius:4px;transition:border-color .12s ease-out,background-color .12s ease-out;position:absolute}[data-slot=comment-mark-area][data-status=resolved]{border-color:color-mix(in oklab, var(--vh-comment-muted) 50%, transparent);border-style:dashed}[data-slot=comment-mark-area][data-active=true]{border-color:color-mix(in oklab, var(--vh-comment-ink) 45%, transparent);border-style:solid}:is([data-slot=comment-mark-area][data-draft=true],[data-slot=comment-layer-area]){background:color-mix(in oklab, var(--vh-comment-mark) 16%, transparent);border:calc(2px * var(--vh-comment-zoom,1)) solid var(--vh-comment-mark);border-radius:3px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle]){background:var(--vh-comment-surface);border:1.5px solid var(--vh-comment-mark);box-sizing:border-box;border-radius:50%;width:8px;height:8px;position:absolute}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner^=top]{top:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner^=bottom]{bottom:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner$=left]{left:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner$=right]{right:-5px}:is([data-slot=comment-mark-pin],[data-slot=comment-mark-area])[data-leaving=true],[data-slot=comment-layer-item][data-leaving=true]>*{pointer-events:none;animation:.13s cubic-bezier(.4,0,1,1) forwards vh-comment-mark-leave}[data-slot=comment-mark-area][data-leaving=true]{animation-name:vh-comment-mark-leave-area}@keyframes vh-comment-mark-leave{to{opacity:0;scale:calc(var(--vh-comment-zoom,1) * .8)}}@keyframes vh-comment-mark-leave-area{to{opacity:0;scale:.97}}@media (prefers-reduced-motion:reduce){:is([data-slot=comment-mark-pin],[data-slot=comment-pin],[data-slot=comment-mark-area],[data-slot=comment-layer-area]){transition:none}:is([data-slot=comment-mark-pin],[data-slot=comment-mark-area])[data-leaving=true],[data-slot=comment-layer-item][data-leaving=true]>*{opacity:0;animation:none}}::highlight(vh-comment){background-color:color-mix(in oklab, var(--vh-comment-ink) 13%, transparent)}::highlight(vh-comment-resolved){background-color:color-mix(in oklab, var(--vh-comment-ink) 6%, transparent)}::highlight(vh-comment-active),::highlight(vh-comment-draft){background-color:color-mix(in oklab, var(--vh-comment-ink) 26%, transparent)}`,o=`data-content-field`,s=10;function c(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,e=>`\\${e}`)}function l(e,t){return`[${e}="${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"]`}function u(e){let t=[],n=e;for(;n&&n!==document.documentElement&&t.length<s;){if(n.id)return t.unshift(`#${c(n.id)}`),t.join(` > `);let e=n.getAttribute(o);if(e)return t.unshift(l(o,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 d(e){let t=(e.textContent??``).replace(/\s+/g,` `).trim().slice(0,40),n=e.tagName.toLowerCase();return t?`${n} ${t}`:n}function f(e,t){return t?Math.min(1e3,Math.max(0,Math.round(e/t*1e3))):0}function p(){return Math.max(document.documentElement.scrollWidth,document.documentElement.clientWidth,1)}function m(e){return e.closest(`[data-content-field]`)??void 0}function h(e,t,n){let r=e.getBoundingClientRect(),i=m(e)?.getAttribute(`data-content-field`)??void 0;return{kind:`element`,...i?{field:i}:{},selector:u(e),label:d(e),x:f(t-r.left,r.width),y:f(n-r.top,r.height),page:{x:f(t+window.scrollX,p()),y:Math.max(0,Math.round(n+window.scrollY))},viewport:{width:window.innerWidth}}}var g=/^https?:\/\//i;function _(e){return g.test(e)&&URL.canParse(e)?new URL(e).pathname:e}var v=`comments`,y=`/api/_vitehub/comments`;function b(e){let t=new URL(e).pathname,n=t.lastIndexOf(`${y}/assets/`);return n===-1?y:`${t.slice(0,n)}${y}`}function x(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 S(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`)}`}var C=e({docsBase:`https://vitehub.dev/docs/comments/diagnostics`,codes:{COMMENTS_R0001:{why:({target:e})=>`createAnchor() found nothing to anchor to for ${e}.`,fix:`Pass an element, a non-empty selection, or a point that is over an element of the page.`},COMMENTS_R0013:{why:`The comments request did not get an answer from the server.`,fix:`Check the connection and the app URL, then try again.`},COMMENTS_R0015:{why:`The comment list kept changing while its pages were loading.`,fix:`Refresh again. The previous cache is kept until two complete scans agree.`}}});function w(e){let{code:n,details:r,fix:i,status:a,why:o}=e,s=n.startsWith(`COMMENTS_`)?`https://vitehub.dev/docs/comments/diagnostics/${n.toLowerCase()}`:void 0;return Object.assign(new t({code:n,why:o,...i?{fix:i}:{},...s?{docs:s}:{}}),{status:a,...r?{details:r}:{}})}function T(e,t){return Object.assign(C.COMMENTS_R0013(t===void 0?{}:{cause:t}),{status:e})}function E(e){return Object(e)===e&&!Array.isArray(e)}function D(e,t=``){return`${t.replace(/\/+$/,``)}${y}/attachments/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function O(e={}){let t=e.route??`${(e.base??``).replace(/\/+$/,``)}/api/_vitehub/comments`;return async(n,r={})=>{let i=e.fetch??globalThis.fetch,a=new Headers(typeof e.headers==`function`?await e.headers():e.headers);for(let[e,t]of new Headers(r.headers))a.set(e,t);r.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,`application/json`);let o=typeof e.guest==`function`?e.guest():e.guest;o&&(a.set(`x-vitehub-comments-guest-id`,o.id),a.set(`x-vitehub-comments-guest-name`,encodeURIComponent(o.name)));let s;try{s=await i(`${t}${n}`,{...r,headers:a,credentials:e.credentials??`same-origin`,cache:`no-store`})}catch(e){throw T(0,e)}let c=await s.json().catch(()=>void 0);if(E(c)&&E(c.error)){let{code:e,why:t,fix:n}=c.error;throw typeof e!=`string`||typeof t!=`string`?T(s.status):w({code:e,why:t,...typeof n==`string`?{fix:n}:{},status:s.status})}if(E(c)&&`data`in c){let t={data:c.data,people:Array.isArray(c.people)?c.people:[],...E(c.thread)?{thread:c.thread}:{}};return e.onAnswer?.(t),t}throw T(s.status)}}function k(e){let t=new URLSearchParams;return e.page!==void 0&&t.set(`page`,e.page),e.subject?(t.set(`subjectKind`,e.subject.kind),t.set(`subjectId`,e.subject.id)):e.subjectKind&&t.set(`subjectKind`,e.subjectKind),e.status&&t.set(`status`,e.status),e.mine!==void 0&&t.set(`mine`,String(e.mine)),e.mentions!==void 0&&t.set(`mentions`,String(e.mentions)),e.revision&&t.set(`revision`,String(e.revision.lte)),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.before&&(t.set(`beforeId`,e.before.id),t.set(`beforeUpdatedAt`,String(e.before.updatedAt))),t}var A=e=>`/threads/${encodeURIComponent(e)}`,j=e=>({method:`POST`,...e===void 0?{}:{body:JSON.stringify(e)}});function ee(e={}){let t=O(e),n=(e.base??``).replace(/\/+$/,``);return{async list(e){return(await t(`/threads?${k(e)}`)).data},async get(e){let n=`id`in e?A(e.id):`/scopes/${encodeURIComponent(e.scope)}/threads/${e.n}`;return(await t(n)).data},async create(e){return(await t(`/threads`,j(e))).data},async reply({threadId:e,...n}){let r=await t(`${A(e)}/comments`,j(n));if(!r.thread)throw T(200);return r.thread},async edit({threadId:e,messageId:n,...r}){return(await t(`${A(e)}/comments/${encodeURIComponent(n)}`,{method:`PATCH`,body:JSON.stringify(r)})).data},async delete({threadId:e,messageId:n}){let r=n===void 0?A(e):`${A(e)}/comments/${encodeURIComponent(n)}`;return(await t(r,{method:`DELETE`})).data},async resolve({threadId:e}){return(await t(`${A(e)}/resolve`,j())).data},async reopen({threadId:e}){return(await t(`${A(e)}/reopen`,j())).data},async users({query:e,limit:n,threadId:r,subject:i}){let a=new URLSearchParams({q:e});return n!==void 0&&a.set(`limit`,String(n)),r===void 0?i&&(a.set(`subjectKind`,i.kind),a.set(`subjectId`,i.id)):a.set(`thread`,r),(await t(`/people?${a}`)).data},async upload(e){return(await t(`/attachments`,j(e))).data},attachmentUrl:e=>D(e,n)}}var M=`vitehub-comments-guest`,te=b(import.meta.url);function ne(){try{let e=JSON.parse(localStorage.getItem(M)??`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 re(e){let t={id:ne()?.id??crypto.randomUUID(),name:e};return localStorage.setItem(M,JSON.stringify(t)),t}var N=O({route:te,guest:ne});async function P(e,n={}){try{return[void 0,(await N(e,n)).data]}catch(e){if(e instanceof t)return[{code:e.code,why:e.message,...e.fix?{fix:e.fix}:{}},void 0];throw e}}var F=e=>({method:`POST`,body:JSON.stringify(e)}),ie={session:e=>P(`/session?page=${encodeURIComponent(e)}`),field:(e,t)=>P(`/fields?page=${encodeURIComponent(t)}&field=${encodeURIComponent(e)}`),saveField:(e,t)=>P(`/fields?page=${encodeURIComponent(t)}`,F(e))};function ae(e){let t=ee({base:te.slice(0,-y.length),guest:ne,onAnswer:t=>t.people.length&&e.onPeople(t.people)}),n=t=>async(...n)=>{let r=await t(...n);return e.onChange(),r};return{...t,create:n(n=>{let r=e.contextOf(n),i=n.revision??e.revisionOf?.();return t.create({...n,...r?{context:r}:{},...i===void 0?{}:{revision:i}})}),reply:n(t.reply),edit:n(t.edit),delete:n(t.delete),resolve:n(t.resolve),reopen:n(t.reopen)}}async function oe(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function I(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var L={},se=[],ce=()=>{},le=()=>!1,ue=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),de=e=>e.startsWith(`onUpdate:`),fe=Object.assign,pe=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},me=Object.prototype.hasOwnProperty,R=(e,t)=>me.call(e,t),z=Array.isArray,he=e=>be(e)===`[object Map]`,ge=e=>be(e)===`[object Set]`,_e=e=>be(e)===`[object Date]`,B=e=>typeof e==`function`,V=e=>typeof e==`string`,ve=e=>typeof e==`symbol`,H=e=>typeof e==`object`&&!!e,ye=e=>(H(e)||B(e))&&B(e.then)&&B(e.catch),U=Object.prototype.toString,be=e=>U.call(e),xe=e=>be(e).slice(8,-1),Se=e=>be(e)===`[object Object]`,Ce=e=>V(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,we=I(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),Te=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},Ee=/-\w/g,W=Te(e=>e.replace(Ee,e=>e.slice(1).toUpperCase())),G=/\B([A-Z])/g,K=Te(e=>e.replace(G,`-$1`).toLowerCase()),De=Te(e=>e.charAt(0).toUpperCase()+e.slice(1)),Oe=Te(e=>e?`on${De(e)}`:``),ke=(e,t)=>!Object.is(e,t),Ae=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},je=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Me=e=>{let t=parseFloat(e);return isNaN(t)?e:t},Ne,Pe=()=>Ne||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function Fe(e){if(z(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=V(r)?ze(r):Fe(r);if(i)for(let e in i)t[e]=i[e]}return t}if(V(e)||H(e))return e}var Ie=/;(?![^(]*\))/g,Le=/:([^]+)/,Re=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ze(e){let t={};return e.replace(Re,e=>e.startsWith(`/*`)?``:e).split(Ie).forEach(e=>{if(e){let n=e.split(Le);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function Be(e){let t=``;if(V(e))t=e;else if(z(e))for(let n=0;n<e.length;n++){let r=Be(e[n]);r&&(t+=r+` `)}else if(H(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var Ve=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly`,He=I(Ve);Ve+``;function Ue(e){return!!e||e===``}function We(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=Je(e[i],t[i],n);return r}function Ge(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&Je(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Ke(e,t,n){let r=he(e),i=he(t);if(r||i||(r=ge(e),i=ge(t),r||i))return r&&i?Ge(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!Je(e[r],t[r],n))return!1}return String(e)===String(t)}function qe(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function Je(e,t,n){if(e===t)return!0;let r=_e(e),i=_e(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=ve(e),i=ve(t),r||i?e===t:(r=z(e),i=z(t),r||i?r&&i?qe(e,t,n,We):!1:(r=H(e),i=H(t),r||i?!r||!i?!1:qe(e,t,n,Ke):String(e)===String(t))))}var Ye,Xe=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&Ye&&(Ye.active?(this.parent=Ye,this.index=(Ye.scopes||(Ye.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].pause()}for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes){let n=this.scopes.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}let n=this.effects.slice();for(e=0,t=n.length;e<t;e++)n[e].resume()}}run(e){if(this._active){let t=Ye;try{return Ye=this,e()}finally{Ye=t}}}on(){++this._on===1&&(this.prevScope=Ye,Ye=this)}off(){if(this._on>0&&--this._on===0){if(Ye===this)Ye=this.prevScope;else{let e=Ye;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){let e=this.scopes.slice();for(t=0,n=e.length;t<n;t++)e[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function Ze(){return Ye}var q,Qe=new WeakSet,$e=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Ye&&(Ye.active?Ye.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Qe.has(this)&&(Qe.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||rt(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,gt(this),ot(this);let e=q,t=ft;q=this,ft=!0;try{return this.fn()}finally{st(this),q=e,ft=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)ut(e);this.deps=this.depsTail=void 0,gt(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Qe.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){ct(this)&&this.run()}get dirty(){return ct(this)}},et=0,tt,nt;function rt(e,t=!1){if(e.flags|=8,t){e.next=nt,nt=e;return}e.next=tt,tt=e}function it(){et++}function at(){if(--et>0)return;if(nt){let e=nt;for(nt=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;tt;){let t=tt;for(tt=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function ot(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function st(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),ut(r),dt(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function ct(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(lt(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function lt(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===_t)||(e.globalVersion=_t,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!ct(e))))return;e.flags|=2;let t=e.dep,n=q,r=ft;q=e,ft=!0;try{ot(e);let n=e.fn(e._value);(t.version===0||ke(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{q=n,ft=r,st(e),e.flags&=-3}}function ut(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)ut(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function dt(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var ft=!0,pt=[];function mt(){pt.push(ft),ft=!1}function ht(){let e=pt.pop();ft=e===void 0||e}function gt(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=q;q=void 0;try{t()}finally{q=e}}}var _t=0,vt=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},yt=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!q||!ft||q===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==q)t=this.activeLink=new vt(q,this),q.deps?(t.prevDep=q.depsTail,q.depsTail.nextDep=t,q.depsTail=t):q.deps=q.depsTail=t,bt(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=q.depsTail,t.nextDep=void 0,q.depsTail.nextDep=t,q.depsTail=t,q.deps===t&&(q.deps=e)}return t}trigger(e){this.version++,_t++,this.notify(e)}notify(e){it();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{at()}}};function bt(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)bt(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var xt=new WeakMap,St=Symbol(``),Ct=Symbol(``),wt=Symbol(``);function Tt(e,t,n){if(ft&&q){let t=xt.get(e);t||xt.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new yt),r.map=t,r.key=n),r.track()}}function Et(e,t,n,r,i,a){let o=xt.get(e);if(!o){_t++;return}let s=e=>{e&&e.trigger()};if(it(),t===`clear`)o.forEach(s);else{let i=z(e),a=i&&Ce(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===wt||!ve(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(wt)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(St)),he(e)&&s(o.get(Ct)));break;case`delete`:i||(s(o.get(St)),he(e)&&s(o.get(Ct)));break;case`set`:he(e)&&s(o.get(St))}}at()}function Dt(e){let t=J(e);return t===e||(Tt(t,`iterate`,wt),mn(e))?t:pn(e)?fn(e)?t.map(e=>vn(_n(e))):t.map(vn):t.map(_n)}function Ot(e){return Tt(e=J(e),`iterate`,wt),e}function kt(e,t){return pn(e)?vn(fn(e)?_n(t):t):_n(t)}var At={__proto__:null,[Symbol.iterator](){return jt(this,Symbol.iterator,e=>kt(this,e))},concat(...e){return Dt(this).concat(...e.map(e=>z(e)?Dt(e):e))},entries(){return jt(this,`entries`,e=>(e[1]=kt(this,e[1]),e))},every(e,t){return Pt(this,`every`,e,t,void 0,arguments)},filter(e,t){return Pt(this,`filter`,e,t,e=>e.map(e=>kt(this,e)),arguments)},find(e,t){return Pt(this,`find`,e,t,e=>kt(this,e),arguments)},findIndex(e,t){return Pt(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return Pt(this,`findLast`,e,t,e=>kt(this,e),arguments)},findLastIndex(e,t){return Pt(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return Pt(this,`forEach`,e,t,void 0,arguments)},includes(...e){return It(this,`includes`,e)},indexOf(...e){return It(this,`indexOf`,e)},join(e){return Dt(this).join(e)},lastIndexOf(...e){return It(this,`lastIndexOf`,e)},map(e,t){return Pt(this,`map`,e,t,void 0,arguments)},pop(){return Lt(this,`pop`)},push(...e){return Lt(this,`push`,e)},reduce(e,...t){return Ft(this,`reduce`,e,t)},reduceRight(e,...t){return Ft(this,`reduceRight`,e,t)},shift(){return Lt(this,`shift`)},some(e,t){return Pt(this,`some`,e,t,void 0,arguments)},splice(...e){return Lt(this,`splice`,e)},toReversed(){return Dt(this).toReversed()},toSorted(e){return Dt(this).toSorted(e)},toSpliced(...e){return Dt(this).toSpliced(...e)},unshift(...e){return Lt(this,`unshift`,e)},values(){return jt(this,`values`,e=>kt(this,e))}};function jt(e,t,n){let r=Ot(e),i=r[t],a=i.call(r);if(r!==e&&!mn(e)){if(a[Symbol.toStringTag]===`Array Iterator`){let e=Object.create(Object.getPrototypeOf(a));return e.next=()=>Mt(a.next(),n),i!==Nt[t]&&Object.defineProperties(e,{return:{get(){let e=a.return;return typeof e==`function`?e.bind(a):e}},throw:{get(){let e=a.throw;return typeof e==`function`?e.bind(a):e}}}),e}a._next=a.next,a.next=()=>Mt(a._next(),n)}return a}function Mt(e,t){return e.done||(e.value=t(e.value)),e}var Nt=Array.prototype;function Pt(e,t,n,r,i,a){let o=Ot(e),s=o!==e&&!mn(e),c=o[t];if(c!==Nt[t]){let t=c.apply(e,a);return s?_n(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,kt(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function Ft(e,t,n,r){let i=Ot(e),a=i!==e&&!mn(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=kt(e,t)),n.call(this,t,kt(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?kt(e,c):c}function It(e,t,n){let r=J(e);Tt(r,`iterate`,wt);let i=r[t](...n);return(i===-1||i===!1)&&hn(n[0])?(n[0]=J(n[0]),r[t](...n)):i}function Lt(e,t,n=[]){mt(),it();let r=J(e)[t].apply(e,n);return at(),ht(),r}var Rt=I(`__proto__,__v_isRef,__isVue`),zt=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(ve));function Bt(e){ve(e)||(e=String(e));let t=J(this);return Tt(t,`has`,e),t.hasOwnProperty(e)}var Vt=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?on:an:i?rn:nn).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=z(e);if(!r){let e;if(a&&(e=At[t]))return e;if(t===`hasOwnProperty`)return Bt}let o=Reflect.get(e,t,yn(e)?e:n);if((ve(t)?zt.has(t):Rt(t))||(r||Tt(e,`get`,t),i))return o;if(yn(o)){let e=a&&Ce(t)?o:o.value;return r&&H(e)?un(e):e}return H(o)?r?un(o):cn(o):o}},Ht=class extends Vt{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=z(e)&&Ce(t);if(!this._isShallow){let e=pn(i);if(!mn(n)&&!pn(n)&&(i=J(i),n=J(n)),!a&&yn(i)&&!yn(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:R(e,t),s=Reflect.set(e,t,n,yn(e)?e:r);return e===J(r)&&s&&(o?ke(n,i)&&Et(e,`set`,t,n,i):Et(e,`add`,t,n)),s}deleteProperty(e,t){let n=R(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&Et(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!ve(t)||!zt.has(t))&&Tt(e,`has`,t),n}ownKeys(e){return Tt(e,`iterate`,z(e)?`length`:St),Reflect.ownKeys(e)}},Ut=class extends Vt{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Wt=new Ht,Gt=new Ut,Kt=new Ht(!0),qt=e=>e,Jt=e=>Reflect.getPrototypeOf(e);function Yt(e,t,n){return function(...r){let i=this.__v_raw,a=J(i),o=he(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?qt:t?vn:_n;return!t&&Tt(a,`iterate`,c?Ct:St),fe(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function Xt(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Zt(e,t){let n={get(n){let r=this.__v_raw,i=J(r),a=J(n);e||(ke(n,a)&&Tt(i,`get`,n),Tt(i,`get`,a));let{has:o}=Jt(i),s=t?qt:e?vn:_n;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&Tt(J(t),`iterate`,St),t.size},has(t){let n=this.__v_raw,r=J(n),i=J(t);return e||(ke(t,i)&&Tt(r,`has`,t),Tt(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=J(a),s=t?qt:e?vn:_n;return!e&&Tt(o,`iterate`,St),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return fe(n,e?{add:Xt(`add`),set:Xt(`set`),delete:Xt(`delete`),clear:Xt(`clear`)}:{add(e){let n=J(this),r=Jt(n),i=J(e),a=!t&&!mn(e)&&!pn(e)?i:e;return r.has.call(n,a)||ke(e,a)&&r.has.call(n,e)||ke(i,a)&&r.has.call(n,i)||(n.add(a),Et(n,`add`,a,a)),this},set(e,n){!t&&!mn(n)&&!pn(n)&&(n=J(n));let r=J(this),{has:i,get:a}=Jt(r),o=i.call(r,e);o||=(e=J(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?ke(n,s)&&Et(r,`set`,e,n,s):Et(r,`add`,e,n),this},delete(e){let t=J(this),{has:n,get:r}=Jt(t),i=n.call(t,e);i||=(e=J(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&Et(t,`delete`,e,void 0,a),o},clear(){let e=J(this),t=e.size!==0,n=e.clear();return t&&Et(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Yt(r,e,t)}),n}function Qt(e,t){let n=Zt(e,t);return(r,i,a)=>i===`__v_isReactive`?!e:i===`__v_isReadonly`?e:i===`__v_isShallow`?t:i===`__v_raw`?r:Reflect.get(R(n,i)&&i in r?n:r,i,a)}var $t={get:Qt(!1,!1)},en={get:Qt(!1,!0)},tn={get:Qt(!0,!1)},nn=new WeakMap,rn=new WeakMap,an=new WeakMap,on=new WeakMap;function sn(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function cn(e){return pn(e)?e:dn(e,!1,Wt,$t,nn)}function ln(e){return dn(e,!1,Kt,en,rn)}function un(e){return dn(e,!0,Gt,tn,an)}function dn(e,t,n,r,i){if(!H(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=sn(xe(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function fn(e){return pn(e)?fn(e.__v_raw):!!(e&&e.__v_isReactive)}function pn(e){return!!(e&&e.__v_isReadonly)}function mn(e){return!!(e&&e.__v_isShallow)}function hn(e){return e?!!e.__v_raw:!1}function J(e){let t=e&&e.__v_raw;return t?J(t):e}function gn(e){return!R(e,`__v_skip`)&&Object.isExtensible(e)&&je(e,`__v_skip`,!0),e}var _n=e=>H(e)?cn(e):e,vn=e=>H(e)?un(e):e;function yn(e){return e?e.__v_isRef===!0:!1}function Y(e){return xn(e,!1)}function bn(e){return xn(e,!0)}function xn(e,t){return yn(e)?e:new Sn(e,t)}var Sn=class{constructor(e,t){this.dep=new yt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:J(e),this._value=t?e:_n(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||mn(e)||pn(e);e=n?e:J(e),ke(e,t)&&(this._rawValue=e,this._value=n?e:_n(e),this.dep.trigger())}};function Cn(e){return yn(e)?e.value:e}function wn(e){return B(e)?e():Cn(e)}var Tn={get:(e,t,n)=>t===`__v_raw`?e:Cn(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return yn(i)&&!yn(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function En(e){return fn(e)?e:new Proxy(e,Tn)}var Dn=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new yt(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=_t-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&q!==this)return rt(this,!0),!0}get value(){let e=this.dep.track();return lt(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function On(e,t,n=!1){let r,i;return B(e)?r=e:(r=e.get,i=e.set),new Dn(r,i,n)}var kn={},An=new WeakMap,jn=void 0;function Mn(e,t=!1,n=jn){if(n){let t=An.get(n);t||An.set(n,t=[]),t.push(e)}}function Nn(e,t,n=L){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:mn(e)||i===!1||i===0?Pn(e,1):Pn(e),u,d,f,p,m=!1,h=!1;if(yn(e)?(d=()=>e.value,m=mn(e)):fn(e)?(d=()=>l(e),m=!0):z(e)?(h=!0,m=e.some(e=>fn(e)||mn(e)),d=()=>e.map(e=>{if(yn(e))return e.value;if(fn(e))return l(e);if(B(e))return c?c(e,2):e()})):d=B(e)?t?c?()=>c(e,2):e:()=>{if(f){mt();try{f()}finally{ht()}}let t=jn;jn=u;try{return c?c(e,3,[p]):e(p)}finally{jn=t}}:ce,t&&i){let e=d,t=i===!0?1/0:i;d=()=>Pn(e(),t)}let g=Ze(),_=()=>{u.stop(),g&&g.active&&pe(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{try{return e(...t)}finally{_()}}}let v=h?Array(e.length).fill(kn):kn,y=e=>{if(u.flags&1&&(u.dirty||e)){if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>ke(e,v[t])):ke(n,v))){let e=jn;mt();try{f&&f(),jn=u;let e=[n,v===kn?void 0:h&&v[0]===kn?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{jn=e,ht()}}}else u.run()}};return s&&s(y),u=new $e(d),u.scheduler=o?()=>o(y,!1):y,p=e=>Mn(e,!1,u),f=u.onStop=()=>{let e=An.get(u);if(e){if(c)c(e,4);else for(let t of e)t();An.delete(u)}},t?r?y(!0):v=u.run():o?o(y.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function Pn(e,t=1/0,n){if(t<=0||!H(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,yn(e))Pn(e.value,t,n);else if(z(e))for(let r=0;r<e.length;r++)Pn(e[r],t,n);else if(ge(e)||he(e))e.forEach(e=>{Pn(e,t,n)});else if(Se(e)){for(let r in e)Pn(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Pn(e[r],t,n)}return e}function Fn(e,t,n,r){try{return r?e(...r):e()}catch(e){Ln(e,t,n)}}function In(e,t,n,r){if(B(e)){let i=Fn(e,t,n,r);return i&&ye(i)&&i.catch(e=>{Ln(e,t,n)}),i}if(z(e)){let i=[];for(let a=0;a<e.length;a++)i.push(In(e[a],t,n,r));return i}}function Ln(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||L;if(t){let r=t.parent,i=t.proxy,o=`https://vuejs.org/error-reference/#runtime-${n}`;for(;r;){let t=r.ec;if(t){for(let n=0;n<t.length;n++)if(t[n](e,i,o)===!1)return}r=r.parent}if(a){mt(),Fn(a,null,10,[e,i,o]),ht();return}}Rn(e,n,i,r,o)}function Rn(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var zn=[],Bn=-1,Vn=[],Hn=null,Un=0,Wn=Promise.resolve(),Gn=null;function Kn(e){let t=Gn||Wn;return e?t.then(this?e.bind(this):e):t}function qn(e){let t=Bn+1,n=zn.length;for(;t<n;){let r=t+n>>>1,i=zn[r],a=tr(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function Jn(e){if(!(e.flags&1)){let t=tr(e),n=zn[zn.length-1];!n||!(e.flags&2)&&t>=tr(n)?zn.push(e):zn.splice(qn(t),0,e),e.flags|=1,Yn()}}function Yn(){Gn||=Wn.then(nr)}function Xn(e){if(!z(e))Hn&&e.id===-1?Hn.splice(Un+1,0,e):e.flags&1||(Vn.push(e),e.flags|=1);else for(let t=0;t<e.length;t++)Vn.push(e[t]);Yn()}function Zn(e,t,n,r=Bn+1){for(;r<zn.length;r++){let n=zn[r];if(n&&n.flags&2){if(e&&n.id!==e.uid||t!==void 0&&!(n.id>=t))continue;zn.splice(r,1),r=e?r-1:Bn,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function Qn(e,t,n=0){if(Vn.length){let e=Vn,r=0;if(t){e=[];for(let i=0;i<Vn.length;i++){let a=Vn[i];(a.i===void 0?t.has(a):!a.i||a.i.uid<n)?Vn[r++]=a:e.push(a)}}let i=[...new Set(e)].sort((e,t)=>tr(e)-tr(t));if(Vn.length=r,Hn){for(let e=0;e<i.length;e++)Hn.push(i[e]);return}for(Hn=i,Un=0;Un<Hn.length;Un++){let e=Hn[Un];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}Hn=null,Un=0}}var $n=!1;function er(e,t){if($n){e();return}let n=t===void 0?void 0:new Set(Vn);e(),$n=!0;try{Zn(void 0,t),Qn(void 0,n,t)}finally{$n=!1}}var tr=e=>e.id==null?e.flags&2?-1:1/0:e.id;function nr(e){try{for(Bn=0;Bn<zn.length;Bn++){let e=zn[Bn];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Fn(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Bn<zn.length;Bn++){let e=zn[Bn];e&&(e.flags&=-2)}Bn=-1,zn.length=0,Qn(e),Gn=null,(zn.length||Vn.length)&&nr(e)}}var rr=null,ir=null;function ar(e){let t=rr;return rr=e,ir=e&&e.type.__scopeId||null,t}function or(e,t=rr,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&ta(-1);let i=ar(t),a=Zi.length,o;try{o=e(...n)}finally{for(let e=Zi.length;e>a;e--)$i();ar(i),r._d&&ta(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function sr(e,t,n,r){let i=e.dirs,a=t&&t.dirs;for(let o=0;o<i.length;o++){let s=i[o];a&&(s.oldValue=a[o].value);let c=s.dir[r];c&&(mt(),In(c,n,8,[e.el,s,e,t]),ht())}}function cr(e,t){if(xa){let n=xa.provides,r=xa.parent&&xa.parent.provides;r===n&&(n=xa.provides=Object.create(r)),n[e]=t}}function lr(e,t,n=!1){let r=Sa();if(r||ii){let i=ii?ii._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(i&&e in i)return i[e];if(arguments.length>1)return n&&B(t)?t.call(r&&r.proxy):t}}var ur=Symbol.for(`v-scx`),dr=()=>lr(ur);function X(e,t,n){return fr(e,t,n)}function fr(e,t,n=L){let{immediate:r,deep:i,flush:a,once:o}=n,s=fe({},n),c=t&&r||!t&&a!==`post`,l;if(Oa){if(a===`sync`){let e=dr();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=ce,e.resume=ce,e.pause=ce,e}}let u=xa;s.call=(e,t,n)=>In(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{e.i=u,Pi(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():Jn(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=Nn(e,t,s);return Oa&&(l?l.push(f):c&&f()),f}var pr=new WeakMap,mr=Symbol(`_vte`),hr=e=>e.__isTeleport,gr=e=>e&&(e.disabled||e.disabled===``),_r=e=>e&&(e.defer||e.defer===``),vr=e=>typeof SVGElement<`u`&&e instanceof SVGElement,yr=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,br=(e,t)=>{let n=e&&e.to;return V(n)?t?t(n):null:n},xr={name:`Teleport`,__isTeleport:!0,process(e,t,n,r,i,a,o,s,c,l){let{mc:u,pc:d,pbc:f,o:{insert:p,querySelector:m,createText:h,createComment:g,parentNode:_}}=l,v=gr(t.props),{dynamicChildren:y}=t,b=(e,t,n)=>{e.shapeFlag&16&&u(e.children,t,n,i,a,o,s,c)},x=(e=t)=>{let n=gr(e.props),r=e.target=br(e.props,m),a=Er(r,e,h,p);r&&(o!==`svg`&&vr(r)?o=`svg`:o!==`mathml`&&yr(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),Tr(e,!1)))},S=e=>{let t=()=>{if(pr.get(e)===t){if(pr.delete(e),gr(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),Tr(e,!0)}x(e)}};pr.set(e,t),Pi(t,a)};if(e==null){let e=t.el=h(``),i=t.anchor=h(``);if(p(e,n,r),p(i,n,r),_r(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),Tr(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=pr.get(e);if(u){u.flags|=8,pr.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=gr(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||vr(p)?o=`svg`:(o===`mathml`||yr(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),Bi(e,t,!0)):c||d(e,t,_,b,i,a,o,s,!1),v)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):Sr(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=br(t.props,m);e&&(t.target=e,Sr(t,e,null,l,0))}else g&&Sr(t,p,h,l,1);Tr(t,v)}},remove(e,t,n,{um:r,o:{remove:i}},a){let{shapeFlag:o,children:s,anchor:c,targetStart:l,targetAnchor:u,target:d,props:f}=e,p=gr(f),m=a||!p,h=pr.get(e);if(h&&(h.flags|=8,pr.delete(e)),d&&(i(l),i(u)),a&&i(c),!h&&(p||d)&&o&16)for(let e=0;e<s.length;e++){let i=s[e];r(i,t,n,m,!!i.dynamicChildren)}},move:Sr,hydrate:Cr};function Sr(e,t,n,{o:{insert:r},m:i},a=2){a===0&&(e.targetStart&&r(e.targetStart,t,n),r(e.targetAnchor,t,n),n=e.targetAnchor);let{el:o,anchor:s,shapeFlag:c,children:l,props:u}=e,d=a===2;if(d&&r(o,t,n),!pr.has(e)&&(!d||gr(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function Cr(e,t,n,r,i,a,{o:{nextSibling:o,parentNode:s,querySelector:c,insert:l,createText:u}},d){function f(e,n){let r=n;for(;r;){if(r&&r.nodeType===8){if(r.data===`teleport start anchor`)t.targetStart=r;else if(r.data===`teleport anchor`){t.targetAnchor=r,e._lpa=t.targetAnchor&&o(t.targetAnchor);break}}r=o(r)}}function p(e,t){t.anchor=d(o(e),t,s(e),n,r,i,a)}let m=t.target=br(t.props,c),h=gr(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||Er(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||Er(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),Tr(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var wr=xr;function Tr(e,t){let n=e.ctx;if(n&&n.ut){let r,i;for(t?(r=e.el,i=e.anchor):(r=e.targetStart,i=e.targetAnchor);r&&r!==i;)r.nodeType===1&&r.setAttribute(`data-v-owner`,n.uid),r=r.nextSibling;n.ut()}}function Er(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[mr]=o,e&&(r(a,e,i),r(o,e,i)),o}var Dr=Symbol(`_leaveCb`);function Or(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==Yi){t=n;break}}return t}function kr(e){if(!Ur(e))return hr(e.type)&&e.children?Or(e.children):e;if(e.component)return e.component.subTree;let{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&B(n.default))return n.default()}}function Ar(e,t){if(e.shapeFlag&6&&e.component){e.transition=t;let n=e.component.subTree;Ar(hr(n.type)&&kr(n)||n,t)}else if(e.shapeFlag&128)e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback);else if(e.transition=t,e.type===qi&&z(e.children)){let n=ui(e.children,!1);n&&Ar(n,t)}}function jr(e){if(e.component)return jr(e.component.subTree);if(e.type===qi){let t=z(e.children)&&ui(e.children,!1);return t?jr(t):void 0}if(e.type!==Yi)return e}function Z(e,t){return B(e)?fe({name:e.name},t,{setup:e}):e}function Mr(){let e=Sa();return e?(e.appContext.config.idPrefix||`v`)+`-`+e.ids[0]+e.ids[1]++:``}function Nr(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}function Pr(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var Fr=new WeakMap;function Ir(e,t,n,r,i=!1){if(z(e)){e.forEach((e,a)=>Ir(e,t&&(z(t)?t[a]:t),n,r,i));return}if(Br(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Ir(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?Fa(r.component):r.el,o=i?null:a,{i:s,r:c}=e,l=t&&t.r,u=s.refs===L?s.refs={}:s.refs,d=s.setupState,f=J(d),p=d===L?le:e=>!Pr(u,e)&&R(f,e),m=(e,t)=>!(t&&Pr(u,t));if(l!=null&&l!==c){if(Lr(t),V(l))u[l]=null,p(l)&&(d[l]=null);else if(yn(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(B(c))Fn(c,s,12,[o,u]);else{let t=V(c),r=yn(c);if(t||r){let s=()=>{if(e.f){let n=t?p(c)?d[c]:u[c]:m(c)||!e.k?c.value:u[e.k];if(i)z(n)&&pe(n,a);else if(z(n))n.includes(a)||n.push(a);else if(t)u[c]=[a],p(c)&&(d[c]=u[c]);else{let t=[a];m(c,e.k)&&(c.value=t),e.k&&(u[e.k]=t)}}else t?(u[c]=o,p(c)&&(d[c]=o)):r&&(m(c,e.k)&&(c.value=o),e.k&&(u[e.k]=o))};if(o){let t=()=>{s(),Fr.delete(e)};t.id=-1,Fr.set(e,t),Pi(t,n)}else Lr(e),s()}}}function Lr(e){let t=Fr.get(e);t&&(t.flags|=8,Fr.delete(e))}var Rr=e=>e.nodeType===8;Pe().requestIdleCallback,Pe().cancelIdleCallback;function zr(e,t){if(Rr(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(Rr(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Br=e=>!!e.type.__asyncLoader;function Vr(e){B(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return Z({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>zr(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=xa;if(Nr(e),u)return()=>Hr(u,e);let t=t=>{l=null,Ln(t,e,13,!r)};if(s&&e.suspense||Oa)return p().then(t=>()=>Hr(t,e)).catch(e=>(t(e),()=>r?sa(r,{error:e}):null));let a=Y(!1),c=Y(),d=Y(!!i),f,m;return Yr(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Ur(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Hr(u,e);if(c.value&&r)return sa(r,{error:c.value});if(n&&!d.value)return Hr(n,e)}}})}function Hr(e,t){let{ref:n,props:r,children:i,ce:a}=t.vnode,o=sa(e,r,i);return o.ref=n,o.ce=a,delete t.vnode.ce,o}var Ur=e=>e.type.__isKeepAlive;function Wr(e,t,n=xa,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{mt();let i=Ta(n),a=In(t,n,e,r);return i(),ht(),a};return r?i.unshift(a):i.push(a),a}}var Gr=e=>(t,n=xa)=>{(!Oa||e===`sp`)&&Wr(e,(...e)=>t(...e),n)},Kr=Gr(`m`),qr=Gr(`u`),Jr=Gr(`bum`),Yr=Gr(`um`),Xr=Symbol.for(`v-ndc`),Zr=e=>e?Da(e)?Fa(e):Zr(e.parent):null,Qr=fe(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Zr(e.parent),$root:e=>Zr(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>e.type,$forceUpdate:e=>e.f||=()=>{Jn(e.update)},$nextTick:e=>e.n||=Kn.bind(e.proxy),$watch:e=>ce}),$r=(e,t)=>e!==L&&!e.__isScriptSetup&&R(e,t),ei={get({_:e},t){if(t===`__v_skip`)return!0;let{ctx:n,setupState:r,data:i,props:a,accessCache:o,type:s,appContext:c}=e;if(t[0]!==`$`){let e=o[t];if(e!==void 0)switch(e){case 1:return r[t];case 2:return i[t];case 4:return n[t];case 3:return a[t]}else if($r(r,t))return o[t]=1,r[t];else if(R(a,t))return o[t]=3,a[t];else if(n!==L&&R(n,t))return o[t]=4,n[t];else o[t]=0}let l=Qr[t],u,d;if(l)return t===`$attrs`&&Tt(e.attrs,`get`,``),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==L&&R(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,R(d,t))return d[t]},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return $r(i,t)?(i[t]=n,!0):R(e.props,t)||t[0]===`$`&&t.slice(1)in e?!1:(a[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,props:a,type:o}},s){let c;return!!(n[s]||$r(t,s)||R(a,s)||R(r,s)||R(Qr,s)||R(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?R(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function ti(){return{app:null,config:{isNativeTag:le,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var ni=0;function ri(e,t){return function(n,r=null){B(n)||(n=fe({},n)),r!=null&&!H(r)&&(r=null);let i=ti(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:ni++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:La,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&B(e.install)?(a.add(e),e.install(c,...t)):B(e)&&(a.add(e),e(c,...t))),c},mixin(e){return c},component(e,t){return t?(i.components[e]=t,c):i.components[e]},directive(e,t){return t?(i.directives[e]=t,c):i.directives[e]},mount(a,o,l){if(!s){let u=c._ceVNode||sa(n,r);return u.appContext=i,l===!0?l=`svg`:l===!1&&(l=void 0),o&&t?t(u,a):e(u,a,l),s=!0,c._container=a,a.__vue_app__=c,Fa(u.component)}},onUnmount(e){o.push(e)},unmount(){s&&(In(o,c._instance,16),e(null,c._container),delete c._container.__vue_app__)},provide(e,t){return i.provides[e]=t,c},runWithContext(e){let t=ii;ii=c;try{return e()}finally{ii=t}}};return c}}var ii=null,ai=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${W(t)}Modifiers`]||e[`${K(t)}Modifiers`];function oi(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||L,i=n,a=t.startsWith(`update:`),o=a&&ai(r,t.slice(7));o&&(o.trim&&(i=n.map(e=>V(e)?e.trim():e)),o.number&&(i=i.map(Me)));let s,c=r[s=Oe(t)]||r[s=Oe(W(t))];!c&&a&&(c=r[s=Oe(K(t))]),c&&In(c,e,6,i);let l=r[s+`Once`];if(l){if(!e.emitted)e.emitted={};else if(e.emitted[s])return;e.emitted[s]=!0,In(l,e,6,i)}}function si(e,t,n=!1){let r=t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={};return a?(z(a)?a.forEach(e=>o[e]=null):fe(o,a),H(e)&&r.set(e,o),o):(H(e)&&r.set(e,null),null)}function ci(e,t){return!e||!ue(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),R(e,t[0].toLowerCase()+t.slice(1))||R(e,K(t))||R(e,t))}function li(e){let{type:t,vnode:n,proxy:r,withProxy:i,propsOptions:[a],slots:o,attrs:s,emit:c,render:l,renderCache:u,props:d,data:f,setupState:p,ctx:m,inheritAttrs:h}=e,g=ar(e),_,v;try{if(n.shapeFlag&4){let e=i||r,t=e;_=fa(l.call(t,e,u,d,p,f,m)),v=s}else{let e=t;_=fa(e.length>1?e(d,{attrs:s,slots:o,emit:c}):e(d,null)),v=t.props?s:di(s)}}catch(t){Zi.length=0,Ln(t,e,1),_=sa(Yi)}let y=_;if(v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;e.length&&t&7&&(a&&e.some(de)&&(v=fi(v,a)),y=ua(y,v,!1,!0))}return n.dirs&&(y=ua(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&Ar(hr(y.type)&&kr(y)||y,n.transition),_=y,ar(g),_}function ui(e,t=!0){let n;for(let t=0;t<e.length;t++){let r=e[t];if(na(r)){if(r.type!==Yi||r.children===`v-if`){if(n)return;n=r}}else return}return n}var di=e=>{let t;for(let n in e)(n===`class`||n===`style`||ue(n))&&((t||={})[n]=e[n]);return t},fi=(e,t)=>{let n={};for(let r in e)(!de(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function pi(e,t,n){let{props:r,children:i,component:a}=e,{props:o,children:s,patchFlag:c}=t,l=a.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return r?mi(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(hi(o,r,n)&&!ci(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||mi(r,o,l):!!o;return!1}function mi(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;i<r.length;i++){let a=r[i];if(!R(e,a)||hi(t,e,a)&&!ci(n,a))return!0}return!1}function hi(e,t,n){let r=e[n],i=t[n];return n===`style`&&H(r)&&H(i)?!Je(r,i):r!==i}function gi({vnode:e,parent:t,suspense:n},r){for(;t;){let n=t.subTree;if(n.suspense&&n.suspense.activeBranch===e&&(n.suspense.vnode.el=n.el=r,e=n),n===e)(e=t.vnode).el=r,t=t.parent;else break}n&&n.activeBranch===e&&(n.vnode.el=r)}var _i={},vi=()=>Object.create(_i),yi=e=>Object.getPrototypeOf(e)===_i;function bi(e,t,n,r=!1){let i={},a=vi();e.propsDefaults=Object.create(null),Si(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);e.props=n?r?i:ln(i):e.type.props?i:a,e.attrs=a}function xi(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=J(i),[c]=e.propsOptions,l=!1;if((r||o>0)&&!(o&16)){if(o&8){let n=e.vnode.dynamicProps;for(let r=0;r<n.length;r++){let o=n[r];if(ci(e.emitsOptions,o))continue;let u=t[o];if(c){if(R(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=W(o);i[t]=Ci(c,s,t,u,e,!1)}}else u!==a[o]&&(a[o]=u,l=!0)}}}else{Si(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!R(t,a)&&((r=K(a))===a||!R(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=Ci(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!R(t,e))&&(delete a[e],l=!0)}l&&Et(e.attrs,`set`,``)}function Si(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(we(c))continue;let l=t[c],u;i&&R(i,u=W(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:ci(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=J(n),r=s||L;for(let o=0;o<a.length;o++){let s=a[o];n[s]=Ci(i,t,s,r[s],e,!R(r,s))}}return o}function Ci(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=R(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&B(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=Ta(i);r=a[n]=e.call(null,t),o()}}else r=e;i.ce&&i.ce._setProp(n,r)}o[0]&&(a&&!e?r=!1:o[1]&&(r===``||r===K(n))&&(r=!0))}return r}function wi(e,t,n=!1){let r=t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[];if(!a)return H(e)&&r.set(e,se),se;if(z(a))for(let e=0;e<a.length;e++){let t=W(a[e]);Ti(t)&&(o[t]=L)}else if(a)for(let e in a){let t=W(e);if(Ti(t)){let n=a[e],r=o[t]=z(n)||B(n)?{type:n}:fe({},n),i=r.type,c=!1,l=!0;if(z(i))for(let e=0;e<i.length;++e){let t=i[e],n=B(t)&&t.name;if(n===`Boolean`){c=!0;break}n===`String`&&(l=!1)}else c=B(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||R(r,`default`))&&s.push(t)}}let c=[o,s];return H(e)&&r.set(e,c),c}function Ti(e){return e[0]!==`$`&&!we(e)}var Ei=e=>e===`_`||e===`_ctx`||e===`$stable`,Di=e=>z(e)?e.map(fa):[fa(e)],Oi=(e,t,n)=>{if(t._n)return t;let r=or((...e)=>Di(t(...e)),n);return r._c=!1,r},ki=(e,t,n)=>{let r=e._ctx;for(let n in e){if(Ei(n))continue;let i=e[n];if(B(i))t[n]=Oi(n,i,r);else if(i!=null){let e=Di(i);t[n]=()=>e}}},Ai=(e,t)=>{let n=Di(t);e.slots.default=()=>n},ji=(e,t,n)=>{for(let r in t)(n||!Ei(r))&&(e[r]=t[r])},Mi=(e,t,n)=>{let r=e.slots=vi();if(e.vnode.shapeFlag&32){let e=t._;e?(ji(r,t,n),n&&je(r,`_`,e,!0)):ki(t,r)}else t&&Ai(e,t)},Ni=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=L;if(r.shapeFlag&32){let e=t._;e?n&&e===1?a=!1:ji(i,t,n):(a=!t.$stable,ki(t,i)),o=t}else t&&(Ai(e,t),o={default:1});if(a)for(let e in i)!Ei(e)&&o[e]==null&&delete i[e]},Pi=Ki;function Fi(e){return Ii(e)}function Ii(e,t){let n=Pe();n.__VUE__=!0;let{insert:r,remove:i,patchProp:a,createElement:o,createText:s,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:f,setScopeId:p=ce,insertStaticContent:m}=e,h=(e,t,n,r=null,i=null,a=null,o=void 0,s=null,c=!!t.dynamicChildren)=>{if(e===t)return;e&&!ra(e,t)&&(r=I(e),P(e,i,a,!0),e=null),t.patchFlag===-2&&(c=!1,t.dynamicChildren=null),t.dynamicChildren&&e&&e.dynamicChildren&&e.dynamicChildren.hasOnce&&(t.dynamicChildren===se&&(t.dynamicChildren=[]),t.dynamicChildren.hasOnce=!0);let{type:l,ref:u,shapeFlag:d}=t;switch(l){case Ji:g(e,t,n,r);break;case Yi:_(e,t,n,r);break;case Xi:e??v(t,n,r,o);break;case qi:O(e,t,n,r,i,a,o,s,c);break;default:d&1?x(e,t,n,r,i,a,o,s,c):d&6?k(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,ue)}u!=null&&i?Ir(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&Ir(e.ref,null,a,e,!0)},g=(e,t,n,i)=>{if(e==null)r(t.el=s(t.children),n,i);else{let n=t.el=e.el;t.children!==e.children&&l(n,t.children)}},_=(e,t,n,i)=>{e==null?r(t.el=c(t.children||``),n,i):t.el=e.el},v=(e,t,n,r)=>{[e.el,e.anchor]=m(e.children,t,n,r,e.el,e.anchor)},y=({el:e,anchor:t},n,i)=>{let a;for(;e&&e!==t;)a=f(e),r(e,n,i),e=a;r(t,n,i)},b=({el:e,anchor:t})=>{let n;for(;e&&e!==t;)n=f(e),i(e),e=n;i(t)},x=(e,t,n,r,i,a,o,s,c)=>{if(t.type===`svg`?o=`svg`:t.type===`math`&&(o=`mathml`),e==null)S(t,n,r,i,a,o,s,c);else{let n=e.el&&e.el._isVueCE?e.el:null;try{n&&n._beginPatch(),T(e,t,i,a,o,s,c)}finally{n&&n._endPatch()}}},S=(e,t,n,i,s,c,l,d)=>{let f,p,{props:m,shapeFlag:h,transition:g,dirs:_}=e;if(f=e.el=o(e.type,c,m&&m.is,m),h&8?u(f,e.children):h&16&&w(e.children,f,null,i,s,Li(e,c),l,d),_&&sr(e,null,i,`created`),C(f,e,e.scopeId,l,i),m){for(let e in m)e!==`value`&&!we(e)&&a(f,e,null,m[e],c,i);`value`in m&&a(f,`value`,null,m.value,c),(p=m.onVnodeBeforeMount)&&ga(p,i,e)}_&&sr(e,null,i,`beforeMount`);let v=zi(s,g);v&&g.beforeEnter(f),r(f,t,n),((p=m&&m.onVnodeMounted)||v||_)&&Pi(()=>{try{p&&ga(p,i,e),v&&g.enter(f),_&&sr(e,null,i,`mounted`)}finally{}},s)},C=(e,t,n,r,i)=>{if(n&&p(e,n),r)for(let t=0;t<r.length;t++)p(e,r[t]);if(i){let n=i.subTree;if(t===n||Gi(n.type)&&(n.ssContent===t||n.ssFallback===t)){let t=i.vnode;C(e,t,t.scopeId,t.slotScopeIds,i.parent)}}},w=(e,t,n,r,i,a,o,s,c=0)=>{for(let l=c;l<e.length;l++){let c=e[l]=s?pa(e[l]):fa(e[l]);h(null,c,t,n,r,i,a,o,s)}},T=(e,t,n,r,i,o,s)=>{let c=t.el=e.el,{patchFlag:l,dynamicChildren:d,dirs:f}=t;l|=e.patchFlag&16;let p=e.props||L,m=t.props||L,h;if(n&&Ri(n,!1),(h=m.onVnodeBeforeUpdate)&&ga(h,n,t,e),f&&sr(t,e,n,`beforeUpdate`),n&&Ri(n,!0),d&&(!e.dynamicChildren||e.dynamicChildren.length!==d.length)&&(l=0,s=!1,d=null),(p.innerHTML&&m.innerHTML==null||p.textContent&&m.textContent==null)&&u(c,``),d?E(e.dynamicChildren,d,c,n,r,Li(t,i),o):s||te(e,t,c,null,n,r,Li(t,i),o,!1),l>0){if(l&16)D(c,p,m,n,i);else if(l&2&&p.class!==m.class&&a(c,`class`,null,m.class,i),l&4&&a(c,`style`,p.style,m.style,i),l&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let r=e[t],o=p[r],s=m[r];(s!==o||r===`value`)&&a(c,r,o,s,i,n)}}l&1&&e.children!==t.children&&u(c,t.children)}else!s&&d==null&&D(c,p,m,n,i);((h=m.onVnodeUpdated)||f)&&Pi(()=>{h&&ga(h,n,t,e),f&&sr(t,e,n,`updated`)},r)},E=(e,t,n,r,i,a,o)=>{for(let s=0;s<t.length;s++){let c=e[s],l=t[s],u=c.el||Wi(c),f=u&&(c.type===qi||!ra(c,l)||c.shapeFlag&198)?d(u):n;h(c,l,f,null,r,i,a,o,!0)}},D=(e,t,n,r,i)=>{if(t!==n){if(t!==L)for(let o in t)!we(o)&&!(o in n)&&a(e,o,t[o],null,i,r);for(let o in n){if(we(o))continue;let s=n[o],c=t[o];s!==c&&o!==`value`&&a(e,o,c,s,i,r)}`value`in n&&a(e,`value`,t.value,n.value,i)}},O=(e,t,n,i,a,o,c,l,u)=>{let d=t.el=e?e.el:s(``),f=t.anchor=e?e.anchor:s(``),{patchFlag:p,dynamicChildren:m,slotScopeIds:h}=t;h&&(l=l?l.concat(h):h),e==null?(r(d,n,i),r(f,n,i),w(t.children||[],n,f,a,o,c,l,u)):p>0&&p&64&&m&&e.dynamicChildren&&e.dynamicChildren.length===m.length?(E(e.dynamicChildren,m,n,a,o,c,l),(t.key!=null||a&&t===a.subTree)&&Bi(e,t,!0)):te(e,t,n,f,a,o,c,l,u)},k=(e,t,n,r,i,a,o,s,c)=>{t.slotScopeIds=s,e==null?t.shapeFlag&512?i.ctx.activate(t,n,r,o,c):A(t,n,r,i,a,o,c):j(e,t,c)},A=(e,t,n,r,i,a,o)=>{let s=e.component=ba(e,r,i);if(Ur(e)&&(s.ctx.renderer=ue),ka(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,ee,o,a),!e.el){let r=s.subTree=sa(Yi);_(null,r,t,n),e.placeholder=r.el}}else ee(s,e,t,n,i,a,o)},j=(e,t,n)=>{let r=t.component=e.component;if(pi(e,t,n)){if(r.asyncDep&&!r.asyncResolved){t.el=e.el,t.placeholder=e.placeholder,M(r,t,n);return}r.next=t,r.update()}else t.el=e.el,t.placeholder=e.placeholder,r.vnode=t},ee=(e,t,n,r,i,a,o)=>{let s=()=>{if(e.isMounted){let{next:t,bu:n,u:r,parent:s,vnode:c}=e;{let n=Hi(e);if(n){t&&(t.el=c.el,M(e,t,o)),n.asyncDep.then(()=>{Pi(()=>{e.isUnmounted||l()},i)});return}}let u=t,f;Ri(e,!1),t?(t.el=c.el,M(e,t,o)):t=c,n&&Ae(n),(f=t.props&&t.props.onVnodeBeforeUpdate)&&ga(f,s,t,c),Ri(e,!0);let p=li(e),m=e.subTree;e.subTree=p,h(m,p,d(m.el),I(m),e,i,a),t.el=p.el,u===null&&gi(e,p.el),r&&Pi(r,i),(f=t.props&&t.props.onVnodeUpdated)&&Pi(()=>ga(f,s,t,c),i)}else{let o,{el:s,props:c}=t,{bm:l,m:u,parent:d,root:f,type:p}=e,m=Br(t);if(Ri(e,!1),l&&Ae(l),!m&&(o=c&&c.onVnodeBeforeMount)&&ga(o,d,t),Ri(e,!0),s&&fe){let t=()=>{e.subTree=li(e),fe(s,e.subTree,e,i,null)};m&&p.__asyncHydrate?p.__asyncHydrate(s,e,t):t()}else{f.ce&&f.ce._hasShadowRoot()&&f.ce._injectChildStyle(p,e.parent?e.parent.type:void 0);let o=e.subTree=li(e);h(null,o,n,r,e,i,a),t.el=o.el}if(u&&Pi(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;Pi(()=>ga(o,d,e),i)}(t.shapeFlag&256||d&&Br(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&Pi(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new $e(s);e.scope.off();let l=e.update=c.run.bind(c),u=e.job=c.runIfDirty.bind(c);u.i=e,u.id=e.uid,c.scheduler=()=>Jn(u),Ri(e,!0),l()},M=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,xi(e,t.props,r,n),Ni(e,t.children,n),mt(),Zn(e),ht()},te=(e,t,n,r,i,a,o,s,c=!1)=>{let l=e&&e.children,d=e?e.shapeFlag:0,f=t.children,{patchFlag:p,shapeFlag:m}=t;if(p>0){if(p&128){re(l,f,n,r,i,a,o,s,c);return}if(p&256){ne(l,f,n,r,i,a,o,s,c);return}}m&8?(d&16&&oe(l,i,a),f!==l&&u(n,f)):d&16?m&16?re(l,f,n,r,i,a,o,s,c):oe(l,i,a,!0):(d&8&&u(n,``),m&16&&w(f,n,r,i,a,o,s,c))},ne=(e,t,n,r,i,a,o,s,c)=>{e||=se,t||=se;let l=e.length,u=t.length,d=Math.min(l,u),f=0;for(;f<d;f++){let r=t[f]=c?pa(t[f]):fa(t[f]);h(e[f],r,n,null,i,a,o,s,c)}l>u?oe(e,i,a,!0,!1,d):w(t,n,r,i,a,o,s,c,d)},re=(e,t,n,r,i,a,o,s,c)=>{let l=0,u=t.length,d=e.length-1,f=u-1;for(;l<=d&&l<=f;){let r=e[l],u=t[l]=c?pa(t[l]):fa(t[l]);if(ra(r,u))h(r,u,n,null,i,a,o,s,c);else break;l++}for(;l<=d&&l<=f;){let r=e[d],l=t[f]=c?pa(t[f]):fa(t[f]);if(ra(r,l))h(r,l,n,null,i,a,o,s,c);else break;d--,f--}if(l>d){if(l<=f){let e=f+1,d=e<u?t[e].el:r;for(;l<=f;)h(null,t[l]=c?pa(t[l]):fa(t[l]),n,d,i,a,o,s,c),l++}}else if(l>f)for(;l<=d;)P(e[l],i,a,!0),l++;else{let p=l,m=l,g=new Map;for(l=m;l<=f;l++){let e=t[l]=c?pa(t[l]):fa(t[l]);e.key!=null&&g.set(e.key,l)}let _,v=0,y=f-m+1,b=!1,x=0,S=Array(y);for(l=0;l<y;l++)S[l]=0;for(l=p;l<=d;l++){let r=e[l];if(v>=y){P(r,i,a,!0);continue}let u;if(r.key!=null)u=g.get(r.key);else for(_=m;_<=f;_++)if(S[_-m]===0&&ra(r,t[_])){u=_;break}u===void 0?P(r,i,a,!0):(S[u-m]=l+1,u>=x?x=u:b=!0,h(r,t[u],n,null,i,a,o,s,c),v++)}let C=b?Vi(S):se;for(_=C.length-1,l=y-1;l>=0;l--){let e=m+l,d=t[e],f=t[e+1],p=e+1<u?f.el||Wi(f):r;S[l]===0?h(null,d,n,p,i,a,o,s,c):b&&(_<0||l!==C[_]?N(d,n,p,2):_--)}}},N=(e,t,n,a,o=null)=>{let{el:s,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){N(e.component.subTree,t,n,a);return}if(d&128){e.suspense.move(t,n,a);return}if(d&64){c.move(e,t,n,ue);return}if(c===qi){r(s,t,n);for(let e=0;e<u.length;e++)N(u[e],t,n,a);r(e.anchor,t,n);return}if(c===Xi){y(e,t,n);return}if(a!==2&&d&1&&l){if(a===0)l.persisted&&!s[Dr]?r(s,t,n):(l.beforeEnter(s),r(s,t,n),Pi(()=>l.enter(s),o));else{let{leave:a,delayLeave:o,afterLeave:c}=l,u=()=>{e.ctx.isUnmounted?i(s):r(s,t,n)},d=()=>{let e=s._isLeaving||!!s[Dr];s._isLeaving&&s[Dr](!0),l.persisted&&!e?u():a(s,()=>{u(),c&&c()})};o?o(s,u,d):d()}}else r(s,t,n)},P=(e,t,n,r=!1,i=!1)=>{let{type:a,props:o,ref:s,children:c,dynamicChildren:l,shapeFlag:u,patchFlag:d,dirs:f,cacheIndex:p,memo:m}=e;if((d===-2||l&&l.hasOnce)&&(i=!1),s!=null&&(mt(),Ir(s,null,n,e,!0),ht()),p!=null&&(!e.ctx||e.ctx===t)&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let h=u&1&&f,g=!Br(e),_;if(g&&(_=o&&o.onVnodeBeforeUnmount)&&ga(_,t,e),u&6)ae(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}h&&sr(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,ue,r):l&&!l.hasOnce&&(a!==qi||d>0&&d&64)?oe(l,t,n,!1,!0):(a===qi&&d&384||!i&&u&16)&&oe(c,t,n),r&&F(e)}let v=m!=null&&p==null;(g&&(_=o&&o.onVnodeUnmounted)||h||v)&&Pi(()=>{_&&ga(_,t,e),h&&sr(e,null,t,`unmounted`),v&&(e.el=null)},n)},F=e=>{let{type:t,el:n,anchor:r,transition:a}=e,o=t===qi;if(o&&!a){ie(n,r);return}if(t===Xi){b(e),a&&!a.persisted&&a.afterLeave&&a.afterLeave();return}let s=o?jr(e):e,c=()=>{o?d(n)&&ie(n,r):i(n),a&&!a.persisted&&a.afterLeave&&a.afterLeave()};if(s&&s.shapeFlag&1&&a&&!a.persisted){let{leave:e,delayLeave:t}=a,n=s.el,r=()=>e(n,c);t?t(n,c,r):r()}else c()},ie=(e,t)=>{let n;for(;e!==t;)n=f(e),i(e),e=n;i(t)},ae=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;Ui(c),Ui(l),r&&Ae(r),i.stop(),a?(a.flags|=8,P(o,e,t,n)):e.vnode.el&&o&&(o.transition=e.vnode.transition,P(o,e,t,n)),s&&Pi(s,t),Pi(()=>{e.isUnmounted=!0},t)},oe=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)P(e[o],t,n,r,i)},I=e=>{if(e.shapeFlag&6)return I(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=f(e.anchor||e.el),n=t&&t[mr];return n?f(n):t},le=(e,t,n)=>{er(()=>{e==null?t._vnode&&P(t._vnode,null,null,!0):h(t._vnode||null,e,t,null,null,null,n),t._vnode=e},e&&t._vnode?void 0:e&&e.component?e.component.uid:ya())},ue={p:h,um:P,m:N,r:F,mt:A,mc:w,pc:te,pbc:E,n:I,o:e},de,fe;return t&&([de,fe]=t(ue)),{render:le,hydrate:de,createApp:ri(le,de)}}function Li({type:e,props:t},n){return n===`svg`&&e===`foreignObject`||n===`mathml`&&e===`annotation-xml`&&t&&t.encoding&&t.encoding.includes(`html`)?void 0:n}function Ri({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function zi(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Bi(e,t,n=!1){let r=e.children,i=t.children;if(z(r)&&z(i))for(let e=0;e<r.length;e++){let t=r[e],a=i[e];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=i[e]=pa(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&Bi(t,a)),a.type===Ji&&(a.patchFlag===-1&&(a=i[e]=pa(a)),a.el=t.el),a.type===Yi&&!a.el&&(a.el=t.el)}}function Vi(e){let t=e.slice(),n=[0],r,i,a,o,s,c=e.length;for(r=0;r<c;r++){let c=e[r];if(c!==0){if(i=n[n.length-1],e[i]<c){t[r]=i,n.push(r);continue}for(a=0,o=n.length-1;a<o;)s=a+o>>1,e[n[s]]<c?a=s+1:o=s;c<e[n[a]]&&(a>0&&(t[r]=n[a-1]),n[a]=r)}}for(a=n.length,o=n[a-1];a-->0;)n[a]=o,o=t[o];return n}function Hi(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:Hi(t)}function Ui(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function Wi(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?Wi(t.subTree):null}var Gi=e=>e.__isSuspense;function Ki(e,t){t&&t.pendingBranch?z(e)?t.effects.push(...e):t.effects.push(e):Xn(e)}var qi=Symbol.for(`v-fgt`),Ji=Symbol.for(`v-txt`),Yi=Symbol.for(`v-cmt`),Xi=Symbol.for(`v-stc`),Zi=[],Qi=null;function $i(){Zi.pop(),Qi=Zi[Zi.length-1]||null}var ea=1;function ta(e,t=!1){ea+=e,e<0&&Qi&&t&&(Qi.hasOnce=!0)}function na(e){return e?e.__v_isVNode===!0:!1}function ra(e,t){return e.type===t.type&&e.key===t.key}var ia=({key:e})=>e??null,aa=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:V(e)||yn(e)||B(e)?{i:rr,r:e,k:t,f:!!n}:e);function oa(e,t=null,n=null,r=0,i=null,a=e===qi?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&ia(t),ref:t&&aa(t),scopeId:ir,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:r,dynamicProps:i,dynamicChildren:null,appContext:null,ctx:rr};return s?(ma(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=V(n)?8:16),ea>0&&!o&&Qi&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&Qi.push(c),c}var sa=ca;function ca(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===Xr)&&(e=Yi),na(e)){let r=ua(e,t,!0);return n&&ma(r,n),ea>0&&!a&&Qi&&(r.shapeFlag&6?Qi[Qi.indexOf(e)]=r:Qi.push(r)),r.patchFlag=-2,r}if(Ia(e)&&(e=e.__vccOpts),t){t=la(t);let{class:e,style:n}=t;e&&!V(e)&&(t.class=Be(e)),H(n)&&(hn(n)&&!z(n)&&(n=fe({},n)),t.style=Fe(n))}let o=V(e)?1:Gi(e)?128:hr(e)?64:H(e)?4:B(e)?2:0;return oa(e,t,n,r,i,o,a,!0)}function la(e){return e?hn(e)||yi(e)?fe({},e):e:null}function ua(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?ha(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&ia(l),ref:t&&t.ref?n&&a?z(a)?a.concat(aa(t)):[a,aa(t)]:aa(t):a,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:s,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==qi?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&ua(e.ssContent),ssFallback:e.ssFallback&&ua(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce,cacheIndex:e.cacheIndex};return c&&r&&Ar(u,c.clone(u)),u}function da(e=` `,t=0){return sa(Ji,null,e,t)}function fa(e){return e==null||typeof e==`boolean`?sa(Yi):z(e)?sa(qi,null,e.slice()):na(e)?pa(e):sa(Ji,null,String(e))}function pa(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:ua(e)}function ma(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(z(t))n=16;else if(typeof t==`object`){if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),ma(e,n()),n._c&&(n._d=!0));return}{n=32;let r=t._;!r&&!yi(t)?t._ctx=rr:r===3&&rr&&(rr.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}}else if(B(t)){if(r&65){ma(e,{default:t});return}t={default:t,_ctx:rr},n=32}else t=String(t),r&64?(n=16,t=[da(t)]):n=8;e.children=t,e.shapeFlag|=n}function ha(...e){let t={};for(let n=0;n<e.length;n++){let r=e[n];for(let e in r)if(e===`class`)t.class!==r.class&&(t.class=Be([t.class,r.class]));else if(e===`style`)t.style=Fe([t.style,r.style]);else if(ue(e)){let n=t[e],i=r[e];i&&n!==i&&!(z(n)&&n.includes(i))?t[e]=n?[].concat(n,i):i:i==null&&n==null&&!de(e)&&(t[e]=i)}else e!==``&&(t[e]=r[e])}return t}function ga(e,t,n,r=null){In(e,t,7,[n,r])}var _a=ti(),va=0;function ya(){return va}function ba(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||_a,a={uid:va++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Xe(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(i.provides),ids:t?t.ids:[``,0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:wi(r,i),emitsOptions:si(r,i),emit:null,emitted:null,propsDefaults:L,inheritAttrs:r.inheritAttrs,ctx:L,data:L,props:L,attrs:L,slots:L,refs:L,setupState:L,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return a.ctx={_:a},a.root=t?t.root:a,a.emit=oi.bind(null,a),e.ce&&e.ce(a),a}var xa=null,Sa=()=>xa||rr,Ca,wa;{let e=Pe(),t=(t,n)=>{let r;return(r=e[t])||(r=e[t]=[]),r.push(n),e=>{r.length>1?r.forEach(t=>t(e)):r[0](e)}};Ca=t(`__VUE_INSTANCE_SETTERS__`,e=>xa=e),wa=t(`__VUE_SSR_SETTERS__`,e=>Oa=e)}var Ta=e=>{let t=xa;return Ca(e),e.scope.on(),()=>{e.scope.off(),Ca(t)}},Ea=()=>{xa&&xa.scope.off(),Ca(null)};function Da(e){return e.vnode.shapeFlag&4}var Oa=!1;function ka(e,t=!1,n=!1){t&&wa(t);let{props:r,children:i}=e.vnode,a=Da(e);bi(e,r,a,t),Mi(e,i,n||t);let o=a?Aa(e,t):void 0;return t&&wa(!1),o}function Aa(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,ei);let{setup:r}=n;if(r){mt();let n=e.setupContext=r.length>1?Pa(e):null,i=Ta(e),a=Fn(r,e,0,[e.props,n]),o=ye(a);if(ht(),i(),(o||e.sp)&&!Br(e)&&Nr(e),o){if(a.then(Ea,Ea),t)return a.then(n=>{wa(!0);try{ja(e,n,t)}finally{wa(!1)}}).catch(t=>{Ln(t,e,0)});e.asyncDep=a}else ja(e,a,t)}else Ma(e,t)}function ja(e,t,n){B(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:H(t)&&(e.setupState=En(t)),Ma(e,n)}function Ma(e,t,n){let r=e.type;e.render||=r.render||ce}var Na={get(e,t){return Tt(e,`get`,``),e[t]}};function Pa(e){return{attrs:new Proxy(e.attrs,Na),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function Fa(e){return e.exposed?e.exposeProxy||=new Proxy(En(gn(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Qr)return Qr[n](e)},has(e,t){return t in e||t in Qr}}):e.proxy}function Ia(e){return B(e)&&`__vccOpts`in e}var Q=(e,t)=>On(e,t,Oa);function $(e,t,n){try{ta(-1);let r=arguments.length;return r===2?H(t)&&!z(t)?na(t)?sa(e,null,[t]):sa(e,t):sa(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&na(n)&&(n=[n]),sa(e,t,n))}finally{ta(1)}}var La=`3.5.44`,Ra=void 0,za=typeof window<`u`&&window.trustedTypes;if(za)try{Ra=za.createPolicy(`vue`,{createHTML:e=>e})}catch{}var Ba=Ra?e=>Ra.createHTML(e):e=>e,Va=`http://www.w3.org/2000/svg`,Ha=`http://www.w3.org/1998/Math/MathML`,Ua=typeof document<`u`?document:null,Wa=Ua&&Ua.createElement(`template`),Ga={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?Ua.createElementNS(Va,e):t===`mathml`?Ua.createElementNS(Ha,e):n?Ua.createElement(e,{is:n}):Ua.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>Ua.createTextNode(e),createComment:e=>Ua.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Ua.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),i!==a&&(i=i.nextSibling););else{Wa.innerHTML=Ba(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=Wa.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Ka=Symbol(`_vtc`);function qa(e,t,n){let r=e[Ka];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var Ja=Symbol(`_vod`),Ya=Symbol(`_vsh`),Xa=Symbol(``),Za=/(?:^|;)\s*display\s*:/;function Qa(e,t,n){let r=e.style,i=V(n),a=!1;if(n&&!i){if(t){if(V(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??eo(r,t,``)}else for(let e in t)n[e]??eo(r,e,``)}for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?eo(r,i,``):io(e,i,!V(t)&&t?t[i]:void 0,o)||eo(r,i,o)}}else if(i){if(t!==n){let e=r[Xa];e&&(n+=`;`+e),r.cssText=n,a=Za.test(n)}}else t&&e.removeAttribute(`style`);Ja in e&&((!i||t!==n)&&(e[Ja]=a?r.display:``),e[Ya]&&(r.display=`none`))}var $a=/\s*!important$/;function eo(e,t,n){if(z(n))n.forEach(n=>eo(e,t,n));else if(n??=``,t.startsWith(`--`))$a.test(n)?e.setProperty(t,n.replace($a,``),`important`):e.setProperty(t,n);else{let r=ro(e,t);$a.test(n)?e.setProperty(K(r),n.replace($a,``),`important`):e[r]=n}}var to=[`Webkit`,`Moz`,`ms`],no={};function ro(e,t){let n=no[t];if(n)return n;let r=W(t);if(r!==`filter`&&r in e)return no[t]=r;r=De(r);for(let n=0;n<to.length;n++){let i=to[n]+r;if(i in e)return no[t]=i}return t}function io(e,t,n,r){return e.tagName===`TEXTAREA`&&(t===`width`||t===`height`)&&V(r)&&n===r}var ao=`http://www.w3.org/1999/xlink`;function oo(e,t,n,r,i,a=He(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(ao,t.slice(6,t.length)):e.setAttributeNS(ao,t,n):n==null||a&&!Ue(n)?e.removeAttribute(t):e.setAttribute(t,a?``:ve(n)?String(n):n)}function so(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?Ba(n):n);return}let a=e.tagName;if(t===`value`&&a!==`PROGRESS`&&!a.includes(`-`)){let r=a===`OPTION`?e.getAttribute(`value`)||``:e.value,i=n==null?e.type===`checkbox`?`on`:``:String(n);(r!==i||!(`_value`in e))&&(e.value=i),n??e.removeAttribute(t),e._value=n;return}let o=!1;if(n===``||n==null){let r=typeof e[t];r===`boolean`?n=Ue(n):n==null&&r===`string`?(n=``,o=!0):r===`number`&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function co(e,t,n,r){e.addEventListener(t,n,r)}function lo(e,t,n,r){e.removeEventListener(t,n,r)}var uo=Symbol(`_vei`);function fo(e,t,n,r,i=null){let a=e[uo]||(e[uo]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=ho(t);r?co(e,n,a[t]=yo(r,i),s):o&&(lo(e,n,o,s),a[t]=void 0)}}var po=/(Once|Passive|Capture)$/,mo=/^on:?(?:Once|Passive|Capture)$/;function ho(e){let t,n;for(;(n=e.match(po))&&!mo.test(e);)t||={},e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===`:`?e.slice(3):K(e.slice(2)),t]}var go=0,_o=Promise.resolve(),vo=()=>go||=(_o.then(()=>go=0),Date.now());function yo(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;let r=n.value;if(z(r)){let n=e.stopImmediatePropagation;e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0};let i=r.slice(),a=[e];for(let n=0;n<i.length&&!e._stopped;n++){let e=i[n];e&&In(e,t,5,a)}}else In(r,t,5,[e])};return n.value=e,n.attached=vo(),n}var bo=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,xo=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?qa(e,r,o):t===`style`?Qa(e,n,r):ue(t)?de(t)||fo(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),1):t[0]===`^`?(t=t.slice(1),0):So(e,t,r,o))?(so(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&oo(e,t,r,o,a,t!==`value`)):e._isVueCE&&(Co(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!V(r)))?so(e,W(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),oo(e,t,r,o))};function So(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&bo(t)&&B(n));if(t===`spellcheck`||t===`draggable`||t===`translate`||t===`autocorrect`||t===`sandbox`&&e.tagName===`IFRAME`||t===`form`||t===`list`&&e.tagName===`INPUT`||t===`type`&&e.tagName===`TEXTAREA`)return!1;if(t===`width`||t===`height`){let t=e.tagName;if(t===`IMG`||t===`VIDEO`||t===`CANVAS`||t===`SOURCE`)return!1}return bo(t)&&V(n)?!1:t in e}function Co(e,t){let n=e._def.props;if(!n)return!1;let r=W(t);return Array.isArray(n)?n.some(e=>W(e)===r):Object.keys(n).some(e=>W(e)===r)}var wo=fe({patchProp:xo},Ga),To;function Eo(){return To||=Fi(wo)}var Do=((...e)=>{let t=Eo().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=ko(e);if(!r)return;let i=t._component;!B(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Oo(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function Oo(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function ko(e){return V(e)?document.querySelector(e):e}var Ao=new WeakSet;function jo(){let e=e=>{e.stopPropagation(),e.preventDefault(),t()},t=()=>{document.removeEventListener(`click`,e,!0),document.removeEventListener(`pointerdown`,t,!0)};document.addEventListener(`click`,e,!0),document.addEventListener(`pointerdown`,t,!0)}function Mo(e){Kr(()=>document.addEventListener(`pointerdown`,e,!0)),Jr(()=>document.removeEventListener(`pointerdown`,e,!0))}var No=`comments:shake`,Po=`[data-slot='comment-composer'][data-dirty='true']`;function Fo(e=document){return e.querySelector(Po)!==null}function Io(e=document,t=!1){let n=[...e.querySelectorAll(Po)];for(let e of n)e.dispatchEvent(new CustomEvent(No,{detail:{escape:t}}));return n.length>0}var Lo=e=>e.composedPath().filter(e=>e instanceof Element),Ro=32,zo=e=>Math.min(1e3,Math.max(0,e));function Bo(e,t){return t>0?zo(Math.round(e/t*1e3)):0}function Vo(e){return e.nodeType===9?e:e.ownerDocument}function Ho(e){let t=e.getRootNode();return t.nodeType===11?t:Vo(e)??document}function Uo(e){return`"${e.replace(/["\\]/g,`\\$&`)}"`}function Wo(e,t){if(t===`:scope`&&e.nodeType===1)return[e];try{return[...e.querySelectorAll(t)]}catch{return[]}}function Go(e,t,n){let r=Wo(e,t);return r.length===1&&r[0]===n}var Ko=[/^:[\w-]+:$/,/^«[^»]*»$/,/^_r_[\w-]+_$/,/^radix-/,/^headlessui-/,/^reka-/,/^v-\d/,/^data-v-/,/^ember\d/,/^[\da-f-]{8,}$/i];function qo(e){if(Ko.some(t=>t.test(e)))return!0;let t=e.replace(/\D/g,``).length;return e.length>=6&&t/e.length>.5}function Jo(e,t){let n=[],r=e.getAttribute(`data-comment-id`);r&&n.push(`[data-comment-id=${Uo(r)}]`);let i=e.getAttribute(`id`);i&&!qo(i)&&n.push(/^[A-Za-z][\w-]*$/.test(i)?`#${i}`:`[id=${Uo(i)}]`);let a=e.getAttribute(`data-testid`);return a&&n.push(`[data-testid=${Uo(a)}]`),n.find(n=>Go(t,n,e))}function Yo(e){let t=e.localName,n=e.parentElement;if(!n)return t;let r=[...n.children].filter(e=>e.localName===t);return r.length>1?`${t}:nth-of-type(${r.indexOf(e)+1})`:t}function Xo(e,t=Ho(e)){if(e===t)return`:scope`;let n=Jo(e,t);if(n)return n;let r=[],i=e;for(;i&&i!==t;){let n=i===e?void 0:Jo(i,t);r.unshift(n??Yo(i));let a=r.join(` > `);if(n||Go(t,a,e))return a;i=i.parentElement}return r.join(` > `)}function Zo(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}function Qo(e,t){let n=t.root,r=n?.nodeType===11?n:n&&Vo(n)||document;return(typeof r.elementsFromPoint==`function`?r.elementsFromPoint(e.x,e.y):[r.elementFromPoint(e.x,e.y)]).find(e=>e!==null&&(!n||n.contains(e))&&!t.ignore?.(e))}function $o(e,t=[]){for(let n of e.childNodes)n.nodeType===3?t.push(n):n.nodeType===1&&$o(n,t);return t}var es=4;function ts(e,t,n){let r=0,i=t.nodeType===3?void 0:t.childNodes[n];for(let a of $o(e)){if(t.nodeType===3){if(a===t)return r+n}else if(i?a===i||i.compareDocumentPosition(a)&es:!t.contains(a)&&t.compareDocumentPosition(a)&es)break;r+=a.data.length}return r}function ns(e){return`rangeCount`in e?e.rangeCount>0&&!e.isCollapsed?e.getRangeAt(0):void 0:e.collapsed?void 0:e}function rs(e){return e.nodeType===1?e:e.parentElement}function is(e,t){let n=ns(e),r=n?.toString()??``,i=n&&rs(n.commonAncestorContainer);if(!n||!i||r===``)throw C.COMMENTS_R0001({target:`an empty selection`});let a=as(i,t)??i;if(t.root&&(!t.root.contains(n.startContainer)||!t.root.contains(n.endContainer)||!t.root.contains(a)))throw C.COMMENTS_R0001({target:`a selection outside the configured root`});let o=ts(a,n.startContainer,n.startOffset),s=$o(a).map(e=>e.data).join(``),c=t.context??Ro;return{kind:`text`,selector:Xo(a,t.root??Ho(a)),exact:r,prefix:s.slice(Math.max(0,o-c),o),suffix:s.slice(o+r.length,o+r.length+c)}}function as(e,t){let n=e;for(;n&&t.ignore?.(n);)n=n.parentElement;return n??void 0}function os(e){return e.localName===`img`}function ss(e,t,n){if(t.root&&!t.root.contains(e))throw C.COMMENTS_R0001({target:`an element outside the configured root`});let r=Zo(e),i=Xo(e,t.root??Ho(e)),a=os(e)?`image`:void 0;if(t.area){let e=Bo(t.area.left-r.left,r.width),n=Bo(t.area.top-r.top,r.height),o={selector:i,x:e,y:n,width:Math.max(0,Bo(t.area.left+t.area.width-r.left,r.width)-e),height:Math.max(0,Bo(t.area.top+t.area.height-r.top,r.height)-n)};if(o.width>0&&o.height>0)return a?{kind:a,...o}:{kind:`area`,...o}}let o=n?Bo(n.x-r.left,r.width):500,s=n?Bo(n.y-r.top,r.height):500;return a?{kind:a,selector:i,x:o,y:s}:{kind:`element`,selector:i,x:o,y:s}}function cs(e,t={}){if(e===`page`)return{kind:`page`};if(`nodeType`in e)return ss(e,t,t.point);if(`rangeCount`in e||`startContainer`in e)return is(e,t);let n=Qo(e,t);if(!n)throw C.COMMENTS_R0001({target:`the point ${Math.round(e.x)}, ${Math.round(e.y)}`});return ss(n,t,e)}var ls=4;function us(e,t){let n=[];for(let r=e.indexOf(t.exact);r!==-1;r=e.indexOf(t.exact,r+1)){let i=e.slice(0,r),a=e.slice(r+t.exact.length),o=0;for(;o<t.prefix.length&&i.at(-1-o)===t.prefix.at(-1-o);)o++;let s=0;for(;s<t.suffix.length&&a[s]===t.suffix[s];)s++;n.push({start:r,score:o+s,ambiguous:!1})}if(n.length===1)return n[0];let r=Math.min(ls,t.prefix.length+t.suffix.length),i=n.reduce((e,t)=>!e||t.score>e.score?t:e,void 0);if(!(!i||r===0||i.score<r))return{...i,ambiguous:n.filter(e=>e.score===i.score).length>1}}function ds(e,t,n){let r=0;for(let i of e){let e=r+i.data.length;if(n?t>r&&t<=e:t>=r&&t<e)return{node:i,offset:t-r};r=e}let i=e.at(-1);return i&&t===r?{node:i,offset:i.data.length}:void 0}function fs(e){return e.width>0||e.height>0}function ps(e){let t=Vo(e)?.defaultView;for(let n=e;n;n=n.parentElement){let e=t?.getComputedStyle(n).display??`block`;if(!e.startsWith(`inline`)&&e!==`contents`)return n}return e}var ms=8,hs=30;function gs(e,t){let n=$o(t),r=us(n.map(e=>e.data).join(``),e);if(!r)return;let i=r.start,a=ds(n,i,!1),o=ds(n,i+e.exact.length,!0),s=Zo(t),c=s,l=s;if(a&&o){let e=(Vo(t)??document).createRange();if(e.setStart(a.node,a.offset),e.setEnd(o.node,o.offset),typeof e.getBoundingClientRect==`function`){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();fs({left:t,top:n,width:r,height:i})&&(c={left:t,top:n,width:r,height:i})}let n=(typeof e.getClientRects==`function`?[...e.getClientRects()].filter(fs):[]).at(-1);l=n?{left:n.left,top:n.top,width:n.width,height:n.height}:c}if(!fs(c))return;let u=Vo(t)?.defaultView,d=Zo(ps(t)),f=Math.min(Math.max(d.left+d.width,l.left+l.width)+ms,(u?.innerWidth??1/0)-hs),p=l.top+l.height/2;return{position:{clipped:vs(t,l.left+Math.max(0,l.width-1),p),detached:!1,kind:`text`,x:f,y:p,width:c.width,height:c.height,element:t},score:r.score,ambiguous:r.ambiguous}}function _s(e){if(e.parentElement)return e.parentElement;let t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function vs(e,t,n){let r=e.ownerDocument.defaultView;if(!r)return!1;for(let i=_s(e);i;i=_s(i)){let{overflow:e,overflowX:a,overflowY:o}=r.getComputedStyle(i);if(![e,a,o].some(e=>e!==``&&e!==`visible`))continue;let s=Zo(i);if(fs(s)&&(t<s.left-1||t>s.left+s.width+1||n<s.top-1||n>s.top+s.height+1))return!0}return!1}function ys(e,t=document){let n;for(let r of Wo(t,e.selector)){let t=$o(r),i=us(t.map(e=>e.data).join(``),e),a=i&&ds(t,i.start,!1),o=i&&ds(t,i.start+e.exact.length,!0);if(!i||!a||!o)continue;if(n&&i.score===n.score){n.ambiguous=!0;continue}if(n&&i.score<n.score)continue;let s=(Vo(r)??document).createRange();s.setStart(a.node,a.offset),s.setEnd(o.node,o.offset),n={range:s,score:i.score,ambiguous:i.ambiguous}}return n&&!n.ambiguous?n.range:void 0}function bs(e,t=document){if(e.kind===`page`)return{clipped:!1,detached:!1,kind:`page`,x:0,y:0,width:0,height:0};let n=Wo(t,e.selector);if(e.kind===`text`){let t;for(let r of n){let n=gs(e,r);n&&(!t||n.score>t.score)?t=n:n&&t&&n.score===t.score&&(t.ambiguous=!0)}return t&&!t.ambiguous?t.position:{detached:!0}}let r=n.length===1?n[0]:void 0;if(!r)return{detached:!0};let i=Zo(r);if(!fs(i))return{detached:!0};let a=`width`in e&&e.width?e.width/1e3*i.width:0,o=`height`in e&&e.height?e.height/1e3*i.height:0,s=i.left+e.x/1e3*i.width,c=i.top+e.y/1e3*i.height;return{clipped:vs(r,s,c),detached:!1,kind:e.kind,x:s,y:c,width:a,height:o,element:r}}function xs(e){return e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase()}function Ss(e){let{transport:t}=e,n=new Set,r=new Map,i=new Set,a=new Set,o=new Set,s=[],c=`idle`,l,u=e.query??{},d=0,f=()=>!e.user&&!!(u.mine||u.mentions),p=()=>{for(let e of n)e()},m=t=>{let n=e.user;return!(u.subject&&(t.subject.kind!==u.subject.kind||t.subject.id!==u.subject.id)||u.subjectKind!==void 0&&t.subject.kind!==u.subjectKind||u.page!==void 0&&(t.subject.kind!==`page`||t.subject.id!==u.page)||u.revision&&(t.revision===void 0||t.revision>u.revision.lte)||u.status&&t.status!==u.status||n&&u.mine&&t.author.id!==n.id||n&&u.mentions&&!t.messages.some(e=>e.mentions.includes(n.id))||f()&&!i.has(t.id))},h=()=>{s=[...r.values()].filter(m).sort((e,t)=>e.n-t.n),p()},g=e=>{let t=r.get(e.id);return o.has(e.id)||t&&t.updatedAt>e.updatedAt?t??e:(r.set(e.id,e),a.add(e.id),h(),f()&&x(),e)},_=e=>{o.add(e),a.delete(e),r.delete(e)&&h()},v=new Map,y=async(e,t)=>{let n=v.get(e),r=(async()=>(await n?.catch(()=>void 0),t()))();v.set(e,r);try{return await r}finally{v.get(e)===r&&v.delete(e)}},b=async()=>{let e=++d;a=new Set,o=new Set,c=`loading`,p();try{let n={...u},f=n.limit??200,p=[],m;for(let r=0;;r++){p=[];let i=n.before,a=0;for(;;){let r=await t.list({...n,limit:f,...i?{before:i}:{}});if(e!==d)return s;if(a++,p.push(...r),n.limit!==void 0||r.length<f)break;let o=r.at(-1);i={id:o.id,updatedAt:o.updatedAt}}if(n.limit!==void 0||a===1&&m===void 0)break;let o=JSON.stringify(p);if(o===m)break;if(r===2)throw C.COMMENTS_R0015();m=o}if(e!==d)return s;let g=new Map;for(let e of p){let t=r.get(e.id);o.has(e.id)||g.set(e.id,t&&(t.updatedAt>e.updatedAt||a.has(e.id)&&t.updatedAt===e.updatedAt)?t:e)}for(let e of a){let t=r.get(e);t&&!g.has(e)&&g.set(e,t)}r.clear();for(let[e,t]of g)r.set(e,t);i=new Set(p.map(e=>e.id)),c=`ready`,l=void 0,h()}catch(t){throw e===d&&(c=`error`,l=t,p()),t}return s},x=()=>{b().catch(()=>void 0)},S=t=>{if(t.type===`thread`){if(!e.user&&(u.mine||u.mentions))return x();r.get(t.thread.id)?.updatedAt===t.thread.updatedAt?x():g(t.thread)}else t.type===`deleted`?_(t.threadId):x()};return{transport:t,user:e.user,get threads(){return s},get status(){return c},get error(){return l},get query(){return u},set query(e){u=e,d++,i.clear(),h()},refresh:b,get:e=>t.get(e),create:async e=>g(await t.create(e)),reply:e=>y(e.threadId,async()=>g(await t.reply(e))),edit:e=>y(e.threadId,async()=>g(await t.edit(e))),delete:e=>y(e.threadId,async()=>{let n=await t.delete(e);return n?g(n):_(e.threadId),n}),resolve:e=>y(e.threadId,async()=>g(await t.resolve(e))),reopen:e=>y(e.threadId,async()=>g(await t.reopen(e))),users:e=>t.users(e),onChange(e){return n.add(e),()=>{n.delete(e)}},start(){let n=[];return t.subscribe?n.push(t.subscribe(S)):e.refreshOnFocus!==!1&&typeof window<`u`&&(window.addEventListener(`focus`,x),n.push(()=>window.removeEventListener(`focus`,x))),x(),()=>{for(let e of n.splice(0))e()}}}}var Cs=e=>e.name??e.id;function ws(e){return{id:e.id,image:e.image,name:Cs(e)}}var Ts=({author:e,actor:t})=>t?`${t.name??t.id} (${Cs(e)})`:Cs(e);function Es(e){let{author:t,actor:n}=e;return n?{id:`${t.id}:${n.id}`,image:n.image,name:n.name??n.id}:ws(t)}function Ds(e){let t=e.replace(/\\([\\`*_{}[\]()#+\-.!>~|])/g,(e,t)=>String.fromCharCode(57344+t.charCodeAt(0))).replace(/^\s*(?:```|~~~).*$/gm,``).replace(/^\s*::+[\w-]*(?:\{[^}\n]*\})?\s*$/gm,``).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/<\/?[a-z][^>]*>/gi,``).replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+\[[ xX]\]\s+|[-*+]\s+|\d+[.)]\s+)/gm,``);for(let e=0;e<3;e++)t=t.replace(/(`+)([^`]+?)\1/g,`$2`).replace(/(\*\*|~~|\*)(?=\S)(.*?\S)\1/g,`$2`).replace(/(?<![\p{L}\p{N}_])(__|_)(?=\S)(.*?\S)\1(?![\p{L}\p{N}_])/gu,`$2`);return t.replace(/[\ue000-\ue07f]/g,e=>String.fromCharCode(e.charCodeAt(0)-57344)).replace(/\s+/g,` `).trim()}function Os(e,t=60){let n=Ds(e);return n.length>t?`${n.slice(0,t-1)}…`:n}var ks=`comment-mention`,As=/[\s([{"'“]/u;function js(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&!As.test(n[r-1]))return;let i=n.slice(r+1);if(!(i.length>40||/^\s|\n|\s{2}|@/u.test(i)))return{start:r,query:i}}function Ms(e,t,n={}){let r=xs(t),i=new Set(n.participants),a=new Set,o=[[],[],[],[]];for(let t of e){if(t.id===n.exclude||a.has(t.id))continue;a.add(t.id);let e=xs(Cs(t)),s=e.startsWith(r)?0:e.split(/\s+/u).some((e,t)=>t>0&&e.startsWith(r))?1:void 0;s!==void 0&&o[s*2+ +!i.has(t.id)].push(t)}return o.flat().slice(0,n.limit??6)}var Ns=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Ps=new WeakMap;function Fs(e,t){let n=[...t].filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length);if(n.length===0)return[e];let r=RegExp(`@(${n.map(e=>Ns(e.name)).join(`|`)})(?![\\p{L}\\p{N}_])`,`uy`),i=[],a=0;for(let t=e.indexOf(`@`);t!==-1;t=e.indexOf(`@`,t+1)){if(t>0&&!As.test(e[t-1]))continue;r.lastIndex=t;let o=r.exec(e),s=o&&n.find(e=>e.name===o[1]);o&&s&&(t>a&&i.push(e.slice(a,t)),i.push(s),a=t+o[0].length,t=a-1)}return a<e.length&&i.push(e.slice(a)),i}function Is(e){return Ps.get(e)}function Ls(e){let t=[...new Map(e.filter(e=>e.name).map(e=>[e.name,e])).values()].sort((e,t)=>t.name.length-e.name.length),n=t.length>0?RegExp(`@(${t.map(e=>Ns(e.name)).join(`|`)})(?![\\p{L}\\p{N}_])`,`iuy`):void 0,r={name:`vitehub-comment-mentions`,markdownItPlugins:[e=>{e.inline.ruler.before(`text`,`vitehub_comment_mention`,(e,r)=>{if(!n||e.src[e.pos]!==`@`)return!1;let i=e.src[e.pos-1];if(i!==void 0&&!As.test(i))return!1;n.lastIndex=e.pos;let a=n.exec(e.src);if(!a)return!1;let o=a[1].toLowerCase(),s=t.find(e=>e.name.toLowerCase()===o);if(!s)return!1;if(!r){let t=e.push(`mdc_inline_component`,ks,0);t.attrs=[[`user`,s.id],[`label`,s.name]]}return e.pos+=a[0].length,!0})}]};return Ps.set(r,t),r}var Rs=Symbol(`ViteHubComments`),zs=()=>lr(Rs,null)??void 0;function Bs(e,t,n){return n?[...e,...t]:t.slice(-1)}function Vs(e,t){return!t||t.split(`,`).some(t=>{let n=t.trim();return n.startsWith(`.`)?e.name.toLowerCase().endsWith(n.toLowerCase()):n.endsWith(`/*`)?e.type.startsWith(n.slice(0,-1)):e.type===n})}function Hs(e){let t=e.replace(/@.*/,``).trim().split(/[\s._-]+/).filter(Boolean),n=t[0]??``,r=t.length>1?t.at(-1)??``:n.slice(1);return(n.slice(0,1)+r.slice(0,1)).toUpperCase()||`?`}var Us=Z({name:`AvatarStack`,props:{people:{required:!0,type:Array},max:{default:3,type:[Number,null]},size:{default:`default`,type:String},variant:{default:`default`,type:String}},setup(e){let t=Q(()=>{let t=new Set;return e.people.filter(e=>!t.has(e.id)&&t.add(e.id))}),n=Q(()=>{let n=e.max===null?1/0:Math.max(2,e.max);return t.value.length>n?t.value.slice(0,n-1):t.value}),r=Q(()=>t.value.slice(n.value.length));return()=>$(`div`,{"aria-label":`${t.value.length} ${t.value.length===1?`person`:`people`}: ${t.value.map(e=>e.name).join(`, `)}`,"data-size":e.size,"data-slot":`avatar-stack`,"data-variant":e.variant,role:`group`},[...n.value.map(e=>$(`span`,{"aria-hidden":`true`,"data-slot":`avatar-stack-item`,key:e.id,style:e.color?{"--vh-avatar-color":e.color}:void 0,title:e.name},e.image?$(`img`,{alt:``,"data-slot":`avatar-stack-image`,src:e.image}):$(`span`,{"data-slot":`avatar-stack-fallback`},Hs(e.name)))),r.value.length?$(`span`,{"aria-hidden":`true`,"data-slot":`avatar-stack-count`,title:r.value.map(e=>e.name).join(`, `)},`+${r.value.length}`):null])}}),Ws={why:({message:e})=>e===void 0?``:String(e)},Gs=e({docsBase:`https://vitehub.dev/docs/ui/diagnostics`,codes:{UI_R0001:{...Ws,fix:`Pick the file again. The browser could not read the file that the message names.`},UI_R0002:{...Ws,fix:"Use the component that the message names as it says: inside its parent, such as `CommentLayer`, `ChoicesInput`, or `MessageScroller`, or with the props that the message names."},UI_CLIPBOARD_UNAVAILABLE:{why:`The clipboard is not available.`,fix:"Serve the page over HTTPS or from `localhost`, where the browser gives pages the clipboard API."},UI_MARKDOWN_UPLOAD_URL_MISSING:{why:({route:e,file:t})=>`${e} stored ${t} without a URL. Serve the Blob store with \`blob.serve\` so the editor can link it.`,fix:"Add `serve` to the Blob options, such as `vitehub({ blob: { serve: { access: 'public' } } })`, so the upload route returns a URL for each file that it stores."},UI_RELATIVE_TIME_NOW_INVALID:{why:`RelativeTime cannot read the supplied clock value.`,fix:`Pass a valid Date, an ISO date string, or milliseconds as now.`},UI_RELATIVE_TIME_THRESHOLD_INVALID:{why:({threshold:e})=>`RelativeTime threshold "${e}" is not a duration.`,fix:`Pass a number and a unit, such as "3w", or "none" as threshold.`},UI_ZIP_PATH_UNSAFE:{why:`ZIP files must use safe project-relative paths.`,fix:"Pass `zipFiles()` and `downloadZip()` a folder name and file paths that are relative to the project, without empty, `.`, or `..` segments, `:`, or a backslash."}}});function Ks(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Gs.UI_R0001({message:`Could not read ${e.name}.`})),r.onload=()=>t(String(r.result)),r.readAsDataURL(e)})}async function qs(e){return{filename:e.name,mediaType:e.type||`application/octet-stream`,type:`file`,url:await Ks(e)}}var Js=r({default:()=>Ys}),Ys={name:`NuxtUIStandIn`,render:()=>null},Xs={"i-lucide-arrow-left":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m12 19l-7-7l7-7m7 7H5`}]],"i-lucide-arrow-up":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`m5 12l7-7l7 7m-7 7V5`}]],"i-lucide-check":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M20 6L9 17l-5-5`}]],"i-lucide-external-link":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}]],"i-lucide-file":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M14 2v5a1 1 0 0 0 1 1h5`}]],"i-lucide-list":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13`}]],"i-lucide-message-circle":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092a10 10 0 1 0-4.777-4.719`}]],"i-lucide-pencil":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4`}]],"i-lucide-plus":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 12h14m-7-7v14`}]],"i-lucide-refresh-cw":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12a9 9 0 0 1 9-9a9.75 9.75 0 0 1 6.74 2.74L21 8`}],[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 3v5h-5m5 4a9 9 0 0 1-9 9a9.75 9.75 0 0 1-6.74-2.74L3 16`}],[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 16H3v5`}]],"i-lucide-rotate-ccw":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8`}],[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 3v5h5`}]],"i-lucide-square":[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,rx:`2`}]],"i-lucide-square-pen":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}],[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`}]],"i-lucide-trash-2":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]],"i-lucide-x":[[`path`,{fill:`none`,stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M18 6L6 18M6 6l12 12`}]]},Zs=Z({name:`UIcon`,inheritAttrs:!1,props:{name:{default:``,type:String}},setup(e,{attrs:t}){return()=>{let n=Xs[e.name];return n?$(`svg`,{...t,"aria-hidden":`true`,"data-slot":`standalone-icon`,fill:`none`,viewBox:`0 0 24 24`},n.map(([e,t])=>$(e,t))):$(`span`,{...t,"aria-hidden":`true`,"data-slot":`standalone-icon`})}}}),Qs=Z({name:`UButton`,inheritAttrs:!1,props:{color:{default:`primary`,type:String},disabled:{default:!1,type:Boolean},icon:{type:String},label:{type:String},loading:{default:!1,type:Boolean},size:{default:`md`,type:String},square:{default:!1,type:Boolean},to:{type:String},type:{default:`button`,type:String},variant:{default:`solid`,type:String}},setup(e,{attrs:t,slots:n}){return()=>{let r={...t,"aria-busy":e.loading?`true`:void 0,"data-color":e.color,"data-size":e.size,"data-square":e.square||!e.label&&!n.default?`true`:void 0,"data-variant":e.variant,"data-standalone-button":``},i=[e.icon?$(Zs,{name:e.icon}):null,e.label?$(`span`,e.label):null,n.default?.()];return e.to?$(`a`,{...r,href:e.to},i):$(`button`,{...r,disabled:e.disabled||e.loading,type:e.type},i)}}});function $s(e){let t=e.getRootNode();return t instanceof ShadowRoot?t:e.ownerDocument.body}var ec=Z({name:`UModal`,inheritAttrs:!1,props:{title:{type:String},ui:{default:()=>({}),type:Object}},setup(e,{slots:t}){let n=Y(!1),r=Y(null),i=Y(null),a=()=>{n.value=!1,r.value?.querySelector(`button, a`)?.focus()},o=e=>{e.key===`Escape`&&n.value&&(e.stopPropagation(),a())};return X(n,e=>{e&&requestAnimationFrame(()=>i.value?.focus())}),Jr(()=>{n.value=!1}),()=>{let s=e.ui;return[$(`span`,{"data-slot":`standalone-modal-trigger`,onClick:()=>n.value=!0,ref:r},t.default?.()),n.value&&r.value?$(wr,{to:$s(r.value)},$(`div`,{class:s.overlay,"data-slot":`standalone-modal`,onClick:e=>e.target===e.currentTarget&&a()},$(`div`,{"aria-label":e.title,"aria-modal":`true`,class:s.content,onKeydown:o,ref:i,role:`dialog`,tabindex:-1},t.content?.({close:a})))):null]}}});function tc(e){e.component(`UButton`,Qs),e.component(`UIcon`,Zs),e.component(`UModal`,ec)}var nc=r({default:()=>Qs}),rc=r({default:()=>ic}),ic={name:`NuxtUIStandIn`,render:()=>null},ac=r({default:()=>oc}),oc={name:`NuxtUIStandIn`,render:()=>null},sc=r({default:()=>cc}),cc={name:`NuxtUIStandIn`,render:()=>null},lc=r({default:()=>uc}),uc={name:`NuxtUIStandIn`,render:()=>null},dc=r({default:()=>fc}),fc={name:`NuxtUIStandIn`,render:()=>null},pc=r({default:()=>mc}),mc={name:`NuxtUIStandIn`,render:()=>null},hc=r({default:()=>gc}),gc={name:`NuxtUIStandIn`,render:()=>null},_c=r({default:()=>Zs}),vc=r({default:()=>yc}),yc={name:`NuxtUIStandIn`,render:()=>null},bc=r({default:()=>ec}),xc=r({default:()=>Sc}),Sc={name:`NuxtUIStandIn`,render:()=>null},Cc=r({default:()=>wc}),wc={name:`NuxtUIStandIn`,render:()=>null};function Tc(e,t){let n=typeof e==`string`&&!t?`${e}Context`:t,r=Symbol(n);return[t=>{let n=lr(r,t);if(n||n===null)return n;throw Error(`Injection \`${r.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(`, `)}`:`\`${e}\``}`)},e=>(cr(r,e),e)]}var[Ec,Dc]=Tc(`TooltipProvider`),Oc=Symbol(`ViteHubUIComponents`),kc={UBadge:Vr(()=>Promise.resolve(Js)),UButton:Vr(()=>Promise.resolve(nc)),UChatReasoning:Vr(()=>Promise.resolve(rc)),UChatTool:Vr(()=>Promise.resolve(ac)),UCollapsible:Vr(()=>Promise.resolve(sc)),UDropdownMenu:Vr(()=>Promise.resolve(lc)),UEditorDragHandle:Vr(()=>Promise.resolve(dc)),UEditorSuggestionMenu:Vr(()=>Promise.resolve(pc)),UEditorToolbar:Vr(()=>Promise.resolve(hc)),UIcon:Vr(()=>Promise.resolve(_c)),UInput:Vr(()=>Promise.resolve(vc)),UModal:Vr(()=>Promise.resolve(bc)),UTabs:Vr(()=>Promise.resolve(xc)),UTooltip:Vr(()=>Promise.resolve(Cc))};function Ac(e){return lr(Oc,void 0)?.[e]??Sa()?.appContext.components[e]??kc[e]}function jc(){return lr(Oc,void 0)?.UTooltip??Sa()?.appContext.components.UTooltip??(Ec(null)?kc.UTooltip:void 0)}var Mc=Symbol(`ViteHubUIIcons`),Nc={arrowLeft:`i-lucide-arrow-left`,arrowUp:`i-lucide-arrow-up`,check:`i-lucide-check`,close:`i-lucide-x`,copy:`i-lucide-copy`,copyCheck:`i-lucide-check`,external:`i-lucide-external-link`,file:`i-lucide-file`,plus:`i-lucide-plus`,reload:`i-lucide-refresh-cw`,stop:`i-lucide-square`,comment:`i-lucide-message-circle`,commentList:`i-lucide-list`,commentPage:`i-lucide-square-pen`,delete:`i-lucide-trash-2`,edit:`i-lucide-pencil`,reopen:`i-lucide-rotate-ccw`};function Pc(){let e=lr(Mc,void 0);return Q(()=>({...Nc,...Object.fromEntries(Object.entries(wn(e)??{}).filter(([,e])=>e))}))}function Fc(e){if(!e)return!1;if(/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(e)||e.startsWith(`blob:`))return!0;try{let t=new URL(e,`https://vitehub.invalid`);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}var Ic=Z({name:`ImagePreview`,inheritAttrs:!1,props:{alt:{default:``,type:String},compact:{default:!1,type:Boolean},src:{default:``,type:String},title:{type:String}},setup(e){let t=Y(!1),n=Q(()=>e.alt||e.title||`Image`),r=Ac(`UModal`),i=Ac(`UButton`),a=Pc();return X(()=>e.src,()=>{t.value=!1}),()=>Fc(e.src)?$(r,{title:n.value,transition:!1,ui:{overlay:`vh-image-overlay`,content:`vh-image-dialog`}},{default:()=>$(`button`,{"aria-label":`Preview ${n.value}`,class:[`vh-image-preview`,e.compact&&`vh-image-preview--compact`],title:e.title||n.value,type:`button`},t.value?$(`span`,{class:`vh-image-unavailable`},`Image unavailable`):$(`img`,{alt:n.value,loading:`lazy`,onError:()=>{t.value=!0},src:e.src})),content:({close:r})=>[$(`div`,{class:`vh-image-dialog__toolbar`},[$(`span`,{class:`vh-image-dialog__name`,title:n.value},n.value),$(i,{"aria-label":`Open original image`,class:`vh-image-dialog__action`,color:`neutral`,icon:a.value.external,external:!0,to:e.src,target:`_blank`,rel:`noreferrer`,variant:`ghost`}),$(i,{"aria-label":`Close image preview`,class:`vh-image-dialog__action`,color:`neutral`,icon:a.value.close,onClick:r,variant:`ghost`})]),t.value?$(`p`,{class:`vh-image-dialog__error`,role:`status`},`Image unavailable. The file may have been moved or deleted.`):$(`img`,{alt:n.value,class:`vh-image-dialog__image`,onError:()=>{t.value=!0},src:e.src})]}):$(`span`,{class:`vh-image-unavailable`},n.value)}});function Lc(e,t,n=`div`,r={}){return Z({name:e,setup(e,{attrs:i,slots:a}){return()=>$(n,{...i,"data-slot":t,...r},a.default?.())}})}var Rc=e=>({default:e,type:[String,Object]}),zc=Z({name:`Attachment`,props:{orientation:{default:`horizontal`,type:String},size:{default:`default`,type:String},state:{default:`done`,type:String}},setup(e,{slots:t}){return()=>$(`div`,{"data-orientation":e.orientation,"data-size":e.size,"data-slot":`attachment`,"data-state":e.state},t.default?.())}}),Bc=Lc(`AttachmentGroup`,`attachment-group`),Vc=Z({name:`AttachmentMedia`,props:{variant:{default:`icon`,type:String}},setup(e,{slots:t}){return()=>$(`div`,{"data-slot":`attachment-media`,"data-variant":e.variant},t.default?.())}}),Hc=Lc(`AttachmentContent`,`attachment-content`),Uc=Lc(`AttachmentTitle`,`attachment-title`,`span`),Wc=Lc(`AttachmentActions`,`attachment-actions`),Gc=Z({name:`AttachmentAction`,setup(e,{slots:t}){let n=Ac(`UButton`);return()=>$(n,{color:`neutral`,"data-slot":`attachment-action`,size:`xs`,square:!0,variant:`ghost`},t)}}),Kc={error:`Retry prompt`,ready:`Send prompt`,streaming:`Stop response`,submitted:`Stop response`},qc={error:`reload`,ready:`arrowUp`,streaming:`stop`,submitted:`stop`};function Jc(){return typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches&&!matchMedia(`(any-pointer: fine)`).matches}var Yc=Z({name:`PromptInput`,inheritAttrs:!1,props:{accept:{type:String},attachments:{default:!0,type:Boolean},attachVariant:{default:`outline`,type:String},disabled:{default:!1,type:Boolean},files:{default:()=>[],type:Array},filesDisabled:{default:!1,type:Boolean},filterFiles:{type:Function},readonly:{default:!1,type:Boolean},modelValue:{default:``,type:String},multiple:{default:!0,type:Boolean},placeholder:{type:String},status:{default:`ready`,type:String},submitLabel:{type:String}},emits:[`error`,`reload`,`submit`,`stop`,`update:files`,`update:modelValue`],setup(e,{attrs:t,emit:n,slots:r}){let i=Y(null),a=Y(null),o=Y(0),s=Q(()=>o.value>0),c=Q(()=>e.status===`ready`&&!e.disabled&&!e.readonly&&!s.value&&(e.modelValue.trim().length>0||e.files.length>0)),l=Y(!1);Kr(()=>{l.value=Jc()});let u=!1,d=0,f=new Map;Jr(()=>{u=!0});let p=Ac(`UButton`),m=Ac(`UIcon`),h=Pc(),g=Q(()=>e.disabled||e.filesDisabled),_=t=>{g.value||n(`update:files`,e.files.filter((e,n)=>n!==t))},v=async(t,r)=>{if(g.value)return;let i=d++;o.value++;try{let n=Array.from(t),a=e.filterFiles?.(n)??n;if(a.length===0)return;r?.();let o=await Promise.all(Array.from(a,qs));u||f.set(i,o)}catch(e){u||n(`error`,e)}finally{if(o.value--,!u&&o.value===0&&f.size>0){let t=[...f].sort(([e],[t])=>e-t).flatMap(([,e])=>e);f.clear(),n(`update:files`,Bs(e.files,t,e.multiple))}}},y=async t=>{let n=t.clipboardData;if(!e.attachments||!n)return;let r=n.getData(`text/plain`).length>0,i=Array.from(n.files).filter(e=>e.type.startsWith(`image/`)||!r);i.length!==0&&await v(i,()=>t.preventDefault())},b=t=>{t.preventDefault(),c.value&&n(`submit`,{files:e.files,text:e.modelValue.trim()})},x=()=>{e.status===`streaming`||e.status===`submitted`?n(`stop`):e.status===`error`?n(`reload`):a.value?.requestSubmit()},S=()=>$(Bc,{"data-slot":`prompt-input-attachments`},()=>e.files.map((e,t)=>{let n=e.filename??e.mediaType,r=e.mediaType.startsWith(`image/`);return $(zc,{key:`${e.filename}-${t}`,size:`xs`},()=>[$(Vc,{variant:r?`image`:`icon`},()=>r?$(Ic,{alt:n,compact:!0,src:e.url}):$(m,{name:h.value.file})),$(Hc,()=>$(Uc,()=>n)),$(Wc,()=>$(Gc,{"aria-label":`Remove ${e.filename??`attachment`}`,disabled:g.value,icon:h.value.close,onClick:()=>_(t)}))])}));return()=>$(`form`,{...t,"data-slot":`prompt-input`,onSubmit:b,ref:a},[$(`div`,{"data-focus-frame":``,"data-slot":`prompt-input-group`},[e.files.length>0||r.files?r.files?.({files:e.files,remove:_})??S():null,$(`textarea`,{"aria-label":t[`aria-label`]??`Message`,"data-slot":`prompt-input-textarea`,enterkeyhint:l.value?`enter`:`send`,onInput:e=>n(`update:modelValue`,e.target.value),onKeydown:t=>{t.key!==`Enter`||t.shiftKey||t.ctrlKey||t.metaKey||t.altKey||t.isComposing||Jc()||(t.preventDefault(),e.status===`ready`&&!e.disabled&&!e.readonly&&a.value?.requestSubmit())},onPaste:y,placeholder:e.placeholder,"aria-busy":e.readonly?`true`:void 0,disabled:e.disabled,readonly:e.readonly,rows:1,value:e.modelValue}),$(`div`,{"data-slot":`prompt-input-toolbar`},[e.attachments&&$(`input`,{accept:e.accept,"aria-label":`Add attachment`,"data-slot":`visually-hidden`,disabled:g.value,multiple:e.multiple,onChange:async e=>{let t=e.currentTarget;t instanceof HTMLInputElement&&(await v(t.files??[]),t.value=``)},ref:i,tabindex:-1,type:`file`}),r.actions?.()??(e.attachments&&$(p,{"aria-label":`Add attachment`,class:e.attachVariant===`ghost`?`rounded-full text-muted hover:text-default`:`rounded-full`,color:`neutral`,disabled:g.value,icon:h.value.plus,onClick:()=>i.value?.click(),size:`sm`,square:!0,type:`button`,variant:e.attachVariant})),r[`footer-leading`]?.(),$(`span`,{"data-slot":`prompt-input-spacer`}),r.submit?.({canSubmit:c.value,preparingFiles:s.value,status:e.status})??$(p,{"aria-label":e.status===`ready`&&e.submitLabel?e.submitLabel:Kc[e.status],class:`rounded-full`,color:`neutral`,disabled:e.status===`ready`&&!c.value||e.disabled&&e.status===`error`,icon:h.value[qc[e.status]],loading:e.status===`ready`&&(s.value||e.readonly),onClick:x,size:`sm`,square:!0,type:`button`,variant:e.status===`ready`&&!c.value?`soft`:`solid`})])])])}}),Xc=/^\S{2,}$/u,Zc={comment:`Add a comment`,edit:`Edit your comment`,reply:`Reply`},Qc={comment:`Comment`,edit:`Save`,reply:`Reply`},$c={comment:`Comment`,edit:`Edit comment`,reply:`Reply`},el=e=>{let t=e.getData(`text/plain`).length>0;return Array.from(e.files).filter(e=>e.type.startsWith(`image/`)||!t)},tl=2e3,nl=Z({name:`CommentComposer`,props:{modelValue:{default:``,type:String},mentions:{default:()=>[],type:Array},files:{type:Array},user:{type:Object},variant:{default:`comment`,type:String},placeholder:{type:String},busy:{default:!1,type:Boolean},error:{type:String},autofocus:{default:!0,type:Boolean},guard:{default:!0,type:Boolean},people:{default:()=>[],type:Array},participants:{default:()=>[],type:Array},users:{type:Function},attachments:{default:!0,type:Boolean},accept:{type:String},allowEmpty:{default:void 0,type:Boolean},layout:{default:`box`,type:String},size:{default:`md`,type:String},frame:{default:`field`,type:String}},emits:[`update:modelValue`,`update:mentions`,`update:files`,`submit`,`cancel`],slots:Object,setup(e,{emit:t,expose:n,slots:r}){let i=zs(),a=Y(null),o=Y(null),s=Y(null),c=Y(),l=Y(!1),u=new Map,d=Mr(),f=e=>`${d}-option-${e}`,p,m=Y(!1),h;X(m,e=>{clearTimeout(h),e&&(h=setTimeout(()=>m.value=!1,tl))});let g=0,_,v,y=Y([]),b=Q(()=>e.files??y.value);X([()=>e.modelValue,b],()=>m.value=!1);let x=Q(()=>e.attachments&&e.variant!==`edit`),S=Q(()=>e.allowEmpty??e.variant===`reply`),C=new WeakMap,w=new Set,T=e=>{let t=C.get(e);return t||(t={filename:e.name,mediaType:e.type||`application/octet-stream`,type:`file`,url:URL.createObjectURL(e)},C.set(e,t),w.add(t.url)),t},E=Q(()=>b.value.map(T));X(()=>[...b.value],(e,t)=>{for(let n of t){let t=C.get(n);t&&!e.includes(n)&&(URL.revokeObjectURL(t.url),w.delete(t.url),C.delete(n))}});function D(n){e.busy||(y.value=n,c.value=void 0,t(`update:files`,n))}function O(t){if(!x.value)return[];let n=Array.from(t).filter(t=>Vs(t,e.accept));return n.length>0&&D([...b.value,...n]),n}let k=Q(()=>[...e.people,...i?.people.value??[]]),A=e=>{let t=k.value.find(t=>t.id===e);return u.get(e)??(t?Cs(t):void 0)},j=()=>e.users?e.users:i?i.users:e.people.length>0?async()=>e.people:void 0,ee=()=>e.user?.id??i?.user.value?.id,M=()=>a.value?.querySelector(`textarea`)??null,te=()=>e.modelValue.trim().length>0,ne=()=>te()||b.value.length>0,re=()=>M()?.focus(),N=Y(!1),P=0;function F(){let t=M(),n=t?.parentElement;if(e.layout!==`row`||!t||!n||!e.modelValue){N.value=!1;return}let r=getComputedStyle(t),i=Number.parseFloat(r.lineHeight);if(!(i>0))return;N.value?(t.style.boxSizing=`border-box`,t.style.maxWidth=`${n.clientWidth-P}px`):P=n.clientWidth-t.offsetWidth;let a=t.scrollHeight-Number.parseFloat(r.paddingTop)-Number.parseFloat(r.paddingBottom);t.style.removeProperty(`box-sizing`),t.style.removeProperty(`max-width`),N.value=a>i*1.5}let ie=typeof ResizeObserver==`function`?new ResizeObserver(()=>F()):void 0;X([()=>e.modelValue,()=>e.layout,()=>e.size],F,{flush:`post`});async function ae(){let e=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;o.value=null,await Kn(),a.value?.offsetWidth,o.value=e?`flash`:`shake`,clearTimeout(p),p=setTimeout(()=>o.value=null,450),re()}let oe=e=>{e instanceof CustomEvent&&e.detail?.escape===!0&&(m.value=!0),ae()};Kr(()=>{a.value?.addEventListener(No,oe);let t=M()?.parentElement;t&&ie?.observe(t),F(),e.autofocus&&Kn(re)}),Jr(()=>{ie?.disconnect(),a.value?.removeEventListener(No,oe),clearTimeout(p),clearTimeout(h);for(let e of w)URL.revokeObjectURL(e)}),n({focus:re,shake:ae}),X(s,e=>{let t=M();if(!t)return;t.setAttribute(`role`,`combobox`),t.setAttribute(`aria-autocomplete`,`list`);let n=e!==null&&e.items.length>0;t.setAttribute(`aria-expanded`,String(n)),n?(t.setAttribute(`aria-controls`,`${d}-list`),t.setAttribute(`aria-activedescendant`,f(e.index))):(t.removeAttribute(`aria-controls`),t.removeAttribute(`aria-activedescendant`))},{deep:!0}),Mo(n=>{e.guard&&a.value&&!Lo(n).includes(a.value)&&(Ao.add(n),ne()?(n.stopPropagation(),jo(),ae()):t(`cancel`))});function I(){let e=M();!e||e.selectionStart===_&&e.selectionEnd===_||(g++,_=void 0,s.value=null)}function L(n){I();let r=M(),i=s.value;if(!r||!i)return;if(r.selectionStart!==r.selectionEnd||r.value.slice(0,r.selectionStart)!==i.before){s.value=null;return}let a=r.selectionStart,o=`@${Cs(n)} `,c=e.modelValue.slice(0,i.start)+o+e.modelValue.slice(a).replace(/^ /u,``);u.set(n.id,Cs(n)),t(`update:modelValue`,c),e.mentions.includes(n.id)||t(`update:mentions`,[...e.mentions,n.id]),s.value=null,Kn(()=>{let e=i.start+o.length;r.setSelectionRange(e,e),r.focus()})}async function se(t){let n=++g;_=t.selectionStart;let r=j(),i=t.value.slice(0,t.selectionStart),a=t.selectionStart===t.selectionEnd?js(t.value,t.selectionStart):void 0;if(a?.start!==v&&(v=void 0),!r||!a||a.start===v){s.value=null;return}let o=[],c=!1;try{o=await r(a.query)}catch(e){c=!0,console.warn(`[vitehub] The comment box could not load people to mention:`,e)}let l=Ms(o,a.query,{exclude:ee(),participants:e.participants});if(I(),n!==g||a.start===v)return;let u=t.selectionStart===t.selectionEnd&&t.value.slice(0,t.selectionStart)===i,d=l.length>0||Xc.test(a.query);s.value=u&&d?{before:i,failed:c,index:0,items:l,query:a.query,start:a.start}:null}function ce(n){if(e.busy)return;let r=[...b.value];if(!n.text&&(r.length===0||!S.value)){r.length>0&&(c.value=`Write a comment to send with the files.`);return}let i=e.mentions.filter(e=>{let t=A(e);if(t===void 0)return!1;let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|[^\\p{L}\\p{N}\\p{M}_])@${r}(?=$|[^\\p{L}\\p{N}\\p{M}_])`,`iu`).test(n.text)});t(`submit`,{body:n.text,files:r,mentions:[...i]})}function le(e){if(e.isComposing)return;let t=s.value,n=t!==null&&t.items.length>0;if(n&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;t.index=(t.index+n+t.items.length)%t.items.length;return}if(n&&(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),L(t.items[t.index]);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),!e.repeat&&(t?(g++,v=t.start,s.value=null):ne()&&!m.value?(m.value=!0,ae()):ue()))}async function ue(){e.busy||(m.value=!1,ne()&&(t(`update:modelValue`,``),t(`update:mentions`,[]),D([]),await Kn()),t(`cancel`))}let de=e=>x.value&&(e.dataTransfer?.types.includes(`Files`)??!1);return()=>$(`div`,{"data-busy":e.busy?`true`:void 0,"data-dirty":ne()?`true`:void 0,"data-dragging":l.value?`true`:void 0,"data-frame":e.frame,"data-layout":e.layout,"data-multiline":N.value?`true`:void 0,"data-shake":o.value??void 0,"data-size":e.size,"data-slot":`comment-composer`,"data-variant":e.variant,onKeydownCapture:le,onKeyupCapture:I,onClickCapture:I,onSelectCapture:I,onInputCapture:e=>{e.target instanceof HTMLTextAreaElement&&se(e.target)},onPasteCapture:t=>{x.value&&t.clipboardData&&el(t.clipboardData).some(t=>Vs(t,e.accept))&&t.preventDefault()},onDragover:e=>{de(e)&&(e.preventDefault(),l.value=!0)},onDragleave:e=>{(!(e.relatedTarget instanceof Node)||!a.value?.contains(e.relatedTarget))&&(l.value=!1)},onDrop:e=>{l.value=!1,de(e)&&(e.preventDefault(),O(e.dataTransfer?.files??[]),re())},ref:a},[$(`div`,{"data-slot":`comment-composer-box`},[r.extra?$(`div`,{"data-slot":`comment-composer-extra`},r.extra()):null,$(Yc,{accept:e.accept,"aria-label":$c[e.variant],attachments:x.value,attachVariant:e.layout===`row`?`ghost`:`outline`,files:E.value,filesDisabled:e.busy,readonly:e.busy,filterFiles:e=>(O(e),[]),modelValue:e.modelValue,placeholder:e.placeholder??Zc[e.variant],submitLabel:Qc[e.variant],onSubmit:ce,"onUpdate:files":e=>D(b.value.filter(t=>e.includes(T(t)))),"onUpdate:modelValue":e=>t(`update:modelValue`,e)}),s.value&&s.value.items.length===0?$(`div`,{"data-slot":`comment-composer-mentions`,"data-state":s.value.failed?`error`:`empty`,role:`status`},$(`p`,{"data-slot":`comment-composer-mention-empty`},r[`mention-empty`]?.({failed:s.value.failed,query:s.value.query})??(s.value.failed?`Could not load people.`:`No one by that name can be mentioned here.`))):s.value?$(`ul`,{"aria-label":`People`,"data-slot":`comment-composer-mentions`,id:`${d}-list`,role:`listbox`},s.value.items.map((e,t)=>{let n=t===s.value?.index;return $(`li`,{"aria-selected":String(n),"data-slot":`comment-composer-mention`,id:f(t),key:e.id,onMousedown:t=>{t.preventDefault(),L(e)},role:`option`},r[`mention-item`]?.({active:n,person:e})??[$(Us,{"aria-hidden":`true`,people:[ws(e)],size:`sm`}),$(`span`,{"data-slot":`comment-composer-mention-name`},Cs(e))])})):null,e.error??c.value?$(`p`,{"data-slot":`comment-composer-error`,role:`alert`},e.error??c.value):null,$(`p`,{"aria-live":`polite`,"data-slot":`comment-composer-status`},m.value?`Press Esc again to discard.`:``)])])}});function rl(e={}){let t=e.flashMs??2500,n=e.visibility??`all`,r=null,i=null,a=[],o=[],s=[],c=new Set,l=new Map,u=new Map,d=new Map,f=new Map,p=new Set,m=(e,t)=>{let n=setTimeout(()=>{c.delete(n),e()},t);return c.add(n),n};function h(){let e=o;o=n===`hidden`?[...new Set([...r?[r]:[],...a])]:[];let t=n===`hidden`?e.filter(e=>!o.includes(e)):[];s=n===`hidden`?[...s.filter(e=>!o.includes(e)),...t.filter(e=>!s.includes(e))]:[];for(let e of t)clearTimeout(f.get(e)),f.set(e,m(()=>{f.delete(e),s=s.filter(t=>t!==e);for(let e of p)e()},130));for(let e of p)e()}function g(e){let t=l.get(e);t&&(clearTimeout(t),c.delete(t),l.delete(e))}function _(e,t){if(g(e),d.delete(e),e===i){d.set(e,t);return}u.set(e,Date.now()+t),l.set(e,m(()=>{l.delete(e),u.delete(e),a=a.filter(t=>t!==e),h()},t))}return{get visibility(){return n},get only(){return o},get leaving(){return s},set(e){if(e!==n){if(n=e,e===`all`){for(let e of[...l.keys()])g(e);u.clear(),d.clear(),a=[]}h()}},open(e){e!==r&&(r=e,h())},flash(e){n===`hidden`&&(_(e,t),a.includes(e)||(a=[...a,e],h()))},hover(e){if(e===i)return;let t=i;if(i=e,t!==null){let e=d.get(t);e!==void 0&&_(t,e)}if(e!==null&&l.has(e)){let t=Math.max(0,(u.get(e)??0)-Date.now());g(e),u.delete(e),d.set(e,t)}},isShown:e=>n===`all`||o.includes(e),subscribe(e){return p.add(e),()=>p.delete(e)},stop(){for(let e of c)clearTimeout(e);c.clear(),l.clear(),u.clear(),d.clear(),f.clear()}}}function il(e){let{resolvedAt:t}=e;return e.status!==`resolved`||t===void 0?[]:e.messages.filter(e=>e.createdAt>t)}var al=e=>il(e).length>0;function ol(e){return(t,{message:n})=>e?t===`edit`||t===`delete`?n?.author.id===e.id:!0:!1}var sl=`draft`,cl=`[data-comments-ui]`;function ll(e){for(let t=e;t;){if(t.closest(cl))return!0;let e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}return!1}var ul=e=>e.composedPath().filter(e=>e instanceof Element);function dl(e,t){return e.kind===t.kind&&e.id===t.id}function fl(e,t){return!e||!t?e===t:e.detached||t.detached?e.detached===t.detached:e.element===t.element&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.clipped===t.clipped}var pl=`input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='textbox'], [role='combobox'], [role='searchbox']`,ml=e=>e.some(e=>e.matches(pl));function hl(e){return e instanceof Error?e.message:`The comment could not be sent. Try again.`}function gl(e){let{client:t}=e,n=e.param??`comment`,r=e.hotkey===void 0?`c`:e.hotkey!==!1&&e.hotkey.toLowerCase(),i=e.ignore??ll,a=Q(()=>wn(e.subject)),o=Q(()=>wn(e.user)??t.user),s=Y(!1),c=Y(`page`),l=Q({get:()=>c.value,set:e=>{if(e!==c.value){if(F())return ie();c.value=e}}}),u=cn({open:!0,resolved:!1,mine:!1}),d=Y(t.status),f=bn(t.threads),p=bn(new Map),m=Y(null),h=Y(null),g=bn(new Map),_=Q(()=>new Set(g.value.values())),v=e=>{let t=Symbol();return g.value=new Map(g.value).set(t,e),()=>{let e=new Map(g.value);e.delete(t),g.value=e}},y=Y(null),b=Y(!1),x=Y(0),S=e=>e.status===`open`||al(e),C=e=>u.open&&S(e)||u.resolved&&e.status===`resolved`?!u.mine||e.author.id===o.value?.id:!1,w=e=>dl(e.subject,a.value),T=Q(()=>f.value.filter(e=>w(e)&&C(e))),E=Q(()=>f.value.filter(e=>(l.value===`site`||w(e))&&C(e))),D=Q(()=>{let e=f.value.filter(e=>l.value===`site`||w(e));return{open:e.filter(S).length,resolved:e.filter(e=>e.status===`resolved`).length}}),O=Q(()=>f.value.find(e=>e.id===h.value)),k=yn(e.visibility)?e.visibility:Y(e.visibility??`all`),A=rl({visibility:k.value,flashMs:e.flashMs}),j=Y(0);A.subscribe(()=>j.value++),X(k,e=>A.set(e),{flush:`sync`}),X(h,e=>A.open(e),{flush:`sync`}),X(y,e=>A.hover(e),{flush:`sync`});let ee=Q(()=>{j.value;let e=new Set(T.value.map(e=>e.id));O.value&&w(O.value)&&e.add(O.value.id);for(let t of f.value){let n=k.value===`hidden`&&(A.isShown(t.id)||A.leaving.includes(t.id));w(t)&&(_.value.has(t.id)||n)&&e.add(t.id)}return e}),M=Q(()=>(j.value,new Set([...ee.value].filter(e=>A.isShown(e)||_.value.has(e))))),te=Q(()=>(j.value,new Set(A.leaving.filter(e=>ee.value.has(e)&&!_.value.has(e))))),ne=e=>A.flash(e),re=()=>wn(e.root)??document,N=()=>wn(e.uiRoot)??document;function P(){let e=new Map;for(let t of f.value.filter(e=>ee.value.has(e.id)))e.set(t.id,bs(t.anchor,re()));m.value&&e.set(sl,bs(m.value.anchor,re()));let t=p.value;e.size===t.size&&[...e].every(([e,n])=>fl(n,t.get(e)))||(p.value=e)}let F=()=>(m.value?.body.trim().length??0)>0||Fo(N()),ie=(e=!1)=>{x.value++,Io(N(),e)};function ae(){s.value=!0;let e=typeof window>`u`?void 0:window.getSelection();if(e&&!e.isCollapsed&&e.rangeCount>0){let t=e.getRangeAt(0).commonAncestorContainer,n=t instanceof Element?t:t.parentElement;if(n?.isConnected&&!i(n)){let t=e.getRangeAt(0).getBoundingClientRect();try{ce(e,{point:{x:t.left,y:t.top}}),e.removeAllRanges()}catch{}}}}function oe(){m.value=null}function I(){return F()?(ie(),!1):(h.value=null,y.value=null,!0)}function L(e=!1){if(F())return ie(e);oe(),I(),s.value=!1}function se(){s.value?L():ae()}function ce(e,{files:t,...n}={}){if(F())return ie();I();let r=cs(e,{root:re(),ignore:i,...n}),a=n.point??{x:0,y:0};if(e===`page`)a={x:Math.max(16,window.innerWidth/2-180),y:96};else if(`nodeType`in e){let t=e.getBoundingClientRect();a=n.point??{x:t.left+t.width/2,y:t.top+t.height/2}}else!(`rangeCount`in e)&&!(`startContainer`in e)&&(a=e);m.value={anchor:r,point:a,body:``,mentions:[],attachments:[],...t?.length?{files:t}:{},busy:!1,error:void 0},P()}async function le(){let e=m.value,n=e?.body.trim()??``;if(!e||e.busy||!n&&e.attachments.length===0)return;let r=e.body,i=[...e.mentions],o=[...e.attachments];e.busy=!0,e.error=void 0;try{let s=await t.create({subject:a.value,anchor:J(e.anchor),body:n,mentions:i,...o.length>0?{attachments:o}:{}});return e.busy=!1,ne(s.id),m.value===e&&e.body===r&&e.mentions.length===i.length&&e.mentions.every((e,t)=>e===i[t])&&(m.value=null),s}catch(t){e.busy=!1,e.error=hl(t);return}}let ue;function de(e){clearTimeout(ue);let t=0,n=()=>{P();let r=p.value.get(e);r&&!r.detached?(r.element?.scrollIntoView?.({block:`center`}),P()):++t<20&&(ue=setTimeout(n,150))};n()}function fe(e,t={}){let n=typeof e==`string`?e:e.id;if(F())return ie();oe(),h.value=n,y.value=null;let r=f.value.find(e=>e.id===n);r&&w(r)&&(t.scroll?de(n):P())}function pe(t){let r=e.location?.()??window.location,i=e.subjectUrl?.(t.subject)??(t.subject.kind===`page`?t.subject.id:r.href),a=new URL(i,r.origin);return a.searchParams.set(n,String(t.n)),`${a.pathname.startsWith(`//`)?`/%2F${a.pathname.slice(2)}`:a.pathname}${a.search}${a.hash}`}let me=!1;function R(){if(me||d.value!==`ready`)return;me=!0;let t=e.location?.()??window.location,r=Number(new URLSearchParams(t.search).get(n));if(!Number.isInteger(r)||r<1)return;let i=f.value.find(e=>e.n===r&&w(e));i&&(i.status===`resolved`&&(u.resolved=!0),u.mine=!1,fe(i,{scroll:!0}))}function z(e){if(e.defaultPrevented||e.isComposing||e.repeat)return;let t=ul(e),n=t[0];if(e.key===`Escape`){if(t.some(e=>e.matches(`[data-slot='comment-composer']`)))return;(s.value||m.value||h.value)&&L(!0);return}if(!(e.ctrlKey||e.metaKey||e.altKey||e.shiftKey||ml(t))){if(e.key===`Enter`&&s.value&&n&&!t.some(i)&&n!==document.body&&n!==document.documentElement){e.preventDefault();try{ce(n)}catch{}return}r!==!1&&e.key.toLowerCase()===r&&(e.preventDefault(),se())}}function he(){let n=[];t.query=l.value===`page`?{subject:a.value}:{},n.push(t.onChange(()=>{d.value=t.status,f.value=t.threads})),d.value=t.status,f.value=t.threads,n.push(t.start()),document.addEventListener(`keydown`,z),n.push(()=>document.removeEventListener(`keydown`,z));let r=0,i=()=>{r||=requestAnimationFrame(()=>{r=0,P()})};window.addEventListener(`scroll`,i,{capture:!0,passive:!0}),window.addEventListener(`resize`,i),window.addEventListener(`load`,i,{capture:!0}),document.fonts?.addEventListener(`loadingdone`,i);let o=()=>{me=!1,R()};window.addEventListener(`popstate`,o),n.push(X(()=>e.location?.().search,o));let s=new MutationObserver(e=>{e.every(e=>e.target instanceof Element&&ll(e.target))||i()}),c={attributes:!0,characterData:!0,childList:!0,subtree:!0};n.push(X(re,e=>{s.disconnect(),s.observe(document.documentElement,c),e!==document&&s.observe(e,c),i()},{immediate:!0,flush:`post`}));let u=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i),g=new Set;return n.push(()=>{window.removeEventListener(`scroll`,i,{capture:!0}),window.removeEventListener(`resize`,i),window.removeEventListener(`load`,i,{capture:!0}),window.removeEventListener(`popstate`,o),document.fonts?.removeEventListener(`loadingdone`,i),s.disconnect(),u?.disconnect(),clearTimeout(ue),r&&cancelAnimationFrame(r),A.stop()}),n.push(X(p,()=>{let e=new Set;for(let t of p.value.values())!t.detached&&t.element&&e.add(t.element);for(let t of g)e.has(t)||(u?.unobserve(t),g.delete(t));for(let t of e)g.has(t)||(u?.observe(t),g.add(t))},{flush:`post`})),n.push(X([ee,()=>m.value?.anchor,h],()=>P(),{flush:`post`})),n.push(X(()=>d.value===`ready`,e=>e&&R(),{immediate:!0})),n.push(X(()=>`${a.value.kind}\u0000${a.value.id}\u0000${l.value}`,()=>{t.query=l.value===`page`?{subject:a.value}:{},oe(),h.value=null,y.value=null,me=!1,t.refresh().catch(()=>void 0)})),()=>{for(let e of n.splice(0))e()}}let ge=bn(new Map),_e=Q(()=>{let t=new Map,n=e=>{e&&(!t.has(e.id)||e.name)&&t.set(e.id,e)};for(let e of ge.value.values())n(e);for(let t of wn(e.people)??[])n(t);for(let e of f.value){n(e.author),n(e.resolvedBy);for(let t of e.messages)n(t.author)}return n(o.value),[...t.values()]});async function B(e,n){let r=await t.users({query:e,...n?{threadId:n}:{subject:a.value}});if(r.some(e=>ge.value.get(e.id)!==e)){let e=new Map(ge.value);for(let t of r)e.set(t.id,t);ge.value=e}return r}let V={client:t,subject:a,user:o,can:(t,n)=>o.value!==void 0&&(e.can??ol(o.value))(t,n),people:_e,active:s,scope:l,filters:u,status:d,threads:f,pageThreads:T,listed:E,counts:D,positions:p,draft:m,openId:h,hoverId:y,opened:O,listOpen:b,blocked:x,visibility:k,shown:M,leaving:te,retainMark:v,isShown:e=>M.value.has(e),flash:ne,enter:ae,exit:L,toggle:se,startDraft:ce,cancelDraft:oe,send:le,open:fe,close:I,create:async({anchor:e={kind:`page`},attachments:n,body:r,mentions:i})=>{let o=await t.create({subject:a.value,anchor:e,body:r,mentions:i,...n?.length?{attachments:n}:{}});return ne(o.id),o},reply:async(e,n,r,i)=>{let a=await t.reply({threadId:e,body:n,mentions:r,...i?.length?{attachments:i}:{}});return ne(e),a},edit:(e,n,r,i)=>t.edit({threadId:e,messageId:n,body:r,mentions:i}),remove:async(e,n)=>{let r=await t.delete({threadId:e,messageId:n});return!r&&h.value===e&&(h.value=null,y.value=null),r},resolve:e=>t.resolve({threadId:e}),reopen:e=>t.reopen({threadId:e}),users:B,link:pe,measure:P,start:he};if(e.autoStart!==!1&&Sa()){let e;Kr(()=>{e=he()}),Jr(()=>e?.())}return V}function _l(e){cr(Rs,e)}function vl(e){let t=e??zs();if(!t)throw Gs.UI_R0002({message:"Comment parts need a comments state. Put them inside CommentLayer, or pass the result of useComments() as the `comments` prop."});return t}function yl(e,t={}){let[n,r,i,a]=[1e3,6e4,36e5,864e5],[o,s,c]=[7*a,30*a,365*a],l={s:n,m:r,h:i,d:a,w:o,mo:s,y:c},{threshold:u=`3w`,locale:d=`en-US`,style:f=`long`}=t,[,p,m]=/^(\d+(?:\.\d+)?)\s*(s|m|h|d|w|mo|y)$/i.exec(u)??[],h=/^(none|never)$/i.test(u)?1/0:p&&m?Number(p)*(l[m.toLowerCase()]??NaN):NaN;if(Number.isNaN(h))throw Gs.UI_RELATIVE_TIME_THRESHOLD_INVALID({threshold:u});let g=t.now===void 0?Date.now():new Date(t.now).getTime();if(!Number.isFinite(g))throw Gs.UI_RELATIVE_TIME_NOW_INVALID();let _=t.timeZone??new Intl.DateTimeFormat().resolvedOptions().timeZone,v=new Intl.RelativeTimeFormat(d,{numeric:`auto`,style:f}),y=e=>Object.fromEntries(new Intl.DateTimeFormat(`en-US`,{timeZone:_,hourCycle:`h23`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}).formatToParts(e).map(e=>[e.type,Number(e.value)])),b=e=>{let t=y(e);return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)-Math.floor(e/1e3)*1e3},x=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?\s*(Z|[+-]\d{2}:?\d{2})?)?$/i.exec(e);if(!t)return;let[n,r,i,o,s,c]=[1,2,3,4,5,6].map(e=>Number(t[e]??0)),l=Date.UTC(n,r-1,i,o,s,c,Number((t[7]??``).padEnd(3,`0`))),u=new Date(l);if(u.getUTCFullYear()!==n||u.getUTCMonth()!==r-1||u.getUTCDate()!==i||o>23||s>59||c>59)return;if(t[4]===void 0)return{at:Math.floor(l/a)*a,wall:!0};let d=t[8];if(d?.toUpperCase()===`Z`)return{at:l,wall:!1};if(d){let e=d.replace(/\D/g,``),t=Number(e.slice(0,2)),n=Number(e.slice(2));return t>23||n>59?void 0:{at:l-(d.startsWith(`-`)?-1:1)*(t*60+n)*6e4,wall:!1}}let f=[...new Set([l-a,l,l+a].map(e=>l-b(e)))].filter(e=>e+b(e)===l).sort((e,t)=>e-t)[0];return f===void 0?void 0:{at:f,wall:!1}},S=Math.floor((g+b(g))/a),C=typeof e==`string`?NaN:new Date(e).getTime(),w=typeof e==`string`?x(e.trim()):Number.isFinite(C)?{at:C,wall:!1}:void 0;if(!w)return;let T=w.wall?(w.at/a-S)*a:w.at-g,E=w.wall?Math.max(Math.abs(T),a):Math.abs(T),[D,O]=E<r?[`second`,n]:E<i?[`minute`,r]:E<a?[`hour`,i]:E<o?[`day`,a]:E<s?[`week`,o]:E<c?[`month`,s]:[`year`,c],k=v.format(Math.trunc(T/O)||0,D),A=e=>new Intl.DateTimeFormat(d,{timeZone:w.wall?`UTC`:_,...e}).format(w.at),j={day:`numeric`,month:`short`},ee={hour:`numeric`,minute:`2-digit`,timeZoneName:`short`},M=Math.abs(T)>=h,te=w.wall?new Date(w.at).getUTCFullYear():y(w.at).year;return{datetime:w.wall?new Date(w.at).toISOString().slice(0,10):new Date(w.at).toISOString().replace(/\.000Z$/,`Z`),mode:M?`absolute`:`relative`,label:M?A(te===y(g).year?j:{...j,year:`numeric`}):k,tip:M?w.wall?k:`${k} · ${A(ee)}`:A({weekday:`short`,...j,year:`numeric`,...w.wall?{}:ee})}}var bl=Symbol(`ViteHubRelativeNow`),xl=3e4;function Sl(e){let t,n=()=>e.value=Date.now(),r=()=>clearInterval(t),i=()=>{r(),n(),t=setInterval(n,xl)},a=()=>document.visibilityState===`hidden`?r():i();return document.addEventListener(`visibilitychange`,a),a(),()=>{r(),document.removeEventListener(`visibilitychange`,a)}}var Cl=Y(0),wl=0,Tl;function El(){return wl++===0&&(Tl=Sl(Cl)),Cl}function Dl(){--wl===0&&Tl?.()}var Ol=6e4,kl=Z({name:`RelativeTime`,inheritAttrs:!1,props:{at:{required:!0,type:[Number,String,Date]},threshold:{default:`3w`,type:String},format:{default:`long`,type:String},locale:{default:`en`,type:String},tooltip:{default:!0,type:Boolean}},setup(e,{attrs:t}){let n=jc(),r=lr(bl,void 0),i=bn(),a=Y(!1);Kr(()=>{r||(i.value=El()),a.value=!0}),Jr(()=>{i.value&&Dl()});let o=Q(()=>r?.value??i.value?.value),s=t=>{let n=o.value;if(n===void 0)return;let r={locale:e.locale,style:e.format,threshold:e.threshold,timeZone:t},i=yl(e.at,{...r,now:n});if(!i?.datetime.includes(`T`))return i;let a=Date.parse(i.datetime);return Math.abs(a-n)<Ol?yl(e.at,{...r,now:a}):i},c=Q(()=>s(a.value?void 0:`UTC`)),l=Q(()=>{let t=yl(e.at,{locale:e.locale,now:e.at,threshold:`none`,timeZone:`UTC`});if(!t)return;let n=new Intl.DateTimeFormat(e.locale,{day:`numeric`,month:`short`,timeZone:`UTC`,year:`numeric`}).format(Date.parse(t.datetime));return{...t,label:n,mode:`absolute`}}),u=()=>a.value?s()?.tip:void 0;return()=>{let r=c.value??l.value;if(!r)return $(`time`,{...t,"data-slot":t[`data-slot`]??`relative-time`},String(e.at));let i=e=>$(`time`,{...t,"data-mode":r.mode,"data-slot":t[`data-slot`]??`relative-time`,datetime:r.datetime,title:e},r.label);return e.tooltip?n?$(n,null,{content:u,default:()=>i()}):i(u()):i()}}});function Al(e){let t=e.anchor.kind===`text`?e.anchor.exact:``;return Ds(e.messages[0]?.body??``)||t}function jl(e){return{thread:e,text:Al(e)}}function Ml(e,t={}){let n=e.messages.length-1;return[$(`span`,{"data-slot":`comment-list-number`},String(e.n)),$(Us,{"aria-hidden":`true`,people:[Es(e)],size:`sm`}),$(`span`,{"data-slot":`comment-list-body`},[$(`span`,{"data-slot":`comment-list-text`},t.preview??Al(e)),$(`span`,{"data-slot":`comment-list-meta`},[$(`span`,Ts(e)),$(kl,{at:e.updatedAt}),n>0?$(`span`,`${n} ${n===1?`reply`:`replies`}`):null,e.status===`resolved`?$(`span`,`Resolved`):null,t.detached?$(`span`,{"data-slot":`comment-list-detached`},`Detached`):null,t.site&&e.subject.kind===`page`?$(`span`,e.subject.id):null])])]}var Nl={type:Object},Pl=Z({name:`CommentFilters`,props:{comments:Nl},setup(e){let t=Ac(`UButton`),n=vl(e.comments);return()=>{let e=(e,r,i)=>$(t,{"aria-pressed":String(n.filters[e]),color:`neutral`,"data-slot":`comment-filter`,"data-state":n.filters[e]?`on`:`off`,key:e,label:i===void 0?r:`${r} ${i}`,onClick:()=>n.filters[e]=!n.filters[e],size:`xs`,variant:n.filters[e]?`soft`:`ghost`});return $(`div`,{"aria-label":`Filter comments`,"data-slot":`comment-filters`,role:`group`},[e(`open`,`Open`,n.counts.value.open),e(`resolved`,`Resolved`,n.counts.value.resolved),e(`mine`,`Mine`)])}}}),Fl=Z({name:`CommentList`,props:{comments:Nl,navigate:{type:Function}},emits:[`select`],slots:Object,setup(e,{emit:t,slots:n}){let r=Ac(`UButton`),i=vl(e.comments);function a(n,r){t(`select`,n),!(r&&(r.ctrlKey||r.metaKey||r.shiftKey||r.button!==0))&&(r?.preventDefault(),n.subject.kind===i.subject.value.kind&&n.subject.id===i.subject.value.id?i.open(n,{scroll:!0}):i.close()&&(e.navigate??(e=>window.location.assign(e)))(i.link(n)))}return()=>{let e=(e,t)=>$(r,{"aria-pressed":String(i.scope.value===e),color:`neutral`,"data-slot":`comment-list-scope`,label:t,onClick:()=>i.scope.value=e,size:`xs`,variant:i.scope.value===e?`soft`:`ghost`}),t=i.listed.value;return $(`section`,{"aria-label":`Comments`,"data-comments-ui":``,"data-slot":`comment-list`},[$(`header`,{"data-slot":`comment-list-header`},[$(`div`,{"data-slot":`comment-list-scopes`,role:`group`,"aria-label":`Scope`},[e(`page`,`This page`),e(`site`,`All pages`)]),$(Pl,{comments:i})]),t.length===0?$(`p`,{"data-slot":`comment-list-empty`,role:`status`},i.status.value===`loading`&&i.threads.value.length===0?`Loading comments.`:i.status.value===`error`?`The comments could not load.`:`No comments here.`):$(`ol`,{"data-slot":`comment-list-items`},t.map(e=>{let t=i.positions.value.get(e.id)?.detached===!0;return $(`li`,{key:e.id},[$(`a`,{"aria-current":i.openId.value===e.id?`true`:void 0,"data-detached":t?`true`:void 0,"data-focus-inset":``,"data-slot":`comment-list-item`,"data-status":e.status,href:i.link(e),onClick:t=>a(e,t)},n.row?.(jl(e))??Ml(e,{detached:t,preview:n.preview?.(jl(e)),site:i.scope.value===`site`}))])}))])}}}),Il=Z({name:`CommentToolbar`,props:{comments:Nl,people:{default:()=>[],type:Array}},setup(e,{slots:t}){let n=Ac(`UButton`),r=Pc(),i=vl(e.comments);return()=>{let a=i.pageThreads.value.length;return $(`div`,{"aria-label":`Comments`,"data-comments-ui":``,"data-slot":`comment-toolbar`,role:`toolbar`},[$(n,{"aria-keyshortcuts":`C`,"aria-label":`Comment mode`,"aria-pressed":String(i.active.value),color:`neutral`,"data-slot":`comment-toolbar-mode`,icon:r.value.comment,onClick:i.toggle,size:`sm`,title:`Comment (C)`,variant:i.active.value?`solid`:`ghost`}),$(n,{"aria-label":`Comment list, ${a} on this page`,"aria-pressed":String(i.listOpen.value),color:`neutral`,"data-slot":`comment-toolbar-list`,icon:r.value.commentList,label:String(a),onClick:()=>i.listOpen.value=!i.listOpen.value,size:`sm`,variant:i.listOpen.value?`solid`:`ghost`}),$(n,{"aria-label":`Comment on page`,color:`neutral`,"data-slot":`comment-toolbar-page`,icon:r.value.commentPage,onClick:()=>{i.startDraft(`page`)},size:`sm`,title:`Comment on the whole page`,variant:`ghost`}),e.people.length>0?$(Us,{people:e.people,size:`sm`,variant:`outline`}):null,t.default?.()])}}}),Ll=Z({name:`CommentPin`,props:{n:{type:Number},author:{type:Object},status:{default:`open`,type:String},excerpt:{type:String},active:{default:!1,type:Boolean},draft:{default:!1,type:Boolean}},emits:[`select`,`hover`,`leave`],setup(e,{emit:t}){let n=()=>{if(e.draft)return`New comment`;let t=e.author?` by ${Cs(e.author)}`:``,n=e.excerpt?`: ${e.excerpt}`:``;return`Comment ${e.n}${t}${n}${e.status===`resolved`?`, resolved`:``}`},r=!1,i=!1;return()=>$(`button`,{"aria-expanded":e.draft?void 0:String(e.active),"aria-label":n(),"data-active":e.active?`true`:void 0,"data-draft":e.draft?`true`:void 0,"data-slot":`comment-pin`,"data-status":e.status,onBlur:()=>{i=!1,r||t(`leave`)},onClick:()=>t(`select`),onFocus:()=>{i=!0,t(`hover`)},onPointerenter:()=>{r=!0,t(`hover`)},onPointerleave:()=>{r=!1,i||t(`leave`)},type:`button`},[e.author?$(Us,{"aria-hidden":`true`,people:[ws(e.author)],size:`sm`}):null,e.draft||e.n===void 0?null:$(`span`,{"data-slot":`comment-pin-number`},String(e.n))])}}),Rl=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)|(\[[^\]\n]+\]\(https?:\/\/[^\s)]+\))|(https?:\/\/[^\s<>)]+)/g;function zl(e,t){return $(`a`,{href:e,rel:`noopener noreferrer`,target:`_blank`},t)}function Bl(e,t,n){return!n||t.length===0?[e]:Fs(e,t).map(e=>typeof e==`string`?e:$(n,{label:e.name,user:e.id}))}function Vl(e,t=[],n){let r=[],i=0;for(let a of e.matchAll(Rl)){let o=a.index;o>i&&r.push(...Bl(e.slice(i,o),t,n));let s=a[0];if(a[1])r.push($(`code`,s.slice(1,-1)));else if(a[2])r.push($(`strong`,Bl(s.slice(2,-2),t,n)));else if(a[3])r.push($(`em`,Bl(s.slice(1,-1),t,n)));else if(a[4]){let e=s.indexOf(`](`);r.push(zl(s.slice(e+2,-1),s.slice(1,e)))}else r.push(zl(s,s));i=o+s.length}return i<e.length&&r.push(...Bl(e.slice(i),t,n)),r}var Hl=Z({name:`Markdown`,inheritAttrs:!1,props:{components:{type:Object},plugins:{type:Array},value:{default:``,type:String}},setup(e,{attrs:t}){return()=>{let n=(e.plugins??[]).flatMap(e=>Is(J(e))??[]),r=e.components?.[`comment-mention`];return $(`div`,{...t,class:[`vh-markdown`,t.class]},e.value.split(/\n{2,}/).filter(e=>e.trim()).map(e=>$(`p`,e.split(`
11
+ `).flatMap((e,t)=>t?[$(`br`),...Vl(e,n,r)]:Vl(e,n,r)))))}}}),Ul=Z({name:`Marker`,props:{as:Rc(`div`),variant:{default:`default`,type:String}},setup(e,{slots:t}){return()=>$(e.as,{"data-slot":`marker`,"data-variant":e.variant},t.default?.())}}),Wl=Lc(`MarkerContent`,`marker-content`,`span`),Gl=new Set([`apng`,`avif`,`bmp`,`gif`,`heic`,`jpeg`,`jpg`,`png`,`svg`,`webp`]);function Kl(e){return e instanceof Error?e.message:`That did not work. Try again.`}var ql=e=>e.split(/[/\\]/).at(-1)||e;function Jl(e){if(e)try{let{protocol:t}=new URL(e,`https://vitehub.invalid`);return t===`http:`||t===`https:`||t===`blob:`?e:void 0}catch{return}}function Yl(e,t,n,r){if(e.attachments.length===0)return null;let i=e.attachments.map(e=>{let n=t?.(e),r=typeof n==`string`?{url:n}:n,i=r?.name||ql(e),a=/\.([a-z0-9]+)$/i.exec(i)?.[1]?.toLowerCase(),o=Jl(r?.url);return{href:o,image:o!==void 0&&(r?.type?r.type.startsWith(`image/`):a===void 0||Gl.has(a)),key:e,name:i}}),a=i.filter(e=>e.image),o=i.filter(e=>!e.image);return[a.length>0?$(`div`,{"data-slot":`comment-reply-images`},a.map(e=>$(Ic,{alt:e.name,key:e.key,src:e.href}))):null,o.length>0?$(Bc,{"data-slot":`comment-reply-attachments`},()=>o.map(e=>$(zc,{key:e.key,size:`xs`},()=>[$(Vc,{variant:`icon`},()=>$(n,{name:r})),$(Hc,()=>$(Uc,()=>e.href?$(`a`,{href:e.href,rel:`noreferrer`,target:`_blank`},e.name):e.name))]))):null]}var Xl=Z({name:`CommentReply`,props:{message:{required:!0,type:Object},user:{type:Object},editable:{default:!1,type:Boolean},deletable:{default:void 0,type:Boolean},compact:{default:!1,type:Boolean},confirmDelete:{default:!1,type:Boolean},size:{default:`md`,type:String},people:{default:()=>[],type:Array},users:{type:Function},attachmentUrl:{type:Function},onEdit:{type:Function},onDelete:{type:Function}},slots:Object,setup(e,{slots:t}){let n=Ac(`UButton`),r=Ac(`UIcon`),i=Pc(),a=zs(),o=Y(!1),s=Y(!1),c=Y(!1),l=Y(),u=Y(``),d=Y([]),f=()=>e.user?.id??a?.user.value?.id,p=Z({props:{label:{default:``,type:String},user:{default:``,type:String}},setup(t){return()=>e.message.mentions.includes(t.user)?$(`span`,{"data-self":t.user===f()?`true`:void 0,"data-slot":`comment-mention`},`@${t.label}`):`@${t.label}`}}),m={[ks]:p},h=Q(()=>{let t=new Map;for(let n of[...a?.people.value??[],...e.people,...e.user?[e.user]:[]])t.set(n.id,n);return[Ls(e.message.mentions.flatMap(e=>{let n=t.get(e);return n?[{id:e,name:Cs(n)}]:[]}))]});async function g(e){if(c.value)return!1;c.value=!0,l.value=void 0;try{return await e(),!0}catch(e){return l.value=Kl(e),!1}finally{c.value=!1}}function _(){u.value=e.message.body,d.value=[...e.message.mentions],l.value=void 0,o.value=!0}async function v(t){if(!e.onEdit)return;let n=u.value,r=d.value,i=t.body===e.message.body?[...new Set([...e.message.mentions,...t.mentions])]:t.mentions;await g(()=>e.onEdit?.(e.message.id,t.body,i))&&u.value===n&&d.value===r&&(o.value=!1)}let y=()=>e.editable&&e.onEdit!==void 0,b=()=>(e.deletable??e.editable)&&e.onDelete!==void 0;async function x(){e.onDelete&&await g(()=>e.onDelete?.(e.message.id))&&(s.value=!1)}return()=>{let{message:a}=e;return $(`div`,{"data-compact":e.compact?`true`:void 0,"data-editing":o.value?`true`:void 0,"data-size":e.size,"data-slot":`comment-reply`},[$(`div`,{"data-slot":`comment-reply-content`},[$(`div`,{"data-slot":`comment-reply-header`},[$(Us,{"aria-hidden":`true`,people:[Es(a)],size:`sm`}),$(`span`,{"data-agent":a.actor?`true`:void 0,"data-slot":`comment-reply-author`},Ts(a)),$(kl,{at:a.createdAt,"data-slot":`comment-reply-time`}),a.editedAt?$(`span`,{"data-slot":`comment-reply-edited`},`edited`):null]),o.value?$(nl,{autofocus:!0,busy:c.value,error:l.value,mentions:d.value,modelValue:u.value,onCancel:()=>{c.value||(o.value=!1)},onSubmit:v,"onUpdate:mentions":e=>d.value=e,"onUpdate:modelValue":e=>u.value=e,people:e.people,size:e.size,users:e.users,variant:`edit`},{...t[`mention-item`]?{"mention-item":t[`mention-item`]}:{},...t[`mention-empty`]?{"mention-empty":t[`mention-empty`]}:{}}):t.body?.({message:a})??$(Hl,{components:m,"data-slot":`comment-reply-body`,plugins:h.value,value:a.body}),o.value||e.compact?null:t.attachments?.({message:a})??Yl(a,e.attachmentUrl,r,i.value.file),s.value?$(`div`,{"aria-label":`Confirm delete`,"data-slot":`comment-reply-confirm`,role:`group`},[$(`p`,`Delete this comment and every reply to it?`),$(n,{color:`error`,label:`Delete thread`,loading:c.value,onClick:x,size:`xs`}),$(n,{color:`neutral`,label:`Cancel`,onClick:()=>s.value=!1,size:`xs`,variant:`ghost`})]):null,!o.value&&l.value?$(`p`,{"data-slot":`comment-reply-error`,role:`alert`},l.value):null]),(y()||b())&&!o.value&&!s.value&&!e.compact?$(`div`,{"data-slot":`comment-reply-actions`},[y()?$(n,{"aria-label":`Edit`,color:`neutral`,icon:i.value.edit,onClick:_,size:`xs`,variant:`ghost`}):null,b()?$(n,{"aria-label":`Delete`,color:`neutral`,icon:i.value.delete,onClick:()=>e.confirmDelete?s.value=!0:void x(),size:`xs`,variant:`ghost`}):null]):null])}}}),Zl=e=>$(Ul,{key:`resolved`,variant:`separator`},()=>$(Wl,()=>`Resolved${e.resolvedBy?` by ${Cs(e.resolvedBy)}`:``}`)),Ql=Z({name:`CommentThread`,props:{thread:{required:!0,type:Object},user:{type:Object},preview:{default:!1,type:Boolean},readOnly:{default:!1,type:Boolean},can:{type:Function},busy:{default:!1,type:Boolean},error:{type:String},detached:{default:!1,type:Boolean},people:{default:()=>[],type:Array},users:{type:Function},attachments:{default:!0,type:Boolean},accept:{type:String},attachmentUrl:{type:Function},navigation:{default:`close`,type:String},dismissible:{default:!0,type:Boolean},size:{default:`md`,type:String},onReply:{type:Function},onEdit:{type:Function},onDelete:{type:Function},onResolve:{type:Function},onReopen:{type:Function}},emits:[`close`],slots:Object,setup(e,{emit:t,expose:n,slots:r}){let i=Ac(`UButton`),a=Pc(),o=zs(),s=Y(null),c=Y(``),l=Y([]),u=Y([]),d=Y(!1),f=Y(),p=Y(null),m=Q(()=>e.user??o?.user.value),h=Q(()=>e.users??(o?t=>o.users(t,e.thread.id):void 0)),g=(t,n)=>!e.readOnly&&(e.can??o?.can??ol(m.value))(t,{message:n,thread:e.thread}),_=Q(()=>{let t=new Map;for(let n of[...e.people,e.thread.author,...e.thread.messages.map(e=>e.author),...m.value?[m.value]:[]])t.set(n.id,n);return[...t.values()]}),v=Q(()=>[...new Set([e.thread.author.id,...e.thread.messages.map(e=>e.author.id)])]);Mo(n=>{let r=Lo(n);if(e.preview||!e.dismissible||!s.value||r.includes(s.value)||r.some(e=>e.matches(`[data-slot='comment-pin']`))||Ao.has(n))return;Ao.add(n);let i=s.value.getRootNode();Io(i instanceof ShadowRoot?i:document)?(n.stopPropagation(),jo()):t(`close`)});async function y(t){if(d.value||!e.onReply)return;d.value=!0,f.value=void 0;let n=c.value,r=l.value,i=u.value;try{await e.onReply(t.body,[...t.mentions],[...t.files]),c.value===n&&l.value===r&&u.value===i&&(c.value=``,l.value=[],u.value=[]),Kn(()=>p.value?.focus())}catch(e){f.value=Kl(e)}finally{d.value=!1}}async function b(e){if(!(s.value&&Io(s.value))){f.value=void 0;try{await e?.()}catch(e){f.value=Kl(e)}}}function x(){s.value&&Io(s.value)||t(`close`)}n({close:x});let S=()=>({...r.body?{body:r.body}:{},...r.attachments?{attachments:r.attachments}:{},...r[`mention-item`]?{"mention-item":r[`mention-item`]}:{},...r[`mention-empty`]?{"mention-empty":r[`mention-empty`]}:{}}),C=()=>({...r.extra?{extra:r.extra}:{},...r[`mention-item`]?{"mention-item":r[`mention-item`]}:{},...r[`mention-empty`]?{"mention-empty":r[`mention-empty`]}:{}});return()=>{let{thread:t}=e,n=t.status===`resolved`,o=il(t),w=!n||o.length>0,T=t.messages[0],E=t.anchor.kind===`text`?t.anchor.exact:void 0;if(e.preview){let n=t.messages.length-1;return $(`div`,{"data-preview":`true`,"data-size":e.size,"data-slot":`comment-thread`,"data-status":t.status},[T?$(Xl,{compact:!0,message:T,people:_.value,size:e.size,user:m.value},r.body?{body:r.body}:void 0):null,n>0?$(`p`,{"data-slot":`comment-thread-count`},`${n} ${n===1?`reply`:`replies`}`):null])}let D=e.navigation===`back`,O=r.anchor?r.anchor({thread:t}):E?$(`blockquote`,{"data-slot":`comment-thread-quote`},E):null;return $(`section`,{"aria-label":`Comment ${t.n}`,"data-size":e.size,"data-slot":`comment-thread`,"data-status":t.status,ref:s,role:`dialog`,tabindex:-1},[$(`header`,{"data-slot":`comment-thread-header`},[D?$(i,{"aria-label":`Back to comments`,color:`neutral`,icon:a.value.arrowLeft,onClick:x,size:`xs`,variant:`ghost`}):null,$(`span`,{"data-slot":`comment-thread-title`},`Comment ${t.n}`),$(`span`,{"data-slot":`comment-thread-spacer`}),r.actions?$(`div`,{"data-slot":`comment-thread-actions`},r.actions({thread:t})):null,g(`resolve`)?$(i,{"aria-label":w?`Resolve`:`Reopen`,color:`neutral`,icon:w?a.value.check:a.value.reopen,onClick:()=>void b(w?e.onResolve:e.onReopen),size:`xs`,variant:`ghost`}):null,D?null:$(i,{"aria-label":`Close`,color:`neutral`,icon:a.value.close,onClick:x,size:`xs`,variant:`ghost`})]),$(`div`,{"data-slot":`comment-thread-messages`},[O,e.detached?$(`p`,{"data-slot":`comment-thread-detached`,role:`status`},`The place of this comment is no longer on the page.`):null,...t.messages.flatMap((r,i)=>[n&&r===o[0]?Zl(t):null,$(Xl,{attachmentUrl:e.attachmentUrl,confirmDelete:i===0,deletable:g(`delete`,r),editable:g(`edit`,r),key:r.id,message:r,onDelete:e.onDelete,onEdit:e.onEdit,people:_.value,size:e.size,user:m.value,users:h.value},S())]),n&&o.length===0?Zl(t):null,r.after?$(`div`,{"data-slot":`comment-thread-after`},r.after({thread:t})):null]),!g(`reply`)&&(f.value??e.error)?$(`p`,{role:`alert`},f.value??e.error):null,g(`reply`)?$(nl,{accept:e.accept,attachments:e.attachments,autofocus:!1,busy:e.busy||d.value,error:f.value??e.error,files:u.value,guard:!1,layout:`row`,mentions:l.value,modelValue:c.value,onCancel:x,onSubmit:y,participants:v.value,"onUpdate:files":e=>u.value=e,"onUpdate:mentions":e=>l.value=e,"onUpdate:modelValue":e=>c.value=e,people:_.value,ref:p,size:e.size,user:m.value,users:h.value,variant:`reply`},C()):null])}}}),$l=360,eu=420;function tu(e,t,n,r){let i=(Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16)/2,a=t?(r-n)/2-i:e.x,o=a>r/2&&a+i+n>r-i,s=Math.max(i,Math.min(o?a-i-n:a+i,r-i-n));return{x:a,y:e.y,flipX:o,left:s-a}}var nu=e=>e===`area`||e===`image`?`round`:`point`,ru=6,iu=32,au=8,ou=900,su=8,cu=72;function lu(e){let t={x:e.left+e.width/2,y:e.top+e.height/2},n=document.elementsFromPoint(t.x,t.y).find(e=>!e.closest(`[data-comments-ui]`)&&!e.localName.startsWith(`vitehub-`)&&e!==document.documentElement);for(let t=n??null;t&&t!==document.documentElement;t=t.parentElement){let n=t.getBoundingClientRect();if(n.left<=e.left+1&&n.top<=e.top+1&&n.right>=e.left+e.width-1&&n.bottom>=e.top+e.height-1)return t}}var uu=Z({name:`CommentLayer`,props:{client:{type:Object},subject:{type:Object},user:{type:Object},comments:{type:Object},people:{default:()=>[],type:Array},hotkey:{default:`c`,type:[String,Boolean]},readOnly:{default:!1,type:Boolean},subjectUrl:{type:Function},navigate:{type:Function},can:{type:Function},upload:{type:Function},accept:{type:String},attachmentUrl:{type:Function},placement:{default:`pin`,type:String},size:{default:`sm`,type:String}},setup(e,{slots:t}){let{client:n,subject:r}=e;if(!e.comments&&(!n||!r))throw Gs.UI_R0002({message:"CommentLayer needs a `client` and a `subject`, or the `comments` state from useComments()."});let i=Y(null),a=()=>{let e=i.value?.getRootNode();return e instanceof ShadowRoot?e:document},o=e.comments??gl({client:n,hotkey:e.hotkey,subject:()=>e.subject,subjectUrl:e.subjectUrl,uiRoot:a,user:()=>e.user});_l(o);let s=Y([]),c=bn(null);X(()=>o.draft.value,(e,t)=>{e!==t&&(s.value=e?.files?[...e.files]:[])});let l=Q(()=>e.upload!==void 0&&o.client.transport.supportsAttachments!==!1),u=async t=>l.value&&t.length>0&&e.upload?e.upload(t):[],d=Q(()=>o.user.value),f=Q(()=>o.threads.value.filter(e=>o.pageThreads.value.includes(e)||o.shown.value.has(e.id)||o.leaving.value.has(e.id))),p=Q(()=>f.value.filter(e=>o.shown.value.has(e.id)||o.leaving.value.has(e.id))),m=null,h=Y(null),g=(e,t)=>({left:Math.min(e.x,t.clientX),top:Math.min(e.y,t.clientY),width:Math.abs(t.clientX-e.x),height:Math.abs(t.clientY-e.y)}),_=e=>{h.value=null,m=Ao.has(e)||e.button!==0?null:{x:e.clientX,y:e.clientY,draw:e.pointerType!==`touch`},m?.draw&&e.target instanceof Element&&e.target.setPointerCapture?.(e.pointerId)},v=e=>{m?.draw&&(!h.value&&Math.hypot(e.clientX-m.x,e.clientY-m.y)<=ru||(h.value=g(m,e)))},y=e=>{let t=m,n=h.value;if(m=null,h.value=null,t){if(n){let n=g(t,e),r=n.width>=au&&n.height>=au?lu(n):void 0;if(!r)return;e.preventDefault();try{o.startDraft(r,{area:n,point:{x:n.left,y:n.top}})}catch{}return}if(!(Math.hypot(e.clientX-t.x,e.clientY-t.y)>ru)){e.preventDefault();try{o.startDraft({x:e.clientX,y:e.clientY})}catch{}}}},b=null,x=!1;X(()=>o.openId.value,(e,t)=>{if(e){Kn(()=>i.value?.querySelector(`[data-slot='comment-thread']:not([data-preview])`)?.focus());return}b=null;let n=a().activeElement,r=i.value?.querySelector(`[data-slot='comment-thread']:not([data-preview])`);t&&(!n||n===document.body||r?.contains(n))&&(b=t)},{flush:`pre`}),X(()=>o.openId.value,e=>{if(e||!b)return;let t=b;b=null,Kn(()=>{let e=i.value?.querySelectorAll(`[data-slot='comment-pin']`)??[];x=!0,([...e].find(e=>e.getAttribute(`data-thread-id`)===t)??i.value?.querySelector(`[data-slot='comment-toolbar-mode']`))?.focus(),x=!1})},{flush:`post`});let S=null;X(()=>o.draft.value,(e,t)=>{if(e&&!t){let e=document.activeElement,t=a();S=e instanceof HTMLElement&&e!==document.body&&!(t instanceof ShadowRoot&&e===t.host)&&!i.value?.contains(e)?e:null;return}if(e||!t)return;let n=S;S=null,Kn(()=>{let e=a().activeElement;n?.isConnected&&(!e||e===document.body)&&n.focus({preventScroll:!0})})},{flush:`sync`});let C=Y(null),w=Y(!1),T=Y(0),E=()=>{T.value=C.value?.offsetWidth??0};X(()=>o.draft.value,(e,t)=>{e!==t&&(w.value=!1)});let D=typeof ResizeObserver==`function`?new ResizeObserver(()=>{E();let e=C.value;e?.parentElement?.hasAttribute(`data-above`)&&e.getBoundingClientRect().top<8&&(w.value=!0)}):void 0;X(C,(e,t)=>{t&&D?.unobserve(t),e&&D?.observe(e),E()}),Jr(()=>D?.disconnect());let O=({x:e,y:t})=>({left:`${e}px`,top:`${t}px`,"--vh-comment-x":`${e}px`}),k=cn(new Map),A=new Map,j=new Map,ee=(e,t)=>{let n=j.get(e);n!==t&&(n&&te?.unobserve(n),j.delete(e),t&&(j.set(e,t),te?.observe(t)))},M=()=>{for(let[e,t]of A){let n=t.querySelector(`:scope > [data-slot='comment-layer-popover']`),r=n?getComputedStyle(n).getPropertyValue(`position-area`):``;if(ee(e,n&&r&&r!==`none`?n:null),!n||!r||r===`none`){k.delete(e);continue}let i=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o={x:a.left+a.right<i.left*2,y:a.top+a.bottom<i.top*2},s=k.get(e);(s?.x!==o.x||s?.y!==o.y)&&k.set(e,o)}},te=typeof ResizeObserver==`function`?new ResizeObserver(M):void 0,ne=0,re=()=>{ne||=requestAnimationFrame(()=>{ne=0,M()})};Kr(()=>{M(),window.addEventListener(`resize`,re,{passive:!0}),window.visualViewport?.addEventListener(`resize`,re,{passive:!0})}),qr(M),Jr(()=>{te?.disconnect(),cancelAnimationFrame(ne),window.removeEventListener(`resize`,re),window.visualViewport?.removeEventListener(`resize`,re)});let N=e=>t=>{t instanceof HTMLElement?A.set(e,t):(A.delete(e),ee(e,null),k.delete(e))},P=(e,t,n)=>{let r=n===void 0?void 0:k.get(n),i=r?r.x:e+$l>window.innerWidth,a=r?r.y:t+eu>window.innerHeight;return{"data-flip-x":i?`true`:void 0,"data-flip-y":a?`true`:void 0}},F=t=>$(nl,{accept:e.accept,attachments:l.value,busy:t.busy||c.value===t,error:t.error,mentions:t.mentions,modelValue:t.body,onCancel:()=>o.cancelDraft(),files:s.value,frame:`none`,layout:`row`,onSubmit:async e=>{if(t.busy||c.value===t||o.draft.value!==t)return;c.value=t,t.error=void 0,t.mentions=e.mentions;let n=s.value,r=t.body,i=t.mentions;try{let a=await u(e.files);if(o.draft.value!==t||t.body!==r||t.mentions!==i||s.value!==n)return;t.attachments=a,await o.send()&&s.value===n&&(s.value=[])}catch(e){t.error=e instanceof Error?e.message:`The files could not be uploaded. Try again.`}finally{c.value===t&&(c.value=null)}},"onUpdate:files":e=>s.value=e,"onUpdate:mentions":e=>t.mentions=e,"onUpdate:modelValue":e=>t.body=e,people:d.value?[d.value]:[],size:e.size,user:d.value,users:o.users}),ie=Y(typeof window>`u`?0:window.innerWidth),ae=()=>{ie.value=window.innerWidth,E()};Kr(()=>window.addEventListener(`resize`,ae,{passive:!0})),Jr(()=>window.removeEventListener(`resize`,ae));let oe=Q(()=>e.placement===`margin`&&ie.value>=ou),I=cn(new Map),L=new Map,se=typeof ResizeObserver==`function`?new ResizeObserver(e=>{for(let t of e){let e=t.target.getAttribute(`data-margin-key`),n=Math.round(t.target.getBoundingClientRect().height);e&&n&&I.get(e)!==n&&I.set(e,n)}}):void 0;Jr(()=>se?.disconnect());let ce=e=>t=>{let n=L.get(e);n&&n!==t&&se?.unobserve(n),t instanceof Element?(L.set(e,t),se?.observe(t)):L.delete(e)},le=t=>$(Ql,{accept:e.accept,attachmentUrl:e.attachmentUrl,attachments:l.value,can:e.can,key:t.id,detached:o.positions.value.get(t.id)?.detached===!0,readOnly:e.readOnly,size:e.size,onClose:()=>o.close(),onDelete:e=>o.remove(t.id,e),onEdit:(e,n,r)=>o.edit(t.id,e,n,r),onReopen:()=>o.reopen(t.id),onReply:async(e,n,r)=>o.reply(t.id,e,n,await u(r)),onResolve:async()=>{await o.resolve(t.id),o.close()},thread:t,user:d.value}),ue=(e,t)=>{let n=f.value.flatMap(t=>{let n=o.shown.value.has(t.id)?e.get(t.id):void 0;return n?[{active:o.openId.value===t.id,key:t.id,thread:t,y:n.y}]:[]});t!==void 0&&n.push({active:!0,key:sl,y:t}),n.sort((e,t)=>e.y-t.y);let r=e=>I.get(e.key)??(e.active?eu:cu),i=[],a=-1/0;for(let e of n){let t=Math.max(e.y-16,a+su);i.push(t),a=t+r(e)}let s=window.innerHeight-16;return n.forEach((e,t)=>{if(!(!e.active||i[t]+r(e)<=s)){i[t]=Math.max(16,s-r(e));for(let e=t-1;e>=0;e--)i[e]=Math.min(i[e],i[e+1]-su-r(n[e]));for(let e=t+1;e<n.length;e++)i[e]=Math.max(i[e],i[e-1]+su+r(n[e-1]))}}),{at:new Map(n.map((e,t)=>[e.key,i[t]])),node:$(`div`,{"data-slot":`comment-margin`},n.flatMap((e,t)=>{let n=e.thread;return!n||e.active?[]:[$(`button`,{"aria-label":`Comment ${n.n}: ${Os(n.messages[0]?.body??``)}`,"data-margin-key":e.key,"data-slot":`comment-margin-card`,"data-status":n.status,key:e.key,onClick:()=>o.open(n),onPointerenter:()=>{o.draft.value||(o.hoverId.value=n.id)},onPointerleave:()=>{o.hoverId.value===n.id&&(o.hoverId.value=null)},ref:ce(e.key),style:{top:`${i[t]}px`},type:`button`},Ml(n))]}))}};return()=>{let n=new Map;for(let e of p.value){let t=o.positions.value.get(e.id);if(!t||t.detached||t.clipped||e.anchor.kind===`page`)continue;let r=e=>[...n.values()].some(n=>Math.abs(n.x-t.x)<iu&&Math.abs(n.y-e)<iu),i=t.y;for(;r(i);)i+=iu;if(i!==t.y&&i>window.innerHeight-iu)for(i=t.y-iu;r(i);)i-=iu;n.set(e.id,{...t,y:i})}let r=p.value.flatMap(t=>{let r=n.get(t.id);if(!r)return[];let i=!o.shown.value.has(t.id),a=o.openId.value===t.id,s=o.hoverId.value===t.id&&!i&&!a&&!o.draft.value&&!oe.value;return[$(`div`,{...P(r.x,r.y,t.id),"data-kind":t.anchor.kind,"data-leaving":i?`true`:void 0,"data-slot":`comment-layer-item`,inert:i||void 0,key:t.id,ref:N(t.id),style:O(r)},[$(Ll,{active:a,author:t.author,"data-shape":nu(t.anchor.kind),"data-thread-id":t.id,excerpt:Os(t.messages[0]?.body??``),n:t.n,onHover:()=>{!a&&!x&&!o.draft.value&&(o.hoverId.value=t.id)},onLeave:()=>{o.hoverId.value===t.id&&(o.hoverId.value=null)},onSelect:()=>a?o.close():o.open(t),status:t.status}),s?$(`div`,{"data-preview":`true`,"data-slot":`comment-layer-popover`},$(Ql,{preview:!0,size:e.size,thread:t})):null])]}),a=o.draft.value,s=a&&o.positions.value.get(`draft`),c=s&&!s.detached&&a?.anchor.kind!==`page`?s:a?.point,l=!!(oe.value&&a&&c&&a.anchor.kind!==`page`),u=oe.value?ue(n,l?c.y:void 0):null,f=e=>{let t=u?.at.get(e);return t===void 0?void 0:{"data-margin":`true`,"data-margin-key":e,style:{top:`${t}px`}}},g=o.opened.value,b=g&&o.positions.value.get(g.id),S=b&&!b.detached&&!b.clipped&&g?.anchor.kind!==`page`?n.get(g.id)??b:void 0,E=g&&S?f(g.id):void 0,D=g?$(`div`,{...S?P(S.x,S.y,`opened-thread`):{},"data-kind":g.anchor.kind,"data-slot":`comment-layer-item`,key:`opened-thread`,ref:N(`opened-thread`),style:S?O(S):void 0},$(`div`,{...E,"data-floating":S?void 0:`true`,"data-slot":`comment-layer-popover`,ref:e=>E&&ce(g.id)(e)},le(g))):null,k=a&&c?tu(c,a.anchor.kind===`page`,T.value,ie.value):void 0,A=l?f(sl):void 0,j=a&&k?$(`div`,{...P(k.x,k.y),"data-flip-x":k.flipX?`true`:void 0,...(a.anchor.kind===`area`||a.anchor.kind===`image`)&&k.y>72&&!w.value?{"data-above":`true`}:{},"data-draft":`true`,"data-kind":a.anchor.kind,"data-slot":`comment-layer-item`,style:O(k)},[$(Ll,{author:d.value,"data-shape":nu(a.anchor.kind),draft:!0}),$(`div`,{...A,"data-slot":`comment-layer-popover`,style:A?.style??{left:`${k.left}px`,right:`auto`},ref:e=>{C.value=e instanceof HTMLElement?e:null,A&&ce(sl)(e)}},F(a))]):null;return $(`div`,{"data-active":o.active.value?`true`:void 0,"data-comments-ui":``,"data-slot":`comment-layer`,ref:i},[o.active.value?$(`div`,{"data-slot":`comment-layer-overlay`,onPointercancel:()=>{m=null,h.value=null},onPointerdown:_,onPointermove:v,onPointerup:y},h.value?[$(`div`,{"data-slot":`comment-layer-area`,style:{left:`${h.value.left}px`,top:`${h.value.top}px`,width:`${h.value.width}px`,height:`${h.value.height}px`}},[...[`top-left`,`top-right`,`bottom-left`,`bottom-right`].map(e=>$(`span`,{"data-corner":e,"data-slot":`comment-layer-area-handle`,key:e})),$(`span`,{"data-slot":`comment-layer-area-size`},`${Math.round(h.value.width)} × ${Math.round(h.value.height)}`)])]:[]):null,...r,j,D,u?.node,t.default?.({comments:o})??[$(Il,{comments:o,people:e.people}),o.listOpen.value?$(Fl,{comments:o,navigate:e.navigate}):null]])}}}),du=new Set([`row`,`preview`,`group-header`,`list-actions`]);function fu(e){return e instanceof Error?e.message:`The comment could not be sent. Try again.`}var pu=(e,t)=>e.kind===t.kind&&e.id===t.id,mu=Z({name:`CommentPanel`,props:{comments:{type:Object},client:{type:Object},subject:{type:Object},user:{type:Object},variant:{default:`docked`,type:String},thread:{default:void 0,type:[String,null]},status:{type:String},title:{default:`Comments`,type:String},readOnly:{default:!1,type:Boolean},upload:{type:Function},accept:{type:String},attachmentUrl:{type:Function},allowEmpty:{default:!1,type:Boolean},people:{default:()=>[],type:Array},can:{type:Function},group:{type:Function}},emits:[`update:thread`,`update:status`,`select`],slots:Object,setup(e,{emit:t,slots:n}){let r=Ac(`UButton`),i=e.comments??zs();if(!i&&(!e.client||!e.subject))throw Gs.UI_R0002({message:"CommentPanel needs a comments state: put it inside CommentLayer, pass `comments`, or pass a `client` and a `subject`."});let a=vl(i??gl({client:e.client,hotkey:!1,subject:()=>e.subject,user:()=>e.user}));_l(a);let o=Y(null),s=Y(null),c=Y(`open`),l=Q(()=>e.thread===void 0?s.value:e.thread),u=Q(()=>e.status??c.value),d=Q(()=>a.threads.value.filter(e=>a.scope.value===`site`||pu(e.subject,a.subject.value))),f=Q(()=>d.value.filter(e=>e.status===u.value||u.value===`open`&&al(e))),p=Q(()=>l.value?a.threads.value.find(e=>e.id===l.value):void 0);X(p,(e,t,n)=>{e&&n(a.retainMark(e.id))},{immediate:!0,flush:`sync`});let m=Y(``),h=Y([]),g=Y([]),_=Y(!1),v=Y();function y(e){s.value=e,t(`update:thread`,e)}function b(e){c.value=e,t(`update:status`,e)}function x(e){t(`select`,e),y(e.id),Kn(()=>o.value?.querySelector(`[data-slot='comment-thread']`)?.focus())}function S(){let e=l.value;y(null),Kn(()=>{[...o.value?.querySelectorAll(`[data-slot='comment-panel-item']`)??[]].find(t=>t.dataset.threadId===e)?.focus()})}let C=Q(()=>e.upload!==void 0&&a.client.transport.supportsAttachments!==!1),w=async t=>C.value&&t.length>0&&e.upload?e.upload(t):[],T=()=>`${a.subject.value.kind}\u0000${a.subject.value.id}`,E=0;X(T,()=>{E++,m.value=``,h.value=[],g.value=[],v.value=void 0,_.value=!1});async function D(e){if(_.value)return;let t=++E;_.value=!0,v.value=void 0;let n={body:m.value,files:g.value,mentions:h.value};try{let r=await w(e.files);if(t!==E)return;await a.create({attachments:r,body:e.body,mentions:e.mentions}),t===E&&m.value===n.body&&g.value===n.files&&h.value===n.mentions&&(m.value=``,h.value=[],g.value=[])}catch(e){t===E&&(v.value=fu(e))}finally{t===E&&(_.value=!1)}}let O=()=>Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0&&!du.has(e))),k=Q(()=>{let t=[];for(let n of f.value){let r=e.group?e.group(n):u.value===`open`&&n.status===`resolved`?`Replied since resolved`:void 0,i=t.find(e=>e.label===r);i||t.push(i={label:r,threads:[]}),i.threads.push(n)}return t.sort((e,t)=>Number(e.label!==void 0)-Number(t.label!==void 0))}),A=e=>$(`li`,{key:e.id},[$(`button`,{"data-focus-inset":``,"data-slot":`comment-panel-item`,"data-status":e.status,"data-thread-id":e.id,onClick:()=>x(e),type:`button`},n.row?.(jl(e))??Ml(e,{detached:a.positions.value.get(e.id)?.detached===!0,preview:n.preview?.(jl(e)),site:a.scope.value===`site`}))]),j=(e,t,n)=>$(`ol`,{"aria-label":t,"data-slot":`comment-panel-items`,key:n},e.map(A)),ee=()=>k.value.map(({label:t,threads:r})=>t===void 0?j(r,e.title,`ungrouped`):$(`section`,{"aria-label":t,"data-slot":`comment-panel-group`,key:t},[$(`h3`,{"data-slot":`comment-panel-group-header`},n[`group-header`]?.({group:t,threads:r})??t),j(r,t)])),M=()=>{let t=a.counts.value,i=(e,t,n)=>$(r,{"aria-pressed":String(u.value===e),color:`neutral`,"data-slot":`comment-panel-filter`,"data-state":u.value===e?`on`:`off`,label:`${t} ${n}`,onClick:()=>b(e),size:`xs`,variant:u.value===e?`soft`:`ghost`}),o=a.status.value===`loading`&&a.threads.value.length===0?`Loading comments.`:a.status.value===`error`?`The comments could not load.`:u.value===`open`?`No open comments.`:`No resolved comments.`;return[$(`header`,{"data-slot":`comment-panel-header`},[$(`h2`,{"data-slot":`comment-panel-title`},e.title),$(`div`,{"aria-label":`Filter comments`,"data-slot":`comment-panel-filters`,role:`group`},[i(`open`,`Open`,t.open),i(`resolved`,`Resolved`,t.resolved)]),n[`list-actions`]?$(`div`,{"data-slot":`comment-panel-actions`},n[`list-actions`]()):null]),f.value.length===0?$(`p`,{"data-slot":`comment-panel-empty`,role:`status`},o):e.group||k.value.some(e=>e.label!==void 0)?$(`div`,{"data-slot":`comment-panel-groups`},ee()):j(f.value,e.title),e.readOnly?null:$(`div`,{"data-slot":`comment-panel-composer`},[$(nl,{accept:e.accept,allowEmpty:e.allowEmpty,attachments:C.value,autofocus:!1,busy:_.value,error:v.value,files:g.value,guard:!1,layout:`row`,mentions:h.value,modelValue:m.value,onSubmit:D,"onUpdate:files":e=>g.value=e,"onUpdate:mentions":e=>h.value=e,"onUpdate:modelValue":e=>m.value=e,people:e.people,placeholder:`Comment on this page`,user:a.user.value},{...n.extra?{extra:n.extra}:{},...n[`mention-item`]?{"mention-item":n[`mention-item`]}:{},...n[`mention-empty`]?{"mention-empty":n[`mention-empty`]}:{}})])]},te=t=>$(Ql,{accept:e.accept,attachmentUrl:e.attachmentUrl,attachments:C.value,can:e.can,detached:a.positions.value.get(t.id)?.detached===!0,dismissible:!1,key:t.id,navigation:`back`,onClose:S,onDelete:async e=>{await a.remove(t.id,e)||S()},onEdit:(e,n,r)=>a.edit(t.id,e,n,r),onReopen:()=>a.reopen(t.id),onReply:async(e,n,r)=>a.reply(t.id,e,n,await w(r)),onResolve:()=>a.resolve(t.id),people:e.people,readOnly:e.readOnly,thread:t,user:a.user.value},O());return()=>$(`section`,{"aria-label":p.value?`Comment ${p.value.n}`:e.title,"data-comments-ui":``,"data-slot":`comment-panel`,"data-variant":e.variant,"data-view":p.value?`thread`:`list`,ref:o},p.value?te(p.value):M())}}),hu=`:host{color:canvastext;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font:14px/1.45 system-ui,-apple-system,Segoe UI,sans-serif}*,:before,:after{box-sizing:border-box}[data-slot=standalone-icon]{flex:none;width:1.1em;height:1.1em;display:inline-block}[data-standalone-button]{appearance:none;border-radius:var(--vh-radius);color:inherit;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;gap:.375rem;padding:.375rem .625rem;font-size:.875rem;font-weight:500;line-height:1.25rem;text-decoration:none;display:inline-flex}[data-standalone-button][data-size=xs]{gap:.25rem;padding:.25rem .5rem;font-size:.75rem;line-height:1rem}[data-standalone-button][data-size=sm]{padding:.375rem .625rem;font-size:.75rem}[data-standalone-button][data-square=true]{padding:.375rem}[data-standalone-button][data-size=xs][data-square=true]{padding:.25rem}[data-standalone-button][data-variant=solid]{background:var(--vh-highlighted);color:var(--vh-inverted)}[data-standalone-button][data-variant=solid][data-color=primary]{background:var(--vh-primary);color:var(--vh-inverted)}[data-standalone-button][data-variant=solid][data-color=error]{background:var(--vh-error);color:var(--vh-inverted)}[data-standalone-button][data-variant=outline]{border-color:var(--vh-border)}[data-standalone-button][data-variant=soft]{background:var(--vh-bg-accented)}[data-standalone-button][data-variant=ghost]{color:var(--vh-muted)}[data-standalone-button]:is([data-variant=ghost],[data-variant=outline],[data-variant=soft]):hover:not(:disabled){background:var(--vh-bg-accented);color:var(--vh-highlighted)}[data-standalone-button][data-variant=solid]:hover:not(:disabled){opacity:.9}[data-standalone-button].rounded-full{border-radius:9999px}[data-standalone-button][aria-busy=true]{opacity:.6}[data-standalone-button]:disabled{cursor:default;opacity:.4}[data-slot=standalone-modal-trigger]{display:contents}[data-slot=standalone-modal]{background:color-mix(in oklab, var(--vh-bg-elevated) 75%, transparent);pointer-events:auto;z-index:2147483002;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}[data-slot=standalone-modal]>[role=dialog]{background:var(--vh-bg);border-radius:calc(var(--vh-radius) * 1.5);color:var(--vh-text);max-width:calc(100vw - 2rem);max-height:calc(100dvh - 2rem);overflow:auto}`,gu=`@layer theme,base,comark;@layer components{:root,:host{--vh-comment-default-mark:oklch(58.8% .158 241.966);--vh-comment-default-pin:oklch(20.5% 0 0);--vh-comment-default-pin-text:oklch(98.5% 0 0);--vh-comment-default-surface:oklch(100% 0 0);--vh-comment-default-muted:oklch(50% 0 0);--vh-comment-default-ink:oklch(20.5% 0 0);--vh-comment-shadow:oklch(0% 0 0/.18)}:root,:host,:where([data-slot^=comment-mark],[data-slot=comment-pin],[data-slot^=comment-layer-area]){--vh-comment-mark:var(--vh-ui-comment-mark,var(--vh-focus,var(--vh-comment-default-mark)));--vh-comment-pin:var(--vh-ui-comment-pin,var(--vh-primary,var(--vh-comment-default-pin)));--vh-comment-pin-text:var(--vh-ui-comment-pin-text,var(--vh-inverted,var(--vh-comment-default-pin-text)));--vh-comment-surface:var(--vh-ui-comment-surface,var(--vh-bg,var(--vh-comment-default-surface)));--vh-comment-muted:var(--vh-ui-comment-muted,var(--vh-muted,var(--vh-comment-default-muted)));--vh-comment-ink:var(--vh-ui-comment-ink,var(--vh-highlighted,var(--vh-comment-default-ink)));--vh-comment-pin-size:var(--vh-ui-comment-pin-size,28px)}:root.dark,:root[data-theme=dark],:host(.dark),:host([data-theme=dark]){--vh-comment-default-mark:oklch(74.6% .16 232.661);--vh-comment-default-pin:oklch(98.5% 0 0);--vh-comment-default-pin-text:oklch(20.5% 0 0);--vh-comment-default-surface:oklch(14.5% 0 0);--vh-comment-default-muted:oklch(70.8% 0 0);--vh-comment-default-ink:oklch(98.5% 0 0)}@media (prefers-color-scheme:dark){:root:not(.light,.dark,[data-theme]){--vh-comment-default-mark:oklch(74.6% .16 232.661);--vh-comment-default-pin:oklch(98.5% 0 0);--vh-comment-default-pin-text:oklch(20.5% 0 0);--vh-comment-default-surface:oklch(14.5% 0 0);--vh-comment-default-muted:oklch(70.8% 0 0);--vh-comment-default-ink:oklch(98.5% 0 0)}}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]){background:var(--vh-comment-pin);border-radius:calc(var(--vh-comment-pin-size) / 2) calc(var(--vh-comment-pin-size) / 2) calc(var(--vh-comment-pin-size) / 2) 4px;box-shadow:0 0 0 2px var(--vh-comment-surface), 0 2px 8px var(--vh-comment-shadow);box-sizing:border-box;color:var(--vh-comment-pin-text);cursor:pointer;height:var(--vh-comment-pin-size);letter-spacing:.02em;scale:var(--vh-comment-zoom,1);transform-origin:0 100%;width:var(--vh-comment-pin-size);border:0;place-items:center;padding:0;font-size:11px;font-weight:600;line-height:1;transition:scale .12s ease-out,opacity .15s ease-out;display:grid;position:absolute}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-shape=round]{border-radius:calc(var(--vh-comment-pin-size) / 2);transform-origin:50%}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])>img{border-radius:inherit;object-fit:cover;width:100%;height:100%;display:block}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):before{content:"";border-radius:50%;position:absolute;inset:-8px}:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):is(:hover,:focus-visible,[data-active=true]){scale:calc(var(--vh-comment-zoom,1) * 1.06)}@media not ((hover:hover) and (pointer:fine)){:is([data-slot=comment-mark-pin],[data-slot=comment-pin]):hover:not(:focus-visible,[data-active=true]){scale:var(--vh-comment-zoom,1)}}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-status=resolved]{filter:grayscale();opacity:.55}:is([data-slot=comment-mark-pin],[data-slot=comment-pin])[data-status=resolved]:not(:has(img)){background:var(--vh-comment-muted)}:is([data-slot=comment-mark-area],[data-slot=comment-layer-area]){border:calc(1px * var(--vh-comment-zoom,1)) solid color-mix(in oklab, var(--vh-comment-ink) 22%, transparent);box-sizing:border-box;pointer-events:none;border-radius:4px;transition:border-color .12s ease-out,background-color .12s ease-out;position:absolute}[data-slot=comment-mark-area][data-status=resolved]{border-color:color-mix(in oklab, var(--vh-comment-muted) 50%, transparent);border-style:dashed}[data-slot=comment-mark-area][data-active=true]{border-color:color-mix(in oklab, var(--vh-comment-ink) 45%, transparent);border-style:solid}:is([data-slot=comment-mark-area][data-draft=true],[data-slot=comment-layer-area]){background:color-mix(in oklab, var(--vh-comment-mark) 16%, transparent);border:calc(2px * var(--vh-comment-zoom,1)) solid var(--vh-comment-mark);border-radius:3px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle]){background:var(--vh-comment-surface);border:1.5px solid var(--vh-comment-mark);box-sizing:border-box;border-radius:50%;width:8px;height:8px;position:absolute}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner^=top]{top:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner^=bottom]{bottom:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner$=left]{left:-5px}:is([data-slot=comment-mark-handle],[data-slot=comment-layer-area-handle])[data-corner$=right]{right:-5px}:is([data-slot=comment-mark-pin],[data-slot=comment-mark-area])[data-leaving=true],[data-slot=comment-layer-item][data-leaving=true]>*{pointer-events:none;animation:.13s cubic-bezier(.4,0,1,1) forwards vh-comment-mark-leave}[data-slot=comment-mark-area][data-leaving=true]{animation-name:vh-comment-mark-leave-area}@keyframes vh-comment-mark-leave{to{opacity:0;scale:calc(var(--vh-comment-zoom,1) * .8)}}@keyframes vh-comment-mark-leave-area{to{opacity:0;scale:.97}}@media (prefers-reduced-motion:reduce){:is([data-slot=comment-mark-pin],[data-slot=comment-pin],[data-slot=comment-mark-area],[data-slot=comment-layer-area]){transition:none}:is([data-slot=comment-mark-pin],[data-slot=comment-mark-area])[data-leaving=true],[data-slot=comment-layer-item][data-leaving=true]>*{opacity:0;animation:none}}::highlight(vh-comment){background-color:color-mix(in oklab, var(--vh-comment-ink) 13%, transparent)}::highlight(vh-comment-resolved){background-color:color-mix(in oklab, var(--vh-comment-ink) 6%, transparent)}::highlight(vh-comment-active),::highlight(vh-comment-draft){background-color:color-mix(in oklab, var(--vh-comment-ink) 26%, transparent)}@starting-style{[data-copied] [data-slot=copy-button-icon]>[data-icon=check]{filter:blur(3px);opacity:0;scale:.3}}:is([data-slot=message-group],[data-slot=bubble-group]){flex-direction:column;gap:.5rem;min-width:0;display:flex}[data-slot=message][data-align]{gap:.5rem;width:100%;min-width:0;font-size:.875rem;line-height:1.25rem;display:flex;position:relative}[data-slot=message][data-align=end]{flex-direction:row-reverse}:is([data-slot=message-header],[data-slot=message-footer]){color:var(--vh-muted);align-items:center;min-width:0;max-width:100%;padding-inline:.75rem;font-size:.75rem;font-weight:500;line-height:1rem;display:flex}[data-slot=message][data-align]:is(:has([data-variant=ghost]),:not(:has([data-slot=bubble]))) :is([data-slot=message-header],[data-slot=message-footer]){padding-inline:0}[data-slot=bubble]{flex-direction:column;gap:.25rem;width:fit-content;min-width:0;max-width:80%;display:flex;position:relative}:is([data-slot=bubble][data-align=end],[data-slot=message][data-align=end] [data-slot=bubble]){align-self:flex-end}[data-slot=bubble][data-variant=ghost]{max-width:100%}[data-slot=marker]{color:var(--vh-muted);text-align:left;align-items:center;gap:.5rem;width:100%;min-height:1rem;font-size:.875rem;line-height:1.25rem;display:flex;position:relative}[data-slot=marker] :is(svg,.iconify):not([class*=size-]),[data-slot=marker-icon]{flex-shrink:0;width:1rem;height:1rem}:is(a[data-slot=marker],[data-slot=marker-content]>a){color:inherit;text-underline-offset:3px;text-decoration:underline}@media (hover:hover){:is(a[data-slot=marker],[data-slot=marker-content]>a):hover{color:var(--vh-highlighted)}}[data-slot=marker][data-variant=separator]:before,[data-slot=marker][data-variant=separator]:after{background:var(--vh-border);content:"";flex:1;min-width:0;height:1px}[data-slot=marker][data-variant=separator]:before{margin-right:.25rem}[data-slot=marker][data-variant=separator]:after{margin-left:.25rem}[data-slot=marker][data-variant=border]{border-bottom:1px solid var(--vh-border);padding-bottom:.5rem}[data-slot=marker-content]{overflow-wrap:break-word;min-width:0}[data-slot=marker][data-variant=separator] [data-slot=marker-content]{text-align:center;flex:none}[data-slot=trace]{flex-direction:column;gap:.5rem;width:100%;min-width:0;display:flex}[data-slot=trace]>:has(>[data-slot=trace-line]){border-radius:calc(var(--vh-radius) * .75);text-align:left;width:fit-content;min-width:0;max-width:100%;display:flex}[data-trace-chevron] svg{stroke:currentColor;stroke-width:2px;transition:rotate .15s}@keyframes vh-trace-open{0%{height:0}to{height:var(--collapsible-panel-height)}}@keyframes vh-trace-close{0%{height:var(--collapsible-panel-height)}to{height:0}}[data-slot=attachment]{background:var(--vh-bg);border:1px solid var(--vh-border);border-radius:calc(var(--vh-radius) * 1.5);color:var(--vh-text);flex-wrap:wrap;flex-shrink:0;width:fit-content;min-width:0;max-width:100%;transition:background-color .15s,border-color .15s;display:flex;position:relative}[data-slot=attachment]:has(>a,>button):hover{background:color-mix(in oklab, var(--vh-bg-elevated) 50%, var(--vh-bg))}[data-slot=attachment][data-state=error]{border-color:color-mix(in oklab, var(--vh-error) 30%, transparent)}[data-slot=attachment][data-state=idle]{border-style:dashed}[data-slot=attachment][data-size=default]{gap:.5rem;font-size:.875rem;line-height:1.25rem}[data-slot=attachment][data-size=default]:has([data-slot=attachment-media]){padding:.5rem}[data-slot=attachment][data-size=default]:has([data-slot=attachment-content]){padding:.5rem .625rem}[data-slot=attachment][data-size=sm]{gap:.625rem;font-size:.75rem;line-height:1rem}[data-slot=attachment][data-size=sm]:has([data-slot=attachment-media]){padding:.375rem}[data-slot=attachment][data-size=sm]:has([data-slot=attachment-content]){padding:.375rem .5rem}[data-slot=attachment][data-size=xs]{border-radius:var(--vh-radius);gap:.375rem;font-size:.75rem;line-height:1rem}[data-slot=attachment][data-size=xs]:has([data-slot=attachment-media]){padding:.25rem}[data-slot=attachment][data-size=xs]:has([data-slot=attachment-content]){padding:.25rem .375rem}[data-slot=attachment][data-orientation=horizontal]{align-items:center;min-width:10rem}[data-slot=attachment][data-orientation=vertical]{flex-direction:column;width:6rem}[data-slot=attachment][data-orientation=vertical]:has([data-slot=attachment-content]){width:7.5rem}[data-slot=attachment-media]{aspect-ratio:1;background:var(--vh-bg-elevated);border-radius:var(--vh-radius);color:var(--vh-highlighted);flex-shrink:0;justify-content:center;align-items:center;width:2.5rem;display:flex;position:relative;overflow:hidden}[data-slot=attachment][data-orientation=vertical] [data-slot=attachment-media]{width:100%}[data-slot=attachment][data-size=sm] [data-slot=attachment-media]{width:2rem}[data-slot=attachment][data-size=xs] [data-slot=attachment-media]{border-radius:calc(var(--vh-radius) * .75);width:1.75rem}[data-slot=attachment][data-state=error] [data-slot=attachment-media]{background:color-mix(in oklab, var(--vh-error) 10%, transparent);color:var(--vh-error)}[data-slot=attachment-media] svg{pointer-events:none}[data-slot=attachment-media] :is(svg,.iconify):not([class*=size-]){width:1rem;height:1rem}[data-slot=attachment][data-orientation=vertical] [data-slot=attachment-media] :is(svg,.iconify):not([class*=size-]){width:1.5rem;height:1.5rem}[data-slot=attachment][data-size=xs] [data-slot=attachment-media] :is(svg,.iconify):not([class*=size-]){width:.875rem;height:.875rem}[data-slot=attachment-media][data-variant=image]{opacity:.6}[data-slot=attachment]:is([data-state=done],[data-state=idle]) [data-slot=attachment-media][data-variant=image]{opacity:1}[data-slot=attachment-media][data-variant=image]>img{aspect-ratio:1;object-fit:cover;width:100%}[data-slot=attachment-content]{flex:1;min-width:0;max-width:100%;line-height:1.25}[data-slot=attachment][data-orientation=vertical] [data-slot=attachment-content]{padding-inline:.25rem}[data-slot=attachment-title]{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:100%;font-weight:500;display:block;overflow:hidden}[data-slot=attachment-description]{color:var(--vh-muted);text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:100%;margin-top:.125rem;font-size:.75rem;line-height:1rem;display:block;overflow:hidden}[data-slot=attachment][data-state=error] [data-slot=attachment-description]{color:color-mix(in oklab, var(--vh-error) 80%, transparent)}[data-slot=attachment-actions]{z-index:20;flex-shrink:0;align-items:center;display:flex;position:relative}[data-slot=attachment][data-orientation=vertical] [data-slot=attachment-actions]{gap:.25rem;position:absolute;top:.75rem;right:.75rem}[data-slot=attachment-trigger]{border-radius:inherit;cursor:pointer;z-index:10;background:0 0;border:0;padding:0;position:absolute;inset:0}[data-slot=attachment-group]{overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scrollbar-width:none;gap:.75rem;min-width:0;padding-block:.25rem;scroll-padding-inline:.25rem;display:flex;overflow-x:auto}[data-slot=attachment-group]>[data-slot=attachment]{scroll-snap-align:start;flex:none}[data-slot=message-scroller]{flex-direction:column;width:100%;height:100%;min-height:0;display:flex;position:relative;overflow:hidden}[data-slot=message-scroller-viewport]{overscroll-behavior:contain;scrollbar-gutter:stable;scrollbar-width:thin;width:100%;min-width:0;height:100%;min-height:0;overflow-y:auto}[data-slot=message-scroller-content]{flex-direction:column;gap:1.5rem;height:max-content;min-height:100%;display:flex}[data-slot=message-scroller-item]{flex-shrink:0;min-width:0}[data-slot=message-scroller-button]{background:var(--vh-bg);border:1px solid var(--vh-border);border-radius:var(--vh-radius);color:var(--vh-highlighted);cursor:pointer;justify-content:center;align-items:center;width:2rem;height:2rem;transition:background-color .15s;display:flex;position:absolute;bottom:1rem;left:50%;transform:translate(-50%)}@media (hover:hover){[data-slot=message-scroller-button]:hover{background:var(--vh-bg-elevated)}}[data-slot=message-scroller-button][hidden]{display:none}[data-slot=prompt-input]{width:100%}[data-slot=prompt-input-group]{background:var(--vh-bg);border:1px solid var(--vh-border);border-radius:calc(var(--vh-radius) * 2);flex-direction:column;min-width:0;display:flex}[data-slot=prompt-input-attachments]{padding:.5rem .5rem 0}[data-slot=prompt-input-textarea]{color:var(--vh-highlighted);field-sizing:content;font:inherit;resize:none;background:0 0;border:0;width:100%;min-height:3.5rem;max-height:12rem;padding:.75rem .875rem .25rem;font-size:.875rem;line-height:1.5rem}@media (any-pointer:coarse){[data-slot=prompt-input-textarea]{font-size:max(1rem,16px)}}[data-slot=prompt-input-textarea]::placeholder{color:var(--vh-muted)}[data-slot=prompt-input-toolbar]{align-items:center;gap:.375rem;min-width:0;padding:.25rem .5rem .5rem;display:flex}[data-slot=prompt-input-spacer]{flex:1}[data-slot=prompt-input-toolbar] button:active:not(:disabled){scale:.96}@media (pointer:coarse){[data-slot=prompt-input-toolbar] button{position:relative}[data-slot=prompt-input-toolbar] button:before{content:"";position:absolute;inset:-8px}}[data-slot=avatar-stack]{--vh-avatar-size:2rem;isolation:isolate;align-items:center;display:inline-flex}[data-slot=avatar-stack][data-size=sm]{--vh-avatar-size:1.5rem}[data-slot=avatar-stack][data-size=lg]{--vh-avatar-size:2.5rem}:is([data-slot=avatar-stack-item],[data-slot=avatar-stack-count]){background:var(--vh-bg-accented);box-shadow:0 0 0 2px var(--vh-bg);color:var(--vh-highlighted);font-size:calc(var(--vh-avatar-size) * .4);height:var(--vh-avatar-size);-webkit-user-select:none;user-select:none;width:var(--vh-avatar-size);border-radius:9999px;flex:none;justify-content:center;align-items:center;font-weight:500;line-height:1;display:inline-flex;overflow:hidden}:is([data-slot=avatar-stack-item],[data-slot=avatar-stack-count])+:is([data-slot=avatar-stack-item],[data-slot=avatar-stack-count]){margin-inline-start:calc(var(--vh-avatar-size) * -.15)}[data-slot=avatar-stack-count]{color:var(--vh-muted);font-size:calc(var(--vh-avatar-size) * .34)}[data-slot=avatar-stack][data-variant=outline] [data-slot=avatar-stack-item]{box-shadow:0 0 0 2px var(--vh-bg), 0 0 0 4px var(--vh-avatar-color,var(--vh-border))}[data-slot=avatar-stack][data-variant=outline] :is([data-slot=avatar-stack-item],[data-slot=avatar-stack-count])+:is([data-slot=avatar-stack-item],[data-slot=avatar-stack-count]){margin-inline-start:calc(var(--vh-avatar-size) * .05)}[data-slot=avatar-stack-image]{object-fit:cover;width:100%;height:100%}:is([data-slot=connection-status],[data-slot=sync-status]){color:var(--vh-muted);white-space:nowrap;align-items:center;gap:.375rem;font-size:.75rem;line-height:1rem;display:inline-flex}:is([data-slot=connection-status-indicator],[data-slot=sync-status-indicator]){background:var(--vh-dimmed);border-radius:9999px;flex:none;width:.5rem;height:.5rem;position:relative}:is([data-slot=connection-status-indicator][data-status=connected],[data-slot=sync-status-indicator][data-status=synchronized]){background:var(--vh-success)}:is([data-slot=connection-status-indicator][data-status=reconnecting],[data-slot=sync-status-indicator][data-status=synchronizing]){background:var(--vh-warning)}:is([data-slot=connection-status][data-status=reconnecting],[data-slot=sync-status][data-status=error]){color:var(--vh-highlighted)}:is([data-slot=connection-status-indicator]:not([data-status=connected]),[data-slot=sync-status-indicator]:is([data-status=loading],[data-status=synchronizing])):after{background:inherit;border-radius:inherit;content:"";animation:1.5s cubic-bezier(0,0,.2,1) infinite vh-status-ping;position:absolute;inset:0}@keyframes vh-status-ping{75%,to{opacity:0;transform:scale(2.25)}}@media (prefers-reduced-motion:reduce){:is([data-slot=connection-status-indicator],[data-slot=sync-status-indicator]):after{animation:none}}:is([data-slot=relative-time],[data-slot=comment-reply-time]){font-variant-numeric:tabular-nums}[data-slot=status]{align-items:center;gap:.375rem;min-width:0;font-size:.75rem;line-height:1rem;display:inline-flex}[data-slot=status][data-size=md]{font-size:.875rem;line-height:1.25rem}[data-slot=status][data-colored][data-tone=success]{color:var(--vh-text-success,var(--vh-success))}[data-slot=status][data-colored][data-tone=warning]{color:var(--vh-text-warning,var(--vh-warning))}[data-slot=status][data-colored][data-tone=error]{color:var(--vh-text-error,var(--vh-error))}[data-slot=status][data-colored][data-tone=info]{color:var(--vh-text-info,var(--vh-info))}.collaboration-carets__caret{pointer-events:none;word-break:normal;border-inline:1px solid;margin-inline:-1px;position:relative}.collaboration-carets__label{border-radius:calc(var(--vh-radius) * .5) calc(var(--vh-radius) * .5) calc(var(--vh-radius) * .5) 0;color:var(--vh-inverted);inset-inline-start:-1px;-webkit-user-select:none;user-select:none;white-space:nowrap;padding:.0625rem .375rem;font-size:.75rem;font-style:normal;font-weight:600;line-height:1.25;position:absolute;top:-1.4em}[data-slot=comment-layer]{pointer-events:none;z-index:2147483000;position:fixed;inset:0}[data-slot=comment-layer]>*{pointer-events:auto}[data-slot=comment-layer-overlay]{cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M2 26V14a12 12 0 1 1 12 12H2z' fill='%23fff' stroke='%23111' stroke-width='1.5'/%3E%3C/svg%3E") 2 26,crosshair;position:absolute;inset:0}[data-slot=comment-layer-area-size]{background:color-mix(in oklab, var(--vh-comment-mark), black 10%);color:var(--vh-on-media,white);font-variant-numeric:tabular-nums;white-space:nowrap;border-radius:.25rem;padding:.0625rem .3125rem;font:500 .6875rem/1rem ui-monospace,SFMono-Regular,Menlo,monospace;position:absolute;top:calc(100% + .375rem);left:-2px}[data-slot=comment-margin]{pointer-events:none;width:18rem;position:absolute;top:0;right:1rem}[data-slot=comment-margin-card]{background:var(--vh-bg);border-radius:calc(var(--vh-radius) * 1.5);box-shadow:var(--vh-shadow-floating,0 0 0 1px var(--vh-border));box-sizing:border-box;color:var(--vh-text);font:inherit;pointer-events:auto;text-align:start;border:0;font-size:.875rem;transition:top .16s;position:absolute;left:0;right:0}button[data-slot=comment-margin-card]{cursor:pointer;align-items:flex-start;gap:.5rem;padding:.625rem .75rem;display:flex}button[data-slot=comment-margin-card]:hover{background:var(--vh-bg-elevated)}button[data-slot=comment-margin-card][data-status=resolved]{opacity:.65}[data-slot=comment-layer-item]>[data-slot=comment-layer-popover][data-margin=true][data-margin-key]{z-index:1;width:18rem;transition:top .16s;position:fixed;bottom:auto;left:auto;right:1rem}[data-slot=comment-layer-popover][data-margin=true][data-margin-key]{flex-direction:column;max-height:calc(100dvh - 2rem);display:flex}[data-slot=comment-layer-popover][data-margin=true]>[data-slot=comment-thread]{flex-direction:column;flex:auto;min-height:0;display:flex}[data-slot=comment-layer-popover][data-margin=true] [data-slot=comment-thread-messages]{flex:auto;min-height:0;max-height:none}[data-slot=comment-margin-card] [data-slot=comment-list-text]{-webkit-line-clamp:3}@media (prefers-reduced-motion:reduce){[data-slot=comment-margin-card],[data-slot=comment-layer-popover][data-margin=true]{transition:none}}[data-slot=comment-layer-item]{pointer-events:none;position:absolute}[data-slot=comment-layer-item]>*{pointer-events:auto}[data-slot=comment-pin]{transform:translateY(-100%)}[data-slot=comment-pin] [data-slot=avatar-stack]{--vh-avatar-size:var(--vh-comment-pin-size);border-radius:inherit}[data-slot=comment-pin] [data-slot=avatar-stack-item]{border-radius:inherit;box-shadow:none;color:inherit;font-size:inherit;font-weight:inherit;background:0 0}[data-slot=comment-pin-number]{background:var(--vh-highlighted);color:var(--vh-inverted);text-align:center;border-radius:9999px;min-width:1rem;padding:.15rem .25rem;font-size:.625rem;font-weight:600;line-height:1;position:absolute;top:-.4rem;right:-.4rem}[data-slot=comment-layer-popover]{--vh-comment-card-width:22.5rem;background:var(--vh-bg);border-radius:calc(var(--vh-radius) * 1.5);box-shadow:var(--vh-shadow-floating,0 0 0 1px var(--vh-border));color:var(--vh-text);max-width:calc(100vw - 1rem);width:var(--vh-comment-card-width);font-size:.875rem;position:absolute;top:.5rem;left:.5rem;overflow:visible}[data-slot=comment-layer-item][data-flip-x=true]>[data-slot=comment-layer-popover]{left:auto;right:clamp(calc(var(--vh-comment-x,0px) + .5rem - 100vw), .5rem, calc(var(--vh-comment-x,100vw) - min(var(--vh-comment-card-width), 100vw - 1rem) - .5rem))}[data-slot=comment-layer-item][data-flip-y=true]>[data-slot=comment-layer-popover]{top:auto;bottom:2.5rem}[data-slot=comment-layer-popover]:not([data-margin],[data-preview]):has(>[data-slot=comment-thread][data-size=sm]){--vh-comment-card-radius:1rem;--vh-comment-card-width:21.25rem;flex-direction:column;max-height:min(28rem,60dvh);display:flex;&>[data-slot=comment-thread]{flex:auto;min-height:0}& [data-slot=comment-thread-messages]{flex:auto;min-height:0;max-height:none}}[data-slot=comment-layer-item]>[data-slot=comment-layer-popover]:not([data-margin],[data-floating],[data-preview]):has(>[data-slot=comment-thread][data-size=sm]){border-radius:.375rem var(--vh-comment-card-radius) var(--vh-comment-card-radius)}[data-slot=comment-layer-item][data-flip-x=true]>[data-slot=comment-layer-popover]:not([data-margin],[data-floating],[data-preview]):has(>[data-slot=comment-thread][data-size=sm]){border-radius:var(--vh-comment-card-radius) .375rem var(--vh-comment-card-radius) var(--vh-comment-card-radius)}[data-slot=comment-layer-item][data-flip-y=true]>[data-slot=comment-layer-popover]:not([data-margin],[data-floating],[data-preview]):has(>[data-slot=comment-thread][data-size=sm]){border-radius:var(--vh-comment-card-radius) var(--vh-comment-card-radius) var(--vh-comment-card-radius) .375rem}[data-slot=comment-layer-item][data-flip-x=true][data-flip-y=true]>[data-slot=comment-layer-popover]:not([data-margin],[data-floating],[data-preview]):has(>[data-slot=comment-thread][data-size=sm]){border-radius:var(--vh-comment-card-radius) var(--vh-comment-card-radius) .375rem}@position-try --vh-comment-above{margin:0 0 2.5rem .5rem;position-area:top right}@position-try --vh-comment-above-left{margin:0 .5rem 2.5rem 0;position-area:top left}@position-try --vh-comment-below-inside{margin:.5rem .5rem 0;position-area:bottom span-all}@position-try --vh-comment-above-inside{margin:0 .5rem 2.5rem;position-area:top span-all}@supports (anchor-name:--a){[data-slot=comment-layer-item]{anchor-name:--vh-comment-spot;anchor-scope:--vh-comment-spot}[data-slot=comment-layer-item]:not([data-draft])>[data-slot=comment-layer-popover]:not([data-margin],[data-floating]){position-anchor:--vh-comment-spot;position-area:bottom right;position-try-fallbacks:flip-inline, --vh-comment-above, --vh-comment-above-left, --vh-comment-below-inside, --vh-comment-above-inside;margin:.5rem 0 0 .5rem;position:fixed;inset:auto}}[data-slot=comment-layer-popover][data-preview=true]{pointer-events:none;width:18rem}[data-slot=comment-layer-popover][data-floating=true]{position:fixed;inset:auto 1rem 4.5rem auto}[data-slot=comment-layer-item][data-draft=true]>[data-slot=comment-layer-popover]{--vh-bubble-edge:color-mix(in oklab, var(--vh-highlighted) 8%, transparent);--vh-bubble-radius:1.4375rem;border-radius:.375rem var(--vh-bubble-radius) var(--vh-bubble-radius);box-shadow:0 0 0 1px var(--vh-bubble-edge), 0 2px 4px color-mix(in oklab, var(--vh-highlighted) 6%, transparent), 0 10px 24px -6px color-mix(in oklab, var(--vh-highlighted) 18%, transparent);transform-origin:0 0;border:0;width:18rem;animation:.15s cubic-bezier(.23,1,.32,1) vh-comment-bubble-in}[data-slot=comment-layer-item][data-draft=true]>[data-slot=comment-layer-popover]:has(>[data-slot=comment-composer][data-size=sm]){--vh-bubble-radius:1.125rem}[data-slot=comment-layer-popover]:has([data-slot=comment-composer][data-frame=none] [data-slot=prompt-input-textarea]:focus-visible){--vh-bubble-edge:color-mix(in oklab, var(--vh-highlighted) 22%, transparent)}[data-slot=comment-layer-item][data-draft=true][data-flip-x=true]>[data-slot=comment-layer-popover]{border-radius:var(--vh-bubble-radius) .375rem var(--vh-bubble-radius) var(--vh-bubble-radius);transform-origin:100% 0}[data-slot=comment-layer-item][data-draft=true][data-flip-y=true]>[data-slot=comment-layer-popover]{border-radius:var(--vh-bubble-radius) var(--vh-bubble-radius) var(--vh-bubble-radius) .375rem;transform-origin:0 100%}[data-slot=comment-layer-item][data-draft=true][data-flip-x=true][data-flip-y=true]>[data-slot=comment-layer-popover]{border-radius:var(--vh-bubble-radius) var(--vh-bubble-radius) .375rem;transform-origin:100% 100%}@keyframes vh-comment-bubble-in{0%{opacity:0;scale:.96}}@media (prefers-reduced-motion:reduce){[data-slot=comment-layer-item][data-draft=true]>[data-slot=comment-layer-popover]{animation:none}}[data-slot=comment-composer]{align-items:flex-start;gap:.5rem;padding:.5rem;display:flex}[data-slot=comment-composer-box]{flex:1;min-width:0;position:relative}[data-slot=comment-composer] [data-slot=prompt-input-textarea]{min-height:2.25rem;padding-block:.5rem .125rem}[data-slot=comment-composer][data-shake=shake]{animation:.4s cubic-bezier(.36,.07,.19,.97) both vh-comment-shake}[data-slot=comment-composer][data-shake=flash] [data-slot=prompt-input-group]{animation:.45s both vh-comment-flash}@keyframes vh-comment-shake{10%,90%{transform:translate(-1px)}20%,80%{transform:translate(3px)}30%,50%,70%{transform:translate(-5px)}40%,60%{transform:translate(5px)}}@keyframes vh-comment-flash{0%,60%{border-color:var(--vh-error);box-shadow:0 0 0 3px color-mix(in oklab, var(--vh-error) 25%, transparent)}}@media (prefers-reduced-motion:reduce){[data-slot=comment-composer][data-shake=shake]{animation:none}}[data-slot=comment-composer-mentions]{background:var(--vh-bg);border-radius:calc(var(--vh-radius) * 1.5);box-shadow:var(--vh-shadow-floating,0 0 0 1px var(--vh-border));z-index:1;width:100%;margin:.25rem 0 0;padding:.25rem;list-style:none;position:absolute;top:100%;left:0}[data-slot=comment-composer-mention]{border-radius:calc(var(--vh-radius) * .75);cursor:pointer;padding:.375rem .5rem}[data-slot=comment-composer-mention][aria-selected=true]{background:var(--vh-bg-accented)}[data-slot=comment-composer-mention-empty]{color:var(--vh-muted);margin:0;padding:.375rem .5rem}[data-slot=comment-composer-error]{color:var(--vh-error);margin:.375rem 0 0;font-size:.75rem}[data-slot=comment-composer-status]{color:var(--vh-muted);margin:0;font-size:.75rem}[data-slot=comment-composer-status]:not(:empty){padding:.25rem .625rem .125rem}[data-slot=comment-thread]{flex-direction:column;display:flex}[data-slot=comment-thread-header]{border-block-end:1px solid var(--vh-border);align-items:center;gap:.25rem;padding:.375rem .5rem .375rem .75rem;display:flex}@media (pointer:coarse){:is([data-slot=comment-thread-header],[data-slot=comment-reply-actions])>:is(button,a){justify-content:center;min-width:2.75rem;min-height:2.75rem}}[data-slot=comment-thread-title]{color:var(--vh-highlighted);font-weight:600}[data-slot=comment-thread-spacer]{flex:1}[data-slot=comment-thread-messages]{flex-direction:column;max-height:22rem;display:flex;overflow-y:auto}[data-slot=comment-thread-quote]{border-inline-start:2px solid var(--vh-border);color:var(--vh-muted);margin:.75rem .75rem 0;padding-inline-start:.625rem}:is([data-slot=comment-thread-detached],[data-slot=comment-thread-count]){color:var(--vh-muted);margin:.5rem .75rem 0;font-size:.75rem}[data-slot=comment-reply]{gap:.5rem;padding:.75rem;display:flex}[data-slot=comment-reply-content]{flex:1;min-width:0}[data-slot=comment-reply-header]{flex-wrap:wrap;align-items:center;gap:.375rem;min-height:1.5rem;display:flex}[data-slot=comment-reply-header]>[data-slot=avatar-stack]{margin-inline-end:.125rem}[data-slot=comment-reply-content]>:not([data-slot=comment-reply-header]){margin-inline-start:2rem}[data-slot=comment-reply-author]{color:var(--vh-highlighted);font-weight:500}:is([data-slot=comment-reply-time],[data-slot=comment-reply-edited]){color:var(--vh-muted);font-size:.75rem}[data-slot=comment-reply-body]{overflow-wrap:anywhere}[data-slot=comment-reply-actions]{opacity:0;transition:opacity .12s;display:flex}[data-slot=comment-reply]:is(:hover,:focus-within) [data-slot=comment-reply-actions]{opacity:1}@media (any-pointer:coarse){[data-slot=comment-reply-actions]{opacity:1}}[data-slot=comment-reply][data-compact=true] [data-slot=comment-reply-body]{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}[data-slot=comment-reply][data-editing=true] [data-slot=comment-composer]{padding:.25rem 0 0}[data-slot=comment-toolbar]{background:var(--vh-bg);box-shadow:var(--vh-shadow-floating,0 0 0 1px var(--vh-border));border-radius:9999px;align-items:center;gap:.25rem;padding:.25rem;display:flex;position:fixed;bottom:1rem;left:50%;transform:translate(-50%)}[data-slot=comment-filters]{flex-wrap:wrap;gap:.25rem;display:flex}[data-slot=comment-list]{background:var(--vh-bg);border-inline-start:1px solid var(--vh-border);color:var(--vh-text);flex-direction:column;width:20rem;max-width:100vw;font-size:.875rem;display:flex;position:fixed;top:0;bottom:0;right:0;overflow-y:auto}[data-slot=comment-list-header]{border-block-end:1px solid var(--vh-border);flex-direction:column;gap:.5rem;padding:.75rem;display:flex}[data-slot=comment-list-scopes]{gap:.25rem;display:flex}[data-slot=comment-list-empty]{color:var(--vh-muted);margin:0;padding:1rem .75rem}[data-slot=comment-list-items]{margin:0;padding:0;list-style:none}[data-slot=comment-list-item]{border-block-end:1px solid var(--vh-border);color:inherit;align-items:flex-start;gap:.5rem;padding:.625rem .75rem;text-decoration:none;display:flex}[data-slot=comment-list-item]:is(:hover,[aria-current=true]){background:var(--vh-bg-elevated)}[data-slot=comment-list-item][data-status=resolved]{opacity:.65}[data-slot=comment-list-number]{color:var(--vh-muted);flex:none;min-width:1.25rem;padding-top:.25rem;font-size:.75rem}[data-slot=comment-list-body]{flex-direction:column;flex:1;gap:.125rem;min-width:0;display:flex}[data-slot=comment-list-text]{-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}[data-slot=comment-list-meta]{color:var(--vh-muted);flex-wrap:wrap;gap:.25rem .5rem;font-size:.75rem;display:flex}[data-slot=comment-reply-confirm]{flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.5rem;display:flex}[data-slot=comment-reply-confirm]>p{flex-basis:100%;margin:0}[data-slot=comment-reply-error]{color:var(--vh-error);margin:.375rem 0 0;font-size:.75rem}[data-slot=comment-mention]{background:var(--vh-comment-mention-bg,color-mix(in oklab, var(--vh-bg-accented) 80%, transparent));border-radius:calc(var(--vh-radius) * .5);color:var(--vh-highlighted);padding:0 .125rem;font-weight:500}[data-slot=comment-mention][data-self=true]{background:var(--vh-comment-mention-self-bg,color-mix(in oklab, var(--vh-warning) 25%, transparent))}[data-slot=comment-composer-extra]{margin-block-end:.375rem}[data-slot=comment-composer-mention]{align-items:center;gap:.5rem;display:flex}[data-slot=comment-composer-mention] [data-slot=avatar-stack]{--vh-avatar-size:1.25rem}[data-slot=comment-composer][data-dragging=true] [data-slot=prompt-input-group]{border-color:var(--vh-primary);box-shadow:0 0 0 3px color-mix(in oklab, var(--vh-primary) 20%, transparent)}[data-slot=comment-composer] [data-slot=prompt-input-attachments]{flex-wrap:wrap;gap:.375rem;overflow:visible}[data-slot=comment-composer] [data-slot=attachment]:has(>[data-slot=attachment-media][data-variant=image]){border-radius:calc(var(--vh-radius) * .75);background:0 0;border:0;min-width:0;padding:0;&>[data-slot=attachment-media]{border-radius:inherit;outline:1px solid color-mix(in oklab, var(--vh-highlighted) 10%, transparent);outline-offset:-1px;width:2.5rem}&>[data-slot=attachment-content]{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}&>[data-slot=attachment-actions]{position:absolute;top:-.375rem;right:-.375rem}}[data-slot=comment-reply-attachments]{flex-wrap:wrap;margin-top:.5rem}[data-slot=comment-panel-groups]{flex:1;min-height:0;overflow-y:auto}[data-slot=comment-panel-groups] [data-slot=comment-panel-items]{flex:none;overflow:visible}[data-slot=comment-panel-group-header]{border-block-start:1px solid var(--vh-border);color:var(--vh-muted);margin:0;padding:.75rem .75rem .25rem;font-size:.75rem;font-weight:500}[data-slot=comment-reply-images]{flex-wrap:wrap;gap:.5rem;margin-top:.5rem;display:flex;& .vh-image-preview{aspect-ratio:auto;width:auto;max-width:100%;max-height:10rem}& .vh-image-preview img{object-fit:contain;width:auto;max-width:100%;height:auto;max-height:10rem}}[data-slot=comment-thread-actions]{align-items:center;gap:.25rem;display:flex}[data-slot=comment-thread-after]{padding:0 .75rem .75rem}[data-slot=comment-panel]{background:var(--vh-bg);color:var(--vh-text);flex-direction:column;min-height:0;font-size:.875rem;display:flex}[data-slot=comment-panel][data-variant=docked]{border-inline-start:1px solid var(--vh-border);height:100%}[data-slot=comment-panel][data-variant=floating]{border-radius:calc(var(--vh-radius) * 1.5);box-shadow:var(--vh-shadow-floating,0 0 0 1px var(--vh-border));width:min(22.5rem,100vw - 1rem);max-height:min(36rem,100dvh - 2rem);overflow:hidden}[data-slot=comment-panel-header]{border-block-end:1px solid var(--vh-border);justify-content:space-between;align-items:center;gap:.5rem;padding:.5rem .5rem .5rem .75rem;display:flex}[data-slot=comment-panel-title]{color:var(--vh-highlighted);font-size:inherit;margin:0;font-weight:600}[data-slot=comment-panel-filters]{flex:1;gap:.25rem;display:flex}[data-slot=comment-panel-actions]{align-items:center;gap:.25rem;margin-block:-.25rem;display:flex}[data-slot=comment-panel-items]{flex:1;min-height:0;margin:0;padding:0;list-style:none;overflow-y:auto}[data-slot=comment-panel-item]{border:0;border-block-end:1px solid var(--vh-border);color:inherit;cursor:pointer;font:inherit;text-align:start;background:0 0;align-items:flex-start;gap:.5rem;width:100%;padding:.625rem .75rem;display:flex}[data-slot=comment-panel-item]:hover{background:var(--vh-bg-elevated)}[data-slot=comment-panel-empty]{color:var(--vh-muted);flex:1;margin:0;padding:1rem .75rem}[data-slot=comment-panel-composer],[data-slot=comment-thread]>[data-slot=comment-composer]{border-block-start:1px solid var(--vh-border)}[data-slot=comment-composer][data-layout=row]{padding:.25rem;& [data-slot=prompt-input-group]{box-shadow:none;background:0 0;border-color:#0000;border-radius:calc(1.125rem + 1px);flex-flow:wrap;align-items:flex-end;gap:.25rem;padding:.125rem}& [data-slot=prompt-input-attachments]{flex-basis:100%;padding:.25rem .25rem 0}& [data-slot=prompt-input-textarea]{flex:1;order:1;width:auto;min-width:0;min-height:2rem;padding:.25rem}& [data-slot=prompt-input-toolbar]{display:contents}& [data-slot=prompt-input-spacer]{display:none}& [data-slot=prompt-input-toolbar]>button:last-child{order:2}& [data-slot=prompt-input-toolbar]>button{justify-content:center;min-width:2rem;height:2rem}}[data-slot=comment-thread][data-size=sm]{font-size:.875rem;line-height:1.25rem}[data-slot=comment-thread][data-size=sm] [data-slot=comment-thread-quote]{margin-top:.5rem}[data-slot=comment-thread][data-size=sm]>[data-slot=comment-composer]{border-block-start:0;& [data-slot=prompt-input-group]{background:var(--vh-bg-elevated);box-shadow:none;border-color:#0000}}[data-slot=comment-reply][data-size=sm]{padding:.5rem .75rem;position:relative;& [data-slot=comment-reply-header]{align-items:baseline}& [data-slot=comment-reply-header]>[data-slot=avatar-stack]{align-self:center}& [data-slot=comment-reply-author]{font-size:.875rem;line-height:1.5rem}& [data-slot=comment-reply-body]{--vh-typeset-leading:1.5;font-size:.875rem}}@media not (any-pointer:coarse){[data-slot=comment-reply][data-size=sm] [data-slot=comment-reply-actions]{background:var(--vh-bg);border-radius:var(--vh-radius);position:absolute;top:.375rem;right:.5rem}}[data-slot=comment-composer][data-size=sm] [data-slot=prompt-input-textarea]{min-height:2rem;padding:.375rem .625rem 0}[data-slot=comment-composer][data-size=sm][data-layout=row]{& [data-slot=prompt-input-group]{border-radius:calc(1rem + 1px)}& [data-slot=prompt-input-textarea]{min-height:1.75rem;padding:.21875rem .25rem;line-height:1.3125rem}& [data-slot=prompt-input-toolbar]>button{min-width:1.75rem;height:1.75rem}}[data-slot=comment-composer][data-layout=row][data-multiline=true]{& [data-slot=prompt-input-textarea]{flex-basis:100%;order:0;padding-inline:.5rem}& [data-slot=prompt-input-spacer]{display:block}}[data-slot=comment-panel-composer] [data-slot=comment-composer-mentions],[data-slot=comment-thread]>[data-slot=comment-composer] [data-slot=comment-composer-mentions]{margin:0 0 .25rem;top:auto;bottom:100%}[data-slot=comment-panel]>[data-slot=comment-thread]{flex:1;min-height:0}[data-slot=comment-panel]>[data-slot=comment-thread] [data-slot=comment-thread-messages]{flex:1;max-height:none}.vh-typeset{--vh-typeset-flow:.85em;--vh-typeset-leading:1.65;font-size:.9375rem;line-height:var(--vh-typeset-leading);overflow-wrap:anywhere;min-width:0}.vh-image-preview{appearance:none;aspect-ratio:4/3;background:var(--vh-bg-elevated);border:1px solid var(--vh-border);border-radius:var(--vh-radius);color:var(--vh-muted);cursor:zoom-in;vertical-align:top;justify-content:center;align-items:center;width:13rem;max-width:100%;padding:0;display:inline-flex;overflow:hidden}.vh-image-preview img{object-fit:cover;width:100%;height:100%;display:block}.vh-image-preview--compact{aspect-ratio:1;border:0;width:100%;height:100%}.vh-image-unavailable{overflow-wrap:anywhere;padding:.5rem;font-size:.75rem}.vh-image-dialog__toolbar{color:var(--vh-on-media,var(--vh-highlighted));border:0;flex:none;align-items:center;gap:.25rem;padding-bottom:.5rem;display:flex}.vh-image-dialog__name{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:.75rem;overflow:hidden}.vh-image-dialog__image{border-radius:var(--vh-radius);object-fit:contain;max-width:92vw;max-height:calc(92dvh - 3rem);display:block}.vh-image-dialog__error{background:var(--vh-media-scrim,var(--vh-bg-elevated));border-radius:var(--vh-radius);color:var(--vh-on-media,var(--vh-highlighted));max-width:24rem;padding:2rem;font-size:.875rem}[data-slot=invocation] [data-activity-id][data-selected=true]{background:var(--vh-bg-elevated);border-radius:calc(var(--vh-radius) * .85);scroll-margin-block:5rem}[data-slot=visually-hidden]{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}:where(:root,[class^=vh-ws-],[class*=\\ vh-ws-]){--vh-ws-font-mono:var(--font-mono,"Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace);--vh-ws-code-bg:var(--vh-bg);--vh-ws-code-fg:var(--vh-highlighted);--vh-ws-code-cursor:var(--vh-highlighted);--vh-ws-code-selection:color-mix(in oklab, var(--vh-highlighted) 14%, transparent);--vh-ws-code-line:color-mix(in oklab, var(--vh-highlighted) 4%, transparent);--vh-ws-code-gutter:var(--vh-dimmed);--vh-ws-code-gutter-active:var(--vh-text);--vh-ws-code-comment:var(--vh-dimmed);--vh-ws-code-punctuation:var(--vh-muted);--vh-ws-terminal-bg:var(--vh-ws-code-bg);--vh-ws-terminal-fg:var(--vh-text);--vh-ws-ink:var(--ui-text-highlighted,CanvasText);--vh-ws-ink-inverted:var(--ui-bg,Canvas)}:is(.vh-ws-preview-path,.vh-ws-input) input{font-family:var(--vh-ws-font-mono)}@keyframes vh-ws-pulse{50%{opacity:.35}}:is([data-slot=editor-suggestion-label],[data-slot=editor-suggestion-description]){text-overflow:ellipsis;white-space:nowrap;overflow:hidden}}@layer utilities;:where([data-focus-ring]):has(:focus-visible){outline:2px solid var(--vh-focus,var(--vh-primary));outline-offset:2px}[data-slot=comment-composer][data-layout=row]{& [data-slot=prompt-input-textarea]:focus-visible{outline:none}&:not([data-dragging=true]) [data-slot=prompt-input-group]:has([data-slot=prompt-input-textarea]:focus-visible){border-color:color-mix(in oklab, var(--vh-highlighted) 22%, transparent);box-shadow:0 0 0 3px color-mix(in oklab, var(--vh-highlighted) 6%, transparent)}&[data-dragging=true] [data-slot=prompt-input-group]{border-color:var(--vh-primary);box-shadow:0 0 0 3px color-mix(in oklab, var(--vh-primary) 14%, transparent)}&[data-size=sm]:not([data-dragging=true]) [data-slot=prompt-input-group]:has([data-slot=prompt-input-textarea]:focus-visible){box-shadow:none}}[data-slot=comment-thread][data-size=sm]>[data-slot=comment-composer][data-layout=row]:not([data-dragging=true]) [data-slot=prompt-input-group]:has([data-slot=prompt-input-textarea]:focus-visible){background:var(--vh-bg);border-color:var(--vh-border-accented)}[data-slot=comment-composer][data-frame=none]:not([data-dragging=true]) [data-slot=prompt-input-group]:has([data-slot=prompt-input-textarea]:focus-visible){box-shadow:none;border-color:#0000}:where(:root,[data-slot],[class^=vh-],[class*=\\ vh-]){--vh-radius:var(--vh-ui-radius,calc(var(--ui-radius,.25rem) * 2));--vh-border:var(--vh-ui-border,var(--ui-border,color-mix(in oklab, currentColor 14%, transparent)));--vh-border-accented:var(--vh-ui-border-accented,var(--ui-border-accented,color-mix(in oklab, currentColor 24%, transparent)));--vh-muted:var(--vh-ui-muted,var(--ui-text-muted,color-mix(in oklab, currentColor 68%, transparent)));--vh-dimmed:var(--vh-ui-dimmed,var(--ui-text-dimmed,color-mix(in oklab, currentColor 68%, transparent)));--vh-text:var(--vh-ui-text,var(--ui-text,currentColor));--vh-bg:var(--vh-ui-bg,var(--ui-bg,Canvas));--vh-bg-muted:var(--vh-ui-bg-muted,var(--ui-bg-muted,color-mix(in oklab, Canvas 94%, currentColor)));--vh-bg-elevated:var(--vh-ui-bg-elevated,var(--ui-bg-elevated,color-mix(in oklab, Canvas 96%, currentColor)));--vh-bg-accented:var(--vh-ui-bg-accented,var(--ui-bg-accented,color-mix(in oklab, Canvas 90%, currentColor)));--vh-highlighted:var(--vh-ui-highlighted,var(--ui-text-highlighted,currentColor));--vh-inverted:var(--vh-ui-inverted,var(--ui-text-inverted,Canvas));--vh-primary:var(--vh-ui-primary,var(--ui-primary,var(--vh-highlighted)));--vh-ring:var(--vh-ui-ring,color-mix(in oklab, var(--vh-primary) 50%, transparent));--vh-error:var(--vh-ui-error,var(--ui-error,var(--vh-highlighted)));--vh-info:var(--vh-ui-info,var(--ui-info,var(--vh-highlighted)));--vh-success:var(--vh-ui-success,var(--ui-success,var(--vh-highlighted)));--vh-warning:var(--vh-ui-warning,var(--ui-warning,var(--vh-highlighted)))}.vh-typeset>*{margin-block:0}.vh-typeset>*+*{margin-block-start:var(--vh-typeset-flow)}.vh-typeset :where(h1,h2,h3,h4){letter-spacing:-.015em;margin-block-start:1.35em;font-weight:650;line-height:1.3}.vh-typeset :where(h1){font-size:1.35em}.vh-typeset :where(h2){font-size:1.2em}.vh-typeset :where(h3,h4){font-size:1.05em}.vh-typeset :where(ul,ol){padding-inline-start:1.25rem}.vh-typeset ul{list-style-type:disc}.vh-typeset ol{list-style-type:decimal}.vh-typeset li+li{margin-block-start:.25em}.vh-typeset :where(code):not(pre code){background:color-mix(in oklab, currentColor 8%, transparent);border:1px solid color-mix(in oklab, currentColor 10%, transparent);border-radius:calc(var(--vh-radius) * .65);padding:.1em .35em;font-size:.875em}.vh-typeset :where(pre){border:1px solid var(--vh-border);border-radius:var(--vh-radius);max-width:100%;padding:.875rem 1rem;overflow:auto}.vh-typeset :where(blockquote){border-inline-start:2px solid var(--vh-border);color:var(--vh-muted);padding-inline-start:1rem}.vh-typeset :where(a){text-decoration:underline;text-decoration-color:color-mix(in oklab, currentColor 35%, transparent);text-underline-offset:.2em}.vh-typeset-chat>:first-child{margin-block-start:0}.vh-typeset-chat[data-streaming]{contain:layout style}.vh-typeset p:has(>.vh-image-preview:only-child){vertical-align:top;max-width:calc(50% - .5rem);margin:.5rem .5rem 0 0;display:inline-block}.vh-image-overlay{background:rgb(from var(--vh-media-scrim,var(--vh-bg-elevated)) r g b / 80%);z-index:59}.vh-image-dialog{box-shadow:none;z-index:60;background:0 0;border-radius:0;width:max-content;max-width:92vw;max-height:92dvh;overflow:visible}.vh-image-dialog__action{color:var(--vh-on-media,var(--vh-highlighted));flex:none}.vh-image-dialog__action:hover{background:color-mix(in oklab, var(--vh-on-media,var(--vh-highlighted)) 10%, transparent)}@keyframes vh-primitive-icon{50%{opacity:var(--vh-primitive-icon-opacity,1);transform:var(--vh-primitive-icon-motion,none)}}[data-slot=comment-composer] [data-slot=attachment]:has(>[data-slot=attachment-media][data-variant=image]) [data-slot=attachment-actions]>button{background:var(--vh-highlighted);box-shadow:0 1px 3px color-mix(in oklab, var(--vh-highlighted) 10%, transparent), 0 1px 2px -1px color-mix(in oklab, var(--vh-highlighted) 10%, transparent);color:var(--vh-inverted);border:0;border-radius:9999px;place-items:center;width:1.25rem;min-width:0;height:1.25rem;padding:0;display:grid;& :is(svg,.iconify){width:.75rem;height:.75rem}}`;function _u(e){return typeof e==`string`&&e?e:void 0}function vu(e){let t=_u(e?.__name)??_u(e?.name);return t?{name:t}:void 0}function yu(){let e=[];for(let t of document.querySelectorAll(`[data-v-app], #__nuxt, #app`))t._vnode&&e.push(t);return e}function bu(e){let t=new Map,n=(e,r,i)=>{if(!e||typeof e!=`object`||i>4e3)return;let a=e;if(a.component){let e=vu(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 yu())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 xu(){for(let e of yu()){let t=e.__vue_app__?.config?.globalProperties?.$router?.currentRoute?.value?.matched,n=t?.length?_u(t.at(-1)?.path):void 0;if(n)return n}}var Su={button:`button`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,img:`img`,nav:`navigation`,textarea:`textbox`};function Cu(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(Su,t)?Su[t]:void 0}function wu(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`)??Cu(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 Tu(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=xu();if(r&&(n.route=r.slice(0,256)),e){n.element=wu(e);let t=bu(e);t.length&&(n.components=t)}return n}function Eu(e){let t,n,r=0;async function i(i){r++;let a=t;if(!a)return;t=void 0,n?.();let{element:o,field:s,page:c,digest:l,original:u,initial:d}=a;o.contentEditable=`inherit`,o.removeAttribute(`data-vitehub-editing`);let f=(o.textContent??``).trim();if(!i){o.textContent=u;return}if(f===d.trim())return;let[p]=await ie.saveField({field:s,value:f,ifDigest:l},c);if(p)return o.textContent=u,e.failed(p);e.drafted(s),e.info(`Saved as a draft. Publish it in the Console at console.vitehub.dev.`)}async function a(a){let s=i(!0),c=r;if(await s,c!==r||!a.isConnected)return;let l=a.getAttribute(o);if(!l)return;let u=e.page(),[d,f]=await ie.field(l,u);if(c!==r||!a.isConnected)return;if(d)return e.failed(d);if(!f.editable||f.value===null){e.info(`This field is not plain text. Edit it in the Console at console.vitehub.dev.`);return}t={element:a,field:l,page:u,digest:f.digest,original:a.textContent??``,initial:f.value},a.textContent=f.value,a.setAttribute(`data-vitehub-editing`,``),a.contentEditable=`plaintext-only`,a.contentEditable!==`plaintext-only`&&(a.contentEditable=`true`),a.focus();let p=document.createRange();p.selectNodeContents(a),getSelection()?.removeAllRanges(),getSelection()?.addRange(p);let m=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),i(!0)),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(!1))},h=()=>void i(!0);a.addEventListener(`keydown`,m),a.addEventListener(`blur`,h,{once:!0}),n=()=>{a.removeEventListener(`keydown`,m),a.removeEventListener(`blur`,h)}}return{start:a,finish:i,get element(){return t?.element}}}var Du=`modulepreload`,Ou=function(e){return`/`+e},ku={},Au=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ou(t,n),t=s(t),t in ku)return;ku[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Du,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ju={marker:{label:`Marker`,key:`B`,width:14},pen:{label:`Pen`,key:`P`,width:3},arrow:{label:`Arrow`,key:`A`,width:3},text:{label:`Text`,key:`T`,width:20}},Mu={pink:`#ec4899`,amber:`#f59e0b`,blue:`#2563eb`,green:`#16a34a`},Nu=`http://www.w3.org/2000/svg`,Pu=e=>e.tip??`marker`,Fu=e=>ju[Pu(e)].width,Iu=`600 ${ju.text.width}px ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif`,Lu=`0 1px 1.5px rgb(0 0 0 / 30%)`,Ru=`:host{position:absolute;left:0;top:0;width:0;height:0;z-index:2147482999}
12
+ :host([frozen]){z-index:2147482998}
13
+ .layer{position:fixed;inset:0;touch-action:none}
14
+ .layer[data-frozen]{position:absolute;pointer-events:none}
15
+ svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
16
+ path{fill:none;stroke-linecap:round;stroke-linejoin:round}
17
+ path.marker{stroke-width:${ju.marker.width}px;stroke-opacity:.4;stroke-linecap:butt;mix-blend-mode:multiply}
18
+ path.pen{stroke-width:${ju.pen.width}px}
19
+ path.arrow{stroke-width:${ju.arrow.width}px}
20
+ .label{filter:drop-shadow(${Lu})}
21
+ .label text{font:${Iu};white-space:pre}
22
+ input{position:fixed;z-index:1;box-sizing:border-box;margin:0;border:0;outline:0;font:${Iu};caret-color:currentColor;box-shadow:${Lu},0 0 0 2px rgb(255 255 255 / 90%)}`,zu=([e,t])=>`${e.toFixed(1)} ${t.toFixed(1)}`;function Bu(e){let[t,...n]=e;if(!t)return``;if(n.length===0)return`M${zu(t)}l0.1 0`;let r=`M${zu(t)}`;for(let t=1;t<e.length-1;t++){let n=e[t],i=e[t+1];r+=`Q${zu(n)} ${zu([(n[0]+i[0])/2,(n[1]+i[1])/2])}`}return`${r}L${zu(e[e.length-1])}`}function Vu(e,t,n=!1){let r=t[0]-e[0],i=t[1]-e[1],a=Math.hypot(r,i)||1,o=n?0:Math.min(18,a*.08),s=[(e[0]+t[0])/2-i/a*o,(e[1]+t[1])/2+r/a*o],c=Math.atan2(t[1]-s[1],t[0]-s[0]),l=Math.min(14,a*.4)+ju.arrow.width,u=e=>[t[0]-l*Math.cos(c+e),t[1]-l*Math.sin(c+e)];return{control:s,left:u(-.5),right:u(.5)}}function Hu(e){if(Pu(e)!==`arrow`)return Bu(e.points);let t=e.points[0],n=e.points[e.points.length-1];if(!t||!n)return``;let{control:r,left:i,right:a}=Vu(t,n,e.straight);return`M${zu(t)}Q${zu(r)} ${zu(n)}M${zu(i)}L${zu(n)}L${zu(a)}`}var Uu;function Wu(e){return Uu??=document.createElement(`canvas`).getContext(`2d`),Uu?(Uu.font=Iu,Uu.measureText(e).width):e.length*ju.text.width*.55}function Gu(e){let t=ju.text.width,n=Math.round(t*.45),r=Math.round(t*1.5),[i,a]=e.points[0]??[0,0];return{left:i,top:a-r/2,width:Math.ceil(Wu(e.text??``))+n*2,height:r,padding:n,radius:Math.round(t*.35)}}function Ku(e){let[t,n,r]=[1,3,5].map(t=>{let n=Number.parseInt(e.slice(t,t+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.4?`#0a0a0a`:`#ffffff`}function qu(e){let t=e.flatMap(e=>{if(Pu(e)===`text`){let t=Gu(e);return[{left:t.left,top:t.top,width:t.width,height:t.height+2}]}let t=Fu(e)/2,n=e.points,r=e.points[0],i=e.points[e.points.length-1];if(Pu(e)===`arrow`&&r&&i){let{control:t,left:a,right:o}=Vu(r,i,e.straight);n=[r,t,i,a,o]}return n.map(([e,n])=>({left:e-t,top:n-t,width:t*2,height:t*2}))});if(t.length===0)return;let n=Math.min(...t.map(e=>e.left)),r=Math.min(...t.map(e=>e.top)),i=Math.max(...t.map(e=>e.left+e.width)),a=Math.max(...t.map(e=>e.top+e.height));return{left:n,top:r,width:i-n,height:a-r}}function Ju(e,t){if(e===`arrow`)return`crosshair`;if(e===`text`)return`text`;let n=ju[e].width,r=Math.max(8,n+4),i=`<svg xmlns="${Nu}" width="${r}" height="${r}"><circle cx="${r/2}" cy="${r/2}" r="${Math.max(2,n/2)}" fill="${t}" fill-opacity="${e===`marker`?.4:.9}" stroke="#0a0a0a" stroke-opacity=".55"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(i)}") ${r/2} ${r/2}, crosshair`}function Yu(e,t){let n=Gu(t),r=document.createElementNS(Nu,`rect`),i=document.createElementNS(Nu,`text`);for(let[e,t]of Object.entries({x:n.left,y:n.top,width:n.width,height:n.height,rx:n.radius}))r.setAttribute(e,String(t));r.setAttribute(`fill`,t.color),i.setAttribute(`x`,String(n.left+n.padding)),i.setAttribute(`y`,String(t.points[0][1])),i.setAttribute(`dominant-baseline`,`central`),i.setAttribute(`fill`,Ku(t.color)),i.textContent=t.text??``,e.replaceChildren(r,i)}function Xu(e,t){if(Pu(e)===`text`){let n=document.createElementNS(Nu,`g`);return n.setAttribute(`class`,`label`),Yu(n,e),t.append(n),n}let n=document.createElementNS(Nu,`path`);return n.setAttribute(`class`,Pu(e)),n.setAttribute(`stroke`,e.color),n.setAttribute(`d`,Hu(e)),t.append(n),n}function Zu(e,t){for(let n of t){if(e.save(),Pu(n)===`text`){let t=Gu(n),r=e.getTransform().a;e.shadowColor=`rgb(0 0 0 / 30%)`,e.shadowBlur=1.5*r,e.shadowOffsetY=r,e.fillStyle=n.color,e.beginPath(),e.roundRect(t.left,t.top,t.width,t.height,t.radius),e.fill(),e.shadowColor=`transparent`,e.font=Iu,e.textBaseline=`middle`,e.fillStyle=Ku(n.color),e.fillText(n.text??``,t.left+t.padding,n.points[0][1])}else{let t=Pu(n)===`marker`;e.globalAlpha=t?.4:1,e.globalCompositeOperation=t?`multiply`:`source-over`,e.strokeStyle=n.color,e.lineWidth=Fu(n),e.lineCap=t?`butt`:`round`,e.lineJoin=`round`,e.stroke(new Path2D(Hu(n)))}e.restore()}}function Qu(e){let t=document.createElement(`vitehub-marker`);t.setAttribute(`data-comments-ui`,``);let n=t.attachShadow({mode:`open`}),r=document.createElement(`style`);r.textContent=Ru;let i=document.createElement(`div`);i.className=`layer`;let a=document.createElementNS(Nu,`svg`);i.append(a),n.append(r,i),document.documentElement.append(t);let o=[],s,c,l,u=()=>{if(!l)return;let{input:e,stroke:t}=l,n=Gu({...t,text:e.value||` `}),r=(t,n)=>e.style.setProperty(t,n);r(`left`,`${n.left}px`),r(`top`,`${n.top}px`),r(`width`,`${n.width+2}px`),r(`height`,`${n.height}px`),r(`padding`,`0 ${n.padding}px`),r(`border-radius`,`${n.radius}px`),r(`background`,t.color),r(`color`,Ku(t.color))},d=()=>{if(!l)return;let{input:t,stroke:n,label:r}=l;l=void 0;let i=t.value.trim();if(t.remove(),r)i?(r.text=i,r.color=n.color,Yu(r.element,r),r.element.removeAttribute(`visibility`)):o.splice(o.indexOf(r),1)[0]?.element.remove();else{if(!i)return;o.push({...n,text:i,element:Xu({...n,text:i},a)})}e.onChange()},f=(e,t)=>{let n=document.createElement(`input`);n.type=`text`,n.maxLength=200,n.spellcheck=!1,n.value=e.text??``,n.setAttribute(`aria-label`,`Label`),n.setAttribute(`enterkeyhint`,`done`),l={input:n,stroke:{...e},label:t},u(),t?.element.setAttribute(`visibility`,`hidden`),n.addEventListener(`input`,u),n.addEventListener(`blur`,d),i.append(n),n.focus({preventScroll:!0}),t&&n.select()},p=t=>{l&&t.composedPath()[0]===l.input&&(t.stopPropagation(),!t.isComposing&&((t.key===`PageUp`||t.key===`PageDown`)&&t.preventDefault(),(t.key===`Enter`||t.key===`Escape`)&&(t.preventDefault(),d(),t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&e.onSubmit?.())))};addEventListener(`keydown`,p,!0);let m=(e,t)=>o.findLast(n=>{if(Pu(n)!==`text`)return!1;let r=Gu(n);return e>=r.left-4&&e<=r.left+r.width+4&&t>=r.top-4&&t<=r.top+r.height+4}),h=()=>{i.style.cursor=Ju(e.tip(),e.color()),l&&l.stroke.color!==e.color()&&(l.stroke.color=e.color(),u())};h(),i.addEventListener(`pointerdown`,t=>{if(l&&t.composedPath().includes(l.input)||t.button!==0||i.hasAttribute(`data-frozen`))return;if(t.preventDefault(),l)return d();i.setPointerCapture(t.pointerId);let n=e.tip(),r=e.color();if(n===`text`){let e=m(t.clientX,t.clientY);c={label:e,from:[t.clientX,t.clientY],at:e?.points[0],moved:!1,color:r};return}let o={tip:n,color:r,points:[[t.clientX,t.clientY]]};s={...o,element:Xu(o,a)}}),i.addEventListener(`pointermove`,e=>{if(c){let{label:t,from:n,at:r}=c;if(!t||!r)return;let i=e.clientX-n[0],a=e.clientY-n[1];if(!c.moved&&Math.hypot(i,a)<3)return;c.moved=!0,t.points=[[r[0]+i,r[1]+a]],Yu(t.element,t);return}if(!s)return;let t=[e.clientX,e.clientY],n=s.points[0];if(s.tip===`arrow`||e.shiftKey)e.shiftKey?s.straight=!0:delete s.straight,s.points=[n,s.tip===`marker`&&e.shiftKey?[t[0],n[1]]:t];else{let e=s.points[s.points.length-1];Math.hypot(t[0]-e[0],t[1]-e[1])>2&&s.points.push(t)}s.element.setAttribute(`d`,Hu(s))});let g=t=>{if(c){let{label:n,from:r,moved:i,color:a}=c;if(c=void 0,t.type===`pointercancel`)return;if(n){i?e.onChange():f(n,n);return}return f({tip:`text`,color:a,points:[[r[0]-Math.round(ju.text.width*.45),r[1]]],text:``})}if(!s)return;let n=s;s=void 0;let r=n.points[0],i=n.points[n.points.length-1];if(n.tip===`arrow`&&Math.hypot(i[0]-r[0],i[1]-r[1])<10)return n.element.remove();o.push(n),e.onChange()};i.addEventListener(`pointerup`,g),i.addEventListener(`pointercancel`,g);for(let e of[`wheel`,`touchmove`])i.addEventListener(e,e=>e.preventDefault(),{passive:!1});return{strokes:()=>o.map(e=>{let t={tip:e.tip,color:e.color,points:e.points.map(([e,t])=>[e,t])};return e.straight&&(t.straight=!0),e.text!==void 0&&(t.text=e.text),t}),restyle:h,commit:d,undo(){d(),o.pop()?.element.remove(),e.onChange()},freeze(){d(),t.setAttribute(`frozen`,``),i.setAttribute(`data-frozen`,``),Object.assign(i.style,{left:`${scrollX}px`,top:`${scrollY}px`,width:`${innerWidth}px`,height:`${innerHeight}px`,cursor:``})},remove(){removeEventListener(`keydown`,p,!0),l&&=(l.input.removeEventListener(`blur`,d),void 0),t.remove()}}}function $u(){for(let e of[document.documentElement,document.body]){let t=e?getComputedStyle(e).backgroundColor:``;if(t&&t!==`transparent`&&!/^rgba\(.*,\s*0\)$/.test(t))return t}return`#ffffff`}function ed(e){return e.position!==`static`||e.transform!==`none`||e.filter!==`none`||e.perspective!==`none`||/paint|layout|strict|content/.test(e.contain)||/transform|perspective|filter/.test(e.willChange)}function td(e){for(let t=e.parentElement;t&&t!==document.documentElement;t=t.parentElement){if(ed(getComputedStyle(t)))return t;let e=t.parentElement;if(e&&(e.scrollTop||e.scrollLeft))return t}}function nd(e){let t=`data-vitehub-pin`,n=[],r=document.createTreeWalker(document.documentElement,NodeFilter.SHOW_ELEMENT);for(let t=r.nextNode();t;t=r.nextNode()){if(!(t instanceof HTMLElement)||e(t))continue;let r=getComputedStyle(t);if(r.position!==`fixed`&&r.position!==`sticky`||r.visibility===`hidden`)continue;let i=t.getBoundingClientRect();i.bottom<=0||i.right<=0||i.top>=innerHeight||i.left>=innerWidth||n.push({element:t,sticky:r.position===`sticky`,rect:i})}for(let e of n.filter(e=>e.sticky)){let t=e.element.getAttribute(`style`);e.element.style.setProperty(`position`,`static`,`important`),e.from=e.element.getBoundingClientRect(),e.element.style.removeProperty(`position`),e.element.getAttribute(`style`)!==t&&(t===null?e.element.removeAttribute(`style`):e.element.setAttribute(`style`,t))}return n.forEach((e,n)=>{if(!e.sticky){let t=td(e.element),n=t?.getBoundingClientRect(),r=e.element.parentElement;e.left=e.rect.left-(t&&n?n.left+t.clientLeft:0)+(r?.scrollLeft??0),e.top=e.rect.top-(t&&n?n.top+t.clientTop:0)+(r?.scrollTop??0)}e.element.setAttribute(t,String(n))}),{apply(e){if(!(e instanceof HTMLElement)||!e.hasAttribute(t))return;let r=n[Number(e.getAttribute(t))];if(e.removeAttribute(t),!r)return;let i=(t,n)=>e.style.setProperty(t,n,`important`);for(let t of[`inset`,`right`,`bottom`,`margin-block-start`,`margin-block-end`,`margin-inline-start`,`margin-inline-end`])e.style.removeProperty(t);if(r.sticky&&r.from){i(`position`,`relative`),i(`left`,`${r.rect.left-r.from.left}px`),i(`top`,`${r.rect.top-r.from.top}px`);return}i(`position`,`absolute`),i(`left`,`${r.left}px`),i(`top`,`${r.top}px`),i(`width`,`${r.rect.width}px`),i(`height`,`${r.rect.height}px`),i(`margin`,`0`),i(`box-sizing`,`border-box`);for(let e of[`transform`,`translate`,`rotate`,`scale`])i(e,`none`)},release(){for(let e of n)e.element.removeAttribute(t)}}}function rd(e){let t=new Map,n=``;for(let r of e.querySelectorAll(`[style]`)){if(r.namespaceURI!==`http://www.w3.org/1999/xhtml`||r.closest(`defs, symbol`))continue;let e=r.getAttribute(`style`),i=t.get(e);if(!t.has(e)){let a=``;for(let e=0;e<r.style.length;e++){let t=r.style.item(e),n=r.style.getPropertyValue(t);if(!n){a=void 0;break}a+=`${t}:${n}!important;`}i=a===void 0?void 0:`_s${t.size.toString(36)}`,t.set(e,i),i&&(n+=`.${i}{${a}}\n`)}i&&(r.removeAttribute(`style`),r.classList.add(i))}let r=e.firstElementChild;(r?.localName===`style`?r:e.insertBefore(document.createElement(`style`),r)).append(n)}async function id(e,t){let n=nd(t);try{let{domToCanvas:r}=await Au(async()=>{let{domToCanvas:e}=await import(`./dist-BoHMOFax.js`);return{domToCanvas:e}},[]),i=Math.min(devicePixelRatio||1,2),a=await r(document.documentElement,{width:innerWidth,height:innerHeight,scale:i,backgroundColor:$u(),filter:e=>!t(e),features:{restoreScrollPosition:!0},onCloneEachNode:e=>n.apply(e),onCreateForeignObjectSvg:rd,timeout:3e3}),o=a.getContext(`2d`);return o?(o.setTransform(i,0,0,i,0,0),Zu(o,e),await new Promise(e=>a.toBlob(t=>e(t??void 0),`image/webp`,.85))):void 0}catch{return}finally{n.release()}}var ad=`
23
+ :host {
24
+ all: initial;
25
+ --ui-bg: #fff; --ui-bg-elevated: #f5f5f5; --ui-bg-accented: #e5e5e5; --ui-bg-muted: #fafafa; --ui-border: #e5e5e5;
26
+ --ui-text: #404040; --ui-text-muted: #737373; --ui-text-highlighted: #171717; --ui-text-inverted: #fff; --ui-primary: #171717;
64
27
  }
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);
28
+ :host(.dark) {
29
+ --ui-bg: #171717; --ui-bg-elevated: #262626; --ui-bg-accented: #404040; --ui-bg-muted: #1f1f1f; --ui-border: rgb(255 255 255 / 12%);
30
+ --ui-text: #e5e5e5; --ui-text-muted: #a3a3a3; --ui-text-highlighted: #fafafa; --ui-text-inverted: #171717; --ui-primary: #fafafa;
70
31
  }
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; }
32
+ .root { position: fixed; inset: 0; pointer-events: none; z-index: 2147482999; font-family: "Geist Variable", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
33
+ .root > * { pointer-events: auto; }
34
+ /* The comment layer covers the page. Only its parts and the comment mode overlay take the pointer, as @vite-hub/ui styles them. */
35
+ .root > .cursors, .root > .outlines, .root > .areas, .root > [data-slot="comment-layer"] { pointer-events: none; }
90
36
  .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; }
37
+ .avatar img { width: 100%; height: 100%; object-fit: cover; }
160
38
 
161
39
  .cursor { position: fixed; transform: translate(-2px, -2px); transition: left 80ms linear, top 80ms linear; }
162
40
  .cursor svg { display: block; filter: drop-shadow(0 1px 1px rgb(0 0 0 / .25)); }
163
41
  .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
42
 
165
- .outline { position: fixed; border: 2px solid var(--accent); border-radius: 4px; }
43
+ .outline { position: fixed; border: 2px solid var(--vh-comment-mark); border-radius: 4px; }
166
44
  .outline[data-kind="draft"] { border-style: dashed; border-color: #f59e0b; }
167
45
  .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); }
46
+ .outline[data-kind="hover"] + .tag { background: var(--vh-comment-mark); color: #fff; }
47
+
48
+ .card { position: fixed; left: 50%; bottom: 68px; translate: -50% 0; z-index: 2147483001; width: min(320px, calc(100vw - 32px)); display: grid; gap: 8px; padding: 12px; background: var(--vh-bg); color: var(--vh-text); border: 1px solid var(--vh-border); border-radius: calc(var(--vh-radius) * 1.5); box-shadow: 0 8px 24px rgb(0 0 0 / .16); font-size: 13px; }
49
+ .card label { display: grid; gap: 4px; font-weight: 500; }
50
+ .card input { font: inherit; color: inherit; background: var(--vh-bg-elevated); border: 1px solid var(--vh-border); border-radius: var(--vh-radius); padding: 6px 8px; }
51
+ .card input:focus-visible { outline: 2px solid var(--vh-ring); outline-offset: 0; }
52
+ @media (pointer: coarse) { .card input { font-size: 16px; } }
53
+ .card .row { display: flex; justify-content: flex-end; gap: 6px; }
169
54
 
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; }
55
+ .toast { position: fixed; left: 50%; bottom: 68px; translate: -50% 0; z-index: 2147483001; max-width: min(520px, calc(100vw - 32px)); padding: 8px 8px 8px 14px; background: var(--vh-bg); color: var(--vh-text); border: 1px solid var(--vh-border); border-radius: 12px; box-shadow: 0 8px 24px -6px rgb(0 0 0 / .16); display: flex; gap: 12px; align-items: center; font-size: 13px; text-wrap: pretty; }
56
+ .toast[data-kind="error"] { border-color: color-mix(in oklab, var(--vh-error) 45%, transparent); }
57
+ .toast a { color: var(--vh-primary); font-weight: 500; white-space: nowrap; text-underline-offset: 3px; }
173
58
  .toast > span { padding: 4px 0; }
174
59
 
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); }
60
+ /*
61
+ * Where the pins go. Their look is Drop's, in @vite-hub/ui/comment-marks.css. A pin sits in the gutter right of a
62
+ * quote's block, level with its last line; at the corner of an area; at the point of a click. --pin-x and --pin-y place
63
+ * the pin's corner from the spot, and the card opens beside the pin, level with it, or under it near the right edge of
64
+ * the screen.
65
+ */
66
+ [data-slot="comment-layer-item"] { --pin-x: 0px; --pin-y: calc(var(--vh-comment-pin-size) * -1); }
67
+ [data-slot="comment-layer-item"][data-kind="text"] { --pin-x: 0px; --pin-y: calc(var(--vh-comment-pin-size) / -2); }
68
+ [data-slot="comment-layer-item"]:is([data-kind="area"], [data-kind="image"]) { --pin-x: calc(var(--vh-comment-pin-size) / -2); --pin-y: calc(var(--vh-comment-pin-size) / -2); }
69
+ [data-slot="comment-pin"] { touch-action: manipulation; transform: translate(var(--pin-x), var(--pin-y)); }
70
+ [data-kind="text"] > [data-slot="comment-pin"] { transform-origin: 0 50%; }
71
+ [data-slot="comment-pin"] [data-slot="avatar-stack"] { --vh-avatar-size: var(--vh-comment-pin-size); display: block; }
72
+ [data-slot="comment-pin"] [data-slot="avatar-stack-item"] {
73
+ border-radius: inherit; box-shadow: none; background: none; color: inherit; font: 600 11px/var(--vh-comment-pin-size) "Geist Variable", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .02em;
74
+ }
75
+ /* A new comment is one small surface, as in Drop: the line grows with the text, with the attach and send buttons beside it. */
76
+ [data-draft="true"] [data-slot="comment-composer"] { padding: 4px; }
77
+ [data-draft="true"] [data-slot="prompt-input-group"] { flex-flow: row wrap; align-items: flex-end; border: 0; box-shadow: none; background: none; }
78
+ [data-draft="true"] [data-slot="prompt-input-attachments"] { flex-basis: 100%; }
79
+ [data-draft="true"] [data-slot="prompt-input-textarea"] { flex: 1; min-width: 0; min-height: 2.25rem; padding: .5rem .25rem .375rem .625rem; }
80
+ [data-draft="true"] [data-slot="prompt-input-toolbar"] { padding: .25rem; }
81
+ [data-slot="comment-pin-number"] { display: none; }
82
+ [data-slot="comment-pin"][data-draft="true"] { outline: none; }
83
+
84
+ /*
85
+ * --popover-width is the width the card wants. On a narrow screen it is the screen less 12px each side, and the card
86
+ * moves toward the middle so that no part of it goes off screen. --vh-comment-x is the x of the spot on the screen.
87
+ */
88
+ [data-slot="comment-layer-popover"] {
89
+ --popover-width: 340px; --popover-room: min(var(--popover-width), calc(100vw - 24px));
90
+ left: min(calc(var(--pin-x) + 36px), calc(100vw - 12px - var(--popover-room) - var(--vh-comment-x, 0px)));
91
+ top: var(--pin-y); width: var(--popover-room); max-width: none;
92
+ border-radius: 6px 16px 16px 16px; box-shadow: 0 8px 24px rgb(0 0 0 / .16), 0 1px 3px rgb(0 0 0 / .08);
93
+ transform-origin: 0 14px; animation: vitehub-comments-pop 160ms cubic-bezier(.23, 1, .32, 1);
94
+ }
95
+ [data-draft="true"] > [data-slot="comment-layer-popover"] { --popover-width: 300px; border-radius: 6px 18px 18px 18px; }
96
+ [data-slot="comment-layer-popover"][data-preview="true"] { --popover-width: 18rem; animation: none; }
97
+ [data-slot="comment-layer-item"][data-flip-x="true"] > [data-slot="comment-layer-popover"] {
98
+ left: auto; right: clamp(calc(var(--vh-comment-x, 0px) + 12px - 100vw), calc(-28px - var(--pin-x)), calc(var(--vh-comment-x, 100vw) - var(--popover-room) - 12px)); top: calc(var(--pin-y) + 36px); border-radius: 16px 6px 16px 16px; transform-origin: 100% 0;
99
+ }
100
+ [data-slot="comment-layer-item"][data-flip-y="true"] > [data-slot="comment-layer-popover"] {
101
+ top: auto; bottom: calc(-28px - var(--pin-y)); border-radius: 16px 16px 16px 6px; transform-origin: 0 100%;
102
+ }
103
+ [data-slot="comment-layer-item"][data-flip-x="true"][data-flip-y="true"] > [data-slot="comment-layer-popover"] {
104
+ bottom: calc(8px - var(--pin-y)); border-radius: 16px 16px 6px 16px; transform-origin: 100% 100%;
105
+ }
106
+ [data-slot="comment-layer-item"][data-above="true"] > [data-slot="comment-layer-popover"] {
107
+ top: auto; bottom: calc(var(--pin-y) * -1 + 4px); border-radius: 16px 16px 16px 6px; transform-origin: 0 100%;
108
+ }
109
+ [data-slot="comment-layer-popover"][data-floating="true"] { border-radius: 16px; }
110
+ /* The overlay places a card beside its pin itself, so it turns off the CSS anchor placement of @vite-hub/ui/styles.css. */
111
+ [data-slot="comment-layer-item"]:not([data-draft]) > [data-slot="comment-layer-popover"]:not([data-margin], [data-floating]) {
112
+ position: absolute; margin: 0; position-area: none; position-try-fallbacks: none;
113
+ }
114
+
115
+ /*
116
+ * On a touch screen the small buttons of a card, such as Resolve and Close, take a 44px hit area. The box's own toolbar
117
+ * already has one, and an attachment's trigger covers its attachment.
118
+ */
119
+ [data-slot="comment-layer-popover"] button { touch-action: manipulation; }
120
+ @media (pointer: coarse) {
121
+ [data-slot="comment-layer-popover"] button:not([data-slot="attachment-trigger"], [data-slot="prompt-input-toolbar"] button) { position: relative; }
122
+ [data-slot="comment-layer-popover"] button:not([data-slot="attachment-trigger"], [data-slot="prompt-input-toolbar"] button)::after {
123
+ content: ""; position: absolute; inset: min(0px, calc((100% - 44px) / 2));
124
+ }
125
+ }
126
+
127
+ /* The area that a drag in comment mode draws, as comment-marks.css draws it. The overlay is fixed to the screen. The
128
+ areas of threads are in their own root, under the page's floating controls (see areaStyles). */
129
+ [data-slot="comment-layer-area"] { position: fixed; }
130
+
131
+ /* The bar over selected text: the pill's dark glass on a light page, its light twin on a dark one. */
132
+ .selection-bar {
133
+ position: fixed; z-index: 2147483001; translate: -50% -100%; display: flex; gap: 4px; padding: 4px;
134
+ border: 1px solid rgb(255 255 255 / 12%); border-radius: 12px; background: rgb(17 17 17 / 92%);
135
+ box-shadow: 0 8px 24px rgb(0 0 0 / 25%); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
136
+ font: 500 12px/1 "Geist Variable", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
137
+ --bar-text: #d4d4d4; --bar-strong: #fafafa; --bar-hover: rgb(255 255 255 / 8%);
138
+ transform-origin: 50% 100%; animation: vitehub-comments-pop 140ms cubic-bezier(.23, 1, .32, 1);
139
+ }
140
+ .selection-bar[data-below="true"] { translate: -50% 0; transform-origin: 50% 0; }
141
+ :host(.dark) .selection-bar {
142
+ border-color: rgb(0 0 0 / 10%); background: rgb(250 250 250 / 94%); box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
143
+ --bar-text: #404040; --bar-strong: #0a0a0a; --bar-hover: rgb(0 0 0 / 6%);
144
+ }
145
+ .selection-bar button {
146
+ all: unset; position: relative; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
147
+ border-radius: 8px; color: var(--bar-text); cursor: pointer; touch-action: manipulation; white-space: nowrap;
148
+ transition: background-color 150ms, color 150ms, scale 150ms; transition-timing-function: cubic-bezier(.23, 1, .32, 1);
149
+ }
150
+ .selection-bar button::before { content: ""; position: absolute; inset: -9px -2px; }
151
+ @media (hover: hover) and (pointer: fine) { .selection-bar button:hover { background: var(--bar-hover); color: var(--bar-strong); } }
152
+ .selection-bar button:active { scale: .96; }
153
+ .selection-bar button:focus-visible { outline: 2px solid var(--bar-strong); outline-offset: 1px; }
154
+
155
+ @keyframes vitehub-comments-pop { from { opacity: 0; scale: .96; } }
156
+ @keyframes vitehub-comments-enter { from { opacity: 0; transform: translateY(4px); } }
157
+ .toast, .card { animation: vitehub-comments-enter 180ms cubic-bezier(.23, 1, .32, 1); }
180
158
  @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; }
159
+ .toast, .card, .selection-bar, [data-slot="comment-layer-popover"] { animation: none; }
160
+ .selection-bar button { transition-property: background-color, color; }
161
+ .selection-bar button:active { scale: none; }
184
162
  .cursor { transition: none; }
185
163
  }
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; }
164
+ `,od=`
165
+ :host {
166
+ all: initial; display: block; height: 100%; color-scheme: dark;
167
+ --ui-bg: #0a0a0a; --ui-bg-elevated: #171717; --ui-bg-accented: #262626; --ui-bg-muted: #171717; --ui-border: rgb(255 255 255 / 12%);
168
+ --ui-text: #e5e5e5; --ui-text-muted: #a3a3a3; --ui-text-highlighted: #fafafa; --ui-text-inverted: #0a0a0a; --ui-primary: #fafafa;
169
+ }
170
+ .panel-root { height: 100%; }
171
+ [data-slot="comment-panel"] { height: 100%; background: var(--vh-bg); }
172
+ `,sd=`
173
+ :host { font: inherit; color: inherit; color-scheme: inherit; }
174
+ /* The overlay's mount point sits between the segment and the toolbar. It passes the pill's alignment on, so items such as the avatars center like the buttons. */
175
+ :host > div { align-items: inherit; }
176
+ .toolbar { display: flex; flex-direction: var(--vitehub-pill-flow, row); align-items: inherit; gap: 2px; font-variant-numeric: tabular-nums; }
177
+ .toolbar svg { flex: none; }
178
+ .sep { width: 4px; height: 4px; flex: none; }
179
+ .actions { display: flex; flex-direction: inherit; align-items: inherit; gap: 2px; }
180
+ .divider { width: 1px; height: 16px; margin: 0 4px; flex: none; background: var(--vitehub-pill-line); }
181
+ .count { min-width: 16px; padding: 0 4px; border-radius: 4px; background: var(--vitehub-pill-hover); font-size: 10px; line-height: 17px; text-align: center; }
182
+ button[aria-pressed="true"] .count, button[aria-expanded="true"] .count { display: none; }
183
+ /* The tips and the colors stay rows of square buttons, also when the pill docks to a side and stacks the other controls. */
184
+ .swatches { display: flex; gap: 2px; }
185
+ .swatch, .icon, .eye { width: 28px; padding: 0; justify-content: center; }
186
+ .icon { align-self: flex-start; }
187
+ .swatch span { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 20%); }
188
+ .swatch[aria-pressed="true"] { background: var(--vitehub-pill-hover); box-shadow: inset 0 0 0 1.5px var(--vitehub-pill-strong); color: inherit; }
189
+ button.done:not(:disabled) { background: var(--vitehub-pill-on); color: var(--vitehub-pill-on-text); }
190
+ button:disabled { opacity: .45; cursor: default; }
191
+ .people { display: flex; padding: 0 2px; }
192
+ .avatar { width: 20px; height: 20px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; color: #18181b; overflow: hidden; }
193
+ .avatar img { width: 100%; height: 100%; object-fit: cover; }
194
+ .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--vitehub-pill-surface); }
195
+ img.me { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
196
+ `,cd=`
188
197
  html.vitehub-edit-mode [data-content-field] { cursor: text !important; }
189
198
  [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};
199
+ `,ld=`
200
+ :host { all: initial; position: fixed; inset: 0; z-index: 1; pointer-events: none; }
201
+ `,ud={open:`vh-comment`,resolved:`vh-comment-resolved`,active:`vh-comment-active`,draft:`vh-comment-draft`},dd=e=>`${e}\n${gu.replaceAll(`:root.dark`,`:host(.dark)`).replaceAll(`:root`,`:host`)}\n${hu}`;function fd(e){let t=document.createElement(`style`);return t.textContent=e,t}function pd(e,t){let n=new Map;for(let r of e){if(r.id===t)continue;let e=n.get(r.id);e?e.tabs++:n.set(r.id,{person:r,tabs:1})}return[...n.values()]}function md(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join(``)||`?`}function hd(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 gd(){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 _d(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))}var vd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`})),yd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`m9 11-6 6v3h9l3-3M22 12l-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`})),bd={marker:yd,pen:()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z`})),arrow:()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M7 17 17 7M7 7h10v10`})),text:()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M4 7V4h16v3M9 20h6M12 4v16`}))};function xd(e){if(!(e.metaKey||e.ctrlKey||e.altKey))return Object.keys(ju).find(t=>ju[t].key===e.key.toUpperCase())}var Sd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11`})),Cd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7ZM14 2v4a2 2 0 0 0 2 2h4`})),wd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.98-3.98L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5zM15 5l4 4`})),Td=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M18 6 6 18M6 6l12 12`})),Ed=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[$(`path`,{d:`M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0`}),$(`circle`,{cx:12,cy:12,r:3})]),Dd=()=>$(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},$(`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c4.97 0 8.9 3.06 9.94 6.65a1 1 0 0 1 0 .7 10.8 10.8 0 0 1-1.44 2.49M14.08 14.16a3 3 0 0 1-4.24-4.24M17.48 17.5a10.75 10.75 0 0 1-15.42-5.15 1 1 0 0 1 0-.7 10.75 10.75 0 0 1 4.45-5.14M2 2l20 20`})),Od=`vitehub-comments-visibility`;function kd(){try{return localStorage.getItem(Od)===`hidden`?`hidden`:`all`}catch{return`all`}}function Ad(e){try{e===`hidden`?localStorage.setItem(Od,e):localStorage.removeItem(Od)}catch{}}var jd=()=>$(`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`},$(`path`,{d:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`}));function Md(e,t=1){let n=document.elementsFromPoint(e.left+e.width/2,e.top+e.height/2).find(e=>!Pd(e)&&e!==document.documentElement);for(let r=n??null;r&&r!==document.documentElement;r=r.parentElement){let n=r.getBoundingClientRect();if(n.left<=e.left+t&&n.top<=e.top+t&&n.right>=e.left+e.width-t&&n.bottom>=e.top+e.height-t)return r}}function Nd(e,t){let n=t.getBoundingClientRect(),r=Math.max(e.left,n.left),i=Math.max(e.top,n.top);return{left:r,top:i,width:Math.min(e.left+e.width,n.right)-r,height:Math.min(e.top+e.height,n.bottom)-i}}function Pd(e){for(let t=e;t;){if(t.closest(`[data-comments-ui], vitehub-pill, vitehub-window`))return!0;let e=t.getRootNode();t=e instanceof ShadowRoot?e.host:null}return!1}function Fd(e){let{host:t,context:n,session:r}=e,i=t.shadowRoot,a=document.createElement(`div`);a.className=`root`,i.replaceChildren(fd(dd(ad)),a);let s=Y(x(location.pathname)),c=bn(r?.subject??{kind:`page`,id:s.value}),l=r?.revision,d=Y(!1),f=Y(!1),p=0,g=Y(location.search),_=bn(),C=Y(!1),w=bn(),T=Y(!1),E,D=Y(!1),O=Y(0),k=Y(`marker`),A=Y(`pink`),j=Y(!1),ee,M=bn(),te=Y(new Set),N=Y(!1),P=Y(`comment`),F,I=Y(ne()),L=Y(0),se=bn([]),ce=Y(`open`),le=Y(null),ue=bn(),de=Y(0),fe=Y(kd()===`hidden`),pe,me=0,R,z,he=new Set,ge=new WeakMap,_e=(e,t=!1)=>{clearTimeout(z),_.value=e,t||(z=setTimeout(()=>_.value=void 0,e.kind===`error`?8e3:5e3))},B=e=>_e({text:e.fix?`${e.why} ${e.fix}`:e.why,kind:`error`}),V=()=>r?.user??void 0,ve=r?.presence!==!1,H=Q(()=>V()??(I.value?{id:`guest:${I.value.id}`,name:I.value.name,guest:!0}:void 0)),ye=bn(r?.can),U=Q(()=>!!ye.value?.comment),be=Q(()=>U.value&&!H.value),xe=Q({get:()=>fe.value&&U.value?`hidden`:`all`,set:e=>{fe.value=e===`hidden`,Ad(e)}}),Se=(e,{thread:t,message:n})=>{let r=H.value;if(!r||be.value)return!1;let i=t.can??{comment:U.value,resolve:!!ye.value?.resolve,delete:!!ye.value?.delete};if(e===`reply`)return t.status===`open`&&i.comment;if(e===`resolve`)return i.resolve;let a=e=>!r.guest&&!e.author.guest&&e.author.id===r.id;return n?e===`edit`?a(n):(t.messages[0]?.id===n.id?t.messages.every(a):a(n))?i.comment:i.delete===!0&&!r.guest:!1},Ce=ae({contextOf:e=>ge.get(e.anchor)??Tu(void 0),revisionOf:()=>l,onPeople(e){let t=new Map(se.value.map(e=>[e.id,e]));for(let n of e)t.set(n.id,n);se.value=[...t.values()]},onChange:()=>pe?.setLocal(`commentsChange`,crypto.randomUUID())}),we=Ss({transport:{...Ce,subscribe(e){return he.add(e),()=>he.delete(e)}},...V()?{user:V()}:{}}),Te=()=>{for(let e of he)e({type:`reconnected`})},Ee=async e=>await Promise.all(e.map(async e=>(await Ce.upload({name:e.name,type:e.type,data:await oe(e),subject:c.value})).key)),W=Eu({page:()=>s.value,info:e=>_e({text:e,kind:`info`}),failed:B,drafted(e){te.value=new Set([...te.value,e])}}),G;function K(e){if(e!==`mark`&&Ae(),d.value&&(f.value=e===`comment`&&U.value),!(d.value&&e!==`edit`&&e!==`view`)){if(e===`mark`){if(!U.value||D.value)return;if(be.value){P.value=e,F=void 0,N.value=!0;return}W.finish(!0),T.value=!1,G.exit(),ke()}else if(e===`comment`){if(!U.value)return;if(be.value){P.value=e,F=void 0,N.value=!0;return}W.finish(!0),T.value=!1,G.enter()}else if(e===`edit`){if(!r?.content||!U.value||(G.exit(),G.active.value))return;T.value=!0}else N.value=!1,F=void 0,G.exit(),T.value=!1,W.finish(!0);M.value=void 0}}let De=Q(()=>D.value?`mark`:T.value?`edit`:G?.active.value?`comment`:`view`),Oe=Q(()=>De.value===`comment`||d.value&&f.value||N.value&&P.value!==`mark`);function ke(){je(),E=Qu({tip:()=>k.value,color:()=>Mu[A.value],onChange:()=>O.value=E?.strokes().length??0,onSubmit:()=>void Me()}),O.value=0,D.value=!0}function Ae(){E?.remove(),E=void 0,O.value=0,D.value=!1}function je(){ee?.session.remove(),ee=void 0}async function Me(){let e=E;e?.commit();let t=e?.strokes()??[],n=qu(t);if(e&&n&&!j.value){j.value=!0,e.freeze();try{let r=await id(t,e=>e instanceof Element&&Pd(e));if(E!==e)return;E=void 0,D.value=!1,O.value=0,r||_e({text:`This page could not be drawn as a picture. The comment marks the area without one.`,kind:`info`});let i=r?[new File([r],`highlight.webp`,{type:r.type})]:[],a=G.draft.value,o=Md(n,ju.marker.width/2+1);try{if(o){let e=Nd(n,o);G.startDraft(o,{area:e,point:{x:e.left,y:e.top},files:i})}else G.startDraft(`page`,{files:i})}catch{}G.draft.value===a?e.remove():ee={session:e,draft:G.draft.value}}finally{j.value=!1}}}async function Ne(e=!1){if(!r?.realtime||!t.isConnected||n?.signal.aborted||pe&&!e)return;let i=++me,a=await Au(()=>import(`./client-DmsSMOzi.js`),__vite__mapDeps([0,1])).catch(()=>void 0);if(!a||i!==me||!t.isConnected||n?.signal.aborted)return;pe?.destroy();let o=V()??(I.value?{id:`guest:${I.value.id}`,name:`${I.value.name} (guest)`}:void 0),c=b(import.meta.url).slice(0,-y.length),l=a.connectRealtimeRoom(v,S(s.value),{identity:o,baseURL:c,params:{page:s.value}}),u=new Map;l.onUpdate(()=>{L.value++;let e=new Map,t=!1;for(let[n,r]of l.states())n!==l.clientId&&typeof r.commentsChange==`string`&&(e.set(n,r.commentsChange),u.get(n)!==r.commentsChange&&(t=!0));u=e,t&&Te()}),pe=l}function Pe(){me++,pe?.destroy(),pe=void 0}function Fe(){if(n){if(!R){R=n.createWindow({id:`comments`,title:`Comments`,trigger:n.bar,colorScheme:()=>`dark`,onHide:()=>C.value=!1});let e=document.createElement(`div`);e.setAttribute(`data-comments-ui`,``);let t=e.attachShadow({mode:`open`}),r=document.createElement(`div`);r.className=`panel-root dark`,t.append(fd(dd(od)),r),R.body.append(e),w.value=r}C.value=!0,R.show()}}function Ie(e){I.value=re(e),N.value=!1,Ne(!0);let t=P.value;P.value=`comment`;let n=F;if(F=void 0,n?.startContainer.isConnected){let e=getSelection();if(e?.removeAllRanges(),e?.addRange(n),Ue())return}t===`page`?Ze():K(t)}async function Le(e){await fetch(e,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`}).catch(()=>void 0),location.reload()}function Re(t){let n=t.signIn&&`${t.signIn.url}?return=${encodeURIComponent(location.pathname+location.search+location.hash)}`,r=t.github;if(r&&t.signOut){let e=t.signOut,n=r.repository?`@${r.login} cannot push to ${r.repository}, so cannot comment here.`:`Signed in as @${r.login}, but this site does not say which GitHub repository it is built from.`;_e({text:n,kind:`error`,action:[`Use another account`,()=>void Le(e)]},!0)}else _e(n?{text:`Sign in to comment on this page.`,kind:`info`,link:[`Sign in with GitHub`,n],action:[`Close`,e.exit]}:{text:`Comments are only for the site's team. Sign in with an account that may comment.`,kind:`error`,action:[`Close`,e.exit]},!0)}function ze(){let e=getSelection();if(!U.value||T.value||d.value||!e||e.isCollapsed||e.rangeCount===0||!e.toString().trim())return;let t=e.getRangeAt(0),n=t.commonAncestorContainer,r=n instanceof Element?n:n.parentElement;if(!(!r?.isConnected||Pd(r)||r.closest(`input, textarea, select, [contenteditable]:not([contenteditable='false'])`)))return t.cloneRange()}let Be,Ve=!1;function He(){if(Ve)return;Be=G?.draft.value?void 0:ze();let e=Be?.getBoundingClientRect();ue.value=e&&(e.width||e.height)?{left:e.left+e.width/2,top:e.top,bottom:e.bottom}:void 0}function Ue(e=ze()){if(Ve=!1,!e)return!1;if(be.value)return P.value=`comment`,F=e,N.value=!0,!0;W.finish(!0);let t=e.getBoundingClientRect();try{G.startDraft(e,{point:{x:t.right,y:t.top}}),getSelection()?.removeAllRanges()}catch{return!1}return Be=void 0,ue.value=void 0,!0}let We=typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight==`function`;function Ge(){if(!We)return;let e={open:[],resolved:[],active:[],draft:[]},t=new Set([G.openId.value,G.hoverId.value].filter(Boolean)),n=G.threads.value.filter(e=>G.isShown(e.id));for(let r of n){if(r.anchor.kind!==`text`||!G.isShown(r.id))continue;let n=ys(r.anchor);n&&e[t.has(r.id)?`active`:r.status===`resolved`?`resolved`:`open`].push(n)}let r=G.draft.value?.anchor;if(r?.kind===`text`){let t=ys(J(r));t&&e.draft.push(t)}for(let[t,n]of Object.entries(ud))CSS.highlights.set(n,new Highlight(...e[t]))}function Ke(){if(We)for(let e of Object.values(ud))CSS.highlights.delete(e)}let qe=Z({setup(){let e=Y(null);Kn(()=>e.value?.focus());let t=t=>{t.preventDefault();let n=e.value?.value.trim();n?Ie(n):e.value?.focus()};return()=>$(`form`,{class:`card`,role:`dialog`,"aria-label":`Your name`,onSubmit:t,onKeydown:e=>e.key===`Escape`&&(N.value=!1)},[$(`label`,[`Your name`,$(`input`,{"aria-label":`Your name`,autocomplete:`name`,maxlength:64,placeholder:`Shown next to your comments`,ref:e})]),$(`div`,{class:`row`},[$(Qs,{color:`neutral`,label:`Cancel`,onClick:()=>N.value=!1,size:`sm`,variant:`ghost`}),$(Qs,{label:`Comment`,size:`sm`,type:`submit`})])])}}),Je=Z({name:`CommentsOverlay`,setup(){return G=gl({client:we,subject:()=>c.value,location:()=>({href:location.href,origin:location.origin,search:g.value}),user:()=>H.value,people:se,hotkey:!1,ignore:Pd,can:Se,uiRoot:()=>i,autoStart:!!r?.can.read,visibility:xe}),X(De,t=>e.onMode(t),{immediate:!0,flush:`sync`}),X(()=>G.status.value,e=>{e===`ready`&&!pe&&Ne()}),X(()=>G.counts.value.open,()=>L.value++),X(ce,e=>{G.filters.resolved=e===`resolved`}),X(()=>G.filters.resolved,e=>{e&&(ce.value=`resolved`)}),X(()=>G.draft.value,e=>{if(!e||e.anchor.kind===`page`)return;let t=document.elementsFromPoint(e.point.x,e.point.y).find(e=>!Pd(e)&&e!==document.documentElement);t&&(e.anchor.kind===`element`&&(e.anchor=h(t,e.point.x,e.point.y)),ge.set(J(e.anchor),Tu(t)))},{flush:`sync`}),X([de,G.pageThreads,G.openId,G.hoverId,()=>G.draft.value?.anchor,G.shown],Ge,{flush:`post`}),X(()=>G.draft.value,He),X(()=>G.draft.value,e=>{ee&&e!==ee.draft&&je()}),()=>{let t=[];if(ye.value?.read&&!d.value){t.push($(uu,{comments:G,readOnly:!H.value,upload:U.value?Ee:void 0,attachmentUrl:Ce.attachmentUrl},{default:()=>[]})),t.push($(`div`,{class:`cursors`},$e())),t.push($(`div`,{class:`outlines`},et())),t.push(e.areas?$(wr,{to:e.areas},Qe()):$(`div`,{class:`areas`},Qe()));let n=ue.value;if(n&&!G.draft.value){let e=matchMedia(`(pointer: coarse)`).matches,r=n.bottom+(e?20:8),i=n.top<(e?102:56)||e&&r<=innerHeight-46,a=i?Math.min(r,innerHeight-46):n.top-(e?64:8);t.push($(`div`,{class:`selection-bar`,"data-below":i?`true`:void 0,role:`group`,"aria-label":`Selected text`,style:{left:`${Math.min(Math.max(64,n.left),innerWidth-64)}px`,top:`${a}px`},onPointerdown:e=>{e.preventDefault(),Ve=!0,addEventListener(`pointerup`,()=>setTimeout(()=>{Ve&&(Ve=!1,He())},300),{capture:!0,once:!0})},onMousedown:e=>e.preventDefault()},$(`button`,{type:`button`,"aria-keyshortcuts":`C`,title:`Comment on the selected text (C)`,onClick:()=>Ue(Be)},[vd(),`Comment`])))}w.value&&!d.value&&t.push($(wr,{to:w.value},$(mu,{key:s.value,comments:G,attachmentUrl:Ce.attachmentUrl,readOnly:!H.value||!G.threads.value.some(e=>e.id===le.value)&&!U.value,"onUpdate:thread":e=>le.value=e,status:ce.value,"onUpdate:status":e=>ce.value=e,title:s.value,upload:U.value?Ee:void 0,onSelect:e=>{let t=G.positions.value.get(e.id);t&&!t.detached&&t.element?.scrollIntoView({block:`center`,behavior:`smooth`})}})))}ye.value?.read&&e.toolbar&&t.push($(wr,{to:e.toolbar},q())),N.value&&t.push($(qe));let n=_.value;return n&&t.push($(`div`,{class:`toast`,role:`status`,"data-kind":n.kind},[$(`span`,n.text),n.link?$(`a`,{href:n.link[1]},n.link[0]):null,n.action?$(Qs,{color:`neutral`,label:n.action[0],onClick:n.action[1],size:`sm`,variant:`ghost`}):null])),t}}});function Ye(e){k.value=e,E?.restyle()}function Xe(){let e=j.value,t=e=>e.preventDefault();return $(`div`,{class:`toolbar`,role:`group`,"aria-label":`Highlight`},[$(`div`,{class:`swatches`},Object.keys(ju).map(t=>$(`button`,{key:t,class:`swatch`,type:`button`,"aria-label":ju[t].label,"aria-keyshortcuts":ju[t].key,"aria-pressed":String(k.value===t),title:`${ju[t].label} (${ju[t].key})`,disabled:e,onClick:()=>Ye(t)},bd[t]()))),$(`span`,{class:`sep`}),$(`div`,{class:`swatches`},Object.keys(Mu).map(n=>$(`button`,{key:n,class:`swatch`,type:`button`,"aria-label":`${n[0].toUpperCase()}${n.slice(1)} ink`,"aria-pressed":String(A.value===n),disabled:e,onMousedown:t,onClick:()=>{A.value=n,E?.restyle()}},$(`span`,{style:{background:Mu[n]}})))),$(`span`,{class:`sep`}),$(`button`,{type:`button`,class:`icon`,"aria-label":`Undo`,"aria-keyshortcuts":`Meta+Z Control+Z`,title:`Undo`,disabled:e||O.value===0,onClick:()=>E?.undo()},Sd()),$(`button`,{type:`button`,disabled:e,onClick:()=>K(`view`),title:`Cancel (Esc)`},`Cancel`),$(`button`,{type:`button`,class:`done`,"aria-keyshortcuts":`Enter`,"aria-busy":e?`true`:void 0,disabled:!e&&O.value===0,onClick:()=>void Me(),title:`Comment on the highlighted area (Enter)`},e?`Taking picture…`:`Done`)])}function Ze(){if(U.value&&!d.value){if(be.value){P.value=`page`,F=void 0,N.value=!0;return}W.finish(!0),G.startDraft(`page`)}}function q(){if(L.value,D.value||j.value)return Xe();let e=r?.signOut,t=e?r?.github:void 0,n=ve?pd(pe?.people()??[],H.value?.id):[],i=n.slice(0,5).map(({person:e,tabs:t})=>$(`span`,{class:`avatar`,key:e.id,title:t>1?`${e.name} · ${t} tabs`:e.name,style:{background:e.color}},e.image?$(`img`,{src:e.image,alt:``}):md(e.name))),a=`${n.length} other ${n.length===1?`person`:`people`} on this page`,o=G.counts.value.open,s=Oe.value,c=e=>e&&o>0?$(`span`,{class:`count`},String(o)):null,l=()=>C.value?R?.hide():Fe();return $(`div`,{class:`toolbar`,role:`group`,"aria-label":`Comments`},[U.value?$(`button`,{"aria-keyshortcuts":`C`,"aria-label":s?`Comments: click anywhere on the page`:o?`Comments, ${o} open`:`Comments`,"aria-pressed":String(s),onClick:()=>K(s?`view`:`comment`),title:s?`Stop commenting (C)`:`Comment on the page (C)`,type:`button`},[vd(),s?`Click anywhere`:`Comments`,c(!s)]):$(`button`,{"aria-expanded":String(C.value),"aria-label":o?`Comments, ${o} open`:`Comments`,onClick:l,title:`Show comments`,type:`button`},[vd(),`Comments`,c(!0)]),U.value?$(`button`,{"aria-label":`Hide comments`,"aria-pressed":String(xe.value===`hidden`),class:`eye`,onClick:()=>xe.value=xe.value===`hidden`?`all`:`hidden`,title:xe.value===`hidden`?`Show comments`:`Hide comments`,type:`button`},xe.value===`hidden`?Dd():Ed()):null,s?$(`div`,{class:`actions`,role:`group`,"aria-label":`Comment actions`},[$(`span`,{class:`divider`,"aria-hidden":`true`}),$(`button`,{onClick:Ze,title:`Comment on the whole page`,type:`button`},[Cd(),`Whole page`]),$(`button`,{"aria-expanded":String(C.value),onClick:l,title:`All comments on this page`,type:`button`},[jd(),`All comments`,c(!C.value)]),$(`button`,{"aria-label":`Stop commenting`,onClick:()=>K(`view`),title:`Stop commenting (Esc)`,type:`button`},Td()),$(`span`,{class:`divider`,"aria-hidden":`true`})]):null,U.value?$(`button`,{"aria-keyshortcuts":`B`,"aria-pressed":`false`,onClick:()=>K(`mark`),title:`Highlight the page and comment (B)`,type:`button`},[yd(),`Highlight`]):null,r?.content&&U.value?$(`button`,{"aria-keyshortcuts":`E`,"aria-pressed":String(De.value===`edit`),onClick:()=>K(De.value===`edit`?`view`:`edit`),title:`Edit text (E)`,type:`button`},[wd(),`Edit`]):null,i.length>0?$(`span`,{"aria-label":a,class:`people`},i):null,e&&t?$(`button`,{"aria-label":`Sign out @${t.login}`,onClick:()=>void Le(e),title:`Signed in as @${t.login}. Sign out`,type:`button`},r?.user?.image?$(`img`,{alt:``,class:`me`,src:r.user.image}):md(r?.user?.name??t.login)):null])}function Qe(){let e=[],t=(t,n,r)=>{let i=G.positions.value.get(t);if(!i||i.detached||i.clipped||n!==`area`&&n!==`image`||!i.width||!i.height)return;let a=t!==`draft`&&G.leaving.value.has(t);(t===`draft`||a||G.isShown(t))&&e.push($(`div`,{key:t,"data-leaving":a?`true`:void 0,"data-active":r.active?`true`:void 0,"data-draft":r.draft?`true`:void 0,"data-slot":`comment-mark-area`,"data-status":r.status,style:{left:`${i.x}px`,top:`${i.y}px`,width:`${i.width}px`,height:`${i.height}px`}}))},n=new Set([G.openId.value,G.hoverId.value]);for(let e of G.threads.value)t(e.id,e.anchor.kind,{status:e.status,active:n.has(e.id)});let r=G.draft.value;return r&&t(`draft`,r.anchor.kind,{draft:!0}),e}function $e(){L.value;let e=[];if(!ve)return e;for(let[t,n]of pe?.states()??[]){let r=n.cursor,i=n.user;if(!r||!i?.id||i.id===H.value?.id)continue;let a=null;try{a=document.querySelector(r.selector)}catch{}if(!a)continue;let o=a.getBoundingClientRect(),s=typeof i.color==`string`&&/^#[\da-f]{6}$/i.test(i.color)?i.color:hd(i.id);e.push($(`div`,{class:`cursor`,key:t,style:{left:`${o.left+r.x/1e3*o.width}px`,top:`${o.top+r.y/1e3*o.height}px`}},[$(`svg`,{width:15,height:15,viewBox:`0 0 24 24`,"aria-hidden":`true`},$(`path`,{d:`M4 2l16 7-7 2-3 8z`,fill:s,stroke:`#000`,"stroke-width":1.5})),$(`span`,{style:{background:s}},i.name??`Someone`)]))}return e}function et(){if(L.value,!T.value)return[];let e=[];for(let t of document.querySelectorAll(`[${o}]`)){let n=t.getAttribute(o),r=t===M.value?`hover`:te.value.has(n)?`draft`:void 0;if(!r)continue;let i=t.getBoundingClientRect();e.push($(`div`,{class:`outline`,"data-kind":r,key:`${n}-outline`,style:{left:`${i.left-3}px`,top:`${i.top-3}px`,width:`${i.width+6}px`,height:`${i.height+6}px`}})),e.push($(`div`,{class:`tag`,key:`${n}-tag`,style:{left:`${i.left-3}px`,top:`${i.top-3}px`}},r===`draft`?`Draft`:n))}return e}let tt=Do(Je);tc(tt),tt.mount(a),r&&!r.can.read?e.prompt!==!1&&Re(r):e.failure&&_e({text:e.failure.why,kind:`error`,action:[`Close`,e.exit]},!0);let nt;function rt(){_.value===nt&&(_.value=void 0),nt=void 0}function it(e){let t=++p;ie.session(e).then(async([n,r])=>{if(t!==p||s.value!==e)return;if(n){nt={text:`${n.why} Comments are paused on this page.`,kind:`error`,action:[`Retry`,()=>{s.value===e&&it(e)}]},_e(nt,!0);return}rt(),ye.value=r.can,l=r.revision;let i=r.subject??{kind:`page`,id:e};if(i.kind!==c.value.kind||i.id!==c.value.id?c.value=i:!pe&&G.status.value===`ready`&&Ne(),await Kn(),t!==p)return;d.value=!1;let a=f.value;f.value=!1,a&&K(`comment`)})}let at=()=>[i,w.value?.getRootNode()].some(e=>e instanceof ShadowRoot&&e.querySelector(`[data-slot='comment-composer'][data-dirty='true']`)!==null);return{app:tt,hasUnsentComment:at,showPanel:Fe,setMode:K,finishEdit:W.finish,navigated(e){if(e===s.value){g.value=location.search;return}if(at()){if(!window.confirm(`Discard your unsent comment and show comments for the new page?`))return;G.cancelDraft()}N.value=!1,F=void 0,s.value=e,g.value=location.search,le.value=null,D.value&&K(`view`),je(),rt(),f.value=f.value||G.active.value,G.active.value=!1,d.value=!0,it(e),Pe()},refresh:Te,pointer(e,t){if(T.value){let e=t?m(t):void 0;e!==M.value&&(M.value=e)}if(!pe||!t||!ve)return;let n=t.getBoundingClientRect();pe.setLocal(`cursor`,{selector:u(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})},leave:()=>pe?.setLocal(`cursor`,null),layout:e=>{L.value++,e&&de.value++,ue.value&&He()},selectionChanged:He,promptAccess:()=>{r&&!r.can.read&&Re(r)},editMode:()=>T.value,editElement:()=>W.element,startEdit:e=>W.start(e),key(e){if(e.key===`Escape`&&T.value){K(`view`);return}if(D.value&&(e.key!==`b`||k.value!==`marker`)){let t=xd(e);if(t)Ye(t);else if(e.key===`Escape`)K(`view`);else if(e.key===`Enter`)Me();else if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`)E?.undo();else if(![` `,`PageUp`,`PageDown`,`Home`,`End`,`ArrowUp`,`ArrowDown`].includes(e.key))return;e.preventDefault();return}_d(e)||e.metaKey||e.ctrlKey||e.altKey||(e.key===`c`&&U.value&&(e.preventDefault(),Ue()||K(Oe.value?`view`:`comment`)),e.key===`b`&&U.value&&(e.preventDefault(),K(De.value===`mark`?`view`:`mark`)),e.key===`e`&&r?.content&&U.value&&(e.preventDefault(),K(De.value===`edit`?`view`:`edit`)))},destroy(){Ae(),je(),Ke(),clearTimeout(z),W.finish(!1),Pe(),tt.unmount(),R?.destroy()}}}function Id(e){let t=document.createElement(`style`);return t.textContent=e,t}var Ld=class extends HTMLElement{context;documentStyle=Id(`@layer components {\n${a}\n}\n${cd}`);areas=document.createElement(`vitehub-comment-areas`);toolbar=document.createElement(`div`);control;mode=`view`;frame=0;changed=!1;lastCursor=0;cleanups=[];get active(){return this.isConnected&&!this.context?.signal.aborted}async connectedCallback(){this.setAttribute(`data-comments-ui`,``),this.shadowRoot||this.attachShadow({mode:`open`});let e=this.context?.bar;if(e){e.tabIndex=-1,e.setAttribute(`data-comments-ui`,``);let t=e.shadowRoot??e.attachShadow({mode:`open`}),n=document.createElement(`button`);n.disabled=!0,n.setAttribute(`aria-busy`,`true`),n.textContent=this.context?.tool.label??`Comments`,t.replaceChildren(Id(i+sd),this.toolbar),this.toolbar.replaceChildren(n)}this.restoreDocumentState(),this.cleanups.push(()=>this.documentStyle.remove());let t=this.areas.shadowRoot??this.areas.attachShadow({mode:`open`});t.replaceChildren(Id(a+ld)),this.areas.setAttribute(`data-comments-ui`,``),document.documentElement.append(this.areas),this.cleanups.push(()=>this.areas.remove()),this.followTheme();let[n,r]=await ie.session(x(location.pathname)),o=this.active&&!n&&r.can.read;if(e&&(e.hidden=!o),this.active){if(this.toolbar.replaceChildren(),this.control=Fd({host:this,...this.context?{context:this.context}:{},...e?{toolbar:this.toolbar}:{},areas:t,...n?{failure:n}:{session:r},onMode:e=>{this.mode=e,this.restoreDocumentState()},exit:()=>this.context?.exit(),prompt:this.context?.open!==!1}),!o){if(e&&r&&this.active&&!this.context?.open&&(r.signIn||r.signOut)){let t=document.createElement(`button`);t.type=`button`,t.textContent=this.context?.tool.label??`Comments`,t.addEventListener(`click`,()=>this.control?.promptAccess()),this.toolbar.replaceChildren(t),e.hidden=!1}return}this.listen(),this.context?.onOpen(()=>this.control?.showPanel()),this.context?.beforeExit(()=>!this.control?.hasUnsentComment()||window.confirm(`Turn off tools without sending your comment?`)),this.context?.open&&!new URLSearchParams(location.search).has(`comment`)&&this.control.showPanel()}}disconnectedCallback(){for(let e of this.cleanups.splice(0))e();cancelAnimationFrame(this.frame),this.control?.destroy(),this.control=void 0}followTheme(){let e=()=>{let e=gd();this.style.colorScheme=e?`dark`:`light`,this.classList.toggle(`dark`,e),this.areas.classList.toggle(`dark`,e),this.dataset.theme=e?`dark`:`light`;let t=`@layer components {\n${a}\n:root { --vh-comment-ink: var(--vh-ui-comment-ink, var(--vh-highlighted, ${getComputedStyle(this.areas).getPropertyValue(`--vh-comment-default-ink`).trim()})); }\n}\n${cd}`;this.documentStyle.textContent!==t&&(this.documentStyle.textContent=t)};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))}schedule(){cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{let e=this.changed;this.changed=!1,this.control?.layout(e)})}listen(){let e=()=>this.schedule();this.on(window,`scroll`,e,{capture:!0,passive:!0}),this.on(window,`resize`,e);let t=new MutationObserver(t=>{if(t.every(e=>e.target===this||this.contains(e.target)))return;let n=this.control?.editElement();n&&!n.isConnected&&this.control?.finishEdit(!0),this.restoreDocumentState(),this.changed=!0,e()});t.observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`style`,`hidden`]}),this.cleanups.push(()=>t.disconnect());let n=()=>queueMicrotask(()=>{this.active&&this.control?.navigated(x(location.pathname))});for(let e of[`astro:before-swap`,`turbo:before-render`])this.on(document,e,()=>void this.control?.finishEdit(!0));for(let e of[`pushState`,`replaceState`]){let t=history[e];history[e]=function(...e){let r=t.apply(this,e);return n(),r},this.cleanups.push(()=>{history[e]=t})}this.on(window,`popstate`,n);let r,i=e=>{clearTimeout(r),r=setTimeout(()=>this.control?.selectionChanged(),e)};this.on(document,`selectionchange`,()=>i(200)),this.on(document,`pointerup`,()=>i(0)),this.cleanups.push(()=>clearTimeout(r)),this.on(document,`pointermove`,e=>this.pointerMoved(e),{passive:!0}),this.on(document,`pointerleave`,()=>this.control?.leave()),this.on(document,`click`,e=>this.clicked(e),{capture:!0}),this.on(document,`keydown`,e=>this.control?.key(e)),this.on(document,`visibilitychange`,()=>{document.visibilityState===`visible`&&this.control?.refresh()});let a=setInterval(()=>{document.visibilityState===`visible`&&this.control?.refresh()},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){this.ours(e)||!this.control?.editMode()&&e.timeStamp-this.lastCursor<80||(this.lastCursor=e.timeStamp,this.control?.pointer(e,this.elementAt(e.clientX,e.clientY)))}clicked(e){if(this.ours(e)||!this.control?.editMode())return;let t=this.elementAt(e.clientX,e.clientY),n=t?m(t):void 0;n&&n!==this.control.editElement()&&(e.preventDefault(),e.stopPropagation(),this.control.startEdit(n))}restoreDocumentState(){this.documentStyle.parentElement!==document.head&&document.head.append(this.documentStyle);for(let e of[`comment`,`edit`]){let t=`vitehub-${e}-mode`,n=this.mode===e;document.documentElement.classList.contains(t)!==n&&document.documentElement.classList.toggle(t,n)}}stop(){this.control?.finishEdit(!1),this.control?.setMode(`view`),this.mode=`view`,this.restoreDocumentState(),this.remove()}},Rd=e=>{customElements.get(`vitehub-comments`)||customElements.define(`vitehub-comments`,Ld);let t=document.createElement(`vitehub-comments`);if(t instanceof Ld)return t.context=e,document.documentElement.append(t),()=>t.stop()};export{Rd as default};